agentic-mermaid 0.5.4 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/AGENT_NATIVE.md +5 -9
  2. package/CHANGELOG.md +66 -0
  3. package/Instructions_for_agents.md +171 -97
  4. package/README.md +1 -1
  5. package/dist/agent-core.d.ts +7 -7
  6. package/dist/agent-core.js +1 -1
  7. package/dist/agent.d.ts +9 -10
  8. package/dist/agent.js +1 -1
  9. package/dist/agentic-mermaid-mcp.js +1 -1
  10. package/dist/am.js +1 -1
  11. package/dist/browser-lazy/chunks/{agentic-producer-core-ECZ3CMZM.js → agentic-producer-core-MYYZCUJS.js} +1 -1
  12. package/dist/browser-lazy/chunks/{architecture-H5LTMKQW.js → architecture-OHEIJI33.js} +6 -6
  13. package/dist/browser-lazy/chunks/{block-566X6FNV.js → block-DMBSQUFZ.js} +6 -6
  14. package/dist/browser-lazy/chunks/{builtin-backends-VAFEZXKY.js → builtin-backends-JTN3XG37.js} +3 -3
  15. package/dist/browser-lazy/chunks/{c4-ZXFDLBFK.js → c4-TK5GVVGU.js} +3 -3
  16. package/dist/browser-lazy/chunks/{chunk-7UFOFWBA.js → chunk-2R6M4CUH.js} +1 -1
  17. package/dist/browser-lazy/chunks/{chunk-YVNJDVQO.js → chunk-3K25OV6X.js} +1 -1
  18. package/dist/browser-lazy/chunks/{chunk-QVSZOF5M.js → chunk-3QXHJBE3.js} +1 -1
  19. package/dist/browser-lazy/chunks/{chunk-IUI4DYC3.js → chunk-4G652M75.js} +1 -1
  20. package/dist/browser-lazy/chunks/{chunk-LBXXKLIR.js → chunk-4WON4RCG.js} +3 -3
  21. package/dist/browser-lazy/chunks/{chunk-V6I2VGNQ.js → chunk-5SZ2YBKG.js} +9 -9
  22. package/dist/browser-lazy/chunks/{chunk-XHU3A432.js → chunk-CJZMMNPO.js} +1 -1
  23. package/dist/browser-lazy/chunks/{chunk-5LKPDHPC.js → chunk-F4CQMYR2.js} +4 -4
  24. package/dist/browser-lazy/chunks/{chunk-G4JBA7HU.js → chunk-GK5PSUKH.js} +3 -3
  25. package/dist/browser-lazy/chunks/{chunk-VRZKI33U.js → chunk-HAMXYU5V.js} +1 -1
  26. package/dist/browser-lazy/chunks/{chunk-Z7UHFVKN.js → chunk-IFUYPCDA.js} +6 -6
  27. package/dist/browser-lazy/chunks/{chunk-3JTYTXA6.js → chunk-ILCWDEZN.js} +4 -4
  28. package/dist/browser-lazy/chunks/{chunk-64JFHCJC.js → chunk-JJFXEH35.js} +1 -1
  29. package/dist/browser-lazy/chunks/{chunk-PXTLV57R.js → chunk-KOO3MCMJ.js} +1 -1
  30. package/dist/browser-lazy/chunks/{chunk-A7V5VDKN.js → chunk-LO25KEJY.js} +1 -1
  31. package/dist/browser-lazy/chunks/{chunk-TT5GR5EJ.js → chunk-MGB5QQEH.js} +1 -1
  32. package/dist/browser-lazy/chunks/{chunk-PSZEE64O.js → chunk-NVZKY7UI.js} +8 -8
  33. package/dist/browser-lazy/chunks/{chunk-6UOOATQR.js → chunk-PA7YKMP5.js} +1 -1
  34. package/dist/browser-lazy/chunks/{chunk-NKW2ZNCD.js → chunk-PS4HSV54.js} +1 -1
  35. package/dist/browser-lazy/chunks/{chunk-OBI5U5XU.js → chunk-QG67RIGQ.js} +1 -1
  36. package/dist/browser-lazy/chunks/{chunk-J57YRC2M.js → chunk-QOIFBX26.js} +1 -1
  37. package/dist/browser-lazy/chunks/chunk-QQCKPJF3.js +1 -0
  38. package/dist/browser-lazy/chunks/{chunk-O34YYEQV.js → chunk-QXSPMZ67.js} +1 -1
  39. package/dist/browser-lazy/chunks/{chunk-4NILRBC7.js → chunk-QYORAVMZ.js} +1 -1
  40. package/dist/browser-lazy/chunks/{chunk-OFOS57WQ.js → chunk-SC7LXD2V.js} +1 -1
  41. package/dist/browser-lazy/chunks/{chunk-EIYLJ4FI.js → chunk-SZAI2WB4.js} +12 -12
  42. package/dist/browser-lazy/chunks/{chunk-37FZNMPR.js → chunk-TXYQEDUF.js} +1 -1
  43. package/dist/browser-lazy/chunks/{chunk-2JQXRKBC.js → chunk-VR6YRNUZ.js} +1 -1
  44. package/dist/browser-lazy/chunks/{chunk-7TTFBJYA.js → chunk-WNTLLJPT.js} +1 -1
  45. package/dist/browser-lazy/chunks/{chunk-62MR3LWJ.js → chunk-YYF5TS6K.js} +1 -1
  46. package/dist/browser-lazy/chunks/{class-XIFNVBFE.js → class-QOJOM2XO.js} +8 -8
  47. package/dist/browser-lazy/chunks/{er-VEUYJBGG.js → er-2W6UXQT7.js} +6 -6
  48. package/dist/browser-lazy/chunks/{eventmodeling-G7DITZX7.js → eventmodeling-IVAFIO2U.js} +9 -9
  49. package/dist/browser-lazy/chunks/{flowchart-SSFIU4EU.js → flowchart-Y6OWQ46O.js} +1 -1
  50. package/dist/browser-lazy/chunks/{gantt-HQNVDX2B.js → gantt-BXTFJPZM.js} +6 -6
  51. package/dist/browser-lazy/chunks/{gitgraph-Z5MN6M6L.js → gitgraph-PW6R75SQ.js} +4 -4
  52. package/dist/browser-lazy/chunks/{ishikawa-UEERNFQV.js → ishikawa-GFX3XQQZ.js} +2 -2
  53. package/dist/browser-lazy/chunks/{journey-3BEWWGB5.js → journey-Q3M2GVKJ.js} +7 -7
  54. package/dist/browser-lazy/chunks/{kanban-2WFNCWLB.js → kanban-WVGVXROE.js} +11 -11
  55. package/dist/browser-lazy/chunks/{mindmap-R2C6SNYR.js → mindmap-CEDNSFJ6.js} +6 -6
  56. package/dist/browser-lazy/chunks/{packet-GMVCI5YZ.js → packet-Z56OVP2O.js} +3 -3
  57. package/dist/browser-lazy/chunks/{pie-WER45DKC.js → pie-FOJURIAM.js} +7 -7
  58. package/dist/browser-lazy/chunks/{quadrant-NCUPSFKN.js → quadrant-OGUQEK5C.js} +4 -4
  59. package/dist/browser-lazy/chunks/{radar-WLYS4YC5.js → radar-XTAUIQIJ.js} +9 -9
  60. package/dist/browser-lazy/chunks/render-core-QRFSDWGQ.js +3 -0
  61. package/dist/browser-lazy/chunks/{requirement-AK3NWMJ6.js → requirement-KEJ7ILX2.js} +7 -7
  62. package/dist/browser-lazy/chunks/{sankey-C2DY6WVU.js → sankey-ODWGDRAM.js} +8 -8
  63. package/dist/browser-lazy/chunks/{sequence-D4WJB44W.js → sequence-4ZNQR7S7.js} +1 -1
  64. package/dist/browser-lazy/chunks/{state-YUQVESE7.js → state-6IWPVJ4C.js} +2 -2
  65. package/dist/browser-lazy/chunks/{timeline-BMBJJXWR.js → timeline-LPJMPVPV.js} +4 -4
  66. package/dist/browser-lazy/chunks/{treemap-B66XBZZ6.js → treemap-2KFOQZRA.js} +4 -4
  67. package/dist/browser-lazy/chunks/xychart-KIPWFNVQ.js +16 -0
  68. package/dist/browser-lazy/chunks/{zenuml-62RLYFWP.js → zenuml-2ABFLOUP.js} +6 -6
  69. package/dist/browser-lazy/index.js +1 -1
  70. package/dist/browser.global.js +436 -436
  71. package/dist/chunk-3QC3FE2X.js +4 -0
  72. package/dist/{chunk-XU5LPD2D.js → chunk-5BYN55G4.js} +1 -1
  73. package/dist/chunk-5XKELJT2.js +2 -0
  74. package/dist/chunk-7HIKKNPP.js +150 -0
  75. package/dist/chunk-A5TX2FW5.js +2 -0
  76. package/dist/chunk-AS6A6XHE.js +2 -0
  77. package/dist/{chunk-DOFB572I.js → chunk-CGCGMO4U.js} +15 -15
  78. package/dist/chunk-GO4CS5KS.js +52 -0
  79. package/dist/{chunk-KXMANAST.js → chunk-JRLCGATA.js} +47 -47
  80. package/dist/{chunk-7XYB2LNC.js → chunk-K6TYUPTW.js} +2 -2
  81. package/dist/{chunk-HINRNKPO.js → chunk-QVP364DJ.js} +2 -2
  82. package/dist/chunk-V5RFODN6.js +2 -0
  83. package/dist/cli-PVKOWT4V.js +191 -0
  84. package/dist/elk-constructor.js +1 -1
  85. package/dist/{index-Bvhprdxz.d.ts → index-Bs7imZCS.d.ts} +14 -4
  86. package/dist/index.d.ts +4 -4
  87. package/dist/index.js +1 -1
  88. package/dist/{jsonl-RPJY6YWO.js → jsonl-5N4DTV7P.js} +2 -2
  89. package/dist/mcp-cli-EPIA7DTH.js +2 -0
  90. package/dist/{paint-certification-BoLyr006.d.ts → paint-certification-aIPtFDcn.d.ts} +2 -2
  91. package/dist/server-X6OFY2ZN.js +527 -0
  92. package/dist/{svg-styles-BnCoXyYe.d.ts → svg-styles-DfHloZTH.d.ts} +1 -1
  93. package/dist/svg-styles.d.ts +1 -1
  94. package/dist/svg-styles.js +1 -1
  95. package/dist/svg.d.ts +4 -4
  96. package/dist/svg.js +1 -1
  97. package/dist/{types-CLVJCaH2.d.ts → types-DkUbM48-.d.ts} +1 -1
  98. package/dist/zenuml/chunks/{appearance-5RM5MVM2.js → appearance-ROFRJDW7.js} +1 -1
  99. package/dist/zenuml/chunks/{builtin-backends-UTNWL4N3.js → builtin-backends-LM2A6WWK.js} +2 -2
  100. package/dist/zenuml/chunks/{chunk-ZNZRIISS.js → chunk-E6ZQYSVJ.js} +2 -2
  101. package/dist/zenuml/chunks/{chunk-IARQ24W3.js → chunk-KCHXQ5UA.js} +2 -2
  102. package/dist/zenuml/chunks/{chunk-3A6S6GNB.js → chunk-TEDVLVJM.js} +1 -1
  103. package/dist/zenuml/chunks/{chunk-CNLL4BGF.js → chunk-WD3ZPN3X.js} +1 -1
  104. package/dist/zenuml/chunks/{chunk-6J4BGPB2.js → chunk-WUHZDXTF.js} +24 -24
  105. package/dist/zenuml/chunks/{chunk-55WS466K.js → chunk-ZGLUBUQJ.js} +9 -9
  106. package/dist/zenuml/chunks/{render-core-ECIWU5ZS.js → render-core-WTHYSKBN.js} +2 -2
  107. package/dist/zenuml/chunks/{zenuml-N3LZMB2G.js → zenuml-3TCHUQJZ.js} +8 -8
  108. package/dist/zenuml.d.ts +2 -2
  109. package/dist/zenuml.js +1 -1
  110. package/docs/api.md +84 -4
  111. package/docs/quality.md +6 -3
  112. package/docs/style-authoring.md +23 -0
  113. package/docs/testing-strategy.md +59 -52
  114. package/examples/styles/readme-hero.md +4 -3
  115. package/package.json +4 -4
  116. package/server.json +2 -2
  117. package/skills/agentic-mermaid-diagram-workflow/SKILL.md +19 -154
  118. package/skills/agentic-mermaid-diagram-workflow/references/code-mode.md +12 -2
  119. package/skills/agentic-mermaid-diagram-workflow/references/hosted-mcp.md +5 -1
  120. package/dist/browser-lazy/chunks/chunk-6GPDLZFQ.js +0 -1
  121. package/dist/browser-lazy/chunks/render-core-42UVWIPF.js +0 -3
  122. package/dist/browser-lazy/chunks/xychart-HAVFROGT.js +0 -16
  123. package/dist/chunk-2DNGDTJD.js +0 -2
  124. package/dist/chunk-4F2UGYTM.js +0 -4
  125. package/dist/chunk-EHJI3QYE.js +0 -52
  126. package/dist/chunk-MKE7GNYU.js +0 -146
  127. package/dist/chunk-U4MT3RRE.js +0 -2
  128. package/dist/chunk-VUFVLGTH.js +0 -2
  129. package/dist/chunk-WYIB6BUR.js +0 -2
  130. package/dist/cli-ZYIDBYNS.js +0 -226
  131. package/dist/mcp-cli-YVDCORWA.js +0 -2
  132. package/dist/server-4JGAVXR3.js +0 -524
  133. package/docs/MCP-DIRECTORY-LISTINGS.md +0 -145
@@ -1 +0,0 @@
1
- import{a as e,c as t}from"./chunk-MFTQWHUB.js";import{a as i,b as r,c as n,e as o,f as a}from"./chunk-O34YYEQV.js";import{$ as s,A as l,B as d,C as h,D as g,E as u,F as f,G as c,H as p,I as y,J as m,K as x,L as b,M as w,O as M,P as v,Q as S,R as k,S as E,T as P,U as N,V as C,W as I,X as L,Y as R,Z as O,_ as $,a as z,aa as A,b as B,ba as F,c as T,ca as _,da as H,ea as D,fa as W,g as j,ga as V,ha as X,i as U,ia as G,j as Y,ja as q,k as Q,ka as K,l as J,la as Z,m as ee,ma as et,na as ei,oa as er,pa as en,q as eo,qa as ea,r as es,ra as el,s as ed,sa as eh,t as eg,ta as eu,u as ef,ua as ec,v as ep,va as ey,w as em,wa as ex,x as eb,xa as ew,y as eM,ya as ev,z as eS}from"./chunk-NKW2ZNCD.js";import{b as ek}from"./chunk-HJVO5VC3.js";import{a as eE,b as eP,c as eN,d as eC,h as eI}from"./chunk-PXTLV57R.js";import{A as eL,B as eR,k as eO,l as e$,m as ez,n as eA,o as eB,p as eF,r as eT,s as e_,t as eH,u as eD,v as eW,w as ej,x as eV,y as eX,z as eU}from"./chunk-QVSZOF5M.js";import{L as eG,P as eY,ja as eq,ka as eQ,la as eK}from"./chunk-G4JBA7HU.js";import{c as eJ,d as eZ,e as e0,h as e1,l as e2,m as e5,n as e6}from"./chunk-YVNJDVQO.js";import{$b as e4,A as e8,Ab as e3,C as e9,G as e7,La as te,Oa as tt,Ob as ti,Pb as tr,Q as tn,Qb as to,R as ta,Ua as ts,Ub as tl,Wa as td,Yb as th,_ as tg,_b as tu,bb as tf,t as tc}from"./chunk-EIYLJ4FI.js";function tp(e){throw Error(`LAYOUT_HINT_INVALID: ${e}`)}var ty=class extends Error{constructor(e,t,i){super(i),this.pass=e,this.contract=t,this.name="LayoutPassContractError"}pass;contract;code="LAYOUT_PASS_CONTRACT_VIOLATION"},tm=class extends ty{constructor(e,t,i,r,n){super(e,"metric-budget",`Layout pass '${e}' worsened ${t} from ${i} to ${r} (allowance ${n})`),this.metric=t,this.before=i,this.after=r,this.allowance=n,this.name="LayoutMetricBudgetError"}metric;before;after;allowance;code="LAYOUT_METRIC_BUDGET_EXCEEDED"},tx=e=>{let t=[...e.nodes],i=e=>{for(let r of e)t.push(r),i(r.children??[])};return i(e.groups??[]),t},tb=["unreadableTitles","edgeCrossings","labelConflicts","totalBends","nonCanonicalEndpointRate","peerBarycenterDelta","area"];function tw(e,t){let i=new Map,r=e=>{for(let t of e)i.set(t.id,t),r(t.children)};r(e.subgraphs);let n=t=>{for(let r of t)r.nodeIds=i.get(r.id).nodeIds.filter(t=>e.nodes.has(t)&&!i.has(t)),n(r.children)};n(t.groups)}function tM(e,t){let i=[];if(![e.width,e.height].every(Number.isFinite)||e.width<0||e.height<0)return["non-finite or negative canvas"];let r=(t,r,n,o,a)=>{![r,n,o,a].every(Number.isFinite)||o<0||a<0?i.push(`${t}: non-finite or negative geometry`):(r<-.5||n<-.5||r+o>e.width+.5||n+a>e.height+.5)&&i.push(`${t}: outside canvas`)};for(let t of e.nodes)r(`node ${t.id}`,t.x,t.y,t.width,t.height);let n=e=>{r(`group ${e.id}`,e.x,e.y,e.width,e.height),e.children.forEach(n)};for(let o of(e.groups.forEach(n),e.edges)){for(let e of("invisible"!==o.style&&o.points.length<2&&i.push(`edge ${o.source}->${o.target}: missing route`),!o.label||o.labelPosition&&o.labelBlock||i.push(`label ${o.source}->${o.target}: missing retained geometry`),o.points))r(`edge ${o.source}->${o.target}`,e.x,e.y,0,0);if(void 0!==o.label&&o.labelPosition&&o.labelBlock){let e=eI(o,t);e&&r(`label ${o.source}->${o.target}`,e.x,e.y,e.w,e.h)}}for(let t of e.notes??[])r(`note ${t.id}`,t.x,t.y,t.width,t.height);if(e.title?.block){let t=e.title,i=t.block;r("diagram title",t.x-i.width/2,t.y-i.height/2,i.width,i.height)}return i}function tv(e,t){let i,r,n,o=tM(e,t);return o.length?o:(i=[],r=(e,t,i,r)=>{let n=0,o=1;for(let[a,s,l,d]of[[e.x,t.x-e.x,i.x,i.x+i.width],[e.y,t.y-e.y,i.y,i.y+r]]){if(0===s){if(a<=l||a>=d)return!1;continue}let e=(l-a)/s,t=(d-a)/s;if((n=Math.max(n,Math.min(e,t)))>=(o=Math.min(o,Math.max(e,t))))return!1}return n<o},n=o=>{if(!o.concurrencyRegion){let n=o.labelBlock??eP(e9(o.label,o.labelContent),t,"group"),a=o.headerHeight??t.groupHeaderFontSize+16+n.height-n.lineHeight;if(!Number.isFinite(a)||a<0)i.push(`group-header ${o.id}: invalid retained height`);else if(a>0&&o.width>0){for(let t of e.edges)if("invisible"!==t.style){for(let e=1;e<t.points.length;e++)if(r(t.points[e-1],t.points[e],o,a)){i.push(`group-header ${o.id}: edge ${t.source}->${t.target} segment ${e} enters reserved band`);break}}}}o.children.forEach(n)},e.groups.forEach(n),i)}function tS(e,t,i,r=!1){return tk(e,t,i,r)}function tk(e,t,i,r=!1,n="final"){try{var o;let a=i.produce(),s=function(e,t,i){let r=[],n=(e,t,n,o)=>{if(!n)return;let a=e7(t,"formatted","node"===o?i.nodeTextTransform:"edge"===o?i.edgeTextTransform:i.groupTextTransform),s=n.prepared,l=s.lines.length===a.lines.length&&s.lines.every((e,t)=>e.length===a.lines[t].length&&e.every((e,i)=>{let r=a.lines[t][i];return e.text===r.text&&e.bold===r.bold&&e.italic===r.italic&&e.underline===r.underline&&e.strikethrough===r.strikethrough&&e.sourceStart===r.sourceStart&&e.sourceEnd===r.sourceEnd&&e.clusters?.length===r.clusters?.length&&(e.clusters?.every((e,t)=>{let i=r.clusters[t];return e.text===i.text&&e.sourceStart===i.sourceStart&&e.sourceEnd===i.sourceEnd})??!0)}));(s.source!==a.source||s.display!==a.display||s.transform!==a.transform||s.lineStarts.length!==a.lineStarts.length||s.lineStarts.some((e,t)=>e!==a.lineStarts[t])||!l)&&r.push(`${e}: changed retained prepared text`)},o=new Map,a=new Map,s=new Map,l=new Map,d=(e,t="")=>{for(let i of e)o.set(i.id,t),s.set(i.id,i),d(i.children,i.id)},h=(e,t="")=>{for(let i of e)a.has(i.id)&&r.push(`group ${i.id}: duplicate identity`),a.set(i.id,t),l.set(i.id,i),h(i.children,i.id)};for(let[i,n]of(d(e.subgraphs),h(t.groups),o))a.get(i)!==n&&r.push(`group ${i}: missing or changed parent`);for(let e of a.keys())o.has(e)||r.push(`group ${e}: unexpected identity`);let g=new Set,u=new Map(t.nodes.map(e=>[e.id,e]));for(let i of t.nodes)if(g.has(i.id)&&r.push(`node ${i.id}: duplicate identity`),g.add(i.id),e.nodes.has(i.id))if(i.label!==e.nodes.get(i.id).label)r.push(`node ${i.id}: changed label`);else{let t=e.nodes.get(i.id);n(`node ${i.id}`,e9(t.label,t.labelContent),i.labelBlock,"node")}else r.push(`node ${i.id}: unexpected identity`);for(let t of e.nodes.keys())g.has(t)||a.has(t)||r.push(`node ${t}: missing identity`);for(let[e,t]of s){let i=l.get(e);if(!i)continue;i.label!==t.label&&r.push(`group ${e}: changed label`),n(`group ${e}`,e9(t.label,t.labelContent),i.labelBlock,"group");let a=l.get(o.get(e)??"");for(let n of(a&&(i.x<a.x-.5||i.y<a.y-.5||i.x+i.width>a.x+a.width+.5||i.y+i.height>a.y+a.height+.5)&&r.push(`group ${e}: outside authored parent ${a.id}`),t.nodeIds)){if(s.has(n))continue;let t=u.get(n);t&&(t.x<i.x-.5||t.y<i.y-.5||t.x+t.width>i.x+i.width+.5||t.y+t.height>i.y+i.height+.5)&&r.push(`member ${n}: outside authored group ${e}`)}}let f=new Set;for(let[i,o]of t.edges.entries()){let t=o.edgeIndex??i,a=e.edges[t];if(f.has(t)&&r.push(`edge ${t}: duplicate identity`),f.add(t),!a){r.push(`edge ${t}: unexpected identity`);continue}void 0!==a.label&&n(`edge ${t}`,e9(a.label,a.labelContent),o.labelBlock,"edge"),(o.source!==a.source||o.target!==a.target||(o.id??"")!==(a.id??"")||(o.label??"")!==(a.label??"")||o.style!==a.style||o.hasArrowStart!==a.hasArrowStart||o.hasArrowEnd!==a.hasArrowEnd||(o.startMarker??"arrow")!==(a.startMarker??"arrow")||(o.endMarker??"arrow")!==(a.endMarker??"arrow"))&&r.push(`edge ${t}: changed endpoints, identity, label, shaft or markers`)}return e.edges.forEach((e,t)=>{f.has(t)||r.push(`edge ${t}: missing identity`)}),r}(e,a,t);if(r&&s.length)throw TypeError(`Owned layout changed authored meaning: ${s.join("; ")}`);let l=[...s,..."placement"===n?tM(a,t):tv(a,t)],d=0===l.length?D(e,a,t):void 0;d&&l.push(...V(d).map(e=>`${e.metric}: ${e.detail}`));let h=0===l.length&&(i.preferNext?.(a)??!1);return{attempt:{strategy:i.strategy,violations:l},...0===l.length&&d?{certified:{positioned:a,strategy:i.strategy,score:(o=d.metrics,{unreadableTitles:+!!h,labelConflicts:o.labelConflicts,edgeCrossings:o.edgeCrossings,totalBends:o.totalBends,nonCanonicalEndpointRate:1-o.portEndpointRate,peerBarycenterDelta:Math.round(1e3*o.peerBarycenterDelta)/1e3,area:a.width*a.height})}}:{}}}catch(e){if(r||e instanceof ty||e instanceof eG||e instanceof to)throw e;return{attempt:{strategy:i.strategy,violations:[e instanceof Error?e.message:String(e)]}}}}function tE(e,t){for(let i of tb){if(t.score[i]<e.score[i])return{selected:t,reason:i};if(t.score[i]>e.score[i])return{selected:e,reason:i}}return{selected:e,reason:"candidate-order"}}function tP(e,t,i,r,n="final"){let o=[],a=i.slice(0,4),s=r?[r,...a]:a,l,d,h=!1,g=[],u=(e,t)=>({selected:e,reason:t,compared:g,attempts:o.length});for(let[i,r]of s.entries()){if(l&&"routing"===d&&!1===r.qualityAlternative)continue;h&&(tf("layout-candidate","candidate-rejected",o.length+1),h=!1);let a=tk(e,t,r,!1,n);o.push(a.attempt);let f=a.certified;if(f){if(g.push({strategy:f.strategy,score:f.score}),l){let e=tE(l,f);return u(e.selected,e.reason)}let t=s.slice(i+1);if(f.score.unreadableTitles&&t.length>0){l=f,d="readability";continue}if(0===f.score.edgeCrossings&&0===f.score.labelConflicts)return u(f,"first-certified");if(!ep(e))return u(f,"work-budget");if(!t.some(e=>!1!==e.qualityAlternative))return u(f,"no-alternative");l=f,d="routing";continue}if(l)return u(l,"alternative-invalid");h=!0}if(l)return u(l,"no-alternative");throw new tr(o)}function tN(e,t){let{selected:i,reason:r,compared:n,attempts:o}=t;return tw(e,i.positioned),i.positioned.certification={status:"passed",strategy:i.strategy,attempts:o,hardViolations:0,preference:{selectedScore:i.score,reason:r,compared:n}},i.positioned}function tC(e,t,i){let r=e.labelBlock??eE(e9(e.label,e.labelContent),i);return{x:t.x-(r.width+16)/2,y:t.y-(r.height+16)/2,width:r.width+16,height:r.height+16}}function tI(e){let t=[e[0],e[e.length-1]],i=-1;for(let r=1;r<e.length;r++){let n=e[r-1],o=e[r],a=Math.hypot(o.x-n.x,o.y-n.y);a>i&&(i=a,t=[n,o])}return{x:(t[0].x+t[1].x)/2,y:(t[0].y+t[1].y)/2}}function tL(e){return Math.max(8,.75*e.edgeLabelFontSize)}function tR(e){return Math.max(12,e.edgeLabelFontSize)}function tO(e){let t=(e.lineWidth??1)*2;return Math.max(18,e.edgeLabelFontSize+eZ.width+2*t)}function t$(e){return tO(e)+(3*e0.dash+2*e0.gap)}function tz(e,t,i){return Math.abs(i.x-t.x)>=Math.abs(i.y-t.y)?e.width/2:e.height/2}function tA(e,t,i,r,n,o){let a,s,l=(a=o.lineWidth??1,s="thick"===e.style?2*a:a,Math.max(18,o.edgeLabelFontSize+eZ.width+2*s));if(e.hasArrowStart&&1===i){let e=t[0],i=tz(n,e,t[1]);if(Math.hypot(r.x-e.x,r.y-e.y)<i+l)return!1}if(e.hasArrowEnd&&i===t.length-1){let e=t[t.length-1],i=tz(n,t[t.length-2],e);if(Math.hypot(r.x-e.x,r.y-e.y)<i+l)return!1}return!0}function tB(e,t,i,r,n,o){if(!e.label)return[];let a=eA(t);if(0===a)return[];let s=a/2,l=[],d=[.5,.45,.55,.4,.6,.35,.65,.3,.7,.25,.75,.2,.8,1/6,5/6],h=0;for(let a=1;a<t.length;a++){var g;let u=t[a-1],f=t[a],c=Math.hypot(f.x-u.x,f.y-u.y);if(0===c)continue;let p=eF(r).isHorizontal?.01>Math.abs(u.y-f.y):.01>Math.abs(u.x-f.x),y=e.hasArrowStart&&1===a||e.hasArrowEnd&&a===t.length-1,m=tC(e,{x:0,y:0},n),x=(g=a,{start:e.hasArrowStart&&1===g?tO(n):tR(n),end:e.hasArrowEnd&&g===t.length-1?t$(n):tR(n)}),b=[...d,...function(e,t,i,r){let n=Math.hypot(i.x-t.x,i.y-t.y);if(0===n)return[];let o=tz(e,t,i),a=(o+r.start)/n,s=1-(o+r.end)/n;return a>s?[]:[(a+s)/2]}(m,u,f,x)].filter((e,t,i)=>e>=0&&e<=1&&i.findIndex(t=>.001>Math.abs(t-e))===t),w=.01>Math.abs(u.x-f.x),M=Math.min(m.height/2+3,(w?m.width:m.height)/2-1),v=o?[0,M/4,-M/4,M/2,-M/2,M,-M]:[0];for(let r=0;r<b.length;r++){let d=b[r];for(let g of v){let m={x:u.x+(f.x-u.x)*d+(w?g:0),y:u.y+(f.y-u.y)*d+(w?0:g)},b=tC(e,m,n);if(i.some(e=>eV(b,e,2))||!tA(e,t,a,m,b,n))continue;let M=function(e,t,i,r,n){let o=tz(e,i,r);return Math.hypot(t.x-i.x,t.y-i.y)>=o+n.start&&Math.hypot(t.x-r.x,t.y-r.y)>=o+n.end}(b,m,u,f,x),v=w?b.y>=Math.min(u.y,f.y)&&b.y+b.height<=Math.max(u.y,f.y):b.x>=Math.min(u.x,f.x)&&b.x+b.width<=Math.max(u.x,f.x);(!o||M&&v&&o(e,m))&&l.push({point:m,box:b,order:r,rank:0,pathDistance:h+c*d,routeMidpointDistance:Math.abs(h+c*d-s),segmentMidpointDistance:Math.abs(c*(d-.5)),straightRunPenalty:p&&M?0:p?2:10,terminalSegmentPenalty:+!!y})}}h+=c}return l.sort((e,t)=>e.straightRunPenalty-t.straightRunPenalty||e.terminalSegmentPenalty-t.terminalSegmentPenalty||e.segmentMidpointDistance-t.segmentMidpointDistance||e.routeMidpointDistance-t.routeMidpointDistance||e.order-t.order||e.pathDistance-t.pathDistance),l.map((e,t)=>({...e,rank:t}))}function tF(e,t,i,r,n){return tB(e,t,i,r,n)[0]?.point??eB(t)}function tT(e,t){let i=0,r=[];for(let e=1;e<t.length;e++){let n=Math.hypot(t[e].x-t[e-1].x,t[e].y-t[e-1].y);r.push(n),i+=n}let n=1/0,o=0,a=0;for(let i=1;i<t.length;i++){let s=t[i-1],l=t[i],d=l.x-s.x,h=l.y-s.y,g=d*d+h*h,u=g?((e.x-s.x)*d+(e.y-s.y)*h)/g:0;u=Math.max(0,Math.min(1,u));let f=s.x+u*d,c=s.y+u*h,p=Math.hypot(e.x-f,e.y-c);p<n&&(n=p,o=a+u*r[i-1]),a+=r[i-1]}return i?o/i:.5}function t_(e,t,i,r,n=!1,o){let a=e.filter(({edge:e})=>e.label);if(0===a.length)return!0;if(1===a.length){let e=a[0],n=tB(e.edge,e.points,t,i,r,o);if(o&&0===n.length)return!1;e.edge.labelPosition=n[0]?.point??eB(e.points)}else{let e=a.map(({edge:e,points:n})=>tB(e,n,t,i,r,o));if(e.some(e=>0===e.length)){if(o)return!1;for(let{edge:e,points:n}of a)e.labelPosition=tF(e,n,t,i,r)}else{let n=tL(r),s,l=1/0,d=[],h=t=>{if(t===e.length){let e,t,r,n,o,a,h,g=(e=eF(i),r=Math.max(...t=d.map(t=>t.point[e.main]))-Math.min(...t),n=d.reduce((e,t)=>e+t.straightRunPenalty,0),o=d.reduce((e,t)=>e+t.terminalSegmentPenalty,0),a=d.reduce((e,t)=>e+t.segmentMidpointDistance,0),h=d.reduce((e,t)=>e+t.routeMidpointDistance,0),1e4*n+100*r+1e3*o+4*a+.25*d.reduce((e,t)=>e+t.rank,0)+.1*h);g<l&&(l=g,s=d.slice());return}for(let i of e[t])d.some(e=>eV(i.box,e.box,n))||(d.push(i),h(t+1),d.pop())};if(h(0),s)for(let e=0;e<a.length;e++)a[e].edge.labelPosition=s[e].point;else{if(o)return!1;for(let{edge:e,points:n}of a)e.labelPosition=tF(e,n,t,i,r)}}}if(!n)return!0;let s=[],l=tL(r);for(let{edge:e}of a)e.labelPosition&&s.push(tC(e,e.labelPosition,r));for(let e=0;e<a.length;e++){let{edge:n,points:o}=a[e],d=n.labelPosition;(function(e,t,i,r,n,o=[],a=0){if(!e.label||!e.labelPosition)return;let s=function(e,t){let i=eF(t),r=e.map(e=>e[i.main]),n=(Math.min(...r)+Math.max(...r))/2,o=null;for(let t=1;t<e.length;t++){let r=e[t-1],a=e[t],s=Math.min(r[i.main],a[i.main]),l=Math.max(r[i.main],a[i.main]);if(n<s-1e-6||n>l+1e-6)continue;let d=a[i.main]-r[i.main];if(1e-6>=Math.abs(d))continue;let h=(n-r[i.main])/d,g={[i.main]:n,[i.cross]:r[i.cross]+h*(a[i.cross]-r[i.cross])};if(.01>Math.abs(r[i.cross]-a[i.cross]))return g;o??=g}return o}(t,r);if(!s)return;let l=Math.abs(tT(e.labelPosition,t)-.5);if(Math.abs(tT(s,t)-.5)>=l-1e-6)return;let d=tC(e,s,n);if(i.some(e=>eV(d,e,2))||o.some(e=>eV(d,e,a)))return;let h=eF(r);for(let i=1;i<t.length;i++){let r=t[i-1],o=t[i],a=Math.min(r[h.main],o[h.main]),l=Math.max(r[h.main],o[h.main]);if(!(1e-6>=Math.abs(o[h.main]-r[h.main]))&&!(s[h.main]<a-1e-6||s[h.main]>l+1e-6)){if(!tA(e,t,i,s,d,n))return;break}}e.labelPosition=s})(n,o,t,i,r,s.filter((t,i)=>i!==e),l),n.labelPosition&&n.labelPosition!==d&&(s[e]=tC(n,n.labelPosition,r))}return!0}function tH(e,t,i,r){let n=new Map;if(eU("APL_NO_CORANK_FANIN"))return n;let o=e$(r.edges),a=new Map(e.map(e=>[e.id,e])),s=e=>!!e&&eb.has(e.shape)&&!K(e,i),l=e=>!!e&&"rectangle"===e.shape&&!K(e,i),d=new Map;for(let e of t)e.source!==e.target&&X(e,a,r.direction)&&(d.has(e.target)||d.set(e.target,[]),d.get(e.target).push(e));for(let[e,t]of d){if(t.length<2||t.length>6||!s(a.get(e)))continue;let i=t.filter(e=>!!e.label);if(0===i.length||i.length===t.length)continue;let d=t[0].style;if(t.some(e=>e.style!==d))continue;let h=t.map(e=>a.get(e.source)).filter(e=>!!e);if(h.length!==t.length||new Set(h.map(e=>e.id)).size!==h.length||!h.every(l)||!G(h,r.direction,28))continue;let g=!0;for(let e=0;e<h.length&&g;e++)for(let t=0;t<h.length;t++)if(e!==t&&o(h[e].id,h[t].id)){g=!1;break}g&&n.set(e,t)}return n}function tD(e,t,i,r,n,o){let a=4e6,s=m(t,i,r,o,e=>(a-=e)>=0);if(!s)return!1;let l=N({nodes:t,edges:i,groups:r},o),d=new Set(e.map(({edge:e})=>e)),h=t.find(t=>t.id===e[0].edge.source),g=Z(r).filter(e=>et(h,e)),u=(e,t)=>{let i=eI({...e,labelPosition:t},o),r=i&&l.clearPaintRect(i,eC(e,o.lineWidth??1),e);return!!r&&g.every(e=>r.x>e.x&&r.y>e.y&&r.x+r.w<e.x+e.width&&r.y+r.h<e.y+e.height)&&s.clear(e,t,new Map,void 0,d)},f=()=>e.every(({edge:e})=>!e.label||!!e.labelPosition&&s.clear(e,e.labelPosition,new Map));return e.every(({edge:e,points:t})=>{if(!e.label)return!0;if(!e.labelPosition||!u(e,e.labelPosition))return!1;let i=eI(e,o);return t.some((e,r)=>{if(!r)return!1;let n=t[r-1];return n.x===e.x&&n.x>=i.x&&n.x<=i.x+i.w&&i.y>=Math.min(n.y,e.y)&&i.y+i.h<=Math.max(n.y,e.y)||n.y===e.y&&n.y>=i.y&&n.y<=i.y+i.h&&i.x>=Math.min(n.x,e.x)&&i.x+i.w<=Math.max(n.x,e.x)})})&&f()||t_(e,t,n,o,!1,u)&&f()}function tW(e,t){return Z(t).filter(t=>et(e,t)).map(e=>e.id).join("\0")}function tj(e,t,i,r,n,o,a){if(t.length<2||t.length>3||"rectangle"!==e.shape&&"diamond"!==e.shape)return;let s="diamond"!==e.shape&&K(e,n),l=[...t].sort((e,t)=>eW(r.get(e.target),o)-eW(r.get(t.target),o)),d=l.map(e=>r.get(e.target)).filter(Boolean);if(d.length!==l.length)return;let h=s?tW(e,n):"";if(d.every(t=>"rectangle"===t.shape&&(s?tW(t,n)===h:"diamond"===e.shape||!K(t,n)))&&G(d,o,40)&&d.every(t=>i.every(i=>i.source!==t.id&&(i.target!==t.id||i.source===e.id)))){for(let e=0;e<d.length;e++)for(let t=0;t<d.length;t++)if(e!==t&&a(d[e].id,d[t].id))return;return l}}function tV(e,t,i){if(e.length>eg||t.length>ef)return!1;let r=eg-e.length,n=e=>e.every(e=>--r>=0&&n(e.children));return n(i)}var tX=(e,t)=>e.points.length!==t.points.length||e.points.some((e,i)=>e.x!==t.points[i].x||e.y!==t.points[i].y);function tU(){return{remaining:eg*ef}}function tG(e,t,i,r,n,o,a=tU()){let s=e.map((e,t)=>e.x!==i[t].x||e.y!==i[t].y),d=t.map((e,t)=>tX(e,r[t]));if(!s.some(Boolean)&&!d.some(Boolean))return!0;let h=()=>--a.remaining>=0,g=new Map,u=e=>(g.has(e)||g.set(e,y(e,o,h)),g.get(e)),m=new Map,x=e=>{if(!m.has(e)){let t=ee(e,{fill:e.inlineStyle?.fill??o.nodeFillColor??"var(--_node-fill)",stroke:e.inlineStyle?.stroke??o.nodeBorderColor??"var(--_node-stroke)",strokeWidth:ta("stroke-width",e.inlineStyle?.["stroke-width"]??String(o.nodeLineWidth??eJ.innerBox))},o.cornerRadius);m.set(e,td({kind:"shape",id:e.id,role:"node",geometry:f(t.geometry),paint:t.paint,...t.childPaints?{childPaints:t.childPaints}:{}}))}return m.get(e)};try{let o,a,g;for(let t=0;t<e.length;t++){if(!s[t])continue;let i=x(e[t]);if(!c(i))return!1;for(let r=0;r<e.length;r++){if(r===t||s[r]&&r<t)continue;if(!h())return!1;let n=x(e[r]);if(!c(n)||p(i,n))return!1}}for(let n=0;n<e.length;n++){let o=e[n];for(let e=0;e<t.length;e++){let a=t[e];if(!s[n]&&!d[e]||"invisible"===a.style)continue;if(!h()||a.source===o.id&&l(a,o)>l(r[e],i[n])||a.target===o.id&&l(a,void 0,o)>l(r[e],void 0,i[n]))return!1;let g=u(a);if(!g)return!1;let f=x(o);if(!c(f))return!1;if(a.source!==o.id&&a.target!==o.id){for(let e of g.shafts)if(!h()||p(f,e))return!1}for(let e of g.markers)if(("start"===e.position?a.source:a.target)!==o.id&&(!h()||!c(e.bounds)||p(f,e.bounds)))return!1;if(g.label&&(!h()||p(f,g.label)))return!1}}return o=e.filter((e,t)=>e.x!==i[t].x||e.y!==i[t].y),a=t.filter((e,t)=>"invisible"!==e.style&&tX(e,r[t])),g=e=>{if(!h())return!1;if(!e.concurrencyRegion&&0!==e.width){let t=e.headerHeight??e.height;if(!Number.isFinite(e.width)||e.width<0||!Number.isFinite(t)||t<0)return!1;if(t>0&&e.width>0){let i=te({x0:e.x,y0:e.y,x1:e.x+e.width,y1:e.y+t},tt(f({kind:"rect",x:e.x,y:e.y,width:e.width,height:t})));if(!c(i))return!1;for(let e of o){if(!h())return!1;let t=x(e);if(!c(t))return!1;let r=te(t,{x0:e.x,y0:e.y,x1:e.x+e.width,y1:e.y+e.height});if(!c(r)||p(r,i))return!1}for(let e of a){let t=u(e);if(!t)return!1;for(let e of t.shafts)if(!h()||p(e,i))return!1;for(let e of t.markers)if(!h()||!c(e.bounds)||p(e.bounds,i))return!1}}}return e.children.every(g)},n.every(g)}catch{return!1}}function tY(e,t){return{nodes:e.map(e=>({...e})),edges:t.map(e=>({...e,points:e.points.map(e=>({...e})),...e.labelPosition?{labelPosition:{...e.labelPosition}}:{}}))}}function tq(e,t,i,r){e.forEach((e,t)=>{e.x!==i[t].x&&(e.x=i[t].x),e.y!==i[t].y&&(e.y=i[t].y)}),t.forEach((e,t)=>{let i=r[t];tX(i,e)&&(e.points=i.points),(i.labelPosition?.x!==e.labelPosition?.x||i.labelPosition?.y!==e.labelPosition?.y)&&(e.labelPosition=i.labelPosition),i.routeCertificate!==e.routeCertificate&&(e.routeCertificate=i.routeCertificate)})}function tQ(e,t,i){for(let r of i)if(r!==e){for(let e=1;e<r.points.length;e++)if(function(e,t,i,r=2){let n=i.x-r,o=i.x+i.w+r,a=i.y-r,s=i.y+i.h+r;if(.01>Math.abs(e.x-t.x)){let i=Math.min(e.y,t.y),r=Math.max(e.y,t.y);return e.x>=n&&e.x<=o&&r>=a&&i<=s}if(.01>Math.abs(e.y-t.y)){let i=Math.min(e.x,t.x),r=Math.max(e.x,t.x);return e.y>=a&&e.y<=s&&r>=n&&i<=o}return!1}(r.points[e-1],r.points[e],t))return!0}return!1}function tK(e,t){for(let i=1;i<e.length;i++)for(let r=1;r<t.length;r++){let n=e[i-1],o=e[i],a=t[r-1],s=t[r],l=(o.x-n.x)*(s.y-a.y)-(o.y-n.y)*(s.x-a.x);if(1e-9>Math.abs(l))continue;let d=((a.x-n.x)*(s.y-a.y)-(a.y-n.y)*(s.x-a.x))/l,h=((a.x-n.x)*(o.y-n.y)-(a.y-n.y)*(o.x-n.x))/l;if(d>.001&&d<.999&&h>.001&&h<.999)return!0}return!1}function tJ(e,t,i){let r=new Map(t.map(e=>[e.edge,e])),n=new Set,o=e.map((e,t)=>{let i=r.get(e);return i?(n.add(t),{...e,points:i.points,labelPosition:i.label}):e}),{nodes:a,style:s}=i;return $({nodes:a,edges:o},s,n).total<=$({nodes:a,edges:e},s,n).total}function tZ(e,t,i,r){let n=new Map(t.map(e=>[e.edge,e.points])),o=new Set,a=e.map((e,t)=>{let i=n.get(e);return i?(o.add(t),{...e,points:i}):e});for(let t of o){let r=e[t],n=a[t];if(J(r,n.points,a,i,n))return"marker-blocked"}if(r?.labelClearance&&!tJ(e,t,r.labelClearance))return!1;let s=F(a,o)-F(e,o);if(!r?.allowCrossingsForOverlap)return s<=0;let l=_(e,o)-_(a,o);return!(l<0)&&(s<=0||s<=l)}function t0(e,t,i){if(!t)return;let r=i?0:e.length-1,n=i?1:-1,o=e[r];if(!o)return!1;for(let i=r+n;i>=0&&i<e.length;i+=n){let r=e[i];if(r.x!==o.x||r.y!==o.y)return eo(t,o,r)}return!1}function t1(e,t,i){let r={...e,points:e.points.filter((t,i)=>0===i||t.x!==e.points[i-1].x||t.y!==e.points[i-1].y).map(e=>({...e}))};return d(r,t,i),t&&(r.points=ed(r.points,t,!0)),i&&(r.points=ed(r.points,i,!1)),r}function t2(e,t,i,r){if(e.length<2||void 0===i&&void 0===r)return e;let n=e.map(e=>({...e})),o=t?"x":"y";for(let[e,t,a]of[[i,0,1],[r,n.length-1,n.length-2]]){if(void 0===e)continue;let i=n[t],r=n[a];i[o]+=e,r[o]===i[o]-e&&(r[o]+=e)}return n}function t5(e,t,i){let r=[];for(let n of i)e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height&&(r.push(n),r.push(...t5(e,t,n.children)));return r}function t6(e,t,i,r,n){let o="LR"===n,a="RL"===n,s=o||a,l=new Set(t5(t,i,r).map(e=>e.id)),d=t5(s?e:t,s?i:e,r).find(e=>!l.has(e.id));return d?o?d.x-12:a?d.x+d.width+12:"BT"===n?d.y+d.height+12:d.y-12:e}function t4(e,t){let i=new Set(e),r=new Map(e.map((e,t)=>[e,t])),n=new Map(e.map(e=>[e,new Set])),o=new Map(e.map(e=>[e,0])),a=(e,t)=>{let i=new Set,r=[e];for(;r.length>0;){let e=r.pop();if(e===t)return!0;if(!i.has(e))for(let t of(i.add(e),n.get(e)??[]))r.push(t)}return!1};for(let e of t){if(e.source===e.target||!i.has(e.source)||!i.has(e.target))continue;let t=e.source,r=e.target,s=n.get(t);s.has(r)||a(r,t)||(s.add(r),o.set(r,(o.get(r)??0)+1))}let s=(e,t)=>(r.get(e)??0)-(r.get(t)??0),l=e.filter(e=>(o.get(e)??0)===0).sort(s),d=e=>{let t=l.length;for(l.push(e);t>0;){let i=t-1>>>1;if(0>=s(l[i],e))break;l[t]=l[i],t=i}l[t]=e},h=[];for(;l.length>0;){let e=l[0],t=l.pop();if(l.length){let e=0;for(;2*e+1<l.length;){let i=2*e+1;if(i+1<l.length&&0>s(l[i+1],l[i])&&i++,0>=s(t,l[i]))break;l[e]=l[i],e=i}l[e]=t}for(let t of(h.push(e),Array.from(n.get(e)??[]).sort(s))){let e=(o.get(t)??0)-1;o.set(t,e),0===e&&d(t)}}if(h.length<e.length){let t=new Set(h);h.push(...e.filter(e=>!t.has(e)).sort(s))}return h}function t8(e,t,i,r,n="TB",o,a){let s=a??eP(t,r,"node");if("state-fork"===i||"state-join"===i){let e=o?.forkWidth??70,t=o?.forkHeight??10;return"LR"===n||"RL"===n?{width:t,height:e}:{width:e,height:t}}if("state-choice"===i)return{width:36,height:36};if("state-history"===i)return{width:32,height:32};let l=s.width+2*r.nodePaddingX,d=s.height+2*r.nodePaddingY;if("service"===i&&(l=Math.max(l+34,120),d=Math.max(d+6,48)),"diamond"===i){let e=Math.max(l,d)+r.diamondExtraPadding;l=e,d=e}if("circle"===i||"doublecircle"===i){let e=Math.ceil(Math.sqrt(l*l+d*d))+8;d=l="doublecircle"===i?e+12:e}return"ellipse"===i&&(l=Math.ceil(l*Math.SQRT2),d=Math.ceil(d*Math.SQRT2)),"hexagon"===i&&(l+=r.nodePaddingX),("trapezoid"===i||"trapezoid-alt"===i||"lean-r"===i||"lean-l"===i)&&(l+=r.nodePaddingX),"asymmetric"===i&&(l+=12),"cylinder"===i&&(d+=14),"state-start"===i||"state-end"===i?{width:28,height:28}:{width:l=Math.max(l,60),height:d=Math.max(d,36)}}function t3(e,t){let i=new Map;if(eU("APL_NO_CORANK_FANIN"))return i;let r=new Map;for(let t=0;t<e.edges.length;t++){let i=e.edges[t];i.source!==i.target&&(r.has(i.target)||r.set(i.target,[]),r.get(i.target).push(t))}for(let[n,o]of r){if(o.length<2)continue;let r=o.filter(t=>!!e.edges[t].label),a=o.filter(t=>!e.edges[t].label);if(0===r.length||0===a.length)continue;let s=e.nodes.get(n)?.shape;if(void 0===s||!eb.has(s))continue;let l=t=>e.nodes.get(t)?.shape==="rectangle";if(!o.every(t=>l(e.edges[t].source)))continue;let d=0,h=0;for(let i of r){let r=eP(e9(e.edges[i].label,e.edges[i].labelContent),t,"edge");r.text,d=Math.max(d,r.width+8),h=Math.max(h,r.height+6)}for(let e of a)i.set(e,{width:d,height:h})}return i}function t9(e){return{text:" ",width:e.width,height:e.height,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}}function t7(e,t){return t>em({})&&function(e){let t=new Map,i=new Map;for(let{source:r,target:n}of e){if(r===n)return!0;t.set(r,t.get(r)??0),t.set(n,(t.get(n)??0)+1),i.set(r,[...i.get(r)??[],n])}let r=[...t].filter(([,e])=>0===e).map(([e])=>e),n=0;for(let e=r.pop();void 0!==e;e=r.pop())for(let o of(n++,i.get(e)??[])){let e=t.get(o)-1;t.set(o,e),0===e&&r.push(o)}return n<t.size}(e.edges)?{"elk.spacing.edgeNode":String(t)}:{}}function ie(e,t,i){var r;let n,o,a,s,l,d,g,{hook:u,corridor:f}=function(e,t){let i=em(e),r=0;for(let[n,o]of t.edges.entries()){if("invisible"===o.style)continue;let a={...o,inlineStyle:eK(n,t)},s=em(e,a,"start"),l=em(e,a,"end");i=Math.max(i,s,l),r=Math.max(r,(o.hasArrowStart?s-(e.edgeBendRadius??0):0)+(o.hasArrowEnd?l-(e.edgeBendRadius??0):0))}return{hook:i,corridor:r}}(i,e);t={...t,layerSpacing:Math.max(t.layerSpacing??eO.layerSpacing,f),markerPortExtents:t.preserveSubgraphChildOrder||t.stateVisual?void 0:function(e,t){let i=new Map;for(let r=0;r<e.edges.length;r++){let n=e.edges[r],o=e.nodes.get(n.target);if(!o||"rectangle"!==o.shape||o.semanticShape||"invisible"===n.style||n.source===n.target)continue;let a=i.get(o.id)??{count:0,span:0,known:!0};a.count++;let s="thick"===n.style?2:1,l=t.lineWidth*s,d=(Number.isFinite(l)&&l>0?U({...n,curve:void 0,points:[{x:0,y:0},{x:100,y:0}],inlineStyle:eK(r,e)},{...t,lineWidth:Number(tn(l))/s,edgeBendRadius:0}):void 0)?.find(e=>"end"===e.position);!n.hasArrowEnd||d?.bounds&&Object.values(d.bounds).every(Number.isFinite)?d?.bounds&&(a.span=Math.max(a.span,d.bounds.y1-d.bounds.y0)):a.known=!1,i.set(o.id,a)}let r=new Map;for(let[e,t]of i)t.count<2||!t.known||t.span<=0||r.set(e,{count:t.count,span:t.span});return r}(e,i)};let c=new Set,p=new Set;for(let t of e.subgraphs)p.add(t.id),function e(t,i,r){for(let e of t.nodeIds)i.add(e);for(let n of t.children)r.add(n.id),e(n,i,r)}(t,c,p);let y=new Map;for(let t of e.edges)t.source===t.target&&y.set(t.source,(y.get(t.source)??0)+1);let m=Math.max(0,...y.values());m>4&&(t={...t,layerSpacing:Math.max(t.layerSpacing,t.layerSpacing+(m-4)*16)});let x=t.disableCorankFanIn?new Map:t3(e,i),b=function(e){let t=new Map;for(let i of e)!function e(i){for(let e of i.nodeIds)t.set(e,i.id);for(let t of i.children)e(t)}(i);return t}(e.subgraphs),w=function(e){let t=new Map;for(let i of e)!function e(i,r){for(let e of i.nodeIds)t.set(e,r);for(let t of i.children)e(t,r)}(i,i.id);return t}(e.subgraphs),M=function(e){let t=new Map;for(let i of e)!function e(i,r){let n=[...r,i.id];for(let e of i.nodeIds)t.set(e,n);for(let t of i.children)e(t,n)}(i,[]);return t}(e.subgraphs),v=function(e){let t=new Map;for(let i of e)!function e(i,r){for(let n of(t.set(i.id,r),i.children))e(n,i.id)}(i,void 0);return t}(e.subgraphs),S=function(e){let t=new Map;for(let i of e)!function e(i,r){let n=[...r,i.id];for(let r of(t.set(i.id,n),i.children))e(r,n)}(i,[]);return t}(e.subgraphs),k=e=>b.get(e)??v.get(e),E=e=>M.get(e)??S.get(e)?.slice(0,-1)??[],P=il(e,t),N=function(e,t){let i=h(e),r=new Set,n=new Set,o=function(e){let t=new Set,i=(e,r)=>{let n=r||void 0!==e.direction;if(n)for(let i of e.nodeIds)t.add(i);for(let t of e.children)i(t,n)};for(let t of e)i(t,!1);return t}(e.subgraphs),a=new Set;for(let t=0;t<e.edges.length;t++){let o=e.edges[t],s=i[t]??"primary-forward";"primary-forward"===s&&o.label&&a.add(`${o.source}\0${o.target}`),"primary-forward"!==s&&(r.add(o.source),r.add(o.target)),"primary-forward"!==s&&"feedback"!==s&&(n.add(o.source),n.add(o.target))}let s=[],l=[],d=e=>e.replace(/[^A-Za-z0-9_\-]/g,"_"),g=(e,t,i)=>{l.push({edgeIndex:e,routeClass:t,reason:i})};for(let l=0;l<e.edges.length;l++){let h=e.edges[l],u=i[l]??"primary-forward";if(h.source===h.target){g(l,u,"self-loop");continue}if(t.has(h.source)||t.has(h.target)){g(l,u,"subgraph-endpoint");continue}if(!e.nodes.has(h.source)||!e.nodes.has(h.target)){g(l,u,"missing-node");continue}if("primary-forward"!==u&&"feedback"!==u){g(l,u,"unsupported-route-class");continue}if("primary-forward"===u&&(r.has(h.source)||r.has(h.target))){g(l,u,"unsafe-non-primary-incident");continue}if("feedback"===u&&h.label){g(l,u,"unsupported-route-class");continue}if("feedback"===u&&a.has(`${h.target}\0${h.source}`)){g(l,u,"labeled-reciprocal-primary");continue}if("feedback"===u&&(!ii(e.nodes.get(h.source))||!ii(e.nodes.get(h.target)))){g(l,u,"unsupported-shape");continue}if(n.has(h.source)||n.has(h.target)){g(l,u,"unsafe-non-primary-incident");continue}if(o.has(h.source)||o.has(h.target)){g(l,u,"direction-override-node");continue}let f=function(e,t){let i=function(e){switch(e){case"RL":return{source:"W",target:"E"};case"BT":return{source:"N",target:"S"};case"TD":case"TB":return{source:"S",target:"N"};default:return{source:"E",target:"W"}}}(e);return"feedback"===t?{source:i.target,target:i.source}:i}(e.direction,u);s.push({nodeId:h.source,portId:`rp_${d(h.source)}_${l}_s`,side:f.source,edgeIndex:l,sourceId:h.source,targetId:h.target,endpoint:"source",slotIndex:0,routeClass:u,labeled:!!h.label,constraint:"FIXED_SIDE"}),s.push({nodeId:h.target,portId:`rp_${d(h.target)}_${l}_t`,side:f.target,edgeIndex:l,sourceId:h.source,targetId:h.target,endpoint:"target",slotIndex:0,routeClass:u,labeled:!!h.label,constraint:"FIXED_SIDE"})}let u=new Map;for(let e of s){let t=u.get(e.nodeId)??[];t.push(e),u.set(e.nodeId,t)}for(let t of u.values()){var f;t.sort((e,t)=>ir(e.side)-ir(t.side)||e.edgeIndex-t.edgeIndex||io(e.endpoint)-io(t.endpoint));let i=new Map;for(let e of t){let t=i.get(e.side)??0;e.slotIndex=t,i.set(e.side,t+1)}let r=(f=e.nodes.get(t[0].nodeId),f?.shape==="rectangle"&&function(e){if(e.length<2||!e.every(e=>"primary-forward"===e.routeClass&&!e.labeled))return!1;let t=e[0].side;if(!e.every(e=>e.side===t))return!1;let i=new Map;for(let t of e){let e=`${t.sourceId}\0${t.targetId}`;i.set(e,(i.get(e)??0)+1)}return!![...i.values()].some(e=>e>=2)&&(!!e.every(e=>"target"===e.endpoint)||!!e.every(e=>"source"===e.endpoint)&&e.every(e=>(i.get(`${e.sourceId}\0${e.targetId}`)??0)>=2))}(t));for(let e of t)r?(e.constraint="FIXED_ORDER",e.orderReason="primary-duplicate-face"):(e.constraint="FIXED_SIDE",e.orderReason=void 0)}let c=new Map;for(let e of s)c.set(it(e.edgeIndex,e.endpoint),e);return{byEndpoint:c,byNode:u,relaxations:l}}(e,p),C=new Map,I=new Map,L,R=t=>{L??=new Set([...e.nodes.keys(),...p,...[...N.byEndpoint.values()].map(e=>e.portId)]);let i=t;for(;L.has(i);)i+="_";return L.add(i),i},O=(e,t,i)=>{let r=R(`${e}_${i}_${t}`),n=C.get(e)??[];return n.push({id:r,direction:i}),C.set(e,n),r},$=(e,t)=>{let r=p.has(e.source)&&E(e.target).includes(e.source),n=p.has(e.target)&&E(e.source).includes(e.target),o=r?S.get(e.source):E(e.source),a=n?S.get(e.target):E(e.target),s=ig(o,a),l=s?o.indexOf(s)+1:0,d=r?O(e.source,t,"in"):N.byEndpoint.get(it(t,"source"))?.portId??e.source,h=n?O(e.target,t,"out"):N.byEndpoint.get(it(t,"target"))?.portId??e.target,g=0,u=(r,n,o,a=!1)=>{let s=a?function(e,t,i,r,n,o){let a={id:`e${e}`,sources:[i],targets:[r]};if(t.label&&!eU("APL_DECOUPLE_LABELS")){let e=eP(e9(t.label,t.labelContent),n,"edge");a.labels=[{text:e.text,width:e.width+8,height:e.height+6,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}]}else!t.label&&o?.has(e)&&(a.labels=[t9(o.get(e))]);return a}(t,e,n,o,i,x):{id:`e${t}_internal_${g}`,sources:[n],targets:[o]},l={...s,id:R(s.id),hierarchySegment:{edgeIndex:t,order:g++}},d=I.get(r??null)??[];d.push(l),I.set(r??null,d)};for(let e of o.slice(l).reverse()){let i=O(e,t,"out");u(e,d,i),d=i}let f=a.slice(l).map(e=>({scope:e,port:O(e,t,"in")}));u(s,d,f[0]?.port??h,!0);for(let e=0;e<f.length;e++){let t=f[e];u(t.scope,t.port,f[e+1]?.port??h)}},z=new Map;z.set(null,[]);for(let t=0;t<e.edges.length;t++){let i=e.edges[t],r=k(i.source),n=k(i.target);if(r&&r===n)z.has(r)||z.set(r,[]),z.get(r).push({index:t,edge:i});else if(r||n)if(P)$(i,t);else{let e=ig(E(i.source),E(i.target));e?(z.has(e)||z.set(e,[]),z.get(e).push({index:t,edge:i})):z.get(null).push({index:t,edge:i})}else z.get(null).push({index:t,edge:i})}let A={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":e4(e.direction),"elk.spacing.nodeNode":String(t.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(t.layerSpacing),"elk.spacing.edgeEdge":"12","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":String(u),...t7(e,u),"elk.padding":`[top=${t.padding},left=${t.padding},bottom=${t.padding},right=${t.padding}]`,"elk.edgeRouting":"ORTHOGONAL","elk.layered.nodePlacement.bk.fixedAlignment":"BALANCED","elk.contentAlignment":"H_CENTER V_CENTER","elk.layered.thoroughness":String(eO.thoroughness),"elk.layered.highDegreeNodes.treatment":"true","elk.layered.highDegreeNodes.threshold":"8","elk.layered.compaction.postCompaction.strategy":"LEFT_RIGHT_CONSTRAINT_LOCKING","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.layered.feedbackEdges":"true","elk.layered.crossingMinimization.forceNodeModelOrder":"true","elk.layered.wrapping.strategy":"OFF","elk.hierarchyHandling":P?"SEPARATE":"INCLUDE_CHILDREN"},children:[],edges:[]},B=!t.preserveSubgraphChildOrder,F=new Map(e.subgraphs.map(e=>[e.id,e]));for(let d of(r=!!t.preserveSubgraphChildOrder,n=[],o=new Set,a=e=>{o.has(e)||(o.add(e),n.push(e))},s=()=>{for(let t of e.nodes.keys()){let e=w.get(t);e?a(e):c.has(t)||p.has(t)||a(t)}},l=()=>{for(let t of e.subgraphs)a(t.id)},r?(l(),s()):(s(),l()),t4(n,e.edges.map(e=>({source:w.get(e.source)??e.source,target:w.get(e.target)??e.target}))))){let r=F.get(d);if(r){A.children.push(function e(t,i,r,n,o,a,s,l,d,h,g,u,f="TB"){let c=ih(t,n),p=t.concurrencyRegion?r.stateVisual?.dividerMargin??0:0,y=t.direction??f,m={"elk.algorithm":"layered","elk.padding":`[top=${c+n.groupPaddingY+p},left=${n.groupPaddingX+p},bottom=${n.groupPaddingY+p},right=${n.groupPaddingX+p}]`,"elk.edgeRouting":"ORTHOGONAL","elk.contentAlignment":"H_CENTER V_CENTER","elk.spacing.edgeEdge":"12","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":String(o),...t7(i,o),"elk.layered.nodePlacement.bk.fixedAlignment":"BALANCED","elk.layered.spacing.nodeNodeBetweenLayers":String(r.layerSpacing),"elk.spacing.nodeNode":String(r.nodeSpacing)};(t.direction||u)&&(m["elk.direction"]=e4(y));let x=id(t,n);x>0&&u&&(m["elk.nodeSize.constraints"]="MINIMUM_SIZE",m["elk.nodeSize.minimum"]=`(${x}, 0)`);let b={id:t.id,layoutOptions:m,labels:t.label?[{text:t.label}]:void 0,children:[],edges:[],...void 0!==t.headerMinHeight&&0===t.nodeIds.length&&0===t.children.length?{width:Math.max(x,2*n.groupPaddingX),height:c+2*n.groupPaddingY}:{}},w=s.get(t.id)??[];if(w.length>0){let e=c>0,t=eF(i.direction);b.ports=w.map(i=>{let r="in"===i.direction?t.targetSide:t.sourceSide,n="N"===r?"in"===i.direction?"W":"E":r;return{id:i.id,...e&&("N"===r||"BT"===y)?{layoutOptions:{"elk.port.side":ia(n)}}:{}}}),e&&(b.layoutOptions["elk.portConstraints"]="FIXED_SIDE")}for(let e of h?t4(t.nodeIds,i.edges):t.nodeIds){let t=i.nodes.get(e);t&&b.children.push(is(e,t,n,d,y,r.stateVisual,r.nodeSizes?.get(e),r.markerPortExtents?.get(e)))}for(let f of t.children)b.children.push(e(f,i,r,n,o,a,s,l,d,h,g,u,y));for(let{index:e,edge:i}of a.get(t.id)??[]){let t={id:`e${e}`,sources:[d.byEndpoint.get(it(e,"source"))?.portId??i.source],targets:[d.byEndpoint.get(it(e,"target"))?.portId??i.target]};if(i.label&&!eU("APL_DECOUPLE_LABELS")){let e=eP(e9(i.label,i.labelContent),n,"edge");t.labels=[{text:e.text,width:e.width+8,height:e.height+6,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}]}else!i.label&&g.has(e)&&(t.labels=[t9(g.get(e))]);b.edges.push(t)}for(let e of l.get(t.id)??[])b.edges.push(e);return b}(r,e,t,i,u,z,C,I,N,B,x,P,e.direction));continue}let n=e.nodes.get(d);!n||c.has(d)||p.has(d)||A.children.push(is(d,n,i,N,e.direction,t.stateVisual,t.nodeSizes?.get(d),t.markerPortExtents?.get(d)))}for(let{index:e,edge:t}of z.get(null)){let r={id:`e${e}`,sources:[N.byEndpoint.get(it(e,"source"))?.portId??t.source],targets:[N.byEndpoint.get(it(e,"target"))?.portId??t.target]};if(t.label&&!eU("APL_DECOUPLE_LABELS")){let e=eP(e9(t.label,t.labelContent),i,"edge");r.labels=[{text:e.text,width:e.width+8,height:e.height+6,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}]}else!t.label&&x.has(e)&&(r.labels=[t9(x.get(e))]);A.edges.push(r)}for(let e of I.get(null)??[])A.edges.push(e);return function(e,t,i){if(!i)return;let r=new Map,n=e=>{for(let t of e.children??[])r.set(t.id,{node:t,parent:e}),n(t)};n(e);let o=e=>{let i=r.get(e);return i&&t.nodes.has(e)||tp(`unknown node "${e}"`),i},a=new Set;if(i.ranks)for(let[e,t]of Object.entries(i.ranks)){let{node:i,parent:r}=o(e);(!Number.isSafeInteger(t)||t<0||t>1e4)&&tp(`rank for "${e}" must be an integer in [0,10000]`),a.add(r),r.layoutOptions={...r.layoutOptions,"elk.partitioning.activate":"true"},i.layoutOptions={...i.layoutOptions,"elk.partitioning.partition":String(t)}}for(let e of a)for(let t of e.children??[])t.layoutOptions={"elk.partitioning.partition":"0",...t.layoutOptions};let s=new Set;for(let e of i.adjacent??[]){e.length<2&&tp("adjacent needs two or more nodes");let t=e.map(o),i=t[0].parent;for(let r of(t.some(e=>e.parent!==i)&&tp("adjacent nodes need the same container"),e))s.has(r)&&tp("a node cannot repeat in adjacency groups"),s.add(r);let r=i.children,n=Math.min(...t.map(e=>r.indexOf(e.node)));i.children=[...r.slice(0,n),...t.map(e=>e.node),...r.slice(n).filter(t=>!e.includes(t.id))],i.layoutOptions={...i.layoutOptions,"elk.layered.crossingMinimization.forceNodeModelOrder":"true"}}let l=eR(t.edges),d=new Set((i.shortEdges??[]).map(e=>{let t=l.get(e);return void 0===t&&tp(`unknown edge "${e}"`),t})),h=e=>{for(let t of e.edges??[]){let e=/^e(\d+)(?:_|$)/.exec(t.id);e&&d.has(Number(e[1]))&&(t.layoutOptions={...t.layoutOptions,"elk.layered.priority.shortness":"100","elk.layered.priority.direction":"100"})}e.children?.forEach(h)};h(e)}(A,e,t.layoutHints),P&&C.size>0&&(d=e=>"RIGHT"===e||"LEFT"===e,(g=e=>{let t=d(e.layoutOptions?.["elk.direction"]),i=!1;for(let r of e.children??[])void 0!==r.children&&(!i&&C.has(r.id)&&(i=d(r.layoutOptions?.["elk.direction"])!==t||(r.ports??[]).some(e=>{let i=e.layoutOptions?.["elk.port.side"];return t?"NORTH"===i||"SOUTH"===i:"EAST"===i||"WEST"===i})),g(r));i&&e.layoutOptions?.["elk.layered.crossingMinimization.forceNodeModelOrder"]==="true"&&(e.layoutOptions["elk.layered.crossingMinimization.forceNodeModelOrder"]="false",e.layoutOptions["elk.layered.considerModelOrder.strategy"]??="NODES_AND_EDGES")})(A)),A}function it(e,t){return`${e}:${t}`}function ii(e){return e?.shape==="rectangle"||e?.shape==="diamond"}function ir(e){return({N:0,E:1,S:2,W:3})[e]}function io(e){return+("source"!==e)}function ia(e){switch(e){case"N":return"NORTH";case"E":return"EAST";case"S":return"SOUTH";case"W":return"WEST"}}function is(e,t,i,r,n="TB",o,a,s){let l=a??t8(e,e9(t.label,t.labelContent),t.shape,i,n,o,t.labelBlock),d="LR"===n||"RL"===n,h=d?l.height:l.width;if(!a&&s){let e=Math.max(s.span,Math.min(i.cornerRadius??0,(d?l.width:l.height)/2));if(!(h/(s.count+1)>e)){let t=(s.count+1)*(e+1);Number.isFinite(t)&&t>h&&(h=t)}}let g={id:e,width:d?l.width:h,height:d?h:l.height,labels:[{text:t.label}]},u=r.byNode.get(e);if(u&&u.length>0){let e=u.some(e=>"FIXED_ORDER"===e.constraint)?"FIXED_ORDER":"FIXED_SIDE";g.layoutOptions={...g.layoutOptions??{},"elk.portConstraints":e},g.ports=u.map(e=>({id:e.portId,width:0,height:0,layoutOptions:{"elk.port.side":ia(e.side),"elk.port.index":String(e.slotIndex)}}))}return g}function il(e,t){let i=e=>void 0!==e.direction||e.children.some(i);return!0===t.separateHierarchy||e.subgraphs.some(i)}function id(e,t){if(!e.label||e.concurrencyRegion||void 0===e.headerMinHeight&&0===e.nodeIds.length&&0===e.children.length)return 0;let i=eP(e9(e.label,e.labelContent),t,"group").width;return Math.ceil((e.titleOffset??t.groupLabelPaddingX)+i+t.groupLabelPaddingX)}function ih(e,t,i=eP(e9(e.label,e.labelContent),t,"group")){if(e.concurrencyRegion)return 0;let r=t.groupHeaderFontSize+16+i.height-i.lineHeight;if(void 0===e.headerMinHeight)return r;if(!Number.isFinite(e.headerMinHeight)||e.headerMinHeight<=0)throw RangeError("Invalid internal group header minimum");return Math.max(r,e.headerMinHeight)}function ig(e,t){let i;for(let r=0;r<Math.min(e.length,t.length)&&e[r]===t[r];r++)i=e[r];return i}function iu(e,t=!1){let i=new Set;for(let r of e){if(r.source===r.target||t&&!r.label)continue;let e=JSON.stringify([r.source,r.target]);if(i.has(e))return!0;i.add(e)}return!1}var ic=[{id:"extractEdgesRecursively",after:[],mutates:["extract"],determinism:"pure-order",run:e=>{e.elkResult&&function(e,t,i,n,o,a){let s=new Map,l=new Map,d=(e,t,i)=>{for(let r of(l.set(e.id,{x:t,y:i}),e.children??[]))d(r,t+(r.x??0),i+(r.y??0))};d(e,0,0),function e(t,i,r,n,o){if(t.edges)for(let e of t.edges){let t,a=e.hierarchySegment,s=a?.edgeIndex??parseInt(e.id.substring(1),10);if(isNaN(s))continue;let l=e.container?o.get(e.container):void 0,d=l?.x??r,h=l?.y??n,g=[];if(e.sections&&e.sections.length>0){let t=e.sections[0];if(g.push({x:t.startPoint.x+d,y:t.startPoint.y+h}),t.bendPoints)for(let e of t.bendPoints)g.push({x:e.x+d,y:e.y+h});g.push({x:t.endPoint.x+d,y:t.endPoint.y+h})}if(e.labels&&e.labels.length>0){let i=e.labels[0];null!=i.x&&null!=i.y&&(t={x:i.x+(i.width??0)/2+d,y:i.y+(i.height??0)/2+h})}let u=i.get(s)??[];u.push({order:a?.order??0,points:g,labelPosition:t}),i.set(s,u)}if(t.children)for(let a of t.children)e(a,i,r+(a.x??0),n+(a.y??0),o)}(e,s,0,0,l);let h=0;for(let[e,n]of s){let o,s=t.edges[e];if(!s)continue;let l=[];for(let e of n.sort((e,t)=>e.order-t.order)){let t=l.at(-1),i=t?r([t,...e.points]).slice(1):r(e.points),n=i[0],o=i[1],a=t&&n&&1e-6>Math.abs(t.x-n.x)&&1e-6>Math.abs(t.y-n.y),s=t&&n&&o&&(t.x===n.x&&n.x===o.x&&n.y>=Math.min(t.y,o.y)&&n.y<=Math.max(t.y,o.y)||t.y===n.y&&n.y===o.y&&n.x>=Math.min(t.x,o.x)&&n.x<=Math.max(t.x,o.x));l.push(...a||s?i.slice(1):i)}s.label&&l.length>=2&&(o=n.find(e=>e.labelPosition)?.labelPosition??eB(l));let d=function(e,t,i=0){if(e.length<2)return e;let r=!1;for(let t=1;t<e.length;t++){let i=Math.abs(e[t].x-e[t-1].x),n=Math.abs(e[t].y-e[t-1].y);if(i>1&&n>1){r=!0;break}}if(!r)return e;let n=[e[0]];for(let r=1;r<e.length;r++){let o=n[n.length-1],a=e[r],s=Math.abs(a.x-o.x),l=Math.abs(a.y-o.y);if(s>1&&l>1)if(t){let e=i%2==0,r=12*Math.floor(i/2),s=e?t.rightX+r:t.leftX-r;n.push({x:s,y:o.y}),n.push({x:s,y:a.y})}else{let e=(o.y+a.y)/2;n.push({x:o.x,y:e}),n.push({x:a.x,y:e})}n.push(a)}return n}(l,a,h);d!==l&&h++,s.label&&d!==l&&d.length>=2&&(o=eB(d)),i.push({source:s.source,target:s.target,...void 0!==s.id?{id:s.id}:{},label:s.label,...s.labelContent?{labelContent:s.labelContent}:{},style:s.style,hasArrowStart:s.hasArrowStart,hasArrowEnd:s.hasArrowEnd,startMarker:s.startMarker,endMarker:s.endMarker,...s.curve?{curve:s.curve}:{},...s.animate?{animate:!0}:{},...s.animation?{animation:s.animation}:{},points:d,labelPosition:o,inlineStyle:eK(e,t),...s.id&&t.classAssignments.has(s.id)?{classNames:t.classAssignments.get(s.id).split(/\s+/).filter(Boolean)}:{},edgeIndex:e})}}(e.elkResult,e.graph,e.edges,0,0,e.margins),ip(e,e.style)}},{id:"alignLayerNodes",after:["extractEdgesRecursively"],mutates:["positions","edges"],determinism:"in-place",enabled:e=>!!e.elkResult||e.mergeEdges,mayChangeMetrics:{bends:"improve-only",straight:"improve-only"},run:e=>{!function(e,t,i){if(0===e.length)return;let r="LR"===i||"RL"===i,n=new Set,o=new Map;for(let e of t)for(let t of(n.add(`${e.source}:${e.target}`),n.add(`${e.target}:${e.source}`),new Set([e.source,e.target]))){let i=o.get(t)??[];i.push(e),o.set(t,i)}let a=new Map(e.map(e=>[e.id,e])),s=.6*eO.layerSpacing,l=[...e].sort((e,t)=>r?e.x-t.x:e.y-t.y),d=[],h=[l[0]];for(let e=1;e<l.length;e++){let t=(r?l[e].x:l[e].y)-(r?l[e-1].x:l[e-1].y),i=h.some(t=>n.has(`${t.id}:${l[e].id}`));t<=s&&!i?h.push(l[e]):(d.push(h),h=[l[e]])}d.push(h);let g=new Map,u=(e,i)=>{let n=r?i:e.x,o=r?e.y:i;for(let i of t)if(i.source!==e.id&&i.target!==e.id)for(let t=1;t<i.points.length;t++){let r=i.points[t-1],a=i.points[t],s=Math.min(r.x,a.x),l=Math.max(r.x,a.x),d=Math.min(r.y,a.y),h=Math.max(r.y,a.y);if(l>n+.5&&s<n+e.width-.5&&h>o+.5&&d<o+e.height-.5)return!0}return!1};for(let e of d){if(e.length<=1)continue;let t=e.map(e=>r?e.x:e.y),i=Math.min(...t),n=Math.max(...t);if(n-i<=1)continue;let s=(i+n)/2;if(e.some(e=>Math.abs(s-(r?e.x:e.y))>.5&&u(e,s)))continue;let l=new Map(e.flatMap(e=>{let t=s-(r?e.x:e.y);return Math.abs(t)>.5?[[e.id,t]]:[]})),d=new Map(e.map(e=>[e.id,{...e,...r?{x:e.x+(l.get(e.id)??0)}:{y:e.y+(l.get(e.id)??0)}}])),h=new Set,f=!1;for(let e of l.keys())for(let t of o.get(e)??[]){if(h.has(t)||"invisible"===t.style)continue;h.add(t);let e={...t,points:t2(t.points,r,g.get(t.source),g.get(t.target))},i={...t,points:t2(t.points,r,l.get(t.source)??g.get(t.source),l.get(t.target)??g.get(t.target))},n,o;for(let r of[!0,!1]){let s=r?t.source:t.target,l=a.get(s),h=d.get(s)??l,g=t0(e.points,l,r),u;!0===g?u=t0(i.points,h,r):(n??=t1(e,a.get(t.source),a.get(t.target)),o??=t1(i,d.get(t.source)??a.get(t.source),d.get(t.target)??a.get(t.target)),g=t0(n.points,l,r),u=t0(o.points,h,r)),!0===g&&!0!==u&&(f=!0)}}if(!f)for(let t of e){let e=s-(r?t.x:t.y);Math.abs(e)>.5&&(r?t.x=s:t.y=s,g.set(t.id,e))}}if(0!==g.size)for(let e of t)e.points=t2(e.points,r,g.get(e.source),g.get(e.target))}(e.nodes,e.edges,e.graph.direction)}},{id:"equalizePeerNodeDimensions",after:["alignLayerNodes"],mutates:["positions","dimensions"],determinism:"in-place",enabled:e=>!!e.elkResult||e.mergeEdges,run:e=>{!function(e,t,i,r,n){let o=e$(r.edges),a=new Map(e.map(e=>[e.id,e])),s=new Map,l=new Map;for(let e of t)X(e,a,r.direction)&&(s.has(e.target)||s.set(e.target,[]),s.get(e.target).push(e),l.has(e.source)||l.set(e.source,[]),l.get(e.source).push(e));let d=[],h=e=>{if(e.length<2||e.length>5||!e.every(e=>"rectangle"===e.shape)||e.some(e=>K(e,i))||!G(e,r.direction))return;let t=e.map(e=>e.id).sort().join("\0");d.some(e=>e.map(e=>e.id).sort().join("\0")===t)||d.push(e)};for(let e of s.values()){let i=e[0]?.target,r=e.map(e=>a.get(e.source)).filter(Boolean);i&&r.every(e=>t.every(t=>t.source!==e.id||t.target===i))&&h(r)}for(let e of l.values()){let i=e[0]?.source,r=e.map(e=>a.get(e.target)).filter(Boolean);if(!i||!r.every(e=>t.every(t=>t.target!==e.id||t.source===i)&&t.every(t=>t.source!==e.id)))continue;let n=!0;for(let e=0;e<r.length;e++)for(let t=0;t<r.length;t++)e!==t&&o(r[e].id,r[t].id)&&(n=!1);n&&h(r)}let g=!1,u,f=eF(r.direction);for(let t of d){let i=Math.max(...t.map(e=>e.width)),n=Math.max(...t.map(e=>e.height));if(t.every(e=>.5>Math.abs(e.width-i)&&.5>Math.abs(e.height-n)))continue;u??=e.map(e=>({...e}));let o=[...t].sort((e,t)=>e_(e,r.direction)-e_(t,r.direction)),a=Math.min(...o.map(e=>e_(e,r.direction))),l=Math.min(...o.map(e=>eT(e,r.direction))),d=[];for(let e of o)d.push({node:e,x:f.isHorizontal?l:a,y:f.isHorizontal?a:l}),a+=(f.isHorizontal?n:i)+24;let h=new Set(t.map(e=>e.id)),c=(e,t,i,r)=>e<r-.01&&i<t-.01,p=e=>{let t=f.isHorizontal?e.x:e.y;return[t,t+(f.isHorizontal?e.width:e.height)]},y=e=>{let t=f.isHorizontal?e.y:e.x;return[t,t+(f.isHorizontal?e.height:e.width)]},m=d.map(({node:e,x:t,y:r})=>({id:e.id,x:t,y:r,width:i,height:n,orig:p(e)})),x=0,b=new Set;for(let t of m){let[i,r]=p(t),[n,o]=y(t),[a,s]=t.orig;for(let t of e){if(h.has(t.id))continue;let[e,l]=p(t),[d,g]=y(t);c(i,r,e,l)&&!c(a,s,e,l)&&c(n,o,d,g)&&(b.add(t.id),x=Math.max(x,r+24-e))}}let w=new Set,M=e=>{if(!(w.has(e)||h.has(e)))for(let t of(w.add(e),s.get(e)??[]))M(t.source)};for(let e of b)M(e);let v=e.filter(e=>w.has(e.id)),S=new Map(v.map(e=>[e.id,p(e)])),k=[...t,...v].map(e=>({n:e,x:e.x,y:e.y,w:e.width,h:e.height}));if(x>0)for(let e of v)e[f.main]+=x;for(let{node:e,x:t,y:r}of d)e.x=t,e.y=r,e.width=i,e.height=n;let E=new Set([...h,...w]);if([...t,...v].some(t=>{let[i,r]=p(t),[n,o]=y(t),[a,s]=S.get(t.id)??m.find(e=>e.id===t.id).orig;return e.some(e=>{if(E.has(e.id))return!1;let[t,l]=p(e),[d,h]=y(e);return c(i,r,t,l)&&!c(a,s,t,l)&&c(n,o,d,h)})})){for(let e of k)e.n.x=e.x,e.n.y=e.y,e.n.width=e.w,e.n.height=e.h;continue}g=!0}g&&(q(e,r.direction),function(e,t,i,r,n){let o=(e,t)=>Math.min(e.x1,t.x1)-Math.max(e.x0,t.x0)>1e-6&&Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)>1e-6,a=e=>({x0:e.x,y0:e.y,x1:e.x+e.width,y1:e.y+e.height}),s=new Map(e.map(e=>[e.id,e])),l=new Map(t.map(e=>[e.id,e])),d=i.flatMap(e=>{let t=eI(e,n);if(!t)return[];let i=Math.max(4,n.lineWidth*("thick"===e.style?2:1)*2);return[{x0:t.x-i,y0:t.y-i,x1:t.x+t.w+i,y1:t.y+t.h+i}]});for(let i of d)if(t.some((t,r)=>o(i,a(t))&&!o(i,a(e[r]))))return!1;for(let h of i){let i=U(h,n);if(0===i.length)continue;let g=h.points,u=l.get(h.source),f=l.get(h.target);u&&(g=es(g,u,!0)),f&&(g=es(g,f,!1));let c={...h,points:g};for(let e of(ex(t,[c],r,n),g=c.points,[!0,!1])){if(!(e?h.hasArrowStart:h.hasArrowEnd))continue;let t=e?h.source:h.target,i=s.get(t),r=l.get(t),n=e?h.points:[...h.points].reverse(),o=e?g:[...g].reverse(),a=n[0],d=o[0],u=a&&n.find(e=>e.x!==a.x||e.y!==a.y),f=d&&o.find(e=>e.x!==d.x||e.y!==d.y);if(i&&a&&u&&!0===eo(i,a,u)&&(!r||!d||!f||!0!==eo(r,d,f)))return!1}let p=U(c,n);for(let r=0;r<i.length;r++){let n=i[r],s=p[r];if(!n.bounds)continue;if(!s?.bounds)return!1;let l="start"===s.position?h.source:h.target;if(t.some((t,i)=>t.id!==l&&o(s.bounds,a(t))&&!o(n.bounds,a(e[i])))||d.some(e=>o(e,s.bounds)&&!o(e,n.bounds)))return!1}}return!0}(u,e,t,r,n)||e.forEach((e,t)=>{let i=u[t];e.x=i.x,e.y=i.y,e.width=i.width,e.height=i.height}))}(e.nodes,e.edges,e.groups,e.graph,e.style)}},{id:"alignForkRejoinPeerCenters",after:["equalizePeerNodeDimensions"],mutates:["positions"],determinism:"in-place",mayChangeMetrics:{symErr:"improve-only",bends:{worsenBy:2}},enabled:e=>!!e.elkResult||e.mergeEdges,run:e=>{!function(e,t,i,r,n){let o=e$(r.edges),a=new Map(e.map(e=>[e.id,e])),s=new Map;for(let e of t)X(e,a,r.direction)&&(s.has(e.source)||s.set(e.source,[]),s.get(e.source).push(e));let l=e=>t.filter(t=>t.target===e&&X(t,a,r.direction)).length,d=e=>t.filter(t=>t.source===e&&t.target!==e&&X(t,a,r.direction)),h=(e,t)=>{let i=[],r=new Set(t),n=[e];for(;n.length>0;){let e=n.shift();if(!r.has(e.id))for(let t of(r.add(e.id),i.push(e),d(e.id))){let e=a.get(t.target);!e||r.has(e.id)||1===l(e.id)&&n.push(e)}}return i};for(let[l,g]of s){if(3!==g.length)continue;let s=a.get(l);if(!s||"diamond"!==s.shape||K(s,i))continue;let u=[...g].sort((e,t)=>eW(a.get(e.target),r.direction)-eW(a.get(t.target),r.direction)),f=u.map(e=>a.get(e.target)).filter(e=>!!e);if(f.length!==u.length||!f.every(e=>"rectangle"===e.shape&&!K(e,i))||!G(f,r.direction,28))continue;let c=!0;for(let e=0;e<f.length;e++)for(let t=0;t<f.length;t++)e!==t&&o(f[e].id,f[t].id)&&(c=!1);if(!c)continue;let p=f.map(e=>d(e.id));if(!p.every(e=>1===e.length))continue;let y=p[0][0].target;if(!p.every(e=>e[0].target===y))continue;let m=a.get(y);if(!m||K(m,i))continue;let x=new Set(f.map(e=>e.id));for(let e of h(m,x))x.add(e.id);if([...x].some(e=>{let t=a.get(e);return!t||K(t,i)}))continue;let b=(eW(f[0],r.direction)+eW(f[f.length-1],r.direction))/2,w=eW(s,r.direction)-b;.5>=Math.abs(w)||ey(x,e,t,r.direction,w,n)&&(eL("[fork-rejoin] center",s.id,"peer island by",w.toFixed(1)),ec(x,e,t,r.direction,w))}}(e.nodes,e.edges,e.groups,e.graph,e.style)}},{id:"alignPortLanes",after:["alignForkRejoinPeerCenters"],mutates:["positions","edges"],determinism:"in-place",enabled:e=>!!e.elkResult,mayChangeMetrics:{straight:"improve-only",portRate:"improve-only",bends:"improve-only"},run:e=>{!function(e,t,i,r,n){if(!tV(e,t,i))return;let{nodes:o,edges:a}=tY(e,t);!function(e,t,i,r,n){let o="LR"===r||"RL"===r,a=o?"y":"x",s=o?"x":"y",l="LR"===r||"TD"===r?1:-1,d=new Set,h=e=>o?e.height:e.width,u=e=>e[a]+h(e)/2,f=new Map(e.map(e=>[e.id,e])),c=[],p=e=>{for(let t of e)c.push(t),p(t.children)};p(i);let y=e=>c.some(t=>e.x>=t.x-.5&&e.y>=t.y-.5&&e.x+e.width<=t.x+t.width+.5&&e.y+e.height<=t.y+t.height+.5),m=(e,t,i,r,n,o,a,s)=>e<n+a&&e+i>n&&t<o+s&&t+r>o,x=e=>o?e.width:e.height,b=(t,i,r,n)=>e.some(e=>!n.has(e.id)&&t>e[a]-4&&t<e[a]+h(e)+4&&r>e[s]-4&&i<e[s]+x(e)+4),w=(t,i,r,n)=>e.some(e=>!n.has(e.id)&&t>e[s]-4&&t<e[s]+x(e)+4&&r>e[a]-4&&i<e[a]+h(e)+4),M=(e,t)=>{let i=t?e.length-1:0,r=t?-1:1,n=e[i][a],o=i;for(;o>=0&&o<e.length&&.5>=Math.abs(e[o][a]-n);)o+=r;if(o<0||o>=e.length)return null;let l=e[o],d=e[o-r];return{mainPos:l[s],far:l[a],orthogonal:.5>=Math.abs(l[s]-d[s])}},v=(e,t)=>{let i=t?e.length-1:0,r=t?-1:1,n=e[i][a],o=1/0,l=-1/0;for(let t=i;t>=0&&t<e.length&&!(Math.abs(e[t][a]-n)>.5);t+=r)o=Math.min(o,e[t][s]),l=Math.max(l,e[t][s]);return{ref:n,lo:o,hi:l}},S=(e,t,i,r,n=!1)=>{let o=e.points,s=t?o.length-1:0,l=t?-1:1,d=t?0:o.length-1,h=o[s][a],g=1/0,u=-1/0;for(let e=s;e>=0&&e<o.length&&.5>=Math.abs(o[e][a]-h)&&!(n&&e===d);e+=l)g=Math.min(g,e),u=Math.max(u,e);if(u<g)return!1;let f=e=>e>=g&&e<=u?{...o[e],[a]:o[e][a]+i}:o[e];for(let e=Math.max(1,g);e<=Math.min(o.length-1,u+1);e++)if(A(f(e-1),f(e),r))return!0;return!1},k=(i,r,l,h=!1)=>{if(d.has(i.id)||y(i))return!1;let g=f.get(l.source),c=f.get(l.target);if(b(u(i.id===l.source?c:g),Math.min(g[s]+x(g)/2,c[s]+x(c)/2),Math.max(g[s]+x(g)/2,c[s]+x(c)/2),new Set([l.source,l.target])))return!1;for(let e of t){let t=e.source===i.id,n=e.target===i.id;if(!t&&!n)continue;let o=e===l;if(o&&2===e.points.length&&.5>=Math.abs(e.points[0][a]-e.points[1][a]))continue;if(!o){if(e.points.length<3)return!1;let t=n?e.points[e.points.length-1]:e.points[0];if(!e.points.some(e=>Math.abs(e[a]-t[a])>.5))return!1}let s=new Set([e.source,e.target]),d=v(e.points,n);if(b(d.ref+r,d.lo,d.hi,s))return!1;let g=M(e.points,n);if(g){if(!g.orthogonal)return!1;let e=Math.min(d.ref+r,g.far),t=Math.max(d.ref+r,g.far);if(w(g.mainPos,e,t,s))return!1}let u=f.get(n?e.source:e.target);if(u&&u!==i&&!(o&&h)&&S(e,n,r,u))return!1}let p=o?i.x:i.x+r,k=o?i.y+r:i.y;for(let t of e)if(t!==i&&m(p-8,k-8,i.width+16,i.height+16,t.x,t.y,t.width,t.height))return!1;for(let e of t)if(e.source!==i.id&&e.target!==i.id)for(let t=1;t<e.points.length;t++){let r=e.points[t-1],n=e.points[t];if(Math.max(r.x,n.x)>p+.5&&Math.min(r.x,n.x)<p+i.width-.5&&Math.max(r.y,n.y)>k+.5&&Math.min(r.y,n.y)<k+i.height-.5)return!1}for(let e of t){if(e===l)continue;let t=eI(e,n);if(t&&m(p-8,k-8,i.width+16,i.height+16,t.x,t.y,t.w,t.h))return!1}return!0},E=(e,t,i,r=!1)=>{let n=e.points,o=t?n.length-1:0,l=t?-1:1,d=t?0:n.length-1,h=n[o][a],g=1/0,u=-1/0;for(let e=o;e>=0&&e<n.length&&!(Math.abs(n[e][a]-h)>.5||r&&e===d);e+=l)g=Math.min(g,n[e][s]),u=Math.max(u,n[e][s]),n[e][a]+=i;e.labelPosition&&12>=Math.abs(e.labelPosition[a]-h)&&e.labelPosition[s]>=g-.5&&e.labelPosition[s]<=u+.5&&(e.labelPosition[a]+=i)},P=(e,i,r)=>{for(let n of(o?e.y+=i:e.x+=i,t)){if(n===r||0===n.points.length)continue;let t=n.source===e.id,o=n.target===e.id;if(t&&o){for(let e of n.points)e[a]+=i;n.labelPosition&&(n.labelPosition[a]+=i);continue}o&&E(n,!0,i),t&&E(n,!1,i)}let n=r.points[0],s=r.points[r.points.length-1];2===r.points.length&&.5>=Math.abs(n[a]-s[a])?(r.points=[eM(f.get(r.source))[o?l>0?"E":"W":l>0?"S":"N"],eM(f.get(r.target))[o?l>0?"W":"E":l>0?"N":"S"]],r.labelPosition&&(r.labelPosition[a]=u(f.get(r.source)))):E(r,r.target===e.id,i)},N=e=>{if(e.points.length<2||e.source===e.target)return!1;let t=g(e.points);for(let e=1;e<t.length;e++)if((t[e][s]-t[e-1][s])*l<-.5)return!1;return!0},C=(i,r,a)=>{let s=o?i.x:i.x+r,l=o?i.y+r:i.y;for(let t of e)if(t!==i&&m(s-8,l-8,i.width+16,i.height+16,t.x,t.y,t.width,t.height))return!1;for(let e of t)if(!a.has(`${e.source}->${e.target}`))for(let t=1;t<e.points.length;t++){let r=e.points[t-1],n=e.points[t];if(Math.max(r.x,n.x)>s+.5&&Math.min(r.x,n.x)<s+i.width-.5&&Math.max(r.y,n.y)>l+.5&&Math.min(r.y,n.y)<l+i.height-.5)return!1}for(let e of t){if(a.has(`${e.source}->${e.target}`))continue;let t=eI(e,n);if(t&&m(s-8,l-8,i.width+16,i.height+16,t.x,t.y,t.w,t.h))return!1}return!0},I=new Set,L=e=>t.filter(t=>t.source===e&&N(t)),R=e=>t.filter(t=>t.target===e&&N(t)).length,O=e=>{let t=[],i=new Set,r=[e];for(;r.length>0;){let e=r.shift();if(!i.has(e.id))for(let n of(i.add(e.id),t.push(e),L(e.id))){let e=f.get(n.target);!e||i.has(e.id)||1===R(e.id)&&r.push(e)}}return t},$=e=>2===e.points.length&&Number(tn(e.points[0][a]))===Number(tn(e.points[1][a]))&&Number(tn(e.points[0][s]))!==Number(tn(e.points[1][s])),z=(e,t,i)=>{if(e.routeCertificate)return;let r=f.get(e.source),n=f.get(e.target);if(!r||!n)return;let d=t.has(r.id)?{...r,[a]:r[a]+i}:r,h=t.has(n.id)?{...n,[a]:n[a]+i}:n,g=eM(d)[o?l>0?"E":"W":l>0?"S":"N"],u=eM(h)[o?l>0?"W":"E":l>0?"N":"S"];if(!(![g.x,g.y,u.x,u.y].every(Number.isFinite)||Number(tn(g[a]))!==Number(tn(u[a])))&&!(l>0?Number(tn(g[s]))>=Number(tn(u[s])):Number(tn(g[s]))<=Number(tn(u[s]))))return[g,u]},B=(i,r)=>{let n=new Set(i.map(e=>e.id));for(let t of i){let i=o?t.x:t.x+r,a=o?t.y+r:t.y;for(let r of e)if(!n.has(r.id)&&m(i-8,a-8,t.width+16,t.height+16,r.x,r.y,r.width,r.height))return!1}for(let e of t){let t=n.has(e.source),i=n.has(e.target);if(t===i||0===e.points.length)continue;if($(e)&&!z(e,n,r))return!1;let o=f.get(i?e.source:e.target);if(o&&S(e,i,r,o,!0))return!1}return!0},F=(e,i)=>{let r=new Set(e.map(e=>e.id)),n=new Map;for(let e of t)if(r.has(e.source)!==r.has(e.target)&&$(e)){let t=z(e,r,i);if(!t)return!1;n.set(e,t)}for(let t of e)o?t.y+=i:t.x+=i;for(let e of t){let t=r.has(e.source),o=r.has(e.target);if(t&&o){for(let t of e.points)t[a]+=i;e.labelPosition&&(e.labelPosition[a]+=i)}else n.has(e)?(e.points=n.get(e),e.labelPosition&&(e.labelPosition[a]=e.points[0][a])):o?E(e,!0,i,!0):t&&E(e,!1,i,!0)}return!0};for(let i of eU("APL_NO_CENTER")?[]:e){if(d.has(i.id)||y(i)||!eb.has(i.shape))continue;let e=t.filter(e=>e.target===i.id&&e.source!==i.id&&e.points.length>=2),r=new Map,n=e.length>=2;for(let t of e){if(t.label||!N(t)){n=!1;break}let e=f.get(t.source);if(!e||!eb.has(e.shape)){n=!1;break}r.set(e.id,e)}if(!n||r.size<2||t.filter(e=>e.source===i.id&&e.target!==i.id&&N(e)).length>1)continue;let o=[...r.values()],a=o.map(e=>e[s]+x(e)/2);if(Math.max(...a)-Math.min(...a)>Math.max(...o.map(x))+.6*eO.layerSpacing)continue;let l=o.reduce((e,t)=>e+u(t),0)/o.length-u(i);if(.5>=Math.abs(l)){I.add(i.id);continue}let h=O(i),g=new Set(t.filter(e=>e.source===i.id||e.target===i.id).map(e=>`${e.source}->${e.target}`));if(!(!C(i,l,g)||!B(h,l))&&(eL("[apl] center hub",i.id,"by",l.toFixed(1),"over",o.length,"sources"),F(h,l))){for(let e of h)I.add(e.id),d.add(e.id);for(let t of e)d.add(t.source)}}let T=new Set;if(!eU("APL_NO_FACET")){let i=()=>o?l>0?["NE","SE"]:["NW","SW"]:l>0?["SW","SE"]:["NW","NE"];for(let r of e){if("diamond"!==r.shape||d.has(r.id)||y(r))continue;let e=t.filter(e=>e.source===r.id&&e.target!==r.id&&e.points.length>=2&&N(e));if(2!==e.length||e.some(e=>{let t=f.get(e.target);return!t||!eb.has(t.shape)})||e.some(e=>d.has(e.target)||I.has(e.target)||y(f.get(e.target))))continue;let n=[...e].sort((e,t)=>u(f.get(e.target))-u(f.get(t.target))),[s,h]=i(),g=eS(r),c=[[n[0],s],[n[1],h]],p=eM(r),x=c.map(([e,t])=>({edge:e,src:{x:g[t].x,y:g[t].y},cross:g[t][a]})),b=!o&&c[0]&&c[1]?[{edge:c[0][0],src:{x:p.W.x,y:p.W.y},cross:p.W[a]},{edge:c[1][0],src:{x:p.E.x,y:p.E.y},cross:p.E[a]}]:null,w=e=>{let[t,i]=e.map(e=>{let t=f.get(e.edge.target),i=e.cross-u(t);return{x:o?t.x:t.x+i,y:o?t.y+i:t.y,w:t.width,h:t.height}});return!!(t&&i&&m(t.x-8,t.y-8,t.w+16,t.h+16,i.x,i.y,i.w,i.h))},M=e=>e.every(e=>{let t=f.get(e.edge.target),i=e.cross-u(t);return .5>=Math.abs(i)||k(t,i,e.edge,!0)}),v=e=>!!e&&M(e)&&!w(e),S;if(v(x))S=x;else{if(!v(b))continue;S=b}let P=o?l>0?"W":"E":l>0?"N":"S";for(let e of S){let i=e.edge,r=f.get(i.target),n=e.cross-u(r);if(Math.abs(n)>.5)for(let e of(o?r.y+=n:r.x+=n,t)){if(e===i)continue;let t=e.source===r.id,o=e.target===r.id;if(t&&o){for(let t of e.points)t[a]+=n;e.labelPosition&&(e.labelPosition[a]+=n)}else o?E(e,!0,n):t&&E(e,!1,n)}i.points=[{x:e.src.x,y:e.src.y},eM(r)[P]],i.labelPosition&&(i.labelPosition[a]=e.cross),T.add(i),d.add(i.target)}d.add(r.id)}}if(!eU("APL_NO_SVERTEX"))for(let e of t){if(T.has(e)||e.points.length<2||e.source===e.target)continue;let i=f.get(e.source),r=f.get(e.target);if(!i||!r||"diamond"!==r.shape||d.has(i.id)||d.has(r.id)||y(i)||y(r)||!N(e)||e.label)continue;let n=r[a]+h(r)/2;if(!t.some(t=>{if(t===e||t.target!==r.id||!N(t)||t.points.length<2)return!1;let i=f.get(t.source);return!!i&&Math.abs(i[a]+h(i)/2-n)<=h(r)/2}))continue;let g=r[a]+h(r)/2,c=i[a]+h(i)/2,p=c>g,m=o?p?"S":"N":p?"E":"W",x=eM(r)[m];if(Math.abs(c-g)<.5*(h(r)/2))continue;let w=x[a]-u(i);if(Math.abs(w)>.5&&!k(i,w,e,!0))continue;let M=o?l>0?"E":"W":l>0?"S":"N",v=eM(i)[M],S=Math.min(v[s],x[s]),P=Math.max(v[s],x[s]);if(!((x[s]-v[s])*l<=.5)&&!b(x[a],S,P,new Set([i.id,r.id]))){if(eL("[apl] svertex",e.source,"->",e.target,"into",m,"vertex"),Math.abs(w)>.5)for(let r of(o?i.y+=w:i.x+=w,t)){if(r===e)continue;let t=r.source===i.id,n=r.target===i.id;if(t&&n){for(let e of r.points)e[a]+=w;r.labelPosition&&(r.labelPosition[a]+=w)}else n?E(r,!0,w):t&&E(r,!1,w)}e.points=[{x:eM(i)[M].x,y:eM(i)[M].y},{x:x.x,y:x.y}],T.add(e),d.add(i.id),d.add(r.id)}}let _,H=e=>void 0!==tj(e,t.filter(t=>t.source===e.id&&X(t,f,r)),t,f,i,r,_??=e$(t));for(let e of t){if(T.has(e)||e.points.length<2||e.source===e.target)continue;let i=f.get(e.source),r=f.get(e.target);if(!i||!r||!eb.has(i.shape)||!eb.has(r.shape)||I.has(r.id)||"diamond"===i.shape&&t.some(t=>t!==e&&t.source===e.source&&N(t)))continue;let n=u(i)-u(r);if(.5>=Math.abs(n)||!N(e)||g(e.points).length>4)continue;let o=k(r,n,e)?r:!H(i)&&k(i,-n,e)?i:null;o&&(eL("[apl] slide",o.id,"by",(o===r?n:-n).toFixed(1),"for",e.source,"->",e.target),P(o,o===r?n:-n,e),d.add(e.source),d.add(e.target))}}(o,a,i,r,n);let s=tU();(tG(o,a,e,t,i,n,s)||!(s.remaining<0)&&(ex(o,a.filter((e,i)=>tX(e,t[i])),{direction:r},n),tG(o,a,e,t,i,n,s)))&&(H({nodes:o,edges:a},!0)+1e-6<H({nodes:e,edges:t},!0)||tq(e,t,o,a))}(e.nodes,e.edges,e.groups,e.graph.direction,e.style)}},{id:"centerPeerBarycenters",proposal:!0,after:["alignPortLanes"],mutates:["positions"],determinism:"in-place",mayChangeMetrics:{symErr:"improve-only",bends:{worsenBy:2}},enabled:e=>!!e.elkResult||e.mergeEdges,run:e=>{let t;return function(e,t,i,r,n,o){let a=e$(r.edges),s=new Map(e.map(e=>[e.id,e])),l=!eU("APL_NO_CORANK_FANIN"),d=(e,t,n=!1)=>{if(e.length<2||e.length>6)return;let o=e[0].style;if(e.some(e=>e.style!==o)||!n&&e.some(e=>e.label))return;let l=e.map(e=>e[t]);if(new Set(l).size!==l.length)return;let d=l.map(e=>s.get(e)).filter(e=>!!e);if(d.length!==l.length)return;let h="source"===t?e=>eb.has(e.shape):e=>"rectangle"===e.shape;if(d.every(e=>h(e)&&!K(e,i))&&G(d,r.direction,28)){for(let e=0;e<d.length;e++)for(let t=0;t<d.length;t++)if(e!==t&&a(d[e].id,d[t].id))return;return d}};for(let a=0;a<3;a++){let a=new Map,h=new Map;for(let e of t)X(e,s,r.direction)&&(a.has(e.source)||a.set(e.source,[]),a.get(e.source).push(e),h.has(e.target)||h.set(e.target,[]),h.get(e.target).push(e));let g=!1,u=e=>e.reduce((e,t)=>e+eW(t,r.direction),0)/e.length,f=(e,i)=>i.every(i=>t.every(t=>t.source!==i.id&&(t.target!==i.id||t.source===e))),c=(e,t)=>t.length>=2&&t.length<=3&&f(e,t),p=(a,s,l)=>{if(!a||!eb.has(a.shape)||K(a,i))return;let d=l?u(l):void 0,h=s?u(s):void 0;if(void 0!==d&&void 0!==h&&s.length>=4&&f(a.id,s)&&Math.abs(d-h)>1.5){let i=new Set(s.map(e=>e.id)),l=new Set([a.id]),u=d-h,f=d-eW(a,r.direction);if(ey(i,e,t,r.direction,u,n)&&ey(l,e,t,r.direction,f,n)){o?.(),ec(i,e,t,r.direction,u),Math.abs(f)>.5&&ec(l,e,t,r.direction,f),eL("[peer-barycenter] trunk-shift",a.id,"outs by",u.toFixed(1)),g=!0;return}}let p=[];if(void 0!==d&&p.push(d),void 0===h||s&&c(a.id,s)||p.push(h),0===p.length&&void 0!==h&&p.push(h),0===p.length)return;let y=(1===p.length?p[0]:(Math.min(...p)+Math.max(...p))/2)-eW(a,r.direction);if(.5>=Math.abs(y))return;let m=new Set([a.id]);ey(m,e,t,r.direction,y,n)&&(eL("[peer-barycenter] center",a.id,"by",y.toFixed(1),2===p.length?"(mixed)":""),o?.(),ec(m,e,t,r.direction,y),g=!0)};for(let e of[...new Set([...a.keys(),...h.keys()])].sort()){let t=a.get(e),i=h.get(e),r=t?d(t,"target"):void 0,n=i?d(i,"source",l):void 0;p(s.get(e),r,n)}if(!g)break}}(e.nodes,e.edges,e.groups,e.graph,e.style,()=>{let i,r;t??=(i=e.nodes.map(e=>({node:e,x:e.x,y:e.y})),r=e.edges.map(e=>({edge:e,points:e.points.map(e=>({...e})),labelPosition:e.labelPosition?{...e.labelPosition}:void 0})),()=>{for(let{node:e,x:t,y:r}of i)e.x=t,e.y=r;for(let{edge:e,points:t,labelPosition:i}of r)e.points=t,e.labelPosition=i})}),t}},{id:"honorLinkRankDistance",after:["centerPeerBarycenters"],mutates:["positions"],determinism:"in-place",enabled:e=>!!e.elkResult||e.mergeEdges,run:e=>{!function(e,t,i,r){if(!r.edges.some(e=>(e.length??1)>1))return;let n=h(r),o=eF(r.direction),a=new Map(e.map(e=>[e.id,e])),l=new Map,d=e=>{for(let t of e)l.set(t.id,t),d(t.children)};d(i);let u=(e,t)=>{for(let i of e.nodeIds)t.push(i);for(let i of e.children)u(i,t)},f=e=>{if(a.has(e))return[e];let t=eX(r.subgraphs,e);if(!t)return[];let i=[];return u(t,i),i},c=new Map,p=(e,t)=>{for(let i of e){let e=[...t,i.id];for(let t of i.nodeIds)c.set(t,e);p(i.children,e)}};p(r.subgraphs,[]);let y=(e,t)=>{if(l.has(t))return f(t);let i=c.get(t)??[],r=new Set(c.get(e)??[]);for(let t of(l.has(e)&&r.add(e),i))if(!r.has(t))return f(t);return[t]},m=e=>{let t=r.edges[e];return"feedback"===n[e]?{source:t.target,target:t.source}:{source:t.source,target:t.target}},x=e=>{let t=a.get(e);if(t)return{start:t[o.main],size:eD(t,r.direction)};let i=l.get(e);return i?{start:i[o.main],size:"x"===o.main?i.width:i.height}:null},b=e=>{let t=x(e);return t?1===o.sign?t.start:t.start+t.size:null},w=e=>{let t=x(e);return t?1===o.sign?t.start+t.size:t.start:null},M=(e,t)=>{let i=w(e),r=b(t);return null!==i&&null!==r&&(r-i)*o.sign>0},v=new Map;for(let e=0;e<r.edges.length;e++){let t=m(e);if(M(t.source,t.target))for(let e of f(t.source))for(let i of f(t.target))v.has(e)||v.set(e,[]),v.get(e).push(i)}let S=new Map,k=new Set,E=(e,t)=>{if(.5>Math.abs(t))return;let i=new Set,r=[...e];for(;r.length>0;){let e=r.pop();if(i.has(e))continue;i.add(e);let n=a.get(e);if(n){let i=n[o.main];n[o.main]+=t,n[o.main]!==i&&k.add(n),S.set(e,(S.get(e)??0)+t)}for(let t of v.get(e)??[])r.push(t)}},P=new Map,N=e=>{let t=1/0,i=1/0,n=-1/0,o=-1/0,s=eX(r.subgraphs,e.id);for(let e of s?.nodeIds??[]){let r=a.get(e);r&&(t=Math.min(t,r.x),i=Math.min(i,r.y),n=Math.max(n,r.x+r.width),o=Math.max(o,r.y+r.height))}for(let r of e.children)t=Math.min(t,r.x),i=Math.min(i,r.y),n=Math.max(n,r.x+r.width),o=Math.max(o,r.y+r.height);return Number.isFinite(t)?{x:t,y:i,r:n,b:o}:null},C=e=>{for(let t of e.children)C(t);let t=N(e);t&&P.set(e.id,{l:t.x-e.x,t:t.y-e.y,r:e.x+e.width-t.r,b:e.y+e.height-t.b})},I=e=>{for(let t of e.children)I(t);let t=N(e),i=P.get(e.id);t&&i&&(e.x=t.x-i.l,e.y=t.y-i.t,e.width=t.r+i.r-e.x,e.height=t.b+i.b-e.y)};for(let e of i)C(e);let L=(e,t)=>{let i=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),r=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);return i>.5&&r>.5},R=(e,t)=>e.id<t.id?`${e.id}\0${t.id}`:`${t.id}\0${e.id}`,O=new Set;for(let t=0;t<e.length;t++)for(let i=t+1;i<e.length;i++)L(e[t],e[i])&&O.add(R(e[t],e[i]));let $=new Map,z=(t,i)=>{let r=e[t],n=e[i],o=t*e.length+i,a=R(r,n);O.has(a)||!L(r,n)?$.delete(o):$.has(o)||$.set(o,{a:r,b:n,key:a,index:o})},B=()=>{if(k.size){if(k.size>e.length/2)for(let t=0;t<e.length;t++)for(let i=t+1;i<e.length;i++)z(t,i);else for(let t=0;t<e.length;t++)if(k.has(e[t]))for(let i=0;i<e.length;i++)t===i||i<t&&k.has(e[i])||z(Math.min(t,i),Math.max(t,i));k.clear()}};for(let e=0;e<r.edges.length;e++){let t=r.edges[e],i=m(e),n=t.length??1;if(n<=1||!M(i.source,i.target))continue;let a=w(i.source),s=b(i.target);if(null===a||null===s)continue;let l=(s-a)*o.sign,d=tl(n,eO.layerSpacing);l<d&&E(y(i.source,i.target),(d-l)*o.sign)}if(!k.size)return;B();let F=(e,t)=>{let i=new Set(c.get(t)??[]);for(let t of c.get(e)??[])if(!i.has(t))return f(t);return[e]};for(let t=0;t<4*e.length;t++){let e;for(let t of $.values())(!e||t.key<e.key||t.key===e.key&&t.index<e.index)&&(e=t);if(!e)break;let{a:t,b:i}=e,n=(ej(t,r.direction)-ej(i,r.direction))*o.sign,[a,s]=(0!==n?n>0:t.id>i.id)?[i,t]:[t,i],l=1===o.sign?a[o.main]+eD(a,r.direction)+eO.nodeSpacing-s[o.main]:s[o.main]+eD(s,r.direction)+eO.nodeSpacing-a[o.main];E(F(s.id,a.id),1===o.sign?l:-l),B()}let T=new Map;for(let[e,t]of l)T.set(e,{start:t[o.main],size:"x"===o.main?t.width:t.height});for(let e of i)I(e);let _=e=>eW(e,r.direction)+eH(e,r.direction)/2,H=e=>eW(e,r.direction)-eH(e,r.direction)/2,D=Math.max(...e.map(_))+10,W=Math.min(...e.map(H))-10,j=(e,t)=>"x"===o.main?{x:e,y:t}:{x:t,y:e},V=(e,t)=>{let i=a.get(e);if(i)return eM(i)[t];let r=l.get(e);if(!r)return null;let n=r.x+r.width/2,o=r.y+r.height/2;switch(t){case"E":return{x:r.x+r.width,y:o};case"W":return{x:r.x,y:o};case"S":return{x:n,y:r.y+r.height};default:return{x:n,y:r.y}}},X=e=>{for(let t of l.values()){if(t.concurrencyRegion||0===t.width)continue;let i=t.headerHeight??t.height;if(!Number.isFinite(i)||i<0)return!1;if(!(0===i||t.width<=0))for(let r=1;r<e.length;r++){let n=e[r-1],o=e[r];if(Math.max(n.x,o.x)>t.x&&Math.min(n.x,o.x)<t.x+t.width&&Math.max(n.y,o.y)>t.y&&Math.min(n.y,o.y)<t.y+i)return!1}}return!0},U=t=>{let i=new Set;for(let r of e)i.add(r[t]),i.add(r[t]+("x"===t?r.width:r.height));for(let e of l.values()){let r=e.concurrencyRegion?0:e.headerHeight??e.height;r>0&&Number.isFinite(r)&&e.width>0&&(i.add(e[t]),i.add(e[t]+("x"===t?e.width:r)))}let r=[...i].sort((e,t)=>e-t),n=[];for(let e=1;e<r.length;e++)r[e]-r[e-1]>2&&n.push((r[e]+r[e-1])/2);return t===o.cross&&l.size&&r.length>0&&n.push(r[0]-10,r.at(-1)+10),n},G="x"===o.main?"y":"x",Y=(e,t)=>[...e].sort((e,i)=>Math.abs(e-t)-Math.abs(i-t)||e-i).slice(0,16),q=new Map,Q=(e,t)=>{for(let i of e)q.set(i.id,t),Q(i.children,i.id)};Q(r.subgraphs);let K=(e,t)=>{if((c.get(t)??[]).includes(e))return!0;for(let i=q.get(t);void 0!==i;i=q.get(i))if(i===e)return!0;return!1},J=(e,t)=>{for(let i of[t.source,t.target]){let t=a.get(i);if(t){for(let i=1;i<e.length;i++)if(A(e[i-1],e[i],t))return!1}}return!0},Z=e=>{let t=a.get(e),i=l.get(e),r=T.get(e);return t?S.get(e)??0:i&&r?i[o.main]-r.start:void 0},ee=(e,t)=>{let i=a.get(e),n=S.get(e)??0,s=new Set(c.get(t)??[]);l.has(t)&&s.add(t);let d=l.has(e)?e:(c.get(e)??[]).find(e=>!s.has(e));if(d&&l.has(d)){let e=T.get(d),t=l.get(d),r=f(d),n=r.length?S.get(r[0])??0:0;if(r.every(e=>(S.get(e)??0)===n)&&("x"===o.main?t.width:t.height)===e.size)return{...e,delta:t[o.main]-e.start};if(!i)return null}return i?{start:i[o.main]-n,size:eD(i,r.direction),delta:n}:null},et=t=>{let i=ee(t.source,t.target),r=ee(t.target,t.source);if(!i||!r||t.points.length<2)return null;let[n,a]=i.start<=r.start?[i,r]:[r,i],s=n.start+n.size,l=a.start,d=l-s,h=l+a.delta-(s+n.delta),g=i.delta===r.delta&&Number.isFinite(i.delta);if(!g&&!(d>0&&h>0&&[s,l,d,h,n.delta,a.delta].every(Number.isFinite)))return null;let u=g?1:h/d;if(!(u>0&&Number.isFinite(u)))return null;let f=e=>g?e+i.delta:e<=s?e+n.delta:e>=l?e+a.delta:s+n.delta+(e-s)*u,c=t.points.map(e=>({...e,[o.main]:f(e[o.main])}));if(c.some(e=>!Number.isFinite(e.x)||!Number.isFinite(e.y)))return null;let p=t.points.map(e=>e[o.main]).sort((e,t)=>e<t?-1:+(e>t));for(let e=1;e<p.length;e++)if(p[e]>p[e-1]&&!(f(p[e])>f(p[e-1])))return null;let y=(e,t)=>e===t||Math.abs(e-t)<=8*Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))&&tn(e)===tn(t);for(let t=1;t<c.length;t++){let i=c[t-1],r=c[t];if(!y(i.x,r.x)&&!y(i.y,r.y))return null;for(let t of e)if(A(i,r,t))return null}let m=Z(t.source),x=Z(t.target);return void 0!==m&&void 0!==x&&c[0][o.main]===t.points[0][o.main]+m&&c.at(-1)[o.main]===t.points.at(-1)[o.main]+x&&er(c,t)&&eu(c,e,new Set([t.source,t.target]))&&X(c)?c:null},ei=(e,t)=>{if(!t)return null;let i=Z(e);return void 0===i?null:{...t,[o.main]:t[o.main]+i}},er=(e,t)=>{for(let[i,r]of[[t.source,!0],[t.target,!1]]){let n,o=a.get(i),d=l.get(i),h=o??(d?{id:d.id,label:d.label,shape:"rectangle",x:d.x,y:d.y,width:d.width,height:d.height}:void 0);if(!h)return!1;let g=r?e[0]:e.at(-1);if(!g)return!1;for(let t=r?1:e.length-2;t>=0&&t<e.length;t+=r?1:-1){let i=e[t];if(i.x!==g.x||i.y!==g.y){n=i;break}}if(!n||!s(h,g))return!1;let u=!o&&K(i,r?t.target:t.source)?{x:g.x-(n.x-g.x),y:g.y-(n.y-g.y)}:n;if(!Number.isFinite(u.x)||!Number.isFinite(u.y)||!eo(h,g,u))return!1}return!0};for(let i of t){let t=void 0!==i.edgeIndex?n[i.edgeIndex]??"primary-forward":"primary-forward";if("self-loop"===t){let e=S.get(i.source)??0;0!==e&&(i.points=i.points.map(t=>({...t,[o.main]:t[o.main]+e}))),0!==e&&i.labelPosition&&(i.labelPosition[o.main]+=e);continue}let s=l.size>0&&("cross-hierarchy"===t||"container"===t),d=s?et(i):null;if(d){i.points=d,i.label&&(i.labelPosition=eB(d));continue}if("feedback"===t){let t=a.get(i.source),n=a.get(i.target);if(!t||!n)continue;let s=ej(t,r.direction),l=ej(n,r.direction),d=(e,i)=>[j(s,i(t)),j(s,e),j(l,e),j(l,i(n))],h=(e,i,r,o)=>[j(s,i(t)),j(s,e),j(r,e),j(r,o),j(l,o),j(l,i(n))],u=(e,i,r,o)=>[j(s,i(t)),j(s,o),j(r,o),j(r,e),j(l,e),j(l,i(n))],f=new Set([i.source,i.target]),c=t=>eu(g(t),e,f)&&X(t),p=[[D,_],[W,H]],y;for(let[e,t]of p){let i=d(e,t);if(c(i)){y=i;break}}if(!y){let e=Y(U("x"===o.main?"x":"y"),l);e:for(let[t,i]of p){let r=Y(U(G),i(n));for(let n of[h,u])for(let o of e)for(let e of r){let r=n(t,i,o,e);if(c(r)){y=g(r);break e}}}}i.points=y??d(D,_),i.label&&(i.labelPosition=eB(i.points));continue}let h=s?ei(i.source,i.points[0]):V(i.source,o.sourceSide),u=s?ei(i.target,i.points.at(-1)):V(i.target,o.targetSide);if(!h||!u)continue;let f=new Set([i.source,i.target]),c=t=>eu(t,e,f)&&X(t)&&(!s||er(t,i)&&J(t,i)),p=Math.min(h[o.main],u[o.main]),y=Math.max(h[o.main],u[o.main]),m=eh(h,u,r.direction,(p+y)/2),x=c(m);if(!x){let e,t=Y(U("x"===o.main?"x":"y").filter(e=>e>p&&e<y),(p+y)/2);for(let i of t){let t=eh(h,u,r.direction,i);if(c(t)){e=t;break}}if(!e){let i=h[G],r=u[G],n=Y(U(G),(i+r)/2);e:for(let a of n)for(let n of t)for(let s of Y(t.filter(e=>(e-n)*o.sign>0),u[o.main])){let t=g([h,j(n,i),j(n,a),j(s,a),j(s,r),u]);if(c(t)){e=t;break e}}}e&&(m=e,x=!0)}if(s&&!x)throw new tr([{strategy:"link-rank-reconnect",violations:[`edge ${i.source}->${i.target}: no proven contact-preserving route after rank move`]}]);i.points=m,i.label&&(i.labelPosition=eB(i.points))}}(e.nodes,e.edges,e.groups,e.graph)}},{id:"alignLabeledSourcePort",after:["honorLinkRankDistance"],mutates:["positions","edges"],determinism:"in-place",mayChangeMetrics:{portRate:"improve-only"},enabled:e=>!!e.elkResult||e.mergeEdges,run:e=>{!function(e,t,i,r,n,o){if(eU("APL_NO_LABELED_SOURCE_PORT")||!tV(e,t,i)||!t.some(e=>e.label))return;let a=tY(e,t);!function(e,t,i,r,n,o){let a=new Set;for(let[n]of tH(e,t,i,r))a.add(n);let s="LR"===n||"RL"===n,l=s?"y":"x",d=s?"x":"y",h=s?"LR"===n?"E":"W":"BT"===n?"N":"S",g=e=>e[l]+(s?e.height:e.width)/2,u=[],f=e=>{for(let t of e)u.push(t),f(t.children)};f(i);let c=e=>u.some(t=>e.x>=t.x-.5&&e.y>=t.y-.5&&e.x+e.width<=t.x+t.width+.5&&e.y+e.height<=t.y+t.height+.5),p=new Map(e.map(e=>[e.id,e])),y=e=>"x"===d?"E"===h?e.x+e.width:e.x:"S"===h?e.y+e.height:e.y,m=(e,i)=>{let r=new Set([e.id]),n=[e.id];for(;n.length;){let e=n.pop();for(let o of t){if(o.target!==e||o===i)continue;let a=p.get(o.source);if(!(!a||r.has(a.id))){if(1!==t.filter(e=>e.source===a.id).length||!eb.has(a.shape)||c(a))return null;r.add(a.id),n.push(a.id)}}}return r};for(let r of t){if(!r.label||r.points.length<2||r.source===r.target||a.has(r.target))continue;let u=p.get(r.source);if(!u||!eb.has(u.shape)||c(u)||t.some(e=>e!==r&&e.source===u.id&&e.target!==u.id)||Math.abs(r.points[0][d]-y(u))>1)continue;let f=p.get(r.target);if(!f||!eb.has(f.shape)||c(f))continue;let{ctx:x,axis:b}=S(e,t,n,o,i),w=0,M=!1,k={...u};for(let e=0;e<4;e++){let e=v(r,k,f,x,b);if(null===e)break;let t=e-g(k);if(w+=t,k[l]+=t,.5>=Math.abs(t)){M=!0;break}}if(!M||1>=Math.abs(w))continue;let E=m(u,r);if(!E)continue;let P=[...E].map(e=>p.get(e)).filter(Boolean),N=e=>({x:s?e.x:e.x+w,y:s?e.y+w:e.y,width:e.width,height:e.height});if(!(e.some(e=>!E.has(e.id)&&P.some(t=>{let i=N(t);return i.x-2<e.x+e.width&&i.x+i.width+2>e.x&&i.y-2<e.y+e.height&&i.y+i.height+2>e.y}))||t.some(e=>!E.has(e.source)&&!E.has(e.target)&&P.some(t=>{let i=N(t);return e.points.some((t,r)=>{if(0===r)return!1;let n=e.points[r-1];return Math.max(t.x,n.x)>i.x+.5&&Math.min(t.x,n.x)<i.x+i.width-.5&&Math.max(t.y,n.y)>i.y+.5&&Math.min(t.y,n.y)<i.y+i.height-.5})})))){for(let e of P)s?e.y+=w:e.x+=w;for(let e of t)if(E.has(e.source)&&E.has(e.target))for(let t of e.points)t[l]+=w;r.points[0]=eM(u)[h]}}}(a.nodes,a.edges,i,r,n,o);let s=tU();if(!tG(a.nodes,a.edges,e,t,i,o,s)){if(s.remaining<0)return;let{ctx:r,axis:l}=S(a.nodes,a.edges,n,o,i);for(let e=0;e<a.edges.length;e++){let i=a.edges[e];if(!i.label||!tX(i,t[e]))continue;let n=a.nodes.find(e=>e.id===i.source),o=a.nodes.find(e=>e.id===i.target);if(!n||!o||!M(i,n,o,r,l,i.points[0][l.cross]).applied)return;E(i,i.routeCertificate,n,o)}let d=Symbol(),h=()=>--s.remaining>=0,g=()=>{if(!h())throw d};try{let r=N({...a,groups:i},o,g),n=(t,n)=>{g();let l=eI(t,o);if(!l)return!1;let d=r.clearPaintRect(l,eC(t,o.lineWidth??1),t);if(!d)return!1;let u={x0:d.x,y0:d.y,x1:d.x+d.w,y1:d.y+d.h};for(let e of a.edges){g();let i=y(e,o,h);if(!i||i.markers.some(e=>(g(),p(u,e.bounds))))return!1;if(e===t)continue;if(i.shafts.some(e=>(g(),p(u,e))))return!1;let r=eI(e,o);if(r){g();let t=eC(e,o.lineWidth??1);if(p(u,{x0:r.x-t,y0:r.y-t,x1:r.x+r.w+t,y1:r.y+r.h+t}))return!1}}return tG(a.nodes,[t],e,[n],i,o,s)};for(let e=0;e<a.edges.length;e++){g();let i=a.edges[e],r=t[e];if(!i.label||!tX(i,r)||n(i,r))continue;let s=eI(i,o),d=i.points[0],h=i.points[1];if(!s||2!==i.points.length)return;let u=Math.hypot(h.x-d.x,h.y-d.y),f=("x"===l.main?s.w:s.h)/2;if(!(u>2*f))return;let c=!1;for(let e of P(f/u,g))if(g(),i.labelPosition={x:d.x+(h.x-d.x)*e,y:d.y+(h.y-d.y)*e},n(i,r)){c=!0;break}if(!c)return}}catch(e){if(e===d)return;throw e}if(!tG(a.nodes,a.edges,e,t,i,o,s))return}tq(e,t,a.nodes,a.edges)}(e.nodes,e.edges,e.groups,e.graph,e.graph.direction,e.style)}},{id:"bundleEdgePaths",after:["alignLabeledSourcePort"],mutates:["edges"],determinism:"pure-order",enabled:e=>e.mergeEdges,run:e=>{e.bundled=function(e,t,i,r,n){let o=new Map(t.map(e=>[e.id,e])),a=new Set,s=(r,a)=>{for(let[e,t]of a){let i=o.get(e.source),r=o.get(e.target);a.set(e,ed(ed(t,i,!0),r,!1))}let s=e.map(e=>a.has(e)?{...e,points:a.get(e)}:e),l=(t,i,r)=>e.some(e=>e.source===t&&e.target===i&&"invisible"!==e.style&&Q(r,e)&&e.hasArrowStart===r.hasArrowStart&&e.hasArrowEnd===r.hasArrowEnd&&(e.startMarker??"arrow")===(r.startMarker??"arrow")&&(e.endMarker??"arrow")===(r.endMarker??"arrow"));return r.filter(r=>{var o;let d,h,g=a.get(r.edge),u=s[e.indexOf(r.edge)];return function(e,t,i,r){let n=(e,t)=>{if(void 0!==e&&!/^\s*[+]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?\s*$/i.test(e))return;let i=void 0===e?t:Number.parseFloat(e);return Number.isFinite(i)&&i>=0?Number(tn(i)):void 0},o=n(e.inlineStyle?.["stroke-width"],r.lineWidth*("thick"===e.style?2:1)),a=r.edgeBendRadius;if(void 0===o||!Number.isFinite(a)||a<0)return!1;let s=ts({stroke:"#000",strokeWidth:String(o)},!0);if(void 0===s)return!1;let l=s+a,d=e.points.map(e=>({x:Number(tn(e.x)),y:Number(tn(e.y))}));if(!d.every(e=>Number.isFinite(e.x)&&Number.isFinite(e.y)))return!1;let h=d.slice(1).map((e,t)=>{let i=d[t];return{x0:Math.min(i.x,e.x)-l,x1:Math.max(i.x,e.x)+l,y0:Math.min(i.y,e.y)-l,y1:Math.max(i.y,e.y)+l}}),g=(e,t)=>{let i=(Math.abs(e.x0)+Math.abs(e.x1)+Math.abs(e.y0)+Math.abs(e.y1)+Math.abs(t.x0)+Math.abs(t.x1)+Math.abs(t.y0)+Math.abs(t.y1))*1e-10+1e-9;return!Number.isFinite(i)||e.x1+i>t.x0&&e.x0<t.x1+i&&e.y1+i>t.y0&&e.y0<t.y1+i},u=Y(e,r);if(!u||u.length!==+!!e.hasArrowStart+ +!!e.hasArrowEnd)return!1;for(let i of t){let t=n(i.inlineStyle?.["stroke-width"],r.nodeLineWidth);if(void 0===t)return!1;let o=ee(i,{fill:"#000",stroke:"#000",strokeWidth:String(t)},r.cornerRadius),a=td(e3({id:i.id,role:"node",geometry:o.geometry,paint:o.paint,...o.childPaints?{childPaints:o.childPaints}:{}}));if(!a||i.id!==e.source&&i.id!==e.target&&h.some(e=>g(e,a)))return!1;for(let t of u)if(("start"===t.position?e.source:e.target)!==i.id&&(!t.bounds||g(t.bounds,a)))return!1}let f=e=>{let t=e.concurrencyRegion?0:e.headerHeight??e.height;if(t>0){let i={x0:e.x,x1:e.x+e.width,y0:e.y,y1:e.y+t};if(h.some(e=>g(e,i))||u.some(e=>!e.bounds||g(e.bounds,i)))return!1}return e.children.every(f)};return i.every(f)}(u,t,i,n)&&!J(r.edge,g,s,n,u)&&(o=r.edge,d=e.filter(e=>e!==o),h=new Set(B(o,d)),!B(u,d).some(e=>!h.has(e)&&(!Q(o,e)||!l(o.source,e.target,o)||!l(e.source,o.target,e))))})},l="LR"===r,d="RL"===r,h="BT"===r,g=l||d,u=(e,t)=>Math.max(...e.map(({edge:e})=>em(n,e,t))),f=new Map;for(let t of e)t.source!==t.target&&(f.has(t.source)||f.set(t.source,[]),f.get(t.source).push(t));for(let[e,t]of f){if(t.length<2)continue;let n=t[0].style;if(t.some(e=>e.label||e.style!==n))continue;let f=o.get(e);if(!f)continue;let c=t.filter(e=>{let t=o.get(e.target);return!!t&&(l?t.x>f.x+f.width:d?t.x+t.width<f.x:h?t.y+t.height<f.y:t.y>f.y+f.height)});if(c.length<2||new Set(c.map(e=>e.target)).size<2)continue;let p=f.x+f.width/2,y=f.y+f.height/2,m=c.map(e=>({edge:e,node:o.get(e.target)}));for(;m.length>=2;){let e=new Map;if(g){let t=l?f.x+f.width:f.x,n=el(t,l?Math.min(...m.map(e=>e.node.x)):Math.max(...m.map(e=>e.node.x+e.node.width)),u(m,"start"),u(m,"end"));for(let{edge:o,node:a}of(n=t6(n,p,y,i,r),m)){let i=l?a.x:a.x+a.width,r=a.y+a.height/2;e.set(o,[{x:t,y:y},{x:n,y:y},{x:n,y:r},{x:i,y:r}])}}else{let t=h?f.y:f.y+f.height,n=el(t,h?Math.max(...m.map(e=>e.node.y+e.node.height)):Math.min(...m.map(e=>e.node.y)),u(m,"start"),u(m,"end"));for(let{edge:o,node:a}of(n=t6(n,p,y,i,r),m)){let i=a.x+a.width/2,r=h?a.y+a.height:a.y;e.set(o,[{x:p,y:t},{x:p,y:n},{x:i,y:n},{x:i,y:r}])}}let t=s(m,e);if(t.length===m.length){for(let{edge:t}of m)t.points=e.get(t);x(m.map(e=>e.edge),a);break}if(new Set((m=t).map(e=>e.edge.target)).size<2)break}}let c=new Map;for(let t of e)a.has(t)||t.source===t.target||(c.has(t.target)||c.set(t.target,[]),c.get(t.target).push(t));for(let[e,t]of c){if(t.length<2)continue;let n=t[0].style;if(t.some(e=>e.label||e.style!==n))continue;let f=o.get(e);if(!f)continue;let c=t.filter(e=>{let t=o.get(e.source);return!!t&&(l?t.x+t.width<f.x:d?t.x>f.x+f.width:h?t.y>f.y+f.height:t.y+t.height<f.y)});if(c.length<2||new Set(c.map(e=>e.source)).size<2)continue;let p=f.x+f.width/2,y=f.y+f.height/2,m=c.map(e=>({edge:e,node:o.get(e.source)}));for(;m.length>=2;){let e=new Map;if(g){let t=l?f.x:f.x+f.width,n=el(l?Math.max(...m.map(e=>e.node.x+e.node.width)):Math.min(...m.map(e=>e.node.x)),t,u(m,"start"),u(m,"end"));for(let{edge:o,node:a}of(n=t6(n,p,y,i,r),m)){let i=l?a.x+a.width:a.x,r=a.y+a.height/2;e.set(o,[{x:i,y:r},{x:n,y:r},{x:n,y:y},{x:t,y:y}])}}else{let t=h?f.y+f.height:f.y,n=el(h?Math.min(...m.map(e=>e.node.y)):Math.max(...m.map(e=>e.node.y+e.node.height)),t,u(m,"start"),u(m,"end"));for(let{edge:o,node:a}of(n=t6(n,p,y,i,r),m)){let i=a.x+a.width/2,r=h?a.y:a.y+a.height;e.set(o,[{x:i,y:r},{x:i,y:n},{x:p,y:n},{x:p,y:t}])}}let t=s(m,e);if(t.length===m.length){for(let{edge:t}of m)t.points=e.get(t);x(m.map(e=>e.edge),a);break}if(new Set((m=t).map(e=>e.edge.source)).size<2)break}}return a}(e.edges,e.nodes,e.groups,e.graph.direction,e.style),e.genericBundled=e.bundled.size>0}},{id:"markCorankFanInBundles",after:["bundleEdgePaths"],mutates:["edges"],determinism:"in-place",enabled:e=>!!e.elkResult||e.mergeEdges,run:e=>{!function(e,t,i,r,n,o){let a=new Map(e.map(e=>[e.id,e])),l=eF(r.direction);for(let[d,h]of tH(e,t,i,r)){let t=a.get(d),i=[...h].sort((e,t)=>eW(a.get(e.source),r.direction)-eW(a.get(t.source),r.direction)),g=i.map(e=>a.get(e.source)),u=eM(t)[l.targetSide],f=(l.isHorizontal?t.height:t.width)/2*1.6,c=Math.min(28,i.length>1?f/(i.length-1):0),p=ea(i.length,c),y=e=>l.isHorizontal?{x:u.x,y:u.y+e}:{x:u.x+e,y:u.y};p.every(e=>s(t,y(e)))||(p=p.map(()=>0));let m=l.isHorizontal?"E"===l.sourceSide?Math.max(...g.map(e=>e.x+e.width)):Math.min(...g.map(e=>e.x)):"S"===l.sourceSide?Math.max(...g.map(e=>e.y+e.height)):Math.min(...g.map(e=>e.y)),b=m+((l.isHorizontal?u.x:u.y)-m)/2,w=[],M=!0;for(let t=0;t<i.length;t++){let n=i[t],o=eh(eM(g[t])[l.sourceSide],y(p[t]),r.direction,b);if(!eu(o,e,new Set([n.source,n.target]))){M=!1;break}w.push({edge:n,points:o})}if(M){for(let{edge:e,points:t}of w)e.points=t,e.routeCertificate=void 0;x(w.map(e=>e.edge),n),t_(w,e,r.direction,o,!0)}}}(e.nodes,e.edges,e.groups,e.graph,e.bundled,e.style)}},{id:"clipEdgeToShape",after:["bundleEdgePaths"],mutates:["edges"],determinism:"in-place",mayChangeMetrics:{portRate:{worsenBy:1,whenImproves:"endpointApproaches"},endpointApproaches:"improve-only"},run:e=>{let t=new Map(e.nodes.map(e=>[e.id,e]));for(let i of e.edges){let r=e.bundled.has(i)?b(i):void 0;i.points=i.points.filter((e,t,i)=>0===t||e.x!==i[t-1].x||e.y!==i[t-1].y);let n=t.get(i.source),o=t.get(i.target);d(i,n,o),n&&(i.points=ed(i.points,n,!0)),o&&(i.points=ed(i.points,o,!1)),w(i,r)}}},{id:"applySymmetricFanoutEmissions",after:["clipEdgeToShape"],mutates:["edges"],determinism:"in-place",mayChangeMetrics:{symErr:"improve-only",bends:{worsenBy:2}},enabled:e=>!!e.elkResult||e.mergeEdges,run:e=>{!function(e,t,i,r,n,o){let a=e$(r.edges),s=new Map(e.map(e=>[e.id,e])),l=new Map;for(let e of t)X(e,s,r.direction)&&(l.has(e.source)||l.set(e.source,[]),l.get(e.source).push(e));let d=eF(r.direction);for(let[h,g]of l){let l=s.get(h),u=l&&tj(l,g,t,s,i,r.direction,a);if(!l||!u)continue;let f=u.map(e=>s.get(e.target)),c="diamond"!==l.shape&&K(l,i);if(c){let{ctx:n,axis:a}=S(e,t,r.direction,o,i),d=eW(l,r.direction),h=u.map(e=>v(e,l,s.get(e.target),n,a));if(h.every((e,t)=>null!==e&&1>=Math.abs(e-d+(h[h.length-1-t]-d))))continue}let p=f.map(e=>({t:e,x:e.x,y:e.y,width:e.width,height:e.height})),y=Z(i).map(e=>({group:e,x:e.x,y:e.y,width:e.width,height:e.height})),m=()=>{for(let e of p)e.t.x=e.x,e.t.y=e.y,e.t.width=e.width,e.t.height=e.height;for(let e of y)e.group.x=e.x,e.group.y=e.y,e.group.width=e.width,e.group.height=e.height},b=Math.max(...f.map(e=>e.width)),w=Math.max(...f.map(e=>e.height)),M=eW(l,r.direction),k=Math.min(...f.map(e=>eT(e,r.direction))),E=(d.isHorizontal?w:b)+28,P=ea(f.length,E),N="diamond"===l.shape?u.map((e,t)=>er(l,r.direction,t,u.length)[d.cross]):void 0,C=e=>{for(let t=0;t<f.length;t++){let i=f[t];i.width=b,i.height=w,d.isHorizontal?(i.x=k,i.y=e[t]-w/2):(i.x=e[t]-b/2,i.y=k)}};c||C(N??P.map(e=>M+e));let I=new Set(f.map(e=>e.id)),L=()=>{for(let e=0;e<f.length;e++){let t=f[e];if(t.x<0||t.y<0)return!1;for(let i=e+1;i<f.length;i++)if(eV(t,f[i],8))return!1}for(let t of f)for(let i of e)if(!I.has(i.id)&&eV(t,i,8))return!1;return!0},R=c||L();if(!R&&N&&(C(P.map(e=>M+e)),R=L()),!R){m();continue}let O=d.isHorizontal?"E"===d.sourceSide?l.x+l.width:l.x:"S"===d.sourceSide?l.y+l.height:l.y,$=d.isHorizontal?d.sign>0?Math.min(...f.map(e=>e.x)):Math.max(...f.map(e=>e.x+e.width)):d.sign>0?Math.min(...f.map(e=>e.y)):Math.max(...f.map(e=>e.y+e.height)),z=Math.max(0,...u.map(e=>(function(e,t,i){if(!e.label)return 0;let r=tC(e,{x:0,y:0},i);return(eF(t).isHorizontal?r.width:r.height)+3*Math.max(tR(i),e.hasArrowEnd?t$(i):tR(i))})(e,r.direction,o))),A=($-O)*d.sign;if(!c&&z>A+.001){let e=z-A,t=f.map(e=>({x:e.x,y:e.y,width:e.width,height:e.height}));for(let t of f)d.isHorizontal?t.x+=e*d.sign:t.y+=e*d.sign;if(ei(i,t,r.direction,e),!(R=L())){m();continue}$=d.isHorizontal?d.sign>0?Math.min(...f.map(e=>e.x)):Math.max(...f.map(e=>e.x+e.width)):d.sign>0?Math.min(...f.map(e=>e.y)):Math.max(...f.map(e=>e.y+e.height))}let B=Math.max(0,...u.map(e=>(function(e,t,i,r,n){if(!e.label)return 0;let o=eF(t),a=tC(e,{x:0,y:0},i),s=o.isHorizontal?a.width:a.height,l=Math.max(tR(i),e.hasArrowEnd?t$(i):tR(i)),d=((n-r)*o.sign-s)/3;return d>=l-.001?s+2*d:s+tR(i)+l+2})(e,r.direction,o,O,$))),F=O+($-O)*.5,_=$-d.sign*B,H=(_-F)*d.sign<0?_:F;if(c&&(H-O)*d.sign<Math.max(...u.map(e=>em(o,e,"start")))-.001)continue;let D=[];for(let t=0;t<u.length;t++){let i=u[t],n=s.get(i.target),o=eh(er(l,r.direction,t,u.length),en(n,r.direction),r.direction,H);if(!eu(o,e,new Set([i.source,i.target]))){R=!1;break}D.push({edge:i,points:o})}if(R&&c){let e=t.filter(e=>!g.includes(e)&&"invisible"!==e.style),i=t=>e.reduce((e,i)=>e+T(t,i.points),0);R=D.reduce((e,{points:t})=>e+i(t),0)<=D.reduce((e,{edge:t})=>e+i(t.points),0)}if(!R){m();continue}let W=D.map(({edge:e,points:t})=>({edge:{...e,points:t},points:t}));if(c&&W.some(({edge:e})=>e.label)){let n=new Map(D.map(({edge:e},t)=>[e,W[t].edge]));if(!tD(W,e,t.map(e=>n.get(e)??e),i,r.direction,o)){m();continue}}else t_(W,e,r.direction,o);for(let e=0;e<D.length;e++){let{edge:t,points:i}=D[e];t.points=i,t.labelPosition=W[e].edge.labelPosition,t.routeCertificate=void 0}x(D.map(e=>e.edge),n)}}(e.nodes,e.edges,e.groups,e.graph,e.bundled,e.style)}},{id:"applySymmetricParallelEdgeLanes",after:["clipEdgeToShape"],mutates:["edges"],determinism:"in-place",enabled:e=>(!!e.elkResult||e.mergeEdges)&&iu(e.edges,!0),mayChangeMetrics:{symErr:"improve-only",crossings:"improve-only"},run:e=>{!function(e,t,i,r,n,o){let a=new Map(e.map(e=>[e.id,e])),l=eF(r.direction),d=new Map;for(let e of t){if(e.source===e.target||!e.label)continue;let t=a.get(e.source),r=a.get(e.target);if(!t||!r||!eb.has(t.shape)||!eb.has(r.shape)||K(t,i)||K(r,i))continue;let n=`${e.source}\0${e.target}`;d.has(n)||d.set(n,[]),d.get(n).push(e)}for(let i of d.values()){if(i.sort((e,t)=>(e.edgeIndex??0)-(t.edgeIndex??0)),2!==i.length)continue;let d=a.get(i[0].source),h=a.get(i[0].target),u=i.map(e=>tC(e,{x:0,y:0},o)),f=u.map(e=>e.width),c=u.map(e=>e.height),p=(l.isHorizontal?Math.max(...c):Math.max(...f))/2+18,y=[[1/3,2/3],[1/6,1/3],[2/3,5/6]],m=[p,p+16,p+32,p+52].map(e=>({lanes:l.isHorizontal?[Math.min(d.y,h.y)-e,Math.max(d.y+d.height,h.y+h.height)+e]:[Math.min(d.x,h.x)-e,Math.max(d.x+d.width,h.x+h.width)+e],sourceSlots:y[0],targetSlots:y[0]}));if("diamond"===d.shape)for(let e of[...m])for(let t of y)for(let i of y){let n=i.map(e=>h[l.cross]+eH(h,r.direction)*e),o=t.map(e=>d[l.cross]+eH(d,r.direction)*e);for(let r of[e.lanes,[e.lanes[0],n[1]],[n[0],e.lanes[1]],[e.lanes[0],o[1]],[o[0],e.lanes[1]]])m.push({lanes:r,sourceSlots:t,targetSlots:i})}for(let{lanes:a,sourceSlots:l,targetSlots:u}of m){let f=[],c=!0;for(let t=0;t<i.length;t++){let n=i[t],o=g(ed(ed(function(e,t,i,r,n,o,a=(n+1)/(o+1),s=a){let l=eF(i);if(l.isHorizontal){let i={x:"E"===l.sourceSide?e.x+e.width:e.x,y:e.y+e.height*a},n={x:"W"===l.targetSide?t.x:t.x+t.width,y:t.y+t.height*s},o=Math.min(28,Math.max(14,.18*Math.abs(n.x-i.x))),d=i.x+l.sign*o,h=n.x-l.sign*o;return g([i,{x:d,y:i.y},{x:d,y:r},{x:h,y:r},{x:h,y:n.y},n])}let d={x:e.x+e.width*a,y:"S"===l.sourceSide?e.y+e.height:e.y},h={x:t.x+t.width*s,y:"N"===l.targetSide?t.y:t.y+t.height},u=Math.min(28,Math.max(14,.18*Math.abs(h.y-d.y))),f=d.y+l.sign*u,c=h.y-l.sign*u;return g([d,{x:d.x,y:f},{x:r,y:f},{x:r,y:c},{x:h.x,y:c},h])}(d,h,r.direction,a[t],t,i.length,l[t],u[t]),d,!0),h,!1));if(!s(d,o[0])||!s(h,o.at(-1))||!eu(o,e,new Set([d.id,h.id]))){c=!1;break}f.push({edge:n,points:o,label:tI(o)})}if(c){if("diamond"===d.shape){let n=t.filter(e=>!i.includes(e));if(tK(f[0].points,f[1].points)||f.some(e=>n.some(t=>tK(e.points,t.points))))continue;let a=f.map(t=>{let i=[...n,...f.filter(e=>e!==t).map(e=>({...e.edge,points:e.points}))];return tB(t.edge,t.points,e,r.direction,o).filter(e=>!tQ(t.edge,{x:e.box.x,y:e.box.y,w:e.box.width,h:e.box.height},i))}),s;for(let e of a[0]){let t=a[1].find(t=>!eV(e.box,t.box,tL(o)));if(t){s=[e,t];break}}if(!s)continue;f[0].label=s[0].point,f[1].label=s[1].point}for(let e of f){let i=tC(e.edge,e.label,o);"diamond"!==d.shape&&tQ(e.edge,{x:i.x,y:i.y,w:i.width,h:i.height},t)&&(c=!1)}if(!(!c||!0!==tZ(t,f,o))){for(let{edge:e,points:t,label:i}of f)e.points=t,e.labelPosition=i,e.routeCertificate=void 0;x(f.map(e=>e.edge),n);break}}}}}(e.nodes,e.edges,e.groups,e.graph,e.bundled,e.style)}},{id:"applyParallelDuplicateLanes",after:["clipEdgeToShape"],mutates:["edges"],determinism:"in-place",enabled:e=>(!!e.elkResult||e.mergeEdges)&&iu(e.edges),mayChangeMetrics:{crossings:{worsenBy:1,whenImproves:"parallelOverlaps",perImprovement:!0},parallelOverlaps:"improve-only"},run:e=>{!function(e,t,i,r,n,o,a){let l=new Map(e.map(e=>[e.id,e])),d=eF(r.direction),h={allowCrossingsForOverlap:!0,...a?{labelClearance:{nodes:e,style:a}}:{}},u=e=>d.isHorizontal?e.height:e.width,f=(e,t)=>d.isHorizontal?{x:e,y:t}:{x:t,y:e},c=e=>e[d.main]+(d.isHorizontal?e.width:e.height),p=e=>e[d.main],y="E"===d.sourceSide||"S"===d.sourceSide,m="W"===d.targetSide||"N"===d.targetSide,b=(e,t)=>y!==t?c(e):p(e),w=(e,t)=>m!==t?p(e):c(e),M=new Set,v=(e,t)=>{for(let i=1;i<e.points.length;i++){let r=e.points[i-1],n=e.points[i],o=.5>Math.abs(r.x-n.x),a=.5>Math.abs(r.y-n.y);if(!(!o&&!a))for(let e=1;e<t.points.length;e++){let i=t.points[e-1],s=t.points[e];if(o){if(Math.abs(i.x-s.x)>=.5||Math.abs(r.x-i.x)>=1)continue;if(Math.min(Math.max(r.y,n.y),Math.max(i.y,s.y))-Math.max(Math.min(r.y,n.y),Math.min(i.y,s.y))>1)return!0}else if(a){if(Math.abs(i.y-s.y)>=.5||Math.abs(r.y-i.y)>=1)continue;if(Math.min(Math.max(r.x,n.x),Math.max(i.x,s.x))-Math.max(Math.min(r.x,n.x),Math.min(i.x,s.x))>1)return!0}}}return!1},S=new Map;for(let e of t){if(e.source===e.target)continue;let t=l.get(e.source),r=l.get(e.target);if(!t||!r||!eb.has(t.shape)||!eb.has(r.shape)||K(t,i)||K(r,i))continue;let n=(w(r,!1)-b(t,!1))*d.sign,o=(b(t,!0)-w(r,!0))*d.sign;if(n<=16&&o<=16)continue;let a=`${e.source}\0${e.target}`;S.has(a)||S.set(a,[]),S.get(a).push(e)}let k=(e,t)=>{let i=tC(e,t,o),r=eC(e,o.lineWidth??1);return{x:i.x-r,y:i.y-r,width:i.width+2*r,height:i.height+2*r}},E=(i,a,c,p,y=0)=>{i.sort((e,t)=>(e.edgeIndex??0)-(t.edgeIndex??0));let m=l.get(i[0].source),v=l.get(i[0].target),S=b(m,a),E=w(v,a),P=i.length;if(c<4)return!1;let N=i.every(e=>e.label)?Math.max(c,...i.map(e=>{let t=k(e,{x:0,y:0});return(d.isHorizontal?t.width:t.height)+tL(o)})):c,C="target"===p,I=m[d.cross]+u(m)/2+y,L=v[d.cross]+u(v)/2+y,R=[],O=[];for(let e=0;e<P;e++){let t=I+(e-(P-1)/2)*c,r=L+(e-(P-1)/2)*c,n=(a?-1:1)*d.sign,o=C?E-n*(16+e*N):S+n*(16+e*N),s=Math.min(S,E),l=Math.max(S,E);(o<=s+4||o>=l-4)&&(o=(S+E)/2),R.push({edge:i[e],sCross:t,tCross:r}),O.push(o)}R[0].tCross-R[0].sCross>0!==C&&O.reverse();let $=[];for(let t=0;t<P;t++){let{edge:i,sCross:r,tCross:n}=R[t],o=O[t],a=g(ed(ed(r===n?[f(S,r),f(E,n)]:[f(S,r),f(o,r),f(o,n),f(E,n)],m,!0),v,!1));if(a.length<2||!s(m,a[0])||!s(v,a[a.length-1])||!eu(a,e,new Set([m.id,v.id])))return!1;$.push({edge:i,points:a,label:i.label?tI(a):void 0})}let z=tZ(t,$,o,{allowCrossingsForOverlap:!0});if(!0!==z)return z;if("original"!==p){let n=t.filter(e=>!i.includes(e)),a=[...n,...$.map(e=>({...e.edge,points:e.points}))].flatMap(e=>U(e,o)).flatMap(e=>e.bounds?[{x:e.bounds.x0,y:e.bounds.y0,width:e.bounds.x1-e.bounds.x0,height:e.bounds.y1-e.bounds.y0}]:[]),s=n.filter(e=>e.label).map(e=>k(e,e.labelPosition??eB(e.points)));for(let t of $){if(!t.edge.label)continue;let i=[...n,...$.filter(e=>e!==t).map(e=>({...e.edge,points:e.points}))],l=tB(t.edge,t.points,e,r.direction,o).find(r=>{let n=k(t.edge,r.point);return!e.some(e=>eV(n,e,2))&&!a.some(e=>eV(n,e,0))&&!s.some(e=>eV(n,e,2))&&!tQ(t.edge,{x:n.x,y:n.y,w:n.width,h:n.height},i)});if(!l)return!1;t.label=l.point,s.push(k(t.edge,t.label))}}if(h.labelClearance&&!tJ(t,$,h.labelClearance))return!1;for(let{edge:e,points:t,label:i}of $)e.points=t,e.labelPosition=i,e.routeCertificate=void 0,M.add(e);return x($.map(e=>e.edge),n),!0};for(let r of S.values()){if(r.length<2||!r.some(e=>e.label)||!r.some(e=>e.label&&r.some(t=>t!==e&&v(e,t)))||r.every(e=>e.label)&&0===$({nodes:[],edges:r},o).labelLabel)continue;let n=l.get(r[0].source),a=l.get(r[0].target);if(!n||!a)continue;let s=!((w(a,!1)-b(n,!1))*d.sign>16),h=(Math.min(u(n),u(a))-10)/(r.length-1),g=Math.max(14,...r.filter(e=>e.label).map(e=>{let t=k(e,{x:0,y:0});return(d.isHorizontal?t.height:t.width)/2+3})),f=(n,o)=>{let a=E(r,s,n,o);if(!0===a)return!0;if("marker-blocked"!==a||!tV(e,t,i))return!1;let l=(h-n)*(r.length-1)/2;return l>0&&P(0).some(e=>{let t=(2*e-1)*l;return 0!==t&&!0===E(r,s,n,o,t)})};if(!(g<=h&&(f(g,"source")||f(g,"target")))&&!f(Math.min(14,h),"original")&&r.every(e=>e.label)){let e=Math.min(7,h);f(e,"source")||f(e,"target")||f(e,"original")}}let N=new Map,C=new Map;for(let e of t){if(M.has(e)||e.source===e.target||e.label)continue;let t=l.get(e.source),r=l.get(e.target);if(!t||!r||!eb.has(t.shape)||!eb.has(r.shape)||K(t,i)||K(r,i))continue;let n=t=>{t.has(e.target)||t.set(e.target,[]),t.get(e.target).push(e)};(w(r,!1)-b(t,!1))*d.sign>16?n(N):(b(t,!0)-w(r,!0))*d.sign>16&&n(C)}let I=(r,a)=>{if(r.length<2)return;let c=new Map;for(let e of r)c.set(e.source,(c.get(e.source)??0)+1);if(![...c.values()].some(e=>e>=2))return;let p=l.get(r[0].target),y=w(p,a),m=p[d.cross]+u(p)/2,M=e=>{let t=l.get(e.source);return t[d.cross]+u(t)/2};r.sort((e,t)=>M(e)-M(t)||(e.edgeIndex??0)-(t.edgeIndex??0));let v=r.length,S=Math.min(14,(u(p)-10)/(v-1));if(S<4)return;let k=new Map;for(let e of r)k.has(e.source)||k.set(e.source,[]),k.get(e.source).push(e);let E=[],P=[];for(let e=0;e<v;e++){let t=r[e],i=l.get(t.source),n=b(i,a),o=m+(e-(v-1)/2)*S,s=k.get(t.source),h=s.length>1?Math.min(S,(u(i)-10)/(s.length-1)):0,g=i[d.cross]+u(i)/2+(s.indexOf(t)-(s.length-1)/2)*h,f=n+(a?-1:1)*d.sign*(16+e*S),c=Math.min(n,y),p=Math.max(n,y);(f<=c+4||f>=p-4)&&(f=(n+y)/2),E.push({edge:t,source:i,exitMain:n,sCross:g,tCross:o}),P.push(f)}for(let e=0;e<v;){let t=e;for(;t+1<v&&r[t+1].source===r[e].source;)t++;if(t>e&&E[e].tCross-E[e].sCross>0){let i=P.slice(e,t+1).reverse();for(let r=e;r<=t;r++)P[r]=i[r-e]}e=t+1}let N=t=>{let i=[];for(let r=0;r<v;r++){let{edge:n,source:a,exitMain:l}=E[r],d=E[r].sCross,h=E[r].tCross+t,u=P[r],c;c=ed(c=d===h?[f(l,d),f(y,h)]:[f(l,d),f(u,d),f(u,h),f(y,h)],a,!0);let m=ek(c=g(c=ed(c,p,!1)),j(n,o));if(!m||(c=m).length<2||!s(a,c[0])||!s(p,c[c.length-1])||!eu(c,e,new Set([a.id,p.id])))return;i.push({edge:n,points:c})}return i},C=N(0);if(!C)return;let I=tZ(t,C,o,h);if(!0!==I){if("marker-blocked"!==I||!tV(e,t,i))return;let r=-1/0,n=1/0;for(let e of E)r=Math.max(r,e.source[d.cross]+5-e.sCross,p[d.cross]+5-e.tCross),n=Math.min(n,e.source[d.cross]+u(e.source)-5-e.sCross,p[d.cross]+u(p)-5-e.tCross);if(!Number.isFinite(r)||!Number.isFinite(n)||r>0||n<0)return;let a=tU(),s={...h,labelClearance:{nodes:e,style:o}},l;for(let d of[r,n]){if(a.remaining<=0)break;if(0===d)continue;let r=N(d);if(!r||!0!==tZ(t,r,o,s))continue;let n=new Map(r.map(e=>[e.edge,e.points]));if(tG(e,t.map(e=>n.has(e)?{...e,points:n.get(e)}:e),e,t,i,o,a)){l=r;break}}if(!l)return;C=l}for(let{edge:e,points:t}of C)e.points=t,e.labelPosition=void 0,e.routeCertificate=void 0;x(C.map(e=>e.edge),n)};for(let e of N.values())I(e,!1);for(let e of C.values())I(e,!0)}(e.nodes,e.edges,e.groups,e.graph,e.bundled,e.style,e.elkResult?void 0:e.style)}},{id:"collapseTinyBundledHitches",after:["applySymmetricFanoutEmissions","applySymmetricParallelEdgeLanes","applyParallelDuplicateLanes"],mutates:["edges"],determinism:"in-place",mayChangeMetrics:{bends:"improve-only"},run:e=>{ev(e.nodes,e.edges,e.bundled)}},{id:"reassignBundledSiblingLabels",after:["collapseTinyBundledHitches"],mutates:["edges"],determinism:"in-place",run:e=>{!function(e,t,i,r,n,o=[]){let a=new Map(e.map(e=>[e.id,e])),s=new Map;for(let e of t)i.has(e)&&e.label&&X(e,a,r)&&(s.has(e.source)||s.set(e.source,[]),s.get(e.source).push(e));for(let i of s.values()){if(i.length<2||i.length>3||new Set(i.map(e=>e.target)).size<i.length)continue;let s=[...i].sort((e,t)=>{let i=a.get(e.target),n=a.get(t.target);return i&&n?eW(i,r)-eW(n,r):(e.edgeIndex??0)-(t.edgeIndex??0)}),l=a.get(s[0].source);if(l?.shape==="rectangle"&&K(l,o)){let i=s.map(e=>({edge:{...e},points:e.points})),a=new Map(s.map((e,t)=>[e,i[t].edge]));tD(i,e,t.map(e=>a.get(e)??e),o,r,n)&&s.forEach((e,t)=>{e.labelPosition=i[t].edge.labelPosition})}else t_(s.map(e=>({edge:e,points:e.points})),e,r,n)}}(e.nodes,e.edges,e.bundled,e.graph.direction,e.style,e.groups)}},{id:"applyRouteContracts",after:["reassignBundledSiblingLabels"],mutates:["edges"],determinism:"fixed-point",freezesNodes:!0,mayChangeMetrics:{straight:{worsenBy:1,whenImproves:["hard","crossings","endpointApproaches"],perImprovement:!0},bends:{worsenBy:4,whenImproves:["hard","crossings","endpointApproaches"],perImprovement:!0},portRate:{worsenBy:1,whenImproves:["hard","crossings","bends","endpointApproaches","opposingOverlaps"]}},run:e=>{k({nodes:e.nodes,edges:e.edges,groups:e.groups},e.graph,e.bundled,e.style,e.elkResult?void 0:{preserveSelfLoops:!0,preserveLabels:!0,preserveStraightRoutes:!0})}},{id:"reanchorOffOutlineEndpoints",after:["applyRouteContracts"],mutates:["edges"],determinism:"in-place",run:e=>{ex(e.nodes,e.edges,e.graph,e.style)}},{id:"rerouteEdgesThroughNodes",after:["reanchorOffOutlineEndpoints"],mutates:["edges"],determinism:"in-place",run:e=>{ew(e.nodes,e.edges,e.graph,void 0,e.groups),R({nodes:e.nodes,edges:e.edges,groups:e.groups},e.graph,e.style)}},{id:"repairLabelsOnSharedTrunks",after:["rerouteEdgesThroughNodes"],mutates:["edges"],determinism:"in-place",run:e=>{C({nodes:e.nodes,edges:e.edges,groups:e.groups},e.graph,e.style)}},{id:"repairLabelsOffOwnRoute",after:["repairLabelsOnSharedTrunks"],mutates:["edges"],determinism:"in-place",run:e=>{I({nodes:e.nodes,edges:e.edges,groups:e.groups},e.graph,e.style)}},{id:"separateEdgeLabelPills",after:["repairLabelsOffOwnRoute"],mutates:["edges"],determinism:"in-place",run:e=>{L({nodes:e.nodes,edges:e.edges,groups:e.groups},e.graph,e.style,e.elkResult?void 0:{preserveRouteClearance:!0})}},{id:"closeRouteContracts",after:["separateEdgeLabelPills"],mutates:["edges"],determinism:"fixed-point",mayChangeMetrics:{straight:"improve-only",bends:"improve-only"},run:e=>{O({nodes:e.nodes,edges:e.edges,groups:e.groups},e.graph,e.style)}},{id:"translateGeometryToNonNegativeOrigin",after:["closeRouteContracts"],mutates:["translate"],determinism:"in-place",run:e=>{u(e.nodes,e.edges,e.groups,e.layoutPadding,e.style)}},{id:"placeStateNotes",after:["translateGeometryToNonNegativeOrigin"],mutates:["translate"],determinism:"in-place",enabled:e=>!!e.graph.stateNotes?.length,run:e=>{e.notes=function(e,t,i,r,n,o,a){let s=r.stateNotes??[];if(0===s.length)return[];let l=[],d=e=>{for(let t of e)l.push(t),d(t.children)};d(i);let h=[];for(let t of e)h.push({x:t.x,y:t.y,w:t.width,h:t.height});for(let e of l)h.push({x:e.x,y:e.y,w:e.width,h:e.height});for(let e of t){if("invisible"===e.style)continue;for(let t=1;t<e.points.length;t++){let i=e.points[t-1],r=e.points[t];h.push({x:Math.min(i.x,r.x)-2,y:Math.min(i.y,r.y)-2,w:Math.abs(i.x-r.x)+4,h:Math.abs(i.y-r.y)+4})}let t=e.label?eI(e,n):null;t&&h.push(t)}let g=(e,t)=>e.x<t.x+t.w&&e.x+e.w>t.x&&e.y<t.y+t.h&&e.y+e.h>t.y,u=[];for(let t of s){let i=e.find(e=>e.id===t.target),r=i?void 0:l.find(e=>e.id===t.target),o=i??r;if(!o)continue;let s=eP(e9(t.text,t.textContent),n,"note"),d=s.width+20,f=s.height+16,c=o.y+(o.height-f)/2,p="left"===t.side?o.x-a-d:o.x+o.width+a;for(let e=0;e<h.length+u.length+4;e++){let e={x:p-6,y:c-6,w:d+12,h:f+12},i=h.find(t=>g(e,t))??u.map(e=>({x:e.x,y:e.y,w:e.width,h:e.height})).find(t=>g(e,t));if(!i)break;p="left"===t.side?i.x-6-d:i.x+i.w+6}u.push({id:t.id,target:t.target,side:t.side,text:t.text,...t.textContent?{textContent:t.textContent}:{},textBlock:s,x:p,y:c,width:d,height:f})}let f=0,c=0;for(let e of u)f=Math.min(f,e.x),c=Math.min(c,e.y);if(f<0||c<0){let r=f<0?-f+o:0,n=c<0?-c+o:0,a=e=>{e.x+=r,e.y+=n,e.children.forEach(a)};for(let t of e)t.x+=r,t.y+=n;for(let e of i)a(e);for(let e of t){for(let t of e.points)t.x+=r,t.y+=n;e.labelPosition&&(e.labelPosition.x+=r,e.labelPosition.y+=n)}for(let e of u)e.x+=r,e.y+=n}return u}(e.nodes,e.edges,e.groups,e.graph,e.style,e.layoutPadding,e.stateNoteMargin)}}];function ip(i,r){for(let n of i.nodes)n.labelBlock??=eP(e9(n.label,n.labelContent),r,"node"),!n.icon||n.iconFallbackBlock||t(n.icon)||(n.iconFallbackBlock=tg(e(n.icon),{fontSize:10,fontWeight:400}));for(let e of i.edges)void 0!==e.label&&(e.labelBlock??=eP(e9(e.label,e.labelContent),r,"edge"));let n=e=>{e.labelBlock??=eP(e9(e.label,e.labelContent),r,"group"),e.headerHeight=ih(e,r,e.labelBlock),e.children.forEach(n)};i.groups.forEach(n)}function iy(e,t){let i={nodes:e.nodes,edges:e.edges,groups:e.groups,width:0,height:0};return W(e.graph,i,t,e.style,e.bundled)}function im(e,t,i=!1,r=eO.padding,n=e1({}),o=18){let a=[],s=[],l=new Set;for(let e of t.subgraphs)!function e(t,i){for(let r of(i.add(t.id),t.children))e(r,i)}(e,l);return function e(t,i,r,n,o,a,s){if(t.children)for(let l of t.children){let t=(l.x??0)+a,d=(l.y??0)+s,h=l.width??0,g=l.height??0;if(r.has(l.id)){let a=[];e(l,i,r,n,a,t,d);let s=eX(i.subgraphs,l.id),u=s?.stateComposite?eQ(l.id,i):void 0;o.push({id:l.id,label:s?.label??"",...s?.labelContent?{labelContent:s.labelContent}:{},x:t,y:d,width:h,height:g,children:a,...s?.headerMinHeight===void 0?{}:{headerMinHeight:s.headerMinHeight},...s?.concurrencyRegion?{concurrencyRegion:!0}:{},...u?{inlineStyle:u}:{}})}else{let a=i.nodes.get(l.id);if(a){let e=eq(l.id,i),r=i.classAssignments.get(l.id),o=r?r.split(/\s+/).filter(Boolean):void 0;n.push({id:l.id,label:a.label,...a.labelContent?{labelContent:a.labelContent}:{},...a.labelBlock?{labelBlock:a.labelBlock}:{},shape:a.shape,...void 0!==a.floatingNoteId?{floatingNoteId:a.floatingNoteId}:{},...void 0!==a.semanticShape?{semanticShape:a.semanticShape}:{},x:t,y:d,width:h,height:g,inlineStyle:e,classNames:o,...a.icon?{icon:a.icon}:{},...a.image?{image:a.image}:{},...a.iconForm?{iconForm:a.iconForm}:{},...a.href?{href:a.href}:{}})}l.children&&l.children.length>0&&e(l,i,r,n,o,t,d)}}}(e,t,l,a,s,0,0),ix({width:e.width??800,height:e.height??600,nodes:a,edges:[],groups:s},t,i,r,n,o,e)}function ix(e,t,i,r,n,o,a,s){let{nodes:l,edges:d,groups:h}=e,g=ez(h),u={elkResult:a,graph:t,nodes:l,edges:d,groups:h,notes:[],margins:g.length>0?{leftX:Math.min(...g.map(e=>e.x))-20,rightX:Math.max(...g.map(e=>e.right))+20}:void 0,bundled:new Set,genericBundled:!1,mergeEdges:i,style:n,layoutPadding:r,stateNoteMargin:o,frozen:!1};if(s)for(let e of s)u.bundled.add(d[e]);ip(u,n),function(e,t,i={}){let r=new Set,n=e.frozen;for(let o of t){if(o.enabled&&!o.enabled(e)){r.add(o.id);continue}for(let e of o.after)if(!r.has(e))throw new ty(o.id,"ordering",`LayoutPass ordering: '${o.id}' must run after '${e}', which has not run`);let t=Object.entries(o.mayChangeMetrics??{}),a=e=>"improve-only"!==e&&e.whenImproves?"string"==typeof e.whenImproves?[e.whenImproves]:e.whenImproves:[],s=[];for(let[e,i]of t)for(let t of(s.includes(e)||s.push(e),a(i)))s.includes(t)||s.push(t);let l=o.proposal?s.includes("hard")?[...s]:[...s,"hard"]:s;if((t.length||o.proposal)&&!i.measureMetrics)throw new ty(o.id,"measurement",`Layout pass '${o.id}' declares metric budgets but no geometry measurement was supplied`);let d=(t=s)=>{try{return i.measureMetrics(e,t)}catch(e){throw e instanceof ty?e:new ty(o.id,"measurement",`Layout pass '${o.id}' could not measure its declared geometry: ${e instanceof Error?e.message:String(e)}`)}},h=t.length||o.proposal?d(l):void 0,g=n?tx(e).map(({id:e,x:t,y:i,width:r,height:n})=>({id:e,x:t,y:i,width:r,height:n})):void 0,u=n?(e.edges??[]).map(e=>({points:e.points?.map(e=>({...e})),labelPosition:e.labelPosition?{...e.labelPosition}:void 0,certificate:e.routeCertificate})):void 0,f=(e=!1)=>{let i;if(h){let r=d(e?l:s),n=e=>{let t=h[e],i=r[e];if(void 0===t||void 0===i||!Number.isFinite(t)||!Number.isFinite(i))throw new ty(o.id,"measurement",`Layout pass '${o.id}' has no finite measurement for ${e}`);return("straight"===e||"portRate"===e?-1:1)*(i-t)};for(let[s,l]of e&&o.proposal?[...t,["hard","improve-only"]]:t){let e=Math.max(0,...a(l).map(e=>-n(e))),t="improve-only"===l||l.whenImproves&&e<=1e-6?0:l.worsenBy*(l.perImprovement?Math.floor(e+1e-6):1);if(n(s)>t+1e-6){let e=new tm(o.id,s,h[s],r[s],t);if("hard"===s)throw e;i??=e}}}return i},c=()=>{if(g){let t=tx(e),i=o.mutates.includes("translate"),r=i&&g[0]&&t[0]?t[0].x-g[0].x:0,n=i&&g[0]&&t[0]?t[0].y-g[0].y:0,a=(e,t)=>i?1e-6>=Math.abs(t.x-e.x-r)&&1e-6>=Math.abs(t.y-e.y-n):e.x===t.x&&e.y===t.y;if(t.length!==g.length||!e.frozen)throw new ty(o.id,"freeze",`LayoutPass freeze: '${o.id}' changed frozen geometry membership or state`);for(let e=0;e<g.length;e++){let i=g[e],r=t[e];if(i.id!==r.id||i.width!==r.width||i.height!==r.height||!a(i,r))throw new ty(o.id,"freeze",`LayoutPass freeze: '${o.id}' moved frozen geometry without a uniform translation`)}if(u){if((e.edges?.length??0)!==u.length)throw new ty(o.id,"freeze",`LayoutPass freeze: '${o.id}' changed frozen edge membership`);for(let t=0;t<u.length;t++){let r=u[t],n=e.edges[t],s=r.points?.length===n.points?.length&&(r.points??[]).every((e,t)=>n.points?.[t]&&a(e,n.points[t]));if(i){if(!s||!!r.labelPosition!=!!n.labelPosition||r.labelPosition&&!a(r.labelPosition,n.labelPosition))throw new ty(o.id,"freeze",`LayoutPass freeze: '${o.id}' did not translate all frozen routes and labels uniformly`)}else if(!s&&(!o.mutates.includes("edges")||void 0===n.routeCertificate||n.routeCertificate===r.certificate))throw new ty(o.id,"certificate",`LayoutPass certificate: '${o.id}' rewrote edge geometry after the route-contract freeze without re-issuing routeCertificate`)}}}},p=o.run(e);if(p&&!o.proposal)throw new ty(o.id,"metric-budget",`Layout pass '${o.id}' returned a rollback without declaring a cosmetic proposal`);let y=f();if(c(),y){if(!p)throw y;p();let e=f(!0);if(e)throw e;c()}o.freezesNodes&&(e.frozen=!0),n||=e.frozen,r.add(o.id),i.onAfterPass?.(o,e)}}(u,ic,{measureMetrics:iy});let f=e.width,c=e.height,p=eZ.width;for(let e of l)f=Math.max(f,e.x+e.width+r),c=Math.max(c,e.y+e.height+r);for(let e of ez(h))f=Math.max(f,e.right+r),c=Math.max(c,e.bottom+r);for(let e of d){for(let t of e.points)f=Math.max(f,t.x+p+r),c=Math.max(c,t.y+p+r);let t=e.labelBlock?eI(e,n):null;t&&(f=Math.max(f,e.labelPosition.x+60+r,t.x+t.w+r),c=Math.max(c,e.labelPosition.y+20+r,t.y+t.h+r))}for(let e of u.notes)f=Math.max(f,e.x+e.width+r),c=Math.max(c,e.y+e.height+r);return{genericBundled:u.genericBundled,positioned:{width:f,height:c,nodes:l,edges:d,groups:h,...u.notes.length>0?{notes:u.notes}:{}}}}function ib(e,t={}){eY(e);let i=t.graphLayout?tu(t,()=>{let i=e1(t,t.stateVisual?.styleDefaults,t.styleFace);return o(e,t,i,iS)},()=>ik(e,t),!0,(e,t)=>{e.layoutDecision=t}):ik(e,t),r=e1(t,t.stateVisual?.styleDefaults,t.styleFace);ip(i,r);let n=e2(t.diagramTitle,e1(t,t.stateVisual?.styleDefaults,t.styleFace));if(!n)return i;let a=t.padding??eO.padding;if(0===i.width&&0===i.height)return Object.assign(i,e5(n,a));(function(e,t){let i=e=>{for(let r of(e.y+=t,e.children))i(r)};for(let i of e.nodes)i.y+=t;for(let t of e.groups)i(t);for(let i of e.edges){for(let e of i.points)e.y+=t;i.labelPosition&&(i.labelPosition.y+=t)}for(let i of e.notes??[])i.y+=t})(i,n.height),i.height+=n.height,i.width=Math.max(i.width,n.width+2*a),i.title=e6(n,i.width,a);let s=tv(i,r);if(s.length)throw new tr([{strategy:"final-title-projection",violations:s}]);return i}function iw(e,t={}){eY(e);let i=ik(e,t,"placement");return ip({...i,edges:[]},e1(t,void 0,t.styleFace)),i}function iM(e,t={}){eY(e);let i=e1(t,void 0,t.styleFace);return a(e,t,i,iS)}function iv(e,t,r,o=!1){let a=t.stateVisual,s={...eO,...t,...a?{stateVisual:a}:{}},l=e1(t,a?.styleDefaults,t.styleFace),d=ie(e,s,l);if(o&&!a){let t=((...e)=>n().indexedForestLayout(...e))(e,d,s.padding,s.nodeSpacing,s.layerSpacing);if(!t)throw Error("Graph is ineligible for indexed forest layout");let i=im(t,e,eO.mergeEdges,s.padding,l,18);return i.genericBundled&&r?.(i.positioned,()=>im(t,e,!1,s.padding,l,18).positioned),i.positioned}if(1===e.nodes.size&&0===e.edges.length&&0===e.subgraphs.length&&!e.stateNotes?.length&&!a&&d.children?.length===1){let t=d.children[0];return im({...d,width:t.width+2*s.padding,height:t.height+2*s.padding,children:[{...t,x:s.padding,y:s.padding}]},e,eO.mergeEdges,s.padding,l,18).positioned}let h,g,u="exception",f=0;for(let t of[{},{"elk.layered.feedbackEdges":"false"},{"elk.layered.feedbackEdges":"false","elk.layered.compaction.postCompaction.strategy":"NONE"},{"elk.layered.feedbackEdges":"false","elk.layered.compaction.postCompaction.strategy":"NONE","elk.layered.crossingMinimization.forceNodeModelOrder":"false","elk.layered.highDegreeNodes.treatment":"false"}]){++f>1&&tf("elk-degradation",u,f);let r=0===Object.keys(t).length?d:ie(e,s,l);Object.keys(t).length>0&&(r.layoutOptions={...r.layoutOptions,...t});try{let e=i(r);if(iE(e)){g=Error("ELK returned non-finite layout geometry"),u="non-finite-geometry";continue}h=e;break}catch(e){if(e instanceof eG||e instanceof to)throw e;g=e,u="exception"}}if(!h)throw g;let c=h,p=a?.noteMargin??18,y=im(c,e,eO.mergeEdges,s.padding,l,p);return y.genericBundled&&r?.(y.positioned,()=>im(c,e,!1,s.padding,l,p).positioned),y.positioned}var iS={edgeSelectorIndices:eR,graphEdgeMarkerPaintRegions:U,customTextMeasurementActive:tc,certifyCandidate:tS,retainSelection:tN,countEdgeCrossings:F,countOpposingRouteOverlaps:z,countParallelRouteOverlaps:_,measureLabelConflicts:$,DEFAULTS:eO,LABEL_PILL_PADDING:eN,measureRenderStage:ti,graphTextBlock:eP,resolveLabelContent:e9,groupTitleWidth:id,groupHeaderHeight:ih,estimateNodeSize:t8,resolveNodeInlineStyle:eq,resolveEdgeInlineStyle:eK,resolveClassInlineStyle:eQ,containsNonFiniteNumber:iE,finishGraphGeometry:ix,unsupported:e=>{throw new th(e)}};function ik(e,t,i){let r=e1(t,t.stateVisual?.styleDefaults,t.styleFace),o=t=>(function e(t,i,r){return t.some(t=>{let n=eX(i.subgraphs,t.id);return void 0!==n&&t.width+.5<id(n,r)||e(t.children,i,r)})})(t.groups,e,r),a=!1!==t.compareRoutePreferences,s=new WeakMap,l=a&&ep(e)&&!iu(e.edges)?(e,t)=>{s.set(e,t)}:void 0,d=e.subgraphs.length>0&&!il(e,t),h=[{strategy:"default",produce:()=>iv(e,t,l),preferNext:o}],g=(t.nodeSpacing??eO.nodeSpacing)>0&&(t.layerSpacing??eO.layerSpacing)>0,u=void 0===t.graphLayout&&e8("indexed-layout")&&g&&!t.stateVisual&&!t.preserveSubgraphChildOrder&&function(e){if(e.nodes.size<2||e.subgraphs.length>0||e.stateNotes?.length||e.edges.length>=e.nodes.size||[...e.nodes.values()].some(e=>"rectangle"!==e.shape))return!1;let t=new Map,i=new Map;for(let r of e.edges){if(void 0!==r.label||(r.length??1)!==1||r.source===r.target||!e.nodes.has(r.source)||!e.nodes.has(r.target)||t.has(r.target))return!1;t.set(r.target,1);let n=i.get(r.source);n?n.push(r.target):i.set(r.source,[r.target])}let r=[...e.nodes.keys()].filter(e=>!t.has(e));for(let e=0;e<r.length;e++)for(let t of i.get(r[e])??[])r.push(t);return r.length===e.nodes.size}(e)&&(n(),1)?{strategy:"indexed-forest",produce:()=>iv(e,t,l,!0),preferNext:o}:void 0;return t.separateHierarchy||h.push({strategy:"separate-hierarchy",produce:()=>iv(e,{...t,separateHierarchy:!0},l),preferNext:o,qualityAlternative:a&&d}),t.disableCorankFanIn||eU("APL_NO_CORANK_FANIN")||(h.push({strategy:"without-corank",produce:()=>iv(e,{...t,disableCorankFanIn:!0},l),preferNext:o,qualityAlternative:a&&t3(e,r).size>0}),t.separateHierarchy||h.push({strategy:"separate-without-corank",produce:()=>iv(e,{...t,separateHierarchy:!0,disableCorankFanIn:!0},l),preferNext:o,qualityAlternative:a&&d})),"placement"===i?function(e,t,i,r){let{selected:n}=tP(e,t,i,r,"placement");tw(e,n.positioned);let{width:o,height:a,nodes:s,groups:l}=n.positioned;return{width:o,height:a,nodes:s,groups:l}}(e,r,h,u):function(e,t,i,r,n){let o=tP(e,t,i,n),a=tN(e,o),s=r(a,o.selected.score);if(!s)return a;let l={...o.selected,strategy:"bundled"},d=tS(e,t,s),h=[{strategy:l.strategy,score:l.score}];d.certified&&h.push({strategy:d.certified.strategy,score:d.certified.score});let g=d.certified?tE(l,d.certified):{selected:l,reason:"alternative-invalid"},u=g.selected.positioned;return tw(e,u),u.certification={...a.certification,preference:{...a.certification.preference,selectedScore:g.selected.score,routing:{strategy:g.selected===l?"bundled":s.strategy,preference:{selectedScore:g.selected.score,reason:g.reason,compared:h}}}},u}(e,r,h,(e,t)=>{let i=s.get(e);if(!(!i||0===t.edgeCrossings&&0===t.labelConflicts))return{strategy:"without-generic-bundling",produce:i,preferNext:o}},u)}function iE(e,t=new Set){return"number"==typeof e?!Number.isFinite(e):!(null===e||"object"!=typeof e||t.has(e))&&(t.add(e),Array.isArray(e)?e.some(e=>iE(e,t)):Object.values(e).some(e=>iE(e,t)))}export{ib as a,iw as b,iM as c};
@@ -1,3 +0,0 @@
1
- import{b as e,c as t,d as n,e as i,f as r,g as a,k as o,l as s,m as l}from"./chunk-7TTFBJYA.js";import"./chunk-CPO5P4L2.js";import{a as c,b as d,c as u}from"./chunk-37FZNMPR.js";import{e as f,f as p,g as h,h as m,i as g,j as y,k as w,l as b}from"./chunk-5LKPDHPC.js";import{g as v}from"./chunk-V6I2VGNQ.js";import{f as x,h as k,k as $,l as S,m as j,n as M,o as C,q as E,t as O,v as F,w as N,x as I}from"./chunk-7UFOFWBA.js";import{b as z,e as A,f as L}from"./chunk-G4JBA7HU.js";import{g as W,n as R}from"./chunk-3JTYTXA6.js";import{A as G,Ab as D,B as P,Bb as B,Cb as T,Db as V,Eb as q,Fa as _,Fb as H,Gb as J,Ha as U,Hb as Y,Ib as K,Jb as Z,Lb as Q,Mb as X,Nb as ee,Ob as et,Pb as en,Q as ei,Rb as er,X as ea,Ya as eo,Z as es,Zb as el,ab as ec,bb as ed,cb as eu,gb as ef,hb as ep,lb as eh,nb as em,q as eg,s as ey,u as ew,v as eb,w as ev,wb as ex,yb as ek,z as e$}from"./chunk-EIYLJ4FI.js";import"./chunk-PJJSDGLB.js";import{a as eS}from"./chunk-YHMTSXIR.js";import"./chunk-QCU5G5PZ.js";function ej(e,t){return e.match(RegExp(`\\b${t}\\s*=\\s*(["'])(.*?)\\1`,"i"))?.[2]}function eM(e,t){return ej(e,"style")?.match(RegExp(`(?:^|;)\\s*${t}\\s*:\\s*([^;]+)`,"i"))?.[1]?.trim()??ej(e,t)}function eC(e,t,n){let i=Number.parseFloat(eM(e,t)??"");return Number.isFinite(i)?i:n}function eE(e,t){let n=eM(e,"font-weight")?.trim().toLowerCase();if(void 0===n)return t;if("normal"===n)return 400;if("bold"===n)return 700;if("bolder"===n)return t<350?400:t<550?700:900;if("lighter"===n)return t<550?100:t<750?400:700;let i=Number.parseFloat(n);return Number.isFinite(i)?i:t}function eO(e){return e.children.filter(e=>"element"===e.kind)}function eF(e,t){var n;let i="b"===t.name||"strong"===t.name,r=e.mono||(n=t.attrs,/\bclass\s*=\s*(["'])[^"']*\bmono\b/i.test(n)||/(?:^|[,\s])monospace(?:[,\s]|$)/i.test(eM(n,"font-family")??""));return{size:eC(t.attrs,"font-size",e.size),weight:i?Math.max(700,eE(t.attrs,e.weight)):eE(t.attrs,e.weight),letterSpacing:eC(t.attrs,"letter-spacing",e.letterSpacing),mono:r,fontFamily:eM(t.attrs,"font-family")??(r&&!e.mono?void 0:e.fontFamily),fontStyle:"i"===t.name||"em"===t.name||"italic"===eM(t.attrs,"font-style")?"italic":"normal"===eM(t.attrs,"font-style")?"normal":e.fontStyle}}function eN(e,t){return RegExp(`\\b${t}\\s*=`,"i").test(e)}function eI(e){return"tspan"===e.name&&["x","y","dx","dy"].some(t=>eN(e.attrs,t))}var ez=new WeakMap,eA=0,eL=new WeakMap,eW=0,eR=new WeakMap,eG=new P(128,8388608),eD=new P(128,0x1000000,e=>{eG.delete(e)}),eP=new WeakSet;function eB(e,t){let n=ez.get(e);return void 0===n&&(n=eA++,ez.set(e,n)),`${n}:${t}`}function eT(e,t=!1){let n=structuredClone(e),i=new WeakSet,r=(e,n)=>{if(null===e||"object"!=typeof e||null===n||"object"!=typeof n)return n;if(t&&ea(e))return e;if(i.has(e))return n;if(i.add(e),es(e,n),e instanceof Map&&n instanceof Map){let t=n.entries();for(let[i,a]of e){let[e,o]=t.next().value,s=r(i,e),l=r(a,o);n.delete(e),n.set(s,l)}}else if(e instanceof Set&&n instanceof Set){let t=n.values();for(let i of e){let e=t.next().value;n.delete(e),n.add(r(i,e))}}else for(let t of Object.keys(e))n[t]=r(e[t],n[t]);return n};return r(e,n)}function eV(e,t,n,i,r){let a={result:n,...i?{projection:i}:{}},o=2*t.length+W([a,X(n)],0x1000000)+1024;if(o>0x1000000)return void ec("positioned-layout","store-skipped","weight-limit");let s=a;if(r){try{s=eT(a,!0)}catch(e){if(e instanceof Error&&"DataCloneError"===e.name)return void ec("positioned-layout","store-skipped","uncloneable");throw e}ee(n,s.result)}r||eL.set(s,{locallyRepeated:!1}),eD.set(eB(e,t),s,o),eP.add(s.result)}function eq(e,t,n){let i=eR.get(t);if(!n)return void eR.delete(t);if(!i||i.request!==e||eD.get(i.key)!==i.snapshot)return;let r=++eW,a=eL.get(i.snapshot);a.locallyRepeated=a.lastUse===r-1,a.lastUse=r;let o=eG.get(i.key);return o?.owner===i.snapshot?o.drawing:void 0}var e_=new Set(["rectangle","rounded","note","service","diamond","stadium","hexagon","cylinder"]),eH={journey:"x",sequence:"none",xychart:"center",quadrant:"center"};function eJ(e){return e.role?"box"===e.role:e_.has(e.shape)}function eU(e,t,n,i){return Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(i)&&n>=0&&i>=0}function eY(e,t){let n=Math.min(e.x+e.w,t.x+t.w)-Math.max(e.x,t.x),i=Math.min(e.y+e.h,t.y+t.h)-Math.max(e.y,t.y);return n>.5&&i>.5}function eK(e,t,n="both"){let i="center"===n?t.x+t.w/2>=e.x-.5&&t.x+t.w/2<=e.x+e.w+.5:t.x>=e.x-.5&&t.x+t.w<=e.x+e.w+.5,r="x"===n||("center"===n?t.y+t.h/2>=e.y-.5&&t.y+t.h/2<=e.y+e.h+.5:t.y>=e.y-.5&&t.y+t.h<=e.y+e.h+.5);return i&&r}function eZ(e,t,n){let i=t,r=new Set;for(;i?.parentId&&!r.has(i.id);){if(r.add(i.id),i.parentId===e.id)return!0;i=n.get(i.parentId)}return!1}var eQ=new WeakMap,eX=new WeakMap,e0=new WeakSet;function e1(e,t,n){if(Q(e,{...t,role:n}),"agentic"!==t.requested||"elk"!==t.selected||e0.has(e))return;e0.add(e);let i={code:"INEFFECTIVE_CONFIG",field:"graphLayout.backend",message:`Agentic graph layout declined this input; using the requested ELK fallback: ${t.reason??"candidate rejected"}`};(p(e).onConfigDiagnostic??(e=>console.warn(e.message)))(i)}var e5=new Set(["media","supports","container","layer","document"]),e2=new WeakSet;function e3(e,t,n=C()){let i=e.id.startsWith("family:"),r=E(t,i?"external":"internal",n);if(!i&&!n)return r;let a=[];i&&r.family!==e.id&&a.push({code:"SCENE_DOCUMENT",path:"scene.family",message:`external family "${e.id}" emitted a document owned by "${r.family}"`});let o=new Set(e.semanticRoles),s=new Set(e.semanticChannels),l=new Map(e.scenePrimitiveEvidence.map(e=>[`${e.role}\0${e.primitive}`,e]));if(function e(t,n,i="scene.parts"){t.forEach((t,r)=>{let a=`${i}[${r}]`;n(t,a),"group"===t.kind&&e(t.children.map(e=>e.node),n,`${a}.children`)})}(r.parts,(e,t)=>{if(!o.has(e.role))return void a.push({code:"SCENE_PRIMITIVE_CLAIM",path:`${t}.role`,message:`emitted undeclared role "${e.role}"`});for(let n of Object.keys(e.channels??{}))s.has(n)||a.push({code:"SCENE_CHANNEL_CLAIM",path:`${t}.channels.${n}`,message:`emitted undeclared semantic channel "${n}"`});for(let n of k(e)){let i=l.get(`${e.role}\0${n}`);i&&"applicable"===i.applicability&&"unsupported"!==i.realization||a.push({code:"SCENE_PRIMITIVE_CLAIM",path:t,message:`emitted undeclared ${e.role}/${n} primitive`})}}),a.length>0)throw new S(Object.freeze(a));return r}var e8=new WeakMap,e4=new WeakMap;function e6(e,t){let n=e4.get(t);n||(n=new WeakMap,e4.set(t,n));let i=n.get(e);if(i)return ec("positioned-scene","hit"),C(e)&&!i.crossChecks&&(e3(p(e).family,i.scene,!0),i.crossChecks=!0),i.scene;ec("positioned-scene","miss");let r=p(e);if(!r.family.lowerScene)throw Error(`Resolved ${e.output} family has no Scene lowering`);let a="png"===e.output&&!1!==e.appearance.colors.embedFontImport?{...e.appearance.colors,embedFontImport:!1}:e.appearance.colors,o=C(e),s=()=>r.family.lowerScene({positioned:t.positioned,colors:a,resolved:m(e)}),l=ey(r.textMeasurement,()=>e3(r.family,o||r.family.id.startsWith("family:")?s():eo(s),o));return n.set(e,{scene:l,crossChecks:o}),l}function e7(o,s){let l=p(o),c=C(o)?"scene-assertions":l.family.id.startsWith("family:")?"external-family":l.backend&&!F(l.backend.backend)?"alternate-backend":("layout"===l.mode?"default"===o.appearance.inferredBackend:"scene"===l.mode&&l.backend?.inputName==="default")?void 0:"unsupported-mode";!c&&"er"===l.family.id&&(eQ.get(s)?.nodes.length??0)>256&&(c="paint-proof-capacity");let d=c?void 0:A(l.family.lowerScene);if(d||(c??="no-native-producer"),c){ec("native-drawing","bypass",c),ed("native-drawing",c);return}let u=e8.get(s);u||(u=new WeakMap,e8.set(s,u));let f=u.get(o);if(f){if(ec("native-drawing","hit"),f.producer===A(l.family.lowerScene))return f.drawing;ec("native-drawing","bypass","changed-producer"),u.delete(o)}l.backend&&I(l.backend.conformance,l.backend.inputName);let h=eq(o,s,(d=A(l.family.lowerScene))===L(l.family.lowerScene));if(h){ec("native-drawing","hit",void 0,"positioned-owner");let e=d;if(e&&e===A(l.family.lowerScene)&&e===L(l.family.lowerScene))return u.set(o,{drawing:h,producer:e,certification:h.certification}),h;ec("native-drawing","bypass","changed-producer"),eq(o,s,!1),d=A(l.family.lowerScene)}if(ec("native-drawing","miss"),!(d=A(l.family.lowerScene))){ec("native-drawing","bypass","no-native-producer"),ed("native-drawing","no-native-producer");return}let g=d,y="png"===o.output&&!1!==o.appearance.colors.embedFontImport?{...o.appearance.colors,embedFontImport:!1}:o.appearance.colors,w=ey(l.textMeasurement,()=>{let c;return function(o,s,l,c){var d;let u,f,p={family:l,width:s.positioned.width,height:s.positioned.height,colors:s.colors,transparent:s.resolved.renderOptions.transparent??!1},h=a(r);l.startsWith("family:")&&h.uncertain();let m=h.snapshot(p),g=M(p),y=new WeakSet,w=e=>(h.retainFragment()&&y.add(e),Object.freeze(e)),b=e=>{let t=h.leaf(e),n=g.node(t.node);return w({kind:"leaf",node:t.node,svg:n,conditional:t.conditional,nodeCount:1,depth:0,prepared:"document"===e.kind?!/<\s*text/i.test(n):"text"!==e.kind||"prepared"===e.measurement&&void 0!==e.block})},v={shape:e=>b(D(e)),text:e=>b(T(e)),connector:e=>b(B(e)),documentOpen:(e,t)=>{let n=h.snapshot(e);return n?(m=Object.freeze({family:l,width:n.width,height:n.height,colors:n.colors,transparent:n.transparent}),m=h.header(m,t)):h.uncertain(),b(K(e,t))},documentContent:(e,t)=>b(V(e,t)),documentText:e=>b(q(e)),definitions:(e,t)=>b(H(e,t)),documentClose:()=>b(J()),group(t){let n=Object.getOwnPropertyDescriptor(t,"children");n&&"value"in n||h.uncertain();let{children:i,...r}=t,a=h.parts(i,$.maxNodes),o=[],s=1,l=0,c=1,d=!0,u=[];for(let e of a){let t=Object.getOwnPropertyDescriptor(e,"node"),n=Object.getOwnPropertyDescriptor(e,"indent");t&&"value"in t&&n&&"value"in n||h.uncertain();let i=Object.freeze({node:e.node,indent:e.indent});o.push(i),y.has(i.node)||h.uncertain(),u.push(i.node),s+=i.node.nodeCount,l+=i.node.svg.length,c=Math.max(c,1+i.node.depth),d=d&&i.node.prepared}if(s>$.maxNodes)throw RangeError("Native drawing contains too many emitted nodes");if(l>$.maxSerializationBytesPerNode)throw RangeError("Native group has an oversized SVG serialization");let f=Y({...r,children:[]});g.node(f),g.depth(c);let p=h.snapshot(f),m=p?h.group(p,f):void 0,b=p?.identity??{id:f.id,role:f.role};for(let e of u)"leaf"!==e.kind||"shape"!==e.node.kind||e.node.identity||g.enclosure(e.node.id,b);let v=[f.open];for(let e of o)v.push(ex(e.node.svg,e.indent));v.push(f.close);let x=v.join(f.join);return g.serialization(x),w({kind:"group",svg:x,children:Object.freeze(u),matrix:m,own:b,owner:p?.owner,conditional:!p||"conditional"===f.visibility,opacity:e(p?.paint?.opacity),nodeCount:s,depth:c,prepared:!/<\s*text/i.test(f.open+f.close)&&d})},pathArtwork:e=>Z(v,e)},x=eo(()=>o(v,s));for(let e of["parts","family","width","height","colors","transparent"]){let t=Object.getOwnPropertyDescriptor(x,e);t&&"value"in t||h.uncertain()}let k=h.parts(x.parts,$.maxNodes);for(let e of k)y.has(e)||h.uncertain();let C=g.finish();if(!C.valid)throw new S(C.diagnostics);let E=0,F=-1,N=!0;for(let e of k)E+=e.nodeCount,F+=e.svg.length+1,N=N&&e.prepared;if(E>$.maxNodes)throw RangeError("Native drawing contains too many emitted nodes");if(F>$.maxFinalSvgBytes)throw RangeError("Native drawing exceeds the final SVG limit");let I=O(x,{seed:0,...c?{style:c}:{}}),z=k.map((e,t)=>0===t&&I?`${e.svg}
2
- ${I}`:e.svg).join(`
3
- `);j(z,"native drawing output");let A=m??Object.freeze({...p,colors:Object.freeze({bg:"none",fg:"none"})}),L=h.snapshot({family:x.family,width:x.width,height:x.height,colors:x.colors,transparent:x.transparent}),W=Object.freeze({...A,family:L?.family??l});L&&h.same({...L,width:Number(ei(L.width)),height:Number(ei(L.height))},W)||h.uncertain();let R=(d=h.observe,u=i(W),f=[],function e(i,r,a){for(let o=0;o<i.length;o++){let s=i[o],l=`${r}.${o}`;if("group"===s.kind){f.push(s);let i,r=1,o;for(let e=f.length-1;e>=0;e--){let n=f[e];(void 0!==n.matrix||void 0!==i)&&(i=U(n.matrix??_,i??_)),r=t(n.opacity,r),n.conditional&&(o=!0)}let c=n(a?.ancestors,s.own),d=s.owner?.id===s.own.id&&s.owner.role===s.own.role?c.at(-1):s.owner;e(s.children,l,{parentMatrix:i,ancestors:c,owner:d,conditional:o,groupOpacity:r}),f.pop()}else if(a){let e=!s.conditional&&d(s.node,s.svg);u.leaf(s.node,l,a.parentMatrix,a.ancestors,a.conditional||!e,a.groupOpacity,s.node.owner??a.owner)}else{let e=!s.conditional&&d(s.node,s.svg);u.leaf(s.node,l,void 0,void 0,!e)}}}(k,"scene"),u.finish());return h.finish(R,W),Object.freeze({svg:z,header:W,preparedText:N,paint:R})}(g,{positioned:(c=eX.get(s))&&c!==g?eT(s.positioned,!0):s.positioned,colors:y,resolved:m(o)},l.family.id,o.appearance.styled?o.appearance.style:void 0)});return u.set(o,{drawing:w,producer:g,evidence:w}),w}function e9(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function te(e,t,n){return(await tt(e,t,n)).svg}async function tt(e,t,n){"default"!==w(t=y(t))&&await import("./builtin-backends-VAFEZXKY.js"),v(n);let i,r=new Map;for(;;)try{return i??=et("request",()=>b(e,t,"svg",void 0,{expectedFamilyId:n.id,familyDescriptor:n})),function(e){return eu(()=>(function(e){var t;!function(e){if(e2.has(e))return;e2.add(e);let t=p(e),n=t.configDiagnostics??[];if(0===n.length)return;let i=t.onConfigDiagnostic??(e=>console.warn(e.message));for(let e of n)i(e)}(e);let n=[],i=(t=et("layout",()=>{let t,n,i,r;return n=A((t=p(e)).family.lowerScene),i="scene"===t.mode&&N(t.backend?.backend)&&z(t.family)&&!t.textMeasurement&&!!n&&n===L(t.family.lowerScene)&&!C(e),r=function(e,t,n,i,r,a=!1){let o=p(t),s=o.family;if(s.id!==e)throw Error(`Resolved request planned family ${s.id}, not ${e}`);if(!s.layout)throw Error(`No layout registered for Mermaid family ${e}`);let l=!e.startsWith("family:"),c=`${e}:final`;if(l&&!s.projectPositioned)throw new en([{strategy:c,violations:["missing final geometry projection"]}]);let d=m(t),u=globalThis.process?.env,f=G("position-cache")&&l&&"gantt"!==e&&!o.textMeasurement&&(u?.AGENTIC_MERMAID_ELK_CACHE??globalThis.AGENTIC_MERMAID_ELK_CACHE)!=="0",h=f&&n===t.source?{...n,cleanup:void 0}:n,g=f?JSON.stringify([h,t.renderOptions,t.appearance,t.familyConfig,i,"class"===e?d.paintBackendId??"backend:default":void 0,Object.entries(u??{}).filter(([e])=>e.startsWith("APL_")).sort(),e$.map(G)]):void 0,y=void 0!==g&&g.length<=65536?g:void 0;return void 0===y&&ec("positioned-layout","bypass",G("position-cache")?l?"gantt"===e?"time-dependent-family":o.textMeasurement?"custom-text-measurement":void 0===g?"elk-cache-disabled":"key-limit":"external-family":"disabled"),ey(o.textMeasurement,()=>{var o,u;let f="ascii"===t.output||"unicode"===t.output||"html"===t.output?"companion":"primary";if(r&&void 0!==y){let e=function(e,t,n){let i=eB(e,t),r=eD.get(i);if(ec("positioned-layout",r?"hit":"miss"),n&&r&&eL.has(r)){let e=Object.freeze({...r.result});return ee(r.result,e),eR.set(e,{key:i,snapshot:r,request:n}),eP.add(e),{...r,result:e}}return r}(s,y,"svg"===t.output?t:void 0);if(e?.projection){for(let n of X(e.result))e1(t,n,f);return eQ.set(e.result,e.projection),e.result}}let p=void 0===y?void 0:function(e,t,n=!1,i=!1){let r=eD.get(eB(e,t));if(n||ec("positioned-layout",r?"hit":"miss"),!r)return;let a=eT(r.result,i);return ee(r.result,a),a}(s,y,r,a),h=[],m=p??("positioned"in(o=el(e=>{h.push(e),e1(t,e,f)},()=>s.layout({source:n,renderOptions:d.renderOptions,...d.styleFace?{styleFace:d.styleFace}:{},...d.paintBackendId?{paintBackendId:d.paintBackendId}:{},...d.familyConfig?{familyConfig:d.familyConfig}:{},...d.familyAppearance?{familyAppearance:d.familyAppearance}:{}})))?o:{positioned:o});if(p)for(let e of X(p))e1(t,e,f);else for(let e of h)Q(m,e);if(l)try{let t=s.projectPositioned({positioned:m.positioned,options:i}),n=(u={...t,kind:e},function(e){let t=[];eU(0,0,e.bounds.w,e.bounds.h)||t.push({metric:"nonFiniteGeometry",detail:`bounds ${e.bounds.w}\xd7${e.bounds.h}`});let n=(n,i,r)=>{r&&(eU(r.x,r.y,r.w,r.h)?(r.x<-.5||r.y<-.5||r.x+r.w>e.bounds.w+.5||r.y+r.h>e.bounds.h+.5)&&t.push({metric:"offCanvas",detail:"node"===n?`node ${i} at (${r.x},${r.y}) ${r.w}\xd7${r.h}`:`${n} ${i}`}):t.push({metric:"nonFiniteGeometry",detail:`${n} ${i}`}))};for(let t of e.nodes)n("node",t.id,t);for(let t of e.nodes)"hidden"!==t.labelVisibility&&"semantic"!==t.labelVisibility&&n("label",t.id,t.labelBounds);for(let t of e.edges)n("label",t.id,t.label?.bounds);for(let t of e.labels??[])"hidden"!==t.visibility&&"semantic"!==t.visibility&&n("label",t.id,t.bounds);for(let n of e.edges){let i=!1;for(let[r,a]of n.path){if(!Number.isFinite(r)||!Number.isFinite(a)){t.push({metric:"nonFiniteGeometry",detail:`edge ${n.id} path`}),i=!0;break}!i&&(r<-.5||a<-.5||r>e.bounds.w+.5||a>e.bounds.h+.5)&&(t.push({metric:"offCanvas",detail:`edge ${n.id} point (${r},${a})`}),i=!0)}}for(let t of e.groups)n("group",t.id,t);let i=e.nodes.filter(eJ);for(let e=0;e<i.length;e++)for(let n=e+1;n<i.length;n++){let r=i[e],a=i[n];eU(r.x,r.y,r.w,r.h)&&eU(a.x,a.y,a.w,a.h)&&eY(r,a)&&t.push({metric:"nodeOverlaps",detail:`${r.id} overlaps ${a.id}`})}let r=eH[e.kind]??"both",a=new Map(e.groups.map(e=>[e.id,e]));if("none"!==r){let n=new Map(e.nodes.map(e=>[e.id,e]));for(let i of e.groups){let e=i.parentId?a.get(i.parentId):void 0;for(let a of(e&&eU(i.x,i.y,i.w,i.h)&&eU(e.x,e.y,e.w,e.h)&&(eK(e,i,r)||t.push({metric:"groupBreaches",detail:`${i.id} outside parent ${e.id}`})),i.members)){let e=n.get(a);!e||!eU(e.x,e.y,e.w,e.h)||eK(i,e,r)||t.push({metric:"groupBreaches",detail:`${a} outside ${i.id}`})}}}for(let n=0;n<e.groups.length;n++)for(let i=n+1;i<e.groups.length;i++){let r=e.groups[n],o=e.groups[i];!eU(r.x,r.y,r.w,r.h)||!eU(o.x,o.y,o.w,o.h)||eY(r,o)&&(eK(r,o)||eK(o,r)||eZ(r,o,a)||eZ(o,r,a)||t.push({metric:"groupOverlaps",detail:`${r.id} partially overlaps ${o.id}`}))}return{violations:t,groupById:a}}(u).violations);if(n.length)throw new en([{strategy:c,violations:n.map(e=>`${e.metric}: ${e.detail}`)}]);eQ.set(m,t)}catch(e){throw e instanceof en?e:new en([{strategy:c,violations:[e instanceof Error?e.message:String(e)]}])}return p||void 0===y||(r&&"svg"===t.output&&("sequence"===e||"flowchart"===e||"state"===e)?function(e,t,n,i){eV(e,t,n,i,!1)}:function(e,t,n,i){eV(e,t,n,i,!0)})(s,y,m,eQ.get(m)),m})}(t.family.id,e,e.source,{},i,!0),i&&eP.has(r)&&eX.set(r,n),r}),ey(p(e).textMeasurement,()=>(function(e,t,n,i){let r,a,h=p(e);if("scene"!==h.mode&&"family-svg"!==h.mode||!h.executionDecision)throw Error(`Resolved ${e.output} request has no graphical execution plan`);let g=e.renderOptions,y=h.family,w=(r=e.appearance.colors,a="png"===e.output&&!1!==r.embedFontImport?{...r,embedFontImport:!1}:r,{positioned:t.positioned,colors:a,resolved:m(e)}),b,v=!1,k;if("scene"===h.mode){let n=i?void 0:et("drawing",()=>e7(e,t)),r=n?void 0:et("scene",()=>(function(e,t){if("scene"!==p(e).mode)throw Error(`Resolved ${e.output} request has no Scene execution plan`);return e6(e,t)})(e,t));if(k=et("paint-certification",()=>(function(e,t){let n=e8.get(t)?.get(e)?.drawing??e7(e,t);if(n){let i=e8.get(t).get(e);if(ec("paint-certification",i.certification?"hit":"miss",void 0,"native"),i.certification)return i.certification;let r=i.evidence,a=s(r.header,r.paint,eQ.get(t),{outputSupported:!e.appearance.colors.shadow});i.certification=a;let o=Object.freeze({svg:n.svg,preparedText:n.preparedText,certification:a}),l=p(e).family.lowerScene;return i.producer===A(l)&&i.producer===L(l)?function(e,t,n){let i=eR.get(t);if(!i||i.request!==e||eD.get(i.key)!==i.snapshot)return;let r=eL.get(i.snapshot);if(r.oversized)return ec("native-drawing","store-skipped","weight-limit");let a=r.drawingWeight??2*i.key.length+4*n.svg.length+1024,o=eG.leastRecentlyUsed(),s=o&&eL.get(o.owner)?.lastUse,l=void 0!==s&&eW-s>=128;if(!r.locallyRepeated&&!l&&!eG.canFit(i.key,a))return ec("native-drawing","store-skipped","drawing-budget");let c={owner:i.snapshot,drawing:n},d=2*i.key.length+W(n,8388608)+1024;if(r.drawingWeight=d,d>8388608){r.oversized=!0,ec("native-drawing","store-skipped","weight-limit");return}r.locallyRepeated||l||eG.canFit(i.key,d)?eG.set(i.key,c,d):ec("native-drawing","store-skipped","drawing-budget")}(e,t,o):(ec("native-drawing","store-skipped","changed-producer"),eq(e,t,!1)),a}let i=e6(e,t),r=e4.get(t).get(e);if(ec("paint-certification",r.certification?"hit":"miss",void 0,"scene"),r.certification)return r.certification;let a=p(e),l=!e.appearance.colors.shadow&&("layout"===a.mode?"default"===e.appearance.inferredBackend:"scene"===a.mode&&a.backend?.inputName==="default");return r.certification=o(i,eQ.get(t),{outputSupported:l})})(e,t)),"strict"===g.layoutSafety&&"passed"!==k.status||"failed"===k.status&&h.backend?.inputName==="default")throw new l(k);b=n?.svg??et("backend",()=>{let t={seed:g.seed??0,...e.appearance.styled?{style:e.appearance.style}:{}};return i?.begin(t,r),h.backend.backend.render(r,t)}),v=h.backend?.inputName==="default"&&!y.id.startsWith("family:")&&(n?.preparedText??ek(r))}else{if("strict"===g.layoutSafety)throw new f("Strict layout safety requires native Scene evidence");b=et("backend",()=>y.renderSvg(w))}j(b,"backend/family SVG output");let $=R(b,w.colors);k?.repairs.length&&h.backend?.inputName==="default"&&($=function(e,t){let n=ef(e);if(!n)throw Error("Cannot certify a graphical output with no SVG root");let i=e.slice(n.start,n.end).replace(/\sviewBox="[^"]*"/g,""),r=` viewBox="${t.x} ${t.y} ${t.width} ${t.height}"`;return em(e,n,i.slice(0,-1)+r+">")}($,k.viewport)),j($,"color-resolved SVG output"),v||($=function(e,t){let n=function(e){let t=[],n=[],i=0;for(;i<e.length;){let r=e.indexOf("<",i);if(r<0){n.length>0&&i<e.length&&n[n.length-1].children.push({kind:"text-node",raw:e.slice(i)}),i=e.length;break}if(n.length>0&&r>i&&n[n.length-1].children.push({kind:"text-node",raw:e.slice(i,r)}),e.startsWith("\x3c!--",r)){let t=e.indexOf("--\x3e",r+4);if(t<0)return null;i=t+3;continue}let a=function(e,t){let n="";for(let i=t+1;i<e.length;i++){let t=e[i];if(n){t===n&&(n="");continue}if('"'===t||"'"===t){n=t;continue}if(">"===t)return i}return -1}(e,r);if(a<0)return null;let o=e.slice(r,a+1);if(/^<\?/.test(o)||/^<!/.test(o)){i=a+1;continue}let s=o.match(/^<\/\s*([\w:-]+)\s*>$/);if(s){let e=n.pop();if(!e||e.name!==s[1].toLowerCase())return null;e.closeStart=r,i=a+1;continue}let l=o.match(/^<\s*([\w:-]+)([\s\S]*?)(\/?)>$/);if(!l)return null;let c={kind:"element",name:l[1].toLowerCase(),attrs:l[2],openEnd:a+1,closeStart:a+1,children:[]};n.length>0?n[n.length-1].children.push(c):t.push(c),"/"!==l[3]&&n.push(c),i=a+1}return 0===n.length?t:null}(e);if(!n)return e;let i=[],r={size:0,weight:400,letterSpacing:0,mono:!1,fontStyle:"normal",fontFamily:t},a=(e,t,n,r=!1)=>{if(eN(e.attrs,"data-prepared-text"))return;let o=eF(t,e),s=r||eN(e.attrs,"data-literal-text"),l="text"===e.name&&!n,c=l||n&&eI(e);if(c&&eN(e.attrs,"textLength"))return;if(c&&!(l&&function e(t){return eO(t).some(t=>eI(t)||e(t))}(e))){let n,r,a,o=(n=[],r=!1,(a=(e,t,i)=>{let o=eF(t,e);if(!(!i&&eI(e))){if(!i&&eN(e.attrs,"textLength")){r=!0;return}for(let t of e.children)if("text-node"===t.kind){let e=eS(t.raw);e.length>0&&n.push({text:e,metrics:o})}else a(t,o,!1)}})(e,t,!0),{runs:n,blocked:r}),l=o.blocked?null:function(e,t=!1){let n=e.filter(e=>e.text.length>0);if(0===n.length||n.every(e=>0===e.text.trim().length))return null;let i=0,r=0,a=0;for(let e of n){if(!(e.metrics.size>0))return null;let n=eg(e.text).length;r>0&&n>0&&(i+=a),i+=e.metrics.mono?eb(e.text,e.metrics.size,e.metrics.letterSpacing,e.metrics.weight,e.metrics.fontStyle,e.metrics.fontFamily):t?ew(e.text,e.metrics.size,e.metrics.weight,e.metrics.fontStyle,e.metrics.fontFamily)+Math.max(0,n-1)*e.metrics.letterSpacing:ev(e.text,e.metrics.size,e.metrics.weight,e.metrics.letterSpacing,e.metrics.fontStyle,e.metrics.fontFamily),r=n,a=e.metrics.letterSpacing}return Math.round(1e3*i)/1e3}(o.runs,s);null!==l&&i.push({offset:e.openEnd-1,text:` textLength="${l}" lengthAdjust="spacingAndGlyphs" data-font-metrics="deterministic-fit"`})}let d=n||l;for(let t of eO(e))a(t,o,d,s)};for(let e of n)a(e,r,!1);let o=e;for(let e of i.sort((e,t)=>t.offset-e.offset))o=o.slice(0,e.offset)+e.text+o.slice(e.offset);return o}($,e.appearance.font)),j($,"font-geometry-fitted SVG output");let S=g.idPrefix??"";S&&j($=u($,S),"namespaced SVG output");let M=e.source.accessibility,C="c4"===y.id?"C4 architecture diagram":void 0;(t.injectAccessibility??!0)&&(M.title||M.descr||C)&&j($=function(e,t,n,i){let r=`${n}svg-title`,a=`${n}svg-desc`,o=[],s=[];if(t.title&&(o.push(`aria-labelledby="${r}"`),s.push(`<title id="${r}">${e9(t.title)}</title>`)),t.descr&&(o.push(`aria-describedby="${a}"`),s.push(`<desc id="${a}">${e9(t.descr)}</desc>`)),0===s.length&&!i)return e;let l=ef(e);if(!l||ep(l,"aria-labelledby")||ep(l,"aria-describedby"))return e;!i||t.title||ep(l,"aria-label")||o.push(`aria-label="${e9(i).replace(/"/g,"&quot;")}"`);let c=`${ep(l,"role")?"":' role="img"'} ${o.join(" ")}`,d=e.slice(l.start,l.end);return em(e,l,`${d.slice(0,-1)}${c}>${s.join("")}`)}($,M,S,C),"accessibility-projected SVG output"),i&&($=i.finish($)),j($=function(e){let t=ef(e);if(!t)return e;let n=eh(e);if(0===n.length)return e;let i=`am-${function(e){let t=0xdeadbeef,n=0x41c6ce57;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);t=Math.imul(t^r,0x9e3779b1),n=Math.imul(n^r,0x5f356495)}return t=Math.imul(t^t>>>16,0x85ebca6b)^Math.imul(n^n>>>13,0xc2b2ae35),n=Math.imul(n^n>>>16,0x85ebca6b)^Math.imul(t^t>>>13,0xc2b2ae35),`${(n>>>0).toString(36).padStart(7,"0")}${(t>>>0).toString(36).padStart(7,"0")}`}(e)}`,r=e;for(let e=n.length-1;e>=0;e--){let t=n[e];r=`${r.slice(0,t.start)}${function e(t,n){let i="",r=0,a=0,o,s=0;for(;r<t.length;){let l=t[r];if(o){"\\"===l?r++:l===o&&(o=void 0),r++;continue}if("/"===l&&"*"===t[r+1]){let e=t.indexOf("*/",r+2);r=e<0?t.length:e+2;continue}if('"'===l||"'"===l)o=l;else if("("===l)s++;else if(")"===l)s=Math.max(0,s-1);else if(";"===l&&0===s)i+=t.slice(a,r+1),a=r+1;else if("{"===l&&0===s){let o=function(e,t){let n=0,i;for(let r=t;r<e.length;r++){let t=e[r];if(i)"\\"===t?r++:t===i&&(i=void 0);else if("/"===t&&"*"===e[r+1]){let t=e.indexOf("*/",r+2);if(t<0)return e.length;r=t+1}else if('"'===t||"'"===t)i=t;else if("{"===t)n++;else if("}"===t&&0==--n)return r}return e.length}(t,r);i+=function(t,n,i){let r=t.match(/^(?:\s*\/\*[\s\S]*?\*\/)*/)[0],a=t.slice(r.length),o=/^\s*@([\w-]+)/.exec(a);if(o){let r=o[1].toLowerCase(),a=e5.has(r)?e(n,i):n;return`${t}{${a}}`}let s=(function(e){let t=[],n=0,i,r=0;for(let a=0;a<e.length;a++){let o=e[a];i?"\\"===o?a++:o===i&&(i=void 0):'"'===o||"'"===o?i=o:"("===o||"["===o?n++:")"===o||"]"===o?n--:","===o&&0===n&&(t.push(e.slice(r,a)),r=a+1)}return t.push(e.slice(r)),t})(a).map(e=>{let t,n;return t=e.match(/^\s*/)[0],0===(n=e.slice(t.length)).length?e:/^svg(?![\w-])/.exec(n)?`${t}svg.${i}${n.slice(3)}`:`${t}.${i} ${n}`}).join(",");return`${r}${s}{${n}}`}(t.slice(a,r),t.slice(r+1,o),n),a=r=o+1;continue}r++}return i+t.slice(a)}(r.slice(t.start,t.end),i)}${r.slice(t.end)}`}let a=r.slice(t.start,t.end),o=ep(t,"class"),s=o?`${a.slice(0,o.valueEnd-t.start)}${o.value?" ":""}${i}${a.slice(o.valueEnd-t.start)}`:`${a.slice(0,-1)} class="${i}">`;return em(r,t,s)}(c($)),"style-scoped SVG output"),g.compact&&j($=d($),"compacted SVG output");let E="png"===e.output?"strict":g.security,O=et("svg-security",()=>x($,E));return n.push(...O.diagnostics),j($=O.svg,"final SVG output"),Object.freeze({svg:$,executionDecision:h.executionDecision,...k?{layoutCertification:k}:{}})})(e,t,n,void 0)));return function(e,t,n){let i=Object.hasOwn(t,"layoutCertification")?t.layoutCertification:void 0;return function(e,t){let n=t,i;return Object.freeze({svg:e,get receipt(){return void 0===i&&(i=n(),n=void 0),i}})}(t.svg,()=>{var r;let a=(j(r=t.svg,"graphical projection digest input"),g(JSON.stringify(r)));return Object.freeze({...h(e,n),graphicalProjectionDigest:a,executionDecision:t.executionDecision,...i?{layoutCertification:Object.freeze({...i,outputDigest:a})}:{}})})}(e,i,n)})(e))}(i)}catch(i){let e=er(i),t=e?e.load:i?.loadHtmlEntityTable,n=e?"ELK"===e.dependency||"YAML"===e.dependency||"Agentic layout"===e.dependency||"Forest layout"===e.dependency?e.dependency:void 0:"function"==typeof t?"HTML entities":void 0;if(!n||"function"!=typeof t||r.has(n)||[...r.values()].includes(t))throw i;r.set(n,t),await t()}}export{te as renderLoadedFamilySvg,tt as renderLoadedFamilySvgWithReceipt};
@@ -1,16 +0,0 @@
1
- import{a as e,b as t,c as i}from"./chunk-4NILRBC7.js";import{a as a,h as l}from"./chunk-64JFHCJC.js";import{d as n}from"./chunk-J57YRC2M.js";import{a as o,c as r,d as s}from"./chunk-D6MQ7QSU.js";import{a as c,b as h,c as d,d as x,e as g,j as u,l as f}from"./chunk-XHU3A432.js";import{b as p,d as y}from"./chunk-5LKPDHPC.js";import{A as m,t as b,y as v,z as w}from"./chunk-V6I2VGNQ.js";import"./chunk-7UFOFWBA.js";import{a as A,b as k,c as L,d as z,h as S}from"./chunk-VRZKI33U.js";import{C as C,a as $,b as M,c as F,d as T,e as W,g as _,i as I}from"./chunk-QVSZOF5M.js";import{D as P,c as N,ma as O,s as j,y as B}from"./chunk-G4JBA7HU.js";import{a as E,i as Y,j as D,k as X}from"./chunk-3JTYTXA6.js";import{c as R,g as H,h as J}from"./chunk-YVNJDVQO.js";import{Aa as q,Ea as V,M as U,_ as Q,na as Z,o as G,x as K}from"./chunk-EIYLJ4FI.js";import{w as ee}from"./chunk-PJJSDGLB.js";import"./chunk-YHMTSXIR.js";import"./chunk-QCU5G5PZ.js";var et=Object.freeze({id:"xychart",upstreamId:"xychart",maturity:"stable",label:"XY chart",headers:["xychart","xychart-beta"],aliases:[],config:{section:"xyChart",keys:["width","height","useMaxWidth","useWidth","titleFontSize","titlePadding","chartOrientation","plotReservedSpacePercent","showDataLabel","showDataLabelOutsideBar","showTitle","showLegend","legendFontSize","legendPadding","xAxis","yAxis"]},identity:{id:"family:xychart",kind:"family",version:"1.0.0",compatibility:{core:"0.5.4"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:["value","category"],semanticRoles:["prelude","defs","chrome","grid","bar","series","point","axis","legend","title","label"],scenePrimitiveEvidence:[{role:"prelude",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"grid",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"bar",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"bar",primitive:"data-mark",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"series",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"point",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"point",primitive:"data-mark",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"axis",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"axis",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"legend",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"legend",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"legend",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"title",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"label",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]}],example:`xychart-beta
2
- title "Revenue"
3
- x-axis [Q1, Q2, Q3]
4
- y-axis "USD" 0 --> 100
5
- bar [45, 62, 80]`,detect:ee,detectLoose:ee}),ei={width:h,height:h,useMaxWidth:g,useWidth:h,titleFontSize:h,titlePadding:d,chartOrientation:u("vertical","horizontal"),plotReservedSpacePercent:f(0,100,!1),showDataLabel:g,showDataLabelOutsideBar:g,showTitle:g,showLegend:g,legendFontSize:h,legendPadding:d,xAxis:c("an axis-config object",e=>!!e&&"object"==typeof e&&!Array.isArray(e)),yAxis:c("an axis-config object",e=>!!e&&"object"==typeof e&&!Array.isArray(e))},ea={showLabel:g,labelFontSize:h,labelPadding:d,labelRotation:x,showTitle:g,titleFontSize:h,titlePadding:d,showTick:g,tickLength:d,tickWidth:h,showAxisLine:g,axisLineWidth:h},el={showLabel:!0,labelFontSize:14,labelPadding:5,showTitle:!0,titleFontSize:16,titlePadding:5,showTick:!0,tickLength:5,tickWidth:2,showAxisLine:!0,axisLineWidth:2},en={width:700,height:500,useMaxWidth:!0,useWidth:void 0,titleFontSize:20,titlePadding:10,chartOrientation:"vertical",plotReservedSpacePercent:50,showDataLabel:!1,showDataLabelOutsideBar:!1,showTitle:!0,showLegend:!0,legendFontSize:14,legendPadding:5,xAxis:{...el},yAxis:{...el}};function eo(e){return{showLabel:ec(e?.showLabel,el.showLabel),labelFontSize:er(e?.labelFontSize,el.labelFontSize),labelPadding:es(e?.labelPadding,el.labelPadding),showTitle:ec(e?.showTitle,el.showTitle),titleFontSize:er(e?.titleFontSize,el.titleFontSize),titlePadding:es(e?.titlePadding,el.titlePadding),showTick:ec(e?.showTick,el.showTick),tickLength:es(e?.tickLength,el.tickLength),tickWidth:er(e?.tickWidth,el.tickWidth),showAxisLine:ec(e?.showAxisLine,el.showAxisLine),axisLineWidth:er(e?.axisLineWidth,el.axisLineWidth)}}function er(e,t){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:t}function es(e,t){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:t}function ec(e,t){return"boolean"==typeof e?e:t}function eh(e){let t=Math.max(0,...e.series.map(e=>e.data.length));return e.xAxis.categories?Math.max(1,e.xAxis.categories.length,t):Math.max(1,t)}function ed(e,t=eh(e)){if(e.xAxis.range){let{min:i,max:a}=e.xAxis.range,l=t>1?(a-i)/(t-1):0;return Array.from({length:t},(e,t)=>i+l*t)}return Array.from({length:t},(e,t)=>t)}function ex(e,t=eh(e)){return e.xAxis.categories?Array.from({length:t},(t,i)=>e.xAxis.categories[i]??String(i+1)):e.xAxis.range?ed(e,t).map(e=>ep(e)):Array.from({length:t},(e,t)=>String(t+1))}function eg(e,t){let i=Math.min(e.min,e.max);return Math.min(Math.max(e.min,e.max),Math.max(i,t))}function eu(e){if(Number.isInteger(e))return String(e);let t=e.toFixed(+(10>Math.abs(e)));return 0===Number(t)&&0!==e?String(e):t}function ef(e,t,i=10){if(!(i>0))return[];if(e===t)return[e];let a=t<e,[l,n,o]=function e(t,i,a){let l=(i-t)/Math.max(0,a),n=Math.floor(Math.log10(l)),o=l/Math.pow(10,n),r=o>=Math.sqrt(50)?10:o>=Math.sqrt(10)?5:o>=Math.sqrt(2)?2:1,s,c,h;return n<0?(s=Math.round(t*(h=Math.pow(10,-n)/r)),c=Math.round(i*h),s/h<t&&s++,c/h>i&&c--,h=-h):(s=Math.round(t/(h=Math.pow(10,n)*r)),c=Math.round(i/h),s*h<t&&s++,c*h>i&&c--),c<s&&.5<=a&&a<2?e(t,i,2*a):[s,c,h]}(a?t:e,a?e:t,i);if(!(n>=l))return[];let r=n-l+1,s=Array(r);if(a)if(o<0)for(let e=0;e<r;e++)s[e]=-((n-e)/o);else for(let e=0;e<r;e++)s[e]=(n-e)*o;else if(o<0)for(let e=0;e<r;e++)s[e]=-((l+e)/o);else for(let e=0;e<r;e++)s[e]=(l+e)*o;return s.map(ey)}function ep(e){return!Number.isFinite(e)||Number.isInteger(e)?String(e):Number(e.toPrecision(12)).toString()}function ey(e){return Math.round(1e12*e)/1e12}var em={nodeLabelFontSize:14,edgeLabelFontSize:16,groupHeaderFontSize:20,nodeLabelFontWeight:400,edgeLabelFontWeight:400,groupHeaderFontWeight:500,nodePaddingX:0,nodePaddingY:0,nodeLineWidth:0,edgeLineWidth:3,groupCornerRadius:0,groupPaddingX:0,groupPaddingY:0,groupLineWidth:R.outerBox};function eb(e,t,i,a){let l=e.series.some(e=>"line"===e.type)?t:0,n=e=>e.showLabel&&e.showTick?e.tickWidth/2:0;return{value:Math.max(.5,n(i),l),position:a?Math.max(n(a),l):0}}function ev(e){return e.showAxisLine?e.axisLineWidth/2:0}function ew(e,t,i,a,l,n,o){if(!t.showLegend)return{items:[],size:0,hiddenLabels:[]};let r=function(e){if(!(e.length>1||e.some(e=>void 0!==e.label&&e.label.length>0)))return[];let t=[],i=0,a=0;for(let l=0;l<e.length;l++){let n=e[l],o="bar"===n.type?i++:a++,r="bar"===n.type?`Bar ${o+1}`:`Line ${o+1}`;t.push({label:void 0!==n.label&&n.label.length>0?n.label:r,type:n.type,seriesIndex:o,colorIndex:l})}return t}(e.series);if(0===r.length)return{items:[],size:0,hiddenLabels:[]};let s=Math.ceil(Math.max(...r.map(e=>o.legend(e.label,t.legendFontSize)))),c=2*t.legendPadding+12+6+s,h=Math.max(...r.map(e=>o.block("legend",e.label,t.legendFontSize).height),12)+t.legendPadding,d=t.legendPadding+r.length*h;if(c>i||d>n)return{items:[],size:0,hiddenLabels:r.map(e=>e.label)};let x=a-c+t.legendPadding;return{items:r.map((e,i)=>({label:e.label,x:x,y:l+t.legendPadding+i*h,type:e.type,seriesIndex:e.seriesIndex,colorIndex:e.colorIndex})),size:c,hiddenLabels:[]}}function eA(e,t,i,a){if(!e||!t.showTitle)return{height:0};let l=a.wrapTitle(e,t.titleFontSize,Math.max(1,t.width-2*t.titlePadding)),n=(l.height,l.lineHeight,l.height+2*t.titlePadding);return n>i?{height:0}:{height:n,title:{text:l.text,block:l,x:t.width/2,y:t.titlePadding+l.height/2}}}function ek(e,t,i,a,l,n=e.titleFontSize){let o=a,r={...e,showAxisLine:!1,showLabel:!1,showTick:!1,showTitle:!1};if(e.showAxisLine&&o>e.axisLineWidth&&(r.showAxisLine=!0,o-=e.axisLineWidth),e.showLabel&&i.length>0){let t=l()+2*e.labelPadding;t<=o&&(r.showLabel=!0,o-=t)}if(e.showTick&&o>=e.tickLength&&(r.showTick=!0,o-=e.tickLength),e.showTitle&&t){let t=n+2*e.titlePadding;t<=o&&(r.showTitle=!0,o-=t)}return{config:r,size:a-o}}function eL(e,t,i,a,l){let n=t?l.block("axisTitle",t,e.titleFontSize).height-e.titleFontSize*(K-1):e.titleFontSize;return ek(e,t,i,a,()=>Math.max(e.labelFontSize,...i.map(t=>l.block("tick",t,e.labelFontSize).height-e.labelFontSize*(K-1))),n)}function ez(e,t,i,a,l,n){return ek(e,t,i,a,()=>Math.max(...i.map(t=>l.tick(t,e.labelFontSize))),t?l.block("axisTitle",t,e.titleFontSize,Math.max(1,n-4)).height-e.titleFontSize*(K-1):e.titleFontSize)}function eS(e,t,i,a,l,n,o){let r=l.showAxisLine?l.axisLineWidth:0,s=l.showTick?l.tickLength:0,c=a.y+a.height+r+s+l.labelPadding+.4*l.labelFontSize,h=t.map(e=>n.tick(e,l.labelFontSize)),d=h.length?Math.max(...h):0,x=e.map(e=>i(e)),g=1/0;for(let e=1;e<x.length;e++)g=Math.min(g,Math.abs(x[e]-x[e-1]));let u=Number.isFinite(g)&&g>0?Math.max(1,Math.ceil((d+6)/g)):1;return e.map((e,l)=>{let n=l%u==0?t[l]:"",d=i(e);if(void 0!==o&&n){let e=h[l]/2;d=Math.max(2+e,Math.min(o-2-e,d))}return{label:n,x:i(e),y:a.y+a.height+r,tx:i(e),ty:a.y+a.height+r+s,labelX:d,labelY:c,textAnchor:"middle"}})}function eC(e,t,i,a,l){let n=l.showAxisLine?l.axisLineWidth:0,o=l.showTick?l.tickLength:0,r=a.x-n-o-l.labelPadding;return e.map((e,l)=>({label:t[l],x:a.x-n,y:i(e),tx:a.x-n-o,ty:i(e),labelX:r,labelY:i(e),textAnchor:"end"}))}function e$(e,t){let i=e.x-(t.showAxisLine?t.axisLineWidth/2:0);return{x1:i,y1:e.y,x2:i,y2:e.y+e.height}}function eM(e,t,i,a,l){if(!e||!i.showTitle)return;let n=l.block("axisTitle",e,i.titleFontSize,Math.max(1,a-4)),o=n.width/2,r=t.y+t.height/2;return{text:e,block:n,x:i.titlePadding+.8*i.titleFontSize,y:2*o+4>=a?a/2:Math.min(a-2-o,Math.max(2+o,r)),rotate:-90}}function eF(e,t,i,a){let l=e.xAxis.categories;if(!l||e.xAxis.range||!t.xAxis.showLabel)return[];let n=(e,t)=>t<l.length&&""!==e,o=ex(e);return i.showLabel?o.filter((e,t)=>n(e,t)&&a[t]?.label===""):o.filter(n)}function eT(e,t,i,a,l){if(!a.showDataLabel||0===e.length)return{dataLabels:[],unlabeledBars:[]};let n=e.map(e=>eu(e.value)),o=16;for(;o>=8&&!e.every((e,i)=>{let a=l.block("data",n[i],o);return t?a.height<=e.height-4:a.width<=e.width-8});o--);if(o<8)return{dataLabels:[],unlabeledBars:[...e]};let r=[],s=[];return e.forEach((e,c)=>{let h=n[c],d=l.block("data",h,o),x=d.width,g=t?e.width-12>=x:e.height-10>=d.height,u=a=>(t?a?i.x+i.width-(e.x+e.width):e.x-i.x:a?e.y-i.y:i.y+i.height-(e.y+e.height))>=(t?x:d.height)+4,f=e.value>0||0===e.value&&(u(!0)||!u(!1)),p=u(f),y=a.showDataLabelOutsideBar?p?"outside":g?"inside":void 0:g?"inside":p?"outside":void 0;if(!y)return void s.push(e);if(t){let t="outside"===y===f,i=f?e.x+e.width:e.x,a="outside"===y?4:-8;r.push({bar:e,text:h,fontSize:o,placement:y,x:i+(f?a:-a),y:e.y+e.height/2,anchor:t?"start":"end",dominantBaseline:"middle"});return}let m="inside"===y?f:!f;r.push({bar:e,text:h,fontSize:o,placement:y,x:e.x+e.width/2,y:"inside"===y?f?e.y+8:e.y+e.height-8:f?e.y-4:e.y+e.height+4,anchor:"middle",...m?{dominantBaseline:"hanging"}:{}})}),{dataLabels:r,unlabeledBars:s}}function eW(e,t,i,a,l,n,o,r){let s=e.series.filter(e=>"bar"===e.type).length;if(0===s)return[];let c=.95*i,h=c/Math.max(1,s),d=[],x=0,g=0,u=a(eg(l,0));for(let i of e.series){if("bar"!==i.type){g++;continue}for(let e=0;e<i.data.length;e++){let s=t(e)-c/2+x*h,f=a(eg(l,i.data[e])),p=Math.min(f,u),y=Math.abs(u-f);d.push({x:r?p:s,y:r?s:p,width:r?y:h,height:r?h:y,value:i.data[e],label:n[e],seriesIndex:x,colorIndex:o[g]})}x++,g++}return d}function e_(e,t,i,a,l,n,o){let r=[],s=0,c=0;for(let h of e.series){if("line"!==h.type){c++;continue}r.push({points:h.data.map((e,n)=>{let r=t(n),s=i(eg(a,e));return{x:o?s:r,y:o?r:s,value:e,label:l[n],...h.pointLabels?.[n]!==void 0?{textLabel:h.pointLabels[n]}:{}}}),seriesIndex:s,colorIndex:n[c]}),s++,c++}return r}var eI=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(?:\s+([\s\S]+))?$/;function eP(e,t=!1,i){let a=[],l=[];for(let n of eU(e)){let e=n.trim().match(eI);if(!e)throw Error(`Invalid XYChart point: "${n.trim()}"`);let o=Number(e[1]);if(!Number.isFinite(o))throw Error(`XYChart point must be finite: "${n.trim()}"`);let r=e[2]?.trim();if(t&&void 0!==r&&!r.startsWith('"'))throw Error(`XYChart point labels must be double-quoted: "${n.trim()}"`);let s=void 0===r?void 0:eJ(r);if(null===s)throw Error(`Invalid XYChart point label: "${n.trim()}"`);a.push(o),W("xychart")&&I("xychart","appendSeriesValue",{index:a.length-1,value:o},{line:i,unit:"normalized"}),l.push(s),W("xychart")&&I("xychart","appendSeriesPointLabel",{index:l.length-1,label:s},{line:i,unit:"normalized"})}if(0===a.length)throw Error("XYChart series must contain at least one point");return{values:a,labels:l}}var eN=String.raw`[+-]?(?:\d+(?:\.\d+)?|\.\d+)`,eO=RegExp(`^(${eN})\\s*-->\\s*(${eN})$`),ej=/[^A-Za-z0-9&+=*.#_\s-]/,eB=/[^A-Za-z&+=*.#_\s-]/,eE=/(?<![A-Za-z])(?:xychart-beta|xychart|vertical|horizontal|[xy]-axis|title|line|bar)(?![A-Za-z0-9_])/i;function eY(e,t,i,a,l){if(!l||e.startsWith('"'))return;let n=e.startsWith("'")?"'":("xychart_unquoted_axis_title"===a?eB:ej).exec(t)?.[0];if(void 0!==n)return l(a,`${i} ${JSON.stringify(t)} has ${JSON.stringify(n)} outside a double-quoted string, which pinned Mermaid rejects`);let o=eE.exec(t)?.[0];void 0!==o&&l(a,`${i} ${JSON.stringify(t)} has the keyword ${JSON.stringify(o)} outside a double-quoted string, where pinned Mermaid ends the text: it rejects the line or reads another statement there`)}function eD(e,t,i,a,l){let n=t.trim();if(0===n.length)return!1;let o=eV(n);if(o&&"x"===i){let t=o.prefix,n=t.length>0?eJ(t):void 0;if(null===n)return!1;let r=function(e){let t=eU(e),i=[];for(let e of t){let t=eJ(e);if(null===t||0===t.length)throw j({what:`Invalid XYChart category ${JSON.stringify(e)}`,expectedForm:"nonempty categories separated by commas",example:'x-axis ["A", "B"]'});i.push(t)}return i}(o.contents);if(0===r.length)return!1;if(l)for(let e of eU(o.contents))eY(e,e,"XY chart category","xychart_unquoted_text",l);return void 0!==n&&(eY(t,n,`XY chart ${i}-axis title`,"xychart_unquoted_axis_title",l),e.title=n,W("xychart")&&I("xychart","setAxisTitle",{axis:i,title:n},{line:a,unit:"normalized"})),e.categories=r,W("xychart")&&I("xychart","setAxisCategories",{axis:i,categories:r},{line:a,unit:"normalized"}),delete e.range,W("xychart")&&I("xychart","deleteAxisRange",i,{line:a,unit:"normalized"}),delete e.rangeAuthored,W("xychart")&&I("xychart","deleteAxisRangeAuthored",i,{line:a,unit:"normalized"}),e.authored=!0,W("xychart")&&I("xychart","setAxisAuthored",{axis:i,authored:!0},{line:a,unit:"normalized"}),!0}let r=eX(n);return!!r&&(void 0!==r.title&&(eY(n,r.title,`XY chart ${i}-axis title`,"xychart_unquoted_axis_title",l),e.title=r.title,W("xychart")&&I("xychart","setAxisTitle",{axis:i,title:e.title},{line:a,unit:"normalized"})),r.range&&(e.range=r.range,W("xychart")&&I("xychart","setAxisRange",{axis:i,range:e.range},{line:a,unit:"normalized"}),e.rangeAuthored=!0,W("xychart")&&I("xychart","setAxisRangeAuthored",{axis:i,authored:!0},{line:a,unit:"normalized"}),delete e.categories,W("xychart")&&I("xychart","deleteAxisCategories",i,{line:a,unit:"normalized"})),e.authored=!0,W("xychart")&&I("xychart","setAxisAuthored",{axis:i,authored:!0},{line:a,unit:"normalized"}),!0)}function eX(e){let t=e=>({min:parseFloat(e[1]),max:parseFloat(e[2])}),i=e.match(eO);if(i)return{range:t(i),words:!1};let a=eH(e);if(!a)return null;let l=a.rest.match(eO);if(l)return{title:a.value,range:t(l),words:!1};if(0===a.rest.length)return{title:a.value,words:!1};if(/^["']/.test(e))return null;let n=e,o,r=e.lastIndexOf("--\x3e");if(r>=0){let i=e.slice(0,r).trimEnd(),a=i.length;for(;a>0&&!/\s/.test(i[a-1]);)a--;let l=`${i.slice(a)} --> ${e.slice(r+3).trim()}`.match(eO);if(!l)return null;n=i.slice(0,a).trim(),o=t(l)}return/^[^"[\]]+$/.test(n)&&!n.includes("--\x3e")?{title:n,...o?{range:o}:{},words:!0}:null}var eR={subject:"XYChart text entity",example:'title "Say #quot;hi#quot;"'};function eH(e){let t=e.trim();if(0===t.length)return;if(t.startsWith('"')||t.startsWith("'")){let e=function(e){let t=e[0];if('"'!==t&&"'"!==t)return null;let i="",a=!1;for(let l=1;l<e.length;l++){let n=e[l];if(a){n===t||"\\"===n?i+=n:i+=`\\${n}`,a=!1;continue}if("\\"===n){a=!0;continue}if(n===t)return{value:i,endIndex:l};i+=n}return null}(t);return e?{value:n(e.value,eR),rest:t.slice(e.endIndex+1).trim()}:void 0}let i=t.match(/^([^\s]+)(?:\s+(.*))?$/);if(i)return{value:i[1],rest:(i[2]??"").trim()}}function eJ(e){let t=e.trim();if(!t)return null;if(!t.startsWith('"')&&!t.startsWith("'"))return t;let i=eH(t);return i&&0===i.rest.length?i.value:null}function eq(e){let t=e.match(/^(bar|line)\b/i);if(!t)return null;let i=eV(e.slice(t[0].length).trim());if(!i)return null;let a=i.prefix.length>0?function(e){if(!e)return;let t=e.trim();return t?eJ(t):void 0}(i.prefix):void 0;return null===a?null:{type:t[1].toLowerCase(),label:a,points:i.contents}}function eV(e){let t=null,i=!1,a=-1,l=0,n=-1;for(let o=0;o<e.length;o++){let r=e[o];if(t){if(i){i=!1;continue}if("\\"===r){i=!0;continue}r===t&&(t=null);continue}if('"'===r||"'"===r){t=r;continue}if("["===r){0===l&&(a=o),l++;continue}if("]"===r){if(0===l)return null;0==--l&&(n=o)}}return t||0!==l||a<0||n<a||e.slice(n+1).trim()?null:{prefix:e.slice(0,a).trim(),contents:e.slice(a+1,n)}}function eU(e){let t=[],i="",a=null,l=!1;for(let n=0;n<e.length;n++){let o=e[n];if(a){if(i+=o,l){l=!1;continue}if("\\"===o){l=!0;continue}o===a&&(a=null);continue}if('"'===o||"'"===o){a=o,i+=o;continue}if(","===o){eQ(t,i),i="";continue}i+=o}if(a)throw Error("Unclosed quoted XYChart value");return eQ(t,i),t}function eQ(e,t){e.push(t.trim())}function eZ(e){let t=v(e,["config"])??e,i=v(e,["config","xyChart"])??v(e,["xyChart"])??{},a=e4(i,["chartOrientation"]),l={width:e1(i,["width"]),height:e1(i,["height"]),useMaxWidth:e0(i,["useMaxWidth"])??e0(t,["useMaxWidth"]),useWidth:e1(i,["useWidth"])??e1(t,["useWidth"]),titleFontSize:e1(i,["titleFontSize"]),titlePadding:e2(i,["titlePadding"]),chartOrientation:"horizontal"===a||"vertical"===a?a:void 0,plotReservedSpacePercent:e1(i,["plotReservedSpacePercent"]),showDataLabel:e0(i,["showDataLabel"]),showDataLabelOutsideBar:e0(i,["showDataLabelOutsideBar"]),showTitle:e0(i,["showTitle"]),showLegend:e0(i,["showLegend"]),legendFontSize:e1(i,["legendFontSize"]),legendPadding:e2(i,["legendPadding"]),xAxis:eK(i,"xAxis"),yAxis:eK(i,"yAxis")};return W("xychart")&&I("xychart","resolveConfig",l),l}function eG(e){let t=v(e,["config"])??e,i=v(e,["config","themeVariables","xyChart"])??v(e,["themeVariables","xyChart"])??{},a={backgroundColor:e4(i,["backgroundColor"]),themeCss:e4(t,["themeCSS"]),titleColor:e4(i,["titleColor"]),xAxisLabelColor:e4(i,["xAxisLabelColor"]),xAxisTickColor:e4(i,["xAxisTickColor"]),xAxisLineColor:e4(i,["xAxisLineColor"]),xAxisTitleColor:e4(i,["xAxisTitleColor"]),yAxisLabelColor:e4(i,["yAxisLabelColor"]),yAxisTickColor:e4(i,["yAxisTickColor"]),yAxisLineColor:e4(i,["yAxisLineColor"]),yAxisTitleColor:e4(i,["yAxisTitleColor"]),legendTextColor:e4(i,["legendTextColor"]),dataLabelColor:e4(i,["dataLabelColor"]),plotColorPalette:function(e,t){let i=m(e,t);if(i&&i.length>0){let e=i.filter(e=>"string"==typeof e).map(e=>e.trim()).filter(Boolean);if(e.length>0)return e}var a=e4(e,t);if(!a)return;let l=E(a).map(e=>e.trim()).filter(Boolean);return l.length>0?l:void 0}(i,["plotColorPalette"])};return W("xychart")&&I("xychart","resolveTheme",a),a}function eK(e,t){let i=v(e,[t]);if(!i)return;let a=e0(i,["showLabel"]),l=e1(i,["labelFontSize"]),n=e2(i,["labelPadding"]),o=e0(i,["showTitle"]),r=e1(i,["titleFontSize"]),s=e2(i,["titlePadding"]),c=e0(i,["showTick"]),h=e2(i,["tickLength"]),d=e1(i,["tickWidth"]),x=e0(i,["showAxisLine"]),g=e1(i,["axisLineWidth"]);if(void 0!==a||void 0!==l||void 0!==n||void 0!==o||void 0!==r||void 0!==s||void 0!==c||void 0!==h||void 0!==d||void 0!==x||void 0!==g)return{showLabel:a,labelFontSize:l,labelPadding:n,showTitle:o,titleFontSize:r,titlePadding:s,showTick:c,tickLength:h,tickWidth:d,showAxisLine:x,axisLineWidth:g}}function e0(e,t){let i=w(e,t);return"boolean"==typeof i?i:void 0}function e1(e,t){let i=w(e,t);return"number"==typeof i&&Number.isFinite(i)&&i>0?i:void 0}function e2(e,t){let i=w(e,t);return"number"==typeof i&&Number.isFinite(i)&&i>=0?i:void 0}function e4(e,t){let i=w(e,t);return"string"==typeof i&&i.trim().length>0?i.trim():void 0}function e5(e){return r(e,{escapes:!1,restOfLine:/(?<!\w)acc(?:Title|Descr)\s*:/iy,block:e6})}function e3(e,t,i){let a=[],l=!1,n=e5(e);for(let r=0;r<e.length;r++){let c=r,h=e[r].trim();if(!h||h.startsWith("%%"))continue;if(l){a.push(h),i?.push(c),h.includes("}")&&(l=!1);continue}let d=/^acc(?:Title|Descr)\b/i.test(h);if(!d){let t=n[r];t>r&&(h=s(e,r,t).trim(),r=t)}for(let e of d?tt(h,t):function(e,t){let i=o(e,e6);if(i<0)return tt(e,t);let a=e.slice(0,i).trimEnd(),l=tt(a,t),n=l.length-1;return n>=0&&e8.test(l[n])&&(l[n]=e.slice(a.length-l[n].length).trim()),l}(h,t)){a.push(e),i?.push(c);let t=e.match(/^accDescr\s*:?\s*\{(.*)$/i);t&&!t[1].includes("}")&&(l=!0)}}return a}var e8=/^acc(?:Title|Descr)\s*:/i,e6=/(?<!\w)accDescr\s*\{/iy,e7=/(?:title|[xy]-axis|bar|line)(?!\w)|acc(?:Title\s*:|Descr\s*[:{])/iy;function e9(e,t,i){let a=0;if(i.length>0){let l=te(t.slice(0,i[0]).trim());for(let n=0;n<i.length;n++){let o=te(t.slice(i[n],i[n+1]).trim());if(l&&o&&("title"!==l||"data"===o)){let r=t.slice(a,i[n]).trim();r&&e.push(r),a=i[n],l=o}else"title"!==l&&(l=o)}}let l=t.slice(a).trim();l&&e.push(l)}function te(e){let t=e.match(/^(title|x-axis|y-axis)\s+([\s\S]+)$/i);if(!t){let t=eq(e);return t&&eU(t.points).every(e=>eI.test(e.trim()))?"data":void 0}let i=t[2].trim(),a=i.startsWith('"')||i.startsWith("'");if(/^title$/i.test(t[1]))return null===eJ(i)?void 0:a?"data":"title";let l=/^x/i.test(t[1])?eV(i):null;if(l)return l.prefix&&null===eJ(l.prefix)?void 0:"data";let n=eX(i);return n?n.range||a?"data":n.words?"title":"text":void 0}function tt(e,t){let i=[],a="",l=null,n=0,o=0,r=!1,s=[],c=!1,h=!0;for(let t=0;t<e.length;t++){let d=e[t];if(l){if(a+=d,r){r=!1;continue}if("\\"===d){r=!0;continue}d===l&&(l=null);continue}if('"'===d||"'"===d){l=d,a+=d;continue}if("["===d){n++,a+=d;continue}if("]"===d){n--,a+=d;continue}if("{"===d){o++,a+=d;continue}if("}"===d){o--,a+=d;continue}if(";"===d&&0===n&&0===o){e9(i,a,s),a="",s=[],c=!1,h=!0;continue}if(h&&0===n&&0===o&&/[abltxy]/i.test(d)&&!/\w/.test(e[t-1]??" ")){e7.lastIndex=t;let l=e7.exec(e);if(l&&/^acc/i.test(l[0])){let n=[];if(e9(n,a,s),0===n.length||void 0!==te(n[n.length-1])){if(i.push(...n),a="",s=[],!l[0].endsWith("{"))return i.push(e.slice(t).trim()),i;let o=e.indexOf("}",t+l[0].length);if(o>=0){a+=e.slice(t,o+1),t=o,c=!0,h=!1;continue}}h=!1}else l&&c&&s.push(a.length)}c||/\s/.test(d)||(c=!0),a+=d}if(t&&(l||0!==n||0!==o))throw Error(`Unclosed XYChart delimiter in line: "${e}"`);return e9(i,a,s),i}function ti(e,t,i,a,l,n){if(i.config.showAxisLine&&t.push(e.shape({id:`axis:${a}:line`,role:"axis",geometry:{kind:"line",x1:tn(i.line.x1),y1:tn(i.line.y1),x2:tn(i.line.x2),y2:tn(i.line.y2)},paint:{stroke:l,strokeWidth:String(i.config.axisLineWidth)},attributes:{className:`xychart-axis-line xychart-${a}-axis-line`}})),i.config.showTick)for(let l of i.ticks)t.push(e.shape({id:`axis:${a}:tick:${l.label}`,role:"axis",geometry:{kind:"line",x1:tn(l.x),y1:tn(l.y),x2:tn(l.tx),y2:tn(l.ty)},paint:{stroke:n,strokeWidth:String(i.config.tickWidth)},attributes:{className:`xychart-tick xychart-${a}-tick`}}))}function ta(e,t,i,a,l,n,o){for(let r of i){let i=r.block?.text??H(r.label,n.edgeTextTransform),s="end"===r.textAnchor;t.push(e.text({id:`axis:${l}:label:${r.label}`,role:"axis",text:i,block:r.block,x:r.labelX,y:r.labelY,fontSize:a,fontWeight:n.nodeLabelFontWeight,letterSpacing:n.nodeLetterSpacing,display:"literal",anchor:r.textAnchor,...s?{dominantBaseline:"middle",baselineShift:0}:{},paint:{fill:o},attributes:{className:`xychart-label xychart-${l}-label`}}))}}function tl(e,t,i){let n=t??a,o=e.theme.plotColorPalette,r=l(Math.max(0,...e.bars.map(e=>e.colorIndex),...e.lines.map(e=>e.colorIndex))+1,{accent:n,bg:i}),s=e=>o&&o.length>0?o[e%o.length]:r[e];return{concrete:s,css:e=>!(o&&o.length>0)&&0===e&&r.length<=6&&r[0]===n?`var(--accent, ${a})`:s(e)}}function tn(e){return Math.round(100*e)/100}function to(e){return tn(e).toString()}var tr=N(function(e,a){let l,n,o,r,s,{positioned:c,colors:h,resolved:d}=a,x=d.renderOptions,g=h.font??"Inter",u=x.transparent??!1,f=x.interactive??!1,p=[],y=J(x,em,d.styleFace),m=(l=c.theme,{gridStroke:y.edgeStrokeColor??"color-mix(in srgb, var(--fg) 14%, transparent)",titleColor:l.titleColor??y.groupTextColor??y.nodeTextColor??"var(--_text)",labelColor:y.nodeTextColor??"var(--_text)",xAxisLabelColor:l.xAxisLabelColor??y.nodeTextColor??"var(--_text)",yAxisLabelColor:l.yAxisLabelColor??y.nodeTextColor??"var(--_text)",xAxisTickColor:l.xAxisTickColor??y.groupTextColor??"var(--_text-sec)",yAxisTickColor:l.yAxisTickColor??y.groupTextColor??"var(--_text-sec)",xAxisLineColor:l.xAxisLineColor??y.edgeStrokeColor??"var(--_text-sec)",yAxisLineColor:l.yAxisLineColor??y.edgeStrokeColor??"var(--_text-sec)",xAxisTitleColor:l.xAxisTitleColor??y.edgeTextColor??y.nodeTextColor??"var(--_text)",yAxisTitleColor:l.yAxisTitleColor??y.edgeTextColor??y.nodeTextColor??"var(--_text)",legendTextColor:l.legendTextColor??y.nodeTextColor??"var(--_text)"}),b=!!c.theme.plotColorPalette?.length,v=Math.max(0,...c.bars.map(e=>e.colorIndex),...c.lines.map(e=>e.colorIndex)),w=(n=`mermaid-${function(e){let t=[e.width,e.height,e.title?.text??"",e.accessibility?.title??"",e.accessibility?.description??"",e.bars.length,e.lines.length].join("|"),i=5381;for(let e=0;e<t.length;e++)i=(i<<5)+i^t.charCodeAt(e);return Math.abs(i>>>0).toString(36)}(c)}`,o=c.accessibility?.title?`chart-title-${n}`:void 0,r=c.accessibility?.description?`chart-desc-${n}`:void 0,s=c.config.useWidth??c.width,{openTag:{width:c.config.useMaxWidth?"100%":String(s),height:c.config.useMaxWidth?"100%":String(Math.round(c.height*(s/Math.max(1,c.width)))),style:c.config.useMaxWidth?`max-width:${s}px`:void 0,attrs:{id:n,class:"xychart",role:o||r?"img":void 0,"aria-roledescription":"xychart","aria-labelledby":o,"aria-describedby":r}},title:c.accessibility?.title?`<title id="${o}">${U(c.accessibility.title)}</title>`:void 0,description:c.accessibility?.description?`<desc id="${r}">${U(c.accessibility.description)}</desc>`:void 0}),A=X(c.width,c.height,h,u,w.openTag).replace("<svg ",`<svg data-xychart-colors="${v}" `),{style:k,defs:L}=function(e,t,a,l){let n=new Set;for(let t of e.bars)n.add(t.colorIndex);for(let t of e.lines)n.add(t.colorIndex);let o=[],r=tl(e,a,l);for(let e of[...n].sort((e,t)=>e-t))o.push(` --xychart-color-${e}: ${r.css(e)};`);let s=t?i("xychart",["xychart-bar-group","xychart-dot-group"]):"",c=o.length>0?`
6
- svg {
7
- ${o.join(`
8
- `)}
9
- }`:"",h=e.theme.themeCss?`
10
- ${e.theme.themeCss}
11
- `:"";return{style:`<style>
12
- .xychart-data-label { pointer-events: none; }${c}${s}${h}
13
- </style>`,defs:""}}(c,f,h.accent,h.bg);p.push(e.documentOpen({id:"prelude",width:c.width,height:c.height,colors:h,transparent:u,font:g,hasMonoFont:!1,extraCss:k},A+`
14
- `+D(g,!1,h.shadow,h.embedFontImport)+`
15
- `+k));let z=Y(h);z&&p.push(e.definitions({id:"shadow-defs"},`<defs>${z}</defs>`)),L&&p.push(e.definitions({id:"defs"},L)),w.title&&p.push(e.documentContent({id:"acc-title",role:"chrome",nonPaint:"accessibility"},w.title)),w.description&&p.push(e.documentContent({id:"acc-desc",role:"chrome",nonPaint:"accessibility"},w.description));let S={stroke:m.gridStroke,strokeWidth:"1",...y.edgeStrokeColor?{opacity:"0.25"}:{}};c.gridLines.forEach((t,i)=>{p.push(e.shape({id:`grid:y:${i}`,role:"grid",geometry:{kind:"line",x1:tn(t.x1),y1:tn(t.y1),x2:tn(t.x2),y2:tn(t.y2)},paint:S,attributes:{className:"xychart-grid"}}))}),ti(e,p,c.xAxis,"x",m.xAxisLineColor,m.xAxisTickColor),ti(e,p,c.yAxis,"y",m.yAxisLineColor,m.yAxisTickColor);let C=Math.max(0,...c.bars.map(e=>Math.abs(e.value)),...c.lines.flatMap(e=>e.points.map(e=>Math.abs(e.value)))),$=e=>C>0?e/C:void 0,M=[],F=new Map,T=tl(c,h.accent,h.bg),W=new Map,_=new Map;for(let i of c.bars){let a=F.get(i.seriesIndex)??0;F.set(i.seriesIndex,a+1);let l=`bar:${i.seriesIndex}:${i.label??a}`,n={category:`bar-${i.seriesIndex}`,value:$(i.value)},o=G(d.styleFace,"bar",n,{includeFallback:!1}),r=`var(--xychart-color-${i.colorIndex})`,s=b?r:o?.fillColor??r;_.set(n.category,s),W.set(i,b?T.concrete(i.colorIndex):o?.fillColor??T.concrete(i.colorIndex));let c=o?.strokeColor??o?.borderColor,h=o?.lineWidth;if(p.push(e.shape({id:l,role:"bar",geometry:{kind:"rect",x:tn(i.x),y:tn(i.y),width:tn(i.width),height:tn(i.height)},paint:{fill:s,stroke:c??"none",...void 0!==h?{strokeWidth:String(h)}:{}},channels:n,attributes:{className:`xychart-bar xychart-color-${i.colorIndex}`,data:{value:String(i.value),...i.label?{label:i.label}:{}}}})),f){let a=eu(i.value),n=i.label?`${i.label}: ${a}`:a,o={id:l,role:"bar"};M.push(e.group({id:`tooltip:${l}`,role:"chrome",owner:o,open:'<g class="xychart-bar-group">',close:"</g>",join:"",children:[{indent:0,node:e.shape({id:`${l}:hit`,role:"chrome",owner:o,geometry:{kind:"rect",x:tn(i.x),y:tn(i.y),width:tn(i.width),height:tn(i.height)},paint:{fill:"transparent"}})},{indent:0,node:e.documentContent({id:`${l}:title`,role:"chrome",nonPaint:"interaction-metadata"},`<title>${U(n)}</title>`)},{indent:0,node:t(e,"xychart",i.tooltip,`${l}:tooltip`,o)}]}))}}for(let t of c.lines){let i={category:`line-${t.seriesIndex}`},a=G(d.styleFace,"series",i,{includeFallback:!1}),l=`var(--xychart-color-${t.colorIndex})`,n=b?l:a?.strokeColor??a?.borderColor??l;if(_.set(i.category,n),t.points.length<2)continue;let o=function(e){if(0===e.length)return"";let t=`M${to(e[0].x)},${to(e[0].y)}`;for(let i=1;i<e.length;i++)t+=` L${to(e[i].x)},${to(e[i].y)}`;return t}(t.points),r=a?.lineWidth??y.lineWidth;p.push(e.connector({id:`series:line-${t.seriesIndex}`,role:"series",geometry:{kind:"path",d:o,points:t.points},lineStyle:"solid",paint:{stroke:n,strokeWidth:String(r),strokeLinecap:"round",strokeLinejoin:"round"},channels:i,attributes:{className:`xychart-line xychart-color-${t.colorIndex}`}}))}let I=(e,t,i)=>{let a=`line-${e}`,l=G(d.styleFace,"point",{category:a,value:$(i)},{includeFallback:!1}),n=`var(--xychart-color-${t})`;return{fill:b?n:l?.fillColor??_.get(a)??n,stroke:l?.strokeColor??l?.borderColor??"var(--bg)",strokeWidth:String(l?.lineWidth??2)}};for(let t of c.lines)t.points.forEach((i,a)=>{if(void 0===i.textLabel)return;let l=i.textPosition,n=l?.placement??(c.horizontal?"right":"above"),o=l?.x??i.x+8*!!c.horizontal,r=l?.y??i.y+(c.horizontal?4:-8),s=l?.anchor??(c.horizontal?"start":"middle");p.push(e.shape({id:`point-label-dot:${t.seriesIndex}:${a}`,role:"point",geometry:{kind:"circle",cx:tn(i.x),cy:tn(i.y),r:4},paint:I(t.seriesIndex,t.colorIndex,i.value),channels:{category:`line-${t.seriesIndex}`,value:$(i.value)},attributes:{className:`xychart-dot xychart-color-${t.colorIndex}`,data:{value:String(i.value)}}})),p.push(e.text({id:`point-label:${t.seriesIndex}:${a}`,role:"label",text:i.textBlock?.text??i.textLabel,block:i.textBlock,x:tn(o),y:tn(r),fontSize:12,fontWeight:y.nodeLabelFontWeight,letterSpacing:y.nodeLetterSpacing,display:"literal",anchor:s,baselineShift:.35*!!l,paint:{fill:_.get(`line-${t.seriesIndex}`)??`var(--xychart-color-${t.colorIndex})`},channels:{category:`line-${t.seriesIndex}`,value:$(i.value)},attributes:{className:`xychart-point-label xychart-color-${t.colorIndex}`,data:{"label-position":n}}}))});let P=[];if(f)for(let i of c.lines)i.points.forEach((a,l)=>{let n=`point:line-${i.seriesIndex}:${a.label??l}`,o=eu(a.value),r=a.label?`${a.label}: ${o}`:o;P.push(e.group({id:`point-group:line-${i.seriesIndex}:${a.label??l}`,role:"chrome",open:'<g class="xychart-dot-group">',close:"</g>",join:"",children:[{node:e.shape({id:`hit:${n}`,role:"chrome",owner:{id:n,role:"point"},geometry:{kind:"circle",cx:tn(a.x),cy:tn(a.y),r:12},paint:{fill:"transparent"},attributes:{className:"xychart-hit"}}),indent:0},{node:e.shape({id:n,role:"point",geometry:{kind:"circle",cx:tn(a.x),cy:tn(a.y),r:4},paint:I(i.seriesIndex,i.colorIndex,a.value),channels:{category:`line-${i.seriesIndex}`,value:$(a.value)},attributes:{className:`xychart-dot xychart-color-${i.colorIndex}`,data:{value:String(a.value),...a.label?{label:a.label}:{}}}}),indent:0},{node:e.documentContent({id:`title:${n}`,role:"chrome",nonPaint:"interaction-metadata"},`<title>${U(r)}</title>`),indent:0},{node:t(e,"xychart",a.tooltip,`tooltip:${n}`,{id:n,role:"point"}),indent:0}]}))});let N=new Map;for(let t of c.dataLabels){let i=t.block?.text??H(t.text,y.nodeTextTransform),a=N.get(t.bar.seriesIndex)??0;N.set(t.bar.seriesIndex,a+1);let l=void 0===c.theme.dataLabelColor&&"inside"===t.placement?function(e){let t=void 0===e?null:q(e);return t&&1===t[3]?O(Z(t[0],t[1],t[2])):void 0}(W.get(t.bar)):void 0,n=c.theme.dataLabelColor??l??m.labelColor,o="inside"===t.placement?W.get(t.bar)??"var(--bg)":"var(--bg)";p.push(e.text({id:`label:bar:${t.bar.seriesIndex}:${t.bar.label??a}`,role:"label",text:i,block:t.block,x:tn(t.x),y:tn(t.y),fontSize:t.fontSize,fontWeight:y.nodeLabelFontWeight,letterSpacing:y.nodeLetterSpacing,display:"literal",anchor:t.anchor,...t.dominantBaseline?{dominantBaseline:t.dominantBaseline}:{},baselineShift:0,paint:{fill:n,stroke:o,strokeWidth:String(3),strokeLinejoin:"round",paintOrder:"stroke"},...l?{pageFill:m.labelColor}:{},channels:{category:`bar-${t.bar.seriesIndex}`,value:$(t.bar.value)},attributes:{className:"xychart-data-label",data:{"literal-text":"true"}}}))}if(ta(e,p,c.xAxis.ticks,c.xAxis.config.labelFontSize,"x",y,m.xAxisLabelColor),ta(e,p,c.yAxis.ticks,c.yAxis.config.labelFontSize,"y",y,m.yAxisLabelColor),c.xAxis.title){let t=c.xAxis.title,i=t.block?.text??H(t.text,y.edgeTextTransform),a=t.rotate?{kind:"rotate",angle:t.rotate,cx:t.x,cy:t.y}:void 0;p.push(e.text({id:"axis:x:title",role:"axis",text:i,block:t.block,x:t.x,y:t.y,fontSize:c.xAxis.config.titleFontSize,fontWeight:y.edgeLabelFontWeight,letterSpacing:y.edgeLetterSpacing,display:"literal",anchor:"middle",paint:{fill:m.xAxisTitleColor},transform:a,attributes:{className:"xychart-axis-title xychart-x-axis-title"}}))}if(c.yAxis.title){let t=c.yAxis.title,i=t.block?.text??H(t.text,y.edgeTextTransform),a=t.rotate?{kind:"rotate",angle:t.rotate,cx:t.x,cy:t.y}:void 0;p.push(e.text({id:"axis:y:title",role:"axis",text:i,block:t.block,x:t.x,y:t.y,fontSize:c.yAxis.config.titleFontSize,fontWeight:y.edgeLabelFontWeight,letterSpacing:y.edgeLetterSpacing,display:"literal",anchor:"middle",paint:{fill:m.yAxisTitleColor},transform:a,attributes:{className:"xychart-axis-title xychart-y-axis-title"}}))}if(c.title){let t=c.title.text;p.push(e.text({id:"title",role:"title",text:t,block:c.title.block,x:c.title.x,y:c.title.y,fontSize:c.config.titleFontSize,fontWeight:y.groupHeaderFontWeight,letterSpacing:y.groupLetterSpacing,display:"literal",anchor:"middle",paint:{fill:m.titleColor},attributes:{className:"xychart-title"}}))}if(c.legend.length>0){let t=[];for(let i of c.legend){let a=i.y+Math.max(12,i.block?.height??0)/2;"bar"===i.type?t.push({node:e.shape({id:`legend:swatch:${i.colorIndex}`,role:"legend",geometry:{kind:"rect",x:tn(i.x),y:tn(i.y),width:12,height:12,rx:2,ry:2},paint:{fill:_.get(`bar-${i.seriesIndex}`)??`var(--xychart-color-${i.colorIndex})`},channels:{category:`bar-${i.seriesIndex}`},attributes:{className:"xychart-legend-swatch"}}),indent:2}):(t.push({node:e.shape({id:`legend:swatch:${i.colorIndex}`,role:"legend",geometry:{kind:"line",x1:tn(i.x),y1:tn(a),x2:tn(i.x+12),y2:tn(a)},paint:{stroke:_.get(`line-${i.seriesIndex}`)??`var(--xychart-color-${i.colorIndex})`,strokeWidth:String(3),strokeLinecap:"round"},channels:{category:`line-${i.seriesIndex}`},attributes:{className:"xychart-legend-swatch"}}),indent:2}),t.push({node:e.shape({id:`legend:dot:${i.colorIndex}`,role:"legend",geometry:{kind:"circle",cx:tn(i.x+6),cy:tn(a),r:2.5},paint:{fill:_.get(`line-${i.seriesIndex}`)??`var(--xychart-color-${i.colorIndex})`,stroke:"var(--bg)",strokeWidth:"1"},channels:{category:`line-${i.seriesIndex}`},attributes:{className:"xychart-legend-dot"}}),indent:2}));let l=i.block?.text??H(i.label,y.nodeTextTransform),n=i.x+12+6;t.push({node:e.text({id:`legend:label:${i.colorIndex}`,role:"legend",text:l,block:i.block,x:tn(n),y:tn(a),fontSize:c.config.legendFontSize,fontWeight:y.nodeLabelFontWeight,letterSpacing:y.nodeLetterSpacing,display:"literal",anchor:"start",dominantBaseline:"middle",baselineShift:0,paint:{fill:m.legendTextColor},attributes:{className:"xychart-legend-label"}}),indent:2})}p.push(e.group({id:"legend",role:"legend",open:'<g class="xychart-legend">',close:"</g>",children:t}))}for(let e of M)p.push(e);for(let e of P)p.push(e);return p.push(e.documentClose()),{family:"xychart",width:c.width,height:c.height,colors:h,transparent:u,parts:p}}),ts=T(et,{configDiagnostics:e=>{let t=y("xychart",e,ei),i=p(e.root,e.config.section);if(!i)return t;let a=(e,i)=>{t.push({code:"INEFFECTIVE_CONFIG",field:e,message:`${e} must be ${i}; the invalid value has no effect.`})};for(let e of["xAxis","yAxis"]){let l=i[e];if(!(!l||"object"!=typeof l||Array.isArray(l)))for(let i of Object.keys(l).sort()){let n=ea[i];n?n.valid(l[i])?"labelRotation"===i&&t.push({code:"INEFFECTIVE_CONFIG",field:`xyChart.${e}.${i}`,message:`xyChart ${e}.${i} is accepted for Mermaid compatibility but has no effect on this renderer.`}):a(`xyChart.${e}.${i}`,n.expected):a(`xyChart.${e}.${i}`,"a documented axis-config field")}}return t},statementEnds:e5,normalizeRequest:e=>{let t=eZ(e.source.frontmatter),i=eG(e.source.frontmatter);return{familyConfig:{config:t},appearance:{...void 0===e.renderOptions.bg&&i.backgroundColor?{colors:{bg:i.backgroundColor}}:{},family:{theme:i}}}},layout:t=>{var i,a,l;let n,o=t.familyConfig,r=t.familyAppearance;return F(function(t,i={},a){var l,n,o,r,s,c,h;let d,x,g,u,f,p,y,m,b,v,w,A,k,L,z,S,C,$,M,F,T,W,_,I,P,N,O,j,B,E,Y,D,X,R,H,q,V,U,Z,ee,et,ei,ea,el,eg,ey,ek,eI,eP,eN,eO,ej,eB,eE,eY,eD,eX,eR,eH,eJ,eq,eV,eU,eQ,eZ,eG,eK,e0,e1,e2,e4,e5,e3,e8,e6=J(i,em,a),e7={width:er((l=t.config).width,en.width),height:er(l.height,en.height),useMaxWidth:ec(l.useMaxWidth,en.useMaxWidth),useWidth:"number"==typeof(n=l.useWidth)&&Number.isFinite(n)&&n>0?n:void 0,titleFontSize:er(l.titleFontSize,en.titleFontSize),titlePadding:es(l.titlePadding,en.titlePadding),chartOrientation:"vertical"===l.chartOrientation||"horizontal"===l.chartOrientation?l.chartOrientation:en.chartOrientation,plotReservedSpacePercent:(o=l.plotReservedSpacePercent,r=en.plotReservedSpacePercent,"number"==typeof o&&Number.isFinite(o)&&o>0&&o<=100?Math.max(10,o):r),showDataLabel:ec(l.showDataLabel,en.showDataLabel),showDataLabelOutsideBar:ec(l.showDataLabelOutsideBar,en.showDataLabelOutsideBar),showTitle:ec(l.showTitle,en.showTitle),showLegend:ec(l.showLegend,en.showLegend),legendFontSize:er(l.legendFontSize,en.legendFontSize),legendPadding:es(l.legendPadding,en.legendPadding),xAxis:eo(l.xAxis),yAxis:eo(l.yAxis)};(a?.group?.fontSize!=null||a?.text?.fontSize!=null)&&(e7.titleFontSize=e6.groupHeaderFontSize),(a?.node?.fontSize!=null||a?.text?.fontSize!=null)&&(e7.xAxis.labelFontSize=e6.nodeLabelFontSize,e7.yAxis.labelFontSize=e6.nodeLabelFontSize),(a?.edge?.fontSize!=null||a?.text?.fontSize!=null)&&(e7.xAxis.titleFontSize=e6.edgeLabelFontSize,e7.yAxis.titleFontSize=e6.edgeLabelFontSize),a?.edge?.lineWidth!=null&&(e7.xAxis.axisLineWidth=e6.lineWidth,e7.yAxis.axisLineWidth=e6.lineWidth,e7.xAxis.tickWidth=e6.lineWidth,e7.yAxis.tickWidth=e6.lineWidth);let e9=(e3=new Map,{block:e8=(e,t,i,a)=>{let l=JSON.stringify([e,t,i,a]),n=e3.get(l);if(!n){let o="axisTitle"===e;n=Q(t,{display:"literal",fontSize:i,fontWeight:o?e6.edgeLabelFontWeight:e6.nodeLabelFontWeight,letterSpacing:o?e6.edgeLetterSpacing:e6.nodeLetterSpacing,transform:"axisTitle"===e||"tick"===e?e6.edgeTextTransform:e6.nodeTextTransform,maxWidth:a}),e3.set(l,n)}return n},wrapTitle:(e,t,i)=>Q(e,{display:"literal",transform:e6.groupTextTransform,fontSize:t,fontWeight:e6.groupHeaderFontWeight,letterSpacing:e6.groupLetterSpacing,maxWidth:i}),tick:(e,t)=>e8("tick",e,t).width,legend:(e,t)=>e8("legend",e,t).width}),te=0,tt=Math.max(0,...t.series.flatMap(e=>"line"!==e.type?[]:[Math.max((G(a,"series",{category:`line-${te++}`},{includeFallback:!1})?.lineWidth??e6.lineWidth)/2,i.interactive||e.pointLabels?.some(e=>void 0!==e)?5:0)])),ti=t.horizontal?(d=e7.width,x=e7.height,g=eh(t),u=ex(t,g),y=(p=ef((f=t.yAxis.range).min,f.max)).map(ep),m=Math.max(0,x-Math.floor(x*e7.plotReservedSpacePercent/100)),b=Math.max(0,d-Math.floor(d*e7.plotReservedSpacePercent/100)),w=(v=eA(t.title,e7,m,e9)).height,m=Math.max(0,m-w),A=eL(e7.yAxis,t.yAxis.title,y,m,e9),m=Math.max(0,m-A.size),k=ez(e7.xAxis,t.xAxis.title,u,b,e9,x),b=Math.max(0,b-k.size),C=eb(t,tt,A.config),M=Math.max(0,x-($=Math.max(w+A.size,ev(A.config)))),F=Math.max(1,g),T=Math.min(M,Math.max(0,((k.config.showLabel?.6*e7.xAxis.labelFontSize:0)-M/(2*F))/(1-1/(2*F)))),_=ew(t,e7,b,d,$,W=Math.max(0,M-T),e9),P=Math.max(0,Math.max(I=A.config.showLabel&&y.length>0?Math.max(...[y[0],y[y.length-1]].map(e=>e9.tick(e,e7.yAxis.labelFontSize)/2)):0,C.value,ev(k.config))-k.size),N=Math.max(0,I-_.size,C.value-_.size),O={x:k.size+P,y:$,width:Math.max(0,d-k.size-P-_.size-N),height:W},j=e=>O.x+(e-f.min)/(f.max-f.min||1)*O.width,B=e=>O.y+(e+.5)*(O.height/g),E=O.height/Math.max(1,g),Y=A.config.showLabel?(L=(s=A.config).showAxisLine?s.axisLineWidth:0,z=s.showTick?s.tickLength:0,S=O.y-L-z-s.labelPadding,p.map((e,t)=>({label:y[t],x:j(e),y:O.y-L,tx:j(e),ty:O.y-L-z,labelX:j(e),labelY:S,textAnchor:"middle"}))):[],D=k.config.showLabel?eC(u.map((e,t)=>t),u,B,O,k.config):[],X=p.map(e=>({x1:j(e),y1:O.y,x2:j(e),y2:O.y+O.height})),R=t.series.map((e,t)=>t),H=eW(t,B,E,j,f,u,R,!0),q=e_(t,B,j,f,u,R,!0),{width:d,height:x,accessibility:t.accessibility,horizontal:!0,title:v.title,hiddenTitle:t.title&&e7.showTitle&&!v.title?t.title:void 0,xAxis:{ticks:D,line:e$(O,k.config),title:eM(t.xAxis.title,O,k.config,x,e9),config:k.config},yAxis:{ticks:Y,line:(c=A.config,V=O.y-(c.showAxisLine?c.axisLineWidth/2:0),{x1:O.x,y1:V,x2:O.x+O.width,y2:V}),title:function(e,t,i,a){if(!(!e||!a.showTitle))return{text:e,x:t.x+t.width/2,y:i+a.titlePadding+a.titleFontSize}}(t.yAxis.title,O,w,A.config),config:A.config},plotArea:O,bars:H,lines:q,gridLines:X,legend:_.items,hiddenLegendLabels:_.hiddenLabels,hiddenCategoryLabels:eF(t,e7,k.config,D),...eT(H,!0,O,e7,e9),config:e7,theme:t.theme}):(U=e7.width,Z=e7.height,ee=eh(t),et=ex(t,ee),ei=ed(t,ee),eg=(el=ef((ea=t.yAxis.range).min,ea.max)).map(ep),ey=t.xAxis.range?ef(t.xAxis.range.min,t.xAxis.range.max):void 0,ek=ey?.map(ep)??et,eI=Math.max(0,Z-Math.floor(Z*e7.plotReservedSpacePercent/100)),eP=Math.max(0,U-Math.floor(U*e7.plotReservedSpacePercent/100)),eO=(eN=eA(t.title,e7,eI,e9)).height,eI=Math.max(0,eI-eO),ej=eL(e7.xAxis,t.xAxis.title,ek,eI,e9),eI=Math.max(0,eI-ej.size),eB=ez(e7.yAxis,t.yAxis.title,eg,eP,e9,Z),eP=Math.max(0,eP-eB.size),eX=Math.max(0,Z-(eD=Math.max(eO,eE=eB.config.showLabel&&eg.length>0?e7.yAxis.labelFontSize/2:0,(eY=eb(t,tt,eB.config,t.xAxis.range?ej.config:void 0)).value))-Math.max(ej.size,eE,eY.value,ev(ej.config))),eR=ew(t,e7,eP,U,eD,eX,e9),eJ={x:eH=Math.max(eB.size,eY.position,ev(eB.config)),y:eD,width:Math.max(0,U-eH-Math.max(eR.size,eY.position)),height:eX},eq=t.xAxis.range&&t.series.some(e=>"bar"===e.type)?eJ.width/Math.max(1,ee)/2:0,eV=t.xAxis.range?e=>eJ.x+eq+(e-t.xAxis.range.min)/(t.xAxis.range.max-t.xAxis.range.min||1)*(eJ.width-2*eq):void 0,eU=e=>eV?eV(ei[e]):eJ.x+(e+.5)*(eJ.width/ee),eQ=eV?function(e,t,i){if(e.length<2)return i;let a=1/0;for(let i=1;i<e.length;i++)a=Math.min(a,Math.abs(t(e[i])-t(e[i-1])));return Number.isFinite(a)&&a>0?a:i}(ei,eV,eJ.width/Math.max(2,ee)):eJ.width/Math.max(1,ee),eZ=e=>eJ.y+eJ.height-(e-ea.min)/(ea.max-ea.min||1)*eJ.height,eG=ej.config.showLabel?t.xAxis.range&&ey&&eV?eS(ey,ek,eV,eJ,ej.config,e9,U):eS(et.map((e,t)=>t),et,eU,eJ,ej.config,e9,U):[],eK=eB.config.showLabel?eC(el,eg,eZ,eJ,eB.config):[],e0=el.map(e=>({x1:eJ.x,y1:eZ(e),x2:eJ.x+eJ.width,y2:eZ(e)})),e1=t.series.map((e,t)=>t),e2=eW(t,eU,eQ,eZ,ea,et,e1,!1),e4=e_(t,eU,eZ,ea,et,e1,!1),{width:U,height:Z,accessibility:t.accessibility,title:eN.title,hiddenTitle:t.title&&e7.showTitle&&!eN.title?t.title:void 0,xAxis:{ticks:eG,line:(h=ej.config,e5=eJ.y+eJ.height+(h.showAxisLine?h.axisLineWidth/2:0),{x1:eJ.x,y1:e5,x2:eJ.x+eJ.width,y2:e5}),title:function(e,t,i,a){if(!(!e||!a.showTitle))return{text:e,x:t.x+t.width/2,y:i-a.titlePadding-a.titleFontSize/2}}(t.xAxis.title,eJ,Z,ej.config),config:ej.config},yAxis:{ticks:eK,line:e$(eJ,eB.config),title:eM(t.yAxis.title,eJ,eB.config,Z,e9),config:eB.config},plotArea:eJ,bars:e2,lines:e4,gridLines:e0,legend:eR.items,hiddenLegendLabels:eR.hiddenLabels,hiddenCategoryLabels:eF(t,e7,ej.config,eG),...eT(e2,!1,eJ,e7,e9),config:e7,theme:t.theme});for(let e of[ti.xAxis,ti.yAxis]){if(e.title){let i=e.title.block??=e9.block("axisTitle",e.title.text,e.config.titleFontSize),a=(i.lines.length-1)*i.lineHeight/2+(i.lineHeight-e.config.titleFontSize*K)/2;e.title.rotate?e.title.x+=a:e.title.y+=t.horizontal?a:-a}for(let t of e.ticks){let i=t.block=e9.block("tick",t.label,e.config.labelFontSize),a="start"===t.textAnchor?0:"end"===t.textAnchor?i.width:i.width/2;t.labelX=Math.max(a,Math.min(ti.width-i.width+a,t.labelX)),t.labelY=Math.max(i.height/2,Math.min(ti.height-i.height/2,t.labelY))}}for(let e of ti.legend)e.block=e9.block("legend",e.label,ti.config.legendFontSize);for(let e of ti.dataLabels)e.block=e9.block("data",e.text,e.fontSize);for(let e of ti.lines)for(let t of e.points)if(void 0!==t.textLabel){let e=t.textBlock=e9.block("data",t.textLabel,12,Math.max(1,ti.width-8)),i=(e,t,i)=>Math.max(t,Math.min(i,e));if(ti.horizontal){let a=t.x+8+e.width<=ti.width-4,l=a?"start":"end";t.textPosition={x:a?i(t.x+8,4,ti.width-4-e.width):i(t.x-8,e.width+4,ti.width-4),y:i(t.y,e.height/2,ti.height-e.height/2),anchor:l,placement:a?"right":"left"}}else{let a=t.y-8-e.height>=ti.plotArea.y;t.textPosition={x:i(t.x,e.width/2,ti.width-e.width/2),y:i(t.y+(a?-1:1)*(8+e.height/2),e.height/2,ti.height-e.height/2),anchor:"middle",placement:a?"above":"below"}}}for(let t of ti.bars)t.tooltip=e(ti.horizontal?t.x+t.width:t.x+t.width/2,ti.horizontal?t.y+t.height/2:t.y,eu(t.value));for(let t of ti.lines)for(let i of t.points)i.tooltip=e(i.x,i.y-4,eu(i.value));return ti}((i=b(P(function(e,t={}){let i=e3(e,!0===t.strict),a=B(i),l=a.accessibility,n=a.familyLines;if(void 0!==a.unclosedIndex){if(t.strict)throw Error('XYChart accDescr block is missing a closing "}"');let e=a.unclosedIndex;n=a.familyLines.slice(0,e-i.length),l.descr=i.slice(e).join(`
16
- `).replace(/^[^{]*\{/,"").trim()||void 0}let o={},r={},s=[],c=e3(n,!0===t.strict),h,d=!1,x,g=c[0],u=g?.match(/^xychart(?:-beta)?(?:\s+(horizontal|vertical))?$/i);if(!u&&t.strict)throw Error(`Invalid XYChart header: "${g??""}"`);u&&W("xychart")&&_("xychart","header",g,{line:1,unit:"normalized"}),u?.[1]&&(x=u[1].toLowerCase(),W("xychart")&&I("xychart","setHeaderOrientation",x,{line:1,unit:"normalized"}),d="horizontal"===x,W("xychart")&&I("xychart","setHorizontal",d,{line:1,unit:"normalized"}));for(let e=+!!u;e<c.length;e++){let i=c[e],a=i.match(/^title\s+([\s\S]+)$/i);if(a){W("xychart")&&_("xychart","title",i,{line:e+1,unit:"normalized"});let l=eJ(a[1]);if(null===l){if(t.strict)throw Error(`Invalid XYChart title directive: "${i}"`)}else h=l,W("xychart")&&I("xychart","setTitle",h,{line:e+1,unit:"normalized"});continue}let l=i.match(/^x-axis\s+([\s\S]+)$/i);if(l){if(W("xychart")&&_("xychart","x-axis",i,{line:e+1,unit:"normalized"}),!eD(o,l[1],"x",e+1)&&t.strict)throw Error(`Invalid XYChart x-axis directive: "${i}"`);continue}let n=i.match(/^y-axis\s+([\s\S]+)$/i);if(n){if(W("xychart")&&_("xychart","y-axis",i,{line:e+1,unit:"normalized"}),!eD(r,n[1],"y",e+1)&&t.strict)throw Error(`Invalid XYChart y-axis directive: "${i}"`);continue}let d=eq(i);if(d?.type==="bar"){W("xychart")&&_("xychart","bar",i,{line:e+1,unit:"normalized"});let a=eP(d.points,!0===t.strict,e+1);s.push({type:"bar",label:d.label,data:a.values,...a.labels.some(e=>void 0!==e)?{pointLabels:a.labels}:{}}),W("xychart")&&I("xychart","appendSeries",s[s.length-1],{line:e+1,unit:"normalized"});continue}if(d?.type==="line"){W("xychart")&&_("xychart","line",i,{line:e+1,unit:"normalized"});let a=eP(d.points,!0===t.strict,e+1);s.push({type:"line",label:d.label,data:a.values,...a.labels.some(e=>void 0!==e)?{pointLabels:a.labels}:{}}),W("xychart")&&I("xychart","appendSeries",s[s.length-1],{line:e+1,unit:"normalized"});continue}throw W("xychart")&&_("xychart","unrecognized",i,{line:e+1,unit:"normalized"}),Error(`Unrecognized XYChart line: "${i}"`)}if(!r.range&&s.length>0){let e=s.flatMap(e=>e.data),t=s.some(e=>"bar"===e.type),i=t?Math.min(0,...e):Math.min(...e),a=t?Math.max(0,...e):Math.max(...e),l=a-i||1,n=t&&0===i,o=t&&0===a&&i<0;n||(i-=.1*l),o||(a+=.1*l),i>0&&i<.5*l&&(i=0),r.range={min:i,max:a},W("xychart")&&I("xychart","deriveYAxisRange",r.range)}return r.range||(r.range={min:0,max:100},W("xychart")&&I("xychart","setFallbackYAxisRange",r.range)),{title:h,accessibility:l.title||l.descr?{...void 0!==l.title?{title:l.title}:{},...void 0!==l.descr?{description:l.descr}:{}}:void 0,horizontal:d,headerOrientation:x,xAxis:o,yAxis:r,series:s,config:eZ({}),theme:eG({})}}(t.source.familyLines),t.source.accessibility),t.source.frontmatter),a=o?.config??eZ({}),l=r?.theme??eG({}),n={...i,horizontal:i.headerOrientation?i.horizontal:"horizontal"===a.chartOrientation,config:a,theme:l},W("xychart")&&I("xychart","applyConfig",{horizontal:n.horizontal,config:a,theme:l}),n),t.renderOptions,t.styleFace),{injectAccessibility:!1})},projectPositioned:$(function({positioned:e,options:t}){let i=[],a=[],l=k(A(e)),n=(e,t,i,n,o,r="middle",s=0)=>{if(!t)return;let c=C(i,n,o,r);if(c&&s){let e=V({x0:c.x,y0:c.y,x1:c.x+c.w,y1:c.y+c.h},{x:n,y:o},s);c=k({x:e.x0,y:e.y0,width:e.x1-e.x0,height:e.y1-e.y0})}a.push({id:e,text:t,...c?{bounds:c}:{},container:l})},o=new Map;if(e.bars.forEach(e=>{let t=o.get(e.seriesIndex)??0;o.set(e.seriesIndex,t+1),i.push({id:`bar#${e.seriesIndex}:pt#${t}`,x:L(e.x),y:L(e.y),w:z(e.x,e.width),h:z(e.y,e.height),shape:"rectangle",label:e.label,role:"labelled-mark",labelVisibility:"semantic"})}),e.lines.forEach(t=>{t.points.forEach((a,l)=>{let o=e.plotArea,r=Math.max(o.x,Math.min(o.x+o.width,a.x-3)),s=Math.max(o.y,Math.min(o.y+o.height,a.y-3)),c=Math.max(r,Math.min(o.x+o.width,a.x+3)),h=Math.max(s,Math.min(o.y+o.height,a.y+3));if(i.push({id:`line#${t.seriesIndex}:pt#${l}`,x:L(r),y:L(s),w:z(r,c-r),h:z(s,h-s),shape:"circle",label:a.label,role:a.label?"labelled-mark":"mark",labelVisibility:"semantic"}),void 0!==a.textLabel){let e=a.textPosition;n(`point-label:${t.seriesIndex}:${l}`,a.textBlock?.text??a.textLabel,e?a.textBlock:void 0,e?.x??a.x,e?.y??a.y,e?.anchor??"middle")}})}),e.title){let t=e.title;n("title",t.block?.text??t.text,t.block,t.x,t.y)}for(let[t,i]of[["x",e.xAxis],["y",e.yAxis]]){if(i.title){let e=i.title;n(`axis:${t}:title`,e.block?.text??e.text,e.block,e.x,e.y,"middle",e.rotate)}i.ticks.forEach((e,i)=>n(`axis:${t}:label:${i}`,e.block?.text??e.label,e.block,e.labelX,e.labelY,e.textAnchor))}for(let t of e.legend)n(`legend:label:${t.colorIndex}`,t.block?.text??t.label,t.block,t.x+12+6,t.y+Math.max(12,t.block?.height??0)/2,"start");e.dataLabels.forEach((e,t)=>{let i="hanging"===e.dominantBaseline?e.y+(e.block?.height??0)/2:"middle"===e.dominantBaseline?e.y:e.y-.35*e.fontSize;n(`data-label:${t}`,e.block?.text??e.text,e.block,e.x,i,e.anchor)});let r=[{id:"plot",x:L(e.plotArea.x),y:L(e.plotArea.y),w:z(e.plotArea.x,e.plotArea.width),h:z(e.plotArea.y,e.plotArea.height),members:i.filter(t=>t.x+t.w/2>=e.plotArea.x&&t.x+t.w/2<=e.plotArea.x+e.plotArea.width&&t.y+t.h/2>=e.plotArea.y&&t.y+t.h/2<=e.plotArea.y+e.plotArea.height).map(e=>e.id)}],s={version:1,nodes:i,edges:[],groups:r,bounds:{w:L(e.width),h:L(e.height)},labels:a};return t.debug&&(s.certificates=S("xychart",s,"plot-contained",r[0],"center")),s}),lowerScene:M(tr)});export{ts as default};
@@ -1,2 +0,0 @@
1
- import{ja as d}from"./chunk-KXMANAST.js";import{Gc as t,gf as n,gh as o,hh as s,ib as i,ih as a}from"./chunk-EHJI3QYE.js";function c(e){if(e instanceof t){return{code:e.code,message:e.message,line:e.line,preservation:e.preservation,help:e.help}}if(e instanceof d){return{code:e.code,message:e.message,requestedWidth:e.requestedWidth,requiredWidth:e.requiredWidth,family:e.family,reason:e.reason}}if(e instanceof i){return{code:e.code,message:e.message,subject:e.subject,property:e.property,value:e.value}}if(e instanceof n){return{code:e.code,message:e.message,subject:e.subject,property:e.property,value:e.value}}if(e instanceof o){return{code:e.code,message:e.message,key:e.key,value:e.value}}if(e instanceof a){return{code:e.code,message:e.message,path:e.path,value:e.value}}if(e instanceof s){return{code:e.code,message:e.message,field:e.field,value:e.value}}return void 0}function p(e){return c(e)??{code:"RENDER_FAILED",message:"Rendering failed"}}export{c as a,p as b};
2
- //# sourceMappingURL=chunk-2DNGDTJD.js.map