@memoarchitect/architect 0.7.2 → 0.8.27
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 +1 -1
- package/dist/assets/{AiWorkspace-Bu9TlIWg.js → AiWorkspace-Dp5oBDww.js} +1 -1
- package/dist/assets/{AnalysisWorkspace-CodmoI-v.js → AnalysisWorkspace-CNHTkSRD.js} +1 -1
- package/dist/assets/{ComplianceWizard-CTihkUi-.js → ComplianceWizard-CAJDtLdv.js} +1 -1
- package/dist/assets/DSMView-Bv9j1Vk_.js +5 -0
- package/dist/assets/Dashboard-BnOwnA1R.js +1 -0
- package/dist/assets/DhfDashboard-CQpiYHtW.js +1 -0
- package/dist/assets/DhfWorkbench-DHxWuiiL.js +69 -0
- package/dist/assets/DiagramCanvas-DtLlTvJf.js +4 -0
- package/dist/assets/{DiagramEditor-UJDHcAUF.js → DiagramEditor-DP_PiI7K.js} +2 -2
- package/dist/assets/DiagramToolbarControls-XMGLx08e.js +1 -0
- package/dist/assets/{ElementDetailView-10U0rr33.js → ElementDetailView-BQsWfbPD.js} +1 -1
- package/dist/assets/ExplorerTreeRow-CmGPHRI8.js +3 -0
- package/dist/assets/{ImportView-D8svP04Q.js → ImportView-YFBlvgF_.js} +1 -1
- package/dist/assets/{LayerGrid-DEe0Ryz-.js → LayerGrid-KXyuibWY.js} +1 -1
- package/dist/assets/{LayerTable-CN_b2rDr.js → LayerTable-CGsFJsKs.js} +1 -1
- package/dist/assets/{MaxGraphCanvas-bo8oPBct.js → MaxGraphCanvas-BNn0Jxr6.js} +1 -1
- package/dist/assets/{ModelDiff-xe95oVua.js → ModelDiff-CJCXuz_h.js} +1 -1
- package/dist/assets/{OntologyDecompositionDiagram-BL9R8bdB.js → OntologyDecompositionDiagram-5JWUI_PB.js} +1 -1
- package/dist/assets/{OntologyViewer-CtqNkkCn.js → OntologyViewer-DxIWCcJM.js} +2 -2
- package/dist/assets/{RelationshipOverlay-DL0N8Vmk.js → RelationshipOverlay-B3AN-bM-.js} +1 -1
- package/dist/assets/{RelationshipsSection-BoJ0aUXe.js → RelationshipsSection-DggeGBKP.js} +1 -1
- package/dist/assets/{ReviewDashboard-DeTge2oC.js → ReviewDashboard-Qyj8RRFp.js} +1 -1
- package/dist/assets/{ScenarioEditor-FAEYTHgP.js → ScenarioEditor-BIAh6tLX.js} +1 -1
- package/dist/assets/{StatisticsDashboard-BAZRqIPN.js → StatisticsDashboard-CtI1hlfO.js} +1 -1
- package/dist/assets/{SysmlCodeEditor-BBfup_Ni.js → SysmlCodeEditor-i0BHj3of.js} +117 -117
- package/dist/assets/{TabularView-I4LjHhoH.js → TabularView-DXxpRshk.js} +1 -1
- package/dist/assets/TraceabilityMatrix-qEKmDy8z.js +3 -0
- package/dist/assets/UiScreensWorkspace-BHhs5tcY.js +1 -0
- package/dist/assets/{WorkflowWizard-VwpEHt3R.js → WorkflowWizard-BjtGPRsS.js} +1 -1
- package/dist/assets/index-Cdkjp-H4.css +1 -0
- package/dist/assets/index-a2rpMs5Y.js +4067 -0
- package/dist/assets/{index.es-ClbJxlAQ.js → index.es-BwDQ0kmQ.js} +1 -1
- package/dist/assets/{jspdf.es.min-DZ68BGxk.js → jspdf.es.min-KfOikWO5.js} +3 -3
- package/dist/assets/{layout-providers-Dr743WlP.js → layout-providers-BSDYNZu0.js} +1 -1
- package/dist/assets/notation-scene-CxT28i2i.js +1 -0
- package/dist/assets/{reactflow-s7jmJtXx.js → reactflow-C9OlmOYw.js} +1 -1
- package/dist/assets/xlsx-CkFp8p6R.js +105 -0
- package/dist/index.html +3 -3
- package/dist-standalone/index.html +5504 -0
- package/lib/__tests__/standalone-distribution.test.d.ts +2 -0
- package/lib/__tests__/standalone-distribution.test.d.ts.map +1 -0
- package/lib/__tests__/standalone-distribution.test.js +51 -0
- package/lib/__tests__/standalone-distribution.test.js.map +1 -0
- package/lib/__tests__/supervised-child-args.test.js +21 -1
- package/lib/__tests__/supervised-child-args.test.js.map +1 -1
- package/lib/bin/memo-architect.js +15 -6
- package/lib/bin/memo-architect.js.map +1 -1
- package/lib/commands/build.d.ts.map +1 -1
- package/lib/commands/build.js +15 -18
- package/lib/commands/build.js.map +1 -1
- package/lib/commands/dev.d.ts +14 -0
- package/lib/commands/dev.d.ts.map +1 -1
- package/lib/commands/dev.js +40 -1
- package/lib/commands/dev.js.map +1 -1
- package/lib/feature-grants.d.ts.map +1 -1
- package/lib/feature-grants.js +3 -1
- package/lib/feature-grants.js.map +1 -1
- package/package.json +10 -6
- package/dist/assets/DSMView-BiC845df.js +0 -1
- package/dist/assets/Dashboard-CgnNLhKq.js +0 -1
- package/dist/assets/DhfDashboard-w-dJoJHU.js +0 -1
- package/dist/assets/DhfWorkbench-o6B_MT-0.js +0 -69
- package/dist/assets/DiagramCanvas-CqGqDbgT.js +0 -3
- package/dist/assets/DiagramToolbarControls-B2gZFJlg.js +0 -1
- package/dist/assets/ExplorerTreeRow-DqhF_qoO.js +0 -3
- package/dist/assets/TraceabilityMatrix-DbrvjqLN.js +0 -3
- package/dist/assets/UiScreensWorkspace-DDD_PyJs.js +0 -1
- package/dist/assets/editor.worker-DyuDvpVp.js +0 -26
- package/dist/assets/element-options-B7AgTB8R.js +0 -3
- package/dist/assets/index-BWMNo4wW.css +0 -1
- package/dist/assets/index-Bij8Q4Kg.js +0 -45
- package/dist/assets/notation-scene-DT8LpWVK.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var le=Object.defineProperty;var fe=(W,E,y)=>E in W?le(W,E,{enumerable:!0,configurable:!0,writable:!0,value:y}):W[E]=y;var ee=(W,E,y)=>fe(W,typeof E!="symbol"?E+"":E,y);import{g as ge}from"./zustand-CrhqMOHB.js";import{r as pe}from"./elk-6l8mIQnQ.js";const ve="memo.layout.elk";function ue(W){return structuredClone(W)}function me(W,E){const y=(r,s)=>{if(s.has(r.id))throw new Error(`Layout result contains duplicate node id: ${r.id}`);if(s.add(r.id),r.x!==void 0&&!Number.isFinite(r.x))throw new Error(`Layout result has invalid x for ${r.id}`);if(r.y!==void 0&&!Number.isFinite(r.y))throw new Error(`Layout result has invalid y for ${r.id}`);for(const t of r.children??[])y(t,s)},C=new Set,_=new Set;if(y(W,C),y(E,_),C.size!==_.size||[...C].some(r=>!_.has(r)))throw new Error("Layout provider changed the graph node identity set");const h=r=>`${r.id}\0${r.sources.join("\0")}\0${r.targets.join("\0")}`,n=new Set((W.edges??[]).map(h)),a=new Set((E.edges??[]).map(h));if(n.size!==a.size||[...n].some(r=>!a.has(r)))throw new Error("Layout provider changed the graph edge identity or endpoints")}class we{constructor(){ee(this,"providers",new Map)}register(E){const y=this.providers.get(E.descriptor.id);if(y&&y!==E)throw new Error(`Layout provider already registered: ${E.descriptor.id}`);this.providers.set(E.descriptor.id,E)}unregister(E){return this.providers.delete(E)}get(E){return this.providers.get(E)}list(E=[]){return[...this.providers.values()].map(y=>y.descriptor).filter(y=>E.every(C=>y.capabilities.includes(C))).sort((y,C)=>y.name.localeCompare(C.name))}async layout(E,y={}){var a;const C=y.providerId??ve,_=this.providers.get(C);if(!_)throw new Error(`Layout provider not found: ${C}`);const h=_.supports(E);if(!h.supported)throw new Error(`${_.descriptor.name} cannot layout this diagram${h.reason?`: ${h.reason}`:""}`);if((a=y.signal)!=null&&a.aborted)throw y.signal.reason??new DOMException("Layout aborted","AbortError");const n=await _.layout(E,y);return me(E,n),n}async dispose(){await Promise.all([...this.providers.values()].map(E=>{var y;return(y=E.dispose)==null?void 0:y.call(E)})),this.providers.clear()}}var K=(W,E)=>()=>(E||W((E={exports:{}}).exports,E),E.exports),Z=K((W,E)=>{var y=Object.defineProperty,C=(v,l,T)=>l in v?y(v,l,{enumerable:!0,configurable:!0,writable:!0,value:T}):v[l]=T,_=(v,l)=>()=>(l||v((l={exports:{}}).exports,l),l.exports),h=(v,l,T)=>C(v,typeof l!="symbol"?l+"":l,T),n=_((v,l)=>{var T="\0",b="\0",x="",I=class{constructor(o){h(this,"_isDirected",!0),h(this,"_isMultigraph",!1),h(this,"_isCompound",!1),h(this,"_label"),h(this,"_defaultNodeLabelFn",()=>{}),h(this,"_defaultEdgeLabelFn",()=>{}),h(this,"_nodes",{}),h(this,"_in",{}),h(this,"_preds",{}),h(this,"_out",{}),h(this,"_sucs",{}),h(this,"_edgeObjs",{}),h(this,"_edgeLabels",{}),h(this,"_nodeCount",0),h(this,"_edgeCount",0),h(this,"_parent"),h(this,"_children"),o&&(this._isDirected=Object.hasOwn(o,"directed")?o.directed:!0,this._isMultigraph=Object.hasOwn(o,"multigraph")?o.multigraph:!1,this._isCompound=Object.hasOwn(o,"compound")?o.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[b]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(o){return this._label=o,this}graph(){return this._label}setDefaultNodeLabel(o){return this._defaultNodeLabelFn=o,typeof o!="function"&&(this._defaultNodeLabelFn=()=>o),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var o=this;return this.nodes().filter(e=>Object.keys(o._in[e]).length===0)}sinks(){var o=this;return this.nodes().filter(e=>Object.keys(o._out[e]).length===0)}setNodes(o,e){var d=arguments,c=this;return o.forEach(function(m){d.length>1?c.setNode(m,e):c.setNode(m)}),this}setNode(o,e){return Object.hasOwn(this._nodes,o)?(arguments.length>1&&(this._nodes[o]=e),this):(this._nodes[o]=arguments.length>1?e:this._defaultNodeLabelFn(o),this._isCompound&&(this._parent[o]=b,this._children[o]={},this._children[b][o]=!0),this._in[o]={},this._preds[o]={},this._out[o]={},this._sucs[o]={},++this._nodeCount,this)}node(o){return this._nodes[o]}hasNode(o){return Object.hasOwn(this._nodes,o)}removeNode(o){var e=this;if(Object.hasOwn(this._nodes,o)){var d=c=>e.removeEdge(e._edgeObjs[c]);delete this._nodes[o],this._isCompound&&(this._removeFromParentsChildList(o),delete this._parent[o],this.children(o).forEach(function(c){e.setParent(c)}),delete this._children[o]),Object.keys(this._in[o]).forEach(d),delete this._in[o],delete this._preds[o],Object.keys(this._out[o]).forEach(d),delete this._out[o],delete this._sucs[o],--this._nodeCount}return this}setParent(o,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e===void 0)e=b;else{e+="";for(var d=e;d!==void 0;d=this.parent(d))if(d===o)throw new Error("Setting "+e+" as parent of "+o+" would create a cycle");this.setNode(e)}return this.setNode(o),this._removeFromParentsChildList(o),this._parent[o]=e,this._children[e][o]=!0,this}_removeFromParentsChildList(o){delete this._children[this._parent[o]][o]}parent(o){if(this._isCompound){var e=this._parent[o];if(e!==b)return e}}children(o=b){if(this._isCompound){var e=this._children[o];if(e)return Object.keys(e)}else{if(o===b)return this.nodes();if(this.hasNode(o))return[]}}predecessors(o){var e=this._preds[o];if(e)return Object.keys(e)}successors(o){var e=this._sucs[o];if(e)return Object.keys(e)}neighbors(o){var e=this.predecessors(o);if(e){let c=new Set(e);for(var d of this.successors(o))c.add(d);return Array.from(c.values())}}isLeaf(o){var e;return this.isDirected()?e=this.successors(o):e=this.neighbors(o),e.length===0}filterNodes(o){var e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph());var d=this;Object.entries(this._nodes).forEach(function([P,z]){o(P)&&e.setNode(P,z)}),Object.values(this._edgeObjs).forEach(function(P){e.hasNode(P.v)&&e.hasNode(P.w)&&e.setEdge(P,d.edge(P))});var c={};function m(P){var z=d.parent(P);return z===void 0||e.hasNode(z)?(c[P]=z,z):z in c?c[z]:m(z)}return this._isCompound&&e.nodes().forEach(P=>e.setParent(P,m(P))),e}setDefaultEdgeLabel(o){return this._defaultEdgeLabelFn=o,typeof o!="function"&&(this._defaultEdgeLabelFn=()=>o),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(o,e){var d=this,c=arguments;return o.reduce(function(m,P){return c.length>1?d.setEdge(m,P,e):d.setEdge(m,P),P}),this}setEdge(){var o,e,d,c,m=!1,P=arguments[0];typeof P=="object"&&P!==null&&"v"in P?(o=P.v,e=P.w,d=P.name,arguments.length===2&&(c=arguments[1],m=!0)):(o=P,e=arguments[1],d=arguments[3],arguments.length>2&&(c=arguments[2],m=!0)),o=""+o,e=""+e,d!==void 0&&(d=""+d);var z=F(this._isDirected,o,e,d);if(Object.hasOwn(this._edgeLabels,z))return m&&(this._edgeLabels[z]=c),this;if(d!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(e),this._edgeLabels[z]=m?c:this._defaultEdgeLabelFn(o,e,d);var U=A(this._isDirected,o,e,d);return o=U.v,e=U.w,Object.freeze(U),this._edgeObjs[z]=U,D(this._preds[e],o),D(this._sucs[o],e),this._in[e][z]=U,this._out[o][z]=U,this._edgeCount++,this}edge(o,e,d){var c=arguments.length===1?B(this._isDirected,arguments[0]):F(this._isDirected,o,e,d);return this._edgeLabels[c]}edgeAsObj(){let o=this.edge(...arguments);return typeof o!="object"?{label:o}:o}hasEdge(o,e,d){var c=arguments.length===1?B(this._isDirected,arguments[0]):F(this._isDirected,o,e,d);return Object.hasOwn(this._edgeLabels,c)}removeEdge(o,e,d){var c=arguments.length===1?B(this._isDirected,arguments[0]):F(this._isDirected,o,e,d),m=this._edgeObjs[c];return m&&(o=m.v,e=m.w,delete this._edgeLabels[c],delete this._edgeObjs[c],R(this._preds[e],o),R(this._sucs[o],e),delete this._in[e][c],delete this._out[o][c],this._edgeCount--),this}inEdges(o,e){return this.isDirected()?this.filterEdges(this._in[o],o,e):this.nodeEdges(o,e)}outEdges(o,e){return this.isDirected()?this.filterEdges(this._out[o],o,e):this.nodeEdges(o,e)}nodeEdges(o,e){if(o in this._nodes)return this.filterEdges({...this._in[o],...this._out[o]},o,e)}filterEdges(o,e,d){if(o){var c=Object.values(o);return d?c.filter(function(m){return m.v===e&&m.w===d||m.v===d&&m.w===e}):c}}};function D(o,e){o[e]?o[e]++:o[e]=1}function R(o,e){--o[e]||delete o[e]}function F(o,e,d,c){var m=""+e,P=""+d;if(!o&&m>P){var z=m;m=P,P=z}return m+x+P+x+(c===void 0?T:c)}function A(o,e,d,c){var m=""+e,P=""+d;if(!o&&m>P){var z=m;m=P,P=z}var U={v:m,w:P};return c&&(U.name=c),U}function B(o,e){return F(o,e.v,e.w,e.name)}l.exports=I}),a=_((v,l)=>{l.exports="3.0.2"}),r=_((v,l)=>{l.exports={Graph:n(),version:a()}}),s=_((v,l)=>{var T=n();l.exports={write:b,read:D};function b(R){var F={options:{directed:R.isDirected(),multigraph:R.isMultigraph(),compound:R.isCompound()},nodes:x(R),edges:I(R)};return R.graph()!==void 0&&(F.value=structuredClone(R.graph())),F}function x(R){return R.nodes().map(function(F){var A=R.node(F),B=R.parent(F),o={v:F};return A!==void 0&&(o.value=A),B!==void 0&&(o.parent=B),o})}function I(R){return R.edges().map(function(F){var A=R.edge(F),B={v:F.v,w:F.w};return F.name!==void 0&&(B.name=F.name),A!==void 0&&(B.value=A),B})}function D(R){var F=new T(R.options).setGraph(R.value);return R.nodes.forEach(function(A){F.setNode(A.v,A.value),A.parent&&F.setParent(A.v,A.parent)}),R.edges.forEach(function(A){F.setEdge({v:A.v,w:A.w,name:A.name},A.value)}),F}}),t=_((v,l)=>{l.exports=b;var T=()=>1;function b(I,D,R,F){return x(I,String(D),R||T,F||function(A){return I.outEdges(A)})}function x(I,D,R,F){var A={},B=!0,o=0,e=I.nodes(),d=function(z){var U=R(z);A[z.v].distance+U<A[z.w].distance&&(A[z.w]={distance:A[z.v].distance+U,predecessor:z.v},B=!0)},c=function(){e.forEach(function(z){F(z).forEach(function(U){var H=U.v===z?U.v:U.w,te=H===U.v?U.w:U.v;d({v:H,w:te})})})};e.forEach(function(z){var U=z===D?0:Number.POSITIVE_INFINITY;A[z]={distance:U}});for(var m=e.length,P=1;P<m&&(B=!1,o++,c(),!!B);P++);if(o===m-1&&(B=!1,c(),B))throw new Error("The graph contains a negative weight cycle");return A}}),i=_((v,l)=>{l.exports=T;function T(b){var x={},I=[],D;function R(F){Object.hasOwn(x,F)||(x[F]=!0,D.push(F),b.successors(F).forEach(R),b.predecessors(F).forEach(R))}return b.nodes().forEach(function(F){D=[],R(F),D.length&&I.push(D)}),I}}),g=_((v,l)=>{var T=class{constructor(){h(this,"_arr",[]),h(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(b){return b.key})}has(b){return Object.hasOwn(this._keyIndices,b)}priority(b){var x=this._keyIndices[b];if(x!==void 0)return this._arr[x].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(b,x){var I=this._keyIndices;if(b=String(b),!Object.hasOwn(I,b)){var D=this._arr,R=D.length;return I[b]=R,D.push({key:b,priority:x}),this._decrease(R),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var b=this._arr.pop();return delete this._keyIndices[b.key],this._heapify(0),b.key}decrease(b,x){var I=this._keyIndices[b];if(x>this._arr[I].priority)throw new Error("New priority is greater than current priority. Key: "+b+" Old: "+this._arr[I].priority+" New: "+x);this._arr[I].priority=x,this._decrease(I)}_heapify(b){var x=this._arr,I=2*b,D=I+1,R=b;I<x.length&&(R=x[I].priority<x[R].priority?I:R,D<x.length&&(R=x[D].priority<x[R].priority?D:R),R!==b&&(this._swap(b,R),this._heapify(R)))}_decrease(b){for(var x=this._arr,I=x[b].priority,D;b!==0&&(D=b>>1,!(x[D].priority<I));)this._swap(b,D),b=D}_swap(b,x){var I=this._arr,D=this._keyIndices,R=I[b],F=I[x];I[b]=F,I[x]=R,D[F.key]=b,D[R.key]=x}};l.exports=T}),u=_((v,l)=>{var T=g();l.exports=x;var b=()=>1;function x(D,R,F,A){var B=function(o){return D.outEdges(o)};return I(D,String(R),F||b,A||B)}function I(D,R,F,A){var B={},o=new T,e,d,c=function(m){var P=m.v!==e?m.v:m.w,z=B[P],U=F(m),H=d.distance+U;if(U<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+U);H<z.distance&&(z.distance=H,z.predecessor=e,o.decrease(P,H))};for(D.nodes().forEach(function(m){var P=m===R?0:Number.POSITIVE_INFINITY;B[m]={distance:P},o.add(m,P)});o.size()>0&&(e=o.removeMin(),d=B[e],d.distance!==Number.POSITIVE_INFINITY);)A(e).forEach(c);return B}}),N=_((v,l)=>{var T=u();l.exports=b;function b(x,I,D){return x.nodes().reduce(function(R,F){return R[F]=T(x,F,I,D),R},{})}}),V=_((v,l)=>{l.exports=T;function T(x,I,D){if(x[I].predecessor!==void 0)throw new Error("Invalid source vertex");if(x[D].predecessor===void 0&&D!==I)throw new Error("Invalid destination vertex");return{weight:x[D].distance,path:b(x,I,D)}}function b(x,I,D){for(var R=[],F=D;F!==I;)R.push(F),F=x[F].predecessor;return R.push(I),R.reverse()}}),Y=_((v,l)=>{l.exports=T;function T(b){var x=0,I=[],D={},R=[];function F(A){var B=D[A]={onStack:!0,lowlink:x,index:x++};if(I.push(A),b.successors(A).forEach(function(d){Object.hasOwn(D,d)?D[d].onStack&&(B.lowlink=Math.min(B.lowlink,D[d].index)):(F(d),B.lowlink=Math.min(B.lowlink,D[d].lowlink))}),B.lowlink===B.index){var o=[],e;do e=I.pop(),D[e].onStack=!1,o.push(e);while(A!==e);R.push(o)}}return b.nodes().forEach(function(A){Object.hasOwn(D,A)||F(A)}),R}}),q=_((v,l)=>{var T=Y();l.exports=b;function b(x){return T(x).filter(function(I){return I.length>1||I.length===1&&x.hasEdge(I[0],I[0])})}}),k=_((v,l)=>{l.exports=b;var T=()=>1;function b(I,D,R){return x(I,D||T,R||function(F){return I.outEdges(F)})}function x(I,D,R){var F={},A=I.nodes();return A.forEach(function(B){F[B]={},F[B][B]={distance:0},A.forEach(function(o){B!==o&&(F[B][o]={distance:Number.POSITIVE_INFINITY})}),R(B).forEach(function(o){var e=o.v===B?o.w:o.v,d=D(o);F[B][e]={distance:d,predecessor:B}})}),A.forEach(function(B){var o=F[B];A.forEach(function(e){var d=F[e];A.forEach(function(c){var m=d[B],P=o[c],z=d[c],U=m.distance+P.distance;U<z.distance&&(z.distance=U,z.predecessor=P.predecessor)})})}),F}}),L=_((v,l)=>{function T(x){var I={},D={},R=[];function F(A){if(Object.hasOwn(D,A))throw new b;Object.hasOwn(I,A)||(D[A]=!0,I[A]=!0,x.predecessors(A).forEach(F),delete D[A],R.push(A))}if(x.sinks().forEach(F),Object.keys(I).length!==x.nodeCount())throw new b;return R}var b=class extends Error{constructor(){super(...arguments)}};l.exports=T,T.CycleException=b}),p=_((v,l)=>{var T=L();l.exports=b;function b(x){try{T(x)}catch(I){if(I instanceof T.CycleException)return!1;throw I}return!0}}),j=_((v,l)=>{l.exports=T;function T(x,I,D,R,F){Array.isArray(I)||(I=[I]);var A=(x.isDirected()?x.successors:x.neighbors).bind(x),B={};return I.forEach(function(o){if(!x.hasNode(o))throw new Error("Graph does not have node: "+o);F=b(x,o,D==="post",B,A,R,F)}),F}function b(x,I,D,R,F,A,B){return Object.hasOwn(R,I)||(R[I]=!0,D||(B=A(B,I)),F(I).forEach(function(o){B=b(x,o,D,R,F,A,B)}),D&&(B=A(B,I))),B}}),M=_((v,l)=>{var T=j();l.exports=b;function b(x,I,D){return T(x,I,D,function(R,F){return R.push(F),R},[])}}),G=_((v,l)=>{var T=M();l.exports=b;function b(x,I){return T(x,I,"post")}}),S=_((v,l)=>{var T=M();l.exports=b;function b(x,I){return T(x,I,"pre")}}),$=_((v,l)=>{var T=n(),b=g();l.exports=x;function x(I,D){var R=new T,F={},A=new b,B;function o(d){var c=d.v===B?d.w:d.v,m=A.priority(c);if(m!==void 0){var P=D(d);P<m&&(F[c]=B,A.decrease(c,P))}}if(I.nodeCount()===0)return R;I.nodes().forEach(function(d){A.add(d,Number.POSITIVE_INFINITY),R.setNode(d)}),A.decrease(I.nodes()[0],0);for(var e=!1;A.size()>0;){if(B=A.removeMin(),Object.hasOwn(F,B))R.setEdge(B,F[B]);else{if(e)throw new Error("Input graph is not connected: "+I);e=!0}I.nodeEdges(B).forEach(o)}return R}}),f=_((v,l)=>{var T=u(),b=t();l.exports=x;function x(D,R,F,A){return I(D,R,F,A||function(B){return D.outEdges(B)})}function I(D,R,F,A){if(F===void 0)return T(D,R,F,A);for(var B=!1,o=D.nodes(),e=0;e<o.length;e++){for(var d=A(o[e]),c=0;c<d.length;c++){var m=d[c],P=m.v===o[e]?m.v:m.w,z=P===m.v?m.w:m.v;F({v:P,w:z})<0&&(B=!0)}if(B)return b(D,R,F,A)}return T(D,R,F,A)}}),w=_((v,l)=>{l.exports={bellmanFord:t(),components:i(),dijkstra:u(),dijkstraAll:N(),extractPath:V(),findCycles:q(),floydWarshall:k(),isAcyclic:p(),postorder:G(),preorder:S(),prim:$(),shortestPaths:f(),reduce:j(),tarjan:Y(),topsort:L()}}),O=r();E.exports={Graph:O.Graph,json:s(),alg:w(),version:O.version}}),Ee=K((W,E)=>{var y=class{constructor(){let h={};h._next=h._prev=h,this._sentinel=h}dequeue(){let h=this._sentinel,n=h._prev;if(n!==h)return C(n),n}enqueue(h){let n=this._sentinel;h._prev&&h._next&&C(h),h._next=n._next,n._next._prev=h,n._next=h,h._prev=n}toString(){let h=[],n=this._sentinel,a=n._prev;for(;a!==n;)h.push(JSON.stringify(a,_)),a=a._prev;return"["+h.join(", ")+"]"}};function C(h){h._prev._next=h._next,h._next._prev=h._prev,delete h._next,delete h._prev}function _(h,n){if(h!=="_next"&&h!=="_prev")return n}E.exports=y}),be=K((W,E)=>{var y=Z().Graph,C=Ee();E.exports=h;var _=()=>1;function h(i,g){if(i.nodeCount()<=1)return[];let u=r(i,g||_);return n(u.graph,u.buckets,u.zeroIdx).flatMap(N=>i.outEdges(N.v,N.w))}function n(i,g,u){let N=[],V=g[g.length-1],Y=g[0],q;for(;i.nodeCount();){for(;q=Y.dequeue();)a(i,g,u,q);for(;q=V.dequeue();)a(i,g,u,q);if(i.nodeCount()){for(let k=g.length-2;k>0;--k)if(q=g[k].dequeue(),q){N=N.concat(a(i,g,u,q,!0));break}}}return N}function a(i,g,u,N,V){let Y=V?[]:void 0;return i.inEdges(N.v).forEach(q=>{let k=i.edge(q),L=i.node(q.v);V&&Y.push({v:q.v,w:q.w}),L.out-=k,s(g,u,L)}),i.outEdges(N.v).forEach(q=>{let k=i.edge(q),L=q.w,p=i.node(L);p.in-=k,s(g,u,p)}),i.removeNode(N.v),Y}function r(i,g){let u=new y,N=0,V=0;i.nodes().forEach(k=>{u.setNode(k,{v:k,in:0,out:0})}),i.edges().forEach(k=>{let L=u.edge(k.v,k.w)||0,p=g(k),j=L+p;u.setEdge(k.v,k.w,j),V=Math.max(V,u.node(k.v).out+=p),N=Math.max(N,u.node(k.w).in+=p)});let Y=t(V+N+3).map(()=>new C),q=N+1;return u.nodes().forEach(k=>{s(Y,q,u.node(k))}),{graph:u,buckets:Y,zeroIdx:q}}function s(i,g,u){u.out?u.in?i[u.out-u.in+g].enqueue(u):i[i.length-1].enqueue(u):i[0].enqueue(u)}function t(i){let g=[];for(let u=0;u<i;u++)g.push(u);return g}}),X=K((W,E)=>{var y=Z().Graph;E.exports={addBorderNode:g,addDummyNode:C,applyWithChunking:V,asNonCompoundGraph:h,buildLayerMatrix:s,intersectRect:r,mapValues:S,maxRank:Y,normalizeRanks:t,notime:L,partition:q,pick:G,predecessorWeights:a,range:M,removeEmptyRanks:i,simplify:_,successorWeights:n,time:k,uniqueId:j,zipObject:$};function C(f,w,O,v){for(var l=v;f.hasNode(l);)l=j(v);return O.dummy=w,f.setNode(l,O),l}function _(f){let w=new y().setGraph(f.graph());return f.nodes().forEach(O=>w.setNode(O,f.node(O))),f.edges().forEach(O=>{let v=w.edge(O.v,O.w)||{weight:0,minlen:1},l=f.edge(O);w.setEdge(O.v,O.w,{weight:v.weight+l.weight,minlen:Math.max(v.minlen,l.minlen)})}),w}function h(f){let w=new y({multigraph:f.isMultigraph()}).setGraph(f.graph());return f.nodes().forEach(O=>{f.children(O).length||w.setNode(O,f.node(O))}),f.edges().forEach(O=>{w.setEdge(O,f.edge(O))}),w}function n(f){let w=f.nodes().map(O=>{let v={};return f.outEdges(O).forEach(l=>{v[l.w]=(v[l.w]||0)+f.edge(l).weight}),v});return $(f.nodes(),w)}function a(f){let w=f.nodes().map(O=>{let v={};return f.inEdges(O).forEach(l=>{v[l.v]=(v[l.v]||0)+f.edge(l).weight}),v});return $(f.nodes(),w)}function r(f,w){let O=f.x,v=f.y,l=w.x-O,T=w.y-v,b=f.width/2,x=f.height/2;if(!l&&!T)throw new Error("Not possible to find intersection inside of the rectangle");let I,D;return Math.abs(T)*b>Math.abs(l)*x?(T<0&&(x=-x),I=x*l/T,D=x):(l<0&&(b=-b),I=b,D=b*T/l),{x:O+I,y:v+D}}function s(f){let w=M(Y(f)+1).map(()=>[]);return f.nodes().forEach(O=>{let v=f.node(O),l=v.rank;l!==void 0&&(w[l][v.order]=O)}),w}function t(f){let w=f.nodes().map(v=>{let l=f.node(v).rank;return l===void 0?Number.MAX_VALUE:l}),O=V(Math.min,w);f.nodes().forEach(v=>{let l=f.node(v);Object.hasOwn(l,"rank")&&(l.rank-=O)})}function i(f){let w=f.nodes().map(b=>f.node(b).rank).filter(b=>b!==void 0),O=V(Math.min,w),v=[];f.nodes().forEach(b=>{let x=f.node(b).rank-O;v[x]||(v[x]=[]),v[x].push(b)});let l=0,T=f.graph().nodeRankFactor;Array.from(v).forEach((b,x)=>{b===void 0&&x%T!==0?--l:b!==void 0&&l&&b.forEach(I=>f.node(I).rank+=l)})}function g(f,w,O,v){let l={width:0,height:0};return arguments.length>=4&&(l.rank=O,l.order=v),C(f,"border",l,w)}function u(f,w=N){let O=[];for(let v=0;v<f.length;v+=w){let l=f.slice(v,v+w);O.push(l)}return O}var N=65535;function V(f,w){if(w.length>N){let O=u(w);return f.apply(null,O.map(v=>f.apply(null,v)))}else return f.apply(null,w)}function Y(f){let w=f.nodes().map(O=>{let v=f.node(O).rank;return v===void 0?Number.MIN_VALUE:v});return V(Math.max,w)}function q(f,w){let O={lhs:[],rhs:[]};return f.forEach(v=>{w(v)?O.lhs.push(v):O.rhs.push(v)}),O}function k(f,w){let O=Date.now();try{return w()}finally{console.log(f+" time: "+(Date.now()-O)+"ms")}}function L(f,w){return w()}var p=0;function j(f){var w=++p;return f+(""+w)}function M(f,w,O=1){w==null&&(w=f,f=0);let v=T=>T<w;O<0&&(v=T=>w<T);let l=[];for(let T=f;v(T);T+=O)l.push(T);return l}function G(f,w){let O={};for(let v of w)f[v]!==void 0&&(O[v]=f[v]);return O}function S(f,w){let O=w;return typeof w=="string"&&(O=v=>v[w]),Object.entries(f).reduce((v,[l,T])=>(v[l]=O(T,l),v),{})}function $(f,w){return f.reduce((O,v,l)=>(O[v]=w[l],O),{})}}),ye=K((W,E)=>{var y=be(),C=X().uniqueId;E.exports={run:_,undo:n};function _(a){(a.graph().acyclicer==="greedy"?y(a,r(a)):h(a)).forEach(s=>{let t=a.edge(s);a.removeEdge(s),t.forwardName=s.name,t.reversed=!0,a.setEdge(s.w,s.v,t,C("rev"))});function r(s){return t=>s.edge(t).weight}}function h(a){let r=[],s={},t={};function i(g){Object.hasOwn(t,g)||(t[g]=!0,s[g]=!0,a.outEdges(g).forEach(u=>{Object.hasOwn(s,u.w)?r.push(u):i(u.w)}),delete s[g])}return a.nodes().forEach(i),r}function n(a){a.edges().forEach(r=>{let s=a.edge(r);if(s.reversed){a.removeEdge(r);let t=s.forwardName;delete s.reversed,delete s.forwardName,a.setEdge(r.w,r.v,s,t)}})}}),_e=K((W,E)=>{var y=X();E.exports={run:C,undo:h};function C(n){n.graph().dummyChains=[],n.edges().forEach(a=>_(n,a))}function _(n,a){let r=a.v,s=n.node(r).rank,t=a.w,i=n.node(t).rank,g=a.name,u=n.edge(a),N=u.labelRank;if(i===s+1)return;n.removeEdge(a);let V,Y,q;for(q=0,++s;s<i;++q,++s)u.points=[],Y={width:0,height:0,edgeLabel:u,edgeObj:a,rank:s},V=y.addDummyNode(n,"edge",Y,"_d"),s===N&&(Y.width=u.width,Y.height=u.height,Y.dummy="edge-label",Y.labelpos=u.labelpos),n.setEdge(r,V,{weight:u.weight},g),q===0&&n.graph().dummyChains.push(V),r=V;n.setEdge(r,t,{weight:u.weight},g)}function h(n){n.graph().dummyChains.forEach(a=>{let r=n.node(a),s=r.edgeLabel,t;for(n.setEdge(r.edgeObj,s);r.dummy;)t=n.successors(a)[0],n.removeNode(a),s.points.push({x:r.x,y:r.y}),r.dummy==="edge-label"&&(s.x=r.x,s.y=r.y,s.width=r.width,s.height=r.height),a=t,r=n.node(a)})}}),ne=K((W,E)=>{var{applyWithChunking:y}=X();E.exports={longestPath:C,slack:_};function C(h){var n={};function a(r){var s=h.node(r);if(Object.hasOwn(n,r))return s.rank;n[r]=!0;let t=h.outEdges(r).map(g=>g==null?Number.POSITIVE_INFINITY:a(g.w)-h.edge(g).minlen);var i=y(Math.min,t);return i===Number.POSITIVE_INFINITY&&(i=0),s.rank=i}h.sources().forEach(a)}function _(h,n){return h.node(n.w).rank-h.node(n.v).rank-h.edge(n).minlen}}),he=K((W,E)=>{var y=Z().Graph,C=ne().slack;E.exports=_;function _(r){var s=new y({directed:!1}),t=r.nodes()[0],i=r.nodeCount();s.setNode(t,{});for(var g,u;h(s,r)<i;)g=n(s,r),u=s.hasNode(g.v)?C(r,g):-C(r,g),a(s,r,u);return s}function h(r,s){function t(i){s.nodeEdges(i).forEach(g=>{var u=g.v,N=i===u?g.w:u;!r.hasNode(N)&&!C(s,g)&&(r.setNode(N,{}),r.setEdge(i,N,{}),t(N))})}return r.nodes().forEach(t),r.nodeCount()}function n(r,s){return s.edges().reduce((t,i)=>{let g=Number.POSITIVE_INFINITY;return r.hasNode(i.v)!==r.hasNode(i.w)&&(g=C(s,i)),g<t[0]?[g,i]:t},[Number.POSITIVE_INFINITY,null])[1]}function a(r,s,t){r.nodes().forEach(i=>s.node(i).rank+=t)}}),ke=K((W,E)=>{var y=he(),C=ne().slack,_=ne().longestPath,h=Z().alg.preorder,n=Z().alg.postorder,a=X().simplify;E.exports=r,r.initLowLimValues=g,r.initCutValues=s,r.calcCutValue=i,r.leaveEdge=N,r.enterEdge=V,r.exchangeEdges=Y;function r(p){p=a(p),_(p);var j=y(p);g(j),s(j,p);for(var M,G;M=N(j);)G=V(j,p,M),Y(j,p,M,G)}function s(p,j){var M=n(p,p.nodes());M=M.slice(0,M.length-1),M.forEach(G=>t(p,j,G))}function t(p,j,M){var G=p.node(M),S=G.parent;p.edge(M,S).cutvalue=i(p,j,M)}function i(p,j,M){var G=p.node(M),S=G.parent,$=!0,f=j.edge(M,S),w=0;return f||($=!1,f=j.edge(S,M)),w=f.weight,j.nodeEdges(M).forEach(O=>{var v=O.v===M,l=v?O.w:O.v;if(l!==S){var T=v===$,b=j.edge(O).weight;if(w+=T?b:-b,k(p,M,l)){var x=p.edge(M,l).cutvalue;w+=T?-x:x}}}),w}function g(p,j){arguments.length<2&&(j=p.nodes()[0]),u(p,{},1,j)}function u(p,j,M,G,S){var $=M,f=p.node(G);return j[G]=!0,p.neighbors(G).forEach(w=>{Object.hasOwn(j,w)||(M=u(p,j,M,w,G))}),f.low=$,f.lim=M++,S?f.parent=S:delete f.parent,M}function N(p){return p.edges().find(j=>p.edge(j).cutvalue<0)}function V(p,j,M){var G=M.v,S=M.w;j.hasEdge(G,S)||(G=M.w,S=M.v);var $=p.node(G),f=p.node(S),w=$,O=!1;$.lim>f.lim&&(w=f,O=!0);var v=j.edges().filter(l=>O===L(p,p.node(l.v),w)&&O!==L(p,p.node(l.w),w));return v.reduce((l,T)=>C(j,T)<C(j,l)?T:l)}function Y(p,j,M,G){var S=M.v,$=M.w;p.removeEdge(S,$),p.setEdge(G.v,G.w,{}),g(p),s(p,j),q(p,j)}function q(p,j){var M=p.nodes().find(S=>!j.node(S).parent),G=h(p,M);G=G.slice(1),G.forEach(S=>{var $=p.node(S).parent,f=j.edge(S,$),w=!1;f||(f=j.edge($,S),w=!0),j.node(S).rank=j.node($).rank+(w?f.minlen:-f.minlen)})}function k(p,j,M){return p.hasEdge(j,M)}function L(p,j,M){return M.low<=j.lim&&j.lim<=M.lim}}),xe=K((W,E)=>{var y=ne(),C=y.longestPath,_=he(),h=ke();E.exports=n;function n(t){var i=t.graph().ranker;if(i instanceof Function)return i(t);switch(t.graph().ranker){case"network-simplex":s(t);break;case"tight-tree":r(t);break;case"longest-path":a(t);break;case"none":break;default:s(t)}}var a=C;function r(t){C(t),_(t)}function s(t){h(t)}}),Oe=K((W,E)=>{E.exports=y;function y(h){let n=_(h);h.graph().dummyChains.forEach(a=>{let r=h.node(a),s=r.edgeObj,t=C(h,n,s.v,s.w),i=t.path,g=t.lca,u=0,N=i[u],V=!0;for(;a!==s.w;){if(r=h.node(a),V){for(;(N=i[u])!==g&&h.node(N).maxRank<r.rank;)u++;N===g&&(V=!1)}if(!V){for(;u<i.length-1&&h.node(N=i[u+1]).minRank<=r.rank;)u++;N=i[u]}h.setParent(a,N),a=h.successors(a)[0]}})}function C(h,n,a,r){let s=[],t=[],i=Math.min(n[a].low,n[r].low),g=Math.max(n[a].lim,n[r].lim),u,N;u=a;do u=h.parent(u),s.push(u);while(u&&(n[u].low>i||g>n[u].lim));for(N=u,u=r;(u=h.parent(u))!==N;)t.push(u);return{path:s.concat(t.reverse()),lca:N}}function _(h){let n={},a=0;function r(s){let t=a;h.children(s).forEach(r),n[s]={low:t,lim:a++}}return h.children().forEach(r),n}}),Ne=K((W,E)=>{var y=X();E.exports={run:C,cleanup:a};function C(r){let s=y.addDummyNode(r,"root",{},"_root"),t=h(r),i=Object.values(t),g=y.applyWithChunking(Math.max,i)-1,u=2*g+1;r.graph().nestingRoot=s,r.edges().forEach(V=>r.edge(V).minlen*=u);let N=n(r)+1;r.children().forEach(V=>_(r,s,u,N,g,t,V)),r.graph().nodeRankFactor=u}function _(r,s,t,i,g,u,N){let V=r.children(N);if(!V.length){N!==s&&r.setEdge(s,N,{weight:0,minlen:t});return}let Y=y.addBorderNode(r,"_bt"),q=y.addBorderNode(r,"_bb"),k=r.node(N);r.setParent(Y,N),k.borderTop=Y,r.setParent(q,N),k.borderBottom=q,V.forEach(L=>{_(r,s,t,i,g,u,L);let p=r.node(L),j=p.borderTop?p.borderTop:L,M=p.borderBottom?p.borderBottom:L,G=p.borderTop?i:2*i,S=j!==M?1:g-u[N]+1;r.setEdge(Y,j,{weight:G,minlen:S,nestingEdge:!0}),r.setEdge(M,q,{weight:G,minlen:S,nestingEdge:!0})}),r.parent(N)||r.setEdge(s,Y,{weight:0,minlen:g+u[N]})}function h(r){var s={};function t(i,g){var u=r.children(i);u&&u.length&&u.forEach(N=>t(N,g+1)),s[i]=g}return r.children().forEach(i=>t(i,1)),s}function n(r){return r.edges().reduce((s,t)=>s+r.edge(t).weight,0)}function a(r){var s=r.graph();r.removeNode(s.nestingRoot),delete s.nestingRoot,r.edges().forEach(t=>{var i=r.edge(t);i.nestingEdge&&r.removeEdge(t)})}}),Ie=K((W,E)=>{var y=X();E.exports=C;function C(h){function n(a){let r=h.children(a),s=h.node(a);if(r.length&&r.forEach(n),Object.hasOwn(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(let t=s.minRank,i=s.maxRank+1;t<i;++t)_(h,"borderLeft","_bl",a,s,t),_(h,"borderRight","_br",a,s,t)}}h.children().forEach(n)}function _(h,n,a,r,s,t){let i={width:0,height:0,rank:t,borderType:n},g=s[n][t-1],u=y.addDummyNode(h,"border",i,a);s[n][t]=u,h.setParent(u,r),g&&h.setEdge(g,u,{weight:1})}}),je=K((W,E)=>{E.exports={adjust:y,undo:C};function y(t){let i=t.graph().rankdir.toLowerCase();(i==="lr"||i==="rl")&&_(t)}function C(t){let i=t.graph().rankdir.toLowerCase();(i==="bt"||i==="rl")&&n(t),(i==="lr"||i==="rl")&&(r(t),_(t))}function _(t){t.nodes().forEach(i=>h(t.node(i))),t.edges().forEach(i=>h(t.edge(i)))}function h(t){let i=t.width;t.width=t.height,t.height=i}function n(t){t.nodes().forEach(i=>a(t.node(i))),t.edges().forEach(i=>{let g=t.edge(i);g.points.forEach(a),Object.hasOwn(g,"y")&&a(g)})}function a(t){t.y=-t.y}function r(t){t.nodes().forEach(i=>s(t.node(i))),t.edges().forEach(i=>{let g=t.edge(i);g.points.forEach(s),Object.hasOwn(g,"x")&&s(g)})}function s(t){let i=t.x;t.x=t.y,t.y=i}}),Le=K((W,E)=>{var y=X();E.exports=C;function C(_){let h={},n=_.nodes().filter(i=>!_.children(i).length),a=n.map(i=>_.node(i).rank),r=y.applyWithChunking(Math.max,a),s=y.range(r+1).map(()=>[]);function t(i){if(h[i])return;h[i]=!0;let g=_.node(i);s[g.rank].push(i),_.successors(i).forEach(t)}return n.sort((i,g)=>_.node(i).rank-_.node(g).rank).forEach(t),s}}),Ce=K((W,E)=>{var y=X().zipObject;E.exports=C;function C(h,n){let a=0;for(let r=1;r<n.length;++r)a+=_(h,n[r-1],n[r]);return a}function _(h,n,a){let r=y(a,a.map((N,V)=>V)),s=n.flatMap(N=>h.outEdges(N).map(V=>({pos:r[V.w],weight:h.edge(V).weight})).sort((V,Y)=>V.pos-Y.pos)),t=1;for(;t<a.length;)t<<=1;let i=2*t-1;t-=1;let g=new Array(i).fill(0),u=0;return s.forEach(N=>{let V=N.pos+t;g[V]+=N.weight;let Y=0;for(;V>0;)V%2&&(Y+=g[V+1]),V=V-1>>1,g[V]+=N.weight;u+=N.weight*Y}),u}}),Me=K((W,E)=>{E.exports=y;function y(C,_=[]){return _.map(h=>{let n=C.inEdges(h);if(n.length){let a=n.reduce((r,s)=>{let t=C.edge(s),i=C.node(s.v);return{sum:r.sum+t.weight*i.order,weight:r.weight+t.weight}},{sum:0,weight:0});return{v:h,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:h}})}}),Te=K((W,E)=>{var y=X();E.exports=C;function C(n,a){let r={};n.forEach((t,i)=>{let g=r[t.v]={indegree:0,in:[],out:[],vs:[t.v],i};t.barycenter!==void 0&&(g.barycenter=t.barycenter,g.weight=t.weight)}),a.edges().forEach(t=>{let i=r[t.v],g=r[t.w];i!==void 0&&g!==void 0&&(g.indegree++,i.out.push(r[t.w]))});let s=Object.values(r).filter(t=>!t.indegree);return _(s)}function _(n){let a=[];function r(t){return i=>{i.merged||(i.barycenter===void 0||t.barycenter===void 0||i.barycenter>=t.barycenter)&&h(t,i)}}function s(t){return i=>{i.in.push(t),--i.indegree===0&&n.push(i)}}for(;n.length;){let t=n.pop();a.push(t),t.in.reverse().forEach(r(t)),t.out.forEach(s(t))}return a.filter(t=>!t.merged).map(t=>y.pick(t,["vs","i","barycenter","weight"]))}function h(n,a){let r=0,s=0;n.weight&&(r+=n.barycenter*n.weight,s+=n.weight),a.weight&&(r+=a.barycenter*a.weight,s+=a.weight),n.vs=a.vs.concat(n.vs),n.barycenter=r/s,n.weight=s,n.i=Math.min(a.i,n.i),a.merged=!0}}),Pe=K((W,E)=>{var y=X();E.exports=C;function C(n,a){let r=y.partition(n,Y=>Object.hasOwn(Y,"barycenter")),s=r.lhs,t=r.rhs.sort((Y,q)=>q.i-Y.i),i=[],g=0,u=0,N=0;s.sort(h(!!a)),N=_(i,t,N),s.forEach(Y=>{N+=Y.vs.length,i.push(Y.vs),g+=Y.barycenter*Y.weight,u+=Y.weight,N=_(i,t,N)});let V={vs:i.flat(!0)};return u&&(V.barycenter=g/u,V.weight=u),V}function _(n,a,r){let s;for(;a.length&&(s=a[a.length-1]).i<=r;)a.pop(),n.push(s.vs),r++;return r}function h(n){return(a,r)=>a.barycenter<r.barycenter?-1:a.barycenter>r.barycenter?1:n?r.i-a.i:a.i-r.i}}),Re=K((W,E)=>{var y=Me(),C=Te(),_=Pe();E.exports=h;function h(r,s,t,i){let g=r.children(s),u=r.node(s),N=u?u.borderLeft:void 0,V=u?u.borderRight:void 0,Y={};N&&(g=g.filter(p=>p!==N&&p!==V));let q=y(r,g);q.forEach(p=>{if(r.children(p.v).length){let j=h(r,p.v,t,i);Y[p.v]=j,Object.hasOwn(j,"barycenter")&&a(p,j)}});let k=C(q,t);n(k,Y);let L=_(k,i);if(N&&(L.vs=[N,L.vs,V].flat(!0),r.predecessors(N).length)){let p=r.node(r.predecessors(N)[0]),j=r.node(r.predecessors(V)[0]);Object.hasOwn(L,"barycenter")||(L.barycenter=0,L.weight=0),L.barycenter=(L.barycenter*L.weight+p.order+j.order)/(L.weight+2),L.weight+=2}return L}function n(r,s){r.forEach(t=>{t.vs=t.vs.flatMap(i=>s[i]?s[i].vs:i)})}function a(r,s){r.barycenter!==void 0?(r.barycenter=(r.barycenter*r.weight+s.barycenter*s.weight)/(r.weight+s.weight),r.weight+=s.weight):(r.barycenter=s.barycenter,r.weight=s.weight)}}),Fe=K((W,E)=>{var y=Z().Graph,C=X();E.exports=_;function _(n,a,r,s){s||(s=n.nodes());let t=h(n),i=new y({compound:!0}).setGraph({root:t}).setDefaultNodeLabel(g=>n.node(g));return s.forEach(g=>{let u=n.node(g),N=n.parent(g);(u.rank===a||u.minRank<=a&&a<=u.maxRank)&&(i.setNode(g),i.setParent(g,N||t),n[r](g).forEach(V=>{let Y=V.v===g?V.w:V.v,q=i.edge(Y,g),k=q!==void 0?q.weight:0;i.setEdge(Y,g,{weight:n.edge(V).weight+k})}),Object.hasOwn(u,"minRank")&&i.setNode(g,{borderLeft:u.borderLeft[a],borderRight:u.borderRight[a]}))}),i}function h(n){for(var a;n.hasNode(a=C.uniqueId("_root")););return a}}),De=K((W,E)=>{E.exports=y;function y(C,_,h){let n={},a;h.forEach(r=>{let s=C.parent(r),t,i;for(;s;){if(t=C.parent(s),t?(i=n[t],n[t]=s):(i=a,a=s),i&&i!==s){_.setEdge(i,s);return}s=t}})}}),Se=K((W,E)=>{var y=Le(),C=Ce(),_=Re(),h=Fe(),n=De(),a=Z().Graph,r=X();E.exports=s;function s(u,N={}){if(typeof N.customOrder=="function"){N.customOrder(u,s);return}let V=r.maxRank(u),Y=t(u,r.range(1,V+1),"inEdges"),q=t(u,r.range(V-1,-1,-1),"outEdges"),k=y(u);if(g(u,k),N.disableOptimalOrderHeuristic)return;let L=Number.POSITIVE_INFINITY,p,j=N.constraints||[];for(let M=0,G=0;G<4;++M,++G){i(M%2?Y:q,M%4>=2,j),k=r.buildLayerMatrix(u);let S=C(u,k);S<L?(G=0,p=Object.assign({},k),L=S):S===L&&(p=structuredClone(k))}g(u,p)}function t(u,N,V){let Y=new Map,q=(k,L)=>{Y.has(k)||Y.set(k,[]),Y.get(k).push(L)};for(let k of u.nodes()){let L=u.node(k);if(typeof L.rank=="number"&&q(L.rank,k),typeof L.minRank=="number"&&typeof L.maxRank=="number")for(let p=L.minRank;p<=L.maxRank;p++)p!==L.rank&&q(p,k)}return N.map(function(k){return h(u,k,V,Y.get(k)||[])})}function i(u,N,V){let Y=new a;u.forEach(function(q){V.forEach(p=>Y.setEdge(p.left,p.right));let k=q.graph().root,L=_(q,k,Y,N);L.vs.forEach((p,j)=>q.node(p).order=j),n(q,Y,L.vs)})}function g(u,N){Object.values(N).forEach(V=>V.forEach((Y,q)=>u.node(Y).order=q))}}),Ge=K((W,E)=>{var y=Z().Graph,C=X();E.exports={positionX:V,findType1Conflicts:_,findType2Conflicts:h,addConflict:a,hasConflict:r,verticalAlignment:s,horizontalCompaction:t,alignCoordinates:u,findSmallestWidthAlignment:g,balance:N};function _(k,L){let p={};function j(M,G){let S=0,$=0,f=M.length,w=G[G.length-1];return G.forEach((O,v)=>{let l=n(k,O),T=l?k.node(l).order:f;(l||O===w)&&(G.slice($,v+1).forEach(b=>{k.predecessors(b).forEach(x=>{let I=k.node(x),D=I.order;(D<S||T<D)&&!(I.dummy&&k.node(b).dummy)&&a(p,x,b)})}),$=v+1,S=T)}),G}return L.length&&L.reduce(j),p}function h(k,L){let p={};function j(G,S,$,f,w){let O;C.range(S,$).forEach(v=>{O=G[v],k.node(O).dummy&&k.predecessors(O).forEach(l=>{let T=k.node(l);T.dummy&&(T.order<f||T.order>w)&&a(p,l,O)})})}function M(G,S){let $=-1,f,w=0;return S.forEach((O,v)=>{if(k.node(O).dummy==="border"){let l=k.predecessors(O);l.length&&(f=k.node(l[0]).order,j(S,w,v,$,f),w=v,$=f)}j(S,w,S.length,f,G.length)}),S}return L.length&&L.reduce(M),p}function n(k,L){if(k.node(L).dummy)return k.predecessors(L).find(p=>k.node(p).dummy)}function a(k,L,p){if(L>p){let M=L;L=p,p=M}let j=k[L];j||(k[L]=j={}),j[p]=!0}function r(k,L,p){if(L>p){let j=L;L=p,p=j}return!!k[L]&&Object.hasOwn(k[L],p)}function s(k,L,p,j){let M={},G={},S={};return L.forEach($=>{$.forEach((f,w)=>{M[f]=f,G[f]=f,S[f]=w})}),L.forEach($=>{let f=-1;$.forEach(w=>{let O=j(w);if(O.length){O=O.sort((l,T)=>S[l]-S[T]);let v=(O.length-1)/2;for(let l=Math.floor(v),T=Math.ceil(v);l<=T;++l){let b=O[l];G[w]===w&&f<S[b]&&!r(p,w,b)&&(G[b]=w,G[w]=M[w]=M[b],f=S[b])}}})}),{root:M,align:G}}function t(k,L,p,j,M){let G={},S=i(k,L,p,M),$=M?"borderLeft":"borderRight";function f(v,l){let T=S.nodes().slice(),b={},x=T.pop();for(;x;){if(b[x])v(x);else{b[x]=!0,T.push(x);for(let I of l(x))T.push(I)}x=T.pop()}}function w(v){G[v]=S.inEdges(v).reduce((l,T)=>Math.max(l,G[T.v]+S.edge(T)),0)}function O(v){let l=S.outEdges(v).reduce((b,x)=>Math.min(b,G[x.w]-S.edge(x)),Number.POSITIVE_INFINITY),T=k.node(v);l!==Number.POSITIVE_INFINITY&&T.borderType!==$&&(G[v]=Math.max(G[v],l))}return f(w,S.predecessors.bind(S)),f(O,S.successors.bind(S)),Object.keys(j).forEach(v=>G[v]=G[p[v]]),G}function i(k,L,p,j){let M=new y,G=k.graph(),S=Y(G.nodesep,G.edgesep,j);return L.forEach($=>{let f;$.forEach(w=>{let O=p[w];if(M.setNode(O),f){var v=p[f],l=M.edge(v,O);M.setEdge(v,O,Math.max(S(k,w,f),l||0))}f=w})}),M}function g(k,L){return Object.values(L).reduce((p,j)=>{let M=Number.NEGATIVE_INFINITY,G=Number.POSITIVE_INFINITY;Object.entries(j).forEach(([$,f])=>{let w=q(k,$)/2;M=Math.max(f+w,M),G=Math.min(f-w,G)});let S=M-G;return S<p[0]&&(p=[S,j]),p},[Number.POSITIVE_INFINITY,null])[1]}function u(k,L){let p=Object.values(L),j=C.applyWithChunking(Math.min,p),M=C.applyWithChunking(Math.max,p);["u","d"].forEach(G=>{["l","r"].forEach(S=>{let $=G+S,f=k[$];if(f===L)return;let w=Object.values(f),O=j-C.applyWithChunking(Math.min,w);S!=="l"&&(O=M-C.applyWithChunking(Math.max,w)),O&&(k[$]=C.mapValues(f,v=>v+O))})})}function N(k,L){return C.mapValues(k.ul,(p,j)=>{if(L)return k[L.toLowerCase()][j];{let M=Object.values(k).map(G=>G[j]).sort((G,S)=>G-S);return(M[1]+M[2])/2}})}function V(k){let L=C.buildLayerMatrix(k),p=Object.assign(_(k,L),h(k,L)),j={},M;["u","d"].forEach(S=>{M=S==="u"?L:Object.values(L).reverse(),["l","r"].forEach($=>{$==="r"&&(M=M.map(v=>Object.values(v).reverse()));let f=(S==="u"?k.predecessors:k.successors).bind(k),w=s(k,M,p,f),O=t(k,M,w.root,w.align,$==="r");$==="r"&&(O=C.mapValues(O,v=>-v)),j[S+$]=O})});let G=g(k,j);return u(j,G),N(j,k.graph().align)}function Y(k,L,p){return(j,M,G)=>{let S=j.node(M),$=j.node(G),f=0,w;if(f+=S.width/2,Object.hasOwn(S,"labelpos"))switch(S.labelpos.toLowerCase()){case"l":w=-S.width/2;break;case"r":w=S.width/2;break}if(w&&(f+=p?w:-w),w=0,f+=(S.dummy?L:k)/2,f+=($.dummy?L:k)/2,f+=$.width/2,Object.hasOwn($,"labelpos"))switch($.labelpos.toLowerCase()){case"l":w=$.width/2;break;case"r":w=-$.width/2;break}return w&&(f+=p?w:-w),w=0,f}}function q(k,L){return k.node(L).width}}),Ve=K((W,E)=>{var y=X(),C=Ge().positionX;E.exports=_;function _(n){n=y.asNonCompoundGraph(n),h(n),Object.entries(C(n)).forEach(([a,r])=>n.node(a).x=r)}function h(n){let a=y.buildLayerMatrix(n),r=n.graph().ranksep,s=n.graph().rankalign,t=0;a.forEach(i=>{let g=i.reduce((u,N)=>{let V=n.node(N).height;return u>V?u:V},0);i.forEach(u=>{let N=n.node(u);s==="top"?N.y=t+N.height/2:s==="bottom"?N.y=t+g-N.height/2:N.y=t+g/2}),t+=g+r})}}),Ae=K((W,E)=>{var y=ye(),C=_e(),_=xe(),h=X().normalizeRanks,n=Oe(),a=X().removeEmptyRanks,r=Ne(),s=Ie(),t=je(),i=Se(),g=Ve(),u=X(),N=Z().Graph;E.exports=V;function V(e,d={}){let c=d.debugTiming?u.time:u.notime;return c("layout",()=>{let m=c(" buildLayoutGraph",()=>f(e));return c(" runLayout",()=>Y(m,c,d)),c(" updateInputGraph",()=>q(e,m)),m})}function Y(e,d,c){d(" makeSpaceForEdgeLabels",()=>w(e)),d(" removeSelfEdges",()=>R(e)),d(" acyclic",()=>y.run(e)),d(" nestingGraph.run",()=>r.run(e)),d(" rank",()=>_(u.asNonCompoundGraph(e))),d(" injectEdgeLabelProxies",()=>O(e)),d(" removeEmptyRanks",()=>a(e)),d(" nestingGraph.cleanup",()=>r.cleanup(e)),d(" normalizeRanks",()=>h(e)),d(" assignRankMinMax",()=>v(e)),d(" removeEdgeLabelProxies",()=>l(e)),d(" normalize.run",()=>C.run(e)),d(" parentDummyChains",()=>n(e)),d(" addBorderSegments",()=>s(e)),d(" order",()=>i(e,c)),d(" insertSelfEdges",()=>F(e)),d(" adjustCoordinateSystem",()=>t.adjust(e)),d(" position",()=>g(e)),d(" positionSelfEdges",()=>A(e)),d(" removeBorderNodes",()=>D(e)),d(" normalize.undo",()=>C.undo(e)),d(" fixupEdgeLabelCoords",()=>x(e)),d(" undoCoordinateSystem",()=>t.undo(e)),d(" translateGraph",()=>T(e)),d(" assignNodeIntersects",()=>b(e)),d(" reversePoints",()=>I(e)),d(" acyclic.undo",()=>y.undo(e))}function q(e,d){e.nodes().forEach(c=>{let m=e.node(c),P=d.node(c);m&&(m.x=P.x,m.y=P.y,m.order=P.order,m.rank=P.rank,d.children(c).length&&(m.width=P.width,m.height=P.height))}),e.edges().forEach(c=>{let m=e.edge(c),P=d.edge(c);m.points=P.points,Object.hasOwn(P,"x")&&(m.x=P.x,m.y=P.y)}),e.graph().width=d.graph().width,e.graph().height=d.graph().height}var k=["nodesep","edgesep","ranksep","marginx","marginy"],L={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb",rankalign:"center"},p=["acyclicer","ranker","rankdir","align","rankalign"],j=["width","height","rank"],M={width:0,height:0},G=["minlen","weight","width","height","labeloffset"],S={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},$=["labelpos"];function f(e){let d=new N({multigraph:!0,compound:!0}),c=o(e.graph());return d.setGraph(Object.assign({},L,B(c,k),u.pick(c,p))),e.nodes().forEach(m=>{let P=o(e.node(m)),z=B(P,j);Object.keys(M).forEach(U=>{z[U]===void 0&&(z[U]=M[U])}),d.setNode(m,z),d.setParent(m,e.parent(m))}),e.edges().forEach(m=>{let P=o(e.edge(m));d.setEdge(m,Object.assign({},S,B(P,G),u.pick(P,$)))}),d}function w(e){let d=e.graph();d.ranksep/=2,e.edges().forEach(c=>{let m=e.edge(c);m.minlen*=2,m.labelpos.toLowerCase()!=="c"&&(d.rankdir==="TB"||d.rankdir==="BT"?m.width+=m.labeloffset:m.height+=m.labeloffset)})}function O(e){e.edges().forEach(d=>{let c=e.edge(d);if(c.width&&c.height){let m=e.node(d.v),P={rank:(e.node(d.w).rank-m.rank)/2+m.rank,e:d};u.addDummyNode(e,"edge-proxy",P,"_ep")}})}function v(e){let d=0;e.nodes().forEach(c=>{let m=e.node(c);m.borderTop&&(m.minRank=e.node(m.borderTop).rank,m.maxRank=e.node(m.borderBottom).rank,d=Math.max(d,m.maxRank))}),e.graph().maxRank=d}function l(e){e.nodes().forEach(d=>{let c=e.node(d);c.dummy==="edge-proxy"&&(e.edge(c.e).labelRank=c.rank,e.removeNode(d))})}function T(e){let d=Number.POSITIVE_INFINITY,c=0,m=Number.POSITIVE_INFINITY,P=0,z=e.graph(),U=z.marginx||0,H=z.marginy||0;function te(J){let Q=J.x,re=J.y,se=J.width,ae=J.height;d=Math.min(d,Q-se/2),c=Math.max(c,Q+se/2),m=Math.min(m,re-ae/2),P=Math.max(P,re+ae/2)}e.nodes().forEach(J=>te(e.node(J))),e.edges().forEach(J=>{let Q=e.edge(J);Object.hasOwn(Q,"x")&&te(Q)}),d-=U,m-=H,e.nodes().forEach(J=>{let Q=e.node(J);Q.x-=d,Q.y-=m}),e.edges().forEach(J=>{let Q=e.edge(J);Q.points.forEach(re=>{re.x-=d,re.y-=m}),Object.hasOwn(Q,"x")&&(Q.x-=d),Object.hasOwn(Q,"y")&&(Q.y-=m)}),z.width=c-d+U,z.height=P-m+H}function b(e){e.edges().forEach(d=>{let c=e.edge(d),m=e.node(d.v),P=e.node(d.w),z,U;c.points?(z=c.points[0],U=c.points[c.points.length-1]):(c.points=[],z=P,U=m),c.points.unshift(u.intersectRect(m,z)),c.points.push(u.intersectRect(P,U))})}function x(e){e.edges().forEach(d=>{let c=e.edge(d);if(Object.hasOwn(c,"x"))switch((c.labelpos==="l"||c.labelpos==="r")&&(c.width-=c.labeloffset),c.labelpos){case"l":c.x-=c.width/2+c.labeloffset;break;case"r":c.x+=c.width/2+c.labeloffset;break}})}function I(e){e.edges().forEach(d=>{let c=e.edge(d);c.reversed&&c.points.reverse()})}function D(e){e.nodes().forEach(d=>{if(e.children(d).length){let c=e.node(d),m=e.node(c.borderTop),P=e.node(c.borderBottom),z=e.node(c.borderLeft[c.borderLeft.length-1]),U=e.node(c.borderRight[c.borderRight.length-1]);c.width=Math.abs(U.x-z.x),c.height=Math.abs(P.y-m.y),c.x=z.x+c.width/2,c.y=m.y+c.height/2}}),e.nodes().forEach(d=>{e.node(d).dummy==="border"&&e.removeNode(d)})}function R(e){e.edges().forEach(d=>{if(d.v===d.w){var c=e.node(d.v);c.selfEdges||(c.selfEdges=[]),c.selfEdges.push({e:d,label:e.edge(d)}),e.removeEdge(d)}})}function F(e){var d=u.buildLayerMatrix(e);d.forEach(c=>{var m=0;c.forEach((P,z)=>{var U=e.node(P);U.order=z+m,(U.selfEdges||[]).forEach(H=>{u.addDummyNode(e,"selfedge",{width:H.label.width,height:H.label.height,rank:U.rank,order:z+ ++m,e:H.e,label:H.label},"_se")}),delete U.selfEdges})})}function A(e){e.nodes().forEach(d=>{var c=e.node(d);if(c.dummy==="selfedge"){var m=e.node(c.e.v),P=m.x+m.width/2,z=m.y,U=c.x-P,H=m.height/2;e.setEdge(c.e,c.label),e.removeNode(d),c.label.points=[{x:P+2*U/3,y:z-H},{x:P+5*U/6,y:z-H},{x:P+U,y:z},{x:P+5*U/6,y:z+H},{x:P+2*U/3,y:z+H}],c.label.x=c.x,c.label.y=c.y}})}function B(e,d){return u.mapValues(u.pick(e,d),Number)}function o(e){var d={};return e&&Object.entries(e).forEach(([c,m])=>{typeof c=="string"&&(c=c.toLowerCase()),d[c]=m}),d}}),Be=K((W,E)=>{var y=X(),C=Z().Graph;E.exports={debugOrdering:_};function _(h){let n=y.buildLayerMatrix(h),a=new C({compound:!0,multigraph:!0}).setGraph({});return h.nodes().forEach(r=>{a.setNode(r,{label:r}),a.setParent(r,"layer"+h.node(r).rank)}),h.edges().forEach(r=>a.setEdge(r.v,r.w,{},r.name)),n.forEach((r,s)=>{let t="layer"+s;a.setNode(t,{rank:"same"}),r.reduce((i,g)=>(a.setEdge(i,g,{style:"invis"}),g))}),a}}),ze=K((W,E)=>{E.exports="2.0.4"}),Ye=K((W,E)=>{E.exports={graphlib:Z(),layout:Ae(),debug:Be(),util:{time:X().time,notime:X().notime},version:ze()}});const ie=Ye();/*! For license information please see dagre.esm.js.LEGAL.txt */const We=W=>(W.children??[]).some(E=>{var y,C;return(((y=E.children)==null?void 0:y.length)??0)>0||(((C=E.ports)==null?void 0:C.length)??0)>0}),qe=W=>{switch(W){case"UP":return"BT";case"RIGHT":return"LR";case"LEFT":return"RL";default:return"TB"}};class $e{constructor(){ee(this,"descriptor",{id:"memo.layout.dagre",name:"Dagre",version:ie.version,contractVersion:"1",license:"MIT",description:"Fast directed layout for flat graphs and trees.",mode:"automatic",capabilities:["flat-graph","deterministic"]})}supports(E){const y=!We(E);return{supported:y,...y?{}:{reason:"compound nodes and explicit ports require a different provider"}}}async layout(E){const y=ue(E),C=E.layoutOptions??{},_=new ie.graphlib.Graph({multigraph:!0}).setGraph({rankdir:qe(C["elk.direction"]),nodesep:Number(C["elk.spacing.nodeNode"]??40),ranksep:Number(C["elk.layered.spacing.nodeNodeBetweenLayers"]??80),marginx:20,marginy:20}).setDefaultEdgeLabel(()=>({}));for(const n of y.children??[])_.setNode(n.id,{width:n.width??1,height:n.height??1});for(const n of y.edges??[]){const a=n.sources[0],r=n.targets[0];a&&r&&_.hasNode(a)&&_.hasNode(r)&&_.setEdge(a,r,{},n.id)}ie.layout(_);for(const n of y.children??[]){const a=_.node(n.id);a&&(n.x=a.x-(n.width??1)/2,n.y=a.y-(n.height??1)/2)}for(const n of y.edges??[]){const a=n.sources[0],r=n.targets[0];if(!a||!r||!_.hasEdge(a,r,n.id))continue;const s=_.edge(a,r,n.id),t=(s==null?void 0:s.points)??[];t.length>=2&&(n.sections=[{id:`${n.id}-section`,startPoint:t[0],endPoint:t[t.length-1],bendPoints:t.slice(1,-1)}])}const h=_.graph();return y.width=h.width,y.height=h.height,y}}var Ue=pe();const de=ge(Ue),Ke=5e3;class Xe{constructor(){ee(this,"descriptor",{id:"memo.layout.elk",name:"ELK",version:"0.9.3",contractVersion:"1",license:"EPL-2.0",description:"Layered and hierarchical engineering layouts with ports and orthogonal routes.",mode:"automatic",capabilities:["flat-graph","compound-graph","explicit-ports","orthogonal-routes","fixed-nodes","deterministic","cancellable","worker-runtime"]});ee(this,"instance");ee(this,"chain",Promise.resolve())}supports(){return{supported:!0}}layout(E,y={}){const C=()=>this.runBounded(E,y),_=this.chain.then(C,C);return this.chain=_.then(()=>{},()=>{}),_}dispose(){this.reset()}getInstance(){return this.instance||(this.instance=typeof Worker>"u"?new de:new de({workerFactory:E=>new Worker(new URL("/assets/elk-worker.min-BgEwn2y-.js",import.meta.url))})),this.instance}reset(){var E,y;try{(y=(E=this.instance)==null?void 0:E.terminateWorker)==null||y.call(E)}catch{}this.instance=void 0}runBounded(E,y){return new Promise((C,_)=>{var t,i;let h=!1;const n=g=>{var u;h||(h=!0,clearTimeout(s),(u=y.signal)==null||u.removeEventListener("abort",a),g())},a=()=>n(()=>{var g;this.reset(),_(((g=y.signal)==null?void 0:g.reason)??new DOMException("Layout aborted","AbortError"))}),r=y.timeoutMs??Ke,s=setTimeout(()=>n(()=>{this.reset(),_(new Error(`ELK layout timed out after ${r/1e3}s`))}),r);if((t=y.signal)==null||t.addEventListener("abort",a,{once:!0}),(i=y.signal)!=null&&i.aborted)return a();this.getInstance().layout(E).then(g=>n(()=>C(g)),g=>n(()=>_(g)))})}}const ce=W=>(W.id==="root"||Number.isFinite(W.x)&&Number.isFinite(W.y))&&(W.children??[]).every(ce);class He{constructor(){ee(this,"descriptor",{id:"memo.layout.fixed",name:"Fixed / authored",version:"1.0.0",contractVersion:"1",license:"Internal",description:"Preserves existing authored geometry without automatic rearrangement.",mode:"preserve",capabilities:["flat-graph","compound-graph","explicit-ports","fixed-nodes","deterministic"]})}supports(E){const y=ce(E);return{supported:y,...y?{}:{reason:"every node must already have finite x/y coordinates"}}}async layout(E){return ue(E)}}const oe=new we;oe.register(new Xe);oe.register(new $e);oe.register(new He);function er(W,E){return oe.layout(W,E)}export{ve as D,er as r};
|
|
1
|
+
var le=Object.defineProperty;var fe=(Y,E,y)=>E in Y?le(Y,E,{enumerable:!0,configurable:!0,writable:!0,value:y}):Y[E]=y;var ee=(Y,E,y)=>fe(Y,typeof E!="symbol"?E+"":E,y);import{g as ge}from"./zustand-CrhqMOHB.js";import{r as pe}from"./elk-6l8mIQnQ.js";const ve="memo.layout.elk";function ue(Y){return structuredClone(Y)}function me(Y,E){const y=(r,s)=>{if(s.has(r.id))throw new Error(`Layout result contains duplicate node id: ${r.id}`);if(s.add(r.id),r.x!==void 0&&!Number.isFinite(r.x))throw new Error(`Layout result has invalid x for ${r.id}`);if(r.y!==void 0&&!Number.isFinite(r.y))throw new Error(`Layout result has invalid y for ${r.id}`);for(const t of r.children??[])y(t,s)},C=new Set,_=new Set;if(y(Y,C),y(E,_),C.size!==_.size||[...C].some(r=>!_.has(r)))throw new Error("Layout provider changed the graph node identity set");const h=r=>`${r.id}\0${r.sources.join("\0")}\0${r.targets.join("\0")}`,n=new Set((Y.edges??[]).map(h)),a=new Set((E.edges??[]).map(h));if(n.size!==a.size||[...n].some(r=>!a.has(r)))throw new Error("Layout provider changed the graph edge identity or endpoints")}class we{constructor(){ee(this,"providers",new Map)}register(E){const y=this.providers.get(E.descriptor.id);if(y&&y!==E)throw new Error(`Layout provider already registered: ${E.descriptor.id}`);this.providers.set(E.descriptor.id,E)}unregister(E){return this.providers.delete(E)}get(E){return this.providers.get(E)}list(E=[]){return[...this.providers.values()].map(y=>y.descriptor).filter(y=>E.every(C=>y.capabilities.includes(C))).sort((y,C)=>y.name.localeCompare(C.name))}async layout(E,y={}){var a;const C=y.providerId??ve,_=this.providers.get(C);if(!_)throw new Error(`Layout provider not found: ${C}`);const h=_.supports(E);if(!h.supported)throw new Error(`${_.descriptor.name} cannot layout this diagram${h.reason?`: ${h.reason}`:""}`);if((a=y.signal)!=null&&a.aborted)throw y.signal.reason??new DOMException("Layout aborted","AbortError");const n=await _.layout(E,y);return me(E,n),n}async dispose(){await Promise.all([...this.providers.values()].map(E=>{var y;return(y=E.dispose)==null?void 0:y.call(E)})),this.providers.clear()}}var K=(Y,E)=>()=>(E||Y((E={exports:{}}).exports,E),E.exports),Z=K((Y,E)=>{var y=Object.defineProperty,C=(v,l,T)=>l in v?y(v,l,{enumerable:!0,configurable:!0,writable:!0,value:T}):v[l]=T,_=(v,l)=>()=>(l||v((l={exports:{}}).exports,l),l.exports),h=(v,l,T)=>C(v,typeof l!="symbol"?l+"":l,T),n=_((v,l)=>{var T="\0",b="\0",x="",I=class{constructor(o){h(this,"_isDirected",!0),h(this,"_isMultigraph",!1),h(this,"_isCompound",!1),h(this,"_label"),h(this,"_defaultNodeLabelFn",()=>{}),h(this,"_defaultEdgeLabelFn",()=>{}),h(this,"_nodes",{}),h(this,"_in",{}),h(this,"_preds",{}),h(this,"_out",{}),h(this,"_sucs",{}),h(this,"_edgeObjs",{}),h(this,"_edgeLabels",{}),h(this,"_nodeCount",0),h(this,"_edgeCount",0),h(this,"_parent"),h(this,"_children"),o&&(this._isDirected=Object.hasOwn(o,"directed")?o.directed:!0,this._isMultigraph=Object.hasOwn(o,"multigraph")?o.multigraph:!1,this._isCompound=Object.hasOwn(o,"compound")?o.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[b]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(o){return this._label=o,this}graph(){return this._label}setDefaultNodeLabel(o){return this._defaultNodeLabelFn=o,typeof o!="function"&&(this._defaultNodeLabelFn=()=>o),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var o=this;return this.nodes().filter(e=>Object.keys(o._in[e]).length===0)}sinks(){var o=this;return this.nodes().filter(e=>Object.keys(o._out[e]).length===0)}setNodes(o,e){var d=arguments,c=this;return o.forEach(function(m){d.length>1?c.setNode(m,e):c.setNode(m)}),this}setNode(o,e){return Object.hasOwn(this._nodes,o)?(arguments.length>1&&(this._nodes[o]=e),this):(this._nodes[o]=arguments.length>1?e:this._defaultNodeLabelFn(o),this._isCompound&&(this._parent[o]=b,this._children[o]={},this._children[b][o]=!0),this._in[o]={},this._preds[o]={},this._out[o]={},this._sucs[o]={},++this._nodeCount,this)}node(o){return this._nodes[o]}hasNode(o){return Object.hasOwn(this._nodes,o)}removeNode(o){var e=this;if(Object.hasOwn(this._nodes,o)){var d=c=>e.removeEdge(e._edgeObjs[c]);delete this._nodes[o],this._isCompound&&(this._removeFromParentsChildList(o),delete this._parent[o],this.children(o).forEach(function(c){e.setParent(c)}),delete this._children[o]),Object.keys(this._in[o]).forEach(d),delete this._in[o],delete this._preds[o],Object.keys(this._out[o]).forEach(d),delete this._out[o],delete this._sucs[o],--this._nodeCount}return this}setParent(o,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e===void 0)e=b;else{e+="";for(var d=e;d!==void 0;d=this.parent(d))if(d===o)throw new Error("Setting "+e+" as parent of "+o+" would create a cycle");this.setNode(e)}return this.setNode(o),this._removeFromParentsChildList(o),this._parent[o]=e,this._children[e][o]=!0,this}_removeFromParentsChildList(o){delete this._children[this._parent[o]][o]}parent(o){if(this._isCompound){var e=this._parent[o];if(e!==b)return e}}children(o=b){if(this._isCompound){var e=this._children[o];if(e)return Object.keys(e)}else{if(o===b)return this.nodes();if(this.hasNode(o))return[]}}predecessors(o){var e=this._preds[o];if(e)return Object.keys(e)}successors(o){var e=this._sucs[o];if(e)return Object.keys(e)}neighbors(o){var e=this.predecessors(o);if(e){let c=new Set(e);for(var d of this.successors(o))c.add(d);return Array.from(c.values())}}isLeaf(o){var e;return this.isDirected()?e=this.successors(o):e=this.neighbors(o),e.length===0}filterNodes(o){var e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph());var d=this;Object.entries(this._nodes).forEach(function([P,z]){o(P)&&e.setNode(P,z)}),Object.values(this._edgeObjs).forEach(function(P){e.hasNode(P.v)&&e.hasNode(P.w)&&e.setEdge(P,d.edge(P))});var c={};function m(P){var z=d.parent(P);return z===void 0||e.hasNode(z)?(c[P]=z,z):z in c?c[z]:m(z)}return this._isCompound&&e.nodes().forEach(P=>e.setParent(P,m(P))),e}setDefaultEdgeLabel(o){return this._defaultEdgeLabelFn=o,typeof o!="function"&&(this._defaultEdgeLabelFn=()=>o),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(o,e){var d=this,c=arguments;return o.reduce(function(m,P){return c.length>1?d.setEdge(m,P,e):d.setEdge(m,P),P}),this}setEdge(){var o,e,d,c,m=!1,P=arguments[0];typeof P=="object"&&P!==null&&"v"in P?(o=P.v,e=P.w,d=P.name,arguments.length===2&&(c=arguments[1],m=!0)):(o=P,e=arguments[1],d=arguments[3],arguments.length>2&&(c=arguments[2],m=!0)),o=""+o,e=""+e,d!==void 0&&(d=""+d);var z=F(this._isDirected,o,e,d);if(Object.hasOwn(this._edgeLabels,z))return m&&(this._edgeLabels[z]=c),this;if(d!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(e),this._edgeLabels[z]=m?c:this._defaultEdgeLabelFn(o,e,d);var U=A(this._isDirected,o,e,d);return o=U.v,e=U.w,Object.freeze(U),this._edgeObjs[z]=U,D(this._preds[e],o),D(this._sucs[o],e),this._in[e][z]=U,this._out[o][z]=U,this._edgeCount++,this}edge(o,e,d){var c=arguments.length===1?B(this._isDirected,arguments[0]):F(this._isDirected,o,e,d);return this._edgeLabels[c]}edgeAsObj(){let o=this.edge(...arguments);return typeof o!="object"?{label:o}:o}hasEdge(o,e,d){var c=arguments.length===1?B(this._isDirected,arguments[0]):F(this._isDirected,o,e,d);return Object.hasOwn(this._edgeLabels,c)}removeEdge(o,e,d){var c=arguments.length===1?B(this._isDirected,arguments[0]):F(this._isDirected,o,e,d),m=this._edgeObjs[c];return m&&(o=m.v,e=m.w,delete this._edgeLabels[c],delete this._edgeObjs[c],R(this._preds[e],o),R(this._sucs[o],e),delete this._in[e][c],delete this._out[o][c],this._edgeCount--),this}inEdges(o,e){return this.isDirected()?this.filterEdges(this._in[o],o,e):this.nodeEdges(o,e)}outEdges(o,e){return this.isDirected()?this.filterEdges(this._out[o],o,e):this.nodeEdges(o,e)}nodeEdges(o,e){if(o in this._nodes)return this.filterEdges({...this._in[o],...this._out[o]},o,e)}filterEdges(o,e,d){if(o){var c=Object.values(o);return d?c.filter(function(m){return m.v===e&&m.w===d||m.v===d&&m.w===e}):c}}};function D(o,e){o[e]?o[e]++:o[e]=1}function R(o,e){--o[e]||delete o[e]}function F(o,e,d,c){var m=""+e,P=""+d;if(!o&&m>P){var z=m;m=P,P=z}return m+x+P+x+(c===void 0?T:c)}function A(o,e,d,c){var m=""+e,P=""+d;if(!o&&m>P){var z=m;m=P,P=z}var U={v:m,w:P};return c&&(U.name=c),U}function B(o,e){return F(o,e.v,e.w,e.name)}l.exports=I}),a=_((v,l)=>{l.exports="3.0.2"}),r=_((v,l)=>{l.exports={Graph:n(),version:a()}}),s=_((v,l)=>{var T=n();l.exports={write:b,read:D};function b(R){var F={options:{directed:R.isDirected(),multigraph:R.isMultigraph(),compound:R.isCompound()},nodes:x(R),edges:I(R)};return R.graph()!==void 0&&(F.value=structuredClone(R.graph())),F}function x(R){return R.nodes().map(function(F){var A=R.node(F),B=R.parent(F),o={v:F};return A!==void 0&&(o.value=A),B!==void 0&&(o.parent=B),o})}function I(R){return R.edges().map(function(F){var A=R.edge(F),B={v:F.v,w:F.w};return F.name!==void 0&&(B.name=F.name),A!==void 0&&(B.value=A),B})}function D(R){var F=new T(R.options).setGraph(R.value);return R.nodes.forEach(function(A){F.setNode(A.v,A.value),A.parent&&F.setParent(A.v,A.parent)}),R.edges.forEach(function(A){F.setEdge({v:A.v,w:A.w,name:A.name},A.value)}),F}}),t=_((v,l)=>{l.exports=b;var T=()=>1;function b(I,D,R,F){return x(I,String(D),R||T,F||function(A){return I.outEdges(A)})}function x(I,D,R,F){var A={},B=!0,o=0,e=I.nodes(),d=function(z){var U=R(z);A[z.v].distance+U<A[z.w].distance&&(A[z.w]={distance:A[z.v].distance+U,predecessor:z.v},B=!0)},c=function(){e.forEach(function(z){F(z).forEach(function(U){var H=U.v===z?U.v:U.w,te=H===U.v?U.w:U.v;d({v:H,w:te})})})};e.forEach(function(z){var U=z===D?0:Number.POSITIVE_INFINITY;A[z]={distance:U}});for(var m=e.length,P=1;P<m&&(B=!1,o++,c(),!!B);P++);if(o===m-1&&(B=!1,c(),B))throw new Error("The graph contains a negative weight cycle");return A}}),i=_((v,l)=>{l.exports=T;function T(b){var x={},I=[],D;function R(F){Object.hasOwn(x,F)||(x[F]=!0,D.push(F),b.successors(F).forEach(R),b.predecessors(F).forEach(R))}return b.nodes().forEach(function(F){D=[],R(F),D.length&&I.push(D)}),I}}),g=_((v,l)=>{var T=class{constructor(){h(this,"_arr",[]),h(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(b){return b.key})}has(b){return Object.hasOwn(this._keyIndices,b)}priority(b){var x=this._keyIndices[b];if(x!==void 0)return this._arr[x].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(b,x){var I=this._keyIndices;if(b=String(b),!Object.hasOwn(I,b)){var D=this._arr,R=D.length;return I[b]=R,D.push({key:b,priority:x}),this._decrease(R),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var b=this._arr.pop();return delete this._keyIndices[b.key],this._heapify(0),b.key}decrease(b,x){var I=this._keyIndices[b];if(x>this._arr[I].priority)throw new Error("New priority is greater than current priority. Key: "+b+" Old: "+this._arr[I].priority+" New: "+x);this._arr[I].priority=x,this._decrease(I)}_heapify(b){var x=this._arr,I=2*b,D=I+1,R=b;I<x.length&&(R=x[I].priority<x[R].priority?I:R,D<x.length&&(R=x[D].priority<x[R].priority?D:R),R!==b&&(this._swap(b,R),this._heapify(R)))}_decrease(b){for(var x=this._arr,I=x[b].priority,D;b!==0&&(D=b>>1,!(x[D].priority<I));)this._swap(b,D),b=D}_swap(b,x){var I=this._arr,D=this._keyIndices,R=I[b],F=I[x];I[b]=F,I[x]=R,D[F.key]=b,D[R.key]=x}};l.exports=T}),u=_((v,l)=>{var T=g();l.exports=x;var b=()=>1;function x(D,R,F,A){var B=function(o){return D.outEdges(o)};return I(D,String(R),F||b,A||B)}function I(D,R,F,A){var B={},o=new T,e,d,c=function(m){var P=m.v!==e?m.v:m.w,z=B[P],U=F(m),H=d.distance+U;if(U<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+U);H<z.distance&&(z.distance=H,z.predecessor=e,o.decrease(P,H))};for(D.nodes().forEach(function(m){var P=m===R?0:Number.POSITIVE_INFINITY;B[m]={distance:P},o.add(m,P)});o.size()>0&&(e=o.removeMin(),d=B[e],d.distance!==Number.POSITIVE_INFINITY);)A(e).forEach(c);return B}}),N=_((v,l)=>{var T=u();l.exports=b;function b(x,I,D){return x.nodes().reduce(function(R,F){return R[F]=T(x,F,I,D),R},{})}}),V=_((v,l)=>{l.exports=T;function T(x,I,D){if(x[I].predecessor!==void 0)throw new Error("Invalid source vertex");if(x[D].predecessor===void 0&&D!==I)throw new Error("Invalid destination vertex");return{weight:x[D].distance,path:b(x,I,D)}}function b(x,I,D){for(var R=[],F=D;F!==I;)R.push(F),F=x[F].predecessor;return R.push(I),R.reverse()}}),W=_((v,l)=>{l.exports=T;function T(b){var x=0,I=[],D={},R=[];function F(A){var B=D[A]={onStack:!0,lowlink:x,index:x++};if(I.push(A),b.successors(A).forEach(function(d){Object.hasOwn(D,d)?D[d].onStack&&(B.lowlink=Math.min(B.lowlink,D[d].index)):(F(d),B.lowlink=Math.min(B.lowlink,D[d].lowlink))}),B.lowlink===B.index){var o=[],e;do e=I.pop(),D[e].onStack=!1,o.push(e);while(A!==e);R.push(o)}}return b.nodes().forEach(function(A){Object.hasOwn(D,A)||F(A)}),R}}),q=_((v,l)=>{var T=W();l.exports=b;function b(x){return T(x).filter(function(I){return I.length>1||I.length===1&&x.hasEdge(I[0],I[0])})}}),k=_((v,l)=>{l.exports=b;var T=()=>1;function b(I,D,R){return x(I,D||T,R||function(F){return I.outEdges(F)})}function x(I,D,R){var F={},A=I.nodes();return A.forEach(function(B){F[B]={},F[B][B]={distance:0},A.forEach(function(o){B!==o&&(F[B][o]={distance:Number.POSITIVE_INFINITY})}),R(B).forEach(function(o){var e=o.v===B?o.w:o.v,d=D(o);F[B][e]={distance:d,predecessor:B}})}),A.forEach(function(B){var o=F[B];A.forEach(function(e){var d=F[e];A.forEach(function(c){var m=d[B],P=o[c],z=d[c],U=m.distance+P.distance;U<z.distance&&(z.distance=U,z.predecessor=P.predecessor)})})}),F}}),L=_((v,l)=>{function T(x){var I={},D={},R=[];function F(A){if(Object.hasOwn(D,A))throw new b;Object.hasOwn(I,A)||(D[A]=!0,I[A]=!0,x.predecessors(A).forEach(F),delete D[A],R.push(A))}if(x.sinks().forEach(F),Object.keys(I).length!==x.nodeCount())throw new b;return R}var b=class extends Error{constructor(){super(...arguments)}};l.exports=T,T.CycleException=b}),p=_((v,l)=>{var T=L();l.exports=b;function b(x){try{T(x)}catch(I){if(I instanceof T.CycleException)return!1;throw I}return!0}}),j=_((v,l)=>{l.exports=T;function T(x,I,D,R,F){Array.isArray(I)||(I=[I]);var A=(x.isDirected()?x.successors:x.neighbors).bind(x),B={};return I.forEach(function(o){if(!x.hasNode(o))throw new Error("Graph does not have node: "+o);F=b(x,o,D==="post",B,A,R,F)}),F}function b(x,I,D,R,F,A,B){return Object.hasOwn(R,I)||(R[I]=!0,D||(B=A(B,I)),F(I).forEach(function(o){B=b(x,o,D,R,F,A,B)}),D&&(B=A(B,I))),B}}),M=_((v,l)=>{var T=j();l.exports=b;function b(x,I,D){return T(x,I,D,function(R,F){return R.push(F),R},[])}}),G=_((v,l)=>{var T=M();l.exports=b;function b(x,I){return T(x,I,"post")}}),S=_((v,l)=>{var T=M();l.exports=b;function b(x,I){return T(x,I,"pre")}}),$=_((v,l)=>{var T=n(),b=g();l.exports=x;function x(I,D){var R=new T,F={},A=new b,B;function o(d){var c=d.v===B?d.w:d.v,m=A.priority(c);if(m!==void 0){var P=D(d);P<m&&(F[c]=B,A.decrease(c,P))}}if(I.nodeCount()===0)return R;I.nodes().forEach(function(d){A.add(d,Number.POSITIVE_INFINITY),R.setNode(d)}),A.decrease(I.nodes()[0],0);for(var e=!1;A.size()>0;){if(B=A.removeMin(),Object.hasOwn(F,B))R.setEdge(B,F[B]);else{if(e)throw new Error("Input graph is not connected: "+I);e=!0}I.nodeEdges(B).forEach(o)}return R}}),f=_((v,l)=>{var T=u(),b=t();l.exports=x;function x(D,R,F,A){return I(D,R,F,A||function(B){return D.outEdges(B)})}function I(D,R,F,A){if(F===void 0)return T(D,R,F,A);for(var B=!1,o=D.nodes(),e=0;e<o.length;e++){for(var d=A(o[e]),c=0;c<d.length;c++){var m=d[c],P=m.v===o[e]?m.v:m.w,z=P===m.v?m.w:m.v;F({v:P,w:z})<0&&(B=!0)}if(B)return b(D,R,F,A)}return T(D,R,F,A)}}),w=_((v,l)=>{l.exports={bellmanFord:t(),components:i(),dijkstra:u(),dijkstraAll:N(),extractPath:V(),findCycles:q(),floydWarshall:k(),isAcyclic:p(),postorder:G(),preorder:S(),prim:$(),shortestPaths:f(),reduce:j(),tarjan:W(),topsort:L()}}),O=r();E.exports={Graph:O.Graph,json:s(),alg:w(),version:O.version}}),Ee=K((Y,E)=>{var y=class{constructor(){let h={};h._next=h._prev=h,this._sentinel=h}dequeue(){let h=this._sentinel,n=h._prev;if(n!==h)return C(n),n}enqueue(h){let n=this._sentinel;h._prev&&h._next&&C(h),h._next=n._next,n._next._prev=h,n._next=h,h._prev=n}toString(){let h=[],n=this._sentinel,a=n._prev;for(;a!==n;)h.push(JSON.stringify(a,_)),a=a._prev;return"["+h.join(", ")+"]"}};function C(h){h._prev._next=h._next,h._next._prev=h._prev,delete h._next,delete h._prev}function _(h,n){if(h!=="_next"&&h!=="_prev")return n}E.exports=y}),be=K((Y,E)=>{var y=Z().Graph,C=Ee();E.exports=h;var _=()=>1;function h(i,g){if(i.nodeCount()<=1)return[];let u=r(i,g||_);return n(u.graph,u.buckets,u.zeroIdx).flatMap(N=>i.outEdges(N.v,N.w))}function n(i,g,u){let N=[],V=g[g.length-1],W=g[0],q;for(;i.nodeCount();){for(;q=W.dequeue();)a(i,g,u,q);for(;q=V.dequeue();)a(i,g,u,q);if(i.nodeCount()){for(let k=g.length-2;k>0;--k)if(q=g[k].dequeue(),q){N=N.concat(a(i,g,u,q,!0));break}}}return N}function a(i,g,u,N,V){let W=V?[]:void 0;return i.inEdges(N.v).forEach(q=>{let k=i.edge(q),L=i.node(q.v);V&&W.push({v:q.v,w:q.w}),L.out-=k,s(g,u,L)}),i.outEdges(N.v).forEach(q=>{let k=i.edge(q),L=q.w,p=i.node(L);p.in-=k,s(g,u,p)}),i.removeNode(N.v),W}function r(i,g){let u=new y,N=0,V=0;i.nodes().forEach(k=>{u.setNode(k,{v:k,in:0,out:0})}),i.edges().forEach(k=>{let L=u.edge(k.v,k.w)||0,p=g(k),j=L+p;u.setEdge(k.v,k.w,j),V=Math.max(V,u.node(k.v).out+=p),N=Math.max(N,u.node(k.w).in+=p)});let W=t(V+N+3).map(()=>new C),q=N+1;return u.nodes().forEach(k=>{s(W,q,u.node(k))}),{graph:u,buckets:W,zeroIdx:q}}function s(i,g,u){u.out?u.in?i[u.out-u.in+g].enqueue(u):i[i.length-1].enqueue(u):i[0].enqueue(u)}function t(i){let g=[];for(let u=0;u<i;u++)g.push(u);return g}}),X=K((Y,E)=>{var y=Z().Graph;E.exports={addBorderNode:g,addDummyNode:C,applyWithChunking:V,asNonCompoundGraph:h,buildLayerMatrix:s,intersectRect:r,mapValues:S,maxRank:W,normalizeRanks:t,notime:L,partition:q,pick:G,predecessorWeights:a,range:M,removeEmptyRanks:i,simplify:_,successorWeights:n,time:k,uniqueId:j,zipObject:$};function C(f,w,O,v){for(var l=v;f.hasNode(l);)l=j(v);return O.dummy=w,f.setNode(l,O),l}function _(f){let w=new y().setGraph(f.graph());return f.nodes().forEach(O=>w.setNode(O,f.node(O))),f.edges().forEach(O=>{let v=w.edge(O.v,O.w)||{weight:0,minlen:1},l=f.edge(O);w.setEdge(O.v,O.w,{weight:v.weight+l.weight,minlen:Math.max(v.minlen,l.minlen)})}),w}function h(f){let w=new y({multigraph:f.isMultigraph()}).setGraph(f.graph());return f.nodes().forEach(O=>{f.children(O).length||w.setNode(O,f.node(O))}),f.edges().forEach(O=>{w.setEdge(O,f.edge(O))}),w}function n(f){let w=f.nodes().map(O=>{let v={};return f.outEdges(O).forEach(l=>{v[l.w]=(v[l.w]||0)+f.edge(l).weight}),v});return $(f.nodes(),w)}function a(f){let w=f.nodes().map(O=>{let v={};return f.inEdges(O).forEach(l=>{v[l.v]=(v[l.v]||0)+f.edge(l).weight}),v});return $(f.nodes(),w)}function r(f,w){let O=f.x,v=f.y,l=w.x-O,T=w.y-v,b=f.width/2,x=f.height/2;if(!l&&!T)throw new Error("Not possible to find intersection inside of the rectangle");let I,D;return Math.abs(T)*b>Math.abs(l)*x?(T<0&&(x=-x),I=x*l/T,D=x):(l<0&&(b=-b),I=b,D=b*T/l),{x:O+I,y:v+D}}function s(f){let w=M(W(f)+1).map(()=>[]);return f.nodes().forEach(O=>{let v=f.node(O),l=v.rank;l!==void 0&&(w[l][v.order]=O)}),w}function t(f){let w=f.nodes().map(v=>{let l=f.node(v).rank;return l===void 0?Number.MAX_VALUE:l}),O=V(Math.min,w);f.nodes().forEach(v=>{let l=f.node(v);Object.hasOwn(l,"rank")&&(l.rank-=O)})}function i(f){let w=f.nodes().map(b=>f.node(b).rank).filter(b=>b!==void 0),O=V(Math.min,w),v=[];f.nodes().forEach(b=>{let x=f.node(b).rank-O;v[x]||(v[x]=[]),v[x].push(b)});let l=0,T=f.graph().nodeRankFactor;Array.from(v).forEach((b,x)=>{b===void 0&&x%T!==0?--l:b!==void 0&&l&&b.forEach(I=>f.node(I).rank+=l)})}function g(f,w,O,v){let l={width:0,height:0};return arguments.length>=4&&(l.rank=O,l.order=v),C(f,"border",l,w)}function u(f,w=N){let O=[];for(let v=0;v<f.length;v+=w){let l=f.slice(v,v+w);O.push(l)}return O}var N=65535;function V(f,w){if(w.length>N){let O=u(w);return f.apply(null,O.map(v=>f.apply(null,v)))}else return f.apply(null,w)}function W(f){let w=f.nodes().map(O=>{let v=f.node(O).rank;return v===void 0?Number.MIN_VALUE:v});return V(Math.max,w)}function q(f,w){let O={lhs:[],rhs:[]};return f.forEach(v=>{w(v)?O.lhs.push(v):O.rhs.push(v)}),O}function k(f,w){let O=Date.now();try{return w()}finally{console.log(f+" time: "+(Date.now()-O)+"ms")}}function L(f,w){return w()}var p=0;function j(f){var w=++p;return f+(""+w)}function M(f,w,O=1){w==null&&(w=f,f=0);let v=T=>T<w;O<0&&(v=T=>w<T);let l=[];for(let T=f;v(T);T+=O)l.push(T);return l}function G(f,w){let O={};for(let v of w)f[v]!==void 0&&(O[v]=f[v]);return O}function S(f,w){let O=w;return typeof w=="string"&&(O=v=>v[w]),Object.entries(f).reduce((v,[l,T])=>(v[l]=O(T,l),v),{})}function $(f,w){return f.reduce((O,v,l)=>(O[v]=w[l],O),{})}}),ye=K((Y,E)=>{var y=be(),C=X().uniqueId;E.exports={run:_,undo:n};function _(a){(a.graph().acyclicer==="greedy"?y(a,r(a)):h(a)).forEach(s=>{let t=a.edge(s);a.removeEdge(s),t.forwardName=s.name,t.reversed=!0,a.setEdge(s.w,s.v,t,C("rev"))});function r(s){return t=>s.edge(t).weight}}function h(a){let r=[],s={},t={};function i(g){Object.hasOwn(t,g)||(t[g]=!0,s[g]=!0,a.outEdges(g).forEach(u=>{Object.hasOwn(s,u.w)?r.push(u):i(u.w)}),delete s[g])}return a.nodes().forEach(i),r}function n(a){a.edges().forEach(r=>{let s=a.edge(r);if(s.reversed){a.removeEdge(r);let t=s.forwardName;delete s.reversed,delete s.forwardName,a.setEdge(r.w,r.v,s,t)}})}}),_e=K((Y,E)=>{var y=X();E.exports={run:C,undo:h};function C(n){n.graph().dummyChains=[],n.edges().forEach(a=>_(n,a))}function _(n,a){let r=a.v,s=n.node(r).rank,t=a.w,i=n.node(t).rank,g=a.name,u=n.edge(a),N=u.labelRank;if(i===s+1)return;n.removeEdge(a);let V,W,q;for(q=0,++s;s<i;++q,++s)u.points=[],W={width:0,height:0,edgeLabel:u,edgeObj:a,rank:s},V=y.addDummyNode(n,"edge",W,"_d"),s===N&&(W.width=u.width,W.height=u.height,W.dummy="edge-label",W.labelpos=u.labelpos),n.setEdge(r,V,{weight:u.weight},g),q===0&&n.graph().dummyChains.push(V),r=V;n.setEdge(r,t,{weight:u.weight},g)}function h(n){n.graph().dummyChains.forEach(a=>{let r=n.node(a),s=r.edgeLabel,t;for(n.setEdge(r.edgeObj,s);r.dummy;)t=n.successors(a)[0],n.removeNode(a),s.points.push({x:r.x,y:r.y}),r.dummy==="edge-label"&&(s.x=r.x,s.y=r.y,s.width=r.width,s.height=r.height),a=t,r=n.node(a)})}}),ne=K((Y,E)=>{var{applyWithChunking:y}=X();E.exports={longestPath:C,slack:_};function C(h){var n={};function a(r){var s=h.node(r);if(Object.hasOwn(n,r))return s.rank;n[r]=!0;let t=h.outEdges(r).map(g=>g==null?Number.POSITIVE_INFINITY:a(g.w)-h.edge(g).minlen);var i=y(Math.min,t);return i===Number.POSITIVE_INFINITY&&(i=0),s.rank=i}h.sources().forEach(a)}function _(h,n){return h.node(n.w).rank-h.node(n.v).rank-h.edge(n).minlen}}),he=K((Y,E)=>{var y=Z().Graph,C=ne().slack;E.exports=_;function _(r){var s=new y({directed:!1}),t=r.nodes()[0],i=r.nodeCount();s.setNode(t,{});for(var g,u;h(s,r)<i;)g=n(s,r),u=s.hasNode(g.v)?C(r,g):-C(r,g),a(s,r,u);return s}function h(r,s){function t(i){s.nodeEdges(i).forEach(g=>{var u=g.v,N=i===u?g.w:u;!r.hasNode(N)&&!C(s,g)&&(r.setNode(N,{}),r.setEdge(i,N,{}),t(N))})}return r.nodes().forEach(t),r.nodeCount()}function n(r,s){return s.edges().reduce((t,i)=>{let g=Number.POSITIVE_INFINITY;return r.hasNode(i.v)!==r.hasNode(i.w)&&(g=C(s,i)),g<t[0]?[g,i]:t},[Number.POSITIVE_INFINITY,null])[1]}function a(r,s,t){r.nodes().forEach(i=>s.node(i).rank+=t)}}),ke=K((Y,E)=>{var y=he(),C=ne().slack,_=ne().longestPath,h=Z().alg.preorder,n=Z().alg.postorder,a=X().simplify;E.exports=r,r.initLowLimValues=g,r.initCutValues=s,r.calcCutValue=i,r.leaveEdge=N,r.enterEdge=V,r.exchangeEdges=W;function r(p){p=a(p),_(p);var j=y(p);g(j),s(j,p);for(var M,G;M=N(j);)G=V(j,p,M),W(j,p,M,G)}function s(p,j){var M=n(p,p.nodes());M=M.slice(0,M.length-1),M.forEach(G=>t(p,j,G))}function t(p,j,M){var G=p.node(M),S=G.parent;p.edge(M,S).cutvalue=i(p,j,M)}function i(p,j,M){var G=p.node(M),S=G.parent,$=!0,f=j.edge(M,S),w=0;return f||($=!1,f=j.edge(S,M)),w=f.weight,j.nodeEdges(M).forEach(O=>{var v=O.v===M,l=v?O.w:O.v;if(l!==S){var T=v===$,b=j.edge(O).weight;if(w+=T?b:-b,k(p,M,l)){var x=p.edge(M,l).cutvalue;w+=T?-x:x}}}),w}function g(p,j){arguments.length<2&&(j=p.nodes()[0]),u(p,{},1,j)}function u(p,j,M,G,S){var $=M,f=p.node(G);return j[G]=!0,p.neighbors(G).forEach(w=>{Object.hasOwn(j,w)||(M=u(p,j,M,w,G))}),f.low=$,f.lim=M++,S?f.parent=S:delete f.parent,M}function N(p){return p.edges().find(j=>p.edge(j).cutvalue<0)}function V(p,j,M){var G=M.v,S=M.w;j.hasEdge(G,S)||(G=M.w,S=M.v);var $=p.node(G),f=p.node(S),w=$,O=!1;$.lim>f.lim&&(w=f,O=!0);var v=j.edges().filter(l=>O===L(p,p.node(l.v),w)&&O!==L(p,p.node(l.w),w));return v.reduce((l,T)=>C(j,T)<C(j,l)?T:l)}function W(p,j,M,G){var S=M.v,$=M.w;p.removeEdge(S,$),p.setEdge(G.v,G.w,{}),g(p),s(p,j),q(p,j)}function q(p,j){var M=p.nodes().find(S=>!j.node(S).parent),G=h(p,M);G=G.slice(1),G.forEach(S=>{var $=p.node(S).parent,f=j.edge(S,$),w=!1;f||(f=j.edge($,S),w=!0),j.node(S).rank=j.node($).rank+(w?f.minlen:-f.minlen)})}function k(p,j,M){return p.hasEdge(j,M)}function L(p,j,M){return M.low<=j.lim&&j.lim<=M.lim}}),xe=K((Y,E)=>{var y=ne(),C=y.longestPath,_=he(),h=ke();E.exports=n;function n(t){var i=t.graph().ranker;if(i instanceof Function)return i(t);switch(t.graph().ranker){case"network-simplex":s(t);break;case"tight-tree":r(t);break;case"longest-path":a(t);break;case"none":break;default:s(t)}}var a=C;function r(t){C(t),_(t)}function s(t){h(t)}}),Oe=K((Y,E)=>{E.exports=y;function y(h){let n=_(h);h.graph().dummyChains.forEach(a=>{let r=h.node(a),s=r.edgeObj,t=C(h,n,s.v,s.w),i=t.path,g=t.lca,u=0,N=i[u],V=!0;for(;a!==s.w;){if(r=h.node(a),V){for(;(N=i[u])!==g&&h.node(N).maxRank<r.rank;)u++;N===g&&(V=!1)}if(!V){for(;u<i.length-1&&h.node(N=i[u+1]).minRank<=r.rank;)u++;N=i[u]}h.setParent(a,N),a=h.successors(a)[0]}})}function C(h,n,a,r){let s=[],t=[],i=Math.min(n[a].low,n[r].low),g=Math.max(n[a].lim,n[r].lim),u,N;u=a;do u=h.parent(u),s.push(u);while(u&&(n[u].low>i||g>n[u].lim));for(N=u,u=r;(u=h.parent(u))!==N;)t.push(u);return{path:s.concat(t.reverse()),lca:N}}function _(h){let n={},a=0;function r(s){let t=a;h.children(s).forEach(r),n[s]={low:t,lim:a++}}return h.children().forEach(r),n}}),Ne=K((Y,E)=>{var y=X();E.exports={run:C,cleanup:a};function C(r){let s=y.addDummyNode(r,"root",{},"_root"),t=h(r),i=Object.values(t),g=y.applyWithChunking(Math.max,i)-1,u=2*g+1;r.graph().nestingRoot=s,r.edges().forEach(V=>r.edge(V).minlen*=u);let N=n(r)+1;r.children().forEach(V=>_(r,s,u,N,g,t,V)),r.graph().nodeRankFactor=u}function _(r,s,t,i,g,u,N){let V=r.children(N);if(!V.length){N!==s&&r.setEdge(s,N,{weight:0,minlen:t});return}let W=y.addBorderNode(r,"_bt"),q=y.addBorderNode(r,"_bb"),k=r.node(N);r.setParent(W,N),k.borderTop=W,r.setParent(q,N),k.borderBottom=q,V.forEach(L=>{_(r,s,t,i,g,u,L);let p=r.node(L),j=p.borderTop?p.borderTop:L,M=p.borderBottom?p.borderBottom:L,G=p.borderTop?i:2*i,S=j!==M?1:g-u[N]+1;r.setEdge(W,j,{weight:G,minlen:S,nestingEdge:!0}),r.setEdge(M,q,{weight:G,minlen:S,nestingEdge:!0})}),r.parent(N)||r.setEdge(s,W,{weight:0,minlen:g+u[N]})}function h(r){var s={};function t(i,g){var u=r.children(i);u&&u.length&&u.forEach(N=>t(N,g+1)),s[i]=g}return r.children().forEach(i=>t(i,1)),s}function n(r){return r.edges().reduce((s,t)=>s+r.edge(t).weight,0)}function a(r){var s=r.graph();r.removeNode(s.nestingRoot),delete s.nestingRoot,r.edges().forEach(t=>{var i=r.edge(t);i.nestingEdge&&r.removeEdge(t)})}}),Ie=K((Y,E)=>{var y=X();E.exports=C;function C(h){function n(a){let r=h.children(a),s=h.node(a);if(r.length&&r.forEach(n),Object.hasOwn(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(let t=s.minRank,i=s.maxRank+1;t<i;++t)_(h,"borderLeft","_bl",a,s,t),_(h,"borderRight","_br",a,s,t)}}h.children().forEach(n)}function _(h,n,a,r,s,t){let i={width:0,height:0,rank:t,borderType:n},g=s[n][t-1],u=y.addDummyNode(h,"border",i,a);s[n][t]=u,h.setParent(u,r),g&&h.setEdge(g,u,{weight:1})}}),je=K((Y,E)=>{E.exports={adjust:y,undo:C};function y(t){let i=t.graph().rankdir.toLowerCase();(i==="lr"||i==="rl")&&_(t)}function C(t){let i=t.graph().rankdir.toLowerCase();(i==="bt"||i==="rl")&&n(t),(i==="lr"||i==="rl")&&(r(t),_(t))}function _(t){t.nodes().forEach(i=>h(t.node(i))),t.edges().forEach(i=>h(t.edge(i)))}function h(t){let i=t.width;t.width=t.height,t.height=i}function n(t){t.nodes().forEach(i=>a(t.node(i))),t.edges().forEach(i=>{let g=t.edge(i);g.points.forEach(a),Object.hasOwn(g,"y")&&a(g)})}function a(t){t.y=-t.y}function r(t){t.nodes().forEach(i=>s(t.node(i))),t.edges().forEach(i=>{let g=t.edge(i);g.points.forEach(s),Object.hasOwn(g,"x")&&s(g)})}function s(t){let i=t.x;t.x=t.y,t.y=i}}),Le=K((Y,E)=>{var y=X();E.exports=C;function C(_){let h={},n=_.nodes().filter(i=>!_.children(i).length),a=n.map(i=>_.node(i).rank),r=y.applyWithChunking(Math.max,a),s=y.range(r+1).map(()=>[]);function t(i){if(h[i])return;h[i]=!0;let g=_.node(i);s[g.rank].push(i),_.successors(i).forEach(t)}return n.sort((i,g)=>_.node(i).rank-_.node(g).rank).forEach(t),s}}),Ce=K((Y,E)=>{var y=X().zipObject;E.exports=C;function C(h,n){let a=0;for(let r=1;r<n.length;++r)a+=_(h,n[r-1],n[r]);return a}function _(h,n,a){let r=y(a,a.map((N,V)=>V)),s=n.flatMap(N=>h.outEdges(N).map(V=>({pos:r[V.w],weight:h.edge(V).weight})).sort((V,W)=>V.pos-W.pos)),t=1;for(;t<a.length;)t<<=1;let i=2*t-1;t-=1;let g=new Array(i).fill(0),u=0;return s.forEach(N=>{let V=N.pos+t;g[V]+=N.weight;let W=0;for(;V>0;)V%2&&(W+=g[V+1]),V=V-1>>1,g[V]+=N.weight;u+=N.weight*W}),u}}),Me=K((Y,E)=>{E.exports=y;function y(C,_=[]){return _.map(h=>{let n=C.inEdges(h);if(n.length){let a=n.reduce((r,s)=>{let t=C.edge(s),i=C.node(s.v);return{sum:r.sum+t.weight*i.order,weight:r.weight+t.weight}},{sum:0,weight:0});return{v:h,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:h}})}}),Te=K((Y,E)=>{var y=X();E.exports=C;function C(n,a){let r={};n.forEach((t,i)=>{let g=r[t.v]={indegree:0,in:[],out:[],vs:[t.v],i};t.barycenter!==void 0&&(g.barycenter=t.barycenter,g.weight=t.weight)}),a.edges().forEach(t=>{let i=r[t.v],g=r[t.w];i!==void 0&&g!==void 0&&(g.indegree++,i.out.push(r[t.w]))});let s=Object.values(r).filter(t=>!t.indegree);return _(s)}function _(n){let a=[];function r(t){return i=>{i.merged||(i.barycenter===void 0||t.barycenter===void 0||i.barycenter>=t.barycenter)&&h(t,i)}}function s(t){return i=>{i.in.push(t),--i.indegree===0&&n.push(i)}}for(;n.length;){let t=n.pop();a.push(t),t.in.reverse().forEach(r(t)),t.out.forEach(s(t))}return a.filter(t=>!t.merged).map(t=>y.pick(t,["vs","i","barycenter","weight"]))}function h(n,a){let r=0,s=0;n.weight&&(r+=n.barycenter*n.weight,s+=n.weight),a.weight&&(r+=a.barycenter*a.weight,s+=a.weight),n.vs=a.vs.concat(n.vs),n.barycenter=r/s,n.weight=s,n.i=Math.min(a.i,n.i),a.merged=!0}}),Pe=K((Y,E)=>{var y=X();E.exports=C;function C(n,a){let r=y.partition(n,W=>Object.hasOwn(W,"barycenter")),s=r.lhs,t=r.rhs.sort((W,q)=>q.i-W.i),i=[],g=0,u=0,N=0;s.sort(h(!!a)),N=_(i,t,N),s.forEach(W=>{N+=W.vs.length,i.push(W.vs),g+=W.barycenter*W.weight,u+=W.weight,N=_(i,t,N)});let V={vs:i.flat(!0)};return u&&(V.barycenter=g/u,V.weight=u),V}function _(n,a,r){let s;for(;a.length&&(s=a[a.length-1]).i<=r;)a.pop(),n.push(s.vs),r++;return r}function h(n){return(a,r)=>a.barycenter<r.barycenter?-1:a.barycenter>r.barycenter?1:n?r.i-a.i:a.i-r.i}}),Re=K((Y,E)=>{var y=Me(),C=Te(),_=Pe();E.exports=h;function h(r,s,t,i){let g=r.children(s),u=r.node(s),N=u?u.borderLeft:void 0,V=u?u.borderRight:void 0,W={};N&&(g=g.filter(p=>p!==N&&p!==V));let q=y(r,g);q.forEach(p=>{if(r.children(p.v).length){let j=h(r,p.v,t,i);W[p.v]=j,Object.hasOwn(j,"barycenter")&&a(p,j)}});let k=C(q,t);n(k,W);let L=_(k,i);if(N&&(L.vs=[N,L.vs,V].flat(!0),r.predecessors(N).length)){let p=r.node(r.predecessors(N)[0]),j=r.node(r.predecessors(V)[0]);Object.hasOwn(L,"barycenter")||(L.barycenter=0,L.weight=0),L.barycenter=(L.barycenter*L.weight+p.order+j.order)/(L.weight+2),L.weight+=2}return L}function n(r,s){r.forEach(t=>{t.vs=t.vs.flatMap(i=>s[i]?s[i].vs:i)})}function a(r,s){r.barycenter!==void 0?(r.barycenter=(r.barycenter*r.weight+s.barycenter*s.weight)/(r.weight+s.weight),r.weight+=s.weight):(r.barycenter=s.barycenter,r.weight=s.weight)}}),Fe=K((Y,E)=>{var y=Z().Graph,C=X();E.exports=_;function _(n,a,r,s){s||(s=n.nodes());let t=h(n),i=new y({compound:!0}).setGraph({root:t}).setDefaultNodeLabel(g=>n.node(g));return s.forEach(g=>{let u=n.node(g),N=n.parent(g);(u.rank===a||u.minRank<=a&&a<=u.maxRank)&&(i.setNode(g),i.setParent(g,N||t),n[r](g).forEach(V=>{let W=V.v===g?V.w:V.v,q=i.edge(W,g),k=q!==void 0?q.weight:0;i.setEdge(W,g,{weight:n.edge(V).weight+k})}),Object.hasOwn(u,"minRank")&&i.setNode(g,{borderLeft:u.borderLeft[a],borderRight:u.borderRight[a]}))}),i}function h(n){for(var a;n.hasNode(a=C.uniqueId("_root")););return a}}),De=K((Y,E)=>{E.exports=y;function y(C,_,h){let n={},a;h.forEach(r=>{let s=C.parent(r),t,i;for(;s;){if(t=C.parent(s),t?(i=n[t],n[t]=s):(i=a,a=s),i&&i!==s){_.setEdge(i,s);return}s=t}})}}),Se=K((Y,E)=>{var y=Le(),C=Ce(),_=Re(),h=Fe(),n=De(),a=Z().Graph,r=X();E.exports=s;function s(u,N={}){if(typeof N.customOrder=="function"){N.customOrder(u,s);return}let V=r.maxRank(u),W=t(u,r.range(1,V+1),"inEdges"),q=t(u,r.range(V-1,-1,-1),"outEdges"),k=y(u);if(g(u,k),N.disableOptimalOrderHeuristic)return;let L=Number.POSITIVE_INFINITY,p,j=N.constraints||[];for(let M=0,G=0;G<4;++M,++G){i(M%2?W:q,M%4>=2,j),k=r.buildLayerMatrix(u);let S=C(u,k);S<L?(G=0,p=Object.assign({},k),L=S):S===L&&(p=structuredClone(k))}g(u,p)}function t(u,N,V){let W=new Map,q=(k,L)=>{W.has(k)||W.set(k,[]),W.get(k).push(L)};for(let k of u.nodes()){let L=u.node(k);if(typeof L.rank=="number"&&q(L.rank,k),typeof L.minRank=="number"&&typeof L.maxRank=="number")for(let p=L.minRank;p<=L.maxRank;p++)p!==L.rank&&q(p,k)}return N.map(function(k){return h(u,k,V,W.get(k)||[])})}function i(u,N,V){let W=new a;u.forEach(function(q){V.forEach(p=>W.setEdge(p.left,p.right));let k=q.graph().root,L=_(q,k,W,N);L.vs.forEach((p,j)=>q.node(p).order=j),n(q,W,L.vs)})}function g(u,N){Object.values(N).forEach(V=>V.forEach((W,q)=>u.node(W).order=q))}}),Ge=K((Y,E)=>{var y=Z().Graph,C=X();E.exports={positionX:V,findType1Conflicts:_,findType2Conflicts:h,addConflict:a,hasConflict:r,verticalAlignment:s,horizontalCompaction:t,alignCoordinates:u,findSmallestWidthAlignment:g,balance:N};function _(k,L){let p={};function j(M,G){let S=0,$=0,f=M.length,w=G[G.length-1];return G.forEach((O,v)=>{let l=n(k,O),T=l?k.node(l).order:f;(l||O===w)&&(G.slice($,v+1).forEach(b=>{k.predecessors(b).forEach(x=>{let I=k.node(x),D=I.order;(D<S||T<D)&&!(I.dummy&&k.node(b).dummy)&&a(p,x,b)})}),$=v+1,S=T)}),G}return L.length&&L.reduce(j),p}function h(k,L){let p={};function j(G,S,$,f,w){let O;C.range(S,$).forEach(v=>{O=G[v],k.node(O).dummy&&k.predecessors(O).forEach(l=>{let T=k.node(l);T.dummy&&(T.order<f||T.order>w)&&a(p,l,O)})})}function M(G,S){let $=-1,f,w=0;return S.forEach((O,v)=>{if(k.node(O).dummy==="border"){let l=k.predecessors(O);l.length&&(f=k.node(l[0]).order,j(S,w,v,$,f),w=v,$=f)}j(S,w,S.length,f,G.length)}),S}return L.length&&L.reduce(M),p}function n(k,L){if(k.node(L).dummy)return k.predecessors(L).find(p=>k.node(p).dummy)}function a(k,L,p){if(L>p){let M=L;L=p,p=M}let j=k[L];j||(k[L]=j={}),j[p]=!0}function r(k,L,p){if(L>p){let j=L;L=p,p=j}return!!k[L]&&Object.hasOwn(k[L],p)}function s(k,L,p,j){let M={},G={},S={};return L.forEach($=>{$.forEach((f,w)=>{M[f]=f,G[f]=f,S[f]=w})}),L.forEach($=>{let f=-1;$.forEach(w=>{let O=j(w);if(O.length){O=O.sort((l,T)=>S[l]-S[T]);let v=(O.length-1)/2;for(let l=Math.floor(v),T=Math.ceil(v);l<=T;++l){let b=O[l];G[w]===w&&f<S[b]&&!r(p,w,b)&&(G[b]=w,G[w]=M[w]=M[b],f=S[b])}}})}),{root:M,align:G}}function t(k,L,p,j,M){let G={},S=i(k,L,p,M),$=M?"borderLeft":"borderRight";function f(v,l){let T=S.nodes().slice(),b={},x=T.pop();for(;x;){if(b[x])v(x);else{b[x]=!0,T.push(x);for(let I of l(x))T.push(I)}x=T.pop()}}function w(v){G[v]=S.inEdges(v).reduce((l,T)=>Math.max(l,G[T.v]+S.edge(T)),0)}function O(v){let l=S.outEdges(v).reduce((b,x)=>Math.min(b,G[x.w]-S.edge(x)),Number.POSITIVE_INFINITY),T=k.node(v);l!==Number.POSITIVE_INFINITY&&T.borderType!==$&&(G[v]=Math.max(G[v],l))}return f(w,S.predecessors.bind(S)),f(O,S.successors.bind(S)),Object.keys(j).forEach(v=>G[v]=G[p[v]]),G}function i(k,L,p,j){let M=new y,G=k.graph(),S=W(G.nodesep,G.edgesep,j);return L.forEach($=>{let f;$.forEach(w=>{let O=p[w];if(M.setNode(O),f){var v=p[f],l=M.edge(v,O);M.setEdge(v,O,Math.max(S(k,w,f),l||0))}f=w})}),M}function g(k,L){return Object.values(L).reduce((p,j)=>{let M=Number.NEGATIVE_INFINITY,G=Number.POSITIVE_INFINITY;Object.entries(j).forEach(([$,f])=>{let w=q(k,$)/2;M=Math.max(f+w,M),G=Math.min(f-w,G)});let S=M-G;return S<p[0]&&(p=[S,j]),p},[Number.POSITIVE_INFINITY,null])[1]}function u(k,L){let p=Object.values(L),j=C.applyWithChunking(Math.min,p),M=C.applyWithChunking(Math.max,p);["u","d"].forEach(G=>{["l","r"].forEach(S=>{let $=G+S,f=k[$];if(f===L)return;let w=Object.values(f),O=j-C.applyWithChunking(Math.min,w);S!=="l"&&(O=M-C.applyWithChunking(Math.max,w)),O&&(k[$]=C.mapValues(f,v=>v+O))})})}function N(k,L){return C.mapValues(k.ul,(p,j)=>{if(L)return k[L.toLowerCase()][j];{let M=Object.values(k).map(G=>G[j]).sort((G,S)=>G-S);return(M[1]+M[2])/2}})}function V(k){let L=C.buildLayerMatrix(k),p=Object.assign(_(k,L),h(k,L)),j={},M;["u","d"].forEach(S=>{M=S==="u"?L:Object.values(L).reverse(),["l","r"].forEach($=>{$==="r"&&(M=M.map(v=>Object.values(v).reverse()));let f=(S==="u"?k.predecessors:k.successors).bind(k),w=s(k,M,p,f),O=t(k,M,w.root,w.align,$==="r");$==="r"&&(O=C.mapValues(O,v=>-v)),j[S+$]=O})});let G=g(k,j);return u(j,G),N(j,k.graph().align)}function W(k,L,p){return(j,M,G)=>{let S=j.node(M),$=j.node(G),f=0,w;if(f+=S.width/2,Object.hasOwn(S,"labelpos"))switch(S.labelpos.toLowerCase()){case"l":w=-S.width/2;break;case"r":w=S.width/2;break}if(w&&(f+=p?w:-w),w=0,f+=(S.dummy?L:k)/2,f+=($.dummy?L:k)/2,f+=$.width/2,Object.hasOwn($,"labelpos"))switch($.labelpos.toLowerCase()){case"l":w=$.width/2;break;case"r":w=-$.width/2;break}return w&&(f+=p?w:-w),w=0,f}}function q(k,L){return k.node(L).width}}),Ve=K((Y,E)=>{var y=X(),C=Ge().positionX;E.exports=_;function _(n){n=y.asNonCompoundGraph(n),h(n),Object.entries(C(n)).forEach(([a,r])=>n.node(a).x=r)}function h(n){let a=y.buildLayerMatrix(n),r=n.graph().ranksep,s=n.graph().rankalign,t=0;a.forEach(i=>{let g=i.reduce((u,N)=>{let V=n.node(N).height;return u>V?u:V},0);i.forEach(u=>{let N=n.node(u);s==="top"?N.y=t+N.height/2:s==="bottom"?N.y=t+g-N.height/2:N.y=t+g/2}),t+=g+r})}}),Ae=K((Y,E)=>{var y=ye(),C=_e(),_=xe(),h=X().normalizeRanks,n=Oe(),a=X().removeEmptyRanks,r=Ne(),s=Ie(),t=je(),i=Se(),g=Ve(),u=X(),N=Z().Graph;E.exports=V;function V(e,d={}){let c=d.debugTiming?u.time:u.notime;return c("layout",()=>{let m=c(" buildLayoutGraph",()=>f(e));return c(" runLayout",()=>W(m,c,d)),c(" updateInputGraph",()=>q(e,m)),m})}function W(e,d,c){d(" makeSpaceForEdgeLabels",()=>w(e)),d(" removeSelfEdges",()=>R(e)),d(" acyclic",()=>y.run(e)),d(" nestingGraph.run",()=>r.run(e)),d(" rank",()=>_(u.asNonCompoundGraph(e))),d(" injectEdgeLabelProxies",()=>O(e)),d(" removeEmptyRanks",()=>a(e)),d(" nestingGraph.cleanup",()=>r.cleanup(e)),d(" normalizeRanks",()=>h(e)),d(" assignRankMinMax",()=>v(e)),d(" removeEdgeLabelProxies",()=>l(e)),d(" normalize.run",()=>C.run(e)),d(" parentDummyChains",()=>n(e)),d(" addBorderSegments",()=>s(e)),d(" order",()=>i(e,c)),d(" insertSelfEdges",()=>F(e)),d(" adjustCoordinateSystem",()=>t.adjust(e)),d(" position",()=>g(e)),d(" positionSelfEdges",()=>A(e)),d(" removeBorderNodes",()=>D(e)),d(" normalize.undo",()=>C.undo(e)),d(" fixupEdgeLabelCoords",()=>x(e)),d(" undoCoordinateSystem",()=>t.undo(e)),d(" translateGraph",()=>T(e)),d(" assignNodeIntersects",()=>b(e)),d(" reversePoints",()=>I(e)),d(" acyclic.undo",()=>y.undo(e))}function q(e,d){e.nodes().forEach(c=>{let m=e.node(c),P=d.node(c);m&&(m.x=P.x,m.y=P.y,m.order=P.order,m.rank=P.rank,d.children(c).length&&(m.width=P.width,m.height=P.height))}),e.edges().forEach(c=>{let m=e.edge(c),P=d.edge(c);m.points=P.points,Object.hasOwn(P,"x")&&(m.x=P.x,m.y=P.y)}),e.graph().width=d.graph().width,e.graph().height=d.graph().height}var k=["nodesep","edgesep","ranksep","marginx","marginy"],L={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb",rankalign:"center"},p=["acyclicer","ranker","rankdir","align","rankalign"],j=["width","height","rank"],M={width:0,height:0},G=["minlen","weight","width","height","labeloffset"],S={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},$=["labelpos"];function f(e){let d=new N({multigraph:!0,compound:!0}),c=o(e.graph());return d.setGraph(Object.assign({},L,B(c,k),u.pick(c,p))),e.nodes().forEach(m=>{let P=o(e.node(m)),z=B(P,j);Object.keys(M).forEach(U=>{z[U]===void 0&&(z[U]=M[U])}),d.setNode(m,z),d.setParent(m,e.parent(m))}),e.edges().forEach(m=>{let P=o(e.edge(m));d.setEdge(m,Object.assign({},S,B(P,G),u.pick(P,$)))}),d}function w(e){let d=e.graph();d.ranksep/=2,e.edges().forEach(c=>{let m=e.edge(c);m.minlen*=2,m.labelpos.toLowerCase()!=="c"&&(d.rankdir==="TB"||d.rankdir==="BT"?m.width+=m.labeloffset:m.height+=m.labeloffset)})}function O(e){e.edges().forEach(d=>{let c=e.edge(d);if(c.width&&c.height){let m=e.node(d.v),P={rank:(e.node(d.w).rank-m.rank)/2+m.rank,e:d};u.addDummyNode(e,"edge-proxy",P,"_ep")}})}function v(e){let d=0;e.nodes().forEach(c=>{let m=e.node(c);m.borderTop&&(m.minRank=e.node(m.borderTop).rank,m.maxRank=e.node(m.borderBottom).rank,d=Math.max(d,m.maxRank))}),e.graph().maxRank=d}function l(e){e.nodes().forEach(d=>{let c=e.node(d);c.dummy==="edge-proxy"&&(e.edge(c.e).labelRank=c.rank,e.removeNode(d))})}function T(e){let d=Number.POSITIVE_INFINITY,c=0,m=Number.POSITIVE_INFINITY,P=0,z=e.graph(),U=z.marginx||0,H=z.marginy||0;function te(J){let Q=J.x,re=J.y,se=J.width,ae=J.height;d=Math.min(d,Q-se/2),c=Math.max(c,Q+se/2),m=Math.min(m,re-ae/2),P=Math.max(P,re+ae/2)}e.nodes().forEach(J=>te(e.node(J))),e.edges().forEach(J=>{let Q=e.edge(J);Object.hasOwn(Q,"x")&&te(Q)}),d-=U,m-=H,e.nodes().forEach(J=>{let Q=e.node(J);Q.x-=d,Q.y-=m}),e.edges().forEach(J=>{let Q=e.edge(J);Q.points.forEach(re=>{re.x-=d,re.y-=m}),Object.hasOwn(Q,"x")&&(Q.x-=d),Object.hasOwn(Q,"y")&&(Q.y-=m)}),z.width=c-d+U,z.height=P-m+H}function b(e){e.edges().forEach(d=>{let c=e.edge(d),m=e.node(d.v),P=e.node(d.w),z,U;c.points?(z=c.points[0],U=c.points[c.points.length-1]):(c.points=[],z=P,U=m),c.points.unshift(u.intersectRect(m,z)),c.points.push(u.intersectRect(P,U))})}function x(e){e.edges().forEach(d=>{let c=e.edge(d);if(Object.hasOwn(c,"x"))switch((c.labelpos==="l"||c.labelpos==="r")&&(c.width-=c.labeloffset),c.labelpos){case"l":c.x-=c.width/2+c.labeloffset;break;case"r":c.x+=c.width/2+c.labeloffset;break}})}function I(e){e.edges().forEach(d=>{let c=e.edge(d);c.reversed&&c.points.reverse()})}function D(e){e.nodes().forEach(d=>{if(e.children(d).length){let c=e.node(d),m=e.node(c.borderTop),P=e.node(c.borderBottom),z=e.node(c.borderLeft[c.borderLeft.length-1]),U=e.node(c.borderRight[c.borderRight.length-1]);c.width=Math.abs(U.x-z.x),c.height=Math.abs(P.y-m.y),c.x=z.x+c.width/2,c.y=m.y+c.height/2}}),e.nodes().forEach(d=>{e.node(d).dummy==="border"&&e.removeNode(d)})}function R(e){e.edges().forEach(d=>{if(d.v===d.w){var c=e.node(d.v);c.selfEdges||(c.selfEdges=[]),c.selfEdges.push({e:d,label:e.edge(d)}),e.removeEdge(d)}})}function F(e){var d=u.buildLayerMatrix(e);d.forEach(c=>{var m=0;c.forEach((P,z)=>{var U=e.node(P);U.order=z+m,(U.selfEdges||[]).forEach(H=>{u.addDummyNode(e,"selfedge",{width:H.label.width,height:H.label.height,rank:U.rank,order:z+ ++m,e:H.e,label:H.label},"_se")}),delete U.selfEdges})})}function A(e){e.nodes().forEach(d=>{var c=e.node(d);if(c.dummy==="selfedge"){var m=e.node(c.e.v),P=m.x+m.width/2,z=m.y,U=c.x-P,H=m.height/2;e.setEdge(c.e,c.label),e.removeNode(d),c.label.points=[{x:P+2*U/3,y:z-H},{x:P+5*U/6,y:z-H},{x:P+U,y:z},{x:P+5*U/6,y:z+H},{x:P+2*U/3,y:z+H}],c.label.x=c.x,c.label.y=c.y}})}function B(e,d){return u.mapValues(u.pick(e,d),Number)}function o(e){var d={};return e&&Object.entries(e).forEach(([c,m])=>{typeof c=="string"&&(c=c.toLowerCase()),d[c]=m}),d}}),Be=K((Y,E)=>{var y=X(),C=Z().Graph;E.exports={debugOrdering:_};function _(h){let n=y.buildLayerMatrix(h),a=new C({compound:!0,multigraph:!0}).setGraph({});return h.nodes().forEach(r=>{a.setNode(r,{label:r}),a.setParent(r,"layer"+h.node(r).rank)}),h.edges().forEach(r=>a.setEdge(r.v,r.w,{},r.name)),n.forEach((r,s)=>{let t="layer"+s;a.setNode(t,{rank:"same"}),r.reduce((i,g)=>(a.setEdge(i,g,{style:"invis"}),g))}),a}}),ze=K((Y,E)=>{E.exports="2.0.4"}),We=K((Y,E)=>{E.exports={graphlib:Z(),layout:Ae(),debug:Be(),util:{time:X().time,notime:X().notime},version:ze()}});const ie=We();/*! For license information please see dagre.esm.js.LEGAL.txt */const Ye=Y=>(Y.children??[]).some(E=>{var y,C;return(((y=E.children)==null?void 0:y.length)??0)>0||(((C=E.ports)==null?void 0:C.length)??0)>0}),qe=Y=>{switch(Y){case"UP":return"BT";case"RIGHT":return"LR";case"LEFT":return"RL";default:return"TB"}};class $e{constructor(){ee(this,"descriptor",{id:"memo.layout.dagre",name:"Dagre",version:ie.version,contractVersion:"1",license:"MIT",description:"Fast directed layout for flat graphs and trees.",mode:"automatic",capabilities:["flat-graph","deterministic"]})}supports(E){const y=!Ye(E);return{supported:y,...y?{}:{reason:"compound nodes and explicit ports require a different provider"}}}async layout(E){const y=ue(E),C=E.layoutOptions??{},_=new ie.graphlib.Graph({multigraph:!0}).setGraph({rankdir:qe(C["elk.direction"]),nodesep:Number(C["elk.spacing.nodeNode"]??40),ranksep:Number(C["elk.layered.spacing.nodeNodeBetweenLayers"]??80),marginx:20,marginy:20}).setDefaultEdgeLabel(()=>({}));for(const n of y.children??[])_.setNode(n.id,{width:n.width??1,height:n.height??1});for(const n of y.edges??[]){const a=n.sources[0],r=n.targets[0];a&&r&&_.hasNode(a)&&_.hasNode(r)&&_.setEdge(a,r,{},n.id)}ie.layout(_);for(const n of y.children??[]){const a=_.node(n.id);a&&(n.x=a.x-(n.width??1)/2,n.y=a.y-(n.height??1)/2)}for(const n of y.edges??[]){const a=n.sources[0],r=n.targets[0];if(!a||!r||!_.hasEdge(a,r,n.id))continue;const s=_.edge(a,r,n.id),t=(s==null?void 0:s.points)??[];t.length>=2&&(n.sections=[{id:`${n.id}-section`,startPoint:t[0],endPoint:t[t.length-1],bendPoints:t.slice(1,-1)}])}const h=_.graph();return y.width=h.width,y.height=h.height,y}}var Ue=pe();const de=ge(Ue);function Ke(){if(!(typeof Worker>"u"))return()=>new Worker(new URL("/assets/elk-worker.min-BgEwn2y-.js",import.meta.url))}const Xe=5e3;class He{constructor(){ee(this,"descriptor",{id:"memo.layout.elk",name:"ELK",version:"0.9.3",contractVersion:"1",license:"EPL-2.0",description:"Layered and hierarchical engineering layouts with ports and orthogonal routes.",mode:"automatic",capabilities:["flat-graph","compound-graph","explicit-ports","orthogonal-routes","fixed-nodes","deterministic","cancellable","worker-runtime"]});ee(this,"instance");ee(this,"chain",Promise.resolve())}supports(){return{supported:!0}}layout(E,y={}){const C=()=>this.runBounded(E,y),_=this.chain.then(C,C);return this.chain=_.then(()=>{},()=>{}),_}dispose(){this.reset()}getInstance(){if(!this.instance){const E=Ke();this.instance=E?new de({workerFactory:E}):new de}return this.instance}reset(){var E,y;try{(y=(E=this.instance)==null?void 0:E.terminateWorker)==null||y.call(E)}catch{}this.instance=void 0}runBounded(E,y){return new Promise((C,_)=>{var t,i;let h=!1;const n=g=>{var u;h||(h=!0,clearTimeout(s),(u=y.signal)==null||u.removeEventListener("abort",a),g())},a=()=>n(()=>{var g;this.reset(),_(((g=y.signal)==null?void 0:g.reason)??new DOMException("Layout aborted","AbortError"))}),r=y.timeoutMs??Xe,s=setTimeout(()=>n(()=>{this.reset(),_(new Error(`ELK layout timed out after ${r/1e3}s`))}),r);if((t=y.signal)==null||t.addEventListener("abort",a,{once:!0}),(i=y.signal)!=null&&i.aborted)return a();this.getInstance().layout(E).then(g=>n(()=>C(g)),g=>n(()=>_(g)))})}}const ce=Y=>(Y.id==="root"||Number.isFinite(Y.x)&&Number.isFinite(Y.y))&&(Y.children??[]).every(ce);class Qe{constructor(){ee(this,"descriptor",{id:"memo.layout.fixed",name:"Fixed / authored",version:"1.0.0",contractVersion:"1",license:"Internal",description:"Preserves existing authored geometry without automatic rearrangement.",mode:"preserve",capabilities:["flat-graph","compound-graph","explicit-ports","fixed-nodes","deterministic"]})}supports(E){const y=ce(E);return{supported:y,...y?{}:{reason:"every node must already have finite x/y coordinates"}}}async layout(E){return ue(E)}}const oe=new we;oe.register(new He);oe.register(new $e);oe.register(new Qe);function rr(Y,E){return oe.layout(Y,E)}export{ve as D,rr as r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var ko=Object.defineProperty;var Ao=(e,t,n)=>t in e?ko(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ht=(e,t,n)=>Ao(e,typeof t!="symbol"?t+"":t,n);import{h as Qt,Q as it,O as ce,U as vn,F as dt,V as pe,S as en,W as ne,X as ae,Y as eo,u as Se,j as Co}from"./index-a2rpMs5Y.js";import{u as no,j as C,H as Ut,P as It}from"./reactflow-C9OlmOYw.js";import{a as yt}from"./zustand-CrhqMOHB.js";import{r as To,D as Fo}from"./layout-providers-BSDYNZu0.js";import{E as Oo}from"./ExplorerTreeRow-CmGPHRI8.js";function oo(e){return e&&e.charAt(0).toLowerCase()+e.slice(1)}function No(e){return new Set(e.map(oo))}const so=(e,t,n,s)=>e.y===t.y&&n.y===s.y&&e.y===n.y?Math.max(Math.min(e.x,t.x),Math.min(n.x,s.x))<Math.min(Math.max(e.x,t.x),Math.max(n.x,s.x)):e.x===t.x&&n.x===s.x&&e.x===n.x?Math.max(Math.min(e.y,t.y),Math.min(n.y,s.y))<Math.min(Math.max(e.y,t.y),Math.max(n.y,s.y)):!1,io=(e,t,n,s)=>{const o=e.y===t.y,i=n.y===s.y;if(o===i)return!1;const a=o?e:n,r=o?t:s,c=o?n:e,h=o?s:t;return c.x>Math.min(a.x,r.x)&&c.x<Math.max(a.x,r.x)&&a.y>Math.min(c.y,h.y)&&a.y<Math.max(c.y,h.y)},ro=26,Ue=(e,t,n)=>t==="left"?{x:e.x-n,y:e.y}:t==="right"?{x:e.x+n,y:e.y}:t==="top"?{x:e.x,y:e.y-n}:{x:e.x,y:e.y+n};function ao(e){const t=e.filter((n,s)=>s===0||Math.abs(n.x-e[s-1].x)>.01||Math.abs(n.y-e[s-1].y)>.01);return t.filter((n,s)=>s===0||s===t.length-1||!(t[s-1].x===n.x&&n.x===t[s+1].x||t[s-1].y===n.y&&n.y===t[s+1].y))}const Oe=e=>e==="left"||e==="right";function ze(e){const{source:t,target:n,sourceSide:s,targetSide:o}=e,i=Math.abs(t.x-n.x)+Math.abs(t.y-n.y),a=Math.min(ro,i/3),r=s&&a>.5?Ue(t,s,a):t,c=o&&a>.5?Ue(n,o,a):n,h=Math.abs(r.x-c.x)<.5||Math.abs(r.y-c.y)<.5?[]:Oe(s)===Oe(o)?Oe(s)||!s?[{x:(r.x+c.x)/2,y:r.y},{x:(r.x+c.x)/2,y:c.y}]:[{x:r.x,y:(r.y+c.y)/2},{x:c.x,y:(r.y+c.y)/2}]:Oe(s)?[{x:c.x,y:r.y}]:[{x:r.x,y:c.y}];return ao([t,r,...h,c,n])}function Bi(e){return new Map(e.map(t=>[t.id,ze(t)]))}const _o=12e3,Do=600,Po=90,Lo=.75,Ro=2e4,jo=96,Bo=1,$o=6,Ho=10,Ne=160,Wo=(e,t)=>e*73856093^t*19349663;function En(e,t,n,s,o){const i=Math.floor(e/Ne),a=Math.floor(n/Ne),r=Math.floor(t/Ne),c=Math.floor(s/Ne);for(let h=i;h<=a;h++)for(let g=r;g<=c;g++)o(Wo(h,g))}class co{constructor(){Ht(this,"buckets",new Map);Ht(this,"query",0)}add(t,n,s,o,i){const a={ax:t,ay:n,bx:s,by:o,owner:i,seen:0};En(Math.min(t,s),Math.min(n,o),Math.max(t,s),Math.max(n,o),r=>{const c=this.buckets.get(r);c?c.push(a):this.buckets.set(r,[a])})}near(t,n,s,o,i){const a=++this.query,r=[];return En(t,n,s,o,c=>{const h=this.buckets.get(c);if(h)for(const g of h)g.seen===a||g.owner===i||(g.seen=a,r.push(g))}),r}conflicts(t,n,s){const o=this.near(Math.min(t.x,n.x),Math.min(t.y,n.y),Math.max(t.x,n.x),Math.max(t.y,n.y),s);let i=0;for(const a of o){const r={x:a.ax,y:a.ay},c={x:a.bx,y:a.by};(so(t,n,r,c)||io(t,n,r,c))&&i++}return i}}class zo{constructor(t){Ht(this,"f");Ht(this,"state");Ht(this,"size",0);Ht(this,"poppedF",0);this.f=new Float64Array(t),this.state=new Int32Array(t)}get length(){return this.size}clear(){this.size=0}push(t,n){if(this.size===this.f.length){const o=new Float64Array(this.size*2),i=new Int32Array(this.size*2);o.set(this.f),i.set(this.state),this.f=o,this.state=i}let s=this.size++;for(this.f[s]=t,this.state[s]=n;s>0;){const o=s-1>>1;if(this.f[o]<=this.f[s])break;this.swap(o,s),s=o}}pop(){const t=this.state[0];if(this.poppedF=this.f[0],this.size--,this.size>0){this.f[0]=this.f[this.size],this.state[0]=this.state[this.size];for(let n=0;;){const s=n*2+1,o=s+1;let i=n;if(s<this.size&&this.f[s]<this.f[i]&&(i=s),o<this.size&&this.f[o]<this.f[i]&&(i=o),i===n)break;this.swap(i,n),n=i}}return t}swap(t,n){const s=this.f[t];this.f[t]=this.f[n],this.f[n]=s;const o=this.state[t];this.state[t]=this.state[n],this.state[n]=o}}function kn(e,t,n,s,o){const i=c=>{const h=[...c].sort((l,y)=>l-y),g=[];for(const l of h)(g.length===0||Math.abs(l-g[g.length-1])>.5)&&g.push(l);return g},a=(c,h)=>{if(c.length<=h)return c;const g=l=>l<s?s-l:l>o?l-o:0;return[...c].sort((l,y)=>g(l)-g(y)).slice(0,h).sort((l,y)=>l-y)},r=i([...e,...t]);for(let c=n.maxLanes;c>=1;c--){const h=[...r];for(let l=1;l<r.length;l++){const y=r[l]-r[l-1],w=Math.min(c,Math.floor(y/n.laneGap)-1);for(let m=1;m<=w;m++)h.push(r[l-1]+y*m/(w+1))}const g=i(h);if(g.length<=n.maxAxisCoords)return Float64Array.from(g)}return Float64Array.from(i([...e,...a(r,n.maxAxisCoords-e.length)]))}function Rt(e,t){let n=0,s=e.length-1,o=-1;for(;n<=s;){const i=n+s>>1;e[i]<=t?(o=i,n=i+1):s=i-1}return o}function le(e,t){const n=Rt(e,t+.25);return n>=0&&Math.abs(e[n]-t)<=.25?n:-1}const Go=e=>({laneGap:(e==null?void 0:e.laneGap)??Ho,maxLanes:(e==null?void 0:e.maxLanes)??$o,maxAxisCoords:(e==null?void 0:e.maxAxisCoords)??jo,heuristicWeight:(e==null?void 0:e.heuristicWeight)??Bo}),Yo=e=>({crossing:(e==null?void 0:e.crossing)??Do,overlap:(e==null?void 0:e.overlap)??_o,bend:(e==null?void 0:e.bend)??Po,detour:(e==null?void 0:e.detour)??Lo});function Ee(e,t,n=18,s="long-first",o={}){const i=Math.max(12,n*.75),a=Yo(o.costs),r=Go(o.lattice),c=S=>Math.abs(S.source.x-S.target.x)+Math.abs(S.source.y-S.target.y),h=e.map((S,E)=>({request:S,index:E})).sort((S,E)=>(s==="long-first"?1:-1)*(c(E.request)-c(S.request))),g=new Array(e.length);let l=new co;const y=new Uo,w=(S,E)=>{for(let v=1;v<E.length;v++)l.add(E[v-1].x,E[v-1].y,E[v].x,E[v].y,S)};for(const{request:S,index:E}of h){const v=Cn(S,t,l,E,n,i,y,a,r);g[E]=v,w(E,v)}const m=o.refineRounds??4,p=o.refineFraction??1,u=o.refineBudgetMs??150,M=performance.now();for(let S=0;S<m&&!(performance.now()-M>u);S++){const v=g.map((Z,H)=>({owner:H,crossings:An(Z,l,H)})).filter(Z=>Z.crossings>0).sort((Z,H)=>H.crossings-Z.crossings);if(v.length===0)break;const D=Math.max(1,Math.min(v.length,Math.ceil(e.length*p)));let K=!1;for(let Z=0;Z<D&&!(performance.now()-M>u);Z++){const H=v[Z].owner,B=Cn(e[H],t,l,H,n,i,y,a,r);An(B,l,H)<v[Z].crossings&&(g[H]=B,K=!0)}if(!K)break;l=Xo(g)}const I=new Map;return e.forEach((S,E)=>I.set(S.id,g[E])),I}function Xo(e){const t=new co;for(let n=0;n<e.length;n++)for(let s=1;s<e[n].length;s++)t.add(e[n][s-1].x,e[n][s-1].y,e[n][s].x,e[n][s].y,n);return t}function An(e,t,n){let s=0;for(let o=1;o<e.length;o++)s+=t.conflicts(e[o-1],e[o],n);return s}class Uo{constructor(){Ht(this,"blocked",new Uint8Array(0));Ht(this,"hClear",new Uint8Array(0));Ht(this,"vClear",new Uint8Array(0));Ht(this,"hCost",new Float64Array(0));Ht(this,"vCost",new Float64Array(0));Ht(this,"g",new Float64Array(0));Ht(this,"parent",new Int32Array(0));Ht(this,"heap",new zo(1024))}fit(t,n){const s=t*n;this.blocked.length<s&&(this.blocked=new Uint8Array(s),this.g=new Float64Array(s*3),this.parent=new Int32Array(s*3));const o=Math.max(0,t-1)*n,i=t*Math.max(0,n-1);this.hClear.length<o&&(this.hClear=new Uint8Array(o),this.hCost=new Float64Array(o)),this.vClear.length<i&&(this.vClear=new Uint8Array(i),this.vCost=new Float64Array(i)),this.blocked.fill(0,0,s),this.hClear.fill(1,0,o),this.hCost.fill(0,0,o),this.vClear.fill(1,0,i),this.vCost.fill(0,0,i),this.g.fill(Number.POSITIVE_INFINITY,0,s*3),this.parent.fill(-1,0,s*3),this.heap.clear()}}function Cn(e,t,n,s,o,i,a,r,c){const h=e.source,g=e.target,l=Math.abs(h.x-g.x)+Math.abs(h.y-g.y),y=Math.min(ro,l/3),w=!!e.sourceSide&&y>.5,m=!!e.targetSide&&y>.5,p=w?Ue(h,e.sourceSide,y):h,u=m?Ue(g,e.targetSide,y):g,M=(T,f)=>f.x>T.x-i&&f.x<T.x+T.width+i&&f.y>T.y-i&&f.y<T.y+T.height+i,I=Math.max(240,l*.35),S=Math.min(h.x,g.x),E=Math.max(h.x,g.x),v=Math.min(h.y,g.y),D=Math.max(h.y,g.y),K=[];for(const T of t)T.id===e.sourceNodeId||T.id===e.targetNodeId||T.x+T.width<S-I||T.x>E+I||T.y+T.height<v-I||T.y>D+I||M(T,h)||M(T,g)||K.push(T);const Z=[],H=[];for(const T of K)Z.push(T.x-i,T.x+T.width+i),H.push(T.y-i,T.y+T.height+i);const B=kn([p.x,u.x],[...Z,S-o,E+o,(p.x+u.x)/2],c,Math.min(p.x,u.x),Math.max(p.x,u.x)),Y=kn([p.y,u.y],[...H,v-o,D+o,(p.y+u.y)/2],c,Math.min(p.y,u.y),Math.max(p.y,u.y)),nt=B.length,ht=Y.length,ft=le(B,p.x),_t=le(Y,p.y),Bt=le(B,u.x),q=le(Y,u.y);if(nt<2||ht<2||ft<0||_t<0||Bt<0||q<0)return ze(e);a.fit(nt,ht);const{blocked:Lt,hClear:$t,vClear:wt,hCost:jt,vCost:Dt,g:zt,parent:Yt,heap:mt}=a,At=nt-1,k=ht-1,P=i-1;for(const T of K){const f=T.x-P,d=T.x+T.width+P,x=T.y-P,A=T.y+T.height+P;let F=Rt(B,f)+1,O=Rt(B,d);for(;O>=0&&O<nt&&B[O]>=d;)O--;let N=Rt(Y,x)+1,L=Rt(Y,A);for(;L>=0&&L<ht&&Y[L]>=A;)L--;for(let pt=Math.max(0,N);pt<=L;pt++){const kt=pt*nt;for(let xt=Math.max(0,F);xt<=O;xt++)Lt[kt+xt]=1}const G=Math.max(0,Rt(Y,x)+1),tt=L,ot=Math.max(0,Rt(B,f)),vt=Math.min(At-1,O);for(let pt=G;pt<=tt;pt++){const kt=pt*At;for(let xt=ot;xt<=vt;xt++)$t[kt+xt]=0}const Et=Math.max(0,Rt(B,f)+1),gt=O,Pt=Math.max(0,Rt(Y,x)),Tt=Math.min(k-1,L);for(let pt=Et;pt<=gt;pt++){const kt=pt*k;for(let xt=Pt;xt<=Tt;xt++)wt[kt+xt]=0}}Lt[_t*nt+ft]=0,Lt[q*nt+Bt]=0;const R=n.near(B[0],Y[0],B[nt-1],Y[ht-1],s);for(const T of R)if(Math.abs(T.ax-T.bx)<.01){const d=T.ax,x=Math.min(T.ay,T.by),A=Math.max(T.ay,T.by),F=Rt(B,d),O=Math.max(0,Rt(Y,x)+1);let N=Rt(Y,A);for(;N>=0&&N<ht&&Y[N]>=A;)N--;if(F>=0&&F<At&&B[F]<d&&B[F+1]>d)for(let G=O;G<=N;G++)jt[G*At+F]+=r.crossing;const L=le(B,d);if(L>=0){const G=Math.max(0,Rt(Y,x)),tt=Math.min(k-1,N);for(let ot=G;ot<=tt;ot++)Dt[L*k+ot]+=r.overlap}}else{const d=T.ay,x=Math.min(T.ax,T.bx),A=Math.max(T.ax,T.bx),F=Rt(Y,d),O=Math.max(0,Rt(B,x)+1);let N=Rt(B,A);for(;N>=0&&N<nt&&B[N]>=A;)N--;if(F>=0&&F<k&&Y[F]<d&&Y[F+1]>d)for(let G=O;G<=N;G++)Dt[G*k+F]+=r.crossing;const L=le(Y,d);if(L>=0){const G=Math.max(0,Rt(B,x)),tt=Math.min(At-1,N);for(let ot=G;ot<=tt;ot++)jt[L*At+ot]+=r.overlap}}const J=_t*nt+ft,rt=q*nt+Bt,at=B[Bt],St=Y[q],Kt=c.heuristicWeight,Xt=(T,f)=>(Math.abs(B[T]-at)+Math.abs(Y[f]-St))*Kt,b=J*3+2;zt[b]=0,mt.push(Xt(ft,_t),b);const _=e.sourceSide,j=e.targetSide,W=(T,f)=>_?w?_==="left"?T<=0:_==="right"?T>=0:_==="top"?f<=0:f>=0:_==="left"?T<0:_==="right"?T>0:_==="top"?f<0:f>0:!0,z=(T,f)=>j?m?j==="left"?T>=0:j==="right"?T<=0:j==="top"?f>=0:f<=0:j==="left"?T>0:j==="right"?T<0:j==="top"?f>0:f<0:!0;let Q=0,$=-1;for(;mt.length>0;){const T=mt.pop(),f=T/3|0;if(f===rt){$=T;break}if(++Q>Ro)break;const d=T-f*3,x=zt[T];if(x+Xt(f%nt,f/nt|0)<mt.poppedF-.001)continue;const A=f%nt,F=f/nt|0;for(let O=0;O<4;O++){const N=O===0?-1:O===1?1:0,L=O===2?-1:O===3?1:0,G=A+N,tt=F+L;if(G<0||G>=nt||tt<0||tt>=ht)continue;const ot=tt*nt+G;if(Lt[ot]||f===J&&!W(N,L)||ot===rt&&!z(N,L))continue;let vt,Et;const gt=N!==0?0:1;if(N!==0){const Ft=F*At+(N>0?A:G);if(!$t[Ft])continue;vt=jt[Ft],Et=Math.abs(B[G]-B[A])}else{const Ft=A*k+(L>0?F:tt);if(!wt[Ft])continue;vt=Dt[Ft],Et=Math.abs(Y[tt]-Y[F])}const Pt=Xt(A,F),Tt=Xt(G,tt),pt=Et+vt+(d!==2&&d!==gt?r.bend:0)+(Tt>Pt?(Tt-Pt)*r.detour:0),kt=ot*3+gt,xt=x+pt;xt>=zt[kt]||(zt[kt]=xt,Yt[kt]=T,mt.push(xt+Tt,kt))}}if($<0)return ze(e);const U=[];for(let T=$;T>=0;T=Yt[T]){const f=T/3|0;if(U.push({x:B[f%nt],y:Y[f/nt|0]}),T===b)break}return U.reverse(),w&&U.unshift(h),m&&U.push(g),U.length>=2?ao(U):ze(e)}const ke=new Set(["composedOf","composes","decomposedBy","aggregation"]);function qe(e,t,n=ke){const s=new Map;for(const r of e)s.set(r.id,r);const o=new Map,i=new Set;for(const r of t)n.has(r.type)&&(!s.has(r.sourceId)||!s.has(r.targetId)||r.sourceId!==r.targetId&&(i.has(r.targetId)||(o.has(r.sourceId)||o.set(r.sourceId,[]),o.get(r.sourceId).push(r.targetId),i.add(r.targetId))));return{roots:[...s.keys()].filter(r=>!i.has(r)),childrenMap:o,elements:s}}function $i(e,t){const n=[],s=(o,i,a)=>{const r=e.childrenMap.get(o)??[];r.length>0&&i>=t&&n.push(o);for(const c of r)a.has(c)||(a.add(c),s(c,i+1,a))};for(const o of e.roots)s(o,0,new Set([o]));return n}function Hi(e){if(e.elements.size===0)return null;const t=new Set,n=o=>{if(!t.has(o)){t.add(o);for(const i of e.childrenMap.get(o)??[])n(i)}};e.roots[0]&&n(e.roots[0]);const s=[...e.elements.keys()].filter(o=>!t.has(o));return e.roots.length===1&&s.length===0?null:{rootIds:e.roots,disconnectedIds:s}}const Ko=new Set(["name","title","description","shortDescription","longDescription","sourceReference","rationaleText","semantics","protocolSemantics","queryDescription","dataSourceDescription","documentUsage","doc"]);function Vo(e,t=4){const n=[];e.shortId&&n.push({key:"id",value:e.shortId});for(const[s,o]of Object.entries(e.attributes)){if(n.length>=t)break;if(Ko.has(s)||s.includes(".")||s==="id"&&n.some(a=>a.key==="id"))continue;const i=o.split("::").pop().trim();!i||i.length>28||n.push({key:s,value:i})}return n.slice(0,t)}const ue={layout:(e,t)=>To(e,t)},Tn=(e,t)=>{const n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),s=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);return n>0&&s>0?n*s:0},Zo=(e,t,n)=>{if(e.y===t.y){if(e.y<n.y||e.y>n.y+n.height)return 0;const s=Math.min(Math.max(e.x,t.x),n.x+n.width)-Math.max(Math.min(e.x,t.x),n.x);return Math.max(s,0)}if(e.x===t.x){if(e.x<n.x||e.x>n.x+n.width)return 0;const s=Math.min(Math.max(e.y,t.y),n.y+n.height)-Math.max(Math.min(e.y,t.y),n.y);return Math.max(s,0)}return 0};function Je(e,t){var r;const n=new Map,s=[],o=c=>c.slice(1).reduce((h,g,l)=>h+Math.abs(g.x-c[l].x)+Math.abs(g.y-c[l].y),0),i=e.flatMap(c=>c.points.slice(1).map((h,g)=>({edgeId:c.id,a:c.points[g],b:h}))),a=[...e].sort((c,h)=>o(h.points)-o(c.points));for(const c of a){const{points:h,width:g,height:l}=c;if(h.length<2)continue;const y=[];for(let p=1;p<h.length;p++){const u=h[p-1],M=h[p],I=Math.abs(M.x-u.x)+Math.abs(M.y-u.y),S=Math.abs(M.x-u.x)>=Math.abs(M.y-u.y),E=l/2+4;for(const v of I>=g*1.5?[.5,.3,.7]:[.5,.25,.75]){const D={x:u.x+(M.x-u.x)*v,y:u.y+(M.y-u.y)*v};for(const K of[-1,1])y.push({center:S?{x:D.x,y:D.y+K*E}:{x:D.x+K*(g/2+4),y:D.y},segmentLength:I})}}let w=((r=y[0])==null?void 0:r.center)??h[0],m=Number.POSITIVE_INFINITY;for(const p of y){const u={x:p.center.x-g/2,y:p.center.y-l/2,width:g,height:l};let M=0;for(const I of s)M+=Tn(u,I)*3;for(const I of t)M+=Tn(u,I)*4;for(const I of i)I.edgeId!==c.id&&(M+=Zo(I.a,I.b,u)*12*2.5);M+=Math.max(0,g*1.4-p.segmentLength)*2,M<m&&(m=M,w=p.center)}n.set(c.id,w),s.push({x:w.x-g/2,y:w.y-l/2,width:g,height:l})}return n}const Qe=20,tn=e=>e.length*6.4+12;function qo(e){const{connectors:t,rects:n}=e,s=e.obstacles??[...n.entries()].map(([w,m])=>({id:w,...m})),o=[],i=new Map;for(const w of t){const m=n.get(w.sourceId),p=n.get(w.targetId);if(!m||!p||w.sourceId===w.targetId)continue;const u=v=>({x:v.x+v.width/2,y:v.y+v.height/2}),M=Math.abs(u(p).x-u(m).x)>=Math.abs(u(p).y-u(m).y),I=M?u(p).x>=u(m).x:u(p).y>=u(m).y,S=M?I?"right":"left":I?"bottom":"top",E=M?I?"left":"right":I?"top":"bottom";i.set(w.id,{source:S,target:E}),o.push({connectorId:w.id,nodeId:w.sourceId,side:S,otherCentre:u(p)}),o.push({connectorId:w.id,nodeId:w.targetId,side:E,otherCentre:u(m)})}const a=new Map,r=(w,m)=>`${w}\0${m}`,c=new Map;for(const w of o){const m=`${w.nodeId}\0${w.side}`;c.set(m,[...c.get(m)??[],w])}for(const w of c.values()){const m=n.get(w[0].nodeId),p=w[0].side==="left"||w[0].side==="right",u=[...w].sort((S,E)=>p?S.otherCentre.y-E.otherCentre.y:S.otherCentre.x-E.otherCentre.x),M=(p?m.height:m.width)*.7,I=(p?m.y+m.height/2:m.x+m.width/2)-M/2;u.forEach((S,E)=>{const v=u.length===1?(p?m.height:m.width)/2:I+M*(E/(u.length-1))-(p?m.y:m.x);a.set(r(S.connectorId,S.nodeId),{x:S.side==="left"?m.x:S.side==="right"?m.x+m.width:m.x+(p?m.width/2:v),y:S.side==="top"?m.y:S.side==="bottom"?m.y+m.height:m.y+(p?v:m.height/2)})})}const h=[];for(const w of t){const m=i.get(w.id);m&&h.push({id:w.id,source:a.get(r(w.id,w.sourceId)),target:a.get(r(w.id,w.targetId)),sourceNodeId:w.sourceId,targetNodeId:w.targetId,sourceSide:m.source,targetSide:m.target})}const g=Ee(h,s,e.channelGap),l=Je(t.flatMap(w=>{const m=g.get(w.id);return w.label&&m&&m.length>=2?[{id:w.id,points:m,width:tn(w.label),height:Qe}]:[]}),s),y=new Map;for(const[w,m]of g)y.set(w,{points:m,labelPoint:l.get(w)});return y}function Jo(e,t,n=1.5){if(e<=0||t<=0)return Number.POSITIVE_INFINITY;const s=1+1.35*Math.abs(Math.log(e/t/n));return e*t*s}function Qo(e,t=1.25){return e<=1?Math.max(e,1):Math.min(e,Math.max(2,Math.round(Math.sqrt(e*t))))}function lo(e,t){const n=new Set(e.map(h=>h.id)),s=new Map,o=new Map(e.map(h=>[h.id,0]));for(const h of t)!n.has(h.source)||!n.has(h.target)||h.source===h.target||(s.has(h.source)||s.set(h.source,[]),s.get(h.source).push(h.target),o.set(h.target,(o.get(h.target)??0)+1));const i=e.map(h=>h.id),a=i.filter(h=>(o.get(h)??0)===0),r=[],c=new Set;for(;a.length;){const h=a.shift();if(!c.has(h)){c.add(h),r.push(h);for(const g of s.get(h)??[])o.set(g,(o.get(g)??1)-1),o.get(g)===0&&a.push(g)}}for(const h of i)c.has(h)||r.push(h);return r}function ts(e,t,n,s,o){const i=new Map(e.map(p=>[p.id,p])),a=lo(e,t).map(p=>i.get(p)),r=Qo(e.length,o),c=Math.ceil(e.length/r),h=a.map((p,u)=>{const M=Math.floor(u/r),I=u%r,S=M%2===0?I:r-1-I;return{node:p,row:M,col:S}}),g=Array.from({length:r},()=>0),l=Array.from({length:c},()=>0);for(const{node:p,row:u,col:M}of h)g[M]=Math.max(g[M],p.width),l[u]=Math.max(l[u],p.height);const y=g.map((p,u)=>u===0?0:g.slice(0,u).reduce((M,I)=>M+I,0)+n*u),w=l.map((p,u)=>u===0?0:l.slice(0,u).reduce((M,I)=>M+I,0)+s*u),m=h.map(({node:p,row:u,col:M})=>({...p,x:y[M]+(g[M]-p.width)/2,y:w[u]+(l[u]-p.height)/2}));return{strategy:"balanced-board",width:g.reduce((p,u)=>p+u,0)+n*Math.max(r-1,0),height:l.reduce((p,u)=>p+u,0)+s*Math.max(c-1,0),children:m}}function es(e,t,n,s){const o={x:e.x+e.width/2,y:e.y+e.height/2},i={x:t.x+t.width/2,y:t.y+t.height/2},a={x:n.x+n.width/2,y:n.y+n.height/2},r={x:s.x+s.width/2,y:s.y+s.height/2},c=(h,g,l)=>(g.x-h.x)*(l.y-h.y)-(g.y-h.y)*(l.x-h.x);return c(o,i,a)*c(o,i,r)<0&&c(a,r,o)*c(a,r,i)<0}function ns(e,t,n=1.5){const s=new Map(e.children.map(m=>[m.id,m]));let o=0,i=0,a=0,r=0;const c=t.filter(m=>s.has(m.source)&&s.has(m.target));for(const m of c){const p=s.get(m.source),u=s.get(m.target);o+=Math.abs(p.x+p.width/2-(u.x+u.width/2))+Math.abs(p.y+p.height/2-(u.y+u.height/2));const M=u.x+u.width/2-(p.x+p.width/2),I=Math.abs(u.y+u.height/2-(p.y+p.height/2));M<=0&&(a+=55e3),a+=Math.max(0,I-Math.max(M,0))*80,Math.abs(M)>8&&I>8&&(r+=18e3)}for(let m=0;m<c.length;m++)for(let p=m+1;p<c.length;p++){const u=c[m],M=c[p];u.source===M.source||u.source===M.target||u.target===M.source||u.target===M.target||es(s.get(u.source),s.get(u.target),s.get(M.source),s.get(M.target))&&i++}const h=Ee(c.map(m=>{const p=s.get(m.source),u=s.get(m.target);return{id:m.id,source:{x:p.x+p.width,y:p.y+p.height/2},target:{x:u.x,y:u.y+u.height/2},sourceNodeId:m.source,targetNodeId:m.target,sourceSide:"right",targetSide:"left"}}),e.children);let g=0,l=0,y=0;const w=[];for(const[m,p]of h){l+=Math.max(0,p.length-2);for(let u=1;u<p.length;u++)g+=Math.abs(p[u].x-p[u-1].x)+Math.abs(p[u].y-p[u-1].y),w.push({edgeId:m,a:p[u-1],b:p[u]})}for(let m=0;m<w.length;m++)for(let p=m+1;p<w.length;p++){const u=w[m],M=w[p];u.edgeId!==M.edgeId&&(so(u.a,u.b,M.a,M.b)||io(u.a,u.b,M.a,M.b))&&y++}return Jo(e.width,e.height,n)+o*18+a+r+i*Math.max(e.width*e.height*.35,5e4)+g*6+l*4e3+y*Math.max(e.width*e.height*.45,7e4)}async function Fn(e){const{nodes:t,edges:n}=e;if(t.length===0)return{strategy:"balanced-board",width:0,height:0,children:[]};const s=e.targetAspect??1.5,o=e.gapX??54,i=e.gapY??58,a=h=>{const g=new Map(t.map(M=>[M.id,M])),l=lo(t,n).map(M=>g.get(M));let y=0;const w=Math.max(...h==="RIGHT"?l.map(M=>M.height):l.map(M=>M.width));let m=l.map(M=>{const I={...M,x:h==="RIGHT"?y:(w-M.width)/2,y:h==="DOWN"?y:(w-M.height)/2};return y+=h==="RIGHT"?M.width+o:M.height+i,I});if(h==="RIGHT"&&n.some(M=>M.sourceAnchorY!==void 0&&M.targetAnchorY!==void 0)){new Map(m.map(v=>[v.id,v]));const M=new Map,I=[...m].sort((v,D)=>D.width*D.height-v.width*v.height)[0];M.set(I.id,0);let S=!0;for(;S;){S=!1;for(const v of n){if(v.sourceAnchorY===void 0||v.targetAnchorY===void 0)continue;const D=M.get(v.source),K=M.get(v.target);D!==void 0&&K===void 0?(M.set(v.target,D+v.sourceAnchorY-v.targetAnchorY),S=!0):K!==void 0&&D===void 0&&(M.set(v.source,K+v.targetAnchorY-v.sourceAnchorY),S=!0)}}m=m.map(v=>({...v,y:M.get(v.id)??v.y}));const E=Math.min(...m.map(v=>v.y));m=m.map(v=>({...v,y:v.y-E}))}const p=Math.max(...m.map(M=>M.x+M.width)),u=Math.max(...m.map(M=>M.y+M.height));return{strategy:h==="RIGHT"?"layered-right":"layered-down",width:p,height:u,children:m}};if(e.directedFlowAxis==="RIGHT")return a("RIGHT");if(e.directedFlowAxis==="DOWN")return a("DOWN");const r=[ts(t,n,o,i,s),a("RIGHT"),a("DOWN")];if(t.length>=3&&n.length>0)try{const h=new Map(t.filter(u=>{var M;return(M=u.ports)==null?void 0:M.length}).map(u=>[u.id,u])),g={left:"WEST",right:"EAST",top:"NORTH",bottom:"SOUTH"},l=new Set((e.graphPorts??[]).map(u=>u.id)),y=(e.graphPorts??[]).map(u=>({id:u.id,width:1,height:1,...u.side==="left"||u.side==="right"?{layoutOptions:{"elk.layered.layering.layerConstraint":u.side==="right"?"LAST_SEPARATE":"FIRST_SEPARATE"}}:{}})),m=(await ue.layout({id:`resolver-${e.id}`,layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.aspectRatio":String(s),"elk.padding":"[top=0,left=0,bottom=0,right=0]","elk.spacing.nodeNode":String(i),"elk.layered.spacing.nodeNodeBetweenLayers":String(o),"elk.layered.nodePlacement.strategy":"BRANDES_KOEPF","elk.layered.nodePlacement.favorStraightEdges":"true","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.crossingMinimization.semiInteractive":"true","elk.layered.thoroughness":"18","elk.layered.wrapping.strategy":t.length>5?"MULTI_EDGE":"OFF","elk.layered.wrapping.additionalEdgeSpacing":"18","elk.separateConnectedComponents":"true","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.randomSeed":"1"},children:[...y,...t.map(u=>{var M;return(M=u.ports)!=null&&M.length?{id:u.id,width:u.width,height:u.height,layoutOptions:{"elk.portConstraints":"FIXED_SIDE"},ports:u.ports.map(I=>({id:I.id,width:8,height:8,layoutOptions:{"elk.port.side":g[I.side]}}))}:{id:u.id,width:u.width,height:u.height}})],edges:n.map(u=>({id:u.id,sources:[h.has(u.source)&&u.sourcePort?u.sourcePort:u.source],targets:[h.has(u.target)&&u.targetPort?u.targetPort:u.target]}))},{providerId:e.layoutProviderId})).children??[],p=m.filter(u=>!l.has(u.id));if(p.length===t.length){const u=new Map(t.map(v=>[v.id,v])),M=Math.min(...p.map(v=>v.x??0)),I=Math.min(...p.map(v=>v.y??0)),S=p.map(v=>{const D=v.ports;return{...u.get(v.id),x:(v.x??0)-M,y:(v.y??0)-I,...D!=null&&D.length?{portY:new Map(D.map(K=>[K.id,K.y??0])),portX:new Map(D.map(K=>[K.id,K.x??0]))}:{}}}),E=m.filter(v=>l.has(v.id));r.push({strategy:"elk-layered",width:Math.max(...S.map(v=>v.x+v.width)),height:Math.max(...S.map(v=>v.y+v.height)),...E.length?{graphPortY:new Map(E.map(v=>[v.id,(v.y??0)-I]))}:{},children:S})}}catch{}const c=h=>{const g=ns(h,n,s);if(!e.preferBalancedLayout)return g;const l=Math.abs(Math.log(Math.max(h.width,1)/Math.max(h.height,1)/s));return g+h.width*h.height*l*2.8};return r.reduce((h,g)=>c(g)<c(h)?g:h)}async function os(e,t){var I;const n=Object.values(e.elements),s=t!=null&&t.viewpointFilter?n.filter(t.viewpointFilter):n,o=new Set(s.map(S=>S.id)),i=(I=t==null?void 0:t.relationshipTypes)!=null&&I.length?new Set(t.relationshipTypes.map(S=>S.toLowerCase())):void 0,a=e.relationships.filter(S=>o.has(S.sourceId)&&o.has(S.targetId)&&(!i||i.has(S.type.toLowerCase()))),r=s.length,c=r>60?"RIGHT":"DOWN",h=r>40?"24":r>20?"32":"40",g=r>40?"60":r>20?"80":"100",l=t!=null&&t.compartments?new Map(s.map(S=>[S.id,Vo(S)])):void 0,y=S=>Math.max(S.name.length*7.5+48,S.kind.length*6.8+48,130),w=S=>{const E=l==null?void 0:l.get(S.id);return 52+(E!=null&&E.length?E.length*15+10:0)},m={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":c,"elk.spacing.nodeNode":h,"elk.layered.spacing.nodeNodeBetweenLayers":g,"elk.layered.spacing.edgeNodeBetweenLayers":"24","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.compaction.postCompaction.strategy":"EDGE_LENGTH","elk.layered.wrapping.strategy":"MULTI_EDGE","elk.layered.wrapping.additionalEdgeSpacing":"16","elk.separateConnectedComponents":"true","elk.spacing.componentComponent":"56","elk.aspectRatio":"1.6","elk.padding":"[top=20, left=20, bottom=20, right=20]"},children:s.map(S=>({id:S.id,width:y(S),height:w(S)})),edges:a.map((S,E)=>({id:S.id||`e-${E}`,sources:[S.sourceId],targets:[S.targetId]}))};let p;try{p=await ue.layout(m,{providerId:t==null?void 0:t.layoutProviderId})}catch(S){console.warn("ELK layout failed, retrying without edge wrapping:",S),delete m.layoutOptions["elk.layered.wrapping.strategy"],delete m.layoutOptions["elk.layered.wrapping.additionalEdgeSpacing"],p=await ue.layout(m,{providerId:t==null?void 0:t.layoutProviderId})}const u=(p.children||[]).map(S=>{const E=e.elements[S.id],v=Qt[E==null?void 0:E.layer]||"#666",D=l==null?void 0:l.get(S.id);return{id:S.id,type:"diagramNode",position:{x:S.x||0,y:S.y||0},data:{label:(E==null?void 0:E.name)||S.id,kind:(E==null?void 0:E.kind)??"",layer:(E==null?void 0:E.layer)??"",construct:E==null?void 0:E.construct,color:v,...D!=null&&D.length?{compartments:D}:{}}}}),M=a.map((S,E)=>{const v=ce[S.type]||"#9CA3AF",D=S.type.toLowerCase(),K=S.type==="flow",Z=S.type==="succession",H=D==="composedof"||D==="decomposedby"||D==="aggregation"||D==="composes";return{id:S.id||`e-${E}`,source:S.sourceId,target:S.targetId,label:H?void 0:S.type,type:Z?"smoothstep":"default",animated:K,style:{stroke:v,strokeWidth:H?2.5:K?2:it.defaultWidth,strokeDasharray:H||K?void 0:S.type==="traceTo"?"5 3":void 0},labelStyle:{fontSize:"10px",fill:"#6B7280",fontWeight:500},labelBgPadding:it.labelBgPadding,labelBgBorderRadius:it.labelBgRadius,labelBgStyle:it.labelBgStyle,markerEnd:{type:H?"arrow":"arrowclosed",color:v,width:it.arrowSize,height:it.arrowSize}}});return{nodes:u,edges:M}}function ho(e){var a;const t=new Set((((a=e.registries)==null?void 0:a.kinds)??[]).filter(r=>{var c;return(c=r.namespace)==null?void 0:c.some(h=>h==="logical"||h==="implementation"||h==="realization")}).map(r=>r.name)),n=new Map;for(const r of Object.values(e.elements))t.has(r.kind)&&n.set(r.id,r);const s=new Map,o=new Set;for(const r of e.relationships)(r.type==="composedOf"||r.type==="aggregation")&&n.has(r.sourceId)&&n.has(r.targetId)&&(s.has(r.sourceId)||s.set(r.sourceId,[]),s.get(r.sourceId).push(r.targetId),o.add(r.targetId));return{roots:[...n.keys()].filter(r=>!o.has(r)),childrenMap:s,elements:n}}const qt=64,_e=100,On=110,Nn=300,_n=44;function nn(e){return Math.max(e.name.length*8+80,220)}async function ss(e,t){const n=t.tree??ho(e);if(n.roots.length===0)return{nodes:[],edges:[]};const s=t.positionCache??new Map,o=y=>t.nodeDirections.get(y)||"vertical",i=y=>(n.childrenMap.get(y)||[]).filter(w=>n.elements.has(w)),a=y=>{const w=n.elements.get(y),m=nn(w),p=i(y);if(!t.expandedNodes.has(y)||p.length===0)return{width:m,height:qt};const u=p.map(a);if(o(y)==="vertical"){const S=u.reduce((v,D)=>v+D.width,0)+(u.length-1)*_e,E=Math.max(...u.map(v=>v.height));return{width:Math.max(m,S),height:qt+On+E}}const M=Math.max(...u.map(S=>S.width)),I=u.reduce((S,E)=>S+E.height,0)+(u.length-1)*_n;return{width:m+Nn+M,height:Math.max(qt,I)}},r=[],c=[],h=ce.composedOf,g=(y,w,m,p)=>{const u=n.elements.get(y),M=nn(u),I=i(y),S=t.expandedNodes.has(y);let E=s.get(y);E||(E={x:m-M/2,y:p-qt/2},s.set(y,E));const v={element:u,layerColor:Qt[u.layer]||"#666",isExpanded:S,hasChildren:I.length>0,childCount:I.length,direction:o(y),onToggleExpand:()=>t.callbacks.onToggleExpand(y),onToggleDirection:()=>t.callbacks.onToggleDirection(y),showDirectionButton:!0,label:u.name};if(r.push({id:y,type:"decompositionNode",position:{x:E.x,y:E.y},data:v,style:{width:M,height:qt}}),w){const K=o(w);c.push({id:`decomp-${w}-${y}`,source:w,target:y,sourceHandle:K==="vertical"?"bottom":"right",targetHandle:K==="vertical"?"top":"left",type:"smoothstep",style:{stroke:h,strokeWidth:it.defaultWidth},markerEnd:{type:"arrowclosed",color:h,width:it.arrowSize,height:it.arrowSize}})}if(!S||I.length===0)return;const D=I.map(a);if(o(y)==="vertical"){const K=D.reduce((B,Y)=>B+Y.width,0)+(D.length-1)*_e;let Z=E.x+M/2-K/2;const H=E.y+qt+On+qt/2;I.forEach((B,Y)=>{g(B,y,Z+D[Y].width/2,H),Z+=D[Y].width+_e})}else{const K=E.x+M+Nn;let Z=E.y+qt+20;I.forEach((H,B)=>{const Y=n.elements.get(H);g(H,y,K+nn(Y)/2,Z+qt/2),Z+=D[B].height+_n})}};let l=0;for(const y of n.roots){if(!n.elements.has(y))continue;const w=a(y);g(y,null,l+w.width/2,100),l+=w.width+_e*2}return{nodes:r,edges:c}}const on=240,sn=80,se=20;function is(e,t){const n=t.tree??ho(e);if(n.roots.length===0)return{nodes:[],edges:[]};const s=[];function o(l,y,w,m,p){const u=n.elements.get(l);if(!u)return{width:0,height:0};const M=Qt[u.layer]||"#666",I=n.childrenMap.get(l)||[],S=I.length>0,E=t.expandedNodes.has(l);let v=on,D=sn;if(E&&S){let H=se,B=sn+se,Y=0,nt=0;for(const ht of I){if(!n.elements.has(ht))continue;const ft=o(ht,l,w+1,H,B);H+ft.width>800&&H>se&&(H=se,B+=Y+se,Y=0,i(ht),o(ht,l,w+1,H,B)),H+=ft.width+se,Y=Math.max(Y,ft.height),nt=Math.max(nt,H)}v=Math.max(on,nt),D=B+Y+se}const K=vn[w%vn.length],Z={element:u,layerColor:M,isExpanded:E,hasChildren:S,childCount:I.length,direction:"vertical",onToggleExpand:()=>t.callbacks.onToggleExpand(l),onToggleDirection:()=>{},showDirectionButton:!1,depthBgColor:K,isContainer:S,label:u.name};return s.push({id:l,type:"decompositionNode",position:{x:m,y:p},...y?{parentId:y,extent:"parent"}:{},data:Z,style:{width:E&&S?v:on,height:E&&S?D:sn}}),{width:v,height:D}}function i(l){const y=new Set([l]),w=m=>{for(const p of n.childrenMap.get(m)||[])y.add(p),w(p)};w(l);for(let m=s.length-1;m>=0;m--)y.has(s[m].id)&&s.splice(m,1)}let a=0;for(const l of n.roots){if(!n.elements.has(l))continue;const y=o(l,null,0,a,0);a+=y.width+40}const r=new Map(s.map(l=>[l.id,l])),c=[],h=new Set,g=l=>{if(h.has(l.id))return;const y=l.parentId?r.get(l.parentId):void 0;y&&g(y),h.add(l.id),c.push(l)};for(const l of s)g(l);return{nodes:c,edges:[]}}function rs(e){var a;const t=new Set((((a=e.registries)==null?void 0:a.kinds)??[]).filter(r=>{var c;return(c=r.namespace)==null?void 0:c.includes("functional")}).map(r=>r.name)),n=new Map;for(const r of Object.values(e.elements))t.has(r.kind)&&n.set(r.id,r);const s=new Map,o=new Set;for(const r of e.relationships)(r.type==="decomposedBy"||r.type==="composedOf")&&n.has(r.sourceId)&&n.has(r.targetId)&&(s.has(r.sourceId)||s.set(r.sourceId,[]),s.get(r.sourceId).push(r.targetId),o.add(r.targetId));return{roots:[...n.keys()].filter(r=>!o.has(r)),childrenMap:s,elements:n}}async function Wi(e,t){const n=rs(e);if(n.roots.length===0)return{nodes:[],edges:[]};const s=new Set,o=[];function i(g){if(n.elements.has(g)&&(s.add(g),t.expandedNodes.has(g)))for(const l of n.childrenMap.get(g)||[])n.elements.has(l)&&(o.push({parentId:g,childId:l}),i(l))}for(const g of n.roots)i(g);const a={id:"root",layoutOptions:{"elk.algorithm":"mrtree","elk.direction":"DOWN","elk.spacing.nodeNode":"40","elk.mrtree.searchOrder":"DFS"},children:[...s].map(g=>{const l=n.elements.get(g);return{id:g,width:Math.max(l.name.length*8+80,220),height:56}}),edges:o.map((g,l)=>({id:`fbs-${l}`,sources:[g.parentId],targets:[g.childId]}))},c=((await ue.layout(a,{providerId:t.layoutProviderId})).children||[]).map(g=>{const l=n.elements.get(g.id),y=Qt[l.layer]||"#E67E22",w=(n.childrenMap.get(g.id)||[]).length,m=t.nodeDirections.get(g.id)||"vertical",p={element:l,layerColor:y,isExpanded:t.expandedNodes.has(g.id),hasChildren:w>0,childCount:w,direction:m,onToggleExpand:()=>t.callbacks.onToggleExpand(g.id),onToggleDirection:()=>t.callbacks.onToggleDirection(g.id),showDirectionButton:!0,label:l.name};return{id:g.id,type:"decompositionNode",position:{x:g.x||0,y:g.y||0},data:p}}),h=o.map((g,l)=>{const y=t.nodeDirections.get(g.parentId)||"vertical";return{id:`fbs-e-${l}`,source:g.parentId,target:g.childId,sourceHandle:y==="vertical"?"bottom":"right",targetHandle:y==="vertical"?"top":"left",type:"default",style:{stroke:ce.decomposedBy,strokeWidth:it.defaultWidth},markerEnd:{type:"arrowclosed",color:ce.decomposedBy,width:it.arrowSize,height:it.arrowSize}}});return{nodes:c,edges:h}}const zi=["graph","tree","containment"];function Gi(e){const t=e==null?void 0:e.layoutHint;return t==="tree"||t==="containment"||t==="graph"?t:"graph"}function as(e,t){const n=Object.values(e.elements);return t?n.filter(t):n}function cs(e,t,n){const s=n!=null&&n.length?No(n):void 0;return qe(as(e,t),e.relationships,s)}async function Yi(e,t){if(t.mode==="graph")return os(e,{viewpointFilter:t.viewpointFilter,relationshipTypes:t.relationshipTypes,compartments:!0,layoutProviderId:t.layoutProviderId});const n=cs(e,t.viewpointFilter,t.hierarchyRelationshipTypes);return t.mode==="tree"?ss(e,{expandedNodes:t.expandedNodes,nodeDirections:t.nodeDirections,callbacks:t.callbacks,tree:n,positionCache:t.positionCache}):is(e,{expandedNodes:t.expandedNodes,callbacks:{onToggleExpand:t.callbacks.onToggleExpand},tree:n})}const Ke="__inner";function Xi(e){if(e&&!["left","right","top","bottom"].includes(e))return e.endsWith(Ke)?e.slice(0,-Ke.length):e}const Ui={in:"#16A34A",out:"#D97706",inout:"#2563EB"},ls={data:"#3498DB",energy:"#D97706",material:"#16A34A",control:"#6B7280"},ds=new Set(["flow","bind"]);function hs(e,t=""){return e||(ds.has(oo(t))?void 0:t)||void 0}function gs(e,t){const n=e??"";return/energy|power|voltage|current|thermal|heat/i.test(n)?"energy":/material|fluid|gas|liquid|drug|dose|batch|consumable/i.test(n)?"material":t&&/succession|control/i.test(t)?"control":"data"}const In=["left","right","top","bottom"],ve=e=>e==="left"||e==="right";function Ki(e){return e&&In.includes(e)?e:void 0}function go(e){return e.construct==="port"||e.kind.endsWith("Port")}function ye(e){var n;const t=(n=e.attributes.connectorType)==null?void 0:n.trim();return t||void 0}function Dn(e){var s,o;const t=(s=e.portSpec)==null?void 0:s.direction;if(t==="in"||t==="out"||t==="inout")return t;const n=(o=(e.attributes.direction??"").split("::").pop())==null?void 0:o.trim();if(n==="bidirectional")return"inout";if(n==="in"||n==="out"||n==="inout")return n}const Nt=24,Vi=Nt,rn=Nt,he=30,yn=48,ee=yn,Pn=44,De=12,us=14,fs=104,uo=5,an=(e,t)=>{const n=Math.max(e.length*6.1+10,t?t.length*5.2+10:0);return Math.min(Math.max(n,44),fs)},cn=30,Ge=30,ms=72,Me=ms+6,ps=26,ys=Nt/2+uo+ps,xe=14,ln=90,Ln=112,xs=72,ws=(e,t=7.2)=>e.length*t+20,bs=e=>Math.min(Math.max(ws(e,7.1),96),180);function fo(e){var s,o;const t=(s=e.portSpec)==null?void 0:s.direction,n=t==="in"||t==="out"||t==="inout"?t:(o=(e.attributes.direction??"").split("::").pop())==null?void 0:o.trim();if(n==="in")return"in";if(n==="out"||n==="inout"||n==="bidirectional"||/out(put)?$/i.test(e.name))return"out";if(/in(put)?$/i.test(e.name))return"in"}function Is(e,t,n){return fo(e)??(t>n?"out":"in")}const Ms=e=>e==="in"?"left":"right";function Ss(e,t){const n=e.filter(o=>!t.isConnected(o)&&!t.hasChildParts(o)&&t.portCount(o)===0),s=new Set(n);return{flowKids:e.filter(o=>!s.has(o)),orphanKids:n}}function vs(e,t,n){const s=new Map,o=new Map;for(const[r,c]of e)c.owner&&(t(c.owner)?s.set(r,c.owner):e.has(c.owner)&&o.set(r,c.owner));for(const r of n)!ke.has(r.type)||!e.has(r.targetId)||s.has(r.targetId)||o.has(r.targetId)||(t(r.sourceId)?s.set(r.targetId,r.sourceId):e.has(r.sourceId)&&o.set(r.targetId,r.sourceId));const i=new Map,a=(r,c)=>{const h=i.get(r)??s.get(r);if(h)return i.set(r,h),h;const g=o.get(r);if(!g||c.has(g))return;c.add(g);const l=a(g,c);return l&&i.set(r,l),l};for(const r of e.keys())a(r,new Set([r]));return{ownerPart:i,parentPort:o}}function dn(e,t,n){if(t==="none")return;if(t==="all")return e;let s=e;const o=new Set([s]);for(;n.has(s);){const i=n.get(s);if(o.has(i))break;o.add(i),s=i}return s}function Es(e,t,n){const s=new Set,o=i=>{if(!(s.has(i)||!t(i))){s.add(i);for(const a of e.get(i)??[])o(a)}};return o(n),s}function ks(e,t){const n=t.size??Nt,s=t.pitch??Ge,o=t.horizontalPitch??Me,i=t.nestedPitch??he,a=t.height??t.bodyBottom,r=new Map;for(const c of In){const h=e.filter(I=>t.sideOf(I)===c);if(h.length===0)continue;const g=h.length,l=ve(c),y=l?t.bodyTop:t.bodyLeft??0,w=l?t.bodyBottom:t.bodyRight??t.width,m=l?s:o,p=Math.max(w-y,0),u=l?t.minCenterY:y+m/2;let M=-1/0;h.forEach((I,S)=>{var v;let E=g===1&&l&&t.singleCenterY!==void 0?t.singleCenterY:y+(g===1?p/2:(S+.5)/g*p);E=Math.max(E,u,M+m),M=E+((((v=t.weightOf)==null?void 0:v.call(t,I))??1)-1)*i,r.set(I,{x:l?c==="left"?-n/2:t.width-n/2:E-n/2,y:l?E-n/2:c==="top"?-n/2:a-n/2,side:c})})}return r}function Rn(e,t,n){for(const s of In){const o=ve(s),i=o?t:n;if(!i)continue;const a=[...e].filter(([c,h])=>h.side===s&&i.has(c)).map(([c])=>c);if(a.length<2)continue;const r=a.map(c=>o?e.get(c).y:e.get(c).x).sort((c,h)=>c-h);[...a].sort((c,h)=>i.get(c)-i.get(h)).forEach((c,h)=>{const g=e.get(c);o?g.y=r[h]:g.x=r[h]})}}function As(e,t){return[...e.reduce((n,s)=>{const o=`${t(s.sourceId)}\0${t(s.targetId)}`,i=n.get(o);return i?i.count++:n.set(o,{rel:s,count:1}),n},new Map).values()].map(({rel:n,count:s})=>s===1?n:{...n,id:`bundle-${n.id}`,attributes:{...n.attributes,bundleCount:String(s)}})}async function Zi(e,t){var T;const n=Object.values(e.elements),s=t!=null&&t.viewpointFilter?n.filter(t.viewpointFilter):n,o=new Map,i=[];for(const f of s)go(f)?o.set(f.id,f):i.push(f);if(i.length===0)return{nodes:[],edges:[]};const a=(t==null?void 0:t.portDisplay)??"all",r=a!=="none",c=qe(i,e.relationships),h=t!=null&&t.focusId&&c.elements.has(t.focusId)?t.focusId:void 0,g=h?Es(c.childrenMap,f=>c.elements.has(f),h):null,l=f=>c.elements.has(f)&&(!g||g.has(f)),y=f=>{var d;return(d=t==null?void 0:t.collapsedNodes)!=null&&d.has(f)?[]:(c.childrenMap.get(f)??[]).filter(l)},{ownerPart:w,parentPort:m}=vs(o,l,e.relationships);for(const f of[...o.keys()])w.has(f)||o.delete(f);const p=f=>dn(f,"ports",m),u=new Map;for(const[f,d]of w)!o.has(f)||m.has(f)||(u.has(d)||u.set(d,[]),u.get(d).push(f));const M=new Map;if(a==="all")for(const[f]of m){if(!o.has(f))continue;const d=p(f);!o.has(d)||d===f||(M.has(d)||M.set(d,[]),M.get(d).push(f))}const I=f=>{var d;return 1+(((d=M.get(f))==null?void 0:d.length)??0)},S=(T=t==null?void 0:t.relationshipTypes)!=null&&T.length?new Set(t.relationshipTypes.map(f=>f.toLowerCase())):void 0,E=f=>o.has(f)||l(f),v=e.relationships.filter(f=>!ke.has(f.type)&&(!S||S.has(f.type.toLowerCase()))&&E(f.sourceId)&&E(f.targetId)&&f.sourceId!==f.targetId),D=f=>w.get(f)??f,K=f=>(o.has(f)?dn(f,a,m):void 0)??D(f),Z=(t==null?void 0:t.connectionDisplay)??"summary",H=new Set([...w].filter(([,f])=>f===(t==null?void 0:t.focusId)).map(([f])=>f)),B=H.size>0?v.filter(f=>H.has(f.sourceId)||H.has(f.targetId)):v,Y=Z==="none"?[]:Z==="all"?v:As(B,K),nt=new Set;for(const f of v)for(const d of[f.sourceId,f.targetId]){if(!o.has(d))continue;let x=d;for(;x&&!nt.has(x);)nt.add(x),x=m.get(x)}for(const[f,d]of u)u.set(f,d.filter(x=>nt.has(x)));const ht=new Set(v.filter(f=>l(f.sourceId)).map(f=>f.sourceId)),ft=new Set(v.filter(f=>l(f.targetId)).map(f=>f.targetId)),_t=new Map;for(const[f,d]of c.childrenMap)for(const x of d)l(x)&&_t.set(x,f);const Bt=new Map,q=f=>{const d=Bt.get(f);if(d)return d;const x=o.get(f);let A=fo(x);if(!A){const F=m.get(f);if(F&&o.has(F))A=q(F);else{let O=0,N=0;for(const L of Y)L.sourceId===f&&O++,L.targetId===f&&N++;A=Is(x,O,N)}}return Bt.set(f,A),A},Lt=t==null?void 0:t.portWalls,$t=new Map,wt=f=>{const d=$t.get(f);if(d)return d;const x=Lt==null?void 0:Lt.get(f),A=m.get(f),F=x??(A&&o.has(A)?wt(A):void 0)??Ms(q(f));return $t.set(f,F),F},jt=f=>{const d=A=>{const F=f.filter(O=>wt(O)===A).map(O=>{const N=o.get(O);return an((N==null?void 0:N.name)??"",N&&ye(N))});return F.length===0?us:Math.max(...F)+Nt+uo-Nt/2},x=A=>f.some(F=>wt(F)===A);return{left:d("left"),right:d("right"),top:0,bottom:x("bottom")?ys:0}},Dt=(f,d)=>f.filter(x=>wt(x)===d).reduce((x,A)=>x+(ve(d)?Ge:Me)+(I(A)-1)*he,0),zt=f=>bs(f.name),Yt=(f,d)=>{const x=jt(d),A=Math.max(Dt(d,"left"),Dt(d,"right"),0),F=Pn+cn,O=Math.max(F+A+8+x.bottom,xs+x.bottom),N=zt(f),L=Math.max(Dt(d,"top"),Dt(d,"bottom")),G=Math.max(x.left+Math.max(N,L)+x.right,Ln),tt=ks(d,{width:G,height:O,bodyTop:Pn,bodyBottom:O-De/2-x.bottom,bodyLeft:x.left,bodyRight:G-x.right,sideOf:wt,weightOf:I,minCenterY:F,singleCenterY:Math.max((O-x.bottom)/2,F)});return{width:G,height:O,childPos:new Map,portPos:tt}},mt=new Map,At=new Map,k=new Map,P=async f=>{const d=y(f),x=r?u.get(f)??[]:[],A=c.elements.get(f);if(d.length===0){const V=Yt(A,x);return mt.set(f,V),V}const F=new Map;for(const V of d)F.set(V,await P(V));const O=new Set(d),N=new Set(x),L=V=>{if(o.has(V)){const X=p(V);if(N.has(X))return X}let st=D(V);for(;st&&!O.has(st);)st=_t.get(st);return st},G=(V,st)=>{var et;if(!o.has(V)||w.get(V)!==st)return;const X=p(V);return(et=u.get(st))!=null&&et.includes(X)?X:void 0},tt=[],ot=new Set;Y.forEach((V,st)=>{const X=L(V.sourceId),et=L(V.targetId);X&&et&&X!==et&&(tt.push({id:`ic-${st}`,source:X,target:et,sourcePort:G(V.sourceId,X),targetPort:G(V.targetId,et)}),O.has(X)&&ot.add(X),O.has(et)&&ot.add(et))});const{flowKids:vt,orphanKids:Et}=Ss(d,{isConnected:V=>ot.has(V),hasChildParts:V=>(c.childrenMap.get(V)??[]).some(l),portCount:V=>{var st;return((st=u.get(V))==null?void 0:st.length)??0}}),gt=jt(x),Pt=new Map;let Tt=0,pt=0;if(vt.length>0){const V=X=>(u.get(X)??[]).map(et=>({id:et,side:wt(et)})),st=await Fn({id:`container-${f}`,nodes:vt.map(X=>({id:X,width:F.get(X).width,height:F.get(X).height,ports:V(X)})),edges:tt,graphPorts:x.map(X=>({id:X,side:wt(X)})),gapX:54,gapY:58,targetAspect:1.3,directedFlowAxis:"AUTO",preferBalancedLayout:!0,layoutProviderId:t==null?void 0:t.layoutProviderId});for(const X of st.children){const et=X.x+gt.left,Mt=X.y+ee;Pt.set(X.id,{x:et,y:Mt}),Tt=Math.max(Tt,et-gt.left+X.width),pt=Math.max(pt,Mt+X.height),(X.portY||X.portX)&&Rn(F.get(X.id).portPos,X.portY??new Map,X.portX)}st.graphPortY&&At.set(f,new Map([...st.graphPortY].map(([X,et])=>[X,et+ee])))}if(vt.length>0&&tt.length>0){const V=(ee+Math.max(pt,ee))/2,st=new Map(At.get(f)??[]),X=new Map(k.get(f)??[]),et=(ut,lt)=>{if(N.has(ut))return{x:X.get(ut)??Tt/2,y:st.get(ut)??V};const bt=Pt.get(ut),Ot=F.get(ut);if(!bt||!Ot)return;const ct=lt?Ot.portPos.get(lt):void 0;return ct?{x:bt.x+ct.x+Nt/2,y:bt.y+ct.y+Nt/2}:{x:bt.x+Ot.width/2,y:bt.y+Ot.height/2}},Mt=ut=>ut.reduce((lt,bt)=>lt+bt,0)/ut.length;for(let ut=0;ut<2;ut++){const lt=new Map,bt=new Map,Ot=(ct,Ct)=>{if(!(ct===void 0||Ct===void 0))for(const[Gt,me]of[[lt,Ct.y],[bt,Ct.x]])Gt.has(ct)||Gt.set(ct,[]),Gt.get(ct).push(me)};for(const ct of tt){const Ct=et(ct.source,ct.sourcePort),Gt=et(ct.target,ct.targetPort);Ot(ct.sourcePort??(N.has(ct.source)?ct.source:void 0),Gt),Ot(ct.targetPort??(N.has(ct.target)?ct.target:void 0),Ct)}for(const ct of vt){const Ct=F.get(ct),Gt=new Map,me=new Map;for(const Ce of Ct.portPos.keys()){const Te=lt.get(Ce);Te!=null&&Te.length&&Gt.set(Ce,Mt(Te));const Fe=bt.get(Ce);Fe!=null&&Fe.length&&me.set(Ce,Mt(Fe))}(Gt.size>1||me.size>1)&&Rn(Ct.portPos,Gt,me)}for(const ct of x){const Ct=lt.get(ct);Ct!=null&&Ct.length&&st.set(ct,Mt(Ct));const Gt=bt.get(ct);Gt!=null&&Gt.length&&X.set(ct,Mt(Gt))}}st.size>0&&At.set(f,st),X.size>0&&k.set(f,X)}if(Et.length>0){const V=Math.max(...Et.map(Ot=>F.get(Ot).width)),st=Math.max(Tt,V),X=Math.max(1,Math.min(Et.length,Math.floor((st+xe)/(V+xe))||1)),et=pt>0?pt+xe:ee;let Mt=0,ut=et,lt=0,bt=0;for(const Ot of Et){const ct=F.get(Ot),Ct=gt.left+Mt*(V+xe);Pt.set(Ot,{x:Ct,y:ut}),Tt=Math.max(Tt,Ct-gt.left+ct.width),lt=Math.max(lt,ct.height),bt=Math.max(bt,ut+ct.height),Mt++,Mt>=X&&(Mt=0,ut+=lt+xe,lt=0)}pt=Math.max(pt,bt)}const kt=Math.min(zt(A)+32,248),xt=Math.max(Dt(x,"top"),Dt(x,"bottom"));let Ft=Math.max(gt.left+Math.max(Tt,xt)+gt.right,kt,Ln),te=Math.max(pt+De+gt.bottom,ee+De+8+gt.bottom);const oe=new Map,Ae=At.get(f)??new Map,fe=k.get(f)??new Map;for(const V of["left","right"]){const st=x.filter(et=>wt(et)===V).sort((et,Mt)=>(Ae.get(et)??0)-(Ae.get(Mt)??0));let X=-1/0;for(const et of st){const Mt=Math.max((te-gt.bottom)/2,ee+cn),ut=ee+cn;let lt=Ae.get(et)??(st.length===1?Mt:ut);lt=Math.max(lt,ut,X+Ge);const bt=lt+(I(et)-1)*he;X=bt,oe.set(et,{x:V==="left"?-Nt/2:Ft-Nt/2,y:lt-Nt/2,side:V}),te=Math.max(te,bt+Ge/2+De+gt.bottom)}}for(const V of["top","bottom"]){const st=x.filter(lt=>wt(lt)===V).sort((lt,bt)=>(fe.get(lt)??0)-(fe.get(bt)??0));if(st.length===0)continue;const X=gt.left,Mt=Math.max(Ft-gt.right,X)-X;let ut=-1/0;for(const[lt,bt]of st.entries()){let Ot=X+(st.length===1?Mt/2:(lt+.5)/st.length*Mt);Ot=Math.max(Ot,X+Me/2,ut+Me),ut=Ot+(I(bt)-1)*he,oe.set(bt,{x:Ot-Nt/2,y:0,side:V}),Ft=Math.max(Ft,ut+Me/2+gt.right)}}for(const[,V]of oe)V.side==="right"&&(V.x=Ft-Nt/2),V.side==="top"&&(V.y=-Nt/2),V.side==="bottom"&&(V.y=te-Nt/2);const Vt={width:Ft,height:te,childPos:Pt,portPos:oe};return mt.set(f,Vt),Vt},R=h?[h]:c.roots.filter(f=>l(f));for(const f of R)await P(f);const J=new Map;if(R.length===1)J.set(R[0],{x:0,y:0});else{const f=N=>{let L=D(N);const G=new Set;for(;L&&_t.has(L)&&!G.has(L);)G.add(L),L=_t.get(L);return L&&R.includes(L)?L:R.includes(N)?N:L},d=new Set(R),x=[],A=(N,L)=>{var G;if(o.has(N)&&w.get(N)===L){const tt=p(N),ot=(G=mt.get(L))==null?void 0:G.portPos.get(tt);if(ot)return ot.y+Nt/2}return mt.get(L).height/2};Y.forEach((N,L)=>{const G=f(N.sourceId),tt=f(N.targetId);G&&tt&&G!==tt&&d.has(G)&&d.has(tt)&&x.push({id:`root-${L}`,source:G,target:tt,sourceAnchorY:A(N.sourceId,G),targetAnchorY:A(N.targetId,tt)})});const F=await Fn({id:"interconnection-roots",nodes:R.map(N=>({id:N,width:mt.get(N).width,height:mt.get(N).height})),edges:x,gapX:ln,gapY:ln,targetAspect:1.3,directedFlowAxis:"AUTO",preferBalancedLayout:!0,layoutProviderId:t==null?void 0:t.layoutProviderId});for(const N of F.children)J.set(N.id,{x:N.x,y:N.y});let O=0;for(const N of R)J.has(N)||(J.set(N,{x:O,y:0}),O+=mt.get(N).width+ln)}const rt=new Map;for(const[f,d]of u){const x=mt.get(f);if(!x)continue;const A=[];for(const F of d){const O=x.portPos.get(F);if(!O)continue;const N=o.get(F),L=M.get(F)??[];A.push({id:F,name:N.name,x:O.x,y:O.y,side:O.side,direction:Dn(N)??q(F),nestedCount:L.length||void 0,labelWidth:an(N.name,ye(N)),connectorType:ye(N)});const G=ve(O.side),tt=G?O.y+Nt/2:O.x+Nt/2,ot=(G?O.x:O.y)+(Nt-rn)/2;L.forEach((vt,Et)=>{const gt=o.get(vt),Pt=tt+he*(Et+1)-rn/2;A.push({id:vt,name:gt.name,x:G?ot:Pt,y:G?Pt:ot,side:O.side,direction:Dn(gt)??q(vt),size:rn,nested:!0,labelWidth:an(gt.name,ye(gt)),connectorType:ye(gt)})})}rt.set(f,A)}const at=[],St=new Map,Kt=(f,d,x,A={x:0,y:0},F,O=!1)=>{var Pt,Tt,pt;const N=c.elements.get(f),L=mt.get(f),G=(t==null?void 0:t.legend)&&((Pt=N.attributes[t.legend.attribute])==null?void 0:Pt.split("::").pop()),tt=G&&((Tt=t==null?void 0:t.legend)==null?void 0:Tt.colors.get(G))||Qt[N.layer]||"#64748B",ot=x??J.get(f),vt=d?{x:A.x+ot.x,y:A.y+ot.y}:ot;St.set(f,vt);const Et=(c.childrenMap.get(f)??[]).some(l),gt=Et;at.push({id:f,type:"interconnectionNode",position:ot,...d?{parentId:d,extent:O&&F?[[0,yn],[Math.max(0,F.width-L.width),Math.max(yn,F.height-L.height)]]:"parent"}:{},data:{label:N.name,kind:N.kind,layer:N.layer,color:tt,isContainer:gt,isFrame:!d&>,hasChildren:Et,isCollapsed:((pt=t==null?void 0:t.collapsedNodes)==null?void 0:pt.has(f))??!1,onToggleCollapse:Et&&(t!=null&&t.onToggleCollapse)?()=>t.onToggleCollapse(f):void 0,onDrillIn:Et&&d&&(t!=null&&t.onDrillIn)?()=>t.onDrillIn(f):void 0,ports:rt.get(f)??[],showPortText:(t==null?void 0:t.showPortText)!==!1,implicitIn:r&&ft.has(f),implicitOut:r&&ht.has(f),onPortMove:t!=null&&t.onPortMove?(kt,xt,Ft)=>t.onPortMove(f,kt,xt,Ft):void 0,onPortResize:t!=null&&t.onPortResize?(kt,xt,Ft)=>t.onPortResize(f,kt,xt,Ft):void 0,onPortSelect:t!=null&&t.onPortSelect?kt=>t.onPortSelect(kt):void 0,minWidth:L.width,minHeight:L.height},style:{width:L.width,height:L.height}});for(const[kt,xt]of L.childPos)Kt(kt,f,xt,vt,L,!d&>)};for(const f of R)Kt(f);const Xt=(f,d)=>{let x=f;const A=new Set;for(;x&&!A.has(x);){if(x===d)return!0;A.add(x),x=_t.get(x)}return!1},b=(f,d)=>{const x=w.get(f),A=D(d);return Xt(A,x)?`${f}${Ke}`:f},_=f=>o.has(f)?dn(f,a,m):void 0,j=(f,d,x)=>{var G;if(!r)return;const A=rt.get(f)??[];if(!A.length)return;const F=St.get(f),O=St.get(d),N=F&&O?Math.abs(O.x-F.x)>=Math.abs(O.y-F.y)?O.x>=F.x?"right":"left":O.y>=F.y?"bottom":"top":void 0,L=tt=>x==="source"?tt==="out"?0:tt==="inout"?1:4:tt==="in"?0:tt==="inout"?1:4;return(G=[...A].sort((tt,ot)=>L(tt.direction)-L(ot.direction)||+(tt.side!==N)-+(ot.side!==N)||tt.id.localeCompare(ot.id))[0])==null?void 0:G.id},W=Y.flatMap((f,d)=>{var fe;const x=o.has(f.sourceId)?w.get(f.sourceId):f.sourceId,A=o.has(f.targetId)?w.get(f.targetId):f.targetId;if(!mt.has(x)||!mt.has(A))return[];const F=_(f.sourceId)??j(x,A,"source"),O=_(f.targetId)??j(A,x,"target"),N=gs(f.flowItem,f.type),L=ls[N],G=Number(((fe=f.attributes)==null?void 0:fe.bundleCount)??0),tt=G>1?`${G} connections`:hs(f.flowItem,f.type),ot=F?b(F,f.targetId):"right",vt=O?b(O,f.sourceId):"left",Et=Vt=>Vt==="left"?"right":Vt==="right"?"left":Vt==="top"?"bottom":"top",gt=(Vt,V,st,X)=>{var Mt;if(!V)return X;const et=((Mt=(rt.get(Vt)??[]).find(ut=>ut.id===V))==null?void 0:Mt.side)??X;return st.endsWith(Ke)?Et(et):et},Pt=gt(x,F,ot,"right"),Tt=gt(A,O,vt,"left"),pt=f.id||`ic-e-${d}`,kt=(Vt,V,st,X)=>{const et=St.get(Vt),Mt=mt.get(Vt);if(V){const ut=(rt.get(Vt)??[]).find(lt=>lt.id===V);if(ut){const lt=ut.size??Nt,bt=(ut.nestedCount??0)*he/2,Ot=ve(ut.side),ct=et.x+ut.x+lt/2+(Ot?0:bt),Ct=et.y+ut.y+lt/2+(Ot?bt:0);return X==="left"?{x:ct-lt/2,y:Ct}:X==="right"?{x:ct+lt/2,y:Ct}:X==="top"?{x:ct,y:Ct-lt/2}:{x:ct,y:Ct+lt/2}}}return{x:et.x+(st?Mt.width:0),y:et.y+Mt.height/2}},xt=kt(x,F,!0,Pt),Ft=kt(A,O,!1,Tt),te=St.get(x),oe=St.get(A);return[{edge:{id:pt,source:x,target:A,sourceHandle:ot,targetHandle:vt,type:"interconnectionEdge",className:"ibd-interconnection-edge",zIndex:5,label:tt,animated:f.type==="flow",style:{stroke:L,strokeWidth:Math.max(2,it.defaultWidth)},labelStyle:{fontSize:dt.badge,fill:"#4B5563",fontWeight:600},labelBgPadding:it.labelBgPadding,labelBgBorderRadius:it.labelBgRadius,labelBgStyle:{...it.labelBgStyle,fillOpacity:.96,stroke:"#E2E8F0",strokeWidth:1},markerEnd:{type:"arrowclosed",color:L,width:it.arrowSize,height:it.arrowSize},data:{flowCategory:N,sourceOffset:{x:xt.x-te.x,y:xt.y-te.y},targetOffset:{x:Ft.x-oe.x,y:Ft.y-oe.y},sourcePortId:F,targetPortId:O,sourceSide:Pt,targetSide:Tt}},route:{id:pt,source:xt,target:Ft,sourceNodeId:x,targetNodeId:A,sourceSide:Pt,targetSide:Tt}}]}),z=at.filter(f=>!f.data.isFrame).map(f=>{const d=St.get(f.id),x=mt.get(f.id);return{id:f.id,x:d.x,y:d.y,width:x.width,height:x.height}}),Q=Ee(W.map(f=>f.route),z,28,"short-first"),$=Je(W.flatMap(({edge:f})=>{const d=Q.get(f.id);return f.label&&d&&d.length>=2?[{id:f.id,points:d,width:tn(String(f.label)),height:Qe}]:[]}),z),U=W.map(({edge:f})=>({...f,data:{...f.data,points:Q.get(f.id)??[],labelPoint:$.get(f.id),showLabel:(t==null?void 0:t.showConnectionText)!==!1}}));return{nodes:at,edges:U}}const re="control-in",ge="control-out",Wt={background:"transparent",border:"none",width:8,height:8};function Cs({onDrillIn:e,color:t,label:n}){return C.jsx("button",{onClick:s=>{s.stopPropagation(),e()},onDoubleClick:s=>s.stopPropagation(),className:"nodrag",title:`Open ${n} as its own diagram`,"aria-label":`Drill into ${n}`,style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${t}66`,borderRadius:4,background:"#FFFFFF",color:t,fontSize:10,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"↳"})}function Ts({data:e,selected:t}){const n=e,{nodeType:s,label:o,laneColor:i,layerColor:a,inPorts:r,outPorts:c}=n,[h,g]=yt.useState(!1);if(s==="start")return C.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"#374151",border:"2px solid #374151",boxShadow:en.sm},children:C.jsx(Ut,{id:ge,type:"source",position:n.flowDirection==="vertical"?It.Bottom:It.Right,style:Wt})});if(s==="done")return C.jsxs("div",{style:{width:28,height:28,borderRadius:"50%",background:"#FFFFFF",border:"3px solid #374151",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:en.sm},children:[C.jsx("div",{style:{width:14,height:14,borderRadius:"50%",background:"#374151"}}),C.jsx(Ut,{id:re,type:"target",position:n.flowDirection==="vertical"?It.Top:It.Left,style:Wt})]});if(s==="decision"||s==="merge"){const I=n.flowDirection==="vertical",S=I?{...Wt,left:"50%",top:0,right:"auto",bottom:"auto",transform:"translate(-50%, -50%)"}:{...Wt,left:0,top:32,right:"auto",bottom:"auto",transform:"translate(-50%, -50%)"},E=I?{...Wt,left:"50%",top:64,right:"auto",bottom:"auto",transform:"translate(-50%, -50%)"}:{...Wt,left:64,top:32,right:"auto",bottom:"auto",transform:"translate(-50%, -50%)"};return C.jsxs("div",{title:o||(s==="decision"?"Decision node":"Merge node"),style:{width:64,height:64,position:"relative",overflow:"visible"},children:[C.jsx("svg",{width:64,height:64,style:{position:"absolute",inset:0,overflow:"visible"},"aria-hidden":"true",children:C.jsx("polygon",{points:"32,2 62,32 32,62 2,32",fill:"#DDEFB8",stroke:"#374151",strokeWidth:"2.25"})}),C.jsx("span",{style:{position:"absolute",top:70,left:-34,width:132,display:"block",textAlign:"center",fontSize:13,fontWeight:600,lineHeight:1.2,color:"#374151",overflowWrap:"anywhere",pointerEvents:"none"},children:o}),C.jsx(Ut,{id:re,type:"target",position:I?It.Top:It.Left,style:S}),C.jsx(Ut,{id:ge,type:"source",position:I?It.Bottom:It.Right,style:E})]})}if(s==="activityFinal"||s==="flowFinal"){const p=s==="activityFinal";return C.jsxs("div",{title:o||(p?"Activity final / terminate":"Flow final"),style:{width:28,height:28,borderRadius:"50%",background:"#FFFFFF",border:"2px solid #374151",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",overflow:"visible"},children:[p?C.jsx("div",{style:{width:14,height:14,borderRadius:"50%",background:"#374151"}}):C.jsx("span",{style:{color:"#374151",fontSize:22,lineHeight:1},children:"×"}),o&&C.jsx("span",{style:{position:"absolute",top:33,left:-46,width:120,textAlign:"center",fontSize:12,fontWeight:600,lineHeight:1.2,color:"#374151",pointerEvents:"none",overflowWrap:"anywhere"},children:o}),C.jsx(Ut,{id:re,type:"target",position:n.flowDirection==="vertical"?It.Top:It.Left,style:Wt})]})}if(s==="fork"||s==="join"){const p=n.flowDirection==="vertical";return C.jsxs("div",{title:s==="fork"?"Fork — split into concurrent flows":"Join — synchronize concurrent flows",style:{width:"100%",height:"100%",background:"#374151",borderRadius:3,boxShadow:en.sm},children:[C.jsx(Ut,{id:re,type:"target",position:p?It.Top:It.Left,style:Wt}),C.jsx(Ut,{id:ge,type:"source",position:p?It.Bottom:It.Right,style:Wt})]})}const l=i||a||"#9CA3AF",y=s==="accept"?"«accept action»":s==="send"?"«send action»":void 0;if(n.isFrame)return C.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${l}08`,border:`1.5px solid ${l}66`,borderRadius:10,boxShadow:t?"0 0 0 3px #2DD4A8":"none",position:"relative"},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px 0"},children:[n.onToggleExpand&&C.jsx("button",{"aria-label":`Collapse ${o}`,className:"nodrag",onClick:p=>{p.stopPropagation(),n.onToggleExpand()},onDoubleClick:p=>p.stopPropagation(),style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${l}66`,borderRadius:4,background:"#FFFFFF",color:l,fontSize:11,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"−"}),n.onDrillIn&&C.jsx(Cs,{onDrillIn:n.onDrillIn,color:l,label:o}),C.jsx("span",{style:{fontSize:dt.md,fontWeight:700,color:l,whiteSpace:"nowrap"},children:o}),n.allocatedTo&&C.jsxs("span",{style:{fontSize:"9px",color:"#9CA3AF",whiteSpace:"nowrap"},children:["→"," ",n.allocatedTo]})]}),C.jsx(Ut,{id:re,type:"target",position:n.flowDirection==="vertical"?It.Top:It.Left,style:Wt}),C.jsx(Ut,{id:ge,type:"source",position:n.flowDirection==="vertical"?It.Bottom:It.Right,style:Wt})]});const w=18,m=Math.max(r.length*w,c.length*w,0);return C.jsxs("div",{onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),style:{background:"#FFFFFF",border:`1.5px solid ${l}`,borderRadius:3,minWidth:"140px",boxShadow:t?"0 0 0 3px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.35)":h?`0 0 0 2px ${l}22`:"none",transition:"box-shadow 150ms ease",overflow:"hidden"},children:[C.jsxs("div",{style:{padding:"8px 14px",fontSize:dt.md,fontWeight:600,color:"#1a1a1a",background:`${l}0D`,borderBottom:m>0?"1px solid #E5E5E0":"none",textAlign:"center",...n.flowDirection==="vertical"?{whiteSpace:"nowrap"}:{whiteSpace:"normal",overflowWrap:"anywhere",lineHeight:1.25}},children:[y&&C.jsx("div",{style:{fontSize:10,color:l,fontStyle:"italic",marginBottom:2},children:y}),o,n.hasChildren&&n.onDrillIn&&C.jsx("button",{"aria-label":`Drill into ${o}`,title:`Open ${o} as its own diagram`,className:"nodrag",onClick:p=>{p.stopPropagation(),n.onDrillIn()},onDoubleClick:p=>p.stopPropagation(),style:{float:"right",marginLeft:4,width:18,height:18,padding:0,border:`1px solid ${l}`,borderRadius:2,background:"#FFFFFF",color:l,fontSize:11,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:"↳"}),n.hasChildren&&n.onToggleExpand&&C.jsx("button",{"aria-label":n.isExpanded?`Collapse ${o}`:`Expand ${o}`,onClick:p=>{p.stopPropagation(),n.onToggleExpand()},style:{float:"right",marginLeft:8,width:18,height:18,padding:0,border:`1px solid ${l}`,borderRadius:2,background:"#FFFFFF",color:l,fontSize:13,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:n.isExpanded?"−":"+"})]}),m>0&&C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0"},children:[C.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:r.map(p=>C.jsxs("div",{style:{fontSize:dt.badge,color:"#6B7280",paddingLeft:"8px",display:"flex",alignItems:"center",height:`${w}px`,gap:"4px"},children:[C.jsx(Ut,{id:`in:${p}`,type:"target",position:n.flowDirection==="vertical"?It.Top:It.Left,style:Wt}),p]},`in-${p}`))}),C.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px",alignItems:"flex-end"},children:c.map(p=>C.jsxs("div",{style:{fontSize:dt.badge,color:"#6B7280",paddingRight:"8px",display:"flex",alignItems:"center",height:`${w}px`,gap:"4px"},children:[p,C.jsx(Ut,{id:`out:${p}`,type:"source",position:n.flowDirection==="vertical"?It.Bottom:It.Right,style:Wt})]},`out-${p}`))})]}),n.allocatedTo&&C.jsxs("div",{style:{fontSize:"9px",color:"#9CA3AF",textAlign:"center",padding:"2px 6px",borderTop:"1px solid #F3F4F6",background:"#FAFAFA"},children:["→"," ",n.allocatedTo]}),C.jsx(Ut,{id:re,type:"target",position:n.flowDirection==="vertical"?It.Top:It.Left,style:Wt}),C.jsx(Ut,{id:ge,type:"source",position:n.flowDirection==="vertical"?It.Bottom:It.Right,style:Wt})]})}const qi=yt.memo(Ts);function jn(e,t,n,s,o){const i=e*o+s;return i>=0?0:Math.max(0,Math.min(-i/o,t-n))}const Bn=40;function Fs({data:e,selected:t,positionAbsoluteX:n,positionAbsoluteY:s,width:o,height:i}){const a=e,r=a.orientation==="column",[c,h,g]=no(l=>l.transform);return C.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${a.color}08`,border:t?"3px solid #2DD4A8":`1px solid ${a.color}30`,borderLeft:t?"3px solid #2DD4A8":r?`1px solid ${a.color}30`:`3px solid ${a.color}`,borderTop:t?"3px solid #2DD4A8":r?`3px solid ${a.color}`:`1px solid ${a.color}30`,borderRadius:pe.md,pointerEvents:"auto",cursor:a.inspectElementId?"pointer":"default",display:"flex"},children:C.jsx("div",{style:{...r?{width:"100%",height:Os,borderBottom:`1px solid ${a.color}24`}:{width:Ns,height:"100%",borderRight:`1px solid ${a.color}24`},background:`${a.color}0F`,borderRadius:r?`${pe.md}px ${pe.md}px 0 0`:`${pe.md}px 0 0 ${pe.md}px`,flexShrink:0}})})}const Ji=yt.memo(Fs),Os=30,Ns=34;function _s({data:e,positionAbsoluteX:t,positionAbsoluteY:n,width:s,height:o}){const i=e,a=i.orientation==="column",[r,c,h]=no(l=>l.transform),g=a?jn(n,o??0,Bn,c,h):jn(t,s??0,Bn,r,h);return C.jsx("div",{style:{width:"100%",height:"100%",display:"flex",pointerEvents:"none",alignItems:a?"flex-start":"center",justifyContent:a?"center":"flex-start"},children:C.jsx("div",{style:{writingMode:a?"horizontal-tb":"vertical-rl",transform:a?void 0:"rotate(180deg)",padding:a?"6px 12px":"12px 6px",fontSize:dt.xs,fontWeight:700,color:i.color,letterSpacing:"0.04em",textTransform:"uppercase",whiteSpace:"nowrap",background:g>0?"#FFFFFFEE":"transparent",borderRadius:4,...a?{marginTop:g}:{marginLeft:g}},children:i.label})})}const Qi=yt.memo(_s);function tr(e,t){const n=t.registries,s=new Set(e.filter(i=>!ne(i,n)).map(i=>i.id)),o=new Set;for(const i of t.relationships)i.type!=="flow"&&i.type!=="succession"||(s.has(i.sourceId)&&o.add(i.sourceId),s.has(i.targetId)&&o.add(i.targetId));return e.filter(i=>!ne(i,n)&&!o.has(i.id))}function mo(e,t,n=new Set,s){const o=Object.values(e.elements),a=(t?o.filter(t):o).filter(l=>ae(l,e.registries)!==void 0),r=a.filter(l=>l.parentAction);if(r.length===0)return a;const c=new Map(a.map(l=>[l.id,l])),h=[],g=l=>{const y=a.filter(w=>w.parentAction===l.id);if(n.has(l.id)&&y.length>0){for(const w of y)g(w);return}h.push(l)};if(s){for(const l of a.filter(y=>y.parentAction===s))g(l);return h}for(const l of r){const y=l.parentAction?c.get(l.parentAction):void 0;y!=null&&y.parentAction||g(l)}return h}function Ds(e,t,n=new Set,s){if(n.size===0)return new Map;const o=new Set(mo(e,t,n,s).map(g=>g.id)),i=Object.values(e.elements),a=t?i.filter(t):i,r=new Map;for(const g of a)g.parentAction&&(r.has(g.parentAction)||r.set(g.parentAction,[]),r.get(g.parentAction).push(g));const c=new Map,h=(g,l)=>{const y=[];for(const w of r.get(g)??[])l.has(w.id)||(l.add(w.id),o.has(w.id)?y.push(w.id):y.push(...h(w.id,l)));return y};for(const g of n){if(o.has(g))continue;const l=h(g,new Set([g]));l.length>0&&c.set(g,l)}return c}function Ps(e,t,n=new Set,s){const o=Object.values(e.elements),a=(t?o.filter(t):o).filter(m=>ae(m,e.registries)!==void 0),r=[],c=new Map,h=new Map,g=m=>a.filter(p=>p.parentAction===m),l=(m,p)=>{r.push(m),p&&(c.set(m.id,p),h.has(p)||h.set(p,[]),h.get(p).push(m.id));const u=g(m.id);if(!(u.length===0||!n.has(m.id))){h.set(m.id,[]);for(const M of u)l(M,m.id)}};if(s){for(const m of g(s))l(m);return{actions:r,parentOf:c,childrenOf:h}}const y=new Map(a.map(m=>[m.id,m])),w=a.filter(m=>m.parentAction);if(w.length===0)return{actions:a,parentOf:c,childrenOf:h};for(const m of w){const p=m.parentAction?y.get(m.parentAction):void 0;p!=null&&p.parentAction||l(m)}return{actions:r,parentOf:c,childrenOf:h}}function Ls(e,t){const n=e.attributes.actionType,s=n?t.elements[n]:void 0,o=((s==null?void 0:s.construct)==="action"?s.parameters:e.parameters)??[];return{inPorts:o.filter(i=>i.direction==="in"||i.direction==="inout").map(i=>i.name),outPorts:o.filter(i=>i.direction==="out"||i.direction==="inout").map(i=>i.name)}}const $n=["#4A90D9","#E67E22","#2ECC71","#9B59B6","#E74C3C","#1ABC9C","#F39C12","#7B68EE"],hn="Unallocated",Rs="Unstaged";function Mn(e,t,n="all"){const s=new Map;for(const c of t.relationships)ke.has(c.type)&&!s.has(c.targetId)&&s.set(c.targetId,c.sourceId);const o=[e],i=new Set(o);let a=e;for(;s.has(a);){const c=s.get(a);if(i.has(c))break;o.unshift(c),i.add(c),a=c}if(n==="all")return{id:e,level:o.length};const r=Math.min(Math.max(n,1),o.length)-1;return{id:o[r],level:r+1}}function js(e,t,n="all"){var o;const s=Mn(e,t,n).id;return((o=t.elements[s])==null?void 0:o.name)??s}function er(e,t){const n=[...new Set(e)].map(o=>Mn(o,t).level);if(n.length===0)return[];const s=Math.min(...n);return s<=1?[]:Array.from({length:s},(o,i)=>i+1)}function Bs(e,t,n="allocation",s="all"){var r,c;const o=new Map,i=[],a=new Map;for(const h of e){if(ne(h,t.registries))continue;const g=h.allocatedTo?Mn(h.allocatedTo,t,s).id:hn,l=n==="stage"?h.attributes.stage||h.attributes.phase||Rs:g;if(o.set(h.id,l),!a.has(l)){const y={id:l,label:n==="allocation"&&l!==hn?((r=t.elements[l])==null?void 0:r.name)??l:l,color:$n[a.size%$n.length],inspectElementId:n==="allocation"&&l!==hn?l:((c=Object.values(t.elements).find(w=>w.id===l||w.name===l))==null?void 0:c.id)??h.id};a.set(l,y),i.push(y)}}return{laneOf:o,lanes:i}}const $s=18,xn=36,Hs=20,ie=36,Hn=16,Pe=120,gn=18,Wn=40,Le=32,zn=64,Gn=10,de=28;function Yn(e,t,n,s){return{id:`__lane_label_${e.id}`,type:"actionFlowLaneLabel",position:n,data:{label:e.label,color:e.color,orientation:t,isFrame:!0},style:{...s,pointerEvents:"none"},draggable:!1,selectable:!1,zIndex:5}}const po=140,yo=240,xo=9,Ws=20,wo=36;function wn(e){return Math.max(e.name.length*xo+wo,po)}function zs(e,t,n,s){const o=e.filter(i=>{const a=ae(i,s);return a!=="decision"&&a!=="merge"&&a!=="fork"&&a!=="join"&&a!=="activityFinal"&&a!=="flowFinal"});return o.length===0?po:n==="horizontal"?Math.min(yo,Math.max(...o.map(wn))):Math.max(...o.map(i=>bo(t.get(i.id),i)+xn))}function bo(e,t){const s=Math.max((e==null?void 0:e.inPorts.length)??0,(e==null?void 0:e.outPorts.length)??0,0)*$s;return s+(s>0?8:0)+(t.allocatedTo?Hs:0)}function Gs(e,t,n,s,o){const i=ae(e,s);if(i==="decision"||i==="merge")return{width:64,height:64};if(i==="activityFinal"||i==="flowFinal")return{width:28,height:28};if(i==="fork"||i==="join")return n==="vertical"?{width:zn,height:Gn}:{width:Gn,height:zn};const a=bo(t,e);if(n==="vertical")return{width:wn(e),height:o??xn+a};const r=o??Math.min(yo,wn(e)),c=Math.max(1,Math.ceil(e.name.length*xo/Math.max(1,r-wo)));return{width:r,height:xn+(c-1)*Ws+a}}function Xn(e){const t=e??"";return/energy|power|voltage|current|thermal|heat/i.test(t)?"energy":/material|fluid|gas|liquid|batch|consumable/i.test(t)?"material":"data"}const un={control:"#4B5563",data:"#3498DB",energy:"#D97706",material:"#16A34A"};function Ys(e,t){const n=new Map,s=new Map;for(const r of t)s.set(r,0);for(const r of e)!t.has(r.sourceId)||!t.has(r.targetId)||(n.has(r.sourceId)||n.set(r.sourceId,[]),n.get(r.sourceId).push(r),s.set(r.targetId,(s.get(r.targetId)??0)+1));const o=new Set,i=new Map,a=r=>{i.set(r,1);for(const c of n.get(r)??[]){const h=i.get(c.targetId)??0;h===1?o.add(c.id):h===0&&a(c.targetId)}i.set(r,2)};for(const r of t)(s.get(r)??0)===0&&!i.has(r)&&a(r);for(const r of t)i.has(r)||a(r);return o}async function nr(e,t){var rt,at,St,Kt,Xt;const n=(t==null?void 0:t.nesting)??"flat",s=n==="nested"?Ps(e,t==null?void 0:t.viewpointFilter,t==null?void 0:t.expandedActionIds,t==null?void 0:t.focusActionId):{actions:mo(e,t==null?void 0:t.viewpointFilter,t==null?void 0:t.expandedActionIds,t==null?void 0:t.focusActionId),childrenOf:new Map},o=s.actions;if(o.length===0)return{nodes:[],edges:[]};const i=new Set(o.map(b=>b.id)),{laneOf:a,lanes:r}=Bs(o,e,t==null?void 0:t.laneGrouping,t==null?void 0:t.displayLevel),c=(t==null?void 0:t.direction)??"horizontal",h=n!=="nested"&&((t==null?void 0:t.swimlanes)??!0)&&r.length>=1,g=e.relationships.filter(b=>b.type==="succession"),l=e.relationships.filter(b=>b.type==="flow"),y=new Map;for(const b of n==="nested"?[]:(t==null?void 0:t.expandedActionIds)??[]){const _=Object.values(e.elements).filter(z=>z.parentAction===b);if(_.length===0)continue;const j=((rt=g.find(z=>z.sourceId===`${b}__start`))==null?void 0:rt.targetId)??_[0].id,W=((at=g.find(z=>z.targetId===`${b}__done`))==null?void 0:at.sourceId)??_[_.length-1].id;y.set(b,{first:j,last:W})}const w=b=>b.map(_=>{var j,W;return{..._,sourceId:((j=y.get(_.sourceId))==null?void 0:j.last)??_.sourceId,targetId:((W=y.get(_.targetId))==null?void 0:W.first)??_.targetId}}),m=w(g),p=w(l),u=new Set;for(const b of m){const _=b.sourceId.endsWith("__start")?b.sourceId.slice(0,-7):void 0,j=b.targetId.endsWith("__done")?b.targetId.slice(0,-6):void 0;_&&!y.has(_)&&i.has(b.targetId)&&u.add(b.sourceId),j&&!y.has(j)&&i.has(b.sourceId)&&u.add(b.targetId)}const M=new Set([...i,...u]),I=p.filter(b=>M.has(b.sourceId)&&M.has(b.targetId)&&(!(t!=null&&t.visibleFlowKinds)||t.visibleFlowKinds.has(Xn(b.flowItem)))),S=new Set(I.map(b=>`${b.sourceId}\0${b.targetId}`)),E=m.filter(b=>M.has(b.sourceId)&&M.has(b.targetId)&&(!(t!=null&&t.visibleFlowKinds)||t.visibleFlowKinds.has("control"))&&!S.has(`${b.sourceId}\0${b.targetId}`)),v=Ys(E,M),D=E.filter(b=>!v.has(b.id)),K=new Map(o.map(b=>[b.id,Ls(b,e)])),Z=new Map(o.map(b=>[b.id,b])),H=new Map,B=new Map;if(n==="nested"){for(const[b,_]of s.childrenOf)H.set(b,_.filter(j=>M.has(j)));for(const b of u){const _=b.endsWith("__start")?b.slice(0,-7):b.slice(0,-6);H.has(_)&&H.get(_).push(b)}for(const[b,_]of H)for(const j of _)B.set(j,b)}const Y=zs(o,K,c,e.registries),nt=b=>{const _=Z.get(b);return _?Gs(_,K.get(b),c,e.registries,Y):{width:de,height:de}},ht=b=>{const _=H.get(b)??[];return _.length===0?{id:b,...nt(b)}:{id:b,layoutOptions:{"elk.algorithm":"layered","elk.direction":c==="vertical"?"DOWN":"RIGHT","elk.padding":"[top=44,left=24,bottom=24,right=24]","elk.spacing.nodeNode":"36","elk.layered.spacing.nodeNodeBetweenLayers":"68","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"},children:_.map(ht)}},ft=[...u,...o.map(b=>b.id)].filter(b=>!B.has(b)),_t={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":c==="vertical"?"DOWN":"RIGHT","elk.spacing.nodeNode":"40","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.separateConnectedComponents":"true","elk.spacing.componentComponent":"56",...n==="nested"?{"elk.hierarchyHandling":"INCLUDE_CHILDREN"}:{}},children:ft.map(ht),edges:[...I,...D].map((b,_)=>({id:`afe-${_}`,sources:[b.sourceId],targets:[b.targetId]}))},Bt=await ue.layout(_t,{providerId:t==null?void 0:t.layoutProviderId}),q=new Map,Lt=b=>{q.set(b.id,{x:b.x??0,y:b.y??0,width:b.width??140,height:b.height??56});for(const _ of b.children??[])Lt(_)};for(const b of Bt.children??[])Lt(b);const $t=new Map(r.map(b=>[b.id,b.color])),wt=[],jt=new Map,Dt=[...u].some(b=>b.endsWith("__start")),zt=[...u].some(b=>b.endsWith("__done")),Yt=Dt?de+24:0,mt=zt?de+24:0;if(h&&c==="horizontal"){const b=new Map;for(const Q of o){if(ne(Q,e.registries))continue;const $=q.get(Q.id),U=a.get(Q.id);b.has(U)||b.set(U,[]),b.get(U).push($.y)}const _=[...r].sort((Q,$)=>{const U=T=>T.reduce((f,d)=>f+d,0)/T.length;return U(b.get(Q.id)??[0])-U(b.get($.id)??[0])});let j=1/0,W=-1/0;for(const Q of o){const $=q.get(Q.id);j=Math.min(j,$.x),W=Math.max(W,$.x+$.width)}let z=0;for(const Q of _){const $=o.filter(d=>a.get(d.id)===Q.id);$.sort((d,x)=>q.get(d.id).x-q.get(x.id).x||q.get(d.id).y-q.get(x.id).y);const U=Math.min(...$.map(d=>q.get(d.id).y));let T=0;const f=[];for(const d of $){const x=q.get(d.id);let A=z+ie+(x.y-U);for(const F of f)x.x<F.x1&&x.x+x.width>F.x0&&(A=Math.max(A,F.bottom+16));q.set(d.id,{...x,y:A}),f.push({x0:x.x,x1:x.x+x.width,bottom:A+x.height}),T=Math.max(T,A+x.height-z)}T+=ie,wt.push({id:`__lane_${Q.id}`,type:"actionFlowLane",position:{x:j-Pe,y:z},data:{label:Q.label,color:Q.color,orientation:"row",inspectElementId:Q.inspectElementId,memberIds:$.map(d=>d.id),isFrame:!0},style:{width:W-j+Pe+ie,height:T},draggable:!1,selectable:!1,zIndex:-1}),wt.push(Yn(Q,"row",{x:j-Pe,y:z},{width:W-j+Pe+ie,height:T})),z+=T+Hn}}else if(h){let b=1/0,_=-1/0;for(const W of o){const z=q.get(W.id);b=Math.min(b,z.y),_=Math.max(_,z.y+z.height)}let j=0;for(const W of r){const z=o.filter(U=>a.get(U.id)===W.id).sort((U,T)=>q.get(U.id).y-q.get(T.id).y||q.get(U.id).x-q.get(T.id).x),$=Math.max(...z.map(U=>q.get(U.id).width))+ie*2;jt.set(W.id,{left:j,width:$});for(const U of z){const T=q.get(U.id);q.set(U.id,{...T,x:j+($-T.width)/2})}wt.push({id:`__lane_${W.id}`,type:"actionFlowLane",position:{x:j,y:b-Le-Yt},data:{label:W.label,color:W.color,orientation:"column",inspectElementId:W.inspectElementId,memberIds:z.map(U=>U.id),isFrame:!0},style:{width:$,height:_-b+Le+ie+Yt+mt},draggable:!1,selectable:!1,zIndex:-1}),wt.push(Yn(W,"column",{x:j,y:b-Le-Yt},{width:$,height:_-b+Le+ie+Yt+mt})),j+=$+Hn}}const At=n==="nested"?[]:o.filter(b=>{const _=ae(b,e.registries);return _==="decision"||_==="merge"||_==="fork"||_==="join"});if(At.length>0)for(const b of At){const _=q.get(b.id),j=ae(b,e.registries),W=[];for(const Q of[...E,...I]){const $=j==="decision"||j==="fork"?Q.targetId===b.id?Q.sourceId:void 0:Q.sourceId===b.id?Q.targetId:void 0;if($===void 0)continue;const U=q.get($);U&&W.push(c==="vertical"?U.x+U.width/2:U.y+U.height/2)}if(W.length===0)continue;const z=W.reduce((Q,$)=>Q+$,0)/W.length;q.set(b.id,c==="vertical"?{..._,x:z-_.width/2}:{..._,y:z-_.height/2})}if(c==="vertical"&&h&&jt.size>0){const b=[...E,...I],_=new Map(o.map(j=>[j.id,j]));for(const j of o.filter(W=>ne(W,e.registries))){const W=new Set,z=[j.id],Q=new Set;for(;z.length>0&&W.size<=1;){const x=z.pop();if(!Q.has(x)){Q.add(x);for(const A of b){const F=A.sourceId===x?A.targetId:A.targetId===x?A.sourceId:void 0;if(!F||Q.has(F))continue;const O=_.get(F);if(O)if(ne(O,e.registries))z.push(F);else{const N=a.get(F);N&&W.add(N)}}}}if(W.size!==1)continue;const $=jt.get([...W][0]),U=q.get(j.id);if(!$||!U)continue;const T=12,f=$.left+T,d=$.left+$.width-U.width-T;q.set(j.id,{...U,x:Math.max(f,Math.min(U.x,d))})}}for(const b of n==="nested"?[]:u){const _=q.get(b);if(!_)continue;const j=[];for(const $ of E){const U=$.sourceId===b?$.targetId:$.targetId===b?$.sourceId:void 0;if(!U)continue;const T=q.get(U);T&&j.push(c==="vertical"?T.x+T.width/2:T.y+T.height/2)}if(j.length===0)continue;const W=j.reduce(($,U)=>$+U,0)/j.length,z=o.filter($=>!ne($,e.registries)).map($=>q.get($.id)).filter($=>!!$),Q=b.endsWith("__start");if(c==="vertical"){const $=Math.min(...z.map(T=>T.y)),U=Math.max(...z.map(T=>T.y+T.height));q.set(b,{..._,x:W-_.width/2,y:Q?$-_.height-16:U+16})}else{const $=Math.min(...z.map(T=>T.x)),U=Math.max(...z.map(T=>T.x+T.width));q.set(b,{..._,x:Q?$-_.width-24:U+24,y:W-_.height/2})}}const k=[];if(n!=="nested"){const b=Ds(e,t==null?void 0:t.viewpointFilter,t==null?void 0:t.expandedActionIds,t==null?void 0:t.focusActionId);for(const[_,j]of b){const W=e.elements[_],z=j.map(d=>q.get(d)).filter(d=>!!d);if(!W||z.length===0)continue;const Q=Math.min(...z.map(d=>d.x)),$=Math.min(...z.map(d=>d.y)),U=Math.max(...z.map(d=>d.x+d.width)),T=Math.max(...z.map(d=>d.y+d.height)),f={element:W,label:W.name,nodeType:"action",laneColor:"#9CA3AF",layerColor:Qt[W.layer]||"#FF6B6B",inPorts:[],outPorts:[],hasChildren:!0,isExpanded:!0,isFrame:!0,onToggleExpand:t!=null&&t.onToggleAction?()=>t.onToggleAction(_):void 0,onDrillIn:t!=null&&t.onDrillInAction?()=>t.onDrillInAction(_):void 0,flowDirection:c};k.push({id:`__group_${_}`,type:"actionFlowNode",position:{x:Q-gn,y:$-Wn},style:{width:U-Q+gn*2,height:T-$+Wn+gn},draggable:!1,selectable:!1,data:f})}}const P=[...wt,...k],R=b=>{const _=B.get(b);return _?{parentId:_,extent:"parent"}:{}};for(const b of u){const _=q.get(b),j=b.endsWith("__start"),W={label:j?"Start":"Done",nodeType:j?"start":"done",laneColor:"#374151",layerColor:"#374151",inPorts:[],outPorts:[],flowDirection:c};P.push({id:b,type:"actionFlowNode",position:{x:_.x,y:_.y},style:{width:de,height:de},...R(b),data:W})}for(const b of o){const _=q.get(b.id),j=ae(b,e.registries);if(ne(b,e.registries)){const T={element:b,label:b.name,nodeType:j,laneColor:"#374151",layerColor:"#374151",inPorts:[],outPorts:[],flowDirection:c};P.push({id:b.id,type:"actionFlowNode",position:{x:_.x,y:_.y},style:{width:_.width,height:_.height},...R(b.id),data:T});continue}const W=K.get(b.id),z=a.get(b.id),Q=b.allocatedTo?js(b.allocatedTo,e,t==null?void 0:t.displayLevel):void 0,$=(((St=H.get(b.id))==null?void 0:St.length)??0)>0,U={element:b,label:b.name,nodeType:j??"action",parameters:b.parameters,allocatedTo:Q,laneColor:$t.get(z)??"#9CA3AF",layerColor:Qt[b.layer]||"#FF6B6B",inPorts:W.inPorts,outPorts:W.outPorts,hasChildren:Object.values(e.elements).some(T=>T.parentAction===b.id),isExpanded:((Kt=t==null?void 0:t.expandedActionIds)==null?void 0:Kt.has(b.id))??!1,isFrame:$,onToggleExpand:t!=null&&t.onToggleAction?()=>t.onToggleAction(b.id):void 0,onDrillIn:t!=null&&t.onDrillInAction?()=>t.onDrillInAction(b.id):void 0,flowDirection:c};P.push({id:b.id,type:"actionFlowNode",position:{x:_.x,y:_.y},style:{width:_.width,height:_.height},...R(b.id),data:U})}if(B.size>0){const b=new Map(P.map(z=>[z.id,z])),_=[],j=new Set,W=z=>{if(j.has(z.id))return;j.add(z.id);const Q=z.parentId?b.get(z.parentId):void 0;Q&&W(Q),_.push(z)};for(const z of P)W(z);P.length=0,P.push(..._)}const J=[];for(const b of I){const _=Xn(b.flowItem),j=un[_],W=b.flowItem?/signal|error|status|code|report|alarm|response|command|data|reading/i.test(b.flowItem):!1;J.push({id:b.id,source:b.sourceId,target:b.targetId,...b.sourceEnd?{sourceHandle:`out:${b.sourceEnd}`}:{},...b.targetEnd?{targetHandle:`in:${b.targetEnd}`}:{},label:void 0,type:"smoothstep",animated:!1,style:{stroke:j,strokeWidth:it.flowWidth,strokeDasharray:W?"6 3":void 0},labelStyle:{fontSize:dt.badge,fill:j,fontWeight:600},labelBgStyle:it.labelBgStyle,labelBgPadding:it.labelBgPadding,labelBgBorderRadius:it.labelBgRadius,markerEnd:{type:"arrowclosed",color:j,width:it.arrowSize,height:it.arrowSize},zIndex:2,data:{flowCategory:_,flowItem:b.flowItem}})}for(const b of E){const _=v.has(b.id);J.push({id:b.id,source:b.sourceId,target:b.targetId,sourceHandle:ge,targetHandle:re,type:c==="vertical"&&!_?"straight":"smoothstep",animated:!1,style:{stroke:un.control,strokeWidth:1.5},markerEnd:{type:"arrowclosed",color:un.control,width:12,height:12},zIndex:2,label:(Xt=b.sourceEnd)!=null&&Xt.startsWith("[")?b.sourceEnd:void 0,data:{flowCategory:"control"}})}return{nodes:P,edges:J}}function Xs(e){return e.attributes.sourceState&&e.attributes.targetState?!0:e.kind==="Transition"||e.kind.endsWith("Transition")}function Us(e){return e.kind.endsWith("State")||e.kind.endsWith("Machine")||e.kind.endsWith("Mode")}function Ks(e,t){const n=Object.values(e.elements),s=t?n.filter(t):n,o=[],i=[],a=[];for(const r of s)Xs(r)?i.push(r):Us(r)?o.push(r):a.push(r);return{states:o,transitions:i,annotations:a}}const Un=46;function Vs(e){return e.length>Un?`${e.slice(0,Un-1)}…`:e}function Zs(e){const t=e.attributes.trigger??"",n=e.attributes.guardSummary??e.attributes.guard??"",s=n&&!/^none\b/i.test(n),o=t||e.name;return Vs(s?`${o} [${n}]`:o)}function qs(e,t){const n=new Map;for(const o of t)n.set(o.name,o.id),n.set(o.id,o.id);const s=[];for(const o of e){const i=n.get(o.attributes.sourceState??""),a=n.get(o.attributes.targetState??"");!i||!a||s.push({element:o,sourceId:i,targetId:a,label:Zs(o)})}return s}function Js(e,t={}){const n=t.collapsedStateIds??new Set,s=t.focusStateId&&e.elements.has(t.focusStateId)?t.focusStateId:void 0,o=y=>(e.childrenMap.get(y)??[]).filter(w=>e.elements.has(w)),i=s?o(s):[],a=i.length>0?i:e.roots.filter(y=>e.elements.has(y)),r=new Set,c=new Map,h=new Map,g=(y,w)=>{c.set(y,w),h.set(w,(h.get(w)??0)+1);for(const m of o(y))g(m,w)},l=y=>{r.add(y);const w=o(y);if(n.has(y)){for(const m of w)g(m,y);return}for(const m of w)l(m)};for(const y of a)l(y);return{visible:r,liftTo:c,hiddenCount:h,roots:a}}function Qs(e,t){const n=o=>t.visible.has(o)?o:t.liftTo.get(o),s=[];for(const o of e){const i=n(o.sourceId),a=n(o.targetId);if(!i||!a)continue;const r=o.sourceId===o.targetId;i===a&&!r||s.push({...o,sourceId:i,targetId:a})}return s}const ti="#FF6B6B",ei="#95A5A6",Kn="#64748B";async function or(e,t){const{states:n,transitions:s,annotations:o}=Ks(e,t==null?void 0:t.viewpointFilter);if(n.length===0&&o.length===0)return{nodes:[],edges:[]};const i=qe(n,e.relationships),a=Js(i,{focusStateId:t==null?void 0:t.focusStateId,collapsedStateIds:t==null?void 0:t.collapsedStateIds}),r=Qs(qs(s,n),a);if(a.visible.size===0&&o.length===0)return{nodes:[],edges:[]};const c=I=>({width:Math.max(I.name.length*7.5+56,150),height:(i.childrenMap.get(I.id)??[]).some(S=>i.elements.has(S))?74:54}),h=I=>{const S=i.elements.get(I),E=(i.childrenMap.get(I)??[]).filter(v=>a.visible.has(v));return E.length===0?{id:I,...c(S)}:{id:I,layoutOptions:{"elk.algorithm":"layered","elk.direction":"DOWN","elk.padding":"[top=48,left=28,bottom=28,right=28]","elk.spacing.nodeNode":"72","elk.layered.spacing.nodeNodeBetweenLayers":"120","elk.spacing.edgeNode":"32","elk.edgeRouting":"ORTHOGONAL","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"},children:E.map(h)}},g={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"DOWN","elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.edgeRouting":"ORTHOGONAL","elk.spacing.nodeNode":"72","elk.layered.spacing.nodeNodeBetweenLayers":"120","elk.spacing.edgeNode":"32","elk.spacing.edgeLabel":"8","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.separateConnectedComponents":"true","elk.spacing.componentComponent":"64","elk.padding":"[top=20, left=20, bottom=20, right=20]"},children:a.roots.map(h),edges:r.map((I,S)=>({id:`st-${S}`,sources:[I.sourceId],targets:[I.targetId]}))},l=await ue.layout(g,{providerId:t==null?void 0:t.layoutProviderId}),y=[],w=new Map,m=(I,S,E={x:0,y:0})=>{var D,K;const v=i.elements.get(I.id);if(v){const Z=!!((D=I.children)!=null&&D.length),H=v.kind.endsWith("Machine"),B={x:E.x+(I.x??0),y:E.y+(I.y??0)};w.set(I.id,{...B,width:I.width??150,height:I.height??54,isContainer:Z}),y.push({id:I.id,type:"stateNode",position:{x:I.x??0,y:I.y??0},...S?{parentId:S,extent:"parent"}:{},data:{label:v.name,kind:v.kind,color:ti,isContainer:Z,isMachine:H,subtitle:v.attributes.modeKind,hasChildren:(i.childrenMap.get(I.id)??[]).some(Y=>i.elements.has(Y)),isCollapsed:!!((K=t==null?void 0:t.collapsedStateIds)!=null&&K.has(I.id)),hiddenCount:a.hiddenCount.get(I.id)??0,onToggleCollapse:t!=null&&t.onToggleCollapse?()=>t.onToggleCollapse(I.id):void 0,onDrillIn:t!=null&&t.onDrillIn?()=>t.onDrillIn(I.id):void 0},style:{width:I.width??150,height:I.height??54}});for(const Y of I.children??[])m(Y,I.id,B);return}};for(const I of l.children??[])m(I);if(o.length>0){let I=0,S=800;for(const Z of l.children??[])I=Math.max(I,(Z.y??0)+(Z.height??0)),S=Math.max(S,(Z.x??0)+(Z.width??0));const E=240,v=48,D=14,K=Math.max(2,Math.floor(S/(E+D)));o.forEach((Z,H)=>{y.push({id:Z.id,type:"stateNode",position:{x:H%K*(E+D),y:I+56+Math.floor(H/K)*(v+D)},data:{label:Z.name,kind:Z.kind,color:ei,isNote:!0},style:{width:E,height:v}})})}const p=[...w.entries()].filter(([,I])=>!I.isContainer).map(([I,S])=>({id:I,x:S.x,y:S.y,width:S.width,height:S.height})),u=qo({connectors:r.map((I,S)=>({id:I.element.id||`st-e-${S}`,sourceId:I.sourceId,targetId:I.targetId,label:I.label})),rects:w,obstacles:p,channelGap:26}),M=r.map((I,S)=>{const E=I.element.id||`st-e-${S}`,v=u.get(E),D={id:E,source:I.sourceId,target:I.targetId,label:I.label,style:{stroke:Kn,strokeWidth:it.defaultWidth},markerEnd:{type:"arrowclosed",color:Kn,width:it.arrowSize,height:it.arrowSize}};return v?{...D,type:"interconnectionEdge",data:{points:v.points,labelPoint:v.labelPoint}}:{...D,type:"smoothstep",labelStyle:{fontSize:dt.badge,fill:"#6B7280",fontWeight:500},labelBgPadding:it.labelBgPadding,labelBgBorderRadius:it.labelBgRadius,labelBgStyle:it.labelBgStyle}});return{nodes:y,edges:M}}const ni=/(?:Actor|User)$/,oi=new Set(["UseCase"]),Io=new Set(["initiates","participatesin","performs","interactswith","includes","extends"]),Zt=e=>e.toLowerCase();function Mo(e){return ni.test(e.kind)||e.construct==="actor"}function Sn(e){return oi.has(e.kind)||e.construct==="use case"}function sr(e){const t=new Set(Object.values(e.elements).filter(Sn).map(o=>o.id)),n=new Map;for(const o of e.relationships.filter(i=>Zt(i.type)==="includes"&&t.has(i.sourceId)&&t.has(i.targetId)))n.set(o.targetId,[...n.get(o.targetId)??[],o.sourceId]);const s=(o,i=new Set)=>{if(i.has(o))return 0;const a=n.get(o)??[];return a.length===0?0:1+Math.min(...a.map(r=>s(r,new Set([...i,o]))))};return Math.max(0,...[...t].map(o=>s(o)))}function ir(e){const t=Object.values(e.elements),n=new Set(t.filter(Sn).map(o=>o.id)),s=new Set(e.relationships.filter(o=>Io.has(Zt(o.type))).flatMap(o=>n.has(o.sourceId)?[o.targetId]:n.has(o.targetId)?[o.sourceId]:[]));return t.filter(Mo).filter(o=>s.has(o.id)).map(o=>({id:o.id,name:o.name})).sort((o,i)=>o.name.localeCompare(i.name))}function rr(e){var o,i;const t=`${(e==null?void 0:e.layoutHint)??""};${(e==null?void 0:e.styleHint)??""}`,n=/(?:usecase:)?level\s*=\s*(all|\d+)/i.exec(t),s=/(?:edge|routing)\s*=\s*(straight|orthogonal|elbow|rounded|curved|arc)/i.exec(t);return{level:(n==null?void 0:n[1])==="all"?"all":n?Number(n[1]):"all",edgeStyle:{orthogonal:"elbow"}[((o=s==null?void 0:s[1])==null?void 0:o.toLowerCase())??""]??((i=s==null?void 0:s[1])==null?void 0:i.toLowerCase())??"straight"}}function ar(e,t={}){const n=Object.values(e.elements).filter(d=>!t.viewpointFilter||t.viewpointFilter(d)),s=n.filter(Sn),o=e.relationships.filter(d=>Io.has(Zt(d.type))),i=new Map;for(const d of o.filter(x=>Zt(x.type)==="includes")){const x=i.get(d.targetId)??[];x.push(d.sourceId),i.set(d.targetId,x)}const a=(d,x=new Set)=>{if(x.has(d))return 0;const A=i.get(d)??[];return A.length===0?0:1+Math.min(...A.map(F=>a(F,new Set([...x,d]))))},r=t.level??"all",c=new Set(s.filter(d=>r==="all"||a(d.id)<=r).map(d=>d.id));let h=!0;for(;h;){h=!1;for(const d of o.filter(x=>Zt(x.type)==="extends"))if(c.has(d.sourceId)||c.has(d.targetId))for(const x of[d.sourceId,d.targetId])!c.has(x)&&s.some(A=>A.id===x)&&(c.add(x),h=!0)}const g=t.hiddenActorIds??new Set;for(const d of o){const x=c.has(d.sourceId)?d.targetId:c.has(d.targetId)?d.sourceId:void 0;x&&g.has(x)&&(c.delete(d.sourceId),c.delete(d.targetId))}const l=s.filter(d=>c.has(d.id)),y=n.filter(Mo).filter(d=>!g.has(d.id)).filter(d=>o.some(x=>x.sourceId===d.id&&c.has(x.targetId)||x.targetId===d.id&&c.has(x.sourceId))),w=new Set([...y,...l].map(d=>d.id));if(l.length===0)return{nodes:[],edges:[]};const m=new Set(o.filter(d=>Zt(d.type)==="extends").map(d=>d.sourceId)),p=new Map;for(const d of l){if(m.has(d.id))continue;const x=a(d.id);p.set(x,[...p.get(x)??[],d])}const M=[...p.keys()].sort((d,x)=>d-x).map(d=>[...p.get(d)??[]]);if(M.length===1&&M[0].length>4){const d=M[0],x=Math.min(3,Math.ceil(d.length/4)),A=Math.ceil(d.length/x);M.splice(0,1,...Array.from({length:x},(F,O)=>d.slice(O*A,(O+1)*A)))}const I=new Map;M.forEach((d,x)=>d.forEach(A=>I.set(A.id,x)));const S=new Map;for(const d of o.filter(x=>Zt(x.type)==="extends")){const x=l.find(O=>O.id===d.sourceId),A=I.get(d.targetId);if(!x||A===void 0||I.has(x.id))continue;const F=M[A];F.splice(F.findIndex(O=>O.id===d.targetId)+1,0,x),I.set(x.id,A),S.set(d.targetId,[...S.get(d.targetId)??[],x])}const E=new Set([...S.values()].flat().map(d=>d.id)),v=d=>o.filter(x=>x.sourceId===d||x.targetId===d).map(x=>x.sourceId===d?x.targetId:x.sourceId),D=new Map,K=()=>M.forEach(d=>d.forEach((x,A)=>D.set(x.id,A)));K(),y.forEach((d,x)=>D.set(d.id,x));const Z=d=>{const x=v(d).map(A=>D.get(A)).filter(A=>A!==void 0);return x.length===0?D.get(d)??0:x.reduce((A,F)=>A+F,0)/x.length};for(let d=0;d<3;d++){const x=d%2===0?M:[...M].reverse();for(const A of x){const F=A.filter(O=>!E.has(O.id));F.sort((O,N)=>Z(O.id)-Z(N.id)),A.splice(0,A.length,...F.flatMap(O=>[O,...S.get(O.id)??[]])),K()}y.sort((A,F)=>Z(A.id)-Z(F.id)),y.forEach((A,F)=>D.set(A.id,F))}const H=176,B=88,Y=104,nt=40,ht=104,ft=88,_t=116,Bt=48,q=62,Lt=44,$t=76,wt=20,jt=Math.max(1,...M.map(d=>d.length)),Dt=Math.max(520,M.length*H+Math.max(M.length-1,0)*Y+Bt*2),zt=Math.max(300,jt*B+(jt-1)*nt+q+Lt),Yt=d=>Bt+d*(H+Y)+H/2,mt=new Map;for(const d of y){const x=v(d.id).map(F=>I.get(F)).filter(F=>F!==void 0).map(Yt),A=x.length?x.reduce((F,O)=>F+O,0)/x.length:0;mt.set(d.id,x.length===0||A<=Dt/2?"left":"right")}const At=y.filter(d=>mt.get(d.id)==="left"),k=y.filter(d=>mt.get(d.id)==="right"),P=wt+(At.length?ht+$t:0),R=wt,J=[{id:"__use_case_boundary__",type:"useCaseBoundary",position:{x:P,y:R},data:{label:t.systemName||"System Boundary",isFrame:!0,kind:"System Boundary"},style:{width:Dt,height:zt},draggable:!1,selectable:!1,zIndex:-1}],rt=new Map,at=R+q,St=zt-q-Lt;M.forEach((d,x)=>{const A=d.length*B+(d.length-1)*nt;let F=at+(St-A)/2;for(const O of d){const N={x:P+Bt+x*(H+Y),y:F};rt.set(O.id,N),J.push({id:O.id,type:"useCase",position:N,data:{label:O.name,kind:O.kind,color:"#E67E22",level:a(O.id)},style:{width:H,height:B}}),F+=B+nt}});for(const d of["left","right"]){const A=(d==="left"?At:k).map(O=>{const N=v(O.id).map(L=>rt.get(L)).filter(L=>!!L).map(L=>L.y);return{actor:O,y:N.length?N.reduce((L,G)=>L+G,0)/N.length:R+q}}).sort((O,N)=>O.y-N.y);let F=-1/0;for(const{actor:O,y:N}of A){const L=Math.max(N,F+_t-ft,wt);F=L+ft,J.push({id:O.id,type:"useCaseActor",position:{x:d==="left"?wt:P+Dt+$t,y:L},data:{label:O.name,kind:O.kind,color:"#334155",side:d},style:{width:ht,height:ft}})}}const Kt=t.edgeStyle??"straight",Xt=o.filter(d=>w.has(d.sourceId)&&w.has(d.targetId)).map(d=>{const x=k.some(O=>O.id===d.sourceId),A=x?d.targetId:d.sourceId,F=x?d.sourceId:d.targetId;return{edge:{id:d.id,source:A,target:F,label:/^(includes|extends)$/.test(Zt(d.type))?`«${Zt(d.type)}»`:void 0,type:"useCaseEdge",data:{routing:Kt},style:{stroke:"#64748B",strokeWidth:1.4,strokeDasharray:/^(includes|extends)$/.test(Zt(d.type))?"5 4":void 0}},source:A,target:F}}),b=new Map(J.map(d=>[d.id,d])),_=d=>{var x,A;return{width:Number(((x=d.style)==null?void 0:x.width)??150),height:Number(((A=d.style)==null?void 0:A.height)??82)}},j=(d,x)=>{const A=_(b.get(d));return x==="left"?{x:0,y:A.height/2}:x==="right"?{x:A.width,y:A.height/2}:x==="top"?{x:A.width/2,y:0}:{x:A.width/2,y:A.height}},W=(d,x)=>{const A=b.get(d),F=j(d,x);return{x:A.position.x+F.x,y:A.position.y+F.y}},z=Xt.map(({edge:d,source:x,target:A})=>{var ot,vt;const F=y.find(Et=>Et.id===x),O=y.find(Et=>Et.id===A),N=!F&&!O&&I.get(x)!==void 0&&I.get(x)===I.get(A),L=N&&(((ot=rt.get(x))==null?void 0:ot.y)??0)<(((vt=rt.get(A))==null?void 0:vt.y)??0),G=F?k.includes(F)?"left":"right":N?L?"bottom":"top":"right",tt=O?k.includes(O)?"left":"right":N?L?"top":"bottom":"left";return{id:d.id,source:W(x,G),target:W(A,tt),sourceNodeId:x,targetNodeId:A,sourceSide:G,targetSide:tt}}),Q=J.filter(d=>d.type==="useCase"||d.type==="useCaseActor").map(d=>({id:d.id,x:d.position.x,y:d.position.y,..._(d)})),$=Kt==="straight"?new Map:Ee(z,Q,28),U=Je(Xt.flatMap(({edge:d})=>{const x=$.get(d.id),A=d.label;return A&&x&&x.length>=2?[{id:d.id,points:x,width:tn(A),height:Qe}]:[]}),Q),T=new Map(z.map(d=>[d.id,d])),f=Xt.map(({edge:d})=>({...d,data:{...d.data,points:$.get(d.id)??[],labelPoint:U.get(d.id),sourceOffset:j(d.source,T.get(d.id).sourceSide),targetOffset:j(d.target,T.get(d.id).targetSide),sourceSide:T.get(d.id).sourceSide,targetSide:T.get(d.id).targetSide}}));return{nodes:J,edges:f}}const Vn=new Set(["includesStep",...ke]);function Zn(e){return e.kind.endsWith("Step")||!!e.attributes.stepOrder}function si(e){if(!e)return;const t=e.split(":");return(t.length>1?t[t.length-1]:t[0]).trim()||void 0}function ii(e,t){const n=e.split(":")[0].trim(),s=t.elements[n];if(s)return s.name;for(const o of Object.values(t.elements))if(o.attributes.id===n)return o.name;return e}const qn=e=>{const t=Number(e.attributes.stepOrder);return Number.isFinite(t)?t:0};function ri(e,t){const n=Object.values(e.elements),s=t?n.filter(t):n,o=s.filter(Zn),i=new Set(o.map(p=>p.id)),a=s.filter(p=>!Zn(p)&&e.relationships.some(u=>Vn.has(u.type)&&u.sourceId===p.id&&i.has(u.targetId))),r=[],c=new Map,h=p=>{const u=p.split(":")[0].trim()||p;return c.has(u)||(c.set(u,r.length),r.push({id:u,label:ii(p,e)})),c.get(u)},g=p=>[...p].sort((u,M)=>qn(u)-qn(M)).map(u=>({step:u,lane:h(u.attributes.allocatedFunction??u.allocatedTo??u.id),item:si(u.attributes.exchangeItem)})),l=p=>{var M;const u=e.relationships.find(I=>I.type==="realizesScenario"&&I.sourceId===p.id);return u?(M=e.elements[u.targetId])==null?void 0:M.name:void 0},y=new Set,w=[];for(const p of a){const u=e.relationships.filter(M=>Vn.has(M.type)&&M.sourceId===p.id&&i.has(M.targetId)).map(M=>e.elements[M.targetId]);for(const M of u)y.add(M.id);w.push({chain:p,scenario:l(p),occurrences:g(u)})}const m=o.filter(p=>!y.has(p.id));return m.length>0&&w.push({occurrences:g(m)}),{lifelines:r,sections:w.filter(p=>p.occurrences.length>0)}}const we=240,ai=52,ci=68,li=40,di=24,Jn=14;function cr(e,t){const n=ri(e,t==null?void 0:t.viewpointFilter);if(n.lifelines.length===0)return{nodes:[],edges:[]};const s=[],o=[],i=g=>g*we+we/2;let a=ai+28;const r=[];for(const g of n.sections){const l=a;a+=li;const y=g.occurrences.map(w=>{const m={...w,y:a};return a+=ci,m});r.push({section:g,top:l,bottom:a,placed:y}),a+=di}const c=a,h=n.lifelines.length*we;return n.lifelines.forEach((g,l)=>{s.push({id:`__lifeline_${g.id}`,type:"seqLifeline",position:{x:l*we,y:0},data:{label:g.label},style:{width:we,height:c},draggable:!1,selectable:!1,zIndex:-2})}),r.forEach(({section:g,top:l,bottom:y,placed:w},m)=>{var p;s.push({id:`__section_${m}`,type:"seqSection",position:{x:-24,y:l},data:{label:((p=g.chain)==null?void 0:p.name)??"Steps",scenario:g.scenario},style:{width:h+48,height:y-l},draggable:!1,selectable:!1,zIndex:-1}),w.forEach((u,M)=>{if(s.push({id:u.step.id,type:"seqOccurrence",position:{x:i(u.lane)-Jn/2,y:u.y-Jn/2},data:{label:u.step.name,kind:u.step.kind},draggable:!1,zIndex:2}),M<w.length-1){const I=w[M+1],S=I.lane>=u.lane,E=I.lane===u.lane;o.push({id:`seq-${m}-${M}`,source:u.step.id,target:I.step.id,sourceHandle:E||S?"right":"left",targetHandle:E?"right":S?"left":"right",type:E?"smoothstep":"straight",label:u.item,style:{stroke:"#3498DB",strokeWidth:it.flowWidth},labelStyle:{fontSize:dt.badge,fill:"#4A90D9",fontWeight:600},labelBgPadding:it.labelBgPadding,labelBgBorderRadius:it.labelBgRadius,labelBgStyle:it.labelBgStyle,markerEnd:{type:"arrowclosed",color:"#3498DB",width:it.arrowSize,height:it.arrowSize},zIndex:1})}})}),{nodes:s,edges:o}}const hi=new Set(["interactsincontext","interactswith","exchangeswith","appliesincontext","connectsphysically"]),fn=new Set(["Actor","User"]),Ye=e=>e.toLowerCase(),mn=e=>e.kind==="UseContext"||/environment|context/i.test(e.name)||/environment/i.test(String(e.attributes.entityKind??"")),gi=e=>/systemofinterest|system-of-interest/i.test(String(e.attributes.contextRole??""))||String(e.attributes.isSystemOfInterest??"").toLowerCase()==="true",Jt=76,So=170,ui=238,Re=30,be=104,je=240,Be=108,$e=92,He=74,pn=40,We=e=>Math.min(Math.max(e.length*7.4+28,So),ui),fi=e=>{var n;const t=String(((n=e.attributes)==null?void 0:n.contextSide)??"").toLowerCase().replace(/[^a-z]/g,"");if(t.endsWith("actor"))return"left";if(t.endsWith("externalsystem"))return"right";if(t.endsWith("environment"))return"top";if(t.endsWith("constraint"))return"bottom"},mi=e=>{var t;return((t=e.attributes)==null?void 0:t.interactionLabel)||`«${Ye(e.type)}»`};function pi(e,t,n){const s=new Map,o=[];for(const i of e){const a=t.some(c=>c.sourceId===i&&c.targetId===n),r=t.some(c=>c.sourceId===n&&c.targetId===i);a&&!r?s.set(i,"left"):r&&!a?s.set(i,"right"):o.push(i)}for(const i of o){const a=[...s.values()].filter(c=>c==="left").length,r=s.size-a;s.set(i,a<=r?"left":"right")}return s}function lr(e,t,n={}){var mt,At;const s=Object.values(e.elements).filter(k=>!n.viewpointFilter||n.viewpointFilter(k)),o=(mt=n.relationshipTypes)!=null&&mt.length?new Set(n.relationshipTypes.map(Ye)):void 0,i=e.relationships.filter(k=>hi.has(Ye(k.type))&&(!o||o.has(Ye(k.type)))),a=new Set(i.flatMap(k=>[k.sourceId,k.targetId])),r=s.filter(k=>a.has(k.id)&&!go(k));if(r.length===0)return{nodes:[],edges:[]};const c=k=>i.filter(P=>P.sourceId===k.id||P.targetId===k.id).length,h=r.find(gi)??r.find(k=>/system/i.test(k.name))??[...r].sort((k,P)=>c(P)-c(k))[0],g=r.filter(k=>k.id!==h.id),l=new Set([h.id,...g.map(k=>k.id)]),y=i.filter(k=>l.has(k.sourceId)&&l.has(k.targetId)),w=pi(g.map(k=>k.id),y,h.id);for(const k of y){const P=fi(k);P&&w.set(k.sourceId,P)}const m=k=>fn.has(k.kind)?0:mn(k)?1:2,p=k=>g.filter(P=>w.get(P.id)===k).sort((P,R)=>m(P)-m(R)||P.name.localeCompare(R.name)),u={left:p("left"),right:p("right"),top:p("top"),bottom:p("bottom")},M=k=>k.length===0?0:k.length*Jt+(k.length-1)*Re,I=k=>k.length===0?0:Math.max(...k.map(P=>We(P.name))),S=k=>k.length===0?0:k.reduce((P,R)=>P+We(R.name),0)+(k.length-1)*Re,E=je+$e*2,v=Be+He*2,D=I(u.left),K=pn+(D>0?D+be:0)+Math.max(E,S(u.top),S(u.bottom))/2,Z=pn+(u.top.length>0?Jt+be:0)+Math.max(v,M(u.left),M(u.right))/2,H=K-E/2,B=Z-v/2,Y=H+E+(u.right.length>0?be:0),nt=[{id:"__context_boundary__",type:"contextBoundary",position:{x:H,y:B},style:{width:E,height:v},data:{label:`${t??h.name} — System Boundary`,isFrame:!0,minWidth:je+$e*2,minHeight:Be+He*2},zIndex:-1},{id:h.id,type:"contextSystem",parentId:"__context_boundary__",extent:"parent",position:{x:$e,y:He},data:{label:h.name,kind:h.kind},style:{width:je,height:Be}}],ht=new Map;for(const k of["left","right"]){const P=u[k];let R=Z-M(P)/2;for(const J of P){const rt=We(J.name),at=k==="left"?pn+D-rt:Y;ht.set(J.id,{x:at,y:R,width:rt,height:Jt,side:k}),nt.push({id:J.id,type:"contextExternal",position:{x:at,y:R},data:{label:J.name,kind:J.kind,category:mn(J)?"environment":fn.has(J.kind)?"person":"system"},style:{width:rt,height:Jt}}),R+=Jt+Re}}for(const k of["top","bottom"]){const P=u[k],R=S(P);let J=K-R/2;const rt=k==="top"?B-be-Jt:B+v+be;for(const at of P){const St=We(at.name);ht.set(at.id,{x:J,y:rt,width:St,height:Jt,side:k}),nt.push({id:at.id,type:"contextExternal",position:{x:J,y:rt},data:{label:at.name,kind:at.kind,category:mn(at)?"environment":fn.has(at.kind)?"person":"system"},style:{width:St,height:Jt}}),J+=St+Re}}const ft={x:H+$e,y:B+He,width:je,height:Be},_t={left:[],right:[],top:[],bottom:[]};for(const k of y){const P=k.sourceId===h.id?k.targetId:k.sourceId;if(k.sourceId!==h.id&&k.targetId!==h.id)continue;const R=(At=ht.get(P))==null?void 0:At.side;R&&!_t[R].includes(k.id)&&_t[R].push(k.id)}for(const k of["left","right"])_t[k].sort((P,R)=>{const J=rt=>{var St;const at=y.find(Kt=>Kt.id===rt);return((St=ht.get(at.sourceId===h.id?at.targetId:at.sourceId))==null?void 0:St.y)??0};return J(P)-J(R)});const Bt=(k,P)=>{const R=_t[P],J=Math.max(R.indexOf(k),0);return{x:P==="left"?ft.x:P==="right"?ft.x+ft.width:ft.x+ft.width*(J+.5)/Math.max(R.length,1),y:P==="top"?ft.y:P==="bottom"?ft.y+ft.height:ft.y+ft.height*(J+.5)/Math.max(R.length,1)}},q=(k,P)=>{const R=ht.get(k);return P==="top"?{x:R.x+R.width/2,y:R.y}:P==="bottom"?{x:R.x+R.width/2,y:R.y+R.height}:{x:P==="left"?R.x:R.x+R.width,y:R.y+R.height/2}},Lt=(k,P)=>{var St;if(k===h.id)return((St=ht.get(P))==null?void 0:St.side)??"left";const R=ht.get(k),J=P===h.id?ft:ht.get(P),rt={x:R.x+R.width/2,y:R.y+R.height/2},at={x:J.x+J.width/2,y:J.y+J.height/2};return Math.abs(at.y-rt.y)>Math.abs(at.x-rt.x)?at.y<rt.y?"top":"bottom":J.x+(P===h.id?ft.width:ht.get(P).width)/2>=R.x+R.width/2?"right":"left"},$t=y.map(k=>{const P=Lt(k.sourceId,k.targetId),R=Lt(k.targetId,k.sourceId),J=(rt,at)=>rt===h.id?Bt(k.id,at):q(rt,at);return{rel:k,sourceSide:P,targetSide:R,source:J(k.sourceId,P),target:J(k.targetId,R)}}),wt=nt.filter(k=>!k.data.isFrame).map(k=>{var P,R;return{id:k.id,x:k.position.x,y:k.position.y,width:Number(((P=k.style)==null?void 0:P.width)??So),height:Number(((R=k.style)==null?void 0:R.height)??Jt)}}),jt=Ee($t.map(k=>({id:k.rel.id,source:k.source,target:k.target,sourceNodeId:k.rel.sourceId,targetNodeId:k.rel.targetId,sourceSide:k.sourceSide,targetSide:k.targetSide})),wt,24),Dt=new Map($t.map(k=>[k.rel.id,mi(k.rel)])),zt=Je($t.flatMap(k=>{const P=jt.get(k.rel.id),R=Dt.get(k.rel.id);return P&&P.length>=2?[{id:k.rel.id,points:P,width:tn(R),height:Qe}]:[]}),wt),Yt=$t.map(k=>{const P=(R,J,rt)=>{const at=R===h.id?ft:ht.get(R);return{x:rt.x-at.x,y:rt.y-at.y,side:J}};return{id:k.rel.id,source:k.rel.sourceId,target:k.rel.targetId,type:"useCaseEdge",label:Dt.get(k.rel.id),style:{stroke:"#0F766E",strokeWidth:1.5},data:{routing:"rounded",points:jt.get(k.rel.id)??[k.source,k.target],labelPoint:zt.get(k.rel.id),sourceSide:k.sourceSide,targetSide:k.targetSide,sourceOffset:P(k.rel.sourceId,k.sourceSide,k.source),targetOffset:P(k.rel.targetId,k.targetSide,k.target)}}});return{nodes:nt,edges:Yt}}const yi=new Set(["name","title","description","shortDescription","longDescription","sourceReference","rationaleText","semantics","queryDescription","dataSourceDescription","doc"]),xi=7,bn=80;function wi(e,t){const n=e.attributes[t];return n===void 0?void 0:(n.includes("::")?n.split("::").pop().trim():n)||void 0}function bi(e){const t=new Map;for(const n of e)for(const s of Object.keys(n.attributes))yi.has(s)||s.includes(".")||t.set(s,(t.get(s)??0)+1);return[...t.entries()].sort((n,s)=>s[1]-n[1]).slice(0,xi).map(([n])=>n)}function Ii(e){const t=new Map;for(const s of e)t.has(s.kind)||t.set(s.kind,[]),t.get(s.kind).push(s);const n=[];for(const[s,o]of t){const i=bi(o),a=o.map(c=>({element:c,values:i.map(h=>wi(c,h))})),r=i.map((c,h)=>{const g=a.map(l=>l.values[h]).filter(l=>l!==void 0);return g.length>0&&g.every(l=>Number.isFinite(Number(l)))});n.push({kind:s,columns:i,numeric:r,rows:a})}return n.sort((s,o)=>o.rows.length-s.rows.length)}function Mi(e,t,n){const s=n==="asc"?1:-1;return[...e.rows].sort((i,a)=>{if(t<0)return i.element.name.localeCompare(a.element.name)*s;const r=i.values[t],c=a.values[t];return r===void 0&&c===void 0?0:r===void 0?1:c===void 0?-1:e.numeric[t]?(Number(r)-Number(c))*s:r.localeCompare(c)*s})}function Si(e,t,n){const s=new Map(e.map(l=>[l.id,l])),o=n!=null&&n.length?new Set(n.map(l=>l.toLowerCase())):void 0,i=t.filter(l=>s.has(l.sourceId)&&s.has(l.targetId)&&l.sourceId!==l.targetId&&(!o||o.has(l.type.toLowerCase())));if(i.length===0)return;const a=new Set,r=new Set,c=new Map,h=new Set;for(const l of i){a.add(l.sourceId),r.add(l.targetId),h.add(l.type);const y=`${l.sourceId}|${l.targetId}`;c.has(y)||c.set(y,[]),c.get(y).includes(l.type)||c.get(y).push(l.type)}const g=(l,y)=>l.kind.localeCompare(y.kind)||l.name.localeCompare(y.name);return{rows:[...a].map(l=>s.get(l)).sort(g),cols:[...r].map(l=>s.get(l)).sort(g),cells:c,relTypes:[...h].sort()}}const Ve={padding:"6px 10px",fontSize:dt.xs,fontWeight:600,color:"#374151",textAlign:"left",borderBottom:"2px solid #E5E5E0",background:"#FAFAF8",position:"sticky",top:0,cursor:"pointer",whiteSpace:"nowrap",userSelect:"none"},Ze={padding:"5px 10px",fontSize:dt.xs,color:"#374151",borderBottom:"1px solid #F0F0ED",verticalAlign:"top"};function vi(e){return e.length>bn?`${e.slice(0,bn-1)}…`:e}function Ei({section:e,search:t}){var l;const n=Se(y=>y.selectElement),[s,o]=yt.useState(-1),[i,a]=yt.useState("asc"),r=yt.useMemo(()=>{const y=Mi(e,s,i);if(!t)return y;const w=t.toLowerCase();return y.filter(m=>m.element.name.toLowerCase().includes(w)||m.values.some(p=>p==null?void 0:p.toLowerCase().includes(w)))},[e,s,i,t]);if(r.length===0)return null;const c=Qt[(l=e.rows[0])==null?void 0:l.element.layer]||"#6B7280",h=y=>{s===y?a(w=>w==="asc"?"desc":"asc"):(o(y),a("asc"))},g=y=>s===y?i==="asc"?" ↑":" ↓":"";return C.jsxs("div",{style:{marginBottom:28},children:[C.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[C.jsx("span",{style:{width:8,height:8,borderRadius:2,background:c,display:"inline-block"}}),C.jsx("span",{style:{fontSize:dt.sm,fontWeight:700,color:"#1B3A4B"},children:e.kind}),C.jsx("span",{style:{fontSize:dt.xs,color:"#9CA3AF"},children:r.length})]}),C.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",background:"#FFFFFF",borderRadius:8,overflow:"hidden",border:"1px solid #E5E5E0"},children:[C.jsx("thead",{children:C.jsxs("tr",{children:[C.jsxs("th",{style:Ve,onClick:()=>h(-1),children:["Element",g(-1)]}),e.columns.map((y,w)=>C.jsxs("th",{style:Ve,onClick:()=>h(w),children:[y,g(w)]},y))]})}),C.jsx("tbody",{children:r.map(y=>C.jsxs("tr",{onMouseEnter:w=>{w.currentTarget.style.background="#F7F7F5"},onMouseLeave:w=>{w.currentTarget.style.background="transparent"},children:[C.jsx("td",{style:{...Ze,whiteSpace:"nowrap"},children:C.jsx("button",{onClick:()=>n(y.element.id),style:{background:"none",border:"none",padding:0,fontSize:dt.xs,fontWeight:600,color:"#1B6FD9",cursor:"pointer",textDecoration:"none"},title:"Open element detail",children:y.element.name})}),y.values.map((w,m)=>C.jsx("td",{style:Ze,title:w&&w.length>bn?w:void 0,children:w?vi(w):C.jsx("span",{style:{color:"#D1D5DB"},children:"—"})},m))]},y.element.id))})]})]})}function ki({elements:e,model:t,relationshipTypes:n}){const s=Se(a=>a.selectElement),o=yt.useMemo(()=>Si(e,t.relationships,n),[e,t.relationships,n]);if(!o)return C.jsx("div",{style:{color:"#9CA3AF",fontSize:dt.sm,padding:24},children:"No relationships among this view's elements."});const i=(a,r=!1)=>C.jsx("button",{onClick:()=>s(a.id),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"10px",fontWeight:600,color:"#374151",...r?{writingMode:"vertical-rl",transform:"rotate(180deg)",maxHeight:120}:{},whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:180},title:`${a.kind} · open detail`,children:a.name});return C.jsxs("div",{children:[C.jsx("div",{className:"flex gap-3 mb-2",style:{fontSize:dt.xs,color:"#6B7280"},children:o.relTypes.map(a=>C.jsxs("span",{className:"flex items-center gap-1",children:[C.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:ce[a]||"#6B7280",display:"inline-block"}}),a]},a))}),C.jsxs("table",{style:{borderCollapse:"collapse",background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[C.jsx("thead",{children:C.jsxs("tr",{children:[C.jsx("th",{style:{...Ve,cursor:"default"}}),o.cols.map(a=>C.jsx("th",{style:{...Ve,cursor:"default",verticalAlign:"bottom",padding:"8px 4px"},children:i(a,!0)},a.id))]})}),C.jsx("tbody",{children:o.rows.map(a=>C.jsxs("tr",{children:[C.jsx("td",{style:{...Ze,whiteSpace:"nowrap",background:"#FAFAF8"},children:i(a)}),o.cols.map(r=>{const c=o.cells.get(`${a.id}|${r.id}`);return C.jsx("td",{style:{...Ze,textAlign:"center",padding:"4px 6px"},title:c==null?void 0:c.join(", "),children:c==null?void 0:c.map(h=>C.jsx("span",{style:{width:9,height:9,borderRadius:"50%",margin:1,background:ce[h]||"#6B7280",display:"inline-block"}},h))},r.id)})]},a.id))})]})]})}function dr({diagram:e,model:t,viewpointFilter:n}){const[s,o]=yt.useState("table"),[i,a]=yt.useState(""),r=yt.useMemo(()=>{const g=Object.values(t.elements);return n?g.filter(n):g},[t,n]),c=yt.useMemo(()=>Ii(r),[r]),h=eo.grid;return C.jsx("div",{className:"flex-1 overflow-auto",style:{background:"#F7F7F5"},children:C.jsxs("div",{style:{padding:"16px 20px",maxWidth:1240},children:[C.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[C.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:h.color+"20",color:h.color,fontSize:dt.badge},title:h.fullName,children:h.label}),C.jsx("span",{style:{fontSize:dt.md,fontWeight:700,color:"#1a1a1a"},children:e.name}),C.jsxs("span",{style:{fontSize:dt.xs,color:"#9CA3AF"},children:[r.length," elements"]}),C.jsx("div",{className:"flex rounded overflow-hidden ml-2",style:{border:"1px solid #E5E5E0"},children:["table","matrix"].map(g=>C.jsx("button",{onClick:()=>o(g),className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:s===g?"#1B3A4B":"#FFFFFF",color:s===g?"#FFFFFF":"#6B7280",border:"none",cursor:"pointer"},children:g},g))}),s==="table"&&C.jsx("input",{value:i,onChange:g=>a(g.target.value),placeholder:"Filter rows…",className:"px-2 py-1 rounded focus:outline-none ml-auto",style:{fontSize:dt.xs,border:"1px solid #E5E5E0",background:"#FFFFFF",color:"#1a1a1a",width:200}})]}),s==="table"?c.map(g=>C.jsx(Ei,{section:g,search:i},g.kind)):C.jsx(ki,{elements:r,model:t,relationshipTypes:e.relationshipTypes}),s==="table"&&c.length===0&&C.jsx("div",{style:{color:"#9CA3AF",fontSize:dt.sm,padding:24},children:"This view selects no elements."})]})})}const Ai=8;function vo(e,t,n){const s=(t.get(e.id)??[]).filter(o=>n.has(o)).map(o=>vo(n.get(o),t,n));return s.sort(Xe),{id:e.id,label:e.name,element:e,kind:e.kind,layer:e.layer,children:s,count:1+s.reduce((o,i)=>o+i.count,0)}}const Xe=(e,t)=>(e.kind??"").localeCompare(t.kind??"")||e.label.localeCompare(t.label);function Ci(e,t){const n=qe(e,t),s=new Map,o=[];for(const i of n.roots){const a=n.elements.get(i),r=vo(a,n.childrenMap,n.elements),c=a.package;if(!c){o.push(r);continue}if(!s.has(c)){const g=c.split("::").pop()??c,l={id:`pkg:${c}`,label:g,title:c,children:[],count:0};s.set(c,l),o.push(l)}const h=s.get(c);h.children.push(r),h.count+=r.count}for(const i of s.values()){const a=new Set(i.children.map(c=>c.kind));if(i.children.length<=Ai||a.size<=1){i.children.sort(Xe);continue}const r=new Map;for(const c of i.children){const h=c.kind??"—";r.has(h)||r.set(h,[]),r.get(h).push(c)}i.children=[...r.entries()].sort((c,h)=>c[0].localeCompare(h[0])).map(([c,h])=>{var g;return{id:`kind:${i.id}:${c}`,label:c,kind:c,layer:(g=h[0])==null?void 0:g.layer,children:h.sort(Xe),count:h.reduce((l,y)=>l+y.count,0)}})}return o.sort(Xe),o}function Ti(e,t){const n=t.trim().toLowerCase();if(!n)return;const s=new Set,o=new Set,i=(a,r)=>{const c=a.label.toLowerCase().includes(n)||(a.kind??"").toLowerCase().includes(n);let h=!1;for(const g of a.children)i(g,[...r,a.id])&&(h=!0);if(c||h){s.add(a.id);for(const g of r)s.add(g),o.add(g);return h&&o.add(a.id),!0}return!1};for(const a of e)i(a,[]);return{visible:s,expanded:o}}function Fi(e){if(!e)return"·";const t=e.replace(/[^A-Za-z]/g,"").match(/[A-Z]/g);return t&&t.length>=2?t.slice(0,2).join(""):e.slice(0,2).toUpperCase()}function Eo({node:e,depth:t,expanded:n,visible:s,forceExpanded:o,onToggle:i}){const a=Se(m=>m.selectElement),r=Se(m=>m.selectedElementId),c=Se(m=>m.deleteModelElement);if(s&&!s.has(e.id))return null;const h=n.has(e.id)||!!(o!=null&&o.has(e.id)),g=e.children.length>0,l=!e.element,y=Qt[e.layer??""]||"#95A5A6",w=e.element&&e.id===r;return C.jsxs(C.Fragment,{children:[C.jsx(Oo,{id:e.id,label:e.label,depth:t,hasChildren:g,expanded:h,selected:!!w,badge:l?e.id.startsWith("pkg:")?"PKG":"GRP":Fi(e.kind),badgeColor:y,count:g?e.count:void 0,title:e.title??e.kind,onClick:()=>{g&&i(e.id),e.element&&a(e.id)},onDelete:e.element?()=>c(e.id):void 0}),h&&e.children.map(m=>C.jsx(Eo,{node:m,depth:t+1,expanded:n,visible:s,forceExpanded:o,onToggle:i},m.id))]})}function hr({diagram:e,model:t,viewpointFilter:n}){const[s,o]=yt.useState(new Set),[i,a]=yt.useState(""),r=yt.useMemo(()=>{const m=Object.values(t.elements);return n?m.filter(n):m},[t,n]),c=yt.useMemo(()=>Ci(r,t.relationships),[r,t.relationships]),h=yt.useMemo(()=>Ti(c,i),[c,i]),g=yt.useCallback(m=>{o(p=>{const u=new Set(p);return u.has(m)?u.delete(m):u.add(m),u})},[]),l=yt.useCallback((m,p)=>{for(const u of m)u.children.length>0&&(p.add(u.id),l(u.children,p));return p},[]),y=eo.browser,w=r.length;return C.jsx("div",{className:"flex-1 overflow-auto",style:{background:"#F7F7F5"},children:C.jsxs("div",{style:{padding:"16px 20px",maxWidth:860},children:[C.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[C.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:y.color+"20",color:y.color,fontSize:dt.badge},title:y.fullName,children:y.label}),C.jsx("span",{style:{fontSize:dt.md,fontWeight:700,color:"#1a1a1a"},children:e.name}),C.jsxs("span",{style:{fontSize:dt.xs,color:"#9CA3AF"},children:[w," elements"]}),C.jsx("button",{onClick:()=>o(l(c,new Set)),className:"px-2 py-0.5 text-xs font-medium rounded ml-2",style:{background:"#FFFFFF",color:"#374151",border:"1px solid #E5E5E0",cursor:"pointer"},children:"Expand All"}),C.jsx("button",{onClick:()=>o(new Set),className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#FFFFFF",color:"#374151",border:"1px solid #E5E5E0",cursor:"pointer"},children:"Collapse All"}),C.jsx("input",{value:i,onChange:m=>a(m.target.value),placeholder:"Filter by name or kind…",className:"px-2 py-1 rounded focus:outline-none ml-auto",style:{fontSize:dt.xs,border:"1px solid #E5E5E0",background:"#FFFFFF",color:"#1a1a1a",width:220}})]}),C.jsxs("div",{style:{background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:10,padding:"10px 8px"},children:[c.length===0&&C.jsx("div",{style:{color:"#9CA3AF",fontSize:dt.sm,padding:16},children:"This view selects no elements."}),c.map(m=>C.jsx(Eo,{node:m,depth:0,expanded:s,visible:h==null?void 0:h.visible,forceExpanded:h==null?void 0:h.expanded,onToggle:g},m.id)),h&&c.every(m=>!h.visible.has(m.id))&&C.jsxs("div",{style:{color:"#9CA3AF",fontSize:dt.sm,padding:16},children:["No matches for “",i,"”."]})]})]})})}function gr({x:e,y:t,sourceElement:n,targetElement:s,registries:o,allowedTypes:i,onSelect:a,onCancel:r}){const c=yt.useRef(null),[h,g]=yt.useState(""),[l,y]=yt.useState(""),w=yt.useRef(null);yt.useEffect(()=>{var E;(E=w.current)==null||E.focus()},[]),yt.useEffect(()=>{const E=v=>{c.current&&!c.current.contains(v.target)&&r()};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[r]),yt.useEffect(()=>{const E=v=>{v.key==="Escape"&&r()};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[r]);const m=yt.useMemo(()=>{const E=Co(n,s,o);if(!(i!=null&&i.length))return E;const v=new Set(i.map(D=>D.toLowerCase()));return E.filter(D=>v.has(D.definition.name.toLowerCase())||v.has(D.definition.sysmlName.toLowerCase()))},[n,s,o,i]),p=yt.useMemo(()=>{const E=h.trim().toLowerCase();return E?m.filter(v=>{var D;return((D=v.definition.nativeKeyword)==null?void 0:D.toLowerCase().includes(E))||v.definition.label.toLowerCase().includes(E)||v.definition.name.toLowerCase().includes(E)}):m},[m,h]),u=260,M=320,I=Math.min(e,window.innerWidth-u-8),S=Math.min(t,window.innerHeight-M-8);return C.jsxs("div",{ref:c,className:"fixed z-50 flex flex-col shadow-xl rounded-xl overflow-hidden",style:{left:I,top:S,width:u,maxHeight:M,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.16)"},children:[C.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",flexShrink:0},children:[C.jsx("div",{style:{fontSize:dt.xs,fontWeight:600,color:"#374151",marginBottom:4},children:"Relationship Type"}),C.jsxs("div",{style:{fontSize:"10px",color:"#9CA3AF",marginBottom:4},children:[n.kind," → ",s.kind]}),C.jsx("input",{ref:w,value:h,onChange:E=>g(E.target.value),placeholder:"Search…","aria-label":"Search relationship types",className:"w-full px-2 py-1 rounded focus:outline-none",style:{fontSize:dt.xs,background:"#F7F7F5",border:"1px solid #E5E5E0",color:"#374151"}}),C.jsx("input",{value:l,onChange:E=>y(E.target.value),placeholder:"Transported item / flow label (optional)","aria-label":"Transported item or flow label",className:"w-full px-2 py-1 rounded focus:outline-none",style:{marginTop:6,fontSize:dt.xs,background:"#F7F7F5",border:"1px solid #E5E5E0",color:"#374151"}})]}),C.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[p.map(E=>{const{definition:v,direction:D,sourceId:K,targetId:Z}=E,H=v.nativeKeyword??v.label,B=D==="incoming";return C.jsxs("button",{onClick:()=>a({type:v.name,sourceId:K,targetId:Z,direction:D,flowItem:l.trim()||void 0}),className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-left",style:{background:"none",border:"none",cursor:"pointer"},onMouseEnter:Y=>{Y.currentTarget.style.background="#F7F7F5"},onMouseLeave:Y=>{Y.currentTarget.style.background="none"},children:[C.jsx("div",{style:{width:10,height:10,borderRadius:"50%",flexShrink:0,background:ce[v.name]??"#6B7280"}}),C.jsxs("div",{style:{minWidth:0},children:[C.jsxs("div",{style:{fontSize:dt.xs,fontWeight:500,color:"#1a1a1a"},children:[H,B&&C.jsx("span",{style:{color:"#9CA3AF",fontWeight:400},children:" (reversed)"})]}),C.jsxs("div",{className:"truncate",style:{fontSize:"10px",color:"#9CA3AF"},children:[v.sourceEnd.name," → ",v.targetEnd.name]})]})]},`${v.name}-${D}`)}),p.length===0&&C.jsx("div",{className:"p-3 text-center",style:{color:"#9CA3AF",fontSize:dt.xs},children:m.length===0?`The ontology defines no relationship between a ${n.kind} and a ${s.kind}.`:"No matching types"})]})]})}function ur(e){var t,n,s;return((s=(n=(t=e)==null?void 0:t.canvas)==null?void 0:n.layout)==null?void 0:s.provider)??Fo}const Qn={AcceptActionUsage:"accept",SendActionUsage:"send",DecisionNodeUsage:"decision",MergeNodeUsage:"merge",ForkNodeUsage:"fork",JoinNodeUsage:"join",TerminateActionUsage:"activity-final",ActivityFinalNodeUsage:"activity-final",FlowFinalNodeUsage:"flow-final"},to={action:"usage",accept:"accept",send:"send",decision:"decision",merge:"merge",fork:"fork",join:"join",activityFinal:"activity-final",flowFinal:"flow-final"};function Oi(e){return e.isDefinition?"definition":e.metaclass&&Qn[e.metaclass]?Qn[e.metaclass]:e.metaclass&&to[e.metaclass]?to[e.metaclass]:"usage"}const Ie=e=>typeof e=="number"&&Number.isFinite(e)?e:typeof e=="string"&&Number.isFinite(Number.parseFloat(e))?Number.parseFloat(e):void 0;function Ni(e){const t=new Map(e.map(i=>[i.id,i])),n=[],s=new Set,o=i=>{s.has(i.id)||(s.add(i.id),i.parentId&&t.has(i.parentId)&&o(t.get(i.parentId)),n.push(i))};return e.forEach(o),n}function fr(e,t){const n=new Set(e.map(o=>o.id));return{nodes:Ni(e).map(o=>{var m,p,u,M;const i=o.data??{},a=typeof i.label=="string"&&i.label?i.label:o.id,r=typeof i.kind=="string"?i.kind:o.type??"",c=/definition$| def$/i.test(r)||i.isDefinition===!0,h=typeof i.nodeType=="string"?i.nodeType:r,g=i.isFrame===!0?"frame":i.genericRecord===!0?"generic":Oi({metaclass:h||r,isDefinition:c,viewKind:typeof i.viewKind=="string"?i.viewKind:void 0}),l=Array.isArray(i.ports)?i.ports.filter(I=>!!I&&typeof I=="object"&&typeof I.id=="string"):[],y=l.length?l:[...Array.isArray(i.inPorts)?i.inPorts.filter(I=>typeof I=="string").map((I,S)=>({id:`in:${I}`,name:I,side:"left",direction:"in",pin:!0,_i:S})):[],...Array.isArray(i.outPorts)?i.outPorts.filter(I=>typeof I=="string").map((I,S)=>({id:`out:${I}`,name:I,side:"right",direction:"out",pin:!0,_i:S})):[]],w=Array.isArray(i.compartments)?i.compartments:void 0;return{id:o.id,subjectId:typeof i.subjectId=="string"?i.subjectId:o.id,...o.parentId&&n.has(o.parentId)?{parentId:o.parentId}:{},x:((m=o.position)==null?void 0:m.x)??0,y:((p=o.position)==null?void 0:p.y)??0,width:Ie(o.width)??Ie((u=o.style)==null?void 0:u.width)??Math.max(130,a.length*7.5+48),height:Ie(o.height)??Ie((M=o.style)==null?void 0:M.height)??52,label:a,kind:r,glyph:g,color:[i.bgColor,i.color,i.layerColor].find(I=>typeof I=="string"&&!!I)??"#6B7280",isDefinition:c,isFrame:i.isFrame===!0,...y.length?{ports:y}:{},...w!=null&&w.length?{compartments:w}:{},...Array.isArray(i.memberIds)?{memberIds:i.memberIds}:{},...i.orientation==="row"||i.orientation==="column"?{orientation:i.orientation}:{},accessibilityText:`${g} ${a}${r?` (${r})`:""}`,...i.diagnostic&&typeof i.diagnostic=="object"?{diagnostic:i.diagnostic}:{}}}),edges:t.filter(o=>n.has(o.source)&&n.has(o.target)).map(o=>{var a,r,c;const i=o.style;return{id:o.id,subjectId:typeof((a=o.data)==null?void 0:a.subjectId)=="string"?o.data.subjectId:o.id,sourceId:o.source,targetId:o.target,...typeof o.label=="string"&&o.label?{label:o.label}:{},...o.sourceHandle?{sourcePortId:o.sourceHandle}:{},...o.targetHandle?{targetPortId:o.targetHandle}:{},color:typeof(i==null?void 0:i.stroke)=="string"?i.stroke:"#9CA3AF",strokeWidth:Ie(i==null?void 0:i.strokeWidth)??1.5,dashed:typeof(i==null?void 0:i.strokeDasharray)=="string",animated:o.animated===!0,...typeof((r=o.data)==null?void 0:r.routing)=="string"?{routing:o.data.routing}:{},points:Array.isArray((c=o.data)==null?void 0:c.points)&&o.data.points.length>2?o.data.points.slice(1,-1):[]}})}}function mr(e){const t=a=>a.replace(/[&<>"']/g,r=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[r]),n=Math.max(1,...e.nodes.map(a=>a.x+a.width+24)),s=Math.max(1,...e.nodes.map(a=>a.y+a.height+24)),o=a=>{const r=a.glyph==="decision"||a.glyph==="merge"?`<polygon points="${a.x+a.width/2},${a.y} ${a.x+a.width},${a.y+a.height/2} ${a.x+a.width/2},${a.y+a.height} ${a.x},${a.y+a.height/2}"/>`:a.glyph==="fork"||a.glyph==="join"?`<rect x="${a.x}" y="${a.y+a.height/2-4}" width="${a.width}" height="8" rx="2" fill="#111"/>`:a.glyph==="activity-final"?`<circle cx="${a.x+a.width/2}" cy="${a.y+a.height/2}" r="${Math.min(a.width,a.height)/2-3}"/><circle cx="${a.x+a.width/2}" cy="${a.y+a.height/2}" r="${Math.min(a.width,a.height)/2-9}" fill="white"/>`:`<rect x="${a.x}" y="${a.y}" width="${a.width}" height="${a.height}" rx="${a.isDefinition?2:12}"/>`;return`<g data-subject-id="${t(a.subjectId)}" aria-label="${t(a.accessibilityText)}" fill="white" stroke="${a.color}" stroke-width="1.5">${r}<text x="${a.x+a.width/2}" y="${a.y+a.height/2}" text-anchor="middle" fill="#111" stroke="none" font-size="12">${t(a.label)}</text>${a.diagnostic?`<circle cx="${a.x+a.width-7}" cy="${a.y+7}" r="5" fill="#d97706" stroke="none"/>`:""}</g>`},i=a=>{const r=e.nodes.find(g=>g.id===a.sourceId),c=e.nodes.find(g=>g.id===a.targetId);if(!r||!c)return"";const h=[{x:r.x+r.width,y:r.y+r.height/2},...a.points,{x:c.x,y:c.y+c.height/2}].map(g=>`${g.x},${g.y}`).join(" ");return`<g data-subject-id="${t(a.subjectId)}"><polyline points="${h}" fill="none" stroke="${a.color}" stroke-width="${a.strokeWidth}"${a.dashed?' stroke-dasharray="5 3"':""}/>${a.label?`<text x="${(r.x+c.x)/2}" y="${(r.y+c.y)/2-5}" font-size="11">${t(a.label)}</text>`:""}</g>`};return`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${s}" viewBox="0 0 ${n} ${s}">${e.edges.map(i).join("")}${e.nodes.map(o).join("")}</svg>`}export{Qi as A,qe as B,ke as C,Hi as D,cs as E,rs as F,zi as G,ho as H,Vi as I,Xi as J,dr as K,hr as L,ls as M,he as N,Ee as O,fs as P,Bi as Q,gr as R,Je as S,Ki as T,fr as U,mr as V,ss as a,is as b,Wi as c,ar as d,lr as e,Zi as f,nr as g,or as h,cr as i,Yi as j,os as k,ms as l,Ke as m,Ui as n,uo as o,ir as p,er as q,tr as r,ur as s,Us as t,sr as u,Gi as v,rr as w,Ji as x,qi as y,$i as z};
|