@legionworks/facet 1.9.0

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 (327) hide show
  1. package/LICENSE-APACHE +202 -0
  2. package/LICENSE-MIT +23 -0
  3. package/README.md +158 -0
  4. package/dist/gallery/chunk-4g8rem85.css +656 -0
  5. package/dist/gallery/chunk-c6s9k9ty.js +5970 -0
  6. package/dist/gallery/frame/artifact.css +8424 -0
  7. package/dist/gallery/frame/chunks/abnfDiagram-N423BO3Z-jj74szbm.js +155 -0
  8. package/dist/gallery/frame/chunks/architecture-TIHT7OUA-cvdjn7dt.js +10 -0
  9. package/dist/gallery/frame/chunks/architectureDiagram-T3A2C74G-n4z77eg6.js +8675 -0
  10. package/dist/gallery/frame/chunks/blockDiagram-VBNYF7ZC-7xsqzrd1.js +3529 -0
  11. package/dist/gallery/frame/chunks/c4Diagram-5PPSVZJV-z2zjs7wx.js +2413 -0
  12. package/dist/gallery/frame/chunks/classDiagram-JCYQIIEL-ve8rngqp.js +47 -0
  13. package/dist/gallery/frame/chunks/classDiagram-v2-OCEON4UE-8cfaxb8z.js +47 -0
  14. package/dist/gallery/frame/chunks/cose-bilkent-JH36ORCC-sn92qexx.js +4822 -0
  15. package/dist/gallery/frame/chunks/cynefin-VYW2F7L2-tqjv913d.js +10 -0
  16. package/dist/gallery/frame/chunks/cynefinDiagram-MW4NZA55-c1c0dj12.js +500 -0
  17. package/dist/gallery/frame/chunks/dagre-VZM6K2ZE-7tyg4yt2.js +476 -0
  18. package/dist/gallery/frame/chunks/diagram-7IWD3JNH-y4eng9sc.js +526 -0
  19. package/dist/gallery/frame/chunks/diagram-B4RE2ZJO-rn3p7j5h.js +673 -0
  20. package/dist/gallery/frame/chunks/diagram-LBJQPF4R-w4a2cm9q.js +255 -0
  21. package/dist/gallery/frame/chunks/diagram-Q27KOJAE-aqc2v7wy.js +575 -0
  22. package/dist/gallery/frame/chunks/diagram-UB23O5K3-xncy8nyd.js +355 -0
  23. package/dist/gallery/frame/chunks/ebnfDiagram-BXEA7PRR-acwgxz16.js +175 -0
  24. package/dist/gallery/frame/chunks/erDiagram-JOGREHBK-mzp5nswt.js +1332 -0
  25. package/dist/gallery/frame/chunks/eventmodeling-45OFAUF4-sg07qr0c.js +10 -0
  26. package/dist/gallery/frame/chunks/flowDiagram-UKHOOZJN-2e5ygs44.js +29 -0
  27. package/dist/gallery/frame/chunks/ganttDiagram-PKOTCBZU-p2hhh7hr.js +2620 -0
  28. package/dist/gallery/frame/chunks/gitGraph-TEB2WS4Q-j6kw0naa.js +10 -0
  29. package/dist/gallery/frame/chunks/gitGraphDiagram-DS77QQ5N-4z9z8wjm.js +1347 -0
  30. package/dist/gallery/frame/chunks/info-DKCQHKI2-mpt80jd3.js +10 -0
  31. package/dist/gallery/frame/chunks/infoDiagram-6WML65LV-5rqm3mgg.js +65 -0
  32. package/dist/gallery/frame/chunks/ishikawaDiagram-WSZJBQD7-b51z96jy.js +975 -0
  33. package/dist/gallery/frame/chunks/journeyDiagram-NVQOT4AX-9jbfp0pk.js +1272 -0
  34. package/dist/gallery/frame/chunks/kanban-definition-27J2QSJJ-4x0vx4se.js +1116 -0
  35. package/dist/gallery/frame/chunks/katex-xfgk95tv.js +14034 -0
  36. package/dist/gallery/frame/chunks/markdown-1s5vwkf2.js +9 -0
  37. package/dist/gallery/frame/chunks/markdown-2h6bwsms.js +3239 -0
  38. package/dist/gallery/frame/chunks/markdown-2x113yh8.js +107 -0
  39. package/dist/gallery/frame/chunks/markdown-30b7rwmp.js +1943 -0
  40. package/dist/gallery/frame/chunks/markdown-356bfj4g.js +2031 -0
  41. package/dist/gallery/frame/chunks/markdown-44n9ea69.js +2406 -0
  42. package/dist/gallery/frame/chunks/markdown-56enrf2r.js +39 -0
  43. package/dist/gallery/frame/chunks/markdown-5avymm8t.js +725 -0
  44. package/dist/gallery/frame/chunks/markdown-6r4svars.js +33 -0
  45. package/dist/gallery/frame/chunks/markdown-6zz8efx2.js +24 -0
  46. package/dist/gallery/frame/chunks/markdown-7jp6prnb.js +19 -0
  47. package/dist/gallery/frame/chunks/markdown-809k7q41.js +55 -0
  48. package/dist/gallery/frame/chunks/markdown-82xmzhzd.js +1076 -0
  49. package/dist/gallery/frame/chunks/markdown-92n37gd4.js +7627 -0
  50. package/dist/gallery/frame/chunks/markdown-ag2sssf8.js +36 -0
  51. package/dist/gallery/frame/chunks/markdown-b4s7ntq2.js +19 -0
  52. package/dist/gallery/frame/chunks/markdown-c9k0fvp1.js +100 -0
  53. package/dist/gallery/frame/chunks/markdown-ceefymn8.js +125 -0
  54. package/dist/gallery/frame/chunks/markdown-d1wfbs70.js +243 -0
  55. package/dist/gallery/frame/chunks/markdown-dy5sgjhc.js +11022 -0
  56. package/dist/gallery/frame/chunks/markdown-dz3z5w30.js +30868 -0
  57. package/dist/gallery/frame/chunks/markdown-eg6ngz7y.js +30340 -0
  58. package/dist/gallery/frame/chunks/markdown-ff5wvb43.js +1149 -0
  59. package/dist/gallery/frame/chunks/markdown-ffg06nfz.js +86 -0
  60. package/dist/gallery/frame/chunks/markdown-fvfncadf.js +472 -0
  61. package/dist/gallery/frame/chunks/markdown-gvyszqpv.js +19 -0
  62. package/dist/gallery/frame/chunks/markdown-gx1p0ew0.js +88 -0
  63. package/dist/gallery/frame/chunks/markdown-gxye5frz.js +65 -0
  64. package/dist/gallery/frame/chunks/markdown-h7pzv34e.js +105 -0
  65. package/dist/gallery/frame/chunks/markdown-hab789t9.js +47 -0
  66. package/dist/gallery/frame/chunks/markdown-hjp6sj8t.js +125 -0
  67. package/dist/gallery/frame/chunks/markdown-jka64qgp.js +1993 -0
  68. package/dist/gallery/frame/chunks/markdown-k8xkn8mw.js +56 -0
  69. package/dist/gallery/frame/chunks/markdown-m7frq8x8.js +112 -0
  70. package/dist/gallery/frame/chunks/markdown-p740v4qm.js +36 -0
  71. package/dist/gallery/frame/chunks/markdown-pxfeh231.js +57 -0
  72. package/dist/gallery/frame/chunks/markdown-pzgd8z3s.js +87 -0
  73. package/dist/gallery/frame/chunks/markdown-qx3cngz2.js +1673 -0
  74. package/dist/gallery/frame/chunks/markdown-rawhfvvc.js +85 -0
  75. package/dist/gallery/frame/chunks/markdown-rd8w0ng9.js +49 -0
  76. package/dist/gallery/frame/chunks/markdown-rm2yxfjj.js +2773 -0
  77. package/dist/gallery/frame/chunks/markdown-s1jatrnk.js +993 -0
  78. package/dist/gallery/frame/chunks/markdown-sgfg5vvq.js +59 -0
  79. package/dist/gallery/frame/chunks/markdown-t4ethv9d.js +409 -0
  80. package/dist/gallery/frame/chunks/markdown-tnmabqvz.js +36 -0
  81. package/dist/gallery/frame/chunks/markdown-tvdpppw8.js +5292 -0
  82. package/dist/gallery/frame/chunks/markdown-v0x27twr.js +22 -0
  83. package/dist/gallery/frame/chunks/markdown-v14td68x.js +36 -0
  84. package/dist/gallery/frame/chunks/markdown-w6sgd54z.js +36 -0
  85. package/dist/gallery/frame/chunks/markdown-xw8dsk8b.js +2125 -0
  86. package/dist/gallery/frame/chunks/markdown-y18mve73.js +85 -0
  87. package/dist/gallery/frame/chunks/markdown-yengsms5.js +427 -0
  88. package/dist/gallery/frame/chunks/markdown-z1wc0v0d.js +1826 -0
  89. package/dist/gallery/frame/chunks/markdown-zazx9h4n.js +329 -0
  90. package/dist/gallery/frame/chunks/mermaid-de7p4v0x.js +30 -0
  91. package/dist/gallery/frame/chunks/mindmap-definition-FAOFIHXS-ra44cbem.js +1216 -0
  92. package/dist/gallery/frame/chunks/packet-7NZHBO7P-xppm5913.js +10 -0
  93. package/dist/gallery/frame/chunks/pegDiagram-VL7TDLO6-a2a4wg03.js +163 -0
  94. package/dist/gallery/frame/chunks/pie-RZYD4A2V-hnbxk152.js +10 -0
  95. package/dist/gallery/frame/chunks/pieDiagram-7S7Q4E2Y-f1vxjtmx.js +311 -0
  96. package/dist/gallery/frame/chunks/quadrantDiagram-CIZ2JOQS-ywafa6kh.js +1390 -0
  97. package/dist/gallery/frame/chunks/radar-I7S5WNFK-ewqd27se.js +10 -0
  98. package/dist/gallery/frame/chunks/railroad-3IZDKUUU-5hy4bdx3.js +10 -0
  99. package/dist/gallery/frame/chunks/railroad-abnf-AHOZXSZD-bh5sxz0d.js +10 -0
  100. package/dist/gallery/frame/chunks/railroad-ebnf-EBAXGLYW-6b9c3zeh.js +10 -0
  101. package/dist/gallery/frame/chunks/railroad-peg-LSFZ7HO6-avc8v39s.js +10 -0
  102. package/dist/gallery/frame/chunks/railroadDiagram-AXF67PYL-qc61wax4.js +131 -0
  103. package/dist/gallery/frame/chunks/requirementDiagram-LRYGKXZP-9bs4786c.js +1295 -0
  104. package/dist/gallery/frame/chunks/sankeyDiagram-W5VNT64P-awt1em8b.js +1339 -0
  105. package/dist/gallery/frame/chunks/sequenceDiagram-SI44F4Z6-qaf9mz3t.js +4324 -0
  106. package/dist/gallery/frame/chunks/sizeCapture-X5ZJPWSS-9fq685xd.js +64 -0
  107. package/dist/gallery/frame/chunks/stateDiagram-OKZ733FA-vx7a7hh0.js +456 -0
  108. package/dist/gallery/frame/chunks/stateDiagram-v2-UEYNNEHI-x4m6ws5t.js +46 -0
  109. package/dist/gallery/frame/chunks/swimlanes-SLNWSIFB-e4mxm1gh.js +8287 -0
  110. package/dist/gallery/frame/chunks/swimlanesDiagram-ULZ7WXOC-0h93e2qq.js +42 -0
  111. package/dist/gallery/frame/chunks/timeline-definition-Z64GVDOM-wp0bhbzg.js +1549 -0
  112. package/dist/gallery/frame/chunks/treeView-QDETBFTQ-hcx7n0vt.js +10 -0
  113. package/dist/gallery/frame/chunks/treemap-6X3UGDF4-av02skdw.js +10 -0
  114. package/dist/gallery/frame/chunks/vennDiagram-T6HMQDX7-pmvk1p7n.js +2566 -0
  115. package/dist/gallery/frame/chunks/wardley-OPB4EBWU-njsp6e40.js +10 -0
  116. package/dist/gallery/frame/chunks/wardleyDiagram-T6FBY63Y-eggmnv4z.js +979 -0
  117. package/dist/gallery/frame/chunks/xychartDiagram-ELKLHX3M-q40tnpe5.js +1954 -0
  118. package/dist/gallery/frame/frame.css +183 -0
  119. package/dist/gallery/frame/runtime/chart.js +42744 -0
  120. package/dist/gallery/frame/runtime/html.js +14 -0
  121. package/dist/gallery/frame/runtime/markdown.js +1403 -0
  122. package/dist/gallery/frame/runtime/mermaid.js +32 -0
  123. package/dist/gallery/frame/runtime/svg.js +14 -0
  124. package/dist/gallery/frame/runtime/tsx.js +52 -0
  125. package/dist/gallery/index.html +104 -0
  126. package/docs/reference/cli.md +163 -0
  127. package/docs/reference/export.md +106 -0
  128. package/docs/reference/html.md +215 -0
  129. package/docs/reference/http.md +85 -0
  130. package/docs/reference/mcp.md +78 -0
  131. package/docs/reference/security.md +119 -0
  132. package/docs/reference/storage.md +93 -0
  133. package/docs/reference/tsx.md +101 -0
  134. package/docs/reference/validation.md +212 -0
  135. package/package.json +89 -0
  136. package/scripts/build-gallery.ts +127 -0
  137. package/scripts/launch-netns.sh +67 -0
  138. package/skills/facet/SKILL.md +100 -0
  139. package/src/cli/client.ts +311 -0
  140. package/src/cli/commands/create.ts +49 -0
  141. package/src/cli/commands/doctor.ts +249 -0
  142. package/src/cli/commands/export.ts +179 -0
  143. package/src/cli/commands/instantiate.ts +35 -0
  144. package/src/cli/commands/list.ts +49 -0
  145. package/src/cli/commands/open.ts +75 -0
  146. package/src/cli/commands/pin.ts +39 -0
  147. package/src/cli/commands/promote.ts +49 -0
  148. package/src/cli/commands/publish.ts +122 -0
  149. package/src/cli/commands/read-back.ts +56 -0
  150. package/src/cli/commands/status.ts +114 -0
  151. package/src/cli/commands/watch.ts +146 -0
  152. package/src/cli/main.ts +522 -0
  153. package/src/cli/output.ts +106 -0
  154. package/src/cli/parser.ts +376 -0
  155. package/src/cli/presenter.ts +212 -0
  156. package/src/cli/service-metadata.ts +134 -0
  157. package/src/cli/spawn-service.ts +326 -0
  158. package/src/css.d.ts +4 -0
  159. package/src/gallery-web/app.ts +1581 -0
  160. package/src/gallery-web/export-menu.ts +121 -0
  161. package/src/gallery-web/export.ts +112 -0
  162. package/src/gallery-web/favicon.ts +54 -0
  163. package/src/gallery-web/frame/entries/chart.ts +6 -0
  164. package/src/gallery-web/frame/entries/html.ts +6 -0
  165. package/src/gallery-web/frame/entries/markdown.ts +6 -0
  166. package/src/gallery-web/frame/entries/mermaid.ts +6 -0
  167. package/src/gallery-web/frame/entries/svg.ts +6 -0
  168. package/src/gallery-web/frame/entries/tsx.ts +6 -0
  169. package/src/gallery-web/frame/frame-payload.ts +91 -0
  170. package/src/gallery-web/frame/renderer-validation.ts +13 -0
  171. package/src/gallery-web/frame/renderers/chart.ts +182 -0
  172. package/src/gallery-web/frame/renderers/dompurify-shim.ts +112 -0
  173. package/src/gallery-web/frame/renderers/html.ts +48 -0
  174. package/src/gallery-web/frame/renderers/markdown.ts +81 -0
  175. package/src/gallery-web/frame/renderers/mermaid.ts +120 -0
  176. package/src/gallery-web/frame/renderers/registry.ts +260 -0
  177. package/src/gallery-web/frame/renderers/svg.ts +393 -0
  178. package/src/gallery-web/frame/renderers/tsx.ts +61 -0
  179. package/src/gallery-web/frame/runtime.ts +501 -0
  180. package/src/gallery-web/frame/styles/artifact.css +8424 -0
  181. package/src/gallery-web/frame/styles/frame.css +183 -0
  182. package/src/gallery-web/frame/styles/html-source.css +23 -0
  183. package/src/gallery-web/frame/view-box.ts +33 -0
  184. package/src/gallery-web/frame-html.ts +72 -0
  185. package/src/gallery-web/index.html +104 -0
  186. package/src/gallery-web/session.ts +107 -0
  187. package/src/gallery-web/sse-client.ts +212 -0
  188. package/src/gallery-web/styles/app.css +420 -0
  189. package/src/gallery-web/styles/tokens.css +112 -0
  190. package/src/gallery-web/styles/verdict.css +186 -0
  191. package/src/gallery-web/swap.ts +64 -0
  192. package/src/gallery-web/theme.ts +40 -0
  193. package/src/gallery-web/view-state.ts +93 -0
  194. package/src/harness-adapters/claude-code/README.md +10 -0
  195. package/src/harness-adapters/claude-code/facet.sh +4 -0
  196. package/src/harness-adapters/codex/README.md +10 -0
  197. package/src/harness-adapters/codex/facet.sh +4 -0
  198. package/src/harness-adapters/mcp/README.md +13 -0
  199. package/src/harness-adapters/mcp/cli-bridge.ts +216 -0
  200. package/src/harness-adapters/mcp/main.ts +15 -0
  201. package/src/harness-adapters/mcp/server.ts +164 -0
  202. package/src/harness-adapters/mcp/tool-schemas.ts +53 -0
  203. package/src/harness-adapters/opencode/README.md +10 -0
  204. package/src/harness-adapters/opencode/facet.sh +4 -0
  205. package/src/runtime/compiled-entrypoints.ts +69 -0
  206. package/src/service/dispatcher.ts +717 -0
  207. package/src/service/export.ts +218 -0
  208. package/src/service/http-utils.ts +55 -0
  209. package/src/service/lexical/expectations.ts +210 -0
  210. package/src/service/lifecycle/idle-controller.ts +125 -0
  211. package/src/service/lifecycle/orphan-cleanup.ts +128 -0
  212. package/src/service/lifecycle/process-lock.ts +235 -0
  213. package/src/service/main.ts +136 -0
  214. package/src/service/process.ts +240 -0
  215. package/src/service/router-guards.ts +239 -0
  216. package/src/service/router.ts +627 -0
  217. package/src/service/security/auth.ts +168 -0
  218. package/src/service/security/host-origin.ts +138 -0
  219. package/src/service/security/http-guards.ts +13 -0
  220. package/src/service/security/leases.ts +182 -0
  221. package/src/service/security/token-store.ts +138 -0
  222. package/src/service/server.ts +356 -0
  223. package/src/service/store/database.ts +61 -0
  224. package/src/service/store/evidence-retention.ts +234 -0
  225. package/src/service/store/migrations.ts +167 -0
  226. package/src/service/store/repository-lifecycle.ts +121 -0
  227. package/src/service/store/repository.ts +732 -0
  228. package/src/service/store/schema.ts +218 -0
  229. package/src/service/stored-verdict.ts +97 -0
  230. package/src/service/stream.ts +301 -0
  231. package/src/service/verdict-enrichment.ts +45 -0
  232. package/src/shared/build/frame-bundle-plugins.ts +61 -0
  233. package/src/shared/build-mode.ts +28 -0
  234. package/src/shared/config/evidence-read.ts +98 -0
  235. package/src/shared/config/limits.ts +56 -0
  236. package/src/shared/config/paths.ts +96 -0
  237. package/src/shared/contracts/artifact-types.ts +2 -0
  238. package/src/shared/contracts/artifact.ts +98 -0
  239. package/src/shared/contracts/commands/_shared.ts +59 -0
  240. package/src/shared/contracts/commands/guards.ts +86 -0
  241. package/src/shared/contracts/commands/index.ts +204 -0
  242. package/src/shared/contracts/commands/names.ts +35 -0
  243. package/src/shared/contracts/commands/requests.ts +149 -0
  244. package/src/shared/contracts/commands/results.ts +200 -0
  245. package/src/shared/contracts/envelope.ts +140 -0
  246. package/src/shared/contracts/events.ts +41 -0
  247. package/src/shared/contracts/observed-counts.ts +19 -0
  248. package/src/shared/contracts/renderers.ts +6 -0
  249. package/src/shared/contracts/validation.ts +296 -0
  250. package/src/shared/errors/facet-error.ts +127 -0
  251. package/src/shared/errors/store-error.ts +68 -0
  252. package/src/shared/evidence-image.ts +37 -0
  253. package/src/shared/export.ts +31 -0
  254. package/src/shared/html/policy.ts +108 -0
  255. package/src/shared/html/style-vocabulary.ts +352 -0
  256. package/src/shared/logging/logger.ts +108 -0
  257. package/src/shared/logging/redact.ts +49 -0
  258. package/src/shared/security/frozen-csp.ts +13 -0
  259. package/src/shared/storage-version.ts +2 -0
  260. package/src/shared/tsx/execution.ts +29 -0
  261. package/src/shared/tsx/import-policy.ts +94 -0
  262. package/src/shared/util/dir-permissions.ts +94 -0
  263. package/src/shared/util/mermaid-nodes.ts +230 -0
  264. package/src/shared/util/process.ts +67 -0
  265. package/src/shared/util/time.ts +21 -0
  266. package/src/shared/version.ts +3 -0
  267. package/src/validation/sandbox/limits.ts +41 -0
  268. package/src/validation/sandbox/netns.ts +177 -0
  269. package/src/validation/tier0/chart.ts +177 -0
  270. package/src/validation/tier0/dom-shim.ts +54 -0
  271. package/src/validation/tier0/html.ts +408 -0
  272. package/src/validation/tier0/markdown.ts +285 -0
  273. package/src/validation/tier0/mermaid.ts +98 -0
  274. package/src/validation/tier0/runner.ts +504 -0
  275. package/src/validation/tier0/svg.ts +321 -0
  276. package/src/validation/tier0/tsx/allowlist-resolver.ts +77 -0
  277. package/src/validation/tier0/tsx/ast-policy-capabilities.ts +238 -0
  278. package/src/validation/tier0/tsx/ast-policy-shared.ts +71 -0
  279. package/src/validation/tier0/tsx/ast-policy.ts +181 -0
  280. package/src/validation/tier0/tsx/compiler.ts +156 -0
  281. package/src/validation/tier0/worker-dispatch.ts +211 -0
  282. package/src/validation/tier0/worker-entry.ts +96 -0
  283. package/src/validation/tier0/worker-input.ts +75 -0
  284. package/src/validation/tier1/browser-process.ts +147 -0
  285. package/src/validation/tier1/cdp-pipe.ts +281 -0
  286. package/src/validation/tier1/entries/chart.ts +5 -0
  287. package/src/validation/tier1/entries/html.ts +6 -0
  288. package/src/validation/tier1/entries/markdown.ts +5 -0
  289. package/src/validation/tier1/entries/mermaid.ts +5 -0
  290. package/src/validation/tier1/entries/svg.ts +5 -0
  291. package/src/validation/tier1/entries/tsx.ts +5 -0
  292. package/src/validation/tier1/frame-target.ts +162 -0
  293. package/src/validation/tier1/harness-entry.ts +261 -0
  294. package/src/validation/tier1/harness.ts +215 -0
  295. package/src/validation/tier1/isolated-probe.ts +94 -0
  296. package/src/validation/tier1/launcher.ts +177 -0
  297. package/src/validation/tier1/limits.ts +80 -0
  298. package/src/validation/tier1/nonce.ts +17 -0
  299. package/src/validation/tier1/protocol-probe.ts +519 -0
  300. package/src/validation/tier1/runner.ts +1122 -0
  301. package/src/validation/tier1/verdict.ts +246 -0
  302. package/src/validation/tier1/webp.ts +69 -0
  303. package/templates/README.md +88 -0
  304. package/templates/bar-compare.vl.json +63 -0
  305. package/templates/capacity-report.tsx +102 -0
  306. package/templates/decision-record.md +24 -0
  307. package/templates/deployment-state.mmd +40 -0
  308. package/templates/exemplar.md +91 -0
  309. package/templates/facet-story.tsx +799 -0
  310. package/templates/fleet-dashboard.html +141 -0
  311. package/templates/html-release-ledger.html +91 -0
  312. package/templates/html-status-report.html +114 -0
  313. package/templates/incident-console.tsx +147 -0
  314. package/templates/legion-boundaries.mmd +23 -0
  315. package/templates/legion-flow.mmd +15 -0
  316. package/templates/legion-sequence.mmd +14 -0
  317. package/templates/legion-state.mmd +7 -0
  318. package/templates/metric-card.svg +29 -0
  319. package/templates/observability-map.svg +101 -0
  320. package/templates/pipeline-audit.md +108 -0
  321. package/templates/release-metrics.vl.json +98 -0
  322. package/templates/service-topology.mmd +47 -0
  323. package/templates/status-report.md +32 -0
  324. package/templates/system-map.svg +53 -0
  325. package/templates/timeseries.vl.json +71 -0
  326. package/templates/tsx-interactive-counter.tsx +19 -0
  327. package/templates/tsx-status-report.tsx +31 -0
@@ -0,0 +1,1943 @@
1
+ import {
2
+ createTooltip
3
+ } from "./markdown-hjp6sj8t.js";
4
+ import {
5
+ getDiagramElement
6
+ } from "./markdown-gvyszqpv.js";
7
+ import {
8
+ setupViewPortForSVG
9
+ } from "./markdown-6r4svars.js";
10
+ import {
11
+ render
12
+ } from "./markdown-h7pzv34e.js";
13
+ import {
14
+ generateId,
15
+ utils_default
16
+ } from "./markdown-ff5wvb43.js";
17
+ import {
18
+ clear,
19
+ common_default,
20
+ dompurify_shim_default,
21
+ getAccDescription,
22
+ getAccTitle,
23
+ getConfig2,
24
+ getDiagramTitle,
25
+ setAccDescription,
26
+ setAccTitle,
27
+ setDiagramTitle
28
+ } from "./markdown-92n37gd4.js";
29
+ import {
30
+ log,
31
+ select_default
32
+ } from "./markdown-xw8dsk8b.js";
33
+ import {
34
+ __name
35
+ } from "./markdown-1s5vwkf2.js";
36
+
37
+ // node_modules/mermaid/dist/chunks/mermaid.core/chunk-5RXB4S5H.mjs
38
+ var parser = function() {
39
+ var o = /* @__PURE__ */ __name(function(k, v, o2, l) {
40
+ for (o2 = o2 || {}, l = k.length;l--; o2[k[l]] = v)
41
+ ;
42
+ return o2;
43
+ }, "o"), $V0 = [1, 2], $V1 = [1, 3], $V2 = [1, 4], $V3 = [2, 4], $V4 = [1, 9], $V5 = [1, 11], $V6 = [1, 16], $V7 = [1, 17], $V8 = [1, 18], $V9 = [1, 19], $Va = [1, 33], $Vb = [1, 20], $Vc = [1, 21], $Vd = [1, 22], $Ve = [1, 23], $Vf = [1, 24], $Vg = [1, 26], $Vh = [1, 27], $Vi = [1, 28], $Vj = [1, 29], $Vk = [1, 30], $Vl = [1, 31], $Vm = [1, 32], $Vn = [1, 35], $Vo = [1, 36], $Vp = [1, 37], $Vq = [1, 38], $Vr = [1, 34], $Vs = [1, 4, 5, 16, 17, 19, 21, 22, 24, 25, 26, 27, 28, 29, 33, 35, 37, 38, 41, 45, 48, 51, 52, 53, 54, 57], $Vt = [1, 4, 5, 14, 15, 16, 17, 19, 21, 22, 24, 25, 26, 27, 28, 29, 33, 35, 37, 38, 39, 40, 41, 45, 48, 51, 52, 53, 54, 57], $Vu = [4, 5, 16, 17, 19, 21, 22, 24, 25, 26, 27, 28, 29, 33, 35, 37, 38, 41, 45, 48, 51, 52, 53, 54, 57];
44
+ var parser2 = {
45
+ trace: /* @__PURE__ */ __name(function trace() {}, "trace"),
46
+ yy: {},
47
+ symbols_: { error: 2, start: 3, SPACE: 4, NL: 5, SD: 6, document: 7, line: 8, statement: 9, classDefStatement: 10, styleStatement: 11, cssClassStatement: 12, idStatement: 13, DESCR: 14, "-->": 15, HIDE_EMPTY: 16, scale: 17, WIDTH: 18, COMPOSIT_STATE: 19, STRUCT_START: 20, STRUCT_STOP: 21, STATE_DESCR: 22, AS: 23, ID: 24, FORK: 25, JOIN: 26, CHOICE: 27, CONCURRENT: 28, note: 29, notePosition: 30, NOTE_TEXT: 31, direction: 32, acc_title: 33, acc_title_value: 34, acc_descr: 35, acc_descr_value: 36, acc_descr_multiline_value: 37, CLICK: 38, STRING: 39, HREF: 40, classDef: 41, CLASSDEF_ID: 42, CLASSDEF_STYLEOPTS: 43, DEFAULT: 44, style: 45, STYLE_IDS: 46, STYLEDEF_STYLEOPTS: 47, class: 48, CLASSENTITY_IDS: 49, STYLECLASS: 50, direction_tb: 51, direction_bt: 52, direction_rl: 53, direction_lr: 54, eol: 55, ";": 56, EDGE_STATE: 57, STYLE_SEPARATOR: 58, left_of: 59, right_of: 60, $accept: 0, $end: 1 },
48
+ terminals_: { 2: "error", 4: "SPACE", 5: "NL", 6: "SD", 14: "DESCR", 15: "-->", 16: "HIDE_EMPTY", 17: "scale", 18: "WIDTH", 19: "COMPOSIT_STATE", 20: "STRUCT_START", 21: "STRUCT_STOP", 22: "STATE_DESCR", 23: "AS", 24: "ID", 25: "FORK", 26: "JOIN", 27: "CHOICE", 28: "CONCURRENT", 29: "note", 31: "NOTE_TEXT", 33: "acc_title", 34: "acc_title_value", 35: "acc_descr", 36: "acc_descr_value", 37: "acc_descr_multiline_value", 38: "CLICK", 39: "STRING", 40: "HREF", 41: "classDef", 42: "CLASSDEF_ID", 43: "CLASSDEF_STYLEOPTS", 44: "DEFAULT", 45: "style", 46: "STYLE_IDS", 47: "STYLEDEF_STYLEOPTS", 48: "class", 49: "CLASSENTITY_IDS", 50: "STYLECLASS", 51: "direction_tb", 52: "direction_bt", 53: "direction_rl", 54: "direction_lr", 56: ";", 57: "EDGE_STATE", 58: "STYLE_SEPARATOR", 59: "left_of", 60: "right_of" },
49
+ productions_: [0, [3, 2], [3, 2], [3, 2], [7, 0], [7, 2], [8, 2], [8, 1], [8, 1], [9, 1], [9, 1], [9, 1], [9, 1], [9, 2], [9, 3], [9, 4], [9, 1], [9, 2], [9, 1], [9, 4], [9, 3], [9, 6], [9, 1], [9, 1], [9, 1], [9, 1], [9, 4], [9, 4], [9, 1], [9, 2], [9, 2], [9, 1], [9, 5], [9, 5], [10, 3], [10, 3], [11, 3], [12, 3], [32, 1], [32, 1], [32, 1], [32, 1], [55, 1], [55, 1], [13, 1], [13, 1], [13, 3], [13, 3], [30, 1], [30, 1]],
50
+ performAction: /* @__PURE__ */ __name(function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
51
+ var $0 = $$.length - 1;
52
+ switch (yystate) {
53
+ case 3:
54
+ yy.setRootDoc($$[$0]);
55
+ return $$[$0];
56
+ break;
57
+ case 4:
58
+ this.$ = [];
59
+ break;
60
+ case 5:
61
+ if ($$[$0] != "nl") {
62
+ $$[$0 - 1].push($$[$0]);
63
+ this.$ = $$[$0 - 1];
64
+ }
65
+ break;
66
+ case 6:
67
+ case 7:
68
+ this.$ = $$[$0];
69
+ break;
70
+ case 8:
71
+ this.$ = "nl";
72
+ break;
73
+ case 12:
74
+ this.$ = $$[$0];
75
+ break;
76
+ case 13:
77
+ const stateStmt = $$[$0 - 1];
78
+ stateStmt.description = yy.trimColon($$[$0]);
79
+ this.$ = stateStmt;
80
+ break;
81
+ case 14:
82
+ this.$ = { stmt: "relation", state1: $$[$0 - 2], state2: $$[$0] };
83
+ break;
84
+ case 15:
85
+ const relDescription = yy.trimColon($$[$0]);
86
+ this.$ = { stmt: "relation", state1: $$[$0 - 3], state2: $$[$0 - 1], description: relDescription };
87
+ break;
88
+ case 19:
89
+ this.$ = { stmt: "state", id: $$[$0 - 3], type: "default", description: "", doc: $$[$0 - 1] };
90
+ break;
91
+ case 20:
92
+ var id = $$[$0];
93
+ var description = $$[$0 - 2].trim();
94
+ if ($$[$0].match(":")) {
95
+ var parts = $$[$0].split(":");
96
+ id = parts[0];
97
+ description = [description, parts[1]];
98
+ }
99
+ this.$ = { stmt: "state", id, type: "default", description };
100
+ break;
101
+ case 21:
102
+ this.$ = { stmt: "state", id: $$[$0 - 3], type: "default", description: $$[$0 - 5], doc: $$[$0 - 1] };
103
+ break;
104
+ case 22:
105
+ this.$ = { stmt: "state", id: $$[$0], type: "fork" };
106
+ break;
107
+ case 23:
108
+ this.$ = { stmt: "state", id: $$[$0], type: "join" };
109
+ break;
110
+ case 24:
111
+ this.$ = { stmt: "state", id: $$[$0], type: "choice" };
112
+ break;
113
+ case 25:
114
+ this.$ = { stmt: "state", id: yy.getDividerId(), type: "divider" };
115
+ break;
116
+ case 26:
117
+ this.$ = { stmt: "state", id: $$[$0 - 1].trim(), note: { position: $$[$0 - 2].trim(), text: $$[$0].trim() } };
118
+ break;
119
+ case 29:
120
+ this.$ = $$[$0].trim();
121
+ yy.setAccTitle(this.$);
122
+ break;
123
+ case 30:
124
+ case 31:
125
+ this.$ = $$[$0].trim();
126
+ yy.setAccDescription(this.$);
127
+ break;
128
+ case 32:
129
+ this.$ = {
130
+ stmt: "click",
131
+ id: $$[$0 - 3],
132
+ url: $$[$0 - 2],
133
+ tooltip: $$[$0 - 1]
134
+ };
135
+ break;
136
+ case 33:
137
+ this.$ = {
138
+ stmt: "click",
139
+ id: $$[$0 - 3],
140
+ url: $$[$0 - 1],
141
+ tooltip: ""
142
+ };
143
+ break;
144
+ case 34:
145
+ case 35:
146
+ this.$ = { stmt: "classDef", id: $$[$0 - 1].trim(), classes: $$[$0].trim() };
147
+ break;
148
+ case 36:
149
+ this.$ = { stmt: "style", id: $$[$0 - 1].trim(), styleClass: $$[$0].trim() };
150
+ break;
151
+ case 37:
152
+ this.$ = { stmt: "applyClass", id: $$[$0 - 1].trim(), styleClass: $$[$0].trim() };
153
+ break;
154
+ case 38:
155
+ yy.setDirection("TB");
156
+ this.$ = { stmt: "dir", value: "TB" };
157
+ break;
158
+ case 39:
159
+ yy.setDirection("BT");
160
+ this.$ = { stmt: "dir", value: "BT" };
161
+ break;
162
+ case 40:
163
+ yy.setDirection("RL");
164
+ this.$ = { stmt: "dir", value: "RL" };
165
+ break;
166
+ case 41:
167
+ yy.setDirection("LR");
168
+ this.$ = { stmt: "dir", value: "LR" };
169
+ break;
170
+ case 44:
171
+ case 45:
172
+ this.$ = { stmt: "state", id: $$[$0].trim(), type: "default", description: "" };
173
+ break;
174
+ case 46:
175
+ this.$ = { stmt: "state", id: $$[$0 - 2].trim(), classes: [$$[$0].trim()], type: "default", description: "" };
176
+ break;
177
+ case 47:
178
+ this.$ = { stmt: "state", id: $$[$0 - 2].trim(), classes: [$$[$0].trim()], type: "default", description: "" };
179
+ break;
180
+ }
181
+ }, "anonymous"),
182
+ table: [{ 3: 1, 4: $V0, 5: $V1, 6: $V2 }, { 1: [3] }, { 3: 5, 4: $V0, 5: $V1, 6: $V2 }, { 3: 6, 4: $V0, 5: $V1, 6: $V2 }, o([1, 4, 5, 16, 17, 19, 22, 24, 25, 26, 27, 28, 29, 33, 35, 37, 38, 41, 45, 48, 51, 52, 53, 54, 57], $V3, { 7: 7 }), { 1: [2, 1] }, { 1: [2, 2] }, { 1: [2, 3], 4: $V4, 5: $V5, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 13: 15, 16: $V6, 17: $V7, 19: $V8, 22: $V9, 24: $Va, 25: $Vb, 26: $Vc, 27: $Vd, 28: $Ve, 29: $Vf, 32: 25, 33: $Vg, 35: $Vh, 37: $Vi, 38: $Vj, 41: $Vk, 45: $Vl, 48: $Vm, 51: $Vn, 52: $Vo, 53: $Vp, 54: $Vq, 57: $Vr }, o($Vs, [2, 5]), { 9: 39, 10: 12, 11: 13, 12: 14, 13: 15, 16: $V6, 17: $V7, 19: $V8, 22: $V9, 24: $Va, 25: $Vb, 26: $Vc, 27: $Vd, 28: $Ve, 29: $Vf, 32: 25, 33: $Vg, 35: $Vh, 37: $Vi, 38: $Vj, 41: $Vk, 45: $Vl, 48: $Vm, 51: $Vn, 52: $Vo, 53: $Vp, 54: $Vq, 57: $Vr }, o($Vs, [2, 7]), o($Vs, [2, 8]), o($Vs, [2, 9]), o($Vs, [2, 10]), o($Vs, [2, 11]), o($Vs, [2, 12], { 14: [1, 40], 15: [1, 41] }), o($Vs, [2, 16]), { 18: [1, 42] }, o($Vs, [2, 18], { 20: [1, 43] }), { 23: [1, 44] }, o($Vs, [2, 22]), o($Vs, [2, 23]), o($Vs, [2, 24]), o($Vs, [2, 25]), { 30: 45, 31: [1, 46], 59: [1, 47], 60: [1, 48] }, o($Vs, [2, 28]), { 34: [1, 49] }, { 36: [1, 50] }, o($Vs, [2, 31]), { 13: 51, 24: $Va, 57: $Vr }, { 42: [1, 52], 44: [1, 53] }, { 46: [1, 54] }, { 49: [1, 55] }, o($Vt, [2, 44], { 58: [1, 56] }), o($Vt, [2, 45], { 58: [1, 57] }), o($Vs, [2, 38]), o($Vs, [2, 39]), o($Vs, [2, 40]), o($Vs, [2, 41]), o($Vs, [2, 6]), o($Vs, [2, 13]), { 13: 58, 24: $Va, 57: $Vr }, o($Vs, [2, 17]), o($Vu, $V3, { 7: 59 }), { 24: [1, 60] }, { 24: [1, 61] }, { 23: [1, 62] }, { 24: [2, 48] }, { 24: [2, 49] }, o($Vs, [2, 29]), o($Vs, [2, 30]), { 39: [1, 63], 40: [1, 64] }, { 43: [1, 65] }, { 43: [1, 66] }, { 47: [1, 67] }, { 50: [1, 68] }, { 24: [1, 69] }, { 24: [1, 70] }, o($Vs, [2, 14], { 14: [1, 71] }), { 4: $V4, 5: $V5, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 13: 15, 16: $V6, 17: $V7, 19: $V8, 21: [1, 72], 22: $V9, 24: $Va, 25: $Vb, 26: $Vc, 27: $Vd, 28: $Ve, 29: $Vf, 32: 25, 33: $Vg, 35: $Vh, 37: $Vi, 38: $Vj, 41: $Vk, 45: $Vl, 48: $Vm, 51: $Vn, 52: $Vo, 53: $Vp, 54: $Vq, 57: $Vr }, o($Vs, [2, 20], { 20: [1, 73] }), { 31: [1, 74] }, { 24: [1, 75] }, { 39: [1, 76] }, { 39: [1, 77] }, o($Vs, [2, 34]), o($Vs, [2, 35]), o($Vs, [2, 36]), o($Vs, [2, 37]), o($Vt, [2, 46]), o($Vt, [2, 47]), o($Vs, [2, 15]), o($Vs, [2, 19]), o($Vu, $V3, { 7: 78 }), o($Vs, [2, 26]), o($Vs, [2, 27]), { 5: [1, 79] }, { 5: [1, 80] }, { 4: $V4, 5: $V5, 8: 8, 9: 10, 10: 12, 11: 13, 12: 14, 13: 15, 16: $V6, 17: $V7, 19: $V8, 21: [1, 81], 22: $V9, 24: $Va, 25: $Vb, 26: $Vc, 27: $Vd, 28: $Ve, 29: $Vf, 32: 25, 33: $Vg, 35: $Vh, 37: $Vi, 38: $Vj, 41: $Vk, 45: $Vl, 48: $Vm, 51: $Vn, 52: $Vo, 53: $Vp, 54: $Vq, 57: $Vr }, o($Vs, [2, 32]), o($Vs, [2, 33]), o($Vs, [2, 21])],
183
+ defaultActions: { 5: [2, 1], 6: [2, 2], 47: [2, 48], 48: [2, 49] },
184
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
185
+ if (hash.recoverable) {
186
+ this.trace(str);
187
+ } else {
188
+ var error = new Error(str);
189
+ error.hash = hash;
190
+ throw error;
191
+ }
192
+ }, "parseError"),
193
+ parse: /* @__PURE__ */ __name(function parse(input) {
194
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
195
+ var args = lstack.slice.call(arguments, 1);
196
+ var lexer2 = Object.create(this.lexer);
197
+ var sharedState = { yy: {} };
198
+ for (var k in this.yy) {
199
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
200
+ sharedState.yy[k] = this.yy[k];
201
+ }
202
+ }
203
+ lexer2.setInput(input, sharedState.yy);
204
+ sharedState.yy.lexer = lexer2;
205
+ sharedState.yy.parser = this;
206
+ if (typeof lexer2.yylloc == "undefined") {
207
+ lexer2.yylloc = {};
208
+ }
209
+ var yyloc = lexer2.yylloc;
210
+ lstack.push(yyloc);
211
+ var ranges = lexer2.options && lexer2.options.ranges;
212
+ if (typeof sharedState.yy.parseError === "function") {
213
+ this.parseError = sharedState.yy.parseError;
214
+ } else {
215
+ this.parseError = Object.getPrototypeOf(this).parseError;
216
+ }
217
+ function popStack(n) {
218
+ stack.length = stack.length - 2 * n;
219
+ vstack.length = vstack.length - n;
220
+ lstack.length = lstack.length - n;
221
+ }
222
+ __name(popStack, "popStack");
223
+ function lex() {
224
+ var token;
225
+ token = tstack.pop() || lexer2.lex() || EOF;
226
+ if (typeof token !== "number") {
227
+ if (token instanceof Array) {
228
+ tstack = token;
229
+ token = tstack.pop();
230
+ }
231
+ token = self.symbols_[token] || token;
232
+ }
233
+ return token;
234
+ }
235
+ __name(lex, "lex");
236
+ var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
237
+ while (true) {
238
+ state = stack[stack.length - 1];
239
+ if (this.defaultActions[state]) {
240
+ action = this.defaultActions[state];
241
+ } else {
242
+ if (symbol === null || typeof symbol == "undefined") {
243
+ symbol = lex();
244
+ }
245
+ action = table[state] && table[state][symbol];
246
+ }
247
+ if (typeof action === "undefined" || !action.length || !action[0]) {
248
+ var errStr = "";
249
+ expected = [];
250
+ for (p in table[state]) {
251
+ if (this.terminals_[p] && p > TERROR) {
252
+ expected.push("'" + this.terminals_[p] + "'");
253
+ }
254
+ }
255
+ if (lexer2.showPosition) {
256
+ errStr = "Parse error on line " + (yylineno + 1) + `:
257
+ ` + lexer2.showPosition() + `
258
+ Expecting ` + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
259
+ } else {
260
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
261
+ }
262
+ this.parseError(errStr, {
263
+ text: lexer2.match,
264
+ token: this.terminals_[symbol] || symbol,
265
+ line: lexer2.yylineno,
266
+ loc: yyloc,
267
+ expected
268
+ });
269
+ }
270
+ if (action[0] instanceof Array && action.length > 1) {
271
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
272
+ }
273
+ switch (action[0]) {
274
+ case 1:
275
+ stack.push(symbol);
276
+ vstack.push(lexer2.yytext);
277
+ lstack.push(lexer2.yylloc);
278
+ stack.push(action[1]);
279
+ symbol = null;
280
+ if (!preErrorSymbol) {
281
+ yyleng = lexer2.yyleng;
282
+ yytext = lexer2.yytext;
283
+ yylineno = lexer2.yylineno;
284
+ yyloc = lexer2.yylloc;
285
+ if (recovering > 0) {
286
+ recovering--;
287
+ }
288
+ } else {
289
+ symbol = preErrorSymbol;
290
+ preErrorSymbol = null;
291
+ }
292
+ break;
293
+ case 2:
294
+ len = this.productions_[action[1]][1];
295
+ yyval.$ = vstack[vstack.length - len];
296
+ yyval._$ = {
297
+ first_line: lstack[lstack.length - (len || 1)].first_line,
298
+ last_line: lstack[lstack.length - 1].last_line,
299
+ first_column: lstack[lstack.length - (len || 1)].first_column,
300
+ last_column: lstack[lstack.length - 1].last_column
301
+ };
302
+ if (ranges) {
303
+ yyval._$.range = [
304
+ lstack[lstack.length - (len || 1)].range[0],
305
+ lstack[lstack.length - 1].range[1]
306
+ ];
307
+ }
308
+ r = this.performAction.apply(yyval, [
309
+ yytext,
310
+ yyleng,
311
+ yylineno,
312
+ sharedState.yy,
313
+ action[1],
314
+ vstack,
315
+ lstack
316
+ ].concat(args));
317
+ if (typeof r !== "undefined") {
318
+ return r;
319
+ }
320
+ if (len) {
321
+ stack = stack.slice(0, -1 * len * 2);
322
+ vstack = vstack.slice(0, -1 * len);
323
+ lstack = lstack.slice(0, -1 * len);
324
+ }
325
+ stack.push(this.productions_[action[1]][0]);
326
+ vstack.push(yyval.$);
327
+ lstack.push(yyval._$);
328
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
329
+ stack.push(newState);
330
+ break;
331
+ case 3:
332
+ return true;
333
+ }
334
+ }
335
+ return true;
336
+ }, "parse")
337
+ };
338
+ var lexer = /* @__PURE__ */ function() {
339
+ var lexer2 = {
340
+ EOF: 1,
341
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
342
+ if (this.yy.parser) {
343
+ this.yy.parser.parseError(str, hash);
344
+ } else {
345
+ throw new Error(str);
346
+ }
347
+ }, "parseError"),
348
+ setInput: /* @__PURE__ */ __name(function(input, yy) {
349
+ this.yy = yy || this.yy || {};
350
+ this._input = input;
351
+ this._more = this._backtrack = this.done = false;
352
+ this.yylineno = this.yyleng = 0;
353
+ this.yytext = this.matched = this.match = "";
354
+ this.conditionStack = ["INITIAL"];
355
+ this.yylloc = {
356
+ first_line: 1,
357
+ first_column: 0,
358
+ last_line: 1,
359
+ last_column: 0
360
+ };
361
+ if (this.options.ranges) {
362
+ this.yylloc.range = [0, 0];
363
+ }
364
+ this.offset = 0;
365
+ return this;
366
+ }, "setInput"),
367
+ input: /* @__PURE__ */ __name(function() {
368
+ var ch = this._input[0];
369
+ this.yytext += ch;
370
+ this.yyleng++;
371
+ this.offset++;
372
+ this.match += ch;
373
+ this.matched += ch;
374
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
375
+ if (lines) {
376
+ this.yylineno++;
377
+ this.yylloc.last_line++;
378
+ } else {
379
+ this.yylloc.last_column++;
380
+ }
381
+ if (this.options.ranges) {
382
+ this.yylloc.range[1]++;
383
+ }
384
+ this._input = this._input.slice(1);
385
+ return ch;
386
+ }, "input"),
387
+ unput: /* @__PURE__ */ __name(function(ch) {
388
+ var len = ch.length;
389
+ var lines = ch.split(/(?:\r\n?|\n)/g);
390
+ this._input = ch + this._input;
391
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
392
+ this.offset -= len;
393
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
394
+ this.match = this.match.substr(0, this.match.length - 1);
395
+ this.matched = this.matched.substr(0, this.matched.length - 1);
396
+ if (lines.length - 1) {
397
+ this.yylineno -= lines.length - 1;
398
+ }
399
+ var r = this.yylloc.range;
400
+ this.yylloc = {
401
+ first_line: this.yylloc.first_line,
402
+ last_line: this.yylineno + 1,
403
+ first_column: this.yylloc.first_column,
404
+ last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
405
+ };
406
+ if (this.options.ranges) {
407
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
408
+ }
409
+ this.yyleng = this.yytext.length;
410
+ return this;
411
+ }, "unput"),
412
+ more: /* @__PURE__ */ __name(function() {
413
+ this._more = true;
414
+ return this;
415
+ }, "more"),
416
+ reject: /* @__PURE__ */ __name(function() {
417
+ if (this.options.backtrack_lexer) {
418
+ this._backtrack = true;
419
+ } else {
420
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
421
+ ` + this.showPosition(), {
422
+ text: "",
423
+ token: null,
424
+ line: this.yylineno
425
+ });
426
+ }
427
+ return this;
428
+ }, "reject"),
429
+ less: /* @__PURE__ */ __name(function(n) {
430
+ this.unput(this.match.slice(n));
431
+ }, "less"),
432
+ pastInput: /* @__PURE__ */ __name(function() {
433
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
434
+ return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
435
+ }, "pastInput"),
436
+ upcomingInput: /* @__PURE__ */ __name(function() {
437
+ var next = this.match;
438
+ if (next.length < 20) {
439
+ next += this._input.substr(0, 20 - next.length);
440
+ }
441
+ return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
442
+ }, "upcomingInput"),
443
+ showPosition: /* @__PURE__ */ __name(function() {
444
+ var pre = this.pastInput();
445
+ var c = new Array(pre.length + 1).join("-");
446
+ return pre + this.upcomingInput() + `
447
+ ` + c + "^";
448
+ }, "showPosition"),
449
+ test_match: /* @__PURE__ */ __name(function(match, indexed_rule) {
450
+ var token, lines, backup;
451
+ if (this.options.backtrack_lexer) {
452
+ backup = {
453
+ yylineno: this.yylineno,
454
+ yylloc: {
455
+ first_line: this.yylloc.first_line,
456
+ last_line: this.last_line,
457
+ first_column: this.yylloc.first_column,
458
+ last_column: this.yylloc.last_column
459
+ },
460
+ yytext: this.yytext,
461
+ match: this.match,
462
+ matches: this.matches,
463
+ matched: this.matched,
464
+ yyleng: this.yyleng,
465
+ offset: this.offset,
466
+ _more: this._more,
467
+ _input: this._input,
468
+ yy: this.yy,
469
+ conditionStack: this.conditionStack.slice(0),
470
+ done: this.done
471
+ };
472
+ if (this.options.ranges) {
473
+ backup.yylloc.range = this.yylloc.range.slice(0);
474
+ }
475
+ }
476
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
477
+ if (lines) {
478
+ this.yylineno += lines.length;
479
+ }
480
+ this.yylloc = {
481
+ first_line: this.yylloc.last_line,
482
+ last_line: this.yylineno + 1,
483
+ first_column: this.yylloc.last_column,
484
+ last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
485
+ };
486
+ this.yytext += match[0];
487
+ this.match += match[0];
488
+ this.matches = match;
489
+ this.yyleng = this.yytext.length;
490
+ if (this.options.ranges) {
491
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
492
+ }
493
+ this._more = false;
494
+ this._backtrack = false;
495
+ this._input = this._input.slice(match[0].length);
496
+ this.matched += match[0];
497
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
498
+ if (this.done && this._input) {
499
+ this.done = false;
500
+ }
501
+ if (token) {
502
+ return token;
503
+ } else if (this._backtrack) {
504
+ for (var k in backup) {
505
+ this[k] = backup[k];
506
+ }
507
+ return false;
508
+ }
509
+ return false;
510
+ }, "test_match"),
511
+ next: /* @__PURE__ */ __name(function() {
512
+ if (this.done) {
513
+ return this.EOF;
514
+ }
515
+ if (!this._input) {
516
+ this.done = true;
517
+ }
518
+ var token, match, tempMatch, index;
519
+ if (!this._more) {
520
+ this.yytext = "";
521
+ this.match = "";
522
+ }
523
+ var rules = this._currentRules();
524
+ for (var i = 0;i < rules.length; i++) {
525
+ tempMatch = this._input.match(this.rules[rules[i]]);
526
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
527
+ match = tempMatch;
528
+ index = i;
529
+ if (this.options.backtrack_lexer) {
530
+ token = this.test_match(tempMatch, rules[i]);
531
+ if (token !== false) {
532
+ return token;
533
+ } else if (this._backtrack) {
534
+ match = false;
535
+ continue;
536
+ } else {
537
+ return false;
538
+ }
539
+ } else if (!this.options.flex) {
540
+ break;
541
+ }
542
+ }
543
+ }
544
+ if (match) {
545
+ token = this.test_match(match, rules[index]);
546
+ if (token !== false) {
547
+ return token;
548
+ }
549
+ return false;
550
+ }
551
+ if (this._input === "") {
552
+ return this.EOF;
553
+ } else {
554
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
555
+ ` + this.showPosition(), {
556
+ text: "",
557
+ token: null,
558
+ line: this.yylineno
559
+ });
560
+ }
561
+ }, "next"),
562
+ lex: /* @__PURE__ */ __name(function lex() {
563
+ var r = this.next();
564
+ if (r) {
565
+ return r;
566
+ } else {
567
+ return this.lex();
568
+ }
569
+ }, "lex"),
570
+ begin: /* @__PURE__ */ __name(function begin(condition) {
571
+ this.conditionStack.push(condition);
572
+ }, "begin"),
573
+ popState: /* @__PURE__ */ __name(function popState() {
574
+ var n = this.conditionStack.length - 1;
575
+ if (n > 0) {
576
+ return this.conditionStack.pop();
577
+ } else {
578
+ return this.conditionStack[0];
579
+ }
580
+ }, "popState"),
581
+ _currentRules: /* @__PURE__ */ __name(function _currentRules() {
582
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
583
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
584
+ } else {
585
+ return this.conditions["INITIAL"].rules;
586
+ }
587
+ }, "_currentRules"),
588
+ topState: /* @__PURE__ */ __name(function topState(n) {
589
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
590
+ if (n >= 0) {
591
+ return this.conditionStack[n];
592
+ } else {
593
+ return "INITIAL";
594
+ }
595
+ }, "topState"),
596
+ pushState: /* @__PURE__ */ __name(function pushState(condition) {
597
+ this.begin(condition);
598
+ }, "pushState"),
599
+ stateStackSize: /* @__PURE__ */ __name(function stateStackSize() {
600
+ return this.conditionStack.length;
601
+ }, "stateStackSize"),
602
+ options: { "case-insensitive": true },
603
+ performAction: /* @__PURE__ */ __name(function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
604
+ function processId() {
605
+ const idx = yy_.yytext.indexOf("%%");
606
+ if (idx === 0) {
607
+ return false;
608
+ }
609
+ if (idx > 0) {
610
+ const before = yy_.yytext.slice(0, idx);
611
+ const after = yy_.yytext.slice(idx);
612
+ if (after) {
613
+ yy.lexer.unput(after);
614
+ }
615
+ yy_.yytext = before;
616
+ }
617
+ return true;
618
+ }
619
+ __name(processId, "processId");
620
+ var YYSTATE = YY_START;
621
+ switch ($avoiding_name_collisions) {
622
+ case 0:
623
+ return 38;
624
+ break;
625
+ case 1:
626
+ return 40;
627
+ break;
628
+ case 2:
629
+ return 39;
630
+ break;
631
+ case 3:
632
+ return 44;
633
+ break;
634
+ case 4:
635
+ return 51;
636
+ break;
637
+ case 5:
638
+ return 52;
639
+ break;
640
+ case 6:
641
+ return 53;
642
+ break;
643
+ case 7:
644
+ return 54;
645
+ break;
646
+ case 8:
647
+ return 5;
648
+ break;
649
+ case 9:
650
+ break;
651
+ case 10:
652
+ break;
653
+ case 11:
654
+ break;
655
+ case 12:
656
+ break;
657
+ case 13:
658
+ this.pushState("SCALE");
659
+ return 17;
660
+ break;
661
+ case 14:
662
+ return 18;
663
+ break;
664
+ case 15:
665
+ this.popState();
666
+ break;
667
+ case 16:
668
+ this.begin("acc_title");
669
+ return 33;
670
+ break;
671
+ case 17:
672
+ this.popState();
673
+ return "acc_title_value";
674
+ break;
675
+ case 18:
676
+ this.begin("acc_descr");
677
+ return 35;
678
+ break;
679
+ case 19:
680
+ this.popState();
681
+ return "acc_descr_value";
682
+ break;
683
+ case 20:
684
+ this.begin("acc_descr_multiline");
685
+ break;
686
+ case 21:
687
+ this.popState();
688
+ break;
689
+ case 22:
690
+ return "acc_descr_multiline_value";
691
+ break;
692
+ case 23:
693
+ this.pushState("CLASSDEF");
694
+ return 41;
695
+ break;
696
+ case 24:
697
+ this.popState();
698
+ this.pushState("CLASSDEFID");
699
+ return "DEFAULT_CLASSDEF_ID";
700
+ break;
701
+ case 25:
702
+ this.popState();
703
+ this.pushState("CLASSDEFID");
704
+ return 42;
705
+ break;
706
+ case 26:
707
+ this.popState();
708
+ return 43;
709
+ break;
710
+ case 27:
711
+ this.pushState("CLASS");
712
+ return 48;
713
+ break;
714
+ case 28:
715
+ this.popState();
716
+ this.pushState("CLASS_STYLE");
717
+ return 49;
718
+ break;
719
+ case 29:
720
+ this.popState();
721
+ return 50;
722
+ break;
723
+ case 30:
724
+ this.pushState("STYLE");
725
+ return 45;
726
+ break;
727
+ case 31:
728
+ this.popState();
729
+ this.pushState("STYLEDEF_STYLES");
730
+ return 46;
731
+ break;
732
+ case 32:
733
+ this.popState();
734
+ return 47;
735
+ break;
736
+ case 33:
737
+ this.pushState("SCALE");
738
+ return 17;
739
+ break;
740
+ case 34:
741
+ return 18;
742
+ break;
743
+ case 35:
744
+ this.popState();
745
+ break;
746
+ case 36:
747
+ this.pushState("STATE");
748
+ break;
749
+ case 37:
750
+ this.popState();
751
+ yy_.yytext = yy_.yytext.slice(0, -8).trim();
752
+ return 25;
753
+ break;
754
+ case 38:
755
+ this.popState();
756
+ yy_.yytext = yy_.yytext.slice(0, -8).trim();
757
+ return 26;
758
+ break;
759
+ case 39:
760
+ this.popState();
761
+ yy_.yytext = yy_.yytext.slice(0, -10).trim();
762
+ return 27;
763
+ break;
764
+ case 40:
765
+ this.popState();
766
+ yy_.yytext = yy_.yytext.slice(0, -8).trim();
767
+ return 25;
768
+ break;
769
+ case 41:
770
+ this.popState();
771
+ yy_.yytext = yy_.yytext.slice(0, -8).trim();
772
+ return 26;
773
+ break;
774
+ case 42:
775
+ this.popState();
776
+ yy_.yytext = yy_.yytext.slice(0, -10).trim();
777
+ return 27;
778
+ break;
779
+ case 43:
780
+ return 51;
781
+ break;
782
+ case 44:
783
+ return 52;
784
+ break;
785
+ case 45:
786
+ return 53;
787
+ break;
788
+ case 46:
789
+ return 54;
790
+ break;
791
+ case 47:
792
+ this.pushState("STATE_STRING");
793
+ break;
794
+ case 48:
795
+ this.pushState("STATE_ID");
796
+ return "AS";
797
+ break;
798
+ case 49:
799
+ if (!processId())
800
+ return;
801
+ this.popState();
802
+ return "ID";
803
+ break;
804
+ case 50:
805
+ this.popState();
806
+ break;
807
+ case 51:
808
+ return "STATE_DESCR";
809
+ break;
810
+ case 52:
811
+ throw new Error('Error: State name must be a single word. Found: "' + yy_.yytext.trim() + '"');
812
+ break;
813
+ case 53:
814
+ return 19;
815
+ break;
816
+ case 54:
817
+ this.popState();
818
+ break;
819
+ case 55:
820
+ this.popState();
821
+ this.pushState("struct");
822
+ return 20;
823
+ break;
824
+ case 56:
825
+ this.popState();
826
+ return 21;
827
+ break;
828
+ case 57:
829
+ break;
830
+ case 58:
831
+ this.begin("NOTE");
832
+ return 29;
833
+ break;
834
+ case 59:
835
+ this.popState();
836
+ this.pushState("NOTE_ID");
837
+ return 59;
838
+ break;
839
+ case 60:
840
+ this.popState();
841
+ this.pushState("NOTE_ID");
842
+ return 60;
843
+ break;
844
+ case 61:
845
+ this.popState();
846
+ this.pushState("FLOATING_NOTE");
847
+ break;
848
+ case 62:
849
+ this.popState();
850
+ this.pushState("FLOATING_NOTE_ID");
851
+ return "AS";
852
+ break;
853
+ case 63:
854
+ break;
855
+ case 64:
856
+ return "NOTE_TEXT";
857
+ break;
858
+ case 65:
859
+ if (!processId())
860
+ return;
861
+ this.popState();
862
+ return "ID";
863
+ break;
864
+ case 66:
865
+ if (!processId())
866
+ return;
867
+ this.popState();
868
+ this.pushState("NOTE_TEXT");
869
+ return 24;
870
+ break;
871
+ case 67:
872
+ this.popState();
873
+ yy_.yytext = yy_.yytext.substr(2).trim();
874
+ return 31;
875
+ break;
876
+ case 68:
877
+ this.popState();
878
+ yy_.yytext = yy_.yytext.slice(0, -8).trim();
879
+ return 31;
880
+ break;
881
+ case 69:
882
+ return 6;
883
+ break;
884
+ case 70:
885
+ return 6;
886
+ break;
887
+ case 71:
888
+ return 16;
889
+ break;
890
+ case 72:
891
+ return 57;
892
+ break;
893
+ case 73:
894
+ if (!processId())
895
+ return;
896
+ return 24;
897
+ break;
898
+ case 74:
899
+ yy_.yytext = yy_.yytext.trim();
900
+ return 14;
901
+ break;
902
+ case 75:
903
+ return 15;
904
+ break;
905
+ case 76:
906
+ return 28;
907
+ break;
908
+ case 77:
909
+ return 58;
910
+ break;
911
+ case 78:
912
+ return 5;
913
+ break;
914
+ case 79:
915
+ return "INVALID";
916
+ break;
917
+ }
918
+ }, "anonymous"),
919
+ rules: [/^(?:click\b)/i, /^(?:href\b)/i, /^(?:"[^"]*")/i, /^(?:default\b)/i, /^(?:.*direction\s+TB[^\n]*)/i, /^(?:.*direction\s+BT[^\n]*)/i, /^(?:.*direction\s+RL[^\n]*)/i, /^(?:.*direction\s+LR[^\n]*)/i, /^(?:[\n]+)/i, /^(?:[\s]+)/i, /^(?:((?!\n)\s)+)/i, /^(?:#[^\n]*)/i, /^(?:%%(?!\{)[^\n]*)/i, /^(?:scale\s+)/i, /^(?:\d+)/i, /^(?:\s+width\b)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:classDef\s+)/i, /^(?:DEFAULT\s+)/i, /^(?:\w+\s+)/i, /^(?:[^\n]*)/i, /^(?:class\s+)/i, /^(?:(\w+)+((,\s*\w+)*))/i, /^(?:[^\n]*)/i, /^(?:style\s+)/i, /^(?:[\w,]+\s+)/i, /^(?:[^\n]*)/i, /^(?:scale\s+)/i, /^(?:\d+)/i, /^(?:\s+width\b)/i, /^(?:state\s+)/i, /^(?:.*<<fork>>)/i, /^(?:.*<<join>>)/i, /^(?:.*<<choice>>)/i, /^(?:.*\[\[fork\]\])/i, /^(?:.*\[\[join\]\])/i, /^(?:.*\[\[choice\]\])/i, /^(?:.*direction\s+TB[^\n]*)/i, /^(?:.*direction\s+BT[^\n]*)/i, /^(?:.*direction\s+RL[^\n]*)/i, /^(?:.*direction\s+LR[^\n]*)/i, /^(?:["])/i, /^(?:\s*as\s+)/i, /^(?:[^\n\{]*)/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:\w+\s+\w+.*?\{)/i, /^(?:[^\n\s\{]+)/i, /^(?:\n)/i, /^(?:\{)/i, /^(?:\})/i, /^(?:[\n])/i, /^(?:note\s+)/i, /^(?:left of\b)/i, /^(?:right of\b)/i, /^(?:")/i, /^(?:\s*as\s*)/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:[^\n]*)/i, /^(?:\s*[^:\n\s\-]+)/i, /^(?:\s*:[^:\n;]+)/i, /^(?:[\s\S]*?\n\s*end note\b)/i, /^(?:stateDiagram\s+)/i, /^(?:stateDiagram-v2\s+)/i, /^(?:hide empty description\b)/i, /^(?:\[\*\])/i, /^(?:[^:\n\s\-\{]+)/i, /^(?:\s*:(?:[^:\n;]|:[^:\n;])+)/i, /^(?:-->)/i, /^(?:--)/i, /^(?::::)/i, /^(?:$)/i, /^(?:.)/i],
920
+ conditions: { LINE: { rules: [10, 11, 12], inclusive: false }, struct: { rules: [10, 11, 12, 23, 27, 30, 36, 43, 44, 45, 46, 56, 57, 58, 72, 73, 74, 75, 76, 77], inclusive: false }, FLOATING_NOTE_ID: { rules: [65], inclusive: false }, FLOATING_NOTE: { rules: [62, 63, 64], inclusive: false }, NOTE_TEXT: { rules: [67, 68], inclusive: false }, NOTE_ID: { rules: [66], inclusive: false }, NOTE: { rules: [59, 60, 61], inclusive: false }, STYLEDEF_STYLEOPTS: { rules: [], inclusive: false }, STYLEDEF_STYLES: { rules: [32], inclusive: false }, STYLE_IDS: { rules: [], inclusive: false }, STYLE: { rules: [31], inclusive: false }, CLASS_STYLE: { rules: [29], inclusive: false }, CLASS: { rules: [28], inclusive: false }, CLASSDEFID: { rules: [26], inclusive: false }, CLASSDEF: { rules: [24, 25], inclusive: false }, acc_descr_multiline: { rules: [21, 22], inclusive: false }, acc_descr: { rules: [19], inclusive: false }, acc_title: { rules: [17], inclusive: false }, SCALE: { rules: [14, 15, 34, 35], inclusive: false }, ALIAS: { rules: [], inclusive: false }, STATE_ID: { rules: [49], inclusive: false }, STATE_STRING: { rules: [50, 51], inclusive: false }, FORK_STATE: { rules: [], inclusive: false }, STATE: { rules: [10, 11, 12, 37, 38, 39, 40, 41, 42, 47, 48, 52, 53, 54, 55], inclusive: false }, ID: { rules: [10, 11, 12], inclusive: false }, INITIAL: { rules: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 16, 18, 20, 23, 27, 30, 33, 36, 55, 58, 69, 70, 71, 72, 73, 74, 75, 77, 78, 79], inclusive: true } }
921
+ };
922
+ return lexer2;
923
+ }();
924
+ parser2.lexer = lexer;
925
+ function Parser() {
926
+ this.yy = {};
927
+ }
928
+ __name(Parser, "Parser");
929
+ Parser.prototype = parser2;
930
+ parser2.Parser = Parser;
931
+ return new Parser;
932
+ }();
933
+ parser.parser = parser;
934
+ var stateDiagram_default = parser;
935
+ var DEFAULT_DIAGRAM_DIRECTION = "TB";
936
+ var DEFAULT_NESTED_DOC_DIR = "TB";
937
+ var STMT_DIRECTION = "dir";
938
+ var STMT_STATE = "state";
939
+ var STMT_ROOT = "root";
940
+ var STMT_RELATION = "relation";
941
+ var STMT_CLASSDEF = "classDef";
942
+ var STMT_STYLEDEF = "style";
943
+ var STMT_APPLYCLASS = "applyClass";
944
+ var DEFAULT_STATE_TYPE = "default";
945
+ var DIVIDER_TYPE = "divider";
946
+ var G_EDGE_STYLE = "fill:none";
947
+ var G_EDGE_ARROWHEADSTYLE = "fill: #333";
948
+ var G_EDGE_LABELPOS = "c";
949
+ var G_EDGE_LABELTYPE = "markdown";
950
+ var G_EDGE_THICKNESS = "normal";
951
+ var SHAPE_STATE = "rect";
952
+ var SHAPE_STATE_WITH_DESC = "rectWithTitle";
953
+ var SHAPE_START = "stateStart";
954
+ var SHAPE_END = "stateEnd";
955
+ var SHAPE_DIVIDER = "divider";
956
+ var SHAPE_GROUP = "roundedWithTitle";
957
+ var SHAPE_NOTE = "note";
958
+ var SHAPE_NOTEGROUP = "noteGroup";
959
+ var CSS_DIAGRAM = "statediagram";
960
+ var CSS_STATE = "state";
961
+ var CSS_DIAGRAM_STATE = `${CSS_DIAGRAM}-${CSS_STATE}`;
962
+ var CSS_EDGE = "transition";
963
+ var CSS_NOTE = "note";
964
+ var CSS_NOTE_EDGE = "note-edge";
965
+ var CSS_EDGE_NOTE_EDGE = `${CSS_EDGE} ${CSS_NOTE_EDGE}`;
966
+ var CSS_DIAGRAM_NOTE = `${CSS_DIAGRAM}-${CSS_NOTE}`;
967
+ var CSS_CLUSTER = "cluster";
968
+ var CSS_DIAGRAM_CLUSTER = `${CSS_DIAGRAM}-${CSS_CLUSTER}`;
969
+ var CSS_CLUSTER_ALT = "cluster-alt";
970
+ var CSS_DIAGRAM_CLUSTER_ALT = `${CSS_DIAGRAM}-${CSS_CLUSTER_ALT}`;
971
+ var PARENT = "parent";
972
+ var NOTE = "note";
973
+ var DOMID_STATE = "state";
974
+ var DOMID_TYPE_SPACER = "----";
975
+ var NOTE_ID = `${DOMID_TYPE_SPACER}${NOTE}`;
976
+ var PARENT_ID = `${DOMID_TYPE_SPACER}${PARENT}`;
977
+ var getDir = /* @__PURE__ */ __name((parsedItem, defaultDir = DEFAULT_NESTED_DOC_DIR) => {
978
+ if (!parsedItem.doc) {
979
+ return defaultDir;
980
+ }
981
+ let dir = defaultDir;
982
+ for (const parsedItemDoc of parsedItem.doc) {
983
+ if (parsedItemDoc.stmt === "dir") {
984
+ dir = parsedItemDoc.value;
985
+ }
986
+ }
987
+ return dir;
988
+ }, "getDir");
989
+ var getClasses = /* @__PURE__ */ __name(function(text, diagramObj) {
990
+ return diagramObj.db.getClasses();
991
+ }, "getClasses");
992
+ var draw = /* @__PURE__ */ __name(async function(text, id, _version, diag) {
993
+ log.info("REF0:");
994
+ log.info("Drawing state diagram (v2)", id);
995
+ const { securityLevel, state: conf, layout } = getConfig2();
996
+ diag.db.extract(diag.db.getRootDocV2());
997
+ const data4Layout = diag.db.getData();
998
+ const svg = getDiagramElement(id, securityLevel);
999
+ data4Layout.type = diag.type;
1000
+ data4Layout.layoutAlgorithm = layout;
1001
+ data4Layout.nodeSpacing = conf?.nodeSpacing || 50;
1002
+ data4Layout.rankSpacing = conf?.rankSpacing || 50;
1003
+ const config = getConfig2();
1004
+ if (config.look === "neo") {
1005
+ data4Layout.markers = ["barbNeo"];
1006
+ } else {
1007
+ data4Layout.markers = ["barb"];
1008
+ }
1009
+ data4Layout.diagramId = id;
1010
+ await render(data4Layout, svg);
1011
+ const padding = 8;
1012
+ try {
1013
+ const links = typeof diag.db.getLinks === "function" ? diag.db.getLinks() : /* @__PURE__ */ new Map;
1014
+ links.forEach((linkInfo, key) => {
1015
+ const stateId = typeof key === "string" ? key : typeof key?.id === "string" ? key.id : "";
1016
+ const stateNode = data4Layout.nodes.find((node) => node.id === stateId);
1017
+ if (!stateId) {
1018
+ log.warn("⚠️ Invalid or missing stateId from key:", JSON.stringify(key));
1019
+ return;
1020
+ }
1021
+ const allNodes = svg.node()?.querySelectorAll("g.node, g.rough-node");
1022
+ let matchedElem;
1023
+ allNodes?.forEach((g) => {
1024
+ const text2 = g.textContent?.trim();
1025
+ if (g.id === stateNode?.domId || text2 === stateId) {
1026
+ matchedElem = g;
1027
+ }
1028
+ });
1029
+ if (!matchedElem) {
1030
+ log.warn("⚠️ Could not find node matching text:", stateId);
1031
+ return;
1032
+ }
1033
+ const parent = matchedElem.parentNode;
1034
+ if (!parent) {
1035
+ log.warn("⚠️ Node has no parent, cannot wrap:", stateId);
1036
+ return;
1037
+ }
1038
+ const a = document.createElementNS("http://www.w3.org/2000/svg", "a");
1039
+ const cleanedUrl = linkInfo.url.replace(/^"+|"+$/g, "");
1040
+ a.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", cleanedUrl);
1041
+ a.setAttribute("target", "_blank");
1042
+ if (linkInfo.tooltip) {
1043
+ const tooltip = linkInfo.tooltip.replace(/^"+|"+$/g, "");
1044
+ a.setAttribute("title", tooltip);
1045
+ matchedElem.setAttribute("title", tooltip);
1046
+ }
1047
+ parent.replaceChild(a, matchedElem);
1048
+ a.appendChild(matchedElem);
1049
+ log.info("\uD83D\uDD17 Wrapped node in <a> tag for:", stateId, linkInfo.url);
1050
+ });
1051
+ } catch (err) {
1052
+ log.error("❌ Error injecting clickable links:", err);
1053
+ }
1054
+ utils_default.insertTitle(svg, "statediagramTitleText", conf?.titleTopMargin ?? 25, diag.db.getDiagramTitle());
1055
+ setupViewPortForSVG(svg, padding, CSS_DIAGRAM, conf?.useMaxWidth ?? true);
1056
+ }, "draw");
1057
+ var stateRenderer_v3_unified_default = {
1058
+ getClasses,
1059
+ draw,
1060
+ getDir
1061
+ };
1062
+ var nodeDb = /* @__PURE__ */ new Map;
1063
+ var graphItemCount = 0;
1064
+ function stateDomId(itemId = "", counter = 0, type = "", typeSpacer = DOMID_TYPE_SPACER) {
1065
+ const typeStr = type !== null && type.length > 0 ? `${typeSpacer}${type}` : "";
1066
+ return `${DOMID_STATE}-${itemId}${typeStr}-${counter}`;
1067
+ }
1068
+ __name(stateDomId, "stateDomId");
1069
+ var setupDoc = /* @__PURE__ */ __name((parentParsedItem, doc, diagramStates, nodes, edges, altFlag, look, classes) => {
1070
+ log.trace("items", doc);
1071
+ doc.forEach((item) => {
1072
+ switch (item.stmt) {
1073
+ case STMT_STATE:
1074
+ dataFetcher(parentParsedItem, item, diagramStates, nodes, edges, altFlag, look, classes);
1075
+ break;
1076
+ case DEFAULT_STATE_TYPE:
1077
+ dataFetcher(parentParsedItem, item, diagramStates, nodes, edges, altFlag, look, classes);
1078
+ break;
1079
+ case STMT_RELATION:
1080
+ {
1081
+ dataFetcher(parentParsedItem, item.state1, diagramStates, nodes, edges, altFlag, look, classes);
1082
+ dataFetcher(parentParsedItem, item.state2, diagramStates, nodes, edges, altFlag, look, classes);
1083
+ const isNeo = look === "neo";
1084
+ const edgeData = {
1085
+ id: "edge" + graphItemCount,
1086
+ start: item.state1.id,
1087
+ end: item.state2.id,
1088
+ arrowhead: "normal",
1089
+ arrowTypeEnd: isNeo ? "arrow_barb_neo" : "arrow_barb",
1090
+ style: G_EDGE_STYLE,
1091
+ labelStyle: "",
1092
+ label: common_default.sanitizeText(item.description ?? "", getConfig2()),
1093
+ arrowheadStyle: G_EDGE_ARROWHEADSTYLE,
1094
+ labelpos: G_EDGE_LABELPOS,
1095
+ labelType: G_EDGE_LABELTYPE,
1096
+ thickness: G_EDGE_THICKNESS,
1097
+ classes: CSS_EDGE,
1098
+ look
1099
+ };
1100
+ edges.push(edgeData);
1101
+ graphItemCount++;
1102
+ }
1103
+ break;
1104
+ }
1105
+ });
1106
+ }, "setupDoc");
1107
+ var getDir2 = /* @__PURE__ */ __name((parsedItem, defaultDir = DEFAULT_NESTED_DOC_DIR) => {
1108
+ let dir = defaultDir;
1109
+ if (parsedItem.doc) {
1110
+ for (const parsedItemDoc of parsedItem.doc) {
1111
+ if (parsedItemDoc.stmt === "dir") {
1112
+ dir = parsedItemDoc.value;
1113
+ }
1114
+ }
1115
+ }
1116
+ return dir;
1117
+ }, "getDir");
1118
+ function insertOrUpdateNode(nodes, nodeData, classes) {
1119
+ if (!nodeData.id || nodeData.id === "</join></fork>" || nodeData.id === "</choice>") {
1120
+ return;
1121
+ }
1122
+ if (nodeData.cssClasses) {
1123
+ if (!Array.isArray(nodeData.cssCompiledStyles)) {
1124
+ nodeData.cssCompiledStyles = [];
1125
+ }
1126
+ nodeData.cssClasses.split(" ").forEach((cssClass) => {
1127
+ const classDef = classes.get(cssClass);
1128
+ if (classDef) {
1129
+ nodeData.cssCompiledStyles = [...nodeData.cssCompiledStyles ?? [], ...classDef.styles];
1130
+ }
1131
+ });
1132
+ }
1133
+ const existingNodeData = nodes.find((node) => node.id === nodeData.id);
1134
+ if (existingNodeData) {
1135
+ Object.assign(existingNodeData, nodeData);
1136
+ } else {
1137
+ nodes.push(nodeData);
1138
+ }
1139
+ }
1140
+ __name(insertOrUpdateNode, "insertOrUpdateNode");
1141
+ function getClassesFromDbInfo(dbInfoItem) {
1142
+ return dbInfoItem?.classes?.join(" ") ?? "";
1143
+ }
1144
+ __name(getClassesFromDbInfo, "getClassesFromDbInfo");
1145
+ function getStylesFromDbInfo(dbInfoItem) {
1146
+ return dbInfoItem?.styles ?? [];
1147
+ }
1148
+ __name(getStylesFromDbInfo, "getStylesFromDbInfo");
1149
+ var dataFetcher = /* @__PURE__ */ __name((parent, parsedItem, diagramStates, nodes, edges, altFlag, look, classes) => {
1150
+ const itemId = parsedItem.id;
1151
+ const dbState = diagramStates.get(itemId);
1152
+ const classStr = getClassesFromDbInfo(dbState);
1153
+ const style = getStylesFromDbInfo(dbState);
1154
+ const config = getConfig2();
1155
+ log.info("dataFetcher parsedItem", parsedItem, dbState, style);
1156
+ if (itemId !== "root") {
1157
+ let shape = SHAPE_STATE;
1158
+ if (parsedItem.start === true) {
1159
+ shape = SHAPE_START;
1160
+ } else if (parsedItem.start === false) {
1161
+ shape = SHAPE_END;
1162
+ }
1163
+ if (parsedItem.type !== DEFAULT_STATE_TYPE) {
1164
+ shape = parsedItem.type;
1165
+ }
1166
+ if (!nodeDb.get(itemId)) {
1167
+ nodeDb.set(itemId, {
1168
+ id: itemId,
1169
+ shape,
1170
+ description: common_default.sanitizeText(itemId, config),
1171
+ cssClasses: `${classStr} ${CSS_DIAGRAM_STATE}`,
1172
+ cssStyles: style
1173
+ });
1174
+ }
1175
+ const newNode = nodeDb.get(itemId);
1176
+ if (parsedItem.description) {
1177
+ if (Array.isArray(newNode.description)) {
1178
+ newNode.shape = SHAPE_STATE_WITH_DESC;
1179
+ newNode.description.push(parsedItem.description);
1180
+ } else {
1181
+ if (newNode.description?.length && newNode.description.length > 0) {
1182
+ newNode.shape = SHAPE_STATE_WITH_DESC;
1183
+ if (newNode.description === itemId) {
1184
+ newNode.description = [parsedItem.description];
1185
+ } else {
1186
+ newNode.description = [newNode.description, parsedItem.description];
1187
+ }
1188
+ } else {
1189
+ newNode.shape = SHAPE_STATE;
1190
+ newNode.description = parsedItem.description;
1191
+ }
1192
+ }
1193
+ newNode.description = common_default.sanitizeTextOrArray(newNode.description, config);
1194
+ }
1195
+ if (newNode.description?.length === 1 && newNode.shape === SHAPE_STATE_WITH_DESC) {
1196
+ if (newNode.type === "group") {
1197
+ newNode.shape = SHAPE_GROUP;
1198
+ } else {
1199
+ newNode.shape = SHAPE_STATE;
1200
+ }
1201
+ }
1202
+ if (!newNode.type && parsedItem.doc) {
1203
+ log.info("Setting cluster for XCX", itemId, getDir2(parsedItem));
1204
+ newNode.type = "group";
1205
+ newNode.isGroup = true;
1206
+ newNode.dir = getDir2(parsedItem);
1207
+ newNode.explicitDir = parsedItem.doc.some((s) => s.stmt === "dir");
1208
+ newNode.shape = parsedItem.type === DIVIDER_TYPE ? SHAPE_DIVIDER : SHAPE_GROUP;
1209
+ newNode.cssClasses = `${newNode.cssClasses} ${CSS_DIAGRAM_CLUSTER} ${altFlag ? CSS_DIAGRAM_CLUSTER_ALT : ""}`;
1210
+ }
1211
+ const nodeData = {
1212
+ labelStyle: "",
1213
+ shape: newNode.shape,
1214
+ label: newNode.description,
1215
+ cssClasses: newNode.cssClasses,
1216
+ cssCompiledStyles: [],
1217
+ cssStyles: newNode.cssStyles,
1218
+ id: itemId,
1219
+ dir: newNode.dir,
1220
+ domId: stateDomId(itemId, graphItemCount),
1221
+ type: newNode.type,
1222
+ isGroup: newNode.type === "group",
1223
+ padding: 8,
1224
+ rx: 10,
1225
+ ry: 10,
1226
+ look,
1227
+ labelType: "markdown"
1228
+ };
1229
+ if (nodeData.shape === SHAPE_DIVIDER) {
1230
+ nodeData.label = "";
1231
+ }
1232
+ if (parent && parent.id !== "root") {
1233
+ log.trace("Setting node ", itemId, " to be child of its parent ", parent.id);
1234
+ nodeData.parentId = parent.id;
1235
+ }
1236
+ nodeData.centerLabel = true;
1237
+ if (parsedItem.note) {
1238
+ const noteData = {
1239
+ labelStyle: "",
1240
+ shape: SHAPE_NOTE,
1241
+ label: parsedItem.note.text,
1242
+ labelType: "markdown",
1243
+ cssClasses: CSS_DIAGRAM_NOTE,
1244
+ cssStyles: [],
1245
+ cssCompiledStyles: [],
1246
+ id: itemId + NOTE_ID + "-" + graphItemCount,
1247
+ domId: stateDomId(itemId, graphItemCount, NOTE),
1248
+ type: newNode.type,
1249
+ isGroup: newNode.type === "group",
1250
+ padding: config.flowchart?.padding,
1251
+ look,
1252
+ position: parsedItem.note.position
1253
+ };
1254
+ const parentNodeId = itemId + PARENT_ID;
1255
+ const groupData = {
1256
+ labelStyle: "",
1257
+ shape: SHAPE_NOTEGROUP,
1258
+ label: parsedItem.note.text,
1259
+ cssClasses: newNode.cssClasses,
1260
+ cssStyles: [],
1261
+ id: itemId + PARENT_ID,
1262
+ domId: stateDomId(itemId, graphItemCount, PARENT),
1263
+ type: "group",
1264
+ isGroup: true,
1265
+ padding: 16,
1266
+ look,
1267
+ position: parsedItem.note.position
1268
+ };
1269
+ graphItemCount++;
1270
+ groupData.id = parentNodeId;
1271
+ noteData.parentId = parentNodeId;
1272
+ insertOrUpdateNode(nodes, groupData, classes);
1273
+ insertOrUpdateNode(nodes, noteData, classes);
1274
+ insertOrUpdateNode(nodes, nodeData, classes);
1275
+ let from = itemId;
1276
+ let to = noteData.id;
1277
+ if (parsedItem.note.position === "left of") {
1278
+ from = noteData.id;
1279
+ to = itemId;
1280
+ }
1281
+ edges.push({
1282
+ id: from + "-" + to,
1283
+ start: from,
1284
+ end: to,
1285
+ arrowhead: "none",
1286
+ arrowTypeEnd: "",
1287
+ style: G_EDGE_STYLE,
1288
+ labelStyle: "",
1289
+ classes: CSS_EDGE_NOTE_EDGE,
1290
+ arrowheadStyle: G_EDGE_ARROWHEADSTYLE,
1291
+ labelpos: G_EDGE_LABELPOS,
1292
+ labelType: G_EDGE_LABELTYPE,
1293
+ thickness: G_EDGE_THICKNESS,
1294
+ look
1295
+ });
1296
+ } else {
1297
+ insertOrUpdateNode(nodes, nodeData, classes);
1298
+ }
1299
+ }
1300
+ if (parsedItem.doc) {
1301
+ log.trace("Adding nodes children ");
1302
+ setupDoc(parsedItem, parsedItem.doc, diagramStates, nodes, edges, !altFlag, look, classes);
1303
+ }
1304
+ }, "dataFetcher");
1305
+ var reset = /* @__PURE__ */ __name(() => {
1306
+ nodeDb.clear();
1307
+ graphItemCount = 0;
1308
+ }, "reset");
1309
+ var CONSTANTS = {
1310
+ START_NODE: "[*]",
1311
+ START_TYPE: "start",
1312
+ END_NODE: "[*]",
1313
+ END_TYPE: "end",
1314
+ COLOR_KEYWORD: "color",
1315
+ FILL_KEYWORD: "fill",
1316
+ BG_FILL: "bgFill",
1317
+ STYLECLASS_SEP: ","
1318
+ };
1319
+ var newClassesList = /* @__PURE__ */ __name(() => /* @__PURE__ */ new Map, "newClassesList");
1320
+ var newDoc = /* @__PURE__ */ __name(() => ({
1321
+ relations: [],
1322
+ states: /* @__PURE__ */ new Map,
1323
+ documents: {}
1324
+ }), "newDoc");
1325
+ var clone = /* @__PURE__ */ __name((o) => JSON.parse(JSON.stringify(o)), "clone");
1326
+ var StateDB = class {
1327
+ constructor(version) {
1328
+ this.version = version;
1329
+ this.nodes = [];
1330
+ this.edges = [];
1331
+ this.rootDoc = [];
1332
+ this.classes = newClassesList();
1333
+ this.documents = { root: newDoc() };
1334
+ this.currentDocument = this.documents.root;
1335
+ this.startEndCount = 0;
1336
+ this.dividerCnt = 0;
1337
+ this.links = /* @__PURE__ */ new Map;
1338
+ this.funs = [];
1339
+ this.getAccTitle = getAccTitle;
1340
+ this.setAccTitle = setAccTitle;
1341
+ this.getAccDescription = getAccDescription;
1342
+ this.setAccDescription = setAccDescription;
1343
+ this.setDiagramTitle = setDiagramTitle;
1344
+ this.getDiagramTitle = getDiagramTitle;
1345
+ this.clear();
1346
+ this.setRootDoc = this.setRootDoc.bind(this);
1347
+ this.getDividerId = this.getDividerId.bind(this);
1348
+ this.setDirection = this.setDirection.bind(this);
1349
+ this.trimColon = this.trimColon.bind(this);
1350
+ this.bindFunctions = this.bindFunctions.bind(this);
1351
+ }
1352
+ static {
1353
+ __name(this, "StateDB");
1354
+ }
1355
+ static {
1356
+ this.relationType = {
1357
+ AGGREGATION: 0,
1358
+ EXTENSION: 1,
1359
+ COMPOSITION: 2,
1360
+ DEPENDENCY: 3
1361
+ };
1362
+ }
1363
+ extract(statements) {
1364
+ this.clear(true);
1365
+ for (const item of Array.isArray(statements) ? statements : statements.doc) {
1366
+ switch (item.stmt) {
1367
+ case STMT_STATE:
1368
+ this.addState(item.id.trim(), item.type, item.doc, item.description, item.note);
1369
+ break;
1370
+ case STMT_RELATION:
1371
+ this.addRelation(item.state1, item.state2, item.description);
1372
+ break;
1373
+ case STMT_CLASSDEF:
1374
+ this.addStyleClass(item.id.trim(), item.classes);
1375
+ break;
1376
+ case STMT_STYLEDEF:
1377
+ this.handleStyleDef(item);
1378
+ break;
1379
+ case STMT_APPLYCLASS:
1380
+ this.setCssClass(item.id.trim(), item.styleClass);
1381
+ break;
1382
+ case "click":
1383
+ this.addLink(item.id, item.url, item.tooltip);
1384
+ break;
1385
+ }
1386
+ }
1387
+ const diagramStates = this.getStates();
1388
+ const config = getConfig2();
1389
+ reset();
1390
+ dataFetcher(undefined, this.getRootDocV2(), diagramStates, this.nodes, this.edges, true, config.look, this.classes);
1391
+ for (const node of this.nodes) {
1392
+ if (!Array.isArray(node.label)) {
1393
+ continue;
1394
+ }
1395
+ node.description = node.label.slice(1);
1396
+ if (node.isGroup && node.description.length > 0) {
1397
+ throw new Error(`Group nodes can only have label. Remove the additional description for node [${node.id}]`);
1398
+ }
1399
+ node.label = node.label[0];
1400
+ }
1401
+ }
1402
+ handleStyleDef(item) {
1403
+ const ids = item.id.trim().split(",");
1404
+ const styles = item.styleClass.split(",");
1405
+ for (const id of ids) {
1406
+ let state = this.getState(id);
1407
+ if (!state) {
1408
+ const trimmedId = id.trim();
1409
+ this.addState(trimmedId);
1410
+ state = this.getState(trimmedId);
1411
+ }
1412
+ if (state) {
1413
+ state.styles = styles.map((s) => s.replace(/;/g, "")?.trim());
1414
+ }
1415
+ }
1416
+ }
1417
+ setRootDoc(o) {
1418
+ log.info("Setting root doc", o);
1419
+ this.rootDoc = o;
1420
+ if (this.version === 1) {
1421
+ this.extract(o);
1422
+ } else {
1423
+ this.extract(this.getRootDocV2());
1424
+ }
1425
+ }
1426
+ docTranslator(parent, node, first) {
1427
+ if (node.stmt === STMT_RELATION) {
1428
+ this.docTranslator(parent, node.state1, true);
1429
+ this.docTranslator(parent, node.state2, false);
1430
+ return;
1431
+ }
1432
+ if (node.stmt === STMT_STATE) {
1433
+ if (node.id === CONSTANTS.START_NODE) {
1434
+ node.id = parent.id + (first ? "_start" : "_end");
1435
+ node.start = first;
1436
+ } else {
1437
+ node.id = node.id.trim();
1438
+ }
1439
+ }
1440
+ if (node.stmt !== STMT_ROOT && node.stmt !== STMT_STATE || !node.doc) {
1441
+ return;
1442
+ }
1443
+ const doc = [];
1444
+ let currentDoc = [];
1445
+ for (const stmt of node.doc) {
1446
+ if (stmt.type === DIVIDER_TYPE) {
1447
+ const newNode = clone(stmt);
1448
+ newNode.doc = clone(currentDoc);
1449
+ doc.push(newNode);
1450
+ currentDoc = [];
1451
+ } else {
1452
+ currentDoc.push(stmt);
1453
+ }
1454
+ }
1455
+ if (doc.length > 0 && currentDoc.length > 0) {
1456
+ const newNode = {
1457
+ stmt: STMT_STATE,
1458
+ id: generateId(),
1459
+ type: "divider",
1460
+ doc: clone(currentDoc)
1461
+ };
1462
+ doc.push(clone(newNode));
1463
+ node.doc = doc;
1464
+ }
1465
+ node.doc.forEach((docNode) => this.docTranslator(node, docNode, true));
1466
+ }
1467
+ getRootDocV2() {
1468
+ this.docTranslator({ id: STMT_ROOT, stmt: STMT_ROOT }, { id: STMT_ROOT, stmt: STMT_ROOT, doc: this.rootDoc }, true);
1469
+ return { id: STMT_ROOT, doc: this.rootDoc };
1470
+ }
1471
+ addState(id, type = DEFAULT_STATE_TYPE, doc = undefined, descr = undefined, note = undefined, classes = undefined, styles = undefined, textStyles = undefined) {
1472
+ const trimmedId = id?.trim();
1473
+ if (!this.currentDocument.states.has(trimmedId)) {
1474
+ log.info("Adding state ", trimmedId, descr);
1475
+ this.currentDocument.states.set(trimmedId, {
1476
+ stmt: STMT_STATE,
1477
+ id: trimmedId,
1478
+ descriptions: [],
1479
+ type,
1480
+ doc,
1481
+ note,
1482
+ classes: [],
1483
+ styles: [],
1484
+ textStyles: []
1485
+ });
1486
+ } else {
1487
+ const state = this.currentDocument.states.get(trimmedId);
1488
+ if (!state) {
1489
+ throw new Error(`State not found: ${trimmedId}`);
1490
+ }
1491
+ if (!state.doc) {
1492
+ state.doc = doc;
1493
+ }
1494
+ if (!state.type) {
1495
+ state.type = type;
1496
+ }
1497
+ }
1498
+ if (descr) {
1499
+ log.info("Setting state description", trimmedId, descr);
1500
+ const descriptions = Array.isArray(descr) ? descr : [descr];
1501
+ descriptions.forEach((des) => this.addDescription(trimmedId, des.trim()));
1502
+ }
1503
+ if (note) {
1504
+ const doc2 = this.currentDocument.states.get(trimmedId);
1505
+ if (!doc2) {
1506
+ throw new Error(`State not found: ${trimmedId}`);
1507
+ }
1508
+ doc2.note = note;
1509
+ doc2.note.text = common_default.sanitizeText(doc2.note.text, getConfig2());
1510
+ }
1511
+ if (classes) {
1512
+ log.info("Setting state classes", trimmedId, classes);
1513
+ const classesList = Array.isArray(classes) ? classes : [classes];
1514
+ classesList.forEach((cssClass) => this.setCssClass(trimmedId, cssClass.trim()));
1515
+ }
1516
+ if (styles) {
1517
+ log.info("Setting state styles", trimmedId, styles);
1518
+ const stylesList = Array.isArray(styles) ? styles : [styles];
1519
+ stylesList.forEach((style) => this.setStyle(trimmedId, style.trim()));
1520
+ }
1521
+ if (textStyles) {
1522
+ log.info("Setting state styles", trimmedId, styles);
1523
+ const textStylesList = Array.isArray(textStyles) ? textStyles : [textStyles];
1524
+ textStylesList.forEach((textStyle) => this.setTextStyle(trimmedId, textStyle.trim()));
1525
+ }
1526
+ }
1527
+ clear(saveCommon) {
1528
+ this.nodes = [];
1529
+ this.edges = [];
1530
+ this.funs = [this.setupToolTips.bind(this)];
1531
+ this.documents = { root: newDoc() };
1532
+ this.currentDocument = this.documents.root;
1533
+ this.startEndCount = 0;
1534
+ this.classes = newClassesList();
1535
+ if (!saveCommon) {
1536
+ this.links = /* @__PURE__ */ new Map;
1537
+ clear();
1538
+ }
1539
+ }
1540
+ getState(id) {
1541
+ return this.currentDocument.states.get(id);
1542
+ }
1543
+ getStates() {
1544
+ return this.currentDocument.states;
1545
+ }
1546
+ logDocuments() {
1547
+ log.info("Documents = ", this.documents);
1548
+ }
1549
+ getRelations() {
1550
+ return this.currentDocument.relations;
1551
+ }
1552
+ addLink(stateId, url, tooltip) {
1553
+ this.links.set(stateId, { url, tooltip });
1554
+ log.warn("Adding link", stateId, url, tooltip);
1555
+ }
1556
+ getLinks() {
1557
+ return this.links;
1558
+ }
1559
+ startIdIfNeeded(id = "") {
1560
+ if (id === CONSTANTS.START_NODE) {
1561
+ this.startEndCount++;
1562
+ return `${CONSTANTS.START_TYPE}${this.startEndCount}`;
1563
+ }
1564
+ return id;
1565
+ }
1566
+ startTypeIfNeeded(id = "", type = DEFAULT_STATE_TYPE) {
1567
+ return id === CONSTANTS.START_NODE ? CONSTANTS.START_TYPE : type;
1568
+ }
1569
+ endIdIfNeeded(id = "") {
1570
+ if (id === CONSTANTS.END_NODE) {
1571
+ this.startEndCount++;
1572
+ return `${CONSTANTS.END_TYPE}${this.startEndCount}`;
1573
+ }
1574
+ return id;
1575
+ }
1576
+ endTypeIfNeeded(id = "", type = DEFAULT_STATE_TYPE) {
1577
+ return id === CONSTANTS.END_NODE ? CONSTANTS.END_TYPE : type;
1578
+ }
1579
+ addRelationObjs(item1, item2, relationTitle = "") {
1580
+ const id1 = this.startIdIfNeeded(item1.id.trim());
1581
+ const type1 = this.startTypeIfNeeded(item1.id.trim(), item1.type);
1582
+ const id2 = this.startIdIfNeeded(item2.id.trim());
1583
+ const type2 = this.startTypeIfNeeded(item2.id.trim(), item2.type);
1584
+ this.addState(id1, type1, item1.doc, item1.description, item1.note, item1.classes, item1.styles, item1.textStyles);
1585
+ this.addState(id2, type2, item2.doc, item2.description, item2.note, item2.classes, item2.styles, item2.textStyles);
1586
+ this.currentDocument.relations.push({
1587
+ id1,
1588
+ id2,
1589
+ relationTitle: common_default.sanitizeText(relationTitle, getConfig2())
1590
+ });
1591
+ }
1592
+ addRelation(item1, item2, title) {
1593
+ if (typeof item1 === "object" && typeof item2 === "object") {
1594
+ this.addRelationObjs(item1, item2, title);
1595
+ } else if (typeof item1 === "string" && typeof item2 === "string") {
1596
+ const id1 = this.startIdIfNeeded(item1.trim());
1597
+ const type1 = this.startTypeIfNeeded(item1);
1598
+ const id2 = this.endIdIfNeeded(item2.trim());
1599
+ const type2 = this.endTypeIfNeeded(item2);
1600
+ this.addState(id1, type1);
1601
+ this.addState(id2, type2);
1602
+ this.currentDocument.relations.push({
1603
+ id1,
1604
+ id2,
1605
+ relationTitle: title ? common_default.sanitizeText(title, getConfig2()) : undefined
1606
+ });
1607
+ }
1608
+ }
1609
+ addDescription(id, descr) {
1610
+ const theState = this.currentDocument.states.get(id);
1611
+ const _descr = descr.startsWith(":") ? descr.replace(":", "").trim() : descr;
1612
+ theState?.descriptions?.push(common_default.sanitizeText(_descr, getConfig2()));
1613
+ }
1614
+ cleanupLabel(label) {
1615
+ return label.startsWith(":") ? label.slice(2).trim() : label.trim();
1616
+ }
1617
+ getDividerId() {
1618
+ this.dividerCnt++;
1619
+ return `divider-id-${this.dividerCnt}`;
1620
+ }
1621
+ addStyleClass(id, styleAttributes = "") {
1622
+ if (!this.classes.has(id)) {
1623
+ this.classes.set(id, { id, styles: [], textStyles: [] });
1624
+ }
1625
+ const foundClass = this.classes.get(id);
1626
+ if (styleAttributes && foundClass) {
1627
+ styleAttributes.split(CONSTANTS.STYLECLASS_SEP).forEach((attrib) => {
1628
+ const fixedAttrib = attrib.replace(/([^;]*);/, "$1").trim();
1629
+ if (RegExp(CONSTANTS.COLOR_KEYWORD).exec(attrib)) {
1630
+ const newStyle1 = fixedAttrib.replace(CONSTANTS.FILL_KEYWORD, CONSTANTS.BG_FILL);
1631
+ const newStyle2 = newStyle1.replace(CONSTANTS.COLOR_KEYWORD, CONSTANTS.FILL_KEYWORD);
1632
+ foundClass.textStyles.push(newStyle2);
1633
+ }
1634
+ foundClass.styles.push(fixedAttrib);
1635
+ });
1636
+ }
1637
+ }
1638
+ getClasses() {
1639
+ return this.classes;
1640
+ }
1641
+ setupToolTips(element) {
1642
+ const tooltipElem = createTooltip();
1643
+ const svg = select_default(element).select("svg");
1644
+ const nodes = svg.selectAll("g.node, g.rough-node");
1645
+ nodes.on("mouseover", (e) => {
1646
+ const el = select_default(e.currentTarget);
1647
+ const title = el.attr("title");
1648
+ if (title === null) {
1649
+ return;
1650
+ }
1651
+ const rect = e.currentTarget?.getBoundingClientRect();
1652
+ tooltipElem.transition().duration(200).style("opacity", ".9");
1653
+ tooltipElem.style("left", window.scrollX + rect.left + (rect.right - rect.left) / 2 + "px").style("top", window.scrollY + rect.bottom + "px");
1654
+ tooltipElem.html(dompurify_shim_default.sanitize(title));
1655
+ el.classed("hover", true);
1656
+ }).on("mouseout", (e) => {
1657
+ tooltipElem.transition().duration(500).style("opacity", 0);
1658
+ const el = select_default(e.currentTarget);
1659
+ el.classed("hover", false);
1660
+ });
1661
+ }
1662
+ setCssClass(itemIds, cssClassName) {
1663
+ itemIds.split(",").forEach((id) => {
1664
+ let foundState = this.getState(id);
1665
+ if (!foundState) {
1666
+ const trimmedId = id.trim();
1667
+ this.addState(trimmedId);
1668
+ foundState = this.getState(trimmedId);
1669
+ }
1670
+ foundState?.classes?.push(cssClassName);
1671
+ });
1672
+ }
1673
+ setStyle(itemId, styleText) {
1674
+ this.getState(itemId)?.styles?.push(styleText);
1675
+ }
1676
+ setTextStyle(itemId, cssClassName) {
1677
+ this.getState(itemId)?.textStyles?.push(cssClassName);
1678
+ }
1679
+ bindFunctions(element) {
1680
+ this.funs.forEach((fun) => {
1681
+ fun(element);
1682
+ });
1683
+ }
1684
+ getDirectionStatement() {
1685
+ return this.rootDoc.find((doc) => doc.stmt === STMT_DIRECTION);
1686
+ }
1687
+ getDirection() {
1688
+ return this.getDirectionStatement()?.value ?? DEFAULT_DIAGRAM_DIRECTION;
1689
+ }
1690
+ setDirection(dir) {
1691
+ const doc = this.getDirectionStatement();
1692
+ if (doc) {
1693
+ doc.value = dir;
1694
+ } else {
1695
+ this.rootDoc.unshift({ stmt: STMT_DIRECTION, value: dir });
1696
+ }
1697
+ }
1698
+ trimColon(str) {
1699
+ return str.startsWith(":") ? str.slice(1).trim() : str.trim();
1700
+ }
1701
+ getData() {
1702
+ const config = getConfig2();
1703
+ return {
1704
+ nodes: this.nodes,
1705
+ edges: this.edges,
1706
+ other: {},
1707
+ config,
1708
+ direction: getDir(this.getRootDocV2())
1709
+ };
1710
+ }
1711
+ getConfig() {
1712
+ return getConfig2().state;
1713
+ }
1714
+ };
1715
+ var getStyles = /* @__PURE__ */ __name((options) => `
1716
+ defs [id$="-barbEnd"] {
1717
+ fill: ${options.transitionColor};
1718
+ stroke: ${options.transitionColor};
1719
+ }
1720
+ g.stateGroup text {
1721
+ fill: ${options.nodeBorder};
1722
+ stroke: none;
1723
+ font-size: 10px;
1724
+ }
1725
+ g.stateGroup text {
1726
+ fill: ${options.textColor};
1727
+ stroke: none;
1728
+ font-size: 10px;
1729
+
1730
+ }
1731
+ g.stateGroup .state-title {
1732
+ font-weight: bolder;
1733
+ fill: ${options.stateLabelColor};
1734
+ }
1735
+
1736
+ g.stateGroup rect {
1737
+ fill: ${options.mainBkg};
1738
+ stroke: ${options.nodeBorder};
1739
+ }
1740
+
1741
+ g.stateGroup line {
1742
+ stroke: ${options.lineColor};
1743
+ stroke-width: ${options.strokeWidth || 1};
1744
+ }
1745
+
1746
+ .transition {
1747
+ stroke: ${options.transitionColor};
1748
+ stroke-width: ${options.strokeWidth || 1};
1749
+ fill: none;
1750
+ }
1751
+
1752
+ .stateGroup .composit {
1753
+ fill: ${options.background};
1754
+ border-bottom: 1px
1755
+ }
1756
+
1757
+ .stateGroup .alt-composit {
1758
+ fill: #e0e0e0;
1759
+ border-bottom: 1px
1760
+ }
1761
+
1762
+ .state-note {
1763
+ stroke: ${options.noteBorderColor};
1764
+ fill: ${options.noteBkgColor};
1765
+
1766
+ text {
1767
+ fill: ${options.noteTextColor};
1768
+ stroke: none;
1769
+ font-size: 10px;
1770
+ }
1771
+ }
1772
+
1773
+ .stateLabel .box {
1774
+ stroke: none;
1775
+ stroke-width: 0;
1776
+ fill: ${options.mainBkg};
1777
+ opacity: 0.5;
1778
+ }
1779
+
1780
+ .edgeLabel .label rect {
1781
+ fill: ${options.labelBackgroundColor};
1782
+ opacity: 0.5;
1783
+ }
1784
+ .edgeLabel {
1785
+ background-color: ${options.edgeLabelBackground};
1786
+ p {
1787
+ background-color: ${options.edgeLabelBackground};
1788
+ }
1789
+ rect {
1790
+ opacity: 0.5;
1791
+ background-color: ${options.edgeLabelBackground};
1792
+ fill: ${options.edgeLabelBackground};
1793
+ }
1794
+ text-align: center;
1795
+ }
1796
+ .edgeLabel .label text {
1797
+ fill: ${options.transitionLabelColor || options.tertiaryTextColor};
1798
+ }
1799
+ .label div .edgeLabel {
1800
+ color: ${options.transitionLabelColor || options.tertiaryTextColor};
1801
+ }
1802
+
1803
+ .stateLabel text {
1804
+ fill: ${options.stateLabelColor};
1805
+ font-size: 10px;
1806
+ font-weight: bold;
1807
+ }
1808
+
1809
+ .node circle.state-start {
1810
+ fill: ${options.specialStateColor};
1811
+ stroke: ${options.specialStateColor};
1812
+ }
1813
+
1814
+ .node .fork-join {
1815
+ fill: ${options.specialStateColor};
1816
+ stroke: ${options.specialStateColor};
1817
+ }
1818
+
1819
+ .node circle.state-end {
1820
+ fill: ${options.innerEndBackground};
1821
+ stroke: ${options.background};
1822
+ stroke-width: 1.5
1823
+ }
1824
+ .end-state-inner {
1825
+ fill: ${options.compositeBackground || options.background};
1826
+ // stroke: ${options.background};
1827
+ stroke-width: 1.5
1828
+ }
1829
+
1830
+ .node rect {
1831
+ fill: ${options.stateBkg || options.mainBkg};
1832
+ stroke: ${options.stateBorder || options.nodeBorder};
1833
+ stroke-width: ${options.strokeWidth || 1}px;
1834
+ }
1835
+ .node polygon {
1836
+ fill: ${options.mainBkg};
1837
+ stroke: ${options.stateBorder || options.nodeBorder};;
1838
+ stroke-width: ${options.strokeWidth || 1}px;
1839
+ }
1840
+ [id$="-barbEnd"] {
1841
+ fill: ${options.lineColor};
1842
+ }
1843
+
1844
+ .statediagram-cluster rect {
1845
+ fill: ${options.compositeTitleBackground};
1846
+ stroke: ${options.stateBorder || options.nodeBorder};
1847
+ stroke-width: ${options.strokeWidth || 1}px;
1848
+ }
1849
+
1850
+ .cluster-label, .nodeLabel {
1851
+ color: ${options.stateLabelColor};
1852
+ // line-height: 1;
1853
+ }
1854
+
1855
+ .statediagram-cluster rect.outer {
1856
+ rx: 5px;
1857
+ ry: 5px;
1858
+ }
1859
+ .statediagram-state .divider {
1860
+ stroke: ${options.stateBorder || options.nodeBorder};
1861
+ }
1862
+
1863
+ .statediagram-state .title-state {
1864
+ rx: 5px;
1865
+ ry: 5px;
1866
+ }
1867
+ .statediagram-cluster.statediagram-cluster .inner {
1868
+ fill: ${options.compositeBackground || options.background};
1869
+ }
1870
+ .statediagram-cluster.statediagram-cluster-alt .inner {
1871
+ fill: ${options.altBackground ? options.altBackground : "#efefef"};
1872
+ }
1873
+
1874
+ .statediagram-cluster .inner {
1875
+ rx:0;
1876
+ ry:0;
1877
+ }
1878
+
1879
+ .statediagram-state rect.basic {
1880
+ rx: 5px;
1881
+ ry: 5px;
1882
+ }
1883
+ .statediagram-state rect.divider {
1884
+ stroke-dasharray: 10,10;
1885
+ fill: ${options.altBackground ? options.altBackground : "#efefef"};
1886
+ }
1887
+
1888
+ .note-edge {
1889
+ stroke-dasharray: 5;
1890
+ }
1891
+
1892
+ .statediagram-note rect {
1893
+ fill: ${options.noteBkgColor};
1894
+ stroke: ${options.noteBorderColor};
1895
+ stroke-width: 1px;
1896
+ rx: 0;
1897
+ ry: 0;
1898
+ }
1899
+ .statediagram-note rect {
1900
+ fill: ${options.noteBkgColor};
1901
+ stroke: ${options.noteBorderColor};
1902
+ stroke-width: 1px;
1903
+ rx: 0;
1904
+ ry: 0;
1905
+ }
1906
+
1907
+ .statediagram-note text {
1908
+ fill: ${options.noteTextColor};
1909
+ }
1910
+
1911
+ .statediagram-note .nodeLabel {
1912
+ color: ${options.noteTextColor};
1913
+ }
1914
+ .statediagram .edgeLabel {
1915
+ color: red; // ${options.noteTextColor};
1916
+ }
1917
+
1918
+ [id$="-dependencyStart"], [id$="-dependencyEnd"] {
1919
+ fill: ${options.lineColor};
1920
+ stroke: ${options.lineColor};
1921
+ stroke-width: ${options.strokeWidth || 1};
1922
+ }
1923
+
1924
+ .statediagramTitleText {
1925
+ text-anchor: middle;
1926
+ font-size: 18px;
1927
+ fill: ${options.textColor};
1928
+ }
1929
+
1930
+ [data-look="neo"].statediagram-cluster rect {
1931
+ fill: ${options.mainBkg};
1932
+ stroke: ${options.useGradient ? "url(" + options.svgId + "-gradient)" : options.stateBorder || options.nodeBorder};
1933
+ stroke-width: ${options.strokeWidth ?? 1};
1934
+ }
1935
+ [data-look="neo"].statediagram-cluster rect.outer {
1936
+ rx: ${options.radius}px;
1937
+ ry: ${options.radius}px;
1938
+ filter: ${options.dropShadow ? options.dropShadow.replace("url(#drop-shadow)", `url(${options.svgId}-drop-shadow)`) : "none"}
1939
+ }
1940
+ `, "getStyles");
1941
+ var styles_default = getStyles;
1942
+
1943
+ export { stateDiagram_default, stateRenderer_v3_unified_default, StateDB, styles_default };