@elliemae/pui-cli 8.62.2 → 8.62.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/build/docs/404.html +16 -0
  2. package/build/docs/api/functions/loadRoutes/index.html +22 -0
  3. package/build/docs/api/index.html +22 -0
  4. package/build/docs/api/type-aliases/LIB_NAME/index.html +17 -0
  5. package/build/docs/api/variables/babelConfig/index.html +40 -0
  6. package/build/docs/api/variables/commitlintConfig/index.html +20 -0
  7. package/build/docs/api/variables/eslintBaseConfig/index.html +130 -0
  8. package/build/docs/api/variables/eslintConfig/index.html +178 -0
  9. package/build/docs/api/variables/jestConfig/index.html +98 -0
  10. package/build/docs/api/variables/jestNodeConfig/index.html +98 -0
  11. package/build/docs/api/variables/lintStagedConfig/index.html +24 -0
  12. package/build/docs/api/variables/prettierConfig/index.html +30 -0
  13. package/build/docs/api/variables/stylelintConfig/index.html +30 -0
  14. package/build/docs/api/variables/vitestConfig/index.html +17 -0
  15. package/build/docs/assets/css/styles.5e594f8e.css +1 -0
  16. package/build/docs/assets/js/04ee7372.6701a521.js +1 -0
  17. package/build/docs/assets/js/0551d4dd.58dce19e.js +1 -0
  18. package/build/docs/assets/js/1038.7eccbe83.js +1 -0
  19. package/build/docs/assets/js/1200.62fdfb17.js +1 -0
  20. package/build/docs/assets/js/1340.e320589e.js +1 -0
  21. package/build/docs/assets/js/1348.fdba76ee.js +1 -0
  22. package/build/docs/assets/js/1591.b2d5d84b.js +1 -0
  23. package/build/docs/assets/js/16b7bc88.98d0e7e1.js +1 -0
  24. package/build/docs/assets/js/17896441.4a6e0d00.js +1 -0
  25. package/build/docs/assets/js/1912.edd5c016.js +1 -0
  26. package/build/docs/assets/js/1b9df811.cbc3937e.js +1 -0
  27. package/build/docs/assets/js/213.e69351b3.js +1 -0
  28. package/build/docs/assets/js/2154.9723abaf.js +1 -0
  29. package/build/docs/assets/js/2185.f2209249.js +1 -0
  30. package/build/docs/assets/js/2186.40926696.js +1 -0
  31. package/build/docs/assets/js/2327.22ae5940.js +1 -0
  32. package/build/docs/assets/js/234.83bc0029.js +1 -0
  33. package/build/docs/assets/js/2399.63cd96a9.js +1 -0
  34. package/build/docs/assets/js/2421.0a678e37.js +1 -0
  35. package/build/docs/assets/js/2534.dbf7919d.js +1 -0
  36. package/build/docs/assets/js/2650.eb69c6a5.js +1 -0
  37. package/build/docs/assets/js/2652.3c5e01f6.js +1 -0
  38. package/build/docs/assets/js/2675.413b1881.js +1 -0
  39. package/build/docs/assets/js/2856.434d8532.js +1 -0
  40. package/build/docs/assets/js/3075.8eb78c50.js +1 -0
  41. package/build/docs/assets/js/3171.c208ec80.js +1 -0
  42. package/build/docs/assets/js/3186.4706e934.js +1 -0
  43. package/build/docs/assets/js/3242.80d2f573.js +1 -0
  44. package/build/docs/assets/js/3380.fa624efa.js +1 -0
  45. package/build/docs/assets/js/3720.8e7f36d4.js +2 -0
  46. package/build/docs/assets/js/3720.8e7f36d4.js.LICENSE.txt +9 -0
  47. package/build/docs/assets/js/3731.3625e619.js +1 -0
  48. package/build/docs/assets/js/3749.25d3a9dc.js +1 -0
  49. package/build/docs/assets/js/3753.ad43bbbf.js +1 -0
  50. package/build/docs/assets/js/37d86055.ac328609.js +1 -0
  51. package/build/docs/assets/js/386.82e1d440.js +2 -0
  52. package/build/docs/assets/js/386.82e1d440.js.LICENSE.txt +1 -0
  53. package/build/docs/assets/js/3938.381439b7.js +1 -0
  54. package/build/docs/assets/js/3995.9c7a08d7.js +1 -0
  55. package/build/docs/assets/js/4074.2d89387a.js +1 -0
  56. package/build/docs/assets/js/4567.40926696.js +1 -0
  57. package/build/docs/assets/js/4570.22eef064.js +1 -0
  58. package/build/docs/assets/js/4832.f41ebb6a.js +1 -0
  59. package/build/docs/assets/js/4944.20a6ae14.js +1 -0
  60. package/build/docs/assets/js/504.082248a2.js +1 -0
  61. package/build/docs/assets/js/5111.1b6768c7.js +1 -0
  62. package/build/docs/assets/js/5153.ccd7118e.js +1 -0
  63. package/build/docs/assets/js/5463.df303412.js +1 -0
  64. package/build/docs/assets/js/5529.a57e8e4a.js +1 -0
  65. package/build/docs/assets/js/5663.13fc2f9f.js +1 -0
  66. package/build/docs/assets/js/5818.62ee6d97.js +1 -0
  67. package/build/docs/assets/js/5850.e0052526.js +1 -0
  68. package/build/docs/assets/js/5973.50ffe932.js +1 -0
  69. package/build/docs/assets/js/5d5f1db0.ee0a2786.js +1 -0
  70. package/build/docs/assets/js/5e8c322a.03e5f869.js +1 -0
  71. package/build/docs/assets/js/5e95c892.0b2807a1.js +1 -0
  72. package/build/docs/assets/js/5fb3c522.7fa934f6.js +1 -0
  73. package/build/docs/assets/js/6001.475cf9bc.js +1 -0
  74. package/build/docs/assets/js/6216.81ed3f71.js +1 -0
  75. package/build/docs/assets/js/6286.1e2004df.js +1 -0
  76. package/build/docs/assets/js/6737.cba35710.js +1 -0
  77. package/build/docs/assets/js/6779.48fa5e85.js +1 -0
  78. package/build/docs/assets/js/6780.35d6b408.js +1 -0
  79. package/build/docs/assets/js/681.7048216c.js +1 -0
  80. package/build/docs/assets/js/6bd11e52.4a64999a.js +1 -0
  81. package/build/docs/assets/js/6e96545e.82b3f634.js +1 -0
  82. package/build/docs/assets/js/7129.6a95a014.js +1 -0
  83. package/build/docs/assets/js/7173.3df1d101.js +1 -0
  84. package/build/docs/assets/js/71f6d02b.f4ef9e77.js +1 -0
  85. package/build/docs/assets/js/7330.25c0f54a.js +1 -0
  86. package/build/docs/assets/js/777.6cc435d2.js +1 -0
  87. package/build/docs/assets/js/80e87108.fb514ef2.js +1 -0
  88. package/build/docs/assets/js/821.8d4e2a80.js +1 -0
  89. package/build/docs/assets/js/8335.7c94cd06.js +1 -0
  90. package/build/docs/assets/js/8347.ba32afd0.js +1 -0
  91. package/build/docs/assets/js/8398.64ed21da.js +1 -0
  92. package/build/docs/assets/js/8585.38199cd1.js +1 -0
  93. package/build/docs/assets/js/8725.440f4f8c.js +1 -0
  94. package/build/docs/assets/js/918.44c83d98.js +1 -0
  95. package/build/docs/assets/js/9242.e3fb85ca.js +1 -0
  96. package/build/docs/assets/js/940.c104b973.js +1 -0
  97. package/build/docs/assets/js/9661.e5f9a8b1.js +1 -0
  98. package/build/docs/assets/js/9718.706df9d5.js +1 -0
  99. package/build/docs/assets/js/9737.81795237.js +1 -0
  100. package/build/docs/assets/js/9805.40926696.js +1 -0
  101. package/build/docs/assets/js/9998.2236d038.js +1 -0
  102. package/build/docs/assets/js/a7bd4aaa.82b76b67.js +1 -0
  103. package/build/docs/assets/js/a94703ab.8fd80ed9.js +1 -0
  104. package/build/docs/assets/js/aba21aa0.3bbcf0cc.js +1 -0
  105. package/build/docs/assets/js/b8ac1d98.eac62e10.js +1 -0
  106. package/build/docs/assets/js/bde5209a.1f661437.js +1 -0
  107. package/build/docs/assets/js/c377a04b.54071de3.js +1 -0
  108. package/build/docs/assets/js/common.469f0e39.js +1 -0
  109. package/build/docs/assets/js/e5f79924.3b9434d6.js +1 -0
  110. package/build/docs/assets/js/f736c962.1745b6ff.js +1 -0
  111. package/build/docs/assets/js/main.ceaf5a1d.js +2 -0
  112. package/build/docs/assets/js/main.ceaf5a1d.js.LICENSE.txt +51 -0
  113. package/build/docs/assets/js/runtime~main.2ef68500.js +1 -0
  114. package/build/docs/img/favicon.ico +0 -0
  115. package/build/docs/img/logo.jpeg +0 -0
  116. package/build/docs/img/logo.svg +22 -0
  117. package/build/docs/img/readme.md +1 -0
  118. package/build/docs/index.html +175 -0
  119. package/build/docs/readme.md +1 -0
  120. package/build/docs/sitemap.xml +1 -0
  121. package/build/docs/ssl-certificate-setup/index.html +284 -0
  122. package/build/docs/usage-guide/index.html +416 -0
  123. package/dist/cjs/build/vite.config.js +16 -0
  124. package/dist/cjs/package.json +1 -4
  125. package/dist/esm/build/vite.config.js +16 -0
  126. package/dist/esm/package.json +1 -4
  127. package/dist/types/tsconfig.tsbuildinfo +1 -1
  128. package/package.json +42 -41
@@ -0,0 +1,9 @@
1
+ /*!
2
+ Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable
3
+ Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com)
4
+ Licensed under The MIT License (http://opensource.org/licenses/MIT)
5
+ */
6
+
7
+ /*! Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */
8
+
9
+ /*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */
@@ -0,0 +1 @@
1
+ "use strict";(globalThis.webpackChunk_elliemae_pui_cli=globalThis.webpackChunk_elliemae_pui_cli||[]).push([[3731],{3731(t,e,a){a.d(e,{diagram:()=>_});var r=a(3492),n=a(4969),i=a(3639),s=a(4689),o=a(2371),l=a(8053),c=a(9183),d={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"},g={axes:[],curves:[],options:d},u=structuredClone(g),h=s.UI.radar,p=(0,l.K)(()=>(0,i.$t)({...h,...(0,s.zj)().radar}),"getConfig"),x=(0,l.K)(()=>u.axes,"getAxes"),m=(0,l.K)(()=>u.curves,"getCurves"),$=(0,l.K)(()=>u.options,"getOptions"),f=(0,l.K)(t=>{u.axes=t.map(t=>({name:t.name,label:t.label??t.name}))},"setAxes"),v=(0,l.K)(t=>{u.curves=t.map(t=>({name:t.name,label:t.label??t.name,entries:y(t.entries)}))},"setCurves"),y=(0,l.K)(t=>{if(null==t[0].axis)return t.map(t=>t.value);const e=x();if(0===e.length)throw new Error("Axes must be populated before curves for reference entries");return e.map(e=>{const a=t.find(t=>t.axis?.$refText===e.name);if(void 0===a)throw new Error("Missing entry for axis "+e.label);return a.value})},"computeCurveEntries"),b={getAxes:x,getCurves:m,getOptions:$,setAxes:f,setCurves:v,setOptions:(0,l.K)(t=>{const e=t.reduce((t,e)=>(t[e.name]=e,t),{});u.options={showLegend:e.showLegend?.value??d.showLegend,ticks:e.ticks?.value??d.ticks,max:e.max?.value??d.max,min:e.min?.value??d.min,graticule:e.graticule?.value??d.graticule}},"setOptions"),getConfig:p,clear:(0,l.K)(()=>{(0,s.IU)(),u=structuredClone(g)},"clear"),setAccTitle:s.SV,getAccTitle:s.iN,setDiagramTitle:s.ke,getDiagramTitle:s.ab,getAccDescription:s.m7,setAccDescription:s.EI},w=(0,l.K)(t=>{(0,r.S)(t,b);const{axes:e,curves:a,options:n}=t;b.setAxes(e),b.setCurves(a),b.setOptions(n)},"populate"),C={parse:(0,l.K)(async t=>{const e=await(0,c.qg)("radar",t);o.R.debug(e),w(e)},"parse")},M=(0,l.K)((t,e,a,r)=>{const i=r.db,s=i.getAxes(),o=i.getCurves(),l=i.getOptions(),c=i.getConfig(),d=i.getDiagramTitle(),g=(0,n.D)(e),u=K(g,c),h=l.max??Math.max(...o.map(t=>Math.max(...t.entries))),p=l.min,x=Math.min(c.width,c.height)/2;L(u,s,x,l.ticks,l.graticule),k(u,s,x,c),T(u,s,o,p,h,l.graticule,c),S(u,o,l.showLegend,c),u.append("text").attr("class","radarTitle").text(d).attr("x",0).attr("y",-c.height/2-c.marginTop)},"draw"),K=(0,l.K)((t,e)=>{const a=e.width+e.marginLeft+e.marginRight,r=e.height+e.marginTop+e.marginBottom,n=e.marginLeft+e.width/2,i=e.marginTop+e.height/2;return(0,s.a$)(t,r,a,e.useMaxWidth??!0),t.attr("viewBox",`0 0 ${a} ${r}`).attr("overflow","visible"),t.append("g").attr("transform",`translate(${n}, ${i})`)},"drawFrame"),L=(0,l.K)((t,e,a,r,n)=>{if("circle"===n)for(let i=0;i<r;i++){const e=a*(i+1)/r;t.append("circle").attr("r",e).attr("class","radarGraticule")}else if("polygon"===n){const n=e.length;for(let i=0;i<r;i++){const s=a*(i+1)/r,o=e.map((t,e)=>{const a=2*e*Math.PI/n-Math.PI/2;return`${s*Math.cos(a)},${s*Math.sin(a)}`}).join(" ");t.append("polygon").attr("points",o).attr("class","radarGraticule")}}},"drawGraticule"),k=(0,l.K)((t,e,a,r)=>{const n=e.length;for(let i=0;i<n;i++){const s=e[i].label,o=2*i*Math.PI/n-Math.PI/2,l=Math.cos(o),c=Math.sin(o);t.append("line").attr("x1",0).attr("y1",0).attr("x2",a*r.axisScaleFactor*l).attr("y2",a*r.axisScaleFactor*c).attr("class","radarAxisLine");const d=l>.01?"start":l<-.01?"end":"middle",g=c>.01?"hanging":c<-.01?"auto":"central",u=4;t.append("text").text(s).attr("x",a*r.axisLabelFactor*l+u*l).attr("y",a*r.axisLabelFactor*c+u*c).attr("text-anchor",d).attr("dominant-baseline",g).attr("class","radarAxisLabel")}},"drawAxes");function T(t,e,a,r,n,i,s){const o=e.length,l=Math.min(s.width,s.height)/2;a.forEach((e,a)=>{if(e.entries.length!==o)return;const c=e.entries.map((t,e)=>{const a=2*Math.PI*e/o-Math.PI/2,i=A(t,r,n,l);return{x:i*Math.cos(a),y:i*Math.sin(a)}});"circle"===i?t.append("path").attr("d",O(c,s.curveTension)).attr("class",`radarCurve-${a}`):"polygon"===i&&t.append("polygon").attr("points",c.map(t=>`${t.x},${t.y}`).join(" ")).attr("class",`radarCurve-${a}`)})}function A(t,e,a,r){return r*(Math.min(Math.max(t,e),a)-e)/(a-e)}function O(t,e){const a=t.length;let r=`M${t[0].x},${t[0].y}`;for(let n=0;n<a;n++){const i=t[(n-1+a)%a],s=t[n],o=t[(n+1)%a],l=t[(n+2)%a],c={x:s.x+(o.x-i.x)*e,y:s.y+(o.y-i.y)*e},d={x:o.x-(l.x-s.x)*e,y:o.y-(l.y-s.y)*e};r+=` C${c.x},${c.y} ${d.x},${d.y} ${o.x},${o.y}`}return`${r} Z`}function S(t,e,a,r){if(!a)return;const n=3*(r.width/2+r.marginRight)/4,i=3*-(r.height/2+r.marginTop)/4;e.forEach((e,a)=>{const r=t.append("g").attr("transform",`translate(${n}, ${i+20*a})`);r.append("rect").attr("width",12).attr("height",12).attr("class",`radarLegendBox-${a}`),r.append("text").attr("x",16).attr("y",0).attr("class","radarLegendText").text(e.label)})}(0,l.K)(T,"drawCurves"),(0,l.K)(A,"relativeRadius"),(0,l.K)(O,"closedRoundCurve"),(0,l.K)(S,"drawLegend");var I={draw:M},z=(0,l.K)((t,e)=>{let a="";for(let r=0;r<t.THEME_COLOR_LIMIT;r++){const n=t[`cScale${r}`];a+=`\n\t\t.radarCurve-${r} {\n\t\t\tcolor: ${n};\n\t\t\tfill: ${n};\n\t\t\tfill-opacity: ${e.curveOpacity};\n\t\t\tstroke: ${n};\n\t\t\tstroke-width: ${e.curveStrokeWidth};\n\t\t}\n\t\t.radarLegendBox-${r} {\n\t\t\tfill: ${n};\n\t\t\tfill-opacity: ${e.curveOpacity};\n\t\t\tstroke: ${n};\n\t\t}\n\t\t`}return a},"genIndexStyles"),E=(0,l.K)(t=>{const e=(0,s.P$)(),a=(0,s.zj)(),r=(0,i.$t)(e,a.themeVariables);return{themeVariables:r,radarOptions:(0,i.$t)(r.radar,t)}},"buildRadarStyleOptions"),_={parser:C,db:b,renderer:I,styles:(0,l.K)(({radar:t}={})=>{const{themeVariables:e,radarOptions:a}=E(t);return`\n\t.radarTitle {\n\t\tfont-size: ${e.fontSize};\n\t\tcolor: ${e.titleColor};\n\t\tdominant-baseline: hanging;\n\t\ttext-anchor: middle;\n\t}\n\t.radarAxisLine {\n\t\tstroke: ${a.axisColor};\n\t\tstroke-width: ${a.axisStrokeWidth};\n\t}\n\t.radarAxisLabel {\n\t\tfont-size: ${a.axisLabelFontSize}px;\n\t\tcolor: ${a.axisColor};\n\t}\n\t.radarGraticule {\n\t\tfill: ${a.graticuleColor};\n\t\tfill-opacity: ${a.graticuleOpacity};\n\t\tstroke: ${a.graticuleColor};\n\t\tstroke-width: ${a.graticuleStrokeWidth};\n\t}\n\t.radarLegendText {\n\t\ttext-anchor: start;\n\t\tfont-size: ${a.legendFontSize}px;\n\t\tdominant-baseline: hanging;\n\t}\n\t${z(e,a)}\n\t`},"styles")}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(globalThis.webpackChunk_elliemae_pui_cli=globalThis.webpackChunk_elliemae_pui_cli||[]).push([[3749],{6130(e,r,a){a.d(r,{diagram:()=>i});var l=a(6780),s=(a(5644),a(9673),a(1355),a(1033),a(4247),a(9976),a(33),a(2679),a(735),a(6170),a(490),a(1538),a(3639),a(4689),a(2371),a(8053)),i={parser:l._$,get db(){return new l.NM},renderer:l.Lh,styles:l.tM,init:(0,s.K)(e=>{e.class||(e.class={}),e.class.arrowMarkerAbsolute=e.arrowMarkerAbsolute},"init")}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(globalThis.webpackChunk_elliemae_pui_cli=globalThis.webpackChunk_elliemae_pui_cli||[]).push([[3753],{3753(t,e,n){n.r(e),n.d(e,{render:()=>to});var o=n(4570),r=n(9976),s=n(33),i=(n(2679),n(735)),a=n(6170),c=(n(490),n(1538),n(3639)),f=n(4689),d=n(2371),l=n(8053),u=n(2399);async function h(t,e){const o=new u.T({multigraph:!0,compound:!0}),r=[...e.edges],i=(0,f.D7)(),a=t.insert("g").attr("class","root"),c=a.insert("g").attr("class","clusters"),d=a.insert("g").attr("class","edges edgePath"),l=a.insert("g").attr("class","edgeLabels"),h=a.insert("g").attr("class","nodes"),g=new Map,p=null!=t.node();await Promise.all(e.nodes.map(async t=>{if(t.isGroup)o.setNode(t.id,{...t});else{if(p){const e=await(0,s.on)(h,t,{config:i,dir:t.dir}),n=e.node()?.getBBox()??{width:0,height:0};g.set(t.id,e),t.width=n.width,t.height=n.height}o.setNode(t.id,{...t})}}));for(const n of r){o.setEdge(n.start,n.end,{...n},n.id);e.edges.some(t=>t.id===n.id)||e.edges.push(n)}if(globalThis.mermaidCaptureSizes){const{captureNodeSizes:o}=await n.e(5111).then(n.bind(n,5111));o(t,e)}return{graph:o,groups:{clusters:c,edgePaths:d,edgeLabels:l,nodes:h,rootGroups:a},nodeElements:g}}(0,l.K)(h,"createGraphWithElements");var g=1e-5,p=1e-6;function x(t){const e=[];for(let n=0;n<t.length-1;n++)e.push({a:t[n],b:t[n+1]});return e}function m(t,e,n,o){const r=e.x-t.x,s=e.y-t.y,i=o.x-n.x,a=o.y-n.y,c=r*a-s*i;if(0===c)return null;const f=n.x-t.x,d=n.y-t.y,l=(f*a-d*i)/c,u=(f*s-d*r)/c;return l<=p||l>=.999999||u<=p||u>=.999999?null:{point:{x:t.x+l*r,y:t.y+l*s},tA:l,tB:u}}function y(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}function b(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n],r=x(o.points);for(let s=n+1;s<t.length;s++){const n=t[s],i=x(n.points);for(const[t,s]of r.entries())for(const[r,a]of i.entries()){const i=m(s.a,s.b,a.a,a.b);if(!i)continue;const c=y(s);!!(c!==y(a))&&c?e.push({jumpEdgeId:o.id,otherEdgeId:n.id,segIndex:t,t:i.tA,point:i.point}):e.push({jumpEdgeId:n.id,otherEdgeId:o.id,segIndex:r,t:i.tB,point:i.point})}}}return e}function M(t){const e=Math.round(1e3*t)/1e3;return Number.isInteger(e),`${e}`}function K(t){return`${M(t.x)},${M(t.y)}`}function I(t){const e=t.b.x-t.a.x,n=t.b.y-t.a.y;return Math.abs(e)>=Math.abs(n)?e>=0?1:0:n>=0?1:0}(0,l.K)(x,"buildSegmentList"),(0,l.K)(m,"segmentIntersection"),(0,l.K)(y,"isHorizontalSeg"),(0,l.K)(b,"findEdgeIntersections"),(0,l.K)(M,"fmt"),(0,l.K)(K,"pointToString"),(0,l.K)(I,"getArcSweepFlag");function w(t,e){if(t.length<2)return t.map(t=>({...t}));const n=t.map(t=>({...t})),o=e.arrowTypeStart&&i.hq[e.arrowTypeStart];if(o){const e=t[0],r=t[1],s=Math.atan2(r.y-e.y,r.x-e.x);n[0].x=e.x+o*Math.cos(s),n[0].y=e.y+o*Math.sin(s)}const r=e.arrowTypeEnd&&i.hq[e.arrowTypeEnd];if(r){const e=t.length,o=t[e-2],s=t[e-1],i=Math.atan2(s.y-o.y,s.x-o.x);n[e-1].x=s.x-r*Math.cos(i),n[e-1].y=s.y-r*Math.sin(i)}return n}function S(t,e,n,o,r){const s=t.point.x,i=t.point.y,a={x:s-e*t.r,y:i-n*t.r},c={x:s+e*t.r,y:i+n*t.r},f=[`L${K(a)}`];return"arc"===r?f.push(`A${M(t.r)},${M(t.r)} 0 0 ${o} ${K(c)}`):f.push(`M${K(c)}`),f}function v(t,e,n,o){const r=e.x-t.x,s=e.y-t.y,i=n.x-e.x,a=n.y-e.y,c=Math.hypot(r,s),f=Math.hypot(i,a);if(c<g||f<g)return null;const d=r/c,l=s/c,u=i/f,h=a/f,p=d*u+l*h,x=Math.max(-1,Math.min(1,p)),m=Math.acos(x);if(m<g||Math.abs(Math.PI-m)<g)return null;const y=Math.min(o/Math.sin(m/2),c/2,f/2);return{startX:e.x-d*y,startY:e.y-l*y,endX:e.x+u*y,endY:e.y+h*y,ctrlX:e.x,ctrlY:e.y,cutLen:y}}function C(t,e,n){const o=t.points;if(o.length<2)return"";const r=w(o,t),s="rounded"===t.curve,i=x(r),a=new Map;for(const f of e){const t=i[f.segIndex];if(!t)continue;const e=Math.hypot(t.b.x-t.a.x,t.b.y-t.a.y),o=a.get(f.segIndex)??[];o.push({t:f.t,point:f.point,d:f.t*e,r:n.jumpRadius}),a.set(f.segIndex,o)}const c=[`M${K(r[0])}`];for(let f=0;f<i.length;f++){const t=i[f],e=Math.hypot(t.b.x-t.a.x,t.b.y-t.a.y),o=0===e?0:(t.b.x-t.a.x)/e,d=0===e?0:(t.b.y-t.a.y)/e,l=I(t);let u=0;if(s&&f>0){const t=v(r[f-1],r[f],r[f+1]??r[f],5);t&&(u=t.cutLen)}let h=e,g=null;s&&f<i.length-1&&(g=v(r[f],r[f+1],r[f+2]??r[f+1],5),g&&(h=e-g.cutLen));const p=[...a.get(f)??[]].sort((t,e)=>t.t-e.t);for(const n of p)n.r=Math.min(n.r,n.d-u,h-n.d);for(let n=0;n<p.length-1;n++){const t=p[n+1].d-p[n].d;if(p[n].r+p[n+1].r>t){const e=t/2;p[n].r=Math.min(p[n].r,e),p[n+1].r=Math.min(p[n+1].r,e)}}for(const r of p)r.r<.001||c.push(...S(r,o,d,l,n.jumpStyle));s&&g?(c.push(`L${M(g.startX)},${M(g.startY)}`),c.push(`Q${M(g.ctrlX)},${M(g.ctrlY)} ${M(g.endX)},${M(g.endY)}`)):c.push(`L${K(t.b)}`)}return c.join(" ")}function L(t){return/^[\d\s+,.LMelm-]*$/.test(t)}function k(t){return!t||("linear"===t||"rounded"===t||"step"===t||"stepBefore"===t||"stepAfter"===t)}function T(t){if(!t)return null;try{const e="function"==typeof atob?atob(t):Buffer.from(t,"base64").toString(),n=JSON.parse(e);if(!Array.isArray(n))return null;const o=[];for(const t of n)t&&"number"==typeof t.x&&"number"==typeof t.y&&o.push({x:t.x,y:t.y});return o.length>=2?o:null}catch{return null}}function $(t,e,n){if(!n.enabled)return;const o=t.node();if(!o)return;const r=new Map;for(const f of e)r.set(f.id,f);const s=[],i=new Map;for(const f of e){const t="undefined"!=typeof CSS&&CSS.escape?CSS.escape(f.id):f.id,e=o.querySelector(`path[data-id="${t}"]`);if(!e)continue;i.set(f.id,e);const n=T(e.getAttribute("data-points"))??f.points;s.push({...f,points:n})}const a=b(s);if(0===a.length)return;const c=new Map;for(const f of a){const t=c.get(f.jumpEdgeId)??[];t.push(f),c.set(f.jumpEdgeId,t)}for(const f of s){const t=c.get(f.id);if(!t||0===t.length)continue;const e=r.get(f.id),o=e?.curve;if(void 0!==o&&!k(o))continue;const s=i.get(f.id);if(!s)continue;if(void 0===o){if(!L(s.getAttribute("d")??""))continue}const a=s.getAttribute("style")??"",d=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(a),l=d?Number.parseFloat(d[1]):null,u=d?Number.parseFloat(d[2]):null,h=C(f,t,n);if(s.setAttribute("d",h),null!==l&&null!==u&&"function"==typeof s.getTotalLength){const t=s.getTotalLength(),e=`0 ${l} ${Math.max(0,t-l-u)} ${u}`,n=a.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${e};`).replace(/;\s*;+/g,";");s.setAttribute("style",n)}}}async function R(t,e){for(const r of t.nodes)r.isGroup?await(0,s.U)(e.clusters,r):(0,s.U_)(r);const n=new Map;for(const r of t.nodes)r?.id&&n.set(r.id,r);for(const s of t.edges){const o=s.start?n.get(s.start)??{}:{},i=s.end?n.get(s.end)??{}:{},a=(0,r.Jo)(e.edgePaths,{...s},{},t.type,o,i,t.diagramId);s.label&&await(0,r.jP)(e.rootGroups,s),s.label&&O(s,a)}const o=t.config?.swimlane?.lineHops;if(!1!==o){const n="gap"===o?"gap":"arc",r=t.edges.filter(t=>Array.isArray(t.points)&&t.points.length>=2).map(t=>({id:t.id,points:t.points,curve:t.curve,arrowTypeStart:t.arrowTypeStart,arrowTypeEnd:t.arrowTypeEnd}));$(e.edgePaths,r,{enabled:!0,jumpRadius:6,jumpStyle:n})}}function O(t,e){const n=e?.updatedPath??e?.originalPath,o=(0,f.zj)(),{subGraphTitleTotalMargin:s}=(0,a.O)({flowchart:o.flowchart??{}});if(t.label){const o=r.lP.get(t.id);let i=t.x,a=t.y;if(n){const o=c._K.calcLabelPosition(n);d.R.debug("Moving label "+t.label+" from (",i,",",a,") to (",o.x,",",o.y,") abc88"),e&&(i=o.x,a=o.y)}o.attr("transform",`translate(${i}, ${a+s/2})`)}if(t?.startLabelLeft){const e=r.UQ.get(t.id).startLeft;let o=t?.x,s=t?.y;if(n){const e=c._K.calcTerminalLabelPosition(t.arrowTypeStart?10:0,"start_left",n);o=e.x,s=e.y}e.attr("transform",`translate(${o}, ${s})`)}if(t.startLabelRight){const e=r.UQ.get(t.id).startRight;let o=t.x,s=t.y;if(n){const e=c._K.calcTerminalLabelPosition(t.arrowTypeStart?10:0,"start_right",n);o=e.x,s=e.y}e.attr("transform",`translate(${o}, ${s})`)}if(t.endLabelLeft){const e=r.UQ.get(t.id).endLeft;let o=t.x,s=t.y;if(n){const e=c._K.calcTerminalLabelPosition(t.arrowTypeEnd?10:0,"end_left",n);o=e.x,s=e.y}e.attr("transform",`translate(${o}, ${s})`)}if(t.endLabelRight){const e=r.UQ.get(t.id).endRight;let o=t.x,s=t.y;if(n){const e=c._K.calcTerminalLabelPosition(t.arrowTypeEnd?10:0,"end_right",n);o=e.x,s=e.y}e.attr("transform",`translate(${o}, ${s})`)}}(0,l.K)(w,"applyMarkerOffsets"),(0,l.K)(S,"emitJump"),(0,l.K)(v,"computeRoundedCorner"),(0,l.K)(C,"rewriteEdgePath"),(0,l.K)(L,"isStraightPath"),(0,l.K)(k,"curveSupportsLineHops"),(0,l.K)(T,"decodeDataPoints"),(0,l.K)($,"applyLineJumpsToSvg"),(0,l.K)(R,"adjustLayout"),(0,l.K)(O,"positionEdgeLabel");var N="__swimlane_default__";function B(t){return Math.max(t.padding??20,20)}function E(t){const{x:e,y:n,width:o,height:r}=t,s=t.swimlaneContentTop;if("number"!=typeof e||"number"!=typeof n||"number"!=typeof o||"number"!=typeof r||"number"!=typeof s||!Number.isFinite(e)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(r)||!Number.isFinite(s)||o<=0||r<=0)return void delete t.groupTitleRect;const i=n-r/2,a=Math.min(s,n+r/2),c=i+Math.min(21,Math.max(0,a-i));c<=i?delete t.groupTitleRect:t.groupTitleRect={left:e-o/2,right:e+o/2,top:i,bottom:c}}function F(t){const e=t.direction,n=t.nodes??=[];for(const s of t.nodes??[])s.isGroup&&!s.parentId&&(s.shape="swimlane",e&&(s.direction=e));const o=n.filter(t=>!t.isGroup&&!t.parentId);if(0===o.length)return;let r=n.find(t=>t.id===N);r?r.isGroup&&(r.shape="swimlane",e&&(r.direction=e)):(r={id:N,label:"",isGroup:!0,shape:"swimlane",padding:20,...e?{direction:e}:{}},n.push(r));for(const s of o)s.parentId=N}function Y(t){const e=new Map;for(const i of t.nodes??[])e.set(i.id,i);const n=[];for(const i of t.edges??[]){const t="string"==typeof i.start?i.start:void 0,e="string"==typeof i.end?i.end:void 0;t&&e&&(i.labelNodeId||n.push({id:i.id,src:t,dst:e,ref:i}))}const o=t.nodes??[],r=o.filter(t=>t.isGroup),s=o.filter(t=>!t.isGroup);return{nodes:[...[...r].reverse(),...s].map(t=>t.id),edges:n,layout:t,nodeById:e}}function X(t,e,n,o){const{layout:r}=t,s=t.nodeById,i=o?.layerGap??100,a=o?.nodeGap??40;let c=0;for(const u of e.layers){let t=0;for(const e of u){const o=s.get(e);if(!o){t++;continue}o.layer=c,o.order=t;const r=n.x[e]??t*a,f=n.y[e]??c*i;o.x=r,o.y=f,t++}c++}const f=r.nodes??[],d=new Map,l=[];for(const u of f){if(!u?.isGroup)continue;u.parentId||l.push(u);const t=f.filter(t=>t.parentId===u.id);let e=1/0,o=-1/0,r=1/0,s=-1/0;for(const i of t){const t=i.x??n.x[i.id],a=i.y??n.y[i.id],c=i.width??0,f=i.height??0;null!=t&&null!=a&&(e=Math.min(e,t-c/2),o=Math.max(o,t+c/2),r=Math.min(r,a-f/2),s=Math.max(s,a+f/2))}if(e===1/0||r===1/0)u.x=u.x??0,u.y=u.y??0,u.width=u.width??0,u.height=u.height??0;else{const t=u.padding??20,n=u.parentId?t:2*B(u),i=t,a=Math.max(0,o-e)+n,c=Math.max(0,s-r)+i,f=(e+o)/2,l=(r+s)/2;u.x=f,u.y=l,u.width=a,u.height=c,d.set(u.id,{minX:e,maxX:o,minY:r,maxY:s})}}if(l.length>0&&d.size>0){let t=1/0,e=-1/0,n=0;for(const o of l){const r=o.padding??20;r>n&&(n=r);const s=d.get(o.id);s&&(t=Math.min(t,s.minY),e=Math.max(e,s.maxY))}if(t!==1/0&&e!==-1/0){const o=36,r=Math.max(0,e-t)+2*Math.max(n,o),s=(t+e)/2;for(const e of l)e.y=s,e.height=r,e.swimlaneContentTop=t;const i=[...l].sort((t,e)=>(t.x??0)-(e.x??0)),a=[],c=[],f=[];for(const t of i){const e=d.get(t.id);if(!e)continue;const n=Math.max(0,e.maxX-e.minX)+2*B(t),o=(e.minX+e.maxX)/2;a.push(t.id),c.push(o),f.push(n)}const u=a.length;if(u>0){const t=new Map;if(1===u)t.set(a[0],f[0]);else{const e=[];for(let t=0;t<u-1;t++)e.push(c[t+1]-c[t]);const n=new Array(u);n[0]=0;for(let t=0;t<u-1;t++)n[t+1]=2*e[t]-n[t];let o=0,r=Number.POSITIVE_INFINITY;for(let t=0;t<u;t++){const e=f[t];t%2==0?o=Math.max(o,e-n[t]):r=Math.min(r,n[t]-e)}let s=o;s=o<=r?(o+r)/2:o;for(let i=0;i<u;i++){const e=n[i]+(i%2==0?s:-s),o=Math.max(f[i],e);t.set(a[i],o)}}for(const e of l){const n=t.get(e.id);null!=n&&(e.width=n),E(e)}}}}}(0,l.K)(B,"topLaneHorizontalPadding"),(0,l.K)(E,"assignTopLaneTitleRect"),(0,l.K)(F,"prepareLayoutForSwimlanes"),(0,l.K)(Y,"toGraphView"),(0,l.K)(X,"writeBackToLayoutData");function P(t){const e=[],n=[],o=new Map;for(const i of t.nodes)o.set(i.id,i);for(const i of t.edges){if(!i.label||0===i.label.length)continue;if(i.isLayoutOnly)continue;if(i.labelNodeId)continue;const t=i.start?o.get(i.start):void 0,r=i.end?o.get(i.end):void 0;if(!t||!r){d.R.warn("[EdgeLabelNodes]",`Edge ${i.id} has missing source or target node`);continue}const s=`edge-label-${i.start}-${i.end}-${i.id}`,a=t.parentId!==r.parentId?r.parentId:t.parentId,c={id:s,label:i.label,edgeStart:i.start??"",edgeEnd:i.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:a,isGroup:!1,labelStyle:Array.isArray(i.labelStyle)?i.labelStyle[0]:i.labelStyle??"",...t.dir?{dir:t.dir}:{}};e.push(c),i.labelNodeId=s,i.label=void 0,i.text=void 0;const f={id:`${i.id}-to-label`,start:i.start,end:s,type:"normal",isLayoutOnly:!0},l={id:`${i.id}-from-label`,start:s,end:i.end,type:"normal",isLayoutOnly:!0};n.push(f,l)}const r=[...t.nodes,...e],s=[...t.edges,...n];return{...t,nodes:r,edges:s}}(0,l.K)(P,"createEdgeLabelNodes");var z=.001;function A(t){const e=t.x??0,n=t.y??0,o=t.width??0,r=t.height??0;return o>0&&r>0?{cx:e,cy:n,rect:st(e,n,o,r)}:void 0}function G(t){if(t.isGroup)return;const e=A(t);if(!e)return;return{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}}function D(t,e,n=z){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}function H(t,e,n=z){return Math.abs(t.x-e.x)<n}function _(t,e,n=z){return Math.abs(t.y-e.y)<n}function j(t,e,n=z){return _(t,e,n)&&Math.abs(t.x-e.x)>n}function V(t,e,n=z){return H(t,e,n)&&Math.abs(t.y-e.y)>n}function W(t,e,n,o){return Math.max(0,Math.min(Math.max(t,e),Math.max(n,o))-Math.max(Math.min(t,e),Math.min(n,o)))}function U(t,e,n=z){return t.horizontal&&e.horizontal&&_(t.a,e.a,n)?W(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&H(t.a,e.a,n)?W(t.a.y,t.b.y,e.a.y,e.b.y):0}function q(t,e=z){const n=[];for(let o=0;o<t.length-1;o++){const r=t[o],s=t[o+1],i=j(r,s,e),a=V(r,s,e);(i||a)&&n.push({index:o,a:r,b:s,horizontal:i,vertical:a})}return n}function J(t,e=z){const n=q(t,e);let o=0;for(let r=1;r<n.length;r++)n[r-1].horizontal!==n[r].horizontal&&o++;return o}function Q(t,e=z){const n=[];for(const o of t){const t=n.length>0?n[n.length-1]:void 0;t&&D(t,o,e)||n.push({x:o.x,y:o.y})}return n}function Z(t,e=z){if(!t||4!==t.length)return;const[n,o,r,s]=t;if(j(n,o,e)&&V(o,r,e)&&j(r,s,e))return{kind:"HVH",p0:n,p1:o,p2:r,p3:s};return V(n,o,e)&&j(o,r,e)&&V(r,s,e)?{kind:"VHV",p0:n,p1:o,p2:r,p3:s}:void 0}function tt(t,e,n,o=0){const r=Math.min(t.x,e.x),s=Math.max(t.x,e.x),i=Math.min(t.y,e.y),a=Math.max(t.y,e.y);return s>n.left-o&&r<n.right+o&&a>n.top-o&&i<n.bottom+o}function et(t,e,n=0){return t.x>e.left+n&&t.x<e.right-n&&t.y>e.top+n&&t.y<e.bottom-n}function nt(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}function ot(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}function rt(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}function st(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}function it(t){return A(t)?.rect}function at(t,e){switch(e){case"top":return{x:t.cx,y:t.rect.top};case"bottom":return{x:t.cx,y:t.rect.bottom};case"left":return{x:t.rect.left,y:t.cy};case"right":return{x:t.rect.right,y:t.cy}}}function ct(t,e,n,o,r,s=z){const i="left"===e||"right"===e,a="left"===o||"right"===o;if(i&&a){if("right"===e&&"left"===o&&t.x<n.x||"left"===e&&"right"===o&&t.x>n.x){if(_(t,n,s))return[t,n];const e=(t.x+n.x)/2;return[t,{x:e,y:t.y},{x:e,y:n.y},n]}if(e===o){if(_(t,n,s))return;const o="left"===e?Math.min(t.x,n.x)-r:Math.max(t.x,n.x)+r;return[t,{x:o,y:t.y},{x:o,y:n.y},n]}return}if(!i&&!a){if(e===o){if(H(t,n,s))return;const o="top"===e?Math.min(t.y,n.y)-r:Math.max(t.y,n.y)+r;return[t,{x:t.x,y:o},{x:n.x,y:o},n]}if(!("bottom"===e&&"top"===o&&t.y<n.y||"top"===e&&"bottom"===o&&t.y>n.y))return;if(H(t,n,s))return[t,n];const i=(t.y+n.y)/2;return[t,{x:t.x,y:i},{x:n.x,y:i},n]}if(i&&!a){const r="right"===e&&n.x>t.x||"left"===e&&n.x<t.x,s="top"===o&&t.y<n.y||"bottom"===o&&t.y>n.y;return r&&s?[t,{x:n.x,y:t.y},n]:void 0}const c="bottom"===e&&n.y>t.y||"top"===e&&n.y<t.y,f="left"===o&&t.x<n.x||"right"===o&&t.x>n.x;return c&&f?[t,{x:t.x,y:n.y},n]:void 0}function ft(t,e,n,o){return"left"===e||"right"===e?[t,{x:o,y:t.y},{x:o,y:n.y},n]:[t,{x:t.x,y:o},{x:n.x,y:o},n]}function dt(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const t=G(o);t&&(e.set(t.id,t),n.push({id:t.id,rect:t.rect}))}return{nodeInfoById:e,realNodeRects:n}}function lt(t){const e=[],n=[];for(const o of t){const t=G(o);if(!t)continue;const r={id:t.id,rect:t.rect};o.isEdgeLabel?n.push(r):e.push(r)}return{realNodeRects:e,labelNodeRects:n}}function ut(t,{includeEdgeLabels:e=!0}={}){const n=[];for(const o of t){if(o.isGroup||!e&&o.isEdgeLabel)continue;const t=o.x??0,r=o.y??0,s=o.width??0,i=o.height??0;n.push({nodeId:o.id,...st(t,r,s,i)})}return n}function ht(t,e,n=z){const o=t.start,r=t.end;if(!o||!r)return;const s=e.get(o),i=e.get(r);return s&&i?{srcId:o,dstId:r,srcInfo:s,dstInfo:i,collinearX:Math.abs(s.cx-i.cx)<n,collinearY:Math.abs(s.cy-i.cy)<n}:void 0}function gt(t,e,n,o=[],r=0){for(const s of n)if(!o.includes(s.id)&&tt(t,e,s.rect,-r))return!0;return!1}function pt(t,e,n,o,r=z,s=1e-6){const i=_(t,e,r),a=H(t,e,r),c=_(n,o,r),f=H(n,o,r);if(i&&c||a&&f)return!1;if(!i&&!a||!c&&!f)return!1;const d=i?{a:t,b:e}:{a:n,b:o},l=a?{a:t,b:e}:{a:n,b:o},u=d.a.y,h=Math.min(d.a.x,d.b.x),g=Math.max(d.a.x,d.b.x),p=l.a.x,x=Math.min(l.a.y,l.b.y),m=Math.max(l.a.y,l.b.y);if(p<h||p>g||u<x||u>m)return!1;const y=Math.abs(p-d.a.x)<s&&Math.abs(u-d.a.y)<s||Math.abs(p-d.b.x)<s&&Math.abs(u-d.b.y)<s,b=Math.abs(p-l.a.x)<s&&Math.abs(u-l.a.y)<s||Math.abs(p-l.b.x)<s&&Math.abs(u-l.b.y)<s;return!(y&&b)}function xt(t,e,n,o,r=z){const s=_(t,e,r),i=H(t,e,r),a=_(n,o,r),c=H(n,o,r);return i&&c&&H(t,n,r)?W(t.y,e.y,n.y,o.y)>r:!!(s&&a&&_(t,n,r))&&W(t.x,e.x,n.x,o.x)>r}function mt(t,e,n,o,{epsilon:r=z,skipDegenerateOther:s=!1}={}){for(const i of n){if(i===o||i.isLayoutOnly)continue;const n=i.points;if(n&&!(n.length<2))for(let o=0;o<n.length-1;o++){const i=n[o],a=n[o+1];if((!s||!D(i,a,r))&&(pt(t,e,i,a,r)||xt(t,e,i,a,r)))return!0}}return!1}function yt(t,e,n,o,r=z){const s=_(t,e,r),i=H(t,e,r),a=_(n,o,r),c=H(n,o,r);if(!(s&&c||i&&a))return!1;const f=s?{a:t,b:e}:{a:n,b:o},d=s?{a:n,b:o}:{a:t,b:e},l=f.a.y,u=Math.min(f.a.x,f.b.x),h=Math.max(f.a.x,f.b.x),g=d.a.x,p=Math.min(d.a.y,d.b.y),x=Math.max(d.a.y,d.b.y);return g>u+r&&g<h-r&&l>p+r&&l<x-r}function bt(t,e,n){const o=Math.min(e,n),r=Math.max(e,n);return t>o+z&&t<r-z}function Mt(t,e,n){return H(t,e)&&H(e,n)?bt(e.y,t.y,n.y):!(!_(t,e)||!_(e,n))&&bt(e.x,t.x,n.x)}function Kt(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){const r=n[n.length-1],s=t[o],i=o+1<t.length?t[o+1]:void 0;if(r&&i){if(D(r,i)){o++,e=!0;continue}if(Mt(r,s,i)){e=!0;continue}}n.push(s)}return{points:n,changed:e}}function It(t){const e=[t[0]];for(let o=1;o<t.length;o++){const n=e[e.length-1],r=t[o];if(!H(n,r)&&!_(n,r)){const t=e.length>=2?e[e.length-2]:void 0,o=!!t&&H(t,n)?{x:n.x,y:r.y}:{x:r.x,y:n.y};e.push(o)}e.push(r)}const n=[];for(const o of e){const t=n[n.length-1];t&&D(t,o)||n.push(o)}return n}function wt(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const t=Kt(e);if(e=t.points,!t.changed)break}return e}(0,l.K)(A,"measuredNodeRect"),(0,l.K)(G,"nodeBoundsInfoFor"),(0,l.K)(D,"samePoint"),(0,l.K)(H,"sameX"),(0,l.K)(_,"sameY"),(0,l.K)(j,"isHorizontalSegment"),(0,l.K)(V,"isVerticalSegment"),(0,l.K)(W,"overlapLength"),(0,l.K)(U,"sameAxisSegmentOverlapLength"),(0,l.K)(q,"orthogonalSegmentsForPoints"),(0,l.K)(J,"countOrthogonalBends"),(0,l.K)(Q,"dedupeConsecutivePoints"),(0,l.K)(Z,"classifyThreeSegmentRoute"),(0,l.K)(tt,"segmentBoundsOverlapRect"),(0,l.K)(et,"pointInsideRect"),(0,l.K)(nt,"rectContainsRect"),(0,l.K)(ot,"rectsOverlap"),(0,l.K)(rt,"inflateRect"),(0,l.K)(st,"rectFromCenterSize"),(0,l.K)(it,"rectOfNodeBounds"),(0,l.K)(at,"portForRectSide"),(0,l.K)(ct,"buildOrthogonalPortPath"),(0,l.K)(ft,"buildSameSideTrackPath"),(0,l.K)(dt,"collectRealNodeBounds"),(0,l.K)(lt,"collectNodeRectEntries"),(0,l.K)(ut,"collectLayoutNodeRects"),(0,l.K)(ht,"getNodePairGeometry"),(0,l.K)(gt,"segmentHitsAnyRect"),(0,l.K)(pt,"orthogonalSegmentsCross"),(0,l.K)(xt,"sameAxisSegmentsOverlap"),(0,l.K)(mt,"segmentConflictsWithAnyEdge"),(0,l.K)(yt,"orthogonalSegmentsStrictlyCross"),(0,l.K)(bt,"strictlyBetween"),(0,l.K)(Mt,"isCollinearIntermediate"),(0,l.K)(Kt,"simplifyPolylineOnce"),(0,l.K)(It,"orthogonalizePolyline"),(0,l.K)(wt,"simplifyPolyline");var St=.001;function vt(t,e,n){const o=t;if(o.isLayoutOnly||!o.points||o.points.length<n)return;const r=o.start?e.get(o.start):void 0,s=o.end?e.get(o.end):void 0;return{edge:o,points:o.points,srcRect:r?it(r):void 0,dstRect:s?it(s):void 0}}function Ct(t,e,n){if(_(t,e,St)){return{x:t.x<n.left?n.left:n.right,y:t.y}}if(H(t,e,St)){const e=t.y<n.top?n.top:n.bottom;return{x:t.x,y:e}}return{x:Math.min(n.right,Math.max(n.left,t.x)),y:Math.min(n.bottom,Math.max(n.top,t.y))}}function Lt(t,e,n){const o=n?1:-1;let r=n?0:t.length-1;for(;r>=0&&r<t.length&&et(t[r],e,.5);)r+=o;if(r<0||r>=t.length)return t;const s=r-o;if(s<0||s>=t.length)return t;const i=Ct(t[r],t[s],e);return n?[i,...t.slice(r)]:[...t.slice(0,r+1),i]}function kt(t,e){for(const n of t){const t=vt(n,e,2);if(!t)continue;let o=[...t.points];t.srcRect&&(o=Lt(o,t.srcRect,!0)),t.dstRect&&(o=Lt(o,t.dstRect,!1)),o=wt(It(o)),o=Pt(o,t.srcRect,t.dstRect),t.edge.points=wt(It(o))}}function Tt(t,e,n,o=!1){if(_(t,e,St)){if(e.y<n.top-St||e.y>n.bottom+St)return e;if(o){if(t.x<n.left-St)return{x:n.left,y:t.y};if(t.x>n.right+St)return{x:n.right,y:t.y}}return{x:Math.abs(e.x-n.left)<=Math.abs(e.x-n.right)?n.left:n.right,y:t.y}}if(H(t,e,St)){if(e.x<n.left-St||e.x>n.right+St)return e;if(o){if(t.y<n.top-St)return{x:t.x,y:n.top};if(t.y>n.bottom+St)return{x:t.x,y:n.bottom}}const r=Math.abs(e.y-n.top)<=Math.abs(e.y-n.bottom);return{x:t.x,y:r?n.top:n.bottom}}return e}function $t(t,e,n){const o=t[e];for(let r=e+n;r>=0&&r<t.length;r+=n){const e=t[r];if(!D(e,o,St))return e}return t[e+n]}function Rt(t,e){const n=t+4,o=e-4;return n<=o?{lo:n,hi:o}:{lo:(t+e)/2,hi:(t+e)/2}}function Ot(t,e,n){const{lo:o,hi:r}=Rt(e,n);return Math.min(r,Math.max(o,t))}function Nt(t){const e=Math.max(...t.map(t=>t.lo)),n=Math.min(...t.map(t=>t.hi));if(!(e>n))return{lo:e,hi:n}}function Bt(t,e){return"left"===e||"right"===e?Rt(t.top,t.bottom):Rt(t.left,t.right)}function Et(t,e,n){const o=t.y>=n.top-St&&t.y<=n.bottom+St,r=t.x>=n.left-St&&t.x<=n.right+St;if(_(t,e,St)&&o){if(Math.abs(t.x-n.left)<St)return"left";if(Math.abs(t.x-n.right)<St)return"right"}if(H(t,e,St)&&r){if(Math.abs(t.y-n.top)<St)return"top";if(Math.abs(t.y-n.bottom)<St)return"bottom"}}function Ft(t){return"left"===t||"right"===t}function Yt(t,e,n,o,r){const s=[],i=n?Et(t,e,n):void 0,a=o?Et(e,t,o):void 0;return n&&i&&Ft(i)===r&&s.push(Bt(n,i)),o&&a&&Ft(a)===r&&s.push(Bt(o,a)),s.length>0?Nt(s):void 0}function Xt(t,e,n,o,r){const s=Yt(t,e,n,o,r);if(!s)return;const i=r?t.y:t.x,a=Math.min(s.hi,Math.max(s.lo,i));return Math.abs(a-i)<St?void 0:r?[{x:t.x,y:a},{x:e.x,y:a}]:[{x:a,y:t.y},{x:a,y:e.y}]}function Pt(t,e,n){if(2!==t.length)return t;const[o,r]=t;return _(o,r,St)?Xt(o,r,e,n,!0)??t:H(o,r,St)?Xt(o,r,e,n,!1)??t:t}function zt(t,e,n){return Ft(n)?{x:t.x,y:Ot(t.y,e.top,e.bottom)}:{x:Ot(t.x,e.left,e.right),y:t.y}}function At(t,e,n,o,r,s){const i=t.map(t=>({...t}));for(let a=e;a>=0&&a<t.length;a+=n){const e=t[a];if(s&&!_(e,o,St))break;if(!s&&!H(e,o,St))break;s?i[a].y=r.y:i[a].x=r.x}return i}function Gt(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,r=n?1:-1,s=t[o],i=$t(t,o,r);if(!i)return t;const a=Et(s,i,e);if(!a)return t;const c=Ft(a),f=zt(s,e,a);return D(s,f,St)?t:At(t,o,r,s,f,c)}function Dt(t,e,n){const o=Math.min(t.x,e.x)>=n.left-St&&Math.max(t.x,e.x)<=n.right+St,r=Math.min(t.y,e.y)>=n.top-St&&Math.max(t.y,e.y)<=n.bottom+St;return Math.abs(t.y-n.top)<St&&Math.abs(e.y-n.top)<St&&o?"top":Math.abs(t.y-n.bottom)<St&&Math.abs(e.y-n.bottom)<St&&o?"bottom":Math.abs(t.x-n.left)<St&&Math.abs(e.x-n.left)<St&&r?"left":Math.abs(t.x-n.right)<St&&Math.abs(e.x-n.right)<St&&r?"right":void 0}function Ht(t,e,n,o){switch(t){case"top":return H(e,n,St)&&n.y<o.top-St;case"bottom":return H(e,n,St)&&n.y>o.bottom+St;case"left":return _(e,n,St)&&n.x<o.left-St;case"right":return _(e,n,St)&&n.x>o.right+St}}function _t(t,e,n){if(t.length<3)return t;if(n){const n=Dt(t[0],t[1],e);return n&&Ht(n,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,r=Dt(t[o-1],t[o],e);return r&&Ht(r,t[o-1],t[o-2],e)?t.slice(0,o):t}function jt(t,e,n){let o=t;if(e){const t=$t(o,0,1);if(t){const n=Tt(t,o[0],e);n!==o[0]&&(o=[n,...o.slice(1)])}o=_t(o,e,!0)}if(n){const t=o.length-1,e=$t(o,t,-1);if(e){const r=Tt(e,o[t],n,!0);r!==o[t]&&(o=[...o.slice(0,t),r])}o=_t(o,n,!1)}const r=Pt(o,e,n);return r!==o||2===o.length?r:(e&&(o=Gt(o,e,!0)),n&&(o=Gt(o,n,!1)),o)}function Vt(t,e){for(const n of t){const t=vt(n,e,2);if(!t)continue;const o=jt(Q(t.points,St),t.srcRect,t.dstRect);if(o.length<3){t.edge.points=o;continue}const r=[o[0],{...o[0]},...o.slice(1,-1),o[o.length-1],{...o[o.length-1]}];t.edge.points=r}}function Wt(t){return new Map(t.map(t=>[t.id,t]))}function Ut(t,e){let n=t.parentId,o=null;for(;n;){const t=e.get(n);if(!t?.isGroup)break;o=t.id,n=t.parentId}return o}function qt(t,e){let n=0,o=t.parentId;for(;o;){const t=e.get(o);if(!t?.isGroup)break;n++,o=t.parentId}return n}function Jt(t){let e=1/0,n=-1/0,o=1/0,r=-1/0;for(const s of t){const t=s.x,i=s.y;if("number"!=typeof t||"number"!=typeof i)continue;const a=s.width??0,c=s.height??0;e=Math.min(e,t-a/2),n=Math.max(n,t+a/2),o=Math.min(o,i-c/2),r=Math.max(r,i+c/2)}return e===1/0||o===1/0?null:{minX:e,maxX:n,minY:o,maxY:r}}function Qt(t,e){const n=t.padding??20;t.x=(e.minX+e.maxX)/2,t.y=(e.minY+e.maxY)/2,t.width=Math.max(0,e.maxX-e.minX)+n,t.height=Math.max(0,e.maxY-e.minY)+n}function Zt(t){const e=Wt(t),n=t.filter(t=>t.isGroup&&t.parentId).sort((t,n)=>qt(n,e)-qt(t,e));for(const o of n){const e=Jt(t.filter(t=>t.parentId===o.id));e&&Qt(o,e)}}function te(t,e){const n=t.nodes??[],o=t.edges??[],r=n.filter(t=>!t.isGroup);let s=1/0,i=-1/0;for(const c of r){const t=c[e];"number"==typeof t&&(s=Math.min(s,t),i=Math.max(i,t))}if(!Number.isFinite(s)||!Number.isFinite(i))return!1;const a=(0,l.K)(t=>s+i-t,"mirror");for(const c of n){const t=c[e];"number"==typeof t&&(c[e]=a(t));const n=c.groupTitleRect;n&&(c.groupTitleRect="x"===e?{...n,left:a(n.right),right:a(n.left)}:{...n,top:a(n.bottom),bottom:a(n.top)})}for(const c of o)for(const t of c.points??[])t[e]=a(t[e]);return!0}function ee(t){return!(t.nodes??[]).some(t=>!t.isGroup)||te(t,"y")}function ne(t,e="LR"){const n=t.nodes??[],o=t.edges??[],r=n.filter(t=>!t.isGroup);let s=1/0,i=1/0;for(const v of r){const t=v.x??0,e=v.y??0;t<s&&(s=t),e<i&&(i=e)}if(!Number.isFinite(s)||!Number.isFinite(i))return!1;const a=36;let c=0,f=0;for(const v of r)c+=v.width??0,f+=v.height??0;const d=c/r.length,l=f/r.length,u=l>0?Math.max(1,d/l):1;for(const v of r){const t=v.x??0,e=((v.y??0)-i)*u+a,n=t-s;v.x=e,v.y=n}for(const v of o)if(v.points)for(const t of v.points){const e=t.x,n=(t.y-i)*u+a,o=e-s;t.x=n,t.y=o}Zt(n);const h=n.filter(t=>t.isGroup&&!t.parentId);if(0===h.length)return"RL"===e&&te(t,"x"),!0;const g=Wt(n),p=new Map;for(const v of n){if(v.isGroup)continue;const t=Ut(v,g);if(!t)continue;const e=p.get(t)??[];e.push(v),p.set(t,e)}let x=0;for(const v of h){const t=v.padding??0;t>x&&(x=t)}const m=[];let y=1/0,b=-1/0;for(const v of h){const t=Jt(p.get(v.id)??[]);t&&(y=Math.min(y,t.minX),b=Math.max(b,t.maxX),m.push({lane:v,contentTop:t.minY,contentBottom:t.maxY,centerY:(t.minY+t.maxY)/2}))}if(y===1/0||b===-1/0)return!0;const M=Math.max(0,b-y)+2*Math.max(x,10),K=a+M,I=(y+b)/2-M/2-a,w=I+K/2,S=Math.max(x,a);m.sort((t,e)=>t.centerY-e.centerY);for(let v=0;v<m.length;v++){const t=m[v];let e,n;if(0===v)e=t.contentTop-S;else{e=(m[v-1].contentBottom+t.contentTop)/2}if(v===m.length-1)n=t.contentBottom+S;else{const e=m[v+1];n=(t.contentBottom+e.contentTop)/2}const o=Math.max(0,n-e),r=(e+n)/2;t.lane.x=w,t.lane.y=r,t.lane.width=K,t.lane.height=o,t.lane.swimlaneContentTop=t.contentTop,t.lane.groupTitleRect={left:I,right:I+a,top:e,bottom:n}}return"RL"===e&&te(t,"x"),!0}(0,l.K)(vt,"endpointContextFor"),(0,l.K)(Ct,"segmentEnterPoint"),(0,l.K)(Lt,"clipEndpoint"),(0,l.K)(kt,"clipEdgeEndpointsToNodeBoundaries"),(0,l.K)(Tt,"snapEndpointToBoundary"),(0,l.K)($t,"firstDistinctAdjacent"),(0,l.K)(Rt,"cornerClearanceRange"),(0,l.K)(Ot,"clampToCornerClearance"),(0,l.K)(Nt,"intersectRanges"),(0,l.K)(Bt,"clearanceRangeForSide"),(0,l.K)(Et,"terminalSideForSegment"),(0,l.K)(Ft,"isHorizontalSide"),(0,l.K)(Yt,"straightClearanceRange"),(0,l.K)(Xt,"clearStraightEndpointCornerAxis"),(0,l.K)(Pt,"clearStraightEndpointCornerConnections"),(0,l.K)(zt,"cornerClearedEndpoint"),(0,l.K)(At,"moveCollinearEndpointRun"),(0,l.K)(Gt,"clearEndpointCornerConnection"),(0,l.K)(Dt,"borderSideForSegment"),(0,l.K)(Ht,"leavesOutward"),(0,l.K)(_t,"collapseOwnBorderStub"),(0,l.K)(jt,"snapAndCollapseEndpoints"),(0,l.K)(Vt,"prepareEdgeEndpointsForRenderer"),(0,l.K)(Wt,"buildNodeMap"),(0,l.K)(Ut,"resolveTopLevelGroupId"),(0,l.K)(qt,"groupDepth"),(0,l.K)(Jt,"boundsForChildren"),(0,l.K)(Qt,"applyGroupBounds"),(0,l.K)(Zt,"recomputeNestedGroupBounds"),(0,l.K)(te,"mirrorAxis"),(0,l.K)(ee,"applyBtDirectionTransform"),(0,l.K)(ne,"applyLrDirectionTransform");var oe=1e-6,re=[0,8,-8,16,-16];function se(t,e){const{nodeInfoById:n,realNodeRects:o}=dt(e);for(const r of t){if(r.isLayoutOnly)continue;const e=r.points;if(!e||e.length<4)continue;const s=Z(Q(e,oe),oe);if(!s)continue;const{p3:i}=s,a="HVH"===s.kind,c=ht(r,n,oe);if(!c)continue;const{srcId:f,dstId:d,srcInfo:l,dstInfo:u,collinearX:h,collinearY:g}=c;if(h||g)continue;let p;const x=l.rect;for(const n of re){let e,s,c;if(a){const t=u.cy>l.cy?x.bottom:x.top,o=l.cx+n;if(o<=x.left+oe||o>=x.right-oe)continue;e={x:o,y:t},s={x:o,y:i.y},c={x:i.x,y:i.y}}else{const t=u.cx>l.cx?x.right:x.left,o=l.cy+n;if(o<=x.top+oe||o>=x.bottom-oe)continue;e={x:t,y:o},s={x:i.x,y:o},c={x:i.x,y:i.y}}const h=D(e,s,oe),g=D(s,c,oe);if(h&&g)continue;if(!h&&gt(e,s,o,[f],1))continue;if(!g&&gt(s,c,o,[d],1))continue;const m=!h&&mt(e,s,t,r,{epsilon:oe,skipDegenerateOther:!0}),y=!g&&mt(s,c,t,r,{epsilon:oe,skipDegenerateOther:!0});if(!m&&!y){p=h?[s,c]:g?[e,s]:[e,s,c];break}}p&&(r.points=p)}}function ie(t,e){const n=.001,{realNodeRects:o,labelNodeRects:r}=lt(e.values());for(const s of t){if(s.isLayoutOnly)continue;const i=s.points;if(!i||i.length<4)continue;const a=Q(i,n);if(a.length<4)continue;const c=a.length-1,f=a[c],d=a[c-1],u=a[c-2],h=f.x-d.x,g=f.y-d.y,p=Math.hypot(h,g);if(p>=10||p<n)continue;const x=d.x-u.x,m=d.y-u.y;if(Math.hypot(x,m)<n)continue;const y=j(d,f,n),b=V(d,f,n),M=j(u,d,n),K=V(u,d,n);if(!(y&&K||b&&M))continue;const I=s.end,w=s.start,S=I?e.get(I):void 0;if(!S)continue;const v=S.x??0,C=S.y??0,L=it(S);if(!L)continue;let k,T;if(K){const t=m<0;k={x:v,y:u.y},T={x:v,y:t?L.bottom:L.top}}else{const t=x>0;k={x:u.x,y:C},T={x:t?L.right:L.left,y:C}}if(gt(k,T,o,I?[I]:[],-2))continue;if(gt(k,T,r,[],-2))continue;if(w){const t=e.get(w),n=t?it(t):void 0;if(n&&et(k,n,2))continue}const $=(0,l.K)((t,e)=>`${t.x.toFixed(3)},${t.y.toFixed(3)}|${e.x.toFixed(3)},${e.y.toFixed(3)}`,"ownSegmentKey"),R=new Set;for(let t=0;t<a.length-1;t++)R.add($(a[t],a[t+1]));const O=(0,l.K)((e,o)=>{for(const r of t){if(r===s)continue;if(r.isLayoutOnly)continue;const t=r.points;if(t&&!(t.length<2))for(let r=0;r<t.length-1;r++){const s=t[r],i=t[r+1];if(!R.has($(s,i))&&yt(e,o,s,i,n))return!0}}return!1},"segmentCrossesOtherEdge");if(O(k,T))continue;if(c-3>=0){const t=a[c-3];if(gt(t,k,o,[w,I].filter(t=>Boolean(t)),-2))continue;if(O(t,k))continue}const N=[...a.slice(0,c-2),k,T];s.points=N;const B=s.labelNodeId;if(B){const t=e.get(B);if(t){const e=t.width??0,o=t.height??0;if(e>0&&o>0){let r,s,i=-1;for(let t=0;t<N.length-1;t++){const a=N[t],c=N[t+1],f=Math.hypot(c.x-a.x,c.y-a.y),d=_(a,c,n),l=H(a,c,n);(d&&f>=e+2||l&&f>=o+2)&&(f>i&&(i=f,r=(a.x+c.x)/2,s=(a.y+c.y)/2))}void 0!==r&&void 0!==s&&(t.x=r,t.y=s)}}}}}(0,l.K)(se,"portSwapToLShape"),(0,l.K)(ie,"collapseShortTerminalStub");var ae=.001,ce=q,fe=(0,l.K)((t,e)=>H(t,e,ae)||_(t,e,ae),"orthogonallyAligned");function de(t,e){const n=(0,l.K)((t,e)=>{const n=t.x??0,o=t.y??0,r=e.x-n,s=e.y-o;let i=(t.width??0)/2,a=(t.height??0)/2;return Math.abs(s)*i>Math.abs(r)*a?(s<0&&(a=-a),{x:n+(0===s?0:a*r/s),y:o+a}):(r<0&&(i=-i),{x:n+i,y:o+(0===r?0:i*s/r)})},"rectIntersect"),o=(0,l.K)((t,o)=>{const r=Q(t.points??[]);if(r.length<2)return;const s=o?t.start:t.end,i=s?e.get(s):void 0,a=i?it(i):void 0;if(!i||!s||!a)return;const c=o?r[0]:r[r.length-1],f=o?r[1]:r[r.length-2],d=n(i,c);let l=c;return fe(f,d)&&(l=f),H(d,l,ae)?{edge:t,edgeId:String(t.id??""),nodeId:s,atStart:o,orientation:"V",coord:d.x,min:Math.min(d.y,l.y),max:Math.max(d.y,l.y),boundary:d,railEnd:l,rect:a}:_(d,l,ae)?{edge:t,edgeId:String(t.id??""),nodeId:s,atStart:o,orientation:"H",coord:d.y,min:Math.min(d.x,l.x),max:Math.max(d.x,l.x),boundary:d,railEnd:l,rect:a}:void 0},"terminalLaneFor"),r=(0,l.K)((t,e)=>Math.max(0,Math.min(t.max,e.max)-Math.max(t.min,e.min)),"projectedOverlapLength"),s=(0,l.K)((t,e)=>{if(t.nodeId!==e.nodeId||t.orientation!==e.orientation)return!1;if("H"===t.orientation){return(Math.abs(t.boundary.x-t.rect.left)<1||Math.abs(t.boundary.x-t.rect.right)<1)&&H(t.boundary,e.boundary,1)}return(Math.abs(t.boundary.y-t.rect.top)<1||Math.abs(t.boundary.y-t.rect.bottom)<1)&&_(t.boundary,e.boundary,1)},"sameTerminalFace"),i=(0,l.K)((t,e)=>{if(t.nodeId!==e.nodeId||t.orientation!==e.orientation)return!1;return r(t,e)>=8&&Math.abs(t.coord-e.coord)<.5},"exactTerminalLaneConflict"),a=(0,l.K)((t,e)=>{if(t.nodeId!==e.nodeId||t.orientation!==e.orientation||"H"!==t.orientation||t.atStart===e.atStart)return!1;const n=r(t,e);if(n<8)return!1;const o=t.rect.bottom-t.rect.top;return!(n<o||n>2*o)&&(s(t,e)&&Math.abs(t.coord-e.coord)<16)},"nearTerminalLaneConflict"),c=(0,l.K)((t,e)=>{const n=Q(t.edge.points??[]);if(n.length<2)return;const o="V"===t.orientation?{x:t.boundary.x+e,y:t.boundary.y}:{x:t.boundary.x,y:t.boundary.y+e},r="V"===t.orientation?{x:t.railEnd.x+e,y:t.railEnd.y}:{x:t.railEnd.x,y:t.railEnd.y+e};if(!(0,l.K)(()=>Math.abs(t.boundary.y-t.rect.top)<1||Math.abs(t.boundary.y-t.rect.bottom)<1?_(o,t.boundary,ae)&&o.x>=t.rect.left+1&&o.x<=t.rect.right-1:(Math.abs(t.boundary.x-t.rect.left)<1||Math.abs(t.boundary.x-t.rect.right)<1)&&(H(o,t.boundary,ae)&&o.y>=t.rect.top+1&&o.y<=t.rect.bottom-1),"boundaryStaysOnSameFace")())return;if(t.atStart){const e=n.length>1&&D(n[1],t.railEnd,ae),s=n.slice(e?2:1),i=s[0];if(i&&!fe(i,r))return;return[o,r,...s]}const s=n.length>1&&D(n[n.length-2],t.railEnd,ae),i=n.slice(0,s?-2:-1),a=i[i.length-1];return!a||fe(a,r)?[...i,r,o]:void 0},"shiftedCandidate"),f=(0,l.K)(t=>{const n=t.edge,o=Q(n.points??[]);if(2!==o.length)return!1;const r=n.start,s=n.end,i=r?e.get(r):void 0,a=s?e.get(s):void 0;if(!i||!a)return!1;const c=i.x??0,f=i.y??0,d=a.x??0,l=a.y??0,[u,h]=o;return _(u,h,ae)&&Math.abs(f-l)<1&&Math.abs(c-d)>1||H(u,h,ae)&&Math.abs(c-d)<1&&Math.abs(f-l)>1},"laneIsStraightCollinearConnector"),d=[-7,7,-14,14,-21,21];for(let l=0;l<8;l++){const e=t.filter(t=>!t.isLayoutOnly).flatMap(t=>[o(t,!0),o(t,!1)]).filter(t=>Boolean(t));let n=!1;for(let t=0;t<e.length&&!n;t++)for(let r=t+1;r<e.length&&!n;r++){const s=e[t],l=e[r];if(s.edge===l.edge||!i(s,l)&&!a(s,l))continue;const u=!i(s,l),h=[s,l].sort((t,e)=>{const n=f(t),o=f(e);return n!==o?Number(n)-Number(o):Number(!e.atStart)-Number(!t.atStart)});for(const t of h){for(const r of d){const s=c(t,r);if(!s)continue;const f=o({...t.edge,points:s},t.atStart);if(f&&!e.some(e=>e.edge!==t.edge&&(i(f,e)||u&&a(f,e)))){t.edge.points=s,n=!0;break}}if(n)break}}if(!n)return}}function le(t,e){const{realNodeRects:n,labelNodeRects:o}=lt(e.values()),r=(0,l.K)((e,r)=>{const s=e.start,i=e.end,a=ce(r);if(a.length!==r.length-1)return!1;const c=[s,i].filter(t=>Boolean(t));for(const t of a){if(gt(t.a,t.b,n,c,-2))return!1;if(gt(t.a,t.b,o,[],-2))return!1}for(const n of t){if(n===e||n.isLayoutOnly)continue;const t=n.points;if(t&&!(t.length<2))for(const e of a)for(const n of ce(Q(t))){if(U(e,n,.5)>=8)return!1;if(yt(e.a,e.b,n.a,n.b,ae))return!1}}return!0},"candidateIsSafe"),s=(0,l.K)((t,e)=>{if(e+4>=t.length)return;const n=t[e],o=t[e+1],r=t[e+2],s=t[e+3],i=t[e+4],a=j(n,o)&&V(o,r)&&j(r,s)&&V(s,i)&&H(n,s,ae)&&H(n,i,ae)&&H(o,r,ae)&&(o.x-n.x)*(s.x-r.x)<0,c=V(n,o)&&j(o,r)&&V(r,s)&&j(s,i)&&_(n,s,ae)&&_(n,i,ae)&&_(o,r,ae)&&(o.y-n.y)*(s.y-r.y)<0;if(a||c)return Q([...t.slice(0,e+1),i,...t.slice(e+5)]);if(e+5>=t.length)return;const f=t[e+5],d=V(n,o)&&j(o,r)&&V(r,s)&&j(s,i)&&V(i,f)&&H(n,i,ae)&&H(n,f,ae)&&H(r,s,ae)&&(r.x-o.x)*(i.x-s.x)<0,l=j(n,o)&&V(o,r)&&j(r,s)&&V(s,i)&&j(i,f)&&_(n,i,ae)&&_(n,f,ae)&&_(r,s,ae)&&(r.y-o.y)*(i.y-s.y)<0;return d||l?Q([...t.slice(0,e+1),f,...t.slice(e+6)]):void 0},"withoutDogleg");for(let i=0;i<8;i++){let e=!1;for(const n of t){if(n.isLayoutOnly)continue;const t=Q(n.points??[]);for(let o=0;o<=t.length-5;o++){const i=s(t,o);if(i&&r(n,i)){n.points=i,e=!0;break}}if(e)break}if(!e)return}}function ue(t,e){const{realNodeRects:n,labelNodeRects:o}=lt(e.values()),r=t.filter(t=>!t.isLayoutOnly),s=(0,l.K)((t,e,n)=>Q(t===e?n??[]:t.points??[]),"pointsFor"),i=(0,l.K)((t,e)=>{let n=0;for(let o=0;o<r.length;o++){const i=ce(s(r[o],t,e));for(let a=o+1;a<r.length;a++){const o=ce(s(r[a],t,e));for(const t of i)for(const e of o)yt(t.a,t.b,e.a,e.b,ae)&&n++}}return n},"strictCrossingCount"),a=(0,l.K)(t=>{const e=ce(t);if(3!==e.length)return;const n=e[1];return e[0].horizontal!==n.horizontal&&e[2].horizontal!==n.horizontal?{index:n.index,horizontal:n.horizontal,vertical:n.vertical,segment:n}:void 0},"middleRail"),c=(0,l.K)((t,e)=>{const o=[t.start,t.end].filter(t=>Boolean(t));return n.filter(t=>{if(o.includes(t.id))return!1;const n=t.rect;if(e.horizontal){return W(e.a.x,e.b.x,n.left,n.right)>=8&&e.a.y>=n.top-2&&e.a.y<=n.bottom+2}return W(e.a.y,e.b.y,n.top,n.bottom)>=8&&e.a.x>=n.left-2&&e.a.x<=n.right+2})},"blockingRectsFor"),f=(0,l.K)((t,e,n)=>{const o=t.map(t=>({...t}));if(e.horizontal)o[e.index].y=n,o[e.index+1].y=n;else{if(!e.vertical)return;o[e.index].x=n,o[e.index+1].x=n}const r=wt(Q(o));return ce(r).length===r.length-1?r:void 0},"candidateByMovingRail"),d=(0,l.K)((t,e,a)=>{const c=[t.start,t.end].filter(t=>Boolean(t)),f=ce(e);if(f.length!==e.length-1)return!1;for(const r of f){if(gt(r.a,r.b,n,c,-2))return!1;if(gt(r.a,r.b,o,[],-2))return!1}for(const n of r)if(n!==t)for(const t of f)for(const e of ce(s(n)))if(U(t,e,.5)>=8)return!1;return i(t,e)<=a},"candidateIsSafe");for(let l=0;l<8;l++){const t=i();let e=!1;for(const n of r){const o=s(n),r=a(o);if(!r)continue;const i=c(n,r.segment);if(0===i.length)continue;const l=r.horizontal?[Math.min(...i.map(t=>t.rect.top))-20,Math.max(...i.map(t=>t.rect.bottom))+20]:[Math.min(...i.map(t=>t.rect.left))-20,Math.max(...i.map(t=>t.rect.right))+20];for(const s of l){const i=f(o,r.segment,s);if(i&&d(n,i,t)){n.points=i,e=!0;break}}if(e)break}if(!e)return}}function he(t,e){const n=(0,l.K)(t=>{const e=t.groupTitleRect;if(e&&"number"==typeof e.left&&"number"==typeof e.right&&"number"==typeof e.top&&"number"==typeof e.bottom&&Number.isFinite(e.left)&&Number.isFinite(e.right)&&Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&!(e.right<=e.left)&&!(e.bottom<=e.top))return{left:e.left,right:e.right,top:e.top,bottom:e.bottom}},"validTitleRect"),o=(0,l.K)(t=>{if(!t.isGroup||t.parentId)return;const e=t.direction,o="string"==typeof e?e.toUpperCase():"";if("LR"===o||"RL"===o||"BT"===o)return;const r=n(t),s=t.y,i=t.height;if(!r||"number"!=typeof s||"number"!=typeof i||!Number.isFinite(s)||!Number.isFinite(i)||i<=0)return;const a=r.right-r.left,c=r.bottom-r.top;return c<=0||a<c?void 0:{node:t,rect:r}},"topLaneTitleFor"),r=(0,l.K)((t,e)=>{if(!t.horizontal)return!1;const n=t.a.y;return!(n<=e.top+ae||n>=e.bottom-ae)&&W(t.a.x,t.b.x,e.left,e.right)>=8},"horizontalSegmentIntersectsTitle"),s=[...e.values()].map(o).filter(t=>Boolean(t));if(0===s.length)return;let i=0;for(const a of t){if(a.isLayoutOnly)continue;const t=Q(a.points??[]);for(const e of ce(t))for(const t of s)r(e,t.rect)&&(i=Math.max(i,t.rect.bottom-e.a.y+4))}if(!(i<=ae))for(const a of s){const t=a.node.y,e=a.node.height;"number"!=typeof t||"number"!=typeof e||!Number.isFinite(t)||!Number.isFinite(e)||e<=0||(a.node.y=t-i/2,a.node.height=e+i,a.node.groupTitleRect={...a.rect,top:a.rect.top-i,bottom:a.rect.bottom-i})}}function ge(t,e){const n=(0,l.K)(t=>{const e=t.groupTitleRect;if(e&&"number"==typeof e.left&&"number"==typeof e.right&&"number"==typeof e.top&&"number"==typeof e.bottom&&Number.isFinite(e.left)&&Number.isFinite(e.right)&&Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&!(e.right<=e.left)&&!(e.bottom<=e.top))return{left:e.left,right:e.right,top:e.top,bottom:e.bottom}},"validTitleRect"),o=(0,l.K)(t=>{if(!t.isGroup||t.parentId)return;if("LR"!==t.direction)return;const e=n(t),o=t.x,r=t.width;if(!e||"number"!=typeof o||"number"!=typeof r||!Number.isFinite(o)||!Number.isFinite(r)||r<=0)return;const s=e.right-e.left,i=e.bottom-e.top;return s<=0||i<s?void 0:{node:t,rect:e}},"leftLaneTitleFor"),r=(0,l.K)((t,e)=>{if(!t.vertical)return!1;const n=t.a.x;return!(n<=e.left+ae||n>=e.right-ae)&&W(t.a.y,t.b.y,e.top,e.bottom)>=8},"verticalSegmentIntersectsTitle"),s=(0,l.K)((t,e)=>{if(!t.horizontal)return!1;const n=t.a.y;return!(n<=e.top+ae||n>=e.bottom-ae)&&W(t.a.x,t.b.x,e.left,e.right)>=8},"horizontalSegmentIntersectsTitle"),i=[...e.values()].map(o).filter(t=>Boolean(t));if(0===i.length)return;let a=0;for(const c of t){if(c.isLayoutOnly)continue;const t=Q(c.points??[]);for(const e of ce(t))for(const t of i)if(r(e,t.rect))a=Math.max(a,t.rect.right-e.a.x+4);else if(s(e,t.rect)){const n=Math.min(e.a.x,e.b.x);a=Math.max(a,t.rect.right-n+4)}}if(!(a<=ae))for(const c of i){const t=c.node.x,e=c.node.width;"number"!=typeof t||"number"!=typeof e||!Number.isFinite(t)||!Number.isFinite(e)||e<=0||(c.node.x=t-a/2,c.node.width=e+a,c.node.groupTitleRect={...c.rect,left:c.rect.left-a,right:c.rect.right-a})}}function pe(t,e){const{realNodeRects:n}=lt(e.values()),o=t.filter(t=>!t.isLayoutOnly),r=(0,l.K)((t,e=new Map)=>Q(e.get(t)??t.points??[]),"replacementPointsFor"),s=(0,l.K)((t=new Map)=>{let e=0;for(let n=0;n<o.length;n++){const s=ce(r(o[n],t));for(let i=n+1;i<o.length;i++){const n=ce(r(o[i],t));for(const t of s)for(const o of n)yt(t.a,t.b,o.a,o.b,ae)&&e++}}return e},"crossingCount"),i=(0,l.K)((t=new Map)=>o.reduce((e,n)=>e+J(r(n,t)),0),"totalBends"),a=(0,l.K)(t=>{const e=r(t);if(e.length<4)return;const n=e[e.length-2],o=e[e.length-1];return j(n,o,ae)||V(n,o,ae)?{tailStart:n,terminal:o}:void 0},"terminalTailFor"),c=(0,l.K)((t,e)=>{const n=r(t);if(n.length<3)return;const o=n[0],s=n[1];let i;if(j(o,s,ae))i={x:s.x,y:e.tailStart.y};else{if(!V(o,s,ae))return;i={x:e.tailStart.x,y:s.y}}const a=wt(Q([o,s,i,e.tailStart,e.terminal]));return ce(a).length===a.length-1?a:void 0},"candidateWithDestinationTail"),f=(0,l.K)((t,e)=>{const o=[t.start,t.end].filter(t=>Boolean(t));for(const r of ce(e))if(gt(r.a,r.b,n,o,-2))return!0;return!1},"pathHasNodeHit"),d=(0,l.K)((t,e,n)=>{for(const s of o)if(s!==t)for(const t of ce(e))for(const e of ce(r(s,n)))if(U(t,e,.5)>=8)return!0;return!1},"pathHasSharedTrack"),u=(0,l.K)((t,e,n)=>!f(t,e)&&!d(t,e,n),"candidateIsSafe"),h=(0,l.K)(()=>{const t=new Map;for(const n of o){const o=n.end;if(!o||!e.has(o))continue;if(r(n).length<4)continue;const s=t.get(o)??[];s.push(n),t.set(o,s)}return t},"edgesByDestination");for(let l=0;l<4;l++){const t=s();if(0===t)return;let e,n=t,o=i();for(const r of h().values())for(let f=0;f<r.length;f++)for(let d=f+1;d<r.length;d++){const l=r[f],h=r[d],g=a(l),p=a(h);if(!g||!p)continue;const x=c(l,p),m=c(h,g);if(!x||!m)continue;const y=new Map([[l,x],[h,m]]);if(!u(l,x,y)||!u(h,m,y))continue;const b=s(y),M=i(y);b>=t||(b>n||b===n&&M>=o||(e=y,n=b,o=M))}if(!e)return;for(const[r,s]of e)r.points=s}}function xe(t,e){const{realNodeRects:n,labelNodeRects:o}=lt(e.values()),r=t.filter(t=>!t.isLayoutOnly),s=(0,l.K)((t,e=new Map)=>Q(e.get(t)??t.points??[]),"replacementPointsFor"),i=(0,l.K)((t=new Map)=>{let e=0;for(let n=0;n<r.length;n++){const o=ce(s(r[n],t));for(let i=n+1;i<r.length;i++){const n=ce(s(r[i],t));for(const t of o)for(const o of n)yt(t.a,t.b,o.a,o.b,ae)&&e++}}return e},"strictCrossingCount"),a=(0,l.K)((t=new Map)=>r.reduce((e,n)=>e+J(s(n,t)),0),"totalBends"),c=(0,l.K)(t=>{const n=t.start,o=t.end,r=n?e.get(n):void 0,s=o?e.get(o):void 0,i=r?it(r):void 0,a=s?it(s):void 0;return i&&a?{src:i,dst:a}:void 0},"endpointRectsFor"),f=(0,l.K)((t,e,n)=>{if(n.index<=0||n.index+1>=e.length-1)return;const o=c(t);if(o){if(n.vertical){const r=n.a.x,s=Math.min(o.src.left,o.dst.left),i=Math.max(o.src.right,o.dst.right),a=r<s-ae?"left":r>i+ae?"right":void 0;if(!a)return;return{edge:t,points:e,segmentIndex:n.index,axis:"vertical",side:a,coord:r,min:Math.min(n.a.y,n.b.y),max:Math.max(n.a.y,n.b.y)}}if(n.horizontal){const r=n.a.y,s=Math.min(o.src.top,o.dst.top),i=Math.max(o.src.bottom,o.dst.bottom),a=r<s-ae?"top":r>i+ae?"bottom":void 0;if(!a)return;return{edge:t,points:e,segmentIndex:n.index,axis:"horizontal",side:a,coord:r,min:Math.min(n.a.x,n.b.x),max:Math.max(n.a.x,n.b.x)}}}},"externalRailForSegment"),d=(0,l.K)(()=>{const t=[];for(const e of r){const n=s(e);for(const o of ce(n)){const r=f(e,n,o);r&&t.push(r)}}return t},"collectExternalRails"),u=(0,l.K)((t,e)=>t.edge!==e.edge&&t.axis===e.axis&&t.side===e.side&&W(t.min,t.max,e.min,e.max)>=8,"railsInteract"),h=(0,l.K)(t=>{const e=[],n=new Set;for(const o of t){if(n.has(o))continue;const r=[o],s=[];for(n.add(o);r.length>0;){const e=r.pop();s.push(e);for(const o of t)!n.has(o)&&u(e,o)&&(n.add(o),r.push(o))}s.length>1&&e.push(s)}return e},"connectedComponents"),g=(0,l.K)(t=>{const e=[];for(const n of t)e.some(t=>Math.abs(t-n.coord)<ae)||e.push(n.coord);for(;e.length<t.length;){const n=Math.min(...e),o=Math.max(...e),r=t[0].side;e.push("left"===r||"top"===r?n-12*(t.length-e.length):o+12*(t.length-e.length))}return e},"uniqueCoordsFor"),p=(0,l.K)(t=>{const e=t.map(t=>t.coord),n=g(t),o=[];if(t.length<=6){const r=new Array(n.length).fill(!1),s=[],i=(0,l.K)(()=>{if(s.length!==t.length)for(const[t,e]of n.entries())r[t]||(r[t]=!0,s.push(e),i(),s.pop(),r[t]=!1);else s.some((t,n)=>Math.abs(t-e[n])>=ae)&&o.push([...s])},"visit");return i(),o}for(let r=0;r<e.length;r++)for(let t=r+1;t<e.length;t++){const n=[...e];[n[r],n[t]]=[n[t],n[r]],o.push(n)}return o},"coordinateAssignmentsFor"),x=(0,l.K)((t,e)=>{const n=new Map;for(const[r,s]of t.entries()){const t=e[r],o=n.get(s.edge)??s.points.map(t=>({x:t.x,y:t.y}));"vertical"===s.axis?(o[s.segmentIndex].x=t,o[s.segmentIndex+1].x=t):(o[s.segmentIndex].y=t,o[s.segmentIndex+1].y=t),n.set(s.edge,o)}const o=new Map;for(const[r,s]of n){const t=wt(Q(s));if(ce(t).length!==t.length-1)return;o.set(r,t)}return o},"replacementsForAssignment"),m=(0,l.K)(t=>{for(const[e,r]of t){const t=[e.start,e.end].filter(t=>Boolean(t));for(const e of ce(r)){if(gt(e.a,e.b,n,t,-2))return!1;if(gt(e.a,e.b,o,[],-2))return!1}}for(let e=0;e<r.length;e++){const n=r[e],o=t.has(n),i=ce(s(n,t));for(let a=e+1;a<r.length;a++){const e=r[a];if(!o&&!t.has(e))continue;const n=ce(s(e,t));for(const t of i)for(const e of n)if(U(t,e,.5)>=8)return!1}}return!0},"candidateIsSafe");for(let l=0;l<4;l++){const t=i();if(0===t)return;let e,n=t,o=a(),r=Number.POSITIVE_INFINITY;for(const s of h(d()))for(const c of p(s)){const f=x(s,c);if(!f||!m(f))continue;const d=i(f);if(d>=t)continue;const l=a(f),u=s.reduce((t,e,n)=>t+Math.abs(c[n]-e.coord),0);d>n||d===n&&(l>o||l===o&&u>=r)||(e=f,n=d,o=l,r=u)}if(!e)return;for(const[s,i]of e)s.points=i}}function me(t,e){const{realNodeRects:n,labelNodeRects:o}=lt(e.values()),r=t.filter(t=>!t.isLayoutOnly),s=(0,l.K)((t,e,n)=>Q(t===e?n??[]:t.points??[]),"pointsFor"),i=(0,l.K)(t=>ce(t).reduce((t,e)=>{const n=e.a.x-e.b.x,o=e.a.y-e.b.y;return t+Math.hypot(n,o)},0),"pathLength"),a=(0,l.K)((t,e)=>{let n=0;for(let o=0;o<r.length;o++){const i=ce(s(r[o],t,e));for(let a=o+1;a<r.length;a++){const o=ce(s(r[a],t,e));for(const t of i)for(const e of o)yt(t.a,t.b,e.a,e.b,ae)&&n++}}return n},"strictCrossingCount"),c=(0,l.K)((t,e)=>{if(t.horizontal){const n=t.a.y;return(Math.abs(n-e.top)<1||Math.abs(n-e.bottom)<1)&&W(t.a.x,t.b.x,e.left,e.right)>=8}if(t.vertical){const n=t.a.x;return(Math.abs(n-e.left)<1||Math.abs(n-e.right)<1)&&W(t.a.y,t.b.y,e.top,e.bottom)>=8}return!1},"segmentRunsAlongRectBorder"),f=(0,l.K)(t=>{const n=[t.start,t.end].filter(t=>Boolean(t)),o=[];for(const r of n){const t=e.get(r),n=t?it(t):void 0;n&&o.push(n)}return o},"endpointRectsFor"),d=(0,l.K)((t,e)=>{if(e+3>=t.length)return[];const n=t[e],o=t[e+1],r=t[e+2],s=t[e+3],i=j(n,o,ae)&&V(o,r,ae)&&j(r,s,ae),a=V(n,o,ae)&&j(o,r,ae)&&V(r,s,ae);if(!i&&!a)return[];if(!(i?Math.sign(o.x-n.x)!==Math.sign(s.x-r.x):Math.sign(o.y-n.y)!==Math.sign(s.y-r.y)))return[];const c=H(n,s,ae)||_(n,s,ae)?[]:[{x:n.x,y:s.y},{x:s.x,y:n.y}],f=0===c.length?[[...t.slice(0,e+1),...t.slice(e+3)]]:c.map(n=>[...t.slice(0,e+1),n,...t.slice(e+3)]),d=new Set;return f.map(t=>wt(Q(t))).filter(t=>{if(ce(t).length!==t.length-1)return!1;if(!t.some(t=>D(t,s,ae)))return!1;const e=t.map(t=>`${t.x.toFixed(3)},${t.y.toFixed(3)}`).join("|");return!d.has(e)&&(d.add(e),!0)})},"shortcutCandidatesAt"),u=(0,l.K)((t,e,i)=>{const d=[t.start,t.end].filter(t=>Boolean(t)),l=f(t);for(const r of ce(e)){if(gt(r.a,r.b,n,d,-2))return!1;if(gt(r.a,r.b,o,[],-2))return!1;if(l.some(t=>c(r,t)))return!1}for(const n of r)if(n!==t)for(const t of ce(e))for(const e of ce(s(n)))if(U(t,e,.5)>=8)return!1;return a(t,e)<=i},"candidateIsSafe");for(let l=0;l<8;l++){const t=a();let e,n,o=t,c=Number.POSITIVE_INFINITY,f=Number.POSITIVE_INFINITY;for(const l of r){const r=s(l),h=J(r,ae),g=i(r);for(let s=0;s<=r.length-4;s++)for(const p of d(r,s)){const r=J(p,ae),s=i(p);if(!(r<h||r===h&&s<g-ae)||!u(l,p,t))continue;const d=a(l,p);d>o||d===o&&(r>c||r===c&&s>=f)||(e=l,n=p,o=d,c=r,f=s)}}if(!e||!n)return;e.points=n}}function ye(t,e){const n=20,o=[];for(const l of e.values()){if(l.isGroup||l.isEdgeLabel)continue;const t=l.x??0,e=l.y??0,n=it(l);n&&o.push({id:String(l.id??""),cx:t,cy:e,rect:n})}if(0===o.length)return;const r=new Map(o.map(t=>[t.id,t])),s=o.map(t=>({id:t.id,rect:t.rect})),i=["top","bottom","left","right"],a={top:Math.min(...o.map(t=>t.rect.top))-n,bottom:Math.max(...o.map(t=>t.rect.bottom))+n,left:Math.min(...o.map(t=>t.rect.left))-n,right:Math.max(...o.map(t=>t.rect.right))+n},c=t.filter(t=>!t.isLayoutOnly),f=new Map(c.map((t,e)=>[t,e])),d=(0,l.K)(t=>{const e="left"===t||"top"===t?-1:1,o=[];for(let r=0;r<=2;r++)o.push(a[t]+e*n*r);return o},"outwardTracksForSide"),u=(0,l.K)((t,e=new Map)=>Q(e.get(t)??t.points??[]),"replacementPointsFor"),h=(0,l.K)((t,e)=>{let n=0;for(const o of t)for(const t of e)yt(o.a,o.b,t.a,t.b,ae)&&n++;return n},"crossingCountBetweenSegments"),g=(0,l.K)((t,e)=>h(ce(t),ce(e)),"crossingCountBetweenPaths"),p=(0,l.K)((t=new Map)=>{let e=0;const n=[],o=new Set,r=[],s=(0,l.K)(t=>{o.has(t)||(o.add(t),r.push(t))},"addEdge");for(let i=0;i<c.length;i++){const o=c[i],r=u(o,t);for(let a=i+1;a<c.length;a++){const i=c[a],f=g(r,u(i,t));f>0&&(e+=f,n.push({first:o,second:i,count:f}),s(o),s(i))}}return r.sort((t,e)=>(f.get(t)??0)-(f.get(e)??0)),{count:e,pairs:n,edgeSet:o,edges:r}},"crossingSnapshot"),x=(0,l.K)((t,e)=>{const n=new Set(e.keys());if(0===n.size)return t.count;let o=0;for(const s of t.pairs)(n.has(s.first)||n.has(s.second))&&(o+=s.count);let r=0;for(let s=0;s<c.length;s++){const t=c[s],o=n.has(t),i=u(t,e);for(let a=s+1;a<c.length;a++){const t=c[a];(o||n.has(t))&&(r+=g(i,u(t,e)))}}return t.count-o+r},"crossingCountWithReplacements"),m=(0,l.K)(t=>{const e=new Map;for(const r of t.pairs){const t=e.get(r.first)??new Set;t.add(r.second),e.set(r.first,t);const n=e.get(r.second)??new Set;n.add(r.first),e.set(r.second,n)}const n=[],o=new Set;for(const r of t.edges){if(o.has(r))continue;const t=[r],s=[];for(o.add(r);t.length>0;){const n=t.pop();s.push(n);for(const r of e.get(n)??[])o.has(r)||(o.add(r),t.push(r))}s.sort((t,e)=>(f.get(t)??0)-(f.get(e)??0)),s.length>1&&n.push(s)}return n},"crossingComponents"),y=(0,l.K)(t=>[t.start,t.end].filter(t=>Boolean(t)),"endpointIdsFor"),b=(0,l.K)(t=>{const e=[];for(const n of m(t)){const t=new Set(n),o=new Set(n.flatMap(t=>y(t))),r=[...n];for(const e of c)t.has(e)||y(e).some(t=>o.has(t))&&r.push(e);r.sort((t,e)=>(f.get(t)??0)-(f.get(e)??0)),e.push(r)}return e},"pairSearchGroups"),M=(0,l.K)((t,e,n)=>x(t,new Map([[e,n]])),"crossingCountWithSingleReplacement"),K=(0,l.K)(t=>{const e=new Map;for(const n of t.pairs)e.set(n.first,(e.get(n.first)??0)+n.count),e.set(n.second,(e.get(n.second)??0)+n.count);return e},"currentCrossingsByEdge"),I=(0,l.K)(t=>t.slice(1).reduce((e,n,o)=>{const r=t[o];return e+Math.abs(n.x-r.x)+Math.abs(n.y-r.y)},0),"pathLength"),w=(0,l.K)((t=new Map)=>c.reduce((e,n)=>e+J(u(n,t)),0),"totalBends"),S=(0,l.K)((t=new Map)=>c.reduce((e,n)=>e+I(u(n,t)),0),"totalLength"),v=(0,l.K)((t,e,n=new Map)=>{const o=ce(e);for(const r of c)if(r!==t)for(const t of o)for(const e of ce(u(r,n)))if(U(t,e,.5)>=8)return!0;return!1},"pathHasSegmentConflict"),C=(0,l.K)((t,e)=>{const n=[t.start,t.end].filter(t=>Boolean(t));for(const o of ce(e))if(gt(o.a,o.b,s,n,-2))return!0;return!1},"pathHitsNode"),L=(0,l.K)((t,e)=>{const n=wt(Q(e));ce(n).length===n.length-1&&t.push(n)},"pushOrthogonalCandidate"),k=(0,l.K)(t=>"left"===t||"right"===t,"sideIsHorizontal"),T=(0,l.K)((t,e,o)=>{switch(e){case"left":return Math.min(t.x,o.x)-n;case"right":return Math.max(t.x,o.x)+n;case"top":return Math.min(t.y,o.y)-n;case"bottom":return Math.max(t.y,o.y)+n}},"localTrackForSameSide"),$=(0,l.K)((t,e,o,r)=>{const s="left"===o||"top"===o?-1:1,i=[T(e,o,r),a[o]];for(const a of i)for(let i=0;i<=2;i++)L(t,ft(e,o,r,a+s*n*i))},"addSameSideCandidates"),R=(0,l.K)((t,e,n,o,r)=>{for(const s of d(n))for(const n of d(r))L(t,[e,{x:s,y:e.y},{x:s,y:n},{x:o.x,y:n},o])},"addHorizontalToVerticalCandidates"),O=(0,l.K)((t,e,n,o,r)=>{for(const s of d(n))for(const n of d(r))L(t,[e,{x:e.x,y:s},{x:n,y:s},{x:n,y:o.y},o])},"addVerticalToHorizontalCandidates"),N=(0,l.K)((t,e,n,o,r)=>{const s=[...d("top"),...d("bottom")];for(const i of d(n))for(const n of d(r))for(const r of s)L(t,[e,{x:i,y:e.y},{x:i,y:r},{x:n,y:r},{x:n,y:o.y},o])},"addHorizontalPairCandidates"),B=(0,l.K)((t,e,n,o,r)=>{const s=[...d("left"),...d("right")];for(const i of d(n))for(const n of d(r))for(const r of s)L(t,[e,{x:e.x,y:i},{x:r,y:i},{x:r,y:n},{x:o.x,y:n},o])},"addVerticalPairCandidates"),E=(0,l.K)(t=>{const e=new Set;return t.map(t=>Q(t)).filter(t=>{const n=t.map(t=>`${t.x.toFixed(3)},${t.y.toFixed(3)}`).join("|");return!(e.has(n)||t.length<2)&&(e.add(n),!0)})},"dedupeCandidatePaths"),F=(0,l.K)((t,e,o,r)=>{const s=[],i=ct(t,e,o,r,n,ae);i&&L(s,i),e===r&&$(s,t,e,o);const a=k(e),c=k(r);return a&&!c?R(s,t,e,o,r):!a&&c?O(s,t,e,o,r):a?N(s,t,e,o,r):B(s,t,e,o,r),E(s)},"buildCandidatesForSides"),Y=(0,l.K)((t,e,n,o)=>{const r=[...d("left"),...d("right")],s=[...d("top"),...d("bottom")];for(const a of i){const i=at(o,a),c="top"===a||"bottom"===a?d(a):s;for(const o of r){L(t,[e,n,{x:o,y:n.y},{x:o,y:i.y},i]);for(const r of c)L(t,[e,n,{x:o,y:n.y},{x:o,y:r},{x:i.x,y:r},i])}}},"addVerticalDepartureOuterTrackCandidates"),X=(0,l.K)((t,e,n,o)=>{const r=[...d("left"),...d("right")],s=[...d("top"),...d("bottom")];for(const a of i){const i=at(o,a),c="left"===a||"right"===a?d(a):r;for(const o of s){L(t,[e,n,{x:n.x,y:o},{x:i.x,y:o},i]);for(const r of c)L(t,[e,n,{x:n.x,y:o},{x:r,y:o},{x:r,y:i.y},i])}}},"addHorizontalDepartureOuterTrackCandidates"),P=(0,l.K)(t=>{const e=t.start,n=t.end,o=n?r.get(n):void 0;if(!e||!o)return[];const s=Q(t.points??[]);if(s.length<4)return[];const i=s[0],a=s[1],c=[];return V(i,a,ae)?Y(c,i,a,o):j(i,a,ae)&&X(c,i,a,o),c},"terminalPreservingOuterTrackCandidates"),z=(0,l.K)(t=>{const e=t.start,n=t.end,o=e?r.get(e):void 0,s=n?r.get(n):void 0;if(!o||!s)return[];const a=[];for(const r of i){const t=at(o,r);for(const e of i)a.push(...F(t,r,at(s,e),e))}return a.push(...P(t)),a},"candidatePathsFor"),A=(0,l.K)(()=>new Map(c.map(t=>[t,ce(u(t))])),"currentSegmentsByEdge"),G=(0,l.K)((t,e,n)=>{const o=new Set;for(const r of c){if(r===t)continue;const s=n.get(r)??ce(u(r));e.some(t=>s.some(e=>U(t,e,.5)>=8))&&o.add(r)}return o},"sharedTrackConflictsFor"),D=(0,l.K)((t,e,n,o)=>{const r=new Set;return z(t).map(t=>wt(Q(t))).filter(e=>{if(C(t,e))return!1;const n=e.map(t=>`${t.x.toFixed(3)},${t.y.toFixed(3)}`).join("|");return!(r.has(n)||e.length<2)&&(r.add(n),!0)}).map(r=>{const s=ce(r);let i=0;for(const e of c)e!==t&&(i+=h(s,n.get(e)??ce(u(e))));return{candidate:r,candidateSegments:s,crossings:e.count-(o.get(t)??0)+i,bends:J(r,ae),totalBends:J(r),length:I(r)}}).filter(({crossings:t})=>t<=e.count).sort((t,e)=>t.crossings-e.crossings||t.bends-e.bends||t.length-e.length).slice(0,48).map(e=>({path:e.candidate,segments:e.candidateSegments,sharedTrackConflicts:G(t,e.candidateSegments,n),totalBends:e.totalBends,length:e.length}))},"pairCandidatesFor"),H=(0,l.K)((t,e,n,o,r,s)=>{let i=0;for(const c of t.pairs)c.first!==e&&c.second!==e&&c.first!==o&&c.second!==o||(i+=c.count);let a=h(n.segments,r.segments);for(const f of c){if(f===e||f===o)continue;const t=s.get(f)??ce(u(f));a+=h(n.segments,t)+h(r.segments,t)}return t.count-i+a},"pairCrossingCount"),_=(0,l.K)((t,e)=>{for(const n of t.sharedTrackConflicts)if(n!==e)return!1;return!0},"conflictsOnlyWith"),W=(0,l.K)((t,e)=>t.segments.some(t=>e.segments.some(e=>U(t,e,.5)>=8)),"candidatesShareTrack"),q=(0,l.K)((t,e,n,o)=>_(e,n.edge)&&_(o,t.edge)&&!W(e,o),"pairCandidatesAreCompatible"),Z=(0,l.K)((t,e,n,o,r)=>{const s=H(t.current,e.edge,n,o.edge,r,t.baseSegments);if(!(s>=t.current.count))return{replacements:new Map([[e.edge,n.path],[o.edge,r.path]]),crossings:s,bends:t.currentBends-(t.baseBendsByEdge.get(e.edge)??0)-(t.baseBendsByEdge.get(o.edge)??0)+n.totalBends+r.totalBends,length:t.currentLength-(t.baseLengthByEdge.get(e.edge)??0)-(t.baseLengthByEdge.get(o.edge)??0)+n.length+r.length}},"scorePairReplacement"),tt=(0,l.K)((t,e)=>t.crossings<e.crossings||t.crossings===e.crossings&&(t.bends<e.bends||t.bends===e.bends&&t.length<e.length),"pairScoreIsBetter"),et=(0,l.K)((t,e,n,o)=>{let r=o;for(const s of e.candidates)for(const o of n.candidates){if(!q(e,s,n,o))continue;const i=Z(t,e,s,n,o);i&&tt(i,r)&&(r=i)}return r},"bestScoreForOptionPair"),nt=(0,l.K)(t=>{const e=w(),n=S(),o=A(),r=K(t),s=new Map(c.map(t=>[t,J(u(t))])),i=new Map(c.map(t=>[t,I(u(t))])),a=new Map,f=b(t);for(const c of f)for(const e of c){if(a.has(e))continue;const n=D(e,t,o,r);n.length>0&&a.set(e,{edge:e,candidates:n})}let d={replacements:new Map,crossings:t.count,bends:e,length:n};const l={current:t,currentBends:e,currentLength:n,baseBendsByEdge:s,baseLengthByEdge:i,baseSegments:o};for(const c of f){const e=new Set(c.filter(e=>t.edgeSet.has(e))),n=c.map(t=>a.get(t)).filter(t=>Boolean(t));for(let t=0;t<n.length;t++){const o=n[t];for(let r=t+1;r<n.length;r++){const t=n[r];(e.has(o.edge)||e.has(t.edge))&&(d=et(l,o,t,d))}}}return d.replacements.size>0?d.replacements:void 0},"bestPairedReplacement");for(let l=0;l<4;l++){const t=p(),e=t.count;if(0===e)return;let n,o,r=e,s=Number.POSITIVE_INFINITY;for(const a of t.edges){const i=J(u(a),ae);for(const c of z(a)){const f=C(a,c),d=!f&&v(a,c),l=M(t,a,c),u=J(c,ae);if(f||d)continue;(l<e||l===e&&u<i)&&(l>r||l===r&&u>=s||(n=a,o=c,r=l,s=u))}}if(n&&o){n.points=o;continue}const i=nt(t);if(!i)return;for(const[a,c]of i)a.points=c}}(0,l.K)(de,"separateSharedRenderedTerminalLanes"),(0,l.K)(le,"collapseRedundantRectangularDoglegs"),(0,l.K)(ue,"liftObstacleHuggingSameSideRails"),(0,l.K)(he,"liftTopLaneTitleBandsAboveRails"),(0,l.K)(ge,"shiftLeftLaneTitleBandsLeftOfRails"),(0,l.K)(pe,"swapDestinationTerminalTailsToReduceCrossings"),(0,l.K)(xe,"reassignCrossingExternalRailChannels"),(0,l.K)(me,"shortcutRedundantOrthogonalJogs"),(0,l.K)(ye,"resolveRenderedOrthogonalCrossings");var be=.001;function Me(t,e){const{nodeInfoById:n,realNodeRects:o}=dt(e),r=["top","bottom","left","right"],s={top:Math.min(...o.map(t=>t.rect.top))-20,bottom:Math.max(...o.map(t=>t.rect.bottom))+20,left:Math.min(...o.map(t=>t.rect.left))-20,right:Math.max(...o.map(t=>t.rect.right))+20},i=(0,l.K)((t,e,n,o)=>{const r=[],i=ct(t,e,n,o,20,be);return i&&r.push(i),e===o&&r.push(ft(t,e,n,s[e])),r},"buildOrthogonalPathCandidates"),a=(0,l.K)((t,e)=>{for(let n=0;n<t.length-1;n++){if(gt(t[n],t[n+1],o,e,1))return!0}return!1},"pathHitsNode"),c=(0,l.K)((e,n,o=!1)=>{let r=0;const s=q(e,be),i=n.start,a=n.end;for(const c of t){if(c===n||c.isLayoutOnly)continue;const t=c.start,e=c.end;if(!o&&i&&a&&(t===i||t===a||e===i||e===a))continue;const f=c.points;if(f&&!(f.length<2))for(const n of s)for(const t of q(f,be))(pt(n.a,n.b,t.a,t.b,be,be)||U(n,t,be)>=8)&&r++}return r},"pathConflictCount"),f=(0,l.K)((t,e)=>{const n=Math.abs(t.y-e.rect.top),o=Math.abs(t.y-e.rect.bottom),r=Math.abs(t.x-e.rect.left),s=Math.abs(t.x-e.rect.right);let i="top",a=n;return o<a&&(i="bottom",a=o),r<a&&(i="left",a=r),s<a&&(i="right",a=s),i},"nearestSideOfRect"),d=new Map,u=(0,l.K)((t,e,n)=>{const o=d.get(t)??[];o.push({side:e,edgeId:n}),d.set(t,o)},"addFaceClaim");for(const l of t){if(l.isLayoutOnly)continue;const t=l.points??[];if(t.length<1)continue;const e=l.id??"",o=l.start,r=l.end;if(o){const r=n.get(o);r&&u(o,f(t[0],r),e)}if(r){const o=n.get(r);o&&u(r,f(t[t.length-1],o),e)}}const h=(0,l.K)((t,e,n)=>d.get(t)?.some(t=>t.edgeId!==n&&t.side===e)??!1,"faceIsClaimed");for(const l of t){if(l.isLayoutOnly)continue;const t=l.points;if(!t||t.length<2)continue;const e=J(t,be);if(e<4)continue;const o=l.start,s=l.end;if(!o||!s)continue;const g=n.get(o),p=n.get(s);if(!g||!p)continue;const x=l.id??"",m=c(t,l,!0),y=c(t,l);let b,M=m,K=e;for(const n of r){if(h(o,n,x))continue;const t=at(g,n);for(const e of r){if(h(s,e,x))continue;const r=at(p,e);for(const f of i(t,n,r,e)){if(a(f,[o,s]))continue;const t=J(f,be);if(m>0){const e=c(f,l,!0);if(e>M||e===M&&t>=K)continue;M=e,K=t,b=f;continue}c(f,l)>y||t<K&&(K=t,b=f)}}}if(b){l.points=b;const t=d.get(o);t&&d.set(o,t.filter(t=>t.edgeId!==x));const e=d.get(s);e&&d.set(s,e.filter(t=>t.edgeId!==x)),u(o,f(b[0],g),x),u(s,f(b[b.length-1],p),x)}}}(0,l.K)(Me,"simplifyDetouredEdges");var Ke=.001;function Ie(t,e){const n=e?0:t.length-1,o=e?1:-1,r=t[n],s=t[n+o];if(!r||!s)return;const i=s.x-r.x,a=s.y-r.y;if(!(Math.abs(i)+Math.abs(a)<Ke)){if(Math.abs(a)<=Ke){const t=r.x+10*Math.sign(i);return{left:Math.min(r.x,t),right:Math.max(r.x,t),top:r.y-7,bottom:r.y+7}}if(Math.abs(i)<=Ke){const t=r.y+10*Math.sign(a);return{left:r.x-7,right:r.x+7,top:Math.min(r.y,t),bottom:Math.max(r.y,t)}}return{left:Math.min(r.x,s.x),right:Math.max(r.x,s.x),top:Math.min(r.y,s.y),bottom:Math.max(r.y,s.y)}}}function we(t){return{left:Math.min(t.left,t.right),right:Math.max(t.left,t.right),top:Math.min(t.top,t.bottom),bottom:Math.max(t.top,t.bottom)}}function Se(t,e){const n=Q(e);return[Ie(n,!0),Ie(n,!1)].some(e=>e&&ot(t,we(e)))}function ve(t,e){const n=[];for(const l of t){if(l.isLayoutOnly)continue;const t=l.points;if(t&&!(t.length<2))for(let e=0;e<t.length-1;e++)n.push({edgeId:l.id,p1:t[e],p2:t[e+1]})}const o=[],r=[];for(const l of e.values()){const t=l.isGroup,e=l.parentId;if(t&&!e){const t=it(l);t&&r.push({id:l.id,rect:t});continue}if(t)continue;if(l.isEdgeLabel)continue;const n=it(l);n&&o.push({nodeId:l.id,rect:n})}const s=(0,l.K)((t,e)=>{const n=rt(e,3);for(const{nodeId:r,rect:s}of o)if(r!==t&&ot(n,s))return!0;return!1},"labelOverlapsForeignNode"),i=(0,l.K)((t,e)=>{const o=rt(e,3);for(const r of n)if(r.edgeId!==t&&tt(r.p1,r.p2,o))return!0;return!1},"labelOverlapsForeignEdge"),a=(0,l.K)((t,e,n)=>s(t,n)||i(e,n),"labelOverlapsAnything"),c=[],f=(0,l.K)(t=>{for(const{id:e,rect:n}of r)if(nt(n,t))return e},"findContainingLane"),d=(0,l.K)((t,e)=>c.some(n=>n.labelId!==t&&ot(e,n.rect)),"overlapsPlacedLabel");for(const u of t){if(u.isLayoutOnly)continue;const t=u.labelNodeId;if(!t)continue;const n=e.get(t);if(!n)continue;const o=u.points;if(!o||o.length<2)continue;const h=n.width??0,g=n.height??0;if(h<=0||g<=0)continue;const p=[];for(let e=0;e<o.length-1;e++){const t=o[e],n=o[e+1],r=Math.abs(t.x-n.x),s=Math.abs(t.y-n.y);r<Ke&&s<Ke||(r>=Ke&&s>=Ke||p.push({idx:e,length:r+s,orientation:r>=Ke?"horizontal":"vertical",midX:(t.x+n.x)/2,midY:(t.y+n.y)/2}))}if(0===p.length)continue;const x=p.length>=3?p.filter(t=>t.idx>0&&t.idx<p.length-1):p,m=x.length>0?x:p,y=h>=g?"horizontal":"vertical",b=(0,l.K)(t=>[...t].sort((t,e)=>{const n=t.orientation===y;if(n!==(e.orientation===y))return n?-1:1;const o=t.length>=("horizontal"===t.orientation?h:g)+2;return o!==e.length>=("horizontal"===e.orientation?h:g)+2?o?-1:1:e.length-t.length}),"rankSegments"),M=p[0],K=p[p.length-1],I=[.5,.25,.75,.05,.95,.15,.85,.1,.9],w=(0,l.K)((t,e)=>{const n=o[t.idx],r=o[t.idx+1];return{midX:n.x+(r.x-n.x)*e,midY:n.y+(r.y-n.y)*e}},"anchorAtT"),S=(0,l.K)((t,e,n)=>Math.min(n,Math.max(e,t)),"clamp"),v=(0,l.K)((t,e)=>t.midX>=e.left-Ke&&t.midX<=e.right+Ke&&t.midY>=e.top-Ke&&t.midY<=e.bottom+Ke,"pointInsideRectInclusive"),C=(0,l.K)(t=>{const e=st(t.midX,t.midY,h,g),n=f(e);if(n)return{laneId:n,anchor:t,rect:e};const o=r.find(({rect:e})=>v(t,e));if(!o)return;const s=o.rect.left+h/2+1,i=o.rect.right-h/2-1,a=o.rect.top+g/2+1,c=o.rect.bottom-g/2-1;if(s>i||a>c)return;const d={midX:S(t.midX,s,i),midY:S(t.midY,a,c)},l=st(d.midX,d.midY,h,g);return v(t,l)?{laneId:o.id,anchor:d,rect:l}:void 0},"placementForAnchor"),L=(0,l.K)((t,e,n)=>"horizontal"===t.orientation?Math.abs(e.midX-n.x):Math.abs(e.midY-n.y),"distanceAlongSegment"),k=(0,l.K)((t,e)=>{const n=("horizontal"===t.orientation?h/2:g/2)+12;if(t===M){const r=o[t.idx];if(L(t,e,r)+Ke<n)return!1}if(t===K){const r=o[t.idx+1];if(L(t,e,r)+Ke<n)return!1}return!0},"labelClearsTerminalEndpoints"),T=(0,l.K)(e=>{const n=b(e);for(const r of n)for(const e of I){const n=w(r,e);if(!k(r,n))continue;const s=C(n);if(s&&(!Se(s.rect,o)&&!d(t,s.rect)&&!a(t,u.id,s.rect)))return{laneId:s.laneId,anchor:s.anchor}}},"tryPool"),$=(0,l.K)((e,n,r=!1)=>{const a=b(e);for(const c of a){const e={midX:c.midX,midY:c.midY};if(n&&!k(c,e))continue;const a=C(e);if(a&&!Se(a.rect,o)&&!d(t,a.rect)&&!s(t,a.rect)&&(r||!i(u.id,a.rect)))return{laneId:a.laneId,anchor:a.anchor}}},"findLaneContainingFallback"),R=T(m)??(m.length<p.length?T(p):void 0)??$(p,!0)??$(p,!1)??$(p,!1,!0);if(R){n.x=R.anchor.midX,n.y=R.anchor.midY,n.parentId=R.laneId;const e=st(R.anchor.midX,R.anchor.midY,h,g),o=c.findIndex(e=>e.labelId===t);o>=0?c[o]={labelId:t,rect:e}:c.push({labelId:t,rect:e})}}}(0,l.K)(Ie,"markerClearanceRectFor"),(0,l.K)(we,"normalizeRect"),(0,l.K)(Se,"labelOverlapsOwnMarker"),(0,l.K)(ve,"anchorLabelsToPolyline");var Ce=1e-6;function Le(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}function ke(t,e){const{nodeInfoById:n,realNodeRects:o}=dt(e),r=new Map;for(const i of e){const t=i.id;i.isGroup||i.isEdgeLabel&&r.set(t,{w:i.width??0,h:i.height??0})}const s=(0,l.K)((e,n,o,s)=>{const i=Le(n,o);let a=0;const c=(0,l.K)(t=>{if(!t)return;const e=r.get(t);if(!e)return;const n="x"===s?e.w/2:e.h/2;n>a&&(a=n)},"consider");c(e.labelNodeId);for(const r of t){if(r===e)continue;if(r.isLayoutOnly)continue;const t=r.start,n=r.end;t&&n&&(Le(t,n)===i&&c(r.labelNodeId))}return a>0?a+3:0},"labelClearanceFor");for(const i of t){if(i.isLayoutOnly)continue;if(!Z(i.points,Ce))continue;const e=ht(i,n,Ce);if(!e)continue;const{srcId:r,dstId:a,srcInfo:c,dstInfo:f,collinearX:d,collinearY:l}=e;if(d===l)continue;let u,h;if(d){const t=f.cy>c.cy;u={x:c.cx,y:t?c.rect.bottom:c.rect.top},h={x:f.cx,y:t?f.rect.top:f.rect.bottom}}else{const t=f.cx>c.cx;u={x:t?c.rect.right:c.rect.left,y:c.cy},h={x:t?f.rect.left:f.rect.right,y:f.cy}}if(gt(u,h,o,[r,a],1))continue;const g=s(i,r,a,d?"x":"y"),p=g>4?g:4,x=[0,p,-p];for(const n of x){const e={...u},s={...h};if(d){if(e.x+=n,s.x+=n,e.x<=c.rect.left||e.x>=c.rect.right)continue;if(s.x<=f.rect.left||s.x>=f.rect.right)continue}else{if(e.y+=n,s.y+=n,e.y<=c.rect.top||e.y>=c.rect.bottom)continue;if(s.y<=f.rect.top||s.y>=f.rect.bottom)continue}if(!gt(e,s,o,[r,a],1)&&!mt(e,s,t,i,{epsilon:Ce})){i.points=[e,s];break}}}}function Te(t,e){const n=.001,{realNodeRects:o,labelNodeRects:r}=lt(e.values()),s=(0,l.K)((t,e)=>q(e,n).map(n=>({...n,edge:t,interior:n.index>=1&&n.index<=e.length-3})),"segmentsFor"),i=(0,l.K)(()=>{const e=[];for(const n of t){if(n.isLayoutOnly)continue;const t=n.points;!t||t.length<2||e.push(...s(n,Q(t)))}return e},"allSegments"),a=(0,l.K)((t,e)=>t.horizontal&&e.horizontal?W(t.a.x,t.b.x,e.a.x,e.b.x)>=8&&Math.abs(t.a.y-e.a.y)<7:!(!t.vertical||!e.vertical)&&(W(t.a.y,t.b.y,e.a.y,e.b.y)>=8&&Math.abs(t.a.x-e.a.x)<7),"hasCrowdedParallelTrack"),c=(0,l.K)((e,i)=>{const c=e.start,f=e.end,d=s(e,i);if(d.length!==i.length-1)return!1;const l=[c,f].filter(t=>Boolean(t)),u=e.labelNodeId?[e.labelNodeId]:[];for(const t of d){if(gt(t.a,t.b,o,l,-2))return!1;if(gt(t.a,t.b,r,u,-2))return!1}for(const o of t){if(o===e||o.isLayoutOnly)continue;const t=o.points;if(t&&!(t.length<2))for(const e of d)for(const r of s(o,Q(t))){if(a(e,r))return!1;if(yt(e.a,e.b,r.a,r.b,n))return!1}}return!0},"candidateIsSafe"),f=(0,l.K)((t,e)=>{const n=Q(t.edge.points??[]);if(n.length<4||t.index>=n.length-1)return;const o=n.map(t=>({...t}));if(t.horizontal)o[t.index].y+=e,o[t.index+1].y+=e;else{if(!t.vertical)return;o[t.index].x+=e,o[t.index+1].x+=e}return s(t.edge,o).length===o.length-1?o:void 0},"shiftedCandidate"),d=(0,l.K)((t,e)=>({x:t.x??(e.left+e.right)/2,y:t.y??(e.top+e.bottom)/2}),"nodeCenter"),u=(0,l.K)(t=>{const n=t.edge,o=Q(n.points??[]);if(4!==o.length||1!==t.index)return;const r=n.start?e.get(n.start):void 0,s=n.end?e.get(n.end):void 0,i=r?it(r):void 0,a=s?it(s):void 0,c=o.slice(t.index+2);return r&&s&&i&&a&&0!==c.length?{sourceCenter:d(r,i),targetCenter:d(s,a),sourceRect:i,tail:c}:void 0},"sourceDetourContextFor"),h=(0,l.K)((t,e,o,r,s,i)=>{const a=r.y>=o.y,c=a?s.bottom:s.top,f=c+(a?20:-20);if(a&&t.b.y<=f+n||!a&&t.b.y>=f-n)return;const d=t.a.x+e;return Q([{x:o.x,y:c},{x:o.x,y:f},{x:d,y:f},{x:d,y:t.b.y},...i],n)},"verticalSourceDetour"),g=(0,l.K)((t,e,o,r,s,i)=>{const a=r.x>=o.x,c=a?s.right:s.left,f=c+(a?20:-20);if(a&&t.b.x<=f+n||!a&&t.b.x>=f-n)return;const d=t.a.y+e;return Q([{x:c,y:o.y},{x:f,y:o.y},{x:f,y:d},{x:t.b.x,y:d},...i],n)},"horizontalSourceDetour"),p=(0,l.K)((t,e)=>{const n=u(t);if(n)return t.vertical?h(t,e,n.sourceCenter,n.targetCenter,n.sourceRect,n.tail):t.horizontal?g(t,e,n.sourceCenter,n.targetCenter,n.sourceRect,n.tail):void 0},"sourceDetourCandidate"),x=[-7,7,-14,14,-21,21];for(let l=0;l<12;l++){const t=i();let e=!1;for(let n=0;n<t.length&&!e;n++)for(let o=n+1;o<t.length&&!e;o++){const r=t[n],s=t[o];if(r.edge===s.edge||!a(r,s))continue;const i=[r,s].filter(t=>t.interior);for(const t of i){for(const n of x){const o=f(t,n);if(o&&c(t.edge,o)){t.edge.points=o,e=!0;break}const r=p(t,n);if(r&&c(t.edge,r)){t.edge.points=r,e=!0;break}}if(e)break}}if(!e)return}}function $e(t,e,n,o){const r=e.x-t.x,s=e.y-t.y,i=o.x-n.x,a=o.y-n.y,c=r*a-s*i;if(Math.abs(c)<1e-10)return!1;const f=n.x-t.x,d=n.y-t.y,l=(f*a-d*i)/c,u=(f*s-d*r)/c,h=.01;return l>h&&l<.99&&u>h&&u<.99}function Re(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const r=ut(e),s=[];for(const a of n){if(a.isLayoutOnly)continue;const t=a.points;if(!t||t.length<2)continue;const e=a.start,n=a.end,i=a.labelNodeId,c=a.id??`${e}->${n}`;for(const s of r)if(s.nodeId!==e&&s.nodeId!==n&&(!i||s.nodeId!==i))for(let e=0;e<t.length-1;e++)if(tt(t[e],t[e+1],s,-1)){o.push({type:"edge-node-overlap",edgeId:c,targetId:s.nodeId,detail:`segment ${e} passes through node "${s.nodeId}"`});break}for(let o=0;o<t.length-1;o++)s.push({edgeId:c,start:e,end:n,p1:t[o],p2:t[o+1]})}const i=new Set;for(let a=0;a<s.length;a++)for(let t=a+1;t<s.length;t++){const e=s[a],n=s[t];if(e.edgeId!==n.edgeId&&(e.start!==n.start&&e.start!==n.end&&e.end!==n.start&&e.end!==n.end&&$e(e.p1,e.p2,n.p1,n.p2))){const t=e.edgeId<n.edgeId?`${e.edgeId}|${n.edgeId}`:`${n.edgeId}|${e.edgeId}`;i.has(t)||(i.add(t),o.push({type:"edge-edge-crossing",edgeId:e.edgeId,targetId:n.edgeId,detail:`edges "${e.edgeId}" and "${n.edgeId}" cross`}))}}if(o.length>0){const t=o.filter(t=>"edge-node-overlap"===t.type).length,e=o.filter(t=>"edge-edge-crossing"===t.type).length;d.R.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${t} edge-node overlap(s), ${e} edge crossing(s)`);for(const n of o)d.R.warn(`[SWIMLANE_VALIDATE] ${n.type}: ${n.detail}`)}return o}function Oe(t,e){const n=t.nodes??[],o=t.edges??[],r=n.filter(t=>!t.isGroup);if(("LR"===e||"RL"===e)&&r.length>0&&!ne(t,e))return;if("BT"===e&&r.length>0&&!ee(t))return;for(const a of o){if(a.isLayoutOnly)continue;const t=a.points;!t||t.length<2||(a.points=wt(It(t)))}Me(o,n),ke(o,n),se(o,n);const s=new Map;for(const a of n)s.set(String(a.id),a);ve(o,s),kt(o,s),ie(o,s),Te(o,s),de(o,s),le(o,s),ue(o,s),pe(o,s);const i=(0,l.K)(()=>{ye(o,s),xe(o,s),me(o,s),ve(o,s),Vt(o,s),ue(o,s),ve(o,s),Vt(o,s)},"finalizeRenderedEdges");i(),Te(o,s),i(),he(o,s),ge(o,s),he(o,s),ge(o,s)}function Ne(t){const e=new Map(t.nodeById),n=new Set,o=[];for(const r of t.edges){if(!e.has(r.src)||!e.has(r.dst))continue;const t=`${r.id}:${r.src}->${r.dst}`;n.has(t)||(n.add(t),o.push(r))}return{nodes:[...e.keys()],edges:o,layout:t.layout,nodeById:e}}function Be(t,e){return t.edges.filter(t=>t.dst===e)}function Ee(t){const e=new Map;for(const n of t.nodes)e.set(n,[]);for(const n of t.edges)e.get(n.src).push(n.dst);return e}function Fe(t){const e=Ee(t);for(const n of e.values())n.sort((t,e)=>t.localeCompare(e));return e}function Ye(t){const e=new Map;for(const n of t.nodes)e.set(n,0);for(const n of t.edges)e.set(n.dst,(e.get(n.dst)??0)+1);return e}function Xe(t){return[...t.entries()].filter(([,t])=>0===t).map(([t])=>t).sort((t,e)=>t.localeCompare(e))}function Pe(t,e=()=>!0){const n=new Map,o=new Map;for(const r of t.nodes)n.set(r,[]),o.set(r,[]);for(const r of t.edges)e(r)&&(o.get(r.src).push(r.dst),n.get(r.dst).push(r.src));return{preds:n,succs:o}}function ze(t,e,n,o){let r=0;for(const i of t.nodes)o?.skipGroups&&t.nodeById.get(i)?.isGroup||(r=Math.max(r,n[i]??0));const s=Array.from({length:r+1},()=>[]);for(const i of e)o?.skipGroups&&t.nodeById.get(i)?.isGroup||s[Math.max(0,n[i]??0)].push(i);return s}function Ae(t){const e=Ye(t),n=Xe(e),o=[],r=Fe(t);for(;n.length;){const t=n.shift();o.push(t);for(const o of r.get(t)??[])if(e.set(o,(e.get(o)??0)-1),0===(e.get(o)??0)){let t=0;for(;t<n.length&&n[t]<o;)t++;n.splice(t,0,o)}}return o.length===t.nodes.length?o:null}function Ge(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}function De(t){const e=new Array(t.length),n=(0,l.K)((o,r)=>{if(r-o<=1)return 0;const s=o+r>>1;let i=n(o,s)+n(s,r),a=o,c=s,f=o;for(;a<s||c<r;)c>=r||a<s&&t[a]<=t[c]?e[f++]=t[a++]:(e[f++]=t[c++],i+=s-a);for(let n=o;n<r;n++)t[n]=e[n];return i},"count");return n(0,t.length)}function He(t){const e=Ne(t),n=new Map;for(const f of e.nodes)n.set(f,[]);for(const f of e.edges)n.get(f.src).push(f);for(const f of n.values())f.sort((t,e)=>t.dst===e.dst?t.id.localeCompare(e.id):t.dst.localeCompare(e.dst));const o=Object.create(null);for(const f of e.nodes)o[f]=0;const r=[],s=(0,l.K)(t=>{o[t]=1;for(const e of n.get(t)??[]){const t=e.dst;0===o[t]?s(t):1===o[t]&&r.push(e)}o[t]=2},"dfs"),i=[...e.nodes].sort((t,e)=>t.localeCompare(e));for(const f of i)0===o[f]&&s(f);const a=new Set(r.map(t=>`${t.id}:${t.src}->${t.dst}`)),c=e.edges.map(t=>a.has(`${t.id}:${t.src}->${t.dst}`)?{id:t.id,src:t.dst,dst:t.src,weight:t.weight,ref:t.ref}:t);return{acyclic:{nodes:[...e.nodes],edges:c,layout:e.layout,nodeById:new Map(e.nodeById)},reversed:r}}function _e(t){const e=new Map,n=(0,l.K)(o=>{if(e.has(o))return e.get(o);const r=t.nodeById.get(o);if(!r)return e.set(o,null),null;const s=r.parentId;if(!s)return e.set(o,null),null;const i=n(s)??s;return e.set(o,i),i},"resolve");for(const o of t.nodes)n(o);return e}function je(t){const e=_e(t);return t=>e.get(t)??null}function Ve(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}function We(t,e){const n=Ve(t);if(!e||0===e.length)return n;const o=new Set(n),r=new Set,s=[];for(const i of e)o.has(i)&&!r.has(i)&&(r.add(i),s.push(i));for(const i of n)r.has(i)||s.push(i);return s}(0,l.K)(Le,"pairKey"),(0,l.K)(ke,"straightenCollinearSiblingDetours"),(0,l.K)(Te,"nudgeSharedInteriorSubpaths"),(0,l.K)($e,"segmentsIntersect"),(0,l.K)(Re,"validateSwimlanesLayout"),(0,l.K)(Oe,"postProcessSwimlaneLayout"),(0,l.K)(Ne,"normalizeGraph"),(0,l.K)(Be,"incoming"),(0,l.K)(Ee,"buildSuccessorMap"),(0,l.K)(Fe,"buildSortedSuccessorMap"),(0,l.K)(Ye,"buildInDegreeMap"),(0,l.K)(Xe,"sortedZeroInDegreeNodes"),(0,l.K)(Pe,"buildPredecessorSuccessorMaps"),(0,l.K)(ze,"buildLayersFromRanks"),(0,l.K)(Ae,"topoSortIfAcyclic"),(0,l.K)(Ge,"buildLayerIndex"),(0,l.K)(De,"countInversions"),(0,l.K)(He,"removeCycles_DFS"),(0,l.K)(_e,"buildTopLaneMap"),(0,l.K)(je,"createTopLaneResolver"),(0,l.K)(Ve,"buildTopLaneOrder"),(0,l.K)(We,"resolveTopLaneOrder");var Ue=8,qe=4,Je=!0,Qe=100,Ze=40;function tn(t,e){const n=Ne(t),o=e?.laneOf??(()=>null),r=e?.rankHint,{preds:s}=Pe(n);for(const l of s.values())l.sort((t,e)=>t.localeCompare(e));const i=Ae(n)??[...n.nodes].sort((t,e)=>t.localeCompare(e)),a=new Map;for(const[l,I]of i.entries())a.set(I,l);const c=new Map,f=new Map;for(const l of n.nodes)f.set(l,[]);for(const l of i){const t=(s.get(l)??[]).filter(t=>c.has(t));if(t.length>0){const e=en(l,t,{laneOf:o,rankHint:r,topoIndex:a});c.set(l,e),f.get(e).push(l)}else c.has(l)||c.set(l,null)}for(const l of n.nodes)c.has(l)||c.set(l,null);const d=new Set;for(const l of n.nodes)null===(c.get(l)??null)&&d.add(l);const u=[...d].sort((t,e)=>{const n=a.get(t)??0,o=a.get(e)??0;return n===o?t.localeCompare(e):n-o}),h=nn(n),g=new Map;for(const[l,I]of h.entries())g.set(l,[...I].sort((t,e)=>t.localeCompare(e)));const p=on(g),x=rn(g),m=new Map;for(const l of n.nodes)m.set(l,[]);for(const l of x)for(const t of l.nodes){const e=m.get(t);e?e.push(l.id):m.set(t,[l.id])}const y=[],b=[],M=new Set,K=(0,l.K)(t=>{if(!M.has(t)){M.add(t),y.push(t);for(const e of f.get(t)??[])K(e);b.push(t)}},"walk");for(const l of u)K(l);for(const l of i)K(l);return{parent:c,children:f,roots:u,componentOf:p,blocks:x,nodeBlocks:m,adjacency:g,preorder:y,postorder:b,topologicalOrder:i}}function en(t,e,n){const o=n.laneOf(t);return[...e].sort((t,e)=>{const r=n.laneOf(t),s=n.laneOf(e),i=null!=r&&r===o;if(i!==(null!=s&&s===o))return i?-1:1;const a=n.rankHint?.[t],c=n.rankHint?.[e];if(null!=a&&null!=c&&a!==c)return c-a;const f=n.topoIndex.get(t)??0,d=n.topoIndex.get(e)??0;return f!==d?f-d:t.localeCompare(e)})[0]}function nn(t){const e=new Map;for(const n of t.nodes)e.set(n,new Set);for(const n of t.edges)e.get(n.src).add(n.dst),e.get(n.dst).add(n.src);return e}function on(t){const e=new Map;let n=0;for(const o of t.keys()){if(e.has(o))continue;const r=[o];for(;r.length>0;){const o=r.pop();if(!e.has(o)){e.set(o,n);for(const n of t.get(o)??[])e.has(n)||r.push(n)}}n++}return e}function rn(t){const e=new Map,n=new Map,o=[],r=[];let s=0;const i=(0,l.K)((a,c)=>{e.set(a,++s),n.set(a,s);for(const f of t.get(a)??[])f!==c&&(e.has(f)?(e.get(f)??0)<(e.get(a)??0)&&(o.push([a,f]),n.set(a,Math.min(n.get(a)??s,e.get(f)??s))):(o.push([a,f]),i(f,a),n.set(a,Math.min(n.get(a)??s,n.get(f)??s)),(n.get(f)??0)>=(e.get(a)??0)&&r.push(sn(a,f,o,r.length))))},"visit");for(const a of t.keys())e.has(a)||i(a,null);return r}function sn(t,e,n,o){const r=[],s=new Set;for(;n.length>0;){const o=n.pop();if(r.push(o),s.add(o[0]),s.add(o[1]),o[0]===t&&o[1]===e||o[0]===e&&o[1]===t)break}return{id:o,edges:r,nodes:[...s]}}function an(t,e,n){const o=[...t.nodes],r=new Map;for(const[l,b]of o.entries())r.set(b,l);const s=o.length,i=new Array(s).fill(-1),a=new Array(s).fill(0),c=[],f=new Set;for(const l of o){const t=n.parent.get(l)??null,e=r.get(l);null!=e&&(null==t&&(i[e]=-1,a[e]=0,f.has(l)||(f.add(l),c.push(l))))}for(;c.length>0;){const t=c.shift(),e=r.get(t);if(null==e)continue;const o=n.children.get(t)??[];for(const n of o){if(f.has(n))continue;const t=r.get(n);null!=t&&(i[t]=e,a[t]=a[e]+1,f.add(n),c.push(n))}}for(const l of o){if(f.has(l))continue;const t=r.get(l);null!=t&&(i[t]=-1,a[t]=0,f.add(l))}const d=Math.max(1,Math.ceil(Math.log2(Math.max(1,s)))+1),u=Array.from({length:d},()=>new Array(s).fill(-1));for(let l=0;l<s;l++)u[0][l]=i[l];for(let l=1;l<d;l++)for(let t=0;t<s;t++){const e=u[l-1][t];u[l][t]=-1===e?-1:u[l-1][e]}const h=(0,l.K)((t,e)=>{if(-1===t||-1===e)return-1;a[t]<a[e]&&([t,e]=[e,t]);const n=a[t]-a[e];for(let o=0;o<d;o++)if(n>>o&1&&-1===(t=u[o][t]))return-1;if(t===e)return t;for(let o=d-1;o>=0;o--){const n=u[o][t],r=u[o][e];-1!==n&&-1!==r&&(n!==r&&(t=n,e=r))}return u[0][t]},"lcaIndex"),g=Array.from({length:s},()=>new Map);for(const l of t.edges){let t=l.src,n=l.dst,o=e[t],s=e[n];if(null==o||null==s)continue;if(o>s&&([t,n]=[n,t],[o,s]=[s,o]),null==o||null==s||o===s)continue;const i=r.get(t),a=r.get(n);if(null==i||null==a)continue;const c=h(i,a);if(-1===c)continue;const f=g[c];for(let e=o;e<s;e++)f.set(e,(f.get(e)??0)+1)}const p=new Map,x=(0,l.K)((t,e)=>{if(0!==e.size)for(const[n,o]of e)t.set(n,(t.get(n)??0)+o)},"mergeInto"),m=new Set,y=(0,l.K)(t=>{const o=r.get(t);m.add(t);const s=null==o?void 0:g[o],i=s?new Map(s):new Map,a=n.children.get(t)??[];for(const n of a){const o=y(n),r=e[t];if(null!=r){let s=p.get(t);s||(s=new Map,p.set(t,s));let i=o.get(r)??0;const a=e[n];null!=a&&a>r&&(i+=1),s.set(n,i)}x(i,o)}return i},"dfs");for(const l of n.roots)m.has(l)||y(l);for(const l of o)m.has(l)||y(l);return p}function cn(t,e,n){const o=new Map,r=(0,l.K)(t=>{let s=n[t]??0;const i=[...e.get(t)??[]];i.sort(fn(n));for(const e of i){r(e);const t=o.get(e);null!=t&&(s=Math.min(s,t))}o.set(t,s)},"annotate");for(const s of t)r(s);return o}function fn(t){return(e,n)=>{const o=t[e]??0,r=t[n]??0;return o===r?e.localeCompare(n):o-r}}function dn(t,e,n,o){let r=0;for(const c of e){const t=n[c]??0;t>r&&(r=t)}const s=Array.from({length:r+1},()=>[]),i=new Set,a=(0,l.K)(t=>{if(i.has(t))return;i.add(t);const e=n[t]??0;s[e]||(s[e]=[]),s[e].push(t);for(const n of o(t))a(n)},"emit");for(const c of t)a(c);for(const c of e)if(!i.has(c)){const t=n[c]??0;s[t]||(s[t]=[]),s[t].push(c),i.add(c)}return s}function ln(t){const e=[];for(const n of t){const t=new Set,o=[];for(const e of n)t.has(e)||(t.add(e),o.push(e));e.push(o)}return e}function un(t,e,n,o){return r=>{const s=t.get(r)??[];if(0===s.length)return[];const i=e[r]??0,a=[],c=[],f=n.get(r);for(const t of s){const e=o.get(t)??i;e>i?a.push({child:t,min:e}):c.push(t)}return a.sort((t,e)=>t.min===e.min?t.child.localeCompare(e.child):t.min-e.min),c.sort((t,e)=>{const n=f?.get(t)??0,r=f?.get(e)??0;if(n!==r)return n-r;const s=o.get(t)??i,a=o.get(e)??i;return s!==a?s-a:t.localeCompare(e)}),[...a.map(t=>t.child),...c]}}function hn(t,e,n){const o=tn(t,{rankHint:e,laneOf:n}),{children:r,roots:s}=o;for(const d of t.nodes)r.has(d)||r.set(d,[]);const i=an(t,e,o),a=[...s].sort(fn(e)),c=un(r,e,i,cn(a,r,e));let f=dn(a,t.nodes,e,c);return f=ln(f),f}function gn(t,e,n){const o=new Set(t),r=new Set(e),s=Ge(e),i=[];for(const a of n)o.has(a.src)&&r.has(a.dst)&&i.push(s.get(a.dst));return De(i)}function pn(t,e,n){const o=[];for(const s of e){const t=n[s.src],e=n[s.dst];if(null==t||null==e||t===e)continue;let r=s.src,i=s.dst,a=t,c=e;t>e&&(r=s.dst,i=s.src,a=e,c=t);for(let n=a;n<c;n++)o.push({id:`${s.id}@${n}`,src:r,dst:i,ref:s.ref})}let r=0;for(let s=0;s+1<t.length;s++)r+=gn(t[s],t[s+1],o);return r}function xn(t,e){const n={...e},{preds:o}=Pe(t),r=je(t);let s=pn(hn(t,n,r),t.edges,n);const i=qe;for(let a=0;a<i;a++){let e=!1;const i=[...t.nodes].sort((t,e)=>(n[e]??0)-(n[t]??0));for(const a of i){const i=n[a]??0;if(0===i)continue;let c=0;for(const t of o.get(a)??[])c=Math.max(c,(n[t]??0)+1);if(c>=i)continue;const f=i;n[a]=c;const d=pn(hn(t,n,r),t.edges,n);d<s?(s=d,e=!0):n[a]=f}if(!e)break}return n}function mn(t,e){const n=je(t),o=[...t.nodes].sort((t,n)=>(e[t]??0)-(e[n]??0)||t.localeCompare(n));for(const r of o){const o=n(r);if(!o)continue;const s=t.edges.filter(t=>t.src===r);if(0===s.length)continue;let i=!1,a=0;for(const t of s){const e=n(t.dst);null==e||e===o?i=!0:a++}if(0===a||i)continue;let c=0,f=!1;for(const e of t.edges){if(e.dst!==r)continue;const t=n(e.src);t&&(t===o?f=!0:c++)}if(c>0||!f)continue;const d=e[r]??0,l=d+a;let u=0;for(const n of t.edges)n.dst===r&&(u=Math.max(u,(e[n.src]??0)+1));const h=Math.max(d,u,l);h!==d&&(e[r]=h)}}function yn(t,e){const n=Ne(t),o=Ae(n)??[...n.nodes].sort(),r=e?.compactSingleInput??!1,s=je(n);let i=Object.create(null);for(const a of o){const t=Be(n,a),o=e?.ignoreCrossLaneEdges?t.filter(t=>{const e=s(t.src),n=s(a);return!e||!n||e===n}):t;if(0===o.length)i[a]=0;else if(r&&1===o.length){const t=o[0].src,e=s(t),n=s(a);i[a]=e!==n?i[t]??0:(i[t]??0)+1}else{let t=-1/0;for(const e of o)t=Math.max(t,(i[e.src]??0)+1);i[a]=t===-1/0?0:t}}e?.optimizeRanksByCrossings&&(i=xn(n,i)),e?.ignoreCrossLaneEdges&&mn(n,i);return{layers:hn(n,i,s),rankOf:i,dummy:new Set}}function bn(t,e){const n=Ne(t),o={...yn(n,{compactSingleInput:e?.compactSingleInput,ignoreCrossLaneEdges:e?.ignoreCrossLaneEdges,optimizeRanksByCrossings:e?.optimizeRanksByCrossings}).rankOf},r=je(n),{preds:s,succs:i}=Pe(n,t=>{if(e?.ignoreCrossLaneEdges){const e=r(t.src),n=r(t.dst);if(e&&n&&e!==n)return!1}return!0}),a=Ae(n)??[...n.nodes],c=[...a].reverse(),f=(0,l.K)((t,e)=>{let n=0;for(const i of s.get(t)??[])n=Math.max(n,(o[i]??0)+1);let r=Number.POSITIVE_INFINITY;const a=i.get(t)??[];return a.length>0&&(r=Math.min(...a.map(t=>(o[t]??0)-1))),Number.isFinite(r)||(r=Math.max(n,e)),Math.min(Math.max(e,n),r)},"clampFeasible"),d=Ue,u=(0,l.K)(t=>{let e=!1;for(const n of t){const t=s.get(n)??[],r=i.get(n)??[];if(0===t.length&&0===r.length)continue;const a=t.length>0?t.reduce((t,e)=>t+(o[e]??0)+1,0)/t.length:o[n]??0,c=r.length>0?r.reduce((t,e)=>t+(o[e]??0)-1,0)/r.length:o[n]??0,d=Math.round((a+c)/2),l=f(n,d);l!==o[n]&&(o[n]=l,e=!0)}return e},"relaxOrder");for(let l=0;l<d;l++){const t=u(a),e=u(c);if(!t&&!e)break}for(const l of a){let t=0;for(const e of s.get(l)??[])t=Math.max(t,(o[e]??0)+1);(o[l]??0)<t&&(o[l]=t)}for(const l of c){const t=i.get(l)??[];if(t.length>0){const e=Math.min(...t.map(t=>(o[t]??0)-1));(o[l]??0)>e&&(o[l]=e)}}return{layers:ze(n,a,o),rankOf:o,dummy:new Set}}function Mn(t){const e=Ye(t),n=Fe(t);let o=Xe(e);const r=[];for(;o.length>0;){const t=[];for(const s of o){r.push(s);for(const o of n.get(s)??[])e.set(o,(e.get(o)??0)-1),0===(e.get(o)??0)&&t.push(o)}o=t.sort((t,e)=>t.localeCompare(e))}return r.length===t.nodes.length?r:null}function Kn(t,e){const n=Ne(t),o="LR"===e?.direction?Mn(n)??[...n.nodes].sort():Ae(n)??[...n.nodes].sort(),r=je(n),s=(0,l.K)(t=>r(t)??t,"laneOf"),i=Object.create(null),a=new Map,c=(0,l.K)((t,n)=>e?.ignoreCrossLaneEdges??!0?s(t)===s(n)?1:0:1,"edgeWeight");for(const f of o){const t=n.nodeById.get(f);if(t?.isGroup)continue;const e=Be(n,f);let o=0;if(e.length>0)for(const n of e){const t=n.src,e=i[t]??0;o=Math.max(o,e+c(t,f))}const r=s(f),d=a.get(r)??0,l=Math.max(o,d);i[f]=l,a.set(r,l+1)}return{layers:ze(n,o,i,{skipGroups:!0}),rankOf:i,dummy:new Set}}function In(t,e){const n=Ne(e),{rankOf:o}=t,r=t.layers.map(t=>[...t]),s=new Set(t.dummy?[...t.dummy]:[]);let i=0;const a=new Map(n.nodeById),c=(0,l.K)(t=>{const e="placeholder-"+i++,n={id:e,isGroup:!1,isDummy:!0,width:0,height:0};for(a.set(e,n),s.add(e);r.length<=t;)r.push([]);return r[t].push(e),o[e]=t,e},"addDummyAt"),f=[...n.edges].sort((t,e)=>t.id===e.id?t.src===e.src?t.dst.localeCompare(e.dst):t.src.localeCompare(e.src):t.id.localeCompare(e.id)),d=[];for(const l of f){const t=o[l.src]??0,e=o[l.dst]??0;if(e-t<=1){d.push(l);continue}let n=l.src;for(let o=t+1,s=0;o<e;o++,s++){const t=c(o);d.push({id:`${l.id}#${s}`,src:n,dst:t,weight:l.weight,ref:l.ref}),n=t}const r=e-t-2;d.push({id:`${l.id}#${Math.max(r+1,0)}`,src:n,dst:l.dst,weight:l.weight,ref:l.ref})}const u={nodes:[...n.nodes,...[...s].filter(t=>!n.nodes.includes(t))],edges:d,layout:n.layout,nodeById:a};return{layering:{layers:r,rankOf:o,dummy:s},graphWithDummies:u}}function wn(t){const e=t.length;if(0===e)return Number.POSITIVE_INFINITY;const n=[...t].sort((t,e)=>t-e);return e%2==1?n[(e-1)/2]:.5*(n[e/2-1]+n[e/2])}function Sn(t){if(0===t.length)return Number.POSITIVE_INFINITY;return t.reduce((t,e)=>t+e,0)/t.length}function vn(t,e,n,o){const r=new Map;for(const s of t)r.set(s,[]);for(const s of n)"down"===o?e.has(s.src)&&r.has(s.dst)&&r.get(s.dst).push(e.get(s.src)):e.has(s.dst)&&r.has(s.src)&&r.get(s.src).push(e.get(s.dst));return r}function Cn(t,e,n){const o=n.get(t)??0,r=n.get(e)??0;return o!==r?o-r:t.localeCompare(e)}function Ln(t,e,n){const o=new Set(t),r=new Set(e),s=Ge(t),i=Ge(e),a=[];for(const c of n)o.has(c.src)&&r.has(c.dst)&&a.push({u:s.get(c.src),v:i.get(c.dst)});a.sort((t,e)=>t.u===e.u?t.v-e.v:t.u-e.u);return De(a.map(t=>t.v))}function kn(t,e,n){return[...t].sort((t,o)=>{const r=wn(e.get(t)??[]),s=wn(e.get(o)??[]);return r===s?Cn(t,o,n):isFinite(r)?isFinite(s)?r-s:-1:1})}function Tn(t,e,n,o,r,s){const i=Ge(t),a=Ge(e),c=vn(e,i,n,o);if(!r||!s||0===s.length)return kn(e,c,a);const f=new Map;for(const u of e){const t=r(u),e=f.get(t)??[];e.push(u),f.set(t,e)}const d=[];for(const u of s){const t=f.get(u);if(!t||0===t.length)continue;const e=kn(t,c,a);d.push(...e)}const l=f.get(null);if(l&&l.length>0){const t=kn(l,c,a);for(const e of t){const t=Sn(c.get(e)??[]);let n=d.length;if(isFinite(t))for(const[e,o]of d.entries()){if(t<Sn(c.get(o)??[])){n=e;break}}d.splice(n,0,e)}}return d}function $n(t,e,n,o,r){const s=[...e],i=new Set(t),a=new Set(e),c=o?new Set(o):null,f=n.filter(t=>i.has(t.src)&&a.has(t.dst)),d=c?n.filter(t=>a.has(t.src)&&c.has(t.dst)):void 0,u=(0,l.K)(e=>{let n=Ln(t,e,f);return d&&o&&(n+=Ln(e,o,d)),n},"crossingScore"),h=r?new Map:null;if(r&&h)for(const l of e)h.set(l,r(l));let g=!0,p=u(s);for(;g;){g=!1;for(let t=0;t+1<s.length;t++){if(h){if(h.get(s[t])!==h.get(s[t+1]))continue}const e=p;[s[t],s[t+1]]=[s[t+1],s[t]];const n=u(s);n<e?(p=n,g=!0):[s[t],s[t+1]]=[s[t+1],s[t]]}}return s}function Rn(t,e,n){const o=t.layers.map(t=>[...t]),r=e.edges,s=je(e),i=We(e,n?.laneOrder);for(let a=0;a<3;a++){for(let t=1;t<o.length;t++)o[t]=Tn(o[t-1],o[t],r,"down",s,i),o[t]=$n(o[t-1],o[t],r,o[t+1],s);for(let t=o.length-2;t>=0;t--)o[t]=Tn(o[t+1],o[t],r,"up",s,i),o[t]=$n(o[t+1],o[t],r,o[t-1],s)}return{layers:o}}function On(t,e,n){const o=n?.layerGap??Qe,r=n?.nodeGap??Ze,s=n?.laneGap??2*r,i=n?.direction??"TB",a="LR"===i||"RL"===i,c=t.layers,f=Object.create(null),d=Object.create(null),u=(0,l.K)(t=>e.nodeById.get(t),"getNode"),h=(0,l.K)(t=>u(t)?.width??0,"getWidth"),g=(0,l.K)(t=>u(t)?.height??0,"getHeight"),p=je(e),x=We(e,n?.laneOrder),m=c.map(t=>t.reduce((t,e)=>Math.max(t,g(e)),0)),y=[];if(a)for(let l=0;l+1<c.length;l++){const t=c[l].reduce((t,e)=>Math.max(t,h(e)),0),e=c[l+1].reduce((t,e)=>Math.max(t,h(e)),0),n=m[l]/2+m[l+1]/2,r=(t+e)/2,s=Math.max(0,r-n-o);y.push(s)}const b=new Set;for(const l of c)for(const t of l)b.add(p(t));const M=b.has(null),K=x.filter(t=>b.has(t)),I=[...M?[null]:[],...K],w=Object.create(null);for(const l of K)w[l]=0;M&&(w.null=0);for(const l of c){const t=Object.create(null),e=[];for(const n of l){const o=p(n);null===o?e.push(n):(t[o]||=[]).push(n)}for(const[n,o]of Object.entries(t)){const t=o.reduce((t,e)=>t+h(e),0)+r*Math.max(0,o.length-1);w[n]=Math.max(w[n]??0,t)}if(M&&e.length){const t=e.reduce((t,e)=>t+h(e),0)+r*Math.max(0,e.length-1);w.null=Math.max(w.null??0,t)}}const S=new Map;{const t=I.map(t=>(null===t?w.null:w[t])??0);let e=-(t.reduce((t,e)=>t+e,0)+s*Math.max(0,I.length-1))/2;for(let n=0;n<I.length;n++){const o=I[n],r=t[n]??0,i=e+r/2;S.set(o,i),e+=r,n<I.length-1&&(e+=s)}}let v=0;for(const[l,L]of c.entries()){const t=m[l]??0,e=new Map;for(const n of L){const t=p(n),o=e.get(t)??[];o.push(n),e.set(t,o)}for(const n of I){const o=e.get(n)??[];if(0===o.length)continue;const s=S.get(n);if(1===o.length){const e=o[0];f[e]=s,d[e]=v+t/2}else{const e=o.map(t=>h(t));let n=s-(e.reduce((t,e)=>t+e,0)+r*(o.length-1))/2;for(const[s,i]of o.entries()){const o=e[s];f[i]=n+o/2,d[i]=v+t/2,n+=o+r}}}v+=t+o+(y[l]??0)}const C=new Map;for(const l of e.edges){const t=l.ref.id;C.has(t)||C.set(t,[]),C.get(t).push(l)}for(const[,l]of C){if(0===l.length)continue;const t=l[0].ref,n=t.start,o=t.end;if(null==n||null==o)continue;const r=Math.round(((f[n]??0)+(f[o]??0))/2),s=new Set;for(const e of l)s.add(e.src),s.add(e.dst);for(const i of s){if(i===n||i===o)continue;const t=e.nodeById.get(i);t?.isDummy&&(f[i]=r)}}return{x:f,y:d}}(0,l.K)(tn,"buildDrivingTree"),(0,l.K)(en,"chooseParent"),(0,l.K)(nn,"buildAdjacency"),(0,l.K)(on,"assignComponents"),(0,l.K)(rn,"computeBlocks"),(0,l.K)(sn,"popBlock"),(0,l.K)(an,"computeSubtreeCrossCounts"),(0,l.K)(cn,"annotateMinimumLayers"),(0,l.K)(fn,"compareByRankThenId"),(0,l.K)(dn,"emitNodesInTreeOrder"),(0,l.K)(ln,"deduplicateLayers"),(0,l.K)(un,"createChildOrderer"),(0,l.K)(hn,"buildMultitreeLayerOrder"),(0,l.K)(gn,"countCrossingsBetweenAdjacent"),(0,l.K)(pn,"totalCrossings"),(0,l.K)(xn,"optimizeRanksByCrossings"),(0,l.K)(mn,"adjustCrossLaneSources"),(0,l.K)(yn,"assignLayers_LongestPath"),(0,l.K)(bn,"assignLayers_Gravity"),(0,l.K)(Mn,"topoSortByGenerationIfAcyclic"),(0,l.K)(Kn,"assignLayers_LaneAwareCompact"),(0,l.K)(In,"makeProperLayering"),(0,l.K)(wn,"median"),(0,l.K)(Sn,"barycenter"),(0,l.K)(vn,"neighborPositionsFor"),(0,l.K)(Cn,"currentOrderTieBreak"),(0,l.K)(Ln,"countCrossingsBetweenAdjacent"),(0,l.K)(kn,"sortByHeuristic"),(0,l.K)(Tn,"reorderLayer"),(0,l.K)($n,"transposeImprove"),(0,l.K)(Rn,"orderLayers"),(0,l.K)(On,"assignCoordinates");function Nn(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return e>>>0}function Bn(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}function En(t,e){const n=[...t],o=Bn(e);for(let r=n.length-1;r>0;r--){const t=Math.floor(o()*(r+1));[n[r],n[t]]=[n[t],n[r]]}return n}function Fn(t,e){let n=0;for(const[o,r]of t.entries())n+=Math.abs(o-(e.get(r)??o));return n}function Yn(t,e){const n=new Map;for(const[r,s]of t.entries())n.set(s,r);let o=0;for(const{a:r,b:s,weight:i}of e){const t=n.get(r),e=n.get(s);null!=t&&null!=e&&(o+=i*Math.abs(t-e))}return o}function Xn(t){const e=Ve(t);if(e.length<2)return[];const n=new Map(e.map((t,e)=>[t,e])),o=je(t),r=new Map;for(const s of t.layout.edges??[]){if(s.isLayoutOnly)continue;const e="string"==typeof s.start?s.start:void 0,i="string"==typeof s.end?s.end:void 0;if(!(e&&i&&t.nodeById.has(e)&&t.nodeById.has(i)))continue;const a=o(e),c=o(i);if(!a||!c||a===c)continue;const f=n.get(a),d=n.get(c);if(null==f||null==d)continue;const[l,u]=f<=d?[a,c]:[c,a],h=`${l}\0${u}`,g=r.get(h);g?g.weight++:r.set(h,{a:l,b:u,weight:1})}return[...r.values()]}function Pn(t,e,n){const o=[...t];let r=Yn(o,e),s=!0,i=0;const a=Math.max(1,o.length);for(;s&&i<a;){s=!1,i++;for(let t=0;t+1<o.length;t++){[o[t],o[t+1]]=[o[t+1],o[t]];const n=Yn(o,e);n<r?(r=n,s=!0):[o[t],o[t+1]]=[o[t+1],o[t]]}}return{order:o,cost:r,sourceDistance:Fn(o,n)}}function zn(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}function An(t,e,n){const o=[...e].sort((t,e)=>t.a===e.a?t.b.localeCompare(e.b):t.a.localeCompare(e.a)).map(({a:t,b:e,weight:n})=>`${t}:${e}:${n}`).join("|");return Nn(`${t.join("|")}#${o}#${n}`)}function Gn(t,e={}){const n=Ve(t);if(n.length<2)return n;const o=Xn(t);if(0===o.length)return n;const r=new Map(n.map((t,e)=>[t,e]));let s=Pn(n,o,r);const i=Math.max(0,e.restarts??8);for(let a=0;a<i;a++){const t=Pn(En(n,An(n,o,a)),o,r);zn(t,s)&&(s=t)}return s.order}function Dn(t,e){const n=e?.ignoreCrossLaneEdges??!0,o=e?.optimizeRanksByCrossings??!0,r=Ne(t),s=e?.automaticLaneOrdering?Gn(r,{restarts:8}):void 0,i=He(r),a=i.acyclic,c=n?Kn(a,{compactSingleInput:e?.compactSingleInput??Je,ignoreCrossLaneEdges:!0,direction:e?.direction}):bn(a,{compactSingleInput:e?.compactSingleInput??Je,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:f,graphWithDummies:d}=In(c,a),l=Rn(f,d,{laneOrder:s}),u=On(l,d,{layerGap:e?.layerGap,nodeGap:e?.nodeGap,direction:e?.direction,laneOrder:s});return{acyclic:a,reversed:i.reversed,layering:f,ordered:l,coordinates:u}}(0,l.K)(Nn,"hashString"),(0,l.K)(Bn,"mulberry32"),(0,l.K)(En,"deterministicShuffle"),(0,l.K)(Fn,"sourceDistance"),(0,l.K)(Yn,"laneArrangementCost"),(0,l.K)(Xn,"buildWeightedLaneEdges"),(0,l.K)(Pn,"greedySwitch"),(0,l.K)(zn,"isBetterCandidate"),(0,l.K)(An,"seedForRestart"),(0,l.K)(Gn,"optimizeTopLaneOrder"),(0,l.K)(Dn,"sugiyamaLayout");var Hn=1e-6,_n=15,jn=15,Vn=20;function Wn(t,e,n){const o=t.x??0,r=t.y??0,s=e.x-o,i=e.y-r,a=Math.abs(s),c=Math.abs(i);if(a<Hn&&c<Hn)return n;return c>Hn&&3*c>=a?i>0?"bottom":"top":a>Hn?s>0?"right":"left":n}function Un(t,e){return Math.abs(t.to-e.from)<Hn||Math.abs(t.to-e.to)<Hn?t.to:t.from}function qn(t,e){return"vertical"===t.orient?{x:t.coord,y:e}:{x:e,y:t.coord}}function Jn(t,e){const n=t.nodes??[],o=t.edges??[],r=[];for(const l of o)l.isLayoutOnly||r.push({...l,__originalEdge:l});const s=new Map,i=new Map,a=[],c="LR"===e;for(const l of n)s.set(l.id,l);const f=n.filter(t=>t.isGroup&&!t.parentId);for(const nt of f){const t={id:nt.id},e=(0,l.K)(o=>{i.set(o.id,t),n.filter(t=>t.parentId===o.id).forEach(e)},"assignLane");e(nt)}const d=n.filter(t=>!t.isGroup&&!t.isEdgeLabel).map(t=>{const e=t.width??10,n=t.height??10,o=t.x??0,r=t.y??0;return{nodeId:t.id,minX:o-e/2-8,maxX:o+e/2+8,minY:r-n/2-8,maxY:r+n/2+8,visualXHalfExtent:c?n/2+8:e/2+8}}),u=(0,l.K)((t,e,n,o)=>{let r=a.find(n=>n.orientation===t&&Math.abs(n.coord-e)<1);return r||(r={id:`pipe-${t}-${e.toFixed(0)}`,orientation:t,coord:e,spanMin:n,spanMax:o,tracks:[]},a.push(r)),r.spanMin=Math.min(r.spanMin,n),r.spanMax=Math.max(r.spanMax,o),r},"getOrAddPipe"),h=(0,l.K)((t,e)=>{const n=t.width??10,o=t.height??10,r=t.x??0,s=t.y??0;switch(e){case"top":return{x:r,y:s-o/2};case"bottom":return{x:r,y:s+o/2};case"left":return{x:r-n/2,y:s};case"right":return{x:r+n/2,y:s}}},"portForSide"),g=(0,l.K)((t,e,n)=>h(t,Wn(t,e,n?"bottom":"top")),"getOrthogonalPort"),p=[],x=[],m=new Set,y=(0,l.K)((t,e,n)=>{if(0===p.length)return 0;const o=Math.abs(e.y-n.y)<Hn,r=Math.abs(e.x-n.x)<Hn;if(!o&&!r)return 0;let s=0;if(o){const o=e.y,r=Math.min(e.x,n.x)-Hn,i=Math.max(e.x,n.x)+Hn;if(i<=r)return 0;for(const e of p)e.edgeIndex!==t&&"vertical"===e.orientation&&(e.pipe.coord<r||e.pipe.coord>i||e.from-Hn<=o&&e.to+Hn>=o&&(s+=1e3))}else if(r){const o=e.x,r=Math.min(e.y,n.y)-Hn,i=Math.max(e.y,n.y)+Hn;if(i<=r)return 0;for(const e of p)e.edgeIndex!==t&&"horizontal"===e.orientation&&(e.pipe.coord<r||e.pipe.coord>i||e.from-Hn<=o&&e.to+Hn>=o&&(s+=1e3))}return s},"crossingPenalty"),b=r.map((t,e)=>{if(!t.start||!t.end)return{idx:e,crossLane:0,dx:0,dy:0};const n=s.get(t.start),o=s.get(t.end),r=i.get(t.start),a=i.get(t.end);return{idx:e,crossLane:r&&a&&r.id!==a.id?1:0,dx:n&&o?Math.abs((o.x??0)-(n.x??0)):0,dy:n&&o?Math.abs((o.y??0)-(n.y??0)):0}}).sort((t,e)=>{if(t.crossLane!==e.crossLane)return e.crossLane-t.crossLane;const n=t.dx+t.dy,o=e.dx+e.dy;return Math.abs(n-o)>1?n-o:t.idx-e.idx}).map(t=>t.idx),M=(0,l.K)((t,e,n,o)=>{const r=Math.min(t.x,e.x),s=Math.max(t.x,e.x),i=Math.min(t.y,e.y),a=Math.max(t.y,e.y);return!!d.find(c=>(!n||c.nodeId!==n)&&((!o||c.nodeId!==o)&&(Math.abs(t.x-e.x)>Hn?c.minY<t.y&&c.maxY>t.y&&c.maxX>r&&c.minX<s:c.minX<t.x&&c.maxX>t.x&&c.maxY>i&&c.minY<a)))},"isSegmentBlocked"),K=new Map,I=new Map;for(const l of r)l.start&&l.end&&l.start!==l.end&&(I.set(l.start,(I.get(l.start)??0)+1),I.set(l.end,(I.get(l.end)??0)+1));const w=(0,l.K)((t,e)=>Wn(t,e,"bottom"),"determineSide"),S=new Map;for(const[l,nt]of r.entries()){if(!nt.start||!nt.end||nt.start===nt.end)continue;if(nt.points&&nt.points.length>0)continue;const t=s.get(nt.start),e=s.get(nt.end);if(!t||!e)continue;const n=(e.x??0)-(t.x??0),o=(e.y??0)-(t.y??0);S.set(l,{edgeIdx:l,srcId:nt.start,dstId:nt.end,srcSide:w(t,{x:e.x??0,y:e.y??0}),dstSide:w(e,{x:t.x??0,y:t.y??0}),absDx:Math.abs(n),absDy:Math.abs(o),dxSign:Math.sign(n),dySign:Math.sign(o)})}const v=(0,l.K)(t=>"top"===t.srcSide||"bottom"===t.srcSide?0===t.absDx?1/0:t.absDy/t.absDx:0===t.absDy?1/0:t.absDx/t.absDy,"preferenceStrength"),C=(0,l.K)(t=>"top"===t.srcSide||"bottom"===t.srcSide?t.dxSign>=0?"right":"left":t.dySign>=0?"bottom":"top","secondarySide"),L=new Map;for(const l of S.values()){const t=`${l.srcId}:${l.srcSide}`;L.has(t)||L.set(t,[]),L.get(t).push(l)}const k=new Map,T=(0,l.K)((t,e)=>`${t}:${e}`,"loadKey");for(const l of S.values())k.set(T(l.srcId,l.srcSide),(k.get(T(l.srcId,l.srcSide))??0)+1),k.set(T(l.dstId,l.dstSide),(k.get(T(l.dstId,l.dstSide))??0)+1);for(const l of L.values())if(!(l.length<2)){l.sort((t,e)=>{const n=v(t),o=v(e);return Math.abs(n-o)>1e-9?o-n:t.edgeIdx-e.edgeIdx});for(let t=1;t<l.length;t++){const e=l[t],n=C(e),o=k.get(T(e.srcId,e.srcSide))??0,r=k.get(T(e.srcId,n))??0;r>=o||(k.set(T(e.srcId,e.srcSide),o-1),k.set(T(e.srcId,n),r+1),e.srcSide=n)}}const $=(0,l.K)(t=>{const e=t?.shape;return"question"===e||"diamond"===e},"isDiamondNode"),R=new Map;for(const l of S.values())R.has(l.dstId)||R.set(l.dstId,new Set),R.get(l.dstId).add(l.dstSide);for(const l of S.values()){if(!$(s.get(l.srcId)))continue;const t=R.get(l.srcId);if(!t?.has(l.srcSide))continue;const e=C(l);if(t.has(e)||(k.get(T(l.srcId,e))??0)>0)continue;const n=k.get(T(l.srcId,l.srcSide))??0;k.set(T(l.srcId,l.srcSide),Math.max(0,n-1)),k.set(T(l.srcId,e),1),l.srcSide=e}for(const l of S.values()){const{edgeIdx:t,srcId:e,dstId:n,srcSide:o,dstSide:r}=l,i=s.get(e),a=s.get(n),c=`${e}:${o}:src`,f="top"===o||"bottom"===o?a.x??0:a.y??0;K.has(c)||K.set(c,[]),K.get(c).push({edgeIdx:t,oppositeCoord:f});const d=`${n}:${r}:dst`,u="top"===r||"bottom"===r?i.x??0:i.y??0;K.has(d)||K.set(d,[]),K.get(d).push({edgeIdx:t,oppositeCoord:u})}const O=new Map;for(const[l,nt]of K){if(nt.length<2)continue;nt.sort((t,e)=>t.oppositeCoord-e.oppositeCoord);const t=l.split(":"),e=t.slice(0,-2).join(":"),n=t[t.length-2],o=t[t.length-1],r=s.get(e);if(!r)continue;const i="left"===n||"right"===n?r.height??10:r.width??10,a=r.shape,c="question"===a||"diamond"===a?.3*i:i,f=20,d=Math.min(f,Math.max(8,c/(nt.length+1))),u=-(d*(nt.length-1))/2;for(const[s,l]of nt.entries()){const t=u+s*d,e=`${l.edgeIdx}:${o}`;O.set(e,t)}}const N=(0,l.K)(t=>Boolean(r[t]?.labelNodeId),"edgeHasLabelNode"),B=(0,l.K)((t,e)=>!!t&&((K.get(`${t}:${e}:src`)??[]).some(({edgeIdx:t})=>N(t))||(K.get(`${t}:${e}:dst`)??[]).some(({edgeIdx:t})=>N(t))),"faceHasLabelNode"),E=(0,l.K)((t,e,n)=>"top"===e||"bottom"===e?{x:t.x+n,y:t.y}:{x:t.x,y:t.y+n},"applyPortOffset"),F=(0,l.K)((t,e,n)=>{const o=S.get(t),r={x:n.x??0,y:n.y??0},s={x:e.x??0,y:e.y??0},i=o?.srcSide??w(e,r),a=o?.dstSide??w(n,s);let c=o?h(e,o.srcSide):g(e,r,!0),f=o?h(n,o.dstSide):g(n,s,!1);const d=O.get(`${t}:src`),l=O.get(`${t}:dst`);return void 0!==d&&(c=E(c,i,d)),void 0!==l&&(f=E(f,a,l)),{pSrcPort:c,pDstPort:f,srcSide:i,dstSide:a}},"portsForEdge");for(const nt of b){const t=r[nt];if(x[nt]=[],!t.start||!t.end)continue;if(t.points&&t.points.length>0)continue;if(t.start===t.end)continue;const e=s.get(t.start),n=s.get(t.end);if(!e||!n)continue;const{pSrcPort:o,pDstPort:i,srcSide:f,dstSide:h}=F(nt,e,n),g={...o},b={...i},w="top"===f||"bottom"===f,S="top"===h||"bottom"===h;if(w){const t=o.y>(e.y??0);g.y=t?o.y+Vn:o.y-Vn}else{const t=o.x>(e.x??0);g.x=t?o.x+Vn:o.x-Vn}if(S){const t=i.y>(n.y??0);b.y=t?i.y+Vn:i.y-Vn}else{const t=i.x>(n.x??0);b.x=t?i.x+Vn:i.x-Vn}const v=(0,l.K)((t,e)=>{for(const n of d)if(!e.includes(n.nodeId)&&t.x>n.minX&&t.x<n.maxX&&t.y>n.minY&&t.y<n.maxY)return{inside:!0,obstacle:n};return{inside:!1}},"isPointInObstacle"),C=(0,l.K)((t,e,n,o,r)=>{if(r){const r=t.y>(e.y??0);return{x:(n.x??0)>=t.x?o.maxX+_n:o.minX-_n,y:r?o.maxY+jn:o.minY-jn,leavesPositiveSide:r}}const s=t.x>(e.x??0),i=(n.y??0)>=t.y;return{x:s?o.maxX+_n:o.minX-_n,y:i?o.maxY+jn:o.minY-jn,leavesPositiveSide:s}},"obstacleDetour");let L=[];const k=[t.start,t.end],T=v(g,k);if(T.inside&&T.obstacle){const t=T.obstacle;if(w){const r=C(o,e,n,t,!0);g.x=r.x,g.y=r.y;const s=r.leavesPositiveSide?Math.min(t.minY-2,o.y+Vn):Math.max(t.maxY+2,o.y-Vn);L=[{x:o.x,y:s},{x:r.x,y:s},{x:r.x,y:r.y}]}else{const r=C(o,e,n,t,!1),s=r.leavesPositiveSide?Math.min(t.minX-2,o.x+Vn):Math.max(t.maxX+2,o.x-Vn);g.x=r.x,g.y=r.y,L=[{x:s,y:o.y},{x:s,y:r.y},{x:r.x,y:r.y}]}}let $=[];const R=v(b,k);if(R.inside&&R.obstacle){const t=R.obstacle;if(S){const o=C(i,n,e,t,!0);b.x=o.x,b.y=o.y,$=[{x:o.x,y:o.y},{x:i.x,y:o.y}]}else{const o=C(i,n,e,t,!1);b.x=o.x,b.y=o.y,$=[{x:o.x,y:o.y},{x:o.x,y:i.y}]}}if(0===L.length&&0===$.length){const e=_n,n=Math.abs(g.x-b.x)<e,r=Math.abs(g.y-b.y)<e,s=void 0!==O.get(`${nt}:src`)||void 0!==O.get(`${nt}:dst`),a=(K.get(`${t.start??""}:${f}:src`)?.length??0)+(K.get(`${t.start??""}:${f}:dst`)?.length??0),c=(K.get(`${t.end??""}:${h}:src`)?.length??0)+(K.get(`${t.end??""}:${h}:dst`)?.length??0),d=a>1||c>1,l=I.get(t.start??"")??0,u=I.get(t.end??"")??0,x=a>1&&B(t.start,f)||c>1&&B(t.end,h);if((n||r)&&!s&&(!d||d&&!x&&(a<=1||l<=2)&&(c<=1||u<=2))){if(!M(o,i,t.start,t.end)){t.points=[{...o},{...g},{...b},{...i}],m.add(nt);const e=r?"horizontal":"vertical",n=r?o.y:o.x,s=r?Math.min(o.x,i.x):Math.min(o.y,i.y),a=r?Math.max(o.x,i.x):Math.max(o.y,i.y),c={id:`fast-path-${e}-${n.toFixed(0)}-${nt}`,orientation:e,coord:n,spanMin:s,spanMax:a,tracks:[]};p.push({edgeIndex:nt,segmentIndex:0,orientation:e,pipe:c,trackIndex:0,from:s,to:a});continue}}}const N=u("vertical",g.x,g.y,g.y);g.x=N.coord;const E=u("vertical",b.x,b.y,b.y);b.x=E.coord;let Y=Math.min(g.x,b.x)-50,X=Math.max(g.x,b.x)+50,P=Math.min(g.y,b.y)-50,z=Math.max(g.y,b.y)+50;for(const r of d){const t=Math.min(g.x,b.x),e=Math.max(g.x,b.x),n=Math.min(g.y,b.y),o=Math.max(g.y,b.y);r.minX<e&&r.maxX>t&&r.minY<o&&r.maxY>n&&(Y=Math.min(Y,r.minX-25),X=Math.max(X,r.maxX+25),P=Math.min(P,r.minY-25),z=Math.max(z,r.maxY+25))}for(const r of d){if(r.maxX<Y||r.minX>X||r.maxY<P||r.minY>z)continue;const t=_n;u("horizontal",r.minY-t,Y,X),u("horizontal",r.maxY+t,Y,X);const e=jn;u("vertical",r.minX-e,P,z),u("vertical",r.maxX+e,P,z)}u("horizontal",g.y,Y,X),u("horizontal",b.y,Y,X);const A=a.filter(t=>"horizontal"===t.orientation&&t.coord>=P&&t.coord<=z),G=a.filter(t=>"vertical"===t.orientation&&t.coord>=Y&&t.coord<=X),D=(0,l.K)((t,e)=>`${t.toFixed(1)},${e.toFixed(1)}`,"getKey"),H=D(g.x,g.y),_=D(b.x,b.y),j=new Map,V=new Map,W=new Map,U=new Set,q=[];j.set(H,0),W.set(H,"n"),q.push({key:H,f:Math.hypot(b.x-g.x,b.y-g.y),pt:g}),U.add(H);let J=[];const Q=(0,l.K)((e,n)=>M(e,n,t.start,t.end),"checkSegmentBlocked"),Z={x:b.x,y:g.y},tt=Q(g,Z),et=Q(Z,b),ot=tt||et,rt={x:g.x,y:b.y},st=Q(g,rt),it=Q(rt,b);if(ot?st||it||(J=Math.abs(g.x-b.x)<Hn?[g,b]:[g,rt,b]):J=Math.abs(g.y-b.y)<Hn||Math.abs(g.x-b.x)<Hn?[g,b]:[g,Z,b],0===J.length)for(;q.length>0;){q.sort((t,e)=>t.f-e.f);const e=q.shift();if(U.delete(e.key),e.key===_){let t=_,e=b;for(J=[e];V.has(t);){const n=V.get(t);J.unshift(n),e=n,t=D(n.x,n.y)}break}const n=e.pt.x,o=e.pt.y,r=G.sort((t,e)=>t.coord-e.coord),s=r.findIndex(t=>Math.abs(t.coord-n)<1),i=A.sort((t,e)=>t.coord-e.coord),a=i.findIndex(t=>Math.abs(t.coord-o)<1),c=[];s>0&&c.push({x:r[s-1].coord,y:o}),s>=0&&s<r.length-1&&c.push({x:r[s+1].coord,y:o}),a>0&&c.push({x:n,y:i[a-1].coord}),a>=0&&a<i.length-1&&c.push({x:n,y:i[a+1].coord});for(const f of c){const r=Math.min(n,f.x),s=Math.max(n,f.x),i=Math.min(o,f.y),a=Math.max(o,f.y);if(d.some(e=>e.nodeId!==t.start&&e.nodeId!==t.end&&(r!==s?e.minY<o&&e.maxY>o&&e.maxX>r&&e.minX<s:e.minX<n&&e.maxX>n&&e.maxY>i&&e.minY<a)))continue;const c=D(f.x,f.y),l=Math.abs(f.x-n)+Math.abs(f.y-o),u=y(nt,e.pt,f);let h=0;const p=b.x-g.x,x=b.y-g.y,m=f.x-n,M=f.y-o;(x>10&&M<-5||x<-10&&M>5)&&(h=100*Math.abs(M)),(p>10&&m<-5||p<-10&&m>5)&&(h+=50*Math.abs(m));let K=0;const I=W.get(e.key)??"n",w=Math.abs(m)>Hn?"h":"v";"n"!==I&&I!==w&&(K=50);const S=l+u+h+K,v=(j.get(e.key)??1/0)+S,C=Math.abs(b.x-f.x)+Math.abs(b.y-f.y);if(v<(j.get(c)??1/0))if(V.set(c,e.pt),j.set(c,v),W.set(c,w),U.has(c)){const t=q.findIndex(t=>t.key===c);-1!==t&&(q[t].f=v+C)}else q.push({key:c,f:v+C,pt:f}),U.add(c)}}if(0===J.length&&(J=[g,{x:g.x,y:b.y},b]),J.length>4){const t=J[0],e=J[J.length-1];let n=Math.min(t.x,e.x),o=Math.max(t.x,e.x),r=Math.min(t.y,e.y),s=Math.max(t.y,e.y);for(const c of J)n=Math.min(n,c.x),o=Math.max(o,c.x),r=Math.min(r,c.y),s=Math.max(s,c.y);const i=o>Math.max(t.x,e.x),a=n<Math.min(t.x,e.x);if(c){const r=jn;if(i){const n=Math.max(t.x,e.x),s=Math.min(t.y,e.y),i=Math.max(t.y,e.y),a=d.filter(t=>t.minX<n&&t.maxX>n&&t.minY<i&&t.maxY>s);if(a.length>0){let n=Math.max(t.x,e.x);for(const t of a){const e=(t.minX+t.maxX)/2;if(void 0===t.visualXHalfExtent||isNaN(t.visualXHalfExtent))continue;const o=e+t.visualXHalfExtent+r;n=Math.max(n,o)}isNaN(n)||(o=n)}}if(a){const o=d.filter(n=>n.minX<Math.min(t.x,e.x)+r&&n.minY<Math.max(t.y,e.y)&&n.maxY>Math.min(t.y,e.y));if(o.length>0){let s=Math.min(t.x,e.x);for(const t of o){const e=(t.minX+t.maxX)/2-t.visualXHalfExtent-r;s=Math.min(s,e)}n=s}}}const f=(0,l.K)(n=>{const o=e.y>t.y,r=d.filter(n=>{const o=Math.min(t.x,e.x)<n.maxX&&Math.max(t.x,e.x)>n.minX,r=Math.min(t.y,e.y)<n.maxY&&Math.max(t.y,e.y)>n.minY;return o&&r});let s=r;if(c&&r.length>0){const t=r.filter(t=>t.minX<n&&t.maxX>n);t.length>0&&(s=t)}if(0===s.length)return e.y;if(o){const t=Math.max(...s.map(t=>t.maxY))+15;if(t<e.y-Hn)return t}else{const t=Math.min(...s.map(t=>t.minY))-15;if(t>e.y+Hn)return t}return e.y},"findBestReturnY"),u=(0,l.K)(n=>{const o=f(n),r={x:n,y:t.y},s={x:n,y:o},i={x:e.x,y:o},a=Q(t,r),c=Q(r,s),d=Q(s,i),l=o!==e.y&&Q(i,e);return a||c||d||l?null:Math.abs(o-e.y)<Hn?[t,r,s,e]:[t,r,s,i,e]},"trySimplifyWithDetourX"),h=i&&!a?u(o):a&&!i?u(n):null;h&&(J=h)}const at=[o,...L,...J,...$.reverse(),i];if(at.length>=3){const t=at[at.length-1],e=at[at.length-2],n=at[at.length-3],o=Math.abs(n.y-e.y)<Hn&&Math.abs(e.y-t.y)<Hn,r=Math.abs(n.x-e.x)<Hn&&Math.abs(e.x-t.x)<Hn;if(o){const o=Math.sign(e.x-n.x),r=Math.sign(t.x-n.x);0!==o&&o===r&&Math.abs(e.x-n.x)>Math.abs(t.x-n.x)&&at.splice(-2,1)}else if(r){const o=Math.sign(e.y-n.y),r=Math.sign(t.y-n.y);0!==o&&o===r&&Math.abs(e.y-n.y)>Math.abs(t.y-n.y)&&at.splice(-2,1)}}const ct=[at[0]];for(let r=1;r<at.length-1;r++){if(1===r){ct.push(at[r]);continue}const t=ct[ct.length-1],e=at[r],n=at[r+1];if(Math.abs(t.y-e.y)<Hn&&Math.abs(e.y-n.y)<Hn){if(e.x>t.x!==n.x>e.x){ct.push(e);continue}continue}if(Math.abs(t.x-e.x)<Hn&&Math.abs(e.x-n.x)<Hn){if(e.y>t.y!==n.y>e.y){ct.push(e);continue}continue}ct.push(e)}ct.push(at[at.length-1]);for(let r=0;r<ct.length-1;r++){const t=ct[r],e=ct[r+1],n=Math.abs(t.x-e.x)<Hn?"vertical":"horizontal",o="vertical"===n?t.x:t.y,s="vertical"===n?Math.min(t.y,e.y):Math.min(t.x,e.x),i="vertical"===n?Math.max(t.y,e.y):Math.max(t.x,e.x),a=u(n,o,s,i),c={edgeIndex:nt,segmentIndex:r,orientation:n,pipe:a,trackIndex:0,from:s,to:i};p.push(c),x[nt].push(p.length-1),a.tracks[0]||(a.tracks[0]={index:0,coord:a.coord,segments:[]}),a.tracks[0].segments.push({edgeIndex:nt,segmentIndex:r,from:s,to:i})}}const Y=(0,l.K)((t,e)=>t.from<e.to&&e.from<t.to,"segmentsOverlap"),X=(0,l.K)((t,e,n,o)=>{const r=!o.segments.some(n=>(n.edgeIndex!==e.edgeIndex||n.segmentIndex!==e.segmentIndex)&&Y(n,t)),s=!n.segments.some(n=>(n.edgeIndex!==t.edgeIndex||n.segmentIndex!==t.segmentIndex)&&Y(n,e));return!(!r||!s)&&(t.trackIndex=o.index,e.trackIndex=n.index,n.segments=[...n.segments.filter(e=>e.edgeIndex!==t.edgeIndex||e.segmentIndex!==t.segmentIndex),{edgeIndex:e.edgeIndex,segmentIndex:e.segmentIndex,from:e.from,to:e.to}],o.segments=[...o.segments.filter(t=>t.edgeIndex!==e.edgeIndex||t.segmentIndex!==e.segmentIndex),{edgeIndex:t.edgeIndex,segmentIndex:t.segmentIndex,from:t.from,to:t.to}],!0)},"trySwapSegmentsAcrossTracks"),P=(0,l.K)(t=>{const e=t.tracks.length;return t.tracks[e]={index:e,coord:t.coord,segments:[]},e},"createNewTrack"),z=(0,l.K)((t,e)=>{const n=t.pipe.tracks[t.trackIndex];n.segments=n.segments.filter(e=>e.edgeIndex!==t.edgeIndex||e.segmentIndex!==t.segmentIndex),t.trackIndex=e;t.pipe.tracks[e].segments.push({edgeIndex:t.edgeIndex,segmentIndex:t.segmentIndex,from:t.from,to:t.to})},"moveSegmentToTrack"),A=(0,l.K)((t,e)=>{const n=x[t.edgeIndex];for(const o of n){const n=p[o];n.pipe===t.pipe&&z(n,e)}},"moveSegmentChainToTrack"),G=(0,l.K)(t=>{const e=x[t.edgeIndex],n=e.indexOf(p.indexOf(t)),o=[];return n>0&&o.push(p[e[n-1]]),n<e.length-1&&o.push(p[e[n+1]]),o},"getAdjacentSegmentsAlongEdge"),D=(0,l.K)((t,e)=>{if(t.orientation===e.orientation)return!1;const n="horizontal"===t.orientation?t:e,o="horizontal"===t.orientation?e:t;return o.pipe.coord>n.from&&o.pipe.coord<n.to&&n.pipe.coord>o.from&&n.pipe.coord<o.to},"haveAnyCrossing"),H=(0,l.K)((t,e)=>{for(const n of t.tracks){if(!n.segments.some(t=>(t.edgeIndex!==e.edgeIndex||t.segmentIndex!==e.segmentIndex)&&Y(t,e)))return n.index}return-1},"findAvailableTrack"),_=(0,l.K)((t,e)=>{if(t.trackIndex===e.trackIndex)return Y(t,e);const n=G(t),o=G(e);return n.some(t=>o.some(e=>D(t,e)))},"segmentsConflict"),j=(0,l.K)((t,e,n)=>{if(X(t,e,t.pipe.tracks[t.trackIndex],e.pipe.tracks[e.trackIndex]))return;const o=H(t.pipe,e);n(e,-1!==o?o:P(t.pipe))},"resolveTrackConflict"),V=(0,l.K)(t=>{let e=0;for(let n=0;n<t.length;n++)for(let o=n+1;o<t.length;o++){const r=t[n],s=t[o];r.pipe===s.pipe&&(_(r,s)&&(e++,j(r,s,A)))}return e},"resolveHandleConflicts"),W=new Map,U=(0,l.K)(t=>{if(W.has(t))return W.get(t);const e=x[t];if(0===e.length){const e={dest:0,deviation:0,base:0,delta:0};return W.set(t,e),e}const n=p[e[0]].pipe.coord;let o=n;for(let s=1;s<e.length;s++){const t=p[e[s]];if("horizontal"===t.orientation){const e=t.from,r=t.to;o=Math.abs(e-n)>Math.abs(r-n)?e:r;break}}const r={dest:o,deviation:Math.abs(o-n),base:n,delta:o-n};return W.set(t,r),r},"getDestInfo"),q=(0,l.K)(()=>{let t=0;const e=new Map;for(const[o,s]of r.entries())0!==x[o].length&&s.start&&(e.has(s.start)||e.set(s.start,[]),e.get(s.start).push(o));const n=(0,l.K)(t=>{const e=r[t];if(!e.start||!e.end)return 0;const n=s.get(e.start),o=s.get(e.end);if(!n||!o)return 0;const i=(o.x??0)-(n.x??0),a=(o.y??0)-(n.y??0);return Math.abs(i)+Math.abs(a)},"getEdgeDistance");for(const o of e.values()){o.sort((t,e)=>{const o=U(t),r=U(e);if(Math.abs(o.deviation-r.deviation)>1)return o.deviation-r.deviation;if(Math.abs(o.dest-r.dest)>1)return o.dest-r.dest;const s=n(t),i=n(e);if(Math.abs(s-i)>1)return i-s;const a=x[t].length,c=x[e].length;if(a!==c)return a-c;if(1===a){const n=x[t][0],o=x[e][0];if(p[n]&&p[o]){const t=p[n],e=p[o],r=Math.abs(t.to-t.from),s=Math.abs(e.to-e.from);if(Math.abs(r-s)>1)return r-s}}return 0});const e=o.map(t=>p[x[t][0]]);t+=V(e)}return t},"fixSourceHandleCrossings"),J=(0,l.K)(()=>{let t=0;const e=new Map;for(const[n,o]of r.entries()){0!==x[n].length&&(o.end&&(e.has(o.end)||e.set(o.end,[]),e.get(o.end).push(n)))}for(const n of e.values()){n.sort((t,e)=>{const n=(0,l.K)(t=>{const e=x[t];if(e.length<2)return 0;const n=p[e[e.length-2]];return Math.abs(n.to-n.from)},"getDist"),o=n(t),r=n(e);return Math.abs(o-r)>.1?o-r:t-e});const e=n.map(t=>p[x[t][x[t].length-1]]);t+=V(e)}return t},"fixTargetHandleCrossings"),Q=(0,l.K)(()=>{let t=0;for(const e of a){const n=[];for(const t of e.tracks)for(const e of t.segments){const t=x[e.edgeIndex].find(t=>p[t].segmentIndex===e.segmentIndex);void 0!==t&&n.push(p[t])}n.sort((t,e)=>t.edgeIndex-e.edgeIndex||t.segmentIndex-e.segmentIndex);for(let e=0;e<n.length;e++)for(let o=e+1;o<n.length;o++){const r=n[e],s=n[o];_(r,s)&&(t++,j(r,s,z))}}return t},"fixPipeCrossings");let Z=0;for(;Z<10;){let t=0;if(t+=q(),t+=J(),t+=Q(),0===t)break;Z++}const tt=new Map;for(const nt of a){const t=[];nt.tracks.forEach(e=>{e.segments.forEach(n=>{t.push({edgeIndex:n.edgeIndex,segmentIndex:n.segmentIndex,trackIndex:e.index,from:n.from,to:n.to})})}),t.sort((t,e)=>t.from-e.from);const e=[];if(t.length>0){let n=[t[0]],o=t[0].to;for(let r=1;r<t.length;r++){const s=t[r];s.from<o?(n.push(s),o=Math.max(o,s.to)):(e.push(n),n=[s],o=s.to)}e.push(n)}for(const n of e){const t=new Set;n.forEach(e=>t.add(e.trackIndex));const e=new Map;n.forEach(t=>{const n=U(t.edgeIndex);e.set(t.trackIndex,(e.get(t.trackIndex)??0)+n.delta)});const o=[...t].filter(t=>(e.get(t)??0)<-1),r=[...t].filter(t=>(e.get(t)??0)>1),s=[...t].filter(t=>Math.abs(e.get(t)??0)<=1);o.sort((t,n)=>(e.get(n)??0)-(e.get(t)??0)),r.sort((t,n)=>(e.get(t)??0)-(e.get(n)??0));const i=(0,l.K)((t,e)=>{n.filter(e=>e.trackIndex===t).forEach(t=>{const n=m.has(t.edgeIndex)?nt.coord:e;tt.set(`${t.edgeIndex}-${t.segmentIndex}`,n)})},"assignCoord");let a=0;for(const n of o)a++,i(n,nt.coord-10*a);if(0===s.length&&t.size>0){const n=[...t].sort((t,n)=>Math.abs(e.get(t)??0)-Math.abs(e.get(n)??0))[0],i=o.indexOf(n);-1!==i&&o.splice(i,1);const a=r.indexOf(n);-1!==a&&r.splice(a,1),s.push(n)}let c=0;for(const n of s){if(0===c)i(n,nt.coord);else{const t=c%2==1?1:-1,e=Math.ceil(c/2);i(n,nt.coord+t*e*10*.5)}c++}let f=0;for(const n of r)f++,i(n,nt.coord+10*f)}}for(const[l,nt]of r.entries()){const t=x[l]??[];if(0===t.length)continue;const e=[],n=s.get(nt.start),o=s.get(nt.end),{pSrcPort:r,pDstPort:i}=F(l,n,o),a=t.map(t=>{const e=p[t],n=tt.get(`${e.edgeIndex}-${e.segmentIndex}`)??e.pipe.coord;return{orient:e.orientation,coord:n,from:e.from,to:e.to}});e.push(r);for(let s=0;s<a.length;s++){const t=a[s],n=e[e.length-1],o="vertical"===t.orient?n.y:n.x,r="vertical"===t.orient?n.x:n.y,i=a[s+1],c=s<a.length-1;if(Math.abs(r-t.coord)>Hn&&e.push(qn(t,o)),c&&i.orient===t.orient)if(Math.abs(t.coord-i.coord)>Hn){const n="vertical"===t.orient?(o+i.from)/2:Un(t,i);e.push(qn(t,n),qn(i,n))}else 0!==s&&s!==a.length-2||e.push(qn(t,Un(t,i)));else if(c)e.push(qn(t,i.coord));else{const n=Math.abs(t.from-o)<Math.abs(t.to-o)?t.to:t.from;e.push(qn(t,n))}}const c=e[e.length-1];(Math.abs(c.x-i.x)>Hn||Math.abs(c.y-i.y)>Hn)&&e.push(i);const f=[];e.length>0&&f.push(e[0]);for(let s=1;s<e.length;s++){const t=e[s],n=f[f.length-1];(Math.abs(t.x-n.x)>Hn||Math.abs(t.y-n.y)>Hn)&&f.push(t)}nt.points=f}for(const l of r){const t=l.__originalEdge;t&&l.points&&(t.points=l.points)}t.edges=(t.edges??[]).filter(t=>!t.isLayoutOnly);const et=(0,l.K)((t,e)=>{const n=e.x??0,o=e.y??0,r=e.width??0,s=e.height??0;if(r<=0||s<=0)return t;const i=n-r/2,a=n+r/2,c=o-s/2,f=o+s/2;if(t.x<i||t.x>a||t.y<c||t.y>f)return t;const d=t.x-i,l=a-t.x,u=t.y-c,h=f-t.y,g=Math.min(d,l,u,h);return g===d?{x:i,y:t.y}:g===l?{x:a,y:t.y}:g===u?{x:t.x,y:c}:{x:t.x,y:f}},"nodeBoundaryClamp");for(const l of t.edges){const t=l.points;if(!t||t.length<2)continue;const e=l.start,n=l.end,o=e?s.get(e):void 0,r=n?s.get(n):void 0;o&&(t[0]=et(t[0],o)),r&&(t[t.length-1]=et(t[t.length-1],r))}return t}function Qn(t){return t.direction??"TB"}function Zn(t){const e=Y(t),n=t.config.flowchart?.nodeSpacing??40,o=t.config.flowchart?.rankSpacing??100,r=t.config.swimlane?.ignoreCrossLaneEdges??!0,s=t.config.swimlane?.optimizeRanksByCrossings??!0,i=t.config.swimlane?.automaticLaneOrdering??!1,a=Qn(t),{ordered:c,coordinates:f}=Dn(e,{nodeGap:n,layerGap:o,ignoreCrossLaneEdges:r,optimizeRanksByCrossings:s,automaticLaneOrdering:i,direction:a});X(e,c,f,{nodeGap:n,layerGap:o});for(const d of t.edges??[])delete d.points;Jn(t,a);for(const d of t.edges??[])d.curve&&"basis"!==d.curve||(d.curve="rounded");return Oe(t,a),Re(t),a}async function to(t,e){const n=e.select("g");(0,r.g0)(n,t.markers,t.type,t.diagramId),(0,s.gh)(),(0,r.IU)(),(0,s.IU)(),(0,o.IU)(),F(t);const i=P(t);t.nodes=i.nodes,t.edges=i.edges;const{groups:a}=await h(n,t);Zn(t),await R(t,a)}(0,l.K)(Wn,"chooseOrthogonalSide"),(0,l.K)(Un,"sharedLineEndpointCoord"),(0,l.K)(qn,"pointOnLine"),(0,l.K)(Jn,"routeEdgesOrthogonal"),(0,l.K)(Qn,"getSwimlaneDirection"),(0,l.K)(Zn,"runSwimlaneLayoutCore"),(0,l.K)(to,"render")}}]);
@@ -0,0 +1 @@
1
+ "use strict";(globalThis.webpackChunk_elliemae_pui_cli=globalThis.webpackChunk_elliemae_pui_cli||[]).push([[7581],{6549(e,n,l){l.r(n),l.d(n,{assets:()=>a,contentTitle:()=>o,default:()=>d,frontMatter:()=>r,metadata:()=>i,toc:()=>c});const i=JSON.parse('{"id":"api/variables/stylelintConfig","title":"stylelintConfig","description":"Type Declaration","source":"@site/docs/api/variables/stylelintConfig.md","sourceDirName":"api/variables","slug":"/api/variables/stylelintConfig","permalink":"/cli/api/variables/stylelintConfig","draft":false,"unlisted":false,"editUrl":"https://git.elliemae.io/platform-ui/pui-cli.git/docs/api/variables/stylelintConfig.md","tags":[],"version":"current","frontMatter":{},"sidebar":"docsSidebar","previous":{"title":"prettierConfig","permalink":"/cli/api/variables/prettierConfig"},"next":{"title":"vitestConfig","permalink":"/cli/api/variables/vitestConfig"}}');var s=l(6070),t=l(5676);const r={},o="stylelintConfig",a={},c=[{value:"Type Declaration",id:"type-declaration",level:2},{value:"customSyntax",id:"customsyntax",level:3},{value:"extends",id:"extends",level:3},{value:"ignoreFiles",id:"ignorefiles",level:3},{value:"rules",id:"rules",level:3},{value:"rules.function-no-unknown",id:"rulesfunction-no-unknown",level:4},{value:"rules.selector-type-no-unknown",id:"rulesselector-type-no-unknown",level:4}];function u(e){const n={code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",pre:"pre",...(0,t.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"stylelintconfig",children:"stylelintConfig"})}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"stylelintConfig: {\n customSyntax: string;\n extends: string[];\n ignoreFiles: string[];\n rules: {\n function-no-unknown: null;\n selector-type-no-unknown: null;\n };\n};\n"})}),"\n",(0,s.jsx)(n.h2,{id:"type-declaration",children:"Type Declaration"}),"\n",(0,s.jsx)(n.h3,{id:"customsyntax",children:"customSyntax"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:'customSyntax: string = "postcss-styled-syntax";\n'})}),"\n",(0,s.jsx)(n.h3,{id:"extends",children:"extends"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"extends: string[];\n"})}),"\n",(0,s.jsx)(n.h3,{id:"ignorefiles",children:"ignoreFiles"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"ignoreFiles: string[];\n"})}),"\n",(0,s.jsx)(n.h3,{id:"rules",children:"rules"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"rules: {\n function-no-unknown: null;\n selector-type-no-unknown: null;\n};\n"})}),"\n",(0,s.jsx)(n.h4,{id:"rulesfunction-no-unknown",children:"rules.function-no-unknown"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"function-no-unknown: null = null;\n"})}),"\n",(0,s.jsx)(n.h4,{id:"rulesselector-type-no-unknown",children:"rules.selector-type-no-unknown"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-ts",children:"selector-type-no-unknown: null = null;\n"})})]})}function d(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(u,{...e})}):u(e)}}}]);