agentic-mermaid 0.4.1 → 0.5.3

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 (253) hide show
  1. package/AGENT_NATIVE.md +94 -627
  2. package/CHANGELOG.md +651 -0
  3. package/Instructions_for_agents.md +44 -23
  4. package/LICENSES/Khroma-MIT.txt +21 -0
  5. package/LICENSES/Mermaid-MIT.txt +21 -0
  6. package/LICENSES/es-toolkit-MIT.txt +21 -0
  7. package/LICENSES/pele-MIT.txt +40 -0
  8. package/LICENSES/zenuml-core-MIT.txt +21 -0
  9. package/README.md +93 -50
  10. package/SECURITY.md +28 -12
  11. package/THIRD_PARTY_NOTICES.md +60 -0
  12. package/assets/hero.png +0 -0
  13. package/dist/agent-core.d.ts +478 -210
  14. package/dist/agent-core.js +1 -396
  15. package/dist/agent.d.ts +17 -8
  16. package/dist/agent.js +1 -408
  17. package/dist/agentic-mermaid-mcp.js +1 -11
  18. package/dist/am.js +1 -34562
  19. package/dist/browser-lazy/chunks/agentic-producer-core-CC6OOLDW.js +1 -0
  20. package/dist/browser-lazy/chunks/architecture-QUFVKYJR.js +13 -0
  21. package/dist/browser-lazy/chunks/block-6J3Q63BO.js +11 -0
  22. package/dist/browser-lazy/chunks/builtin-backends-7SOZZHPF.js +12 -0
  23. package/dist/browser-lazy/chunks/c4-SQVBZAKJ.js +10 -0
  24. package/dist/browser-lazy/chunks/chunk-2GPK4VFF.js +5 -0
  25. package/dist/browser-lazy/chunks/chunk-2I4UPL7Q.js +3 -0
  26. package/dist/browser-lazy/chunks/chunk-2SH76OTH.js +1 -0
  27. package/dist/browser-lazy/chunks/chunk-2UIA2IME.js +3 -0
  28. package/dist/browser-lazy/chunks/chunk-4LHYF3BS.js +1 -0
  29. package/dist/browser-lazy/chunks/chunk-5B2Z7575.js +1 -0
  30. package/dist/browser-lazy/chunks/chunk-5FQ534HP.js +1 -0
  31. package/dist/browser-lazy/chunks/chunk-5UVGUSD6.js +1 -0
  32. package/dist/browser-lazy/chunks/chunk-5X6MJX3H.js +1 -0
  33. package/dist/browser-lazy/chunks/chunk-AMJLVPUB.js +4 -0
  34. package/dist/browser-lazy/chunks/chunk-BU5LHXNJ.js +3 -0
  35. package/dist/browser-lazy/chunks/chunk-BY2CPG6B.js +1 -0
  36. package/dist/browser-lazy/chunks/chunk-CN7WTBWB.js +1 -0
  37. package/dist/browser-lazy/chunks/chunk-CQE4HQEW.js +1 -0
  38. package/dist/browser-lazy/chunks/chunk-CSFUKSU6.js +1 -0
  39. package/dist/browser-lazy/chunks/chunk-DF6765YX.js +17 -0
  40. package/dist/browser-lazy/chunks/chunk-E2WMJZNM.js +1 -0
  41. package/dist/browser-lazy/chunks/chunk-FAIMVOX5.js +6 -0
  42. package/dist/browser-lazy/chunks/chunk-GVOEAY52.js +1 -0
  43. package/dist/browser-lazy/chunks/chunk-HLWUNUCM.js +1 -0
  44. package/dist/browser-lazy/chunks/chunk-ICC7HBJX.js +1 -0
  45. package/dist/browser-lazy/chunks/chunk-J35HAQQF.js +20 -0
  46. package/dist/browser-lazy/chunks/chunk-J7FFAFQF.js +1 -0
  47. package/dist/browser-lazy/chunks/chunk-LH7HUDKW.js +1 -0
  48. package/dist/browser-lazy/chunks/chunk-N5ELX7LR.js +2 -0
  49. package/dist/browser-lazy/chunks/chunk-NMQQMRIR.js +1 -0
  50. package/dist/browser-lazy/chunks/chunk-NO7ZIVRU.js +1 -0
  51. package/dist/browser-lazy/chunks/chunk-OZ443IVJ.js +16 -0
  52. package/dist/browser-lazy/chunks/chunk-PQGPS2YV.js +7 -0
  53. package/dist/browser-lazy/chunks/chunk-QA6GJQ4X.js +1 -0
  54. package/dist/browser-lazy/chunks/chunk-RIVTHZAQ.js +1 -0
  55. package/dist/browser-lazy/chunks/chunk-SZELX2EJ.js +1 -0
  56. package/dist/browser-lazy/chunks/chunk-TYZOZXUJ.js +22 -0
  57. package/dist/browser-lazy/chunks/chunk-UL6NDWLL.js +1 -0
  58. package/dist/browser-lazy/chunks/chunk-VQYYGAXP.js +1 -0
  59. package/dist/browser-lazy/chunks/chunk-VWVZGQE2.js +1 -0
  60. package/dist/browser-lazy/chunks/chunk-X2UYKWKM.js +4 -0
  61. package/dist/browser-lazy/chunks/chunk-YCEICNM6.js +1 -0
  62. package/dist/browser-lazy/chunks/chunk-Z3FDIVLN.js +20 -0
  63. package/dist/browser-lazy/chunks/class-5QA4SCTS.js +13 -0
  64. package/dist/browser-lazy/chunks/decode-63UIZGD2.js +1 -0
  65. package/dist/browser-lazy/chunks/elk.bundled-L4CADV5W.js +24 -0
  66. package/dist/browser-lazy/chunks/er-7ZSKGN7Y.js +11 -0
  67. package/dist/browser-lazy/chunks/eventmodeling-2BPLHWRN.js +19 -0
  68. package/dist/browser-lazy/chunks/flowchart-NEIMZTB5.js +4 -0
  69. package/dist/browser-lazy/chunks/forest-implementation-AEP24AIP.js +1 -0
  70. package/dist/browser-lazy/chunks/gantt-RDPIFYAF.js +11 -0
  71. package/dist/browser-lazy/chunks/gitgraph-N4Y5RYB7.js +9 -0
  72. package/dist/browser-lazy/chunks/ishikawa-LD3YBDJN.js +6 -0
  73. package/dist/browser-lazy/chunks/journey-6YQR5DJX.js +16 -0
  74. package/dist/browser-lazy/chunks/kanban-PLMJ7NBW.js +20 -0
  75. package/dist/browser-lazy/chunks/mermaid-yaml-runtime-QVYX4EWK.js +136 -0
  76. package/dist/browser-lazy/chunks/mindmap-K2UBFO3Y.js +12 -0
  77. package/dist/browser-lazy/chunks/packet-CUW4QY6Y.js +7 -0
  78. package/dist/browser-lazy/chunks/pie-7F7UUCG3.js +15 -0
  79. package/dist/browser-lazy/chunks/quadrant-TOONO2WC.js +10 -0
  80. package/dist/browser-lazy/chunks/radar-J6JVWVAX.js +16 -0
  81. package/dist/browser-lazy/chunks/render-core-BZOM3K7D.js +3 -0
  82. package/dist/browser-lazy/chunks/requirement-CMAKDJPO.js +19 -0
  83. package/dist/browser-lazy/chunks/sankey-AWXQEP3F.js +13 -0
  84. package/dist/browser-lazy/chunks/sequence-Q2RJRB4L.js +5 -0
  85. package/dist/browser-lazy/chunks/state-WRBFQEDX.js +4 -0
  86. package/dist/browser-lazy/chunks/timeline-D2KILFXM.js +6 -0
  87. package/dist/browser-lazy/chunks/treemap-N3VYX5D4.js +6 -0
  88. package/dist/browser-lazy/chunks/xychart-G73OGK66.js +16 -0
  89. package/dist/browser-lazy/chunks/zenuml-H4BXNYXR.js +16 -0
  90. package/dist/browser-lazy/index.d.ts +544 -275
  91. package/dist/browser-lazy/index.js +1 -1
  92. package/dist/browser.global.js +802 -565
  93. package/dist/chunk-3LGLPG33.js +2 -0
  94. package/dist/chunk-7CRDX2QR.js +2 -0
  95. package/dist/chunk-7PPW2BMO.js +2 -0
  96. package/dist/chunk-DQDKA5ND.js +2 -0
  97. package/dist/chunk-EHCMJUMD.js +52 -0
  98. package/dist/chunk-GVCHLSHH.js +4 -0
  99. package/dist/chunk-H3NCS2XZ.js +19 -0
  100. package/dist/chunk-JZOJ4YGS.js +201 -0
  101. package/dist/chunk-MKE7GNYU.js +146 -0
  102. package/dist/chunk-NKNFOREZ.js +2 -0
  103. package/dist/chunk-O7H2UX5K.js +2 -0
  104. package/dist/chunk-OMY6NRQD.js +58 -0
  105. package/dist/chunk-UA234O4M.js +4 -0
  106. package/dist/chunk-VUFVLGTH.js +2 -0
  107. package/dist/chunk-XU5LPD2D.js +2 -0
  108. package/dist/cli-YGGTJZH7.js +226 -0
  109. package/dist/elk-constructor.js +2 -0
  110. package/dist/elk-constructor.node.js +11 -0
  111. package/dist/index-EeXqJXr5.d.ts +1223 -0
  112. package/dist/index.d.ts +4 -1
  113. package/dist/index.js +1 -334
  114. package/dist/jsonl-RPJY6YWO.js +2 -0
  115. package/dist/mcp-cli-63DYXTVD.js +2 -0
  116. package/dist/{index-BGA_-6LV.d.ts → paint-certification-6rwQjIv_.d.ts} +5283 -6173
  117. package/dist/server-5NEOHOFS.js +524 -0
  118. package/dist/svg-styles-BdnoM7AT.d.ts +724 -0
  119. package/dist/svg-styles.d.ts +1 -0
  120. package/dist/svg-styles.js +2 -0
  121. package/dist/svg.d.ts +13 -0
  122. package/dist/svg.js +2 -0
  123. package/dist/types-BcS52Mjt.d.ts +1360 -0
  124. package/dist/zenuml/chunks/appearance-UOQ5KA6O.js +1 -0
  125. package/dist/zenuml/chunks/builtin-backends-KDKE7YHO.js +12 -0
  126. package/dist/zenuml/chunks/chunk-42DXZ5C6.js +4 -0
  127. package/dist/zenuml/chunks/chunk-7TVYPTDW.js +1 -0
  128. package/dist/zenuml/chunks/chunk-EVPSMEKN.js +1 -0
  129. package/dist/zenuml/chunks/chunk-OXQWRSBM.js +20 -0
  130. package/dist/zenuml/chunks/chunk-QWX77U7G.js +2 -0
  131. package/dist/zenuml/chunks/chunk-RLJEI7YN.js +29 -0
  132. package/dist/zenuml/chunks/chunk-RZ6XK5CD.js +29 -0
  133. package/dist/zenuml/chunks/decode-BWERFDGK.js +1 -0
  134. package/dist/zenuml/chunks/mermaid-yaml-runtime-KZVU74WU.js +136 -0
  135. package/dist/zenuml/chunks/render-core-V5RQ737O.js +3 -0
  136. package/dist/zenuml/chunks/zenuml-EA2ZFRUX.js +20 -0
  137. package/dist/zenuml-frame.global.js +3626 -0
  138. package/dist/zenuml.d.ts +83 -0
  139. package/dist/zenuml.js +1 -0
  140. package/docs/MCP-DIRECTORY-LISTINGS.md +5 -1
  141. package/docs/README.md +59 -103
  142. package/docs/agent-api-cookbook.md +26 -16
  143. package/docs/agent-mutation-policy.md +86 -15
  144. package/docs/agent-workflow-examples.md +1 -1
  145. package/docs/api-advanced.md +385 -0
  146. package/docs/api.md +320 -366
  147. package/docs/ascii.md +40 -4
  148. package/docs/browser.md +46 -7
  149. package/docs/choosing-a-diagram.md +148 -0
  150. package/docs/code-mode-impact.md +1 -0
  151. package/docs/comparison.md +244 -28
  152. package/docs/computational-aesthetics-prototype-plan.md +10 -10
  153. package/docs/config.md +60 -2
  154. package/docs/custom-fonts.md +78 -21
  155. package/docs/diagram-families.md +160 -10
  156. package/docs/eventmodeling-and-zenuml.md +165 -0
  157. package/docs/features.md +21 -19
  158. package/docs/fork-differences.md +105 -32
  159. package/docs/getting-started.md +56 -51
  160. package/docs/layout-certification.md +126 -0
  161. package/docs/mcp-code-mode-rationale.md +20 -12
  162. package/docs/mcp-http-transport.md +14 -8
  163. package/docs/quality.md +145 -15
  164. package/docs/react.md +76 -31
  165. package/docs/style-authoring.md +23 -11
  166. package/docs/svg-semantic-contract.md +104 -4
  167. package/docs/testing-strategy.md +684 -126
  168. package/docs/theming.md +27 -8
  169. package/examples/styles/readme-hero.md +25 -0
  170. package/examples/styles/readme-hero.mmd +13 -0
  171. package/examples/styles/readme-hero.style.json +7 -0
  172. package/package.json +114 -57
  173. package/server.json +2 -2
  174. package/skills/agentic-mermaid-diagram-workflow/SKILL.md +26 -8
  175. package/skills/agentic-mermaid-diagram-workflow/references/cli.md +13 -3
  176. package/skills/agentic-mermaid-diagram-workflow/references/code-mode.md +2 -1
  177. package/skills/agentic-mermaid-diagram-workflow/references/flowchart.md +9 -6
  178. package/skills/agentic-mermaid-diagram-workflow/references/hosted-mcp.md +1 -0
  179. package/skills/agentic-mermaid-diagram-workflow/references/sequence.md +4 -3
  180. package/skills/agentic-mermaid-diagram-workflow/references/timeline.md +7 -6
  181. package/skills/agentic-mermaid-diagram-workflow/references/upstream/agentflow.md +574 -0
  182. package/skills/agentic-mermaid-diagram-workflow/references/upstream/architecture.md +10 -2
  183. package/skills/agentic-mermaid-diagram-workflow/references/upstream/c4.md +18 -0
  184. package/skills/agentic-mermaid-diagram-workflow/references/upstream/classDiagram.md +123 -0
  185. package/skills/agentic-mermaid-diagram-workflow/references/upstream/cynefin.md +6 -1
  186. package/skills/agentic-mermaid-diagram-workflow/references/upstream/entityRelationshipDiagram.md +129 -9
  187. package/skills/agentic-mermaid-diagram-workflow/references/upstream/eventmodeling.md +22 -0
  188. package/skills/agentic-mermaid-diagram-workflow/references/upstream/flowchart.md +188 -60
  189. package/skills/agentic-mermaid-diagram-workflow/references/upstream/gitgraph.md +13 -7
  190. package/skills/agentic-mermaid-diagram-workflow/references/upstream/mindmap.md +110 -1
  191. package/skills/agentic-mermaid-diagram-workflow/references/upstream/packet.md +38 -0
  192. package/skills/agentic-mermaid-diagram-workflow/references/upstream/requirementDiagram.md +115 -0
  193. package/skills/agentic-mermaid-diagram-workflow/references/upstream/sequenceDiagram.md +101 -0
  194. package/skills/agentic-mermaid-diagram-workflow/references/upstream/stateDiagram.md +87 -0
  195. package/skills/agentic-mermaid-diagram-workflow/references/upstream/swimlanes.md +105 -2
  196. package/skills/agentic-mermaid-diagram-workflow/references/upstream/timeline.md +12 -6
  197. package/skills/agentic-mermaid-diagram-workflow/references/upstream/usecase.md +953 -0
  198. package/skills/agentic-mermaid-diagram-workflow/references/upstream/venn.md +77 -0
  199. package/skills/agentic-mermaid-diagram-workflow/references/upstream/xyChart.md +1 -1
  200. package/dist/browser-lazy/chunks/architecture-KTHE2HX3.js +0 -31
  201. package/dist/browser-lazy/chunks/chunk-2XCPFAD5.js +0 -46
  202. package/dist/browser-lazy/chunks/chunk-3H4F7RBT.js +0 -1
  203. package/dist/browser-lazy/chunks/chunk-4EVLW2NJ.js +0 -1
  204. package/dist/browser-lazy/chunks/chunk-5Q4S74UO.js +0 -1
  205. package/dist/browser-lazy/chunks/chunk-6OAPWSDO.js +0 -1
  206. package/dist/browser-lazy/chunks/chunk-A7L4WWVW.js +0 -143
  207. package/dist/browser-lazy/chunks/chunk-C7FJO2I3.js +0 -4
  208. package/dist/browser-lazy/chunks/chunk-D3XXDKIO.js +0 -1
  209. package/dist/browser-lazy/chunks/chunk-DXA5WL7H.js +0 -4
  210. package/dist/browser-lazy/chunks/chunk-EPFMQPXX.js +0 -1
  211. package/dist/browser-lazy/chunks/chunk-FFOHLPDA.js +0 -2
  212. package/dist/browser-lazy/chunks/chunk-FLD63DXE.js +0 -2
  213. package/dist/browser-lazy/chunks/chunk-G6OLSHRG.js +0 -7
  214. package/dist/browser-lazy/chunks/chunk-GRXCKTHX.js +0 -0
  215. package/dist/browser-lazy/chunks/chunk-I6VE56S7.js +0 -1
  216. package/dist/browser-lazy/chunks/chunk-KJVNXJ5Y.js +0 -1
  217. package/dist/browser-lazy/chunks/chunk-L227EPFP.js +0 -11
  218. package/dist/browser-lazy/chunks/chunk-LNIHDJSF.js +0 -1
  219. package/dist/browser-lazy/chunks/chunk-M6BT2HIP.js +0 -1
  220. package/dist/browser-lazy/chunks/chunk-NZRUMODH.js +0 -1
  221. package/dist/browser-lazy/chunks/chunk-OFRMKQA6.js +0 -1
  222. package/dist/browser-lazy/chunks/chunk-P7HMSKHJ.js +0 -1
  223. package/dist/browser-lazy/chunks/chunk-PXKL3O6H.js +0 -1
  224. package/dist/browser-lazy/chunks/chunk-PZEWZT35.js +0 -1
  225. package/dist/browser-lazy/chunks/chunk-STQRDZ67.js +0 -1
  226. package/dist/browser-lazy/chunks/chunk-SUFMSWTX.js +0 -1
  227. package/dist/browser-lazy/chunks/chunk-T7IJ6V4B.js +0 -3
  228. package/dist/browser-lazy/chunks/chunk-UAEZO5VL.js +0 -1
  229. package/dist/browser-lazy/chunks/chunk-WEUWIFG3.js +0 -1
  230. package/dist/browser-lazy/chunks/chunk-X64T74C5.js +0 -24
  231. package/dist/browser-lazy/chunks/class-F7R6TJ73.js +0 -9
  232. package/dist/browser-lazy/chunks/er-BDK7CM5L.js +0 -9
  233. package/dist/browser-lazy/chunks/flowchart-KFU6XV7S.js +0 -4
  234. package/dist/browser-lazy/chunks/gantt-I64VVDSP.js +0 -28
  235. package/dist/browser-lazy/chunks/gitgraph-EDUVJ5IJ.js +0 -8
  236. package/dist/browser-lazy/chunks/journey-TLO2RNM3.js +0 -40
  237. package/dist/browser-lazy/chunks/mindmap-OJCNDYPM.js +0 -9
  238. package/dist/browser-lazy/chunks/pie-HVG6XO7K.js +0 -19
  239. package/dist/browser-lazy/chunks/quadrant-U6S2L4MJ.js +0 -24
  240. package/dist/browser-lazy/chunks/radar-ZDLOBTVG.js +0 -32
  241. package/dist/browser-lazy/chunks/render-core-Y2DFNMQG.js +0 -12
  242. package/dist/browser-lazy/chunks/sequence-Z4WFS3VB.js +0 -12
  243. package/dist/browser-lazy/chunks/state-2HV2YGN3.js +0 -4
  244. package/dist/browser-lazy/chunks/timeline-XM4UFPOC.js +0 -20
  245. package/dist/browser-lazy/chunks/xychart-7JDHWTQY.js +0 -36
  246. package/dist/chunk-GGXCNCNA.js +0 -4118
  247. package/dist/chunk-IVD4NXNE.js +0 -615
  248. package/dist/chunk-JDMRPUAG.js +0 -37
  249. package/dist/chunk-JWAAW3FH.js +0 -149
  250. package/dist/chunk-LCGBT32P.js +0 -62036
  251. package/dist/chunk-RWMZRUIC.js +0 -4715
  252. package/dist/mcp-cli-4MLKC3ZH.js +0 -17
  253. package/docs/mutation-testing.md +0 -285
@@ -0,0 +1,11 @@
1
+ import{a as e,b as t}from"./chunk-YCEICNM6.js";import{a as i,b as n,d as a}from"./chunk-ICC7HBJX.js";import{C as r,aa as o,xa as l}from"./chunk-4LHYF3BS.js";import"./chunk-CQE4HQEW.js";import"./chunk-LH7HUDKW.js";import"./chunk-5FQ534HP.js";import"./chunk-BY2CPG6B.js";import"./chunk-SZELX2EJ.js";import{d as s}from"./chunk-QA6GJQ4X.js";import{a as d,b as h}from"./chunk-2I4UPL7Q.js";import{c as p,k as y}from"./chunk-2SH76OTH.js";import{d as c}from"./chunk-AMJLVPUB.js";import{t as f,z as g}from"./chunk-DF6765YX.js";import"./chunk-J35HAQQF.js";import{c as x,d as u,e as m}from"./chunk-CN7WTBWB.js";import{C as b,D as w,a as M,b as k,c as v,d as S,e as R,g as $,i as L,o as _}from"./chunk-HLWUNUCM.js";import{A as E,C as W,K as F,S as z,aa as I,c as C,ca as T,ea as B,pa as N,s as P,w as H,y as D}from"./chunk-X2UYKWKM.js";import{i as j,j as O,k as K,q as U}from"./chunk-TYZOZXUJ.js";import{a as A,b as G,c as q,h as X,l as Y,m as Z,n as Q,o as J}from"./chunk-NO7ZIVRU.js";import{C as V,D as ee,E as et,G as ei,H as en,K as ea,La as er,M as eo,Mb as el,N as es,Na as ed,Nb as eh,O as ep,Qb as ey,Tb as ec,Wa as ef,Yb as eg,Z as ex,Zb as eu,a as em,da as eb,o as ew,sb as eM}from"./chunk-Z3FDIVLN.js";import{q as ek,r as ev}from"./chunk-N5ELX7LR.js";import"./chunk-5UVGUSD6.js";import"./chunk-CSFUKSU6.js";var eS=Object.freeze({id:"er",upstreamId:"er",maturity:"stable",label:"ER",headers:["erDiagram"],aliases:[],config:{section:"er",keys:["layoutDirection","nodeSpacing","rankSpacing","titleTopMargin","diagramPadding","minEntityWidth","minEntityHeight","entityPadding","stroke","fill","fontSize","look","theme"],noopKeys:["diagramPadding","entityPadding","fill","fontSize","look","minEntityHeight","minEntityWidth","stroke","theme","titleTopMargin"]},identity:{id:"family:er",kind:"family",version:"1.0.0",compatibility:{core:"0.5.3"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:["category"],semanticRoles:["prelude","title","defs","chrome","group","group-header","entity","attribute","relationship","cardinality","label"],scenePrimitiveEvidence:[{role:"prelude",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"title",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group-header",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"entity",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"entity",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"attribute",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"attribute",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"relationship",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"cardinality",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"label",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]}],example:`erDiagram
2
+ CUSTOMER ||--o{ ORDER : places
3
+ ORDER {
4
+ string id
5
+ }`,detect:ek,detectLoose:ev}),eR={layoutDirection:y("TB","TD","BT","LR","RL"),nodeSpacing:p,rankSpacing:p};function e$(e,t,i,n){let a=[],r=e.x-t.x,o=e.y-t.y,l=Math.sqrt(r*r+o*o);if(0===l)return[];let s=r/l,d=o/l,h=-d;if("parent"===i){let t=(t,i)=>({x:e.x-s*t+h*i,y:e.y-d*t+s*i});return[{geometry:{kind:"polygon",points:[t(0,0),t(6,4),t(12,0),t(6,-4)]},paint:{fill:"var(--bg)",...n}}]}let p=e.x-4*s,y=e.y-4*d,c=e.x-16*s,f=e.y-16*d,g="many"===i||"zero-many"===i,x=(e,t)=>{a.push({geometry:{kind:"line",x1:e+6*h,y1:t+6*s,x2:e-6*h,y2:t-6*s},paint:n})};if("one"===i?(x(p,y),x(p-4*s,y-4*d)):"zero-one"===i&&x(p,y),g){let t=p+7*h,r=y+7*s;a.push({geometry:{kind:"line",x1:t,y1:r,x2:c,y2:f},paint:n}),a.push({geometry:{kind:"line",x1:p,y1:y,x2:c,y2:f},paint:n});let o=p-7*h,l=y-7*s;a.push({geometry:{kind:"line",x1:o,y1:l,x2:c,y2:f},paint:n}),"many"===i&&x(e.x-20*s,e.y-20*d)}if("zero-one"===i||"zero-many"===i){let t=g?20:12,i=e.x-s*t,r=e.y-d*t;a.push({geometry:{kind:"circle",cx:i,cy:r,r:4},paint:{fill:"var(--bg)",...n}})}return a}function eL(e,t,i,n){let a=e$(e,t,i,{stroke:"#000",strokeWidth:String(n+.25)}),r=[];for(let e of a){let t=ef({kind:"shape",id:"cardinality",role:"cardinality",geometry:e.geometry,paint:e.paint});if(!t||!Object.values(t).every(Number.isFinite))return;r.push(t)}return r}function e_(e,t){return eL({x:0,y:0},{x:1,y:0},e,t)?.reduce((e,t)=>er(e,t),void 0)}function eE(e,t){let i=e.width+8,n=e.height+6;return{kind:"rect",x:t.x-i/2,y:t.y-n/2,width:i,height:n,rx:2,ry:2}}function eW(e,t){return ef({kind:"shape",id:"label-pill",role:"chrome",geometry:eE(e,t),paint:{fill:"#000",stroke:"#000",strokeWidth:"0.5"}})}var eF=class extends RangeError{code="ER_ROUTE_WORK_LIMIT";constructor(){super("ER_ROUTE_WORK_LIMIT: frame corridor checks exceed 400000; split the diagram or reduce its relationships"),this.name="ErRouteWorkLimitError"}},ez=class extends Error{code="ER_ROUTE_BLOCKED";constructor(e,t){super(`ER_ROUTE_BLOCKED: no clear frame corridor from ${e} to ${t}`),this.name="ErRouteGeometryError"}},eI=class extends RangeError{code="ER_LABEL_WORK_LIMIT";constructor(){super("ER_LABEL_WORK_LIMIT: label-slot search exceeds 400000 operations; split the diagram or reduce its relationships"),this.name="ErLabelWorkLimitError"}},eC={subject:"ER text entity",example:'A["I #9829; ER"]'};function eT(e){return e.replace(/\\(["\\])/g,"$1")}function eB(e,t,i){let n=e.slice(1,-1);return n.includes("\\")?i?.(`${t} ${e} contains a backslash, and \\" reads as "`,'write " as #quot; and \\ as #92;'):n.includes("%")?i?.(`${t} ${e} contains a % and is read as written`,"write % as #37;"):""===n&&i?.(`${t} ${e} is empty and is read as no text`,"give the name some text"),eT(n)}function eN(e){return s(e,eC)}function eP(e){return en(e).replace(/\*\*([\s\S]+?)\*\*/g,"<b>$1</b>").replace(/_([^_\n]+)_/g,"<i>$1</i>").replace(/(?<!\*)\*([^*\n]+)\*(?!\*)/g,"<i>$1</i>")}function eH(e,t,i=!1){if(/#\w+;/.test(e))return{value:t,prepared:et(ei(i?en(e):eP(e),i?"literal":"formatted"),/#\w+;/g,eN),authored:e}}function eD(e,t=!1){let i=t?eN(eP(e)):eN(e),n=eH(e,i);return{label:i,...n?{labelContent:n}:{}}}function ej(e,t){let i=V(e,t);return"string"!=typeof i?ee(i).replace(/\s+/g," ").trim():ea(e).replace(/\s+/g," ").trim()}function eO(e,t,i){let n=ew(i,"relationship",{category:e.identifying?"identifying":"non-identifying"},{includeFallback:!1});return ex(V(e.label,e.labelContent),{transform:n?.textTransform??t.edgeTextTransform,fontSize:n?.fontSize??t.edgeLabelFontSize,fontWeight:n?.fontWeight??t.edgeLabelFontWeight,letterSpacing:n?.letterSpacing??t.edgeLetterSpacing})}function eK(e,t,i,n){let a=[],r=eG(e,t,i,n??{operations:0},!0,a);for(let t of e.relationships){let e=r.get(t);e?t.finalLabelPosition={...e}:delete t.finalLabelPosition}return a}function eU(e){let t=new Map;for(let i of e.relationships){if(!i.label||i.points.length<2)continue;let e=i.finalLabelPosition;if(!e||!Number.isFinite(e.x)||!Number.isFinite(e.y))return;t.set(i,e)}return t}function eA(e,t,i,n={operations:0}){return eG(e,t,i,n,"shaft-aware"===e.labelPlacement)}function eG(e,t,i,n,a,r){let o=new Map,l=(e=1)=>{if(n.operations+=e,n.operations>4e5)throw new eI};if(!e.relationships.some(e=>e.label&&e.points.length>1))return o;let s=(e,t)=>Math.min(e.x1,t.x1)-Math.max(e.x0,t.x0)>.5&&Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)>.5,d=[...e.entities.map(e=>{let i=Number.parseFloat(e.inlineStyle?.["stroke-width"]??""),n=(Number.isFinite(i)&&i>0?i:t.nodeLineWidth)/2;return{x0:e.x-n,y0:e.y-n,x1:e.x+e.width+n,y1:e.y+e.height+n}}),...e.groups.flatMap(e=>[{x0:e.x,y0:e.y,x1:e.x+e.width,y1:e.y+e.headerHeight},{x0:e.x-.75,y0:e.y-.75,x1:e.x+.75,y1:e.y+e.height+.75},{x0:e.x+e.width-.75,y0:e.y-.75,x1:e.x+e.width+.75,y1:e.y+e.height+.75},{x0:e.x-.75,y0:e.y-.75,x1:e.x+e.width+.75,y1:e.y+.75},{x0:e.x-.75,y0:e.y+e.height-.75,x1:e.x+e.width+.75,y1:e.y+e.height+.75}])],h=e.relationships.flatMap(e=>{if(0===e.points.length)return[];let i=[e.points[0],e.points[e.points.length-1]],n=i.map(e=>({x0:e.x-18,y0:e.y-18,x1:e.x+18,y1:e.y+18}));if(e.points.length<2)return n;let a=[eL(i[0],e.points[1],e.cardinality1,t.lineWidth),eL(i[1],e.points.at(-2),e.cardinality2,t.lineWidth)];return l(2),[...n,...a.flatMap(e=>e??[])]}),p=[];l(d.length+h.length);let y=a?e.relationships.flatMap(e=>{if(e.points.length<2)return[];let n=ew(i,"relationship",{category:e.identifying?"identifying":"non-identifying"},{includeFallback:!1}),a=n?.bendRadius??t.edgeBendRadius,r=n?.lineWidth??t.lineWidth;if(r<=0)return[];let o=a>0&&e.points.length>2,s=Math.max(.5,r/2)+.5*!!o;if(o){l(e.points.length);let t=eb(e.points,a,{metric:"manhattan"}).geometry,i=[];if(!ed(t.d,t=>(l(),i.push({owner:e,box:{x0:t.bounds.x0-s,y0:t.bounds.y0-s,x1:t.bounds.x1+s,y1:t.bounds.y1+s}}),!0),()=>(l(),!0)))throw new eI;return i}return e.points.slice(1).map((t,i)=>{l();let n=e.points[i];return{owner:e,box:{x0:Math.min(n.x,t.x)-s,y0:Math.min(n.y,t.y)-s,x1:Math.max(n.x,t.x)+s,y1:Math.max(n.y,t.y)+s}}})}):[];for(let n of e.relationships){if(!n.label||n.points.length<2)continue;let c=n.labelBlock??eO(n,t,i),f=c.width+16,g=c.height+16,x=(e,t)=>({x0:e-f/2,y0:t-g/2,x1:e+f/2,y1:t+g/2}),u=[];for(let e of y)l(),e.owner!==n&&u.push(e.box);let m=t=>(l(),t.x0<0||t.y0<0||t.x1>e.width||t.y1>e.height||p.some(e=>(l(),s(t,e)))||d.some(e=>(l(),s(t,e)))||h.some(e=>(l(),s(t,e)))||u.some(e=>(l(),s(t,e)))),b=n.points,w=[],M=0;for(let e=1;e<b.length;e++){l();let t=Math.hypot(b[e].x-b[e-1].x,b[e].y-b[e-1].y);w.push(t),M+=t}let k=e=>{let t=e;for(let e=0;e<w.length;e++){if(l(),t<=w[e]||e===w.length-1){let i=0===w[e]?0:Math.max(0,Math.min(1,t/w[e]));return{x:b[e].x+(b[e+1].x-b[e].x)*i,y:b[e].y+(b[e+1].y-b[e].y)*i}}t-=w[e]}return b[b.length-1]};l(2*b.length);let v=eq(b),S={x:v.x,y:v.y},R=x(v.x,v.y),$=a?n.labelPosition:void 0;$&&Number.isFinite($.x)&&Number.isFinite($.y)&&b.slice(1).some((e,t)=>{l();let i=b[t],n=e.x-i.x,a=e.y-i.y,r=n*n+a*a,o=r?Math.max(0,Math.min(1,(($.x-i.x)*n+($.y-i.y)*a)/r)):0;return .001>=Math.hypot($.x-i.x-o*n,$.y-i.y-o*a)})&&!m(x($.x,$.y))&&(R=x((S={...$}).x,S.y));let L=m(R);if(L)for(let e of[.4,.6,.3,.7,.25,.75,.2,.8,.15,.85]){let t=k(M*e),i=x(t.x,t.y);if(!m(i)){S=t,R=i,L=!1;break}}if(L){l(d.length+h.length+p.length+u.length);let t=[...d,...h,...p,...u],i,n=0;for(let a=1;a<b.length;a++){l();let r=b[a-1],o=b[a],s=w[a-1],d=r.x===o.x,h=r.y===o.y;if(0===s||!d&&!h){n+=s;continue}let p=d?r.x:r.y,y=(d?f:g)/2,c=(d?g:f)/2,x=d?e.width:e.height,u=d?e.height:e.width;if(p-y<0||p+y>x){n+=s;continue}let m=Math.max(Math.min(d?r.y:r.x,d?o.y:o.x),c),k=Math.min(Math.max(d?r.y:r.x,d?o.y:o.x),u-c);if(m>=k){n+=s;continue}let v=[];for(let e of t){l();let t=d?e.x0:e.y0;Math.min(p+y,d?e.x1:e.y1)-Math.max(p-y,t)<=.5||v.push([(d?e.y0:e.x0)-c+.5,(d?e.y1:e.x1)+c-.5])}v.sort((e,t)=>(l(),e[0]-t[0]||e[1]-t[1]));let S=d?r.y:r.x,R=Math.sign((d?o.y:o.x)-S),$=S+R*(M/2-n),L=(e,t)=>{l();let a=Math.max(1e-6,Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))*8);if(t-e<=2*a)return;let r=Math.max(e+a,Math.min(t-a,$)),o=Math.abs(n+Math.abs(r-S)-M/2);(!i||o<i.distance)&&(i={point:d?{x:p,y:r}:{x:r,y:p},distance:o})},_=m;for(let[e,t]of v)if(l(),!(t<=_)&&(e>k||(e>_&&L(_,Math.min(k,e)),(_=Math.max(_,t))>=k)))break;_<k&&L(_,k),n+=s}i&&!m(x(i.point.x,i.point.y))&&(R=x((S=i.point).x,S.y),L=!1)}L&&r&&(l(),r.push(n)),p.push(R),o.set(n,S)}return o}function eq(e){if(0===e.length)return{x:0,y:0};if(1===e.length)return e[0];let t=0;for(let i=1;i<e.length;i++){let n=e[i].x-e[i-1].x,a=e[i].y-e[i-1].y;t+=Math.sqrt(n*n+a*a)}if(0===t)return e[0];let i=t/2,n=0;for(let t=1;t<e.length;t++){let a=e[t].x-e[t-1].x,r=e[t].y-e[t-1].y,o=Math.sqrt(a*a+r*r);if(n+o>=i){let l=o>0?(i-n)/o:0;return{x:e[t-1].x+a*l,y:e[t-1].y+r*l}}n+=o}return e[e.length-1]}var eX={nodeLabelFontSize:A.nodeLabel,edgeLabelFontSize:A.edgeLabel,groupHeaderFontSize:A.groupHeader,nodeLabelFontWeight:700,edgeLabelFontWeight:G.edgeLabel,groupHeaderFontWeight:G.groupHeader,nodePaddingX:14,nodePaddingY:8,nodeCornerRadius:0,nodeLineWidth:q.outerBox,edgeLineWidth:q.connector,groupCornerRadius:0,groupPaddingX:14,groupPaddingY:8,groupLineWidth:q.outerBox};function eY(e,t){return ex(e,{transform:t.nodeTextTransform,fontSize:t.nodeLabelFontSize,fontWeight:t.nodeLabelFontWeight,letterSpacing:t.nodeLetterSpacing})}function eZ(e,t){return ex(e,{transform:t.groupTextTransform,fontSize:t.groupHeaderFontSize,fontWeight:t.groupHeaderFontWeight,letterSpacing:t.groupLetterSpacing})}function eQ(e){let t={display:"literal",fontSize:11,fontWeight:400,monospace:!0};return{type:ex(e.type,t),name:ex(e.name,t),keys:ex(e.keys.join(","),{display:"literal",fontSize:9,fontWeight:600}),...e.comment?{comment:ex(ej(e.comment,e.commentContent),{display:"literal",fontSize:11,fontWeight:400})}:{}}}function eJ(){return ex("<i>(no attributes)</i>",{fontSize:11,fontWeight:400})}function eV(e,t,i){for(let i of e.entities)i.labelBlock=eY(V(i.label,i.labelContent),t),i.attributeBlocks=i.attributes.map(eQ),0===i.attributes.length&&(i.emptyAttributeBlock=eJ());for(let i of e.groups)i.labelBlock??=eZ(V(i.label,i.labelContent),t);for(let n of e.relationships)n.labelBlock??=eO(n,t,i);return e}function e0(e,t){let i=new Map(e.groups.map(e=>[e.id,e.parentId])),n=new Map([...e.entities.map(e=>[e.id,e.groupId]),...i]),a=(e,t)=>{for(let a=n.get(t),r=0;void 0!==a&&i.has(a)&&r<F.nesting;a=i.get(a),r++)if(a===e)return!0;return!1},r=new Map,o=new Map,l=new Map;for(let[i,n]of e.relationships.entries()){let e=a(n.entity1,n.entity2)?n.entity1:a(n.entity2,n.entity1)?n.entity2:void 0;if(!e)continue;r.set(e,(r.get(e)??0)+t[i].height+56);let s=e===n.entity1?n.entity2:n.entity1;o.set(s,Math.max(o.get(s)??0,t[i].height+40));let d=l.get(e)??[];d.push(i),l.set(e,d)}let s=new Map;for(let e of l.values())e.forEach((t,i)=>s.set(t,(i+1)/(e.length+1)));return{padding:r,exits:o,lanes:s}}function e1(e,t,i){let n=Math.max(e.x,t.x)+(Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*i;return[{x:n,y:e.y+e.height},{x:n,y:t.y+t.height}]}function e2(e,t){return e.flatMap((e,i)=>{if(!e.label||e.points.length<2)return[];let n=e.labelPosition??_(e.points),a=t[i];return[{x0:n.x-a.width/2-8,x1:n.x+a.width/2+8,y0:n.y-a.height/2-8,y1:n.y+a.height/2+8}]})}function e5(e,t=1){if(e.operations+=t,e.operations>4e5)throw new eF}function e4(e,t){for(let i=1;i<e.length;i++){let n=e[i-1],a=e[i],r=n.x===a.x;if(e5(t),![n.x,n.y,a.x,a.y].every(Number.isFinite)||n.x!==a.x&&n.y!==a.y||n.x===a.x&&n.y===a.y)return!1;for(let o=1;o<i;o++){e5(t);let l=e[o-1],s=e[o];if(r===(l.x===s.x)){let e=r?"x":"y",t=r?"y":"x";if(n[e]!==l[e])continue;let d=Math.max(Math.min(n[t],a[t]),Math.min(l[t],s[t])),h=Math.min(Math.max(n[t],a[t]),Math.max(l[t],s[t]));if(o===i-1?d<h:d<=h)return!1}else if(o!==i-1){let e=r?n.x:l.x,t=r?l.y:n.y;if(e>=Math.min(n.x,a.x)&&e<=Math.max(n.x,a.x)&&t>=Math.min(n.y,a.y)&&t<=Math.max(n.y,a.y)&&e>=Math.min(l.x,s.x)&&e<=Math.max(l.x,s.x)&&t>=Math.min(l.y,s.y)&&t<=Math.max(l.y,s.y))return!1}}}return!0}function e7(e,t,i,n){let a=new Map([...e,...t].map(e=>[e.id,e])),r=new Set(t.map(e=>e.id)),o=(e=1)=>e5(n,e),l=new Map([...e.map(e=>[e.id,e.groupId]),...t.map(e=>[e.id,e.parentId])]),s=(e,t)=>{for(let i=l.get(t),n=0;void 0!==i&&n<F.nesting;i=l.get(i),n++)if(o(),i===e)return!0;return!1};for(let e of i)for(let t of[!1,!0]){let i=t?e.entity2:e.entity1,n=t?e.entity1:e.entity2,l=a.get(i),d=t?e.points.at(-1):e.points[0];if(!l||!d)continue;let h=(t?[...e.points].reverse():e.points).find(e=>e.x!==d.x||e.y!==d.y);if(o(e.points.length),h)if(r.has(i)&&s(i,n)){if(h.x!==d.x)throw new ez(e.entity1,e.entity2);d.y=l.y+l.height}else{let e=h.y===d.y&&h.x!==d.x||(d.x===l.x||d.x===l.x+l.width)&&h.x!==d.x,t=h.x===d.x&&h.y!==d.y||(d.y===l.y||d.y===l.y+l.height)&&h.y!==d.y;e?(d.x=h.x>d.x?l.x+l.width:l.x,h.y=d.y):t&&(d.y=h.y>d.y?l.y+l.height:l.y,h.x=d.x)}}}function e6(e,t,i,n,a,s,d={operations:0},h){e7(e,t,i,d);let p=a.lineWidth,y=ey([...e.map(e=>e.id),...t.map(e=>e.id)]),c=new Set(t.map(e=>e.id)),f=new Map,g=new Map,x=[...e.map(e=>{let t=y(`er-entity:${e.id}`,["er","entity",e.id]);f.set(t,e.id);let i=Number.parseFloat(e.inlineStyle?.["stroke-width"]??""),n=(Number.isFinite(i)&&i>0?i:a.nodeLineWidth)/2;return{...e,id:t,x:e.x-n,y:e.y-n,width:e.width+2*n,height:e.height+2*n,shape:"rectangle"}}),...t.map(e=>{let t=y(`er-header:${e.id}`,["er","header",e.id]);return g.set(t,e.id),{...e,id:t,height:e.headerHeight,shape:"rectangle"}})],u=e=>e5(d,e);for(let[e,t]of i.entries()){if(h&&!h.indices.has(e)||t.points.length<2)continue;let[i,m]=[t.points[0],t.points.at(-1)],b=ew(s,"relationship",{category:t.identifying?"identifying":"non-identifying"},{includeFallback:!1}),w=(b?.bendRadius??a.edgeBendRadius)+2*(b?.lineWidth??a.lineWidth),M=x.filter(e=>{let i=f.get(e.id);return void 0===i||c.has(i)||i!==t.entity1&&i!==t.entity2}).map(e=>w&&g.get(e.id)!==t.entity1&&g.get(e.id)!==t.entity2?{...e,x:e.x-w,y:e.y-w,width:e.width+2*w,height:e.height+2*w}:e),k=e=>e.slice(1).some((t,i)=>M.some(n=>(u(1),o(e[i],t,n)))),v=(e,n,r)=>{let o=eL(e,n,r,p);if(u(2+(o?.length??0)),!o?.length)return!1;let l=e.y===n.y,s=Math.sign(l?n.x-e.x:n.y-e.y),d=Math.max(...o.map(t=>s>0?l?t.x1-e.x:t.y1-e.y:l?e.x-t.x0:e.y-t.y0)),h=Math.abs(l?n.x-e.x:n.y-e.y),y=b?.bendRadius??a.edgeBendRadius,c=e===i?t.points[2]:t.points.at(-3),f=c?Math.abs(c.x-n.x)+Math.abs(c.y-n.y):h;return h-(t.points.length>2?Math.min(y,h/2,f/2):0)>=d};if(!k(t.points)&&e4(t.points,d)&&v(i,t.points[1],t.cardinality1)&&v(m,t.points.at(-2),t.cardinality2)&&(!h||h.admit(e,t.points)))continue;delete t.labelPosition;let S=t.points.find(e=>e.x!==i.x||e.y!==i.y),R=[...t.points].reverse().find(e=>e.x!==m.x||e.y!==m.y),$=[],L=p+.25,_=(i,r,o,l)=>{let s={x:Math.sign(r.x-i.x),y:Math.sign(r.y-i.y)},d=eL(i,r,l,p);if(u(2+(d?.length??0)),!d?.length)throw new ez(t.entity1,t.entity2);let h=Math.max(0,...d.map(e=>s.x>0?e.x1-i.x:s.x<0?i.x-e.x0:s.y>0?e.y1-i.y:i.y-e.y0)),c=h+(b?.bendRadius??a.edgeBendRadius)+L,f=n[e],g=(s.x?f.width:f.height)/2+8,x=t.entity1===t.entity2&&t.label?h+g+1+L+a.nodeLineWidth/2:0,m=Math.max(c+1+L,x),w=Math.max(20,m);for(let e of M){if(u(1),!(s.x?i.y>e.y&&i.y<e.y+e.height:i.x>e.x&&i.x<e.x+e.width))continue;let t=s.x>0?e.x-i.x:s.x<0?i.x-e.x-e.width:s.y>0?e.y-i.y:i.y-e.y-e.height;t>=0&&(w=Math.min(w,t-1-L))}if(w<m)throw new ez(t.entity1,t.entity2);let k=Math.max(0,...d.map(e=>s.x?Math.max(i.y-e.y0,e.y1-i.y):Math.max(i.x-e.x0,e.x1-i.x))),v={x:i.x+s.x*c,y:i.y+s.y*c};return u(d.length+2),$.push({id:y(`er-terminal:${e}:${$.length}`,["er","terminal",e,$.length]),label:"",shape:"rectangle",x:s.x?Math.min(i.x,v.x):i.x-k,y:s.y?Math.min(i.y,v.y):i.y-k,width:s.x?c:2*k,height:s.y?c:2*k}),{id:o,label:"",shape:"rectangle",x:i.x+s.x*w,y:i.y+s.y*w,width:0,height:0}},E=_(i,S,t.entity1,t.cardinality1),W=_(m,R,t.entity2,t.cardinality2),F=e=>k(e)||e.slice(1).some((t,i)=>$.some(n=>(u(1),o(e[i],t,n)))),z=n[e],I=z.width/2+8,C=z.height/2+8,T=M.map(e=>({...e,x:e.x-I,y:e.y-C,width:e.width+2*I,height:e.height+2*C})),B=[T];u(M.length);let N={source:E.id,target:W.id,style:"solid",hasArrowStart:!1,hasArrowEnd:!1,points:[{x:E.x,y:E.y},...t.points.slice(1,-1),{x:W.x,y:W.y}]},P=Math.abs(m.x-i.x)>=Math.abs(m.y-i.y)?m.x>=i.x?"LR":"RL":m.y>=i.y?"TB":"BT";if(l([...T,...$,E,W],[N],{direction:P},u),F(N.points)){u(M.length);let e=M.map(e=>"TB"===P||"BT"===P?{...e,x:e.x-I,width:e.width+2*I}:{...e,y:e.y-C,height:e.height+2*C});B.push(e),l([...e,...$,E,W],[N],{direction:P},u)}if(F(N.points)){let e="LR"===P||"RL"===P?m.y>=i.y?"TB":"BT":m.x>=i.x?"LR":"RL";u(M.length);let t=M.map(t=>"TB"===e||"BT"===e?{...t,x:t.x-I,width:t.width+2*I}:{...t,y:t.y-C,height:t.height+2*C});B.push(t),l([...t,...$,E,W],[N],{direction:e},u)}let H=t=>{if(F(t))return!1;let n=r([i,...t,m]);return e4(n,d)&&(!h||h.admit(e,n))};if(!H(N.points)){let e;for(let t of[...B,M]){let i=[E.x,W.x],n=[E.y,W.y];for(let e of[...t,...$])u(4),i.push(e.x-L,e.x+e.width+L),n.push(e.y-L,e.y+e.height+L);for(let a of(i.sort((e,t)=>(u(1),Math.abs(e-(E.x+W.x)/2)-Math.abs(t-(E.x+W.x)/2)||e-t)),n.sort((e,t)=>(u(1),Math.abs(e-(E.y+W.y)/2)-Math.abs(t-(E.y+W.y)/2)||e-t)),u((i.length+n.length+2)*4),[[E,{x:W.x,y:E.y},W],[E,{x:E.x,y:W.y},W],...i.map(e=>[E,{x:e,y:E.y},{x:e,y:W.y},W]),...n.map(e=>[E,{x:E.x,y:e},{x:W.x,y:e},W])])){let i=r(a);if(!i.slice(1).some((e,n)=>t.some(t=>(u(1),o(i[n],e,t))))&&H(i)){e=i;break}}if(e)break}if(!e)throw new ez(t.entity1,t.entity2);N.points=e}if(t.points=r([i,...N.points,m]),k(t.points))throw new ez(t.entity1,t.entity2)}}function e8(e){let t=Math.max(0,...e.map(e=>e.comment?eQ(e).comment.width:0));return t>0?t+12:0}function e3(e,t){let i={x:e.x+e.width/2,y:e.y+e.height/2},n=t.x-i.x,a=t.y-i.y;return Math.abs(n)*e.height>=Math.abs(a)*e.width?{point:{x:n>=0?e.x+e.width:e.x,y:i.y+a/(Math.abs(n)||1)*e.width/2},horizontal:!0}:{point:{x:i.x+n/(Math.abs(a)||1)*e.height/2,y:a>=0?e.y+e.height:e.y},horizontal:!1}}function e9(e,t){let i=e3(e,{x:t.x+t.width/2,y:t.y+t.height/2}),n=e3(t,{x:e.x+e.width/2,y:e.y+e.height/2});return function(e,t,i,n){let a=[e];if(e.x!==t.x&&e.y!==t.y)if(i!==n)a.push(i?{x:t.x,y:e.y}:{x:e.x,y:t.y});else if(i){let i=(e.x+t.x)/2;a.push({x:i,y:e.y},{x:i,y:t.y})}else{let i=(e.y+t.y)/2;a.push({x:e.x,y:i},{x:t.x,y:i})}return a.push(t),a}(i.point,n.point,i.horizontal,n.horizontal)}function te(e,t,i,n){let a=new Map([...e.entities.map(e=>[e.id,e.groupId]),...e.groups.map(e=>[e.id,e.parentId])]),r=new Map;for(let o of(e5(n,a.size),e.relationships)){if(e5(n),o.label){let e=eO(o,t,i).width+16+t.nodeLineWidth+1.5+2*(t.lineWidth+.25);for(let[t,i]of[[o.entity1,o.entity2],[o.entity2,o.entity1]])for(let o=a.get(i),l=0;void 0!==o&&l<F.nesting;o=a.get(o),l++)if(e5(n),o===t){r.set(o,Math.max(r.get(o)??20,e));break}}let e=ew(i,"relationship",{category:o.identifying?"identifying":"non-identifying"},{includeFallback:!1})?.bendRadius??t.edgeBendRadius;for(let[l,s]of[[o.entity1,o.cardinality1],[o.entity2,o.cardinality2]]){let d=a.get(l);if(!d)continue;let h=e_(s,t.lineWidth);if(e5(n),!h)throw new ez(o.entity1,o.entity2);let p=ew(i,"relationship",{category:o.identifying?"identifying":"non-identifying"},{includeFallback:!1})?.lineWidth??t.lineWidth,y=h.x1+2*e+2*p+3*(t.lineWidth+.25)+2+.75;r.set(d,Math.max(r.get(d)??20,y))}}return r}function tt(e,t,i,n,a,r,o,l=20,s,d={operations:0},h=new Map){if(0===i.length)return!1;let p=new Map(i.map(e=>[e.id,e])),y=new Map(e.groups.map(e=>[e.id,e])),c=new Map,f=new Map;for(let e of i){let t=e.parentId&&p.has(e.parentId)?e.parentId:void 0,i=c.get(t)??[];i.push(e),c.set(t,i)}for(let e of t){let t=e.groupId&&p.has(e.groupId)?e.groupId:void 0,i=f.get(t)??[];i.push(e),f.set(t,i)}let g=new Map([...t,...i].map(e=>[e.id,e])),x=t=>{e5(d);let i=e.relationships[t],r=g.get(i.entity1),o=g.get(i.entity2),l=e9(r,o),s=eL(l[0],l[1],i.cardinality1,n.lineWidth),h=eL(l.at(-1),l.at(-2),i.cardinality2,n.lineWidth);if(!s?.length||!h?.length)return!0;let y=(e,t)=>(e5(d),e.x0<t.x1&&e.x1>t.x0&&e.y0<t.y1&&e.y1>t.y0);if(s.some(e=>h.some(t=>y(e,t))))return!0;let c=(e,t)=>({x0:t.x,y0:t.y,x1:t.x+t.width,y1:t.y+(p.has(e)?t.headerHeight:t.height)});if(s.some(e=>y(e,c(i.entity2,o)))||h.some(e=>y(e,c(i.entity1,r))))return!0;if(i.label){let e=eW(a[t],_(l));if(!e||y(e,c(i.entity1,r))||y(e,c(i.entity2,o)))return!0}return!1},u=!1,m=(e,t,i)=>{for(let n of(e.x+=t,e.y+=i,f.get(e.id)??[]))n.x+=t,n.y+=i;for(let n of c.get(e.id)??[])m(n,t,i)},b=e=>new Set([e.id,...(f.get(e.id)??[]).map(e=>e.id),...(c.get(e.id)??[]).flatMap(e=>[...b(e)])]),w=(t,i)=>{let M=c.get(t)??[];for(let e of M)w(e.id,y.get(e.id)?.direction??i);let k=f.get(t)??[],v=new Map(k.map(e=>[e.id,e])),S=new Map(k.map(e=>[e.id,[]]));for(let t of e.relationships)v.has(t.entity1)&&v.has(t.entity2)&&(S.get(t.entity1).push(t.entity2),S.get(t.entity2).push(t.entity1));let R=new Set,$=[];for(let e of k){if(R.has(e.id))continue;let t=[],i=[e.id];for(;i.length;){let e=i.pop();R.has(e)||(R.add(e),t.push(v.get(e)),i.push(...S.get(e)))}let n=Math.min(...t.map(e=>e.x)),a=Math.min(...t.map(e=>e.y)),r={x:n,y:a,width:Math.max(...t.map(e=>e.x+e.width))-n,height:Math.max(...t.map(e=>e.y+e.height))-a};$.push({box:r,ids:new Set(t.map(e=>e.id)),move:(e,i)=>{for(let n of(r.x+=e,r.y+=i,t))n.x+=e,n.y+=i}})}let L=[...$,...M.map(e=>({box:e,ids:b(e),move:(t,i)=>m(e,t,i)}))];if(((t,i)=>{let r="LR"===i||"RL"===i,h=r?"y":"x",y=r?"height":"width",c=r?"x":"y",f=t=>{let i=[];for(let a of e.relationships){if(e5(d),!t.ids.has(a.entity1)&&!t.ids.has(a.entity2))continue;let e=g.get(a.entity1),r=g.get(a.entity2);if(!e||!r)continue;let o=e9(e,r),l=2*(ew(s,"relationship",{category:a.identifying?"identifying":"non-identifying"},{includeFallback:!1})?.bendRadius??n.edgeBendRadius)+2*n.lineWidth+4*(n.lineWidth+.25)+2;for(let[e,r,s,h]of[[a.entity1,o[0],o[1],a.cardinality1],[a.entity2,o.at(-1),o.at(-2),a.cardinality2]]){if(!t.ids.has(e))continue;let o=eL(r,s,h,n.lineWidth);if(e5(d,2+(o?.length??0)),!o)throw new ez(a.entity1,a.entity2);i.push(...o.map(e=>({...e,overhead:l})))}}return i},m=e=>Math.max(0,...[...e.ids].map(e=>{if(e5(d),p.has(e))return .75;let t=g.get(e),i=Number.parseFloat(t?.inlineStyle?.["stroke-width"]??"");return(Number.isFinite(i)&&i>0?i:n.nodeLineWidth)/2})),b=new Map,w=new Map(t.map(e=>[e,Math.max(0,...[...e.ids].map(e=>o.get(e)??0))])),M=new Map;for(let e of t)for(let t of e.ids)b.set(t,e);for(let[t,i]of e.relationships.entries()){e5(d);let e=b.get(i.entity1),o=b.get(i.entity2);if(!e||!o||e===o)continue;let l=e_(i.cardinality1,n.lineWidth),h=e_(i.cardinality2,n.lineWidth);if(!l||!h)throw new ez(i.entity1,i.entity2);let p=ew(s,"relationship",{category:i.identifying?"identifying":"non-identifying"},{includeFallback:!1})?.bendRadius??n.edgeBendRadius,y=e=>Math.max(0,e.x1,-e.x0,e.y1,-e.y0)+p,c=y(l)+y(h)+2*(n.lineWidth+.25),f=i.label?Math.max(a[t][r?"height":"width"]+56,a[t][r?"height":"width"]+20+c):c,g=c+(i.label?a[t][r?"width":"height"]+20:0);for(let[i,n]of[[e,o],[o,e]]){let e=M.get(i)??new Map,a=e.get(n);e.set(n,{cross:Math.max(a?.cross??0,f),main:Math.max(a?.main??0,g),indices:[...a?.indices??[],t]}),M.set(i,e)}}let k=new Map(t.map(e=>[e,new Set]));for(let t of e.relationships){e5(d);let e=b.get(t.entity1),i=b.get(t.entity2);e&&i&&e!==i&&k.get(e).add(i)}let v=(e,t)=>{let i=[e],n=new Set;for(;i.length;){e5(d);let e=i.pop();if(e===t)return!0;if(!n.has(e))for(let t of(n.add(e),k.get(e)))e5(d),i.push(t)}return!1},S=new Map(t.map(e=>[e,[]])),R=new Map(t.map(e=>[e,[]]));for(let[e,t]of k)for(let i of t)e5(d),v(i,e)||(S.get(i).push(e),R.get(e).push(i));let $=new Map(t.map(e=>[e,S.get(e).length])),L=t.filter(e=>0===$.get(e)),_="BT"===i||"RL"===i,E=r?"width":"height";for(let e=0;e<L.length;e++){let t=L[e],i=0;for(let e of S.get(t)){e5(d);let n=Math.max(l,M.get(t)?.get(e)?.main??0);i=_?Math.min(i,e.box[c]-n-t.box[c]-t.box[E]):Math.max(i,e.box[c]+e.box[E]+n-t.box[c])}for(let e of(0!==i&&(t.move(r?i:0,r?0:i),u=!0),R.get(t)))e5(d),$.set(e,$.get(e)-1),0===$.get(e)&&L.push(e)}t.sort((e,t)=>e.box[h]-t.box[h]||e.box[c]-t.box[c]);let W=[];for(let e of t){for(let t=0;t<W.length;t++){let t=0;for(let i of W){e5(d);let n=M.get(e)?.get(i),a=f(e),o=f(i),s=m(e),p=m(i),g=(e,t,i)=>(e5(d),e.x0<t.x+t.width+i&&e.x1>t.x-i&&e.y0<t.y+t.height+i&&e.y1>t.y-i),u=a.some(e=>g(e,i.box,p))||o.some(t=>g(t,e.box,s)),b=(e,t,i,n)=>Math.max(0,...e.map(e=>{e5(d);let a=i?(r?e.y1:e.x1)-t[h]-t[y]:t[h]-(r?e.y0:e.x0);return a>0?a+e.overhead+n:0})),k=u?b(o,i.box,!0,s)+b(a,e.box,!1,p):0,v=Math.max(n?.cross??0,w.get(e),w.get(i),k),S=r?"width":"height",R=Math.min(e.box[c]+e.box[S],i.box[c]+i.box[S])-Math.max(e.box[c],i.box[c]),$=Math.min(e.box[h]+e.box[y],i.box[h]+i.box[y])-Math.max(e.box[h],i.box[h]);(R>.5||u||n&&R>-n.main&&n.indices.some(x))&&$>-Math.max(v,l>20?l:0)+.5&&(t=Math.max(t,i.box[h]+i.box[y]+Math.max(l,v)-e.box[h]))}if(0===t)break;e.move(r?0:t,r?t:0),u=!0}W.push(e)}})(L,i),void 0===t||0===L.length)return;let _=p.get(t),E=h.get(_.id)??20,W=Math.min(...L.map(e=>e.box.x))-E,F=Math.min(...L.map(e=>e.box.y))-E-_.headerHeight,z=Math.max(W+(_.labelBlock?.width??eZ(_.label,n).width)+20,Math.max(...L.map(e=>e.box.x+e.box.width))+E)-W,I=Math.max(...L.map(e=>e.box.y+e.box.height))+Math.max(E,r.get(_.id)??0)-F;(_.x!==W||_.y!==F||_.width!==z||_.height!==I)&&(u=!0),Object.assign(_,{x:W,y:F,width:z,height:I})};return w(void 0,e.direction??"LR"),u}function ti(e,t,i){let n=Y(t,i);if(!n)return e;if(0===e.width&&0===e.height)return{...e,...Z(n,40)};let a=n.height;for(let t of e.entities)t.y+=a;for(let t of e.groups)t.y+=a;for(let t of e.relationships){for(let e of t.points)e.y+=a;t.labelPosition&&(t.labelPosition.y+=a)}let r=Math.max(e.width,n.width+80);return{...e,width:r,height:e.height+a,title:Q(n,r,40)}}function tn(e,t,i,n){let a=e.relationships;if(!a.length)return e;let l=(e=1)=>e5(n,e),s=(e,t)=>(l(),e.x0<t.x1&&e.x1>t.x0&&e.y0<t.y1&&e.y1>t.y0),d=new Map([...e.entities,...e.groups].map(e=>[e.id,e])),h=new Set(e.groups.map(e=>e.id));e7(e.entities,e.groups,a,n);let p=[...e.entities.map(e=>{let i=Number.parseFloat(e.inlineStyle?.["stroke-width"]??""),n=(Number.isFinite(i)&&i>0?i:t.nodeLineWidth)/2;return{id:e.id,box:{x0:e.x-n,y0:e.y-n,x1:e.x+e.width+n,y1:e.y+e.height+n}}}),...e.groups.flatMap(e=>{let t=e.x,i=e.y,n=t+e.width,a=i+e.height;return[{id:e.id,group:!0,box:{x0:t,y0:i,x1:n,y1:i+e.headerHeight}},{id:e.id,group:!0,border:!0,box:{x0:t-.75,y0:i-.75,x1:t+.75,y1:a+.75}},{id:e.id,group:!0,border:!0,box:{x0:n-.75,y0:i-.75,x1:n+.75,y1:a+.75}},{id:e.id,group:!0,border:!0,box:{x0:t-.75,y0:i-.75,x1:n+.75,y1:i+.75}},{id:e.id,group:!0,border:!0,box:{x0:t-.75,y0:a-.75,x1:n+.75,y1:a+.75}}]})];l(p.length+d.size);let y=()=>a.flatMap((e,i)=>{if(l(),e.points.length<2)throw new ez(e.entity1,e.entity2);return[0,1].map(n=>{let a=n?e.points.at(-1):e.points[0],r=n?e.points.at(-2):e.points[1],o=eL(a,r,n?e.cardinality2:e.cardinality1,t.lineWidth);if(l(2+(o?.length??0)),!o?.length)throw new ez(e.entity1,e.entity2);return{index:i,end:n,rel:e,id:n?e.entity2:e.entity1,point:a,toward:r,pieces:o}})}),c=(e,t,i,n)=>Math.max(0,...e.map(e=>(l(),n>0?i?e.x1-t.x:e.y1-t.y:i?t.x-e.x0:t.y-e.y0))),f=()=>a.flatMap((e,n)=>{let a=ew(i,"relationship",{category:e.identifying?"identifying":"non-identifying"},{includeFallback:!1}),r=(a?.lineWidth??t.lineWidth)/2,o=a?.bendRadius??t.edgeBendRadius,s=(e,t,i,n)=>{l(),t.y===i.y?i.x>t.x===n?e.x0=n?t.x:i.x:e.x1=n?t.x:i.x:t.x===i.x&&(i.y>t.y===n?e.y0=n?t.y:i.y:e.y1=n?t.y:i.y)};if(o>0&&e.points.length>2){let t=eb(e.points,o,{metric:"manhattan"}).geometry,i=[],a;if("path"!==t.kind||!ed(t.d,e=>{l();let t={x0:e.bounds.x0-r,y0:e.bounds.y0-r,x1:e.bounds.x1+r,y1:e.bounds.y1+r};return!i.length&&e.line&&s(t,e.line[0],e.line[1],!0),a=e.line,i.push({index:n,box:t,first:!1,last:!1,...e.line?{line:e.line}:{}}),!0},()=>(l(),!0)))throw new ez(e.entity1,e.entity2);return i.length&&(i[0].first=!0,i.at(-1).last=!0,a&&s(i.at(-1).box,a[0],a[1],!1)),i}return e.points.slice(1).map((t,i)=>{l();let a=e.points[i];if(a.x!==t.x&&a.y!==t.y||![a.x,a.y,t.x,t.y,r].every(Number.isFinite))throw new ez(e.entity1,e.entity2);let o={x0:Math.min(a.x,t.x)-r,y0:Math.min(a.y,t.y)-r,x1:Math.max(a.x,t.x)+r,y1:Math.max(a.y,t.y)+r};return 0===i&&s(o,a,t,!0),i===e.points.length-2&&s(o,a,t,!1),{index:n,box:o,first:0===i,last:i===e.points.length-2,line:[a,t]}})}),g=eK(e,t,i,n),x=eU(e)??eA(e,t,i,n),u=!1,m=new Map;for(let e of y()){l();let t=e.point.y===e.toward.y?e.toward.x>e.point.x?"E":"W":e.toward.y>e.point.y?"S":"N",i=m.get(e.id)??new Map,n=i.get(t)??[];n.push(e),i.set(t,n),m.set(e.id,i)}let b=[...m.values()].flatMap(e=>[...e.values()].flatMap(e=>e.sort((e,t)=>(l(),(e.point.y===e.toward.y?e.point.y-t.point.y:e.point.x-t.point.x)||2*e.index+e.end-2*t.index-t.end)))),w=new Map(b.map((e,t)=>[2*e.index+e.end,t]));for(let e of(l(2*b.length),b)){l();let a=d.get(e.id),o=e.end?e.rel.points.at(-1):e.rel.points[0],g=e.end?e.rel.points.at(-2):e.rel.points[1],x=g.y===o.y&&g.x!==o.x,m=g.x===o.x&&g.y!==o.y,b=Math.sign(x?g.x-o.x:g.y-o.y),M=x?o.x===(b>0?a.x+a.width:a.x):o.y===(b>0?a.y+a.height:a.y);if(!x&&!m||!M)continue;let k=x?o.y:o.x,v=h.has(e.id)?6:Math.min(t.cornerRadius??0,a.width/2,a.height/2),S=(x?a.y:a.x)+v,R=(x?a.y+a.height:a.x+a.width)-v,$=y(),L=$.find(t=>t.index===e.index&&t.end===e.end),_=$.filter(t=>(l(),!(t.id!==e.id||w.get(2*t.index+t.end)<=w.get(2*e.index+e.end))&&(x?t.point.x===o.x&&t.toward.y===t.point.y&&Math.sign(t.toward.x-t.point.x)===b:t.point.y===o.y&&t.toward.x===t.point.x&&Math.sign(t.toward.y-t.point.y)===b))),E=new Set(_);l(_.length);let W=[...$.filter(t=>(l(),(t.index!==e.index||t.end!==e.end)&&!E.has(t))).flatMap(e=>e.pieces),...f().filter(t=>t.index!==e.index&&!_.some(e=>(l(),e.index===t.index&&(e.end?t.last:t.first)))).map(e=>e.box)],F=[...p.filter(t=>t.id!==e.id||!!t.group!==h.has(e.id)).map(e=>e.box),...W],z=new Set($.filter(t=>t.index===e.index).flatMap(e=>e.pieces));l(z.size);let I=[...p.filter(t=>(t.id!==e.id||!!t.group!==h.has(e.id))&&!t.border).map(e=>e.box),...W.filter(e=>!z.has(e))],C=ew(i,"relationship",{category:e.rel.identifying?"identifying":"non-identifying"},{includeFallback:!1}),T=(C?.lineWidth??t.lineWidth)/2,B=c(L.pieces,o,x,b)+(C?.bendRadius??t.edgeBendRadius)+T+t.lineWidth+.25,N=Math.min(Math.abs(x?g.x-o.x:g.y-o.y),B),P=x?{x:o.x+b*N,y:o.y}:{x:o.x,y:o.y+b*N},H={x0:Math.min(o.x,P.x)-(x?0:T),x1:Math.max(o.x,P.x)+(x?0:T),y0:Math.min(o.y,P.y)-(x?T:0),y1:Math.max(o.y,P.y)+(x?T:0)},D=[...L.pieces.map(e=>({piece:e,occupied:F})),{piece:H,occupied:I}];if(l(F.length+I.length+D.length),k>=S&&k<=R&&!D.some(({piece:e,occupied:t})=>t.some(t=>s(e,t))))continue;let j=$.find(t=>t.index===e.index&&t.end!==e.end),O=j.point.y===j.toward.y;if(x!==O){let n=Math.sign(O?j.toward.x-j.point.x:j.toward.y-j.point.y),a=ew(i,"relationship",{category:e.rel.identifying?"identifying":"non-identifying"},{includeFallback:!1}),r=c(j.pieces,j.point,O,n)+(a?.lineWidth??t.lineWidth)/2+t.lineWidth+.25,o=r+Math.min(a?.bendRadius??t.edgeBendRadius,r),l=O?j.point.x:j.point.y;n>0?S=Math.max(S,l+o):R=Math.min(R,l-o)}let K=Math.max(S,Math.min(k,R)),U=[];for(let{piece:e,occupied:i}of D)for(let n of i){l();let i=x?e.x0:e.y0,a=x?e.x1:e.y1,r=x?n.x0:n.y0;if(i>=(x?n.x1:n.y1)||a<=r)continue;let o=t.lineWidth+.25;U.push([(x?n.y0:n.x0)-((x?e.y1:e.x1)-k)-o,(x?n.y1:n.x1)-((x?e.y0:e.x0)-k)+o])}for(let[e,t]of(U.sort((e,t)=>(l(),e[0]-t[0]||e[1]-t[1])),U))l(),K>e&&K<t&&(K=t);if(K>R){K=Math.max(S,Math.min(k,R));for(let e=U.length-1;e>=0;e--){l();let[t,i]=U[e];K>t&&K<i&&(K=t)}if(K<S)throw new ez(e.rel.entity1,e.rel.entity2)}if(K===k)continue;if(K>R)throw new ez(e.rel.entity1,e.rel.entity2);let A=e.rel.points.map(e=>({...e})),G=e.end?-1:1,q=e.end?A.length-1:0,X=x?"y":"x",Y=o[X],Z=K-Y,Q=q;for(let e=q;e>=0&&e<A.length&&A[e][X]===Y;e+=G)l(),Q=e;if(Q===(e.end?0:A.length-1)){let n=A[0],a=A.at(-1);A[q][X]=K;let o=$.find(t=>t.index===e.index&&0===t.end),l=$.find(t=>t.index===e.index&&1===t.end),s=ew(i,"relationship",{category:e.rel.identifying?"identifying":"non-identifying"},{includeFallback:!1}),d=e=>{let i=Math.sign(x?e.toward.x-e.point.x:e.toward.y-e.point.y),n=c(e.pieces,e.point,x,i)+(s?.lineWidth??t.lineWidth)/2+t.lineWidth+.25;return n+Math.min(s?.bendRadius??t.edgeBendRadius,n)},h=x?"x":"y",p=Math.sign(a[h]-n[h]),y=n[h]+p*d(o),f=a[h]-p*d(l);if((f-y)*p<0)throw new ez(e.rel.entity1,e.rel.entity2);let g=Math.max(Math.min(y,f),Math.min(Math.max(y,f),(n[h]+a[h])/2));e.rel.points=r(x?[n,{x:g,y:n.y},{x:g,y:a.y},a]:[n,{x:n.x,y:g},{x:a.x,y:g},a])}else{for(let e=q;e!==Q+G;e+=G)l(),A[e][X]+=Z;e.rel.points=r(A)}if(!e4(e.rel.points,n))throw new ez(e.rel.entity1,e.rel.entity2);delete e.rel.finalLabelPosition,u=!0}if(u&&(e6(e.entities,e.groups,a,a.map(e=>e.labelBlock??eO(e,t,i)),t,i,n),g=eK(e,t,i,n),x=eU(e)??eA(e,t,i,n)),g.length){l(a.length+g.length);let r=new Set(g),o=new Set(a.flatMap((e,t)=>r.has(e)?[t]:[]));e6(e.entities,e.groups,a,a.map(e=>e.labelBlock??eO(e,t,i)),t,i,n,{indices:o,admit:(a,r)=>(function(e,t,i,n,a,r){let o=e.relationships[t];if(!o.label)return!0;if(r.operations+=e.relationships.length+2*i.length+2,r.operations>4e5)throw new eI;let l={...o,points:i},s=Math.max(e.width,...i.map(e=>e.x+40)),d=Math.max(e.height,...i.map(e=>e.y+40)),h={...e,width:s,height:d,relationships:e.relationships.map((e,i)=>i===t?l:e)},p=[];return eG(h,n,a,r,!0,p),!p.includes(l)})(e,a,r,t,i,n)}),e.width=Math.max(e.width,...a.flatMap(e=>e.points.map(e=>e.x+40))),e.height=Math.max(e.height,...a.flatMap(e=>e.points.map(e=>e.y+40))),eK(e,t,i,n),x=eU(e)??eA(e,t,i,n)}let M=y(),k=f(),v=a.flatMap((e,n)=>{l();let a=x.get(e);if(!e.label||!a)return[];let r=eW(e.labelBlock??eO(e,t,i),a);if(!r)throw new ez(e.entity1,e.entity2);return[{index:n,box:r}]});for(let e of a)if(!e4(e.points,n))throw new ez(e.entity1,e.entity2);for(let t of a)for(let i=1;i<t.points.length;i++){for(let n of e.entities)if(l(),o(t.points[i-1],t.points[i],{...n,label:"",shape:"rectangle"}))throw new ez(t.entity1,t.entity2);for(let n of e.groups)if(l(),n.headerHeight>0&&o(t.points[i-1],t.points[i],{...n,height:n.headerHeight,label:"",shape:"rectangle"}))throw new ez(t.entity1,t.entity2)}let S=(e,t,i,n,r,o)=>{if(h.has(t)!==o)return!1;let s=a[e.index],d=e.first&&s.entity1===t?0:e.last&&s.entity2===t?1:void 0;if(void 0===d)return!1;let p=d?s.points.at(-1):s.points[0],y=d?s.points.at(-2):s.points[1],c=p.y>=i.y+r&&p.y<=i.y+i.height-r,f=p.x>=i.x+r&&p.x<=i.x+i.width-r;return l(),c&&y.y===p.y&&(p.x===i.x&&y.x<p.x&&e.box.x1<=i.x+n||p.x===i.x+i.width&&y.x>p.x&&e.box.x0>=i.x+i.width-n)||f&&y.x===p.x&&(p.y===i.y&&y.y<p.y&&e.box.y1<=i.y+n||p.y===i.y+i.height&&y.y>p.y&&e.box.y0>=i.y+i.height-n)};for(let i of k){let n=a[i.index];for(let a of e.entities){let e=Number.parseFloat(a.inlineStyle?.["stroke-width"]??""),r=(Number.isFinite(e)&&e>0?e:t.nodeLineWidth)/2,o={x0:a.x-r,y0:a.y-r,x1:a.x+a.width+r,y1:a.y+a.height+r};if(s(i.box,o)&&!S(i,a.id,a,r,Math.min(t.cornerRadius??0,a.width/2,a.height/2),!1))throw new ez(n.entity1,n.entity2)}for(let t of e.groups){let e={x0:t.x,y0:t.y,x1:t.x+t.width,y1:t.y+t.headerHeight};if(t.headerHeight>0&&s(i.box,e)&&!S(i,t.id,t,.75,6,!0))throw new ez(n.entity1,n.entity2)}}let R=new Map(M.map(e=>(l(4*e.pieces.length+1),[e,{x0:Math.min(...e.pieces.map(e=>e.x0)),y0:Math.min(...e.pieces.map(e=>e.y0)),x1:Math.max(...e.pieces.map(e=>e.x1)),y1:Math.max(...e.pieces.map(e=>e.y1))}])));for(let e of M)for(let t of M)if(l(),!(2*t.index+t.end<=2*e.index+e.end||!s(R.get(e),R.get(t)))){for(let i of e.pieces)if(t.pieces.some(e=>s(i,e)))throw new ez(e.rel.entity1,e.rel.entity2)}for(let e of M){let t=e.toward.x-e.point.x,i=e.toward.y-e.point.y,n=0===i&&0!==t,a=0===t&&0!==i,r=Math.sign(n?t:i),o=k.find(t=>(l(),t.index===e.index&&(e.end?t.last:t.first)))?.line,d=o&&(e.end?o[0]:o[1]),y=o&&(e.end?o[1]:o[0]);if(!n&&!a||!d||!y||(n?d.y!==y.y||Math.sign(d.x-y.x)!==r:d.x!==y.x||Math.sign(d.y-y.y)!==r)||r*((n?d.x:d.y)-(n?e.point.x:e.point.y))<c(e.pieces,e.point,n,r))throw new ez(e.rel.entity1,e.rel.entity2);for(let t of e.pieces){for(let i of p)if((i.id!==e.id||!!i.group!==h.has(e.id))&&s(t,i.box))throw new ez(e.rel.entity1,e.rel.entity2);for(let i of k)if((i.index!==e.index||!(e.end?i.last:i.first))&&s(t,i.box))throw new ez(e.rel.entity1,e.rel.entity2)}}for(let e of v){let t=a[e.index];for(let i of p)if(s(e.box,i.box))throw new ez(t.entity1,t.entity2);for(let i of M)if(s(e.box,R.get(i))&&i.pieces.some(t=>s(e.box,t)))throw new ez(t.entity1,t.entity2);for(let i of k)if(i.index!==e.index&&s(e.box,i.box))throw new ez(t.entity1,t.entity2);for(let i of v)if(i.index<e.index&&s(e.box,i.box))throw new ez(t.entity1,t.entity2)}return e}var ta=String.raw`[A-Za-z0-9_][\w.-]*(?![\w.-])`,tr=String.raw`"(?:\\.|[^"\\])*"`,to=RegExp(`^${tr}$`),tl=`(?:${tr}|${ta})`,ts=RegExp(`^${ta}$`),td=String.raw`${tl}(?:\[\s*(?:${tr}|[^\]"\r\n]+)\s*\])?(?::::[\w-]+(?:,[\w-]+)*)?`,th=new RegExp(String.raw`^(${tl})(?:\[\s*(?:(${tr})|([^\]"\r\n]+))\s*\])?(?::::([\w-]+(?:,[\w-]+)*))?$`),tp=String.raw`(?:one or zero|zero or one|one or more|one or many|zero or more|zero or many|only one|many\(0\)|many\(1\)|1\+|0\+|many|one|1|u(?=[.\-|])|[|o}{]+)`,ty=String.raw`(?:\|\||\|o|o\||\}o|o\{|\}\||\|\{|\bu(?=[.\-|]))`,tc=RegExp(`^(${td})(?:[ \\t]+(${tp})|(${ty}))(?:([ \\t]*(?:--|\\.\\.|\\.-|-\\.)[ \\t]*)|([ \\t]+(?:optionally to|to)[ \\t]+))(?:(${tp})[ \\t]+|(${ty}))(${td})(?:[ \\t]*:[ \\t]*(.*))?$`,"i");function tf(e,t){let i=e.trim().match(th);if(!i)return null;let n=i[1].startsWith('"')?eB(i[1],"ER entity name",t):i[1],a=void 0!==i[2]?eB(i[2],"ER entity alias",t):i[3]?.trim();return{id:n,...void 0!==a?{alias:a}:{},...i[4]?{className:i[4].replaceAll(","," ")}:{},...i[1].startsWith('"')?{quoted:!0}:{}}}function tg(e,t,i){let n=e.get(t);if(n)for(let e of i)n.push(e);else e.set(t,[...i])}var tx=RegExp(String.raw`^subgraph\s+(${tr}|\S+?)(?:\s*\[([^\]]+)\])?$`,"i"),tu=/#(\d{2}|\d{5}|\d{7});/g;function tm(e){let t="ER_STYLE_ENTITY_";for(;e.includes(t);)t+="_";let i=[],n=e.replace(tu,(e,n)=>{let a=Number(n);return i.push(a<=1114111?String.fromCodePoint(a):"�"),`${t}${i.length-1}_`}),a=RegExp(`${t}(\\d+)_`,"g"),r=e=>e.replace(a,(e,t)=>i[Number(t)]);return Object.fromEntries(Object.entries(I(n)).map(([e,t])=>[r(e),r(t)]))}function tb(e,i,n){let a=t(e);if(a)return{kind:"direction",direction:a};let r=function(e,t){let i=e.match(tx);if(!i)return null;let n=i[1].startsWith('"')?eB(i[1],"ER subgraph id",t):i[1],a=i[2]?.trim();return a?{id:n,title:to.test(a)?eB(a,"ER subgraph title",t):a}:{id:n}}(e,n);if(r)return{kind:"group-open",...r};if("end"===e&&i)return{kind:"end"};let o=e.match(/^classDef\s+([\w,-]+)\s+(.+)$/is);if(o)return{kind:"class-def",names:o[1].split(",").map(e=>e.trim()).filter(Boolean),props:tm(o[2])};let l=function(e,t){let i=/^class[ \t]+/i.exec(e);if(!i)return null;let n=e.slice(i[0].length).trimEnd(),a=n.length,r=[],o=e=>/[A-Za-z0-9_-]/.test(e);for(;a>0;){let e=a;for(;a>0&&o(n[a-1]);)a--;if(a===e)break;r.push(n.slice(a,e));let i=a;for(;a>0&&(" "===n[a-1]||" "===n[a-1]);)a--;if(","===n[a-1]){for(a--;a>0&&(" "===n[a-1]||" "===n[a-1]);)a--;continue}if(a===i||0===a)break;let l=n.slice(0,a).split(",").map(e=>tf(e.trim(),t));return 0===l.length||l.some(e=>null===e)?null:{ids:l.map(e=>e.id),classNames:r.reverse()}}return null}(e,n);if(l)return{kind:"class",...l};if(/^class(?:[ \t]|$)/i.test(e))throw Error(`Invalid ER class assignment: ${e}`);let s=e.match(/^style\s+(.+?)\s+(.+)$/is);if(s){let t=s[1].split(",").map(e=>tf(e.trim(),n));if(t.some(e=>null===e))throw Error(`Invalid ER style assignment: ${e}`);return{kind:"style",ids:t.map(e=>e.id),props:tm(s[2])}}let d=function(e,t){let i=e.match(tc);if(!i)return null;let n=i[2]??i[3];if("1"===n&&/^[ \t]/.test(i[4]??""))return null;let a=tf(i[1],t),r=tf(i[8],t);if(!a||!r)return null;let o=(i[4]??i[5]).trim().replace(/[ \t]+/g," ").toLowerCase();return{entity1:a,entity2:r,leftToken:n,rightToken:i[6]??i[7],identifying:"--"===o||"to"===o,label:function(e,t){let i=e.trim();if(!i.startsWith('"'))return i;if(/^"[^"]*"$/.test(i))return i.slice(1,-1);if(/^"(?:\\.|[^"\\])*"$/.test(i))return t?.(`ER relation label ${i} contains \\", which reads as "`,'write " as #quot;'),eT(i.slice(1,-1));throw P({what:`ER relation label ${i} is not one quoted string`,expectedForm:'one pair of quotes, with " written as #quot;',example:'A ||--o{ B : "says #quot;hi#quot;"'})}(i[9]??"",t),...!function(e){let t=e.replace(/#\w+;/g,"§");if(t.startsWith('"')||/direction\s+(?:TB|BT|LR|RL)/i.test(t))return!1;let i=/^(?:\P{ASCII}|[\w*.-])*/u.exec(t)[0],n=t.slice(i.length);return""===i||/^\d/.test(i)||tv.test(t)||tk.test(t)||/^[^\s"]/.test(n)||(n.match(/"/g)?.length??0)%2==1}(i[9]?.trim()??"")?/^[^"\s][^\s"]*(?:\s+\S|")/.test(i[9]?.trim()??"")?{unquotedWords:!0}:{}:{unreadLabel:!0}}}(e,n);if(d)return{kind:"relation",relation:d};let h=e.match(tw),p=h?tf(h[1],n):null;if(p)return{kind:"block-open",reference:p};let y=tf(e,n);return y?{kind:"entity",reference:y}:null}var tw=RegExp(`^(${td})\\s*\\{`),tM=RegExp(`^${td}`),tk=RegExp(String.raw`^(?:\|\||\|o|o\||\}o|o\{|\}\||\|\{|--|\.\.|\.-|-\.|u(?=[.|-])|1\+|0\+|1(?=\s+[\w"']|--|\.\.|\.-|-\.)|(?:one or zero|zero or one|one or more|one or many|zero or more|zero or many|only one|many\(0\)|many\(1\)|many|one|optionally to|to)(?!\w))`,"i"),tv=/^(?:(?:subgraph|end|style|classDef|class|erDiagram)(?!\w)|direction\s+(?:TB|BT|LR|RL))/i;function tS(e){let t=!1;for(let i=0;i<e.length;i++){let n=e[i];if(t)'"'===n&&(t=!1);else if('"'===n)t=!0;else if("`"===n&&(0===i||/\s/.test(e[i-1]))){let t=e.indexOf("`",i+1);t>i+1&&!/\s/.test(e.slice(i+1,t))&&(i=t)}else if("}"===n)return i}return -1}var tR=/[\w*\u00C0-\uFFFF]/,t$=/^[*A-Za-z_\u00C0-\uFFFF][\w\-[\]().,\u00C0-\uFFFF*]*$/,tL=/^`[^`]+`$/,t_=(e,t=e.text)=>"word"===e.kind&&((t.match(/~/g)?.length??0)>=2||t$.test(t)||tL.test(t))&&!/^(?:PK|FK|UK)\b/i.test(t),tE=e=>"word"===e.kind&&e.text.split(",").every(e=>!e||/^(?:PK|FK|UK)$/i.test(e));function tW(e,t,i,n){let a=e=>e.replace(/^`([^`]+)`(\?)?$/,(e,t,i)=>t+(i??"")),r=void 0===n?void 0:eN(en(n)),o=void 0===n?void 0:eH(n,r,!0);return{type:a(e),name:a(t),keys:i,comment:r,...o?{commentContent:o}:{}}}function tF(e,t,i){let n=(t,i)=>({syntax:t,start:i,end:"block-open"===t.kind?i+tw.exec(e.slice(i))[0].length:e.length}),a=tI(e,t,i);if(a)return a;let r=tb(e,t,i);if(r)return[n(r,0)];let o=[],l=[],s=[{syntax:{kind:"unknown"},start:0,end:e.length}];for(let i=0;i<e.length;){let a=e.slice(i);if(tk.test(a))return s;if(i>0){let e=[],r=tI(a,t,(t,i)=>e.push([t,i]));if(r){o.push(...r.map(e=>({...e,start:e.start+i,end:e.end+i}))),l.push(...e);break}let s=tb(a,t,(t,i)=>e.push([t,i]));if(s){o.push(n(s,i)),l.push(...e);break}}if(tv.test(a))return s;let r=tM.exec(a),d=r&&tf(r[0],(e,t)=>l.push([e,t]));if(!d)return s;o.push({syntax:{kind:"entity",reference:d},start:i,end:i+r[0].length}),i+=r[0].length,i+=e.slice(i).length-e.slice(i).trimStart().length}if(i)for(let[e,t]of l)i(e,t);return o}var tz=/^(?:[^":]|"[^"]*")*?:\s*"[^"]*"/;function tI(e,t,i){let n=tz.exec(e)?.[0].length??-1;if(n<0||!e.slice(n).trim())return null;let a=[],r=(e,t)=>{a.push([e,t])},o,l,s=e.length-e.slice(n).trimStart().length;try{if(o=tb(e.slice(0,n),t,r),o?.kind!=="relation")return null;l=tF(e.slice(s),t,r)}catch{return null}if(l.some(e=>"unknown"===e.syntax.kind))return null;if(i)for(let[e,t]of a)i(e,t);return[{syntax:o,start:0,end:n},...l.map(e=>({...e,syntax:e.syntax,start:e.start+s,end:e.end+s}))]}function tC(e,t){let i=e.get(t);return i||(i={id:t,label:t,attributes:[]},e.set(t,i),R("er")&&L("er","createEntity",i)),i}function tT(e){switch(e.toLowerCase()){case"u":return"parent";case"||":case"only one":case"1":case"one":return"one";case"|o":case"o|":case"one or zero":case"zero or one":return"zero-one";case"}|":case"|{":case"one or more":case"one or many":case"many(1)":case"1+":return"many";case"}o":case"o{":case"zero or more":case"zero or many":case"many(0)":case"0+":case"many":return"zero-many";default:return null}}function tB(e,t,i,n,a,r){let o={stroke:a.edgeStrokeColor??"var(--_line)",strokeWidth:String(a.lineWidth+.25)},l=e$(t,i,n,o);return e.shape({id:r,role:"cardinality",geometry:{kind:"compound",children:l.map(e=>e.geometry)},paint:o,...l.some(e=>e.paint!==o)?{childPaints:l.map(e=>e.paint)}:{},channels:{category:n}})}var tN=C(function(e,t){let{positioned:i,colors:n,resolved:a}=t,r=a.renderOptions,o=n.font??"Inter",l=r.transparent??!1,s=[],d=X(r,eX,a.styleFace),h=`er-${ec(i.width,i.height,i.entities.length,i.relationships.length)}`,p=`${h}-title`,y=`${h}-desc`,c=U(i.accessibilityTitle,i.accessibilityDescription,p,y);s.push(e.documentOpen({id:"prelude",width:i.width,height:i.height,colors:n,transparent:l,font:o,hasMonoFont:!0},K(i.width,i.height,n,l,c)+`
6
+ `+O(o,!0,n.shadow,n.embedFontImport)));let f=[];f.push("<defs>");let g=j(n);for(let t of(g&&f.push(g),f.push("</defs>"),s.push(e.definitions({id:"defs"},f.join(`
7
+ `))),i.accessibilityTitle&&s.push(e.documentContent({id:"acc-title",role:"chrome",nonPaint:"accessibility"},`<title id="${p}">${eo(i.accessibilityTitle)}</title>`)),i.accessibilityDescription&&s.push(e.documentContent({id:"acc-desc",role:"chrome",nonPaint:"accessibility"},`<desc id="${y}">${eo(i.accessibilityDescription)}</desc>`)),i.title&&s.push(e.text(J(i.title,d))),i.groups))s.push(function(e,t,i){let n=i.groupBorderColor??"var(--_node-stroke)",a=i.groupFillColor??"var(--_group-fill)",r=i.groupHeaderFillColor??"var(--_group-hdr)",o=i.groupTextColor??"var(--_text)",l=t.labelBlock??eZ(V(t.label,t.labelContent),i);return e.group({id:`er-group:${t.id}`,role:"group",open:`<g class="er-subgraph" data-id="${es(t.id)}" data-label="${ep(t.label)}"${t.parentId?` data-parent-id="${es(t.parentId)}"`:""}>`,close:"</g>",children:[{node:e.shape({id:`er-group:${t.id}:box`,role:"group",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:6,ry:6},paint:{fill:a,stroke:n,strokeWidth:"1.5"}}),indent:2},{node:e.shape({id:`er-group:${t.id}:header`,role:"group-header",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.headerHeight,rx:6,ry:6},paint:{fill:r,stroke:"none"}}),indent:2},{node:e.text({id:`er-group:${t.id}:label`,role:"label",text:l.text,block:l,x:t.x+10,y:t.y+t.headerHeight/2,fontSize:l.fontSize,anchor:"start",paint:{fill:o}}),indent:2}]})}(e,t,d));let x=new Map,u=new Set(i.groups.map(e=>e.id)),m=e=>({id:e,role:u.has(e)?"group":"entity"});for(let t of i.relationships){let i=`${t.entity1}-${t.entity2}`,n=x.get(i)??0;x.set(i,n+1),s.push(function(e,t,i,n,a,r){let o=t.identifying?"solid":"dashed",l={category:t.identifying?"identifying":"non-identifying"},s=ew(n,"relationship",l,{includeFallback:!1}),d=s?.bendRadius??i.edgeBendRadius,h={endpoints:{from:t.entity1,to:t.entity2,start:{owner:r(t.entity1)},end:{owner:r(t.entity2)}},relationship:{kind:t.identifying?"identifying":"non-identifying"},route:{ownership:"layout",bendRadius:d},labels:t.label?[{text:t.label,textContent:{value:t.label,prepared:ei(V(t.label,t.labelContent))}}]:[]};if(t.points.length<2)return e.connector({id:a,role:"relationship",geometry:{kind:"polyline",points:t.points},lineStyle:"invisible",paint:{},channels:l,...h});let p={className:"er-relationship",data:{cardinality1:t.cardinality1,cardinality2:t.cardinality2,identifying:String(t.identifying),...t.label?{label:em(t.label)}:{}}},y={stroke:s?.strokeColor??i.edgeStrokeColor??"var(--_line)",strokeWidth:String(s?.lineWidth??i.lineWidth),...t.identifying?{}:{strokeDasharray:"6 4"}};if(d>0&&t.points.length>2){let i=eb(t.points,d,{metric:"manhattan"});return e.connector({id:a,role:"relationship",geometry:i.geometry,lineStyle:o,paint:y,channels:l,...h,route:{...h.route,contours:i.contours},attributes:p})}return e.connector({id:a,role:"relationship",geometry:{kind:"polyline",points:t.points},lineStyle:o,paint:y,channels:l,...h,attributes:p})}(e,t,d,a.styleFace,`rel:${i}#${n}`,m))}for(let t of i.entities)s.push(function(e,t,i,n){let{id:a,x:r,y:o,width:l,height:s,headerHeight:d,rowHeight:h,label:p,attributes:y}=t,c=[],f=t.className?` ${es(t.className)}`:"",g=t.className?` data-class="${es(t.className)}"`:"",x=`<g class="entity${f}" data-id="${es(a)}" data-label="${ep(p)}"${g}>`,u=t.inlineStyle??{},m=void 0!==i.nodeTextColor,b=N(t.inlineStyle,n,m?void 0:i.groupHeaderFillColor??"var(--_group-hdr)"),w=N(t.inlineStyle,n,m?void 0:i.nodeFillColor??"var(--_node-fill)"),M=u.fill??i.nodeFillColor??"var(--_node-fill)",k=u.stroke??i.nodeBorderColor??"var(--_node-stroke)",v=Number.parseFloat(u["stroke-width"]??""),S=Number.isFinite(v)&&v>0?v:i.nodeLineWidth,R=u["stroke-dasharray"],$=void 0===R?{}:{strokeDasharray:R};c.push({indent:2,node:e.shape({id:`entity-rect:${a}`,role:"entity",geometry:{kind:"rect",x:r,y:o,width:l,height:s,rx:i.cornerRadius??0,ry:i.cornerRadius??0},paint:{fill:M,stroke:k,strokeWidth:String(S),...$}})});let L=u.fill??i.groupHeaderFillColor??"var(--_group-hdr)",_=eM(r,o,l,d,i.cornerRadius??0);c.push({indent:2,node:e.shape({id:`entity-header:${a}`,role:"group-header",geometry:{kind:"path",d:_},paint:{fill:L,stroke:k,strokeWidth:String(S),...$}})});let E=b(i.nodeTextColor??"var(--_text)"),W=t.labelBlock??eY(V(p,t.labelContent),i),F=W.text;c.push({indent:2,node:e.text({id:`entity-name:${a}`,role:"label",text:F,block:W,x:r+l/2,y:o+d/2,fontSize:i.nodeLabelFontSize,anchor:"middle",paint:{fill:E}})});let z=o+d,I=Math.min(i.nodeLineWidth,q.innerBox);c.push({indent:2,node:e.shape({id:`entity-divider:${a}`,role:"chrome",geometry:{kind:"line",x1:r,y1:z,x2:r+l,y2:z},paint:{stroke:k,strokeWidth:String(I),...$}})});let C=e8(y);for(let n=0;n<y.length;n++)for(let o of function(e,t,i,n,a,r,o,l,s,d){let h=[],p=`attr:${i}:${t.name}`,y=d??eQ(t),c=o.nodeTextColor??"var(--_text-sec)",f=l(c),g=l(o.nodeTextColor??"var(--_text-muted)"),x=0;if(t.keys.length>0){let i=t.keys.join(",");x=y.keys.width+8;let r=n+Math.max(6,o.nodePaddingX/2);h.push(e.shape({id:`${p}:key-badge`,role:"chrome",geometry:{kind:"rect",x:r,y:a-7,width:x,height:14,rx:2,ry:2},paint:{fill:"var(--_key-badge)"}})),h.push(e.text({id:`${p}:key-text`,role:"attribute",text:i,block:y.keys,x:r+x/2,y:a,fontSize:9,anchor:"middle",paint:{fill:c}}))}let u=n+Math.max(8,o.nodePaddingX/2)+(x>0?x+6:0);h.push(e.text({id:`${p}:type`,role:"attribute",text:t.type,block:y.type,x:u,y:a,fontSize:11,anchor:"start",paint:{fill:g},attributes:{className:"mono"}}));let m=n+r-Math.max(8,o.nodePaddingX/2);if(h.push(e.text({id:p,role:"attribute",text:t.name,block:y.name,x:m-s,y:a,fontSize:11,anchor:"end",paint:{fill:f},attributes:{className:"mono"}})),t.comment){let i=ej(t.comment,t.commentContent);h.push(e.text({id:`${p}:comment`,role:"attribute",text:i,block:y.comment,x:m,y:a,fontSize:11,anchor:"end",paint:{fill:g}}))}if(t.comment&&t.comment.length>0){let i=ea(t.comment);return[e.group({id:`${p}:row`,role:"attribute",open:`<g><title>${eo(i)}</title>`,close:"</g>",children:h.map(e=>({node:e,indent:0}))})]}return h}(e,y[n],a,r,z+n*h+h/2,l,i,w,C,t.attributeBlocks?.[n]))c.push({indent:2,node:o});if(0===y.length){let n=w(i.nodeTextColor??"var(--_text-muted)"),o=t.emptyAttributeBlock??eJ();c.push({indent:2,node:e.text({id:`entity-empty:${a}`,role:"attribute",text:o.text,block:o,x:r+l/2,y:z+h/2,fontSize:11,anchor:"middle",paint:{fill:n}})})}return e.group({id:`entity:${a}`,role:"entity",open:x,close:"</g>",children:c})}(e,t,d,n));let b=new Map;for(let t of i.relationships){let i=`${t.entity1}-${t.entity2}`,n=b.get(i)??0;b.set(i,n+1),s.push(...function(e,t,i,n){if(t.points.length<2)return[e.shape({id:n,role:"cardinality",geometry:{kind:"compound",children:[]},paint:{}})];let a=t.points[0],r=t.points[1],o=t.points[t.points.length-1],l=t.points[t.points.length-2];return[tB(e,a,r,t.cardinality1,i,`${n}:1`),tB(e,o,l,t.cardinality2,i,`${n}:2`)]}(e,t,d,`card:${i}#${n}`))}let w=eU(i)??eA(i,d,a.styleFace),M=new Map;for(let t of i.relationships){let i=`${t.entity1}-${t.entity2}`,n=M.get(i)??0;M.set(i,n+1),s.push(...function(e,t,i,n,a,r){if(!t.label||t.points.length<2)return[];let o={category:t.identifying?"identifying":"non-identifying"},l=ew(n,"relationship",o,{includeFallback:!1}),s=l?.fontSize??i.edgeLabelFontSize,d=r??eq(t.points),h=t.labelBlock??eO(t,i,n),p=h.text,y=e.shape({id:`${a}:bg`,role:"chrome",geometry:eE(h,d),paint:{fill:"var(--bg)",stroke:"var(--_inner-stroke)",strokeWidth:"0.5"},channels:o}),c=l?.textColor??i.edgeTextColor??"var(--_text-muted)";return[y,e.text({id:a,role:"label",text:p,block:h,x:d.x,y:d.y,fontSize:s,anchor:"middle",paint:{fill:c},channels:o})]}(e,t,d,a.styleFace,`rel-label:${i}#${n}`,w.get(t)))}return s.push(e.documentClose()),{family:"er",width:i.width,height:i.height,colors:n,transparent:l,parts:s}}),tP=S(eS,{configDiagnostics:e=>c("er",e,eR),normalizeRequest:t=>({renderOptions:function(t,i){if(!t)return i;let n=e(t,"er","nodeSpacing"),a=e(t,"er","rankSpacing");return void 0===n&&void 0===a?i:{...i,nodeSpacing:i.nodeSpacing??n,layerSpacing:i.layerSpacing??a}}(t.source.frontmatter,t.renderOptions)}),layout:e=>{let t=f(function(e,t){if(!t)return e;let i=g(t,["er","layoutDirection"]),n="string"==typeof i&&/^(TB|TD|BT|LR|RL)$/i.test(i)?i.toUpperCase():void 0;return void 0===e.direction&&void 0!==n?{...e,direction:n}:e}(W(function(e){let t=D(e);E(t),e=t.familyLines;let i={entities:[],classDefs:new Map,relationships:[],groups:[],...void 0!==t.accessibility.title?{accessibilityTitle:en(t.accessibility.title)}:{},...void 0!==t.accessibility.descr?{accessibilityDescription:en(t.accessibility.descr)}:{}};R("er")&&($("er","header",e[0]??"",{line:1,unit:"normalized"}),L("er","initialize",i));let n=function(e,t){let i,n,a,r,o,l,s,p,y,c,f=new Map,g=function(e,t,i){let n=[],a=0,r,o=e.findLastIndex(e=>e.includes('"')),l=t=>{let i=t.tokens[0],a=t.tokens.at(-1);n.push({syntax:"type"===t.last?{kind:"unknown"}:{kind:"attribute",attribute:function({tokens:e}){let t=+(e[1]?.text==="?"),i=e.slice(2+t).filter(e=>"word"===e.kind).flatMap(e=>e.text.split(",")).filter(Boolean).map(e=>e.toUpperCase()),n=e.find(e=>"comment"===e.kind);return tW(e[0].text+(t?"?":""),e[1+t].text,i,n?.text.slice(1,-1))}(t),text:function(e,{tokens:t}){return t.map((i,n)=>{let a=t[n-1];return a?((a.endLine??a.line)===i.line?e[i.line].slice(a.end,i.start):" ")+i.text:i.text}).join("")}(e,t),...!function({tokens:e}){let t=+(e[1]?.text==="?"),i=e.slice(2+t).filter(e=>"word"===e.kind).map(e=>e.text).join(" ");return""===i||/^(?:PK|FK|UK)(?:\s*,\s*(?:PK|FK|UK))*$/i.test(i)}(t)?{generous:!0}:{}},line:i.line,start:i.start,endLine:a.endLine??a.line,end:a.end})};for(let s=0;s<e.length;s++){let p=e[s],y=p.trim(),c=[],f=0,g=r?.comment;if(g&&y&&!y.startsWith("%%")){let e=p.indexOf('"');if(g.parts.push((e<0?p:p.slice(0,e)).trim()),i?.set(s,e<0?p.length:e+1),e<0)continue;c.push({kind:"comment",text:`"${g.parts.join(`
8
+ `)}"`,line:g.line,start:g.start,endLine:s,end:e+1}),r.comment=void 0,f=e+1}else if(!y||y.startsWith("%%")){n.push({syntax:{kind:y?"comment":"blank"},line:s,start:0,endLine:s,end:p.length});continue}let x=p.slice(f),u=f+x.length-x.trimStart().length+h(x.trim()).length,m=e=>{for(;e<u&&/\s/.test(p[e]);)e++;return e};for(let e=m(f);e<u||c.length>0;)if(r){let t=tS(p.slice(e,u)),i=t<0?u:e+t,a=[...c.splice(0),...function(e,t,i,n){let a=e.slice(i,n),r=new Map,o=[];for(let e=0,t=!1;e<a.length;e++)if('"'===a[e])t=!t;else{if("~"!==a[e]||t)continue;tR.test(a[e+1]??"")?o.push(e):o.length>0&&r.set(o.pop(),e)}let l=e=>{let t=e;for(;t<a.length&&!/[\s"]/.test(a[t]);)t++;return t},s=[],d=(e,n,r)=>{s.push({kind:e,text:a.slice(n,r),line:t,start:i+n,end:i+r})};for(let e=0;e<a.length;)if(/\s/.test(a[e]))e++;else if('"'===a[e]){let t=a.indexOf('"',e+1);d(t<0?"stray":"comment",e,t<0?e+1:t+1),e=t<0?e+1:t+1}else{let t=l(e),i=a.slice(e,t).indexOf("~"),n=i<0?void 0:r.get(e+i);void 0!==n&&n>=t&&(t=l(n+1)),d("word",e,t),e=t}return s}(p,s,e,i)],h=s<o?a.findIndex(e=>"stray"===e.kind):-1;h>=0&&(r.comment={line:s,start:a[h].start,parts:[p.slice(a[h].start+1,u).trimEnd()]},a=a.slice(0,h));let y=function(e,t){let i=[],n=e&&{tokens:[...e.tokens],last:e.last};for(let e of t)if(n?.last==="type")if("?"!==e.text||1!==n.tokens.length||n.tokens[0].text.endsWith("?"))if(!t_(e))return null;else n={tokens:[...n.tokens,e],last:"name"};else n.tokens.push(e);else if(n?.last==="name"&&tE(e))n.tokens.push(e);else if(n?.last==="name"&&"comment"===e.kind)n={tokens:[...n.tokens,e],last:"comment"};else{if(!t_(e,e.text.replace(/\?$/,"")))return null;n&&i.push(n),n={tokens:[e],last:"type"}}return{done:i,...n?{open:n}:{}}}(r.open,a);if(y){for(let e of y.done)l(e);r.open=y.open}else{r.open&&l(r.open),r.open=void 0,r.comment=void 0;let t=p.slice(e,i).trimEnd(),a=function(e){let t=e.match(/^(\S+)\s+(\S+)(?:\s+(.+))?$/);if(!t||/^(?:"|(?:PK|FK|UK)\b)/i.test(t[1])||!t.slice(1,3).every(e=>/[^\W_]|[\u00C0-\uFFFF]/.test(e))||d(e)>=0||tS(e)>=0)return null;let i=t[1],n=t[2],a=t[3]?.trim()??"",r=a.match(/"([^"]*)"/),o=[];for(let e of a.replace(/"[^"]*"/,"").trim().split(/[\s,]+/)){let t=e.toUpperCase();if("PK"===t||"FK"===t||"UK"===t)o.push(t);else if(e)return null}return tW(i,n,o,r?.[1])}(t);n.push({syntax:a?{kind:"attribute",attribute:a,text:t,generous:!0}:{kind:"unknown"},line:s,start:e,endLine:s,end:e+t.length})}if(t<0)break;r.open&&l(r.open),n.push({syntax:{kind:"block-close"},line:s,start:i,endLine:s,end:i+1}),r=void 0,e=m(i+1)}else{let i=tF(p.slice(e,u),a>0,t?(e,i)=>t(e,i,s):void 0);for(let{syntax:t,start:o,end:l}of i)n.push({syntax:t,line:s,start:e+o,endLine:s,end:e+l}),"group-open"===t.kind?a++:"end"===t.kind?a--:"block-open"===t.kind&&(r={});e=m(e+i.at(-1).end)}}return n.sort((e,t)=>e.line-t.line||e.start-t.start)}(e,void 0,f),x=[],u=new Set;for(let e=g.length-1;e>=0;e--)x[e]=u.has(g[e].endLine),u.add(g[e].line);let m=new Map,b=[],w=(i=[],n=new Set,a=new Map,r=[],o=new Set,l=[],s=new Map,p=H(),y=e=>{n.has(e)||(n.add(e),i.push(e))},{open(e){if(o.has(e))throw Error(`Duplicate ER subgraph id '${e}'`);o.add(e),r.push(e),l.push({id:e,names:[]})},close(){let e=l.pop();if(!e)throw Error("ER `end` closes no subgraph");s.set(e.id,p.close(e.id,e.names)),l.at(-1)?.names.push(e.id)},get innermost(){return l.at(-1)?.id},declare:c=(e,t)=>{y(e),void 0===t||a.has(e)||a.set(e,t),l.at(-1)?.names.push(e)},relationEnd:(e,t)=>!o.has(e)&&(c(e,t),!0),style:y,created:e=>n.has(e),finish(){let e=l.at(-1);if(e)throw P({what:`ER subgraph '${e.id}' is never closed`,expectedForm:"each subgraph closed by an end line",example:`subgraph G
9
+ A
10
+ end`});let t=new Map;for(let e of[...i,...r]){let i=p.ownerOf(e);void 0!==i&&t.set(e,i)}return{order:i,alias:a,owner:t,groups:r.map(e=>({id:e,...t.has(e)?{parentId:t.get(e)}:{},entityIds:s.get(e).filter(e=>n.has(e))}))}}}),M;for(let[t,{syntax:i,line:n,endLine:a,end:r}]of g.entries()){let o=m.get(n)??0,l=x[t]?r:e[a].length;m.set(a,l);let s=n===a?e[n].slice(o,l):[e[n].slice(o),...e.slice(n+1,a),e[a].slice(0,l)].join(`
11
+ `),d={line:n,column:o,endLine:a,endColumn:l,...void 0!==w.innermost?{groupId:w.innermost}:{},...void 0!==M?{entityId:M}:{}},h={raw:s,...d,syntax:i};switch(b.push(h),R("er")&&$("er",i.kind,h.raw,{line:n+2,unit:"normalized"}),i.kind){case"group-open":w.open(i.id),R("er")&&L("er","openGroup",{id:i.id,enclosingGroupId:d.groupId},{line:n+2,unit:"normalized"});break;case"end":w.close(),R("er")&&L("er","closeGroup",{id:d.groupId,enclosingGroupId:w.innermost},{line:n+2,unit:"normalized"});break;case"block-open":M=i.reference.id,w.declare(M,i.reference.alias),R("er")&&L("er","declareEntity",{...i.reference,groupId:d.groupId},{line:n+2,unit:"normalized"});break;case"block-close":M=void 0;break;case"entity":w.declare(i.reference.id,i.reference.alias),R("er")&&L("er","declareEntity",{...i.reference,groupId:d.groupId},{line:n+2,unit:"normalized"});break;case"relation":h.relationEntityIds=[i.relation.entity1,i.relation.entity2].filter(e=>{let t=w.relationEnd(e.id,e.alias);return R("er")&&L("er","nameRelationshipEndpoint",{...e,isEntity:t,groupId:d.groupId},{line:n+2,unit:"normalized"}),t}).map(e=>e.id);break;case"style":for(let e of i.ids)w.style(e),R("er")&&L("er","ensureStyledEntity",{id:e},{line:n+2,unit:"normalized"})}}if(void 0!==M)throw Error(`ER_UNCLOSED_ENTITY: entity '${M}' needs a closing }`);let k=w.finish();return R("er")&&L("er","resolvePlacement",k),{statements:b,placement:k,continuedComments:f}}(e.slice(1)),a=new Map,r=new Map,o=(e,t)=>{let i=tC(a,e);return t&&(tg(r,e,t.split(" ")),R("er")&&L("er","appendEntityClasses",{id:e,classNames:r.get(e)})),i},l=e=>o(e.id,e.className),s=new Map;for(let e of n.statements){let t=e.syntax;switch(t.kind){case"unknown":throw Error(`ER_UNSUPPORTED_STATEMENT: line ${e.line+2}: ${e.raw.trim()}`);case"attribute":a.get(e.entityId).attributes.push(t.attribute),R("er")&&L("er","addAttribute",{entityId:e.entityId,attribute:t.attribute},{line:e.line+2,unit:"normalized"});break;case"direction":{let n=void 0!==e.groupId?s.get(e.groupId):void 0;n?n.direction=t.direction:i.direction=t.direction,R("er")&&L("er","setDirection",{direction:t.direction,groupId:n?.id},{line:e.line+2,unit:"normalized"});break}case"group-open":s.set(t.id,{id:t.id,...eD(t.title??t.id,!0)}),R("er")&&L("er","upsertGroup",s.get(t.id),{line:e.line+2,unit:"normalized"});break;case"end":break;case"class-def":for(let n of t.names)i.classDefs.set(n,{...t.props}),R("er")&&L("er","setClassDefinition",{name:n,props:i.classDefs.get(n)},{line:e.line+2,unit:"normalized"});break;case"class":for(let i of t.ids)a.has(i)&&(tg(r,i,t.classNames),R("er")&&L("er","appendEntityClasses",{id:i,classNames:r.get(i)},{line:e.line+2,unit:"normalized"}));break;case"style":for(let i of t.ids){let n=tC(a,i);n.inlineStyle={...n.inlineStyle,...t.props},R("er")&&L("er","setEntityStyle",{id:i,props:n.inlineStyle},{line:e.line+2,unit:"normalized"})}break;case"block-open":case"entity":l(t.reference);break;case"relation":for(let n of(i.relationships.push(function(e,t){let i=tT(e.leftToken),n=tT(e.rightToken);if(!i||!n)throw Error(`Invalid ER cardinality "${e.leftToken}${e.identifying?"--":".."}${e.rightToken}" in "${t}" (valid tokens include ||, |o, o|, }o, o{, }|, |{ and Mermaid's word/numeric aliases)`);return{entity1:e.entity1.id,entity2:e.entity2.id,cardinality1:i,cardinality2:n,...eD(e.label,!0),identifying:e.identifying}}(t.relation,e.raw)),R("er")&&L("er","addRelationship",i.relationships.at(-1),{line:e.line+2,unit:"normalized"}),[t.relation.entity1,t.relation.entity2]))e.relationEntityIds.includes(n.id)&&o(n.id,n.className)}}let p=n.placement;for(let[e,t]of r)a.get(e).className=t.join(" "),R("er")&&L("er","resolveEntityClasses",{id:e,className:a.get(e).className});return i.entities=p.order.map(e=>{var t;let i=a.get(e);Object.assign(i,void 0!==(t=p.alias.get(e))?eD(t,!0):ts.test(e)?{label:e}:eD(e,!0));let n=p.owner.get(e);return R("er")&&L("er","resolveEntity",{...i,groupId:n}),void 0!==n?{...i,groupId:n}:i}),i.groups=p.groups.map(e=>{let t={...s.get(e.id),...void 0!==e.parentId?{parentId:e.parentId}:{},entityIds:e.entityIds};return R("er")&&L("er","resolveGroup",t),t}),z(i),i}(e.source.familyLines),e.source.accessibility),e.source.frontmatter),e.source.frontmatter);return B(t.classDefs,t.entities),v(function(e,t={},r){z(e);let o=X(t,eX,r),l={operations:0},s=e=>{try{return e()}catch(i){if(t.graphLayout?.backend!=="agentic"||"elk"!==t.graphLayout.fallback||!(i instanceof ez||i instanceof eF||i instanceof eI))throw i;let e=new eh([{strategy:"er-final-geometry",violations:[i.message]}]);throw e.cause=i,e}};if(0===e.entities.length){let i=()=>e.groups.length?tn(ti(eV(function(e,t,i,n={operations:0}){let a=e.relationships.map(e=>eO(e,t,i)),r=e0(e,a),o=te(e,t,i,n),l=(e.direction??"LR")==="LR"||(e.direction??"LR")==="RL",s="RL"===e.direction||"BT"===e.direction,d=e.groups.filter(e=>!e.parentId),h=s?[...d].reverse():d,p=[],y=(i,n,a)=>{let s=eZ(V(i.label,i.labelContent),t),d=t.groupHeaderFontSize+16+s.height-s.lineHeight,h={id:i.id,label:i.label,...i.labelContent?{labelContent:i.labelContent}:{},labelBlock:s,...i.parentId?{parentId:i.parentId}:{},x:n,y:a,width:Math.max(160,s.width+20),height:Math.max(100,d+20),headerHeight:d};p.push(h);let c=o.get(i.id)??20,f=n+c,g=a+d+c;for(let t of e.groups.filter(e=>e.parentId===i.id)){let e=y(t,f,g);h.width=Math.max(h.width,e.x+e.width-n+c),h.height=Math.max(h.height,e.y+e.height-a+Math.max(c,r.padding.get(i.id)??0)),l?f+=e.width+20:g+=e.height+Math.max(20,r.exits.get(t.id)??0)}return h},c=40,f=40;for(let e of h){let t=y(e,c,f);l?c+=t.width+40:f+=t.height+30}tt(e,[],p,t,a,r.padding,r.exits,20,i,n,o);let g=new Map(p.map(e=>[e.id,e])),x=e.relationships.map((e,t)=>{let i=g.get(e.entity1),n=g.get(e.entity2),a=[];return i&&n&&r.lanes.has(t)?a.push(...e1(i,n,r.lanes.get(t))):i&&n&&a.push(...e9(i,n)),{entity1:e.entity1,entity2:e.entity2,cardinality1:e.cardinality1,cardinality2:e.cardinality2,label:e.label,...e.labelContent?{labelContent:e.labelContent}:{},identifying:e.identifying,points:a}});e6([],p,x,a,t,i,n);let u=x.flatMap(e=>e.points),m=e2(x,a),b=Math.max(0,40-Math.min(...p.map(e=>e.x),...u.map(e=>e.x)),...m.map(e=>-e.x0)),w=Math.max(0,40-Math.min(...p.map(e=>e.y),...u.map(e=>e.y)),...m.map(e=>-e.y0));for(let e of p)e.x+=b,e.y+=w;for(let e of u)e.x+=b,e.y+=w;return{width:Math.max(...p.map(e=>e.x+e.width+40),...u.map(e=>e.x+40),...m.map(e=>e.x1+b),0),height:Math.max(...p.map(e=>e.y+e.height+40),...u.map(e=>e.y+40),...m.map(e=>e.y1+w),0),accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,entities:[],relationships:x,groups:p}}(e,o,r,l),o,r),e.title,o),o,r,l):ti({width:0,height:0,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,entities:[],relationships:[],groups:[]},e.title,o);return eg(t,()=>s(i),()=>(e5(l,0),i()),!0)}let d=function(e,t){let i=new Map;for(let n of e.entities){let e=eY(V(n.label,n.labelContent),t),a=e.width,r=0===n.attributes.length?eJ().width:0,o=e8(n.attributes);for(let e of n.attributes){let t=eQ(e),i=e.keys.length?t.keys.width+14:0,n=t.type.width+t.name.width+i+12+o;n>r&&(r=n)}let l=Math.max(140,a+2*t.nodePaddingX,r+2*Math.max(8,t.nodePaddingX)),s=Math.max(34,e.height+2*t.nodePaddingY),d=s+22*Math.max(n.attributes.length,1);i.set(n.id,{width:l,height:d,headerHeight:s})}return i}(e,o),h=t=>tn(ti(eV(function(e,t,i,n,a,r={operations:0}){let o=new Map;for(let e of t.entities)o.set(e.id,e);let l=[],s=T(t.classDefs.get("default"),"classDef default");for(let n of e.entities){let e=o.get(n.id);if(e){let a={...s};for(let i of e.className?.split(/[ \t]+/)??[])Object.assign(a,T(t.classDefs.get(i),`classDef ${i}`));l.push({id:e.id,label:e.label,...e.labelContent?{labelContent:e.labelContent}:{},attributes:e.attributes,x:n.x??0,y:n.y??0,width:n.width??i.get(e.id).width,height:n.height??i.get(e.id).height,headerHeight:i.get(e.id).headerHeight,rowHeight:22,...e.className?{className:e.className}:{},...Object.keys(a).length>0||e.inlineStyle?{inlineStyle:{...a,...T(e.inlineStyle,`style ${e.id}`)}}:{},...e.groupId?{groupId:e.groupId}:{}})}}let d=new Map(l.map(e=>[e.id,{x:e.x,y:e.y,width:e.width,height:e.height}])),h=t.relationships.map(e=>eO(e,n,a)),p=e0(t,h),y=te(t,n,a,r);!function(e,t,i,n,a,r){let o=new Set;for(let l of e.groups){if(!l.direction)continue;let s=l.entityIds.map(e=>t.find(t=>t.id===e)).filter(e=>!!e);if(s.length<2)continue;for(let e of s)o.add(e.id);let d="LR"===l.direction||"RL"===l.direction,h="RL"===l.direction||"BT"===l.direction?[...s].reverse():s,p=new Set(s.map(e=>e.id)),y=Math.max(48,...e.relationships.flatMap((e,t)=>{if(e5(r),!p.has(e.entity1)||!p.has(e.entity2))return[];let o=e_(e.cardinality1,n.lineWidth),l=e_(e.cardinality2,n.lineWidth);if(e5(r,2),!o||!l)throw new ez(e.entity1,e.entity2);let s=ew(a,"relationship",{category:e.identifying?"identifying":"non-identifying"},{includeFallback:!1})?.bendRadius??n.edgeBendRadius,h=Math.max(18,o.x1)+Math.max(18,l.x1)+2*s+2*(n.lineWidth+.25);return[Math.max(e.label?i[t][d?"width":"height"]+56:0,h+(e.label?i[t][d?"width":"height"]+20:0))]})),c=Math.min(...s.map(e=>e.x)),f=Math.min(...s.map(e=>e.y)),g=d?c:f;for(let e of h)d?(e.x=g,e.y=f,g+=e.width+y):(e.x=c,e.y=g,g+=e.height+y)}}(t,l,h,n,a,r);let c=function(e,t,i,n,a){let r=[];for(let o of[...e.groups].reverse()){let e=[...t.filter(e=>e.groupId===o.id),...r.filter(e=>e.parentId===o.id)],l=a.get(o.id)??20,s=eZ(V(o.label,o.labelContent),i),d=i.groupHeaderFontSize+16+s.height-s.lineHeight,h=e.length?Math.min(...e.map(e=>e.x))-l:40,p=e.length?Math.min(...e.map(e=>e.y))-l-d:40,y=Math.max(h+s.width+20,e.length?Math.max(...e.map(e=>e.x+e.width))+l:h+140),c=e.length?Math.max(...e.map(e=>e.y+e.height))+Math.max(l,n.get(o.id)??0):p+90;r.unshift({id:o.id,label:o.label,...o.labelContent?{labelContent:o.labelContent}:{},labelBlock:s,...o.parentId?{parentId:o.parentId}:{},x:h,y:p,width:y-h,height:c-p,headerHeight:d})}return r}(t,l,n,p.padding,y),f=e.preserveTerminalNormals?20+2*Math.max(n.edgeBendRadius,...t.relationships.map(e=>ew(a,"relationship",{category:e.identifying?"identifying":"non-identifying"},{includeFallback:!1})?.bendRadius??n.edgeBendRadius)):20;tt(t,l,c,n,h,p.padding,p.exits,f,a,r,y);let g=new Map;l.forEach(e=>g.set(e.id,e)),c.forEach(e=>g.set(e.id,e));let x=e.routes,u=[];for(let i=0;i<t.relationships.length;i++){let n=t.relationships[i],a=g.get(n.entity1),r=g.get(n.entity2),o=d.get(n.entity1),l=d.get(n.entity2),s=a&&o?a.x-o.x:void 0,y=a&&o?a.y-o.y:void 0,c=void 0!==s&&void 0!==y&&r&&l&&.001>Math.abs(r.x-l.x-s)&&.001>Math.abs(r.y-l.y-y)&&a.width===o.width&&a.height===o.height&&r.width===l.width&&r.height===l.height?x.get(i):void 0,f=[],m;if(a&&r&&p.lanes.has(i))f.push(...e1(a,r,p.lanes.get(i)));else if(c?.length){f.push(...c.map(e=>({x:e.x+s,y:e.y+y})));let t=e.labelPositions?.get(i);t&&(m={x:t.x+s,y:t.y+y})}else a&&r&&f.push(...e9(a,r));u.push({entity1:n.entity1,entity2:n.entity2,cardinality1:n.cardinality1,cardinality2:n.cardinality2,label:n.label,...n.labelContent?{labelContent:n.labelContent}:{},labelBlock:h[i],identifying:n.identifying,points:f,...m?{labelPosition:m}:{}})}e6(l,c,u,h,n,a,r);let m=[...l.flatMap(e=>[e.x,e.x+e.width]),...c.flatMap(e=>[e.x,e.x+e.width]),...u.flatMap(e=>e.points.map(e=>e.x))],b=[...l.flatMap(e=>[e.y,e.y+e.height]),...c.flatMap(e=>[e.y,e.y+e.height]),...u.flatMap(e=>e.points.map(e=>e.y))],w=e2(u,h),M=Math.max(0,m.length?40-Math.min(...m):0,...w.map(e=>-e.x0)),k=Math.max(0,b.length?40-Math.min(...b):0,...w.map(e=>-e.y0));if(0!==M||0!==k){for(let e of l)e.x+=M,e.y+=k;for(let e of c)e.x+=M,e.y+=k;for(let e of u){for(let t of e.points)t.x+=M,t.y+=k;e.labelPosition&&(e.labelPosition.x+=M,e.labelPosition.y+=k)}}return{width:Math.max((e.width??600)+M,...l.map(e=>e.x+e.width+40),...c.map(e=>e.x+e.width+40),...u.flatMap(e=>e.points.map(e=>e.x+40)),...w.map(e=>e.x1+M)),height:Math.max((e.height??400)+k,...l.map(e=>e.y+e.height+40),...c.map(e=>e.y+e.height+40),...u.flatMap(e=>e.points.map(e=>e.y+40)),...w.map(e=>e.y1+k)),accessibilityTitle:t.accessibilityTitle,accessibilityDescription:t.accessibilityDescription,entities:l,relationships:u,groups:c,...e.labelPlacement?{labelPlacement:e.labelPlacement}:{}}}(t,e,d,o,r,l),o,r),e.title,o),o,r,l);return eg(t,()=>s(()=>h((()=>{let i=new Map(e.entities.map((e,t)=>[e.id,t])),n=new Set(e.groups.map(e=>e.id)),s=new Set([...i.keys(),...n]),h=new Map,p=t.layerSpacing??90,y=0;for(let t of e.relationships){let e=ew(r,"relationship",{category:t.identifying?"identifying":"non-identifying"},{includeFallback:!1});for(let[i,a]of[[t.entity1,t.cardinality1],[t.entity2,t.cardinality2]]){let r=e_(a,o.lineWidth);if(e5(l),!r)throw new ez(t.entity1,t.entity2);let s=r.x1+(e?.lineWidth??o.lineWidth)/2+o.lineWidth+.25,d=s+Math.min(e?.bendRadius??o.edgeBendRadius,s);y=Math.max(y,d),p=Math.max(p,4*d),n.has(i)||h.set(i,(h.get(i)??0)+r.y1-r.y0+o.lineWidth+.25)}}let c=new Map(e.entities.map(e=>{let t=d.get(e.id),i=(h.get(e.id)??0)+2*Math.max(8,o.cornerRadius??0);return[e.id,{...t,width:Math.max(t.width,i),height:Math.max(t.height,i)}]})),f=e.relationships.flatMap((e,t)=>{let a=n.has(e.entity1)?void 0:i.get(e.entity1),l=n.has(e.entity2)?void 0:i.get(e.entity2);if(!s.has(e.entity1)||!s.has(e.entity2))throw Error("ER relationship references an undeclared entity or frame");if(void 0===a||void 0===l)return[];let d=eO(e,o,r);return[{relationshipIndex:t,source:a,target:l,minSpan:1,...e.label?{label:{width:d.width+16,height:d.height+16}}:{}}]}),g=el("agentic",()=>a({nodes:e.entities.map(e=>({id:e.id,...c.get(e.id)})),edges:f,direction:e.direction??"LR",padding:40,nodeSpacing:t.nodeSpacing??70,layerSpacing:p,...y>0?{minimumTerminalLead:y}:{},edgeSpacing:Math.max(6,o.lineWidth+4)}));return{width:g.width,height:g.height,preserveTerminalNormals:!0,labelPlacement:"shaft-aware",entities:g.nodes.map((t,i)=>({id:e.entities[i].id,...t,...c.get(e.entities[i].id)})),routes:new Map(g.edges.map((e,t)=>[f[t].relationshipIndex,e.points])),labelPositions:new Map(g.edges.flatMap((e,t)=>e.labelPosition?[[f[t].relationshipIndex,{...e.labelPosition}]]:[]))}})())),()=>h((()=>{e5(l,0);let{elkGraph:a}=function(e,t,i,n,a={operations:0}){let r=X(t,eX,n),o=0,l=new Map;for(let t of e.relationships){let e=ew(n,"relationship",{category:t.identifying?"identifying":"non-identifying"},{includeFallback:!1});for(let[n,s]of[[t.entity1,t.cardinality1],[t.entity2,t.cardinality2]]){e5(a,12);let d=e_(s,r.lineWidth);if(!d)throw new ez(t.entity1,t.entity2);o=Math.max(o,d.x1+(e?.bendRadius??r.edgeBendRadius)+(e?.lineWidth??r.lineWidth)/2),i.has(n)&&l.set(n,(l.get(n)??0)+d.y1-d.y0+r.lineWidth+.25)}}let s={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":eu(e.direction??"LR"),"elk.spacing.nodeNode":String(t.nodeSpacing??70),"elk.layered.spacing.nodeNodeBetweenLayers":String(t.layerSpacing??90),"elk.padding":"[top=40,left=40,bottom=40,right=40]","elk.edgeRouting":"ORTHOGONAL",...o>10?{"elk.layered.spacing.edgeNodeBetweenLayers":String(o)}:{},"elk.edgeLabels.placement":"CENTER"},children:[],edges:[]};for(let t of e.entities){let e=i.get(t.id),n=(l.get(t.id)??0)+2*Math.max(8,r.cornerRadius??0);e5(a),s.children.push({id:t.id,width:Math.max(e.width,n),height:Math.max(e.height,n)})}let d=new Set(e.entities.map(e=>e.id));for(let t=0;t<e.relationships.length;t++){let i=e.relationships[t];if(!d.has(i.entity1)||!d.has(i.entity2))continue;let a={id:`e${t}`,sources:[i.entity1],targets:[i.entity2]};if(i.label){let e=eO(i,r,n);a.labels=[{text:e.text,width:e.width+8,height:e.height+6}]}s.edges.push(a)}return{elkGraph:s,entitySizes:i}}(e,t,d,r,l),o=i(a);return{width:o.width,height:o.height,entities:o.children??[],routes:new Map((o.edges??[]).map(e=>{let t=e.sections?.[0];return[Number(e.id.slice(1)),t?n([t.startPoint,...t.bendPoints??[],t.endPoint]):[]]}))}})()),!0)}(t,e.renderOptions,e.styleFace))},projectPositioned:M(function({positioned:e,options:t}){let i=e.entities.map(e=>({id:e.id,x:x(e.x),y:x(e.y),w:u(e.x,e.width),h:u(e.y,e.height),shape:"rectangle",label:e.label,...w(e.labelBlock,e.x+e.width/2,e.y+e.headerHeight/2,{...e,height:e.headerHeight})})),n=new Map(e.entities.map(e=>[e.id,{x:e.x,y:e.y,width:e.width,height:e.height}])),a=eU(e);if("shaft-aware"===e.labelPlacement&&!a)throw Error("ER_LABEL_LAYOUT_MISSING: project the complete native family layout artifact");let r=a??eA(e,X({},eX));return{version:1,nodes:i,edges:e.relationships.map((e,i)=>{let a=r.get(e);return{id:`rel#${i}:${e.entity1}->${e.entity2}`,from:e.entity1,to:e.entity2,path:e.points.map(e=>[x(e.x),x(e.y)]),label:e.label&&a?{x:x(a.x),y:x(a.y),text:e.label,bounds:b(e.labelBlock,a.x,a.y)}:void 0,route:t.debug?m("er",i,e.points,n.get(e.entity1),n.get(e.entity2)):void 0}}),groups:e.groups.map(t=>({id:t.id,x:x(t.x),y:x(t.y),w:u(t.x,t.width),h:u(t.y,t.height),members:[...e.entities.filter(e=>e.groupId===t.id).map(e=>e.id),...e.groups.filter(e=>e.parentId===t.id).map(e=>e.id)],label:t.label,parentId:t.parentId})),bounds:{w:x(e.width),h:x(e.height)}}}),lowerScene:k(tN)});export{tP as default};
@@ -0,0 +1,19 @@
1
+ import{a as e}from"./chunk-BY2CPG6B.js";import"./chunk-SZELX2EJ.js";import{a as t}from"./chunk-2UIA2IME.js";import{c as i}from"./chunk-CN7WTBWB.js";import{D as n,a as r,b as o,c as a,d as l,e as s,g as d,i as c}from"./chunk-HLWUNUCM.js";import{B as f,H as p,M as h,c as m,o as g,q as u,qa as y,t as v,u as w,y as x}from"./chunk-X2UYKWKM.js";import{l as b,r as k,u as _}from"./chunk-TYZOZXUJ.js";import{h as E,l as $,n as M,o as S}from"./chunk-NO7ZIVRU.js";import{Ua as j,Z as W,da as z}from"./chunk-Z3FDIVLN.js";import{S as O,a as I}from"./chunk-N5ELX7LR.js";import"./chunk-5UVGUSD6.js";import"./chunk-CSFUKSU6.js";var R=Object.freeze({id:"eventmodeling",upstreamId:"eventmodeling",maturity:"experimental",label:"Event Modeling",headers:["eventmodeling"],aliases:[],config:{section:"eventmodeling",keys:["padding","rowHeight","useWidth","useMaxWidth","theme","look","layout"],noopKeys:["useWidth","useMaxWidth","theme","look","layout"]},identity:{id:"family:eventmodeling",kind:"family",version:"1.0.0",compatibility:{core:"0.5.3"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:[],semanticRoles:["prelude","title","chrome","node","label","group","edge","defs"],scenePrimitiveEvidence:[{role:"prelude",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"title",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"node",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"node",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"label",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"edge",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"marker",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]}],example:`eventmodeling
2
+ tf 01 ui CartUI
3
+ tf 02 cmd AddItem
4
+ tf 03 evt ItemAdded`,detect:O,detectLoose:O}),C={ui:"ui",pcr:"processor",processor:"processor",cmd:"command",command:"command",rmo:"readmodel",readmodel:"readmodel",evt:"event",event:"event"},U="[_a-zA-Z]\\w*(?:\\.[_a-zA-Z]\\w*)*",A=RegExp(`^(tf|timeframe|rf|resetframe)\\s+(\\d{1,3})\\s+(\\w+)\\s+(${U})`),F=new Set(["json","jsobj","figma","salt","uri","md","html","text"]);function D(e){let t=Object.hasOwn(C,e)?C[e]:void 0;if(!t)throw Error(`Unknown Event Modeling type: ${e}`);return t}function L(e,t){let i=e.match(/^(?:`(\w+)`\s*)?([\s\S]+)$/);if(!i||i[1]&&!F.has(i[1]))throw Error("Invalid Event Modeling data type");let n=i[2];if(t?!/^\{\s*\n[\s\S]*\n?\}$/.test(n):!/^(?:\{.*\}|".*"|'.*')$/.test(n))throw Error("Invalid Event Modeling data");return{...i[1]?{type:i[1]}:{},text:n.slice(1,-1).replace(t?/^\n|\n$/g:/$^/g,"")}}function B(e){let t=e.entity.split("."),i=t.length>1?t.slice(0,-1).join("."):"",n="event"===e.type?"Events":"command"===e.type||"readmodel"===e.type?"Command / Read Model":"UI / Automation";return i?`${i} \xb7 ${n}`:n}var P=new Set(["eventmodeling","rmo","readmodel","ui","cmd","command","evt","event","pcr","processor","json","jsobj","figma","salt","uri","md","html","text","tf","timeframe","rf","resetframe","entity","data","note","gwt","given","when","then","title"]);function T(e,t){let i=[],n="",r=t?[]:void 0,o=(e,t)=>{if(n+=e,r)for(let i=0;i<e.length;i++)r.push(t+i)},a=e.indexOf(`
5
+ `);a<0&&(a=e.length);let l=!0;for(let t=0;t<e.length;t++){let s=e[t],d=e[t+1];if(t>a){l=!n.slice(n.lastIndexOf(`
6
+ `)+1).trim();let i=e.indexOf(`
7
+ `,t);a=i<0?e.length:i}let c=l;if(l&&=/\s/.test(s),c&&("t"===s||"a"===s)&&/^(?:title(?:[ \t]|$)|accTitle[ \t]*:|accDescr[ \t]*:)/.test(e.slice(t,a))){let i=e.indexOf("%%",t);o(e.slice(t,i>=0&&i<a?i:a),t),t=a-1;continue}if("/"===s&&"*"===d){let n=e.indexOf("*/",t+2);if(n<0)throw Error("Unclosed Event Modeling comment");i.push([t,n+2]);let r=e.slice(t,n+2);o(r.replace(/[^\n]/g," "),t),l=c||r.includes(`
8
+ `),t=n+1;continue}if("%"===s&&"%"===d||"/"===s&&"/"===d){t=a-1;continue}if("{"===s){if(!e.slice(t+1,a).trim()&&a<e.length){let n=/^}[ \t]*(?=\n|$)/gm;n.lastIndex=a+1;let r=n.exec(e);if(!r)throw Error("Unclosed Event Modeling block");i.push([t,r.index+r[0].length]),o(e.slice(t,r.index+r[0].length),t),t=r.index+r[0].length-1;continue}let n=e.lastIndexOf("}",a-1);if(n<t)throw Error("Unclosed inline data");o(e.slice(t,n+1),t),t=n;continue}if('"'===s||"'"===s||"`"===s){let i="`"===s?e.indexOf(s,t+1):e.lastIndexOf(s,a-1);if(i<=t||i>=a)throw Error("Unclosed inline value");o(e.slice(t,i+1),t),t=i;continue}/\s/.test(e[t-1]??"")&&/[tredng]/.test(s)&&/^(?:tf|timeframe|rf|resetframe|entity|data|note|gwt)\s/.test(e.slice(t))&&n.slice(n.lastIndexOf(`
9
+ `)+1).trim()&&(n=n.trimEnd(),r&&(r.length=n.length),o(`
10
+ `,t)),o(s,t)}return{text:n,offsets:r,protectedSpans:i}}function Z(e,t){let i=v(e),n=i.map((e,t)=>t);for(let[e,r]of t){let t=w(i,e).line-1,o=w(i,Math.max(e,r-1)).line-1;n[t]=Math.max(n[t],o)}return n}var H=k("eventmodeling-arrow",{width:8,height:8},"end",{fill:"var(--_line)"},"userSpaceOnUse"),X=e([H]),N=m(function(e,{positioned:i,colors:n,resolved:r}){let o=i.style,a=y(n),l=o.edgeStrokeColor?{...H,paint:{...H.paint,fill:o.edgeStrokeColor}}:H,s=[e.definitions({id:"defs",markerResources:[l]},`<defs>${_([l])}</defs>`)];for(let t of(i.title&&s.push(e.text(S(i.title,o))),i.lanes)){let n={id:t.id,role:"group"};s.push(e.group({id:t.id,role:"group",open:"<g>",close:"</g>",children:[{node:e.shape({id:`${t.id}:surface`,role:"group",identity:!1,owner:n,geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:o.groupCornerRadius},paint:{fill:o.groupFillColor??"var(--_group-fill)",stroke:o.groupBorderColor??"var(--_node-stroke)",strokeWidth:String(o.groupLineWidth)}}),indent:2},...o.groupHeaderFillColor?[{node:e.shape({id:`${t.id}:header`,role:"chrome",owner:n,geometry:{kind:"rect",x:t.x,y:t.y,width:i.laneWidth,height:t.height,rx:o.groupCornerRadius},paint:{fill:o.groupHeaderFillColor,stroke:"none"}}),indent:2}]:[],{node:e.text({id:`${t.id}:label`,role:"label",owner:n,text:t.block.text,block:t.block,x:t.x+o.groupLabelPaddingX,y:t.y+t.height/2,anchor:"start",fontSize:t.block.fontSize,fontWeight:t.block.fontWeight,letterSpacing:t.block.letterSpacing,paint:{fill:o.groupTextColor??a("var(--_text)",o.groupHeaderFillColor??o.groupFillColor??"var(--_group-fill)")}}),indent:2}]}))}for(let t of i.edges)s.push(e.connector({id:t.id,role:"edge",geometry:t.projection?.geometry??{kind:"polyline",points:t.points},route:{ownership:"layout",bendRadius:o.edgeBendRadius,...t.projection?{contours:t.projection.contours}:{}},lineStyle:"solid",paint:{stroke:o.edgeStrokeColor??"var(--_line)",strokeWidth:String(o.lineWidth)},endpoints:{from:t.from,to:t.to},relationship:{kind:t.explicit?"explicit":"inferred",direction:"forward"},markers:{end:l}}));for(let t of i.nodes){let i={id:t.id,role:"node"},n=o.nodeFillColor??"var(--_node-fill)";s.push(e.group({id:t.id,role:"node",open:`<g data-parent="${t.lane}">`,close:"</g>",children:[{node:e.shape({id:`${t.id}:surface`,role:"node",identity:!1,owner:i,geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:o.cornerRadius??5},paint:{fill:n,stroke:o.nodeBorderColor??"var(--_node-stroke)",strokeWidth:String(o.nodeLineWidth)}}),indent:2},{node:e.text({id:`${t.id}:label`,role:"label",owner:i,text:t.block.text,block:t.block,x:t.x+t.width/2,y:t.y+t.height/2,anchor:"middle",fontSize:t.block.fontSize,fontWeight:t.block.fontWeight,letterSpacing:t.block.letterSpacing,paint:{fill:o.nodeTextColor??a("var(--_text)",n)}}),indent:2}]}))}return t(e,"eventmodeling",i,n,r.renderOptions.transparent??!1,s)}),Y=l(R,{normalizeRequest:e=>{let t=e.source.config.eventmodeling,i=t?.padding,n=t?.rowHeight;return{renderOptions:{...e.renderOptions,...void 0===e.renderOptions.padding&&"number"==typeof i&&Number.isFinite(i)&&i>=0?{padding:i}:{}},familyConfig:{rowHeight:"number"==typeof n&&Number.isFinite(n)&&n>=0?n:0},appearance:{family:{palette:e.colors}}}},statementEnds:function(e){let t=e.join(`
11
+ `);try{return Z(t,T(t,!1).protectedSpans)}catch{return e.map((e,t)=>t)}},layout:e=>{let t=function(e,t){let i=(Array.isArray(e)?e.join(`
12
+ `):e).replace(/\r\n/g,`
13
+ `),n=T(i,!1),r=n.text.split(`
14
+ `),o=x(i.split(`
15
+ `),Z(i,n.protectedSpans)),a={kind:"eventmodeling",frames:[],entities:[],data:Object.create(null),notes:[],specifications:[],...f(u(o.accessibility))},l=I(i);if(l){let e=p(l.yaml);if(!e.ok)throw Error(e.message);e.value&&"object"==typeof e.value&&"title"in e.value&&"string"==typeof e.value.title&&(a.title=e.value.title)}let m=new Set,y=r.findIndex(e=>"eventmodeling"===e.trim());if(y<0)throw Error("Expected eventmodeling header");let b,k="given";for(y++;y<r.length;y++){let e=r[y].trim();if(!e||e.startsWith("%%")||e.startsWith("//"))continue;if(d("eventmodeling","statement",e,{line:y+1,unit:"normalized"}),e.startsWith("title ")){a.title=g(e.slice(6));continue}if(e.startsWith("accTitle:")){a.accessibilityTitle=e.slice(9).trim();continue}if(e.startsWith("accDescr:")){a.accessibilityDescription=e.slice(9).trim();continue}if(e.startsWith("accDescr {")){let t=[e.slice(10)];for(;!t[t.length-1].includes("}")&&++y<r.length;)t.push(r[y]);if(!t[t.length-1].includes("}"))throw Error("Unclosed accessibility description");a.accessibilityDescription=t.join(`
16
+ `).replace(/}\s*$/,"").trim();continue}let t=e.match(A);if(t){if(m.has(t[2])){let o=n.offsets??T(i,!0).offsets,a=r.slice(0,y).reduce((e,t)=>e+t.length+1,0)+r[y].indexOf(e),l=w(v(i),o[a]??i.length);throw Error(`Duplicate event modeling frame ID "${t[2]}" on line ${l.line}`)}m.add(t[2]),b=void 0;let o=e.slice(t[0].length).trim(),l=[];for(;o.startsWith("->>");){let e=o.match(/^->>\s*(\d{1,3})(?=\s|$)/);if(!e)throw Error("Invalid frame reference");l.push(e[1]),o=o.slice(e[0].length).trim()}let d=o.match(/^\[\[(\w+)\]\]/);d&&(o=o.slice(d[0].length).trim()),a.frames.push({id:t[2],reset:"rf"===t[1]||"resetframe"===t[1],type:D(t[3]),entity:t[4],sources:l,...d?{dataReference:d[1]}:{},...o?{data:L(o,!1)}:{}}),s("eventmodeling")&&c("eventmodeling","append-frame",a.frames.at(-1)),h("nodes",a.frames.length);continue}let o=e.match(RegExp(`^entity\\s+(${U})$`));if(o){a.entities.push(o[1]),b=void 0;continue}let l=e.match(/^(data\s+([_a-zA-Z]\w*)|note\s+(\d{1,3}))(?:\s+([\s\S]+))?$/);if(l){b=void 0;let e=l[4]??"";for(;!e.includes("{");){if(++y>=r.length)throw Error("Unclosed Event Modeling data block");e+=(e?`
17
+ `:"")+r[y].trim()}let t=[e];for(;!/^}\s*$/.test(r[++y]??"");){if(y>=r.length)throw Error("Unclosed Event Modeling data block");t.push(r[y])}t.push("}");let i=L(t.join(`
18
+ `),!0);if(l[2]){if(Object.hasOwn(a.data,l[2]))throw Error(`Duplicate data: ${l[2]}`);a.data[l[2]]=i}else a.notes.push({frame:l[3],data:i});continue}let f=e.match(/^gwt\s+(\d{1,3})\s*(.*)$/);if(f&&(k="given",b={frame:f[1],given:[],when:[],then:[]},a.specifications.push(b),e=f[2]),b){let t=e.split(/\s+/).filter(Boolean);for(;t.length;){let e=t.shift();if("given"===e||"when"===e||"then"===e){["given","when","then"].indexOf(e),k=e;continue}let i=t.shift();if(!i||!/^[_a-zA-Z]\w*$/.test(i))throw Error("Invalid specification entity");b[k].push({type:D(e),entity:i})}continue}throw Error(`Unsupported Event Modeling statement: ${e}`)}return function(e,t=!1){if(t&&[...new Set([...e.frames.map(e=>e.entity),...e.entities,...Object.keys(e.data),...e.specifications.flatMap(e=>[...e.given,...e.when,...e.then].map(e=>e.entity))].filter(e=>e.split(".").some(e=>P.has(e))))].length)throw Error("Event Modeling identifiers cannot use reserved Mermaid grammar keywords");let i=new Set;for(let t of[e.title,e.accessibilityTitle,e.accessibilityDescription])if(void 0!==t&&"string"!=typeof t)throw Error("Metadata must be text");let n=(e,t)=>{if(!e||"object"!=typeof e||Array.isArray(e)||Object.keys(e).some(e=>!t.includes(e)))throw Error("Unknown or malformed Event Modeling record field")},r=e=>{if(n(e,["text","type"]),!e||"string"!=typeof e.text||void 0!==e.type&&!F.has(e.type))throw Error("Invalid data record")};for(let t of e.entities)if("string"!=typeof t||!RegExp(`^${U}$`).test(t))throw Error("Invalid entity declaration");if(new Set(e.entities).size!==e.entities.length)throw Error("Duplicate entity declaration");for(let[t,i]of Object.entries(e.data)){if(!/^[_a-zA-Z]\w*$/.test(t))throw Error("Invalid data identifier");r(i)}for(let t of e.notes)n(t,["frame","data"]),r(t.data);for(let t of e.frames){if(n(t,["id","reset","type","entity","sources","dataReference","data"]),"string"!=typeof t.id||!/^\d{1,3}$/.test(t.id)||i.has(t.id))throw Error(`Duplicate or invalid frame ID: ${t.id}`);if(i.add(t.id),"boolean"!=typeof t.reset||!Array.isArray(t.sources)||!t.sources.every(e=>"string"==typeof e))throw Error("Invalid frame record");if(t.data&&r(t.data),"string"!=typeof t.entity||!RegExp(`^${U}$`).test(t.entity)||!Object.values(C).includes(t.type))throw Error("Invalid frame entity or type")}for(let t of e.frames){for(let e of t.sources)if(!i.has(e)||e===t.id)throw Error(`Invalid source frame: ${e}`);if(new Set(t.sources).size!==t.sources.length)throw Error("Duplicate frame relation");if(void 0!==t.dataReference&&("string"!=typeof t.dataReference||!/^[_a-zA-Z]\w*$/.test(t.dataReference)))throw Error("Invalid data reference");if(t.dataReference&&!Object.hasOwn(e.data,t.dataReference))throw Error(`Unknown data: ${t.dataReference}`)}for(let t of e.notes)if(!i.has(t.frame))throw Error(`Unknown note frame: ${t.frame}`);for(let t of e.specifications){if(n(t,["frame","given","when","then"]),!Array.isArray(t.given)||!Array.isArray(t.when)||!Array.isArray(t.then))throw Error("Invalid specification statements");if(!i.has(t.frame)||!t.given.length||!t.then.length)throw Error("Invalid Given/When/Then specification");for(let e of[...t.given,...t.when,...t.then])if(n(e,["type","entity"]),!Object.values(C).includes(e.type)||"string"!=typeof e.entity||!/^[_a-zA-Z]\w*$/.test(e.entity))throw Error("Invalid specification type or entity")}}(a),a}(e.source.authoredFamilyBody??e.source.familyBody);return void 0===t.title&&"string"==typeof e.source.frontmatter.title&&(t.title=e.source.frontmatter.title),a(function(e,t={},i,n=0,r){let o=E(t,void 0,i),a=t.padding??24,l=j({stroke:o.nodeBorderColor??(r?b(r).nodeStroke:"var(--_node-stroke)"),strokeWidth:String(o.nodeLineWidth)},!1)??0,s=(function(e){let t=new Map;for(let i of e.frames){let e=B(i),n=t.get(e)??{id:`lane:${t.size}`,label:e,members:[]};n.members.push(i.id),t.set(e,n)}return[...t.values()]})(e).map(e=>({...e,block:W(e.label,{display:"literal",fontFamily:o.groupFont??t.font,fontSize:o.groupHeaderFontSize,fontWeight:o.groupHeaderFontWeight,letterSpacing:o.groupLetterSpacing,transform:o.groupTextTransform,maxWidth:220}),x:a,y:0,width:0,height:0})),d=new Map(s.map(e=>[e.label,e])),c=function(e){let t=[],i,n;for(let r of e.frames){let e=void 0!==i&&B(i)===B(r),o=e?n:i,a=[...r.sources];for(let e of(r.reset||!o||a.length||a.unshift(o.id),a))t.push({id:`relation:${e}:${r.id}`,from:e,to:r.id,explicit:r.sources.includes(e)});e||(n=i),i=r}return h("edges",t.length),t}(e),f=new Map(e.frames.map(e=>[e.id,{incoming:0,outgoing:0}]));for(let e of c)f.get(e.from).outgoing++,f.get(e.to).incoming++;let p=Math.max(12,8+o.lineWidth),m=$(e.title,o),g=Math.max(140,...s.map(e=>o.groupLabelPaddingX+e.block.width+o.groupPaddingX))+l,u=e.frames.map((i,n)=>{let r,a,s,c,h,m=(a=(r="string"==typeof i?e.frames.find(e=>e.id===i):i).id,s=r.data??(r.dataReference?e.data[r.dataReference]:void 0),c=e.notes.filter(e=>e.frame===a).map(e=>`Note: ${e.data.text}`),h=e.specifications.filter(e=>e.frame===a).flatMap(e=>["given","when","then"].filter(t=>e[t].length).map(t=>`${t}: ${e[t].map(e=>`${e.type} ${e.entity}`).join(", ")}`)),W([`${r.id} \xb7 ${r.type}${r.reset?" · reset":""}`,r.entity,...s?[s.text]:[],...c,...h].join(`
19
+ `),{display:"literal",fontFamily:t.font,fontSize:o.nodeLabelFontSize,fontWeight:o.nodeLabelFontWeight,letterSpacing:o.nodeLetterSpacing,transform:o.nodeTextTransform,maxWidth:220})),g=Math.max(120,m.width+2*(o.nodePaddingX+l)),u=f.get(i.id),y=Math.max(u.incoming,u.outgoing),v=Math.max(6+l,o.nodePaddingY+l,Math.min(o.cornerRadius??5,g/2));return{id:i.id,frame:i,block:m,lane:d.get(B(i)).id,x:0,y:0,width:g,height:Math.max(64,m.height+2*(o.nodePaddingY+l),y>1?(y-1)*p+2*v:0),index:n}}),y=Math.max(160,...u.map(e=>e.width)),v=Math.max(48,t.nodeSpacing??48,2*l+16),w=Math.max(2*a+g+Math.max(1,u.length)*y+Math.max(0,u.length-1)*v+Math.max(o.groupPaddingX+l,v/2+o.lineWidth),(m?.width??0)+2*a),x=new Map;for(let e of u){let t=x.get(e.lane)??[];t.push(e),x.set(e.lane,t)}let k=a+(m?.height??0)+v/2+Math.max(4,o.lineWidth);for(let e of s){let t=x.get(e.id)??[];for(let i of(e.y=k,e.height=Math.max(n,e.block.height+2*o.groupPaddingY,...t.map(e=>e.height+2*(o.groupPaddingY+l))),e.width=w-2*a,t))i.x=a+g+i.index*(y+v),i.y=k+(e.height-i.height)/2;k+=e.height+v}let _=new Map(u.map(e=>[e.id,e])),S=new Map(s.map(e=>[e.id,e])),O=new Map,I=new Map,R=c.map((e,t)=>{let i=_.get(e.from),n=_.get(e.to),r=I.get(i.id)??0,a=O.get(n.id)??0;I.set(i.id,r+1),O.set(n.id,a+1);let s={x:i.x+i.width+l,y:i.y+i.height/2+(r-(f.get(i.id).outgoing-1)/2)*p},d={x:n.x-l,y:n.y+n.height/2+(a-(f.get(n.id).incoming-1)/2)*p},c=i.x+y+v/2,h=n.x-v/2,m=S.get(i.lane).y-v/2,g=i.lane===n.lane&&n.index===i.index+1&&s.y===d.y?[s,d]:n.index===i.index+1?[s,{x:c,y:s.y},{x:c,y:d.y},d]:[s,{x:c,y:s.y},{x:c,y:m},{x:h,y:m},{x:h,y:d.y},d],u=o.edgeBendRadius>0?z(g,o.edgeBendRadius,{precision:3,terminalClearance:{end:X(H.id,o.lineWidth,"end")}}):void 0;return{...e,points:u?.geometry.points??g,projection:u,index:t}});return{style:o,laneWidth:g,width:w,height:Math.max(k+a,2*a+40),lanes:s,nodes:u,edges:R,...m?{title:M(m,w,a)}:{}}}(t,e.renderOptions,e.styleFace,e.familyConfig?.rowHeight,e.familyAppearance?.palette))},projectPositioned:r(({positioned:e})=>({version:1,bounds:{w:i(e.width),h:i(e.height)},nodes:e.nodes.map(e=>({id:e.id,x:i(e.x),y:i(e.y),w:i(e.width),h:i(e.height),shape:"rectangle",label:e.frame.entity,parentId:e.lane,...n(e.block,e.x+e.width/2,e.y+e.height/2,e)})),edges:e.edges.map(e=>({id:e.id,from:e.from,to:e.to,path:e.points.map(e=>[i(e.x),i(e.y)])})),groups:e.lanes.map(t=>({id:t.id,label:t.label,x:i(t.x),y:i(t.y),w:i(t.width),h:i(t.height),members:e.nodes.filter(e=>e.lane===t.id).map(e=>e.id)})),labels:[]})),lowerScene:o(N)});export{Y as default};
@@ -0,0 +1,4 @@
1
+ import{a as e,b as i,d as t}from"./chunk-OZ443IVJ.js";import{b as a}from"./chunk-BU5LHXNJ.js";import"./chunk-E2WMJZNM.js";import"./chunk-VWVZGQE2.js";import{a as r}from"./chunk-GVOEAY52.js";import"./chunk-NMQQMRIR.js";import"./chunk-ICC7HBJX.js";import"./chunk-4LHYF3BS.js";import"./chunk-CQE4HQEW.js";import"./chunk-LH7HUDKW.js";import"./chunk-5FQ534HP.js";import"./chunk-BY2CPG6B.js";import"./chunk-SZELX2EJ.js";import"./chunk-2GPK4VFF.js";import"./chunk-QA6GJQ4X.js";import{b as o}from"./chunk-2SH76OTH.js";import{d as n}from"./chunk-AMJLVPUB.js";import{u as c,z as s}from"./chunk-DF6765YX.js";import"./chunk-J35HAQQF.js";import{a as l,b as p,c as m,d as d}from"./chunk-HLWUNUCM.js";import{da as f}from"./chunk-X2UYKWKM.js";import"./chunk-TYZOZXUJ.js";import{h as h}from"./chunk-NO7ZIVRU.js";import{C as _,Z as u}from"./chunk-Z3FDIVLN.js";import{h as v}from"./chunk-N5ELX7LR.js";import"./chunk-5UVGUSD6.js";import"./chunk-CSFUKSU6.js";var b=Object.freeze({id:"flowchart",upstreamId:"flowchart-v2",maturity:"stable",label:"Flowchart",headers:["flowchart","graph"],aliases:["swimlane"],config:{section:"flowchart",keys:["nodeSpacing","rankSpacing","wrappingWidth","titleTopMargin","subGraphTitleMargin","arrowMarkerAbsolute","diagramPadding","htmlLabels","curve","padding","defaultRenderer","inheritDir","look","minNodeWidth","theme"],noopKeys:["arrowMarkerAbsolute","curve","defaultRenderer","diagramPadding","htmlLabels","inheritDir","look","minNodeWidth","padding","subGraphTitleMargin","theme","titleTopMargin"]},identity:{id:"family:flowchart",kind:"family",version:"1.0.0",compatibility:{core:"0.5.3"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:[],semanticRoles:["prelude","title","defs","chrome","group","group-header","edge","edge-label","node","label","icon"],scenePrimitiveEvidence:[{role:"prelude",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"title",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"marker",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group-header",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group-header",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"edge",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"edge-label",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"node",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"node",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"label",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"icon",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"icon",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"icon",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]}],example:`flowchart TD
2
+ A[Start] --> B{Ship?}
3
+ B -->|yes| C[Deploy]
4
+ B -->|no| D[Fix]`,detect:v,detectLoose:v}),y={nodeSpacing:o,rankSpacing:o,wrappingWidth:o};function g(e,i){let t=s(e,["flowchart",i]);return"number"==typeof t&&Number.isFinite(t)&&t>0?t:void 0}var k=d(b,{configDiagnostics:e=>n("flowchart",e,y),statementEnds:i,normalizeRequest:e=>({renderOptions:function(e,i){if(!e)return i;let t=g(e,"nodeSpacing"),a=g(e,"rankSpacing"),r=g(e,"wrappingWidth");return void 0===t&&void 0===a&&void 0===r?i:{...i,nodeSpacing:i.nodeSpacing??t,layerSpacing:i.layerSpacing??a,wrappingWidth:i.wrappingWidth??r}}(e.source.frontmatter,e.renderOptions)}),layout:e=>{let i=t(e.source.authoredFamilyBody??e.source.familyBody,e.source.familyBody);f(i),function(e,i,t){let a=i.wrappingWidth,r=h(i,void 0,t);for(let i of e.nodes.values()){let e=a??(i.markdownLabel?200:void 0);if(void 0===e||!i.label){delete i.labelBlock;continue}i.labelBlock=u(_(i.label,i.labelContent),{maxWidth:e,transform:r.nodeTextTransform,fontSize:r.nodeLabelFontSize,fontWeight:r.nodeLabelFontWeight,letterSpacing:r.nodeLetterSpacing})}}(i,e.renderOptions,e.styleFace);let a=c(e.source.frontmatter);return m(r(i,{...e.renderOptions,...e.styleFace?{styleFace:e.styleFace}:{},...a?{diagramTitle:a}:{}}))},projectPositioned:l(e),lowerScene:p(a)});export{k as default};
@@ -0,0 +1 @@
1
+ import"./chunk-CSFUKSU6.js";function e(e){let{nodes:t,edges:n,padding:i,nodeSpacing:r,layerSpacing:h}=e;if(t.length<2||n.length>=t.length||r<=0||h<=0||![i,r,h].every(e=>Number.isFinite(e)&&e>=0)||t.some(e=>!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0))return;let l=t.map(()=>[]),o=new Uint32Array(t.length);for(let e of n){if(void 0!==e.label||1!==e.minSpan||e.source===e.target||!Number.isInteger(e.source)||!Number.isInteger(e.target)||e.source<0||e.source>=t.length||e.target<0||e.target>=t.length||(o[e.target]=o[e.target]+1,o[e.target]>1))return;l[e.source].push(e.target)}let g=t.flatMap((e,t)=>0===o[t]?[t]:[]),a=[...g],s=new Uint32Array(t.length);for(let e=0;e<a.length;e++){let t=a[e];for(let e of l[t])s[e]=s[t]+1,a.push(e)}if(a.length!==t.length)return;let d="LR"===e.direction||"RL"===e.direction,u="RL"===e.direction||"BT"===e.direction,m=e=>d?t[e].width:t[e].height,c=e=>d?t[e].height:t[e].width;if(t.some((e,t)=>void 0!==e.minimumPortSpacing&&(l[t].length-1)*e.minimumPortSpacing>c(t)-2*(e.paintCornerRadius??0)))return;let p=new Float64Array(t.length),f=[];for(let e=a.length-1;e>=0;e--){let t=a[e],n=l[t],i=Math.max(0,n.length-1)*r;for(let e of n)i+=p[e];p[t]=Math.max(c(t),i),f[s[t]]=Math.max(f[s[t]]??0,m(t))}let y=[],x=0;for(let e=0;e<f.length;e++)y.push(x),x+=f[e]+(e+1<f.length?h:0);let w=new Float64Array(t.length),S=0;for(let e of g)w[e]=S,S+=p[e]+r;if(S-=r,!Number.isFinite(x+S+2*i))return;let b=t.map(()=>({x:0,y:0}));for(let e of a){let t=l[e],n=i+w[e]+(p[e]-c(e))/2,h=y[s[e]]+(f[s[e]]-m(e))/2;u&&(h=x-h-m(e)),h+=i,b[e]=d?{x:h,y:n}:{x:n,y:h};let o=Math.max(0,t.length-1)*r;for(let e of t)o+=p[e];let g=w[e]+(p[e]-o)/2;for(let e of t)w[e]=g,g+=p[e]+r}let F=new Float64Array(t.length),M=e.edgeSpacing??6;for(let n=0;n<t.length;n++){let i=t[n].minimumPortSpacing,r=l[n];if(!i||r.length<2)continue;let o=[],g=[],a=(d?b[n].y:b[n].x)+c(n)/2;for(let[e,t]of r.entries()){let n=a+(e-(r.length-1)/2)*i,h=(d?b[t].y:b[t].x)+c(t)/2;h<n?o.push(t):h>n&&g.push(t)}if((Math.max(o.length,g.length)-1)*M>h-2*Math.max(12,e.minimumTerminalLead??0))return;o.forEach((e,t)=>{F[e]=(t-(o.length-1)/2)*M}),g.forEach((e,t)=>{F[e]=((g.length-1)/2-t)*M})}let P=new Uint32Array(t.length);return{topology:"forest",width:2*i+(d?x:S),height:2*i+(d?S:x),nodes:b,edges:n.map(n=>{if(e.placementOnly&&!e.cycleOriented&&!e.loopPorts?.length)return{points:[]};let r=b[n.source],h=b[n.target],o=t[n.source],g=t[n.target],a=d?{x:r.x+(u?0:o.width),y:r.y+o.height/2}:{x:r.x+o.width/2,y:r.y+(u?0:o.height)},m=d?{x:h.x+(u?g.width:0),y:h.y+g.height/2}:{x:h.x+g.width/2,y:h.y+(u?g.height:0)},c=P[n.source],p=l[n.source].length;if(P[n.source]=c+1,o.minimumPortSpacing&&p>1){let e=(c-(p-1)/2)*o.minimumPortSpacing;d?a.y+=e:a.x+=e}let w=d?(a.x+m.x)/2:(a.y+m.y)/2,S=s[n.source],M=i+(u?x-(y[S]+f[S]):y[S]+f[S]),N=i+(u?x-y[S+1]:y[S+1]);return(w<=Math.min(M,N)||w>=Math.max(M,N))&&(w=M+(N-M)/2),o.minimumPortSpacing&&p>1&&(w=(M+N)/2+(u?-1:1)*F[n.target]),{points:d?[a,{x:w,y:a.y},{x:w,y:m.y},m]:[a,{x:a.x,y:w},{x:m.x,y:w},m]}})}}function t(t,n,i,r,h){let l=n.children;if(!l||l.length<2||t.subgraphs.length>0||t.stateNotes?.length||l.length!==t.nodes.size||t.edges.some(e=>void 0!==e.label||(e.length??1)!==1)||[...t.nodes.values()].some(e=>"rectangle"!==e.shape)||![i,r,h].every(e=>Number.isFinite(e)&&e>=0)||0===r||0===h)return;let o=new Map(l.map((e,t)=>[e.id,t])),g=t.edges.map(e=>({source:o.get(e.source)??-1,target:o.get(e.target)??-1,minSpan:1})),a=e({nodes:l.map(e=>({id:e.id,width:e.width,height:e.height})),edges:g,direction:t.direction,padding:i,nodeSpacing:r,layerSpacing:h});if(a)return{...n,width:a.width,height:a.height,children:l.map((e,t)=>({...e,...a.nodes[t]})),edges:t.edges.map((e,t)=>{let n=a.edges[t].points;return{id:`e${t}`,sources:[e.source],targets:[e.target],sections:[{id:`e${t}_s0`,startPoint:n[0],bendPoints:n.slice(1,-1),endPoint:n.at(-1)}]}})}}export{t as indexedForestLayout,e as layoutMeasuredForest};
@@ -0,0 +1,11 @@
1
+ import{a as e}from"./chunk-BY2CPG6B.js";import"./chunk-SZELX2EJ.js";import{d as t}from"./chunk-QA6GJQ4X.js";import{a as i,b as a}from"./chunk-2I4UPL7Q.js";import{a as n,b as l,e as r,g as o,k as s}from"./chunk-2SH76OTH.js";import{d as d}from"./chunk-AMJLVPUB.js";import{y as c,z as u}from"./chunk-DF6765YX.js";import"./chunk-J35HAQQF.js";import{a as h,c as f,d as m,h as p}from"./chunk-CN7WTBWB.js";import{D as g,a as k,b as x,c as y,d as b,e as v,g as w,i as M}from"./chunk-HLWUNUCM.js";import{aa as S,c as T,ca as F,x as L}from"./chunk-X2UYKWKM.js";import{i as $,j as I,k as C,u as _}from"./chunk-TYZOZXUJ.js";import{c as D,g as A,h as W}from"./chunk-NO7ZIVRU.js";import{K as z,Tb as B,Z as E,_ as U,o as N}from"./chunk-Z3FDIVLN.js";import{A as H,B as Y}from"./chunk-N5ELX7LR.js";import"./chunk-5UVGUSD6.js";import"./chunk-CSFUKSU6.js";var O=Object.freeze({id:"gantt",upstreamId:"gantt",maturity:"stable",label:"Gantt",headers:["gantt"],aliases:[],config:{section:"gantt",keys:["displayMode","barHeight","topAxis","tickInterval","axisFormat","barGap","topPadding","leftPadding","gridLineStartPadding","fontSize","sectionFontSize","numberSectionStyles","todayMarker","weekday","rightPadding","titleTopMargin"],noopKeys:["barGap","topPadding","leftPadding","rightPadding","titleTopMargin","gridLineStartPadding","fontSize","sectionFontSize","numberSectionStyles","todayMarker","weekday"]},identity:{id:"family:gantt",kind:"family",version:"1.0.0",compatibility:{core:"0.5.3"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:["status","progress","emphasis","category"],semanticRoles:["prelude","defs","chrome","section","grid","axis","label","task","milestone","edge","marker-line","title"],scenePrimitiveEvidence:[{role:"prelude",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"marker",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"section",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"section",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"grid",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"axis",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"label",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"task",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"milestone",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"edge",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"marker-line",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"title",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]}],example:`gantt
2
+ title Plan
3
+ dateFormat YYYY-MM-DD
4
+ section Build
5
+ Implement :a1, 2026-01-05, 5d
6
+ Review :after a1, 2d`,detect:H,detectLoose:Y}),P={displayMode:s("compact"),barHeight:l,topAxis:r,axisFormat:o,tickInterval:n('a positive Mermaid interval such as "1day" or "2week"',e=>"string"==typeof e&&/^[1-9]\d*(?:millisecond|second|minute|hour|day|week|month)$/i.test(e.trim()))},j=class extends Error{code;line;constructor(e,t,i){super(`${e}: ${t}`),this.name="GanttError",this.code=e,this.line=i}},X=["stroke","stroke-width","opacity","stroke-dasharray"],G=/^[#\w][\w#(),.%\s/-]*$/;function R(e){let t=[],i=[],a=S(e,{caseInsensitive:!0});for(let[e,n]of(F(void 0===a.stroke?{}:{stroke:a.stroke},"todayMarker"),Object.entries(a))){if(!X.includes(e)||"stroke"!==e&&!G.test(n)){i.push(e);continue}t.push([e,n])}return{applied:t,ignored:i}}var J=["active","done","crit","milestone","vert"],K=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],V=/^(\d+(?:\.\d+)?)(ms|s|m|h|d|w|M|y)$/,Z=/^([1-9][0-9]*)(millisecond|second|minute|hour|day|week|month)$/;function Q(e){return e.split(/[,\s]+/).filter(Boolean).map(e=>{let t=e.toLowerCase();return"weekends"===t?{kind:"weekends"}:K.includes(t)?{kind:"weekday",day:t}:{kind:"date",raw:e}})}var q={title:/^title\s+(.+)$/i,dateFormat:/^dateFormat\s+(.+)$/i,axisFormat:/^axisFormat\s+(.+)$/i,tickInterval:/^tickInterval\s+(.+)$/i,excludes:/^excludes\s+(.+)$/i,includes:/^includes\s+(.+)$/i,todayMarker:/^todayMarker\s+(.+)$/i,weekday:/^weekday\s+(.+)$/i,weekend:/^weekend\s+(.+)$/i,section:/^section\s+(.+)$/i,click:/^click\s+([\w-]+)\s+(href|call)\s+(.+)$/i},ee=/^(?:dateFormat|axisFormat|tickInterval|excludes|includes)\s/i,et=/^(?:title|section|click|todayMarker|weekday|weekend|acc(?:Title|Descr))\b/i;function ei(e){if(ee.test(e))return e.indexOf(";");let t=e.indexOf(":");if(et.test(e)||t<=0)return -1;let a=e.indexOf(";",t+1),n=i(e.slice(t+1));return n>=0&&a>t+n?-1:a}var ea=/^click\s+[\w-]+$/i,en=/^(?:href|call)\s/i;function el(e){if(!e)return{};let t={},i=u(e,["title"]);"string"==typeof i&&""!==i.trim()&&(t.title=i);let a=u(e,["displayMode"]),n=(c(e,["gantt"])?u(e,["gantt","displayMode"]):void 0)??a;"string"==typeof n&&"compact"===n.toLowerCase()&&(t.displayMode="compact");let l=u(e,["gantt","barHeight"]);"number"==typeof l&&Number.isFinite(l)&&l>0&&(t.barHeight=l),!0===u(e,["gantt","topAxis"])&&(t.topAxis=!0);let r=u(e,["gantt","axisFormat"]);"string"==typeof r&&(t.axisFormat=r);let o=u(e,["gantt","tickInterval"]);if("string"==typeof o){let e=o.match(Z);e&&(t.tickInterval={count:Number(e[1]),unit:e[2]})}return t}function er(e){return Math.floor(e/864e5)}function eo(e){return 864e5*er(e)}function es(e){return((er(e)+4)%7+7)%7}var ed={sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6},ec=["YYYY","YY","MM","M","DD","D","HH","H","mm","m","ss","s","SSS","X","x"],eu=new Set(["HH","H","mm","m","ss","s","SSS","X","x"]);function eh(e){let t=[],i=0;e:for(;i<e.length;){for(let a of ec)if(e.startsWith(a,i)){t.push({kind:"field",field:a}),i+=a.length;continue e}t.push({kind:"literal",text:e[i]}),i++}return t}function ef(e,t){let i=eh(t),a=0,n={},l=(t,i)=>{let n=0;for(;n<i&&a+n<e.length&&e[a+n]>="0"&&e[a+n]<="9";)n++;if(n<t)return null;let l=Number(e.slice(a,a+n));return a+=n,l};for(let t of i){if("literal"===t.kind){if(e[a]!==t.text)return null;a++;continue}switch(t.field){case"YYYY":{let e=l(4,4);if(null===e)return null;n.year=e;break}case"YY":{let e=l(2,2);if(null===e)return null;n.year=2e3+e;break}case"MM":{let e=l(2,2);if(null===e)return null;n.month=e;break}case"M":{let e=l(1,2);if(null===e)return null;n.month=e;break}case"DD":{let e=l(2,2);if(null===e)return null;n.day=e;break}case"D":{let e=l(1,2);if(null===e)return null;n.day=e;break}case"HH":{let e=l(2,2);if(null===e)return null;n.hour=e;break}case"H":{let e=l(1,2);if(null===e)return null;n.hour=e;break}case"mm":{let e=l(2,2);if(null===e)return null;n.minute=e;break}case"m":{let e=l(1,2);if(null===e)return null;n.minute=e;break}case"ss":{let e=l(2,2);if(null===e)return null;n.second=e;break}case"s":{let e=l(1,2);if(null===e)return null;n.second=e;break}case"SSS":{let e=l(3,3);if(null===e)return null;n.msec=e;break}case"X":{let e=l(1,11);if(null===e)return null;n.unix=e;break}case"x":{let e=l(1,14);if(null===e)return null;n.unixMs=e}}}return a!==e.length?null:void 0!==n.unixMs?n.unixMs:void 0!==n.unix?1e3*n.unix:function(e,t,i,a=0,n=0,l=0,r=0){if(t<1||t>12||i<1||i>31||a<0||a>23||n<0||n>59||l<0||l>59)return null;let o=Date.UTC(e,t-1,i,a,n,l,r),s=new Date(o);return s.getUTCFullYear()!==e||s.getUTCMonth()!==t-1||s.getUTCDate()!==i?null:o}(n.year??1970,n.month??1,n.day??1,n.hour??0,n.minute??0,n.second??0,n.msec??0)}var em={ms:1,s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function ep(e,t){let i=new Set,a=new Set,n=!1;for(let l of e){if("weekends"===l.kind){n=!0;continue}if("weekday"===l.kind){a.add(ed[l.day]);continue}let e=ef(l.raw,t.dateFormat)??ef(l.raw,"YYYY-MM-DD");if(null===e)throw new j("GANTT_BAD_DATE",`Invalid calendar date "${l.raw}" for dateFormat "${t.dateFormat}"`);i.add(er(e))}return{days:i,weekdays:a,weekends:n}}var eg=new WeakMap,ek=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ex=["January","February","March","April","May","June","July","August","September","October","November","December"],ey=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],eb=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function ev(e,t){let i=new Date(e),a=(e,t=2)=>String(e).padStart(t,"0"),n=()=>Math.floor((e-Date.UTC(i.getUTCFullYear(),0,1))/864e5)+1,l=e=>{let t=(7+es(Date.UTC(i.getUTCFullYear(),0,1))-e)%7;return Math.floor((n()-1+t)/7)},r="";for(let o=0;o<t.length;o++){let s=t[o];if("%"!==s){r+=s;continue}let d=t[++o];switch(d){case"Y":r+=String(i.getUTCFullYear());break;case"y":r+=a(i.getUTCFullYear()%100);break;case"m":r+=a(i.getUTCMonth()+1);break;case"d":r+=a(i.getUTCDate());break;case"e":r+=String(i.getUTCDate()).padStart(2," ");break;case"b":r+=ek[i.getUTCMonth()];break;case"B":r+=ex[i.getUTCMonth()];break;case"a":r+=ey[es(e)];break;case"A":r+=eb[es(e)];break;case"H":r+=a(i.getUTCHours());break;case"I":r+=a((i.getUTCHours()+11)%12+1);break;case"M":r+=a(i.getUTCMinutes());break;case"S":r+=a(i.getUTCSeconds());break;case"L":r+=a(i.getUTCMilliseconds(),3);break;case"p":r+=12>i.getUTCHours()?"AM":"PM";break;case"j":r+=a(n(),3);break;case"U":r+=a(l(0));break;case"W":r+=a(l(1));break;case"%":r+="%";break;default:r+=void 0===d?"%":`%${d}`}}return r}function ew(e,t){return{id:e,shape:"arrow",size:{width:8,height:7},ref:{x:8,y:3.5},orient:"auto",geometry:{kind:"path",d:"M0,0 L8,3.5 L0,7 Z"},paint:{fill:t}}}var eM=(e,t)=>t?Math.max(1.8,1.5*e):Math.max(1.2,e),eS=e([ew("dependency","black")]),eT=e=>eS("dependency",e,"end"),eF={nodeLabelFontSize:13,edgeLabelFontSize:11,groupHeaderFontSize:13,nodeLabelFontWeight:500,edgeLabelFontWeight:500,groupHeaderFontWeight:600,nodePaddingX:0,nodePaddingY:0,nodeLineWidth:D.innerBox,edgeLineWidth:D.connector,groupCornerRadius:0,groupPaddingX:0,groupPaddingY:0,groupLineWidth:D.outerBox},eL={millisecond:1,second:1e3,minute:6e4,hour:36e5,day:864e5,week:6048e5,month:2592e6},e$=[{unit:"minute",count:1,format:"%H:%M"},{unit:"minute",count:15,format:"%H:%M"},{unit:"hour",count:1,format:"%H:%M"},{unit:"hour",count:6,format:"%H:%M"},{unit:"day",count:1,format:"%m-%d"},{unit:"week",count:1,format:"%m-%d"},{unit:"week",count:2,format:"%m-%d"},{unit:"month",count:1,format:"%b %Y"},{unit:"month",count:3,format:"%b %Y"},{unit:"month",count:12,format:"%Y"}];function eI(e={},t){return W(e,eF,t)}function eC(e){return Math.max(17,e.groupHeaderFontSize)}function e_(e){return Math.max(e.groupHeaderFontWeight,600)}function eD(e){let t=eW(e);return Math.max(34===t?18:t/2,eC(e)+1)}function eA(e){return Math.max(10,.75*e.edgeLabelFontSize)}function eW(e){return Math.max(34,Math.ceil(1.5*eC(e))+8)}function ez(e){return void 0!==e.milestoneX?{x:e.milestoneX-e.h/2,y:e.y,w:e.h,h:e.h}:{x:e.x,y:e.y,w:e.w,h:e.h}}function eB(e,t,i,a){let[n,l]=t<=i?[t,i]:[i,t];return e>a.x+.01&&e<a.x+a.w-.01&&l>a.y+.01&&n<a.y+a.h-.01}function eE(e,t,i){return .01>=Math.abs(e.x-t.x)?i.some(i=>eB(e.x,e.y,t.y,i)):i.some(i=>(function(e,t,i,a){let[n,l]=t<=i?[t,i]:[i,t];return e>a.y+.01&&e<a.y+a.h-.01&&l>a.x+.01&&n<a.x+a.w-.01})(e.y,e.x,t.x,i))}function eU(e,t){return e.findIndex(e=>t>=e.y-.01&&t<=e.y+e.h+.01)}function eN(e,t,i){return(e[t].y+e[t].h+(t+1<e.length?e[t+1].y:i.y+i.h))/2}function eH(e,t,i){let a=e[t].y;return((t>0?e[t-1].y+e[t-1].h:i.y)+a)/2}function eY(e,t,i,a,n){let l=E(e,{display:"literal",transform:t,fontSize:i,fontWeight:a,letterSpacing:n,maxWidth:220});return{lines:[...l.lines],width:l.width,block:l}}function eO(e){return e.includes("crit")?"crit":e.includes("active")?"active":e.includes("done")?"done":void 0}function eP(e,t,i,a,n,l,r,o,s,d,c="start",u=0,h,f){return e.text({id:t,role:i,text:l,x:eG(a),y:eG(n),fontSize:o,block:f,fontWeight:s,letterSpacing:u,display:"literal",anchor:c,paint:{fill:d},channels:h,attributes:{className:r},...f?{}:{baselineShift:0,dominantBaseline:"middle"}})}function ej(e){if(!e)return{};let t=void 0===e.lineWidth?void 0:"outline"===e.cue?e.lineWidth+1:"double-line"===e.cue?e.lineWidth+2:e.lineWidth,i="pattern"===e.cue?"3 2":"double-line"===e.cue?"8 2 2 2":void 0;return{...void 0!==e.fillColor?{fill:e.fillColor}:{},...e.strokeColor??e.borderColor?{stroke:e.strokeColor??e.borderColor}:{},...void 0!==t?{strokeWidth:String(t)}:{},...void 0!==i?{strokeDasharray:i}:{}}}function eX(e,t,i,a){return{className:e,data:{task:t,...i?.cue&&"none"!==i.cue?{"brand-cue":i.cue}:{},...a?{href:a}:{}}}}function eG(e){return Math.round(100*e)/100}function eR(e){return void 0===e?"":e.id??e.label}var eJ=T(function(e,t){var i;let{positioned:a,colors:n,resolved:l}=t,r=l.renderOptions,o=n.font??"Inter",s=r.transparent??!1,d=eI(r,l.styleFace),c={groupFill:d.groupFillColor??"var(--surface, var(--fg))",groupOpacity:d.groupFillColor?"1":"0.07",excludedFill:d.edgeStrokeColor??"var(--muted, var(--line, var(--fg)))",edgeStroke:d.edgeStrokeColor??"var(--line, var(--border, var(--fg)))",nodeFill:d.nodeFillColor??"var(--accent, var(--fg))",nodeBorder:d.nodeBorderColor??"var(--fg)",doneFill:d.nodeFillColor??"var(--muted, var(--line, var(--fg)))",criticalFill:d.nodeFillColor??"var(--fg)",criticalStroke:d.nodeBorderColor??d.edgeStrokeColor??"var(--accent, var(--fg))",titleFill:d.groupTextColor??d.nodeTextColor??"var(--_text)",groupText:d.groupTextColor??d.nodeTextColor??"var(--_text)",taskText:d.nodeTextColor??"var(--_text)",axisText:d.edgeTextColor??d.groupTextColor??"var(--_text-muted)"},u=[],h=r.gantt??{},f={dependencyArrows:!0===h.dependencyArrows&&a.dependencies.length>0,criticalBars:!0===h.criticalPath&&a.criticalTaskIndexes.length>0,criticalArrows:!0===h.dependencyArrows&&!0===h.criticalPath&&a.dependencies.some(e=>e.critical)},m=new Set(f.criticalBars?a.criticalTaskIndexes:[]);u.push(e.documentOpen({id:"prelude",width:a.width,height:a.height,colors:n,transparent:s,font:o,hasMonoFont:!1},C(a.width,a.height,n,s)+`
7
+ `+I(o,!1,n.shadow,n.embedFontImport)));let p=$(n);p&&u.push(e.definitions({id:"shadow-defs"},`<defs>${p}</defs>`));let g=`gantt-${B(a.width,a.height,...a.bars.map(e=>`${e.taskIndex}:${e.id??e.label}`),...a.dependencies.map(e=>`${e.fromTaskIndex}>${e.toTaskIndex}:${e.kind}`))}-dep-arrow`,k=`${g}-crit`,x=[ew(g,c.edgeStroke),...f.criticalArrows?[ew(k,c.criticalStroke)]:[]];f.dependencyArrows&&u.push(e.definitions({id:"defs",markerResources:x},`<defs>
8
+ ${_(x)}
9
+ </defs>`));let y=a.plot,b=y.y+y.h,v=new Map;a.sections.forEach((t,i)=>{if(i%2==0){let i=t.label??"",a=v.get(i)??0;v.set(i,a+1),u.push(e.shape({id:`section-band:${i}#${a}`,role:"section",geometry:{kind:"rect",x:eG(y.x),y:eG(t.y),width:eG(y.w),height:eG(t.h)},paint:{fill:c.groupFill,opacity:c.groupOpacity},channels:void 0!==t.label?{category:t.label}:void 0,attributes:{className:"gantt-section-band"}}))}});let w={fill:c.excludedFill,opacity:"0.1"};for(let t of a.excludedBands)u.push(e.shape({id:`excluded:${t.start}`,role:"grid",geometry:{kind:"rect",x:eG(t.x),y:eG(y.y),width:eG(t.w),height:eG(y.h)},paint:w,attributes:{className:"gantt-excluded-band"}}));let M={stroke:c.edgeStroke,strokeWidth:String(d.lineWidth),opacity:d.edgeStrokeColor?"0.6":"0.45"};for(let t of a.ticks)u.push(e.shape({id:`grid:${t.time}`,role:"grid",geometry:{kind:"line",x1:eG(t.x),y1:eG(y.y),x2:eG(t.x),y2:eG(b)},paint:M,attributes:{className:"gantt-grid-line"}}));let S=eA(d),T=10===S&&11===d.edgeLabelFontSize?12:Math.max(12,S);for(let t of a.ticks){let i=t.labelBlock?.text??A(t.label,d.edgeTextTransform);u.push(eP(e,`axis:${t.time}:bottom`,"axis",t.x,b+T,i,"gantt-axis-label",d.edgeLabelFontSize,d.edgeLabelFontWeight,c.axisText,"middle",d.edgeLetterSpacing,void 0,t.labelBlock)),a.topAxis&&u.push(eP(e,`axis:${t.time}:top`,"axis",t.x,y.y-S,i,"gantt-axis-label",d.edgeLabelFontSize,d.edgeLabelFontWeight,c.axisText,"middle",d.edgeLetterSpacing,void 0,t.labelBlock))}let F=1.3*d.groupHeaderFontSize,L=1.3*d.nodeLabelFontSize,D=new Map;for(let t of a.sections)if(void 0!==t.label){let i=D.get(t.label)??0;D.set(t.label,i+1),(t.labelBlock?.lines??t.labelLines??[A(t.label,d.groupTextTransform)]).forEach((n,l)=>{let r=0===l?`section-label:${t.label}#${i}`:`section-label:${t.label}#${i}/${l}`;u.push(eP(e,r,"section",8,t.y+a.barHeight/2+4+l*(t.labelBlock?.lineHeight??F),n,"gantt-section-label",d.groupHeaderFontSize,d.groupHeaderFontWeight,c.groupText,"start",d.groupLetterSpacing,{category:t.label},U(t.labelBlock,l)))})}let W=new Map,z=e=>{let t=W.get(e)??0;return W.set(e,t+1),0===t?`task-label:${e}`:`task-label:${e}#${t}`};if(a.compact){let t=new Map;for(let e of a.bars){let i=t.get(e.y)??[];i.push(e),t.set(e.y,i)}for(let i of t.values())i.sort((e,t)=>e.x-t.x),i.forEach((t,n)=>{let l=t.labelBlock??E(t.label,{display:"literal",transform:d.nodeTextTransform,fontSize:d.nodeLabelFontSize,fontWeight:d.nodeLabelFontWeight,letterSpacing:d.nodeLetterSpacing}),r=l.text,o=l.width,s=t.y+t.h/2;if(t.labelPosition)return void u.push(eP(e,z(t.id??t.label),"label",t.labelPosition.x,t.labelPosition.y,r,"gantt-task-label",d.nodeLabelFontSize,d.nodeLabelFontWeight,c.taskText,t.labelPosition.anchor,d.nodeLetterSpacing,void 0,l));let h=n>0?i[n-1].x+i[n-1].w+4:2,f=n+1<i.length?i[n+1].x-4:a.width-2;t.x-6-o>=h?u.push(eP(e,z(t.id??t.label),"label",t.x-6,s,r,"gantt-task-label",d.nodeLabelFontSize,d.nodeLabelFontWeight,c.taskText,"end",d.nodeLetterSpacing,void 0,l)):t.x+t.w+6+o<=f?u.push(eP(e,z(t.id??t.label),"label",t.x+t.w+6,s,r,"gantt-task-label",d.nodeLabelFontSize,d.nodeLabelFontWeight,c.taskText,"start",d.nodeLetterSpacing,void 0,l)):u.push(eP(e,z(t.id??t.label),"label",16,s,r,"gantt-task-label",d.nodeLabelFontSize,d.nodeLabelFontWeight,c.taskText,"start",d.nodeLetterSpacing,void 0,l))})}else for(let t of a.bars){let i=t.labelBlock?.lines??t.labelLines??[A(t.label,d.nodeTextTransform)],a=z(t.id??t.label);i.forEach((i,n)=>{let l=0===n?a:`${a}/${n}`;u.push(eP(e,l,"label",t.labelPosition?.x??16,(t.labelPosition?.y??t.y+t.h/2)+n*(t.labelBlock?.lineHeight??L),i,"gantt-task-label",d.nodeLabelFontSize,d.nodeLabelFontWeight,c.taskText,"start",d.nodeLetterSpacing,void 0,U(t.labelBlock,n)))})}let H=new Map,Y=e=>{let t=H.get(e)??0;return H.set(e,t+1),0===t?`task:${e}`:`task:${e}#${t}`},O=new Map(a.links.map(e=>[e.taskIndex,e.href]));for(let t of a.bars){let n=a.sections[t.sectionIndex]?.label,o="strict"===r.security?void 0:O.get(t.taskIndex),s=t.id??t.label,h=m.has(t.taskIndex),f=h?" gantt-bar-critical-path":"",p=h?{stroke:c.criticalStroke,strokeWidth:String(Math.max(2,1.5*d.nodeLineWidth))}:{};if(void 0!==t.milestoneX){let i=t.milestoneX,a=t.y+t.h/2,r=t.h/2,m=eO(t.tags),g="gantt-milestone"+(void 0!==m?` gantt-milestone-${m}`:"")+f,k=`M ${eG(i)} ${eG(a-r)} L ${eG(i+r)} ${eG(a)} L ${eG(i)} ${eG(a+r)} L ${eG(i-r)} ${eG(a)} Z`,x="crit"===m?{fill:c.criticalFill,stroke:c.criticalStroke,strokeWidth:String(Math.max(1.5,d.nodeLineWidth))}:"active"===m?{fill:c.nodeFill,stroke:c.nodeBorder,strokeWidth:String(Math.max(1.5,d.nodeLineWidth)),opacity:"1"}:"done"===m?{fill:c.doneFill,stroke:c.nodeBorder,strokeWidth:String(Math.max(1,d.nodeLineWidth)),opacity:d.nodeFillColor?"0.72":"0.55"}:{fill:c.nodeFill,stroke:c.nodeBorder,strokeWidth:String(Math.max(1,d.nodeLineWidth))},y={...void 0!==m?{status:m}:{},..."done"===m?{progress:1}:{},...h?{emphasis:!0}:{},...void 0!==n?{category:n}:{}},b=N(l.styleFace,"milestone",y,{includeFallback:!1}),v={...x,...ej(b),...p};u.push(e.shape({id:Y(s),role:"milestone",geometry:{kind:"path",d:k},paint:v,channels:y,attributes:eX(g,s,b,o)}));continue}let g=eO(t.tags),k={...void 0!==g?{status:g}:{},..."done"===g?{progress:1}:{},...h?{emphasis:!0}:{},...void 0!==n?{category:n}:{}},x=N(l.styleFace,"task",k,{includeFallback:!1}),y={...function(e,t,i){let a={stroke:i.nodeBorderColor?t.nodeBorder:"none",...i.nodeBorderColor?{strokeWidth:String(i.nodeLineWidth)}:{}};switch(e){case"crit":return{fill:t.criticalFill,stroke:t.criticalStroke,strokeWidth:String(Math.max(1.5,i.nodeLineWidth)),opacity:"0.95"};case"active":return{fill:t.nodeFill,stroke:t.nodeBorder,strokeWidth:String(Math.max(1.5,i.nodeLineWidth)),opacity:"1"};case"done":return{fill:t.doneFill,...a,opacity:i.nodeFillColor?"0.72":"0.55"};default:return{fill:t.nodeFill,...a,opacity:"0.92"}}}(g,c,d),...ej(x),...p};u.push(e.shape({id:Y(s),role:"task",geometry:{kind:"rect",x:eG(t.x),y:eG(t.y),width:eG(Math.max(2,t.w)),height:eG(t.h),rx:3,ry:3},paint:y,channels:k,attributes:eX(`${(i=t.tags).includes("crit")?"gantt-bar gantt-bar-crit":i.includes("active")?"gantt-bar gantt-bar-active":i.includes("done")?"gantt-bar gantt-bar-done":"gantt-bar"}${f}`,s,x,o)}))}if(f.dependencyArrows){let t=new Map(a.bars.map(e=>[e.taskIndex,e])),i=new Map;for(let n of a.dependencies){let a=eR(t.get(n.fromTaskIndex)),l=eR(t.get(n.toTaskIndex)),r=`${a}->${l}:${n.kind}`,o=i.get(r)??0;i.set(r,o+1);let s=f.criticalArrows&&n.critical,h=s?"gantt-dep-arrow gantt-dep-arrow-crit":"gantt-dep-arrow",m=s?k:g,p=n.points.map(e=>({x:eG(e.x),y:eG(e.y)})),y=p.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" "),b=0===o?`dep:${r}`:`dep:${r}#${o}`,v=e.connector({id:b,role:"edge",geometry:{kind:"path",d:y,points:p},lineStyle:"solid",paint:s?{stroke:c.criticalStroke,strokeWidth:String(eM(d.lineWidth,!0))}:{stroke:c.edgeStroke,strokeWidth:String(eM(d.lineWidth,!1))},markers:{mid:[],end:x.find(e=>e.id===m)},endpoints:{from:a,to:l},relationship:{kind:n.kind,direction:"forward"},route:{ownership:"layout"},channels:s?{status:"crit",emphasis:!0}:void 0,attributes:{className:h}});u.push(e.group({id:`${b}:fade`,role:"chrome",open:"<g>",close:"</g>",paint:{opacity:s?"0.95":"0.6"},children:[{node:v,indent:0}]}))}}let P={stroke:c.edgeStroke,strokeWidth:String(Math.max(2,d.lineWidth)),strokeDasharray:"6 3"},j=new Map;for(let t of a.verts){let i=j.get(t.label)??0;j.set(t.label,i+1),u.push(e.shape({id:`vert:${t.label}#${i}`,role:"marker-line",geometry:{kind:"line",x1:eG(t.x),y1:eG(y.y),x2:eG(t.x),y2:eG(b)},paint:P,attributes:{className:"gantt-vert-marker"}}));let n=t.labelBlock?.text??A(t.label,d.edgeTextTransform),l=a.topAxis?Math.max(24,S+1.25*d.edgeLabelFontSize):10===S&&11===d.edgeLabelFontSize?8:S;u.push(eP(e,`vert-label:${t.label}#${i}`,"axis",t.x,y.y-l,n,"gantt-axis-label",d.edgeLabelFontSize,Math.max(d.edgeLabelFontWeight,600),c.axisText,"middle",d.edgeLetterSpacing,void 0,t.labelBlock))}if(void 0!==a.todayX){let t=void 0!==a.todayMarkerStyle?R(a.todayMarkerStyle):void 0,i=Object.fromEntries(t?.applied??[]);u.push(e.shape({id:"today-marker",role:"marker-line",geometry:{kind:"line",x1:eG(a.todayX),y1:eG(y.y),x2:eG(a.todayX),y2:eG(b)},paint:{stroke:i.stroke??d.edgeStrokeColor??"var(--accent, var(--fg))",strokeWidth:i["stroke-width"]??String(Math.max(2,d.lineWidth)),strokeDasharray:i["stroke-dasharray"]??"4 3",...void 0!==i.opacity?{opacity:i.opacity}:{}},attributes:{className:"gantt-today-marker"}}))}if(a.title){let t=a.titleBlock?.text??A(a.title,d.groupTextTransform),i=a.titleY??eD(d);u.push(eP(e,"title","title",a.width/2,i,t,"gantt-title",eC(d),e_(d),c.titleFill,"middle",d.groupLetterSpacing,void 0,a.titleBlock))}if(a.emptyLabel){let t=a.emptyLabel;u.push(eP(e,"empty-state","label",y.x+y.w/2,y.y+y.h/2,t.text,"gantt-empty-state",t.fontSize,t.fontWeight,c.axisText,"middle",t.letterSpacing,void 0,t))}return u.push(e.documentClose()),{family:"gantt",width:a.width,height:a.height,colors:n,transparent:s,parts:u}}),eK=b(O,{configDiagnostics:e=>d("gantt",e,P),normalizeRequest:e=>({familyConfig:{config:el(e.source.frontmatter)}}),layout:e=>{let n=e.familyConfig?.config??el(void 0);return y(function(e,n,l={}){var r;let o=(r=function(e){let n=a((e[0]??"").trim());if(!/^gantt\s*$/i.test(n))throw new j("GANTT_BAD_DIRECTIVE",`Expected "gantt" header, got "${n}"`,1);v("gantt")&&w("gantt","header",e[0]??"",{line:1,unit:"normalized"});let l={dateFormat:"YYYY-MM-DD",inclusiveEndDates:!1,topAxis:!1,excludes:[],includes:[],weekendStart:"saturday",weekStart:"sunday",sections:[{taskIndexes:[]}],tasks:[],clicks:[]};v("gantt")&&M("gantt","initialize",l);let r=new Set,o=0;for(let n of function e(n){let l=[];for(let r=0;r<n.length;r++){let o=r,s=n[r],d=s.trim(),c=(e,t=n.slice(o,r+1))=>{let i="section"===e.kind||"title"===e.kind?s.indexOf(e.value,s.search(/\S/)+e.kind.length)+1:"task"===e.kind?s.search(/\S/)+1:void 0;l.push({...e,raw:t,startLine:o+1,endLine:r+1,valueColumn:i})};if(!d||d.startsWith("%%")){c({kind:d?"comment":"blank"});continue}let u=L(n,r);if(void 0===u){let e=n.slice(r);r=n.length-1,c({kind:"invalid",code:"GANTT_BAD_DIRECTIVE",message:"Unclosed accDescr block",structural:!0},e);break}if(null!==u){r=u.endIndex;let t=n.slice(o,r+1);if(u.suffixLine&&(t[t.length-1]=t.at(-1).slice(0,t.at(-1).indexOf("}")+1)),c({kind:"accessibility",directive:u},t),u.suffixLine){let t=n[r],i=t.indexOf("}")+1,a=e([t.slice(i)]);l.push(...a.map(e=>({...e,startLine:r+1,endLine:r+1,valueColumn:void 0===e.valueColumn?void 0:e.valueColumn+i})))}continue}if(ei(d)>=0){let t=s,i=0;for(let a=0;;a++){let n=ei(t.trim()),o=n<0?t.length:t.length-t.trimStart().length+n;if(l.push(...e([t.slice(0,o)]).map((e,t)=>({...e,startLine:r+1,endLine:r+1,valueColumn:void 0===e.valueColumn?void 0:e.valueColumn+i,...a>0&&0===t?{afterSemicolon:!0}:{}}))),n<0)break;i+=o+1,t=t.slice(o+1)}continue}let h=function(e,t){if(!ea.test(e[t].trim()))return -1;let i=t+1;for(;i<e.length&&(!e[i].trim()||e[i].trim().startsWith("%%"));)i++;return i<e.length&&en.test(e[i].trim())?i:-1}(n,r);h>r&&(r=h,d=`${d}
10
+ ${n[r].trim()}`);let f=!1;for(let[e,t]of Object.entries(q)){let i=("weekday"===e||"weekend"===e?a(d):d).match(t);if(!i)continue;f=!0;let n=i[1].trim();c("title"===e||"section"===e?{kind:e,value:n}:"click"===e?{kind:"click",taskId:n,action:i[2].toLowerCase(),rest:i[3].trim()}:"weekday"!==e||K.includes(n.toLowerCase())?"weekend"!==e||["friday","saturday"].includes(n.toLowerCase())?{kind:"directive",name:e,value:n}:{kind:"invalid",code:"GANTT_BAD_DIRECTIVE",message:`Invalid weekend "${n}" (friday or saturday)`}:{kind:"invalid",code:"GANTT_BAD_DIRECTIVE",message:`Invalid weekday "${n}"`});break}if(f)continue;let m=a(d);if(/^(inclusiveEndDates|topAxis)\s*$/i.test(m)){c({kind:"directive",name:/^topAxis/i.test(m)?"topAxis":"inclusiveEndDates",value:""});continue}let p=d.indexOf(":");if(!/^(dateFormat|axisFormat|tickInterval|inclusiveEndDates|topAxis|excludes|includes|todayMarker|weekday|weekend|click)\b/i.test(d)&&p>0&&p<d.length-1){let e=d.slice(0,p).trim(),n=s.indexOf(":"),l=i(s.slice(n+1)),r=l<0?-1:n+1+l,o=a(d.slice(p+1)).trim(),u=function(e){let t=e.split(",").map(e=>e.trim());if(t.some(e=>0===e.length))return null;let i=[],a=0;for(;a<t.length&&J.includes(t[a]);){let e=t[a];if(i.includes(e))return null;i.push(e),a++}let n=t.slice(a);if(0===n.length||n.length>3)return null;let l=e=>{let t=e.match(/^after\s+(.+)$/);return t?{kind:"after",refs:t[1].split(/\s+/).filter(Boolean)}:{kind:"date",raw:e}},r=e=>{let t=e.match(/^until\s+(.+)$/);return t?{kind:"until",refs:t[1].split(/\s+/).filter(Boolean)}:V.test(e)?{kind:"duration",raw:e}:{kind:"date",raw:e}};if(1===n.length)return{tags:i,end:r(n[0])};if(2===n.length)return{tags:i,start:l(n[0]),end:r(n[1])};let o=n[0];return/^[\w-]+$/.test(o)?{tags:i,id:o,start:l(n[1]),end:r(n[2])}:null}(o);u?(c({kind:"task",label:t(e,{subject:"Gantt task text entity",example:"Task #35;1 : 1d"}),labelSource:e,meta:u},[r<0?s:s.slice(0,r)]),r>=0&&c({kind:"comment"},[s.slice(r)])):c({kind:"invalid",code:"GANTT_BAD_TASK",message:`Invalid task metadata "${o}"`})}else c({kind:"invalid",code:"GANTT_BAD_DIRECTIVE",message:`Unrecognized gantt line "${d}"`})}return l}(e.slice(1))){let e=n.startLine+1;if(v("gantt")&&w("gantt","directive"===n.kind?n.name:n.kind,n.raw.join(`
11
+ `),{line:e,unit:"normalized"}),"invalid"===n.kind)throw new j(n.code,n.message,e);if("accessibility"===n.kind)n.directive.title?l.accTitle=n.directive.value:l.accDescr=n.directive.value.replace(/\s*\n\s*/g," "),v("gantt")&&M("gantt",n.directive.title?"setAccessibilityTitle":"setAccessibilityDescription",n.directive.title?l.accTitle:l.accDescr,{line:e,unit:"normalized"});else if("title"===n.kind)l.title=n.value,v("gantt")&&M("gantt","setTitle",l.title,{line:e,unit:"normalized"});else if("directive"===n.kind){let t=n.value;switch(n.name){case"dateFormat":l.dateFormat=t;break;case"axisFormat":l.axisFormat=t;break;case"tickInterval":{let e=t.match(Z);e&&(l.tickInterval={count:Number(e[1]),unit:e[2]});break}case"inclusiveEndDates":l.inclusiveEndDates=!0;break;case"topAxis":l.topAxis=!0;break;case"excludes":{let i=Q(t);l.excludes.push(...i),v("gantt")&&M("gantt","appendExcludes",i,{line:e,unit:"normalized"});break}case"includes":{let i=Q(t);l.includes.push(...i),v("gantt")&&M("gantt","appendIncludes",i,{line:e,unit:"normalized"});break}case"todayMarker":l.todayMarker="off"===t.toLowerCase()?{off:!0}:{off:!1,style:t};break;case"weekday":l.weekStart=t.toLowerCase();break;case"weekend":l.weekendStart=t.toLowerCase()}if(v("gantt")){let i="weekday"===n.name?"weekStart":"weekend"===n.name?"weekendStart":n.name;"excludes"!==n.name&&"includes"!==n.name&&("tickInterval"!==n.name||Z.test(t))&&M("gantt",`set:${i}`,l[i],{line:e,unit:"normalized"})}}else if("click"===n.kind)l.clicks.push({taskId:n.taskId,action:n.action,rest:n.rest,line:e}),v("gantt")&&M("gantt","addClick",l.clicks.at(-1),{line:e,unit:"normalized"});else if("section"===n.kind)l.sections.push({label:n.value,taskIndexes:[],line:e}),o=l.sections.length-1,v("gantt")&&M("gantt","addSection",{index:o,...l.sections[o]},{line:e,unit:"normalized"});else if("task"===n.kind){let{label:t,meta:i}=n;if(void 0!==i.id){if(r.has(i.id))throw new j("GANTT_DUPLICATE_TASK_ID",`Duplicate task id "${i.id}"`,e);r.add(i.id)}let a={index:l.tasks.length,id:i.id,label:t,tags:i.tags,start:i.start,end:i.end,sectionIndex:o,line:e};l.tasks.push(a),v("gantt")&&M("gantt","addTask",a,{line:e,unit:"normalized"}),l.sections[o].taskIndexes.push(a.index),v("gantt")&&M("gantt","attachTask",{sectionIndex:o,taskIndex:a.index,taskId:a.id},{line:e,unit:"normalized"})}}return l.todayMarker?.style!==void 0&&R(l.todayMarker.style),l}(e),void 0!==n.title&&void 0===r.title&&(r.title=n.title),n.displayMode&&(r.displayMode=n.displayMode),void 0!==n.barHeight&&(r.barHeight=n.barHeight),n.topAxis&&(r.topAxis=!0),void 0!==n.axisFormat&&void 0===r.axisFormat&&(r.axisFormat=n.axisFormat),void 0!==n.tickInterval&&void 0===r.tickInterval&&(r.tickInterval=n.tickInterval),r),s=function(e,t={}){let i,a={dateFormat:e.dateFormat,inclusiveEndDates:e.inclusiveEndDates,excludes:e.excludes,includes:e.includes,weekendStart:e.weekendStart,weekStart:e.weekStart},n=function(e){let t=ep(e.excludes,e),i=ep(e.includes,e),a="friday"===e.weekendStart?[5,6]:[6,0],n=e=>{let n=er(e),l=es(e);return!(i.days.has(n)||i.weekdays.has(l)||i.weekends&&a.includes(l))&&!!(t.days.has(n)||t.weekdays.has(l)||t.weekends&&a.includes(l))};if(e.excludes.length){let e;eg.set(n,()=>e??={weekdays:Array.from({length:7},(e,n)=>!(i.weekdays.has(n)||i.weekends&&a.includes(n))&&(t.weekdays.has(n)||t.weekends&&a.includes(n))),exceptions:[...new Set([...t.days,...i.days])].sort((e,t)=>e-t)})}return n}(a),l=!eh(e.dateFormat).some(e=>"field"===e.kind&&eu.has(e.field)),r=new Map;for(let t of e.tasks)void 0!==t.id&&r.set(t.id,t);let o=e.tasks.map((t,i)=>(function(e,t,i){let a=[];if(void 0===e.start&&i&&a.push(i.index),e.start?.kind==="after")for(let i of e.start.refs){let n=t.get(i);if(!n)throw new j("GANTT_UNKNOWN_TASK_REF",`Task "${e.label}" starts after unknown id "${i}"`,e.line);a.push(n.index)}if("until"===e.end.kind)for(let i of e.end.refs){let n=t.get(i);if(!n)throw new j("GANTT_UNKNOWN_TASK_REF",`Task "${e.label}" runs until unknown id "${i}"`,e.line);a.push(n.index)}return a})(t,r,e.tasks[i-1])),s=function(e,t,i){let a=Array(e).fill(0),n=[],l=Array(e).fill(0),r=[];for(let o=0;o<e;o++)if(0===a[o])for(a[o]=1,n.push(o);n.length;){let e=n.at(-1);if(l[e]<t[e].length){let r=t[e][l[e]];if(l[e]=l[e]+1,0===a[r])a[r]=1,n.push(r);else if(1===a[r]){let e=n.indexOf(r),t=n.slice(e).concat(r).map(i);throw new j("GANTT_DEPENDENCY_CYCLE",`Dependency cycle: ${t.join(" -> ")}`)}}else n.pop(),a[e]=2,r.push(e)}return r}(e.tasks.length,o,t=>e.tasks[t].id??e.tasks[t].label),d=Array(e.tasks.length),c=t=>{let i;if(d[t.index])return d[t.index];if(void 0===t.start){let e=t.index>0?d[t.index-1]:void 0;if(!e)throw new j("GANTT_NO_START",`Task "${t.label}" has no start date and no previous task to follow`,t.line);i=e.end}else if("after"===t.start.kind)i=Math.max(...t.start.refs.map(e=>d[r.get(e).index].end));else{let a=ef(t.start.raw,e.dateFormat);if(null===a)throw new j("GANTT_BAD_DATE",`Invalid start date "${t.start.raw}" for dateFormat "${e.dateFormat}"`,t.line);i=a}let o,s=!1;if("until"===t.end.kind)o=Math.min(...t.end.refs.map(e=>d[r.get(e).index].start)),s=!0;else if("duration"===t.end.kind){let e=function(e,t){let i=t.match(V);if(!i)return null;let a=Number(i[1]),n=i[2];if(!Number.isFinite(a))return null;if("M"===n||"y"===n){let t="y"===n?12*a:a,i=Math.trunc(t),l=t-i,r=new Date(e),o=r.getUTCMonth()+i,s=new Date(Date.UTC(r.getUTCFullYear(),o,1,r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds())),d=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth()+1,0)).getUTCDate();s.setUTCDate(Math.min(r.getUTCDate(),d));let c=s.getTime();return l>0&&(c+=Math.round(30*l*864e5)),c}return e+Math.round(a*em[n])}(i,t.end.raw);if(null===e)throw new j("GANTT_BAD_DURATION",`Invalid duration "${t.end.raw}"`,t.line);o=e}else{let i=ef(t.end.raw,e.dateFormat);if(null===i)throw new j("GANTT_BAD_DATE",`Invalid end date "${t.end.raw}" for dateFormat "${e.dateFormat}"`,t.line);o=a.inclusiveEndDates&&l?i+864e5:i,s=!0}let c=o;if(!s&&a.excludes.length>0){let e=function(e,t,i,a){let n=e+864e5,l=t,r=t,o=!1,s=0,d=t-e>=12096e5&&Number.isSafeInteger(e)&&Number.isSafeInteger(t)&&Math.max(Math.abs(e),Math.abs(t))+864e9<Number.MAX_SAFE_INTEGER?eg.get(i)?.():void 0;for(;n<=l;){if(d){let e=er(n),t=0,i=d.exceptions.length;for(;t<i;){let a=t+i>>>1;d.exceptions[a]<e?t=a+1:i=a}let a=Math.floor(Math.min(Math.floor((l-n)/864e5)+1,1e4-s,t<d.exceptions.length?d.exceptions[t]-e:1/0)/7);if(a>0){let e=es(n),t=0,i,c,u=o,h=d.weekdays[(e+6)%7];for(let a=0;a<7;a++)u||(i=t),h||(c=t),(u=h=d.weekdays[(e+a)%7])&&t++;let f=a>1&&void 0!==c?(a-1)*t+c:i;void 0!==f&&(r=l+864e5*f),l+=a*t*864e5,n+=7*a*864e5,s+=7*a,o=u;continue}}if(++s>1e4)throw new j("GANTT_SCHEDULE_OVERFLOW","Calendar exclusion walk exceeded 10000 days (is every day excluded?)",a);o||(r=l),(o=i(n))&&(l+=864e5),n+=864e5}return{end:l,renderEnd:r}}(i,o,n,t.line);o=e.end,c=e.renderEnd}o<i&&(o=i),c<i&&(c=i),c>o&&(c=o);let u={index:t.index,id:t.id,label:t.label,tags:t.tags,sectionIndex:t.sectionIndex,start:i,end:o,renderEnd:c,manualEnd:s,line:t.line};return d[t.index]=u,u};for(let t of s)c(e.tasks[t]);if(0===d.length)return{tasks:d,timeMin:0,timeMax:0,dateOnly:l,isExcludedDay:n};let u=1/0,h=-1/0;for(let e of d)u=Math.min(u,e.start),h=Math.max(h,e.renderEnd);if(h===u&&(h=u+(l?864e5:36e5)),void 0!==t.today&&!e.todayMarker?.off){let a=ef(t.today,e.dateFormat)??ef(t.today,"YYYY-MM-DD");if(null===a)throw new j("GANTT_BAD_DATE",`Invalid clock value "${t.today}" for dateFormat "${e.dateFormat}"`);i=a}return{tasks:d,timeMin:u,timeMax:h,dateOnly:l,today:i,analysis:function(e,t,i,a){let n=[],l=new Set;for(let t of e.tasks){if(t.start?.kind==="after")for(let e of t.start.refs){let a=i.get(e);n.push({from:a.index,to:t.index}),l.add(a.index)}if("until"===t.end.kind)for(let e of t.end.refs)l.add(i.get(e).index)}if(0===n.length)return;let r=Math.min(...t.map(e=>e.start)),o=Math.max(...t.map(e=>e.end)),s=t.map(()=>[]);for(let e of n)s[e.from].push(e.to);let d=Array(t.length).fill(NaN);for(let e=a.length-1;e>=0;e--){let i=a[e],n=s[i],l=o;for(let e of n){let i=t[e].end-t[e].start;l=Math.min(l,d[e]-i)}d[i]=l}let c={},u=new Set;for(let e of n)u.add(e.from),u.add(e.to);let h=[];for(let e of t){let t=d[e.index]-e.end;void 0!==e.id&&(c[e.id]=t),u.has(e.index)&&0===t&&void 0!==e.id&&h.push(e.id)}let f=new Set(n.map(e=>e.to));return{criticalPathTaskIds:h,slackByTaskId:c,projectStart:r,projectEnd:o,entryTaskIds:t.filter(e=>void 0!==e.id&&!f.has(e.index)).map(e=>e.id),sinkTaskIds:t.filter(e=>void 0!==e.id&&!l.has(e.index)).map(e=>e.id)}}(e,d,r,s),isExcludedDay:n}}(o,l.clock),d=function(e,t,i={}){let a,n=eI(i.renderOptions,i.styleFace),l=i.compact??"compact"===e.displayMode,r=0===t.tasks.length?E("No tasks scheduled",{fontSize:n.nodeLabelFontSize,fontWeight:n.nodeLabelFontWeight,transform:n.nodeTextTransform,letterSpacing:n.nodeLetterSpacing}):void 0,o=i.barHeight??e.barHeight??22,s=Math.ceil(Math.max(o,1.3*Math.max(n.nodeLabelFontSize,n.groupHeaderFontSize)))+8,d=t.tasks.filter(e=>e.tags.includes("vert")),c=t.tasks.filter(e=>!e.tags.includes("vert")),u=function(e){let t=new Map;for(let i of e){let e=t.get(i.sectionIndex);e||t.set(i.sectionIndex,e=[]),e.push(i)}return t}(c),h=new Map,f=new Map,m=0;for(let e of c)if(l){let t=E(e.label,{display:"literal",transform:n.nodeTextTransform,fontSize:n.nodeLabelFontSize,fontWeight:n.nodeLabelFontWeight,letterSpacing:n.nodeLetterSpacing});h.set(e.index,{lines:t.lines,width:t.width,block:t}),m=Math.max(m,t.width)}else{let t=eY(e.label,n.nodeTextTransform,n.nodeLabelFontSize,n.nodeLabelFontWeight,n.nodeLetterSpacing);h.set(e.index,t),m=Math.max(m,t.width)}for(let t=0;t<e.sections.length;t++){let i=e.sections[t];if(i.label){let e=eY(z(i.label),n.groupTextTransform,n.groupHeaderFontSize,n.groupHeaderFontWeight,n.groupLetterSpacing);f.set(t,e),m=Math.max(m,e.width)}}m=Math.ceil(m)+Math.max(12,i.renderOptions?.gantt?.dependencyArrows?eT(eM(n.lineWidth,!0===i.renderOptions.gantt.criticalPath))+4:0),l&&(s=Math.max(s,...[...h.values()].map(e=>Math.ceil(e.block.height)+8)));let p=new Map(d.map(e=>[e.index,E(e.label,{display:"literal",transform:n.edgeTextTransform,fontSize:n.edgeLabelFontSize,fontWeight:Math.max(n.edgeLabelFontWeight,600),letterSpacing:n.edgeLetterSpacing})])),g=Math.max(1,t.timeMax-t.timeMin),k=(function(e,t,i=8){if(0===e.tasks.length)return[];let a=function(e,t,i=8){let a=e.timeMax-e.timeMin;if(t.tickInterval&&a/(eL[t.tickInterval.unit]*t.tickInterval.count)<=120)return{...t.tickInterval,format:t.axisFormat??function(e){switch(e){case"millisecond":case"second":return"%H:%M:%S";case"minute":case"hour":return"%H:%M";case"day":case"week":return"%m-%d";case"month":return"%b %Y"}}(t.tickInterval.unit)};for(let e of e$)if(a/(eL[e.unit]*e.count)<=i)return{unit:e.unit,count:e.count,format:t.axisFormat??e.format};let n=e$[e$.length-1],l=n.count;for(;a/(eL.month*l)>120;)l*=2;return{unit:"month",count:l,format:t.axisFormat??n.format}}(e,t,i),n=ed[t.weekStart],l=[],r=function(e,t,i){if("week"===t.unit){let t=eo(e),a=0;for(;es(t)!==i&&a++<7;)t-=864e5;return t}if("month"===t.unit){let t=new Date(e);return Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),1)}if("day"===t.unit)return eo(e);let a=eL[t.unit]*t.count;return Math.floor(e/a)*a}(e.timeMin,a,n),o=0;for(;r<=e.timeMax&&o++<=120;)r>=e.timeMin&&l.push({time:r,label:ev(r,a.format)}),r=function(e,t){if("month"===t.unit){let i=new Date(e);return Date.UTC(i.getUTCFullYear(),i.getUTCMonth()+t.count,1)}return e+eL[t.unit]*t.count}(r,a);return 0===l.length&&l.push({time:e.timeMin,label:ev(e.timeMin,a.format)}),l})(t,e).map(e=>({...e,block:E(e.label,{display:"literal",transform:n.edgeTextTransform,fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing})})),x=16+m,y=i.width??32+m+600,b=Math.max(16,Math.ceil((a=Math.max(120,y-x-16),Math.max(0,...k.map(e=>e.block.width/2-(t.timeMax-e.time)/g*a))+2))),v=e.title?E(e.title,{display:"literal",transform:n.groupTextTransform,fontSize:eC(n),fontWeight:e_(n),letterSpacing:n.groupLetterSpacing,...void 0===i.width?{}:{maxWidth:Math.max(1,i.width-32)}}):void 0,w=v?.width??0,M=v?v.height-v.lineHeight:0,S=i.width??Math.max(y+b-16,Math.ceil(w)+32),T=Math.max(120,S-x-b),F=v?Math.max(eW(n)+M,v.height):0,L=Math.max(24,Math.ceil(eA(n)+.65*n.edgeLabelFontSize+4)),$=16+F+(e.topAxis?L:0)+Math.max(0,...[...p.values()].map(e=>(e.height-e.lineHeight)/2)),I=e=>x+(e-t.timeMin)/g*T,C=[],_=[],D=[],A=$,W=(e,t)=>Math.max(s,Math.ceil(o/2+(e-.5)*t)+8),B=Math.max(1.3*n.nodeLabelFontSize,...[...h.values()].map(e=>e.block.lineHeight)),U=Math.max(1.3*n.groupHeaderFontSize,...[...f.values()].map(e=>e.block.lineHeight));for(let t=0;t<e.sections.length;t++){let i=e.sections[t],a=u.get(t)??[];if(0===a.length&&void 0===i.label)continue;let n=D.length,r=A,d=_.length,c=f.get(t)?.lines;void 0!==i.label&&(A+=W(c?.length??1,U));let m=l?function(e){let t=[],i=[],a=0,n;for(let l of e){let r=-1;if(n){if(n[1]<=l.start){let e=1;for(;e<a;)e=n[2*e]<=l.start?2*e:2*e+1;r=e-a}}else r=t.findIndex(e=>e<=l.start);-1===r&&(r=t.length);let o=r===t.length;if(t[r]=l.end,i.push(r),n&&t.length<=a){let e=a+r;for(n[e]=t[r];(e>>=1)>0;)n[e]=Math.min(n[2*e],n[2*e+1])}else if(n||o&&33===t.length&&i.length<e.length&&e.every(e=>Number.isFinite(e.start)&&Number.isFinite(e.end))){n=Array(2*(a=0===a?64:2*a)).fill(1/0);for(let e=0;e<t.length;e++)n[a+e]=t[e];for(let e=a-1;e>0;e--)n[e]=Math.min(n[2*e],n[2*e+1])}}return i}(a):a.map((e,t)=>t),p=0===a.length?0:Math.max(...m)+1,g=[];if(l)for(let e=0;e<p;e++)g.push({barIndexes:[],sectionIndex:n,y:A+e*s,h:o});else{let e=A;for(let t of a)g.push({barIndexes:[],sectionIndex:n,y:e,h:o}),e+=W(h.get(t.index)?.lines.length??1,B)}if(a.forEach((e,t)=>{let a=m[t],l=g[a],r=I(e.start),s=Math.max(2*(e.renderEnd>e.start),I(e.renderEnd)-r),c;if(e.tags.includes("milestone")){let e=o/2,t=x+e;c=Math.min(Math.max(t,x+T-e),Math.max(t,r+s/2))}let u=h.get(e.index)?.lines;C.push({taskIndex:e.index,id:e.id,label:e.label,labelBlock:h.get(e.index)?.block,tags:e.tags,sectionIndex:n,x:r,y:l.y,w:s,h:o,milestoneX:c,rowIndex:d+ +(void 0!==i.label)+a,start:e.start,end:e.renderEnd,...u&&u.length>1?{labelLines:u}:{}}),l.barIndexes.push(C.length-1)}),_.push(...g),l)A+=p*s;else for(let e of a)A+=W(h.get(e.index)?.lines.length??1,B);D.push({label:i.label,labelBlock:f.get(t)?.block,y:r,h:A-r,rowStart:d,rowEnd:_.length,...c&&c.length>1?{labelLines:c}:{}}),A+=6}let N=Math.max(s,A-$,r?r.height+16:0),H=$+N+L+16,Y=k.map(e=>({time:e.time,x:I(e.time),label:e.label,labelBlock:e.block})),O=d.map(e=>({taskIndex:e.index,label:e.label,labelBlock:p.get(e.index),x:I(e.start+(e.renderEnd-e.start)/2),time:e.start})),P=void 0!==i.today&&i.today>=t.timeMin&&i.today<=t.timeMax?I(i.today):void 0,j=[];if(e.excludes.length>0&&t.dateOnly&&(t.timeMax-eo(t.timeMin))/864e5<=1e4){let e,i=i=>{if(void 0===e)return;let a=Math.max(e,t.timeMin),n=Math.min(i,t.timeMax);n>a&&j.push({x:I(a),w:I(n)-I(a),start:a,end:n}),e=void 0};for(let a=eo(t.timeMin);a<t.timeMax;a+=864e5)t.isExcludedDay(a)?void 0===e&&(e=a):i(a);i(t.timeMax)}let X=new Set(t.analysis?.criticalPathTaskIds??[]),G=t.tasks.filter(e=>void 0!==e.id&&X.has(e.id)).map(e=>e.index),R=function(e,t,i,a,n,l,r={}){let o=function(e){let t=new Map;for(let i of e.tasks)void 0!==i.id&&t.set(i.id,i);let i=[],a=new Set,n=(e,t,n)=>{let l=`${e}>${t}:${n}`;a.has(l)||(a.add(l),i.push({from:e,to:t,kind:n}))};for(let i of e.tasks){if(i.start?.kind==="after")for(let e of i.start.refs){let a=t.get(e);a&&n(a.index,i.index,"after")}if("until"===i.end.kind)for(let e of i.end.refs){let a=t.get(e);a&&n(i.index,a.index,"until")}}return i}(e);if(0===o.length)return[];let s=new Map(i.map(e=>[e.taskIndex,e])),d=i.map(ez),c=a.map(e=>({y:e.y,h:e.h})).sort((e,t)=>e.y-t.y),u=new Set(t.analysis?.criticalPathTaskIds??[]),h=[];for(let e of o){let i=s.get(e.from),a=s.get(e.to);if(!i||!a)continue;let o=t.tasks[e.from],f=t.tasks[e.to],m="after"===e.kind&&void 0!==o.id&&void 0!==f.id&&u.has(o.id)&&u.has(f.id)&&o.end===f.start,p=function(e,t,i,a,n,l=8){let r=e.rect,o=t.rect,s=r.y+r.h/2,d=o.y+o.h/2,c=eU(a,s),u=eU(a,d);if(-1===c||-1===u)return null;let h=c===u,f=h||u>c,m=f?eN(a,c,n):eH(a,c,n),p=h?m:f?eH(a,u,n):eN(a,u,n),g=[],k=r.x+r.w,x=[{x:k,y:s},{x:k+l,y:s},{x:k+l,y:m}];if(eE(x[0],x[1],i)||eE(x[1],x[2],i)){let t=e.tipX??(r.w>=2*l?k-l:r.x+r.w/2);g.push({x:t,y:f?r.y+r.h:r.y},{x:t,y:m})}else g.push(...x);let y=g[g.length-1].x,b=o.x-l;if(!h){let e=f?1:-1;for(let t=c+e;t!==u;t+=e){let e=a[t];if(i.some(t=>eB(y,e.y-1,e.y+e.h+1,t))){let l=f?eH(a,t,n):eN(a,t,n),r=function(e,t,i,a){let n=i.x-8,l=i.x+i.w+8,r=t.filter(t=>t.y<e.y+e.h-.01&&t.y+t.h>e.y+.01),o=new Set([n]);for(let e of r)o.add(Math.max(n,Math.min(l,e.x-8))),o.add(Math.max(n,Math.min(l,e.x+e.w+8)));let s=n,d=1/0;for(let t of o){if(r.some(i=>eB(t,e.y-1,e.y+e.h+1,i)))continue;let i=Math.abs(t-a);(i<d-.01||.01>=Math.abs(i-d)&&t<s)&&(s=t,d=i)}return s}(e,i,n,b);g.push({x:y,y:l},{x:r,y:l}),y=r}}}let v=o.x-l,w=[{x:v,y:p},{x:v,y:d},{x:o.x,y:d}],M,S;if(eE(w[0],w[1],i)||eE(w[1],w[2],i)){let e=t.tipX??(o.w>=2*l?o.x+l:o.x+o.w/2),i=p<o.y;S=[{x:e,y:p},{x:e,y:i?o.y:o.y+o.h}],M=i?"down":"up"}else S=w,M="right";g.push({x:y,y:p},...S);let T=function(e){let t=[];for(let i of e){let e=t[t.length-1];if(e&&.01>=Math.abs(e.x-i.x)&&.01>=Math.abs(e.y-i.y))continue;t.push({x:i.x,y:i.y});let a=t.length;if(a>=3){let e=t[a-3],i=t[a-2],n=t[a-1];(.01>=Math.abs(e.x-i.x)&&.01>=Math.abs(i.x-n.x)||.01>=Math.abs(e.y-i.y)&&.01>=Math.abs(i.y-n.y))&&t.splice(a-2,1)}}return t}(g);for(let e=1;e<T.length;e++)if(eE(T[e-1],T[e],i))return null;return{points:T,arrowDir:M}}({rect:ez(i),tipX:i.milestoneX},{rect:ez(a),tipX:a.milestoneX},d,c,n,r.gantt?.dependencyArrows?eT(eM(l.lineWidth,!0===r.gantt.criticalPath&&m)):8);p&&h.push({fromTaskIndex:e.from,toTaskIndex:e.to,kind:e.kind,critical:m,points:p.points,arrowDir:p.arrowDir})}return h}(e,t,C,_,{x:x,y:$,w:T,h:N},n,i.renderOptions),J=new Map(e.tasks.flatMap(e=>e.id?[[e.id,e.index]]:[])),K=e.clicks.flatMap(e=>{if("href"!==e.action)return[];let t=J.get(e.taskId),i=e.rest.match(/^"((?:\\.|[^"])*)"|^(\S+)/)?.slice(1).find(Boolean);return void 0!==t&&i&&/^(?:https?:|mailto:)/i.test(i)?[{taskIndex:t,href:i.replace(/\\(["\\])/g,"$1")}]:[]}),V=new Map;for(let e of C){let t=V.get(e.y)??[];t.push(e),V.set(e.y,t)}for(let e of V.values())e.sort((e,t)=>e.x-t.x),e.forEach((t,i)=>{let a=t.labelBlock;if(!a)return;let n=t.y+t.h/2,r=i>0?e[i-1].x+e[i-1].w+4:2,o=i+1<e.length?e[i+1].x-4:S-2;t.labelPosition=l?t.x-6-a.width>=r?{x:t.x-6,y:n,anchor:"end"}:t.x+t.w+6+a.width<=o?{x:t.x+t.w+6,y:n,anchor:"start"}:{x:16,y:n,anchor:"start"}:{x:16,y:n,anchor:"start"}});return{...r?{emptyLabel:r}:{},title:v?.text,titleBlock:v,titleY:Math.max(eD(n),(v?.lineHeight??0)/2)+M/2,width:S,height:H,plot:{x:x,y:$,w:T,h:N},labelColumnWidth:m,rows:_,sections:D,bars:C,links:K,verts:O,ticks:Y,dependencies:R,criticalTaskIndexes:G,excludedBands:j,topAxis:e.topAxis,todayX:P,...e.todayMarker?.style!==void 0?{todayMarkerStyle:e.todayMarker.style}:{},timeMin:t.timeMin,timeMax:t.timeMax,dateOnly:t.dateOnly,compact:l,barHeight:o}}(o,s,{...l.layout,today:s.today});return{model:o,schedule:s,positioned:d}}(e.source.familyLines,n,{clock:{today:e.renderOptions.ganttToday},layout:{renderOptions:e.renderOptions,...e.styleFace?{styleFace:e.styleFace}:{}}}).positioned)},projectPositioned:k(function({positioned:e,options:t}){let i=e.plot.x+e.plot.w,a={version:1,nodes:e.bars.map(t=>{let a=t.id??`task#${t.taskIndex}`,n=t.labelPosition,l=n&&!e.compact&&t.labelBlock?n.y+(t.labelBlock.height-t.labelBlock.lineHeight)/2:n?.y,r=n&&void 0!==l?g(t.labelBlock,n.x,l,h(e),n.anchor):{};if(void 0!==t.milestoneX){let e=t.h/2;return{id:a,x:f(t.milestoneX-e),y:f(t.y),w:m(t.milestoneX-e,t.h),h:m(t.y,t.h),shape:"diamond",label:t.label,...r}}let o=Math.max(2,t.w),s=Math.min(t.x,i-o);return{id:a,x:f(s),y:f(t.y),w:m(s,o),h:m(t.y,t.h),shape:"rectangle",label:t.label,...r}}),edges:[],groups:e.sections.map((t,i)=>({id:`section#${i}`,x:f(e.plot.x),y:f(t.y),w:m(e.plot.x,e.plot.w),h:m(t.y,t.h),members:e.bars.filter(e=>e.sectionIndex===i).map(e=>e.id??`task#${e.taskIndex}`),label:t.label})),bounds:{w:f(e.width),h:f(e.height)}};return t.debug&&(a.certificates=p("gantt",a,"section-contained")),a}),lowerScene:x(eJ)});export{eK as default};
@@ -0,0 +1,9 @@
1
+ import{h as e}from"./chunk-J7FFAFQF.js";import{b as t,c as i,f as a}from"./chunk-2I4UPL7Q.js";import{d as r,e as n,g as o}from"./chunk-2SH76OTH.js";import{d as l}from"./chunk-AMJLVPUB.js";import"./chunk-DF6765YX.js";import"./chunk-J35HAQQF.js";import{a as s,b as c,c as m,d as h}from"./chunk-CN7WTBWB.js";import{C as d,a as p,b as g,c as f,d as u,e as y,g as b,i as x}from"./chunk-HLWUNUCM.js";import{C as k,c as w,y as L}from"./chunk-X2UYKWKM.js";import{e as v,i as B,j as z,k as M,q as S}from"./chunk-TYZOZXUJ.js";import{f as $,h as C}from"./chunk-NO7ZIVRU.js";import{Da as R,N as F,Qb as _,S as T,T as G,U as I,Z as H,na as N,ob as Y,ra as X,wa as E,x as O}from"./chunk-Z3FDIVLN.js";import{E as j,F as A}from"./chunk-N5ELX7LR.js";import"./chunk-5UVGUSD6.js";import"./chunk-CSFUKSU6.js";var W=Object.freeze({id:"gitgraph",upstreamId:"gitGraph",maturity:"stable",label:"GitGraph",headers:["gitGraph"],aliases:[],config:{section:"gitGraph",keys:["showBranches","showCommitLabel","mainBranchName","mainBranchOrder","parallelCommits","rotateCommitLabel","arrowMarkerAbsolute","diagramPadding","nodeLabel","titleTopMargin"],noopKeys:["arrowMarkerAbsolute","diagramPadding","nodeLabel","titleTopMargin"]},identity:{id:"family:gitgraph",kind:"family",version:"1.0.0",compatibility:{core:"0.5.3"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:["status","category"],semanticRoles:["prelude","chrome","title","group","rail","edge","node","label"],scenePrimitiveEvidence:[{role:"prelude",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"title",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"rail",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"edge",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"node",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"label",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]}],example:`gitGraph
2
+ commit id:"base"
3
+ branch feature
4
+ commit id:"work"
5
+ checkout main
6
+ commit id:"release"
7
+ merge feature id:"merge"`,detect:j,detectLoose:A}),D={showBranches:n,showCommitLabel:n,parallelCommits:n,rotateCommitLabel:n,mainBranchName:o,mainBranchOrder:r};function U(e){return"merge"===e.source&&e.customId?e.sourceId||e.id:e.message||e.sourceId||e.id}function P(e,t,i,a={}){return H(e,{display:"literal",fontSize:t,fontWeight:i,...a})}function q(e,t){return -6-e[t].fontSize-e.slice(0,t).reduce((e,t)=>e+t.height+5,0)-(e[t].height-e[t].lineHeight)/2}function V(e,t){let i=e.height-e.lineHeight;return"LR"===t?24+i:4+i/2}function K(e,t,i,a,r){let n=[{minX:-10,minY:-10,maxX:10,maxY:10}];if(r){let r=e.labelBlock??P(U(e),a,500);n.push(Z(r,14*("LR"!==t),V(r,t),a,"LR"===t?"middle":"start","LR"===t&&i?45:0))}let o=e.tagBlocks??e.tags.map(e=>P(e,10,600));for(let[t,i]of e.tags.entries()){let e=Q(o[t],14,q(o,t),10,600,"start",0);n.push({...e,minX:e.minX-4,maxX:e.maxX+6,minY:e.minY-2,maxY:e.maxY+2})}return{minX:Math.min(...n.map(e=>e.minX)),minY:Math.min(...n.map(e=>e.minY)),maxX:Math.max(...n.map(e=>e.maxX)),maxY:Math.max(...n.map(e=>e.maxY))}}function Z(e,t,i,a,r,n){let o="string"==typeof e?P(e,a,500):e;a=o.fontSize;let l=o.height-o.lineHeight,s=Math.max(18,o.width+24),c="middle"===r?-s/2:-12,m=R({x0:t+c,y0:i-a-l/2,x1:t+c+s,y1:i+6+l/2},{x:t,y:i},n);return{minX:m.x0,minY:m.y0,maxX:m.x1,maxY:m.y1}}function Q(e,t,i,a,r,n,o){let l="string"==typeof e?P(e,a,r):e;a=l.fontSize;let s=l.height-l.lineHeight,c=l.width,m="middle"===n?-c/2:"end"===n?-c:0,h=R({x0:t+m,y0:i+(-a-s/2),x1:t+m+c,y1:i+(.28*a+s/2)},{x:t,y:i},o);return{minX:h.x0,minY:h.y0,maxX:h.x1,maxY:h.y1}}function J(e){return Math.round(1e3*e)/1e3}var ee=class extends Error{constructor(e,t){super(e),this.line=t,this.name="GitGraphParseError"}line},et=class extends ee{constructor(e,t){super(`Duplicate gitGraph commit id '${e}' on line ${t}; commit IDs must be unique.`,t),this.id=e}id;code="GITGRAPH_DUPLICATE_COMMIT_ID"},ei={spanning:"\"'",wholeLine:e=>/^title(?:\s|$)/i.test(e)};function ea(e){return i(e,ei)}var er=/^commit(?:\s+(.*))?$/is,en=/^merge\s+("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+)(?:\s+(.*))?$/is;function eo(e,t,i){let a={tags:[]},r=0,n=/([A-Za-z][\w-]*)\s*:\s*("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+)/gy;for(;r<e.length;){for(;/\s/.test(e[r]??"");)r++;if(r>=e.length)break;n.lastIndex=r;let o=n.exec(e);if(!o)throw new ee(`Invalid gitGraph attribute syntax near '${e.slice(r)}'.`,t);let l=o[1].toLowerCase();if(!i.includes(l))throw new ee(`Attribute '${l}' is not valid for this gitGraph statement.`,t);let s=el(o[2]);if("id"===l)a.id=s;else if("msg"===l)a.msg=s;else if("tag"===l)a.tags.push(s);else if("parent"===l)a.parent=s;else{let e=s.toUpperCase();if(!["NORMAL","REVERSE","HIGHLIGHT"].includes(e))throw new ee(`Invalid commit type '${s}'.`,t);a.type=e}r=n.lastIndex}return a}function el(e){if(!/^(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')$/.test(e))return e;let t={b:"\b",f:"\f",n:`
8
+ `,r:"\r",t:" ",v:"\v",0:"\0"};return e.slice(1,-1).replace(/\\(.)/g,(e,i)=>t[i]??i)}var es=function(e){let t={"\b":"b","\f":"f","\n":"n","\r":"r"," ":"t","\v":"v","\0":"0"};return`"${e.replace(/[\\"%\b\f\n\r\t\v\0]/g,e=>`\\${t[e]??e}`).replace(/#\w+;/g,e=>`${e.slice(0,-1)}\\;`).replace(/style/g,"sty\\le").replace(/classDef/g,"class\\Def")}"`};function ec(e){let t=(e&&"object"==typeof e&&!Array.isArray(e)?e:{}).commitLabelFontSize,i="number"==typeof t?t:"string"==typeof t?Number.parseFloat(t):11;return Number.isFinite(i)&&i>0?i:11}function em(e,t){let i={commitLabelFontSize:ec(t)};if(!e||"object"!=typeof e||Array.isArray(e))return i;for(let t of["showBranches","showCommitLabel","rotateCommitLabel","parallelCommits"])"boolean"==typeof e[t]&&(i[t]=e[t]);return"string"==typeof e.mainBranchName&&e.mainBranchName.trim()&&(i.mainBranchName=e.mainBranchName.trim()),"number"==typeof e.mainBranchOrder&&Number.isFinite(e.mainBranchOrder)&&(i.mainBranchOrder=e.mainBranchOrder),i}function eh(e){return Math.round(1e3*e)/1e3}var ed=w(function(t,i){var a;let r,n,o,l,s,c,m,h,{positioned:d,colors:p,resolved:g}=i,f=g.renderOptions,u=p.font??"Inter",y=f.transparent??!1,b="gitgraph-title",x="gitgraph-desc",k=S(d.accessibilityTitle??"Git graph",d.accessibilityDescription,b,x,"git graph"),w=[M(d.width,d.height,p,y,{attrs:k}),z(u,!1,p.shadow,p.embedFontImport)],L=B(p);L&&w.push(`<defs>${L}</defs>`);let $=g.familyAppearance;if(!$)throw Error("GitGraph rendering requires request-boundary family appearance resolution");let C=(a=$.themeVariables,r=a&&"object"==typeof a&&!Array.isArray(a)?a:{},n="string"==typeof p.accent?p.accent:"#3b82f6",o="string"==typeof p.bg?p.bg:"#ffffff",l=/^#[0-9a-f]{6}$/i.test(n)?n:"#3b82f6",s=/^#[0-9a-f]{6}$/i.test(o)?o:"#ffffff",c=e(d.branches.length,d.branches.length<=6?{accent:l,bg:s}:{accent:n,bg:o}),m=new Map,d.branches.forEach((e,t)=>{let i=t%8,a=v(r[`git${i}`])??c[t],n=v(r[`gitBranchLabel${i}`])??a,o=v(r[`gitInv${i}`])??a,l=E(a)&&E(s)?N(a,s,18):"var(--_node-fill)",h=E(a)&&E(s)?N(a,s,9):"var(--bg)",d=X(n,h,4.5,p.fg);m.set(e.name,{line:a,label:d,highlight:o,normalFill:l,labelBackground:h})}),h=ec(r),{branches:m,commitLabelColor:v(r.commitLabelColor)??"var(--_text-sec)",commitLabelBackground:v(r.commitLabelBackground)??(E(s)?s:"var(--bg)"),commitLabelFontSize:h}),R=[t.documentOpen({id:"prelude",width:d.width,height:d.height,colors:p,transparent:y,font:u,hasMonoFont:!1},w.join(`
9
+ `))];if(R.push(t.documentText({id:"acc-title",element:"title",domId:b,text:d.accessibilityTitle??"Git graph"})),d.accessibilityDescription&&R.push(t.documentText({id:"acc-desc",element:"description",domId:x,text:d.accessibilityDescription})),d.title){let e=d.titleBlock??P(d.title,16,600);R.push(t.text({id:"gitgraph-visible-title",role:"title",identity:{id:"gitgraph-title",classNames:["gitgraph-title"]},text:e.text,block:e,x:d.width/2,y:8+(d.titleBlock?.fontSize??16)*.65+((d.titleBlock?.height??0)-(d.titleBlock?.lineHeight??0))/2,fontSize:e.fontSize,anchor:"middle",paint:{fill:"var(--_text)"},attributes:{className:"gitgraph-title"}}))}if(d.showBranches)for(let e of d.branches){let i=I("branch",e.name),a=C.branches.get(e.name),r=eh("LR"===d.direction?e.x1-10:e.x1),n=eh("LR"===d.direction?e.y1:e.y1-16),o=e.labelBlock??P(e.name,12,600),l=o.height-o.lineHeight,s=eh(o.width+10),c=eh("LR"===d.direction?r-s:r-s/2);R.push(t.group({id:i,role:"group",channels:{category:e.name},open:`<g class="git-branch" data-id="${F(i)}" data-branch="${F(e.name)}">`,close:"</g>",children:[{node:t.shape({id:G(i,"label-bg"),role:"chrome",geometry:{kind:"rect",x:c,y:eh(n-o.fontSize-1-l/2),width:s,height:eh(o.fontSize+6+l),rx:4,ry:4},paint:{fill:a.labelBackground,stroke:a.line,strokeWidth:"1"},attributes:{className:"git-branch-label-background"}}),indent:2},{node:t.shape({id:G(i,"line"),role:"rail",geometry:{kind:"line",x1:eh(e.x1),y1:eh(e.y1),x2:eh(e.x2),y2:eh(e.y2)},paint:{stroke:a.line,strokeWidth:"3"},channels:{category:e.name},attributes:{className:"git-branch-line",data:{branch:e.name}}}),indent:2},{node:t.text({id:G(i,"label"),role:"label",text:o.text,block:o,x:r,y:n-.35*o.fontSize,fontSize:o.fontSize,anchor:"LR"===d.direction?"end":"middle",paint:{fill:a.label},channels:{category:e.name},attributes:{className:"git-branch-label",data:{branch:e.name}}}),indent:2}]}))}let _=new Map(d.commits.map(e=>[e.id,e]));for(let e of d.edges){let i=_.get(e.to)?.branch,a=i?C.branches.get(i)?.line??"var(--_line)":"var(--_line)";R.push(t.connector({id:T(e.from,e.to),role:"edge",geometry:{kind:"polyline",points:e.points.map(e=>({x:eh(e.x),y:eh(e.y)}))},lineStyle:"cherry-pick"===e.kind?"dashed":"solid",paint:{fill:"none",stroke:a,strokeWidth:"parent"===e.kind?"2":"2.5",..."cherry-pick"===e.kind?{strokeDasharray:"4 3"}:{}},endpoints:{from:e.from,to:e.to},relationship:{kind:e.kind,direction:"forward"},route:{ownership:"layout"},channels:{category:e.kind},attributes:{className:`git-edge git-edge-${e.kind}`}}))}for(let e of d.commits)R.push(function(e,t,i,a){let r=t.customType??t.type,n=function(e){let t=e.customType??e.type;return"HIGHLIGHT"===t?{kind:"rect",x:eh(e.x-9),y:eh(e.y-9),width:18,height:18,rx:2,ry:2}:"CHERRY_PICK"===t?{kind:"polygon",points:[{x:eh(e.x),y:eh(e.y-10)},{x:eh(e.x+10),y:eh(e.y)},{x:eh(e.x),y:eh(e.y+10)},{x:eh(e.x-10),y:eh(e.y)}]}:{kind:"circle",cx:eh(e.x),cy:eh(e.y),r:"MERGE"===t?10:8}}(t),o=a.branches.get(t.branch),l="HIGHLIGHT"===r?o.highlight:"MERGE"===r?o.line:o.normalFill,s=o.line,c=[{node:e.shape({id:G(t.id,"shape"),role:"chrome",geometry:n,paint:{fill:l,stroke:s,strokeWidth:"2"},channels:{status:r.toLowerCase(),category:t.branch}}),indent:2}];if("MERGE"===r&&c.push({node:e.shape({id:G(t.id,"inner"),role:"chrome",geometry:{kind:"circle",cx:eh(t.x),cy:eh(t.y),r:5},paint:{fill:"none",stroke:"var(--bg)",strokeWidth:"1.5"}}),indent:2}),"REVERSE"===r)for(let i of[-1,1])c.push({node:e.shape({id:G(t.id,"cross",i),role:"chrome",geometry:{kind:"line",x1:eh(t.x-6),y1:eh(t.y+6*i),x2:eh(t.x+6),y2:eh(t.y-6*i)},paint:{stroke:"var(--_arrow)",strokeWidth:"2"}}),indent:2});if(i.showCommitLabel){let r=t.labelBlock??P(U(t),a.commitLabelFontSize,500),n=r.text,l=r.height-r.lineHeight,s="LR"===i.direction?t.x:t.x+14,m=t.y+V(r,i.direction),h="LR"===i.direction?"middle":"start",d="LR"===i.direction&&i.rotateCommitLabel?{kind:"rotate",angle:45,cx:eh(s),cy:eh(m)}:void 0;if(a.commitLabelBackground){let i=eh(Math.max(18,r.width+24)),n=eh("middle"===h?s-i/2:s-12);c.push({node:e.shape({id:G(t.id,"label-bg"),role:"chrome",geometry:{kind:"rect",x:n,y:eh(m-r.fontSize-l/2),width:i,height:eh(r.fontSize+6+l),rx:3,ry:3},paint:{fill:a.commitLabelBackground,fillOpacity:"0.94",stroke:o.line,strokeWidth:"0.75"},transform:d,attributes:{className:"git-commit-label-background"}}),indent:2})}c.push({node:e.text({id:G(t.id,"label"),role:"label",text:n,block:r,x:s,y:m-.35*r.fontSize,fontSize:r.fontSize,anchor:h,paint:{fill:a.commitLabelColor},transform:d,attributes:{className:"git-commit-label"}}),indent:2})}let m=t.tagBlocks??t.tags.map(e=>P(e,10,600));return t.tags.forEach((i,a)=>{let r=m[a],n=r.height-r.lineHeight,l=t.x+14,s=t.y+q(m,a),h=eh(r.width+10);c.push({node:e.shape({id:G(t.id,"tag-bg",a),role:"chrome",geometry:{kind:"rect",x:eh(l-4),y:eh(s-r.fontSize-1-n/2),width:h,height:eh(r.fontSize+5+n),rx:4,ry:4},paint:{fill:o.labelBackground,stroke:o.line,strokeWidth:"0.75"},attributes:{className:"git-tag-background"}}),indent:2}),c.push({node:e.text({id:G(t.id,"tag",a),role:"label",text:r.text,block:r,x:l,y:s-.35*r.fontSize,fontSize:r.fontSize,anchor:"start",paint:{fill:o.label},attributes:{className:"git-tag"}}),indent:2})}),e.group({id:t.id,role:"node",channels:{status:r.toLowerCase(),category:t.branch},open:`<g class="git-commit type-${r.toLowerCase()}" data-id="${F(t.id)}" data-branch="${F(t.branch)}" data-commit-type="${t.type}"${r!==t.type?` data-visual-type="${r}"`:""}>`,close:"</g>",children:c})}(t,e,d,C));return R.push(t.documentClose()),{family:"gitgraph",width:d.width,height:d.height,colors:p,transparent:y,parts:R}}),ep=u(W,{configDiagnostics:e=>l("gitgraph",e,D),statementEnds:ea,normalizeRequest:e=>({familyConfig:{position:em(e.source.config.gitGraph,e.source.config.themeVariables),..."string"==typeof e.source.frontmatter.title?{title:e.source.frontmatter.title}:{}},appearance:{family:{themeVariables:function(e){let t=e&&"object"==typeof e&&!Array.isArray(e)?e:{},i={commitLabelFontSize:ec(t)};for(let e=0;e<8;e++)for(let a of[`git${e}`,`gitBranchLabel${e}`,`gitInv${e}`]){let e=v(t[a]);void 0!==e&&(i[a]=e)}for(let e of["commitLabelColor","commitLabelBackground"]){let a=v(t[e]);void 0!==a&&(i[e]=a)}return i}(e.source.config.themeVariables)}}}),layout:e=>{let i=e.familyConfig,r=i?.position??em(void 0);return f(function(e,t,i={},a){return function(e,t={}){var i,a;let r="number"==typeof(i=t.padding)&&Number.isFinite(i)&&i>=0?i:44,n=!1!==t.showBranches,o=!1!==t.showCommitLabel,l=!1!==t.rotateCommitLabel,s="number"==typeof(a=t.commitLabelFontSize)&&Number.isFinite(a)&&a>0?a:11,c=C(t.renderOptions??{},{...$,nodeLabelFontSize:s,nodeLabelFontWeight:500,groupHeaderFontSize:12,groupHeaderFontWeight:600},t.styleFace),m=C(t.renderOptions??{},{...$,nodeLabelFontSize:10,nodeLabelFontWeight:600},t.styleFace),h=C(t.renderOptions??{},{...$,groupHeaderFontSize:16,groupHeaderFontWeight:600},t.styleFace),d=e.commits.map(e=>({...e,labelBlock:P(U(e),c.nodeLabelFontSize,c.nodeLabelFontWeight,{transform:c.nodeTextTransform,letterSpacing:c.nodeLetterSpacing}),tagBlocks:e.tags.map(e=>P(e,m.nodeLabelFontSize,m.nodeLabelFontWeight,{transform:m.nodeTextTransform,letterSpacing:m.nodeLetterSpacing}))})),p=e.title?P(e.title,h.groupHeaderFontSize,h.groupHeaderFontWeight,{transform:h.groupTextTransform,letterSpacing:h.groupLetterSpacing}):void 0,g=p?40-16*O+p.height:0,f=e.branches.map(e=>({...e,labelBlock:P(e.name,c.groupHeaderFontSize,c.groupHeaderFontWeight,{transform:c.groupTextTransform,letterSpacing:c.groupLetterSpacing})})).sort((e,t)=>e.order-t.order||e.sequence-t.sequence||Y(e.name,t.name)),u=new Map(f.map((e,t)=>[e.name,t])),y=(d.map(e=>[e.id,e]),new Map);for(let e of d){let t=0===e.parents.length?0:Math.max(...e.parents.map(e=>y.get(e)??0))+1;y.set(e.id,t)}let b=e=>t.parallelCommits?y.get(e.id):e.sequence,x=Math.max(0,...d.map(b)),k=Math.max(82,...f.map(e=>e.labelBlock.height+20),...d.map(t=>{let i=K(t,e.direction,l,s,o);return i.maxY-i.minY+20})),w=Math.max(150,...f.map(e=>e.labelBlock.width+20)),L=n?Math.max(80,...f.map(e=>e.labelBlock.width+24)):20,v=new Map;for(let t of d){let i=b(t),a=K(t,e.direction,l,s,o),r=v.get(i);v.set(i,r?{minX:Math.min(r.minX,a.minX),minY:Math.min(r.minY,a.minY),maxX:Math.max(r.maxX,a.maxX),maxY:Math.max(r.maxY,a.maxY)}:a)}let B=new Map,z=Array.from({length:x+1},(t,i)=>"BT"===e.direction?x-i:i);for(let[t,i]of z.entries()){let a=v.get(i)??{minX:-10,minY:-10,maxX:10,maxY:10},r="LR"===e.direction?a.minX:a.minY;if(0===t){B.set(i,"LR"===e.direction?Math.max(0,-r):0);continue}let n=z[t-1],o=v.get(n)??{minX:-10,minY:-10,maxX:10,maxY:10},l=B.get(n),s="LR"===e.direction?o.maxX:o.maxY;B.set(i,Math.max(l+94,l+s-r+18))}let M=r+L+20,S=r+g+38,R=d.map(t=>{let i=u.get(t.branch)??0,a=b(t);return"LR"===e.direction?{...t,lane:i,x:M+B.get(a),y:r+g+i*k}:{...t,lane:i,x:r+L+i*w,y:S+B.get(a)}}),F=new Map(R.map(e=>[e.id,e])),_=[],T=new Map;for(let t of R){let i="LR"===e.direction?t.x:t.y;for(let[a,r]of(T.set(t.branch,Math.max(T.get(t.branch)??-1/0,i)),[...new Set(t.parents)].entries())){let i=F.get(r);if(!i)continue;let n="LR"===e.direction?(i.x+t.x)/2:(i.y+t.y)/2,o="LR"===e.direction?[{x:i.x,y:i.y},{x:n,y:i.y},{x:n,y:t.y},{x:t.x,y:t.y}]:[{x:i.x,y:i.y},{x:i.x,y:n},{x:t.x,y:n},{x:t.x,y:t.y}],l=0===a?"parent":"cherry-pick"===t.source?"cherry-pick":"merge";_.push({from:i.id,to:t.id,kind:l,points:o})}}let G=f.map((t,i)=>{let a=T.get(t.name)??-1/0;if("LR"===e.direction){let e=r+g+i*k;return{...t,lane:i,x1:M-14,y1:e,x2:Math.max(M,a),y2:e}}let n=r+L+i*w;return{...t,lane:i,x1:n,y1:r+g-14,x2:n,y2:Math.max(S,a)}}),I,H;"LR"===e.direction?(I=Math.max(2*r+L+80,...R.map(e=>e.x+(o?Math.max(26,.75*e.labelBlock.width):18)))+r,H=2*r+g+Math.max(0,f.length-1)*k+82+(o?2*s+26:0)):(I=2*r+L+Math.max(1,f.length)*w,H=Math.max(2*r+g+80,...R.map(e=>e.y+(o?38:18)))+r),e.title&&(I=Math.max(I,p.width+2*r));let N=[...R.flatMap(t=>{var i;let a;return[...o?[(i=e.direction,a=t.labelBlock??P(U(t),s,500),"LR"===i?Z(a,t.x,t.y+V(a,i),s,"middle",45*!!l):Z(a,t.x+14,t.y+V(a,i),s,"start",0))]:[],...t.tags.map((e,i)=>Q(t.tagBlocks[i],t.x+14,t.y+q(t.tagBlocks,i),10,600,"start",0))]}),...n?G.map(t=>Q(t.labelBlock,"LR"===e.direction?t.x1-10:t.x1,"LR"===e.direction?t.y1:t.y1-16,12,600,"LR"===e.direction?"end":"middle",0)):[]];if(N.length>0){let e=Math.min(...N.map(e=>e.minX)),t=Math.min(...N.map(e=>e.minY)),i=Math.max(...N.map(e=>e.maxX)),a=Math.max(...N.map(e=>e.maxY)),n=e<r?r-e:0,o=r+g,l=t<o?o-t:0;if(0!==n||0!==l){for(let e of R)e.x+=n,e.y+=l;for(let e of G)e.x1+=n,e.x2+=n,e.y1+=l,e.y2+=l;for(let e of _)for(let t of e.points)t.x+=n,t.y+=l}I=Math.max(I+n,i+n+r),H=Math.max(H+l,a+l+r)}for(let e of R)e.x=J(e.x),e.y=J(e.y);for(let e of G)e.x1=J(e.x1),e.y1=J(e.y1),e.x2=J(e.x2),e.y2=J(e.y2);for(let e of _)for(let t of e.points)t.x=J(t.x),t.y=J(t.y);return{width:J(I),height:J(H),direction:e.direction,...e.title?{title:e.title,titleBlock:p}:{},commits:R,branches:G,edges:_,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,showBranches:n,showCommitLabel:o,rotateCommitLabel:l}}(e,{...t,renderOptions:i,styleFace:a})}(k(function(e,i={}){var r,n;let o=e.replace(/^\uFEFF/,"").split(/\r?\n/),l=L(o,ea(o));if(void 0!==l.unclosedIndex)throw new ee("Unclosed accDescr block",l.unclosedIndex+1);let s=a(l.familyLines,ei).map(t),c=s.findIndex(e=>/^\s*gitgraph\b/i.test(e));if(c<0)throw new ee("gitGraph source must start with a gitGraph header");let m=s[c].trim().match(/^gitGraph(?:\s+(LR|TB|BT))?\s*:?[ \t]*$/i);if(!m)throw new ee("Invalid gitGraph header; expected gitGraph, gitGraph LR:, gitGraph TB:, or gitGraph BT:",c+1);y("gitgraph")&&b("gitgraph","header",s[c],{line:c+1,unit:"normalized"});let h=m[1]?.toUpperCase()??"LR",d="string"==typeof i.mainBranchName&&i.mainBranchName.trim()?i.mainBranchName.trim():"main",p="number"==typeof(r=i.mainBranchOrder)&&Number.isFinite(r)?r:0,g="string"==typeof i.title&&i.title.trim()?i.title.trim():void 0,f=[],u=new Map([[d,{name:d,order:p,sequence:0}]]),k=[],w=new Map,v=[],B=new Map;for(let e=c+1;e<s.length;e++){let t=s[e].trim(),i=t.match(er),a=i?void 0:t.match(en);if(!i&&!a)continue;let r=i?i[1]??"":a[2]??"";if(!(i&&/^(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')$/.test(r)))try{let t=eo(r,e+1,i?["id","tag","type","msg"]:["id","tag","type"]);B.set(e,t),void 0!==t.id&&v.push(t.id)}catch{}}let z=_(v),M=new Map,S=d,$=0,C=l.accessibility.title,R=l.accessibility.descr;y("gitgraph")&&x("gitgraph","initialize",{direction:h,mainBranchName:d,title:g,branch:u.get(d),currentBranch:S,accessibilityTitle:C,accessibilityDescription:R});let F=(e,t,i,a={},r)=>{let n=void 0!==e.id,o=e.id??`c${$}`;if("merge"===t&&n&&M.has(o))throw new et(o,i);let l=n&&!w.has(o)?o:z(o,["commit",$]),s="merge"===t?"MERGE":"cherry-pick"===t?"CHERRY_PICK":e.type??"NORMAL",c=u.get(S),m={id:l,...n&&l!==e.id?{sourceId:e.id}:{},...e.msg?{message:e.msg}:{},type:s,tags:e.tags,branch:S,parents:r??(c.head?[c.head]:[]),sequence:$++,source:t,customId:n,...a};return f.push(m),y("gitgraph")&&x("gitgraph","addCommit",m,{line:i,unit:"normalized"}),w.set(l,m),M.set(e.id??l,m),c.head=l,y("gitgraph")&&x("gitgraph","setBranchHead",{branch:S,head:l},{line:i,unit:"normalized"}),m};for(let e=c+1;e<s.length;e++){let t=s[e].trim();if(!t||t.startsWith("%%"))continue;let i=t.match(er);if(i){y("gitgraph")&&b("gitgraph","commit",t,{line:e+1,unit:"normalized"});let a=i[1]??"",r=F(/^(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')$/.test(a)?{tags:[],msg:el(a)}:B.get(e)??eo(a,e+1,["id","tag","type","msg"]),"commit",e+1);k.push({kind:"commit",ref:r.id}),y("gitgraph")&&x("gitgraph","appendStatement",k.at(-1),{line:e+1,unit:"normalized"});continue}let a=t.match(/^branch\s+("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+)(?:\s+order\s*:\s*(-?\d+))?$/i);if(a){y("gitgraph")&&b("gitgraph","branch",t,{line:e+1,unit:"normalized"});let i=el(a[1]);if(u.has(i))throw new ee(`Trying to create existing branch '${i}'; use checkout ${/^[A-Za-z_](?:[-./\w]*[-\w])?$/.test(i)&&!/^(?:title|(?:gitGraph|commit|branch|checkout|switch|merge|cherry-pick|LR|TB|BT|NORMAL|REVERSE|HIGHLIGHT)$)/i.test(i)?i:es(i)} instead.`,e+1);let r=void 0===a[2]?void 0:Number(a[2]);if(void 0!==r&&r<=0)throw new ee("Branch order must be a positive integer.",e+1);let o=r??((n=u.size)<=9?n/10:1-1/(n+1));u.set(i,{name:i,order:o,sequence:u.size,...u.get(S)?.head?{head:u.get(S).head}:{}}),y("gitgraph")&&x("gitgraph","addBranch",u.get(i),{line:e+1,unit:"normalized"}),S=i,y("gitgraph")&&x("gitgraph","setCurrentBranch",i,{line:e+1,unit:"normalized"}),k.push({kind:"branch",name:i,...void 0!==a[2]?{order:o}:{}}),y("gitgraph")&&x("gitgraph","appendStatement",k.at(-1),{line:e+1,unit:"normalized"});continue}let r=t.match(/^(checkout|switch)\s+("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+)$/i);if(r){y("gitgraph")&&b("gitgraph","checkout",t,{line:e+1,unit:"normalized"});let i=el(r[2]);if(!u.has(i))throw new ee(`Trying to checkout branch '${i}' before it is created.`,e+1);S=i,y("gitgraph")&&x("gitgraph","setCurrentBranch",i,{line:e+1,unit:"normalized"}),k.push({kind:"checkout",branch:i,keyword:r[1].toLowerCase()}),y("gitgraph")&&x("gitgraph","appendStatement",k.at(-1),{line:e+1,unit:"normalized"});continue}let o=t.match(en);if(o){y("gitgraph")&&b("gitgraph","merge",t,{line:e+1,unit:"normalized"});let i=el(o[1]),a=B.get(e)??eo(o[2]??"",e+1,["id","tag","type"]);if(i===S)throw new ee(`Cannot merge branch '${i}' into itself.`,e+1);let r=u.get(S),n=u.get(i);if(!n)throw new ee(`Branch to be merged ('${i}') does not exist.`,e+1);if(!r.head)throw new ee(`Current branch '${S}' has no commits.`,e+1);if(!n.head)throw new ee(`Branch to be merged ('${i}') has no commits.`,e+1);if(n.head===r.head)throw new ee("Cannot merge branches with the same head commit.",e+1);let l=F(a,"merge",e+1,{mergeBranch:i,message:`merged branch ${i} into ${S}`,...a.type?{customType:a.type}:{}},[r.head,n.head]);k.push({kind:"merge",ref:l.id,branch:i}),y("gitgraph")&&x("gitgraph","appendStatement",k.at(-1),{line:e+1,unit:"normalized"});continue}let l=t.match(/^cherry-pick\s+(.+)$/is);if(l){y("gitgraph")&&b("gitgraph","cherry-pick",t,{line:e+1,unit:"normalized"});let i=eo(l[1],e+1,["id","tag","parent"]);if(!i.id)throw new ee('cherry-pick requires id:"existing commit".',e+1);let a=M.get(i.id);if(!a)throw new ee(`Cherry-pick source commit '${i.id}' does not exist.`,e+1);let r=u.get(S);if(!r.head)throw new ee(`Current branch '${S}' has no commits.`,e+1);if(function(e,t,i){let a=[e],r=new Set;for(;a.length>0;){let e=a.pop();if(e===t)return!0;if(r.has(e))continue;r.add(e);let n=i.get(e);n&&a.push(..."cherry-pick"===n.source?n.parents.slice(0,1):n.parents)}return!1}(r.head,a.id,w))throw new ee(`Cherry-pick source '${a.id}' is already reachable from current branch '${S}'.`,e+1);let n=i.parent?M.get(i.parent)?.id:void 0;if(2===a.parents.length){if(!i.parent)throw new ee(`Cherry-picking merge commit '${a.id}' requires parent:"immediate parent".`,e+1);if(!n||!a.parents.includes(n))throw new ee(`Cherry-pick parent '${i.parent}' is not an immediate parent of '${a.id}'.`,e+1)}let o=0===i.tags.length?`cherry-pick:${a.sourceId??a.id}${i.parent?`|parent:${i.parent}`:""}`:void 0,s=F({tags:o?[o]:i.tags},"cherry-pick",e+1,{message:`cherry-picked ${U(a)} into ${S}`,cherrySource:a.id,...n?{cherryParent:n}:{},...o?{syntheticCherryTag:o}:{}},[r.head,a.id]);k.push({kind:"cherry-pick",ref:s.id,source:a.id,...n?{parent:n}:{}}),y("gitgraph")&&x("gitgraph","appendStatement",k.at(-1),{line:e+1,unit:"normalized"});continue}throw y("gitgraph")&&b("gitgraph","invalid",t,{line:e+1,unit:"normalized"}),new ee(`Unsupported gitGraph statement on line ${e+1}: ${t}`,e+1)}return{direction:h,mainBranchName:d,...g?{title:g}:{},commits:f,branches:[...u.values()],statements:k,...C?{accessibilityTitle:C}:{},...R?{accessibilityDescription:R}:{}}}(e.source.familyBody,{mainBranchName:r.mainBranchName,mainBranchOrder:r.mainBranchOrder,title:i?.title}),e.source.accessibility),r,e.renderOptions,e.styleFace),{injectAccessibility:!1})},projectPositioned:p(function({positioned:e}){return{version:1,nodes:e.commits.map(t=>{let i=t.customType??t.type,a=t.labelBlock,r=a&&e.showCommitLabel?d(a,"LR"===e.direction?t.x:t.x+14,t.y+V(a,e.direction)-.35*a.fontSize,"LR"===e.direction?"middle":"start"):void 0;if(r&&"LR"===e.direction&&e.rotateCommitLabel&&a){let i=R({x0:r.x,y0:r.y,x1:r.x+r.w,y1:r.y+r.h},{x:t.x,y:t.y+V(a,e.direction)},45);r=c({x:i.x0,y:i.y0,width:i.x1-i.x0,height:i.y1-i.y0})}return{id:t.id,x:m(t.x-10),y:m(t.y-10),w:m(20),h:m(20),shape:"CHERRY_PICK"===i?"diamond":"HIGHLIGHT"===i?"rectangle":"ellipse",label:t.message||t.id,labelVisibility:e.showCommitLabel?"visible":"hidden",labelBounds:r,labelContainer:c(s(e))}}),edges:e.edges.map((e,t)=>({id:`edge#${t}:${e.from}->${e.to}`,from:e.from,to:e.to,path:e.points.map(e=>[m(e.x),m(e.y)])})),groups:e.showBranches?e.branches.map(t=>{let i=e.commits.filter(e=>e.branch===t.name),a=Math.min(t.x1,t.x2,...i.map(e=>e.x-10)),r=Math.min(t.y1,t.y2,...i.map(e=>e.y-10)),n=Math.max(t.x1,t.x2,...i.map(e=>e.x+10)),o=Math.max(t.y1,t.y2,...i.map(e=>e.y+10));return{id:`branch:${t.name}`,x:m(a),y:m(r),w:h(a,Math.max(1,n-a)),h:h(r,Math.max(1,o-r)),members:i.map(e=>e.id),label:t.name}}):[],bounds:{w:m(e.width),h:m(e.height)}}}),lowerScene:g(ed)});export{ep as default};
@@ -0,0 +1,6 @@
1
+ import{a as e,b as t}from"./chunk-5B2Z7575.js";import{c as i,e as o}from"./chunk-2SH76OTH.js";import{d as n}from"./chunk-AMJLVPUB.js";import"./chunk-DF6765YX.js";import"./chunk-J35HAQQF.js";import{a as a}from"./chunk-2UIA2IME.js";import{a as s,b as r,c as d}from"./chunk-CN7WTBWB.js";import{C as l,D as h,a as c,b as p,c as m,d as f,g as g,i as b}from"./chunk-HLWUNUCM.js";import{A as u,B as k,M as y,c as x,n as w,o as v,q as _,qa as M,y as S}from"./chunk-X2UYKWKM.js";import{r as W,u as j}from"./chunk-TYZOZXUJ.js";import{f as z,h as C,l as F,n as L,o as P}from"./chunk-NO7ZIVRU.js";import{Z as U}from"./chunk-Z3FDIVLN.js";import{P as E}from"./chunk-N5ELX7LR.js";import"./chunk-5UVGUSD6.js";import"./chunk-CSFUKSU6.js";var I=Object.freeze({id:"ishikawa",upstreamId:"ishikawa",maturity:"stable",label:"Ishikawa",headers:["ishikawa","ishikawa-beta"],aliases:[],config:{section:"ishikawa",keys:["diagramPadding","useMaxWidth"],noopKeys:["useMaxWidth"]},identity:{id:"family:ishikawa",kind:"family",version:"1.0.0",compatibility:{core:"0.5.3"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:[],semanticRoles:["prelude","chrome","title","node","label","defs","edge","rail"],scenePrimitiveEvidence:[{role:"prelude",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"title",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"node",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"node",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"label",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"marker",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"edge",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"rail",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]}],example:`ishikawa
2
+ Slow release
3
+ Process
4
+ Manual checks
5
+ Tooling
6
+ Slow builds`,detect:E,detectLoose:E}),B=W("ishikawa-arrow",{width:8,height:8},"end",{fill:"var(--_line)"},"userSpaceOnUse"),O=x(function(e,{positioned:t,colors:i,resolved:o}){let n=C(o.renderOptions,z,o.styleFace),s=M(i),r=n.edgeStrokeColor?{...B,paint:{...B.paint,fill:n.edgeStrokeColor}}:B,d=[];d.push(e.definitions({id:"defs",markerResources:[r]},`<defs>${j([r])}</defs>`)),t.title&&d.push(e.text(P(t.title,n)));let l=t.nodes.find(e=>0===e.depth);for(let i of(t.spine.length&&d.push(e.connector({id:"spine",role:"rail",geometry:{kind:"polyline",points:t.spine},lineStyle:"solid",paint:{stroke:n.edgeStrokeColor??"var(--_line)",strokeWidth:String(n.lineWidth)},...l?{endpoints:{to:l.node.id,end:{owner:{id:l.node.id,role:"node"},point:t.spine.at(-1)}}}:{},relationship:{kind:"effect-spine",direction:"forward"},markers:{end:r}})),t.branches))d.push(e.connector({id:i.id,role:"edge",geometry:{kind:"polyline",points:i.points},lineStyle:"solid",paint:{stroke:n.edgeStrokeColor??"var(--_line)",strokeWidth:String(n.lineWidth)},endpoints:{from:i.from,to:i.to},relationship:{kind:"cause",direction:"forward"}}));for(let i of t.nodes){let t={id:i.node.id,role:"node"},o=[],a=n.nodeFillColor??"var(--_node-fill)",r=n.nodeTextColor??(i.depth<=1?s("var(--_text)",a):"var(--_text)");i.depth<=1&&o.push(e.shape({id:`box:${i.node.id}`,role:"node",identity:!1,owner:t,geometry:{kind:"rect",x:i.x,y:i.y,width:i.width,height:i.height,rx:n.cornerRadius??(0===i.depth?8:3)},paint:{fill:n.nodeFillColor??"var(--_node-fill)",stroke:n.nodeBorderColor??"var(--_node-stroke)",strokeWidth:String(n.nodeLineWidth)}})),o.push(e.text({id:`label:${i.node.id}`,role:"label",owner:t,text:i.block.text,block:i.block,x:i.x+i.width/2,y:i.y+i.height/2,fontSize:i.block.fontSize,fontWeight:i.block.fontWeight,anchor:"middle",paint:{fill:r}})),d.push(e.group({id:i.node.id,role:"node",open:"<g>",close:"</g>",children:o.map(e=>({node:e,indent:2}))}))}return a(e,"ishikawa",t,i,o.renderOptions.transparent??!1,d)}),T=f(I,{configDiagnostics:e=>n("ishikawa",e,{diagramPadding:i,useMaxWidth:o}),layout:i=>{let o=i.source.config.ishikawa;return m(function(i,o={},n,a,s=24){t(i.nodes);let r=C(o,z,n),d=n?.node?.paddingX??12,l=n?.node?.paddingY??8,h=n?.node?.paddingX??16,c=n?.node?.paddingY??12,p=e(i.nodes),m=(e,t=!1)=>U(e,{fontSize:r.nodeLabelFontSize,fontWeight:t&&n?.node?.fontWeight===void 0&&n?.text?.fontWeight===void 0?Math.max(600,r.nodeLabelFontWeight):r.nodeLabelFontWeight,letterSpacing:r.nodeLetterSpacing,transform:r.nodeTextTransform,maxWidth:220}),f=F(a,r),g=i.nodes[0];if(!g)return{width:Math.max(100,(f?.width??0)+2*s),height:80+(f?.height??0),body:i,nodes:[],branches:[],spine:[],options:o,...f?{title:L(f,Math.max(100,f.width+2*s),s)}:{}};let b=(p.get(g.id)??[]).map((e,t)=>((e,t)=>{let i=m(e.label,!0),o=[],n=[],a=[],s=(e,i,o)=>{for(let n=e.length-1;n>=0;n--)a.push({node:e[t?e.length-1-n:n],depth:i,parent:o,slot:n,bone:-1})};for(s(p.get(e.id)??[],2,-1);a.length;){let e=a.pop();if(-1!==e.bone){n.push(e.bone);continue}let t=o.length,i=p.get(e.node.id)??[];o.push({node:e.node,block:m(e.node.label),depth:e.depth,parent:e.parent,slot:e.slot,kids:i.length,rise:0,at:0,textEnd:0}),e.depth%2==0?n.push(t):a.push({...e,bone:t}),s(i,e.depth+1,t)}let r=16;for(let e of n){let t=o[e].block.height+14;o[e].rise=r+t/2,r+=t}let h=(i.width+2*d)/2;for(let e of o){let t=e.parent<0?void 0:o[e.parent];e.depth%2==0?(e.at=t?.at??0,e.textEnd=e.at-(e.kids?(e.kids+1)*24:20)-6):(e.at=t.at-(t.kids-e.slot)*24,e.textEnd=e.at-6),h=Math.max(h,e.block.width-e.textEnd)}return{node:e,block:i,width:i.width+2*d,height:i.height+2*l,bones:o,rise:Math.max(64,r+12),reach:h}})(e,t%2==0)),u=m(g.label,!0),k=u.width+2*h,y=Math.max(52,u.height+2*c),x=[{node:g,block:u,x:0,y:-y/2,width:k,height:y,depth:0}],w=[],v=-40,_=k,M=-y/2,S=y/2,W=-40,j=[];for(let e=0;e<b.length;e+=2){if(e>0){let t=0;for(let i=0;i<2;i++){let o=b[e-2+i],n=b[e+i];o&&(t=Math.max(t,o.reach+(n?.width??0)/2+Math.abs((n?.rise??0)-o.rise)/2))}W-=t+32}j.push(W,W)}let P=(e,t,i,o,n,a,s)=>{x.push({node:e,block:t,x:i,y:o,width:n,height:a,depth:s}),v=Math.min(v,i),_=Math.max(_,i+n),M=Math.min(M,o),S=Math.max(S,o+a)};b.forEach((e,t)=>{let i=t%2==0?-1:1,o=j[t],n=(e,t)=>o+e-t/2,a=n(0,e.rise),s=i*e.rise;for(let t of(P(e.node,e.block,a-e.width/2,s+(i<0?-e.height:0),e.width,e.height,1),w.push({id:`branch:${e.node.id}`,from:e.node.id,to:g.id,points:[{x:a,y:s},{x:o,y:0}]}),e.bones)){let o=i*t.rise,a=n(t.textEnd,t.rise);P(t.node,t.block,a-t.block.width,o-t.block.height/2,t.block.width,t.block.height,t.depth);let s=t.depth%2==0?[{x:a+6,y:o},{x:n(t.at,t.rise),y:o}]:[{x:n(t.at,t.rise),y:o},{x:n(t.at,e.bones[t.parent].rise),y:i*e.bones[t.parent].rise}];w.push({id:`branch:${t.node.id}`,from:t.node.id,to:t.node.parentId,points:s})}});let E=Math.min(v-28,W-28),I=Math.max(_-(v=Math.min(v,E)),f?.width??0),B=Math.ceil(I+2*s),O=Math.ceil(S-M+(f?.height??0)+2*s),T=s-v+(I-(_-v))/2,$=s-M+(f?.height??0);for(let e of x)e.x+=T,e.y+=$;for(let e of w)for(let t of e.points)t.x+=T,t.y+=$;return{width:B,height:O,body:i,nodes:x,branches:w,spine:[{x:E+T,y:$},{x:T,y:$}],options:o,...f?{title:L(f,B,s)}:{}}}(function(e){let t,i=S("string"==typeof e?e.split(/\r?\n/):e);u(i);let o=i.familyLines,n=o.findIndex(e=>e.trim()&&!e.trim().startsWith("%%"));if(t=o[n]??"",!/^ishikawa(?:-beta)?\s*(?:%%.*)?$/i.test(t.trim()))throw Error("Ishikawa source must start with ishikawa");let a={kind:"ishikawa",nodes:[],...k(_(i.accessibility))},s=[],r;for(let e=n+1;e<o.length;e++){let t=o[e],i=t.trim();if(!i||i.startsWith("%%"))continue;let n=v(w(i));g("ishikawa","node",t,{line:e+1,unit:"normalized"}),y("nodes",a.nodes.length+1);let d=t.match(/^[\t ]*/)?.[0].length??0;if(0===a.nodes.length){let e={id:"effect",label:n};a.nodes.push(e),b("ishikawa","add-node",e),s.push({level:0,node:e});continue}r??=d;let l=Math.max(1,d-r+1);for(;s.length>1&&s.at(-1).level>=l;)s.pop();y("nesting",s.length);let h={id:`cause-${a.nodes.length}`,label:n,parentId:s.at(-1).node.id};a.nodes.push(h),s.push({level:l,node:h}),b("ishikawa","add-node",h)}return a}(i.source.authoredFamilyBody??i.source.familyBody),i.renderOptions,i.styleFace,"string"==typeof i.source.frontmatter.title?i.source.frontmatter.title:void 0,"number"==typeof o?.diagramPadding&&Number.isFinite(o.diagramPadding)&&o.diagramPadding>=0?o.diagramPadding:void 0))},projectPositioned:c(function({positioned:e}){return{version:1,bounds:{w:d(e.width),h:d(e.height)},nodes:e.nodes.map(e=>({id:e.node.id,x:d(e.x),y:d(e.y),w:d(e.width),h:d(e.height),shape:"rectangle",label:e.node.label,role:e.depth<=1?"box":"labelled-mark",...h(e.block,e.x+e.width/2,e.y+e.height/2,e)})),edges:e.branches.map(e=>({id:e.id,from:e.from,to:e.to,path:e.points.map(e=>[d(e.x),d(e.y)])})),groups:[],labels:e.title?[{id:"title",text:e.title.text,bounds:l(e.title.block,e.title.x,e.title.y),container:r(s(e))}]:[]}}),lowerScene:p(O)});export{T as default};