pgexplain 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -2
- package/dist/cli.js +1031 -75
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +30 -2
- package/dist/index.js +532 -30
- package/dist/index.js.map +1 -1
- package/dist/server.js +3996 -0
- package/dist/server.js.map +1 -0
- package/dist/web/assets/PlanGraph-0P3xGm2e.js +23 -0
- package/dist/web/assets/PlanGraph-C5ap-Sga.css +1 -0
- package/dist/web/assets/index-BqB6p5Pn.js +227 -0
- package/dist/web/assets/index-ByEFSLsN.css +1 -0
- package/dist/web/index.html +13 -0
- package/package.json +10 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import{r as ci,g as Sc,R as Mc,a as D,j as M,B as kc,n as Cc}from"./index-BqB6p5Pn.js";var ui=Object.defineProperty,Ic=(e,t,n)=>t in e?ui(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ac=(e,t)=>{for(var n in t)ui(e,n,{get:t[n],enumerable:!0})},$c=(e,t,n)=>Ic(e,t+"",n),li={};Ac(li,{Graph:()=>de,alg:()=>ar,json:()=>fi,version:()=>Lc});var Pc=Object.defineProperty,di=(e,t)=>{for(var n in t)Pc(e,n,{get:t[n],enumerable:!0})},de=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let r of this.successors(e))n.add(r);return Array.from(n.values())}}isLeaf(e){let t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,i])=>{e(o)&&t.setNode(o,i)}),Object.values(this._edgeObjs).forEach(o=>{t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,this.edge(o))});let n={},r=o=>{let i=this.parent(o);return!i||t.hasNode(i)?(n[o]=i??void 0,i??void 0):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(o=>t.setParent(o,r(o))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let o,i,s,a,c=!1;typeof e=="object"&&e!==null&&"v"in e?(o=e.v,i=e.w,s=e.name,arguments.length===2&&(a=t,c=!0)):(o=e,i=t,s=r,arguments.length>2&&(a=n,c=!0)),o=""+o,i=""+i,s!==void 0&&(s=""+s);let u=ft(this._isDirected,o,i,s);if(u in this._edgeLabels)return c&&(this._edgeLabels[u]=a),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(i),this._edgeLabels[u]=c?a:this._defaultEdgeLabelFn(o,i,s);let d=Tc(this._isDirected,o,i,s);return o=d.v,i=d.w,Object.freeze(d),this._edgeObjs[u]=d,zr(this._preds[i],o),zr(this._sucs[o],i),this._in[i][u]=d,this._out[o][u]=d,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Mn(this._isDirected,e):ft(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Mn(this._isDirected,e):ft(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Mn(this._isDirected,e):ft(this._isDirected,e,t,n),o=this._edgeObjs[r];if(o){let i=o.v,s=o.w;delete this._edgeLabels[r],delete this._edgeObjs[r],jr(this._preds[s],i),jr(this._sucs[i],s),delete this._in[s][r],delete this._out[i][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(o=>o.v===t&&o.w===n||o.v===n&&o.w===t):r}};function zr(e,t){e[t]?e[t]++:e[t]=1}function jr(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function ft(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let s=o;o=i,i=s}return o+""+i+""+(r===void 0?"\0":r)}function Tc(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let a=o;o=i,i=a}let s={v:o,w:i};return r&&(s.name=r),s}function Mn(e,t){return ft(e,t.v,t.w,t.name)}var Lc="4.0.1",fi={};di(fi,{read:()=>zc,write:()=>Dc});function Dc(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Oc(e),edges:Rc(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Oc(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),o={v:t};return n!==void 0&&(o.value=n),r!==void 0&&(o.parent=r),o})}function Rc(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function zc(e){let t=new de(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var ar={};di(ar,{CycleException:()=>Kt,bellmanFord:()=>hi,components:()=>Vc,dijkstra:()=>Ut,dijkstraAll:()=>Yc,findCycles:()=>Xc,floydWarshall:()=>Gc,isAcyclic:()=>Uc,postorder:()=>Zc,preorder:()=>Qc,prim:()=>Jc,shortestPaths:()=>eu,tarjan:()=>pi,topsort:()=>mi});var jc=()=>1;function hi(e,t,n,r){return Hc(e,String(t),n||jc,r||function(o){return e.outEdges(o)})}function Hc(e,t,n,r){let o={},i,s=0,a=e.nodes(),c=function(l){let f=n(l);o[l.v].distance+f<o[l.w].distance&&(o[l.w]={distance:o[l.v].distance+f,predecessor:l.v},i=!0)},u=function(){a.forEach(function(l){r(l).forEach(function(f){let h=f.v===l?f.v:f.w,g=h===f.v?f.w:f.v;c({v:h,w:g})})})};a.forEach(function(l){let f=l===t?0:Number.POSITIVE_INFINITY;o[l]={distance:f,predecessor:""}});let d=a.length;for(let l=1;l<d&&(i=!1,s++,u(),!!i);l++);if(s===d-1&&(i=!1,u(),i))throw new Error("The graph contains a negative weight cycle");return o}function Vc(e){let t={},n=[],r;function o(i){i in t||(t[i]=!0,r.push(i),e.successors(i).forEach(o),e.predecessors(i).forEach(o))}return e.nodes().forEach(function(i){r=[],o(i),r.length&&n.push(r)}),n}var gi=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let o=this._arr,i=o.length;return n[r]=i,o.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,o=e;n<t.length&&(o=t[n].priority<t[o].priority?n:o,r<t.length&&(o=t[r].priority<t[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,o=n[e],i=n[t];n[e]=i,n[t]=o,r[i.key]=e,r[o.key]=t}},Bc=()=>1;function Ut(e,t,n,r){let o=function(i){return e.outEdges(i)};return Fc(e,String(t),n||Bc,r||o)}function Fc(e,t,n,r){let o={},i=new gi,s,a,c=function(u){let d=u.v!==s?u.v:u.w,l=o[d],f=n(u),h=a.distance+f;if(f<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+u+" Weight: "+f);h<l.distance&&(l.distance=h,l.predecessor=s,i.decrease(d,h))};for(e.nodes().forEach(function(u){let d=u===t?0:Number.POSITIVE_INFINITY;o[u]={distance:d,predecessor:""},i.add(u,d)});i.size()>0&&(s=i.removeMin(),a=o[s],a.distance!==Number.POSITIVE_INFINITY);)r(s).forEach(c);return o}function Yc(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=Ut(e,o,t,n),r},{})}function pi(e){let t=0,n=[],r={},o=[];function i(s){let a=r[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),e.successors(s).forEach(function(c){c in r?r[c].onStack&&(a.lowlink=Math.min(a.lowlink,r[c].index)):(i(c),a.lowlink=Math.min(a.lowlink,r[c].lowlink))}),a.lowlink===a.index){let c=[],u;do u=n.pop(),r[u].onStack=!1,c.push(u);while(s!==u);o.push(c)}}return e.nodes().forEach(function(s){s in r||i(s)}),o}function Xc(e){return pi(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Wc=()=>1;function Gc(e,t,n){return qc(e,t||Wc,n||function(r){return e.outEdges(r)})}function qc(e,t,n){let r={},o=e.nodes();return o.forEach(function(i){r[i]={},r[i][i]={distance:0,predecessor:""},o.forEach(function(s){i!==s&&(r[i][s]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(i).forEach(function(s){let a=s.v===i?s.w:s.v,c=t(s);r[i][a]={distance:c,predecessor:i}})}),o.forEach(function(i){let s=r[i];o.forEach(function(a){let c=r[a];o.forEach(function(u){let d=c[i],l=s[u],f=c[u],h=d.distance+l.distance;h<f.distance&&(f.distance=h,f.predecessor=l.predecessor)})})}),r}var Kt=class extends Error{constructor(...e){super(...e)}};function mi(e){let t={},n={},r=[];function o(i){if(i in n)throw new Kt;i in t||(n[i]=!0,t[i]=!0,e.predecessors(i).forEach(o),delete n[i],r.push(i))}if(e.sinks().forEach(o),Object.keys(t).length!==e.nodeCount())throw new Kt;return r}function Uc(e){try{mi(e)}catch(t){if(t instanceof Kt)return!1;throw t}return!0}function Kc(e,t,n,r,o){Array.isArray(t)||(t=[t]);let i=(a=>{var c;return(c=e.isDirected()?e.successors(a):e.neighbors(a))!=null?c:[]}),s={};return t.forEach(function(a){if(!e.hasNode(a))throw new Error("Graph does not have node: "+a);o=yi(e,a,n==="post",s,i,r,o)}),o}function yi(e,t,n,r,o,i,s){return t in r||(r[t]=!0,n||(s=i(s,t)),o(t).forEach(function(a){s=yi(e,a,n,r,o,i,s)}),n&&(s=i(s,t))),s}function xi(e,t,n){return Kc(e,t,n,function(r,o){return r.push(o),r},[])}function Zc(e,t){return xi(e,t,"post")}function Qc(e,t){return xi(e,t,"pre")}function Jc(e,t){let n=new de,r={},o=new gi,i;function s(c){let u=c.v===i?c.w:c.v,d=o.priority(u);if(d!==void 0){let l=t(c);l<d&&(r[u]=i,o.decrease(u,l))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(c){o.add(c,Number.POSITIVE_INFINITY),n.setNode(c)}),o.decrease(e.nodes()[0],0);let a=!1;for(;o.size()>0;){if(i=o.removeMin(),i in r)n.setEdge(i,r[i]);else{if(a)throw new Error("Input graph is not connected: "+e);a=!0}e.nodeEdges(i).forEach(s)}return n}function eu(e,t,n,r){return tu(e,t,n,r??(o=>{let i=e.outEdges(o);return i??[]}))}function tu(e,t,n,r){if(n===void 0)return Ut(e,t,n,r);let o=!1,i=e.nodes();for(let s=0;s<i.length;s++){let a=r(i[s]);for(let c=0;c<a.length;c++){let u=a[c],d=u.v===i[s]?u.v:u.w,l=d===u.v?u.w:u.v;n({v:d,w:l})<0&&(o=!0)}if(o)return hi(e,t,n,r)}return Ut(e,t,n,r)}function ct(e,t,n,r){let o=r;for(;e.hasNode(o);)o=cr(r);return n.dummy=t,e.setNode(o,n),o}function nu(e){let t=new de().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},o=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})}),t}function wi(e){let t=new de({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function Hr(e,t){let n=e.x,r=e.y,o=t.x-n,i=t.y-r,s=e.width/2,a=e.height/2;if(!o&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let c,u;return Math.abs(i)*s>Math.abs(o)*a?(i<0&&(a=-a),c=a*o/i,u=a):(o<0&&(s=-s),c=s,u=s*i/o),{x:n+c,y:r+u}}function kt(e){let t=yt(bi(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),o=r.rank;o!==void 0&&(t[o]||(t[o]=[]),t[o][r.order]=n)}),t}function ru(e){let t=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MAX_VALUE:o}),n=_e(Math.min,t);e.nodes().forEach(r=>{let o=e.node(r);Object.hasOwn(o,"rank")&&(o.rank-=n)})}function ou(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),n=_e(Math.min,t),r=[];e.nodes().forEach(s=>{let a=e.node(s).rank-n;r[a]||(r[a]=[]),r[a].push(s)});let o=0,i=e.graph().nodeRankFactor;Array.from(r).forEach((s,a)=>{s===void 0&&a%i!==0?--o:s!==void 0&&o&&s.forEach(c=>e.node(c).rank+=o)})}function Vr(e,t,n,r){let o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=r),ct(e,"border",o,t)}function iu(e,t=vi){let n=[];for(let r=0;r<e.length;r+=t){let o=e.slice(r,r+t);n.push(o)}return n}var vi=65535;function _e(e,t){if(t.length>vi){let n=iu(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function bi(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return _e(Math.max,t)}function su(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function _i(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function Ei(e,t){return t()}var au=0;function cr(e){let t=++au;return e+(""+t)}function yt(e,t,n=1){t==null&&(t=e,e=0);let r=i=>i<t;n<0&&(r=i=>t<i);let o=[];for(let i=e;r(i);i+=n)o.push(i);return o}function Zt(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function ln(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[o,i])=>(r[o]=n(i,o),r),{})}function cu(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}var dn="\0",uu="3.0.0",lu=class{constructor(){$c(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Br(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Br(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,du)),n=n._prev;return"["+e.join(", ")+"]"}};function Br(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function du(e,t){if(e!=="_next"&&e!=="_prev")return t}var fu=lu,hu=()=>1;function gu(e,t){if(e.nodeCount()<=1)return[];let n=mu(e,t||hu);return pu(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function pu(e,t,n){var r;let o=[],i=t[t.length-1],s=t[0],a;for(;e.nodeCount();){for(;a=s.dequeue();)kn(e,t,n,a);for(;a=i.dequeue();)kn(e,t,n,a);if(e.nodeCount()){for(let c=t.length-2;c>0;--c)if(a=(r=t[c])==null?void 0:r.dequeue(),a){o=o.concat(kn(e,t,n,a,!0)||[]);break}}}return o}function kn(e,t,n,r,o){let i=[],s=o?i:void 0;return(e.inEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),u=e.node(a.v);o&&i.push({v:a.v,w:a.w}),u.out-=c,Xn(t,n,u)}),(e.outEdges(r.v)||[]).forEach(a=>{let c=e.edge(a),u=a.w,d=e.node(u);d.in-=c,Xn(t,n,d)}),e.removeNode(r.v),s}function mu(e,t){let n=new de,r=0,o=0;e.nodes().forEach(a=>{n.setNode(a,{v:a,in:0,out:0})}),e.edges().forEach(a=>{let c=n.edge(a.v,a.w)||0,u=t(a),d=c+u;n.setEdge(a.v,a.w,d);let l=n.node(a.v),f=n.node(a.w);o=Math.max(o,l.out+=u),r=Math.max(r,f.in+=u)});let i=yu(o+r+3).map(()=>new fu),s=r+1;return n.nodes().forEach(a=>{Xn(i,s,n.node(a))}),{graph:n,buckets:i,zeroIdx:s}}function Xn(e,t,n){var r,o,i;n.out?n.in?(i=e[n.out-n.in+t])==null||i.enqueue(n):(o=e[e.length-1])==null||o.enqueue(n):(r=e[0])==null||r.enqueue(n)}function yu(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function xu(e){(e.graph().acyclicer==="greedy"?gu(e,t(e)):wu(e)).forEach(n=>{let r=e.edge(n);e.removeEdge(n),r.forwardName=n.name,r.reversed=!0,e.setEdge(n.w,n.v,r,cr("rev"))});function t(n){return r=>n.edge(r).weight}}function wu(e){let t=[],n={},r={};function o(i){Object.hasOwn(r,i)||(r[i]=!0,n[i]=!0,e.outEdges(i).forEach(s=>{Object.hasOwn(n,s.w)?t.push(s):o(s.w)}),delete n[i])}return e.nodes().forEach(o),t}function vu(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function bu(e){e.graph().dummyChains=[],e.edges().forEach(t=>_u(e,t))}function _u(e,t){let n=t.v,r=e.node(n).rank,o=t.w,i=e.node(o).rank,s=t.name,a=e.edge(t),c=a.labelRank;if(i===r+1)return;e.removeEdge(t);let u,d,l;for(l=0,++r;r<i;++l,++r)a.points=[],d={width:0,height:0,edgeLabel:a,edgeObj:t,rank:r},u=ct(e,"edge",d,"_d"),r===c&&(d.width=a.width,d.height=a.height,d.dummy="edge-label",d.labelpos=a.labelpos),e.setEdge(n,u,{weight:a.weight},s),l===0&&e.graph().dummyChains.push(u),n=u;e.setEdge(n,o,{weight:a.weight},s)}function Eu(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,o;for(e.setEdge(n.edgeObj,r);n.dummy;)o=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=o,n=e.node(t)})}function ur(e){let t={};function n(r){let o=e.node(r);if(Object.hasOwn(t,r))return o.rank;t[r]=!0;let i=e.outEdges(r),s=i?i.map(c=>c==null?Number.POSITIVE_INFINITY:n(c.w)-e.edge(c).minlen):[],a=_e(Math.min,s);return a===Number.POSITIVE_INFINITY&&(a=0),o.rank=a}e.sources().forEach(n)}function et(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Ni=Nu;function Nu(e){let t=new de({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],o=e.nodeCount();t.setNode(r,{});let i,s;for(;Su(t,e)<o&&(i=Mu(t,e),!!i);)s=t.hasNode(i.v)?et(e,i):-et(e,i),ku(t,e,s);return t}function Su(e,t){function n(r){let o=t.nodeEdges(r);o&&o.forEach(i=>{let s=i.v,a=r===s?i.w:s;!e.hasNode(a)&&!et(t,i)&&(e.setNode(a,{}),e.setEdge(r,a,{}),n(a))})}return e.nodes().forEach(n),e.nodeCount()}function Mu(e,t){return t.edges().reduce((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=et(t,r)),o<n[0]?[o,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function ku(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:Cu,postorder:Iu}=ar,Au=qe;qe.initLowLimValues=dr;qe.initCutValues=lr;qe.calcCutValue=Si;qe.leaveEdge=ki;qe.enterEdge=Ci;qe.exchangeEdges=Ii;function qe(e){e=nu(e),ur(e);let t=Ni(e);dr(t),lr(t,e);let n,r;for(;n=ki(t);)r=Ci(t,e,n),Ii(t,e,n,r)}function lr(e,t){let n=Iu(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>$u(e,t,r))}function $u(e,t,n){let r=e.node(n).parent,o=e.edge(n,r);o.cutvalue=Si(e,t,n)}function Si(e,t,n){let r=e.node(n).parent,o=!0,i=t.edge(n,r),s=0;i||(o=!1,i=t.edge(r,n)),s=i.weight;let a=t.nodeEdges(n);return a&&a.forEach(c=>{let u=c.v===n,d=u?c.w:c.v;if(d!==r){let l=u===o,f=t.edge(c).weight;if(s+=l?f:-f,Tu(e,n,d)){let h=e.edge(n,d).cutvalue;s+=l?-h:h}}}),s}function dr(e,t){arguments.length<2&&(t=e.nodes()[0]),Mi(e,{},1,t)}function Mi(e,t,n,r,o){let i=n,s=e.node(r);t[r]=!0;let a=e.neighbors(r);return a&&a.forEach(c=>{Object.hasOwn(t,c)||(n=Mi(e,t,n,c,r))}),s.low=i,s.lim=n++,o?s.parent=o:delete s.parent,n}function ki(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Ci(e,t,n){let r=n.v,o=n.w;t.hasEdge(r,o)||(r=n.w,o=n.v);let i=e.node(r),s=e.node(o),a=i,c=!1;return i.lim>s.lim&&(a=s,c=!0),t.edges().filter(u=>c===Fr(e,e.node(u.v),a)&&c!==Fr(e,e.node(u.w),a)).reduce((u,d)=>et(t,d)<et(t,u)?d:u)}function Ii(e,t,n,r){let o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),dr(e),lr(e,t),Pu(e,t)}function Pu(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=Cu(e,[n]);r=r.slice(1),r.forEach(o=>{let i=e.node(o).parent,s=t.edge(o,i),a=!1;s||(s=t.edge(i,o),a=!0),t.node(o).rank=t.node(i).rank+(a?s.minlen:-s.minlen)})}function Tu(e,t,n){return e.hasEdge(t,n)}function Fr(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Lu=Du;function Du(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":Yr(e);break;case"tight-tree":Ru(e);break;case"longest-path":Ou(e);break;case"none":break;default:Yr(e)}}var Ou=ur;function Ru(e){ur(e),Ni(e)}function Yr(e){Au(e)}var zu=ju;function ju(e){let t=Vu(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),o=r.edgeObj,i=Hu(e,t,o.v,o.w),s=i.path,a=i.lca,c=0,u=s[c],d=!0;for(;n!==o.w;){if(r=e.node(n),d){for(;(u=s[c])!==a&&e.node(u).maxRank<r.rank;)c++;u===a&&(d=!1)}if(!d){for(;c<s.length-1&&e.node(s[c+1]).minRank<=r.rank;)c++;u=s[c]}u!==void 0&&e.setParent(n,u),n=e.successors(n)[0]}})}function Hu(e,t,n,r){let o=[],i=[],s=Math.min(t[n].low,t[r].low),a=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),o.push(c);while(c&&(t[c].low>s||a>t[c].lim));let u=c,d=r;for(;(d=e.parent(d))!==u;)i.push(d);return{path:o.concat(i.reverse()),lca:u}}function Vu(e){let t={},n=0;function r(o){let i=n;e.children(o).forEach(r),t[o]={low:i,lim:n++}}return e.children(dn).forEach(r),t}function Bu(e){let t=ct(e,"root",{},"_root"),n=Fu(e),r=Object.values(n),o=_e(Math.max,r)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(a=>e.edge(a).minlen*=i);let s=Yu(e)+1;e.children(dn).forEach(a=>Ai(e,t,i,s,o,n,a)),e.graph().nodeRankFactor=i}function Ai(e,t,n,r,o,i,s){var a;let c=e.children(s);if(!c.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:n});return}let u=Vr(e,"_bt"),d=Vr(e,"_bb"),l=e.node(s);e.setParent(u,s),l.borderTop=u,e.setParent(d,s),l.borderBottom=d,c.forEach(f=>{var h;Ai(e,t,n,r,o,i,f);let g=e.node(f),x=g.borderTop?g.borderTop:f,y=g.borderBottom?g.borderBottom:f,p=g.borderTop?r:2*r,b=x!==y?1:o-((h=i[s])!=null?h:0)+1;e.setEdge(u,x,{weight:p,minlen:b,nestingEdge:!0}),e.setEdge(y,d,{weight:p,minlen:b,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,u,{weight:0,minlen:o+((a=i[s])!=null?a:0)})}function Fu(e){let t={};function n(r,o){let i=e.children(r);i&&i.length&&i.forEach(s=>n(s,o+1)),t[r]=o}return e.children(dn).forEach(r=>n(r,1)),t}function Yu(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Xu(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Wu=Gu;function Gu(e){function t(n){let r=e.children(n),o=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,s=o.maxRank+1;i<s;++i)Xr(e,"borderLeft","_bl",n,o,i),Xr(e,"borderRight","_br",n,o,i)}}e.children(dn).forEach(t)}function Xr(e,t,n,r,o,i){let s={width:0,height:0,rank:i,borderType:t},a=o[t][i-1],c=ct(e,"border",s,n);o[t][i]=c,e.setParent(c,r),a&&e.setEdge(a,c,{weight:1})}function qu(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&$i(e)}function Uu(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&Ku(e),(n==="lr"||n==="rl")&&(Zu(e),$i(e))}function $i(e){e.nodes().forEach(t=>Wr(e.node(t))),e.edges().forEach(t=>Wr(e.edge(t)))}function Wr(e){let t=e.width;e.width=e.height,e.height=t}function Ku(e){e.nodes().forEach(t=>Cn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Cn),Object.hasOwn(r,"y")&&Cn(r)})}function Cn(e){e.y=-e.y}function Zu(e){e.nodes().forEach(t=>In(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(In),Object.hasOwn(r,"x")&&In(r)})}function In(e){let t=e.x;e.x=e.y,e.y=t}function Qu(e){let t={},n=e.nodes().filter(a=>!e.children(a).length),r=n.map(a=>e.node(a).rank),o=_e(Math.max,r),i=yt(o+1).map(()=>[]);function s(a){if(t[a])return;t[a]=!0;let c=e.node(a);i[c.rank].push(a);let u=e.successors(a);u&&u.forEach(s)}return n.sort((a,c)=>e.node(a).rank-e.node(c).rank).forEach(s),i}function Ju(e,t){let n=0;for(let r=1;r<t.length;++r)n+=el(e,t[r-1],t[r]);return n}function el(e,t,n){let r=cu(n,n.map((u,d)=>d)),o=t.flatMap(u=>{let d=e.outEdges(u);return d?d.map(l=>({pos:r[l.w],weight:e.edge(l).weight})).sort((l,f)=>l.pos-f.pos):[]}),i=1;for(;i<n.length;)i<<=1;let s=2*i-1;i-=1;let a=new Array(s).fill(0),c=0;return o.forEach(u=>{let d=u.pos+i;a[d]+=u.weight;let l=0;for(;d>0;)d%2&&(l+=a[d+1]),d=d-1>>1,a[d]+=u.weight;c+=u.weight*l}),c}function tl(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let o=r.reduce((i,s)=>{let a=e.edge(s),c=e.node(s.v);return{sum:i.sum+a.weight*c.order,weight:i.weight+a.weight}},{sum:0,weight:0});return{v:n,barycenter:o.sum/o.weight,weight:o.weight}}})}function nl(e,t){let n={};e.forEach((o,i)=>{let s={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(s.barycenter=o.barycenter,s.weight=o.weight),n[o.v]=s}),t.edges().forEach(o=>{let i=n[o.v],s=n[o.w];i!==void 0&&s!==void 0&&(s.indegree++,i.out.push(s))});let r=Object.values(n).filter(o=>!o.indegree);return rl(r)}function rl(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&ol(o,i)}}function r(o){return i=>{i.in.push(o),--i.indegree===0&&e.push(i)}}for(;e.length;){let o=e.pop();t.push(o),o.in.reverse().forEach(n(o)),o.out.forEach(r(o))}return t.filter(o=>!o.merged).map(o=>Zt(o,["vs","i","barycenter","weight"]))}function ol(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function il(e,t){let n=su(e,d=>Object.hasOwn(d,"barycenter")),r=n.lhs,o=n.rhs.sort((d,l)=>l.i-d.i),i=[],s=0,a=0,c=0;r.sort(sl(!!t)),c=Gr(i,o,c),r.forEach(d=>{c+=d.vs.length,i.push(d.vs),s+=d.barycenter*d.weight,a+=d.weight,c=Gr(i,o,c)});let u={vs:i.flat(1)};return a&&(u.barycenter=s/a,u.weight=a),u}function Gr(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function sl(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function Pi(e,t,n,r){let o=e.children(t),i=e.node(t),s=i?i.borderLeft:void 0,a=i?i.borderRight:void 0,c={};s&&(o=o.filter(f=>f!==s&&f!==a));let u=tl(e,o);u.forEach(f=>{if(e.children(f.v).length){let h=Pi(e,f.v,n,r);c[f.v]=h,Object.hasOwn(h,"barycenter")&&cl(f,h)}});let d=nl(u,n);al(d,c);let l=il(d,r);if(s&&a){l.vs=[s,l.vs,a].flat(1);let f=e.predecessors(s);if(f&&f.length){let h=e.node(f[0]),g=e.predecessors(a),x=e.node(g[0]);Object.hasOwn(l,"barycenter")||(l.barycenter=0,l.weight=0),l.barycenter=(l.barycenter*l.weight+h.order+x.order)/(l.weight+2),l.weight+=2}}return l}function al(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function cl(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function ul(e,t,n,r){r||(r=e.nodes());let o=ll(e),i=new de({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(s=>e.node(s));return r.forEach(s=>{let a=e.node(s),c=e.parent(s);if(a.rank===t||a.minRank<=t&&t<=a.maxRank){i.setNode(s),i.setParent(s,c||o);let u=e[n](s);u&&u.forEach(d=>{let l=d.v===s?d.w:d.v,f=i.edge(l,s),h=f!==void 0?f.weight:0;i.setEdge(l,s,{weight:e.edge(d).weight+h})}),Object.hasOwn(a,"minRank")&&i.setNode(s,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]})}}),i}function ll(e){let t;for(;e.hasNode(t=cr("_root")););return t}function dl(e,t,n){let r={},o;n.forEach(i=>{let s=e.parent(i),a,c;for(;s;){if(a=e.parent(s),a?(c=r[a],r[a]=s):(c=o,o=s),c&&c!==s){t.setEdge(c,s);return}s=a}})}function Ti(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,Ti);return}let n=bi(e),r=qr(e,yt(1,n+1),"inEdges"),o=qr(e,yt(n-1,-1,-1),"outEdges"),i=Qu(e);if(Ur(e,i),t.disableOptimalOrderHeuristic)return;let s=Number.POSITIVE_INFINITY,a,c=t.constraints||[];for(let u=0,d=0;d<4;++u,++d){fl(u%2?r:o,u%4>=2,c),i=kt(e);let l=Ju(e,i);l<s?(d=0,a=Object.assign({},i),s=l):l===s&&(a=structuredClone(i))}Ur(e,a)}function qr(e,t,n){let r=new Map,o=(i,s)=>{r.has(i)||r.set(i,[]),r.get(i).push(s)};for(let i of e.nodes()){let s=e.node(i);if(typeof s.rank=="number"&&o(s.rank,i),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let a=s.minRank;a<=s.maxRank;a++)a!==s.rank&&o(a,i)}return t.map(function(i){return ul(e,i,n,r.get(i)||[])})}function fl(e,t,n){let r=new de;e.forEach(function(o){n.forEach(a=>r.setEdge(a.left,a.right));let i=o.graph().root,s=Pi(o,i,r,t);s.vs.forEach((a,c)=>o.node(a).order=c),dl(o,r,s.vs)})}function Ur(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}function hl(e,t){let n={};function r(o,i){let s=0,a=0,c=o.length,u=i[i.length-1];return i.forEach((d,l)=>{let f=pl(e,d),h=f?e.node(f).order:c;(f||d===u)&&(i.slice(a,l+1).forEach(g=>{let x=e.predecessors(g);x&&x.forEach(y=>{let p=e.node(y),b=p.order;(b<s||h<b)&&!(p.dummy&&e.node(g).dummy)&&Li(n,y,g)})}),a=l+1,s=h)}),i}return t.length&&t.reduce(r),n}function gl(e,t){let n={};function r(i,s,a,c,u){yt(s,a).forEach(d=>{let l=i[d];if(l!==void 0&&e.node(l).dummy){let f=e.predecessors(l);f&&f.forEach(h=>{if(h===void 0)return;let g=e.node(h);g.dummy&&(g.order<c||g.order>u)&&Li(n,h,l)})}})}function o(i,s){let a=-1,c=-1,u=0;return s.forEach((d,l)=>{if(e.node(d).dummy==="border"){let f=e.predecessors(d);if(f&&f.length){let h=f[0];if(h===void 0)return;c=e.node(h).order,r(s,u,l,a,c),u=l,a=c}}r(s,u,s.length,c,i.length)}),s}return t.length&&t.reduce(o),n}function pl(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function Li(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];r||(e[t]=r={}),r[n]=!0}function ml(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function yl(e,t,n,r){let o={},i={},s={};return t.forEach(a=>{a.forEach((c,u)=>{o[c]=c,i[c]=c,s[c]=u})}),t.forEach(a=>{let c=-1;a.forEach(u=>{let d=r(u);if(d&&d.length){let l=d.sort((h,g)=>{let x=s[h],y=s[g];return(x!==void 0?x:0)-(y!==void 0?y:0)}),f=(l.length-1)/2;for(let h=Math.floor(f),g=Math.ceil(f);h<=g;++h){let x=l[h];if(x===void 0)continue;let y=s[x];if(y!==void 0&&i[u]===u&&c<y&&!ml(n,u,x)){let p=o[x];p!==void 0&&(i[x]=u,i[u]=o[u]=p,c=y)}}}})}),{root:o,align:i}}function xl(e,t,n,r,o=!1){let i={},s=wl(e,t,n,o),a=o?"borderLeft":"borderRight";function c(h,g){let x=s.nodes().slice(),y={},p=x.pop();for(;p;){if(y[p])h(p);else{y[p]=!0,x.push(p);for(let b of g(p))x.push(b)}p=x.pop()}}function u(h){let g=s.inEdges(h);g?i[h]=g.reduce((x,y)=>{var p;let b=(p=i[y.v])!=null?p:0,m=s.edge(y);return Math.max(x,b+(m!==void 0?m:0))},0):i[h]=0}function d(h){let g=s.outEdges(h),x=Number.POSITIVE_INFINITY;g&&(x=g.reduce((p,b)=>{let m=i[b.w],w=s.edge(b);return Math.min(p,(m!==void 0?m:0)-(w!==void 0?w:0))},Number.POSITIVE_INFINITY));let y=e.node(h);x!==Number.POSITIVE_INFINITY&&y.borderType!==a&&(i[h]=Math.max(i[h]!==void 0?i[h]:0,x))}function l(h){return s.predecessors(h)||[]}function f(h){return s.successors(h)||[]}return c(u,l),c(d,f),Object.keys(r).forEach(h=>{var g;let x=n[h];x!==void 0&&(i[h]=(g=i[x])!=null?g:0)}),i}function wl(e,t,n,r){let o=new de,i=e.graph(),s=Nl(i.nodesep,i.edgesep,r);return t.forEach(a=>{let c;a.forEach(u=>{let d=n[u];if(d!==void 0){if(o.setNode(d),c!==void 0){let l=n[c];if(l!==void 0){let f=o.edge(l,d);o.setEdge(l,d,Math.max(s(e,u,c),f||0))}}c=u}})}),o}function vl(e,t){return Object.values(t).reduce((n,r)=>{let o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([a,c])=>{let u=Sl(e,a)/2;o=Math.max(c+u,o),i=Math.min(c-u,i)});let s=o-i;return s<n[0]&&(n=[s,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function bl(e,t){let n=Object.values(t),r=_e(Math.min,n),o=_e(Math.max,n);["u","d"].forEach(i=>{["l","r"].forEach(s=>{let a=i+s,c=e[a];if(!c||c===t)return;let u=Object.values(c),d=r-_e(Math.min,u);s!=="l"&&(d=o-_e(Math.max,u)),d&&(e[a]=ln(c,l=>l+d))})})}function _l(e,t=void 0){let n=e.ul;return n?ln(n,(r,o)=>{var i,s;if(t){let c=t.toLowerCase(),u=e[c];if(u&&u[o]!==void 0)return u[o]}let a=Object.values(e).map(c=>{let u=c[o];return u!==void 0?u:0}).sort((c,u)=>c-u);return(((i=a[1])!=null?i:0)+((s=a[2])!=null?s:0))/2}):{}}function El(e){let t=kt(e),n=Object.assign(hl(e,t),gl(e,t)),r={},o;["u","d"].forEach(s=>{o=s==="u"?t:Object.values(t).reverse(),["l","r"].forEach(a=>{a==="r"&&(o=o.map(d=>Object.values(d).reverse()));let c=yl(e,o,n,d=>(s==="u"?e.predecessors(d):e.successors(d))||[]),u=xl(e,o,c.root,c.align,a==="r");a==="r"&&(u=ln(u,d=>-d)),r[s+a]=u})});let i=vl(e,r);return bl(r,i),_l(r,e.graph().align)}function Nl(e,t,n){return(r,o,i)=>{let s=r.node(o),a=r.node(i),c=0,u;if(c+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":u=-s.width/2;break;case"r":u=s.width/2;break}if(u&&(c+=n?u:-u),u=void 0,c+=(s.dummy?t:e)/2,c+=(a.dummy?t:e)/2,c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":u=a.width/2;break;case"r":u=-a.width/2;break}return u&&(c+=n?u:-u),c}}function Sl(e,t){return e.node(t).width}function Ml(e){e=wi(e),kl(e),Object.entries(El(e)).forEach(([t,n])=>e.node(t).x=n)}function kl(e){let t=kt(e),n=e.graph(),r=n.ranksep,o=n.rankalign,i=0;t.forEach(s=>{let a=s.reduce((c,u)=>{var d;let l=(d=e.node(u).height)!=null?d:0;return c>l?c:l},0);s.forEach(c=>{let u=e.node(c);o==="top"?u.y=i+u.height/2:o==="bottom"?u.y=i+a-u.height/2:u.y=i+a/2}),i+=a+r})}function Cl(e,t={}){let n=t.debugTiming?_i:Ei;return n("layout",()=>{let r=n(" buildLayoutGraph",()=>zl(e));return n(" runLayout",()=>Il(r,n,t)),n(" updateInputGraph",()=>Al(e,r)),r})}function Il(e,t,n){t(" makeSpaceForEdgeLabels",()=>jl(e)),t(" removeSelfEdges",()=>ql(e)),t(" acyclic",()=>xu(e)),t(" nestingGraph.run",()=>Bu(e)),t(" rank",()=>Lu(wi(e))),t(" injectEdgeLabelProxies",()=>Hl(e)),t(" removeEmptyRanks",()=>ou(e)),t(" nestingGraph.cleanup",()=>Xu(e)),t(" normalizeRanks",()=>ru(e)),t(" assignRankMinMax",()=>Vl(e)),t(" removeEdgeLabelProxies",()=>Bl(e)),t(" normalize.run",()=>bu(e)),t(" parentDummyChains",()=>zu(e)),t(" addBorderSegments",()=>Wu(e)),t(" order",()=>Ti(e,n)),t(" insertSelfEdges",()=>Ul(e)),t(" adjustCoordinateSystem",()=>qu(e)),t(" position",()=>Ml(e)),t(" positionSelfEdges",()=>Kl(e)),t(" removeBorderNodes",()=>Gl(e)),t(" normalize.undo",()=>Eu(e)),t(" fixupEdgeLabelCoords",()=>Xl(e)),t(" undoCoordinateSystem",()=>Uu(e)),t(" translateGraph",()=>Fl(e)),t(" assignNodeIntersects",()=>Yl(e)),t(" reversePoints",()=>Wl(e)),t(" acyclic.undo",()=>vu(e))}function Al(e,t){e.nodes().forEach(n=>{let r=e.node(n),o=t.node(n);r&&(r.x=o.x,r.y=o.y,r.order=o.order,r.rank=o.rank,t.children(n).length&&(r.width=o.width,r.height=o.height))}),e.edges().forEach(n=>{let r=e.edge(n),o=t.edge(n);r.points=o.points,Object.hasOwn(o,"x")&&(r.x=o.x,r.y=o.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var $l=["nodesep","edgesep","ranksep","marginx","marginy"],Pl={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},Tl=["acyclicer","ranker","rankdir","align","rankalign"],Ll=["width","height","rank"],Kr={width:0,height:0},Dl=["minlen","weight","width","height","labeloffset"],Ol={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Rl=["labelpos"];function zl(e){let t=new de({multigraph:!0,compound:!0}),n=$n(e.graph());return t.setGraph(Object.assign({},Pl,An(n,$l),Zt(n,Tl))),e.nodes().forEach(r=>{let o=$n(e.node(r)),i=An(o,Ll);Object.keys(Kr).forEach(a=>{i[a]===void 0&&(i[a]=Kr[a])}),t.setNode(r,i);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let o=$n(e.edge(r));t.setEdge(r,Object.assign({},Ol,An(o,Dl),Zt(o,Rl)))}),t}function jl(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Hl(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),o={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};ct(e,"edge-proxy",o,"_ep")}})}function Vl(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Bl(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function Fl(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,o=0,i=e.graph(),s=i.marginx||0,a=i.marginy||0;function c(u){let d=u.x,l=u.y,f=u.width,h=u.height;t=Math.min(t,d-f/2),n=Math.max(n,d+f/2),r=Math.min(r,l-h/2),o=Math.max(o,l+h/2)}e.nodes().forEach(u=>c(e.node(u))),e.edges().forEach(u=>{let d=e.edge(u);Object.hasOwn(d,"x")&&c(d)}),t-=s,r-=a,e.nodes().forEach(u=>{let d=e.node(u);d.x-=t,d.y-=r}),e.edges().forEach(u=>{let d=e.edge(u);d.points.forEach(l=>{l.x-=t,l.y-=r}),Object.hasOwn(d,"x")&&(d.x-=t),Object.hasOwn(d,"y")&&(d.y-=r)}),i.width=n-t+s,i.height=o-r+a}function Yl(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),o=e.node(t.w),i,s;n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=o,s=r),n.points.unshift(Hr(r,i)),n.points.push(Hr(o,s))})}function Xl(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function Wl(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Gl(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),o=e.node(n.borderBottom),i=e.node(n.borderLeft[n.borderLeft.length-1]),s=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(s.x-i.x),n.height=Math.abs(o.y-r.y),n.x=i.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function ql(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Ul(e){kt(e).forEach(t=>{let n=0;t.forEach((r,o)=>{let i=e.node(r);i.order=o+n,(i.selfEdges||[]).forEach(s=>{ct(e,"selfedge",{width:s.label.width,height:s.label.height,rank:i.rank,order:o+ ++n,e:s.e,label:s.label},"_se")}),delete i.selfEdges})})}function Kl(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="selfedge"){let r=n,o=e.node(r.e.v),i=o.x+o.width/2,s=o.y,a=n.x-i,c=o.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:i+2*a/3,y:s-c},{x:i+5*a/6,y:s-c},{x:i+a,y:s},{x:i+5*a/6,y:s+c},{x:i+2*a/3,y:s+c}],r.label.x=n.x,r.label.y=n.y}})}function An(e,t){return ln(Zt(e,t),Number)}function $n(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function Zl(e){let t=kt(e),n=new de({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>n.setEdge(r.v,r.w,{},r.name)),t.forEach((r,o)=>{let i="layer"+o;n.setNode(i,{rank:"same"}),r.reduce((s,a)=>(n.setEdge(s,a,{style:"invis"}),a))}),n}var Ql={graphlib:li,version:uu,layout:Cl,debug:Zl,util:{time:_i,notime:Ei}},Zr=Ql;/*! For license information please see dagre.esm.js.LEGAL.txt */function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=se(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Jl={value:()=>{}};function fn(){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 Yt(n)}function Yt(e){this._=e}function ed(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Yt.prototype=fn.prototype={constructor:Yt,on:function(e,t){var n=this._,r=ed(e+"",n),o,i=-1,s=r.length;if(arguments.length<2){for(;++i<s;)if((o=(e=r[i]).type)&&(o=td(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(o=(e=r[i]).type)n[o]=Qr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=Qr(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Yt(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,i;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,i=r.length;o<i;++o)r[o].value.apply(t,n)}};function td(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function Qr(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=Jl,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Wn="http://www.w3.org/1999/xhtml";const Jr={svg:"http://www.w3.org/2000/svg",xhtml:Wn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function hn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Jr.hasOwnProperty(t)?{space:Jr[t],local:e}:e}function nd(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Wn&&t.documentElement.namespaceURI===Wn?t.createElement(e):t.createElementNS(n,e)}}function rd(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Di(e){var t=hn(e);return(t.local?rd:nd)(t)}function od(){}function fr(e){return e==null?od:function(){return this.querySelector(e)}}function id(e){typeof e!="function"&&(e=fr(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=new Array(s),c,u,d=0;d<s;++d)(c=i[d])&&(u=e.call(c,c.__data__,d,i))&&("__data__"in c&&(u.__data__=c.__data__),a[d]=u);return new ue(r,this._parents)}function sd(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ad(){return[]}function Oi(e){return e==null?ad:function(){return this.querySelectorAll(e)}}function cd(e){return function(){return sd(e.apply(this,arguments))}}function ud(e){typeof e=="function"?e=cd(e):e=Oi(e);for(var t=this._groups,n=t.length,r=[],o=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,u=0;u<a;++u)(c=s[u])&&(r.push(e.call(c,c.__data__,u,s)),o.push(c));return new ue(r,o)}function Ri(e){return function(){return this.matches(e)}}function zi(e){return function(t){return t.matches(e)}}var ld=Array.prototype.find;function dd(e){return function(){return ld.call(this.children,e)}}function fd(){return this.firstElementChild}function hd(e){return this.select(e==null?fd:dd(typeof e=="function"?e:zi(e)))}var gd=Array.prototype.filter;function pd(){return Array.from(this.children)}function md(e){return function(){return gd.call(this.children,e)}}function yd(e){return this.selectAll(e==null?pd:md(typeof e=="function"?e:zi(e)))}function xd(e){typeof e!="function"&&(e=Ri(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,u=0;u<s;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&a.push(c);return new ue(r,this._parents)}function ji(e){return new Array(e.length)}function wd(){return new ue(this._enter||this._groups.map(ji),this._parents)}function Qt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Qt.prototype={constructor:Qt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function vd(e){return function(){return e}}function bd(e,t,n,r,o,i){for(var s=0,a,c=t.length,u=i.length;s<u;++s)(a=t[s])?(a.__data__=i[s],r[s]=a):n[s]=new Qt(e,i[s]);for(;s<c;++s)(a=t[s])&&(o[s]=a)}function _d(e,t,n,r,o,i,s){var a,c,u=new Map,d=t.length,l=i.length,f=new Array(d),h;for(a=0;a<d;++a)(c=t[a])&&(f[a]=h=s.call(c,c.__data__,a,t)+"",u.has(h)?o[a]=c:u.set(h,c));for(a=0;a<l;++a)h=s.call(e,i[a],a,i)+"",(c=u.get(h))?(r[a]=c,c.__data__=i[a],u.delete(h)):n[a]=new Qt(e,i[a]);for(a=0;a<d;++a)(c=t[a])&&u.get(f[a])===c&&(o[a]=c)}function Ed(e){return e.__data__}function Nd(e,t){if(!arguments.length)return Array.from(this,Ed);var n=t?_d:bd,r=this._parents,o=this._groups;typeof e!="function"&&(e=vd(e));for(var i=o.length,s=new Array(i),a=new Array(i),c=new Array(i),u=0;u<i;++u){var d=r[u],l=o[u],f=l.length,h=Sd(e.call(d,d&&d.__data__,u,r)),g=h.length,x=a[u]=new Array(g),y=s[u]=new Array(g),p=c[u]=new Array(f);n(d,l,x,y,p,h,t);for(var b=0,m=0,w,N;b<g;++b)if(w=x[b]){for(b>=m&&(m=b+1);!(N=y[m])&&++m<g;);w._next=N||null}}return s=new ue(s,r),s._enter=a,s._exit=c,s}function Sd(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Md(){return new ue(this._exit||this._groups.map(ji),this._parents)}function kd(e,t,n){var r=this.enter(),o=this,i=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),r&&o?r.merge(o).order():o}function Cd(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,i=r.length,s=Math.min(o,i),a=new Array(o),c=0;c<s;++c)for(var u=n[c],d=r[c],l=u.length,f=a[c]=new Array(l),h,g=0;g<l;++g)(h=u[g]||d[g])&&(f[g]=h);for(;c<o;++c)a[c]=n[c];return new ue(a,this._parents)}function Id(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,i=r[o],s;--o>=0;)(s=r[o])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Ad(e){e||(e=$d);function t(l,f){return l&&f?e(l.__data__,f.__data__):!l-!f}for(var n=this._groups,r=n.length,o=new Array(r),i=0;i<r;++i){for(var s=n[i],a=s.length,c=o[i]=new Array(a),u,d=0;d<a;++d)(u=s[d])&&(c[d]=u);c.sort(t)}return new ue(o,this._parents).order()}function $d(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Pd(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Td(){return Array.from(this)}function Ld(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length;o<i;++o){var s=r[o];if(s)return s}return null}function Dd(){let e=0;for(const t of this)++e;return e}function Od(){return!this.node()}function Rd(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],i=0,s=o.length,a;i<s;++i)(a=o[i])&&e.call(a,a.__data__,i,o);return this}function zd(e){return function(){this.removeAttribute(e)}}function jd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Hd(e,t){return function(){this.setAttribute(e,t)}}function Vd(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Bd(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Fd(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 Yd(e,t){var n=hn(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?jd:zd:typeof t=="function"?n.local?Fd:Bd:n.local?Vd:Hd)(n,t))}function Hi(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Xd(e){return function(){this.style.removeProperty(e)}}function Wd(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Gd(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function qd(e,t,n){return arguments.length>1?this.each((t==null?Xd:typeof t=="function"?Gd:Wd)(e,t,n??"")):tt(this.node(),e)}function tt(e,t){return e.style.getPropertyValue(t)||Hi(e).getComputedStyle(e,null).getPropertyValue(t)}function Ud(e){return function(){delete this[e]}}function Kd(e,t){return function(){this[e]=t}}function Zd(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Qd(e,t){return arguments.length>1?this.each((t==null?Ud:typeof t=="function"?Zd:Kd)(e,t)):this.node()[e]}function Vi(e){return e.trim().split(/^|\s+/)}function hr(e){return e.classList||new Bi(e)}function Bi(e){this._node=e,this._names=Vi(e.getAttribute("class")||"")}Bi.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 Fi(e,t){for(var n=hr(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Yi(e,t){for(var n=hr(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function Jd(e){return function(){Fi(this,e)}}function ef(e){return function(){Yi(this,e)}}function tf(e,t){return function(){(t.apply(this,arguments)?Fi:Yi)(this,e)}}function nf(e,t){var n=Vi(e+"");if(arguments.length<2){for(var r=hr(this.node()),o=-1,i=n.length;++o<i;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?tf:t?Jd:ef)(n,t))}function rf(){this.textContent=""}function of(e){return function(){this.textContent=e}}function sf(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function af(e){return arguments.length?this.each(e==null?rf:(typeof e=="function"?sf:of)(e)):this.node().textContent}function cf(){this.innerHTML=""}function uf(e){return function(){this.innerHTML=e}}function lf(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function df(e){return arguments.length?this.each(e==null?cf:(typeof e=="function"?lf:uf)(e)):this.node().innerHTML}function ff(){this.nextSibling&&this.parentNode.appendChild(this)}function hf(){return this.each(ff)}function gf(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function pf(){return this.each(gf)}function mf(e){var t=typeof e=="function"?e:Di(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function yf(){return null}function xf(e,t){var n=typeof e=="function"?e:Di(e),r=t==null?yf:typeof t=="function"?t:fr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function wf(){var e=this.parentNode;e&&e.removeChild(this)}function vf(){return this.each(wf)}function bf(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function _f(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ef(e){return this.select(e?_f:bf)}function Nf(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Sf(e){return function(t){e.call(this,t,this.__data__)}}function Mf(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 kf(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,i;n<o;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function Cf(e,t,n){return function(){var r=this.__on,o,i=Sf(t);if(r){for(var s=0,a=r.length;s<a;++s)if((o=r[s]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(o):this.__on=[o]}}function If(e,t,n){var r=Mf(e+""),o,i=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,u=a.length,d;c<u;++c)for(o=0,d=a[c];o<i;++o)if((s=r[o]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?Cf:kf,o=0;o<i;++o)this.each(a(r[o],t,n));return this}function Xi(e,t,n){var r=Hi(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function Af(e,t){return function(){return Xi(this,e,t)}}function $f(e,t){return function(){return Xi(this,e,t.apply(this,arguments))}}function Pf(e,t){return this.each((typeof t=="function"?$f:Af)(e,t))}function*Tf(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,i=r.length,s;o<i;++o)(s=r[o])&&(yield s)}var Wi=[null];function ue(e,t){this._groups=e,this._parents=t}function Ct(){return new ue([[document.documentElement]],Wi)}function Lf(){return this}ue.prototype=Ct.prototype={constructor:ue,select:id,selectAll:ud,selectChild:hd,selectChildren:yd,filter:xd,data:Nd,enter:wd,exit:Md,join:kd,merge:Cd,selection:Lf,order:Id,sort:Ad,call:Pd,nodes:Td,node:Ld,size:Dd,empty:Od,each:Rd,attr:Yd,style:qd,property:Qd,classed:nf,text:af,html:df,raise:hf,lower:pf,append:mf,insert:xf,remove:vf,clone:Ef,datum:Nf,on:If,dispatch:Pf,[Symbol.iterator]:Tf};function ce(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],Wi)}function Df(e){let t;for(;t=e.sourceEvent;)e=t;return e}function he(e,t){if(e=Df(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const Of={passive:!1},xt={capture:!0,passive:!1};function Pn(e){e.stopImmediatePropagation()}function Qe(e){e.preventDefault(),e.stopImmediatePropagation()}function Gi(e){var t=e.document.documentElement,n=ce(e).on("dragstart.drag",Qe,xt);"onselectstart"in t?n.on("selectstart.drag",Qe,xt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function qi(e,t){var n=e.document.documentElement,r=ce(e).on("dragstart.drag",null);t&&(r.on("click.drag",Qe,xt),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 Dt=e=>()=>e;function Gn(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:i,x:s,y:a,dx:c,dy:u,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:d}})}Gn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Rf(e){return!e.ctrlKey&&!e.button}function zf(){return this.parentNode}function jf(e,t){return t??{x:e.x,y:e.y}}function Hf(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ui(){var e=Rf,t=zf,n=jf,r=Hf,o={},i=fn("start","drag","end"),s=0,a,c,u,d,l=0;function f(w){w.on("mousedown.drag",h).filter(r).on("touchstart.drag",y).on("touchmove.drag",p,Of).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,N){if(!(d||!e.call(this,w,N))){var _=m(this,t.call(this,w,N),w,N,"mouse");_&&(ce(w.view).on("mousemove.drag",g,xt).on("mouseup.drag",x,xt),Gi(w.view),Pn(w),u=!1,a=w.clientX,c=w.clientY,_("start",w))}}function g(w){if(Qe(w),!u){var N=w.clientX-a,_=w.clientY-c;u=N*N+_*_>l}o.mouse("drag",w)}function x(w){ce(w.view).on("mousemove.drag mouseup.drag",null),qi(w.view,u),Qe(w),o.mouse("end",w)}function y(w,N){if(e.call(this,w,N)){var _=w.changedTouches,k=t.call(this,w,N),$=_.length,P,V;for(P=0;P<$;++P)(V=m(this,k,w,N,_[P].identifier,_[P]))&&(Pn(w),V("start",w,_[P]))}}function p(w){var N=w.changedTouches,_=N.length,k,$;for(k=0;k<_;++k)($=o[N[k].identifier])&&(Qe(w),$("drag",w,N[k]))}function b(w){var N=w.changedTouches,_=N.length,k,$;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),k=0;k<_;++k)($=o[N[k].identifier])&&(Pn(w),$("end",w,N[k]))}function m(w,N,_,k,$,P){var V=i.copy(),S=he(P||_,N),T,H,v;if((v=n.call(w,new Gn("beforestart",{sourceEvent:_,target:f,identifier:$,active:s,x:S[0],y:S[1],dx:0,dy:0,dispatch:V}),k))!=null)return T=v.x-S[0]||0,H=v.y-S[1]||0,function I(E,A,L){var C=S,z;switch(E){case"start":o[$]=I,z=s++;break;case"end":delete o[$],--s;case"drag":S=he(L||A,N),z=s;break}V.call(E,w,new Gn(E,{sourceEvent:A,subject:v,target:f,identifier:$,active:z,x:S[0]+T,y:S[1]+H,dx:S[0]-C[0],dy:S[1]-C[1],dispatch:V}),k)}}return f.filter=function(w){return arguments.length?(e=typeof w=="function"?w:Dt(!!w),f):e},f.container=function(w){return arguments.length?(t=typeof w=="function"?w:Dt(w),f):t},f.subject=function(w){return arguments.length?(n=typeof w=="function"?w:Dt(w),f):n},f.touchable=function(w){return arguments.length?(r=typeof w=="function"?w:Dt(!!w),f):r},f.on=function(){var w=i.on.apply(i,arguments);return w===i?f:w},f.clickDistance=function(w){return arguments.length?(l=(w=+w)*w,f):Math.sqrt(l)},f}function gr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ki(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function It(){}var wt=.7,Jt=1/wt,Je="\\s*([+-]?\\d+)\\s*",vt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ee="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Vf=/^#([0-9a-f]{3,8})$/,Bf=new RegExp(`^rgb\\(${Je},${Je},${Je}\\)$`),Ff=new RegExp(`^rgb\\(${Ee},${Ee},${Ee}\\)$`),Yf=new RegExp(`^rgba\\(${Je},${Je},${Je},${vt}\\)$`),Xf=new RegExp(`^rgba\\(${Ee},${Ee},${Ee},${vt}\\)$`),Wf=new RegExp(`^hsl\\(${vt},${Ee},${Ee}\\)$`),Gf=new RegExp(`^hsla\\(${vt},${Ee},${Ee},${vt}\\)$`),eo={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};gr(It,Fe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:to,formatHex:to,formatHex8:qf,formatHsl:Uf,formatRgb:no,toString:no});function to(){return this.rgb().formatHex()}function qf(){return this.rgb().formatHex8()}function Uf(){return Zi(this).formatHsl()}function no(){return this.rgb().formatRgb()}function Fe(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Vf.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ro(t):n===3?new ae(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Ot(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Ot(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=Bf.exec(e))?new ae(t[1],t[2],t[3],1):(t=Ff.exec(e))?new ae(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Yf.exec(e))?Ot(t[1],t[2],t[3],t[4]):(t=Xf.exec(e))?Ot(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Wf.exec(e))?so(t[1],t[2]/100,t[3]/100,1):(t=Gf.exec(e))?so(t[1],t[2]/100,t[3]/100,t[4]):eo.hasOwnProperty(e)?ro(eo[e]):e==="transparent"?new ae(NaN,NaN,NaN,0):null}function ro(e){return new ae(e>>16&255,e>>8&255,e&255,1)}function Ot(e,t,n,r){return r<=0&&(e=t=n=NaN),new ae(e,t,n,r)}function Kf(e){return e instanceof It||(e=Fe(e)),e?(e=e.rgb(),new ae(e.r,e.g,e.b,e.opacity)):new ae}function qn(e,t,n,r){return arguments.length===1?Kf(e):new ae(e,t,n,r??1)}function ae(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}gr(ae,qn,Ki(It,{brighter(e){return e=e==null?Jt:Math.pow(Jt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?wt:Math.pow(wt,e),new ae(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ae(Ve(this.r),Ve(this.g),Ve(this.b),en(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:oo,formatHex:oo,formatHex8:Zf,formatRgb:io,toString:io}));function oo(){return`#${He(this.r)}${He(this.g)}${He(this.b)}`}function Zf(){return`#${He(this.r)}${He(this.g)}${He(this.b)}${He((isNaN(this.opacity)?1:this.opacity)*255)}`}function io(){const e=en(this.opacity);return`${e===1?"rgb(":"rgba("}${Ve(this.r)}, ${Ve(this.g)}, ${Ve(this.b)}${e===1?")":`, ${e})`}`}function en(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ve(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function He(e){return e=Ve(e),(e<16?"0":"")+e.toString(16)}function so(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ge(e,t,n,r)}function Zi(e){if(e instanceof ge)return new ge(e.h,e.s,e.l,e.opacity);if(e instanceof It||(e=Fe(e)),!e)return new ge;if(e instanceof ge)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),i=Math.max(t,n,r),s=NaN,a=i-o,c=(i+o)/2;return a?(t===i?s=(n-r)/a+(n<r)*6:n===i?s=(r-t)/a+2:s=(t-n)/a+4,a/=c<.5?i+o:2-i-o,s*=60):a=c>0&&c<1?0:s,new ge(s,a,c,e.opacity)}function Qf(e,t,n,r){return arguments.length===1?Zi(e):new ge(e,t,n,r??1)}function ge(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}gr(ge,Qf,Ki(It,{brighter(e){return e=e==null?Jt:Math.pow(Jt,e),new ge(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?wt:Math.pow(wt,e),new ge(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new ae(Tn(e>=240?e-240:e+120,o,r),Tn(e,o,r),Tn(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new ge(ao(this.h),Rt(this.s),Rt(this.l),en(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=en(this.opacity);return`${e===1?"hsl(":"hsla("}${ao(this.h)}, ${Rt(this.s)*100}%, ${Rt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ao(e){return e=(e||0)%360,e<0?e+360:e}function Rt(e){return Math.max(0,Math.min(1,e||0))}function Tn(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 pr=e=>()=>e;function Jf(e,t){return function(n){return e+n*t}}function eh(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 th(e){return(e=+e)==1?Qi:function(t,n){return n-t?eh(t,n,e):pr(isNaN(t)?n:t)}}function Qi(e,t){var n=t-e;return n?Jf(e,n):pr(isNaN(e)?t:e)}const tn=(function e(t){var n=th(t);function r(o,i){var s=n((o=qn(o)).r,(i=qn(i)).r),a=n(o.g,i.g),c=n(o.b,i.b),u=Qi(o.opacity,i.opacity);return function(d){return o.r=s(d),o.g=a(d),o.b=c(d),o.opacity=u(d),o+""}}return r.gamma=e,r})(1);function nh(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(i){for(o=0;o<n;++o)r[o]=e[o]*(1-i)+t[o]*i;return r}}function rh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function oh(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),i=new Array(n),s;for(s=0;s<r;++s)o[s]=pt(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<r;++s)i[s]=o[s](a);return i}}function ih(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function be(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function sh(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=pt(e[o],t[o]):r[o]=t[o];return function(i){for(o in n)r[o]=n[o](i);return r}}var Un=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ln=new RegExp(Un.source,"g");function ah(e){return function(){return e}}function ch(e){return function(t){return e(t)+""}}function Ji(e,t){var n=Un.lastIndex=Ln.lastIndex=0,r,o,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(r=Un.exec(e))&&(o=Ln.exec(t));)(i=o.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(r=r[0])===(o=o[0])?a[s]?a[s]+=o:a[++s]=o:(a[++s]=null,c.push({i:s,x:be(r,o)})),n=Ln.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?ch(c[0].x):ah(t):(t=c.length,function(u){for(var d=0,l;d<t;++d)a[(l=c[d]).i]=l.x(u);return a.join("")})}function pt(e,t){var n=typeof t,r;return t==null||n==="boolean"?pr(t):(n==="number"?be:n==="string"?(r=Fe(t))?(t=r,tn):Ji:t instanceof Fe?tn:t instanceof Date?ih:rh(t)?nh:Array.isArray(t)?oh:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?sh:be)(e,t)}var co=180/Math.PI,Kn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function es(e,t,n,r,o,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*co,skewX:Math.atan(c)*co,scaleX:s,scaleY:a}}var zt;function uh(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Kn:es(t.a,t.b,t.c,t.d,t.e,t.f)}function lh(e){return e==null||(zt||(zt=document.createElementNS("http://www.w3.org/2000/svg","g")),zt.setAttribute("transform",e),!(e=zt.transform.baseVal.consolidate()))?Kn:(e=e.matrix,es(e.a,e.b,e.c,e.d,e.e,e.f))}function ts(e,t,n,r){function o(u){return u.length?u.pop()+" ":""}function i(u,d,l,f,h,g){if(u!==l||d!==f){var x=h.push("translate(",null,t,null,n);g.push({i:x-4,x:be(u,l)},{i:x-2,x:be(d,f)})}else(l||f)&&h.push("translate("+l+t+f+n)}function s(u,d,l,f){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),f.push({i:l.push(o(l)+"rotate(",null,r)-2,x:be(u,d)})):d&&l.push(o(l)+"rotate("+d+r)}function a(u,d,l,f){u!==d?f.push({i:l.push(o(l)+"skewX(",null,r)-2,x:be(u,d)}):d&&l.push(o(l)+"skewX("+d+r)}function c(u,d,l,f,h,g){if(u!==l||d!==f){var x=h.push(o(h)+"scale(",null,",",null,")");g.push({i:x-4,x:be(u,l)},{i:x-2,x:be(d,f)})}else(l!==1||f!==1)&&h.push(o(h)+"scale("+l+","+f+")")}return function(u,d){var l=[],f=[];return u=e(u),d=e(d),i(u.translateX,u.translateY,d.translateX,d.translateY,l,f),s(u.rotate,d.rotate,l,f),a(u.skewX,d.skewX,l,f),c(u.scaleX,u.scaleY,d.scaleX,d.scaleY,l,f),u=d=null,function(h){for(var g=-1,x=f.length,y;++g<x;)l[(y=f[g]).i]=y.x(h);return l.join("")}}}var dh=ts(uh,"px, ","px)","deg)"),fh=ts(lh,", ",")",")"),hh=1e-12;function uo(e){return((e=Math.exp(e))+1/e)/2}function gh(e){return((e=Math.exp(e))-1/e)/2}function ph(e){return((e=Math.exp(2*e))-1)/(e+1)}const Xt=(function e(t,n,r){function o(i,s){var a=i[0],c=i[1],u=i[2],d=s[0],l=s[1],f=s[2],h=d-a,g=l-c,x=h*h+g*g,y,p;if(x<hh)p=Math.log(f/u)/t,y=function(k){return[a+k*h,c+k*g,u*Math.exp(t*k*p)]};else{var b=Math.sqrt(x),m=(f*f-u*u+r*x)/(2*u*n*b),w=(f*f-u*u-r*x)/(2*f*n*b),N=Math.log(Math.sqrt(m*m+1)-m),_=Math.log(Math.sqrt(w*w+1)-w);p=(_-N)/t,y=function(k){var $=k*p,P=uo(N),V=u/(n*b)*(P*ph(t*$+N)-gh(N));return[a+V*h,c+V*g,u*P/uo(t*$+N)]}}return y.duration=p*1e3*t/Math.SQRT2,y}return o.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},o})(Math.SQRT2,2,4);var nt=0,ht=0,lt=0,ns=1e3,nn,gt,rn=0,Ye=0,gn=0,bt=typeof performance=="object"&&performance.now?performance:Date,rs=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function mr(){return Ye||(rs(mh),Ye=bt.now()+gn)}function mh(){Ye=0}function on(){this._call=this._time=this._next=null}on.prototype=os.prototype={constructor:on,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?mr():+n)+(t==null?0:+t),!this._next&>!==this&&(gt?gt._next=this:nn=this,gt=this),this._call=e,this._time=n,Zn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Zn())}};function os(e,t,n){var r=new on;return r.restart(e,t,n),r}function yh(){mr(),++nt;for(var e=nn,t;e;)(t=Ye-e._time)>=0&&e._call.call(void 0,t),e=e._next;--nt}function lo(){Ye=(rn=bt.now())+gn,nt=ht=0;try{yh()}finally{nt=0,wh(),Ye=0}}function xh(){var e=bt.now(),t=e-rn;t>ns&&(gn-=t,rn=e)}function wh(){for(var e,t=nn,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:nn=n);gt=e,Zn(r)}function Zn(e){if(!nt){ht&&(ht=clearTimeout(ht));var t=e-Ye;t>24?(e<1/0&&(ht=setTimeout(lo,e-bt.now()-gn)),lt&&(lt=clearInterval(lt))):(lt||(rn=bt.now(),lt=setInterval(xh,ns)),nt=1,rs(lo))}}function fo(e,t,n){var r=new on;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var vh=fn("start","end","cancel","interrupt"),bh=[],is=0,ho=1,Qn=2,Wt=3,go=4,Jn=5,Gt=6;function pn(e,t,n,r,o,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;_h(e,n,{name:t,index:r,group:o,on:vh,tween:bh,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:is})}function yr(e,t){var n=xe(e,t);if(n.state>is)throw new Error("too late; already scheduled");return n}function Ne(e,t){var n=xe(e,t);if(n.state>Wt)throw new Error("too late; already running");return n}function xe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function _h(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=os(i,0,n.time);function i(u){n.state=ho,n.timer.restart(s,n.delay,n.time),n.delay<=u&&s(u-n.delay)}function s(u){var d,l,f,h;if(n.state!==ho)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===Wt)return fo(s);h.state===go?(h.state=Gt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=Gt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(fo(function(){n.state===Wt&&(n.state=go,n.timer.restart(a,n.delay,n.time),a(u))}),n.state=Qn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Qn){for(n.state=Wt,o=new Array(f=n.tween.length),d=0,l=-1;d<f;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(o[++l]=h);o.length=l+1}}function a(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=Jn,1),l=-1,f=o.length;++l<f;)o[l].call(e,d);n.state===Jn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Gt,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function qt(e,t){var n=e.__transition,r,o,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){i=!1;continue}o=r.state>Qn&&r.state<Jn,r.state=Gt,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}i&&delete e.__transition}}function Eh(e){return this.each(function(){qt(this,e)})}function Nh(e,t){var n,r;return function(){var o=Ne(this,e),i=o.tween;if(i!==n){r=n=i;for(var s=0,a=r.length;s<a;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}o.tween=r}}function Sh(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var i=Ne(this,e),s=i.tween;if(s!==r){o=(r=s).slice();for(var a={name:t,value:n},c=0,u=o.length;c<u;++c)if(o[c].name===t){o[c]=a;break}c===u&&o.push(a)}i.tween=o}}function Mh(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=xe(this.node(),n).tween,o=0,i=r.length,s;o<i;++o)if((s=r[o]).name===e)return s.value;return null}return this.each((t==null?Nh:Sh)(n,e,t))}function xr(e,t,n){var r=e._id;return e.each(function(){var o=Ne(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return xe(o,r).value[t]}}function ss(e,t){var n;return(typeof t=="number"?be:t instanceof Fe?tn:(n=Fe(t))?(t=n,tn):Ji)(e,t)}function kh(e){return function(){this.removeAttribute(e)}}function Ch(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ih(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttribute(e);return s===o?null:s===r?i:i=t(r=s,n)}}function Ah(e,t,n){var r,o=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===o?null:s===r?i:i=t(r=s,n)}}function $h(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function Ph(e,t,n){var r,o,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a)))}}function Th(e,t){var n=hn(e),r=n==="transform"?fh:ss;return this.attrTween(e,typeof t=="function"?(n.local?Ph:$h)(n,r,xr(this,"attr."+e,t)):t==null?(n.local?Ch:kh)(n):(n.local?Ah:Ih)(n,r,t))}function Lh(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Dh(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Oh(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Dh(e,i)),n}return o._value=t,o}function Rh(e,t){var n,r;function o(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Lh(e,i)),n}return o._value=t,o}function zh(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=hn(e);return this.tween(n,(r.local?Oh:Rh)(r,t))}function jh(e,t){return function(){yr(this,e).delay=+t.apply(this,arguments)}}function Hh(e,t){return t=+t,function(){yr(this,e).delay=t}}function Vh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?jh:Hh)(t,e)):xe(this.node(),t).delay}function Bh(e,t){return function(){Ne(this,e).duration=+t.apply(this,arguments)}}function Fh(e,t){return t=+t,function(){Ne(this,e).duration=t}}function Yh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Bh:Fh)(t,e)):xe(this.node(),t).duration}function Xh(e,t){if(typeof t!="function")throw new Error;return function(){Ne(this,e).ease=t}}function Wh(e){var t=this._id;return arguments.length?this.each(Xh(t,e)):xe(this.node(),t).ease}function Gh(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ne(this,e).ease=n}}function qh(e){if(typeof e!="function")throw new Error;return this.each(Gh(this._id,e))}function Uh(e){typeof e!="function"&&(e=Ri(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var i=t[o],s=i.length,a=r[o]=[],c,u=0;u<s;++u)(c=i[u])&&e.call(c,c.__data__,u,i)&&a.push(c);return new Ae(r,this._parents,this._name,this._id)}function Kh(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,i=Math.min(r,o),s=new Array(r),a=0;a<i;++a)for(var c=t[a],u=n[a],d=c.length,l=s[a]=new Array(d),f,h=0;h<d;++h)(f=c[h]||u[h])&&(l[h]=f);for(;a<r;++a)s[a]=t[a];return new Ae(s,this._parents,this._name,this._id)}function Zh(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 Qh(e,t,n){var r,o,i=Zh(t)?yr:Ne;return function(){var s=i(this,e),a=s.on;a!==r&&(o=(r=a).copy()).on(t,n),s.on=o}}function Jh(e,t){var n=this._id;return arguments.length<2?xe(this.node(),n).on.on(e):this.each(Qh(n,e,t))}function eg(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function tg(){return this.on("end.remove",eg(this._id))}function ng(e){var t=this._name,n=this._id;typeof e!="function"&&(e=fr(e));for(var r=this._groups,o=r.length,i=new Array(o),s=0;s<o;++s)for(var a=r[s],c=a.length,u=i[s]=new Array(c),d,l,f=0;f<c;++f)(d=a[f])&&(l=e.call(d,d.__data__,f,a))&&("__data__"in d&&(l.__data__=d.__data__),u[f]=l,pn(u[f],t,n,f,u,xe(d,n)));return new Ae(i,this._parents,t,n)}function rg(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Oi(e));for(var r=this._groups,o=r.length,i=[],s=[],a=0;a<o;++a)for(var c=r[a],u=c.length,d,l=0;l<u;++l)if(d=c[l]){for(var f=e.call(d,d.__data__,l,c),h,g=xe(d,n),x=0,y=f.length;x<y;++x)(h=f[x])&&pn(h,t,n,x,f,g);i.push(f),s.push(d)}return new Ae(i,s,t,n)}var og=Ct.prototype.constructor;function ig(){return new og(this._groups,this._parents)}function sg(e,t){var n,r,o;return function(){var i=tt(this,e),s=(this.style.removeProperty(e),tt(this,e));return i===s?null:i===n&&s===r?o:o=t(n=i,r=s)}}function as(e){return function(){this.style.removeProperty(e)}}function ag(e,t,n){var r,o=n+"",i;return function(){var s=tt(this,e);return s===o?null:s===r?i:i=t(r=s,n)}}function cg(e,t,n){var r,o,i;return function(){var s=tt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),tt(this,e))),s===c?null:s===r&&c===o?i:(o=c,i=t(r=s,a))}}function ug(e,t){var n,r,o,i="style."+t,s="end."+i,a;return function(){var c=Ne(this,e),u=c.on,d=c.value[i]==null?a||(a=as(t)):void 0;(u!==n||o!==d)&&(r=(n=u).copy()).on(s,o=d),c.on=r}}function lg(e,t,n){var r=(e+="")=="transform"?dh:ss;return t==null?this.styleTween(e,sg(e,r)).on("end.style."+e,as(e)):typeof t=="function"?this.styleTween(e,cg(e,r,xr(this,"style."+e,t))).each(ug(this._id,e)):this.styleTween(e,ag(e,r,t),n).on("end.style."+e,null)}function dg(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function fg(e,t,n){var r,o;function i(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&dg(e,s,n)),r}return i._value=t,i}function hg(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,fg(e,t,n??""))}function gg(e){return function(){this.textContent=e}}function pg(e){return function(){var t=e(this);this.textContent=t??""}}function mg(e){return this.tween("text",typeof e=="function"?pg(xr(this,"text",e)):gg(e==null?"":e+""))}function yg(e){return function(t){this.textContent=e.call(this,t)}}function xg(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&yg(o)),t}return r._value=e,r}function wg(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,xg(e))}function vg(){for(var e=this._name,t=this._id,n=cs(),r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,u=0;u<a;++u)if(c=s[u]){var d=xe(c,t);pn(c,e,n,u,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ae(r,this._parents,e,n)}function bg(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--o===0&&i()}};n.each(function(){var u=Ne(this,r),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),u.on=t}),o===0&&i()})}var _g=0;function Ae(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function cs(){return++_g}var Ce=Ct.prototype;Ae.prototype={constructor:Ae,select:ng,selectAll:rg,selectChild:Ce.selectChild,selectChildren:Ce.selectChildren,filter:Uh,merge:Kh,selection:ig,transition:vg,call:Ce.call,nodes:Ce.nodes,node:Ce.node,size:Ce.size,empty:Ce.empty,each:Ce.each,on:Jh,attr:Th,attrTween:zh,style:lg,styleTween:hg,text:mg,textTween:wg,remove:tg,tween:Mh,delay:Vh,duration:Yh,ease:Wh,easeVarying:qh,end:bg,[Symbol.iterator]:Ce[Symbol.iterator]};function Eg(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Ng={time:null,delay:0,duration:250,ease:Eg};function Sg(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 Mg(e){var t,n;e instanceof Ae?(t=e._id,e=e._name):(t=cs(),(n=Ng).time=mr(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,i=0;i<o;++i)for(var s=r[i],a=s.length,c,u=0;u<a;++u)(c=s[u])&&pn(c,e,t,u,s,n||Sg(c,t));return new Ae(r,this._parents,e,t)}Ct.prototype.interrupt=Eh;Ct.prototype.transition=Mg;const jt=e=>()=>e;function kg(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Ie(e,t,n){this.k=e,this.x=t,this.y=n}Ie.prototype={constructor:Ie,scale:function(e){return e===1?this:new Ie(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ie(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 mn=new Ie(1,0,0);us.prototype=Ie.prototype;function us(e){for(;!e.__zoom;)if(!(e=e.parentNode))return mn;return e.__zoom}function Dn(e){e.stopImmediatePropagation()}function dt(e){e.preventDefault(),e.stopImmediatePropagation()}function Cg(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ig(){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 po(){return this.__zoom||mn}function Ag(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function $g(){return navigator.maxTouchPoints||"ontouchstart"in this}function Pg(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function ls(){var e=Cg,t=Ig,n=Pg,r=Ag,o=$g,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Xt,u=fn("start","zoom","end"),d,l,f,h=500,g=150,x=0,y=10;function p(v){v.property("__zoom",po).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",V).filter(o).on("touchstart.zoom",S).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}p.transform=function(v,I,E,A){var L=v.selection?v.selection():v;L.property("__zoom",po),v!==L?N(v,I,E,A):L.interrupt().each(function(){_(this,arguments).event(A).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},p.scaleBy=function(v,I,E,A){p.scaleTo(v,function(){var L=this.__zoom.k,C=typeof I=="function"?I.apply(this,arguments):I;return L*C},E,A)},p.scaleTo=function(v,I,E,A){p.transform(v,function(){var L=t.apply(this,arguments),C=this.__zoom,z=E==null?w(L):typeof E=="function"?E.apply(this,arguments):E,j=C.invert(z),R=typeof I=="function"?I.apply(this,arguments):I;return n(m(b(C,R),z,j),L,s)},E,A)},p.translateBy=function(v,I,E,A){p.transform(v,function(){return n(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof E=="function"?E.apply(this,arguments):E),t.apply(this,arguments),s)},null,A)},p.translateTo=function(v,I,E,A,L){p.transform(v,function(){var C=t.apply(this,arguments),z=this.__zoom,j=A==null?w(C):typeof A=="function"?A.apply(this,arguments):A;return n(mn.translate(j[0],j[1]).scale(z.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof E=="function"?-E.apply(this,arguments):-E),C,s)},A,L)};function b(v,I){return I=Math.max(i[0],Math.min(i[1],I)),I===v.k?v:new Ie(I,v.x,v.y)}function m(v,I,E){var A=I[0]-E[0]*v.k,L=I[1]-E[1]*v.k;return A===v.x&&L===v.y?v:new Ie(v.k,A,L)}function w(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function N(v,I,E,A){v.on("start.zoom",function(){_(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(A).end()}).tween("zoom",function(){var L=this,C=arguments,z=_(L,C).event(A),j=t.apply(L,C),R=E==null?w(j):typeof E=="function"?E.apply(L,C):E,F=Math.max(j[1][0]-j[0][0],j[1][1]-j[0][1]),Y=L.__zoom,U=typeof I=="function"?I.apply(L,C):I,Q=c(Y.invert(R).concat(F/Y.k),U.invert(R).concat(F/U.k));return function(q){if(q===1)q=U;else{var O=Q(q),B=F/O[2];q=new Ie(B,R[0]-O[0]*B,R[1]-O[1]*B)}z.zoom(null,q)}})}function _(v,I,E){return!E&&v.__zooming||new k(v,I)}function k(v,I){this.that=v,this.args=I,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,I),this.taps=0}k.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,I){return this.mouse&&v!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&v!=="touch"&&(this.touch1[1]=I.invert(this.touch1[0])),this.that.__zoom=I,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(v){var I=ce(this.that).datum();u.call(v,this.that,new kg(v,{sourceEvent:this.sourceEvent,target:p,transform:this.that.__zoom,dispatch:u}),I)}};function $(v,...I){if(!e.apply(this,arguments))return;var E=_(this,I).event(v),A=this.__zoom,L=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,r.apply(this,arguments)))),C=he(v);if(E.wheel)(E.mouse[0][0]!==C[0]||E.mouse[0][1]!==C[1])&&(E.mouse[1]=A.invert(E.mouse[0]=C)),clearTimeout(E.wheel);else{if(A.k===L)return;E.mouse=[C,A.invert(C)],qt(this),E.start()}dt(v),E.wheel=setTimeout(z,g),E.zoom("mouse",n(m(b(A,L),E.mouse[0],E.mouse[1]),E.extent,s));function z(){E.wheel=null,E.end()}}function P(v,...I){if(f||!e.apply(this,arguments))return;var E=v.currentTarget,A=_(this,I,!0).event(v),L=ce(v.view).on("mousemove.zoom",R,!0).on("mouseup.zoom",F,!0),C=he(v,E),z=v.clientX,j=v.clientY;Gi(v.view),Dn(v),A.mouse=[C,this.__zoom.invert(C)],qt(this),A.start();function R(Y){if(dt(Y),!A.moved){var U=Y.clientX-z,Q=Y.clientY-j;A.moved=U*U+Q*Q>x}A.event(Y).zoom("mouse",n(m(A.that.__zoom,A.mouse[0]=he(Y,E),A.mouse[1]),A.extent,s))}function F(Y){L.on("mousemove.zoom mouseup.zoom",null),qi(Y.view,A.moved),dt(Y),A.event(Y).end()}}function V(v,...I){if(e.apply(this,arguments)){var E=this.__zoom,A=he(v.changedTouches?v.changedTouches[0]:v,this),L=E.invert(A),C=E.k*(v.shiftKey?.5:2),z=n(m(b(E,C),A,L),t.apply(this,I),s);dt(v),a>0?ce(this).transition().duration(a).call(N,z,A,v):ce(this).call(p.transform,z,A,v)}}function S(v,...I){if(e.apply(this,arguments)){var E=v.touches,A=E.length,L=_(this,I,v.changedTouches.length===A).event(v),C,z,j,R;for(Dn(v),z=0;z<A;++z)j=E[z],R=he(j,this),R=[R,this.__zoom.invert(R),j.identifier],L.touch0?!L.touch1&&L.touch0[2]!==R[2]&&(L.touch1=R,L.taps=0):(L.touch0=R,C=!0,L.taps=1+!!d);d&&(d=clearTimeout(d)),C&&(L.taps<2&&(l=R[0],d=setTimeout(function(){d=null},h)),qt(this),L.start())}}function T(v,...I){if(this.__zooming){var E=_(this,I).event(v),A=v.changedTouches,L=A.length,C,z,j,R;for(dt(v),C=0;C<L;++C)z=A[C],j=he(z,this),E.touch0&&E.touch0[2]===z.identifier?E.touch0[0]=j:E.touch1&&E.touch1[2]===z.identifier&&(E.touch1[0]=j);if(z=E.that.__zoom,E.touch1){var F=E.touch0[0],Y=E.touch0[1],U=E.touch1[0],Q=E.touch1[1],q=(q=U[0]-F[0])*q+(q=U[1]-F[1])*q,O=(O=Q[0]-Y[0])*O+(O=Q[1]-Y[1])*O;z=b(z,Math.sqrt(q/O)),j=[(F[0]+U[0])/2,(F[1]+U[1])/2],R=[(Y[0]+Q[0])/2,(Y[1]+Q[1])/2]}else if(E.touch0)j=E.touch0[0],R=E.touch0[1];else return;E.zoom("touch",n(m(z,j,R),E.extent,s))}}function H(v,...I){if(this.__zooming){var E=_(this,I).event(v),A=v.changedTouches,L=A.length,C,z;for(Dn(v),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),C=0;C<L;++C)z=A[C],E.touch0&&E.touch0[2]===z.identifier?delete E.touch0:E.touch1&&E.touch1[2]===z.identifier&&delete E.touch1;if(E.touch1&&!E.touch0&&(E.touch0=E.touch1,delete E.touch1),E.touch0)E.touch0[1]=this.__zoom.invert(E.touch0[0]);else if(E.end(),E.taps===2&&(z=he(z,this),Math.hypot(l[0]-z[0],l[1]-z[1])<y)){var j=ce(this).on("dblclick.zoom");j&&j.apply(this,arguments)}}}return p.wheelDelta=function(v){return arguments.length?(r=typeof v=="function"?v:jt(+v),p):r},p.filter=function(v){return arguments.length?(e=typeof v=="function"?v:jt(!!v),p):e},p.touchable=function(v){return arguments.length?(o=typeof v=="function"?v:jt(!!v),p):o},p.extent=function(v){return arguments.length?(t=typeof v=="function"?v:jt([[+v[0][0],+v[0][1]],[+v[1][0],+v[1][1]]]),p):t},p.scaleExtent=function(v){return arguments.length?(i[0]=+v[0],i[1]=+v[1],p):[i[0],i[1]]},p.translateExtent=function(v){return arguments.length?(s[0][0]=+v[0][0],s[1][0]=+v[1][0],s[0][1]=+v[0][1],s[1][1]=+v[1][1],p):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},p.constrain=function(v){return arguments.length?(n=v,p):n},p.duration=function(v){return arguments.length?(a=+v,p):a},p.interpolate=function(v){return arguments.length?(c=v,p):c},p.on=function(){var v=u.on.apply(u,arguments);return v===u?p:v},p.clickDistance=function(v){return arguments.length?(x=(v=+v)*v,p):Math.sqrt(x)},p.tapDistance=function(v){return arguments.length?(y=+v,p):y},p}const ye={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle: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.`},_t=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ds=["Enter"," ","Escape"],fs={"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 rt;(function(e){e.Strict="strict",e.Loose="loose"})(rt||(rt={}));var Be;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Be||(Be={}));var Et;(function(e){e.Partial="partial",e.Full="full"})(Et||(Et={}));const hs={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Le;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Le||(Le={}));var sn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(sn||(sn={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const mo={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top};function gs(e){return e===null?null:e?"valid":"invalid"}const ps=e=>"id"in e&&"source"in e&&"target"in e,Tg=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),wr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),At=(e,t=[0,0])=>{const{width:n,height:r}=$e(e),o=e.origin??t,i=n*o[0],s=r*o[1];return{x:e.position.x-i,y:e.position.y-s}},Lg=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const i=typeof o=="string";let s=!t.nodeLookup&&!i?o:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(o):wr(o)?o:t.nodeLookup.get(o.id));const a=s?an(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return yn(r,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return xn(n)},$t=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=yn(n,an(o)),r=!0)}),r?xn(n):{x:0,y:0,width:0,height:0}},vr=(e,t,[n,r,o]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/o,c=(t.y-r)/o,u=t.width/o,d=t.height/o,l=[];for(const f of e.values()){const{measured:h,selectable:g=!0,hidden:x=!1}=f;if(s&&!g||x)continue;const y=h.width??f.width??f.initialWidth??0,p=h.height??f.height??f.initialHeight??0,{x:b,y:m}=f.internals.positionAbsolute,w=ws(a,c,u,d,b,m,y,p),N=y*p,_=i&&w>0;(!f.internals.handleBounds||_||w>=N||f.dragging)&&l.push(f)}return l},Dg=(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 Og(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function Rg({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:i},s){if(e.size===0)return!0;const a=Og(e,s),c=$t(a),u=_r(c,t,n,(s==null?void 0:s.minZoom)??o,(s==null?void 0:s.maxZoom)??i,(s==null?void 0:s.padding)??.1);return await r.setViewport(u,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),!0}function ms({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},d=s.origin??r;let l=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!a)i==null||i("005",ye.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(l=[[c,u],[c+h,u+g]])}else a&&We(s.extent)&&(l=[[s.extent[0][0]+c,s.extent[0][1]+u],[s.extent[1][0]+c,s.extent[1][1]+u]]);const f=We(l)?Xe(t,l,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(i==null||i("015",ye.error015())),{position:{x:f.x-c+(s.measured.width??0)*d[0],y:f.y-u+(s.measured.height??0)*d[1]},positionAbsolute:f}}async function zg({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),g=!h&&f.parentId&&s.find(x=>x.id===f.parentId);(h||g)&&s.push(f)}const a=new Set(t.map(f=>f.id)),c=r.filter(f=>f.deletable!==!1),d=Dg(s,c);for(const f of c)a.has(f.id)&&!d.find(g=>g.id===f.id)&&d.push(f);if(!o)return{edges:d,nodes:s};const l=await o({nodes:s,edges:d});return typeof l=="boolean"?l?{edges:d,nodes:s}:{edges:[],nodes:[]}:l}const ot=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Xe=(e={x:0,y:0},t,n)=>({x:ot(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:ot(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function ys(e,t,n){const{width:r,height:o}=$e(n),{x:i,y:s}=n.internals.positionAbsolute;return Xe(e,[[i,s],[i+r,s+o]],t)}const yo=(e,t,n)=>e<t?ot(Math.abs(e-t),1,t)/t:e>n?-ot(Math.abs(e-n),1,t)/t:0,br=(e,t,n=15,r=40)=>{const o=yo(e.x,r,t.width-r)*n,i=yo(e.y,r,t.height-r)*n;return[o,i]},yn=(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)}),er=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),xn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Nt=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=wr(e)?e.internals.positionAbsolute:At(e,t);return{x:n,y:r,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},an=(e,t=[0,0])=>{var o,i;const{x:n,y:r}=wr(e)?e.internals.positionAbsolute:At(e,t);return{x:n,y:r,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},xs=(e,t)=>xn(yn(er(e),er(t))),ws=(e,t,n,r,o,i,s,a)=>{const c=Math.max(0,Math.min(e+n,o+s)-Math.max(e,o)),u=Math.max(0,Math.min(t+r,i+a)-Math.max(t,i));return Math.ceil(c*u)},cn=(e,t)=>ws(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),xo=e=>pe(e.width)&&pe(e.height)&&pe(e.x)&&pe(e.y),pe=e=>!isNaN(e)&&isFinite(e),vs=(e,t)=>(n,r)=>{},Pt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Tt=({x:e,y:t},[n,r,o],i=!1,s=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return i?Pt(a,s):a},it=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function Ue(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 jg(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Ue(e,n),o=Ue(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=Ue(e.top??e.y??0,n),o=Ue(e.bottom??e.y??0,n),i=Ue(e.left??e.x??0,t),s=Ue(e.right??e.x??0,t);return{top:r,right:s,bottom:o,left:i,x:i+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Hg(e,t,n,r,o,i){const{x:s,y:a}=it(e,[t,n,r]),{x:c,y:u}=it({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=o-c,l=i-u;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(l)}}const _r=(e,t,n,r,o,i)=>{const s=jg(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,u=Math.min(a,c),d=ot(u,r,o),l=e.x+e.width/2,f=e.y+e.height/2,h=t/2-l*d,g=n/2-f*d,x=Hg(e,h,g,d,t,n),y={left:Math.min(x.left-s.left,0),top:Math.min(x.top-s.top,0),right:Math.min(x.right-s.right,0),bottom:Math.min(x.bottom-s.bottom,0)};return{x:h-y.left+y.right,y:g-y.top+y.bottom,zoom:d}},St=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function We(e){return e!=null&&e!=="parent"}function $e(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 bs(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 _s(e,t={width:0,height:0},n,r,o){const i={...e},s=r.get(n);if(s){const a=s.origin||o;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function wo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Vg(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function Bg(e){return{...fs,...e||{}}}function mt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:i,y:s}=me(e),a=Tt({x:i-((o==null?void 0:o.left)??0),y:s-((o==null?void 0:o.top)??0)},r),{x:c,y:u}=n?Pt(a,t):a;return{xSnapped:c,ySnapped:u,...a}}const Er=e=>({width:e.offsetWidth,height:e.offsetHeight}),Es=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Fg=["INPUT","SELECT","TEXTAREA"];function Ns(e){var r,o;const t=((o=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Fg.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Ss=e=>"clientX"in e,me=(e,t)=>{var i,s;const n=Ss(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},vo=(e,t,n,r,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...Er(s)}})};function Ms({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+o*.375+s*.375+n*.125,u=t*.125+i*.375+a*.375+r*.125,d=Math.abs(c-e),l=Math.abs(u-t);return[c,u,d,l]}function Ht(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function bo({pos:e,x1:t,y1:n,x2:r,y2:o,c:i}){switch(e){case W.Left:return[t-Ht(t-r,i),n];case W.Right:return[t+Ht(r-t,i),n];case W.Top:return[t,n-Ht(n-o,i)];case W.Bottom:return[t,n+Ht(o-n,i)]}}function ks({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,curvature:s=.25}){const[a,c]=bo({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[u,d]=bo({pos:i,x1:r,y1:o,x2:e,y2:t,c:s}),[l,f,h,g]=Ms({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:d});return[`M${e},${t} C${a},${c} ${u},${d} ${r},${o}`,l,f,h,g]}function Cs({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,s=Math.abs(r-t)/2,a=r<t?r+s:r-s;return[i,a,o,s]}function Yg({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return r;const s=o&&n?r+1e3:r,a=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return s+a}function Xg({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const i=yn(an(e),an(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return cn(s,xn(i))>0}const Wg=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Gg=(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)),qg=(e,t,n={})=>{var i;if(!e.source||!e.target)return(i=n.onError)==null||i.call(n,"006",ye.error006()),t;const r=n.getEdgeId||Wg;let o;return ps(e)?o={...e}:o={...e,id:r(e)},Gg(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function Is({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,i,s,a]=Cs({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,i,s,a]}const _o={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},Ug=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.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},Eo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Kg({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:o,offset:i,stepPosition:s}){const a=_o[t],c=_o[r],u={x:e.x+a.x*i,y:e.y+a.y*i},d={x:n.x+c.x*i,y:n.y+c.y*i},l=Ug({source:u,sourcePosition:t,target:d}),f=l.x!==0?"x":"y",h=l[f];let g=[],x,y;const p={x:0,y:0},b={x:0,y:0},[,,m,w]=Cs({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*c[f]===-1){f==="x"?(x=o.x??u.x+(d.x-u.x)*s,y=o.y??(u.y+d.y)/2):(x=o.x??(u.x+d.x)/2,y=o.y??u.y+(d.y-u.y)*s);const $=[{x,y:u.y},{x,y:d.y}],P=[{x:u.x,y},{x:d.x,y}];a[f]===h?g=f==="x"?$:P:g=f==="x"?P:$}else{const $=[{x:u.x,y:d.y}],P=[{x:d.x,y:u.y}];if(f==="x"?g=a.x===h?P:$:g=a.y===h?$:P,t===r){const v=Math.abs(e[f]-n[f]);if(v<=i){const I=Math.min(i-1,i-v);a[f]===h?p[f]=(u[f]>e[f]?-1:1)*I:b[f]=(d[f]>n[f]?-1:1)*I}}if(t!==r){const v=f==="x"?"y":"x",I=a[f]===c[v],E=u[v]>d[v],A=u[v]<d[v];(a[f]===1&&(!I&&E||I&&A)||a[f]!==1&&(!I&&A||I&&E))&&(g=f==="x"?$:P)}const V={x:u.x+p.x,y:u.y+p.y},S={x:d.x+b.x,y:d.y+b.y},T=Math.max(Math.abs(V.x-g[0].x),Math.abs(S.x-g[0].x)),H=Math.max(Math.abs(V.y-g[0].y),Math.abs(S.y-g[0].y));T>=H?(x=(V.x+S.x)/2,y=g[0].y):(x=g[0].x,y=(V.y+S.y)/2)}const N={x:u.x+p.x,y:u.y+p.y},_={x:d.x+b.x,y:d.y+b.y};return[[e,...N.x!==g[0].x||N.y!==g[0].y?[N]:[],...g,..._.x!==g[g.length-1].x||_.y!==g[g.length-1].y?[_]:[],n],x,y,m,w]}function Zg(e,t,n,r){const o=Math.min(Eo(e,t)/2,Eo(t,n)/2,r),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const u=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${i+o*u},${s}Q ${i},${s} ${i},${s+o*d}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+o*c}Q ${i},${s} ${i+o*a},${s}`}function tr({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top,borderRadius:s=5,centerX:a,centerY:c,offset:u=20,stepPosition:d=.5}){const[l,f,h,g,x]=Kg({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:i,center:{x:a,y:c},offset:u,stepPosition:d});let y=`M${l[0].x} ${l[0].y}`;for(let p=1;p<l.length-1;p++)y+=Zg(l[p-1],l[p],l[p+1],s);return y+=`L${l[l.length-1].x} ${l[l.length-1].y}`,[y,f,h,g,x]}function No(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Qg(e){var l;const{sourceNode:t,targetNode:n}=e;if(!No(t)||!No(n))return null;const r=t.internals.handleBounds||So(t.handles),o=n.internals.handleBounds||So(n.handles),i=Mo((r==null?void 0:r.source)??[],e.sourceHandle),s=Mo(e.connectionMode===rt.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!i||!s)return(l=e.onError)==null||l.call(e,"008",ye.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(i==null?void 0:i.position)||W.Bottom,c=(s==null?void 0:s.position)||W.Top,u=Ge(t,i,a),d=Ge(n,s,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:c}}function So(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 Ge(e,t,n=W.Left,r=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??$e(e);if(r)return{x:o+s/2,y:i+a/2};switch((t==null?void 0:t.position)??n){case W.Top:return{x:o+s/2,y:i};case W.Right:return{x:o+s,y:i+a/2};case W.Bottom:return{x:o+s/2,y:i+a};case W.Left:return{x:o,y:i+a/2}}}function Mo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function nr(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function Jg(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||r,a.markerEnd||o].forEach(c=>{if(c&&typeof c=="object"){const u=nr(c,t);i.has(u)||(s.push({id:u,color:c.color||n,...c}),i.add(u))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const As=1e3,ep=10,Nr={nodeOrigin:[0,0],nodeExtent:_t,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},tp={...Nr,checkEquality:!0};function Sr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function np(e,t,n){const r=Sr(Nr,n);for(const o of e.values())if(o.parentId)kr(o,e,t,r);else{const i=At(o,r.nodeOrigin),s=We(o.extent)?o.extent:r.nodeExtent,a=Xe(i,s,$e(o));o.internals.positionAbsolute=a}}function rp(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&r.push(i)}return{source:n,target:r}}function Mr(e){return e==="manual"}function rr(e,t,n,r={}){var d,l;const o=Sr(tp,r),i={i:0},s=new Map(t),a=o!=null&&o.elevateNodesOnSelect&&!Mr(o.zIndexMode)?As:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const f of e){let h=s.get(f.id);if(o.checkEquality&&f===(h==null?void 0:h.internals.userNode))t.set(f.id,h);else{const g=At(f,o.nodeOrigin),x=We(f.extent)?f.extent:o.nodeExtent,y=Xe(g,x,$e(f));h={...o.defaults,...f,measured:{width:(d=f.measured)==null?void 0:d.width,height:(l=f.measured)==null?void 0:l.height},internals:{positionAbsolute:y,handleBounds:rp(f,h),z:$s(f,a,o.zIndexMode),userNode:f}},t.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),f.parentId&&kr(h,t,n,r,i),u||(u=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function op(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 kr(e,t,n,r,o){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=Sr(Nr,r),u=e.parentId,d=t.get(u);if(!d){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}op(e,n),o&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++o.i,d.internals.z=d.internals.z+o.i*ep),o&&d.internals.rootParentIndex!==void 0&&(o.i=d.internals.rootParentIndex);const l=i&&!Mr(c)?As:0,{x:f,y:h,z:g}=ip(e,d,s,a,l,c),{positionAbsolute:x}=e.internals,y=f!==x.x||h!==x.y;(y||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:f,y:h}:x,z:g}})}function $s(e,t,n){const r=pe(e.zIndex)?e.zIndex:0;return Mr(n)?r:r+(e.selected?t:0)}function ip(e,t,n,r,o,i){const{x:s,y:a}=t.internals.positionAbsolute,c=$e(e),u=At(e,n),d=We(e.extent)?Xe(u,e.extent,c):u;let l=Xe({x:s+d.x,y:a+d.y},r,c);e.extent==="parent"&&(l=ys(l,c,t));const f=$s(e,o,i),h=t.internals.z??0;return{x:l.x,y:l.y,z:h>=f?h+1:f}}function Cr(e,t,n,r=[0,0]){var s;const o=[],i=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const u=((s=i.get(a.parentId))==null?void 0:s.expandedRect)??Nt(c),d=xs(u,a.rect);i.set(a.parentId,{expandedRect:d,parent:c})}return i.size>0&&i.forEach(({expandedRect:a,parent:c},u)=>{var m;const d=c.internals.positionAbsolute,l=$e(c),f=c.origin??r,h=a.x<d.x?Math.round(Math.abs(d.x-a.x)):0,g=a.y<d.y?Math.round(Math.abs(d.y-a.y)):0,x=Math.max(l.width,Math.round(a.width)),y=Math.max(l.height,Math.round(a.height)),p=(x-l.width)*f[0],b=(y-l.height)*f[1];(h>0||g>0||p||b)&&(o.push({id:u,type:"position",position:{x:c.position.x-h+p,y:c.position.y-g+b}}),(m=n.get(u))==null||m.forEach(w=>{e.some(N=>N.id===w.id)||o.push({id:w.id,type:"position",position:{x:w.position.x+h,y:w.position.y+g}})})),(l.width<a.width||l.height<a.height||h||g)&&o.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:x+(h?f[0]*h-p:0),height:y+(g?f[1]*g-b:0)}})}),o}function sp(e,t,n,r,o,i,s){const a=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const u=[],d=window.getComputedStyle(a),{m22:l}=new window.DOMMatrixReadOnly(d.transform),f=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const x=Er(h.nodeElement),y=g.measured.width!==x.width||g.measured.height!==x.height;if(!!(x.width&&x.height&&(y||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),m=We(g.extent)?g.extent:i;let{positionAbsolute:w}=g.internals;g.parentId&&g.extent==="parent"?w=ys(w,x,t.get(g.parentId)):m&&(w=Xe(w,m,x));const N={...g,measured:x,internals:{...g.internals,positionAbsolute:w,handleBounds:{source:vo("source",h.nodeElement,b,l,g.id),target:vo("target",h.nodeElement,b,l,g.id)}}};t.set(g.id,N),g.parentId&&kr(N,t,n,{nodeOrigin:o,zIndexMode:s}),c=!0,y&&(u.push({id:g.id,type:"dimensions",dimensions:x}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:Nt(N,o)}))}}if(f.length>0){const h=Cr(f,t,n,o);u.push(...h)}return{changes:u,updatedInternals:c}}async function ap({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],r);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function ko(e,t,n,r,o,i){let s=o;const a=r.get(s)||new Map;r.set(s,a.set(n,t)),s=`${o}-${e}`;const c=r.get(s)||new Map;if(r.set(s,c.set(n,t)),i){s=`${o}-${e}-${i}`;const u=r.get(s)||new Map;r.set(s,u.set(n,t))}}function Ps(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:i,sourceHandle:s=null,targetHandle:a=null}=r,c={edgeId:r.id,source:o,target:i,sourceHandle:s,targetHandle:a},u=`${o}-${s}--${i}-${a}`,d=`${i}-${a}--${o}-${s}`;ko("source",c,d,e,o,s),ko("target",c,u,e,i,a),t.set(r.id,r)}}function Ts(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ts(n,t):!1}function Co(e,t,n){var o;let r=e;do{if((o=r==null?void 0:r.matches)!=null&&o.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function cp(e,t,n,r){const o=new Map;for(const[i,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!Ts(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&o.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 o}function On({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var s,a,c;const o=[];for(const[u,d]of t){const l=(s=n.get(u))==null?void 0:s.internals.userNode;l&&o.push({...l,position:d.position,dragging:r})}if(!e)return[o[0],o];const i=(a=n.get(e))==null?void 0:a.internals.userNode;return[i?{...i,position:((c=t.get(e))==null?void 0:c.position)||i.position,dragging:r}:o[0],o]}function up({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:r-o.distance.y},s=Pt(i,t);return{x:s.x-i.x,y:s.y-i.y}}function lp({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let i={x:null,y:null},s=0,a=new Map,c=!1,u={x:0,y:0},d=null,l=!1,f=null,h=!1,g=!1,x=null;function y({noDragClassName:b,handleSelector:m,domNode:w,isSelectable:N,nodeId:_,nodeClickDistance:k=0}){f=ce(w);function $({x:T,y:H}){const{nodeLookup:v,nodeExtent:I,snapGrid:E,snapToGrid:A,nodeOrigin:L,onNodeDrag:C,onSelectionDrag:z,onError:j,updateNodePositions:R}=t();i={x:T,y:H};let F=!1;const Y=a.size>1,U=Y&&I?er($t(a)):null,Q=Y&&A?up({dragItems:a,snapGrid:E,x:T,y:H}):null;for(const[q,O]of a){if(!v.has(q))continue;let B={x:T-O.distance.x,y:H-O.distance.y};A&&(B=Q?{x:Math.round(B.x+Q.x),y:Math.round(B.y+Q.y)}:Pt(B,E));let Z=null;if(Y&&I&&!O.extent&&U){const{positionAbsolute:X}=O.internals,J=X.x-U.x+I[0][0],te=X.x+O.measured.width-U.x2+I[1][0],ne=X.y-U.y+I[0][1],ie=X.y+O.measured.height-U.y2+I[1][1];Z=[[J,ne],[te,ie]]}const{position:K,positionAbsolute:G}=ms({nodeId:q,nextPosition:B,nodeLookup:v,nodeExtent:Z||I,nodeOrigin:L,onError:j});F=F||O.position.x!==K.x||O.position.y!==K.y,O.position=K,O.internals.positionAbsolute=G}if(g=g||F,!!F&&(R(a,!0),x&&(r||C||!_&&z))){const[q,O]=On({nodeId:_,dragItems:a,nodeLookup:v});r==null||r(x,a,q,O),C==null||C(x,q,O),_||z==null||z(x,O)}}async function P(){if(!d)return;const{transform:T,panBy:H,autoPanSpeed:v,autoPanOnNodeDrag:I}=t();if(!I){c=!1,cancelAnimationFrame(s);return}const[E,A]=br(u,d,v);(E!==0||A!==0)&&(i.x=(i.x??0)-E/T[2],i.y=(i.y??0)-A/T[2],await H({x:E,y:A})&&$(i)),s=requestAnimationFrame(P)}function V(T){var Y;const{nodeLookup:H,multiSelectionActive:v,nodesDraggable:I,transform:E,snapGrid:A,snapToGrid:L,selectNodesOnDrag:C,onNodeDragStart:z,onSelectionDragStart:j,unselectNodesAndEdges:R}=t();l=!0,(!C||!N)&&!v&&_&&((Y=H.get(_))!=null&&Y.selected||R()),N&&C&&_&&(e==null||e(_));const F=mt(T.sourceEvent,{transform:E,snapGrid:A,snapToGrid:L,containerBounds:d});if(i=F,a=cp(H,I,F,_),a.size>0&&(n||z||!_&&j)){const[U,Q]=On({nodeId:_,dragItems:a,nodeLookup:H});n==null||n(T.sourceEvent,a,U,Q),z==null||z(T.sourceEvent,U,Q),_||j==null||j(T.sourceEvent,Q)}}const S=Ui().clickDistance(k).on("start",T=>{const{domNode:H,nodeDragThreshold:v,transform:I,snapGrid:E,snapToGrid:A}=t();d=(H==null?void 0:H.getBoundingClientRect())||null,h=!1,g=!1,x=T.sourceEvent,v===0&&V(T),i=mt(T.sourceEvent,{transform:I,snapGrid:E,snapToGrid:A,containerBounds:d}),u=me(T.sourceEvent,d)}).on("drag",T=>{const{autoPanOnNodeDrag:H,transform:v,snapGrid:I,snapToGrid:E,nodeDragThreshold:A,nodeLookup:L}=t(),C=mt(T.sourceEvent,{transform:v,snapGrid:I,snapToGrid:E,containerBounds:d});if(x=T.sourceEvent,(T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1||_&&!L.has(_))&&(h=!0),!h){if(!c&&H&&l&&(c=!0,P()),!l){const z=me(T.sourceEvent,d),j=z.x-u.x,R=z.y-u.y;Math.sqrt(j*j+R*R)>A&&V(T)}(i.x!==C.xSnapped||i.y!==C.ySnapped)&&a&&l&&(u=me(T.sourceEvent,d),$(C))}}).on("end",T=>{if(!l||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,l=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:H,updateNodePositions:v,onNodeDragStop:I,onSelectionDragStop:E}=t();if(g&&(v(a,!1),g=!1),o||I||!_&&E){const[A,L]=On({nodeId:_,dragItems:a,nodeLookup:H,dragging:!1});o==null||o(T.sourceEvent,a,A,L),I==null||I(T.sourceEvent,A,L),_||E==null||E(T.sourceEvent,L)}}}).filter(T=>{const H=T.target;return!T.button&&(!b||!Co(H,`.${b}`,w))&&(!m||Co(H,m,w))});f.call(S)}function p(){f==null||f.on(".drag",null)}return{update:y,destroy:p}}function dp(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())cn(o,Nt(i))>0&&r.push(i);return r}const fp=250;function hp(e,t,n,r){var a,c;let o=[],i=1/0;const s=dp(e,n,t+fp);for(const u of s){const d=[...((a=u.internals.handleBounds)==null?void 0:a.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const l of d){if(r.nodeId===l.nodeId&&r.type===l.type&&r.id===l.id)continue;const{x:f,y:h}=Ge(u,l,l.position,!0),g=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(h-e.y,2));g>t||(g<i?(o=[{...l,x:f,y:h}],i=g):g===i&&o.push({...l,x:f,y:h}))}}if(!o.length)return null;if(o.length>1){const u=r.type==="source"?"target":"source";return o.find(d=>d.type===u)??o[0]}return o[0]}function Ls(e,t,n,r,o,i=!1){var u,d,l;const s=r.get(e);if(!s)return null;const a=o==="strict"?(u=s.internals.handleBounds)==null?void 0:u[t]:[...((d=s.internals.handleBounds)==null?void 0:d.source)??[],...((l=s.internals.handleBounds)==null?void 0:l.target)??[]],c=(n?a==null?void 0:a.find(f=>f.id===n):a==null?void 0:a[0])??null;return c&&i?{...c,...Ge(s,c,c.position,!0)}:c}function Ds(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function gp(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Os=()=>!0;function pp(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:u,autoPanOnConnect:d,flowId:l,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:x,onConnectEnd:y,isValidConnection:p=Os,onReconnectEnd:b,updateConnection:m,getTransform:w,getFromHandle:N,autoPanSpeed:_,dragThreshold:k=1,handleDomNode:$}){const P=Es(e.target);let V=0,S;const{x:T,y:H}=me(e),v=Ds(i,$),I=a==null?void 0:a.getBoundingClientRect();let E=!1;if(!I||!v)return;const A=Ls(o,v,r,c,t);if(!A)return;let L=me(e,I),C=!1,z=null,j=!1,R=null;function F(){if(!d||!I)return;const[K,G]=br(L,I,_);f({x:K,y:G}),V=requestAnimationFrame(F)}const Y={...A,nodeId:o,type:v,position:A.position},U=c.get(o);let q={inProgress:!0,isValid:null,from:Ge(U,Y,W.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:U,to:L,toHandle:null,toPosition:mo[Y.position],toNode:null,pointer:L};function O(){E=!0,m(q),g==null||g(e,{nodeId:o,handleId:r,handleType:v})}k===0&&O();function B(K){if(!E){const{x:ie,y:le}=me(K),we=ie-T,ve=le-H;if(!(we*we+ve*ve>k*k))return;O()}if(!N()||!Y){Z(K);return}const G=w();L=me(K,I),S=hp(Tt(L,G,!1,[1,1]),n,c,Y),C||(F(),C=!0);const X=Rs(K,{handle:S,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:p,doc:P,lib:u,flowId:l,nodeLookup:c});R=X.handleDomNode,z=X.connection,j=gp(!!S,X.isValid);const J=c.get(o),te=J?Ge(J,Y,W.Left,!0):q.from,ne={...q,from:te,isValid:j,to:X.toHandle&&j?it({x:X.toHandle.x,y:X.toHandle.y},G):L,toHandle:X.toHandle,toPosition:j&&X.toHandle?X.toHandle.position:mo[Y.position],toNode:X.toHandle?c.get(X.toHandle.nodeId):null,pointer:L};m(ne),q=ne}function Z(K){if(!("touches"in K&&K.touches.length>0)){if(E){(S||R)&&z&&j&&(x==null||x(z));const{inProgress:G,...X}=q,J={...X,toPosition:q.toHandle?q.toPosition:null};y==null||y(K,J),i&&(b==null||b(K,J))}h(),cancelAnimationFrame(V),C=!1,j=!1,z=null,R=null,P.removeEventListener("mousemove",B),P.removeEventListener("mouseup",Z),P.removeEventListener("touchmove",B),P.removeEventListener("touchend",Z)}}P.addEventListener("mousemove",B),P.addEventListener("mouseup",Z),P.addEventListener("touchmove",B),P.addEventListener("touchend",Z)}function Rs(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:u=Os,nodeLookup:d}){const l=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y:g}=me(e),x=s.elementFromPoint(h,g),y=x!=null&&x.classList.contains(`${a}-flow__handle`)?x:f,p={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const b=Ds(void 0,y),m=y.getAttribute("data-nodeid"),w=y.getAttribute("data-handleid"),N=y.classList.contains("connectable"),_=y.classList.contains("connectableend");if(!m||!b)return p;const k={source:l?m:r,sourceHandle:l?w:o,target:l?r:m,targetHandle:l?o:w};p.connection=k;const P=N&&_&&(n===rt.Strict?l&&b==="source"||!l&&b==="target":m!==r||w!==o);p.isValid=P&&u(k),p.toHandle=Ls(m,b,w,d,n,!0)}return p}const or={onPointerDown:pp,isValid:Rs};function mp({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=ce(e);function i({translateExtent:a,width:c,height:u,zoomStep:d=1,pannable:l=!0,zoomable:f=!0,inversePan:h=!1}){const g=m=>{if(m.sourceEvent.type!=="wheel"||!t)return;const w=n(),N=m.sourceEvent.ctrlKey&&St()?10:1,_=-m.sourceEvent.deltaY*(m.sourceEvent.deltaMode===1?.05:m.sourceEvent.deltaMode?1:.002)*d,k=w[2]*Math.pow(2,_*N);t.scaleTo(k)};let x=[0,0];const y=m=>{(m.sourceEvent.type==="mousedown"||m.sourceEvent.type==="touchstart")&&(x=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY])},p=m=>{const w=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],_=[N[0]-x[0],N[1]-x[1]];x=N;const k=r()*Math.max(w[2],Math.log(w[2]))*(h?-1:1),$={x:w[0]-_[0]*k,y:w[1]-_[1]*k},P=[[0,0],[c,u]];t.setViewportConstrained({x:$.x,y:$.y,zoom:w[2]},P,a)},b=ls().on("start",y).on("zoom",l?p:null).on("zoom.wheel",f?g:null);o.call(b,{})}function s(){o.on("zoom",null)}return{update:i,destroy:s,pointer:he}}const wn=e=>({x:e.x,y:e.y,zoom:e.k}),Rn=({x:e,y:t,zoom:n})=>mn.translate(e,t).scale(n),Ke=(e,t)=>e.target.closest(`.${t}`),zs=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),yp=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,zn=(e,t=0,n=yp,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},js=e=>{const t=e.ctrlKey&&St()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function xp({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(Ke(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const l=n.property("__zoom").k||1;if(d.ctrlKey&&s){const y=he(d),p=js(d),b=l*Math.pow(2,p);r.scaleTo(n,b,y,d);return}const f=d.deltaMode===1?20:1;let h=o===Be.Vertical?0:d.deltaX*f,g=o===Be.Horizontal?0:d.deltaY*f;!St()&&d.shiftKey&&o!==Be.Vertical&&(h=d.deltaY*f,g=0),r.translateBy(n,-(h/l)*i,-(g/l)*i,{internal:!0});const x=wn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,x),e.panScrollTimeout=setTimeout(()=>{u==null||u(d,x),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(d,x))}}function wp({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const i=r.type==="wheel",s=!t&&i&&!r.ctrlKey,a=Ke(r,e);if(r.ctrlKey&&i&&a&&r.preventDefault(),s||a)return null;r.preventDefault(),n.call(this,r,o)}}function vp({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,s,a;if((i=r.sourceEvent)!=null&&i.internal)return;const o=wn(r.transform);e.mouseButton=((s=r.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,o))}}function bp({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return i=>{var s,a;e.usedRightMouseButton=!!(n&&zs(t,e.mouseButton??0)),(s=i.sourceEvent)!=null&&s.sync||r([i.transform.x,i.transform.y,i.transform.k]),o&&!((a=i.sourceEvent)!=null&&a.internal)&&(o==null||o(i.sourceEvent,wn(i.transform)))}}function _p({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:i}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,i&&zs(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const c=wn(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(s.sourceEvent,c)},n?150:0)}}}function Ep({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:c,lib:u,connectionInProgress:d}){return l=>{var y;const f=e||t,h=n&&l.ctrlKey,g=l.type==="wheel";if(l.button===1&&l.type==="mousedown"&&(Ke(l,`${u}-flow__node`)||Ke(l,`${u}-flow__edge`)))return!0;if(!r&&!f&&!o&&!i&&!n||s||d&&!g||Ke(l,a)&&g||Ke(l,c)&&(!g||o&&g&&!e)||!n&&l.ctrlKey&&g)return!1;if(!n&&l.type==="touchstart"&&((y=l.touches)==null?void 0:y.length)>1)return l.preventDefault(),!1;if(!f&&!o&&!h&&g||!r&&(l.type==="mousedown"||l.type==="touchstart")||Array.isArray(r)&&!r.includes(l.button)&&l.type==="mousedown")return!1;const x=Array.isArray(r)&&r.includes(l.button)||!l.button||l.button<=1;return(!l.ctrlKey||g)&&x}}function Np({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),l=ls().scaleExtent([t,n]).translateExtent(r),f=ce(e).call(l);b({x:o.x,y:o.y,zoom:ot(o.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=f.on("wheel.zoom"),g=f.on("dblclick.zoom");l.wheelDelta(js);async function x(S,T){return f?new Promise(H=>{l==null||l.interpolate((T==null?void 0:T.interpolate)==="linear"?pt:Xt).transform(zn(f,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>H(!0)),S)}):!1}function y({noWheelClassName:S,noPanClassName:T,onPaneContextMenu:H,userSelectionActive:v,panOnScroll:I,panOnDrag:E,panOnScrollMode:A,panOnScrollSpeed:L,preventScrolling:C,zoomOnPinch:z,zoomOnScroll:j,zoomOnDoubleClick:R,zoomActivationKeyPressed:F,lib:Y,onTransformChange:U,connectionInProgress:Q,paneClickDistance:q,selectionOnDrag:O}){v&&!u.isZoomingOrPanning&&p();const B=I&&!F&&!v;l.clickDistance(O?1/0:!pe(q)||q<0?0:q);const Z=B?xp({zoomPanValues:u,noWheelClassName:S,d3Selection:f,d3Zoom:l,panOnScrollMode:A,panOnScrollSpeed:L,zoomOnPinch:z,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):wp({noWheelClassName:S,preventScrolling:C,d3ZoomHandler:h});f.on("wheel.zoom",Z,{passive:!1});const K=vp({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:s});l.on("start",K);const G=bp({zoomPanValues:u,panOnDrag:E,onPaneContextMenu:!!H,onPanZoom:i,onTransformChange:U});l.on("zoom",G);const X=_p({zoomPanValues:u,panOnDrag:E,panOnScroll:I,onPaneContextMenu:H,onPanZoomEnd:a,onDraggingChange:c});l.on("end",X);const J=Ep({zoomActivationKeyPressed:F,panOnDrag:E,zoomOnScroll:j,panOnScroll:I,zoomOnDoubleClick:R,zoomOnPinch:z,userSelectionActive:v,noPanClassName:T,noWheelClassName:S,lib:Y,connectionInProgress:Q});l.filter(J),R?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function p(){l.on("zoom",null)}async function b(S,T,H){const v=Rn(S),I=l==null?void 0:l.constrain()(v,T,H);return I&&await x(I),I}async function m(S,T){const H=Rn(S);return await x(H,T),H}function w(S){if(f){const T=Rn(S),H=f.property("__zoom");(H.k!==S.zoom||H.x!==S.x||H.y!==S.y)&&(l==null||l.transform(f,T,null,{sync:!0}))}}function N(){const S=f?us(f.node()):{x:0,y:0,k:1};return{x:S.x,y:S.y,zoom:S.k}}async function _(S,T){return f?new Promise(H=>{l==null||l.interpolate((T==null?void 0:T.interpolate)==="linear"?pt:Xt).scaleTo(zn(f,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>H(!0)),S)}):!1}async function k(S,T){return f?new Promise(H=>{l==null||l.interpolate((T==null?void 0:T.interpolate)==="linear"?pt:Xt).scaleBy(zn(f,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>H(!0)),S)}):!1}function $(S){l==null||l.scaleExtent(S)}function P(S){l==null||l.translateExtent(S)}function V(S){const T=!pe(S)||S<0?0:S;l==null||l.clickDistance(T)}return{update:y,destroy:p,setViewport:m,setViewportConstrained:b,getViewport:N,scaleTo:_,scaleBy:k,setScaleExtent:$,setTranslateExtent:P,syncViewport:w,setClickDistance:V}}var st;(function(e){e.Line="line",e.Handle="handle"})(st||(st={}));function Sp({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:i}){const s=e-t,a=n-r,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&o&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function Io(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function Pe(e,t){return Math.max(0,t-e)}function Te(e,t){return Math.max(0,e-t)}function Vt(e,t,n){return Math.max(0,t-e,e-n)}function Ao(e,t){return e?!t:t}function Mp(e,t,n,r,o,i,s,a){let{affectsX:c,affectsY:u}=t;const{isHorizontal:d,isVertical:l}=t,f=d&&l,{xSnapped:h,ySnapped:g}=n,{minWidth:x,maxWidth:y,minHeight:p,maxHeight:b}=r,{x:m,y:w,width:N,height:_,aspectRatio:k}=e;let $=Math.floor(d?h-e.pointerX:0),P=Math.floor(l?g-e.pointerY:0);const V=N+(c?-$:$),S=_+(u?-P:P),T=-i[0]*N,H=-i[1]*_;let v=Vt(V,x,y),I=Vt(S,p,b);if(s){let L=0,C=0;c&&$<0?L=Pe(m+$+T,s[0][0]):!c&&$>0&&(L=Te(m+V+T,s[1][0])),u&&P<0?C=Pe(w+P+H,s[0][1]):!u&&P>0&&(C=Te(w+S+H,s[1][1])),v=Math.max(v,L),I=Math.max(I,C)}if(a){let L=0,C=0;c&&$>0?L=Te(m+$,a[0][0]):!c&&$<0&&(L=Pe(m+V,a[1][0])),u&&P>0?C=Te(w+P,a[0][1]):!u&&P<0&&(C=Pe(w+S,a[1][1])),v=Math.max(v,L),I=Math.max(I,C)}if(o){if(d){const L=Vt(V/k,p,b)*k;if(v=Math.max(v,L),s){let C=0;!c&&!u||c&&!u&&f?C=Te(w+H+V/k,s[1][1])*k:C=Pe(w+H+(c?$:-$)/k,s[0][1])*k,v=Math.max(v,C)}if(a){let C=0;!c&&!u||c&&!u&&f?C=Pe(w+V/k,a[1][1])*k:C=Te(w+(c?$:-$)/k,a[0][1])*k,v=Math.max(v,C)}}if(l){const L=Vt(S*k,x,y)/k;if(I=Math.max(I,L),s){let C=0;!c&&!u||u&&!c&&f?C=Te(m+S*k+T,s[1][0])/k:C=Pe(m+(u?P:-P)*k+T,s[0][0])/k,I=Math.max(I,C)}if(a){let C=0;!c&&!u||u&&!c&&f?C=Pe(m+S*k,a[1][0])/k:C=Te(m+(u?P:-P)*k,a[0][0])/k,I=Math.max(I,C)}}}P=P+(P<0?I:-I),$=$+($<0?v:-v),o&&(f?V>S*k?P=(Ao(c,u)?-$:$)/k:$=(Ao(c,u)?-P:P)*k:d?(P=$/k,u=c):($=P*k,c=u));const E=c?m+$:m,A=u?w+P:w;return{width:N+(c?-$:$),height:_+(u?-P:P),x:i[0]*$*(c?-1:1)+E,y:i[1]*P*(u?-1:1)+A}}const Hs={width:0,height:0,x:0,y:0},kp={...Hs,pointerX:0,pointerY:0,aspectRatio:1};function Cp(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[r-a,o-c],[r+i-a,o+s-c]]}function Ip({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const i=ce(e);let s={controlDirection:Io("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:d,keepAspectRatio:l,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:x,shouldResize:y}){let p={...Hs},b={...kp};s={boundaries:d,resizeDirection:f,keepAspectRatio:l,controlDirection:Io(u)};let m,w=null,N=[],_,k,$,P=!1;const V=Ui().on("start",S=>{const{nodeLookup:T,transform:H,snapGrid:v,snapToGrid:I,nodeOrigin:E,paneDomNode:A}=n();if(m=T.get(t),!m)return;w=(A==null?void 0:A.getBoundingClientRect())??null;const{xSnapped:L,ySnapped:C}=mt(S.sourceEvent,{transform:H,snapGrid:v,snapToGrid:I,containerBounds:w});p={width:m.measured.width??0,height:m.measured.height??0,x:m.position.x??0,y:m.position.y??0},b={...p,pointerX:L,pointerY:C,aspectRatio:p.width/p.height},_=void 0,k=We(m.extent)?m.extent:void 0,m.parentId&&(m.extent==="parent"||m.expandParent)&&(_=T.get(m.parentId)),_&&m.extent==="parent"&&(k=[[0,0],[_.measured.width,_.measured.height]]),N=[],$=void 0;for(const[z,j]of T)if(j.parentId===t&&(N.push({id:z,position:{...j.position},extent:j.extent}),j.extent==="parent"||j.expandParent)){const R=Cp(j,m,j.origin??E);$?$=[[Math.min(R[0][0],$[0][0]),Math.min(R[0][1],$[0][1])],[Math.max(R[1][0],$[1][0]),Math.max(R[1][1],$[1][1])]]:$=R}h==null||h(S,{...p})}).on("drag",S=>{const{transform:T,snapGrid:H,snapToGrid:v,nodeOrigin:I}=n(),E=mt(S.sourceEvent,{transform:T,snapGrid:H,snapToGrid:v,containerBounds:w}),A=[];if(!m)return;const{x:L,y:C,width:z,height:j}=p,R={},F=m.origin??I,{width:Y,height:U,x:Q,y:q}=Mp(b,s.controlDirection,E,s.boundaries,s.keepAspectRatio,F,k,$),O=Y!==z,B=U!==j,Z=Q!==L&&O,K=q!==C&&B;if(!Z&&!K&&!O&&!B)return;if((Z||K||F[0]===1||F[1]===1)&&(R.x=Z?Q:p.x,R.y=K?q:p.y,p.x=R.x,p.y=R.y,N.length>0)){const te=Q-L,ne=q-C;for(const ie of N)ie.position={x:ie.position.x-te+F[0]*(Y-z),y:ie.position.y-ne+F[1]*(U-j)},A.push(ie)}if((O||B)&&(R.width=O&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:p.width,R.height=B&&(!s.resizeDirection||s.resizeDirection==="vertical")?U:p.height,p.width=R.width,p.height=R.height),_&&m.expandParent){const te=F[0]*(R.width??0);R.x&&R.x<te&&(p.x=te,b.x=b.x-(R.x-te));const ne=F[1]*(R.height??0);R.y&&R.y<ne&&(p.y=ne,b.y=b.y-(R.y-ne))}const G=Sp({width:p.width,prevWidth:z,height:p.height,prevHeight:j,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),X={...p,direction:G};(y==null?void 0:y(S,X))!==!1&&(P=!0,g==null||g(S,X),r(R,A))}).on("end",S=>{P&&(x==null||x(S,{...p}),o==null||o({...p}),P=!1)});i.call(V)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var jn={exports:{}},Hn={},Vn={exports:{}},Bn={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* use-sync-external-store-shim.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var $o;function Ap(){if($o)return Bn;$o=1;var e=ci();function t(l,f){return l===f&&(l!==0||1/l===1/f)||l!==l&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(l,f){var h=f(),g=r({inst:{value:h,getSnapshot:f}}),x=g[0].inst,y=g[1];return i(function(){x.value=h,x.getSnapshot=f,c(x)&&y({inst:x})},[l,h,f]),o(function(){return c(x)&&y({inst:x}),l(function(){c(x)&&y({inst:x})})},[l]),s(h),h}function c(l){var f=l.getSnapshot;l=l.value;try{var h=f();return!n(l,h)}catch{return!0}}function u(l,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:a;return Bn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,Bn}var Po;function $p(){return Po||(Po=1,Vn.exports=Ap()),Vn.exports}/**
|
|
10
|
+
* @license React
|
|
11
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var To;function Pp(){if(To)return Hn;To=1;var e=ci(),t=$p();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,c=e.useDebugValue;return Hn.useSyncExternalStoreWithSelector=function(u,d,l,f,h){var g=i(null);if(g.current===null){var x={hasValue:!1,value:null};g.current=x}else x=g.current;g=a(function(){function p(_){if(!b){if(b=!0,m=_,_=f(_),h!==void 0&&x.hasValue){var k=x.value;if(h(k,_))return w=k}return w=_}if(k=w,r(m,_))return k;var $=f(_);return h!==void 0&&h(k,$)?(m=_,k):(m=_,w=$)}var b=!1,m,w,N=l===void 0?null:l;return[function(){return p(d())},N===null?void 0:function(){return p(N())}]},[d,l,f,h]);var y=o(u,g[0],g[1]);return s(function(){x.hasValue=!0,x.value=y},[y]),c(y),y},Hn}var Lo;function Tp(){return Lo||(Lo=1,jn.exports=Pp()),jn.exports}var Lp=Tp();const Dp=Sc(Lp),Op={},Do=e=>{let t;const n=new Set,r=(d,l)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=l??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},o=()=>t,c={setState:r,getState:o,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(Op?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,o,c);return c},Rp=e=>e?Do(e):Do,{useDebugValue:zp}=Mc,{useSyncExternalStoreWithSelector:jp}=Dp,Hp=e=>e;function Vs(e,t=Hp,n){const r=jp(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return zp(r),r}const Oo=(e,t)=>{const n=Rp(e),r=(o,i=t)=>Vs(n,o,i);return Object.assign(r,n),r},Vp=(e,t)=>e?Oo(e,t):Oo;function re(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,o]of e)if(!Object.is(o,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 vn=D.createContext(null),Bp=vn.Provider,Bs=ye.error001("react");function ee(e,t){const n=D.useContext(vn);if(n===null)throw new Error(Bs);return Vs(n,e,t)}function oe(){const e=D.useContext(vn);if(e===null)throw new Error(Bs);return D.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Ro={display:"none"},Fp={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Fs="react-flow__node-desc",Ys="react-flow__edge-desc",Yp="react-flow__aria-live",Xp=e=>e.ariaLiveMessage,Wp=e=>e.ariaLabelConfig;function Gp({rfId:e}){const t=ee(Xp);return M.jsx("div",{id:`${Yp}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Fp,children:t})}function qp({rfId:e,disableKeyboardA11y:t}){const n=ee(Wp);return M.jsxs(M.Fragment,{children:[M.jsx("div",{id:`${Fs}-${e}`,style:Ro,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),M.jsx("div",{id:`${Ys}-${e}`,style:Ro,children:n["edge.a11yDescription.default"]}),!t&&M.jsx(Gp,{rfId:e})]})}const bn=D.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},i)=>{const s=`${e}`.split("-");return M.jsx("div",{className:se(["react-flow__panel",n,...s]),style:r,ref:i,...o,children:t})});bn.displayName="Panel";const zo="https://reactflow.dev?utm_source=attribution";function Up({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:M.jsx(bn,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${zo}`,children:M.jsx("a",{href:zo,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Kp=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}},Bt=e=>e.id;function Zp(e,t){return re(e.selectedNodes.map(Bt),t.selectedNodes.map(Bt))&&re(e.selectedEdges.map(Bt),t.selectedEdges.map(Bt))}function Qp({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:r}=ee(Kp,Zp);return D.useEffect(()=>{const o={nodes:n,edges:r};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,r,e]),null}const Jp=e=>!!e.onSelectionChangeHandlers;function e0({onSelectionChange:e}){const t=ee(Jp);return e||t?M.jsx(Qp,{onSelectionChange:e}):null}const Xs=[0,0],t0={x:0,y:0,zoom:1},n0=["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"],jo=[...n0,"rfId"],r0=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}),Ho={translateExtent:_t,nodeOrigin:Xs,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function o0(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=ee(r0,re),u=oe();D.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=Ho,a()}),[]);const d=D.useRef(Ho);return D.useEffect(()=>{for(const l of jo){const f=e[l],h=d.current[l];f!==h&&(typeof e[l]>"u"||(l==="nodes"?t(f):l==="edges"?n(f):l==="minZoom"?r(f):l==="maxZoom"?o(f):l==="translateExtent"?i(f):l==="nodeExtent"?s(f):l==="ariaLabelConfig"?u.setState({ariaLabelConfig:Bg(f)}):l==="fitView"?u.setState({fitViewQueued:f}):l==="fitViewOptions"?u.setState({fitViewOptions:f}):u.setState({[l]:f})))}d.current=e},jo.map(l=>e[l])),null}function Vo(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function i0(e){var r;const[t,n]=D.useState(e==="system"?null:e);return D.useEffect(()=>{if(e!=="system"){n(e);return}const o=Vo(),i=()=>n(o!=null&&o.matches?"dark":"light");return i(),o==null||o.addEventListener("change",i),()=>{o==null||o.removeEventListener("change",i)}},[e]),t!==null?t:(r=Vo())!=null&&r.matches?"dark":"light"}const Bo=typeof document<"u"?document:null;function Mt(e=null,t={target:Bo,actInsideInputWithModifier:!0}){const[n,r]=D.useState(!1),o=D.useRef(!1),i=D.useRef(new Set([])),[s,a]=D.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(l=>typeof l=="string").map(l=>l.replace("+",`
|
|
18
|
+
`).replace(`
|
|
19
|
+
|
|
20
|
+
`,`
|
|
21
|
+
+`).split(`
|
|
22
|
+
`)),d=u.reduce((l,f)=>l.concat(...f),[]);return[u,d]}return[[],[]]},[e]);return D.useEffect(()=>{const c=(t==null?void 0:t.target)??Bo,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=h=>{var y,p;if(o.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!o.current||o.current&&!u)&&Ns(h))return!1;const x=Yo(h.code,a);if(i.current.add(h[x]),Fo(s,i.current,!1)){const b=((p=(y=h.composedPath)==null?void 0:y.call(h))==null?void 0:p[0])||h.target,m=(b==null?void 0:b.nodeName)==="BUTTON"||(b==null?void 0:b.nodeName)==="A";t.preventDefault!==!1&&(o.current||!m)&&h.preventDefault(),r(!0)}},l=h=>{const g=Yo(h.code,a);Fo(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[g]),h.key==="Meta"&&i.current.clear(),o.current=!1},f=()=>{i.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",d),c==null||c.addEventListener("keyup",l),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",d),c==null||c.removeEventListener("keyup",l),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function Fo(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function Yo(e,t){return t.includes(e)?"code":"key"}const s0=()=>{const e=oe();return D.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,o,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??r,y:t.y??o,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:o,minZoom:i,maxZoom:s,panZoom:a}=e.getState(),c=_r(t,r,o,i,s,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(c,{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:o,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:a,y:c}=s.getBoundingClientRect(),u={x:t.x-a,y:t.y-c},d=n.snapGrid??o,l=n.snapToGrid??i;return Tt(u,r,l,d)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:i}=r.getBoundingClientRect(),s=it(t,n);return{x:s.x+o,y:s.y+i}}}),[])};function Ws(e,t){const n=[],r=new Map,o=[];for(const i of e)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const s=r.get(i.id);s?s.push(i):r.set(i.id,[i])}for(const i of t){const s=r.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const a={...i};for(const c of s)a0(c,a);n.push(a)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function a0(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 c0(e,t){return Ws(e,t)}function u0(e,t){return Ws(e,t)}function je(e,t){return{id:e,type:"select",selected:t}}function Ze(e,t=new Set,n=!1){const r=[];for(const[o,i]of e){const s=t.has(o);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),r.push(je(i.id,s)))}return r}function Xo({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,s]of e.entries()){const a=t.get(s.id),c=((o=a==null?void 0:a.internals)==null?void 0:o.userNode)??a;c!==void 0&&c!==s&&n.push({id:s.id,item:s,type:"replace"}),c===void 0&&n.push({item:s,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function Wo(e){return{id:e.id,type:"remove"}}const l0=vs();function d0(e,t,n={}){return qg(e,t,{...n,onError:n.onError??l0})}const Go=e=>Tg(e),f0=e=>ps(e);function Gs(e){return D.forwardRef(e)}const h0=typeof window<"u"?D.useLayoutEffect:D.useEffect;function qo(e){const[t,n]=D.useState(BigInt(0)),[r]=D.useState(()=>g0(()=>n(o=>o+BigInt(1))));return h0(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function g0(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const qs=D.createContext(null);function p0({children:e}){const t=oe(),n=D.useCallback(a=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:d,onNodesChange:l,nodeLookup:f,fitViewQueued:h,onNodesChangeMiddlewareMap:g}=t.getState();let x=c;for(const p of a)x=typeof p=="function"?p(x):p;let y=Xo({items:x,lookup:f});for(const p of g.values())y=p(y);d&&u(x),y.length>0?l==null||l(y):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:p,nodes:b,setNodes:m}=t.getState();p&&m(b)})},[]),r=qo(n),o=D.useCallback(a=>{const{edges:c=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:l,edgeLookup:f}=t.getState();let h=c;for(const g of a)h=typeof g=="function"?g(h):g;d?u(h):l&&l(Xo({items:h,lookup:f}))},[]),i=qo(o),s=D.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return M.jsx(qs.Provider,{value:s,children:e})}function m0(){const e=D.useContext(qs);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const y0=e=>!!e.panZoom;function Ir(){const e=s0(),t=oe(),n=m0(),r=ee(y0),o=D.useMemo(()=>{const i=l=>t.getState().nodeLookup.get(l),s=l=>{n.nodeQueue.push(l)},a=l=>{n.edgeQueue.push(l)},c=l=>{var p,b;const{nodeLookup:f,nodeOrigin:h}=t.getState(),g=Go(l)?l:f.get(l.id),x=g.parentId?_s(g.position,g.measured,g.parentId,f,h):g.position,y={...g,position:x,width:((p=g.measured)==null?void 0:p.width)??g.width,height:((b=g.measured)==null?void 0:b.height)??g.height};return Nt(y)},u=(l,f,h={replace:!1})=>{s(g=>g.map(x=>{if(x.id===l){const y=typeof f=="function"?f(x):f;return h.replace&&Go(y)?y:{...x,...y}}return x}))},d=(l,f,h={replace:!1})=>{a(g=>g.map(x=>{if(x.id===l){const y=typeof f=="function"?f(x):f;return h.replace&&f0(y)?y:{...x,...y}}return x}))};return{getNodes:()=>t.getState().nodes.map(l=>({...l})),getNode:l=>{var f;return(f=i(l))==null?void 0:f.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:l=[]}=t.getState();return l.map(f=>({...f}))},getEdge:l=>t.getState().edgeLookup.get(l),setNodes:s,setEdges:a,addNodes:l=>{const f=Array.isArray(l)?l:[l];n.nodeQueue.push(h=>[...h,...f])},addEdges:l=>{const f=Array.isArray(l)?l:[l];n.edgeQueue.push(h=>[...h,...f])},toObject:()=>{const{nodes:l=[],edges:f=[],transform:h}=t.getState(),[g,x,y]=h;return{nodes:l.map(p=>({...p})),edges:f.map(p=>({...p})),viewport:{x:g,y:x,zoom:y}}},deleteElements:async({nodes:l=[],edges:f=[]})=>{const{nodes:h,edges:g,onNodesDelete:x,onEdgesDelete:y,triggerNodeChanges:p,triggerEdgeChanges:b,onDelete:m,onBeforeDelete:w}=t.getState(),{nodes:N,edges:_}=await zg({nodesToRemove:l,edgesToRemove:f,nodes:h,edges:g,onBeforeDelete:w}),k=_.length>0,$=N.length>0;if(k){const P=_.map(Wo);y==null||y(_),b(P)}if($){const P=N.map(Wo);x==null||x(N),p(P)}return($||k)&&(m==null||m({nodes:N,edges:_})),{deletedNodes:N,deletedEdges:_}},getIntersectingNodes:(l,f=!0,h)=>{const g=xo(l),x=g?l:c(l),y=h!==void 0;return x?(h||t.getState().nodes).filter(p=>{const b=t.getState().nodeLookup.get(p.id);if(b&&!g&&(p.id===l.id||!b.internals.positionAbsolute))return!1;const m=Nt(y?p:b),w=cn(m,x);return f&&w>0||w>=m.width*m.height||w>=x.width*x.height}):[]},isNodeIntersecting:(l,f,h=!0)=>{const x=xo(l)?l:c(l);if(!x)return!1;const y=cn(x,f);return h&&y>0||y>=f.width*f.height||y>=x.width*x.height},updateNode:u,updateNodeData:(l,f,h={replace:!1})=>{u(l,g=>{const x=typeof f=="function"?f(g):f;return h.replace?{...g,data:x}:{...g,data:{...g.data,...x}}},h)},updateEdge:d,updateEdgeData:(l,f,h={replace:!1})=>{d(l,g=>{const x=typeof f=="function"?f(g):f;return h.replace?{...g,data:x}:{...g,data:{...g.data,...x}}},h)},getNodesBounds:l=>{const{nodeLookup:f,nodeOrigin:h}=t.getState();return Lg(l,{nodeLookup:f,nodeOrigin:h})},getHandleConnections:({type:l,id:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}-${l}${f?`-${f}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:l,handleId:f,nodeId:h})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${h}${l?f?`-${l}-${f}`:`-${l}`:""}`))==null?void 0:g.values())??[])},fitView:async l=>{const f=t.getState().fitViewResolver??Vg();return t.setState({fitViewQueued:!0,fitViewOptions:l,fitViewResolver:f}),n.nodeQueue.push(h=>[...h]),f.promise}}},[]);return D.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const Uo=e=>e.selected,x0=typeof window<"u"?window:void 0;function w0({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=oe(),{deleteElements:r}=Ir(),o=Mt(e,{actInsideInputWithModifier:!1}),i=Mt(t,{target:x0});D.useEffect(()=>{if(o){const{edges:s,nodes:a}=n.getState();r({nodes:a.filter(Uo),edges:s.filter(Uo)}),n.setState({nodesSelectionActive:!1})}},[o]),D.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function v0(e){const t=oe();D.useEffect(()=>{const n=()=>{var o,i,s,a;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const r=Er(e.current);(r.height===0||r.width===0)&&((a=(s=t.getState()).onError)==null||a.call(s,"004",ye.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 _n={position:"absolute",width:"100%",height:"100%",top:0,left:0},b0=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function _0({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:o=.5,panOnScrollMode:i=Be.Free,zoomOnDoubleClick:s=!0,panOnDrag:a=!0,defaultViewport:c,translateExtent:u,minZoom:d,maxZoom:l,zoomActivationKeyCode:f,preventScrolling:h=!0,children:g,noWheelClassName:x,noPanClassName:y,onViewportChange:p,isControlledViewport:b,paneClickDistance:m,selectionOnDrag:w}){const N=oe(),_=D.useRef(null),{userSelectionActive:k,lib:$,connectionInProgress:P}=ee(b0,re),V=Mt(f),S=D.useRef();v0(_);const T=D.useCallback(H=>{p==null||p({x:H[0],y:H[1],zoom:H[2]}),b||N.setState({transform:H})},[p,b]);return D.useEffect(()=>{if(_.current){S.current=Np({domNode:_.current,minZoom:d,maxZoom:l,translateExtent:u,viewport:c,onDraggingChange:E=>N.setState(A=>A.paneDragging===E?A:{paneDragging:E}),onPanZoomStart:(E,A)=>{const{onViewportChangeStart:L,onMoveStart:C}=N.getState();C==null||C(E,A),L==null||L(A)},onPanZoom:(E,A)=>{const{onViewportChange:L,onMove:C}=N.getState();C==null||C(E,A),L==null||L(A)},onPanZoomEnd:(E,A)=>{const{onViewportChangeEnd:L,onMoveEnd:C}=N.getState();C==null||C(E,A),L==null||L(A)}});const{x:H,y:v,zoom:I}=S.current.getViewport();return N.setState({panZoom:S.current,transform:[H,v,I],domNode:_.current.closest(".react-flow")}),()=>{var E;(E=S.current)==null||E.destroy()}}},[]),D.useEffect(()=>{var H;(H=S.current)==null||H.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:o,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:a,zoomActivationKeyPressed:V,preventScrolling:h,noPanClassName:y,userSelectionActive:k,noWheelClassName:x,lib:$,onTransformChange:T,connectionInProgress:P,selectionOnDrag:w,paneClickDistance:m})},[e,t,n,r,o,i,s,a,V,h,y,k,x,$,T,P,w,m]),M.jsx("div",{className:"react-flow__renderer",ref:_,style:_n,children:g})}const E0=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function N0(){const{userSelectionActive:e,userSelectionRect:t}=ee(E0,re);return e&&t?M.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 Fn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},S0=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function M0({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Et.Full,panOnDrag:r,autoPanOnSelection:o,paneClickDistance:i,selectionOnDrag:s,onSelectionStart:a,onSelectionEnd:c,onPaneClick:u,onPaneContextMenu:d,onPaneScroll:l,onPaneMouseEnter:f,onPaneMouseMove:h,onPaneMouseLeave:g,children:x}){const y=D.useRef(0),p=oe(),{userSelectionActive:b,elementsSelectable:m,dragging:w,panBy:N,autoPanSpeed:_}=ee(S0,re),k=m&&(e||b),$=D.useRef(null),P=D.useRef(),V=D.useRef(new Set),S=D.useRef(new Set),T=D.useRef(!1),H=D.useRef(!1),v=D.useRef({x:0,y:0}),I=D.useRef(!1),E=O=>{if(H.current||T.current||p.getState().connection.inProgress){H.current=!1,T.current=!1;return}u==null||u(O),p.getState().resetSelectedElements(),p.setState({nodesSelectionActive:!1})},A=O=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){O.preventDefault();return}d==null||d(O)},L=l?O=>l(O):void 0,C=O=>{H.current&&(O.stopPropagation(),H.current=!1)},z=O=>{var ie,le;const{domNode:B,transform:Z}=p.getState();if(P.current=B==null?void 0:B.getBoundingClientRect(),!P.current)return;const K=O.target===$.current;if(!K&&!!O.target.closest(".nokey")||!e||!(s&&K||t)||O.button!==0||!O.isPrimary)return;(le=(ie=O.target)==null?void 0:ie.setPointerCapture)==null||le.call(ie,O.pointerId),H.current=!1;const{x:J,y:te}=me(O.nativeEvent,P.current),ne=Tt({x:J,y:te},Z);p.setState({userSelectionRect:{width:0,height:0,startX:ne.x,startY:ne.y,x:J,y:te}}),K||(O.stopPropagation(),O.preventDefault())};function j(O,B){const{userSelectionRect:Z}=p.getState();if(!Z)return;const{transform:K,nodeLookup:G,edgeLookup:X,connectionLookup:J,triggerNodeChanges:te,triggerEdgeChanges:ne,defaultEdgeOptions:ie}=p.getState(),le={x:Z.startX,y:Z.startY},{x:we,y:ve}=it(le,K),Se={startX:le.x,startY:le.y,x:O<we?O:we,y:B<ve?B:ve,width:Math.abs(O-we),height:Math.abs(B-ve)},ut=V.current,Oe=S.current;V.current=new Set(vr(G,Se,K,n===Et.Partial,!0).map(fe=>fe.id)),S.current=new Set;const Re=(ie==null?void 0:ie.selectable)??!0;for(const fe of V.current){const Me=J.get(fe);if(Me)for(const{edgeId:ke}of Me.values()){const ze=X.get(ke);ze&&(ze.selectable??Re)&&S.current.add(ke)}}if(!wo(ut,V.current)){const fe=Ze(G,V.current,!0);te(fe)}if(!wo(Oe,S.current)){const fe=Ze(X,S.current);ne(fe)}p.setState({userSelectionRect:Se,userSelectionActive:!0,nodesSelectionActive:!1})}function R(){if(!o||!P.current)return;const[O,B]=br(v.current,P.current,_);N({x:O,y:B}).then(Z=>{if(!H.current||!Z){y.current=requestAnimationFrame(R);return}const{x:K,y:G}=v.current;j(K,G),y.current=requestAnimationFrame(R)})}const F=()=>{cancelAnimationFrame(y.current),y.current=0,I.current=!1};D.useEffect(()=>()=>F(),[]);const Y=O=>{const{userSelectionRect:B,transform:Z,resetSelectedElements:K}=p.getState();if(!P.current||!B)return;const{x:G,y:X}=me(O.nativeEvent,P.current);v.current={x:G,y:X};const J=it({x:B.startX,y:B.startY},Z);if(!H.current){const te=t?0:i;if(Math.hypot(G-J.x,X-J.y)<=te)return;K(),a==null||a(O)}H.current=!0,I.current||(R(),I.current=!0),j(G,X)},U=O=>{var B,Z;if(!k){O.target===$.current&&p.getState().connection.inProgress&&(T.current=!0);return}O.button===0&&((Z=(B=O.target)==null?void 0:B.releasePointerCapture)==null||Z.call(B,O.pointerId),!b&&O.target===$.current&&p.getState().userSelectionRect&&(E==null||E(O)),p.setState({userSelectionActive:!1,userSelectionRect:null}),H.current&&(c==null||c(O),p.setState({nodesSelectionActive:V.current.size>0})),F())},Q=O=>{var B,Z;(Z=(B=O.target)==null?void 0:B.releasePointerCapture)==null||Z.call(B,O.pointerId),F()},q=r===!0||Array.isArray(r)&&r.includes(0);return M.jsxs("div",{className:se(["react-flow__pane",{draggable:q,dragging:w,selection:e}]),onClick:k?void 0:Fn(E,$),onContextMenu:Fn(A,$),onWheel:Fn(L,$),onPointerEnter:k?void 0:f,onPointerMove:k?Y:h,onPointerUp:U,onPointerCancel:k?Q:void 0,onPointerDownCapture:k?z:void 0,onClickCapture:k?C:void 0,onPointerLeave:g,ref:$,style:_n,children:[x,M.jsx(N0,{})]})}function ir({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),u=a.get(e);if(!u){c==null||c("012",ye.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&s)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):o([e])}function Us({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:i,nodeClickDistance:s}){const a=oe(),[c,u]=D.useState(!1),d=D.useRef();return D.useEffect(()=>{d.current=lp({getStoreItems:()=>a.getState(),onNodeMouseDown:l=>{ir({id:l,store:a,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),D.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:s}),()=>{var l;(l=d.current)==null||l.destroy()}},[n,r,t,i,e,o,s]),c}const k0=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Ks(){const e=oe();return D.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:i,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:u,nodeOrigin:d}=e.getState(),l=new Map,f=k0(s),h=o?i[0]:5,g=o?i[1]:5,x=n.direction.x*h*n.factor,y=n.direction.y*g*n.factor;for(const[,p]of u){if(!f(p))continue;let b={x:p.internals.positionAbsolute.x+x,y:p.internals.positionAbsolute.y+y};o&&(b=Pt(b,i));const{position:m,positionAbsolute:w}=ms({nodeId:p.id,nextPosition:b,nodeLookup:u,nodeExtent:r,nodeOrigin:d,onError:a});p.position=m,p.internals.positionAbsolute=w,l.set(p.id,p)}c(l)},[])}const Ar=D.createContext(null),C0=Ar.Provider;Ar.Consumer;const Zs=()=>D.useContext(Ar),I0=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Qs=D.createContext(null);function A0({children:e}){const t=ee(I0,re);return M.jsx(Qs.Provider,{value:t,children:e})}function $0(){const e=D.useContext(Qs);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const P0={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},T0=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:i,connection:s}=r,{fromHandle:a,toHandle:c,isValid:u}=s;if(!a&&!o)return P0;const d=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:d,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===rt.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:!!o,valid:d&&u}};function L0({type:e="source",position:t=W.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:s,onConnect:a,children:c,className:u,onMouseDown:d,onTouchStart:l,...f},h){var I,E;const g=s||null,x=e==="target",y=oe(),p=Zs(),{connectOnClick:b,noPanClassName:m,rfId:w}=$0(),{connectingFrom:N,connectingTo:_,clickConnecting:k,isPossibleEndHandle:$,connectionInProcess:P,clickConnectionInProcess:V,valid:S}=ee(T0(p,g,e),re);p||(E=(I=y.getState()).onError)==null||E.call(I,"010",ye.error010());const T=A=>{const{defaultEdgeOptions:L,onConnect:C,hasDefaultEdges:z}=y.getState(),j={...L,...A};if(z){const{edges:R,setEdges:F,onError:Y}=y.getState();F(d0(j,R,{onError:Y}))}C==null||C(j),a==null||a(j)},H=A=>{if(!p)return;const L=Ss(A.nativeEvent);if(o&&(L&&A.button===0||!L)){const C=y.getState();or.onPointerDown(A.nativeEvent,{handleDomNode:A.currentTarget,autoPanOnConnect:C.autoPanOnConnect,connectionMode:C.connectionMode,connectionRadius:C.connectionRadius,domNode:C.domNode,nodeLookup:C.nodeLookup,lib:C.lib,isTarget:x,handleId:g,nodeId:p,flowId:C.rfId,panBy:C.panBy,cancelConnection:C.cancelConnection,onConnectStart:C.onConnectStart,onConnectEnd:(...z)=>{var j,R;return(R=(j=y.getState()).onConnectEnd)==null?void 0:R.call(j,...z)},updateConnection:C.updateConnection,onConnect:T,isValidConnection:n||((...z)=>{var j,R;return((R=(j=y.getState()).isValidConnection)==null?void 0:R.call(j,...z))??!0}),getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,autoPanSpeed:C.autoPanSpeed,dragThreshold:C.connectionDragThreshold})}L?d==null||d(A):l==null||l(A)},v=A=>{const{onClickConnectStart:L,onClickConnectEnd:C,connectionClickStartHandle:z,connectionMode:j,isValidConnection:R,lib:F,rfId:Y,nodeLookup:U,connection:Q}=y.getState();if(!p||!z&&!o)return;if(!z){L==null||L(A.nativeEvent,{nodeId:p,handleId:g,handleType:e}),y.setState({connectionClickStartHandle:{nodeId:p,type:e,id:g}});return}const q=Es(A.target),O=n||R,{connection:B,isValid:Z}=or.isValid(A.nativeEvent,{handle:{nodeId:p,id:g,type:e},connectionMode:j,fromNodeId:z.nodeId,fromHandleId:z.id||null,fromType:z.type,isValidConnection:O,flowId:Y,doc:q,lib:F,nodeLookup:U});Z&&B&&T(B);const K=structuredClone(Q);delete K.inProgress,K.toPosition=K.toHandle?K.toHandle.position:null,C==null||C(A,K),y.setState({connectionClickStartHandle:null})};return M.jsx("div",{"data-handleid":g,"data-nodeid":p,"data-handlepos":t,"data-id":`${w}-${p}-${g}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",m,u,{source:!x,target:x,connectable:r,connectablestart:o,connectableend:i,clickconnecting:k,connectingfrom:N,connectingto:_,valid:S,connectionindicator:r&&(!P||$)&&(P||V?i:o)}]),onMouseDown:H,onTouchStart:H,onClick:b?v:void 0,ref:h,...f,children:c})}const at=D.memo(Gs(L0));function D0({data:e,isConnectable:t,sourcePosition:n=W.Bottom}){return M.jsxs(M.Fragment,{children:[e==null?void 0:e.label,M.jsx(at,{type:"source",position:n,isConnectable:t})]})}function O0({data:e,isConnectable:t,targetPosition:n=W.Top,sourcePosition:r=W.Bottom}){return M.jsxs(M.Fragment,{children:[M.jsx(at,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,M.jsx(at,{type:"source",position:r,isConnectable:t})]})}function R0(){return null}function z0({data:e,isConnectable:t,targetPosition:n=W.Top}){return M.jsxs(M.Fragment,{children:[M.jsx(at,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const un={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Ko={input:D0,default:O0,output:z0,group:R0};function j0(e){var t,n,r,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const H0=e=>{const{width:t,height:n,x:r,y:o}=$t(e.nodeLookup,{filter:i=>!!i.selected});return{width:pe(t)?t:null,height:pe(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function V0({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=oe(),{width:o,height:i,transformString:s,userSelectionActive:a}=ee(H0,re),c=Ks(),u=D.useRef(null);D.useEffect(()=>{var h;n||(h=u.current)==null||h.focus({preventScroll:!0})},[n]);const d=!a&&o!==null&&i!==null;if(Us({nodeRef:u,disabled:!d}),!d)return null;const l=e?h=>{const g=r.getState().nodes.filter(x=>x.selected);e(h,g)}:void 0,f=h=>{Object.prototype.hasOwnProperty.call(un,h.key)&&(h.preventDefault(),c({direction:un[h.key],factor:h.shiftKey?4:1}))};return M.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:M.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:l,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:o,height:i}})})}const Zo=typeof window<"u"?window:void 0,B0=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Js({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:d,selectionMode:l,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:g,panActivationKeyCode:x,zoomActivationKeyCode:y,elementsSelectable:p,zoomOnScroll:b,zoomOnPinch:m,panOnScroll:w,panOnScrollSpeed:N,panOnScrollMode:_,zoomOnDoubleClick:k,panOnDrag:$,autoPanOnSelection:P,defaultViewport:V,translateExtent:S,minZoom:T,maxZoom:H,preventScrolling:v,onSelectionContextMenu:I,noWheelClassName:E,noPanClassName:A,disableKeyboardA11y:L,onViewportChange:C,isControlledViewport:z}){const{nodesSelectionActive:j,userSelectionActive:R}=ee(B0,re),F=Mt(u,{target:Zo}),Y=Mt(x,{target:Zo}),U=Y||$,Q=Y||w,q=d&&U!==!0,O=F||R||q;return w0({deleteKeyCode:c,multiSelectionKeyCode:g}),M.jsx(_0,{onPaneContextMenu:i,elementsSelectable:p,zoomOnScroll:b,zoomOnPinch:m,panOnScroll:Q,panOnScrollSpeed:N,panOnScrollMode:_,zoomOnDoubleClick:k,panOnDrag:!F&&U,defaultViewport:V,translateExtent:S,minZoom:T,maxZoom:H,zoomActivationKeyCode:y,preventScrolling:v,noWheelClassName:E,noPanClassName:A,onViewportChange:C,isControlledViewport:z,paneClickDistance:a,selectionOnDrag:q,children:M.jsxs(M0,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:U,autoPanOnSelection:P,isSelecting:!!O,selectionMode:l,selectionKeyPressed:F,paneClickDistance:a,selectionOnDrag:q,children:[e,j&&M.jsx(V0,{onSelectionContextMenu:I,noPanClassName:A,disableKeyboardA11y:L})]})})}Js.displayName="FlowRenderer";const F0=D.memo(Js),Y0=e=>t=>e?vr(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 X0(e){return ee(D.useCallback(Y0(e),[e]),re)}const W0=e=>e.updateNodeInternals;function G0(){const e=ee(W0),[t]=D.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:o.target,force:!0})}),e(r)}));return D.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function q0({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=oe(),i=D.useRef(null),s=D.useRef(null),a=D.useRef(e.sourcePosition),c=D.useRef(e.targetPosition),u=D.useRef(t),d=n&&!!e.internals.handleBounds;return D.useEffect(()=>{i.current&&!e.hidden&&(!d||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[d,e.hidden]),D.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),D.useEffect(()=>{if(i.current){const l=u.current!==t,f=a.current!==e.sourcePosition,h=c.current!==e.targetPosition;(l||f||h)&&(u.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function U0({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:i,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:u,nodesFocusable:d,resizeObserver:l,noDragClassName:f,noPanClassName:h,disableKeyboardA11y:g,rfId:x,nodeTypes:y,nodeClickDistance:p,onError:b}){const{node:m,internals:w,isParent:N}=ee(O=>{const B=O.nodeLookup.get(e),Z=O.parentLookup.has(e);return{node:B,internals:B.internals,isParent:Z}},re);let _=m.type||"default",k=(y==null?void 0:y[_])||Ko[_];k===void 0&&(b==null||b("003",ye.error003(_)),_="default",k=(y==null?void 0:y.default)||Ko.default);const $=!!(m.draggable||a&&typeof m.draggable>"u"),P=!!(m.selectable||c&&typeof m.selectable>"u"),V=!!(m.connectable||u&&typeof m.connectable>"u"),S=!!(m.focusable||d&&typeof m.focusable>"u"),T=oe(),H=bs(m),v=q0({node:m,nodeType:_,hasDimensions:H,resizeObserver:l}),I=Us({nodeRef:v,disabled:m.hidden||!$,noDragClassName:f,handleSelector:m.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:p}),E=Ks();if(m.hidden)return null;const A=$e(m),L=j0(m),C=P||$||t||n||r||o,z=n?O=>n(O,{...w.userNode}):void 0,j=r?O=>r(O,{...w.userNode}):void 0,R=o?O=>o(O,{...w.userNode}):void 0,F=i?O=>i(O,{...w.userNode}):void 0,Y=s?O=>s(O,{...w.userNode}):void 0,U=O=>{const{selectNodesOnDrag:B,nodeDragThreshold:Z}=T.getState();P&&(!B||!$||Z>0)&&ir({id:e,store:T,nodeRef:v}),t&&t(O,{...w.userNode})},Q=O=>{if(!(Ns(O.nativeEvent)||g)){if(ds.includes(O.key)&&P){const B=O.key==="Escape";ir({id:e,store:T,unselect:B,nodeRef:v})}else if($&&m.selected&&Object.prototype.hasOwnProperty.call(un,O.key)){O.preventDefault();const{ariaLabelConfig:B}=T.getState();T.setState({ariaLiveMessage:B["node.a11yDescription.ariaLiveMessage"]({direction:O.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),E({direction:un[O.key],factor:O.shiftKey?4:1})}}},q=()=>{var J;if(g||!((J=v.current)!=null&&J.matches(":focus-visible")))return;const{transform:O,width:B,height:Z,autoPanOnNodeFocus:K,setCenter:G}=T.getState();if(!K)return;vr(new Map([[e,m]]),{x:0,y:0,width:B,height:Z},O,!0).length>0||G(m.position.x+A.width/2,m.position.y+A.height/2,{zoom:O[2]})};return M.jsx("div",{className:se(["react-flow__node",`react-flow__node-${_}`,{[h]:$},m.className,{selected:m.selected,selectable:P,parent:N,draggable:$,dragging:I}]),ref:v,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:C?"all":"none",visibility:H?"visible":"hidden",...m.style,...L},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:z,onMouseMove:j,onMouseLeave:R,onContextMenu:F,onClick:U,onDoubleClick:Y,onKeyDown:S?Q:void 0,tabIndex:S?0:void 0,onFocus:S?q:void 0,role:m.ariaRole??(S?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${Fs}-${x}`,"aria-label":m.ariaLabel,...m.domAttributes,children:M.jsx(C0,{value:e,children:M.jsx(k,{id:e,data:m.data,type:_,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:m.selected??!1,selectable:P,draggable:$,deletable:m.deletable??!0,isConnectable:V,sourcePosition:m.sourcePosition,targetPosition:m.targetPosition,dragging:I,dragHandle:m.dragHandle,zIndex:w.z,parentId:m.parentId,...A})})})}var K0=D.memo(U0);const Z0=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function ea(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,onError:i}=ee(Z0,re),s=X0(e.onlyRenderVisibleElements),a=G0();return M.jsx("div",{className:"react-flow__nodes",style:_n,children:s.map(c=>M.jsx(K0,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:a,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:i},c))})}ea.displayName="NodeRenderer";const Q0=D.memo(ea);function J0(e){return ee(D.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),s=n.nodeLookup.get(o.target);i&&s&&Xg({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),re)}const em=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return M.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},tm=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return M.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Qo={[sn.Arrow]:em,[sn.ArrowClosed]:tm};function nm(e){const t=oe();return D.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(Qo,e)?Qo[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",ye.error009(e)),null)},[e])}const rm=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const c=nm(t);return c?M.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:a,refX:"0",refY:"0",children:M.jsx(c,{color:n,strokeWidth:s})}):null},ta=({defaultColor:e,rfId:t})=>{const n=ee(i=>i.edges),r=ee(i=>i.defaultEdgeOptions),o=D.useMemo(()=>Jg(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?M.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:M.jsx("defs",{children:o.map(i=>M.jsx(rm,{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};ta.displayName="MarkerDefinitions";var om=D.memo(ta);function na({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:u,...d}){const[l,f]=D.useState({x:1,y:0,width:0,height:0}),h=se(["react-flow__edge-textwrapper",u]),g=D.useRef(null);return D.useEffect(()=>{if(g.current){const x=g.current.getBBox();f({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),n?M.jsxs("g",{transform:`translate(${e-l.width/2} ${t-l.height/2})`,className:h,visibility:l.width?"visible":"hidden",...d,children:[o&&M.jsx("rect",{width:l.width+2*s[0],x:-s[0],y:-s[1],height:l.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:a,ry:a}),M.jsx("text",{className:"react-flow__edge-text",y:l.height/2,dy:"0.3em",ref:g,style:r,children:n}),c]}):null}na.displayName="EdgeText";const im=D.memo(na);function En({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:u=20,...d}){return M.jsxs(M.Fragment,{children:[M.jsx("path",{...d,d:e,fill:"none",className:se(["react-flow__edge-path",d.className])}),u?M.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&pe(t)&&pe(n)?M.jsx(im,{x:t,y:n,label:r,labelStyle:o,labelShowBg:i,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function Jo({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===W.Left||e===W.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function ra({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:o,targetPosition:i=W.Top}){const[s,a]=Jo({pos:n,x1:e,y1:t,x2:r,y2:o}),[c,u]=Jo({pos:i,x1:r,y1:o,x2:e,y2:t}),[d,l,f,h]=Ms({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:u});return[`M${e},${t} C${s},${a} ${c},${u} ${r},${o}`,d,l,f,h]}function oa(e){return D.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s,targetPosition:a,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:x,markerStart:y,interactionWidth:p})=>{const[b,m,w]=ra({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a}),N=e.isInternal?void 0:t;return M.jsx(En,{id:N,path:b,labelX:m,labelY:w,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:x,markerStart:y,interactionWidth:p})})}const sm=oa({isInternal:!1}),ia=oa({isInternal:!0});sm.displayName="SimpleBezierEdge";ia.displayName="SimpleBezierEdgeInternal";function sa(e){return D.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:l,style:f,sourcePosition:h=W.Bottom,targetPosition:g=W.Top,markerEnd:x,markerStart:y,pathOptions:p,interactionWidth:b})=>{const[m,w,N]=tr({sourceX:n,sourceY:r,sourcePosition:h,targetX:o,targetY:i,targetPosition:g,borderRadius:p==null?void 0:p.borderRadius,offset:p==null?void 0:p.offset,stepPosition:p==null?void 0:p.stepPosition}),_=e.isInternal?void 0:t;return M.jsx(En,{id:_,path:m,labelX:w,labelY:N,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:l,style:f,markerEnd:x,markerStart:y,interactionWidth:b})})}const aa=sa({isInternal:!1}),ca=sa({isInternal:!0});aa.displayName="SmoothStepEdge";ca.displayName="SmoothStepEdgeInternal";function ua(e){return D.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return M.jsx(aa,{...n,id:r,pathOptions:D.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const am=ua({isInternal:!1}),la=ua({isInternal:!0});am.displayName="StepEdge";la.displayName="StepEdgeInternal";function da(e){return D.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:l,style:f,markerEnd:h,markerStart:g,interactionWidth:x})=>{const[y,p,b]=Is({sourceX:n,sourceY:r,targetX:o,targetY:i}),m=e.isInternal?void 0:t;return M.jsx(En,{id:m,path:y,labelX:p,labelY:b,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:l,style:f,markerEnd:h,markerStart:g,interactionWidth:x})})}const cm=da({isInternal:!1}),fa=da({isInternal:!0});cm.displayName="StraightEdge";fa.displayName="StraightEdgeInternal";function ha(e){return D.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:s=W.Bottom,targetPosition:a=W.Top,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:x,markerStart:y,pathOptions:p,interactionWidth:b})=>{const[m,w,N]=ks({sourceX:n,sourceY:r,sourcePosition:s,targetX:o,targetY:i,targetPosition:a,curvature:p==null?void 0:p.curvature}),_=e.isInternal?void 0:t;return M.jsx(En,{id:_,path:m,labelX:w,labelY:N,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:g,markerEnd:x,markerStart:y,interactionWidth:b})})}const um=ha({isInternal:!1}),ga=ha({isInternal:!0});um.displayName="BezierEdge";ga.displayName="BezierEdgeInternal";const ei={default:ga,straight:fa,step:la,smoothstep:ca,simplebezier:ia},ti={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},lm=(e,t,n)=>n===W.Left?e-t:n===W.Right?e+t:e,dm=(e,t,n)=>n===W.Top?e-t:n===W.Bottom?e+t:e,ni="react-flow__edgeupdater";function ri({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:i,onMouseOut:s,type:a}){return M.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:s,className:se([ni,`${ni}-${a}`]),cx:lm(t,r,e),cy:dm(n,r,e),r,stroke:"transparent",fill:"transparent"})}function fm({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:i,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:u,onReconnectStart:d,onReconnectEnd:l,setReconnecting:f,setUpdateHover:h}){const g=oe(),x=(w,N)=>{if(w.button!==0)return;const{autoPanOnConnect:_,domNode:k,connectionMode:$,connectionRadius:P,lib:V,onConnectStart:S,cancelConnection:T,nodeLookup:H,rfId:v,panBy:I,updateConnection:E}=g.getState(),A=N.type==="target",L=(j,R)=>{f(!1),l==null||l(j,n,N.type,R)},C=j=>u==null?void 0:u(n,j),z=(j,R)=>{f(!0),d==null||d(w,n,N.type),S==null||S(j,R)};or.onPointerDown(w.nativeEvent,{autoPanOnConnect:_,connectionMode:$,connectionRadius:P,domNode:k,handleId:N.id,nodeId:N.nodeId,nodeLookup:H,isTarget:A,edgeUpdaterType:N.type,lib:V,flowId:v,cancelConnection:T,panBy:I,isValidConnection:(...j)=>{var R,F;return((F=(R=g.getState()).isValidConnection)==null?void 0:F.call(R,...j))??!0},onConnect:C,onConnectStart:z,onConnectEnd:(...j)=>{var R,F;return(F=(R=g.getState()).onConnectEnd)==null?void 0:F.call(R,...j)},onReconnectEnd:L,updateConnection:E,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},y=w=>x(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),p=w=>x(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>h(!0),m=()=>h(!1);return M.jsxs(M.Fragment,{children:[(e===!0||e==="source")&&M.jsx(ri,{position:a,centerX:r,centerY:o,radius:t,onMouseDown:y,onMouseEnter:b,onMouseOut:m,type:"source"}),(e===!0||e==="target")&&M.jsx(ri,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:p,onMouseEnter:b,onMouseOut:m,type:"target"})]})}function hm({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,reconnectRadius:d,onReconnect:l,onReconnectStart:f,onReconnectEnd:h,rfId:g,edgeTypes:x,noPanClassName:y,onError:p,disableKeyboardA11y:b}){let m=ee(G=>G.edgeLookup.get(e));const w=ee(G=>G.defaultEdgeOptions);m=w?{...w,...m}:m;let N=m.type||"default",_=(x==null?void 0:x[N])||ei[N];_===void 0&&(p==null||p("011",ye.error011(N)),N="default",_=(x==null?void 0:x.default)||ei.default);const k=!!(m.focusable||t&&typeof m.focusable>"u"),$=typeof l<"u"&&(m.reconnectable||n&&typeof m.reconnectable>"u"),P=!!(m.selectable||r&&typeof m.selectable>"u"),V=D.useRef(null),[S,T]=D.useState(!1),[H,v]=D.useState(!1),I=oe(),{zIndex:E=m.zIndex,sourceX:A,sourceY:L,targetX:C,targetY:z,sourcePosition:j,targetPosition:R}=ee(D.useCallback(G=>{const X=G.nodeLookup.get(m.source),J=G.nodeLookup.get(m.target);if(!X||!J)return ti;const te=Qg({id:e,sourceNode:X,targetNode:J,sourceHandle:m.sourceHandle||null,targetHandle:m.targetHandle||null,connectionMode:G.connectionMode,onError:p}),ne=Yg({selected:m.selected,zIndex:m.zIndex,sourceNode:X,targetNode:J,elevateOnSelect:G.elevateEdgesOnSelect,zIndexMode:G.zIndexMode});return{...te||ti,zIndex:ne}},[m.source,m.target,m.sourceHandle,m.targetHandle,m.selected,m.zIndex]),re),F=D.useMemo(()=>m.markerStart?`url('#${nr(m.markerStart,g)}')`:void 0,[m.markerStart,g]),Y=D.useMemo(()=>m.markerEnd?`url('#${nr(m.markerEnd,g)}')`:void 0,[m.markerEnd,g]);if(m.hidden||A===null||L===null||C===null||z===null)return null;const U=G=>{var ne;const{addSelectedEdges:X,unselectNodesAndEdges:J,multiSelectionActive:te}=I.getState();P&&(I.setState({nodesSelectionActive:!1}),m.selected&&te?(J({nodes:[],edges:[m]}),(ne=V.current)==null||ne.blur()):X([e])),o&&o(G,m)},Q=i?G=>{i(G,{...m})}:void 0,q=s?G=>{s(G,{...m})}:void 0,O=a?G=>{a(G,{...m})}:void 0,B=c?G=>{c(G,{...m})}:void 0,Z=u?G=>{u(G,{...m})}:void 0,K=G=>{var X;if(!b&&ds.includes(G.key)&&P){const{unselectNodesAndEdges:J,addSelectedEdges:te}=I.getState();G.key==="Escape"?((X=V.current)==null||X.blur(),J({edges:[m]})):te([e])}};return M.jsx("svg",{style:{zIndex:E},children:M.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${N}`,m.className,y,{selected:m.selected,animated:m.animated,inactive:!P&&!o,updating:S,selectable:P}]),onClick:U,onDoubleClick:Q,onContextMenu:q,onMouseEnter:O,onMouseMove:B,onMouseLeave:Z,onKeyDown:k?K:void 0,tabIndex:k?0:void 0,role:m.ariaRole??(k?"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":k?`${Ys}-${g}`:void 0,ref:V,...m.domAttributes,children:[!H&&M.jsx(_,{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:A,sourceY:L,targetX:C,targetY:z,sourcePosition:j,targetPosition:R,data:m.data,style:m.style,sourceHandleId:m.sourceHandle,targetHandleId:m.targetHandle,markerStart:F,markerEnd:Y,pathOptions:"pathOptions"in m?m.pathOptions:void 0,interactionWidth:m.interactionWidth}),$&&M.jsx(fm,{edge:m,isReconnectable:$,reconnectRadius:d,onReconnect:l,onReconnectStart:f,onReconnectEnd:h,sourceX:A,sourceY:L,targetX:C,targetY:z,sourcePosition:j,targetPosition:R,setUpdateHover:T,setReconnecting:v})]})})}var gm=D.memo(hm);const pm=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function pa({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:d,reconnectRadius:l,onEdgeDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,disableKeyboardA11y:x}){const{edgesFocusable:y,edgesReconnectable:p,elementsSelectable:b,onError:m}=ee(pm,re),w=J0(t);return M.jsxs("div",{className:"react-flow__edges",children:[M.jsx(om,{defaultColor:e,rfId:n}),w.map(N=>M.jsx(gm,{id:N,edgesFocusable:y,edgesReconnectable:p,elementsSelectable:b,noPanClassName:o,onReconnect:i,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,onClick:d,reconnectRadius:l,onDoubleClick:f,onReconnectStart:h,onReconnectEnd:g,rfId:n,onError:m,edgeTypes:r,disableKeyboardA11y:x},N))]})}pa.displayName="EdgeRenderer";const mm=D.memo(pa),ym=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function xm({children:e}){const t=ee(ym);return M.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function wm(e){const t=Ir(),n=D.useRef(!1);D.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const vm=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function bm(e){const t=ee(vm),n=oe();return D.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function _m(e){return e.connection.inProgress?{...e.connection,to:Tt(e.connection.to,e.transform)}:{...e.connection}}function Em(e){return _m}function Nm(e){const t=Em();return ee(t,re)}const Sm=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Mm({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:i,height:s,isValid:a,inProgress:c}=ee(Sm,re);return!(i&&o&&c)?null:M.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:M.jsx("g",{className:se(["react-flow__connection",gs(a)]),children:M.jsx(ma,{style:t,type:n,CustomComponent:r,isValid:a})})})}const ma=({style:e,type:t=Le.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:i,fromNode:s,fromHandle:a,fromPosition:c,to:u,toNode:d,toHandle:l,toPosition:f,pointer:h}=Nm();if(!o)return;if(n)return M.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:f,connectionStatus:gs(r),toNode:d,toHandle:l,pointer:h});let g="";const x={sourceX:i.x,sourceY:i.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:f};switch(t){case Le.Bezier:[g]=ks(x);break;case Le.SimpleBezier:[g]=ra(x);break;case Le.Step:[g]=tr({...x,borderRadius:0});break;case Le.SmoothStep:[g]=tr(x);break;default:[g]=Is(x)}return M.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};ma.displayName="ConnectionLine";const km={};function oi(e=km){D.useRef(e),oe(),D.useEffect(()=>{},[e])}function Cm(){oe(),D.useRef(!1),D.useEffect(()=>{},[])}function ya({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:l,onSelectionStart:f,onSelectionEnd:h,connectionLineType:g,connectionLineStyle:x,connectionLineComponent:y,connectionLineContainerStyle:p,selectionKeyCode:b,selectionOnDrag:m,selectionMode:w,multiSelectionKeyCode:N,panActivationKeyCode:_,zoomActivationKeyCode:k,deleteKeyCode:$,onlyRenderVisibleElements:P,elementsSelectable:V,defaultViewport:S,translateExtent:T,minZoom:H,maxZoom:v,preventScrolling:I,defaultMarkerColor:E,zoomOnScroll:A,zoomOnPinch:L,panOnScroll:C,panOnScrollSpeed:z,panOnScrollMode:j,zoomOnDoubleClick:R,panOnDrag:F,autoPanOnSelection:Y,onPaneClick:U,onPaneMouseEnter:Q,onPaneMouseMove:q,onPaneMouseLeave:O,onPaneScroll:B,onPaneContextMenu:Z,paneClickDistance:K,nodeClickDistance:G,onEdgeContextMenu:X,onEdgeMouseEnter:J,onEdgeMouseMove:te,onEdgeMouseLeave:ne,reconnectRadius:ie,onReconnect:le,onReconnectStart:we,onReconnectEnd:ve,noDragClassName:Se,noWheelClassName:ut,noPanClassName:Oe,disableKeyboardA11y:Re,nodeExtent:fe,rfId:Me,viewport:ke,onViewportChange:ze}){return oi(e),oi(t),Cm(),wm(n),bm(ke),M.jsx(F0,{onPaneClick:U,onPaneMouseEnter:Q,onPaneMouseMove:q,onPaneMouseLeave:O,onPaneContextMenu:Z,onPaneScroll:B,paneClickDistance:K,deleteKeyCode:$,selectionKeyCode:b,selectionOnDrag:m,selectionMode:w,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:N,panActivationKeyCode:_,zoomActivationKeyCode:k,elementsSelectable:V,zoomOnScroll:A,zoomOnPinch:L,zoomOnDoubleClick:R,panOnScroll:C,panOnScrollSpeed:z,panOnScrollMode:j,panOnDrag:F,autoPanOnSelection:Y,defaultViewport:S,translateExtent:T,minZoom:H,maxZoom:v,onSelectionContextMenu:l,preventScrolling:I,noDragClassName:Se,noWheelClassName:ut,noPanClassName:Oe,disableKeyboardA11y:Re,onViewportChange:ze,isControlledViewport:!!ke,children:M.jsxs(xm,{children:[M.jsx(mm,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:le,onReconnectStart:we,onReconnectEnd:ve,onlyRenderVisibleElements:P,onEdgeContextMenu:X,onEdgeMouseEnter:J,onEdgeMouseMove:te,onEdgeMouseLeave:ne,reconnectRadius:ie,defaultMarkerColor:E,noPanClassName:Oe,disableKeyboardA11y:Re,rfId:Me}),M.jsx(Mm,{style:x,type:g,component:y,containerStyle:p}),M.jsx("div",{className:"react-flow__edgelabel-renderer"}),M.jsx(Q0,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:G,onlyRenderVisibleElements:P,noPanClassName:Oe,noDragClassName:Se,disableKeyboardA11y:Re,nodeExtent:fe,rfId:Me}),M.jsx("div",{className:"react-flow__viewport-portal"})]})})}ya.displayName="GraphView";const Im=D.memo(ya),Am=vs(),ii=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:u=2,nodeOrigin:d,nodeExtent:l,zIndexMode:f="basic"}={})=>{const h=new Map,g=new Map,x=new Map,y=new Map,p=r??t??[],b=n??e??[],m=d??[0,0],w=l??_t;Ps(x,y,p);const{nodesInitialized:N}=rr(b,h,g,{nodeOrigin:m,nodeExtent:w,zIndexMode:f});let _=[0,0,1];if(s&&o&&i){const k=$t(h,{filter:S=>!!((S.width||S.initialWidth)&&(S.height||S.initialHeight))}),{x:$,y:P,zoom:V}=_r(k,o,i,c,u,(a==null?void 0:a.padding)??.1);_=[$,P,V]}return{rfId:"1",width:o??0,height:i??0,transform:_,nodes:b,nodesInitialized:N,nodeLookup:h,parentLookup:g,edges:p,edgeLookup:y,connectionLookup:x,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:_t,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:rt.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:s??!1,fitViewOptions:a,fitViewResolver:null,connection:{...hs},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Am,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:fs,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},$m=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:l,zIndexMode:f})=>Vp((h,g)=>{async function x(){const{nodeLookup:y,panZoom:p,fitViewOptions:b,fitViewResolver:m,width:w,height:N,minZoom:_,maxZoom:k}=g();p&&(await Rg({nodes:y,width:w,height:N,panZoom:p,minZoom:_,maxZoom:k},b),m==null||m.resolve(!0),h({fitViewResolver:null}))}return{...ii({nodes:e,edges:t,width:o,height:i,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:d,nodeExtent:l,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:y=>{const{nodeLookup:p,parentLookup:b,nodeOrigin:m,elevateNodesOnSelect:w,fitViewQueued:N,zIndexMode:_,nodesSelectionActive:k}=g(),{nodesInitialized:$,hasSelectedNodes:P}=rr(y,p,b,{nodeOrigin:m,nodeExtent:l,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:_}),V=k&&P;N&&$?(x(),h({nodes:y,nodesInitialized:$,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:V})):h({nodes:y,nodesInitialized:$,nodesSelectionActive:V})},setEdges:y=>{const{connectionLookup:p,edgeLookup:b}=g();Ps(p,b,y),h({edges:y})},setDefaultNodesAndEdges:(y,p)=>{if(y){const{setNodes:b}=g();b(y),h({hasDefaultNodes:!0})}if(p){const{setEdges:b}=g();b(p),h({hasDefaultEdges:!0})}},updateNodeInternals:y=>{const{triggerNodeChanges:p,nodeLookup:b,parentLookup:m,domNode:w,nodeOrigin:N,nodeExtent:_,debug:k,fitViewQueued:$,zIndexMode:P}=g(),{changes:V,updatedInternals:S}=sp(y,b,m,w,N,_,P);S&&(np(b,m,{nodeOrigin:N,nodeExtent:_,zIndexMode:P}),$?(x(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(V==null?void 0:V.length)>0&&(k&&console.log("React Flow: trigger node changes",V),p==null||p(V)))},updateNodePositions:(y,p=!1)=>{const b=[];let m=[];const{nodeLookup:w,triggerNodeChanges:N,connection:_,updateConnection:k,onNodesChangeMiddlewareMap:$}=g();for(const[P,V]of y){const S=w.get(P),T=!!(S!=null&&S.expandParent&&(S!=null&&S.parentId)&&(V!=null&&V.position)),H={id:P,type:"position",position:T?{x:Math.max(0,V.position.x),y:Math.max(0,V.position.y)}:V.position,dragging:p};if(S&&_.inProgress&&_.fromNode.id===S.id){const v=Ge(S,_.fromHandle,W.Left,!0);k({..._,from:v})}T&&S.parentId&&b.push({id:P,parentId:S.parentId,rect:{...V.internals.positionAbsolute,width:V.measured.width??0,height:V.measured.height??0}}),m.push(H)}if(b.length>0){const{parentLookup:P,nodeOrigin:V}=g(),S=Cr(b,w,P,V);m.push(...S)}for(const P of $.values())m=P(m);N(m)},triggerNodeChanges:y=>{const{onNodesChange:p,setNodes:b,nodes:m,hasDefaultNodes:w,debug:N}=g();if(y!=null&&y.length){if(w){const _=c0(y,m);b(_)}N&&console.log("React Flow: trigger node changes",y),p==null||p(y)}},triggerEdgeChanges:y=>{const{onEdgesChange:p,setEdges:b,edges:m,hasDefaultEdges:w,debug:N}=g();if(y!=null&&y.length){if(w){const _=u0(y,m);b(_)}N&&console.log("React Flow: trigger edge changes",y),p==null||p(y)}},addSelectedNodes:y=>{const{multiSelectionActive:p,edgeLookup:b,nodeLookup:m,triggerNodeChanges:w,triggerEdgeChanges:N}=g();if(p){const _=y.map(k=>je(k,!0));w(_);return}w(Ze(m,new Set([...y]),!0)),N(Ze(b))},addSelectedEdges:y=>{const{multiSelectionActive:p,edgeLookup:b,nodeLookup:m,triggerNodeChanges:w,triggerEdgeChanges:N}=g();if(p){const _=y.map(k=>je(k,!0));N(_);return}N(Ze(b,new Set([...y]))),w(Ze(m,new Set,!0))},unselectNodesAndEdges:({nodes:y,edges:p}={})=>{const{edges:b,nodes:m,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:_}=g(),k=y||m,$=p||b,P=[];for(const S of k){if(!S.selected)continue;const T=w.get(S.id);T&&(T.selected=!1),P.push(je(S.id,!1))}const V=[];for(const S of $)S.selected&&V.push(je(S.id,!1));N(P),_(V)},setMinZoom:y=>{const{panZoom:p,maxZoom:b}=g();p==null||p.setScaleExtent([y,b]),h({minZoom:y})},setMaxZoom:y=>{const{panZoom:p,minZoom:b}=g();p==null||p.setScaleExtent([b,y]),h({maxZoom:y})},setTranslateExtent:y=>{var p;(p=g().panZoom)==null||p.setTranslateExtent(y),h({translateExtent:y})},resetSelectedElements:()=>{const{edges:y,nodes:p,triggerNodeChanges:b,triggerEdgeChanges:m,elementsSelectable:w}=g();if(!w)return;const N=p.reduce((k,$)=>$.selected?[...k,je($.id,!1)]:k,[]),_=y.reduce((k,$)=>$.selected?[...k,je($.id,!1)]:k,[]);b(N),m(_)},setNodeExtent:y=>{const{nodes:p,nodeLookup:b,parentLookup:m,nodeOrigin:w,elevateNodesOnSelect:N,nodeExtent:_,zIndexMode:k}=g();y[0][0]===_[0][0]&&y[0][1]===_[0][1]&&y[1][0]===_[1][0]&&y[1][1]===_[1][1]||(rr(p,b,m,{nodeOrigin:w,nodeExtent:y,elevateNodesOnSelect:N,checkEquality:!1,zIndexMode:k}),h({nodeExtent:y}))},panBy:y=>{const{transform:p,width:b,height:m,panZoom:w,translateExtent:N}=g();return ap({delta:y,panZoom:w,transform:p,translateExtent:N,width:b,height:m})},setCenter:async(y,p,b)=>{const{width:m,height:w,maxZoom:N,panZoom:_}=g();if(!_)return!1;const k=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:N;return await _.setViewport({x:m/2-y*k,y:w/2-p*k,zoom:k},{duration:b==null?void 0:b.duration,ease:b==null?void 0:b.ease,interpolate:b==null?void 0:b.interpolate}),!0},cancelConnection:()=>{h({connection:{...hs}})},updateConnection:y=>{h({connection:y})},reset:()=>h({...ii()})}},Object.is);function Pm({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:i,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:u,nodeOrigin:d,nodeExtent:l,zIndexMode:f,children:h}){const[g]=D.useState(()=>$m({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:i,fitView:u,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:d,nodeExtent:l,zIndexMode:f}));return M.jsx(Bp,{value:g,children:M.jsx(p0,{children:M.jsx(A0,{children:h})})})}function Tm({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:u,maxZoom:d,nodeOrigin:l,nodeExtent:f,zIndexMode:h}){return D.useContext(vn)?M.jsx(M.Fragment,{children:e}):M.jsx(Pm,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:i,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:d,nodeOrigin:l,nodeExtent:f,zIndexMode:h,children:e})}const Lm={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Dm({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:i,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:u,onMove:d,onMoveStart:l,onMoveEnd:f,onConnect:h,onConnectStart:g,onConnectEnd:x,onClickConnectStart:y,onClickConnectEnd:p,onNodeMouseEnter:b,onNodeMouseMove:m,onNodeMouseLeave:w,onNodeContextMenu:N,onNodeDoubleClick:_,onNodeDragStart:k,onNodeDrag:$,onNodeDragStop:P,onNodesDelete:V,onEdgesDelete:S,onDelete:T,onSelectionChange:H,onSelectionDragStart:v,onSelectionDrag:I,onSelectionDragStop:E,onSelectionContextMenu:A,onSelectionStart:L,onSelectionEnd:C,onBeforeDelete:z,connectionMode:j,connectionLineType:R=Le.Bezier,connectionLineStyle:F,connectionLineComponent:Y,connectionLineContainerStyle:U,deleteKeyCode:Q="Backspace",selectionKeyCode:q="Shift",selectionOnDrag:O=!1,selectionMode:B=Et.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:K=St()?"Meta":"Control",zoomActivationKeyCode:G=St()?"Meta":"Control",snapToGrid:X,snapGrid:J,onlyRenderVisibleElements:te=!1,selectNodesOnDrag:ne,nodesDraggable:ie,autoPanOnNodeFocus:le,nodesConnectable:we,nodesFocusable:ve,nodeOrigin:Se=Xs,edgesFocusable:ut,edgesReconnectable:Oe,elementsSelectable:Re=!0,defaultViewport:fe=t0,minZoom:Me=.5,maxZoom:ke=2,translateExtent:ze=_t,preventScrolling:ba=!0,nodeExtent:Nn,defaultMarkerColor:_a="#b1b1b7",zoomOnScroll:Ea=!0,zoomOnPinch:Na=!0,panOnScroll:Sa=!1,panOnScrollSpeed:Ma=.5,panOnScrollMode:ka=Be.Free,zoomOnDoubleClick:Ca=!0,panOnDrag:Ia=!0,onPaneClick:Aa,onPaneMouseEnter:$a,onPaneMouseMove:Pa,onPaneMouseLeave:Ta,onPaneScroll:La,onPaneContextMenu:Da,paneClickDistance:Oa=1,nodeClickDistance:Ra=0,children:za,onReconnect:ja,onReconnectStart:Ha,onReconnectEnd:Va,onEdgeContextMenu:Ba,onEdgeDoubleClick:Fa,onEdgeMouseEnter:Ya,onEdgeMouseMove:Xa,onEdgeMouseLeave:Wa,reconnectRadius:Ga=10,onNodesChange:qa,onEdgesChange:Ua,noDragClassName:Ka="nodrag",noWheelClassName:Za="nowheel",noPanClassName:$r="nopan",fitView:Pr,fitViewOptions:Tr,connectOnClick:Qa,attributionPosition:Ja,proOptions:ec,defaultEdgeOptions:tc,elevateNodesOnSelect:nc=!0,elevateEdgesOnSelect:rc=!1,disableKeyboardA11y:Lr=!1,autoPanOnConnect:oc,autoPanOnNodeDrag:ic,autoPanOnSelection:sc=!0,autoPanSpeed:ac,connectionRadius:cc,isValidConnection:uc,onError:lc,style:dc,id:Dr,nodeDragThreshold:fc,connectionDragThreshold:hc,viewport:gc,onViewportChange:pc,width:mc,height:yc,colorMode:xc="light",debug:wc,onScroll:Lt,ariaLabelConfig:vc,zIndexMode:Or="basic",...bc},_c){const Sn=Dr||"1",Ec=i0(xc),Nc=D.useCallback(Rr=>{Rr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Lt==null||Lt(Rr)},[Lt]);return M.jsx("div",{"data-testid":"rf__wrapper",...bc,onScroll:Nc,style:{...dc,...Lm},ref:_c,className:se(["react-flow",o,Ec]),id:Dr,role:"application",children:M.jsxs(Tm,{nodes:e,edges:t,width:mc,height:yc,fitView:Pr,fitViewOptions:Tr,minZoom:Me,maxZoom:ke,nodeOrigin:Se,nodeExtent:Nn,zIndexMode:Or,children:[M.jsx(o0,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:x,onClickConnectStart:y,onClickConnectEnd:p,nodesDraggable:ie,autoPanOnNodeFocus:le,nodesConnectable:we,nodesFocusable:ve,edgesFocusable:ut,edgesReconnectable:Oe,elementsSelectable:Re,elevateNodesOnSelect:nc,elevateEdgesOnSelect:rc,minZoom:Me,maxZoom:ke,nodeExtent:Nn,onNodesChange:qa,onEdgesChange:Ua,snapToGrid:X,snapGrid:J,connectionMode:j,translateExtent:ze,connectOnClick:Qa,defaultEdgeOptions:tc,fitView:Pr,fitViewOptions:Tr,onNodesDelete:V,onEdgesDelete:S,onDelete:T,onNodeDragStart:k,onNodeDrag:$,onNodeDragStop:P,onSelectionDrag:I,onSelectionDragStart:v,onSelectionDragStop:E,onMove:d,onMoveStart:l,onMoveEnd:f,noPanClassName:$r,nodeOrigin:Se,rfId:Sn,autoPanOnConnect:oc,autoPanOnNodeDrag:ic,autoPanSpeed:ac,onError:lc,connectionRadius:cc,isValidConnection:uc,selectNodesOnDrag:ne,nodeDragThreshold:fc,connectionDragThreshold:hc,onBeforeDelete:z,debug:wc,ariaLabelConfig:vc,zIndexMode:Or}),M.jsx(Im,{onInit:u,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:m,onNodeMouseLeave:w,onNodeContextMenu:N,onNodeDoubleClick:_,nodeTypes:i,edgeTypes:s,connectionLineType:R,connectionLineStyle:F,connectionLineComponent:Y,connectionLineContainerStyle:U,selectionKeyCode:q,selectionOnDrag:O,selectionMode:B,deleteKeyCode:Q,multiSelectionKeyCode:K,panActivationKeyCode:Z,zoomActivationKeyCode:G,onlyRenderVisibleElements:te,defaultViewport:fe,translateExtent:ze,minZoom:Me,maxZoom:ke,preventScrolling:ba,zoomOnScroll:Ea,zoomOnPinch:Na,zoomOnDoubleClick:Ca,panOnScroll:Sa,panOnScrollSpeed:Ma,panOnScrollMode:ka,panOnDrag:Ia,autoPanOnSelection:sc,onPaneClick:Aa,onPaneMouseEnter:$a,onPaneMouseMove:Pa,onPaneMouseLeave:Ta,onPaneScroll:La,onPaneContextMenu:Da,paneClickDistance:Oa,nodeClickDistance:Ra,onSelectionContextMenu:A,onSelectionStart:L,onSelectionEnd:C,onReconnect:ja,onReconnectStart:Ha,onReconnectEnd:Va,onEdgeContextMenu:Ba,onEdgeDoubleClick:Fa,onEdgeMouseEnter:Ya,onEdgeMouseMove:Xa,onEdgeMouseLeave:Wa,reconnectRadius:Ga,defaultMarkerColor:_a,noDragClassName:Ka,noWheelClassName:Za,noPanClassName:$r,rfId:Sn,disableKeyboardA11y:Lr,nodeExtent:Nn,viewport:gc,onViewportChange:pc}),M.jsx(e0,{onSelectionChange:H}),za,M.jsx(Up,{proOptions:ec,position:Ja}),M.jsx(qp,{rfId:Sn,disableKeyboardA11y:Lr})]})})}var Om=Gs(Dm);function Rm({dimensions:e,lineWidth:t,variant:n,className:r}){return M.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:se(["react-flow__background-pattern",n,r])})}function zm({radius:e,className:t}){return M.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var De;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(De||(De={}));const jm={[De.Dots]:1,[De.Lines]:1,[De.Cross]:6},Hm=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function xa({id:e,variant:t=De.Dots,gap:n=20,size:r,lineWidth:o=1,offset:i=0,color:s,bgColor:a,style:c,className:u,patternClassName:d}){const l=D.useRef(null),{transform:f,patternId:h}=ee(Hm,re),g=r||jm[t],x=t===De.Dots,y=t===De.Cross,p=Array.isArray(n)?n:[n,n],b=[p[0]*f[2]||1,p[1]*f[2]||1],m=g*f[2],w=Array.isArray(i)?i:[i,i],N=y?[m,m]:b,_=[w[0]*f[2]||1+N[0]/2,w[1]*f[2]||1+N[1]/2],k=`${h}${e||""}`;return M.jsxs("svg",{className:se(["react-flow__background",u]),style:{...c,..._n,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:l,"data-testid":"rf__background",children:[M.jsx("pattern",{id:k,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:x?M.jsx(zm,{radius:m/2,className:d}):M.jsx(Rm,{dimensions:N,lineWidth:o,variant:t,className:d})}),M.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${k})`})]})}xa.displayName="Background";const Vm=D.memo(xa);function Bm(){return M.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:M.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Fm(){return M.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:M.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Ym(){return M.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:M.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 Xm(){return M.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:M.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 Wm(){return M.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:M.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 Ft({children:e,className:t,...n}){return M.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const Gm=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function wa({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:u,children:d,position:l="bottom-left",orientation:f="vertical","aria-label":h}){const g=oe(),{isInteractive:x,minZoomReached:y,maxZoomReached:p,ariaLabelConfig:b}=ee(Gm,re),{zoomIn:m,zoomOut:w,fitView:N}=Ir(),_=()=>{m(),i==null||i()},k=()=>{w(),s==null||s()},$=()=>{N(o),a==null||a()},P=()=>{g.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),c==null||c(!x)},V=f==="horizontal"?"horizontal":"vertical";return M.jsxs(bn,{className:se(["react-flow__controls",V,u]),position:l,style:e,"data-testid":"rf__controls","aria-label":h??b["controls.ariaLabel"],children:[t&&M.jsxs(M.Fragment,{children:[M.jsx(Ft,{onClick:_,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:p,children:M.jsx(Bm,{})}),M.jsx(Ft,{onClick:k,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:y,children:M.jsx(Fm,{})})]}),n&&M.jsx(Ft,{className:"react-flow__controls-fitview",onClick:$,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:M.jsx(Ym,{})}),r&&M.jsx(Ft,{className:"react-flow__controls-interactive",onClick:P,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:x?M.jsx(Wm,{}):M.jsx(Xm,{})}),d]})}wa.displayName="Controls";const qm=D.memo(wa);function Um({id:e,x:t,y:n,width:r,height:o,style:i,color:s,strokeColor:a,strokeWidth:c,className:u,borderRadius:d,shapeRendering:l,selected:f,onClick:h}){const{background:g,backgroundColor:x}=i||{},y=s||g||x;return M.jsx("rect",{className:se(["react-flow__minimap-node",{selected:f},u]),x:t,y:n,rx:d,ry:d,width:r,height:o,style:{fill:y,stroke:a,strokeWidth:c},shapeRendering:l,onClick:h?p=>h(p,e):void 0})}const Km=D.memo(Um),Zm=e=>e.nodes.map(t=>t.id),Yn=e=>e instanceof Function?e:()=>e;function Qm({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:i=Km,onClick:s}){const a=ee(Zm,re),c=Yn(t),u=Yn(e),d=Yn(n),l=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return M.jsx(M.Fragment,{children:a.map(f=>M.jsx(ey,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:i,onClick:s,shapeRendering:l},f))})}function Jm({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:u,x:d,y:l,width:f,height:h}=ee(g=>{const x=g.nodeLookup.get(e);if(!x)return{node:void 0,x:0,y:0,width:0,height:0};const y=x.internals.userNode,{x:p,y:b}=x.internals.positionAbsolute,{width:m,height:w}=$e(y);return{node:y,x:p,y:b,width:m,height:w}},re);return!u||u.hidden||!bs(u)?null:M.jsx(a,{x:d,y:l,width:f,height:h,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:o,strokeColor:n(u),strokeWidth:i,shapeRendering:s,onClick:c,id:u.id})}const ey=D.memo(Jm);var ty=D.memo(Qm);const ny=200,ry=150,oy=e=>!e.hidden,iy=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?xs($t(e.nodeLookup,{filter:oy}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},sy="react-flow__minimap-desc";function va({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:u,maskStrokeColor:d,maskStrokeWidth:l,position:f="bottom-right",onClick:h,onNodeClick:g,pannable:x=!1,zoomable:y=!1,ariaLabel:p,inversePan:b,zoomStep:m=1,offsetScale:w=5}){const N=oe(),_=D.useRef(null),{boundingRect:k,viewBB:$,rfId:P,panZoom:V,translateExtent:S,flowWidth:T,flowHeight:H,ariaLabelConfig:v}=ee(iy,re),I=(e==null?void 0:e.width)??ny,E=(e==null?void 0:e.height)??ry,A=k.width/I,L=k.height/E,C=Math.max(A,L),z=C*I,j=C*E,R=w*C,F=k.x-(z-k.width)/2-R,Y=k.y-(j-k.height)/2-R,U=z+R*2,Q=j+R*2,q=`${sy}-${P}`,O=D.useRef(0),B=D.useRef();O.current=C,D.useEffect(()=>{if(_.current&&V)return B.current=mp({domNode:_.current,panZoom:V,getTransform:()=>N.getState().transform,getViewScale:()=>O.current}),()=>{var X;(X=B.current)==null||X.destroy()}},[V]),D.useEffect(()=>{var X;(X=B.current)==null||X.update({translateExtent:S,width:T,height:H,inversePan:b,pannable:x,zoomStep:m,zoomable:y})},[x,y,b,m,S,T,H]);const Z=h?X=>{var ne;const[J,te]=((ne=B.current)==null?void 0:ne.pointer(X))||[0,0];h(X,{x:J,y:te})}:void 0,K=g?D.useCallback((X,J)=>{const te=N.getState().nodeLookup.get(J).internals.userNode;g(X,te)},[]):void 0,G=p??v["minimap.ariaLabel"];return M.jsx(bn,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof l=="number"?l*C:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:se(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:M.jsxs("svg",{width:I,height:E,viewBox:`${F} ${Y} ${U} ${Q}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":q,ref:_,onClick:Z,children:[G&&M.jsx("title",{id:q,children:G}),M.jsx(ty,{onClick:K,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:a}),M.jsx("path",{className:"react-flow__minimap-mask",d:`M${F-R},${Y-R}h${U+R*2}v${Q+R*2}h${-U-R*2}z
|
|
23
|
+
M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}va.displayName="MiniMap";const ay=D.memo(va),cy=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,uy={[st.Line]:"right",[st.Handle]:"bottom-right"};function ly({nodeId:e,position:t,variant:n=st.Handle,className:r,style:o=void 0,children:i,color:s,minWidth:a=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:l=!1,resizeDirection:f,autoScale:h=!0,shouldResize:g,onResizeStart:x,onResize:y,onResizeEnd:p}){const b=Zs(),m=typeof e=="string"?e:b,w=oe(),N=D.useRef(null),_=n===st.Handle,k=ee(D.useCallback(cy(_&&h),[_,h]),re),$=D.useRef(null),P=t??uy[n];D.useEffect(()=>{if(!(!N.current||!m))return $.current||($.current=Ip({domNode:N.current,nodeId:m,getStoreItems:()=>{const{nodeLookup:S,transform:T,snapGrid:H,snapToGrid:v,nodeOrigin:I,domNode:E}=w.getState();return{nodeLookup:S,transform:T,snapGrid:H,snapToGrid:v,nodeOrigin:I,paneDomNode:E}},onChange:(S,T)=>{const{triggerNodeChanges:H,nodeLookup:v,parentLookup:I,nodeOrigin:E}=w.getState(),A=[],L={x:S.x,y:S.y},C=v.get(m);if(C&&C.expandParent&&C.parentId){const z=C.origin??E,j=S.width??C.measured.width??0,R=S.height??C.measured.height??0,F={id:C.id,parentId:C.parentId,rect:{width:j,height:R,..._s({x:S.x??C.position.x,y:S.y??C.position.y},{width:j,height:R},C.parentId,v,z)}},Y=Cr([F],v,I,E);A.push(...Y),L.x=S.x?Math.max(z[0]*j,S.x):void 0,L.y=S.y?Math.max(z[1]*R,S.y):void 0}if(L.x!==void 0&&L.y!==void 0){const z={id:m,type:"position",position:{...L}};A.push(z)}if(S.width!==void 0&&S.height!==void 0){const j={id:m,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:S.width,height:S.height}};A.push(j)}for(const z of T){const j={...z,type:"position"};A.push(j)}H(A)},onEnd:({width:S,height:T})=>{const H={id:m,type:"dimensions",resizing:!1,dimensions:{width:S,height:T}};w.getState().triggerNodeChanges([H])}})),$.current.update({controlPosition:P,boundaries:{minWidth:a,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:l,resizeDirection:f,onResizeStart:x,onResize:y,onResizeEnd:p,shouldResize:g}),()=>{var S;(S=$.current)==null||S.destroy()}},[P,a,c,u,d,l,x,y,p,g]);const V=P.split("-");return M.jsx("div",{className:se(["react-flow__resize-control","nodrag",...V,n,r]),ref:N,style:{...o,scale:k,...s&&{[_?"backgroundColor":"borderColor"]:s}},children:i})}D.memo(ly);const dy=[{id:"none",label:"None"},{id:"duration",label:"Time"},{id:"rows",label:"Rows"},{id:"cost",label:"Cost"},{id:"buffers",label:"Buffers"}];function fy(e){return`hsl(${((100-Math.max(0,Math.min(100,e)))*1.2).toFixed(0)} 85% 45%)`}const si=e=>(e.sharedHitBlocks??0)+(e.sharedReadBlocks??0)+(e.sharedDirtiedBlocks??0)+(e.sharedWrittenBlocks??0);function hy(e){const t=new Map,n={duration:0,rows:0,cost:0,buffers:0},r=o=>{const i=o.children.reduce((c,u)=>c+(u.totalCost??0),0),s=o.children.reduce((c,u)=>c+si(u),0),a={duration:o.metrics.selfMs??0,rows:o.metrics.totalRows??o.actualRows??0,cost:Math.max((o.totalCost??0)-i,0),buffers:Math.max(si(o)-s,0)};t.set(o.id,a),n.duration=Math.max(n.duration,a.duration),n.rows=Math.max(n.rows,a.rows),n.cost=Math.max(n.cost,a.cost),n.buffers=Math.max(n.buffers,a.buffers),o.children.forEach(r)};return r(e),{values:t,max:n}}function gy(e,t,n,r){var s;if(t==="none")return 0;const o=((s=n.get(e))==null?void 0:s[t])??0,i=r[t]||1;return o/i*100}const sr=234,ai=84;function py({data:e}){const{node:t,heatPct:n,heatMode:r,selected:o}=e,i=t.metrics,s=t.actualLoops===0,a=t.parentRelationship,c=t.subplanName??(a==="InitPlan"||a==="SubPlan"?a:void 0);return M.jsxs("div",{className:`rounded-md border px-2 py-1.5 text-xs shadow-sm ${o?"ring-2 ring-[var(--sev-info)]":""} ${s?"opacity-60":""}`,style:{width:sr,background:"var(--card)",color:"var(--foreground)"},children:[M.jsx(at,{type:"target",position:W.Top,style:{opacity:0}}),M.jsxs("div",{className:"font-medium truncate",title:Cc(t),children:[t.nodeType,(t.workersLaunched??0)>0&&M.jsxs("span",{className:"ml-1 text-muted-foreground",children:["×",(t.workersLaunched??0)+1]})]}),(t.relationName||t.indexName)&&M.jsxs("div",{className:"text-muted-foreground truncate",children:[t.indexName?`using ${t.indexName}`:"",t.relationName?` on ${t.relationName}`:""]}),M.jsxs("div",{className:"text-muted-foreground mt-0.5 flex flex-wrap gap-x-2",children:[i.selfMs!=null&&M.jsxs("span",{children:[i.selfMs.toFixed(1)," ms"]}),i.totalRows!=null&&M.jsxs("span",{children:[i.totalRows.toLocaleString()," rows"]}),s&&M.jsx("span",{children:"never executed"}),i.estimateFactor!=null&&i.estimateFactor>=10&&i.estimateDirection!=="accurate"&&M.jsxs("span",{style:{color:"var(--sev-warn)"},children:[i.estimateFactor.toFixed(0),"× ",i.estimateDirection]})]}),c&&M.jsx("div",{className:"text-[10px] mt-0.5 italic text-muted-foreground truncate",children:c}),r!=="none"&&M.jsx("div",{className:"h-1 rounded mt-1",style:{width:`${Math.max(3,n)}%`,background:fy(n)}}),M.jsx(at,{type:"source",position:W.Bottom,style:{opacity:0}})]})}const my={plan:py};function yy(e,t,n){const{values:r,max:o}=hy(e),i=new Zr.graphlib.Graph;i.setGraph({rankdir:"TB",nodesep:26,ranksep:44}),i.setDefaultEdgeLabel(()=>({}));const s=[],a=[],c=(u,d)=>{if(i.setNode(String(u.id),{width:sr,height:ai}),s.push({id:String(u.id),type:"plan",position:{x:0,y:0},data:{node:u,heatMode:t,heatPct:gy(u.id,t,r,o),selected:n===u.id}}),d){i.setEdge(String(d.id),String(u.id));const l=u.parentRelationship==="InitPlan"||u.parentRelationship==="SubPlan";a.push({id:`${d.id}-${u.id}`,source:String(d.id),target:String(u.id),style:l?{strokeDasharray:"4 3",stroke:"var(--muted-foreground)"}:void 0})}u.children.forEach(l=>c(l,u))};c(e),Zr.layout(i);for(const u of s){const d=i.node(u.id);u.position={x:d.x-sr/2,y:d.y-ai/2}}return{nodes:s,edges:a}}function wy({root:e,onSelect:t,selectedId:n}){const[r,o]=D.useState("duration"),{nodes:i,edges:s}=D.useMemo(()=>yy(e,r,n),[e,r,n]);return M.jsxs("div",{className:"relative h-[600px] rounded-md border",children:[M.jsxs(Om,{nodes:i,edges:s,nodeTypes:my,fitView:!0,minZoom:.1,onNodeClick:(a,c)=>t(c.data.node),children:[M.jsx(Vm,{}),M.jsx(qm,{showInteractive:!1}),M.jsx(ay,{pannable:!0,zoomable:!0})]}),M.jsx("div",{className:"absolute top-2 right-2 z-10 flex gap-1 rounded-md p-1",style:{background:"color-mix(in oklch, var(--card) 85%, transparent)"},children:dy.map(a=>M.jsx(kc,{variant:r===a.id?"default":"secondary",size:"sm",onClick:()=>o(a.id),children:a.label},a.id))})]})}export{wy as PlanGraph};
|