@agent-link/server 0.1.529 → 0.1.531
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/web/dist/assets/{abnfDiagram-VRR7QNED-BfiP2Zk_.js → abnfDiagram-VRR7QNED-BL1HPCFt.js} +1 -1
- package/web/dist/assets/arc-ukC8Y68L.js +1 -0
- package/web/dist/assets/architectureDiagram-ZJ3FMSHR-C1HYHPYr.js +1 -0
- package/web/dist/assets/blockDiagram-677ZJIJ3-DaVx4CNT.js +1 -0
- package/web/dist/assets/{c4Diagram-LMCZKHZV-C8OUf3BR.js → c4Diagram-LMCZKHZV-siodmCca.js} +1 -1
- package/web/dist/assets/channel-_3CXs0S6.js +1 -0
- package/web/dist/assets/{chunk-2Q5K7J3B-C6jSTVLi.js → chunk-2Q5K7J3B-Bx9BT0O5.js} +1 -1
- package/web/dist/assets/{chunk-32BRIVSS-CggGBtt4.js → chunk-32BRIVSS-DMbShUtg.js} +1 -1
- package/web/dist/assets/{chunk-5VM5RSS4-D1soGNls.js → chunk-5VM5RSS4-RoKGQ68D.js} +1 -1
- package/web/dist/assets/chunk-EX3LRPZG-37ljNSR4.js +1 -0
- package/web/dist/assets/{chunk-JWPE2WC7-4UUblnAa.js → chunk-JWPE2WC7-BNdwFjNx.js} +1 -1
- package/web/dist/assets/{chunk-MOJQB5TN-wHLLmx_6.js → chunk-MOJQB5TN-D2uwiiok.js} +1 -1
- package/web/dist/assets/{chunk-RYQCIY6F-3t9VqLG3.js → chunk-RYQCIY6F-C0Es5VR8.js} +1 -1
- package/web/dist/assets/chunk-V7JOEXUC-DPeMSwZ7.js +1 -0
- package/web/dist/assets/{chunk-VR4S4FIN-D1BCGr2u.js → chunk-VR4S4FIN-DGrJyFPf.js} +1 -1
- package/web/dist/assets/{chunk-XXDRQBXY-DGKbzfgb.js → chunk-XXDRQBXY-D2pNZxaH.js} +1 -1
- package/web/dist/assets/classDiagram-OUVF2IWQ-DN82DObI.js +1 -0
- package/web/dist/assets/classDiagram-v2-EOCWNBFH-DN82DObI.js +1 -0
- package/web/dist/assets/{cose-bilkent-JH36ORCC-mSZoV4j5.js → cose-bilkent-JH36ORCC-QFCp3j_I.js} +1 -1
- package/web/dist/assets/{cssMode-BCtl_sZS.js → cssMode-BaPv0biA.js} +1 -1
- package/web/dist/assets/{cynefin-VYW2F7L2-Bs61V2_s.js → cynefin-VYW2F7L2-Crr9xzVk.js} +1 -1
- package/web/dist/assets/{cynefinDiagram-TSTJHNR4-D8sErx-i.js → cynefinDiagram-TSTJHNR4-CvQDUnR9.js} +1 -1
- package/web/dist/assets/{dagre-VKFMJZFB-DwZwRIdq.js → dagre-VKFMJZFB-DZ22tequ.js} +1 -1
- package/web/dist/assets/diagram-FQU43EPY-DpEHzFWe.js +1 -0
- package/web/dist/assets/{diagram-G47NLZAW-D34u5D4R.js → diagram-G47NLZAW-COuikZny.js} +1 -1
- package/web/dist/assets/{diagram-NH7WQ7WH-Bclu-QKX.js → diagram-NH7WQ7WH-CixVLnNt.js} +1 -1
- package/web/dist/assets/diagram-OA4YK3LP-Dm4cMFGq.js +1 -0
- package/web/dist/assets/diagram-WEI45ONY-MTEIG5JH.js +1 -0
- package/web/dist/assets/{ebnfDiagram-CCIWWBDH-BMvfX5B7.js → ebnfDiagram-CCIWWBDH-DO12bkYN.js} +1 -1
- package/web/dist/assets/{editor.main-CRQmkoke.js → editor.main-CgpQktDS.js} +3 -3
- package/web/dist/assets/{erDiagram-Q63AITRT-C5fou_R0.js → erDiagram-Q63AITRT-C75kuF8B.js} +1 -1
- package/web/dist/assets/{flowDiagram-23GEKE2U-BvyeC4B4.js → flowDiagram-23GEKE2U-Dac7EBDx.js} +1 -1
- package/web/dist/assets/{freemarker2-ClAGg0IQ.js → freemarker2-CtNdfXyy.js} +1 -1
- package/web/dist/assets/{ganttDiagram-NO4QXBWP-BhYLcfRq.js → ganttDiagram-NO4QXBWP-CFomad4n.js} +1 -1
- package/web/dist/assets/{gitGraphDiagram-IHSO6WYX-GIUQR9io.js → gitGraphDiagram-IHSO6WYX-DW41CpSa.js} +1 -1
- package/web/dist/assets/{handlebars-BrhIT-2Z.js → handlebars-DqE2xJiR.js} +1 -1
- package/web/dist/assets/{html-Blr8PCTz.js → html--Y0ZbhJn.js} +1 -1
- package/web/dist/assets/{htmlMode-Dde-sA1T.js → htmlMode-tea_pqNu.js} +1 -1
- package/web/dist/assets/{index-DVzecOLh.css → index-CayH0jwf.css} +1 -1
- package/web/dist/assets/{index-i_5HmRyk.js → index-Cqf5h9KI.js} +6 -6
- package/web/dist/assets/{infoDiagram-FWYZ7A6U-BPN79fMb.js → infoDiagram-FWYZ7A6U--twUni5c.js} +1 -1
- package/web/dist/assets/ishikawaDiagram-FXEZZL3T-C4a7qlFu.js +1 -0
- package/web/dist/assets/{javascript-BGGps4Mr.js → javascript-BZzbthCk.js} +1 -1
- package/web/dist/assets/{journeyDiagram-5HDEW3XC-DuUwJnVX.js → journeyDiagram-5HDEW3XC-BnAJJ8PW.js} +1 -1
- package/web/dist/assets/{jsonMode-BmSjf3mu.js → jsonMode-DobieDWX.js} +1 -1
- package/web/dist/assets/kanban-definition-HUTT4EX6-_b-GFMgX.js +1 -0
- package/web/dist/assets/{layout-C0UWAnD9.js → layout-CdIFZZ-x.js} +1 -1
- package/web/dist/assets/{linear-UmV7KkKH.js → linear-COeTfGIu.js} +1 -1
- package/web/dist/assets/{liquid-BN5TFFjS.js → liquid-CVWJKf9r.js} +1 -1
- package/web/dist/assets/{lspLanguageFeatures-B_SnC_5n.js → lspLanguageFeatures-ktS9VY9y.js} +1 -1
- package/web/dist/assets/{map-DupEyqkA.js → map-CKQHuyK8.js} +1 -1
- package/web/dist/assets/{mdx-B9dc9gem.js → mdx-CMKiGQq4.js} +1 -1
- package/web/dist/assets/{mermaid.core-vavDl7Vc.js → mermaid.core-BFos4t0c.js} +3 -3
- package/web/dist/assets/mindmap-definition-LN4V7U3C-CZ596N6V.js +1 -0
- package/web/dist/assets/{pegDiagram-2B236MQR-DM11fXL6.js → pegDiagram-2B236MQR-B7mC_T4T.js} +1 -1
- package/web/dist/assets/pieDiagram-ENE6RG2P-CGnO8ABw.js +1 -0
- package/web/dist/assets/{python-WH7KbzLw.js → python-CfDM8Z6H.js} +1 -1
- package/web/dist/assets/{quadrantDiagram-ABIIQ3AL-ZEnQ2SUE.js → quadrantDiagram-ABIIQ3AL--YDPrR8n.js} +1 -1
- package/web/dist/assets/{railroadDiagram-RFXS5EU6-BVojcmrd.js → railroadDiagram-RFXS5EU6-BFyEmljG.js} +1 -1
- package/web/dist/assets/{razor-CimqSBMk.js → razor-BT-jAkic.js} +1 -1
- package/web/dist/assets/{requirementDiagram-TGXJPOKE-DxQ9PFxS.js → requirementDiagram-TGXJPOKE-Bg1DqDT0.js} +1 -1
- package/web/dist/assets/sankeyDiagram-HTMAVEWB-BQFuyDvQ.js +1 -0
- package/web/dist/assets/sequenceDiagram-DBY2YBRQ-D7VzO-wj.js +1 -0
- package/web/dist/assets/{sizeCapture-X5ZJPWSS-DvQ4QG8W.js → sizeCapture-X5ZJPWSS-DeGW_7pu.js} +1 -1
- package/web/dist/assets/stateDiagram-2N3HPSRC-ahSFUBWd.js +1 -0
- package/web/dist/assets/stateDiagram-v2-6OUMAXLB-BO6bAhNk.js +1 -0
- package/web/dist/assets/swimlanes-5IMT3BWC-Brv-BvGT.js +2 -0
- package/web/dist/assets/swimlanesDiagram-G3AALYLV-DVNi-V2w.js +1 -0
- package/web/dist/assets/timeline-definition-FHXFAJF6-B1YlZETF.js +1 -0
- package/web/dist/assets/{tsMode-Dx0tcA6l.js → tsMode-aqEsVbJ9.js} +1 -1
- package/web/dist/assets/{typescript-DNWZ8y2S.js → typescript-DVcqAE2u.js} +1 -1
- package/web/dist/assets/vennDiagram-L72KCM5P-CryCGvdS.js +1 -0
- package/web/dist/assets/wardleyDiagram-EHGQE667-D6SV9zmm.js +1 -0
- package/web/dist/assets/{xml-BhCfmf0h.js → xml-B8YYWLI7.js} +1 -1
- package/web/dist/assets/xychartDiagram-FW5EYKEG-D0h0SgNX.js +1 -0
- package/web/dist/assets/{yaml-Bxpf18Ey.js → yaml-U6lrNEwn.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/locales/en.json +1 -1
- package/web/dist/locales/zh.json +1 -1
- package/web/dist/assets/arc-048B3EAe.js +0 -1
- package/web/dist/assets/architectureDiagram-ZJ3FMSHR-DlOt88b5.js +0 -1
- package/web/dist/assets/blockDiagram-677ZJIJ3-Dp4rq3HL.js +0 -1
- package/web/dist/assets/channel-BPpgv-ij.js +0 -1
- package/web/dist/assets/chunk-EX3LRPZG-BGkdyKa7.js +0 -1
- package/web/dist/assets/chunk-V7JOEXUC-C9w7ddH_.js +0 -1
- package/web/dist/assets/classDiagram-OUVF2IWQ-5wWFaf41.js +0 -1
- package/web/dist/assets/classDiagram-v2-EOCWNBFH-5wWFaf41.js +0 -1
- package/web/dist/assets/diagram-FQU43EPY-BrBA0t46.js +0 -1
- package/web/dist/assets/diagram-OA4YK3LP-cxAUzrj7.js +0 -1
- package/web/dist/assets/diagram-WEI45ONY-DDoEUds_.js +0 -1
- package/web/dist/assets/ishikawaDiagram-FXEZZL3T-vYLEkyGy.js +0 -1
- package/web/dist/assets/kanban-definition-HUTT4EX6-VT776tJC.js +0 -1
- package/web/dist/assets/mindmap-definition-LN4V7U3C-DPO3dXQI.js +0 -1
- package/web/dist/assets/pieDiagram-ENE6RG2P-qizLyMyZ.js +0 -1
- package/web/dist/assets/sankeyDiagram-HTMAVEWB-C4RIECvO.js +0 -1
- package/web/dist/assets/sequenceDiagram-DBY2YBRQ-_3sOpSqP.js +0 -1
- package/web/dist/assets/stateDiagram-2N3HPSRC-BuGYx19B.js +0 -1
- package/web/dist/assets/stateDiagram-v2-6OUMAXLB-oKII58Qy.js +0 -1
- package/web/dist/assets/swimlanes-5IMT3BWC-YI2ijFsA.js +0 -2
- package/web/dist/assets/swimlanesDiagram-G3AALYLV-BGOAzM8z.js +0 -1
- package/web/dist/assets/timeline-definition-FHXFAJF6-CDEEncuw.js +0 -1
- package/web/dist/assets/vennDiagram-L72KCM5P-BO3KJlti.js +0 -1
- package/web/dist/assets/wardleyDiagram-EHGQE667-C8f1_s1-.js +0 -1
- package/web/dist/assets/xychartDiagram-FW5EYKEG-DV9mcR-c.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./sizeCapture-X5ZJPWSS-DvQ4QG8W.js","./mermaid.core-vavDl7Vc.js","./index-i_5HmRyk.js","./index-DVzecOLh.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as t}from"./index-i_5HmRyk.js";import{c as e}from"./chunk-RYQCIY6F-3t9VqLG3.js";import{al as n,am as o,an as r,ao as s,l as i,c as a,ad as c,ac as f,ae as l,as as d,au as u,y as h,ar as g,av as p,x,aw as m,_ as y,ax as b}from"./mermaid.core-vavDl7Vc.js";import{G as M}from"./graph-DaY0Al7L.js";import"./map-DupEyqkA.js";async function I(e,n){const o=new M({multigraph:!0,compound:!0}),r=[...n.edges],s=a(),i=e.insert("g").attr("class","root"),f=i.insert("g").attr("class","clusters"),l=i.insert("g").attr("class","edges edgePath"),d=i.insert("g").attr("class","edgeLabels"),u=i.insert("g").attr("class","nodes"),h=new Map,g=null!=e.node();await Promise.all(n.nodes.map(async t=>{var e;if(t.isGroup)o.setNode(t.id,{...t});else{if(g){const n=await c(u,t,{config:s,dir:t.dir}),o=(null==(e=n.node())?void 0:e.getBBox())??{width:0,height:0};h.set(t.id,n),t.width=o.width,t.height=o.height}o.setNode(t.id,{...t})}}));for(const t of r){o.setEdge(t.start,t.end,{...t},t.id);n.edges.some(e=>e.id===t.id)||n.edges.push(t)}if(globalThis.mermaidCaptureSizes){const{captureNodeSizes:o}=await t(async()=>{const{captureNodeSizes:t}=await import("./sizeCapture-X5ZJPWSS-DvQ4QG8W.js");return{captureNodeSizes:t}},__vite__mapDeps([0,1,2,3]),import.meta.url);o(e,n)}return{graph:o,groups:{clusters:f,edgePaths:l,edgeLabels:d,nodes:u,rootGroups:i},nodeElements:h}}y(I,"createGraphWithElements");var v=1e-5,S=1e-6;function w(t){const e=[];for(let n=0;n<t.length-1;n++)e.push({a:t[n],b:t[n+1]});return e}function L(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,l=n.y-t.y,d=(f*a-l*i)/c,u=(f*s-l*r)/c;return d<=S||d>=.999999||u<=S||u>=.999999?null:{point:{x:t.x+d*r,y:t.y+d*s},tA:d,tB:u}}function C(t){return Math.abs(t.b.x-t.a.x)>=Math.abs(t.b.y-t.a.y)}function k(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n],r=w(o.points);for(let s=n+1;s<t.length;s++){const n=t[s],i=w(n.points);for(const[t,s]of r.entries())for(const[r,a]of i.entries()){const i=L(s.a,s.b,a.a,a.b);if(!i)continue;const c=C(s);!!(c!==C(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 T(t){const e=Math.round(1e3*t)/1e3;return Number.isInteger(e),`${e}`}function $(t){return`${T(t.x)},${T(t.y)}`}function O(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}y(w,"buildSegmentList"),y(L,"segmentIntersection"),y(C,"isHorizontalSeg"),y(k,"findEdgeIntersections"),y(T,"fmt"),y($,"pointToString"),y(O,"getArcSweepFlag");function R(t,e){if(t.length<2)return t.map(t=>({...t}));const n=t.map(t=>({...t})),o=e.arrowTypeStart&&b[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&&b[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 N(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${$(a)}`];return"arc"===r?f.push(`A${T(t.r)},${T(t.r)} 0 0 ${o} ${$(c)}`):f.push(`M${$(c)}`),f}function B(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<v||f<v)return null;const l=r/c,d=s/c,u=i/f,h=a/f,g=l*u+d*h,p=Math.max(-1,Math.min(1,g)),x=Math.acos(p);if(x<v||Math.abs(Math.PI-x)<v)return null;const m=Math.min(o/Math.sin(x/2),c/2,f/2);return{startX:e.x-l*m,startY:e.y-d*m,endX:e.x+u*m,endY:e.y+h*m,ctrlX:e.x,ctrlY:e.y,cutLen:m}}function E(t,e,n){const o=t.points;if(o.length<2)return"";const r=R(o,t),s="rounded"===t.curve,i=w(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${$(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,l=0===e?0:(t.b.y-t.a.y)/e,d=O(t);let u=0;if(s&&f>0){const t=B(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=B(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(...N(r,o,l,d,n.jumpStyle));s&&g?(c.push(`L${T(g.startX)},${T(g.startY)}`),c.push(`Q${T(g.ctrlX)},${T(g.ctrlY)} ${T(g.endX)},${T(g.endY)}`)):c.push(`L${$(t.b)}`)}return c.join(" ")}function F(t){return/^[\d\s+,.LMelm-]*$/.test(t)}function Y(t){return!t||("linear"===t||"rounded"===t||"step"===t||"stepBefore"===t||"stepAfter"===t)}function X(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 P(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=X(e.getAttribute("data-points"))??f.points;s.push({...f,points:n})}const a=k(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=null==e?void 0:e.curve;if(void 0!==o&&!Y(o))continue;const s=i.get(f.id);if(!s)continue;if(void 0===o){if(!F(s.getAttribute("d")??""))continue}const a=s.getAttribute("style")??"",l=/stroke-dasharray\s*:\s*0\s+([\d.]+)\s+[\d.]+\s+([\d.]+)/.exec(a),d=l?Number.parseFloat(l[1]):null,u=l?Number.parseFloat(l[2]):null,h=E(f,t,n);if(s.setAttribute("d",h),null!==d&&null!==u&&"function"==typeof s.getTotalLength){const t=s.getTotalLength(),e=`0 ${d} ${Math.max(0,t-d-u)} ${u}`,n=a.replace(/stroke-dasharray\s*:[^;]*;?/g,`stroke-dasharray: ${e};`).replace(/;\s*;+/g,";");s.setAttribute("style",n)}}}async function z(t,e){var n,o;for(const i of t.nodes)i.isGroup?await f(e.clusters,i):l(i);const r=new Map;for(const i of t.nodes)(null==i?void 0:i.id)&&r.set(i.id,i);for(const i of t.edges){const n=i.start?r.get(i.start)??{}:{},o=i.end?r.get(i.end)??{}:{},s=d(e.edgePaths,{...i},{},t.type,n,o,t.diagramId);i.label&&await u(e.rootGroups,i),i.label&&A(i,s)}const s=null==(o=null==(n=t.config)?void 0:n.swimlane)?void 0:o.lineHops;if(!1!==s){const n="gap"===s?"gap":"arc",o=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}));P(e.edgePaths,o,{enabled:!0,jumpRadius:6,jumpStyle:n})}}function A(t,e){const n=(null==e?void 0:e.updatedPath)??(null==e?void 0:e.originalPath),o=h(),{subGraphTitleTotalMargin:r}=g({flowchart:o.flowchart??{}});if(t.label){const o=p.get(t.id);let s=t.x,a=t.y;if(n){const o=x.calcLabelPosition(n);i.debug("Moving label "+t.label+" from (",s,",",a,") to (",o.x,",",o.y,") abc88"),e&&(s=o.x,a=o.y)}o.attr("transform",`translate(${s}, ${a+r/2})`)}if(null==t?void 0:t.startLabelLeft){const e=m.get(t.id).startLeft;let o=null==t?void 0:t.x,r=null==t?void 0:t.y;if(n){const e=x.calcTerminalLabelPosition(t.arrowTypeStart?10:0,"start_left",n);o=e.x,r=e.y}e.attr("transform",`translate(${o}, ${r})`)}if(t.startLabelRight){const e=m.get(t.id).startRight;let o=t.x,r=t.y;if(n){const e=x.calcTerminalLabelPosition(t.arrowTypeStart?10:0,"start_right",n);o=e.x,r=e.y}e.attr("transform",`translate(${o}, ${r})`)}if(t.endLabelLeft){const e=m.get(t.id).endLeft;let o=t.x,r=t.y;if(n){const e=x.calcTerminalLabelPosition(t.arrowTypeEnd?10:0,"end_left",n);o=e.x,r=e.y}e.attr("transform",`translate(${o}, ${r})`)}if(t.endLabelRight){const e=m.get(t.id).endRight;let o=t.x,r=t.y;if(n){const e=x.calcTerminalLabelPosition(t.arrowTypeEnd?10:0,"end_right",n);o=e.x,r=e.y}e.attr("transform",`translate(${o}, ${r})`)}}y(R,"applyMarkerOffsets"),y(N,"emitJump"),y(B,"computeRoundedCorner"),y(E,"rewriteEdgePath"),y(F,"isStraightPath"),y(Y,"curveSupportsLineHops"),y(X,"decodeDataPoints"),y(P,"applyLineJumpsToSvg"),y(z,"adjustLayout"),y(A,"positionEdgeLabel");var G="__swimlane_default__";function D(t){return Math.max(t.padding??20,20)}function H(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 j(t){const e=t.direction,n=t.nodes??(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===G);r?r.isGroup&&(r.shape="swimlane",e&&(r.direction=e)):(r={id:G,label:"",isGroup:!0,shape:"swimlane",padding:20,...e?{direction:e}:{}},n.push(r));for(const s of o)s.parentId=G}function _(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 V(t,e,n,o){const{layout:r}=t,s=t.nodeById,i=(null==o?void 0:o.layerGap)??100,a=(null==o?void 0: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??[],l=new Map,d=[];for(const u of f){if(!(null==u?void 0:u.isGroup))continue;u.parentId||d.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*D(u),i=t,a=Math.max(0,o-e)+n,c=Math.max(0,s-r)+i,f=(e+o)/2,d=(r+s)/2;u.x=f,u.y=d,u.width=a,u.height=c,l.set(u.id,{minX:e,maxX:o,minY:r,maxY:s})}}if(d.length>0&&l.size>0){let t=1/0,e=-1/0,n=0;for(const o of d){const r=o.padding??20;r>n&&(n=r);const s=l.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 d)e.y=s,e.height=r,e.swimlaneContentTop=t;const i=[...d].sort((t,e)=>(t.x??0)-(e.x??0)),a=[],c=[],f=[];for(const t of i){const e=l.get(t.id);if(!e)continue;const n=Math.max(0,e.maxX-e.minX)+2*D(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 d){const n=t.get(e.id);null!=n&&(e.width=n),H(e)}}}}}y(D,"topLaneHorizontalPadding"),y(H,"assignTopLaneTitleRect"),y(j,"prepareLayoutForSwimlanes"),y(_,"toGraphView"),y(V,"writeBackToLayoutData");function W(t){const e=[],n=[],o=new Map;for(const i of t.nodes)o.set(i.id,i);for(const a of t.edges){if(!a.label||0===a.label.length)continue;if(a.isLayoutOnly)continue;if(a.labelNodeId)continue;const t=a.start?o.get(a.start):void 0,r=a.end?o.get(a.end):void 0;if(!t||!r){i.warn("[EdgeLabelNodes]",`Edge ${a.id} has missing source or target node`);continue}const s=`edge-label-${a.start}-${a.end}-${a.id}`,c=t.parentId!==r.parentId?r.parentId:t.parentId,f={id:s,label:a.label,edgeStart:a.start??"",edgeEnd:a.end??"",shape:"labelRect",width:0,height:0,isEdgeLabel:!0,isDummy:!0,parentId:c,isGroup:!1,labelStyle:Array.isArray(a.labelStyle)?a.labelStyle[0]:a.labelStyle??"",...t.dir?{dir:t.dir}:{}};e.push(f),a.labelNodeId=s,a.label=void 0,a.text=void 0;const l={id:`${a.id}-to-label`,start:a.start,end:s,type:"normal",isLayoutOnly:!0},d={id:`${a.id}-from-label`,start:s,end:a.end,type:"normal",isLayoutOnly:!0};n.push(l,d)}const r=[...t.nodes,...e],s=[...t.edges,...n];return{...t,nodes:r,edges:s}}y(W,"createEdgeLabelNodes");var J=.001;function q(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:ht(e,n,o,r)}:void 0}function K(t){if(t.isGroup)return;const e=q(t);if(!e)return;return{id:String(t.id??""),cx:e.cx,cy:e.cy,rect:e.rect}}function Q(t,e,n=J){return Math.abs(t.x-e.x)<n&&Math.abs(t.y-e.y)<n}function Z(t,e,n=J){return Math.abs(t.x-e.x)<n}function U(t,e,n=J){return Math.abs(t.y-e.y)<n}function tt(t,e,n=J){return U(t,e,n)&&Math.abs(t.x-e.x)>n}function et(t,e,n=J){return Z(t,e,n)&&Math.abs(t.y-e.y)>n}function nt(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 ot(t,e,n=J){return t.horizontal&&e.horizontal&&U(t.a,e.a,n)?nt(t.a.x,t.b.x,e.a.x,e.b.x):t.vertical&&e.vertical&&Z(t.a,e.a,n)?nt(t.a.y,t.b.y,e.a.y,e.b.y):0}function rt(t,e=J){const n=[];for(let o=0;o<t.length-1;o++){const r=t[o],s=t[o+1],i=tt(r,s,e),a=et(r,s,e);(i||a)&&n.push({index:o,a:r,b:s,horizontal:i,vertical:a})}return n}function st(t,e=J){const n=rt(t,e);let o=0;for(let r=1;r<n.length;r++)n[r-1].horizontal!==n[r].horizontal&&o++;return o}function it(t,e=J){const n=[];for(const o of t){const t=n.length>0?n[n.length-1]:void 0;t&&Q(t,o,e)||n.push({x:o.x,y:o.y})}return n}function at(t,e=J){if(!t||4!==t.length)return;const[n,o,r,s]=t;if(tt(n,o,e)&&et(o,r,e)&&tt(r,s,e))return{kind:"HVH",p0:n,p1:o,p2:r,p3:s};return et(n,o,e)&&tt(o,r,e)&&et(r,s,e)?{kind:"VHV",p0:n,p1:o,p2:r,p3:s}:void 0}function ct(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 ft(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 lt(t,e){return t.left<=e.left&&t.right>=e.right&&t.top<=e.top&&t.bottom>=e.bottom}function dt(t,e){return t.left<e.right&&t.right>e.left&&t.top<e.bottom&&t.bottom>e.top}function ut(t,e){return{left:t.left-e,right:t.right+e,top:t.top-e,bottom:t.bottom+e}}function ht(t,e,n,o){return{left:t-n/2,right:t+n/2,top:e-o/2,bottom:e+o/2}}function gt(t){var e;return null==(e=q(t))?void 0:e.rect}function pt(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 xt(t,e,n,o,r,s=J){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(U(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(U(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(Z(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(Z(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 mt(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 yt(t){const e=new Map,n=[];for(const o of t){if(o.isEdgeLabel)continue;const t=K(o);t&&(e.set(t.id,t),n.push({id:t.id,rect:t.rect}))}return{nodeInfoById:e,realNodeRects:n}}function bt(t){const e=[],n=[];for(const o of t){const t=K(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 Mt(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,...ht(t,r,s,i)})}return n}function It(t,e,n=J){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 vt(t,e,n,o=[],r=0){for(const s of n)if(!o.includes(s.id)&&ct(t,e,s.rect,-r))return!0;return!1}function St(t,e,n,o,r=J,s=1e-6){const i=U(t,e,r),a=Z(t,e,r),c=U(n,o,r),f=Z(n,o,r);if(i&&c||a&&f)return!1;if(!i&&!a||!c&&!f)return!1;const l=i?{a:t,b:e}:{a:n,b:o},d=a?{a:t,b:e}:{a:n,b:o},u=l.a.y,h=Math.min(l.a.x,l.b.x),g=Math.max(l.a.x,l.b.x),p=d.a.x,x=Math.min(d.a.y,d.b.y),m=Math.max(d.a.y,d.b.y);if(p<h||p>g||u<x||u>m)return!1;const y=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,b=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;return!(y&&b)}function wt(t,e,n,o,r=J){const s=U(t,e,r),i=Z(t,e,r),a=U(n,o,r),c=Z(n,o,r);return i&&c&&Z(t,n,r)?nt(t.y,e.y,n.y,o.y)>r:!!(s&&a&&U(t,n,r))&&nt(t.x,e.x,n.x,o.x)>r}function Lt(t,e,n,o,{epsilon:r=J,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||!Q(i,a,r))&&(St(t,e,i,a,r)||wt(t,e,i,a,r)))return!0}}return!1}function Ct(t,e,n,o,r=J){const s=U(t,e,r),i=Z(t,e,r),a=U(n,o,r),c=Z(n,o,r);if(!(s&&c||i&&a))return!1;const f=s?{a:t,b:e}:{a:n,b:o},l=s?{a:n,b:o}:{a:t,b:e},d=f.a.y,u=Math.min(f.a.x,f.b.x),h=Math.max(f.a.x,f.b.x),g=l.a.x,p=Math.min(l.a.y,l.b.y),x=Math.max(l.a.y,l.b.y);return g>u+r&&g<h-r&&d>p+r&&d<x-r}function kt(t,e,n){const o=Math.min(e,n),r=Math.max(e,n);return t>o+J&&t<r-J}function Tt(t,e,n){return Z(t,e)&&Z(e,n)?kt(e.y,t.y,n.y):!(!U(t,e)||!U(e,n))&&kt(e.x,t.x,n.x)}function $t(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(Q(r,i)){o++,e=!0;continue}if(Tt(r,s,i)){e=!0;continue}}n.push(s)}return{points:n,changed:e}}function Ot(t){const e=[t[0]];for(let o=1;o<t.length;o++){const n=e[e.length-1],r=t[o];if(!Z(n,r)&&!U(n,r)){const t=e.length>=2?e[e.length-2]:void 0,o=!!t&&Z(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&&Q(t,o)||n.push(o)}return n}function Rt(t){if(t.length<3)return t;let e=[...t];for(let n=0;n<32;n++){const t=$t(e);if(e=t.points,!t.changed)break}return e}y(q,"measuredNodeRect"),y(K,"nodeBoundsInfoFor"),y(Q,"samePoint"),y(Z,"sameX"),y(U,"sameY"),y(tt,"isHorizontalSegment"),y(et,"isVerticalSegment"),y(nt,"overlapLength"),y(ot,"sameAxisSegmentOverlapLength"),y(rt,"orthogonalSegmentsForPoints"),y(st,"countOrthogonalBends"),y(it,"dedupeConsecutivePoints"),y(at,"classifyThreeSegmentRoute"),y(ct,"segmentBoundsOverlapRect"),y(ft,"pointInsideRect"),y(lt,"rectContainsRect"),y(dt,"rectsOverlap"),y(ut,"inflateRect"),y(ht,"rectFromCenterSize"),y(gt,"rectOfNodeBounds"),y(pt,"portForRectSide"),y(xt,"buildOrthogonalPortPath"),y(mt,"buildSameSideTrackPath"),y(yt,"collectRealNodeBounds"),y(bt,"collectNodeRectEntries"),y(Mt,"collectLayoutNodeRects"),y(It,"getNodePairGeometry"),y(vt,"segmentHitsAnyRect"),y(St,"orthogonalSegmentsCross"),y(wt,"sameAxisSegmentsOverlap"),y(Lt,"segmentConflictsWithAnyEdge"),y(Ct,"orthogonalSegmentsStrictlyCross"),y(kt,"strictlyBetween"),y(Tt,"isCollinearIntermediate"),y($t,"simplifyPolylineOnce"),y(Ot,"orthogonalizePolyline"),y(Rt,"simplifyPolyline");var Nt=.001;function Bt(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?gt(r):void 0,dstRect:s?gt(s):void 0}}function Et(t,e,n){if(U(t,e,Nt)){return{x:t.x<n.left?n.left:n.right,y:t.y}}if(Z(t,e,Nt)){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 Ft(t,e,n){const o=n?1:-1;let r=n?0:t.length-1;for(;r>=0&&r<t.length&&ft(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=Et(t[r],t[s],e);return n?[i,...t.slice(r)]:[...t.slice(0,r+1),i]}function Yt(t,e){for(const n of t){const t=Bt(n,e,2);if(!t)continue;let o=[...t.points];t.srcRect&&(o=Ft(o,t.srcRect,!0)),t.dstRect&&(o=Ft(o,t.dstRect,!1)),o=Rt(Ot(o)),o=Wt(o,t.srcRect,t.dstRect),t.edge.points=Rt(Ot(o))}}function Xt(t,e,n,o=!1){if(U(t,e,Nt)){if(e.y<n.top-Nt||e.y>n.bottom+Nt)return e;if(o){if(t.x<n.left-Nt)return{x:n.left,y:t.y};if(t.x>n.right+Nt)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(Z(t,e,Nt)){if(e.x<n.left-Nt||e.x>n.right+Nt)return e;if(o){if(t.y<n.top-Nt)return{x:t.x,y:n.top};if(t.y>n.bottom+Nt)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 Pt(t,e,n){const o=t[e];for(let r=e+n;r>=0&&r<t.length;r+=n){const e=t[r];if(!Q(e,o,Nt))return e}return t[e+n]}function zt(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 At(t,e,n){const{lo:o,hi:r}=zt(e,n);return Math.min(r,Math.max(o,t))}function Gt(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 Dt(t,e){return"left"===e||"right"===e?zt(t.top,t.bottom):zt(t.left,t.right)}function Ht(t,e,n){const o=t.y>=n.top-Nt&&t.y<=n.bottom+Nt,r=t.x>=n.left-Nt&&t.x<=n.right+Nt;if(U(t,e,Nt)&&o){if(Math.abs(t.x-n.left)<Nt)return"left";if(Math.abs(t.x-n.right)<Nt)return"right"}if(Z(t,e,Nt)&&r){if(Math.abs(t.y-n.top)<Nt)return"top";if(Math.abs(t.y-n.bottom)<Nt)return"bottom"}}function jt(t){return"left"===t||"right"===t}function _t(t,e,n,o,r){const s=[],i=n?Ht(t,e,n):void 0,a=o?Ht(e,t,o):void 0;return n&&i&&jt(i)===r&&s.push(Dt(n,i)),o&&a&&jt(a)===r&&s.push(Dt(o,a)),s.length>0?Gt(s):void 0}function Vt(t,e,n,o,r){const s=_t(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)<Nt?void 0:r?[{x:t.x,y:a},{x:e.x,y:a}]:[{x:a,y:t.y},{x:a,y:e.y}]}function Wt(t,e,n){if(2!==t.length)return t;const[o,r]=t;return U(o,r,Nt)?Vt(o,r,e,n,!0)??t:Z(o,r,Nt)?Vt(o,r,e,n,!1)??t:t}function Jt(t,e,n){return jt(n)?{x:t.x,y:At(t.y,e.top,e.bottom)}:{x:At(t.x,e.left,e.right),y:t.y}}function qt(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&&!U(e,o,Nt))break;if(!s&&!Z(e,o,Nt))break;s?i[a].y=r.y:i[a].x=r.x}return i}function Kt(t,e,n){if(t.length<2)return t;const o=n?0:t.length-1,r=n?1:-1,s=t[o],i=Pt(t,o,r);if(!i)return t;const a=Ht(s,i,e);if(!a)return t;const c=jt(a),f=Jt(s,e,a);return Q(s,f,Nt)?t:qt(t,o,r,s,f,c)}function Qt(t,e,n){const o=Math.min(t.x,e.x)>=n.left-Nt&&Math.max(t.x,e.x)<=n.right+Nt,r=Math.min(t.y,e.y)>=n.top-Nt&&Math.max(t.y,e.y)<=n.bottom+Nt;return Math.abs(t.y-n.top)<Nt&&Math.abs(e.y-n.top)<Nt&&o?"top":Math.abs(t.y-n.bottom)<Nt&&Math.abs(e.y-n.bottom)<Nt&&o?"bottom":Math.abs(t.x-n.left)<Nt&&Math.abs(e.x-n.left)<Nt&&r?"left":Math.abs(t.x-n.right)<Nt&&Math.abs(e.x-n.right)<Nt&&r?"right":void 0}function Zt(t,e,n,o){switch(t){case"top":return Z(e,n,Nt)&&n.y<o.top-Nt;case"bottom":return Z(e,n,Nt)&&n.y>o.bottom+Nt;case"left":return U(e,n,Nt)&&n.x<o.left-Nt;case"right":return U(e,n,Nt)&&n.x>o.right+Nt}}function Ut(t,e,n){if(t.length<3)return t;if(n){const n=Qt(t[0],t[1],e);return n&&Zt(n,t[1],t[2],e)?t.slice(1):t}const o=t.length-1,r=Qt(t[o-1],t[o],e);return r&&Zt(r,t[o-1],t[o-2],e)?t.slice(0,o):t}function te(t,e,n){let o=t;if(e){const t=Pt(o,0,1);if(t){const n=Xt(t,o[0],e);n!==o[0]&&(o=[n,...o.slice(1)])}o=Ut(o,e,!0)}if(n){const t=o.length-1,e=Pt(o,t,-1);if(e){const r=Xt(e,o[t],n,!0);r!==o[t]&&(o=[...o.slice(0,t),r])}o=Ut(o,n,!1)}const r=Wt(o,e,n);return r!==o||2===o.length?r:(e&&(o=Kt(o,e,!0)),n&&(o=Kt(o,n,!1)),o)}function ee(t,e){for(const n of t){const t=Bt(n,e,2);if(!t)continue;const o=te(it(t.points,Nt),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 ne(t){return new Map(t.map(t=>[t.id,t]))}function oe(t,e){let n=t.parentId,o=null;for(;n;){const t=e.get(n);if(!(null==t?void 0:t.isGroup))break;o=t.id,n=t.parentId}return o}function re(t,e){let n=0,o=t.parentId;for(;o;){const t=e.get(o);if(!(null==t?void 0:t.isGroup))break;n++,o=t.parentId}return n}function se(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 ie(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 ae(t){const e=ne(t),n=t.filter(t=>t.isGroup&&t.parentId).sort((t,n)=>re(n,e)-re(t,e));for(const o of n){const e=se(t.filter(t=>t.parentId===o.id));e&&ie(o,e)}}function ce(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=y(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 fe(t){return!(t.nodes??[]).some(t=>!t.isGroup)||ce(t,"y")}function le(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 L of r){const t=L.x??0,e=L.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 L of r)c+=L.width??0,f+=L.height??0;const l=c/r.length,d=f/r.length,u=d>0?Math.max(1,l/d):1;for(const L of r){const t=L.x??0,e=((L.y??0)-i)*u+a,n=t-s;L.x=e,L.y=n}for(const L of o)if(L.points)for(const t of L.points){const e=t.x,n=(t.y-i)*u+a,o=e-s;t.x=n,t.y=o}ae(n);const h=n.filter(t=>t.isGroup&&!t.parentId);if(0===h.length)return"RL"===e&&ce(t,"x"),!0;const g=ne(n),p=new Map;for(const L of n){if(L.isGroup)continue;const t=oe(L,g);if(!t)continue;const e=p.get(t)??[];e.push(L),p.set(t,e)}let x=0;for(const L of h){const t=L.padding??0;t>x&&(x=t)}const m=[];let y=1/0,b=-1/0;for(const L of h){const t=se(p.get(L.id)??[]);t&&(y=Math.min(y,t.minX),b=Math.max(b,t.maxX),m.push({lane:L,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),I=a+M,v=(y+b)/2-M/2-a,S=v+I/2,w=Math.max(x,a);m.sort((t,e)=>t.centerY-e.centerY);for(let L=0;L<m.length;L++){const t=m[L];let e,n;if(0===L)e=t.contentTop-w;else{e=(m[L-1].contentBottom+t.contentTop)/2}if(L===m.length-1)n=t.contentBottom+w;else{const e=m[L+1];n=(t.contentBottom+e.contentTop)/2}const o=Math.max(0,n-e),r=(e+n)/2;t.lane.x=S,t.lane.y=r,t.lane.width=I,t.lane.height=o,t.lane.swimlaneContentTop=t.contentTop,t.lane.groupTitleRect={left:v,right:v+a,top:e,bottom:n}}return"RL"===e&&ce(t,"x"),!0}y(Bt,"endpointContextFor"),y(Et,"segmentEnterPoint"),y(Ft,"clipEndpoint"),y(Yt,"clipEdgeEndpointsToNodeBoundaries"),y(Xt,"snapEndpointToBoundary"),y(Pt,"firstDistinctAdjacent"),y(zt,"cornerClearanceRange"),y(At,"clampToCornerClearance"),y(Gt,"intersectRanges"),y(Dt,"clearanceRangeForSide"),y(Ht,"terminalSideForSegment"),y(jt,"isHorizontalSide"),y(_t,"straightClearanceRange"),y(Vt,"clearStraightEndpointCornerAxis"),y(Wt,"clearStraightEndpointCornerConnections"),y(Jt,"cornerClearedEndpoint"),y(qt,"moveCollinearEndpointRun"),y(Kt,"clearEndpointCornerConnection"),y(Qt,"borderSideForSegment"),y(Zt,"leavesOutward"),y(Ut,"collapseOwnBorderStub"),y(te,"snapAndCollapseEndpoints"),y(ee,"prepareEdgeEndpointsForRenderer"),y(ne,"buildNodeMap"),y(oe,"resolveTopLevelGroupId"),y(re,"groupDepth"),y(se,"boundsForChildren"),y(ie,"applyGroupBounds"),y(ae,"recomputeNestedGroupBounds"),y(ce,"mirrorAxis"),y(fe,"applyBtDirectionTransform"),y(le,"applyLrDirectionTransform");var de=1e-6,ue=[0,8,-8,16,-16];function he(t,e){const{nodeInfoById:n,realNodeRects:o}=yt(e);for(const r of t){if(r.isLayoutOnly)continue;const e=r.points;if(!e||e.length<4)continue;const s=at(it(e,de),de);if(!s)continue;const{p3:i}=s,a="HVH"===s.kind,c=It(r,n,de);if(!c)continue;const{srcId:f,dstId:l,srcInfo:d,dstInfo:u,collinearX:h,collinearY:g}=c;if(h||g)continue;let p;const x=d.rect;for(const n of ue){let e,s,c;if(a){const t=u.cy>d.cy?x.bottom:x.top,o=d.cx+n;if(o<=x.left+de||o>=x.right-de)continue;e={x:o,y:t},s={x:o,y:i.y},c={x:i.x,y:i.y}}else{const t=u.cx>d.cx?x.right:x.left,o=d.cy+n;if(o<=x.top+de||o>=x.bottom-de)continue;e={x:t,y:o},s={x:i.x,y:o},c={x:i.x,y:i.y}}const h=Q(e,s,de),g=Q(s,c,de);if(h&&g)continue;if(!h&&vt(e,s,o,[f],1))continue;if(!g&&vt(s,c,o,[l],1))continue;const m=!h&&Lt(e,s,t,r,{epsilon:de,skipDegenerateOther:!0}),y=!g&&Lt(s,c,t,r,{epsilon:de,skipDegenerateOther:!0});if(!m&&!y){p=h?[s,c]:g?[e,s]:[e,s,c];break}}p&&(r.points=p)}}function ge(t,e){const n=.001,{realNodeRects:o,labelNodeRects:r}=bt(e.values());for(const s of t){if(s.isLayoutOnly)continue;const i=s.points;if(!i||i.length<4)continue;const a=it(i,n);if(a.length<4)continue;const c=a.length-1,f=a[c],l=a[c-1],d=a[c-2],u=f.x-l.x,h=f.y-l.y,g=Math.hypot(u,h);if(g>=10||g<n)continue;const p=l.x-d.x,x=l.y-d.y;if(Math.hypot(p,x)<n)continue;const m=tt(l,f,n),b=et(l,f,n),M=tt(d,l,n),I=et(d,l,n);if(!(m&&I||b&&M))continue;const v=s.end,S=s.start,w=v?e.get(v):void 0;if(!w)continue;const L=w.x??0,C=w.y??0,k=gt(w);if(!k)continue;let T,$;if(I){const t=x<0;T={x:L,y:d.y},$={x:L,y:t?k.bottom:k.top}}else{const t=p>0;T={x:d.x,y:C},$={x:t?k.right:k.left,y:C}}if(vt(T,$,o,v?[v]:[],-2))continue;if(vt(T,$,r,[],-2))continue;if(S){const t=e.get(S),n=t?gt(t):void 0;if(n&&ft(T,n,2))continue}const O=y((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(O(a[t],a[t+1]));const N=y((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(O(s,i))&&Ct(e,o,s,i,n))return!0}}return!1},"segmentCrossesOtherEdge");if(N(T,$))continue;if(c-3>=0){const t=a[c-3];if(vt(t,T,o,[S,v].filter(t=>Boolean(t)),-2))continue;if(N(t,T))continue}const B=[...a.slice(0,c-2),T,$];s.points=B;const E=s.labelNodeId;if(E){const t=e.get(E);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<B.length-1;t++){const a=B[t],c=B[t+1],f=Math.hypot(c.x-a.x,c.y-a.y),l=U(a,c,n),d=Z(a,c,n);(l&&f>=e+2||d&&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)}}}}}y(he,"portSwapToLShape"),y(ge,"collapseShortTerminalStub");var pe=.001,xe=rt,me=y((t,e)=>Z(t,e,pe)||U(t,e,pe),"orthogonallyAligned");function ye(t,e){const n=y((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=y((t,o)=>{const r=it(t.points??[]);if(r.length<2)return;const s=o?t.start:t.end,i=s?e.get(s):void 0,a=i?gt(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],l=n(i,c);let d=c;return me(f,l)&&(d=f),Z(l,d,pe)?{edge:t,edgeId:String(t.id??""),nodeId:s,atStart:o,orientation:"V",coord:l.x,min:Math.min(l.y,d.y),max:Math.max(l.y,d.y),boundary:l,railEnd:d,rect:a}:U(l,d,pe)?{edge:t,edgeId:String(t.id??""),nodeId:s,atStart:o,orientation:"H",coord:l.y,min:Math.min(l.x,d.x),max:Math.max(l.x,d.x),boundary:l,railEnd:d,rect:a}:void 0},"terminalLaneFor"),r=y((t,e)=>Math.max(0,Math.min(t.max,e.max)-Math.max(t.min,e.min)),"projectedOverlapLength"),s=y((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)&&Z(t.boundary,e.boundary,1)}return(Math.abs(t.boundary.y-t.rect.top)<1||Math.abs(t.boundary.y-t.rect.bottom)<1)&&U(t.boundary,e.boundary,1)},"sameTerminalFace"),i=y((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=y((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=y((t,e)=>{const n=it(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(!y(()=>Math.abs(t.boundary.y-t.rect.top)<1||Math.abs(t.boundary.y-t.rect.bottom)<1?U(o,t.boundary,pe)&&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)&&(Z(o,t.boundary,pe)&&o.y>=t.rect.top+1&&o.y<=t.rect.bottom-1),"boundaryStaysOnSameFace")())return;if(t.atStart){const e=n.length>1&&Q(n[1],t.railEnd,pe),s=n.slice(e?2:1),i=s[0];if(i&&!me(i,r))return;return[o,r,...s]}const s=n.length>1&&Q(n[n.length-2],t.railEnd,pe),i=n.slice(0,s?-2:-1),a=i[i.length-1];return!a||me(a,r)?[...i,r,o]:void 0},"shiftedCandidate"),f=y(t=>{const n=t.edge,o=it(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,l=a.x??0,d=a.y??0,[u,h]=o;return U(u,h,pe)&&Math.abs(f-d)<1&&Math.abs(c-l)>1||Z(u,h,pe)&&Math.abs(c-l)<1&&Math.abs(f-d)>1},"laneIsStraightCollinearConnector"),l=[-7,7,-14,14,-21,21];for(let d=0;d<8;d++){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],d=e[r];if(s.edge===d.edge||!i(s,d)&&!a(s,d))continue;const u=!i(s,d),h=[s,d].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 l){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 be(t,e){const{realNodeRects:n,labelNodeRects:o}=bt(e.values()),r=y((e,r)=>{const s=e.start,i=e.end,a=xe(r);if(a.length!==r.length-1)return!1;const c=[s,i].filter(t=>Boolean(t));for(const t of a){if(vt(t.a,t.b,n,c,-2))return!1;if(vt(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 xe(it(t))){if(ot(e,n,.5)>=8)return!1;if(Ct(e.a,e.b,n.a,n.b,pe))return!1}}return!0},"candidateIsSafe"),s=y((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=tt(n,o)&&et(o,r)&&tt(r,s)&&et(s,i)&&Z(n,s,pe)&&Z(n,i,pe)&&Z(o,r,pe)&&(o.x-n.x)*(s.x-r.x)<0,c=et(n,o)&&tt(o,r)&&et(r,s)&&tt(s,i)&&U(n,s,pe)&&U(n,i,pe)&&U(o,r,pe)&&(o.y-n.y)*(s.y-r.y)<0;if(a||c)return it([...t.slice(0,e+1),i,...t.slice(e+5)]);if(e+5>=t.length)return;const f=t[e+5],l=et(n,o)&&tt(o,r)&&et(r,s)&&tt(s,i)&&et(i,f)&&Z(n,i,pe)&&Z(n,f,pe)&&Z(r,s,pe)&&(r.x-o.x)*(i.x-s.x)<0,d=tt(n,o)&&et(o,r)&&tt(r,s)&&et(s,i)&&tt(i,f)&&U(n,i,pe)&&U(n,f,pe)&&U(r,s,pe)&&(r.y-o.y)*(i.y-s.y)<0;return l||d?it([...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=it(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 Me(t,e){const{realNodeRects:n,labelNodeRects:o}=bt(e.values()),r=t.filter(t=>!t.isLayoutOnly),s=y((t,e,n)=>it(t===e?n??[]:t.points??[]),"pointsFor"),i=y((t,e)=>{let n=0;for(let o=0;o<r.length;o++){const i=xe(s(r[o],t,e));for(let a=o+1;a<r.length;a++){const o=xe(s(r[a],t,e));for(const t of i)for(const e of o)Ct(t.a,t.b,e.a,e.b,pe)&&n++}}return n},"strictCrossingCount"),a=y(t=>{const e=xe(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=y((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 nt(e.a.x,e.b.x,n.left,n.right)>=8&&e.a.y>=n.top-2&&e.a.y<=n.bottom+2}return nt(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=y((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=Rt(it(o));return xe(r).length===r.length-1?r:void 0},"candidateByMovingRail"),l=y((t,e,a)=>{const c=[t.start,t.end].filter(t=>Boolean(t)),f=xe(e);if(f.length!==e.length-1)return!1;for(const r of f){if(vt(r.a,r.b,n,c,-2))return!1;if(vt(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 xe(s(n)))if(ot(t,e,.5)>=8)return!1;return i(t,e)<=a},"candidateIsSafe");for(let d=0;d<8;d++){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 d=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 d){const i=f(o,r.segment,s);if(i&&l(n,i,t)){n.points=i,e=!0;break}}if(e)break}if(!e)return}}function Ie(t,e){const n=y(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=y(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=y((t,e)=>{if(!t.horizontal)return!1;const n=t.a.y;return!(n<=e.top+pe||n>=e.bottom-pe)&&nt(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=it(a.points??[]);for(const e of xe(t))for(const t of s)r(e,t.rect)&&(i=Math.max(i,t.rect.bottom-e.a.y+4))}if(!(i<=pe))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 ve(t,e){const n=y(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=y(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=y((t,e)=>{if(!t.vertical)return!1;const n=t.a.x;return!(n<=e.left+pe||n>=e.right-pe)&&nt(t.a.y,t.b.y,e.top,e.bottom)>=8},"verticalSegmentIntersectsTitle"),s=y((t,e)=>{if(!t.horizontal)return!1;const n=t.a.y;return!(n<=e.top+pe||n>=e.bottom-pe)&&nt(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=it(c.points??[]);for(const e of xe(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<=pe))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 Se(t,e){const{realNodeRects:n}=bt(e.values()),o=t.filter(t=>!t.isLayoutOnly),r=y((t,e=new Map)=>it(e.get(t)??t.points??[]),"replacementPointsFor"),s=y((t=new Map)=>{let e=0;for(let n=0;n<o.length;n++){const s=xe(r(o[n],t));for(let i=n+1;i<o.length;i++){const n=xe(r(o[i],t));for(const t of s)for(const o of n)Ct(t.a,t.b,o.a,o.b,pe)&&e++}}return e},"crossingCount"),i=y((t=new Map)=>o.reduce((e,n)=>e+st(r(n,t)),0),"totalBends"),a=y(t=>{const e=r(t);if(e.length<4)return;const n=e[e.length-2],o=e[e.length-1];return tt(n,o,pe)||et(n,o,pe)?{tailStart:n,terminal:o}:void 0},"terminalTailFor"),c=y((t,e)=>{const n=r(t);if(n.length<3)return;const o=n[0],s=n[1];let i;if(tt(o,s,pe))i={x:s.x,y:e.tailStart.y};else{if(!et(o,s,pe))return;i={x:e.tailStart.x,y:s.y}}const a=Rt(it([o,s,i,e.tailStart,e.terminal]));return xe(a).length===a.length-1?a:void 0},"candidateWithDestinationTail"),f=y((t,e)=>{const o=[t.start,t.end].filter(t=>Boolean(t));for(const r of xe(e))if(vt(r.a,r.b,n,o,-2))return!0;return!1},"pathHasNodeHit"),l=y((t,e,n)=>{for(const s of o)if(s!==t)for(const t of xe(e))for(const e of xe(r(s,n)))if(ot(t,e,.5)>=8)return!0;return!1},"pathHasSharedTrack"),d=y((t,e,n)=>!f(t,e)&&!l(t,e,n),"candidateIsSafe"),u=y(()=>{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 h=0;h<4;h++){const t=s();if(0===t)return;let e,n=t,o=i();for(const r of u().values())for(let f=0;f<r.length;f++)for(let l=f+1;l<r.length;l++){const u=r[f],h=r[l],g=a(u),p=a(h);if(!g||!p)continue;const x=c(u,p),m=c(h,g);if(!x||!m)continue;const y=new Map([[u,x],[h,m]]);if(!d(u,x,y)||!d(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 we(t,e){const{realNodeRects:n,labelNodeRects:o}=bt(e.values()),r=t.filter(t=>!t.isLayoutOnly),s=y((t,e=new Map)=>it(e.get(t)??t.points??[]),"replacementPointsFor"),i=y((t=new Map)=>{let e=0;for(let n=0;n<r.length;n++){const o=xe(s(r[n],t));for(let i=n+1;i<r.length;i++){const n=xe(s(r[i],t));for(const t of o)for(const o of n)Ct(t.a,t.b,o.a,o.b,pe)&&e++}}return e},"strictCrossingCount"),a=y((t=new Map)=>r.reduce((e,n)=>e+st(s(n,t)),0),"totalBends"),c=y(t=>{const n=t.start,o=t.end,r=n?e.get(n):void 0,s=o?e.get(o):void 0,i=r?gt(r):void 0,a=s?gt(s):void 0;return i&&a?{src:i,dst:a}:void 0},"endpointRectsFor"),f=y((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-pe?"left":r>i+pe?"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-pe?"top":r>i+pe?"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"),l=y(()=>{const t=[];for(const e of r){const n=s(e);for(const o of xe(n)){const r=f(e,n,o);r&&t.push(r)}}return t},"collectExternalRails"),d=y((t,e)=>t.edge!==e.edge&&t.axis===e.axis&&t.side===e.side&&nt(t.min,t.max,e.min,e.max)>=8,"railsInteract"),u=y(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)&&d(e,o)&&(n.add(o),r.push(o))}s.length>1&&e.push(s)}return e},"connectedComponents"),h=y(t=>{const e=[];for(const n of t)e.some(t=>Math.abs(t-n.coord)<pe)||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"),g=y(t=>{const e=t.map(t=>t.coord),n=h(t),o=[];if(t.length<=6){const r=new Array(n.length).fill(!1),s=[],i=y(()=>{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])>=pe)&&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"),p=y((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=Rt(it(s));if(xe(t).length!==t.length-1)return;o.set(r,t)}return o},"replacementsForAssignment"),x=y(t=>{for(const[e,r]of t){const t=[e.start,e.end].filter(t=>Boolean(t));for(const e of xe(r)){if(vt(e.a,e.b,n,t,-2))return!1;if(vt(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=xe(s(n,t));for(let a=e+1;a<r.length;a++){const e=r[a];if(!o&&!t.has(e))continue;const n=xe(s(e,t));for(const t of i)for(const e of n)if(ot(t,e,.5)>=8)return!1}}return!0},"candidateIsSafe");for(let m=0;m<4;m++){const t=i();if(0===t)return;let e,n=t,o=a(),r=Number.POSITIVE_INFINITY;for(const s of u(l()))for(const c of g(s)){const f=p(s,c);if(!f||!x(f))continue;const l=i(f);if(l>=t)continue;const d=a(f),u=s.reduce((t,e,n)=>t+Math.abs(c[n]-e.coord),0);l>n||l===n&&(d>o||d===o&&u>=r)||(e=f,n=l,o=d,r=u)}if(!e)return;for(const[s,i]of e)s.points=i}}function Le(t,e){const{realNodeRects:n,labelNodeRects:o}=bt(e.values()),r=t.filter(t=>!t.isLayoutOnly),s=y((t,e,n)=>it(t===e?n??[]:t.points??[]),"pointsFor"),i=y(t=>xe(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=y((t,e)=>{let n=0;for(let o=0;o<r.length;o++){const i=xe(s(r[o],t,e));for(let a=o+1;a<r.length;a++){const o=xe(s(r[a],t,e));for(const t of i)for(const e of o)Ct(t.a,t.b,e.a,e.b,pe)&&n++}}return n},"strictCrossingCount"),c=y((t,e)=>{if(t.horizontal){const n=t.a.y;return(Math.abs(n-e.top)<1||Math.abs(n-e.bottom)<1)&&nt(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)&&nt(t.a.y,t.b.y,e.top,e.bottom)>=8}return!1},"segmentRunsAlongRectBorder"),f=y(t=>{const n=[t.start,t.end].filter(t=>Boolean(t)),o=[];for(const r of n){const t=e.get(r),n=t?gt(t):void 0;n&&o.push(n)}return o},"endpointRectsFor"),l=y((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=tt(n,o,pe)&&et(o,r,pe)&&tt(r,s,pe),a=et(n,o,pe)&&tt(o,r,pe)&&et(r,s,pe);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=Z(n,s,pe)||U(n,s,pe)?[]:[{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)]),l=new Set;return f.map(t=>Rt(it(t))).filter(t=>{if(xe(t).length!==t.length-1)return!1;if(!t.some(t=>Q(t,s,pe)))return!1;const e=t.map(t=>`${t.x.toFixed(3)},${t.y.toFixed(3)}`).join("|");return!l.has(e)&&(l.add(e),!0)})},"shortcutCandidatesAt"),d=y((t,e,i)=>{const l=[t.start,t.end].filter(t=>Boolean(t)),d=f(t);for(const r of xe(e)){if(vt(r.a,r.b,n,l,-2))return!1;if(vt(r.a,r.b,o,[],-2))return!1;if(d.some(t=>c(r,t)))return!1}for(const n of r)if(n!==t)for(const t of xe(e))for(const e of xe(s(n)))if(ot(t,e,.5)>=8)return!1;return a(t,e)<=i},"candidateIsSafe");for(let u=0;u<8;u++){const t=a();let e,n,o=t,c=Number.POSITIVE_INFINITY,f=Number.POSITIVE_INFINITY;for(const u of r){const r=s(u),h=st(r,pe),g=i(r);for(let s=0;s<=r.length-4;s++)for(const p of l(r,s)){const r=st(p,pe),s=i(p);if(!(r<h||r===h&&s<g-pe)||!d(u,p,t))continue;const l=a(u,p);l>o||l===o&&(r>c||r===c&&s>=f)||(e=u,n=p,o=l,c=r,f=s)}}if(!e||!n)return;e.points=n}}function Ce(t,e){const n=20,o=[];for(const y of e.values()){if(y.isGroup||y.isEdgeLabel)continue;const t=y.x??0,e=y.y??0,n=gt(y);n&&o.push({id:String(y.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])),l=y(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"),d=y((t,e=new Map)=>it(e.get(t)??t.points??[]),"replacementPointsFor"),u=y((t,e)=>{let n=0;for(const o of t)for(const t of e)Ct(o.a,o.b,t.a,t.b,pe)&&n++;return n},"crossingCountBetweenSegments"),h=y((t,e)=>u(xe(t),xe(e)),"crossingCountBetweenPaths"),g=y((t=new Map)=>{let e=0;const n=[],o=new Set,r=[],s=y(t=>{o.has(t)||(o.add(t),r.push(t))},"addEdge");for(let i=0;i<c.length;i++){const o=c[i],r=d(o,t);for(let a=i+1;a<c.length;a++){const i=c[a],f=h(r,d(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"),p=y((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=d(t,e);for(let a=s+1;a<c.length;a++){const t=c[a];(o||n.has(t))&&(r+=h(i,d(t,e)))}}return t.count-o+r},"crossingCountWithReplacements"),x=y(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"),m=y(t=>[t.start,t.end].filter(t=>Boolean(t)),"endpointIdsFor"),b=y(t=>{const e=[];for(const n of x(t)){const t=new Set(n),o=new Set(n.flatMap(t=>m(t))),r=[...n];for(const e of c)t.has(e)||m(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=y((t,e,n)=>p(t,new Map([[e,n]])),"crossingCountWithSingleReplacement"),I=y(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"),v=y(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"),S=y((t=new Map)=>c.reduce((e,n)=>e+st(d(n,t)),0),"totalBends"),w=y((t=new Map)=>c.reduce((e,n)=>e+v(d(n,t)),0),"totalLength"),L=y((t,e,n=new Map)=>{const o=xe(e);for(const r of c)if(r!==t)for(const t of o)for(const e of xe(d(r,n)))if(ot(t,e,.5)>=8)return!0;return!1},"pathHasSegmentConflict"),C=y((t,e)=>{const n=[t.start,t.end].filter(t=>Boolean(t));for(const o of xe(e))if(vt(o.a,o.b,s,n,-2))return!0;return!1},"pathHitsNode"),k=y((t,e)=>{const n=Rt(it(e));xe(n).length===n.length-1&&t.push(n)},"pushOrthogonalCandidate"),T=y(t=>"left"===t||"right"===t,"sideIsHorizontal"),$=y((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"),O=y((t,e,o,r)=>{const s="left"===o||"top"===o?-1:1,i=[$(e,o,r),a[o]];for(const a of i)for(let i=0;i<=2;i++)k(t,mt(e,o,r,a+s*n*i))},"addSameSideCandidates"),R=y((t,e,n,o,r)=>{for(const s of l(n))for(const n of l(r))k(t,[e,{x:s,y:e.y},{x:s,y:n},{x:o.x,y:n},o])},"addHorizontalToVerticalCandidates"),N=y((t,e,n,o,r)=>{for(const s of l(n))for(const n of l(r))k(t,[e,{x:e.x,y:s},{x:n,y:s},{x:n,y:o.y},o])},"addVerticalToHorizontalCandidates"),B=y((t,e,n,o,r)=>{const s=[...l("top"),...l("bottom")];for(const i of l(n))for(const n of l(r))for(const r of s)k(t,[e,{x:i,y:e.y},{x:i,y:r},{x:n,y:r},{x:n,y:o.y},o])},"addHorizontalPairCandidates"),E=y((t,e,n,o,r)=>{const s=[...l("left"),...l("right")];for(const i of l(n))for(const n of l(r))for(const r of s)k(t,[e,{x:e.x,y:i},{x:r,y:i},{x:r,y:n},{x:o.x,y:n},o])},"addVerticalPairCandidates"),F=y(t=>{const e=new Set;return t.map(t=>it(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"),Y=y((t,e,o,r)=>{const s=[],i=xt(t,e,o,r,n,pe);i&&k(s,i),e===r&&O(s,t,e,o);const a=T(e),c=T(r);return a&&!c?R(s,t,e,o,r):!a&&c?N(s,t,e,o,r):a?B(s,t,e,o,r):E(s,t,e,o,r),F(s)},"buildCandidatesForSides"),X=y((t,e,n,o)=>{const r=[...l("left"),...l("right")],s=[...l("top"),...l("bottom")];for(const a of i){const i=pt(o,a),c="top"===a||"bottom"===a?l(a):s;for(const o of r){k(t,[e,n,{x:o,y:n.y},{x:o,y:i.y},i]);for(const r of c)k(t,[e,n,{x:o,y:n.y},{x:o,y:r},{x:i.x,y:r},i])}}},"addVerticalDepartureOuterTrackCandidates"),P=y((t,e,n,o)=>{const r=[...l("left"),...l("right")],s=[...l("top"),...l("bottom")];for(const a of i){const i=pt(o,a),c="left"===a||"right"===a?l(a):r;for(const o of s){k(t,[e,n,{x:n.x,y:o},{x:i.x,y:o},i]);for(const r of c)k(t,[e,n,{x:n.x,y:o},{x:r,y:o},{x:r,y:i.y},i])}}},"addHorizontalDepartureOuterTrackCandidates"),z=y(t=>{const e=t.start,n=t.end,o=n?r.get(n):void 0;if(!e||!o)return[];const s=it(t.points??[]);if(s.length<4)return[];const i=s[0],a=s[1],c=[];return et(i,a,pe)?X(c,i,a,o):tt(i,a,pe)&&P(c,i,a,o),c},"terminalPreservingOuterTrackCandidates"),A=y(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=pt(o,r);for(const e of i)a.push(...Y(t,r,pt(s,e),e))}return a.push(...z(t)),a},"candidatePathsFor"),G=y(()=>new Map(c.map(t=>[t,xe(d(t))])),"currentSegmentsByEdge"),D=y((t,e,n)=>{const o=new Set;for(const r of c){if(r===t)continue;const s=n.get(r)??xe(d(r));e.some(t=>s.some(e=>ot(t,e,.5)>=8))&&o.add(r)}return o},"sharedTrackConflictsFor"),H=y((t,e,n,o)=>{const r=new Set;return A(t).map(t=>Rt(it(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=xe(r);let i=0;for(const e of c)e!==t&&(i+=u(s,n.get(e)??xe(d(e))));return{candidate:r,candidateSegments:s,crossings:e.count-(o.get(t)??0)+i,bends:st(r,pe),totalBends:st(r),length:v(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:D(t,e.candidateSegments,n),totalBends:e.totalBends,length:e.length}))},"pairCandidatesFor"),j=y((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=u(n.segments,r.segments);for(const f of c){if(f===e||f===o)continue;const t=s.get(f)??xe(d(f));a+=u(n.segments,t)+u(r.segments,t)}return t.count-i+a},"pairCrossingCount"),_=y((t,e)=>{for(const n of t.sharedTrackConflicts)if(n!==e)return!1;return!0},"conflictsOnlyWith"),V=y((t,e)=>t.segments.some(t=>e.segments.some(e=>ot(t,e,.5)>=8)),"candidatesShareTrack"),W=y((t,e,n,o)=>_(e,n.edge)&&_(o,t.edge)&&!V(e,o),"pairCandidatesAreCompatible"),J=y((t,e,n,o,r)=>{const s=j(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"),q=y((t,e)=>t.crossings<e.crossings||t.crossings===e.crossings&&(t.bends<e.bends||t.bends===e.bends&&t.length<e.length),"pairScoreIsBetter"),K=y((t,e,n,o)=>{let r=o;for(const s of e.candidates)for(const o of n.candidates){if(!W(e,s,n,o))continue;const i=J(t,e,s,n,o);i&&q(i,r)&&(r=i)}return r},"bestScoreForOptionPair"),Q=y(t=>{const e=S(),n=w(),o=G(),r=I(t),s=new Map(c.map(t=>[t,st(d(t))])),i=new Map(c.map(t=>[t,v(d(t))])),a=new Map,f=b(t);for(const c of f)for(const e of c){if(a.has(e))continue;const n=H(e,t,o,r);n.length>0&&a.set(e,{edge:e,candidates:n})}let l={replacements:new Map,crossings:t.count,bends:e,length:n};const u={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))&&(l=K(u,o,t,l))}}}return l.replacements.size>0?l.replacements:void 0},"bestPairedReplacement");for(let y=0;y<4;y++){const t=g(),e=t.count;if(0===e)return;let n,o,r=e,s=Number.POSITIVE_INFINITY;for(const a of t.edges){const i=st(d(a),pe);for(const c of A(a)){const f=C(a,c),l=!f&&L(a,c),d=M(t,a,c),u=st(c,pe);if(f||l)continue;(d<e||d===e&&u<i)&&(d>r||d===r&&u>=s||(n=a,o=c,r=d,s=u))}}if(n&&o){n.points=o;continue}const i=Q(t);if(!i)return;for(const[a,c]of i)a.points=c}}y(ye,"separateSharedRenderedTerminalLanes"),y(be,"collapseRedundantRectangularDoglegs"),y(Me,"liftObstacleHuggingSameSideRails"),y(Ie,"liftTopLaneTitleBandsAboveRails"),y(ve,"shiftLeftLaneTitleBandsLeftOfRails"),y(Se,"swapDestinationTerminalTailsToReduceCrossings"),y(we,"reassignCrossingExternalRailChannels"),y(Le,"shortcutRedundantOrthogonalJogs"),y(Ce,"resolveRenderedOrthogonalCrossings");var ke=.001;function Te(t,e){const{nodeInfoById:n,realNodeRects:o}=yt(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=y((t,e,n,o)=>{const r=[],i=xt(t,e,n,o,20,ke);return i&&r.push(i),e===o&&r.push(mt(t,e,n,s[e])),r},"buildOrthogonalPathCandidates"),a=y((t,e)=>{for(let n=0;n<t.length-1;n++){if(vt(t[n],t[n+1],o,e,1))return!0}return!1},"pathHitsNode"),c=y((e,n,o=!1)=>{let r=0;const s=rt(e,ke),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 rt(f,ke))(St(n.a,n.b,t.a,t.b,ke,ke)||ot(n,t,ke)>=8)&&r++}return r},"pathConflictCount"),f=y((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"),l=new Map,d=y((t,e,n)=>{const o=l.get(t)??[];o.push({side:e,edgeId:n}),l.set(t,o)},"addFaceClaim");for(const h of t){if(h.isLayoutOnly)continue;const t=h.points??[];if(t.length<1)continue;const e=h.id??"",o=h.start,r=h.end;if(o){const r=n.get(o);r&&d(o,f(t[0],r),e)}if(r){const o=n.get(r);o&&d(r,f(t[t.length-1],o),e)}}const u=y((t,e,n)=>{var o;return(null==(o=l.get(t))?void 0:o.some(t=>t.edgeId!==n&&t.side===e))??!1},"faceIsClaimed");for(const h of t){if(h.isLayoutOnly)continue;const t=h.points;if(!t||t.length<2)continue;const e=st(t,ke);if(e<4)continue;const o=h.start,s=h.end;if(!o||!s)continue;const g=n.get(o),p=n.get(s);if(!g||!p)continue;const x=h.id??"",m=c(t,h,!0),y=c(t,h);let b,M=m,I=e;for(const n of r){if(u(o,n,x))continue;const t=pt(g,n);for(const e of r){if(u(s,e,x))continue;const r=pt(p,e);for(const f of i(t,n,r,e)){if(a(f,[o,s]))continue;const t=st(f,ke);if(m>0){const e=c(f,h,!0);if(e>M||e===M&&t>=I)continue;M=e,I=t,b=f;continue}c(f,h)>y||t<I&&(I=t,b=f)}}}if(b){h.points=b;const t=l.get(o);t&&l.set(o,t.filter(t=>t.edgeId!==x));const e=l.get(s);e&&l.set(s,e.filter(t=>t.edgeId!==x)),d(o,f(b[0],g),x),d(s,f(b[b.length-1],p),x)}}}y(Te,"simplifyDetouredEdges");var $e=.001;function Oe(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)<$e)){if(Math.abs(a)<=$e){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)<=$e){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 Re(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 Ne(t,e){const n=it(e);return[Oe(n,!0),Oe(n,!1)].some(e=>e&&dt(t,Re(e)))}function Be(t,e){const n=[];for(const d of t){if(d.isLayoutOnly)continue;const t=d.points;if(t&&!(t.length<2))for(let e=0;e<t.length-1;e++)n.push({edgeId:d.id,p1:t[e],p2:t[e+1]})}const o=[],r=[];for(const d of e.values()){const t=d.isGroup,e=d.parentId;if(t&&!e){const t=gt(d);t&&r.push({id:d.id,rect:t});continue}if(t)continue;if(d.isEdgeLabel)continue;const n=gt(d);n&&o.push({nodeId:d.id,rect:n})}const s=y((t,e)=>{const n=ut(e,3);for(const{nodeId:r,rect:s}of o)if(r!==t&&dt(n,s))return!0;return!1},"labelOverlapsForeignNode"),i=y((t,e)=>{const o=ut(e,3);for(const r of n)if(r.edgeId!==t&&ct(r.p1,r.p2,o))return!0;return!1},"labelOverlapsForeignEdge"),a=y((t,e,n)=>s(t,n)||i(e,n),"labelOverlapsAnything"),c=[],f=y(t=>{for(const{id:e,rect:n}of r)if(lt(n,t))return e},"findContainingLane"),l=y((t,e)=>c.some(n=>n.labelId!==t&&dt(e,n.rect)),"overlapsPlacedLabel");for(const d of t){if(d.isLayoutOnly)continue;const t=d.labelNodeId;if(!t)continue;const n=e.get(t);if(!n)continue;const o=d.points;if(!o||o.length<2)continue;const u=n.width??0,h=n.height??0;if(u<=0||h<=0)continue;const g=[];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<$e&&s<$e||(r>=$e&&s>=$e||g.push({idx:e,length:r+s,orientation:r>=$e?"horizontal":"vertical",midX:(t.x+n.x)/2,midY:(t.y+n.y)/2}))}if(0===g.length)continue;const p=g.length>=3?g.filter(t=>t.idx>0&&t.idx<g.length-1):g,x=p.length>0?p:g,m=u>=h?"horizontal":"vertical",b=y(t=>[...t].sort((t,e)=>{const n=t.orientation===m;if(n!==(e.orientation===m))return n?-1:1;const o=t.length>=("horizontal"===t.orientation?u:h)+2;return o!==e.length>=("horizontal"===e.orientation?u:h)+2?o?-1:1:e.length-t.length}),"rankSegments"),M=g[0],I=g[g.length-1],v=[.5,.25,.75,.05,.95,.15,.85,.1,.9],S=y((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"),w=y((t,e,n)=>Math.min(n,Math.max(e,t)),"clamp"),L=y((t,e)=>t.midX>=e.left-$e&&t.midX<=e.right+$e&&t.midY>=e.top-$e&&t.midY<=e.bottom+$e,"pointInsideRectInclusive"),C=y(t=>{const e=ht(t.midX,t.midY,u,h),n=f(e);if(n)return{laneId:n,anchor:t,rect:e};const o=r.find(({rect:e})=>L(t,e));if(!o)return;const s=o.rect.left+u/2+1,i=o.rect.right-u/2-1,a=o.rect.top+h/2+1,c=o.rect.bottom-h/2-1;if(s>i||a>c)return;const l={midX:w(t.midX,s,i),midY:w(t.midY,a,c)},d=ht(l.midX,l.midY,u,h);return L(t,d)?{laneId:o.id,anchor:l,rect:d}:void 0},"placementForAnchor"),k=y((t,e,n)=>"horizontal"===t.orientation?Math.abs(e.midX-n.x):Math.abs(e.midY-n.y),"distanceAlongSegment"),T=y((t,e)=>{const n=("horizontal"===t.orientation?u/2:h/2)+12;if(t===M){const r=o[t.idx];if(k(t,e,r)+$e<n)return!1}if(t===I){const r=o[t.idx+1];if(k(t,e,r)+$e<n)return!1}return!0},"labelClearsTerminalEndpoints"),$=y(e=>{const n=b(e);for(const r of n)for(const e of v){const n=S(r,e);if(!T(r,n))continue;const s=C(n);if(s&&(!Ne(s.rect,o)&&!l(t,s.rect)&&!a(t,d.id,s.rect)))return{laneId:s.laneId,anchor:s.anchor}}},"tryPool"),O=y((e,n,r=!1)=>{const a=b(e);for(const c of a){const e={midX:c.midX,midY:c.midY};if(n&&!T(c,e))continue;const a=C(e);if(a&&!Ne(a.rect,o)&&!l(t,a.rect)&&!s(t,a.rect)&&(r||!i(d.id,a.rect)))return{laneId:a.laneId,anchor:a.anchor}}},"findLaneContainingFallback"),R=$(x)??(x.length<g.length?$(g):void 0)??O(g,!0)??O(g,!1)??O(g,!1,!0);if(R){n.x=R.anchor.midX,n.y=R.anchor.midY,n.parentId=R.laneId;const e=ht(R.anchor.midX,R.anchor.midY,u,h),o=c.findIndex(e=>e.labelId===t);o>=0?c[o]={labelId:t,rect:e}:c.push({labelId:t,rect:e})}}}y(Oe,"markerClearanceRectFor"),y(Re,"normalizeRect"),y(Ne,"labelOverlapsOwnMarker"),y(Be,"anchorLabelsToPolyline");var Ee=1e-6;function Fe(t,e){return t<e?`${t}::${e}`:`${e}::${t}`}function Ye(t,e){const{nodeInfoById:n,realNodeRects:o}=yt(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=y((e,n,o,s)=>{const i=Fe(n,o);let a=0;const c=y(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&&(Fe(t,n)===i&&c(r.labelNodeId))}return a>0?a+3:0},"labelClearanceFor");for(const i of t){if(i.isLayoutOnly)continue;if(!at(i.points,Ee))continue;const e=It(i,n,Ee);if(!e)continue;const{srcId:r,dstId:a,srcInfo:c,dstInfo:f,collinearX:l,collinearY:d}=e;if(l===d)continue;let u,h;if(l){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(vt(u,h,o,[r,a],1))continue;const g=s(i,r,a,l?"x":"y"),p=g>4?g:4,x=[0,p,-p];for(const n of x){const e={...u},s={...h};if(l){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(!vt(e,s,o,[r,a],1)&&!Lt(e,s,t,i,{epsilon:Ee})){i.points=[e,s];break}}}}function Xe(t,e){const n=.001,{realNodeRects:o,labelNodeRects:r}=bt(e.values()),s=y((t,e)=>rt(e,n).map(n=>({...n,edge:t,interior:n.index>=1&&n.index<=e.length-3})),"segmentsFor"),i=y(()=>{const e=[];for(const n of t){if(n.isLayoutOnly)continue;const t=n.points;!t||t.length<2||e.push(...s(n,it(t)))}return e},"allSegments"),a=y((t,e)=>t.horizontal&&e.horizontal?nt(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)&&(nt(t.a.y,t.b.y,e.a.y,e.b.y)>=8&&Math.abs(t.a.x-e.a.x)<7),"hasCrowdedParallelTrack"),c=y((e,i)=>{const c=e.start,f=e.end,l=s(e,i);if(l.length!==i.length-1)return!1;const d=[c,f].filter(t=>Boolean(t)),u=e.labelNodeId?[e.labelNodeId]:[];for(const t of l){if(vt(t.a,t.b,o,d,-2))return!1;if(vt(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 l)for(const r of s(o,it(t))){if(a(e,r))return!1;if(Ct(e.a,e.b,r.a,r.b,n))return!1}}return!0},"candidateIsSafe"),f=y((t,e)=>{const n=it(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"),l=y((t,e)=>({x:t.x??(e.left+e.right)/2,y:t.y??(e.top+e.bottom)/2}),"nodeCenter"),d=y(t=>{const n=t.edge,o=it(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?gt(r):void 0,a=s?gt(s):void 0,c=o.slice(t.index+2);return r&&s&&i&&a&&0!==c.length?{sourceCenter:l(r,i),targetCenter:l(s,a),sourceRect:i,tail:c}:void 0},"sourceDetourContextFor"),u=y((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 l=t.a.x+e;return it([{x:o.x,y:c},{x:o.x,y:f},{x:l,y:f},{x:l,y:t.b.y},...i],n)},"verticalSourceDetour"),h=y((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 l=t.a.y+e;return it([{x:c,y:o.y},{x:f,y:o.y},{x:f,y:l},{x:t.b.x,y:l},...i],n)},"horizontalSourceDetour"),g=y((t,e)=>{const n=d(t);if(n)return t.vertical?u(t,e,n.sourceCenter,n.targetCenter,n.sourceRect,n.tail):t.horizontal?h(t,e,n.sourceCenter,n.targetCenter,n.sourceRect,n.tail):void 0},"sourceDetourCandidate"),p=[-7,7,-14,14,-21,21];for(let x=0;x<12;x++){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 p){const o=f(t,n);if(o&&c(t.edge,o)){t.edge.points=o,e=!0;break}const r=g(t,n);if(r&&c(t.edge,r)){t.edge.points=r,e=!0;break}}if(e)break}}if(!e)return}}function Pe(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,l=n.y-t.y,d=(f*a-l*i)/c,u=(f*s-l*r)/c,h=.01;return d>h&&d<.99&&u>h&&u<.99}function ze(t){const e=t.nodes??[],n=t.edges??[],o=[];if(!n.length||!e.length)return o;const r=Mt(e),s=[];for(const i of n){if(i.isLayoutOnly)continue;const t=i.points;if(!t||t.length<2)continue;const e=i.start,n=i.end,a=i.labelNodeId,c=i.id??`${e}->${n}`;for(const s of r)if(s.nodeId!==e&&s.nodeId!==n&&(!a||s.nodeId!==a))for(let e=0;e<t.length-1;e++)if(ct(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 a=new Set;for(let i=0;i<s.length;i++)for(let t=i+1;t<s.length;t++){const e=s[i],n=s[t];if(e.edgeId!==n.edgeId&&(e.start!==n.start&&e.start!==n.end&&e.end!==n.start&&e.end!==n.end&&Pe(e.p1,e.p2,n.p1,n.p2))){const t=e.edgeId<n.edgeId?`${e.edgeId}|${n.edgeId}`:`${n.edgeId}|${e.edgeId}`;a.has(t)||(a.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;i.warn(`[SWIMLANE_VALIDATE] ${o.length} issue(s) detected: ${t} edge-node overlap(s), ${e} edge crossing(s)`);for(const n of o)i.warn(`[SWIMLANE_VALIDATE] ${n.type}: ${n.detail}`)}return o}function Ae(t,e){const n=t.nodes??[],o=t.edges??[],r=n.filter(t=>!t.isGroup);if(("LR"===e||"RL"===e)&&r.length>0&&!le(t,e))return;if("BT"===e&&r.length>0&&!fe(t))return;for(const a of o){if(a.isLayoutOnly)continue;const t=a.points;!t||t.length<2||(a.points=Rt(Ot(t)))}Te(o,n),Ye(o,n),he(o,n);const s=new Map;for(const a of n)s.set(String(a.id),a);Be(o,s),Yt(o,s),ge(o,s),Xe(o,s),ye(o,s),be(o,s),Me(o,s),Se(o,s);const i=y(()=>{Ce(o,s),we(o,s),Le(o,s),Be(o,s),ee(o,s),Me(o,s),Be(o,s),ee(o,s)},"finalizeRenderedEdges");i(),Xe(o,s),i(),Ie(o,s),ve(o,s),Ie(o,s),ve(o,s)}function Ge(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 De(t,e){return t.edges.filter(t=>t.dst===e)}function He(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 je(t){const e=He(t);for(const n of e.values())n.sort((t,e)=>t.localeCompare(e));return e}function _e(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 Ve(t){return[...t.entries()].filter(([,t])=>0===t).map(([t])=>t).sort((t,e)=>t.localeCompare(e))}function We(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 Je(t,e,n,o){var r,s;let i=0;for(const c of t.nodes)(null==o?void 0:o.skipGroups)&&(null==(r=t.nodeById.get(c))?void 0:r.isGroup)||(i=Math.max(i,n[c]??0));const a=Array.from({length:i+1},()=>[]);for(const c of e)(null==o?void 0:o.skipGroups)&&(null==(s=t.nodeById.get(c))?void 0:s.isGroup)||a[Math.max(0,n[c]??0)].push(c);return a}function qe(t){const e=_e(t),n=Ve(e),o=[],r=je(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 Ke(t){const e=new Map;let n=0;for(const o of t)e.set(o,n),n++;return e}function Qe(t){const e=new Array(t.length),n=y((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 Ze(t){const e=Ge(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=y(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 Ue(t){const e=new Map,n=y(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 tn(t){const e=Ue(t);return t=>e.get(t)??null}function en(t){const e=[];for(const n of t.layout.nodes??[])n.isGroup&&!n.parentId&&e.push(n.id);return[...new Set(e)].reverse()}function nn(t,e){const n=en(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}y(Fe,"pairKey"),y(Ye,"straightenCollinearSiblingDetours"),y(Xe,"nudgeSharedInteriorSubpaths"),y(Pe,"segmentsIntersect"),y(ze,"validateSwimlanesLayout"),y(Ae,"postProcessSwimlaneLayout"),y(Ge,"normalizeGraph"),y(De,"incoming"),y(He,"buildSuccessorMap"),y(je,"buildSortedSuccessorMap"),y(_e,"buildInDegreeMap"),y(Ve,"sortedZeroInDegreeNodes"),y(We,"buildPredecessorSuccessorMaps"),y(Je,"buildLayersFromRanks"),y(qe,"topoSortIfAcyclic"),y(Ke,"buildLayerIndex"),y(Qe,"countInversions"),y(Ze,"removeCycles_DFS"),y(Ue,"buildTopLaneMap"),y(tn,"createTopLaneResolver"),y(en,"buildTopLaneOrder"),y(nn,"resolveTopLaneOrder");var on=8,rn=4,sn=!0,an=100,cn=40;function fn(t,e){const n=Ge(t),o=(null==e?void 0:e.laneOf)??(()=>null),r=null==e?void 0:e.rankHint,{preds:s}=We(n);for(const y of s.values())y.sort((t,e)=>t.localeCompare(e));const i=qe(n)??[...n.nodes].sort((t,e)=>t.localeCompare(e)),a=new Map;for(const[y,v]of i.entries())a.set(v,y);const c=new Map,f=new Map;for(const y of n.nodes)f.set(y,[]);for(const y of i){const t=(s.get(y)??[]).filter(t=>c.has(t));if(t.length>0){const e=ln(y,t,{laneOf:o,rankHint:r,topoIndex:a});c.set(y,e),f.get(e).push(y)}else c.has(y)||c.set(y,null)}for(const y of n.nodes)c.has(y)||c.set(y,null);const l=new Set;for(const y of n.nodes)null===(c.get(y)??null)&&l.add(y);const d=[...l].sort((t,e)=>{const n=a.get(t)??0,o=a.get(e)??0;return n===o?t.localeCompare(e):n-o}),u=dn(n),h=new Map;for(const[y,v]of u.entries())h.set(y,[...v].sort((t,e)=>t.localeCompare(e)));const g=un(h),p=hn(h),x=new Map;for(const y of n.nodes)x.set(y,[]);for(const y of p)for(const t of y.nodes){const e=x.get(t);e?e.push(y.id):x.set(t,[y.id])}const m=[],b=[],M=new Set,I=y(t=>{if(!M.has(t)){M.add(t),m.push(t);for(const e of f.get(t)??[])I(e);b.push(t)}},"walk");for(const y of d)I(y);for(const y of i)I(y);return{parent:c,children:f,roots:d,componentOf:g,blocks:p,nodeBlocks:x,adjacency:h,preorder:m,postorder:b,topologicalOrder:i}}function ln(t,e,n){const o=n.laneOf(t);return[...e].sort((t,e)=>{var r,s;const i=n.laneOf(t),a=n.laneOf(e),c=null!=i&&i===o;if(c!==(null!=a&&a===o))return c?-1:1;const f=null==(r=n.rankHint)?void 0:r[t],l=null==(s=n.rankHint)?void 0:s[e];if(null!=f&&null!=l&&f!==l)return l-f;const d=n.topoIndex.get(t)??0,u=n.topoIndex.get(e)??0;return d!==u?d-u:t.localeCompare(e)})[0]}function dn(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 un(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 hn(t){const e=new Map,n=new Map,o=[],r=[];let s=0;const i=y((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(gn(a,f,o,r.length))))},"visit");for(const a of t.keys())e.has(a)||i(a,null);return r}function gn(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 pn(t,e,n){const o=[...t.nodes],r=new Map;for(const[y,b]of o.entries())r.set(b,y);const s=o.length,i=new Array(s).fill(-1),a=new Array(s).fill(0),c=[],f=new Set;for(const y of o){const t=n.parent.get(y)??null,e=r.get(y);null!=e&&(null==t&&(i[e]=-1,a[e]=0,f.has(y)||(f.add(y),c.push(y))))}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 y of o){if(f.has(y))continue;const t=r.get(y);null!=t&&(i[t]=-1,a[t]=0,f.add(y))}const l=Math.max(1,Math.ceil(Math.log2(Math.max(1,s)))+1),d=Array.from({length:l},()=>new Array(s).fill(-1));for(let y=0;y<s;y++)d[0][y]=i[y];for(let y=1;y<l;y++)for(let t=0;t<s;t++){const e=d[y-1][t];d[y][t]=-1===e?-1:d[y-1][e]}const u=y((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<l;o++)if(n>>o&1&&-1===(t=d[o][t]))return-1;if(t===e)return t;for(let o=l-1;o>=0;o--){const n=d[o][t],r=d[o][e];-1!==n&&-1!==r&&(n!==r&&(t=n,e=r))}return d[0][t]},"lcaIndex"),h=Array.from({length:s},()=>new Map);for(const y of t.edges){let t=y.src,n=y.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=u(i,a);if(-1===c)continue;const f=h[c];for(let e=o;e<s;e++)f.set(e,(f.get(e)??0)+1)}const g=new Map,p=y((t,e)=>{if(0!==e.size)for(const[n,o]of e)t.set(n,(t.get(n)??0)+o)},"mergeInto"),x=new Set,m=y(t=>{const o=r.get(t);x.add(t);const s=null==o?void 0:h[o],i=s?new Map(s):new Map,a=n.children.get(t)??[];for(const n of a){const o=m(n),r=e[t];if(null!=r){let s=g.get(t);s||(s=new Map,g.set(t,s));let i=o.get(r)??0;const a=e[n];null!=a&&a>r&&(i+=1),s.set(n,i)}p(i,o)}return i},"dfs");for(const y of n.roots)x.has(y)||m(y);for(const y of o)x.has(y)||m(y);return g}function xn(t,e,n){const o=new Map,r=y(t=>{let s=n[t]??0;const i=[...e.get(t)??[]];i.sort(mn(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 mn(t){return(e,n)=>{const o=t[e]??0,r=t[n]??0;return o===r?e.localeCompare(n):o-r}}function yn(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=y(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 bn(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 Mn(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=(null==f?void 0:f.get(t))??0,r=(null==f?void 0: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 In(t,e,n){const o=fn(t,{rankHint:e,laneOf:n}),{children:r,roots:s}=o;for(const l of t.nodes)r.has(l)||r.set(l,[]);const i=pn(t,e,o),a=[...s].sort(mn(e)),c=Mn(r,e,i,xn(a,r,e));let f=yn(a,t.nodes,e,c);return f=bn(f),f}function vn(t,e,n){const o=new Set(t),r=new Set(e),s=Ke(e),i=[];for(const a of n)o.has(a.src)&&r.has(a.dst)&&i.push(s.get(a.dst));return Qe(i)}function Sn(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+=vn(t[s],t[s+1],o);return r}function wn(t,e){const n={...e},{preds:o}=We(t),r=tn(t);let s=Sn(In(t,n,r),t.edges,n);const i=rn;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 l=Sn(In(t,n,r),t.edges,n);l<s?(s=l,e=!0):n[a]=f}if(!e)break}return n}function Ln(t,e){const n=tn(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 l=e[r]??0,d=l+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(l,u,d);h!==l&&(e[r]=h)}}function Cn(t,e){const n=Ge(t),o=qe(n)??[...n.nodes].sort(),r=(null==e?void 0:e.compactSingleInput)??!1,s=tn(n);let i=Object.create(null);for(const a of o){const t=De(n,a),o=(null==e?void 0: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}}(null==e?void 0:e.optimizeRanksByCrossings)&&(i=wn(n,i)),(null==e?void 0:e.ignoreCrossLaneEdges)&&Ln(n,i);return{layers:In(n,i,s),rankOf:i,dummy:new Set}}function kn(t,e){const n=Ge(t),o={...Cn(n,{compactSingleInput:null==e?void 0:e.compactSingleInput,ignoreCrossLaneEdges:null==e?void 0:e.ignoreCrossLaneEdges,optimizeRanksByCrossings:null==e?void 0:e.optimizeRanksByCrossings}).rankOf},r=tn(n),{preds:s,succs:i}=We(n,t=>{if(null==e?void 0:e.ignoreCrossLaneEdges){const e=r(t.src),n=r(t.dst);if(e&&n&&e!==n)return!1}return!0}),a=qe(n)??[...n.nodes],c=[...a].reverse(),f=y((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"),l=on,d=y(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,l=Math.round((a+c)/2),d=f(n,l);d!==o[n]&&(o[n]=d,e=!0)}return e},"relaxOrder");for(let u=0;u<l;u++){const t=d(a),e=d(c);if(!t&&!e)break}for(const u of a){let t=0;for(const e of s.get(u)??[])t=Math.max(t,(o[e]??0)+1);(o[u]??0)<t&&(o[u]=t)}for(const u of c){const t=i.get(u)??[];if(t.length>0){const e=Math.min(...t.map(t=>(o[t]??0)-1));(o[u]??0)>e&&(o[u]=e)}}return{layers:Je(n,a,o),rankOf:o,dummy:new Set}}function Tn(t){const e=_e(t),n=je(t);let o=Ve(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 $n(t,e){const n=Ge(t),o="LR"===(null==e?void 0:e.direction)?Tn(n)??[...n.nodes].sort():qe(n)??[...n.nodes].sort(),r=tn(n),s=y(t=>r(t)??t,"laneOf"),i=Object.create(null),a=new Map,c=y((t,n)=>(null==e?void 0:e.ignoreCrossLaneEdges)??!0?s(t)===s(n)?1:0:1,"edgeWeight");for(const f of o){const t=n.nodeById.get(f);if(null==t?void 0:t.isGroup)continue;const e=De(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),l=a.get(r)??0,d=Math.max(o,l);i[f]=d,a.set(r,d+1)}return{layers:Je(n,o,i,{skipGroups:!0}),rankOf:i,dummy:new Set}}function On(t,e){const n=Ge(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=y(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)),l=[];for(const u of f){const t=o[u.src]??0,e=o[u.dst]??0;if(e-t<=1){l.push(u);continue}let n=u.src;for(let o=t+1,s=0;o<e;o++,s++){const t=c(o);l.push({id:`${u.id}#${s}`,src:n,dst:t,weight:u.weight,ref:u.ref}),n=t}const r=e-t-2;l.push({id:`${u.id}#${Math.max(r+1,0)}`,src:n,dst:u.dst,weight:u.weight,ref:u.ref})}const d={nodes:[...n.nodes,...[...s].filter(t=>!n.nodes.includes(t))],edges:l,layout:n.layout,nodeById:a};return{layering:{layers:r,rankOf:o,dummy:s},graphWithDummies:d}}function Rn(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 Nn(t){if(0===t.length)return Number.POSITIVE_INFINITY;return t.reduce((t,e)=>t+e,0)/t.length}function Bn(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 En(t,e,n){const o=n.get(t)??0,r=n.get(e)??0;return o!==r?o-r:t.localeCompare(e)}function Fn(t,e,n){const o=new Set(t),r=new Set(e),s=Ke(t),i=Ke(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 Qe(a.map(t=>t.v))}function Yn(t,e,n){return[...t].sort((t,o)=>{const r=Rn(e.get(t)??[]),s=Rn(e.get(o)??[]);return r===s?En(t,o,n):isFinite(r)?isFinite(s)?r-s:-1:1})}function Xn(t,e,n,o,r,s){const i=Ke(t),a=Ke(e),c=Bn(e,i,n,o);if(!r||!s||0===s.length)return Yn(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 l=[];for(const u of s){const t=f.get(u);if(!t||0===t.length)continue;const e=Yn(t,c,a);l.push(...e)}const d=f.get(null);if(d&&d.length>0){const t=Yn(d,c,a);for(const e of t){const t=Nn(c.get(e)??[]);let n=l.length;if(isFinite(t))for(const[e,o]of l.entries()){if(t<Nn(c.get(o)??[])){n=e;break}}l.splice(n,0,e)}}return l}function Pn(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)),l=c?n.filter(t=>a.has(t.src)&&c.has(t.dst)):void 0,d=y(e=>{let n=Fn(t,e,f);return l&&o&&(n+=Fn(e,o,l)),n},"crossingScore"),u=r?new Map:null;if(r&&u)for(const p of e)u.set(p,r(p));let h=!0,g=d(s);for(;h;){h=!1;for(let t=0;t+1<s.length;t++){if(u){if(u.get(s[t])!==u.get(s[t+1]))continue}const e=g;[s[t],s[t+1]]=[s[t+1],s[t]];const n=d(s);n<e?(g=n,h=!0):[s[t],s[t+1]]=[s[t+1],s[t]]}}return s}function zn(t,e,n){const o=t.layers.map(t=>[...t]),r=e.edges,s=tn(e),i=nn(e,null==n?void 0:n.laneOrder);for(let a=0;a<3;a++){for(let t=1;t<o.length;t++)o[t]=Xn(o[t-1],o[t],r,"down",s,i),o[t]=Pn(o[t-1],o[t],r,o[t+1],s);for(let t=o.length-2;t>=0;t--)o[t]=Xn(o[t+1],o[t],r,"up",s,i),o[t]=Pn(o[t+1],o[t],r,o[t-1],s)}return{layers:o}}function An(t,e,n){const o=(null==n?void 0:n.layerGap)??an,r=(null==n?void 0:n.nodeGap)??cn,s=(null==n?void 0:n.laneGap)??2*r,i=(null==n?void 0:n.direction)??"TB",a="LR"===i||"RL"===i,c=t.layers,f=Object.create(null),l=Object.create(null),d=y(t=>e.nodeById.get(t),"getNode"),u=y(t=>{var e;return(null==(e=d(t))?void 0:e.width)??0},"getWidth"),h=y(t=>{var e;return(null==(e=d(t))?void 0:e.height)??0},"getHeight"),g=tn(e),p=nn(e,null==n?void 0:n.laneOrder),x=c.map(t=>t.reduce((t,e)=>Math.max(t,h(e)),0)),m=[];if(a)for(let y=0;y+1<c.length;y++){const t=c[y].reduce((t,e)=>Math.max(t,u(e)),0),e=c[y+1].reduce((t,e)=>Math.max(t,u(e)),0),n=x[y]/2+x[y+1]/2,r=(t+e)/2,s=Math.max(0,r-n-o);m.push(s)}const b=new Set;for(const y of c)for(const t of y)b.add(g(t));const M=b.has(null),I=p.filter(t=>b.has(t)),v=[...M?[null]:[],...I],S=Object.create(null);for(const y of I)S[y]=0;M&&(S.null=0);for(const y of c){const t=Object.create(null),e=[];for(const n of y){const o=g(n);null===o?e.push(n):(t[o]||(t[o]=[])).push(n)}for(const[n,o]of Object.entries(t)){const t=o.reduce((t,e)=>t+u(e),0)+r*Math.max(0,o.length-1);S[n]=Math.max(S[n]??0,t)}if(M&&e.length){const t=e.reduce((t,e)=>t+u(e),0)+r*Math.max(0,e.length-1);S.null=Math.max(S.null??0,t)}}const w=new Map;{const t=v.map(t=>(null===t?S.null:S[t])??0);let e=-(t.reduce((t,e)=>t+e,0)+s*Math.max(0,v.length-1))/2;for(let n=0;n<v.length;n++){const o=v[n],r=t[n]??0,i=e+r/2;w.set(o,i),e+=r,n<v.length-1&&(e+=s)}}let L=0;for(const[y,k]of c.entries()){const t=x[y]??0,e=new Map;for(const n of k){const t=g(n),o=e.get(t)??[];o.push(n),e.set(t,o)}for(const n of v){const o=e.get(n)??[];if(0===o.length)continue;const s=w.get(n);if(1===o.length){const e=o[0];f[e]=s,l[e]=L+t/2}else{const e=o.map(t=>u(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,l[i]=L+t/2,n+=o+r}}}L+=t+o+(m[y]??0)}const C=new Map;for(const y of e.edges){const t=y.ref.id;C.has(t)||C.set(t,[]),C.get(t).push(y)}for(const[,y]of C){if(0===y.length)continue;const t=y[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 y)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);(null==t?void 0:t.isDummy)&&(f[i]=r)}}return{x:f,y:l}}y(fn,"buildDrivingTree"),y(ln,"chooseParent"),y(dn,"buildAdjacency"),y(un,"assignComponents"),y(hn,"computeBlocks"),y(gn,"popBlock"),y(pn,"computeSubtreeCrossCounts"),y(xn,"annotateMinimumLayers"),y(mn,"compareByRankThenId"),y(yn,"emitNodesInTreeOrder"),y(bn,"deduplicateLayers"),y(Mn,"createChildOrderer"),y(In,"buildMultitreeLayerOrder"),y(vn,"countCrossingsBetweenAdjacent"),y(Sn,"totalCrossings"),y(wn,"optimizeRanksByCrossings"),y(Ln,"adjustCrossLaneSources"),y(Cn,"assignLayers_LongestPath"),y(kn,"assignLayers_Gravity"),y(Tn,"topoSortByGenerationIfAcyclic"),y($n,"assignLayers_LaneAwareCompact"),y(On,"makeProperLayering"),y(Rn,"median"),y(Nn,"barycenter"),y(Bn,"neighborPositionsFor"),y(En,"currentOrderTieBreak"),y(Fn,"countCrossingsBetweenAdjacent"),y(Yn,"sortByHeuristic"),y(Xn,"reorderLayer"),y(Pn,"transposeImprove"),y(zn,"orderLayers"),y(An,"assignCoordinates");function Gn(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 Dn(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 Hn(t,e){const n=[...t],o=Dn(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 jn(t,e){let n=0;for(const[o,r]of t.entries())n+=Math.abs(o-(e.get(r)??o));return n}function _n(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 Vn(t){const e=en(t);if(e.length<2)return[];const n=new Map(e.map((t,e)=>[t,e])),o=tn(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),l=n.get(c);if(null==f||null==l)continue;const[d,u]=f<=l?[a,c]:[c,a],h=`${d}\0${u}`,g=r.get(h);g?g.weight++:r.set(h,{a:d,b:u,weight:1})}return[...r.values()]}function Wn(t,e,n){const o=[...t];let r=_n(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=_n(o,e);n<r?(r=n,s=!0):[o[t],o[t+1]]=[o[t+1],o[t]]}}return{order:o,cost:r,sourceDistance:jn(o,n)}}function Jn(t,e){return t.cost!==e.cost?t.cost<e.cost:t.sourceDistance<e.sourceDistance}function qn(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 Gn(`${t.join("|")}#${o}#${n}`)}function Kn(t,e={}){const n=en(t);if(n.length<2)return n;const o=Vn(t);if(0===o.length)return n;const r=new Map(n.map((t,e)=>[t,e]));let s=Wn(n,o,r);const i=Math.max(0,e.restarts??8);for(let a=0;a<i;a++){const t=Wn(Hn(n,qn(n,o,a)),o,r);Jn(t,s)&&(s=t)}return s.order}function Qn(t,e){const n=(null==e?void 0:e.ignoreCrossLaneEdges)??!0,o=(null==e?void 0:e.optimizeRanksByCrossings)??!0,r=Ge(t),s=(null==e?void 0:e.automaticLaneOrdering)?Kn(r,{restarts:8}):void 0,i=Ze(r),a=i.acyclic,c=n?$n(a,{compactSingleInput:(null==e?void 0:e.compactSingleInput)??sn,ignoreCrossLaneEdges:!0,direction:null==e?void 0:e.direction}):kn(a,{compactSingleInput:(null==e?void 0:e.compactSingleInput)??sn,ignoreCrossLaneEdges:!1,optimizeRanksByCrossings:o}),{layering:f,graphWithDummies:l}=On(c,a),d=zn(f,l,{laneOrder:s}),u=An(d,l,{layerGap:null==e?void 0:e.layerGap,nodeGap:null==e?void 0:e.nodeGap,direction:null==e?void 0:e.direction,laneOrder:s});return{acyclic:a,reversed:i.reversed,layering:f,ordered:d,coordinates:u}}y(Gn,"hashString"),y(Dn,"mulberry32"),y(Hn,"deterministicShuffle"),y(jn,"sourceDistance"),y(_n,"laneArrangementCost"),y(Vn,"buildWeightedLaneEdges"),y(Wn,"greedySwitch"),y(Jn,"isBetterCandidate"),y(qn,"seedForRestart"),y(Kn,"optimizeTopLaneOrder"),y(Qn,"sugiyamaLayout");var Zn=1e-6,Un=15,to=15,eo=20;function no(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<Zn&&c<Zn)return n;return c>Zn&&3*c>=a?i>0?"bottom":"top":a>Zn?s>0?"right":"left":n}function oo(t,e){return Math.abs(t.to-e.from)<Zn||Math.abs(t.to-e.to)<Zn?t.to:t.from}function ro(t,e){return"vertical"===t.orient?{x:t.coord,y:e}:{x:e,y:t.coord}}function so(t,e){var n,o,r,s;const i=t.nodes??[],a=t.edges??[],c=[];for(const y of a)y.isLayoutOnly||c.push({...y,__originalEdge:y});const f=new Map,l=new Map,d=[],u="LR"===e;for(const y of i)f.set(y.id,y);const h=i.filter(t=>t.isGroup&&!t.parentId);for(const it of h){const t={id:it.id},e=y(n=>{l.set(n.id,t),i.filter(t=>t.parentId===n.id).forEach(e)},"assignLane");e(it)}const g=i.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:u?n/2+8:e/2+8}}),p=y((t,e,n,o)=>{let r=d.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:[]},d.push(r)),r.spanMin=Math.min(r.spanMin,n),r.spanMax=Math.max(r.spanMax,o),r},"getOrAddPipe"),x=y((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"),m=y((t,e,n)=>x(t,no(t,e,n?"bottom":"top")),"getOrthogonalPort"),b=[],M=[],I=new Set,v=y((t,e,n)=>{if(0===b.length)return 0;const o=Math.abs(e.y-n.y)<Zn,r=Math.abs(e.x-n.x)<Zn;if(!o&&!r)return 0;let s=0;if(o){const o=e.y,r=Math.min(e.x,n.x)-Zn,i=Math.max(e.x,n.x)+Zn;if(i<=r)return 0;for(const e of b)e.edgeIndex!==t&&"vertical"===e.orientation&&(e.pipe.coord<r||e.pipe.coord>i||e.from-Zn<=o&&e.to+Zn>=o&&(s+=1e3))}else if(r){const o=e.x,r=Math.min(e.y,n.y)-Zn,i=Math.max(e.y,n.y)+Zn;if(i<=r)return 0;for(const e of b)e.edgeIndex!==t&&"horizontal"===e.orientation&&(e.pipe.coord<r||e.pipe.coord>i||e.from-Zn<=o&&e.to+Zn>=o&&(s+=1e3))}return s},"crossingPenalty"),S=c.map((t,e)=>{if(!t.start||!t.end)return{idx:e,crossLane:0,dx:0,dy:0};const n=f.get(t.start),o=f.get(t.end),r=l.get(t.start),s=l.get(t.end);return{idx:e,crossLane:r&&s&&r.id!==s.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),w=y((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!!g.find(c=>(!n||c.nodeId!==n)&&((!o||c.nodeId!==o)&&(Math.abs(t.x-e.x)>Zn?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"),L=new Map,C=new Map;for(const y of c)y.start&&y.end&&y.start!==y.end&&(C.set(y.start,(C.get(y.start)??0)+1),C.set(y.end,(C.get(y.end)??0)+1));const k=y((t,e)=>no(t,e,"bottom"),"determineSide"),T=new Map;for(const[y,it]of c.entries()){if(!it.start||!it.end||it.start===it.end)continue;if(it.points&&it.points.length>0)continue;const t=f.get(it.start),e=f.get(it.end);if(!t||!e)continue;const n=(e.x??0)-(t.x??0),o=(e.y??0)-(t.y??0);T.set(y,{edgeIdx:y,srcId:it.start,dstId:it.end,srcSide:k(t,{x:e.x??0,y:e.y??0}),dstSide:k(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 $=y(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"),O=y(t=>"top"===t.srcSide||"bottom"===t.srcSide?t.dxSign>=0?"right":"left":t.dySign>=0?"bottom":"top","secondarySide"),R=new Map;for(const y of T.values()){const t=`${y.srcId}:${y.srcSide}`;R.has(t)||R.set(t,[]),R.get(t).push(y)}const N=new Map,B=y((t,e)=>`${t}:${e}`,"loadKey");for(const y of T.values())N.set(B(y.srcId,y.srcSide),(N.get(B(y.srcId,y.srcSide))??0)+1),N.set(B(y.dstId,y.dstSide),(N.get(B(y.dstId,y.dstSide))??0)+1);for(const y of R.values())if(!(y.length<2)){y.sort((t,e)=>{const n=$(t),o=$(e);return Math.abs(n-o)>1e-9?o-n:t.edgeIdx-e.edgeIdx});for(let t=1;t<y.length;t++){const e=y[t],n=O(e),o=N.get(B(e.srcId,e.srcSide))??0,r=N.get(B(e.srcId,n))??0;r>=o||(N.set(B(e.srcId,e.srcSide),o-1),N.set(B(e.srcId,n),r+1),e.srcSide=n)}}const E=y(t=>{const e=null==t?void 0:t.shape;return"question"===e||"diamond"===e},"isDiamondNode"),F=new Map;for(const y of T.values())F.has(y.dstId)||F.set(y.dstId,new Set),F.get(y.dstId).add(y.dstSide);for(const y of T.values()){if(!E(f.get(y.srcId)))continue;const t=F.get(y.srcId);if(!(null==t?void 0:t.has(y.srcSide)))continue;const e=O(y);if(t.has(e)||(N.get(B(y.srcId,e))??0)>0)continue;const n=N.get(B(y.srcId,y.srcSide))??0;N.set(B(y.srcId,y.srcSide),Math.max(0,n-1)),N.set(B(y.srcId,e),1),y.srcSide=e}for(const y of T.values()){const{edgeIdx:t,srcId:e,dstId:n,srcSide:o,dstSide:r}=y,s=f.get(e),i=f.get(n),a=`${e}:${o}:src`,c="top"===o||"bottom"===o?i.x??0:i.y??0;L.has(a)||L.set(a,[]),L.get(a).push({edgeIdx:t,oppositeCoord:c});const l=`${n}:${r}:dst`,d="top"===r||"bottom"===r?s.x??0:s.y??0;L.has(l)||L.set(l,[]),L.get(l).push({edgeIdx:t,oppositeCoord:d})}const Y=new Map;for(const[y,it]of L){if(it.length<2)continue;it.sort((t,e)=>t.oppositeCoord-e.oppositeCoord);const t=y.split(":"),e=t.slice(0,-2).join(":"),n=t[t.length-2],o=t[t.length-1],r=f.get(e);if(!r)continue;const s="left"===n||"right"===n?r.height??10:r.width??10,i=r.shape,a="question"===i||"diamond"===i?.3*s:s,c=20,l=Math.min(c,Math.max(8,a/(it.length+1))),d=-(l*(it.length-1))/2;for(const[f,u]of it.entries()){const t=d+f*l,e=`${u.edgeIdx}:${o}`;Y.set(e,t)}}const X=y(t=>{var e;return Boolean(null==(e=c[t])?void 0:e.labelNodeId)},"edgeHasLabelNode"),P=y((t,e)=>!!t&&((L.get(`${t}:${e}:src`)??[]).some(({edgeIdx:t})=>X(t))||(L.get(`${t}:${e}:dst`)??[]).some(({edgeIdx:t})=>X(t))),"faceHasLabelNode"),z=y((t,e,n)=>"top"===e||"bottom"===e?{x:t.x+n,y:t.y}:{x:t.x,y:t.y+n},"applyPortOffset"),A=y((t,e,n)=>{const o=T.get(t),r={x:n.x??0,y:n.y??0},s={x:e.x??0,y:e.y??0},i=(null==o?void 0:o.srcSide)??k(e,r),a=(null==o?void 0:o.dstSide)??k(n,s);let c=o?x(e,o.srcSide):m(e,r,!0),f=o?x(n,o.dstSide):m(n,s,!1);const l=Y.get(`${t}:src`),d=Y.get(`${t}:dst`);return void 0!==l&&(c=z(c,i,l)),void 0!==d&&(f=z(f,a,d)),{pSrcPort:c,pDstPort:f,srcSide:i,dstSide:a}},"portsForEdge");for(const it of S){const t=c[it];if(M[it]=[],!t.start||!t.end)continue;if(t.points&&t.points.length>0)continue;if(t.start===t.end)continue;const e=f.get(t.start),i=f.get(t.end);if(!e||!i)continue;const{pSrcPort:a,pDstPort:l,srcSide:h,dstSide:x}=A(it,e,i),m={...a},S={...l},k="top"===h||"bottom"===h,T="top"===x||"bottom"===x;if(k){const t=a.y>(e.y??0);m.y=t?a.y+eo:a.y-eo}else{const t=a.x>(e.x??0);m.x=t?a.x+eo:a.x-eo}if(T){const t=l.y>(i.y??0);S.y=t?l.y+eo:l.y-eo}else{const t=l.x>(i.x??0);S.x=t?l.x+eo:l.x-eo}const $=y((t,e)=>{for(const n of g)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"),O=y((t,e,n,o,r)=>{if(r){const r=t.y>(e.y??0);return{x:(n.x??0)>=t.x?o.maxX+Un:o.minX-Un,y:r?o.maxY+to:o.minY-to,leavesPositiveSide:r}}const s=t.x>(e.x??0),i=(n.y??0)>=t.y;return{x:s?o.maxX+Un:o.minX-Un,y:i?o.maxY+to:o.minY-to,leavesPositiveSide:s}},"obstacleDetour");let R=[];const N=[t.start,t.end],B=$(m,N);if(B.inside&&B.obstacle){const t=B.obstacle;if(k){const n=O(a,e,i,t,!0);m.x=n.x,m.y=n.y;const o=n.leavesPositiveSide?Math.min(t.minY-2,a.y+eo):Math.max(t.maxY+2,a.y-eo);R=[{x:a.x,y:o},{x:n.x,y:o},{x:n.x,y:n.y}]}else{const n=O(a,e,i,t,!1),o=n.leavesPositiveSide?Math.min(t.minX-2,a.x+eo):Math.max(t.maxX+2,a.x-eo);m.x=n.x,m.y=n.y,R=[{x:o,y:a.y},{x:o,y:n.y},{x:n.x,y:n.y}]}}let E=[];const F=$(S,N);if(F.inside&&F.obstacle){const t=F.obstacle;if(T){const n=O(l,i,e,t,!0);S.x=n.x,S.y=n.y,E=[{x:n.x,y:n.y},{x:l.x,y:n.y}]}else{const n=O(l,i,e,t,!1);S.x=n.x,S.y=n.y,E=[{x:n.x,y:n.y},{x:n.x,y:l.y}]}}if(0===R.length&&0===E.length){const e=Un,i=Math.abs(m.x-S.x)<e,c=Math.abs(m.y-S.y)<e,f=void 0!==Y.get(`${it}:src`)||void 0!==Y.get(`${it}:dst`),d=((null==(n=L.get(`${t.start??""}:${h}:src`))?void 0:n.length)??0)+((null==(o=L.get(`${t.start??""}:${h}:dst`))?void 0:o.length)??0),u=((null==(r=L.get(`${t.end??""}:${x}:src`))?void 0:r.length)??0)+((null==(s=L.get(`${t.end??""}:${x}:dst`))?void 0:s.length)??0),g=d>1||u>1,p=C.get(t.start??"")??0,y=C.get(t.end??"")??0,M=d>1&&P(t.start,h)||u>1&&P(t.end,x);if((i||c)&&!f&&(!g||g&&!M&&(d<=1||p<=2)&&(u<=1||y<=2))){if(!w(a,l,t.start,t.end)){t.points=[{...a},{...m},{...S},{...l}],I.add(it);const e=c?"horizontal":"vertical",n=c?a.y:a.x,o=c?Math.min(a.x,l.x):Math.min(a.y,l.y),r=c?Math.max(a.x,l.x):Math.max(a.y,l.y),s={id:`fast-path-${e}-${n.toFixed(0)}-${it}`,orientation:e,coord:n,spanMin:o,spanMax:r,tracks:[]};b.push({edgeIndex:it,segmentIndex:0,orientation:e,pipe:s,trackIndex:0,from:o,to:r});continue}}}const X=p("vertical",m.x,m.y,m.y);m.x=X.coord;const z=p("vertical",S.x,S.y,S.y);S.x=z.coord;let G=Math.min(m.x,S.x)-50,D=Math.max(m.x,S.x)+50,H=Math.min(m.y,S.y)-50,j=Math.max(m.y,S.y)+50;for(const n of g){const t=Math.min(m.x,S.x),e=Math.max(m.x,S.x),o=Math.min(m.y,S.y),r=Math.max(m.y,S.y);n.minX<e&&n.maxX>t&&n.minY<r&&n.maxY>o&&(G=Math.min(G,n.minX-25),D=Math.max(D,n.maxX+25),H=Math.min(H,n.minY-25),j=Math.max(j,n.maxY+25))}for(const n of g){if(n.maxX<G||n.minX>D||n.maxY<H||n.minY>j)continue;const t=Un;p("horizontal",n.minY-t,G,D),p("horizontal",n.maxY+t,G,D);const e=to;p("vertical",n.minX-e,H,j),p("vertical",n.maxX+e,H,j)}p("horizontal",m.y,G,D),p("horizontal",S.y,G,D);const _=d.filter(t=>"horizontal"===t.orientation&&t.coord>=H&&t.coord<=j),V=d.filter(t=>"vertical"===t.orientation&&t.coord>=G&&t.coord<=D),W=y((t,e)=>`${t.toFixed(1)},${e.toFixed(1)}`,"getKey"),J=W(m.x,m.y),q=W(S.x,S.y),K=new Map,Q=new Map,Z=new Map,U=new Set,tt=[];K.set(J,0),Z.set(J,"n"),tt.push({key:J,f:Math.hypot(S.x-m.x,S.y-m.y),pt:m}),U.add(J);let et=[];const nt=y((e,n)=>w(e,n,t.start,t.end),"checkSegmentBlocked"),ot={x:S.x,y:m.y},rt=nt(m,ot),st=nt(ot,S),at=rt||st,ct={x:m.x,y:S.y},ft=nt(m,ct),lt=nt(ct,S);if(at?ft||lt||(et=Math.abs(m.x-S.x)<Zn?[m,S]:[m,ct,S]):et=Math.abs(m.y-S.y)<Zn||Math.abs(m.x-S.x)<Zn?[m,S]:[m,ot,S],0===et.length)for(;tt.length>0;){tt.sort((t,e)=>t.f-e.f);const e=tt.shift();if(U.delete(e.key),e.key===q){let t=q,e=S;for(et=[e];Q.has(t);){const n=Q.get(t);et.unshift(n),e=n,t=W(n.x,n.y)}break}const n=e.pt.x,o=e.pt.y,r=V.sort((t,e)=>t.coord-e.coord),s=r.findIndex(t=>Math.abs(t.coord-n)<1),i=_.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(g.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=W(f.x,f.y),l=Math.abs(f.x-n)+Math.abs(f.y-o),d=v(it,e.pt,f);let u=0;const h=S.x-m.x,p=S.y-m.y,x=f.x-n,y=f.y-o;(p>10&&y<-5||p<-10&&y>5)&&(u=100*Math.abs(y)),(h>10&&x<-5||h<-10&&x>5)&&(u+=50*Math.abs(x));let b=0;const M=Z.get(e.key)??"n",I=Math.abs(x)>Zn?"h":"v";"n"!==M&&M!==I&&(b=50);const w=l+d+u+b,L=(K.get(e.key)??1/0)+w,C=Math.abs(S.x-f.x)+Math.abs(S.y-f.y);if(L<(K.get(c)??1/0))if(Q.set(c,e.pt),K.set(c,L),Z.set(c,I),U.has(c)){const t=tt.findIndex(t=>t.key===c);-1!==t&&(tt[t].f=L+C)}else tt.push({key:c,f:L+C,pt:f}),U.add(c)}}if(0===et.length&&(et=[m,{x:m.x,y:S.y},S]),et.length>4){const t=et[0],e=et[et.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 d of et)n=Math.min(n,d.x),o=Math.max(o,d.x),r=Math.min(r,d.y),s=Math.max(s,d.y);const i=o>Math.max(t.x,e.x),a=n<Math.min(t.x,e.x);if(u){const r=to;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=g.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=g.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 c=y(n=>{const o=e.y>t.y,r=g.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(u&&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-Zn)return t}else{const t=Math.min(...s.map(t=>t.minY))-15;if(t>e.y+Zn)return t}return e.y},"findBestReturnY"),f=y(n=>{const o=c(n),r={x:n,y:t.y},s={x:n,y:o},i={x:e.x,y:o},a=nt(t,r),f=nt(r,s),l=nt(s,i),d=o!==e.y&&nt(i,e);return a||f||l||d?null:Math.abs(o-e.y)<Zn?[t,r,s,e]:[t,r,s,i,e]},"trySimplifyWithDetourX"),l=i&&!a?f(o):a&&!i?f(n):null;l&&(et=l)}const dt=[a,...R,...et,...E.reverse(),l];if(dt.length>=3){const t=dt[dt.length-1],e=dt[dt.length-2],n=dt[dt.length-3],o=Math.abs(n.y-e.y)<Zn&&Math.abs(e.y-t.y)<Zn,r=Math.abs(n.x-e.x)<Zn&&Math.abs(e.x-t.x)<Zn;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)&&dt.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)&&dt.splice(-2,1)}}const ut=[dt[0]];for(let n=1;n<dt.length-1;n++){if(1===n){ut.push(dt[n]);continue}const t=ut[ut.length-1],e=dt[n],o=dt[n+1];if(Math.abs(t.y-e.y)<Zn&&Math.abs(e.y-o.y)<Zn){if(e.x>t.x!==o.x>e.x){ut.push(e);continue}continue}if(Math.abs(t.x-e.x)<Zn&&Math.abs(e.x-o.x)<Zn){if(e.y>t.y!==o.y>e.y){ut.push(e);continue}continue}ut.push(e)}ut.push(dt[dt.length-1]);for(let n=0;n<ut.length-1;n++){const t=ut[n],e=ut[n+1],o=Math.abs(t.x-e.x)<Zn?"vertical":"horizontal",r="vertical"===o?t.x:t.y,s="vertical"===o?Math.min(t.y,e.y):Math.min(t.x,e.x),i="vertical"===o?Math.max(t.y,e.y):Math.max(t.x,e.x),a=p(o,r,s,i),c={edgeIndex:it,segmentIndex:n,orientation:o,pipe:a,trackIndex:0,from:s,to:i};b.push(c),M[it].push(b.length-1),a.tracks[0]||(a.tracks[0]={index:0,coord:a.coord,segments:[]}),a.tracks[0].segments.push({edgeIndex:it,segmentIndex:n,from:s,to:i})}}const G=y((t,e)=>t.from<e.to&&e.from<t.to,"segmentsOverlap"),D=y((t,e,n,o)=>{const r=!o.segments.some(n=>(n.edgeIndex!==e.edgeIndex||n.segmentIndex!==e.segmentIndex)&&G(n,t)),s=!n.segments.some(n=>(n.edgeIndex!==t.edgeIndex||n.segmentIndex!==t.segmentIndex)&&G(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"),H=y(t=>{const e=t.tracks.length;return t.tracks[e]={index:e,coord:t.coord,segments:[]},e},"createNewTrack"),j=y((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"),_=y((t,e)=>{const n=M[t.edgeIndex];for(const o of n){const n=b[o];n.pipe===t.pipe&&j(n,e)}},"moveSegmentChainToTrack"),V=y(t=>{const e=M[t.edgeIndex],n=e.indexOf(b.indexOf(t)),o=[];return n>0&&o.push(b[e[n-1]]),n<e.length-1&&o.push(b[e[n+1]]),o},"getAdjacentSegmentsAlongEdge"),W=y((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"),J=y((t,e)=>{for(const n of t.tracks){if(!n.segments.some(t=>(t.edgeIndex!==e.edgeIndex||t.segmentIndex!==e.segmentIndex)&&G(t,e)))return n.index}return-1},"findAvailableTrack"),q=y((t,e)=>{if(t.trackIndex===e.trackIndex)return G(t,e);const n=V(t),o=V(e);return n.some(t=>o.some(e=>W(t,e)))},"segmentsConflict"),K=y((t,e,n)=>{if(D(t,e,t.pipe.tracks[t.trackIndex],e.pipe.tracks[e.trackIndex]))return;const o=J(t.pipe,e);n(e,-1!==o?o:H(t.pipe))},"resolveTrackConflict"),Q=y(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&&(q(r,s)&&(e++,K(r,s,_)))}return e},"resolveHandleConflicts"),Z=new Map,U=y(t=>{if(Z.has(t))return Z.get(t);const e=M[t];if(0===e.length){const e={dest:0,deviation:0,base:0,delta:0};return Z.set(t,e),e}const n=b[e[0]].pipe.coord;let o=n;for(let s=1;s<e.length;s++){const t=b[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 Z.set(t,r),r},"getDestInfo"),tt=y(()=>{let t=0;const e=new Map;for(const[o,r]of c.entries())0!==M[o].length&&r.start&&(e.has(r.start)||e.set(r.start,[]),e.get(r.start).push(o));const n=y(t=>{const e=c[t];if(!e.start||!e.end)return 0;const n=f.get(e.start),o=f.get(e.end);if(!n||!o)return 0;const r=(o.x??0)-(n.x??0),s=(o.y??0)-(n.y??0);return Math.abs(r)+Math.abs(s)},"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=M[t].length,c=M[e].length;if(a!==c)return a-c;if(1===a){const n=M[t][0],o=M[e][0];if(b[n]&&b[o]){const t=b[n],e=b[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=>b[M[t][0]]);t+=Q(e)}return t},"fixSourceHandleCrossings"),et=y(()=>{let t=0;const e=new Map;for(const[n,o]of c.entries()){0!==M[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=y(t=>{const e=M[t];if(e.length<2)return 0;const n=b[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=>b[M[t][M[t].length-1]]);t+=Q(e)}return t},"fixTargetHandleCrossings"),nt=y(()=>{let t=0;for(const e of d){const n=[];for(const t of e.tracks)for(const e of t.segments){const t=M[e.edgeIndex].find(t=>b[t].segmentIndex===e.segmentIndex);void 0!==t&&n.push(b[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];q(r,s)&&(t++,K(r,s,j))}}return t},"fixPipeCrossings");let ot=0;for(;ot<10;){let t=0;if(t+=tt(),t+=et(),t+=nt(),0===t)break;ot++}const rt=new Map;for(const it of d){const t=[];it.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=y((t,e)=>{n.filter(e=>e.trackIndex===t).forEach(t=>{const n=I.has(t.edgeIndex)?it.coord:e;rt.set(`${t.edgeIndex}-${t.segmentIndex}`,n)})},"assignCoord");let a=0;for(const n of o)a++,i(n,it.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,it.coord);else{const t=c%2==1?1:-1,e=Math.ceil(c/2);i(n,it.coord+t*e*10*.5)}c++}let f=0;for(const n of r)f++,i(n,it.coord+10*f)}}for(const[y,it]of c.entries()){const t=M[y]??[];if(0===t.length)continue;const e=[],n=f.get(it.start),o=f.get(it.end),{pSrcPort:r,pDstPort:s}=A(y,n,o),i=t.map(t=>{const e=b[t],n=rt.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 f=0;f<i.length;f++){const t=i[f],n=e[e.length-1],o="vertical"===t.orient?n.y:n.x,r="vertical"===t.orient?n.x:n.y,s=i[f+1],a=f<i.length-1;if(Math.abs(r-t.coord)>Zn&&e.push(ro(t,o)),a&&s.orient===t.orient)if(Math.abs(t.coord-s.coord)>Zn){const n="vertical"===t.orient?(o+s.from)/2:oo(t,s);e.push(ro(t,n),ro(s,n))}else 0!==f&&f!==i.length-2||e.push(ro(t,oo(t,s)));else if(a)e.push(ro(t,s.coord));else{const n=Math.abs(t.from-o)<Math.abs(t.to-o)?t.to:t.from;e.push(ro(t,n))}}const a=e[e.length-1];(Math.abs(a.x-s.x)>Zn||Math.abs(a.y-s.y)>Zn)&&e.push(s);const c=[];e.length>0&&c.push(e[0]);for(let f=1;f<e.length;f++){const t=e[f],n=c[c.length-1];(Math.abs(t.x-n.x)>Zn||Math.abs(t.y-n.y)>Zn)&&c.push(t)}it.points=c}for(const y of c){const t=y.__originalEdge;t&&y.points&&(t.points=y.points)}t.edges=(t.edges??[]).filter(t=>!t.isLayoutOnly);const st=y((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 l=t.x-i,d=a-t.x,u=t.y-c,h=f-t.y,g=Math.min(l,d,u,h);return g===l?{x:i,y:t.y}:g===d?{x:a,y:t.y}:g===u?{x:t.x,y:c}:{x:t.x,y:f}},"nodeBoundaryClamp");for(const y of t.edges){const t=y.points;if(!t||t.length<2)continue;const e=y.start,n=y.end,o=e?f.get(e):void 0,r=n?f.get(n):void 0;o&&(t[0]=st(t[0],o)),r&&(t[t.length-1]=st(t[t.length-1],r))}return t}function io(t){return t.direction??"TB"}function ao(t){var e,n,o,r,s;const i=_(t),a=(null==(e=t.config.flowchart)?void 0:e.nodeSpacing)??40,c=(null==(n=t.config.flowchart)?void 0:n.rankSpacing)??100,f=(null==(o=t.config.swimlane)?void 0:o.ignoreCrossLaneEdges)??!0,l=(null==(r=t.config.swimlane)?void 0:r.optimizeRanksByCrossings)??!0,d=(null==(s=t.config.swimlane)?void 0:s.automaticLaneOrdering)??!1,u=io(t),{ordered:h,coordinates:g}=Qn(i,{nodeGap:a,layerGap:c,ignoreCrossLaneEdges:f,optimizeRanksByCrossings:l,automaticLaneOrdering:d,direction:u});V(i,h,g,{nodeGap:a,layerGap:c});for(const p of t.edges??[])delete p.points;so(t,u);for(const p of t.edges??[])p.curve&&"basis"!==p.curve||(p.curve="rounded");return Ae(t,u),ze(t),u}async function co(t,i){const a=i.select("g");n(a,t.markers,t.type,t.diagramId),o(),r(),s(),e(),j(t);const c=W(t);t.nodes=c.nodes,t.edges=c.edges;const{groups:f}=await I(a,t);ao(t),await z(t,f)}y(no,"chooseOrthogonalSide"),y(oo,"sharedLineEndpointCoord"),y(ro,"pointOnLine"),y(so,"routeEdgesOrthogonal"),y(io,"getSwimlaneDirection"),y(ao,"runSwimlaneLayoutCore"),y(co,"render");export{co as render};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as r,s as t}from"./flowDiagram-23GEKE2U-BvyeC4B4.js";import{_ as e}from"./mermaid.core-vavDl7Vc.js";import"./chunk-5VM5RSS4-D1soGNls.js";import"./chunk-XXDRQBXY-DGKbzfgb.js";import"./chunk-VR4S4FIN-D1BCGr2u.js";import"./chunk-32BRIVSS-CggGBtt4.js";import"./index-i_5HmRyk.js";import"./channel-BPpgv-ij.js";var o=r({defaultLayout:"swimlane",styles:e(r=>`${t(r)}\n .swimlane.cluster rect {\n stroke: ${r.clusterBorder} !important;\n }\n [data-look="neo"].cluster rect {\n filter: none;\n }\n`,"getStyles")});export{o as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as t,y as e,S as n,T as i,U as r,c as a,l as s,D as o,K as l,V as c,d as h,t as d,W as u,p}from"./mermaid.core-vavDl7Vc.js";import{d as g}from"./arc-048B3EAe.js";import"./index-i_5HmRyk.js";var y=function(){var e=t(function(t,e,n,i){for(n=n||{},i=t.length;i--;n[t[i]]=e);return n},"o"),n=[6,11,13,14,15,17,19,20,23,24],i=[1,12],r=[1,13],a=[1,14],s=[1,15],o=[1,16],l=[1,19],c=[1,20],h={trace:t(function(){},"trace"),yy:{},symbols_:{error:2,start:3,timeline_header:4,document:5,EOF:6,timeline:7,timeline_lr:8,timeline_td:9,line:10,SPACE:11,statement:12,NEWLINE:13,title:14,acc_title:15,acc_title_value:16,acc_descr:17,acc_descr_value:18,acc_descr_multiline_value:19,section:20,period_statement:21,event_statement:22,period:23,event:24,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",7:"timeline",8:"timeline_lr",9:"timeline_td",11:"SPACE",13:"NEWLINE",14:"title",15:"acc_title",16:"acc_title_value",17:"acc_descr",18:"acc_descr_value",19:"acc_descr_multiline_value",20:"section",23:"period",24:"event"},productions_:[0,[3,3],[4,1],[4,1],[4,1],[5,0],[5,2],[10,2],[10,1],[10,1],[10,1],[12,1],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[21,1],[22,1]],performAction:t(function(t,e,n,i,r,a,s){var o=a.length-1;switch(r){case 1:return a[o-1];case 3:i.setDirection("LR");break;case 4:i.setDirection("TD");break;case 5:case 9:case 10:this.$=[];break;case 6:a[o-1].push(a[o]),this.$=a[o-1];break;case 7:case 8:this.$=a[o];break;case 11:i.getCommonDb().setDiagramTitle(a[o].substr(6)),this.$=a[o].substr(6);break;case 12:this.$=a[o].trim(),i.getCommonDb().setAccTitle(this.$);break;case 13:case 14:this.$=a[o].trim(),i.getCommonDb().setAccDescription(this.$);break;case 15:i.addSection(a[o].substr(8)),this.$=a[o].substr(8);break;case 18:i.addTask(a[o],0,""),this.$=a[o];break;case 19:i.addEvent(a[o].substr(2)),this.$=a[o]}},"anonymous"),table:[{3:1,4:2,7:[1,3],8:[1,4],9:[1,5]},{1:[3]},e(n,[2,5],{5:6}),e(n,[2,2]),e(n,[2,3]),e(n,[2,4]),{6:[1,7],10:8,11:[1,9],12:10,13:[1,11],14:i,15:r,17:a,19:s,20:o,21:17,22:18,23:l,24:c},e(n,[2,10],{1:[2,1]}),e(n,[2,6]),{12:21,14:i,15:r,17:a,19:s,20:o,21:17,22:18,23:l,24:c},e(n,[2,8]),e(n,[2,9]),e(n,[2,11]),{16:[1,22]},{18:[1,23]},e(n,[2,14]),e(n,[2,15]),e(n,[2,16]),e(n,[2,17]),e(n,[2,18]),e(n,[2,19]),e(n,[2,7]),e(n,[2,12]),e(n,[2,13])],defaultActions:{},parseError:t(function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t)},"parseError"),parse:t(function(e){var n=this,i=[0],r=[],a=[null],s=[],o=this.table,l="",c=0,h=0,d=s.slice.call(arguments,1),u=Object.create(this.lexer),p={yy:{}};for(var g in this.yy)Object.prototype.hasOwnProperty.call(this.yy,g)&&(p.yy[g]=this.yy[g]);u.setInput(e,p.yy),p.yy.lexer=u,p.yy.parser=this,void 0===u.yylloc&&(u.yylloc={});var y=u.yylloc;s.push(y);var f=u.options&&u.options.ranges;function m(){var t;return"number"!=typeof(t=r.pop()||u.lex()||1)&&(t instanceof Array&&(t=(r=t).pop()),t=n.symbols_[t]||t),t}"function"==typeof p.yy.parseError?this.parseError=p.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,t(function(t){i.length=i.length-2*t,a.length=a.length-t,s.length=s.length-t},"popStack"),t(m,"lex");for(var x,b,k,w,_,v,$,S,E={};;){if(b=i[i.length-1],this.defaultActions[b]?k=this.defaultActions[b]:(null==x&&(x=m()),k=o[b]&&o[b][x]),void 0===k||!k.length||!k[0]){var T="";for(_ in S=[],o[b])this.terminals_[_]&&_>2&&S.push("'"+this.terminals_[_]+"'");T=u.showPosition?"Parse error on line "+(c+1)+":\n"+u.showPosition()+"\nExpecting "+S.join(", ")+", got '"+(this.terminals_[x]||x)+"'":"Parse error on line "+(c+1)+": Unexpected "+(1==x?"end of input":"'"+(this.terminals_[x]||x)+"'"),this.parseError(T,{text:u.match,token:this.terminals_[x]||x,line:u.yylineno,loc:y,expected:S})}if(k[0]instanceof Array&&k.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+x);switch(k[0]){case 1:i.push(x),a.push(u.yytext),s.push(u.yylloc),i.push(k[1]),x=null,h=u.yyleng,l=u.yytext,c=u.yylineno,y=u.yylloc;break;case 2:if(v=this.productions_[k[1]][1],E.$=a[a.length-v],E._$={first_line:s[s.length-(v||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-(v||1)].first_column,last_column:s[s.length-1].last_column},f&&(E._$.range=[s[s.length-(v||1)].range[0],s[s.length-1].range[1]]),void 0!==(w=this.performAction.apply(E,[l,h,c,p.yy,k[1],a,s].concat(d))))return w;v&&(i=i.slice(0,-1*v*2),a=a.slice(0,-1*v),s=s.slice(0,-1*v)),i.push(this.productions_[k[1]][0]),a.push(E.$),s.push(E._$),$=o[i[i.length-2]][i[i.length-1]],i.push($);break;case 3:return!0}}return!0},"parse")},d=function(){return{EOF:1,parseError:t(function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},"parseError"),setInput:t(function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:t(function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},"input"),unput:t(function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var i=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var r=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===i.length?this.yylloc.first_column:0)+i[i.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[r[0],r[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},"unput"),more:t(function(){return this._more=!0,this},"more"),reject:t(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:t(function(t){this.unput(this.match.slice(t))},"less"),pastInput:t(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:t(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:t(function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},"showPosition"),test_match:t(function(t,e){var n,i,r;if(this.options.backtrack_lexer&&(r={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(r.yylloc.range=this.yylloc.range.slice(0))),(i=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var a in r)this[a]=r[a];return!1}return!1},"test_match"),next:t(function(){if(this.done)return this.EOF;var t,e,n,i;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var r=this._currentRules(),a=0;a<r.length;a++)if((n=this._input.match(this.rules[r[a]]))&&(!e||n[0].length>e[0].length)){if(e=n,i=a,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,r[a])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,r[i]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:t(function(){var t=this.next();return t||this.lex()},"lex"),begin:t(function(t){this.conditionStack.push(t)},"begin"),popState:t(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:t(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:t(function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},"topState"),pushState:t(function(t){this.begin(t)},"pushState"),stateStackSize:t(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:t(function(t,e,n,i){switch(n){case 0:case 1:case 3:case 4:break;case 2:return 13;case 5:return 8;case 6:return 9;case 7:return 7;case 8:return 14;case 9:return this.begin("acc_title"),15;case 10:return this.popState(),"acc_title_value";case 11:return this.begin("acc_descr"),17;case 12:return this.popState(),"acc_descr_value";case 13:this.begin("acc_descr_multiline");break;case 14:this.popState();break;case 15:return"acc_descr_multiline_value";case 16:return 20;case 17:return 24;case 18:return 23;case 19:return 6;case 20:return"INVALID"}},"anonymous"),rules:[/^(?:%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:timeline[ \t]+LR\b)/i,/^(?:timeline[ \t]+TD\b)/i,/^(?:timeline\b)/i,/^(?:title\s[^\n]+)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:section\s[^:\n]+)/i,/^(?::\s(?:[^:\n]|:(?!\s))+)/i,/^(?:[^#:\n]+)/i,/^(?:$)/i,/^(?:.)/i],conditions:{acc_descr_multiline:{rules:[14,15],inclusive:!1},acc_descr:{rules:[12],inclusive:!1},acc_title:{rules:[10],inclusive:!1},INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,11,13,16,17,18,19,20],inclusive:!0}}}}();function u(){this.yy={}}return h.lexer=d,t(u,"Parser"),u.prototype=h,h.Parser=u,new u}();y.parser=y;var f=y,m={};d(m,{addEvent:()=>L,addSection:()=>I,addTask:()=>C,addTaskOrg:()=>N,clear:()=>S,default:()=>O,getCommonDb:()=>$,getDirection:()=>T,getSections:()=>M,getTasks:()=>H,setDirection:()=>E});var x="",b=0,k="LR",w=[],_=[],v=[],$=t(()=>u,"getCommonDb"),S=t(function(){w.length=0,_.length=0,x="",v.length=0,k="LR",p()},"clear"),E=t(function(t){k=t},"setDirection"),T=t(function(){return k},"getDirection"),I=t(function(t){x=t,w.push(t)},"addSection"),M=t(function(){return w},"getSections"),H=t(function(){let t=D();let e=0;for(;!t&&e<100;)t=D(),e++;return _.push(...v),_},"getTasks"),C=t(function(t,e,n){const i={id:b++,section:x,type:x,task:t,score:e||0,events:n?[n]:[]};v.push(i)},"addTask"),L=t(function(t){v.find(t=>t.id===b-1).events.push(t)},"addEvent"),N=t(function(t){const e={section:x,type:x,description:t,task:t,classes:[]};_.push(e)},"addTaskOrg"),D=t(function(){const e=t(function(t){return v[t].processed},"compileTask");let n=!0;for(const[t,i]of v.entries())e(t),n=n&&i.processed;return n},"compileTasks"),O={clear:S,getCommonDb:$,getDirection:T,setDirection:E,addSection:I,getSections:M,getTasks:H,addTask:C,addTaskOrg:N,addEvent:L},A=0,B=t(function(t,e){const n=t.append("rect");return n.attr("x",e.x),n.attr("y",e.y),n.attr("fill",e.fill),n.attr("stroke",e.stroke),n.attr("width",e.width),n.attr("height",e.height),n.attr("rx",e.rx),n.attr("ry",e.ry),void 0!==e.class&&n.attr("class",e.class),n},"drawRect"),R=t(function(e,n){const i=15,r=e.append("circle").attr("cx",n.cx).attr("cy",n.cy).attr("class","face").attr("r",i).attr("stroke-width",2).attr("overflow","visible"),a=e.append("g");function s(t){const e=g().startAngle(Math.PI/2).endAngle(Math.PI/2*3).innerRadius(7.5).outerRadius(i/2.2);t.append("path").attr("class","mouth").attr("d",e).attr("transform","translate("+n.cx+","+(n.cy+2)+")")}function o(t){const e=g().startAngle(3*Math.PI/2).endAngle(Math.PI/2*5).innerRadius(7.5).outerRadius(i/2.2);t.append("path").attr("class","mouth").attr("d",e).attr("transform","translate("+n.cx+","+(n.cy+7)+")")}function l(t){t.append("line").attr("class","mouth").attr("stroke",2).attr("x1",n.cx-5).attr("y1",n.cy+7).attr("x2",n.cx+5).attr("y2",n.cy+7).attr("class","mouth").attr("stroke-width","1px").attr("stroke","#666")}return a.append("circle").attr("cx",n.cx-5).attr("cy",n.cy-5).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666"),a.append("circle").attr("cx",n.cx+5).attr("cy",n.cy-5).attr("r",1.5).attr("stroke-width",2).attr("fill","#666").attr("stroke","#666"),t(s,"smile"),t(o,"sad"),t(l,"ambivalent"),n.score>3?s(a):n.score<3?o(a):l(a),r},"drawFace"),P=t(function(t,e){const n=t.append("circle");return n.attr("cx",e.cx),n.attr("cy",e.cy),n.attr("class","actor-"+e.pos),n.attr("fill",e.fill),n.attr("stroke",e.stroke),n.attr("r",e.r),void 0!==n.class&&n.attr("class",n.class),void 0!==e.title&&n.append("title").text(e.title),n},"drawCircle"),j=t(function(t,e){const n=e.text.replace(/<br\s*\/?>/gi," "),i=t.append("text");i.attr("x",e.x),i.attr("y",e.y),i.attr("class","legend"),i.style("text-anchor",e.anchor),void 0!==e.class&&i.attr("class",e.class);const r=i.append("tspan");return r.attr("x",e.x+2*e.textMargin),r.text(n),i},"drawText"),W=t(function(e,n){function i(t,e,n,i,r){return t+","+e+" "+(t+n)+","+e+" "+(t+n)+","+(e+i-r)+" "+(t+n-1.2*r)+","+(e+i)+" "+t+","+(e+i)}t(i,"genPoints");const r=e.append("polygon");r.attr("points",i(n.x,n.y,50,20,7)),r.attr("class","labelBox"),n.y=n.y+n.labelMargin,n.x=n.x+.5*n.labelMargin,j(e,n)},"drawLabel"),F=t(function(t,e,n){const i=t.append("g"),r=Z();r.x=e.x,r.y=e.y,r.fill=e.fill,r.width=n.width,r.height=n.height,r.class="journey-section section-type-"+e.num,r.rx=3,r.ry=3,B(i,r),q(n)(e.text,i,r.x,r.y,r.width,r.height,{class:"journey-section section-type-"+e.num},n,e.colour)},"drawSection"),z=-1,V=t(function(t,e,n,i){const r=e.x+n.width/2,a=t.append("g");z++;a.append("line").attr("id",i+"-task"+z).attr("x1",r).attr("y1",e.y).attr("x2",r).attr("y2",450).attr("class","task-line").attr("stroke-width","1px").attr("stroke-dasharray","4 2").attr("stroke","#666"),R(a,{cx:r,cy:300+30*(5-e.score),score:e.score});const s=Z();s.x=e.x,s.y=e.y,s.fill=e.fill,s.width=n.width,s.height=n.height,s.class="task task-type-"+e.num,s.rx=3,s.ry=3,B(a,s),q(n)(e.task,a,s.x,s.y,s.width,s.height,{class:"task"},n,e.colour)},"drawTask"),G=t(function(t,e){B(t,{x:e.startx,y:e.starty,width:e.stopx-e.startx,height:e.stopy-e.starty,fill:e.fill,class:"rect"}).lower()},"drawBackgroundRect"),U=t(function(){return{x:0,y:0,fill:void 0,"text-anchor":"start",width:100,height:100,textMargin:0,rx:0,ry:0}},"getTextObj"),Z=t(function(){return{x:0,y:0,width:100,anchor:"start",height:100,rx:0,ry:0}},"getNoteRect"),q=function(){function e(t,e,n,i,a,s,o,l){r(e.append("text").attr("x",n+a/2).attr("y",i+s/2+5).style("font-color",l).style("text-anchor","middle").text(t),o)}function n(t,e,n,i,a,s,o,l,c){const{taskFontSize:h,taskFontFamily:d}=l,u=t.split(/<br\s*\/?>/gi);for(let p=0;p<u.length;p++){const t=p*h-h*(u.length-1)/2,l=e.append("text").attr("x",n+a/2).attr("y",i).attr("fill",c).style("text-anchor","middle").style("font-size",h).style("font-family",d);l.append("tspan").attr("x",n+a/2).attr("dy",t).text(u[p]),l.attr("y",i+s/2).attr("dominant-baseline","central").attr("alignment-baseline","central"),r(l,o)}}function i(t,e,i,a,s,o,l,c){const h=e.append("switch"),d=h.append("foreignObject").attr("x",i).attr("y",a).attr("width",s).attr("height",o).attr("position","fixed").append("xhtml:div").style("display","table").style("height","100%").style("width","100%");d.append("div").attr("class","label").style("display","table-cell").style("text-align","center").style("vertical-align","middle").text(t),n(t,h,i,a,s,o,l,c),r(d,l)}function r(t,e){for(const n in e)n in e&&t.attr(n,e[n])}return t(e,"byText"),t(n,"byTspan"),t(i,"byFo"),t(r,"_setTextAttrs"),function(t){return"fo"===t.textPlacement?i:"old"===t.textPlacement?e:n}}(),Y=t(function(t,e){A=0,z=-1,t.append("defs").append("marker").attr("id",e+"-arrowhead").attr("refX",5).attr("refY",2).attr("markerWidth",6).attr("markerHeight",4).attr("orient","auto").append("path").attr("d","M 0,0 V 4 L6,2 Z")},"initGraphics");function K(t,e){t.each(function(){var t,n=h(this),i=n.text().split(/(\s+|<br>)/).reverse(),r=[],a=n.attr("y"),s=parseFloat(n.attr("dy")),o=n.text(null).append("tspan").attr("x",0).attr("y",a).attr("dy",s+"em");for(let l=0;l<i.length;l++)t=i[i.length-1-l],r.push(t),o.text(r.join(" ").trim()),(o.node().getComputedTextLength()>e||"<br>"===t)&&(r.pop(),o.text(r.join(" ").trim()),r="<br>"===t?[""]:[t],o=n.append("tspan").attr("x",0).attr("y",a).attr("dy","1.1em").text(t))})}t(K,"wrap");var X=t(function(t,e,n,i,r,a=!1){var s,o,l;const{theme:c,look:d}=i,u=null==c?void 0:c.includes("redux"),p=n%((null==(s=null==i?void 0:i.themeVariables)?void 0:s.THEME_COLOR_LIMIT)??12)-1,g=t.append("g");e.section=p,g.attr("class",(e.class?e.class+" ":"")+"timeline-node section-"+p);const y=g.append("g"),f=g.append("g"),m=f.append("text").text(e.descr).attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle").call(K,e.width).node().getBBox(),x=(null==(o=i.fontSize)?void 0:o.replace)?i.fontSize.replace("px",""):i.fontSize;if(e.height=m.height+1.1*x*.5+e.padding,e.height=Math.max(e.height,e.maxHeight),e.width=e.width+2*e.padding,f.attr("transform","translate("+e.width/2+", "+e.padding/2+")"),u&&f.attr("transform",`translate(${e.width/2}, ${a?e.padding/2+3:e.padding})`),Q(y,e,p,r,i),"neo"===d&&(g.attr("data-look","neo"),u)){const e=c.includes("dark"),n=(null==(l=t.node())?void 0:l.ownerSVGElement)??t.node(),i=h(n),r=i.attr("id")??"",a=r?`${r}-drop-shadow`:"drop-shadow";if(i.select(`#${a}`).empty()){const t=i.select("defs");(t.empty()?i.append("defs"):t).append("filter").attr("id",a).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity",e?"0.2":"0.06").attr("flood-color",e?"#FFFFFF":"#000000")}}return e},"drawNode"),J=t(function(t,e,n){var i;const r=t.append("g"),a=r.append("text").text(e.descr).attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle").call(K,e.width).node().getBBox(),s=(null==(i=n.fontSize)?void 0:i.replace)?n.fontSize.replace("px",""):n.fontSize;return r.remove(),a.height+1.1*s*.5+e.padding},"getVirtualNodeHeight"),Q=t(function(t,e,n,i,r){const{theme:a}=r,s=(null==a?void 0:a.includes("redux"))?0:5,o=s>0?`M0 ${e.height-5} v${10-e.height} q0,-${s},${s},-${s} h${e.width-10} q${s},0,${s},${s} v${e.height-5} H0 Z`:`M0 ${e.height-5} v${-(e.height-5)} h${e.width} v${e.height} H0 Z`;t.append("path").attr("id",i+"-node-"+A++).attr("class","node-bkg node-"+e.type).attr("d",o),(null==a?void 0:a.includes("redux"))||t.append("line").attr("class","node-line-"+n).attr("x1",0).attr("y1",e.height).attr("x2",e.width).attr("y2",e.height)},"defaultBkg"),tt={drawRect:B,drawCircle:P,drawSection:F,drawText:j,drawLabel:W,drawTask:V,drawBackgroundRect:G,getTextObj:U,getNoteRect:Z,initGraphics:Y,drawNode:X,getVirtualNodeHeight:J},et=t(function(t,e,n,i){var r,o,l;const d=a(),{look:u,theme:p,themeVariables:g}=d,{useGradient:y,gradientStart:f,gradientStop:m}=g,x=(null==(r=d.timeline)?void 0:r.leftMargin)??50;s.debug("timeline",i.db);const b=d.securityLevel;let k;"sandbox"===b&&(k=h("#i"+e));const w=h("sandbox"===b?k.nodes()[0].contentDocument.body:"body").select("#"+e);w.append("g");const _=i.db.getTasks(),v=i.db.getCommonDb().getDiagramTitle();s.debug("task",_),tt.initGraphics(w,e);const $=i.db.getSections();s.debug("sections",$);let S=0,E=0,T=0,I=0,M=50+x,H=50;I=50;let C=0,L=!0;$.forEach(function(t){const e={number:C,descr:t,section:C,width:150,padding:20,maxHeight:S},n=tt.getVirtualNodeHeight(w,e,d);s.debug("sectionHeight before draw",n),S=Math.max(S,n+20)});let N=0,D=0;s.debug("tasks.length",_.length);for(const[a,c]of _.entries()){const t={number:a,descr:c,section:c.section,width:150,padding:20,maxHeight:E},e=tt.getVirtualNodeHeight(w,t,d);s.debug("taskHeight before draw",e),E=Math.max(E,e+20),N=Math.max(N,c.events.length);let n=0;for(const i of c.events){const t={descr:i,section:c.section,number:c.section,width:150,padding:20,maxHeight:50};n+=tt.getVirtualNodeHeight(w,t,d)}c.events.length>0&&(n+=10*(c.events.length-1)),D=Math.max(D,n)}s.debug("maxSectionHeight before draw",S),s.debug("maxTaskHeight before draw",E),$&&$.length>0?$.forEach(t=>{const n=_.filter(e=>e.section===t),i={number:C,descr:t,section:C,width:200*Math.max(n.length,1)-50,padding:20,maxHeight:S};s.debug("sectionNode",i);const r=w.append("g"),a=tt.drawNode(r,i,C,d,e);s.debug("sectionNode output",a),r.attr("transform",`translate(${M}, 50)`),H+=S+50,n.length>0&&nt(w,n,C,M,H,E,d,N,D,S,!1,e),M+=200*Math.max(n.length,1),H=50,C++}):(L=!1,nt(w,_,C,M,H,E,d,N,D,S,!0,e));const O=w.node().getBBox();s.debug("bounds",O),v&&w.append("text").text(v).attr("x","neo"===u?2*O.x+x:O.width/2-x).attr("font-size","4ex").attr("font-weight","bold").attr("y",20),T=L?S+E+150:E+100;if(w.append("g").attr("class","lineWrapper").append("line").attr("x1",x).attr("y1",T).attr("x2",O.width+3*x).attr("y2",T).attr("stroke-width",4).attr("stroke","black").attr("marker-end",`url(#${e}-arrowhead)`),"neo"===u&&y&&"neutral"!==p){const t=w.select("defs"),e=(t.empty()?w.append("defs"):t).append("linearGradient").attr("id",w.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");e.append("stop").attr("offset","0%").attr("stop-color",f).attr("stop-opacity",1),e.append("stop").attr("offset","100%").attr("stop-color",m).attr("stop-opacity",1)}c(void 0,w,(null==(o=d.timeline)?void 0:o.padding)??50,(null==(l=d.timeline)?void 0:l.useMaxWidth)??!1)},"draw"),nt=t(function(t,e,n,i,r,a,o,l,c,h,d,u){var p;for(const g of e){const e={descr:g.task,section:n,number:n,width:150,padding:20,maxHeight:a};s.debug("taskNode",e);const l=t.append("g").attr("class","taskWrapper"),h=tt.drawNode(l,e,n,o,u).height;if(s.debug("taskHeight after draw",h),l.attr("transform",`translate(${i}, ${r})`),a=Math.max(a,h),g.events){const e=t.append("g").attr("class","lineWrapper");let s=a;r+=100,s+=it(t,g.events,n,i,r,o,u),r-=100,e.append("line").attr("x1",i+95).attr("y1",r+a).attr("x2",i+95).attr("y2",r+a+100+c+100).attr("stroke-width",2).attr("stroke","black").attr("marker-end",`url(#${u}-arrowhead)`).attr("stroke-dasharray","5,5")}i+=200,d&&!(null==(p=o.timeline)?void 0:p.disableMulticolor)&&n++}r-=10},"drawTasks"),it=t(function(t,e,n,i,r,a,o){let l=0;const c=r;r+=100;for(const h of e){const e={descr:h,section:n,number:n,width:150,padding:20,maxHeight:50};s.debug("eventNode",e);const c=t.append("g").attr("class","eventWrapper"),d=tt.drawNode(c,e,n,a,o,!0).height;l+=d,c.attr("transform",`translate(${i}, ${r})`),r=r+10+d}return r=c,l},"drawEvents"),rt={setConf:t(()=>{},"setConf"),draw:et},at=200,st=t(function(t,e,n,i){var r,h,d,u,p;const g=a(),y=(null==(r=g.timeline)?void 0:r.leftMargin)??50;s.debug("timeline",i.db);const f=o(e);f.append("g");const m=i.db.getTasks(),x=i.db.getCommonDb().getDiagramTitle();s.debug("task",m),tt.initGraphics(f);const b=i.db.getSections();s.debug("sections",b);let k=0,w=0;const _=50+y;let v=50;const $=v,S=230,E=_+S;let T=0;const I=b&&b.length>0,M=I?E:_+S,H=Math.max(50,580);b.forEach(function(t){const e={number:T,descr:t,section:T,width:H,padding:5,maxHeight:k},n=tt.getVirtualNodeHeight(f,e,g);s.debug("sectionHeight before draw",n),k=Math.max(k,n)});let C=0;s.debug("tasks.length",m.length);for(const[a,o]of m.entries()){const t={number:a,descr:o,section:o.section,width:at,padding:5,maxHeight:w},e=tt.getVirtualNodeHeight(f,t,g);s.debug("taskHeight before draw",e),w=Math.max(w,e);let n=0;for(const i of o.events){const t={descr:i,section:o.section,number:o.section,width:300,padding:5,maxHeight:50};n+=tt.getVirtualNodeHeight(f,t,g)}o.events.length>0&&(n+=10*(o.events.length-1)),C=Math.max(C,n)+0}s.debug("maxSectionHeight before draw",k),s.debug("maxTaskHeight before draw",w);const L=Math.max(w,C)+30;I?b.forEach(t=>{const e=m.filter(e=>e.section===t),n={number:T,descr:t,section:T,width:H,padding:5,maxHeight:k};s.debug("sectionNode",n);const i=f.append("g"),r=tt.drawNode(i,n,T,g);s.debug("sectionNode output",r);const a=M-S;i.attr("transform",`translate(${a}, ${v})`);const o=v+r.height+20;e.length>0&&ot(f,e,T,M,o,w,g,L,!1);const l=e.length,c=r.height+20+L*Math.max(l,1)-(l>0?60:0);v+=c,T++}):ot(f,m,T,M,v,w,g,L,!0);let N=null==(h=f.node())?void 0:h.getBBox();if(!N)throw new Error("bbox not found");if(s.debug("bounds",N),x){if(f.append("text").text(x).attr("x",N.width/2-y).attr("font-size","4ex").attr("font-weight","bold").attr("y",20),N=null==(d=f.node())?void 0:d.getBBox(),!N)throw new Error("bbox not found");s.debug("bounds after title",N)}const[D]=l(g.fontSize),O=2*(D??16),A=.5*(D??16)+20,B=f.append("g").attr("class","lineWrapper");B.append("line").attr("x1",M).attr("y1",$-O).attr("x2",M).attr("y2",N.y+N.height+A).attr("stroke-width",4).attr("stroke","black").attr("marker-end","url(#arrowhead)"),B.lower(),c(void 0,f,(null==(u=g.timeline)?void 0:u.padding)??50,(null==(p=g.timeline)?void 0:p.useMaxWidth)??!1)},"draw"),ot=t(function(t,e,n,i,r,a,o,l,c){var h;for(const d of e){const e={descr:d.task,section:n,number:n,width:at,padding:5,maxHeight:a};s.debug("taskNode",e);const u=t.append("g").attr("class","taskWrapper"),p=tt.drawNode(u,e,n,o),g=p.height;s.debug("taskHeight after draw",g);const y=i-20-p.width;if(u.attr("transform",`translate(${y}, ${r})`),a=Math.max(a,g),d.events&&d.events.length>0){const e=r,a=i+50;lt(t,d.events,n,i,a,e,o)}r+=l,c&&!(null==(h=o.timeline)?void 0:h.disableMulticolor)&&n++}},"drawTasks"),lt=t(function(t,e,n,i,r,a,o){let l=a;for(const c of e){const e={descr:c,section:n,number:n,width:300,padding:5,maxHeight:0};s.debug("eventNode",e);const a=t.append("g").attr("class","eventWrapper"),h=tt.drawNode(a,e,n,o).height;a.attr("transform",`translate(${r}, ${l})`);const d=l+h/2;t.append("g").attr("class","lineWrapper").append("line").attr("x1",i).attr("y1",d).attr("x2",r).attr("y2",d).attr("stroke-width",2).attr("stroke","black").attr("marker-end","url(#arrowhead)").attr("stroke-dasharray","5,5"),l=l+h+10}return l-a},"drawEvents"),ct={setConf:t(()=>{},"setConf"),draw:st},ht=t(t=>{var n;const{theme:i}=e(),r=null==i?void 0:i.includes("dark"),a=null==i?void 0:i.includes("color"),s=(null==(n=t.svgId)?void 0:n.replace(/^#/,""))??"",o=s?`url(#${s}-drop-shadow)`:t.dropShadow??"none";let l="";for(let e=0;e<t.THEME_COLOR_LIMIT;e++){const n=""+(17-3*e),i=a?t.borderColorArray[e]:t.mainBkg,s=a?t.borderColorArray[e]:t.nodeBorder;l+=`\n .section-${e-1} rect,\n .section-${e-1} path,\n .section-${e-1} circle {\n fill: ${r&&a?t.mainBkg:i};\n stroke: ${s};\n stroke-width: ${t.strokeWidth};\n filter: ${o};\n }\n\n .section-${e-1} text {\n fill: ${t.nodeBorder};\n font-weight: ${t.fontWeight}\n }\n\n .node-icon-${e-1} {\n font-size: 40px;\n color: ${t["cScaleLabel"+e]};\n }\n\n .section-edge-${e-1} {\n stroke: ${t["cScale"+e]};\n }\n\n .edge-depth-${e-1} {\n stroke-width: ${n};\n }\n\n .section-${e-1} line {\n stroke: ${t["cScaleInv"+e]};\n stroke-width: 3;\n }\n\n .lineWrapper line {\n stroke: ${t.nodeBorder};\n stroke-width:${t.strokeWidth}\n }\n\n .disabled,\n .disabled circle,\n .disabled text {\n fill: ${t.tertiaryColor??"lightgray"};\n }\n\n .disabled text {\n fill: ${t.clusterBorder??"#efefef"};\n }\n `}return l},"genReduxSections"),dt=t(t=>{let e="";for(let a=0;a<t.THEME_COLOR_LIMIT;a++)t["lineColor"+a]=t["lineColor"+a]||t["cScaleInv"+a],n(t["lineColor"+a])?t["lineColor"+a]=i(t["lineColor"+a],20):t["lineColor"+a]=r(t["lineColor"+a],20);for(let n=0;n<t.THEME_COLOR_LIMIT;n++){const i=""+(17-3*n);e+=`\n .section-${n-1} rect, .section-${n-1} path, .section-${n-1} circle, .section-${n-1} path {\n fill: ${t["cScale"+n]};\n }\n .section-${n-1} text {\n fill: ${t["cScaleLabel"+n]};\n }\n .node-icon-${n-1} {\n font-size: 40px;\n color: ${t["cScaleLabel"+n]};\n }\n .section-edge-${n-1}{\n stroke: ${t["cScale"+n]};\n }\n .edge-depth-${n-1}{\n stroke-width: ${i};\n }\n .section-${n-1} line {\n stroke: ${t["cScaleInv"+n]} ;\n stroke-width: 3;\n }\n\n .lineWrapper line{\n stroke: ${t["cScaleLabel"+n]} ;\n }\n\n .disabled, .disabled circle, .disabled text {\n fill: ${t.tertiaryColor??"lightgray"};\n }\n .disabled text {\n fill: ${t.clusterBorder??"#efefef"};\n }\n `}return e},"genSections"),ut=t(t=>{var n;const{theme:i}=e(),r=null==i?void 0:i.includes("redux"),a="neutral"===i,s=(null==(n=t.svgId)?void 0:n.replace(/^#/,""))??"";let o="";if(t.useGradient&&s&&t.THEME_COLOR_LIMIT&&!a)for(let e=0;e<t.THEME_COLOR_LIMIT;e++)o+=`\n .section-${e-1}[data-look="neo"] rect,\n .section-${e-1}[data-look="neo"] path,\n .section-${e-1}[data-look="neo"] circle {\n fill: ${t.mainBkg};\n stroke: url(#${s}-gradient);\n stroke-width: 2;\n }\n .section-${e-1}[data-look="neo"] line {\n stroke: url(#${s}-gradient);\n stroke-width: 2;\n }`;return`\n .edge {\n stroke-width: 3;\n }\n ${r?ht(t):dt(t)}\n ${o}\n .section-root rect, .section-root path, .section-root circle {\n fill: ${t.git0};\n }\n .section-root text {\n fill: ${t.gitBranchLabel0};\n }\n .icon-container {\n height:100%;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .edge {\n fill: none;\n }\n .eventWrapper {\n filter: brightness(120%);\n }\n`},"getStyles"),pt={db:m,renderer:{setConf:t(()=>{},"setConf"),draw:t((t,e,n,i)=>{var r,a;return"TD"===((null==(a=null==(r=null==i?void 0:i.db)?void 0:r.getDirection)?void 0:a.call(r))??"LR")?ct.draw(t,e,n,i):rt.draw(t,e,n,i)},"draw")},parser:f,styles:ut};export{pt as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b3 as t,s as e,g as n,o as s,n as i,a as r,b as o,_ as a,y as l,D as c,d as h,ak as u,S as f,T as d,U as y,e as g,p as x,A as p,B as m}from"./mermaid.core-vavDl7Vc.js";import"./index-i_5HmRyk.js";const v=(e,n)=>t(e,"a",-n),b=1e-10;function I(t,e){const n=function(t){const e=[];for(let n=0;n<t.length;++n)for(let s=n+1;s<t.length;++s){const i=_(t[n],t[s]);for(const t of i)t.parentIndex=[n,s],e.push(t)}return e}(t),s=n.filter(e=>function(t,e){return e.every(e=>k(t,e)<e.radius+b)}(e,t));let i=0,r=0;const o=[];if(s.length>1){const e=S(s);for(let t=0;t<s.length;++t){const n=s[t];n.angle=Math.atan2(n.x-e.x,n.y-e.y)}s.sort((t,e)=>e.angle-t.angle);let n=s[s.length-1];for(let a=0;a<s.length;++a){const e=s[a];r+=(n.x+e.x)*(e.y-n.y);const l={x:(e.x+n.x)/2,y:(e.y+n.y)/2};let c=null;for(let s=0;s<e.parentIndex.length;++s)if(n.parentIndex.includes(e.parentIndex[s])){const i=t[e.parentIndex[s]],r=Math.atan2(e.x-i.x,e.y-i.y),o=Math.atan2(n.x-i.x,n.y-i.y);let a=o-r;a<0&&(a+=2*Math.PI);const h=o-a/2;let u=k(l,{x:i.x+i.radius*Math.sin(h),y:i.y+i.radius*Math.cos(h)});u>2*i.radius&&(u=2*i.radius),(null==c||c.width>u)&&(c={circle:i,width:u,p1:e,p2:n,large:u>i.radius,sweep:!0})}null!=c&&(o.push(c),i+=M(c.circle.radius,c.width),n=e)}}else{let e=t[0];for(let s=1;s<t.length;++s)t[s].radius<e.radius&&(e=t[s]);let n=!1;for(let s=0;s<t.length;++s)if(k(t[s],e)>Math.abs(e.radius-t[s].radius)){n=!0;break}n?i=r=0:(i=e.radius*e.radius*Math.PI,o.push({circle:e,p1:{x:e.x,y:e.y+e.radius},p2:{x:e.x-b,y:e.y+e.radius},width:2*e.radius,large:!0,sweep:!0}))}return r/=2,e&&(e.area=i+r,e.arcArea=i,e.polygonArea=r,e.arcs=o,e.innerPoints=s,e.intersectionPoints=n),i+r}function M(t,e){return t*t*Math.acos(1-e/t)-(t-e)*Math.sqrt(e*(2*t-e))}function k(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function w(t,e,n){if(n>=t+e)return 0;if(n<=Math.abs(t-e))return Math.PI*Math.min(t,e)*Math.min(t,e);const s=e-(n*n-t*t+e*e)/(2*n);return M(t,t-(n*n-e*e+t*t)/(2*n))+M(e,s)}function _(t,e){const n=k(t,e),s=t.radius,i=e.radius;if(n>=s+i||n<=Math.abs(s-i))return[];const r=(s*s-i*i+n*n)/(2*n),o=Math.sqrt(s*s-r*r),a=t.x+r*(e.x-t.x)/n,l=t.y+r*(e.y-t.y)/n,c=-(e.y-t.y)*(o/n),h=-(e.x-t.x)*(o/n);return[{x:a+c,y:l-h},{x:a-c,y:l+h}]}function S(t){const e={x:0,y:0};for(const n of t)e.x+=n.x,e.y+=n.y;return e.x/=t.length,e.y/=t.length,e}function E(t){const e=new Array(t);for(let n=0;n<t;++n)e[n]=0;return e}function T(t,e){return E(t).map(()=>E(e))}function z(t,e){let n=0;for(let s=0;s<t.length;++s)n+=t[s]*e[s];return n}function A(t){return Math.sqrt(z(t,t))}function R(t,e,n){for(let s=0;s<e.length;++s)t[s]=e[s]*n}function D(t,e,n,s,i){for(let r=0;r<t.length;++r)t[r]=e*n[r]+s*i[r]}function N(t,e,n){const s=(n=n||{}).maxIterations||200*e.length,i=n.nonZeroDelta||1.05,r=n.zeroDelta||.001,o=n.minErrorDelta||1e-6,a=n.minErrorDelta||1e-5,l=void 0!==n.rho?n.rho:1,c=void 0!==n.chi?n.chi:2,h=void 0!==n.psi?n.psi:-.5,u=void 0!==n.sigma?n.sigma:.5;let f;const d=e.length,y=new Array(d+1);y[0]=e,y[0].fx=t(e),y[0].id=0;for(let I=0;I<d;++I){const n=e.slice();n[I]=n[I]?n[I]*i:r,y[I+1]=n,y[I+1].fx=t(n),y[I+1].id=I+1}function g(t){for(let e=0;e<t.length;e++)y[d][e]=t[e];y[d].fx=t.fx}const x=(t,e)=>t.fx-e.fx,p=e.slice(),m=e.slice(),v=e.slice(),b=e.slice();for(let I=0;I<s;++I){if(y.sort(x),n.history){const t=y.map(t=>{const e=t.slice();return e.fx=t.fx,e.id=t.id,e});t.sort((t,e)=>t.id-e.id),n.history.push({x:y[0].slice(),fx:y[0].fx,simplex:t})}f=0;for(let t=0;t<d;++t)f=Math.max(f,Math.abs(y[0][t]-y[1][t]));if(Math.abs(y[0].fx-y[d].fx)<o&&f<a)break;for(let t=0;t<d;++t){p[t]=0;for(let e=0;e<d;++e)p[t]+=y[e][t];p[t]/=d}const e=y[d];if(D(m,1+l,p,-l,e),m.fx=t(m),m.fx<y[0].fx)D(b,1+c,p,-c,e),b.fx=t(b),b.fx<m.fx?g(b):g(m);else if(m.fx>=y[d-1].fx){let n=!1;if(m.fx>e.fx?(D(v,1+h,p,-h,e),v.fx=t(v),v.fx<e.fx?g(v):n=!0):(D(v,1-h*l,p,h*l,e),v.fx=t(v),v.fx<m.fx?g(v):n=!0),n){if(u>=1)break;for(let e=1;e<y.length;++e)D(y[e],1-u,y[0],u,y[e]),y[e].fx=t(y[e])}}else g(m)}return y.sort(x),{fx:y[0].fx,x:y[0]}}function O(t,e,n,s,i,r,o){const a=n.fx,l=z(n.fxprime,e);let c=a,h=a,u=l,f=0;function d(h,f,d){for(let y=0;y<16;++y)if(i=(h+f)/2,D(s.x,1,n.x,i,e),c=s.fx=t(s.x,s.fxprime),u=z(s.fxprime,e),c>a+r*i*l||c>=d)f=i;else{if(Math.abs(u)<=-o*l)return i;u*(f-h)>=0&&(f=h),h=i,d=c}return 0}i=i||1,r=r||1e-6,o=o||.1;for(let y=0;y<10;++y){if(D(s.x,1,n.x,i,e),c=s.fx=t(s.x,s.fxprime),u=z(s.fxprime,e),c>a+r*i*l||y&&c>=h)return d(f,i,h);if(Math.abs(u)<=-o*l)return i;if(u>=0)return d(i,f,c);h=c,f=i,i*=2}return i}function C(t,e,n){let s={x:e.slice(),fx:0,fxprime:e.slice()},i={x:e.slice(),fx:0,fxprime:e.slice()};const r=e.slice();let o,a,l,c=1;l=(n=n||{}).maxIterations||20*e.length,s.fx=t(s.x,s.fxprime),o=s.fxprime.slice(),R(o,s.fxprime,-1);for(let h=0;h<l;++h){if(c=O(t,o,s,i,c),n.history&&n.history.push({x:s.x.slice(),fx:s.fx,fxprime:s.fxprime.slice(),alpha:c}),c){D(r,1,i.fxprime,-1,s.fxprime);const t=z(s.fxprime,s.fxprime);D(o,Math.max(0,z(r,i.fxprime)/t),o,-1,i.fxprime),a=s,s=i,i=a}else R(o,s.fxprime,-1);if(A(s.fxprime)<=1e-5)break}return n.history&&n.history.push({x:s.x.slice(),fx:s.fx,fxprime:s.fxprime.slice(),alpha:c}),s}function F(t,e={}){e.maxIterations=e.maxIterations||500;const n=e.initialLayout||P,s=e.lossFunction||L,i=function(t,e={}){const n=e.distinct,s=t.map(t=>Object.assign({},t));function i(t){return t.join(";")}if(n){const t=new Map;for(const e of s)for(let n=0;n<e.sets.length;n++){const s=String(e.sets[n]);t.set(s,e.size+(t.get(s)||0));for(let i=n+1;i<e.sets.length;i++){const n=String(e.sets[i]),r=`${s};${n}`,o=`${n};${s}`;t.set(r,e.size+(t.get(r)||0)),t.set(o,e.size+(t.get(o)||0))}}for(const e of s)e.sets.length<3&&(e.size=t.get(i(e.sets)))}const r=[],o=new Set;for(const a of s)if(1===a.sets.length)r.push(a.sets[0]);else if(2===a.sets.length){const t=a.sets[0],e=a.sets[1];o.add(i(a.sets)),o.add(i([e,t]))}r.sort((t,e)=>t===e?0:t<e?-1:1);for(let a=0;a<r.length;++a){const t=r[a];for(let e=a+1;e<r.length;++e){const n=r[e];o.has(i([t,n]))||s.push({sets:[t,n],size:0})}}return s}(t,e),r=n(i,e),o=Object.keys(r),a=[];for(const c of o)a.push(r[c].x),a.push(r[c].y);const l=N(t=>{const e={};for(let n=0;n<o.length;++n){const s=o[n];e[s]={x:t[2*n],y:t[2*n+1],radius:r[s].radius}}return s(e,i)},a,e).x;for(let c=0;c<o.length;++c){const t=o[c];r[t].x=l[2*c],r[t].y=l[2*c+1]}return r}const $=1e-10;function j(t,e,n){return Math.min(t,e)*Math.min(t,e)*Math.PI<=n+$?Math.abs(t-e):function(t,e,n,s){const i=(s=s||{}).maxIterations||100,r=s.tolerance||1e-10,o=t(e),a=t(n);let l=n-e;if(o*a>0)throw"Initial bisect points must have opposite signs";if(0===o)return e;if(0===a)return n;for(let c=0;c<i;++c){l/=2;const n=e+l,s=t(n);if(s*o>=0&&(e=n),Math.abs(l)<r||0===s)return n}return e+l}(s=>w(t,e,s)-n,0,t+e)}function P(t,e={}){let n=function(t,e){const n=e&&e.lossFunction?e.lossFunction:L,s={},i={};for(const u of t)if(1===u.sets.length){const t=u.sets[0];s[t]={x:1e10,y:1e10,rowid:s.length,size:u.size,radius:Math.sqrt(u.size/Math.PI)},i[t]=[]}t=t.filter(t=>2===t.sets.length);for(const u of t){let t=null!=u.weight?u.weight:1;const e=u.sets[0],n=u.sets[1];u.size+$>=Math.min(s[e].size,s[n].size)&&(t=0),i[e].push({set:n,size:u.size,weight:t}),i[n].push({set:e,size:u.size,weight:t})}const r=[];function o(t,e){return e.size-t.size}Object.keys(i).forEach(t=>{let e=0;for(let n=0;n<i[t].length;++n)e+=i[t][n].size*i[t][n].weight;r.push({set:t,size:e})}),r.sort(o);const a={};function l(t){return t.set in a}function c(t,e){s[e].x=t.x,s[e].y=t.y,a[e]=!0}c({x:0,y:0},r[0].set);for(let u=1;u<r.length;++u){const e=r[u].set,a=i[e].filter(l),f=s[e];if(a.sort(o),0===a.length)throw"ERROR: missing pairwise overlap information";const d=[];for(var h=0;h<a.length;++h){const t=s[a[h].set],e=j(f.radius,t.radius,a[h].size);d.push({x:t.x+e,y:t.y}),d.push({x:t.x-e,y:t.y}),d.push({y:t.y+e,x:t.x}),d.push({y:t.y-e,x:t.x});for(let n=h+1;n<a.length;++n){const i=s[a[n].set],r=j(f.radius,i.radius,a[n].size),o=_({x:t.x,y:t.y,radius:e},{x:i.x,y:i.y,radius:r});d.push(...o)}}let y=1e50,g=d[0];for(const i of d){s[e].x=i.x,s[e].y=i.y;const r=n(s,t);r<y&&(y=r,g=i)}c(g,e)}return s}(t,e);const s=e.lossFunction||L;if(t.length>=8){const i=function(t,e={}){const n=e.restarts||10,s=[],i={};for(const f of t)1===f.sets.length&&(i[f.sets[0]]=s.length,s.push(f));let{distances:r,constraints:o}=function(t,e,n){const s=T(e.length,e.length),i=T(e.length,e.length);return t.filter(t=>2===t.sets.length).forEach(t=>{const r=n[t.sets[0]],o=n[t.sets[1]],a=j(Math.sqrt(e[r].size/Math.PI),Math.sqrt(e[o].size/Math.PI),t.size);s[r][o]=s[o][r]=a;let l=0;t.size+1e-10>=Math.min(e[r].size,e[o].size)?l=1:t.size<=1e-10&&(l=-1),i[r][o]=i[o][r]=l}),{distances:s,constraints:i}}(t,s,i);const a=A(r.map(A))/r.length;r=r.map(t=>t.map(t=>t/a));const l=(t,e)=>function(t,e,n,s){for(let r=0;r<e.length;++r)e[r]=0;let i=0;for(let r=0;r<n.length;++r){const o=t[2*r],a=t[2*r+1];for(let l=r+1;l<n.length;++l){const c=t[2*l],h=t[2*l+1],u=n[r][l],f=s[r][l],d=(c-o)*(c-o)+(h-a)*(h-a),y=Math.sqrt(d),g=d-u*u;f>0&&y<=u||f<0&&y>=u||(i+=2*g*g,e[2*r]+=4*g*(o-c),e[2*r+1]+=4*g*(a-h),e[2*l]+=4*g*(c-o),e[2*l+1]+=4*g*(h-a))}}return i}(t,e,r,o);let c=null;for(let f=0;f<n;++f){const t=C(l,E(2*r.length).map(Math.random),e);(!c||t.fx<c.fx)&&(c=t)}const h=c.x,u={};for(let f=0;f<s.length;++f){const t=s[f];u[t.sets[0]]={x:h[2*f]*a,y:h[2*f+1]*a,radius:Math.sqrt(t.size/Math.PI)}}if(e.history)for(const f of e.history)R(f.x,a);return u}(t,e);s(i,t)+1e-8<s(n,t)&&(n=i)}return n}function L(t,e){let n=0;for(const s of e){if(1===s.sets.length)continue;let e;if(2===s.sets.length){const n=t[s.sets[0]],i=t[s.sets[1]];e=w(n.radius,i.radius,k(n,i))}else e=I(s.sets.map(e=>t[e]));n+=(null!=s.weight?s.weight:1)*(e-s.size)*(e-s.size)}return n}function U(t,e){let n=0;for(const s of e){if(1===s.sets.length)continue;let e;if(2===s.sets.length){const n=t[s.sets[0]],i=t[s.sets[1]];e=w(n.radius,i.radius,k(n,i))}else e=I(s.sets.map(e=>t[e]));const i=null!=s.weight?s.weight:1,r=Math.log((e+1)/(s.size+1));n+=i*r*r}return n}function q(t,e,n){if(null==n?t.sort((t,e)=>e.radius-t.radius):t.sort(n),t.length>0){const e=t[0].x,n=t[0].y;for(const s of t)s.x-=e,s.y-=n}if(2===t.length){k(t[0],t[1])<Math.abs(t[1].radius-t[0].radius)&&(t[1].x=t[0].x+t[0].radius-t[1].radius-1e-10,t[1].y=t[0].y)}if(t.length>1){const n=Math.atan2(t[1].x,t[1].y)-e,s=Math.cos(n),i=Math.sin(n);for(const e of t){const t=e.x,n=e.y;e.x=s*t-i*n,e.y=i*t+s*n}}if(t.length>2){let n=Math.atan2(t[2].x,t[2].y)-e;for(;n<0;)n+=2*Math.PI;for(;n>2*Math.PI;)n-=2*Math.PI;if(n>Math.PI){const e=t[1].y/(1e-10+t[1].x);for(const n of t){var s=(n.x+e*n.y)/(1+e*e);n.x=2*s-n.x,n.y=2*s*e-n.y}}}}function B(t){const e=e=>({max:t.reduce((t,n)=>Math.max(t,n[e]+n.radius),Number.NEGATIVE_INFINITY),min:t.reduce((t,n)=>Math.min(t,n[e]-n.radius),Number.POSITIVE_INFINITY)});return{xRange:e("x"),yRange:e("y")}}function G(t,e,n){null==e&&(e=Math.PI/2);let s=X(t).map(t=>Object.assign({},t));const i=function(t){function e(t){return t.parent!==t&&(t.parent=e(t.parent)),t.parent}function n(t,n){const s=e(t),i=e(n);s.parent=i}t.forEach(t=>{t.parent=t});for(let i=0;i<t.length;++i)for(let e=i+1;e<t.length;++e){const s=t[i].radius+t[e].radius;k(t[i],t[e])+1e-10<s&&n(t[e],t[i])}const s=new Map;for(let i=0;i<t.length;++i){const n=e(t[i]).parent.setid;s.has(n)||s.set(n,[]),s.get(n).push(t[i])}return t.forEach(t=>{delete t.parent}),Array.from(s.values())}(s);for(const c of i){q(c,e,n);const t=B(c);c.size=(t.xRange.max-t.xRange.min)*(t.yRange.max-t.yRange.min),c.bounds=t}i.sort((t,e)=>e.size-t.size),s=i[0];let r=s.bounds;const o=(r.xRange.max-r.xRange.min)/50;function a(t,e,n){if(!t)return;const i=t.bounds;let a,l;if(e)a=r.xRange.max-i.xRange.min+o;else{a=r.xRange.max-i.xRange.max;const t=(i.xRange.max-i.xRange.min)/2-(r.xRange.max-r.xRange.min)/2;t<0&&(a+=t)}if(n)l=r.yRange.max-i.yRange.min+o;else{l=r.yRange.max-i.yRange.max;const t=(i.yRange.max-i.yRange.min)/2-(r.yRange.max-r.yRange.min)/2;t<0&&(l+=t)}for(const r of t)r.x+=a,r.y+=l,s.push(r)}let l=1;for(;l<i.length;)a(i[l],!0,!1),a(i[l+1],!1,!0),a(i[l+2],!0,!0),l+=3,r=B(s);return W(s)}function V(t,e,n,s,i){const r=X(t);e-=2*s,n-=2*s;const{xRange:o,yRange:a}=B(r);if(o.max===o.min||a.max===a.min)return t;let l,c;if(i){const t=2*Math.sqrt(i/Math.PI);l=e/t,c=n/t}else l=e/(o.max-o.min),c=n/(a.max-a.min);const h=Math.min(c,l),u=(e-(o.max-o.min)*h)/2,f=(n-(a.max-a.min)*h)/2;return W(r.map(t=>({radius:h*t.radius,x:s+u+(t.x-o.min)*h,y:s+f+(t.y-a.min)*h,setid:t.setid})))}function W(t){const e={};for(const n of t)e[n.setid]=n;return e}function X(t){return Object.keys(t).map(e=>Object.assign(t[e],{setid:e}))}function Y(t={}){let e=!1,n=600,s=350,i=15,r=1e3,o=Math.PI/2,a=!0,l=null,c=!0,h=!0,u=null,f=null,d=!1,y=null,g=!(!t||!t.symmetricalTextCentre)&&t.symmetricalTextCentre,x={},p=t&&t.colourScheme?t.colourScheme:t&&t.colorScheme?t.colorScheme:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],m=0,v=function(t){if(t in x)return x[t];var e=x[t]=p[m];return m+=1,m>=p.length&&(m=0),e},b=F,I=L;function M(x){let p=x.datum();const m=new Set;p.forEach(t=>{0==t.size&&1==t.sets.length&&m.add(t.sets[0])}),p=p.filter(t=>!t.sets.some(t=>m.has(t)));let M={},k={};if(p.length>0){let t=b(p,{lossFunction:I,distinct:d});a&&(t=G(t,o,f)),M=V(t,n,s,i,l),k=J(M,p,g)}const w={};function _(t){return t.sets in w?w[t.sets]:1==t.sets.length?""+t.sets[0]:void 0}p.forEach(t=>{t.label&&(w[t.sets]=t.label)}),x.selectAll("svg").data([M]).enter().append("svg");const S=x.select("svg");e?S.attr("viewBox",`0 0 ${n} ${s}`):S.attr("width",n).attr("height",s);const E={};let T=!1;function z(t){return e=>et(t.sets.map(t=>{let i=E[t],r=M[t];return i||(i={x:n/2,y:s/2,radius:1}),r||(r={x:n/2,y:s/2,radius:1}),{x:i.x*(1-e)+r.x*e,y:i.y*(1-e)+r.y*e,radius:i.radius*(1-e)+r.radius*e}}),y)}S.selectAll(".venn-area path").each(function(t){const e=this.getAttribute("d");1==t.sets.length&&e&&!d&&(T=!0,E[t.sets[0]]=function(t){const e=t.split(" ");return{x:Number.parseFloat(e[1]),y:Number.parseFloat(e[2]),radius:-Number.parseFloat(e[4])}}(e))});const A=S.selectAll(".venn-area").data(p,t=>t.sets),R=A.enter().append("g").attr("class",t=>`venn-area venn-${1==t.sets.length?"circle":"intersection"}${t.colour||t.color?" venn-coloured":""}`).attr("data-venn-sets",t=>t.sets.join("_")),D=R.append("path"),N=R.append("text").attr("class","label").text(t=>_(t)).attr("text-anchor","middle").attr("dy",".35em").attr("x",n/2).attr("y",s/2);function O(t){return"function"==typeof t.transition?t.transition("venn").duration(r):t}h&&(D.style("fill-opacity","0").filter(t=>1==t.sets.length).style("fill",t=>t.colour?t.colour:t.color?t.color:v(t.sets)).style("fill-opacity",".25"),N.style("fill",e=>e.colour||e.color?"#FFF":t.textFill?t.textFill:1==e.sets.length?v(e.sets):"#444"));let C=x;T&&"function"==typeof C.transition?(C=O(x),C.selectAll("path").attrTween("d",z)):C.selectAll("path").attr("d",t=>et(t.sets.map(t=>M[t])),y);const F=C.selectAll("text").filter(t=>t.sets in k).text(t=>_(t)).attr("x",t=>Math.floor(k[t.sets].x)).attr("y",t=>Math.floor(k[t.sets].y));c&&(T?"on"in F?F.on("end",K(M,_)):F.each("end",K(M,_)):F.each(K(M,_)));const $=O(A.exit()).remove();"function"==typeof A.transition&&$.selectAll("path").attrTween("d",z);const j=$.selectAll("text").attr("x",n/2).attr("y",s/2);return null!==u&&(N.style("font-size","0px"),F.style("font-size",u),j.style("font-size","0px")),{circles:M,textCentres:k,nodes:A,enter:R,update:C,exit:$}}return M.wrap=function(t){return arguments.length?(c=t,M):c},M.useViewBox=function(){return e=!0,M},M.width=function(t){return arguments.length?(n=t,M):n},M.height=function(t){return arguments.length?(s=t,M):s},M.padding=function(t){return arguments.length?(i=t,M):i},M.distinct=function(t){return arguments.length?(d=t,M):d},M.colours=function(t){return arguments.length?(v=t,M):v},M.colors=function(t){return arguments.length?(v=t,M):v},M.fontSize=function(t){return arguments.length?(u=t,M):u},M.round=function(t){return arguments.length?(y=t,M):y},M.duration=function(t){return arguments.length?(r=t,M):r},M.layoutFunction=function(t){return arguments.length?(b=t,M):b},M.normalize=function(t){return arguments.length?(a=t,M):a},M.scaleToFit=function(t){return arguments.length?(l=t,M):l},M.styled=function(t){return arguments.length?(h=t,M):h},M.orientation=function(t){return arguments.length?(o=t,M):o},M.orientationOrder=function(t){return arguments.length?(f=t,M):f},M.lossFunction=function(t){return arguments.length?(I="default"===t?L:"logRatio"===t?U:t,M):I},M}function K(t,e){return function(n){const s=this,i=t[n.sets[0]].radius||50,r=e(n)||"",o=r.split(/\s+/).reverse(),a=(r.length+o.length)/3;let l=o.pop(),c=[l],h=0;s.textContent=null;const u=[];function f(t){const e=s.ownerDocument.createElementNS(s.namespaceURI,"tspan");return e.textContent=t,u.push(e),s.append(e),e}let d=f(l);for(;l=o.pop(),l;){c.push(l);const t=c.join(" ");d.textContent=t,t.length>a&&d.getComputedTextLength()>i&&(c.pop(),d.textContent=c.join(" "),c=[l],d=f(l),h++)}const y=.35-1.1*h/2,g=s.getAttribute("x"),x=s.getAttribute("y");u.forEach((t,e)=>{t.setAttribute("x",g),t.setAttribute("y",x),t.setAttribute("dy",`${y+1.1*e}em`)})}}function Z(t,e,n){let s=e[0].radius-k(e[0],t);for(let i=1;i<e.length;++i){const n=e[i].radius-k(e[i],t);n<=s&&(s=n)}for(let i=0;i<n.length;++i){const e=k(n[i],t)-n[i].radius;e<=s&&(s=e)}return s}function H(t,e,n){const s=[];for(const h of t)s.push({x:h.x,y:h.y}),s.push({x:h.x+h.radius/2,y:h.y}),s.push({x:h.x-h.radius/2,y:h.y}),s.push({x:h.x,y:h.y+h.radius/2}),s.push({x:h.x,y:h.y-h.radius/2});let i=s[0],r=Z(s[0],t,e);for(let h=1;h<s.length;++h){const n=Z(s[h],t,e);n>=r&&(i=s[h],r=n)}const o=N(n=>-1*Z({x:n[0],y:n[1]},t,e),[i.x,i.y],{maxIterations:500,minErrorDelta:1e-10}).x,a={x:n?0:o[0],y:o[1]};let l=!0;for(const h of t)if(k(a,h)>h.radius){l=!1;break}for(const h of e)if(k(a,h)<h.radius){l=!1;break}if(l)return a;if(1==t.length)return{x:t[0].x,y:t[0].y};const c={};return I(t,c),0===c.arcs.length?{x:0,y:-1e3,disjoint:!0}:1==c.arcs.length?{x:c.arcs[0].circle.x,y:c.arcs[0].circle.y}:e.length?H(t,[]):S(c.arcs.map(t=>t.p1))}function J(t,e,n){const s={},i=function(t){const e={},n=Object.keys(t);for(const s of n)e[s]=[];for(let s=0;s<n.length;s++){const i=n[s],r=t[i];for(let o=s+1;o<n.length;++o){const s=n[o],a=t[s],l=k(r,a);l+a.radius<=r.radius+1e-10?e[s].push(i):l+r.radius<=a.radius+1e-10&&e[i].push(s)}}return e}(t);for(let r=0;r<e.length;++r){const o=e[r].sets,a={},l={};for(let t=0;t<o.length;++t){a[o[t]]=!0;const e=i[o[t]];for(let t=0;t<e.length;++t)l[e[t]]=!0}const c=[],h=[];for(let e in t)e in a?c.push(t[e]):e in l||h.push(t[e]);const u=H(c,h,n);s[o]=u,u.disjoint&&e[r].size}return s}function Q(t){if(0===t.length)return[];const e={};return I(t,e),e.arcs}function tt(t,e){if(0===t.length)return"M 0 0";const n=Math.pow(10,e||0),s=null!=e?t=>Math.round(t*n)/n:t=>t;if(1==t.length){const e=t[0].circle;return function(t,e,n){const s=[];return s.push("\nM",t,e),s.push("\nm",-n,0),s.push("\na",n,n,0,1,0,2*n,0),s.push("\na",n,n,0,1,0,2*-n,0),s.join(" ")}(s(e.x),s(e.y),s(e.radius))}const i=["\nM",s(t[0].p2.x),s(t[0].p2.y)];for(const r of t){const t=s(r.circle.radius);i.push("\nA",t,t,0,r.large?1:0,r.sweep?1:0,s(r.p1.x),s(r.p1.y))}return i.join(" ")}function et(t,e){return tt(Q(t),e)}var nt=function(){var t=a(function(t,e,n,s){for(n=n||{},s=t.length;s--;n[t[s]]=e);return n},"o"),e=[5,8],n=[7,8,11,12,17,19,22,24],s=[1,17],i=[1,18],r=[7,8,11,12,14,15,16,17,19,20,21,22,24,27],o=[1,31],l=[1,39],c=[7,8,11,12,17,19,22,24,27],h=[1,57],u=[1,56],f=[1,58],d=[1,59],y=[1,60],g=[7,8,11,12,16,17,19,20,22,24,27,31,32,33],x={trace:a(function(){},"trace"),yy:{},symbols_:{error:2,start:3,optNewlines:4,VENN:5,document:6,EOF:7,NEWLINE:8,line:9,statement:10,TITLE:11,SET:12,identifier:13,BRACKET_LABEL:14,COLON:15,NUMERIC:16,UNION:17,identifierList:18,TEXT:19,IDENTIFIER:20,STRING:21,INDENT_TEXT:22,indentedTextTail:23,STYLE:24,stylesOpt:25,styleField:26,COMMA:27,styleValue:28,valueTokens:29,valueToken:30,HEXCOLOR:31,RGBCOLOR:32,RGBACOLOR:33,$accept:0,$end:1},terminals_:{2:"error",5:"VENN",7:"EOF",8:"NEWLINE",11:"TITLE",12:"SET",14:"BRACKET_LABEL",15:"COLON",16:"NUMERIC",17:"UNION",19:"TEXT",20:"IDENTIFIER",21:"STRING",22:"INDENT_TEXT",24:"STYLE",27:"COMMA",31:"HEXCOLOR",32:"RGBCOLOR",33:"RGBACOLOR"},productions_:[0,[3,4],[4,0],[4,2],[6,0],[6,2],[9,1],[9,1],[10,1],[10,2],[10,3],[10,4],[10,5],[10,2],[10,3],[10,4],[10,5],[10,3],[10,3],[10,3],[10,4],[10,4],[10,2],[10,3],[23,1],[23,1],[23,1],[23,2],[23,2],[25,1],[25,3],[26,3],[28,1],[28,1],[29,1],[29,2],[30,1],[30,1],[30,1],[30,1],[30,1],[18,1],[18,3],[13,1],[13,1]],performAction:a(function(t,e,n,s,i,r,o){var a=r.length-1;switch(i){case 1:return r[a-1];case 2:case 3:case 4:case 6:this.$=[];break;case 5:case 35:r[a-1].push(r[a]),this.$=r[a-1];break;case 7:case 22:case 32:case 36:case 37:case 38:case 39:case 40:case 43:case 44:this.$=r[a];break;case 8:s.setDiagramTitle(r[a].substr(6)),this.$=r[a].substr(6);break;case 9:s.addSubsetData([r[a]],void 0,void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 10:s.addSubsetData([r[a-1]],r[a],void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 11:s.addSubsetData([r[a-2]],void 0,parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 12:s.addSubsetData([r[a-3]],r[a-2],parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 13:if(r[a].length<2)throw new Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a]),s.addSubsetData(r[a],void 0,void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 14:if(r[a-1].length<2)throw new Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a-1]),s.addSubsetData(r[a-1],r[a],void 0),s.setIndentMode&&s.setIndentMode(!0);break;case 15:if(r[a-2].length<2)throw new Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a-2]),s.addSubsetData(r[a-2],void 0,parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 16:if(r[a-3].length<2)throw new Error("union requires multiple identifiers");s.validateUnionIdentifiers&&s.validateUnionIdentifiers(r[a-3]),s.addSubsetData(r[a-3],r[a-2],parseFloat(r[a])),s.setIndentMode&&s.setIndentMode(!0);break;case 17:case 18:case 19:s.addTextData(r[a-1],r[a],void 0);break;case 20:case 21:s.addTextData(r[a-2],r[a-1],r[a]);break;case 23:s.addStyleData(r[a-1],r[a]);break;case 24:case 25:case 26:if(!(l=s.getCurrentSets()))throw new Error("text requires set");s.addTextData(l,r[a],void 0);break;case 27:case 28:var l;if(!(l=s.getCurrentSets()))throw new Error("text requires set");s.addTextData(l,r[a-1],r[a]);break;case 29:case 41:case 34:this.$=[r[a]];break;case 30:case 42:this.$=[...r[a-2],r[a]];break;case 31:this.$=[r[a-2],r[a]];break;case 33:this.$=r[a].join(" ")}},"anonymous"),table:[t(e,[2,2],{3:1,4:2}),{1:[3]},{5:[1,3],8:[1,4]},t(n,[2,4],{6:5}),t(e,[2,3]),{7:[1,6],8:[1,8],9:7,10:9,11:[1,10],12:[1,11],17:[1,12],19:[1,13],22:[1,14],24:[1,15]},{1:[2,1]},t(n,[2,5]),t(n,[2,6]),t(n,[2,7]),t(n,[2,8]),{13:16,20:s,21:i},{13:20,18:19,20:s,21:i},{13:20,18:21,20:s,21:i},{16:[1,25],20:[1,23],21:[1,24],23:22},{13:20,18:26,20:s,21:i},t(n,[2,9],{14:[1,27],15:[1,28]}),t(r,[2,43]),t(r,[2,44]),t(n,[2,13],{14:[1,29],15:[1,30],27:o}),t(r,[2,41]),{16:[1,34],20:[1,32],21:[1,33],27:o},t(n,[2,22]),t(n,[2,24],{14:[1,35]}),t(n,[2,25],{14:[1,36]}),t(n,[2,26]),{20:l,25:37,26:38,27:o},t(n,[2,10],{15:[1,40]}),{16:[1,41]},t(n,[2,14],{15:[1,42]}),{16:[1,43]},{13:44,20:s,21:i},t(n,[2,17],{14:[1,45]}),t(n,[2,18],{14:[1,46]}),t(n,[2,19]),t(n,[2,27]),t(n,[2,28]),t(n,[2,23],{27:[1,47]}),t(c,[2,29]),{15:[1,48]},{16:[1,49]},t(n,[2,11]),{16:[1,50]},t(n,[2,15]),t(r,[2,42]),t(n,[2,20]),t(n,[2,21]),{20:l,26:51},{16:h,20:u,21:[1,53],28:52,29:54,30:55,31:f,32:d,33:y},t(n,[2,12]),t(n,[2,16]),t(c,[2,30]),t(c,[2,31]),t(c,[2,32]),t(c,[2,33],{30:61,16:h,20:u,31:f,32:d,33:y}),t(g,[2,34]),t(g,[2,36]),t(g,[2,37]),t(g,[2,38]),t(g,[2,39]),t(g,[2,40]),t(g,[2,35])],defaultActions:{6:[2,1]},parseError:a(function(t,e){if(!e.recoverable){var n=new Error(t);throw n.hash=e,n}this.trace(t)},"parseError"),parse:a(function(t){var e=this,n=[0],s=[],i=[null],r=[],o=this.table,l="",c=0,h=0,u=r.slice.call(arguments,1),f=Object.create(this.lexer),d={yy:{}};for(var y in this.yy)Object.prototype.hasOwnProperty.call(this.yy,y)&&(d.yy[y]=this.yy[y]);f.setInput(t,d.yy),d.yy.lexer=f,d.yy.parser=this,void 0===f.yylloc&&(f.yylloc={});var g=f.yylloc;r.push(g);var x=f.options&&f.options.ranges;function p(){var t;return"number"!=typeof(t=s.pop()||f.lex()||1)&&(t instanceof Array&&(t=(s=t).pop()),t=e.symbols_[t]||t),t}"function"==typeof d.yy.parseError?this.parseError=d.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,a(function(t){n.length=n.length-2*t,i.length=i.length-t,r.length=r.length-t},"popStack"),a(p,"lex");for(var m,v,b,I,M,k,w,_,S={};;){if(v=n[n.length-1],this.defaultActions[v]?b=this.defaultActions[v]:(null==m&&(m=p()),b=o[v]&&o[v][m]),void 0===b||!b.length||!b[0]){var E="";for(M in _=[],o[v])this.terminals_[M]&&M>2&&_.push("'"+this.terminals_[M]+"'");E=f.showPosition?"Parse error on line "+(c+1)+":\n"+f.showPosition()+"\nExpecting "+_.join(", ")+", got '"+(this.terminals_[m]||m)+"'":"Parse error on line "+(c+1)+": Unexpected "+(1==m?"end of input":"'"+(this.terminals_[m]||m)+"'"),this.parseError(E,{text:f.match,token:this.terminals_[m]||m,line:f.yylineno,loc:g,expected:_})}if(b[0]instanceof Array&&b.length>1)throw new Error("Parse Error: multiple actions possible at state: "+v+", token: "+m);switch(b[0]){case 1:n.push(m),i.push(f.yytext),r.push(f.yylloc),n.push(b[1]),m=null,h=f.yyleng,l=f.yytext,c=f.yylineno,g=f.yylloc;break;case 2:if(k=this.productions_[b[1]][1],S.$=i[i.length-k],S._$={first_line:r[r.length-(k||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(k||1)].first_column,last_column:r[r.length-1].last_column},x&&(S._$.range=[r[r.length-(k||1)].range[0],r[r.length-1].range[1]]),void 0!==(I=this.performAction.apply(S,[l,h,c,d.yy,b[1],i,r].concat(u))))return I;k&&(n=n.slice(0,-1*k*2),i=i.slice(0,-1*k),r=r.slice(0,-1*k)),n.push(this.productions_[b[1]][0]),i.push(S.$),r.push(S._$),w=o[n[n.length-2]][n[n.length-1]],n.push(w);break;case 3:return!0}}return!0},"parse")},p=function(){return{EOF:1,parseError:a(function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},"parseError"),setInput:a(function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:a(function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},"input"),unput:a(function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var s=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===s.length?this.yylloc.first_column:0)+s[s.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},"unput"),more:a(function(){return this._more=!0,this},"more"),reject:a(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:a(function(t){this.unput(this.match.slice(t))},"less"),pastInput:a(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:a(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:a(function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},"showPosition"),test_match:a(function(t,e){var n,s,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),(s=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var r in i)this[r]=i[r];return!1}return!1},"test_match"),next:a(function(){if(this.done)return this.EOF;var t,e,n,s;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),r=0;r<i.length;r++)if((n=this._input.match(this.rules[i[r]]))&&(!e||n[0].length>e[0].length)){if(e=n,s=r,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,i[r])))return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,i[s]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:a(function(){var t=this.next();return t||this.lex()},"lex"),begin:a(function(t){this.conditionStack.push(t)},"begin"),popState:a(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:a(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:a(function(t){return(t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},"topState"),pushState:a(function(t){this.begin(t)},"pushState"),stateStackSize:a(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:a(function(t,e,n,s){switch(n){case 0:case 1:case 2:case 4:case 7:case 8:break;case 3:if(t.getIndentMode&&t.getIndentMode())return t.consumeIndentText=!0,this.begin("INITIAL"),22;break;case 5:t.setIndentMode&&t.setIndentMode(!1),this.begin("INITIAL"),this.unput(e.yytext);break;case 6:return this.begin("bol"),8;case 9:return 7;case 10:return 11;case 11:return 5;case 12:return 12;case 13:return 17;case 14:if(!t.consumeIndentText)return 19;t.consumeIndentText=!1;break;case 15:return 24;case 16:return e.yytext=e.yytext.slice(2,-2),14;case 17:return e.yytext=e.yytext.slice(1,-1).trim(),14;case 18:return 16;case 19:return 31;case 20:return 33;case 21:return 32;case 22:return 20;case 23:return 21;case 24:return 27;case 25:return 15}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[ \t]+(?=[\n\r]))/i,/^(?:[ \t]+(?=text\b))/i,/^(?:[ \t]+)/i,/^(?:[^ \t\n\r])/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:[ \t]+)/i,/^(?:$)/i,/^(?:title\s[^#\n;]+)/i,/^(?:venn-beta\b)/i,/^(?:set\b)/i,/^(?:union\b)/i,/^(?:text\b)/i,/^(?:style\b)/i,/^(?:\["[^\"]*"\])/i,/^(?:\[[^\]\"]+\])/i,/^(?:[+-]?(\d+(\.\d+)?|\.\d+))/i,/^(?:#[0-9a-fA-F]{3,8})/i,/^(?:rgba\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:rgb\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i,/^(?:"[^\"]*")/i,/^(?:,)/i,/^(?::)/i],conditions:{bol:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0},INITIAL:{rules:[0,1,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0}}}}();function m(){this.yy={}}return x.lexer=p,a(m,"Parser"),m.prototype=x,x.Parser=m,new m}();nt.parser=nt;var st,it=nt,rt=[],ot=[],at=[],lt=new Set,ct=!1,ht=a((t,e,n)=>{const s=pt(t).sort(),i=n??10/Math.pow(t.length,2);st=s,1===s.length&<.add(s[0]),rt.push({sets:s,size:i,label:e?ft(e):void 0})},"addSubsetData"),ut=a(()=>rt,"getSubsetData"),ft=a(t=>{const e=t.trim();return e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e},"normalizeText"),dt=a(t=>t?ft(t):t,"normalizeStyleValue"),yt=a((t,e,n)=>{const s=ft(e);ot.push({sets:pt(t).sort(),id:s,label:n?ft(n):void 0})},"addTextData"),gt=a((t,e)=>{const n=pt(t).sort(),s={};for(const[i,r]of e)s[i]=dt(r)??r;at.push({targets:n,styles:s})},"addStyleData"),xt=a(()=>at,"getStyleData"),pt=a(t=>t.map(t=>ft(t)),"normalizeIdentifierList"),mt=a(t=>{const e=pt(t).filter(t=>!lt.has(t));if(e.length>0)throw new Error(`unknown set identifier: ${e.join(", ")}`)},"validateUnionIdentifiers"),vt=a(()=>ot,"getTextData"),bt=a(()=>st,"getCurrentSets"),It=a(()=>ct,"getIndentMode"),Mt=a(t=>{ct=t},"setIndentMode"),kt=m.venn;function wt(){return p(kt,l().venn)}a(wt,"getConfig");var _t={getConfig:wt,clear:a(()=>{x(),rt.length=0,ot.length=0,at.length=0,lt.clear(),st=void 0,ct=!1},"customClear"),setAccTitle:o,getAccTitle:r,setDiagramTitle:i,getDiagramTitle:s,getAccDescription:n,setAccDescription:e,addSubsetData:ht,getSubsetData:ut,addTextData:yt,addStyleData:gt,validateUnionIdentifiers:mt,getTextData:vt,getStyleData:xt,getCurrentSets:bt,getIndentMode:It,setIndentMode:Mt},St=a(t=>`\n .venn-title {\n font-size: 32px;\n fill: ${t.vennTitleTextColor};\n font-family: ${t.fontFamily};\n }\n\n .venn-circle text {\n font-size: 48px;\n font-family: ${t.fontFamily};\n }\n\n .venn-intersection text {\n font-size: 48px;\n fill: ${t.vennSetTextColor};\n font-family: ${t.fontFamily};\n }\n\n .venn-text-node {\n font-family: ${t.fontFamily};\n color: ${t.vennSetTextColor};\n }\n`,"getStyles");function Et(t){const e=new Map;for(const n of t){const t=n.targets.join("|"),s=e.get(t);s?Object.assign(s,n.styles):e.set(t,{...n.styles})}return e}a(Et,"buildStyleByKey");var Tt=a((t,e,n,s)=>{var i,r,o;const a=s.db,x=null==(i=a.getConfig)?void 0:i.call(a),{themeVariables:p,look:m,handDrawnSeed:b}=l(),I="handDrawn"===m,M=[p.venn1,p.venn2,p.venn3,p.venn4,p.venn5,p.venn6,p.venn7,p.venn8].filter(Boolean),k=null==(r=a.getDiagramTitle)?void 0:r.call(a),w=a.getSubsetData(),_=a.getTextData(),S=Et(a.getStyleData()),E=Rt(w),T=(null==x?void 0:x.width)??800,z=(null==x?void 0:x.height)??450,A=T/1600,R=k?48*A:0,D=p.primaryTextColor??p.textColor,N=c(e);N.attr("viewBox",`0 0 ${T} ${z}`),k&&N.append("text").text(k).attr("class","venn-title").attr("font-size",32*A+"px").attr("text-anchor","middle").attr("dominant-baseline","middle").attr("x","50%").attr("y",32*A).style("fill",p.vennTitleTextColor||p.titleColor);const O=h(document.createElement("div")),C=Y().width(T).height(z-R);O.datum(E).call(C);const $=I?u.svg(O.select("svg").node()):void 0,j=function(t,e={}){const{lossFunction:n,layoutFunction:s=F,normalize:i=!0,orientation:r=Math.PI/2,orientationOrder:o,width:a=600,height:l=350,padding:c=15,scaleToFit:h=!1,symmetricalTextCentre:u=!1,distinct:f,round:d=2}=e;let y=s(t,{lossFunction:"default"!==n&&n?"logRatio"===n?U:n:L,distinct:f});i&&(y=G(y,r,o));const g=V(y,a,l,c,h),x=J(g,t,u),p=new Map(Object.keys(g).map(t=>[t,{set:t,x:g[t].x,y:g[t].y,radius:g[t].radius}])),m=t.map(t=>{const e=t.sets.map(t=>p.get(t)),n=Q(e);return{circles:e,arcs:n,path:tt(n,d),area:t,has:new Set(t.sets)}});function v(t){let e="";for(const n of m)n.has.size>t.length&&t.every(t=>n.has.has(t))&&(e+=" "+n.path);return e}return m.map(({circles:t,arcs:e,path:n,area:s})=>({data:s,text:x[s.sets],circles:t,arcs:e,path:n,distinctPath:n+v(s.sets)}))}(E,{width:T,height:z-R,padding:(null==x?void 0:x.padding)??15}),P=new Map;for(const l of j){const t=zt([...l.data.sets].sort());P.set(t,l)}_.length>0&&At(x,P,O,_,A,S);const q=f(p.background||"#f4f4f4");O.selectAll(".venn-circle").each(function(t,e){var n;const s=h(this),i=zt([...t.sets].sort()),r=S.get(i),o=(null==r?void 0:r.fill)||M[e%M.length]||p.primaryColor;s.classed("venn-set-"+e%8,!0);const a=(null==r?void 0:r["fill-opacity"])??.1,l=(null==r?void 0:r.stroke)||o,c=(null==r?void 0:r["stroke-width"])||""+5*A;if(I&&$){const t=P.get(i);if(t&&t.circles.length>0){const i=t.circles[0],r=$.circle(i.x,i.y,2*i.radius,{roughness:.7,seed:b,fill:v(o,.7),fillStyle:"hachure",fillWeight:2,hachureGap:8,hachureAngle:60*e-41,stroke:l,strokeWidth:parseFloat(String(c))});s.select("path").remove(),null==(n=s.node())||n.insertBefore(r,s.select("text").node())}}else s.select("path").style("fill",o).style("fill-opacity",a).style("stroke",l).style("stroke-width",c).style("stroke-opacity",.95);const u=(null==r?void 0:r.color)||(q?d(o,30):y(o,30));s.select("text").style("font-size",48*A+"px").style("fill",u)}),I&&$?O.selectAll(".venn-intersection").each(function(t){var e;const n=h(this),s=zt([...t.sets].sort()),i=S.get(s),r=null==i?void 0:i.fill;if(r){const t=n.select("path"),s=t.attr("d");if(s){const n=$.path(s,{roughness:.7,seed:b,fill:v(r,.3),fillStyle:"cross-hatch",fillWeight:2,hachureGap:6,hachureAngle:60,stroke:"none"}),i=t.node();null==(e=null==i?void 0:i.parentNode)||e.insertBefore(n,i),t.remove()}}else n.select("path").style("fill-opacity",0);n.select("text").style("font-size",48*A+"px").style("fill",(null==i?void 0:i.color)??p.vennSetTextColor??D)}):(O.selectAll(".venn-intersection text").style("font-size",48*A+"px").style("fill",t=>{var e;const n=zt([...t.sets].sort());return(null==(e=S.get(n))?void 0:e.color)??p.vennSetTextColor??D}),O.selectAll(".venn-intersection path").style("fill-opacity",t=>{var e;const n=zt([...t.sets].sort());return(null==(e=S.get(n))?void 0:e.fill)?1:0}).style("fill",t=>{var e;const n=zt([...t.sets].sort());return(null==(e=S.get(n))?void 0:e.fill)??"transparent"}));const B=N.append("g").attr("transform",`translate(0, ${R})`),W=O.select("svg").node();if(W&&"childNodes"in W)for(const l of[...W.childNodes])null==(o=B.node())||o.appendChild(l);g(N,z,T,(null==x?void 0:x.useMaxWidth)??!0)},"draw");function zt(t){return t.join("|")}function At(t,e,n,s,i,r){var o;const a=(null==t?void 0:t.useDebugLayout)??!1,l=n.select("svg").append("g").attr("class","venn-text-nodes"),c=new Map;for(const h of s){const t=zt(h.sets),e=c.get(t);e?e.push(h):c.set(t,[h])}for(const[h,u]of c.entries()){const t=e.get(h);if(!(null==t?void 0:t.text))continue;const n=t.text.x,s=t.text.y,c=Math.min(...t.circles.map(t=>t.radius)),f=Math.min(...t.circles.map(t=>t.radius-Math.hypot(n-t.x,s-t.y)));let d=Number.isFinite(f)?Math.max(0,f):0;0===d&&Number.isFinite(c)&&(d=.6*c);const y=l.append("g").attr("class","venn-text-area").attr("font-size",40*i+"px");a&&y.append("circle").attr("class","venn-text-debug-circle").attr("cx",n).attr("cy",s).attr("r",d).attr("fill","none").attr("stroke","purple").attr("stroke-width",1.5*i).attr("stroke-dasharray",`${6*i} ${4*i}`);const g=Math.max(80*i,2*d*.95),x=Math.max(60*i,2*d*.95),p=(t.data.label&&t.data.label.length>0?Math.min(32*i,.25*d):0)+(u.length<=2?30*i:0),m=n-g/2,v=s-x/2+p,b=Math.max(1,Math.ceil(Math.sqrt(u.length))),I=g/b,M=x/Math.max(1,Math.ceil(u.length/b));for(const[e,l]of u.entries()){const t=e%b,n=Math.floor(e/b),s=m+I*(t+.5),c=v+M*(n+.5);a&&y.append("rect").attr("class","venn-text-debug-cell").attr("x",m+I*t).attr("y",v+M*n).attr("width",I).attr("height",M).attr("fill","none").attr("stroke","teal").attr("stroke-width",1*i).attr("stroke-dasharray",`${4*i} ${3*i}`);const h=.9*I,u=.9*M,f=y.append("foreignObject").attr("class","venn-text-node-fo").attr("width",h).attr("height",u).attr("x",s-h/2).attr("y",c-u/2).attr("overflow","visible"),d=null==(o=r.get(l.id))?void 0:o.color,g=f.append("xhtml:span").attr("class","venn-text-node").style("display","flex").style("width","100%").style("height","100%").style("white-space","normal").style("align-items","center").style("justify-content","center").style("text-align","center").style("overflow-wrap","normal").style("word-break","normal").text(l.label??l.id);d&&g.style("color",d)}}}function Rt(t){const e=new Set(t.map(t=>[...t.sets].sort().join("|"))),n=new Map(t.filter(t=>1===t.sets.length&&void 0!==t.size).map(t=>[t.sets[0],t.size])),s=[];for(const i of t){if(i.sets.length<3)continue;const t=[...i.sets].sort();for(let i=0;i<t.length-1;i++)for(let r=i+1;r<t.length;r++){const o=[t[i],t[r]],a=o.join("|");if(!e.has(a)){e.add(a);const t=n.get(o[0]),i=n.get(o[1]),r=void 0!==t&&void 0!==i?Math.min(t,i)/4:2.5;s.push({sets:o,size:r,label:""})}}}return s.length>0?[...t,...s]:t}a(zt,"stableSetsKey"),a(At,"renderTextNodes"),a(Rt,"ensurePairwiseSubsets");var Dt={parser:it,db:_t,renderer:{draw:Tt},styles:St};export{Dt as diagram};
|