ggn-layout 0.1.0 → 0.1.2
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/CHANGELOG.md +110 -0
- package/LICENSE +15 -0
- package/README.md +17 -5
- package/THIRD_PARTY_NOTICES.md +35 -3
- package/dist/{algorithms-CNhihjzf.js → algorithms-JOaPA3B9.js} +11 -0
- package/dist/{algorithms-DXUI06fi.cjs → algorithms-X6GKNYEw.cjs} +11 -0
- package/dist/api/index.cjs +12 -1
- package/dist/api/index.d.cts +14 -3
- package/dist/api/index.d.ts +14 -3
- package/dist/api/index.js +12 -1
- package/dist/api/layered.cjs +12 -1
- package/dist/api/layered.d.cts +13 -2
- package/dist/api/layered.d.ts +13 -2
- package/dist/api/layered.js +12 -1
- package/dist/{api-BRaDa6RG.js → api-D4FVITVw.js} +12 -1
- package/dist/{api-DWBi7ngO.cjs → api-DTHTxaol.cjs} +12 -1
- package/dist/{internal-BOuvVTiR.d.cts → core-DWo6Sbh9.d.ts} +13 -2
- package/dist/{internal-Coxrnk9C.d.ts → core-Or66h-Jn.d.cts} +13 -2
- package/dist/{internal.cjs → core.cjs} +12 -1
- package/dist/{internal.d.ts → core.d.cts} +14 -3
- package/dist/{internal.d.cts → core.d.ts} +14 -3
- package/dist/{internal.js → core.js} +12 -1
- package/dist/{elk-json-ibWtLFj2.d.cts → elk-json-BiUIDEHd.d.cts} +11 -0
- package/dist/{elk-json-ibWtLFj2.d.ts → elk-json-BiUIDEHd.d.ts} +11 -0
- package/dist/{elk-json-BtGnwuQE.cjs → elk-json-BqpJCr7A.cjs} +12 -1
- package/dist/{elk-json-B9eLYtu6.js → elk-json-Dm4r-Nqy.js} +12 -1
- package/dist/{index-C_0jvfEV.d.ts → index-DprqHh4K.d.ts} +13 -2
- package/dist/{index-Dl2hrLFA.d.cts → index-DwemPNSn.d.cts} +13 -2
- package/dist/index.cjs +12 -1
- package/dist/index.d.cts +16 -5
- package/dist/index.d.ts +16 -5
- package/dist/index.js +12 -1
- package/dist/layered-options-CWVVspE4.d.cts +17 -0
- package/dist/layered-options-vH0HCu1n.d.ts +17 -0
- package/dist/layout-worker.cjs +12 -1
- package/dist/layout-worker.d.cts +12 -1
- package/dist/layout-worker.d.ts +12 -1
- package/dist/layout-worker.js +12 -1
- package/dist/options.cjs +12 -1
- package/dist/options.d.cts +13 -2
- package/dist/options.d.ts +13 -2
- package/dist/options.js +12 -1
- package/dist/{validate-B9vX3T2G.d.ts → validate-YGFYSdxd.d.cts} +11 -0
- package/dist/{validate-B9vX3T2G.d.cts → validate-YGFYSdxd.d.ts} +11 -0
- package/docs/API.md +1 -1
- package/docs/reference/elk-algorithm-catalog.md +2 -2
- package/docs/reference/elk-algorithm-guide.md +4 -4
- package/docs/reference/elk-edge-routing-investigation.md +10 -13
- package/docs/reference/elk-json-format.md +1 -1
- package/docs/reference/elk-layout-options-mechanism.md +1 -1
- package/docs/reference/elk-layout-options.md +4 -4
- package/docs/reference/elk-node-labels.md +11 -8
- package/docs/reference/elk-spacing-options.md +1 -1
- package/docs/reference/elkjs-feature-coverage.md +2 -3
- package/package.json +18 -9
- package/dist/layered-options-COPhjoOB.d.ts +0 -6
- package/dist/layered-options-Dm7nJC1R.d.cts +0 -6
- /package/{src/api → schema}/layout-input.schema.json +0 -0
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import{T as e,o as t,r as n,w as r}from"./elk-json-B9eLYtu6.js";import{ii as i,ni as a,ri as o}from"./algorithms-CNhihjzf.js";function s(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function c(e,t){let n=s(e,t);if(n==null)return null;if(typeof n==`object`){let e=n;return typeof e.x==`number`&&typeof e.y==`number`?{x:e.x,y:e.y}:null}let[r,i]=String(n).replace(/[()[\]]/g,``).split(`,`).map(e=>Number(e.trim()));return Number.isFinite(r)&&Number.isFinite(i)?{x:r,y:i}:null}function l(e,t){let n=s(e,t);if(n==null)return null;let r=Number(n);return Number.isFinite(r)?r:null}function u(e,t,n=!1){let r=s(e,t);return r==null?n:String(r)===`true`}function d(e){let t=s(e,`org.eclipse.elk.edgeRouting`),n=0,r=0;for(let i of e.children??[]){let a=c(i,`org.eclipse.elk.position`);if(a!==null&&(i.x=a.x,i.y=a.y,String(s(i,`org.eclipse.elk.nodeSize.constraints`)??``).includes(`MINIMUM_SIZE`))){let e=c(i,`org.eclipse.elk.nodeSize.minimum`);if(e!==null&&e.x>0&&e.y>0){let t=Math.max(i.width??0,e.x),n=Math.max(i.height??0,e.y);i.width=t,i.height=n}}n=Math.max(n,(i.x??0)+(i.width??0)),r=Math.max(r,(i.y??0)+(i.height??0));for(let e of i.labels??[]){let t=c(e,`org.eclipse.elk.position`);t!==null&&(e.x=t.x,e.y=t.y),n=Math.max(n,(i.x??0)+(e.x??0)+(e.width??0)),r=Math.max(r,(i.y??0)+(e.y??0)+(e.height??0))}for(let e of i.ports??[]){let t=c(e,`org.eclipse.elk.position`);t!==null&&(e.x=t.x,e.y=t.y);let a=(i.x??0)+(e.x??0),o=(i.y??0)+(e.y??0);n=Math.max(n,a+(e.width??0)),r=Math.max(r,o+(e.height??0));for(let t of e.labels??[]){let e=c(t,`org.eclipse.elk.position`);e!==null&&(t.x=e.x,t.y=e.y),n=Math.max(n,a+(t.x??0)+(t.width??0)),r=Math.max(r,o+(t.y??0)+(t.height??0))}}for(let e of re(i)){let i=f(e,t);n=Math.max(n,i.x),r=Math.max(r,i.y)}for(let a of ie(i)){let o=a.sources?.[0],s=o===void 0?null:ae(e,o);if(s!==null&&s!==i){let e=f(a,t);n=Math.max(n,e.x),r=Math.max(r,e.y)}}}if(t===`ORTHOGONAL`)for(let t of e.children??[])for(let e of re(t))p(e);if(!u(e,`org.eclipse.elk.nodeSize.fixedGraphSize`)){let t=te(e);e.width=n+t.left+t.right,e.height=r+t.top+t.bottom}return e}function f(e,t){let n=e.sources?.[0],r=e.targets?.[0],i={x:0,y:0},a=s(e,`org.eclipse.elk.bendPoints`),o=Array.isArray(a)?a:null;if(o!==null&&o.length>=2){let t={};o.length>=1&&(t.startPoint=ne(o[0])),o.length>=2&&(t.endPoint=ne(o[o.length-1])),o.length>2&&(t.bendPoints=o.slice(1,-1).map(ne)),e.sections=[t]}if(n!==void 0&&r!==void 0)for(let t of e.sections??[]){for(let e of t.bendPoints??[])i.x=Math.max(i.x,e.x),i.y=Math.max(i.y,e.y);t.startPoint&&(i.x=Math.max(i.x,t.startPoint.x),i.y=Math.max(i.y,t.startPoint.y)),t.endPoint&&(i.x=Math.max(i.x,t.endPoint.x),i.y=Math.max(i.y,t.endPoint.y))}return i}function p(e){let t=(e.sections??[])[0]?.bendPoints;t!==void 0&&t.length>0&&(e.layoutOptions={...e.layoutOptions,"org.eclipse.elk.junctionPoints":t.map(e=>({x:e.x,y:e.y}))})}function m(t){let n=l(t,`org.eclipse.elk.spacing.nodeNode`)??20,r=te(t),i=l(t,`org.eclipse.elk.aspectRatio`)??1.6,a=l(t,`org.eclipse.elk.randomSeed`)??0,o=new e(a),s=t.children??[],c=s.length;if(c===0)return t;let u=0,d=0,f=0;for(let e of s){let t=e.width??0,n=e.height??0;u=Math.max(u,t),d=Math.max(d,n),f+=t*n}let p=f+2*n*n*c,m=Math.sqrt(p),g=Math.max(m*i,u),_=Math.max(m/i,d);for(let e of s)e.x=r.left+o.nextDouble()*(g-(e.width??0)),e.y=r.left+o.nextDouble()*(_-(e.height??0));let v=g+r.left+r.right,y=_+r.top+r.bottom;for(let e of s)for(let n of re(e))(!n.sections||(n.sections??[]).length===0)&&h(n,o,v,y,t);return t.width=v,t.height=y,t}function h(e,t,n,r,i){let a=oe(i,e.sources?.[0]),o=oe(i,e.targets?.[0]),s=a.x,c=a.y,l=a.w/2,u=a.h/2;s+=l,c+=u;let d=o.x,f=o.y,p=o.w/2,m=o.h/2;d+=p,f+=m;let h={startPoint:{x:0,y:0},endPoint:{x:0,y:0},bendPoints:[]},g=d;d>s+l?g=s+l:d<s-l&&(g=s-l);let _=f;f>c+u?_=c+u:f<c-u&&(_=c-u),g>s-l&&g<s+l&&_>c-u&&_<c+u&&(g=s+l),h.startPoint={x:g,y:_};let v=s;s>d+p?v=d+p:s<d-p&&(v=d-p);let y=c;c>f+m?y=f+m:c<f-m&&(y=f-m),v>d-p&&v<d+p&&y>f-m&&y<f+m&&(y=f+m),h.endPoint={x:v,y};let ee=t.nextInt(5),te=v-g,ne=y-_,re=Math.sqrt(te*te+ne*ne)*.2,ie=te/(ee+1),ae=ne/(ee+1),b=g,se=_;for(let e=0;e<ee;e++){b+=ie,se+=ae;let e=b+t.nextFloat()*re-re/2;e<0?e=1:e>n&&(e=n-1);let i=se+t.nextFloat()*re-re/2;i<0?i=1:i>r&&(i=r-1),h.bendPoints.push({x:e,y:i})}e.sections=[h]}function g(e){let t=String(s(e,`org.eclipse.elk.box.packingMode`)??`SIMPLE`);if(t!==`SIMPLE`)throw Error(`[layout] box.packingMode '${t}' 尚未移植 (当前仅 SIMPLE); 见 docs/NON-LAYERED-PORTING.md`);return _(e,l(e,`org.eclipse.elk.spacing.nodeNode`)??15,te(e),u(e,`org.eclipse.elk.expandNodes`),u(e,`org.eclipse.elk.interactive`)),e}function _(e,t,n,r,i){let a=v(e,i),o=ee(e),s=l(e,`org.eclipse.elk.aspectRatio`)??1.3,c=y(a,t,n,o.x,o.y,r,s);e.width=c.x,e.height=c.y}function v(e,t){let n=[...e.children??[]];return n.sort((e,n)=>{let r=l(e,`org.eclipse.elk.priority`)??0,i=l(n,`org.eclipse.elk.priority`)??0;if(r!==i)return i-r;if(t){let t=(e.y??0)-(n.y??0);return t===0?(e.x??0)-(n.x??0):t}return(e.width??0)*(e.height??0)-(n.width??0)*(n.height??0)}),n}function y(e,t,n,r,i,a,o){let s=0,c=0;for(let t of e)s=Math.max(s,t.width??0),c+=(t.width??0)*(t.height??0);let l=c/Math.max(1,e.length),u=0;for(let t of e)u+=((t.width??0)*(t.height??0)-l)**2;u=Math.sqrt(u/Math.max(1,e.length)),c+=e.length*1*u,c+=Math.sqrt(c)*(n.bottom+n.top),c+=Math.sqrt(c)*n.right,s=Math.max(s,Math.sqrt(c*o))+n.left;let d=n.left,f=n.top,p=0,m=n.left+n.right,h=[0],g=[];for(let r=0;r<e.length;r++){let i=e[r],o=i.width??0,c=i.height??0;d+o>s&&(a&&(g.push(p),h.push(r)),d=n.left,f+=p+t,p=0,m=Math.max(m,n.left+n.right+o)),i.x=d,i.y=f,m=Math.max(m,d+o+n.right),p=Math.max(p,c),d+=o+t}m=Math.max(m,r);let _=f+p+n.bottom;if(_<i&&(p+=i-_,_=i),a){d=n.left,h.push(e.length);let r=h.shift();g.push(p);let i=0,a=0;for(let o=0;o<e.length;o++){o===r&&(d=n.left,i=g[a++],r=h.shift());let s=e[o];s.height,s.height=i,o+1===r&&(s.width=m-d-n.right),s.x=d,d+=(s.width??0)+t}}return{x:m,y:_}}function ee(e){let t=String(s(e,`org.eclipse.elk.nodeSize.constraints`)??``),n=c(e,`org.eclipse.elk.nodeSize.minimum`);return t.includes(`MINIMUM_SIZE`)&&n!==null?n:{x:0,y:0}}function te(e,t=15){let n=s(e,`org.eclipse.elk.padding`);if(typeof n==`object`&&n){let e=n,r=n=>typeof e[n]==`number`?e[n]:t;return{left:r(`left`),top:r(`top`),right:r(`right`),bottom:r(`bottom`)}}if(typeof n==`string`){let e={};for(let t of n.replace(/^\[|\]$/g,``).split(`,`)){let[n,r]=t.split(`=`).map(e=>e.trim()),i=Number(r);n!==void 0&&Number.isFinite(i)&&(e[n]=i)}let r=n=>e[n]??t;return{left:r(`left`),top:r(`top`),right:r(`right`),bottom:r(`bottom`)}}return{left:t,top:t,right:t,bottom:t}}function ne(e){let t=e;return{x:Number(t.x??0),y:Number(t.y??0)}}function re(e){return e.edges??[]}function ie(e){return[]}function ae(e,t){let n=t.replace(/^N/,``),r=[e];for(;r.length>0;){let e=r.pop();if(e.id===n||e.id===t)return e;for(let t of e.children??[])r.push(t)}return null}function oe(e,t){if(t===void 0)return{x:0,y:0,w:0,h:0};let n=t.replace(/^N/,``),r=ae(e,t);if(r!==null)return{x:r.x??0,y:r.y??0,w:r.width??0,h:r.height??0};let i=n.lastIndexOf(`.`);if(i!==-1){let t=ae(e,n.slice(0,i));if(t!==null){let e=(t.ports??[]).find(e=>e.id===n.slice(i+1)||e.id===`N${n.slice(i+1)}`);return{x:(e?.x??0)+(t.x??0),y:(e?.y??0)+(t.y??0),w:e?.width??0,h:e?.height??0}}}return{x:0,y:0,w:0,h:0}}var b=class e{x;y;constructor(e=0,t=0){this.x=e,this.y=t}clone(){return new e(this.x,this.y)}set(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}scale(e){return this.x*=e,this.y*=e,this}reset(){return this.x=0,this.y=0,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}distance(e){let t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}bound(e,t,n,r){this.x<e?this.x=e:this.x>n&&(this.x=n),this.y<t?this.y=t:this.y>r&&(this.y=r)}wiggle(e,t){let n=2*e.nextDouble()*t-t,r=2*Math.PI*e.nextDouble();this.x+=n*Math.cos(r),this.y+=n*Math.sin(r)}};function se(e,t,n){let r=t/2,i=n/2,a=Math.abs(e.x),o=Math.abs(e.y),s=1,c=1;return a>r&&(s=r/a),o>i&&(c=i/o),e.scale(Math.min(s,c)),e}const x=o.priority.id,ce=o.spacingNodeNode.id,le=o.spacingEdgeLabel.id,ue=o.aspectRatio.id,de=o.randomSeed.id,fe=o.separateConnectedComponents.id,pe=o.padding.id,me=o.interactive.id,he=o.omitNodeMicroLayout.id,ge=o.edgeLabelsInline.id,_e=a.force.forceModel.id,ve=a.force.forceIterations.id,ye=a.force.forceRepulsivePower.id,be=a.force.forceTemperature.id,xe=a.force.forceRepulsion.id,Se=a.force.stressFixed.id,Ce=a.force.stressDesiredEdgeLength.id,we=a.force.stressDimension.id,Te=a.force.stressEpsilon.id,Ee=a.force.stressIterationLimit.id,S={[x]:1,[ce]:80,[le]:5,[ue]:1.6,[de]:1,[fe]:!0,[pe]:50,[me]:!1,[he]:!1,[ge]:!1,[_e]:`FRUCHTERMAN_REINGOLD`,[ve]:300,[ye]:0,[be]:.001,[xe]:5,[Se]:!1,[Ce]:100,[we]:`XY`,[Te]:.001,[Ee]:2147483647};function C(e,t,n){return e.hasProperty(t)?e.getProperty(t):n}function De(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function Oe(e,t){if(typeof e==`number`)return{top:e,left:e,right:e,bottom:e};if(typeof e==`string`){let n=String(e).replace(/[\[\]]/g,``),r={};for(let e of n.split(`,`)){let t=e.indexOf(`=`);if(t!==-1){let n=e.slice(0,t).trim(),i=Number(e.slice(t+1).trim());Number.isFinite(i)&&(r[n]=i)}else{let t=Number(e.trim());Number.isFinite(t)&&(r.top=t,r.left=t,r.right=t,r.bottom=t)}}return{top:r.top??t,left:r.left??t,right:r.right??t,bottom:r.bottom??t}}return{top:t,left:t,right:t,bottom:t}}var ke=class extends i{displacement=new b;position=new b;size=new b;getPosition(){return this.position}getSize(){return this.size}getRadius(){return this.size.length()/2}getDisplacement(){return this.displacement}},Ae=class extends ke{id=0;label;parent;children=null;constructor(e=``,t=null){super(),this.label=e,this.parent=t}isCompound(){return this.children!==null&&this.children.length>0}getLabel(){return this.label}getParent(){return this.parent}getChildren(){return this.children===null&&(this.children=[]),this.children}getDepth(){return this.parent===null?0:this.parent.getDepth()+1}},je=class extends i{bendpoints=[];labels=[];source=null;target=null;getSource(){return this.source}getTarget(){return this.target}setSource(e){this.source=e}setTarget(e){this.target=e}getBendpoints(){return this.bendpoints}getLabels(){return this.labels}getSourcePoint(){let e=this.getTarget().getPosition().clone().sub(this.getSource().getPosition());return se(e,this.getSource().getSize().x,this.getSource().getSize().y),e.add(this.getSource().getPosition())}getTargetPoint(){let e=this.getSource().getPosition().clone().sub(this.getTarget().getPosition());return se(e,this.getTarget().getSize().x,this.getTarget().getSize().y),e.add(this.getTarget().getPosition())}distributeBendpoints(){let e=this.bendpoints.length;if(e>0){let t=this.getSource().getPosition(),n=this.getTarget().getPosition().clone().sub(t).scale(1/(e+1)),r=t.clone();for(let e of this.bendpoints)e.getPosition().x=r.x+n.x,e.getPosition().y=r.y+n.y,r.add(n)}}},Me=class extends ke{edge;text;constructor(e,t){super(),this.edge=e,this.text=t,e.getLabels().push(this)}getText(){return this.text}getEdge(){return this.edge}refreshPosition(){let e=C(this,ge,S[ge]),t=this.edge.getSource().getPosition(),n=this.edge.getTarget().getPosition();if(e){let e=n.clone().sub(t).scale(.5),r=this.getSize().clone().scale(.5),i=t.clone().add(e).sub(r);this.getPosition().set(i)}else{let e=C(this.edge,le,S[le]),r=this.getPosition();t.x>=n.x?t.y>=n.y?(r.x=n.x+(t.x-n.x)/2+e,r.y=n.y+(t.y-n.y)/2-e-this.getSize().y):(r.x=n.x+(t.x-n.x)/2+e,r.y=t.y+(n.y-t.y)/2+e):t.y>=n.y?(r.x=t.x+(n.x-t.x)/2+e,r.y=n.y+(t.y-n.y)/2+e):(r.x=t.x+(n.x-t.x)/2+e,r.y=t.y+(n.y-t.y)/2-e-this.getSize().y)}}},Ne=class extends ke{edge;constructor(e){super(),this.edge=e,e.getBendpoints().push(this)}getEdge(){return this.edge}},Pe=class extends i{nodes=[];edges=[];labels=[];bendpoints=[];adjacency=null;getNodes(){return this.nodes}getEdges(){return this.edges}getLabels(){return this.labels}getBendpoints(){return this.bendpoints}getParticles(){return[...this.nodes,...this.labels,...this.bendpoints]}getConnection(e,t){if(e instanceof Ae&&t instanceof Ae){let n=e,r=t;return(this.adjacency?.[n.id]?.[r.id]??0)+(this.adjacency?.[r.id]?.[n.id]??0)}if(e instanceof Ne&&t instanceof Ne){let n=e,r=t;if(n.getEdge()===r.getEdge())return C(r.getEdge(),x,S[x])}return 0}calcAdjacency(){let e=this.nodes.length;this.adjacency=Array.from({length:e},()=>Array(e).fill(0));for(let e of this.edges)this.adjacency[e.getSource().id][e.getTarget().id]+=C(e,x,S[x])}};const Fe=`force.origin`,Ie=`force.random`,Le=`force.boundingBox.upLeft`,Re=`force.boundingBox.lowRight`;function ze(e,t){for(let[n,r]of Object.entries(t?.layoutOptions??{}))e.setProperty(n,r);for(let[n,r]of Object.entries(t?.properties??{}))e.setProperty(n,r)}function Be(e){return e.split(`.`).length>1?e.slice(0,e.lastIndexOf(`.`)):e}var Ve=class{importGraph(e){let t=new Pe;ze(t,e),t.setProperty(Fe,e);let n=/* @__PURE__ */ new Map;return this.transformNodes(e,t,n),this.transformEdges(e,t,n),t}transformNodes(e,t,n){let r=0;for(let i of e.children??[]){let e=new Ae((i.labels??[])[0]?.text??``);ze(e,i),e.setProperty(Fe,i),e.id=r++,e.getPosition().x=(i.x??0)+(i.width??0)/2,e.getPosition().y=(i.y??0)+(i.height??0)/2,e.getSize().x=Math.max(i.width??0,1),e.getSize().y=Math.max(i.height??0,1),t.getNodes().push(e),n.set(i.id,e)}}transformEdges(e,t,n){for(let r of e.edges??[]){let e=(r.sources??[])[0],i=(r.targets??[])[0];if(e===void 0||i===void 0)continue;let a=n.get(e)??n.get(Be(e)),o=n.get(i)??n.get(Be(i));if(!a||!o)continue;let s=new je;ze(s,r),s.setProperty(Fe,r),s.setSource(a),s.setTarget(o),t.getEdges().push(s);for(let e of r.labels??[]){let n=new Me(s,e.text??``);ze(n,{layoutOptions:e.layoutOptions}),n.setProperty(Fe,e),n.getSize().x=Math.max(e.width??0,1),n.getSize().y=Math.max(e.height??0,1),n.refreshPosition(),t.getLabels().push(n)}}}applyLayout(e){let t=e.getProperty(Fe),n=2**53-1,r=2**53-1,i=-(2**53-1),a=-(2**53-1);for(let t of e.getNodes()){let e=t.getPosition(),o=t.getSize();n=Math.min(n,e.x-o.x/2),r=Math.min(r,e.y-o.y/2),i=Math.max(i,e.x+o.x/2),a=Math.max(a,e.y+o.y/2)}for(let t of e.getBendpoints()){let e=t.getPosition(),o=t.getSize();n=Math.min(n,e.x-o.x/2),r=Math.min(r,e.y-o.y/2),i=Math.max(i,e.x+o.x/2),a=Math.max(a,e.y+o.y/2)}let o=Oe(C(e,pe,S[pe]),S[pe]),s=new b(o.left-n,o.top-r);for(let t of e.getNodes()){let e=t.getProperty(Fe);e&&(e.x=t.getPosition().x+s.x-(e.width??0)/2,e.y=t.getPosition().y+s.y-(e.height??0)/2)}for(let t of e.getEdges()){let e=t.getProperty(Fe);if(!e)continue;let n=(e.sections??[])[0]??{},r=t.getSourcePoint().clone().add(s);n.startPoint={x:r.x,y:r.y},n.endPoint={x:t.getTargetPoint().x+s.x,y:t.getTargetPoint().y+s.y},n.bendPoints=t.getBendpoints().map(e=>({x:e.getPosition().x+s.x,y:e.getPosition().y+s.y})),e.sections===void 0?e.sections=[n]:e.sections[0]=n}for(let t of e.getLabels()){let e=t.getProperty(Fe);e&&(e.x=t.getPosition().x+s.x,e.y=t.getPosition().y+s.y)}let c=i-n+o.left+o.right,l=a-r+o.top+o.bottom;t.width=c,t.height=l}},He=class{split(e){if(!C(e,fe,S[fe]))return[e];let t=e.getNodes().length,n=Array(t).fill(!1),r=Array.from({length:t},()=>[]);for(let t of e.getEdges())r[t.getSource().id].push(t),r[t.getTarget().id].push(t);let i=[];for(let t of e.getNodes()){let a=this.dfs(t,null,null,n,r);a!==null&&(a.copyProperties(e),i.push(a))}if(i.length>1)for(let e of i){let t=0;for(let n of e.getNodes())n.id=t++}return i}dfs(e,t,n,r,i){if(!r[e.id]){r[e.id]=!0;let a=n;a===null&&(a=new Pe),a.getNodes().push(e);for(let n of i[e.id])n.getTarget()!==t&&n.getSource()!==t&&(n.getSource()!==e&&this.dfs(n.getSource(),e,a,r,i),n.getTarget()!==e&&this.dfs(n.getTarget(),e,a,r,i),a.getEdges().push(n),a.getLabels().push(...n.getLabels()));return a}return null}recombine(e){if(e.length===1)return e[0];if(e.length<=0)return new Pe;for(let t of e){let e=0,n=2**53-1,r=2**53-1,i=-(2**53-1),a=-(2**53-1);for(let o of t.getNodes())e+=C(o,x,S[x]),n=Math.min(n,o.getPosition().x-o.getSize().x/2),r=Math.min(r,o.getPosition().y-o.getSize().y/2),i=Math.max(i,o.getPosition().x+o.getSize().x/2),a=Math.max(a,o.getPosition().y+o.getSize().y/2);t.setProperty(x,e),t.setProperty(Le,new b(n,r)),t.setProperty(Re,new b(i,a))}e.sort((e,t)=>{let n=C(t,x,0)-C(e,x,0);return n===0?(e.getProperty(Re).x-e.getProperty(Le).x)*(e.getProperty(Re).y-e.getProperty(Le).y)-(t.getProperty(Re).x-t.getProperty(Le).x)*(t.getProperty(Re).y-t.getProperty(Le).y):n});let t=new Pe;t.copyProperties(e[0]);let n=0,r=0;for(let t of e){let e=this.sizeOf(t);n=Math.max(n,e.x),r+=e.x*e.y}n=Math.max(n,Math.sqrt(r));let i=C(t,ce,S[ce]),a=0,o=0,s=0,c=i;for(let r of e){let e=this.sizeOf(r);a+e.x>n&&(a=0,o+=s+i,s=0),this.moveGraph(t,r,a,o),c=Math.max(c,a+e.x),s=Math.max(s,e.y),a+=e.x+i}return t}sizeOf(e){let t=e.getProperty(Re),n=e.getProperty(Le);return{x:t.x-n.x,y:t.y-n.y}}moveGraph(e,t,n,r){let i=new b(n,r);i.sub(t.getProperty(Le));for(let n of t.getNodes())n.getPosition().add(i),e.getNodes().push(n);for(let n of t.getEdges()){for(let e of n.getBendpoints())e.getPosition().add(i);e.getEdges().push(n)}for(let n of t.getLabels())n.getPosition().add(i),e.getLabels().push(n)}},Ue=class{graph;apsp=[];w=[];desiredEdgeLength=S[Ce];dim=`XY`;epsilon=S[Te];iterationLimit=S[Ee];connectedEdges=/* @__PURE__ */ new Map;initialize(e){if(e.getNodes().length<=1)return;this.graph=e,this.dim=C(e,we,S[we]),this.iterationLimit=C(e,Ee,S[Ee]),this.epsilon=C(e,Te,S[Te]),this.desiredEdgeLength=C(e,Ce,S[Ce]),this.connectedEdges.clear();for(let t of e.getEdges()){let e=t.getSource(),n=t.getTarget();this.connectedEdges.has(e)||this.connectedEdges.set(e,[]),this.connectedEdges.has(n)||this.connectedEdges.set(n,[]),this.connectedEdges.get(e).push(t),this.connectedEdges.get(n).push(t)}let t=e.getNodes().length;this.apsp=Array.from({length:t},()=>Array(t).fill(0));for(let t of e.getNodes())this.dijkstra(t,this.apsp[t.id]);this.w=Array.from({length:t},()=>Array(t).fill(0));for(let e=0;e<t;e++)for(let n=0;n<t;n++){let t=this.apsp[e][n];this.w[e][n]=1/(t*t)}}execute(){if(this.graph.getNodes().length<=1)return;let e=0,t=this.computeStress(),n=1/0;do{e>0&&(t=n);for(let e of this.graph.getNodes()){if(C(e,Se,S[Se]))continue;let t=this.computeNewPosition(e);e.getPosition().reset().add(t)}n=this.computeStress()}while(!this.done(e++,t,n))}dijkstra(e,t){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set;t[e.id]=0;for(let r of this.graph.getNodes())r.id!==e.id&&(t[r.id]=2**53-1),n.add(r);for(;n.size>0;){let e=null,i=1/0;for(let r of n)t[r.id]<i&&(i=t[r.id],e=r);if(e===null)break;n.delete(e),r.add(e);for(let n of this.connectedEdges.get(e)??[]){let i=this.getOther(n,e);if(r.has(i))continue;let a=n.hasProperty(Ce)?n.getProperty(Ce):this.desiredEdgeLength,o=t[e.id]+a;o<t[i.id]&&(t[i.id]=o)}}}done(e,t,n){return t===0||(t-n)/t<this.epsilon||e>=this.iterationLimit}computeStress(){let e=0,t=this.graph.getNodes();for(let n=0;n<t.length;n++){let r=t[n];for(let i=n+1;i<t.length;i++){let n=t[i],a=r.getPosition().distance(n.getPosition())-this.apsp[r.id][n.id];e+=this.w[r.id][n.id]*a*a}}return e}computeNewPosition(e){let t=0,n=0,r=0;for(let i of this.graph.getNodes()){if(e===i)continue;let a=this.w[e.id][i.id];t+=a;let o=e.getPosition().distance(i.getPosition());o>0&&this.dim!==`Y`&&(n+=a*(i.getPosition().x+this.apsp[e.id][i.id]*(e.getPosition().x-i.getPosition().x)/o)),o>0&&this.dim!==`X`&&(r+=a*(i.getPosition().y+this.apsp[e.id][i.id]*(e.getPosition().y-i.getPosition().y)/o))}switch(this.dim){case`X`:return new b(n/t,e.getPosition().y);case`Y`:return new b(e.getPosition().x,r/t);default:return new b(n/t,r/t)}}getOther(e,t){if(e.getSource()===t)return e.getTarget();if(e.getTarget()===t)return e.getSource();throw Error(`Node 'one' must be either source or target of edge 'edge'.`)}},We=class{random;graph;dispBound=0;initialize(e){if(this.graph=e,this.random=e.getProperty(Ie),e.calcAdjacency(),this.dispBound=Math.max(e.getNodes().length*16+e.getEdges().length,256),!C(e,me,S[me])){let t=e.getNodes().length;for(let n of e.getNodes()){let e=n.getPosition();e.x=this.random.nextDouble()*t,e.y=this.random.nextDouble()*t}}let t=e.getBendpoints();for(let n of e.getEdges()){let e=C(n,ye,S[ye]);if(e>0){for(let r=0;r<e;r++)t.push(new Ne(n));n.distributeBendpoints()}}}getGraph(){return this.graph}getRandom(){return this.random}layout(e){this.initialize(e);let t=0;for(;this.moreIterations(t);){this.iterationDone();for(let t of e.getParticles())for(let n of e.getParticles())if(n!==t){let e=this.calcDisplacement(n,t);e!==null&&t.getDisplacement().add(e)}for(let t of e.getParticles()){let e=t.getDisplacement();e.bound(-this.dispBound,-this.dispBound,this.dispBound,this.dispBound),t.getPosition().add(e),e.reset()}t++}}iterationDone(){for(let e of this.graph.getEdges()){for(let t of e.getLabels())t.refreshPosition();e.distributeBendpoints()}}static avoidSamePosition(e,t,n){let r=t.getPosition(),i=n.getPosition();for(;r.x-i.x===0&&r.y-i.y===0;)if(t instanceof Ne&&n instanceof Ne){let e=t.getEdge(),i=e.getTargetPoint().clone().sub(e.getSourcePoint()),a=new b(i.x/i.length()*2,-i.y/i.length()*2);r.add(a);let o=n.getEdge(),s=o.getTargetPoint().clone().sub(o.getSourcePoint()),c=i===s?-2:2,l=new b(s.x/s.length()*c,-s.y/s.length()*c);r.add(l)}else r.wiggle(e,1),i.wiggle(e,1)}},Ge=class e extends We{static ZERO_FACTOR=100;maxIterations=S[ve];springLength=S[ce];repulsionFactor=S[xe];initialize(e){super.initialize(e),this.maxIterations=C(e,ve,S[ve]),this.springLength=C(e,ce,S[ce]),this.repulsionFactor=C(e,xe,S[xe])}moreIterations(e){return e<this.maxIterations}calcDisplacement(t,n){We.avoidSamePosition(this.getRandom(),t,n);let r=n.getPosition().clone().sub(t.getPosition()),i=r.length(),a=Math.max(0,i-t.getRadius()-n.getRadius()),o,s=this.getGraph().getConnection(t,n);return o=s>0?-e.attractive(a,this.springLength)*s:e.repulsive(a,this.repulsionFactor)*C(t,x,S[x]),r.scale(o/i),r}static repulsive(t,n){return t>0?n/(t*t):n*e.ZERO_FACTOR}static attractive(t,n){return t>0?Math.log(t/n):-e.ZERO_FACTOR}},Ke=class e extends We{static SPACING_FACTOR=.01;static ZERO_FACTOR=100;temperature=S[be];threshold=0;k=0;initialize(t){super.initialize(t),this.temperature=C(t,be,S[be]),this.threshold=this.temperature/C(t,ve,S[ve]);let n=t.getNodes().length,r=0,i=0;for(let e of t.getNodes())r+=e.getSize().x,i+=e.getSize().y;let a=r*i,o=C(t,ce,S[ce])*e.SPACING_FACTOR;this.k=Math.sqrt(a/(2*n))*o}moreIterations(){return this.temperature>0}calcDisplacement(t,n){We.avoidSamePosition(this.getRandom(),t,n);let r=n.getPosition().clone().sub(t.getPosition()),i=r.length(),a=Math.max(0,i-t.getRadius()-n.getRadius()),o=e.repulsive(a,this.k)*C(t,x,S[x]),s=this.getGraph().getConnection(t,n);return s>0&&(o-=e.attractive(a,this.k)*s),r.scale(o*this.temperature/i),r}iterationDone(){super.iterationDone(),this.temperature-=this.threshold}static repulsive(t,n){return t>0?n*n/t:n*n*e.ZERO_FACTOR}static attractive(e,t){return e*e/t}};function qe(e){switch(e){case`EADES`:return new Ge;default:return new Ke}}function w(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function Je(e){if(typeof e!=`string`||e===``)return{};let t={};for(let n of e.split(`;,;`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r!==``&&(t[r]=i)}return t}function Ye(e,t){return e===t||e.endsWith(`.`+t)||t===e.replace(/^org\.eclipse\.elk\./,``)}function Xe(e,t,n){for(let[e,r]of Object.entries(Je(w(t,`org.eclipse.elk.spacing.individual`))))if(Ye(n,e))return r;if(e!==void 0){let t=w(e,n);if(t!=null&&t!==``)return t}}function Ze(e,t,n,r){let i=Xe(e,t,n);if(i==null||i===``)return r;let a=Number(i);return Number.isFinite(a)?a:r}const Qe=`org.eclipse.elk.nodeLabels.placement`,$e=`org.eclipse.elk.spacing.portPort`,et={NORTH:`org.eclipse.elk.portAlignment.north`,EAST:`org.eclipse.elk.portAlignment.east`,SOUTH:`org.eclipse.elk.portAlignment.south`,WEST:`org.eclipse.elk.portAlignment.west`},tt={UNDEFINED:0,NORTH:1,EAST:2,SOUTH:3,WEST:4};function nt(e){if(Array.isArray(e))return e.map(String);if(typeof e==`string`){let t=e.match(/^\[(.*)\]$/);return(t?t[1]:e).split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}return[]}function T(e){let t=w(e,`org.eclipse.elk.port.side`);return typeof t==`string`&&t.trim()!==``?t.trim().toUpperCase():`UNDEFINED`}function rt(e){let t=w(e,`org.eclipse.elk.portConstraints`);if(typeof t==`string`){let e=t.trim().toUpperCase();if([`UNDEFINED`,`FREE`,`FIXED_SIDE`,`FIXED_SIDES`,`FIXED_ORDER`,`FIXED_RATIO`,`FIXED_POS`].includes(e))return e}return`UNDEFINED`}function it(e){return nt(w(e,`org.eclipse.elk.nodeSize.constraints`))}function at(e,t){let n=w(e,et[t]),r=w(e,`org.eclipse.elk.portAlignment.default`),i=n??r;if(typeof i==`string`){let e=i.trim().toUpperCase();if([`BEGIN`,`CENTER`,`END`,`DISTRIBUTED`,`JUSTIFIED`].includes(e))return e}return`DISTRIBUTED`}function ot(e,t){let n=Xe(e,t,`org.eclipse.elk.spacing.portsSurrounding`),r=e=>{if(typeof n==`object`&&n){let t=n;return typeof t[e]==`number`?t[e]:0}return 0};if(typeof n==`string`){let e={};for(let t of n.replace(/^\[|\]$/g,``).split(`,`)){let[n,r]=t.split(`=`).map(e=>e.trim()),i=Number(r);n!==void 0&&Number.isFinite(i)&&(e[n]=i)}return{top:e.top??0,left:e.left??0,right:e.right??0,bottom:e.bottom??0}}return{top:r(`top`),left:r(`left`),right:r(`right`),bottom:r(`bottom`)}}function st(e,t){let n=Xe(e,t,`org.eclipse.elk.nodeLabels.padding`);if(typeof n==`number`)return{top:n,left:n,right:n,bottom:n};if(typeof n==`string`){let e={};for(let t of n.replace(/^\[|\]$/g,``).split(`,`)){let[n,r]=t.split(`=`).map(e=>e.trim()),i=Number(r);n!==void 0&&Number.isFinite(i)&&(e[n]=i)}let t=t=>e[t]??5;return{top:t(`top`),left:t(`left`),right:t(`right`),bottom:t(`bottom`)}}return{top:5,left:5,right:5,bottom:5}}function ct(e){for(let t of e.children??[])lt(e,t)}function lt(e,t){let n=t.ports??[],r=t.labels??[];if((t.children?.length??0)>0||n.length===0&&r.length===0)return;for(let e of n)if(T(e)===`UNDEFINED`)throw Error(`[elk-common] Label and node size calculator can only be used with ports that have port sides assigned.`);let i=rt(t);(i===`FIXED_ORDER`||i===`FIXED_RATIO`||i===`FIXED_POS`)&&ut(n);let a=t.width??0,o=t.height??0,s=it(t);if(!(s.length===0||s.length===1&&s[0]===`PORT_LABELS`)){let i=dt(e,t,n,r,s);a=i.w,o=i.h,t.width=a,t.height=o}i!==`FIXED_POS`&&i!==`FIXED_RATIO`&&mt(e,t,n,i,a,o),vt(e,t,r,a,o),bt(t,a,o)}function ut(e){let t=e=>{let t=w(e,`org.eclipse.elk.portIndex`);if(t==null)return null;let n=Number(t);return Number.isFinite(n)?n:null};e.sort((e,n)=>{let r=T(e),i=T(n),a=(tt[r]??0)-(tt[i]??0);if(a!==0)return a;let o=t(e),s=t(n);if(o!==null&&s!==null&&o!==s)return o-s;let c=e.x??0,l=e.y??0,u=n.x??0,d=n.y??0;switch(r){case`NORTH`:return c-u;case`EAST`:return l-d;case`SOUTH`:return u-c;case`WEST`:return d-l;default:return 0}})}function dt(e,t,n,r,i){let a=Ze(e,t,$e,10),o=ot(e,t),s=st(e,t),c=0,l=0;if(i.includes(`NODE_LABELS`)){let n=Ze(e,t,`org.eclipse.elk.spacing.labelLabel`,0),i=2*n,a=nt(w(t,`org.eclipse.elk.nodeSize.options`)),o=!a.includes(`ASYMMETRICAL`),u=a.includes(`OUTSIDE_NODE_LABELS_OVERHANG`),d=(e,t,n)=>{let r=e??{w:0,h:0,n:0};return r.w=Math.max(r.w,t),r.h+=n,r.n+=1,r},f=/* @__PURE__ */ new Map;for(let e of r){let n=_t(t,e);if(!n.startsWith(`IN_`))continue;let r=n.split(`_`),i=`TCB`.indexOf(r[1]??``),a=`LCR`.indexOf(r[2]??``);if(i<0||a<0)continue;let o=`${i}${a}`;f.set(o,{row:i,col:a,...d(f.get(o),e.width??0,e.height??0)})}if(f.size>0){let e=[[0,0,0],[0,0,0],[0,0,0]],t=[0,0,0];for(let r of f.values())e[r.row][r.col]=Math.max(e[r.row][r.col],r.w),t[r.row]=Math.max(t[r.row],r.h+Math.max(0,r.n-1)*n);let r=0;for(let t of e){if(o){let e=Math.max(t[0],t[2]);t[0]=e,t[2]=e}r=Math.max(r,ft(t,i))}if(o){let e=Math.max(t[0],t[2]);t[0]=e,t[2]=e}let a=ft(t,i);r>0&&(c=Math.max(c,r+s.left+s.right)),a>0&&(l=Math.max(l,a+s.top+s.bottom))}if(!u){let e={N:[void 0,void 0,void 0],S:[void 0,void 0,void 0]},a={W:[void 0,void 0,void 0],E:[void 0,void 0,void 0]};for(let n of r){let r=_t(t,n);if(r.startsWith(`IN_`))continue;let i=r.split(`_`),o=i[1]??``,s=i[2]??``;if(o===`T`||o===`B`){let t=`LCR`.indexOf(s);if(t<0)continue;let r=o===`T`?`N`:`S`;e[r][t]=d(e[r][t],n.width??0,n.height??0)}else if(o===`L`||o===`R`){let e=`TCB`.indexOf(s);if(e<0)continue;let t=o===`L`?`W`:`E`;a[t][e]=d(a[t][e],n.width??0,n.height??0)}}let s=0;for(let t of[`N`,`S`]){let n=e[t].map(e=>e?.w??0);if(o){let e=Math.max(n[0],n[2]);n[0]=e,n[2]=e}s=Math.max(s,ft(n,i))}let u=0;for(let e of[`W`,`E`]){let t=a[e].map(e=>e?e.h+Math.max(0,e.n-1)*n:0);if(o){let e=Math.max(t[0],t[2]);t[0]=e,t[2]=e}u=Math.max(u,ft(t,i))}c=Math.max(c,s),l=Math.max(l,u)}}if(i.includes(`PORTS`)){for(let e of[`NORTH`,`SOUTH`]){let r=n.filter(t=>T(t)===e);if(r.length===0)continue;let i=at(t,e),s=pt(r.map(e=>e.width??0),a,i)+o.left+o.right;c=Math.max(c,s)}for(let e of[`EAST`,`WEST`]){let r=n.filter(t=>T(t)===e);if(r.length===0)continue;let i=at(t,e),s=pt(r.map(e=>e.height??0),a,i)+o.top+o.bottom;l=Math.max(l,s)}}return{w:c,h:l}}function ft(e,t){let n=0,r=0;for(let t of e)t>0&&(n+=t,r++);return r>1?n+t*(r-1):n}function pt(e,t,n){if(e.length===0)return 0;let r=e.reduce((e,t)=>e+t,0);return e.length>1&&(r+=(e.length-1)*t),n===`DISTRIBUTED`&&(r+=2*t),r}function mt(e,t,n,r,i,a){let o=Ze(e,t,$e,10),s=ot(e,t);for(let e of[`NORTH`,`SOUTH`]){let r=e===`SOUTH`?[...n.filter(t=>T(t)===e)].reverse():n.filter(t=>T(t)===e),c=ht(r,i,o,s.left,s.right,at(t,e),e=>e.width??0);for(let t=0;t<r.length;t++){let n=r[t];n.x=c[t],n.y=e===`NORTH`?-(n.height??0):a}}for(let e of[`EAST`,`WEST`]){let r=e===`WEST`?[...n.filter(t=>T(t)===e)].reverse():n.filter(t=>T(t)===e),c=ht(r,a,o,s.top,s.bottom,at(t,e),e=>e.height??0);for(let t=0;t<r.length;t++){let n=r[t];n.y=c[t],n.x=e===`WEST`?-(n.width??0):i}}}function ht(e,t,n,r,i,a,o){let s=e.length;if(s===0)return[];let c=e.map(o),l=c.reduce((e,t)=>e+t,0);s>1&&(l+=(s-1)*n),a===`DISTRIBUTED`&&(l+=2*n);let u=t-r-i,d=r,f=n,p=a,m=l;if((p===`DISTRIBUTED`||p===`JUSTIFIED`)&&s===1&&(p===`DISTRIBUTED`&&(m=l-2*n),p=`CENTER`),u<m)p===`DISTRIBUTED`?(f+=(u-m)/(s+1),d+=f):f+=(u-m)/(s-1);else switch(p){case`BEGIN`:break;case`CENTER`:d+=(u-m)/2;break;case`END`:d+=u-m;break;case`DISTRIBUTED`:{let e=(u-m)/(s+1);f+=Math.max(0,e),d+=f;break}case`JUSTIFIED`:{let e=(u-m)/(s-1);f+=Math.max(0,e);break}}let h=[];for(let e=0;e<s;e++)h.push(d),d+=c[e]+f;return h}function gt(e,t){let n=w(t,Qe);return nt(n===void 0?w(e,Qe):n)}function _t(e,t){let n=[...gt(e,t)].sort().join(` `);for(let{loc:e,sets:t}of[{loc:`OUT_T_L`,sets:[[`OUTSIDE`,`V_TOP`,`H_LEFT`]]},{loc:`OUT_T_C`,sets:[[`OUTSIDE`,`V_TOP`,`H_CENTER`],[`OUTSIDE`,`V_TOP`,`H_CENTER`,`H_PRIORITY`]]},{loc:`OUT_T_R`,sets:[[`OUTSIDE`,`V_TOP`,`H_RIGHT`]]},{loc:`OUT_B_L`,sets:[[`OUTSIDE`,`V_BOTTOM`,`H_LEFT`]]},{loc:`OUT_B_C`,sets:[[`OUTSIDE`,`V_BOTTOM`,`H_CENTER`],[`OUTSIDE`,`V_BOTTOM`,`H_CENTER`,`H_PRIORITY`]]},{loc:`OUT_B_R`,sets:[[`OUTSIDE`,`V_BOTTOM`,`H_RIGHT`]]},{loc:`OUT_L_T`,sets:[[`OUTSIDE`,`H_LEFT`,`V_TOP`,`H_PRIORITY`]]},{loc:`OUT_L_C`,sets:[[`OUTSIDE`,`H_LEFT`,`V_CENTER`],[`OUTSIDE`,`H_LEFT`,`V_CENTER`,`H_PRIORITY`]]},{loc:`OUT_L_B`,sets:[[`OUTSIDE`,`H_LEFT`,`V_BOTTOM`,`H_PRIORITY`]]},{loc:`OUT_R_T`,sets:[[`OUTSIDE`,`H_RIGHT`,`V_TOP`,`H_PRIORITY`]]},{loc:`OUT_R_C`,sets:[[`OUTSIDE`,`H_RIGHT`,`V_CENTER`],[`OUTSIDE`,`H_RIGHT`,`V_CENTER`,`H_PRIORITY`]]},{loc:`OUT_R_B`,sets:[[`OUTSIDE`,`H_RIGHT`,`V_BOTTOM`,`H_PRIORITY`]]},{loc:`IN_T_L`,sets:[[`INSIDE`,`V_TOP`,`H_LEFT`],[`INSIDE`,`V_TOP`,`H_LEFT`,`H_PRIORITY`]]},{loc:`IN_T_C`,sets:[[`INSIDE`,`V_TOP`,`H_CENTER`],[`INSIDE`,`V_TOP`,`H_CENTER`,`H_PRIORITY`]]},{loc:`IN_T_R`,sets:[[`INSIDE`,`V_TOP`,`H_RIGHT`],[`INSIDE`,`V_TOP`,`H_RIGHT`,`H_PRIORITY`]]},{loc:`IN_C_L`,sets:[[`INSIDE`,`V_CENTER`,`H_LEFT`],[`INSIDE`,`V_CENTER`,`H_LEFT`,`H_PRIORITY`]]},{loc:`IN_C_C`,sets:[[`INSIDE`,`V_CENTER`,`H_CENTER`],[`INSIDE`,`V_CENTER`,`H_CENTER`,`H_PRIORITY`]]},{loc:`IN_C_R`,sets:[[`INSIDE`,`V_CENTER`,`H_RIGHT`],[`INSIDE`,`V_CENTER`,`H_RIGHT`,`H_PRIORITY`]]},{loc:`IN_B_L`,sets:[[`INSIDE`,`V_BOTTOM`,`H_LEFT`],[`INSIDE`,`V_BOTTOM`,`H_LEFT`,`H_PRIORITY`]]},{loc:`IN_B_C`,sets:[[`INSIDE`,`V_BOTTOM`,`H_CENTER`],[`INSIDE`,`V_BOTTOM`,`H_CENTER`,`H_PRIORITY`]]},{loc:`IN_B_R`,sets:[[`INSIDE`,`V_BOTTOM`,`H_RIGHT`],[`INSIDE`,`V_BOTTOM`,`H_RIGHT`,`H_PRIORITY`]]}])for(let r of t)if([...r].sort().join(` `)===n)return e;return`UNDEFINED`}function vt(e,t,n,r,i){let a=st(e,t),o=Ze(e,t,`org.eclipse.elk.spacing.labelNode`,5),s=Ze(e,t,`org.eclipse.elk.spacing.labelLabel`,0),c=/* @__PURE__ */ new Map;for(let e of n){let n=_t(t,e);if(!n.startsWith(`IN_`))continue;let r=c.get(n)??[];r.push(e),c.set(n,r)}let l=a.left,u=a.top,d=Math.max(0,r-a.left-a.right),f=Math.max(0,i-a.top-a.bottom);for(let[e,t]of c){let n=e.split(`_`)[1],r=e.split(`_`)[2],i=t.reduce((e,t)=>e+(t.height??0),0)+Math.max(0,t.length-1)*s,a;a=n===`T`?u:n===`B`?u+f-i:u+(f-i)/2;for(let e of t){let t=e.width??0,n=e.height??0,i;i=r===`L`?l:r===`R`?l+d-t:l+(d-t)/2,e.x=i,e.y=a,a+=n+s}}for(let e of n){let n=_t(t,e);if(n.startsWith(`IN_`))continue;let a=e.width??0,s=e.height??0,c,l;switch(n){case`OUT_T_L`:c=0,l=-(s+o);break;case`OUT_T_C`:c=(r-a)/2,l=-(s+o);break;case`OUT_T_R`:c=r-a,l=-(s+o);break;case`OUT_B_L`:c=0,l=i+o;break;case`OUT_B_C`:c=(r-a)/2,l=i+o;break;case`OUT_B_R`:c=r-a,l=i+o;break;case`OUT_L_T`:c=-(a+o),l=0;break;case`OUT_L_C`:c=-(a+o),l=(i-s)/2;break;case`OUT_L_B`:c=-(a+o),l=i-s;break;case`OUT_R_T`:c=r+o,l=0;break;case`OUT_R_C`:c=r+o,l=(i-s)/2;break;case`OUT_R_B`:c=r+o,l=i-s;break;default:continue}e.x=c,e.y=l}}function yt(e,t,n,r,i){if(r<=0&&i<=0)return;let a=Math.min(e.x,t),o=Math.min(e.y,n),s=Math.max(e.x+e.w,t+r),c=Math.max(e.y+e.h,n+i);e.x=a,e.y=o,e.w=s-a,e.h=c-o}function bt(e,t,n){let r={x:0,y:0,w:t,h:n};for(let t of e.labels??[])yt(r,t.x??0,t.y??0,t.width??0,t.height??0);for(let t of e.ports??[])yt(r,t.x??0,t.y??0,t.width??0,t.height??0);let i={top:Math.max(0,-r.y),bottom:Math.max(0,r.y+r.h-n),left:Math.max(0,-r.x),right:Math.max(0,r.x+r.w-t)};e.layoutOptions={...e.layoutOptions,"org.eclipse.elk.margins":i}}function xt(t,n){let r=Number(De(n,de)??1);t.setProperty(Ie,r===0?new e:new e(r))}function St(e){(De(e,he)??!1)||ct(e);let t=new Ve,n=t.importGraph(e);xt(n,e);let r=qe(De(e,_e)??`FRUCHTERMAN_REINGOLD`),i=new He().split(n);for(let e of i)r.layout(e);return n=new He().recombine(i),t.applyLayout(n),e}function Ct(e){De(e,me)??!1?(De(e,he)??!1)||ct(e):St(e);let t=new Ve,n=t.importGraph(e),r=new He().split(n),i=new Ue;for(let e of r)if(!(e.getNodes().length<=1)){i.initialize(e),i.execute();for(let t of e.getLabels())t.refreshPosition()}return n=new He().recombine(r),t.applyLayout(n),e}const wt=o.aspectRatio.id,Tt=o.padding.id,Et=o.spacingNodeNode.id,Dt=o.nodeSizeFixedGraphSize.id,Ot=o.nodeSizeConstraints.id,kt=o.nodeSizeMinimum.id,At=o.contentAlignment.id,jt=o.interactive.id,Mt=o.omitNodeMicroLayout.id,Nt=o.priority.id,Pt=a.rectpacking.widthApproximationStrategy.id,Ft=a.rectpacking.widthApproximationTargetWidth.id,It=a.rectpacking.widthApproximationOptimizationGoal.id,Lt=a.rectpacking.widthApproximationLastPlaceShift.id,Rt=a.rectpacking.packingStrategy.id,zt=a.rectpacking.packingCompactionRowHeightReevaluation.id,Bt=a.rectpacking.packingCompactionIterations.id,Vt=a.rectpacking.whiteSpaceEliminationStrategy.id,Ht=a.rectpacking.trybox.id,Ut=a.rectpacking.orderBySize.id,Wt=a.rectpacking.desiredPosition.id,Gt=a.rectpacking.currentPosition.id,Kt=a.rectpacking.inNewRow.id,qt={[wt]:1.3,[Tt]:15,[Et]:15,[Dt]:!1,[At]:`topLeft`,[jt]:!1,[Mt]:!1,[Pt]:`GREEDY`,[Ft]:-1,[It]:`MAX_SCALE_DRIVEN`,[Lt]:!0,[Rt]:`COMPACTION`,[zt]:!1,[Bt]:1,[Vt]:`NONE`,[Ht]:!1,[Ut]:!1,[Wt]:-1,[Gt]:-1,[Kt]:!1};function E(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function D(e,t){let n=E(e,t);if(n==null||n===``)return qt[t];let r=Number(n);return Number.isFinite(r)?r:qt[t]}function Jt(e,t,n){let r=E(e,t);return r==null||r===``?n:String(r)===`true`}function Yt(e,t,n){let r=E(e,t);return r==null||r===``?n:String(r)}function Xt(e){let t=E(e,Tt);if(typeof t==`number`)return{top:t,left:t,right:t,bottom:t};if(typeof t==`string`){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}let n=t=>e[t]??qt[Tt];return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return{top:qt[Tt],left:qt[Tt],right:qt[Tt],bottom:qt[Tt]}}var Zt=class{scaleMeasure=0;drawingWidth;drawingHeight;area=0;aspectRatio=0;dar;placementOption;nextXcoordinate;nextYcoordinate;constructor(e,t,n,r,i=0,a=0){this.dar=e,this.drawingWidth=t,this.drawingHeight=n,this.placementOption=r,this.nextXcoordinate=i,this.nextYcoordinate=a,this.calcAreaAspectRatioScaleMeasure()}calcAreaAspectRatioScaleMeasure(){this.drawingWidth>0&&this.drawingHeight>0&&(this.area=this.drawingWidth*this.drawingHeight,this.aspectRatio=this.drawingWidth/this.drawingHeight,this.scaleMeasure=O.computeScaleMeasure(this.drawingWidth,this.drawingHeight,this.dar))}getScaleMeasure(){return this.scaleMeasure}getArea(){return this.area}getAspectRatio(){return this.aspectRatio}getPlacementOption(){return this.placementOption}setPlacementOption(e){this.placementOption=e}getNextXcoordinate(){return this.nextXcoordinate}setNextXcoordinate(e){this.nextXcoordinate=e}getNextYcoordinate(){return this.nextYcoordinate}setNextYcoordinate(e){this.nextYcoordinate=e}getDesiredAspectRatio(){return this.dar}getDrawingWidth(){return this.drawingWidth}setDrawingWidth(e){this.drawingWidth=e,this.calcAreaAspectRatioScaleMeasure()}getDrawingHeight(){return this.drawingHeight}setDrawingHeight(e){this.drawingHeight=e,this.calcAreaAspectRatioScaleMeasure()}};const O={computeScaleMeasure(e,t,n){return Math.min(n/e,1/t)},resetCoordinates(e){for(let t of e)t.x=0,t.y=0},calculateDimensionsRows(e,t){let n=0,r=0,i=0;for(let a of e)n=Math.max(n,a.getWidth()),r+=a.getHeight()+(i>0?t:0),i++;return{x:n,y:r}},calculateDimensions(e){let t=0,n=0;for(let r of e)t=Math.max((r.width??0)+(r.x??0),t),n=Math.max((r.height??0)+(r.y??0),n);return{x:t,y:n}}};var Qt=class{additionalHeight=0;drawingHeight=0;drawingWidth=0;minHeight=0;minWidth=0;rows=[];targetWidth=0;minRowIncrease=0;maxRowIncrease=0;minRowDecrease=0;maxRowDecrease=0};const $t={getWidthLPRorLPB(e,t,n){return Math.max(e,t+n)},getHeightLPRorLPB(e,t,n){return Math.max(e,t+n)},calculateYforLPR(e,t,n,r){let i=null,a=0;for(let o of t){let t=(o.y??0)+(o.height??0);this.verticalOrderConstraint(o,e,r)&&((i===null||(n.y??0)-t<(n.y??0)-a)&&(i=o),a=(i.y??0)+(i.height??0))}return i===null?0:a+r},calculateXforLPB(e,t,n,r){let i=null,a=0;for(let o of t){let t=(o.x??0)+(o.width??0);this.horizontalOrderConstraint(o,e,r)&&((i===null||(n.x??0)-t<(n.x??0)-a)&&(i=o),a=(i.x??0)+(i.width??0))}return i===null?0:a+r},calculateAreaLPR(e,t,n){let r=(e.y??0)+(e.height??0),i=n.getNextYcoordinate()+(t.height??0),a=Math.max(r,i)-Math.min(e.y??0,n.getNextYcoordinate());return(n.getNextXcoordinate()+(t.width??0)-(e.x??0))*a},calculateAreaLPB(e,t,n){let r=(e.x??0)+(e.width??0),i=n.getNextXcoordinate()+(t.width??0);return(Math.max(r,i)-Math.min(e.x??0,n.getNextXcoordinate()))*(n.getNextYcoordinate()+(t.height??0)-(e.y??0))},verticalOrderConstraint(e,t,n){return t<(e.x??0)+(e.width??0)+n},horizontalOrderConstraint(e,t,n){return t<(e.y??0)+(e.height??0)+n}},en=(e,t,n)=>{let r=1/0;for(let t of e)r=Math.min(r,(t.getDrawingWidth()+n.left+n.right)*(t.getDrawingHeight()+n.top+n.bottom));return e.filter(e=>(e.getDrawingWidth()+n.left+n.right)*(e.getDrawingHeight()+n.top+n.bottom)===r)},tn=(e,t,n)=>{let r=1/0;for(let i of e)r=Math.min(r,Math.abs((i.getDrawingWidth()+n.left+n.right)/(i.getDrawingHeight()+n.top+n.bottom)-t));return e.filter(e=>Math.abs((e.getDrawingWidth()+n.left+n.right)/(e.getDrawingHeight()+n.top+n.bottom)-t)===r)},nn=(e,t,n)=>{let r=-1/0;for(let t of e)r=Math.max(r,O.computeScaleMeasure(t.getDrawingWidth()+n.left+n.right,t.getDrawingHeight()+n.top+n.bottom,t.getDesiredAspectRatio()));return e.filter(e=>O.computeScaleMeasure(e.getDrawingWidth()+n.left+n.right,e.getDrawingHeight()+n.top+n.bottom,e.getDesiredAspectRatio())===r)};var rn=class{aspectRatio;goal;lpShift;constructor(e,t,n){this.aspectRatio=e,this.goal=t,this.lpShift=n}approxBoundingBox(e,t,n){let r=e[0];r.x=0,r.y=0;let i=[r],a=r,o=new Zt(this.aspectRatio,r.width??0,r.height??0,`WHOLE_DRAWING`);for(let r=1;r<e.length;r++){let s=e[r],c=this.calcValuesForOpt(`CANDIDATE_POSITION_LAST_PLACED_RIGHT`,s,a,o,i,t),l=this.calcValuesForOpt(`CANDIDATE_POSITION_LAST_PLACED_BELOW`,s,a,o,i,t),u=this.calcValuesForOpt(`CANDIDATE_POSITION_WHOLE_DRAWING_RIGHT`,s,a,o,i,t),d=this.calcValuesForOpt(`CANDIDATE_POSITION_WHOLE_DRAWING_BELOW`,s,a,o,i,t),f=this.findBestCandidate(c,l,u,d,s,a,n);s.x=f.getNextXcoordinate(),s.y=f.getNextYcoordinate(),f.setPlacementOption(`WHOLE_DRAWING`),o=f,a=s,i.push(s)}return o}findBestCandidate(e,t,n,r,i,a,o){let s=[e,t,n,r],c=[];switch(this.goal){case`MAX_SCALE_DRIVEN`:c=[nn,en,tn];break;case`ASPECT_RATIO_DRIVEN`:c=[tn,en,nn];break;case`AREA_DRIVEN`:c=[en,nn,tn]}for(let e of c)s.length>1&&(s=e(s,this.aspectRatio,o));if(s.length===1)return s[s.length-1];if(s.length===2)return this.checkSpecialCases(s[0],s[1],a,i);throw Error(`[rectpacking] no best candidate found`)}checkSpecialCases(e,t,n,r){let i=e.getPlacementOption(),a=t.getPlacementOption(),o=i===`CANDIDATE_POSITION_LAST_PLACED_BELOW`||i===`CANDIDATE_POSITION_WHOLE_DRAWING_BELOW`,s=a===`CANDIDATE_POSITION_LAST_PLACED_BELOW`||a===`CANDIDATE_POSITION_WHOLE_DRAWING_BELOW`,c=i===`CANDIDATE_POSITION_LAST_PLACED_RIGHT`||i===`CANDIDATE_POSITION_WHOLE_DRAWING_RIGHT`,l=a===`CANDIDATE_POSITION_LAST_PLACED_RIGHT`||a===`CANDIDATE_POSITION_WHOLE_DRAWING_RIGHT`,u=i===`CANDIDATE_POSITION_LAST_PLACED_RIGHT`||i===`CANDIDATE_POSITION_LAST_PLACED_BELOW`,d=a===`CANDIDATE_POSITION_LAST_PLACED_RIGHT`||a===`CANDIDATE_POSITION_LAST_PLACED_BELOW`;if(o&&s)return e.getPlacementOption()===`CANDIDATE_POSITION_WHOLE_DRAWING_BELOW`?e:t;if(c&&l)return e.getPlacementOption()===`CANDIDATE_POSITION_WHOLE_DRAWING_RIGHT`?e:t;if(u&&d){let a,o;return i===`CANDIDATE_POSITION_LAST_PLACED_RIGHT`?(a=e,o=t):(a=t,o=e),$t.calculateAreaLPR(n,r,a)<=$t.calculateAreaLPB(n,r,o)?e.getPlacementOption()===`CANDIDATE_POSITION_LAST_PLACED_RIGHT`?e:t:e.getPlacementOption()===`CANDIDATE_POSITION_LAST_PLACED_BELOW`?e:t}return e}calcValuesForOpt(e,t,n,r,i,a){let o=0,s=0,c=r.getDrawingWidth(),l=r.getDrawingHeight(),u=t.height??0,d=t.width??0,f,p;switch(e){case`CANDIDATE_POSITION_LAST_PLACED_RIGHT`:o=(n.x??0)+(n.width??0)+a,s=this.lpShift?$t.calculateYforLPR(o,i,n,a):n.y??0,f=$t.getWidthLPRorLPB(c,o,d),p=$t.getHeightLPRorLPB(l,s,u);break;case`CANDIDATE_POSITION_LAST_PLACED_BELOW`:s=(n.y??0)+(n.height??0)+a,o=this.lpShift?$t.calculateXforLPB(s,i,n,a):n.x??0,f=$t.getWidthLPRorLPB(c,o,d),p=$t.getHeightLPRorLPB(l,s,u);break;case`CANDIDATE_POSITION_WHOLE_DRAWING_RIGHT`:o=c+a,s=0,f=c+a+d,p=Math.max(l,u);break;case`CANDIDATE_POSITION_WHOLE_DRAWING_BELOW`:o=0,s=l+a,f=Math.max(c,d),p=l+a+u;break;default:throw Error(`[rectpacking] IllegalPlacementOption`)}return new Zt(this.aspectRatio,f,p,e,o,s)}};function an(e,t,n){let r=Yt(e,Pt,`GREEDY`);switch(r){case`GREEDY`:{let r=D(e,wt),i=Xt(e),a=Yt(e,It,`MAX_SCALE_DRIVEN`),o=Jt(e,Lt,!0),s=D(e,Et);O.resetCoordinates(n),t.targetWidth=new rn(r,a,o).approxBoundingBox(n,s,i).getDrawingWidth();break}case`TARGET_WIDTH`:if(E(e,Ft)!==void 0&&E(e,Ft)!==null)t.targetWidth=D(e,Ft);else throw Error(`[rectpacking] A target width has to be set if the TargetWidthWidthApproximator should be used.`);break;default:throw Error(`[rectpacking] no implementation for width approximator ${r}`)}}var on=class{x;y;width=0;height=0;nodeNodeSpacing;rects=[];constructor(e,t,n){this.x=e,this.y=t,this.nodeNodeSpacing=n}addRectangle(e){return e.x=this.x+this.width+(this.rects.length===0?0:this.nodeNodeSpacing),e.y=this.y,this.height=Math.max(this.height,e.height??0),this.width+=(e.width??0)+(this.rects.length===0?0:this.nodeNodeSpacing),this.rects.push(e),!0}removeRectangle(e,t){let n=this.rects.indexOf(e);n!==-1&&this.rects.splice(n,1),t&&this.updateRow()}updateRow(){let e=0,t=0;for(let n of this.rects)n.x=this.x+e,n.y=this.y,e+=(n.width??0)+this.nodeNodeSpacing,t=Math.max(t,(n.height??0)+this.nodeNodeSpacing);this.width=e-this.nodeNodeSpacing,this.height=t-this.nodeNodeSpacing}expand(e,t,n){let r=(e-this.width)/this.rects.length,i=0;this.height+=t,this.width=e;for(let e of this.rects)e.width,e.height,e.x=(e.x??0)+i*r,e.y=(e.y??0)+n*t,e.width=(e.width??0)+r,e.height=this.height,i++,e.width,e.height}getY(){return this.y}setY(e){this.y=e}getWidth(){return this.width}getHeight(){return this.height}getNodes(){return this.rects}getX(){return this.x}setX(e){this.x=e}},sn=class{smallestRectWidth=1/0;minWidth=0;width=0;minHeight=0;smallestRectHeight=1/0;averageHeight=0;maxHeight=0;height=0;children=[];rows=[];x;y;parentRow;stack=null;nodeNodeSpacing;fixed=!1;positionFixed=!1;constructor(e,t,n,r){this.nodeNodeSpacing=r,this.parentRow=n,this.x=e,this.y=t,this.width=0,this.height=0}addChild(e){this.rows.length===0&&this.rows.push(new on(this.x,this.y,this.nodeNodeSpacing)),this.children.push(e),this.rows[this.rows.length-1].addRectangle(e),this.adjustSizeAdd(e)}addChildInNewRow(e){this.children.push(e);let t=this.getLastRow();this.rows.push(new on(this.x,t.getY()+t.getHeight()+this.nodeNodeSpacing,this.nodeNodeSpacing)),this.getLastRow().addRectangle(e),this.adjustSizeAdd(e)}removeChild(e){let t=this.children.indexOf(e);t!==-1&&this.children.splice(t,1);for(let t=0;t<this.rows.length;t++){let n=this.rows[t];if(n.getNodes().includes(e)){n.removeRectangle(e,!0),n.getNodes().length===0&&this.rows.splice(t,1);break}}this.adjustSizeAfterRemove()}setLocation(e,t){this.adjustChildrensXandY(e-this.x,t-this.y);for(let n of this.rows)n.setX(n.getX()+e-this.x),n.setY(n.getY()+t-this.y);this.x=e,this.y=t}adjustChildrensXandY(e,t){for(let n of this.children)n.x=(n.x??0)+e,n.y=(n.y??0)+t}adjustSizeAdd(e){let t=this.getLastRow().getWidth();this.smallestRectWidth=Math.min(this.smallestRectWidth,e.width??0),this.width=Math.max(this.width,t),this.minWidth=Math.max(this.minWidth,(e.width??0)+(this.children.length===1?0:this.nodeNodeSpacing)),this.smallestRectHeight=Math.min(this.smallestRectHeight,e.height??0),this.maxHeight+=(e.height??0)+(this.children.length===1?0:this.nodeNodeSpacing),this.minHeight=Math.max(this.minHeight,e.height??0);let n=this.rows.length>0?(this.rows.length-1)*this.nodeNodeSpacing:0;for(let e of this.rows)n+=e.getHeight();this.height=n,this.averageHeight=this.maxHeight/this.children.length-this.nodeNodeSpacing*((this.children.length-1)/this.children.length),this.parentRow.notifyAboutNodeChange()}getWidthForTargetHeight(e){if(this.maxHeight<=e||this.fitsRectsInWidthHeight(this.minWidth,e,!1))return this.minWidth;let t=this.width,n=this.minWidth,r=this.width,i=(t-n)/2+n;for(;n+1<t;)this.fitsRectsInWidthHeight(i,e,!1)?(r=i,t=i):n=i,i=(t-n)/2+n;return r}getHeightForTargetWidth(e){return this.layoutRectsInWidth(e,!1).height}placeRectsIn(e,t){return this.fitsRectsInWidthHeight(e,t,!0)}placeRectsInWidth(e){let t=this.width,n=this.height,r=this.layoutRectsInWidth(e,!0);return r.width!==t||r.height!==n}layoutRectsInWidth(e,t){let n=0,r=this.y,i=0,a=0,o=0,s=0,c=0;t&&(this.rows=[],this.rows.push(new on(this.x,this.y,this.nodeNodeSpacing)));let l=0;for(let u of this.children)n+(u.width??0)+(l>0?this.nodeNodeSpacing:0)>e&&o>0&&(n=0,r+=o+this.nodeNodeSpacing,i=Math.max(i,s),a+=o+this.nodeNodeSpacing,o=0,s=0,t&&(c++,this.rows.push(new on(this.x,r,this.nodeNodeSpacing))),l=0),s+=(u.width??0)+(l>0?this.nodeNodeSpacing:0),o=Math.max(o,u.height??0),t&&this.rows[c].addRectangle(u),n+=(u.width??0)+(l>0?this.nodeNodeSpacing:0),l++;return i=Math.max(i,s),a+=o,t&&(this.width=i,this.height=a,this.parentRow.notifyAboutNodeChange()),{x:this.x,y:this.y,width:i,height:a}}fitsRectsInWidthHeight(e,t,n){let r=this.layoutRectsInWidth(e,n);return r.width<=e&&r.height<=t}adjustSizeAfterRemove(){let e=0,t=0,n=[],r=0;for(let i=0;i<this.rows.length;i++){let a=this.rows[i];a.getNodes().length===0?n.push(i):(e=Math.max(e,a.getWidth()),t+=a.getHeight()+(r>0?this.nodeNodeSpacing:0)),r++}for(let e=n.length-1;e>=0;e--)this.rows.splice(n[e],1);this.height=t,this.width=e,this.minWidth=0,this.minHeight=0,this.maxHeight=0,this.smallestRectHeight=1/0,this.smallestRectWidth=1/0;for(let e of this.children)this.smallestRectWidth=Math.min(this.smallestRectWidth,e.width??0),this.minWidth=Math.max(this.minWidth,e.width??0),this.minHeight=Math.max(this.minHeight,e.height??0),this.smallestRectHeight=Math.min(this.smallestRectHeight,e.height??0),this.maxHeight+=(e.height??0)+this.nodeNodeSpacing;this.averageHeight=this.maxHeight/this.children.length-this.nodeNodeSpacing*((this.children.length-1)/this.children.length),this.parentRow.notifyAboutNodeChange()}expand(e,t){let n=this.width+e;this.width+=e,this.height+=t;let r=t/this.rows.length,i=0;for(let e of this.rows)e.expand(n,r,i),i++}getWidth(){return this.width}setWidth(e){this.width=e}getHeight(){return this.height}setHeight(e){this.height=e}getChildren(){return this.children}getX(){return this.x}getY(){return this.y}getParentRow(){return this.parentRow}setParentRow(e){this.parentRow=e}getMinWidth(){return this.minWidth}getMinHeight(){return this.minHeight}getMaxHeight(){return this.maxHeight}getSmallestRectHeight(){return this.smallestRectHeight}getAverageHeight(){return this.averageHeight}isFixed(){return this.fixed}setFixed(e){this.fixed=e}isPositionFixed(){return this.positionFixed}setPositionFixed(e){this.positionFixed=e}getRows(){return this.rows}getLastRowNewX(){let e=this.getLastRow();return e.getX()+e.getWidth()}getLastRowY(){return this.getLastRow().getY()}getLastRow(){return this.rows[this.rows.length-1]}getStack(){return this.stack}setStack(e){this.stack=e}getSmallestRectWidth(){return this.smallestRectWidth}setSmallestRectWidth(e){this.smallestRectWidth=e}resetBlock(){this.adjustSizeAfterRemove()}},cn=class{blocks=[];x;y;width=0;height=0;nodeNodeSpacing;constructor(e,t,n){this.x=e,this.y=t,this.nodeNodeSpacing=n}addBlock(e){e.setStack(this),this.width=Math.max(this.width,e.getWidth()),this.height+=e.getHeight()+(this.blocks.length===0?0:this.nodeNodeSpacing),this.blocks.push(e)}updateDimension(){let e=0,t=0,n=0;for(let r of this.blocks)t=Math.max(t,r.getWidth()),e+=r.getHeight()+(n>0?this.nodeNodeSpacing:0),n++;this.height=e,this.width=t}setLocation(e,t){let n=e-this.x,r=t-this.y;for(let e of this.blocks)e.setLocation(e.getX()+n,e.getY()+r);this.x=e,this.y=t}getWidthForFixedHeight(e){if(this.blocks.length===1)return this.blocks[0].getWidthForTargetHeight(e);let t=this.getMinimumWidth(),n=this.width,r=t,i=this.width,a=(n-r)/2+r;for(;r+1<n;){let t=0;for(let e of this.blocks)t+=e.getHeightForTargetWidth(a);t<e?(i=a,n=a):r=a,a=(n-r)/2+r}return i}placeRectsIn(e){let t=this.getY(),n=0;for(let r of this.blocks)r.setLocation(this.x,t),r.placeRectsInWidth(e),n=Math.max(n,r.getWidth()),t+=r.getHeight()+this.nodeNodeSpacing;this.width=n,this.height=t}expand(e,t){let n=0,r=t/this.blocks.length;for(let t of this.blocks)t.setLocation(t.getX(),t.getY()+n*r),t.expand(this.getWidth()-t.getWidth()+e,r),n++}getMinimumWidth(){let e=0;for(let t of this.blocks)e=Math.max(e,t.getMinWidth());return e}getBlocks(){return this.blocks}getX(){return this.x}getY(){return this.y}getWidth(){return this.width}setWidth(e){this.width=e}getHeight(){return this.height}setHeight(e){this.height=e}},ln=class{height=0;width=0;y;nodeNodeSpacing;children=[];stacks=[];potentialAdditionalWidthToGetLastBlock=0;constructor(e,t){this.y=e,this.nodeNodeSpacing=t}notifyAboutNodeChange(){let e=0,t=-1/0,n=0;for(let r of this.children)e+=r.getWidth()+(n>0?this.nodeNodeSpacing:0),t=Math.max(t,r.getHeight()),n++;this.width=e,this.height=t}expand(e,t){let n=(e-this.width)/this.stacks.length,r=0;for(let e of this.stacks){let i=this.getHeight()-e.getHeight()+t;e.setLocation(e.getX()+r*n,e.getY()),e.expand(n,i),r++}}calculateBlockStacks(){let e=-1;for(let t of this.children)t.getX()===e?this.stacks[this.stacks.length-1].addBlock(t):(this.stacks.push(new cn(t.getX(),this.y,this.nodeNodeSpacing)),this.stacks[this.stacks.length-1].addBlock(t),e=t.getX())}getFirstBlock(){return this.children[0]}getLastBlock(){return this.children[this.children.length-1]}getNumberOfAssignedBlocks(){return this.children.length}addBlock(e){this.height=Math.max(this.height,e.getHeight()),this.width+=e.getWidth()+(this.children.length===0?0:this.nodeNodeSpacing),this.children.push(e)}removeBlock(e){let t=this.children.indexOf(e);t!==-1&&this.children.splice(t,1),this.width-=e.getWidth()+(this.children.length===0?0:this.nodeNodeSpacing);let n=Number.MIN_VALUE;for(let e of this.children)n=Math.max(n,e.getHeight());this.height=n}getHeight(){return this.height}setHeight(e){this.height=e}getWidth(){return this.width}setWidth(e){this.width=e}getY(){return this.y}setY(e){let t=e-this.y;for(let e of this.stacks)e.setLocation(e.getX(),e.getY()+t);this.y=e}getChildren(){return this.children}getStacks(){return this.stacks}getPotentialAdditionalWidthToGetLastBlock(){return this.potentialAdditionalWidthToGetLastBlock}setPotentialAdditionalWidthToGetLastBlock(e){this.potentialAdditionalWidthToGetLastBlock=e}resetStacks(){this.stacks=[]}};const un={place(e,t,n,r){let i=[],a=new ln(0,n),o=0;a.addBlock(new sn(0,0,a,n));let s=0;for(let c of e){let e=a.getLastBlock();if((s+(c.width??0)+(a.getChildren()[0].getChildren().length===0?0:n)>t||fn(c))&&(s=0,o+=a.getHeight()+n,i.push(a),a=new ln(o,n),e=new sn(0,a.getY(),a,n),a.addBlock(e),s=0),e.getChildren().length===0||!r&&dn(e,c,n))e.addChild(c);else{let t=new sn(e.getX()+e.getWidth()+n,a.getY(),a,n);a.addBlock(t),t.addChild(c)}s=(c.x??0)+(c.width??0)}return i.push(a),i},placeRectInBlock(e,t,n,r,i){if(dn(t,n,i)){if(t.getLastRowNewX()+(n.width??0)+i<=r&&(t.getLastRowY()-e.getY()+(n.height??0)<=e.getHeight()||e.getChildren().length===1))return t.addChild(n),!0;if(t.getX()+(n.width??0)<=r&&t.getY()+t.getHeight()+(n.height??0)+i<=e.getY()+e.getHeight())return t.addChildInNewRow(n),!0}return!1}};function dn(e,t,n){let r=t.height??0;return r>=e.getSmallestRectHeight()&&r<=e.getMinHeight()||e.getAverageHeight()*.5<=r&&e.getAverageHeight()*1.5>=r}function fn(e){return Jt(e,Kt,!1)}const pn={compact(e,t,n,r,i){let a=!1,o=!1,s=e+1,c=t[e],l=c.getChildren(),u=null;for(let e=0;e<c.getNumberOfAssignedBlocks();e++){let d=l[e];if(d.isFixed())continue;if(d.getChildren().length===0){c.removeBlock(d),e--,a=!0;continue}d.isPositionFixed()||(u!==null&&u.updateDimension(),u=new cn(u===null?0:u.getX()+u.getWidth()+r,c.getY(),r),d.setLocation(u.getX()+u.getWidth(),c.getY()),c.getStacks().push(u),u.addBlock(d),d.setPositionFixed(!0));let f=null;f=mn(t,c,e,s);let p=!1;if(f!==null&&(p=f.getParentRow()!==c),f!==null){if(f.getChildren().length!==0&&!fn(f.getChildren()[0]))gn(d,n),a=_n(c,d,f,n,r)||a;else{c.removeBlock(f);break}if(f.getChildren().length===0)for(t.length>s&&t[s].removeBlock(f),f=null;t.length>s&&t[s].getChildren().length===0;)t.splice(s,1);if(f===null){e--;continue}if(!fn(f.getChildren()[0])&&vn(t,c,d,f,p,n,s,r)){a=!0;continue}if(p){let e=c.getHeight(),l=f.getMinHeight();if(!fn(f.getChildren()[0])&&yn(t,c,d,f,p,n,s,r,i)){if(a=!0,e<l){o=!0,f.setParentRow(c);break}continue}if(hn(c,d)){d.setFixed(!0),a=!0;continue}}else if(hn(c,d)){d.setFixed(!0),a=!0;continue}if(a)continue}hn(c,d)?(d.setFixed(!0),a=!0,f!==null&&f.setPositionFixed(!1)):u?.updateDimension()}return{somethingWasChanged:a,compactRowAgain:o}}};function mn(e,t,n,r){return n<t.getNumberOfAssignedBlocks()-1?t.getChildren()[n+1]:r<e.length&&e[r].getChildren().length!==0?e[r].getChildren()[0]:null}function hn(e,t){let n=!1,r=t.getStack().getWidth();if(t.getHeight()<e.getHeight()){let i=t.getStack().getWidthForFixedHeight(e.getHeight());t.getStack().getWidth()>i&&(t.getStack().placeRectsIn(i),n=r!==t.getStack().getWidth())}return n}function gn(e,t){e.placeRectsInWidth(t-e.getX()),e.getStack().updateDimension()}function _n(e,t,n,r,i){let a=!1,o=n.getChildren()[0];for(;un.placeRectInBlock(e,t,o,r,i)&&(a=!0,n.removeChild(o),n.getChildren().length!==0);)o=n.getChildren()[0];return n.getChildren().length===0&&n.getParentRow().removeBlock(n),a&&t.getStack().updateDimension(),a}function vn(e,t,n,r,i,a,o,s){let c=!1,l=a-n.getX(),u=n.getY()-t.getY()+n.getHeightForTargetWidth(l);if(r.getMinWidth()+s>l)return!1;let d=r.getHeightForTargetWidth(l);return u+s+d<=t.getHeight()?(n.placeRectsInWidth(a-n.getX()),n.setFixed(!0),r.placeRectsInWidth(a-n.getX()),r.setLocation(n.getX(),n.getY()+n.getHeight()+s),r.setPositionFixed(!0),n.getStack().addBlock(r),c=!0,i&&(t.addBlock(r),r.setParentRow(t),e.length>o&&(e[o].removeBlock(r),e[o].getChildren().length===0&&e.splice(o,1)))):n.getStack().updateDimension(),c}function yn(e,t,n,r,i,a,o,s,c){let l=!1,u=n.getStack().getWidthForFixedHeight(t.getY()+t.getHeight()-n.getStack().getY()),d=r.getMinHeight()>t.getHeight()&&c,f=a-(n.getStack().getX()+u-s),p=r.getHeightForTargetWidth(f);if(d&&p>r.getMinHeight())return!1;if(d){let e=0;for(let n of t.getStacks())e+=n.getWidthForFixedHeight(r.getMinHeight())+s;f=a-e}if(f<r.getMinWidth())return!1;let m=o===e.length-1&&f>=e[o].getWidth();return!d&&p>t.getHeight()&&!m?!1:((m||d||p<=t.getHeight())&&(m&&p>t.getHeight()?(n.setHeight(p),n.placeRectsInWidth(n.getWidthForTargetHeight(p))):(n.getStack().placeRectsIn(u),n.setFixed(!0)),r.placeRectsInWidth(a-(n.getX()+n.getWidth())),r.setLocation(n.getStack().getX()+n.getStack().getWidth(),t.getY()),t.addBlock(r),e.length>o&&(e[o].removeBlock(r),e[o].getChildren().length===0&&e.splice(o,1)),l=!0),l)}var bn=class{aspectRatio;nodeNodeSpacing;potentialRowWidthDecreaseMin=1/0;potentialRowWidthDecreaseMax=0;potentialRowWidthIncreaseMin=1/0;potentialRowWidthIncreaseMax=0;constructor(e,t){this.aspectRatio=e,this.nodeNodeSpacing=t}start(e,t,n){let r=n.targetWidth,i=n.minWidth,a=n.minHeight,o=Jt(e,zt,!1);O.resetCoordinates(e.children??[]);let s=un.place(e.children??[],r,this.nodeNodeSpacing,o);for(let e=0;e<s.length;e++){let t=s[e];if(e!==0){let n=s[e-1];t.setY(n.getY()+n.getHeight()+this.nodeNodeSpacing)}if(pn.compact(e,s,r,this.nodeNodeSpacing,o).compactRowAgain){for(let e of t.getChildren())e.setFixed(!1),e.setPositionFixed(!1),e.resetBlock();t.resetStacks(),t.setWidth(r),e--}else{if(this.adjustWidthAndHeight(t),e+1<s.length&&(this.potentialRowWidthIncreaseMax=Math.max(t.getWidth()+this.nodeNodeSpacing+s[e+1].getFirstBlock().getWidth()-r,this.potentialRowWidthDecreaseMax),this.potentialRowWidthIncreaseMin=Math.min(t.getWidth()+this.nodeNodeSpacing+s[e+1].getFirstBlock().getWidth()-r,this.potentialRowWidthDecreaseMin),t.getStacks().length!==0)){let e=t.getStacks()[t.getStacks().length-1].getWidth()+(t.getStacks().length<=1?0:this.nodeNodeSpacing);this.potentialRowWidthDecreaseMax=Math.max(this.potentialRowWidthDecreaseMax,e),this.potentialRowWidthDecreaseMin=Math.min(this.potentialRowWidthDecreaseMax,e)}if(s.length===1){let e=t.getStacks()[t.getStacks().length-1],n=e.getBlocks()[e.getBlocks().length-1];for(let e of n.getRows())this.potentialRowWidthDecreaseMax=Math.max(this.potentialRowWidthDecreaseMax,n.getWidth()-e.getWidth()),this.potentialRowWidthDecreaseMin=Math.min(this.potentialRowWidthDecreaseMin,n.getWidth()-e.getWidth()),this.potentialRowWidthIncreaseMax=Math.max(this.potentialRowWidthIncreaseMax,e.getWidth()+this.nodeNodeSpacing),this.potentialRowWidthIncreaseMin=Math.min(this.potentialRowWidthIncreaseMin,e.getWidth()+this.nodeNodeSpacing)}}}let c=O.calculateDimensionsRows(s,this.nodeNodeSpacing),l=Math.max(c.x,i-t.left-t.right),u=Math.max(c.y,a-t.top-t.bottom)-c.y;return n.additionalHeight=u,n.rows=s,new Zt(this.aspectRatio,l,c.y+u,`WHOLE_DRAWING`)}adjustWidthAndHeight(e){let t=0,n=0,r=0;for(let i of e.getStacks())i.updateDimension(),t=Math.max(t,i.getHeight()),n+=i.getWidth()+(r>0?this.nodeNodeSpacing:0),r++;e.setHeight(t),e.setWidth(n)}};function xn(e){return{id:e.id,width:e.width,height:e.height,x:e.x,y:e.y,layoutOptions:{...e.layoutOptions},children:(e.children??[]).map(e=>({id:e.id,width:e.width,height:e.height,x:e.x,y:e.y,layoutOptions:{...e.layoutOptions}}))}}function Sn(e,t){t.width=e.width,t.height=e.height,t.x=e.x,t.y=e.y;for(let n=0;n<(e.children??[]).length;n++)Sn(e.children[n],t.children[n])}function Cn(e,t){e.minRowIncrease=t.potentialRowWidthIncreaseMin,e.maxRowIncrease=t.potentialRowWidthIncreaseMax,e.minRowDecrease=t.potentialRowWidthDecreaseMin,e.maxRowDecrease=t.potentialRowWidthDecreaseMax}function wn(e,t,n,r){let i=Xt(e),a=D(e,wt);e.children.length>1&&r.minRowIncrease!==1/0&&(n.getDrawingWidth()+i.left+i.right)/(n.getDrawingHeight()+i.top+i.bottom)<a?r.targetWidth+=r.minRowIncrease:e.children.length>1&&r.minRowDecrease!==1/0&&(n.getDrawingWidth()+i.left+i.right)/(n.getDrawingHeight()+i.top+i.bottom)>a&&(r.targetWidth=Math.max(r.minWidth,r.targetWidth-r.minRowDecrease))}function Tn(e,t,n){let r=D(e,wt),i=D(e,Et),a=e.children??[],o=new bn(r,i),s=o.start(e,n,t);Cn(t,o);let c=Math.trunc(D(e,Bt));for(;c>1;){let l=xn(e),u=s.getScaleMeasure(),d={...t,rows:[],additionalHeight:0};wn(e,l,s,d),o=new bn(r,i);let f=o.start(l,n,d),p=f.getScaleMeasure();if(p>=u&&p===p){for(let e=0;e<(l.children??[]).length;e++)Sn(l.children[e],a[e]);Cn(t,o),s.setDrawingWidth(f.getDrawingWidth()),s.setDrawingHeight(f.getDrawingHeight())}c--}return t.drawingHeight=s.getDrawingHeight(),t.drawingWidth=s.getDrawingWidth(),s}function En(e,t,n){let r=t.targetWidth,i=D(e,Et);O.resetCoordinates(e.children??[]);let a=un.place(e.children??[],r,i,Jt(e,zt,!1)),o;if(a===null)o=O.calculateDimensions(e.children??[]);else{for(let e of a)for(let t of e.getChildren()){let n=new cn(t.getX(),t.getY(),i);n.addBlock(t),e.getStacks().push(n)}o=O.calculateDimensionsRows(a,i)}let s=Math.max(o.x,t.minWidth-n.left-n.right),c=Math.max(o.y,t.minHeight-n.top-n.bottom),l=c-o.y;t.additionalHeight=l,t.drawingWidth=s,t.drawingHeight=c+l,t.rows=a}function Dn(e,t,n){let r=O.calculateDimensions(e.children??[]),i=Math.max(r.x,t.minWidth-n.left-n.right),a=Math.max(r.y,t.minHeight-n.top-n.bottom),o=a-r.y;t.additionalHeight=o,t.drawingWidth=i,t.drawingHeight=a+o}function On(e,t,n){let r=Yt(e,Rt,`COMPACTION`);switch(r){case`COMPACTION`:return Tn(e,t,n);case`SIMPLE`:return En(e,t,n),new Zt(D(e,wt),t.drawingWidth,t.drawingHeight,`WHOLE_DRAWING`);case`NONE`:return Dn(e,t,n),new Zt(D(e,wt),t.drawingWidth,t.drawingHeight,`WHOLE_DRAWING`);default:throw Error(`[rectpacking] no implementation for packing strategy ${r}`)}}function kn(e,t,n,r){let i=n/e.length,a=0;for(let n of e)n.setY(n.getY()+i*a),n.expand(t,i),a++}function An(e,t){if(t.rows.length>0)kn(t.rows,t.drawingWidth,t.additionalHeight,D(e,Et));else throw Error(`[rectpacking] whitespace elimination cannot be done with packing strategy NONE`)}function jn(e,t){let n=t.drawingWidth,r=t.drawingHeight,i=D(e,wt),a=t.additionalHeight;n/r<i?(n=r*i,t.drawingWidth=n):(a+=n/i-r,t.additionalHeight=a,t.drawingHeight=r+a),An(e,t)}function Mn(e,t){switch(Yt(e,Vt,`NONE`)){case`EQUAL_BETWEEN_STRUCTURES`:An(e,t);break;case`TO_ASPECT_RATIO`:jn(e,t)}}function Nn(e,t){let n=E(e,t);if(n==null)return null;if(typeof n==`object`){let e=n;return typeof e.x==`number`&&typeof e.y==`number`?{x:e.x,y:e.y}:null}let[r,i]=String(n).replace(/[()[\]]/g,``).split(`,`).map(e=>Number(e.trim()));return Number.isFinite(r)&&Number.isFinite(i)?{x:r,y:i}:null}function Pn(e){return String(E(e,Ot)??``).includes(`MINIMUM_SIZE`)?Nn(e,kt)??{x:0,y:0}:{x:0,y:0}}function Fn(e,t){let n=Pn(e);t.minWidth=n.x,t.minHeight=n.y}function In(e){e.targetWidth=Math.max(e.targetWidth,e.minWidth)}function Ln(e){(e.children??[]).sort((e,t)=>(t.height??0)-(e.height??0))}function Rn(e){let t=e.children??[],n=[];for(let e of t)E(e,Wt)!==void 0&&n.push(e);for(let e of n){let n=t.indexOf(e);n!==-1&&t.splice(n,1)}n.sort((e,t)=>{let n=D(e,Wt),r=D(t,Wt);return n===r?-1:n-r});for(let e of n){let n=D(e,Wt);n=Math.min(n,t.length),t.splice(n,0,e)}let r=0;for(let e of t)e.layoutOptions??={},e.layoutOptions[Gt]=String(r),r++}function zn(e,t,n,r,i){let a=String(E(e,At)??`topLeft`),o=0,s=0;if(t.drawingWidth>n&&(a.includes(`H_CENTER`)?o=(t.drawingWidth-n)/2:a.includes(`H_RIGHT`)&&(o=t.drawingWidth-n)),t.drawingHeight>r&&(a.includes(`V_CENTER`)?s=(t.drawingHeight-r)/2:a.includes(`V_BOTTOM`)&&(s=t.drawingHeight-r)),o!==0||s!==0)for(let e of i)e.x=(e.x??0)+o,e.y=(e.y??0)+s}function Bn(e,t,n){let r=Pn(e);e.width=Math.max(r.x,t),e.height=Math.max(r.y,n)}function Vn(e){let t=Xt(e),n=Jt(e,Dt,!1),r=D(e,Et),i=Jt(e,Ht,!1),a=e.children??[],o=!1;if(i&&a.length>=3){let e=a[0],t=a[1],n=0;for(;n+2<a.length;){let i=e;if(e=t,t=a[n+2],(i.height??0)>=(e.height??0)+(t.height??0)+r||(t.height??0)>=(i.height??0)+(e.height??0)+r){o=!0;break}n++}}else o=!0;if(!o){let t=a.length;for(let e of a)e.layoutOptions??={},e.layoutOptions[Nt]=String(t),t--;return g(e),e}let s=new Qt;Jt(e,Ut,!1)&&Ln(e),Jt(e,jt,!1)&&Rn(e),Fn(e,s),an(e,s,a),In(s),On(e,s,t),Mn(e,s);let c=0,l=0;for(let e of a)c=Math.max(c,(e.x??0)+(e.width??0)),l=Math.max(l,(e.y??0)+(e.height??0));zn(e,s,c,l,a);for(let e of a)e.x=(e.x??0)+t.left,e.y=(e.y??0)+t.top;return n||Bn(e,s.drawingWidth+t.left+t.right,s.drawingHeight+t.top+t.bottom),e}var Hn=class{grid=[];rows=0;cols=0;put(e,t,n){if(e>=this.cols||t>=this.rows)throw Error(`The grid has a size of (${this.cols} x ${this.rows}). The requested index of (${e} x ${t}) is out of bounds.`);this.grid[t].splice(e,0,n)}get(e,t){if(e>=this.cols||t>=this.rows)throw Error(`The grid has a size of (${this.cols} x ${this.rows}). The requested index of (${e} x ${t}) is out of bounds.`);return this.grid[t][e]??null}getRow(e){if(e>=this.rows)throw Error(`The grid has a size of (${this.cols} x ${this.rows}). The requested row ${e}) is out of bounds.`);return this.grid[e]}getColumn(e){if(e>=this.cols)throw Error(`The grid has a size of (${this.cols} x ${this.rows}). The requested column ${e}) is out of bounds.`);let t=[];for(let n=0;n<this.rows;n++)t.push(this.grid[n][e]??null);return t}getColumns(){return this.cols}getRows(){return this.rows}setGridSize(e,t){this.cols=e,this.rows=t,this.grid=[];for(let n=0;n<t;n++){let t=[];for(let n=0;n<e;n++)t.push(null);this.grid.push(t)}}};const Un=o.padding.id,Wn=o.spacingNodeNode.id,Gn=a.topdownpacking.hierarchicalNodeWidth.id,Kn=a.topdownpacking.hierarchicalNodeAspectRatio.id,qn=a.topdownpacking.nodeArrangementStrategy.id,Jn=a.topdownpacking.whitespaceEliminationStrategy.id,Yn={[Un]:12,[Wn]:20,[Gn]:150,[Kn]:1.414,[qn]:`LEFT_RIGHT_TOP_DOWN_NODE_PLACER`,[Jn]:`BOTTOM_ROW_EQUAL_WHITESPACE_ELIMINATOR`};function Xn(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function Zn(e,t){let n=Xn(e,t);if(n==null||n===``)return Yn[t];let r=Number(n);return Number.isFinite(r)?r:Yn[t]}function Qn(e,t,n){let r=Xn(e,t);return r==null||r===``?n:String(r)}function $n(e){let t=Xn(e,Un);if(typeof t==`number`)return{top:t,left:t,right:t,bottom:t};if(typeof t==`object`&&t){let e=t,n=t=>typeof e[t]==`number`?e[t]:Yn[Un];return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}if(typeof t==`string`){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}let n=t=>e[t]??Yn[Un];return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return{top:Yn[Un],left:Yn[Un],right:Yn[Un],bottom:Yn[Un]}}function er(e){let t=(e.children??[]).length,n=$n(e),r=Zn(e,Wn),i=Zn(e,Gn),a=Zn(e,Kn),o=Math.ceil(Math.sqrt(t)),s=o*i+n.left+n.right+(o-1)*r,c=t>o*o-o||o===0?o:o-1;return{x:s,y:c*i/a+n.top+n.bottom+(c-1)*r}}function tr(e){return Math.ceil(Math.sqrt(e))}function nr(e,t){return e>t*t-t||t===0?t:t-1}function rr(e,t){let n=$n(e),r=Zn(e,Wn),i=er(e);e.width=Math.max(e.width??0,i.x),e.height=Math.max(e.height??0,i.y);let a=[...e.children??[]],o=tr(a.length),s=nr(a.length,o);t.setGridSize(o,s);let c=Zn(e,Gn),l=Zn(e,Kn),u=n.left,d=n.top,f=0,p=0;for(let e of a)e.width=c,e.height=c/l,e.x=u,e.y=d,t.put(f,p,e),u+=e.width+r,f+=1,f>=o&&(u=n.left,d+=c/l+r,f=0,p+=1)}function ir(e,t){if((e.width??0)===0||t.getColumns()===0)return;let n=$n(e);for(let r=0;r<t.getRows();r++){let i=t.getRow(r),a=null,o=i.length;for(;a===null;)a=i[--o]??null;let s=(a.x??0)+(a.width??0);if(s+n.right<(e.width??0)){let t=((e.width??0)-(s+n.right))/(o+1),r=0;for(let e=0;e<=o;e++){let n=i[e];n.x=(n.x??0)+r,n.width=(n.width??0)+t,r+=t}}}let r=t.getColumn(0),i=r[r.length-1],a=(i.y??0)+(i.height??0),o=((e.height??0)-(a+n.bottom))/(r.length+1),s=0;if(a+n.bottom<(e.height??0))for(let e=0;e<t.getRows();e++){let n=t.getRow(e);for(let e of n){if(e===null)break;e.y=(e.y??0)+s,e.height=(e.height??0)+o,s+=o}}}function ar(e){let t=new Hn,n=Qn(e,qn,`LEFT_RIGHT_TOP_DOWN_NODE_PLACER`);if(n!==`LEFT_RIGHT_TOP_DOWN_NODE_PLACER`)throw Error(`[topdownpacking] No implementation is available for the node placer ${n}`);let r=Qn(e,Jn,`BOTTOM_ROW_EQUAL_WHITESPACE_ELIMINATOR`);if(r!==`BOTTOM_ROW_EQUAL_WHITESPACE_ELIMINATOR`)throw Error(`[topdownpacking] No implementation is available for the whitespace eliminator${r}`);return rr(e,t),ir(e,t),e}function k(e,t,n){return Math.abs(e-t)<=n?0:e<t?-1:1}function or(e){return e.x=-e.x,e.y=-e.y,e}function sr(e,t){let n=e.length();return n>0&&e.scale(t/n),e}function cr(e,t,n=.05){return Math.abs(e.x-t.x)<=n&&Math.abs(e.y-t.y)<=n}function lr(e){return`${e.x},${e.y}`}var ur=class e{x;y;width;height;constructor(e=0,t=0,n=0,r=0){this.x=e,this.y=t,this.width=n,this.height=r}clone(){return new e(this.x,this.y,this.width,this.height)}getPosition(){return new b(this.x,this.y)}getTopLeft(){return this.getPosition()}getTopRight(){return new b(this.x+this.width,this.y)}getBottomLeft(){return new b(this.x,this.y+this.height)}getBottomRight(){return new b(this.x+this.width,this.y+this.height)}getCenter(){return new b(this.x+this.width/2,this.y+this.height/2)}};function dr(e,t){let n=Math.min(Math.abs(e.x-(t.x+t.width)),Math.abs(e.x+e.width-t.x)),r=Math.min(Math.abs(e.y-(t.y+t.height)),Math.abs(e.y+e.height-t.y)),i=Math.abs(e.x+e.width/2-(t.x+t.width/2));if(i>e.width/2+t.width/2)return 1;let a=Math.abs(e.y+e.height/2-(t.y+t.height/2));return a>e.height/2+t.height/2?1:i===0&&a===0?0:i===0?r/a+1:a===0?n/i+1:Math.min(n/i,r/a)+1}function fr(e){return[{u:e.getTopLeft(),v:e.getTopRight()},{u:e.getTopLeft(),v:e.getBottomLeft()},{u:e.getBottomRight(),v:e.getTopRight()},{u:e.getBottomRight(),v:e.getBottomLeft()}]}function pr(e,t,n,r){let i=n.clone().sub(e),a=mr(i,t),o=mr(t,r),s=mr(i,r)/o,c=a/o;if(o===0){if(a===0){let i=n.clone().add(r.clone().scale(.5)),a=e.distance(i),o=e.clone().add(t).distance(i),s=r.length()*.5;return a<o&&a<=s?e.clone():o<=s?e.clone().add(t):null}return null}return s>=0&&s<=1&&c>=0&&c<=1?e.clone().add(t.clone().scale(s)):null}function mr(e,t){return e.x*t.y-e.y*t.x}function hr(e,t,n,r,i){return Math.min(gr(e,t,n,r,i),gr(n,r,e,t,or(i.clone())))}function gr(e,t,n,r,i){let a=1/0,o=!1,s=pr(e,t.clone().sub(e),n.clone().add(i),r.clone().sub(n)),c=s!==null&&!(cr(s,e)||cr(s,t)),l=pr(e,t.clone().sub(e),n,i);l!==null&&(cr(l,e)===cr(l,t)||c?a=Math.min(a,l.sub(n).length()):o=!0);let u=pr(e,t.clone().sub(e),r,i);return u!==null&&(o||cr(u,e)===cr(u,t)||c)&&(a=Math.min(a,u.sub(r).length())),a}const _r=1e-5;function vr(e,t){let n=t.x-(e.x+e.width),r=e.x-(t.x+t.width),i=e.y-(t.y+t.height),a=t.y-(e.y+e.height),o=Math.max(r,n),s=Math.max(i,a);return k(o,0,_r)>=0==k(s,0,_r)>=0?k(o,0,_r)>0?Math.sqrt(s*s+o*o):-Math.sqrt(s*s+o*o):Math.max(s,o)}function yr(e,t,n){let r=t/2,i=n/2,a=Math.abs(e.x),o=Math.abs(e.y),s=1,c=1;return a>r&&(s=r/a),o>i&&(c=i/o),e.scale(Math.min(s,c)),e}const br=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));function xr(e){return br.setFloat64(0,e,!1),br.getUint32(0,!1)^br.getUint32(4,!1)|0}function Sr(e){let t=e|0;return t=(t&1431655765)<<1|t>>>1&1431655765,t=(t&858993459)<<2|t>>>2&858993459,t=(t&252645135)<<4|t>>>4&252645135,t=(t&16711935)<<8|t>>>8&16711935,t<<16|t>>>16}function Cr(e,t){return xr(e)+Sr(xr(t))|0}function wr(e){return e^e>>>16}var Tr=class{buckets=Array.from({length:16},()=>[]);capacity=16;threshold=12;size=0;add(e){let t=wr(e.javaHash())&this.capacity-1,n=this.buckets[t];for(let t of n)if(t.javaEquals(e))return!1;return n.push(e),this.size++,this.size>this.threshold&&this.resize(this.capacity*2),!0}addAll(e){for(let t of e)this.add(t)}has(e){let t=wr(e.javaHash()),n=this.buckets[t&this.capacity-1];for(let t=0;t<n.length;t++)if(n[t].javaEquals(e))return!0;return!1}delete(e){let t=wr(e.javaHash())&this.capacity-1,n=this.buckets[t];for(let t=0;t<n.length;t++)if(n[t].javaEquals(e))return n.splice(t,1),this.size--,!0;return!1}clear(){this.buckets=Array.from({length:16},()=>[]),this.capacity=16,this.threshold=12,this.size=0}resize(e){let t=this.buckets;this.capacity=e,this.threshold=Math.floor(e*.75),this.buckets=Array.from({length:e},()=>[]);for(let n of t)for(let t of n){let n=wr(t.javaHash())&e-1;this.buckets[n].push(t)}}*[Symbol.iterator](){for(let e of this.buckets)for(let t of e)yield t}toArray(){let e=[];for(let t of this.buckets)for(let n=0;n<t.length;n++)e.push(t[n]);return e}forEach(e){for(let t of this.buckets)for(let n=0;n<t.length;n++)e(t[n])}},Er=class e{u;v;constructor(e,t){this.u=e,this.v=t}key(){let e=lr(this.u),t=lr(this.v);return e<=t?`${e}|${t}`:`${t}|${e}`}contains(e){return this.u.x===e.x&&this.u.y===e.y||this.v.x===e.x&&this.v.y===e.y}javaHash(){return Cr(this.u.x,this.u.y)+Cr(this.v.x,this.v.y)|0}javaEquals(t){if(!(t instanceof e))return!1;let n=t;return this.u.x===n.u.x&&this.u.y===n.u.y&&this.v.x===n.v.x&&this.v.y===n.v.y||this.u.x===n.v.x&&this.u.y===n.v.y&&this.v.x===n.u.x&&this.v.y===n.u.y}},Dr=class{node;children;constructor(e){this.node=e,this.children=[]}},Or=class{originalVertex;vertex;rect;constructor(e,t){this.originalVertex=e,this.vertex=e.clone(),this.rect=t.clone()}translate(e){this.vertex.add(e),this.rect.x+=e.x,this.rect.y+=e.y}setCenterPosition(e){this.translate(e.clone().sub(this.vertex))}underlap(e){let t=Math.abs(this.rect.getCenter().x-e.rect.getCenter().x),n=Math.abs(this.rect.getCenter().y-e.rect.getCenter().y),r=0,i=0,a=1,o=1;return t>this.rect.width/2+e.rect.width/2&&(r=Math.min(Math.abs(this.rect.x-(e.rect.x+e.rect.width)),Math.abs(this.rect.x+this.rect.width-e.rect.x)),a=1-r/t),n>this.rect.height/2+e.rect.height/2&&(i=Math.min(Math.abs(this.rect.y-(e.rect.y+e.rect.height)),Math.abs(this.rect.y+this.rect.height-e.rect.y)),o=1-i/n),(1-Math.min(a,o))*Math.sqrt(t*t+n*n)}distance(e,t){let n=1/0;for(let r of fr(this.rect))for(let i of fr(e.rect)){let e=hr(r.u,r.v,i.u,i.v,t);n=Math.min(n,e)}return n}touches(e){return k(this.rect.x,e.rect.x+e.rect.width,1e-4)<=0&&k(e.rect.x,this.rect.x+this.rect.width,1e-4)<=0&&k(this.rect.y,e.rect.y+e.rect.height,1e-4)<=0&&k(e.rect.y,this.rect.y+this.rect.height,1e-4)<=0}},kr=class{vertices=[];tEdges=null;treeConstructionStrategy;tree=null;compactionStrategy;costFunction;preferredRoot=null;orthogonalCompaction=!1;overlapsExisted=!0;constructor(e,t,n){this.costFunction=e,this.treeConstructionStrategy=t,this.compactionStrategy=n}};const Ar=o.padding.id,jr=o.spacingNodeNode.id,Mr=o.underlyingLayoutAlgorithm.id;o.debugMode.id;const Nr=o.structureExtractionStrategy.id,Pr=a.spore.processingOrderTreeConstruction.id,Fr=a.spore.processingOrderSpanningTreeCostFunction.id,Ir=a.spore.processingOrderPreferredRoot.id,Lr=a.spore.processingOrderRootSelection.id,Rr=a.spore.compactionStrategy.id,zr=a.spore.compactionOrthogonal.id,Br=a.spore.overlapRemovalMaxIterations.id,Vr=a.spore.overlapRemovalRunScanline.id,A={[Ar]:8,[jr]:8,[Nr]:`DELAUNAY_TRIANGULATION`,[Pr]:`MINIMUM_SPANNING_TREE`,[Fr]:`CIRCLE_UNDERLAP`,[Lr]:`CENTER_NODE`,[Rr]:`DEPTH_FIRST`,[zr]:!1,[Br]:64,[Vr]:!0};function Hr(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function Ur(e,t){let n=Hr(e,t);if(n==null||n===``)return A[t];let r=Number(n);return Number.isFinite(r)?r:A[t]}function Wr(e,t,n){let r=Hr(e,t);return r==null||r===``?n:String(r)}function Gr(e,t){let n=Hr(e,t);return n==null||n===``?A[t]:String(n)===`true`}function Kr(e){let t=Hr(e,Ar);if(typeof t==`number`)return{top:t,left:t,right:t,bottom:t};if(typeof t==`object`&&t){let e=t,n=t=>typeof e[t]==`number`?e[t]:A[Ar];return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}if(typeof t==`string`){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}let n=t=>e[t]??A[Ar];return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return{top:A[Ar],left:A[Ar],right:A[Ar],bottom:A[Ar]}}var qr=class{graph;nodeMap=/* @__PURE__ */ new Map;elkGraph;spacingNodeNode=8;padding={top:8,left:8,right:8,bottom:8};centerDistance=e=>e.u.distance(e.v);minimumRootDistance=e=>Math.min(e.u.distance(this.graph.preferredRoot.vertex),e.v.distance(this.graph.preferredRoot.vertex));circleUnderlap=e=>{let t=this.nodeMap.get(j(e.u)).node,n=this.nodeMap.get(j(e.v)).node;return e.u.distance(e.v)-e.u.distance(t.rect.getPosition())-e.v.distance(n.rect.getPosition())};rectangleUnderlap=e=>{let t=this.nodeMap.get(j(e.u)).node,n=this.nodeMap.get(j(e.v)).node;return t.underlap(n)};invertedOverlap=e=>{let t=this.nodeMap.get(j(e.u)).node,n=this.nodeMap.get(j(e.v)).node,r=t.rect,i=n.rect,a=vr(r,i);if(a>=0)return a;let o=i.getCenter().sub(r.getCenter()).length();return-(dr(r,i)-1)*o};importGraph(e,t={}){this.elkGraph=e,this.nodeMap=/* @__PURE__ */ new Map,this.padding=Kr(e),this.spacingNodeNode=Ur(e,jr);let n=Hr(e,Ir),r=t.costFunction??Wr(e,Fr,`CIRCLE_UNDERLAP`),i=t.treeConstruction??Wr(e,Pr,`MINIMUM_SPANNING_TREE`),a=Wr(e,Rr,`DEPTH_FIRST`),o=t.rootSelection??Wr(e,Lr,`CENTER_NODE`),s=this.centerDistance;switch(r){case`CENTER_DISTANCE`:s=this.centerDistance;break;case`CIRCLE_UNDERLAP`:s=this.circleUnderlap;break;case`RECTANGLE_UNDERLAP`:s=this.rectangleUnderlap;break;case`INVERTED_OVERLAP`:s=this.invertedOverlap;break;case`MINIMUM_ROOT_DISTANCE`:s=this.minimumRootDistance;break;default:throw Error(`No implementation available for ${r}`)}let c=new kr(s,i,a);if(c.orthogonalCompaction=Gr(e,zr),this.graph=c,(e.children??[]).length===0)return c;for(let t of e.children??[]){let e=(t.width??0)/2,n=(t.height??0)/2,r=new b((t.x??0)+e,(t.y??0)+n);for(;this.nodeMap.has(j(r));)r.add(new b((Math.random()-.5)*.001,(Math.random()-.5)*.001));let i=Jr(Hr(t,`org.eclipse.elk.margins`)),a=new Or(r,new ur(r.x-e-this.spacingNodeNode/2-i.left,r.y-n-this.spacingNodeNode/2-i.top,(t.width??0)+this.spacingNodeNode+i.left+i.right,(t.height??0)+this.spacingNodeNode+i.top+i.bottom));c.vertices.push(a),this.nodeMap.set(j(r),{node:a,elkNode:t})}switch(o){case`FIXED`:if(n==null)c.preferredRoot=c.vertices[0];else for(let e of c.vertices){let t=this.nodeMap.get(j(e.originalVertex)).elkNode.id;t!==void 0&&t===n&&(c.preferredRoot=e)}break;case`CENTER_NODE`:{let e=new b(this.elkGraph.width??0,this.elkGraph.height??0);e.scale(.5),e.add(new b(this.elkGraph.x??0,this.elkGraph.y??0));let t=1/0;for(let n of c.vertices){let r=n.originalVertex.distance(e);r<t&&(t=r,c.preferredRoot=n)}break}default:throw Error(`No implementation available for ${o}`)}return c}updateGraph(e){let t=/* @__PURE__ */ new Map;e.tEdges=null,e.tree=null;for(let n of e.vertices){let e=this.nodeMap.get(j(n.originalVertex));n.originalVertex=n.rect.getCenter(),t.set(j(n.originalVertex),e)}this.nodeMap=t}applyPositions(e){if(e.vertices.length===0)return;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e.vertices){let e=this.nodeMap.get(j(a.originalVertex)).elkNode;e.x=a.rect.x,e.y=a.rect.y,t=Math.min(t,e.x),n=Math.min(n,e.y),r=Math.max(r,e.x+(e.width??0)),i=Math.max(i,e.y+(e.height??0))}this.elkGraph.width=r-t+this.padding.left+this.padding.right,this.elkGraph.height=i-n+this.padding.top+this.padding.bottom;let a=-t+this.padding.left,o=-n+this.padding.top;for(let e of this.elkGraph.children??[])e.x=(e.x??0)+a,e.y=(e.y??0)+o;for(let e of this.elkGraph.edges??[]){let t=Yr(e),n=Xr(this.elkGraph,e.sources?.[0]),r=Xr(this.elkGraph,e.targets?.[0]);if(n===void 0||r===void 0)continue;let i=new b((n.x??0)+(n.width??0)/2,(n.y??0)+(n.height??0)/2),a=new b((r.x??0)+(r.width??0)/2,(r.y??0)+(r.height??0)/2),o=a.clone().sub(i);yr(o,n.width??0,n.height??0),i.add(o);let s=i.clone().sub(a);yr(s,r.width??0,r.height??0),a.add(s),t.startPoint={x:i.x,y:i.y},t.endPoint={x:a.x,y:a.y}}}};function j(e){return`${e.x},${e.y}`}function Jr(e){let t={top:0,left:0,right:0,bottom:0};if(typeof e==`number`)return{top:e,left:e,right:e,bottom:e};if(typeof e==`object`&&e){let t=e,n=e=>typeof t[e]==`number`?t[e]:0;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}if(typeof e==`string`&&e.trim()!==``){let t={};for(let n of e.replace(/^\[|\]$/g,``).split(`,`)){let[e,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);e!==void 0&&Number.isFinite(i)&&(t[e]=i)}let n=e=>t[e]??0;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return t}function Yr(e){return e.sections??=[],e.sections.length===0&&e.sections.push({startPoint:{x:0,y:0},endPoint:{x:0,y:0}}),e.sections[0]}function Xr(e,t){if(t===void 0)return;let n=(e.children??[]).find(e=>e.id===t);if(n!==void 0)return n;let r=t.includes(`.`)?t.slice(0,t.lastIndexOf(`.`)):t;return(e.children??[]).find(e=>e.id===r)}var Zr=class e{a;b;c;tEdges;vertices;circumcenter;constructor(e,t,n){this.a=e,this.b=t,this.c=n,this.tEdges=[new Er(e,t),new Er(t,n),new Er(n,e)],this.vertices=[e,t,n],this.circumcenter=this.calculateCircumcenter()}calculateCircumcenter(){let e=this.b.clone().sub(this.a),t=this.c.clone().sub(this.a),n=this.c.clone().sub(this.b),r=e.x*(this.a.x+this.b.x)+e.y*(this.a.y+this.b.y),i=t.x*(this.a.x+this.c.x)+t.y*(this.a.y+this.c.y),a=2*(e.x*n.y-e.y*n.x);return new b((t.y*r-e.y*i)/a,(e.x*i-t.x*r)/a)}inCircumcircle(e){return this.circumcenter.distance(e)<this.circumcenter.distance(this.a)-1e-4}containsEdge(e){return this.tEdges.some(t=>t.javaEquals(e))}containsVertex(e){return this.vertices.some(t=>lr(t)===lr(e))}javaEquals(t){return t instanceof e&&this.containsVertex(t.a)&&this.containsVertex(t.b)&&this.containsVertex(t.c)}javaHash(){return Cr(this.a.x,this.a.y)+Cr(this.b.x,this.b.y)+Cr(this.c.x,this.c.y)|0}};function Qr(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x),i=Math.max(i,a.y);let a=r-t,o=i-n,s=new Zr(new b(t-50,n-a-50),new b(t-50,i+a+50),new b(r+o/2+50,n+o/2)),c=new Tr;c.add(s);for(let t of e){let e=[];c.forEach(n=>{n.inCircumcircle(t)&&e.push(n)});let n=[];for(let t of e)for(let r of t.tEdges){let i=!0;for(let n of e)if(n!==t&&n.containsEdge(r)){i=!1;break}i&&n.push(r)}for(let t of e)c.delete(t);for(let e of n)c.add(new Zr(t,e.u,e.v))}let l=new Tr;c.forEach(e=>{for(let t of e.tEdges)l.add(t)});for(let e of l.toArray())(s.containsVertex(e.u)||s.containsVertex(e.v))&&l.delete(e);return l}function $r(e){let t=e.vertices.map(e=>e.originalVertex);e.tEdges===null?e.tEdges=Qr(t):e.tEdges.addAll(Qr(t).toArray())}function ei(e,t,n){let r=[];e.forEach(e=>r.push({edge:e,weight:n(e),order:0})),r.sort((e,t)=>e.weight<t.weight?-1:+(e.weight>t.weight));for(let e=0;e<r.length;e++)r[e].order=e;let i=/* @__PURE__ */ new Map,a=e=>{let t=i.get(e);return t===void 0&&(t=ti(e),i.set(e,t)),t},o=/* @__PURE__ */ new Map;for(let e of r){let t=a(e.edge.u),n=a(e.edge.v),r=o.get(t);r===void 0&&o.set(t,r=[]),r.push(e);let i=o.get(n);i===void 0&&o.set(n,i=[]),i.push(e)}let s=[],c=(e,t)=>e.weight<t.weight?!0:e.weight>t.weight?!1:e.order<t.order,l=e=>{let t=s.length;for(s.push(e);t>0;){let n=t-1>>1,r=s[n];if(!c(e,r))break;s[n]=e,s[t]=r,t=n}},u=()=>{let e=s[0],t=s.pop();if(s.length===0)return e;s[0]=t;let n=0;for(;;){let e=n*2+1;if(e>=s.length)break;let r=e+1,i=e;r<s.length&&c(s[r],s[e])&&(i=r);let a=s[i];if(!c(a,t))break;s[n]=a,s[i]=t,n=i}return e},d=new Dr(t),f=/* @__PURE__ */ new Map,p=new Uint8Array(r.length),m=e=>{let t=o.get(e);if(t!==void 0)for(let e of t)p[e.order]===0&&(p[e.order]=1,l(e))},h=a(t);for(f.set(h,d),m(h);s.length>0;){let e=u().edge,t=a(e.u),n=a(e.v),r=f.has(t);if(r===f.has(n))continue;let i=r?n:t,o=new Dr(r?e.v:e.u);f.get(r?t:n).children.push(o),f.set(i,o),m(i)}return d}function ti(e){return`${e.x},${e.y}`}function ni(e,t){let n=/* @__PURE__ */ new Map;for(let e of t)n.set(ti(e.originalVertex),e);let r=new Dr(n.get(ti(e.node)));return ri(r,e,n),r}function ri(e,t,n){for(let r of t.children){let t=new Dr(n.get(ti(r.node)));e.children.push(t),ri(t,r,n)}}function ii(e){let t=e.preferredRoot===null?e.vertices[0].originalVertex:e.preferredRoot.originalVertex;e.tree=ni(ei(e.tEdges,t,e.costFunction),e.vertices)}function ai(e){let t=t=>-e.costFunction(t),n=e.preferredRoot===null?e.vertices[0].vertex:e.preferredRoot.vertex;e.tree=ni(ei(e.tEdges,n,t),e.vertices)}function oi(e){e.overlapsExisted=!1,si(e.tree,e)}function si(e,t){for(let n of e.children){n.node.translate(e.node.vertex.clone().sub(e.node.originalVertex));let r=dr(e.node.rect,n.node.rect);r>1&&(t.overlapsExisted=!0),n.node.setCenterPosition(e.node.vertex.clone().add(n.node.originalVertex.clone().sub(e.node.originalVertex).scale(r))),si(n,t)}}function ci(e,t){li(e,t)}function li(e,t){for(let n of e.children)li(n,t);for(let n of e.children){let r=e.node.vertex.clone().sub(n.node.vertex);if(t){let t=e.node.rect,i=n.node.rect;Math.abs(r.x)>=Math.abs(r.y)?(r.y=0,i.y+i.height>t.y&&i.y<t.y+t.height&&sr(r,Math.max(t.x-(i.x+i.width),i.x-(t.x+t.width)))):(r.x=0,i.x+i.width>t.x&&i.x<t.x+t.width&&sr(r,Math.max(t.y-(i.y+i.height),i.y-(t.y+t.height))))}else sr(r,e.node.underlap(n.node));let i=r.length();i=ui(e,n,i,r),sr(r,i),fi(n,r)}}function ui(e,t,n,r){let i=Math.min(n,di(e.node,t,n,r));for(let n of e.children)n!==t&&(i=Math.min(i,ui(n,t,i,r)));return i}function di(e,t,n,r){let i=n;for(let n of t.children){let t=n.node;if(e.touches(t)){if(k(t.rect.x,e.rect.x+e.rect.width,1e-4)===0&&r.x<0||k(t.rect.x+t.rect.width,e.rect.x,1e-4)===0&&r.x>0||k(t.rect.y,e.rect.y+e.rect.height,1e-4)===0&&r.y<0||k(t.rect.y+t.rect.height,e.rect.y,1e-4)===0&&r.y>0){i=0;break}}else i=Math.min(i,e.distance(t,r));i=Math.min(i,di(e,n,i,r))}return i}function fi(e,t){e.node.translate(t);for(let n of e.children)fi(n,t)}function pi(e){ci(e.tree,e.orthogonalCompaction)}function mi(e,t){let n=e.low?e.node.rect.y:e.node.rect.y+e.node.rect.height,r=t.low?t.node.rect.y:t.node.rect.y+t.node.rect.height,i=n<r?-1:+(n>r);if(i===0){if(!e.low&&t.low)return-1;if(!t.low&&e.low)return 1}return i}function hi(e,t){let n=e.rect.x<t.rect.x?-1:+(e.rect.x>t.rect.x);if(n!==0)return n;let r=e.originalVertex.x<t.originalVertex.x?-1:+(e.originalVertex.x>t.originalVertex.x);return r===0?e.originalVertex.y<t.originalVertex.y?-1:+(e.originalVertex.y>t.originalVertex.y):r}function gi(e,t){return e!==t&&k(e.rect.x,t.rect.x+t.rect.width,1e-4)<0&&k(t.rect.x,e.rect.x+e.rect.width,1e-4)<0}function _i(e,t){let n=[];for(let t of e)n.push({node:t,low:!0}),n.push({node:t,low:!1});n.sort(mi);let r=[],i=e=>{let t=0,n=r.length;for(;t<n;){let i=t+n>>>1;hi(r[i],e)<0?t=i+1:n=i}return t};for(let e of n)if(e.low){let n=i(e.node);if(r[n]!==void 0&&hi(r[n],e.node)===0)throw Error(`Invalid hitboxes for scanline overlap calculation.`);r.splice(n,0,e.node);let a=!1;for(let n of r)if(gi(e.node,n))t(e.node,n),a=!0;else if(a)break}else{let t=r.findIndex(t=>t===e.node);t!==-1&&r.splice(t,1)}}function vi(e){let t=new Tr;return _i(e,(e,n)=>{t.add(new Er(e.originalVertex,n.originalVertex))}),t}function yi(e){xi(e);let t={rootSelection:`CENTER_NODE`,costFunction:`INVERTED_OVERLAP`,treeConstruction:`MINIMUM_SPANNING_TREE`},n=new qr,r=n.importGraph(e,t),i=Ur(e,Br),a=Gr(e,Vr),o=!0,s=0;for(;s<i&&o;){if(a){let e=vi(r.vertices);if(e.size===0)break;r.tEdges=e}$r(r),ii(r),oi(r),n.updateGraph(r),o=r.overlapsExisted,s++}return n.applyPositions(r),e}function bi(e){xi(e);let t=new qr,n=t.importGraph(e);return n.vertices.length>1&&($r(n),n.treeConstructionStrategy===`MAXIMUM_SPANNING_TREE`?ai(n):ii(n),pi(n)),t.applyPositions(n),e}function xi(e){let t=Hr(e,Mr);if(t==null||String(t).trim()===``)return;let n=String(t).trim();switch(Si(n)){case`box`:g(e);return;case`fixed`:d(e);return;case`random`:m(e);return;case`stress`:Ct(e);return;case`force`:St(e);return;case`rectpacking`:Vn(e);return;case`topdownpacking`:ar(e);return;case`layered`:case`sporeoverlap`:case`sporecompaction`:throw Error(`[spore] underlying layout algorithm '${n}' 未支持 (递归 layered/spore 未移植)`);default:return}}function Si(e){return String(e).trim().toLowerCase().replace(/^org\.eclipse\.elk\./,``).replace(/^elk\./,``)}const Ci=a.radial.centerOnRoot.id,wi=a.radial.orderId.id,Ti=a.radial.radius.id,Ei=a.radial.rotate.id,Di=a.radial.rotationTargetAngle.id,Oi=a.radial.rotationComputeAdditionalWedgeSpace.id,ki=a.radial.rotationOutgoingEdgeAngles.id,Ai=a.radial.compactor.id,ji=a.radial.compactionStepSize.id,Mi=a.radial.sorter.id,Ni=a.radial.wedgeCriteria.id,Pi=a.radial.optimizationCriteria.id,Fi=o.spacingNodeNode.id,Ii=o.padding.id,Li=o.margins.id,Ri=o.omitNodeMicroLayout.id,zi=o.nodeSizeFixedGraphSize.id,Bi=o.position.id,Vi=o.childAreaWidth.id,Hi=o.childAreaHeight.id,Ui={[Ci]:!1,[wi]:0,[Ti]:0,[Ei]:!1,[Di]:0,[Oi]:!1,[ki]:!1,[Ai]:`NONE`,[ji]:1,[Mi]:`NONE`,[Ni]:`NODE_SIZE`,[Pi]:`NONE`,[Fi]:20,[Ri]:!1,[zi]:!1};function M(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function Wi(e,t){let n=M(e,t);if(n==null||n===``)return Ui[t];let r=Number(n);return Number.isFinite(r)?r:Ui[t]}function Gi(e,t,n){let r=M(e,t);return r==null||r===``?n:String(r)}function Ki(e,t){let n=M(e,t);return n==null||n===``?Ui[t]:String(n)===`true`}function qi(e){let t=M(e,Li);if(typeof t==`number`)return{top:t,left:t,right:t,bottom:t};if(typeof t==`object`&&t){let e=t,n=t=>typeof e[t]==`number`?e[t]:0;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}if(typeof t==`string`&&t.trim()!==``){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}let n=t=>e[t]??0;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return{top:0,left:0,right:0,bottom:0}}function Ji(e){let t=M(e,Ii);if(typeof t==`number`)return{top:t,left:t,right:t,bottom:t};if(typeof t==`object`&&t){let e=t,n=t=>typeof e[t]==`number`?e[t]:12;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}if(typeof t==`string`&&t.trim()!==``){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}let n=t=>e[t]??12;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return{top:12,left:12,right:12,bottom:12}}const Yi=/* @__PURE__ */ new WeakMap;function Xi(e,t,n){let r=Yi.get(e);r===void 0&&(r=/* @__PURE__ */ new Map,Yi.set(e,r)),r.set(t,n)}function Zi(e,t,n){let r=Yi.get(e)?.get(t);if(r!==void 0)return r;let i=M(e,t);return i!=null&&i!==``?i:n}const N=2*Math.PI;function Qi(e,t){let n=e-t;return Math.abs(n)<=1e-10*Math.max(1,Math.abs(e),Math.abs(t))?0:n<0?-1:1}function P(e,t){if(e.id===t)return e;for(let n of e.children??[]){let e=P(n,t);if(e!==void 0)return e}}function F(e,t){if(t!==void 0){if(P(e,t)!==void 0)return t;if(t.includes(`.`)){let n=t.slice(0,t.lastIndexOf(`.`));if(P(e,n)!==void 0)return n}return t}}function $i(e,t){return t===void 0||P(e,t)!==void 0||!t.includes(`.`)?!1:P(e,t.slice(0,t.lastIndexOf(`.`)))!==void 0}function ea(e,t){return(e.edges??[]).filter(n=>F(e,String(n.sources?.[0]??``))===t.id)}function ta(e,t){return(e.edges??[]).filter(n=>F(e,String(n.targets?.[0]??``))===t.id)}function na(e,t){return(e.edges??[]).filter(n=>F(e,String(n.sources?.[0]??``))===t.id)}function ra(e,t){let n=F(e,String(t.sources?.[0]??``)),r=F(e,String(t.targets?.[0]??``));if(n===void 0||r===void 0)return!0;let i=P(e,n),a=P(e,r);return i===void 0||a===void 0||ia(e,i)!==ia(e,a)}function ia(e,t){let n=e=>{for(let r of e.children??[]){if(r===t)return e;let i=n(r);if(i!==void 0)return i}};return n(e)}function I(e,t){let n=[],r=new Set(t.children??[]);for(let i of ea(e,t))if(!$i(e,String(i.sources?.[0]??``))){let t=F(e,String(i.targets?.[0]??``)),a=t===void 0?void 0:P(e,t);a!==void 0&&!r.has(a)&&n.push(a)}return n}function aa(e,t){return new Set(I(e,t))}function oa(e){for(let t of e.children??[])if(ta(e,t).length===0)return t;return null}function sa(e,t){let n=ma(e,t);return n===null?t:sa(e,n)}function ca(e,t){let n=I(e,t);if(n.length===0)return 1;let r=0;for(let t of n)r+=ca(e,t);return r}function la(e,t){return(n,r)=>{let i=Math.atan2((n.y??0)+t,n.x??0);i<0&&(i+=N),i+=e,i>N&&(i-=N);let a=Math.atan2((r.y??0)+t,r.x??0);return a<0&&(a+=N),a+=e,a>N&&(a-=N),Qi(i,a)}}function ua(e){let t=0;for(let n of e.children??[]){let e=n.width??0,r=n.height??0,i=Math.sqrt(e*e+r*r);t=Math.max(i,t);let a=ua(n);t=Math.max(a,t)}return t}function da(e,t){let n=[];for(let r of t)n.push(...I(e,r));return n}function fa(e,t){let n=/* @__PURE__ */ new Set;for(let r of t)for(let t of aa(e,r))n.add(t);return n}function pa(e,t,n){e.x=t-(e.width??0)/2,e.y=n-(e.height??0)/2}function ma(e,t){let n=ta(e,t);if(n.length>0){let t=n[0],r=F(e,String(t.sources?.[0]??``));return(r===void 0?null:P(e,r))??null}return null}var ha=class{sort(e){e.sort((e,t)=>Wi(e,wi)-Wi(t,wi))}initialize(e){}};const ga=.25*Math.PI,_a=.5*Math.PI,va=.75*Math.PI,ya=1.25*Math.PI,ba=1.5*Math.PI,xa=1.75*Math.PI;var Sa=class{compRight=la(0,0);compLeft=la(Math.PI,0);compTop=la(ba,0);compBottom=la(_a,0);idSorter=null;graph=null;constructor(e){this.graph=e}initialize(e){this.idSorter=new ha;let t=I(this.graph,e);t.sort(this.compRight),this.setIDForNodes(t,0)}setIDForNodes(e,t){let n=t,r=0;for(let t of e){Xi(t,wi,n++);let e=I(this.graph,t),i=Math.atan2((t.y??0)+(t.height??0)/2,(t.x??0)+(t.width??0)/2);i+=i<0?N:0,i<ga||i>xa?e.sort(this.compLeft):i<=xa&&i>ya?e.sort(this.compTop):i<=ya&&i>va?e.sort(this.compRight):i<=va&&e.sort(this.compBottom),r=this.setIDForNodes(e,r)}return n}sort(e){if(e.length!==0){if(this.idSorter===null){let t=sa(this.graph,e[0]);this.initialize(t)}this.idSorter.sort(e)}}};function Ca(e,t){switch(t){case`NONE`:return null;case`POLAR_COORDINATE`:return new Sa(e);case`ID`:return new ha;default:throw Error(`No implementation is available for the layout option ${t}`)}}var wa=class{graph;constructor(e){this.graph=e}evaluate(e){let t=0;for(let n of ea(this.graph,e)){let r=P(this.graph,F(this.graph,String(n.targets?.[0]??``))??``),i=(r.x??0)+(r.width??0)/2,a=(r.y??0)+(r.height??0)/2,o=(e.x??0)+(e.width??0)/2,s=(e.y??0)+(e.height??0)/2,c=new b(i-o,a-s),l=new b(c.x,c.y);se(l,e.width??0,e.height??0),c.x-=l.x,c.y-=l.y,o=i-c.x,s=a-c.y;let u=new b(c.x,c.y);se(u,r.width??0,r.height??0),c.x-=u.x,c.y-=u.y,i=o+c.x,a=s+c.y;let d=i-o,f=a-s;t+=Math.sqrt(d*d+f*f)}return t}},Ta=class{graph;constructor(e){this.graph=e}evaluate(e){let t=0;for(let n of ea(this.graph,e)){let r=P(this.graph,F(this.graph,String(n.targets?.[0]??``))??``),i=(r.x??0)+(r.width??0)/2,a=(r.y??0)+(r.height??0)/2,o=M(r,Bi);if(o===void 0)throw Error(`[radial] EdgeLengthPositionOptimization requires CoreOptions.POSITION (Java NPE 等价)`);let s=(e.x??0)+o.x+(e.width??0)/2,c=(e.y??0)+o.y+(e.height??0),l=i-s,u=a-c;t+=Math.sqrt(l*l+u*u)}return t}},Ea=class{graph;constructor(e){this.graph=e}evaluate(e){let t=0,n=I(this.graph,e),r=0;for(let i of n){r++;for(let a=r;a<n.length;a++)this.isCrossing(e,i,n[a])&&(t+=1)}return t}isCrossing(e,t,n){let r=(e.x??0)+(e.width??0)/2,i=(e.x??0)+(e.width??0)/2,a=new b((t.x??0)+(t.width??0)/2,(t.y??0)+(t.height??0)/2),o=M(t,Bi);if(o===void 0)throw Error(`[radial] CrossingMinimizationPosition requires CoreOptions.POSITION (Java NPE 等价)`);o.x+=r,o.y+=i;let s=(a.y-o.y)/(a.x-o.x),c=a.y-s*a.x,l=new b((n.x??0)+(n.width??0)/2,(n.y??0)+(n.height??0)/2),u=M(n,Bi);if(u===void 0)throw Error(`[radial] CrossingMinimizationPosition requires CoreOptions.POSITION (Java NPE 等价)`);u.x+=r,u.y+=i;let d=(l.y-u.y)/(l.x-u.x),f=(c-(l.y-d*l.x))/(d-s);return!(o.x<f&&a.x<f||f<o.x&&f<a.x||u.x<f&&l.x<f||f<u.x&&f<l.x)}};function Da(e,t){switch(t){case`EDGE_LENGTH`:return new wa(e);case`EDGE_LENGTH_BY_POSITION`:return new Ta(e);case`CROSSING_MINIMIZATION_BY_POSITION`:return new Ea(e);case`NONE`:return null;default:throw Error(`No implementation is available for the layout option ${t}`)}}var Oa=class{graph;constructor(e){this.graph=e}calculateWedgeSpace(e){return ca(this.graph,e)}},ka=class{graph;constructor(e){this.graph=e}calculateWedgeSpace(e){let t=I(this.graph,e),n=e.height??0,r=e.width??0,i=Math.sqrt(n*n+r*r),a=0;for(let e of t)a+=this.calculateWedgeSpace(e);return Math.max(a,i)}};function Aa(e,t){switch(t){case`LEAF_NUMBER`:return new Oa(e);case`NODE_SIZE`:return new ka(e);default:throw Error(`No implementation is available for the layout option ${t}`)}}const ja=Math.PI/180;function Ma(e){Na(e,Zi(e,Za,void 0),Zi(e,Ti,0),Ca(e,Gi(e,Mi,`NONE`)),Aa(e,Gi(e,Ni,`NODE_SIZE`)),Da(e,Gi(e,Pi,`NONE`)))}function Na(e,t,n,r,i,a){let o=0,s=Number.MAX_VALUE;if(a!==null)for(let c=0;c<360;c++){let l=c*ja;Pa(e,t,n,r,i,t,0,0,2*Math.PI,l);let u=a.evaluate(t);u<s&&(o=l,s=u)}Pa(e,t,n,r,i,t,0,0,2*Math.PI,o)}function Pa(e,t,n,r,i,a,o,s,c,l){let u=l,d=(s+c)/2+u;pa(a,o*Math.cos(d),o*Math.sin(d));let f=i.calculateWedgeSpace(a),p=2*Math.acos(o/o+n),m,h;p<c-s?(m=p/f,h=(s+c-p)/2):(m=(c-s)/f,h=s);let g=I(e,a);r!==null&&(r.initialize(t),r.sort(g));for(let a of g){let s=i.calculateWedgeSpace(a);Pa(e,t,n,r,i,a,o+n,h,h+m*s,l),h+=m*s}}var Fa=class{compactionStep=1;spacing=0;root=null;contractLayer(e,t,n){for(let e of t){let t=(e.x??0)+(e.width??0)/2,r=(e.y??0)+(e.height??0)/2,i=this.root,a=(i.x??0)+(i.width??0)/2,o=(i.y??0)+(i.height??0)/2,s=t-a,c=r-o,l=Math.sqrt(s*s+c*c);s*=this.compactionStep/l,c*=this.compactionStep/l,n?(t-=s,r-=c):(t+=s,r+=c),e.x=t-(e.width??0)/2,e.y=r-(e.height??0)/2}}moveNode(e,t){let n=this.root,r=(n.x??0)+(n.width??0)/2,i=(n.y??0)+(n.height??0)/2,a=(e.x??0)+(e.width??0)/2,o=(e.y??0)+(e.height??0)/2,s=a-r,c=o-i,l=Math.sqrt(s*s+c*c),u=s/l,d=c/l;e.x=(e.x??0)+u*t,e.y=(e.y??0)+d*t}overlap(e,t){let n=(e.x??0)-this.spacing/2,r=(t.x??0)-this.spacing/2,i=(e.y??0)-this.spacing/2,a=(t.y??0)-this.spacing/2,o=(e.width??0)+this.spacing,s=(t.width??0)+this.spacing,c=(e.height??0)+this.spacing,l=(t.height??0)+this.spacing;return n<r+s&&r<n&&i<a+l&&a<i||r<n+o&&n<r&&a<i+c&&i<a||n<r+s&&r<n&&i<a&&a<i+c||r<n+o&&n<r&&i<a+l&&a<i}overlapLayer(e){let t=!1;if(e.length<2)return!1;for(let n=0;n<e.length;n++)n<e.length-1?t||=this.overlap(e[n],e[n+1]):t||=this.overlap(e[n],e[0]);return t}getCompactionStep(){return this.compactionStep}setCompactionStep(e){this.compactionStep=e}getSpacing(){return this.spacing}setSpacing(e){this.spacing=e}getRoot(){return this.root}setRoot(e){this.root=e}},Ia=class extends Fa{graph;sorter=null;lastRadius=0;constructor(e){super(),this.graph=e}compact(e){let t=Zi(e,Za,void 0);this.setRoot(t),this.sorter=Ca(this.graph,Gi(e,Mi,`NONE`));let n=M(e,ji);n!=null&&this.setCompactionStep(Number(n)),this.setSpacing(Wi(e,Fi));let r=I(this.graph,t);this.sorter!==null&&this.sorter.sort(r),this.contract(r)}contract(e){if(e.length===0)return;let t=this.overlapping(e),n=!1;for(;!t;)this.contractLayer(this.graph,e,!0),n=!0,t=this.overlapping(e);n&&this.contractLayer(this.graph,e,!1);let r=da(this.graph,e);this.sorter!==null&&this.sorter.sort(r),this.lastRadius=this.calculateRadius(e[0]),this.contract(r)}calculateRadius(e){let t=e.x??0,n=e.y??0,r=this.getRoot(),i=r.x??0,a=r.y??0,o=t-i,s=n-a;return Math.sqrt(o*o+s*s)}overlapping(e){if(this.overlapLayer(e))return!0;for(let t of e){let e=ma(this.graph,t);if(e!==null&&this.overlap(t,e)||this.calculateRadius(t)-this.getSpacing()<=this.lastRadius)return!0}return!1}},La=class extends Fa{graph;leftContour=/* @__PURE__ */ new Map;rightContour=/* @__PURE__ */ new Map;sorter=null;constructor(e){super(),this.graph=e}compact(e){let t=Zi(e,Za,void 0);this.setRoot(t),this.sorter=Ca(this.graph,Gi(e,Mi,`NONE`));let n=M(e,ji);n!=null&&this.setCompactionStep(Number(n)),this.setSpacing(Wi(e,Fi));let r=I(this.graph,t);this.sorter!==null&&this.sorter.sort(r),this.constructContour(r);for(let e=0;e<2;e++)for(let e=0;e<r.length;e++){let n=e<r.length-1?r[e+1]:r[0],i=e===0?r[r.length-1]:r[e-1];this.contractWedge(r[e],[t],i,n,[r[e]])}}contractWedge(e,t,n,r,i){let a=this.overlapping(t,n,r,i),o=!1;for(;!a;)this.contractLayer(this.graph,i,!0),o=!0,a=this.overlapping(t,n,r,i);o&&this.contractLayer(this.graph,i,!1);let s=da(this.graph,i);s.length>0&&(this.sorter!==null&&this.sorter.sort(s),this.contractWedge(e,i,n,r,s))}overlapping(e,t,n,r){this.sorter!==null&&this.sorter.sort(r);let i=r[0];if(this.contourOverlap(t,i,!1))return!0;let a=r[r.length-1];if(this.contourOverlap(n,a,!0)||this.overlapLayer(r))return!0;for(let t of r)for(let n of e)if(this.overlap(t,n))return!0;return!1}contourOverlap(e,t,n){let r=n?this.leftContour.get(e):this.rightContour.get(e);if(r===void 0)return!1;for(let e of r)if(this.overlap(t,e))return!0;return!1}constructContour(e){for(let t of e){this.leftContour.set(t,[t]),this.rightContour.set(t,[t]);let e=I(this.graph,t);if(e.length>0)for(this.sorter!==null&&this.sorter.sort(e),this.leftContour.get(t).push(e[0]),this.rightContour.get(t).push(e[e.length-1]);da(this.graph,e).length>0;)e=da(this.graph,e),this.sorter!==null&&this.sorter.sort(e),this.leftContour.get(t).push(e[0]),this.rightContour.get(t).push(e[e.length-1])}}};function Ra(e){za(e,Gi(e,Ai,`NONE`)).compact(e)}function za(e,t){switch(t){case`RADIAL_COMPACTION`:return new Ia(e);case`WEDGE_COMPACTION`:return new La(e);default:throw Error(`No implementation is available for the layout option ${t}`)}}var Ba=class extends Fa{graph;sorter=null;constructor(e){super(),this.graph=e}removeOverlaps(e){let t=Zi(e,Za,void 0);this.setRoot(t),this.sorter=Ca(this.graph,Gi(e,Mi,`NONE`)),this.setSpacing(Wi(e,Fi));let n=I(this.graph,t);this.extend(n)}extend(e){if(e.length===0)return;let t=e.map(e=>({x:e.x??0,y:e.y??0}));for(;this.overlapLayer(e);)this.contractLayer(this.graph,e,!1);let n=0,r=0;if(e.length>0){let i=e[0];n=(i.x??0)-t[0].x,r=(i.y??0)-t[0].y}let i=Math.sqrt(n*n+r*r),a=fa(this.graph,e);if(a.size>0)for(let e of a)this.moveNode(e,i);this.sorter!==null&&this.sorter.sort([...a]),this.extend([...a])}};function Va(e){new Ba(e).removeOverlaps(e)}var Ha=class{graph;constructor(e){this.graph=e}rotate(e){let t=Wi(e,Di);if(Ki(e,Oi)){let n=Zi(e,Za,void 0),r=na(this.graph,n),i=r[r.length-1],a=r[0],o=P(this.graph,F(this.graph,String(i.targets?.[0]??``))??``),s=P(this.graph,F(this.graph,String(a.targets?.[0]??``))??``),c={x:(o.x??0)+(o.width??0)/2,y:(o.y??0)+(o.height??0)/2},l={x:(s.x??0)+(s.width??0)/2,y:(s.y??0)+(s.height??0)/2},u=t;u<=0&&(u+=N);let d=Wa(c,l);d<=0&&(d+=N);let f=Math.atan2(c.y,c.x);f<=0&&(f+=N),t=Math.PI-(f-u+d/2)}for(let n of e.children??[]){let e=Ua({x:(n.x??0)+(n.width??0)/2,y:(n.y??0)+(n.height??0)/2},t);n.x=e.x-(n.width??0)/2,n.y=e.y-(n.height??0)/2}}};function Ua(e,t){let n=Math.cos(t),r=Math.sin(t);return{x:e.x*n-e.y*r,y:e.x*r+e.y*n}}function Wa(e,t){let n=e.x*t.y-e.y*t.x,r=e.x*t.x+e.y*t.y;return Math.atan2(n,r)}function Ga(e){new Ha(e).rotate(e)}function Ka(e){let t=Number.MAX_VALUE,n=Number.MAX_VALUE,r=Number.MIN_VALUE,i=Number.MIN_VALUE;for(let a of e.children??[]){let e=a.x??0,o=a.y??0,s=a.width??0,c=a.height??0,l=qi(a);t=Math.min(t,e-l.left),n=Math.min(n,o-l.top),r=Math.max(r,e+s+l.right),i=Math.max(i,o+c+l.bottom)}let a=Ji(e),o={x:t-a.left,y:n-a.top},s=r-t+a.left+a.right,c=i-n+a.top+a.bottom;if(Ki(e,Ci)){let t=Zi(e,Za,void 0),n=qi(t),r=(t.x??0)+(t.width??0)/2+(n.left+n.right)/2-o.x,i=(t.y??0)+(t.height??0)/2+(n.top+n.bottom)/2-o.y,a=s-r,l=c-i;if(a<s/2){let e=a-r;s+=e,o.x-=e}else{let e=r-a;s+=e}if(l<c/2){let e=l-i;c+=e,o.y-=e}else{let e=i-l;c+=e}}for(let t of e.children??[])t.x=(t.x??0)-o.x,t.y=(t.y??0)-o.y;Ki(e,zi)||(e.width=s,e.height=c),Xi(e,Vi,s-a.left-a.right),Xi(e,Hi,c-a.top-a.bottom)}var qa=class{graph;constructor(e){this.graph=e}routeEdges(e){for(let t of ea(this.graph,e))if(!$i(this.graph,String(t.sources?.[0]??``))){let n=P(this.graph,F(this.graph,String(t.targets?.[0]??``))??``);if(n===void 0)continue;if(!ra(this.graph,t)){let r=(e.x??0)+(e.width??0)/2,i=(e.y??0)+(e.height??0)/2,a=(n.x??0)+(n.width??0)/2,o=(n.y??0)+(n.height??0)/2,s=new b(a-r,o-i),c=new b(s.x,s.y);se(c,e.width??0,e.height??0),s.x-=c.x,s.y-=c.y,r=a-s.x,i=o-s.y;let l=new b(s.x,s.y);se(l,n.width??0,n.height??0),s.x-=l.x,s.y-=l.y,a=r+s.x,o=i+s.y;let u=Ja(t);u.startPoint={x:r,y:i},u.endPoint={x:a,y:o},this.routeEdges(n)}}}};function Ja(e){return e.sections??=[],e.sections.length===0&&e.sections.push({startPoint:{x:0,y:0},endPoint:{x:0,y:0}}),e.sections[0]}function Ya(e){let t=Zi(e,Za,void 0);new qa(e).routeEdges(t)}function Xa(e){let t=Zi(e,Za,void 0);for(let n of na(e,t)){let t=n.sections?.[0];if(t===void 0)continue;let r=t.startPoint,i=t.endPoint;if(r===void 0||i===void 0)continue;let a={x:i.x-r.x,y:i.y-r.y},o=Math.atan2(a.y,a.x),s=P(e,F(e,String(n.targets?.[0]??``))??``);s!==void 0&&Xi(s,Di,o)}}const Za=`org.eclipse.elk.radial.internal.root`;function Qa(e){(M(e,Ri)??!1)||ct(e);let t=oa(e);if(t===null)throw Error(`The given graph is not a tree!`);Xi(e,Za,t);let n=Wi(e,Ti);return n===0&&(n=ua(e)),Xi(e,Ti,n),Ma(e),Va(e),Gi(e,Ai,`NONE`)!==`NONE`&&Ra(e),Ki(e,Ei)&&Ga(e),Ka(e),Ya(e),Ki(e,ki)&&Xa(e),e}var $a=class{props=/* @__PURE__ */ new Map;ensure(e){let t=this.props.get(e);return t===void 0&&(t={},this.props.set(e,t)),t}getLeftOutline(e){return this.props.get(e)?.leftOutline}setLeftOutline(e,t){this.ensure(e).leftOutline=t}getRightOutline(e){return this.props.get(e)?.rightOutline}setRightOutline(e,t){this.ensure(e).rightOutline=t}getOutlineMaxDepth(e){return this.props.get(e)?.outlineMaxDepth}setOutlineMaxDepth(e,t){this.ensure(e).outlineMaxDepth=t}getMinX(e){return this.props.get(e)?.minX}setMinX(e,t){this.ensure(e).minX=t}getMaxX(e){return this.props.get(e)?.maxX}setMaxX(e,t){this.ensure(e).maxX=t}getMinY(e){return this.props.get(e)?.minY}setMinY(e,t){this.ensure(e).minY=t}getMaxY(e){return this.props.get(e)?.maxY}setMaxY(e,t){this.ensure(e).maxY=t}getEdgeBendHeight(e){return this.props.get(e)?.edgeBendHeight}setEdgeBendHeight(e,t){this.ensure(e).edgeBendHeight=t}getNodeModelOrder(e){return this.props.get(e)?.nodeModelOrder??0}setNodeModelOrder(e,t){this.ensure(e).nodeModelOrder=t}};const eo=o.spacingNodeNode.id,to=o.padding.id,no=o.margins.id,ro=o.omitNodeMicroLayout.id,io=a.vertiflex.verticalConstraint.id,ao=a.vertiflex.layoutStrategy.id,oo=a.vertiflex.layerDistance.id,so=a.vertiflex.considerNodeModelOrder.id;function co(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function lo(e,t,n){let r=co(e,t);if(r==null||r===``)return n;let i=Number(r);return Number.isFinite(i)?i:n}function uo(e,t,n){let r=co(e,t);return r==null||r===``?n:String(r).toLowerCase()===`true`||String(r).toLowerCase()!==`false`&&n}function fo(e,t,n){let r=co(e,t);return r==null||r===``?n:String(r)}function po(e,t){let n=co(e,t);if(n==null||n===``)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function mo(e){let t=co(e,no),n=e=>{if(typeof t==`object`&&t){let n=t;return typeof n[e]==`number`?n[e]:0}return 0};if(typeof t==`string`){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}return{top:e.top??0,left:e.left??0,right:e.right??0,bottom:e.bottom??0}}return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}function ho(e){let t=co(e,to);if(typeof t==`number`)return{top:t,left:t,right:t,bottom:t};if(typeof t==`object`&&t){let e=t,n=t=>typeof e[t]==`number`?e[t]:12;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}if(typeof t==`string`){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}let n=t=>e[t]??12;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return{top:12,left:12,right:12,bottom:12}}o.spacingIndividual.id;function L(e,t){return(e.edges??[]).filter(e=>(e.sources??[])[0]===t.id)}function go(e,t){return(e.edges??[]).filter(e=>(e.targets??[])[0]===t.id)}function _o(e,t){let n=(t.targets??[])[0],r=(e.children??[]).find(e=>e.id===n);if(r===void 0)throw Error(`[vertiflex] 跨层级边不支持:target "${n}" 不在当前层级的直接子节点中(vertiflex 为树算法,边须连接父→直接子;跨层级边请改挂到 group 容器端点)`);return r}function vo(e){for(let t of e.children??[])if(go(e,t).length===0)return t;return null}function yo(e){return e.sections??=[],e.sections.length===0&&e.sections.push({startPoint:{x:0,y:0},endPoint:{x:0,y:0}}),e.sections[0]}function bo(e,t,n){e.bendPoints??=[],e.bendPoints.push({x:t,y:n})}function R(e){return e.x??0}function xo(e){return e.y??0}function So(e,t){let n=lo(e,oo,50),r=lo(e,eo,20);(e.children??[]).length>0&&Co(e,t,0,n,r)}function Co(e,t,n,r,i){let a=po(t,io);a!==void 0&&(n=a),t.y=n;let o=n+r+(t.height??0)+Math.max(mo(t).bottom,i);for(let n of L(e,t))Co(e,_o(e,n),o,r,i)}function wo(e,t){if(e<t)return-1;if(e>t)return 1;if(e===0&&t===0){if(1/e<1/t)return-1;if(1/e>1/t)return 1}return 0}var To=class{invert=!1;constructor(e=!1){this.invert=e}compare(e,t,n){let r;return r=this.invert?wo(t.y??0,e.y??0):wo(e.y??0,t.y??0),r===0?n.getNodeModelOrder(e)-n.getNodeModelOrder(t):r}},z=class{relativeX;absoluteY;next;constructor(e,t,n){this.relativeX=e,this.absoluteY=t,this.next=n}getAbsoluteY(){return this.absoluteY}setAbsoluteY(e){this.absoluteY=e}getRelativeX(){return this.relativeX}setRelativeX(e){this.relativeX=e}getNext(){return this.next}setNext(e){this.next=e}isLast(){return this.next===null}printFullOutline(){let e=[this.toString()];return this.isLast()||e.push(this.getNext().printFullOutline()),e.join(`
|
|
1
|
+
/**
|
|
2
|
+
* ggn-layout — TypeScript port of the Eclipse Layout Kernel (ELK) layered layout algorithms.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026 GGN contributors.
|
|
5
|
+
* Portions derived from ELK (https://github.com/eclipse/elk), Copyright (c) Kiel University
|
|
6
|
+
* and others, are licensed under the Eclipse Public License 2.0 (EPL-2.0);
|
|
7
|
+
* GGN-original portions are licensed under MIT.
|
|
8
|
+
* See LICENSES/EPL-2.0.txt, LICENSE and THIRD_PARTY_NOTICES.md.
|
|
9
|
+
*
|
|
10
|
+
* SPDX-License-Identifier: (MIT AND EPL-2.0)
|
|
11
|
+
*/
|
|
12
|
+
import{T as e,o as t,r as n,w as r}from"./elk-json-Dm4r-Nqy.js";import{ii as i,ni as a,ri as o}from"./algorithms-JOaPA3B9.js";function s(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function c(e,t){let n=s(e,t);if(n==null)return null;if(typeof n==`object`){let e=n;return typeof e.x==`number`&&typeof e.y==`number`?{x:e.x,y:e.y}:null}let[r,i]=String(n).replace(/[()[\]]/g,``).split(`,`).map(e=>Number(e.trim()));return Number.isFinite(r)&&Number.isFinite(i)?{x:r,y:i}:null}function l(e,t){let n=s(e,t);if(n==null)return null;let r=Number(n);return Number.isFinite(r)?r:null}function u(e,t,n=!1){let r=s(e,t);return r==null?n:String(r)===`true`}function d(e){let t=s(e,`org.eclipse.elk.edgeRouting`),n=0,r=0;for(let i of e.children??[]){let a=c(i,`org.eclipse.elk.position`);if(a!==null&&(i.x=a.x,i.y=a.y,String(s(i,`org.eclipse.elk.nodeSize.constraints`)??``).includes(`MINIMUM_SIZE`))){let e=c(i,`org.eclipse.elk.nodeSize.minimum`);if(e!==null&&e.x>0&&e.y>0){let t=Math.max(i.width??0,e.x),n=Math.max(i.height??0,e.y);i.width=t,i.height=n}}n=Math.max(n,(i.x??0)+(i.width??0)),r=Math.max(r,(i.y??0)+(i.height??0));for(let e of i.labels??[]){let t=c(e,`org.eclipse.elk.position`);t!==null&&(e.x=t.x,e.y=t.y),n=Math.max(n,(i.x??0)+(e.x??0)+(e.width??0)),r=Math.max(r,(i.y??0)+(e.y??0)+(e.height??0))}for(let e of i.ports??[]){let t=c(e,`org.eclipse.elk.position`);t!==null&&(e.x=t.x,e.y=t.y);let a=(i.x??0)+(e.x??0),o=(i.y??0)+(e.y??0);n=Math.max(n,a+(e.width??0)),r=Math.max(r,o+(e.height??0));for(let t of e.labels??[]){let e=c(t,`org.eclipse.elk.position`);e!==null&&(t.x=e.x,t.y=e.y),n=Math.max(n,a+(t.x??0)+(t.width??0)),r=Math.max(r,o+(t.y??0)+(t.height??0))}}for(let e of re(i)){let i=f(e,t);n=Math.max(n,i.x),r=Math.max(r,i.y)}for(let a of ie(i)){let o=a.sources?.[0],s=o===void 0?null:ae(e,o);if(s!==null&&s!==i){let e=f(a,t);n=Math.max(n,e.x),r=Math.max(r,e.y)}}}if(t===`ORTHOGONAL`)for(let t of e.children??[])for(let e of re(t))p(e);if(!u(e,`org.eclipse.elk.nodeSize.fixedGraphSize`)){let t=te(e);e.width=n+t.left+t.right,e.height=r+t.top+t.bottom}return e}function f(e,t){let n=e.sources?.[0],r=e.targets?.[0],i={x:0,y:0},a=s(e,`org.eclipse.elk.bendPoints`),o=Array.isArray(a)?a:null;if(o!==null&&o.length>=2){let t={};o.length>=1&&(t.startPoint=ne(o[0])),o.length>=2&&(t.endPoint=ne(o[o.length-1])),o.length>2&&(t.bendPoints=o.slice(1,-1).map(ne)),e.sections=[t]}if(n!==void 0&&r!==void 0)for(let t of e.sections??[]){for(let e of t.bendPoints??[])i.x=Math.max(i.x,e.x),i.y=Math.max(i.y,e.y);t.startPoint&&(i.x=Math.max(i.x,t.startPoint.x),i.y=Math.max(i.y,t.startPoint.y)),t.endPoint&&(i.x=Math.max(i.x,t.endPoint.x),i.y=Math.max(i.y,t.endPoint.y))}return i}function p(e){let t=(e.sections??[])[0]?.bendPoints;t!==void 0&&t.length>0&&(e.layoutOptions={...e.layoutOptions,"org.eclipse.elk.junctionPoints":t.map(e=>({x:e.x,y:e.y}))})}function m(t){let n=l(t,`org.eclipse.elk.spacing.nodeNode`)??20,r=te(t),i=l(t,`org.eclipse.elk.aspectRatio`)??1.6,a=l(t,`org.eclipse.elk.randomSeed`)??0,o=new e(a),s=t.children??[],c=s.length;if(c===0)return t;let u=0,d=0,f=0;for(let e of s){let t=e.width??0,n=e.height??0;u=Math.max(u,t),d=Math.max(d,n),f+=t*n}let p=f+2*n*n*c,m=Math.sqrt(p),g=Math.max(m*i,u),_=Math.max(m/i,d);for(let e of s)e.x=r.left+o.nextDouble()*(g-(e.width??0)),e.y=r.left+o.nextDouble()*(_-(e.height??0));let v=g+r.left+r.right,y=_+r.top+r.bottom;for(let e of s)for(let n of re(e))(!n.sections||(n.sections??[]).length===0)&&h(n,o,v,y,t);return t.width=v,t.height=y,t}function h(e,t,n,r,i){let a=oe(i,e.sources?.[0]),o=oe(i,e.targets?.[0]),s=a.x,c=a.y,l=a.w/2,u=a.h/2;s+=l,c+=u;let d=o.x,f=o.y,p=o.w/2,m=o.h/2;d+=p,f+=m;let h={startPoint:{x:0,y:0},endPoint:{x:0,y:0},bendPoints:[]},g=d;d>s+l?g=s+l:d<s-l&&(g=s-l);let _=f;f>c+u?_=c+u:f<c-u&&(_=c-u),g>s-l&&g<s+l&&_>c-u&&_<c+u&&(g=s+l),h.startPoint={x:g,y:_};let v=s;s>d+p?v=d+p:s<d-p&&(v=d-p);let y=c;c>f+m?y=f+m:c<f-m&&(y=f-m),v>d-p&&v<d+p&&y>f-m&&y<f+m&&(y=f+m),h.endPoint={x:v,y};let ee=t.nextInt(5),te=v-g,ne=y-_,re=Math.sqrt(te*te+ne*ne)*.2,ie=te/(ee+1),ae=ne/(ee+1),b=g,se=_;for(let e=0;e<ee;e++){b+=ie,se+=ae;let e=b+t.nextFloat()*re-re/2;e<0?e=1:e>n&&(e=n-1);let i=se+t.nextFloat()*re-re/2;i<0?i=1:i>r&&(i=r-1),h.bendPoints.push({x:e,y:i})}e.sections=[h]}function g(e){let t=String(s(e,`org.eclipse.elk.box.packingMode`)??`SIMPLE`);if(t!==`SIMPLE`)throw Error(`[layout] box.packingMode '${t}' 尚未移植 (当前仅 SIMPLE); 见 docs/NON-LAYERED-PORTING.md`);return _(e,l(e,`org.eclipse.elk.spacing.nodeNode`)??15,te(e),u(e,`org.eclipse.elk.expandNodes`),u(e,`org.eclipse.elk.interactive`)),e}function _(e,t,n,r,i){let a=v(e,i),o=ee(e),s=l(e,`org.eclipse.elk.aspectRatio`)??1.3,c=y(a,t,n,o.x,o.y,r,s);e.width=c.x,e.height=c.y}function v(e,t){let n=[...e.children??[]];return n.sort((e,n)=>{let r=l(e,`org.eclipse.elk.priority`)??0,i=l(n,`org.eclipse.elk.priority`)??0;if(r!==i)return i-r;if(t){let t=(e.y??0)-(n.y??0);return t===0?(e.x??0)-(n.x??0):t}return(e.width??0)*(e.height??0)-(n.width??0)*(n.height??0)}),n}function y(e,t,n,r,i,a,o){let s=0,c=0;for(let t of e)s=Math.max(s,t.width??0),c+=(t.width??0)*(t.height??0);let l=c/Math.max(1,e.length),u=0;for(let t of e)u+=((t.width??0)*(t.height??0)-l)**2;u=Math.sqrt(u/Math.max(1,e.length)),c+=e.length*1*u,c+=Math.sqrt(c)*(n.bottom+n.top),c+=Math.sqrt(c)*n.right,s=Math.max(s,Math.sqrt(c*o))+n.left;let d=n.left,f=n.top,p=0,m=n.left+n.right,h=[0],g=[];for(let r=0;r<e.length;r++){let i=e[r],o=i.width??0,c=i.height??0;d+o>s&&(a&&(g.push(p),h.push(r)),d=n.left,f+=p+t,p=0,m=Math.max(m,n.left+n.right+o)),i.x=d,i.y=f,m=Math.max(m,d+o+n.right),p=Math.max(p,c),d+=o+t}m=Math.max(m,r);let _=f+p+n.bottom;if(_<i&&(p+=i-_,_=i),a){d=n.left,h.push(e.length);let r=h.shift();g.push(p);let i=0,a=0;for(let o=0;o<e.length;o++){o===r&&(d=n.left,i=g[a++],r=h.shift());let s=e[o];s.height,s.height=i,o+1===r&&(s.width=m-d-n.right),s.x=d,d+=(s.width??0)+t}}return{x:m,y:_}}function ee(e){let t=String(s(e,`org.eclipse.elk.nodeSize.constraints`)??``),n=c(e,`org.eclipse.elk.nodeSize.minimum`);return t.includes(`MINIMUM_SIZE`)&&n!==null?n:{x:0,y:0}}function te(e,t=15){let n=s(e,`org.eclipse.elk.padding`);if(typeof n==`object`&&n){let e=n,r=n=>typeof e[n]==`number`?e[n]:t;return{left:r(`left`),top:r(`top`),right:r(`right`),bottom:r(`bottom`)}}if(typeof n==`string`){let e={};for(let t of n.replace(/^\[|\]$/g,``).split(`,`)){let[n,r]=t.split(`=`).map(e=>e.trim()),i=Number(r);n!==void 0&&Number.isFinite(i)&&(e[n]=i)}let r=n=>e[n]??t;return{left:r(`left`),top:r(`top`),right:r(`right`),bottom:r(`bottom`)}}return{left:t,top:t,right:t,bottom:t}}function ne(e){let t=e;return{x:Number(t.x??0),y:Number(t.y??0)}}function re(e){return e.edges??[]}function ie(e){return[]}function ae(e,t){let n=t.replace(/^N/,``),r=[e];for(;r.length>0;){let e=r.pop();if(e.id===n||e.id===t)return e;for(let t of e.children??[])r.push(t)}return null}function oe(e,t){if(t===void 0)return{x:0,y:0,w:0,h:0};let n=t.replace(/^N/,``),r=ae(e,t);if(r!==null)return{x:r.x??0,y:r.y??0,w:r.width??0,h:r.height??0};let i=n.lastIndexOf(`.`);if(i!==-1){let t=ae(e,n.slice(0,i));if(t!==null){let e=(t.ports??[]).find(e=>e.id===n.slice(i+1)||e.id===`N${n.slice(i+1)}`);return{x:(e?.x??0)+(t.x??0),y:(e?.y??0)+(t.y??0),w:e?.width??0,h:e?.height??0}}}return{x:0,y:0,w:0,h:0}}var b=class e{x;y;constructor(e=0,t=0){this.x=e,this.y=t}clone(){return new e(this.x,this.y)}set(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}scale(e){return this.x*=e,this.y*=e,this}reset(){return this.x=0,this.y=0,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}distance(e){let t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}bound(e,t,n,r){this.x<e?this.x=e:this.x>n&&(this.x=n),this.y<t?this.y=t:this.y>r&&(this.y=r)}wiggle(e,t){let n=2*e.nextDouble()*t-t,r=2*Math.PI*e.nextDouble();this.x+=n*Math.cos(r),this.y+=n*Math.sin(r)}};function se(e,t,n){let r=t/2,i=n/2,a=Math.abs(e.x),o=Math.abs(e.y),s=1,c=1;return a>r&&(s=r/a),o>i&&(c=i/o),e.scale(Math.min(s,c)),e}const x=o.priority.id,ce=o.spacingNodeNode.id,le=o.spacingEdgeLabel.id,ue=o.aspectRatio.id,de=o.randomSeed.id,fe=o.separateConnectedComponents.id,pe=o.padding.id,me=o.interactive.id,he=o.omitNodeMicroLayout.id,ge=o.edgeLabelsInline.id,_e=a.force.forceModel.id,ve=a.force.forceIterations.id,ye=a.force.forceRepulsivePower.id,be=a.force.forceTemperature.id,xe=a.force.forceRepulsion.id,Se=a.force.stressFixed.id,Ce=a.force.stressDesiredEdgeLength.id,we=a.force.stressDimension.id,Te=a.force.stressEpsilon.id,Ee=a.force.stressIterationLimit.id,S={[x]:1,[ce]:80,[le]:5,[ue]:1.6,[de]:1,[fe]:!0,[pe]:50,[me]:!1,[he]:!1,[ge]:!1,[_e]:`FRUCHTERMAN_REINGOLD`,[ve]:300,[ye]:0,[be]:.001,[xe]:5,[Se]:!1,[Ce]:100,[we]:`XY`,[Te]:.001,[Ee]:2147483647};function C(e,t,n){return e.hasProperty(t)?e.getProperty(t):n}function De(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function Oe(e,t){if(typeof e==`number`)return{top:e,left:e,right:e,bottom:e};if(typeof e==`string`){let n=String(e).replace(/[\[\]]/g,``),r={};for(let e of n.split(`,`)){let t=e.indexOf(`=`);if(t!==-1){let n=e.slice(0,t).trim(),i=Number(e.slice(t+1).trim());Number.isFinite(i)&&(r[n]=i)}else{let t=Number(e.trim());Number.isFinite(t)&&(r.top=t,r.left=t,r.right=t,r.bottom=t)}}return{top:r.top??t,left:r.left??t,right:r.right??t,bottom:r.bottom??t}}return{top:t,left:t,right:t,bottom:t}}var ke=class extends i{displacement=new b;position=new b;size=new b;getPosition(){return this.position}getSize(){return this.size}getRadius(){return this.size.length()/2}getDisplacement(){return this.displacement}},Ae=class extends ke{id=0;label;parent;children=null;constructor(e=``,t=null){super(),this.label=e,this.parent=t}isCompound(){return this.children!==null&&this.children.length>0}getLabel(){return this.label}getParent(){return this.parent}getChildren(){return this.children===null&&(this.children=[]),this.children}getDepth(){return this.parent===null?0:this.parent.getDepth()+1}},je=class extends i{bendpoints=[];labels=[];source=null;target=null;getSource(){return this.source}getTarget(){return this.target}setSource(e){this.source=e}setTarget(e){this.target=e}getBendpoints(){return this.bendpoints}getLabels(){return this.labels}getSourcePoint(){let e=this.getTarget().getPosition().clone().sub(this.getSource().getPosition());return se(e,this.getSource().getSize().x,this.getSource().getSize().y),e.add(this.getSource().getPosition())}getTargetPoint(){let e=this.getSource().getPosition().clone().sub(this.getTarget().getPosition());return se(e,this.getTarget().getSize().x,this.getTarget().getSize().y),e.add(this.getTarget().getPosition())}distributeBendpoints(){let e=this.bendpoints.length;if(e>0){let t=this.getSource().getPosition(),n=this.getTarget().getPosition().clone().sub(t).scale(1/(e+1)),r=t.clone();for(let e of this.bendpoints)e.getPosition().x=r.x+n.x,e.getPosition().y=r.y+n.y,r.add(n)}}},Me=class extends ke{edge;text;constructor(e,t){super(),this.edge=e,this.text=t,e.getLabels().push(this)}getText(){return this.text}getEdge(){return this.edge}refreshPosition(){let e=C(this,ge,S[ge]),t=this.edge.getSource().getPosition(),n=this.edge.getTarget().getPosition();if(e){let e=n.clone().sub(t).scale(.5),r=this.getSize().clone().scale(.5),i=t.clone().add(e).sub(r);this.getPosition().set(i)}else{let e=C(this.edge,le,S[le]),r=this.getPosition();t.x>=n.x?t.y>=n.y?(r.x=n.x+(t.x-n.x)/2+e,r.y=n.y+(t.y-n.y)/2-e-this.getSize().y):(r.x=n.x+(t.x-n.x)/2+e,r.y=t.y+(n.y-t.y)/2+e):t.y>=n.y?(r.x=t.x+(n.x-t.x)/2+e,r.y=n.y+(t.y-n.y)/2+e):(r.x=t.x+(n.x-t.x)/2+e,r.y=t.y+(n.y-t.y)/2-e-this.getSize().y)}}},Ne=class extends ke{edge;constructor(e){super(),this.edge=e,e.getBendpoints().push(this)}getEdge(){return this.edge}},Pe=class extends i{nodes=[];edges=[];labels=[];bendpoints=[];adjacency=null;getNodes(){return this.nodes}getEdges(){return this.edges}getLabels(){return this.labels}getBendpoints(){return this.bendpoints}getParticles(){return[...this.nodes,...this.labels,...this.bendpoints]}getConnection(e,t){if(e instanceof Ae&&t instanceof Ae){let n=e,r=t;return(this.adjacency?.[n.id]?.[r.id]??0)+(this.adjacency?.[r.id]?.[n.id]??0)}if(e instanceof Ne&&t instanceof Ne){let n=e,r=t;if(n.getEdge()===r.getEdge())return C(r.getEdge(),x,S[x])}return 0}calcAdjacency(){let e=this.nodes.length;this.adjacency=Array.from({length:e},()=>Array(e).fill(0));for(let e of this.edges)this.adjacency[e.getSource().id][e.getTarget().id]+=C(e,x,S[x])}};const Fe=`force.origin`,Ie=`force.random`,Le=`force.boundingBox.upLeft`,Re=`force.boundingBox.lowRight`;function ze(e,t){for(let[n,r]of Object.entries(t?.layoutOptions??{}))e.setProperty(n,r);for(let[n,r]of Object.entries(t?.properties??{}))e.setProperty(n,r)}function Be(e){return e.split(`.`).length>1?e.slice(0,e.lastIndexOf(`.`)):e}var Ve=class{importGraph(e){let t=new Pe;ze(t,e),t.setProperty(Fe,e);let n=/* @__PURE__ */ new Map;return this.transformNodes(e,t,n),this.transformEdges(e,t,n),t}transformNodes(e,t,n){let r=0;for(let i of e.children??[]){let e=new Ae((i.labels??[])[0]?.text??``);ze(e,i),e.setProperty(Fe,i),e.id=r++,e.getPosition().x=(i.x??0)+(i.width??0)/2,e.getPosition().y=(i.y??0)+(i.height??0)/2,e.getSize().x=Math.max(i.width??0,1),e.getSize().y=Math.max(i.height??0,1),t.getNodes().push(e),n.set(i.id,e)}}transformEdges(e,t,n){for(let r of e.edges??[]){let e=(r.sources??[])[0],i=(r.targets??[])[0];if(e===void 0||i===void 0)continue;let a=n.get(e)??n.get(Be(e)),o=n.get(i)??n.get(Be(i));if(!a||!o)continue;let s=new je;ze(s,r),s.setProperty(Fe,r),s.setSource(a),s.setTarget(o),t.getEdges().push(s);for(let e of r.labels??[]){let n=new Me(s,e.text??``);ze(n,{layoutOptions:e.layoutOptions}),n.setProperty(Fe,e),n.getSize().x=Math.max(e.width??0,1),n.getSize().y=Math.max(e.height??0,1),n.refreshPosition(),t.getLabels().push(n)}}}applyLayout(e){let t=e.getProperty(Fe),n=2**53-1,r=2**53-1,i=-(2**53-1),a=-(2**53-1);for(let t of e.getNodes()){let e=t.getPosition(),o=t.getSize();n=Math.min(n,e.x-o.x/2),r=Math.min(r,e.y-o.y/2),i=Math.max(i,e.x+o.x/2),a=Math.max(a,e.y+o.y/2)}for(let t of e.getBendpoints()){let e=t.getPosition(),o=t.getSize();n=Math.min(n,e.x-o.x/2),r=Math.min(r,e.y-o.y/2),i=Math.max(i,e.x+o.x/2),a=Math.max(a,e.y+o.y/2)}let o=Oe(C(e,pe,S[pe]),S[pe]),s=new b(o.left-n,o.top-r);for(let t of e.getNodes()){let e=t.getProperty(Fe);e&&(e.x=t.getPosition().x+s.x-(e.width??0)/2,e.y=t.getPosition().y+s.y-(e.height??0)/2)}for(let t of e.getEdges()){let e=t.getProperty(Fe);if(!e)continue;let n=(e.sections??[])[0]??{},r=t.getSourcePoint().clone().add(s);n.startPoint={x:r.x,y:r.y},n.endPoint={x:t.getTargetPoint().x+s.x,y:t.getTargetPoint().y+s.y},n.bendPoints=t.getBendpoints().map(e=>({x:e.getPosition().x+s.x,y:e.getPosition().y+s.y})),e.sections===void 0?e.sections=[n]:e.sections[0]=n}for(let t of e.getLabels()){let e=t.getProperty(Fe);e&&(e.x=t.getPosition().x+s.x,e.y=t.getPosition().y+s.y)}let c=i-n+o.left+o.right,l=a-r+o.top+o.bottom;t.width=c,t.height=l}},He=class{split(e){if(!C(e,fe,S[fe]))return[e];let t=e.getNodes().length,n=Array(t).fill(!1),r=Array.from({length:t},()=>[]);for(let t of e.getEdges())r[t.getSource().id].push(t),r[t.getTarget().id].push(t);let i=[];for(let t of e.getNodes()){let a=this.dfs(t,null,null,n,r);a!==null&&(a.copyProperties(e),i.push(a))}if(i.length>1)for(let e of i){let t=0;for(let n of e.getNodes())n.id=t++}return i}dfs(e,t,n,r,i){if(!r[e.id]){r[e.id]=!0;let a=n;a===null&&(a=new Pe),a.getNodes().push(e);for(let n of i[e.id])n.getTarget()!==t&&n.getSource()!==t&&(n.getSource()!==e&&this.dfs(n.getSource(),e,a,r,i),n.getTarget()!==e&&this.dfs(n.getTarget(),e,a,r,i),a.getEdges().push(n),a.getLabels().push(...n.getLabels()));return a}return null}recombine(e){if(e.length===1)return e[0];if(e.length<=0)return new Pe;for(let t of e){let e=0,n=2**53-1,r=2**53-1,i=-(2**53-1),a=-(2**53-1);for(let o of t.getNodes())e+=C(o,x,S[x]),n=Math.min(n,o.getPosition().x-o.getSize().x/2),r=Math.min(r,o.getPosition().y-o.getSize().y/2),i=Math.max(i,o.getPosition().x+o.getSize().x/2),a=Math.max(a,o.getPosition().y+o.getSize().y/2);t.setProperty(x,e),t.setProperty(Le,new b(n,r)),t.setProperty(Re,new b(i,a))}e.sort((e,t)=>{let n=C(t,x,0)-C(e,x,0);return n===0?(e.getProperty(Re).x-e.getProperty(Le).x)*(e.getProperty(Re).y-e.getProperty(Le).y)-(t.getProperty(Re).x-t.getProperty(Le).x)*(t.getProperty(Re).y-t.getProperty(Le).y):n});let t=new Pe;t.copyProperties(e[0]);let n=0,r=0;for(let t of e){let e=this.sizeOf(t);n=Math.max(n,e.x),r+=e.x*e.y}n=Math.max(n,Math.sqrt(r));let i=C(t,ce,S[ce]),a=0,o=0,s=0,c=i;for(let r of e){let e=this.sizeOf(r);a+e.x>n&&(a=0,o+=s+i,s=0),this.moveGraph(t,r,a,o),c=Math.max(c,a+e.x),s=Math.max(s,e.y),a+=e.x+i}return t}sizeOf(e){let t=e.getProperty(Re),n=e.getProperty(Le);return{x:t.x-n.x,y:t.y-n.y}}moveGraph(e,t,n,r){let i=new b(n,r);i.sub(t.getProperty(Le));for(let n of t.getNodes())n.getPosition().add(i),e.getNodes().push(n);for(let n of t.getEdges()){for(let e of n.getBendpoints())e.getPosition().add(i);e.getEdges().push(n)}for(let n of t.getLabels())n.getPosition().add(i),e.getLabels().push(n)}},Ue=class{graph;apsp=[];w=[];desiredEdgeLength=S[Ce];dim=`XY`;epsilon=S[Te];iterationLimit=S[Ee];connectedEdges=/* @__PURE__ */ new Map;initialize(e){if(e.getNodes().length<=1)return;this.graph=e,this.dim=C(e,we,S[we]),this.iterationLimit=C(e,Ee,S[Ee]),this.epsilon=C(e,Te,S[Te]),this.desiredEdgeLength=C(e,Ce,S[Ce]),this.connectedEdges.clear();for(let t of e.getEdges()){let e=t.getSource(),n=t.getTarget();this.connectedEdges.has(e)||this.connectedEdges.set(e,[]),this.connectedEdges.has(n)||this.connectedEdges.set(n,[]),this.connectedEdges.get(e).push(t),this.connectedEdges.get(n).push(t)}let t=e.getNodes().length;this.apsp=Array.from({length:t},()=>Array(t).fill(0));for(let t of e.getNodes())this.dijkstra(t,this.apsp[t.id]);this.w=Array.from({length:t},()=>Array(t).fill(0));for(let e=0;e<t;e++)for(let n=0;n<t;n++){let t=this.apsp[e][n];this.w[e][n]=1/(t*t)}}execute(){if(this.graph.getNodes().length<=1)return;let e=0,t=this.computeStress(),n=1/0;do{e>0&&(t=n);for(let e of this.graph.getNodes()){if(C(e,Se,S[Se]))continue;let t=this.computeNewPosition(e);e.getPosition().reset().add(t)}n=this.computeStress()}while(!this.done(e++,t,n))}dijkstra(e,t){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set;t[e.id]=0;for(let r of this.graph.getNodes())r.id!==e.id&&(t[r.id]=2**53-1),n.add(r);for(;n.size>0;){let e=null,i=1/0;for(let r of n)t[r.id]<i&&(i=t[r.id],e=r);if(e===null)break;n.delete(e),r.add(e);for(let n of this.connectedEdges.get(e)??[]){let i=this.getOther(n,e);if(r.has(i))continue;let a=n.hasProperty(Ce)?n.getProperty(Ce):this.desiredEdgeLength,o=t[e.id]+a;o<t[i.id]&&(t[i.id]=o)}}}done(e,t,n){return t===0||(t-n)/t<this.epsilon||e>=this.iterationLimit}computeStress(){let e=0,t=this.graph.getNodes();for(let n=0;n<t.length;n++){let r=t[n];for(let i=n+1;i<t.length;i++){let n=t[i],a=r.getPosition().distance(n.getPosition())-this.apsp[r.id][n.id];e+=this.w[r.id][n.id]*a*a}}return e}computeNewPosition(e){let t=0,n=0,r=0;for(let i of this.graph.getNodes()){if(e===i)continue;let a=this.w[e.id][i.id];t+=a;let o=e.getPosition().distance(i.getPosition());o>0&&this.dim!==`Y`&&(n+=a*(i.getPosition().x+this.apsp[e.id][i.id]*(e.getPosition().x-i.getPosition().x)/o)),o>0&&this.dim!==`X`&&(r+=a*(i.getPosition().y+this.apsp[e.id][i.id]*(e.getPosition().y-i.getPosition().y)/o))}switch(this.dim){case`X`:return new b(n/t,e.getPosition().y);case`Y`:return new b(e.getPosition().x,r/t);default:return new b(n/t,r/t)}}getOther(e,t){if(e.getSource()===t)return e.getTarget();if(e.getTarget()===t)return e.getSource();throw Error(`Node 'one' must be either source or target of edge 'edge'.`)}},We=class{random;graph;dispBound=0;initialize(e){if(this.graph=e,this.random=e.getProperty(Ie),e.calcAdjacency(),this.dispBound=Math.max(e.getNodes().length*16+e.getEdges().length,256),!C(e,me,S[me])){let t=e.getNodes().length;for(let n of e.getNodes()){let e=n.getPosition();e.x=this.random.nextDouble()*t,e.y=this.random.nextDouble()*t}}let t=e.getBendpoints();for(let n of e.getEdges()){let e=C(n,ye,S[ye]);if(e>0){for(let r=0;r<e;r++)t.push(new Ne(n));n.distributeBendpoints()}}}getGraph(){return this.graph}getRandom(){return this.random}layout(e){this.initialize(e);let t=0;for(;this.moreIterations(t);){this.iterationDone();for(let t of e.getParticles())for(let n of e.getParticles())if(n!==t){let e=this.calcDisplacement(n,t);e!==null&&t.getDisplacement().add(e)}for(let t of e.getParticles()){let e=t.getDisplacement();e.bound(-this.dispBound,-this.dispBound,this.dispBound,this.dispBound),t.getPosition().add(e),e.reset()}t++}}iterationDone(){for(let e of this.graph.getEdges()){for(let t of e.getLabels())t.refreshPosition();e.distributeBendpoints()}}static avoidSamePosition(e,t,n){let r=t.getPosition(),i=n.getPosition();for(;r.x-i.x===0&&r.y-i.y===0;)if(t instanceof Ne&&n instanceof Ne){let e=t.getEdge(),i=e.getTargetPoint().clone().sub(e.getSourcePoint()),a=new b(i.x/i.length()*2,-i.y/i.length()*2);r.add(a);let o=n.getEdge(),s=o.getTargetPoint().clone().sub(o.getSourcePoint()),c=i===s?-2:2,l=new b(s.x/s.length()*c,-s.y/s.length()*c);r.add(l)}else r.wiggle(e,1),i.wiggle(e,1)}},Ge=class e extends We{static ZERO_FACTOR=100;maxIterations=S[ve];springLength=S[ce];repulsionFactor=S[xe];initialize(e){super.initialize(e),this.maxIterations=C(e,ve,S[ve]),this.springLength=C(e,ce,S[ce]),this.repulsionFactor=C(e,xe,S[xe])}moreIterations(e){return e<this.maxIterations}calcDisplacement(t,n){We.avoidSamePosition(this.getRandom(),t,n);let r=n.getPosition().clone().sub(t.getPosition()),i=r.length(),a=Math.max(0,i-t.getRadius()-n.getRadius()),o,s=this.getGraph().getConnection(t,n);return o=s>0?-e.attractive(a,this.springLength)*s:e.repulsive(a,this.repulsionFactor)*C(t,x,S[x]),r.scale(o/i),r}static repulsive(t,n){return t>0?n/(t*t):n*e.ZERO_FACTOR}static attractive(t,n){return t>0?Math.log(t/n):-e.ZERO_FACTOR}},Ke=class e extends We{static SPACING_FACTOR=.01;static ZERO_FACTOR=100;temperature=S[be];threshold=0;k=0;initialize(t){super.initialize(t),this.temperature=C(t,be,S[be]),this.threshold=this.temperature/C(t,ve,S[ve]);let n=t.getNodes().length,r=0,i=0;for(let e of t.getNodes())r+=e.getSize().x,i+=e.getSize().y;let a=r*i,o=C(t,ce,S[ce])*e.SPACING_FACTOR;this.k=Math.sqrt(a/(2*n))*o}moreIterations(){return this.temperature>0}calcDisplacement(t,n){We.avoidSamePosition(this.getRandom(),t,n);let r=n.getPosition().clone().sub(t.getPosition()),i=r.length(),a=Math.max(0,i-t.getRadius()-n.getRadius()),o=e.repulsive(a,this.k)*C(t,x,S[x]),s=this.getGraph().getConnection(t,n);return s>0&&(o-=e.attractive(a,this.k)*s),r.scale(o*this.temperature/i),r}iterationDone(){super.iterationDone(),this.temperature-=this.threshold}static repulsive(t,n){return t>0?n*n/t:n*n*e.ZERO_FACTOR}static attractive(e,t){return e*e/t}};function qe(e){switch(e){case`EADES`:return new Ge;default:return new Ke}}function w(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function Je(e){if(typeof e!=`string`||e===``)return{};let t={};for(let n of e.split(`;,;`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r!==``&&(t[r]=i)}return t}function Ye(e,t){return e===t||e.endsWith(`.`+t)||t===e.replace(/^org\.eclipse\.elk\./,``)}function Xe(e,t,n){for(let[e,r]of Object.entries(Je(w(t,`org.eclipse.elk.spacing.individual`))))if(Ye(n,e))return r;if(e!==void 0){let t=w(e,n);if(t!=null&&t!==``)return t}}function Ze(e,t,n,r){let i=Xe(e,t,n);if(i==null||i===``)return r;let a=Number(i);return Number.isFinite(a)?a:r}const Qe=`org.eclipse.elk.nodeLabels.placement`,$e=`org.eclipse.elk.spacing.portPort`,et={NORTH:`org.eclipse.elk.portAlignment.north`,EAST:`org.eclipse.elk.portAlignment.east`,SOUTH:`org.eclipse.elk.portAlignment.south`,WEST:`org.eclipse.elk.portAlignment.west`},tt={UNDEFINED:0,NORTH:1,EAST:2,SOUTH:3,WEST:4};function nt(e){if(Array.isArray(e))return e.map(String);if(typeof e==`string`){let t=e.match(/^\[(.*)\]$/);return(t?t[1]:e).split(/[\s,]+/).map(e=>e.trim()).filter(Boolean)}return[]}function T(e){let t=w(e,`org.eclipse.elk.port.side`);return typeof t==`string`&&t.trim()!==``?t.trim().toUpperCase():`UNDEFINED`}function rt(e){let t=w(e,`org.eclipse.elk.portConstraints`);if(typeof t==`string`){let e=t.trim().toUpperCase();if([`UNDEFINED`,`FREE`,`FIXED_SIDE`,`FIXED_SIDES`,`FIXED_ORDER`,`FIXED_RATIO`,`FIXED_POS`].includes(e))return e}return`UNDEFINED`}function it(e){return nt(w(e,`org.eclipse.elk.nodeSize.constraints`))}function at(e,t){let n=w(e,et[t]),r=w(e,`org.eclipse.elk.portAlignment.default`),i=n??r;if(typeof i==`string`){let e=i.trim().toUpperCase();if([`BEGIN`,`CENTER`,`END`,`DISTRIBUTED`,`JUSTIFIED`].includes(e))return e}return`DISTRIBUTED`}function ot(e,t){let n=Xe(e,t,`org.eclipse.elk.spacing.portsSurrounding`),r=e=>{if(typeof n==`object`&&n){let t=n;return typeof t[e]==`number`?t[e]:0}return 0};if(typeof n==`string`){let e={};for(let t of n.replace(/^\[|\]$/g,``).split(`,`)){let[n,r]=t.split(`=`).map(e=>e.trim()),i=Number(r);n!==void 0&&Number.isFinite(i)&&(e[n]=i)}return{top:e.top??0,left:e.left??0,right:e.right??0,bottom:e.bottom??0}}return{top:r(`top`),left:r(`left`),right:r(`right`),bottom:r(`bottom`)}}function st(e,t){let n=Xe(e,t,`org.eclipse.elk.nodeLabels.padding`);if(typeof n==`number`)return{top:n,left:n,right:n,bottom:n};if(typeof n==`string`){let e={};for(let t of n.replace(/^\[|\]$/g,``).split(`,`)){let[n,r]=t.split(`=`).map(e=>e.trim()),i=Number(r);n!==void 0&&Number.isFinite(i)&&(e[n]=i)}let t=t=>e[t]??5;return{top:t(`top`),left:t(`left`),right:t(`right`),bottom:t(`bottom`)}}return{top:5,left:5,right:5,bottom:5}}function ct(e){for(let t of e.children??[])lt(e,t)}function lt(e,t){let n=t.ports??[],r=t.labels??[];if((t.children?.length??0)>0||n.length===0&&r.length===0)return;for(let e of n)if(T(e)===`UNDEFINED`)throw Error(`[elk-common] Label and node size calculator can only be used with ports that have port sides assigned.`);let i=rt(t);(i===`FIXED_ORDER`||i===`FIXED_RATIO`||i===`FIXED_POS`)&&ut(n);let a=t.width??0,o=t.height??0,s=it(t);if(!(s.length===0||s.length===1&&s[0]===`PORT_LABELS`)){let i=dt(e,t,n,r,s);a=i.w,o=i.h,t.width=a,t.height=o}i!==`FIXED_POS`&&i!==`FIXED_RATIO`&&mt(e,t,n,i,a,o),vt(e,t,r,a,o),bt(t,a,o)}function ut(e){let t=e=>{let t=w(e,`org.eclipse.elk.portIndex`);if(t==null)return null;let n=Number(t);return Number.isFinite(n)?n:null};e.sort((e,n)=>{let r=T(e),i=T(n),a=(tt[r]??0)-(tt[i]??0);if(a!==0)return a;let o=t(e),s=t(n);if(o!==null&&s!==null&&o!==s)return o-s;let c=e.x??0,l=e.y??0,u=n.x??0,d=n.y??0;switch(r){case`NORTH`:return c-u;case`EAST`:return l-d;case`SOUTH`:return u-c;case`WEST`:return d-l;default:return 0}})}function dt(e,t,n,r,i){let a=Ze(e,t,$e,10),o=ot(e,t),s=st(e,t),c=0,l=0;if(i.includes(`NODE_LABELS`)){let n=Ze(e,t,`org.eclipse.elk.spacing.labelLabel`,0),i=2*n,a=nt(w(t,`org.eclipse.elk.nodeSize.options`)),o=!a.includes(`ASYMMETRICAL`),u=a.includes(`OUTSIDE_NODE_LABELS_OVERHANG`),d=(e,t,n)=>{let r=e??{w:0,h:0,n:0};return r.w=Math.max(r.w,t),r.h+=n,r.n+=1,r},f=/* @__PURE__ */ new Map;for(let e of r){let n=_t(t,e);if(!n.startsWith(`IN_`))continue;let r=n.split(`_`),i=`TCB`.indexOf(r[1]??``),a=`LCR`.indexOf(r[2]??``);if(i<0||a<0)continue;let o=`${i}${a}`;f.set(o,{row:i,col:a,...d(f.get(o),e.width??0,e.height??0)})}if(f.size>0){let e=[[0,0,0],[0,0,0],[0,0,0]],t=[0,0,0];for(let r of f.values())e[r.row][r.col]=Math.max(e[r.row][r.col],r.w),t[r.row]=Math.max(t[r.row],r.h+Math.max(0,r.n-1)*n);let r=0;for(let t of e){if(o){let e=Math.max(t[0],t[2]);t[0]=e,t[2]=e}r=Math.max(r,ft(t,i))}if(o){let e=Math.max(t[0],t[2]);t[0]=e,t[2]=e}let a=ft(t,i);r>0&&(c=Math.max(c,r+s.left+s.right)),a>0&&(l=Math.max(l,a+s.top+s.bottom))}if(!u){let e={N:[void 0,void 0,void 0],S:[void 0,void 0,void 0]},a={W:[void 0,void 0,void 0],E:[void 0,void 0,void 0]};for(let n of r){let r=_t(t,n);if(r.startsWith(`IN_`))continue;let i=r.split(`_`),o=i[1]??``,s=i[2]??``;if(o===`T`||o===`B`){let t=`LCR`.indexOf(s);if(t<0)continue;let r=o===`T`?`N`:`S`;e[r][t]=d(e[r][t],n.width??0,n.height??0)}else if(o===`L`||o===`R`){let e=`TCB`.indexOf(s);if(e<0)continue;let t=o===`L`?`W`:`E`;a[t][e]=d(a[t][e],n.width??0,n.height??0)}}let s=0;for(let t of[`N`,`S`]){let n=e[t].map(e=>e?.w??0);if(o){let e=Math.max(n[0],n[2]);n[0]=e,n[2]=e}s=Math.max(s,ft(n,i))}let u=0;for(let e of[`W`,`E`]){let t=a[e].map(e=>e?e.h+Math.max(0,e.n-1)*n:0);if(o){let e=Math.max(t[0],t[2]);t[0]=e,t[2]=e}u=Math.max(u,ft(t,i))}c=Math.max(c,s),l=Math.max(l,u)}}if(i.includes(`PORTS`)){for(let e of[`NORTH`,`SOUTH`]){let r=n.filter(t=>T(t)===e);if(r.length===0)continue;let i=at(t,e),s=pt(r.map(e=>e.width??0),a,i)+o.left+o.right;c=Math.max(c,s)}for(let e of[`EAST`,`WEST`]){let r=n.filter(t=>T(t)===e);if(r.length===0)continue;let i=at(t,e),s=pt(r.map(e=>e.height??0),a,i)+o.top+o.bottom;l=Math.max(l,s)}}return{w:c,h:l}}function ft(e,t){let n=0,r=0;for(let t of e)t>0&&(n+=t,r++);return r>1?n+t*(r-1):n}function pt(e,t,n){if(e.length===0)return 0;let r=e.reduce((e,t)=>e+t,0);return e.length>1&&(r+=(e.length-1)*t),n===`DISTRIBUTED`&&(r+=2*t),r}function mt(e,t,n,r,i,a){let o=Ze(e,t,$e,10),s=ot(e,t);for(let e of[`NORTH`,`SOUTH`]){let r=e===`SOUTH`?[...n.filter(t=>T(t)===e)].reverse():n.filter(t=>T(t)===e),c=ht(r,i,o,s.left,s.right,at(t,e),e=>e.width??0);for(let t=0;t<r.length;t++){let n=r[t];n.x=c[t],n.y=e===`NORTH`?-(n.height??0):a}}for(let e of[`EAST`,`WEST`]){let r=e===`WEST`?[...n.filter(t=>T(t)===e)].reverse():n.filter(t=>T(t)===e),c=ht(r,a,o,s.top,s.bottom,at(t,e),e=>e.height??0);for(let t=0;t<r.length;t++){let n=r[t];n.y=c[t],n.x=e===`WEST`?-(n.width??0):i}}}function ht(e,t,n,r,i,a,o){let s=e.length;if(s===0)return[];let c=e.map(o),l=c.reduce((e,t)=>e+t,0);s>1&&(l+=(s-1)*n),a===`DISTRIBUTED`&&(l+=2*n);let u=t-r-i,d=r,f=n,p=a,m=l;if((p===`DISTRIBUTED`||p===`JUSTIFIED`)&&s===1&&(p===`DISTRIBUTED`&&(m=l-2*n),p=`CENTER`),u<m)p===`DISTRIBUTED`?(f+=(u-m)/(s+1),d+=f):f+=(u-m)/(s-1);else switch(p){case`BEGIN`:break;case`CENTER`:d+=(u-m)/2;break;case`END`:d+=u-m;break;case`DISTRIBUTED`:{let e=(u-m)/(s+1);f+=Math.max(0,e),d+=f;break}case`JUSTIFIED`:{let e=(u-m)/(s-1);f+=Math.max(0,e);break}}let h=[];for(let e=0;e<s;e++)h.push(d),d+=c[e]+f;return h}function gt(e,t){let n=w(t,Qe);return nt(n===void 0?w(e,Qe):n)}function _t(e,t){let n=[...gt(e,t)].sort().join(` `);for(let{loc:e,sets:t}of[{loc:`OUT_T_L`,sets:[[`OUTSIDE`,`V_TOP`,`H_LEFT`]]},{loc:`OUT_T_C`,sets:[[`OUTSIDE`,`V_TOP`,`H_CENTER`],[`OUTSIDE`,`V_TOP`,`H_CENTER`,`H_PRIORITY`]]},{loc:`OUT_T_R`,sets:[[`OUTSIDE`,`V_TOP`,`H_RIGHT`]]},{loc:`OUT_B_L`,sets:[[`OUTSIDE`,`V_BOTTOM`,`H_LEFT`]]},{loc:`OUT_B_C`,sets:[[`OUTSIDE`,`V_BOTTOM`,`H_CENTER`],[`OUTSIDE`,`V_BOTTOM`,`H_CENTER`,`H_PRIORITY`]]},{loc:`OUT_B_R`,sets:[[`OUTSIDE`,`V_BOTTOM`,`H_RIGHT`]]},{loc:`OUT_L_T`,sets:[[`OUTSIDE`,`H_LEFT`,`V_TOP`,`H_PRIORITY`]]},{loc:`OUT_L_C`,sets:[[`OUTSIDE`,`H_LEFT`,`V_CENTER`],[`OUTSIDE`,`H_LEFT`,`V_CENTER`,`H_PRIORITY`]]},{loc:`OUT_L_B`,sets:[[`OUTSIDE`,`H_LEFT`,`V_BOTTOM`,`H_PRIORITY`]]},{loc:`OUT_R_T`,sets:[[`OUTSIDE`,`H_RIGHT`,`V_TOP`,`H_PRIORITY`]]},{loc:`OUT_R_C`,sets:[[`OUTSIDE`,`H_RIGHT`,`V_CENTER`],[`OUTSIDE`,`H_RIGHT`,`V_CENTER`,`H_PRIORITY`]]},{loc:`OUT_R_B`,sets:[[`OUTSIDE`,`H_RIGHT`,`V_BOTTOM`,`H_PRIORITY`]]},{loc:`IN_T_L`,sets:[[`INSIDE`,`V_TOP`,`H_LEFT`],[`INSIDE`,`V_TOP`,`H_LEFT`,`H_PRIORITY`]]},{loc:`IN_T_C`,sets:[[`INSIDE`,`V_TOP`,`H_CENTER`],[`INSIDE`,`V_TOP`,`H_CENTER`,`H_PRIORITY`]]},{loc:`IN_T_R`,sets:[[`INSIDE`,`V_TOP`,`H_RIGHT`],[`INSIDE`,`V_TOP`,`H_RIGHT`,`H_PRIORITY`]]},{loc:`IN_C_L`,sets:[[`INSIDE`,`V_CENTER`,`H_LEFT`],[`INSIDE`,`V_CENTER`,`H_LEFT`,`H_PRIORITY`]]},{loc:`IN_C_C`,sets:[[`INSIDE`,`V_CENTER`,`H_CENTER`],[`INSIDE`,`V_CENTER`,`H_CENTER`,`H_PRIORITY`]]},{loc:`IN_C_R`,sets:[[`INSIDE`,`V_CENTER`,`H_RIGHT`],[`INSIDE`,`V_CENTER`,`H_RIGHT`,`H_PRIORITY`]]},{loc:`IN_B_L`,sets:[[`INSIDE`,`V_BOTTOM`,`H_LEFT`],[`INSIDE`,`V_BOTTOM`,`H_LEFT`,`H_PRIORITY`]]},{loc:`IN_B_C`,sets:[[`INSIDE`,`V_BOTTOM`,`H_CENTER`],[`INSIDE`,`V_BOTTOM`,`H_CENTER`,`H_PRIORITY`]]},{loc:`IN_B_R`,sets:[[`INSIDE`,`V_BOTTOM`,`H_RIGHT`],[`INSIDE`,`V_BOTTOM`,`H_RIGHT`,`H_PRIORITY`]]}])for(let r of t)if([...r].sort().join(` `)===n)return e;return`UNDEFINED`}function vt(e,t,n,r,i){let a=st(e,t),o=Ze(e,t,`org.eclipse.elk.spacing.labelNode`,5),s=Ze(e,t,`org.eclipse.elk.spacing.labelLabel`,0),c=/* @__PURE__ */ new Map;for(let e of n){let n=_t(t,e);if(!n.startsWith(`IN_`))continue;let r=c.get(n)??[];r.push(e),c.set(n,r)}let l=a.left,u=a.top,d=Math.max(0,r-a.left-a.right),f=Math.max(0,i-a.top-a.bottom);for(let[e,t]of c){let n=e.split(`_`)[1],r=e.split(`_`)[2],i=t.reduce((e,t)=>e+(t.height??0),0)+Math.max(0,t.length-1)*s,a;a=n===`T`?u:n===`B`?u+f-i:u+(f-i)/2;for(let e of t){let t=e.width??0,n=e.height??0,i;i=r===`L`?l:r===`R`?l+d-t:l+(d-t)/2,e.x=i,e.y=a,a+=n+s}}for(let e of n){let n=_t(t,e);if(n.startsWith(`IN_`))continue;let a=e.width??0,s=e.height??0,c,l;switch(n){case`OUT_T_L`:c=0,l=-(s+o);break;case`OUT_T_C`:c=(r-a)/2,l=-(s+o);break;case`OUT_T_R`:c=r-a,l=-(s+o);break;case`OUT_B_L`:c=0,l=i+o;break;case`OUT_B_C`:c=(r-a)/2,l=i+o;break;case`OUT_B_R`:c=r-a,l=i+o;break;case`OUT_L_T`:c=-(a+o),l=0;break;case`OUT_L_C`:c=-(a+o),l=(i-s)/2;break;case`OUT_L_B`:c=-(a+o),l=i-s;break;case`OUT_R_T`:c=r+o,l=0;break;case`OUT_R_C`:c=r+o,l=(i-s)/2;break;case`OUT_R_B`:c=r+o,l=i-s;break;default:continue}e.x=c,e.y=l}}function yt(e,t,n,r,i){if(r<=0&&i<=0)return;let a=Math.min(e.x,t),o=Math.min(e.y,n),s=Math.max(e.x+e.w,t+r),c=Math.max(e.y+e.h,n+i);e.x=a,e.y=o,e.w=s-a,e.h=c-o}function bt(e,t,n){let r={x:0,y:0,w:t,h:n};for(let t of e.labels??[])yt(r,t.x??0,t.y??0,t.width??0,t.height??0);for(let t of e.ports??[])yt(r,t.x??0,t.y??0,t.width??0,t.height??0);let i={top:Math.max(0,-r.y),bottom:Math.max(0,r.y+r.h-n),left:Math.max(0,-r.x),right:Math.max(0,r.x+r.w-t)};e.layoutOptions={...e.layoutOptions,"org.eclipse.elk.margins":i}}function xt(t,n){let r=Number(De(n,de)??1);t.setProperty(Ie,r===0?new e:new e(r))}function St(e){(De(e,he)??!1)||ct(e);let t=new Ve,n=t.importGraph(e);xt(n,e);let r=qe(De(e,_e)??`FRUCHTERMAN_REINGOLD`),i=new He().split(n);for(let e of i)r.layout(e);return n=new He().recombine(i),t.applyLayout(n),e}function Ct(e){De(e,me)??!1?(De(e,he)??!1)||ct(e):St(e);let t=new Ve,n=t.importGraph(e),r=new He().split(n),i=new Ue;for(let e of r)if(!(e.getNodes().length<=1)){i.initialize(e),i.execute();for(let t of e.getLabels())t.refreshPosition()}return n=new He().recombine(r),t.applyLayout(n),e}const wt=o.aspectRatio.id,Tt=o.padding.id,Et=o.spacingNodeNode.id,Dt=o.nodeSizeFixedGraphSize.id,Ot=o.nodeSizeConstraints.id,kt=o.nodeSizeMinimum.id,At=o.contentAlignment.id,jt=o.interactive.id,Mt=o.omitNodeMicroLayout.id,Nt=o.priority.id,Pt=a.rectpacking.widthApproximationStrategy.id,Ft=a.rectpacking.widthApproximationTargetWidth.id,It=a.rectpacking.widthApproximationOptimizationGoal.id,Lt=a.rectpacking.widthApproximationLastPlaceShift.id,Rt=a.rectpacking.packingStrategy.id,zt=a.rectpacking.packingCompactionRowHeightReevaluation.id,Bt=a.rectpacking.packingCompactionIterations.id,Vt=a.rectpacking.whiteSpaceEliminationStrategy.id,Ht=a.rectpacking.trybox.id,Ut=a.rectpacking.orderBySize.id,Wt=a.rectpacking.desiredPosition.id,Gt=a.rectpacking.currentPosition.id,Kt=a.rectpacking.inNewRow.id,qt={[wt]:1.3,[Tt]:15,[Et]:15,[Dt]:!1,[At]:`topLeft`,[jt]:!1,[Mt]:!1,[Pt]:`GREEDY`,[Ft]:-1,[It]:`MAX_SCALE_DRIVEN`,[Lt]:!0,[Rt]:`COMPACTION`,[zt]:!1,[Bt]:1,[Vt]:`NONE`,[Ht]:!1,[Ut]:!1,[Wt]:-1,[Gt]:-1,[Kt]:!1};function E(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function D(e,t){let n=E(e,t);if(n==null||n===``)return qt[t];let r=Number(n);return Number.isFinite(r)?r:qt[t]}function Jt(e,t,n){let r=E(e,t);return r==null||r===``?n:String(r)===`true`}function Yt(e,t,n){let r=E(e,t);return r==null||r===``?n:String(r)}function Xt(e){let t=E(e,Tt);if(typeof t==`number`)return{top:t,left:t,right:t,bottom:t};if(typeof t==`string`){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}let n=t=>e[t]??qt[Tt];return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return{top:qt[Tt],left:qt[Tt],right:qt[Tt],bottom:qt[Tt]}}var Zt=class{scaleMeasure=0;drawingWidth;drawingHeight;area=0;aspectRatio=0;dar;placementOption;nextXcoordinate;nextYcoordinate;constructor(e,t,n,r,i=0,a=0){this.dar=e,this.drawingWidth=t,this.drawingHeight=n,this.placementOption=r,this.nextXcoordinate=i,this.nextYcoordinate=a,this.calcAreaAspectRatioScaleMeasure()}calcAreaAspectRatioScaleMeasure(){this.drawingWidth>0&&this.drawingHeight>0&&(this.area=this.drawingWidth*this.drawingHeight,this.aspectRatio=this.drawingWidth/this.drawingHeight,this.scaleMeasure=O.computeScaleMeasure(this.drawingWidth,this.drawingHeight,this.dar))}getScaleMeasure(){return this.scaleMeasure}getArea(){return this.area}getAspectRatio(){return this.aspectRatio}getPlacementOption(){return this.placementOption}setPlacementOption(e){this.placementOption=e}getNextXcoordinate(){return this.nextXcoordinate}setNextXcoordinate(e){this.nextXcoordinate=e}getNextYcoordinate(){return this.nextYcoordinate}setNextYcoordinate(e){this.nextYcoordinate=e}getDesiredAspectRatio(){return this.dar}getDrawingWidth(){return this.drawingWidth}setDrawingWidth(e){this.drawingWidth=e,this.calcAreaAspectRatioScaleMeasure()}getDrawingHeight(){return this.drawingHeight}setDrawingHeight(e){this.drawingHeight=e,this.calcAreaAspectRatioScaleMeasure()}};const O={computeScaleMeasure(e,t,n){return Math.min(n/e,1/t)},resetCoordinates(e){for(let t of e)t.x=0,t.y=0},calculateDimensionsRows(e,t){let n=0,r=0,i=0;for(let a of e)n=Math.max(n,a.getWidth()),r+=a.getHeight()+(i>0?t:0),i++;return{x:n,y:r}},calculateDimensions(e){let t=0,n=0;for(let r of e)t=Math.max((r.width??0)+(r.x??0),t),n=Math.max((r.height??0)+(r.y??0),n);return{x:t,y:n}}};var Qt=class{additionalHeight=0;drawingHeight=0;drawingWidth=0;minHeight=0;minWidth=0;rows=[];targetWidth=0;minRowIncrease=0;maxRowIncrease=0;minRowDecrease=0;maxRowDecrease=0};const $t={getWidthLPRorLPB(e,t,n){return Math.max(e,t+n)},getHeightLPRorLPB(e,t,n){return Math.max(e,t+n)},calculateYforLPR(e,t,n,r){let i=null,a=0;for(let o of t){let t=(o.y??0)+(o.height??0);this.verticalOrderConstraint(o,e,r)&&((i===null||(n.y??0)-t<(n.y??0)-a)&&(i=o),a=(i.y??0)+(i.height??0))}return i===null?0:a+r},calculateXforLPB(e,t,n,r){let i=null,a=0;for(let o of t){let t=(o.x??0)+(o.width??0);this.horizontalOrderConstraint(o,e,r)&&((i===null||(n.x??0)-t<(n.x??0)-a)&&(i=o),a=(i.x??0)+(i.width??0))}return i===null?0:a+r},calculateAreaLPR(e,t,n){let r=(e.y??0)+(e.height??0),i=n.getNextYcoordinate()+(t.height??0),a=Math.max(r,i)-Math.min(e.y??0,n.getNextYcoordinate());return(n.getNextXcoordinate()+(t.width??0)-(e.x??0))*a},calculateAreaLPB(e,t,n){let r=(e.x??0)+(e.width??0),i=n.getNextXcoordinate()+(t.width??0);return(Math.max(r,i)-Math.min(e.x??0,n.getNextXcoordinate()))*(n.getNextYcoordinate()+(t.height??0)-(e.y??0))},verticalOrderConstraint(e,t,n){return t<(e.x??0)+(e.width??0)+n},horizontalOrderConstraint(e,t,n){return t<(e.y??0)+(e.height??0)+n}},en=(e,t,n)=>{let r=1/0;for(let t of e)r=Math.min(r,(t.getDrawingWidth()+n.left+n.right)*(t.getDrawingHeight()+n.top+n.bottom));return e.filter(e=>(e.getDrawingWidth()+n.left+n.right)*(e.getDrawingHeight()+n.top+n.bottom)===r)},tn=(e,t,n)=>{let r=1/0;for(let i of e)r=Math.min(r,Math.abs((i.getDrawingWidth()+n.left+n.right)/(i.getDrawingHeight()+n.top+n.bottom)-t));return e.filter(e=>Math.abs((e.getDrawingWidth()+n.left+n.right)/(e.getDrawingHeight()+n.top+n.bottom)-t)===r)},nn=(e,t,n)=>{let r=-1/0;for(let t of e)r=Math.max(r,O.computeScaleMeasure(t.getDrawingWidth()+n.left+n.right,t.getDrawingHeight()+n.top+n.bottom,t.getDesiredAspectRatio()));return e.filter(e=>O.computeScaleMeasure(e.getDrawingWidth()+n.left+n.right,e.getDrawingHeight()+n.top+n.bottom,e.getDesiredAspectRatio())===r)};var rn=class{aspectRatio;goal;lpShift;constructor(e,t,n){this.aspectRatio=e,this.goal=t,this.lpShift=n}approxBoundingBox(e,t,n){let r=e[0];r.x=0,r.y=0;let i=[r],a=r,o=new Zt(this.aspectRatio,r.width??0,r.height??0,`WHOLE_DRAWING`);for(let r=1;r<e.length;r++){let s=e[r],c=this.calcValuesForOpt(`CANDIDATE_POSITION_LAST_PLACED_RIGHT`,s,a,o,i,t),l=this.calcValuesForOpt(`CANDIDATE_POSITION_LAST_PLACED_BELOW`,s,a,o,i,t),u=this.calcValuesForOpt(`CANDIDATE_POSITION_WHOLE_DRAWING_RIGHT`,s,a,o,i,t),d=this.calcValuesForOpt(`CANDIDATE_POSITION_WHOLE_DRAWING_BELOW`,s,a,o,i,t),f=this.findBestCandidate(c,l,u,d,s,a,n);s.x=f.getNextXcoordinate(),s.y=f.getNextYcoordinate(),f.setPlacementOption(`WHOLE_DRAWING`),o=f,a=s,i.push(s)}return o}findBestCandidate(e,t,n,r,i,a,o){let s=[e,t,n,r],c=[];switch(this.goal){case`MAX_SCALE_DRIVEN`:c=[nn,en,tn];break;case`ASPECT_RATIO_DRIVEN`:c=[tn,en,nn];break;case`AREA_DRIVEN`:c=[en,nn,tn]}for(let e of c)s.length>1&&(s=e(s,this.aspectRatio,o));if(s.length===1)return s[s.length-1];if(s.length===2)return this.checkSpecialCases(s[0],s[1],a,i);throw Error(`[rectpacking] no best candidate found`)}checkSpecialCases(e,t,n,r){let i=e.getPlacementOption(),a=t.getPlacementOption(),o=i===`CANDIDATE_POSITION_LAST_PLACED_BELOW`||i===`CANDIDATE_POSITION_WHOLE_DRAWING_BELOW`,s=a===`CANDIDATE_POSITION_LAST_PLACED_BELOW`||a===`CANDIDATE_POSITION_WHOLE_DRAWING_BELOW`,c=i===`CANDIDATE_POSITION_LAST_PLACED_RIGHT`||i===`CANDIDATE_POSITION_WHOLE_DRAWING_RIGHT`,l=a===`CANDIDATE_POSITION_LAST_PLACED_RIGHT`||a===`CANDIDATE_POSITION_WHOLE_DRAWING_RIGHT`,u=i===`CANDIDATE_POSITION_LAST_PLACED_RIGHT`||i===`CANDIDATE_POSITION_LAST_PLACED_BELOW`,d=a===`CANDIDATE_POSITION_LAST_PLACED_RIGHT`||a===`CANDIDATE_POSITION_LAST_PLACED_BELOW`;if(o&&s)return e.getPlacementOption()===`CANDIDATE_POSITION_WHOLE_DRAWING_BELOW`?e:t;if(c&&l)return e.getPlacementOption()===`CANDIDATE_POSITION_WHOLE_DRAWING_RIGHT`?e:t;if(u&&d){let a,o;return i===`CANDIDATE_POSITION_LAST_PLACED_RIGHT`?(a=e,o=t):(a=t,o=e),$t.calculateAreaLPR(n,r,a)<=$t.calculateAreaLPB(n,r,o)?e.getPlacementOption()===`CANDIDATE_POSITION_LAST_PLACED_RIGHT`?e:t:e.getPlacementOption()===`CANDIDATE_POSITION_LAST_PLACED_BELOW`?e:t}return e}calcValuesForOpt(e,t,n,r,i,a){let o=0,s=0,c=r.getDrawingWidth(),l=r.getDrawingHeight(),u=t.height??0,d=t.width??0,f,p;switch(e){case`CANDIDATE_POSITION_LAST_PLACED_RIGHT`:o=(n.x??0)+(n.width??0)+a,s=this.lpShift?$t.calculateYforLPR(o,i,n,a):n.y??0,f=$t.getWidthLPRorLPB(c,o,d),p=$t.getHeightLPRorLPB(l,s,u);break;case`CANDIDATE_POSITION_LAST_PLACED_BELOW`:s=(n.y??0)+(n.height??0)+a,o=this.lpShift?$t.calculateXforLPB(s,i,n,a):n.x??0,f=$t.getWidthLPRorLPB(c,o,d),p=$t.getHeightLPRorLPB(l,s,u);break;case`CANDIDATE_POSITION_WHOLE_DRAWING_RIGHT`:o=c+a,s=0,f=c+a+d,p=Math.max(l,u);break;case`CANDIDATE_POSITION_WHOLE_DRAWING_BELOW`:o=0,s=l+a,f=Math.max(c,d),p=l+a+u;break;default:throw Error(`[rectpacking] IllegalPlacementOption`)}return new Zt(this.aspectRatio,f,p,e,o,s)}};function an(e,t,n){let r=Yt(e,Pt,`GREEDY`);switch(r){case`GREEDY`:{let r=D(e,wt),i=Xt(e),a=Yt(e,It,`MAX_SCALE_DRIVEN`),o=Jt(e,Lt,!0),s=D(e,Et);O.resetCoordinates(n),t.targetWidth=new rn(r,a,o).approxBoundingBox(n,s,i).getDrawingWidth();break}case`TARGET_WIDTH`:if(E(e,Ft)!==void 0&&E(e,Ft)!==null)t.targetWidth=D(e,Ft);else throw Error(`[rectpacking] A target width has to be set if the TargetWidthWidthApproximator should be used.`);break;default:throw Error(`[rectpacking] no implementation for width approximator ${r}`)}}var on=class{x;y;width=0;height=0;nodeNodeSpacing;rects=[];constructor(e,t,n){this.x=e,this.y=t,this.nodeNodeSpacing=n}addRectangle(e){return e.x=this.x+this.width+(this.rects.length===0?0:this.nodeNodeSpacing),e.y=this.y,this.height=Math.max(this.height,e.height??0),this.width+=(e.width??0)+(this.rects.length===0?0:this.nodeNodeSpacing),this.rects.push(e),!0}removeRectangle(e,t){let n=this.rects.indexOf(e);n!==-1&&this.rects.splice(n,1),t&&this.updateRow()}updateRow(){let e=0,t=0;for(let n of this.rects)n.x=this.x+e,n.y=this.y,e+=(n.width??0)+this.nodeNodeSpacing,t=Math.max(t,(n.height??0)+this.nodeNodeSpacing);this.width=e-this.nodeNodeSpacing,this.height=t-this.nodeNodeSpacing}expand(e,t,n){let r=(e-this.width)/this.rects.length,i=0;this.height+=t,this.width=e;for(let e of this.rects)e.width,e.height,e.x=(e.x??0)+i*r,e.y=(e.y??0)+n*t,e.width=(e.width??0)+r,e.height=this.height,i++,e.width,e.height}getY(){return this.y}setY(e){this.y=e}getWidth(){return this.width}getHeight(){return this.height}getNodes(){return this.rects}getX(){return this.x}setX(e){this.x=e}},sn=class{smallestRectWidth=1/0;minWidth=0;width=0;minHeight=0;smallestRectHeight=1/0;averageHeight=0;maxHeight=0;height=0;children=[];rows=[];x;y;parentRow;stack=null;nodeNodeSpacing;fixed=!1;positionFixed=!1;constructor(e,t,n,r){this.nodeNodeSpacing=r,this.parentRow=n,this.x=e,this.y=t,this.width=0,this.height=0}addChild(e){this.rows.length===0&&this.rows.push(new on(this.x,this.y,this.nodeNodeSpacing)),this.children.push(e),this.rows[this.rows.length-1].addRectangle(e),this.adjustSizeAdd(e)}addChildInNewRow(e){this.children.push(e);let t=this.getLastRow();this.rows.push(new on(this.x,t.getY()+t.getHeight()+this.nodeNodeSpacing,this.nodeNodeSpacing)),this.getLastRow().addRectangle(e),this.adjustSizeAdd(e)}removeChild(e){let t=this.children.indexOf(e);t!==-1&&this.children.splice(t,1);for(let t=0;t<this.rows.length;t++){let n=this.rows[t];if(n.getNodes().includes(e)){n.removeRectangle(e,!0),n.getNodes().length===0&&this.rows.splice(t,1);break}}this.adjustSizeAfterRemove()}setLocation(e,t){this.adjustChildrensXandY(e-this.x,t-this.y);for(let n of this.rows)n.setX(n.getX()+e-this.x),n.setY(n.getY()+t-this.y);this.x=e,this.y=t}adjustChildrensXandY(e,t){for(let n of this.children)n.x=(n.x??0)+e,n.y=(n.y??0)+t}adjustSizeAdd(e){let t=this.getLastRow().getWidth();this.smallestRectWidth=Math.min(this.smallestRectWidth,e.width??0),this.width=Math.max(this.width,t),this.minWidth=Math.max(this.minWidth,(e.width??0)+(this.children.length===1?0:this.nodeNodeSpacing)),this.smallestRectHeight=Math.min(this.smallestRectHeight,e.height??0),this.maxHeight+=(e.height??0)+(this.children.length===1?0:this.nodeNodeSpacing),this.minHeight=Math.max(this.minHeight,e.height??0);let n=this.rows.length>0?(this.rows.length-1)*this.nodeNodeSpacing:0;for(let e of this.rows)n+=e.getHeight();this.height=n,this.averageHeight=this.maxHeight/this.children.length-this.nodeNodeSpacing*((this.children.length-1)/this.children.length),this.parentRow.notifyAboutNodeChange()}getWidthForTargetHeight(e){if(this.maxHeight<=e||this.fitsRectsInWidthHeight(this.minWidth,e,!1))return this.minWidth;let t=this.width,n=this.minWidth,r=this.width,i=(t-n)/2+n;for(;n+1<t;)this.fitsRectsInWidthHeight(i,e,!1)?(r=i,t=i):n=i,i=(t-n)/2+n;return r}getHeightForTargetWidth(e){return this.layoutRectsInWidth(e,!1).height}placeRectsIn(e,t){return this.fitsRectsInWidthHeight(e,t,!0)}placeRectsInWidth(e){let t=this.width,n=this.height,r=this.layoutRectsInWidth(e,!0);return r.width!==t||r.height!==n}layoutRectsInWidth(e,t){let n=0,r=this.y,i=0,a=0,o=0,s=0,c=0;t&&(this.rows=[],this.rows.push(new on(this.x,this.y,this.nodeNodeSpacing)));let l=0;for(let u of this.children)n+(u.width??0)+(l>0?this.nodeNodeSpacing:0)>e&&o>0&&(n=0,r+=o+this.nodeNodeSpacing,i=Math.max(i,s),a+=o+this.nodeNodeSpacing,o=0,s=0,t&&(c++,this.rows.push(new on(this.x,r,this.nodeNodeSpacing))),l=0),s+=(u.width??0)+(l>0?this.nodeNodeSpacing:0),o=Math.max(o,u.height??0),t&&this.rows[c].addRectangle(u),n+=(u.width??0)+(l>0?this.nodeNodeSpacing:0),l++;return i=Math.max(i,s),a+=o,t&&(this.width=i,this.height=a,this.parentRow.notifyAboutNodeChange()),{x:this.x,y:this.y,width:i,height:a}}fitsRectsInWidthHeight(e,t,n){let r=this.layoutRectsInWidth(e,n);return r.width<=e&&r.height<=t}adjustSizeAfterRemove(){let e=0,t=0,n=[],r=0;for(let i=0;i<this.rows.length;i++){let a=this.rows[i];a.getNodes().length===0?n.push(i):(e=Math.max(e,a.getWidth()),t+=a.getHeight()+(r>0?this.nodeNodeSpacing:0)),r++}for(let e=n.length-1;e>=0;e--)this.rows.splice(n[e],1);this.height=t,this.width=e,this.minWidth=0,this.minHeight=0,this.maxHeight=0,this.smallestRectHeight=1/0,this.smallestRectWidth=1/0;for(let e of this.children)this.smallestRectWidth=Math.min(this.smallestRectWidth,e.width??0),this.minWidth=Math.max(this.minWidth,e.width??0),this.minHeight=Math.max(this.minHeight,e.height??0),this.smallestRectHeight=Math.min(this.smallestRectHeight,e.height??0),this.maxHeight+=(e.height??0)+this.nodeNodeSpacing;this.averageHeight=this.maxHeight/this.children.length-this.nodeNodeSpacing*((this.children.length-1)/this.children.length),this.parentRow.notifyAboutNodeChange()}expand(e,t){let n=this.width+e;this.width+=e,this.height+=t;let r=t/this.rows.length,i=0;for(let e of this.rows)e.expand(n,r,i),i++}getWidth(){return this.width}setWidth(e){this.width=e}getHeight(){return this.height}setHeight(e){this.height=e}getChildren(){return this.children}getX(){return this.x}getY(){return this.y}getParentRow(){return this.parentRow}setParentRow(e){this.parentRow=e}getMinWidth(){return this.minWidth}getMinHeight(){return this.minHeight}getMaxHeight(){return this.maxHeight}getSmallestRectHeight(){return this.smallestRectHeight}getAverageHeight(){return this.averageHeight}isFixed(){return this.fixed}setFixed(e){this.fixed=e}isPositionFixed(){return this.positionFixed}setPositionFixed(e){this.positionFixed=e}getRows(){return this.rows}getLastRowNewX(){let e=this.getLastRow();return e.getX()+e.getWidth()}getLastRowY(){return this.getLastRow().getY()}getLastRow(){return this.rows[this.rows.length-1]}getStack(){return this.stack}setStack(e){this.stack=e}getSmallestRectWidth(){return this.smallestRectWidth}setSmallestRectWidth(e){this.smallestRectWidth=e}resetBlock(){this.adjustSizeAfterRemove()}},cn=class{blocks=[];x;y;width=0;height=0;nodeNodeSpacing;constructor(e,t,n){this.x=e,this.y=t,this.nodeNodeSpacing=n}addBlock(e){e.setStack(this),this.width=Math.max(this.width,e.getWidth()),this.height+=e.getHeight()+(this.blocks.length===0?0:this.nodeNodeSpacing),this.blocks.push(e)}updateDimension(){let e=0,t=0,n=0;for(let r of this.blocks)t=Math.max(t,r.getWidth()),e+=r.getHeight()+(n>0?this.nodeNodeSpacing:0),n++;this.height=e,this.width=t}setLocation(e,t){let n=e-this.x,r=t-this.y;for(let e of this.blocks)e.setLocation(e.getX()+n,e.getY()+r);this.x=e,this.y=t}getWidthForFixedHeight(e){if(this.blocks.length===1)return this.blocks[0].getWidthForTargetHeight(e);let t=this.getMinimumWidth(),n=this.width,r=t,i=this.width,a=(n-r)/2+r;for(;r+1<n;){let t=0;for(let e of this.blocks)t+=e.getHeightForTargetWidth(a);t<e?(i=a,n=a):r=a,a=(n-r)/2+r}return i}placeRectsIn(e){let t=this.getY(),n=0;for(let r of this.blocks)r.setLocation(this.x,t),r.placeRectsInWidth(e),n=Math.max(n,r.getWidth()),t+=r.getHeight()+this.nodeNodeSpacing;this.width=n,this.height=t}expand(e,t){let n=0,r=t/this.blocks.length;for(let t of this.blocks)t.setLocation(t.getX(),t.getY()+n*r),t.expand(this.getWidth()-t.getWidth()+e,r),n++}getMinimumWidth(){let e=0;for(let t of this.blocks)e=Math.max(e,t.getMinWidth());return e}getBlocks(){return this.blocks}getX(){return this.x}getY(){return this.y}getWidth(){return this.width}setWidth(e){this.width=e}getHeight(){return this.height}setHeight(e){this.height=e}},ln=class{height=0;width=0;y;nodeNodeSpacing;children=[];stacks=[];potentialAdditionalWidthToGetLastBlock=0;constructor(e,t){this.y=e,this.nodeNodeSpacing=t}notifyAboutNodeChange(){let e=0,t=-1/0,n=0;for(let r of this.children)e+=r.getWidth()+(n>0?this.nodeNodeSpacing:0),t=Math.max(t,r.getHeight()),n++;this.width=e,this.height=t}expand(e,t){let n=(e-this.width)/this.stacks.length,r=0;for(let e of this.stacks){let i=this.getHeight()-e.getHeight()+t;e.setLocation(e.getX()+r*n,e.getY()),e.expand(n,i),r++}}calculateBlockStacks(){let e=-1;for(let t of this.children)t.getX()===e?this.stacks[this.stacks.length-1].addBlock(t):(this.stacks.push(new cn(t.getX(),this.y,this.nodeNodeSpacing)),this.stacks[this.stacks.length-1].addBlock(t),e=t.getX())}getFirstBlock(){return this.children[0]}getLastBlock(){return this.children[this.children.length-1]}getNumberOfAssignedBlocks(){return this.children.length}addBlock(e){this.height=Math.max(this.height,e.getHeight()),this.width+=e.getWidth()+(this.children.length===0?0:this.nodeNodeSpacing),this.children.push(e)}removeBlock(e){let t=this.children.indexOf(e);t!==-1&&this.children.splice(t,1),this.width-=e.getWidth()+(this.children.length===0?0:this.nodeNodeSpacing);let n=Number.MIN_VALUE;for(let e of this.children)n=Math.max(n,e.getHeight());this.height=n}getHeight(){return this.height}setHeight(e){this.height=e}getWidth(){return this.width}setWidth(e){this.width=e}getY(){return this.y}setY(e){let t=e-this.y;for(let e of this.stacks)e.setLocation(e.getX(),e.getY()+t);this.y=e}getChildren(){return this.children}getStacks(){return this.stacks}getPotentialAdditionalWidthToGetLastBlock(){return this.potentialAdditionalWidthToGetLastBlock}setPotentialAdditionalWidthToGetLastBlock(e){this.potentialAdditionalWidthToGetLastBlock=e}resetStacks(){this.stacks=[]}};const un={place(e,t,n,r){let i=[],a=new ln(0,n),o=0;a.addBlock(new sn(0,0,a,n));let s=0;for(let c of e){let e=a.getLastBlock();if((s+(c.width??0)+(a.getChildren()[0].getChildren().length===0?0:n)>t||fn(c))&&(s=0,o+=a.getHeight()+n,i.push(a),a=new ln(o,n),e=new sn(0,a.getY(),a,n),a.addBlock(e),s=0),e.getChildren().length===0||!r&&dn(e,c,n))e.addChild(c);else{let t=new sn(e.getX()+e.getWidth()+n,a.getY(),a,n);a.addBlock(t),t.addChild(c)}s=(c.x??0)+(c.width??0)}return i.push(a),i},placeRectInBlock(e,t,n,r,i){if(dn(t,n,i)){if(t.getLastRowNewX()+(n.width??0)+i<=r&&(t.getLastRowY()-e.getY()+(n.height??0)<=e.getHeight()||e.getChildren().length===1))return t.addChild(n),!0;if(t.getX()+(n.width??0)<=r&&t.getY()+t.getHeight()+(n.height??0)+i<=e.getY()+e.getHeight())return t.addChildInNewRow(n),!0}return!1}};function dn(e,t,n){let r=t.height??0;return r>=e.getSmallestRectHeight()&&r<=e.getMinHeight()||e.getAverageHeight()*.5<=r&&e.getAverageHeight()*1.5>=r}function fn(e){return Jt(e,Kt,!1)}const pn={compact(e,t,n,r,i){let a=!1,o=!1,s=e+1,c=t[e],l=c.getChildren(),u=null;for(let e=0;e<c.getNumberOfAssignedBlocks();e++){let d=l[e];if(d.isFixed())continue;if(d.getChildren().length===0){c.removeBlock(d),e--,a=!0;continue}d.isPositionFixed()||(u!==null&&u.updateDimension(),u=new cn(u===null?0:u.getX()+u.getWidth()+r,c.getY(),r),d.setLocation(u.getX()+u.getWidth(),c.getY()),c.getStacks().push(u),u.addBlock(d),d.setPositionFixed(!0));let f=null;f=mn(t,c,e,s);let p=!1;if(f!==null&&(p=f.getParentRow()!==c),f!==null){if(f.getChildren().length!==0&&!fn(f.getChildren()[0]))gn(d,n),a=_n(c,d,f,n,r)||a;else{c.removeBlock(f);break}if(f.getChildren().length===0)for(t.length>s&&t[s].removeBlock(f),f=null;t.length>s&&t[s].getChildren().length===0;)t.splice(s,1);if(f===null){e--;continue}if(!fn(f.getChildren()[0])&&vn(t,c,d,f,p,n,s,r)){a=!0;continue}if(p){let e=c.getHeight(),l=f.getMinHeight();if(!fn(f.getChildren()[0])&&yn(t,c,d,f,p,n,s,r,i)){if(a=!0,e<l){o=!0,f.setParentRow(c);break}continue}if(hn(c,d)){d.setFixed(!0),a=!0;continue}}else if(hn(c,d)){d.setFixed(!0),a=!0;continue}if(a)continue}hn(c,d)?(d.setFixed(!0),a=!0,f!==null&&f.setPositionFixed(!1)):u?.updateDimension()}return{somethingWasChanged:a,compactRowAgain:o}}};function mn(e,t,n,r){return n<t.getNumberOfAssignedBlocks()-1?t.getChildren()[n+1]:r<e.length&&e[r].getChildren().length!==0?e[r].getChildren()[0]:null}function hn(e,t){let n=!1,r=t.getStack().getWidth();if(t.getHeight()<e.getHeight()){let i=t.getStack().getWidthForFixedHeight(e.getHeight());t.getStack().getWidth()>i&&(t.getStack().placeRectsIn(i),n=r!==t.getStack().getWidth())}return n}function gn(e,t){e.placeRectsInWidth(t-e.getX()),e.getStack().updateDimension()}function _n(e,t,n,r,i){let a=!1,o=n.getChildren()[0];for(;un.placeRectInBlock(e,t,o,r,i)&&(a=!0,n.removeChild(o),n.getChildren().length!==0);)o=n.getChildren()[0];return n.getChildren().length===0&&n.getParentRow().removeBlock(n),a&&t.getStack().updateDimension(),a}function vn(e,t,n,r,i,a,o,s){let c=!1,l=a-n.getX(),u=n.getY()-t.getY()+n.getHeightForTargetWidth(l);if(r.getMinWidth()+s>l)return!1;let d=r.getHeightForTargetWidth(l);return u+s+d<=t.getHeight()?(n.placeRectsInWidth(a-n.getX()),n.setFixed(!0),r.placeRectsInWidth(a-n.getX()),r.setLocation(n.getX(),n.getY()+n.getHeight()+s),r.setPositionFixed(!0),n.getStack().addBlock(r),c=!0,i&&(t.addBlock(r),r.setParentRow(t),e.length>o&&(e[o].removeBlock(r),e[o].getChildren().length===0&&e.splice(o,1)))):n.getStack().updateDimension(),c}function yn(e,t,n,r,i,a,o,s,c){let l=!1,u=n.getStack().getWidthForFixedHeight(t.getY()+t.getHeight()-n.getStack().getY()),d=r.getMinHeight()>t.getHeight()&&c,f=a-(n.getStack().getX()+u-s),p=r.getHeightForTargetWidth(f);if(d&&p>r.getMinHeight())return!1;if(d){let e=0;for(let n of t.getStacks())e+=n.getWidthForFixedHeight(r.getMinHeight())+s;f=a-e}if(f<r.getMinWidth())return!1;let m=o===e.length-1&&f>=e[o].getWidth();return!d&&p>t.getHeight()&&!m?!1:((m||d||p<=t.getHeight())&&(m&&p>t.getHeight()?(n.setHeight(p),n.placeRectsInWidth(n.getWidthForTargetHeight(p))):(n.getStack().placeRectsIn(u),n.setFixed(!0)),r.placeRectsInWidth(a-(n.getX()+n.getWidth())),r.setLocation(n.getStack().getX()+n.getStack().getWidth(),t.getY()),t.addBlock(r),e.length>o&&(e[o].removeBlock(r),e[o].getChildren().length===0&&e.splice(o,1)),l=!0),l)}var bn=class{aspectRatio;nodeNodeSpacing;potentialRowWidthDecreaseMin=1/0;potentialRowWidthDecreaseMax=0;potentialRowWidthIncreaseMin=1/0;potentialRowWidthIncreaseMax=0;constructor(e,t){this.aspectRatio=e,this.nodeNodeSpacing=t}start(e,t,n){let r=n.targetWidth,i=n.minWidth,a=n.minHeight,o=Jt(e,zt,!1);O.resetCoordinates(e.children??[]);let s=un.place(e.children??[],r,this.nodeNodeSpacing,o);for(let e=0;e<s.length;e++){let t=s[e];if(e!==0){let n=s[e-1];t.setY(n.getY()+n.getHeight()+this.nodeNodeSpacing)}if(pn.compact(e,s,r,this.nodeNodeSpacing,o).compactRowAgain){for(let e of t.getChildren())e.setFixed(!1),e.setPositionFixed(!1),e.resetBlock();t.resetStacks(),t.setWidth(r),e--}else{if(this.adjustWidthAndHeight(t),e+1<s.length&&(this.potentialRowWidthIncreaseMax=Math.max(t.getWidth()+this.nodeNodeSpacing+s[e+1].getFirstBlock().getWidth()-r,this.potentialRowWidthDecreaseMax),this.potentialRowWidthIncreaseMin=Math.min(t.getWidth()+this.nodeNodeSpacing+s[e+1].getFirstBlock().getWidth()-r,this.potentialRowWidthDecreaseMin),t.getStacks().length!==0)){let e=t.getStacks()[t.getStacks().length-1].getWidth()+(t.getStacks().length<=1?0:this.nodeNodeSpacing);this.potentialRowWidthDecreaseMax=Math.max(this.potentialRowWidthDecreaseMax,e),this.potentialRowWidthDecreaseMin=Math.min(this.potentialRowWidthDecreaseMax,e)}if(s.length===1){let e=t.getStacks()[t.getStacks().length-1],n=e.getBlocks()[e.getBlocks().length-1];for(let e of n.getRows())this.potentialRowWidthDecreaseMax=Math.max(this.potentialRowWidthDecreaseMax,n.getWidth()-e.getWidth()),this.potentialRowWidthDecreaseMin=Math.min(this.potentialRowWidthDecreaseMin,n.getWidth()-e.getWidth()),this.potentialRowWidthIncreaseMax=Math.max(this.potentialRowWidthIncreaseMax,e.getWidth()+this.nodeNodeSpacing),this.potentialRowWidthIncreaseMin=Math.min(this.potentialRowWidthIncreaseMin,e.getWidth()+this.nodeNodeSpacing)}}}let c=O.calculateDimensionsRows(s,this.nodeNodeSpacing),l=Math.max(c.x,i-t.left-t.right),u=Math.max(c.y,a-t.top-t.bottom)-c.y;return n.additionalHeight=u,n.rows=s,new Zt(this.aspectRatio,l,c.y+u,`WHOLE_DRAWING`)}adjustWidthAndHeight(e){let t=0,n=0,r=0;for(let i of e.getStacks())i.updateDimension(),t=Math.max(t,i.getHeight()),n+=i.getWidth()+(r>0?this.nodeNodeSpacing:0),r++;e.setHeight(t),e.setWidth(n)}};function xn(e){return{id:e.id,width:e.width,height:e.height,x:e.x,y:e.y,layoutOptions:{...e.layoutOptions},children:(e.children??[]).map(e=>({id:e.id,width:e.width,height:e.height,x:e.x,y:e.y,layoutOptions:{...e.layoutOptions}}))}}function Sn(e,t){t.width=e.width,t.height=e.height,t.x=e.x,t.y=e.y;for(let n=0;n<(e.children??[]).length;n++)Sn(e.children[n],t.children[n])}function Cn(e,t){e.minRowIncrease=t.potentialRowWidthIncreaseMin,e.maxRowIncrease=t.potentialRowWidthIncreaseMax,e.minRowDecrease=t.potentialRowWidthDecreaseMin,e.maxRowDecrease=t.potentialRowWidthDecreaseMax}function wn(e,t,n,r){let i=Xt(e),a=D(e,wt);e.children.length>1&&r.minRowIncrease!==1/0&&(n.getDrawingWidth()+i.left+i.right)/(n.getDrawingHeight()+i.top+i.bottom)<a?r.targetWidth+=r.minRowIncrease:e.children.length>1&&r.minRowDecrease!==1/0&&(n.getDrawingWidth()+i.left+i.right)/(n.getDrawingHeight()+i.top+i.bottom)>a&&(r.targetWidth=Math.max(r.minWidth,r.targetWidth-r.minRowDecrease))}function Tn(e,t,n){let r=D(e,wt),i=D(e,Et),a=e.children??[],o=new bn(r,i),s=o.start(e,n,t);Cn(t,o);let c=Math.trunc(D(e,Bt));for(;c>1;){let l=xn(e),u=s.getScaleMeasure(),d={...t,rows:[],additionalHeight:0};wn(e,l,s,d),o=new bn(r,i);let f=o.start(l,n,d),p=f.getScaleMeasure();if(p>=u&&p===p){for(let e=0;e<(l.children??[]).length;e++)Sn(l.children[e],a[e]);Cn(t,o),s.setDrawingWidth(f.getDrawingWidth()),s.setDrawingHeight(f.getDrawingHeight())}c--}return t.drawingHeight=s.getDrawingHeight(),t.drawingWidth=s.getDrawingWidth(),s}function En(e,t,n){let r=t.targetWidth,i=D(e,Et);O.resetCoordinates(e.children??[]);let a=un.place(e.children??[],r,i,Jt(e,zt,!1)),o;if(a===null)o=O.calculateDimensions(e.children??[]);else{for(let e of a)for(let t of e.getChildren()){let n=new cn(t.getX(),t.getY(),i);n.addBlock(t),e.getStacks().push(n)}o=O.calculateDimensionsRows(a,i)}let s=Math.max(o.x,t.minWidth-n.left-n.right),c=Math.max(o.y,t.minHeight-n.top-n.bottom),l=c-o.y;t.additionalHeight=l,t.drawingWidth=s,t.drawingHeight=c+l,t.rows=a}function Dn(e,t,n){let r=O.calculateDimensions(e.children??[]),i=Math.max(r.x,t.minWidth-n.left-n.right),a=Math.max(r.y,t.minHeight-n.top-n.bottom),o=a-r.y;t.additionalHeight=o,t.drawingWidth=i,t.drawingHeight=a+o}function On(e,t,n){let r=Yt(e,Rt,`COMPACTION`);switch(r){case`COMPACTION`:return Tn(e,t,n);case`SIMPLE`:return En(e,t,n),new Zt(D(e,wt),t.drawingWidth,t.drawingHeight,`WHOLE_DRAWING`);case`NONE`:return Dn(e,t,n),new Zt(D(e,wt),t.drawingWidth,t.drawingHeight,`WHOLE_DRAWING`);default:throw Error(`[rectpacking] no implementation for packing strategy ${r}`)}}function kn(e,t,n,r){let i=n/e.length,a=0;for(let n of e)n.setY(n.getY()+i*a),n.expand(t,i),a++}function An(e,t){if(t.rows.length>0)kn(t.rows,t.drawingWidth,t.additionalHeight,D(e,Et));else throw Error(`[rectpacking] whitespace elimination cannot be done with packing strategy NONE`)}function jn(e,t){let n=t.drawingWidth,r=t.drawingHeight,i=D(e,wt),a=t.additionalHeight;n/r<i?(n=r*i,t.drawingWidth=n):(a+=n/i-r,t.additionalHeight=a,t.drawingHeight=r+a),An(e,t)}function Mn(e,t){switch(Yt(e,Vt,`NONE`)){case`EQUAL_BETWEEN_STRUCTURES`:An(e,t);break;case`TO_ASPECT_RATIO`:jn(e,t)}}function Nn(e,t){let n=E(e,t);if(n==null)return null;if(typeof n==`object`){let e=n;return typeof e.x==`number`&&typeof e.y==`number`?{x:e.x,y:e.y}:null}let[r,i]=String(n).replace(/[()[\]]/g,``).split(`,`).map(e=>Number(e.trim()));return Number.isFinite(r)&&Number.isFinite(i)?{x:r,y:i}:null}function Pn(e){return String(E(e,Ot)??``).includes(`MINIMUM_SIZE`)?Nn(e,kt)??{x:0,y:0}:{x:0,y:0}}function Fn(e,t){let n=Pn(e);t.minWidth=n.x,t.minHeight=n.y}function In(e){e.targetWidth=Math.max(e.targetWidth,e.minWidth)}function Ln(e){(e.children??[]).sort((e,t)=>(t.height??0)-(e.height??0))}function Rn(e){let t=e.children??[],n=[];for(let e of t)E(e,Wt)!==void 0&&n.push(e);for(let e of n){let n=t.indexOf(e);n!==-1&&t.splice(n,1)}n.sort((e,t)=>{let n=D(e,Wt),r=D(t,Wt);return n===r?-1:n-r});for(let e of n){let n=D(e,Wt);n=Math.min(n,t.length),t.splice(n,0,e)}let r=0;for(let e of t)e.layoutOptions??={},e.layoutOptions[Gt]=String(r),r++}function zn(e,t,n,r,i){let a=String(E(e,At)??`topLeft`),o=0,s=0;if(t.drawingWidth>n&&(a.includes(`H_CENTER`)?o=(t.drawingWidth-n)/2:a.includes(`H_RIGHT`)&&(o=t.drawingWidth-n)),t.drawingHeight>r&&(a.includes(`V_CENTER`)?s=(t.drawingHeight-r)/2:a.includes(`V_BOTTOM`)&&(s=t.drawingHeight-r)),o!==0||s!==0)for(let e of i)e.x=(e.x??0)+o,e.y=(e.y??0)+s}function Bn(e,t,n){let r=Pn(e);e.width=Math.max(r.x,t),e.height=Math.max(r.y,n)}function Vn(e){let t=Xt(e),n=Jt(e,Dt,!1),r=D(e,Et),i=Jt(e,Ht,!1),a=e.children??[],o=!1;if(i&&a.length>=3){let e=a[0],t=a[1],n=0;for(;n+2<a.length;){let i=e;if(e=t,t=a[n+2],(i.height??0)>=(e.height??0)+(t.height??0)+r||(t.height??0)>=(i.height??0)+(e.height??0)+r){o=!0;break}n++}}else o=!0;if(!o){let t=a.length;for(let e of a)e.layoutOptions??={},e.layoutOptions[Nt]=String(t),t--;return g(e),e}let s=new Qt;Jt(e,Ut,!1)&&Ln(e),Jt(e,jt,!1)&&Rn(e),Fn(e,s),an(e,s,a),In(s),On(e,s,t),Mn(e,s);let c=0,l=0;for(let e of a)c=Math.max(c,(e.x??0)+(e.width??0)),l=Math.max(l,(e.y??0)+(e.height??0));zn(e,s,c,l,a);for(let e of a)e.x=(e.x??0)+t.left,e.y=(e.y??0)+t.top;return n||Bn(e,s.drawingWidth+t.left+t.right,s.drawingHeight+t.top+t.bottom),e}var Hn=class{grid=[];rows=0;cols=0;put(e,t,n){if(e>=this.cols||t>=this.rows)throw Error(`The grid has a size of (${this.cols} x ${this.rows}). The requested index of (${e} x ${t}) is out of bounds.`);this.grid[t].splice(e,0,n)}get(e,t){if(e>=this.cols||t>=this.rows)throw Error(`The grid has a size of (${this.cols} x ${this.rows}). The requested index of (${e} x ${t}) is out of bounds.`);return this.grid[t][e]??null}getRow(e){if(e>=this.rows)throw Error(`The grid has a size of (${this.cols} x ${this.rows}). The requested row ${e}) is out of bounds.`);return this.grid[e]}getColumn(e){if(e>=this.cols)throw Error(`The grid has a size of (${this.cols} x ${this.rows}). The requested column ${e}) is out of bounds.`);let t=[];for(let n=0;n<this.rows;n++)t.push(this.grid[n][e]??null);return t}getColumns(){return this.cols}getRows(){return this.rows}setGridSize(e,t){this.cols=e,this.rows=t,this.grid=[];for(let n=0;n<t;n++){let t=[];for(let n=0;n<e;n++)t.push(null);this.grid.push(t)}}};const Un=o.padding.id,Wn=o.spacingNodeNode.id,Gn=a.topdownpacking.hierarchicalNodeWidth.id,Kn=a.topdownpacking.hierarchicalNodeAspectRatio.id,qn=a.topdownpacking.nodeArrangementStrategy.id,Jn=a.topdownpacking.whitespaceEliminationStrategy.id,Yn={[Un]:12,[Wn]:20,[Gn]:150,[Kn]:1.414,[qn]:`LEFT_RIGHT_TOP_DOWN_NODE_PLACER`,[Jn]:`BOTTOM_ROW_EQUAL_WHITESPACE_ELIMINATOR`};function Xn(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function Zn(e,t){let n=Xn(e,t);if(n==null||n===``)return Yn[t];let r=Number(n);return Number.isFinite(r)?r:Yn[t]}function Qn(e,t,n){let r=Xn(e,t);return r==null||r===``?n:String(r)}function $n(e){let t=Xn(e,Un);if(typeof t==`number`)return{top:t,left:t,right:t,bottom:t};if(typeof t==`object`&&t){let e=t,n=t=>typeof e[t]==`number`?e[t]:Yn[Un];return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}if(typeof t==`string`){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}let n=t=>e[t]??Yn[Un];return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return{top:Yn[Un],left:Yn[Un],right:Yn[Un],bottom:Yn[Un]}}function er(e){let t=(e.children??[]).length,n=$n(e),r=Zn(e,Wn),i=Zn(e,Gn),a=Zn(e,Kn),o=Math.ceil(Math.sqrt(t)),s=o*i+n.left+n.right+(o-1)*r,c=t>o*o-o||o===0?o:o-1;return{x:s,y:c*i/a+n.top+n.bottom+(c-1)*r}}function tr(e){return Math.ceil(Math.sqrt(e))}function nr(e,t){return e>t*t-t||t===0?t:t-1}function rr(e,t){let n=$n(e),r=Zn(e,Wn),i=er(e);e.width=Math.max(e.width??0,i.x),e.height=Math.max(e.height??0,i.y);let a=[...e.children??[]],o=tr(a.length),s=nr(a.length,o);t.setGridSize(o,s);let c=Zn(e,Gn),l=Zn(e,Kn),u=n.left,d=n.top,f=0,p=0;for(let e of a)e.width=c,e.height=c/l,e.x=u,e.y=d,t.put(f,p,e),u+=e.width+r,f+=1,f>=o&&(u=n.left,d+=c/l+r,f=0,p+=1)}function ir(e,t){if((e.width??0)===0||t.getColumns()===0)return;let n=$n(e);for(let r=0;r<t.getRows();r++){let i=t.getRow(r),a=null,o=i.length;for(;a===null;)a=i[--o]??null;let s=(a.x??0)+(a.width??0);if(s+n.right<(e.width??0)){let t=((e.width??0)-(s+n.right))/(o+1),r=0;for(let e=0;e<=o;e++){let n=i[e];n.x=(n.x??0)+r,n.width=(n.width??0)+t,r+=t}}}let r=t.getColumn(0),i=r[r.length-1],a=(i.y??0)+(i.height??0),o=((e.height??0)-(a+n.bottom))/(r.length+1),s=0;if(a+n.bottom<(e.height??0))for(let e=0;e<t.getRows();e++){let n=t.getRow(e);for(let e of n){if(e===null)break;e.y=(e.y??0)+s,e.height=(e.height??0)+o,s+=o}}}function ar(e){let t=new Hn,n=Qn(e,qn,`LEFT_RIGHT_TOP_DOWN_NODE_PLACER`);if(n!==`LEFT_RIGHT_TOP_DOWN_NODE_PLACER`)throw Error(`[topdownpacking] No implementation is available for the node placer ${n}`);let r=Qn(e,Jn,`BOTTOM_ROW_EQUAL_WHITESPACE_ELIMINATOR`);if(r!==`BOTTOM_ROW_EQUAL_WHITESPACE_ELIMINATOR`)throw Error(`[topdownpacking] No implementation is available for the whitespace eliminator${r}`);return rr(e,t),ir(e,t),e}function k(e,t,n){return Math.abs(e-t)<=n?0:e<t?-1:1}function or(e){return e.x=-e.x,e.y=-e.y,e}function sr(e,t){let n=e.length();return n>0&&e.scale(t/n),e}function cr(e,t,n=.05){return Math.abs(e.x-t.x)<=n&&Math.abs(e.y-t.y)<=n}function lr(e){return`${e.x},${e.y}`}var ur=class e{x;y;width;height;constructor(e=0,t=0,n=0,r=0){this.x=e,this.y=t,this.width=n,this.height=r}clone(){return new e(this.x,this.y,this.width,this.height)}getPosition(){return new b(this.x,this.y)}getTopLeft(){return this.getPosition()}getTopRight(){return new b(this.x+this.width,this.y)}getBottomLeft(){return new b(this.x,this.y+this.height)}getBottomRight(){return new b(this.x+this.width,this.y+this.height)}getCenter(){return new b(this.x+this.width/2,this.y+this.height/2)}};function dr(e,t){let n=Math.min(Math.abs(e.x-(t.x+t.width)),Math.abs(e.x+e.width-t.x)),r=Math.min(Math.abs(e.y-(t.y+t.height)),Math.abs(e.y+e.height-t.y)),i=Math.abs(e.x+e.width/2-(t.x+t.width/2));if(i>e.width/2+t.width/2)return 1;let a=Math.abs(e.y+e.height/2-(t.y+t.height/2));return a>e.height/2+t.height/2?1:i===0&&a===0?0:i===0?r/a+1:a===0?n/i+1:Math.min(n/i,r/a)+1}function fr(e){return[{u:e.getTopLeft(),v:e.getTopRight()},{u:e.getTopLeft(),v:e.getBottomLeft()},{u:e.getBottomRight(),v:e.getTopRight()},{u:e.getBottomRight(),v:e.getBottomLeft()}]}function pr(e,t,n,r){let i=n.clone().sub(e),a=mr(i,t),o=mr(t,r),s=mr(i,r)/o,c=a/o;if(o===0){if(a===0){let i=n.clone().add(r.clone().scale(.5)),a=e.distance(i),o=e.clone().add(t).distance(i),s=r.length()*.5;return a<o&&a<=s?e.clone():o<=s?e.clone().add(t):null}return null}return s>=0&&s<=1&&c>=0&&c<=1?e.clone().add(t.clone().scale(s)):null}function mr(e,t){return e.x*t.y-e.y*t.x}function hr(e,t,n,r,i){return Math.min(gr(e,t,n,r,i),gr(n,r,e,t,or(i.clone())))}function gr(e,t,n,r,i){let a=1/0,o=!1,s=pr(e,t.clone().sub(e),n.clone().add(i),r.clone().sub(n)),c=s!==null&&!(cr(s,e)||cr(s,t)),l=pr(e,t.clone().sub(e),n,i);l!==null&&(cr(l,e)===cr(l,t)||c?a=Math.min(a,l.sub(n).length()):o=!0);let u=pr(e,t.clone().sub(e),r,i);return u!==null&&(o||cr(u,e)===cr(u,t)||c)&&(a=Math.min(a,u.sub(r).length())),a}const _r=1e-5;function vr(e,t){let n=t.x-(e.x+e.width),r=e.x-(t.x+t.width),i=e.y-(t.y+t.height),a=t.y-(e.y+e.height),o=Math.max(r,n),s=Math.max(i,a);return k(o,0,_r)>=0==k(s,0,_r)>=0?k(o,0,_r)>0?Math.sqrt(s*s+o*o):-Math.sqrt(s*s+o*o):Math.max(s,o)}function yr(e,t,n){let r=t/2,i=n/2,a=Math.abs(e.x),o=Math.abs(e.y),s=1,c=1;return a>r&&(s=r/a),o>i&&(c=i/o),e.scale(Math.min(s,c)),e}const br=/* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));function xr(e){return br.setFloat64(0,e,!1),br.getUint32(0,!1)^br.getUint32(4,!1)|0}function Sr(e){let t=e|0;return t=(t&1431655765)<<1|t>>>1&1431655765,t=(t&858993459)<<2|t>>>2&858993459,t=(t&252645135)<<4|t>>>4&252645135,t=(t&16711935)<<8|t>>>8&16711935,t<<16|t>>>16}function Cr(e,t){return xr(e)+Sr(xr(t))|0}function wr(e){return e^e>>>16}var Tr=class{buckets=Array.from({length:16},()=>[]);capacity=16;threshold=12;size=0;add(e){let t=wr(e.javaHash())&this.capacity-1,n=this.buckets[t];for(let t of n)if(t.javaEquals(e))return!1;return n.push(e),this.size++,this.size>this.threshold&&this.resize(this.capacity*2),!0}addAll(e){for(let t of e)this.add(t)}has(e){let t=wr(e.javaHash()),n=this.buckets[t&this.capacity-1];for(let t=0;t<n.length;t++)if(n[t].javaEquals(e))return!0;return!1}delete(e){let t=wr(e.javaHash())&this.capacity-1,n=this.buckets[t];for(let t=0;t<n.length;t++)if(n[t].javaEquals(e))return n.splice(t,1),this.size--,!0;return!1}clear(){this.buckets=Array.from({length:16},()=>[]),this.capacity=16,this.threshold=12,this.size=0}resize(e){let t=this.buckets;this.capacity=e,this.threshold=Math.floor(e*.75),this.buckets=Array.from({length:e},()=>[]);for(let n of t)for(let t of n){let n=wr(t.javaHash())&e-1;this.buckets[n].push(t)}}*[Symbol.iterator](){for(let e of this.buckets)for(let t of e)yield t}toArray(){let e=[];for(let t of this.buckets)for(let n=0;n<t.length;n++)e.push(t[n]);return e}forEach(e){for(let t of this.buckets)for(let n=0;n<t.length;n++)e(t[n])}},Er=class e{u;v;constructor(e,t){this.u=e,this.v=t}key(){let e=lr(this.u),t=lr(this.v);return e<=t?`${e}|${t}`:`${t}|${e}`}contains(e){return this.u.x===e.x&&this.u.y===e.y||this.v.x===e.x&&this.v.y===e.y}javaHash(){return Cr(this.u.x,this.u.y)+Cr(this.v.x,this.v.y)|0}javaEquals(t){if(!(t instanceof e))return!1;let n=t;return this.u.x===n.u.x&&this.u.y===n.u.y&&this.v.x===n.v.x&&this.v.y===n.v.y||this.u.x===n.v.x&&this.u.y===n.v.y&&this.v.x===n.u.x&&this.v.y===n.u.y}},Dr=class{node;children;constructor(e){this.node=e,this.children=[]}},Or=class{originalVertex;vertex;rect;constructor(e,t){this.originalVertex=e,this.vertex=e.clone(),this.rect=t.clone()}translate(e){this.vertex.add(e),this.rect.x+=e.x,this.rect.y+=e.y}setCenterPosition(e){this.translate(e.clone().sub(this.vertex))}underlap(e){let t=Math.abs(this.rect.getCenter().x-e.rect.getCenter().x),n=Math.abs(this.rect.getCenter().y-e.rect.getCenter().y),r=0,i=0,a=1,o=1;return t>this.rect.width/2+e.rect.width/2&&(r=Math.min(Math.abs(this.rect.x-(e.rect.x+e.rect.width)),Math.abs(this.rect.x+this.rect.width-e.rect.x)),a=1-r/t),n>this.rect.height/2+e.rect.height/2&&(i=Math.min(Math.abs(this.rect.y-(e.rect.y+e.rect.height)),Math.abs(this.rect.y+this.rect.height-e.rect.y)),o=1-i/n),(1-Math.min(a,o))*Math.sqrt(t*t+n*n)}distance(e,t){let n=1/0;for(let r of fr(this.rect))for(let i of fr(e.rect)){let e=hr(r.u,r.v,i.u,i.v,t);n=Math.min(n,e)}return n}touches(e){return k(this.rect.x,e.rect.x+e.rect.width,1e-4)<=0&&k(e.rect.x,this.rect.x+this.rect.width,1e-4)<=0&&k(this.rect.y,e.rect.y+e.rect.height,1e-4)<=0&&k(e.rect.y,this.rect.y+this.rect.height,1e-4)<=0}},kr=class{vertices=[];tEdges=null;treeConstructionStrategy;tree=null;compactionStrategy;costFunction;preferredRoot=null;orthogonalCompaction=!1;overlapsExisted=!0;constructor(e,t,n){this.costFunction=e,this.treeConstructionStrategy=t,this.compactionStrategy=n}};const Ar=o.padding.id,jr=o.spacingNodeNode.id,Mr=o.underlyingLayoutAlgorithm.id;o.debugMode.id;const Nr=o.structureExtractionStrategy.id,Pr=a.spore.processingOrderTreeConstruction.id,Fr=a.spore.processingOrderSpanningTreeCostFunction.id,Ir=a.spore.processingOrderPreferredRoot.id,Lr=a.spore.processingOrderRootSelection.id,Rr=a.spore.compactionStrategy.id,zr=a.spore.compactionOrthogonal.id,Br=a.spore.overlapRemovalMaxIterations.id,Vr=a.spore.overlapRemovalRunScanline.id,A={[Ar]:8,[jr]:8,[Nr]:`DELAUNAY_TRIANGULATION`,[Pr]:`MINIMUM_SPANNING_TREE`,[Fr]:`CIRCLE_UNDERLAP`,[Lr]:`CENTER_NODE`,[Rr]:`DEPTH_FIRST`,[zr]:!1,[Br]:64,[Vr]:!0};function Hr(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function Ur(e,t){let n=Hr(e,t);if(n==null||n===``)return A[t];let r=Number(n);return Number.isFinite(r)?r:A[t]}function Wr(e,t,n){let r=Hr(e,t);return r==null||r===``?n:String(r)}function Gr(e,t){let n=Hr(e,t);return n==null||n===``?A[t]:String(n)===`true`}function Kr(e){let t=Hr(e,Ar);if(typeof t==`number`)return{top:t,left:t,right:t,bottom:t};if(typeof t==`object`&&t){let e=t,n=t=>typeof e[t]==`number`?e[t]:A[Ar];return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}if(typeof t==`string`){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}let n=t=>e[t]??A[Ar];return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return{top:A[Ar],left:A[Ar],right:A[Ar],bottom:A[Ar]}}var qr=class{graph;nodeMap=/* @__PURE__ */ new Map;elkGraph;spacingNodeNode=8;padding={top:8,left:8,right:8,bottom:8};centerDistance=e=>e.u.distance(e.v);minimumRootDistance=e=>Math.min(e.u.distance(this.graph.preferredRoot.vertex),e.v.distance(this.graph.preferredRoot.vertex));circleUnderlap=e=>{let t=this.nodeMap.get(j(e.u)).node,n=this.nodeMap.get(j(e.v)).node;return e.u.distance(e.v)-e.u.distance(t.rect.getPosition())-e.v.distance(n.rect.getPosition())};rectangleUnderlap=e=>{let t=this.nodeMap.get(j(e.u)).node,n=this.nodeMap.get(j(e.v)).node;return t.underlap(n)};invertedOverlap=e=>{let t=this.nodeMap.get(j(e.u)).node,n=this.nodeMap.get(j(e.v)).node,r=t.rect,i=n.rect,a=vr(r,i);if(a>=0)return a;let o=i.getCenter().sub(r.getCenter()).length();return-(dr(r,i)-1)*o};importGraph(e,t={}){this.elkGraph=e,this.nodeMap=/* @__PURE__ */ new Map,this.padding=Kr(e),this.spacingNodeNode=Ur(e,jr);let n=Hr(e,Ir),r=t.costFunction??Wr(e,Fr,`CIRCLE_UNDERLAP`),i=t.treeConstruction??Wr(e,Pr,`MINIMUM_SPANNING_TREE`),a=Wr(e,Rr,`DEPTH_FIRST`),o=t.rootSelection??Wr(e,Lr,`CENTER_NODE`),s=this.centerDistance;switch(r){case`CENTER_DISTANCE`:s=this.centerDistance;break;case`CIRCLE_UNDERLAP`:s=this.circleUnderlap;break;case`RECTANGLE_UNDERLAP`:s=this.rectangleUnderlap;break;case`INVERTED_OVERLAP`:s=this.invertedOverlap;break;case`MINIMUM_ROOT_DISTANCE`:s=this.minimumRootDistance;break;default:throw Error(`No implementation available for ${r}`)}let c=new kr(s,i,a);if(c.orthogonalCompaction=Gr(e,zr),this.graph=c,(e.children??[]).length===0)return c;for(let t of e.children??[]){let e=(t.width??0)/2,n=(t.height??0)/2,r=new b((t.x??0)+e,(t.y??0)+n);for(;this.nodeMap.has(j(r));)r.add(new b((Math.random()-.5)*.001,(Math.random()-.5)*.001));let i=Jr(Hr(t,`org.eclipse.elk.margins`)),a=new Or(r,new ur(r.x-e-this.spacingNodeNode/2-i.left,r.y-n-this.spacingNodeNode/2-i.top,(t.width??0)+this.spacingNodeNode+i.left+i.right,(t.height??0)+this.spacingNodeNode+i.top+i.bottom));c.vertices.push(a),this.nodeMap.set(j(r),{node:a,elkNode:t})}switch(o){case`FIXED`:if(n==null)c.preferredRoot=c.vertices[0];else for(let e of c.vertices){let t=this.nodeMap.get(j(e.originalVertex)).elkNode.id;t!==void 0&&t===n&&(c.preferredRoot=e)}break;case`CENTER_NODE`:{let e=new b(this.elkGraph.width??0,this.elkGraph.height??0);e.scale(.5),e.add(new b(this.elkGraph.x??0,this.elkGraph.y??0));let t=1/0;for(let n of c.vertices){let r=n.originalVertex.distance(e);r<t&&(t=r,c.preferredRoot=n)}break}default:throw Error(`No implementation available for ${o}`)}return c}updateGraph(e){let t=/* @__PURE__ */ new Map;e.tEdges=null,e.tree=null;for(let n of e.vertices){let e=this.nodeMap.get(j(n.originalVertex));n.originalVertex=n.rect.getCenter(),t.set(j(n.originalVertex),e)}this.nodeMap=t}applyPositions(e){if(e.vertices.length===0)return;let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e.vertices){let e=this.nodeMap.get(j(a.originalVertex)).elkNode;e.x=a.rect.x,e.y=a.rect.y,t=Math.min(t,e.x),n=Math.min(n,e.y),r=Math.max(r,e.x+(e.width??0)),i=Math.max(i,e.y+(e.height??0))}this.elkGraph.width=r-t+this.padding.left+this.padding.right,this.elkGraph.height=i-n+this.padding.top+this.padding.bottom;let a=-t+this.padding.left,o=-n+this.padding.top;for(let e of this.elkGraph.children??[])e.x=(e.x??0)+a,e.y=(e.y??0)+o;for(let e of this.elkGraph.edges??[]){let t=Yr(e),n=Xr(this.elkGraph,e.sources?.[0]),r=Xr(this.elkGraph,e.targets?.[0]);if(n===void 0||r===void 0)continue;let i=new b((n.x??0)+(n.width??0)/2,(n.y??0)+(n.height??0)/2),a=new b((r.x??0)+(r.width??0)/2,(r.y??0)+(r.height??0)/2),o=a.clone().sub(i);yr(o,n.width??0,n.height??0),i.add(o);let s=i.clone().sub(a);yr(s,r.width??0,r.height??0),a.add(s),t.startPoint={x:i.x,y:i.y},t.endPoint={x:a.x,y:a.y}}}};function j(e){return`${e.x},${e.y}`}function Jr(e){let t={top:0,left:0,right:0,bottom:0};if(typeof e==`number`)return{top:e,left:e,right:e,bottom:e};if(typeof e==`object`&&e){let t=e,n=e=>typeof t[e]==`number`?t[e]:0;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}if(typeof e==`string`&&e.trim()!==``){let t={};for(let n of e.replace(/^\[|\]$/g,``).split(`,`)){let[e,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);e!==void 0&&Number.isFinite(i)&&(t[e]=i)}let n=e=>t[e]??0;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return t}function Yr(e){return e.sections??=[],e.sections.length===0&&e.sections.push({startPoint:{x:0,y:0},endPoint:{x:0,y:0}}),e.sections[0]}function Xr(e,t){if(t===void 0)return;let n=(e.children??[]).find(e=>e.id===t);if(n!==void 0)return n;let r=t.includes(`.`)?t.slice(0,t.lastIndexOf(`.`)):t;return(e.children??[]).find(e=>e.id===r)}var Zr=class e{a;b;c;tEdges;vertices;circumcenter;constructor(e,t,n){this.a=e,this.b=t,this.c=n,this.tEdges=[new Er(e,t),new Er(t,n),new Er(n,e)],this.vertices=[e,t,n],this.circumcenter=this.calculateCircumcenter()}calculateCircumcenter(){let e=this.b.clone().sub(this.a),t=this.c.clone().sub(this.a),n=this.c.clone().sub(this.b),r=e.x*(this.a.x+this.b.x)+e.y*(this.a.y+this.b.y),i=t.x*(this.a.x+this.c.x)+t.y*(this.a.y+this.c.y),a=2*(e.x*n.y-e.y*n.x);return new b((t.y*r-e.y*i)/a,(e.x*i-t.x*r)/a)}inCircumcircle(e){return this.circumcenter.distance(e)<this.circumcenter.distance(this.a)-1e-4}containsEdge(e){return this.tEdges.some(t=>t.javaEquals(e))}containsVertex(e){return this.vertices.some(t=>lr(t)===lr(e))}javaEquals(t){return t instanceof e&&this.containsVertex(t.a)&&this.containsVertex(t.b)&&this.containsVertex(t.c)}javaHash(){return Cr(this.a.x,this.a.y)+Cr(this.b.x,this.b.y)+Cr(this.c.x,this.c.y)|0}};function Qr(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x),i=Math.max(i,a.y);let a=r-t,o=i-n,s=new Zr(new b(t-50,n-a-50),new b(t-50,i+a+50),new b(r+o/2+50,n+o/2)),c=new Tr;c.add(s);for(let t of e){let e=[];c.forEach(n=>{n.inCircumcircle(t)&&e.push(n)});let n=[];for(let t of e)for(let r of t.tEdges){let i=!0;for(let n of e)if(n!==t&&n.containsEdge(r)){i=!1;break}i&&n.push(r)}for(let t of e)c.delete(t);for(let e of n)c.add(new Zr(t,e.u,e.v))}let l=new Tr;c.forEach(e=>{for(let t of e.tEdges)l.add(t)});for(let e of l.toArray())(s.containsVertex(e.u)||s.containsVertex(e.v))&&l.delete(e);return l}function $r(e){let t=e.vertices.map(e=>e.originalVertex);e.tEdges===null?e.tEdges=Qr(t):e.tEdges.addAll(Qr(t).toArray())}function ei(e,t,n){let r=[];e.forEach(e=>r.push({edge:e,weight:n(e),order:0})),r.sort((e,t)=>e.weight<t.weight?-1:+(e.weight>t.weight));for(let e=0;e<r.length;e++)r[e].order=e;let i=/* @__PURE__ */ new Map,a=e=>{let t=i.get(e);return t===void 0&&(t=ti(e),i.set(e,t)),t},o=/* @__PURE__ */ new Map;for(let e of r){let t=a(e.edge.u),n=a(e.edge.v),r=o.get(t);r===void 0&&o.set(t,r=[]),r.push(e);let i=o.get(n);i===void 0&&o.set(n,i=[]),i.push(e)}let s=[],c=(e,t)=>e.weight<t.weight?!0:e.weight>t.weight?!1:e.order<t.order,l=e=>{let t=s.length;for(s.push(e);t>0;){let n=t-1>>1,r=s[n];if(!c(e,r))break;s[n]=e,s[t]=r,t=n}},u=()=>{let e=s[0],t=s.pop();if(s.length===0)return e;s[0]=t;let n=0;for(;;){let e=n*2+1;if(e>=s.length)break;let r=e+1,i=e;r<s.length&&c(s[r],s[e])&&(i=r);let a=s[i];if(!c(a,t))break;s[n]=a,s[i]=t,n=i}return e},d=new Dr(t),f=/* @__PURE__ */ new Map,p=new Uint8Array(r.length),m=e=>{let t=o.get(e);if(t!==void 0)for(let e of t)p[e.order]===0&&(p[e.order]=1,l(e))},h=a(t);for(f.set(h,d),m(h);s.length>0;){let e=u().edge,t=a(e.u),n=a(e.v),r=f.has(t);if(r===f.has(n))continue;let i=r?n:t,o=new Dr(r?e.v:e.u);f.get(r?t:n).children.push(o),f.set(i,o),m(i)}return d}function ti(e){return`${e.x},${e.y}`}function ni(e,t){let n=/* @__PURE__ */ new Map;for(let e of t)n.set(ti(e.originalVertex),e);let r=new Dr(n.get(ti(e.node)));return ri(r,e,n),r}function ri(e,t,n){for(let r of t.children){let t=new Dr(n.get(ti(r.node)));e.children.push(t),ri(t,r,n)}}function ii(e){let t=e.preferredRoot===null?e.vertices[0].originalVertex:e.preferredRoot.originalVertex;e.tree=ni(ei(e.tEdges,t,e.costFunction),e.vertices)}function ai(e){let t=t=>-e.costFunction(t),n=e.preferredRoot===null?e.vertices[0].vertex:e.preferredRoot.vertex;e.tree=ni(ei(e.tEdges,n,t),e.vertices)}function oi(e){e.overlapsExisted=!1,si(e.tree,e)}function si(e,t){for(let n of e.children){n.node.translate(e.node.vertex.clone().sub(e.node.originalVertex));let r=dr(e.node.rect,n.node.rect);r>1&&(t.overlapsExisted=!0),n.node.setCenterPosition(e.node.vertex.clone().add(n.node.originalVertex.clone().sub(e.node.originalVertex).scale(r))),si(n,t)}}function ci(e,t){li(e,t)}function li(e,t){for(let n of e.children)li(n,t);for(let n of e.children){let r=e.node.vertex.clone().sub(n.node.vertex);if(t){let t=e.node.rect,i=n.node.rect;Math.abs(r.x)>=Math.abs(r.y)?(r.y=0,i.y+i.height>t.y&&i.y<t.y+t.height&&sr(r,Math.max(t.x-(i.x+i.width),i.x-(t.x+t.width)))):(r.x=0,i.x+i.width>t.x&&i.x<t.x+t.width&&sr(r,Math.max(t.y-(i.y+i.height),i.y-(t.y+t.height))))}else sr(r,e.node.underlap(n.node));let i=r.length();i=ui(e,n,i,r),sr(r,i),fi(n,r)}}function ui(e,t,n,r){let i=Math.min(n,di(e.node,t,n,r));for(let n of e.children)n!==t&&(i=Math.min(i,ui(n,t,i,r)));return i}function di(e,t,n,r){let i=n;for(let n of t.children){let t=n.node;if(e.touches(t)){if(k(t.rect.x,e.rect.x+e.rect.width,1e-4)===0&&r.x<0||k(t.rect.x+t.rect.width,e.rect.x,1e-4)===0&&r.x>0||k(t.rect.y,e.rect.y+e.rect.height,1e-4)===0&&r.y<0||k(t.rect.y+t.rect.height,e.rect.y,1e-4)===0&&r.y>0){i=0;break}}else i=Math.min(i,e.distance(t,r));i=Math.min(i,di(e,n,i,r))}return i}function fi(e,t){e.node.translate(t);for(let n of e.children)fi(n,t)}function pi(e){ci(e.tree,e.orthogonalCompaction)}function mi(e,t){let n=e.low?e.node.rect.y:e.node.rect.y+e.node.rect.height,r=t.low?t.node.rect.y:t.node.rect.y+t.node.rect.height,i=n<r?-1:+(n>r);if(i===0){if(!e.low&&t.low)return-1;if(!t.low&&e.low)return 1}return i}function hi(e,t){let n=e.rect.x<t.rect.x?-1:+(e.rect.x>t.rect.x);if(n!==0)return n;let r=e.originalVertex.x<t.originalVertex.x?-1:+(e.originalVertex.x>t.originalVertex.x);return r===0?e.originalVertex.y<t.originalVertex.y?-1:+(e.originalVertex.y>t.originalVertex.y):r}function gi(e,t){return e!==t&&k(e.rect.x,t.rect.x+t.rect.width,1e-4)<0&&k(t.rect.x,e.rect.x+e.rect.width,1e-4)<0}function _i(e,t){let n=[];for(let t of e)n.push({node:t,low:!0}),n.push({node:t,low:!1});n.sort(mi);let r=[],i=e=>{let t=0,n=r.length;for(;t<n;){let i=t+n>>>1;hi(r[i],e)<0?t=i+1:n=i}return t};for(let e of n)if(e.low){let n=i(e.node);if(r[n]!==void 0&&hi(r[n],e.node)===0)throw Error(`Invalid hitboxes for scanline overlap calculation.`);r.splice(n,0,e.node);let a=!1;for(let n of r)if(gi(e.node,n))t(e.node,n),a=!0;else if(a)break}else{let t=r.findIndex(t=>t===e.node);t!==-1&&r.splice(t,1)}}function vi(e){let t=new Tr;return _i(e,(e,n)=>{t.add(new Er(e.originalVertex,n.originalVertex))}),t}function yi(e){xi(e);let t={rootSelection:`CENTER_NODE`,costFunction:`INVERTED_OVERLAP`,treeConstruction:`MINIMUM_SPANNING_TREE`},n=new qr,r=n.importGraph(e,t),i=Ur(e,Br),a=Gr(e,Vr),o=!0,s=0;for(;s<i&&o;){if(a){let e=vi(r.vertices);if(e.size===0)break;r.tEdges=e}$r(r),ii(r),oi(r),n.updateGraph(r),o=r.overlapsExisted,s++}return n.applyPositions(r),e}function bi(e){xi(e);let t=new qr,n=t.importGraph(e);return n.vertices.length>1&&($r(n),n.treeConstructionStrategy===`MAXIMUM_SPANNING_TREE`?ai(n):ii(n),pi(n)),t.applyPositions(n),e}function xi(e){let t=Hr(e,Mr);if(t==null||String(t).trim()===``)return;let n=String(t).trim();switch(Si(n)){case`box`:g(e);return;case`fixed`:d(e);return;case`random`:m(e);return;case`stress`:Ct(e);return;case`force`:St(e);return;case`rectpacking`:Vn(e);return;case`topdownpacking`:ar(e);return;case`layered`:case`sporeoverlap`:case`sporecompaction`:throw Error(`[spore] underlying layout algorithm '${n}' 未支持 (递归 layered/spore 未移植)`);default:return}}function Si(e){return String(e).trim().toLowerCase().replace(/^org\.eclipse\.elk\./,``).replace(/^elk\./,``)}const Ci=a.radial.centerOnRoot.id,wi=a.radial.orderId.id,Ti=a.radial.radius.id,Ei=a.radial.rotate.id,Di=a.radial.rotationTargetAngle.id,Oi=a.radial.rotationComputeAdditionalWedgeSpace.id,ki=a.radial.rotationOutgoingEdgeAngles.id,Ai=a.radial.compactor.id,ji=a.radial.compactionStepSize.id,Mi=a.radial.sorter.id,Ni=a.radial.wedgeCriteria.id,Pi=a.radial.optimizationCriteria.id,Fi=o.spacingNodeNode.id,Ii=o.padding.id,Li=o.margins.id,Ri=o.omitNodeMicroLayout.id,zi=o.nodeSizeFixedGraphSize.id,Bi=o.position.id,Vi=o.childAreaWidth.id,Hi=o.childAreaHeight.id,Ui={[Ci]:!1,[wi]:0,[Ti]:0,[Ei]:!1,[Di]:0,[Oi]:!1,[ki]:!1,[Ai]:`NONE`,[ji]:1,[Mi]:`NONE`,[Ni]:`NODE_SIZE`,[Pi]:`NONE`,[Fi]:20,[Ri]:!1,[zi]:!1};function M(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function Wi(e,t){let n=M(e,t);if(n==null||n===``)return Ui[t];let r=Number(n);return Number.isFinite(r)?r:Ui[t]}function Gi(e,t,n){let r=M(e,t);return r==null||r===``?n:String(r)}function Ki(e,t){let n=M(e,t);return n==null||n===``?Ui[t]:String(n)===`true`}function qi(e){let t=M(e,Li);if(typeof t==`number`)return{top:t,left:t,right:t,bottom:t};if(typeof t==`object`&&t){let e=t,n=t=>typeof e[t]==`number`?e[t]:0;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}if(typeof t==`string`&&t.trim()!==``){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}let n=t=>e[t]??0;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return{top:0,left:0,right:0,bottom:0}}function Ji(e){let t=M(e,Ii);if(typeof t==`number`)return{top:t,left:t,right:t,bottom:t};if(typeof t==`object`&&t){let e=t,n=t=>typeof e[t]==`number`?e[t]:12;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}if(typeof t==`string`&&t.trim()!==``){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}let n=t=>e[t]??12;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return{top:12,left:12,right:12,bottom:12}}const Yi=/* @__PURE__ */ new WeakMap;function Xi(e,t,n){let r=Yi.get(e);r===void 0&&(r=/* @__PURE__ */ new Map,Yi.set(e,r)),r.set(t,n)}function Zi(e,t,n){let r=Yi.get(e)?.get(t);if(r!==void 0)return r;let i=M(e,t);return i!=null&&i!==``?i:n}const N=2*Math.PI;function Qi(e,t){let n=e-t;return Math.abs(n)<=1e-10*Math.max(1,Math.abs(e),Math.abs(t))?0:n<0?-1:1}function P(e,t){if(e.id===t)return e;for(let n of e.children??[]){let e=P(n,t);if(e!==void 0)return e}}function F(e,t){if(t!==void 0){if(P(e,t)!==void 0)return t;if(t.includes(`.`)){let n=t.slice(0,t.lastIndexOf(`.`));if(P(e,n)!==void 0)return n}return t}}function $i(e,t){return t===void 0||P(e,t)!==void 0||!t.includes(`.`)?!1:P(e,t.slice(0,t.lastIndexOf(`.`)))!==void 0}function ea(e,t){return(e.edges??[]).filter(n=>F(e,String(n.sources?.[0]??``))===t.id)}function ta(e,t){return(e.edges??[]).filter(n=>F(e,String(n.targets?.[0]??``))===t.id)}function na(e,t){return(e.edges??[]).filter(n=>F(e,String(n.sources?.[0]??``))===t.id)}function ra(e,t){let n=F(e,String(t.sources?.[0]??``)),r=F(e,String(t.targets?.[0]??``));if(n===void 0||r===void 0)return!0;let i=P(e,n),a=P(e,r);return i===void 0||a===void 0||ia(e,i)!==ia(e,a)}function ia(e,t){let n=e=>{for(let r of e.children??[]){if(r===t)return e;let i=n(r);if(i!==void 0)return i}};return n(e)}function I(e,t){let n=[],r=new Set(t.children??[]);for(let i of ea(e,t))if(!$i(e,String(i.sources?.[0]??``))){let t=F(e,String(i.targets?.[0]??``)),a=t===void 0?void 0:P(e,t);a!==void 0&&!r.has(a)&&n.push(a)}return n}function aa(e,t){return new Set(I(e,t))}function oa(e){for(let t of e.children??[])if(ta(e,t).length===0)return t;return null}function sa(e,t){let n=ma(e,t);return n===null?t:sa(e,n)}function ca(e,t){let n=I(e,t);if(n.length===0)return 1;let r=0;for(let t of n)r+=ca(e,t);return r}function la(e,t){return(n,r)=>{let i=Math.atan2((n.y??0)+t,n.x??0);i<0&&(i+=N),i+=e,i>N&&(i-=N);let a=Math.atan2((r.y??0)+t,r.x??0);return a<0&&(a+=N),a+=e,a>N&&(a-=N),Qi(i,a)}}function ua(e){let t=0;for(let n of e.children??[]){let e=n.width??0,r=n.height??0,i=Math.sqrt(e*e+r*r);t=Math.max(i,t);let a=ua(n);t=Math.max(a,t)}return t}function da(e,t){let n=[];for(let r of t)n.push(...I(e,r));return n}function fa(e,t){let n=/* @__PURE__ */ new Set;for(let r of t)for(let t of aa(e,r))n.add(t);return n}function pa(e,t,n){e.x=t-(e.width??0)/2,e.y=n-(e.height??0)/2}function ma(e,t){let n=ta(e,t);if(n.length>0){let t=n[0],r=F(e,String(t.sources?.[0]??``));return(r===void 0?null:P(e,r))??null}return null}var ha=class{sort(e){e.sort((e,t)=>Wi(e,wi)-Wi(t,wi))}initialize(e){}};const ga=.25*Math.PI,_a=.5*Math.PI,va=.75*Math.PI,ya=1.25*Math.PI,ba=1.5*Math.PI,xa=1.75*Math.PI;var Sa=class{compRight=la(0,0);compLeft=la(Math.PI,0);compTop=la(ba,0);compBottom=la(_a,0);idSorter=null;graph=null;constructor(e){this.graph=e}initialize(e){this.idSorter=new ha;let t=I(this.graph,e);t.sort(this.compRight),this.setIDForNodes(t,0)}setIDForNodes(e,t){let n=t,r=0;for(let t of e){Xi(t,wi,n++);let e=I(this.graph,t),i=Math.atan2((t.y??0)+(t.height??0)/2,(t.x??0)+(t.width??0)/2);i+=i<0?N:0,i<ga||i>xa?e.sort(this.compLeft):i<=xa&&i>ya?e.sort(this.compTop):i<=ya&&i>va?e.sort(this.compRight):i<=va&&e.sort(this.compBottom),r=this.setIDForNodes(e,r)}return n}sort(e){if(e.length!==0){if(this.idSorter===null){let t=sa(this.graph,e[0]);this.initialize(t)}this.idSorter.sort(e)}}};function Ca(e,t){switch(t){case`NONE`:return null;case`POLAR_COORDINATE`:return new Sa(e);case`ID`:return new ha;default:throw Error(`No implementation is available for the layout option ${t}`)}}var wa=class{graph;constructor(e){this.graph=e}evaluate(e){let t=0;for(let n of ea(this.graph,e)){let r=P(this.graph,F(this.graph,String(n.targets?.[0]??``))??``),i=(r.x??0)+(r.width??0)/2,a=(r.y??0)+(r.height??0)/2,o=(e.x??0)+(e.width??0)/2,s=(e.y??0)+(e.height??0)/2,c=new b(i-o,a-s),l=new b(c.x,c.y);se(l,e.width??0,e.height??0),c.x-=l.x,c.y-=l.y,o=i-c.x,s=a-c.y;let u=new b(c.x,c.y);se(u,r.width??0,r.height??0),c.x-=u.x,c.y-=u.y,i=o+c.x,a=s+c.y;let d=i-o,f=a-s;t+=Math.sqrt(d*d+f*f)}return t}},Ta=class{graph;constructor(e){this.graph=e}evaluate(e){let t=0;for(let n of ea(this.graph,e)){let r=P(this.graph,F(this.graph,String(n.targets?.[0]??``))??``),i=(r.x??0)+(r.width??0)/2,a=(r.y??0)+(r.height??0)/2,o=M(r,Bi);if(o===void 0)throw Error(`[radial] EdgeLengthPositionOptimization requires CoreOptions.POSITION (Java NPE 等价)`);let s=(e.x??0)+o.x+(e.width??0)/2,c=(e.y??0)+o.y+(e.height??0),l=i-s,u=a-c;t+=Math.sqrt(l*l+u*u)}return t}},Ea=class{graph;constructor(e){this.graph=e}evaluate(e){let t=0,n=I(this.graph,e),r=0;for(let i of n){r++;for(let a=r;a<n.length;a++)this.isCrossing(e,i,n[a])&&(t+=1)}return t}isCrossing(e,t,n){let r=(e.x??0)+(e.width??0)/2,i=(e.x??0)+(e.width??0)/2,a=new b((t.x??0)+(t.width??0)/2,(t.y??0)+(t.height??0)/2),o=M(t,Bi);if(o===void 0)throw Error(`[radial] CrossingMinimizationPosition requires CoreOptions.POSITION (Java NPE 等价)`);o.x+=r,o.y+=i;let s=(a.y-o.y)/(a.x-o.x),c=a.y-s*a.x,l=new b((n.x??0)+(n.width??0)/2,(n.y??0)+(n.height??0)/2),u=M(n,Bi);if(u===void 0)throw Error(`[radial] CrossingMinimizationPosition requires CoreOptions.POSITION (Java NPE 等价)`);u.x+=r,u.y+=i;let d=(l.y-u.y)/(l.x-u.x),f=(c-(l.y-d*l.x))/(d-s);return!(o.x<f&&a.x<f||f<o.x&&f<a.x||u.x<f&&l.x<f||f<u.x&&f<l.x)}};function Da(e,t){switch(t){case`EDGE_LENGTH`:return new wa(e);case`EDGE_LENGTH_BY_POSITION`:return new Ta(e);case`CROSSING_MINIMIZATION_BY_POSITION`:return new Ea(e);case`NONE`:return null;default:throw Error(`No implementation is available for the layout option ${t}`)}}var Oa=class{graph;constructor(e){this.graph=e}calculateWedgeSpace(e){return ca(this.graph,e)}},ka=class{graph;constructor(e){this.graph=e}calculateWedgeSpace(e){let t=I(this.graph,e),n=e.height??0,r=e.width??0,i=Math.sqrt(n*n+r*r),a=0;for(let e of t)a+=this.calculateWedgeSpace(e);return Math.max(a,i)}};function Aa(e,t){switch(t){case`LEAF_NUMBER`:return new Oa(e);case`NODE_SIZE`:return new ka(e);default:throw Error(`No implementation is available for the layout option ${t}`)}}const ja=Math.PI/180;function Ma(e){Na(e,Zi(e,Za,void 0),Zi(e,Ti,0),Ca(e,Gi(e,Mi,`NONE`)),Aa(e,Gi(e,Ni,`NODE_SIZE`)),Da(e,Gi(e,Pi,`NONE`)))}function Na(e,t,n,r,i,a){let o=0,s=Number.MAX_VALUE;if(a!==null)for(let c=0;c<360;c++){let l=c*ja;Pa(e,t,n,r,i,t,0,0,2*Math.PI,l);let u=a.evaluate(t);u<s&&(o=l,s=u)}Pa(e,t,n,r,i,t,0,0,2*Math.PI,o)}function Pa(e,t,n,r,i,a,o,s,c,l){let u=l,d=(s+c)/2+u;pa(a,o*Math.cos(d),o*Math.sin(d));let f=i.calculateWedgeSpace(a),p=2*Math.acos(o/o+n),m,h;p<c-s?(m=p/f,h=(s+c-p)/2):(m=(c-s)/f,h=s);let g=I(e,a);r!==null&&(r.initialize(t),r.sort(g));for(let a of g){let s=i.calculateWedgeSpace(a);Pa(e,t,n,r,i,a,o+n,h,h+m*s,l),h+=m*s}}var Fa=class{compactionStep=1;spacing=0;root=null;contractLayer(e,t,n){for(let e of t){let t=(e.x??0)+(e.width??0)/2,r=(e.y??0)+(e.height??0)/2,i=this.root,a=(i.x??0)+(i.width??0)/2,o=(i.y??0)+(i.height??0)/2,s=t-a,c=r-o,l=Math.sqrt(s*s+c*c);s*=this.compactionStep/l,c*=this.compactionStep/l,n?(t-=s,r-=c):(t+=s,r+=c),e.x=t-(e.width??0)/2,e.y=r-(e.height??0)/2}}moveNode(e,t){let n=this.root,r=(n.x??0)+(n.width??0)/2,i=(n.y??0)+(n.height??0)/2,a=(e.x??0)+(e.width??0)/2,o=(e.y??0)+(e.height??0)/2,s=a-r,c=o-i,l=Math.sqrt(s*s+c*c),u=s/l,d=c/l;e.x=(e.x??0)+u*t,e.y=(e.y??0)+d*t}overlap(e,t){let n=(e.x??0)-this.spacing/2,r=(t.x??0)-this.spacing/2,i=(e.y??0)-this.spacing/2,a=(t.y??0)-this.spacing/2,o=(e.width??0)+this.spacing,s=(t.width??0)+this.spacing,c=(e.height??0)+this.spacing,l=(t.height??0)+this.spacing;return n<r+s&&r<n&&i<a+l&&a<i||r<n+o&&n<r&&a<i+c&&i<a||n<r+s&&r<n&&i<a&&a<i+c||r<n+o&&n<r&&i<a+l&&a<i}overlapLayer(e){let t=!1;if(e.length<2)return!1;for(let n=0;n<e.length;n++)n<e.length-1?t||=this.overlap(e[n],e[n+1]):t||=this.overlap(e[n],e[0]);return t}getCompactionStep(){return this.compactionStep}setCompactionStep(e){this.compactionStep=e}getSpacing(){return this.spacing}setSpacing(e){this.spacing=e}getRoot(){return this.root}setRoot(e){this.root=e}},Ia=class extends Fa{graph;sorter=null;lastRadius=0;constructor(e){super(),this.graph=e}compact(e){let t=Zi(e,Za,void 0);this.setRoot(t),this.sorter=Ca(this.graph,Gi(e,Mi,`NONE`));let n=M(e,ji);n!=null&&this.setCompactionStep(Number(n)),this.setSpacing(Wi(e,Fi));let r=I(this.graph,t);this.sorter!==null&&this.sorter.sort(r),this.contract(r)}contract(e){if(e.length===0)return;let t=this.overlapping(e),n=!1;for(;!t;)this.contractLayer(this.graph,e,!0),n=!0,t=this.overlapping(e);n&&this.contractLayer(this.graph,e,!1);let r=da(this.graph,e);this.sorter!==null&&this.sorter.sort(r),this.lastRadius=this.calculateRadius(e[0]),this.contract(r)}calculateRadius(e){let t=e.x??0,n=e.y??0,r=this.getRoot(),i=r.x??0,a=r.y??0,o=t-i,s=n-a;return Math.sqrt(o*o+s*s)}overlapping(e){if(this.overlapLayer(e))return!0;for(let t of e){let e=ma(this.graph,t);if(e!==null&&this.overlap(t,e)||this.calculateRadius(t)-this.getSpacing()<=this.lastRadius)return!0}return!1}},La=class extends Fa{graph;leftContour=/* @__PURE__ */ new Map;rightContour=/* @__PURE__ */ new Map;sorter=null;constructor(e){super(),this.graph=e}compact(e){let t=Zi(e,Za,void 0);this.setRoot(t),this.sorter=Ca(this.graph,Gi(e,Mi,`NONE`));let n=M(e,ji);n!=null&&this.setCompactionStep(Number(n)),this.setSpacing(Wi(e,Fi));let r=I(this.graph,t);this.sorter!==null&&this.sorter.sort(r),this.constructContour(r);for(let e=0;e<2;e++)for(let e=0;e<r.length;e++){let n=e<r.length-1?r[e+1]:r[0],i=e===0?r[r.length-1]:r[e-1];this.contractWedge(r[e],[t],i,n,[r[e]])}}contractWedge(e,t,n,r,i){let a=this.overlapping(t,n,r,i),o=!1;for(;!a;)this.contractLayer(this.graph,i,!0),o=!0,a=this.overlapping(t,n,r,i);o&&this.contractLayer(this.graph,i,!1);let s=da(this.graph,i);s.length>0&&(this.sorter!==null&&this.sorter.sort(s),this.contractWedge(e,i,n,r,s))}overlapping(e,t,n,r){this.sorter!==null&&this.sorter.sort(r);let i=r[0];if(this.contourOverlap(t,i,!1))return!0;let a=r[r.length-1];if(this.contourOverlap(n,a,!0)||this.overlapLayer(r))return!0;for(let t of r)for(let n of e)if(this.overlap(t,n))return!0;return!1}contourOverlap(e,t,n){let r=n?this.leftContour.get(e):this.rightContour.get(e);if(r===void 0)return!1;for(let e of r)if(this.overlap(t,e))return!0;return!1}constructContour(e){for(let t of e){this.leftContour.set(t,[t]),this.rightContour.set(t,[t]);let e=I(this.graph,t);if(e.length>0)for(this.sorter!==null&&this.sorter.sort(e),this.leftContour.get(t).push(e[0]),this.rightContour.get(t).push(e[e.length-1]);da(this.graph,e).length>0;)e=da(this.graph,e),this.sorter!==null&&this.sorter.sort(e),this.leftContour.get(t).push(e[0]),this.rightContour.get(t).push(e[e.length-1])}}};function Ra(e){za(e,Gi(e,Ai,`NONE`)).compact(e)}function za(e,t){switch(t){case`RADIAL_COMPACTION`:return new Ia(e);case`WEDGE_COMPACTION`:return new La(e);default:throw Error(`No implementation is available for the layout option ${t}`)}}var Ba=class extends Fa{graph;sorter=null;constructor(e){super(),this.graph=e}removeOverlaps(e){let t=Zi(e,Za,void 0);this.setRoot(t),this.sorter=Ca(this.graph,Gi(e,Mi,`NONE`)),this.setSpacing(Wi(e,Fi));let n=I(this.graph,t);this.extend(n)}extend(e){if(e.length===0)return;let t=e.map(e=>({x:e.x??0,y:e.y??0}));for(;this.overlapLayer(e);)this.contractLayer(this.graph,e,!1);let n=0,r=0;if(e.length>0){let i=e[0];n=(i.x??0)-t[0].x,r=(i.y??0)-t[0].y}let i=Math.sqrt(n*n+r*r),a=fa(this.graph,e);if(a.size>0)for(let e of a)this.moveNode(e,i);this.sorter!==null&&this.sorter.sort([...a]),this.extend([...a])}};function Va(e){new Ba(e).removeOverlaps(e)}var Ha=class{graph;constructor(e){this.graph=e}rotate(e){let t=Wi(e,Di);if(Ki(e,Oi)){let n=Zi(e,Za,void 0),r=na(this.graph,n),i=r[r.length-1],a=r[0],o=P(this.graph,F(this.graph,String(i.targets?.[0]??``))??``),s=P(this.graph,F(this.graph,String(a.targets?.[0]??``))??``),c={x:(o.x??0)+(o.width??0)/2,y:(o.y??0)+(o.height??0)/2},l={x:(s.x??0)+(s.width??0)/2,y:(s.y??0)+(s.height??0)/2},u=t;u<=0&&(u+=N);let d=Wa(c,l);d<=0&&(d+=N);let f=Math.atan2(c.y,c.x);f<=0&&(f+=N),t=Math.PI-(f-u+d/2)}for(let n of e.children??[]){let e=Ua({x:(n.x??0)+(n.width??0)/2,y:(n.y??0)+(n.height??0)/2},t);n.x=e.x-(n.width??0)/2,n.y=e.y-(n.height??0)/2}}};function Ua(e,t){let n=Math.cos(t),r=Math.sin(t);return{x:e.x*n-e.y*r,y:e.x*r+e.y*n}}function Wa(e,t){let n=e.x*t.y-e.y*t.x,r=e.x*t.x+e.y*t.y;return Math.atan2(n,r)}function Ga(e){new Ha(e).rotate(e)}function Ka(e){let t=Number.MAX_VALUE,n=Number.MAX_VALUE,r=Number.MIN_VALUE,i=Number.MIN_VALUE;for(let a of e.children??[]){let e=a.x??0,o=a.y??0,s=a.width??0,c=a.height??0,l=qi(a);t=Math.min(t,e-l.left),n=Math.min(n,o-l.top),r=Math.max(r,e+s+l.right),i=Math.max(i,o+c+l.bottom)}let a=Ji(e),o={x:t-a.left,y:n-a.top},s=r-t+a.left+a.right,c=i-n+a.top+a.bottom;if(Ki(e,Ci)){let t=Zi(e,Za,void 0),n=qi(t),r=(t.x??0)+(t.width??0)/2+(n.left+n.right)/2-o.x,i=(t.y??0)+(t.height??0)/2+(n.top+n.bottom)/2-o.y,a=s-r,l=c-i;if(a<s/2){let e=a-r;s+=e,o.x-=e}else{let e=r-a;s+=e}if(l<c/2){let e=l-i;c+=e,o.y-=e}else{let e=i-l;c+=e}}for(let t of e.children??[])t.x=(t.x??0)-o.x,t.y=(t.y??0)-o.y;Ki(e,zi)||(e.width=s,e.height=c),Xi(e,Vi,s-a.left-a.right),Xi(e,Hi,c-a.top-a.bottom)}var qa=class{graph;constructor(e){this.graph=e}routeEdges(e){for(let t of ea(this.graph,e))if(!$i(this.graph,String(t.sources?.[0]??``))){let n=P(this.graph,F(this.graph,String(t.targets?.[0]??``))??``);if(n===void 0)continue;if(!ra(this.graph,t)){let r=(e.x??0)+(e.width??0)/2,i=(e.y??0)+(e.height??0)/2,a=(n.x??0)+(n.width??0)/2,o=(n.y??0)+(n.height??0)/2,s=new b(a-r,o-i),c=new b(s.x,s.y);se(c,e.width??0,e.height??0),s.x-=c.x,s.y-=c.y,r=a-s.x,i=o-s.y;let l=new b(s.x,s.y);se(l,n.width??0,n.height??0),s.x-=l.x,s.y-=l.y,a=r+s.x,o=i+s.y;let u=Ja(t);u.startPoint={x:r,y:i},u.endPoint={x:a,y:o},this.routeEdges(n)}}}};function Ja(e){return e.sections??=[],e.sections.length===0&&e.sections.push({startPoint:{x:0,y:0},endPoint:{x:0,y:0}}),e.sections[0]}function Ya(e){let t=Zi(e,Za,void 0);new qa(e).routeEdges(t)}function Xa(e){let t=Zi(e,Za,void 0);for(let n of na(e,t)){let t=n.sections?.[0];if(t===void 0)continue;let r=t.startPoint,i=t.endPoint;if(r===void 0||i===void 0)continue;let a={x:i.x-r.x,y:i.y-r.y},o=Math.atan2(a.y,a.x),s=P(e,F(e,String(n.targets?.[0]??``))??``);s!==void 0&&Xi(s,Di,o)}}const Za=`org.eclipse.elk.radial.internal.root`;function Qa(e){(M(e,Ri)??!1)||ct(e);let t=oa(e);if(t===null)throw Error(`The given graph is not a tree!`);Xi(e,Za,t);let n=Wi(e,Ti);return n===0&&(n=ua(e)),Xi(e,Ti,n),Ma(e),Va(e),Gi(e,Ai,`NONE`)!==`NONE`&&Ra(e),Ki(e,Ei)&&Ga(e),Ka(e),Ya(e),Ki(e,ki)&&Xa(e),e}var $a=class{props=/* @__PURE__ */ new Map;ensure(e){let t=this.props.get(e);return t===void 0&&(t={},this.props.set(e,t)),t}getLeftOutline(e){return this.props.get(e)?.leftOutline}setLeftOutline(e,t){this.ensure(e).leftOutline=t}getRightOutline(e){return this.props.get(e)?.rightOutline}setRightOutline(e,t){this.ensure(e).rightOutline=t}getOutlineMaxDepth(e){return this.props.get(e)?.outlineMaxDepth}setOutlineMaxDepth(e,t){this.ensure(e).outlineMaxDepth=t}getMinX(e){return this.props.get(e)?.minX}setMinX(e,t){this.ensure(e).minX=t}getMaxX(e){return this.props.get(e)?.maxX}setMaxX(e,t){this.ensure(e).maxX=t}getMinY(e){return this.props.get(e)?.minY}setMinY(e,t){this.ensure(e).minY=t}getMaxY(e){return this.props.get(e)?.maxY}setMaxY(e,t){this.ensure(e).maxY=t}getEdgeBendHeight(e){return this.props.get(e)?.edgeBendHeight}setEdgeBendHeight(e,t){this.ensure(e).edgeBendHeight=t}getNodeModelOrder(e){return this.props.get(e)?.nodeModelOrder??0}setNodeModelOrder(e,t){this.ensure(e).nodeModelOrder=t}};const eo=o.spacingNodeNode.id,to=o.padding.id,no=o.margins.id,ro=o.omitNodeMicroLayout.id,io=a.vertiflex.verticalConstraint.id,ao=a.vertiflex.layoutStrategy.id,oo=a.vertiflex.layerDistance.id,so=a.vertiflex.considerNodeModelOrder.id;function co(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function lo(e,t,n){let r=co(e,t);if(r==null||r===``)return n;let i=Number(r);return Number.isFinite(i)?i:n}function uo(e,t,n){let r=co(e,t);return r==null||r===``?n:String(r).toLowerCase()===`true`||String(r).toLowerCase()!==`false`&&n}function fo(e,t,n){let r=co(e,t);return r==null||r===``?n:String(r)}function po(e,t){let n=co(e,t);if(n==null||n===``)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function mo(e){let t=co(e,no),n=e=>{if(typeof t==`object`&&t){let n=t;return typeof n[e]==`number`?n[e]:0}return 0};if(typeof t==`string`){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}return{top:e.top??0,left:e.left??0,right:e.right??0,bottom:e.bottom??0}}return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}function ho(e){let t=co(e,to);if(typeof t==`number`)return{top:t,left:t,right:t,bottom:t};if(typeof t==`object`&&t){let e=t,n=t=>typeof e[t]==`number`?e[t]:12;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}if(typeof t==`string`){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}let n=t=>e[t]??12;return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return{top:12,left:12,right:12,bottom:12}}o.spacingIndividual.id;function L(e,t){return(e.edges??[]).filter(e=>(e.sources??[])[0]===t.id)}function go(e,t){return(e.edges??[]).filter(e=>(e.targets??[])[0]===t.id)}function _o(e,t){let n=(t.targets??[])[0],r=(e.children??[]).find(e=>e.id===n);if(r===void 0)throw Error(`[vertiflex] 跨层级边不支持:target "${n}" 不在当前层级的直接子节点中(vertiflex 为树算法,边须连接父→直接子;跨层级边请改挂到 group 容器端点)`);return r}function vo(e){for(let t of e.children??[])if(go(e,t).length===0)return t;return null}function yo(e){return e.sections??=[],e.sections.length===0&&e.sections.push({startPoint:{x:0,y:0},endPoint:{x:0,y:0}}),e.sections[0]}function bo(e,t,n){e.bendPoints??=[],e.bendPoints.push({x:t,y:n})}function R(e){return e.x??0}function xo(e){return e.y??0}function So(e,t){let n=lo(e,oo,50),r=lo(e,eo,20);(e.children??[]).length>0&&Co(e,t,0,n,r)}function Co(e,t,n,r,i){let a=po(t,io);a!==void 0&&(n=a),t.y=n;let o=n+r+(t.height??0)+Math.max(mo(t).bottom,i);for(let n of L(e,t))Co(e,_o(e,n),o,r,i)}function wo(e,t){if(e<t)return-1;if(e>t)return 1;if(e===0&&t===0){if(1/e<1/t)return-1;if(1/e>1/t)return 1}return 0}var To=class{invert=!1;constructor(e=!1){this.invert=e}compare(e,t,n){let r;return r=this.invert?wo(t.y??0,e.y??0):wo(e.y??0,t.y??0),r===0?n.getNodeModelOrder(e)-n.getNodeModelOrder(t):r}},z=class{relativeX;absoluteY;next;constructor(e,t,n){this.relativeX=e,this.absoluteY=t,this.next=n}getAbsoluteY(){return this.absoluteY}setAbsoluteY(e){this.absoluteY=e}getRelativeX(){return this.relativeX}setRelativeX(e){this.relativeX=e}getNext(){return this.next}setNext(e){this.next=e}isLast(){return this.next===null}printFullOutline(){let e=[this.toString()];return this.isLast()||e.push(this.getNext().printFullOutline()),e.join(`
|
|
2
13
|
`)}toString(){return`X:${this.relativeX}, Y:${this.absoluteY}`}};const Eo=-100;function Do(e,t,n){let r=lo(e,eo,20),i=uo(e,so,!0);if((e.children??[]).length>0)switch(fo(e,ao,`STRAIGHT`)){case`STRAIGHT`:ko(e,t,n,r,i);break;case`BEND`:Ao(e,t,n,r)}}function Oo(e,t){let n=new z(e.getRelativeX(),Eo,new z(0,e.getAbsoluteY(),e.getNext())),r=new z(t.getRelativeX(),Eo,new z(0,t.getAbsoluteY(),t.getNext())),i=n.getRelativeX()-r.getRelativeX(),a,o,s,c,l,u,d;for(a=n,o=r,s=a.getRelativeX(),c=o.getRelativeX();a!==null&&!o.isLast();){let e=o.getNext();e.getAbsoluteY()>a.getAbsoluteY()?(l=e.getRelativeX(),u=e.getAbsoluteY()-o.getAbsoluteY(),d=s-c-(a.getAbsoluteY()-o.getAbsoluteY())*l/u,i=Math.max(i,d),a=a.getNext(),a!==null&&(s+=a.getRelativeX())):(o=o.getNext(),c+=o.getRelativeX())}for(a=n,o=r,s=a.getRelativeX(),c=o.getRelativeX();o!==null&&!a.isLast();){let e=a.getNext();e.getAbsoluteY()>o.getAbsoluteY()?(l=e.getRelativeX(),u=e.getAbsoluteY()-a.getAbsoluteY(),d=s-c+(o.getAbsoluteY()-a.getAbsoluteY())*l/u,i=Math.max(i,d),o=o.getNext(),o!==null&&(c+=o.getRelativeX())):(a=a.getNext(),s+=a.getRelativeX())}return i}function ko(e,t,n,r,i){if(Po(t,n,r),L(e,t).length>0){let a=[];for(let o of L(e,t)){let t=_o(e,o);ko(e,t,n,r,i),a.push(t)}jo(a,n,i);for(let e=0;e<a.length-1;e++)Fo(a[0],a[e],a[e+1],n);let o=0,s=0,c=0;for(;o<a.length&&(a[o].y??0)>=s;)(a[o].y??0)>s&&(c=o,s=a[o].y??0),o+=1;let l=0;if(o>0&&(l=(R(a[c])+R(a[o-1])+(a[o-1].width??0))/2-R(t)-(t.width??0)/2),!uo(t,so,!0)){let e=(R(a[0])+R(a[a.length-1])+(a[a.length-1].width??0)-(t.width??0))/2-R(t),r;if(e<l){let i,o,u;for(let l=0;l<c;l++)for(let d=l+1;d<c+1;d++)for(i=n.getRightOutline(a[l]),o=R(a[l])+i.getRelativeX(),u=R(a[d])+(a[d].width??0)/2;i!==void 0&&i.getAbsoluteY()<s;)r=u-(t.width??0)/2+(u-o)*((t.y??0)+(t.height??0)-s)/(s-i.getAbsoluteY()),e=Math.max(e,r),i=i.getNext()??void 0,i!==void 0&&(o+=i.getRelativeX());l=e}if(e>l){let i,c,u;for(let l=o;l<a.length;l++)for(let d=o-1;d<l;d++)for(i=n.getLeftOutline(a[l]),c=R(a[l])+i.getRelativeX(),u=R(a[d])+(a[d].width??0)/2;i!==void 0&&i.getAbsoluteY()<s;)r=u-(t.width??0)/2+(u-c)*((t.y??0)+(t.height??0)-s)/(s-i.getAbsoluteY()),e=Math.min(e,r),i=i.getNext()??void 0,i!==void 0&&(c+=i.getRelativeX());l=e}}for(let e of a)e.x=R(e)-l;let u=n.getLeftOutline(t),d=n.getLeftOutline(a[0]),f=R(a[0])+d.getRelativeX()-u.getRelativeX();u.getNext().getNext().getNext().setNext(new z(f,d.getAbsoluteY(),d.getNext()));let p=n.getRightOutline(t),m=n.getRightOutline(a[a.length-1]);f=R(a[a.length-1])+m.getRelativeX()-p.getRelativeX(),p.getNext().getNext().getNext().setNext(new z(f,m.getAbsoluteY(),m.getNext()));for(let e of a)n.setOutlineMaxDepth(t,Math.max(n.getOutlineMaxDepth(t)??0,n.getOutlineMaxDepth(e)??0)),n.setMinX(t,Math.min(n.getMinX(t)??0,R(e)+(n.getMinX(e)??0))),n.setMaxX(t,Math.max(n.getMaxX(t)??0,R(e)+(n.getMaxX(e)??0)));n.setMaxY(t,n.getOutlineMaxDepth(t)??0)}}function Ao(e,t,n,r){if(Po(t,n,r),L(e,t).length>0){let i=[];for(let a of L(e,t)){let t=_o(e,a);Ao(e,t,n,r),i.push(t)}let a=i.length;for(let e=0;e<i.length-1;e++)Fo(i[0],i[e],i[e+1],n);let o=(R(i[0])+(i[0].width??0)/2+R(i[i.length-1])+(i[i.length-1].width??0)/2-(t.width??0))/2-R(t);for(let e of i)e.x=R(e)-o,n.setEdgeBendHeight(e,n.getLeftOutline(e).getAbsoluteY());let s=0;for(;s<a-1&&R(i[s])+(i[s].width??0)+mo(i[s]).right-(t.width??0)/2<=0;)s++;let c=n.getEdgeBendHeight(i[s]);for(let e=0;e<a;e++)c<n.getEdgeBendHeight(i[e])?n.setEdgeBendHeight(i[e],c):c=n.getEdgeBendHeight(i[e]);for(s=a-1;s>0&&R(i[s])-mo(i[s]).left-(t.width??0)/2>=0;)s--;if(s<a)for(let e=s;e>=0;e--)c<n.getEdgeBendHeight(i[e])?n.setEdgeBendHeight(i[e],c):c=n.getEdgeBendHeight(i[e]);let l,u,d=n.getLeftOutline(i[0]),f=n.getLeftOutline(t);l=R(i[0])+d.getRelativeX()-f.getRelativeX(),u=new z(0,d.getAbsoluteY(),d.getNext()),f.getNext().getNext().getNext().setNext(new z(l,n.getEdgeBendHeight(i[0]),u));let p=n.getRightOutline(t),m=n.getRightOutline(i[a-1]);l=R(i[a-1])+m.getRelativeX()-p.getRelativeX(),u=new z(0,m.getAbsoluteY(),m.getNext()),p.getNext().getNext().getNext().setNext(new z(l,n.getEdgeBendHeight(i[a-1]),u));for(let e of i)n.setOutlineMaxDepth(t,Math.max(n.getOutlineMaxDepth(t)??0,n.getOutlineMaxDepth(e)??0)),n.setMinX(t,Math.min(n.getMinX(t)??0,R(e)+(n.getMinX(e)??0))),n.setMaxX(t,Math.max(n.getMaxX(t)??0,R(e)+(n.getMaxX(e)??0)));n.setMaxY(t,n.getOutlineMaxDepth(t)??0)}}function jo(e,t,n){e.sort((e,n)=>new To(!1).compare(e,n,t));let r=[],i=[];if(n)Mo(e,r,i,t);else{r.push(e[e.length-1]);let t=0,n=0;for(let a=1;a<e.length;a++)t<=n?(r.push(e[e.length-1-a]),t+=e[e.length-1-a].width??0):(i.push(e[e.length-1-a]),n+=e[e.length-1-a].width??0);r.reverse()}i.sort((e,n)=>new To(!0).compare(e,n,t)),r.push(...i);for(let t=0;t<e.length;t++)e[t]=r[t]}function Mo(e,t,n,r){if(e.length===0)return;if(e.length===1&&t.push(e[0]),e.length===2){let i=e[0],a=e[1];r.getNodeModelOrder(i)>r.getNodeModelOrder(a)?(t.push(a),n.push(i)):(t.push(i),n.push(a))}let i=[],a={first:0,second:0},o=e[0];i.push(o);for(let r=1;r<e.length;r++){let s=e[r];if((o.y??0)===(s.y??0))i.push(s);else{let e=No(i,a);t.push(...i.slice(0,e+1)),n.push(...i.slice(e+1)),i=[],i.push(s)}if(o=s,r===e.length-1){let e=No(i,a);t.push(...i.slice(0,e+1)),n.push(...i.slice(e+1))}}}function No(e,t){if(e.length===1)return 0;{let n=t.first,r=t.second,i=0;for(let t of e)i+=t.width??0;let a=(i-n+r)/2,o=0;for(;a<o&&0<e.length;)o+=e[0].width??0;let s=o-a,c=a-(o-(e[0].width??0)),l;l=s>c?0:-1,t.first=n+s;let u=0;for(let t=l+1;t<e.length;t++)u+=e[t].width??0;return t.second=r+u,l}}function Po(e,t,n){let r=mo(e),i;i=new z(0,(e.y??0)+(e.height??0)+r.bottom+n/2,new z((e.width??0)/2,(e.y??0)+(e.height??0)+r.bottom+n/2,null)),t.setLeftOutline(e,new z(-r.left-n/2+(e.width??0)/2,(e.y??0)-r.top-n/2,new z(-(e.width??0)/2,(e.y??0)-r.top,i))),i=new z(0,(e.y??0)+(e.height??0)+r.bottom,new z(-(e.width??0)/2,(e.y??0)+(e.height??0)+r.bottom+n/2,null)),t.setRightOutline(e,new z((e.width??0)/2+r.right+n/2,(e.y??0)-r.top,new z((e.width??0)/2,(e.y??0)-r.top-n/2,i))),t.setMinX(e,(e.x??0)-r.left),t.setMaxX(e,(e.x??0)+r.right+(e.width??0)),t.setMinY(e,(e.y??0)-r.top),t.setMaxY(e,(e.y??0)+r.bottom+(e.height??0)),t.setOutlineMaxDepth(e,t.getLeftOutline(e).getNext().getNext().getAbsoluteY())}function Fo(e,t,n,r){let i,a,o,s=Oo(r.getRightOutline(t),r.getLeftOutline(n));if(n.x=R(t)+s,(r.getOutlineMaxDepth(e)??0)<(r.getOutlineMaxDepth(n)??0)){let t=r.getLeftOutline(e),s=t.getRelativeX()+R(e);for(;!t.isLast();)t=t.getNext(),s+=t.getRelativeX();let c=new z(r.getLeftOutline(n).getRelativeX(),Eo,r.getLeftOutline(n).getNext()),l=c.getRelativeX()+R(n);for(;c.getNext().getAbsoluteY()<=t.getAbsoluteY();)c=c.getNext(),l+=c.getRelativeX();i=c.getNext().getRelativeX(),a=c.getNext().getAbsoluteY()-c.getAbsoluteY(),o=(t.getAbsoluteY()-c.getAbsoluteY())*i/a;let u=-s+l+o,d=new z(c.getNext().getRelativeX()-o,c.getNext().getAbsoluteY(),c.getNext().getNext());t.setNext(new z(u,t.getAbsoluteY(),d)),r.setOutlineMaxDepth(e,r.getOutlineMaxDepth(n)??0)}if((r.getOutlineMaxDepth(n)??0)<(r.getOutlineMaxDepth(t)??0)){let e=r.getRightOutline(n),s=e.getRelativeX()+R(n);for(;!e.isLast();)e=e.getNext(),s+=e.getRelativeX();let c=new z(r.getRightOutline(t).getRelativeX(),Eo,r.getRightOutline(t).getNext()),l=c.getRelativeX()+R(t);for(;c.getNext().getAbsoluteY()<=e.getAbsoluteY();)c=c.getNext(),l+=c.getRelativeX();i=c.getNext().getRelativeX(),a=c.getNext().getAbsoluteY()-c.getAbsoluteY(),o=(e.getAbsoluteY()-c.getAbsoluteY())*i/a;let u=l-s+o,d=new z(c.getNext().getRelativeX()-o,c.getNext().getAbsoluteY(),c.getNext().getNext());e.setNext(new z(u,e.getAbsoluteY(),d)),r.setOutlineMaxDepth(n,r.getOutlineMaxDepth(t)??0)}}function Io(e,t){(e.children??[]).length>0&&(t.x=R(t)-Lo(e,t),Ro(e,t))}function Lo(e,t){if(L(e,t).length===0)return R(t);{let n=0;for(let r of L(e,t)){let t=Lo(e,_o(e,r));n=t<n?t:n}return n+R(t)}}function Ro(e,t){if(L(e,t).length>0)for(let n of L(e,t)){let r=_o(e,n);r.x=R(r)+R(t),Ro(e,r)}}function zo(e,t,n){(e.children??[]).length>0&&Bo(e,t,n)}function Bo(e,t,n){for(let r of L(e,t)){let i=_o(e,r),a=yo(r),o=R(t)+(t.width??0)/2,s=xo(t)+(t.height??0),c=R(i)+(i.width??0)/2,l=xo(i);a.startPoint={x:o,y:s},a.endPoint={x:c,y:l};let u=n.getEdgeBendHeight(i)??0;Math.abs(u-(l-lo(e,eo,20)/2))>1e-4&&bo(a,c,u),Bo(e,i,n)}}function Vo(e,t){(e.children??[]).length>0&&Ho(e,t)}function Ho(e,t){for(let n of L(e,t)){let r=_o(e,n),i=yo(n),a=R(t)+(t.width??0)/2,o=xo(t)+(t.height??0),s=R(r)+(r.width??0)/2,c=xo(r);i.startPoint={x:a,y:o},i.endPoint={x:s,y:c},Ho(e,r)}}function Uo(e){let t=new $a,n=lo(e,eo,20);uo(e,ro,!1)||ct(e);let r=vo(e);if(r===null)throw Error(`[vertiflex] The given graph is not a tree!`);for(let t of e.children??[]){if(go(e,t).length>1)throw Error(`[vertiflex] The given graph is not an acyclic tree!`);t.x=0,t.y=0}Wo(e,r,0,n);let i=0;for(let n of e.children??[])t.setNodeModelOrder(n,i),i+=1;switch(So(e,r),Do(e,r,t),Io(e,r),fo(e,ao,`STRAIGHT`)){case`STRAIGHT`:Vo(e,r);break;case`BEND`:zo(e,r,t)}return Go(e),e}function Wo(e,t,n,r){let i,a=po(t,io);i=a===void 0?n:a;let o=i+(t.height??0)+Math.max(mo(t).bottom,r);for(let n of L(e,t)){let t=_o(e,n),r=po(t,io);if(r!==void 0&&o>r+mo(t).top)throw Error(`[vertiflex] Invalid vertical constraints. Node ${t.id} has a vertical constraint that is too low for its ancestors.`)}for(let n of L(e,t))Wo(e,_o(e,n),o,r)}function Go(e){let t=ho(e),n=0,r=0;for(let t of e.children??[]){let e=mo(t);n<(t.x??0)+(t.width??0)+e.right&&(n=(t.x??0)+(t.width??0)+e.right),r<(t.y??0)+(t.height??0)+e.bottom&&(r=(t.y??0)+(t.height??0)+e.bottom)}e.width=n+t.right,e.height=r+t.bottom}function Ko(e,t,n){return Math.abs(e-t)<=n}function qo(e,t,n){return Math.abs(e-t)<=n?0:e<t?-1:1}var Jo=class{x;y;width;height;constructor(e=0,t=0,n=0,r=0){this.x=e,this.y=t,this.width=n,this.height=r}getTopLeft(){return new b(this.x,this.y)}getTopRight(){return new b(this.x+this.width,this.y)}getBottomLeft(){return new b(this.x,this.y+this.height)}getBottomRight(){return new b(this.x+this.width,this.y+this.height)}},Yo=class e{points=[];add(e){return this.points.push(e),e}addAt(e,t){return this.points.splice(e,0,t),t}remove(){let e=this.points[0];return this.points.splice(0,1),e}get(e){return this.points[e]}getFirst(){return this.points[0]}getLast(){return this.points[this.points.length-1]}size(){return this.points.length}toArray(){return this.points}each(e){for(let t of this.points)e(t)}reverse(){let t=new e;for(let e=this.points.length-1;e>=0;e--)t.add(this.points[e].clone());return t}static of(t){let n=new e;for(let e of t)n.add(e);return n}};function Xo(e,t,n,r){let i=e,a=t.clone().sub(e),o=n,s=r.clone().sub(n),c=i.x,l=i.y,u=o.x,d=o.y,f=a.x,p=a.y,m=s.x,h=s.y,g=m*p-f*h;if(Ko(0,g,1e-5))return!1;let _=1/g*((c-u)*p-(l-d)*f),v=1/g*-(-(c-u)*h+(l-d)*m);return qo(0,_,1e-5)<0&&qo(_,1,1e-5)<0&&qo(0,v,1e-5)<0&&qo(v,1,1e-5)<0}function Zo(e,t){let n=e.x,r=e.x+e.width,i=e.y,a=e.y+e.height;return t.x>n&&t.x<r&&t.y>i&&t.y<a}function Qo(e,t,n){return Zo(e,t)&&Zo(e,n)}function $o(e,t){if(t.size()<2)return!1;let n=t.getFirst(),r=n;for(let n=1;n<t.size();n++){let i=t.get(n);if(!Qo(e,r,i))return!1;r=i}return!!Qo(e,r,n)}function es(e,t,n){return Qo(e,t,n)?!1:Xo(e.getTopLeft(),e.getTopRight(),t,n)||Xo(e.getTopRight(),e.getBottomRight(),t,n)||Xo(e.getBottomRight(),e.getBottomLeft(),t,n)||Xo(e.getBottomLeft(),e.getTopLeft(),t,n)}function ts(e,t){if(t.size()<2)return!1;let n=t.getFirst(),r=n;for(let n=1;n<t.size();n++){let i=t.get(n);if(es(e,r,i))return!0;r=i}return!!es(e,r,n)}var B=class{first;second;constructor(e,t){this.first=e,this.second=t}getFirst(){return this.first}getSecond(){return this.second}},ns=class{first;second;third;fourth;constructor(e,t,n,r){this.first=e,this.second=t,this.third=n,this.fourth=r}getFirst(){return this.first}getSecond(){return this.second}getThird(){return this.third}getFourth(){return this.fourth}},rs=class e{first;second;third;constructor(e,t,n){this.first=e,this.second=t,this.third=n}getFirst(){return this.first}getSecond(){return this.second}getThird(){return this.third}equals(t){return t instanceof e&&this.first===t.first&&this.second===t.second&&this.third===t.third}},is=class{top;left;right;bottom;constructor(e=0,t=0,n=0,r=0){this.top=e,this.left=t,this.right=n,this.bottom=r}getHorizontal(){return this.left+this.right}getVertical(){return this.top+this.bottom}};let as=/* @__PURE__ */ function(e){return e.NORTH=`NORTH`,e.EAST=`EAST`,e.SOUTH=`SOUTH`,e.WEST=`WEST`,e}({});(function(e){function t(e){return e===`EAST`||e===`WEST`}e.isHorizontal=t})(as||={});var os=class{shape;bounds;cp=null;coords=null;parentCoords=null;extensions=[];constructor(e){this.shape=e;let t=1/0,n=1/0,r=-1/0,i=-1/0,a=e.toArray();for(let e of a)t=Math.min(t,e.x),n=Math.min(n,e.y),r=Math.max(r,e.x),i=Math.max(i,e.y);this.bounds=new Jo(t,n,r-t,i-n)}getOffset(){return this.cp.getOffset()}getCoords(){if(this.coords!==null)return this.coords;this.coords=Array(this.shape.size()*2);let e=0;return this.shape.each(t=>{this.coords[e]=t.x,this.coords[e+1]=t.y,e+=2}),this.coords}addExtension(e){this.extensions.push(e)}getExtensions(){return this.extensions}getBounds(){return this.bounds}setParentCoords(e){this.parentCoords=e}getParentcoords(){return this.parentCoords}setComponent(e){this.cp=e}intersects(e){return ts(e,this.shape)||$o(e,this.shape)}},ss=class{parent;direction;offset;width;constructor(e,t,n,r){this.parent=e,this.direction=t,this.width=r;let i=e.getBounds();this.offset=new b(-i.x,-i.y),this.offset.add(n);let a=r/2;as.isHorizontal(t)?this.offset.y-=a:this.offset.x-=a,e.addExtension(this)}getParent(){return this.parent}getDirection(){return this.direction}getOffset(){return this.offset}getWidth(){return this.width}},cs=class{offset;shapes;changed=!0;bounds=null;minCornerOfBoundingRectangle=null;id=-1;constructor(){this.offset=new b(0,0),this.shapes=/* @__PURE__ */ new Set}setOffset(e){this.changed=!0,this.offset=e}getOffset(){return this.offset}getElements(){return this.shapes}getDimensionsOfBoundingRectangle(){return this.changed&&this.update(),this.bounds}getMinCorner(){return this.changed&&this.update(),this.minCornerOfBoundingRectangle}intersects(e){for(let t of this.shapes)if(t.intersects(e))return!0;return!1}addElement(e){this.changed=!0,this.shapes.add(e),e.setComponent(this)}addElements(e){for(let t of e)this.addElement(t)}update(){this.changed=!1;let e=1/0,t=-1/0,n=1/0,r=-1/0;for(let i of this.shapes){let a=i.getBounds();e=Math.min(e,a.x),t=Math.max(t,a.x+a.width),n=Math.min(n,a.y),r=Math.max(r,a.y+a.height);for(let o of i.getExtensions()){let i=o.getDirection(),s,c;as.isHorizontal(i)?(s=a.y+o.getOffset().y,c=s+o.getWidth(),n=Math.min(n,s),r=Math.max(r,c)):(s=a.x+o.getOffset().x,c=s+o.getWidth(),e=Math.min(e,s),t=Math.max(t,c))}}this.bounds=new b(t-e,r-n),this.minCornerOfBoundingRectangle=new b(e+this.offset.x,n+this.offset.y)}getId(){return this.id}setId(e){this.id=e}},ls=class{components=/* @__PURE__ */ new Set;dimensions=null;inset=0;layoutOptions;constructor(e,t=0,n={}){for(let t of e){let e=new cs;e.addElements(t),this.components.add(e)}this.inset=t,this.layoutOptions=n}getComponents(){return this.components}getDimensions(){return this.dimensions}setDimensions(e){this.dimensions=e}getInset(){return this.inset}};const us=o.spacingComponentComponent.id,ds=o.edgeThickness.id,fs=o.padding.id,ps=o.aspectRatio.id,ms=a.disco.componentCompactionStrategy.id;a.disco.componentLayoutAlgorithm.id,a.disco.debugDiscoGraph.id,a.disco.debugDiscoPolys.id;const hs=a.disco.polyominoFill.id,gs=a.disco.polyominoLowLevelSort.id,_s=a.disco.polyominoHighLevelSort.id,vs=a.disco.polyominoTraversalStrategy.id,ys={[us]:20,[ds]:1,[fs]:12,[ms]:`POLYOMINO`,[hs]:!0,[gs]:`BY_SIZE_AND_SHAPE`,[_s]:`NUM_OF_EXTERNAL_SIDES_THAN_NUM_OF_EXTENSIONS_LAST`,[vs]:`QUADRANTS_LINE_BY_LINE`};function bs(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function xs(e,t){let n=bs(e,t);if(n==null||n===``)return ys[t];let r=Number(n);return Number.isFinite(r)?r:ys[t]}function Ss(e,t){let n=bs(e,t);return n==null||n===``?ys[t]:String(n).toLowerCase()===`true`}function Cs(e,t,n){let r=bs(e,t);return r==null||r===``?n:String(r)}function ws(e){let t=bs(e,fs);if(typeof t==`number`)return new is(t,t,t,t);if(typeof t==`object`&&t){let e=t,n=t=>typeof e[t]==`number`?e[t]:ys[fs];return new is(n(`top`),n(`left`),n(`right`),n(`bottom`))}if(typeof t==`string`){let e=t.match(/top=([\d.]+),\s*left=([\d.]+),\s*right=([\d.]+),\s*bottom=([\d.]+)/);if(e)return new is(Number(e[1]),Number(e[2]),Number(e[3]),Number(e[4]))}return new is(ys[fs],ys[fs],ys[fs],ys[fs])}function Ts(e){let t=bs(e,ps);if(t==null||t===``)return;let n=Number(t);return Number.isFinite(n)?n:void 0}function V(e,t){if(H(t,e)!==null)return e;let n=e.lastIndexOf(`.`);return n===-1?e:e.slice(0,n)}function Es(e,t){if(H(t,e)!==null)return;let n=e.lastIndexOf(`.`);return n===-1?void 0:e.slice(n+1)}function Ds(e){let t=[],n=e=>{for(let n of e.edges??[])t.push(n);for(let t of e.children??[])n(t)};return n(e),t}function H(e,t){if(e.id===t)return e;for(let n of e.children??[]){let e=H(n,t);if(e!==null)return e}return null}let Os;(function(e){function t(e){let t=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Map,i=[],a=e.children??[];n(a,e,r);for(let e of a)if(!t.has(e)){let n=[];i.push(n),s(e,n,t,r)}return i}e.split=t;function n(e,t,n){let s=Ds(t),c=/* @__PURE__ */ new Map;for(let l of e){let e=/* @__PURE__ */ new Set;n.set(l,e);let u=(e,t)=>r(e)===r(t),d=s.filter(e=>V(String(e.targets?.[0]??``),t)===l.id);o(e,d.filter(e=>{let n=H(t,V(String(e.sources?.[0]??``),t));return n!==null&&u(n,l)}),e=>H(t,V(String(e.sources?.[0]??``),t)));let f=d.filter(e=>{let n=H(t,V(String(e.sources?.[0]??``),t));return n!==null&&n.id===r(l)});for(let n of f){let r=String(n.sources?.[0]??``),o=i(t,r);if(o!==void 0){let n=c.get(o);n===void 0&&(n=a(r,o,t,s),c.set(o,n));for(let t of n)e.add(t)}}let p=s.filter(e=>V(String(e.sources?.[0]??``),t)===l.id);o(e,p.filter(e=>{let n=H(t,V(String(e.targets?.[0]??``),t));return n!==null&&u(l,n)}),e=>H(t,V(String(e.targets?.[0]??``),t)));let m=p.filter(e=>{let n=H(t,V(String(e.targets?.[0]??``),t));return n!==null&&n.id===r(l)});for(let n of m){let r=String(n.targets?.[0]??``),o=i(t,r);if(o!==void 0){let n=c.get(o);n===void 0&&(n=a(r,o,t,s),c.set(o,n));for(let t of n)e.add(t)}}}}function r(e){let t=e.id.lastIndexOf(`.`);return t===-1?``:e.id.slice(0,t)}function i(e,t){let n=H(e,V(t,e)),r=Es(t,e);if(n!==null&&r!==void 0)return(n.ports??[]).find(e=>e.id===r)}function a(e,t,n,r){let i=H(n,V(e,n)),a=e=>{let t=H(n,V(String(e.sources?.[0]??``),n)),r=H(n,V(String(e.targets?.[0]??``),n));return i!==null&&(t!==null&&i.id===t.id||r!==null&&i.id===r.id)},o=e=>{let t=H(n,V(String(e.sources?.[0]??``),n)),r=H(n,V(String(e.targets?.[0]??``),n));return t!==null&&i!==null&&t.id===i.id?r:t},s=r.filter(t=>{let n=String(t.sources?.[0]??``),r=String(t.targets?.[0]??``);return n===e||r===e});return new Set(s.filter(a).map(o))}function o(e,t,n){for(let r of t)e.add(n(r))}function s(e,t,n,r){n.add(e),t.push(e);let i=r.get(e);if(i!==void 0)for(let e of i)n.has(e)||s(e,t,n,r)}})(Os||={});const ks=Math.PI/2;var As=class{parent=null;elementMapping=/* @__PURE__ */ new Map;incomingExtensionsMapping=/* @__PURE__ */ new Map;outgoingExtensionsMapping=/* @__PURE__ */ new Map;transformedGraph=null;componentSpacing=0;constructor(e=0){this.componentSpacing=e}importGraph(e){this.parent=e;let t=Os.split(e),n=[];for(let r of t){let t=[];n.push(t);let i=/* @__PURE__ */ new Set;for(let n of r){let r=this.importElkShape(n,!0,0,0);t.push(r);let a=n.x??0,o=n.y??0;r.setParentCoords(new b(a,o));for(let e of n.labels??[]){let n=this.importElkShape(e,!1,a,o);t.push(n)}for(let e of n.ports??[]){let n=this.importElkShape(e,!1,a,o);t.push(n);let r=(e.x??0)+a,i=(e.y??0)+o;for(let n of e.labels??[]){let e=this.importElkShape(n,!1,r,i);t.push(e)}}for(let t of this.allIncidentEdges(e,n))i.add(t)}this.importElkEdges(i,t)}let r={...e.layoutOptions??{},...e.properties??{}};return this.transformedGraph=new ls(n,this.componentSpacing/2,r),this.transformedGraph}applyLayout(){let e=this.transformedGraph.getDimensions(),t=e.x,n=e.y,r=this.parent.width??0,i=this.parent.height??0;this.parent.width=e.x,this.parent.height=e.y;let a=t/r,o=n/i;for(let e of this.parent.labels??[])e.x=(e.x??0)*a,e.y=(e.y??0)*o;for(let e of this.parent.ports??[]){let t=e.x??0,n=e.y??0;t>0&&(e.x=t*a),n>0&&(e.y=n*o)}for(let[e,t]of this.elementMapping)this.applyOffset(e,t);let s=[];for(let[e,t]of this.incomingExtensionsMapping){let n=t.getDirection(),r=this.firstEdgeSection(e),i=this.adjustFirstSegment(this.getSourceNode(this.parent,e),this.createVectorChain(r),n);this.applyVectorChain(i,r);let a=this.getSourcePort(this.parent,e);a!==void 0&&!s.includes(a)&&(s.push(a),this.adjustRelatedPort(a,i.getFirst(),n))}for(let[e,t]of this.outgoingExtensionsMapping){let n=t.getDirection(),r=this.firstEdgeSection(e),i=this.adjustFirstSegment(this.getTargetNode(this.parent,e),Yo.of(this.createVectorChain(r).toArray()).reverse(),n),a=Yo.of(i.toArray()).reverse();this.applyVectorChain(a,r);let o=this.getTargetPort(this.parent,e);o!==void 0&&!s.includes(o)&&(s.push(o),this.adjustRelatedPort(o,a.getLast(),n))}}adjustRelatedPort(e,t,n){as.isHorizontal(n)?e.y=t.y-(e.height??0)/2:e.x=t.x-(e.width??0)/2}importElkShape(e,t,n,r){let i=this.componentSpacing/2,a=(e.x??0)+n-i,o=(e.y??0)+r-i,s=a+(e.width??0)+this.componentSpacing,c=o+(e.height??0)+this.componentSpacing,l=new Yo;l.add(new b(a,o)),l.add(new b(a,c)),l.add(new b(s,c)),l.add(new b(s,o));let u=new os(l);return t&&this.elementMapping.set(e,u),u}importElkEdge(e,t){let n=this.firstEdgeSection(e),r=this.createVectorChain(n),i=xs(e,ds),a=new os(this.getContour(r.toArray(),i+this.componentSpacing));this.elementMapping.set(e,a),t.push(a);for(let n of e.labels??[]){let e=this.importElkShape(n,!0,0,0);t.push(e)}return a}importExtension(e,t,n){let r=this.firstEdgeSection(e),i=this.createVectorChain(r);n&&(i=Yo.of(i.toArray()).reverse());let a,o=xs(e,ds),s=i.getFirst(),c=i.get(1);if(i.size()>2){let e=i.toArray().slice(1);a=new os(this.getContour(e,o+this.componentSpacing)),t.push(a)}else a=n?this.elementMapping.get(this.getSourceNode(this.parent,e)):this.elementMapping.get(this.getTargetNode(this.parent,e));let l=this.getSourceNode(this.parent,e);n&&(l=this.getTargetNode(this.parent,e));let u=this.nearestSide(s,l),d=o+this.componentSpacing,f;as.isHorizontal(u)?(d+=Math.abs(s.y-c.y),f=new b(c.x,(c.y+s.y)/2)):(d+=Math.abs(s.x-c.x),f=new b((c.x+s.x)/2,c.y)),n?this.outgoingExtensionsMapping.set(e,new ss(a,u,f,d)):this.incomingExtensionsMapping.set(e,new ss(a,u,f,d)),this.elementMapping.set(e,a);for(let n of e.labels??[]){let e=this.importElkShape(n,!0,0,0);t.push(e)}}nearestSide(e,t){let n,r=Number.MAX_VALUE,i=`NORTH`;return r=Math.abs(e.y),n=Math.abs((t.height??0)-e.y),n<r&&(r=n,i=`SOUTH`),n=Math.abs(e.x),n<r&&(r=n,i=`WEST`),n=Math.abs((t.width??0)-e.x),n<r&&(r=n,i=`EAST`),i}importElkEdges(e,t){for(let n of e)if(this.elementMapping.get(n)===void 0){let e=this.getSourceNode(this.parent,n),r=this.getTargetNode(this.parent,n);e.id===r.id||js(e)===js(r)?this.importElkEdge(n,t):e.id===js(r)?this.incomingExtensionsMapping.get(n)===void 0&&this.elementMapping.get(r)!==void 0&&this.importExtension(n,t,!1):this.outgoingExtensionsMapping.get(n)===void 0&&this.elementMapping.get(e)!==void 0&&this.importExtension(n,t,!0)}}getContour(e,t){let n=[],r=[],i=t/2,a=e.length,o,s=e[0],c=e[1],l=this.getOrthogonalPoints(s.x,s.y,c.x,c.y,i);n.push(l[0]),r.push(l[1]);for(let t=2;t<a;t++)o=s,s=c,c=e[t],l=this.getOrthogonalPoints(s.x,s.y,o.x,o.y,i),n.push(l[1]),r.push(l[0]),l=this.getOrthogonalPoints(s.x,s.y,c.x,c.y,i),n.push(l[0]),r.push(l[1]);l=this.getOrthogonalPoints(c.x,c.y,s.x,s.y,i),n.push(l[1]),r.push(l[0]);let u=new Yo,d=[];u.add(n[0]);for(let e=1;e<n.length-2;e+=2){let t=n[e],r=this.computeIntersection(n[e-1],t,n[e+1],n[e+2]);!Number.isFinite(r.x)||!Number.isFinite(r.y)?u.add(t):u.add(r)}u.add(n[n.length-1]),d.push(r[0]);for(let e=1;e<r.length-2;e+=2){let t=r[e],n=this.computeIntersection(r[e-1],t,r[e+1],r[e+2]);!Number.isFinite(n.x)||!Number.isFinite(n.y)?d.push(t):d.push(n)}d.push(r[r.length-1]);for(let e=d.length-1;e>=0;e--)u.add(d[e]);return u}getOrthogonalPoints(e,t,n,r,i){let a=n-e,o=r-t,s=Math.atan2(a,o),c=s+ks,l=s-ks,u=i*Math.sin(c)+e,d=i*Math.cos(c)+t,f=i*Math.sin(l)+e,p=i*Math.cos(l)+t;return[new b(u,d),new b(f,p)]}computeIntersection(e,t,n,r){let i=e.x,a=e.y,o=t.x,s=t.y,c=n.x,l=n.y,u=r.x,d=r.y,f=i*s-a*o,p=c*d-l*u,m=(i-o)*(l-d)-(a-s)*(c-u);return new b((f*(c-u)-p*(i-o))/m,(f*(l-d)-p*(a-s))/m)}adjustFirstSegment(e,t,n){let r=t.remove();switch(n){case`NORTH`:r.y=0;break;case`SOUTH`:r.y=e.height??0;break;case`WEST`:r.x=0;break;default:r.x=e.width??0}return t.addAt(0,r),t}allEdges(e){let t=[],n=e=>{for(let n of e.edges??[])t.push(n);for(let t of e.children??[])n(t)};return n(e),t}allIncidentEdges(e,t){return this.allEdges(e).filter(n=>{let r=V(String(n.sources?.[0]??``),e),i=V(String(n.targets?.[0]??``),e),a=t.id;return r===a||i===a})}getSourceNode(e,t){return H(e,V(String(t.sources?.[0]??``),e))}getTargetNode(e,t){return H(e,V(String(t.targets?.[0]??``),e))}getSourcePort(e,t){let n=String(t.sources?.[0]??``),r=Es(n,e);if(r!==void 0)return H(e,V(n,e))?.ports?.find(e=>e.id===r)}getTargetPort(e,t){let n=String(t.targets?.[0]??``),r=Es(n,e);if(r!==void 0)return H(e,V(n,e))?.ports?.find(e=>e.id===r)}firstEdgeSection(e){let t=(e.sections??[])[0];if(t!==void 0)return t;let n={startPoint:{x:0,y:0},endPoint:{x:0,y:0},bendPoints:[]};return e.sections=[n],n}createVectorChain(e){let t=new Yo;t.add(new b(e.startPoint.x,e.startPoint.y));for(let n of e.bendPoints??[])t.add(new b(n.x,n.y));return t.add(new b(e.endPoint.x,e.endPoint.y)),t}applyVectorChain(e,t){let n=e.toArray();t.startPoint={x:n[0].x,y:n[0].y},n.length>=2&&(t.endPoint={x:n[n.length-1].x,y:n[n.length-1].y}),t.bendPoints=n.length>2?n.slice(1,-1).map(e=>({x:e.x,y:e.y})):[]}applyOffset(e,t){let n=t.getOffset();if(`sections`in e){let t=e,r=this.firstEdgeSection(t),i=this.createVectorChain(r);i.each(e=>{e.add(n)}),this.applyVectorChain(i,r);let a=t.properties?.[`org.eclipse.elk.junctionPoints`];if(Array.isArray(a))for(let e of a)e.x+=n.x,e.y+=n.y}else{let t=e;t.x=(t.x??0)+n.x,t.y=(t.y??0)+n.y}}};function js(e){let t=e.id.lastIndexOf(`.`);return t===-1?``:e.id.slice(0,t)}var U=class extends Error{constructor(e){super(e),this.name=`IndexOutOfBoundsException`}},Ms=class{grid;wordsPerRow=0;xSize;ySize;constructor(e=0,t=0){this.grid=/* @__PURE__ */ new Uint32Array,this.xSize=0,this.ySize=0,this.reinitialize(e,t)}getWidth(){return this.xSize}getHeight(){return this.ySize}isEmpty(e,t){try{return this.retrieve(e,t)===0}catch{throw new U(`Grid is only of size ${this.xSize}*${this.ySize}. Requested point (${e}, ${t}) is out of bounds.`)}}isBlocked(e,t){try{return this.retrieve(e,t)===1}catch{throw new U(`Grid is only of size ${this.xSize}*${this.ySize}. Requested point (${e}, ${t}) is out of bounds.`)}}isWeaklyBlocked(e,t){try{return this.retrieve(e,t)===2}catch{throw new U(`Grid is only of size ${this.xSize}*${this.ySize}. Requested point (${e}, ${t}) is out of bounds.`)}}inBounds(e,t){return e>=0&&t>=0&&e<this.xSize&&t<this.ySize}reinitialize(e,t){this.wordsPerRow=Math.ceil(e/32),this.grid=new Uint32Array(this.wordsPerRow*t*2),this.xSize=e,this.ySize=t}setEmpty(e,t){this.set(e,t,!1,!1)}setBlocked(e,t){this.set(e,t,!1,!0)}setWeaklyBlocked(e,t){this.set(e,t,!0,!1)}toString(){let e=` `,t=0;for(let n=0;n<this.xSize;n++)e+=t.toString(),t=this.incModTen(t);e+=`
|
|
3
14
|
`,t=0;for(let n=0;n<this.ySize;n++){e+=t.toString(),t=this.incModTen(t);for(let t=0;t<this.xSize;t++){let r=this.retrieve(t,n);e+=r===0?`_`:r===1?`X`:`0`}e+=`
|
|
4
15
|
`}return e.substring(0,e.length-1)}retrieve(e,t){let n=e>>5;if(e<0||t<0||t>=this.ySize||n>=this.wordsPerRow)throw new U(`Grid is only of size ${this.xSize}*${this.ySize}. Requested point (${e}, ${t}) is out of bounds.`);let r=(e&31)<<1,i=(t*this.wordsPerRow+n)*2+(r>>>5),a=this.grid[i]>>>(r&31)&3;return Number(a)}set(e,t,n,r){if(e>=this.xSize)throw new U(`Grid is only of size ${this.xSize}*${this.ySize}. Requested point (${e}, ${t}) is out of bounds.`);let i=e>>5;if(e<0||t<0||t>=this.ySize||i>=this.wordsPerRow)throw new U(`Grid is only of size ${this.xSize}*${this.ySize}. Requested point (${e}, ${t}) is out of bounds.`);let a=(e&31)<<1,o=(t*this.wordsPerRow+i)*2+(a>>>5),s=a&31,c=this.grid[o],l=1<<s;r?c|=l:c&=~l,l<<=1,n?c|=l:c&=~l,this.grid[o]=c}incModTen(e){return e>8?0:e+1}};let Ns=/* @__PURE__ */ function(e){return e.NORTH=`NORTH`,e.EAST=`EAST`,e.SOUTH=`SOUTH`,e.WEST=`WEST`,e}({});(function(e){function t(e){return e===`EAST`||e===`WEST`}e.isHorizontal=t})(Ns||={});var Ps=class extends Ms{xCenter;yCenter;constructor(e=0,t=0){super(e,t),this.xCenter=e-1>>1,this.yCenter=t-1>>1}isEmptyCenterBased(e,t){try{return this.isEmpty(e+this.xCenter,t+this.yCenter)}catch(n){throw new U(`${n instanceof Error?n.message:String(n)} Given center based coordinates were (${e}, ${t}).`)}}isBlockedCenterBased(e,t){try{return this.isBlocked(e+this.xCenter,t+this.yCenter)}catch(n){throw new U(`${n instanceof Error?n.message:String(n)} Given center based coordinates were (${e}, ${t}).`)}}isWeaklyBlockedCenterBased(e,t){try{return this.isWeaklyBlocked(e+this.xCenter,t+this.yCenter)}catch(n){throw new U(`${n instanceof Error?n.message:String(n)} Given center based coordinates were (${e}, ${t}).`)}}inBoundsCenterBased(e,t){let n=e,r=t;return n+=this.xCenter,r+=this.yCenter,this.inBounds(n,r)}intersectsWithCenterBased(e,t,n){for(let r=0;r<e.getWidth();r++){let i=r-e.getCenterX()+t;for(let t=0;t<e.getHeight();t++){let a=t-e.getCenterY()+n;if(this.inBoundsCenterBased(i,a)&&(!e.isEmpty(r,t)&&this.isBlockedCenterBased(i,a)||e.isBlocked(r,t)&&!this.isEmptyCenterBased(i,a)))return!0}}return!1}intersectsWithCenterBasedPoly(e,t,n){if(this.intersectsWithCenterBased(e,t,n))return!0;for(let r of e.getPolyominoExtensions()){let i=!1,a=this.getCenterX()-e.getCenterX()+t,o=a+e.getWidth(),s=this.getCenterY()-e.getCenterY()+n,c=s+e.getHeight();switch(r.getFirst()){case`NORTH`:i=this.weaklyIntersectsArea(a+r.getSecond(),0,a+r.getThird(),s-1);break;case`EAST`:i=this.weaklyIntersectsArea(o,s+r.getSecond(),this.getWidth()-1,s+r.getThird());break;case`SOUTH`:i=this.weaklyIntersectsArea(a+r.getSecond(),c,a+r.getThird(),this.getHeight()-1);break;default:i=this.weaklyIntersectsArea(0,s+r.getSecond(),a-1,s+r.getThird())}if(i)return!0}return!1}addFilledCellsFrom(e,t,n){for(let r=0;r<e.getWidth();r++){let i=r-e.getCenterX()+t;for(let t=0;t<e.getHeight();t++){let a=t-e.getCenterY()+n;e.isBlocked(r,t)?this.isWeaklyBlockedCenterBased(i,a)||this.setBlockedCenterBased(i,a):e.isWeaklyBlocked(r,t)&&(this.isBlockedCenterBased(i,a)||this.setWeaklyBlockedCenterBased(i,a))}}}addFilledCellsFromPoly(e,t,n){this.addFilledCellsFrom(e,t,n),e.setX(this.xCenter-e.getCenterX()+t),e.setY(this.yCenter-e.getCenterY()+n);for(let t of e.getPolyominoExtensions())switch(t.getFirst()){case`NORTH`:this.weaklyBlockArea(e.getX()+t.getSecond(),0,e.getX()+t.getThird(),e.getY()-1);break;case`EAST`:this.weaklyBlockArea(e.getX()+e.getWidth(),e.getY()+t.getSecond(),this.getWidth()-1,e.getY()+t.getThird());break;case`SOUTH`:this.weaklyBlockArea(e.getX()+t.getSecond(),e.getY()+e.getHeight(),e.getX()+t.getThird(),this.getHeight()-1);break;default:this.weaklyBlockArea(0,e.getY()+t.getSecond(),e.getX()-1,e.getY()+t.getThird())}}getFilledBounds(){let e=this.getWidth(),t=this.getHeight(),n=2**53-1,r=-(2**53-1),i=2**53-1,a=-(2**53-1);for(let o=0;o<e;++o)for(let e=0;e<t;++e)this.isBlocked(o,e)&&(n=Math.min(n,o),r=Math.max(r,o),i=Math.min(i,e),a=Math.max(a,e));let o=r-n+1,s=a-i+1;return new ns(n,i,o,s)}weaklyBlockArea(e,t,n,r){for(let i=t;i<=r;i++)for(let t=e;t<=n;t++)this.isBlocked(t,i)||this.setWeaklyBlocked(t,i)}weaklyIntersectsArea(e,t,n,r){for(let i=t;i<=r;i++)for(let t=e;t<=n;t++)if(this.isBlocked(t,i))return!0;return!1}getCenterX(){return this.xCenter}getCenterY(){return this.yCenter}reinitialize(e,t){super.reinitialize(e,t),this.xCenter=e-1>>1,this.yCenter=t-1>>1}setBlockedCenterBased(e,t){try{this.setBlocked(e+this.xCenter,t+this.yCenter)}catch(n){throw new U(`${n instanceof Error?n.message:String(n)} Given center based coordinates were (${e}, ${t}).`)}}setEmptyCenterBased(e,t){try{this.setEmpty(e+this.xCenter,t+this.yCenter)}catch(n){throw new U(`${n instanceof Error?n.message:String(n)} Given center based coordinates were (${e}, ${t}).`)}}setWeaklyBlockedCenterBased(e,t){try{this.setWeaklyBlocked(e+this.xCenter,t+this.yCenter)}catch(n){throw new U(`${n instanceof Error?n.message:String(n)} Given center based coordinates were (${e}, ${t}).`)}}},Fs=class extends Ps{x=0;y=0;polyominoExtensions;constructor(e=0,t=0,n=[]){super(e,t),this.polyominoExtensions=n}getX(){return this.x}getY(){return this.y}setX(e){this.x=e}setY(e){this.y=e}getPolyominoExtensions(){return this.polyominoExtensions}addExtension(e,t,n){this.polyominoExtensions.push(new rs(e,t,n))}},Is=class e extends Fs{representee;pWidth;pHeight;cellSizeX;cellSizeY;constructor(t,n,r){super(),this.cellSizeX=n,this.cellSizeY=r,this.representee=t;let i=t.getDimensionsOfBoundingRectangle();this.pWidth=e.computeLowResDimension(i.x,this.cellSizeX),this.pHeight=e.computeLowResDimension(i.y,this.cellSizeY),this.reinitialize(this.pWidth,this.pHeight),this.fillCells();for(let e of this.representee.getElements())e.getExtensions().length>0&&this.addExtensionsToPoly(e)}getOffset(){let e=this.representee.getDimensionsOfBoundingRectangle().clone();return e.x-=this.pWidth*this.cellSizeX,e.y-=this.pHeight*this.cellSizeY,e.scale(-.5)}getMinCornerOnCanvas(){return this.representee.getMinCorner().clone().sub(this.getOffset())}getCellSizeX(){return this.cellSizeX}getCellSizeY(){return this.cellSizeY}getId(){return this.representee.getId()}setId(e){this.representee.setId(e)}getRepresentee(){return this.representee}static computeLowResDimension(e,t){let n=e/t,r=Math.trunc(n);return n>r&&r++,r}fillCells(){let e=this.representee.getMinCorner(),t=this.getOffset(),n=e.x-t.x,r,i=e.y-t.y;for(let e=0;e<this.pHeight;e++){r=n;for(let t=0;t<this.pWidth;t++)this.representee.intersects(new Jo(r,i,this.cellSizeX,this.cellSizeY))&&this.setBlocked(t,e),r+=this.cellSizeX;i+=this.cellSizeY}}addExtensionsToPoly(e){let t=e.getExtensions(),n=this.representee.getMinCorner(),r=this.getOffset(),i=n.x-r.x,a=n.y-r.y,o=e.getBounds();i=o.x-i;let s=o.y-a;for(let e of t){let t=e.getOffset(),n=i+t.x,r=s+t.y,a=Math.trunc(n/this.cellSizeX),o=Math.trunc(r/this.cellSizeY),c=e.getDirection(),l;switch(c){case`NORTH`:l=`NORTH`;break;case`EAST`:l=`EAST`;break;case`SOUTH`:l=`SOUTH`;break;default:l=`WEST`}if(as.isHorizontal(c)){let t=Math.trunc((r+e.getWidth())/this.cellSizeY);this.addExtension(l,o,t),c===`WEST`?this.weaklyBlockArea(0,o,a,t):this.weaklyBlockArea(a,o,this.pWidth-1,t)}else{let t=Math.trunc((n+e.getWidth())/this.cellSizeX);this.addExtension(l,a,t),c===`NORTH`?this.weaklyBlockArea(a,0,t,o):this.weaklyBlockArea(a,o,t,this.pHeight-1)}}}};let Ls;(function(e){function t(e){let t=e.getWidth(),n=Array(t),r=Array(t),i=e.getHeight(),a=Array(i),o=Array(i);for(let r=0;r<t;r++){let t=0;for(;t<i&&!e.isBlocked(r,t);)t++;n[r]=t}for(let n=0;n<t;n++){let t=i-1;for(;t>=0&&!e.isBlocked(n,t);)t--;r[n]=t}for(let n=0;n<i;n++){let r=0;for(;r<t&&!e.isBlocked(r,n);)r++;a[n]=r}for(let n=0;n<i;n++){let r=t-1;for(;r>=0&&!e.isBlocked(r,n);)r--;o[n]=r}for(let s=0;s<t;s++)for(let t=0;t<i;t++)s<o[t]&&s>a[t]&&t<r[s]&&t>n[s]&&e.setBlocked(s,t)}e.fillPolyomino=t})(Ls||={});var Rs=class{polys=[];grid;lowLevelSort;highLevelSort;traversalStrategy;constructor(e,t,n=!1,r=`BY_SIZE_AND_SHAPE`,i=`NUM_OF_EXTERNAL_SIDES_THAN_NUM_OF_EXTENSIONS_LAST`,a=`QUADRANTS_LINE_BY_LINE`){this.lowLevelSort=r,this.highLevelSort=i,this.traversalStrategy=a;let o=0,s=0;for(let t of e)n&&Ls.fillPolyomino(t),this.polys.push(t),o+=t.getWidth(),s+=t.getHeight();if(this.polys.length>0){let e=this.polys[0];o+=e.getWidth(),s+=e.getHeight()}o*=2,s*=2,t>1?o=Math.ceil(o*t):s=Math.ceil(s/t),this.grid=new Ps(o,s)}getPolyominoes(){return this.polys}getGrid(){return this.grid}},zs=class{normalFun;externalFun;constructor(e,t){this.normalFun=e,this.externalFun=t}apply(e,t){return t.getPolyominoExtensions().length>0?this.externalFun(e,t):this.normalFun(e,t)}},Bs=class{apply(e,t){let n=e.getFirst(),r=e.getSecond(),i=n,a=r,o=Math.max(Math.abs(n),Math.abs(r));return n<=0&&n===r?(i=0,a=r-1):n===-o&&r!==o?(i=r,a=n,r>=0&&i++):(i=-r,a=n),new B(i,a)}},Vs=class{apply(e,t){let n=e.getFirst(),r=e.getSecond();if(n>=0){if(n===r)return new B(-n-1,-n-1);if(n===-r)return new B(-n,r+1)}return Math.abs(n)>Math.abs(r)?n<0?new B(-n,r):new B(-n,r+1):new B(n+1,r)}},Hs=class{apply(e,t){let n=e.getFirst(),r=e.getSecond(),i=n,a=r;return n===0&&r===0?--a:n===-1&&r<=0?(i=0,a-=2):n<=0&&r>0?(--i,--a):n>=0&&r<0?(i+=1,a+=1):n>0&&r>=0?(--i,a+=1):(i+=1,--a),new B(i,a)}},Us=class{apply(e,t){let n=e.getFirst(),r=e.getSecond(),i=Math.max(Math.abs(n),Math.abs(r));return n<i&&r===-i?new B(n+1,r):n===i&&r<i?new B(n,r+1):n>=-i&&r===i?new B(n-1,r):new B(n,r-1)}},Ws=class{lastPoly=null;posX=!0;posY=!0;negX=!0;negY=!0;costFun;constructor(e){this.costFun=e}apply(e,t){if(t!==this.lastPoly){this.lastPoly=t;let e=new Set(t.getPolyominoExtensions().map(e=>e.getFirst()));this.posX=!0,this.posY=!0,this.negX=!0,this.negY=!0;let n=e.has(`NORTH`),r=e.has(`SOUTH`);n&&!r&&(this.posY=!1),!n&&r&&(this.negY=!1),n=e.has(`EAST`);let i=e.has(`WEST`);n&&!i&&(this.negX=!1),!n&&i&&(this.posX=!1)}let n=this.costFun(e,t),r=n.getFirst(),i=n.getSecond(),a=!1;return r<0?this.negX||(a=!0):this.posX||(a=!0),i<0?this.negY||(a=!0):this.posY||(a=!0),a?this.apply(n,t):n}},Gs=class{packPolyominoes(e){let t=e.getPolyominoes(),n=e.getGrid();switch(e.lowLevelSort){case`BY_SIZE`:t.sort(Ks(qs));break;default:t.sort(Ks(Js))}switch(e.highLevelSort){case`CORNER_CASES_THAN_SINGLE_SIDE_LAST`:t.sort(Ys),t.sort(Qs),t.sort($s);break;default:t.sort(Ys),t.sort(Zs)}let r;switch(e.traversalStrategy){case`SPIRAL`:r=(e,t)=>new Us().apply(e,t);break;case`LINE_BY_LINE`:r=(e,t)=>new Vs().apply(e,t);break;case`MANHATTAN`:r=(e,t)=>new Hs().apply(e,t);break;case`JITTER`:r=(e,t)=>new Bs().apply(e,t);break;case`QUADRANTS_MANHATTAN`:r=(e,t)=>new Ws((e,t)=>new Hs().apply(e,t)).apply(e,t);break;case`QUADRANTS_LINE_BY_LINE`:r=(e,t)=>new Ws((e,t)=>new Vs().apply(e,t)).apply(e,t);break;case`COMBINE_LINE_BY_LINE_MANHATTAN`:r=(e,t)=>new zs((e,t)=>new Ws((e,t)=>new Vs().apply(e,t)).apply(e,t),(e,t)=>new Ws((e,t)=>new Hs().apply(e,t)).apply(e,t)).apply(e,t);break;case`COMBINE_JITTER_MANHATTAN`:r=(e,t)=>new zs((e,t)=>new Ws((e,t)=>new Bs().apply(e,t)).apply(e,t),(e,t)=>new Ws((e,t)=>new Hs().apply(e,t)).apply(e,t)).apply(e,t);break;default:r=(e,t)=>new Ws((e,t)=>new Bs().apply(e,t)).apply(e,t)}for(let e of t){let t=0,i=0,a=new B(t,i);for(;n.intersectsWithCenterBasedPoly(e,t,i);)a=r(a,e),t=a.getFirst(),i=a.getSecond();n.addFilledCellsFromPoly(e,t,i)}}};function Ks(e){return(t,n)=>-e(t,n)}function qs(e,t){let n=e.getWidth()+e.getHeight(),r=t.getWidth()+t.getHeight();return n<r?-1:n===r?0:1}function Js(e,t){let n=e.getWidth(),r=e.getHeight();n<r?n*=n:r*=r;let i=n+r;n=t.getWidth(),r=t.getHeight(),n<r?n*=n:r*=r;let a=n+r;return i<a?-1:i===a?0:1}function Ys(e,t){let n=e.getPolyominoExtensions().length,r=t.getPolyominoExtensions().length;return n<r?-1:n===r?0:1}function Xs(e){return new Set(e.getPolyominoExtensions().map(e=>e.getFirst()))}function Zs(e,t){let n=Xs(e).size,r=Xs(t).size;return n<r?-1:n===r?0:1}function Qs(e,t){let n=Xs(e).size,r=Xs(t).size;return n=+(n===1),r=+(r===1),n<r?-1:n===r?0:1}function $s(e,t){let n=Xs(e).size;n=+(n===2),n===1&&[...Xs(e)].filter(e=>e===`EAST`||e===`WEST`).length%2==0&&(n=0);let r=Xs(t).size;return r=+(r===2),r===1&&[...Xs(t)].filter(e=>e===`EAST`||e===`WEST`).length%2==0&&(r=0),n<r?-1:n===r?0:1}var ec=class{gridCellSizeX=0;gridCellSizeY=0;upperBound=100;cmpGraph=null;polys=[];grid=null;aspectRatio=null;fill=!1;compact(e){this.cmpGraph=e,this.polys=[];let t=this.computeCellSize(this.cmpGraph);this.gridCellSizeX=t,this.gridCellSizeY=t,this.fill=Ss(this.cmpGraph.layoutOptions,`org.eclipse.elk.alg.common.compaction.polyomino.fill`),this.aspectRatio=Ts(this.cmpGraph.layoutOptions)??1,this.aspectRatio>1?this.gridCellSizeX*=this.aspectRatio:this.gridCellSizeY/=this.aspectRatio,this.createPolyominoes(),this.packPolyominoes(),this.applyToDCGraph()}computeCellSize(e){let t=0,n=0,r=e.getComponents(),i=r.size;for(let e of r){let r=e.getDimensionsOfBoundingRectangle(),i=r.x,a=r.y;t+=i+a,n+=i*a}let a=Math.sqrt(4*this.upperBound*i*n-4*n+t*t)+t,o=2*(this.upperBound*i-1);return o===0?a:a/o}createPolyominoes(){let e=this.cmpGraph.getComponents();for(let t of e){let e=new Is(t,this.gridCellSizeX,this.gridCellSizeY);this.polys.push(e)}}packPolyominoes(){let e=0;for(let t of this.polys)t.setId(e),e++;let t=Cs(this.cmpGraph.layoutOptions,`org.eclipse.elk.alg.common.compaction.polyomino.lowLevelSort`,`BY_SIZE_AND_SHAPE`),n=Cs(this.cmpGraph.layoutOptions,`org.eclipse.elk.alg.common.compaction.polyomino.highLevelSort`,`NUM_OF_EXTERNAL_SIDES_THAN_NUM_OF_EXTENSIONS_LAST`),r=Cs(this.cmpGraph.layoutOptions,`org.eclipse.elk.alg.common.compaction.polyomino.traversalStrategy`,`QUADRANTS_LINE_BY_LINE`),i=new Rs(this.polys,this.aspectRatio,this.fill,t,n,r);new Gs().packPolyominoes(i),this.polys=i.getPolyominoes(),this.grid=i.getGrid()}applyToDCGraph(){let e=this.grid.getFilledBounds(),t=ws(this.cmpGraph.layoutOptions),n=t.getHorizontal(),r=t.getVertical(),i=e.getThird()*this.gridCellSizeX+n,a=e.getFourth()*this.gridCellSizeY+r;this.cmpGraph.setDimensions(new b(i,a));for(let t of this.polys){let n=new b(t.getX()-e.getFirst(),t.getY()-e.getSecond());n.x*=t.getCellSizeX(),n.y*=t.getCellSizeY(),n.add(t.getOffset());let r=t.getRepresentee().getMinCorner();t.getRepresentee().setOffset(n.sub(r))}}};function tc(e){let t=new As(xs(e,us)),n=t.importGraph(e);switch(Cs(e,ms,`POLYOMINO`)){case`POLYOMINO`:new ec().compact(n);break;default:console.error(`DisCo: no compaction strategy used for connected components.`)}return t.applyLayout(),e}const nc=o.padding.id,rc=o.spacingNodeNode.id,ic=o.spacingEdgeNode.id,ac=o.aspectRatio.id,oc=o.priority.id,sc=o.separateConnectedComponents.id,cc=o.debugMode.id,lc=o.direction.id,uc=o.nodeSizeFixedGraphSize.id,dc=a.mrtree.weighting.id,fc=a.mrtree.searchOrder.id,pc=a.mrtree.positionConstraint.id,mc=a.mrtree.edgeRoutingMode.id,W=a.mrtree.treeLevel.id,hc=a.mrtree.compaction.id,gc=a.mrtree.edgeEndTextureLength.id;let _c=/* @__PURE__ */ function(e){return e.UNDEFINED=`UNDEFINED`,e.UP=`UP`,e.DOWN=`DOWN`,e.LEFT=`LEFT`,e.RIGHT=`RIGHT`,e}({});(function(e){function t(e){return e===`UP`||e===`DOWN`}e.isVertical=t;function n(e){return e===`LEFT`||e===`RIGHT`}e.isHorizontal=n})(_c||={});const vc={[nc]:20,[rc]:20,[ic]:3,[ac]:1.6,[oc]:1,[sc]:!0,[cc]:!1,[lc]:`UNDEFINED`,[dc]:`MODEL_ORDER`,[fc]:`DFS`,[pc]:-1,[mc]:`AVOID_OVERLAP`,[W]:0,[hc]:!1,[gc]:7,[uc]:!1};function yc(e,t){return e.layoutOptions?.[t]??e.properties?.[t]??e.layoutOptions?.[t.replace(/^org\.eclipse\.elk\./,`elk.`)]}function bc(e,t){let n=yc(e,t);if(n==null||n===``)return vc[t];let r=Number(n);return Number.isFinite(r)?r:vc[t]}function xc(e){let t=yc(e,nc);if(typeof t==`number`)return{top:t,left:t,right:t,bottom:t};if(typeof t==`object`&&t){let e=t,n=t=>typeof e[t]==`number`?e[t]:vc[nc];return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}if(typeof t==`string`){let e={};for(let n of t.replace(/^\[|\]$/g,``).split(`,`)){let[t,r]=n.split(`=`).map(e=>e.trim()),i=Number(r);t!==void 0&&Number.isFinite(i)&&(e[t]=i)}let n=t=>e[t]??vc[nc];return{top:n(`top`),left:n(`left`),right:n(`right`),bottom:n(`bottom`)}}return{top:vc[nc],left:vc[nc],right:vc[nc],bottom:vc[nc]}}const Sc=`origin`,Cc=`DESCENDANTS`,G=`ROOT`,wc=`LEFTNEIGHBOR`,Tc=`LEFTSIBLING`,Ec=`RIGHTSIBLING`,Dc=`DUMMY`,Oc=`REMOVABLE_EDGES`,kc=`XCOOR`,Ac=`YCOOR`,jc=`LEVELHEIGHT`,K=`LEVELMIN`,q=`LEVELMAX`,Mc=`GRAPH_XMIN`,Nc=`GRAPH_YMIN`,Pc=`COMPACT_CONSTRAINTS`,Fc=`POSITION`,J=`PRELIM`,Ic=`MODIFIER`,Lc=`boundingBox.upLeft`,Rc=`boundingBox.lowRight`;function Y(e,t,n){let r=e.props[t];return r===void 0?n:r}function X(e,t,n){e.props[t]=n}function Z(e,t,n){let r=e.props[t];if(r==null||r===``)return n;let i=Number(r);return Number.isFinite(i)?i:n}function Q(e,t,n){return Math.trunc(Z(e,t,n))}function $(e,t,n){let r=e.props[t];if(r==null||r===``)return n;if(typeof r==`boolean`)return r;let i=String(r).trim().toLowerCase();return i!==`false`&&i!==`0`}var zc=class{id=0;props={};constructor(e){e!==void 0&&(this.id=e)}},Bc=class extends zc{pos=new b;size=new b;constructor(e){super(e)}getPosition(){return this.pos}getSize(){return this.size}},Vc=class extends Bc{graph;label;outgoingEdges=[];incomingEdges=[];constructor(e,t,n){super(e),this.graph=t,this.label=n}toString(){return this.label===void 0||this.label.length===0?`n_${this.id}`:`n_${this.label}`}getLabel(){return this.label}setLabel(e){this.label=e}getParent(){return this.incomingEdges.length===0?null:this.incomingEdges[0].getSource()}getChildrenCopy(){return this.outgoingEdges.map(e=>e.getTarget())}getChildren(){return this.outgoingEdges.map(e=>e.getTarget())}getOutgoingEdges(){return this.outgoingEdges}getIncomingEdges(){return this.incomingEdges}addChild(e){let t=new Uc(this,e);X(t,Dc,!0),this.graph.getEdges().push(t),this.outgoingEdges.push(t),e.incomingEdges.push(t)}isLeaf(){return this.outgoingEdges.length===0}};let Hc=0;var Uc=class extends zc{labels=[];source;target;bendPoints=[];identityHash=++Hc;constructor(e,t){super(),this.source=e,this.target=t}toString(){return this.source!==void 0&&this.target!==void 0?`${this.source.toString()}->${this.target.toString()}`:`e_${this.identityHash}`}getSource(){return this.source}setSource(e){if(this.source!==e){let t=this.source.getOutgoingEdges().indexOf(this);this.source!==void 0&&t!==-1&&this.source.getOutgoingEdges().splice(t,1),e!==void 0&&!e.getOutgoingEdges().includes(this)&&e.getOutgoingEdges().push(this),this.source=e}}getTarget(){return this.target}setTarget(e){if(this.target!==e){let t=this.target.getIncomingEdges().indexOf(this);this.target!==void 0&&t!==-1&&this.target.getIncomingEdges().splice(t,1),e!==void 0&&!e.getIncomingEdges().includes(this)&&e.getIncomingEdges().push(this),this.target=e}}getLabels(){return this.labels}getBendPoints(){return this.bendPoints}},Wc=class{nodes=[];edges=[];props={};toString(){let e=``;for(let t of this.nodes)e+=`${t.toString()}\n`;for(let t of this.edges)e+=`${t.toString()}\n`;return e}getEdges(){return this.edges}getNodes(){return this.nodes}};function Gc(e){switch(e){case`UP`:return new b(0,-1);case`RIGHT`:return new b(1,0);case`LEFT`:return new b(-1,0);default:return new b(0,1)}}var Kc=class{importGraph(e){let t=new Wc;Object.assign(t.props,e.layoutOptions??{},e.properties??{}),X(t,Sc,e);let n=/* @__PURE__ */ new Map;return this.transformNodes(e,t,n),this.transformEdges(e,t,n),t}transformNodes(e,t,n){let r=0;for(let i of e.children??[]){let e=``;(i.labels?.length??0)>0&&(e=i.labels[0].text??``);let a=new Vc(r++,t,e);Object.assign(a.props,i.layoutOptions??{},i.properties??{}),X(a,Sc,i),a.getPosition().y=(i.y??0)+(i.height??0)/2,a.getSize().x=Math.max(i.width??0,1),a.getPosition().x=(i.x??0)+(i.width??0)/2,a.getSize().y=Math.max(i.height??0,1),t.getNodes().push(a),n.set(i,a)}}transformEdges(e,t,n){let r=this.buildNodeIndex(e);for(let i of e.edges??[])if(!this.isHierarchical(i)&&!this.isSelfloop(i)){let e=this.findNode(r,i.sources?.[0]??``),a=this.findNode(r,i.targets?.[0]??``),o=e===void 0?void 0:n.get(e),s=a===void 0?void 0:n.get(a);if(o!==void 0&&s!==void 0){let e=new Uc(o,s);X(e,Sc,i),Object.assign(e.props,i.layoutOptions??{},i.properties??{}),o.getOutgoingEdges().push(e),s.getIncomingEdges().push(e),t.getEdges().push(e)}}}isHierarchical(e){return(e.sources??[]).length!==1||(e.targets??[]).length!==1}isSelfloop(e){return String(e.sources?.[0]??``)===String(e.targets?.[0]??``)}buildNodeIndex(e){let t=/* @__PURE__ */ new Map;for(let n of e.children??[]){t.has(n.id)||t.set(n.id,n);for(let e of n.ports??[]){let r=`${n.id}.${e.id}`;t.has(r)||t.set(r,n)}}return t}findNode(e,t){return e.get(t)}applyLayout(e){let t=Y(e,Sc,void 0);if(t===void 0)return;let n=2147483647,r=2147483647,i=-2147483648,a=-2147483648;for(let t of e.getNodes()){let e=t.getPosition(),o=t.getSize();n=Math.min(n,e.x-o.x/2),r=Math.min(r,e.y-o.y/2),i=Math.max(i,e.x+o.x/2),a=Math.max(a,e.y+o.y/2)}let o=xc(t);for(let t of e.getNodes()){let e=Y(t,Sc,void 0);if(e!==void 0&&typeof e==`object`&&`id`in e){let n=e;n.x=t.getPosition().x,n.y=t.getPosition().y}}for(let t of e.getEdges()){let e=Y(t,Sc,void 0);if(e!==void 0){let n=t.getBendPoints(),r=this.firstEdgeSection(e,!0,!0);this.applyVectorChain(n,r)}}let s=i-n+o.left+o.right,c=a-r+o.top+o.bottom;bc(t,uc)||this.resizeNode(t,s,c,!1,!1),t.layoutOptions??={},t.layoutOptions[`org.eclipse.elk.childArea.width`]=String(s-o.left-o.right),t.layoutOptions[`org.eclipse.elk.childArea.height`]=String(c-o.top-o.bottom)}firstEdgeSection(e,t,n){if(e.sections??=[],e.sections.length===0)return e.sections.push({startPoint:{x:0,y:0},endPoint:{x:0,y:0}}),e.sections[0];let r=e.sections[0];if(t&&(r.bendPoints=[],r.startPoint={x:0,y:0},r.endPoint={x:0,y:0}),n)for(;e.sections.length>1;)e.sections.pop();return r}applyVectorChain(e,t){if(e.length<2)throw Error(`The vector chain must contain at least a source and a target point.`);let n=e[0];t.startPoint={x:n.x,y:n.y},t.bendPoints??=[];let r=t.bendPoints,i=r.length,a=e.slice(1,e.length-1);for(let e=0;e<a.length;e++){let t=a[e];e<i?(r[e].x=t.x,r[e].y=t.y):r.push({x:t.x,y:t.y})}for(;r.length>a.length;)r.pop();let o=e[e.length-1];t.endPoint={x:o.x,y:o.y}}resizeNode(e,t,n,r,i){let a=this.effectiveMinSizeConstraintFor(e),o=Math.max(a.x,t),s=Math.max(a.y,n);e.width=o,e.height=s}effectiveMinSizeConstraintFor(e){let t=e.layoutOptions?.[`org.eclipse.elk.nodeSize.minimum`]??e.properties?.[`org.eclipse.elk.nodeSize.minimum`];if(t==null)return{x:0,y:0};if(typeof t==`number`)return{x:t,y:t};if(Array.isArray(t))return{x:Number(t[0])||0,y:Number(t[1])||0};let n=String(t).replace(/^\[|\]$/g,``),r=n.match(/^(-?[\d.]+)[, ]+(-?[\d.]+)$/);if(r)return{x:Number(r[1])||0,y:Number(r[2])||0};let i=Number(n);return Number.isFinite(i)?{x:i,y:i}:{x:0,y:0}}};function qc(e){X(e,Mc,Math.min(...e.getNodes().map(e=>e.getPosition().x))),X(e,Nc,Math.min(...e.getNodes().map(e=>e.getPosition().y))),X(e,`GRAPH_XMAX`,Math.max(...e.getNodes().map(e=>e.getPosition().x+e.getSize().x))),X(e,`GRAPH_YMAX`,Math.max(...e.getNodes().map(e=>e.getPosition().y+e.getSize().y)))}var Jc=class{incidence=[];visited=[];initialize(e){let t=e.getNodes().length;this.incidence=Array.from({length:t},()=>[]),this.visited=Array(t).fill(!1);for(let t of e.getNodes())this.incidence[t.id]=[];for(let t of e.getEdges())this.incidence[t.getSource().id].push(t),this.incidence[t.getTarget().id].push(t)}split(e){if(Y(e,sc,vc[sc])){this.initialize(e);let t=[];for(let n of e.getNodes()){let r=this.dfs(n,null);r!==null&&(Object.assign(r.props,e.props),t.push(r))}if(this.incidence=[],this.visited=[],t.length>1)for(let e of t){let t=0;for(let n of e.getNodes())n.id=t++}return t}return[e]}dfs(e,t){if(!this.visited[e.id]){this.visited[e.id]=!0;let n=t;n===null&&(n=new Wc),n.getNodes().push(e);for(let t of this.incidence[e.id])t.getSource()!==e&&this.dfs(t.getSource(),n),t.getTarget()!==e&&this.dfs(t.getTarget(),n),n.getEdges().push(t);return n}return null}pack(e){if(e.length===1)return this.applyPaddingAndNormalizePositions(e[0]),e[0];if(e.length<=0)return new Wc;for(let t of e){let e=0,n=2147483647,r=2147483647,i=-2147483648,a=-2147483648;for(let o of t.getNodes())e+=Y(o,oc,1),n=Math.min(n,o.getPosition().x),r=Math.min(r,o.getPosition().y),i=Math.max(i,o.getPosition().x+o.getSize().x),a=Math.max(a,o.getPosition().y+o.getSize().y);X(t,oc,e),X(t,Lc,new b(n,r)),X(t,Rc,new b(i,a))}e.sort((e,t)=>{let n=Y(t,oc,0)-Y(e,oc,0);if(n===0){let n=Y(t,Rc,new b).clone();n.sub(Y(t,Lc,new b));let r=Y(e,Rc,new b).clone();return r.sub(Y(e,Lc,new b)),n.x*n.y-r.x*r.y}return n});let t=new Wc;Object.assign(t.props,e[0].props);let n=0,r=0;for(let t of e){let e=Y(t,Rc,new b).clone();e.sub(Y(t,Lc,new b)),n=Math.max(n,e.x),r+=e.x*e.y}n=Math.max(n,Math.sqrt(r)*Y(t,ac,1.6));let i=Y(t,rc,20),a=0,o=0,s=0,c=i;for(let r of e){let e=Y(r,Rc,new b).clone();e.sub(Y(r,Lc,new b)),a+e.x>n&&(a=0,o+=s+i,s=0),this.moveGraph(t,r,a,o),c=Math.max(c,a+e.x),s=Math.max(s,e.y),a+=e.x+i}for(let[n,r]of Object.entries(e[0].props))X(t,n,r);return qc(t),this.applyPaddingAndNormalizePositions(t),t}applyPaddingAndNormalizePositions(e){let t=xc(e);X(e,Lc,new b(0,0)),this.moveGraph(new Wc,e,t.left-Y(e,Mc,0),t.top-Y(e,Nc,0))}moveGraph(e,t,n,r){let i=new b(n,r);i.sub(Y(t,Lc,new b));for(let n of t.getNodes())n.getPosition().add(i),e.getNodes().push(n);let a=/* @__PURE__ */ new Set;for(let n of t.getEdges())if(!a.has(n)){a.add(n);for(let e of n.getBendPoints())e.add(i);e.getEdges().push(n)}}};function Yc(e){let t=Array(e.getNodes().length).fill(0),n=[],r=0;for(let t of e.getNodes())t.id=r++;let i=e.props[fc];for(let r of e.getNodes())t[r.id]===0&&(i===`BFS`?Zc(r,t,n):Xc(r,t,n),t[r.id]=2);for(let e of n){let t=e.getSource().getOutgoingEdges().indexOf(e);t!==-1&&e.getSource().getOutgoingEdges().splice(t,1);let n=e.getTarget().getIncomingEdges().indexOf(e);n!==-1&&e.getTarget().getIncomingEdges().splice(n,1)}X(e,Oc,n)}function Xc(e,t,n){t[e.id]=1;for(let r of e.getOutgoingEdges()){let e=r.getTarget();t[e.id]===1?n.push(r):t[e.id]===2?t[e.id]=1:Xc(e,t,n)}}function Zc(e,t,n){let r=[e];do{let e=r.shift();t[e.id]=1;for(let i of e.getOutgoingEdges()){let e=i.getTarget();t[e.id]===1?n.push(i):t[e.id]===2?t[e.id]=1:r.push(e)}}while(r.length>0)}function Qc(e){let t=e.getNodes().find(e=>$(e,G,!1));if(t===void 0)return;let n=e.props[dc];n===`FAN`||n===`DESCENDANTS`?$c([t],n):n===`CONSTRAINT`&&el([t])}function $c(e,t){let n=t===`DESCENDANTS`?Cc:`FAN`,r=0,i=[...e];i.sort((e,t)=>Q(e,n,0)-Q(t,n,0));let a=i.length,o=!0;for(let e=i.length-1;e>=0&&o;e--){let t=i[e];Q(t,n,0)===0?a--:o=!1}let s=i.slice(0,a),c=i.slice(a);if(s.length===0)for(let e of c)X(e,Fc,r++);else for(let e of s){X(e,Fc,r++);let i=e.getChildrenCopy();$c(i,t),i.sort((e,t)=>Q(t,Fc,0)-Q(e,Fc,0));let a=[];for(let t of i)for(let n of e.getOutgoingEdges())n.getTarget()===t&&a.push(n);e.getOutgoingEdges().splice(0),e.getOutgoingEdges().push(...a);let s=e.getOutgoingEdges().length;o=!0;for(let e=c.length-1;0<s&&o&&e>=0;e--){let t=c[e];Q(t,n,0)===0?(X(t,Fc,r++),s--,c.splice(e,1)):o=!1}}}function el(e){let t=e.filter(e=>Q(e,pc,-1)<0),n=e.filter(t=>Q(t,pc,-1)<e.length&&Q(t,pc,-1)>=0),r=e.filter(t=>Q(t,pc,-1)>=e.length),i=Array(e.length).fill(void 0);for(let e=0;e<n.length;e++){let t=n[e],r=Q(t,pc,-1);r>=0&&r<n.length&&i[r]===void 0&&(i[r]=t,n.splice(e,1),e--)}for(let e=0;e<n.length;e++){let t=n[e],r=Q(t,pc,-1);for(let a=0;;a++){let o=r+a;if(o<i.length&&o>=0&&i[o]===void 0||(o=r-a,o<i.length&&o>=0&&i[o]===void 0)){i[o]=t,n.splice(e,1),e--;break}}}r.sort((e,t)=>-tl(Q(e,pc,-1),Q(t,pc,-1)));for(let e=i.length-1;e>=0;e--)i[e]===void 0&&r.length>0&&(i[e]=r.shift());for(let e=0;e<i.length;e++)i[e]===void 0&&t.length>0&&(i[e]=t.shift());for(let e=0;e<i.length;e++)X(i[e],Fc,e);let a=e.filter(e=>Q(e,`FAN`,0)!==0);for(let e of a){let t=e.getChildrenCopy();el(t),t.sort((e,t)=>Q(e,Fc,0)-Q(t,Fc,0));let n=[];for(let r of t)for(let t of e.getOutgoingEdges())t.getTarget()===r&&n.push(t);e.getOutgoingEdges().splice(0),e.getOutgoingEdges().push(...n)}}function tl(e,t){return e<t?-1:+(e>t)}function nl(e){return e.getNodes().find(e=>$(e,G,!1))}function rl(e,t,n){let r=[],i=/* @__PURE__ */ new Set;for(let t of n?e.getIncomingEdges():e.getOutgoingEdges())i.has(t)||(i.add(t),r.push(t));let a=Y(t,Oc,void 0);if(a!==void 0)for(let t of a){let a=n?t.getTarget():t.getSource();(a===e||a.id===e.id)&&(i.has(t)||(i.add(t),r.push(t)))}return r}function il(e,t){let n=[];for(let r of rl(e,t,!0))r.getTarget().id===e.id&&Q(r.getSource(),W,0)!==Q(r.getTarget(),W,0)&&n.push(r);return n.sort((e,t)=>e.getSource().getPosition().x-t.getSource().getPosition().x),n}function al(e,t){let n=[];for(let r of rl(e,t,!1))r.getSource().id===e.id&&r.getSource().getLabel()!==`SUPER_ROOT`&&Q(r.getSource(),W,0)!==Q(r.getTarget(),W,0)&&n.push(r);return n.sort((e,t)=>e.getTarget().getPosition().x-t.getTarget().getPosition().x),n}function ol(e){return e.getBendPoints().length===0?new b(e.getTarget().getPosition().x,e.getTarget().getPosition().y):e.getBendPoints()[0]}function sl(e){return e.getBendPoints().length===0?new b(e.getSource().getPosition().x,e.getSource().getPosition().y):e.getBendPoints()[e.getBendPoints().length-1]}function cl(e){let t=e.props[lc];if(t==null)return`UNDEFINED`;let n=String(t).toUpperCase();return n===`UP`?`UP`:n===`LEFT`?`LEFT`:n===`RIGHT`?`RIGHT`:n===`DOWN`?`DOWN`:`UNDEFINED`}function ll(e){return Gc(e)}function ul(e,t,n){let r=n.x/2,i=n.y/2,a=Math.abs(t.x-e.x),o=Math.abs(t.y-e.y),s=1,c=1;a>r&&(s=r/a),o>i&&(c=i/o);let l=Math.min(s,c);e.x+=l*(t.x-e.x),e.y+=l*(t.y-e.y)}function dl(e,t){let n=ll(cl(t));return n.x*(e.getTarget().getPosition().x-e.getSource().getPosition().x)+n.y*(e.getTarget().getPosition().y-e.getSource().getPosition().y)<=0}function fl(e,t){return`${e}#${t}`}function pl(e,t){let n=ll(cl(t));if(e.getIncomingEdges().length===0)return null;let r=e.getIncomingEdges().map(e=>e.getSource()),i=t.getNodes().filter(e=>r.includes(e));if(i.length===0)return null;let a=e=>{let t=new b(e.getPosition().x+e.getSize().x/2,e.getPosition().y+e.getSize().y/2);return t.x*n.x+t.y*n.y},o=Math.max(...i.map(a));return i.find(e=>a(e)===o)??null}function ml(e,t=-1){let n=[...e],r=t;if(0<n.length){if(1<r){r--;let e=[];for(let t of n)e=e.concat(t.getChildren());return ml(e,r)}if(r<0){let e=[];for(let t of n)e=e.concat(t.getChildren());if(0<e.length)return ml(e,r)}}return n[0]??null}function hl(e){let t=Z(e,rc,20),n=xl(e.props[lc]);n===`UNDEFINED`&&(n=`DOWN`,e.props[lc]=n);let r=[];for(let t of e.getNodes())$(t,`ROOT`,!1)&&r.push(t);let i=r[0];gl(i,0,t,n),yl(i,-(Z(i,jc,0)/2),0,t)}function gl(e,t,n,r){X(e,Ic,0);let i=bl(e,Tc);if(e.isLeaf()){if(i!==null){let t=Z(i,J,0)+n+vl(i,e,r);X(e,J,t)}else X(e,J,0)}else{for(let i of e.getChildren())gl(i,t+1,n,r);let a=e.getChildren(),o=a[0],s=a[a.length-1],c=(Z(s,J,0)+Z(o,J,0))/2;if(i!==null){let a=Z(i,J,0)+n+vl(i,e,r);X(e,J,a),X(e,Ic,Z(e,J,0)-c),_l(e,t,n,r)}else X(e,J,c)}}function _l(e,t,n,r){let i=e.getChildren(),a=i.length>0?i[0]:null,o=a===null?null:bl(a,wc),s=1;for(;a!==null&&o!==null;){let t=0,i=0,c=a,l=o;for(let e=0;e<s;e++){if(c=c.getParent(),l=l.getParent(),c===null||l===null)return;i+=Z(c,Ic,0),t+=Z(l,Ic,0)}let u=Z(o,J,0),d=Z(a,J,0),f=vl(a,o,r),p=u+t+n+f-d-i;if(0<p){let t=e,n=0;for(;t!==null&&t!==l;)n++,t=bl(t,Tc);if(t!==null){let r=p/n;for(t=e;t!==l&&t!==null;){let e=Z(t,J,0)+p;X(t,J,e);let n=Z(t,Ic,0)+p;X(t,Ic,n),p-=r,t=bl(t,Tc)}}else return}s++,a=a.isLeaf()?ml(e.getChildren(),s):a.getChildren()[0]??null,o=a===null?null:bl(a,wc)}}function vl(e,t,n){let r=0;return e!==null&&(r+=n===`UP`||n===`DOWN`?e.getSize().x/2:e.getSize().y/2),t!==null&&(r+=n===`UP`||n===`DOWN`?t.getSize().x/2:t.getSize().y/2),r}function yl(e,t,n,r){if(e!==null){let i=Z(e,J,0)+n,a=t+Z(e,jc,0)/2;X(e,kc,Math.round(i)),X(e,Ac,Math.round(a)),e.isLeaf()||yl(e.getChildren()[0]??null,t+Z(e,jc,0)+r,n+Z(e,Ic,0),r);let o=bl(e,Ec);o!==null&&yl(o,t,n,r)}}function bl(e,t){return e.props[t]??null}function xl(e){if(e==null)return`UNDEFINED`;let t=String(e).toUpperCase();return t===`UP`?`UP`:t===`LEFT`?`LEFT`:t===`RIGHT`?`RIGHT`:t===`DOWN`?`DOWN`:`UNDEFINED`}var Sl=class{neighborOne;neighborTwo;bendPoints;graph;d;nodeBendpointPadding;onFirstNodeSide=!1;onLastNodeSide=!1;getNeighborOne(){return this.neighborOne}getNeighborTwo(){return this.neighborTwo}isOnFirstNodeSide(){return this.onFirstNodeSide}isOnLastNodeSide(){return this.onLastNodeSide}constructor(e,t,n,r){this.neighborOne=e,this.neighborTwo=t,this.graph=r,this.bendPoints=[n];let i=r.props[lc];this.d=i===`UP`?`UP`:i===`LEFT`?`LEFT`:i===`RIGHT`?`RIGHT`:`DOWN`,this.nodeBendpointPadding=Z(r,ic,3),this.updateBendPoints()}addBendPoints(e){this.bendPoints.push(e),this.d===`LEFT`||this.d===`RIGHT`?this.bendPoints.sort((e,t)=>e.third.getTarget().getPosition().y-t.third.getTarget().getPosition().y):this.bendPoints.sort((e,t)=>e.third.getTarget().getPosition().x-t.third.getTarget().getPosition().x),this.updateBendPoints()}updateBendPoints(){let e=0,t=this.bendPoints.length;for(let n of this.bendPoints){let r,i,a,o=(e+1)/(t+1);if(this.neighborOne===null&&this.neighborTwo===null)return;this.neighborOne!==null&&this.neighborTwo===null?(this.onLastNodeSide=!0,this.d===`LEFT`?(a=this.neighborOne.getPosition().y+this.neighborOne.getSize().y+this.nodeBendpointPadding*(e+1),r=new b(Z(this.neighborOne,q,0)+this.nodeBendpointPadding,a),i=new b(Z(this.neighborOne,K,0)-this.nodeBendpointPadding,a)):this.d===`RIGHT`?(a=this.neighborOne.getPosition().y+this.neighborOne.getSize().y+this.nodeBendpointPadding*(e+1),r=new b(Z(this.neighborOne,K,0)-this.nodeBendpointPadding,a),i=new b(Z(this.neighborOne,q,0)+this.nodeBendpointPadding,a)):this.d===`UP`?(a=this.neighborOne.getPosition().x+this.neighborOne.getSize().x+this.nodeBendpointPadding*(e+1),r=new b(a,Z(this.neighborOne,q,0)+this.nodeBendpointPadding),i=new b(a,Z(this.neighborOne,K,0)-this.nodeBendpointPadding)):(a=this.neighborOne.getPosition().x+this.neighborOne.getSize().x+this.nodeBendpointPadding*(e+1),r=new b(a,Z(this.neighborOne,K,0)-this.nodeBendpointPadding),i=new b(a,Z(this.neighborOne,q,0)+this.nodeBendpointPadding))):this.neighborOne!==null&&this.neighborTwo!==null?this.d===`LEFT`?(a=this.neighborTwo.getPosition().y*o+(this.neighborOne.getPosition().y+this.neighborOne.getSize().y)*(1-o),r=new b(Z(this.neighborOne,q,0)+this.nodeBendpointPadding,a),i=new b(Z(this.neighborOne,K,0)-this.nodeBendpointPadding,a)):this.d===`RIGHT`?(a=this.neighborTwo.getPosition().y*o+(this.neighborOne.getPosition().y+this.neighborOne.getSize().y)*(1-o),r=new b(Z(this.neighborOne,K,0)-this.nodeBendpointPadding,a),i=new b(Z(this.neighborOne,q,0)+this.nodeBendpointPadding,a)):this.d===`UP`?(a=this.neighborTwo.getPosition().x*o+(this.neighborOne.getPosition().x+this.neighborOne.getSize().x)*(1-o),r=new b(a,Z(this.neighborOne,q,0)+this.nodeBendpointPadding),i=new b(a,Z(this.neighborOne,K,0)-this.nodeBendpointPadding)):(a=this.neighborTwo.getPosition().x*o+(this.neighborOne.getPosition().x+this.neighborOne.getSize().x)*(1-o),r=new b(a,Z(this.neighborOne,K,0)-this.nodeBendpointPadding),i=new b(a,Z(this.neighborOne,q,0)+this.nodeBendpointPadding)):(this.onFirstNodeSide=!0,this.d===`LEFT`?(a=this.neighborTwo.getPosition().y-this.nodeBendpointPadding*(e+1),r=new b(Z(this.neighborTwo,q,0)+this.nodeBendpointPadding,a),i=new b(Z(this.neighborTwo,K,0)-this.nodeBendpointPadding,a)):this.d===`RIGHT`?(a=this.neighborTwo.getPosition().y-this.nodeBendpointPadding*(e+1),r=new b(Z(this.neighborTwo,K,0)-this.nodeBendpointPadding,a),i=new b(Z(this.neighborTwo,q,0)+this.nodeBendpointPadding,a)):this.d===`UP`?(a=this.neighborTwo.getPosition().x-this.nodeBendpointPadding*(e+1),r=new b(a,Z(this.neighborTwo,q,0)+this.nodeBendpointPadding),i=new b(a,Z(this.neighborTwo,K,0)-this.nodeBendpointPadding)):(a=this.neighborTwo.getPosition().x-this.nodeBendpointPadding*(e+1),r=new b(a,Z(this.neighborTwo,K,0)-this.nodeBendpointPadding),i=new b(a,Z(this.neighborTwo,q,0)+this.nodeBendpointPadding))),n.first.x=r.x,n.first.y=r.y,n.second.x=i.x,n.second.y=i.y,e++}}};function Cl(e){let t=e.props[mc];if(t===`MIDDLE_TO_MIDDLE`)for(let t of e.getEdges())wl(t);else if(t===`AVOID_OVERLAP`||t==null){Tl(e);for(let t of e.getEdges())t.getBendPoints().length<2&&wl(t)}}function wl(e){let t=e.getBendPoints(),n=e.getSource(),r=e.getTarget(),i=new b(n.getPosition().x+n.getSize().x/2,n.getPosition().y+n.getSize().y/2),a=new b(r.getPosition().x+r.getSize().x/2,r.getPosition().y+r.getSize().y/2);t.unshift(i),t.push(a),ul(i,t[1],e.getSource().getSize()),ul(a,t[t.length-2],e.getTarget().getSize())}function Tl(e){let t=nl(e),n=Z(e,ic,3),r=Z(e,gc,7),i=Al(e.props[lc]);Ol(e,i,n),El(e,t,i,n,r),kl(e,i,n,r)}function El(e,t,n,r,i){let a=0,o=0,s=/* @__PURE__ */ new Map,c=Math.max(...e.getNodes().map(e=>Q(e,W,0)))+1,l=Array(c).fill(0),u=Array(c).fill(0),d=[...new Set(e.getEdges())];for(let t of d){let c=Q(t.getSource(),W,0),d=Q(t.getTarget(),W,0),f=d-c;if(f>1)for(let r=c+1;r<d;r++){let i=e.getNodes().filter(e=>Q(e,W,0)===r),l=0;if(n===`LEFT`||n===`RIGHT`){for(i.sort((e,t)=>e.getPosition().y-t.getPosition().y),l=0;l<i.length;l++){let e=(r-c)/(d-c);if(i[l].getPosition().y>t.getSource().getPosition().y*(1-e)+t.getTarget().getPosition().y*e)break}if(i.length>0){let e=t.getBendPoints().length===0?t.getSource().getPosition().clone():t.getBendPoints()[t.getBendPoints().length-1],n=i[i.length-1],r=n.getPosition().clone().add(n.getSize()),a=i[0],o=a.getPosition().clone().add(a.getSize());if(l>=i.length-1&&e.y>r.y&&t.getTarget().getPosition().y>r.y||l<=0&&e.y<o.x&&t.getTarget().getPosition().y<o.y)continue}}else{for(i.sort((e,t)=>e.getPosition().x-t.getPosition().x),l=0;l<i.length;l++){let e=(r-c)/(d-c);if(i[l].getPosition().x>t.getSource().getPosition().x*(1-e)+t.getTarget().getPosition().x*e)break}if(i.length>0){let e=t.getBendPoints().length===0?t.getSource().getPosition().clone():t.getBendPoints()[t.getBendPoints().length-1],n=i[i.length-1],r=n.getPosition().clone().add(n.getSize()),a=i[0],o=a.getPosition().clone().add(a.getSize());if(l>=i.length-1&&e.x>r.x&&t.getTarget().getPosition().x>r.x||l<=0&&e.x<o.x&&t.getTarget().getPosition().x<o.x)continue}}let u=new b,f=new b;t.getBendPoints().push(u),t.getBendPoints().push(f);let p,m={first:u,second:f,third:t},h=fl(r,l);s.has(h)?(p=s.get(h),p.addBendPoints(m)):(p=new Sl(l===0?null:i[l-1],l===i.length?null:i[l],m,e),s.set(h,p)),n!==`LEFT`&&n!==`RIGHT`?(p.isOnFirstNodeSide()&&p.getNeighborTwo().getPosition().x<=Z(e,`GRAPH_XMIN`,0)&&a++,p.isOnLastNodeSide()&&p.getNeighborOne().getPosition().x+p.getNeighborOne().getSize().x>=Z(e,`GRAPH_XMAX`,0)&&o++):(p.isOnFirstNodeSide()&&p.getNeighborTwo().getPosition().y<=Z(e,`GRAPH_YMIN`,0)&&a++,p.isOnLastNodeSide()&&p.getNeighborOne().getPosition().y+p.getNeighborOne().getSize().y>=Z(e,`GRAPH_YMAX`,0)&&o++)}else if(f===0)wl(t);else if(f<0){l[c]++,u[d]++;let s=Dl(t,n,e,a,o,r,i,u[d],l[c]);a=s[0],o=s[1]}}}function Dl(e,t,n,r,i,a,o,s,c){let l=r,u=i,d=e.getSource(),f=e.getTarget(),p=0;if(t===`LEFT`||t===`RIGHT`){let e=n.getNodes().map(e=>e.getPosition().y+e.getSize().y/2).reduce((e,t)=>e+t,0)/n.getNodes().length;d.getPosition().y+d.getSize().y/2>e?(u++,p=Math.max(...n.getNodes().map(e=>e.getPosition().y+e.getSize().y+a*u))):(l++,p=Math.min(...n.getNodes().map(e=>e.getPosition().y-a*l)))}else{let e=n.getNodes().map(e=>e.getPosition().x+e.getSize().x/2).reduce((e,t)=>e+t,0)/n.getNodes().length;d.getPosition().x+d.getSize().x/2>e?(u++,p=Math.max(...n.getNodes().map(e=>e.getPosition().x+e.getSize().x+a*u))):(l++,p=Math.min(...n.getNodes().map(e=>e.getPosition().x-a*l)))}return t===`LEFT`?(e.getBendPoints().push(new b(Z(d,K,0)-a,p)),e.getBendPoints().push(new b(f.getPosition().x+f.getSize().x+a+o,p)),e.getBendPoints().push(new b(f.getPosition().x+f.getSize().x+a+o,f.getPosition().y+f.getSize().y/2)),e.getBendPoints().push(new b(f.getPosition().x+f.getSize().x,f.getPosition().y+f.getSize().y/2))):t===`RIGHT`?(e.getBendPoints().push(new b(Z(d,q,0)+a,d.getPosition().y+d.getSize().y/2)),e.getBendPoints().push(new b(d.getPosition().x+d.getSize().x+a,p)),e.getBendPoints().push(new b(f.getPosition().x-a-o,p)),e.getBendPoints().push(new b(f.getPosition().x-a-o,f.getPosition().y+f.getSize().y/2)),e.getBendPoints().push(new b(f.getPosition().x,f.getPosition().y+f.getSize().y/2))):t===`UP`?(e.getBendPoints().push(new b(p,Z(d,K,0)-a)),e.getBendPoints().push(new b(p,f.getPosition().y+f.getSize().y+a+o)),e.getBendPoints().push(new b(f.getPosition().x+f.getSize().x/2,f.getPosition().y+f.getSize().y+a+o)),e.getBendPoints().push(new b(f.getPosition().x+f.getSize().x/2,f.getPosition().y+f.getSize().y+a))):(e.getBendPoints().length>0&&(e.getBendPoints()[e.getBendPoints().length-1].y=Z(d,q,0)+a*c),e.getBendPoints().push(new b(p,Z(d,q,0)+a*c)),e.getBendPoints().push(new b(p,f.getPosition().y-a*s-o))),[l,u]}function Ol(e,t,n){for(let r of e.getNodes()){if(r.getLabel()===`SUPER_ROOT`)continue;let i=al(r,e);t===`LEFT`||t===`RIGHT`?i.sort((e,t)=>ol(e).y-ol(t).y):i.sort((e,t)=>ol(e).x-ol(t).x);let a=i.length;for(let o=0;o<a;o++){if($(r,`COMPACT_LEVEL_ASCENSION`,!1)&&!dl(i[o],e))continue;let s=a===1?.5:(o+1)/(a+1);if(t===`LEFT`){let e=Z(r,K,0),t=r.getPosition().y+r.getSize().y*s;i[o].getBendPoints().unshift(new b(Math.min(e,r.getPosition().x-n),t)),i[o].getBendPoints().unshift(new b(r.getPosition().x,t))}else if(t===`RIGHT`){let e=Z(r,q,0)+n,t=r.getPosition().y+r.getSize().y*s;i[o].getBendPoints().unshift(new b(e,t)),i[o].getBendPoints().unshift(new b(r.getPosition().x+r.getSize().x,t))}else if(t===`UP`){let e=Z(r,K,0),t=r.getPosition().x+r.getSize().x*s;i[o].getBendPoints().unshift(new b(t,Math.min(r.getPosition().y-n,e))),i[o].getBendPoints().unshift(new b(t,r.getPosition().y))}else{let e=Z(r,q,0)+n,t=r.getPosition().x+r.getSize().x*s;i[o].getBendPoints().unshift(new b(t,e)),i[o].getBendPoints().unshift(new b(t,r.getPosition().y+r.getSize().y))}}}}function kl(e,t,n,r){let i=5.3;for(let a of e.getNodes()){if(a.getLabel()===`SUPER_ROOT`)continue;let o=il(a,e);t===`LEFT`||t===`RIGHT`?o.sort((e,t)=>sl(e).y-sl(t).y):o.sort((e,t)=>sl(e).x-sl(t).x);let s=o.length;for(let c=0;c<s;c++){let l=s===1?.5:(1+c)/(s+1);if(t===`LEFT`){let e=Z(a,q,0);if(a.getPosition().x+a.getSize().x+r<e)o[c].getBendPoints().push(new b(e+n,a.getPosition().y+a.getSize().y*l));else if(o[c].getBendPoints().length>0){let e=o[c].getBendPoints()[o[c].getBendPoints().length-1].x,t=a.getPosition().x+a.getSize().x/2,n=o[c].getBendPoints()[o[c].getBendPoints().length-1].y,s=a.getPosition().y+a.getSize().y/2;r>0&&Math.abs(n-s)/(Math.abs(e-t)/40)>50&&(s>n?o[c].getBendPoints().push(new b(a.getPosition().x+a.getSize().x+r/i,a.getPosition().y+a.getSize().y*l-r/2)):o[c].getBendPoints().push(new b(a.getPosition().x+a.getSize().x+r/i,a.getPosition().y+a.getSize().y*l+r/2)))}o[c].getBendPoints().push(new b(a.getPosition().x+a.getSize().x,a.getPosition().y+a.getSize().y*l))}else if(t===`RIGHT`){let e=Z(a,K,0);if(a.getPosition().x-r>e)o[c].getBendPoints().push(new b(e-n,a.getPosition().y+a.getSize().y*l));else if(o[c].getBendPoints().length>0){let e=o[c].getBendPoints()[o[c].getBendPoints().length-1].x,t=a.getPosition().x+a.getSize().x/2,n=o[c].getBendPoints()[o[c].getBendPoints().length-1].y,s=a.getPosition().y+a.getSize().y/2;r>0&&Math.abs(n-s)/(Math.abs(e-t)/40)>50&&(s>n?o[c].getBendPoints().push(new b(a.getPosition().x-r/i,a.getPosition().y+a.getSize().y*l-r/2)):o[c].getBendPoints().push(new b(a.getPosition().x-r/i,a.getPosition().y+a.getSize().y*l+r/2)))}o[c].getBendPoints().push(new b(a.getPosition().x,a.getPosition().y+a.getSize().y*l))}else if(t===`UP`){let e=Z(a,q,0);if(a.getPosition().y+a.getSize().y+r<e)o[c].getBendPoints().push(new b(a.getPosition().x+a.getSize().x*l,e+n));else if(o[c].getBendPoints().length>0){let e=o[c].getBendPoints()[o[c].getBendPoints().length-1].x,t=a.getPosition().x+a.getSize().x/2,n=o[c].getBendPoints()[o[c].getBendPoints().length-1].y,s=a.getPosition().y+a.getSize().y/2;r>0&&Math.abs(e-t)/(Math.abs(n-s)/40)>50&&(t>e?o[c].getBendPoints().push(new b(a.getPosition().x+a.getSize().x*l-r/2,a.getPosition().y+r/i+a.getSize().y)):o[c].getBendPoints().push(new b(a.getPosition().x+a.getSize().x*l+r/2,a.getPosition().y+r/i+a.getSize().y)))}o[c].getBendPoints().push(new b(a.getPosition().x+a.getSize().x*l,a.getPosition().y+a.getSize().y))}else{let t=Z(a,K,0);if(dl(o[c],e))o[c].getBendPoints().push(new b(a.getPosition().x+a.getSize().x*l,o[c].getBendPoints()[o[c].getBendPoints().length-1].y));else if(a.getPosition().y-r>t)o[c].getBendPoints().push(new b(a.getPosition().x+a.getSize().x*l,t-n));else if(o[c].getBendPoints().length>0){let e=o[c].getBendPoints()[o[c].getBendPoints().length-1].x,t=a.getPosition().x+a.getSize().x/2,n=o[c].getBendPoints()[o[c].getBendPoints().length-1].y,s=a.getPosition().y+a.getSize().y/2;r>0&&Math.abs(e-t)/(Math.abs(n-s)/40)>50&&(t>e?o[c].getBendPoints().push(new b(a.getPosition().x+a.getSize().x*l-r/2,a.getPosition().y-r/i)):o[c].getBendPoints().push(new b(a.getPosition().x+a.getSize().x*l+r/2,a.getPosition().y-r/i)))}o[c].getBendPoints().push(new b(a.getPosition().x+a.getSize().x*l,a.getPosition().y))}}}}function Al(e){if(e==null)return`DOWN`;let t=String(e).toUpperCase();return t===`UP`?`UP`:t===`LEFT`?`LEFT`:t===`RIGHT`?`RIGHT`:`DOWN`}function jl(e){let t=[];for(let n of e.getNodes())n.getIncomingEdges().length===0&&(X(n,G,!0),t.push(n));switch(t.length){case 0:{let t=new Vc(0,e,`DUMMY_ROOT`);X(t,G,!0),X(t,Dc,!0),e.getNodes().push(t)}break;case 1:break;default:{let n=new Vc(0,e,`SUPER_ROOT`);for(let e of t)n.addChild(e),X(e,G,!1);X(n,G,!0),X(n,Dc,!0),e.getNodes().push(n);break}}}function Ml(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=e.getNodes().find(e=>$(e,G,!1));if(r!==void 0){Nl([r],t,n);for(let r of e.getNodes()){let e=Y(r,`ID`,``);X(r,`FAN`,t.get(e)??0);let i=1+(n.get(e)??0);X(r,Cc,i)}}}function Nl(e,t,n){if(e.length===0)return;let r=[],i=null,a=null,o=Math.floor(Math.log10(e.length))+1,s=0;for(let t of e){a!==Y(t,`ID`,``)&&(a=Y(t,`ID`,``),s=0),i=a===null?Pl(s++,o):a+Pl(s++,o),X(t,`ID`,i);for(let e of t.getChildren())r.push(e),X(e,`ID`,i)}let c=/* @__PURE__ */ new Map;for(let t=0;t<i.length-o;t++)for(let n of e){let e=Y(n,`ID`,``).substring(0,t+1),r=(c.get(e)??0)+1;c.set(e,r)}for(let[e,r]of c){let i=n.get(e)??0;n.set(e,r+i),i=t.get(e)??0,i<r&&t.set(e,r)}Nl(r,t,n)}function Pl(e,t){let n=`${e}`;for(;n.length<t;)n=`0${n}`;return n}function Fl(e){let t=/* @__PURE__ */ new Map;Il(e.getNodes().filter(e=>$(e,G,!1)),0,t);for(let n of e.getNodes()){let e=t.get(n.id)??0;n.props[W]=e}}function Il(e,t,n){if(e.length>0){let r=[];for(let i of e){n.set(i.id,t);for(let e of i.getChildren())r.push(e)}Il(r,t+1,n)}}function Ll(e){let t=e.getNodes().find(e=>$(e,G,!1));t!==void 0&&Rl(t.getChildren())}function Rl(e){if(e.length===0)return;let t=[],n=null;for(let r of e){for(let e of r.getChildren())t.push(e);n!==null&&(X(n,`RIGHTNEIGHBOR`,r),X(r,wc,n),r.getParent()===n.getParent()&&(X(n,Ec,r),X(r,Tc,n))),n=r}Rl(t)}function zl(e){let t=e.getNodes().find(e=>$(e,G,!1));if(t===void 0)return;let n=e.props[`org.eclipse.elk.direction`];Bl([t],n)}function Bl(e,t){if(e.length===0)return;let n=[],r=0;if(t===`LEFT`||t===`RIGHT`)for(let t of e){for(let e of t.getChildren())n.push(e);r<t.getSize().x&&(r=t.getSize().x)}else for(let t of e){for(let e of t.getChildren())n.push(e);r<t.getSize().y&&(r=t.getSize().y)}for(let t of e)X(t,jc,r);Bl(n,t)}function Vl(e){let t=e.props[lc];if(t!==`DOWN`&&t!=null)for(let n of e.getNodes()){let e=Q(n,kc,0),r=Q(n,Ac,0);switch(t.toUpperCase()){case`UP`:r*=-1;break;case`RIGHT`:{let t=e;e=r,r=t;break}case`LEFT`:{let t=e;e=-r,r=t;break}}X(n,kc,e),X(n,Ac,r)}}function Hl(e){let t=e.getNodes().find(e=>$(e,G,!1));if(t===void 0)return;let n=t.getPosition();n.x=Q(t,kc,0),n.y=Q(t,Ac,0);let r=t.getChildrenCopy();do r=Ul(r);while(r.length>0);for(let t of e.getNodes())t.getPosition().sub(new b(t.getSize().x/2,t.getSize().y/2))}function Ul(e){if(e.length===0)return[];let t=[];for(let n of e){t.push(...n.getChildrenCopy());let e=n.getPosition();e.x=Q(n,kc,0),e.y=Q(n,Ac,0)}return t}function Wl(e){if(!$(e,hc,!1))return;let t=e.props[lc],n=t===`UP`?`UP`:t===`LEFT`?`LEFT`:t===`RIGHT`?`RIGHT`:`DOWN`,r=Z(e,rc,20),i=Gl(e,n);Kl(e,r/2/2);let a=e.getNodes(),o=ll(n);a.sort((e,t)=>o.x*e.getPosition().x+o.y*e.getPosition().y-(o.x*t.getPosition().x+o.y*t.getPosition().y));for(let t of a)if(!$(t,`ROOT`,!1)){let a=ql(t,n),o=pl(t,e),s=0,c=0;if(a!==null){let e=a.getPosition();switch(n){case`LEFT`:s=e.x-r-t.getSize().x,o!==null&&o.getPosition().x-r-t.getSize().x<s&&(s=o.getPosition().x-r-t.getSize().x),c=s+t.getSize().x;break;case`RIGHT`:s=e.x+a.getSize().x+r,o!==null&&o.getPosition().x+r>s&&(s=o.getPosition().x+o.getSize().x+r),c=s+t.getSize().x;break;case`UP`:s=e.y-r-t.getSize().y,o!==null&&o.getPosition().y-r-t.getSize().y<s&&(s=o.getPosition().y-r-t.getSize().y),c=s+t.getSize().y;break;case`DOWN`:s=e.y+a.getSize().y+r,o!==null&&o.getPosition().y+r>s&&(s=o.getPosition().y+o.getSize().y+r),c=s+t.getSize().y}}else if(o!==null)switch(n){case`LEFT`:s=o.getPosition().x-r-t.getSize().x,c=s+t.getSize().x;break;case`RIGHT`:s=o.getPosition().x+o.getSize().x+r,c=s+t.getSize().x;break;case`UP`:s=o.getPosition().y-r-t.getSize().y,c=s+t.getSize().y;break;case`DOWN`:s=o.getPosition().y+o.getSize().y+r,c=s+t.getSize().y}if(Y(e,mc,`AVOID_OVERLAP`)===`AVOID_OVERLAP`){let e=i.find(e=>e.first<=s&&e.second>=c);if(e===void 0?(e=n===`LEFT`||n===`UP`?i.slice(1).find(e=>e.first<=s):i.slice(1).find(e=>e.first>=s),e!==void 0&&(n===`LEFT`||n===`RIGHT`?t.getPosition().x=e.first:t.getPosition().y=e.first)):n===`LEFT`||n===`RIGHT`?t.getPosition().x=s:t.getPosition().y=s,e!==void 0){let n=i.indexOf(e);n>0&&n!==t.props[W]&&(X(t,`COMPACT_LEVEL_ASCENSION`,!0),t.props[W]=n)}}else n===`LEFT`||n===`RIGHT`?t.getPosition().x=s:t.getPosition().y=s}}function Gl(e,t){let n=[];for(let r of e.getNodes()){for(;Q(r,W,0)>n.length-1;)n.push({first:Number.MAX_VALUE,second:-Number.MAX_VALUE});let e=Q(r,W,0);t===`LEFT`||t===`RIGHT`?(r.getPosition().x<n[e].first&&(n[e].first=r.getPosition().x),r.getPosition().x+r.getSize().x>n[e].second&&(n[e].second=r.getPosition().x+r.getSize().x)):(r.getPosition().y<n[e].first&&(n[e].first=r.getPosition().y),r.getPosition().y+r.getSize().y>n[e].second&&(n[e].second=r.getPosition().y+r.getSize().y))}return n}function Kl(e,t){let n=e.props[`org.eclipse.elk.direction`],r=n===`UP`?`UP`:n===`LEFT`?`LEFT`:n===`RIGHT`?`RIGHT`:`DOWN`,i=r===`LEFT`||r===`RIGHT`?`DOWN`:`RIGHT`,a=e.getNodes().filter(e=>!String(e.getLabel()??``).includes(`SUPER_ROOT`)),o=[];for(let e of a){let n=e.getPosition().clone();n.x-=t,n.y-=t,o.push({node:e,vec:n,upper:!0})}for(let e of a){let n=e.getPosition().clone();n.x+=e.getSize().x+t,n.y+=e.getSize().y+t,o.push({node:e,vec:n,upper:!1})}let s=ll(i);o.sort((e,t)=>s.x*e.vec.x+s.y*e.vec.y-(s.x*t.vec.x+s.y*t.vec.y));let c=ll(r),l=[],u=e=>c.x*e.getPosition().x+c.y*e.getPosition().y,d=e=>{let t=u(e),n=0,r=l.length;for(;n<r;){let e=n+r>>1;u(l[e])<t?n=e+1:r=e}l.splice(n,0,e)},f=e=>{let t=u(e),n=0,r=l.length;for(;n<r;){let e=n+r>>1;u(l[e])<t?n=e+1:r=e}return n>0?l[n-1]:void 0},p=e=>{let t=l.indexOf(e);return l[t+1]},m=/* @__PURE__ */ new Map;for(let e of o){let t=e.node;if(e.upper)d(t),f(t)!==void 0&&m.set(t,f(t)),l.length-(l.indexOf(t)+1)>1&&m.set(p(t),t);else{if(f(t)!==void 0){let e=f(t);e===m.get(t)&&Y(t,Pc,[]).push(e)}if(l.length-(l.indexOf(t)+1)>1){let e=p(t);m.get(e)===t&&Y(e,Pc,[]).push(t)}l.splice(l.indexOf(t),1)}}}function ql(e,t){let n=Y(e,Pc,[]);if(n===null||n.length<1)return null;if(n.length===1)return n[0];let r=null;switch(t){case`LEFT`:r=n.reduce((e,t)=>e.getPosition().x<=t.getPosition().x?e:t);break;case`RIGHT`:r=n.reduce((e,t)=>e.getPosition().x+e.getSize().x>=t.getPosition().x+t.getSize().x?e:t);break;case`UP`:r=n.reduce((e,t)=>e.getPosition().y<=t.getPosition().y?e:t);break;case`DOWN`:r=n.reduce((e,t)=>e.getPosition().y+e.getSize().y>=t.getPosition().y+t.getSize().y?e:t)}return r}function Jl(e){let t=[];for(let n of e.getNodes()){for(;Q(n,W,0)>t.length-1;)t.push({first:Number.MAX_VALUE,second:-Number.MAX_VALUE});let r=Q(n,W,0);e.props[`org.eclipse.elk.direction`]===`LEFT`||e.props[`org.eclipse.elk.direction`]===`RIGHT`?(n.getPosition().x<t[r].first&&(t[r].first=n.getPosition().x),n.getPosition().x+n.getSize().x>t[r].second&&(t[r].second=n.getPosition().x+n.getSize().x)):(n.getPosition().y<t[r].first&&(t[r].first=n.getPosition().y),n.getPosition().y+n.getSize().y>t[r].second&&(t[r].second=n.getPosition().y+n.getSize().y))}for(let n of e.getNodes()){let e=Q(n,W,0);X(n,K,t[e].first),X(n,q,t[e].second)}}function Yl(e){let t=Y(e,Oc,[]);for(let e of t)e.getSource().getOutgoingEdges().push(e),e.getTarget().getIncomingEdges().push(e)}function Xl(e){let t=new Kc,n=t.importGraph(e),r=new Jc,i=r.split(n);for(let e of i)Zl(e);let a=r.pack(i);return t.applyLayout(a),e}function Zl(e){Yc(e),jl(e),Ml(e),Fl(e),Qc(e),Ll(e),zl(e),hl(e),Vl(e),Hl(e),Wl(e),Jl(e),qc(e),Cl(e),Yl(e)}r(`box`,g),r(`fixed`,d),r(`random`,m),r(`stress`,Ct),r(`force`,St),r(`rectpacking`,Vn),r(`topdownpacking`,ar),r(`sporeoverlap`,yi),r(`sporecompaction`,bi),r(`radial`,Qa),r(`vertiflex`,Uo),r(`disco`,tc),r(`mrtree`,Xl);function Ql(e,n){let r=e instanceof Error?e.name:typeof e,i=e instanceof Error?e.message:String(e),a=e instanceof Error?e.stack:void 0;return new t(`INTERNAL_ERROR`,`inputs[${n}]`,`布局内部错误: ${i}`,{phase:`batch`,details:{originalName:r,originalMessage:i,stack:a}})}function $l(e,r){let i=[],a=0;for(let o=0;o<e.length;o+=1){if(r?.control?.signal?.aborted){for(let n=o;n<e.length;n+=1)i.push({index:n,ok:!1,error:new t(`ABORTED`,`inputs[${n}]`,`批次因取消信号终止`,{phase:`batch`})});break}try{let t=n(e[o],r);i.push({index:o,ok:!0,output:t}),a+=1}catch(e){i.push({index:o,ok:!1,error:e instanceof t?e:Ql(e,o)})}}return{items:i,okCount:a,errorCount:i.length-a}}function eu(e,t){t.set(e.id,e);for(let n of e.children??[])eu(n,t)}function tu(e,t,n){for(let r of e.edges??[]){let e=`${t}\u0000${r.id??``}\u0000${r.sources[0]??``}\u0000${r.targets[0]??``}`,i=n.get(e)??[];i.push(r),n.set(e,i)}for(let t of e.children??[])tu(t,t.id,n)}function nu(e,t,n){return e===void 0||t===void 0?e!==t:Math.hypot(e.x-t.x,e.y-t.y)>n}function ru(e,t,n){if(e===void 0||t===void 0)return e!==t;if(nu(e.startPoint,t.startPoint,n)||nu(e.endPoint,t.endPoint,n))return!0;let r=e.bendPoints??[],i=t.bendPoints??[];if(r.length!==i.length)return!0;for(let e=0;e<r.length;e+=1)if(nu(r[e],i[e],n))return!0;return!1}function iu(e,t,n){return e===void 0||ru(e.sections?.[0],t.sections?.[0],n)}function au(e){return e!==void 0&&Number.isFinite(e)&&e>=0?e:.5}function ou(e,t,n){let r=au(n?.tolerance),i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Map;eu(e,i),eu(t,a);let o=[],s=0,c=0;for(let[e,t]of a){let n=i.get(e),a=n===void 0?void 0:{x:n.x,y:n.y},l={x:t.x,y:t.y},u=a===void 0?0:Math.hypot(l.x-a.x,l.y-a.y);n===void 0||u>r?(o.push({id:e,before:a,after:l,distance:u}),c=Math.max(c,u)):s+=1}let l=n?.includeEdges!==!1;if(!l)return{changedNodes:o,changedEdges:[],unchangedNodes:s,unchangedEdges:0,edgesChecked:l,maxNodeDistance:c};let u=/* @__PURE__ */ new Map,d=/* @__PURE__ */ new Map;tu(e,e.id,u),tu(t,t.id,d);let f=[],p=0,m=/* @__PURE__ */ new Set;for(let[e,t]of d){let n=u.get(e)??[];for(let i=0;i<t.length;i+=1){let a=t[i],o=n[i];m.add(e),iu(o,a,r)?f.push({id:a.id,routeChanged:!0}):p+=1}}return{changedNodes:o,changedEdges:f,unchangedNodes:s,unchangedEdges:p,edgesChecked:l,maxNodeDistance:c}}function su(e,t,r){let{tolerance:i,includeEdges:a,...o}=r??{};return ou(t,n(e,{...o,responseFormat:`full`}),{tolerance:i,includeEdges:a})}function cu(e,t){if(e.addEventListener)return e.addEventListener(`message`,t),()=>e.removeEventListener?.(`message`,t);let n=e=>t({data:e});return e.on?.(`message`,n),()=>e.off?.(`message`,n)}const lu=`布局已中止 (LayoutControl.signal)`;function uu(e){let t=typeof e==`function`?null:e,n=typeof e==`function`?e:null,r=!1,i=1,a=()=>{},o=/* @__PURE__ */ new Map,s=()=>{if(t===null){if(n===null)throw Error(`LayoutWorkerClient 已 dispose`);t=n(),a=cu(t,c)}return t},c=e=>{let t=e.data;if(typeof t!=`object`||!t||typeof t.id!=`number`)return;let n=t.id,r=o.get(n);if(r)switch(t.type){case`result`:o.delete(n),r.cleanup?.(),r.resolve(t.output);break;case`error`:o.delete(n),r.cleanup?.(),r.reject(new du(t.error));break;case`progress`:r.control?.onProgress?.(t.progress);break;default:o.delete(n),r.cleanup?.(),r.reject(/* @__PURE__ */ Error(`未知 worker 响应类型: ${String(t.type)}`))}},l=(e,n)=>{if(t!==null&&(a(),t.terminate?.(),t=null),e!==null){let t=o.get(e);t&&(o.delete(e),t.cleanup?.(),t.reject(n))}for(let t of o.values())t.cleanup?.(),t.reject(/* @__PURE__ */ Error(e===null?`LayoutWorkerClient disposed`:`worker 已终止 (另一个请求被取消或 client dispose)`));o.clear()};return t!==null&&(a=cu(t,c)),{layout(e,t){return new Promise((n,a)=>{if(r){a(/* @__PURE__ */ Error(`LayoutWorkerClient 已 dispose`));return}if(t?.control?.signal?.aborted){a(/* @__PURE__ */ Error(lu));return}let c;try{c=s()}catch(e){a(e);return}let u=i++,{control:d,...f}=t??{},p={resolve:n,reject:a,control:d};if(d?.signal){let e=()=>l(u,/* @__PURE__ */ Error(lu));d.signal.addEventListener(`abort`,e,{once:!0}),p.cleanup=()=>d.signal.removeEventListener(`abort`,e)}o.set(u,p);try{c.postMessage({type:`layout`,id:u,input:e,options:f})}catch(e){o.delete(u),p.cleanup?.(),a(e)}})},dispose(){r||(r=!0,l(null,/* @__PURE__ */ Error(`LayoutWorkerClient disposed`)))}}}var du=class extends t{constructor(e){super(e.code??`INVALID_INPUT`,e.path??`root`,e.message,{phase:e.phase,details:e.details}),this.message=e.message,this.retryable=e.retryable??!1}};export{$l as i,ou as n,su as r,uu as t};
|