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,6 +1,6 @@
1
- import{b as e,c as t}from"./chunk-TT5GR5EJ.js";import{b as n,d as i}from"./chunk-J57YRC2M.js";import{q as o,r as a,w as r}from"./chunk-V6I2VGNQ.js";import{b as l,c as s,f as d,g as c}from"./chunk-VRZKI33U.js";import{D as h,e as p,g as g,i as u}from"./chunk-QVSZOF5M.js";import{c as f,h as x,i as b,k as m,ma as y,oa as k,r as w,s as v,y as M}from"./chunk-G4JBA7HU.js";import{b as I,i as S,j as $,k as L,m as C,q as W,u as P}from"./chunk-3JTYTXA6.js";import{a as q,b as F,c as H,d as E,g as Y,h as z,l as T,m as B,n as _,o as N}from"./chunk-YVNJDVQO.js";import{Aa as O,Ba as j,C as A,Ca as X,E as D,F as R,G as J,H as U,M as V,N as Z,O as G,Qb as Q,T as K,Vb as ee,_ as et,ka as en,ma as ei,na as eo,o as ea,wa as er,x as el,y as es}from"./chunk-EIYLJ4FI.js";import{e as ed}from"./chunk-PJJSDGLB.js";import{a as ec}from"./chunk-YHMTSXIR.js";var eh=/&amp;(#\d+|#[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z\d]{0,31});|&(#\d+|#[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z\d]{0,31});/g;function ep(e,t){let i=e.originalText;if(!i.includes("&"))return e;let o=i.includes("&")?i.replace(eh,(e,t,i)=>{if(void 0!==t)return t.startsWith("#")||b.has(t)||n(t)?`#38;${t.replace("#","#35;")}#59;`:`&${t};`;if(!i.startsWith("#")&&!b.has(i))return n(i)?`#${i};`:e;let o=ec(e);return"#"===o?"#35;":";"===o?"#59;":o}):i;return o===("decoded"===t?ec(i):i)?e:r(o)}var eg={subject:"Sequence text entity",example:"A->>B: #35;"},eu=RegExp(`#\\w+;|${x.source}`,"g");function ef(e){let t=e.trim(),n=/^:?(wrap|nowrap):/.exec(t);return n?{text:t.slice(n[0].length).trim(),wrap:"wrap"===n[1]}:{text:t}}function ex(e){let t=function(e){let t=i(e,eg);if(t===e)return{value:t};let n=D(J(U(e)),eu,e=>i(e,eg));return{value:t,content:Object.freeze({value:t,authored:e,prepared:n})}}(e),n=i(U(e),eg);return{label:n,...t.content?{labelContent:Object.freeze({...t.content,value:n})}:{}}}var eb=/^(loop|alt|opt|par_over|par|critical|break|rect|box)\b\s*([\s\S]*)$/i,em=/^(else|and|option)\b\s*([\s\S]*)$/i;function ey(e){let t=e.toLowerCase();return"transparent"===t||t in en||!!/^(?:#|(?:rgb|rgba|hsl|hsla)\()/i.test(e)&&null!==O(e)}function ek(e){let t=en[e.toLowerCase()];if(t)return t;let n=ei(e);if(n)return eo(n[0],n[1],n[2]);let i=e.match(/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})/i);return i?eo(Math.min(255,Number.parseInt(i[1],10)),Math.min(255,Number.parseInt(i[2],10)),Math.min(255,Number.parseInt(i[3],10))):null}var ew=class{constructor(e={}){this.options=e}options;records=new Map;order=[];boxes=[];currentBox;apply(e){if("links"===e.kind){let t=this.records.get(e.id);t&&(t.links={...t.links,...e.links});return}this.addActor(e.id,"declare"===e.kind?e:void 0)}applyAll(e){for(let t of e)this.apply(t)}openBox(e){this.boxes.push(e),this.currentBox=this.boxes.length-1}closeBox(){this.currentBox=void 0}has(e){return this.records.has(e)}indexOf(e){return this.order.indexOf(e)}list(){return this.order.map(e=>this.records.get(e))}addActor(e,t){let n=this.records.get(e),i=this.currentBox;if(n&&(void 0!==i&&void 0!==n.box&&i!==n.box&&this.options.onBoxConflict?.(e),void 0!==(i=n.box??i)&&(n.box=i),t?.label===void 0||t.create))return;let o={id:e,label:t?.label??e,...t?.wrap===void 0?{}:{wrap:t.wrap},type:t?.type??"participant",...t?{keyword:t.keyword}:{},...n?.links&&!this.options.upstreamLinks?{links:n.links}:{},...void 0!==i?{box:i}:{}};this.records.set(e,o),n||this.order.push(e),void 0!==this.currentBox&&i===this.currentBox&&this.boxes[this.currentBox].actorIds.push(e)}},ev=new Map([["<<--\x3e>",["filled","filled"]],["<<->>",["filled","filled"]],["--\x3e>",["none","filled"]],["->>",["none","filled"]],["--\x3e",["none","none"]],["->",["none","none"]],["--x",["none","cross"]],["-x",["none","cross"]],["--)",["none","open"]],["-)",["none","open"]],["--|\\",["none","half-top"]],["-|\\",["none","half-top"]],["--|/",["none","half-bottom"]],["-|/",["none","half-bottom"]],["--\\\\",["none","stick-top"]],["-\\\\",["none","stick-top"]],["--//",["none","stick-bottom"]],["-//",["none","stick-bottom"]],["/|--",["half-bottom","none"]],["/|-",["half-bottom","none"]],["\\|--",["half-top","none"]],["\\|-",["half-top","none"]],["//--",["stick-bottom","none"]],["//-",["stick-bottom","none"]],["\\\\--",["stick-top","none"]],["\\\\-",["stick-top","none"]],["--|",["none","stick-top"]],["-|",["none","stick-top"]],["--/",["none","stick-bottom"]],["-/",["none","stick-bottom"]],["--\\",["none","stick-top"]],["-\\",["none","stick-top"]],["|--",["stick-top","none"]],["|-",["stick-top","none"]],["/--",["stick-bottom","none"]],["/-",["stick-bottom","none"]],["\\--",["stick-top","none"]],["\\-",["stick-top","none"]]]),eM=new Set(["--|","-|","--/","-/","--\\","-\\","|--","|-","/--","/-","\\--","\\-"]),eI=new Map([...eM].map(e=>{let[t,n]=ev.get(e),i=[...ev].find(([i,o])=>!eM.has(i)&&o[0]===t&&o[1]===n&&i.includes("--")===e.includes("--"))[0];return[e,i]})),eS=[...ev.keys()].sort((e,t)=>t.length-e.length),e$=eS.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),eL=new RegExp(String.raw`^(\S+?)(\(\))?\s*(${e$})`),eC=new RegExp(String.raw`^(\S+?)\s+(\(\))\s*(${e$})`),eW=new Set(["participant","actor","note","alt","else","loop","rect","opt","par","and","end","activate","deactivate","autonumber","box","create","destroy","link","links","critical","break","option","title","over","off","properties","details","sequencediagram","par_over"]),eP=new Set([...eW,"acctitle","accdescr"]),eq=/(?:#\w+;|[^\/\\\+\()\+<\->\->:\n,;])+((?!(\-x|\-\-x|\-\)|\-\-\)|\-\|\\|\-\\|\-\/|\-\/\/|\-\|\/|\/\|\-|\\\|\-|\/\/\-|\\\\\-|\/\|\-|\-\-\|\\|\-\-|\(\)))[\-]*(?:#\w+;|[^\+<\->\->:\n,;])+)*/iy;function eF(e,t){return eq.lastIndex=t,eq.exec(e)?.[0].trim()??""}function eH(e,t){if(!e||e.trim()!==e||/[\r\n]/.test(e))return!1;let n=m(e);if(n.startsWith("#"))return!1;if("declaration"===t)return eO(e)&&!/:/.test(n)&&!n.includes("%%{");if(n.startsWith("%")||n.includes("%%"))return!1;let i=n.toLowerCase(),o=/^(\w+)\b/.exec(i)?.[1];return!(o&&eW.has(o)&&(!["title","link","links","properties","details"].includes(o)||/\s/.test(i.slice(o.length,o.length+1)))||/^(?:\d+(?:\.\d{1,2})?|\.\d{1,2})(?=\s)/.test(n)||eW.has(i)&&!["title","link","links","properties","details"].includes(i)||"receiver"===t&&["acctitle","accdescr"].includes(i)||/^(?:left|right) of\b/.test(i))&&eF(`${n}${"sender"===t?"->>Z:":":"}`,0)===n}var eE=new WeakMap,eY=new WeakMap;function ez(e,t){eE.set(e,t)}function eT(e,t){eY.set(e,t)}function eB(n,i={}){let r=a(n),l=M(r.map(e=>e.raw)),s=l.familyLines.flatMap((e,t)=>e.trim()?[{text:e.trim(),origin:r[l.familyOrigins[t]].line}]:[]);n=s.map(e=>e.text);let d=e=>{let t=s[e]?.origin??e;return i.authoredLine?.(t)??t+1};p("sequence")&&void 0!==n[0]&&g("sequence","header",n[0],{line:1,unit:"normalized"});let c={actors:[],messages:[],blocks:[],notes:[],activationEvents:[],boxes:[],...void 0!==l.accessibility.title?{accessibilityTitle:U(l.accessibility.title)}:{},...void 0!==l.accessibility.descr?{accessibilityDescription:U(l.accessibility.descr)}:{}},h=new ew,f=new Map,x=new Map,b=function(n){let i=a(n).map(n=>{if(!n.raw.trim()||o(n.raw))return{...n,syntax:null};try{return{...n,syntax:function(n){let i=function(n){let i=n.match(/^(participant|actor)\s+([^\s@]+)\s*@\{/i);if(i){let o=i[1].toLowerCase(),a=i[2];eX(a);let r=e(n,i[0].length-1,"sequence"),l=r.ok?n.slice(r.end+1):"",s=l.match(/^\s+as(?:\s+(.*))?$/i);if(!r.ok||""!==l.trim()&&!s)throw v({what:`Invalid participant metadata in "${n}": ${r.ok?`unexpected "${l.trim()}" after it`:r.message}`,expectedForm:'a YAML mapping in @{…} with no "}" inside, then optionally `as <label>`',example:'participant DB@{ "type": "database", "alias": "Orders" }'});let d=s?ef(s[1]??""):void 0,c=d?d.text||null:void 0;if(null===c)return null;let{entries:h}=r,p=h.get("type"),g="string"==typeof p?p.toLowerCase():o;if(!eN.has(g))throw Error(`Unknown sequence actor type '${g}'`);let u=t(h.get("alias")),f=void 0!==u&&(void 0===c||c===a)?u:c,x=[...h.keys()].filter(e=>"type"!==e&&"alias"!==e);return{id:a,label:f??a,type:g,keyword:o,aliased:void 0!==f,...d?.wrap===void 0?{}:{wrap:d.wrap},...x.length?{unmodeledMetadata:x}:{}}}if(n.includes("@{"))return null;let o=n.match(/^(participant|actor)\s+/i);if(!o)return null;let a=n.slice(o[0].length),r=a.match(/^(\S+?)\s+as(\s*)(.+)$/i);if(!r&&(!a||/\s/.test(a)&&/[<>:\n,;@]/.test(m(a))))return null;let l=r?r[1]:a.trim();eX(l);let s=o[1].toLowerCase(),d=r?.[3]===void 0?void 0:ef(r[3]);return{id:l,label:d?.text??l,type:s,keyword:s,aliased:!!r,...r?.[2]===""?{unspacedAlias:!0}:{},...d?.wrap===void 0?{}:{wrap:d.wrap}}}(n);if(i)return{kind:"declaration",declaration:i};let o=function(e){let t=e.match(/^link\s+(\S+)\s*:\s*(.+?)\s*@\s*(\S+)$/i);if(t)return/^(?:https?:|mailto:)/i.test(t[3])?{actorId:t[1],links:{[t[2].trim()]:t[3]}}:null;let n=e.match(/^links\s+(\S+)\s*:\s*(\{.*\})$/i);if(!n)return null;try{let e=JSON.parse(n[2]),t={};for(let[n,i]of Object.entries(e))"string"==typeof i&&/^(?:https?:|mailto:)/i.test(i)&&(t[n]=i);return Object.keys(t).length>0?{actorId:n[1],links:t}:null}catch{return null}}(n);if(o)return{kind:"links",...o};let a=n.match(/^(?:properties|details)\s+(\S+)\s*:/i);if(a)return{kind:"actor-data",actorId:a[1]};let r=n.match(/^title(?:\s*:\s*|\s+)(.+)$/i);if(r)return{kind:"title",text:r[1].trim()};let l=n.match(/^autonumber(?:\s+(.*))?$/i);if(l){let e=l[1]?.trim()??"";if(/^off$/i.test(e))return{kind:"autonumber",numbering:null};let t=e.match(/^((?:\d+(?:\.\d{1,2})?|\.\d{1,2}))(?:\s+((?:\d+(?:\.\d{1,2})?|\.\d{1,2})))?$/);return(!e||t)&&(!t||Number.isFinite(Number(t[1]))&&(void 0===t[2]||Number.isFinite(Number(t[2]))))?{kind:"autonumber",numbering:t?{next:Number.parseFloat(t[1]),...void 0===t[2]?{}:{step:Number.parseFloat(t[2])}}:{}}:null}let s=n.match(/^box(?:\s+(.*))?$/i);if(s)return{kind:"box",text:s[1]?.trim()??""};let d=function(e){let t=e.match(/^create\s+(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/i);if(!t)return null;let n=t[2];eX(n);let i=void 0===t[3]?void 0:ef(t[3]);return{id:n,label:i?.text??n,type:t[1].toLowerCase(),...i?.wrap===void 0?{}:{wrap:i.wrap}}}(n);if(d)return{kind:"create",declaration:d};let c=n.match(/^destroy\s+(\S+)$/i);if(c)return{kind:"destroy",actorId:c[1]};let h=function(e){let t=e.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.*)$/i);if(!t)return null;let n=t[1].toLowerCase();return{actorIds:t[2].trim().split(",").map(e=>e.trim()),...ef(t[3]),position:"left of"===n?"left":"right of"===n?"right":"over"}}(n);if(h)return{kind:"note",note:h};let p=function(e){let t=eb.exec(e);if(!t)return null;let n=t[1].toLowerCase(),i=t[2]?.trim()??"";if("box"===n)return{type:n,label:i};let o=ef(i);return{type:n,label:o.text,...void 0===o.wrap?{}:{wrap:o.wrap}}}(n);if(p&&"box"!==p.type)return{kind:"block",opener:{type:p.type,label:p.label,...void 0===p.wrap?{}:{wrap:p.wrap}}};let g=function(e){let t=em.exec(e);if(!t)return null;let n=ef(t[2]??"");return{type:t[1].toLowerCase(),label:n.text,...void 0===n.wrap?{}:{wrap:n.wrap}}}(n);if(g)return{kind:"continuation",continuation:g};if("end"===n)return{kind:"end"};let u=function(e){var t;let n=function(e){eq.lastIndex=0;let t=eq.exec(e);if(!t)return;let n=t[0].length,i=e.startsWith("()",n),o=i&&/\s$/.test(t[0]);for(i&&(n+=2);n<e.length&&/\s/.test(e[n]);)n++;let a=eS.find(t=>e.startsWith(t,n));if(a)return n+=a.length,{from:t[0].trim(),arrow:a,end:n,centralStart:i,spacedCentral:o}}(e);if(!n){let t=e.match(eL),i=t??e.match(eC);i&&(n={from:i[1],centralStart:!!i[2],arrow:i[3],end:i[0].length,spacedCentral:!t})}if(!n||(t=n.arrow,!ev.has(t)))return null;let{from:i,arrow:o,centralStart:a,spacedCentral:r}=n;if(r&&(/^(?:[0-9]+(?:\.[0-9]{1,2})?|\.[0-9]{1,2})$/.test(i)||eW.has(i.toLowerCase())))return null;let l=e.slice(n.end).trimStart(),s=l.startsWith("()");s&&(l=l.slice(2).trimStart());let d="+"===l[0]||"-"===l[0]?l[0]:void 0;if(r&&d)return null;d&&(l=l.slice(1).trimStart());let c=l.indexOf(":");if(c<1)return null;let h=l.slice(0,c).trimEnd(),{text:p,wrap:g}=ef(l.slice(c+1));if(!h||r&&(/[+<>]/.test(h)||h.includes("()")||eP.has(h.toLowerCase())))return null;let u=m(e),f=m(i),x=m(h),b=m(e.slice(0,e.length-l.length)).length,y=eF(u,0);return y.length<=f.length&&(y!==f||eF(u,b)!==x)?null:{from:i,arrow:eI.get(o)??o,activationMark:d,to:h,label:p,centralStart:a,centralEnd:s,...void 0===g?{}:{wrap:g},...eM.has(o)?{localArrow:o}:{}}}(n);if(u)return{kind:"message",message:u};let f=n.match(/^(activate|deactivate)\s+(\S+)$/i);return f?{kind:"activation",actorId:f[2],activate:"activate"===f[1].toLowerCase()}:null}(n.raw.trim())}}catch(e){if(e instanceof Q)throw e;return{...n,syntax:null,error:e}}}),r=[],l=[],s=(e,t,n)=>{l.push({line:e.line,syntax:t,message:n})};for(let[e,t]of i.entries()){let{syntax:n}=t;if(r.length&&(t.parent=r.at(-1)),!n){t.error instanceof eA?s(t,"sequence_participant_id",t.error.message):t.raw.trim()&&!o(t.raw)&&s(t,"sequence_statement",`Sequence statement is preserved in source but not drawn: ${t.raw.trim()}`);continue}if("block"===n.kind||"box"===n.kind)r.push(e);else if("end"===n.kind){let n=r.pop();void 0===n?s(t,"sequence_block_boundary","Sequence end has no open block or box"):(t.closes=n,i[n].endIndex=e)}else if("continuation"===n.kind){var d,c;let e=void 0!==t.parent?i[t.parent].syntax:null;e?.kind==="block"&&(d=n.continuation.type,c=e.opener.type,"else"===d&&"alt"===c||"and"===d&&("par"===c||"par_over"===c)||"option"===d&&"critical"===c)||s(t,"sequence_block_boundary",`Sequence ${n.continuation.type} does not belong to the enclosing block`)}else if("declaration"===n.kind&&n.declaration.unmodeledMetadata?.length)s(t,"sequence_participant_metadata",`Participant metadata fields ${n.declaration.unmodeledMetadata.join(", ")} are not modeled; the declaration is preserved as source`);else if("message"===n.kind&&n.message.localArrow){let{localArrow:e,arrow:i}=n.message;s(t,"sequence_local_arrow",`The arrow ${e} is a local spelling pinned Mermaid does not read, so it rejects this line. Ours draws it as Mermaid's ${i} and writes ${i}`)}else"declaration"===n.kind&&n.declaration.unspacedAlias&&s(t,"sequence_unspaced_alias","Participant text immediately following as is read as its alias. Pinned Mermaid can reject this or read it as part of the ID; write as <label> with a separating space");if("declaration"===n.kind||"create"===n.kind){let e=ej(n.declaration.id);e&&s(t,"sequence_participant_id_extension",e)}if("message"===n.kind)for(let[e,i]of[["sender",n.message.from],["receiver",n.message.to]])eH(i,e)||s(t,"sequence_message_id_extension",`Participant "${i}" is read as the ${e}, but pinned Mermaid reads another token there; rename it before typed editing`)}for(let e of r)s(i[e],"sequence_block_boundary","Sequence block or box is never closed by end");return{statements:i,issues:l}}(n.slice(1)),y=b.issues.find(e=>"sequence_block_boundary"===e.syntax);if(y)throw Error(`SEQUENCE_BLOCK_BOUNDARY: line ${d(y.line+1)}: ${y.message}`);let k=new Map,w=[],S=new Map,$={visible:!0===i.showSequenceNumbers,next:1,step:1},L=[],C=[],W=e=>{let{from:t,to:n}=e,o=function(e){let t=e.includes("--")?"dashed":"solid",[n,i]=ev.get(e)??["none","none"];return{lineStyle:t,startHead:n,endHead:i}}(e.arrow),a={from:t,to:n,...ex(e.label.trim()),...(e.wrap??i.wrap)===void 0?{}:{wrap:e.wrap??i.wrap},lineStyle:o.lineStyle,startHead:o.startHead,endHead:o.endHead,centralStart:e.centralStart,centralEnd:e.centralEnd};"+"===e.activationMark&&(a.activate=!0),"-"===e.activationMark&&(a.deactivate=!0),$.visible&&(a.number=$.next),$.next=Math.round(($.next+$.step)*100)/100,eD(L,e=>e===n,e=>{f.set(e,c.messages.length),p("sequence")&&u("sequence","bind-create",{id:e,messageIndex:c.messages.length})}),eD(C,e=>e===t||e===n,e=>{x.set(e,c.messages.length),p("sequence")&&u("sequence","bind-destroy",{id:e,messageIndex:c.messages.length})}),c.messages.push(a),p("sequence")&&u("sequence","add-message",a)};for(let[e,t]of b.statements.entries()){let n=t.raw.trim();if(p("sequence")&&g("sequence",t.syntax?.kind??"unrecognized",t.raw,{line:t.line+2,column:t.column+1,unit:"normalized"}),t.error)throw t.error;let a=t.syntax;if(!a){if(void 0!==l.unclosedIndex&&n===l.familyLines[l.unclosedIndex]?.trim())continue;if(n&&!o(n))throw Error(`SEQUENCE_UNSUPPORTED_STATEMENT: line ${d(t.line+1)}: ${n}`);continue}for(let e of function(e){switch(e?.kind){case"declaration":{let{id:t,label:n,type:i,keyword:o,aliased:a,wrap:r}=e.declaration;return[{kind:"declare",id:t,keyword:o,type:i,...a?{label:n}:{},...void 0===r?{}:{wrap:r}}]}case"create":{let{id:t,label:n,type:i,wrap:o}=e.declaration;return[{kind:"declare",id:t,keyword:"actor"===i?"actor":"participant",type:i,label:n,...void 0===o?{}:{wrap:o},create:!0}]}case"links":return[{kind:"mention",id:e.actorId},{kind:"links",id:e.actorId,links:e.links}];case"actor-data":return[{kind:"mention",id:e.actorId}];case"note":return e.note.actorIds.map(e=>({kind:"mention",id:e}));case"message":return[{kind:"mention",id:e.message.from},{kind:"mention",id:e.message.to}];default:return[]}}(a))h.apply(e),p("sequence")&&u("sequence","participant.apply",e);switch(a.kind){case"declaration":case"create":"create"===a.kind&&L.push(a.declaration.id);break;case"links":case"actor-data":break;case"title":{let e=ex(a.text);c.title=e.label,c.titleContent=e.labelContent,p("sequence")&&u("sequence","set-title",c.title);break}case"autonumber":$.visible=null!==a.numbering,a.numbering?.next!==void 0&&($.next=a.numbering.next,$.step=a.numbering.step??1),p("sequence")&&u("sequence","set-autonumber",$);break;case"box":{let e=a.text,t={actorIds:[]},n=e.match(/^((?:rgb|rgba|hsl|hsla)\([^)]*\))\s*(.*)$/i),o=e;if(n&&ey(n[1]))t.color=n[1],o=n[2]?.trim()??"";else{let n=e.split(/\s+/,1)[0]??"";n&&ey(n)&&(t.color=n,o=e.slice(n.length).trim())}if(o){let e=ef(o);Object.assign(t,ex(e.text)),(e.wrap??i.wrap)!==void 0&&(t.wrap=e.wrap??i.wrap)}c.boxes.push(t),h.openBox(t),p("sequence")&&u("sequence","open-box",{index:c.boxes.length-1,box:t});break}case"destroy":C.push(a.actorId),p("sequence")&&u("sequence","pending-destroy",a.actorId);break;case"note":{let{note:e}=a,n=ex(e.text),o=c.notes.length;c.notes.push({actorIds:e.actorIds,text:n.label,...(e.wrap??i.wrap)===void 0?{}:{wrap:e.wrap??i.wrap},...n.labelContent?{textContent:n.labelContent}:{},position:e.position,afterIndex:c.messages.length-1}),p("sequence")&&u("sequence","add-note",{note:c.notes.at(-1),parent:t.parent});for(let e=t.parent;void 0!==e;e=k.get(e)?.parent)k.get(e)?.noteIndices.push(o);break}case"block":{let{opener:n}=a,o=n.type,r=ex("rect"===n.type?"":n.label),l="rect"===n.type&&n.label.startsWith("#")?"":n.label,s="rect"===n.type?function(e){let t=I(e);if(!t)return;let n=t.toLowerCase();if("transparent"===n||Object.hasOwn(en,n))return t;let i=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i.exec(t);if(i&&i.slice(1).every(e=>255>=Number(e)))return t;let o=/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0(?:\.\d+)?|\.\d+|1(?:\.0+)?)\s*\)$/i.exec(t);if(o&&o.slice(1,4).every(e=>255>=Number(e)))return t}(l):void 0;if("rect"===n.type&&l&&!s)throw Error("SEQUENCE_RECT_COLOR_UNSUPPORTED: rect requires a safe concrete CSS color");k.set(e,{type:o,...r,...(n.wrap??i.wrap)===void 0?{}:{wrap:n.wrap??i.wrap},...s?{color:s}:{},startIndex:c.messages.length,dividers:[],dividerNoteIndices:[],parent:t.parent,parentSection:void 0===t.parent?0:k.get(t.parent)?.dividers.length??0,noteIndices:[],childBlockIndices:[],childSectionIndices:[]}),w.push({kind:"open",blockId:e,messageIndex:c.messages.length,noteIndex:c.notes.length}),p("sequence")&&u("sequence","open-block",{id:e,block:k.get(e)});break}case"continuation":{let e=void 0!==t.parent?k.get(t.parent):void 0;e&&(w.push({kind:"divider",blockId:t.parent,messageIndex:c.messages.length,noteIndex:c.notes.length,dividerIndex:e.dividers.length}),e.dividerNoteIndices.push(c.notes.length),e.dividers.push({index:c.messages.length,...ex(a.continuation.label),...(a.continuation.wrap??i.wrap)===void 0?{}:{wrap:a.continuation.wrap??i.wrap}}),p("sequence")&&u("sequence","divide-block",{parent:t.parent,divider:e.dividers.at(-1),type:a.continuation.type}));break}case"end":{let e=k.get(t.closes);if(e){let n=c.blocks.length;S.set(t.closes,n),w.push({kind:"close",blockId:t.closes,messageIndex:c.messages.length,noteIndex:c.notes.length});let i={type:e.type,label:e.label,...void 0===e.wrap?{}:{wrap:e.wrap},...e.labelContent?{labelContent:e.labelContent}:{},...e.color?{color:e.color}:{},startIndex:e.startIndex,endIndex:Math.max(c.messages.length-1,e.startIndex),dividers:e.dividers};eE.set(i,{endMessageExclusive:c.messages.length,endNoteExclusive:c.notes.length,dividerNoteIndices:e.dividerNoteIndices,noteIndices:e.noteIndices,childBlockIndices:e.childBlockIndices,childSectionIndices:e.childSectionIndices}),void 0!==e.parent&&(k.get(e.parent)?.childBlockIndices.push(n),k.get(e.parent)?.childSectionIndices.push(e.parentSection)),c.blocks.push(i),p("sequence")&&u("sequence","close-block",{id:t.closes,parent:e.parent,parentSection:e.parentSection,block:i,notes:e.noteIndices,children:e.childBlockIndices})}else h.closeBox(),p("sequence")&&u("sequence","close-box",null);break}case"message":W(a.message);break;case"activation":c.activationEvents.push({actorId:a.actorId,kind:a.activate?"activate":"deactivate",messageIndex:c.messages.length}),p("sequence")&&u("sequence","activation",c.activationEvents.at(-1))}}return c.actors=h.list().map(({id:e,label:t,type:n,links:o,box:a,wrap:r})=>({id:e,...ex(t),type:n,...(r??i.wrap)===void 0?{}:{wrap:r??i.wrap},...o?{links:o}:{},...void 0!==a?{box:a}:{},...f.has(e)?{createMessageIndex:f.get(e)}:{},...x.has(e)?{destroyMessageIndex:x.get(e)}:{}})),eY.set(c,w.map(({blockId:e,...t})=>({...t,blockIndex:S.get(e)}))),c}function e_(e){let t;return n=>{if(!t){let n=e.originalText.split(/\r?\n/),i=e.wrapperSource?e.wrapperSource.split(/\r?\n/).length-1:0,o=n.slice(i).flatMap((e,t)=>(0===t?ed(e).split(`
2
- `):[e]).map(e=>({text:e.trim(),line:i+t+1}))),a=0;t=e.familyLines.map(e=>{let t=e.trim();for(let e=a;e<o.length;e++){let n=o[e].text;if(n===t||n.slice(n.indexOf("}")+1).trim()===t)return a=e+1,o[e].line}})}return t[n]}}var eN=new Set(["participant","actor","boundary","control","entity","database","collections","queue"]);function eO(e){return"string"==typeof e&&""!==e&&e.trim()===e&&!/[<>,;@#\r\n]/.test(m(e))}function ej(e){let t=eO(e);return t&&eH(e,"declaration")?null:`Sequence participant ID ${JSON.stringify(e)} ${t?"is read as authored, but pinned Mermaid rejects colons in declaration IDs":"has ambiguous declaration delimiters or whitespace"}. Typed editing and serialization require a portable ID; rename this ID and its references, and put display punctuation in an alias`}var eA=class extends w{};function eX(e){if(!eO(e))throw new eA(ej(e))}function eD(e,t,n){for(let i=e.length-1;i>=0;i--){let o=e[i];t(o)&&(n(o),e.splice(i,1))}}function eR(e,t,n,i,o,a,r=0,l=et(e,{fontSize:o,fontWeight:a,letterSpacing:r})){let s="middle"===i?t-l.width/2:"start"===i?t:t-l.width;return{text:l.text,block:l,x:t,y:n,anchor:i,fontSize:o,fontWeight:a,letterSpacing:r,bounds:{x:s,y:n-l.height/2,width:l.width,height:l.height},metrics:l}}function eJ(e,t){let n=Math.min(e.x,t.x),i=Math.min(e.y,t.y);return{x:n,y:i,width:Math.max(e.x+e.width,t.x+t.width)-n,height:Math.max(e.y+e.height,t.y+t.height)-i}}function eU(e,t,n){return{x:e.x+t,y:e.y+n,width:e.width,height:e.height}}function eV(e,t,n){return{...e,x:e.x+t,y:e.y+n,bounds:eU(e.bounds,t,n)}}function eZ(e,t,n,i){if("participant"===e.type){let o=eR(t.displayLabel,n,i+t.height/2,"middle",t.fontSize,t.fontWeight,t.letterSpacing,t.block),a={x:n-t.width/2,y:i,width:t.width,height:t.height};return{id:e.id,label:e.label,type:e.type,...e.links?{links:{...e.links}}:{},...t.menuBlock?{menuBlock:t.menuBlock}:{},x:n,y:i,width:t.width,height:t.height,bounds:a,labelPosition:o}}let o="actor"===e.type?i+t.height:Math.max(i+t.height,i+26),a=o+Math.max(14,t.labelMetrics.lineHeight/2+5.5)+(t.labelMetrics.lines.length-1)/2*t.labelMetrics.lineHeight,r=eR(t.displayLabel,n,a,"middle",t.fontSize,t.fontWeight,t.letterSpacing,t.block),l=eJ({x:n-t.width/2,y:i,width:t.width,height:o-i},r.bounds),s={x:l.x,y:l.y,width:l.width,height:l.height+4};return{id:e.id,label:e.label,type:e.type,...e.links?{links:{...e.links}}:{},...t.menuBlock?{menuBlock:t.menuBlock}:{},x:n,y:i,width:t.width,height:t.height,bounds:s,labelPosition:r}}function eG(e,t,n,i){let o=t.dividerNoteIndices[i]??-1,a=t.dividerNoteIndices[i+1]??t.endNoteExclusive;return o>=0&&o<a&&n.notes[o].afterIndex<e.dividers[i].index?o:void 0}function eQ(e,t,n,i,o,a,r,l,s,d,c,h,p){let g,u,f=e.startIndex<n.endMessageExclusive?r[e.startIndex]:void 0,x=e.startIndex<n.endMessageExclusive?r[n.endMessageExclusive-1]:void 0,b=new Set;for(let t=e.startIndex;t<n.endMessageExclusive;t++){let e=i.messages[t];e&&(b.add(o.get(e.from)??0),b.add(o.get(e.to)??0))}for(let e of n.noteIndices){let t=i.notes[e];if(t)for(let e of t.actorIds){let t=o.get(e);void 0!==t&&b.add(t)}}if(0===b.size)for(let e=0;e<i.actors.length;e++)b.add(e);let m=1/0,y=-1/0;for(let e of b){let t=a[e];if(!t)continue;let n=t.bounds;m=Math.min(m,n.x-d.groupPaddingX),y=Math.max(y,n.x+n.width+d.groupPaddingX)}for(let t=e.startIndex;t<n.endMessageExclusive;t++){let e=r[t];e&&(m=Math.min(m,e.bounds.x-d.groupPaddingX),y=Math.max(y,e.bounds.x+e.bounds.width+d.groupPaddingX))}for(let e of n.noteIndices){let t=l[e];t&&(m=Math.min(m,t.x-d.groupPaddingX),y=Math.max(y,t.x+t.width+d.groupPaddingX))}for(let e of n.childBlockIndices){let t=s[e];t&&(m=Math.min(m,t.x-d.groupPaddingX),y=Math.max(y,t.x+t.width+d.groupPaddingX))}for(let n of("rect"!==e.type&&(y=Math.max(y,m+t.tabWidth+d.groupPaddingX)),t.dividers))n.label&&(y=Math.max(y,m+8+n.metrics.width+d.groupPaddingX));let k=f&&!f.isSelf&&f.labelPosition.text.includes(`
3
- `)?Math.ceil(Math.max(0,f.labelPosition.y-f.labelPosition.bounds.y-d.edgeLabelFontSize*el/2-1e-6)):0,w=n.noteIndices.length>0?t.contentTopPadding:t.blockPadTop,v=p?.top??(f?f.y-(t.blockPadTop+k):h-w),M=(x?.y??h)+d.groupPaddingY+12;for(let i=e.startIndex;i<n.endMessageExclusive;i++){let e=r[i];if(!e)continue;v=Math.min(v,e.bounds.y-Math.max(t.tabHeight,d.groupPaddingY));let n=e.isSelf?d.groupPaddingY+4:d.groupPaddingY;M=Math.max(M,e.bounds.y+e.bounds.height+n)}for(let o of b){let l=i.actors[o],s=a[o];if(!(!s||l?.createMessageIndex===void 0||!r[l.createMessageIndex])&&l.createMessageIndex>=e.startIndex&&l.createMessageIndex<n.endMessageExclusive){let e=t.contentTopPadding;v=Math.min(v,s.bounds.y-e),M=Math.max(M,s.bounds.y+s.bounds.height+d.groupPaddingY)}}for(let e of n.noteIndices){let n=l[e];if(!n)continue;let i=t.contentTopPadding;v=Math.min(v,n.y-i),M=Math.max(M,n.y+n.height+d.groupPaddingY)}for(let e of n.childBlockIndices){let n=s[e];n&&(v=Math.min(v,n.y-t.enclosingHeaderStep),M=Math.max(M,n.y+n.height+d.groupPaddingY))}let I=t.dividers.map((o,a)=>{let g=eG(e,n,i,a),u=void 0===g?void 0:l[g],f=o.index<n.endMessageExclusive?r[o.index]:void 0;if("par_over"===e.type){if(!o.label)return{y:v+t.tabHeight,label:""};let e=u??f?.bounds;for(let[t,r]of n.childBlockIndices.entries()){let l=s[r];l&&n.childSectionIndices[t]===a+1&&i.blocks[r].startIndex===o.index&&(!e||l.y<e.y)&&(e=l)}let r=e?.x??m+8,l=e?e.y-o.metrics.height-8:v+t.tabHeight+8+a*(o.metrics.height+8),c=eR(o.displayLabel,r,l+o.metrics.height/2,"start",d.edgeLabelFontSize,d.edgeLabelFontWeight,d.edgeLetterSpacing,o.block);return y=Math.max(y,c.bounds.x+c.bounds.width+d.groupPaddingX),M=Math.max(M,c.bounds.y+c.bounds.height+d.groupPaddingY),{y:l,label:o.label,labelPosition:c}}let x=f?.y??h,b=28+o.extraLinesHeight+o.extraFontOffset;if(o.label&&f?.label){let e=m+8,t=e+o.metrics.width,n=f.labelPosition.bounds,i=n.x,a=n.x+n.width;if(t+8>i&&e-8<a){let e=Math.max(0,Math.ceil(x-10-(n.y+n.height/2)));b=Math.max(36+o.extraLinesHeight+o.extraFontOffset+e,Math.ceil(24+c+o.extraLinesHeight+o.extraFontOffset+e))}}let k=p?.dividerY[a],w=k??(u?u.y-o.noteContentOffset:x-b);for(let[e,t]of n.childBlockIndices.entries()){let r=s[t],l=i.blocks[t];if(void 0===k&&r&&l?.startIndex===o.index&&n.childSectionIndices[e]===a+1){let e=o.noteContentOffset;w=Math.min(w,r.y-e)}}if(!o.label)return{y:w,label:o.label};let I=w+o.firstLineOffset+(o.metrics.lines.length-1)/2*o.metrics.lineHeight,S=eR(o.displayLabel,m+8,I,"start",d.edgeLabelFontSize,d.edgeLabelFontWeight,d.edgeLetterSpacing,o.block);return M=Math.max(M,S.bounds.y+S.bounds.height+d.groupPaddingY),{y:w,label:o.label,labelPosition:{...S,text:o.displayLabel}}}),S="rect"===e.type?void 0:(g=v+t.tabHeight/2,u=eR(t.headerText,m+d.groupLabelPaddingX,g,"start",d.groupHeaderFontSize,d.groupHeaderFontWeight,d.groupLetterSpacing,t.block),{x:m,y:v,width:t.tabWidth,height:t.tabHeight,label:{...u,text:t.headerText}}),$={x:m,y:v,width:y-m,height:M-v};return{type:e.type,label:e.label,...e.color?{color:e.color}:{},x:$.x,y:$.y,width:$.width,height:$.height,dividers:I,...S?{header:S}:{},bounds:$}}function eK(e,t,n){for(let i of e.actors)i.x+=t,i.y+=n,i.bounds=eU(i.bounds,t,n),i.labelPosition=eV(i.labelPosition,t,n);for(let i of e.messages)!function(e,t,n){e.x1+=t,e.x2+=t,e.y+=n,e.points=e.points.map(e=>({x:e.x+t,y:e.y+n})),e.labelPosition=eV(e.labelPosition,t,n),e.bounds=eU(e.bounds,t,n)}(i,t,n);for(let i of e.blocks)for(let e of(i.x+=t,i.y+=n,i.bounds=eU(i.bounds,t,n),i.header&&(i.header={...i.header,x:i.header.x+t,y:i.header.y+n,label:eV(i.header.label,t,n)}),i.dividers))e.y+=n,e.labelPosition&&(e.labelPosition=eV(e.labelPosition,t,n));for(let i of e.notes)i.x+=t,i.y+=n;for(let i of e.boxes)i.x+=t,i.y+=n,void 0!==i.labelY&&(i.labelY+=n);for(let i of e.activations)i.x+=t,i.topY+=n,i.bottomY+=n;for(let i of e.lifelines)i.x+=t,i.topY+=n,i.bottomY+=n;for(let i of e.destructions)i.x+=t,i.y+=n}var e0={nodeLabelFontSize:q.nodeLabel,edgeLabelFontSize:q.edgeLabel,groupHeaderFontSize:q.edgeLabel,nodeLabelFontWeight:F.nodeLabel,edgeLabelFontWeight:F.edgeLabel,groupHeaderFontWeight:F.groupHeader,nodePaddingX:16,nodePaddingY:6,nodeCornerRadius:4,nodeLineWidth:H.outerBox,edgeLineWidth:H.connector,groupCornerRadius:0,groupPaddingX:10,groupPaddingY:8,groupLabelPaddingX:6,groupLineWidth:H.outerBox};function e1(e,t={},n={},i){let o=z(t,e0,i),a=n.diagramMarginX??30,r=n.diagramMarginY??30,l=n.width??80,s=n.noteMargin??10,d=n.activationWidth??10,c=e.actors.map(e=>ea(i,"actor",{category:e.id},{includeFallback:!1})),h=Math.max(n.height??40,...c.map(e=>es("Mg",e?.fontSize??o.nodeLabelFontSize,e?.fontWeight??o.nodeLabelFontWeight).height+(e?.paddingY??o.nodePaddingY)*2)),p=es("Mg",e0.edgeLabelFontSize,e0.edgeLabelFontWeight).height,g=es("Mg",o.edgeLabelFontSize,o.edgeLabelFontWeight).height,u=n.messageMargin??40,f=Math.max(u,u+g-p),x=Math.max(30,f-10),b=Math.max(40,40+(o.groupHeaderFontSize-e0.groupHeaderFontSize)+(o.groupPaddingY-e0.groupPaddingY)*2),m=Math.max(28,b+o.groupPaddingY+20-f);if(0===e.actors.length)return e2({width:0,height:0,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,actors:[],lifelines:[],messages:[],activations:[],blocks:[],notes:[],boxes:[],destructions:[]},void 0===e.title?void 0:A(e.title,e.titleContent),o,a,r);let y=e.actors.map((e,t)=>{var i,a;let r,s,d,p,g,u,f,x,b,m;return i=void 0===e.wrap&&void 0!==n.wrap?{...e,wrap:n.wrap}:e,a=c[t],r=a?.textTransform??o.nodeTextTransform,s=a?.fontSize??o.nodeLabelFontSize,d=a?.fontWeight??o.nodeLabelFontWeight,p=a?.letterSpacing??o.nodeLetterSpacing,g=a?.paddingX??o.nodePaddingX,u=a?.paddingY??o.nodePaddingY,x=(f=et(A(i.label,i.labelContent),{transform:r,fontSize:s,fontWeight:d,letterSpacing:p,...i.wrap?{maxWidth:240}:{}})).text,b=Math.max(f.width+2*g,l),m="participant"===i.type?Math.max(h,Math.ceil(f.height+2*u)):h,{fontSize:s,fontWeight:d,letterSpacing:p,paddingX:g,paddingY:u,displayLabel:x,block:f,...i.links?{menuBlock:et("⋯",{display:"literal",fontSize:10,fontWeight:400})}:{},labelMetrics:f,width:b,height:m}}),k=y.map(e=>e.width),w=new Map;for(let t=0;t<e.actors.length;t++)w.set(e.actors[t].id,t);let v=e.messages.map(e=>{var t;let i,a,r,l,s,c,h,p,g,u,f,x,b,m,y;return s=(l=et((r=Object.freeze({value:a=void 0!==(t=void 0===e.wrap&&void 0!==n.wrap?{...e,wrap:n.wrap}:e).number?`${t.number}. ${t.label}`:t.label,prepared:J((i=A(t.label,t.labelContent),void 0!==t.number?R([`${t.number}. `,"string"==typeof i?J(i):i]):i))})).prepared,{transform:o.edgeTextTransform,fontSize:o.edgeLabelFontSize,fontWeight:o.edgeLabelFontWeight,letterSpacing:o.edgeLetterSpacing,...t.wrap?{maxWidth:240}:{}})).text,c=o.edgeLabelFontSize*el,h=a?l:{width:0,height:0,lines:[],lineHeight:c},p=Math.max("none"!==t.startHead?E.width:0,5*!!t.centralStart),g=Math.max("none"!==t.endHead?E.width:0,5*!!t.centralEnd),u=Math.max(o.lineWidth/2,"none"!==t.startHead||"none"!==t.endHead?E.height/2:0,t.centralStart||t.centralEnd?4.75:0),f=Math.max(16,p+g+8),x=h.width+f,m=(b=30+(h.width>0?8+h.width:0))+Math.max(12,d/2+8),y=t.from===t.to?0:Math.ceil(Math.max(0,h.height-c)),{label:a,labelContent:r,displayLabel:s,block:l,labelMetrics:h,startPad:p,endPad:g,markerHalfHeight:u,requiredSpanWidth:x,selfRightExtent:b,requiredSelfNeighborGap:m,extraAboveHeight:y}}),M=Array.from({length:Math.max(0,e.actors.length-1)},()=>0);for(let t=0;t<e.messages.length;t++){let n=e.messages[t],i=v[t],o=w.get(n.from),a=w.get(n.to);if(void 0===o||void 0===a)continue;if(o===a){o<e.actors.length-1&&(M[o]=Math.max(M[o],i.requiredSelfNeighborGap));continue}let r=Math.min(o,a),l=Math.max(o,a),s=l-r,d=e.actors[a].createMessageIndex===t&&"participant"===e.actors[a].type?k[a]/2:0,c=(i.requiredSpanWidth+d)/s;for(let e=r;e<l;e++)M[e]=Math.max(M[e],c)}let I=[],S=a+k[0]/2;for(let t=0;t<e.actors.length;t++){if(t>0){let e=(k[t-1]+k[t])/2;S+=Math.max(void 0!==n.actorMargin?e+n.actorMargin:Math.max(140,e+40),M[t-1]??0)}I.push(S)}let $=(e.boxes??[]).flatMap((t,i)=>{let a=e.actors.flatMap((e,t)=>e.box===i?[t]:[]),r=t.label?et(A(t.label,t.labelContent),{transform:o.groupTextTransform,fontSize:o.groupHeaderFontSize,fontWeight:o.groupHeaderFontWeight,letterSpacing:o.groupLetterSpacing,fontFamily:o.groupFont,...t.wrap??n.wrap?{maxWidth:240}:{}}):void 0;return a.length>0?[{box:t,memberIdxs:a,block:r}]:[]}),L=Math.max(22,...$.map(e=>(e.block?.height??0)+8)),C=r+($.length>0?L+6:0),W=e.actors.map((e,t)=>eZ(e,y[t],I[t],C)),P=e.actors.flatMap((t,n)=>{if(void 0!==t.createMessageIndex&&t.createMessageIndex<e.messages.length)return[];let i=W[n].bounds;return[i.y+i.height]}),q=P.length>0?Math.max(...P):C+h,F=q+26,H=[],Y=e.blocks.map((t,n)=>{let i=eE.get(t);if(i)return i;let o=[];for(let n=0;n<e.notes.length;n++){let i=e.notes[n];i.afterIndex>=t.startIndex&&i.afterIndex<=t.endIndex&&o.push(n)}let a=[];for(let i=0;i<n;i++){let o=e.blocks[i];o.startIndex>=t.startIndex&&o.endIndex<=t.endIndex&&(e.blocks.some((e,a)=>a>i&&a<n&&o.startIndex>=e.startIndex&&o.endIndex<=e.endIndex&&e.startIndex>=t.startIndex&&e.endIndex<=t.endIndex)||a.push(i))}return{endMessageExclusive:Math.min(t.endIndex+1,e.messages.length),dividerNoteIndices:t.dividers.map(()=>-1),endNoteExclusive:o.length>0?o.at(-1)+1:e.notes.filter(e=>e.afterIndex<=t.endIndex).length,noteIndices:o,childBlockIndices:a,childSectionIndices:a.map(n=>t.dividers.filter(t=>e.blocks[n].startIndex>=t.index).length)}}),T=e.blocks.map(e=>{var t;let i,a,r,l,s,d,c,h,p,u,f;return a=(i=et("rect"===(t={...e,wrap:e.wrap??n.wrap,dividers:e.dividers.map(e=>({...e,wrap:e.wrap??n.wrap}))}).type?"":t.label?R([`${t.type} [`,J(A(t.label,t.labelContent)),"]"]):t.type,{transform:o.groupTextTransform,fontSize:o.groupHeaderFontSize,fontWeight:o.groupHeaderFontWeight,letterSpacing:o.groupLetterSpacing,fontFamily:o.groupFont,...t.wrap?{maxWidth:240}:{}})).text,r=o.groupHeaderFontSize*el,s=Math.ceil(Math.max(0,((l=a?i:{width:0,height:0,lines:[],lineHeight:r}).lines.length-1)*l.lineHeight)),d=Math.max(2*o.groupPaddingX,2*o.groupLabelPaddingX),c="rect"===t.type?0:l.width+d,h="rect"===t.type?0:Math.max(18,o.groupHeaderFontSize+o.groupPaddingY)+s,p=b+s,u="rect"===t.type?o.groupPaddingY:h+o.groupPaddingY,f=t.dividers.map(e=>{let t=et(e.label?R(["[",J(A(e.label,e.labelContent)),"]"]):"",{transform:o.edgeTextTransform,fontSize:o.edgeLabelFontSize,fontWeight:o.edgeLabelFontWeight,letterSpacing:o.edgeLetterSpacing,...e.wrap?{maxWidth:240}:{}}),n=t.text,i=e.label?t:{width:0,height:0,lines:[],lineHeight:g},a=Math.max(14,Math.ceil(i.lineHeight/2+6)),r=Math.max(0,a-14),l=Math.ceil(Math.max(0,(i.lines.length-1)*i.lineHeight));return{index:e.index,label:e.label,displayLabel:n,block:t,metrics:i,firstLineOffset:a,extraFontOffset:r,extraLinesHeight:l,requiredExtraBefore:24+l+r,noteContentOffset:Math.ceil(Math.max(28+l+r,a+(i.lines.length-1)/2*i.lineHeight+i.height/2+o.groupPaddingY))}}),{headerText:a,block:i,headerMetrics:l,tabWidth:c,tabHeight:h,extraHeaderLinesHeight:s,blockPadTop:p,blockHeaderExtra:m+s,enclosingHeaderStep:u,contentTopPadding:"rect"===t.type?o.groupPaddingY:Math.max(p,h+o.groupPaddingY),dividers:f}}),B=eY.get(e),_=new Map,N=new Map,O=new Map,j=new Map,X=new Map;for(let t=0;t<e.blocks.length;t++){let n=e.blocks[t],i=N.get(n.startIndex)??[];i.push(t),N.set(n.startIndex,i);let o=Y[t],a=o.noteIndices[0];if(void 0!==a){let e=O.get(a)??[];e.push(t),O.set(a,e)}for(let e of o.childBlockIndices)j.set(e,t)}let D=new Set,U=new Set;if(B){let t=new Map(B.filter(e=>"open"===e.kind).map(e=>[e.blockIndex,e.noteIndex]));for(let n=0;n<e.blocks.length;n++){let i=e.blocks[n],o=Y[n],a=new Set(o.childSectionIndices),r=i.startIndex,l=t.get(n);for(let e=0;e<=i.dividers.length;e++){let t=i.dividers[e]?.index??o.endMessageExclusive,s=o.dividerNoteIndices[e]??o.endNoteExclusive;r!==t||l!==s||a.has(e)||U.add(n),r=t,l=s}o.childBlockIndices.some(t=>e.blocks[t].startIndex===Y[t].endMessageExclusive&&0===Y[t].noteIndices.length)&&U.add(n)}for(let t=0;t<e.blocks.length;t++){let e=j.get(t);U.has(t)&&void 0!==e&&U.add(e)}}let V=e=>(N.get(e)??[]).filter(t=>!D.has(t)&&Y[t].endMessageExclusive>e),Z=e=>0===e.length?0:T[e[0]].blockHeaderExtra+e.slice(1).reduce((e,t)=>e+T[t].enclosingHeaderStep,0);for(let t=0;t<e.blocks.length;t++){if(U.has(t)||"par_over"===e.blocks[t].type)continue;let n=T[t],i=Y[t];for(let[o,a]of n.dividers.entries()){let n=eG(e.blocks[t],i,e,o);if(void 0!==n){X.set(n,Math.max(X.get(n)??0,a.noteContentOffset));continue}if(a.index>=i.endMessageExclusive)continue;let r=a.requiredExtraBefore;for(let t of i.childBlockIndices)e.blocks[t]?.startIndex===a.index&&(r+=T[t].blockHeaderExtra);let l=_.get(a.index)??0;_.set(a.index,Math.max(l,r))}}let G=new Map,Q=new Map,K=new Map;for(let t=0;t<e.actors.length;t++){let n=e.actors[t];if(void 0!==n.createMessageIndex&&n.createMessageIndex<e.messages.length){let e=G.get(n.createMessageIndex)??[];e.push(t),G.set(n.createMessageIndex,e)}if(void 0!==n.destroyMessageIndex&&n.destroyMessageIndex<e.messages.length){let e=Q.get(n.destroyMessageIndex)??[];e.push(n.id),Q.set(n.destroyMessageIndex,e)}}let ee=new Map;for(let t=0;t<e.notes.length;t++){let n=e.notes[t],i=ee.get(n.afterIndex)??[];i.push({note:n,index:t}),ee.set(n.afterIndex,i)}let en=Array(e.notes.length),ei=new Map,eo=[],er=new Map;for(let t of e.activationEvents??[]){let e=er.get(t.messageIndex)??[];e.push(t),er.set(t.messageIndex,e)}let ed=(e,t)=>{let n=ei.get(e)??[];n.push({startY:t,depth:n.length}),ei.set(e,n)},ec=(e,t)=>{let n=ei.get(e);if(!n||0===n.length)return;let{startY:i,depth:o}=n.pop(),a=w.get(e);void 0===a||t<=i||eo.push({actorId:e,x:I[a]-d/2+4*o,topY:i,bottomY:t,width:d})},eh=(e,t)=>{for(let n of er.get(e)??[])"activate"===n.kind?ed(n.actorId,t):ec(n.actorId,t)},ep=(e,t)=>{let i=et(A(e.text,e.textContent),{transform:o.nodeTextTransform,fontSize:o.nodeLabelFontSize,fontWeight:o.nodeLabelFontWeight,letterSpacing:o.nodeLetterSpacing,...e.wrap??n.wrap?{maxWidth:240}:{}}),a=Math.max(60,i.width+2*o.nodePaddingX),r=i.height+2*o.nodePaddingY,l=w.get(e.actorIds[0]??"")??0,d;if("left"===e.position)d=I[l]-k[l]/2-a-s;else if("right"===e.position)d=I[l]+k[l]/2+s;else if(e.actorIds.length>1){let t=w.get(e.actorIds[e.actorIds.length-1]??"")??l;d=(I[l]+I[t])/2-a/2}else d=I[l]-a/2;return{text:e.text,block:i,x:d,y:t,width:a,height:r,position:e.position,actors:e.actorIds}},eg=Array(e.blocks.length),eu=[],ef=-1/0,ex=q,eb=-1/0,em=0,ey=0,ek=0,ew=0,ev=new Map,eM=(t,n,i)=>{let o=0,a=[];for(let[o,r]of ev){let l=e.blocks[o];for(let e=l.startIndex;e<r.messageEnd;e++)H[e]&&a.push(H[e].bounds);for(let e of Y[o].noteIndices)e<r.noteEnd&&en[e]&&a.push(en[e]);for(let e of r.priorChildren)eg[e]&&a.push(eg[e]);for(let[s,d]of l.dividers.entries()){let c=T[o].dividers[s];if(!d.label)continue;let h=eG(l,Y[o],e,s),p=void 0!==h&&h<r.noteEnd?en[h]:void 0===h&&d.index<r.messageEnd?H[d.index]?.bounds:void 0;if(p&&a.push({x:p.x,y:p.y-c.metrics.height-8,width:c.metrics.width,height:c.metrics.height}),void 0===h&&n===d.index||void 0!==h&&i===h){let e=c.metrics.height+8;t={x:t.x,y:t.y-e,width:Math.max(t.width,c.metrics.width),height:t.height+e}}}}for(let e=0;e<=a.length;e++){let e=a.find(e=>t.x<e.x+e.width+8&&t.x+t.width+8>e.x&&t.y+o<e.y+e.height+8&&t.y+t.height+o+8>e.y);if(!e)break;o=e.y+e.height+8-t.y}return o},eI=e=>{let t=[];for(let n=e;void 0!==n&&!D.has(n);n=j.get(n))t.push(n);for(let e=t.length-1;e>=0;e--){let n=t[e],i=Math.max(ex,ef,eb)+8;eu[n]={top:i,dividerY:[]},D.add(n),ex=eb=i+T[n].enclosingHeaderStep}},eS=t=>{let n=e.blocks[t],i=Y[t],a=eu[t]?.top,r=void 0!==a&&n.startIndex===i.endMessageExclusive&&0===i.noteIndices.length?a+T[t].blockPadTop:en[i.noteIndices[0]??-1]?.y??F;D.add(t);let l=eQ(n,T[t],i,e,w,W,H,en,eg,o,g,r,eu[t]);eg[t]=l,ef=Math.max(ef,l.y+l.height);let s=ev.get(t);s&&(ex=Math.max(ex,s.bottom,ef),F=Math.max(F,ex+f/2),ev.delete(t))},e$=()=>{if(B){for(;ek<B.length;){let t=B[ek];if(t.messageIndex>H.length||t.noteIndex>em)break;let n=t.blockIndex;if("open"===t.kind&&U.has(n)&&eI(n),"open"===t.kind&&"par_over"===e.blocks[n].type){eI(n);let i=Math.max(0,...T[n].dividers.map(e=>e.noteContentOffset));eb+=i,ex=eb,F=Math.max(F,eb+f/2),ev.set(n,{messageY:F,contentBottom:ex,completedBottom:ef,reservedBottom:eb,bottom:ex,messageEnd:e.blocks[n].startIndex,noteEnd:t.noteIndex,priorChildren:[]}),ew++}if("divider"===t.kind){let e=ev.get(n);if(e){e.bottom=Math.max(e.bottom,ex,ef,eb),e.messageEnd=t.messageIndex,e.noteEnd=t.noteIndex,e.priorChildren=Y[n].childBlockIndices.filter(e=>eg[e]),({messageY:F,contentBottom:ex,completedBottom:ef,reservedBottom:eb}=e),ew++,ek++;continue}let i=T[n].dividers[t.dividerIndex],o=Math.max(ex,ef,eb)+8;U.has(n)?(eu[n].dividerY[t.dividerIndex]=o,ex=eb=o+i.noteContentOffset):eb=o+i.noteContentOffset}"close"===t.kind&&eS(n),ek++}return}for(;ey<e.blocks.length;){let e=ey,t=Y[e];if(t.endMessageExclusive>H.length||t.endNoteExclusive>em)break;eS(e),ey++}},eL=(e,t)=>{let n=t;for(let{note:t,index:i}of ee.get(e)??[]){let e=ew;for(let t of(e$(),e!==ew&&(n=F),n=Math.max(n,ef+8,eb),O.get(i)??[])){let e=eu[t]?.top;void 0!==e&&(n=Math.max(n,e+T[t].contentTopPadding))}let o=(O.get(i)??[]).filter(e=>!D.has(e)),a=X.get(i)??0;if(o.length>0||a>0){let e=a+(o.length>0?T[o[0]].contentTopPadding+o.slice(1).reduce((e,t)=>e+T[t].enclosingHeaderStep,0):0);for(let t of(n=Math.max(n,Math.max(ex,ef)+8+e),o))D.add(t)}let r=ep(t,n),l=eM(r,void 0,i);l>0&&(n+=l,r=ep(t,n)),en[i]=r,ex=Math.max(ex,r.y+r.height),em=i+1,n=r.y+r.height+4}ee.has(e)&&(F=Math.max(F,n+f/2))};eL(-1,F);for(let t=0;t<e.messages.length;t++){let n=e.messages[t],i=v[t],a=w.get(n.from)??0,r=w.get(n.to)??0,l=n.from===n.to;e$();let s=V(t),d=Math.max(_.get(t)??0,Z(s));for(let e of G.get(t)??[]){let t=W[e].height/2;d=d>0?d+Math.max(0,t-12):t+8}F+=d+i.extraAboveHeight;let c=I[a],h=I[r],p=e.actors[r].createMessageIndex!==t||"participant"!==e.actors[r].type||l?h:h-Math.sign(h-c)*k[r]/2,u=()=>{let a=function(e,t,n,i,o,a){let r=e.from===e.to;if(r){let l=a+Math.max(20,t.labelMetrics.height)/2,s=eR(t.displayLabel,i+30+8,l,"start",n.edgeLabelFontSize,n.edgeLabelFontWeight,n.edgeLetterSpacing,t.block),d={x:i-t.startPad,y:a-t.markerHalfHeight,width:30+t.startPad+n.lineWidth/2,height:20+2*t.markerHalfHeight},c=t.label?eJ(d,s.bounds):d;return{from:e.from,to:e.to,label:t.label,labelContent:t.labelContent,lineStyle:e.lineStyle,startHead:e.startHead,endHead:e.endHead,centralStart:e.centralStart??!1,centralEnd:e.centralEnd??!1,x1:i,x2:o,y:a,isSelf:r,points:[{x:i,y:a},{x:i+30,y:a},{x:i+30,y:a+20},{x:o,y:a+20}],labelPosition:s,bounds:c}}let l=Math.max(2.85,n.lineWidth/2+2),s=Math.max(10,t.labelMetrics.height/2+l),d=eR(t.displayLabel,(i+o)/2,a-s,"middle",n.edgeLabelFontSize,n.edgeLabelFontWeight,n.edgeLetterSpacing,t.block),c=i<=o?t.startPad:t.endPad,h=i<=o?t.endPad:t.startPad,p=Math.min(i,o)-c,g=Math.max(i,o)+h,u={x:p,y:a-t.markerHalfHeight,width:g-p,height:2*t.markerHalfHeight},f=t.label?eJ(u,d.bounds):u;return{from:e.from,to:e.to,label:t.label,labelContent:t.labelContent,lineStyle:e.lineStyle,startHead:e.startHead,endHead:e.endHead,centralStart:e.centralStart??!1,centralEnd:e.centralEnd??!1,x1:i,x2:o,y:a,isSelf:r,points:[{x:i,y:a},{x:o,y:a}],labelPosition:d,bounds:f}}(n,i,o,c,p,F);for(let n of(H[t]=a,G.get(t)??[]))W[n]=eZ(e.actors[n],y[n],I[n],F-W[n].height/2);return a},b=u(),m=b.bounds.y,M=0,S=new Set(s),$=(N.get(t)??[]).filter(e=>S.has(e)||eu[e]?.top!==void 0&&!eg[e]);if($.length>0){let t=[];for(let n of $){for(let e of Y[n].childBlockIndices)eg[e]&&(t[e]=eg[e]);t[n]=eQ(e.blocks[n],T[n],Y[n],e,w,W,H,en,t,o,g,F,eu[n]);let i=eu[n]?.top;void 0!==i?M=Math.max(M,i-t[n].y):m=Math.min(m,t[n].y)}}let L=Math.max(0,M,(s.length>0?Math.max(ex,ef,eb):Math.max(ef,eb))+8*(s.length>0)-m);L>0&&(F+=L,b=u());let C=eM(b.bounds,t);for(let e of(C>0&&(F+=C,b=u()),s))D.add(e);ex=Math.max(ex,b.bounds.y+b.bounds.height,...(G.get(t)??[]).map(e=>W[e].bounds.y+W[e].bounds.height)),eh(t,F);let P=Q.get(t);if(P)for(let e of P)K.set(e,F);n.activate&&ed(n.to,F),n.deactivate&&ec(n.from,F);let q=l?Math.max(x,Math.ceil(i.labelMetrics.height)+10):0;F+=l?q+f:f;let E=G.get(t);if(E){let e=Math.max(...E.map(e=>{let t=W[e];return t.bounds.height-t.height/2}));F+=e}let z=E?ex+8:b.y+q+14;eL(t,z)}e$();let eC=Math.max(H[H.length-1]?.y??F,F-f/2);for(let[t,n]of(eh(e.messages.length,eC),ei))for(;n.length>0;)ec(t,eC);for(let t of W)e.actors[w.get(t.id)]?.external&&(t.external=!0);for(let[t,n]of H.entries()){let i=e.messages[t];void 0!==i.id&&(n.id=i.id),void 0!==i.parentId&&(n.parentId=i.parentId)}for(let[t,n]of eg.entries()){let i=e.blocks[t];void 0!==i.id&&(n.id=i.id),void 0!==i.parentId&&(n.parentId=i.parentId)}for(let[t,n]of en.entries()){let i=e.notes[t];n&&i?.id!==void 0&&(n.id=i.id),n&&i?.parentId!==void 0&&(n.parentId=i.parentId)}let eW=en.filter(e=>void 0!==e),eP=eg.reduce((e,t)=>Math.max(e,t.y+t.height),0);eP>0&&(F=Math.max(F,eP+8));let eq=F,eF=$.map(({box:e,memberIdxs:t,block:n})=>{let i=Math.min(...t.map(e=>W[e].bounds.x))-8,o=Math.max(...t.map(e=>W[e].bounds.x+W[e].bounds.width))+8;return e.label&&(o=Math.max(o,i+n.width+16)),{label:e.label,block:n,labelY:r+L/2,color:e.color,x:i,y:r,width:o-i,height:eq+8-r}}),eH=F+r,ez=a,eT=0;for(let e of W){let t=e.bounds;ez=Math.min(ez,t.x),eT=Math.max(eT,t.x+t.width)}for(let e of eg)ez=Math.min(ez,e.x),eT=Math.max(eT,e.x+e.width);for(let e of eW)ez=Math.min(ez,e.x),eT=Math.max(eT,e.x+e.width);for(let e of eF)ez=Math.min(ez,e.x),eT=Math.max(eT,e.x+e.width);for(let e of eo)ez=Math.min(ez,e.x),eT=Math.max(eT,e.x+e.width);for(let e of H){ez=Math.min(ez,e.bounds.x);let t=e.isSelf&&e.label?8:0;eT=Math.max(eT,e.bounds.x+e.bounds.width+t)}let eB=ez<a?a-ez:0;if(eB>0){eK({actors:W,messages:H,blocks:eg,notes:eW,boxes:eF,activations:eo,lifelines:[],destructions:[]},eB,0);for(let e=0;e<I.length;e++)I[e]+=eB}let e_=e.actors.map((e,t)=>{let n=W[t],i=n.bounds.y+n.bounds.height;return{actorId:e.id,x:I[t],topY:i,bottomY:K.get(e.id)??eH-r}}),eN=e.actors.filter(e=>K.has(e.id)).map(e=>({actorId:e.id,x:I[w.get(e.id)],y:K.get(e.id)}));return e2({width:Math.max(eT+eB+a,200),height:Math.max(eH,100),accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,actors:W,lifelines:e_,messages:H,activations:eo,blocks:eg,notes:eW,boxes:eF,destructions:eN},void 0===e.title?void 0:A(e.title,e.titleContent),o,a,r)}function e2(e,t,n,i,o){let a=T(t,n);if(!a)return e;if(0===e.width&&0===e.height)return{...e,...B(a,i,o)};let r=a.height;eK(e,0,r);let l=Math.max(e.width,a.width+2*i);return{...e,width:l,height:e.height+r,title:_(a,l,o)}}function e3(e,t){let n,i,o,a,r,{positioned:l,colors:s,resolved:d}=t,c=d.renderOptions,h=s.font??"Inter",p=c.transparent??!1,g=[],u=z(c,e0,d.styleFace),f=`seq-${ee(l.width,l.height,l.actors.length,l.messages.length)}`,x=`${f}-title`,b=`${f}-desc`,m=W(l.accessibilityTitle,l.accessibilityDescription,x,b);g.push(e.documentOpen({id:"prelude",width:l.width,height:l.height,colors:s,transparent:p,font:h,hasMonoFont:!1},L(l.width,l.height,s,p,m)+`
4
- `+$(h,!1,s.shadow,s.embedFontImport)));let w=[];w.push("<defs>");let v=(n=E.width,i=E.height,o=u.edgeStrokeColor??"var(--_arrow)",a={size:{width:n,height:i},orient:"auto-start-reverse"},r=[{x:0,y:0},{x:n,y:i/2},{x:0,y:i}],[{...a,id:"seq-arrow",shape:"arrow",ref:{x:n,y:i/2},geometry:{kind:"polygon",points:r},paint:{fill:o}},{...a,id:"seq-arrow-open",shape:"open-arrow",ref:{x:n,y:i/2},geometry:{kind:"polyline",points:r},paint:{fill:"none",stroke:o,strokeWidth:"1"}},{...a,id:"seq-arrow-cross",shape:"cross",ref:{x:n/2,y:i/2},orient:"auto",geometry:{kind:"path",d:`M1 1 L${n-1} ${i-1} M1 ${i-1} L${n-1} 1`},paint:{fill:"none",stroke:o,strokeWidth:"1.5"}},{...a,id:"seq-arrow-half-top",shape:"arrow",ref:{x:n,y:i/2},geometry:{kind:"polygon",points:[{x:0,y:0},{x:n,y:i/2},{x:0,y:i/2}]},paint:{fill:o}},{...a,id:"seq-arrow-half-bottom",shape:"arrow",ref:{x:n,y:i/2},geometry:{kind:"polygon",points:[{x:0,y:i/2},{x:n,y:i/2},{x:0,y:i}]},paint:{fill:o}},{...a,id:"seq-arrow-stick-top",shape:"open-arrow",ref:{x:n,y:i/2},geometry:{kind:"path",d:`M0 0 L${n} ${i/2}`},paint:{fill:"none",stroke:o,strokeWidth:"1.5"}},{...a,id:"seq-arrow-stick-bottom",shape:"open-arrow",ref:{x:n,y:i/2},geometry:{kind:"path",d:`M0 ${i} L${n} ${i/2}`},paint:{fill:"none",stroke:o,strokeWidth:"1.5"}}]);w.push(P(v));let M=S(s);M&&w.push(M),w.push("</defs>"),g.push(e.definitions({id:"defs",markerResources:v},w.join(`
5
- `))),l.accessibilityTitle&&g.push(e.documentContent({id:"a11y-title",role:"chrome",nonPaint:"accessibility"},`<title id="${x}">${V(l.accessibilityTitle)}</title>`)),l.accessibilityDescription&&g.push(e.documentContent({id:"a11y-desc",role:"chrome",nonPaint:"accessibility"},`<desc id="${b}">${V(l.accessibilityDescription)}</desc>`));let I=l.blocks.some(e=>"rect"===e.type),q=I?[...l.blocks].reverse().sort((e,t)=>t.width*t.height-e.width*e.height):l.blocks,F=function(e,t,n,i){let o=(e,t,n)=>t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height,a=e.flatMap(e=>{let t=e.color&&"transparent"!==e.color.toLowerCase()?ek(e.color):void 0;return t?[{x:e.x,y:e.y,width:e.width,height:e.height,hex:t,authored:!0}]:[]}),r=C("var(--bg)",i)??"#ffffff";for(let e of t){let t=e6(e,n),l=void 0===t?void 0:C(t,i)??t,s=void 0===l?null:O(l);if(!s||0===s[3])continue;let d=e.x+e.width/2,c=e.y+e.height/2,h=j(l,a.findLast(e=>o(e,d,c))?.hex??r);h&&a.push({x:e.x,y:e.y,width:e.width,height:e.height,hex:eo(...h),authored:"rect"===e.type})}return(e,t)=>{let n=a.findLastIndex(t=>o(t,e.x,e.y)),r=a[n],l=void 0!==r&&!(o(r,e.x-e.width/2,e.y-e.height/2)&&o(r,e.x+e.width/2,e.y+e.height/2))||a.some((t,i)=>i>n&&t.hex!==r?.hex&&e.x-e.width/2<t.x+t.width&&e.x+e.width/2>t.x&&e.y-e.height/2<t.y+t.height&&e.y+e.height/2>t.y);if(!r)return l?{ink:t,halo:"var(--bg)"}:{ink:t};let s=C(t,i),d=s?er(s,r.hex):y(r.hex)??t;return r.authored||l?{ink:d,halo:r.hex}:{ink:d}}}(l.boxes,q,u,s);l.title&&g.push(e.text(N(l.title,u)));let T=new Map;for(let t of l.boxes){let n=t.label??"",i=T.get(n)??0;T.set(n,i+1),g.push(function(e,t,n,i){let o=[],a=`<g class="box"${t.label?` data-label="${G(t.label)}"`:""}>`,r=t.color?.toLowerCase()==="transparent"?"none":t.color,l=r??"color-mix(in srgb, var(--fg) 5%, var(--bg))";if(o.push({indent:2,node:e.shape({id:`${i}:rect`,role:"group",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.groupCornerRadius,ry:n.groupCornerRadius},paint:{fill:l,stroke:"none"}})}),t.label){let a=t.block?.text??Y(t.label,n.groupTextTransform),l=function(e,t){let n=t.groupTextColor??"var(--_text-sec)";if(!e||"none"===e)return n;let i=ek(e);if(!i)return n;let o=t.groupTextColor;if(o){let e=X(o,i);if(null!==e&&e>=4.5)return o}return y(i)??n}(r,n),s=t.x+t.width/2,d=t.labelY??t.y+13;o.push({indent:2,node:e.text({id:`${i}:title`,role:"label",text:a,block:t.block,x:s,y:d,fontSize:n.groupHeaderFontSize,fontWeight:n.groupHeaderFontWeight,letterSpacing:n.groupLetterSpacing,anchor:"middle",paint:{fill:l}})})}return e.group({id:i,role:"group",open:a,close:"</g>",children:o})}(e,t,u,`box:${n}#${i}`))}let B=new Map,_=new Map;for(let e of l.blocks){let t=B.get(e.type)??0;B.set(e.type,t+1),_.set(e,e.id??`block:${e.type}#${t}`)}for(let t of q)g.push(e9(e,t,u,_.get(t),I?"background":"all"));if(I){for(let t of q)"rect"!==t.type&&g.push(e9(e,t,u,_.get(t),"frame"));for(let t of l.blocks)t.dividers.length>0&&g.push(e9(e,t,u,_.get(t),"dividers"))}let A=function(e){let t=new Map,n=[];for(let i of e){let e=`${i.from}->${i.to}`,o=t.get(e)??0;if(t.set(e,o+1),!i.labelPosition.text.trim())continue;let a=i.labelPosition.bounds;n.push({key:`${e}#${o}`,x:a.x-2,y:a.y-2,width:a.width+4,height:a.height+4})}let i=e=>{let t="x"===e?"width":"height",i=[...n].sort((t,n)=>t[e]-n[e]),o=(n,a)=>{if(n>=a)return;let r=n+a>>>1,l=i[r],s=o(n,r),d=o(r+1,a);return{area:l,left:s,right:d,end:Math.max(l[e]+l[t],s?.end??-1/0,d?.end??-1/0)}},a=o(0,i.length);return n=>{let i=[],o=a=>{if(!a||a.end<n[e])return;o(a.left);let r=a.area;r[e]>n[e]+n[t]||(r.x<=n.x+n.width&&r.x+r.width>=n.x&&r.y<=n.y+n.height&&r.y+r.height>=n.y&&i.push(r),o(a.right))};return o(a),i}},o=i("x"),a=i("y");return(e,t)=>{let n=("x"===t?o:a)(e).sort((e,t)=>e.y-t.y),i=[],r=e.y+e.height,l=e.y,s;for(let t of n){let n=Math.max(e.y,t.y);n>l&&i.push({top:l,bottom:n,after:s});let o=Math.min(r,t.y+t.height);o>l&&(l=o,s=t.key)}return l<r&&i.push({top:l,bottom:r,after:s}),i}}(l.messages),D=new Set(l.actors.filter(e=>e.external).map(e=>e.id));for(let t of l.lifelines){if(D.has(t.actorId))continue;let n=Math.max(.75,.75*u.lineWidth);g.push(function(e,t,n,i){let o=n.edgeStrokeColor??"var(--_line)",a=Math.max(.75,.75*n.lineWidth),r=`lifeline:${t.actorId}`;return 1!==i.length||i[0].top!==t.topY||i[0].bottom!==t.bottomY?e.group({id:r,role:"lifeline",open:`<g class="lifeline" data-actor="${Z(t.actorId)}">`,close:"</g>",children:i.map(n=>{let i=(n.top-t.topY)%10;return{indent:2,node:e.connector({id:n.after?K(r,"after",n.after):K(r,"start"),role:"lifeline",geometry:{kind:"line",x1:t.x,y1:n.top,x2:t.x,y2:n.bottom},lineStyle:"dashed",paint:{stroke:o,strokeWidth:String(a),strokeDasharray:"6 4",strokeDashoffset:String(i)}})}})}):e.connector({id:r,role:"lifeline",geometry:{kind:"line",x1:t.x,y1:t.topY,x2:t.x,y2:t.bottomY},lineStyle:"dashed",paint:{stroke:o,strokeWidth:String(a),strokeDasharray:"6 4"},attributes:{className:"lifeline",data:{actor:t.actorId}}})}(e,t,u,A({x:t.x-n/2,y:t.topY,width:n,height:t.bottomY-t.topY},"x")))}let R=new Map;for(let t of l.activations){let n=R.get(t.actorId)??0;R.set(t.actorId,n+1),g.push(function(e,t,n,i,o){let a=n.nodeFillColor??"var(--_node-fill)",r=n.nodeBorderColor??"var(--_node-stroke)";if(1!==o.length||o[0].top!==t.topY||o[0].bottom!==t.bottomY){let n=[],l=[],s=[];for(let e of o)for(let n of(l.push(`M ${t.x} ${e.top} h ${t.width} V ${e.bottom} h ${-t.width} Z`),[{x1:t.x,y1:e.top,x2:t.x,y2:e.bottom},{x1:t.x+t.width,y1:e.top,x2:t.x+t.width,y2:e.bottom},...e.top===t.topY?[{x1:t.x,y1:e.top,x2:t.x+t.width,y2:e.top}]:[],...e.bottom===t.bottomY?[{x1:t.x,y1:e.bottom,x2:t.x+t.width,y2:e.bottom}]:[]]))s.push(`M ${n.x1} ${n.y1} L ${n.x2} ${n.y2}`);if(l.length){let t=l.join(" "),o=s.join(" ");n.push({indent:2,node:e.shape({id:K(i,"fill"),role:"activation",surfaceFragment:!0,geometry:{kind:"path",d:t},paint:{fill:a,stroke:"none"}})}),n.push({indent:2,node:e.shape({id:K(i,"border"),role:"activation",geometry:{kind:"path",d:o},paint:{fill:"none",stroke:r,strokeWidth:String(H.innerBox)}})})}return e.group({id:i,role:"activation",open:`<g class="activation" data-actor="${Z(t.actorId)}">`,close:"</g>",children:n})}return e.shape({id:i,role:"activation",geometry:{kind:"rect",x:t.x,y:t.topY,width:t.width,height:t.bottomY-t.topY},paint:{fill:a,stroke:r,strokeWidth:String(H.innerBox)},attributes:{className:"activation",data:{actor:t.actorId}}})}(e,t,u,`activation:${t.actorId}#${n}`,A({x:t.x-H.innerBox/2,y:t.topY,width:t.width+H.innerBox,height:t.bottomY-t.topY},"y")))}let J=new Map;for(let t of l.blocks){let n=J.get(t.type)??0;J.set(t.type,n+1),"rect"!==t.type&&t.header&&g.push(function(e,t,n,i){let{x:o,y:a,width:r,height:l,label:s}=t,{text:d,x:c,y:h}=s,p=n.groupHeaderFillColor??"var(--_group-hdr)",g=n.groupBorderColor??"var(--_node-stroke)",u=n.groupTextColor??"var(--_text-sec)";return e.group({id:`${i}:header-overlay`,role:"block",open:'<g class="sequence-block-header-overlay" pointer-events="none" aria-hidden="true">',close:"</g>",children:[{indent:0,node:e.shape({id:`${i}:tab`,role:"block",geometry:{kind:"rect",x:o,y:a,width:r,height:l},paint:{fill:p,stroke:g,strokeWidth:String(n.groupLineWidth)}})},{indent:0,node:e.text({id:`${i}:label`,role:"label",text:d,block:s.block,x:c,y:h,fontSize:n.groupHeaderFontSize,fontWeight:n.groupHeaderFontWeight,letterSpacing:n.groupLetterSpacing,anchor:"start",paint:{fill:u}})}]})}(e,t.header,u,_.get(t)))}let U=new Map;for(let t of l.blocks){let n=U.get(t.type)??0;U.set(t.type,n+1),t.dividers.some(e=>e.label)&&g.push(function(e,t,n,i,o){let a=n.edgeTextColor??"var(--_text-muted)",r=[];return t.dividers.forEach((t,l)=>{if(!t.label||!t.labelPosition)return;let{text:s,x:d,y:c,bounds:h}=t.labelPosition,p=o(e8(h),a),g={ink:p.ink,halo:p.halo??n.groupFillColor??"var(--bg)"};r.push({indent:2,node:e.text({id:`${i}:divider#${l}:label`,role:"label",text:s,block:t.labelPosition.block,x:d,y:c,fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing,anchor:"start",paint:{fill:g.ink,...e5(g)}})})}),e.group({id:`${i}:divider-labels`,role:"block",open:'<g class="sequence-block-divider-labels" pointer-events="none">',close:"</g>",children:r})}(e,t,u,_.get(t),F))}let Q=new Map;for(let t of l.messages){let n=`${t.from}->${t.to}`,i=Q.get(n)??0;Q.set(n,i+1),g.push(function(e,t,n,i,o,a){let r=[],l=e4(a,t.startHead),s=e4(a,t.endHead),d=n.edgeStrokeColor??"var(--_line)",c=n.edgeTextColor??"var(--_text-muted)",{text:h,x:p,y:g,bounds:u}=t.labelPosition,f={stroke:d,strokeWidth:String(n.lineWidth),..."dashed"===t.lineStyle?{strokeDasharray:"6 4"}:{}},x={endpoints:{from:t.from,to:t.to},relationship:{kind:"sequence-message",direction:t.isSelf?"self":l&&s?"bidirectional":l?"reverse":s?"forward":"undirected"},route:{ownership:"layout"},labels:t.label?[{text:t.label,...t.labelContent?{textContent:t.labelContent}:{}}]:[]},b=`<g class="message" data-label="${G(t.label)}" data-line-style="${t.lineStyle}" data-start-head="${t.startHead}" data-end-head="${t.endHead}" data-central-start="${t.centralStart}" data-central-end="${t.centralEnd}" data-self="${t.isSelf}"${void 0===t.parentId?"":` data-parent-id="${Z(t.parentId)}"`}>`;if(t.isSelf){r.push({indent:2,node:e.connector({id:`${i}:line`,role:"message",geometry:{kind:"polyline",points:t.points},lineStyle:t.lineStyle,paint:f,markers:{...l?{start:l}:{},mid:[],...s?{end:s}:{}},...x})});let a=o(e8(u),c);r.push({indent:2,node:e.text({id:`${i}:label`,role:"label",text:h,block:t.labelPosition.block,x:p,y:g,fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing,anchor:"start",paint:{fill:a.ink,...e5(a)}})})}else{let a=t.points[0],d=t.points[t.points.length-1];r.push({indent:2,node:e.connector({id:`${i}:line`,role:"message",geometry:{kind:"line",x1:a.x,y1:a.y,x2:d.x,y2:d.y},lineStyle:t.lineStyle,paint:f,markers:{...l?{start:l}:{},mid:[],...s?{end:s}:{}},...x})});let b=o(e8(u),c);r.push({indent:2,node:e.text({id:`${i}:label`,role:"label",text:h,block:t.labelPosition.block,x:p,y:g,fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing,anchor:"middle",paint:{fill:b.ink,...e5(b)}})})}return t.centralStart&&r.push({indent:2,node:e.shape({id:`${i}:central-start`,role:"chrome",geometry:{kind:"circle",cx:t.x1,cy:t.y,r:4},paint:{fill:"var(--bg)",stroke:d,strokeWidth:"1.5"},attributes:{className:"sequence-central-connection",data:{side:"start"}}})}),t.centralEnd&&r.push({indent:2,node:e.shape({id:`${i}:central-end`,role:"chrome",geometry:{kind:"circle",cx:t.x2,cy:t.y,r:4},paint:{fill:"var(--bg)",stroke:d,strokeWidth:"1.5"},attributes:{className:"sequence-central-connection",data:{side:"end"}}})}),e.group({id:i,role:"message",open:b,close:"</g>",children:r})}(e,t,u,t.id??`message:${n}#${i}`,F,v))}let et=new Map;for(let t of l.notes){let n=`${(t.actors??[]).join(",")}@${t.position??"over"}`,i=et.get(n)??0;et.set(n,i+1),g.push(function(e,t,n,i,o){let{x:a,y:r,width:l,height:s}=t,d=t.actors&&t.actors.length>0?` data-actors="${t.actors.map(Z).join(",")}"`:"",c=t.position?` data-position="${Z(t.position)}"`:"",h=n.nodeFillColor??"var(--bg)",p=n.nodeBorderColor??"var(--_node-stroke)",g=n.nodeTextColor??k("var(--_text-muted)",h,i),u=n.cornerRadius??0,f=t.block?.text??Y(t.text,n.nodeTextTransform);return e.group({id:o,role:"note",open:`<g class="note"${c}${d}${void 0===t.parentId?"":` data-parent-id="${Z(t.parentId)}"`}>`,close:"</g>",children:[{indent:2,node:e.shape({id:`${o}:rect`,role:"note",geometry:{kind:"rect",x:a,y:r,width:l,height:s,rx:u,ry:u},paint:{fill:h,stroke:p,strokeWidth:String(H.innerBox)}})},{indent:2,node:e.text({id:`${o}:text`,role:"label",text:f,block:t.block,x:a+l/2,y:r+s/2,fontSize:n.nodeLabelFontSize,fontWeight:n.nodeLabelFontWeight,letterSpacing:n.nodeLetterSpacing,anchor:"middle",paint:{fill:g}})}]})}(e,t,u,s,t.id??`note:${n}#${i}`))}for(let t of l.destructions)g.push(function(e,t,n){let i=n.edgeStrokeColor??"var(--_line)",o=Math.max(1.5,n.lineWidth),a=`M ${t.x-8} ${t.y-8} L ${t.x+8} ${t.y+8} M ${t.x-8} ${t.y+8} L ${t.x+8} ${t.y-8}`;return e.shape({id:`destroy:${t.actorId}`,role:"icon",geometry:{kind:"path",d:a},paint:{fill:"none",stroke:i,strokeWidth:String(o)},channels:{category:t.actorId},attributes:{className:"destroy-cross",data:{actor:t.actorId}}})}(e,t,u));for(let t of l.actors)t.external||g.push(function(e,t,n,i,o,a,r){let{id:l,x:s,y:d,width:c,height:h,label:p,type:g}=t,u=[],f=ea(o,"actor",{category:l},{includeFallback:!1}),x=f?.fontSize??n.nodeLabelFontSize,b=f?.fontWeight??n.nodeLabelFontWeight,m=f?.letterSpacing??n.nodeLetterSpacing,y=(f?.textTransform??n.nodeTextTransform,f?.lineWidth??n.nodeLineWidth),w=f?.fillColor??n.nodeFillColor??"var(--_node-fill)",v=f?.borderColor??n.nodeBorderColor??"var(--_node-stroke)",M=f?.textColor??n.nodeTextColor??"var(--_text)",I=f?.textColor??n.nodeTextColor??k("var(--_text)",w,i),S=a&&t.links?` data-links="${Z(JSON.stringify(t.links))}" role="link" tabindex="0"`:"",$=`<g class="actor" data-id="${Z(l)}" data-label="${G(p)}" data-type="${g}"${S}>`,{text:L,x:C,y:W,bounds:P}=t.labelPosition,q=r(e8(P),M);if("actor"===g){let i=h/24*.9,o=s-12*i,a=d+(h-24*i)/2,r=y/i;u.push({indent:2,node:e.pathArtwork({id:`actor:${l}:icon`,owner:{id:l,role:"actor"},channels:{category:l},open:`<g transform="translate(${o},${a}) scale(${i})">`,transform:{kind:"matrix",a:i,b:0,c:0,d:i,e:o,f:a},paint:{fill:"none",stroke:f?.borderColor??n.edgeStrokeColor??"var(--_line)",strokeWidth:String(r)},join:`
6
- `,indent:2,paths:["M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z","M15 10C15 11.6569 13.6569 13 12 13C10.3431 13 9 11.6569 9 10C9 8.34315 10.3431 7 12 7C13.6569 7 15 8.34315 15 10Z","M5.62842 18.3563C7.08963 17.0398 9.39997 16 12 16C14.6 16 16.9104 17.0398 18.3716 18.3563"]})}),u.push({indent:2,node:e.text({id:`actor:${l}:label`,role:"label",text:L,block:t.labelPosition.block,x:C,y:W,fontSize:x,fontWeight:b,letterSpacing:m,anchor:"middle",paint:{fill:q.ink,...e5(q)},channels:{category:l}})})}else if("participant"!==g){let i=s-c/2,o=d+2,a=Math.max(24,h-4),r=[],p={id:l,role:"actor"},k={fill:w,stroke:f?.borderColor??n.edgeStrokeColor??"var(--_line)",strokeWidth:String(y)},v=t=>{r.push(e.shape({id:K(`actor:${l}:icon`,"part",r.length),role:"icon",owner:p,geometry:t,paint:k}))},M=e=>v({kind:"path",d:e}),I=(e,t,n)=>v({kind:"circle",cx:e,cy:t,r:n}),S=(e,t,n,i)=>v({kind:"line",x1:e,y1:t,x2:n,y2:i}),$=(e,t,n,i,o)=>v({kind:"rect",x:e,y:t,width:n,height:i,...void 0===o?{}:{rx:o}});"database"===g?(v({kind:"ellipse",cx:s,cy:o+5,rx:c/2,ry:5}),M(`M${i} ${o+5}V${o+a-5}A${c/2} 5 0 0 0 ${i+c} ${o+a-5}V${o+5}`),v({kind:"ellipse",cx:s,cy:o+a-5,rx:c/2,ry:5})):"collections"===g?($(i+6,o,c-6,a-6),$(i,o+6,c-6,a-6)):"queue"===g?($(i,o,c,a,a/2),S(i+8,o+a/2,i+c-8,o+a/2)):"entity"===g?(I(s,o+a/2-3,Math.min(c,a)/2-3),S(i+5,o+a,i+c-5,o+a)):"boundary"===g?(I(s+3,o+a/2,Math.min(c,a)/2-3),S(i+3,o+2,i+3,o+a-2)):"control"===g?(I(s,o+a/2,Math.min(c,a)/2-3),M(`M${s-4} ${o+4}L${s+4} ${o}L${s+2} ${o+8}`)):I(s,o+a/2,Math.min(c,a)/2-3),u.push({indent:2,node:e.group({id:`actor:${l}:icon`,role:"icon",owner:p,channels:{category:l},open:`<g class="sequence-actor-glyph sequence-actor-${g}">`,close:"</g>",join:"",children:r.map(e=>({node:e,indent:0}))})}),u.push({indent:2,node:e.text({id:`actor:${l}:label`,role:"label",text:L,block:t.labelPosition.block,x:C,y:W,fontSize:x,fontWeight:b,letterSpacing:m,anchor:"middle",paint:{fill:q.ink,...e5(q)},channels:{category:l}})})}else{let i=s-c/2,o=f?.cornerRadius??n.cornerRadius??4;u.push({indent:2,node:e.shape({id:`actor:${l}:box`,role:"actor",geometry:{kind:"rect",x:i,y:d,width:c,height:h,rx:o,ry:o},paint:{fill:w,stroke:v,strokeWidth:String(y)},channels:{category:l}})}),u.push({indent:2,node:e.text({id:`actor:${l}:label`,role:"label",text:L,block:t.labelPosition.block,x:C,y:W,fontSize:x,fontWeight:b,letterSpacing:m,anchor:"middle",paint:{fill:I},channels:{category:l}})})}let F="participant"===g?I:M;return t.links&&u.push({indent:2,node:e.text({id:`actor:${l}:menu`,role:"icon",text:"⋯",block:t.menuBlock,x:s+c/2-7,y:d+10,fontSize:10,anchor:"middle",paint:{fill:F},channels:{category:l},baselineShift:0,attributes:{className:"sequence-actor-menu"}})}),e.group({id:`actor:${l}`,role:"actor",open:$,close:"</g>",children:u,channels:{category:l}})}(e,t,u,s,d.styleFace,"strict"!==c.security,F));return g.push(e.documentClose()),{family:"sequence",width:l.width,height:l.height,colors:s,transparent:p,parts:g}}function e5(e){return e.halo?{stroke:e.halo,strokeWidth:"3",strokeLinejoin:"round",paintOrder:"stroke"}:{}}function e8(e){return{x:e.x+e.width/2,y:e.y+e.height/2,width:e.width,height:e.height}}function e4(e,t){if("none"===t)return;let n="filled"===t?"seq-arrow":"cross"===t?"seq-arrow-cross":"half-top"===t?"seq-arrow-half-top":"half-bottom"===t?"seq-arrow-half-bottom":"stick-top"===t?"seq-arrow-stick-top":"stick-bottom"===t?"seq-arrow-stick-bottom":"seq-arrow-open";return e.find(e=>e.id===n)}function e6(e,t){return"rect"===e.type?e.color??t.groupFillColor??"rgba(128, 128, 128, 0.5)":t.groupFillColor}function e9(e,t,n,i,o="all"){let a=[],r=t.label?` data-label="${G(t.label)}"`:"",l="dividers"===o?`<g class="sequence-block-divider-overlay" data-owner="${Z(i)}">`:"frame"===o?`<g class="sequence-block-frame-overlay" data-owner="${Z(i)}">`:`<g class="block" data-type="${Z(t.type)}"${r}${void 0===t.parentId?"":` data-parent-id="${Z(t.parentId)}"`}>`,s=e6(t,n)??"none",d="rect"===t.type?"none":n.groupBorderColor??"var(--_node-stroke)";"dividers"!==o&&a.push({indent:2,node:e.shape({id:"frame"===o?`${i}:frame`:`${i}:rect`,role:"block",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.groupCornerRadius,ry:n.groupCornerRadius},paint:{fill:"frame"===o?"none":s,stroke:"background"===o?"none":d,strokeWidth:String(n.groupLineWidth)}})});let c=n.edgeStrokeColor??"var(--_line)",h=0;for(let r of"background"===o||"frame"===o||"par_over"===t.type?[]:t.dividers){let o=`${i}:divider#${h}`;h++;let l=Math.max(.75,.75*n.lineWidth);a.push({indent:2,node:e.connector({id:o,role:"block",geometry:{kind:"line",x1:t.x,y1:r.y,x2:t.x+t.width,y2:r.y},lineStyle:"dashed",paint:{stroke:c,strokeWidth:String(l),strokeDasharray:"6 4"}})})}return e.group({id:"dividers"===o?`${i}:divider-overlay`:"frame"===o?`${i}:frame-overlay`:i,role:"block",open:l,close:"</g>",children:a})}var e7=f(e3);function te({positioned:e,options:t}){let n=new Map(e.lifelines.map(e=>[e.actorId,e.x])),i=new Map;for(let t of e.messages)for(let e of[t.from,t.to])i.has(e)||i.set(e,t.y);let o=new Map;for(let t of e.notes)if(void 0!==t.parentId&&void 0!==t.id){let e=o.get(t.parentId)??[];e.push(t.id),o.set(t.parentId,e)}return{version:1,nodes:[...e.actors.map(e=>({id:e.id,x:s(e.external?e.x:e.bounds.x),y:s(e.external?i.get(e.id)??e.y:e.bounds.y),w:s(e.external?0:e.bounds.width),h:s(e.external?0:e.bounds.height),shape:e.external?"external-anchor":"rectangle",label:e.label,labelBounds:l(e.labelPosition.bounds),labelContainer:l(e.bounds),...e.external?{labelVisibility:"semantic"}:{},role:e.external?"mark":"box"})),...e.notes.map((e,t)=>({id:e.id??`note#${t}`,...void 0===e.parentId?{}:{parentId:e.parentId},x:s(e.x),y:s(e.y),w:s(e.width),h:s(e.height),shape:"note",label:e.text,...h(e.block,e.x+e.width/2,e.y+e.height/2,e),role:"box"}))],edges:e.messages.map((e,i)=>{var o;let a,r,h,p,g,u,f,x;return{id:e.id??`msg#${i}:${e.from}->${e.to}`,...void 0===e.parentId?{}:{parentId:e.parentId},from:e.from,to:e.to,path:e.points.map(e=>[s(e.x),s(e.y)]),label:e.label?{x:s(e.labelPosition.x),y:s(e.labelPosition.y),text:e.label,bounds:l(e.labelPosition.bounds)}:void 0,route:t.debug?(o=e.points,a=n.get(e.from),r=n.get(e.to),h=o[0],p=o[o.length-1],g=void 0!==a&&void 0!==h&&1>=Math.abs(h.x-a),u=void 0!==r&&void 0!==p&&1>=Math.abs(p.x-r),f=!e.isSelf&&o.every(t=>1>=Math.abs(t.y-e.y)),x=d(o),{family:"sequence",edgeIndex:i,routeClass:"family-layout",invariant:g&&u&&x?e.isSelf?"self-message":"lifeline-message":"unverified-family-route",bendCount:c(o),horizontal:f,sourceLifeline:g,targetLifeline:u,selfMessage:e.isSelf}):void 0}}),groups:e.blocks.map((e,t)=>({id:e.id??`block#${t}:${e.type}`,...void 0===e.parentId?{}:{parentId:e.parentId},x:s(e.bounds.x),y:s(e.bounds.y),w:s(e.bounds.width),h:s(e.bounds.height),members:void 0===e.id?[]:o.get(e.id)??[],label:e.label})),bounds:{w:s(e.width),h:s(e.height)}}}export{ep as a,ez as b,eT as c,eB as d,e_ as e,e1 as f,e3 as g,e7 as h,te as i};
1
+ import{b as e,c as t}from"./chunk-MGB5QQEH.js";import{b as n,d as i}from"./chunk-QOIFBX26.js";import{q as o,r as a,w as r}from"./chunk-5SZ2YBKG.js";import{b as l,c as s,f as d,g as c}from"./chunk-HAMXYU5V.js";import{D as h,e as p,g as g,i as u}from"./chunk-3QXHJBE3.js";import{c as f,h as x,i as b,k as m,ma as y,oa as k,r as w,s as v,y as M}from"./chunk-GK5PSUKH.js";import{b as S,i as I,j as $,k as L,m as C,q as W,u as P}from"./chunk-ILCWDEZN.js";import{a as q,b as H,c as F,d as E,g as z,h as Y,l as B,m as T,n as _,o as N}from"./chunk-3K25OV6X.js";import{Aa as O,Ba as j,C as X,Ca as A,E as D,F as R,G as U,H as Z,M as G,N as Q,O as V,Qb as J,T as K,Vb as ee,_ as et,ka as en,ma as ei,na as eo,o as ea,wa as er,x as el,y as es}from"./chunk-SZAI2WB4.js";import{e as ed}from"./chunk-PJJSDGLB.js";import{a as ec}from"./chunk-YHMTSXIR.js";var eh=/&amp;(#\d+|#[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z\d]{0,31});|&(#\d+|#[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z\d]{0,31});/g;function ep(e,t){let i=e.originalText;if(!i.includes("&"))return e;let o=i.includes("&")?i.replace(eh,(e,t,i)=>{if(void 0!==t)return t.startsWith("#")||b.has(t)||n(t)?`#38;${t.replace("#","#35;")}#59;`:`&${t};`;if(!i.startsWith("#")&&!b.has(i))return n(i)?`#${i};`:e;let o=ec(e);return"#"===o?"#35;":";"===o?"#59;":o}):i;return o===("decoded"===t?ec(i):i)?e:r(o)}var eg={subject:"Sequence text entity",example:"A->>B: #35;"},eu=RegExp(`#\\w+;|${x.source}`,"g");function ef(e){let t=e.trim(),n=/^:?(wrap|nowrap):/.exec(t);return n?{text:t.slice(n[0].length).trim(),wrap:"wrap"===n[1]}:{text:t}}function ex(e){let t=function(e){let t=i(e,eg);if(t===e)return{value:t};let n=D(U(Z(e)),eu,e=>i(e,eg));return{value:t,content:Object.freeze({value:t,authored:e,prepared:n})}}(e),n=i(Z(e),eg);return{label:n,...t.content?{labelContent:Object.freeze({...t.content,value:n})}:{}}}var eb=/^(loop|alt|opt|par_over|par|critical|break|rect|box)\b\s*([\s\S]*)$/i,em=/^(else|and|option)\b\s*([\s\S]*)$/i;function ey(e){let t=e.toLowerCase();return"transparent"===t||t in en||!!/^(?:#|(?:rgb|rgba|hsl|hsla)\()/i.test(e)&&null!==O(e)}function ek(e){let t=en[e.toLowerCase()];if(t)return t;let n=ei(e);if(n)return eo(n[0],n[1],n[2]);let i=e.match(/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})/i);return i?eo(Math.min(255,Number.parseInt(i[1],10)),Math.min(255,Number.parseInt(i[2],10)),Math.min(255,Number.parseInt(i[3],10))):null}var ew=class{constructor(e={}){this.options=e}options;records=new Map;order=[];boxes=[];currentBox;apply(e){if("links"===e.kind){let t=this.records.get(e.id);t&&(t.links={...t.links,...e.links});return}this.addActor(e.id,"declare"===e.kind?e:void 0)}applyAll(e){for(let t of e)this.apply(t)}openBox(e){this.boxes.push(e),this.currentBox=this.boxes.length-1}closeBox(){this.currentBox=void 0}has(e){return this.records.has(e)}indexOf(e){return this.order.indexOf(e)}list(){return this.order.map(e=>this.records.get(e))}addActor(e,t){let n=this.records.get(e),i=this.currentBox;if(n&&(void 0!==i&&void 0!==n.box&&i!==n.box&&this.options.onBoxConflict?.(e),void 0!==(i=n.box??i)&&(n.box=i),t?.label===void 0||t.create))return;let o={id:e,label:t?.label??e,...t?.wrap===void 0?{}:{wrap:t.wrap},type:t?.type??"participant",...t?{keyword:t.keyword}:{},...n?.links&&!this.options.upstreamLinks?{links:n.links}:{},...void 0!==i?{box:i}:{}};this.records.set(e,o),n||this.order.push(e),void 0!==this.currentBox&&i===this.currentBox&&this.boxes[this.currentBox].actorIds.push(e)}},ev=new Map([["<<--\x3e>",["filled","filled"]],["<<->>",["filled","filled"]],["--\x3e>",["none","filled"]],["->>",["none","filled"]],["--\x3e",["none","none"]],["->",["none","none"]],["--x",["none","cross"]],["-x",["none","cross"]],["--)",["none","open"]],["-)",["none","open"]],["--|\\",["none","half-top"]],["-|\\",["none","half-top"]],["--|/",["none","half-bottom"]],["-|/",["none","half-bottom"]],["--\\\\",["none","stick-top"]],["-\\\\",["none","stick-top"]],["--//",["none","stick-bottom"]],["-//",["none","stick-bottom"]],["/|--",["half-bottom","none"]],["/|-",["half-bottom","none"]],["\\|--",["half-top","none"]],["\\|-",["half-top","none"]],["//--",["stick-bottom","none"]],["//-",["stick-bottom","none"]],["\\\\--",["stick-top","none"]],["\\\\-",["stick-top","none"]],["--|",["none","stick-top"]],["-|",["none","stick-top"]],["--/",["none","stick-bottom"]],["-/",["none","stick-bottom"]],["--\\",["none","stick-top"]],["-\\",["none","stick-top"]],["|--",["stick-top","none"]],["|-",["stick-top","none"]],["/--",["stick-bottom","none"]],["/-",["stick-bottom","none"]],["\\--",["stick-top","none"]],["\\-",["stick-top","none"]]]),eM=new Set(["--|","-|","--/","-/","--\\","-\\","|--","|-","/--","/-","\\--","\\-"]),eS=new Map([...eM].map(e=>{let[t,n]=ev.get(e),i=[...ev].find(([i,o])=>!eM.has(i)&&o[0]===t&&o[1]===n&&i.includes("--")===e.includes("--"))[0];return[e,i]})),eI=[...ev.keys()].sort((e,t)=>t.length-e.length),e$=eI.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),eL=new RegExp(String.raw`^(\S+?)(\(\))?\s*(${e$})`),eC=new RegExp(String.raw`^(\S+?)\s+(\(\))\s*(${e$})`),eW=new Set(["participant","actor","note","alt","else","loop","rect","opt","par","and","end","activate","deactivate","autonumber","box","create","destroy","link","links","critical","break","option","title","over","off","properties","details","sequencediagram","par_over"]),eP=new Set([...eW,"acctitle","accdescr"]),eq=/(?:#\w+;|[^\/\\\+\()\+<\->\->:\n,;])+((?!(\-x|\-\-x|\-\)|\-\-\)|\-\|\\|\-\\|\-\/|\-\/\/|\-\|\/|\/\|\-|\\\|\-|\/\/\-|\\\\\-|\/\|\-|\-\-\|\\|\-\-|\(\)))[\-]*(?:#\w+;|[^\+<\->\->:\n,;])+)*/iy;function eH(e,t){return eq.lastIndex=t,eq.exec(e)?.[0].trim()??""}function eF(e,t){if(!e||e.trim()!==e||/[\r\n]/.test(e))return!1;let n=m(e);if(n.startsWith("#"))return!1;if("declaration"===t)return eO(e)&&!/:/.test(n)&&!n.includes("%%{");if(n.startsWith("%")||n.includes("%%"))return!1;let i=n.toLowerCase(),o=/^(\w+)\b/.exec(i)?.[1];return!(o&&eW.has(o)&&(!["title","link","links","properties","details"].includes(o)||/\s/.test(i.slice(o.length,o.length+1)))||/^(?:\d+(?:\.\d{1,2})?|\.\d{1,2})(?=\s)/.test(n)||eW.has(i)&&!["title","link","links","properties","details"].includes(i)||"receiver"===t&&["acctitle","accdescr"].includes(i)||/^(?:left|right) of\b/.test(i))&&eH(`${n}${"sender"===t?"->>Z:":":"}`,0)===n}var eE=new WeakMap,ez=new WeakMap;function eY(e,t){eE.set(e,t)}function eB(e,t){ez.set(e,t)}function eT(n,i={}){let r=a(n),l=M(r.map(e=>e.raw)),s=l.familyLines.flatMap((e,t)=>e.trim()?[{text:e.trim(),origin:r[l.familyOrigins[t]].line}]:[]);n=s.map(e=>e.text);let d=e=>{let t=s[e]?.origin??e;return i.authoredLine?.(t)??t+1};p("sequence")&&void 0!==n[0]&&g("sequence","header",n[0],{line:1,unit:"normalized"});let c={actors:[],messages:[],blocks:[],notes:[],activationEvents:[],boxes:[],...void 0!==l.accessibility.title?{accessibilityTitle:Z(l.accessibility.title)}:{},...void 0!==l.accessibility.descr?{accessibilityDescription:Z(l.accessibility.descr)}:{}},h=new ew,f=new Map,x=new Map,b=function(n){let i=a(n).map(n=>{if(!n.raw.trim()||o(n.raw))return{...n,syntax:null};try{return{...n,syntax:function(n){let i=function(n){let i=n.match(/^(participant|actor)\s+([^\s@]+)\s*@\{/i);if(i){let o=i[1].toLowerCase(),a=i[2];eA(a);let r=e(n,i[0].length-1,"sequence"),l=r.ok?n.slice(r.end+1):"",s=l.match(/^\s+as(?:\s+(.*))?$/i);if(!r.ok||""!==l.trim()&&!s)throw v({what:`Invalid participant metadata in "${n}": ${r.ok?`unexpected "${l.trim()}" after it`:r.message}`,expectedForm:'a YAML mapping in @{…} with no "}" inside, then optionally `as <label>`',example:'participant DB@{ "type": "database", "alias": "Orders" }'});let d=s?ef(s[1]??""):void 0,c=d?d.text||null:void 0;if(null===c)return null;let{entries:h}=r,p=h.get("type"),g="string"==typeof p?p.toLowerCase():o;if(!eN.has(g))throw Error(`Unknown sequence actor type '${g}'`);let u=t(h.get("alias")),f=void 0!==u&&(void 0===c||c===a)?u:c,x=[...h.keys()].filter(e=>"type"!==e&&"alias"!==e);return{id:a,label:f??a,type:g,keyword:o,aliased:void 0!==f,...d?.wrap===void 0?{}:{wrap:d.wrap},...x.length?{unmodeledMetadata:x}:{}}}if(n.includes("@{"))return null;let o=n.match(/^(participant|actor)\s+/i);if(!o)return null;let a=n.slice(o[0].length),r=a.match(/^(\S+?)\s+as(\s*)(.+)$/i);if(!r&&(!a||/\s/.test(a)&&/[<>:\n,;@]/.test(m(a))))return null;let l=r?r[1]:a.trim();eA(l);let s=o[1].toLowerCase(),d=r?.[3]===void 0?void 0:ef(r[3]);return{id:l,label:d?.text??l,type:s,keyword:s,aliased:!!r,...r?.[2]===""?{unspacedAlias:!0}:{},...d?.wrap===void 0?{}:{wrap:d.wrap}}}(n);if(i)return{kind:"declaration",declaration:i};let o=function(e){let t=e.match(/^link\s+(\S+)\s*:\s*(.+?)\s*@\s*(\S+)$/i);if(t)return/^(?:https?:|mailto:)/i.test(t[3])?{actorId:t[1],links:{[t[2].trim()]:t[3]}}:null;let n=e.match(/^links\s+(\S+)\s*:\s*(\{.*\})$/i);if(!n)return null;try{let e=JSON.parse(n[2]),t={};for(let[n,i]of Object.entries(e))"string"==typeof i&&/^(?:https?:|mailto:)/i.test(i)&&(t[n]=i);return Object.keys(t).length>0?{actorId:n[1],links:t}:null}catch{return null}}(n);if(o)return{kind:"links",...o};let a=n.match(/^(?:properties|details)\s+(\S+)\s*:/i);if(a)return{kind:"actor-data",actorId:a[1]};let r=n.match(/^title(?:\s*:\s*|\s+)(.+)$/i);if(r)return{kind:"title",text:r[1].trim()};let l=n.match(/^autonumber(?:\s+(.*))?$/i);if(l){let e=l[1]?.trim()??"";if(/^off$/i.test(e))return{kind:"autonumber",numbering:null};let t=e.match(/^((?:\d+(?:\.\d{1,2})?|\.\d{1,2}))(?:\s+((?:\d+(?:\.\d{1,2})?|\.\d{1,2})))?$/);return(!e||t)&&(!t||Number.isFinite(Number(t[1]))&&(void 0===t[2]||Number.isFinite(Number(t[2]))))?{kind:"autonumber",numbering:t?{next:Number.parseFloat(t[1]),...void 0===t[2]?{}:{step:Number.parseFloat(t[2])}}:{}}:null}let s=n.match(/^box(?:\s+(.*))?$/i);if(s)return{kind:"box",text:s[1]?.trim()??""};let d=function(e){let t=e.match(/^create\s+(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/i);if(!t)return null;let n=t[2];eA(n);let i=void 0===t[3]?void 0:ef(t[3]);return{id:n,label:i?.text??n,type:t[1].toLowerCase(),...i?.wrap===void 0?{}:{wrap:i.wrap}}}(n);if(d)return{kind:"create",declaration:d};let c=n.match(/^destroy\s+(\S+)$/i);if(c)return{kind:"destroy",actorId:c[1]};let h=function(e){let t=e.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.*)$/i);if(!t)return null;let n=t[1].toLowerCase();return{actorIds:t[2].trim().split(",").map(e=>e.trim()),...ef(t[3]),position:"left of"===n?"left":"right of"===n?"right":"over"}}(n);if(h)return{kind:"note",note:h};let p=function(e){let t=eb.exec(e);if(!t)return null;let n=t[1].toLowerCase(),i=t[2]?.trim()??"";if("box"===n)return{type:n,label:i};let o=ef(i);return{type:n,label:o.text,...void 0===o.wrap?{}:{wrap:o.wrap}}}(n);if(p&&"box"!==p.type)return{kind:"block",opener:{type:p.type,label:p.label,...void 0===p.wrap?{}:{wrap:p.wrap}}};let g=function(e){let t=em.exec(e);if(!t)return null;let n=ef(t[2]??"");return{type:t[1].toLowerCase(),label:n.text,...void 0===n.wrap?{}:{wrap:n.wrap}}}(n);if(g)return{kind:"continuation",continuation:g};if("end"===n)return{kind:"end"};let u=function(e){var t;let n=function(e){eq.lastIndex=0;let t=eq.exec(e);if(!t)return;let n=t[0].length,i=e.startsWith("()",n),o=i&&/\s$/.test(t[0]);for(i&&(n+=2);n<e.length&&/\s/.test(e[n]);)n++;let a=eI.find(t=>e.startsWith(t,n));if(a)return n+=a.length,{from:t[0].trim(),arrow:a,end:n,centralStart:i,spacedCentral:o}}(e);if(!n){let t=e.match(eL),i=t??e.match(eC);i&&(n={from:i[1],centralStart:!!i[2],arrow:i[3],end:i[0].length,spacedCentral:!t})}if(!n||(t=n.arrow,!ev.has(t)))return null;let{from:i,arrow:o,centralStart:a,spacedCentral:r}=n;if(r&&(/^(?:[0-9]+(?:\.[0-9]{1,2})?|\.[0-9]{1,2})$/.test(i)||eW.has(i.toLowerCase())))return null;let l=e.slice(n.end).trimStart(),s=l.startsWith("()");s&&(l=l.slice(2).trimStart());let d="+"===l[0]||"-"===l[0]?l[0]:void 0;if(r&&d)return null;d&&(l=l.slice(1).trimStart());let c=l.indexOf(":");if(c<1)return null;let h=l.slice(0,c).trimEnd(),{text:p,wrap:g}=ef(l.slice(c+1));if(!h||r&&(/[+<>]/.test(h)||h.includes("()")||eP.has(h.toLowerCase())))return null;let u=m(e),f=m(i),x=m(h),b=m(e.slice(0,e.length-l.length)).length,y=eH(u,0);return y.length<=f.length&&(y!==f||eH(u,b)!==x)?null:{from:i,arrow:eS.get(o)??o,activationMark:d,to:h,label:p,centralStart:a,centralEnd:s,...void 0===g?{}:{wrap:g},...eM.has(o)?{localArrow:o}:{}}}(n);if(u)return{kind:"message",message:u};let f=n.match(/^(activate|deactivate)\s+(\S+)$/i);return f?{kind:"activation",actorId:f[2],activate:"activate"===f[1].toLowerCase()}:null}(n.raw.trim())}}catch(e){if(e instanceof J)throw e;return{...n,syntax:null,error:e}}}),r=[],l=[],s=(e,t,n)=>{l.push({line:e.line,syntax:t,message:n})};for(let[e,t]of i.entries()){let{syntax:n}=t;if(r.length&&(t.parent=r.at(-1)),!n){t.error instanceof eX?s(t,"sequence_participant_id",t.error.message):t.raw.trim()&&!o(t.raw)&&s(t,"sequence_statement",`Sequence statement is preserved in source but not drawn: ${t.raw.trim()}`);continue}if("block"===n.kind||"box"===n.kind)r.push(e);else if("end"===n.kind){let n=r.pop();void 0===n?s(t,"sequence_block_boundary","Sequence end has no open block or box"):(t.closes=n,i[n].endIndex=e)}else if("continuation"===n.kind){var d,c;let e=void 0!==t.parent?i[t.parent].syntax:null;e?.kind==="block"&&(d=n.continuation.type,c=e.opener.type,"else"===d&&"alt"===c||"and"===d&&("par"===c||"par_over"===c)||"option"===d&&"critical"===c)||s(t,"sequence_block_boundary",`Sequence ${n.continuation.type} does not belong to the enclosing block`)}else if("declaration"===n.kind&&n.declaration.unmodeledMetadata?.length)s(t,"sequence_participant_metadata",`Participant metadata fields ${n.declaration.unmodeledMetadata.join(", ")} are not modeled; the declaration is preserved as source`);else if("message"===n.kind&&n.message.localArrow){let{localArrow:e,arrow:i}=n.message;s(t,"sequence_local_arrow",`The arrow ${e} is a local spelling pinned Mermaid does not read, so it rejects this line. Ours draws it as Mermaid's ${i} and writes ${i}`)}else"declaration"===n.kind&&n.declaration.unspacedAlias&&s(t,"sequence_unspaced_alias","Participant text immediately following as is read as its alias. Pinned Mermaid can reject this or read it as part of the ID; write as <label> with a separating space");if("declaration"===n.kind||"create"===n.kind){let e=ej(n.declaration.id);e&&s(t,"sequence_participant_id_extension",e)}if("message"===n.kind)for(let[e,i]of[["sender",n.message.from],["receiver",n.message.to]])eF(i,e)||s(t,"sequence_message_id_extension",`Participant "${i}" is read as the ${e}, but pinned Mermaid reads another token there; rename it before typed editing`)}for(let e of r)s(i[e],"sequence_block_boundary","Sequence block or box is never closed by end");return{statements:i,issues:l}}(n.slice(1)),y=b.issues.find(e=>"sequence_block_boundary"===e.syntax);if(y)throw Error(`SEQUENCE_BLOCK_BOUNDARY: line ${d(y.line+1)}: ${y.message}`);let k=new Map,w=[],I=new Map,$={visible:!0===i.showSequenceNumbers,next:1,step:1},L=[],C=[],W=e=>{let{from:t,to:n}=e,o=function(e){let t=e.includes("--")?"dashed":"solid",[n,i]=ev.get(e)??["none","none"];return{lineStyle:t,startHead:n,endHead:i}}(e.arrow),a={from:t,to:n,...ex(e.label.trim()),...(e.wrap??i.wrap)===void 0?{}:{wrap:e.wrap??i.wrap},lineStyle:o.lineStyle,startHead:o.startHead,endHead:o.endHead,centralStart:e.centralStart,centralEnd:e.centralEnd};"+"===e.activationMark&&(a.activate=!0),"-"===e.activationMark&&(a.deactivate=!0),$.visible&&(a.number=$.next),$.next=Math.round(($.next+$.step)*100)/100,eD(L,e=>e===n,e=>{f.set(e,c.messages.length),p("sequence")&&u("sequence","bind-create",{id:e,messageIndex:c.messages.length})}),eD(C,e=>e===t||e===n,e=>{x.set(e,c.messages.length),p("sequence")&&u("sequence","bind-destroy",{id:e,messageIndex:c.messages.length})}),c.messages.push(a),p("sequence")&&u("sequence","add-message",a)};for(let[e,t]of b.statements.entries()){let n=t.raw.trim();if(p("sequence")&&g("sequence",t.syntax?.kind??"unrecognized",t.raw,{line:t.line+2,column:t.column+1,unit:"normalized"}),t.error)throw t.error;let a=t.syntax;if(!a){if(void 0!==l.unclosedIndex&&n===l.familyLines[l.unclosedIndex]?.trim())continue;if(n&&!o(n))throw Error(`SEQUENCE_UNSUPPORTED_STATEMENT: line ${d(t.line+1)}: ${n}`);continue}for(let e of function(e){switch(e?.kind){case"declaration":{let{id:t,label:n,type:i,keyword:o,aliased:a,wrap:r}=e.declaration;return[{kind:"declare",id:t,keyword:o,type:i,...a?{label:n}:{},...void 0===r?{}:{wrap:r}}]}case"create":{let{id:t,label:n,type:i,wrap:o}=e.declaration;return[{kind:"declare",id:t,keyword:"actor"===i?"actor":"participant",type:i,label:n,...void 0===o?{}:{wrap:o},create:!0}]}case"links":return[{kind:"mention",id:e.actorId},{kind:"links",id:e.actorId,links:e.links}];case"actor-data":return[{kind:"mention",id:e.actorId}];case"note":return e.note.actorIds.map(e=>({kind:"mention",id:e}));case"message":return[{kind:"mention",id:e.message.from},{kind:"mention",id:e.message.to}];default:return[]}}(a))h.apply(e),p("sequence")&&u("sequence","participant.apply",e);switch(a.kind){case"declaration":case"create":"create"===a.kind&&L.push(a.declaration.id);break;case"links":case"actor-data":break;case"title":{let e=ex(a.text);c.title=e.label,c.titleContent=e.labelContent,p("sequence")&&u("sequence","set-title",c.title);break}case"autonumber":$.visible=null!==a.numbering,a.numbering?.next!==void 0&&($.next=a.numbering.next,$.step=a.numbering.step??1),p("sequence")&&u("sequence","set-autonumber",$);break;case"box":{let e=a.text,t={actorIds:[]},n=e.match(/^((?:rgb|rgba|hsl|hsla)\([^)]*\))\s*(.*)$/i),o=e;if(n&&ey(n[1]))t.color=n[1],o=n[2]?.trim()??"";else{let n=e.split(/\s+/,1)[0]??"";n&&ey(n)&&(t.color=n,o=e.slice(n.length).trim())}if(o){let e=ef(o);Object.assign(t,ex(e.text)),(e.wrap??i.wrap)!==void 0&&(t.wrap=e.wrap??i.wrap)}c.boxes.push(t),h.openBox(t),p("sequence")&&u("sequence","open-box",{index:c.boxes.length-1,box:t});break}case"destroy":C.push(a.actorId),p("sequence")&&u("sequence","pending-destroy",a.actorId);break;case"note":{let{note:e}=a,n=ex(e.text),o=c.notes.length;c.notes.push({actorIds:e.actorIds,text:n.label,...(e.wrap??i.wrap)===void 0?{}:{wrap:e.wrap??i.wrap},...n.labelContent?{textContent:n.labelContent}:{},position:e.position,afterIndex:c.messages.length-1}),p("sequence")&&u("sequence","add-note",{note:c.notes.at(-1),parent:t.parent});for(let e=t.parent;void 0!==e;e=k.get(e)?.parent)k.get(e)?.noteIndices.push(o);break}case"block":{let{opener:n}=a,o=n.type,r=ex("rect"===n.type?"":n.label),l="rect"===n.type&&n.label.startsWith("#")?"":n.label,s="rect"===n.type?function(e){let t=S(e);if(!t)return;let n=t.toLowerCase();if("transparent"===n||Object.hasOwn(en,n))return t;let i=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i.exec(t);if(i&&i.slice(1).every(e=>255>=Number(e)))return t;let o=/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0(?:\.\d+)?|\.\d+|1(?:\.0+)?)\s*\)$/i.exec(t);if(o&&o.slice(1,4).every(e=>255>=Number(e)))return t}(l):void 0;if("rect"===n.type&&l&&!s)throw Error("SEQUENCE_RECT_COLOR_UNSUPPORTED: rect requires a safe concrete CSS color");k.set(e,{type:o,...r,...(n.wrap??i.wrap)===void 0?{}:{wrap:n.wrap??i.wrap},...s?{color:s}:{},startIndex:c.messages.length,dividers:[],dividerNoteIndices:[],parent:t.parent,parentSection:void 0===t.parent?0:k.get(t.parent)?.dividers.length??0,noteIndices:[],childBlockIndices:[],childSectionIndices:[]}),w.push({kind:"open",blockId:e,messageIndex:c.messages.length,noteIndex:c.notes.length}),p("sequence")&&u("sequence","open-block",{id:e,block:k.get(e)});break}case"continuation":{let e=void 0!==t.parent?k.get(t.parent):void 0;e&&(w.push({kind:"divider",blockId:t.parent,messageIndex:c.messages.length,noteIndex:c.notes.length,dividerIndex:e.dividers.length}),e.dividerNoteIndices.push(c.notes.length),e.dividers.push({index:c.messages.length,...ex(a.continuation.label),...(a.continuation.wrap??i.wrap)===void 0?{}:{wrap:a.continuation.wrap??i.wrap}}),p("sequence")&&u("sequence","divide-block",{parent:t.parent,divider:e.dividers.at(-1),type:a.continuation.type}));break}case"end":{let e=k.get(t.closes);if(e){let n=c.blocks.length;I.set(t.closes,n),w.push({kind:"close",blockId:t.closes,messageIndex:c.messages.length,noteIndex:c.notes.length});let i={type:e.type,label:e.label,...void 0===e.wrap?{}:{wrap:e.wrap},...e.labelContent?{labelContent:e.labelContent}:{},...e.color?{color:e.color}:{},startIndex:e.startIndex,endIndex:Math.max(c.messages.length-1,e.startIndex),dividers:e.dividers};eE.set(i,{endMessageExclusive:c.messages.length,endNoteExclusive:c.notes.length,dividerNoteIndices:e.dividerNoteIndices,noteIndices:e.noteIndices,childBlockIndices:e.childBlockIndices,childSectionIndices:e.childSectionIndices}),void 0!==e.parent&&(k.get(e.parent)?.childBlockIndices.push(n),k.get(e.parent)?.childSectionIndices.push(e.parentSection)),c.blocks.push(i),p("sequence")&&u("sequence","close-block",{id:t.closes,parent:e.parent,parentSection:e.parentSection,block:i,notes:e.noteIndices,children:e.childBlockIndices})}else h.closeBox(),p("sequence")&&u("sequence","close-box",null);break}case"message":W(a.message);break;case"activation":c.activationEvents.push({actorId:a.actorId,kind:a.activate?"activate":"deactivate",messageIndex:c.messages.length}),p("sequence")&&u("sequence","activation",c.activationEvents.at(-1))}}return c.actors=h.list().map(({id:e,label:t,type:n,links:o,box:a,wrap:r})=>({id:e,...ex(t),type:n,...(r??i.wrap)===void 0?{}:{wrap:r??i.wrap},...o?{links:o}:{},...void 0!==a?{box:a}:{},...f.has(e)?{createMessageIndex:f.get(e)}:{},...x.has(e)?{destroyMessageIndex:x.get(e)}:{}})),ez.set(c,w.map(({blockId:e,...t})=>({...t,blockIndex:I.get(e)}))),c}function e_(e){let t;return n=>{if(!t){let n=e.originalText.split(/\r?\n/),i=e.wrapperSource?e.wrapperSource.split(/\r?\n/).length-1:0,o=n.slice(i).flatMap((e,t)=>(0===t?ed(e).split(`
2
+ `):[e]).map(e=>({text:e.trim(),line:i+t+1}))),a=0;t=e.familyLines.map(e=>{let t=e.trim();for(let e=a;e<o.length;e++){let n=o[e].text;if(n===t||n.slice(n.indexOf("}")+1).trim()===t)return a=e+1,o[e].line}})}return t[n]}}var eN=new Set(["participant","actor","boundary","control","entity","database","collections","queue"]);function eO(e){return"string"==typeof e&&""!==e&&e.trim()===e&&!/[<>,;@#\r\n]/.test(m(e))}function ej(e){let t=eO(e);return t&&eF(e,"declaration")?null:`Sequence participant ID ${JSON.stringify(e)} ${t?"is read as authored, but pinned Mermaid rejects colons in declaration IDs":"has ambiguous declaration delimiters or whitespace"}. Typed editing and serialization require a portable ID; rename this ID and its references, and put display punctuation in an alias`}var eX=class extends w{};function eA(e){if(!eO(e))throw new eX(ej(e))}function eD(e,t,n){for(let i=e.length-1;i>=0;i--){let o=e[i];t(o)&&(n(o),e.splice(i,1))}}function eR(e,t,n,i,o,a,r=0,l=et(e,{fontSize:o,fontWeight:a,letterSpacing:r})){let s="middle"===i?t-l.width/2:"start"===i?t:t-l.width;return{text:l.text,block:l,x:t,y:n,anchor:i,fontSize:o,fontWeight:a,letterSpacing:r,bounds:{x:s,y:n-l.height/2,width:l.width,height:l.height},metrics:l}}function eU(e,t){let n=Math.min(e.x,t.x),i=Math.min(e.y,t.y);return{x:n,y:i,width:Math.max(e.x+e.width,t.x+t.width)-n,height:Math.max(e.y+e.height,t.y+t.height)-i}}function eZ(e,t,n){return{x:e.x+t,y:e.y+n,width:e.width,height:e.height}}function eG(e,t,n){return{...e,x:e.x+t,y:e.y+n,bounds:eZ(e.bounds,t,n)}}function eQ(e,t,n,i){if("participant"===e.type){let o=eR(t.displayLabel,n,i+t.height/2,"middle",t.fontSize,t.fontWeight,t.letterSpacing,t.block),a={x:n-t.width/2,y:i,width:t.width,height:t.height};return{id:e.id,label:e.label,type:e.type,...e.links?{links:{...e.links}}:{},...t.menuBlock?{menuBlock:t.menuBlock}:{},x:n,y:i,width:t.width,height:t.height,bounds:a,labelPosition:o}}let o="actor"===e.type?i+t.height:Math.max(i+t.height,i+26),a=o+Math.max(14,t.labelMetrics.lineHeight/2+5.5)+(t.labelMetrics.lines.length-1)/2*t.labelMetrics.lineHeight,r=eR(t.displayLabel,n,a,"middle",t.fontSize,t.fontWeight,t.letterSpacing,t.block),l=eU({x:n-t.width/2,y:i,width:t.width,height:o-i},r.bounds),s={x:l.x,y:l.y,width:l.width,height:l.height+4};return{id:e.id,label:e.label,type:e.type,...e.links?{links:{...e.links}}:{},...t.menuBlock?{menuBlock:t.menuBlock}:{},x:n,y:i,width:t.width,height:t.height,bounds:s,labelPosition:r}}function eV(e,t,n,i){let o=t.dividerNoteIndices[i]??-1,a=t.dividerNoteIndices[i+1]??t.endNoteExclusive;return o>=0&&o<a&&n.notes[o].afterIndex<e.dividers[i].index?o:void 0}function eJ(e,t,n,i,o,a,r,l,s,d,c,h,p){let g,u,f=e.startIndex<n.endMessageExclusive?r[e.startIndex]:void 0,x=e.startIndex<n.endMessageExclusive?r[n.endMessageExclusive-1]:void 0,b=new Set;for(let t=e.startIndex;t<n.endMessageExclusive;t++){let e=i.messages[t];e&&(b.add(o.get(e.from)??0),b.add(o.get(e.to)??0))}for(let e of n.noteIndices){let t=i.notes[e];if(t)for(let e of t.actorIds){let t=o.get(e);void 0!==t&&b.add(t)}}if(0===b.size)for(let e=0;e<i.actors.length;e++)b.add(e);let m=1/0,y=-1/0;for(let e of b){let t=a[e];if(!t)continue;let n=t.bounds;m=Math.min(m,n.x-d.groupPaddingX),y=Math.max(y,n.x+n.width+d.groupPaddingX)}for(let t=e.startIndex;t<n.endMessageExclusive;t++){let e=r[t];e&&(m=Math.min(m,e.bounds.x-d.groupPaddingX),y=Math.max(y,e.bounds.x+e.bounds.width+d.groupPaddingX))}for(let e of n.noteIndices){let t=l[e];t&&(m=Math.min(m,t.x-d.groupPaddingX),y=Math.max(y,t.x+t.width+d.groupPaddingX))}for(let e of n.childBlockIndices){let t=s[e];t&&(m=Math.min(m,t.x-d.groupPaddingX),y=Math.max(y,t.x+t.width+d.groupPaddingX))}for(let n of("rect"!==e.type&&(y=Math.max(y,m+t.tabWidth+d.groupPaddingX)),t.dividers))n.label&&(y=Math.max(y,m+8+n.metrics.width+d.groupPaddingX));let k=f&&!f.isSelf&&f.labelPosition.text.includes(`
3
+ `)?Math.ceil(Math.max(0,f.labelPosition.y-f.labelPosition.bounds.y-d.edgeLabelFontSize*el/2-1e-6)):0,w=n.noteIndices.length>0?t.contentTopPadding:t.blockPadTop,v=p?.top??(f?f.y-(t.blockPadTop+k):h-w),M=(x?.y??h)+d.groupPaddingY+12;for(let i=e.startIndex;i<n.endMessageExclusive;i++){let e=r[i];if(!e)continue;v=Math.min(v,e.bounds.y-Math.max(t.tabHeight,d.groupPaddingY));let n=e.isSelf?d.groupPaddingY+4:d.groupPaddingY;M=Math.max(M,e.bounds.y+e.bounds.height+n)}for(let o of b){let l=i.actors[o],s=a[o];if(!(!s||l?.createMessageIndex===void 0||!r[l.createMessageIndex])&&l.createMessageIndex>=e.startIndex&&l.createMessageIndex<n.endMessageExclusive){let e=t.contentTopPadding;v=Math.min(v,s.bounds.y-e),M=Math.max(M,s.bounds.y+s.bounds.height+d.groupPaddingY)}}for(let e of n.noteIndices){let n=l[e];if(!n)continue;let i=t.contentTopPadding;v=Math.min(v,n.y-i),M=Math.max(M,n.y+n.height+d.groupPaddingY)}for(let e of n.childBlockIndices){let n=s[e];n&&(v=Math.min(v,n.y-t.enclosingHeaderStep),M=Math.max(M,n.y+n.height+d.groupPaddingY))}let S=t.dividers.map((o,a)=>{let g=eV(e,n,i,a),u=void 0===g?void 0:l[g],f=o.index<n.endMessageExclusive?r[o.index]:void 0;if("par_over"===e.type){if(!o.label)return{y:v+t.tabHeight,label:""};let e=u??f?.bounds;for(let[t,r]of n.childBlockIndices.entries()){let l=s[r];l&&n.childSectionIndices[t]===a+1&&i.blocks[r].startIndex===o.index&&(!e||l.y<e.y)&&(e=l)}let r=e?.x??m+8,l=e?e.y-o.metrics.height-8:v+t.tabHeight+8+a*(o.metrics.height+8),c=eR(o.displayLabel,r,l+o.metrics.height/2,"start",d.edgeLabelFontSize,d.edgeLabelFontWeight,d.edgeLetterSpacing,o.block);return y=Math.max(y,c.bounds.x+c.bounds.width+d.groupPaddingX),M=Math.max(M,c.bounds.y+c.bounds.height+d.groupPaddingY),{y:l,label:o.label,labelPosition:c}}let x=f?.y??h,b=28+o.extraLinesHeight+o.extraFontOffset;if(o.label&&f?.label){let e=m+8,t=e+o.metrics.width,n=f.labelPosition.bounds,i=n.x,a=n.x+n.width;if(t+8>i&&e-8<a){let e=Math.max(0,Math.ceil(x-10-(n.y+n.height/2)));b=Math.max(36+o.extraLinesHeight+o.extraFontOffset+e,Math.ceil(24+c+o.extraLinesHeight+o.extraFontOffset+e))}}let k=p?.dividerY[a],w=k??(u?u.y-o.noteContentOffset:x-b);for(let[e,t]of n.childBlockIndices.entries()){let r=s[t],l=i.blocks[t];if(void 0===k&&r&&l?.startIndex===o.index&&n.childSectionIndices[e]===a+1){let e=o.noteContentOffset;w=Math.min(w,r.y-e)}}if(!o.label)return{y:w,label:o.label};let S=w+o.firstLineOffset+(o.metrics.lines.length-1)/2*o.metrics.lineHeight,I=eR(o.displayLabel,m+8,S,"start",d.edgeLabelFontSize,d.edgeLabelFontWeight,d.edgeLetterSpacing,o.block);return M=Math.max(M,I.bounds.y+I.bounds.height+d.groupPaddingY),{y:w,label:o.label,labelPosition:{...I,text:o.displayLabel}}}),I="rect"===e.type?void 0:(g=v+t.tabHeight/2,u=eR(t.headerText,m+d.groupLabelPaddingX,g,"start",d.groupHeaderFontSize,d.groupHeaderFontWeight,d.groupLetterSpacing,t.block),{x:m,y:v,width:t.tabWidth,height:t.tabHeight,label:{...u,text:t.headerText}}),$={x:m,y:v,width:y-m,height:M-v};return{type:e.type,label:e.label,...e.color?{color:e.color}:{},x:$.x,y:$.y,width:$.width,height:$.height,dividers:S,...I?{header:I}:{},bounds:$}}function eK(e,t,n){for(let i of e.actors)i.x+=t,i.y+=n,i.bounds=eZ(i.bounds,t,n),i.labelPosition=eG(i.labelPosition,t,n);for(let i of e.messages)!function(e,t,n){e.x1+=t,e.x2+=t,e.y+=n,e.points=e.points.map(e=>({x:e.x+t,y:e.y+n})),e.labelPosition=eG(e.labelPosition,t,n),e.bounds=eZ(e.bounds,t,n)}(i,t,n);for(let i of e.blocks)for(let e of(i.x+=t,i.y+=n,i.bounds=eZ(i.bounds,t,n),i.header&&(i.header={...i.header,x:i.header.x+t,y:i.header.y+n,label:eG(i.header.label,t,n)}),i.dividers))e.y+=n,e.labelPosition&&(e.labelPosition=eG(e.labelPosition,t,n));for(let i of e.notes)i.x+=t,i.y+=n;for(let i of e.boxes)i.x+=t,i.y+=n,void 0!==i.labelY&&(i.labelY+=n);for(let i of e.activations)i.x+=t,i.topY+=n,i.bottomY+=n;for(let i of e.lifelines)i.x+=t,i.topY+=n,i.bottomY+=n;for(let i of e.destructions)i.x+=t,i.y+=n}var e0={nodeLabelFontSize:q.nodeLabel,edgeLabelFontSize:q.edgeLabel,groupHeaderFontSize:q.edgeLabel,nodeLabelFontWeight:H.nodeLabel,edgeLabelFontWeight:H.edgeLabel,groupHeaderFontWeight:H.groupHeader,nodePaddingX:16,nodePaddingY:6,nodeCornerRadius:4,nodeLineWidth:F.outerBox,edgeLineWidth:F.connector,groupCornerRadius:0,groupPaddingX:10,groupPaddingY:8,groupLabelPaddingX:6,groupLineWidth:F.outerBox};function e1(e,t={},n={},i){let o=Y(t,e0,i),a=n.diagramMarginX??30,r=n.diagramMarginY??30,l=n.width??80,s=n.noteMargin??10,d=n.activationWidth??10,c=e.actors.map(e=>ea(i,"actor",{category:e.id},{includeFallback:!1})),h=Math.max(n.height??40,...c.map(e=>es("Mg",e?.fontSize??o.nodeLabelFontSize,e?.fontWeight??o.nodeLabelFontWeight).height+(e?.paddingY??o.nodePaddingY)*2)),p=es("Mg",e0.edgeLabelFontSize,e0.edgeLabelFontWeight).height,g=es("Mg",o.edgeLabelFontSize,o.edgeLabelFontWeight).height,u=n.messageMargin??40,f=Math.max(u,u+g-p),x=Math.max(30,f-10),b=Math.max(40,40+(o.groupHeaderFontSize-e0.groupHeaderFontSize)+(o.groupPaddingY-e0.groupPaddingY)*2),m=Math.max(28,b+o.groupPaddingY+20-f);if(0===e.actors.length)return e2({width:0,height:0,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,actors:[],lifelines:[],messages:[],activations:[],blocks:[],notes:[],boxes:[],destructions:[]},void 0===e.title?void 0:X(e.title,e.titleContent),o,a,r);let y=e.actors.map((e,t)=>{var i,a;let r,s,d,p,g,u,f,x,b,m;return i=void 0===e.wrap&&void 0!==n.wrap?{...e,wrap:n.wrap}:e,a=c[t],r=a?.textTransform??o.nodeTextTransform,s=a?.fontSize??o.nodeLabelFontSize,d=a?.fontWeight??o.nodeLabelFontWeight,p=a?.letterSpacing??o.nodeLetterSpacing,g=a?.paddingX??o.nodePaddingX,u=a?.paddingY??o.nodePaddingY,x=(f=et(X(i.label,i.labelContent),{transform:r,fontSize:s,fontWeight:d,letterSpacing:p,...i.wrap?{maxWidth:240}:{}})).text,b=Math.max(f.width+2*g,l),m="participant"===i.type?Math.max(h,Math.ceil(f.height+2*u)):h,{fontSize:s,fontWeight:d,letterSpacing:p,paddingX:g,paddingY:u,displayLabel:x,block:f,...i.links?{menuBlock:et("⋯",{display:"literal",fontSize:10,fontWeight:400})}:{},labelMetrics:f,width:b,height:m}}),k=y.map(e=>e.width),w=new Map;for(let t=0;t<e.actors.length;t++)w.set(e.actors[t].id,t);let v=e.messages.map(e=>{var t;let i,a,r,l,s,c,h,p,g,u,f,x,b,m,y;return s=(l=et((r=Object.freeze({value:a=void 0!==(t=void 0===e.wrap&&void 0!==n.wrap?{...e,wrap:n.wrap}:e).number?`${t.number}. ${t.label}`:t.label,prepared:U((i=X(t.label,t.labelContent),void 0!==t.number?R([`${t.number}. `,"string"==typeof i?U(i):i]):i))})).prepared,{transform:o.edgeTextTransform,fontSize:o.edgeLabelFontSize,fontWeight:o.edgeLabelFontWeight,letterSpacing:o.edgeLetterSpacing,...t.wrap?{maxWidth:240}:{}})).text,c=o.edgeLabelFontSize*el,h=a?l:{width:0,height:0,lines:[],lineHeight:c},p=Math.max("none"!==t.startHead?E.width:0,5*!!t.centralStart),g=Math.max("none"!==t.endHead?E.width:0,5*!!t.centralEnd),u=Math.max(o.lineWidth/2,"none"!==t.startHead||"none"!==t.endHead?E.height/2:0,t.centralStart||t.centralEnd?4.75:0),f=Math.max(16,p+g+8),x=h.width+f,m=(b=30+(h.width>0?8+h.width:0))+Math.max(12,d/2+8),y=t.from===t.to?0:Math.ceil(Math.max(0,h.height-c)),{label:a,labelContent:r,displayLabel:s,block:l,labelMetrics:h,startPad:p,endPad:g,markerHalfHeight:u,requiredSpanWidth:x,selfRightExtent:b,requiredSelfNeighborGap:m,extraAboveHeight:y}}),M=Array.from({length:Math.max(0,e.actors.length-1)},()=>0);for(let t=0;t<e.messages.length;t++){let n=e.messages[t],i=v[t],o=w.get(n.from),a=w.get(n.to);if(void 0===o||void 0===a)continue;if(o===a){o<e.actors.length-1&&(M[o]=Math.max(M[o],i.requiredSelfNeighborGap));continue}let r=Math.min(o,a),l=Math.max(o,a),s=l-r,d=e.actors[a].createMessageIndex===t&&"participant"===e.actors[a].type?k[a]/2:0,c=(i.requiredSpanWidth+d)/s;for(let e=r;e<l;e++)M[e]=Math.max(M[e],c)}let S=[],I=a+k[0]/2;for(let t=0;t<e.actors.length;t++){if(t>0){let e=(k[t-1]+k[t])/2;I+=Math.max(void 0!==n.actorMargin?e+n.actorMargin:Math.max(140,e+40),M[t-1]??0)}S.push(I)}let $=(e.boxes??[]).flatMap((t,i)=>{let a=e.actors.flatMap((e,t)=>e.box===i?[t]:[]),r=t.label?et(X(t.label,t.labelContent),{transform:o.groupTextTransform,fontSize:o.groupHeaderFontSize,fontWeight:o.groupHeaderFontWeight,letterSpacing:o.groupLetterSpacing,fontFamily:o.groupFont,...t.wrap??n.wrap?{maxWidth:240}:{}}):void 0;return a.length>0?[{box:t,memberIdxs:a,block:r}]:[]}),L=Math.max(22,...$.map(e=>(e.block?.height??0)+8)),C=r+($.length>0?L+6:0),W=e.actors.map((e,t)=>eQ(e,y[t],S[t],C)),P=e.actors.flatMap((t,n)=>{if(void 0!==t.createMessageIndex&&t.createMessageIndex<e.messages.length)return[];let i=W[n].bounds;return[i.y+i.height]}),q=P.length>0?Math.max(...P):C+h,H=q+26,F=[],z=e.blocks.map((t,n)=>{let i=eE.get(t);if(i)return i;let o=[];for(let n=0;n<e.notes.length;n++){let i=e.notes[n];i.afterIndex>=t.startIndex&&i.afterIndex<=t.endIndex&&o.push(n)}let a=[];for(let i=0;i<n;i++){let o=e.blocks[i];o.startIndex>=t.startIndex&&o.endIndex<=t.endIndex&&(e.blocks.some((e,a)=>a>i&&a<n&&o.startIndex>=e.startIndex&&o.endIndex<=e.endIndex&&e.startIndex>=t.startIndex&&e.endIndex<=t.endIndex)||a.push(i))}return{endMessageExclusive:Math.min(t.endIndex+1,e.messages.length),dividerNoteIndices:t.dividers.map(()=>-1),endNoteExclusive:o.length>0?o.at(-1)+1:e.notes.filter(e=>e.afterIndex<=t.endIndex).length,noteIndices:o,childBlockIndices:a,childSectionIndices:a.map(n=>t.dividers.filter(t=>e.blocks[n].startIndex>=t.index).length)}}),B=e.blocks.map(e=>{var t;let i,a,r,l,s,d,c,h,p,u,f;return a=(i=et("rect"===(t={...e,wrap:e.wrap??n.wrap,dividers:e.dividers.map(e=>({...e,wrap:e.wrap??n.wrap}))}).type?"":t.label?R([`${t.type} [`,U(X(t.label,t.labelContent)),"]"]):t.type,{transform:o.groupTextTransform,fontSize:o.groupHeaderFontSize,fontWeight:o.groupHeaderFontWeight,letterSpacing:o.groupLetterSpacing,fontFamily:o.groupFont,...t.wrap?{maxWidth:240}:{}})).text,r=o.groupHeaderFontSize*el,s=Math.ceil(Math.max(0,((l=a?i:{width:0,height:0,lines:[],lineHeight:r}).lines.length-1)*l.lineHeight)),d=Math.max(2*o.groupPaddingX,2*o.groupLabelPaddingX),c="rect"===t.type?0:l.width+d,h="rect"===t.type?0:Math.max(18,o.groupHeaderFontSize+o.groupPaddingY)+s,p=b+s,u="rect"===t.type?o.groupPaddingY:h+o.groupPaddingY,f=t.dividers.map(e=>{let t=et(e.label?R(["[",U(X(e.label,e.labelContent)),"]"]):"",{transform:o.edgeTextTransform,fontSize:o.edgeLabelFontSize,fontWeight:o.edgeLabelFontWeight,letterSpacing:o.edgeLetterSpacing,...e.wrap?{maxWidth:240}:{}}),n=t.text,i=e.label?t:{width:0,height:0,lines:[],lineHeight:g},a=Math.max(14,Math.ceil(i.lineHeight/2+6)),r=Math.max(0,a-14),l=Math.ceil(Math.max(0,(i.lines.length-1)*i.lineHeight));return{index:e.index,label:e.label,displayLabel:n,block:t,metrics:i,firstLineOffset:a,extraFontOffset:r,extraLinesHeight:l,requiredExtraBefore:24+l+r,noteContentOffset:Math.ceil(Math.max(28+l+r,a+(i.lines.length-1)/2*i.lineHeight+i.height/2+o.groupPaddingY))}}),{headerText:a,block:i,headerMetrics:l,tabWidth:c,tabHeight:h,extraHeaderLinesHeight:s,blockPadTop:p,blockHeaderExtra:m+s,enclosingHeaderStep:u,contentTopPadding:"rect"===t.type?o.groupPaddingY:Math.max(p,h+o.groupPaddingY),dividers:f}}),T=ez.get(e),_=new Map,N=new Map,O=new Map,j=new Map,A=new Map;for(let t=0;t<e.blocks.length;t++){let n=e.blocks[t],i=N.get(n.startIndex)??[];i.push(t),N.set(n.startIndex,i);let o=z[t],a=o.noteIndices[0];if(void 0!==a){let e=O.get(a)??[];e.push(t),O.set(a,e)}for(let e of o.childBlockIndices)j.set(e,t)}let D=new Set,Z=new Set;if(T){let t=new Map(T.filter(e=>"open"===e.kind).map(e=>[e.blockIndex,e.noteIndex]));for(let n=0;n<e.blocks.length;n++){let i=e.blocks[n],o=z[n],a=new Set(o.childSectionIndices),r=i.startIndex,l=t.get(n);for(let e=0;e<=i.dividers.length;e++){let t=i.dividers[e]?.index??o.endMessageExclusive,s=o.dividerNoteIndices[e]??o.endNoteExclusive;r!==t||l!==s||a.has(e)||Z.add(n),r=t,l=s}o.childBlockIndices.some(t=>e.blocks[t].startIndex===z[t].endMessageExclusive&&0===z[t].noteIndices.length)&&Z.add(n)}for(let t=0;t<e.blocks.length;t++){let e=j.get(t);Z.has(t)&&void 0!==e&&Z.add(e)}}let G=e=>(N.get(e)??[]).filter(t=>!D.has(t)&&z[t].endMessageExclusive>e),Q=e=>0===e.length?0:B[e[0]].blockHeaderExtra+e.slice(1).reduce((e,t)=>e+B[t].enclosingHeaderStep,0);for(let t=0;t<e.blocks.length;t++){if(Z.has(t)||"par_over"===e.blocks[t].type)continue;let n=B[t],i=z[t];for(let[o,a]of n.dividers.entries()){let n=eV(e.blocks[t],i,e,o);if(void 0!==n){A.set(n,Math.max(A.get(n)??0,a.noteContentOffset));continue}if(a.index>=i.endMessageExclusive)continue;let r=a.requiredExtraBefore;for(let t of i.childBlockIndices)e.blocks[t]?.startIndex===a.index&&(r+=B[t].blockHeaderExtra);let l=_.get(a.index)??0;_.set(a.index,Math.max(l,r))}}let V=new Map,J=new Map,K=new Map;for(let t=0;t<e.actors.length;t++){let n=e.actors[t];if(void 0!==n.createMessageIndex&&n.createMessageIndex<e.messages.length){let e=V.get(n.createMessageIndex)??[];e.push(t),V.set(n.createMessageIndex,e)}if(void 0!==n.destroyMessageIndex&&n.destroyMessageIndex<e.messages.length){let e=J.get(n.destroyMessageIndex)??[];e.push(n.id),J.set(n.destroyMessageIndex,e)}}let ee=new Map;for(let t=0;t<e.notes.length;t++){let n=e.notes[t],i=ee.get(n.afterIndex)??[];i.push({note:n,index:t}),ee.set(n.afterIndex,i)}let en=Array(e.notes.length),ei=new Map,eo=[],er=new Map;for(let t of e.activationEvents??[]){let e=er.get(t.messageIndex)??[];e.push(t),er.set(t.messageIndex,e)}let ed=(e,t)=>{let n=ei.get(e)??[];n.push({startY:t,depth:n.length}),ei.set(e,n)},ec=(e,t)=>{let n=ei.get(e);if(!n||0===n.length)return;let{startY:i,depth:o}=n.pop(),a=w.get(e);void 0===a||t<=i||eo.push({actorId:e,x:S[a]-d/2+4*o,topY:i,bottomY:t,width:d})},eh=(e,t)=>{for(let n of er.get(e)??[])"activate"===n.kind?ed(n.actorId,t):ec(n.actorId,t)},ep=(e,t)=>{let i=et(X(e.text,e.textContent),{transform:o.nodeTextTransform,fontSize:o.nodeLabelFontSize,fontWeight:o.nodeLabelFontWeight,letterSpacing:o.nodeLetterSpacing,...e.wrap??n.wrap?{maxWidth:240}:{}}),a=Math.max(60,i.width+2*o.nodePaddingX),r=i.height+2*o.nodePaddingY,l=w.get(e.actorIds[0]??"")??0,d;if("left"===e.position)d=S[l]-k[l]/2-a-s;else if("right"===e.position)d=S[l]+k[l]/2+s;else if(e.actorIds.length>1){let t=w.get(e.actorIds[e.actorIds.length-1]??"")??l;d=(S[l]+S[t])/2-a/2}else d=S[l]-a/2;return{text:e.text,block:i,x:d,y:t,width:a,height:r,position:e.position,actors:e.actorIds}},eg=Array(e.blocks.length),eu=[],ef=-1/0,ex=q,eb=-1/0,em=0,ey=0,ek=0,ew=0,ev=new Map,eM=(t,n,i)=>{let o=0,a=[];for(let[o,r]of ev){let l=e.blocks[o];for(let e=l.startIndex;e<r.messageEnd;e++)F[e]&&a.push(F[e].bounds);for(let e of z[o].noteIndices)e<r.noteEnd&&en[e]&&a.push(en[e]);for(let e of r.priorChildren)eg[e]&&a.push(eg[e]);for(let[s,d]of l.dividers.entries()){let c=B[o].dividers[s];if(!d.label)continue;let h=eV(l,z[o],e,s),p=void 0!==h&&h<r.noteEnd?en[h]:void 0===h&&d.index<r.messageEnd?F[d.index]?.bounds:void 0;if(p&&a.push({x:p.x,y:p.y-c.metrics.height-8,width:c.metrics.width,height:c.metrics.height}),void 0===h&&n===d.index||void 0!==h&&i===h){let e=c.metrics.height+8;t={x:t.x,y:t.y-e,width:Math.max(t.width,c.metrics.width),height:t.height+e}}}}for(let e=0;e<=a.length;e++){let e=a.find(e=>t.x<e.x+e.width+8&&t.x+t.width+8>e.x&&t.y+o<e.y+e.height+8&&t.y+t.height+o+8>e.y);if(!e)break;o=e.y+e.height+8-t.y}return o},eS=e=>{let t=[];for(let n=e;void 0!==n&&!D.has(n);n=j.get(n))t.push(n);for(let e=t.length-1;e>=0;e--){let n=t[e],i=Math.max(ex,ef,eb)+8;eu[n]={top:i,dividerY:[]},D.add(n),ex=eb=i+B[n].enclosingHeaderStep}},eI=t=>{let n=e.blocks[t],i=z[t],a=eu[t]?.top,r=void 0!==a&&n.startIndex===i.endMessageExclusive&&0===i.noteIndices.length?a+B[t].blockPadTop:en[i.noteIndices[0]??-1]?.y??H;D.add(t);let l=eJ(n,B[t],i,e,w,W,F,en,eg,o,g,r,eu[t]);eg[t]=l,ef=Math.max(ef,l.y+l.height);let s=ev.get(t);s&&(ex=Math.max(ex,s.bottom,ef),H=Math.max(H,ex+f/2),ev.delete(t))},e$=()=>{if(T){for(;ek<T.length;){let t=T[ek];if(t.messageIndex>F.length||t.noteIndex>em)break;let n=t.blockIndex;if("open"===t.kind&&Z.has(n)&&eS(n),"open"===t.kind&&"par_over"===e.blocks[n].type){eS(n);let i=Math.max(0,...B[n].dividers.map(e=>e.noteContentOffset));eb+=i,ex=eb,H=Math.max(H,eb+f/2),ev.set(n,{messageY:H,contentBottom:ex,completedBottom:ef,reservedBottom:eb,bottom:ex,messageEnd:e.blocks[n].startIndex,noteEnd:t.noteIndex,priorChildren:[]}),ew++}if("divider"===t.kind){let e=ev.get(n);if(e){e.bottom=Math.max(e.bottom,ex,ef,eb),e.messageEnd=t.messageIndex,e.noteEnd=t.noteIndex,e.priorChildren=z[n].childBlockIndices.filter(e=>eg[e]),({messageY:H,contentBottom:ex,completedBottom:ef,reservedBottom:eb}=e),ew++,ek++;continue}let i=B[n].dividers[t.dividerIndex],o=Math.max(ex,ef,eb)+8;Z.has(n)?(eu[n].dividerY[t.dividerIndex]=o,ex=eb=o+i.noteContentOffset):eb=o+i.noteContentOffset}"close"===t.kind&&eI(n),ek++}return}for(;ey<e.blocks.length;){let e=ey,t=z[e];if(t.endMessageExclusive>F.length||t.endNoteExclusive>em)break;eI(e),ey++}},eL=(e,t)=>{let n=t;for(let{note:t,index:i}of ee.get(e)??[]){let e=ew;for(let t of(e$(),e!==ew&&(n=H),n=Math.max(n,ef+8,eb),O.get(i)??[])){let e=eu[t]?.top;void 0!==e&&(n=Math.max(n,e+B[t].contentTopPadding))}let o=(O.get(i)??[]).filter(e=>!D.has(e)),a=A.get(i)??0;if(o.length>0||a>0){let e=a+(o.length>0?B[o[0]].contentTopPadding+o.slice(1).reduce((e,t)=>e+B[t].enclosingHeaderStep,0):0);for(let t of(n=Math.max(n,Math.max(ex,ef)+8+e),o))D.add(t)}let r=ep(t,n),l=eM(r,void 0,i);l>0&&(n+=l,r=ep(t,n)),en[i]=r,ex=Math.max(ex,r.y+r.height),em=i+1,n=r.y+r.height+4}ee.has(e)&&(H=Math.max(H,n+f/2))};eL(-1,H);for(let t=0;t<e.messages.length;t++){let n=e.messages[t],i=v[t],a=w.get(n.from)??0,r=w.get(n.to)??0,l=n.from===n.to;e$();let s=G(t),d=Math.max(_.get(t)??0,Q(s));for(let e of V.get(t)??[]){let t=W[e].height/2;d=d>0?d+Math.max(0,t-12):t+8}H+=d+i.extraAboveHeight;let c=S[a],h=S[r],p=e.actors[r].createMessageIndex!==t||"participant"!==e.actors[r].type||l?h:h-Math.sign(h-c)*k[r]/2,u=()=>{let a=function(e,t,n,i,o,a){let r=e.from===e.to;if(r){let l=a+Math.max(20,t.labelMetrics.height)/2,s=eR(t.displayLabel,i+30+8,l,"start",n.edgeLabelFontSize,n.edgeLabelFontWeight,n.edgeLetterSpacing,t.block),d={x:i-t.startPad,y:a-t.markerHalfHeight,width:30+t.startPad+n.lineWidth/2,height:20+2*t.markerHalfHeight},c=t.label?eU(d,s.bounds):d;return{from:e.from,to:e.to,label:t.label,labelContent:t.labelContent,lineStyle:e.lineStyle,startHead:e.startHead,endHead:e.endHead,centralStart:e.centralStart??!1,centralEnd:e.centralEnd??!1,x1:i,x2:o,y:a,isSelf:r,points:[{x:i,y:a},{x:i+30,y:a},{x:i+30,y:a+20},{x:o,y:a+20}],labelPosition:s,bounds:c}}let l=Math.max(2.85,n.lineWidth/2+2),s=Math.max(10,t.labelMetrics.height/2+l),d=eR(t.displayLabel,(i+o)/2,a-s,"middle",n.edgeLabelFontSize,n.edgeLabelFontWeight,n.edgeLetterSpacing,t.block),c=i<=o?t.startPad:t.endPad,h=i<=o?t.endPad:t.startPad,p=Math.min(i,o)-c,g=Math.max(i,o)+h,u={x:p,y:a-t.markerHalfHeight,width:g-p,height:2*t.markerHalfHeight},f=t.label?eU(u,d.bounds):u;return{from:e.from,to:e.to,label:t.label,labelContent:t.labelContent,lineStyle:e.lineStyle,startHead:e.startHead,endHead:e.endHead,centralStart:e.centralStart??!1,centralEnd:e.centralEnd??!1,x1:i,x2:o,y:a,isSelf:r,points:[{x:i,y:a},{x:o,y:a}],labelPosition:d,bounds:f}}(n,i,o,c,p,H);for(let n of(F[t]=a,V.get(t)??[]))W[n]=eQ(e.actors[n],y[n],S[n],H-W[n].height/2);return a},b=u(),m=b.bounds.y,M=0,I=new Set(s),$=(N.get(t)??[]).filter(e=>I.has(e)||eu[e]?.top!==void 0&&!eg[e]);if($.length>0){let t=[];for(let n of $){for(let e of z[n].childBlockIndices)eg[e]&&(t[e]=eg[e]);t[n]=eJ(e.blocks[n],B[n],z[n],e,w,W,F,en,t,o,g,H,eu[n]);let i=eu[n]?.top;void 0!==i?M=Math.max(M,i-t[n].y):m=Math.min(m,t[n].y)}}let L=Math.max(0,M,(s.length>0?Math.max(ex,ef,eb):Math.max(ef,eb))+8*(s.length>0)-m);L>0&&(H+=L,b=u());let C=eM(b.bounds,t);for(let e of(C>0&&(H+=C,b=u()),s))D.add(e);ex=Math.max(ex,b.bounds.y+b.bounds.height,...(V.get(t)??[]).map(e=>W[e].bounds.y+W[e].bounds.height)),eh(t,H);let P=J.get(t);if(P)for(let e of P)K.set(e,H);n.activate&&ed(n.to,H),n.deactivate&&ec(n.from,H);let q=l?Math.max(x,Math.ceil(i.labelMetrics.height)+10):0;H+=l?q+f:f;let E=V.get(t);if(E){let e=Math.max(...E.map(e=>{let t=W[e];return t.bounds.height-t.height/2}));H+=e}let Y=E?ex+8:b.y+q+14;eL(t,Y)}e$();let eC=Math.max(F[F.length-1]?.y??H,H-f/2);for(let[t,n]of(eh(e.messages.length,eC),ei))for(;n.length>0;)ec(t,eC);for(let t of W)e.actors[w.get(t.id)]?.external&&(t.external=!0);for(let[t,n]of F.entries()){let i=e.messages[t];void 0!==i.id&&(n.id=i.id),void 0!==i.parentId&&(n.parentId=i.parentId)}for(let[t,n]of eg.entries()){let i=e.blocks[t];void 0!==i.id&&(n.id=i.id),void 0!==i.parentId&&(n.parentId=i.parentId)}for(let[t,n]of en.entries()){let i=e.notes[t];n&&i?.id!==void 0&&(n.id=i.id),n&&i?.parentId!==void 0&&(n.parentId=i.parentId)}let eW=en.filter(e=>void 0!==e),eP=eg.reduce((e,t)=>Math.max(e,t.y+t.height),0);eP>0&&(H=Math.max(H,eP+8));let eq=H,eH=$.map(({box:e,memberIdxs:t,block:n})=>{let i=Math.min(...t.map(e=>W[e].bounds.x))-8,o=Math.max(...t.map(e=>W[e].bounds.x+W[e].bounds.width))+8;return e.label&&(o=Math.max(o,i+n.width+16)),{label:e.label,block:n,labelY:r+L/2,color:e.color,x:i,y:r,width:o-i,height:eq+8-r}}),eF=H+r,eY=a,eB=0;for(let e of W){let t=e.bounds;eY=Math.min(eY,t.x),eB=Math.max(eB,t.x+t.width)}for(let e of eg)eY=Math.min(eY,e.x),eB=Math.max(eB,e.x+e.width);for(let e of eW)eY=Math.min(eY,e.x),eB=Math.max(eB,e.x+e.width);for(let e of eH)eY=Math.min(eY,e.x),eB=Math.max(eB,e.x+e.width);for(let e of eo)eY=Math.min(eY,e.x),eB=Math.max(eB,e.x+e.width);for(let e of F){eY=Math.min(eY,e.bounds.x);let t=e.isSelf&&e.label?8:0;eB=Math.max(eB,e.bounds.x+e.bounds.width+t)}let eT=eY<a?a-eY:0;if(eT>0){eK({actors:W,messages:F,blocks:eg,notes:eW,boxes:eH,activations:eo,lifelines:[],destructions:[]},eT,0);for(let e=0;e<S.length;e++)S[e]+=eT}let e_=e.actors.map((e,t)=>{let n=W[t],i=n.bounds.y+n.bounds.height;return{actorId:e.id,x:S[t],topY:i,bottomY:K.get(e.id)??eF-r}}),eN=e.actors.filter(e=>K.has(e.id)).map(e=>({actorId:e.id,x:S[w.get(e.id)],y:K.get(e.id)}));return e2({width:Math.max(eB+eT+a,200),height:Math.max(eF,100),accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,actors:W,lifelines:e_,messages:F,activations:eo,blocks:eg,notes:eW,boxes:eH,destructions:eN},void 0===e.title?void 0:X(e.title,e.titleContent),o,a,r)}function e2(e,t,n,i,o){let a=B(t,n);if(!a)return e;if(0===e.width&&0===e.height)return{...e,...T(a,i,o)};let r=a.height;eK(e,0,r);let l=Math.max(e.width,a.width+2*i);return{...e,width:l,height:e.height+r,title:_(a,l,o)}}function e3(e,t){let n,i,o,a,r,{positioned:l,colors:s,resolved:d}=t,c=d.renderOptions,h=s.font??"Inter",p=c.transparent??!1,g=[],u=Y(c,e0,d.styleFace),f=`seq-${ee(l.width,l.height,l.actors.length,l.messages.length)}`,x=`${f}-title`,b=`${f}-desc`,m=W(l.accessibilityTitle,l.accessibilityDescription,x,b);g.push(e.documentOpen({id:"prelude",width:l.width,height:l.height,colors:s,transparent:p,font:h,hasMonoFont:!1},L(l.width,l.height,s,p,m)+`
4
+ `+$(h,!1,s.shadow,s.embedFontImport)));let w=[];w.push("<defs>");let v=(n=E.width,i=E.height,o=u.edgeStrokeColor??"var(--_arrow)",a={size:{width:n,height:i},orient:"auto-start-reverse"},r=[{x:0,y:0},{x:n,y:i/2},{x:0,y:i}],[{...a,id:"seq-arrow",shape:"arrow",ref:{x:n,y:i/2},geometry:{kind:"polygon",points:r},paint:{fill:o}},{...a,id:"seq-arrow-open",shape:"open-arrow",ref:{x:n,y:i/2},geometry:{kind:"polyline",points:r},paint:{fill:"none",stroke:o,strokeWidth:"1"}},{...a,id:"seq-arrow-cross",shape:"cross",ref:{x:n/2,y:i/2},orient:"auto",geometry:{kind:"path",d:`M1 1 L${n-1} ${i-1} M1 ${i-1} L${n-1} 1`},paint:{fill:"none",stroke:o,strokeWidth:"1.5"}},{...a,id:"seq-arrow-half-top",shape:"arrow",ref:{x:n,y:i/2},geometry:{kind:"polygon",points:[{x:0,y:0},{x:n,y:i/2},{x:0,y:i/2}]},paint:{fill:o}},{...a,id:"seq-arrow-half-bottom",shape:"arrow",ref:{x:n,y:i/2},geometry:{kind:"polygon",points:[{x:0,y:i/2},{x:n,y:i/2},{x:0,y:i}]},paint:{fill:o}},{...a,id:"seq-arrow-stick-top",shape:"open-arrow",ref:{x:n,y:i/2},geometry:{kind:"path",d:`M0 0 L${n} ${i/2}`},paint:{fill:"none",stroke:o,strokeWidth:"1.5"}},{...a,id:"seq-arrow-stick-bottom",shape:"open-arrow",ref:{x:n,y:i/2},geometry:{kind:"path",d:`M0 ${i} L${n} ${i/2}`},paint:{fill:"none",stroke:o,strokeWidth:"1.5"}}]);w.push(P(v));let M=I(s);M&&w.push(M),w.push("</defs>"),g.push(e.definitions({id:"defs",markerResources:v},w.join(`
5
+ `))),l.accessibilityTitle&&g.push(e.documentContent({id:"a11y-title",role:"chrome",nonPaint:"accessibility"},`<title id="${x}">${G(l.accessibilityTitle)}</title>`)),l.accessibilityDescription&&g.push(e.documentContent({id:"a11y-desc",role:"chrome",nonPaint:"accessibility"},`<desc id="${b}">${G(l.accessibilityDescription)}</desc>`));let S=l.blocks.some(e=>"rect"===e.type),q=S?[...l.blocks].reverse().sort((e,t)=>t.width*t.height-e.width*e.height):l.blocks,H=function(e,t,n,i){let o=(e,t,n)=>t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height,a=e.flatMap(e=>{let t=e.color&&"transparent"!==e.color.toLowerCase()?ek(e.color):void 0;return t?[{x:e.x,y:e.y,width:e.width,height:e.height,hex:t,authored:!0}]:[]}),r=C("var(--bg)",i)??"#ffffff";for(let e of t){let t=e6(e,n),l=void 0===t?void 0:C(t,i)??t,s=void 0===l?null:O(l);if(!s||0===s[3])continue;let d=e.x+e.width/2,c=e.y+e.height/2,h=j(l,a.findLast(e=>o(e,d,c))?.hex??r);h&&a.push({x:e.x,y:e.y,width:e.width,height:e.height,hex:eo(...h),authored:"rect"===e.type})}return(e,t)=>{let n=a.findLastIndex(t=>o(t,e.x,e.y)),r=a[n],l=void 0!==r&&!(o(r,e.x-e.width/2,e.y-e.height/2)&&o(r,e.x+e.width/2,e.y+e.height/2))||a.some((t,i)=>i>n&&t.hex!==r?.hex&&e.x-e.width/2<t.x+t.width&&e.x+e.width/2>t.x&&e.y-e.height/2<t.y+t.height&&e.y+e.height/2>t.y);if(!r)return l?{ink:t,halo:"var(--bg)"}:{ink:t};let s=C(t,i),d=s?er(s,r.hex):y(r.hex)??t;return r.authored||l?{ink:d,halo:r.hex}:{ink:d}}}(l.boxes,q,u,s);l.title&&g.push(e.text(N(l.title,u)));let B=new Map;for(let t of l.boxes){let n=t.label??"",i=B.get(n)??0;B.set(n,i+1),g.push(function(e,t,n,i){let o=[],a=`<g class="box"${t.label?` data-label="${V(t.label)}"`:""}>`,r=t.color?.toLowerCase()==="transparent"?"none":t.color,l=r??"color-mix(in srgb, var(--fg) 5%, var(--bg))";if(o.push({indent:2,node:e.shape({id:`${i}:rect`,role:"group",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.groupCornerRadius,ry:n.groupCornerRadius},paint:{fill:l,stroke:"none"}})}),t.label){let a=t.block?.text??z(t.label,n.groupTextTransform),l=function(e,t){let n=t.groupTextColor??"var(--_text-sec)";if(!e||"none"===e)return n;let i=ek(e);if(!i)return n;let o=t.groupTextColor;if(o){let e=A(o,i);if(null!==e&&e>=4.5)return o}return y(i)??n}(r,n),s=t.x+t.width/2,d=t.labelY??t.y+13;o.push({indent:2,node:e.text({id:`${i}:title`,role:"label",text:a,block:t.block,x:s,y:d,fontSize:n.groupHeaderFontSize,fontWeight:n.groupHeaderFontWeight,letterSpacing:n.groupLetterSpacing,anchor:"middle",paint:{fill:l}})})}return e.group({id:i,role:"group",open:a,close:"</g>",children:o})}(e,t,u,`box:${n}#${i}`))}let T=new Map,_=new Map;for(let e of l.blocks){let t=T.get(e.type)??0;T.set(e.type,t+1),_.set(e,e.id??`block:${e.type}#${t}`)}for(let t of q)g.push(e9(e,t,u,_.get(t),S?"background":"all"));if(S){for(let t of q)"rect"!==t.type&&g.push(e9(e,t,u,_.get(t),"frame"));for(let t of l.blocks)t.dividers.length>0&&g.push(e9(e,t,u,_.get(t),"dividers"))}let X=function(e){let t=new Map,n=[];for(let i of e){let e=`${i.from}->${i.to}`,o=t.get(e)??0;if(t.set(e,o+1),!i.labelPosition.text.trim())continue;let a=i.labelPosition.bounds;n.push({key:`${e}#${o}`,x:a.x-2,y:a.y-2,width:a.width+4,height:a.height+4})}let i=e=>{let t="x"===e?"width":"height",i=[...n].sort((t,n)=>t[e]-n[e]),o=(n,a)=>{if(n>=a)return;let r=n+a>>>1,l=i[r],s=o(n,r),d=o(r+1,a);return{area:l,left:s,right:d,end:Math.max(l[e]+l[t],s?.end??-1/0,d?.end??-1/0)}},a=o(0,i.length);return n=>{let i=[],o=a=>{if(!a||a.end<n[e])return;o(a.left);let r=a.area;r[e]>n[e]+n[t]||(r.x<=n.x+n.width&&r.x+r.width>=n.x&&r.y<=n.y+n.height&&r.y+r.height>=n.y&&i.push(r),o(a.right))};return o(a),i}},o=i("x"),a=i("y");return(e,t)=>{let n=("x"===t?o:a)(e).sort((e,t)=>e.y-t.y),i=[],r=e.y+e.height,l=e.y,s;for(let t of n){let n=Math.max(e.y,t.y);n>l&&i.push({top:l,bottom:n,after:s});let o=Math.min(r,t.y+t.height);o>l&&(l=o,s=t.key)}return l<r&&i.push({top:l,bottom:r,after:s}),i}}(l.messages),D=new Set(l.actors.filter(e=>e.external).map(e=>e.id));for(let t of l.lifelines){if(D.has(t.actorId))continue;let n=Math.max(.75,.75*u.lineWidth);g.push(function(e,t,n,i){let o=n.edgeStrokeColor??"var(--_line)",a=Math.max(.75,.75*n.lineWidth),r=`lifeline:${t.actorId}`;return 1!==i.length||i[0].top!==t.topY||i[0].bottom!==t.bottomY?e.group({id:r,role:"lifeline",open:`<g class="lifeline" data-actor="${Q(t.actorId)}">`,close:"</g>",children:i.map(n=>{let i=(n.top-t.topY)%10;return{indent:2,node:e.connector({id:n.after?K(r,"after",n.after):K(r,"start"),role:"lifeline",geometry:{kind:"line",x1:t.x,y1:n.top,x2:t.x,y2:n.bottom},lineStyle:"dashed",paint:{stroke:o,strokeWidth:String(a),strokeDasharray:"6 4",strokeDashoffset:String(i)}})}})}):e.connector({id:r,role:"lifeline",geometry:{kind:"line",x1:t.x,y1:t.topY,x2:t.x,y2:t.bottomY},lineStyle:"dashed",paint:{stroke:o,strokeWidth:String(a),strokeDasharray:"6 4"},attributes:{className:"lifeline",data:{actor:t.actorId}}})}(e,t,u,X({x:t.x-n/2,y:t.topY,width:n,height:t.bottomY-t.topY},"x")))}let R=new Map;for(let t of l.activations){let n=R.get(t.actorId)??0;R.set(t.actorId,n+1),g.push(function(e,t,n,i,o){let a=n.nodeFillColor??"var(--_node-fill)",r=n.nodeBorderColor??"var(--_node-stroke)";if(1!==o.length||o[0].top!==t.topY||o[0].bottom!==t.bottomY){let n=[],l=[],s=[];for(let e of o)for(let n of(l.push(`M ${t.x} ${e.top} h ${t.width} V ${e.bottom} h ${-t.width} Z`),[{x1:t.x,y1:e.top,x2:t.x,y2:e.bottom},{x1:t.x+t.width,y1:e.top,x2:t.x+t.width,y2:e.bottom},...e.top===t.topY?[{x1:t.x,y1:e.top,x2:t.x+t.width,y2:e.top}]:[],...e.bottom===t.bottomY?[{x1:t.x,y1:e.bottom,x2:t.x+t.width,y2:e.bottom}]:[]]))s.push(`M ${n.x1} ${n.y1} L ${n.x2} ${n.y2}`);if(l.length){let t=l.join(" "),o=s.join(" ");n.push({indent:2,node:e.shape({id:K(i,"fill"),role:"activation",surfaceFragment:!0,geometry:{kind:"path",d:t},paint:{fill:a,stroke:"none"}})}),n.push({indent:2,node:e.shape({id:K(i,"border"),role:"activation",geometry:{kind:"path",d:o},paint:{fill:"none",stroke:r,strokeWidth:String(F.innerBox)}})})}return e.group({id:i,role:"activation",open:`<g class="activation" data-actor="${Q(t.actorId)}">`,close:"</g>",children:n})}return e.shape({id:i,role:"activation",geometry:{kind:"rect",x:t.x,y:t.topY,width:t.width,height:t.bottomY-t.topY},paint:{fill:a,stroke:r,strokeWidth:String(F.innerBox)},attributes:{className:"activation",data:{actor:t.actorId}}})}(e,t,u,`activation:${t.actorId}#${n}`,X({x:t.x-F.innerBox/2,y:t.topY,width:t.width+F.innerBox,height:t.bottomY-t.topY},"y")))}let U=new Map;for(let t of l.blocks){let n=U.get(t.type)??0;U.set(t.type,n+1),"rect"!==t.type&&t.header&&g.push(function(e,t,n,i){let{x:o,y:a,width:r,height:l,label:s}=t,{text:d,x:c,y:h}=s,p=n.groupHeaderFillColor??"var(--_group-hdr)",g=n.groupBorderColor??"var(--_node-stroke)",u=n.groupTextColor??"var(--_text-sec)";return e.group({id:`${i}:header-overlay`,role:"block",open:'<g class="sequence-block-header-overlay" pointer-events="none" aria-hidden="true">',close:"</g>",children:[{indent:0,node:e.shape({id:`${i}:tab`,role:"block",geometry:{kind:"rect",x:o,y:a,width:r,height:l},paint:{fill:p,stroke:g,strokeWidth:String(n.groupLineWidth)}})},{indent:0,node:e.text({id:`${i}:label`,role:"label",text:d,block:s.block,x:c,y:h,fontSize:n.groupHeaderFontSize,fontWeight:n.groupHeaderFontWeight,letterSpacing:n.groupLetterSpacing,anchor:"start",paint:{fill:u}})}]})}(e,t.header,u,_.get(t)))}let Z=new Map;for(let t of l.blocks){let n=Z.get(t.type)??0;Z.set(t.type,n+1),t.dividers.some(e=>e.label)&&g.push(function(e,t,n,i,o){let a=n.edgeTextColor??"var(--_text-muted)",r=[];return t.dividers.forEach((t,l)=>{if(!t.label||!t.labelPosition)return;let{text:s,x:d,y:c,bounds:h}=t.labelPosition,p=o(e8(h),a),g={ink:p.ink,halo:p.halo??n.groupFillColor??"var(--bg)"};r.push({indent:2,node:e.text({id:`${i}:divider#${l}:label`,role:"label",text:s,block:t.labelPosition.block,x:d,y:c,fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing,anchor:"start",paint:{fill:g.ink,...e5(g)}})})}),e.group({id:`${i}:divider-labels`,role:"block",open:'<g class="sequence-block-divider-labels" pointer-events="none">',close:"</g>",children:r})}(e,t,u,_.get(t),H))}let J=new Map;for(let t of l.messages){let n=`${t.from}->${t.to}`,i=J.get(n)??0;J.set(n,i+1),g.push(function(e,t,n,i,o,a){let r=[],l=e4(a,t.startHead),s=e4(a,t.endHead),d=n.edgeStrokeColor??"var(--_line)",c=n.edgeTextColor??"var(--_text-muted)",{text:h,x:p,y:g,bounds:u}=t.labelPosition,f={stroke:d,strokeWidth:String(n.lineWidth),..."dashed"===t.lineStyle?{strokeDasharray:"6 4"}:{}},x={endpoints:{from:t.from,to:t.to},relationship:{kind:"sequence-message",direction:t.isSelf?"self":l&&s?"bidirectional":l?"reverse":s?"forward":"undirected"},route:{ownership:"layout"},labels:t.label?[{text:t.label,...t.labelContent?{textContent:t.labelContent}:{}}]:[]},b=`<g class="message" data-label="${V(t.label)}" data-line-style="${t.lineStyle}" data-start-head="${t.startHead}" data-end-head="${t.endHead}" data-central-start="${t.centralStart}" data-central-end="${t.centralEnd}" data-self="${t.isSelf}"${void 0===t.parentId?"":` data-parent-id="${Q(t.parentId)}"`}>`;if(t.isSelf){r.push({indent:2,node:e.connector({id:`${i}:line`,role:"message",geometry:{kind:"polyline",points:t.points},lineStyle:t.lineStyle,paint:f,markers:{...l?{start:l}:{},mid:[],...s?{end:s}:{}},...x})});let a=o(e8(u),c);r.push({indent:2,node:e.text({id:`${i}:label`,role:"label",text:h,block:t.labelPosition.block,x:p,y:g,fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing,anchor:"start",paint:{fill:a.ink,...e5(a)}})})}else{let a=t.points[0],d=t.points[t.points.length-1];r.push({indent:2,node:e.connector({id:`${i}:line`,role:"message",geometry:{kind:"line",x1:a.x,y1:a.y,x2:d.x,y2:d.y},lineStyle:t.lineStyle,paint:f,markers:{...l?{start:l}:{},mid:[],...s?{end:s}:{}},...x})});let b=o(e8(u),c);r.push({indent:2,node:e.text({id:`${i}:label`,role:"label",text:h,block:t.labelPosition.block,x:p,y:g,fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing,anchor:"middle",paint:{fill:b.ink,...e5(b)}})})}return t.centralStart&&r.push({indent:2,node:e.shape({id:`${i}:central-start`,role:"chrome",geometry:{kind:"circle",cx:t.x1,cy:t.y,r:4},paint:{fill:"var(--bg)",stroke:d,strokeWidth:"1.5"},attributes:{className:"sequence-central-connection",data:{side:"start"}}})}),t.centralEnd&&r.push({indent:2,node:e.shape({id:`${i}:central-end`,role:"chrome",geometry:{kind:"circle",cx:t.x2,cy:t.y,r:4},paint:{fill:"var(--bg)",stroke:d,strokeWidth:"1.5"},attributes:{className:"sequence-central-connection",data:{side:"end"}}})}),e.group({id:i,role:"message",open:b,close:"</g>",children:r})}(e,t,u,t.id??`message:${n}#${i}`,H,v))}let et=new Map;for(let t of l.notes){let n=`${(t.actors??[]).join(",")}@${t.position??"over"}`,i=et.get(n)??0;et.set(n,i+1),g.push(function(e,t,n,i,o){let{x:a,y:r,width:l,height:s}=t,d=t.actors&&t.actors.length>0?` data-actors="${t.actors.map(Q).join(",")}"`:"",c=t.position?` data-position="${Q(t.position)}"`:"",h=n.nodeFillColor??"var(--bg)",p=n.nodeBorderColor??"var(--_node-stroke)",g=n.nodeTextColor??k("var(--_text-muted)",h,i),u=n.cornerRadius??0,f=t.block?.text??z(t.text,n.nodeTextTransform);return e.group({id:o,role:"note",open:`<g class="note"${c}${d}${void 0===t.parentId?"":` data-parent-id="${Q(t.parentId)}"`}>`,close:"</g>",children:[{indent:2,node:e.shape({id:`${o}:rect`,role:"note",geometry:{kind:"rect",x:a,y:r,width:l,height:s,rx:u,ry:u},paint:{fill:h,stroke:p,strokeWidth:String(F.innerBox)}})},{indent:2,node:e.text({id:`${o}:text`,role:"label",text:f,block:t.block,x:a+l/2,y:r+s/2,fontSize:n.nodeLabelFontSize,fontWeight:n.nodeLabelFontWeight,letterSpacing:n.nodeLetterSpacing,anchor:"middle",paint:{fill:g}})}]})}(e,t,u,s,t.id??`note:${n}#${i}`))}for(let t of l.destructions)g.push(function(e,t,n){let i=n.edgeStrokeColor??"var(--_line)",o=Math.max(1.5,n.lineWidth),a=`M ${t.x-8} ${t.y-8} L ${t.x+8} ${t.y+8} M ${t.x-8} ${t.y+8} L ${t.x+8} ${t.y-8}`;return e.shape({id:`destroy:${t.actorId}`,role:"icon",geometry:{kind:"path",d:a},paint:{fill:"none",stroke:i,strokeWidth:String(o)},channels:{category:t.actorId},attributes:{className:"destroy-cross",data:{actor:t.actorId}}})}(e,t,u));for(let t of l.actors)t.external||g.push(function(e,t,n,i,o,a,r){let{id:l,x:s,y:d,width:c,height:h,label:p,type:g}=t,u=[],f=ea(o,"actor",{category:l},{includeFallback:!1}),x=f?.fontSize??n.nodeLabelFontSize,b=f?.fontWeight??n.nodeLabelFontWeight,m=f?.letterSpacing??n.nodeLetterSpacing,y=(f?.textTransform??n.nodeTextTransform,f?.lineWidth??n.nodeLineWidth),w=f?.fillColor??n.nodeFillColor??"var(--_node-fill)",v=f?.borderColor??n.nodeBorderColor??"var(--_node-stroke)",M=f?.textColor??n.nodeTextColor??"var(--_text)",S=f?.textColor??n.nodeTextColor??k("var(--_text)",w,i),I=a&&t.links?` data-links="${Q(JSON.stringify(t.links))}" role="link" tabindex="0"`:"",$=`<g class="actor" data-id="${Q(l)}" data-label="${V(p)}" data-type="${g}"${I}>`,{text:L,x:C,y:W,bounds:P}=t.labelPosition,q=r(e8(P),M);if("actor"===g){let i=h/24*.9,o=s-12*i,a=d+(h-24*i)/2,r=y/i;u.push({indent:2,node:e.pathArtwork({id:`actor:${l}:icon`,owner:{id:l,role:"actor"},channels:{category:l},open:`<g transform="translate(${o},${a}) scale(${i})">`,transform:{kind:"matrix",a:i,b:0,c:0,d:i,e:o,f:a},paint:{fill:"none",stroke:f?.borderColor??n.edgeStrokeColor??"var(--_line)",strokeWidth:String(r)},join:`
6
+ `,indent:2,paths:["M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z","M15 10C15 11.6569 13.6569 13 12 13C10.3431 13 9 11.6569 9 10C9 8.34315 10.3431 7 12 7C13.6569 7 15 8.34315 15 10Z","M5.62842 18.3563C7.08963 17.0398 9.39997 16 12 16C14.6 16 16.9104 17.0398 18.3716 18.3563"]})}),u.push({indent:2,node:e.text({id:`actor:${l}:label`,role:"label",text:L,block:t.labelPosition.block,x:C,y:W,fontSize:x,fontWeight:b,letterSpacing:m,anchor:"middle",paint:{fill:q.ink,...e5(q)},channels:{category:l}})})}else if("participant"!==g){let i=s-c/2,o=d+2,a=Math.max(24,h-4),r=[],p={id:l,role:"actor"},k={fill:w,stroke:f?.borderColor??n.edgeStrokeColor??"var(--_line)",strokeWidth:String(y)},v=t=>{r.push(e.shape({id:K(`actor:${l}:icon`,"part",r.length),role:"icon",owner:p,geometry:t,paint:k}))},M=e=>v({kind:"path",d:e}),S=(e,t,n)=>v({kind:"circle",cx:e,cy:t,r:n}),I=(e,t,n,i)=>v({kind:"line",x1:e,y1:t,x2:n,y2:i}),$=(e,t,n,i,o)=>v({kind:"rect",x:e,y:t,width:n,height:i,...void 0===o?{}:{rx:o}});"database"===g?(v({kind:"ellipse",cx:s,cy:o+5,rx:c/2,ry:5}),M(`M${i} ${o+5}V${o+a-5}A${c/2} 5 0 0 0 ${i+c} ${o+a-5}V${o+5}`),v({kind:"ellipse",cx:s,cy:o+a-5,rx:c/2,ry:5})):"collections"===g?($(i+6,o,c-6,a-6),$(i,o+6,c-6,a-6)):"queue"===g?($(i,o,c,a,a/2),I(i+8,o+a/2,i+c-8,o+a/2)):"entity"===g?(S(s,o+a/2-3,Math.min(c,a)/2-3),I(i+5,o+a,i+c-5,o+a)):"boundary"===g?(S(s+3,o+a/2,Math.min(c,a)/2-3),I(i+3,o+2,i+3,o+a-2)):"control"===g?(S(s,o+a/2,Math.min(c,a)/2-3),M(`M${s-4} ${o+4}L${s+4} ${o}L${s+2} ${o+8}`)):S(s,o+a/2,Math.min(c,a)/2-3),u.push({indent:2,node:e.group({id:`actor:${l}:icon`,role:"icon",owner:p,channels:{category:l},open:`<g class="sequence-actor-glyph sequence-actor-${g}">`,close:"</g>",join:"",children:r.map(e=>({node:e,indent:0}))})}),u.push({indent:2,node:e.text({id:`actor:${l}:label`,role:"label",text:L,block:t.labelPosition.block,x:C,y:W,fontSize:x,fontWeight:b,letterSpacing:m,anchor:"middle",paint:{fill:q.ink,...e5(q)},channels:{category:l}})})}else{let i=s-c/2,o=f?.cornerRadius??n.cornerRadius??4;u.push({indent:2,node:e.shape({id:`actor:${l}:box`,role:"actor",geometry:{kind:"rect",x:i,y:d,width:c,height:h,rx:o,ry:o},paint:{fill:w,stroke:v,strokeWidth:String(y)},channels:{category:l}})}),u.push({indent:2,node:e.text({id:`actor:${l}:label`,role:"label",text:L,block:t.labelPosition.block,x:C,y:W,fontSize:x,fontWeight:b,letterSpacing:m,anchor:"middle",paint:{fill:S},channels:{category:l}})})}let H="participant"===g?S:M;return t.links&&u.push({indent:2,node:e.text({id:`actor:${l}:menu`,role:"icon",text:"⋯",block:t.menuBlock,x:s+c/2-7,y:d+10,fontSize:10,anchor:"middle",paint:{fill:H},channels:{category:l},baselineShift:0,attributes:{className:"sequence-actor-menu"}})}),e.group({id:`actor:${l}`,role:"actor",open:$,close:"</g>",children:u,channels:{category:l}})}(e,t,u,s,d.styleFace,"strict"!==c.security,H));return g.push(e.documentClose()),{family:"sequence",width:l.width,height:l.height,colors:s,transparent:p,parts:g}}function e5(e){return e.halo?{stroke:e.halo,strokeWidth:"3",strokeLinejoin:"round",paintOrder:"stroke"}:{}}function e8(e){return{x:e.x+e.width/2,y:e.y+e.height/2,width:e.width,height:e.height}}function e4(e,t){if("none"===t)return;let n="filled"===t?"seq-arrow":"cross"===t?"seq-arrow-cross":"half-top"===t?"seq-arrow-half-top":"half-bottom"===t?"seq-arrow-half-bottom":"stick-top"===t?"seq-arrow-stick-top":"stick-bottom"===t?"seq-arrow-stick-bottom":"seq-arrow-open";return e.find(e=>e.id===n)}function e6(e,t){return"rect"===e.type?e.color??t.groupFillColor??"rgba(128, 128, 128, 0.5)":t.groupFillColor}function e9(e,t,n,i,o="all"){let a=[],r=t.label?` data-label="${V(t.label)}"`:"",l="dividers"===o?`<g class="sequence-block-divider-overlay" data-owner="${Q(i)}">`:"frame"===o?`<g class="sequence-block-frame-overlay" data-owner="${Q(i)}">`:`<g class="block" data-type="${Q(t.type)}"${r}${void 0===t.parentId?"":` data-parent-id="${Q(t.parentId)}"`}>`,s=e6(t,n)??"none",d="rect"===t.type?"none":n.groupBorderColor??"var(--_node-stroke)";"dividers"!==o&&a.push({indent:2,node:e.shape({id:"frame"===o?`${i}:frame`:`${i}:rect`,role:"block",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.groupCornerRadius,ry:n.groupCornerRadius},paint:{fill:"frame"===o?"none":s,stroke:"background"===o?"none":d,strokeWidth:String(n.groupLineWidth)}})});let c=n.edgeStrokeColor??"var(--_line)",h=0;for(let r of"background"===o||"frame"===o||"par_over"===t.type?[]:t.dividers){let o=`${i}:divider#${h}`;h++;let l=Math.max(.75,.75*n.lineWidth);a.push({indent:2,node:e.connector({id:o,role:"block",geometry:{kind:"line",x1:t.x,y1:r.y,x2:t.x+t.width,y2:r.y},lineStyle:"dashed",paint:{stroke:c,strokeWidth:String(l),strokeDasharray:"6 4"}})})}return e.group({id:"dividers"===o?`${i}:divider-overlay`:"frame"===o?`${i}:frame-overlay`:i,role:"block",open:l,close:"</g>",children:a})}var e7=f(e3);function te({positioned:e,options:t}){let n=new Map(e.lifelines.map(e=>[e.actorId,e.x])),i=new Map;for(let t of e.messages)for(let e of[t.from,t.to])i.has(e)||i.set(e,t.y);let o=new Map;for(let t of e.notes)if(void 0!==t.parentId&&void 0!==t.id){let e=o.get(t.parentId)??[];e.push(t.id),o.set(t.parentId,e)}return{version:1,nodes:[...e.actors.map(e=>({id:e.id,x:s(e.external?e.x:e.bounds.x),y:s(e.external?i.get(e.id)??e.y:e.bounds.y),w:s(e.external?0:e.bounds.width),h:s(e.external?0:e.bounds.height),shape:e.external?"external-anchor":"rectangle",label:e.label,labelBounds:l(e.labelPosition.bounds),labelContainer:l(e.bounds),...e.external?{labelVisibility:"semantic"}:{},role:e.external?"mark":"box"})),...e.notes.map((e,t)=>({id:e.id??`note#${t}`,...void 0===e.parentId?{}:{parentId:e.parentId},x:s(e.x),y:s(e.y),w:s(e.width),h:s(e.height),shape:"note",label:e.text,...h(e.block,e.x+e.width/2,e.y+e.height/2,e),role:"box"}))],edges:e.messages.map((e,i)=>{var o;let a,r,h,p,g,u,f,x;return{id:e.id??`msg#${i}:${e.from}->${e.to}`,...void 0===e.parentId?{}:{parentId:e.parentId},from:e.from,to:e.to,path:e.points.map(e=>[s(e.x),s(e.y)]),label:e.label?{x:s(e.labelPosition.x),y:s(e.labelPosition.y),text:e.label,bounds:l(e.labelPosition.bounds)}:void 0,route:t.debug?(o=e.points,a=n.get(e.from),r=n.get(e.to),h=o[0],p=o[o.length-1],g=void 0!==a&&void 0!==h&&1>=Math.abs(h.x-a),u=void 0!==r&&void 0!==p&&1>=Math.abs(p.x-r),f=!e.isSelf&&o.every(t=>1>=Math.abs(t.y-e.y)),x=d(o),{family:"sequence",edgeIndex:i,routeClass:"family-layout",invariant:g&&u&&x?e.isSelf?"self-message":"lifeline-message":"unverified-family-route",bendCount:c(o),horizontal:f,sourceLifeline:g,targetLifeline:u,selfMessage:e.isSelf}):void 0}}),groups:e.blocks.map((e,t)=>({id:e.id??`block#${t}:${e.type}`,...void 0===e.parentId?{}:{parentId:e.parentId},x:s(e.bounds.x),y:s(e.bounds.y),w:s(e.bounds.width),h:s(e.bounds.height),members:void 0===e.id?[]:o.get(e.id)??[],label:e.label})),bounds:{w:s(e.width),h:s(e.height)}}}export{ep as a,eY as b,eB as c,eT as d,e_ as e,e1 as f,e3 as g,e7 as h,te as i};
@@ -1,4 +1,4 @@
1
- import{Aa as e,B as r,N as t,Q as i,R as o,fb as n,ib as s,kb as a,la as l,mb as f,na as u,oa as c,ra as d,sa as g,ta as h,va as v,xa as p,za as $}from"./chunk-EIYLJ4FI.js";import{a as m}from"./chunk-YHMTSXIR.js";var w=/^(?:#[0-9a-f]{3,4}|#[0-9a-f]{6}|#[0-9a-f]{8}|[a-z][a-z0-9-]*)$/i,b=/^var\(--[a-z_][a-z0-9_-]*\)$/i,x=/^[a-z0-9_#(),.%+\-\s/]*$/i,y=new Set(["color","color-mix","device-cmyk","hsl","hsla","hwb","lab","lch","oklab","oklch","rgb","rgba"]);function k(e){let r=[],t=0,i=0;for(let o=0;o<e.length;o++){let n=e[o];if("("===n?t++:")"===n?t--:","===n&&0===t&&(r.push(e.slice(i,o)),i=o+1),t<0)return[e]}return 0!==t?[e]:(r.push(e.slice(i)),r)}function B(e){return _(e,!1)}function _(e,r){if("string"!=typeof e)return;let t=e.trim();if(0===t.length||t.length>256)return;if(w.test(t))return t;if(!x.test(t))return;let i=t.indexOf("(");if(i<=0||!t.endsWith(")"))return;let o=0;for(let e of t)if("("===e)o++;else if(")"===e&&--o<0)return;if(0!==o)return;for(let e of t.matchAll(/([a-z][a-z0-9-]*)\s*\(/gi)){let t=e[1].toLowerCase();if(!(r&&"var"===t)&&!y.has(t))return}let n=t.slice(0,i).trim().toLowerCase();return r&&"var"===n||y.has(n)?t:void 0}function z(r,t=!1){let i=j(r);if(void 0===i)return;let o=i.toLowerCase();return"currentcolor"===o||t&&"none"===o||b.test(i)||null!==e(i)?i:void 0}function S(e){return`a color name, #RGB, #RGBA, #RRGGBB, #RRGGBBAA, rgb(), rgba(), hsl(), hsla(), transparent, currentColor${e?", none":""}, or var(--name)`}function j(e){return"string"==typeof e&&e.length<=256&&b.test(e)?e:_(e,!0)}var M=/^[a-z0-9_,'(). \t-]+$/i;function F(e){if("string"!=typeof e)return;let r=function(e){if(!e.includes('"')&&!e.includes("'"))return e;let r="";for(let t=0;t<e.length;t++){let i=e[t];if('"'!==i&&"'"!==i){r+=i;continue}let o=e.indexOf(i,t+1);if(o<0)return;let n=e.slice(t+1,o);if(n.includes('"')||n.includes("'"))return;r+=`'${n}'`,t=o}return r}(e.trim());if(void 0===r||0===r.length||r.length>256||!M.test(r))return;let t=0;for(let e of r)if("("===e)t++;else if(")"===e&&--t<0)return;if(0===t){for(let e of r.matchAll(/([a-z][a-z0-9-]*)\s*\(/gi))if("var"!==e[1].toLowerCase())return;if(!/\b(?:url|expression|import)\b/i.test(r))return r}}function A(e){let r=F(e);if(void 0===r)throw Error("font family must be a safe non-fetching CSS family or var() fallback");return r}function E(e,r){let t=new WeakSet,i=0,o=e=>{if(!(i>r)){if("string"==typeof e){i+=4*e.length+16;return}if(null===e||"object"!=typeof e){i+=16;return}if(t.has(e)){i+=8;return}if(t.add(e),i+=64,e instanceof Map){for(let[t,n]of e)if(i+=32,o(t),o(n),i>r)break}else if(e instanceof Set){for(let t of e)if(i+=16,o(t),i>r)break}else if(e instanceof ArrayBuffer)i+=e.byteLength;else if(ArrayBuffer.isView(e))o(e.buffer);else for(let t of Object.keys(e))if(i+=2*t.length+16,o(e[t]),i>r)break}};return o(e),i}var C={bg:"#FFFFFF",fg:"#27272A"};function O(e){if(!e.shadow)return"";let r=function(e){if(e.replace("#","").length<6)return!1;let[r,t,i]=l(e);return $(r,t,i)/255<.4}(e.bg);return` <filter id="bm-shadow" x="-12%" y="-10%" width="128%" height="136%">
1
+ import{Aa as e,B as r,N as t,Q as i,R as o,fb as n,ib as s,kb as a,la as l,mb as f,na as u,oa as c,ra as d,sa as g,ta as h,va as v,xa as p,za as $}from"./chunk-SZAI2WB4.js";import{a as m}from"./chunk-YHMTSXIR.js";var w=/^(?:#[0-9a-f]{3,4}|#[0-9a-f]{6}|#[0-9a-f]{8}|[a-z][a-z0-9-]*)$/i,b=/^var\(--[a-z_][a-z0-9_-]*\)$/i,x=/^[a-z0-9_#(),.%+\-\s/]*$/i,y=new Set(["color","color-mix","device-cmyk","hsl","hsla","hwb","lab","lch","oklab","oklch","rgb","rgba"]);function k(e){let r=[],t=0,i=0;for(let o=0;o<e.length;o++){let n=e[o];if("("===n?t++:")"===n?t--:","===n&&0===t&&(r.push(e.slice(i,o)),i=o+1),t<0)return[e]}return 0!==t?[e]:(r.push(e.slice(i)),r)}function B(e){return _(e,!1)}function _(e,r){if("string"!=typeof e)return;let t=e.trim();if(0===t.length||t.length>256)return;if(w.test(t))return t;if(!x.test(t))return;let i=t.indexOf("(");if(i<=0||!t.endsWith(")"))return;let o=0;for(let e of t)if("("===e)o++;else if(")"===e&&--o<0)return;if(0!==o)return;for(let e of t.matchAll(/([a-z][a-z0-9-]*)\s*\(/gi)){let t=e[1].toLowerCase();if(!(r&&"var"===t)&&!y.has(t))return}let n=t.slice(0,i).trim().toLowerCase();return r&&"var"===n||y.has(n)?t:void 0}function S(r,t=!1){let i=j(r);if(void 0===i)return;let o=i.toLowerCase();return"currentcolor"===o||t&&"none"===o||b.test(i)||null!==e(i)?i:void 0}function z(e){return`a color name, #RGB, #RGBA, #RRGGBB, #RRGGBBAA, rgb(), rgba(), hsl(), hsla(), transparent, currentColor${e?", none":""}, or var(--name)`}function j(e){return"string"==typeof e&&e.length<=256&&b.test(e)?e:_(e,!0)}var M=/^[a-z0-9_,'(). \t-]+$/i;function F(e){if("string"!=typeof e)return;let r=function(e){if(!e.includes('"')&&!e.includes("'"))return e;let r="";for(let t=0;t<e.length;t++){let i=e[t];if('"'!==i&&"'"!==i){r+=i;continue}let o=e.indexOf(i,t+1);if(o<0)return;let n=e.slice(t+1,o);if(n.includes('"')||n.includes("'"))return;r+=`'${n}'`,t=o}return r}(e.trim());if(void 0===r||0===r.length||r.length>256||!M.test(r))return;let t=0;for(let e of r)if("("===e)t++;else if(")"===e&&--t<0)return;if(0===t){for(let e of r.matchAll(/([a-z][a-z0-9-]*)\s*\(/gi))if("var"!==e[1].toLowerCase())return;if(!/\b(?:url|expression|import)\b/i.test(r))return r}}function A(e){let r=F(e);if(void 0===r)throw Error("font family must be a safe non-fetching CSS family or var() fallback");return r}function E(e,r){let t=new WeakSet,i=0,o=e=>{if(!(i>r)){if("string"==typeof e){i+=4*e.length+16;return}if(null===e||"object"!=typeof e){i+=16;return}if(t.has(e)){i+=8;return}if(t.add(e),i+=64,e instanceof Map){for(let[t,n]of e)if(i+=32,o(t),o(n),i>r)break}else if(e instanceof Set){for(let t of e)if(i+=16,o(t),i>r)break}else if(e instanceof ArrayBuffer)i+=e.byteLength;else if(ArrayBuffer.isView(e))o(e.buffer);else for(let t of Object.keys(e))if(i+=2*t.length+16,o(e[t]),i>r)break}};return o(e),i}var C={bg:"#FFFFFF",fg:"#27272A"};function O(e){if(!e.shadow)return"";let r=function(e){if(e.replace("#","").length<6)return!1;let[r,t,i]=l(e);return $(r,t,i)/255<.4}(e.bg);return` <filter id="bm-shadow" x="-12%" y="-10%" width="128%" height="136%">
2
2
  <feDropShadow dx="0" dy="1.5" stdDeviation="2.5" flood-color="${r?"#ffffff":"#000000"}" flood-opacity="${r?"0.12":"0.08"}" />
3
3
  </filter>`}function R(e){return/^[A-Za-z0-9][A-Za-z0-9 _-]*$/.test(e)}function L(e,r,t,i=!1){e=A(e);let o=i?[...R(e)?[`@import url('https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@400;500;600;700&amp;display=swap');`]:[],...r?["@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&amp;display=swap');"]:[]]:[],n=`
4
4
  /* Derived from --bg and --fg (overridable via --line, --accent, etc.) */
@@ -16,7 +16,7 @@ import{Aa as e,B as r,N as t,Q as i,R as o,fb as n,ib as s,kb as a,la as l,mb as
16
16
  --_key-badge: color-mix(in srgb, var(--fg) 10%, var(--bg));`,s=t?`
17
17
  .node, .class-node, .entity, .actor[data-type="participant"], .note, .block, .timeline-event, .journey-task, .sankey-node { filter: url(#bm-shadow); }`:"",a=` svg { font-family: var(--font, ${R(e)?`'${e}'`:e}), system-ui, sans-serif; }`;return["<style>",...o.length>0?[` ${o.join(`
18
18
  `)}`,a]:[a],...r?[" .mono { font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace; }"]:[],` svg {${n}`,` }${s}`,"</style>"].join(`
19
- `)}function W(e,r,t,n,s){let a=void 0===t.font?void 0:A(t.font);for(let e of["bg","fg","line","accent","muted","surface","border"]){let r=t[e];void 0!==r&&function(e,r){if(void 0===j(e))throw Error(`${r} must be a safe non-fetching CSS color or var() reference`)}(r,e)}let l=[`--bg:${t.bg}`,`--fg:${t.fg}`,t.line?`--line:${t.line}`:"",t.accent?`--accent:${t.accent}`:"",t.muted?`--muted:${t.muted}`:"",t.surface?`--surface:${t.surface}`:"",t.border?`--border:${t.border}`:"",a?`--font:${a}`:""].filter(Boolean).join(";"),f=s&&("width"in s||"height"in s||"style"in s||"attrs"in s)?s:void 0,u=f?.attrs??s??{},c=`${l}${n?"":";background:var(--bg)"}${f?.style?`;${f.style}`:""}`,d=Object.entries(u).filter(([,e])=>void 0!==e).map(([e,r])=>`${e}="${r}"`).join(" "),g=d?` ${d}`:"";return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${i(e)} ${i(r)}" width="${o("width",String(f?.width??e))}" height="${o("height",String(f?.height??r))}" style="${c}"${g}>`}var D=new r(64,262144);function I(r){let t=[r.bg,r.fg,r.line,r.accent,r.muted,r.surface,r.border].join(`
20
- `),i=D.get(t);if(i)return i;let o=Object.freeze(function(r){let{bg:t,fg:i}=r,o=r.surface??c(i,t,3),n=c(i,t,5),s=c(i,t,10),a=H(r,[t,o,n,s]),{text:l,textSec:f,textMuted:h,textFaint:p}=a.legible?a:H(r,[t,n,s]);return{bg:t,fg:i,text:l,textSec:f,textMuted:h,textFaint:p,line:g(r.line??c(i,t,50),t,3,l),arrow:g(r.accent??c(i,t,85),t,3,l),nodeFill:o,nodeStroke:function(r,t,i){let o=e(r),n=e(t);if(!o||!n||1!==o[3]||1!==n[3])return r;let s=u(o[0],o[1],o[2]),a=u(n[0],n[1],n[2]);if((d(s,a)??1/0)>=v)return r;let l=e(i);return g(s,a,v,l?.[3]===1?u(l[0],l[1],l[2]):void 0)}(r.border??c(i,t,20),t,l),groupFill:t,groupHdr:n,innerStroke:c(i,t,12),keyBadge:s}}(G(r)??r)),n=2*t.length+E(o,262144);return D.set(t,o,n),o}function G(r){if(p(r.bg)&&p(r.fg))return r;let t=e(r.bg),i=e(r.fg);if(!(!t||!i||1!==t[3]||1!==i[3]))return{...r,bg:u(t[0],t[1],t[2]),fg:u(i[0],i[1],i[2])}}function H(e,r){let{bg:t,fg:i}=e,o=U(i,r),n=U(e.muted??c(i,t,78),r,o),s=U(e.muted??c(i,t,66),r,o),a=U(c(i,t,54),r,o,v),l=(e,t)=>r.every(r=>(d(e,r)??1/0)>=t),f=[o,n,s].every(e=>l(e,h))&&l(a,v);return{text:o,textSec:n,textMuted:s,textFaint:a,legible:f}}function U(e,r,t,i=h){let o=e;for(let e=0;e<2;e++)for(let e of r)o=g(o,e,i,t);return o}function P(e){if(!G(e))return;let r=I(e),t=new Map;return t.set("bg",r.bg),t.set("fg",r.fg),e.line&&p(e.line)&&t.set("line",e.line),e.accent&&p(e.accent)&&t.set("accent",e.accent),e.muted&&p(e.muted)&&t.set("muted",e.muted),e.surface&&p(e.surface)&&t.set("surface",e.surface),e.border&&p(e.border)&&t.set("border",e.border),t.set("_text",r.text),t.set("_text-sec",r.textSec),t.set("_text-muted",r.textMuted),t.set("_text-faint",r.textFaint),t.set("_line",r.line),t.set("_arrow",r.arrow),t.set("_node-fill",r.nodeFill),t.set("_node-stroke",r.nodeStroke),t.set("_group-fill",r.groupFill),t.set("_group-hdr",r.groupHdr),t.set("_inner-stroke",r.innerStroke),t.set("_key-badge",r.keyBadge),t}function J(e,r){if(p(e))return e;let t=e.match(/^var\(\s*--([\w-]+)\s*(?:,\s*(#[0-9a-fA-F]{3,8})\s*)?\)$/);if(t)return P(r)?.get(t[1])??t[2]}function K(r){let t=new Map;for(let i of r.styleContexts)for(let o of r.source.slice(i.start,i.end).matchAll(/--([\w-]+)\s*:\s*([^;{}]+)/g)){let r=o[2].trim();("none"===r||"currentcolor"===r.toLowerCase()||e(r)||r.startsWith("var(")&&j(r))&&t.set(o[1],r)}return t}function N(e,r){let t=Y(r,e);return t?Z(e,t):e}function T(e,r){return X(t(e),Y(r))}function V(){let e,r;return(i,o)=>{let n=t(i);if(o!==e){let t=Object.isFrozen(o)?Object.getOwnPropertyDescriptors(o):void 0;if(!(t&&Reflect.ownKeys(t).every(e=>"value"in t[e])&&["bg","fg","line","accent","muted","surface","border","font"].every(e=>{let r=t[e];return Object.hasOwn(t,e)&&(void 0===r.value||"string"==typeof r.value)})))return X(n,Y(o));r=Y(o),e=o}return X(n,r)}}function X(e,r){let t=r?r.resolveCss(e,r.vars,10):e;return r&&/[<"]/.test(t)?s(n(Z(`<rect fill="${e}"/>`,r))[0],"fill"):m(t)}function Y(e,r){let t=P(e);if(!t)return;let i=I(e),o=void 0===r?void 0:a(r),n=o?K(o):new Map;for(let[e,r]of t)(e.startsWith("_")||void 0!==r&&!n.has(e))&&n.set(e,r);n.set("bg",i.bg),n.set("fg",i.fg);let s=new Set(["font"]);for(let r of[e.font,e.line,e.accent,e.muted,e.surface,e.border])if(r)for(let e of r.matchAll(/var\(\s*--([\w-]+)/g))n.has(e[1])||s.add(e[1]);return{vars:n,SKIP_VARS:s,resolveCss:(e,r,t)=>{let o=e;for(let e=0;e<t;e++){let e=o;if((o=(o=(o=o.replace(/var\(--([\w-]+)\)/g,(e,t)=>s.has(t)?e:r.get(t)??e)).replace(/var\(--([\w-]+),\s*([^()]+)\)/g,(e,t,i)=>s.has(t)?e:r.get(t)??i.trim())).replace(/color-mix\(in srgb,\s*(#[0-9a-fA-F]{3,8})\s+(\d+(?:\.\d+)?)%,\s*(#[0-9a-fA-F]{3,8}|transparent)\)/g,(e,r,t,o)=>c(r,"transparent"===o?i.bg:o,parseFloat(t))))===e)break}return o},projection:o}}function Z(e,r){let{vars:t,SKIP_VARS:i,resolveCss:o}=r,n=r.projection??a(e),s=new Map,l=f(e,e=>{let r=s.get(e);if(void 0!==r)return r;let i=o(e,t,10);return s.set(e,i),i},n),u=l.includes("color-mix(");if(!u){for(let e of l.matchAll(/var\((?=\s*--([\w-]+))/g))if(!i.has(e[1])){u=!0;break}}if(!u)return l;let c=a(l),d=K(c);if(d.size>0)for(let e=0;e<5;e++){let e=f(l,e=>o(e,d,1),c);if(e===l)break;c=a(l=e)}return l}function q(e,r,t,i,o){let n={};return o?(n.role="img",n["aria-roledescription"]=o):(e||r)&&(n.role="img"),e&&(n["aria-labelledby"]=t),r&&(n["aria-describedby"]=i),n}function Q(e,r,t,i,o){if("start"!==t&&"end"!==t)throw TypeError("Arrow endpoint must be start or end");let{width:n,height:s}=r,a="start"===t?0:n,l="start"===t?n:0,f={id:e,shape:"arrow",size:{width:n,height:s},ref:{x:a,y:s/2},...o?{units:o}:{},orient:"auto",geometry:{kind:"polygon",points:[{x:l,y:0},{x:a,y:s/2},{x:l,y:s}]},paint:i};return et(f),f}function ee(e,r){if(!Number.isFinite(e))throw Error(`Marker ${r} must be finite`);return e}function er(e){return e.map(e=>`${ee(e.x,"point.x")} ${ee(e.y,"point.y")}`).join(", ")}function et(e){if("string"!=typeof e.id||""===e.id.trim())throw Error("Marker id must not be empty");if(!["arrow","open-arrow","circle","cross","triangle","diamond","diamond-open"].includes(String(e.shape)))throw Error(`Marker "${e.id}" has an unknown shape`);if(!e.geometry)throw Error(`Marker "${e.id}" must declare geometry`);if(!e.size)throw Error(`Marker "${e.id}" must declare marker size`);if(!e.ref)throw Error(`Marker "${e.id}" must declare a reference point`);if(!(e.size.width>0)||!(e.size.height>0))throw Error(`Marker "${e.id}" size must be positive`);if(ee(e.size.width,"size.width"),ee(e.size.height,"size.height"),ee(e.ref.x,"ref.x"),ee(e.ref.y,"ref.y"),void 0!==e.units&&"strokeWidth"!==e.units&&"userSpaceOnUse"!==e.units)throw Error(`Marker "${e.id}" units must be strokeWidth or userSpaceOnUse`);if("number"==typeof e.orient)ee(e.orient,"orient");else if(void 0!==e.orient&&"auto"!==e.orient&&"auto-start-reverse"!==e.orient)throw Error(`Marker "${e.id}" orient must be auto, auto-start-reverse, or a finite angle`);if(void 0!==e.overflow&&"hidden"!==e.overflow&&"visible"!==e.overflow)throw Error(`Marker "${e.id}" overflow must be hidden or visible`);if(e.viewBox&&(ee(e.viewBox.x,"viewBox.x"),ee(e.viewBox.y,"viewBox.y"),ee(e.viewBox.width,"viewBox.width"),ee(e.viewBox.height,"viewBox.height"),!(e.viewBox.width>0)||!(e.viewBox.height>0)))throw Error(`Marker "${e.id}" viewBox must be positive`)}function ei(e,r={}){et(e);let i=" ".repeat(r.indent??2),o=`${i} `,n=e.units,s=e.orient??"auto",a=[`id="${t(e.id)}"`,`markerWidth="${ee(e.size.width,"size.width")}"`,`markerHeight="${ee(e.size.height,"size.height")}"`,`refX="${ee(e.ref.x,"ref.x")}"`,`refY="${ee(e.ref.y,"ref.y")}"`,`orient="${t(String(s))}"`,...n?[`markerUnits="${t(n)}"`]:[],...e.viewBox?[`viewBox="${ee(e.viewBox.x,"viewBox.x")} ${ee(e.viewBox.y,"viewBox.y")} ${ee(e.viewBox.width,"viewBox.width")} ${ee(e.viewBox.height,"viewBox.height")}"`]:[],...e.overflow?[`overflow="${t(e.overflow)}"`]:[]];return[`${i}<marker ${a.join(" ")}>`,...function e(r,i,o){let n=function(e){if(!e)return"";let r=[];return void 0!==e.fill&&r.push(`fill="${t(e.fill)}"`),void 0!==e.stroke&&r.push(`stroke="${t(e.stroke)}"`),void 0!==e.strokeWidth&&r.push(`stroke-width="${t(e.strokeWidth)}"`),void 0!==e.strokeDasharray&&r.push(`stroke-dasharray="${t(e.strokeDasharray)}"`),void 0!==e.strokeDashoffset&&r.push(`stroke-dashoffset="${t(e.strokeDashoffset)}"`),void 0!==e.strokeLinecap&&r.push(`stroke-linecap="${t(e.strokeLinecap)}"`),void 0!==e.strokeLinejoin&&r.push(`stroke-linejoin="${t(e.strokeLinejoin)}"`),void 0!==e.strokeMiterlimit&&r.push(`stroke-miterlimit="${t(e.strokeMiterlimit)}"`),void 0!==e.vectorEffect&&r.push(`vector-effect="${t(e.vectorEffect)}"`),void 0!==e.paintOrder&&r.push(`paint-order="${t(e.paintOrder)}"`),void 0!==e.opacity&&r.push(`opacity="${t(e.opacity)}"`),r.length>0?` ${r.join(" ")}`:""}(i);switch(r.kind){case"rect":return[`${o}<rect x="${ee(r.x,"rect.x")}" y="${ee(r.y,"rect.y")}" width="${ee(r.width,"rect.width")}" height="${ee(r.height,"rect.height")}"${void 0!==r.rx?` rx="${ee(r.rx,"rect.rx")}"`:""}${void 0!==r.ry?` ry="${ee(r.ry,"rect.ry")}"`:""}${n} />`];case"circle":return[`${o}<circle cx="${ee(r.cx,"circle.cx")}" cy="${ee(r.cy,"circle.cy")}" r="${ee(r.r,"circle.r")}"${n} />`];case"ellipse":return[`${o}<ellipse cx="${ee(r.cx,"ellipse.cx")}" cy="${ee(r.cy,"ellipse.cy")}" rx="${ee(r.rx,"ellipse.rx")}" ry="${ee(r.ry,"ellipse.ry")}"${n} />`];case"line":return[`${o}<line x1="${ee(r.x1,"line.x1")}" y1="${ee(r.y1,"line.y1")}" x2="${ee(r.x2,"line.x2")}" y2="${ee(r.y2,"line.y2")}"${n} />`];case"polygon":return[`${o}<polygon points="${er(r.points)}"${n} />`];case"polyline":return[`${o}<polyline points="${er(r.points)}"${n} />`];case"path":return[`${o}<path d="${t(r.d)}"${n} />`];case"compound":return r.children.flatMap(r=>e(r,i,o))}}(e.geometry,e.paint,o),`${i}</marker>`].join(`
19
+ `)}function W(e,r,t,n,s){let a=void 0===t.font?void 0:A(t.font);for(let e of["bg","fg","line","accent","muted","surface","border"]){let r=t[e];void 0!==r&&function(e,r){if(void 0===j(e))throw Error(`${r} must be a safe non-fetching CSS color or var() reference`)}(r,e)}let l=[`--bg:${t.bg}`,`--fg:${t.fg}`,t.line?`--line:${t.line}`:"",t.accent?`--accent:${t.accent}`:"",t.muted?`--muted:${t.muted}`:"",t.surface?`--surface:${t.surface}`:"",t.border?`--border:${t.border}`:"",a?`--font:${a}`:""].filter(Boolean).join(";"),f=s&&("width"in s||"height"in s||"style"in s||"attrs"in s)?s:void 0,u=f?.attrs??s??{},c=`${l}${n?"":";background:var(--bg)"}${f?.style?`;${f.style}`:""}`,d=Object.entries(u).filter(([,e])=>void 0!==e).map(([e,r])=>`${e}="${r}"`).join(" "),g=d?` ${d}`:"";return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${i(e)} ${i(r)}" width="${o("width",String(f?.width??e))}" height="${o("height",String(f?.height??r))}" style="${c}"${g}>`}var D=new r(64,262144);function G(r){let t=[r.bg,r.fg,r.line,r.accent,r.muted,r.surface,r.border].join(`
20
+ `),i=D.get(t);if(i)return i;let o=Object.freeze(function(r){let{bg:t,fg:i}=r,o=r.surface??c(i,t,3),n=c(i,t,5),s=c(i,t,10),a=H(r,[t,o,n,s]),{text:l,textSec:f,textMuted:h,textFaint:p}=a.legible?a:H(r,[t,n,s]);return{bg:t,fg:i,text:l,textSec:f,textMuted:h,textFaint:p,line:g(r.line??c(i,t,50),t,3,l),arrow:g(r.accent??c(i,t,85),t,3,l),nodeFill:o,nodeStroke:function(r,t,i){let o=e(r),n=e(t);if(!o||!n||1!==o[3]||1!==n[3])return r;let s=u(o[0],o[1],o[2]),a=u(n[0],n[1],n[2]);if((d(s,a)??1/0)>=v)return r;let l=e(i);return g(s,a,v,l?.[3]===1?u(l[0],l[1],l[2]):void 0)}(r.border??c(i,t,20),t,l),groupFill:t,groupHdr:n,innerStroke:c(i,t,12),keyBadge:s}}(I(r)??r)),n=2*t.length+E(o,262144);return D.set(t,o,n),o}function I(r){if(p(r.bg)&&p(r.fg))return r;let t=e(r.bg),i=e(r.fg);if(!(!t||!i||1!==t[3]||1!==i[3]))return{...r,bg:u(t[0],t[1],t[2]),fg:u(i[0],i[1],i[2])}}function H(e,r){let{bg:t,fg:i}=e,o=U(i,r),n=U(e.muted??c(i,t,78),r,o),s=U(e.muted??c(i,t,66),r,o),a=U(c(i,t,54),r,o,v),l=(e,t)=>r.every(r=>(d(e,r)??1/0)>=t),f=[o,n,s].every(e=>l(e,h))&&l(a,v);return{text:o,textSec:n,textMuted:s,textFaint:a,legible:f}}function U(e,r,t,i=h){let o=e;for(let e=0;e<2;e++)for(let e of r)o=g(o,e,i,t);return o}function P(e){if(!I(e))return;let r=G(e),t=new Map;return t.set("bg",r.bg),t.set("fg",r.fg),e.line&&p(e.line)&&t.set("line",e.line),e.accent&&p(e.accent)&&t.set("accent",e.accent),e.muted&&p(e.muted)&&t.set("muted",e.muted),e.surface&&p(e.surface)&&t.set("surface",e.surface),e.border&&p(e.border)&&t.set("border",e.border),t.set("_text",r.text),t.set("_text-sec",r.textSec),t.set("_text-muted",r.textMuted),t.set("_text-faint",r.textFaint),t.set("_line",r.line),t.set("_arrow",r.arrow),t.set("_node-fill",r.nodeFill),t.set("_node-stroke",r.nodeStroke),t.set("_group-fill",r.groupFill),t.set("_group-hdr",r.groupHdr),t.set("_inner-stroke",r.innerStroke),t.set("_key-badge",r.keyBadge),t}function Z(e,r){if(p(e))return e;let t=e.match(/^var\(\s*--([\w-]+)\s*(?:,\s*(#[0-9a-fA-F]{3,8})\s*)?\)$/);if(t)return P(r)?.get(t[1])??t[2]}function K(r){let t=new Map;for(let i of r.styleContexts)for(let o of r.source.slice(i.start,i.end).matchAll(/--([\w-]+)\s*:\s*([^;{}]+)/g)){let r=o[2].trim();("none"===r||"currentcolor"===r.toLowerCase()||e(r)||r.startsWith("var(")&&j(r))&&t.set(o[1],r)}return t}function N(e,r){let t=q(r,e);return t?J(e,t):e}function T(e,r){return X(t(e),q(r))}function V(){let e,r;return(i,o)=>{let n=t(i);if(o!==e){let t=Object.isFrozen(o)?Object.getOwnPropertyDescriptors(o):void 0;if(!(t&&Reflect.ownKeys(t).every(e=>"value"in t[e])&&["bg","fg","line","accent","muted","surface","border","font"].every(e=>{let r=t[e];return Object.hasOwn(t,e)&&(void 0===r.value||"string"==typeof r.value)})))return X(n,q(o));r=q(o),e=o}return X(n,r)}}function X(e,r){let t=r?r.resolveCss(e,r.vars,10):e;return r&&/[<"]/.test(t)?s(n(J(`<rect fill="${e}"/>`,r))[0],"fill"):m(t)}function q(e,r){let t=P(e);if(!t)return;let i=G(e),o=void 0===r?void 0:a(r),n=o?K(o):new Map;for(let[e,r]of t)(e.startsWith("_")||void 0!==r&&!n.has(e))&&n.set(e,r);n.set("bg",i.bg),n.set("fg",i.fg);let s=new Set(["font"]);for(let r of[e.font,e.line,e.accent,e.muted,e.surface,e.border])if(r)for(let e of r.matchAll(/var\(\s*--([\w-]+)/g))n.has(e[1])||s.add(e[1]);return{vars:n,SKIP_VARS:s,resolveCss:(e,r,t)=>{let o=e;for(let e=0;e<t;e++){let e=o;if((o=(o=(o=o.replace(/var\(--([\w-]+)\)/g,(e,t)=>s.has(t)?e:r.get(t)??e)).replace(/var\(--([\w-]+),\s*([^()]+)\)/g,(e,t,i)=>s.has(t)?e:r.get(t)??i.trim())).replace(/color-mix\(in srgb,\s*(#[0-9a-fA-F]{3,8})\s+(\d+(?:\.\d+)?)%,\s*(#[0-9a-fA-F]{3,8}|transparent)\)/g,(e,r,t,o)=>c(r,"transparent"===o?i.bg:o,parseFloat(t))))===e)break}return o},projection:o}}function J(e,r){let{vars:t,SKIP_VARS:i,resolveCss:o}=r,n=r.projection??a(e),s=new Map,l=f(e,e=>{let r=s.get(e);if(void 0!==r)return r;let i=o(e,t,10);return s.set(e,i),i},n),u=l.includes("color-mix(");if(!u){for(let e of l.matchAll(/var\((?=\s*--([\w-]+))/g))if(!i.has(e[1])){u=!0;break}}if(!u)return l;let c=a(l),d=K(c);if(d.size>0)for(let e=0;e<5;e++){let e=f(l,e=>o(e,d,1),c);if(e===l)break;c=a(l=e)}return l}function Y(e,r,t,i,o){let n={};return o?(n.role="img",n["aria-roledescription"]=o):(e||r)&&(n.role="img"),e&&(n["aria-labelledby"]=t),r&&(n["aria-describedby"]=i),n}function Q(e,r,t,i,o){if("start"!==t&&"end"!==t)throw TypeError("Arrow endpoint must be start or end");let{width:n,height:s}=r,a="start"===t?0:n,l="start"===t?n:0,f={id:e,shape:"arrow",size:{width:n,height:s},ref:{x:a,y:s/2},...o?{units:o}:{},orient:"auto",geometry:{kind:"polygon",points:[{x:l,y:0},{x:a,y:s/2},{x:l,y:s}]},paint:i};return et(f),f}function ee(e,r){if(!Number.isFinite(e))throw Error(`Marker ${r} must be finite`);return e}function er(e){return e.map(e=>`${ee(e.x,"point.x")} ${ee(e.y,"point.y")}`).join(", ")}function et(e){if("string"!=typeof e.id||""===e.id.trim())throw Error("Marker id must not be empty");if(!["arrow","open-arrow","circle","cross","triangle","diamond","diamond-open"].includes(String(e.shape)))throw Error(`Marker "${e.id}" has an unknown shape`);if(!e.geometry)throw Error(`Marker "${e.id}" must declare geometry`);if(!e.size)throw Error(`Marker "${e.id}" must declare marker size`);if(!e.ref)throw Error(`Marker "${e.id}" must declare a reference point`);if(!(e.size.width>0)||!(e.size.height>0))throw Error(`Marker "${e.id}" size must be positive`);if(ee(e.size.width,"size.width"),ee(e.size.height,"size.height"),ee(e.ref.x,"ref.x"),ee(e.ref.y,"ref.y"),void 0!==e.units&&"strokeWidth"!==e.units&&"userSpaceOnUse"!==e.units)throw Error(`Marker "${e.id}" units must be strokeWidth or userSpaceOnUse`);if("number"==typeof e.orient)ee(e.orient,"orient");else if(void 0!==e.orient&&"auto"!==e.orient&&"auto-start-reverse"!==e.orient)throw Error(`Marker "${e.id}" orient must be auto, auto-start-reverse, or a finite angle`);if(void 0!==e.overflow&&"hidden"!==e.overflow&&"visible"!==e.overflow)throw Error(`Marker "${e.id}" overflow must be hidden or visible`);if(e.viewBox&&(ee(e.viewBox.x,"viewBox.x"),ee(e.viewBox.y,"viewBox.y"),ee(e.viewBox.width,"viewBox.width"),ee(e.viewBox.height,"viewBox.height"),!(e.viewBox.width>0)||!(e.viewBox.height>0)))throw Error(`Marker "${e.id}" viewBox must be positive`)}function ei(e,r={}){et(e);let i=" ".repeat(r.indent??2),o=`${i} `,n=e.units,s=e.orient??"auto",a=[`id="${t(e.id)}"`,`markerWidth="${ee(e.size.width,"size.width")}"`,`markerHeight="${ee(e.size.height,"size.height")}"`,`refX="${ee(e.ref.x,"ref.x")}"`,`refY="${ee(e.ref.y,"ref.y")}"`,`orient="${t(String(s))}"`,...n?[`markerUnits="${t(n)}"`]:[],...e.viewBox?[`viewBox="${ee(e.viewBox.x,"viewBox.x")} ${ee(e.viewBox.y,"viewBox.y")} ${ee(e.viewBox.width,"viewBox.width")} ${ee(e.viewBox.height,"viewBox.height")}"`]:[],...e.overflow?[`overflow="${t(e.overflow)}"`]:[]];return[`${i}<marker ${a.join(" ")}>`,...function e(r,i,o){let n=function(e){if(!e)return"";let r=[];return void 0!==e.fill&&r.push(`fill="${t(e.fill)}"`),void 0!==e.stroke&&r.push(`stroke="${t(e.stroke)}"`),void 0!==e.strokeWidth&&r.push(`stroke-width="${t(e.strokeWidth)}"`),void 0!==e.strokeDasharray&&r.push(`stroke-dasharray="${t(e.strokeDasharray)}"`),void 0!==e.strokeDashoffset&&r.push(`stroke-dashoffset="${t(e.strokeDashoffset)}"`),void 0!==e.strokeLinecap&&r.push(`stroke-linecap="${t(e.strokeLinecap)}"`),void 0!==e.strokeLinejoin&&r.push(`stroke-linejoin="${t(e.strokeLinejoin)}"`),void 0!==e.strokeMiterlimit&&r.push(`stroke-miterlimit="${t(e.strokeMiterlimit)}"`),void 0!==e.vectorEffect&&r.push(`vector-effect="${t(e.vectorEffect)}"`),void 0!==e.paintOrder&&r.push(`paint-order="${t(e.paintOrder)}"`),void 0!==e.opacity&&r.push(`opacity="${t(e.opacity)}"`),r.length>0?` ${r.join(" ")}`:""}(i);switch(r.kind){case"rect":return[`${o}<rect x="${ee(r.x,"rect.x")}" y="${ee(r.y,"rect.y")}" width="${ee(r.width,"rect.width")}" height="${ee(r.height,"rect.height")}"${void 0!==r.rx?` rx="${ee(r.rx,"rect.rx")}"`:""}${void 0!==r.ry?` ry="${ee(r.ry,"rect.ry")}"`:""}${n} />`];case"circle":return[`${o}<circle cx="${ee(r.cx,"circle.cx")}" cy="${ee(r.cy,"circle.cy")}" r="${ee(r.r,"circle.r")}"${n} />`];case"ellipse":return[`${o}<ellipse cx="${ee(r.cx,"ellipse.cx")}" cy="${ee(r.cy,"ellipse.cy")}" rx="${ee(r.rx,"ellipse.rx")}" ry="${ee(r.ry,"ellipse.ry")}"${n} />`];case"line":return[`${o}<line x1="${ee(r.x1,"line.x1")}" y1="${ee(r.y1,"line.y1")}" x2="${ee(r.x2,"line.x2")}" y2="${ee(r.y2,"line.y2")}"${n} />`];case"polygon":return[`${o}<polygon points="${er(r.points)}"${n} />`];case"polyline":return[`${o}<polyline points="${er(r.points)}"${n} />`];case"path":return[`${o}<path d="${t(r.d)}"${n} />`];case"compound":return r.children.flatMap(r=>e(r,i,o))}}(e.geometry,e.paint,o),`${i}</marker>`].join(`
21
21
  `)}function eo(e,r={}){let t=new Set;for(let r of e){if(t.has(r.id))throw Error(`Duplicate marker resource "${r.id}"`);t.add(r.id)}return e.map(e=>ei(e,r)).join(`
22
- `)}export{k as a,B as b,z as c,S as d,j as e,F as f,E as g,C as h,O as i,L as j,W as k,I as l,J as m,N as n,T as o,V as p,q as q,Q as r,et as s,ei as t,eo as u};
22
+ `)}export{k as a,B as b,S as c,z as d,j as e,F as f,E as g,C as h,O as i,L as j,W as k,G as l,Z as m,N as n,T as o,V as p,Y as q,Q as r,et as s,ei as t,eo as u};
@@ -1 +1 @@
1
- import{Aa as t,Ca as e,la as r,ma as n,na as a,oa as l,pa as i,ta as o,ya as f}from"./chunk-EIYLJ4FI.js";var u="#3b82f6";function h(t){let[e,n,a]=r(t),l=e/255,i=n/255,o=a/255,f=Math.max(l,i,o),u=Math.min(l,i,o),h=(f+u)/2;if(f===u)return[0,0,100*h];let s=f-u;return[360*(f===l?((i-o)/s+6*(i<o))/6:f===i?((o-l)/s+2)/6:((l-i)/s+4)/6),100*(h>.5?s/(2-f-u):s/(f+u)),100*h]}function s(t,e,r){let n=r/100,a=e/100*(1-Math.abs(2*n-1)),l=a*(1-Math.abs(t/60%2-1)),i=n-a/2,o,f,u;t<60?(o=a,f=l,u=0):t<120?(o=l,f=a,u=0):t<180?(o=0,f=a,u=l):t<240?(o=0,f=l,u=a):t<300?(o=l,f=0,u=a):(o=a,f=0,u=l);let h=t=>Math.round((t+i)*255).toString(16).padStart(2,"0");return`#${h(o)}${h(f)}${h(u)}`}function c(t){return f(t)}function d(t){return h(t)[2]<50}function b(t){return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function L(t){let e=n(t);if(!e)return null;let r=i(e[0]/255),a=i(e[1]/255),l=i(e[2]/255),o=Math.cbrt(.4122214708*r+.5363325363*a+.0514459929*l),f=Math.cbrt(.2119034982*r+.6806995451*a+.1073969566*l),u=Math.cbrt(.0883024619*r+.2817188376*a+.6299787005*l);return{L:.2104542553*o+.793617785*f-.0040720468*u,a:1.9779984951*o-2.428592205*f+.4505937099*u,b:.0259040371*o+.7827717662*f-.808675766*u}}function v(t){var e;let r,n,l,i,o,f,u;return n=(r=t.h*Math.PI/180,e={L:t.L,a:t.C*Math.cos(r),b:t.C*Math.sin(r)}).L+.3963377774*e.a+.2158037573*e.b,l=e.L-.1055613458*e.a-.0638541728*e.b,i=e.L-.0894841775*e.a-1.291485548*e.b,a(255*b(4.0767416621*(o=n*n*n)-3.3077115913*(f=l*l*l)+.2309699292*(u=i*i*i)),255*b(-1.2684380046*o+2.6097574011*f-.3413193965*u),255*b(-.0041960863*o-.7034186147*f+1.707614701*u))}function M(t){let e,r,n=L(t);return n?(e=Math.hypot(n.a,n.b),r=(180*Math.atan2(n.b,n.a)/Math.PI+360)%360,{L:n.L,C:e,h:r}):null}function m(t,e){let r=L(t),n=L(e);return r&&n?Math.hypot(r.L-n.L,r.a-n.a,r.b-n.b):null}function p(t){let e=1/0;for(let r=0;r<t.length;r++)for(let n=r+1;n<t.length;n++){let a=m(t[r],t[n]);null!==a&&a<e&&(e=a)}return e}function C(t){let e=n(t);if(!e)return null;let r=.2126729*(e[0]/255)**2.4+.7151522*(e[1]/255)**2.4+.072175*(e[2]/255)**2.4;return r<.022?r+(.022-r)**1.414:r}function g(t,e){let r,n,a,l=(n=C(t),a=C(e),null===n||null===a?null:5e-4>Math.abs(a-n)?0:100*(a>n?(r=(a**.56-n**.57)*1.14)<.1?0:r-.027:(r=(a**.65-n**.62)*1.14)>-.1?0:r+.027));return null===l?null:Math.abs(l)}function x(t,e={}){return function(t,e,r){var n,a;let l,i,o,f,b,v,m,p,C,g=k(e.labelInk),x,D=void 0===g?void 0:()=>x??=$(k(e.bg),void 0,g);if(t<=6){let r=e.accent??u;return function(t,e,r,n,a){let l=k(e),i=t.map(t=>k(t,l));if(i.some(t=>void 0===t))return t;let o=((void 0===l?null:L(l))?.L??1)<.55,f=i.map(t=>{if(w(t,l,n))return t;let e=M(t);return e?y(e,l,o,r,n,a):t});return(f.length>1?A(f,l,o,r,n,a):f).map((e,r)=>e===i[r]?t[r]:e)}(Array.from({length:Math.max(0,t)},(t,n)=>(function(t,e,r){if(0===t)return e;let n=c(e)?e:u,a=r&&c(r)?r:void 0,[l,i]=h(n),o=Math.max(55,Math.min(85,i)),f=Math.ceil(t/2),b=t%2==1,L=a&&d(a)?!b:b,v=L?Math.max(25,48-13*f):Math.min(78,55+11*f);return s(((l+(L?-8:12)*f)%360+360)%360,o,v)})(n,r,e.bg)),e.bg,void 0,g,D)}let E=k(e.bg);return n=k(e.accent,E)??u,a=void 0,o=(i=(l=M(n)??{L:.6,C:.16,h:264}).C<.03)?264:l.h,f=Math.max(.11,Math.min(.16,i?.16:l.C)),v=(b=((void 0===E?null:L(E))?.L??1)<.55)?[.74,.6]:[.56,.7],m=360/t,p=Array.from({length:t},(t,e)=>{if(0===e&&w(n,E,g))return n;let r=0===e?o:((o+e*m)%360+360)%360;return y({L:0===e?l.L:v[e%2],C:f,h:r},E,b,a,g,D)}),t<=24?A(p,E,b,a,g,D):(C=new Set,p.map((t,e)=>{if(a&&a.tailItems++,!C.has(t.toLowerCase()))return C.add(t.toLowerCase()),t;let r=M(t);if(r)for(let t=1;t<=24;t++){a&&a.candidateEvaluations++;let n=y({...r,L:F(r.L+(t%2==0?1:-1)*Math.ceil(t/2)*.008),h:(r.h+137.508*t+.01*e)%360},E,b,a,g,D);if(!C.has(n.toLowerCase()))return C.add(n.toLowerCase()),n}return t}))}(t,e)}function k(e,r){if(void 0===e)return;let n=t(e);if(!n)return;if(1===n[3])return a(n[0],n[1],n[2]);if(void 0===r)return;let l=t(r);if(!(!l||1!==l[3]))return a(n[0]*n[3]+l[0]*(1-n[3]),n[1]*n[3]+l[1]*(1-n[3]),n[2]*n[3]+l[2]*(1-n[3]))}function w(t,r,n){if(void 0!==n&&(e(t,n)??0)<o)return!1;if(void 0===r)return!0;let a=e(t,r),l=g(t,r);return null!==a&&null!==l&&a>=1.25&&l>=15}function y(t,e,r,n,a,l){n&&n.candidateEvaluations++;let i=v(t);if(w(i,e,a))return i;let o=(void 0===e?void 0:L(e))?.L??+!r,f=t.L>=o?1:-1;for(let r=1;r<=24;r++){let l=.04*r;for(let r of[f,-f]){n&&n.candidateEvaluations++;let i=v({...t,L:F(t.L+r*l)});if(w(i,e,a))return i}}let u=["#000000","#ffffff"].filter(t=>w(t,e,a));if(u.length>0)return u.sort((t,r)=>void 0===e?0:(g(r,e)??0)-(g(t,e)??0))[0];if(void 0!==a){let t=L(i),r,o=1/0;for(let i of l?.()??$(e,n,a)){n&&(n.candidateEvaluations++,t&&n.pairDistanceChecks++);let e=t?P(i.lab,t):0;e<o&&(r=i,o=e)}if(r)return r.hex;D()}return i}function D(){throw Error("Cannot derive categorical fills within bounded search with readable label ink, page visibility and distinct peer colors; select a different textColor or explicit fillColor")}function E(e,r,n){let i=void 0===r?null:t(r);if(!i||1!==i[3])return e;let o=a(i[0],i[1],i[2]),f=t(e);if(!f||1!==f[3])return e;let u=a(f[0],f[1],f[2]),h=t=>l(t,o,n);if(w(h(u),o))return e;let s=M(u);if(!s)return e;let c=L(o)?.L??1,d=s.L>=c?1:-1;for(let t=1;t<=24;t++){let e=.04*t;for(let t of[d,-d]){let r=v({...s,L:F(s.L+t*e)});if(w(h(r),o))return r}}return["#000000","#ffffff"].sort((t,e)=>(g(h(e),o)??0)-(g(h(t),o)??0))[0]}function A(t,e,r,n,a,l){let i=[];for(let l=0;l<t.length;l++){let o=t[l],f=0===l&&w(o,e,a);i.push(f||S(o,i,n)>=.1?o:function(t,e,r,n,a,l){let i=M(t);if(!i)return t;let o=t,f=S(t,e,a);for(let t=1;t<=12;t++){let u=.03*t,h=7*t;for(let t of[{...i,L:F(i.L+u)},{...i,L:F(i.L-u)},{...i,h:(i.h+h)%360},{...i,h:(i.h-h+360)%360},{...i,L:F(n?i.L+u:i.L-u),h:(i.h+h)%360}]){a&&a.candidateEvaluations++;let n=v(t);if(!w(n,r,l))continue;let i=S(n,e,a);if(i>=.1)return n;i>f&&(f=i,o=n)}}return o}(o,i,e,r,n,a))}if(n&&(n.pairDistanceChecks+=i.length*(i.length-1)/2),p(i)>=.1)return i;let o=function(t,e,r,n,a){if(t.length<2)return t;let l=void 0===n?J:P,i=a?.()??$(e,r,n),o=L(t[0]);if(!o)return t;let f={hex:t[0],lab:o},u=void 0===n?void 0:Float64Array.from(i,t=>(r&&r.pairDistanceChecks++,l(t.lab,f.lab))),h=e=>{let a=e?[f,e]:[f],o=new Set(a.map(t=>t.hex.toLowerCase())),h=u?.slice(),s=t=>{if(h)for(let e=0;e<i.length;e++)r&&r.pairDistanceChecks++,h[e]=Math.min(h[e],l(i[e].lab,t.lab))};for(e&&s(e);a.length<t.length;){let e,f=-1,u=1/0,c=L(t[a.length]);for(let t=0;t<i.length;t++){let s=i[t];if(o.has(s.hex.toLowerCase()))continue;r&&r.candidateEvaluations++;let d=h?.[t]??1/0;if(!h)for(let t of a)r&&r.pairDistanceChecks++,d=Math.min(d,l(s.lab,t.lab));c&&void 0!==n&&r&&r.pairDistanceChecks++;let b=c?l(s.lab,c):0;(d>f+1e-12||1e-12>=Math.abs(d-f)&&b<u)&&(e=s,f=d,u=b)}if(!e)return t;a.push(e),o.add(e.hex.toLowerCase()),s(e)}return a.map(t=>t.hex)},s=h();if(void 0===n)return s;let c=I(s,r);if(c>=.1)return s;let d=s;for(let t of s.slice(2)){let e=L(t);if(!e||(r&&r.pairDistanceChecks++,.1>l(f.lab,e)))continue;let n=h({hex:t,lab:e}),a=I(n,r);if(a>=.1)return n;a>c&&(d=n,c=a)}let b=d.map(t=>({hex:t,lab:L(t)})),v=b.length,M=new Float64Array(i.length*v),m=t=>{for(let e=0;e<i.length;e++)r&&r.pairDistanceChecks++,M[e*v+t]=l(i[e].lab,b[t].lab)};for(let t=0;t<v;t++)m(t);for(let t=0;t<24;t++){let t=!1;for(let e=1;e<v;e++){let n,a=1/0;for(let t=0;t<v;t++)t!==e&&(r&&r.pairDistanceChecks++,a=Math.min(a,l(b[e].lab,b[t].lab)));for(let t=0;t<i.length;t++){r&&r.candidateEvaluations++;let l=1/0;for(let r=0;r<v&&!(r!==e&&(l=Math.min(l,M[t*v+r]))<=a+1e-12);r++);l>a+1e-12&&(a=l,n=i[t])}n&&(b[e]=n,m(e),t=!0)}let e=b.map(t=>t.hex);if(I(e,r)>=.1)return e;if(!t)break}return b.map(t=>t.hex)}(i,e,n,a,l);return void 0!==a&&.1>I(o,n)&&D(),o}function I(t,e){return e&&(e.pairDistanceChecks+=t.length*(t.length-1)/2),p(t)}function S(t,e,r){let n=1/0;for(let a of e){r&&r.pairDistanceChecks++;let e=m(t,a);null!==e&&e<n&&(n=e)}return n}var F=t=>Math.max(.08,Math.min(.97,t));function $(t,e,r){let n=new Map,l=a=>{if(e&&e.candidateEvaluations++,n.has(a)||!w(a,t,r))return;let l=L(a);l&&n.set(a,{hex:a,lab:l})};l("#000000"),l("#ffffff");let i=void 0!==r,o=i?44:22,f=i?Array.from({length:14},(t,e)=>(e+1)*.02):[.04,.08,.12,.16,.2,.24,.28];for(let t=0;t<=o;t++){let e=.08+t*(i?.02:.04);for(let t of(l(v({L:e,C:0,h:0})),f))for(let r=0;r<360;r+=i?5:10)l(v({L:e,C:t,h:r}))}if(void 0!==r)for(let t=0;t<=255;t+=17)for(let e=0;e<=255;e+=17)for(let r=0;r<=255;r+=17)l(a(t,e,r));return[...n.values()]}var J=(t,e)=>Math.hypot(t.L-e.L,t.a-e.a,t.b-e.b),P=(t,e)=>{let r=t.L-e.L,n=t.a-e.a,a=t.b-e.b;return Math.sqrt(r*r+n*n+a*a)};export{u as a,h as b,s as c,c as d,d as e,p as f,g as g,x as h,E as i};
1
+ import{Aa as t,Ca as e,la as r,ma as n,na as a,oa as l,pa as i,ta as o,ya as f}from"./chunk-SZAI2WB4.js";var u="#3b82f6";function h(t){let[e,n,a]=r(t),l=e/255,i=n/255,o=a/255,f=Math.max(l,i,o),u=Math.min(l,i,o),h=(f+u)/2;if(f===u)return[0,0,100*h];let s=f-u;return[360*(f===l?((i-o)/s+6*(i<o))/6:f===i?((o-l)/s+2)/6:((l-i)/s+4)/6),100*(h>.5?s/(2-f-u):s/(f+u)),100*h]}function s(t,e,r){let n=r/100,a=e/100*(1-Math.abs(2*n-1)),l=a*(1-Math.abs(t/60%2-1)),i=n-a/2,o,f,u;t<60?(o=a,f=l,u=0):t<120?(o=l,f=a,u=0):t<180?(o=0,f=a,u=l):t<240?(o=0,f=l,u=a):t<300?(o=l,f=0,u=a):(o=a,f=0,u=l);let h=t=>Math.round((t+i)*255).toString(16).padStart(2,"0");return`#${h(o)}${h(f)}${h(u)}`}function c(t){return f(t)}function d(t){return h(t)[2]<50}function b(t){return t<=.0031308?12.92*t:1.055*t**(1/2.4)-.055}function L(t){let e=n(t);if(!e)return null;let r=i(e[0]/255),a=i(e[1]/255),l=i(e[2]/255),o=Math.cbrt(.4122214708*r+.5363325363*a+.0514459929*l),f=Math.cbrt(.2119034982*r+.6806995451*a+.1073969566*l),u=Math.cbrt(.0883024619*r+.2817188376*a+.6299787005*l);return{L:.2104542553*o+.793617785*f-.0040720468*u,a:1.9779984951*o-2.428592205*f+.4505937099*u,b:.0259040371*o+.7827717662*f-.808675766*u}}function v(t){var e;let r,n,l,i,o,f,u;return n=(r=t.h*Math.PI/180,e={L:t.L,a:t.C*Math.cos(r),b:t.C*Math.sin(r)}).L+.3963377774*e.a+.2158037573*e.b,l=e.L-.1055613458*e.a-.0638541728*e.b,i=e.L-.0894841775*e.a-1.291485548*e.b,a(255*b(4.0767416621*(o=n*n*n)-3.3077115913*(f=l*l*l)+.2309699292*(u=i*i*i)),255*b(-1.2684380046*o+2.6097574011*f-.3413193965*u),255*b(-.0041960863*o-.7034186147*f+1.707614701*u))}function M(t){let e,r,n=L(t);return n?(e=Math.hypot(n.a,n.b),r=(180*Math.atan2(n.b,n.a)/Math.PI+360)%360,{L:n.L,C:e,h:r}):null}function m(t,e){let r=L(t),n=L(e);return r&&n?Math.hypot(r.L-n.L,r.a-n.a,r.b-n.b):null}function p(t){let e=1/0;for(let r=0;r<t.length;r++)for(let n=r+1;n<t.length;n++){let a=m(t[r],t[n]);null!==a&&a<e&&(e=a)}return e}function C(t){let e=n(t);if(!e)return null;let r=.2126729*(e[0]/255)**2.4+.7151522*(e[1]/255)**2.4+.072175*(e[2]/255)**2.4;return r<.022?r+(.022-r)**1.414:r}function g(t,e){let r,n,a,l=(n=C(t),a=C(e),null===n||null===a?null:5e-4>Math.abs(a-n)?0:100*(a>n?(r=(a**.56-n**.57)*1.14)<.1?0:r-.027:(r=(a**.65-n**.62)*1.14)>-.1?0:r+.027));return null===l?null:Math.abs(l)}function x(t,e={}){return function(t,e,r){var n,a;let l,i,o,f,b,v,m,p,C,g=k(e.labelInk),x,D=void 0===g?void 0:()=>x??=F(k(e.bg),void 0,g);if(t<=6){let r=e.accent??u;return function(t,e,r,n,a){let l=k(e),i=t.map(t=>k(t,l));if(i.some(t=>void 0===t))return t;let o=((void 0===l?null:L(l))?.L??1)<.55,f=i.map(t=>{if(w(t,l,n))return t;let e=M(t);return e?y(e,l,o,r,n,a):t});return(f.length>1?A(f,l,o,r,n,a):f).map((e,r)=>e===i[r]?t[r]:e)}(Array.from({length:Math.max(0,t)},(t,n)=>(function(t,e,r){if(0===t)return e;let n=c(e)?e:u,a=r&&c(r)?r:void 0,[l,i]=h(n),o=Math.max(55,Math.min(85,i)),f=Math.ceil(t/2),b=t%2==1,L=a&&d(a)?!b:b,v=L?Math.max(25,48-13*f):Math.min(78,55+11*f);return s(((l+(L?-8:12)*f)%360+360)%360,o,v)})(n,r,e.bg)),e.bg,void 0,g,D)}let E=k(e.bg);return n=k(e.accent,E)??u,a=void 0,o=(i=(l=M(n)??{L:.6,C:.16,h:264}).C<.03)?264:l.h,f=Math.max(.11,Math.min(.16,i?.16:l.C)),v=(b=((void 0===E?null:L(E))?.L??1)<.55)?[.74,.6]:[.56,.7],m=360/t,p=Array.from({length:t},(t,e)=>{if(0===e&&w(n,E,g))return n;let r=0===e?o:((o+e*m)%360+360)%360;return y({L:0===e?l.L:v[e%2],C:f,h:r},E,b,a,g,D)}),t<=24?A(p,E,b,a,g,D):(C=new Set,p.map((t,e)=>{if(a&&a.tailItems++,!C.has(t.toLowerCase()))return C.add(t.toLowerCase()),t;let r=M(t);if(r)for(let t=1;t<=24;t++){a&&a.candidateEvaluations++;let n=y({...r,L:$(r.L+(t%2==0?1:-1)*Math.ceil(t/2)*.008),h:(r.h+137.508*t+.01*e)%360},E,b,a,g,D);if(!C.has(n.toLowerCase()))return C.add(n.toLowerCase()),n}return t}))}(t,e)}function k(e,r){if(void 0===e)return;let n=t(e);if(!n)return;if(1===n[3])return a(n[0],n[1],n[2]);if(void 0===r)return;let l=t(r);if(!(!l||1!==l[3]))return a(n[0]*n[3]+l[0]*(1-n[3]),n[1]*n[3]+l[1]*(1-n[3]),n[2]*n[3]+l[2]*(1-n[3]))}function w(t,r,n){if(void 0!==n&&(e(t,n)??0)<o)return!1;if(void 0===r)return!0;let a=e(t,r),l=g(t,r);return null!==a&&null!==l&&a>=1.25&&l>=15}function y(t,e,r,n,a,l){n&&n.candidateEvaluations++;let i=v(t);if(w(i,e,a))return i;let o=(void 0===e?void 0:L(e))?.L??+!r,f=t.L>=o?1:-1;for(let r=1;r<=24;r++){let l=.04*r;for(let r of[f,-f]){n&&n.candidateEvaluations++;let i=v({...t,L:$(t.L+r*l)});if(w(i,e,a))return i}}let u=["#000000","#ffffff"].filter(t=>w(t,e,a));if(u.length>0)return u.sort((t,r)=>void 0===e?0:(g(r,e)??0)-(g(t,e)??0))[0];if(void 0!==a){let t=L(i),r,o=1/0;for(let i of l?.()??F(e,n,a)){n&&(n.candidateEvaluations++,t&&n.pairDistanceChecks++);let e=t?W(i.lab,t):0;e<o&&(r=i,o=e)}if(r)return r.hex;D()}return i}function D(){throw Error("Cannot derive categorical fills within bounded search with readable label ink, page visibility and distinct peer colors; select a different textColor or explicit fillColor")}function E(e,r,n){let i=void 0===r?null:t(r);if(!i||1!==i[3])return e;let o=a(i[0],i[1],i[2]),f=t(e);if(!f||1!==f[3])return e;let u=a(f[0],f[1],f[2]),h=t=>l(t,o,n);if(w(h(u),o))return e;let s=M(u);if(!s)return e;let c=L(o)?.L??1,d=s.L>=c?1:-1;for(let t=1;t<=24;t++){let e=.04*t;for(let t of[d,-d]){let r=v({...s,L:$(s.L+t*e)});if(w(h(r),o))return r}}return["#000000","#ffffff"].sort((t,e)=>(g(h(e),o)??0)-(g(h(t),o)??0))[0]}function A(t,e,r,n,a,l){let i=[];for(let l=0;l<t.length;l++){let o=t[l],f=0===l&&w(o,e,a);i.push(f||S(o,i,n)>=.1?o:function(t,e,r,n,a,l){let i=M(t);if(!i)return t;let o=t,f=S(t,e,a);for(let t=1;t<=12;t++){let u=.03*t,h=7*t;for(let t of[{...i,L:$(i.L+u)},{...i,L:$(i.L-u)},{...i,h:(i.h+h)%360},{...i,h:(i.h-h+360)%360},{...i,L:$(n?i.L+u:i.L-u),h:(i.h+h)%360}]){a&&a.candidateEvaluations++;let n=v(t);if(!w(n,r,l))continue;let i=S(n,e,a);if(i>=.1)return n;i>f&&(f=i,o=n)}}return o}(o,i,e,r,n,a))}if(n&&(n.pairDistanceChecks+=i.length*(i.length-1)/2),p(i)>=.1)return i;let o=function(t,e,r,n,a){if(t.length<2)return t;let l=void 0===n?P:W,i=a?.()??F(e,r,n),o=L(t[0]);if(!o)return t;let f={hex:t[0],lab:o},u=void 0===n?void 0:Float64Array.from(i,t=>(r&&r.pairDistanceChecks++,l(t.lab,f.lab))),h=e=>{let a=e?[f,e]:[f],o=new Set(a.map(t=>t.hex.toLowerCase())),h=u?.slice(),s=t=>{if(h)for(let e=0;e<i.length;e++)r&&r.pairDistanceChecks++,h[e]=Math.min(h[e],l(i[e].lab,t.lab))};for(e&&s(e);a.length<t.length;){let e,f=-1,u=1/0,c=L(t[a.length]);for(let t=0;t<i.length;t++){let s=i[t];if(o.has(s.hex.toLowerCase()))continue;r&&r.candidateEvaluations++;let d=h?.[t]??1/0;if(!h)for(let t of a)r&&r.pairDistanceChecks++,d=Math.min(d,l(s.lab,t.lab));c&&void 0!==n&&r&&r.pairDistanceChecks++;let b=c?l(s.lab,c):0;(d>f+1e-12||1e-12>=Math.abs(d-f)&&b<u)&&(e=s,f=d,u=b)}if(!e)return t;a.push(e),o.add(e.hex.toLowerCase()),s(e)}return a.map(t=>t.hex)},s=h();if(void 0===n)return s;let c=I(s,r);if(c>=.1)return s;let d=s;for(let t of s.slice(2)){let e=L(t);if(!e||(r&&r.pairDistanceChecks++,.1>l(f.lab,e)))continue;let n=h({hex:t,lab:e}),a=I(n,r);if(a>=.1)return n;a>c&&(d=n,c=a)}let b=d.map(t=>({hex:t,lab:L(t)})),v=b.length,M=new Float64Array(i.length*v),m=t=>{for(let e=0;e<i.length;e++)r&&r.pairDistanceChecks++,M[e*v+t]=l(i[e].lab,b[t].lab)};for(let t=0;t<v;t++)m(t);for(let t=0;t<24;t++){let t=!1;for(let e=1;e<v;e++){let n,a=1/0;for(let t=0;t<v;t++)t!==e&&(r&&r.pairDistanceChecks++,a=Math.min(a,l(b[e].lab,b[t].lab)));for(let t=0;t<i.length;t++){r&&r.candidateEvaluations++;let l=1/0;for(let r=0;r<v&&!(r!==e&&(l=Math.min(l,M[t*v+r]))<=a+1e-12);r++);l>a+1e-12&&(a=l,n=i[t])}n&&(b[e]=n,m(e),t=!0)}let e=b.map(t=>t.hex);if(I(e,r)>=.1)return e;if(!t)break}return b.map(t=>t.hex)}(i,e,n,a,l);return void 0!==a&&.1>I(o,n)&&D(),o}function I(t,e){return e&&(e.pairDistanceChecks+=t.length*(t.length-1)/2),p(t)}function S(t,e,r){let n=1/0;for(let a of e){r&&r.pairDistanceChecks++;let e=m(t,a);null!==e&&e<n&&(n=e)}return n}var $=t=>Math.max(.08,Math.min(.97,t));function F(t,e,r){let n=new Map,l=a=>{if(e&&e.candidateEvaluations++,n.has(a)||!w(a,t,r))return;let l=L(a);l&&n.set(a,{hex:a,lab:l})};l("#000000"),l("#ffffff");let i=void 0!==r,o=i?44:22,f=i?Array.from({length:14},(t,e)=>(e+1)*.02):[.04,.08,.12,.16,.2,.24,.28];for(let t=0;t<=o;t++){let e=.08+t*(i?.02:.04);for(let t of(l(v({L:e,C:0,h:0})),f))for(let r=0;r<360;r+=i?5:10)l(v({L:e,C:t,h:r}))}if(void 0!==r)for(let t=0;t<=255;t+=17)for(let e=0;e<=255;e+=17)for(let r=0;r<=255;r+=17)l(a(t,e,r));return[...n.values()]}var P=(t,e)=>Math.hypot(t.L-e.L,t.a-e.a,t.b-e.b),W=(t,e)=>{let r=t.L-e.L,n=t.a-e.a,a=t.b-e.b;return Math.sqrt(r*r+n*n+a*a)};export{u as a,h as b,s as c,c as d,d as e,p as f,g as g,x as h,E as i};
@@ -1 +1 @@
1
- import{d as t}from"./chunk-YVNJDVQO.js";import{C as e,_ as n}from"./chunk-EIYLJ4FI.js";function a(t,e){return n(t,{transform:e.edgeTextTransform,fontSize:e.edgeLabelFontSize,fontWeight:e.edgeLabelFontWeight,letterSpacing:e.edgeLetterSpacing})}function r(t,e,r){return"group"===r?n(t,{transform:e.groupTextTransform,fontSize:e.groupHeaderFontSize,fontWeight:e.groupHeaderFontWeight,letterSpacing:e.groupLetterSpacing,fontFamily:e.groupFont}):"edge"===r?a(t,e):"note"===r?n(t,{transform:e.nodeTextTransform,fontSize:e.edgeLabelFontSize,fontWeight:e.edgeLabelFontWeight,letterSpacing:e.edgeLetterSpacing}):n(t,{transform:e.nodeTextTransform,fontSize:e.nodeLabelFontSize,fontWeight:e.nodeLabelFontWeight,letterSpacing:e.nodeLetterSpacing})}var o=8;function i(t,e){return Math.max(4,e*("thick"===t.style?2:1)*2)}var l=4;function h(e,n,a){let r="start"===a?e.hasArrowStart:e.hasArrowEnd;return i(e,n)+(r?e.inlineStyle?.["stroke-width"]?t.width:t.width*n*("thick"===e.style?2:1):0)+l}function g(t,e,n){let a=n.width+2*o,r=n.height+2*o;return{x:t-a/2,y:e-r/2,w:a,h:r}}function s(t,n){if(!t.label||!t.labelPosition)return null;let r=t.labelBlock??a(e(t.label,t.labelContent),n);return g(t.labelPosition.x,t.labelPosition.y,r)}var f=.5;function u(t,e,n){let a=n.x+f,r=n.x+n.w-f,o=n.y+f,i=n.y+n.h-f,l=e.x-t.x,h=e.y-t.y;if(0===l)return 0!==h&&t.x>a&&t.x<r&&Math.max(t.y,e.y)>o&&Math.min(t.y,e.y)<i;if(0===h)return t.y>o&&t.y<i&&Math.max(t.x,e.x)>a&&Math.min(t.x,e.x)<r;let g=(a-t.x)/l,s=(r-t.x)/l,u=(o-t.y)/h,x=(i-t.y)/h;return Math.max(0,Math.min(g,s),Math.min(u,x))<Math.min(1,Math.max(g,s),Math.max(u,x))}export{a as a,r as b,o as c,i as d,l as e,h as f,g as g,s as h,f as i,u as j};
1
+ import{d as t}from"./chunk-3K25OV6X.js";import{C as e,_ as n}from"./chunk-SZAI2WB4.js";function a(t,e){return n(t,{transform:e.edgeTextTransform,fontSize:e.edgeLabelFontSize,fontWeight:e.edgeLabelFontWeight,letterSpacing:e.edgeLetterSpacing})}function r(t,e,r){return"group"===r?n(t,{transform:e.groupTextTransform,fontSize:e.groupHeaderFontSize,fontWeight:e.groupHeaderFontWeight,letterSpacing:e.groupLetterSpacing,fontFamily:e.groupFont}):"edge"===r?a(t,e):"note"===r?n(t,{transform:e.nodeTextTransform,fontSize:e.edgeLabelFontSize,fontWeight:e.edgeLabelFontWeight,letterSpacing:e.edgeLetterSpacing}):n(t,{transform:e.nodeTextTransform,fontSize:e.nodeLabelFontSize,fontWeight:e.nodeLabelFontWeight,letterSpacing:e.nodeLetterSpacing})}var o=8;function i(t,e){return Math.max(4,e*("thick"===t.style?2:1)*2)}var l=4;function h(e,n,a){let r="start"===a?e.hasArrowStart:e.hasArrowEnd;return i(e,n)+(r?e.inlineStyle?.["stroke-width"]?t.width:t.width*n*("thick"===e.style?2:1):0)+l}function g(t,e,n){let a=n.width+2*o,r=n.height+2*o;return{x:t-a/2,y:e-r/2,w:a,h:r}}function s(t,n){if(!t.label||!t.labelPosition)return null;let r=t.labelBlock??a(e(t.label,t.labelContent),n);return g(t.labelPosition.x,t.labelPosition.y,r)}var f=.5;function u(t,e,n){let a=n.x+f,r=n.x+n.w-f,o=n.y+f,i=n.y+n.h-f,l=e.x-t.x,h=e.y-t.y;if(0===l)return 0!==h&&t.x>a&&t.x<r&&Math.max(t.y,e.y)>o&&Math.min(t.y,e.y)<i;if(0===h)return t.y>o&&t.y<i&&Math.max(t.x,e.x)>a&&Math.min(t.x,e.x)<r;let g=(a-t.x)/l,s=(r-t.x)/l,u=(o-t.y)/h,x=(i-t.y)/h;return Math.max(0,Math.min(g,s),Math.min(u,x))<Math.min(1,Math.max(g,s),Math.max(u,x))}export{a as a,r as b,o as c,i as d,l as e,h as f,g as g,s as h,f as i,u as j};
@@ -1 +1 @@
1
- import{M as e}from"./chunk-G4JBA7HU.js";function t(e){let t=new Map;for(let r of e){let e=t.get(r.parentId)??[];e.push(r),t.set(r.parentId,e)}return t}function r(t,r){e("nodes",t.length);let n=new Map(t.map(e=>[e.id,e]));if(n.size!==t.length)throw Error("Hierarchy contains duplicate identities");let a=new Set(t.map(e=>e.parentId)),i=new Map;for(let o of t){let t=new Set,s=r?.(o)??a.has(o.id),d=o;for(;d&&!i.has(d.id);){if(t.has(d.id))throw Error("Hierarchy contains a cycle");if(t.add(d.id),e("nesting",t.size-!s),d.parentId&&!n.has(d.parentId))throw Error(`Unknown parent ${d.parentId}`);d=d.parentId?n.get(d.parentId):void 0}let p=d?i.get(d.id):0;for(let o of[...t].reverse()){let t=n.get(o);e("nesting",p+=r?.(t)??a.has(o)?1:0),i.set(o,p)}}}export{t as a,r as b};
1
+ import{M as e}from"./chunk-GK5PSUKH.js";function t(e){let t=new Map;for(let r of e){let e=t.get(r.parentId)??[];e.push(r),t.set(r.parentId,e)}return t}function r(t,r){e("nodes",t.length);let n=new Map(t.map(e=>[e.id,e]));if(n.size!==t.length)throw Error("Hierarchy contains duplicate identities");let a=new Set(t.map(e=>e.parentId)),i=new Map;for(let o of t){let t=new Set,s=r?.(o)??a.has(o.id),d=o;for(;d&&!i.has(d.id);){if(t.has(d.id))throw Error("Hierarchy contains a cycle");if(t.add(d.id),e("nesting",t.size-!s),d.parentId&&!n.has(d.parentId))throw Error(`Unknown parent ${d.parentId}`);d=d.parentId?n.get(d.parentId):void 0}let p=d?i.get(d.id):0;for(let o of[...t].reverse()){let t=n.get(o);e("nesting",p+=r?.(t)??a.has(o)?1:0),i.set(o,p)}}}export{t as a,r as b};
@@ -1,4 +1,4 @@
1
- import{p as e}from"./chunk-V6I2VGNQ.js";import{H as t,M as r}from"./chunk-G4JBA7HU.js";function n(e){if(!/#\w+;/.test(e))return{text:e,restore:e=>e,sourceOffset:e=>e};let t=new Map,n=e=>{let r=e.codePointAt(0);r>=57344&&r<=63743&&t.set(e,(t.get(e)??0)+1)};for(let t of e)n(t);for(let t of e.matchAll(/\\(?:u([\da-fA-F]{4})|U([\da-fA-F]{8}))/g)){let e=Number.parseInt(t[1]??t[2],16);e<=1114111&&n(String.fromCodePoint(e))}let o="",s=t.get(o)??0;for(let e=57345;s>0&&e<=63743;e++){let r=String.fromCodePoint(e),n=t.get(r)??0;n<s&&(o=r,s=n)}let a=e.length,l=/#\w+;/g;for(;l.test(e);)a+=2*s;r("sourceCharacters",e.length+a);let i=o.repeat(s+1),u=RegExp(`${i}(\\w+)${i}`,"g"),f=[],c=0;return{text:e.replace(/#\w+;/g,(e,t)=>{let r=`${i}${e.slice(1,-1)}${i}`,n=t+c;return f.push({start:n,end:n+r.length,sourceStart:t,sourceEnd:t+e.length}),c+=r.length-e.length,r}),restore:e=>e.replace(u,(e,t)=>`#${t};`),sourceOffset:e=>{let t=0,r=f.length;for(;t<r;){let n=t+r>>>1;f[n].start<=e?t=n+1:r=n}let n=f[t-1];return n?e<n.end?n.sourceStart:e-n.end+n.sourceEnd:e}}}function o(r,o,s){let a=e(r,o,s);if("unclosed"===a.kind)return{ok:!1,unclosed:!0,message:"unclosed @{ metadata block"};if("invalid"===a.kind)return{ok:!1,unclosed:!1,message:a.message};let l=function(e,r){let o=n(e),s=o.text,a=t(s.includes(`
1
+ import{p as e}from"./chunk-5SZ2YBKG.js";import{H as t,M as r}from"./chunk-GK5PSUKH.js";function n(e){if(!/#\w+;/.test(e))return{text:e,restore:e=>e,sourceOffset:e=>e};let t=new Map,n=e=>{let r=e.codePointAt(0);r>=57344&&r<=63743&&t.set(e,(t.get(e)??0)+1)};for(let t of e)n(t);for(let t of e.matchAll(/\\(?:u([\da-fA-F]{4})|U([\da-fA-F]{8}))/g)){let e=Number.parseInt(t[1]??t[2],16);e<=1114111&&n(String.fromCodePoint(e))}let o="",s=t.get(o)??0;for(let e=57345;s>0&&e<=63743;e++){let r=String.fromCodePoint(e),n=t.get(r)??0;n<s&&(o=r,s=n)}let a=e.length,l=/#\w+;/g;for(;l.test(e);)a+=2*s;r("sourceCharacters",e.length+a);let i=o.repeat(s+1),u=RegExp(`${i}(\\w+)${i}`,"g"),f=[],c=0;return{text:e.replace(/#\w+;/g,(e,t)=>{let r=`${i}${e.slice(1,-1)}${i}`,n=t+c;return f.push({start:n,end:n+r.length,sourceStart:t,sourceEnd:t+e.length}),c+=r.length-e.length,r}),restore:e=>e.replace(u,(e,t)=>`#${t};`),sourceOffset:e=>{let t=0,r=f.length;for(;t<r;){let n=t+r>>>1;f[n].start<=e?t=n+1:r=n}let n=f[t-1];return n?e<n.end?n.sourceStart:e-n.end+n.sourceEnd:e}}}function o(r,o,s){let a=e(r,o,s);if("unclosed"===a.kind)return{ok:!1,unclosed:!0,message:"unclosed @{ metadata block"};if("invalid"===a.kind)return{ok:!1,unclosed:!1,message:a.message};let l=function(e,r){let o=n(e),s=o.text,a=t(s.includes(`
2
2
  `)?`${s}
3
3
  `:`{
4
4
  ${s}