langgraph-agent-builder 0.1.0__py3-none-any.whl

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 (34) hide show
  1. langgraph_agent_builder/__init__.py +3 -0
  2. langgraph_agent_builder/_static/assets/BuilderPage-DgZ49R8V.js +143 -0
  3. langgraph_agent_builder/_static/assets/index-BcxBgLEG.css +1 -0
  4. langgraph_agent_builder/_static/assets/index-D08c-Z-o.js +137 -0
  5. langgraph_agent_builder/_static/assets/instrument-sans-latin-ext-wght-normal-B5bTHO_g.woff2 +0 -0
  6. langgraph_agent_builder/_static/assets/instrument-sans-latin-wght-normal-BbzFLZTg.woff2 +0 -0
  7. langgraph_agent_builder/_static/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  8. langgraph_agent_builder/_static/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  9. langgraph_agent_builder/_static/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  10. langgraph_agent_builder/_static/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  11. langgraph_agent_builder/_static/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  12. langgraph_agent_builder/_static/index.html +13 -0
  13. langgraph_agent_builder/api/__init__.py +1 -0
  14. langgraph_agent_builder/api/catalog.py +15 -0
  15. langgraph_agent_builder/api/config.py +40 -0
  16. langgraph_agent_builder/api/deps.py +29 -0
  17. langgraph_agent_builder/api/flows.py +257 -0
  18. langgraph_agent_builder/api/resources.py +41 -0
  19. langgraph_agent_builder/app.py +173 -0
  20. langgraph_agent_builder/auth.py +112 -0
  21. langgraph_agent_builder/cli.py +41 -0
  22. langgraph_agent_builder/errors.py +33 -0
  23. langgraph_agent_builder/node_types.py +302 -0
  24. langgraph_agent_builder/py.typed +1 -0
  25. langgraph_agent_builder/serialization.py +139 -0
  26. langgraph_agent_builder/services/__init__.py +1 -0
  27. langgraph_agent_builder/services/db.py +52 -0
  28. langgraph_agent_builder/services/flows.py +111 -0
  29. langgraph_agent_builder/services/runtime.py +190 -0
  30. langgraph_agent_builder/services/settings.py +81 -0
  31. langgraph_agent_builder-0.1.0.dist-info/METADATA +71 -0
  32. langgraph_agent_builder-0.1.0.dist-info/RECORD +34 -0
  33. langgraph_agent_builder-0.1.0.dist-info/WHEEL +4 -0
  34. langgraph_agent_builder-0.1.0.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,143 @@
1
+ import{c as ce,r as ro,g as lc,R as uc,a as C,j as h,b as pe,u as Ue,D as or,L as se,I as ae,B as de,d as qe,P as so,e as fe,t as He,A as On,f as dc,h as Dr,i as fc,k as hc,m as pc,l as wt,T as at,n as gc,o as ir,X as mc,C as oo,p as io,q as xc,s as yc,v as wc,w as Lr}from"./index-D08c-Z-o.js";/**
2
+ * @license lucide-react v0.468.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const vc=ce("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
7
+ * @license lucide-react v0.468.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const bc=ce("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/**
12
+ * @license lucide-react v0.468.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const ar=ce("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
17
+ * @license lucide-react v0.468.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const _c=ce("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
22
+ * @license lucide-react v0.468.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Nc=ce("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]);/**
27
+ * @license lucide-react v0.468.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const ao=ce("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
32
+ * @license lucide-react v0.468.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const Ec=ce("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
37
+ * @license lucide-react v0.468.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const Sc=ce("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
42
+ * @license lucide-react v0.468.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */const Fn=ce("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
47
+ * @license lucide-react v0.468.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */const Cc=ce("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/**
52
+ * @license lucide-react v0.468.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const kc=ce("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
57
+ * @license lucide-react v0.468.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */const jc=ce("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
62
+ * @license lucide-react v0.468.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */const Mc=ce("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
67
+ * @license lucide-react v0.468.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */const Ac=ce("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/**
72
+ * @license lucide-react v0.468.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */const co=ce("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/**
77
+ * @license lucide-react v0.468.0 - ISC
78
+ *
79
+ * This source code is licensed under the ISC license.
80
+ * See the LICENSE file in the root directory of this source tree.
81
+ */const $c=ce("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
82
+ * @license lucide-react v0.468.0 - ISC
83
+ *
84
+ * This source code is licensed under the ISC license.
85
+ * See the LICENSE file in the root directory of this source tree.
86
+ */const Ic=ce("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
87
+ * @license lucide-react v0.468.0 - ISC
88
+ *
89
+ * This source code is licensed under the ISC license.
90
+ * See the LICENSE file in the root directory of this source tree.
91
+ */const Tc=ce("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
92
+ * @license lucide-react v0.468.0 - ISC
93
+ *
94
+ * This source code is licensed under the ISC license.
95
+ * See the LICENSE file in the root directory of this source tree.
96
+ */const Pc=ce("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/**
97
+ * @license lucide-react v0.468.0 - ISC
98
+ *
99
+ * This source code is licensed under the ISC license.
100
+ * See the LICENSE file in the root directory of this source tree.
101
+ */const cr=ce("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
102
+ * @license lucide-react v0.468.0 - ISC
103
+ *
104
+ * This source code is licensed under the ISC license.
105
+ * See the LICENSE file in the root directory of this source tree.
106
+ */const zc=ce("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
107
+ * @license lucide-react v0.468.0 - ISC
108
+ *
109
+ * This source code is licensed under the ISC license.
110
+ * See the LICENSE file in the root directory of this source tree.
111
+ */const Dc=ce("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/**
112
+ * @license lucide-react v0.468.0 - ISC
113
+ *
114
+ * This source code is licensed under the ISC license.
115
+ * See the LICENSE file in the root directory of this source tree.
116
+ */const lo=ce("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);function ue(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=ue(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Lc={value:()=>{}};function gn(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Qt(n)}function Qt(e){this._=e}function Rc(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Qt.prototype=gn.prototype={constructor:Qt,on:function(e,t){var n=this._,r=Rc(e+"",n),s,i=-1,o=r.length;if(arguments.length<2){for(;++i<o;)if((s=(e=r[i]).type)&&(s=Hc(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<o;)if(s=(e=r[i]).type)n[s]=Rr(n[s],e.name,t);else if(t==null)for(s in n)n[s]=Rr(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Qt(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,i;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,s=i.length;r<s;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,i=r.length;s<i;++s)r[s].value.apply(t,n)}};function Hc(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function Rr(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=Lc,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Yn="http://www.w3.org/1999/xhtml";const Hr={svg:"http://www.w3.org/2000/svg",xhtml:Yn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function mn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Hr.hasOwnProperty(t)?{space:Hr[t],local:e}:e}function Vc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Yn&&t.documentElement.namespaceURI===Yn?t.createElement(e):t.createElementNS(n,e)}}function Bc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function uo(e){var t=mn(e);return(t.local?Bc:Vc)(t)}function Oc(){}function lr(e){return e==null?Oc:function(){return this.querySelector(e)}}function Fc(e){typeof e!="function"&&(e=lr(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],o=i.length,a=r[s]=new Array(o),u,l,d=0;d<o;++d)(u=i[d])&&(l=e.call(u,u.__data__,d,i))&&("__data__"in u&&(l.__data__=u.__data__),a[d]=l);return new me(r,this._parents)}function Yc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Xc(){return[]}function fo(e){return e==null?Xc:function(){return this.querySelectorAll(e)}}function qc(e){return function(){return Yc(e.apply(this,arguments))}}function Wc(e){typeof e=="function"?e=qc(e):e=fo(e);for(var t=this._groups,n=t.length,r=[],s=[],i=0;i<n;++i)for(var o=t[i],a=o.length,u,l=0;l<a;++l)(u=o[l])&&(r.push(e.call(u,u.__data__,l,o)),s.push(u));return new me(r,s)}function ho(e){return function(){return this.matches(e)}}function po(e){return function(t){return t.matches(e)}}var Uc=Array.prototype.find;function Kc(e){return function(){return Uc.call(this.children,e)}}function Gc(){return this.firstElementChild}function Zc(e){return this.select(e==null?Gc:Kc(typeof e=="function"?e:po(e)))}var Qc=Array.prototype.filter;function Jc(){return Array.from(this.children)}function el(e){return function(){return Qc.call(this.children,e)}}function tl(e){return this.selectAll(e==null?Jc:el(typeof e=="function"?e:po(e)))}function nl(e){typeof e!="function"&&(e=ho(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],o=i.length,a=r[s]=[],u,l=0;l<o;++l)(u=i[l])&&e.call(u,u.__data__,l,i)&&a.push(u);return new me(r,this._parents)}function go(e){return new Array(e.length)}function rl(){return new me(this._enter||this._groups.map(go),this._parents)}function rn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}rn.prototype={constructor:rn,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 sl(e){return function(){return e}}function ol(e,t,n,r,s,i){for(var o=0,a,u=t.length,l=i.length;o<l;++o)(a=t[o])?(a.__data__=i[o],r[o]=a):n[o]=new rn(e,i[o]);for(;o<u;++o)(a=t[o])&&(s[o]=a)}function il(e,t,n,r,s,i,o){var a,u,l=new Map,d=t.length,c=i.length,f=new Array(d),p;for(a=0;a<d;++a)(u=t[a])&&(f[a]=p=o.call(u,u.__data__,a,t)+"",l.has(p)?s[a]=u:l.set(p,u));for(a=0;a<c;++a)p=o.call(e,i[a],a,i)+"",(u=l.get(p))?(r[a]=u,u.__data__=i[a],l.delete(p)):n[a]=new rn(e,i[a]);for(a=0;a<d;++a)(u=t[a])&&l.get(f[a])===u&&(s[a]=u)}function al(e){return e.__data__}function cl(e,t){if(!arguments.length)return Array.from(this,al);var n=t?il:ol,r=this._parents,s=this._groups;typeof e!="function"&&(e=sl(e));for(var i=s.length,o=new Array(i),a=new Array(i),u=new Array(i),l=0;l<i;++l){var d=r[l],c=s[l],f=c.length,p=ll(e.call(d,d&&d.__data__,l,r)),g=p.length,v=a[l]=new Array(g),w=o[l]=new Array(g),y=u[l]=new Array(f);n(d,c,v,w,y,p,t);for(var b=0,m=0,x,N;b<g;++b)if(x=v[b]){for(b>=m&&(m=b+1);!(N=w[m])&&++m<g;);x._next=N||null}}return o=new me(o,r),o._enter=a,o._exit=u,o}function ll(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ul(){return new me(this._exit||this._groups.map(go),this._parents)}function dl(e,t,n){var r=this.enter(),s=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?i.remove():n(i),r&&s?r.merge(s).order():s}function fl(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,i=r.length,o=Math.min(s,i),a=new Array(s),u=0;u<o;++u)for(var l=n[u],d=r[u],c=l.length,f=a[u]=new Array(c),p,g=0;g<c;++g)(p=l[g]||d[g])&&(f[g]=p);for(;u<s;++u)a[u]=n[u];return new me(a,this._parents)}function hl(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,i=r[s],o;--s>=0;)(o=r[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function pl(e){e||(e=gl);function t(c,f){return c&&f?e(c.__data__,f.__data__):!c-!f}for(var n=this._groups,r=n.length,s=new Array(r),i=0;i<r;++i){for(var o=n[i],a=o.length,u=s[i]=new Array(a),l,d=0;d<a;++d)(l=o[d])&&(u[d]=l);u.sort(t)}return new me(s,this._parents).order()}function gl(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ml(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function xl(){return Array.from(this)}function yl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length;s<i;++s){var o=r[s];if(o)return o}return null}function wl(){let e=0;for(const t of this)++e;return e}function vl(){return!this.node()}function bl(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],i=0,o=s.length,a;i<o;++i)(a=s[i])&&e.call(a,a.__data__,i,s);return this}function _l(e){return function(){this.removeAttribute(e)}}function Nl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function El(e,t){return function(){this.setAttribute(e,t)}}function Sl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Cl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function kl(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 jl(e,t){var n=mn(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Nl:_l:typeof t=="function"?n.local?kl:Cl:n.local?Sl:El)(n,t))}function mo(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Ml(e){return function(){this.style.removeProperty(e)}}function Al(e,t,n){return function(){this.style.setProperty(e,t,n)}}function $l(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Il(e,t,n){return arguments.length>1?this.each((t==null?Ml:typeof t=="function"?$l:Al)(e,t,n??"")):ct(this.node(),e)}function ct(e,t){return e.style.getPropertyValue(t)||mo(e).getComputedStyle(e,null).getPropertyValue(t)}function Tl(e){return function(){delete this[e]}}function Pl(e,t){return function(){this[e]=t}}function zl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Dl(e,t){return arguments.length>1?this.each((t==null?Tl:typeof t=="function"?zl:Pl)(e,t)):this.node()[e]}function xo(e){return e.trim().split(/^|\s+/)}function ur(e){return e.classList||new yo(e)}function yo(e){this._node=e,this._names=xo(e.getAttribute("class")||"")}yo.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 wo(e,t){for(var n=ur(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function vo(e,t){for(var n=ur(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function Ll(e){return function(){wo(this,e)}}function Rl(e){return function(){vo(this,e)}}function Hl(e,t){return function(){(t.apply(this,arguments)?wo:vo)(this,e)}}function Vl(e,t){var n=xo(e+"");if(arguments.length<2){for(var r=ur(this.node()),s=-1,i=n.length;++s<i;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?Hl:t?Ll:Rl)(n,t))}function Bl(){this.textContent=""}function Ol(e){return function(){this.textContent=e}}function Fl(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Yl(e){return arguments.length?this.each(e==null?Bl:(typeof e=="function"?Fl:Ol)(e)):this.node().textContent}function Xl(){this.innerHTML=""}function ql(e){return function(){this.innerHTML=e}}function Wl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Ul(e){return arguments.length?this.each(e==null?Xl:(typeof e=="function"?Wl:ql)(e)):this.node().innerHTML}function Kl(){this.nextSibling&&this.parentNode.appendChild(this)}function Gl(){return this.each(Kl)}function Zl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ql(){return this.each(Zl)}function Jl(e){var t=typeof e=="function"?e:uo(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function eu(){return null}function tu(e,t){var n=typeof e=="function"?e:uo(e),r=t==null?eu:typeof t=="function"?t:lr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function nu(){var e=this.parentNode;e&&e.removeChild(this)}function ru(){return this.each(nu)}function su(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ou(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function iu(e){return this.select(e?ou:su)}function au(e){return arguments.length?this.property("__data__",e):this.node().__data__}function cu(e){return function(t){e.call(this,t,this.__data__)}}function lu(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function uu(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,i;n<s;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function du(e,t,n){return function(){var r=this.__on,s,i=cu(t);if(r){for(var o=0,a=r.length;o<a;++o)if((s=r[o]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=n),s.value=t;return}}this.addEventListener(e.type,i,n),s={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(s):this.__on=[s]}}function fu(e,t,n){var r=lu(e+""),s,i=r.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var u=0,l=a.length,d;u<l;++u)for(s=0,d=a[u];s<i;++s)if((o=r[s]).type===d.type&&o.name===d.name)return d.value}return}for(a=t?du:uu,s=0;s<i;++s)this.each(a(r[s],t,n));return this}function bo(e,t,n){var r=mo(e),s=r.CustomEvent;typeof s=="function"?s=new s(t,n):(s=r.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function hu(e,t){return function(){return bo(this,e,t)}}function pu(e,t){return function(){return bo(this,e,t.apply(this,arguments))}}function gu(e,t){return this.each((typeof t=="function"?pu:hu)(e,t))}function*mu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length,o;s<i;++s)(o=r[s])&&(yield o)}var _o=[null];function me(e,t){this._groups=e,this._parents=t}function Pt(){return new me([[document.documentElement]],_o)}function xu(){return this}me.prototype=Pt.prototype={constructor:me,select:Fc,selectAll:Wc,selectChild:Zc,selectChildren:tl,filter:nl,data:cl,enter:rl,exit:ul,join:dl,merge:fl,selection:xu,order:hl,sort:pl,call:ml,nodes:xl,node:yl,size:wl,empty:vl,each:bl,attr:jl,style:Il,property:Dl,classed:Vl,text:Yl,html:Ul,raise:Gl,lower:Ql,append:Jl,insert:tu,remove:ru,clone:iu,datum:au,on:fu,dispatch:gu,[Symbol.iterator]:mu};function ge(e){return typeof e=="string"?new me([[document.querySelector(e)]],[document.documentElement]):new me([[e]],_o)}function yu(e){let t;for(;t=e.sourceEvent;)e=t;return e}function we(e,t){if(e=yu(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const wu={passive:!1},_t={capture:!0,passive:!1};function jn(e){e.stopImmediatePropagation()}function ot(e){e.preventDefault(),e.stopImmediatePropagation()}function No(e){var t=e.document.documentElement,n=ge(e).on("dragstart.drag",ot,_t);"onselectstart"in t?n.on("selectstart.drag",ot,_t):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Eo(e,t){var n=e.document.documentElement,r=ge(e).on("dragstart.drag",null);t&&(r.on("click.drag",ot,_t),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Ft=e=>()=>e;function Xn(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:o,y:a,dx:u,dy:l,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:d}})}Xn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function vu(e){return!e.ctrlKey&&!e.button}function bu(){return this.parentNode}function _u(e,t){return t??{x:e.x,y:e.y}}function Nu(){return navigator.maxTouchPoints||"ontouchstart"in this}function So(){var e=vu,t=bu,n=_u,r=Nu,s={},i=gn("start","drag","end"),o=0,a,u,l,d,c=0;function f(x){x.on("mousedown.drag",p).filter(r).on("touchstart.drag",w).on("touchmove.drag",y,wu).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(x,N){if(!(d||!e.call(this,x,N))){var E=m(this,t.call(this,x,N),x,N,"mouse");E&&(ge(x.view).on("mousemove.drag",g,_t).on("mouseup.drag",v,_t),No(x.view),jn(x),l=!1,a=x.clientX,u=x.clientY,E("start",x))}}function g(x){if(ot(x),!l){var N=x.clientX-a,E=x.clientY-u;l=N*N+E*E>c}s.mouse("drag",x)}function v(x){ge(x.view).on("mousemove.drag mouseup.drag",null),Eo(x.view,l),ot(x),s.mouse("end",x)}function w(x,N){if(e.call(this,x,N)){var E=x.changedTouches,j=t.call(this,x,N),I=E.length,P,O;for(P=0;P<I;++P)(O=m(this,j,x,N,E[P].identifier,E[P]))&&(jn(x),O("start",x,E[P]))}}function y(x){var N=x.changedTouches,E=N.length,j,I;for(j=0;j<E;++j)(I=s[N[j].identifier])&&(ot(x),I("drag",x,N[j]))}function b(x){var N=x.changedTouches,E=N.length,j,I;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),j=0;j<E;++j)(I=s[N[j].identifier])&&(jn(x),I("end",x,N[j]))}function m(x,N,E,j,I,P){var O=i.copy(),k=we(P||E,N),T,H,_;if((_=n.call(x,new Xn("beforestart",{sourceEvent:E,target:f,identifier:I,active:o,x:k[0],y:k[1],dx:0,dy:0,dispatch:O}),j))!=null)return T=_.x-k[0]||0,H=_.y-k[1]||0,function A(S,$,z){var M=k,R;switch(S){case"start":s[I]=A,R=o++;break;case"end":delete s[I],--o;case"drag":k=we(z||$,N),R=o;break}O.call(S,x,new Xn(S,{sourceEvent:$,subject:_,target:f,identifier:I,active:R,x:k[0]+T,y:k[1]+H,dx:k[0]-M[0],dy:k[1]-M[1],dispatch:O}),j)}}return f.filter=function(x){return arguments.length?(e=typeof x=="function"?x:Ft(!!x),f):e},f.container=function(x){return arguments.length?(t=typeof x=="function"?x:Ft(x),f):t},f.subject=function(x){return arguments.length?(n=typeof x=="function"?x:Ft(x),f):n},f.touchable=function(x){return arguments.length?(r=typeof x=="function"?x:Ft(!!x),f):r},f.on=function(){var x=i.on.apply(i,arguments);return x===i?f:x},f.clickDistance=function(x){return arguments.length?(c=(x=+x)*x,f):Math.sqrt(c)},f}function dr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Co(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function zt(){}var Nt=.7,sn=1/Nt,it="\\s*([+-]?\\d+)\\s*",Et="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",je="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Eu=/^#([0-9a-f]{3,8})$/,Su=new RegExp(`^rgb\\(${it},${it},${it}\\)$`),Cu=new RegExp(`^rgb\\(${je},${je},${je}\\)$`),ku=new RegExp(`^rgba\\(${it},${it},${it},${Et}\\)$`),ju=new RegExp(`^rgba\\(${je},${je},${je},${Et}\\)$`),Mu=new RegExp(`^hsl\\(${Et},${je},${je}\\)$`),Au=new RegExp(`^hsla\\(${Et},${je},${je},${Et}\\)$`),Vr={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};dr(zt,Ze,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Br,formatHex:Br,formatHex8:$u,formatHsl:Iu,formatRgb:Or,toString:Or});function Br(){return this.rgb().formatHex()}function $u(){return this.rgb().formatHex8()}function Iu(){return ko(this).formatHsl()}function Or(){return this.rgb().formatRgb()}function Ze(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Eu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Fr(t):n===3?new he(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Yt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Yt(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=Su.exec(e))?new he(t[1],t[2],t[3],1):(t=Cu.exec(e))?new he(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ku.exec(e))?Yt(t[1],t[2],t[3],t[4]):(t=ju.exec(e))?Yt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Mu.exec(e))?qr(t[1],t[2]/100,t[3]/100,1):(t=Au.exec(e))?qr(t[1],t[2]/100,t[3]/100,t[4]):Vr.hasOwnProperty(e)?Fr(Vr[e]):e==="transparent"?new he(NaN,NaN,NaN,0):null}function Fr(e){return new he(e>>16&255,e>>8&255,e&255,1)}function Yt(e,t,n,r){return r<=0&&(e=t=n=NaN),new he(e,t,n,r)}function Tu(e){return e instanceof zt||(e=Ze(e)),e?(e=e.rgb(),new he(e.r,e.g,e.b,e.opacity)):new he}function qn(e,t,n,r){return arguments.length===1?Tu(e):new he(e,t,n,r??1)}function he(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}dr(he,qn,Co(zt,{brighter(e){return e=e==null?sn:Math.pow(sn,e),new he(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Nt:Math.pow(Nt,e),new he(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new he(Ke(this.r),Ke(this.g),Ke(this.b),on(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:Yr,formatHex:Yr,formatHex8:Pu,formatRgb:Xr,toString:Xr}));function Yr(){return`#${We(this.r)}${We(this.g)}${We(this.b)}`}function Pu(){return`#${We(this.r)}${We(this.g)}${We(this.b)}${We((isNaN(this.opacity)?1:this.opacity)*255)}`}function Xr(){const e=on(this.opacity);return`${e===1?"rgb(":"rgba("}${Ke(this.r)}, ${Ke(this.g)}, ${Ke(this.b)}${e===1?")":`, ${e})`}`}function on(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ke(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function We(e){return e=Ke(e),(e<16?"0":"")+e.toString(16)}function qr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ve(e,t,n,r)}function ko(e){if(e instanceof ve)return new ve(e.h,e.s,e.l,e.opacity);if(e instanceof zt||(e=Ze(e)),!e)return new ve;if(e instanceof ve)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),i=Math.max(t,n,r),o=NaN,a=i-s,u=(i+s)/2;return a?(t===i?o=(n-r)/a+(n<r)*6:n===i?o=(r-t)/a+2:o=(t-n)/a+4,a/=u<.5?i+s:2-i-s,o*=60):a=u>0&&u<1?0:o,new ve(o,a,u,e.opacity)}function zu(e,t,n,r){return arguments.length===1?ko(e):new ve(e,t,n,r??1)}function ve(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}dr(ve,zu,Co(zt,{brighter(e){return e=e==null?sn:Math.pow(sn,e),new ve(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Nt:Math.pow(Nt,e),new ve(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new he(Mn(e>=240?e-240:e+120,s,r),Mn(e,s,r),Mn(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new ve(Wr(this.h),Xt(this.s),Xt(this.l),on(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=on(this.opacity);return`${e===1?"hsl(":"hsla("}${Wr(this.h)}, ${Xt(this.s)*100}%, ${Xt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Wr(e){return e=(e||0)%360,e<0?e+360:e}function Xt(e){return Math.max(0,Math.min(1,e||0))}function Mn(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 fr=e=>()=>e;function Du(e,t){return function(n){return e+n*t}}function Lu(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Ru(e){return(e=+e)==1?jo:function(t,n){return n-t?Lu(t,n,e):fr(isNaN(t)?n:t)}}function jo(e,t){var n=t-e;return n?Du(e,n):fr(isNaN(e)?t:e)}const an=(function e(t){var n=Ru(t);function r(s,i){var o=n((s=qn(s)).r,(i=qn(i)).r),a=n(s.g,i.g),u=n(s.b,i.b),l=jo(s.opacity,i.opacity);return function(d){return s.r=o(d),s.g=a(d),s.b=u(d),s.opacity=l(d),s+""}}return r.gamma=e,r})(1);function Hu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(i){for(s=0;s<n;++s)r[s]=e[s]*(1-i)+t[s]*i;return r}}function Vu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Bu(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),i=new Array(n),o;for(o=0;o<r;++o)s[o]=vt(e[o],t[o]);for(;o<n;++o)i[o]=t[o];return function(a){for(o=0;o<r;++o)i[o]=s[o](a);return i}}function Ou(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function ke(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Fu(e,t){var n={},r={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=vt(e[s],t[s]):r[s]=t[s];return function(i){for(s in n)r[s]=n[s](i);return r}}var Wn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,An=new RegExp(Wn.source,"g");function Yu(e){return function(){return e}}function Xu(e){return function(t){return e(t)+""}}function Mo(e,t){var n=Wn.lastIndex=An.lastIndex=0,r,s,i,o=-1,a=[],u=[];for(e=e+"",t=t+"";(r=Wn.exec(e))&&(s=An.exec(t));)(i=s.index)>n&&(i=t.slice(n,i),a[o]?a[o]+=i:a[++o]=i),(r=r[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,u.push({i:o,x:ke(r,s)})),n=An.lastIndex;return n<t.length&&(i=t.slice(n),a[o]?a[o]+=i:a[++o]=i),a.length<2?u[0]?Xu(u[0].x):Yu(t):(t=u.length,function(l){for(var d=0,c;d<t;++d)a[(c=u[d]).i]=c.x(l);return a.join("")})}function vt(e,t){var n=typeof t,r;return t==null||n==="boolean"?fr(t):(n==="number"?ke:n==="string"?(r=Ze(t))?(t=r,an):Mo:t instanceof Ze?an:t instanceof Date?Ou:Vu(t)?Hu:Array.isArray(t)?Bu:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Fu:ke)(e,t)}var Ur=180/Math.PI,Un={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ao(e,t,n,r,s,i){var o,a,u;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(u=e*n+t*r)&&(n-=e*u,r-=t*u),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,u/=a),e*r<t*n&&(e=-e,t=-t,u=-u,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(t,e)*Ur,skewX:Math.atan(u)*Ur,scaleX:o,scaleY:a}}var qt;function qu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Un:Ao(t.a,t.b,t.c,t.d,t.e,t.f)}function Wu(e){return e==null||(qt||(qt=document.createElementNS("http://www.w3.org/2000/svg","g")),qt.setAttribute("transform",e),!(e=qt.transform.baseVal.consolidate()))?Un:(e=e.matrix,Ao(e.a,e.b,e.c,e.d,e.e,e.f))}function $o(e,t,n,r){function s(l){return l.length?l.pop()+" ":""}function i(l,d,c,f,p,g){if(l!==c||d!==f){var v=p.push("translate(",null,t,null,n);g.push({i:v-4,x:ke(l,c)},{i:v-2,x:ke(d,f)})}else(c||f)&&p.push("translate("+c+t+f+n)}function o(l,d,c,f){l!==d?(l-d>180?d+=360:d-l>180&&(l+=360),f.push({i:c.push(s(c)+"rotate(",null,r)-2,x:ke(l,d)})):d&&c.push(s(c)+"rotate("+d+r)}function a(l,d,c,f){l!==d?f.push({i:c.push(s(c)+"skewX(",null,r)-2,x:ke(l,d)}):d&&c.push(s(c)+"skewX("+d+r)}function u(l,d,c,f,p,g){if(l!==c||d!==f){var v=p.push(s(p)+"scale(",null,",",null,")");g.push({i:v-4,x:ke(l,c)},{i:v-2,x:ke(d,f)})}else(c!==1||f!==1)&&p.push(s(p)+"scale("+c+","+f+")")}return function(l,d){var c=[],f=[];return l=e(l),d=e(d),i(l.translateX,l.translateY,d.translateX,d.translateY,c,f),o(l.rotate,d.rotate,c,f),a(l.skewX,d.skewX,c,f),u(l.scaleX,l.scaleY,d.scaleX,d.scaleY,c,f),l=d=null,function(p){for(var g=-1,v=f.length,w;++g<v;)c[(w=f[g]).i]=w.x(p);return c.join("")}}}var Uu=$o(qu,"px, ","px)","deg)"),Ku=$o(Wu,", ",")",")"),Gu=1e-12;function Kr(e){return((e=Math.exp(e))+1/e)/2}function Zu(e){return((e=Math.exp(e))-1/e)/2}function Qu(e){return((e=Math.exp(2*e))-1)/(e+1)}const Jt=(function e(t,n,r){function s(i,o){var a=i[0],u=i[1],l=i[2],d=o[0],c=o[1],f=o[2],p=d-a,g=c-u,v=p*p+g*g,w,y;if(v<Gu)y=Math.log(f/l)/t,w=function(j){return[a+j*p,u+j*g,l*Math.exp(t*j*y)]};else{var b=Math.sqrt(v),m=(f*f-l*l+r*v)/(2*l*n*b),x=(f*f-l*l-r*v)/(2*f*n*b),N=Math.log(Math.sqrt(m*m+1)-m),E=Math.log(Math.sqrt(x*x+1)-x);y=(E-N)/t,w=function(j){var I=j*y,P=Kr(N),O=l/(n*b)*(P*Qu(t*I+N)-Zu(N));return[a+O*p,u+O*g,l*P/Kr(t*I+N)]}}return w.duration=y*1e3*t/Math.SQRT2,w}return s.rho=function(i){var o=Math.max(.001,+i),a=o*o,u=a*a;return e(o,a,u)},s})(Math.SQRT2,2,4);var lt=0,xt=0,gt=0,Io=1e3,cn,yt,ln=0,Qe=0,xn=0,St=typeof performance=="object"&&performance.now?performance:Date,To=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function hr(){return Qe||(To(Ju),Qe=St.now()+xn)}function Ju(){Qe=0}function un(){this._call=this._time=this._next=null}un.prototype=Po.prototype={constructor:un,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?hr():+n)+(t==null?0:+t),!this._next&&yt!==this&&(yt?yt._next=this:cn=this,yt=this),this._call=e,this._time=n,Kn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Kn())}};function Po(e,t,n){var r=new un;return r.restart(e,t,n),r}function ed(){hr(),++lt;for(var e=cn,t;e;)(t=Qe-e._time)>=0&&e._call.call(void 0,t),e=e._next;--lt}function Gr(){Qe=(ln=St.now())+xn,lt=xt=0;try{ed()}finally{lt=0,nd(),Qe=0}}function td(){var e=St.now(),t=e-ln;t>Io&&(xn-=t,ln=e)}function nd(){for(var e,t=cn,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:cn=n);yt=e,Kn(r)}function Kn(e){if(!lt){xt&&(xt=clearTimeout(xt));var t=e-Qe;t>24?(e<1/0&&(xt=setTimeout(Gr,e-St.now()-xn)),gt&&(gt=clearInterval(gt))):(gt||(ln=St.now(),gt=setInterval(td,Io)),lt=1,To(Gr))}}function Zr(e,t,n){var r=new un;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var rd=gn("start","end","cancel","interrupt"),sd=[],zo=0,Qr=1,Gn=2,en=3,Jr=4,Zn=5,tn=6;function yn(e,t,n,r,s,i){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;od(e,n,{name:t,index:r,group:s,on:rd,tween:sd,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:zo})}function pr(e,t){var n=Ee(e,t);if(n.state>zo)throw new Error("too late; already scheduled");return n}function Me(e,t){var n=Ee(e,t);if(n.state>en)throw new Error("too late; already running");return n}function Ee(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function od(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=Po(i,0,n.time);function i(l){n.state=Qr,n.timer.restart(o,n.delay,n.time),n.delay<=l&&o(l-n.delay)}function o(l){var d,c,f,p;if(n.state!==Qr)return u();for(d in r)if(p=r[d],p.name===n.name){if(p.state===en)return Zr(o);p.state===Jr?(p.state=tn,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete r[d]):+d<t&&(p.state=tn,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete r[d])}if(Zr(function(){n.state===en&&(n.state=Jr,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Gn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Gn){for(n.state=en,s=new Array(f=n.tween.length),d=0,c=-1;d<f;++d)(p=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(s[++c]=p);s.length=c+1}}function a(l){for(var d=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(u),n.state=Zn,1),c=-1,f=s.length;++c<f;)s[c].call(e,d);n.state===Zn&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=tn,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function nn(e,t){var n=e.__transition,r,s,i=!0,o;if(n){t=t==null?null:t+"";for(o in n){if((r=n[o]).name!==t){i=!1;continue}s=r.state>Gn&&r.state<Zn,r.state=tn,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[o]}i&&delete e.__transition}}function id(e){return this.each(function(){nn(this,e)})}function ad(e,t){var n,r;return function(){var s=Me(this,e),i=s.tween;if(i!==n){r=n=i;for(var o=0,a=r.length;o<a;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}s.tween=r}}function cd(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var i=Me(this,e),o=i.tween;if(o!==r){s=(r=o).slice();for(var a={name:t,value:n},u=0,l=s.length;u<l;++u)if(s[u].name===t){s[u]=a;break}u===l&&s.push(a)}i.tween=s}}function ld(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Ee(this.node(),n).tween,s=0,i=r.length,o;s<i;++s)if((o=r[s]).name===e)return o.value;return null}return this.each((t==null?ad:cd)(n,e,t))}function gr(e,t,n){var r=e._id;return e.each(function(){var s=Me(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Ee(s,r).value[t]}}function Do(e,t){var n;return(typeof t=="number"?ke:t instanceof Ze?an:(n=Ze(t))?(t=n,an):Mo)(e,t)}function ud(e){return function(){this.removeAttribute(e)}}function dd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fd(e,t,n){var r,s=n+"",i;return function(){var o=this.getAttribute(e);return o===s?null:o===r?i:i=t(r=o,n)}}function hd(e,t,n){var r,s=n+"",i;return function(){var o=this.getAttributeNS(e.space,e.local);return o===s?null:o===r?i:i=t(r=o,n)}}function pd(e,t,n){var r,s,i;return function(){var o,a=n(this),u;return a==null?void this.removeAttribute(e):(o=this.getAttribute(e),u=a+"",o===u?null:o===r&&u===s?i:(s=u,i=t(r=o,a)))}}function gd(e,t,n){var r,s,i;return function(){var o,a=n(this),u;return a==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),u=a+"",o===u?null:o===r&&u===s?i:(s=u,i=t(r=o,a)))}}function md(e,t){var n=mn(e),r=n==="transform"?Ku:Do;return this.attrTween(e,typeof t=="function"?(n.local?gd:pd)(n,r,gr(this,"attr."+e,t)):t==null?(n.local?dd:ud)(n):(n.local?hd:fd)(n,r,t))}function xd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function yd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function wd(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&yd(e,i)),n}return s._value=t,s}function vd(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&xd(e,i)),n}return s._value=t,s}function bd(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=mn(e);return this.tween(n,(r.local?wd:vd)(r,t))}function _d(e,t){return function(){pr(this,e).delay=+t.apply(this,arguments)}}function Nd(e,t){return t=+t,function(){pr(this,e).delay=t}}function Ed(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?_d:Nd)(t,e)):Ee(this.node(),t).delay}function Sd(e,t){return function(){Me(this,e).duration=+t.apply(this,arguments)}}function Cd(e,t){return t=+t,function(){Me(this,e).duration=t}}function kd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Sd:Cd)(t,e)):Ee(this.node(),t).duration}function jd(e,t){if(typeof t!="function")throw new Error;return function(){Me(this,e).ease=t}}function Md(e){var t=this._id;return arguments.length?this.each(jd(t,e)):Ee(this.node(),t).ease}function Ad(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Me(this,e).ease=n}}function $d(e){if(typeof e!="function")throw new Error;return this.each(Ad(this._id,e))}function Id(e){typeof e!="function"&&(e=ho(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],o=i.length,a=r[s]=[],u,l=0;l<o;++l)(u=i[l])&&e.call(u,u.__data__,l,i)&&a.push(u);return new ze(r,this._parents,this._name,this._id)}function Td(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,i=Math.min(r,s),o=new Array(r),a=0;a<i;++a)for(var u=t[a],l=n[a],d=u.length,c=o[a]=new Array(d),f,p=0;p<d;++p)(f=u[p]||l[p])&&(c[p]=f);for(;a<r;++a)o[a]=t[a];return new ze(o,this._parents,this._name,this._id)}function Pd(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 zd(e,t,n){var r,s,i=Pd(t)?pr:Me;return function(){var o=i(this,e),a=o.on;a!==r&&(s=(r=a).copy()).on(t,n),o.on=s}}function Dd(e,t){var n=this._id;return arguments.length<2?Ee(this.node(),n).on.on(e):this.each(zd(n,e,t))}function Ld(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Rd(){return this.on("end.remove",Ld(this._id))}function Hd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=lr(e));for(var r=this._groups,s=r.length,i=new Array(s),o=0;o<s;++o)for(var a=r[o],u=a.length,l=i[o]=new Array(u),d,c,f=0;f<u;++f)(d=a[f])&&(c=e.call(d,d.__data__,f,a))&&("__data__"in d&&(c.__data__=d.__data__),l[f]=c,yn(l[f],t,n,f,l,Ee(d,n)));return new ze(i,this._parents,t,n)}function Vd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=fo(e));for(var r=this._groups,s=r.length,i=[],o=[],a=0;a<s;++a)for(var u=r[a],l=u.length,d,c=0;c<l;++c)if(d=u[c]){for(var f=e.call(d,d.__data__,c,u),p,g=Ee(d,n),v=0,w=f.length;v<w;++v)(p=f[v])&&yn(p,t,n,v,f,g);i.push(f),o.push(d)}return new ze(i,o,t,n)}var Bd=Pt.prototype.constructor;function Od(){return new Bd(this._groups,this._parents)}function Fd(e,t){var n,r,s;return function(){var i=ct(this,e),o=(this.style.removeProperty(e),ct(this,e));return i===o?null:i===n&&o===r?s:s=t(n=i,r=o)}}function Lo(e){return function(){this.style.removeProperty(e)}}function Yd(e,t,n){var r,s=n+"",i;return function(){var o=ct(this,e);return o===s?null:o===r?i:i=t(r=o,n)}}function Xd(e,t,n){var r,s,i;return function(){var o=ct(this,e),a=n(this),u=a+"";return a==null&&(u=a=(this.style.removeProperty(e),ct(this,e))),o===u?null:o===r&&u===s?i:(s=u,i=t(r=o,a))}}function qd(e,t){var n,r,s,i="style."+t,o="end."+i,a;return function(){var u=Me(this,e),l=u.on,d=u.value[i]==null?a||(a=Lo(t)):void 0;(l!==n||s!==d)&&(r=(n=l).copy()).on(o,s=d),u.on=r}}function Wd(e,t,n){var r=(e+="")=="transform"?Uu:Do;return t==null?this.styleTween(e,Fd(e,r)).on("end.style."+e,Lo(e)):typeof t=="function"?this.styleTween(e,Xd(e,r,gr(this,"style."+e,t))).each(qd(this._id,e)):this.styleTween(e,Yd(e,r,t),n).on("end.style."+e,null)}function Ud(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Kd(e,t,n){var r,s;function i(){var o=t.apply(this,arguments);return o!==s&&(r=(s=o)&&Ud(e,o,n)),r}return i._value=t,i}function Gd(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,Kd(e,t,n??""))}function Zd(e){return function(){this.textContent=e}}function Qd(e){return function(){var t=e(this);this.textContent=t??""}}function Jd(e){return this.tween("text",typeof e=="function"?Qd(gr(this,"text",e)):Zd(e==null?"":e+""))}function ef(e){return function(t){this.textContent=e.call(this,t)}}function tf(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&ef(s)),t}return r._value=e,r}function nf(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,tf(e))}function rf(){for(var e=this._name,t=this._id,n=Ro(),r=this._groups,s=r.length,i=0;i<s;++i)for(var o=r[i],a=o.length,u,l=0;l<a;++l)if(u=o[l]){var d=Ee(u,t);yn(u,e,n,l,o,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new ze(r,this._parents,e,n)}function sf(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(i,o){var a={value:o},u={value:function(){--s===0&&i()}};n.each(function(){var l=Me(this,r),d=l.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(u)),l.on=t}),s===0&&i()})}var of=0;function ze(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Ro(){return++of}var Te=Pt.prototype;ze.prototype={constructor:ze,select:Hd,selectAll:Vd,selectChild:Te.selectChild,selectChildren:Te.selectChildren,filter:Id,merge:Td,selection:Od,transition:rf,call:Te.call,nodes:Te.nodes,node:Te.node,size:Te.size,empty:Te.empty,each:Te.each,on:Dd,attr:md,attrTween:bd,style:Wd,styleTween:Gd,text:Jd,textTween:nf,remove:Rd,tween:ld,delay:Ed,duration:kd,ease:Md,easeVarying:$d,end:sf,[Symbol.iterator]:Te[Symbol.iterator]};function af(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var cf={time:null,delay:0,duration:250,ease:af};function lf(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 uf(e){var t,n;e instanceof ze?(t=e._id,e=e._name):(t=Ro(),(n=cf).time=hr(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,i=0;i<s;++i)for(var o=r[i],a=o.length,u,l=0;l<a;++l)(u=o[l])&&yn(u,e,t,l,o,n||lf(u,t));return new ze(r,this._parents,e,t)}Pt.prototype.interrupt=id;Pt.prototype.transition=uf;const Wt=e=>()=>e;function df(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function Pe(e,t,n){this.k=e,this.x=t,this.y=n}Pe.prototype={constructor:Pe,scale:function(e){return e===1?this:new Pe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Pe(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 wn=new Pe(1,0,0);Ho.prototype=Pe.prototype;function Ho(e){for(;!e.__zoom;)if(!(e=e.parentNode))return wn;return e.__zoom}function $n(e){e.stopImmediatePropagation()}function mt(e){e.preventDefault(),e.stopImmediatePropagation()}function ff(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function hf(){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 es(){return this.__zoom||wn}function pf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function gf(){return navigator.maxTouchPoints||"ontouchstart"in this}function mf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function Vo(){var e=ff,t=hf,n=mf,r=pf,s=gf,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,u=Jt,l=gn("start","zoom","end"),d,c,f,p=500,g=150,v=0,w=10;function y(_){_.property("__zoom",es).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",O).filter(s).on("touchstart.zoom",k).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(_,A,S,$){var z=_.selection?_.selection():_;z.property("__zoom",es),_!==z?N(_,A,S,$):z.interrupt().each(function(){E(this,arguments).event($).start().zoom(null,typeof A=="function"?A.apply(this,arguments):A).end()})},y.scaleBy=function(_,A,S,$){y.scaleTo(_,function(){var z=this.__zoom.k,M=typeof A=="function"?A.apply(this,arguments):A;return z*M},S,$)},y.scaleTo=function(_,A,S,$){y.transform(_,function(){var z=t.apply(this,arguments),M=this.__zoom,R=S==null?x(z):typeof S=="function"?S.apply(this,arguments):S,V=M.invert(R),L=typeof A=="function"?A.apply(this,arguments):A;return n(m(b(M,L),R,V),z,o)},S,$)},y.translateBy=function(_,A,S,$){y.transform(_,function(){return n(this.__zoom.translate(typeof A=="function"?A.apply(this,arguments):A,typeof S=="function"?S.apply(this,arguments):S),t.apply(this,arguments),o)},null,$)},y.translateTo=function(_,A,S,$,z){y.transform(_,function(){var M=t.apply(this,arguments),R=this.__zoom,V=$==null?x(M):typeof $=="function"?$.apply(this,arguments):$;return n(wn.translate(V[0],V[1]).scale(R.k).translate(typeof A=="function"?-A.apply(this,arguments):-A,typeof S=="function"?-S.apply(this,arguments):-S),M,o)},$,z)};function b(_,A){return A=Math.max(i[0],Math.min(i[1],A)),A===_.k?_:new Pe(A,_.x,_.y)}function m(_,A,S){var $=A[0]-S[0]*_.k,z=A[1]-S[1]*_.k;return $===_.x&&z===_.y?_:new Pe(_.k,$,z)}function x(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function N(_,A,S,$){_.on("start.zoom",function(){E(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event($).end()}).tween("zoom",function(){var z=this,M=arguments,R=E(z,M).event($),V=t.apply(z,M),L=S==null?x(V):typeof S=="function"?S.apply(z,M):S,X=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),q=z.__zoom,G=typeof A=="function"?A.apply(z,M):A,B=u(q.invert(L).concat(X/q.k),G.invert(L).concat(X/G.k));return function(Y){if(Y===1)Y=G;else{var D=B(Y),F=X/D[2];Y=new Pe(F,L[0]-D[0]*F,L[1]-D[1]*F)}R.zoom(null,Y)}})}function E(_,A,S){return!S&&_.__zooming||new j(_,A)}function j(_,A){this.that=_,this.args=A,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,A),this.taps=0}j.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,A){return this.mouse&&_!=="mouse"&&(this.mouse[1]=A.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=A.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=A.invert(this.touch1[0])),this.that.__zoom=A,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var A=ge(this.that).datum();l.call(_,this.that,new df(_,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:l}),A)}};function I(_,...A){if(!e.apply(this,arguments))return;var S=E(this,A).event(_),$=this.__zoom,z=Math.max(i[0],Math.min(i[1],$.k*Math.pow(2,r.apply(this,arguments)))),M=we(_);if(S.wheel)(S.mouse[0][0]!==M[0]||S.mouse[0][1]!==M[1])&&(S.mouse[1]=$.invert(S.mouse[0]=M)),clearTimeout(S.wheel);else{if($.k===z)return;S.mouse=[M,$.invert(M)],nn(this),S.start()}mt(_),S.wheel=setTimeout(R,g),S.zoom("mouse",n(m(b($,z),S.mouse[0],S.mouse[1]),S.extent,o));function R(){S.wheel=null,S.end()}}function P(_,...A){if(f||!e.apply(this,arguments))return;var S=_.currentTarget,$=E(this,A,!0).event(_),z=ge(_.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",X,!0),M=we(_,S),R=_.clientX,V=_.clientY;No(_.view),$n(_),$.mouse=[M,this.__zoom.invert(M)],nn(this),$.start();function L(q){if(mt(q),!$.moved){var G=q.clientX-R,B=q.clientY-V;$.moved=G*G+B*B>v}$.event(q).zoom("mouse",n(m($.that.__zoom,$.mouse[0]=we(q,S),$.mouse[1]),$.extent,o))}function X(q){z.on("mousemove.zoom mouseup.zoom",null),Eo(q.view,$.moved),mt(q),$.event(q).end()}}function O(_,...A){if(e.apply(this,arguments)){var S=this.__zoom,$=we(_.changedTouches?_.changedTouches[0]:_,this),z=S.invert($),M=S.k*(_.shiftKey?.5:2),R=n(m(b(S,M),$,z),t.apply(this,A),o);mt(_),a>0?ge(this).transition().duration(a).call(N,R,$,_):ge(this).call(y.transform,R,$,_)}}function k(_,...A){if(e.apply(this,arguments)){var S=_.touches,$=S.length,z=E(this,A,_.changedTouches.length===$).event(_),M,R,V,L;for($n(_),R=0;R<$;++R)V=S[R],L=we(V,this),L=[L,this.__zoom.invert(L),V.identifier],z.touch0?!z.touch1&&z.touch0[2]!==L[2]&&(z.touch1=L,z.taps=0):(z.touch0=L,M=!0,z.taps=1+!!d);d&&(d=clearTimeout(d)),M&&(z.taps<2&&(c=L[0],d=setTimeout(function(){d=null},p)),nn(this),z.start())}}function T(_,...A){if(this.__zooming){var S=E(this,A).event(_),$=_.changedTouches,z=$.length,M,R,V,L;for(mt(_),M=0;M<z;++M)R=$[M],V=we(R,this),S.touch0&&S.touch0[2]===R.identifier?S.touch0[0]=V:S.touch1&&S.touch1[2]===R.identifier&&(S.touch1[0]=V);if(R=S.that.__zoom,S.touch1){var X=S.touch0[0],q=S.touch0[1],G=S.touch1[0],B=S.touch1[1],Y=(Y=G[0]-X[0])*Y+(Y=G[1]-X[1])*Y,D=(D=B[0]-q[0])*D+(D=B[1]-q[1])*D;R=b(R,Math.sqrt(Y/D)),V=[(X[0]+G[0])/2,(X[1]+G[1])/2],L=[(q[0]+B[0])/2,(q[1]+B[1])/2]}else if(S.touch0)V=S.touch0[0],L=S.touch0[1];else return;S.zoom("touch",n(m(R,V,L),S.extent,o))}}function H(_,...A){if(this.__zooming){var S=E(this,A).event(_),$=_.changedTouches,z=$.length,M,R;for($n(_),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),M=0;M<z;++M)R=$[M],S.touch0&&S.touch0[2]===R.identifier?delete S.touch0:S.touch1&&S.touch1[2]===R.identifier&&delete S.touch1;if(S.touch1&&!S.touch0&&(S.touch0=S.touch1,delete S.touch1),S.touch0)S.touch0[1]=this.__zoom.invert(S.touch0[0]);else if(S.end(),S.taps===2&&(R=we(R,this),Math.hypot(c[0]-R[0],c[1]-R[1])<w)){var V=ge(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return y.wheelDelta=function(_){return arguments.length?(r=typeof _=="function"?_:Wt(+_),y):r},y.filter=function(_){return arguments.length?(e=typeof _=="function"?_:Wt(!!_),y):e},y.touchable=function(_){return arguments.length?(s=typeof _=="function"?_:Wt(!!_),y):s},y.extent=function(_){return arguments.length?(t=typeof _=="function"?_:Wt([[+_[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?(o[0][0]=+_[0][0],o[1][0]=+_[1][0],o[0][1]=+_[0][1],o[1][1]=+_[1][1],y):[[o[0][0],o[0][1]],[o[1][0],o[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?(u=_,y):u},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?(w=+_,y):w},y}const Ne={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:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",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.`},Ct=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Bo=["Enter"," ","Escape"],Oo={"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 ut;(function(e){e.Strict="strict",e.Loose="loose"})(ut||(ut={}));var Ge;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ge||(Ge={}));var kt;(function(e){e.Partial="partial",e.Full="full"})(kt||(kt={}));const Fo={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ve;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ve||(Ve={}));var dn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(dn||(dn={}));var U;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(U||(U={}));const ts={[U.Left]:U.Right,[U.Right]:U.Left,[U.Top]:U.Bottom,[U.Bottom]:U.Top};function Yo(e){return e===null?null:e?"valid":"invalid"}const Xo=e=>"id"in e&&"source"in e&&"target"in e,xf=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),mr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Dt=(e,t=[0,0])=>{const{width:n,height:r}=De(e),s=e.origin??t,i=n*s[0],o=r*s[1];return{x:e.position.x-i,y:e.position.y-o}},yf=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const i=typeof s=="string";let o=!t.nodeLookup&&!i?s:void 0;t.nodeLookup&&(o=i?t.nodeLookup.get(s):mr(s)?s:t.nodeLookup.get(s.id));const a=o?fn(o,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return vn(r,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return bn(n)},Lt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=vn(n,fn(s)),r=!0)}),r?bn(n):{x:0,y:0,width:0,height:0}},xr=(e,t,[n,r,s]=[0,0,1],i=!1,o=!1)=>{const a=(t.x-n)/s,u=(t.y-r)/s,l=t.width/s,d=t.height/s,c=[];for(const f of e.values()){const{measured:p,selectable:g=!0,hidden:v=!1}=f;if(o&&!g||v)continue;const w=p.width??f.width??f.initialWidth??0,y=p.height??f.height??f.initialHeight??0,{x:b,y:m}=f.internals.positionAbsolute,x=Ko(a,u,l,d,b,m,w,y),N=w*y,E=i&&x>0;(!f.internals.handleBounds||E||x>=N||f.dragging)&&c.push(f)}return c},wf=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function vf(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!r||r.has(s.id))&&n.set(s.id,s)}),n}async function bf({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},o){if(e.size===0)return!0;const a=vf(e,o),u=Lt(a),l=wr(u,t,n,(o==null?void 0:o.minZoom)??s,(o==null?void 0:o.maxZoom)??i,(o==null?void 0:o.padding)??.1);return await r.setViewport(l,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0}function qo({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:i}){const o=n.get(e),a=o.parentId?n.get(o.parentId):void 0,{x:u,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},d=o.origin??r;let c=o.extent||s;if(o.extent==="parent"&&!o.expandParent)if(!a)i==null||i("005",Ne.error005());else{const p=a.measured.width,g=a.measured.height;p&&g&&(c=[[u,l],[u+p,l+g]])}else a&&et(o.extent)&&(c=[[o.extent[0][0]+u,o.extent[0][1]+l],[o.extent[1][0]+u,o.extent[1][1]+l]]);const f=et(c)?Je(t,c,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&(i==null||i("015",Ne.error015())),{position:{x:f.x-u+(o.measured.width??0)*d[0],y:f.y-l+(o.measured.height??0)*d[1]},positionAbsolute:f}}async function _f({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const i=new Set(e.map(f=>f.id)),o=[];for(const f of n){if(f.deletable===!1)continue;const p=i.has(f.id),g=!p&&f.parentId&&o.find(v=>v.id===f.parentId);(p||g)&&o.push(f)}const a=new Set(t.map(f=>f.id)),u=r.filter(f=>f.deletable!==!1),d=wf(o,u);for(const f of u)a.has(f.id)&&!d.find(g=>g.id===f.id)&&d.push(f);if(!s)return{edges:d,nodes:o};const c=await s({nodes:o,edges:d});return typeof c=="boolean"?c?{edges:d,nodes:o}:{edges:[],nodes:[]}:c}const dt=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Je=(e={x:0,y:0},t,n)=>({x:dt(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:dt(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Wo(e,t,n){const{width:r,height:s}=De(n),{x:i,y:o}=n.internals.positionAbsolute;return Je(e,[[i,o],[i+r,o+s]],t)}const ns=(e,t,n)=>e<t?dt(Math.abs(e-t),1,t)/t:e>n?-dt(Math.abs(e-n),1,t)/t:0,yr=(e,t,n=15,r=40)=>{const s=ns(e.x,r,t.width-r)*n,i=ns(e.y,r,t.height-r)*n;return[s,i]},vn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Qn=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),bn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),jt=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=mr(e)?e.internals.positionAbsolute:Dt(e,t);return{x:n,y:r,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},fn=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=mr(e)?e.internals.positionAbsolute:Dt(e,t);return{x:n,y:r,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Uo=(e,t)=>bn(vn(Qn(e),Qn(t))),Ko=(e,t,n,r,s,i,o,a)=>{const u=Math.max(0,Math.min(e+n,s+o)-Math.max(e,s)),l=Math.max(0,Math.min(t+r,i+a)-Math.max(t,i));return Math.ceil(u*l)},hn=(e,t)=>Ko(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),rs=e=>be(e.width)&&be(e.height)&&be(e.x)&&be(e.y),be=e=>!isNaN(e)&&isFinite(e),Go=(e,t)=>(n,r)=>{},Rt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Ht=({x:e,y:t},[n,r,s],i=!1,o=[1,1])=>{const a={x:(e-n)/s,y:(t-r)/s};return i?Rt(a,o):a},ft=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function nt(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 Nf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=nt(e,n),s=nt(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=nt(e.top??e.y??0,n),s=nt(e.bottom??e.y??0,n),i=nt(e.left??e.x??0,t),o=nt(e.right??e.x??0,t);return{top:r,right:o,bottom:s,left:i,x:i+o,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Ef(e,t,n,r,s,i){const{x:o,y:a}=ft(e,[t,n,r]),{x:u,y:l}=ft({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=s-u,c=i-l;return{left:Math.floor(o),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(c)}}const wr=(e,t,n,r,s,i)=>{const o=Nf(i,t,n),a=(t-o.x)/e.width,u=(n-o.y)/e.height,l=Math.min(a,u),d=dt(l,r,s),c=e.x+e.width/2,f=e.y+e.height/2,p=t/2-c*d,g=n/2-f*d,v=Ef(e,p,g,d,t,n),w={left:Math.min(v.left-o.left,0),top:Math.min(v.top-o.top,0),right:Math.min(v.right-o.right,0),bottom:Math.min(v.bottom-o.bottom,0)};return{x:p-w.left+w.right,y:g-w.top+w.bottom,zoom:d}},Mt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function et(e){return e!=null&&e!=="parent"}function De(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Zo(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Qo(e,t={width:0,height:0},n,r,s){const i={...e},o=r.get(n);if(o){const a=o.origin||s;i.x+=o.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=o.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function ss(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Sf(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function Cf(e){return{...Oo,...e||{}}}function bt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:i,y:o}=_e(e),a=Ht({x:i-((s==null?void 0:s.left)??0),y:o-((s==null?void 0:s.top)??0)},r),{x:u,y:l}=n?Rt(a,t):a;return{xSnapped:u,ySnapped:l,...a}}const vr=e=>({width:e.offsetWidth,height:e.offsetHeight}),Jo=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},kf=["INPUT","SELECT","TEXTAREA"];function ei(e){var r,s;const t=((s=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:s[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:kf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const ti=e=>"clientX"in e,_e=(e,t)=>{var i,o;const n=ti(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,s=n?e.clientY:(o=e.touches)==null?void 0:o[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},os=(e,t,n,r,s)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(o=>{const a=o.getBoundingClientRect();return{id:o.getAttribute("data-handleid"),type:e,nodeId:s,position:o.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...vr(o)}})};function ni({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:i,targetControlX:o,targetControlY:a}){const u=e*.125+s*.375+o*.375+n*.125,l=t*.125+i*.375+a*.375+r*.125,d=Math.abs(u-e),c=Math.abs(l-t);return[u,l,d,c]}function Ut(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function is({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case U.Left:return[t-Ut(t-r,i),n];case U.Right:return[t+Ut(r-t,i),n];case U.Top:return[t,n-Ut(n-s,i)];case U.Bottom:return[t,n+Ut(s-n,i)]}}function br({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:r,targetY:s,targetPosition:i=U.Top,curvature:o=.25}){const[a,u]=is({pos:n,x1:e,y1:t,x2:r,y2:s,c:o}),[l,d]=is({pos:i,x1:r,y1:s,x2:e,y2:t,c:o}),[c,f,p,g]=ni({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:l,targetControlY:d});return[`M${e},${t} C${a},${u} ${l},${d} ${r},${s}`,c,f,p,g]}function ri({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,i=n<e?n+s:n-s,o=Math.abs(r-t)/2,a=r<t?r+o:r-o;return[i,a,s,o]}function jf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const o=s&&n?r+1e3:r,a=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return o+a}function Mf({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const i=vn(fn(e),fn(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const o={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:r/s[2]};return hn(o,bn(i))>0}const Af=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,$f=(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)),If=(e,t,n={})=>{var i;if(!e.source||!e.target)return(i=n.onError)==null||i.call(n,"006",Ne.error006()),t;const r=n.getEdgeId||Af;let s;return Xo(e)?s={...e}:s={...e,id:r(e)},$f(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function si({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,o,a]=ri({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,o,a]}const as={[U.Left]:{x:-1,y:0},[U.Right]:{x:1,y:0},[U.Top]:{x:0,y:-1},[U.Bottom]:{x:0,y:1}},Tf=({source:e,sourcePosition:t=U.Bottom,target:n})=>t===U.Left||t===U.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},cs=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Pf({source:e,sourcePosition:t=U.Bottom,target:n,targetPosition:r=U.Top,center:s,offset:i,stepPosition:o}){const a=as[t],u=as[r],l={x:e.x+a.x*i,y:e.y+a.y*i},d={x:n.x+u.x*i,y:n.y+u.y*i},c=Tf({source:l,sourcePosition:t,target:d}),f=c.x!==0?"x":"y",p=c[f];let g=[],v,w;const y={x:0,y:0},b={x:0,y:0},[,,m,x]=ri({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*u[f]===-1){f==="x"?(v=s.x??l.x+(d.x-l.x)*o,w=s.y??(l.y+d.y)/2):(v=s.x??(l.x+d.x)/2,w=s.y??l.y+(d.y-l.y)*o);const I=[{x:v,y:l.y},{x:v,y:d.y}],P=[{x:l.x,y:w},{x:d.x,y:w}];a[f]===p?g=f==="x"?I:P:g=f==="x"?P:I}else{const I=[{x:l.x,y:d.y}],P=[{x:d.x,y:l.y}];if(f==="x"?g=a.x===p?P:I:g=a.y===p?I:P,t===r){const _=Math.abs(e[f]-n[f]);if(_<=i){const A=Math.min(i-1,i-_);a[f]===p?y[f]=(l[f]>e[f]?-1:1)*A:b[f]=(d[f]>n[f]?-1:1)*A}}if(t!==r){const _=f==="x"?"y":"x",A=a[f]===u[_],S=l[_]>d[_],$=l[_]<d[_];(a[f]===1&&(!A&&S||A&&$)||a[f]!==1&&(!A&&$||A&&S))&&(g=f==="x"?I:P)}const O={x:l.x+y.x,y:l.y+y.y},k={x:d.x+b.x,y:d.y+b.y},T=Math.max(Math.abs(O.x-g[0].x),Math.abs(k.x-g[0].x)),H=Math.max(Math.abs(O.y-g[0].y),Math.abs(k.y-g[0].y));T>=H?(v=(O.x+k.x)/2,w=g[0].y):(v=g[0].x,w=(O.y+k.y)/2)}const N={x:l.x+y.x,y:l.y+y.y},E={x:d.x+b.x,y:d.y+b.y};return[[e,...N.x!==g[0].x||N.y!==g[0].y?[N]:[],...g,...E.x!==g[g.length-1].x||E.y!==g[g.length-1].y?[E]:[],n],v,w,m,x]}function zf(e,t,n,r){const s=Math.min(cs(e,t)/2,cs(t,n)/2,r),{x:i,y:o}=t;if(e.x===i&&i===n.x||e.y===o&&o===n.y)return`L${i} ${o}`;if(e.y===o){const l=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${i+s*l},${o}Q ${i},${o} ${i},${o+s*d}`}const a=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${i},${o+s*u}Q ${i},${o} ${i+s*a},${o}`}function Jn({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:r,targetY:s,targetPosition:i=U.Top,borderRadius:o=5,centerX:a,centerY:u,offset:l=20,stepPosition:d=.5}){const[c,f,p,g,v]=Pf({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:i,center:{x:a,y:u},offset:l,stepPosition:d});let w=`M${c[0].x} ${c[0].y}`;for(let y=1;y<c.length-1;y++)w+=zf(c[y-1],c[y],c[y+1],o);return w+=`L${c[c.length-1].x} ${c[c.length-1].y}`,[w,f,p,g,v]}function ls(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Df(e){var c;const{sourceNode:t,targetNode:n}=e;if(!ls(t)||!ls(n))return null;const r=t.internals.handleBounds||us(t.handles),s=n.internals.handleBounds||us(n.handles),i=ds((r==null?void 0:r.source)??[],e.sourceHandle),o=ds(e.connectionMode===ut.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!i||!o)return(c=e.onError)==null||c.call(e,"008",Ne.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||U.Bottom,u=(o==null?void 0:o.position)||U.Top,l=tt(t,i,a),d=tt(n,o,u);return{sourceX:l.x,sourceY:l.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:u}}function us(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function tt(e,t,n=U.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:o,height:a}=t??De(e);if(r)return{x:s+o/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case U.Top:return{x:s+o/2,y:i};case U.Right:return{x:s+o,y:i+a/2};case U.Bottom:return{x:s+o/2,y:i+a};case U.Left:return{x:s,y:i+a/2}}}function ds(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function er(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function Lf(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const i=new Set;return e.reduce((o,a)=>([a.markerStart||r,a.markerEnd||s].forEach(u=>{if(u&&typeof u=="object"){const l=er(u,t);i.has(l)||(o.push({id:l,color:u.color||n,...u}),i.add(l))}}),o),[]).sort((o,a)=>o.id.localeCompare(a.id))}const oi=1e3,Rf=10,_r={nodeOrigin:[0,0],nodeExtent:Ct,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Hf={..._r,checkEquality:!0};function Nr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function Vf(e,t,n){const r=Nr(_r,n);for(const s of e.values())if(s.parentId)Sr(s,e,t,r);else{const i=Dt(s,r.nodeOrigin),o=et(s.extent)?s.extent:r.nodeExtent,a=Je(i,o,De(s));s.internals.positionAbsolute=a}}function Bf(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const s of e.handles){const i={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(i):s.type==="target"&&r.push(i)}return{source:n,target:r}}function Er(e){return e==="manual"}function tr(e,t,n,r={}){var d,c;const s=Nr(Hf,r),i={i:0},o=new Map(t),a=s!=null&&s.elevateNodesOnSelect&&!Er(s.zIndexMode)?oi:0;let u=e.length>0,l=!1;t.clear(),n.clear();for(const f of e){let p=o.get(f.id);if(s.checkEquality&&f===(p==null?void 0:p.internals.userNode))t.set(f.id,p);else{const g=Dt(f,s.nodeOrigin),v=et(f.extent)?f.extent:s.nodeExtent,w=Je(g,v,De(f));p={...s.defaults,...f,measured:{width:(d=f.measured)==null?void 0:d.width,height:(c=f.measured)==null?void 0:c.height},internals:{positionAbsolute:w,handleBounds:Bf(f,p),z:ii(f,a,s.zIndexMode),userNode:f}},t.set(f.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(u=!1),f.parentId&&Sr(p,t,n,r,i),l||(l=f.selected??!1)}return{nodesInitialized:u,hasSelectedNodes:l}}function Of(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 Sr(e,t,n,r,s){const{elevateNodesOnSelect:i,nodeOrigin:o,nodeExtent:a,zIndexMode:u}=Nr(_r,r),l=e.parentId,d=t.get(l);if(!d){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}Of(e,n),s&&!d.parentId&&d.internals.rootParentIndex===void 0&&u==="auto"&&(d.internals.rootParentIndex=++s.i,d.internals.z=d.internals.z+s.i*Rf),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const c=i&&!Er(u)?oi:0,{x:f,y:p,z:g}=Ff(e,d,o,a,c,u),{positionAbsolute:v}=e.internals,w=f!==v.x||p!==v.y;(w||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:f,y:p}:v,z:g}})}function ii(e,t,n){const r=be(e.zIndex)?e.zIndex:0;return Er(n)?r:r+(e.selected?t:0)}function Ff(e,t,n,r,s,i){const{x:o,y:a}=t.internals.positionAbsolute,u=De(e),l=Dt(e,n),d=et(e.extent)?Je(l,e.extent,u):l;let c=Je({x:o+d.x,y:a+d.y},r,u);e.extent==="parent"&&(c=Wo(c,u,t));const f=ii(e,s,i),p=t.internals.z??0;return{x:c.x,y:c.y,z:p>=f?p+1:f}}function Cr(e,t,n,r=[0,0]){var o;const s=[],i=new Map;for(const a of e){const u=t.get(a.parentId);if(!u)continue;const l=((o=i.get(a.parentId))==null?void 0:o.expandedRect)??jt(u),d=Uo(l,a.rect);i.set(a.parentId,{expandedRect:d,parent:u})}return i.size>0&&i.forEach(({expandedRect:a,parent:u},l)=>{var m;const d=u.internals.positionAbsolute,c=De(u),f=u.origin??r,p=a.x<d.x?Math.round(Math.abs(d.x-a.x)):0,g=a.y<d.y?Math.round(Math.abs(d.y-a.y)):0,v=Math.max(c.width,Math.round(a.width)),w=Math.max(c.height,Math.round(a.height)),y=(v-c.width)*f[0],b=(w-c.height)*f[1];(p>0||g>0||y||b)&&(s.push({id:l,type:"position",position:{x:u.position.x-p+y,y:u.position.y-g+b}}),(m=n.get(l))==null||m.forEach(x=>{e.some(N=>N.id===x.id)||s.push({id:x.id,type:"position",position:{x:x.position.x+p,y:x.position.y+g}})})),(c.width<a.width||c.height<a.height||p||g)&&s.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:v+(p?f[0]*p-y:0),height:w+(g?f[1]*g-b:0)}})}),s}function Yf(e,t,n,r,s,i,o){const a=r==null?void 0:r.querySelector(".xyflow__viewport");let u=!1;if(!a)return{changes:[],updatedInternals:u};const l=[],d=window.getComputedStyle(a),{m22:c}=new window.DOMMatrixReadOnly(d.transform),f=[];for(const p of e.values()){const g=t.get(p.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),u=!0;continue}const v=vr(p.nodeElement),w=g.measured.width!==v.width||g.measured.height!==v.height;if(!!(v.width&&v.height&&(w||!g.internals.handleBounds||p.force))){const b=p.nodeElement.getBoundingClientRect(),m=et(g.extent)?g.extent:i;let{positionAbsolute:x}=g.internals;g.parentId&&g.extent==="parent"?x=Wo(x,v,t.get(g.parentId)):m&&(x=Je(x,m,v));const N={...g,measured:v,internals:{...g.internals,positionAbsolute:x,handleBounds:{source:os("source",p.nodeElement,b,c,g.id),target:os("target",p.nodeElement,b,c,g.id)}}};t.set(g.id,N),g.parentId&&Sr(N,t,n,{nodeOrigin:s,zIndexMode:o}),u=!0,w&&(l.push({id:g.id,type:"dimensions",dimensions:v}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:jt(N,s)}))}}if(f.length>0){const p=Cr(f,t,n,s);l.push(...p)}return{changes:l,updatedInternals:u}}async function Xf({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:i}){if(!t||!e.x&&!e.y)return!1;const o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,i]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function fs(e,t,n,r,s,i){let o=s;const a=r.get(o)||new Map;r.set(o,a.set(n,t)),o=`${s}-${e}`;const u=r.get(o)||new Map;if(r.set(o,u.set(n,t)),i){o=`${s}-${e}-${i}`;const l=r.get(o)||new Map;r.set(o,l.set(n,t))}}function ai(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:i,sourceHandle:o=null,targetHandle:a=null}=r,u={edgeId:r.id,source:s,target:i,sourceHandle:o,targetHandle:a},l=`${s}-${o}--${i}-${a}`,d=`${i}-${a}--${s}-${o}`;fs("source",u,d,e,s,o),fs("target",u,l,e,i,a),t.set(r.id,r)}}function ci(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:ci(n,t):!1}function hs(e,t,n){var s;let r=e;do{if((s=r==null?void 0:r.matches)!=null&&s.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function qf(e,t,n,r){const s=new Map;for(const[i,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!ci(o,e))&&(o.draggable||t&&typeof o.draggable>"u")){const a=e.get(i);a&&s.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return s}function In({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var o,a,u;const s=[];for(const[l,d]of t){const c=(o=n.get(l))==null?void 0:o.internals.userNode;c&&s.push({...c,position:d.position,dragging:r})}if(!e)return[s[0],s];const i=(a=n.get(e))==null?void 0:a.internals.userNode;return[i?{...i,position:((u=t.get(e))==null?void 0:u.position)||i.position,dragging:r}:s[0],s]}function Wf({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const i={x:n-s.distance.x,y:r-s.distance.y},o=Rt(i,t);return{x:o.x-i.x,y:o.y-i.y}}function Uf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let i={x:null,y:null},o=0,a=new Map,u=!1,l={x:0,y:0},d=null,c=!1,f=null,p=!1,g=!1,v=null;function w({noDragClassName:b,handleSelector:m,domNode:x,isSelectable:N,nodeId:E,nodeClickDistance:j=0}){f=ge(x);function I({x:T,y:H}){const{nodeLookup:_,nodeExtent:A,snapGrid:S,snapToGrid:$,nodeOrigin:z,onNodeDrag:M,onSelectionDrag:R,onError:V,updateNodePositions:L}=t();i={x:T,y:H};let X=!1;const q=a.size>1,G=q&&A?Qn(Lt(a)):null,B=q&&$?Wf({dragItems:a,snapGrid:S,x:T,y:H}):null;for(const[Y,D]of a){if(!_.has(Y))continue;let F={x:T-D.distance.x,y:H-D.distance.y};$&&(F=B?{x:Math.round(F.x+B.x),y:Math.round(F.y+B.y)}:Rt(F,S));let Q=null;if(q&&A&&!D.extent&&G){const{positionAbsolute:W}=D.internals,ee=W.x-G.x+A[0][0],ne=W.x+D.measured.width-G.x2+A[1][0],re=W.y-G.y+A[0][1],le=W.y+D.measured.height-G.y2+A[1][1];Q=[[ee,re],[ne,le]]}const{position:Z,positionAbsolute:K}=qo({nodeId:Y,nextPosition:F,nodeLookup:_,nodeExtent:Q||A,nodeOrigin:z,onError:V});X=X||D.position.x!==Z.x||D.position.y!==Z.y,D.position=Z,D.internals.positionAbsolute=K}if(g=g||X,!!X&&(L(a,!0),v&&(r||M||!E&&R))){const[Y,D]=In({nodeId:E,dragItems:a,nodeLookup:_});r==null||r(v,a,Y,D),M==null||M(v,Y,D),E||R==null||R(v,D)}}async function P(){if(!d)return;const{transform:T,panBy:H,autoPanSpeed:_,autoPanOnNodeDrag:A}=t();if(!A){u=!1,cancelAnimationFrame(o);return}const[S,$]=yr(l,d,_);(S!==0||$!==0)&&(i.x=(i.x??0)-S/T[2],i.y=(i.y??0)-$/T[2],await H({x:S,y:$})&&I(i)),o=requestAnimationFrame(P)}function O(T){var q;const{nodeLookup:H,multiSelectionActive:_,nodesDraggable:A,transform:S,snapGrid:$,snapToGrid:z,selectNodesOnDrag:M,onNodeDragStart:R,onSelectionDragStart:V,unselectNodesAndEdges:L}=t();c=!0,(!M||!N)&&!_&&E&&((q=H.get(E))!=null&&q.selected||L()),N&&M&&E&&(e==null||e(E));const X=bt(T.sourceEvent,{transform:S,snapGrid:$,snapToGrid:z,containerBounds:d});if(i=X,a=qf(H,A,X,E),a.size>0&&(n||R||!E&&V)){const[G,B]=In({nodeId:E,dragItems:a,nodeLookup:H});n==null||n(T.sourceEvent,a,G,B),R==null||R(T.sourceEvent,G,B),E||V==null||V(T.sourceEvent,B)}}const k=So().clickDistance(j).on("start",T=>{const{domNode:H,nodeDragThreshold:_,transform:A,snapGrid:S,snapToGrid:$}=t();d=(H==null?void 0:H.getBoundingClientRect())||null,p=!1,g=!1,v=T.sourceEvent,_===0&&O(T),i=bt(T.sourceEvent,{transform:A,snapGrid:S,snapToGrid:$,containerBounds:d}),l=_e(T.sourceEvent,d)}).on("drag",T=>{const{autoPanOnNodeDrag:H,transform:_,snapGrid:A,snapToGrid:S,nodeDragThreshold:$,nodeLookup:z}=t(),M=bt(T.sourceEvent,{transform:_,snapGrid:A,snapToGrid:S,containerBounds:d});if(v=T.sourceEvent,(T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1||E&&!z.has(E))&&(p=!0),!p){if(!u&&H&&c&&(u=!0,P()),!c){const R=_e(T.sourceEvent,d),V=R.x-l.x,L=R.y-l.y;Math.sqrt(V*V+L*L)>$&&O(T)}(i.x!==M.xSnapped||i.y!==M.ySnapped)&&a&&c&&(l=_e(T.sourceEvent,d),I(M))}}).on("end",T=>{if(!c||p){p&&a.size>0&&t().updateNodePositions(a,!1);return}if(u=!1,c=!1,cancelAnimationFrame(o),a.size>0){const{nodeLookup:H,updateNodePositions:_,onNodeDragStop:A,onSelectionDragStop:S}=t();if(g&&(_(a,!1),g=!1),s||A||!E&&S){const[$,z]=In({nodeId:E,dragItems:a,nodeLookup:H,dragging:!1});s==null||s(T.sourceEvent,a,$,z),A==null||A(T.sourceEvent,$,z),E||S==null||S(T.sourceEvent,z)}}}).filter(T=>{const H=T.target;return!T.button&&(!b||!hs(H,`.${b}`,x))&&(!m||hs(H,m,x))});f.call(k)}function y(){f==null||f.on(".drag",null)}return{update:w,destroy:y}}function Kf(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())hn(s,jt(i))>0&&r.push(i);return r}const Gf=250;function Zf(e,t,n,r){var a,u;let s=[],i=1/0;const o=Kf(e,n,t+Gf);for(const l of o){const d=[...((a=l.internals.handleBounds)==null?void 0:a.source)??[],...((u=l.internals.handleBounds)==null?void 0:u.target)??[]];for(const c of d){if(r.nodeId===c.nodeId&&r.type===c.type&&r.id===c.id)continue;const{x:f,y:p}=tt(l,c,c.position,!0),g=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(p-e.y,2));g>t||(g<i?(s=[{...c,x:f,y:p}],i=g):g===i&&s.push({...c,x:f,y:p}))}}if(!s.length)return null;if(s.length>1){const l=r.type==="source"?"target":"source";return s.find(d=>d.type===l)??s[0]}return s[0]}function li(e,t,n,r,s,i=!1){var l,d,c;const o=r.get(e);if(!o)return null;const a=s==="strict"?(l=o.internals.handleBounds)==null?void 0:l[t]:[...((d=o.internals.handleBounds)==null?void 0:d.source)??[],...((c=o.internals.handleBounds)==null?void 0:c.target)??[]],u=(n?a==null?void 0:a.find(f=>f.id===n):a==null?void 0:a[0])??null;return u&&i?{...u,...tt(o,u,u.position,!0)}:u}function ui(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Qf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const di=()=>!0;function Jf(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:i,isTarget:o,domNode:a,nodeLookup:u,lib:l,autoPanOnConnect:d,flowId:c,panBy:f,cancelConnection:p,onConnectStart:g,onConnect:v,onConnectEnd:w,isValidConnection:y=di,onReconnectEnd:b,updateConnection:m,getTransform:x,getFromHandle:N,autoPanSpeed:E,dragThreshold:j=1,handleDomNode:I}){const P=Jo(e.target);let O=0,k;const{x:T,y:H}=_e(e),_=ui(i,I),A=a==null?void 0:a.getBoundingClientRect();let S=!1;if(!A||!_)return;const $=li(s,_,r,u,t);if(!$)return;let z=_e(e,A),M=!1,R=null,V=!1,L=null;function X(){if(!d||!A)return;const[Z,K]=yr(z,A,E);f({x:Z,y:K}),O=requestAnimationFrame(X)}const q={...$,nodeId:s,type:_,position:$.position},G=u.get(s);let Y={inProgress:!0,isValid:null,from:tt(G,q,U.Left,!0),fromHandle:q,fromPosition:q.position,fromNode:G,to:z,toHandle:null,toPosition:ts[q.position],toNode:null,pointer:z};function D(){S=!0,m(Y),g==null||g(e,{nodeId:s,handleId:r,handleType:_})}j===0&&D();function F(Z){if(!S){const{x:le,y:xe}=_e(Z),Se=le-T,Ce=xe-H;if(!(Se*Se+Ce*Ce>j*j))return;D()}if(!N()||!q){Q(Z);return}const K=x();z=_e(Z,A),k=Zf(Ht(z,K,!1,[1,1]),n,u,q),M||(X(),M=!0);const W=fi(Z,{handle:k,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:o?"target":"source",isValidConnection:y,doc:P,lib:l,flowId:c,nodeLookup:u});L=W.handleDomNode,R=W.connection,V=Qf(!!k,W.isValid);const ee=u.get(s),ne=ee?tt(ee,q,U.Left,!0):Y.from,re={...Y,from:ne,isValid:V,to:W.toHandle&&V?ft({x:W.toHandle.x,y:W.toHandle.y},K):z,toHandle:W.toHandle,toPosition:V&&W.toHandle?W.toHandle.position:ts[q.position],toNode:W.toHandle?u.get(W.toHandle.nodeId):null,pointer:z};m(re),Y=re}function Q(Z){if(!("touches"in Z&&Z.touches.length>0)){if(S){(k||L)&&R&&V&&(v==null||v(R));const{inProgress:K,...W}=Y,ee={...W,toPosition:Y.toHandle?Y.toPosition:null};w==null||w(Z,ee),i&&(b==null||b(Z,ee))}p(),cancelAnimationFrame(O),M=!1,V=!1,R=null,L=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 fi(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:o,lib:a,flowId:u,isValidConnection:l=di,nodeLookup:d}){const c=i==="target",f=t?o.querySelector(`.${a}-flow__handle[data-id="${u}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:p,y:g}=_e(e),v=o.elementFromPoint(p,g),w=v!=null&&v.classList.contains(`${a}-flow__handle`)?v:f,y={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const b=ui(void 0,w),m=w.getAttribute("data-nodeid"),x=w.getAttribute("data-handleid"),N=w.classList.contains("connectable"),E=w.classList.contains("connectableend");if(!m||!b)return y;const j={source:c?m:r,sourceHandle:c?x:s,target:c?r:m,targetHandle:c?s:x};y.connection=j;const P=N&&E&&(n===ut.Strict?c&&b==="source"||!c&&b==="target":m!==r||x!==s);y.isValid=P&&l(j),y.toHandle=li(m,b,x,d,n,!0)}return y}const nr={onPointerDown:Jf,isValid:fi};function eh({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=ge(e);function i({translateExtent:a,width:u,height:l,zoomStep:d=1,pannable:c=!0,zoomable:f=!0,inversePan:p=!1}){const g=m=>{if(m.sourceEvent.type!=="wheel"||!t)return;const x=n(),N=m.sourceEvent.ctrlKey&&Mt()?10:1,E=-m.sourceEvent.deltaY*(m.sourceEvent.deltaMode===1?.05:m.sourceEvent.deltaMode?1:.002)*d,j=x[2]*Math.pow(2,E*N);t.scaleTo(j)};let v=[0,0];const w=m=>{(m.sourceEvent.type==="mousedown"||m.sourceEvent.type==="touchstart")&&(v=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY])},y=m=>{const x=n();if(m.sourceEvent.type!=="mousemove"&&m.sourceEvent.type!=="touchmove"||!t)return;const N=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY],E=[N[0]-v[0],N[1]-v[1]];v=N;const j=r()*Math.max(x[2],Math.log(x[2]))*(p?-1:1),I={x:x[0]-E[0]*j,y:x[1]-E[1]*j},P=[[0,0],[u,l]];t.setViewportConstrained({x:I.x,y:I.y,zoom:x[2]},P,a)},b=Vo().on("start",w).on("zoom",c?y:null).on("zoom.wheel",f?g:null);s.call(b,{})}function o(){s.on("zoom",null)}return{update:i,destroy:o,pointer:we}}const _n=e=>({x:e.x,y:e.y,zoom:e.k}),Tn=({x:e,y:t,zoom:n})=>wn.translate(e,t).scale(n),rt=(e,t)=>e.target.closest(`.${t}`),hi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),th=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Pn=(e,t=0,n=th,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},pi=e=>{const t=e.ctrlKey&&Mt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function nh({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:o,onPanZoomStart:a,onPanZoom:u,onPanZoomEnd:l}){return d=>{if(rt(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const c=n.property("__zoom").k||1;if(d.ctrlKey&&o){const w=we(d),y=pi(d),b=c*Math.pow(2,y);r.scaleTo(n,b,w,d);return}const f=d.deltaMode===1?20:1;let p=s===Ge.Vertical?0:d.deltaX*f,g=s===Ge.Horizontal?0:d.deltaY*f;!Mt()&&d.shiftKey&&s!==Ge.Vertical&&(p=d.deltaY*f,g=0),r.translateBy(n,-(p/c)*i,-(g/c)*i,{internal:!0});const v=_n(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(u==null||u(d,v),e.panScrollTimeout=setTimeout(()=>{l==null||l(d,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(d,v))}}function rh({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const i=r.type==="wheel",o=!t&&i&&!r.ctrlKey,a=rt(r,e);if(r.ctrlKey&&i&&a&&r.preventDefault(),o||a)return null;r.preventDefault(),n.call(this,r,s)}}function sh({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,o,a;if((i=r.sourceEvent)!=null&&i.internal)return;const s=_n(r.transform);e.mouseButton=((o=r.sourceEvent)==null?void 0:o.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,s))}}function oh({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var o,a;e.usedRightMouseButton=!!(n&&hi(t,e.mouseButton??0)),(o=i.sourceEvent)!=null&&o.sync||r([i.transform.x,i.transform.y,i.transform.k]),s&&!((a=i.sourceEvent)!=null&&a.internal)&&(s==null||s(i.sourceEvent,_n(i.transform)))}}function ih({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:i}){return o=>{var a;if(!((a=o.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,i&&hi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&i(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const u=_n(o.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(o.sourceEvent,u)},n?150:0)}}}function ah({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:o,noWheelClassName:a,noPanClassName:u,lib:l,connectionInProgress:d}){return c=>{var w;const f=e||t,p=n&&c.ctrlKey,g=c.type==="wheel";if(c.button===1&&c.type==="mousedown"&&(rt(c,`${l}-flow__node`)||rt(c,`${l}-flow__edge`)))return!0;if(!r&&!f&&!s&&!i&&!n||o||d&&!g||rt(c,a)&&g||rt(c,u)&&(!g||s&&g&&!e)||!n&&c.ctrlKey&&g)return!1;if(!n&&c.type==="touchstart"&&((w=c.touches)==null?void 0:w.length)>1)return c.preventDefault(),!1;if(!f&&!s&&!p&&g||!r&&(c.type==="mousedown"||c.type==="touchstart")||Array.isArray(r)&&!r.includes(c.button)&&c.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(c.button)||!c.button||c.button<=1;return(!c.ctrlKey||g)&&v}}function ch({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:i,onPanZoomStart:o,onPanZoomEnd:a,onDraggingChange:u}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),c=Vo().scaleExtent([t,n]).translateExtent(r),f=ge(e).call(c);b({x:s.x,y:s.y,zoom:dt(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const p=f.on("wheel.zoom"),g=f.on("dblclick.zoom");c.wheelDelta(pi);async function v(k,T){return f?new Promise(H=>{c==null||c.interpolate((T==null?void 0:T.interpolate)==="linear"?vt:Jt).transform(Pn(f,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>H(!0)),k)}):!1}function w({noWheelClassName:k,noPanClassName:T,onPaneContextMenu:H,userSelectionActive:_,panOnScroll:A,panOnDrag:S,panOnScrollMode:$,panOnScrollSpeed:z,preventScrolling:M,zoomOnPinch:R,zoomOnScroll:V,zoomOnDoubleClick:L,zoomActivationKeyPressed:X,lib:q,onTransformChange:G,connectionInProgress:B,paneClickDistance:Y,selectionOnDrag:D}){_&&!l.isZoomingOrPanning&&y();const F=A&&!X&&!_;c.clickDistance(D?1/0:!be(Y)||Y<0?0:Y);const Q=F?nh({zoomPanValues:l,noWheelClassName:k,d3Selection:f,d3Zoom:c,panOnScrollMode:$,panOnScrollSpeed:z,zoomOnPinch:R,onPanZoomStart:o,onPanZoom:i,onPanZoomEnd:a}):rh({noWheelClassName:k,preventScrolling:M,d3ZoomHandler:p});f.on("wheel.zoom",Q,{passive:!1});const Z=sh({zoomPanValues:l,onDraggingChange:u,onPanZoomStart:o});c.on("start",Z);const K=oh({zoomPanValues:l,panOnDrag:S,onPaneContextMenu:!!H,onPanZoom:i,onTransformChange:G});c.on("zoom",K);const W=ih({zoomPanValues:l,panOnDrag:S,panOnScroll:A,onPaneContextMenu:H,onPanZoomEnd:a,onDraggingChange:u});c.on("end",W);const ee=ah({zoomActivationKeyPressed:X,panOnDrag:S,zoomOnScroll:V,panOnScroll:A,zoomOnDoubleClick:L,zoomOnPinch:R,userSelectionActive:_,noPanClassName:T,noWheelClassName:k,lib:q,connectionInProgress:B});c.filter(ee),L?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function y(){c.on("zoom",null)}async function b(k,T,H){const _=Tn(k),A=c==null?void 0:c.constrain()(_,T,H);return A&&await v(A),A}async function m(k,T){const H=Tn(k);return await v(H,T),H}function x(k){if(f){const T=Tn(k),H=f.property("__zoom");(H.k!==k.zoom||H.x!==k.x||H.y!==k.y)&&(c==null||c.transform(f,T,null,{sync:!0}))}}function N(){const k=f?Ho(f.node()):{x:0,y:0,k:1};return{x:k.x,y:k.y,zoom:k.k}}async function E(k,T){return f?new Promise(H=>{c==null||c.interpolate((T==null?void 0:T.interpolate)==="linear"?vt:Jt).scaleTo(Pn(f,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>H(!0)),k)}):!1}async function j(k,T){return f?new Promise(H=>{c==null||c.interpolate((T==null?void 0:T.interpolate)==="linear"?vt:Jt).scaleBy(Pn(f,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>H(!0)),k)}):!1}function I(k){c==null||c.scaleExtent(k)}function P(k){c==null||c.translateExtent(k)}function O(k){const T=!be(k)||k<0?0:k;c==null||c.clickDistance(T)}return{update:w,destroy:y,setViewport:m,setViewportConstrained:b,getViewport:N,scaleTo:E,scaleBy:j,setScaleExtent:I,setTranslateExtent:P,syncViewport:x,setClickDistance:O}}var ht;(function(e){e.Line="line",e.Handle="handle"})(ht||(ht={}));function lh({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:i}){const o=e-t,a=n-r,u=[o>0?1:o<0?-1:0,a>0?1:a<0?-1:0];return o&&s&&(u[0]=u[0]*-1),a&&i&&(u[1]=u[1]*-1),u}function ps(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function Le(e,t){return Math.max(0,t-e)}function Re(e,t){return Math.max(0,e-t)}function Kt(e,t,n){return Math.max(0,t-e,e-n)}function gs(e,t){return e?!t:t}function uh(e,t,n,r,s,i,o,a){let{affectsX:u,affectsY:l}=t;const{isHorizontal:d,isVertical:c}=t,f=d&&c,{xSnapped:p,ySnapped:g}=n,{minWidth:v,maxWidth:w,minHeight:y,maxHeight:b}=r,{x:m,y:x,width:N,height:E,aspectRatio:j}=e;let I=Math.floor(d?p-e.pointerX:0),P=Math.floor(c?g-e.pointerY:0);const O=N+(u?-I:I),k=E+(l?-P:P),T=-i[0]*N,H=-i[1]*E;let _=Kt(O,v,w),A=Kt(k,y,b);if(o){let z=0,M=0;u&&I<0?z=Le(m+I+T,o[0][0]):!u&&I>0&&(z=Re(m+O+T,o[1][0])),l&&P<0?M=Le(x+P+H,o[0][1]):!l&&P>0&&(M=Re(x+k+H,o[1][1])),_=Math.max(_,z),A=Math.max(A,M)}if(a){let z=0,M=0;u&&I>0?z=Re(m+I,a[0][0]):!u&&I<0&&(z=Le(m+O,a[1][0])),l&&P>0?M=Re(x+P,a[0][1]):!l&&P<0&&(M=Le(x+k,a[1][1])),_=Math.max(_,z),A=Math.max(A,M)}if(s){if(d){const z=Kt(O/j,y,b)*j;if(_=Math.max(_,z),o){let M=0;!u&&!l||u&&!l&&f?M=Re(x+H+O/j,o[1][1])*j:M=Le(x+H+(u?I:-I)/j,o[0][1])*j,_=Math.max(_,M)}if(a){let M=0;!u&&!l||u&&!l&&f?M=Le(x+O/j,a[1][1])*j:M=Re(x+(u?I:-I)/j,a[0][1])*j,_=Math.max(_,M)}}if(c){const z=Kt(k*j,v,w)/j;if(A=Math.max(A,z),o){let M=0;!u&&!l||l&&!u&&f?M=Re(m+k*j+T,o[1][0])/j:M=Le(m+(l?P:-P)*j+T,o[0][0])/j,A=Math.max(A,M)}if(a){let M=0;!u&&!l||l&&!u&&f?M=Le(m+k*j,a[1][0])/j:M=Re(m+(l?P:-P)*j,a[0][0])/j,A=Math.max(A,M)}}}P=P+(P<0?A:-A),I=I+(I<0?_:-_),s&&(f?O>k*j?P=(gs(u,l)?-I:I)/j:I=(gs(u,l)?-P:P)*j:d?(P=I/j,l=u):(I=P*j,u=l));const S=u?m+I:m,$=l?x+P:x;return{width:N+(u?-I:I),height:E+(l?-P:P),x:i[0]*I*(u?-1:1)+S,y:i[1]*P*(l?-1:1)+$}}const gi={width:0,height:0,x:0,y:0},dh={...gi,pointerX:0,pointerY:0,aspectRatio:1};function fh(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,i=e.measured.width??0,o=e.measured.height??0,a=n[0]*i,u=n[1]*o;return[[r-a,s-u],[r+i-a,s+o-u]]}function hh({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const i=ge(e);let o={controlDirection:ps("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:d,keepAspectRatio:c,resizeDirection:f,onResizeStart:p,onResize:g,onResizeEnd:v,shouldResize:w}){let y={...gi},b={...dh};o={boundaries:d,resizeDirection:f,keepAspectRatio:c,controlDirection:ps(l)};let m,x=null,N=[],E,j,I,P=!1;const O=So().on("start",k=>{const{nodeLookup:T,transform:H,snapGrid:_,snapToGrid:A,nodeOrigin:S,paneDomNode:$}=n();if(m=T.get(t),!m)return;x=($==null?void 0:$.getBoundingClientRect())??null;const{xSnapped:z,ySnapped:M}=bt(k.sourceEvent,{transform:H,snapGrid:_,snapToGrid:A,containerBounds:x});y={width:m.measured.width??0,height:m.measured.height??0,x:m.position.x??0,y:m.position.y??0},b={...y,pointerX:z,pointerY:M,aspectRatio:y.width/y.height},E=void 0,j=et(m.extent)?m.extent:void 0,m.parentId&&(m.extent==="parent"||m.expandParent)&&(E=T.get(m.parentId)),E&&m.extent==="parent"&&(j=[[0,0],[E.measured.width,E.measured.height]]),N=[],I=void 0;for(const[R,V]of T)if(V.parentId===t&&(N.push({id:R,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const L=fh(V,m,V.origin??S);I?I=[[Math.min(L[0][0],I[0][0]),Math.min(L[0][1],I[0][1])],[Math.max(L[1][0],I[1][0]),Math.max(L[1][1],I[1][1])]]:I=L}p==null||p(k,{...y})}).on("drag",k=>{const{transform:T,snapGrid:H,snapToGrid:_,nodeOrigin:A}=n(),S=bt(k.sourceEvent,{transform:T,snapGrid:H,snapToGrid:_,containerBounds:x}),$=[];if(!m)return;const{x:z,y:M,width:R,height:V}=y,L={},X=m.origin??A,{width:q,height:G,x:B,y:Y}=uh(b,o.controlDirection,S,o.boundaries,o.keepAspectRatio,X,j,I),D=q!==R,F=G!==V,Q=B!==z&&D,Z=Y!==M&&F;if(!Q&&!Z&&!D&&!F)return;if((Q||Z||X[0]===1||X[1]===1)&&(L.x=Q?B:y.x,L.y=Z?Y:y.y,y.x=L.x,y.y=L.y,N.length>0)){const ne=B-z,re=Y-M;for(const le of N)le.position={x:le.position.x-ne+X[0]*(q-R),y:le.position.y-re+X[1]*(G-V)},$.push(le)}if((D||F)&&(L.width=D&&(!o.resizeDirection||o.resizeDirection==="horizontal")?q:y.width,L.height=F&&(!o.resizeDirection||o.resizeDirection==="vertical")?G:y.height,y.width=L.width,y.height=L.height),E&&m.expandParent){const ne=X[0]*(L.width??0);L.x&&L.x<ne&&(y.x=ne,b.x=b.x-(L.x-ne));const re=X[1]*(L.height??0);L.y&&L.y<re&&(y.y=re,b.y=b.y-(L.y-re))}const K=lh({width:y.width,prevWidth:R,height:y.height,prevHeight:V,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),W={...y,direction:K};(w==null?void 0:w(k,W))!==!1&&(P=!0,g==null||g(k,W),r(L,$))}).on("end",k=>{P&&(v==null||v(k,{...y}),s==null||s({...y}),P=!1)});i.call(O)}function u(){i.on(".drag",null)}return{update:a,destroy:u}}var zn={exports:{}},Dn={},Ln={exports:{}},Rn={};/**
117
+ * @license React
118
+ * use-sync-external-store-shim.production.js
119
+ *
120
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
121
+ *
122
+ * This source code is licensed under the MIT license found in the
123
+ * LICENSE file in the root directory of this source tree.
124
+ */var ms;function ph(){if(ms)return Rn;ms=1;var e=ro();function t(c,f){return c===f&&(c!==0||1/c===1/f)||c!==c&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,i=e.useLayoutEffect,o=e.useDebugValue;function a(c,f){var p=f(),g=r({inst:{value:p,getSnapshot:f}}),v=g[0].inst,w=g[1];return i(function(){v.value=p,v.getSnapshot=f,u(v)&&w({inst:v})},[c,p,f]),s(function(){return u(v)&&w({inst:v}),c(function(){u(v)&&w({inst:v})})},[c]),o(p),p}function u(c){var f=c.getSnapshot;c=c.value;try{var p=f();return!n(c,p)}catch{return!0}}function l(c,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return Rn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,Rn}var xs;function gh(){return xs||(xs=1,Ln.exports=ph()),Ln.exports}/**
125
+ * @license React
126
+ * use-sync-external-store-shim/with-selector.production.js
127
+ *
128
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
129
+ *
130
+ * This source code is licensed under the MIT license found in the
131
+ * LICENSE file in the root directory of this source tree.
132
+ */var ys;function mh(){if(ys)return Dn;ys=1;var e=ro(),t=gh();function n(l,d){return l===d&&(l!==0||1/l===1/d)||l!==l&&d!==d}var r=typeof Object.is=="function"?Object.is:n,s=t.useSyncExternalStore,i=e.useRef,o=e.useEffect,a=e.useMemo,u=e.useDebugValue;return Dn.useSyncExternalStoreWithSelector=function(l,d,c,f,p){var g=i(null);if(g.current===null){var v={hasValue:!1,value:null};g.current=v}else v=g.current;g=a(function(){function y(E){if(!b){if(b=!0,m=E,E=f(E),p!==void 0&&v.hasValue){var j=v.value;if(p(j,E))return x=j}return x=E}if(j=x,r(m,E))return j;var I=f(E);return p!==void 0&&p(j,I)?(m=E,j):(m=E,x=I)}var b=!1,m,x,N=c===void 0?null:c;return[function(){return y(d())},N===null?void 0:function(){return y(N())}]},[d,c,f,p]);var w=s(l,g[0],g[1]);return o(function(){v.hasValue=!0,v.value=w},[w]),u(w),w},Dn}var ws;function xh(){return ws||(ws=1,zn.exports=mh()),zn.exports}var yh=xh();const wh=lc(yh),vh={},vs=e=>{let t;const n=new Set,r=(d,c)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const p=t;t=c??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,p))}},s=()=>t,u={setState:r,getState:s,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(vh?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(r,s,u);return u},bh=e=>e?vs(e):vs,{useDebugValue:_h}=uc,{useSyncExternalStoreWithSelector:Nh}=wh,Eh=e=>e;function mi(e,t=Eh,n){const r=Nh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return _h(r),r}const bs=(e,t)=>{const n=bh(e),r=(s,i=t)=>mi(n,s,i);return Object.assign(r,n),r},Sh=(e,t)=>e?bs(e,t):bs;function oe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const Nn=C.createContext(null),Ch=Nn.Provider,xi=Ne.error001("react");function te(e,t){const n=C.useContext(Nn);if(n===null)throw new Error(xi);return mi(n,e,t)}function ie(){const e=C.useContext(Nn);if(e===null)throw new Error(xi);return C.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const _s={display:"none"},kh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},yi="react-flow__node-desc",wi="react-flow__edge-desc",jh="react-flow__aria-live",Mh=e=>e.ariaLiveMessage,Ah=e=>e.ariaLabelConfig;function $h({rfId:e}){const t=te(Mh);return h.jsx("div",{id:`${jh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:kh,children:t})}function Ih({rfId:e,disableKeyboardA11y:t}){const n=te(Ah);return h.jsxs(h.Fragment,{children:[h.jsx("div",{id:`${yi}-${e}`,style:_s,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),h.jsx("div",{id:`${wi}-${e}`,style:_s,children:n["edge.a11yDescription.default"]}),!t&&h.jsx($h,{rfId:e})]})}const En=C.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},i)=>{const o=`${e}`.split("-");return h.jsx("div",{className:ue(["react-flow__panel",n,...o]),style:r,ref:i,...s,children:t})});En.displayName="Panel";const Ns="https://reactflow.dev?utm_source=attribution";function Th({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:h.jsx(En,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Ns}`,children:h.jsx("a",{href:Ns,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Ph=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Gt=e=>e.id;function zh(e,t){return oe(e.selectedNodes.map(Gt),t.selectedNodes.map(Gt))&&oe(e.selectedEdges.map(Gt),t.selectedEdges.map(Gt))}function Dh({onSelectionChange:e}){const t=ie(),{selectedNodes:n,selectedEdges:r}=te(Ph,zh);return C.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(i=>i(s))},[n,r,e]),null}const Lh=e=>!!e.onSelectionChangeHandlers;function Rh({onSelectionChange:e}){const t=te(Lh);return e||t?h.jsx(Dh,{onSelectionChange:e}):null}const vi=[0,0],Hh={x:0,y:0,zoom:1},Vh=["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"],Es=[...Vh,"rfId"],Bh=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}),Ss={translateExtent:Ct,nodeOrigin:vi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Oh(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:i,setNodeExtent:o,reset:a,setDefaultNodesAndEdges:u}=te(Bh,oe),l=ie();C.useEffect(()=>(u(e.defaultNodes,e.defaultEdges),()=>{d.current=Ss,a()}),[]);const d=C.useRef(Ss);return C.useEffect(()=>{for(const c of Es){const f=e[c],p=d.current[c];f!==p&&(typeof e[c]>"u"||(c==="nodes"?t(f):c==="edges"?n(f):c==="minZoom"?r(f):c==="maxZoom"?s(f):c==="translateExtent"?i(f):c==="nodeExtent"?o(f):c==="ariaLabelConfig"?l.setState({ariaLabelConfig:Cf(f)}):c==="fitView"?l.setState({fitViewQueued:f}):c==="fitViewOptions"?l.setState({fitViewOptions:f}):l.setState({[c]:f})))}d.current=e},Es.map(c=>e[c])),null}function Cs(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Fh(e){var r;const[t,n]=C.useState(e==="system"?null:e);return C.useEffect(()=>{if(e!=="system"){n(e);return}const s=Cs(),i=()=>n(s!=null&&s.matches?"dark":"light");return i(),s==null||s.addEventListener("change",i),()=>{s==null||s.removeEventListener("change",i)}},[e]),t!==null?t:(r=Cs())!=null&&r.matches?"dark":"light"}const ks=typeof document<"u"?document:null;function At(e=null,t={target:ks,actInsideInputWithModifier:!0}){const[n,r]=C.useState(!1),s=C.useRef(!1),i=C.useRef(new Set([])),[o,a]=C.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(c=>typeof c=="string").map(c=>c.replace("+",`
133
+ `).replace(`
134
+
135
+ `,`
136
+ +`).split(`
137
+ `)),d=l.reduce((c,f)=>c.concat(...f),[]);return[l,d]}return[[],[]]},[e]);return C.useEffect(()=>{const u=(t==null?void 0:t.target)??ks,l=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=p=>{var w,y;if(s.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!s.current||s.current&&!l)&&ei(p))return!1;const v=Ms(p.code,a);if(i.current.add(p[v]),js(o,i.current,!1)){const b=((y=(w=p.composedPath)==null?void 0:w.call(p))==null?void 0:y[0])||p.target,m=(b==null?void 0:b.nodeName)==="BUTTON"||(b==null?void 0:b.nodeName)==="A";t.preventDefault!==!1&&(s.current||!m)&&p.preventDefault(),r(!0)}},c=p=>{const g=Ms(p.code,a);js(o,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(p[g]),p.key==="Meta"&&i.current.clear(),s.current=!1},f=()=>{i.current.clear(),r(!1)};return u==null||u.addEventListener("keydown",d),u==null||u.addEventListener("keyup",c),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{u==null||u.removeEventListener("keydown",d),u==null||u.removeEventListener("keyup",c),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function js(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function Ms(e,t){return t.includes(e)?"code":"key"}const Yh=()=>{const e=ie();return C.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,i],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??i},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:i,maxZoom:o,panZoom:a}=e.getState(),u=wr(t,r,s,i,o,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(u,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:s,snapToGrid:i,domNode:o}=e.getState();if(!o)return t;const{x:a,y:u}=o.getBoundingClientRect(),l={x:t.x-a,y:t.y-u},d=n.snapGrid??s,c=n.snapToGrid??i;return Ht(l,r,c,d)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:i}=r.getBoundingClientRect(),o=ft(t,n);return{x:o.x+s,y:o.y+i}}}),[])};function bi(e,t){const n=[],r=new Map,s=[];for(const i of e)if(i.type==="add"){s.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const o=r.get(i.id);o?o.push(i):r.set(i.id,[i])}for(const i of t){const o=r.get(i.id);if(!o){n.push(i);continue}if(o[0].type==="remove")continue;if(o[0].type==="replace"){n.push({...o[0].item});continue}const a={...i};for(const u of o)Xh(u,a);n.push(a)}return s.length&&s.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function Xh(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function _i(e,t){return bi(e,t)}function Ni(e,t){return bi(e,t)}function Xe(e,t){return{id:e,type:"select",selected:t}}function st(e,t=new Set,n=!1){const r=[];for(const[s,i]of e){const o=t.has(s);!(i.selected===void 0&&!o)&&i.selected!==o&&(n&&(i.selected=o),r.push(Xe(i.id,o)))}return r}function As({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,o]of e.entries()){const a=t.get(o.id),u=((s=a==null?void 0:a.internals)==null?void 0:s.userNode)??a;u!==void 0&&u!==o&&n.push({id:o.id,item:o,type:"replace"}),u===void 0&&n.push({item:o,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function $s(e){return{id:e.id,type:"remove"}}const qh=Go();function Wh(e,t,n={}){return If(e,t,{...n,onError:n.onError??qh})}const Is=e=>xf(e),Uh=e=>Xo(e);function Ei(e){return C.forwardRef(e)}const Kh=typeof window<"u"?C.useLayoutEffect:C.useEffect;function Ts(e){const[t,n]=C.useState(BigInt(0)),[r]=C.useState(()=>Gh(()=>n(s=>s+BigInt(1))));return Kh(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function Gh(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Si=C.createContext(null);function Zh({children:e}){const t=ie(),n=C.useCallback(a=>{const{nodes:u=[],setNodes:l,hasDefaultNodes:d,onNodesChange:c,nodeLookup:f,fitViewQueued:p,onNodesChangeMiddlewareMap:g}=t.getState();let v=u;for(const y of a)v=typeof y=="function"?y(v):y;let w=As({items:v,lookup:f});for(const y of g.values())w=y(w);d&&l(v),w.length>0?c==null||c(w):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:b,setNodes:m}=t.getState();y&&m(b)})},[]),r=Ts(n),s=C.useCallback(a=>{const{edges:u=[],setEdges:l,hasDefaultEdges:d,onEdgesChange:c,edgeLookup:f}=t.getState();let p=u;for(const g of a)p=typeof g=="function"?g(p):g;d?l(p):c&&c(As({items:p,lookup:f}))},[]),i=Ts(s),o=C.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return h.jsx(Si.Provider,{value:o,children:e})}function Qh(){const e=C.useContext(Si);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Jh=e=>!!e.panZoom;function Vt(){const e=Yh(),t=ie(),n=Qh(),r=te(Jh),s=C.useMemo(()=>{const i=c=>t.getState().nodeLookup.get(c),o=c=>{n.nodeQueue.push(c)},a=c=>{n.edgeQueue.push(c)},u=c=>{var y,b;const{nodeLookup:f,nodeOrigin:p}=t.getState(),g=Is(c)?c:f.get(c.id),v=g.parentId?Qo(g.position,g.measured,g.parentId,f,p):g.position,w={...g,position:v,width:((y=g.measured)==null?void 0:y.width)??g.width,height:((b=g.measured)==null?void 0:b.height)??g.height};return jt(w)},l=(c,f,p={replace:!1})=>{o(g=>g.map(v=>{if(v.id===c){const w=typeof f=="function"?f(v):f;return p.replace&&Is(w)?w:{...v,...w}}return v}))},d=(c,f,p={replace:!1})=>{a(g=>g.map(v=>{if(v.id===c){const w=typeof f=="function"?f(v):f;return p.replace&&Uh(w)?w:{...v,...w}}return v}))};return{getNodes:()=>t.getState().nodes.map(c=>({...c})),getNode:c=>{var f;return(f=i(c))==null?void 0:f.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:c=[]}=t.getState();return c.map(f=>({...f}))},getEdge:c=>t.getState().edgeLookup.get(c),setNodes:o,setEdges:a,addNodes:c=>{const f=Array.isArray(c)?c:[c];n.nodeQueue.push(p=>[...p,...f])},addEdges:c=>{const f=Array.isArray(c)?c:[c];n.edgeQueue.push(p=>[...p,...f])},toObject:()=>{const{nodes:c=[],edges:f=[],transform:p}=t.getState(),[g,v,w]=p;return{nodes:c.map(y=>({...y})),edges:f.map(y=>({...y})),viewport:{x:g,y:v,zoom:w}}},deleteElements:async({nodes:c=[],edges:f=[]})=>{const{nodes:p,edges:g,onNodesDelete:v,onEdgesDelete:w,triggerNodeChanges:y,triggerEdgeChanges:b,onDelete:m,onBeforeDelete:x}=t.getState(),{nodes:N,edges:E}=await _f({nodesToRemove:c,edgesToRemove:f,nodes:p,edges:g,onBeforeDelete:x}),j=E.length>0,I=N.length>0;if(j){const P=E.map($s);w==null||w(E),b(P)}if(I){const P=N.map($s);v==null||v(N),y(P)}return(I||j)&&(m==null||m({nodes:N,edges:E})),{deletedNodes:N,deletedEdges:E}},getIntersectingNodes:(c,f=!0,p)=>{const g=rs(c),v=g?c:u(c),w=p!==void 0;return v?(p||t.getState().nodes).filter(y=>{const b=t.getState().nodeLookup.get(y.id);if(b&&!g&&(y.id===c.id||!b.internals.positionAbsolute))return!1;const m=jt(w?y:b),x=hn(m,v);return f&&x>0||x>=m.width*m.height||x>=v.width*v.height}):[]},isNodeIntersecting:(c,f,p=!0)=>{const v=rs(c)?c:u(c);if(!v)return!1;const w=hn(v,f);return p&&w>0||w>=f.width*f.height||w>=v.width*v.height},updateNode:l,updateNodeData:(c,f,p={replace:!1})=>{l(c,g=>{const v=typeof f=="function"?f(g):f;return p.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},p)},updateEdge:d,updateEdgeData:(c,f,p={replace:!1})=>{d(c,g=>{const v=typeof f=="function"?f(g):f;return p.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},p)},getNodesBounds:c=>{const{nodeLookup:f,nodeOrigin:p}=t.getState();return yf(c,{nodeLookup:f,nodeOrigin:p})},getHandleConnections:({type:c,id:f,nodeId:p})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${p}-${c}${f?`-${f}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:c,handleId:f,nodeId:p})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${p}${c?f?`-${c}-${f}`:`-${c}`:""}`))==null?void 0:g.values())??[])},fitView:async c=>{const f=t.getState().fitViewResolver??Sf();return t.setState({fitViewQueued:!0,fitViewOptions:c,fitViewResolver:f}),n.nodeQueue.push(p=>[...p]),f.promise}}},[]);return C.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const Ps=e=>e.selected,ep=typeof window<"u"?window:void 0;function tp({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=ie(),{deleteElements:r}=Vt(),s=At(e,{actInsideInputWithModifier:!1}),i=At(t,{target:ep});C.useEffect(()=>{if(s){const{edges:o,nodes:a}=n.getState();r({nodes:a.filter(Ps),edges:o.filter(Ps)}),n.setState({nodesSelectionActive:!1})}},[s]),C.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function np(e){const t=ie();C.useEffect(()=>{const n=()=>{var s,i,o,a;if(!e.current||!(((i=(s=e.current).checkVisibility)==null?void 0:i.call(s))??!0))return!1;const r=vr(e.current);(r.height===0||r.width===0)&&((a=(o=t.getState()).onError)==null||a.call(o,"004",Ne.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const Sn={position:"absolute",width:"100%",height:"100%",top:0,left:0},rp=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function sp({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=Ge.Free,zoomOnDoubleClick:o=!0,panOnDrag:a=!0,defaultViewport:u,translateExtent:l,minZoom:d,maxZoom:c,zoomActivationKeyCode:f,preventScrolling:p=!0,children:g,noWheelClassName:v,noPanClassName:w,onViewportChange:y,isControlledViewport:b,paneClickDistance:m,selectionOnDrag:x}){const N=ie(),E=C.useRef(null),{userSelectionActive:j,lib:I,connectionInProgress:P}=te(rp,oe),O=At(f),k=C.useRef();np(E);const T=C.useCallback(H=>{y==null||y({x:H[0],y:H[1],zoom:H[2]}),b||N.setState({transform:H})},[y,b]);return C.useEffect(()=>{if(E.current){k.current=ch({domNode:E.current,minZoom:d,maxZoom:c,translateExtent:l,viewport:u,onDraggingChange:S=>N.setState($=>$.paneDragging===S?$:{paneDragging:S}),onPanZoomStart:(S,$)=>{const{onViewportChangeStart:z,onMoveStart:M}=N.getState();M==null||M(S,$),z==null||z($)},onPanZoom:(S,$)=>{const{onViewportChange:z,onMove:M}=N.getState();M==null||M(S,$),z==null||z($)},onPanZoomEnd:(S,$)=>{const{onViewportChangeEnd:z,onMoveEnd:M}=N.getState();M==null||M(S,$),z==null||z($)}});const{x:H,y:_,zoom:A}=k.current.getViewport();return N.setState({panZoom:k.current,transform:[H,_,A],domNode:E.current.closest(".react-flow")}),()=>{var S;(S=k.current)==null||S.destroy()}}},[]),C.useEffect(()=>{var H;(H=k.current)==null||H.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:o,panOnDrag:a,zoomActivationKeyPressed:O,preventScrolling:p,noPanClassName:w,userSelectionActive:j,noWheelClassName:v,lib:I,onTransformChange:T,connectionInProgress:P,selectionOnDrag:x,paneClickDistance:m})},[e,t,n,r,s,i,o,a,O,p,w,j,v,I,T,P,x,m]),h.jsx("div",{className:"react-flow__renderer",ref:E,style:Sn,children:g})}const op=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function ip(){const{userSelectionActive:e,userSelectionRect:t}=te(op,oe);return e&&t?h.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Hn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},ap=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function cp({isSelecting:e,selectionKeyPressed:t,selectionMode:n=kt.Full,panOnDrag:r,autoPanOnSelection:s,paneClickDistance:i,selectionOnDrag:o,onSelectionStart:a,onSelectionEnd:u,onPaneClick:l,onPaneContextMenu:d,onPaneScroll:c,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:g,children:v}){const w=C.useRef(0),y=ie(),{userSelectionActive:b,elementsSelectable:m,dragging:x,panBy:N,autoPanSpeed:E}=te(ap,oe),j=m&&(e||b),I=C.useRef(null),P=C.useRef(),O=C.useRef(new Set),k=C.useRef(new Set),T=C.useRef(!1),H=C.useRef(!1),_=C.useRef({x:0,y:0}),A=C.useRef(!1),S=D=>{if(H.current||T.current||y.getState().connection.inProgress){H.current=!1,T.current=!1;return}l==null||l(D),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},$=D=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){D.preventDefault();return}d==null||d(D)},z=c?D=>c(D):void 0,M=D=>{H.current&&(D.stopPropagation(),H.current=!1)},R=D=>{var le,xe;const{domNode:F,transform:Q}=y.getState();if(P.current=F==null?void 0:F.getBoundingClientRect(),!P.current)return;const Z=D.target===I.current;if(!Z&&!!D.target.closest(".nokey")||!e||!(o&&Z||t)||D.button!==0||!D.isPrimary)return;(xe=(le=D.target)==null?void 0:le.setPointerCapture)==null||xe.call(le,D.pointerId),H.current=!1;const{x:ee,y:ne}=_e(D.nativeEvent,P.current),re=Ht({x:ee,y:ne},Q);y.setState({userSelectionRect:{width:0,height:0,startX:re.x,startY:re.y,x:ee,y:ne}}),Z||(D.stopPropagation(),D.preventDefault())};function V(D,F){const{userSelectionRect:Q}=y.getState();if(!Q)return;const{transform:Z,nodeLookup:K,edgeLookup:W,connectionLookup:ee,triggerNodeChanges:ne,triggerEdgeChanges:re,defaultEdgeOptions:le}=y.getState(),xe={x:Q.startX,y:Q.startY},{x:Se,y:Ce}=ft(xe,Z),Ae={startX:xe.x,startY:xe.y,x:D<Se?D:Se,y:F<Ce?F:Ce,width:Math.abs(D-Se),height:Math.abs(F-Ce)},pt=O.current,Oe=k.current;O.current=new Set(xr(K,Ae,Z,n===kt.Partial,!0).map(ye=>ye.id)),k.current=new Set;const Fe=(le==null?void 0:le.selectable)??!0;for(const ye of O.current){const $e=ee.get(ye);if($e)for(const{edgeId:Ie}of $e.values()){const Ye=W.get(Ie);Ye&&(Ye.selectable??Fe)&&k.current.add(Ie)}}if(!ss(pt,O.current)){const ye=st(K,O.current,!0);ne(ye)}if(!ss(Oe,k.current)){const ye=st(W,k.current);re(ye)}y.setState({userSelectionRect:Ae,userSelectionActive:!0,nodesSelectionActive:!1})}function L(){if(!s||!P.current)return;const[D,F]=yr(_.current,P.current,E);N({x:D,y:F}).then(Q=>{if(!H.current||!Q){w.current=requestAnimationFrame(L);return}const{x:Z,y:K}=_.current;V(Z,K),w.current=requestAnimationFrame(L)})}const X=()=>{cancelAnimationFrame(w.current),w.current=0,A.current=!1};C.useEffect(()=>()=>X(),[]);const q=D=>{const{userSelectionRect:F,transform:Q,resetSelectedElements:Z}=y.getState();if(!P.current||!F)return;const{x:K,y:W}=_e(D.nativeEvent,P.current);_.current={x:K,y:W};const ee=ft({x:F.startX,y:F.startY},Q);if(!H.current){const ne=t?0:i;if(Math.hypot(K-ee.x,W-ee.y)<=ne)return;Z(),a==null||a(D)}H.current=!0,A.current||(L(),A.current=!0),V(K,W)},G=D=>{var F,Q;if(!j){D.target===I.current&&y.getState().connection.inProgress&&(T.current=!0);return}D.button===0&&((Q=(F=D.target)==null?void 0:F.releasePointerCapture)==null||Q.call(F,D.pointerId),!b&&D.target===I.current&&y.getState().userSelectionRect&&(S==null||S(D)),y.setState({userSelectionActive:!1,userSelectionRect:null}),H.current&&(u==null||u(D),y.setState({nodesSelectionActive:O.current.size>0})),X())},B=D=>{var F,Q;(Q=(F=D.target)==null?void 0:F.releasePointerCapture)==null||Q.call(F,D.pointerId),X()},Y=r===!0||Array.isArray(r)&&r.includes(0);return h.jsxs("div",{className:ue(["react-flow__pane",{draggable:Y,dragging:x,selection:e}]),onClick:j?void 0:Hn(S,I),onContextMenu:Hn($,I),onWheel:Hn(z,I),onPointerEnter:j?void 0:f,onPointerMove:j?q:p,onPointerUp:G,onPointerCancel:j?B:void 0,onPointerDownCapture:j?R:void 0,onClickCapture:j?M:void 0,onPointerLeave:g,ref:I,style:Sn,children:[v,h.jsx(ip,{})]})}function rr({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:o,nodeLookup:a,onError:u}=t.getState(),l=a.get(e);if(!l){u==null||u("012",Ne.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(i({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):s([e])}function Ci({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:o}){const a=ie(),[u,l]=C.useState(!1),d=C.useRef();return C.useEffect(()=>{d.current=Uf({getStoreItems:()=>a.getState(),onNodeMouseDown:c=>{rr({id:c,store:a,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),C.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:o}),()=>{var c;(c=d.current)==null||c.destroy()}},[n,r,t,i,e,s,o]),u}const lp=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function ki(){const e=ie();return C.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:o,onError:a,updateNodePositions:u,nodeLookup:l,nodeOrigin:d}=e.getState(),c=new Map,f=lp(o),p=s?i[0]:5,g=s?i[1]:5,v=n.direction.x*p*n.factor,w=n.direction.y*g*n.factor;for(const[,y]of l){if(!f(y))continue;let b={x:y.internals.positionAbsolute.x+v,y:y.internals.positionAbsolute.y+w};s&&(b=Rt(b,i));const{position:m,positionAbsolute:x}=qo({nodeId:y.id,nextPosition:b,nodeLookup:l,nodeExtent:r,nodeOrigin:d,onError:a});y.position=m,y.internals.positionAbsolute=x,c.set(y.id,y)}u(c)},[])}const kr=C.createContext(null),up=kr.Provider;kr.Consumer;const ji=()=>C.useContext(kr),dp=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Mi=C.createContext(null);function fp({children:e}){const t=te(dp,oe);return h.jsx(Mi.Provider,{value:t,children:e})}function hp(){const e=C.useContext(Mi);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const pp={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},gp=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:o}=r,{fromHandle:a,toHandle:u,isValid:l}=o;if(!a&&!s)return pp;const d=(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:d,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===ut.Strict?(a==null?void 0:a.type)!==n:e!==(a==null?void 0:a.nodeId)||t!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!s,valid:d&&l}};function mp({type:e="source",position:t=U.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:o,onConnect:a,children:u,className:l,onMouseDown:d,onTouchStart:c,...f},p){var A,S;const g=o||null,v=e==="target",w=ie(),y=ji(),{connectOnClick:b,noPanClassName:m,rfId:x}=hp(),{connectingFrom:N,connectingTo:E,clickConnecting:j,isPossibleEndHandle:I,connectionInProcess:P,clickConnectionInProcess:O,valid:k}=te(gp(y,g,e),oe);y||(S=(A=w.getState()).onError)==null||S.call(A,"010",Ne.error010());const T=$=>{const{defaultEdgeOptions:z,onConnect:M,hasDefaultEdges:R}=w.getState(),V={...z,...$};if(R){const{edges:L,setEdges:X,onError:q}=w.getState();X(Wh(V,L,{onError:q}))}M==null||M(V),a==null||a(V)},H=$=>{if(!y)return;const z=ti($.nativeEvent);if(s&&(z&&$.button===0||!z)){const M=w.getState();nr.onPointerDown($.nativeEvent,{handleDomNode:$.currentTarget,autoPanOnConnect:M.autoPanOnConnect,connectionMode:M.connectionMode,connectionRadius:M.connectionRadius,domNode:M.domNode,nodeLookup:M.nodeLookup,lib:M.lib,isTarget:v,handleId:g,nodeId:y,flowId:M.rfId,panBy:M.panBy,cancelConnection:M.cancelConnection,onConnectStart:M.onConnectStart,onConnectEnd:(...R)=>{var V,L;return(L=(V=w.getState()).onConnectEnd)==null?void 0:L.call(V,...R)},updateConnection:M.updateConnection,onConnect:T,isValidConnection:n||((...R)=>{var V,L;return((L=(V=w.getState()).isValidConnection)==null?void 0:L.call(V,...R))??!0}),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:M.autoPanSpeed,dragThreshold:M.connectionDragThreshold})}z?d==null||d($):c==null||c($)},_=$=>{const{onClickConnectStart:z,onClickConnectEnd:M,connectionClickStartHandle:R,connectionMode:V,isValidConnection:L,lib:X,rfId:q,nodeLookup:G,connection:B}=w.getState();if(!y||!R&&!s)return;if(!R){z==null||z($.nativeEvent,{nodeId:y,handleId:g,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const Y=Jo($.target),D=n||L,{connection:F,isValid:Q}=nr.isValid($.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:V,fromNodeId:R.nodeId,fromHandleId:R.id||null,fromType:R.type,isValidConnection:D,flowId:q,doc:Y,lib:X,nodeLookup:G});Q&&F&&T(F);const Z=structuredClone(B);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,M==null||M($,Z),w.setState({connectionClickStartHandle:null})};return h.jsx("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${x}-${y}-${g}-${e}`,className:ue(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",m,l,{source:!v,target:v,connectable:r,connectablestart:s,connectableend:i,clickconnecting:j,connectingfrom:N,connectingto:E,valid:k,connectionindicator:r&&(!P||I)&&(P||O?i:s)}]),onMouseDown:H,onTouchStart:H,onClick:b?_:void 0,ref:p,...f,children:u})}const $t=C.memo(Ei(mp));function xp({data:e,isConnectable:t,sourcePosition:n=U.Bottom}){return h.jsxs(h.Fragment,{children:[e==null?void 0:e.label,h.jsx($t,{type:"source",position:n,isConnectable:t})]})}function yp({data:e,isConnectable:t,targetPosition:n=U.Top,sourcePosition:r=U.Bottom}){return h.jsxs(h.Fragment,{children:[h.jsx($t,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,h.jsx($t,{type:"source",position:r,isConnectable:t})]})}function wp(){return null}function vp({data:e,isConnectable:t,targetPosition:n=U.Top}){return h.jsxs(h.Fragment,{children:[h.jsx($t,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const pn={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},zs={input:xp,default:yp,output:vp,group:wp};function bp(e){var t,n,r,s;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((s=e.style)==null?void 0:s.height)}}const _p=e=>{const{width:t,height:n,x:r,y:s}=Lt(e.nodeLookup,{filter:i=>!!i.selected});return{width:be(t)?t:null,height:be(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function Np({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=ie(),{width:s,height:i,transformString:o,userSelectionActive:a}=te(_p,oe),u=ki(),l=C.useRef(null);C.useEffect(()=>{var p;n||(p=l.current)==null||p.focus({preventScroll:!0})},[n]);const d=!a&&s!==null&&i!==null;if(Ci({nodeRef:l,disabled:!d}),!d)return null;const c=e?p=>{const g=r.getState().nodes.filter(v=>v.selected);e(p,g)}:void 0,f=p=>{Object.prototype.hasOwnProperty.call(pn,p.key)&&(p.preventDefault(),u({direction:pn[p.key],factor:p.shiftKey?4:1}))};return h.jsx("div",{className:ue(["react-flow__nodesselection","react-flow__container",t]),style:{transform:o},children:h.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:c,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:s,height:i}})})}const Ds=typeof window<"u"?window:void 0,Ep=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Ai({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,paneClickDistance:a,deleteKeyCode:u,selectionKeyCode:l,selectionOnDrag:d,selectionMode:c,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:g,panActivationKeyCode:v,zoomActivationKeyCode:w,elementsSelectable:y,zoomOnScroll:b,zoomOnPinch:m,panOnScroll:x,panOnScrollSpeed:N,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:I,autoPanOnSelection:P,defaultViewport:O,translateExtent:k,minZoom:T,maxZoom:H,preventScrolling:_,onSelectionContextMenu:A,noWheelClassName:S,noPanClassName:$,disableKeyboardA11y:z,onViewportChange:M,isControlledViewport:R}){const{nodesSelectionActive:V,userSelectionActive:L}=te(Ep,oe),X=At(l,{target:Ds}),q=At(v,{target:Ds}),G=q||I,B=q||x,Y=d&&G!==!0,D=X||L||Y;return tp({deleteKeyCode:u,multiSelectionKeyCode:g}),h.jsx(sp,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:b,zoomOnPinch:m,panOnScroll:B,panOnScrollSpeed:N,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:!X&&G,defaultViewport:O,translateExtent:k,minZoom:T,maxZoom:H,zoomActivationKeyCode:w,preventScrolling:_,noWheelClassName:S,noPanClassName:$,onViewportChange:M,isControlledViewport:R,paneClickDistance:a,selectionOnDrag:Y,children:h.jsxs(cp,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:o,panOnDrag:G,autoPanOnSelection:P,isSelecting:!!D,selectionMode:c,selectionKeyPressed:X,paneClickDistance:a,selectionOnDrag:Y,children:[e,V&&h.jsx(Np,{onSelectionContextMenu:A,noPanClassName:$,disableKeyboardA11y:z})]})})}Ai.displayName="FlowRenderer";const Sp=C.memo(Ai),Cp=e=>t=>e?xr(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function kp(e){return te(C.useCallback(Cp(e),[e]),oe)}const jp=e=>e.updateNodeInternals;function Mp(){const e=te(jp),[t]=C.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const i=s.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:s.target,force:!0})}),e(r)}));return C.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Ap({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=ie(),i=C.useRef(null),o=C.useRef(null),a=C.useRef(e.sourcePosition),u=C.useRef(e.targetPosition),l=C.useRef(t),d=n&&!!e.internals.handleBounds;return C.useEffect(()=>{i.current&&!e.hidden&&(!d||o.current!==i.current)&&(o.current&&(r==null||r.unobserve(o.current)),r==null||r.observe(i.current),o.current=i.current)},[d,e.hidden]),C.useEffect(()=>()=>{o.current&&(r==null||r.unobserve(o.current),o.current=null)},[]),C.useEffect(()=>{if(i.current){const c=l.current!==t,f=a.current!==e.sourcePosition,p=u.current!==e.targetPosition;(c||f||p)&&(l.current=t,a.current=e.sourcePosition,u.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function $p({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:o,nodesDraggable:a,elementsSelectable:u,nodesConnectable:l,nodesFocusable:d,resizeObserver:c,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:g,rfId:v,nodeTypes:w,nodeClickDistance:y,onError:b}){const{node:m,internals:x,isParent:N}=te(D=>{const F=D.nodeLookup.get(e),Q=D.parentLookup.has(e);return{node:F,internals:F.internals,isParent:Q}},oe);let E=m.type||"default",j=(w==null?void 0:w[E])||zs[E];j===void 0&&(b==null||b("003",Ne.error003(E)),E="default",j=(w==null?void 0:w.default)||zs.default);const I=!!(m.draggable||a&&typeof m.draggable>"u"),P=!!(m.selectable||u&&typeof m.selectable>"u"),O=!!(m.connectable||l&&typeof m.connectable>"u"),k=!!(m.focusable||d&&typeof m.focusable>"u"),T=ie(),H=Zo(m),_=Ap({node:m,nodeType:E,hasDimensions:H,resizeObserver:c}),A=Ci({nodeRef:_,disabled:m.hidden||!I,noDragClassName:f,handleSelector:m.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:y}),S=ki();if(m.hidden)return null;const $=De(m),z=bp(m),M=P||I||t||n||r||s,R=n?D=>n(D,{...x.userNode}):void 0,V=r?D=>r(D,{...x.userNode}):void 0,L=s?D=>s(D,{...x.userNode}):void 0,X=i?D=>i(D,{...x.userNode}):void 0,q=o?D=>o(D,{...x.userNode}):void 0,G=D=>{const{selectNodesOnDrag:F,nodeDragThreshold:Q}=T.getState();P&&(!F||!I||Q>0)&&rr({id:e,store:T,nodeRef:_}),t&&t(D,{...x.userNode})},B=D=>{if(!(ei(D.nativeEvent)||g)){if(Bo.includes(D.key)&&P){const F=D.key==="Escape";rr({id:e,store:T,unselect:F,nodeRef:_})}else if(I&&m.selected&&Object.prototype.hasOwnProperty.call(pn,D.key)){D.preventDefault();const{ariaLabelConfig:F}=T.getState();T.setState({ariaLiveMessage:F["node.a11yDescription.ariaLiveMessage"]({direction:D.key.replace("Arrow","").toLowerCase(),x:~~x.positionAbsolute.x,y:~~x.positionAbsolute.y})}),S({direction:pn[D.key],factor:D.shiftKey?4:1})}}},Y=()=>{var ee;if(g||!((ee=_.current)!=null&&ee.matches(":focus-visible")))return;const{transform:D,width:F,height:Q,autoPanOnNodeFocus:Z,setCenter:K}=T.getState();if(!Z)return;xr(new Map([[e,m]]),{x:0,y:0,width:F,height:Q},D,!0).length>0||K(m.position.x+$.width/2,m.position.y+$.height/2,{zoom:D[2]})};return h.jsx("div",{className:ue(["react-flow__node",`react-flow__node-${E}`,{[p]:I},m.className,{selected:m.selected,selectable:P,parent:N,draggable:I,dragging:A}]),ref:_,style:{zIndex:x.z,transform:`translate(${x.positionAbsolute.x}px,${x.positionAbsolute.y}px)`,pointerEvents:M?"all":"none",visibility:H?"visible":"hidden",...m.style,...z},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:R,onMouseMove:V,onMouseLeave:L,onContextMenu:X,onClick:G,onDoubleClick:q,onKeyDown:k?B:void 0,tabIndex:k?0:void 0,onFocus:k?Y:void 0,role:m.ariaRole??(k?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${yi}-${v}`,"aria-label":m.ariaLabel,...m.domAttributes,children:h.jsx(up,{value:e,children:h.jsx(j,{id:e,data:m.data,type:E,positionAbsoluteX:x.positionAbsolute.x,positionAbsoluteY:x.positionAbsolute.y,selected:m.selected??!1,selectable:P,draggable:I,deletable:m.deletable??!0,isConnectable:O,sourcePosition:m.sourcePosition,targetPosition:m.targetPosition,dragging:A,dragHandle:m.dragHandle,zIndex:x.z,parentId:m.parentId,...$})})})}var Ip=C.memo($p);const Tp=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function $i(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=te(Tp,oe),o=kp(e.onlyRenderVisibleElements),a=Mp();return h.jsx("div",{className:"react-flow__nodes",style:Sn,children:o.map(u=>h.jsx(Ip,{id:u,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:a,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:i},u))})}$i.displayName="NodeRenderer";const Pp=C.memo($i);function zp(e){return te(C.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const i=n.nodeLookup.get(s.source),o=n.nodeLookup.get(s.target);i&&o&&Mf({sourceNode:i,targetNode:o,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),oe)}const Dp=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return h.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Lp=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return h.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Ls={[dn.Arrow]:Dp,[dn.ArrowClosed]:Lp};function Rp(e){const t=ie();return C.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(Ls,e)?Ls[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Ne.error009(e)),null)},[e])}const Hp=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:o,orient:a="auto-start-reverse"})=>{const u=Rp(t);return u?h.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:h.jsx(u,{color:n,strokeWidth:o})}):null},Ii=({defaultColor:e,rfId:t})=>{const n=te(i=>i.edges),r=te(i=>i.defaultEdgeOptions),s=C.useMemo(()=>Lf(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return s.length?h.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:h.jsx("defs",{children:s.map(i=>h.jsx(Hp,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Ii.displayName="MarkerDefinitions";var Vp=C.memo(Ii);function Ti({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:i,labelBgPadding:o=[2,4],labelBgBorderRadius:a=2,children:u,className:l,...d}){const[c,f]=C.useState({x:1,y:0,width:0,height:0}),p=ue(["react-flow__edge-textwrapper",l]),g=C.useRef(null);return C.useEffect(()=>{if(g.current){const v=g.current.getBBox();f({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?h.jsxs("g",{transform:`translate(${e-c.width/2} ${t-c.height/2})`,className:p,visibility:c.width?"visible":"hidden",...d,children:[s&&h.jsx("rect",{width:c.width+2*o[0],x:-o[0],y:-o[1],height:c.height+2*o[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),h.jsx("text",{className:"react-flow__edge-text",y:c.height/2,dy:"0.3em",ref:g,style:r,children:n}),u]}):null}Ti.displayName="EdgeText";const Bp=C.memo(Ti);function Bt({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:o,labelBgPadding:a,labelBgBorderRadius:u,interactionWidth:l=20,...d}){return h.jsxs(h.Fragment,{children:[h.jsx("path",{...d,d:e,fill:"none",className:ue(["react-flow__edge-path",d.className])}),l?h.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,r&&be(t)&&be(n)?h.jsx(Bp,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:o,labelBgPadding:a,labelBgBorderRadius:u}):null]})}function Rs({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===U.Left||e===U.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function Pi({sourceX:e,sourceY:t,sourcePosition:n=U.Bottom,targetX:r,targetY:s,targetPosition:i=U.Top}){const[o,a]=Rs({pos:n,x1:e,y1:t,x2:r,y2:s}),[u,l]=Rs({pos:i,x1:r,y1:s,x2:e,y2:t}),[d,c,f,p]=ni({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:o,sourceControlY:a,targetControlX:u,targetControlY:l});return[`M${e},${t} C${o},${a} ${u},${l} ${r},${s}`,d,c,f,p]}function zi(e){return C.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:o,targetPosition:a,label:u,labelStyle:l,labelShowBg:d,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:w,interactionWidth:y})=>{const[b,m,x]=Pi({sourceX:n,sourceY:r,sourcePosition:o,targetX:s,targetY:i,targetPosition:a}),N=e.isInternal?void 0:t;return h.jsx(Bt,{id:N,path:b,labelX:m,labelY:x,label:u,labelStyle:l,labelShowBg:d,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:w,interactionWidth:y})})}const Op=zi({isInternal:!1}),Di=zi({isInternal:!0});Op.displayName="SimpleBezierEdge";Di.displayName="SimpleBezierEdgeInternal";function Li(e){return C.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:o,labelStyle:a,labelShowBg:u,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:c,style:f,sourcePosition:p=U.Bottom,targetPosition:g=U.Top,markerEnd:v,markerStart:w,pathOptions:y,interactionWidth:b})=>{const[m,x,N]=Jn({sourceX:n,sourceY:r,sourcePosition:p,targetX:s,targetY:i,targetPosition:g,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset,stepPosition:y==null?void 0:y.stepPosition}),E=e.isInternal?void 0:t;return h.jsx(Bt,{id:E,path:m,labelX:x,labelY:N,label:o,labelStyle:a,labelShowBg:u,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:c,style:f,markerEnd:v,markerStart:w,interactionWidth:b})})}const Ri=Li({isInternal:!1}),Hi=Li({isInternal:!0});Ri.displayName="SmoothStepEdge";Hi.displayName="SmoothStepEdgeInternal";function Vi(e){return C.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return h.jsx(Ri,{...n,id:r,pathOptions:C.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const Fp=Vi({isInternal:!1}),Bi=Vi({isInternal:!0});Fp.displayName="StepEdge";Bi.displayName="StepEdgeInternal";function Oi(e){return C.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:o,labelStyle:a,labelShowBg:u,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:c,style:f,markerEnd:p,markerStart:g,interactionWidth:v})=>{const[w,y,b]=si({sourceX:n,sourceY:r,targetX:s,targetY:i}),m=e.isInternal?void 0:t;return h.jsx(Bt,{id:m,path:w,labelX:y,labelY:b,label:o,labelStyle:a,labelShowBg:u,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:c,style:f,markerEnd:p,markerStart:g,interactionWidth:v})})}const Yp=Oi({isInternal:!1}),Fi=Oi({isInternal:!0});Yp.displayName="StraightEdge";Fi.displayName="StraightEdgeInternal";function Yi(e){return C.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:o=U.Bottom,targetPosition:a=U.Top,label:u,labelStyle:l,labelShowBg:d,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:w,pathOptions:y,interactionWidth:b})=>{const[m,x,N]=br({sourceX:n,sourceY:r,sourcePosition:o,targetX:s,targetY:i,targetPosition:a,curvature:y==null?void 0:y.curvature}),E=e.isInternal?void 0:t;return h.jsx(Bt,{id:E,path:m,labelX:x,labelY:N,label:u,labelStyle:l,labelShowBg:d,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:w,interactionWidth:b})})}const Xp=Yi({isInternal:!1}),Xi=Yi({isInternal:!0});Xp.displayName="BezierEdge";Xi.displayName="BezierEdgeInternal";const Hs={default:Xi,straight:Fi,step:Bi,smoothstep:Hi,simplebezier:Di},Vs={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},qp=(e,t,n)=>n===U.Left?e-t:n===U.Right?e+t:e,Wp=(e,t,n)=>n===U.Top?e-t:n===U.Bottom?e+t:e,Bs="react-flow__edgeupdater";function Os({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:o,type:a}){return h.jsx("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:o,className:ue([Bs,`${Bs}-${a}`]),cx:qp(t,r,e),cy:Wp(n,r,e),r,stroke:"transparent",fill:"transparent"})}function Up({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:o,sourcePosition:a,targetPosition:u,onReconnect:l,onReconnectStart:d,onReconnectEnd:c,setReconnecting:f,setUpdateHover:p}){const g=ie(),v=(x,N)=>{if(x.button!==0)return;const{autoPanOnConnect:E,domNode:j,connectionMode:I,connectionRadius:P,lib:O,onConnectStart:k,cancelConnection:T,nodeLookup:H,rfId:_,panBy:A,updateConnection:S}=g.getState(),$=N.type==="target",z=(V,L)=>{f(!1),c==null||c(V,n,N.type,L)},M=V=>l==null?void 0:l(n,V),R=(V,L)=>{f(!0),d==null||d(x,n,N.type),k==null||k(V,L)};nr.onPointerDown(x.nativeEvent,{autoPanOnConnect:E,connectionMode:I,connectionRadius:P,domNode:j,handleId:N.id,nodeId:N.nodeId,nodeLookup:H,isTarget:$,edgeUpdaterType:N.type,lib:O,flowId:_,cancelConnection:T,panBy:A,isValidConnection:(...V)=>{var L,X;return((X=(L=g.getState()).isValidConnection)==null?void 0:X.call(L,...V))??!0},onConnect:M,onConnectStart:R,onConnectEnd:(...V)=>{var L,X;return(X=(L=g.getState()).onConnectEnd)==null?void 0:X.call(L,...V)},onReconnectEnd:z,updateConnection:S,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:x.currentTarget})},w=x=>v(x,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=x=>v(x,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>p(!0),m=()=>p(!1);return h.jsxs(h.Fragment,{children:[(e===!0||e==="source")&&h.jsx(Os,{position:a,centerX:r,centerY:s,radius:t,onMouseDown:w,onMouseEnter:b,onMouseOut:m,type:"source"}),(e===!0||e==="target")&&h.jsx(Os,{position:u,centerX:i,centerY:o,radius:t,onMouseDown:y,onMouseEnter:b,onMouseOut:m,type:"target"})]})}function Kp({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:o,onMouseEnter:a,onMouseMove:u,onMouseLeave:l,reconnectRadius:d,onReconnect:c,onReconnectStart:f,onReconnectEnd:p,rfId:g,edgeTypes:v,noPanClassName:w,onError:y,disableKeyboardA11y:b}){let m=te(K=>K.edgeLookup.get(e));const x=te(K=>K.defaultEdgeOptions);m=x?{...x,...m}:m;let N=m.type||"default",E=(v==null?void 0:v[N])||Hs[N];E===void 0&&(y==null||y("011",Ne.error011(N)),N="default",E=(v==null?void 0:v.default)||Hs.default);const j=!!(m.focusable||t&&typeof m.focusable>"u"),I=typeof c<"u"&&(m.reconnectable||n&&typeof m.reconnectable>"u"),P=!!(m.selectable||r&&typeof m.selectable>"u"),O=C.useRef(null),[k,T]=C.useState(!1),[H,_]=C.useState(!1),A=ie(),{zIndex:S=m.zIndex,sourceX:$,sourceY:z,targetX:M,targetY:R,sourcePosition:V,targetPosition:L}=te(C.useCallback(K=>{const W=K.nodeLookup.get(m.source),ee=K.nodeLookup.get(m.target);if(!W||!ee)return Vs;const ne=Df({id:e,sourceNode:W,targetNode:ee,sourceHandle:m.sourceHandle||null,targetHandle:m.targetHandle||null,connectionMode:K.connectionMode,onError:y}),re=jf({selected:m.selected,zIndex:m.zIndex,sourceNode:W,targetNode:ee,elevateOnSelect:K.elevateEdgesOnSelect,zIndexMode:K.zIndexMode});return{...ne||Vs,zIndex:re}},[m.source,m.target,m.sourceHandle,m.targetHandle,m.selected,m.zIndex]),oe),X=C.useMemo(()=>m.markerStart?`url('#${er(m.markerStart,g)}')`:void 0,[m.markerStart,g]),q=C.useMemo(()=>m.markerEnd?`url('#${er(m.markerEnd,g)}')`:void 0,[m.markerEnd,g]);if(m.hidden||$===null||z===null||M===null||R===null)return null;const G=K=>{var re;const{addSelectedEdges:W,unselectNodesAndEdges:ee,multiSelectionActive:ne}=A.getState();P&&(A.setState({nodesSelectionActive:!1}),m.selected&&ne?(ee({nodes:[],edges:[m]}),(re=O.current)==null||re.blur()):W([e])),s&&s(K,m)},B=i?K=>{i(K,{...m})}:void 0,Y=o?K=>{o(K,{...m})}:void 0,D=a?K=>{a(K,{...m})}:void 0,F=u?K=>{u(K,{...m})}:void 0,Q=l?K=>{l(K,{...m})}:void 0,Z=K=>{var W;if(!b&&Bo.includes(K.key)&&P){const{unselectNodesAndEdges:ee,addSelectedEdges:ne}=A.getState();K.key==="Escape"?((W=O.current)==null||W.blur(),ee({edges:[m]})):ne([e])}};return h.jsx("svg",{style:{zIndex:S},children:h.jsxs("g",{className:ue(["react-flow__edge",`react-flow__edge-${N}`,m.className,w,{selected:m.selected,animated:m.animated,inactive:!P&&!s,updating:k,selectable:P}]),onClick:G,onDoubleClick:B,onContextMenu:Y,onMouseEnter:D,onMouseMove:F,onMouseLeave:Q,onKeyDown:j?Z:void 0,tabIndex:j?0:void 0,role:m.ariaRole??(j?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":m.ariaLabel===null?void 0:m.ariaLabel||`Edge from ${m.source} to ${m.target}`,"aria-describedby":j?`${wi}-${g}`:void 0,ref:O,...m.domAttributes,children:[!H&&h.jsx(E,{id:e,source:m.source,target:m.target,type:m.type,selected:m.selected,animated:m.animated,selectable:P,deletable:m.deletable??!0,label:m.label,labelStyle:m.labelStyle,labelShowBg:m.labelShowBg,labelBgStyle:m.labelBgStyle,labelBgPadding:m.labelBgPadding,labelBgBorderRadius:m.labelBgBorderRadius,sourceX:$,sourceY:z,targetX:M,targetY:R,sourcePosition:V,targetPosition:L,data:m.data,style:m.style,sourceHandleId:m.sourceHandle,targetHandleId:m.targetHandle,markerStart:X,markerEnd:q,pathOptions:"pathOptions"in m?m.pathOptions:void 0,interactionWidth:m.interactionWidth}),I&&h.jsx(Up,{edge:m,isReconnectable:I,reconnectRadius:d,onReconnect:c,onReconnectStart:f,onReconnectEnd:p,sourceX:$,sourceY:z,targetX:M,targetY:R,sourcePosition:V,targetPosition:L,setUpdateHover:T,setReconnecting:_})]})})}var Gp=C.memo(Kp);const Zp=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function qi({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:o,onEdgeMouseEnter:a,onEdgeMouseMove:u,onEdgeMouseLeave:l,onEdgeClick:d,reconnectRadius:c,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:g,disableKeyboardA11y:v}){const{edgesFocusable:w,edgesReconnectable:y,elementsSelectable:b,onError:m}=te(Zp,oe),x=zp(t);return h.jsxs("div",{className:"react-flow__edges",children:[h.jsx(Vp,{defaultColor:e,rfId:n}),x.map(N=>h.jsx(Gp,{id:N,edgesFocusable:w,edgesReconnectable:y,elementsSelectable:b,noPanClassName:s,onReconnect:i,onContextMenu:o,onMouseEnter:a,onMouseMove:u,onMouseLeave:l,onClick:d,reconnectRadius:c,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:g,rfId:n,onError:m,edgeTypes:r,disableKeyboardA11y:v},N))]})}qi.displayName="EdgeRenderer";const Qp=C.memo(qi),Jp=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function eg({children:e}){const t=te(Jp);return h.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function tg(e){const t=Vt(),n=C.useRef(!1);C.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const ng=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function rg(e){const t=te(ng),n=ie();return C.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function sg(e){return e.connection.inProgress?{...e.connection,to:Ht(e.connection.to,e.transform)}:{...e.connection}}function og(e){return sg}function ig(e){const t=og();return te(t,oe)}const ag=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function cg({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:o,isValid:a,inProgress:u}=te(ag,oe);return!(i&&s&&u)?null:h.jsx("svg",{style:e,width:i,height:o,className:"react-flow__connectionline react-flow__container",children:h.jsx("g",{className:ue(["react-flow__connection",Yo(a)]),children:h.jsx(Wi,{style:t,type:n,CustomComponent:r,isValid:a})})})}const Wi=({style:e,type:t=Ve.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:o,fromHandle:a,fromPosition:u,to:l,toNode:d,toHandle:c,toPosition:f,pointer:p}=ig();if(!s)return;if(n)return h.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:a,fromX:i.x,fromY:i.y,toX:l.x,toY:l.y,fromPosition:u,toPosition:f,connectionStatus:Yo(r),toNode:d,toHandle:c,pointer:p});let g="";const v={sourceX:i.x,sourceY:i.y,sourcePosition:u,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case Ve.Bezier:[g]=br(v);break;case Ve.SimpleBezier:[g]=Pi(v);break;case Ve.Step:[g]=Jn({...v,borderRadius:0});break;case Ve.SmoothStep:[g]=Jn(v);break;default:[g]=si(v)}return h.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};Wi.displayName="ConnectionLine";const lg={};function Fs(e=lg){C.useRef(e),ie(),C.useEffect(()=>{},[e])}function ug(){ie(),C.useRef(!1),C.useEffect(()=>{},[])}function Ui({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:o,onNodeMouseEnter:a,onNodeMouseMove:u,onNodeMouseLeave:l,onNodeContextMenu:d,onSelectionContextMenu:c,onSelectionStart:f,onSelectionEnd:p,connectionLineType:g,connectionLineStyle:v,connectionLineComponent:w,connectionLineContainerStyle:y,selectionKeyCode:b,selectionOnDrag:m,selectionMode:x,multiSelectionKeyCode:N,panActivationKeyCode:E,zoomActivationKeyCode:j,deleteKeyCode:I,onlyRenderVisibleElements:P,elementsSelectable:O,defaultViewport:k,translateExtent:T,minZoom:H,maxZoom:_,preventScrolling:A,defaultMarkerColor:S,zoomOnScroll:$,zoomOnPinch:z,panOnScroll:M,panOnScrollSpeed:R,panOnScrollMode:V,zoomOnDoubleClick:L,panOnDrag:X,autoPanOnSelection:q,onPaneClick:G,onPaneMouseEnter:B,onPaneMouseMove:Y,onPaneMouseLeave:D,onPaneScroll:F,onPaneContextMenu:Q,paneClickDistance:Z,nodeClickDistance:K,onEdgeContextMenu:W,onEdgeMouseEnter:ee,onEdgeMouseMove:ne,onEdgeMouseLeave:re,reconnectRadius:le,onReconnect:xe,onReconnectStart:Se,onReconnectEnd:Ce,noDragClassName:Ae,noWheelClassName:pt,noPanClassName:Oe,disableKeyboardA11y:Fe,nodeExtent:ye,rfId:$e,viewport:Ie,onViewportChange:Ye}){return Fs(e),Fs(t),ug(),tg(n),rg(Ie),h.jsx(Sp,{onPaneClick:G,onPaneMouseEnter:B,onPaneMouseMove:Y,onPaneMouseLeave:D,onPaneContextMenu:Q,onPaneScroll:F,paneClickDistance:Z,deleteKeyCode:I,selectionKeyCode:b,selectionOnDrag:m,selectionMode:x,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:N,panActivationKeyCode:E,zoomActivationKeyCode:j,elementsSelectable:O,zoomOnScroll:$,zoomOnPinch:z,zoomOnDoubleClick:L,panOnScroll:M,panOnScrollSpeed:R,panOnScrollMode:V,panOnDrag:X,autoPanOnSelection:q,defaultViewport:k,translateExtent:T,minZoom:H,maxZoom:_,onSelectionContextMenu:c,preventScrolling:A,noDragClassName:Ae,noWheelClassName:pt,noPanClassName:Oe,disableKeyboardA11y:Fe,onViewportChange:Ye,isControlledViewport:!!Ie,children:h.jsxs(eg,{children:[h.jsx(Qp,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:o,onReconnect:xe,onReconnectStart:Se,onReconnectEnd:Ce,onlyRenderVisibleElements:P,onEdgeContextMenu:W,onEdgeMouseEnter:ee,onEdgeMouseMove:ne,onEdgeMouseLeave:re,reconnectRadius:le,defaultMarkerColor:S,noPanClassName:Oe,disableKeyboardA11y:Fe,rfId:$e}),h.jsx(cg,{style:v,type:g,component:w,containerStyle:y}),h.jsx("div",{className:"react-flow__edgelabel-renderer"}),h.jsx(Pp,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:u,onNodeMouseLeave:l,onNodeContextMenu:d,nodeClickDistance:K,onlyRenderVisibleElements:P,noPanClassName:Oe,noDragClassName:Ae,disableKeyboardA11y:Fe,nodeExtent:ye,rfId:$e}),h.jsx("div",{className:"react-flow__viewport-portal"})]})})}Ui.displayName="GraphView";const dg=C.memo(Ui),fg=Go(),Ys=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:o,fitViewOptions:a,minZoom:u=.5,maxZoom:l=2,nodeOrigin:d,nodeExtent:c,zIndexMode:f="basic"}={})=>{const p=new Map,g=new Map,v=new Map,w=new Map,y=r??t??[],b=n??e??[],m=d??[0,0],x=c??Ct;ai(v,w,y);const{nodesInitialized:N}=tr(b,p,g,{nodeOrigin:m,nodeExtent:x,zIndexMode:f});let E=[0,0,1];if(o&&s&&i){const j=Lt(p,{filter:k=>!!((k.width||k.initialWidth)&&(k.height||k.initialHeight))}),{x:I,y:P,zoom:O}=wr(j,s,i,u,l,(a==null?void 0:a.padding)??.1);E=[I,P,O]}return{rfId:"1",width:s??0,height:i??0,transform:E,nodes:b,nodesInitialized:N,nodeLookup:p,parentLookup:g,edges:y,edgeLookup:w,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:u,maxZoom:l,translateExtent:Ct,nodeExtent:x,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ut.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:m,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:a,fitViewResolver:null,connection:{...Fo},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:fg,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Oo,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},hg=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:o,fitViewOptions:a,minZoom:u,maxZoom:l,nodeOrigin:d,nodeExtent:c,zIndexMode:f})=>Sh((p,g)=>{async function v(){const{nodeLookup:w,panZoom:y,fitViewOptions:b,fitViewResolver:m,width:x,height:N,minZoom:E,maxZoom:j}=g();y&&(await bf({nodes:w,width:x,height:N,panZoom:y,minZoom:E,maxZoom:j},b),m==null||m.resolve(!0),p({fitViewResolver:null}))}return{...Ys({nodes:e,edges:t,width:s,height:i,fitView:o,fitViewOptions:a,minZoom:u,maxZoom:l,nodeOrigin:d,nodeExtent:c,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:w=>{const{nodeLookup:y,parentLookup:b,nodeOrigin:m,elevateNodesOnSelect:x,fitViewQueued:N,zIndexMode:E,nodesSelectionActive:j}=g(),{nodesInitialized:I,hasSelectedNodes:P}=tr(w,y,b,{nodeOrigin:m,nodeExtent:c,elevateNodesOnSelect:x,checkEquality:!0,zIndexMode:E}),O=j&&P;N&&I?(v(),p({nodes:w,nodesInitialized:I,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:O})):p({nodes:w,nodesInitialized:I,nodesSelectionActive:O})},setEdges:w=>{const{connectionLookup:y,edgeLookup:b}=g();ai(y,b,w),p({edges:w})},setDefaultNodesAndEdges:(w,y)=>{if(w){const{setNodes:b}=g();b(w),p({hasDefaultNodes:!0})}if(y){const{setEdges:b}=g();b(y),p({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:y,nodeLookup:b,parentLookup:m,domNode:x,nodeOrigin:N,nodeExtent:E,debug:j,fitViewQueued:I,zIndexMode:P}=g(),{changes:O,updatedInternals:k}=Yf(w,b,m,x,N,E,P);k&&(Vf(b,m,{nodeOrigin:N,nodeExtent:E,zIndexMode:P}),I?(v(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),(O==null?void 0:O.length)>0&&(j&&console.log("React Flow: trigger node changes",O),y==null||y(O)))},updateNodePositions:(w,y=!1)=>{const b=[];let m=[];const{nodeLookup:x,triggerNodeChanges:N,connection:E,updateConnection:j,onNodesChangeMiddlewareMap:I}=g();for(const[P,O]of w){const k=x.get(P),T=!!(k!=null&&k.expandParent&&(k!=null&&k.parentId)&&(O!=null&&O.position)),H={id:P,type:"position",position:T?{x:Math.max(0,O.position.x),y:Math.max(0,O.position.y)}:O.position,dragging:y};if(k&&E.inProgress&&E.fromNode.id===k.id){const _=tt(k,E.fromHandle,U.Left,!0);j({...E,from:_})}T&&k.parentId&&b.push({id:P,parentId:k.parentId,rect:{...O.internals.positionAbsolute,width:O.measured.width??0,height:O.measured.height??0}}),m.push(H)}if(b.length>0){const{parentLookup:P,nodeOrigin:O}=g(),k=Cr(b,x,P,O);m.push(...k)}for(const P of I.values())m=P(m);N(m)},triggerNodeChanges:w=>{const{onNodesChange:y,setNodes:b,nodes:m,hasDefaultNodes:x,debug:N}=g();if(w!=null&&w.length){if(x){const E=_i(w,m);b(E)}N&&console.log("React Flow: trigger node changes",w),y==null||y(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:y,setEdges:b,edges:m,hasDefaultEdges:x,debug:N}=g();if(w!=null&&w.length){if(x){const E=Ni(w,m);b(E)}N&&console.log("React Flow: trigger edge changes",w),y==null||y(w)}},addSelectedNodes:w=>{const{multiSelectionActive:y,edgeLookup:b,nodeLookup:m,triggerNodeChanges:x,triggerEdgeChanges:N}=g();if(y){const E=w.map(j=>Xe(j,!0));x(E);return}x(st(m,new Set([...w]),!0)),N(st(b))},addSelectedEdges:w=>{const{multiSelectionActive:y,edgeLookup:b,nodeLookup:m,triggerNodeChanges:x,triggerEdgeChanges:N}=g();if(y){const E=w.map(j=>Xe(j,!0));N(E);return}N(st(b,new Set([...w]))),x(st(m,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:y}={})=>{const{edges:b,nodes:m,nodeLookup:x,triggerNodeChanges:N,triggerEdgeChanges:E}=g(),j=w||m,I=y||b,P=[];for(const k of j){if(!k.selected)continue;const T=x.get(k.id);T&&(T.selected=!1),P.push(Xe(k.id,!1))}const O=[];for(const k of I)k.selected&&O.push(Xe(k.id,!1));N(P),E(O)},setMinZoom:w=>{const{panZoom:y,maxZoom:b}=g();y==null||y.setScaleExtent([w,b]),p({minZoom:w})},setMaxZoom:w=>{const{panZoom:y,minZoom:b}=g();y==null||y.setScaleExtent([b,w]),p({maxZoom:w})},setTranslateExtent:w=>{var y;(y=g().panZoom)==null||y.setTranslateExtent(w),p({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:y,triggerNodeChanges:b,triggerEdgeChanges:m,elementsSelectable:x}=g();if(!x)return;const N=y.reduce((j,I)=>I.selected?[...j,Xe(I.id,!1)]:j,[]),E=w.reduce((j,I)=>I.selected?[...j,Xe(I.id,!1)]:j,[]);b(N),m(E)},setNodeExtent:w=>{const{nodes:y,nodeLookup:b,parentLookup:m,nodeOrigin:x,elevateNodesOnSelect:N,nodeExtent:E,zIndexMode:j}=g();w[0][0]===E[0][0]&&w[0][1]===E[0][1]&&w[1][0]===E[1][0]&&w[1][1]===E[1][1]||(tr(y,b,m,{nodeOrigin:x,nodeExtent:w,elevateNodesOnSelect:N,checkEquality:!1,zIndexMode:j}),p({nodeExtent:w}))},panBy:w=>{const{transform:y,width:b,height:m,panZoom:x,translateExtent:N}=g();return Xf({delta:w,panZoom:x,transform:y,translateExtent:N,width:b,height:m})},setCenter:async(w,y,b)=>{const{width:m,height:x,maxZoom:N,panZoom:E}=g();if(!E)return!1;const j=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:N;return await E.setViewport({x:m/2-w*j,y:x/2-y*j,zoom:j},{duration:b==null?void 0:b.duration,ease:b==null?void 0:b.ease,interpolate:b==null?void 0:b.interpolate}),!0},cancelConnection:()=>{p({connection:{...Fo}})},updateConnection:w=>{p({connection:w})},reset:()=>p({...Ys()})}},Object.is);function Ki({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,initialMinZoom:o,initialMaxZoom:a,initialFitViewOptions:u,fitView:l,nodeOrigin:d,nodeExtent:c,zIndexMode:f,children:p}){const[g]=C.useState(()=>hg({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:l,minZoom:o,maxZoom:a,fitViewOptions:u,nodeOrigin:d,nodeExtent:c,zIndexMode:f}));return h.jsx(Ch,{value:g,children:h.jsx(Zh,{children:h.jsx(fp,{children:p})})})}function pg({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:o,fitView:a,fitViewOptions:u,minZoom:l,maxZoom:d,nodeOrigin:c,nodeExtent:f,zIndexMode:p}){return C.useContext(Nn)?h.jsx(h.Fragment,{children:e}):h.jsx(Ki,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:o,fitView:a,initialFitViewOptions:u,initialMinZoom:l,initialMaxZoom:d,nodeOrigin:c,nodeExtent:f,zIndexMode:p,children:e})}const gg={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function mg({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:o,onNodeClick:a,onEdgeClick:u,onInit:l,onMove:d,onMoveStart:c,onMoveEnd:f,onConnect:p,onConnectStart:g,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:y,onNodeMouseEnter:b,onNodeMouseMove:m,onNodeMouseLeave:x,onNodeContextMenu:N,onNodeDoubleClick:E,onNodeDragStart:j,onNodeDrag:I,onNodeDragStop:P,onNodesDelete:O,onEdgesDelete:k,onDelete:T,onSelectionChange:H,onSelectionDragStart:_,onSelectionDrag:A,onSelectionDragStop:S,onSelectionContextMenu:$,onSelectionStart:z,onSelectionEnd:M,onBeforeDelete:R,connectionMode:V,connectionLineType:L=Ve.Bezier,connectionLineStyle:X,connectionLineComponent:q,connectionLineContainerStyle:G,deleteKeyCode:B="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:D=!1,selectionMode:F=kt.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:Z=Mt()?"Meta":"Control",zoomActivationKeyCode:K=Mt()?"Meta":"Control",snapToGrid:W,snapGrid:ee,onlyRenderVisibleElements:ne=!1,selectNodesOnDrag:re,nodesDraggable:le,autoPanOnNodeFocus:xe,nodesConnectable:Se,nodesFocusable:Ce,nodeOrigin:Ae=vi,edgesFocusable:pt,edgesReconnectable:Oe,elementsSelectable:Fe=!0,defaultViewport:ye=Hh,minZoom:$e=.5,maxZoom:Ie=2,translateExtent:Ye=Ct,preventScrolling:oa=!0,nodeExtent:Cn,defaultMarkerColor:ia="#b1b1b7",zoomOnScroll:aa=!0,zoomOnPinch:ca=!0,panOnScroll:la=!1,panOnScrollSpeed:ua=.5,panOnScrollMode:da=Ge.Free,zoomOnDoubleClick:fa=!0,panOnDrag:ha=!0,onPaneClick:pa,onPaneMouseEnter:ga,onPaneMouseMove:ma,onPaneMouseLeave:xa,onPaneScroll:ya,onPaneContextMenu:wa,paneClickDistance:va=1,nodeClickDistance:ba=0,children:_a,onReconnect:Na,onReconnectStart:Ea,onReconnectEnd:Sa,onEdgeContextMenu:Ca,onEdgeDoubleClick:ka,onEdgeMouseEnter:ja,onEdgeMouseMove:Ma,onEdgeMouseLeave:Aa,reconnectRadius:$a=10,onNodesChange:Ia,onEdgesChange:Ta,noDragClassName:Pa="nodrag",noWheelClassName:za="nowheel",noPanClassName:Mr="nopan",fitView:Ar,fitViewOptions:$r,connectOnClick:Da,attributionPosition:La,proOptions:Ra,defaultEdgeOptions:Ha,elevateNodesOnSelect:Va=!0,elevateEdgesOnSelect:Ba=!1,disableKeyboardA11y:Ir=!1,autoPanOnConnect:Oa,autoPanOnNodeDrag:Fa,autoPanOnSelection:Ya=!0,autoPanSpeed:Xa,connectionRadius:qa,isValidConnection:Wa,onError:Ua,style:Ka,id:Tr,nodeDragThreshold:Ga,connectionDragThreshold:Za,viewport:Qa,onViewportChange:Ja,width:ec,height:tc,colorMode:nc="light",debug:rc,onScroll:Ot,ariaLabelConfig:sc,zIndexMode:Pr="basic",...oc},ic){const kn=Tr||"1",ac=Fh(nc),cc=C.useCallback(zr=>{zr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Ot==null||Ot(zr)},[Ot]);return h.jsx("div",{"data-testid":"rf__wrapper",...oc,onScroll:cc,style:{...Ka,...gg},ref:ic,className:ue(["react-flow",s,ac]),id:Tr,role:"application",children:h.jsxs(pg,{nodes:e,edges:t,width:ec,height:tc,fitView:Ar,fitViewOptions:$r,minZoom:$e,maxZoom:Ie,nodeOrigin:Ae,nodeExtent:Cn,zIndexMode:Pr,children:[h.jsx(Oh,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:g,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:y,nodesDraggable:le,autoPanOnNodeFocus:xe,nodesConnectable:Se,nodesFocusable:Ce,edgesFocusable:pt,edgesReconnectable:Oe,elementsSelectable:Fe,elevateNodesOnSelect:Va,elevateEdgesOnSelect:Ba,minZoom:$e,maxZoom:Ie,nodeExtent:Cn,onNodesChange:Ia,onEdgesChange:Ta,snapToGrid:W,snapGrid:ee,connectionMode:V,translateExtent:Ye,connectOnClick:Da,defaultEdgeOptions:Ha,fitView:Ar,fitViewOptions:$r,onNodesDelete:O,onEdgesDelete:k,onDelete:T,onNodeDragStart:j,onNodeDrag:I,onNodeDragStop:P,onSelectionDrag:A,onSelectionDragStart:_,onSelectionDragStop:S,onMove:d,onMoveStart:c,onMoveEnd:f,noPanClassName:Mr,nodeOrigin:Ae,rfId:kn,autoPanOnConnect:Oa,autoPanOnNodeDrag:Fa,autoPanSpeed:Xa,onError:Ua,connectionRadius:qa,isValidConnection:Wa,selectNodesOnDrag:re,nodeDragThreshold:Ga,connectionDragThreshold:Za,onBeforeDelete:R,debug:rc,ariaLabelConfig:sc,zIndexMode:Pr}),h.jsx(dg,{onInit:l,onNodeClick:a,onEdgeClick:u,onNodeMouseEnter:b,onNodeMouseMove:m,onNodeMouseLeave:x,onNodeContextMenu:N,onNodeDoubleClick:E,nodeTypes:i,edgeTypes:o,connectionLineType:L,connectionLineStyle:X,connectionLineComponent:q,connectionLineContainerStyle:G,selectionKeyCode:Y,selectionOnDrag:D,selectionMode:F,deleteKeyCode:B,multiSelectionKeyCode:Z,panActivationKeyCode:Q,zoomActivationKeyCode:K,onlyRenderVisibleElements:ne,defaultViewport:ye,translateExtent:Ye,minZoom:$e,maxZoom:Ie,preventScrolling:oa,zoomOnScroll:aa,zoomOnPinch:ca,zoomOnDoubleClick:fa,panOnScroll:la,panOnScrollSpeed:ua,panOnScrollMode:da,panOnDrag:ha,autoPanOnSelection:Ya,onPaneClick:pa,onPaneMouseEnter:ga,onPaneMouseMove:ma,onPaneMouseLeave:xa,onPaneScroll:ya,onPaneContextMenu:wa,paneClickDistance:va,nodeClickDistance:ba,onSelectionContextMenu:$,onSelectionStart:z,onSelectionEnd:M,onReconnect:Na,onReconnectStart:Ea,onReconnectEnd:Sa,onEdgeContextMenu:Ca,onEdgeDoubleClick:ka,onEdgeMouseEnter:ja,onEdgeMouseMove:Ma,onEdgeMouseLeave:Aa,reconnectRadius:$a,defaultMarkerColor:ia,noDragClassName:Pa,noWheelClassName:za,noPanClassName:Mr,rfId:kn,disableKeyboardA11y:Ir,nodeExtent:Cn,viewport:Qa,onViewportChange:Ja}),h.jsx(Rh,{onSelectionChange:H}),_a,h.jsx(Th,{proOptions:Ra,position:La}),h.jsx(Ih,{rfId:kn,disableKeyboardA11y:Ir})]})})}var xg=Ei(mg);function yg({dimensions:e,lineWidth:t,variant:n,className:r}){return h.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:ue(["react-flow__background-pattern",n,r])})}function wg({radius:e,className:t}){return h.jsx("circle",{cx:e,cy:e,r:e,className:ue(["react-flow__background-pattern","dots",t])})}var Be;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Be||(Be={}));const vg={[Be.Dots]:1,[Be.Lines]:1,[Be.Cross]:6},bg=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Gi({id:e,variant:t=Be.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=0,color:o,bgColor:a,style:u,className:l,patternClassName:d}){const c=C.useRef(null),{transform:f,patternId:p}=te(bg,oe),g=r||vg[t],v=t===Be.Dots,w=t===Be.Cross,y=Array.isArray(n)?n:[n,n],b=[y[0]*f[2]||1,y[1]*f[2]||1],m=g*f[2],x=Array.isArray(i)?i:[i,i],N=w?[m,m]:b,E=[x[0]*f[2]||1+N[0]/2,x[1]*f[2]||1+N[1]/2],j=`${p}${e||""}`;return h.jsxs("svg",{className:ue(["react-flow__background",l]),style:{...u,...Sn,"--xy-background-color-props":a,"--xy-background-pattern-color-props":o},ref:c,"data-testid":"rf__background",children:[h.jsx("pattern",{id:j,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`,children:v?h.jsx(wg,{radius:m/2,className:d}):h.jsx(yg,{dimensions:N,lineWidth:s,variant:t,className:d})}),h.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${j})`})]})}Gi.displayName="Background";const _g=C.memo(Gi);function Ng(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:h.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Eg(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:h.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Sg(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:h.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function Cg(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:h.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function kg(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:h.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Zt({children:e,className:t,...n}){return h.jsx("button",{type:"button",className:ue(["react-flow__controls-button",t]),...n,children:e})}const jg=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Zi({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:o,onFitView:a,onInteractiveChange:u,className:l,children:d,position:c="bottom-left",orientation:f="vertical","aria-label":p}){const g=ie(),{isInteractive:v,minZoomReached:w,maxZoomReached:y,ariaLabelConfig:b}=te(jg,oe),{zoomIn:m,zoomOut:x,fitView:N}=Vt(),E=()=>{m(),i==null||i()},j=()=>{x(),o==null||o()},I=()=>{N(s),a==null||a()},P=()=>{g.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),u==null||u(!v)},O=f==="horizontal"?"horizontal":"vertical";return h.jsxs(En,{className:ue(["react-flow__controls",O,l]),position:c,style:e,"data-testid":"rf__controls","aria-label":p??b["controls.ariaLabel"],children:[t&&h.jsxs(h.Fragment,{children:[h.jsx(Zt,{onClick:E,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:y,children:h.jsx(Ng,{})}),h.jsx(Zt,{onClick:j,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:w,children:h.jsx(Eg,{})})]}),n&&h.jsx(Zt,{className:"react-flow__controls-fitview",onClick:I,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:h.jsx(Sg,{})}),r&&h.jsx(Zt,{className:"react-flow__controls-interactive",onClick:P,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:v?h.jsx(kg,{}):h.jsx(Cg,{})}),d]})}Zi.displayName="Controls";const Mg=C.memo(Zi);function Ag({id:e,x:t,y:n,width:r,height:s,style:i,color:o,strokeColor:a,strokeWidth:u,className:l,borderRadius:d,shapeRendering:c,selected:f,onClick:p}){const{background:g,backgroundColor:v}=i||{},w=o||g||v;return h.jsx("rect",{className:ue(["react-flow__minimap-node",{selected:f},l]),x:t,y:n,rx:d,ry:d,width:r,height:s,style:{fill:w,stroke:a,strokeWidth:u},shapeRendering:c,onClick:p?y=>p(y,e):void 0})}const $g=C.memo(Ag),Ig=e=>e.nodes.map(t=>t.id),Vn=e=>e instanceof Function?e:()=>e;function Tg({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=$g,onClick:o}){const a=te(Ig,oe),u=Vn(t),l=Vn(e),d=Vn(n),c=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return h.jsx(h.Fragment,{children:a.map(f=>h.jsx(zg,{id:f,nodeColorFunc:u,nodeStrokeColorFunc:l,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:o,shapeRendering:c},f))})}function Pg({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:o,NodeComponent:a,onClick:u}){const{node:l,x:d,y:c,width:f,height:p}=te(g=>{const v=g.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const w=v.internals.userNode,{x:y,y:b}=v.internals.positionAbsolute,{width:m,height:x}=De(w);return{node:w,x:y,y:b,width:m,height:x}},oe);return!l||l.hidden||!Zo(l)?null:h.jsx(a,{x:d,y:c,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:s,strokeColor:n(l),strokeWidth:i,shapeRendering:o,onClick:u,id:l.id})}const zg=C.memo(Pg);var Dg=C.memo(Tg);const Lg=200,Rg=150,Hg=e=>!e.hidden,Vg=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?Uo(Lt(e.nodeLookup,{filter:Hg}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Bg="react-flow__minimap-desc";function Qi({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:o,nodeComponent:a,bgColor:u,maskColor:l,maskStrokeColor:d,maskStrokeWidth:c,position:f="bottom-right",onClick:p,onNodeClick:g,pannable:v=!1,zoomable:w=!1,ariaLabel:y,inversePan:b,zoomStep:m=1,offsetScale:x=5}){const N=ie(),E=C.useRef(null),{boundingRect:j,viewBB:I,rfId:P,panZoom:O,translateExtent:k,flowWidth:T,flowHeight:H,ariaLabelConfig:_}=te(Vg,oe),A=(e==null?void 0:e.width)??Lg,S=(e==null?void 0:e.height)??Rg,$=j.width/A,z=j.height/S,M=Math.max($,z),R=M*A,V=M*S,L=x*M,X=j.x-(R-j.width)/2-L,q=j.y-(V-j.height)/2-L,G=R+L*2,B=V+L*2,Y=`${Bg}-${P}`,D=C.useRef(0),F=C.useRef();D.current=M,C.useEffect(()=>{if(E.current&&O)return F.current=eh({domNode:E.current,panZoom:O,getTransform:()=>N.getState().transform,getViewScale:()=>D.current}),()=>{var W;(W=F.current)==null||W.destroy()}},[O]),C.useEffect(()=>{var W;(W=F.current)==null||W.update({translateExtent:k,width:T,height:H,inversePan:b,pannable:v,zoomStep:m,zoomable:w})},[v,w,b,m,k,T,H]);const Q=p?W=>{var re;const[ee,ne]=((re=F.current)==null?void 0:re.pointer(W))||[0,0];p(W,{x:ee,y:ne})}:void 0,Z=g?C.useCallback((W,ee)=>{const ne=N.getState().nodeLookup.get(ee).internals.userNode;g(W,ne)},[]):void 0,K=y??_["minimap.ariaLabel"];return h.jsx(En,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof c=="number"?c*M:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o=="number"?o:void 0},className:ue(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:h.jsxs("svg",{width:A,height:S,viewBox:`${X} ${q} ${G} ${B}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Y,ref:E,onClick:Q,children:[K&&h.jsx("title",{id:Y,children:K}),h.jsx(Dg,{onClick:Z,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:o,nodeComponent:a}),h.jsx("path",{className:"react-flow__minimap-mask",d:`M${X-L},${q-L}h${G+L*2}v${B+L*2}h${-G-L*2}z
138
+ M${I.x},${I.y}h${I.width}v${I.height}h${-I.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Qi.displayName="MiniMap";C.memo(Qi);const Og=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Fg={[ht.Line]:"right",[ht.Handle]:"bottom-right"};function Yg({nodeId:e,position:t,variant:n=ht.Handle,className:r,style:s=void 0,children:i,color:o,minWidth:a=10,minHeight:u=10,maxWidth:l=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:c=!1,resizeDirection:f,autoScale:p=!0,shouldResize:g,onResizeStart:v,onResize:w,onResizeEnd:y}){const b=ji(),m=typeof e=="string"?e:b,x=ie(),N=C.useRef(null),E=n===ht.Handle,j=te(C.useCallback(Og(E&&p),[E,p]),oe),I=C.useRef(null),P=t??Fg[n];C.useEffect(()=>{if(!(!N.current||!m))return I.current||(I.current=hh({domNode:N.current,nodeId:m,getStoreItems:()=>{const{nodeLookup:k,transform:T,snapGrid:H,snapToGrid:_,nodeOrigin:A,domNode:S}=x.getState();return{nodeLookup:k,transform:T,snapGrid:H,snapToGrid:_,nodeOrigin:A,paneDomNode:S}},onChange:(k,T)=>{const{triggerNodeChanges:H,nodeLookup:_,parentLookup:A,nodeOrigin:S}=x.getState(),$=[],z={x:k.x,y:k.y},M=_.get(m);if(M&&M.expandParent&&M.parentId){const R=M.origin??S,V=k.width??M.measured.width??0,L=k.height??M.measured.height??0,X={id:M.id,parentId:M.parentId,rect:{width:V,height:L,...Qo({x:k.x??M.position.x,y:k.y??M.position.y},{width:V,height:L},M.parentId,_,R)}},q=Cr([X],_,A,S);$.push(...q),z.x=k.x?Math.max(R[0]*V,k.x):void 0,z.y=k.y?Math.max(R[1]*L,k.y):void 0}if(z.x!==void 0&&z.y!==void 0){const R={id:m,type:"position",position:{...z}};$.push(R)}if(k.width!==void 0&&k.height!==void 0){const V={id:m,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:k.width,height:k.height}};$.push(V)}for(const R of T){const V={...R,type:"position"};$.push(V)}H($)},onEnd:({width:k,height:T})=>{const H={id:m,type:"dimensions",resizing:!1,dimensions:{width:k,height:T}};x.getState().triggerNodeChanges([H])}})),I.current.update({controlPosition:P,boundaries:{minWidth:a,minHeight:u,maxWidth:l,maxHeight:d},keepAspectRatio:c,resizeDirection:f,onResizeStart:v,onResize:w,onResizeEnd:y,shouldResize:g}),()=>{var k;(k=I.current)==null||k.destroy()}},[P,a,u,l,d,c,v,w,y,g]);const O=P.split("-");return h.jsx("div",{className:ue(["react-flow__resize-control","nodrag",...O,n,r]),ref:N,style:{...s,scale:j,...o&&{[E?"backgroundColor":"borderColor"]:o}},children:i})}C.memo(Yg);function sr({className:e,children:t,...n}){return h.jsxs("div",{className:pe("relative h-8.5 w-full text-[13px]",e),children:[h.jsx("select",{className:pe("peer h-full w-full cursor-pointer appearance-none rounded-lg border border-border-strong","bg-surface-2 pl-2.5 pr-7 text-text-1 outline-none transition-colors duration-150","focus-visible:border-accent focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent","disabled:cursor-not-allowed disabled:opacity-45"),...n,children:t}),h.jsx(_c,{className:"pointer-events-none absolute right-2 top-1/2 h-4 w-4 -translate-y-1/2 text-text-3 peer-disabled:opacity-45",strokeWidth:1.75,"aria-hidden":"true"})]})}function Xs({checked:e,onCheckedChange:t,label:n,disabled:r}){return h.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":n,disabled:r,onClick:()=>t(!e),className:pe("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors duration-150","focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent","disabled:cursor-not-allowed disabled:opacity-45",e?"bg-accent":"bg-surface-3"),children:h.jsx("span",{className:pe("inline-block h-3.5 w-3.5 transform rounded-full bg-text-1 transition-transform duration-150",e?"translate-x-[18px]":"translate-x-[3px]")})})}const qs={model_provider:"Model Provider (OpenAI-compatible)",qdrant:"Vector DB — Qdrant",pgvector:"Vector DB — pgvector (Postgres)",mcp_server:"MCP Server"},Xg={model_provider:"model_provider",vector_db:"qdrant",mcp_server:"mcp_server"},qg=/^[a-z0-9][a-z0-9-]{1,62}$/,Ws={name:"",display_name:"",base_url:"",url:"",api_key_secret:"",dsn_secret:"",auth_secret:"",default_model:"",embedding_resource:"",embedding_model:"",embedding_dimension:"768"};function Wg(e,t){const n={kind:e,name:t.name,display_name:t.display_name};if(e==="model_provider")return{...n,base_url:t.base_url,api_key_secret:t.api_key_secret||null,default_model:t.default_model};if(e==="mcp_server")return{...n,url:t.url,auth_secret:t.auth_secret||null};const r={resource:t.embedding_resource,model:t.embedding_model,dimension:Number(t.embedding_dimension)||0};return e==="qdrant"?{...n,url:t.url,api_key_secret:t.api_key_secret||null,embedding:r}:{...n,dsn_secret:t.dsn_secret||null,embedding:r}}function Ug({open:e,group:t,onClose:n,onCreated:r}){const[s,i]=C.useState(Xg[t??"model_provider"]),[o,a]=C.useState(Ws),[u,l]=C.useState(!1),[d,c]=C.useState(null),f=Ue({queryKey:["resources","model_provider"],queryFn:()=>fe.resources.list("model_provider"),enabled:e&&(s==="qdrant"||s==="pgvector"),retry:!1}),p=x=>a(N=>({...N,...x})),g=s==="qdrant"||s==="pgvector",v=qg.test(o.name),w=!g||o.embedding_resource!==""&&o.embedding_model!==""&&Number(o.embedding_dimension)>0,y=v&&w&&!u,b=()=>{a(Ws),c(null),n()},m=async()=>{l(!0),c(null);try{const x=await fe.resources.create(Wg(s,o));He.success(`Resource ${x.name} created on the runtime`),r(x.name),b()}catch(x){x instanceof On&&x.issues.length>0?c(x.issues.map(N=>`${N.code} ${N.message}`).join(" · ")):c(x instanceof Error?x.message:"create failed")}finally{l(!1)}};return h.jsxs(or,{open:e,onClose:b,title:"New resource",className:"max-w-md",children:[h.jsx("p",{className:"text-[11px] leading-relaxed text-text-3",children:"Created on the platform runtime — credentials are stored encrypted there and never kept in the builder. Flows reference the resource by name only."}),h.jsxs("div",{className:"mt-3 flex flex-col gap-3",children:[h.jsxs("div",{children:[h.jsx(se,{children:"Type"}),h.jsx(sr,{value:s,"aria-label":"resource type",onChange:x=>i(x.target.value),children:Object.keys(qs).map(x=>h.jsx("option",{value:x,children:qs[x]},x))})]}),h.jsxs("div",{children:[h.jsx(se,{hint:"^[a-z0-9][a-z0-9-]{1,62}$",children:"Name"}),h.jsx(ae,{className:"font-mono",value:o.name,placeholder:"my-kb",onChange:x=>p({name:x.target.value})})]}),h.jsxs("div",{children:[h.jsx(se,{children:"Display name"}),h.jsx(ae,{value:o.display_name,onChange:x=>p({display_name:x.target.value})})]}),s==="model_provider"&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx(se,{hint:"empty = gateway default",children:"Base URL"}),h.jsx(ae,{className:"font-mono",value:o.base_url,placeholder:"http://127.0.0.1:11434/v1",onChange:x=>p({base_url:x.target.value})})]}),h.jsxs("div",{children:[h.jsx(se,{hint:"write-only",children:"API key"}),h.jsx(ae,{type:"password",value:o.api_key_secret,onChange:x=>p({api_key_secret:x.target.value})})]}),h.jsxs("div",{children:[h.jsx(se,{children:"Default model"}),h.jsx(ae,{className:"font-mono",value:o.default_model,placeholder:"llama3.2:latest",onChange:x=>p({default_model:x.target.value})})]})]}),s==="qdrant"&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx(se,{children:"Qdrant URL"}),h.jsx(ae,{className:"font-mono",value:o.url,placeholder:"http://127.0.0.1:6333",onChange:x=>p({url:x.target.value})})]}),h.jsxs("div",{children:[h.jsx(se,{hint:"write-only, optional",children:"API key"}),h.jsx(ae,{type:"password",value:o.api_key_secret,onChange:x=>p({api_key_secret:x.target.value})})]})]}),s==="pgvector"&&h.jsxs("div",{children:[h.jsx(se,{hint:"write-only",children:"Postgres DSN"}),h.jsx(ae,{type:"password",className:"font-mono",value:o.dsn_secret,placeholder:"postgresql://user:pass@host:5432/db",onChange:x=>p({dsn_secret:x.target.value})})]}),g&&h.jsxs("div",{className:"rounded-lg border border-border bg-canvas p-2.5",children:[h.jsx("p",{className:"mb-2 text-[11px] uppercase tracking-wide text-text-3",children:"Embedding (must match the existing collection)"}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsxs("div",{children:[h.jsx(se,{children:"Model provider"}),h.jsxs(sr,{value:o.embedding_resource,"aria-label":"embedding provider",onChange:x=>p({embedding_resource:x.target.value}),children:[h.jsx("option",{value:"",children:"— select —"}),(f.data??[]).map(x=>h.jsx("option",{value:x.name,children:x.display_name||x.name},x.name))]})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[h.jsxs("div",{children:[h.jsx(se,{children:"Model"}),h.jsx(ae,{className:"font-mono",value:o.embedding_model,placeholder:"nomic-embed-text",onChange:x=>p({embedding_model:x.target.value})})]}),h.jsxs("div",{children:[h.jsx(se,{hint:"checked on create (E022)",children:"Dimension"}),h.jsx(ae,{type:"number",value:o.embedding_dimension,onChange:x=>p({embedding_dimension:x.target.value})})]})]})]})]}),s==="mcp_server"&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx(se,{children:"Server URL"}),h.jsx(ae,{className:"font-mono",value:o.url,placeholder:"http://127.0.0.1:8300/mcp",onChange:x=>p({url:x.target.value})})]}),h.jsxs("div",{children:[h.jsx(se,{hint:"write-only, optional bearer",children:"Auth token"}),h.jsx(ae,{type:"password",value:o.auth_secret,onChange:x=>p({auth_secret:x.target.value})})]})]}),d&&h.jsx("p",{className:"text-[11px] text-danger",children:d}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(de,{size:"sm",variant:"ghost",onClick:b,children:"Cancel"}),h.jsxs(de,{size:"sm",disabled:!y,onClick:()=>void m(),children:[u?h.jsx(qe,{size:13,className:"animate-spin"}):h.jsx(so,{size:13}),"Create"]})]})]})]})}function Us(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function Kg(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Ji({value:e,onChange:t,placeholder:n}){const[r,s]=C.useState(()=>e.join(", "));return C.useEffect(()=>{s(i=>Kg(Us(i),e)?i:e.join(", "))},[e]),h.jsx(ae,{value:r,placeholder:n,onChange:i=>{s(i.target.value),t(Us(i.target.value))}})}function Ks(e,...t){const n=new RegExp(e,"g"),r=[];for(const s of t)if(typeof s=="string")for(const i of s.matchAll(n)){const o=i[1];o&&!r.includes(o)&&r.push(o)}return r}function Gg(e){if(typeof e!="object"||e===null)return[];const t=e.properties;return typeof t!="object"||t===null?[]:Object.entries(t).map(([n,r])=>{const s=typeof r=="object"&&r!==null&&r.type==="string"?"text":"json";return{name:n,type:s,label:n}})}const Zg=["text","json","message","documents"];function Gs(e){return Zg.includes(e)?e:"text"}function Qg(e){const n=(Array.isArray(e.rules)?e.rules:[]).map(s=>typeof s=="object"&&s!==null?s.branch:void 0).filter(s=>typeof s=="string"&&s!==""),r=typeof e.default_branch=="string"&&e.default_branch?e.default_branch:"otherwise";return n.includes(r)||n.push(r),n}function It(e,t,n){if(!t)return{inputs:[],outputs:[]};let r=[...t.inputs],s=[...t.outputs];if(t.dynamic_inputs==="prompt_vars")r=Ks(n.prompt_var_pattern,e.config.prompt,e.config.system_prompt).map(i=>({name:i,type:"text",label:i}));else if(t.dynamic_inputs==="arg_keys"){const i=e.config.args;r=(typeof i=="object"&&i!==null?Object.keys(i):[]).map(a=>({name:a,type:"text",label:a}))}else t.dynamic_inputs==="template_vars"?r=[{name:"trigger",type:"text",label:"Trigger"},...Ks(n.prompt_var_pattern,e.config.text).filter(i=>i!=="trigger").map(i=>({name:i,type:"text",label:i}))]:t.dynamic_inputs==="router_input"&&(r=[{name:"input",type:Gs(e.config.input_type),label:"Input"}]);if(t.dynamic_outputs==="input_schema_properties")s=Gg(e.config.input_schema);else if(t.dynamic_outputs==="structured_output_json")s=[...s],e.config.structured_output!=null&&s.push({name:"json",type:"json",label:"JSON"});else if(t.dynamic_outputs==="router_branches"){const i=Gs(e.config.input_type);s=Qg(e.config).map(o=>({name:o,type:i,label:o}))}return{inputs:r,outputs:s}}function Jg(e,t,n){return e===t?!0:n.extra_compatible_ports.some(([r,s])=>r===e&&s===t)}function em(e,t,n,r){const s=It(e.node,n.get(e.node.type),r),i=It(t.node,n.get(t.node.type),r),o=s.outputs.find(u=>u.name===e.port),a=i.inputs.find(u=>u.name===t.port);return o?a?Jg(o.type,a.type,r)?{ok:!0}:{ok:!1,reason:`${o.type} → ${a.type} is not connectable`}:{ok:!1,reason:`no input port ${t.port}`}:{ok:!1,reason:`no output port ${e.port}`}}function tm(e,t,n,r){const s=new Map(e.map(o=>[o.id,o])),i=new Set;for(const o of t){const[a,u]=Zs(o.from),[l,d]=Zs(o.to),c=s.get(a),f=s.get(l),p=c!==void 0&&It(c,n.get(c.type),r).outputs.some(v=>v.name===u),g=f!==void 0&&It(f,n.get(f.type),r).inputs.some(v=>v.name===d);(!p||!g)&&i.add(`${o.from}->${o.to}`)}return i}function Zs(e){const t=e.indexOf(".");return t===-1?[e,""]:[e.slice(0,t),e.slice(t+1)]}const nm={llm_call:"call",mcp_tool:"tool",retrieval:"retrieve",start:"start",end:"end"},rm=50,sm=800,J=dc((e,t)=>{let n="",r=0,s=!1,i=!1;const o=()=>{const l=t();return structuredClone({meta:l.meta,nodes:l.nodes,edges:l.edges})},a=l=>{if(s)return;const d=Date.now();if(l===n&&d-r<sm){r=d;return}n=l,r=d;const c=o();e(f=>({past:[...f.past.slice(-49),c],future:[]}))},u=()=>{n="",r=0,i=!1};return{loaded:!1,meta:{name:"",display_name:"",description:"",tags:[],expose:{kind:"a2a"}},nodes:[],edges:[],catalog:null,issues:[],runtimeChecked:!1,validated:!1,dirty:!1,selectedNodeId:null,past:[],future:[],infoByType:()=>{var l;return new Map((((l=t().catalog)==null?void 0:l.node_types)??[]).map(d=>[d.type,d]))},load:(l,d)=>{u();const{nodes:c,edges:f}=hc(l);e({loaded:!0,meta:pc(l),nodes:c,edges:f,catalog:d,issues:[],runtimeChecked:!1,validated:!1,dirty:!1,selectedNodeId:null,past:[],future:[]})},currentDefinition:()=>{const{meta:l,nodes:d,edges:c}=t();return fc(l,d,c)},onNodesChange:l=>{const d=l.some(f=>f.type==="remove");d&&a("delete");const c=l.find(f=>f.type==="position");c&&"dragging"in c&&(c.dragging&&!i&&(a("move"),i=!0),c.dragging||(i=!1)),e(f=>({nodes:_i(l,f.nodes),dirty:f.dirty||l.some(p=>p.type!=="select"),validated:f.validated&&!d})),d&&t().onEdgesChange([])},onEdgesChange:l=>{l.some(d=>d.type==="remove")&&a("delete"),e(d=>{const c=d.edges;let f=Ni(l,c);const p=d.catalog;if(p){const y=d.nodes.map(x=>x.data.def),b=f.map(x=>({from:`${x.source}.${x.sourceHandle??""}`,to:`${x.target}.${x.targetHandle??""}`})),m=tm(y,b,t().infoByType(),p);f=f.filter(x=>!m.has(x.id))}const g=(y,b,m)=>y.some(x=>x.target===b&&(x.targetHandle??"")==="input"&&`${x.source}.${x.sourceHandle??""}`===m);let v=d.nodes;for(const y of d.nodes){const b=y.data.def;if(b.type!=="end")continue;const m=typeof b.config.output_from=="string"?b.config.output_from:"";if(!m||!g(c,y.id,m)||g(f,y.id,m))continue;const x=f.find(E=>E.target===y.id&&(E.targetHandle??"")==="input"),N=x?`${x.source}.${x.sourceHandle??""}`:"";v=v.map(E=>E.id===y.id?{...E,data:{def:{...b,config:{...b.config,output_from:N}}}}:E)}const w=v!==d.nodes;return{edges:f,nodes:v,dirty:d.dirty||l.length>0||w,validated:d.validated&&l.length===0&&!w}})},onConnect:l=>{if(!t().isValidConnection(l))return;const d=`${l.source}.${l.sourceHandle??""}`,c=`${l.target}.${l.targetHandle??""}`;if(t().edges.some(p=>p.id===Dr(d,c)))return;a(`connect:${d}->${c}`),e(p=>({edges:[...p.edges,{id:Dr(d,c),type:"flow",source:l.source,sourceHandle:l.sourceHandle,target:l.target,targetHandle:l.targetHandle}],dirty:!0,validated:!1}));const f=t().nodes.find(p=>p.id===l.target);if((f==null?void 0:f.data.def.type)==="end"&&(l.targetHandle??"")==="input"){s=!0;try{t().updateNodeConfig(f.id,{output_from:d})}finally{s=!1}}},isValidConnection:l=>{const{catalog:d,nodes:c}=t();if(!d||!l.source||!l.target)return!1;const f=c.find(g=>g.id===l.source),p=c.find(g=>g.id===l.target);return!f||!p?!1:em({node:f.data.def,port:l.sourceHandle??""},{node:p.data.def,port:l.targetHandle??""},t().infoByType(),d).ok},addNode:(l,d)=>{const c=t().infoByType().get(l);if(!c)return;const f=nm[l]??l.replace(/[^a-z0-9_]/g,"_"),p=new Set(t().nodes.map(w=>w.id));let g=1;for(;p.has(`${f}_${g}`);)g+=1;const v=`${f}_${g}`;a(`add:${v}`),e(w=>({nodes:[...w.nodes,{id:v,type:"flow",position:d,data:{def:{id:v,type:l,version:c.version,config:structuredClone(c.default_config??{})}},deletable:l!=="start"&&l!=="end"}],dirty:!0,validated:!1,selectedNodeId:v}))},updateNodeConfig:(l,d)=>{a(`config:${l}`),e(c=>({nodes:c.nodes.map(f=>f.id===l?{...f,data:{def:{...f.data.def,config:{...f.data.def.config,...d}}}}:f),dirty:!0,validated:!1})),t().onEdgesChange([])},updateMeta:l=>{a("meta"),e(d=>({meta:{...d.meta,...l},dirty:!0,validated:!1}))},undo:()=>{const{past:l}=t();if(l.length===0)return;const d=l[l.length-1],c=o();u(),e(f=>({past:f.past.slice(0,-1),future:[c,...f.future].slice(0,rm),meta:d.meta,nodes:d.nodes,edges:d.edges,dirty:!0,validated:!1,selectedNodeId:null}))},redo:()=>{const{future:l}=t();if(l.length===0)return;const d=l[0],c=o();u(),e(f=>({future:f.future.slice(1),past:[...f.past.slice(-49),c],meta:d.meta,nodes:d.nodes,edges:d.edges,dirty:!0,validated:!1,selectedNodeId:null}))},setValidation:l=>{e({issues:l.issues,runtimeChecked:l.runtime_checked,validated:!0})},setIssues:l=>e({issues:l,validated:!0}),select:l=>e({selectedNodeId:l}),markSaved:()=>e({dirty:!1}),markDirty:()=>e({dirty:!0,validated:!1})}});function om(e){return e.some(t=>t.severity==="error")}function jr(e){const t=/^nodes\/([a-z0-9_-]+)/.exec(e);return t?t[1]:null}function Qs({value:e,onCommit:t,placeholder:n,rows:r=6}){const[s,i]=C.useState(()=>e==null?"":JSON.stringify(e,null,2)),[o,a]=C.useState(!1);return C.useEffect(()=>{i(e==null?"":JSON.stringify(e,null,2)),a(!1)},[e]),h.jsxs("div",{children:[h.jsx(at,{rows:r,value:s,placeholder:n??"{ }",className:pe(o&&"border-danger focus-visible:outline-danger"),onChange:u=>i(u.target.value),onBlur:()=>{const u=s.trim();if(!u){a(!1),t(null);return}try{t(JSON.parse(u)),a(!1)}catch{a(!0)}}}),o&&h.jsx("p",{className:"mt-1 text-[11px] text-danger",children:"Not valid JSON — not saved."})]})}function im({value:e,onCommit:t}){const n=Object.entries(typeof e=="object"&&e!==null?e:{}).map(([s,i])=>[s,String(i)]),r=s=>t(Object.fromEntries(s));return h.jsxs("div",{className:"flex flex-col gap-1.5",children:[n.map(([s,i],o)=>h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(ae,{value:s,"aria-label":"port name",placeholder:"port",className:"h-7 font-mono text-xs",onChange:a=>{const u=[...n];u[o]=[a.target.value,i],r(u)}}),h.jsx("span",{className:"text-text-3",children:"→"}),h.jsx(ae,{value:i,"aria-label":"argument name",placeholder:"argument",className:"h-7 font-mono text-xs",onChange:a=>{const u=[...n];u[o]=[s,a.target.value],r(u)}}),h.jsx("button",{type:"button","aria-label":"remove entry",className:"text-text-3 hover:text-danger",onClick:()=>r(n.filter((a,u)=>u!==o)),children:"×"})]},o)),h.jsx("button",{type:"button",className:"self-start text-[11px] text-accent hover:underline",onClick:()=>r([...n,["",""]]),children:"+ add mapping"})]})}function am({value:e,kind:t,onChange:n}){var l,d;const r=Ue({queryKey:["config"],queryFn:fe.config.get}),s=gc(),[i,o]=C.useState(!1),a=Ue({queryKey:["resources",t],queryFn:()=>fe.resources.list(t??void 0),retry:!1}),u=a.data??[];return h.jsxs("div",{children:[h.jsxs(sr,{value:e,"aria-label":"resource",onChange:c=>n(c.target.value||null),children:[h.jsx("option",{value:"",children:"— select resource —"}),e&&!u.some(c=>c.name===e)&&h.jsx("option",{value:e,children:e}),u.map(c=>h.jsxs("option",{value:c.name,children:[c.display_name||c.name," (",c.kind,")"]},c.name))]}),a.isError&&((l=r.data)!=null&&l.runtime_configured?h.jsx("p",{className:"mt-1 text-[11px] text-warning",children:"Platform runtime unreachable — enter the name manually below."}):h.jsx("p",{className:"mt-1 text-[11px] text-text-3",children:"No platform runtime connected — type the resource name; it resolves at publish time."})),a.isSuccess&&u.length===0&&h.jsxs("p",{className:"mt-1 text-[11px] text-text-3",children:["The platform has no ",t?t.replace("_"," "):"matching"," resources yet — type the name it will get; publish resolves it (E020 until it exists)."]}),(a.isError||a.isSuccess&&u.length===0)&&h.jsx(ae,{className:"mt-1 h-7 font-mono text-xs",value:e,placeholder:"resource-name",onChange:c=>n(c.target.value||null)}),h.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[h.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 text-[11px] text-accent hover:underline",onClick:()=>o(!0),children:[h.jsx(so,{size:11})," New resource…"]}),((d=r.data)==null?void 0:d.resources_ui_url)&&h.jsxs("a",{href:r.data.resources_ui_url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-accent hover:underline",children:["Manage in Resources ",h.jsx(Fn,{size:11})]})]}),h.jsx(Ug,{open:i,group:t,onClose:()=>o(!1),onCreated:c=>{s.invalidateQueries({queryKey:["resources"]}),n(c)}})]})}function cm(e,t){return e?e.widget:t.type==="boolean"?"switch":t.type==="integer"||t.type==="number"?"number":t.type==="object"?"json":"text"}function lm({name:e,prop:t,ui:n,value:r,onChange:s,issues:i}){const o=cm(n,t),a=(n==null?void 0:n.label)||e,u=(n==null?void 0:n.help)||t.description||"",l=i.filter(d=>d.path.endsWith(`/${e}`));return h.jsxs("div",{children:[h.jsx(se,{hint:u,children:a}),o==="switch"&&h.jsx(Xs,{checked:r===!0,onCheckedChange:s,label:a}),o==="number"&&h.jsx(ae,{type:"number",value:r==null?"":String(r),min:t.minimum,max:t.maximum,onChange:d=>s(d.target.value===""?null:Number(d.target.value))}),(o==="text"||o==="prompt"||o==="textarea")&&(o==="text"?h.jsx(ae,{value:typeof r=="string"?r:"",placeholder:n==null?void 0:n.placeholder,onChange:d=>s(d.target.value)}):h.jsx(at,{rows:o==="prompt"?6:3,value:typeof r=="string"?r:"",placeholder:n==null?void 0:n.placeholder,onChange:d=>s(d.target.value)})),(o==="schema"||o==="json")&&(n!=null&&n.toggleable?h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx(Xs,{checked:r!=null,onCheckedChange:d=>s(d?{type:"object",properties:{}}:null),label:a}),r!=null&&h.jsx(Qs,{value:r,onCommit:s})]}):h.jsx(Qs,{value:r,onCommit:s})),o==="dict"&&h.jsx(im,{value:r,onCommit:d=>s(d)}),o==="resource"&&h.jsx(am,{value:typeof r=="string"?r:"",kind:(n==null?void 0:n.resource_kind)??null,onChange:s}),l.map(d=>h.jsxs("p",{className:pe("mt-1 text-[11px]",d.severity==="error"?"text-danger":"text-warning"),children:[h.jsx("span",{className:"font-mono",children:d.code})," ",d.message]},`${d.code}-${d.path}`))]})}function um({nodeId:e,info:t}){const n=J(c=>c.nodes.find(f=>f.id===e)),r=J(c=>c.issues),s=J(c=>c.updateNodeConfig);if(!n)return null;const i=r.filter(c=>jr(c.path)===e),o=t.config_schema.properties??{},a=Object.entries(o),u=a.filter(([c])=>{var f;return!(((f=t.ui[c])==null?void 0:f.advanced)??!1)}),l=a.filter(([c])=>{var f;return((f=t.ui[c])==null?void 0:f.advanced)??!1}),d=([c,f])=>h.jsx(lm,{name:c,prop:f,ui:t.ui[c],value:n.data.def.config[c]??f.default??null,onChange:p=>s(e,{[c]:p}),issues:i},c);return h.jsxs("div",{className:"flex flex-col gap-3",children:[h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm font-semibold text-text-1",children:t.label}),h.jsxs(wt,{children:["v",t.version]}),h.jsx("span",{className:"ml-auto font-mono text-[11px] text-text-3",children:e})]}),h.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-text-3",children:t.description})]}),u.map(d),l.length>0&&h.jsxs("details",{children:[h.jsx("summary",{className:"cursor-pointer text-[11px] font-medium uppercase tracking-wide text-text-3",children:"Advanced"}),h.jsx("div",{className:"mt-2 flex flex-col gap-3",children:l.map(d)})]})]})}function dm(){const e=J(r=>r.meta),t=J(r=>r.updateMeta),n=e.expose;return h.jsxs("div",{className:"flex flex-col gap-3",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-sm font-semibold text-text-1",children:"Flow settings"}),h.jsxs("p",{className:"mt-1 text-[11px] text-text-3",children:["Name ",h.jsx("span",{className:"font-mono",children:e.name})," · rename via export → import"]})]}),h.jsxs("div",{children:[h.jsx(se,{children:"Display name"}),h.jsx(ae,{value:e.display_name,onChange:r=>t({display_name:r.target.value})})]}),h.jsxs("div",{children:[h.jsx(se,{children:"Description"}),h.jsx(at,{rows:3,value:e.description,onChange:r=>t({description:r.target.value})})]}),h.jsxs("div",{children:[h.jsx(se,{hint:"comma separated",children:"Tags"}),h.jsx(Ji,{value:e.tags,onChange:r=>t({tags:r})})]}),h.jsxs("p",{className:"text-[11px] text-text-3",children:["Currently exposed as"," ",h.jsx("span",{className:"font-medium text-text-2",children:n.kind==="mcp"?"MCP tool":"A2A agent"})," ","— the door (and its fields) is chosen in the Publish dialog."]})]})}function fm(){const e=J(s=>s.selectedNodeId),t=J(s=>s.infoByType),n=J(s=>s.nodes.find(i=>i.id===s.selectedNodeId)),r=n?t().get(n.data.def.type):void 0;return h.jsx("aside",{className:"flex w-80 shrink-0 flex-col overflow-y-auto border-l border-border bg-surface-1 p-3",children:e&&r?h.jsx(um,{nodeId:e,info:r}):h.jsx(dm,{})})}const ea={play:Mc,flag:Cc,sparkles:cr,wrench:lo,database:Ec,"git-branch":kc,type:zc},hm={text:"var(--color-port-data)",json:"var(--color-port-table)",documents:"var(--color-port-documents)",message:"var(--color-port-message)"};function Js({port:e,side:t}){return h.jsxs("div",{className:pe("relative flex h-6 items-center text-[11px] text-text-2",t==="in"?"justify-start pl-3":"justify-end pr-3"),children:[h.jsx("span",{className:"truncate font-mono",children:e.label||e.name}),h.jsx($t,{type:t==="in"?"target":"source",id:e.name,position:t==="in"?U.Left:U.Right,className:"!h-2.5 !w-2.5 !border-2 !border-canvas",style:{background:hm[e.type]}})]})}const pm=C.memo(function({id:t,data:n,selected:r}){const s=J(w=>w.catalog),i=J(w=>w.issues),o=J(w=>w.infoByType);if(!s)return null;const a=n.def,u=o().get(a.type),{inputs:l,outputs:d}=It(a,u,s),c=ea[(u==null?void 0:u.icon)??""]??cr,f=i.filter(w=>jr(w.path)===t),p=f.filter(w=>w.severity==="error").length,g=f.length-p,v=Math.max(l.length,d.length);return h.jsxs("div",{className:pe("min-w-44 rounded-node border bg-surface-1 shadow-lg shadow-black/25 transition-colors",r?"border-accent":"border-border hover:border-border-strong"),children:[h.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[h.jsx(c,{size:14,strokeWidth:1.75,className:"shrink-0 text-accent"}),h.jsx("span",{className:"truncate text-xs font-semibold text-text-1",children:(u==null?void 0:u.label)??a.type}),h.jsx("span",{className:"ml-auto font-mono text-[10px] text-text-3",children:t}),p>0&&h.jsx("span",{className:"rounded-md bg-danger/15 px-1.5 font-mono text-[10px] text-danger",children:p}),p===0&&g>0&&h.jsx("span",{className:"rounded-md bg-warning/15 px-1.5 font-mono text-[10px] text-warning",children:g})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-x-4 py-1.5",children:[h.jsx("div",{children:l.map(w=>h.jsx(Js,{port:w,side:"in"},w.name))}),h.jsx("div",{className:"col-start-2",children:d.map(w=>h.jsx(Js,{port:w,side:"out"},w.name))}),v===0&&h.jsx("div",{className:"col-span-2 h-1"})]})]})});function gm({id:e,sourceX:t,sourceY:n,targetX:r,targetY:s,sourcePosition:i,targetPosition:o,selected:a}){const[u]=br({sourceX:t,sourceY:n,targetX:r,targetY:s,sourcePosition:i,targetPosition:o});return h.jsx(Bt,{id:e,path:u,style:{stroke:a?"var(--color-accent)":"var(--color-border-strong)",strokeWidth:1.5}})}const mm={flow:pm},xm={flow:gm},eo=["io","llm","rag","tools","flow"],ym={io:"Input / Output",llm:"LLM",rag:"Knowledge",tools:"Tools",flow:"Flow Control"},ta="application/x-agentplane-node-type";function wm({info:e}){const t=ea[e.icon]??cr;return h.jsxs("div",{draggable:!0,role:"button",tabIndex:0,"aria-label":`Add ${e.label}`,title:e.description,onDragStart:n=>{n.dataTransfer.setData(ta,e.type),n.dataTransfer.effectAllowed="move"},className:pe("flex cursor-grab items-center gap-2 rounded-lg border border-border bg-surface-2 px-2.5 py-2","text-xs text-text-1 transition-colors hover:border-border-strong hover:bg-surface-3"),children:[h.jsx(t,{size:14,strokeWidth:1.75,className:"shrink-0 text-accent"}),h.jsxs("div",{className:"min-w-0",children:[h.jsx("div",{className:"truncate font-medium",children:e.label}),h.jsxs("div",{className:"truncate text-[11px] text-text-3",children:[e.type," · v",e.version]})]})]})}function vm({catalog:e}){const t=new Map;for(const r of e.node_types){const s=t.get(r.category)??[];s.push(r),t.set(r.category,s)}const n=[...eo.filter(r=>t.has(r)),...[...t.keys()].filter(r=>!eo.includes(r))];return h.jsx("aside",{className:"flex w-56 shrink-0 flex-col gap-4 overflow-y-auto border-r border-border bg-surface-1 p-3",children:n.map(r=>h.jsxs("section",{children:[h.jsx("h3",{className:"mb-2 px-1 text-[11px] font-semibold uppercase tracking-wide text-text-3",children:ym[r]??r}),h.jsx("div",{className:"flex flex-col gap-1.5",children:(t.get(r)??[]).map(s=>h.jsx(wm,{info:s},`${s.type}@${s.version}`))})]},r))})}async function bm(e,t){const n=e.getReader(),r=new TextDecoder;let s="";for(;;){const{done:i,value:o}=await n.read();if(i)break;s+=r.decode(o,{stream:!0});const a=s.split(/\r?\n\r?\n/);s=a.pop()??"";for(const u of a){const l=u.split(`
139
+ `).find(c=>c.startsWith("data:"));if(!l)continue;let d;try{d=JSON.parse(l.slice(5).trim())}catch{continue}t(d)}}}const na={"A2A-Version":"1.0"},to=new Map;function _m(e,t={}){return{role:"ROLE_USER",messageId:crypto.randomUUID(),parts:[{text:e}],...t}}function ra(e){var r,s,i;const n=(((r=e.artifacts)==null?void 0:r.flatMap(o=>o.parts??[]))??[]).map(o=>o.text??"").join("").trim();return n||(((i=(s=e.status)==null?void 0:s.message)==null?void 0:i.parts)??[]).map(o=>o.text??"").join("").trim()}function Tt(e){return e.replace(/\/$/,"")}async function sa(e){const t=to.get(e);if(t)return t;let n="jsonrpc";try{const r=await fetch(`${Tt(e)}/.well-known/agent-card.json`,{headers:{...ir()}});if(r.ok){const i=((await r.json()).supportedInterfaces??[]).map(o=>o.protocolBinding??"").filter(Boolean);i.length>0&&!i.includes("JSONRPC")&&(n="rest")}}catch{}return to.set(e,n),n}function Bn(e){return(e??[]).map(t=>t.text??"").join("")}async function Nm(e,t){var o,a;const n=await sa(e),r={"Content-Type":"application/json",...na,...ir()};if(n==="jsonrpc"){const u=await fetch(`${Tt(e)}/`,{method:"POST",headers:r,body:JSON.stringify({jsonrpc:"2.0",id:crypto.randomUUID(),method:"SendMessage",params:{message:t}})});if(!u.ok)throw new Error(`A2A send failed: HTTP ${u.status}`);const l=await u.json();if(l.error)throw new Error(`A2A error: ${l.error.message}`);const d=(o=l.result)==null?void 0:o.task;if(d)return d;const c=(a=l.result)==null?void 0:a.message;if(c)return{id:"",status:{state:"TASK_STATE_COMPLETED",message:c}};throw new Error("A2A response carried no task")}const s=await fetch(`${Tt(e)}/message:send`,{method:"POST",headers:r,body:JSON.stringify({message:t})});if(!s.ok)throw new Error(`A2A send failed: HTTP ${s.status}`);const i=await s.json();if(!i.task)throw new Error("A2A response carried no task");return i.task}async function Em(e,t,n,r){var f;const s=await sa(e),i={"Content-Type":"application/json",...na,...ir()},o=s==="jsonrpc"?`${Tt(e)}/`:`${Tt(e)}/message:stream`,a=JSON.stringify(s==="jsonrpc"?{jsonrpc:"2.0",id:crypto.randomUUID(),method:"SendStreamingMessage",params:{message:t}}:{message:t}),u=await fetch(o,{method:"POST",headers:i,body:a,signal:r});if(!u.ok||!u.body){const p=await Nm(e,t);return n.onDelta(ra(p)),(f=n.onTask)==null||f.call(n,p),p}let l=null,d=!1,c="";return await bm(u.body,p=>{var y,b,m,x,N;const v=p.result??p,w=(b=(y=v.statusUpdate)==null?void 0:y.status)==null?void 0:b.message;if(w){const E=Bn(w.parts);E&&(d=!0,n.onDelta(E))}if(v.message){const E=Bn(v.message.parts);E&&(d=!0,n.onDelta(E))}(x=(m=v.artifactUpdate)==null?void 0:m.artifact)!=null&&x.parts&&(c+=Bn(v.artifactUpdate.artifact.parts)),v.task&&(l=v.task,(N=n.onTask)==null||N.call(n,v.task))}),!d&&c&&n.onDelta(c),l}function Sm({endpoint:e,onClose:t,onRedeploy:n}){const[r,s]=C.useState([]),[i,o]=C.useState(""),[a,u]=C.useState(!1),[l,d]=C.useState(null),c=C.useRef(null),f=async()=>{var v;const p=i.trim();if(!p||a)return;o(""),d(null),u(!0),s(w=>[...w,{role:"user",text:p},{role:"agent",text:""}]);const g=w=>s(y=>{const b=[...y];return b[b.length-1]={role:"agent",text:b[b.length-1].text+w},b});try{const w=_m(p,{taskId:void 0,contextId:(v=c.current)==null?void 0:v.contextId}),y=await Em(e,w,{onDelta:g});y&&(c.current=y,s(b=>{const m=[...b];return m[m.length-1].text||(m[m.length-1]={role:"agent",text:ra(y)}),m}))}catch(w){d(w instanceof Error?w.message:String(w))}finally{u(!1)}};return h.jsxs("aside",{className:"flex w-96 shrink-0 flex-col border-l border-border bg-surface-1",children:[h.jsxs("header",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[h.jsx("span",{className:"text-xs font-semibold text-text-1",children:"Playground"}),h.jsx("span",{className:"truncate font-mono text-[10px] text-text-3",title:e,children:e.replace(/^https?:\/\//,"")}),h.jsxs("span",{className:"ml-auto flex items-center gap-1",children:[h.jsx(de,{size:"icon",variant:"ghost",onClick:n,title:"Redeploy current draft","aria-label":"Redeploy current draft",children:h.jsx($c,{size:13})}),h.jsx(de,{size:"icon",variant:"ghost",onClick:t,"aria-label":"Close playground",children:h.jsx(mc,{size:13})})]})]}),h.jsxs("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto p-3",children:[r.length===0&&h.jsx("p",{className:"text-xs leading-relaxed text-text-3",children:"Ephemeral draft deploy is live (expires automatically). Messages go through the gateway to the runtime — nothing runs inside the builder."}),r.map((p,g)=>h.jsx("div",{className:pe("max-w-[85%] whitespace-pre-wrap rounded-lg px-2.5 py-1.5 text-xs leading-relaxed",p.role==="user"?"ml-auto bg-accent/15 text-text-1":"bg-surface-2 text-text-1"),children:p.text||(a&&g===r.length-1?"…":"")},g)),l&&h.jsx("p",{className:"text-[11px] text-danger",children:l})]}),h.jsxs("form",{className:"flex items-center gap-1.5 border-t border-border p-2",onSubmit:p=>{p.preventDefault(),f()},children:[h.jsx(ae,{value:i,placeholder:"Message the draft agent…",onChange:p=>o(p.target.value),disabled:a}),h.jsx(de,{size:"icon",type:"submit",disabled:a||!i.trim(),"aria-label":"Send",children:h.jsx(Tc,{size:13})})]})]})}const Cm=/^[a-z][a-z0-9_]*$/,km=[{kind:"a2a",icon:bc,title:"A2A agent",detail:"Served at /a2a/{name}; other agents discover it via its agent card."},{kind:"mcp",icon:lo,title:"MCP tool",detail:"Served at /mcp/{name}; one tool per flow, args from the start input schema."}];function jm({result:e,exposeKind:t,registryUiUrl:n,onClose:r}){const[s,i]=C.useState(!1),o=`${e.endpoint_url.replace(/\/$/,"")}/.well-known/agent-card.json`,a=e.version_label?`${e.version_label} (deploy #${e.version})`:`Version ${e.version}`;return h.jsxs("div",{children:[h.jsxs("p",{className:"inline-flex items-center gap-1.5 text-sm text-success",children:[h.jsx(oo,{size:15})," ",a," is live on the runtime."]}),h.jsxs("div",{className:"mt-3 rounded-lg border border-border bg-canvas p-2.5",children:[h.jsx("p",{className:"text-[11px] uppercase tracking-wide text-text-3",children:"Endpoint"}),h.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[h.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-text-1",children:e.endpoint_url}),h.jsx(de,{size:"icon",variant:"ghost","aria-label":"Copy endpoint URL",onClick:()=>{io(e.endpoint_url).then(()=>i(!0))},children:s?h.jsx(ar,{size:13}):h.jsx(ao,{size:13})})]})]}),h.jsxs("div",{className:"mt-2 flex flex-col gap-1 text-xs text-text-3",children:[t==="a2a"?h.jsxs("a",{className:"inline-flex items-center gap-1 text-accent hover:underline",href:o,target:"_blank",rel:"noreferrer",children:["View the served agent card ",h.jsx(Fn,{size:11})]}):h.jsx("span",{children:"Connect MCP clients via streamable HTTP at the endpoint above (tool args = start input schema)."}),n&&h.jsxs("a",{className:"inline-flex items-center gap-1 text-accent hover:underline",href:e.registry_id?`${n.replace(/\/$/,"")}/${e.registry_id}`:n,target:"_blank",rel:"noreferrer",children:["Open in registry ",h.jsx(Fn,{size:11})]})]}),h.jsx("div",{className:"mt-4 flex justify-end",children:h.jsx(de,{size:"sm",variant:"secondary",onClick:r,children:"Done"})})]})}const Mm=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function no(e){return e.split(`
140
+ `).map(t=>t.trim()).filter(Boolean)}function Am({value:e,onChange:t}){const[n,r]=C.useState(()=>e.join(`
141
+ `));return C.useEffect(()=>{r(s=>{const i=no(s);return i.length===e.length&&i.every((a,u)=>a===e[u])?s:e.join(`
142
+ `)})},[e]),h.jsx(at,{rows:2,value:n,placeholder:`What is the refund policy?
143
+ Summarize the latest ticket`,onChange:s=>{r(s.target.value),t(no(s.target.value))}})}function $m({flowName:e,open:t,onClose:n,onPublish:r}){var x;const s=J(N=>N.meta),i=J(N=>N.updateMeta),[o,a]=C.useState(!1),[u,l]=C.useState(null),[d,c]=C.useState(""),f=Ue({queryKey:["config"],queryFn:fe.config.get}),p=s.expose,g=p.kind==="mcp",v=!g||Cm.test(p.tool_name??""),w=d===""||Mm.test(d),y=!g&&!s.description&&!s.display_name,b=()=>{l(null),n()},m=async()=>{a(!0);try{const N=await r(d.trim()||null);N?l(N):n()}finally{a(!1)}};return h.jsx(or,{open:t,onClose:b,title:`Publish ${e}`,className:"max-w-lg",children:u?h.jsx(jm,{result:u,exposeKind:p.kind,registryUiUrl:((x=f.data)==null?void 0:x.registry_ui_url)??"",onClose:b}):h.jsxs("div",{className:"flex flex-col gap-3",children:[h.jsxs("div",{children:[h.jsx(se,{hint:"How the runtime serves this flow.",children:"Choose the door"}),h.jsx("div",{className:"grid grid-cols-2 gap-2",children:km.map(N=>h.jsxs("button",{type:"button",onClick:()=>i({expose:{...p,kind:N.kind}}),className:pe("rounded-lg border p-2.5 text-left transition-colors",p.kind===N.kind?"border-accent bg-accent/10":"border-border bg-surface-2 hover:border-border-strong"),children:[h.jsxs("span",{className:pe("flex items-center gap-1.5 text-xs font-semibold",p.kind===N.kind?"text-accent":"text-text-1"),children:[h.jsx(N.icon,{size:13})," ",N.title]}),h.jsx("span",{className:"mt-1 block text-[11px] leading-relaxed text-text-3",children:N.detail})]},N.kind))})]}),h.jsxs("div",{children:[h.jsx(se,{children:"Display name"}),h.jsx(ae,{value:s.display_name,placeholder:e,onChange:N=>i({display_name:N.target.value})})]}),h.jsxs("div",{children:[h.jsx(se,{hint:g?"":"becomes the agent card description",children:"Description"}),h.jsx(at,{rows:2,value:s.description,onChange:N=>i({description:N.target.value})}),y&&h.jsx("p",{className:"mt-1 text-[11px] text-warning",children:"Empty description → a sparse agent card; agents route better with one."})]}),h.jsxs("div",{children:[h.jsx(se,{hint:g?"comma separated":"comma separated — become the card's skill tags",children:"Tags"}),h.jsx(Ji,{value:s.tags,placeholder:"support, rag",onChange:N=>i({tags:N})})]}),!g&&h.jsxs("div",{children:[h.jsx(se,{hint:"one per line — become skill.examples on the card",children:"Example prompts"}),h.jsx(Am,{value:p.examples??[],onChange:N=>i({expose:{...p,examples:N}})})]}),g&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx(se,{hint:"^[a-z][a-z0-9_]*$",children:"Tool name"}),h.jsx(ae,{className:"font-mono",value:p.tool_name??"",placeholder:"search_support_kb",onChange:N=>i({expose:{...p,tool_name:N.target.value||null}})}),!v&&h.jsx("p",{className:"mt-1 text-[11px] text-danger",children:"Required for MCP (E050): lowercase, digits, underscores."})]}),h.jsxs("div",{children:[h.jsx(se,{children:"Tool description"}),h.jsx(at,{rows:2,value:p.tool_description??"",onChange:N=>i({expose:{...p,tool_description:N.target.value}})})]}),h.jsx("p",{className:"text-[11px] text-text-3",children:"MCP tools need a start input schema — it becomes the tool's argument schema (E050 otherwise)."})]}),h.jsxs("div",{children:[h.jsx(se,{hint:"optional — unique per flow; deploy counter stays the identity",children:"Version label"}),h.jsx(ae,{className:"font-mono",value:d,placeholder:"1.2.0",onChange:N=>c(N.target.value)}),!w&&h.jsx("p",{className:"mt-1 text-[11px] text-danger",children:"Must be a semantic version (e.g. 1.2.0, 2.0.0-rc.1)."})]}),h.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[h.jsx(de,{size:"sm",variant:"ghost",onClick:b,children:"Cancel"}),h.jsxs(de,{size:"sm",disabled:o||!v||!w,onClick:()=>void m(),children:[o?h.jsx(qe,{size:13,className:"animate-spin"}):h.jsx(co,{size:13}),"Publish"]})]})]})})}function Im({flowName:e,open:t,onClose:n}){const[r,s]=C.useState(""),[i,o]=C.useState(!1);C.useEffect(()=>{t&&(o(!1),fe.flows.exportText(e,"yaml").then(s).catch(u=>s(`# export failed: ${u instanceof Error?u.message:String(u)}`)))},[t,e]);const a=()=>{const u=new Blob([r],{type:"application/yaml"}),l=URL.createObjectURL(u),d=document.createElement("a");d.href=l,d.download=`${e}.flow.yaml`,d.click(),URL.revokeObjectURL(l)};return h.jsxs(or,{open:t,onClose:n,title:`Share ${e}`,className:"max-w-2xl",children:[h.jsxs("p",{className:"text-xs leading-relaxed text-text-3",children:["Canonical FlowDefinition YAML — import it here, deploy it with"," ",h.jsx("code",{className:"font-mono text-text-2",children:"agentplane deploy"}),", or commit it to git. Resources are referenced by name; the file never contains credentials."]}),h.jsx("pre",{className:"mt-3 max-h-80 overflow-auto rounded-lg border border-border bg-canvas p-3 font-mono text-[11px] leading-relaxed text-text-2",children:r||"…"}),h.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[h.jsxs(de,{size:"sm",onClick:a,children:[h.jsx(Sc,{size:13})," Download .flow.yaml"]}),h.jsxs(de,{size:"sm",variant:"secondary",onClick:()=>{io(r).then(()=>o(!0))},children:[i?h.jsx(ar,{size:13}):h.jsx(ao,{size:13})," ",i?"Copied":"Copy"]})]})]})}function Tm({issue:e,onFocus:t}){const n=jr(e.path),r=e.severity==="error";return h.jsxs("button",{type:"button",onClick:()=>t(n,e.path),className:pe("flex w-full items-start gap-2 rounded-lg border border-transparent px-2 py-1.5 text-left","transition-colors hover:border-border hover:bg-surface-2"),children:[r?h.jsx(xc,{size:13,className:"mt-0.5 shrink-0 text-danger"}):h.jsx(yc,{size:13,className:"mt-0.5 shrink-0 text-warning"}),h.jsxs("span",{className:"min-w-0 flex-1 text-xs leading-relaxed text-text-1",children:[h.jsx("span",{className:pe("font-mono",r?"text-danger":"text-warning"),children:e.code})," ",e.message,h.jsx("span",{className:"mt-0.5 block truncate font-mono text-[10px] text-text-3",children:e.path})]}),h.jsx(wt,{tone:e.source==="runtime"?"accent":"muted",className:"shrink-0",children:e.source})]})}function Pm({onFocusIssue:e}){const t=J(o=>o.issues),n=J(o=>o.validated),r=J(o=>o.runtimeChecked),s=t.filter(o=>o.severity==="error"),i=t.filter(o=>o.severity==="warning");return h.jsxs("section",{"aria-label":"Validation issues",className:"flex max-h-56 flex-col border-t border-border bg-surface-1",children:[h.jsxs("header",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5",children:[h.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-text-3",children:"Validation"}),s.length>0&&h.jsxs("span",{className:"font-mono text-[11px] text-danger",children:[s.length," errors"]}),i.length>0&&h.jsxs("span",{className:"font-mono text-[11px] text-warning",children:[i.length," warnings"]}),h.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-[11px] text-text-3",children:[n&&!r&&h.jsxs(h.Fragment,{children:[h.jsx(Nc,{size:12})," local only — runtime not checked"]}),n&&r&&"local + runtime"]})]}),h.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-1.5",children:[!n&&h.jsx("p",{className:"px-2 py-3 text-xs text-text-3",children:"Not validated yet — run Validate (local check is instant; the runtime answer is authoritative)."}),n&&t.length===0&&h.jsxs("p",{className:"inline-flex items-center gap-1.5 px-2 py-3 text-xs text-success",children:[h.jsx(oo,{size:13})," No issues found."]}),t.map(o=>h.jsx(Tm,{issue:o,onFocus:e},`${o.source}-${o.code}-${o.path}`))]})]})}function zm({flowName:e}){const t=Vt(),n=J(c=>c.nodes),r=J(c=>c.edges),s=J(c=>c.onNodesChange),i=J(c=>c.onEdgesChange),o=J(c=>c.onConnect),a=J(c=>c.isValidConnection),u=J(c=>c.addNode),l=J(c=>c.select),d=C.useCallback(c=>{const f=c.dataTransfer.getData(ta);f&&(c.preventDefault(),u(f,t.screenToFlowPosition({x:c.clientX,y:c.clientY})))},[u,t]);return h.jsxs(xg,{nodes:n,edges:r,nodeTypes:mm,edgeTypes:xm,onNodesChange:s,onEdgesChange:i,onConnect:o,isValidConnection:a,deleteKeyCode:["Backspace","Delete"],onDrop:d,onDragOver:c=>{c.preventDefault(),c.dataTransfer.dropEffect="move"},onSelectionChange:({nodes:c})=>{var f;return l(((f=c[0])==null?void 0:f.id)??null)},fitView:!0,proOptions:{hideAttribution:!0},className:"bg-canvas","aria-label":`Flow canvas for ${e}`,children:[h.jsx(_g,{gap:20,size:1,color:"var(--color-border)"}),h.jsx(Mg,{showInteractive:!1})]})}function Dm({flowName:e}){var L,X,q,G;const t=Vt(),n=J(B=>B.loaded),r=J(B=>B.dirty),s=J(B=>B.validated),i=J(B=>B.issues),o=J(B=>B.catalog),a=J(B=>B.load),u=J(B=>B.currentDefinition),l=J(B=>B.setValidation),d=J(B=>B.setIssues),c=J(B=>B.markSaved),f=J(B=>B.select),p=J(B=>B.undo),g=J(B=>B.redo),v=J(B=>B.past.length>0),w=J(B=>B.future.length>0),y=J(B=>B.nodes),b=J(B=>B.edges),m=J(B=>B.meta),[x,N]=C.useState(null),[E,j]=C.useState(!1),[I,P]=C.useState(!1),[O,k]=C.useState(null),T=Ue({queryKey:["flow",e],queryFn:()=>fe.flows.get(e)}),H=Ue({queryKey:["node-types"],queryFn:fe.catalog.get}),_=Ue({queryKey:["config"],queryFn:fe.config.get}),A=C.useRef(null);C.useEffect(()=>{T.data&&H.data&&A.current!==e&&(A.current=e,a(T.data.definition,H.data))},[T.data,H.data,e,a]),C.useEffect(()=>{const B=Y=>{if(!(Y.ctrlKey||Y.metaKey))return;const D=Y.target;if(D&&(D.tagName==="INPUT"||D.tagName==="TEXTAREA"||D.tagName==="SELECT"||D.isContentEditable))return;const F=Y.key.toLowerCase();F==="z"&&!Y.shiftKey?(Y.preventDefault(),p()):(F==="y"||F==="z"&&Y.shiftKey)&&(Y.preventDefault(),g())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[p,g]),C.useEffect(()=>{if(!n||J.getState().validated)return;const B=setTimeout(()=>{fe.flows.validate(u(),{runtime:!1}).then(l).catch(()=>{})},700);return()=>clearTimeout(B)},[y,b,m,n,u,l]);const S=C.useCallback(async()=>{N("save");try{return await fe.flows.save(e,u()),c(),!0}catch(B){return He.error(B instanceof Error?B.message:"save failed"),!1}finally{N(null)}},[e,u,c]),$=C.useCallback(async()=>{N("validate");try{l(await fe.flows.validate(u()))}catch(B){He.error(B instanceof Error?B.message:"validate failed")}finally{N(null)}},[u,l]),z=C.useCallback(async B=>{if(!await S())return null;N("publish");try{const Y=await fe.flows.publish(e,{version_label:B});return He.success("Deployed to the runtime"),Y}catch(Y){return Y instanceof On&&Y.issues.length>0?(d(Y.issues),He.error("Publish rejected — see validation panel")):He.error(Y instanceof Error?Y.message:"publish failed"),null}finally{N(null)}},[e,S,d]),M=C.useCallback(async()=>{if(await S()){N("playground");try{const B=await fe.flows.playground(e);k(B.endpoint_url)}catch(B){B instanceof On&&B.issues.length>0?(d(B.issues),He.error("Draft rejected — see validation panel")):He.error(B instanceof Error?B.message:"playground deploy failed")}finally{N(null)}}},[e,S,d]),R=C.useCallback(B=>{if(!B)return;const Y=J.getState().nodes.find(D=>D.id===B);Y&&(f(B),t.setCenter(Y.position.x+90,Y.position.y+40,{zoom:1.1,duration:300}))},[t,f]);if(T.isError)return h.jsxs("div",{className:"flex h-full items-center justify-center text-sm text-text-2",children:["Flow not found. ",h.jsx(Lr,{className:"ml-1 text-accent hover:underline",to:"/",children:"Back"})]});if(!n||!o)return h.jsxs("div",{className:"flex h-full items-center justify-center text-sm text-text-3",children:[h.jsx(qe,{className:"mr-2 animate-spin",size:15})," Loading flow…"]});const V=om(i);return h.jsxs("div",{className:"flex h-screen flex-col bg-canvas",children:[h.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-border bg-surface-1 px-3",children:[h.jsx(Lr,{to:"/","aria-label":"Back to flows",className:"text-text-2 hover:text-text-1",children:h.jsx(vc,{size:16})}),h.jsx("span",{className:"text-sm font-semibold text-text-1",children:e}),r&&h.jsx(wt,{tone:"warning",children:"unsaved"}),s&&!V&&h.jsx(wt,{tone:"success",children:"valid"}),s&&V&&h.jsx(wt,{tone:"danger",children:"errors"}),h.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[h.jsx(de,{size:"icon",variant:"ghost",onClick:p,disabled:!v,title:"Undo (Ctrl+Z)","aria-label":"Undo",children:h.jsx(Dc,{size:14})}),h.jsx(de,{size:"icon",variant:"ghost",onClick:g,disabled:!w,title:"Redo (Ctrl+Y)","aria-label":"Redo",children:h.jsx(Ac,{size:14})}),h.jsxs(de,{size:"sm",variant:"secondary",onClick:()=>void S(),disabled:x!==null,children:[x==="save"?h.jsx(qe,{size:13,className:"animate-spin"}):h.jsx(Ic,{size:13}),"Save"]}),h.jsxs(de,{size:"sm",variant:"secondary",onClick:()=>void $(),disabled:x!==null,children:[x==="validate"?h.jsx(qe,{size:13,className:"animate-spin"}):h.jsx(ar,{size:13}),"Validate"]}),h.jsxs(de,{size:"sm",variant:"secondary",onClick:()=>void M(),disabled:x!==null||!((L=_.data)!=null&&L.runtime_configured),title:(X=_.data)!=null&&X.runtime_configured?"Ephemeral deploy + chat":"No runtime configured",children:[x==="playground"?h.jsx(qe,{size:13,className:"animate-spin"}):h.jsx(jc,{size:13}),"Playground"]}),h.jsxs(de,{size:"sm",variant:"secondary",onClick:()=>P(!0),children:[h.jsx(Pc,{size:13})," Share"]}),h.jsxs(de,{size:"sm",onClick:()=>j(!0),disabled:x!==null||!((q=_.data)!=null&&q.runtime_configured),title:(G=_.data)!=null&&G.runtime_configured?"Choose the door, then update runtime draft + deploy":"No runtime configured",children:[x==="publish"?h.jsx(qe,{size:13,className:"animate-spin"}):h.jsx(co,{size:13}),"Publish"]})]})]}),h.jsxs("div",{className:"flex min-h-0 flex-1",children:[h.jsx(vm,{catalog:o}),h.jsxs("main",{className:"flex min-w-0 flex-1 flex-col",children:[h.jsx("div",{className:"min-h-0 flex-1",children:h.jsx(zm,{flowName:e})}),h.jsx(Pm,{onFocusIssue:R})]}),O?h.jsx(Sm,{endpoint:O,onClose:()=>k(null),onRedeploy:()=>void M()}):h.jsx(fm,{})]}),h.jsx($m,{flowName:e,open:E,onClose:()=>j(!1),onPublish:z}),h.jsx(Im,{flowName:e,open:I,onClose:()=>P(!1)})]})}function Rm(){const{flowName:e}=wc();return e?h.jsx(Ki,{children:h.jsx(Dm,{flowName:e})}):null}export{Rm as BuilderPage};