flea-qml 0.0.0-stage → 0.2.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 (637) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +511 -2
  3. package/THIRD-PARTY-NOTICES.md +29 -0
  4. package/demos/App.java +5 -0
  5. package/demos/Dockerfile +4 -0
  6. package/demos/Main.kt +3 -0
  7. package/demos/Program.cs +1 -0
  8. package/demos/README.md +12 -0
  9. package/demos/app.dart +3 -0
  10. package/demos/app.deb +0 -0
  11. package/demos/app.js +1 -0
  12. package/demos/backup.tar +0 -0
  13. package/demos/budget.xlsx +0 -0
  14. package/demos/build.sh +2 -0
  15. package/demos/bundle.zip +0 -0
  16. package/demos/clip.mp4 +0 -0
  17. package/demos/data.sqlite +0 -0
  18. package/demos/disk.iso +0 -0
  19. package/demos/engine.cpp +5 -0
  20. package/demos/firmware.bin +0 -0
  21. package/demos/flake.nix +4 -0
  22. package/demos/folder/inside.txt +1 -0
  23. package/demos/font.ttf +0 -0
  24. package/demos/index.html +5 -0
  25. package/demos/index.php +2 -0
  26. package/demos/init.lua +1 -0
  27. package/demos/letter.docx +0 -0
  28. package/demos/lib.rs +3 -0
  29. package/demos/main.c +6 -0
  30. package/demos/main.h +3 -0
  31. package/demos/math-and-diagrams.md +200 -0
  32. package/demos/notes.tar.gz +0 -0
  33. package/demos/notes.txt +3 -0
  34. package/demos/photo.png +0 -0
  35. package/demos/program +2 -0
  36. package/demos/report.pdf +32 -0
  37. package/demos/script.py +1 -0
  38. package/demos/server.go +7 -0
  39. package/demos/settings.json +4 -0
  40. package/demos/slides.pptx +0 -0
  41. package/demos/song.mp3 +0 -0
  42. package/demos/style.css +4 -0
  43. package/demos/tool.rb +1 -0
  44. package/demos/types.ts +2 -0
  45. package/docs/pele.md +23 -0
  46. package/docs/protocol.md +3420 -0
  47. package/docs/temml.md +63 -0
  48. package/index.js +107 -0
  49. package/package.json +34 -4
  50. package/src/archive.js +407 -0
  51. package/src/archiveops.js +728 -0
  52. package/src/backend.js +369 -0
  53. package/src/bulkrename.js +95 -0
  54. package/src/clip-host.js +76 -0
  55. package/src/clip.js +462 -0
  56. package/src/code.js +168 -0
  57. package/src/compare.js +74 -0
  58. package/src/create.js +128 -0
  59. package/src/dirsize.js +147 -0
  60. package/src/figure-svg.js +530 -0
  61. package/src/figure-thread.js +23 -0
  62. package/src/figure.js +132 -0
  63. package/src/find.js +55 -0
  64. package/src/flea.js +39 -0
  65. package/src/fsinfo.js +39 -0
  66. package/src/highlight.js +141 -0
  67. package/src/html.js +52 -0
  68. package/src/kinds.js +89 -0
  69. package/src/listing.js +130 -0
  70. package/src/markdown-html.js +317 -0
  71. package/src/mathml.js +186 -0
  72. package/src/menu.js +180 -0
  73. package/src/meta.js +135 -0
  74. package/src/office.js +810 -0
  75. package/src/order.js +100 -0
  76. package/src/peek.js +49 -0
  77. package/src/pele-wrapper.js +695 -0
  78. package/src/permissions.js +180 -0
  79. package/src/places.js +313 -0
  80. package/src/preview-language.js +10 -0
  81. package/src/terminal-server.js +95 -0
  82. package/src/terminal-shell.js +26 -0
  83. package/src/transfer.js +669 -0
  84. package/src/trash-record.js +41 -0
  85. package/src/trash.js +210 -0
  86. package/src/trashbrowse.js +327 -0
  87. package/src/uistate.js +393 -0
  88. package/src/uistore.js +168 -0
  89. package/src/vendor/LICENSES/Apache-2.0.txt +202 -0
  90. package/src/vendor/LICENSES/MIT-katex-2015.txt +27 -0
  91. package/src/vendor/LICENSES/MIT-katex.txt +21 -0
  92. package/src/vendor/LICENSES/MIT-mermaid.txt +21 -0
  93. package/src/vendor/LICENSES/MIT-pele.txt +40 -0
  94. package/src/vendor/LICENSES/MIT-perseus.txt +18 -0
  95. package/src/vendor/LICENSES/MIT-temml.txt +21 -0
  96. package/src/vendor/pele.js +145 -0
  97. package/src/vendor/temml.mjs +14708 -0
  98. package/src/watch.js +98 -0
  99. package/src/wayland/client.js +109 -0
  100. package/src/wayland/protocol.js +55 -0
  101. package/src/wayland/protocols/ext-data-control-v1.xml +276 -0
  102. package/src/wayland/protocols/wayland.xml +3248 -0
  103. package/src/wayland/protocols/wlr-data-control-unstable-v1.xml +278 -0
  104. package/src/wayland/resource-io.js +6 -0
  105. package/src/wayland/socket-discovery.js +26 -0
  106. package/src/wayland/transport-posix.js +120 -0
  107. package/src/wayland/transport-win32.js +11 -0
  108. package/src/wayland/transport.js +3 -0
  109. package/src/wayland/win32-resources.js +80 -0
  110. package/src/wayland/win32-wire.js +62 -0
  111. package/test/archive.test.js +80 -0
  112. package/test/bench-markdown-scroll.mjs +190 -0
  113. package/test/clip-host.test.js +113 -0
  114. package/test/code-preview.test.js +35 -0
  115. package/test/compare-ui-paths.test.js +24 -0
  116. package/test/compare.test.js +54 -0
  117. package/test/delete-trash.test.js +67 -0
  118. package/test/dirsize.test.js +138 -0
  119. package/test/file-ops.test.js +307 -0
  120. package/test/file-url.test.js +24 -0
  121. package/test/find-contents.test.js +161 -0
  122. package/test/find-input.test.js +66 -0
  123. package/test/fixtures/pele-parity.json +1006 -0
  124. package/test/highlight-launcher.test.js +35 -0
  125. package/test/html-preview.test.js +22 -0
  126. package/test/input.test.js +15 -0
  127. package/test/keymap.test.js +26 -0
  128. package/test/language-icons.test.js +36 -0
  129. package/test/launcher.test.js +51 -0
  130. package/test/manual-archive-here-ui.mjs +47 -0
  131. package/test/manual-code-scroll.mjs +28 -0
  132. package/test/manual-column-scroll.mjs +24 -0
  133. package/test/manual-compare-ui.mjs +20 -0
  134. package/test/manual-find-status.mjs +37 -0
  135. package/test/manual-folder-focus.mjs +63 -0
  136. package/test/manual-html-security.mjs +23 -0
  137. package/test/manual-html-ui.mjs +30 -0
  138. package/test/manual-syntax-preview.mjs +26 -0
  139. package/test/manual-terminal-lifecycle.mjs +42 -0
  140. package/test/manual-terminal-navigation.mjs +48 -0
  141. package/test/manual-terminal-ui.mjs +47 -0
  142. package/test/manual-trash-ui.mjs +86 -0
  143. package/test/markdown-diagrams.test.js +93 -0
  144. package/test/markdown-html.test.js +105 -0
  145. package/test/mathml.test.js +92 -0
  146. package/test/menu-transfer.test.js +57 -0
  147. package/test/office-preview.test.js +154 -0
  148. package/test/pele-parity.test.js +28 -0
  149. package/test/places.test.js +134 -0
  150. package/test/preview-keys.test.js +60 -0
  151. package/test/preview-language.test.js +22 -0
  152. package/test/status-filename.test.js +20 -0
  153. package/test/transfer-replace-merge.test.js +187 -0
  154. package/test/trash-address.test.js +23 -0
  155. package/test/trash-view.test.js +37 -0
  156. package/test/trashbrowse.test.js +135 -0
  157. package/ui/AboutFacts.qml +78 -0
  158. package/ui/ArchiveCards.qml +95 -0
  159. package/ui/ArchiveCompressDialog.qml +378 -0
  160. package/ui/ArchiveHereConfirm.qml +127 -0
  161. package/ui/ArchivePasswordDialog.qml +257 -0
  162. package/ui/Backend.qml +775 -0
  163. package/ui/BulkOldNames.qml +47 -0
  164. package/ui/BulkRenameDialog.qml +380 -0
  165. package/ui/CardFrame.qml +67 -0
  166. package/ui/CardScroll.qml +79 -0
  167. package/ui/CheckBox.qml +73 -0
  168. package/ui/ChromeBar.qml +360 -0
  169. package/ui/ChromeButton.qml +131 -0
  170. package/ui/ChromeModes.qml +43 -0
  171. package/ui/CodeLines.qml +256 -0
  172. package/ui/CodeRefusal.qml +52 -0
  173. package/ui/CollideConfirm.qml +147 -0
  174. package/ui/CollideHost.qml +167 -0
  175. package/ui/ColumnPane.qml +525 -0
  176. package/ui/ColumnRow.qml +380 -0
  177. package/ui/ColumnsArea.qml +594 -0
  178. package/ui/ColumnsLanding.qml +147 -0
  179. package/ui/CompareView.qml +321 -0
  180. package/ui/ContextMenu.qml +743 -0
  181. package/ui/ConvertDialog.qml +456 -0
  182. package/ui/CountedWorker.qml +7 -0
  183. package/ui/Crumb.qml +64 -0
  184. package/ui/CrumbDrop.qml +25 -0
  185. package/ui/CsvTable.qml +394 -0
  186. package/ui/CursorMark.qml +41 -0
  187. package/ui/DefaultClaim.qml +130 -0
  188. package/ui/DeviceLock.qml +47 -0
  189. package/ui/DeviceMounts.qml +540 -0
  190. package/ui/DialogButton.qml +150 -0
  191. package/ui/DialogField.qml +147 -0
  192. package/ui/DialogHeader.qml +31 -0
  193. package/ui/DialogScrim.qml +20 -0
  194. package/ui/DialogTitle.qml +37 -0
  195. package/ui/Divider.qml +9 -0
  196. package/ui/DropInto.qml +126 -0
  197. package/ui/DropTarget.qml +35 -0
  198. package/ui/DropboxMark.qml +60 -0
  199. package/ui/EmptyState.qml +150 -0
  200. package/ui/EscapeHint.qml +11 -0
  201. package/ui/FactsTable.qml +54 -0
  202. package/ui/FastScrollHandler.qml +476 -0
  203. package/ui/FatNamesConfirm.qml +157 -0
  204. package/ui/Favourites.qml +143 -0
  205. package/ui/FigureService.qml +120 -0
  206. package/ui/FileDrag.qml +267 -0
  207. package/ui/FilterStrip.qml +133 -0
  208. package/ui/FitMetrics.qml +22 -0
  209. package/ui/FlashDriveRows.qml +137 -0
  210. package/ui/FlashHost.qml +72 -0
  211. package/ui/FlashImageRow.qml +104 -0
  212. package/ui/FlashRunner.qml +119 -0
  213. package/ui/FlashStepRow.qml +172 -0
  214. package/ui/FlashStrip.qml +38 -0
  215. package/ui/FlashView.qml +397 -0
  216. package/ui/FleaMark.qml +88 -0
  217. package/ui/FlyoutFade.qml +23 -0
  218. package/ui/FontPane.qml +170 -0
  219. package/ui/Glass.qml +114 -0
  220. package/ui/GlassTagger.qml +59 -0
  221. package/ui/Glyph.qml +64 -0
  222. package/ui/GlyphSolid.qml +22 -0
  223. package/ui/GridArea.qml +664 -0
  224. package/ui/GridTile.qml +325 -0
  225. package/ui/GvfsBridge.qml +164 -0
  226. package/ui/Header.qml +433 -0
  227. package/ui/HoverTimers.qml +39 -0
  228. package/ui/HtmlClip.qml +30 -0
  229. package/ui/HtmlPane.qml +63 -0
  230. package/ui/HyprlandMark.qml +45 -0
  231. package/ui/Ipc.qml +1005 -0
  232. package/ui/IpcControls.qml +7 -0
  233. package/ui/IpcMenuState.qml +48 -0
  234. package/ui/IpcPreviewState.qml +185 -0
  235. package/ui/JumpPath.qml +51 -0
  236. package/ui/KeymapSheet.qml +561 -0
  237. package/ui/KeymapSheetResult.qml +89 -0
  238. package/ui/KindStack.qml +40 -0
  239. package/ui/LangMark.qml +51 -0
  240. package/ui/LangMarkLoader.qml +26 -0
  241. package/ui/List.qml +480 -0
  242. package/ui/LoadingState.qml +54 -0
  243. package/ui/LocalSend.qml +56 -0
  244. package/ui/LocalSendMark.qml +73 -0
  245. package/ui/MarkdownBlockView.qml +311 -0
  246. package/ui/MarkdownBlocks.qml +35 -0
  247. package/ui/MarkdownFigure.qml +254 -0
  248. package/ui/MarkdownImages.qml +72 -0
  249. package/ui/MarkdownList.qml +81 -0
  250. package/ui/MarkdownMathsText.qml +97 -0
  251. package/ui/MarkdownPane.qml +83 -0
  252. package/ui/MarkdownPictures.qml +41 -0
  253. package/ui/MarkdownQuote.qml +52 -0
  254. package/ui/MarkdownRemote.qml +82 -0
  255. package/ui/MarkdownSource.qml +155 -0
  256. package/ui/MarkdownTable.qml +222 -0
  257. package/ui/MarkdownTableScroll.qml +64 -0
  258. package/ui/MarkdownTableWheel.qml +126 -0
  259. package/ui/MarkdownText.qml +87 -0
  260. package/ui/MarkdownWorker.js +132 -0
  261. package/ui/MatchText.qml +99 -0
  262. package/ui/MediaSession.qml +38 -0
  263. package/ui/MediaSound.qml +26 -0
  264. package/ui/MediaStrip.qml +191 -0
  265. package/ui/MediaTrack.qml +36 -0
  266. package/ui/MediaVolume.qml +54 -0
  267. package/ui/MenuActionDialog.qml +396 -0
  268. package/ui/MenuEdgeFade.qml +24 -0
  269. package/ui/MenuHost.qml +227 -0
  270. package/ui/MenuRow.qml +351 -0
  271. package/ui/MountListing.qml +100 -0
  272. package/ui/NetworkDialog.qml +435 -0
  273. package/ui/NetworkForm.qml +426 -0
  274. package/ui/NetworkMounts.qml +913 -0
  275. package/ui/NetworkPlaces.qml +127 -0
  276. package/ui/OpenWithDialog.qml +613 -0
  277. package/ui/Opener.qml +95 -0
  278. package/ui/Pane.qml +1320 -0
  279. package/ui/PaneMenuActions.qml +527 -0
  280. package/ui/PanePath.qml +90 -0
  281. package/ui/PaneRail.qml +268 -0
  282. package/ui/PaneStates.qml +88 -0
  283. package/ui/PaneSwap.qml +339 -0
  284. package/ui/PaneWire.qml +601 -0
  285. package/ui/ParkedWait.qml +9 -0
  286. package/ui/PathEntry.qml +186 -0
  287. package/ui/PathJump.qml +400 -0
  288. package/ui/PdfViewer.qml +297 -0
  289. package/ui/PermissionsDialog.qml +658 -0
  290. package/ui/PermissionsHeadings.qml +31 -0
  291. package/ui/PhoneMounts.qml +67 -0
  292. package/ui/PickerAnswers.qml +75 -0
  293. package/ui/PickerBox.qml +26 -0
  294. package/ui/PickerChrome.qml +295 -0
  295. package/ui/PickerFilter.qml +97 -0
  296. package/ui/PickerGrid.qml +308 -0
  297. package/ui/PickerHeader.qml +28 -0
  298. package/ui/PickerLifecycle.qml +27 -0
  299. package/ui/PickerList.qml +218 -0
  300. package/ui/PickerListing.qml +149 -0
  301. package/ui/PickerPathBar.qml +127 -0
  302. package/ui/PickerPlaces.qml +189 -0
  303. package/ui/PickerRecent.qml +92 -0
  304. package/ui/PickerSave.qml +101 -0
  305. package/ui/PickerSelection.qml +155 -0
  306. package/ui/PickerWindow.qml +846 -0
  307. package/ui/PowerSectorsReader.qml +10 -0
  308. package/ui/PrebuildDriver.qml +146 -0
  309. package/ui/Preview.qml +1005 -0
  310. package/ui/PreviewAnimation.qml +24 -0
  311. package/ui/PreviewArchive.qml +91 -0
  312. package/ui/PreviewColumn.qml +553 -0
  313. package/ui/PreviewEdge.qml +63 -0
  314. package/ui/PreviewFacts.qml +30 -0
  315. package/ui/PreviewFactsLine.qml +34 -0
  316. package/ui/PreviewHtml.qml +233 -0
  317. package/ui/PreviewImage.qml +253 -0
  318. package/ui/PreviewImagePan.qml +13 -0
  319. package/ui/PreviewImageSharp.qml +32 -0
  320. package/ui/PreviewLines.qml +106 -0
  321. package/ui/PreviewMarkdown.qml +706 -0
  322. package/ui/PreviewMedia.qml +250 -0
  323. package/ui/PreviewPdf.qml +482 -0
  324. package/ui/PreviewScroll.qml +201 -0
  325. package/ui/PreviewSwap.qml +335 -0
  326. package/ui/PreviewText.qml +149 -0
  327. package/ui/ProtocolChip.qml +18 -0
  328. package/ui/QuickLookArchive.qml +41 -0
  329. package/ui/QuickLookBar.qml +103 -0
  330. package/ui/QuickLookPrepare.qml +355 -0
  331. package/ui/QuickLookSwap.qml +10 -0
  332. package/ui/QuickLookWarm.qml +65 -0
  333. package/ui/RailDrop.qml +155 -0
  334. package/ui/RailHeading.qml +19 -0
  335. package/ui/RailPlaces.qml +38 -0
  336. package/ui/RailTrashRow.qml +67 -0
  337. package/ui/RenameField.qml +353 -0
  338. package/ui/RendererRetry.qml +11 -0
  339. package/ui/ResizeHandle.qml +52 -0
  340. package/ui/Reveal.qml +54 -0
  341. package/ui/Row.qml +476 -0
  342. package/ui/RowDrag.qml +213 -0
  343. package/ui/RowDropTarget.qml +27 -0
  344. package/ui/RunCard.qml +286 -0
  345. package/ui/Scripts.qml +65 -0
  346. package/ui/SearchStrip.qml +232 -0
  347. package/ui/SelectionBand.qml +140 -0
  348. package/ui/SelectionPreview.qml +370 -0
  349. package/ui/SettingsFavourite.qml +122 -0
  350. package/ui/SettingsGroup.qml +96 -0
  351. package/ui/SettingsHint.qml +12 -0
  352. package/ui/SettingsMetrics.qml +29 -0
  353. package/ui/SettingsPane.qml +178 -0
  354. package/ui/SettingsPanel.qml +547 -0
  355. package/ui/SettingsRail.qml +128 -0
  356. package/ui/SettingsRow.qml +409 -0
  357. package/ui/SettingsRuler.qml +85 -0
  358. package/ui/SettingsSegment.qml +85 -0
  359. package/ui/ShareBrowser.qml +113 -0
  360. package/ui/ShareLink.qml +67 -0
  361. package/ui/ShelfPins.qml +101 -0
  362. package/ui/Sidebar.qml +728 -0
  363. package/ui/SidebarRow.qml +358 -0
  364. package/ui/Spinner.qml +60 -0
  365. package/ui/StableModel.qml +89 -0
  366. package/ui/StateMessage.qml +84 -0
  367. package/ui/StatusBar.qml +512 -0
  368. package/ui/StatusFileName.qml +27 -0
  369. package/ui/TabBar.qml +673 -0
  370. package/ui/TabDragGeometry.qml +60 -0
  371. package/ui/TagMenuMark.qml +52 -0
  372. package/ui/TagRailSection.qml +53 -0
  373. package/ui/TagSlot.qml +40 -0
  374. package/ui/TagState.qml +150 -0
  375. package/ui/TagSwatch.qml +28 -0
  376. package/ui/Taildrop.qml +86 -0
  377. package/ui/TailscaleMark.qml +50 -0
  378. package/ui/TerminalService.qml +69 -0
  379. package/ui/TerminalTab.qml +48 -0
  380. package/ui/TerminalTabs.qml +27 -0
  381. package/ui/Theme.qml +460 -0
  382. package/ui/ThemeColors.qml +43 -0
  383. package/ui/TransferCard.qml +239 -0
  384. package/ui/TrashConfirm.qml +129 -0
  385. package/ui/TrashDropHandler.qml +11 -0
  386. package/ui/TrashHost.qml +202 -0
  387. package/ui/TrashMonitor.qml +30 -0
  388. package/ui/TrashToolbar.qml +19 -0
  389. package/ui/TrashView.qml +492 -0
  390. package/ui/UnlockDialog.qml +450 -0
  391. package/ui/UnlockHost.qml +206 -0
  392. package/ui/UpdateCheck.qml +97 -0
  393. package/ui/UserDirs.qml +25 -0
  394. package/ui/ViewState.qml +565 -0
  395. package/ui/ViewportScrollBar.qml +195 -0
  396. package/ui/ViewportScrollBars.qml +25 -0
  397. package/ui/WebPreview.qml +33 -0
  398. package/ui/WebPreviewView.qml +26 -0
  399. package/ui/WindowBody.qml +829 -0
  400. package/ui/WindowDrag.qml +35 -0
  401. package/ui/boot/Commons/AudioNodes.qml +50 -0
  402. package/ui/boot/Commons/AudioNodesModel.js +96 -0
  403. package/ui/boot/Commons/Border.qml +243 -0
  404. package/ui/boot/Commons/BorderGeometry.js +373 -0
  405. package/ui/boot/Commons/Color.qml +258 -0
  406. package/ui/boot/Commons/I18n.qml +118 -0
  407. package/ui/boot/Commons/InputDevices.qml +112 -0
  408. package/ui/boot/Commons/InputMethodState.qml +38 -0
  409. package/ui/boot/Commons/IpcRegistry.qml +77 -0
  410. package/ui/boot/Commons/Numbers.js +19 -0
  411. package/ui/boot/Commons/Plural.js +91 -0
  412. package/ui/boot/Commons/ShellIpc.qml +12 -0
  413. package/ui/boot/Commons/Style.qml +561 -0
  414. package/ui/boot/Commons/Translations.qml +100 -0
  415. package/ui/boot/Commons/UntypedInput.qml +152 -0
  416. package/ui/boot/Commons/Util.qml +188 -0
  417. package/ui/boot/Commons/qmldir +13 -0
  418. package/ui/boot/LICENSE-omarchy +20 -0
  419. package/ui/boot/Ui/BackgroundMedia.qml +49 -0
  420. package/ui/boot/Ui/BarIconButton.qml +106 -0
  421. package/ui/boot/Ui/BarIconContent.qml +38 -0
  422. package/ui/boot/Ui/BarIndicator.qml +53 -0
  423. package/ui/boot/Ui/BarWidget.qml +50 -0
  424. package/ui/boot/Ui/BorderOverlay.qml +54 -0
  425. package/ui/boot/Ui/BorderSurface.qml +40 -0
  426. package/ui/boot/Ui/Button.qml +224 -0
  427. package/ui/boot/Ui/ButtonGroup.qml +131 -0
  428. package/ui/boot/Ui/ConfirmDialog.qml +134 -0
  429. package/ui/boot/Ui/CursorSurface.qml +42 -0
  430. package/ui/boot/Ui/Dropdown.qml +245 -0
  431. package/ui/boot/Ui/FilterInput.qml +26 -0
  432. package/ui/boot/Ui/IconContentBounds.qml +141 -0
  433. package/ui/boot/Ui/KeyboardPanel.qml +453 -0
  434. package/ui/boot/Ui/MultiSelect.qml +624 -0
  435. package/ui/boot/Ui/NumberField.qml +86 -0
  436. package/ui/boot/Ui/OpticalGlyph.qml +68 -0
  437. package/ui/boot/Ui/OverlayWindow.qml +102 -0
  438. package/ui/boot/Ui/Panel.qml +60 -0
  439. package/ui/boot/Ui/PanelActionButton.qml +105 -0
  440. package/ui/boot/Ui/PanelController.qml +16 -0
  441. package/ui/boot/Ui/PanelHero.qml +112 -0
  442. package/ui/boot/Ui/PanelKeyCatcher.qml +100 -0
  443. package/ui/boot/Ui/PanelSectionHeader.qml +31 -0
  444. package/ui/boot/Ui/PanelSeparator.qml +19 -0
  445. package/ui/boot/Ui/PanelSlider.qml +156 -0
  446. package/ui/boot/Ui/PanelToolTip.qml +50 -0
  447. package/ui/boot/Ui/PluginBarApi.qml +89 -0
  448. package/ui/boot/Ui/PointerMoveGate.qml +54 -0
  449. package/ui/boot/Ui/PopupCard.qml +181 -0
  450. package/ui/boot/Ui/ScreenMoveRemap.qml +43 -0
  451. package/ui/boot/Ui/SearchableDropdown.qml +354 -0
  452. package/ui/boot/Ui/SizedImage.qml +125 -0
  453. package/ui/boot/Ui/SpeedTestOverlay.qml +412 -0
  454. package/ui/boot/Ui/TextField.qml +58 -0
  455. package/ui/boot/Ui/Toggle.qml +118 -0
  456. package/ui/boot/Ui/ToggleSwitch.qml +115 -0
  457. package/ui/boot/Ui/WidgetButton.qml +172 -0
  458. package/ui/boot/Ui/qmldir +41 -0
  459. package/ui/boot/fleatab.qml +50 -0
  460. package/ui/boot/picker.qml +39 -0
  461. package/ui/boot/shell.qml +131 -0
  462. package/ui/boot/tabtearoff.qml +51 -0
  463. package/ui/js/Anchor.js +379 -0
  464. package/ui/js/AnchorHold.js +162 -0
  465. package/ui/js/Archive.js +157 -0
  466. package/ui/js/ArchiveCard.js +44 -0
  467. package/ui/js/ArchiveOps.js +44 -0
  468. package/ui/js/BackReturn.js +118 -0
  469. package/ui/js/BulkRename.js +100 -0
  470. package/ui/js/Buttons.js +54 -0
  471. package/ui/js/ChromeKeys.js +116 -0
  472. package/ui/js/ClipMarks.js +73 -0
  473. package/ui/js/ClipSelection.js +67 -0
  474. package/ui/js/Clipboard.js +179 -0
  475. package/ui/js/Cloud.js +97 -0
  476. package/ui/js/CodeRuns.js +72 -0
  477. package/ui/js/Collide.js +212 -0
  478. package/ui/js/ColumnFit.js +28 -0
  479. package/ui/js/ColumnMenu.js +111 -0
  480. package/ui/js/Columns.js +298 -0
  481. package/ui/js/ColumnsCarry.js +103 -0
  482. package/ui/js/Compare.js +74 -0
  483. package/ui/js/Contrast.js +157 -0
  484. package/ui/js/ControlReader.js +42 -0
  485. package/ui/js/Convert.js +52 -0
  486. package/ui/js/CopyAs.js +52 -0
  487. package/ui/js/Crumbs.js +178 -0
  488. package/ui/js/Csv.js +231 -0
  489. package/ui/js/Density.js +44 -0
  490. package/ui/js/Devices.js +440 -0
  491. package/ui/js/DirSizes.js +180 -0
  492. package/ui/js/Drag.js +360 -0
  493. package/ui/js/DragOut.js +166 -0
  494. package/ui/js/DropDev.js +52 -0
  495. package/ui/js/Dropbox.js +41 -0
  496. package/ui/js/Eject.js +217 -0
  497. package/ui/js/Errors.js +188 -0
  498. package/ui/js/ExtThumbs.js +115 -0
  499. package/ui/js/Facts.js +402 -0
  500. package/ui/js/FigureDate.js +14 -0
  501. package/ui/js/Filter.js +285 -0
  502. package/ui/js/Find.js +46 -0
  503. package/ui/js/Flash.js +184 -0
  504. package/ui/js/FlashCard.js +79 -0
  505. package/ui/js/FlashEndings.js +125 -0
  506. package/ui/js/FlashPane.js +116 -0
  507. package/ui/js/FleaBin.js +12 -0
  508. package/ui/js/Focus.js +504 -0
  509. package/ui/js/FolderSorts.js +108 -0
  510. package/ui/js/FolderViews.js +44 -0
  511. package/ui/js/Format.js +314 -0
  512. package/ui/js/Fuzzy.js +141 -0
  513. package/ui/js/GlassTag.js +72 -0
  514. package/ui/js/Grid.js +33 -0
  515. package/ui/js/GridGeometry.js +90 -0
  516. package/ui/js/GridNames.js +153 -0
  517. package/ui/js/GvfsBridge.js +200 -0
  518. package/ui/js/HostClipboard.js +29 -0
  519. package/ui/js/Icons.js +218 -0
  520. package/ui/js/Input.js +50 -0
  521. package/ui/js/Jump.js +200 -0
  522. package/ui/js/KeyName.js +64 -0
  523. package/ui/js/Keymap.js +401 -0
  524. package/ui/js/Kinds.js +164 -0
  525. package/ui/js/LICENSES/ISC-lucide.txt +43 -0
  526. package/ui/js/LangMarkPaths.js +47 -0
  527. package/ui/js/LangMarks.js +120 -0
  528. package/ui/js/Lists.js +11 -0
  529. package/ui/js/LocalSend.js +39 -0
  530. package/ui/js/LockedMenu.js +63 -0
  531. package/ui/js/MakeDefault.js +186 -0
  532. package/ui/js/MarkBox.js +7 -0
  533. package/ui/js/Markdown.js +119 -0
  534. package/ui/js/MarkdownLists.js +86 -0
  535. package/ui/js/MarkdownMaths.js +58 -0
  536. package/ui/js/MarkdownPictures.js +32 -0
  537. package/ui/js/MarkdownPrepared.js +139 -0
  538. package/ui/js/MarkdownTableFit.js +34 -0
  539. package/ui/js/Marks.js +148 -0
  540. package/ui/js/Marquee.js +96 -0
  541. package/ui/js/Match.js +93 -0
  542. package/ui/js/Material.js +109 -0
  543. package/ui/js/MdBlocks.js +437 -0
  544. package/ui/js/MdBreak.js +71 -0
  545. package/ui/js/MdChunks.js +70 -0
  546. package/ui/js/MdContainer.js +137 -0
  547. package/ui/js/MdDocument.js +337 -0
  548. package/ui/js/MdEmph.js +97 -0
  549. package/ui/js/MdEntity.js +108 -0
  550. package/ui/js/MdEntityTable.js +223 -0
  551. package/ui/js/MdEscape.js +59 -0
  552. package/ui/js/MdFront.js +37 -0
  553. package/ui/js/MdHold.js +32 -0
  554. package/ui/js/MdHtml.js +307 -0
  555. package/ui/js/MdHtmlBlock.js +290 -0
  556. package/ui/js/MdHtmlHeading.js +53 -0
  557. package/ui/js/MdHtmlImage.js +179 -0
  558. package/ui/js/MdInline.js +154 -0
  559. package/ui/js/MdItems.js +212 -0
  560. package/ui/js/MdLeaf.js +309 -0
  561. package/ui/js/MdLink.js +196 -0
  562. package/ui/js/MdMath.js +67 -0
  563. package/ui/js/MdParagraphs.js +138 -0
  564. package/ui/js/MdRefs.js +232 -0
  565. package/ui/js/MdResolve.js +226 -0
  566. package/ui/js/MdRun.js +300 -0
  567. package/ui/js/MdUrl.js +226 -0
  568. package/ui/js/Menu.js +514 -0
  569. package/ui/js/MenuContext.js +85 -0
  570. package/ui/js/MenuFit.js +13 -0
  571. package/ui/js/MenuRefresh.js +74 -0
  572. package/ui/js/MenuWheel.js +35 -0
  573. package/ui/js/Messages.js +186 -0
  574. package/ui/js/Motion.js +16 -0
  575. package/ui/js/Mounts.js +320 -0
  576. package/ui/js/MouseNav.js +13 -0
  577. package/ui/js/Nav.js +329 -0
  578. package/ui/js/NetFs.js +26 -0
  579. package/ui/js/OpenWith.js +83 -0
  580. package/ui/js/Ops.js +585 -0
  581. package/ui/js/Palette.js +33 -0
  582. package/ui/js/PathBar.js +260 -0
  583. package/ui/js/Permissions.js +179 -0
  584. package/ui/js/Phones.js +112 -0
  585. package/ui/js/Picker.js +353 -0
  586. package/ui/js/PlaceMenu.js +96 -0
  587. package/ui/js/Places.js +265 -0
  588. package/ui/js/PreviewAsk.js +21 -0
  589. package/ui/js/PreviewKeys.js +155 -0
  590. package/ui/js/PreviewSettle.js +29 -0
  591. package/ui/js/PreviewSwap.js +101 -0
  592. package/ui/js/PropertyFacts.js +144 -0
  593. package/ui/js/Protocols.js +296 -0
  594. package/ui/js/QuickLookKinds.js +27 -0
  595. package/ui/js/QuickLookRect.js +24 -0
  596. package/ui/js/RailDrop.js +51 -0
  597. package/ui/js/RailKeys.js +87 -0
  598. package/ui/js/RailMenu.js +133 -0
  599. package/ui/js/Recent.js +135 -0
  600. package/ui/js/RecentMode.js +156 -0
  601. package/ui/js/Reload.js +60 -0
  602. package/ui/js/Renderer.js +9 -0
  603. package/ui/js/RunFile.js +143 -0
  604. package/ui/js/Scripts.js +28 -0
  605. package/ui/js/Scroll.js +304 -0
  606. package/ui/js/ScrollOff.js +69 -0
  607. package/ui/js/Search.js +478 -0
  608. package/ui/js/Selection.js +97 -0
  609. package/ui/js/Settings.js +476 -0
  610. package/ui/js/SettingsAbout.js +97 -0
  611. package/ui/js/SettingsShelf.js +52 -0
  612. package/ui/js/SheetKeys.js +42 -0
  613. package/ui/js/SheetQuery.js +281 -0
  614. package/ui/js/ShelfPile.js +27 -0
  615. package/ui/js/SlowClick.js +53 -0
  616. package/ui/js/SlowOp.js +6 -0
  617. package/ui/js/Sort.js +134 -0
  618. package/ui/js/Startup.js +63 -0
  619. package/ui/js/StateWords.js +17 -0
  620. package/ui/js/Status.js +238 -0
  621. package/ui/js/Swap.js +166 -0
  622. package/ui/js/TabMove.js +39 -0
  623. package/ui/js/Tabs.js +751 -0
  624. package/ui/js/Tags.js +134 -0
  625. package/ui/js/Taildrop.js +128 -0
  626. package/ui/js/Tap.js +180 -0
  627. package/ui/js/TextSize.js +107 -0
  628. package/ui/js/Thumbs.js +158 -0
  629. package/ui/js/Transfer.js +172 -0
  630. package/ui/js/Trash.js +84 -0
  631. package/ui/js/TrashDates.js +47 -0
  632. package/ui/js/TrashDrop.js +64 -0
  633. package/ui/js/UiState.js +438 -0
  634. package/ui/js/Unlock.js +152 -0
  635. package/ui/js/Update.js +130 -0
  636. package/ui/js/UserDirs.js +56 -0
  637. package/ui/qmldir +230 -0
@@ -0,0 +1,145 @@
1
+ var $x=[["flowchart",/^\s*flowchart-elk/],["mindmap",/^\s*mindmap/],["architecture",/^\s*architecture/],["agentflow",/^\s*agentflow-beta\b/],["c4",/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/],["kanban",/^\s*kanban/],["class",/^\s*classDiagram/],["er",/^\s*erDiagram/],["gantt",/^\s*gantt/],["info",/^\s*info/],["pie",/^\s*pie/],["requirement",/^\s*requirement(Diagram)?/],["sequence",/^\s*sequenceDiagram/],["swimlane",/^\s*swimlane-beta\b/],["flowchart",/^\s*(graph|flowchart)/],["timeline",/^\s*timeline/],["gitGraph",/^\s*gitGraph/],["state",/^\s*stateDiagram/],["journey",/^\s*journey/],["quadrantChart",/^\s*quadrantChart/],["sankey",/^\s*sankey(-beta)?/],["packet",/^\s*packet(-beta)?/],["xychart",/^\s*xychart(-beta)?/],["block",/^\s*block(-beta)?/],["eventmodeling",/^\s*eventmodeling/],["treeView",/^\s*treeView-beta/],["radar",/^\s*radar-beta/],["ishikawa",/^\s*ishikawa(-beta)?\b/i],["treemap",/^\s*treemap/],["railroad",/^\s*railroad-(?:ebnf-|abnf-|peg-)?beta/i],["venn",/^\s*venn-beta/],["wardley",/^\s*wardley-beta/i],["cynefin",/^\s*cynefin-beta(?:[\s:]|$)/],["usecase",/^\s*usecase-beta(?:\s|$)/]];function Fl(e){for(let[t,n]of $x)if(n.test(e))return t;return null}var Ge=class extends Error{code;type;line;column;snippet;constructor(t,n="syntax",r={}){super(t),this.name="PeleError",this.code=n,this.type=r.type??null,this.line=r.line??0,this.column=r.column??0,this.snippet=r.snippet??""}};function vi(e,t){let n=1,r=0;for(let i=e.indexOf(`
2
+ `);i!==-1&&i<t;i=e.indexOf(`
3
+ `,i+1))n++,r=i+1;let o=e.indexOf(`
4
+ `,t);o===-1&&(o=e.length);let s=t-r+1,a=e.slice(r,o);return{line:n,column:s,snippet:a+`
5
+ `+"-".repeat(s-1)+"^"}}function it(e,t,n,r,o=!1){let s=vi(t,n),a=o?`Lexical error on line ${s.line}. Unrecognized text.`:`Parse error on line ${s.line}:`,i=o?`${a}
6
+ ${s.snippet}`:`${a}
7
+ ${s.snippet}
8
+ ${r}`;return new Ge(i,"syntax",{type:e,...s})}var Dx="amp:38,lt:60,gt:62,quot:34,apos:39,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,sect:167,copy:169,laquo:171,not:172,reg:174,deg:176,plusmn:177,sup2:178,sup3:179,micro:181,para:182,middot:183,sup1:185,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,euro:8364,trade:8482,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,radic:8730,infin:8734,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830,check:10003,cross:10007,equals:61,colon:58,semi:59,num:35,percnt:37,lpar:40,rpar:41,lbrack:91,rbrack:93,lbrace:123,rbrace:125,vert:124,sol:47,bsol:92,quest:63,excl:33,ast:42,plus:43,comma:44,period:46,dollar:36,commat:64,grave:96,hat:94,lowbar:95,tilde:126,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969",zo;function xp(e){if(!zo){zo=new Map;for(let t of Dx.split(",")){let n=t.indexOf(":");zo.set(t.slice(0,n),String.fromCodePoint(Number(t.slice(n+1))))}}return zo.get(e)}function Wl(e,t){return e>0&&e<=1114111&&(e<55296||e>57343)?String.fromCodePoint(e):t}var Ox=/&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|(\w+));/g,Ap="fl°",vx="¶ß";function Px(e){let t="",n=0,r=e.indexOf(Ap);for(;r!==-1;){let o=e.indexOf("¶",r+2);if(o===-1)break;if(e[o+1]==="ß"){let s=e[r+2]==="°",a=e.slice(r+(s?3:2),o),i=e.slice(r,o+2);t+=e.slice(n,r)+(s?Wl(Number(a),i):xp(a)??"&"+a+";"),n=o+2}r=e.indexOf(Ap,o+1)}return n===0?e:t+e.slice(n)}function gt(e){return e.includes(vx)&&(e=Px(e)),e.includes("&")&&(e=e.replace(Ox,(t,n,r,o)=>n?Wl(Number(n),t):r?Wl(parseInt(r,16),t):xp(o)??t)),e}var Pi,Bi=new Map;function Sp(e,t){let n=Pi,r=Bi;Pi=e,Bi=new Map;try{return t()}finally{Pi=n,Bi=r}}function js(e){if(Pi===void 0)return"";let t=Bi.get(e);return t===void 0&&(t=Pi(e)??"",Bi.set(e,t)),t}var Or=class{constructor(t){this.message=t}message},Rp=64;function Vo(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}var Yl=class{lines;i=0;constructor(t){this.lines=t.replace(/\r\n?/g,`
9
+ `).split(`
10
+ `)}skipBlank(){for(;this.i<this.lines.length;){let t=this.lines[this.i].trim();if(t!==""&&t[0]!=="#"&&t!=="---")break;this.i++}}indent(){let t=this.lines[this.i],n=0;for(;n<t.length&&t[n]===" ";)n++;if(t[n]===" ")throw new Error("YAML: tabs are not allowed for indentation");return n}},Bx=/^[-+]?(?:0|[1-9][0-9]*)$/,Fx=/^[-+]?0x[0-9a-fA-F]+$/,Wx=/^[-+]?0o[0-7]+$/,Ux=/^[-+]?0b[01]+$/,Gx=/^[-+]?(?:[0-9][0-9]*(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/,Yx=/[\s#:,[\]{}&*!|>'"%@`]/;function Fi(e){return e===" "||e===" "||e===`
11
+ `||e==="\r"}function Ul(e){let t=e[0],n,r;if(t==='"'||t==="'"){let s=1;for(;;){if(s>=e.length)return null;let a=e[s];if(t==='"'&&a==="\\")s+=2;else if(a===t){if(t==='"'||e[s+1]!=="'")break;s+=2}else s++}for(n=s+1,r=n;Fi(e[r]);)r++;if(e[r]!==":")return null}else{if(t===void 0||Yx.test(t)||t==="-"&&(e.length<2||Fi(e[1])||e[1]===":"||e[1]==="#"))return null;for(r=1;r<e.length&&e[r]!==":"&&e[r]!=="#";)r++;if(e[r]!==":")return null;for(n=r;Fi(e[n-1]);)n--}let o=r+1;if(o<e.length&&!Fi(e[o]))return null;for(;Fi(e[o]);)o++;return{key:e.slice(0,n),length:o}}function Hl(e){let t=e.trim();if(t===""||t==="~"||t==="null"||t==="Null"||t==="NULL")return null;if(t==="true"||t==="True"||t==="TRUE")return!0;if(t==="false"||t==="False"||t==="FALSE")return!1;if(Bx.test(t)||Gx.test(t))return Number(t);if(Fx.test(t)||Wx.test(t)||Ux.test(t)){let n=t[0]==="-",r=Number(n||t[0]==="+"?t.slice(1):t);return n?-r:r}return/^[-+]?\.(?:inf|Inf|INF)$/.test(t)?t[0]==="-"?-1/0:1/0:/^\.(?:nan|NaN|NAN)$/.test(t)?NaN:t}var _p={0:"\0",a:"\x07",b:"\b",t:" ",n:`
12
+ `,v:"\v",f:"\f",r:"\r",e:"\x1B"," ":" ",'"':'"',"/":"/","\\":"\\",N:"…",_:" ",L:"\u2028",P:"\u2029"};function jo(e){if(!e.includes(`
13
+ `))return e;let t=e.split(`
14
+ `),n=t.length-1;for(let r=0;r<=n;r++){let o=t[r],s=0,a=o.length;if(r>0)for(;s<a&&(o.charCodeAt(s)===32||o.charCodeAt(s)===9);)s++;if(r<n)for(;a>s&&(o.charCodeAt(a-1)===32||o.charCodeAt(a-1)===9);)a--;t[r]=o.slice(s,a)}return t.join(`
15
+ `).replace(/\n+/g,r=>r.length===1?" ":`
16
+ `.repeat(r.length-1))}function Hx(e){let t="",n=jo(e.replace(/\\\n[ \t]*/g,""));for(let r=0;r<n.length;r++){let o=n[r];if(o!=="\\"){t+=o;continue}let s=n[++r];if(s==="x"||s==="u"||s==="U"){let a=s==="x"?2:s==="u"?4:8;t+=String.fromCodePoint(parseInt(n.slice(r+1,r+1+a),16)),r+=a}else if(s in _p)t+=_p[s];else throw new Error("YAML: unknown escape sequence")}return t}function fs(e,t,n){for(;t<e.length;){let r=e[t];if(r===" "||r===`
17
+ `||r===" "||r==="\r"||n&&r===",")t++;else if(r==="#"&&(t===0||/\s/.test(e[t-1]))){let o=e.indexOf(`
18
+ `,t);t=o===-1?e.length:o}else break}return t}function wp(e,t){if(!t)throw new Error("YAML: missed comma between flow collection entries");if(e===",")throw new Error("YAML: expected the node content, but found ','")}function Xs(e,t,n,r=0){if(r>Rp)throw new Error("YAML: nesting is too deep");t=fs(e,t,!1);let o=e[t];if(o==="{"){let a={};t++;let i=!0;for(;;){if(t=fs(e,t,!1),t>=e.length)throw new Or("YAML: unexpected end of the stream within a flow collection");if(e[t]==="}")return[a,t+1];wp(e[t],i);let c;[c,t]=Xs(e,t,":,}",r+1),t=fs(e,t,!1);let l=null;e[t]===":"&&([l,t]=Xs(e,t+1,",}",r+1)),Vo(a,String(c),l),t=fs(e,t,!1),i=e[t]===",",i&&t++}}if(o==="["){let a=[];t++;let i=!0;for(;;){if(t=fs(e,t,!1),t>=e.length)throw new Or("YAML: unexpected end of the stream within a flow collection");if(e[t]==="]")return[a,t+1];wp(e[t],i);let c;[c,t]=Xs(e,t,",]",r+1),a.push(c),t=fs(e,t,!1),i=e[t]===",",i&&t++}}if(o==='"'){let a=t+1;for(;a<e.length&&e[a]!=='"';)a+=e[a]==="\\"?2:1;if(a>=e.length)throw new Or("YAML: unexpected end of the stream within a double quoted scalar");return[Hx(e.slice(t+1,a)),a+1]}if(o==="'"){let a=t+1;for(;a<e.length;){if(e[a]==="'"){if(e[a+1]!=="'")break;a++}a++}if(a>=e.length)throw new Or("YAML: unexpected end of the stream within a single quoted scalar");return[jo(e.slice(t+1,a)).replace(/''/g,"'"),a+1]}let s=t;for(;s<e.length;){let a=e[s];if(n.includes(a)&&(a!==":"||s+1>=e.length||/[\s,[\]{}]/.test(e[s+1])))break;if(a==="#"&&s>t&&/\s/.test(e[s-1])){let i=e.indexOf(`
19
+ `,s);return[Hl(jo(e.slice(t,s).trim())),i===-1?e.length:i]}s++}return[Hl(jo(e.slice(t,s).trim())),s]}function Wi(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(t)r==="\\"&&t==='"'?n++:r===t&&(t="");else if(r==='"'||r==="'")t=r;else if(r==="#"&&(n===0||e[n-1]===" "||e[n-1]===" "))return e.slice(0,n)}return e}function Kx(e,t,n){let r=t[0]===">",o=t.includes("-")?"-":t.includes("+")?"+":"",s=/[1-9]/.exec(t),a=s?n+Number(s[0]):-1,i=[];for(;e.i<e.lines.length;){let f=e.lines[e.i];if(f.trim()===""){i.push(""),e.i++;continue}let p=f.length-f.trimStart().length;if(a===-1){if(p<=n)break;a=p}if(p<a)break;i.push(f.slice(a)),e.i++}let c=0;for(;i.length>0&&i[i.length-1]==="";)i.pop(),c++;let l;if(r){l="";for(let f=0;f<i.length;f++){let p=i[f];if(f>0){let u=i[f-1];p===""?l+=`
20
+ `:u!==""&&(l+=/^[ \t]/.test(u)||/^[ \t]/.test(p)?`
21
+ `:" ")}l+=p}}else l=i.join(`
22
+ `);return i.length===0?o==="+"?`
23
+ `.repeat(c):"":o==="-"?l:o==="+"?l+`
24
+ `.repeat(c+1):l+`
25
+ `}function Gl(e,t,n){let r=t[0];if((r==="|"||r===">")&&/^[|>][-+0-9]*\s*(?:#.*)?$/.test(t))return Kx(e,t,n);if(r==="{"||r==="["||r==='"'||r==="'"){let s=e.i,a=t,i=0,c=1;for(;;)try{let[l,f]=Xs(a,0,""),p=0;for(let m=a.indexOf(`
26
+ `);m!==-1&&m<f;m=a.indexOf(`
27
+ `,m+1))p++;let u=a.indexOf(`
28
+ `,f);if(Wi(a.slice(f,u===-1?a.length:u)).trim()!=="")throw new Error("YAML: unexpected content after a value");return e.i=s+p,l}catch(l){if(!(l instanceof Or))throw l;if(s+i>=e.lines.length)throw new Error(l.message);let f=e.lines.slice(s+i,s+i+c);a+=`
29
+ `+f.join(`
30
+ `),i+=f.length,c*=2}}let o=Wi(t).trim();for(;e.i<e.lines.length;){let s=e.lines[e.i];if(s.trim()===""){let i=e.i;for(;i<e.lines.length&&e.lines[i].trim()==="";)i++;if(i>=e.lines.length||e.lines[i].length-e.lines[i].trimStart().length<=n)break;o+=`
31
+ `.repeat(i-e.i),e.i=i;continue}if(s.length-s.trimStart().length<=n)break;let a=Wi(s).trim();o+=(o.endsWith(`
32
+ `)?"":" ")+a,e.i++}return Hl(o)}function Xo(e,t,n=0){if(n>Rp)throw new Error("YAML: nesting is too deep");if(e.skipBlank(),e.i>=e.lines.length)return null;let r=e.indent();if(r<t)return null;let o=e.lines[e.i].slice(r);if(o==="-"||o.startsWith("- ")){let a=[];for(;e.i<e.lines.length&&(e.skipBlank(),!(e.i>=e.lines.length||e.indent()!==r));){let i=e.lines[e.i].slice(r);if(i!=="-"&&!i.startsWith("- "))break;let c=i.slice(1),l=c.length-c.trimStart().length+1,f=Wi(c).trim();f===""?(e.i++,a.push(Xo(e,r+1,n+1))):Ul(f)!==null?(e.lines[e.i]=" ".repeat(r+l)+c.trimStart(),a.push(Xo(e,r+l,n+1))):(e.i++,a.push(Gl(e,c.trim(),r)))}return a}if(Ul(o)===null)return e.i++,Gl(e,o.trim(),r-1);let s={};for(;e.i<e.lines.length&&(e.skipBlank(),!(e.i>=e.lines.length));){let a=e.indent();if(a<r)break;if(a>r)throw new Error("YAML: bad indentation of a mapping entry");let i=e.lines[e.i].slice(r),c=Ul(i);if(!c)throw new Error("YAML: can not read a block mapping entry");let l=String(Xs(c.key,0,"")[0]),f=i.slice(c.length);if(e.i++,Wi(f).trim()==="")if(e.skipBlank(),e.i<e.lines.length){let p=e.indent(),u=e.lines[e.i].slice(p),m=u==="-"||u.startsWith("- ");Vo(s,l,p>r||m&&p===r?Xo(e,m?r:r+1,n+1):null)}else Vo(s,l,null);else Vo(s,l,Gl(e,f.trim(),r))}return s}function Hn(e){let t=e.trim();if(t[0]==="{"||t[0]==="[")try{let[o,s]=Xs(t,0,"");if(fs(t,s,!1)===t.length)return o}catch(o){throw o instanceof Or?new Error(o.message):o}let n=new Yl(e),r=Xo(n,0);if(n.skipBlank(),n.i<n.lines.length&&n.lines[n.i].trim()!=="...")throw new Error("YAML: end of the stream or a document separator is expected");return r}function Be(e){return e<128?e===32||e>=9&&e<=13:e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function On(e){return e===32||e===9}function ps(e){return e===10||e===13||e===8232||e===8233}function ft(e){return e>=48&&e<=57}function yr(e){return e>=65&&e<=90||e>=97&&e<=122}function qo(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Qe(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95}var zx=/^\s*%%(?!{)[^\n]+\n?/gm,qs=/%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi,Vx=/<(\w+)([^>]*)>/g,jx=/="([^"]*)"/g,Xx=new Set(["__proto__","constructor","prototype"]);function qx(e){return(e.includes("%%")?e.replace(zx,""):e).trimStart()}function Qo(e){return e===`
33
+ `||e==="\r"}function Kl(e){return e!==void 0&&/\s/.test(e)}function Qx(e){let t=0;for(;t<e.length&&Kl(e[t])&&!Qo(e[t]);)t++;let n=e.slice(0,t);if(!e.startsWith("---",t))return;let r=[];for(let p=t+3;p<e.length&&Kl(e[p]);p++)Qo(e[p])&&r.push(p);if(r.length===0)return;let o=n+"---",s=p=>{if(!Qo(e[p])||!e.startsWith(o,p+1))return-1;let u=-1;for(let m=p+1+o.length;m<e.length&&Kl(e[m]);m++)Qo(e[m])&&(u=m);return u},a=`
34
+ `+o,i=-1;for(let p=e.lastIndexOf(a);p>r[0];p=e.lastIndexOf(a,p-1))if(s(p)!==-1){i=p;break}if(i===-1)return;let c=r[0];for(let p of r)p<i&&(c=p);let l=c+1,f=l>0?l-1:0;for(let p=e.indexOf(a,f);p!==-1&&p<=i;p=e.indexOf(a,p+1)){if(p<l)continue;let u=s(p);if(u!==-1)return{indent:n,body:e.slice(l,p),length:u+1}}}function hs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Zo(e,t){for(let n of Object.keys(t)){if(Xx.has(n))continue;let r=t[n],o=e[n];hs(r)&&hs(o)?Zo(o,r):hs(r)?e[n]=Zo({},r):e[n]=r}return e}function Zx(e,t){if(!e.includes("%%{"))return e;let n=e.trim().replace(/'/g,'"');qs.lastIndex=0;let r;for(;(r=qs.exec(n))!==null;){r.index===qs.lastIndex&&qs.lastIndex++;let o=r[1]??r[2];if(o==="wrap")t.wrap=!0;else if((o==="init"||o==="initialize")&&r[4])try{let s=JSON.parse(r[4].trim());hs(s)&&Zo(t,s)}catch{}}return qs.lastIndex=0,e.replace(qs,"")}function Vl(e){let t=e.includes("\r")?e.replace(/\r\n?/g,`
35
+ `):e,n=t.includes("<")?t.lastIndexOf(">"):-1;n>0&&(t=t.slice(0,n+1).replace(Vx,(i,c,l)=>"<"+c+l.replace(jx,"='$1'")+">")+t.slice(n+1));let r={},o,s=0,a=t.includes("---")?Qx(t):void 0;if(a){let i=a.indent?a.body.split(`
36
+ `).map(l=>l.startsWith(a.indent)?l.slice(a.indent.length):l).join(`
37
+ `):a.body,c;try{c=Hn(i)}catch(l){throw new Ge(`Front matter is not valid YAML. ${l.message}`,"syntax")}if(hs(c)&&(c.title&&(o=String(c.title)),hs(c.config)&&Zo(r,c.config),c.displayMode)){let l=hs(r.gantt)?r.gantt:r.gantt={};l.displayMode=String(c.displayMode)}for(let l=t.indexOf(`
38
+ `);l!==-1&&l<a.length;l=t.indexOf(`
39
+ `,l+1))s++;t=t.slice(a.length)}return t=Zx(t,r),{text:qx(t),title:o,config:r,withComments:t,lineOffset:s}}var Jx=/#\w+;/g,eS=/^\+?\d+$/,zl=new RegExp("[\\n\\r\u2028\u2029]","g");function Tp(e,t){let n=e.indexOf(t);if(n===-1)return e;let r="",o=0;for(;n!==-1;){zl.lastIndex=n;let s=zl.test(e)?zl.lastIndex-1:e.length,a=!1,i=-1;for(let c=n+t.length;c<s;c++){let l=e.charCodeAt(c);if(l===58)a=!0;else if(l===35){if(a){i=c;break}}else Be(l)&&(a=!1)}if(i!==-1){let c=e.lastIndexOf(";",s-1);c>i&&(r+=e.slice(o,c),o=c+1)}n=s>=e.length?-1:e.indexOf(t,s+1)}return o===0?e:r+e.slice(o)}function Cp(e){return e.includes("#")?Tp(Tp(e,"style"),"classDef").replace(Jx,t=>{let n=t.substring(1,t.length-1);return(eS.test(n)?"fl°°":"fl°")+n+"¶ß"}):e}var Ip="7q7q9vfgfgopij5b9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg7q7qg8g8g8fgs7ijijk2k2ijgzlmk27qdwijfgn5k2lmijlmk2ijgzk2ijq8ijijgz7q7q7qd1fg99fgfgdwfgfg7qfgfg6666dw66n5fgfgfgfg99dw7qfgdwk2dwdwdw9a789ag8",Np="7q99d6fgfgopk26m9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg9999g8g8g8gzr3k2k2k2k2ijgzlmk27qfgk2gzn5k2lmijlmk2ijgzk2ijq8ijijgz997q99g8fg99fggzfggzfg99gzgz7q7qfg7qopgzgzgzgzatfg99gzfglmfgfgdwat7satg8";function Mp(e){let t=new Uint16Array(95);for(let n=0;n<95;n++)t[n]=parseInt(e.substr(n*2,2),36);return t}var tS,nS;function rS(e){return e>=4352&&e<=4447||e>=11904&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=55296&&e<=56319}function sS(e){return e>=768&&e<=879||e>=8203&&e<=8207||e>=56320&&e<=57343||e>=65024&&e<=65039||e===65279}var iS={width(e,t,n){let r=(n&4)!==0,o=n&1?nS??=Mp(Np):tS??=Mp(Ip),s=0;for(let a=0;a<e.length;a++){let i=e.charCodeAt(a);if(!(i<32))if(i<127)s+=r?600:o[i-32];else{if(sS(i))continue;rS(i)?s+=r?1200:1e3:s+=r?600:580}}return s*t/1e3}};function oS(){let e=globalThis;try{if(e.OffscreenCanvas)return new e.OffscreenCanvas(1,1).getContext("2d");if(e.document)return e.document.createElement("canvas").getContext("2d")}catch{return null}return null}var aS=2e4;function kp(){let e=globalThis;return e.document?.fonts??e.fonts}function cS(e,t,n){try{return e?.check(t,n)??!0}catch{return!0}}function lS(e,t="monospace"){let n=oS();if(!n)return null;let r=new Map,o="",s=kp()?.size;return{width(a,i,c){let l=kp();l?.size!==s&&(s=l?.size,r.clear());let f=(c&2?"italic ":"")+(c&1?"bold ":"")+i+"px "+(c&4?t:e),p=r.get(f);p||r.set(f,p=new Map);let u=p.get(a);return u===void 0&&(f!==o&&(n.font=o=f),u=n.measureText(a).width,cS(l,f,a)&&(p.size>=aS&&p.clear(),p.set(a,u))),u}}}var jl=new Map;function Je(e="sans-serif",t="monospace"){let n=e+`
40
+ `+t,r=jl.get(n);return r||(r=lS(e,t)??iS,jl.set(n,r)),r}function Xl(){jl.clear()}function ms(e){return e.ownerDocument?.defaultView??globalThis}function ql(e,t){let n=e.clientWidth-(parseFloat(t.paddingLeft)||0)-(parseFloat(t.paddingRight)||0);return n>0?n:0}function dS(e,t,n,r,o){let s=t.width/n,a=t.height/n,i=(c,l,f)=>l>=f?Math.min(Math.max(c,f-l),0):Math.min(Math.max(c,0),f-l);return{x:i(r,s,e.width),y:i(o,a,e.height),width:s,height:a}}var Qs=1.25,Jo=48,uS="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_b:var(--pele-border,#8a8a8a);position:absolute;top:var(--pele-zoom-top,8px);right:var(--pele-zoom-right,8px);bottom:var(--pele-zoom-bottom,auto);left:var(--pele-zoom-left,auto);display:flex;flex-direction:column;gap:2px;padding:2px;width:auto;max-width:none;border:1px solid var(--_b);border-radius:var(--pele-radius,4px);background:var(--_bg);color:var(--_fg);line-height:0",fS="appearance:none;display:grid;place-items:center;width:24px;height:24px;margin:0;padding:0;border:0;border-radius:calc(var(--pele-radius,4px) - 1px);background:transparent;color:inherit;font:inherit;cursor:pointer",pS={zoomIn:"M5 12h14M12 5v14",zoomOut:"M5 12h14",reset:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8M3 3v5h5"},hS={zoomIn:"Zoom in",zoomOut:"Zoom out",reset:"Reset zoom"};function mS(e,t={}){return Ql(e,t,!0)}function Ql(e,t,n){let r=null,o={width:0,height:0},s={width:0,height:0},a={width:0,height:0},i=!1,c="",l={width:"",height:"",maxWidth:"",margin:"",display:""},f=0,p=0,u=0,m=0,h=()=>ms(e),g=()=>o.width>0&&s.width>0?s.width/o.width:1,x=()=>Math.max(g(),t.maxScale??3),y=()=>r!==null&&o.width>0&&(t.always===!0||g()<.999),_=()=>{if(!r||f!==0)return;let J=r.getBoundingClientRect();s={width:J.width,height:J.height},a={width:Math.max(s.width,e.clientWidth),height:Math.max(s.height,e.clientHeight)},i=a.width>s.width+1||a.height>s.height+1,i||(a=s);let se=h().getComputedStyle(e);c=["Top","Right","Bottom","Left"].map(me=>`${-(parseFloat(se.getPropertyValue(`padding-${me.toLowerCase()}`))||0)}px`).join(" ")},S,P={},k=!1,w=()=>{if(t.controls===!1)return;let J=y();if(!S){if(!J)return;let me=e.ownerDocument;S=me.createElement("div"),S.className="pele pele-zoom",S.setAttribute("style",uS);let Ae={zoomIn:()=>U((f||g())*Qs*Qs),zoomOut:()=>U((f||g())/(Qs*Qs)),reset:()=>D()};for(let de of["zoomIn","zoomOut","reset"]){let oe=me.createElement("button"),ye=t.labels?.[de]??hS[de];oe.type="button",oe.className=`pele-zoom-${de==="zoomIn"?"in":de==="zoomOut"?"out":"reset"}`,oe.setAttribute("style",fS),oe.setAttribute("aria-label",ye),oe.title=ye,oe.innerHTML=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${pS[de]}"/></svg>`,oe.addEventListener("click",Ae[de]),P[de]=oe,S.append(oe)}}J&&!k&&h().getComputedStyle(e).position==="static"&&(e.style.position="relative",k=!0),J&&S.parentNode!==e&&e.append(S),S.hidden=!J,S.style.display=J?"flex":"none";let se=(me,Ae)=>{me&&(me.disabled=Ae,me.style.opacity=Ae?"0.35":"",me.style.cursor=Ae?"default":"pointer")};se(P.zoomIn,(f||g())>=x()*.999),se(P.zoomOut,f===0),P.reset&&(P.reset.style.display=f===0?"none":"grid")},I=J=>S!==void 0&&J.target instanceof h().Node&&S.contains(J.target),D=()=>{r&&(f=0,r.setAttribute("viewBox",`0 0 ${o.width} ${o.height}`),r.style.width=l.width,r.style.height=l.height,r.style.maxWidth=l.maxWidth,r.style.margin=l.margin,r.style.display=l.display,r.style.cursor="",r.style.userSelect="",_(),r.style.touchAction=y()?"pan-y":"",y()?r.setAttribute("tabindex","0"):r.removeAttribute("tabindex"),ae(y()),w())},U=(J,se,me)=>{if(!r||(f===0&&_(),!y()))return;let Ae=f||g(),de=Math.min(Math.max(J,g()),x());if(de<=g()*1.001){D();return}let oe=r.getBoundingClientRect(),ye=se??oe.left+oe.width/2,ce=me??oe.top+oe.height/2,fe=(f?p:0)+(ye-oe.left)/Ae,xe=(f?u:0)+(ce-oe.top)/Ae;f=de;let be=oe;i&&(r.style.maxWidth="none",r.style.margin=c,r.style.display="block",r.style.width=`${a.width}px`,r.style.height=`${a.height}px`,be=r.getBoundingClientRect()),M(fe-(ye-be.left)/f,xe-(ce-be.top)/f),r.style.cursor="grab",r.style.userSelect="none",r.style.touchAction="none",w()},M=(J,se)=>{if(!r)return;let me=dS(o,a,f,J,se);p=me.x,u=me.y,r.setAttribute("viewBox",`${p} ${u} ${me.width} ${me.height}`)},Q=(J,se)=>{f!==0&&M(p-J/f,u-se/f)},q=()=>{R();let J=e.clientWidth+e.clientHeight;J!==m&&(m=J,D())},Y,z,R=()=>{if(!n)return;let J=h();J!==z&&(Y?.disconnect(),z=J,Y=J.ResizeObserver?new J.ResizeObserver(q):void 0,Y?.observe(e))},L=()=>{R();let J=e.firstElementChild;if(r=J&&J.localName==="svg"?J:null,f=0,!r){S?.remove(),ae(!1);return}o={width:Number(r.getAttribute("width"))||0,height:Number(r.getAttribute("height"))||0},l={width:r.style.width,height:r.style.height,maxWidth:r.style.maxWidth,margin:r.style.margin,display:r.style.display},D()},F=new Map,E=!1,C=0,A=0,T=()=>{let[J,se]=[...F.values()];return{distance:Math.hypot(J.x-se.x,J.y-se.y),x:(J.x+se.x)/2,y:(J.y+se.y)/2}},b=J=>{!y()||I(J)||J.pointerType==="mouse"&&J.button!==0||(F.set(J.pointerId,{x:J.clientX,y:J.clientY}),C=0,F.size===2&&(A=T().distance),(F.size===2||f!==0)&&(e.setPointerCapture?.(J.pointerId),r&&(r.style.cursor="grabbing")))},N=J=>{let se=F.get(J.pointerId);if(se){if(F.size===2){let me=T();F.set(J.pointerId,{x:J.clientX,y:J.clientY});let Ae=T();A>0&&Ae.distance>0&&U((f||g())*(Ae.distance/me.distance),Ae.x,Ae.y),Q(Ae.x-me.x,Ae.y-me.y),E=!0;return}F.set(J.pointerId,{x:J.clientX,y:J.clientY}),f!==0&&(C+=Math.abs(J.clientX-se.x)+Math.abs(J.clientY-se.y),C>4&&(E=!0),Q(J.clientX-se.x,J.clientY-se.y))}},$=J=>{F.delete(J.pointerId)&&(A=0,F.size===0&&r&&f!==0&&(r.style.cursor="grab"))},X=J=>{E&&(E=!1,J.preventDefault(),J.stopPropagation())},V=J=>{if(!(J.ctrlKey||J.metaKey)||!y())return;J.preventDefault(),f===0&&_();let se=Math.min(Math.max(-J.deltaY,-24),24);U((f||g())*2**(se*.02),J.clientX,J.clientY)},O=J=>{!y()||I(J)||(J.preventDefault(),f!==0?D():U(Math.max(1,g()*2),J.clientX,J.clientY))},v=J=>{if(!y()||I(J)||J.ctrlKey||J.metaKey||J.altKey)return;let se=J.key;if(se==="+"||se==="=")U((f||g())*Qs);else if(se==="-")U((f||g())/Qs);else{if(f===0)return;if(se==="0"||se==="Escape")D();else if(se==="ArrowLeft")Q(Jo,0);else if(se==="ArrowRight")Q(-Jo,0);else if(se==="ArrowUp")Q(0,Jo);else if(se==="ArrowDown")Q(0,-Jo);else return}J.preventDefault()},W=J=>{if(!r||J.target!==r)return;let se=!0;try{se=r.matches(":focus-visible")}catch{}r.style.outline=se?"":"none"},H=0,G=J=>{y()&&(J.preventDefault(),f===0&&_(),H=f||g())},te=J=>{if(H===0)return;J.preventDefault();let{scale:se,clientX:me,clientY:Ae}=J;U(H*se,me,Ae)},Z=()=>{H=0},B=[["pointerdown",b],["pointermove",N],["pointerup",$],["pointercancel",$],["click",X,{capture:!0}],["dblclick",O],["keydown",v],["focusin",W]];for(let[J,se,me]of B)e.addEventListener(J,se,me);let K=[["wheel",V,{passive:!1}],["gesturestart",G,{passive:!1}],["gesturechange",te,{passive:!1}],["gestureend",Z,{passive:!1}]],ee=!1;function ae(J){if(J!==ee){ee=J;for(let[se,me,Ae]of K)J?e.addEventListener(se,me,Ae):e.removeEventListener(se,me,Ae);J||(H=0)}}return m=e.clientWidth+e.clientHeight,L(),{get scale(){return f||g()},get fit(){return g()},zoomBy(J){U((f||g())*J)},zoomTo(J){U(J)},reset:D,refresh:L,resized:q,destroy(){D(),r&&(r.style.touchAction="",r.removeAttribute("tabindex")),S?.remove(),k&&(e.style.position=""),Y?.disconnect(),ae(!1);for(let[J,se,me]of B)e.removeEventListener(J,se,me)}}}function Zl(e,t){let n=t?ms(t).getComputedStyle(t):e;return{family:n.getPropertyValue("--pele-font").trim()||e.fontFamily||void 0,mono:n.getPropertyValue("--pele-font-mono").trim()||void 0}}function gS(e){return[...new Set([e.ownerDocument?.fonts,globalThis.document?.fonts])].filter(n=>n!==void 0)}var Jl=new WeakMap;function bS(e){let t=Jl.get(e);return t||(t=e.ready.then(()=>{Jl.delete(e),Xl()}),Jl.set(e,t)),t}var ed=new WeakMap;function yS(e,t){Promise.all(e.map(bS)).then(()=>{let n=t.deref();n&&ed.get(n)?.()})}var ea=new WeakMap,ES=0,AS=Math.random().toString(36).slice(2,7),xS="position:relative;height:1.3em;margin-top:-1.3em;line-height:1.3;font-size:0.8em;color:var(--pele-error,#e45756);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;",SS="margin:0;font-size:0.8em;font-family:var(--pele-font-mono,monospace);color:var(--pele-error,#e45756);white-space:pre-wrap;";function _S(e){return e instanceof Error?e.message:String(e)}function wS(e){let t=e.split(`
41
+ `).filter(n=>n.trim()!=="");return t.length>1?`${t[0]} ${t[t.length-1]}`:t[0]??""}function Lp(e,t,n,r={}){ea.get(t)?.destroy();let o=n,s=r,a,i,c=!1,l,f,p,u=`pele-${AS}-${++ES}`,m={},h,g=-1,x=!1,y=!1,_=!1,S=(T,b)=>{let{onRender:N,onError:$,sanitize:X,...V}=s,O={...V,idPrefix:V.idPrefix??u,fontFamily:V.fontFamily??m.family,fontFamilyMono:V.fontFamilyMono??m.mono,maxWidth:void 0};b&&(f=e.render(a,O),h=void 0);let v=s.maxWidth??ql(t,T);return g=v,v>0&&v<f.width&&(h??=e.render(a,{...O,maxWidth:1}).svg!==f.svg,h)?e.render(a,{...O,maxWidth:v}):f},P=T=>{s.sanitize?t.replaceChildren(s.sanitize(T)):t.innerHTML=T},k,w=()=>{let T=p?t.firstElementChild:null;if(T?.style&&(T.style.opacity=l===void 0?"":"0.4"),l===void 0){k?.remove(),k=void 0;return}let b=t.ownerDocument;if(!b)return;k??=b.createElement("div"),k.className="pele pele-error";let N=_S(l);T?(k.textContent=wS(N),k.title=N,k.setAttribute("style",xS),k.parentNode!==t&&t.append(k)):(k.textContent=N,k.removeAttribute("title"),k.setAttribute("style",SS),t.replaceChildren(k))},I=T=>{l=T,w(),s.onError?.(T)},D=()=>{if(y||_)return;let T=gS(t).filter(b=>b.status==="loading");T.length!==0&&(y=!0,yS(T,new WeakRef(A)))},U=()=>{y=!1,x=!0,L()},M=(T,b=!T)=>{let N=ms(t).getComputedStyle(t),$=t.firstElementChild??null,X={fonts:m,natural:f,adapts:h,drawnFor:g,stale:x},V;try{if(T&&(m=Zl(N,$),x=t.isConnected===!1),V=S(N,T),b&&V.svg===p?.svg){T&&(i=a),c&&l!==void 0&&(l=void 0,w());return}P(V.svg)}catch(O){throw{fonts:m,natural:f,adapts:h,drawnFor:g,stale:x}=X,O}if(T&&(i=a),T&&!$&&t.firstElementChild){let O=Zl(N,t.firstElementChild);if(O.family!==m.family||O.mono!==m.mono){let v={fonts:m,natural:f,adapts:h,drawnFor:g};m=O;try{let W=S(N,!0);P(W.svg),V=W}catch{({fonts:m,natural:f,adapts:h,drawnFor:g}=v)}}}p=V,c&&(l=void 0),w(),Q?.refresh(),D(),s.onRender?.(V)},Q,q=!1,Y=()=>{let T=s.zoom??"auto";T!==q&&(Q?.destroy(),q=T,Q=T===!1?void 0:Ql(t,typeof T=="object"?T:{always:T===!0},!1))},z=()=>t.isConnected===!1||!(t.clientWidth>0),R=()=>t.isConnected!==!1&&!(t.clientWidth>0),L=()=>{if(_||(C(),!a||z()))return;let T=ms(t).getComputedStyle(t),b=Zl(T,t.firstElementChild??null);try{if(x||b.family!==m.family||b.mono!==m.mono)M(!0,!0);else if(h!==!1&&s.maxWidth===void 0){let N=ql(t,T);N!==g&&N!==p?.width&&M(!1)}}catch(N){x=!1,c&&(l=N),a!==i&&(a=i,c=!1),w(),s.onError?.(N)}Q?.resized(),D()},F,E,C=()=>{let T=ms(t);T!==F&&(E?.disconnect(),F=T,E=T.ResizeObserver?new T.ResizeObserver(L):void 0,E?.observe(t))},A={get result(){return p},get source(){return o},get error(){return l},get zoom(){return Q},update(T,b=s){let N=!c||T!==o||b.limit!==s.limit||b.maxEdges!==s.maxEdges||b.config!==s.config;o=T,s=b;let $=a;if(N)try{$=e.parse(T,b)}catch(V){c=!1,I(V),Y();return}let X=p;if(a=$,c=!0,R()){x=!0,Y();return}try{M(!0)}catch(V){if(p!==X)throw Y(),V;a=i,c=!1,I(V)}Y()},refresh:L,destroy(){_=!0,E?.disconnect(),E=void 0,F=void 0,Q?.destroy(),ed.delete(A),ea.get(t)===A&&ea.delete(t)}};ed.set(A,U);try{a=e.parse(n,r),c=!0,M(!0)}catch(T){if(p)throw T;a=i,c=!1,I(T)}return Y(),C(),ea.set(t,A),A}var ta=new Map;function $p(...e){for(let t of e)ta.set(t.type,t)}function IM(e){return ta.has(e)}var RS=5e4,TS=4e6,CS=5e3;function Dp(e){try{return e()}catch(t){throw t instanceof RangeError?new Ge("Diagram is nested too deeply.","limit"):t}}var Op=new WeakMap;function vp(e,t=RS,n=CS,r){if(e.length>t)throw new Ge(`Diagram source is longer than the limit of ${t} characters.`,"limit");let o=Vl(e),s=Fl(o.text);if(s===null)throw new Ge("No diagram type detected for the given text.","unsupported-diagram");let a=ta.get(s);if(a===void 0)throw new Ge(`Diagram type "${s}" is not supported yet.`,"unsupported-diagram",{type:s});let i=r?{...r,...o.config}:o.config,c=a.keepComments?o.withComments:o.text,l=a.parse(Cp(c)+`
42
+ `,i,o.title,o.lineOffset,{maxEdges:n});return{type:s,diagram:a,model:l,config:i}}function IS(e,t){if(typeof e=="string")return vp(e,t.limit,t.maxEdges,t.config);let n=Op.get(e);if(n===void 0)throw new TypeError("render() takes diagram text or a model that parse() returned.");return n}function NS(e){return Fl(Vl(e).text)}function NM(e){try{let t=NS(e);return t!==null&&ta.has(t)}catch{return!1}}function MS(e,t={}){return Dp(()=>{let n=vp(e,t.limit,t.maxEdges,t.config);return typeof n.model=="object"&&n.model!==null&&Op.set(n.model,n),n.model})}function kS(e,t={}){return Dp(()=>{let{type:n,diagram:r,model:o,config:s}=IS(e,t),a=s[r.section??n],i=typeof a=="object"&&a!==null&&!Array.isArray(a)&&a.useMaxWidth===!1,c=t.responsive??!i,l=t.icons,f=l&&(m=>l(gt(m))),p=Sp(f,()=>r.render(o,s,{...t,responsive:c,icons:f})),u=t.outputLimit??TS;if(p.svg.length>u)throw new Ge(`Diagram output is longer than the limit of ${u} characters.`,"limit",{type:n});for(let m of p.links)m.id=gt(m.id);return{type:n,...p}})}function MM(e,t,n={}){return Lp({parse:MS,render:kS},e,t,n)}var LS=/[&<>"\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/,$S=/[&<>"]|[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]+/g,DS={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function je(e){return LS.test(e)?e.replace($S,t=>DS[t]??""):e}function $e(e){return je(gt(e))}var td=[];for(let e=0;e<100;e++)td.push(e===0?"":e%10===0?"."+e/10:"."+(e<10?"0"+e:e));function d(e){let t=Math.round(e*100);if(t===0)return"0";if(t>0){if(t<1e11){let n=Math.floor(t/100);return n+td[t-n*100]}}else if(t>-1e11){let n=-t,r=Math.floor(n/100);return"-"+r+td[n-r*100]}return String(t/100)}function Ie(e,t,n,r,o){let s=e.lines;if(s.length===0)return"";let a=e.lineHeight,i=e.size*.35,c=n-e.height/2+a/2+i;if(s.length===1&&s[0].length===1&&s[0][0].icon===void 0&&s[0][0].style===0)return`<text${r} x="${d(t)}" y="${d(c)}" text-anchor="middle">${je(s[0][0].text)}</text>`;let l=Er(e);r=Kn(r,l);let f="",p="";for(let u=0;u<s.length;u++){let m=s[u],h=!1;for(let g of m)g.icon!==void 0&&(h=!0);if(h){let g=t-e.widths[u]/2;for(let x of m){if(x.icon!==void 0){let y=e.size*1.1,_=o?.(x.icon)??"";p+=`<svg class="pele-icon" data-icon="${$e(x.icon)}" x="${d(g)}" y="${d(c-i-y/2)}" width="${d(y)}" height="${d(y)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${_}</svg>`}else x.text!==""&&(f+=`<tspan x="${d(g)}" y="${d(c)}" text-anchor="start"${rr(x.style&~l)}>${je(x.text)}</tspan>`);g+=x.width}}else{for(let g=0;g<m.length;g++){let x=m[g],y=g===0?` x="${d(t)}" y="${d(c)}"`:"";f+=`<tspan${y}${rr(x.style&~l)}>${je(x.text)}</tspan>`}m.length===0&&(f+=`<tspan x="${d(t)}" y="${d(c)}"> </tspan>`)}c+=a}return`<text${r} text-anchor="middle" xml:space="preserve">${f}</text>${p}`}var Pp=' font-weight="var(--_w)"',Bp=' font-style="italic"';function rr(e){return(e&1?Pp:"")+(e&2?Bp:"")}function Er(e){let t=3,n=!1;for(let r of e.lines)for(let o of r)o.icon!==void 0||o.text===""||(t&=o.style,n=!0);return n?t:0}function Kn(e,t){return e+(t&1&&!e.includes(' font-weight="')?Pp:"")+(t&2&&!e.includes(' font-style="')?Bp:"")}var Ui="about:blank",OS=/^([^\w]*)(javascript|data|vbscript)/im,Fp=/&#(\w+)(^\w|;)?/g,Wp=/&(newline|tab);/gi,nd=/[\u0000-\u001F\u007F-\u009F -‍]/gim,vS=/^.+(:|&colon;)/gim,Up=/(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g;function Gp(e){try{return decodeURIComponent(e)}catch{return e}}function zn(e){if(!e)return Ui;let t=Gp(e.trim()),n,r=0;do{if(++r>32)return Ui;t=t.replace(nd,"").replace(Fp,(c,l)=>String.fromCharCode(l)).replace(Wp,"").replace(nd,"").replace(Up,"").trim(),t=Gp(t),n=t.match(nd)||t.match(Fp)||t.match(Wp)||t.match(Up)}while(n&&n.length>0);if(!t)return Ui;if(t[0]==="."||t[0]==="/")return t;let o=t.trimStart(),s=o.match(vS);if(!s)return t;let a=s[0].toLowerCase().trim();if(OS.test(a))return Ui;let i=o.replace(/\\/g,"/");if(a==="mailto:"||a.includes("://"))return i;if(a==="http:"||a==="https:"){let c;try{c=new URL(i)}catch{return Ui}return c.protocol=c.protocol.toLowerCase(),c.hostname=c.hostname.toLowerCase(),c.toString()}return i}function vn(e){return zn(gt(e))}var PS=["http","https","mailto","tel"],BS=["http","https"],FS=/^([a-z][a-z0-9+.-]*):/i,WS=/^[\\/]{2}/;function Yp(e,t){if(WS.test(e))return;let n=FS.exec(e);return!n||t.includes(n[1].toLowerCase())?e:void 0}function Ar(e,t){return t.links===!1?void 0:Yp(e,t.linkSchemes??PS)}function Hp(e,t){return t.images===!1?void 0:Yp(e,t.imageSchemes??BS)}function Pn(e,t,n,r,o,s=""){let a=Ar(t,o);return a===void 0?e:(r.push({id:n,href:a,internal:!1}),`<a href="${je(a)}"${s}${xr(o)}>${e}</a>`)}function xr(e){let t=e.linkRel??"noopener";return t?` rel="${je(t)}"`:""}var US=[["rect","proc","process","rectangle","squareRect"],["rounded","event","roundedRect"],["stadium","terminal","pill"],["fr-rect","subprocess","subproc","framed-rectangle","subroutine"],["cyl","db","database","cylinder"],["datastore","data-store"],["folder","directory"],["bucket"],["console"],["browser"],["person"],["circle","circ"],["bang"],["cloud"],["diam","decision","diamond","question"],["hex","hexagon","prepare"],["lean-r","lean-right","in-out","lean_right"],["lean-l","lean-left","out-in","lean_left"],["trap-b","priority","trapezoid-bottom","trapezoid"],["trap-t","manual","trapezoid-top","inv-trapezoid","inv_trapezoid"],["dbl-circ","double-circle","doublecircle"],["text"],["notch-rect","card","notched-rectangle"],["lin-rect","lined-rectangle","lined-process","lin-proc","shaded-process"],["sm-circ","start","small-circle","stateStart"],["fr-circ","stop","framed-circle","stateEnd"],["fork","join","forkJoin"],["hourglass","collate"],["brace","comment","brace-l"],["brace-r"],["braces"],["bolt","com-link","lightning-bolt"],["doc","document"],["delay","half-rounded-rectangle"],["h-cyl","das","horizontal-cylinder"],["lin-cyl","disk","lined-cylinder"],["curv-trap","curved-trapezoid","display"],["div-rect","div-proc","divided-rectangle","divided-process"],["tri","extract","triangle"],["win-pane","internal-storage","window-pane"],["f-circ","junction","filled-circle"],["notch-pent","loop-limit","notched-pentagon"],["flip-tri","manual-file","flipped-triangle"],["sl-rect","manual-input","sloped-rectangle"],["docs","documents","st-doc","stacked-document"],["st-rect","procs","processes","stacked-rectangle"],["bow-rect","stored-data","bow-tie-rectangle"],["cross-circ","summary","crossed-circle"],["tag-doc","tagged-document"],["tag-rect","tagged-rectangle","tag-proc","tagged-process"],["flag","paper-tape"],["odd","rect_left_inv_arrow"],["lin-doc","lined-document"]],GS=["state","choice","note","composite","rectWithTitle","labelRect","block_arrow","collapsedGroup","iconSquare","iconCircle","icon","iconRounded","imageSquare","anchor","kanbanItem","mindmapCircle","defaultMindmapNode","classBox","erBox","requirementBox","usecaseActor","usecaseActorHollow","usecaseActorAwesome","usecaseActorIcon","usecaseBusiness","usecaseEllipse","usecaseJsonTable"],YS=new Map([["square","rect"],["round","rounded"],["ellipse","ellipse"],["hexagon","hex"],["diamond","diam"]]),na=new Map;for(let e of US)for(let t of e)na.set(t,e[0]);for(let e of GS)na.set(e,e);function ra(e){return na.has(e)}function sa(e){return e===void 0?"rect":YS.get(e)??na.get(e)??"rect"}var HS=new Map([["task","roundedRect"],["tool","subroutine"],["input","lean-right"],["decision","diamond"],["refdoc","lin-doc"],["action","hexagon"],["round","rect"]]),KS=new Set(["doc","stadium","terminal","circle","trapezoid","inv_trapezoid","inv-trapezoid","doublecircle","double-circle","typeDeclaration","procs","lean_left","lean-left","in-out","cylinder","ellipse","odd","tag-rect","tagged-rectangle","delay","half-rounded-rectangle","lin-rect","lined-rectangle","win-pane","window-pane","curv-trap","curved-trapezoid"]),zS=new Set(["roundedRect","subroutine","subprocess","subproc","framed-rectangle","lean-right","diamond","lin-doc","lined-document","hexagon","hex","connector","collapsedGroup"]),Gi="roundedRect";function Zs(e){return e&&(HS.get(e)??e)}function Kp(e){return ra(e)||e==="constructor"}function zp(e,t){for(let n of e)n.isGroup||((!n.shape||n.shape==="squareRect"||n.shape==="rect")&&(n.shape=Gi),KS.has(n.shape)?(t.emitError("SHAPE_REMOVED",`shape "${n.shape}" was removed in v0.8.1, using "${Gi}"`,{nodeId:n.id}),n.shape=Gi):zS.has(n.shape)||(t.emitWarning("SHAPE_UNSUPPORTED",`shape "${n.shape}" is not supported, using "${Gi}"`,{nodeId:n.id}),n.shape=Gi))}var VS=new Set(["shape","view","icon","img","form","pos","w","h","class","style","labelType"]),jS=new Set(["subroutine","subprocess","subproc","framed-rectangle","tool"]);function XS(e){return jS.has(e.type)}function rd(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function Vp(e){return e.startsWith('"')&&e.endsWith('"')?e.substring(1,e.length-1):e}function sd(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function qS(e){let t=o=>Array.isArray(o)?[]:sd(o)?{}:o,n=t(e),r=[[e,n]];for(;r.length>0;){let[o,s]=r.pop();if(Array.isArray(o))for(let a of o){let i=t(a);s.push(i),typeof a=="object"&&a!==null&&r.push([a,i])}else if(sd(o))for(let a of Object.keys(o)){if(a==="__proto__"||a==="constructor"||a==="prototype")continue;let i=o[a],c=t(i);s[a]=c,typeof i=="object"&&i!==null&&r.push([i,c])}}return n}function ia(e,t){return Object.assign(e??{},t)}var QS=/:\s*[>|][\d+-]*\s*$/,ZS=/,([\t ]*)$/;function JS(e){let t=!1,n=!1,r=0,o,s=[];for(let a of e.split(`
43
+ `)){if(o!==void 0){let f=a.length-a.trimStart().length;if(a.trim()===""||f>o){s.push(a);continue}o=void 0}let i=-1;for(let f=0;f<a.length;f++){let p=a[f];if(n)p==="\\"?f++:p==='"'&&(n=!1);else if(t)p==="'"&&(t=!1);else if(p==='"')n=!0;else if(p==="'")t=!0;else if(p==="#"&&(f===0||a[f-1]===" "||a[f-1]===" ")){i=f;break}else p==="["||p==="{"?r++:(p==="]"||p==="}")&&(r=Math.max(0,r-1))}if(t||n||r>0){s.push(a);continue}let c=i>=0?a.slice(0,i):a,l=i>=0?a.slice(i):"";if(QS.test(c)){o=a.length-a.trimStart().length,s.push(a);continue}s.push(c.replace(ZS,"$1")+l)}return s.join(`
44
+ `)}function e1(e,t){if(e==="arrow_point"&&t==="normal")return"sequence";if(e==="arrow_cross"&&t==="normal")return"failure";if(e==="arrow_open"&&t==="dotted")return"reference"}function t1(e){let t=e.trim(),n=t.slice(0,-1),r="arrow_open";switch(t.slice(-1)){case"x":r="arrow_cross";break;case">":r="arrow_point";break;case"-":case".":n=t;break}let o="normal",s=n.length-1,a=0;for(let i=0;i<n.length;i++)n[i]==="."&&a++;return a>0&&(o="dotted",s=a),{type:r,stroke:o,length:s}}function jp(e){if(!e)return;let t={},n=!1;for(let r of Object.keys(e))VS.has(r)||(t[r]=e[r],n=!0);return n?t:void 0}var oa=class{type="agentflow";direction;nodes=new Map;edges=[];subgraphs=[];connectors=new Map;classes=new Map;tooltips=new Map;defaultEdgeStyle;defaultInterpolate;mappings=[];diagnostics=[];title;accTitle;accDescr;lineOffset;subgraphLookup=new Map;globalNodes=new Set;members=new Set;edgeById=new Map;pairCount=new Map;subCount=0;bareMappings=new Set;firstMapping=new Map;reported=new Map;options;constructor(t={}){this.options=t,this.lineOffset=t.lineOffset??0}metadata(t,n,r){let o=n.includes(`
45
+ `),s;try{s=Hn(o?n+`
46
+ `:`{
47
+ `+n+`
48
+ }`)}catch(a){let i=o?JS(n):n,c;if(i!==n)try{c=Hn(i+`
49
+ `)}catch{c=void 0}if(c===void 0){let l=r?` (${r.first_line+this.lineOffset}:${r.first_column+1})`:"";throw new Ge(`Metadata of "${t}" is not valid YAML. ${a.message}${l}`,"syntax",{type:"agentflow",line:r?r.first_line+this.lineOffset:0,column:r?r.first_column+1:0})}s=c}return qS(s??{})}shapeError(t,n){return new Ge(t,"semantic",{type:"agentflow",line:n?n.first_line+this.lineOffset:0,column:n?n.first_column+1:0})}addVertex(t,n,r,o,s,a,i={},c,l){if(!t||t.trim().length===0)return;let f,p,u;c!==void 0&&(f=this.metadata(t,c,l),sd(f)&&(p=f,typeof f.shape=="string"&&(u=f.shape,f.shape=Zs(f.shape))));let m=this.subgraphLookup.get(t);if(m&&f){m.metadata=ia(m.metadata,f);return}let h=this.connectors.get(t);if(h&&f){h.metadata=ia(h.metadata,f);return}if(t==="connectors")return;let g=this.edgeById.get(t);if(g){p?.animate!==void 0&&(g.animate=p.animate),p?.animation!==void 0&&(g.animation=p.animation),p?.curve!==void 0&&(g.interpolate=p.curve),f&&(g.metadata=ia(g.metadata,f));return}let x=this.nodes.get(t);if(x===void 0&&(x={id:t,labelType:"text",styles:[],classes:[]},this.nodes.set(t,x)),n!==void 0?(x.labelType=n.type,x.text=Vp(n.text.trim())):x.text===void 0&&(x.text=t),r!==void 0&&(x.type=r),o!=null)for(let y of o)x.styles.push(y);if(s!=null)for(let y of s)x.classes.push(y);if(a!==void 0&&(x.dir=a),x.props===void 0?x.props=i:i!==void 0&&Object.assign(x.props,i),!!f&&(x.metadata=ia(x.metadata,f),p!==void 0)){if(p.shape){let y=u??p.shape;if(typeof y!="string")throw this.shapeError(`No such shape: ${JSON.stringify(y)}.`,l);if(y!==y.toLowerCase()||y.includes("_"))throw this.shapeError(`No such shape: ${y}. Shape names should be lowercase.`,l);let _=p.shape;if(!Kp(_))throw this.shapeError(`No such shape: ${_}.`,l);x.type=_}p.label&&(x.text=String(p.label),x.labelType=rd(p.labelType))}}addSingleLink(t,n,r,o){let s={start:t,end:n,type:void 0,text:"",labelType:"text",classes:[],isUserDefinedId:!1,interpolate:this.defaultInterpolate},a=r?.text;a!==void 0&&(s.text=Vp(a.text.trim()),s.labelType=rd(a.type)),r!==void 0&&(s.type=r.type,s.stroke=r.stroke,s.length=r.length>10?10:r.length,r.edgeSemantic&&(s.edgeSemantic=r.edgeSemantic));let i=t+"\0"+n,c=this.pairCount.get(i)??0;o&&!this.edgeById.has(o)?(s.id=o,s.isUserDefinedId=!0):s.id=`L_${t}_${n}_${c===0?0:c+1}`;let l=this.options.maxEdges;if(l!==void 0&&this.edges.length>=l)throw new Ge(`Edge limit exceeded. ${this.edges.length} edges found, but the limit is ${l}.`,"limit",{type:"agentflow"});this.edges.push(s),this.pairCount.set(i,c+1),this.edgeById.has(s.id)||this.edgeById.set(s.id,s)}addLink(t,n,r){let o=typeof r?.id=="string"?r.id.replace("@",""):void 0,s=t[t.length-1],a=n[0];for(let i of t)for(let c of n)this.addSingleLink(i,c,r,i===s&&c===a?o:void 0)}updateLinkInterpolate(t,n){for(let r of t)r==="default"?this.defaultInterpolate=n:this.edgeAt(r).interpolate=n}updateLink(t,n){for(let r of t){if(r==="default"){this.defaultEdgeStyle=n;continue}let o=this.edgeAt(r);o.style=n,n.length>0&&!n.some(s=>s?.startsWith("fill"))&&n.push("fill:none")}}edgeAt(t){let n=this.edges[Number(t)];if(n===void 0)throw new Ge(`The index ${t} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${this.edges.length-1}. (Help: Ensure that the index is within the range of existing edges.)`,"semantic",{type:"agentflow"});return n}addClass(t,n){let r=n.join().replace(/\\,/g,"§§§").replace(/,/g,";").replace(/§§§/g,",").split(";");for(let o of t.split(",")){let s=this.classes.get(o);s===void 0&&(s={id:o,styles:[],textStyles:[]},this.classes.set(o,s));for(let a of r)a.includes("color")&&s.textStyles.push(a.replace("fill","bgFill")),s.styles.push(a)}}setDirection(t){let n=t.trim();n.includes("<")&&(n="RL"),n.includes("^")&&(n="BT"),n.includes(">")&&(n="LR"),n.includes("v")&&(n="TB"),n==="TD"&&(n="TB"),this.direction=n}setClass(t,n){for(let r of t.split(","))this.nodes.get(r)?.classes.push(n),this.edgeById.get(r)?.classes.push(n),this.subgraphLookup.get(r)?.classes.push(n)}setTooltip(t,n){if(n!==void 0)for(let r of t.split(","))this.tooltips.set(r,n)}setLink(t,n,r){let o=n.trim();for(let s of t.split(",")){let a=this.nodes.get(s);a!==void 0&&(a.link=o?vn(o):void 0,a.linkTarget=r)}this.setClass(t,"clickable")}setClickEvent(t,n,r){this.setClass(t,"clickable")}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
50
+ `)}addSubGraph(t,n,r,o){let s=t?.text?.trim(),a=r?.text||"";t!==void 0&&t===r&&/\s/.test(a)&&(s=void 0);let i=new Set,c=[],l;for(let h of n)if(typeof h=="string")h.trim()!==""&&!i.has(h)&&(i.add(h),c.push(h));else if(Array.isArray(h))for(let g of h)g.trim()!==""&&!i.has(g)&&(i.add(g),c.push(g));else l=h.value;l??=this.options.inheritDir?this.direction??this.options.direction:void 0,s??="subGraph"+this.subCount,this.subCount++;let f=this.members,p=c.filter(h=>h!==s&&!this.globalNodes.has(h)&&!f.has(h));for(let h of p)f.add(h);let u=this.subgraphLookup.get(s);if(u){for(let h of p)u.nodes.push(h);return a.trim()&&(u.title=a.trim()),l&&(u.dir=l),s}let m={id:s,nodes:p,title:a.trim(),classes:[],dir:l,labelType:rd(r?.type),type:"flow"};return this.subgraphs.push(m),this.subgraphLookup.set(s,m),s}addGlobal(t){let n=!1,r=o=>{let s=o.trim();s!==""&&(this.globalNodes.add(s),this.members.delete(s)&&(n=!0))};for(let o of t)if(typeof o=="string")r(o);else if(Array.isArray(o))for(let s of o)r(s);if(n)for(let o of this.subgraphs)o.nodes=o.nodes.filter(s=>!this.globalNodes.has(s))}addConnector(t,n){let r=t?.text?.trim();if(!r)return"";let o=n?.text?.trim()??"",s=this.connectors.get(r);if(s)o.length>0&&(s.text=o);else{let a={id:r,labelType:"text",styles:[],classes:[],isConnector:!0,text:o.length>0?o:r};this.connectors.set(r,a),this.nodes.set(r,a)}return r}destructLink(t,n){let r=t1(t);return n&&(n.includes(".")?"dotted":"normal")!==r.stroke?{type:"INVALID",stroke:"INVALID"}:{...r,edgeSemantic:e1(r.type,r.stroke)}}subgraph(t){return this.subgraphLookup.get(t)}vertexKind(t){if(XS(t))return"tool";let n=Zs(t.type);return n==="hexagon"||n==="hex"?"action":n==="lean-right"||n==="lean_right"?"input":n==="lin-doc"||n==="lined-document"?"refdoc":n==="diamond"?"decision":"task"}semanticModel(){let t=[],n=[];for(let[a,i]of this.nodes){if(this.subgraphLookup.has(a))continue;let c=jp(i.metadata);if(i.isConnector){let p={id:a};i.text!==void 0&&i.text!==a&&(p.title=i.text),c&&(p.metadata=c),n.push(p);continue}let l={id:a};i.text!==void 0&&(l.label=i.text);let f=Zs(i.type);f!==void 0&&(l.shape=f),l.vertexKind=this.vertexKind(i),c&&(l.metadata=c),t.push(l)}let r=this.edges.map(a=>{let i={start:a.start,end:a.end};return a.id!==void 0&&(i.id=a.id),a.text.length>0&&(i.label=a.text),a.type!==void 0&&(i.type=a.type),a.stroke!==void 0&&(i.stroke=a.stroke),a.edgeSemantic!==void 0&&(i.edgeSemantic=a.edgeSemantic),a.length!==void 0&&(i.length=a.length),a.metadata&&Object.keys(a.metadata).length>0&&(i.metadata={...a.metadata}),i}),o=this.subgraphs.map(a=>{let i={id:a.id,nodes:[...a.nodes],type:a.type,title:a.title};a.dir!==void 0&&(i.direction=a.dir);let c=jp(a.metadata);return c&&(i.metadata=c),i}),s={vertices:t,edges:r,subGraphs:o,connectors:n,diagnostics:this.diagnostics};return this.direction!==void 0&&(s.direction=this.direction),s}position(t){let n=t?.first_line??0,r=t?.first_column??0;return{startLine:n+this.lineOffset,startColumn:r,endLine:(t?.last_line??n)+this.lineOffset,endColumn:t?.last_column??r,startIndex:0,endIndex:0}}pushMapping(t,n,r){let o={id:t,type:n,position:r};return this.mappings.push(o),this.firstMapping.has(t)||this.firstMapping.set(t,o),o}addVertexMapping(t,n,r,o){if(!t)return;let s=this.pushMapping(t,"vertex",this.position(o));r==null&&this.bareMappings.add(s)}extendVertexMapping(t,n){if(!t||!n)return;let r=this.position(n);for(let o=this.mappings.length-1;o>=0;o--){let s=this.mappings[o];if(s.type!=="vertex"||s.id!==t)continue;this.bareMappings.delete(s)&&(s.type="attachment");let a=s.position;(r.endLine>a.endLine||r.endLine===a.endLine&&r.endColumn>a.endColumn)&&(a.endLine=r.endLine,a.endColumn=r.endColumn);return}this.pushMapping(t,"attachment",r)}addEdgeMapping(t,n,r,o){let s=Array.isArray(n)?n.filter(a=>typeof a=="string"&&a!==""):[];this.pushMapping(s.length>0?s.join(">"):"edge","edge",this.position(o))}blockMapping(t,n,r,o){if(!t)return;let s=this.position(r),a=o?this.position(o):s;this.pushMapping(t,n,{startLine:s.startLine,startColumn:s.startColumn,endLine:a.endLine,endColumn:a.endColumn,startIndex:0,endIndex:0})}addSubgraphMapping(t,n,r,o){let s=typeof t=="string"?t:t?.text;this.blockMapping(s??"","subgraph",r,o)}addConnectorMapping(t,n,r,o){this.blockMapping(t?.text?.trim()??"","connector",r,o)}emit(t,n,r,o){let s=o?.nodeId??o?.edgeId,a={id:t,severity:n,message:r};o?.nodeId?a.nodeId=o.nodeId:o?.edgeId&&(a.edgeId=o.edgeId);let i=s?this.firstMapping.get(s):void 0;i&&(a.position=i.position);let c=s??"",l=this.reported.get(c);if(l===void 0)this.reported.set(c,[a]);else{for(let f of l)if(f.id===t&&f.severity===n&&f.message===r&&f.nodeId===a.nodeId&&f.edgeId===a.edgeId)return;l.push(a)}this.diagnostics.push(a),this.options.log?.(n,`agentflow[${t}]: ${r}`)}emitWarning(t,n,r){this.emit(t,"warning",n,r)}emitError(t,n,r){this.emit(t,"error",n,r)}};var n1="4q 0 b 0 5 0 6 m 2 u 2 cp 5 b f 4 8 0 2 0 3m 4 2 1 3 3 9 0 2 2 2 0 2 j 2 2a 2 3u 9 4d a 11 3 0 8 12 21 q 6 2 1a 16 10 1 2 2q 2 0 g 1 8 1 b 2 3 0 h 0 2 t u 2g c 0 p w a 1 5 0 6 l 5 0 a 0 4 0 o o 20 0 2 a 2g 1h 4 0 j 0 8 9 g 6 2 6 6 7 3 1 3 l 2 6 2 0 4 3 4 0 h 0 e 1 2 2 f 1 k 5 5 1 3 l 2 6 2 1 2 1 2 1 w 3 2 0 k 2 h 8 2 2 2 l 2 6 2 1 2 4 4 0 j 0 g 1 10 7 3 1 3 l 2 6 2 1 2 4 4 0 v 1 2 2 g 0 i 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 b n 0 1h 7 2 2 2 m 2 9 2 4 4 0 r 1 7 1 10 7 2 2 2 m 2 9 2 4 4 0 x 0 2 1 g 1 j 7 2 2 2 14 3 0 h 0 i 1 p 5 6 h 4 n 2 8 2 0 3 6 1n 1b 2 1 d 6 1n 1 2 0 3 1 2 0 3 0 7 3 2 6 2 2 2 0 2 0 3 1 2 3 2 1 a 0 3 4 2 0 m 3 x 0 1s 7 2 z s 4 38 16 l 0 h 5 5 3 4 0 4 1 8 2 5 c d 0 i 11 2 0 6 0 3 16 2 98 2 3 3 6 2 0 2 3 3 14 2 3 3 w 2 3 3 6 2 0 2 3 3 e 2 1k 2 3 3 1u 12 f h 2c d h7 3 g 2 p 6 22 m c 2 3 f h f h f c 2 2 g 1f 10 0 5 0 1w 2f 9 14 2 0 6 1x b s 1g t 3 4 c 17 m 6 1l m a 1g 2b 0 2m 1a i 6 1k t e 1 b 17 r z 16 2 b z 30 3 2 3 4 1 a 5b 1t 7p 3 5 3 11 3 5 3 7 2 0 2 0 2 0 2 u 3 1g 2 6 2 0 4 2 2 6 4 3 3 5 5 c 6 2 2 6 39 0 e 0 h c 2u 0 5 0 3 9 2 0 4 4 7 0 2 0 2 0 2 3 2 a 3 3 6 4 5 0 1h 1 22k 1a 2 1a 2 3o 7 3 4 1 d 11 2 0 6 0 3 1j 8 0 h m a 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 29 0 d2 1 17 4 6 1 5 2d 7 2 2 2h 2 3 6 14 4 2l i q 1i f e9 52t 23 g5o 1g wc 1w 19 3 7g 4 f b 1 l 1a h o 9 1x 1e 8 3 2u 3 3 2 3 d a 26 9 2 2 2 3 2 m u 1f f 1d 1r 5 4 0 f r b m q s 8 1a t 0 1d 14 o 2 2 7 l m 4 0 6 1b 2 0 4 1 3 4 3 0 2 0 p 2 3 a 8 2 d 5 3 5 3 5 a 6 2 6 42 y u 8mb d m 5 1c 6it a5 3 2x 13 6 d 4 6 0 2 9 2 c 2 4 2 0 2 1 2 1 2 2z y a2 j 1r 3 1h 15 b 39 4 2 3q 11 p 7 p c 2g 4 5 3 5 3 5 3 2",r1;function s1(){let e=n1.split(" "),t=new Uint16Array(e.length),n=0;for(let r=0;r<e.length;r+=2){let o=n+parseInt(e[r],36);n=o+parseInt(e[r+1],36),t[r]=o,t[r+1]=n}return t}function Js(e){if(e<170||e>65500)return!1;let t=r1??=s1(),n=0,r=(t.length>>1)-1;for(;n<=r;){let o=n+r>>1;if(e<t[o*2])r=o-1;else if(e>t[o*2+1])n=o+1;else return!0}return!1}var id=["$end","INVALID","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","SHAPE_DATA","CALLBACKNAME","CALLBACKARGS","MD_STR","STR","STYLE","DEFAULT","LINKSTYLE","INTERPOLATE","CLASSDEF","CLASS","HREF","CLICK","GRAPH","flow","connector","global","end","LINK_TARGET","NODIR","DIR","direction_tb","direction_bt","direction_rl","direction_lr","direction_td","LINK_ID","NUM","BRKT","STYLE_SEPARATOR","COLON","AMP","SEMI","COMMA","MULT","LINK","START_LINK","EDGE_TEXT","-)","TEXT","(-","STADIUMEND","STADIUMSTART","SUBROUTINEEND","SUBROUTINESTART","VERTEX_WITH_PROPS_START","TAGEND","CYLINDEREND","CYLINDERSTART","DOUBLECIRCLEEND","DOUBLECIRCLESTART","TRAPEND","INVTRAPEND","TRAPSTART","INVTRAPSTART","TAGSTART","UP","SEP","DOWN","COMMENT","NODE_STRING","MINUS","UNICODE_TEXT","PIPE","PE","PS","SQE","SQS","DIAMOND_STOP","DIAMOND_START","NEWLINE","SPACE","EOF"];var Xp=new Uint8Array(128);for(let e of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")Xp[e.charCodeAt(0)]=1;var i1=/accTitle\s*:\s*/y,o1=/accDescr\s*:\s*/y,a1=/accDescr\s*\{\s*/y,c1=/call\s+/y,l1=/click\s+/y,d1=/(?:\r?\n)*\s*\n/y,u1=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,f1=/\s*[<>^]/y,p1=/\s*v\b/y,h1=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y,/.*direction\s+TD[^\n]*/y],od=/[\n\r\u2028\u2029]/g,m1=/\(\s*\)/y,g1=/\n\s*/g;function qp(e){let t=e.length,n=[],r=[],o=[],s=[],a=[],i=0,c=0,l=1,f=0,p=!0,u=e.indexOf("direction"),m=e.indexOf("@"),h=-1,g=0,x=0,y=-1,_=-1,S=-1,P=-1,k=-1,w=-1,I=-1,D=O=>{let v=-1;for(let W=c;W<O;W++){let H=e.charCodeAt(W);H===10?(l++,v=W):H===13&&(W+1<O&&e.charCodeAt(W+1)===10&&W++,l++,v=W)}if(v<0)f+=O-c;else{let W=v+1;for(;W<O;){let H=e.charCodeAt(W);if(H===8232||H===8233)break;W++}f=W-v-1}c=O},U=(O,v)=>{n.push(O),r.push(e.slice(c,v)),o.push(c),s.push(l,f),D(v),s.push(l,f)},M=(O,v)=>{n.push(O),r.push(e.slice(c,v)),o.push(c),s.push(l,f),f+=v-c,c=v,s.push(l,f)},Q=(O,v)=>{n.push(O),r.push(e.slice(c,v)),o.push(c),s.push(l,f);for(let W=c;W<v;W++){let H=e.charCodeAt(W);H===10||H===13?(l++,f=0):f++}c=v,s.push(l,f)},q=(O,v,W)=>{n.push(O),r.push(v),o.push(c),s.push(l,f),D(W),s.push(l,f)},Y=O=>{a.push(i),i=O},z=()=>{a.length>0&&(i=a.pop())},R=(O,v)=>(O.lastIndex=v,O.test(e)?O.lastIndex:-1),L=O=>e.startsWith(O,c)&&!Qe(e.charCodeAt(c+O.length)),F=O=>{if(O>=_&&O<=S)return S;let v=O;for(;v<t&&Be(e.charCodeAt(v));)v++;return _=O,S=v,v},E=O=>{if(O>=P&&O<=k)return k;let v=O;for(;v<t;){let W=e.charCodeAt(v);if(W!==32&&W!==9)break;v++}return P=O,k=v,v},C=O=>{let v=F(O);if(v===I||e.charCodeAt(v)!==45||e.charCodeAt(v+1)!==45)return-1;let W=v+2;for(;e.charCodeAt(W)===45;)W++;let H=e.charCodeAt(W);return H===120||H===62?F(W+1):(I=v,-1)},A=()=>{let O=F(c);if(O===w||e.charCodeAt(O)!==45)return!1;let v=e.charCodeAt(O+1),W=O+2;if(v===45){for(;e.charCodeAt(W)===45;)W++;let H=e.charCodeAt(W);return H===120||H===62?U(42,F(W+1)):(Y(10),U(43,F(O+2))),!0}if(v===46){for(;e.charCodeAt(W)===46;)W++;if(e.charCodeAt(W)===45)return U(42,F(W+1)),!0}return w=O,!1},T=O=>{if(e.charCodeAt(O)!==37||e.charCodeAt(O+1)!==37||e.charCodeAt(O+2)===123)return-1;let v=e.indexOf(`
51
+ `,O+2);return v===-1?t:v},b=()=>{e.charCodeAt(c+1)===96?(Y(2),D(c+2)):(Y(1),D(c+1))},N=O=>{let v=e.charCodeAt(c+1);return O===40?(v===45?(Y(8),M(47,c+2)):v===91?(Y(7),M(49,c+2)):v===40&&e.charCodeAt(c+2)===40?(Y(7),M(57,c+3)):(Y(7),M(72,c+1)),!0):O===91?(v===91?(Y(7),M(51,c+2)):v===40?(Y(7),M(55,c+2)):v===47?(Y(9),M(60,c+2)):v===92?(Y(9),M(61,c+2)):(Y(7),M(74,c+1)),!0):O===124?(Y(7),M(70,c+1),!0):O===123?(Y(7),M(76,c+1),!0):!1},$=()=>{let O=c;for(;O<t;){let v=e.charCodeAt(O);if(v<128&&Xp[v]===1)O++;else if(v===45&&O+1<t){let W=e.charCodeAt(O+1);if(W===62||W===45||W===46)break;O++}else break}return O===c?!1:(M(67,O),!0)},X=O=>{let v=O;for(;v<t;){let W=e.charCodeAt(v);if(W!==32&&W!==9)break;v++}return v},V=O=>{let v;switch(O){case 97:if(e.startsWith("acc",c)){if((v=R(i1,c))>=0)return Y(3),U(2,v),!0;if((v=R(o1,c))>=0)return Y(4),U(4,v),!0;if((v=R(a1,c))>=0)return Y(5),D(v),!0}if(L("agentflow-beta"))return p&&(p=!1,Y(6)),M(20,c+14),!0;break;case 64:if(e.charCodeAt(c+1)===123)return Y(14),q(7,"",c+2),!0;break;case 99:if((v=R(c1,c))>=0)return Y(12),D(v),!0;if(L("classDef"))return M(16,c+8),!0;if(L("class"))return M(17,c+5),!0;if((v=R(l1,c))>=0)return Y(11),D(v),!0;if(L("connector"))return M(22,c+9),!0;break;case 34:return b(),!0;case 115:if(L("style"))return M(12,c+5),!0;break;case 100:if(L("default"))return M(13,c+7),!0;break;case 108:if(L("linkStyle"))return M(14,c+9),!0;break;case 105:if(L("interpolate"))return M(15,c+11),!0;break;case 104:if(e.startsWith("href",c)&&Be(e.charCodeAt(c+4)))return U(18,c+5),!0;break;case 102:if(L("flow"))return M(21,c+4),!0;break;case 103:if(L("global"))return M(23,X(c+6)),!0;break;case 101:if(L("end"))return M(24,X(c+3)),!0;break;case 95:if(L("_self"))return M(25,c+5),!0;if(L("_blank"))return M(25,c+6),!0;if(L("_parent"))return M(25,c+7),!0;if(L("_top"))return M(25,c+4),!0;break}if(u!==-1&&c>=g&&(u<c&&(u=e.indexOf("direction",c)),u!==-1&&(h<c&&(od.lastIndex=c,h=od.test(e)?od.lastIndex-1:t),u<h))){for(let W=0;W<5;W++)if((v=R(h1[W],c))>=0)return U(28+W,v),!0;g=h}if(m!==-1&&O!==34&&!Be(O)){if(c>=x){m<c&&(m=e.indexOf("@",c));let W=c;for(;W<t;){let H=e.charCodeAt(W);if(H===34||Be(H))break;W++}if(x=W,y=-1,m!==-1&&m<W)for(let H=Math.min(W,t-1)-1;H>=m;H--){if(e.charCodeAt(H)!==64)continue;let G=e.charCodeAt(H+1);if(G!==123&&G!==34){y=H;break}}}if(y>c)return M(33,y+1),!0}if(O>=48&&O<=57){let W=c+1;for(;W<t;){let H=e.charCodeAt(W);if(H<48||H>57)break;W++}return M(34,W),!0}switch(O){case 35:return M(35,c+1),!0;case 58:return e.charCodeAt(c+1)===58&&e.charCodeAt(c+2)===58?M(36,c+3):M(37,c+1),!0;case 38:return M(38,c+1),!0;case 59:return M(39,c+1),!0;case 44:return M(40,c+1),!0;case 42:return M(41,c+1),!0;case 60:return M(62,c+1),!0;case 45:return A()||$()||M(68,c+1),!0;case 40:return N(O);case 91:return e.charCodeAt(c+1)===124?(M(52,c+2),!0):N(O);case 124:case 123:return N(O);case 62:return Y(7),M(53,c+1),!0;case 94:return M(63,c+1),!0;case 92:return e.charCodeAt(c+1)===124?(M(64,c+2),!0):$();case 118:return Qe(e.charCodeAt(c+1))?$():(M(65,c+1),!0);case 37:return(v=T(c))>=0?(U(66,v),!0):$()}if(Be(O)){if(A())return!0;if((O===32||O===9)&&(v=T(E(c)))>=0)return U(66,v),!0;for(v=c;;){let W=e.charCodeAt(v);if(W===10)v++;else if(W===13&&e.charCodeAt(v+1)===10)v+=2;else break}return v>c?U(77,v):U(78,c+1),!0}return O<128?$():Js(O)?(M(69,c+1),!0):!1};e:for(;;){if(c>=t){let W=-1;switch(i){case 0:W=79;break;case 3:W=3;break;case 4:W=5;break;case 5:W=6;break;case 11:W=19;break;case 12:W=8;break;case 13:W=9;break}W!==-1&&M(W,t);break}let O=e.charCodeAt(c),v=!0;switch(i){case 0:v=V(O);break;case 1:if(O===34)e.charCodeAt(c+1)===96?(Y(2),D(c+2)):(z(),D(c+1));else{let W=e.indexOf('"',c);U(11,W===-1?t:W)}break;case 2:if(O===96)e.charCodeAt(c+1)===34?(z(),D(c+2)):v=!1;else if(O===34)b();else{let W=c+1;for(;W<t;){let H=e.charCodeAt(W);if(H===96||H===34)break;W++}U(10,W)}break;case 3:case 4:{let W=e.indexOf(`
52
+ `,c);W===-1&&(W=t);let H=i===3?3:5;z(),U(H,W);break}case 5:if(O===125)z(),D(c+1);else{let W=e.indexOf("}",c);W===-1&&(W=t),U(6,W)}break;case 6:{let W;O===34?b():(W=R(d1,c))>=0?(z(),U(26,W)):(W=R(u1,c))>=0||(W=R(f1,c))>=0||(W=R(p1,c))>=0?(z(),U(27,W)):v=N(O);break}case 7:{let W=e.charCodeAt(c+1);switch(O){case 34:b();break;case 40:case 91:case 123:N(O);break;case 93:z(),W===41?M(48,c+2):W===93?M(50,c+2):M(73,c+1);break;case 41:z(),W===93?M(54,c+2):W===41&&e.charCodeAt(c+2)===41?M(56,c+3):M(71,c+1);break;case 124:z(),M(70,c+1);break;case 125:z(),M(75,c+1);break;case 37:{let H=T(c);H>=0?D(H):v=!1;break}default:{let H=c+1;for(;H<t;){let G=e.charCodeAt(H);if(G===91||G===93||G===40||G===41||G===123||G===125||G===124||G===34||G===37)break;H++}U(46,H)}}break}case 8:{let W=e.charCodeAt(c+1),H;if(O===34)b();else if(O===37&&(H=T(c))>=0)D(H);else if((O===45||O===47||O===41)&&W===41)z(),M(45,c+2);else if(O===40||O===91||O===123)N(O);else if(O===41||O===93||O===125)v=!1;else{let G=c+1;for(;G<t;){let te=e.charCodeAt(G);if(te===34||te===40||te===41||te===91||te===93||te===123||te===125||(te===45||te===47)&&e.charCodeAt(G+1)===41||te===37&&e.charCodeAt(G+1)===37&&e.charCodeAt(G+2)!==123)break;G++}Q(46,G)}break}case 9:{let W=e.charCodeAt(c+1);if(O===34){b();break}switch(O){case 40:W===45||W===91||W===40&&e.charCodeAt(c+2)===40?N(O):W===93?(z(),M(58,c+2)):N(O);break;case 91:case 123:N(O);break;case 92:W===93?(z(),M(58,c+2)):M(46,c+1);break;case 47:W===93?(z(),M(59,c+2)):M(46,c+1);break;case 93:case 41:W===93?(z(),M(58,c+2)):v=!1;break;case 125:v=!1;break;case 37:{let H=T(c);H>=0?D(H):v=!1;break}default:{if((O===63||O===61)&&W===93){z(),M(58,c+2);break}let H=c+1;for(;H<t;){let G=e.charCodeAt(H);if(G===92||G===91||G===93||G===40||G===41||G===123||G===125||G===47||G===37)break;H++}U(46,H)}}break}case 10:{if(O===34){b();break}let W=C(c);if(W>=0){z(),U(42,W);break}if(O===45&&e.charCodeAt(c+1)===45){v=!1;break}let H=c+1;for(;H<t;){let G=e.charCodeAt(H);if(G===34)break;if(G===45){if(e.charCodeAt(H+1)===45)break}else if(Be(G)&&C(H)>=0)break;H++}Q(44,H);break}case 11:if(O===34)b();else if(Be(O))z(),D(c+1);else{let W=c+1;for(;W<t&&!Be(e.charCodeAt(W));)W++;M(19,W)}break;case 12:if(O===40){let W=R(m1,c);z(),W>=0?D(W):(Y(13),D(c+1))}else{let W=e.indexOf("(",c);W===-1&&(W=t),U(8,W)}break;case 13:if(O===41)z(),D(c+1);else{let W=e.indexOf(")",c);W===-1&&(W=t),U(9,W)}break;case 14:if(O===34)Y(15),M(7,c+1);else if(O===125)z(),D(c+1);else if(O===94)v=!1;else{let W=c+1;for(;W<t;){let H=e.charCodeAt(W);if(H===125||H===94||H===34)break;W++}U(7,W)}break;case 15:if(O===34)z(),M(7,c+1);else{let W=e.indexOf('"',c);W===-1&&(W=t),q(7,e.slice(c,W).replace(g1,"<br/>"),W)}break}if(!v)return n.push(1),r.push(""),o.push(c),s.push(l,f,l,f),{types:n,texts:r,starts:o,locs:s};continue e}return n.push(0),r.push(""),o.push(t),s.push(l,f,l,f),{types:n,texts:r,starts:o,locs:s}}var aa=new Uint8Array(80);for(let e of[34,67,65,68,13,40,37,38,35,41,69])aa[e]=1;var cd=new Uint8Array(80);for(let e of[34,69,67,27,65,68,40,37,38,35,41])cd[e]=1;var ld=new Uint8Array(80);for(let e of[34,67,78,68,38,69,37,41,35,12,14,16,17,19,20,27,21,22,23,24,65,63,43])ld[e]=1;var dd=new Uint8Array(80);for(let e of[34,67,37,78,35,12])dd[e]=1;var ca=new Uint8Array(80);for(let e of[77,39,79,66])ca[e]=1;var Qp="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",ad="'COMMENT', 'SEMI', 'NEWLINE', 'EOF'",Yi=[],b1=/}[^\S\n]*\n/g;function Jp(e,t,n=!1){let r=!n&&e.includes("}")?e.replace(b1,`}
53
+ `):e,{types:o,texts:s,starts:a,locs:i}=qp(r),c=0,l,f=0,p=0,u=b=>{let N=o[c];throw N===1?it("agentflow",r,a[c],"",!0):it("agentflow",r,a[c],`Expecting ${b}, got '${id[N]}'`)},m=(b,N)=>({first_line:i[4*b],first_column:i[4*b+1],last_line:i[4*N+2],last_column:i[4*N+3]}),h=(b,N="")=>(o[c]!==b&&u(`'${id[b]}'${N?", "+N:""}`),s[c++]),g=()=>{ca[o[c]]===0&&u(ad),c++},x=()=>{aa[o[c]]===0&&u("'NODE_STRING'");let b=s[c++];for(;aa[o[c]]===1;)b+=s[c++];return b},y=()=>{cd[o[c]]===0&&u("'NODE_STRING'");let b=s[c++];for(;cd[o[c]]===1;)b+=s[c++];return b},_=()=>{let b=o[c],N;if(b===11)N="string";else if(b===10)N="markdown";else if(b===46||b===62||b===53||b===69)N="text";else return u(`${Qp}, 'TAGEND', 'STR', 'MD_STR'`);let $=s[c++];for(;;){let X=o[c];if(X!==46&&X!==62&&X!==53&&X!==69)break;$+=s[c++]}return{text:$,type:N}},S=b=>{h(b,Qp)},P=()=>{let b=o[c],N;if(b===11)N="string";else if(b===10)N="markdown";else if(b===44||b===69)N="text";else return u("'EDGE_TEXT', 'STR', 'MD_STR'");let $=s[c++];for(;o[c]===44||o[c]===69;)$+=s[c++];return{text:$,type:N}},k=()=>{let b=o[c],N;if(b===11)N="text";else if(b===10)N="markdown";else if(ld[b]===1)N="text";else return u("'NODE_STRING', 'STR', 'MD_STR'");let $=s[c++];for(;ld[o[c]]===1;)$+=s[c++];return{text:$,type:N}},w=()=>{f=c;let b=s[c++];for(;o[c]===7;)b+=s[c++];return p=c-1,b},I=(b,N,$,X)=>{let V=m($,X);t.addVertex(b,void 0,void 0,void 0,void 0,void 0,void 0,N,V),t.extendVertexMapping(b,V)},D=(b,N)=>{N.data!==void 0&&t.addVertex(b,void 0,void 0,void 0,void 0,void 0,void 0,N.data,m(N.dataFrom,N.dataTo))},U=()=>{let b=c,N=x(),$,X,V;switch(o[c]){case 74:c++,$=_(),S(73),X="square";break;case 57:c++,$=_(),S(56),X="doublecircle";break;case 72:c++,o[c]===72?(c++,$=_(),S(71),h(71),X="circle"):($=_(),S(71),X="round");break;case 47:c++,$=_(),S(45),X="ellipse";break;case 49:c++,$=_(),S(48),X="stadium";break;case 51:c++,$=_(),S(50),X="subroutine";break;case 52:{c++;let O=h(67);h(37);let v=h(67);h(70),$=_(),S(73),X="rect",V={[O]:v};break}case 55:c++,$=_(),S(54),X="cylinder";break;case 76:c++,o[c]===76?(c++,$=_(),S(75),h(75),X="hexagon"):($=_(),S(75),X="diamond");break;case 53:c++,$=_(),S(73),X="odd";break;case 60:c++,$=_(),o[c]===59?(c++,X="lean_right"):(S(58),X="trapezoid");break;case 61:c++,$=_(),o[c]===58?(c++,X="lean_left"):(S(59),X="inv_trapezoid");break}return V!==void 0?t.addVertex(N,$,X,void 0,void 0,void 0,V):X!==void 0?t.addVertex(N,$,X):t.addVertex(N),t.addVertexMapping(N,$,X,m(b,c-1)),N},M=()=>{let b=U();return o[c]===36&&(c++,t.setClass(b,x())),b},Q=()=>{let b=[M()];for(l=void 0;;){let $=o[c]===7?w():void 0,X=f,V=p;if(o[c]!==78)return l=$,b;do c++;while(o[c]===78);if(o[c]!==38)return $!==void 0&&u("'AMP'"),b;c++,o[c]!==78&&u("'SPACE'");do c++;while(o[c]===78);let O=M();$!==void 0&&I(b[b.length-1],$,X,V),b.push(O)}},q=()=>{let b;if(o[c]===33&&(b=s[c++]),o[c]===42){let N=t.destructLink(s[c++]);return b!==void 0&&(N.id=b),o[c]===70&&(c++,N.text=_(),S(70),o[c]===78&&c++),N}if(o[c]===43){let N=s[c++],$=P(),X=h(42,"'EDGE_TEXT'"),V=t.destructLink(X,N);return V.text=$,b!==void 0&&(V.id=b),V}return u("'LINK', 'START_LINK'")},Y=()=>{let b=c,N=Q();l!==void 0&&I(N[N.length-1],l,f,p);let $=N;for(;;){let X=o[c];if(X!==42&&X!==43&&X!==33)return $;let V=q(),O=Q();l!==void 0&&I(O[O.length-1],l,f,p),t.addLink(N,O,V),t.addEdgeMapping(N,O,V,m(b,c-1)),$=O.concat($),N=O}},z=()=>{dd[o[c]]===0&&u("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let b=s[c++];for(;dd[o[c]]===1;)b+=s[c++];return b},R=()=>{let b=[z()];for(;o[c]===40;)c++,b.push(z());return b},L=()=>{c++,h(78);let b;if(o[c]===13)b=[s[c++]];else for(b=[h(34,"'DEFAULT'")];o[c]===40;)c++,b.push(h(34));if(h(78),o[c]!==15){t.updateLink(b,R());return}c++,h(78);let N=y();if(o[c]===78){c++;let $=R();t.updateLinkInterpolate(b,N),t.updateLink(b,$)}else t.updateLinkInterpolate(b,N)},F=(b,N)=>{if(o[c]!==78){t.setLink(b,N);return}if(c++,o[c]===25){t.setLink(b,N,s[c++]);return}let $=h(11,"'LINK_TARGET'");o[c]===78?(c++,t.setLink(b,N,h(25))):t.setLink(b,N),t.setTooltip(b,$)},E=()=>{let b=s[c++];switch(o[c]){case 8:{let N=s[c++],$=o[c]===9,X=$?s[c++]:void 0,V;o[c]===78&&(c++,V=h(11)),$?t.setClickEvent(b,N,X):t.setClickEvent(b,N),V!==void 0&&t.setTooltip(b,V);return}case 18:c++,F(b,h(11));return;case 11:F(b,s[c++]);return;default:{let N=y();if(o[c]===78){c++;let $=h(11);t.setClickEvent(b,N),t.setTooltip(b,$)}else t.setClickEvent(b,N)}}},C=b=>{h(78,ad);let N=k(),$={text:"",type:"text"};o[c]===74&&(c++,$=_(),S(73));let X=o[c]===7?w():void 0;return ca[o[c]]===0&&u(`${ad}, 'SHAPE_DATA'`),{global:!1,at:b,id:N,title:$,data:X,dataFrom:f,dataTo:p,list:[],collect:!1}},A=()=>{let b=o[c];switch(b){case 12:{c++,h(78);let N=x();return h(78),t.addVertex(N,void 0,void 0,R()),g(),Yi}case 14:return L(),g(),Yi;case 16:{c++,h(78);let N=x();return h(78),t.addClass(N,R()),g(),Yi}case 17:{c++,h(78);let N=x();return h(78),t.setClass(N,x()),g(),Yi}case 19:return E(),g(),Yi;case 22:{let N=C(c++),$=c++,X=t.addConnector(N.id,N.title);return D(X,N),t.addConnectorMapping(N.id,N.title,m(N.at,N.at),m($,$)),X}case 28:case 29:case 30:case 31:case 32:return c++,{stmt:"dir",value:y1[b-28]};case 2:{c++;let N=h(3).trim();return t.setAccTitle(N),N}case 4:{c++;let N=h(5).trim();return t.setAccDescription(N),N}case 6:{let N=s[c++].trim();return t.setAccDescription(N),N}default:{aa[b]===0&&u(Zp);let N=Y();return g(),N}}},T=()=>{let b=[],N=[],$=!1;for(;;){let X=o[c];if(X===0)break;if(X===24){let V=b.pop();if(V===void 0)break;let O=c++;if(V.global){t.addGlobal(N),N=V.list,$=V.collect;continue}let v=t.addSubGraph(V.id,N,V.title,"flow");D(v,V),t.addSubgraphMapping(V.id,V.title,m(V.at,V.at),m(O,O)),N=V.list,$=V.collect,$&&N.push(v)}else if(X===39||X===77||X===78||X===79)$&&N.push(s[c]),c++;else if(X===66)c++;else if(X===21||X===23){let V=c++,O;X===23||ca[o[c]]===1?(O={global:X===23,at:V,id:void 0,title:void 0,data:void 0,dataFrom:0,dataTo:0,list:N,collect:$},g()):(O=C(V),O.list=N,O.collect=$,c++),b.push(O),N=[],$=!0}else{let V=A();$&&(!Array.isArray(V)||V.length>0)&&N.push(V)}}b.length>0&&u("'end'")};for(;o[c]===78||o[c]===77||o[c]===66;)c++;if(h(20,"'SPACE', 'NEWLINE', 'COMMENT'"),o[c]===26)c++,t.setDirection("TB");else{let b=h(27,"'NODIR'"),N=o[c];if(N===78){do c++;while(o[c]===78);N=o[c],N!==77&&u("'NEWLINE', 'SPACE'")}else N!==39&&N!==77&&N!==66&&u("'COMMENT', 'SEMI', 'NEWLINE', 'SPACE'");c++,t.setDirection(b)}T(),o[c]!==0&&u(Zp)}var y1=["TB","BT","RL","LR","TD"],Zp="'COMMENT', 'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'flow', 'global', 'connector', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'";function ti(e,t,n=0){return{w:e,h:t,kind:n,pin:0,span:0,x:0,y:0,rank:0}}function ni(e,t,n=1,r=0,o=0){return{tail:e,head:t,minlen:n,labelW:r,labelH:o,tailDx:0,headDx:0,tailFixed:!1,headFixed:!1,reversed:!1,points:[],labelX:0,labelY:0}}var E1=24,eh=2e4,ud=16,th=8,A1=.125,nh=3,x1=18,S1=10,_1=14,w1=2,R1=28,rh=12,T1=12,C1=8,I1=4,sh=.5,Sr=.5,ih=12,N1=40,oh=400;function ei(e){return e===1||e===2}function ah(e,t,n,r){for(let o=t+1;o<n;o++){let s=e[o],a=r[s],i=o-1;for(;i>=t&&(r[e[i]]>a||r[e[i]]===a&&e[i]>s);)e[i+1]=e[i],i--;e[i+1]=s}}function ch(e,t,n){let r=e.length;if(r===0)return{width:0,height:0};let o=t.length,s=1;if(o>0){let j=new Set;for(let ie of t){let ue=Math.min(ie.tail,ie.head),ge=Math.max(ie.tail,ie.head),Se=ue*r+ge;if(ie.labelW>0||j.has(Se)){s=2;break}j.add(Se)}}Hi(e,t),Ki(e,t,s);let a=new Int32Array(o),i=0;for(let j=0;j<o;j++){let ie=t[j];a[j]=Math.abs(e[ie.head].rank-e[ie.tail].rank),a[j]>1&&(i+=a[j]-1)}let c=new Uint8Array(o);if(i>eh){let j=[];for(let ie=0;ie<o;ie++)a[ie]>1&&j.push(ie);j.sort((ie,ue)=>a[ue]-a[ie]||ie-ue);for(let ie of j){if(i<=eh)break;c[ie]=1,i-=a[ie]-1}}let l=r+i,f=new Float64Array(l),p=new Float64Array(l),u=new Uint8Array(l),m=new Int32Array(l),h=0;for(let j=0;j<r;j++){let ie=e[j];f[j]=ie.w,p[j]=ie.h,u[j]=ie.kind,m[j]=ie.rank,ie.rank>h&&(h=ie.rank)}let g=0;for(let j=0;j<o;j++)c[j]||(g+=a[j]);let x=new Int32Array(g),y=new Int32Array(g),_=new Float64Array(g),S=new Float64Array(g),P=new Int32Array(o).fill(-1),k=new Uint8Array(h+1),w=new Int32Array(o).fill(-1),I=!1;for(let j=0;j<r;j++)e[j].span>0&&e[j].kind===0&&(I=!0);let D=I?new Uint8Array(g):void 0,U=I?new Uint8Array(g):void 0,M=new Int32Array(o).fill(-1),Q=new Int32Array(o).fill(-1),q=!1;{let j=r,ie=0;for(let ue=0;ue<o;ue++){if(c[ue])continue;let ge=t[ue],Se=ge.reversed?ge.head:ge.tail,we=ge.reversed?ge.tail:ge.head,ke=ge.reversed?ge.headDx:ge.tailDx,Le=ge.reversed?ge.tailDx:ge.headDx;(ke!==0||Le!==0)&&(q=!0);let Fe=m[Se],He=m[we],_e=-1;ge.labelW>0&&(_e=Fe+(He-Fe>>1),s===2&&He-Fe>=4?(_e&1)===1&&(_e+=ge.reversed?1:-1):s===2&&(_e&1)===0&&(_e+=ge.reversed?1:-1));let Pe=Se;He-Fe>1&&(P[ue]=j),M[ue]=ie,D&&!(ge.reversed?ge.headFixed:ge.tailFixed)&&(D[ie]=ge.reversed?2:1);for(let Ye=Fe+1;Ye<He;Ye++){let Ue=j++;m[Ue]=Ye,Ye===_e?(f[Ue]=ge.labelW,p[Ue]=ge.labelH,u[Ue]=2,w[ue]=Ue,k[Ye]|=ge.reversed?2:1):u[Ue]=1,x[ie]=Pe,y[ie]=Ue,_[ie]=Pe===Se?ke:0,ie++,Pe=Ue}x[ie]=Pe,y[ie]=we,_[ie]=Pe===Se?ke:0,S[ie]=Le,U&&!(ge.reversed?ge.tailFixed:ge.headFixed)&&(U[ie]=ge.reversed?1:2),Q[ue]=ie,ie++}}let Y=new Int32Array(l+1),z=new Int32Array(l+1);for(let j=0;j<g;j++)Y[x[j]+1]++,z[y[j]+1]++;for(let j=0;j<l;j++)Y[j+1]+=Y[j],z[j+1]+=z[j];let R=new Int32Array(g),L=new Int32Array(g);{let j=Y.slice(0,l),ie=z.slice(0,l);for(let ue=0;ue<g;ue++)R[j[x[ue]]++]=ue,L[ie[y[ue]]++]=ue}let F=new Int32Array(h+2);for(let j=0;j<l;j++)F[m[j]+1]++;for(let j=0;j<=h;j++)F[j+1]+=F[j];let E=new Int32Array(l),C=new Int32Array(l);{let j=new Int32Array(l),ie=F.slice(0,h+1);for(let Se=0;Se<l;Se++)j[ie[m[Se]]++]=Se;ie.set(F.subarray(0,h+1));let ue=new Uint8Array(l),ge=[];for(let Se=0;Se<l;Se++)if(!ue[j[Se]])for(ge.push(j[Se]);ge.length>0;){let we=ge.pop();if(!ue[we]){ue[we]=1,E[ie[m[we]]++]=we;for(let ke=Y[we+1]-1;ke>=Y[we];ke--){let Le=y[R[ke]];ue[Le]||ge.push(Le)}}}}let A=!1;for(let j=0;j<r;j++)e[j].pin!==0&&(A=!0);if(A)for(let j=0;j<=h;j++){let ie=Array.from(E.subarray(F[j],F[j+1])),ue=new Map;ie.forEach((Se,we)=>ue.set(Se,we));let ge=Se=>Se<r?e[Se].pin:0;ie.sort((Se,we)=>ge(Se)-ge(we)||ue.get(Se)-ue.get(we)),E.set(ie,F[j])}let T=()=>{for(let j=0;j<=h;j++){let ie=F[j];for(let ue=ie,ge=F[j+1];ue<ge;ue++)C[E[ue]]=ue-ie}};T();let b={n:l,real:r,maxRank:h,W:f,KIND:u,RANK:m,EF:x,ET:y,EFD:_,ETD:S,succStart:Y,succE:R,predStart:z,predE:L,layerStart:F,order:E,pos:C,offsets:q};g>0&&h>0&&(F1(b,e),T()),D&&U&&M1(b,e,D,U);let N=W1(b,n),$=O1(b);if(D&&U){let j=k1(b,D,U);L1(b,e,N,j,n,$),$1(b,e,N,D,U,j,$),D1(b,N,$,n);for(let ie=0;ie<o;ie++){if(c[ie])continue;let ue=t[ie],ge=_[M[ie]],Se=S[Q[ie]];ue.tailDx=ue.reversed?Se:ge,ue.headDx=ue.reversed?ge:Se}}let X=new Uint8Array(l);$&&!n.tracks&&P1(b,N,$,P,a,n.apart?0:n.edgeSep,X),n.tracks||B1(b,N,P,a,n.edgeSep,X);let V=new Int32Array(o+1),O=n.tracks||D&&!n.straight?{from:[],to:[],rank:[],lower:[],track:[],levels:[],wide:[]}:void 0,v=new Int32Array(h+1);if(O){for(let j=0;j<o;j++){if(V[j]=O.from.length,c[j])continue;let ie=P[j],ue=!1;for(let we=ie,ke=ie<0?ie:ie+a[j]-1;we<ke;we++){let Le=$!==void 0&&$[m[we]]===1;!n.tracks&&Le!==(X[we]===1)&&(ue=!0)}if(ue)continue;let ge=N[x[M[j]]]+_[M[j]],Se=m[x[M[j]]];for(let we=ie,ke=ie<0?ie:ie+a[j]-1;we<ke;we++)$&&$[m[we]]||(O.from.push(ge),O.to.push(N[we]),O.rank.push(Se),O.lower.push(we),ge=N[we],Se=m[we]);O.from.push(ge),O.to.push(N[y[Q[j]]]+S[Q[j]]),O.rank.push(Se),O.lower.push(-1)}V[o]=O.from.length}let W=(j,ie)=>{let ue=!1;for(let ge=F[j];ge<F[j+1];ge++){let Se=u[E[ge]];if(Se===ie)ue=!0;else if(Se!==1)return!1}return ue},H=W(0,3)?s:0,G=W(h,4)?s:0,te=new Float64Array(h+1);for(let j=0;j<g;j++){let ie=Math.abs(N[x[j]]+_[j]-N[y[j]]-S[j]);ie>te[m[x[j]]]&&(te[m[x[j]]]=ie)}let Z=new Float64Array(h+1),B=new Float64Array(h+1),K=j=>(j<H||j>=h-G?n.portSep:n.rankSep)/s,ee=new Float64Array(h+1);for(let j=0;j<h;j++)ee[j]=O?K(j):Math.max(K(j),Math.min(nh*n.rankSep/s,te[j]*A1));let ae=new Uint8Array(h+1).fill(1);for(let j=0;j<r;j++)ae[m[j]]=0;for(let j=1;j<h;j++){if(n.tracks||!ae[j]||k[j]!==1&&k[j]!==2)continue;let ie=Math.min((n.headRoom??0)/2,ee[k[j]===1?j-1:j]/2);ee[j-1]+=k[j]===1?-ie:ie,ee[j]+=k[j]===1?ie:-ie}let J=j=>u[j]===1&&ae[m[j]]&&!n.tracks?(B[m[j]]-Z[m[j]])/4:0,se=n.tracks?x1:R1,me=n.tracks?S1:rh,Ae=n.tracks?_1:rh,de=new Int32Array(h+1);if(O){let j=new Float64Array(h+1);for(let ue=0;ue<h;ue++){if($&&$[ue])continue;let ge=ue+1;for(j[ue]=ee[ue];ge<h&&$&&$[ge];)j[ue]+=ee[ge++];de[ue]=ge}for(let ue=0;ue<O.from.length;ue++)O.wide.push(Math.abs(O.from[ue]-O.to[ue])>w1*j[O.rank[ue]]?1:0);let ie=new Float64Array(h+1);v1(O,v,!n.tracks,j,ie);for(let ue=0;ue<h;ue++)v[ue]>0?ee[ue]+=Math.max(0,2*se+(v[ue]-1)*me-j[ue]):ie[ue]>0&&(ee[ue]+=Math.max(0,Math.min(nh*n.rankSep,ie[ue])-j[ue]))}let oe=0;for(let j=0;j<=h;j++){let ie=0;for(let ue=F[j];ue<F[j+1];ue++)p[E[ue]]>ie&&(ie=p[E[ue]]);Z[j]=oe,B[j]=oe+ie,oe+=ie+ee[j]}let ye=oe,ce=(j,ie=O.track[j])=>{let ue=O.rank[j],ge=B[ue],Se=Z[de[ue]],we=n.tracks?v[ue]:O.levels[j],ke=we>1?Math.min(Ae,(Se-ge-2*se)/(we-1)):0;return(ge+Se)/2+(ie-(we-1)/2)*ke},fe=1/0,xe=-1/0;for(let j=0;j<l;j++){let ie=f[j]/2;N[j]-ie<fe&&(fe=N[j]-ie),N[j]+ie>xe&&(xe=N[j]+ie)}let be=new Uint8Array(h+1),re=new Uint8Array(h+1);for(let j=0;j<r;j++)u[j]!==0||!D||(z[j+1]>z[j]&&(be[m[j]]=1),Y[j+1]>Y[j]&&(re[m[j]]=1));for(let j=0;j<r;j++){let ie=e[j],ue=ie.rank;ie.x=N[j]-fe,u[j]===0&&re[ue]&&!be[ue]?ie.y=B[ue]-ie.h/2:u[j]===0&&be[ue]&&!re[ue]?ie.y=Z[ue]+ie.h/2:ie.y=(Z[ue]+B[ue])/2}for(let j=0;j<o;j++){let ie=t[j],ue=e[ie.reversed?ie.head:ie.tail],ge=e[ie.reversed?ie.tail:ie.head],Se=[ue.x+(ie.reversed?ie.headDx:ie.tailDx),ue.y+ue.h/2],we=P[j];if(O&&V[j+1]>V[j])for(let Le=V[j];Le<V[j+1];Le++){if(O.track[Le]>=0&&(n.tracks||O.wide[Le]===1)){let He=ce(Le);Se.push(O.from[Le]-fe,He,O.to[Le]-fe,He)}else O.track[Le]>0&&Se.push(O.from[Le]-fe,ce(Le,O.track[Le]-1));let Fe=O.lower[Le];Fe<0||(Se.push(N[Fe]-fe,Z[m[Fe]]+J(Fe)),B[m[Fe]]>Z[m[Fe]]&&Se.push(N[Fe]-fe,B[m[Fe]]-J(Fe)))}else if(we>=0)for(let Le=we,Fe=we+a[j]-1;Le<Fe;Le++){if(X[Le])continue;let He=N[Le]-fe,_e=Z[m[Le]],Pe=B[m[Le]];Se.push(He,_e+J(Le)),Pe>_e&&Se.push(He,Pe-J(Le))}if(Se.push(ge.x+(ie.reversed?ie.tailDx:ie.headDx),ge.y-ge.h/2),ie.reversed)for(let Le=0,Fe=Se.length-2;Le<Fe;Le+=2,Fe-=2){let He=Se[Le],_e=Se[Le+1];Se[Le]=Se[Fe],Se[Le+1]=Se[Fe+1],Se[Fe]=He,Se[Fe+1]=_e}ie.points=Se;let ke=w[j];ke>=0?(ie.labelX=N[ke]-fe,ie.labelY=(Z[m[ke]]+B[m[ke]])/2):ie.labelW>0&&(ie.labelX=(Se[0]+Se[Se.length-2])/2,ie.labelY=(Se[1]+Se[Se.length-1])/2)}return{width:xe-fe,height:ye}}function Hi(e,t){let n=e.length,r=t.length,o=new Int32Array(n+1);for(let l=0;l<r;l++){let f=t[l];f.reversed=e[f.head].kind===3||e[f.tail].kind===4,f.reversed||o[f.tail+1]++}for(let l=0;l<n;l++)o[l+1]+=o[l];let s=new Int32Array(o[n]);{let l=o.slice(0,n);for(let f=0;f<r;f++)t[f].reversed||(s[l[t[f].tail]++]=f)}let a=new Uint8Array(n),i=o.slice(0,n),c=[];for(let l=0;l<n;l++)if(a[l]===0)for(c.push(l),a[l]=1;c.length>0;){let f=c[c.length-1];if(i[f]<o[f+1]){let p=t[s[i[f]++]],u=p.head;a[u]===1?p.reversed=!0:a[u]===0&&(a[u]=1,c.push(u))}else a[f]=2,c.pop()}}function Ki(e,t,n){let r=e.length,o=t.length,s=new Int32Array(o),a=new Int32Array(o),i=new Int32Array(o),c=new Int32Array(r+1),l=new Int32Array(r+1);for(let S=0;S<o;S++){let P=t[S],k=P.reversed?P.head:P.tail,w=P.reversed?P.tail:P.head;s[S]=k,a[S]=w,i[S]=Math.max(1,P.minlen)*n,c[k+1]++,l[w+1]++}for(let S=0;S<r;S++)c[S+1]+=c[S],l[S+1]+=l[S];let f=new Int32Array(o),p=new Int32Array(o);{let S=c.slice(0,r),P=l.slice(0,r);for(let k=0;k<o;k++)f[S[s[k]]++]=k,p[P[a[k]]++]=k}let u=new Int32Array(r),m=new Int32Array(r);for(let S=0;S<r;S++)m[S]=l[S+1]-l[S];let h=new Int32Array(r),g=0;for(let S=0;S<r;S++)m[S]===0&&(h[g++]=S);for(let S=0;S<g;S++){let P=h[S];for(let k=c[P];k<c[P+1];k++){let w=f[k],I=a[w];u[P]+i[w]>u[I]&&(u[I]=u[P]+i[w]),--m[I]===0&&(h[g++]=I)}}for(let S=0;S<8;S++){let P=!1;for(let k=g-1;k>=0;k--){let w=h[k],I=l[w+1]-l[w],D=c[w+1]-c[w];if(I===0&&D===0)continue;let U=-1/0,M=1/0;for(let q=l[w];q<l[w+1];q++){let Y=p[q];U=Math.max(U,u[s[Y]]+i[Y])}for(let q=c[w];q<c[w+1];q++){let Y=f[q];M=Math.min(M,u[a[Y]]-i[Y])}let Q=u[w];D>I&&M!==1/0?Q=M:I>D&&U!==-1/0&&(Q=U),Q!==u[w]&&(u[w]=Q,P=!0)}if(!P)break}let x=1/0,y=-1/0,_=!1;for(let S=0;S<r;S++){let P=e[S].kind;P===3&&(_=!0),!(P===3||P===4)&&(u[S]<x&&(x=u[S]),u[S]>y&&(y=u[S]))}x===1/0&&(x=0,y=0);for(let S=0;S<r;S++)e[S].kind===3?u[S]=x-n:e[S].kind===4&&(u[S]=y+n);_&&(x-=n);for(let S=0;S<r;S++)e[S].rank=u[S]-x}function lh(e,t,n,r,o,s,a){let i=n===0?e.predStart:e.succStart,c=n===0?e.predE:e.succE,l=n===0?e.EF:e.ET,f=e.pos;s.length=0;for(let h=i[t];h<i[t+1];h++)o[c[h]]!==0&&s.push(c[h]);if(s.length<2)return 0;s.sort((h,g)=>f[l[h]]-f[l[g]]||h-g);let p=h=>{let g=0;a.length=s.length,a[0]=0;for(let x=1;x<s.length;x++){let y=o[s[x]]===o[s[x-1]];a[x]=h(y&&o[s[x]]===1,y),g+=a[x]}return g},u=p(()=>1);if(r/u<th&&(u=p(h=>h?.5:1)),r/u<th&&(u=p((h,g)=>g?0:1)),u===0)return 0;let m=Math.min(ud,r/u);for(let h=1;h<s.length;h++)a[h]*=m;return u*m}function M1(e,t,n,r){let{real:o,W:s,EFD:a,ETD:i}=e,c=[],l=[];for(let f=0;f<o;f++){let p=Math.min(t[f].span,s[f]);if(!(p<=0||t[f].kind!==0))for(let u=0;u<2;u++){let m=lh(e,f,u,p,u===0?r:n,c,l);if(m===0)continue;let h=u===0?i:a,g=-m/2;for(let x=0;x<c.length;x++)g+=l[x],h[c[x]]=g}}}function la(e,t,n,r){if(!t)return n;let{KIND:o,RANK:s,EF:a,ET:i,succStart:c,succE:l,predStart:f,predE:p}=e;for(let u=0;u<1e5;u++){let m=r===0?a[n]:i[n];if(o[m]!==1||!t[s[m]])break;n=r===0?p[f[m]]:l[c[m]]}return n}function k1(e,t,n){let r=[new Int32Array(e.n),new Int32Array(e.n)];for(let o=0;o<e.EF.length;o++)n[o]!==0&&r[0][e.ET[o]]++,t[o]!==0&&r[1][e.EF[o]]++;return r}function fd(e,t){return Math.max(.25,Math.min(.5,4*Math.abs(t)/(Math.abs(e)||1)))}function L1(e,t,n,r,o,s){let a=o.edgeSep,{n:i,real:c,maxRank:l,KIND:f,RANK:p,W:u,EF:m,ET:h,EFD:g,ETD:x,succStart:y,succE:_,predStart:S,predE:P,layerStart:k,order:w,pos:I}=e,D=z=>f[z]===2||f[z]===1&&!(s!==void 0&&s[p[z]]===1),U=(z,R)=>{let L=R===0?m[z]:h[z];return[R===0?n[L]+g[z]:n[L]+x[z],L<c&&t[L].kind===0?r[1-R][L]:0]},M=z=>{let R=k[p[z]],L=R+I[z],F=E=>u[E]/2+u[z]/2+(f[E]===0?o.nodeSep/2+a/2:f[E]===f[z]?a:a/2);return[L>R?n[w[L-1]]+F(w[L-1]):-1/0,L+1<k[p[z]+1]?n[w[L+1]]-F(w[L+1]):1/0]},Q=(z,R,L,F,E)=>{let A=(R[1]!==L[1]?R[1]<L[1]:Math.abs(R[0]-z)<=Math.abs(L[0]-z))?[R[0],L[0]]:[L[0],R[0]];return A.find(T=>T>=F&&T<=E)??Math.max(F,Math.min(E,A[0]))},q=new Uint8Array(i),Y=[];for(let z=1;z<l;z++)for(let R=k[z];R<k[z+1];R++){if(!D(w[R])||q[w[R]])continue;let L=w[R];for(;ei(f[m[P[S[L]]]]);)L=m[P[S[L]]];let F=L,E=-1/0,C=1/0;Y.length=0;for(let A=L;ei(f[A]);A=h[_[y[A]]]){if(F=A,!D(A))continue;q[A]=1,Y.push(A);let[T,b]=M(A);T>E&&(E=T),b<C&&(C=b)}if(E<=C){let A=Q(n[Y[0]],U(P[S[L]],0),U(_[y[F]],1),E,C);for(let T of Y)n[T]=A;continue}for(let A of Y){let[T,b]=M(A);T>b||(n[A]=Q(n[A],U(la(e,s,P[S[A]],0),0),U(la(e,s,_[y[A]],1),1),T,b))}}}function $1(e,t,n,r,o,s,a){let{real:i,W:c,EF:l,ET:f,EFD:p,ETD:u,succStart:m,succE:h,predStart:g,predE:x,pos:y}=e,_=[],S=[],P=[],k=[],w=[],I=(D,U,M,Q,q)=>{if(s[U][M]<2)return 0;D=la(e,a,D,U);let Y=U===0?l[D]:f[D],z=U===0?n[Y]+p[D]:n[Y]+u[D];if(q&&Math.abs(z-n[M])<=Q/2+Sr)return Math.max(-Q/2,Math.min(Q/2,z-n[M]));let R=z,L=0;Y<i&&t[Y].kind===0&&(U===0?r:o)[D]!==0&&s[1-U][Y]>=2&&(L=Math.max(0,Math.min(t[Y].span,c[Y])),L>0&&(R=n[Y]));let F=Math.max(n[M]-Q/2,R-L/2),E=Math.min(n[M]+Q/2,R+L/2);if(F>E+Sr){let A=Math.max(0,Q/2-N1);return Math.max(-A,Math.min(A,z-n[M]))}let C=(n[M]*L+R*Q)/(L+Q);return Math.max(F,Math.min(E,C))-n[M]};for(let D=0,U=!0;U&&D<6;D++){U=!1;for(let M=0;M<i;M++){let Q=Math.min(t[M].span,c[M]);if(!(Q<=0||t[M].kind!==0))for(let q=0;q<2;q++){let Y=q===0?o:r,z=q===0?u:p,R=q===0?l:f,L=q===0?g:m,F=q===0?x:h;if(lh(e,M,q,Q,Y,_,S),_.length===0)continue;_.length===1&&(S[0]=0),P.length=0;for(let A=L[M];A<L[M+1];A++)P.push(F[A]);P.sort((A,T)=>y[R[A]]-y[R[T]]||A-T);let E=0,C=-Q/2;for(let A=0;A<=P.length;A++){let T=A<P.length&&Y[P[A]]===0;if(A<P.length&&!T)continue;let b=0;for(let $=A-1;$>=0&&Y[P[$]]!==0;$--)b++;let N=T?z[P[A]]-ud:Q/2;if(b>0){k.length=0,w.length=0;let $=0;for(let O=0;O<b;O++){O>0&&($+=S[E+O]),k.push(I(_[E+O],q,M,Q,D>0)-$),w.push(1);let v=O>0&&S[E+O]===0;for(;k.length>1&&(v||k[k.length-2]/w[w.length-2]>k[k.length-1]/w[w.length-1]);){v=!1;let W=k.pop(),H=w.pop();k[k.length-1]+=W,w[w.length-1]+=H}}let X=$,V=0;$=0;for(let O=0;O<k.length;O++){let v=N-X<C?(C+N-X)/2:Math.max(C,Math.min(N-X,k[O]/w[O]));for(let W=0;W<w[O];W++,V++)V>0&&($+=S[E+V]),Math.abs(z[_[E+V]]-v-$)>.01&&(U=!0),z[_[E+V]]=v+$}E+=b}T&&(C=z[P[A]]+ud)}}}}}function D1(e,t,n,r){let{n:o,KIND:s,RANK:a,EF:i,ET:c,EFD:l,ETD:f,layerStart:p,order:u,pos:m}=e,h=M=>n!==void 0&&s[M]===1&&n[a[M]]===1,g=[],x=[],y=[],_=[];for(let M=0;M<i.length;M++){if(h(i[M]))continue;let Q=la(e,n,M,1);g.push(i[M]),x.push(c[Q]),y.push(l[M]),_.push(f[Q])}let S=M=>t[x[M]]+_[M]-t[g[M]]-y[M],P=new Int32Array(o),k=[];for(let M=0;M<o;M++)P[M]=M,k.push([M]);let w=(M,Q)=>{let q=P[M],Y=P[Q];if(q!==Y){k[q].length<k[Y].length&&([q,Y]=[Y,q]);for(let z of k[Y])P[z]=q,k[q].push(z);k[Y]=[]}},I=[];for(let M=0;M<g.length;M++){let Q=Math.abs(S(M));Q<.01?w(g[M],x[M]):Q<=ih&&I.push(M)}if(I.length===0)return;I.sort((M,Q)=>Math.abs(S(M))-Math.abs(S(Q))||M-Q);let D=M=>dh(e,r,M),U=(M,Q)=>{for(let q of k[M]){let Y=p[a[q]],z=p[a[q]+1],R=Y+m[q];if(R>Y&&P[u[R-1]]!==M&&t[q]+Q-t[u[R-1]]<D(q)+D(u[R-1])-.01||R+1<z&&P[u[R+1]]!==M&&t[u[R+1]]-t[q]-Q<D(q)+D(u[R+1])-.01)return!1}return!0};for(let M of I){let Q=S(M);if(Math.abs(Q)<.01){w(g[M],x[M]);continue}if(Math.abs(Q)>ih||P[g[M]]===P[x[M]])continue;let q=P[g[M]],Y=P[x[M]],z=k[q].length<=k[Y].length?q:Y;for(let R of[z,z===q?Y:q]){let L=R===q?Q:-Q;if(U(R,L)){for(let F of k[R])t[F]+=L;w(g[M],x[M]);break}}}}function O1(e){let{maxRank:t,KIND:n,layerStart:r,order:o}=e,s=new Uint8Array(t+1),a=!1;for(let i=1;i<t;i++){let c=r[i+1]>r[i];for(let l=r[i];c&&l<r[i+1];l++)n[o[l]]!==1&&(c=!1);c&&(s[i]=1,a=!0)}return a?s:void 0}function v1(e,t,n,r,o){let{from:s,to:a,rank:i,track:c,levels:l,wide:f}=e,p=s.length,u=new Map;for(let q=0;q<p;q++){if(c.push(-1),l.push(0),Math.abs(s[q]-a[q])<Sr)continue;let Y=u.get(i[q]);Y?Y.push(q):u.set(i[q],[q])}let m=new Float64Array(p),h=new Float64Array(p);for(let q=0;q<p;q++)m[q]=Math.min(s[q],a[q]),h[q]=Math.max(s[q],a[q]);let g=(q,Y)=>q>=m[Y]-Sr&&q<=h[Y]+Sr?1:0,x=(q,Y)=>Math.abs(s[q]-s[Y])<Sr||Math.abs(a[q]-a[Y])<Sr,y=(q,Y)=>m[q]<h[Y]-Sr&&m[Y]<h[q]-Sr,_=(q,Y)=>y(q,Y)&&!x(q,Y),S=(q,Y)=>y(q,Y)||g(a[q],Y)+g(s[Y],q)+g(a[Y],q)+g(s[q],Y)>0,P=(q,Y)=>g(a[q],Y)+g(s[Y],q),k=q=>{q.sort((b,N)=>h[N]-m[N]-(h[b]-m[b])||m[b]-m[N]||b-N);let Y=q.length,z=[],R=q.map((b,N)=>N),L=b=>{for(;R[b]!==b;)b=R[b]=R[R[b]];return b},F=q;if(Y<=oh){let b=new Int32Array(Y),N=[];for(let V=0;V<Y;V++)z.push([]),N.push([]);for(let V=0;V<Y;V++)for(let O=V+1;O<Y;O++){let v=q[V],W=q[O];if(!S(v,W))continue;R[L(V)]=L(O);let H=P(v,W),G=P(W,v);if(H===G)continue;let te=H<G?V:O,Z=H<G?O:V;z[Z].push(te),N[te].push(Z),b[Z]++}let $=new Uint8Array(Y),X=[];for(let V=0;V<Y;V++){let O=-1;for(let v=0;v<Y&&!(!$[v]&&((O<0||b[v]<b[O])&&(O=v),b[v]===0));v++);$[O]=1,X.push(O);for(let v of N[O])b[v]--}F=X.map(V=>q[V])}let E=new Map;q.forEach((b,N)=>E.set(b,N));let C=[];for(let b of F){let N=0;for(let $ of z[E.get(b)]??[])c[q[$]]>=N&&(N=c[q[$]]+1);for(;;N++){let $=C[N]??=[],X=!0;for(let V of $)_(b,V)&&(X=!1);if(X){$.push(b);break}}c[b]=N}let A=new Map,T=new Map;return q.forEach((b,N)=>{let $=L(N);A.set($,Math.min(A.get($)??1/0,c[b])),T.set($,Math.max(T.get($)??-1/0,c[b]))}),q.forEach((b,N)=>{let $=L(N);l[b]=T.get($)-A.get($)+1,n&&(c[b]-=A.get($))}),C.length},w=16,I=(q,Y,z)=>{let R=fd(a[q]-s[q],Y);for(let L=0;L<=w;L++){let F=L/w,E=1-F;z[2*L]=s[q]+(a[q]-s[q])*F*F*(3-2*F),z[2*L+1]=Y*(3*R*F*E*E+3*(1-R)*F*F*E+F*F*F)}},D=new Float64Array(2*w+2),U=new Float64Array(2*w+2),M=(q,Y)=>{let z=1/0;for(let R=0;R<=w;R++){let L=q[2*R],F=q[2*R+1];for(let E=0;E<w;E++){let C=Y[2*E+2]-Y[2*E],A=Y[2*E+3]-Y[2*E+1],T=Math.max(0,Math.min(1,((L-Y[2*E])*C+(F-Y[2*E+1])*A)/(C*C+A*A||1))),b=Math.hypot(L-Y[2*E]-T*C,F-Y[2*E+1]-T*A);b<z&&(z=b)}}return z},Q=(q,Y,z)=>{let R=Math.max(z/2,z-2*T1);return I(q,R,D),I(Y,R,U),Math.min(M(D,U),M(U,D))};for(let[q,Y]of u){if(!n){t[q]=k(Y);continue}if(Y.length>oh)continue;let z=Y.filter(b=>f[b]===1);k(z);let R=new Set(z.filter(b=>l[b]>1));for(let b=0;b<Y.length;b++)for(let N=b+1;N<Y.length;N++){let $=Y[b],X=Y[N];R.has($)&&R.has(X)||!_($,X)||s[$]<a[$]!=s[X]<a[X]||Q($,X,r[q])<(f[$]===1||f[X]===1?C1:I1)&&R.add($).add(X)}for(let b of z)c[b]=-1,l[b]=0;if(R.size===0)continue;let L=0,F=0,E=[...R];for(let b=0;b<E.length;b++)for(let N=b+1;N<E.length;N++){let $=E[b],X=E[N];y($,X)&&(s[$]<a[$]!=s[X]<a[X]?L++:x($,X)||F++)}if(L>F){for(let b of Y)(h[b]-m[b])*sh>o[q]&&(o[q]=(h[b]-m[b])*sh);continue}let C=b=>{for(let N of R)if(S(b,N))return!0;return!1},A=Y.filter(b=>R.has(b)||f[b]!==1&&C(b));k(A);let T=0;for(let b of A)l[b]>T&&(T=l[b]);t[q]=T}}function P1(e,t,n,r,o,s,a){let{maxRank:i,EF:c,ET:l,EFD:f,ETD:p,succStart:u,succE:m,predStart:h,predE:g,layerStart:x,order:y}=e,_=new Float64Array(t.length),S=new Float64Array(t.length),P=new Float64Array(t.length);for(let w=0;w<r.length;w++){let I=r[w];if(I<0)continue;let D=I+o[w]-1,U=e.RANK[I];for(let M=I;M<D;M++){if(!n[U+M-I])continue;let Q=M;for(;Q+1<D&&n[U+Q+1-I];)Q++;let q=g[h[M]],Y=m[u[Q]],z=t[c[q]]+f[q],R=t[l[Y]]+p[Y],L=Q-M+2;for(let F=M;F<=Q;F++)_[F]=z+(R-z)*(F-M+1)/L,S[F]=z,P[F]=R;M=Q}}let k=[];for(let w=1;w<i;w++){if(!n[w])continue;let I=x[w],D=x[w+1],U=Array.from(y.subarray(I,D)).sort((M,Q)=>S[M]-S[Q]||P[M]-P[Q]||M-Q);for(let M=0;M<U.length;){k.length=0;let Q=M;for(;Q<U.length&&Math.abs(S[U[Q]]-S[U[M]])<1&&Math.abs(P[U[Q]]-P[U[M]])<1;Q++)k.push(U[Q]);k.sort((q,Y)=>e.pos[q]-e.pos[Y]);for(let q=0;q<k.length;q++){let Y=k[q];t[Y]=_[Y]+(q-(k.length-1)/2)*s,(k.length===1||s===0)&&(a[Y]=1)}M=Q}}}function B1(e,t,n,r,o,s){let{maxRank:a,W:i,KIND:c,RANK:l,EF:f,ET:p,EFD:u,ETD:m,succStart:h,succE:g,predStart:x,predE:y,layerStart:_,order:S}=e,P=new Uint8Array(a+1),k=!1;for(let w=1;w<a;w++){let I=!1,D=!1;for(let U=_[w];U<_[w+1];U++){let M=c[S[U]];M===2?I=!0:M!==1&&(D=!0)}I&&!D&&(P[w]=1,k=!0)}if(k)for(let w=0;w<n.length;w++){let I=n[w];if(!(I<0))for(let D=I,U=I+r[w]-1;D<U;D++){if(c[D]!==1||!P[l[D]])continue;let M=D,Q=D;for(;M>I&&s[M-1];)M--;for(;Q+1<U&&s[Q+1];)Q++;let q=y[x[M]],Y=g[h[Q]],z=t[f[q]]+u[q],R=t[p[Y]]+m[Y],L=Math.min(z,R)-o,F=Math.max(z,R)+o,E=!0,C=l[D];for(let T=_[C];E&&T<_[C+1];T++){let b=S[T];c[b]===2&&t[b]+i[b]/2>L&&t[b]-i[b]/2<F&&(E=!1)}if(!E)continue;s[D]=1;let A=Q-M+2;for(let T=M;T<=Q;T++)t[T]=z+(R-z)*(T-M+1)/A}}}function F1(e,t){let{n,real:r,maxRank:o,W:s,EF:a,ET:i,EFD:c,ETD:l,succStart:f,succE:p,predStart:u,predE:m,layerStart:h,order:g,pos:x,offsets:y}=e,_=0;for(let b=0;b<=o;b++)_=Math.max(_,h[b+1]-h[b]);let S=y?new Int32Array(a.length):void 0,P=1;for(;P<(S?_+a.length:_);)P<<=1;let k=new Int32Array(2*P),w=new Int32Array(a.length),I=()=>{let b=0;for(let N=0;N<o;N++){let $=h[N+2]-h[N+1];if(S){let O=0;for(let v=h[N+1];v<h[N+2];v++){let W=u[g[v]],H=u[g[v]+1],G=!1;for(let te=W+1;te<H;te++)l[m[te]]!==l[m[W]]&&(G=!0);if(G){let te=Array.from(m.subarray(W,H));te.sort((Z,B)=>l[Z]-l[B]);for(let Z=0;Z<te.length;Z++)Z>0&&l[te[Z]]!==l[te[Z-1]]&&O++,S[te[Z]]=O}else for(let te=W;te<H;te++)S[m[te]]=O;O++}$=O}if($<2)continue;let X=0;for(let O=h[N];O<h[N+1];O++){let v=g[O],W=f[v],H=f[v+1],G=X;for(let B=W;B<H;B++)w[X++]=S?S[p[B]]:x[i[p[B]]];let te=X-G;if(te<2)continue;let Z=!1;if(S)for(let B=W+1;B<H;B++)c[p[B]]!==c[p[W]]&&(Z=!0);if(S&&Z){let B=Array.from(p.subarray(W,H));B.sort((K,ee)=>c[K]-c[ee]||S[K]-S[ee]);for(let K=0;K<te;K++)w[G+K]=S[B[K]]}else if(te<=12)for(let B=G+1;B<X;B++){let K=w[B],ee=B-1;for(;ee>=G&&w[ee]>K;)w[ee+1]=w[ee],ee--;w[ee+1]=K}else w.subarray(G,X).sort()}if(X<2)continue;let V=1;for(;V<$;)V<<=1;k.fill(0,0,2*V);for(let O=0;O<X;O++){let v=w[O]+V;for(k[v]++;v>1;)(v&1)===0&&(b+=k[v+1]),v>>=1,k[v]++}}return b},D=I();if(D===0)return;let U=g.slice(),M=new Float64Array(n),Q=new Int32Array(_),q=(b,N)=>M[b]-M[N]||x[b]-x[N],Y=(b,N)=>M[b]-M[N]||x[N]-x[b],z=(b,N)=>{let $=b?u:f,X=b?m:p,V=b?a:i,O=b?c:l;for(let v=1;v<=o;v++){let W=b?v:o-v,H=h[W],G=h[W+1],te=0;for(let B=H;B<G;B++){let K=g[B],ee=K<r?t[K].pin:0;if(ee!==0){M[K]=ee*1e9,Q[te++]=K;continue}let ae=$[K],J=$[K+1];if(ae===J){M[K]=-1;continue}let se=0;for(let me=ae;me<J;me++){let Ae=V[X[me]];se+=x[Ae],y&&s[Ae]>0&&(se+=O[X[me]]/s[Ae])}M[K]=se/(J-ae),Q[te++]=K}if(te<2)continue;Q.subarray(0,te).sort(N?Y:q);let Z=0;for(let B=H;B<G;B++)M[g[B]]!==-1&&(g[B]=Q[Z++]);for(let B=H;B<G;B++)x[g[B]]=B-H}},R=()=>{let b=0;for(let N=0;N<=o;N++)for(let $=h[N];$<h[N+1];$++)if(!(g[$]>=r))for(let X=$+1;X<h[N+1];X++)g[X]<g[$]&&b++;return b},L=()=>{for(let b=0;b<=o;b++)for(let N=h[b];N<h[b+1];N++)x[g[N]]=N-h[b]},F=g.slice(),E=D,C=n<=600,A=U,T=1/0;for(let b=0;b<(C?2:1);b++){b>0&&(g.set(F),L());let N=E,$=F.slice();for(let V=0,O=0;O<4&&V<E1;V++,O++){z((V+b)%2===0,V%4>=2);let v=I();if(v<N&&(N=v,$.set(g),O=0,v===0))break}g.set($);let X=C?R():0;(b===0||N<D||N===D&&X<T)&&(D=N,A=$,T=X)}if(g.set(A),L(),U.set(A),!!C){for(let b=0;b<r;b++)if(t[b].pin!==0)return;if(T!==0){for(let b=0;b<=o;b++)g.subarray(h[b],h[b+1]).reverse();L(),(I()>D||R()>=T)&&g.set(U)}}}function dh(e,t,n){return e.W[n]/2+(e.KIND[n]===0?t.nodeSep:t.edgeSep)/2}function W1(e,t){let{n,maxRank:r,W:o,KIND:s,EF:a,ET:i,EFD:c,ETD:l,succStart:f,succE:p,predStart:u,predE:m,layerStart:h,order:g,pos:x}=e,y=a.length,_=new Float64Array(n);for(let b=0;b<n;b++)_[b]=dh(e,t,b);let S=new Int32Array(y);for(let b=0;b<y;b++)S[b]=x[i[b]];for(let b=0;b<n;b++)f[b+1]-f[b]>1&&ah(p,f[b],f[b+1],S);for(let b=0;b<y;b++)S[b]=x[a[b]];for(let b=0;b<n;b++)u[b+1]-u[b]>1&&ah(m,u[b],u[b+1],S);let P=new Uint8Array(y);for(let b=1;b<=r;b++){let N=h[b]-h[b-1],$=h[b],X=h[b+1],V=0,O=$;for(let v=$;v<X;v++){let W=g[v],H=-1;if(ei(s[W])){let te=a[m[u[W]]];ei(s[te])&&(H=te)}let G=H>=0?x[H]:N;if(H>=0||v===X-1){for(let te=O;te<=v;te++){let Z=g[te],B=ei(s[Z]);for(let K=u[Z];K<u[Z+1];K++){let ee=m[K],ae=x[a[ee]];(ae<V||G<ae)&&!(B&&ei(s[a[ee]]))&&(P[ee]=1)}}O=v+1,V=G}}}let k=[],w=new Int32Array(n),I=new Int32Array(n),D=new Float64Array(n),U=new Int32Array(n),M=new Int32Array(n),Q=new Float64Array(n),q=new Int32Array(n),Y=new Int32Array(n+1),z=new Int32Array(n),R=new Int32Array(n),L=new Int32Array(n);for(let b=0;b<4;b++){let N=b<2,$=(b&1)===1,X=N?u:f,V=N?m:p,O=N?a:i,v=N?l:c,W=N?c:l;for(let B=0;B<n;B++)w[B]=B,I[B]=B,D[B]=0;for(let B=0;B<=r;B++){let K=N?B:r-B,ee=h[K],ae=h[K+1],J=N?K-1:K+1,se=J>=0&&J<=r?h[J+1]-h[J]-1:0,me=-1;for(let Ae=$?ae-1:ee;$?Ae>=ee:Ae<ae;$?Ae--:Ae++){let de=g[Ae],oe=X[de],ye=X[de+1]-oe;if(ye===0)continue;let ce=oe+(ye-1>>1),fe=oe+(ye>>1);for(let xe=0;xe<2&&!(xe===1&&ce===fe);xe++){let be=V[xe===0!==$?ce:fe],re=O[be],j=$?se-x[re]:x[re];I[de]===de&&me<j&&P[be]===0&&(I[re]=de,I[de]=w[de]=w[re],D[de]=D[re]+W[be]-v[be],me=j)}}}let H=0;q.fill(0),Y.fill(0);for(let B=0;B<=r;B++){let K=h[B],ee=h[B+1];for(let ae=K+1;ae<ee;ae++){let J=$?g[ae]:g[ae-1],se=$?g[ae-1]:g[ae],me=_[J]+_[se];U[H]=w[J],M[H]=w[se],Q[H]=$?me-D[J]+D[se]:me+D[J]-D[se],q[w[se]]++,Y[w[J]+1]++,H++}}for(let B=0;B<n;B++)Y[B+1]+=Y[B];R.set(Y.subarray(0,n));for(let B=0;B<H;B++)z[R[U[B]]++]=B;let G=new Float64Array(n),te=0;for(let B=0;B<n;B++)w[B]===B&&q[B]===0&&(L[te++]=B);for(let B=0;B<te;B++){let K=L[B];for(let ee=Y[K];ee<Y[K+1];ee++){let ae=z[ee],J=M[ae];G[K]+Q[ae]>G[J]&&(G[J]=G[K]+Q[ae]),--q[J]===0&&(L[te++]=J)}}for(let B=te-1;B>=0;B--){let K=L[B],ee=1/0;for(let ae=Y[K];ae<Y[K+1];ae++){let J=z[ae],se=G[M[J]]-Q[J];se<ee&&(ee=se)}ee!==1/0&&ee>G[K]&&(G[K]=ee)}let Z=new Float64Array(n);for(let B=0;B<n;B++)Z[B]=($?-G[w[B]]:G[w[B]])+D[B];k.push(Z)}let F=0,E=1/0,C=[],A=[];for(let b=0;b<4;b++){let N=1/0,$=-1/0,X=k[b];for(let V=0;V<n;V++){let O=o[V]/2;X[V]-O<N&&(N=X[V]-O),X[V]+O>$&&($=X[V]+O)}C.push(N),A.push($),$-N<E&&(E=$-N,F=b)}for(let b=0;b<4;b++){let N=(b&1)===0?C[F]-C[b]:A[F]-A[b];if(N!==0){let $=k[b];for(let X=0;X<n;X++)$[X]+=N}}let T=new Float64Array(n);for(let b=0;b<n;b++){let N=k[0][b],$=k[1][b],X=k[2][b],V=k[3][b],O;N>$&&(O=N,N=$,$=O),X>V&&(O=X,X=V,V=O),N>X&&(O=N,N=X,X=O),$>V&&(O=$,$=V,V=O),$>X&&(O=$,$=X,X=O),T[b]=($+X)/2}return T}function tn(e){return e==="BT"||e==="LR"||e==="RL"?e:"TB"}var U1=4e4;function vr(e,t,n,r){for(let o of e)o.x+=n,o.y+=r;for(let o of t){for(let s=0;s<o.route.length;s+=3)o.route[s]+=n,o.route[s+1]+=r;o.labelX+=n,o.labelY+=r}}function $t(e,t,n=-1){return{w:e,h:t,parent:n,isGroup:!1,dir:void 0,padX:0,padTop:0,padBottom:0,minW:0,seq:0,span:0,x:0,y:0}}function uh(e){return e==="TB"?0:e==="BT"?2:e==="LR"?3:1}function pd(e){return e+2&3}function Sn(e,t,n,r){let o=e.length,s=new Map,a=[],i=(w,I)=>{let D={id:w,dir:I,items:[],edges:[],ports:[],portOf:new Map,routes:new Map,x:0,y:0};return s.set(w,D),D},c=i(-1,n),l=[];for(let w=0;w<o;w++)l.push([]);let f=[];for(let w=0;w<o;w++){let I=e[w].parent;I>=0&&I<o&&I!==w&&e[I].isGroup?l[I].push(w):(e[w].parent=-1,f.push(w))}c.items=f,a.push(c);let p=new Int32Array(o),u=new Uint8Array(o),m=w=>{for(let I=w;I<a.length;I++){let D=a[I];for(let U of D.items)if(u[U]=1,p[U]=D.id<0?0:p[D.id]+1,e[U].isGroup){let M=i(U,e[U].dir??D.dir);M.items=l[U],a.push(M)}}};m(0);for(let w=0;w<o;w++){if(u[w])continue;let I=e[w].parent;if(l[I]=l[I].filter(D=>D!==w),e[w].parent=-1,c.items.push(w),u[w]=1,p[w]=0,e[w].isGroup){let D=a.length,U=i(w,e[w].dir??n);U.items=l[w],a.push(U),m(D)}}for(let w=a.length-1;w>0;w--){let I=a[w],D=1/0;for(let U of I.items)e[U].seq<D&&(D=e[U].seq);D!==1/0&&(e[I.id].seq=D)}for(let w of a)w.items.sort((I,D)=>e[I].seq-e[D].seq||I-D);let h=0;for(let w of t){let I=w.src,D=w.dst,U=0;for(;p[I]>p[D];U++)I=e[I].parent;for(;p[D]>p[I];U++)D=e[D].parent;for(;I!==D&&e[I].parent!==e[D].parent;U+=2)I=e[I].parent,D=e[D].parent;I!==D&&(h+U>U1?(w.src=I,w.dst=D):h+=U)}let g=[],x=[];for(let w=0;w<t.length;w++){let I=t[w];if(I.route=[],I.src===I.dst){g.push(w);continue}let D=I.src,U=I.dst,M=[],Q=[];for(;p[D]>p[U];)M.push(D),D=e[D].parent;for(;p[U]>p[D];)Q.push(U),U=e[U].parent;if(D===U){x.push(w);continue}for(;e[D].parent!==e[U].parent;)M.push(D),Q.push(U),D=e[D].parent,U=e[U].parent;s.get(e[D].parent).edges.push({e:w,a:D,b:U});for(let[q,Y]of[[M,!0],[Q,!1]])for(let z of q){let R=s.get(e[z].parent),L={e:w,inner:z,out:Y,side:0,px:0,py:0,route:[]};R.ports.push(L),R.portOf.set(w*2+(Y?0:1),L)}}let y=new Int32Array(o),_=(w,I,D)=>(D?I.src:I.dst)!==w,S=(w,I)=>{let D=w.dir==="TB"||w.dir==="BT",U=uh(w.dir),M=[],Q=[];w.items.forEach((R,L)=>{y[R]=L;let F=e[R],E=I?ti(D?F.w:F.h,D?F.h:F.w):ti(0,0);E.span=F.isGroup?Math.min(F.span,E.w-2*F.padX):F.span,M.push(E)});let q=(R,L,F)=>e[R].isGroup&&_(R,t[L],F),Y=(R,L,F)=>{if(!I||!e[R].isGroup||!_(R,t[L],F))return 0;let E=s.get(R).portOf.get(L*2+(F?0:1));return D?E.px-e[R].w/2:E.py-e[R].h/2};for(let R of w.edges){let L=t[R.e],F=ni(y[R.a],y[R.b],L.minlen);I&&(F.labelW=D?L.labelW:L.labelH,F.labelH=D?L.labelH:L.labelW,F.tailDx=Y(R.a,R.e,!0),F.headDx=Y(R.b,R.e,!1),F.tailFixed=q(R.a,R.e,!0),F.headFixed=q(R.b,R.e,!1)),Q.push(F)}let z=new Int32Array(w.ports.length).fill(-1);return w.ports.forEach((R,L)=>{if(R.side===U||R.side===pd(U)){let F=M.length;M.push(ti(0,0,R.side===U?3:4)),z[L]=F;let E=R.out?ni(y[R.inner],F):ni(F,y[R.inner]);R.out?(E.tailDx=Y(R.inner,R.e,!0),E.tailFixed=q(R.inner,R.e,!0)):(E.headDx=Y(R.inner,R.e,!1),E.headFixed=q(R.inner,R.e,!1)),Q.push(E)}else M[y[R.inner]].pin=R.side===0||R.side===3?-1:1}),{lnodes:M,ledges:Q,dummies:z}};for(let w of a){for(let Q of w.ports)e[Q.inner].isGroup&&_(Q.inner,t[Q.e],Q.out)&&(s.get(Q.inner).portOf.get(Q.e*2+(Q.out?0:1)).side=Q.side);if(w.edges.length===0)continue;let I=!1;for(let Q of w.edges){let q=t[Q.e];(e[Q.a].isGroup&&q.src!==Q.a||e[Q.b].isGroup&&q.dst!==Q.b)&&(I=!0)}if(!I)continue;let{lnodes:D,ledges:U}=S(w,!1);Hi(D,U),Ki(D,U,1);let M=uh(w.dir);w.edges.forEach((Q,q)=>{let Y=t[Q.e],z=!U[q].reversed;e[Q.a].isGroup&&Y.src!==Q.a&&(s.get(Q.a).portOf.get(Q.e*2).side=z?pd(M):M),e[Q.b].isGroup&&Y.dst!==Q.b&&(s.get(Q.b).portOf.get(Q.e*2+1).side=z?M:pd(M))})}let P={width:0,height:0};for(let w=a.length-1;w>=0;w--){let I=a[w],D=I.id>=0?e[I.id]:void 0,U=I.dir==="TB"||I.dir==="BT",M=I.dir==="BT"||I.dir==="RL",{lnodes:Q,ledges:q,dummies:Y}=S(I,!0),z=ch(Q,q,r),R=U?z.width:z.height,L=U?z.height:z.width,F=D?D.padX:0,E=D?D.padTop:0,C=Math.max(R+2*F,D?D.minW:0),A=L+E+(D?D.padBottom:0),T=(C-R)/2,b=E,N=(v,W)=>T+(U?v:M?z.height-W:W),$=(v,W)=>b+(U?M?z.height-W:W:v),X=U?0:1,V=v=>{let W=[];for(let H=0;H<v.length;H+=2)W.push(N(v[H],v[H+1]),$(v[H],v[H+1]),X);return W};I.items.forEach((v,W)=>{e[v].x=N(Q[W].x,Q[W].y),e[v].y=$(Q[W].x,Q[W].y)}),I.edges.forEach((v,W)=>{let H=q[W];I.routes.set(v.e,V(H.points));let G=t[v.e];G.labelW>0&&(G.labelX=N(H.labelX,H.labelY),G.labelY=$(H.labelX,H.labelY))});let O=I.edges.length;I.ports.forEach((v,W)=>{let H=e[v.inner];if(Y[W]>=0){let ee=V(q[O++].points),ae=v.out?ee.length-3:0,J=ee[ae],se=ee[ae+1];v.side===0?se=0:v.side===2?se=A:v.side===3?J=0:J=C,v.out?ee.push(J,se,X):ee.unshift(J,se,X),v.px=J,v.py=se,v.route=ee;return}let G=H.x,te=H.y;if(H.isGroup&&_(v.inner,t[v.e],v.out)){let ee=s.get(v.inner).portOf.get(v.e*2+(v.out?0:1));G+=ee.px-H.w/2,te+=ee.py-H.h/2}else v.side===0?te-=H.h/2:v.side===2?te+=H.h/2:v.side===3?G-=H.w/2:G+=H.w/2;let Z=G,B=te;v.side===0?B=0:v.side===2?B=A:v.side===3?Z=0:Z=C;let K=v.side===0||v.side===2?0:1;v.px=Z,v.py=B,v.route=v.out?[G,te,K,Z,B,K]:[Z,B,K,G,te,K]}),D?(D.w=C,D.h=A):P={width:C,height:A}}for(let w of a){let I=w.x,D=w.y;for(let U of w.items){let M=e[U];if(M.x+=I,M.y+=D,M.isGroup){let Q=s.get(U);Q.x=M.x-M.w/2,Q.y=M.y-M.h/2}}}let k=(w,I,D,U)=>{for(let M=0;M<I.length;M+=3){let Q=I[M]+D,q=I[M+1]+U,Y=w.length;Y>=3&&Math.abs(w[Y-3]-Q)<.01&&Math.abs(w[Y-2]-q)<.01||w.push(Q,q,I[M+2])}};for(let w of a)for(let I of w.edges){let D=t[I.e],U=[],M=[];for(let q=D.src;e[q].parent!==w.id;q=e[q].parent)M.push(s.get(e[q].parent));for(let q of M)k(U,q.portOf.get(I.e*2).route,q.x,q.y);k(U,w.routes.get(I.e),w.x,w.y);let Q=[];for(let q=D.dst;e[q].parent!==w.id;q=e[q].parent)Q.push(s.get(e[q].parent));for(let q=Q.length-1;q>=0;q--)k(U,Q[q].portOf.get(I.e*2+1).route,Q[q].x,Q[q].y);D.route=U,D.labelW>0&&(D.labelX+=w.x,D.labelY+=w.y)}for(let w of x){let I=t[w],D=e[I.src],U=e[I.dst];I.route=[D.x,D.y,0,U.x,U.y,0],I.labelX=(D.x+U.x)/2,I.labelY=(D.y+U.y)/2}for(let w of g){let I=t[w],D=e[I.src];I.labelX=D.x+D.w/2+28+I.labelW/2,I.labelY=D.y}return P}function Vn(e,t){for(let n=0;n<t.length;n+=3){let r=Math.round(t[n+1]),o=e.get(r);o?o.push(t[n]):e.set(r,[t[n]])}}function Pr(e,t,n,r){if(t===0)return e.x;let o=e.y-e.h/2,s=e.x-e.w/2,a=t/2,i=[s+r-6+a,e.x,s+e.w-r+6-a],c=n.get(Math.round(o));if(c===void 0)return i[0];let l=i[0],f=-1;for(let p of i){let u=1/0;for(let m of c)m>s&&m<s+e.w&&(u=Math.min(u,Math.abs(m-p)-a));if(u>=6)return p;u>f+.5&&(f=u,l=p)}return l}function da(e,t,n,r){let o=t>0?r.get(Math.round(e.y-e.h/2)):void 0;if(o===void 0)return!1;let s=e.x-e.w/2;for(let a of o)if(a>s&&a<s+e.w&&Math.abs(a-n)<t/2+4)return!0;return!1}function ua(e,t,n,r,o,s,a,i){let c=1;for(let f=s[a].parent;f>=0&&c<8;f=s[f].parent)c++;let l=`color-mix(in srgb,var(--_a) ${d(100*(1-.5**c))}%,var(--_bg))`;return`<g class="pele-cluster-title" data-id="${o}">`+Ie(e,t,n,` fill="none" stroke="${l}" stroke-width="5" stroke-linejoin="round"`,i)+Ie(e,t,n,r,i)+"</g>"}var kt=8,G1=12,fa=.62,zi=6;function pa(){let e=new Map;return{add(t,n,r){let o=ht(r);n>=0&&o>0&&o+zi>(e.get(t*4+n)??0)&&e.set(t*4+n,o+zi)},of:(t,n)=>n>=0?e.get(t*4+n)??0:0}}function yn(e,t,n,r,o=n>0?n+zi:0,s=r>0?r+zi:0){let a=t==="linear",i=t==="step"||t==="stepBefore"||t==="stepAfter",c=[],l=[],f=[],p=(E,C,A,T)=>Math.abs(E-A)<.01&&Math.abs(C-T)<.01;for(let E=0;E<e.length;E+=3){let C=e[E],A=e[E+1],T=e[E+2],b=c.length-1;if(i&&b>=0&&Math.abs(C-c[b])>=.01&&Math.abs(A-l[b])>=.01){let N=c[b],$=l[b],X=t==="stepBefore"?$:t==="stepAfter"?A:($+A)/2,V=t==="stepBefore"?N:t==="stepAfter"?C:(N+C)/2,O=T===0?[N,X,C,X]:[V,$,V,A];for(let v=0;v<4;v+=2)p(O[v],O[v+1],N,$)||p(O[v],O[v+1],C,A)||(c.push(O[v]),l.push(O[v+1]),f.push(T))}c.push(C),l.push(A),f.push(T)}let u=c.length-1,m=E=>Math.abs(c[E]-c[E-1])<.01||Math.abs(l[E]-l[E-1])<.01,h=E=>a||m(E),g=(E,C,A)=>{if(!h(Math.max(E,C)))return A===0?[0,Math.sign(l[C]-l[E])||1]:[Math.sign(c[C]-c[E])||1,0];let T=c[C]-c[E],b=l[C]-l[E],N=Math.hypot(T,b)||1;return[T/N,b/N]},[x,y]=g(0,1,f[1]),[_,S]=g(u-1,u,f[u]),P=c[0],k=l[0],w=c[u],I=l[u];c[0]+=x*n,l[0]+=y*n,c[u]-=_*r,l[u]-=S*r;let D=E=>Math.abs(c[E]-c[E-1])+Math.abs(l[E]-l[E-1]),U=E=>!a&&E>0&&E<u&&m(E)&&m(E+1)&&D(E)>=.01&&D(E+1)>=.01&&Math.abs(c[E]-c[E-1])<.01!=Math.abs(c[E+1]-c[E])<.01,M=(E,C,A)=>Math.abs(c[E]-c[E-1])*Math.abs(C)+Math.abs(l[E]-l[E-1])*Math.abs(A),Q=(E,C,A)=>{let T=Math.min(Math.max(0,E-zi-C),A/4);return T+Math.min(E-C-T,(A-T)/4)},q=s>r&&(!h(u)||U(u-1))?Q(s,r,M(u,_,S)):0,Y=o>n&&(!h(1)||U(1))?Q(o,n,M(1,x,y)):0;q>=1&&(c.splice(u,0,c[u]-_*q),l.splice(u,0,l[u]-S*q),f.splice(u,0,f[u]),u++),Y>=1&&(c.splice(1,0,c[0]+x*Y),l.splice(1,0,l[0]+y*Y),f.splice(1,0,f[1]),u++);let z=`M${d(c[0])},${d(l[0])}`,R=c[0],L=l[0],F=(E,C)=>{p(E,C,R,L)||(z+=`L${d(E)},${d(C)}`,R=E,L=C)};for(let E=1;E<=u;E++){let C=c[E],A=l[E];if(!h(E)){let O=f[E]===0,v=O?A-L:C-R,W=Math.abs(v)*fd(O?C-R:A-L,v),H=O?0:Math.sign(v)*W,G=O?Math.sign(v)*W:0;z+=`C${d(R+H)},${d(L+G)} ${d(C-H)},${d(A-G)} ${d(C)},${d(A)}`,R=C,L=A;continue}if(!U(E)){if(E<u&&m(E)&&m(E+1)&&(C-c[E-1])*(c[E+1]-C)+(A-l[E-1])*(l[E+1]-A)>0)continue;F(C,A);continue}let T=U(E-1)?D(E)/2:D(E),b=U(E+1)?D(E+1)/2:D(E+1);i&&(T=b=Math.min(G1,T,b));let[N,$]=g(E-1,E,f[E]),[X,V]=g(E,E+1,f[E+1]);F(C-N*T,A-$*T),R=C+X*b,L=A+V*b,i?z+=`Q${d(C)},${d(A)} ${d(R)},${d(L)}`:z+=`C${d(C-N*T*(1-fa))},${d(A-$*T*(1-fa))} ${d(C+X*b*(1-fa))},${d(A+V*b*(1-fa))} ${d(R)},${d(L)}`}return{d:z,sx:P,sy:k,sdx:-x,sdy:-y,ex:w,ey:I,edx:_,edy:S}}function ht(e){return e==="arrow_point"?kt-1:e==="arrow_circle"?kt:e==="arrow_cross"?4:0}function bt(e,t,n,r,o,s){let a=-o,i=r;if(e==="arrow_point"){let c=t-r*kt,l=n-o*kt,f=kt*.42;return`<path class="pele-marker" d="M${d(t)},${d(n)}L${d(c+a*f)},${d(l+i*f)}L${d(c-a*f)},${d(l-i*f)}Z" fill="${s}" stroke="none"/>`}if(e==="arrow_circle")return`<circle class="pele-marker" cx="${d(t-r*4)}" cy="${d(n-o*4)}" r="3.5" fill="${s}" stroke="none"/>`;if(e==="arrow_cross"){let c=t-r*4,l=n-o*4,f=3.5,p=(r+a)*f,u=(o+i)*f,m=(r-a)*f,h=(o-i)*f;return`<path class="pele-marker" d="M${d(c-p)},${d(l-u)}L${d(c+p)},${d(l+u)}M${d(c-m)},${d(l-h)}L${d(c+m)},${d(l+h)}"/>`}return""}function nn(e,t,n,r,o,s){let a=t.width+8,i=t.height;return`<g class="pele-edge-label" data-id="${$e(e)}"><rect x="${d(n-a/2)}" y="${d(r-i/2)}" width="${d(a)}" height="${d(i)}" rx="3" fill="var(--_bg)"/>`+Ie(t,n,r,o,s)+"</g>"}function ha(e,t,n,r,o,s,a,i){let c=(o?t:n)/2,l=Math.min(c-4,8+r*6),f=s+r*8,p=Math.hypot(f,l)||1,u=(g,x)=>o?`${d(e.x+x)},${d(e.y+n/2+g)}`:`${d(e.x+t/2+g)},${d(e.y+x)}`,m=f/p*a,h=l/p*a;return o?(i.labelX=e.x,i.labelY=e.y+n/2+f+4+i.labelH/2):(i.labelX=e.x+t/2+f+4+i.labelW/2,i.labelY=e.y),{d:`M${u(0,-l)}C${u(f,-l*2)} ${u(f,l*2)} ${u(m,l+h)}`,sx:o?e.x-l:e.x+t/2,sy:o?e.y+n/2:e.y-l,sdx:o?0:-1,sdy:o?-1:0,ex:o?e.x+l:e.x+t/2,ey:o?e.y+n/2:e.y+l,edx:o?-l/p:-f/p,edy:o?-f/p:-l/p}}var mh="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg)",Vi="var(--_fm)",Xe="var(--pele-radius,4px)",ji="var(--pele-critical,#e45756)",fh=String.raw`(?:"[^"'\\\n<>{}();:@]*"|'[^"'\\\n<>{}();:@]*'|[\p{L}\p{N}_-][\p{L}\p{N}_ .-]*)`,Y1=new RegExp(String.raw`^\s*${fh}(?:\s*,\s*${fh})*\s*$`,"u");function ph(e,t){return e&&Y1.test(e)?e:t}function gh(e,t,n){return`;--_fm:var(--pele-font-mono,${ph(n,"monospace")});font:${e}px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,${ph(t,"sans-serif")})`}var H1=new Set(["fill","fill-opacity","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-opacity","opacity","rx","ry"]),K1=new Set(["color","font-size","font-family","font-weight","font-style","text-decoration","letter-spacing","word-spacing","opacity"]),z1=/url\s*\(|expression\s*\(|javascript:|[<>{};\\]|@import|image-set|\/\*/i,hh={shape:"",line:"",text:"",stroke:void 0,bold:!1,italic:!1,fontSize:void 0};function At(e){if(e.length===0)return hh;let t=new Map,n=new Map;for(let l of e){let f=l.indexOf(":");if(f<=0)continue;let p=l.slice(0,f).trim().toLowerCase(),u=l.slice(f+1).replace(/!important/gi,"").trim();u===""||z1.test(u)||(H1.has(p)&&t.set(p,u),K1.has(p)&&n.set(p==="color"?"fill":p,u))}if(t.size===0&&n.size===0)return hh;let r="",o="";for(let[l,f]of t)r+=`${l}:${f};`,l!=="fill"&&l!=="fill-opacity"&&(o+=`${l}:${f};`);let s="";for(let[l,f]of n)s+=`${l}:${f};`;let a=n.get("font-weight"),i=n.get("font-size"),c=i&&/^[\d.]+(px)?$/.test(i)?parseFloat(i):void 0;return{shape:r?` style="${je(r)}"`:"",line:o?` style="${je(o)}"`:"",text:s?` style="${je(s)}"`:"",stroke:t.get("stroke"),bold:a==="bold"||a==="bolder"||Number(a)>=600,italic:n.get("font-style")==="italic",fontSize:c!==void 0&&c>0&&c<=200?c:void 0}}var V1=/[^\w-]+/g;function wt(e){let t=e.replace(V1," ").trim();return t===""?"":" "+t}var j1=["#4c78a8","#f58518","#54a24b","#e45756","#72b7b2","#eeca3b","#b279a2","#9d755d"];function ct(e){let t=(e%8+8)%8;return`var(--pele-series-${t+1},${j1[t]})`}var hd=` rx="${Xe}"`,X1=/<rect\b[^>]*>/g;function q1(e){return e.includes(hd)?e.replace(X1,t=>{let n=t.indexOf(hd);if(n<0)return t;let r=t.slice(0,n)+t.slice(n+hd.length),o=r.indexOf(' style="');if(o>=0)return`${r.slice(0,o+8)}rx:var(--_r);${r.slice(o+8)}`;let s=r.endsWith("/>")?r.length-2:r.length-1;return`${r.slice(0,s)} style="rx:var(--_r)"${r.slice(s)}`}):e}var Q1=[["--_tw","title"],["--_hw","heading"],["--_w","bold"]];function Ze(e,t,n,r,o,s,a){let i=je(o.idPrefix??"pele"),c="",l="";s.accTitle&&(c+=`<title id="${i}-title">${$e(s.accTitle)}</title>`,l+=` aria-labelledby="${i}-title"`),s.accDescr&&(c+=`<desc id="${i}-desc">${$e(s.accDescr)}</desc>`,l+=` aria-describedby="${i}-desc"`);let f=o.responsive===!1?"":"max-width:100%;height:auto;";a=q1(a);let p=a.includes("var(--_r)")?`;--_r:${Xe}`:"";for(let[u,m]of Q1)a.includes(`var(${u})`)&&(p+=`;${u}:var(--pele-${m}-weight,bold)`);return`<svg xmlns="http://www.w3.org/2000/svg" class="pele pele-${e}" viewBox="0 0 ${t} ${n}" width="${t}" height="${n}" style="${f}${mh}${p}${je(gh(r,o.fontFamily,o.fontFamilyMono))}" fill="var(--_fg)" role="graphics-document document" aria-roledescription="${e}"${l}>`+c+a+"</svg>"}var mt=18,yt=12,si=12,Nn=(e,t,n)=>(n?t:e)-2*si,Xi=e=>(t,n,r)=>r?0:t-2*e(n)-2*si;function ya(e,t,n){let r=Math.min(1,Math.abs(e)/t);return n*(1-Math.sqrt(1-r*r))}var gs=(e,t,n,r)=>n&1?ya(r,t/2,e/2):ya(r,e/2,t/2),bs=(e,t,n)=>(n?t:e)*.6,bh=(e,t,n,r)=>n&1?0:ya(r,e/2,Math.min(12,Math.max(6,e/14))),ys=(e,t)=>()=>({w:e,h:t,dy:0});function yh(e,t,n){let r=Math.max(1.6*e+40,80),o=(t+10)/(1-(e+8)/r),s=o/2-10-t/2;return{w:r,h:o,dy:n?-s:s}}function ri(e,t){return`<path d="${e}"${t}/>`}var ma=(e,t,n)=>n&1?t/8:0,qi=(e,t)=>({w:Math.max(e+2*mt,2*mt+12),h:t+2*yt,dy:0});function En(e,t){let n="";for(let r=0;r<e.length;r+=2)n+=(r?" ":"")+d(e[r])+","+d(e[r+1]);return`<polygon points="${n}"${t}/>`}function fn(e,t,n,r=""){return`<rect x="${d(-e/2)}" y="${d(-t/2)}" width="${d(e)}" height="${d(t)}"${r}${n}/>`}var jn=` rx="${Xe}"`,Eh={rect:{size:qi,span:Nn,draw:(e,t,n)=>fn(e,t,n,jn)},rounded:{size:qi,span:Nn,draw:(e,t,n)=>fn(e,t,n,` rx="${d(Math.min(12,t/2))}"`)},stadium:{inset:(e,t,n,r)=>n&1?ya(r,t/2,t/2):0,span:(e,t,n)=>n?t*.6:e-t,size:(e,t)=>{let n=t+2*yt;return{w:e+n*.5+2*mt-8,h:n,dy:0}},draw:(e,t,n)=>fn(e,t,n,` rx="${d(t/2)}"`)},"fr-rect":{span:Nn,size:(e,t)=>({w:e+2*mt+16,h:t+2*yt,dy:0}),draw:(e,t,n,r)=>{let o=e/2-8;return fn(e,t,n,jn)+`<path d="M${d(-o)},${d(-t/2)}V${d(t/2)}M${d(o)},${d(-t/2)}V${d(t/2)}" fill="none"${r}/>`}},cyl:{inset:bh,span:(e,t,n)=>n?t-2*si-12:e*.6,size:(e,t)=>{let n=Math.max(e+2*mt,56),r=Math.min(12,Math.max(6,n/14));return{w:n,h:t+2*yt+2*r,dy:r/2}},draw:(e,t,n,r)=>{let o=e/2,s=Math.min(12,Math.max(6,e/14)),a=-t/2+s,i=t/2-s;return`<path d="M${d(-o)},${d(a)}A${d(o)},${d(s)} 0 0 1 ${d(o)},${d(a)}V${d(i)}A${d(o)},${d(s)} 0 0 1 ${d(-o)},${d(i)}Z"${n}/><path d="M${d(-o)},${d(a)}A${d(o)},${d(s)} 0 0 0 ${d(o)},${d(a)}" fill="none"${r}/>`}},circle:{inset:gs,span:bs,size:(e,t)=>{let n=Math.max(Math.sqrt(e*e+t*t)+16,44);return{w:n,h:n,dy:0}},draw:(e,t,n)=>`<circle r="${d(e/2)}"${n}/>`},"dbl-circ":{inset:gs,span:bs,size:(e,t)=>{let n=Math.max(Math.sqrt(e*e+t*t)+26,54);return{w:n,h:n,dy:0}},draw:(e,t,n,r)=>`<circle r="${d(e/2)}"${n}/><circle r="${d(e/2-5)}" fill="none"${r}/>`},ellipse:{inset:gs,span:bs,size:(e,t)=>({w:e*1.3+2*mt,h:t*1.2+2*yt,dy:0}),draw:(e,t,n)=>`<ellipse rx="${d(e/2)}" ry="${d(t/2)}"${n}/>`},diam:{inset:(e,t,n,r)=>n&1?Math.abs(r)*e/t:Math.abs(r)*t/e,span:(e,t,n)=>(n?t:e)*.6,size:(e,t)=>{let n=e+16,r=t+8;return{w:n+1.6*r,h:n/1.6+r,dy:0}},draw:(e,t,n)=>En([0,-t/2,e/2,0,0,t/2,-e/2,0],n)},hex:{inset:(e,t,n,r)=>n&1?Math.abs(r)/2:0,span:(e,t,n)=>n?t*.5:e-t/2-si,size:(e,t)=>{let n=t+2*yt;return{w:e+2*mt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return En([-e/2+r,-t/2,e/2-r,-t/2,e/2,0,e/2-r,t/2,-e/2+r,t/2,-e/2,0],n)}},odd:{inset:(e,t,n)=>n===3?t/4:0,span:Xi(()=>0),size:(e,t)=>{let n=t+2*yt;return{w:e+2*mt+n/4,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return En([-e/2,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2+r,0],n)}},"lean-r":{inset:ma,span:Xi(e=>e/4),size:(e,t)=>{let n=t+2*yt;return{w:e+2*mt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return En([-e/2+r,-t/2,e/2,-t/2,e/2-r,t/2,-e/2,t/2],n)}},"lean-l":{inset:ma,span:Xi(e=>e/4),size:(e,t)=>{let n=t+2*yt;return{w:e+2*mt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return En([-e/2,-t/2,e/2-r,-t/2,e/2,t/2,-e/2+r,t/2],n)}},"trap-b":{inset:ma,span:Xi(e=>e/4),size:(e,t)=>{let n=t+2*yt;return{w:e+2*mt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return En([-e/2+r,-t/2,e/2-r,-t/2,e/2,t/2,-e/2,t/2],n)}},"trap-t":{inset:ma,span:Xi(e=>e/4),size:(e,t)=>{let n=t+2*yt;return{w:e+2*mt+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return En([-e/2,-t/2,e/2,-t/2,e/2-r,t/2,-e/2+r,t/2],n)}},text:{span:Nn,size:(e,t)=>({w:e+8,h:t+8,dy:0}),draw:(e,t)=>fn(e,t,' fill="none" stroke="none"')},"sm-circ":{noLabel:!0,inset:gs,span:bs,size:ys(14,14),draw:(e,t,n)=>`<circle r="${d(e/2)}"${n}/>`},"f-circ":{noLabel:!0,inset:gs,span:bs,size:ys(14,14),draw:(e,t,n,r)=>`<circle r="${d(e/2)}" fill="var(--_l)"${r}/>`},"fr-circ":{noLabel:!0,inset:gs,span:bs,size:ys(18,18),draw:(e,t,n,r)=>`<circle r="${d(e/2)}"${n}/><circle r="${d(e/2-4)}" fill="var(--_l)"${r}/>`},fork:{noLabel:!0,span:(e,t,n)=>(n?t:e)-8,size:ys(72,8),draw:(e,t,n,r)=>fn(e,t,` fill="var(--_l)"${r}`,' rx="2"')},"notch-rect":{size:qi,span:Nn,draw:(e,t,n)=>En([-e/2+10,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2,-t/2+10],n)},"lin-rect":{span:Nn,size:(e,t)=>({w:e+2*mt+8,h:t+2*yt,dy:0}),draw:(e,t,n,r)=>fn(e,t,n,jn)+`<path d="M${d(-e/2+8)},${d(-t/2)}V${d(t/2)}" fill="none"${r}/>`},"div-rect":{span:Nn,size:(e,t)=>({w:e+2*mt,h:t+2*yt+8,dy:4}),draw:(e,t,n,r)=>fn(e,t,n,jn)+`<path d="M${d(-e/2)},${d(-t/2+8)}H${d(e/2)}" fill="none"${r}/>`},"win-pane":{span:Nn,size:(e,t)=>({w:e+2*mt+8,h:t+2*yt+8,dy:4}),draw:(e,t,n,r)=>fn(e,t,n,jn)+`<path d="M${d(-e/2+8)},${d(-t/2)}V${d(t/2)}M${d(-e/2)},${d(-t/2+8)}H${d(e/2)}" fill="none"${r}/>`},tri:{inset:(e,t,n)=>n&1?e/4:0,size:(e,t)=>yh(e,t,!1),draw:(e,t,n)=>En([0,-t/2,e/2,t/2,-e/2,t/2],n)},"flip-tri":{inset:(e,t,n)=>n&1?e/4:0,size:(e,t)=>yh(e,t,!0),draw:(e,t,n)=>En([-e/2,-t/2,e/2,-t/2,0,t/2],n)},"sl-rect":{inset:(e,t,n)=>n===0?5:0,size:(e,t)=>({w:e+2*mt,h:t+2*yt+10,dy:5}),draw:(e,t,n)=>En([-e/2,-t/2+10,e/2,-t/2,e/2,t/2,-e/2,t/2],n)},"notch-pent":{span:Nn,size:(e,t)=>({w:e+2*mt,h:t+2*yt,dy:0}),draw:(e,t,n)=>En([-e/2+10,-t/2,e/2-10,-t/2,e/2,-t/2+10,e/2,t/2,-e/2,t/2,-e/2,-t/2+10],n)},hourglass:{noLabel:!0,inset:(e,t,n)=>n&1?e/2:0,size:ys(32,40),draw:(e,t,n)=>En([-e/2,-t/2,e/2,-t/2,-e/2,t/2,e/2,t/2],n)},delay:{size:(e,t)=>{let n=t+2*yt;return{w:e+2*mt+n/4,h:n,dy:0}},draw:(e,t,n)=>{let r=t/2;return`<path d="M${d(-e/2)},${d(-r)}H${d(e/2-r)}A${d(r)},${d(r)} 0 0 1 ${d(e/2-r)},${d(r)}H${d(-e/2)}Z"${n}/>`}},"h-cyl":{size:(e,t)=>{let n=t+2*yt,r=Math.min(12,n/4);return{w:e+2*mt+2*r,h:n,dy:0}},draw:(e,t,n,r)=>{let o=t/2,s=Math.min(12,t/4),a=-e/2+s,i=e/2-s;return`<path d="M${d(a)},${d(-o)}H${d(i)}A${d(s)},${d(o)} 0 0 1 ${d(i)},${d(o)}H${d(a)}A${d(s)},${d(o)} 0 0 1 ${d(a)},${d(-o)}Z"${n}/><path d="M${d(i)},${d(-o)}A${d(s)},${d(o)} 0 0 0 ${d(i)},${d(o)}" fill="none"${r}/>`}},"cross-circ":{noLabel:!0,inset:gs,span:bs,size:ys(44,44),draw:(e,t,n,r)=>{let o=e/2,s=o*Math.SQRT1_2;return`<circle r="${d(o)}"${n}/><path d="M${d(-s)},${d(-s)}L${d(s)},${d(s)}M${d(s)},${d(-s)}L${d(-s)},${d(s)}" fill="none"${r}/>`}},"st-rect":{span:(e,t,n)=>(n?t:e)-2*si-8,size:(e,t)=>({w:e+2*mt+8,h:t+2*yt+8,dy:4}),draw:(e,t,n)=>{let r=e-8,o=t-8,s="";for(let a=0;a<3;a++){let i=-e/2+(2-a)*4,c=-t/2+a*4;s+=`<rect x="${d(i)}" y="${d(c)}" width="${d(r)}" height="${d(o)}"${jn}${n}/>`}return s}},doc:{inset:(e,t,n)=>n===2?10:0,size:(e,t)=>({w:e+2*mt,h:t+2*yt+10,dy:-5}),draw:(e,t,n)=>ba(e,t,n)},flag:{inset:(e,t,n)=>n&1?0:8,size:(e,t)=>({w:e+2*mt,h:t+2*yt+16,dy:0}),draw:(e,t,n)=>{let r=e/2,o=t/2-8,s=e/4;return`<path d="M${d(-r)},${d(-o)}q${d(s)},-10 ${d(2*s)},0t${d(2*s)},0V${d(o)}q${d(-s)},10 ${d(-2*s)},0t${d(-2*s)},0Z"${n}/>`}},datastore:{size:qi,span:Nn,draw:(e,t,n,r)=>fn(e,t,n.replace('stroke="var(--_b)"','stroke="none"'))+`<path d="M${d(-e/2)},${d(-t/2)}H${d(e/2)}M${d(-e/2)},${d(t/2)}H${d(e/2)}" fill="none"${r}/>`},folder:{size:(e,t)=>({w:Math.max(e+2*mt,64),h:t+2*yt+8,dy:4}),draw:(e,t,n)=>{let r=e/2,o=t/2,s=Math.min(e*.4,48);return ri(`M${d(-r)},${d(-o)}H${d(-r+s)}L${d(-r+s+8)},${d(-o+8)}H${d(r)}V${d(o)}H${d(-r)}Z`,n)}},bucket:{size:(e,t)=>({w:e+2*mt+20,h:t+2*yt+10,dy:3}),inset:(e,t,n)=>n&1?t/12:0,draw:(e,t,n,r)=>{let o=e/2,s=t/2,a=5,i=t/6;return ri(`M${d(-o)},${d(-s+a)}A${d(o)},${d(a)} 0 0 1 ${d(o)},${d(-s+a)}L${d(o-i)},${d(s-a)}A${d(o-i)},${d(a)} 0 0 1 ${d(-o+i)},${d(s-a)}Z`,n)+`<path d="M${d(-o)},${d(-s+a)}A${d(o)},${d(a)} 0 0 0 ${d(o)},${d(-s+a)}" fill="none"${r}/>`}},console:{span:Nn,size:(e,t)=>({w:Math.max(e+2*mt,72),h:t+2*yt+12,dy:6}),draw:(e,t,n,r)=>fn(e,t,n,jn)+`<path d="M${d(-e/2)},${d(-t/2+12)}H${d(e/2)}M${d(-e/2+7)},${d(-t/2+4)}l3,2.5l-3,2.5M${d(-e/2+13)},${d(-t/2+9)}h4" fill="none"${r}/>`},browser:{span:Nn,size:(e,t)=>({w:Math.max(e+2*mt,72),h:t+2*yt+12,dy:6}),draw:(e,t,n,r)=>{let o="";for(let s=0;s<3;s++)o+=`<circle cx="${d(-e/2+8+s*7)}" cy="${d(-t/2+6)}" r="1.5" fill="none"${r}/>`;return fn(e,t,n,jn)+`<path d="M${d(-e/2)},${d(-t/2+12)}H${d(e/2)}" fill="none"${r}/>`+o}},person:{size:(e,t)=>({w:Math.max(e+2*mt,56),h:t+2*yt+26,dy:13}),draw:(e,t,n)=>{let r=-t/2;return`<rect x="${d(-e/2)}" y="${d(r+26)}" width="${d(e)}" height="${d(t-26)}" rx="12"${n}/><circle cy="${d(r+14)}" r="13"${n}/>`}},bang:{size:(e,t)=>({w:e+2*mt+28,h:t+2*yt+24,dy:0}),inset:()=>3,draw:(e,t,n)=>{let o=[];for(let s=0;s<28;s++){let a=Math.PI*s/14-Math.PI/2,i=s%2===0?1:.82;o.push(Math.cos(a)*(e/2)*i,Math.sin(a)*(t/2)*i)}return En(o,n)}},cloud:{size:(e,t)=>({w:e+2*mt+32,h:t+2*yt+24,dy:0}),inset:(e,t,n)=>n&1?2:1,draw:(e,t,n)=>{let r=e/2,o=t/2,s=o*.55;return ri(`M${d(-r+s)},${d(o)}A${d(s)},${d(s)} 0 0 1 ${d(-r+s*.6)},${d(-o*.1)}A${d(r*.42)},${d(o*.7)} 0 0 1 ${d(-r*.1)},${d(-o*.72)}A${d(r*.4)},${d(o*.62)} 0 0 1 ${d(r*.62)},${d(-o*.42)}A${d(s*1.05)},${d(s*1.05)} 0 0 1 ${d(r-s)},${d(o)}Z`,n)}},brace:{size:(e,t)=>({w:e+2*mt+12,h:t+2*yt,dy:0}),draw:(e,t,n,r)=>fn(e,t,' fill="none" stroke="none"')+ga(-e/2+12,t,-1,r)},"brace-r":{size:(e,t)=>({w:e+2*mt+12,h:t+2*yt,dy:0}),draw:(e,t,n,r)=>fn(e,t,' fill="none" stroke="none"')+ga(e/2-12,t,1,r)},braces:{size:(e,t)=>({w:e+2*mt+24,h:t+2*yt,dy:0}),draw:(e,t,n,r)=>fn(e,t,' fill="none" stroke="none"')+ga(-e/2+12,t,-1,r)+ga(e/2-12,t,1,r)},bolt:{noLabel:!0,size:ys(36,56),inset:(e,t,n)=>n&1?e/4:0,draw:(e,t,n)=>En([e*.15,-t/2,-e/2,t*.08,-e*.05,t*.08,-e*.15,t/2,e/2,-t*.08,e*.05,-t*.08],n)},"lin-cyl":{inset:bh,span:(e,t,n)=>n?t-2*si-20:e*.6,size:(e,t)=>{let n=Math.max(e+2*mt,56),r=Math.min(12,Math.max(6,n/14));return{w:n,h:t+2*yt+2*r+8,dy:r/2+4}},draw:(e,t,n,r)=>{let o=e/2,s=Math.min(12,Math.max(6,e/14)),a=-t/2+s,i=t/2-s,c=l=>`M${d(-o)},${d(l)}A${d(o)},${d(s)} 0 0 0 ${d(o)},${d(l)}`;return ri(`M${d(-o)},${d(a)}A${d(o)},${d(s)} 0 0 1 ${d(o)},${d(a)}V${d(i)}A${d(o)},${d(s)} 0 0 1 ${d(-o)},${d(i)}Z`,n)+`<path d="${c(a)}${c(a+8)}" fill="none"${r}/>`}},"curv-trap":{size:(e,t)=>{let n=t+2*yt;return{w:e+2*mt+n*.6,h:n,dy:0}},draw:(e,t,n)=>{let r=e/2,o=t/2,s=t*.3;return ri(`M${d(-r+s)},${d(-o)}H${d(r-s)}A${d(s)},${d(o)} 0 0 1 ${d(r-s)},${d(o)}H${d(-r+s)}L${d(-r)},0Z`,n)}},docs:{size:(e,t)=>({w:e+2*mt+8,h:t+2*yt+18,dy:-1}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n)=>{let r="";for(let o=0;o<3;o++)r+=`<g transform="translate(${(1-o)*4},${(o-1)*4})">${ba(e-8,t-8,n)}</g>`;return r}},"bow-rect":{size:(e,t)=>{let n=t+2*yt;return{w:e+2*mt+n*.4,h:n,dy:0}},inset:(e,t,n)=>n===1?t*.2:0,draw:(e,t,n)=>{let r=e/2,o=t/2,s=t*.2;return ri(`M${d(-r+s)},${d(-o)}H${d(r)}A${d(s)},${d(o)} 0 0 0 ${d(r)},${d(o)}H${d(-r+s)}A${d(s)},${d(o)} 0 0 1 ${d(-r+s)},${d(-o)}Z`,n)}},"tag-rect":{size:qi,span:Nn,draw:(e,t,n,r)=>fn(e,t,n,jn)+`<path d="M${d(e/2-12)},${d(t/2)}L${d(e/2)},${d(t/2-12)}" fill="none"${r}/>`},"tag-doc":{size:(e,t)=>({w:e+2*mt,h:t+2*yt+10,dy:-5}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n,r)=>ba(e,t,n)+`<path d="M${d(e/2-12)},${d(t/2-14)}L${d(e/2)},${d(t/2-26)}" fill="none"${r}/>`},"lin-doc":{size:(e,t)=>({w:e+2*mt+8,h:t+2*yt+10,dy:-5}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n,r)=>ba(e,t,n)+`<path d="M${d(-e/2+8)},${d(-t/2)}V${d(t/2-6)}" fill="none"${r}/>`},collapsedGroup:{size:(e,t)=>({w:e+2*mt+8,h:t+2*yt+8,dy:-2}),draw:(e,t,n)=>`<rect x="${d(-e/2+6)}" y="${d(-t/2+8)}" width="${d(e-12)}" height="${d(t-8)}"${jn}${n}/><rect x="${d(-e/2)}" y="${d(-t/2)}" width="${d(e)}" height="${d(t-4)}"${jn}${n}/>`}};function ga(e,t,n,r){let o=t/2,s=6*n;return`<path d="M${d(e)},${d(-o)}q${d(s)},0 ${d(s)},6V-6q0,6 ${d(s)},6q${d(-s)},0 ${d(-s)},6V${d(o-6)}q0,6 ${d(-s)},6" fill="none"${r}/>`}function ba(e,t,n){let r=e/2,o=-t/2,s=t/2-10,a=e/4;return`<path d="M${d(-r)},${d(o)}H${d(r)}V${d(s)}q${d(-a)},-12 ${d(-2*a)},0t${d(-2*a)},0Z"${n}/>`}var Ah=Eh.rect,Qi=new Map(Object.entries(Eh));function Br(e,t,n){return(Qi.get(e)??Ah).size(t,n)}function Xn(e,t,n,r,o){return(Qi.get(e)??Ah).draw(t,n,r,o)}function _r(e,t,n,r,o=0){return Qi.get(e)?.inset?.(t,n,r,o)??0}function xh(e,t,n,r){return Math.max(0,Qi.get(e)?.span?.(t,n,r)??0)}function Sh(e){return Qi.get(e)?.noLabel!==!0}function Bn(e,t,n){let r=e[t]-n.x,o=e[t+1]-n.y;return Math.abs(Math.abs(o)-n.h/2)<.5?o<0?0:2:Math.abs(Math.abs(r)-n.w/2)<.5?r<0?3:1:-1}function Es(e,t,n,r){if(r.isGroup)return;let o=Bn(e,t,r);if(o===0||o===2){let s=_r(n.shape,n.w,n.h,o,e[t]-r.x)+(r.h-n.h)/2;e[t+1]+=o===0?s:-s}else if(o>=0){let s=_r(n.shape,n.w,n.h,o,e[t+1]-r.y)+(r.w-n.w)/2;e[t]+=o===3?s:-s}}var Z1=1.5,J1=/<br\s*\/?>|\\n|\n/gi,_h=/<\/?([a-zA-Z][\w-]*)(?:\s[^<>]*)?\/?>/y,wh=/(fa[bklrs]?):fa-([\w-]+)/g,e_=/[<\\\n*_]|fa[bklrs]?:fa-/,t_={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function n_(e){let t=e.split(`
54
+ `),n=1/0;for(let r of t){if(r.trim()==="")continue;let o=r.length-r.trimStart().length;o<n&&(n=o)}return n===1/0||n===0?e:t.map(r=>r.slice(Math.min(n,r.length-r.trimStart().length))).join(`
55
+ `)}function md(e,t,n){if(t==="")return;let r=gt(t),o=e[e.length-1];o&&o.style===n&&o.icon===void 0?o.text+=r:e.push({text:r,style:n,width:0})}function r_(e,t,n){if(!t.includes(":fa-")){md(e,t,n);return}let r=0;wh.lastIndex=0;let o;for(;(o=wh.exec(t))!==null;){let s=`${o[1]}:fa-${o[2]}`;if(md(e,t.slice(r,o.index),n),r=o.index+o[0].length,js(s)!=="")e.push({text:"",style:n,icon:s,width:0});else if(t[r]===" ")r++;else if(r===t.length){let a=e[e.length-1];a&&a.icon===void 0&&(a.text=a.text.trimEnd())}}md(e,t.slice(r),n)}function s_(e,t,n,r){let o=r,s=0,a="",i=0,c=t.length,l=()=>{r_(e,a,o),a=""};for(;i<c;){let f=t[i];if(f==="<"){_h.lastIndex=i;let p=_h.exec(t);if(p&&p.index===i){let u=p[1].toLowerCase(),m=t[i+1]==="/",h=u==="b"||u==="strong"?1:u==="i"||u==="em"?2:0;h&&(l(),o=m?o&~h|r&h:o|h),i+=p[0].length;continue}}else if(n&&(f==="*"||f==="_")){let p=t[i+1]===f,u=p?1:2,m=p?2:1,h=(s&u)===0,g=i>0?t[i-1]:" ",x=i+m<c?t[i+m]:" ",y=h&&x.trim()!==""&&t.indexOf(p?f+f:f,i+m)!==-1,_=!h&&g.trim()!=="",S=f==="_"&&/\w/.test(g)&&/\w/.test(x);if((y||_)&&!S){l(),s=y?s|u:s&~u,o=y?o|u:o&~u|r&u,i+=m;continue}}a+=f,i++}l()}function i_(e,t,n){let r=0;for(let o of e)o.width=o.icon!==void 0?n*1.25:t.width(o.text,n,o.style),r+=o.width;return r}function Rh(e,t,n,r,o,s){let a=[],i=0,c=()=>{let l=a[a.length-1];if(l&&l.icon===void 0){let f=l.text.trimEnd();if(f!==l.text){l.text=f;let p=t.width(f,n,l.style);i+=p-l.width,l.width=p}}o.push(a),s.push(i),a=[],i=0};for(let l of e){if(l.icon!==void 0){let f=n*1.25;i>0&&i+f>r&&c(),a.push({...l,width:f}),i+=f;continue}for(let f of l.text.match(/\s*\S+\s*|\s+/g)??[]){let p=f;i>0&&i+t.width(p.trimEnd(),n,l.style)>r&&(c(),p=p.trimStart());let u=a[a.length-1];if(u&&u.style===l.style&&u.icon===void 0){u.text+=p,u.width=t.width(u.text,n,u.style),i=0;for(let m of a)i+=m.width}else{let m=t.width(p,n,l.style);a.push({text:p,style:l.style,width:m}),i+=m}}}(a.length>0||o.length===0)&&c()}function De(e,t,n,r,o,s=0){if(e===void 0||e==="")return t_;let a=Math.round(r*Z1);if(!e_.test(e)&&!e.includes("&")&&!e.includes("fl")){let p=e.trim(),u=n.width(p,r,s);if(u<=o||!p.includes(" "))return{lines:[[{text:p,style:s,width:u}]],widths:[u],width:u,height:a,size:r,lineHeight:a};let m=[],h=[];Rh([{text:p,style:s,width:u}],n,r,o,m,h);let g=0;for(let x of h)x>g&&(g=x);return{lines:m,widths:h,width:g,height:m.length*a,size:r,lineHeight:a}}let i=t?n_(e.replace(/\r\n?/g,`
56
+ `)).trim():e.trim(),c=[],l=[],f=0;for(let p of i.split(J1)){let u=[];s_(u,p.trim(),t,s);let m=i_(u,n,r);m>o?Rh(u,n,r,o,c,l):(c.push(u),l.push(m))}for(let p of l)p>f&&(f=p);return{lines:c,widths:l,width:f,height:c.length*a,size:r,lineHeight:a}}function Fr(e,t,n,r){let o=r(t,!1),s=e.maxWidth;if(s===void 0||!(s>0)||o.width<=s)return o;let a=Math.min(n,t),i=t;o=r(i,!0);for(let c=0;c<3&&o.width>s&&i>a;c++)i=Math.max(a,i-(o.width-s)),o=r(i,!0);return o}function Rt(e){let t=e.maxWidth;return t!==void 0&&t>0?Math.max(80,t-2*(e.padding??8)):4e3}function Wr(e,t,n,r=0){let o=e.maxWidth;return o===void 0||!(o>0)?t:Math.max(Math.min(n,t),Math.min(t,o-r))}var o_=640;function Nt(e,t){let n=t(!1),r=e.maxWidth;if(e.autoDirection===!1||r===void 0||!(r>0)||n.width<=r)return n;let o=e.directionBreakpoint;if(r>=(o!==void 0&&o>0?o:o_))return n;let s=t(!0);return s.width<n.width?s:n}function _n(e){return e==="LR"||e==="RL"}function pn(e,t){let n=t(!1),r=e.maxWidth;if(r===void 0||!(r>0)||n.width<=r)return n;let o=t(!0);return o.width<n.width?o:n}var As=new Map([["tool",0],["task",1],["decision",2],["input",3],["refdoc",4],["connector",5],["action",6]]),Th=As.size,a_=e=>Math.max(1,e-Th),c_=(e,t)=>{let n=Th+e%a_(t);return t>0?n%t:n};function Ch(e,t,n,r){let o=n.size;for(let s of e){if(s.isGroup||s.shape==="collapsedGroup"){s.colorIndex=c_(n.get(s.id)??o++,r);continue}let a=t(s.id);a&&As.has(a)&&(s.kind=a)}}function Ih(e,t,n){let r=[],o=[],s=e.subgraphs,a=y=>{let _=[];for(let S of y){let P=e.classes.get(S);P?.styles&&(_=[..._,...P.styles].map(k=>k.trim())),P?.textStyles&&(_=[..._,...P.textStyles].map(k=>k.trim()))}return _},i=new Set,c=new Map,l=new Set;for(let y of s){if(y.metadata?.view!=="collapsed"||i.has(y.id))continue;let _=[y.id];for(;_.length>0;){let S=e.subgraph(_.pop())?.nodes;if(S!==void 0)for(let P of S)P===y.id||i.has(P)||(i.add(P),c.set(P,y.id),l.has(P)||_.push(P))}l.add(y.id)}let f=new Map;for(let y of i){let _=[y],S=c.get(y);for(;;){let P=f.get(S),k=P??c.get(S);if(k===void 0||(P===void 0&&_.push(S),S=k,P!==void 0))break}for(let P of _)f.set(P,S)}let p=new Map;s.forEach((y,_)=>p.set(y.id,_));let u=new Map,m=(y,_,S)=>{let P=p.get(y);if(P===void 0||P<S)return!1;let k=_;for(let w=0;k!==void 0&&w<=s.length;w++){if(k===y)return!0;k=u.get(k)}return!1};for(let y=s.length-1;y>=0;y--){let _=s[y];if(!i.has(_.id))for(let S of _.nodes){if(m(S,_.id,y)){e.emitWarning("CONTAINMENT_VIOLATION",`Container "${_.id}" cannot contain "${S}" because "${S}" already contains it. The nesting that would close the loop is dropped.`,{nodeId:S});continue}u.set(S,_.id)}}let h=new Map;for(let y=s.length-1;y>=0;y--){let _=s[y];if(i.has(_.id))continue;let S=_.metadata?.view==="collapsed",P={id:_.id,label:_.title,labelType:_.labelType,parentId:u.get(_.id),cssStyles:[],cssCompiledStyles:a(_.classes),cssClasses:_.classes.join(" "),shape:S?"collapsedGroup":"flowGroup",dir:_.dir,isGroup:!S,metadata:S?{..._.metadata,containerType:_.type}:_.metadata};r.push(P),h.set(_.id,P)}for(let y of e.nodes.values()){if(i.has(y.id))continue;let _=h.get(y.id);if(_){_.cssStyles=y.styles,_.cssCompiledStyles=a(y.classes),_.cssClasses=y.classes.join(" ");continue}let S=Zs(y.type),P={id:y.id,label:y.text,labelType:y.labelType,parentId:u.get(y.id),cssStyles:y.styles,cssCompiledStyles:a(["default","node",...y.classes]),cssClasses:"default "+y.classes.join(" "),dir:y.dir,link:y.link,linkTarget:y.linkTarget,tooltip:e.tooltips.get(y.id),metadata:y.metadata,isGroup:!1,shape:S==="square"||S===void 0?"squareRect":S};r.push(P),h.set(y.id,P)}e.edges.forEach((y,_)=>{let S=f.get(y.start)??y.start,P=f.get(y.end)??y.end;if(S===P&&y.start!==y.end)return;let k=[...e.defaultEdgeStyle??[]];y.style&&k.push(...y.style);let w=y.type==="arrow_open"?"none":y.type==="arrow_cross"||y.type==="arrow_point"?y.type:"arrow_point";o.push({id:y.id||`L_${S}_${P}_${_}`,isUserDefinedId:y.isUserDefinedId,start:S,end:P,type:y.type??"normal",label:y.text,labelType:y.labelType,thickness:y.stroke,pattern:y.stroke,minlen:y.length,classes:"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:"none",arrowTypeEnd:w,cssCompiledStyles:a(y.classes),style:k,animate:y.animate,animation:y.animation,curve:y.interpolate||e.defaultInterpolate||n,metadata:y.metadata})}),zp(r,e);let g=new Map;for(let y of s){let _=u.get(y.id);if(_===void 0)continue;let S=g.get(_);S?S.push(y.id):g.set(_,[y.id])}let x=new Map;for(let y of s){if(u.get(y.id)!==void 0)continue;let _=[y.id];for(;_.length>0;){let S=_.pop();if(x.has(S))continue;x.set(S,x.size);let P=g.get(S);if(P)for(let k=P.length-1;k>=0;k--)_.push(P[k])}}return Ch(r,y=>{if(e.connectors.has(y))return"connector";let _=e.nodes.get(y);return _?e.vertexKind(_):void 0},x,t),{nodes:r,edges:o}}var l_=8,d_=40,u_=16,f_=48,Zi=20,gd=26,Ea=14,Nh="collapsed",p_={TB:2,RL:3,BT:0,LR:1},Mh=new WeakMap;function Ed(e,t){let n=Mh.get(e);if(n===void 0){let r=t.flowchart?.curve;n=Ih(e,l_,typeof r=="string"?r:void 0),Mh.set(e,n)}return n}function Aa(e,t,n){let r=e.agentflow?.[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}var h_=/[";]fill:/;function bd(e,t,n){let r=ct(e);return` fill="${r}"${h_.test(n.shape)?"":` fill-opacity="${t}"`} stroke="${r}"`}function Lh(e,t,n){return _n(e.direction)?Nt(n,r=>kh(e,t,n,r)):kh(e,t,n,!1)}function kh(e,t,n,r){let o=Ed(e,t),s=n.fontSize??16,a=Math.round(s*.875),i=n.measurer??Je(n.fontFamily),c=Aa(t,"wrappingWidth",120),l=Aa(t,"minNodeWidth",120),f=n.padding??8,p=n.icons,u=new Map,m=[],h=[];o.nodes.forEach((H,G)=>u.set(H.id,G));for(let H of o.nodes){let G=H.cssStyles.length>0?H.cssCompiledStyles.concat(H.cssStyles):H.cssCompiledStyles,te=At(G),Z=(te.bold?1:0)|(te.italic?2:0),B=H.labelType==="markdown",K=te.fontSize??s,ee,ae;if(H.isGroup){let J=De(H.label,B,i,K,4e3,Z);ee={node:H,style:te,label:J,shape:"group",w:0,h:0,dy:0,loops:0},ae=$t(0,0),ae.isGroup=!0,ae.dir=H.dir?tn(H.dir):void 0,ae.padX=Zi,ae.padTop=J.height>0?J.height+16:Zi,ae.padBottom=Zi,ae.minW=J.width+2*Zi-12}else if(H.shape==="collapsedGroup"){let J=De(H.label,B,i,K,c,Z),se=Math.max(J.width,l)+2*mt,me=J.height+2*yt+Ea;ee={node:H,style:te,label:J,shape:Nh,w:se,h:me,dy:-Ea/2,loops:0},ae=$t(se,me)}else{let J=sa(H.shape),se=De(H.label,B,i,K,c,Z),me=Br(J,J==="diam"?se.width:Math.max(se.width,l),se.height);ee={node:H,style:te,label:se,shape:J,w:me.w,h:me.h,dy:me.dy,loops:0},ae=$t(me.w,me.h)}ae.seq=m.length,m.push(ee),h.push(ae)}o.nodes.forEach((H,G)=>{h[G].parent=H.parentId!==void 0?u.get(H.parentId)??-1:-1});let g=r?"TB":tn(e.direction),x=H=>{let G;for(let te=h[H].parent,Z=0;te>=0&&G===void 0&&Z<1e4;te=h[te].parent,Z++)G=h[te].dir;return G??g},y=H=>{let G=x(H);return G==="LR"||G==="RL"},_=new Int32Array(h.length).fill(-1);for(let H=0;H<h.length;H++){let G=[],te=H;for(;te>=0&&_[te]<0&&G.length<=h.length;)G.push(te),te=h[te].parent;let Z=te>=0?_[te]+1:0;for(let B=G.length-1;B>=0;B--)_[G[B]]=Z++}let S=(H,G)=>{let te=G;for(let Z=_[G];Z>_[H];Z--)te=h[te].parent;return te===H&&G!==H},P=[],k=[],w=[],I=[];for(let H of o.edges){let G=u.get(H.start),te=u.get(H.end);if(G===void 0||te===void 0)continue;let Z=De(H.label,H.labelType==="markdown",i,a,c);if(S(G,te)||S(te,G)){I.push({edge:H,label:Z,src:G,dst:te});continue}G===te&&(m[G].loops++,y(G)?h[G].h+=2*(gd+(Z.height>0?Z.height+8:0)):h[G].w+=2*(gd+(Z.width>0?Z.width+12:0))),w.push(H),k.push(Z),P.push({src:G,dst:te,minlen:H.minlen??1,labelW:Z.width>0?Z.width+12:0,labelH:Z.height>0?Z.height+4:0,route:[],labelX:0,labelY:0})}let D=Sn(h,P,g,{nodeSep:Aa(t,"nodeSpacing",d_),edgeSep:u_,rankSep:Aa(t,"rankSpacing",f_),portSep:20}),U=De(e.title,!1,i,s,4e3,1),M=U.height>0?U.height+12:0,Q=Math.max(D.width,U.width),q=f+(Q-D.width)/2,Y=f+M;vr(h,P,q,Y);let z=Math.ceil(Q+2*f),R=Math.ceil(D.height+M+2*f),L=[],F=[],E=[],C=[],A=I.length*h.length<2e6;for(let{edge:H,src:G,dst:te}of I){let Z=S(te,G),B=Z?te:G,K=Z?G:te,ee=h[B],ae=h[K],J=p_[ee.dir??x(B)],se=Z?J:J+2&3,me=ye=>{let ce=(ye&1)===0,fe=ye===0||ye===3?-1:1,xe=ce?ae.x:ae.x+fe*ae.w/2,be=ce?ae.y+fe*ae.h/2:ae.y,re=ce?ae.x:ee.x+fe*ee.w/2,j=ce?ee.y+fe*ee.h/2:ae.y,ie=ce?0:1;return Z?[xe,be,ie,re,j,ie]:[re,j,ie,xe,be,ie]},Ae=ye=>{for(let ce=0;ce<h.length;ce++){let fe=h[ce];if(ce!==K&&!fe.isGroup&&fe.x+fe.w/2>Math.min(ye[0],ye[3])-1&&fe.x-fe.w/2<Math.max(ye[0],ye[3])+1&&fe.y+fe.h/2>Math.min(ye[1],ye[4])-1&&fe.y-fe.h/2<Math.max(ye[1],ye[4])+1)return!0}return!1},de=me(se);if(A&&Ae(de))for(let ye of[se+1&3,se+3&3,se+2&3]){let ce=me(ye);if(!Ae(ce)){de=ce;break}}C.push(de),E.push((de[0]+de[3])/2,(de[1]+de[4])/2);let oe=de.slice();Es(oe,Z?0:3,m[K],ae),F.push(yn(oe,"linear",0,ht(H.arrowTypeEnd)))}let T=new Map,b=!1;for(let H of h)H.isGroup&&(b=!0);if(b){for(let H of P)Vn(T,H.route);for(let H of C)Vn(T,H)}let N="",$="";for(let H=0;H<m.length;H++){let G=m[H],te=h[H],Z=G.node,B=te.x,K=te.y,ee=wt(Z.cssClasses.replace(/^default\s?/,"")),ae=$e(Z.id);if(te.isGroup){let ce=Pr(te,G.label.width,T,Zi);N+=`<g class="pele-cluster pele-flow${ee}" data-id="${ae}"><rect x="${d(B-te.w/2)}" y="${d(K-te.h/2)}" width="${d(te.w)}" height="${d(te.h)}" rx="${Xe}"${bd(Z.colorIndex??As.size,"0.06",G.style)}${G.style.shape}/>`+Ie(G.label,ce,K-te.h/2+8+G.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${G.style.text}`,p)+"</g>";continue}let J=G.w,se=G.h,me="",Ae;if(G.shape===Nh){let ce=ct(Z.colorIndex??As.size),fe=se/2-Ea-2,xe=fe+(Ea+2)/2;Ae=`<rect x="${d(-J/2)}" y="${d(-se/2)}" width="${d(J)}" height="${d(se)}" rx="${Xe}"${bd(Z.colorIndex??As.size,"0.06",G.style)}${G.style.shape}/><path d="M${d(-J/2+10)},${d(fe)}H${d(J/2-10)}" fill="none" stroke="${ce}" stroke-dasharray="3 3"${G.style.line}/><path class="pele-collapsed-mark" d="${yd(-9,xe)}${yd(0,xe)}${yd(9,xe)}" fill="${ce}" stroke="none"/>`}else{let ce=As.get(Z.kind??"task")??1;me=` pele-kind-${Z.kind??"task"}`,Ae=Xn(G.shape,J,se,bd(ce,"0.14",G.style)+G.style.shape,` stroke="${ct(ce)}"`+G.style.line)}let de=Ie(G.label,0,G.dy,` class="pele-label"${G.style.text}`,p);if(/ internal-link(?: |$)/.test(ee+" ")&&Z.label&&n.links!==!1){let ce=gt(Z.label),fe=Ar(zn(ce),n)!==void 0,xe=je(ce);de=`<a class="internal-link"${fe?` href="${xe}"${xr(n)}`:""} data-href="${xe}">${de}</a>`,L.push({id:Z.id,href:ce,internal:!0})}let ye=Ae+de;Z.tooltip&&(ye=`<title>${$e(Z.tooltip)}</title>`+ye),Z.link&&(ye=Pn(ye,Z.link,Z.id,L,n,Z.linkTarget?` target="${je(Z.linkTarget)}"`:"")),$+=`<g class="pele-node pele-shape-${G.shape}${me}${ee}" data-id="${ae}" transform="translate(${d(B)},${d(K)})">${ye}</g>`}let X="",V="",O=(H,G,te,Z,B)=>{let K=H.style.length>0||H.cssCompiledStyles.length>0?At(H.cssCompiledStyles.concat(H.style)):void 0,ee=H.arrowTypeEnd,ae=K?.stroke?je(K.stroke):"var(--_l)",J=H.thickness==="dotted"?"reference":ee==="arrow_cross"?"failure":"sequence",se=wt(H.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));X+=`<g class="pele-edge pele-edge-${J}${se}" data-id="${$e(H.id)}"${K?.line??""}><path d="${te.d}"${H.thickness==="dotted"?' stroke-dasharray="3 4"':""}/>`+bt(ee,te.ex,te.ey,te.edx,te.edy,ae)+"</g>",G.width>0&&(V+=nn(H.id,G,Z,B,K?.text??"",p))},v=new Map;for(let H=0;H<P.length;H++){let G=P[H],te=w[H],Z=k[H],B=te.arrowTypeEnd,K;if(G.src===G.dst){let ee=m[G.src],ae=v.get(G.src)??0;v.set(G.src,ae+1),K=ha(h[G.src],ee.w,ee.h,ae,y(G.src),gd,ht(B),G)}else{let ee=G.route.slice();Es(ee,0,m[G.src],h[G.src]),Es(ee,ee.length-3,m[G.dst],h[G.dst]),K=yn(ee,te.curve,0,ht(B))}O(te,Z,K,G.labelX,G.labelY)}return I.forEach((H,G)=>O(H.edge,H.label,F[G],E[2*G],E[2*G+1])),{svg:Ze("agentflow",z,R,s,n,e,Ie(U,z/2,f+U.height/2,' class="pele-title" font-weight="var(--_tw)"')+(N?`<g class="pele-clusters">${N}</g>`:"")+(X?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${X}</g>`:"")+(V?`<g class="pele-edge-labels" font-size="${a}">${V}</g>`:"")+`<g class="pele-nodes">${$}</g>`),width:z,height:R,links:L}}function yd(e,t){return`M${d(e-1.75)},${d(t)}a1.75,1.75 0 1 0 3.5,0a1.75,1.75 0 1 0 -3.5,0Z`}var $h={type:"agentflow",keepComments:!0,parse(e,t,n,r,o){let s=t.flowchart??{},a=new oa({inheritDir:s.inheritDir===!0,direction:typeof t.direction=="string"?t.direction:void 0,lineOffset:r,maxEdges:o.maxEdges});return n&&(a.title=n),Jp(e,a),Ed(a,t),a},render:Lh};function sr(e){throw new Ge(e,"semantic",{type:"architecture"})}var xa=class{type="architecture";title;accTitle;accDescr;nodes=new Map;groups=new Map;edges=[];layoutHints=[];registered=new Map;register(t,n,r){this.registered.has(n)&&sr(`The ${t} id [${n}] is already in use by another ${this.registered.get(n)}`),r!==void 0&&(n===r&&sr(`The ${t} [${n}] cannot be placed within itself`),this.registered.has(r)||sr(`The ${t} [${n}]'s parent does not exist. Please make sure the parent is created before this ${t}`),this.registered.get(r)==="node"&&sr(`The ${t} [${n}]'s parent is not a group`)),this.registered.set(n,t==="group"?"group":"node")}addService({id:t,icon:n,iconText:r,title:o,in:s}){this.register("service",t,s),this.nodes.set(t,{id:t,type:"service",icon:n,iconText:r,title:o,in:s})}addJunction({id:t,in:n}){this.register("junction",t,n),this.nodes.set(t,{id:t,type:"junction",in:n})}addGroup({id:t,icon:n,title:r,in:o}){this.register("group",t,o),this.groups.set(t,{id:t,icon:n,title:r,in:o})}addEdge({lhsId:t,rhsId:n,lhsDir:r,rhsDir:o,lhsInto:s,rhsInto:a,lhsGroup:i,rhsGroup:c,title:l}){let f=[["left",t,i],["right",n,c]];for(let[u,m]of f)this.registered.has(m)||sr(`The ${u}-hand id [${m}] does not yet exist. Please create the service/group before declaring an edge to it.`);for(let[u,m]of f)this.nodes.has(m)||sr(`The ${u}-hand id [${m}] is a group. Add {group} to a service inside it instead.`);let p=this.nodes.get(t).in;if(p!==void 0&&p===this.nodes.get(n).in)for(let[u,m,h]of f)h&&sr(`The ${u}-hand id [${m}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);this.edges.push({lhsId:t,lhsDir:r,lhsInto:s,lhsGroup:i,rhsId:n,rhsDir:o,rhsInto:a,rhsGroup:c,title:l})}addLayoutHint(t){t.members.length<2&&sr(`An align directive requires at least two members; got ${t.members.length}`);let n=new Set;for(let r of t.members)this.registered.get(r)!=="node"&&sr(`align ${t.direction} references [${r}], which is not a service or junction`),n.has(r)&&sr(`align ${t.direction} lists [${r}] more than once`),n.add(r);this.layoutHints.push(t)}};function Dh(e,t){e.accDescr&&(t.accDescr=e.accDescr.replace(/\n\s+/g,`
57
+ `)),e.accTitle&&(t.accTitle=e.accTitle.replace(/^\s+/g,"")),e.title&&(t.title=e.title);for(let n of e.groups)t.addGroup(n);for(let n of e.services)t.addService(n);for(let n of e.junctions)t.addJunction(n);for(let n of e.edges)t.addEdge(n);for(let n of e.alignments)t.addLayoutHint({direction:n.direction,members:[...n.members]})}var Oh=new WeakMap;function m_(e){let t=e.map((o,s)=>s),n=[];for(let o=0;o<128;o++){let s=String.fromCharCode(o);n.push(t.filter(a=>{let{pattern:i,first:c}=e[a];return typeof i=="string"?i[0]===s:c===void 0||c.includes(s)}))}let r={starting:n,every:t,longer:e.map(o=>o.longer?.map(s=>e.indexOf(s)))};return Oh.set(e,r),r}function vt(e,t,n){let r=[],o=[],s=[],a=new Uint8Array(t.length),{starting:i,every:c,longer:l}=Oh.get(t)??m_(t),f=[],p=e.length,u=(h,g)=>{if(a[h])return-1;let x=t[h];if(x.match!==void 0)return x.match(e,g);if(x.scanner!==void 0)return(f[h]??=x.scanner())(e,g);let y=x.pattern;return typeof y=="string"?e.startsWith(y,g)?g+y.length:-1:(y.lastIndex=g,y.test(e)?y.lastIndex:(x.opener!==void 0&&(x.opener.lastIndex=g,x.opener.test(e)&&(a[h]=1)),-1))},m=0;e:for(;m<p;){let h=e.charCodeAt(m);for(let g of h<128?i[h]:c){let x=u(g,m);if(x<=m)continue;let y=g,_=l[g];if(_!==void 0)for(let S of _){let P=u(S,m);if(P>x){y=S,x=P;break}}t[y].hidden||(r.push(y),o.push(m),s.push(x)),m=x;continue e}throw it(n,e,m,"",!0)}return r.push(-1),o.push(p),s.push(p),{kinds:r,starts:o,ends:s,src:e}}var Zt={name:"ACC_DESCR",pattern:/[\t ]*accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:" a"},Yt={name:"ACC_TITLE",pattern:/[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:" a"},Ht={name:"TITLE",pattern:/[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:" t"},wn={name:"STRING",pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`},hn={name:"NEWLINE",pattern:/\r?\n/y,first:`\r
58
+ `},mn={name:"WHITESPACE",pattern:/[\t ]+/y,hidden:!0,first:" "},Pt={name:"YAML",pattern:/---[\t ]*\r?\n(?:[\S\s]*?\r?\n)?---(?:\r?\n|(?!\S))/y,hidden:!0,opener:/---[\t ]*\r?\n/y,first:"-"},Kt={name:"DIRECTIVE",pattern:/[\t ]*%%{[\S\s]*?}%%(?:\r?\n|(?!\S))/y,hidden:!0,opener:/[\t ]*%%{/y,first:" %"},zt={name:"SINGLE_LINE_COMMENT",pattern:/[\t ]*%%[^\n\r]*/y,first:" %",hidden:!0};function Vt(e){return{name:e,pattern:new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"(?:(?=%%)|(?!\\S))","y"),first:e[0]}}var g_=/accDescr(?:[\t ]*:([^\n\r]*)|\s*{([^}]*)})/,b_=/accTitle[\t ]*:([^\n\r]*)/,y_=/title([\t ][^\n\r]*|)/;function Ad(e){return e.trim().replace(/[\t ]{2,}/gm," ")}function Bt(e){return Ad(y_.exec(e)[1])}function Ft(e){return Ad(b_.exec(e)[1])}function Wt(e){let t=g_.exec(e);return t[1]!==void 0?Ad(t[1]):t[2].replace(/^\s*/gm,"").replace(/\s+$/gm,"").replace(/[\t ]{2,}/gm," ").replace(/[\n\r]{2,}/gm,`
59
+ `)}var E_=new Map([["b","\b"],["f","\f"],["n",`
60
+ `],["r","\r"],["t"," "],["v","\v"],["0","\0"]]);function rn(e){if(!e.includes("\\"))return e.slice(1,-1);let t="";for(let n=1;n<e.length-1;n++){let r=e[n];if(r==="\\"){let o=e[++n];t+=E_.get(o)??o}else t+=r}return t}var Dt=class{constructor(t,n,r){this.tokens=t;this.types=n;this.diagram=r;this.kinds=t.kinds}tokens;types;diagram;i=0;kinds;get kind(){return this.kinds[this.i]}text(t=this.i){return this.tokens.src.slice(this.tokens.starts[t],this.tokens.ends[t])}take(){return this.text(this.i++)}accept(t){return this.kinds[this.i]!==t?!1:(this.i++,!0)}expect(t){return this.kinds[this.i]!==t&&this.fail(`token of type '${this.types[t].name}'`),this.take()}fail(t){let n=this.kind===-1?"end of input":`\`${this.text()}\``;throw it(this.diagram,this.tokens.src,this.tokens.starts[this.i],`Expecting ${t} but found ${n}.`)}};var Ph={name:"ID",pattern:/[\w]([-\w]*\w)?/y};function Ur(e){return{name:e,pattern:e,longer:[Ph]}}var vh=[Ur("architecture-beta"),Ur("junction"),Ur("service"),Ur("column"),Ur("group"),Ur("align"),Ur("row"),{name:"--",pattern:"--",longer:[Pt]},Ur("in"),{name:":",pattern:":"},{name:"-",pattern:"-",longer:[Pt]},{name:"ARROW_DIRECTION",pattern:/L|R|T|B/y},{name:"ARROW_GROUP",pattern:/\{group\}/y},{name:"ARROW_INTO",pattern:/<|>/y},Zt,Yt,Ht,wn,Ph,hn,mn,Pt,Kt,zt,{name:"ARCH_ICON",pattern:/\([\w-:]+\)/y},{name:"ARCH_TITLE",pattern:/\[(?:"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|[^\[\]\r\n]+)\]/y}];function xd(e){let t=e.slice(1,-1).trim();return(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1).replace(/\\"/g,'"').replace(/\\'/g,"'")),t.trim()}function Bh(e){let t=new Dt(vt(e,vh,"architecture"),vh,"architecture"),n={$type:"Architecture",groups:[],services:[],junctions:[],edges:[],alignments:[]},r=s=>t.kinds[t.i]===s,o=()=>{if(t.kind!==-1)for(t.kind!==19&&t.fail("a line break or the end of input");t.kind===19;)t.i++};for(;t.kind===19;)t.i++;for(t.expect(0);t.kind!==-1;){switch(t.kind){case 19:t.i++;continue;case 14:n.accDescr=Wt(t.take());break;case 15:n.accTitle=Ft(t.take());break;case 16:n.title=Bt(t.take());break;case 4:{t.i++;let s={$type:"Group",id:t.expect(18)};r(24)&&(s.icon=t.take().slice(1,-1)),r(25)&&(s.title=xd(t.take())),t.accept(8)&&(s.in=t.expect(18)),n.groups.push(s);break}case 2:{t.i++;let s={$type:"Service",id:t.expect(18)};r(17)?s.iconText=rn(t.take()):r(24)&&(s.icon=t.take().slice(1,-1)),r(25)&&(s.title=xd(t.take())),t.accept(8)&&(s.in=t.expect(18)),n.services.push(s);break}case 1:{t.i++;let s={$type:"Junction",id:t.expect(18)};t.accept(8)&&(s.in=t.expect(18)),n.junctions.push(s);break}case 18:{let s=t.take(),a=t.accept(12);t.expect(9);let i=t.expect(11),c=t.accept(13),l;t.accept(7)||(r(10)||t.fail("'--' or '-'"),t.i++,l=xd(t.expect(25)),t.expect(10));let f=t.accept(13),p=t.expect(11);t.expect(9);let u=t.expect(18),m=t.accept(12);n.edges.push({$type:"Edge",lhsId:s,lhsGroup:a,lhsDir:i,lhsInto:c,title:l,rhsInto:f,rhsDir:p,rhsId:u,rhsGroup:m});break}case 5:{t.i++,!r(6)&&!r(3)&&t.fail("'row' or 'column'");let s=t.take(),a=[t.expect(18),t.expect(18)];for(;r(18);)a.push(t.take());n.alignments.push({$type:"Alignment",direction:s,members:a});break}default:t.fail("a group, a service, a junction, an edge, an alignment, a title, or a line break")}o()}return n}var A_=new Map([["database","M4 6a8 3 0 1 0 16 0a8 3 0 1 0-16 0M4 6v12a8 3 0 0 0 16 0V6M4 12a8 3 0 0 0 16 0"],["server","M3 4h18v7H3zM3 13h18v7H3zM7 7.5h.01M7 16.5h.01M11 7.5h6M11 16.5h6"],["disk","M5 3h14v18H5zM12 6.5a4 4 0 1 0 0 8a4 4 0 1 0 0-8M12 10.5h.01M8 18h3"],["internet","M3 12a9 9 0 1 0 18 0a9 9 0 1 0-18 0M3 12h18M12 3a13 13 0 0 0 0 18M12 3a13 13 0 0 1 0 18"],["cloud","M7 18a4 4 0 0 1-.5-7.97A6 6 0 0 1 18 9.5a4.25 4.25 0 0 1-.5 8.5z"]]);function Fh(e){let t=A_.get(e);return t===void 0?"":`<path d="${t}" stroke="var(--_fg)" stroke-width="1.5"/>`}var Ji=[-1,1,0,0],Sa=[0,0,-1,1];function eo(e){return e==="L"?0:e==="R"?1:e==="T"?2:3}var Wh=64,_a=2**25,Uh=2**26;function Gh(e,t,n,r){let o=e.length,s=t.length,a=s,i=new Map,c=new Map,l=new Int32Array(o+s).fill(a),f=new Int32Array(s+1),p=[];for(let G=0;G<=s;G++)p.push([]);t.forEach((G,te)=>{c.set(G.id,te);let Z=G.in===void 0?void 0:c.get(G.in);Z!==void 0&&Z!==te?(l[o+te]=Z,f[te]=f[Z]+1):f[te]=1}),e.forEach((G,te)=>{i.set(G.id,te);let Z=G.in===void 0?void 0:c.get(G.in);Z!==void 0&&(l[te]=Z),p[l[te]].push(te)});for(let G=0;G<s;G++)p[l[o+G]].push(o+G);let u=[],m=[],h=[],g=[],x=[],y=[],_=new Array(o+s),S=new Array(o+s),P=(G,te,Z,B,K)=>{if(G===te)return;let ee=G,ae=te,J=l[G],se=l[te];for(;J!==se;)f[J]>=f[se]?(ee=o+J,J=l[ee]):(ae=o+se,se=l[ae]);let me=u.length;u.push(G),m.push(te),h.push(Z),g.push(B),x.push(ee),y.push(ae),(K[ee]??=[]).push(me),(K[ae]??=[]).push(me)};for(let G of r){let te=G.direction==="row";for(let Z=1;Z<G.members.length;Z++){let B=i.get(G.members[Z-1]),K=i.get(G.members[Z]);B!==void 0&&K!==void 0&&P(B,K,te?1:3,te?0:2,_)}}for(let G of[!1,!0])for(let te of n){if(te.lhsDir===te.rhsDir!==G)continue;let Z=i.get(te.lhsId),B=i.get(te.rhsId);Z!==void 0&&B!==void 0&&P(Z,B,eo(te.lhsDir),eo(te.rhsDir),S)}let k=new Int32Array(o+s),w=new Int32Array(o+s),I=new Int32Array(o+s).fill(1),D=new Int32Array(o+s).fill(1),U=new Uint8Array(o+s),M=[],Q=new Map,q=[],Y=new Map,z=0,R=0,L=0,F=(G,te)=>{R=0,L=0;for(let Z=G;Z!==te;Z=o+l[Z])R+=k[Z],L+=w[Z]},E=(G,te,Z)=>{if(k[G]=te,w[G]=Z,U[G]=1,M.push(G),I[G]*D[G]>Wh){q.push(G);return}for(let B=Z;B<Z+D[G];B++)for(let K=te;K<te+I[G];K++)Q.set((K+_a)*Uh+B+_a,G)},C=(G,te,Z,B,K)=>k[G]<te+B&&te<k[G]+I[G]&&w[G]<Z+K&&Z<w[G]+D[G],A=(G,te,Z,B)=>{if(Z*B>Wh){for(let K=z;K<M.length;K++)if(C(M[K],G,te,Z,B))return M[K];return-1}for(let K=te;K<te+B;K++)for(let ee=G;ee<G+Z;ee++){let ae=Q.get((ee+_a)*Uh+K+_a);if(ae!==void 0)return ae}for(let K of q)if(C(K,G,te,Z,B))return K;return-1},T=(G,te,Z,B,K,ee)=>{let ae=`${G},${te},${Z},${B},${K},${ee}`,J=Y.get(ae)??0;for(;;){let se=A(G+J*K,te+J*ee,Z,B);if(se<0)break;J=K>0?k[se]+I[se]-G:K<0?G+Z-k[se]:ee>0?w[se]+D[se]-te:te+B-w[se]}return Y.set(ae,J),J},b=(G,te)=>{let Z=x[te]===G,B=Z?y[te]:x[te];if(U[B])return;let K=Z?h[te]:g[te],ee=Z?g[te]:h[te];F(Z?u[te]:m[te],G);let ae=R,J=L;F(Z?m[te]:u[te],B);let se=Ji[K],me=Sa[K],Ae=0,de=0,oe=Ji[K]+Ji[ee]===0&&Sa[K]+Sa[ee]===0;K===ee?(se=Ji[K]===0?1:0,me=1-se):oe||(Ae=-Ji[ee],de=-Sa[ee]);let ye,ce;if(se!==0?(ye=se>0?k[G]+I[G]:k[G]-I[B],ce=w[G]+J+de-L):(ce=me>0?w[G]+D[G]:w[G]-D[B],ye=k[G]+ae+Ae-R),oe){let fe=S[B];if(fe!==void 0&&fe.length>1){let ue=[];for(let ge of fe){let Se=y[ge]===B,we=Se?x[ge]:y[ge];if(!U[we]||(Se?h[ge]:g[ge])!==K||(Se?g[ge]:h[ge])!==ee)continue;F(Se?u[ge]:m[ge],we);let ke=se!==0?w[we]+L:k[we]+R;F(Se?m[ge]:u[ge],B),ue.push(ke-(se!==0?L:R))}ue.length>1&&(ue.sort((ge,Se)=>ge-Se),se!==0?ce=ue[ue.length-1>>1]:ye=ue[ue.length-1>>1])}let xe=se===0?1:0,be=1-xe,re=T(ye,ce,I[B],D[B],xe,be),j=re===0?0:T(ye,ce,I[B],D[B],-xe,-be),ie=re<=j?re:-j;ye+=xe*ie,ce+=be*ie}else{let fe=T(ye,ce,I[B],D[B],se,me);ye+=se*fe,ce+=me*fe}E(B,ye,ce)},N=G=>{let te=p[G];if(te.length===0)return;M.length=0;let Z=[];for(let fe of te){if(U[fe])continue;z=M.length,Z.push(z),Q.clear(),q.length=0,Y.clear(),E(fe,0,0);let xe=z,be=z,re=0;for(;;){if(xe<M.length){let ie=M[xe++],ue=_[ie];if(ue!==void 0)for(let ge of ue)b(ie,ge);continue}if(be>=M.length)break;let j=S[M[be]];if(j===void 0||re>=j.length){be++,re=0;continue}b(M[be],j[re++])}}Z.push(M.length);let B=Z.length-1,K=new Array(B),ee=new Array(B),ae=new Array(B),J=new Array(B),se=0,me=0;for(let fe=0;fe<B;fe++){let xe=1/0,be=1/0,re=-1/0,j=-1/0;for(let ie=Z[fe];ie<Z[fe+1];ie++){let ue=M[ie];xe=Math.min(xe,k[ue]),be=Math.min(be,w[ue]),re=Math.max(re,k[ue]+I[ue]),j=Math.max(j,w[ue]+D[ue])}K[fe]=xe,ee[fe]=be,ae[fe]=re-xe,J[fe]=j-be,se+=ae[fe]*J[fe],me=Math.max(me,ae[fe])}let Ae=Math.max(me,Math.ceil(Math.sqrt(se*2))),de=0,oe=0,ye=0,ce=0;for(let fe=0;fe<B;fe++){de>0&&de+ae[fe]>Ae&&(oe+=ye,de=0,ye=0);for(let xe=Z[fe];xe<Z[fe+1];xe++)k[M[xe]]+=de-K[fe],w[M[xe]]+=oe-ee[fe];de+=ae[fe],ye=Math.max(ye,J[fe]),ce=Math.max(ce,de)}G<s&&(I[o+G]=ce,D[o+G]=oe+ye)};for(let G=s-1;G>=0;G--)N(G);N(a);let $=new Int32Array(s),X=new Int32Array(s),V=new Int32Array(s),O=new Uint8Array(s);for(let G=0;G<s;G++){let te=l[o+G];V[G]=te===a?-1:te,$[G]=k[o+G]+(te===a?0:$[te]),X[G]=w[o+G]+(te===a?0:X[te]),p[G].length===0&&(O[G]=1)}let v=new Int32Array(o),W=new Int32Array(o),H=new Int32Array(o);for(let G=0;G<o;G++){let te=l[G];H[G]=te===a?-1:te,v[G]=k[G]+(te===a?0:$[te]),W[G]=w[G]+(te===a?0:X[te])}return{col:v,row:W,groupCol:$,groupRow:X,groupCols:I.slice(o),groupRows:D.slice(o),groupParent:V,groupEmpty:O,nodeParent:H}}var An=12,x_=6,Yh=4,Hh=3,S_=[-1,1,0,0],__=[0,0,-1,1];function Sd(e,t,n,r,o){let s=e.architecture,a=s!==null&&typeof s=="object"&&!Array.isArray(s)?s[t]:void 0;return typeof a=="number"&&Number.isFinite(a)?Math.min(o,Math.max(r,a)):n}function Kh(e){let t=new Map;for(let n of e.sort((r,o)=>r-o))t.has(n)||t.set(n,t.size);return t}function zh(e,t,n,r,o){return`<svg class="pele-icon" data-icon="${$e(e)}" x="${d(t)}" y="${d(n)}" width="${d(r)}" height="${d(r)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${o?.(e)??Fh(e)}</svg>`}function w_(e,t,n,r){let o=e.lines.length>n;if(!o&&e.width<=t)return e;let s=r.width("…",e.size,0),a=[],i=[],c=0;for(let l=0;l<Math.min(n,e.lines.length);l++){let f=e.lines[l].map(u=>({...u})),p=e.widths[l];if(p>t||o&&l===n-1)for(;;){let u=f[f.length-1];if(u===void 0){f.push({text:"…",style:0,width:s}),p=s;break}let m=p-u.width;if(u.icon===void 0&&m+s<t){let h=0,g=u.text.length;for(;h<g;){let y=h+g+1>>1;m+r.width(u.text.slice(0,y),e.size,u.style)+s<=t?h=y:g=y-1}let x=h>0?u.text.charCodeAt(h-1):0;x>=55296&&x<=56319&&h--,u.text=u.text.slice(0,h).trimEnd()+"…",u.width=r.width(u.text,e.size,u.style),p=m+u.width;break}f.pop(),p=m}a.push(f),i.push(p),c=Math.max(c,p)}return{...e,lines:a,widths:i,width:c,height:a.length*e.lineHeight}}function R_(e,t){let{x:n,y:r,dx:o,dy:s}=e,{x:a,y:i,dx:c,dy:l}=t,f=n+o*An,p=r+s*An,u=a+c*An,m=i+l*An;if(o*c+s*l===0){let y=o!==0?a:n,_=o!==0?r:i;return(y-n)*o+(_-r)*s>0&&(y-a)*c+(_-i)*l>0?[n,r,y,_,a,i]:o!==0?[n,r,f,p,f,m,u,m,a,i]:[n,r,f,p,u,p,u,m,a,i]}let h=o!==0,g=h?i-r:a-n;if(o===-c&&s===-l){if((a-n)*o+(i-r)*s>0){if(Math.abs(g)<.5)return[n,r,a,i];if(h){let k=o>0?e.x1:t.x1,w=o>0?t.x0:e.x0,I=k<w?(k+w)/2:(n+a)/2;return[n,r,I,r,I,i,a,i]}let _=s>0?e.y1:t.y1,S=s>0?t.y0:e.y0,P=_<S?(_+S)/2:(r+i)/2;return[n,r,n,P,a,P,a,i]}}else if(Math.abs(g)>=1){if(h){let _=o>0?Math.max(n,a)+An:Math.min(n,a)-An;return[n,r,_,r,_,i,a,i]}let y=s>0?Math.max(r,i)+An:Math.min(r,i)-An;return[n,r,n,y,a,y,a,i]}if(h){let y=e.y1+An<=t.y0?(e.y1+t.y0)/2:t.y1+An<=e.y0?(t.y1+e.y0)/2:Math.max(e.y1,t.y1)+An;return[n,r,f,r,f,y,u,y,u,i,a,i]}let x=e.x1+An<=t.x0?(e.x1+t.x0)/2:t.x1+An<=e.x0?(t.x1+e.x0)/2:Math.max(e.x1,t.x1)+An;return[n,r,n,p,x,p,x,m,a,m,a,i]}function T_(e){let t=[e[0],e[1]];for(let n=2;n<e.length;n+=2){let r=e[n],o=e[n+1],s=t.length,a=Math.abs(r-t[s-2])<.01,i=Math.abs(o-t[s-1])<.01;a&&i||(s>=4&&(a&&Math.abs(t[s-4]-t[s-2])<.01||i&&Math.abs(t[s-3]-t[s-1])<.01)?(t[s-2]=r,t[s-1]=o):t.push(r,o))}return t}function C_(e,t,n){let r=e.length/2,o=new Array(r),s=new Array(r);for(let c=0;c<r;c++)o[c]=e[c*2],s[c]=e[c*2+1];let a=(c,l,f)=>{let p=Math.hypot(o[l]-o[c],s[l]-s[c]),u=Math.min(f,Math.max(0,p-1));p>0&&u>0&&(o[c]+=(o[l]-o[c])/p*u,s[c]+=(s[l]-s[c])/p*u)};a(0,1,t),a(r-1,r-2,n);let i=`M${d(o[0])},${d(s[0])}`;for(let c=1;c<r-1;c++){let l=Math.hypot(o[c]-o[c-1],s[c]-s[c-1]),f=Math.hypot(o[c+1]-o[c],s[c+1]-s[c]),p=Math.min(x_,l/2,f/2);if(p<.5){i+=`L${d(o[c])},${d(s[c])}`;continue}let u=o[c]-(o[c]-o[c-1])/l*p,m=s[c]-(s[c]-s[c-1])/l*p,h=o[c]+(o[c+1]-o[c])/f*p,g=s[c]+(s[c+1]-s[c])/f*p;i+=`L${d(u)},${d(m)}Q${d(o[c])},${d(s[c])} ${d(h)},${d(g)}`}return i+`L${d(o[r-1])},${d(s[r-1])}`}function Vh(e,t,n){return pn(n,r=>I_(e,t,n,r))}function I_(e,t,n,r){let o=Sd(t,"iconSize",48,8,512),s=Sd(t,"fontSize",n.fontSize??16,4,128),a=Math.min(Sd(t,"padding",20,0,256),r?12:1/0),i=Math.round(s*.875),c=n.measurer??Je(n.fontFamily),l=n.padding??8,f=n.icons,p=o/2,u=[...e.nodes.values()],m=[...e.groups.values()],h=u.length,g=m.length,x=Gh(u,m,e.edges,e.layoutHints),y=new Map;u.forEach((le,Ee)=>y.set(le.id,Ee));let _=new Array(h),S=new Float64Array(h),P=new Float64Array(h),k=r?Math.max(o,64):Math.max(o*2.25,96);for(let le=0;le<h;le++){let Ee=u[le],Ne=De(Ee.type==="service"?Ee.title:void 0,!0,c,s,k);_[le]=Ne,S[le]=Math.max(o,2*Math.ceil(Ne.width/2)),P[le]=o+(Ne.height>0?Yh+Ne.height:0)}let w=[],I=[];for(let le=0;le<h;le++)w.push(x.col[le]),I.push(x.row[le]);for(let le=0;le<g;le++)x.groupEmpty[le]&&(w.push(x.groupCol[le]),I.push(x.groupRow[le]));let D=Kh(w),U=Kh(I),M=D.size,Q=U.size,q=new Float64Array(M),Y=new Float64Array(Q),z=r?Math.max(24,2*An):Math.max(40,Math.round(o*.75)),R=new Float64Array(M).fill(z),L=new Float64Array(Q).fill(z),F=new Int32Array(h),E=new Int32Array(h);for(let le=0;le<h;le++){let Ee=F[le]=D.get(x.col[le]),Ne=E[le]=U.get(x.row[le]);q[Ee]=Math.max(q[Ee],S[le]),Y[Ne]=Math.max(Y[Ne],P[le])}for(let le=0;le<g;le++){if(!x.groupEmpty[le])continue;let Ee=D.get(x.groupCol[le]),Ne=U.get(x.groupRow[le]);q[Ee]=Math.max(q[Ee],o),Y[Ne]=Math.max(Y[Ne],p)}let C=e.edges.length,A=new Array(C),T=new Int32Array(C*2);for(let le=0;le<C;le++){let Ee=e.edges[le],Ne=T[le*2]=y.get(Ee.lhsId)??-1,Me=T[le*2+1]=y.get(Ee.rhsId)??-1,Ce=De(Ee.title,!0,c,i,160);if(A[le]=Ce,!(Ce.width===0||Ne<0||Me<0)){if(F[Ne]!==F[Me]){let Oe=Math.min(F[Ne],F[Me]);R[Oe]=Math.max(R[Oe],Math.ceil(Ce.width)+28)}else if(q[F[Ne]]=Math.max(q[F[Ne]],2*Math.ceil(Ce.width/2)+8),E[Ne]!==E[Me]){let Oe=Math.min(E[Ne],E[Me]);L[Oe]=Math.max(L[Oe],Math.ceil(Ce.height)+24)}}}let b=new Array(g),N=new Int32Array(g),$=new Int32Array(g),X=new Int32Array(g),V=new Int32Array(g),O=new Float64Array(g),v=new Float64Array(g),W=new Float64Array(g),H=new Float64Array(g),G=new Float64Array(g),te=new Float64Array(g),Z=new Float64Array(M),B=new Float64Array(M),K=new Float64Array(Q),ee=new Float64Array(Q),ae=Math.round(s*1.25);for(let le=0;le<g;le++){N[le]=D.get(x.groupCol[le]),$[le]=D.get(x.groupCol[le]+x.groupCols[le]-1),X[le]=U.get(x.groupRow[le]),V[le]=U.get(x.groupRow[le]+x.groupRows[le]-1);let Ee=De(m[le].title,!0,c,s,r?Math.max(80,Rt(n)/2):320);b[le]=Ee;let Ne=m[le].icon?ae:0;G[le]=Ee.width+Ne+(Ee.width>0&&Ne>0?6:0),te[le]=Math.max(Ee.height,Ne)}for(let le=g-1;le>=0;le--){let Ee=a+O[le],Ne=a+v[le],Me=(te[le]>0?Math.max(a,te[le]+12):a)+W[le],Ce=a+H[le];if(G[le]>0){let We=Ee+Ne;for(let Te=N[le];Te<=$[le];Te++)We+=q[Te]+(Te<$[le]?B[Te]+R[Te]+Z[Te+1]:0);G[le]+20>We&&(Ne+=Math.ceil(G[le]+20-We))}O[le]=Ee,v[le]=Ne,W[le]=Me,H[le]=Ce,Z[N[le]]=Math.max(Z[N[le]],Ee),B[$[le]]=Math.max(B[$[le]],Ne),K[X[le]]=Math.max(K[X[le]],Me),ee[V[le]]=Math.max(ee[V[le]],Ce);let Oe=x.groupParent[le];Oe<0||(N[Oe]===N[le]&&(O[Oe]=Math.max(O[Oe],Ee)),$[Oe]===$[le]&&(v[Oe]=Math.max(v[Oe],Ne)),X[Oe]===X[le]&&(W[Oe]=Math.max(W[Oe],Me)),V[Oe]===V[le]&&(H[Oe]=Math.max(H[Oe],Ce)))}let J=new Float64Array(M),se=new Float64Array(Q),me=0;for(let le=0;le<M;le++)J[le]=me+Z[le],me=J[le]+q[le]+B[le]+(le<M-1?R[le]:0);let Ae=0;for(let le=0;le<Q;le++)se[le]=Ae+K[le],Ae=se[le]+Y[le]+ee[le]+(le<Q-1?L[le]:0);let de=0,oe=0,ye=me,ce=Ae,fe=le=>J[N[le]]-O[le],xe=le=>J[$[le]]+q[$[le]]+v[le],be=le=>se[X[le]]-W[le],re=le=>se[V[le]]+Y[V[le]]+H[le],j=le=>J[F[le]]+q[F[le]]/2,ie=(le,Ee,Ne)=>{let Me=S_[Ee],Ce=__[Ee],Oe=j(le),We=se[E[le]],Te={x:Oe,y:We+p,dx:Me,dy:Ce,x0:Oe-S[le]/2,y0:We,x1:Oe+S[le]/2,y1:We+P[le],gap:0,wire:!1};u[le].type==="junction"?(Te.x0=Te.x1=Oe,Te.y0=Te.y1=Te.y,Te.gap=Hh):Me!==0?Te.x=Oe+Me*p:Te.y=Ce<0?We:We+P[le]+(_[le].height>0?2:0);let Ke=Ne?x.nodeParent[le]:-1;return Ke>=0&&(Te.x0=fe(Ke),Te.x1=xe(Ke),Te.y0=be(Ke),Te.y1=re(Ke),Te.gap=0,Te.wire=u[le].type==="junction",Me!==0?Te.x=Me<0?Te.x0:Te.x1:Te.y=Ce<0?Te.y0:Te.y1),Te},ue="",ge="",Se=[],we=ht("arrow_point");for(let le=0;le<C;le++){let Ee=e.edges[le],Ne=T[le*2],Me=T[le*2+1];if(Ne<0||Me<0)continue;let Ce=ie(Ne,eo(Ee.lhsDir),Ee.lhsGroup),Oe=ie(Me,eo(Ee.rhsDir),Ee.rhsGroup);Ce.x===Oe.x&&Ce.y===Oe.y&&Ce.dx===Oe.dx&&(Ce.x-=8*Math.abs(Ce.dy),Ce.y-=8*Math.abs(Ce.dx),Oe.x+=8*Math.abs(Ce.dy),Oe.y+=8*Math.abs(Ce.dx));let We=R_(Ce,Oe);Ce.wire&&We.unshift(j(Ne),se[E[Ne]]+p),Oe.wire&&We.push(j(Me),se[E[Me]]+p);let Te=T_(We);if(Te.length<4)continue;let Ke=$e(`${Ee.lhsId}-${Ee.rhsId}`);ue+=`<g class="pele-edge" data-id="${Ke}"><path d="${C_(Te,Ee.lhsInto&&!Ce.wire?we+Ce.gap:0,Ee.rhsInto&&!Oe.wire?we+Oe.gap:0)}"/>`+(Ee.lhsInto?bt("arrow_point",Ce.x+Ce.dx*Ce.gap,Ce.y+Ce.dy*Ce.gap,-Ce.dx,-Ce.dy,"var(--_l)"):"")+(Ee.rhsInto?bt("arrow_point",Oe.x+Oe.dx*Oe.gap,Oe.y+Oe.dy*Oe.gap,-Oe.dx,-Oe.dy,"var(--_l)"):"")+"</g>";let ze=-1,at=-1,et=-1,nt=-1,Tt=A[le];for(let lt=0;lt<Te.length;lt+=2)de=Math.min(de,Te[lt]-4),ye=Math.max(ye,Te[lt]+4),oe=Math.min(oe,Te[lt+1]-4),ce=Math.max(ce,Te[lt+1]+4);for(let lt=0;lt+3<Te.length;lt+=2){let Et=Math.abs(Te[lt+1]-Te[lt+3])<.01,ot=Math.abs(Te[lt]-Te[lt+2])+Math.abs(Te[lt+1]-Te[lt+3]);Et||Se.push(Te[lt],Math.min(Te[lt+1],Te[lt+3]),Math.max(Te[lt+1],Te[lt+3])),ot>at&&(ze=lt,at=ot),Et&&ot>nt&&(et=lt,nt=ot)}if(Tt.width>0){let lt=nt>=Tt.width+8?et:ze,Et=(Te[lt]+Te[lt+2])/2,ot=(Te[lt+1]+Te[lt+3])/2,rt=Tt.width+8,Ve=Math.abs(Te[lt]-Te[lt+2])<.01;for(let st of[Ce,Oe])Et+rt/2<=st.x0||Et-rt/2>=st.x1||ot+Tt.height/2<=st.y0||ot-Tt.height/2>=st.y1||(Ve?Et=Et>=(st.x0+st.x1)/2?st.x1+rt/2+4:st.x0-rt/2-4:ot=ot>=(st.y0+st.y1)/2?st.y1+Tt.height/2+4:st.y0-Tt.height/2-4);de=Math.min(de,Et-rt/2),ye=Math.max(ye,Et+rt/2),oe=Math.min(oe,ot-Tt.height/2),ce=Math.max(ce,ot+Tt.height/2),ge+=nn(`${Ee.lhsId}-${Ee.rhsId}`,Tt,Et,ot,"",f)}}let ke="";for(let le=0;le<g;le++){let Ee=m[le],Ne=fe(le),Me=be(le),Ce=xe(le)-Ne,Oe=b[le],We="";if(G[le]>0){let Te=Me+te[le]+12,Ke=[];for(let nt=0;nt<Se.length;nt+=3)Se[nt+1]<Te&&Se[nt+2]>Me&&Se[nt]>Ne&&Se[nt]<Ne+Ce&&Ke.push(Se[nt]);Ke.sort((nt,Tt)=>nt-Tt),Ke.push(Ne+Ce-4);let ze=Ne+10;for(let nt of Ke){if(nt-6-ze>=G[le])break;ze=Math.max(ze,nt+6)}ze+G[le]>Ne+Ce-4&&(ze=Ne+10);let at=Me+6+te[le]/2,et=ze;Ee.icon&&(We+=zh(Ee.icon,ze,at-ae/2,ae,f),et+=ae+6),We+=Ie(Oe,et+Oe.width/2,at,' class="pele-cluster-label" fill="var(--_m)"',f)}ke+=`<g class="pele-cluster" data-id="${$e(Ee.id)}"><rect x="${d(Ne)}" y="${d(Me)}" width="${d(Ce)}" height="${d(re(le)-Me)}" rx="${Xe}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"/>`+We+"</g>"}let Le="",Fe=o*.5,He=Math.max(6,Math.round(s*.75));for(let le=0;le<h;le++){let Ee=u[le],Ne=`data-id="${$e(Ee.id)}" transform="translate(${d(j(le))},${d(se[E[le]])})"`;if(Ee.type==="junction"){Le+=`<g class="pele-node pele-junction" ${Ne}><circle cy="${d(p)}" r="${Hh}" fill="var(--_l)"/></g>`;continue}let Me="";if(Ee.icon)Me=zh(Ee.icon,-Fe/2,(o-Fe)/2,Fe,f);else if(Ee.iconText){let Ce=De(Ee.iconText,!1,c,He,o-8),Oe=Math.max(1,Math.floor((o-4)/(Ce.lineHeight||1)));Me=Ie(w_(Ce,o-8,Oe,c),0,p,` class="pele-icon-text" font-size="${He}"`,f)}Le+=`<g class="pele-node pele-service" ${Ne}><rect x="${d(-p)}" width="${d(o)}" height="${d(o)}" rx="${Xe}" fill="var(--_s)" stroke="var(--_b)"/>`+Me+Ie(_[le],0,o+Yh+_[le].height/2,' class="pele-label"',f)+"</g>"}let _e=De(e.title,!1,c,s,r?Rt(n):4e3,1),Pe=_e.height>0?_e.height+12:0,Ye=Math.ceil(Math.max(ye-de,_e.width)+2*l),Ue=Math.ceil(ce-oe+Pe+2*l),he=Math.round((Ye-(ye-de))/2-de),ne=Math.round(l+Pe-oe),pe=(ke?`<g class="pele-clusters">${ke}</g>`:"")+(ue?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round" stroke-linejoin="round">${ue}</g>`:"")+(ge?`<g class="pele-edge-labels" font-size="${i}">${ge}</g>`:"")+(Le?`<g class="pele-nodes">${Le}</g>`:"");return{svg:Ze("architecture",Ye,Ue,s,n,e,Ie(_e,Ye/2,l+_e.height/2,' class="pele-title" font-weight="var(--_tw)"')+(pe?`<g transform="translate(${he},${ne})">${pe}</g>`:"")),width:Ye,height:Ue,links:[]}}var jh={type:"architecture",parse(e,t,n){let r=new xa;return n&&(r.title=n),Dh(Bh(e),r),r},render:Vh};var Xh=1e5;function N_(e){switch(e){case"[]":return"square";case"()":return"round";case"(())":return"circle";case">]":return"rect_left_inv_arrow";case"{}":return"diamond";case"{{}}":return"hexagon";case"([])":return"stadium";case"[[]]":return"subroutine";case"[()]":return"cylinder";case"((()))":return"doublecircle";case"[//]":return"lean_right";case"[\\\\]":return"lean_left";case"[/\\]":return"trapezoid";case"[\\/]":return"inv_trapezoid";case"<[]>":return"block_arrow";default:return"na"}}function M_(e){switch(e.trim().slice(-1)){case"x":return"arrow_cross";case"o":return"arrow_circle";case">":return"arrow_point";default:return""}}function k_(e){switch(e.trim().charAt(0)){case"x":return"arrow_cross";case"o":return"arrow_circle";case"<":return"arrow_point";default:return"arrow_open"}}function L_(e){return e.includes("==")?"thick":"normal"}function $_(e){return e.includes(".-")?"dotted":"solid"}function qh(e,t){let n=e.flat(),r=-1;for(let o of n)if(o.type==="column-setting"){r=o.columns??-1;break}return{list:n,at:0,parent:t,children:[],columns:r}}var wa=class{type="block";title;root={id:"root",type:"composite",children:[],columns:-1};blocks=[];edges=[];classes=new Map;byId=new Map;typeStr2Type=N_;edgeStrToEdgeData=M_;edgeStrToEdgeStartData=k_;edgeStrToThickness=L_;edgeStrToPattern=$_;warn;pending=new Set;edgeCount=new Map;ids=0;colors=0;spaces=0;constructor(t={}){this.warn=t.warn}generateId(){return"id-"+ ++this.ids}addStyleClass(t,n=""){let r=this.classes.get(t);r||(r={id:t,styles:[],textStyles:[]},this.classes.set(t,r));for(let o of n.split(",")){let s=o.indexOf(";"),a=(s===-1?o:o.slice(0,s)+o.slice(s+1)).trim();o.includes("color")&&r.textStyles.push(a.replace("fill","bgFill").replace("color","fill")),r.styles.push(a)}}addStyle2Node(t,n=""){this.named(t).styles=n.split(",")}setCssClass(t,n){for(let r of t.split(","))(this.named(r.trim()).classes??=[]).push(n)}named(t){let n=this.byId.get(t);return n===void 0&&(n={id:t,type:"na",children:[]},this.byId.set(t,n),this.pending.add(t)),n}setHierarchy(t){let n=[qh(t,this.root)];for(;n.length>0;){let r=n[n.length-1];if(r.at===r.list.length){r.parent.children=r.children,n.pop();continue}let o=r.list[r.at++];switch(r.columns>0&&o.type!=="column-setting"&&typeof o.widthInColumns=="number"&&o.widthInColumns>r.columns&&this.warn?.(`Block ${o.id} width ${o.widthInColumns} exceeds configured column width ${r.columns}`),o.type){case"classDef":this.addStyleClass(o.id,o.css);continue;case"applyClass":this.setCssClass(o.id,o.styleClass??"");continue;case"applyStyles":o.stylesStr&&this.addStyle2Node(o.id,o.stylesStr);continue;case"column-setting":r.parent.columns=o.columns??-1;continue;case"edge":{let c=(this.edgeCount.get(o.id)??0)+1;this.edgeCount.set(o.id,c),o.id=c+"-"+o.id,this.edges.push(o);continue}}o.id??=this.generateId(),o.label||(o.label=o.type==="composite"?"":o.id);let s=this.byId.get(o.id),a=s===void 0||this.pending.delete(o.id);a?(s&&(o.classes=s.classes,o.styles=s.styles),o.type==="composite"&&(o.colorIndex=this.colors++),this.byId.set(o.id,o)):(o.type!=="na"&&(s.type=o.type),o.label!==o.id&&(s.label=o.label));let i=o.children;if(o.children=[],o.type==="space"){let c=o.width??1;if(!(c<=Xh-this.spaces))throw new Ge(`A block diagram can hold at most ${Xh} space blocks.`,"limit",{type:"block"});this.spaces+=Math.max(c,0);for(let l=0;l<c;l++){let f={...o,id:o.id+"-"+l,children:[]};this.byId.set(f.id,f),r.children.push(f)}}else a&&r.children.push(o);i&&i.length>0&&n.push(qh(i,o))}this.blocks=this.root.children??[]}};var _d=["$end","INVALID","BLOCK_DIAGRAM_KEY","id-block","COLUMNS","MD_STR","STR","SPACE_BLOCK","DEFAULT","LINKSTYLE","INTERPOLATE","classDef","DEFAULT_CLASSDEF_ID","CLASSDEF_ID","CLASSDEF_STYLEOPTS","class","CLASSENTITY_IDS","STYLECLASS","style","STYLE_ENTITY_IDS","STYLE_DEFINITION_DATA","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","end","NODE_DSTART","NODE_DEND","BLOCK_ARROW_START","BLOCK_ARROW_END","DIR","NODE_ID","LINK","START_LINK","LINK_LABEL","SIZE","EOF"];var D_=["right","left","x","y","up","down"],Qh=new Uint8Array(128);for(let e of[9,10,11,12,13,32,40,41,45,58,60,61,62,91,123,125])Qh[e]=1;function Zh(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=(U,M,Q)=>(n.push(U),r.push(M),o.push(i),i=Q,!0),l=(U,M)=>c(U,e.slice(i,M),M),f=U=>{s.push(a),a=U},p=()=>{s.length>0&&(a=s.pop())},u=U=>{for(;U<t&&Be(e.charCodeAt(U));)U++;return U},m=U=>{for(;U<t;){let M=e.charCodeAt(U);if(M<48||M>57)break;U++}return U},h=U=>{for(;U<t&&Qe(e.charCodeAt(U));)U++;return U},g=U=>e.startsWith(U,i)&&!Qe(e.charCodeAt(i+U.length)),x=()=>(e.charCodeAt(i+1)===96?(f(2),i+=2):(f(1),i++),!0),y=U=>{if(e.charCodeAt(U)!==46)return-1;do U++;while(e.charCodeAt(U)===46);if(e.charCodeAt(U)!==45)return-1;let M=e.charCodeAt(U+1);return M===120||M===111||M===62?U+2:U+1},_=U=>{let M=e.charCodeAt(U);(M===120||M===111||M===60)&&U++;let Q=e.charCodeAt(U);if(Q===46)return y(U);if(Q!==45&&Q!==61)return-1;let q=U+1;for(;e.charCodeAt(q)===Q;)q++;if(q-U===1)return Q===45?y(q):-1;let Y=e.charCodeAt(q);return Y===120||Y===111||Y===62?q+1:q-U>=3?q:-1},S=()=>{let U=_(i);if(U>=0)return l(33,u(U));let M=e.charCodeAt(i)===60?i+1:i,Q=e.charCodeAt(M),q=e.charCodeAt(M+1);return Q===45&&(q===45||q===46)||Q===61&&q===61?(f(6),l(34,u(M+2))):!1},P=U=>{let M=e.indexOf(`
61
+ `,i);return M===-1&&(M=t),p(),l(U,M)},k=(U,M)=>{let Q=h(i);if(Q===i)return!1;for(;e.charCodeAt(Q)===44;){let q=u(Q+1),Y=h(q);if(Y===q)break;Q=Y}return a=M,l(U,Q)},w=U=>{if(Be(U))return i=u(i+1),!0;let M;switch(U){case 98:if(e.startsWith("block",i)){if(g("block-beta"))return l(2,i+10);if(e.charCodeAt(i+5)===58)return l(3,i+6);if(!Qe(e.charCodeAt(i+5)))return l(2,i+5)}break;case 99:if(e.startsWith("columns",i)){if(M=u(i+7),M>i+7){if(e.startsWith("auto",M)&&!Qe(e.charCodeAt(M+4)))return c(4,"-1",M+4);let Q=m(M);if(Q>M)return c(4,e.slice(M,Q),Q)}}else if(e.startsWith("class",i)){let Q=e.startsWith("Def",i+5),q=Q?i+8:i+5;if(M=u(q),M>q)return f(Q?7:9),l(Q?11:15,M)}break;case 34:return x();case 115:if(e.startsWith("space",i)){if(e.charCodeAt(i+5)===58){let Q=m(i+6);if(Q>i+6)return c(7,e.slice(i+6,Q),Q)}if(!Qe(e.charCodeAt(i+5)))return c(7,"1",i+5)}else if(e.startsWith("style",i)&&(M=u(i+5),M>i+5))return f(11),l(18,M);break;case 100:if(g("default"))return l(8,i+7);break;case 108:if(g("linkStyle"))return l(9,i+9);break;case 105:if(g("interpolate"))return l(10,i+11);break;case 97:if(e.startsWith("accTitle",i)){if(M=u(i+8),e.charCodeAt(M)===58)return f(13),l(21,u(M+1))}else if(e.startsWith("accDescr",i)){M=u(i+8);let Q=e.charCodeAt(M);if(Q===58)return f(14),l(23,u(M+1));if(Q===123)return f(15),i=u(M+1),!0}break;case 101:if(g("end"))return l(26,u(i+3));break;case 45:return e.charCodeAt(i+1)===41?(f(3),l(27,i+2)):S();case 61:return S();case 60:return e.charCodeAt(i+1)===91?(f(4),l(29,i+2)):S();case 40:{let Q=e.charCodeAt(i+1),q=Q===45||Q===91?2:Q===40?e.charCodeAt(i+2)===40?3:2:1;return f(3),l(27,i+q)}case 41:case 123:return f(3),l(27,e.charCodeAt(i+1)===U?i+2:i+1);case 62:return f(3),l(27,i+1);case 91:{let Q=e.charCodeAt(i+1);return f(3),l(27,Q===91||Q===124||Q===40||Q===92||Q===47?i+2:i+1)}case 58:{let Q=m(i+1);return Q>i+1?c(36,e.slice(i+1,Q),Q):!1}}for(M=i;M<t;){let Q=e.charCodeAt(M);if(Q<128?Qh[Q]===1:Be(Q))break;M++}return M>i&&l(32,M)},I=U=>{let M=e.charCodeAt(i+1),Q=0;switch(U){case 34:return x();case 40:Q=M===45?2:M===40?e.charCodeAt(i+2)===40?3:2:1;break;case 41:Q=M===41?e.charCodeAt(i+2)===41?3:2:M===93?2:1;break;case 125:Q=M===125?2:1;break;case 45:Q=M===41?2:0;break;case 93:Q=M===93||M===41||M===62?2:1;break;case 92:case 47:Q=M===93?2:0;break}return Q===0?!1:(p(),l(28,i+Q))},D=U=>{if(U===41)return p(),p(),c(30,"]>",u(i+1));let M=u(U===44?i+1:i);for(let Q of D_)if(e.startsWith(Q,M)){let q=u(M+Q.length);return c(31,e.slice(U===44?M:i,q),q)}return!1};for(;;){if(i>=t){let Q=-1;switch(a){case 0:Q=37;break;case 1:Q=6;break;case 8:Q=14;break;case 10:Q=17;break;case 12:Q=20;break;case 13:Q=22;break;case 14:Q=24;break;case 15:Q=25;break}i=t,Q!==-1&&c(Q,"",t);break}let U=e.charCodeAt(i),M=!0;switch(a){case 0:M=w(U);break;case 1:if(U===34)p(),i++;else{let Q=e.indexOf('"',i);l(6,Q===-1?t:Q)}break;case 2:if(U===96)M=e.charCodeAt(i+1)===34,M&&(p(),i+=2);else if(U===34)M=!1;else{let Q=i+1;for(;Q<t;){let q=e.charCodeAt(Q);if(q===96||q===34)break;Q++}l(5,Q)}break;case 3:M=I(U);break;case 4:if(U===34)x();else if(U===93&&e.charCodeAt(i+1)===62){let Q=u(i+2);M=e.charCodeAt(Q)===40,M&&(f(5),i=Q+1)}else M=!1;break;case 5:M=D(U);break;case 6:if(U===34)e.charCodeAt(i+1)===96?x():(l(35,i+1),f(1));else{let Q=_(u(i));M=Q>=0,M&&(p(),l(33,u(Q)))}break;case 7:{let Q=12,q=e.startsWith("DEFAULT",i)?i+7:i,Y=u(q);(q===i||Y===q)&&(Q=13,q=h(i),Y=u(q)),M=q>i&&Y>q,M&&(a=8,l(Q,Y));break}case 8:P(14);break;case 9:M=k(16,10);break;case 10:P(17);break;case 11:M=k(19,12);break;case 12:P(20);break;case 13:P(22);break;case 14:P(24);break;case 15:if(U===125)p(),i++;else{let Q=e.indexOf("}",i);l(25,Q===-1?t:Q)}break}if(!M)return n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o}}return n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o}}var to="'NODE_ID', 'COLUMNS', 'SPACE_BLOCK', 'BLOCK_DIAGRAM_KEY', 'id-block', 'classDef', 'class', 'style'";function Jh(e){let t=e[e.length-1];return Array.isArray(t)?(e.pop(),e.concat(t)):e}function em(e,t){let{types:n,texts:r,starts:o}=Zh(e),s=0,a=u=>{let m=n[s];throw m===1?it("block",e,o[s],"",!0):it("block",e,o[s],`Expecting ${u}, got '${_d[m]}'`)},i=u=>(n[s]!==u&&a(`'${_d[u]}'`),r[s++]),c=()=>{let u=i(32);if(n[s]===27){let m=r[s++],h=i(6);return{id:u,label:h,typeStr:m+i(28)}}if(n[s]===29){let m=r[s++],h=i(6),g=[i(31)];for(;n[s]===31;)g.push(r[s++]);return{id:u,label:h,typeStr:m+i(30),directions:g}}return{id:u}},l=()=>{let u=c(),m=n[s]===36?parseInt(r[s++],10):1,h={id:u.id,label:u.label,type:t.typeStr2Type(u.typeStr),directions:u.directions,widthInColumns:m},g;for(;n[s]===33||n[s]===34;){let x="";n[s++]===34&&(i(35),x=i(6),i(33));let y=r[s-1],_=c(),S=t.edgeStrToEdgeData(y),P=t.edgeStrToEdgeStartData(y),k=t.edgeStrToThickness(y),w=t.edgeStrToPattern(y);g??=[{id:h.id,label:h.label,type:h.type,directions:h.directions}],h={id:_.id,label:_.label,type:t.typeStr2Type(_.typeStr),directions:_.directions},g.push({id:g[g.length-1].id+"-"+_.id,start:g[g.length-1].id,end:_.id,label:x,type:"edge",thickness:k,pattern:w,directions:_.directions,arrowTypeEnd:S,arrowTypeStart:P},h)}return g??h};i(2);let f=[],p=[];for(;;)switch(n[s]){case 32:p.push(l());break;case 4:p.push({type:"column-setting",columns:parseInt(r[s++],10)});break;case 7:{let u=parseInt(r[s++],10);p.push({id:t.generateId(),type:"space",label:"",width:u,children:[]});break}case 2:s++,f.push({list:p,header:void 0}),p=[];break;case 3:s++,n[s]!==32&&a("'NODE_ID'"),f.push({list:p,header:l()}),p=[];break;case 26:{let u=f.pop();if(u===void 0||p.length===0)return a(to);s++;let m=t.generateId(),h=Jh(p);p=u.list,p.push(u.header===void 0?{id:m,type:"composite",label:"",children:h}:{...u.header,type:"composite",children:h});break}case 11:{s++;let u=i(13).trim();p.push({type:"classDef",id:u,css:i(14).trim()});break}case 15:{s++;let u=i(16).trim();p.push({type:"applyClass",id:u,styleClass:i(17).trim()});break}case 18:{s++;let u=i(19).trim();p.push({type:"applyStyles",id:u,stylesStr:i(20).trim()});break}case 37:f.length>0&&a(to+", 'end'"),p.length===0&&a(to),t.setHierarchy(Jh(p));return;default:a(p.length===0?to:to+(f.length>0?", 'end'":", 'EOF'"))}}var ir=1,or=2,ar=4,cr=8,xs=7,Ra=20,Yr=12;function tm(e){let t=0;if(e)for(let n of e)switch(n.trim()){case"right":t|=ir;break;case"left":t|=or;break;case"up":t|=ar;break;case"down":t|=cr;break;case"x":t|=ir|or;break;case"y":t|=ar|cr;break}return t}var Gr=(e,t)=>e&t?1:0;function no(e){return e!==0&&(e&(ar|cr))===0?"x":e!==0&&(e&(ir|or))===0?"y":""}function wd(e,t,n){let r=no(e),o=Gr(e,or)-Gr(e,ir),s=Gr(e,ar)-Gr(e,cr);if(r==="x"){let a=Math.max(n+8,14)+2*xs,i=Math.min(a/2,Ra);return{w:Math.max(t+12,16)+i*(e===(ir|or)?2:1),h:a,dx:o*i/2,dy:0}}if(r==="y"){let a=Math.max(t+16,14)+2*xs,i=Math.min(a/2,Ra);return{w:a,h:Math.max(n+8,16)+i*(e===(ar|cr)?2:1),dx:0,dy:s*i/2}}return{w:Math.max(t+16,24)+Yr*(Gr(e,or)+Gr(e,ir)),h:Math.max(n+8,24)+Yr*(Gr(e,ar)+Gr(e,cr)),dx:o*Yr/2,dy:s*Yr/2}}function nm(e,t,n,r){let o=no(e),s=t/2,a=n/2,i;if(o==="x"){let l=Math.min(a,Ra),f=a-xs,p=e&or?-s+l:-s,u=e&ir?s-l:s;i=[p,-f,u,-f],e&ir&&i.push(u,-a,s,0,u,a),i.push(u,f,p,f),e&or&&i.push(p,a,-s,0,p,-a)}else if(o==="y"){let l=Math.min(s,Ra),f=s-xs,p=e&ar?-a+l:-a,u=e&cr?a-l:a;i=[f,p,f,u],e&cr&&i.push(s,u,0,a,-s,u),i.push(-f,u,-f,p),e&ar&&i.push(-s,p,0,-a,s,p)}else{let l=e&or?-s+Yr:-s,f=e&ir?s-Yr:s,p=e&ar?-a+Yr:-a,u=e&cr?a-Yr:a,m=(l+f)/2,h=(p+u)/2,g=Math.min(10,(f-l)/2),x=Math.min(10,(u-p)/2);i=[l,p],e&ar&&i.push(m-g,p,m,-a,m+g,p),i.push(f,p),e&ir&&i.push(f,h-x,s,h,f,h+x),i.push(f,u),e&cr&&i.push(m+g,u,m,a,m-g,u),i.push(l,u),e&or&&i.push(l,h+x,-s,h,l,h-x)}let c="";for(let l=0;l<i.length;l+=2)c+=(l?" ":"")+d(i[l])+","+d(i[l+1]);return`<polygon points="${c}" stroke-linejoin="round"${r}/>`}var O_=1e3;function v_(e,t){if(e===0||!Number.isInteger(e))throw new Ge("Columns must be an integer !== 0.","semantic",{type:"block"});if(t<0||!Number.isInteger(t))throw new Ge("Position must be a non-negative integer."+t,"semantic",{type:"block"});return e<0?{px:t,py:0}:{px:t%e,py:Math.floor(t/e)}}function P_(e,t,n){let r=e.columns,o=[],s=0,a=0,i=0,c=0;for(let f of e.children){let{px:p,py:u}=v_(r,s),m=f.span>=1?Math.min(f.span,O_):1;if(r>0&&m>r-p&&(m=r-p),f.span=m,f.col=p,f.row=u,s+=m,p+m>a&&(a=p+m),u===o.length&&o.push(0),f.children.length===0?o[u]=-1:o[u]>=0&&f.nh>o[u]&&(o[u]=f.nh),f.space)continue;let h=(f.nw-t*(m-1))/m;h>i&&(i=h),f.nh>c&&(c=f.nh)}let l=(o.length-1)*t;for(let f=0;f<o.length;f++)o[f]<0&&(o[f]=c),l+=o[f];e.cols=a,e.heights=o,e.nw=Math.max(e.nw,a*i+(a-1)*t+2*n),e.nh=l+2*n+e.head}function B_(e,t,n){let{cols:r,heights:o}=e,s=o.length,a=(e.w-2*n-(r-1)*t)/r,i=e.h-2*n-e.head-(s-1)*t,c=0;for(let h of o)c+=h;let l=c>0?i/c:0,f=c>0?0:i/s,p=e.x-e.w/2+n,u=e.y-e.h/2+n+e.head,m=0;for(let h of e.children){for(;m<h.row;m++)u+=o[m]*l+f+t;h.w=a*h.span+t*(h.span-1),h.h=o[m]*l+f,h.x=p+h.col*(a+t)+h.w/2,h.y=u+h.h/2}}function rm(e,t){let n=[e];for(let r=0;r<n.length;r++)for(let o of n[r].children)n.push(o);for(let r=n.length-1;r>=0;r--){let o=n[r];o.children.length>0&&P_(o,t,r===0?0:t)}e.w=e.nw,e.h=e.nh,e.x=e.w/2,e.y=e.h/2;for(let r=0;r<n.length;r++){let o=n[r];o.children.length>0&&B_(o,t,r===0?0:t)}return{width:e.w,height:e.h}}var F_=12,sm=200,W_=8,im=' fill="var(--_s)" stroke="var(--_b)"',U_=' stroke="var(--_b)"',om=[],G_=[],Y_=[],H_=["default"],K_=2e6,z_=new Map([["square","rect"],["round","rounded"],["circle","circle"],["doublecircle","dbl-circ"],["diamond","diam"],["hexagon","hex"],["stadium","stadium"],["subroutine","fr-rect"],["cylinder","cyl"],["rect_left_inv_arrow","odd"],["lean_right","lean-r"],["lean_left","lean-l"],["trapezoid","trap-b"],["inv_trapezoid","trap-t"]]),V_=new Set(["circle","dbl-circ","diam"]),j_=new Set(["stadium","hex","odd","lean-r","lean-l","trap-b","trap-t"]);function Ta(e){return e.kind===0&&(e.shape==="circle"||e.shape==="dbl-circ")}function ii(e,t,n){let r=e.bw/2,o=e.bh/2,s=Math.abs(t-e.x),a=o;return Ta(e)?a=Math.sqrt(Math.max(r*r-s*s,0)):e.kind===0&&e.shape==="diam"?a=o*Math.max(1-s/r,0):e.kind===0?a=o-_r(e.shape,e.bw,e.bh,n>0?2:0):e.kind===1&&no(e.mask)==="x"&&(a=o-xs),e.y+n*a}function oi(e,t,n){let r=e.bw/2,o=e.bh/2,s=Math.abs(t-e.y),a=r;return Ta(e)?a=Math.sqrt(Math.max(o*o-s*s,0)):e.kind===0&&e.shape==="diam"?a=r*Math.max(1-s/o,0):e.kind===0?a=r-_r(e.shape,e.bw,e.bh,n>0?1:3):e.kind===1&&no(e.mask)==="y"&&(a=r-xs),e.x+n*a}function am(e,t,n,r){let o=t-e.x,s=n-e.y,a=e.bw/2,i=e.bh/2,c;Ta(e)?c=a/(Math.hypot(o,s)||1):e.kind===0&&e.shape==="diam"?c=1/(Math.abs(o)/a+Math.abs(s)/i||1):c=Math.min(o===0?1/0:a/Math.abs(o),s===0?1/0:i/Math.abs(s)),c===1/0&&(c=0),r.push(e.x+o*c,e.y+s*c)}function X_(e,t,n,r,o){let s=o.x-o.bw/2+1,a=o.x+o.bw/2-1,i=o.y-o.bh/2+1,c=o.y+o.bh/2-1;if(e<s&&n<s||e>a&&n>a||t<i&&r<i||t>c&&r>c)return!1;if(e===n||t===r)return!0;let l=n-e,f=r-t,p=(m,h)=>Math.sign(l*(h-t)-f*(m-e)),u=p(s,i);return u===0||p(a,i)!==u||p(a,c)!==u||p(s,c)!==u}function Rd(e,t,n,r){let o=0;for(let s of r)if(!(s===t||s===n)){for(let a=0;a+3<e.length;a+=2)if(X_(e[a],e[a+1],e[a+2],e[a+3],s)){o++;break}}return o}function q_(e,t,n,r){let o=e.x-e.bw/2,s=e.x+e.bw/2,a=e.y-e.bh/2,i=e.y+e.bh/2,c=t.x-t.bw/2,l=t.x+t.bw/2,f=t.y-t.bh/2,p=t.y+t.bh/2,u=Math.max(o,c),m=Math.min(s,l),h=Math.max(a,f),g=Math.min(i,p),x=m-u>6,y=g-h>6;if(x&&y){let q=e.bw*e.bh<=t.bw*t.bh?e:t,Y=q===e?t:e,z=q.y-q.bh/2-(Y.y-Y.bh/2),R=Y.y+Y.bh/2-(q.y+q.bh/2),L=q.x-q.bw/2-(Y.x-Y.bw/2),F=Y.x+Y.bw/2-(q.x+q.bw/2),E=Math.min(z,R,L,F),C;return E===R?C=[q.x,ii(q,q.x,1),q.x,Y.y+Y.bh/2]:E===z?C=[q.x,ii(q,q.x,-1),q.x,Y.y-Y.bh/2]:E===F?C=[oi(q,q.y,1),q.y,Y.x+Y.bw/2,q.y]:C=[oi(q,q.y,-1),q.y,Y.x-Y.bw/2,q.y],q===e?C:[C[2],C[3],C[0],C[1]]}if(x){let q=Math.min(6,(m-u)/2),Y=Math.min(Math.max((u+m)/2+n,u+q),m-q),z=t.y>e.y?1:-1;return[Y,ii(e,Y,z),Y,ii(t,Y,-z)]}if(y){let q=Math.min(6,(g-h)/2),Y=Math.min(Math.max((h+g)/2+n,h+q),g-q),z=t.x>e.x?1:-1;return[oi(e,Y,z),Y,oi(t,Y,-z),Y]}let _=t.x>e.x?1:-1,S=t.y>e.y?1:-1,P=[oi(e,e.y,_),e.y,t.x,e.y,t.x,ii(t,t.x,-S)],k=[e.x,ii(e,e.x,S),e.x,t.y,oi(t,t.y,-_),t.y],w=Math.abs(t.x-e.x)>=Math.abs(t.y-e.y),I=w?P:k;if(r===void 0)return I;let D=Rd(I,e,t,r);if(D===0)return I;let U=w?k:P,M=Rd(U,e,t,r);if(M<D&&(I=U,D=M),D===0)return I;let Q=[];return am(e,t.x,t.y,Q),am(t,e.x,e.y,Q),Rd(Q,e,t,r)<D?Q:I}function Q_(e,t,n){let r=e.length,o=e[0],s=e[1],a=e[r-2],i=e[r-1],c=e[2]-o,l=e[3]-s,f=Math.hypot(c,l);c/=f||1,l/=f||1;let p=a-e[r-4],u=i-e[r-3],m=Math.hypot(p,u);if(p/=m||1,u/=m||1,r===4&&t+n>f){let g=f/(t+n);t*=g,n*=g}t=Math.min(t,f),n=Math.min(n,m);let h=`M${d(o+c*t)},${d(s+l*t)}`;if(r===6){let g=Math.max(0,Math.min(W_,f-t,m-n));h+=`L${d(e[2]-c*g)},${d(e[3]-l*g)}Q${d(e[2])},${d(e[3])} ${d(e[2]+p*g)},${d(e[3]+u*g)}`}return h+=`L${d(a-p*n)},${d(i-u*n)}`,{d:h,sx:o,sy:s,sdx:-c,sdy:-l,ex:a,ey:i,edx:p,edy:u}}function cm(e,t){let n=e.bw/2,r=e.bh/2,o=Math.max(1,Math.min(10+5*(t-1),n,r));if(Ta(e)){let s=e.x+n*Math.SQRT1_2,a=e.y-n*Math.SQRT1_2,i=2*Math.asin(Math.min(1,o/(2*n))),c=l=>Math.atan2(e.y-n*Math.sin(l)-a,e.x+n*Math.cos(l)-s);return[s,a,o,c(Math.PI/4+i),c(Math.PI/4-i)]}if(e.kind===0&&e.shape==="diam"){let s=Math.atan2(r,n);return[e.x+n/2,e.y-r/2,o,s+Math.PI,s]}return[e.x+n,e.y-r,o,Math.PI,Math.PI/2]}function Z_(e,t,n,r){let[o,s,a,i,c]=cm(e,t),l=i+n/a,f=c-r/a,p=(f-l)%(2*Math.PI);p<=0&&(p+=2*Math.PI);let u=o+a*Math.cos(l),m=s+a*Math.sin(l),h=o+a*Math.cos(f),g=s+a*Math.sin(f),x=o+a*Math.cos(i),y=s+a*Math.sin(i),_=o+a*Math.cos(c),S=s+a*Math.sin(c),P=Math.hypot(x-u,y-m),k=Math.hypot(_-h,S-g);return{d:`M${d(u)},${d(m)}A${d(a)},${d(a)} 0 ${p>Math.PI?1:0} 1 ${d(h)},${d(g)}`,sx:x,sy:y,sdx:P>0?(x-u)/P:Math.sin(i),sdy:P>0?(y-m)/P:-Math.cos(i),ex:_,ey:S,edx:k>0?(_-h)/k:-Math.sin(c),edy:k>0?(S-g)/k:Math.cos(c)}}var J_=[.5,.3,.7,.15,.85];function ew(e,t,n,r,o,s,a){if(a===void 0)return .5;for(let i of J_){let c=e[t]+(e[t+2]-e[t])*i,l=e[t+1]+(e[t+3]-e[t+1])*i,f=!0;for(let p of a)if(p!==o&&p!==s&&Math.abs(c-p.x)<(n+p.bw)/2&&Math.abs(l-p.y)<(r+p.bh)/2){f=!1;break}if(f)return i}return .5}function lm(e,t,n){return pn(n,r=>tw(e,t,n,r))}function tw(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.875),a=n.measurer??Je(n.fontFamily),i=n.padding??8,c=n.icons,l=t.block?.padding,f=Math.min(typeof l=="number"&&l>=0?Math.min(l,200):F_,r?6:1/0),p=r?80:sm,u=O=>{let v=[],W=H=>{for(let G of H)for(let te of G.split(";"))v.push(te)};for(let H of O.classes&&O.classes.length>0?O.classes:H_){let G=e.classes.get(H);G&&W(G.styles)}return O.styles&&W(O.styles),At(v)},m=(O,v)=>{let W=O.type,H=W==="space"?At(om):u(O),G=(H.bold?1:0)|(H.italic?2:0),te=H.fontSize??o,Z=0,B="",K,ee=0,ae=0,J=0,se=0,me=0,Ae=0;if(W==="space")Z=3,K=De(void 0,!1,a,te,p);else if(W==="composite")Z=2,K=De(O.label,!1,a,te,r?Rt(n):4e3,G),J=K.height>0?K.height+4:0,ee=K.width+2*f,ae=J+2*f;else if(W==="block_arrow"){Z=1,K=De(O.label,!1,a,te,p,G);let de=!0;for(let ye of K.lines)for(let ce of ye)(ce.icon!==void 0||ce.text.trim()!=="")&&(de=!1);se=tm(O.directions);let oe=de?wd(se,0,0):wd(se,K.width,K.height);ee=oe.w,ae=oe.h,me=oe.dx,Ae=oe.dy}else{B=z_.get(W??"")??"rect",K=De(O.label,!1,a,te,p,G);let de=Br(B,K.width,K.height);ee=de.w,ae=B==="cyl"?Math.max(de.h,K.height+40):de.h,Ae=de.dy}return{children:[],columns:Z===2?O.columns??-1:-1,span:Z===3?1:O.widthInColumns??1,space:Z===3,head:J,nw:ee,nh:ae,col:0,row:0,cols:0,heights:Y_,x:0,y:0,w:0,h:0,block:O,kind:Z,index:v,shape:B,label:K,style:H,mask:se,dx:me,dy:Ae,bw:0,bh:0}},h=m(e.root,0);h.nw=0,h.nh=0;let g=[h],x=new Map;for(let O=0;O<g.length;O++){let v=g[O];if(v.kind===2)for(let W of v.block.children??G_){let H=m(W,g.length);v.children.push(H),g.push(H),H.kind!==3&&x.set(W.id,H)}}let y=rm(h,f),_=[];for(let O of g)O.kind===0&&V_.has(O.shape)?(O.bw=O.nw,O.bh=O.nh):O.kind===1?(O.bw=O.span>1?O.w:O.nw,O.bh=O.nh):(O.bw=O.w,O.bh=O.kind===0&&j_.has(O.shape)?O.nh:O.h),O.kind===0&&O.shape==="cyl"&&(O.dy=Math.min(12,Math.max(6,O.bw/14))/2),(O.kind===0||O.kind===1)&&_.push(O);let S=new Map,P=new Set,k=[],w=[];for(let O of e.edges){let v=x.get(O.start??""),W=x.get(O.end??"");if(v===void 0||W===void 0)continue;let H=Math.min(v.index,W.index)*g.length+Math.max(v.index,W.index);S.set(H,(S.get(H)??0)+1),O.label&&P.add(H),k.push([v,W]),w.push(O)}let I=w.length*_.length<=K_?_:void 0,D=new Map,U=[],M=0,Q=0,q=y.width,Y=y.height,z=(O,v,W,H)=>{O-W/2<M&&(M=O-W/2),O+W/2>q&&(q=O+W/2),v-H/2<Q&&(Q=v-H/2),v+H/2>Y&&(Y=v+H/2)};for(let O=0;O<w.length;O++){let[v,W]=k[O],H=Math.min(v.index,W.index)*g.length+Math.max(v.index,W.index),G=S.get(H)??1,te=D.get(H)??0;D.set(H,te+1);let Z=De(w[O].label,!1,a,s,sm),B,K,ee;if(v===W){let[ae,J,se]=cm(v,te+1);B=[],z(ae,J,2*se+2,2*se+2),K=ae+se+6+Z.width/2,ee=J-se/2}else{let ae=P.has(H)?Math.round(s*1.5)+2:14;B=q_(v,W,(te-(G-1)/2)*ae,I);let J=B.length,se=Math.abs(B[2]-B[0])+Math.abs(B[3]-B[1]),me=Math.abs(B[J-2]-B[J-4])+Math.abs(B[J-1]-B[J-3]),Ae=J===6&&me>se?2:0,de=Z.width>0?ew(B,Ae,Z.width+8,Z.height,v,W,I):.5;K=B[Ae]+(B[Ae+2]-B[Ae])*de,ee=B[Ae+1]+(B[Ae+3]-B[Ae+1])*de}Z.width>0&&z(K,ee,Z.width+8,Z.height),U.push({edge:w[O],points:B,loop:v===W?te+1:0,label:Z,lx:K,ly:ee})}let R=De(e.title,!1,a,o,r?Rt(n):4e3,1),L=R.height>0?R.height+12:0,F=Math.max(q-M,R.width),E=i-M+(F-(q-M))/2,C=i+L-Q;for(let O of g)O.x+=E,O.y+=C;let A=Math.ceil(F+2*i),T=Math.ceil(Y-Q+L+2*i),b="",N="";for(let O=1;O<g.length;O++){let v=g[O];if(v.kind===3)continue;let W=wt((v.block.classes??om).join(" ")),H=$e(v.block.id);if(v.kind===2){let te=v.y-v.h/2;b+=`<g class="pele-cluster${W}" data-id="${H}"><rect x="${d(v.x-v.w/2)}" y="${d(te)}" width="${d(v.w)}" height="${d(v.h)}" rx="${Xe}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${v.style.shape}/>`+Ie(v.label,v.x,te+(v.head+f)/2+2,` class="pele-cluster-label" fill="var(--_m)"${v.style.text}`,c)+"</g>";continue}let G=v.kind===1;N+=`<g class="pele-node pele-shape-${G?"block-arrow":v.shape}${W}" data-id="${H}" transform="translate(${d(v.x)},${d(v.y)})">`+(G?nm(v.mask,v.bw,v.bh,im+v.style.shape):Xn(v.shape,v.bw,v.bh,im+v.style.shape,U_+v.style.line))+Ie(v.label,v.dx,v.dy,` class="pele-label"${v.style.text}`,c)+"</g>"}let $="",X="";for(let O=0;O<U.length;O++){let{edge:v,points:W,loop:H,label:G}=U[O],te=v.arrowTypeStart??"",Z=v.arrowTypeEnd??"",B;if(H>0)B=Z_(k[O][0],H,ht(te),ht(Z));else{for(let ee=0;ee<W.length;ee+=2)W[ee]+=E,W[ee+1]+=C;B=Q_(W,ht(te),ht(Z))}let K=$e(v.id);if($+=`<g class="pele-edge" data-id="${K}"><path d="${B.d}"${v.thickness==="thick"?' stroke-width="2.5"':""}${v.pattern==="dotted"?' stroke-dasharray="3 4"':""}/>`+bt(te,B.sx,B.sy,B.sdx,B.sdy,"var(--_l)")+bt(Z,B.ex,B.ey,B.edx,B.edy,"var(--_l)")+"</g>",G.width>0){let ee=U[O].lx+E,ae=U[O].ly+C;X+=nn(v.id,G,ee,ae,"",c)}}return{svg:Ze("block",A,T,o,n,e,Ie(R,A/2,i+R.height/2,' class="pele-title" font-weight="var(--_tw)"')+(b?`<g class="pele-clusters">${b}</g>`:"")+($?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${$}</g>`:"")+`<g class="pele-nodes">${N}</g>`+(X?`<g class="pele-edge-labels" font-size="${s}">${X}</g>`:"")),width:A,height:T,links:[]}}var dm={type:"block",parse(e,t,n){let r=new wa;return r.title=n,em(e,r),r},render:lm};var nw=new Set(["label","type","descr","techn","sprite","tags","link","bgColor","fontColor","borderColor","shadowing","shape","legendText","legendSprite"]),rw=new Set(["label","descr","techn","sprite","tags","link","textColor","lineColor"]);function ro(e,t){let{key:n,value:r}=t;"from"in e&&(n==="offsetX"||n==="offsetY")?e[n]=parseInt(r):("from"in e?rw:nw).has(n)?e[n]=r:(e.extra??=new Map).set(n,r)}function Ut(e,t,n){n!==void 0&&(typeof n=="string"?e[t]=n:ro(e,n))}function ai(e,t,n){n===void 0?e[t]??="":Ut(e,t,n)}function um(e,t){e.labelAttr=void 0,typeof t=="object"?(e.label="",e.labelAttr=t,ro(e,t)):e.label=t??""}var Ca=class{type="c4";c4Type;title;accTitle;accDescr;shapes=[];boundaries=[{alias:"global",label:"global",type:"global",parent:void 0}];rels=[];shapeInRow=4;boundaryInRow=2;shapeIndex=new Map;boundaryIndex=new Map;relIndex=new Map;current=this.boundaries[0];stack=[];setC4Type(t){this.c4Type=t}setTitle(t){this.title=t}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
62
+ `)}element(t,n,r,o){let s=typeof r=="string"?n.get(r):void 0;return s===void 0&&(s={alias:"",label:"",parent:void 0},t.push(s),typeof r=="string"?(s.alias=r,n.set(r,s)):(s.aliasAttr=r,ro(s,r))),um(s,o),s}addPersonOrSystem(t,n){let r=this.element(this.shapes,this.shapeIndex,n[0],n[1]);ai(r,"descr",n[2]),this.finishShape(r,t,n,3)}addContainer(t,n){let r=this.element(this.shapes,this.shapeIndex,n[0],n[1]);ai(r,"techn",n[2]),ai(r,"descr",n[3]),this.finishShape(r,t,n,4)}addComponent(t,n){this.addContainer(t,n)}finishShape(t,n,r,o){Ut(t,"sprite",r[o]),Ut(t,"tags",r[o+1]),Ut(t,"link",r[o+2]),t.kind=n,t.parent=this.current}boundary(t,n){let r=this.element(this.boundaries,this.boundaryIndex,t[0],t[1]);return t[2]===void 0?r.type=n:Ut(r,"type",t[2]),r}open(t){t.parent=this.current,this.stack.push(this.current),this.current=t}addPersonOrSystemBoundary(t,n="system"){let r=this.boundary(t,n);Ut(r,"tags",t[3]),Ut(r,"link",t[4]),this.open(r)}addContainerBoundary(t){this.addPersonOrSystemBoundary(t,"container")}addDeploymentNode(t,n){let r=this.boundary(n,"node");ai(r,"descr",n[3]),Ut(r,"sprite",n[4]),Ut(r,"tags",n[5]),Ut(r,"link",n[6]),r.nodeType=t,this.open(r)}popBoundaryParseStack(){this.current=this.stack.pop()??this.boundaries[0]}addRel(t,n){let r=n[0],o=n[1];if(r===void 0||o===void 0||n[2]===void 0)return;let s=typeof r=="string"&&typeof o=="string",a=s?this.relIndex.get(r)?.get(o):void 0;if(a===void 0){if(a={type:t,from:"",to:"",label:""},this.rels.push(a),s){let i=this.relIndex.get(r);i===void 0&&this.relIndex.set(r,i=new Map),i.set(o,a)}typeof r=="string"?a.from=r:a.fromAttr=r,typeof o=="string"?a.to=o:a.toAttr=o}a.type=t,um(a,n[2]),ai(a,"techn",n[3]),ai(a,"descr",n[4]),Ut(a,"sprite",n[5]),Ut(a,"tags",n[6]),Ut(a,"link",n[7])}getC4Shape(t){return this.shapeIndex.get(t)??this.boundaryIndex.get(t)}updateElStyle(t,n){let r=typeof n[0]=="string"?this.getC4Shape(n[0]):void 0;r!==void 0&&(Ut(r,"bgColor",n[1]),Ut(r,"fontColor",n[2]),Ut(r,"borderColor",n[3]),Ut(r,"shadowing",n[4]),Ut(r,"shape",n[5]),Ut(r,"sprite",n[6]),Ut(r,"techn",n[7]),Ut(r,"legendText",n[8]),Ut(r,"legendSprite",n[9]))}updateRelStyle(t,n){let r=n[0],o=n[1],s=typeof r=="string"&&typeof o=="string"?this.relIndex.get(r)?.get(o):void 0;if(s===void 0)return;Ut(s,"textColor",n[2]),Ut(s,"lineColor",n[3]);let a=n[4],i=n[5];typeof a=="string"?s.offsetX=parseInt(a):a!==void 0&&ro(s,a),typeof i=="string"?s.offsetY=parseInt(i):i!==void 0&&ro(s,i)}updateLayoutConfig(t,n){let r=a=>a===void 0?NaN:parseInt(typeof a=="string"?a:a.value),o=r(n[0]),s=r(n[1]);o>=1&&(this.shapeInRow=o),s>=1&&(this.boundaryInRow=s)}};var Td=["$end","INVALID","direction_tb","direction_bt","direction_rl","direction_lr","title","accDescription","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","NEWLINE","C4_CONTEXT","C4_CONTAINER","C4_COMPONENT","C4_DYNAMIC","C4_DEPLOYMENT","PERSON","PERSON_EXT","SYSTEM","SYSTEM_DB","SYSTEM_QUEUE","SYSTEM_EXT","SYSTEM_EXT_DB","SYSTEM_EXT_QUEUE","CONTAINER","CONTAINER_DB","CONTAINER_QUEUE","CONTAINER_EXT","CONTAINER_EXT_DB","CONTAINER_EXT_QUEUE","COMPONENT","COMPONENT_DB","COMPONENT_QUEUE","COMPONENT_EXT","COMPONENT_EXT_DB","COMPONENT_EXT_QUEUE","ENTERPRISE_BOUNDARY","SYSTEM_BOUNDARY","BOUNDARY","CONTAINER_BOUNDARY","NODE","NODE_L","NODE_R","REL","BIREL","REL_U","REL_D","REL_L","REL_R","REL_B","REL_INDEX","UPDATE_EL_STYLE","UPDATE_REL_STYLE","UPDATE_LAYOUT_CONFIG","EOF_IN_STRUCT","ATTRIBUTE_EMPTY","STR","STR_KEY","STR_VALUE","LBRACE","RBRACE","EOF"];var sw=new Map([["C4Context",14],["C4Container",15],["C4Component",16],["C4Dynamic",17],["C4Deployment",18],["Person",19],["Person_Ext",20],["System",21],["SystemDb",22],["SystemQueue",23],["System_Ext",24],["SystemDb_Ext",25],["SystemQueue_Ext",26],["Container",27],["ContainerDb",28],["ContainerQueue",29],["Container_Ext",30],["ContainerDb_Ext",31],["ContainerQueue_Ext",32],["Component",33],["ComponentDb",34],["ComponentQueue",35],["Component_Ext",36],["ComponentDb_Ext",37],["ComponentQueue_Ext",38],["Enterprise_Boundary",39],["System_Boundary",40],["Boundary",41],["Container_Boundary",42],["Deployment_Node",43],["Node",43],["Node_L",44],["Node_R",45],["Rel",46],["BiRel",47],["Rel_Up",48],["Rel_U",48],["Rel_Down",49],["Rel_D",49],["Rel_Left",50],["Rel_L",50],["Rel_Right",51],["Rel_R",51],["Rel_Back",52],["RelIndex",53],["UpdateElementStyle",54],["UpdateRelStyle",55],["UpdateLayoutConfig",56]]),Cd=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],Id=/[\n\r\u2028\u2029]/g;function fm(e){let t=e.length,n=[],r=[],o=[],s=0,a=9,i=0,c=!1,l=-2,f=-1,p=0,u=(x,y,_)=>{n.push(x),r.push(y),o.push(_),i=_},m=x=>{for(;x<t&&Be(e.charCodeAt(x));)x++;return x},h=(x,y)=>{let _=e.indexOf(x,y);return _===-1?t:_},g=(x,y)=>{let _=i+x.length;if(!e.startsWith(x,i)||!Be(e.charCodeAt(_)))return!1;let S=++_;for(;_<t;){let P=e.charCodeAt(_);if(P===35||P===10||P===59)break;_++}return _===S?!1:(u(y,i,_),!0)};for(;;){if(c){u(0,t,t);break}i>=t&&(c=!0);let x=e.charCodeAt(i);if(s===0){if(i>=t){u(64,t,t);continue}if(l!==-1&&i>=p&&(l<i&&(l=e.indexOf("direction",i)),l!==-1&&(f<i&&(Id.lastIndex=i,f=Id.test(e)?Id.lastIndex-1:t),l<f))){let y=!1;for(let _=0;_<4&&!y;_++)Cd[_].lastIndex=i,Cd[_].test(e)&&(u(2+_,i,Cd[_].lastIndex),y=!0);if(y)continue;p=f}if(x===116&&g("title",6))continue;if(x===97){if(g("accDescription",7))continue;let y=e.startsWith("accTitle",i);if(y||e.startsWith("accDescr",i)){let _=m(i+8),S=e.charCodeAt(_);if(S===58){u(y?8:10,i,m(_+1)),a=y?9:11,s=7;continue}if(S===123&&!y){i=m(_+1),s=8;continue}}}if(x===37&&e.charCodeAt(i+1)===37){let y=h(`
63
+ `,i+2);for(;y<t&&(e.charCodeAt(y)===10||e.charCodeAt(y)===13);)y++;i=y;continue}if(Be(x)){let y=i,_=-1;for(;y<t;){let S=e.charCodeAt(y);if(!Be(S))break;S===10&&(_=y),y++}_!==-1?u(13,i,_+1):i=y;continue}if(x===123){u(62,i,i+1);continue}if(x===125){u(63,i,i+1);continue}if(Qe(x)){let y=i+1;for(;y<t&&Qe(e.charCodeAt(y));)y++;let _=y-i<=19?sw.get(e.slice(i,y)):void 0;if(_!==void 0){_>18&&(s=1),u(_,i,y);continue}}u(1,i,i);break}if(s===1){if(i>=t)u(57,t,t);else if(x===40){let y=i+1;for(;e.charCodeAt(y)===32;)y++;e.charCodeAt(y)===44?u(58,i,y+1):i++,s=2}else if(x===41)i++,s=0;else{u(1,i,i);break}continue}if(s===2){if(i>=t)continue;if(x===41)i++,s=0;else if(x===44)e.charCodeAt(i+1)===44?u(58,i,i+2):i++;else{let y=i;for(;e.charCodeAt(y)===32;)y++;let _=e.charCodeAt(y);_===34?e.charCodeAt(y+1)===34?u(58,i,y+2):(i=y+1,s=3):_===36?(i=y+1,s=4):u(59,i,h(",",i))}continue}if(s===3){x===34?(i++,s=2):u(59,i,h('"',i));continue}if(s===4){u(60,i,h("=",i)),s=5;continue}if(s===5){if(i>=t)continue;let y=i+1;if(x===61)for(;e.charCodeAt(y)===32;)y++;if(x!==61||e.charCodeAt(y)!==34){u(1,i,i);break}i=y+1,s=6;continue}if(s===6){if(i>=t)continue;x===34?(i++,s=2):u(61,i,h('"',i));continue}if(s===7){u(a,i,h(`
64
+ `,i)),s=0;continue}x===125?(i++,s=0):u(12,i,h("}",i))}return{types:n,starts:r,ends:o}}var Nd=["person","external_person","system","system_db","system_queue","external_system","external_system_db","external_system_queue","container","container_db","container_queue","external_container","external_container_db","external_container_queue","component","component_db","component_queue","external_component","external_component_db","external_component_queue"],iw=["rel","birel","rel_u","rel_d","rel_l","rel_r","rel_b","rel"],ow=["node","nodeL","nodeR"],aw="'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'C4_CONTEXT', 'C4_CONTAINER', 'C4_COMPONENT', 'C4_DYNAMIC', 'C4_DEPLOYMENT'",cw="'STR', 'STR_KEY', 'ATTRIBUTE', 'ATTRIBUTE_EMPTY'";function lw(e){return e===6||e===7||e===8||e===10||e===12}function pm(e){return e>=19&&e<=56}function hm(e,t){let{types:n,starts:r,ends:o}=fm(e),s=0,a=g=>e.slice(r[g],o[g]),i=g=>{let x=n[s];throw x===1?it("c4",e,r[s],"",!0):it("c4",e,r[s],`Expecting ${g}, got '${Td[x]}'`)},c=g=>{n[s]!==g&&i(`'${Td[g]}'`),s++},l=()=>{let g=[];for(;;){let x=n[s];if(x===59)g.push(a(s++).trim());else if(x===58)g.push(""),s++;else if(x===60)s++,n[s]!==61&&i("'STR_VALUE'"),g.push({key:a(s-1).trim(),value:a(s).trim()}),s++;else break}return g.length===0&&i(cw),g},f=g=>{g===6?t.setTitle(a(s++).substring(6)):g===7?t.setAccDescription(a(s++).substring(15)):g===12?t.setAccDescription(a(s++).trim()):(s++,g===8?(n[s]!==9&&i("'acc_title_value'"),t.setTitle(a(s++).trim())):(n[s]!==11&&i("'acc_descr_value'"),t.setAccDescription(a(s++).trim())))},p=g=>{s++;let x=l();if(g<=26)t.addPersonOrSystem(Nd[g-19],x);else if(g<=32)t.addContainer(Nd[g-19],x);else if(g<=38)t.addComponent(Nd[g-19],x);else{if(g<=45)return g===39?x.splice(2,0,"ENTERPRISE"):g===40?x.splice(2,0,"SYSTEM"):g===42&&x.splice(2,0,"CONTAINER"),g>=43?t.addDeploymentNode(ow[g-43],x):g===42?t.addContainerBoundary(x):t.addPersonOrSystemBoundary(x),n[s]===62?(s++,c(13)):n[s]===13?(s++,c(62),n[s]===13&&s++):i("'NEWLINE', 'LBRACE'"),!0;g<=53?(g===53&&x.splice(0,1),t.addRel(iw[g-46],x)):g===54?t.updateElStyle("update_el_style",x):g===55?t.updateRelStyle("update_rel_style",x):t.updateLayoutConfig("update_layout_config",x)}return!1},u=n[s];(u<14||u>18)&&i(aw),s++,c(13);let m=0,h=0;for(;;){let g=n[s];if(h===3||h===4){if(g===13){s++,h=2;continue}if(h===3&&pm(g)){h=1;continue}}else if(pm(g)){p(g)?(m++,h=1):h=4;continue}else if(lw(g)&&h!==1){f(g),h=3;continue}else h!==2&&i("'title', 'accDescription', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'PERSON', 'REL'");if(m>0)g!==63&&i("'NEWLINE', 'RBRACE'"),s++,t.popBoundaryParseStack(),m--,h=4;else{g!==64&&i("'NEWLINE', 'EOF'"),s++,c(0),t.setC4Type(a(0));return}}}var Md=/\s/;function Ss(e,t,n,r,o=0){let s=[];for(let l of e.split(`
65
+ `)){let f=Array.from(l);f.length===0&&s.push("");let p=0;for(;p<f.length;){let u=_=>t.width(f.slice(p,p+_).join(""),n,o)<=r,m=1;for(;m<f.length-p&&u(m);)m=Math.min(f.length-p,m*2);let h=1;for(;h<m;){let _=Math.ceil((h+m)/2);u(_)?h=_:m=_-1}let g=h,x=p+g<f.length;if(x&&!Md.test(f[p+g])){for(let _=g-1;_>0;_--)if(Md.test(f[p+_])){g=_+1;break}}let y=f.slice(p,p+g).join("");for(s.push(x&&y.trimEnd()||y),p+=g;x&&p<f.length&&Md.test(f[p]);)p++}}e===""&&(s.length=0);let a=s.map(l=>t.width(l,n,o)),i=0;for(let l of a)i=Math.max(i,l);let c=Math.round(n*1.5);return{lines:s.map((l,f)=>[{text:l,style:o,width:a[f]}]),widths:a,width:i,height:s.length*c,size:n,lineHeight:c}}function ci(e,t,n){if(e.width<=n)return e;let r=[],o=[];for(let a=0;a<e.lines.length;a++){if(e.widths[a]<=n){r.push(e.lines[a]),o.push(e.widths[a]);continue}let i=[],c=0,l=()=>{r.push(i),o.push(c),i=[],c=0};for(let f of e.lines[a]){if(f.icon!==void 0){i.length&&c+f.width>n&&l(),i.push(f),c+=f.width;continue}for(let p of Array.from(f.text)){let u=i[i.length-1],m=u&&u.icon===void 0&&u.style===f.style,g=t.width(m?u.text+p:p,e.size,f.style)-(m?u.width:0);i.length&&c+g>n&&(l(),u=void 0,g=t.width(p,e.size,f.style)),u&&u.icon===void 0&&u.style===f.style?(u.text+=p,u.width+=g):i.push({text:p,style:f.style,width:g}),c+=g}}(i.length||!e.lines[a].length)&&l()}let s=0;for(let a of o)s=Math.max(s,a);return{...e,lines:r,widths:o,width:s,height:r.length*e.lineHeight}}function wr(e,t,n,r){let o=Er(e),s="<text"+Kn(r,o),a="";for(let i=0;i<e.lines.length;i++){let c=e.lines[i],l=n+(i+.5)*e.lineHeight;if(c.some(p=>p.icon!==void 0)){let p=e.widths[i];a+=Ie({...e,lines:[c],widths:[p],width:p,height:e.lineHeight},t+p/2,l,r);continue}let f="";for(let p of c){let u=rr(p.style&~o);f+=u?`<tspan${u}>${je(p.text)}</tspan>`:je(p.text)}f!==""&&(a+=`${s} x="${d(t)}" y="${d(l+e.size*.35)}" text-anchor="start" xml:space="preserve">${f}</text>`)}return a}var li=28,ws=20,bm=7,dw=8,uw=30,kd=88,Ia=160,io=26,$d=e=>Math.min(12,Math.max(6,e/14)),Dd=e=>Math.min(12,e/4);function _s(e,t,n,r,o,s,a,i){let c=0,l=1;if(a===0){if(o<e||o>n)return 1/0}else{let f=(e-o)/a,p=(n-o)/a;c=Math.max(c,Math.min(f,p)),l=Math.min(l,Math.max(f,p))}if(i===0){if(s<t||s>r)return 1/0}else{let f=(t-s)/i,p=(r-s)/i;c=Math.max(c,Math.min(f,p)),l=Math.min(l,Math.max(f,p))}return c<=l?c:1/0}function so(e,t,n,r,o,s,a,i){let c=a/n,l=i/r,f=(o-e)/n,p=(s-t)/r,u=c*c+l*l,m=2*(c*f+l*p),h=f*f+p*p-1,g=m*m-4*u*h;if(u===0||g<0)return 1/0;let x=(-m-Math.sqrt(g))/(2*u);return x>=0&&x<=1?x:h<=0?0:1/0}function Mn(e,t,n,r,o){let{x:s,y:a,w:i,h:c}=e,l=r-t,f=o-n;if(e.form==="person")return Math.min(_s(s,a+io,s+i,a+c,t,n,l,f),so(s+i/2,a+14,13,13,t,n,l,f));if(e.form==="cyl"){let p=$d(i);return Math.min(_s(s,a+p,s+i,a+c-p,t,n,l,f),so(s+i/2,a+p,i/2,p,t,n,l,f),so(s+i/2,a+c-p,i/2,p,t,n,l,f))}if(e.form==="h-cyl"){let p=Dd(c);return Math.min(_s(s+p,a,s+i-p,a+c,t,n,l,f),so(s+p,a+c/2,p,c/2,t,n,l,f),so(s+i-p,a+c/2,p,c/2,t,n,l,f))}return _s(s,a,s+i,a+c,t,n,l,f)}function Od(e,t,n,r,o){for(let s=2;s<e.length;s+=2){let a=e[s-2],i=e[s-1];if(_s(t,n,r,o,a,i,e[s]-a,e[s+1]-i)<=1)return!0}return!1}function Na(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.w>=t.x+t.w&&e.y+e.h>=t.y+t.h}function fw(e,t,n){let r=e.x+e.w/2,o=e.y+e.h/2,s=t.x+t.w/2,a=t.y+t.h/2,i=Na(e,t);if(i||Na(t,e)){let k=i?e:t,w=i?t:e,I=w.x+w.w/2,D=w.y+w.h/2,U=w.x-k.x,M=k.x+k.w-w.x-w.w,Q=w.y-k.y,q=k.y+k.h-w.y-w.h,Y=Math.min(U,M,Q,q),z=Y===U?k.x:Y===M?k.x+k.w:I,R=Y===U||Y===M?D:Y===q?k.y+k.h:k.y,L=Math.min(Mn(w,z,R,I,D),1),F=z+(I-z)*L,E=R+(D-R)*L;return i?[z,R,F,E]:[F,E,z,R]}let c=r,l=o,f=s,p=a,u=Math.max(e.x,t.x),m=Math.min(e.x+e.w,t.x+t.w),h=Math.max(e.y,t.y),g=Math.min(e.y+e.h,t.y+t.h);u<m?c=f=(u+m)/2:h<g&&(l=p=(h+g)/2);let x=Math.hypot(f-c,p-l)||1,y=-(p-l)/x*n,_=(f-c)/x*n,S=Mn(e,f+y,p+_,c+y,l+_),P=Mn(t,c+y,l+_,f+y,p+_);return S<=1&&P<=1?(c+=y,l+=_,f+=y,p+=_):(c=r,l=o,f=s,p=a,S=Math.min(Mn(e,f,p,c,l),1),P=Math.min(Mn(t,c,l,f,p),1)),[f+(c-f)*S,p+(l-p)*S,c+(f-c)*P,l+(p-l)*P]}var Ld=6,pw=3,mm=12,Ma=class{upright=[];level=[];frames=[[],[]];taken=new Map;squeezed=0;free(t,n,r,o){let s=Math.min(r,o),a=Math.max(r,o),i=(c,l)=>{for(let f=0;f<c.length;f+=3)if(Math.abs(c[f]-n)<l&&c[f+1]<a&&c[f+2]>s)return!0;return!1};return!i(t?this.upright:this.level,Ld)&&!i(this.frames[t?0:1],pw)}crossings(t){let n=0;for(let r=2;r<t.length;r+=2){let o=t[r]===t[r-2],s=o?t[r]:t[r+1],a=Math.min(o?t[r-1]:t[r-2],o?t[r+1]:t[r]),i=Math.max(o?t[r-1]:t[r-2],o?t[r+1]:t[r]),c=o?this.level:this.upright;for(let l=0;l<c.length;l+=3)c[l]>a&&c[l]<i&&c[l+1]<s&&c[l+2]>s&&n++}return n}frame(t){this.frames[0].push(t.x,t.y,t.y+t.h,t.x+t.w,t.y,t.y+t.h),this.frames[1].push(t.y,t.x,t.x+t.w,t.y+t.h,t.x,t.x+t.w)}take(t){for(let n=2;n<t.length;n+=2)t[n]===t[n-2]?this.upright.push(t[n],Math.min(t[n-1],t[n+1]),Math.max(t[n-1],t[n+1])):t[n+1]===t[n-1]&&this.level.push(t[n+1],Math.min(t[n-2],t[n]),Math.max(t[n-2],t[n]))}ports(t,n,r,o,s){let a=this.taken.get(t)??[],i=[];for(let c=0;c<9&&i.length<4;c++){let l=r+(c&1?1:-1)*Math.ceil(c/2)*mm;if(l<o||l>s)continue;let f=!0;for(let p=0;p<a.length;p+=2)a[p]===n&&Math.abs(a[p+1]-l)<mm&&(f=!1);f&&i.push(l)}return i.length?i:[r]}claim(t,n,r){let o=this.taken.get(t);o?o.push(n,r):this.taken.set(t,[n,r])}};function hw(e,t,n){let r=e.length,o=Math.sign(e[2]-e[0]),s=Math.sign(e[3]-e[1]),a=`M${d(e[0]+o*t)},${d(e[1]+s*t)}`;for(let l=2;l<r-2;l+=2){let f=e[l],p=e[l+1],u=Math.sign(f-e[l-2]),m=Math.sign(p-e[l-1]),h=Math.sign(e[l+2]-f),g=Math.sign(e[l+3]-p),x=Math.min(dw,Math.abs(f-e[l-2]+p-e[l-1])/2,Math.abs(e[l+2]-f+e[l+3]-p)/2);a+=`${u?"H"+d(f-u*x):"V"+d(p-m*x)}Q${d(f)},${d(p)} ${d(f+h*x)},${d(p+g*x)}`}let i=Math.sign(e[r-2]-e[r-4]),c=Math.sign(e[r-1]-e[r-3]);return a+(i?"H"+d(e[r-2]-i*n):"V"+d(e[r-1]-c*n))}function ym(e,t,n,r){for(let o of t)if(o!==n&&o!==r&&Od(e,o.x,o.y,o.x+o.w,o.y+o.h))return!1;return!0}function Em(e,t,n,r,o){let s=e.length;return{d:hw(e,n,r),sx:e[0],sy:e[1],sdx:-Math.sign(e[2]-e[0]),sdy:-Math.sign(e[3]-e[1]),ex:e[s-2],ey:e[s-1],edx:Math.sign(e[s-2]-e[s-4]),edy:Math.sign(e[s-1]-e[s-3]),x0:e[t],y0:e[t+1],x1:e[t+2],y1:e[t+3],nx:0,ny:0,lean:0,room:Ia,...o,points:e}}function gm(e,t){let n=[],r=(e+t)/2,o=Math.max(bm,(t-e)/4);for(let s=0;s<9;s++){let a=r+(s&1?1:-1)*Math.ceil(s/2)*o;a>=e+Ld&&a<=t-Ld&&n.push(a)}return n}function mw(e,t,n,r,o,s){let a=e.x+e.w/2,i=e.y+e.h/2,c=t.x+t.w/2,l=t.y+t.h/2,f,p=(g,x,y)=>{if(!ym(g,n,e,t))return;for(let S=2;S<g.length;S+=2){let P=g[S]===g[S-2];if(!r.free(P,P?g[S]:g[S+1],P?g[S-1]:g[S-2],P?g[S+1]:g[S]))return}let _=r.crossings(g)*1e6;for(let S=2;S<g.length;S+=2)_+=Math.abs(g[S]-g[S-2])+Math.abs(g[S+1]-g[S-1]);(!f||_<f.cost)&&(f={points:g,cost:_,upright:x,sides:y})};if(e.x+e.w<=t.x||t.x+t.w<=e.x){let g=c>a,x=Math.sign(l-i),y=g?[1,0]:[0,1],_=gm(g?e.x+e.w:t.x+t.w,g?t.x:e.x);e:for(let S of r.ports(e,y[0],i+x*e.h/4,e.y+8,e.y+e.h-8))for(let P of r.ports(t,y[1],l-x*t.h/4,t.y+8,t.y+t.h-8))for(let k of _){let w=k+(a-k)*Math.min(Mn(e,k,S,a,S),1),I=k+(c-k)*Math.min(Mn(t,k,P,c,P),1),D=f;if(p([w,S,k,S,k,P,I,P],!0,y),f!==D)break e}}if(e.y+e.h<=t.y||t.y+t.h<=e.y){let g=l>i,x=Math.sign(c-a),y=g?[3,2]:[2,3],_=gm(g?e.y+e.h:t.y+t.h,g?t.y:e.y);e:for(let S of r.ports(e,y[0],a+x*e.w/4,e.x+8,e.x+e.w-8))for(let P of r.ports(t,y[1],c-x*t.w/4,t.x+8,t.x+t.w-8))for(let k of _){let w=k+(i-k)*Math.min(Mn(e,S,k,S,i),1),I=k+(l-k)*Math.min(Mn(t,P,k,P,l),1),D=f;if(p([S,w,S,k,P,k,P,I],!1,y),f!==D)break e}}if(!f)return;let{points:u,upright:m,sides:h}=f;return r.take(u),r.claim(e,h[0],m?u[1]:u[0]),r.claim(t,h[1],m?u[7]:u[6]),Em(u,2,o,s,{room:m?kd:Ia})}function Am(e,t,n,r,o,s,a){if(e===t){let x=Math.min(e.h/2-4,10),y=Math.hypot(li,x),_=e.x+e.w,S=e.y+e.h/2,P=li/y,k=x/y;return{d:`M${d(_+P*s)},${d(S-x-k*s)}C${d(_+li)},${d(S-x*2)} ${d(_+li)},${d(S+x*2)} ${d(_+P*a)},${d(S+x+k*a)}`,sx:_,sy:S-x,sdx:-P,sdy:k,ex:_,ey:S+x,edx:-P,edy:-k,x0:_+li+4,y0:S,x1:_+li+4,y1:S,nx:1,ny:0,lean:0,room:64,points:[]}}let[i,c,l,f]=fw(e,t,n),p=i===l,u=!1;if(r&&!Na(e,t)&&!Na(t,e))for(let x of r)x!==e&&x!==t&&_s(x.x,x.y,x.x+x.w,x.y+x.h,i,c,l-i,f-c)<=1&&(u=!0);if(r&&u&&!p&&c!==f){let x=mw(e,t,r,o,s,a);if(x)return x;o.squeezed++}if(r&&u&&(p||c===f)){let x=N=>{let $=N?-1/0:1/0,X=V=>{let O=p?V.x:V.y;$=N?Math.max($,O+(p?V.w:V.h)):Math.min($,O)};X(e),X(t);for(let V of r)V!==e&&V!==t&&_s(V.x,V.y,V.x+V.w,V.y+V.h,i,c,l-i,f-c)<=1&&X(V);return $},y=p?Math.min(e.y,t.y):Math.min(e.x,t.x),_=p?Math.max(e.y+e.h,t.y+t.h):Math.max(e.x+e.w,t.x+t.w),S=(N,$)=>{for(let X of r){if(X===e||X===t)continue;let V=p?X.y<_&&X.y+X.h>y:X.x<_&&X.x+X.w>y,O=p?X.x:X.y,v=O+(p?X.w:X.h);if(V&&(N?v>$:O<$))return!1}return!0},P=e.x+e.w/2,k=e.y+e.h/2,w=t.x+t.w/2,I=t.y+t.h/2,D=Math.sign(p?I-k:w-P),U=N=>{let $=x(N),X=N?1:-1,V=p?N?1:0:N?3:2,O=p?o.ports(e,V,k+D*e.h/4,e.y+8,e.y+e.h-8)[0]:o.ports(e,V,P+D*e.w/4,e.x+8,e.x+e.w-8)[0],v=p?o.ports(t,V,I-D*t.h/4,t.y+8,t.y+t.h-8)[0]:o.ports(t,V,w-D*t.w/4,t.x+8,t.x+t.w-8)[0],W=G=>{if(p){let B=G+(P-G)*Math.min(Mn(e,G,O,P,O),1),K=G+(w-G)*Math.min(Mn(t,G,v,w,v),1);return[B,O,G,O,G,v,K,v]}let te=G+(k-G)*Math.min(Mn(e,O,G,O,k),1),Z=G+(I-G)*Math.min(Mn(t,v,G,v,I),1);return[O,te,O,G,v,G,v,Z]},H=W($+X*ws);for(let G=0;G<=4;G++){let te=$+X*(ws+G*bm),Z=W(te);if(ym(Z,r,e,t)&&(H=Z,o.free(p,te,O,v)))return{points:H,side:V,p0:O,p1:v,step:G}}return{points:H,side:V,p0:O,p1:v,step:5}},M=p?f>c:l<i,Q=S(M,x(M)),q=S(!M,x(!M)),Y=U(M),z=Q===q?U(!M):void 0,R=N=>o.crossings(N.points)*8+N.step,L=q&&!Q||z&&R(z)<R(Y)?!M:M,{points:F,side:E,p0:C,p1:A,step:T}=L===M?Y:z??U(!M),b=L?1:-1;return T>4&&o.squeezed++,o.take(F),o.claim(e,E,C),o.claim(t,E,A),Em(F,2,s,a,p?{nx:b,lean:uw,room:kd}:{room:Ia})}let m=Math.hypot(l-i,f-c)||1,h=(l-i)/m,g=(f-c)/m;return(p||c===f)&&o.take([i,c,l,f]),{d:`M${d(i+h*s)},${d(c+g*s)}L${d(l-h*a)},${d(f-g*a)}`,sx:i,sy:c,sdx:-h,sdy:-g,ex:l,ey:f,edx:h,edy:g,x0:i,y0:c,x1:l,y1:f,nx:n?-g:0,ny:n?h:0,lean:0,room:Math.abs(h)>Math.abs(g)?kd:Ia,points:[i,c,l,f]}}var Pd=216,gw=64,xm=14,bw=12,yw=100,Ew=88,Sm=ws+8,ka=48,di=16,La=10,vd=new Map([["person","person"],["box","rect"],["rounded","rect"],["component","rect"],["cylinder","cyl"],["database","cyl"],["db","cyl"],["queue","h-cyl"],["pipe","h-cyl"]]);function Aw(e){let t=vd.get((e.shape??"").toLowerCase())??vd.get((e.sprite??"").toLowerCase());if(t)return t;if(e.tags)for(let r of e.tags.split(",")){let o=vd.get(r.trim().toLowerCase());if(o)return o}let n=e.kind;return n.endsWith("person")?"person":n.endsWith("_db")?"cyl":n.endsWith("_queue")?"h-cyl":"rect"}function xw(e,t,n,r,o=Pd){let s=Aw(e),a=s==="h-cyl"?36:0,i=s==="person"?io:s==="cyl"?24:0,c=o-2*xm-a,l=[De("«"+e.kind.replace(/_/g," ")+"»",!1,t,r-1,c),De(e.label,!1,t,n,c,1),De(e.techn?`[${e.techn}]`:void 0,!1,t,r,c),De(e.descr,!1,t,r,c)],f=0,p=l[3].height>0?4:0;for(let u of l)f=Math.max(f,u.width),p+=u.height;return{shape:e,form:s,labels:l,textH:p,x:0,y:0,w:Math.max(o,f+2*xm+a),h:Math.max(gw,p+2*bw+i)}}function _m(e,t,n,r,o){let s=0,a=0;for(let i=0;i<e.length;i+=t){let c=Math.min(e.length,i+t),l=0,f=0;for(let p=i;p<c;p++)f=Math.max(f,e[p].h);for(let p=i;p<c;p++){let u=e[p];u.x=l,u.y=a,o&&(u.h=f),l+=u.w+n}s=Math.max(s,l-n),a+=f+r}return[s,e.length>0?a-r:0]}function wm(e,t,n,r,o,s){let a=o===void 0?Sm:12,i=new Map;for(let g of e.boundaries){let x=o===void 0?4e3:Math.max(80,o-2*di-2*Sm*2),y=g.parent?[De(g.label,!1,t,n,x,1),De(g.type?`[${g.type}]`:void 0,!1,t,r,x),De(g.descr,!1,t,r,x)]:[],_=0,S=0;for(let P of y)_+=P.height,S=Math.max(S,P.width);i.set(g,{boundary:g,kids:[],nodes:[],labels:y,head:_>0?_+La+6+ws:a,headW:S,headX:di,x:0,y:0,w:0,h:0,form:"rect"})}let c=i.get(e.boundaries[0]);for(let g of i.values()){let x=g.boundary.parent;x&&i.get(x)?.kids.push(g)}let l=[c],f=new Map([[c.boundary,0]]);for(let g=0;g<l.length;g++)for(let x of l[g].kids)f.set(x.boundary,f.get(l[g].boundary)+1),l.push(x);for(let g of e.shapes)if(g.parent){let x=f.get(g.parent)??0,y=o===void 0?Pd:Math.max(100,Math.min(Pd,o-2*x*a-32));i.get(g.parent)?.nodes.push(xw(g,t,n,r,y))}let p=Math.max(1,e.shapeInRow),u=Math.max(1,e.boundaryInRow),m=new Map;for(let g=l.length-1;g>=0;g--){let x=l[g],y=o===void 0?yw:s,_=(U,M,Q)=>{if(o===void 0)return M;let q=1;for(let Y of U)q=Math.max(q,Y.w);return Math.max(1,Math.min(M,Math.floor((o+Q-2*a)/(q+Q))))},[S,P]=_m(x.nodes,_(x.nodes,p,y),y,Ew,!0),[k,w]=_m(x.kids,_(x.kids,u,ka),ka,ka,!1),I=P>0&&w>0?ka:0,D=x===c?0:a;m.set(x,P+I),x.w=Math.max(S,k,x.headW+2*di-2*D)+2*D,x.h=(D&&x.head)+P+I+w+D}let h=new Map;for(let g of l){let x=g.x+(g===c?0:a),y=g.y+(g===c?0:g.head);for(let _ of g.nodes)_.x+=x,_.y+=y,h.set(_.shape,_);for(let _ of g.kids)_.x+=x,_.y+=y+m.get(g);g!==c&&h.set(g.boundary,g)}return{order:l,boxes:h}}var Sw=7,Oa=36,Bd=24,Rm=2e3,$a=8,_w=[.5,.4,.6,.3,.7,.2,.8],ww=2e6;function Da(e,t,n){let r=[];return e&&r.push("fill:"+e),t&&r.push("stroke:"+t),n&&r.push("color:"+n),At(r)}function Fd(e,t,n,r,o){return t?Pn(e,zn(t.includes("¶ß")?t.replace(/\ufb02\u00b0\u00b0?/g,"#").replace(/\u00b6\u00df/g,";"):t),n,r,o):e}function Tm(e,t,n){return pn(n,r=>{if(!r)return Wd(e,t,n,!1)[0];let[o,s]=Wd(e,t,n,!0,Oa);for(let a=Oa+Bd;s>0&&a<=Oa+3*Bd;a+=Bd){let[i,c]=Wd(e,t,n,!0,a);c<s&&([o,s]=[i,c])}return o})}function Wd(e,t,n,r,o=Oa){let s=n.fontSize??16,a=Math.round(s*.8125),i=n.measurer??Je(n.fontFamily),c=n.padding??8,l=[],{order:f,boxes:p}=wm(e,i,s,a,r?Math.max(80,(n.maxWidth??320)-2*c):void 0,o),u=f[0],m=0,h=0,g=u.w,x=u.h,y=($,X,V,O)=>{m=Math.min(m,$),h=Math.min(h,X),g=Math.max(g,V),x=Math.max(x,O)},_=[],S=new Map;for(let $ of e.rels){let X=$.fromAttr?void 0:e.getC4Shape($.from),V=$.toAttr?void 0:e.getC4Shape($.to),O=X&&p.get(X),v=V&&p.get(V);if(!O||!v)throw new Ge(`C4 rel "${$.from}" -> "${$.to}" references an unknown shape or boundary`,"semantic",{type:"c4"});_.push(O,v);let W=S.get(O);W||S.set(O,W=new Set),W.add(v)}let P=[],k=[];for(let $ of f)for(let X of $.nodes)P.push(X),k.push(X.x+$a,X.y+$a,X.x+X.w-$a,X.y+X.h-$a);let w=e.rels.length*(P.length+f.length+3*e.rels.length)<=ww,I=($,X,V,O)=>{let v=0;for(let W=0;W<k.length;W+=4){let H=Math.min(V,k[W+2])-Math.max($,k[W]);if(H<=0)continue;let G=Math.min(O,k[W+3])-Math.max(X,k[W+1]);G>0&&(v+=H*G)}return v},D=$=>$?Math.max(-Rm,Math.min(Rm,$)):0,U="",M=ht("arrow_point"),Q=new Ma;for(let $ of f)$!==u&&Q.frame($);let q=e.rels.map(($,X)=>{let V=_[X*2],O=_[X*2+1],v=Da(void 0,$.lineColor,void 0),W=v.stroke?je(v.stroke):"var(--_l)",H=$.type==="birel"||$.type==="rel_b",G=$.type!=="rel_b",te=V!==O&&S.get(O)?.has(V)===!0,Z=Am(V,O,te?Sw:0,w?P:void 0,Q,H?M:0,G?M:0);return y(Math.min(Z.x0,Z.x1),Math.min(Z.y0,Z.y1),Math.max(Z.x0,Z.x1),Math.max(Z.y0,Z.y1)),H&&w&&k.push(Z.sx-kt,Z.sy-kt,Z.sx+kt,Z.sy+kt),G&&w&&k.push(Z.ex-kt,Z.ey-kt,Z.ex+kt,Z.ey+kt),U+=`<g class="pele-edge" data-id="${$e($.from+"-"+$.to)}"${v.line}><path d="${Z.d}"/>`+(H?bt("arrow_point",Z.sx,Z.sy,Z.sdx,Z.sdy,W):"")+(G?bt("arrow_point",Z.ex,Z.ey,Z.edx,Z.edy,W):"")+"</g>",Z});for(let $ of f){if(!w||$.headW===0)continue;let X=$.y+La,V=$.y+$.head-ws,O=1/0;for(let v of[di,($.w-$.headW)/2,$.w-di-$.headW]){let W=0;for(let H of q)Od(H.points,$.x+v-4,X,$.x+v+$.headW+4,V)&&W++;if(W<O&&(O=W,$.headX=v),W===0)break}k.push($.x+$.headX-4,X,$.x+$.headX+$.headW+4,V)}let Y="";e.rels.forEach(($,X)=>{let V=q[X],O=$.from+"-"+$.to,v=Da(void 0,void 0,$.textColor),W=(e.c4Type==="C4Dynamic"?X+1+": ":"")+$.label,H=De(W,!1,i,a,V.room),G=De($.techn?`[${$.techn}]`:void 0,!1,i,a,V.room,2),te=Math.max(H.width,G.width)+8,Z=H.height+G.height;if(Z===0)return;let B=Math.abs(V.nx)*(te/2)+Math.abs(V.ny)*(Z/2)+2,K=V.lean?Math.max(0,Math.min(V.lean,B-14)):B,ee=V.nx*K+(r?0:D($.offsetX)),ae=V.ny*K+(r?0:D($.offsetY)),J=.5;if(w){let Ae=1/0,de=ee!==V.nx*K||ae!==V.ny*K;for(let oe=0;oe<(de?2:1)&&Ae>0;oe++){let ye=oe?V.nx*K:ee,ce=oe?V.ny*K:ae;for(let fe of _w){let xe=V.x0+(V.x1-V.x0)*fe+ye,be=V.y0+(V.y1-V.y0)*fe+ce,re=I(xe-te/2,be-Z/2,xe+te/2,be+Z/2);if(re<Ae&&(Ae=re,J=fe,ee=ye,ae=ce),re===0)break}}}let se=V.x0+(V.x1-V.x0)*J+ee,me=V.y0+(V.y1-V.y0)*J+ae-Z/2;w&&k.push(se-te/2,me,se+te/2,me+Z),y(se-te/2,me,se+te/2,me+Z),Y+=`<g class="pele-edge-label" data-id="${$e(O)}">`+($.descr?`<title>${$e($.descr)}</title>`:"")+`<rect x="${d(se-te/2)}" y="${d(me)}" width="${d(te)}" height="${d(Z)}" rx="3" fill="var(--_bg)"/>`+Fd(Ie(H,se,me+H.height/2,v.text)+Ie(G,se,me+H.height+G.height/2,` class="pele-c4-techn" fill="var(--_m)"${v.text}`),$.link,O,l,n)+"</g>"});let z="",R="";for(let $ of f){if($!==u){let X=$.boundary,V=Da(X.bgColor,X.borderColor,X.fontColor),O=$.x+$.headX,v=$.y+La,W=wr($.labels[0],O,v,` class="pele-cluster-label" font-weight="var(--_hw)"${V.text}`);v+=$.labels[0].height,W+=wr($.labels[1],O,v,` class="pele-c4-type" font-size="${a}" fill="var(--_m)"${V.text}`),v+=$.labels[1].height,W+=wr($.labels[2],O,v,` class="pele-c4-descr" font-size="${a}" fill="var(--_m)"${V.text}`),z+=`<g class="pele-cluster pele-c4-${X.nodeType?"node":"boundary"}" data-id="${$e(X.alias)}"><rect x="${d($.x)}" y="${d($.y)}" width="${d($.w)}" height="${d($.h)}" rx="${Xe}" fill="none" stroke="var(--_b)"${X.nodeType?"":' stroke-dasharray="6 4"'}${V.shape}/>`+Fd(W,X.link,X.alias,l,n)+"</g>"}for(let X of $.nodes){let V=X.shape,O=V.kind.startsWith("external"),v=Da(V.bgColor,V.borderColor,V.fontColor),W=' stroke="var(--_b)"'+(O?' stroke-dasharray="4 3"':""),{w:H,h:G,form:te,labels:Z}=X,B=te==="h-cyl"?-Dd(G)/2:0,K=te==="person"?io/2:te==="cyl"?$d(H)/2:0,ee=` fill="var(--_m)"${v.text}`,ae=K-X.textH/2,J=Ie(Z[0],B,ae+Z[0].height/2,` class="pele-c4-type" font-size="${a-1}"${ee}`);ae+=Z[0].height,J+=Ie(Z[1],B,ae+Z[1].height/2,` class="pele-label" font-weight="var(--_hw)"${v.text}`),ae+=Z[1].height,J+=Ie(Z[2],B,ae+Z[2].height/2,` class="pele-c4-techn" font-size="${a}"${ee}`),ae+=Z[2].height+4,J+=Ie(Z[3],B,ae+Z[3].height/2,` class="pele-c4-descr" font-size="${a}"${v.text}`),R+=`<g class="pele-node pele-shape-${te} pele-c4-${V.kind}${O?" pele-c4-external":""}" data-id="${$e(V.alias)}" transform="translate(${d(X.x+H/2)},${d(X.y+G/2)})">`+Fd(Xn(te,H,G,` fill="var(${O?"--_bg":"--_s"})"${W}${v.shape}`,W+v.line)+J,V.link,V.alias,l,n)+"</g>"}}let L=De(e.title,!1,i,s,r?Rt(n):4e3,1),F=L.height>0?L.height+12:0,E=Math.max(g-m,L.width),C=Math.ceil(E+2*c),A=Math.ceil(x-h+F+2*c),T=c-m+(E-(g-m))/2,b=c+F-h;return[{svg:Ze("c4",C,A,s,n,e,Ie(L,C/2,c+L.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(T)},${d(b)})">`+(z?`<g class="pele-clusters">${z}</g>`:"")+(U?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${U}</g>`:"")+(R?`<g class="pele-nodes">${R}</g>`:"")+(Y?`<g class="pele-edge-labels" font-size="${a}">${Y}</g>`:"")+"</g>"),width:C,height:A,links:l},Q.squeezed]}var Cm={type:"c4",parse(e,t,n){let r=new Ca;return n&&(r.title=n),hm(e,r),r},render:Tm};function Ud(e){let t=0;for(let n=e.indexOf("~");n!==-1;n=e.indexOf("~",n+1))t++;return t}function Rw(e){let t=Ud(e);if(t<=1)return e;let n=t%2!==0&&e.startsWith("~"),r=e.split(""),o=[];for(let s=n?1:0;s<r.length;s++)r[s]==="~"&&o.push(s);for(let s=0,a=o.length-1;s<a;s++,a--)r[o[s]]="<",r[o[a]]=">";return r.join("")}function Hr(e){if(!e.includes("~"))return e;let t=e.split(/(,)/),n=[];for(let r=0;r<t.length;r++){let o=t[r];o===","&&r>0&&r+1<t.length&&Ud(t[r-1])===1&&Ud(t[r+1])===1&&(o=t[r-1]+","+t[r+1],r++,n.pop()),n.push(Rw(o))}return n.join("")}function Im(e){return e==="#"||e==="+"||e==="~"||e==="-"}var oo=class{id="";memberType;visibility="";classifier="";parameters="";returnType="";constructor(t,n){this.memberType=n,(n!=="method"||!this.parseMethod(t))&&this.parseAttribute(t),this.id=this.id.startsWith(" ")?" "+this.id.trim():this.id.trim()}parseMethod(t){let n=t.length;for(let r=0;r<n;){let o=r;for(;o<n&&!ps(t.charCodeAt(o));)o++;let s=o-1;for(;s>r&&t.charCodeAt(s)!==41;)s--;let a=s-1;for(;a>r&&t.charCodeAt(a)!==40;)a--;if(a>r){let i=t[r],c=Im(i)&&a>r+1;c&&(this.visibility=i),this.id=t.slice(c?r+1:r,a),this.parameters=t.slice(a+1,s).trim();let l=s+1,f="";if(l<n){let u=t[l];(u==="$"||u==="*"||u.trim()==="")&&(f=u.trim(),l++)}let p=l;for(;p<n&&!ps(t.charCodeAt(p));)p++;if(this.returnType=t.slice(l,p).trim(),f===""){let u=this.returnType.slice(-1);(u==="$"||u==="*")&&(f=u,this.returnType=this.returnType.slice(0,-1))}return this.classifier=f,!0}r=o+1}return this.memberType="attribute",!1}parseAttribute(t){let n=t.slice(0,1),r=t.slice(-1);Im(n)&&(this.visibility=n),(r==="$"||r==="*")&&(this.classifier=r),this.id=t.substring(this.visibility===""?0:1,this.classifier===""?t.length:t.length-1)}getDisplayDetails(){let t=this.visibility+Hr(this.id);return this.memberType==="method"&&(t+=`(${Hr(this.parameters.trim())})`,this.returnType&&(t+=" : "+Hr(this.returnType))),{displayText:t.trim(),cssStyle:this.parseClassifier()}}parseClassifier(){return this.classifier==="*"?"font-style:italic;":this.classifier==="$"?"text-decoration:underline;":""}};var Tw={LINE:0,DOTTED_LINE:1},ui={AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3,LOLLIPOP:4},Cw="classId-";function Kr(e){let t=e.indexOf("~");if(t<=0)return{className:e,type:""};let n=e.indexOf("~",t+1);return{className:e.slice(0,t),type:e.slice(t+1,n===-1?e.length:n)}}function Nm(e){let t=e.charCodeAt(0);return Kr(t>=48&&t<=57?Cw+e:e).className}var va=class{type="class";lineType=Tw;relationType=ui;direction="TB";classes=new Map;relations=[];notes=new Map;namespaces=new Map;interfaces=[];styleClasses=new Map;title;accTitle;accDescr;namespaceStack=[];withCssClass=new Map;addClass(t){let{className:n,type:r}=Kr(t);if(this.classes.has(n))return;let o={id:n,type:r,label:n,cssClasses:"default",methods:[],members:[],annotations:[],styles:[]};this.classes.set(n,o),this.tag(o,"default")}tag(t,n){let r=this.withCssClass.get(n);r?r.add(t):this.withCssClass.set(n,new Set([t]))}ensure(t){return this.addClass(t),this.classes.get(Kr(t).className)}setClassLabel(t,n){this.ensure(t).label=n}addRelation(t){let{type1:n,type2:r}=t.relation;n===ui.LOLLIPOP&&r==="none"?(this.addClass(t.id2),t.id1=this.addInterface(t.id1,t.id2)):r===ui.LOLLIPOP&&n==="none"?(this.addClass(t.id1),t.id2=this.addInterface(t.id2,t.id1)):(this.addClass(t.id1),this.addClass(t.id2)),t.id1=Kr(t.id1).className,t.id2=Kr(t.id2).className,t.relationTitle1=t.relationTitle1.trim(),t.relationTitle2=t.relationTitle2.trim(),this.relations.push(t)}addInterface(t,n){let r=`interface${this.interfaces.length}`;return this.interfaces.push({id:r,label:t,classId:n}),r}addAnnotation(t,n){this.ensure(t).annotations.push(n)}addMember(t,n){let r=this.ensure(t);if(typeof n!="string")return;let o=n.trim();if(o.startsWith("<<")&&o.endsWith(">>"))r.annotations.push(o.substring(2,o.length-2));else if(o.indexOf(")")>0){let s=new oo(o,"method");(s.memberType==="method"?r.methods:r.members).push(s)}else o&&r.members.push(new oo(o,"attribute"))}addMembers(t,n){if(Array.isArray(n)){n.reverse();for(let r of n)this.addMember(t,r)}}addNote(t,n){let r=this.notes.size,o=`note${r}`;return this.notes.set(o,{id:o,class:n,text:t,index:r}),o}cleanupLabel(t){return(t.startsWith(":")?t.substring(1):t).trim()}setCssClass(t,n){for(let r of t.split(",")){let o=this.classes.get(Nm(r));if(o!==void 0){o.cssClasses+=" "+n;for(let s of n.split(" "))this.tag(o,s)}}}defineClass(t,n){for(let r of t){let o=this.styleClasses.get(r);if(o===void 0&&(o={id:r,styles:[],textStyles:[]},this.styleClasses.set(r,o)),!n)continue;for(let i of n)i.includes("color")&&o.textStyles.push(i.replace("fill","bgFill")),o.styles.push(i);let s=this.withCssClass.get(r);if(s===void 0)continue;let a=n.flatMap(i=>i.split(","));for(let i of s)for(let c of a)i.styles.push(c)}}setTooltip(t,n){if(n!==void 0)for(let r of t.split(",")){let o=this.classes.get(Kr(r).className);o&&(o.tooltip=n)}}setLink(t,n,r){let o=gt(n).trim();for(let s of t.split(",")){let a=this.classes.get(Nm(s));a&&(a.link=o?zn(o):void 0,a.linkTarget=typeof r=="string"?r:"_blank")}this.setCssClass(t,"clickable")}setClickEvent(t,n,r){for(let o of t.split(",")){let s=this.classes.get(Kr(o).className);s&&(s.haveCallback=!0)}this.setCssClass(t,"clickable")}setDirection(t){this.direction=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
66
+ `)}addNamespace(t,n){let r=this.namespaceStack[this.namespaceStack.length-1],o=r?`${r}.${t}`:t;this.namespaceStack.push(o);let s=this.namespaces.get(o);if(s)return s.explicit=!0,n&&(s.label=n),o;let a=r||void 0,i=r?r.length+1:0;for(;;){let c=o.indexOf(".",i),l=c===-1,f=l?o:o.slice(0,c),p=this.namespaces.get(f);if(p===void 0){let m=o.slice(i,l?o.length:c);p={id:f,label:l&&n?n:m,classes:new Map,notes:new Map,children:new Map,parent:a,explicit:l},this.namespaces.set(f,p)}else l&&(p.explicit=!0);let u=a?this.namespaces.get(a):void 0;if(u&&(u.children.has(f)||u.children.set(f,p),p.parent??=a),l)return o;a=f,i=c+1}}popNamespace(){this.namespaceStack.pop()}addClassesToNamespace(t,n,r){let o=this.namespaces.get(t);if(o!==void 0){for(let s of n){let{className:a}=Kr(s),i=this.classes.get(a);i!==void 0&&(i.parent=t,o.classes.set(a,i))}for(let s of r){let a=this.notes.get(s);a!==void 0&&(a.parent=t,o.notes.set(s,a))}}}setCssStyle(t,n){let r=this.classes.get(t);if(!(!n||!r))for(let o of n)for(let s of o.split(","))r.styles.push(s)}};var Gd=["$end","INVALID","CLASS_DIAGRAM","NEWLINE","EOF","SQS","STR","SQE","DOT","GENERICTYPE","LABEL","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","STRUCT_START","STRUCT_STOP","NAMESPACE","STYLE_SEPARATOR","ANNOTATION_START","ANNOTATION_END","CLASS","MEMBER","NOTE_FOR","NOTE","CLASSDEF","ALPHA","COMMA","direction_tb","direction_bt","direction_rl","direction_lr","AGGREGATION","EXTENSION","COMPOSITION","DEPENDENCY","LOLLIPOP","LINE","DOTTED_LINE","CALLBACK","LINK","LINK_TARGET","CLICK","CALLBACK_NAME","CALLBACK_ARGS","HREF","STYLE","CSSCLASS","COLON","BRKT","PCT","MINUS","UNICODE_TEXT","BQUOTE_STR","EDGE_STATE","EOF_IN_STRUCT","OPEN_IN_STRUCT","PLUS","EQUALS","PUNCTUATION"];var Iw=[4,6,4,9,44,45,12,14,15,4,56,4,56],Nw=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],Yd=/[\n\r\u2028\u2029]/g;function Mm(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=e.indexOf("direction"),l=-1,f=0,p=(w,I,D)=>(n.push(w),r.push(e.slice(I,D)),o.push(I),i=D,!0),u=w=>{s.push(a),a=w},m=()=>{s.length>0&&(a=s.pop())},h=w=>e.startsWith(w,i)&&!Qe(e.charCodeAt(i+w.length)),g=w=>{for(;w<t&&Be(e.charCodeAt(w));)w++;return w},x=w=>{let I=e.indexOf(w,i);return I===-1?t:I},y=w=>{let I=i,D=-1;for(let U=e.charCodeAt(I);I<t&&Be(U);U=e.charCodeAt(++I))U===10&&(D=I);if(D<0){i=I;return}w&&m(),p(3,i,D+1)},_=w=>{switch(w){case 99:if(h("cssClass"))return p(48,i,i+8);if(h("callback"))return p(40,i,i+8);if(h("click"))return p(43,i,i+5);break;case 108:if(h("link"))return p(41,i,i+4);break;case 110:if(h("note for"))return p(24,i,i+8);if(h("note"))return p(25,i,i+4);break;case 60:if(e.charCodeAt(i+1)===60)return p(20,i,i+2);break;case 62:if(e.charCodeAt(i+1)===62)return p(21,i,i+2);break;case 104:if(h("href"))return p(46,i,i+4);break}return!1},S=w=>{if(_(w))return!0;let I=e.charCodeAt(i+1);switch(w){case 34:return u(1),i++,!0;case 126:return u(3),i++,!0;case 96:return u(2),i++,!0;case 95:if(h("_self"))return p(42,i,i+5);if(h("_blank"))return p(42,i,i+6);if(h("_parent"))return p(42,i,i+7);if(h("_top"))return p(42,i,i+4);break;case 60:return I===124?p(34,i,i+2):p(36,i,i+1);case 124:return I===62&&p(34,i,i+2);case 62:return p(36,i,i+1);case 42:return p(35,i,i+1);case 111:if(!Qe(I))return p(33,i,i+1);break;case 40:return I===41&&p(37,i,i+2);case 45:return I===45?p(38,i,i+2):p(52,i,i+1);case 46:return I===46?p(39,i,i+2):p(8,i,i+1);case 58:{let D=i+1;for(;D<t;){let U=e.charCodeAt(D);if(U===58||U===10||U===59)break;D++}return D>i+1?p(10,i,D):I===58&&e.charCodeAt(i+2)===58&&p(19,i,i+3)}case 43:return p(58,i,i+1);case 37:return p(51,i,i+1);case 61:return p(59,i,i+1);case 91:return p(5,i,i+1);case 93:return p(7,i,i+1);case 33:case 35:case 36:case 38:case 39:case 44:case 63:case 92:case 47:return p(60,i,i+1)}if(Qe(w)){let D=i+1;for(;Qe(e.charCodeAt(D));)D++;return p(27,i,D)}return Js(w)&&p(53,i,i+1)},P=()=>{if(c===-1||i<f||(c<i&&(c=e.indexOf("direction",i)),c===-1)||(l<i&&(Yd.lastIndex=i,l=Yd.test(e)?Yd.lastIndex-1:t),c>=l))return!1;for(let w=0;w<4;w++){let I=Nw[w];if(I.lastIndex=i,I.test(e))return p(29+w,i,I.lastIndex)}return f=l,!1},k=w=>{if(P())return!0;if(Be(w))return y(!1),!0;switch(w){case 37:if(e.charCodeAt(i+1)===37){let I=x(`
67
+ `);for(;I<t&&(e.charCodeAt(I)===10||e.charCodeAt(I)===13);)I++;return i=I,!0}break;case 97:{let I=e.startsWith("accTitle",i);if(!I&&!e.startsWith("accDescr",i))break;let D=g(i+8),U=e.charCodeAt(D);if(U===58)return p(I?11:13,i,g(D+1)),u(I?6:7),!0;if(U===123&&!I)return i=g(D+1),u(8),!0;break}case 99:if(h("classDiagram-v2"))return p(2,i,i+15);if(h("classDiagram"))return p(2,i,i+12);if(e.startsWith("call",i)&&Be(e.charCodeAt(i+4)))return i=g(i+4),u(4),!0;if(h("classDef"))return p(26,i,i+8);if(h("class"))return u(9),p(22,i,i+5);break;case 91:if(e.startsWith("*]",i+1))return p(55,i,i+3);break;case 115:if(h("style"))return p(47,i,i+5);break;case 110:if(h("namespace"))return u(11),p(18,i,i+9);break;case 44:return p(28,i,i+1);case 35:return p(50,i,i+1)}return S(w)||w===58&&p(49,i,i+1)};for(;;){if(i>=t){n.push(Iw[a]),r.push(""),o.push(t);break}let w=e.charCodeAt(i),I=!0;switch(a){case 0:I=k(w);break;case 9:Be(w)?y(!0):w===125?(m(),m(),p(17,i,i+1)):w===123?(u(10),p(16,i,i+1)):I=S(w);break;case 10:if(w===34)u(1),i++;else if(w===125)m(),p(17,i,i+1);else if(w===91&&e.startsWith("*]",i+1))p(55,i,i+3);else if(w===123)p(57,i,i+1);else if(w===10)i++;else{let D=i+1;for(;D<t;){let U=e.charCodeAt(D);if(U===123||U===125||U===10)break;D++}p(23,i,D)}break;case 11:Be(w)?y(!0):w===123?(u(12),p(16,i,i+1)):w===125?m():w===110&&h("namespace")?(u(11),p(18,i,i+9)):I=S(w);break;case 12:Be(w)?y(!1):w===125?(m(),p(17,i,i+1)):w===110&&h("namespace")?(u(11),p(18,i,i+9)):w===91&&e.startsWith("*]",i+1)?p(55,i,i+3):w===99&&h("class")?(u(9),p(22,i,i+5)):I=S(w);break;case 1:w===34?(m(),i++):p(6,i,x('"'));break;case 3:if(w===34)u(1),i++;else{if(_(w))break;w===126?(m(),i++):p(9,i,x("~"))}break;case 2:if(w===34)u(1),i++;else{if(_(w))break;w===126?(u(3),i++):w===96?(m(),i++):p(54,i,x("`"))}break;case 4:if(w===40){let D=g(i+1);m(),e.charCodeAt(D)===41?i=D+1:(u(5),i++)}else p(44,i,x("("));break;case 5:w===41?(m(),i++):p(45,i,x(")"));break;case 6:case 7:p(a===6?12:14,i,x(`
68
+ `)),m();break;case 8:w===125?(m(),i++):p(15,i,x("}"));break}if(!I)return n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o}}return n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o}}var Kd=61,Pa=new Uint8Array(Kd);for(let e of[53,27,52])Pa[e]=1;var Hd=new Uint8Array(Kd);for(let e of[27,49,50,47,51,10])Hd[e]=1;var Rs=new Uint8Array(Kd);Rs[33]=1;Rs[34]=2;Rs[35]=3;Rs[36]=4;Rs[37]=5;var Mw="'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS', 'BQUOTE_STR'";function km(e,t){let{types:n,texts:r,starts:o}=Mm(e),s=0,a=w=>{let I=n[s];throw I===1?it("class",e,o[s],"",!0):it("class",e,o[s],`Expecting ${w}, got '${Gd[I]}'`)},i=w=>(n[s]!==w&&a(`'${Gd[w]}'`),r[s++]),c=()=>(Pa[n[s]]===0&&a("'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS'"),r[s++]),l=w=>{let I="";for(;;){if(n[s]===54){I+=r[s++];break}Pa[n[s]]===0&&a(Mw),I+=r[s++];let D=n[s];if(D===8)I+=".",s++;else if(Pa[D]===0&&D!==54)break}return w&&n[s]===9&&(I+="~"+r[s++]+"~"),I},f=()=>{s++;let w=i(6);return i(7),w},p=()=>{n[s]!==23&&a("'STRUCT_STOP', 'MEMBER'");let w=[];for(;n[s]===23;)w.push(r[s++]);return i(17),w.reverse()},u=()=>{s++;let w=l(!0);switch(t.addClass(w),n[s]===5&&t.setClassLabel(w,f()),n[s]){case 19:{s++;let I=c();t.setCssClass(w,I),n[s]===16&&(s++,t.addMembers(w,p()));break}case 16:s++,n[s]===17?s++:t.addMembers(w,p());break;case 20:{s++;let I=c();i(21),t.addAnnotation(w,I),n[s]===16&&(s++,n[s]===17?s++:t.addMembers(w,p()));break}}return w},m=()=>{if(n[s++]===25)return t.addNote(i(6));let w=l(!0);return t.addNote(i(6),w)},h=()=>{let w=[];for(;;){s++;let I=l(!1),D=n[s]===5?t.addNamespace(I,f()):t.addNamespace(I);i(16),n[s]===3&&s++,w.push({id:D,classes:[],notes:[]});let U=!0;for(;U;){let M=w[w.length-1],Q=n[s];if(Q===18)break;for(Q===22?M.classes.push(u()):Q===25||Q===24?M.notes.push(m()):a("'NAMESPACE', 'CLASS', 'NOTE_FOR', 'NOTE'");;){if(n[s]===3){let Y=n[s+1];if(Y===18||Y===22||Y===25||Y===24){s++;break}s++}i(17);let q=w.pop();if(t.addClassesToNamespace(q.id,q.classes,q.notes),t.popNamespace(),w.length===0){U=!1;break}}}if(w.length===0)return}},g=()=>{let w=Rs[n[s]];return w===0?"none":(s++,w-1)},x=()=>{let w=l(!0),I=n[s];if(I===10){t.addMember(w,t.cleanupLabel(r[s++]));return}let D="none";if(I===6)D=r[s++],I=n[s];else if(Rs[I]===0&&I!==38&&I!==39)return;let U=g();I=n[s],I!==38&&I!==39&&a("'AGGREGATION', 'EXTENSION', 'COMPOSITION', 'DEPENDENCY', 'LOLLIPOP', 'LINE', 'DOTTED_LINE'"),s++;let M=g(),Q=n[s]===6?r[s++]:"none",q=l(!0),Y={id1:w,id2:q,relation:{type1:U,type2:M,lineType:I===38?0:1},relationTitle1:D,relationTitle2:Q};n[s]===10&&(Y.title=t.cleanupLabel(r[s++])),t.addRelation(Y)},y=()=>{let w=[];for(;;){Hd[n[s]]===0&&a("'ALPHA', 'NUM', 'COLON', 'UNIT', 'SPACE', 'BRKT', 'STYLE', 'PCT', 'LABEL'");let I=r[s++];for(;Hd[n[s]]===1;)I+=r[s++];if(w.push(I),n[s]!==28)return w;s++}},_=w=>{n[s]===6&&t.setTooltip(w,r[s++])},S=w=>{let I=i(6),D=n[s]===6?r[s++]:void 0;n[s]===42?t.setLink(w,I,r[s++]):t.setLink(w,I),D!==void 0&&t.setTooltip(w,D)},P=()=>{let w=n[s];switch(w){case 53:case 27:case 52:case 54:x();return;case 18:h();return;case 22:u();return;case 23:s++;return;case 20:{s++;let I=c();i(21),t.addAnnotation(l(!0),I);return}case 40:{s++;let I=l(!0);t.setClickEvent(I,i(6)),_(I);return}case 41:s++,S(l(!0));return;case 43:{s++;let I=l(!0);if(n[s]===46){s++,S(I);return}let D=i(44);n[s]===45?t.setClickEvent(I,D,r[s++]):t.setClickEvent(I,D),_(I);return}case 47:{s++;let I=i(27);t.setCssStyle(I,y());return}case 48:{s++;let I=i(6);t.setCssClass(I,i(27));return}case 25:case 24:m();return;case 26:{s++;let I=[i(27)];for(;n[s]===28;)s++,I.push(i(27));t.defineClass(I,y());return}case 29:case 30:case 31:case 32:s++,t.setDirection(w===29?"TB":w===30?"BT":w===31?"RL":"LR");return;case 11:s++,t.setAccTitle(i(12).trim());return;case 13:s++,t.setAccDescription(i(14).trim());return;case 15:t.setAccDescription(r[s++].trim());return}a("'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'NAMESPACE', 'ANNOTATION_START', 'CLASS', 'MEMBER', 'NOTE_FOR', 'NOTE', 'CLASSDEF', 'direction_tb', 'CALLBACK', 'LINK', 'CLICK', 'STYLE', 'CSSCLASS', 'ALPHA', 'MINUS', 'BQUOTE_STR'")},k=n[s]===2;for(k&&(s++,i(3));P(),!(n[s]!==3||(s++,n[s]===4||n[s]===0)););k&&i(4),i(0)}function Ba(e,t,n,r,o,s,a){let i=De(e,!1,t,n,4e3,1);if(i.height===0)return{width:o,height:s,content:a};let c=i.height+12,l=Math.max(o,Math.ceil(i.width+2*r));return{width:l,height:Math.ceil(s+c),content:Ie(i,l/2,r+i.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d((l-o)/2)},${d(c)})">${a}</g>`}}var kw=["aggregation","extension","composition","dependency","lollipop"];function Lm(e){return typeof e=="number"&&kw[e]||"none"}function $m(e,t=!0){let n=[],r=[],o=new Map,s=new Map,a=new Map,i=new Map,c=u=>{if(t||u===void 0)return u;let m=[],h=u,g;for(;h;){if(i.has(h)){g=i.get(h);break}let x=e.namespaces.get(h);if(x===void 0)break;if(x.explicit){g=h;break}m.push(h),h=x.parent}for(let x of m)i.set(x,g);return g},l=u=>u===void 0?-1:o.get(u)??-1;for(let u of e.namespaces.values())!t&&!u.explicit||(o.set(u.id,n.length),n.push({id:u.id,label:t?u.label:u.id,isGroup:!0,shape:"rect",parentId:t?u.parent:void 0,parent:-1}));for(let u of n)u.parent=l(u.parentId);let f=0;for(let u of e.classes.values()){let m=c(u.parent);s.set(u.id,n.length),n.push({id:u.id,label:u.label,isGroup:!1,shape:"classBox",parentId:m,parent:l(m),classNode:u,colorIndex:f++})}for(let u of e.notes.values()){let m=c(u.parent),h=u.class===void 0?void 0:s.get(u.class);h!==void 0&&r.push({id:`edgeNote${u.index}`,start:u.id,end:n[h].id,source:n.length,target:h,label:void 0,arrowTypeStart:"none",arrowTypeEnd:"none",startLabelRight:"",endLabelLeft:"",pattern:"dotted",classes:"relation"}),n.push({id:u.id,label:u.text,isGroup:!1,shape:"note",parentId:m,parent:l(m)})}for(let u of e.interfaces){let m=s.get(u.classId);a.set(u.id,n.length),n.push({id:u.id,label:u.label,isGroup:!1,shape:"interface",parentId:void 0,parent:m===void 0?-1:n[m].parent})}let p=0;for(let u of e.relations){p++;let{type1:m,type2:h}=u.relation,g=m===ui.LOLLIPOP&&h==="none"?a:s,x=g===s&&h===ui.LOLLIPOP&&m==="none"?a:s;r.push({id:`id_${u.id1}_${u.id2}_${p}`,start:u.id1,end:u.id2,source:g.get(u.id1)??-1,target:x.get(u.id2)??-1,label:u.title,arrowTypeStart:Lm(m),arrowTypeEnd:Lm(h),startLabelRight:u.relationTitle1==="none"?"":u.relationTitle1,endLabelLeft:u.relationTitle2==="none"?"":u.relationTitle2,pattern:u.relation.lineType===1?"dashed":"solid",classes:"relation"})}return{nodes:n,edges:r}}var zd=12,co=16,ao=6,Fa=5;function Vd(e){switch(e){case"extension":return zd;case"composition":case"aggregation":return co;case"lollipop":return 2*Fa;case"dependency":return ht("arrow_point")}return 0}function jd(e,t,n,r,o,s){let a=-o,i=r;switch(e){case"extension":{let c=t-r*zd,l=n-o*zd;return`<path class="pele-marker" d="M${d(t)},${d(n)}L${d(c+a*ao)},${d(l+i*ao)}L${d(c-a*ao)},${d(l-i*ao)}Z" stroke-linejoin="round"/>`}case"composition":case"aggregation":{let c=t-r*co/2,l=n-o*co/2,f=ao-1;return`<path class="pele-marker" d="M${d(t)},${d(n)}L${d(c+a*f)},${d(l+i*f)}L${d(t-r*co)},${d(n-o*co)}L${d(c-a*f)},${d(l-i*f)}Z" stroke-linejoin="round"${e==="composition"?` fill="${s}"`:""}/>`}case"lollipop":return`<circle class="pele-marker" cx="${d(t-r*Fa)}" cy="${d(n-o*Fa)}" r="${Fa}"/>`;case"dependency":return bt("arrow_point",t,n,r,o,s)}return""}var Lw=40,$w=16,Dm=56,Ts=20,Om=26,Xd=12,Wa=8,vm=6,Dw=10,Ow=64,Ua=8,qd="var(--_l)",vw=new Set(["_self","_blank","_parent","_top"]);function Pm(e,t,n){let r=e[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}var Ga=[],Ya=[];function Bm(e,t,n){let r=gt(e.getDisplayDetails().displayText).trim();return{text:r,width:t.width(r,n,e.classifier==="*"?2:0),classifier:e.classifier}}function Fm(e,t,n){let r=o=>pn(n,s=>Pw(e,t,n,o,s));return _n(e.direction)?Nt(n,r):r(!1)}function Pw(e,t,n,r,o){let s=t.class??{},a=$m(e,s.hierarchicalNamespaces!==!1),i=s.hideEmptyMembersBox===!0,c=n.fontSize??16,l=Math.round(c*.875),f=Math.round(c*.8),p=Math.round(f*1.4),u=n.measurer??Je(n.fontFamily),m=n.padding??8,h=r?"TB":tn(e.direction),g=new Map,x=new Map,y=new Map,_=re=>{let j=g.get(re);if(j===void 0){let ie=At([re]);j=ie.shape===""&&ie.text===""?"":re.slice(0,re.indexOf(":")).trim().toLowerCase(),g.set(re,j)}j!==""&&y.set(j,re)},S=re=>{y.clear();let j=x.get(re.cssClasses);if(j===void 0){for(let ie of re.cssClasses.split(" ")){let ue=e.styleClasses.get(ie);if(ue)for(let ge of ue.styles)for(let Se of ge.split(","))_(Se)}j=[...y],x.set(re.cssClasses,j)}else for(let[ie,ue]of j)y.set(ie,ue);for(let ie of re.styles)_(ie);return At(y.size===0?Ya:[...y.values()])},P=new Int32Array(a.nodes.length);for(let re of a.nodes)re.parent>=0&&P[re.parent]++;let k=new Uint8Array(a.nodes.length);for(let re of a.edges){if(re.source<0||re.target<0)continue;let j=a.nodes[re.source].parent,ie=a.nodes[re.target].parent;if(j!==ie){for(let ue=j;ue>=0&&k[ue]===0;ue=a.nodes[ue].parent)k[ue]=1;for(let ue=ie;ue>=0&&k[ue]===0;ue=a.nodes[ue].parent)k[ue]=1}}let w=[],I=[];a.nodes.forEach((re,j)=>{let ie,ue;if(re.isGroup){let ge=De(re.label,!1,u,c,4e3);ie=D(re,ge,0,0,c),P[j]>0?(ue=$t(0,0),ue.isGroup=!0,ue.padX=Ts,ue.padTop=ge.height>0?ge.height+16:Ts,ue.padBottom=Ts,ue.minW=ge.width+2*Ts-12+(k[j]===1&&!o?Math.min(ge.width+24,240):0)):(ie.w=Math.max(ge.width+2*Ts,80),ie.h=ge.height+2*Ts,ue=$t(ie.w,ie.h))}else if(re.classNode)ie=U(re,re.classNode),ue=$t(ie.w,ie.h);else if(re.shape==="note"){let ge=De(re.label,!0,u,l,260);ie=D(re,ge,Math.max(ge.width+2*Xd,40),ge.height+2*Wa,l),ue=$t(ie.w,ie.h)}else{let ge=De(re.label,!1,u,l,200);ie=D(re,ge,Math.max(ge.width,12)+4,Math.max(ge.height,12),l),ue=$t(ie.w,ie.h)}ue.parent=re.parent,ue.seq=j,w.push(ie),I.push(ue)});function D(re,j,ie,ue,ge){return{node:re,style:At(Ya),label:j,w:ie,h:ue,loops:0,annotations:Ya,attributes:Ga,methods:Ga,titleH:0,attributesH:0,fontSize:ge}}function U(re,j){let ie=S(j),ue=ie.fontSize??c,ge=Math.round(ue*.875),Se=Math.round(ge*1.5),we=j.type?"&lt;"+Hr(j.type).replace(/</g,"&lt;").replace(/>/g,"&gt;")+"&gt;":"",ke=De(j.label+we,!1,u,ue,4e3,1|(ie.italic?2:0)),Le=j.annotations.length>0?j.annotations.map(ne=>`«${gt(ne).trim()}»`):Ya,Fe=j.members.length>0?j.members.map(ne=>Bm(ne,u,ge)):Ga,He=j.methods.length>0?j.methods.map(ne=>Bm(ne,u,ge)):Ga,_e=ke.width;for(let ne of Le)_e=Math.max(_e,u.width(ne,f,0));for(let ne of Fe)_e=Math.max(_e,ne.width);for(let ne of He)_e=Math.max(_e,ne.width);let Pe=!(i&&Fe.length===0&&He.length===0),Ye=ne=>Pe?ne>0?2*vm+ne*Se:Dw:0,Ue=2*Wa+Le.length*p+Math.max(ke.height,Math.round(ue*1.5)),he=Ye(Fe.length);return{node:re,style:ie,label:ke,w:Math.max(_e+2*Xd,Ow),h:Ue+he+Ye(He.length),loops:0,annotations:Le,attributes:Fe,methods:He,titleH:Ue,attributesH:he,fontSize:ue}}let M=[],Q=[],q=[],Y=[],z=[],R=new Float64Array(w.length*4),L=(re,j,ie)=>{R[re*4+j]++,ie>R[re*4+j+1]&&(R[re*4+j+1]=ie)};for(let re of a.edges){if(re.source<0||re.target<0)continue;let j=De(re.label,!0,u,l,200),ie=re.startLabelRight?u.width(gt(re.startLabelRight),f,0):0,ue=re.endLabelLeft?u.width(gt(re.endLabelLeft),f,0):0;re.source===re.target?(w[re.source].loops++,I[re.source].w+=2*(Om+(j.width>0?j.width+12:0))):(L(re.source,0,ie),L(re.target,2,ue)),Y.push(ie),z.push(ue),Q.push(re),q.push(j),M.push({src:re.source,dst:re.target,minlen:1,labelW:j.width>0?j.width+12:0,labelH:j.height>0?j.height+4:0,route:[],labelX:0,labelY:0})}if(h==="TB"||h==="BT")for(let re=0;re<w.length;re++){if(!w[re].node.classNode)continue;let j=0;for(let ie=0;ie<4;ie+=2){let ue=R[re*4+ie],ge=R[re*4+ie+1];ue>1&&(j=Math.max(j,(ue-1)*(ge>0?ge+24:14)+24))}j=Math.min(j,480),j>w[re].w&&(I[re].w+=j-w[re].w,w[re].w=j)}let F=!1;for(let re=0;re<Q.length&&!F;re++)F=Y[re]>0||z[re]>0;let E=Sn(I,M,h,{nodeSep:Pm(s,"nodeSpacing",Lw),edgeSep:$w,rankSep:Pm(s,"rankSpacing",F?Dm+16:Dm),portSep:20,apart:!0}),C=new Map,A=[],T=(re,j,ie,ue,ge)=>{let Se=re.route,we=I[ie],ke=Bn(Se,j,we);if(ke<0)return;let Le=(we.w-w[ie].w)/2;ke===1?Se[j]-=Le:ke===3&&(Se[j]+=Le);let Fe=ke&1,He=Se[(j===0?3:j-3)+Fe],_e=He-Se[j+Fe],Pe={route:Se,at:j,toward:He,order:ge,room:ue,side:ke,after:Fe?_e>0:_e>=0},Ye=ie*4+ke,Ue=C.get(Ye);return Ue?Ue.push(Pe):C.set(Ye,[Pe]),Pe},b=[],N=[];for(let re=0;re<M.length;re++){let j=M[re],ie=j.src!==j.dst&&j.route.length>=6;b.push(ie?T(j,0,j.src,Y[re],re):void 0),N.push(ie?T(j,j.route.length-3,j.dst,z[re],re):void 0)}let $=(re,j,ie)=>{for(let ue=I[re].parent,ge=0;ue>=0&&ge<1e4;ue=I[ue].parent,ge++){let Se=I[ue],we=Math.abs(j-Se.x),ke=Math.abs(ie-Se.y);if(Math.abs(ke-Se.h/2)<.5&&we<=Se.w/2+.5||Math.abs(we-Se.w/2)<.5&&ke<=Se.h/2+.5)return!0}return!1},X=[];for(let[re,j]of C){if(j.length<2)continue;let ie=re>>2,ue=re&1,ge=ue?w[ie].h:w[ie].w;j.sort((Le,Fe)=>Le.toward-Fe.toward||Le.order-Fe.order);let Se=0;for(let Le=0;Le+1<j.length;Le++){let Fe=j[Le],He=j[Le+1],_e=ue?20:24;Fe.room>0&&Fe.after&&(_e+=ue?p+6:Fe.room),He.room>0&&!He.after&&(_e+=ue?p+6:He.room),X[Le]=_e,Se+=_e}let we=Math.min(1,(ge-24)/Se);if(we<=0)continue;let ke=(ue?I[ie].y:I[ie].x)-Se*we/2;for(let Le=0;Le<j.length;Le++){let{route:Fe,at:He}=j[Le],_e=He===0?3:-3,Pe=He+_e,Ye=-1;for(let Ue=Pe;Ue>=0&&Ue<Fe.length&&Math.abs(Fe[Ue+ue]-Fe[Pe+ue])<.5;Ue+=_e)if($(ie,Fe[Ue],Fe[Ue+1])){Ye=Ue;break}if(Ye>=0&&Math.abs(Fe[Pe+ue]-ke)<=24)for(let Ue=Pe;Ue!==Ye+_e;Ue+=_e)Fe[Ue+ue]=ke;Fe[He+ue]=ke,ke+=X[Le]*we}}let V=(re,j,ie,ue)=>{if(j===void 0||ie<=0)return;let ge=j.side&1,Se=ue?0:re.length-3,we=Se+1-ge,ke=Math.abs(re[(ue?3:Se-3)+1-ge]-re[we]),Le=Math.min(ge?ie+10:p+6,ke*.35);if(Le<4)return;let Fe=[re[Se],re[Se+1],re[Se+2]];Fe[1-ge]+=(j.side===0||j.side===3?-1:1)*Le,re.splice(ue?3:Se,0,Fe[0],Fe[1],Fe[2])};for(let re=0;re<M.length;re++)V(M[re].route,b[re],Y[re],!0),V(M[re].route,N[re],z[re],!1);let O=0,v=0,W=E.width,H=E.height,G=(re,j,ie,ue,ge,Se)=>{if(!re)return;let we=ie,ke=ue;ge&1?(we+=(ge===3?-1:1)*(5+j/2),ke+=(Se?1:-1)*(7+p/2)):(we+=(Se?1:-1)*(9+j/2),ke+=(ge===0?-1:1)*(3+p/2)),A.push({text:gt(re),x:we,y:ke}),O=Math.min(O,we-j/2),W=Math.max(W,we+j/2),v=Math.min(v,ke-p/2),H=Math.max(H,ke+p/2)},te=new Map,Z=new Int32Array(M.length);for(let re=0;re<M.length;re++){let j=M[re],ie=Q[re],ue=j.route;if(j.src===j.dst){let ge=te.get(j.src)??0;te.set(j.src,ge+1),Z[re]=ge;let Se=I[j.src],we=w[j.src],ke=Se.x+we.w/2,Le=Math.min(we.h/2-4,8+ge*6);G(ie.startLabelRight,Y[re],ke,Se.y-Le,1,!1),G(ie.endLabelLeft,z[re],ke,Se.y+Le,1,!0)}else if(ue.length>=6){let ge=ue.length-3,Se=b[re],we=N[re];G(ie.startLabelRight,Y[re],ue[0],ue[1],Se?Se.side:2,Se?Se.after:!0),G(ie.endLabelLeft,z[re],ue[ge],ue[ge+1],we?we.side:0,we?we.after:!0)}}let B=m-O,K=m-v,ee=Math.ceil(W-O+2*m),ae=Math.ceil(H-v+2*m),J=[],se=new Map;if(a.nodes.length>0&&a.nodes[0].isGroup)for(let re of M)Vn(se,re.route);let me="",Ae="",de="";for(let re=0;re<w.length;re++){let j=w[re],ie=I[re],ue=j.node,ge=ie.x+B,Se=ie.y+K,we=$e(ue.id),ke=ie.isGroup?ie.w:j.w,Le=ie.isGroup?ie.h:j.h;if(ue.isGroup){let He=ie.isGroup?Pr(ie,j.label.width,se,Ts):ie.x,_e=Se-Le/2+8+j.label.height/2,Pe=' class="pele-cluster-label" fill="var(--_m)"',Ye=ie.isGroup&&da(ie,j.label.width,He,se);Ye&&(Ae+=ua(j.label,He+B,_e,Pe,we,a.nodes,re)),me+=`<g class="pele-cluster pele-namespace" data-id="${we}"><rect x="${d(ge-ke/2)}" y="${d(Se-Le/2)}" width="${d(ke)}" height="${d(Le)}" rx="${Xe}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"/>`+(Ye?"":Ie(j.label,He+B,_e,Pe))+"</g>";continue}let Fe=` transform="translate(${d(ge)},${d(Se)})"`;if(ue.classNode)de+=oe(j,ue.classNode,we,Fe);else if(ue.shape==="note"){let He=ke/2,_e=-Le/2;de+=`<g class="pele-node pele-note" data-id="${we}"${Fe}><path d="M${d(-He)},${d(_e)}H${d(He-Ua)}L${d(He)},${d(_e+Ua)}V${d(-_e)}H${d(-He)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"/><path d="M${d(He-Ua)},${d(_e)}V${d(_e+Ua)}H${d(He)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"/>`+Ie(j.label,0,0,` class="pele-label" font-size="${l}"`,n.icons)+"</g>"}else de+=`<g class="pele-node pele-interface" data-id="${we}"${Fe}>`+Ie(j.label,0,0,` class="pele-label" font-size="${l}"`,n.icons)+"</g>"}function oe(re,j,ie,ue){let{w:ge,h:Se,style:we}=re,ke=-ge/2,Le=-Se/2,Fe=Math.round(re.fontSize*.875),He=Math.round(Fe*1.5),_e=`<rect x="${d(ke)}" y="${d(Le)}" width="${d(ge)}" height="${d(Se)}" rx="${Xe}" fill="var(--_s)" stroke="var(--_b)"${we.shape}/>`,Pe=Le+re.titleH,Ye=Pe+re.attributesH;if(Se>re.titleH){let pe=we.stroke?` style="stroke:${je(we.stroke)}"`:"";_e+=`<path class="pele-divider" d="M${d(ke)},${d(Pe)}H${d(-ke)}M${d(ke)},${d(Ye)}H${d(-ke)}" fill="none" stroke="var(--_b)"${pe}/>`}let Ue=Le+Wa;for(let pe of re.annotations)_e+=`<text class="pele-annotation" x="0" y="${d(Ue+p/2+f*.35)}" text-anchor="middle" font-size="${f}" fill="var(--_m)">${je(pe)}</text>`,Ue+=p;let he=re.fontSize===c?"":` font-size="${d(re.fontSize)}"`;_e+=Ie(re.label,0,(Ue+Pe-Wa)/2,` class="pele-label"${he} font-weight="var(--_hw)"${we.text}`,n.icons);let ne=(pe,Re,le)=>{let Ee="",Ne=le+vm+He/2+Fe*.35;for(let Me of pe){let Ce=Me.classifier==="$"?` pele-static"${we.text?we.text.slice(0,-1)+'text-decoration:underline"':' style="text-decoration:underline"'}`:Me.classifier==="*"?` pele-abstract" font-style="italic"${we.text}`:`"${we.text}`;Ee+=`<text class="pele-member pele-${Re}${Ce} x="${d(ke+Xd)}" y="${d(Ne)}">${je(Me.text)}</text>`,Ne+=He}return Ee};return(re.attributes.length>0||re.methods.length>0)&&(_e+=`<g class="pele-members" font-size="${Fe}">${ne(re.attributes,"attribute",Pe)}${ne(re.methods,"method",Ye)}</g>`),j.tooltip&&(_e=`<title>${$e(j.tooltip)}</title>`+_e),j.link&&(_e=Pn(_e,j.link,j.id,J,n,j.linkTarget&&vw.has(j.linkTarget)?` target="${j.linkTarget}"`:"")),`<g class="pele-node pele-class${wt(j.cssClasses.replace(/^default\s?/,""))}" data-id="${ie}"${ue}>${_e}</g>`}let ye="",ce="";for(let re=0;re<M.length;re++){let j=M[re],ie=Q[re],ue=q[re],ge=ie.arrowTypeStart,Se=ie.arrowTypeEnd,we=Vd(ge),ke=Vd(Se),Le;if(j.src===j.dst){let He=I[j.src],_e=w[j.src],Pe=Z[re],Ye=He.x+B+_e.w/2,Ue=He.y+K,he=Math.min(_e.h/2-4,8+Pe*6),ne=Om+Pe*8;Le={d:`M${d(Ye+we)},${d(Ue-he)}C${d(Ye+ne+we)},${d(Ue-he)} ${d(Ye+ne+ke)},${d(Ue+he)} ${d(Ye+ke)},${d(Ue+he)}`,sx:Ye,sy:Ue-he,sdx:-1,sdy:0,ex:Ye,ey:Ue+he,edx:-1,edy:0},j.labelX=He.x+_e.w/2+ne+4+j.labelW/2,j.labelY=He.y}else{let He=j.route;for(let _e=0;_e<He.length;_e+=3)He[_e]+=B,He[_e+1]+=K;Le=yn(He,void 0,we,ke)}let Fe=ie.pattern==="dashed"?' stroke-dasharray="6 4"':ie.pattern==="dotted"?' stroke-dasharray="2 4"':"";if(ye+=`<g class="pele-edge${ie.pattern==="dotted"?" pele-note-edge":" pele-relation"}" data-id="${$e(ie.id)}"><path d="${Le.d}"${Fe}/>`+jd(ge,Le.sx,Le.sy,Le.sdx,Le.sdy,qd)+jd(Se,Le.ex,Le.ey,Le.edx,Le.edy,qd)+"</g>",ue.width>0){let He=j.labelX+B,_e=j.labelY+K;ce+=nn(ie.id,ue,He,_e,"",n.icons)}}let fe="";for(let re of A)fe+=`<text class="pele-cardinality" x="${d(re.x+B)}" y="${d(re.y+K+f*.35)}" text-anchor="middle">${je(re.text)}</text>`;let xe=Ba(e.title,u,c,m,ee,ae,(me?`<g class="pele-clusters">${me}</g>`:"")+(ye?`<g class="pele-edges" fill="none" stroke="${qd}" stroke-linecap="round">${ye}</g>`:"")+(Ae?`<g class="pele-cluster-titles">${Ae}</g>`:"")+(ce?`<g class="pele-edge-labels" font-size="${l}">${ce}</g>`:"")+(fe?`<g class="pele-cardinalities" font-size="${f}" fill="var(--_m)">${fe}</g>`:"")+`<g class="pele-nodes">${de}</g>`);return{svg:Ze("class",xe.width,xe.height,c,n,e,xe.content),width:xe.width,height:xe.height,links:J}}var Wm={type:"class",parse(e,t,n){let r=new va;return n&&(r.title=n),km(e,r),r},render:Fm};var Qd=class{domains=new Map;transitions=[];setDomains(t){if(t)for(let n of t){let r=n.domain;this.domains.set(r,{name:r,items:(n.items??[]).map(o=>({label:o.label}))})}}setTransitions(t){t&&(this.transitions=t.filter(n=>n.from!==n.to).map(n=>({from:n.from,to:n.to,label:n.label||void 0})))}};function Um(e,t){let n=new Qd;return n.setDomains(e.domains),n.setTransitions(e.transitions),{type:"cynefin",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
69
+ `):void 0,domains:n.domains,transitions:n.transitions}}var Gm=[{name:"cynefin-beta:",pattern:"cynefin-beta:"},Vt("cynefin-beta"),{name:"-->",pattern:"-->"},{name:":",pattern:":"},{name:"DOMAIN_NAME",pattern:/complex|complicated|clear|chaotic|confusion/y},Zt,Yt,Ht,wn,hn,mn,Pt,Kt,zt];function Ym(e){let t=new Dt(vt(e,Gm,"cynefin"),Gm,"cynefin"),n={$type:"Cynefin",domains:[],transitions:[]},r=()=>{for(;t.kinds[t.i]===9;)t.i++},o=()=>{t.kind!==-1&&(t.kind!==9&&t.fail("a line break or the end of input"),r())};for(r(),t.kind!==1&&t.kind!==0&&t.fail("'cynefin-beta'"),t.i++;t.kind!==-1;)switch(t.kind){case 9:t.i++;break;case 5:n.accDescr=Wt(t.take()),o();break;case 6:n.accTitle=Ft(t.take()),o();break;case 7:n.title=Bt(t.take()),o();break;case 4:{let s=t.take();if(t.accept(2)){let i={$type:"Transition",from:s,to:t.expect(4)};t.accept(3)&&(i.label=rn(t.expect(8))),o(),n.transitions.push(i);break}let a={$type:"DomainBlock",domain:s,items:[]};for(r();t.kinds[t.i]===8;)a.items.push({$type:"DomainItem",label:rn(t.take())}),r();n.domains.push(a);break}default:t.fail("a domain, a transition, a title, or a line break")}return n}function Hm(e){let t=e+1831565813|0;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Bw(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}function Km(e,t){return typeof e=="number"&&Number.isFinite(e)&&e!==0?e:Bw(t)}var zm={segments:7,vertical:!0,pointStep:17,controlStep:31,controlShift:7},Zd={segments:7,vertical:!1,pointStep:23,controlStep:37,controlShift:11};function Ha(e,t,n,r,o,s){let a=(t-e)/s.segments,i=[],c=[];for(let f=0;f<=s.segments;f++){let p=f===0&&s.pinStart||f===s.segments&&s.pinEnd;i.push(e+f*a),c.push(p?n:n+Hm(r+f*s.pointStep)*o*2-o)}let l=s.vertical?[c[0],i[0]]:[i[0],c[0]];for(let f=0;f<s.segments;f++){let p=(i[f]+i[f+1])/2,u=o*1.5*(f%2===0?1:-1)*Hm(r+f*s.controlStep+s.controlShift);s.vertical?l.push(c[f]+u,p,c[f+1]-u,p,c[f+1],i[f+1]):l.push(p,c[f]+u,p,c[f+1]-u,i[f+1],c[f+1])}return l}function Vm(e,t,n,r){let o=n-t;return[e,t,e+r,t+o*.2,e-r*1.5,t+o*.55,e+r*.5,t+o*.75,e-r,t+o*.85,e+r*.3,t+o*.95,e,n]}function fi(e){let t="";for(let n=2;n<e.length;n+=6)t+=`C${d(e[n])},${d(e[n+1])} ${d(e[n+2])},${d(e[n+3])} ${d(e[n+4])},${d(e[n+5])}`;return t}function lo(e){let t="";for(let n=e.length-6;n>=2;n-=6)t+=`C${d(e[n+2])},${d(e[n+3])} ${d(e[n])},${d(e[n+1])} ${d(e[n-2])},${d(e[n-1])}`;return t}function uo(e){return`M${d(e[0])},${d(e[1])}${fi(e)}`}function jm(e,t,n,r){let o=`${d(n)},${d(r)}`;return`M${d(e-n)},${d(t)}A${o} 0 1,1 ${d(e+n)},${d(t)}A${o} 0 1,1 ${d(e-n)},${d(t)}Z`}var Jd=[["complex",0,0,0],["complicated",1,0,1],["chaotic",0,1,3],["clear",1,1,2]],Fw=4,Ww=new Map([["complex",["Complex","Probe → Sense → Respond","Emergent Practices"]],["complicated",["Complicated","Sense → Analyse → Respond","Good Practices"]],["clear",["Clear","Sense → Categorise → Respond","Best Practices"]],["chaotic",["Chaotic","Act → Sense → Respond","Novel Practices"]],["confusion",["Confusion","","Disorder"]]]),Xm=3,qm=200,Uw=10,Gw=4,Ka=6,Qm=10,Zm=20,za=10;function Va(e,t,n,r,o){let s=e.cynefin?.[t];return typeof s=="number"&&s>=r&&s<=o?s:n}function Jm(e,t,n){let r=n.fontSize??16,o=Math.round(r*.8125),s=Math.round(r*.875),a=n.measurer??Je(n.fontFamily),i=n.padding??8,c=n.icons,l=t.cynefin?.showDomainDescriptions!==!1,f=Va(t,"boundaryAmplitude",8,0,50),p=Km(Va(t,"seed",0,-1e15,1e15),n.idPrefix??"pele"),u=Math.round(s*1.5),m=(B,K)=>{let ee=De(B,!1,a,s,qm);return{text:B,label:ee,w:ee.width+2*Uw,h:Math.max(ee.height,u)+2*Gw,overflow:K}},h=B=>{let K=Ww.get(B),ee=De(K[0],!1,a,r,4e3,1),ae=[];if(l)for(let oe of[K[1],K[2]])oe&&ae.push(De(oe,!1,a,o,4e3,2));let J=e.domains.get(B)?.items??[],se=B==="confusion"&&J.length>Xm?Xm:J.length,me=[];for(let oe=0;oe<se;oe++)me.push(m(J[oe].label,!1));se<J.length&&me.push(m(`+${J.length-se} more`,!0));let Ae=ee.width,de=ee.height;for(let oe of ae)Ae=Math.max(Ae,oe.width),de+=oe.height;me.length>0&&(de+=Qm-Ka);for(let oe of me)Ae=Math.max(Ae,oe.w),de+=Ka+oe.h;return{name:B,title:ee,subtitles:ae,badges:me,w:Ae,h:de,cx:0,cy:0}},g=Jd.map(([B])=>h(B)),x=h("confusion"),y=Math.max(88,x.w*.71+8),_=Math.max(64,x.h*.71+6),S=Va(t,"width",640,100,1e4)/2,P=Va(t,"height",440,100,1e4)/2;for(let B of g)S=Math.max(S,B.w+2*Zm),P=Math.max(P,B.h+2*Zm);for(let B of g){let K=(S-B.w)/2,ee=(P-B.h)/2;if((K/(y+za))**2+(ee/(_+za))**2>=1)continue;let ae=B.w+2*(y+za),J=B.h+2*(_+za);ae*P<=S*J?S=Math.max(S,ae):P=Math.max(P,J)}let k=De(e.title,!1,a,r,4e3,1),w=k.height>0?k.height+12:0,I=2*S,D=2*P,U=i,M=i+w,Q=U+S,q=M+P,Y=U+I,z=M+D,R=Ha(M,q,Q,p,f,{...zm,segments:4,pinEnd:!0}),L=Ha(U,Q,q,p+100,f,{...Zd,segments:4,pinEnd:!0}),F=Ha(Q,Y,q,p+200,f,{...Zd,segments:4,pinStart:!0}),E=Vm(Q,q,z,I*.03),C=(B,K)=>K?`${d(B[B.length-2])},${d(B[B.length-1])}`:`${d(B[0])},${d(B[1])}`,A=new Map([["complex",`M${d(U)},${d(M)}L${C(R,!1)}${fi(R)}${lo(L)}Z`],["complicated",`M${C(R,!1)}L${d(Y)},${d(M)}L${C(F,!0)}${lo(F)}${lo(R)}Z`],["chaotic",`M${C(L,!1)}${fi(L)}${fi(E)}L${d(U)},${d(z)}Z`],["clear",`M${C(F,!1)}${fi(F)}L${d(Y)},${d(z)}L${C(E,!0)}${lo(E)}Z`]]),T="";for(let[B,,,K]of Jd)T+=`<path class="pele-cynefin-region" data-id="${B}" d="${A.get(B)}" fill="${ct(K)}" fill-opacity="0.14"/>`;let b=`<g class="pele-cynefin-boundaries" fill="none" stroke="var(--_b)" stroke-dasharray="6 3"><path d="${uo(R)}"/><path d="${uo(L)}"/><path d="${uo(F)}"/><path class="pele-cynefin-cliff" d="${uo(E)}" stroke="var(--_l)" stroke-width="2" stroke-dasharray="none" stroke-linecap="round"/></g>`,N=jm(Q,q,y,_),$=`<path d="${N}" fill="var(--_bg)"/><path class="pele-cynefin-region" data-id="confusion" d="${N}" fill="${ct(Fw)}" fill-opacity="0.18" stroke="var(--_b)" stroke-dasharray="4 2"/>`,X=B=>{let K=B.cy-B.h/2,ee=Ie(B.title,B.cx,K+B.title.height/2,' class="pele-label" font-weight="var(--_hw)"');K+=B.title.height;for(let ae of B.subtitles)ee+=Ie(ae,B.cx,K+ae.height/2,` class="pele-cynefin-subtitle" font-size="${o}" font-style="italic" fill="var(--_m)"`),K+=ae.height;K+=Qm-Ka;for(let ae of B.badges)K+=Ka,ee+=`<g class="pele-node${ae.overflow?" pele-cynefin-overflow":""}"${ae.overflow?"":` data-id="${$e(ae.text)}"`}><rect x="${d(B.cx-ae.w/2)}" y="${d(K)}" width="${d(ae.w)}" height="${d(ae.h)}" rx="${Xe}" fill="var(--_bg)" stroke="var(--_b)"${ae.overflow?' stroke-dasharray="3 2"':""}/>`+Ie(ae.label,B.cx,K+ae.h/2,` class="pele-label" font-size="${s}"${ae.overflow?' fill="var(--_m)"':""}`,c)+"</g>",K+=ae.h;return`<g class="pele-cynefin-domain" data-id="${B.name}">${ee}</g>`},V=new Map,O="";Jd.forEach(([B,K,ee],ae)=>{let J=g[ae];J.cx=U+S*(K+.5),J.cy=M+P*(ee+.5),V.set(B,J),O+=X(J)}),x.cx=Q,x.cy=q,V.set("confusion",x),O+=X(x);let v=(B,K,ee)=>B===x?((K-Q)/(y+4))**2+((ee-q)/(_+4))**2<=1:Math.abs(K-B.cx)<=B.w/2+8&&Math.abs(ee-B.cy)<=B.h/2+8,W="",H=new Map;for(let B of e.transitions){let K=V.get(B.from),ee=V.get(B.to);if(!K||!ee||K===ee)continue;let ae=B.from<B.to?`${B.from} ${B.to}`:`${B.to} ${B.from}`,J=H.get(ae)??0;H.set(ae,J+1);let se=ee.cx-K.cx,me=ee.cy-K.cy,Ae=Math.hypot(se,me)||1,de=(K.cx+ee.cx)/2,oe=(K.cy+ee.cy)/2,ye=-me*(de-Q)+se*(oe-q)>=0?1:-1,ce=-me/Ae*ye,fe=se/Ae*ye,be=(K!==x&&ee!==x&&Math.abs(se)>1&&Math.abs(me)>1?2*(Math.hypot(y*ce,_*fe)+16):Ae*.15)+J*56,re=de+ce*be,j=oe+fe*be,ie=Ee=>{let Ne=1-Ee;return[Ne*Ne*K.cx+2*Ne*Ee*re+Ee*Ee*ee.cx,Ne*Ne*K.cy+2*Ne*Ee*j+Ee*Ee*ee.cy]},ue=(Ee,Ne,Me,Ce)=>{for(let Oe=0;Oe<16;Oe++){let We=(Ne+Me)/2;v(Ee,...ie(We))===Ce?Ne=We:Me=We}return(Ne+Me)/2},ge=48,Se=1;for(;Se<=ge&&v(K,...ie(Se/ge));)Se++;if(Se>ge)continue;let we=ue(K,(Se-1)/ge,Se/ge,!0);for(;Se<=ge&&!v(ee,...ie(Se/ge));)Se++;let ke=Se>ge?1:ue(ee,(Se-1)/ge,Se/ge,!1),[Le,Fe]=ie(we),[He,_e]=ie(ke),Pe=(Ee,Ne,Me)=>(1-we)*(1-ke)*Ee+((1-we)*ke+we*(1-ke))*Ne+we*ke*Me,Ye=Pe(K.cx,re,ee.cx),Ue=Pe(K.cy,j,ee.cy),he=Math.hypot(He-Ye,_e-Ue)||1,ne=(He-Ye)/he,pe=(_e-Ue)/he,Re=bt("arrow_point",He,_e,ne,pe,"var(--_l)");He-=ne*ht("arrow_point"),_e-=pe*ht("arrow_point");let le="";if(B.label){let Ee=De(B.label,!1,a,o,qm),[Ne,Me]=ie((we+ke)/2),Ce=Math.abs(ce)*Ee.width/2+Math.abs(fe)*Ee.height/2+6,Oe=Ee.width/2+4,We=Math.min(Math.max(Ne+ce*Ce,U+Oe),Math.max(Y-Oe,U+Oe));le=Ie(Ee,We,Me+fe*Ce,` class="pele-edge-label" font-size="${o}"`,c)}W+=`<g class="pele-edge" data-id="${B.from}-${B.to}"><path d="M${d(Le)},${d(Fe)}Q${d(Ye)},${d(Ue)} ${d(He)},${d(_e)}" fill="none" stroke="var(--_l)"/>`+Re+le+"</g>"}let G=Math.ceil(Math.max(I,k.width)+2*i),te=Math.ceil(D+w+2*i),Z=Ie(k,U+I/2,i+k.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-cynefin-regions">${T}</g>`+b+$+O+(W?`<g class="pele-edges">${W}</g>`:"");return{svg:Ze("cynefin",G,te,r,n,e,Z),width:G,height:te,links:[]}}var eg={type:"cynefin",parse:(e,t,n)=>Um(Ym(e),n),render:Jm};function Yw(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}var ja=class{type="er";direction="TB";entities=new Map;relationships=[];classes=new Map;subgraphs=[];title;accTitle;accDescr;subgraphLookup=new Map;claimed=new Set;addEntity(t,n=""){let r=this.entities.get(t);return r===void 0?(r={id:`entity-${t}-${this.entities.size}`,label:t,alias:n,attributes:[],cssClasses:"default",cssStyles:[]},this.entities.set(t,r)):!r.alias&&n&&(r.alias=n),r}addAttributes(t,n){let r=this.addEntity(t);for(let o=n.length-1;o>=0;o--){let s=n[o];s.keys??=[],s.comment??="",r.attributes.push(s)}}addRelationship(t,n,r,o){let s=this.subgraphLookup.has(t)?t:this.addEntity(t).id,a=this.subgraphLookup.has(r)?r:this.addEntity(r).id;this.relationships.push({entityA:s,roleA:n,entityB:a,relSpec:o})}setDirection(t){this.direction=t}addCssStyles(t,n){if(n)for(let r of t){let o=this.entities.get(r);if(o)for(let a of n)o.cssStyles.push(a);let s=this.subgraphLookup.get(r);if(s)for(let a of n)s.cssStyles.push(a)}}addClass(t,n){for(let r of t){let o=this.classes.get(r);if(o===void 0&&(o={id:r,styles:[],textStyles:[]},this.classes.set(r,o)),!!n)for(let s of n)s.includes("color")&&o.textStyles.push(s.replace("fill","bgFill")),o.styles.push(s)}}setClass(t,n){for(let r of t){let o=this.entities.get(r);if(o)for(let a of n)o.cssClasses+=" "+a;let s=this.subgraphLookup.get(r);if(s)for(let a of n)s.classes.push(a)}}addSubGraph(t,n,r){let o=t.text.trim(),s=new Set,a=[],i;for(let l of n.flat()){if(typeof l!="string"){l?.stmt==="dir"&&(i=l.value);continue}let f=l.trim();f===""||s.has(f)||(s.add(f),this.claimed.has(l)||a.push(l))}for(let l of a)this.claimed.add(l);let c={id:o,nodes:a,title:(r.text||"").trim(),classes:[],cssStyles:[],dir:i,labelType:Yw(r.type)};return this.subgraphs.push(c),this.subgraphLookup.set(o,c),o}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
70
+ `)}};var eu=["$end","INVALID","ER_DIAGRAM","EOF","NEWLINE","COLON","STYLE_SEPARATOR","BLOCK_START","BLOCK_STOP","SQS","SQE","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","END","SUBGRAPH","direction_tb","direction_bt","direction_rl","direction_lr","CLASSDEF","UNICODE_TEXT","STYLE_TEXT","COMMA","CLASS","STYLE","SEMI","NUM","BRKT","ENTITY_NAME","DECIMAL_NUM","ENTITY_ONE","ATTRIBUTE_WORD","ATTRIBUTE_KEY","COMMENT","ZERO_OR_ONE","ZERO_OR_MORE","ONE_OR_MORE","ONLY_ONE","MD_PARENT","NON_IDENTIFYING","IDENTIFYING","WORD","CHAR"];var fo=1,Xa=2,ru=4,po=8,qn=new Uint8Array(128);for(let e=0;e<128;e++){let t=e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95,n=t&&(e<48||e>57);t&&(qn[e]|=fo|Xa|po),n&&(qn[e]|=ru)}for(let e of"-*")qn[e.charCodeAt(0)]|=fo|Xa|po;qn[46]|=fo|po;qn[42]|=ru;for(let e of"[](),")qn[e.charCodeAt(0)]|=po;var Hw=/accTitle\s*:\s*/iy,Kw=/accDescr\s*:\s*/iy,zw=/accDescr\s*\{\s*/iy,Vw=[/.*direction\s+TB[^\n]*/iy,/.*direction\s+BT[^\n]*/iy,/.*direction\s+RL[^\n]*/iy,/.*direction\s+LR[^\n]*/iy],tu=/direction/gi,nu=/[\n\r\u2028\u2029]/g;function tg(e,t){return e<128?(qn[e]&t)!==0:e>=192||e===181}function ng(e){let t=e.length,n=[],r=[],o=[],s=0,a=0,i=-2,c=0,l=-1,f=-2,p=-1,u=-1,m=-1,h=(Y,z,R)=>{n.push(Y),r.push(e.slice(z,R)),o.push(z),a=R},g=(Y,z)=>(Y.lastIndex=z,Y.test(e)?Y.lastIndex:-1),x=Y=>{for(let z=0;z<Y.length;z++){let R=Y.charCodeAt(z),L=e.charCodeAt(a+z);if(L!==R&&(R<97||R>122||(L|32)!==R))return!1}return!0},y=Y=>x(Y)&&!Qe(e.charCodeAt(a+Y.length)),_=Y=>{let z=e.charCodeAt(Y);return z>=65&&z<=90?z+32:z},S=Y=>(nu.lastIndex=Y,nu.test(e)?nu.lastIndex-1:t),P=Y=>{for(;ft(e.charCodeAt(Y));)Y++;return Y},k=()=>{if(i===-1||i<a&&(tu.lastIndex=a,i=tu.test(e)?tu.lastIndex-9:-1,i===-1)||a<c||(l<a&&(l=S(a)),i>=l))return!1;for(let Y=0;Y<4;Y++){let z=g(Vw[Y],a);if(z>=0)return h(18+Y,a,z),!0}return c=l,!1},w=()=>{let Y=e.indexOf('"',a+1);if(Y===-1){h(45,a,a+1);return}let z=Y>a+1;for(let R=a+1;z&&R<Y;R++){let L=e.charCodeAt(R);(L===37||L===92||L===13||L===10||L===11||L===8)&&(z=!1)}h(z?31:44,a,Y+1)},I=Y=>{let z=e.charCodeAt(a+1);if(z===43&&(Y===49||Y===48)){h(Y===49?39:38,a,a+2);return}let R=P(a+1);if(e.charCodeAt(R)===46&&ft(e.charCodeAt(R+1))){h(32,a,P(R+2));return}if(Y===49){if(Be(z)){let L=a+2;for(;Be(e.charCodeAt(L));)L++;let F=e.charCodeAt(L);if(Qe(F)||F===34||F===39){h(40,a,a+1);return}}else if(z===45||z===46){let L=e.charCodeAt(a+2);if(L===45||L===46){h(40,a,a+1);return}}if(!Qe(z)){h(33,a,a+1);return}}h(29,a,R)},D=Y=>{let z=e.charCodeAt(a+1);switch(Y){case 101:if(y("erdiagram"))h(2,a,a+9);else if(y("end")){let R=a+3;for(;Be(e.charCodeAt(R));)R++;h(16,a,R)}else return!1;return!0;case 115:if(y("style"))s=6,h(27,a,a+5);else if(y("subgraph"))h(17,a,a+8);else return!1;return!0;case 99:if(y("classdef"))s=6,h(22,a,a+8);else if(y("class"))h(26,a,a+5);else return!1;return!0;case 111:if(y("one or zero"))h(37,a,a+11);else if(y("one or more")||y("one or many"))h(39,a,a+11);else if(y("one"))h(40,a,a+3);else if(y("only one"))h(40,a,a+8);else if(z===124)h(37,a,a+2);else if(z===123)h(38,a,a+2);else if(y("optionally to"))h(42,a,a+13);else return!1;return!0;case 122:if(y("zero or one"))h(37,a,a+11);else if(y("zero or more")||y("zero or many"))h(38,a,a+12);else return!1;return!0;case 109:if(x("many(0)"))h(38,a,a+7);else if(x("many(1)"))h(39,a,a+7);else if(y("many"))h(38,a,a+4);else return!1;return!0;case 116:return y("to")?(h(43,a,a+2),!0):!1;case 117:return z!==46&&z!==45&&z!==124?!1:(h(41,a,a+1),!0);case 124:if(_(a+1)===111&&!Qe(e.charCodeAt(a+2)))h(37,a,a+2);else if(z===124)h(40,a,a+2);else if(z===123)h(39,a,a+2);else return!1;return!0;case 125:if(_(a+1)===111&&!Qe(e.charCodeAt(a+2)))h(38,a,a+2);else if(z===124)h(39,a,a+2);else return!1;return!0;case 46:return z!==46&&z!==45?!1:(h(42,a,a+2),!0);case 45:if(z===45)h(43,a,a+2);else if(z===46)h(42,a,a+2);else return!1;return!0}return!1},U=Y=>{let z;if((Y===97||Y===65)&&x("acc")){if((z=g(Hw,a))>=0){s=3,h(11,a,z);return}if((z=g(Kw,a))>=0){s=4,h(13,a,z);return}if((z=g(zw,a))>=0){s=5,a=z;return}}if(!k()){switch(Y){case 32:case 9:case 13:z=a+1;for(let R=e.charCodeAt(z);R===32||R===9||R===13;R=e.charCodeAt(z))z++;a=z;return;case 10:for(z=a+1;e.charCodeAt(z)===10;)z++;h(4,a,z);return;case 34:w();return;case 123:s=1,h(7,a,a+1);return;case 35:h(30,a,a+1);return;case 44:h(25,a,a+1);return;case 58:e.charCodeAt(a+1)===58&&e.charCodeAt(a+2)===58?h(6,a,a+3):h(5,a,a+1);return;case 91:h(9,a,a+1);return;case 93:h(10,a,a+1);return}if(ft(Y)){I(Y);return}if(!D(Y>=65&&Y<=90?Y+32:Y)){if(Y>=128||(qn[Y]&fo)!==0){z=a+1;for(let R=e.charCodeAt(z);R>=128||(qn[R]&fo)!==0;R=e.charCodeAt(z))z++;h(23,a,z);return}h(45,a,a+1)}}},M=()=>{if(f===-1||f<a&&(f=e.indexOf("~",a),f===-1))return!1;if(m<a){let z=a;for(;z<t&&!Be(e.charCodeAt(z));)z++;m=z}if(f>=m||(p<a&&(p=S(a),u=e.lastIndexOf("~",p-1)),u<=f))return!1;let Y=u+1;for(;Y<t&&!Be(e.charCodeAt(Y));)Y++;return h(34,a,Y),!0},Q=Y=>{if(Be(Y)){for(a++;Be(e.charCodeAt(a));)a++;return}let z=Y|32;if((z===112||z===102||z===117)&&(e.charCodeAt(a+1)|32)===107&&!Qe(e.charCodeAt(a+2))){h(35,a,a+2);return}if(!M()){if(tg(Y,ru)){let R=a+1;for(;R<t&&tg(e.charCodeAt(R),po);)R++;h(34,a,R);return}if(Y===96){s=2,a++;return}if(Y===34){let R=e.indexOf('"',a+1);if(R!==-1){h(36,a,R+1);return}}else if(Y===125){s=0,h(8,a,a+1);return}h(45,a,a+1)}};for(;a<t;){let Y=e.charCodeAt(a),z;switch(s){case 0:U(Y);break;case 1:Q(Y);break;case 2:Y===96?(s=1,a++):(z=e.indexOf("`",a),h(34,a,z===-1?t:z));break;case 3:case 4:z=e.indexOf(`
71
+ `,a),h(s===3?12:14,a,z===-1?t:z),s=0;break;case 5:Y===125?(s=0,a++):(z=e.indexOf("}",a),h(15,a,z===-1?t:z));break;case 6:if(Y===10){for(z=a+1;e.charCodeAt(z)===10;)z++;s=0,h(4,a,z)}else if(Be(Y))for(a++;Be(e.charCodeAt(a));)a++;else if(Y===58)h(5,a,a+1);else if(Y===44)h(25,a,a+1);else if(Y===35)h(30,a,a+1);else if(Y===59)h(28,a,a+1);else if(Y>=128||(qn[Y]&Xa)!==0){z=a+1;for(let R=e.charCodeAt(z);R>=128||(qn[R]&Xa)!==0;R=e.charCodeAt(z))z++;h(24,a,z)}else return n.push(1),r.push(""),o.push(a),{types:n,texts:r,starts:o};break}}let q=s===0?3:s===3?12:s===4?14:s===5?15:-1;return q!==-1&&(n.push(q),r.push(""),o.push(t)),n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o}}var su=new Map([[37,"ZERO_OR_ONE"],[38,"ZERO_OR_MORE"],[39,"ONE_OR_MORE"],[40,"ONLY_ONE"],[41,"MD_PARENT"]]),jw=["TB","BT","RL","LR"],rg="'UNICODE_TEXT', 'NUM', 'ENTITY_NAME', 'DECIMAL_NUM', 'ENTITY_ONE'",Xw="'ZERO_OR_ONE', 'ZERO_OR_MORE', 'ONE_OR_MORE', 'ONLY_ONE', 'MD_PARENT'",qa="'EOF', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'SUBGRAPH', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'CLASSDEF', 'CLASS', 'STYLE', "+rg;function sg(e,t){let{types:n,texts:r,starts:o}=ng(e),s=0,a=I=>{let D=n[s];throw D===1?it("er",e,o[s],"",!0):it("er",e,o[s],`Expecting ${I}, got '${D===45?r[s]:eu[D]}'`)},i=I=>(n[s]!==I&&a(`'${eu[I]}'`),r[s++]),c=()=>{let I=n[s];I!==4&&I!==28&&I!==3&&a("'EOF', 'NEWLINE', 'SEMI'"),s++},l=I=>I===23||I===31||I===29||I===32||I===33,f=()=>{let I=n[s];l(I)||a(rg);let D=r[s++];return I===31?D.slice(1,-1):D},p=()=>{let I=[];for(;;){let D=n[s];if(D!==23&&D!==24&&a("'UNICODE_TEXT', 'STYLE_TEXT'"),I.push(r[s++]),n[s]!==25)return I;s++}},u=I=>I===24||I===29||I===5||I===30,m=()=>{let I=[];for(;;){u(n[s])||a("'STYLE_TEXT', 'COLON', 'NUM', 'BRKT'");let D=r[s++];for(;u(n[s]);)D+=r[s++];if(I.push(D),n[s]!==25)return I;s++}},h=()=>{let I=su.get(n[s++]),D=n[s];D!==43&&D!==42&&a("'NON_IDENTIFYING', 'IDENTIFYING'");let U=D===43?"IDENTIFYING":"NON_IDENTIFYING";s++;let M=su.get(n[s]);return M===void 0?a(Xw):(s++,{cardA:M,relType:U,cardB:I})},g=()=>{let I=n[s];I!==44&&I!==31&&I!==23&&a("'UNICODE_TEXT', 'ENTITY_NAME', 'WORD'");let D=r[s++];return I===23?D:D.slice(1,-1)},x=I=>n[s]===45&&r[s]===I,y=()=>{let I=[];do{let D=i(34);x("?")&&(D+=r[s++]),n[s]!==34&&a(D.endsWith("?")?"'ATTRIBUTE_WORD'":"'ATTRIBUTE_WORD', '?'");let U={type:D,name:r[s++]};if(n[s]===35){let M=[r[s++]];for(;x(",");)s++,M.push(i(35));U.keys=M}n[s]===36&&(U.comment=r[s++].slice(1,-1)),I.push(U)}while(n[s]!==8);return I.reverse()},_=()=>{if(n[s]!==7)return;if(s++,n[s]===8){s++;return}let I=y();return s++,I},S=()=>{let I=f(),D=n[s];if(D===9){s++;let Q=f();i(10);let q;n[s]===6&&(s++,q=p());let Y=_();return t.addEntity(I,Q),Y&&t.addAttributes(I,Y),q&&t.setClass([I],q),[I]}let U;if(D===6&&(s++,U=p(),D=n[s]),su.has(D)){let Q=h(),q=f(),Y;n[s]===6&&(s++,Y=p()),i(5);let z=g();return t.addEntity(I),t.addEntity(q),t.addRelationship(I,z,q,Q),U&&t.setClass([I],U),Y&&t.setClass([q],Y),[I,q]}let M=_();return t.addEntity(I),M&&t.addAttributes(I,M),U&&t.setClass([I],U),[I]};i(2);let P=[{id:"",title:"",list:[]}],k=P[0],w=!1;for(;;){let I=n[s];switch(I){case 4:s++;break;case 3:s++,w&&a(`'END', ${qa}`);return;case 16:{w||a(qa),s++;let D=t.addSubGraph({text:k.id},k.list,{text:k.title});P.pop(),k=P[P.length-1],w=P.length>1,w&&k.list.push(D);break}case 17:{s++;let D=f(),U=D;if(n[s]===9){for(s++,U=f();l(n[s]);)U+=" "+f();i(10)}c(),k={id:D,title:U,list:[]},P.push(k),w=!0;break}case 11:{s++;let D=i(12).trim();t.setAccTitle(D),w&&k.list.push(D);break}case 13:{s++;let D=i(14).trim();t.setAccDescription(D),w&&k.list.push(D);break}case 15:{let D=r[s++].trim();t.setAccDescription(D),w&&k.list.push(D);break}case 18:case 19:case 20:case 21:{s++;let D=jw[I-18];w?k.list.push({stmt:"dir",value:D}):t.setDirection(D);break}case 22:{let D=r[s++],U=p(),M=m();c(),t.addClass(U,M),w&&k.list.push(D);break}case 26:{let D=r[s++],U=p();t.setClass(U,p()),w&&k.list.push(D);break}case 27:{let D=r[s++],U=p(),M=m();c(),t.addCssStyles(U,M),w&&k.list.push(D);break}default:{l(I)||a(w?`'END', ${qa}`:qa);let D=S();if(w)for(let U of D)k.list.push(U)}}}}var qw=[];function ig(e){let t=[],n=[],r=e.subgraphs,o=c=>{let l=[];for(let f of c){let p=e.classes.get(f);if(p!==void 0){for(let u of p.styles)l.push(u.trim());for(let u of p.textStyles)l.push(u.trim())}}return l},s=new Map,a=new Set;for(let c=r.length-1;c>=0;c--){let l=r[c];a.add(l.id);for(let f of l.nodes)s.set(f,l.id)}for(let c=r.length-1;c>=0;c--){let l=r[c];t.push({id:l.id,label:l.title,alias:"",attributes:qw,isGroup:!0,parentId:s.get(l.id),cssStyles:l.cssStyles,cssCompiledStyles:o(l.classes),cssClasses:l.classes.join(" "),dir:l.dir,labelType:l.labelType})}let i=new Map;for(let[c,l]of e.entities){if(a.has(c)){i.set(l.id,c);continue}t.push({id:l.id,label:l.label,alias:l.alias,attributes:l.attributes,isGroup:!1,parentId:s.get(c),cssStyles:l.cssStyles,cssCompiledStyles:o(l.cssClasses.split(" ")),cssClasses:l.cssClasses,dir:void 0,labelType:"markdown"})}return e.relationships.forEach((c,l)=>{n.push({id:`id_${c.entityA}_${c.entityB}_${l}`,start:i.get(c.entityA)??c.entityA,end:i.get(c.entityB)??c.entityB,label:c.roleA,arrowTypeStart:c.relSpec.cardB.toLowerCase(),arrowTypeEnd:c.relSpec.cardA.toLowerCase(),pattern:c.relSpec.relType==="IDENTIFYING"?"solid":"dashed"})}),{nodes:t,edges:n}}var lr=18,og=5,ag=6,iu=10,cg=3.5;function Cs(e,t,n,r,o){let s=(f,p)=>d(t-r*f-o*p)+","+d(n-o*f+r*p),a=f=>`M${s(f,-og)}L${s(f,og)}`,i=`M${s(0,-ag)}L${s(iu,0)}L${s(0,ag)}`,c=f=>`<circle class="pele-marker" cx="${d(t-r*f)}" cy="${d(n-o*f)}" r="${cg}" fill="var(--_bg)"/>`,l=f=>`<path class="pele-marker" d="${f}"/>`;switch(e){case"only_one":return l(a(6)+a(10));case"zero_or_one":return l(a(6))+c(13.5);case"one_or_more":return l(i+a(iu+3.5));case"zero_or_more":return l(i)+c(iu+cg+.5);case"md_parent":return`<path class="pele-marker" d="M${s(0,0)}L${s(6,4)}L${s(12,0)}L${s(6,-4)}Z" fill="var(--_bg)"/>`}return""}var Qw=48,Zw=20,Jw=64,ho=20,mo=28,eR=38,lg=96,dg=18,tR=12,nR=9,ou=12,ug=16,au=9,rR=260,cu=1e6,sR=[],iR=18,oR=14,fg=' fill="var(--_s)" stroke="var(--_b)"';function pg(e,t,n){let r=e.er?.[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}function Qa(e,t,n,r,o){let s=e.lines;if(s.length===0)return"";if(s.length===1&&s[0].length===1&&s[0][0].icon===void 0&&s[0][0].style===0)return`<text${r} x="${d(t)}" y="${d(n)}">${je(s[0][0].text)}</text>`;let a=Er(e),i="",c="";for(let l of s){let f=!1;for(let m of l)m.icon!==void 0&&(f=!0);let p=t,u=!1;for(let m of l){if(m.icon!==void 0){let h=e.size*1.1;c+=`<svg class="pele-icon" data-icon="${$e(m.icon)}" x="${d(p)}" y="${d(n-e.size*.35-h/2)}" width="${d(h)}" height="${d(h)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${o?.(m.icon)??""}</svg>`}else if(m.text!==""){let h=f||!u?` x="${d(p)}" y="${d(n)}"`:"";i+=`<tspan${h}${rr(m.style&~a)}>${je(m.text)}</tspan>`,u=!0}p+=m.width}n+=e.lineHeight}return`<text${Kn(r,a)} xml:space="preserve">${i}</text>${c}`}function lu(e){let t=Hr(e);return t===e?e:t.replace(/</g,"&lt;").replace(/>/g,"&gt;")}function gg(e,t,n){return _n(e.direction)?Nt(n,r=>hg(e,t,n,r)):hg(e,t,n,!1)}function hg(e,t,n,r){let o=ig(e),s=n.fontSize??16,a=Math.round(s*.875),i=n.measurer??Je(n.fontFamily),c=n.padding??8,l=n.icons,f=new Map,p=[],u=[];o.nodes.forEach((A,T)=>f.set(A.id,T));let m=[],h=[],g=[],x=new Map,y=[];for(let A of o.edges){let T=f.get(A.start),b=f.get(A.end);if(T===void 0||b===void 0)continue;let N=De(A.label,!0,i,a,200),$;if(T===b){$={label:N,band:0,at:0};let X=x.get(T);X?X.push($):x.set(T,[$])}y.push($),g.push(A),h.push(N),m.push({src:T,dst:b,minlen:1,labelW:N.width>0?N.width+12:0,labelH:N.height>0?N.height+4:0,route:[],labelX:0,labelY:0})}let _=A=>{let T=A;for(let b=0;b<o.nodes.length;b++){let N=o.nodes[T].parentId,$=N===void 0?void 0:f.get(N);if($===void 0)break;let X=o.nodes[$].dir;if(X)return X==="LR"||X==="RL";T=$}return e.direction==="LR"||e.direction==="RL"};for(let A=0;A<o.nodes.length;A++){let T=o.nodes[A],b=At(T.cssStyles.length>0?T.cssCompiledStyles.concat(T.cssStyles):T.cssCompiledStyles),N=(b.bold?1:0)|(b.italic?2:0),$=b.fontSize??s,X=b.fontSize??a,V=b.fontSize??Math.round(s*.75),O=T.isGroup?De(T.label,!0,i,$,4e3,N):De(T.alias||T.label,!0,i,$,240,N),v=x.get(A)??sR,W=v.length>0&&!T.isGroup&&_(A),H={node:T,style:b,label:O,w:0,h:0,headH:0,rows:[],cols:[],rowSize:X,keySize:V,below:W},G=0,te=0;for(let K of v)K.band=Math.max(eR,W?K.label.width+12:K.label.height+6),te+=K.band,G=Math.max(G,W?K.label.height:K.label.width);let Z=Math.max(lg,W?te+8:0),B;if(T.isGroup)B=$t(0,0),B.isGroup=!0,B.dir=T.dir?tn(T.dir):void 0,B.padX=ho,B.padTop=H.label.height>0?H.label.height+16:ho,B.padBottom=ho,B.minW=Math.max(H.label.width+2*ho-12,lg);else{let K=Math.max(O.height,Math.round($*1.5));if(T.attributes.length===0)H.w=Math.max(O.width+2*dg,Z),H.h=Math.max(K+2*tR,W?0:te+8);else{let ae=Math.round(X*1.5),J=[0,0,0,0];for(let oe of T.attributes){let ye=[De(lu(oe.type),!0,i,X,cu,N),De(lu(oe.name),!0,i,X,cu,N),De(oe.keys.join(", "),!1,i,V,cu,N),De(lu(oe.comment),!0,i,X,rR,N)],ce=ae;for(let fe=0;fe<4;fe++)ye[fe].width>J[fe]&&(J[fe]=ye[fe].width),ye[fe].height>ce&&(ce=ye[fe].height);H.rows.push({cells:ye,h:ce+au}),H.h+=ce+au}let se=0,me=0;for(let oe of J)oe!==0&&(me+=oe+(se>0?ug:0),se++);H.w=Math.max(me+2*ou,O.width+2*dg,Z);let Ae=se>0?(H.w-me-2*ou)/se:0,de=ou;for(let oe of J)H.cols.push(de),oe>0&&(de+=oe+Ae+ug);H.headH=K+2*nR,H.h+=H.headH}let ee=v.length>0?2*(lr+mo*.75+10+G):0;B=W?$t(H.w,H.h+ee):$t(H.w+ee,H.h)}B.seq=p.length,p.push(H),u.push(B)}o.nodes.forEach((A,T)=>{u[T].parent=A.parentId!==void 0?f.get(A.parentId)??-1:-1});let S=Sn(u,m,r?"TB":tn(e.direction),{nodeSep:pg(t,"nodeSpacing",Qw),edgeSep:Zw,rankSep:pg(t,"rankSpacing",Jw),portSep:24});cR(m,u,p);let P=S.width;for(let[A,T]of x){let b=u[A];if(!b.isGroup)continue;let N=0;for(let $ of T)N=Math.max(N,$.label.width);P=Math.max(P,b.x+b.w/2+lr+mo*.75+10+N)}let k=De(e.title,!1,i,s,4e3,1),w=k.height>0?k.height+12:0,I=Math.max(P,k.width),D=c+(I-P)/2,U=c+w;vr(u,m,D,U);let M=Math.ceil(I+2*c),Q=Math.ceil(S.height+w+2*c),q=[],Y=new Map,z=!1;for(let A of u)A.isGroup&&(z=!0);if(z)for(let A of m)Vn(Y,A.route);let R="",L="";for(let A=0;A<p.length;A++){let T=p[A],b=u[A],N=T.node,$=wt(N.cssClasses.replace(/^default\s?/,""));if(b.isGroup){T.w=b.w,T.h=b.h;let B=b.x-b.w/2,K=b.y-b.h/2,ee=Pr(b,T.label.width,Y,ho);R+=`<g class="pele-cluster${$}" data-id="${$e(N.id)}"><rect x="${d(B)}" y="${d(K)}" width="${d(b.w)}" height="${d(b.h)}" rx="${Xe}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${T.style.shape}/>`+Ie(T.label,ee,K+8+T.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${T.style.text}`,l)+"</g>";continue}let X=T.w,V=T.h,O=-X/2,v=-V/2,W=T.style.text,H=`x="${d(O)}" y="${d(v)}" width="${d(X)}" height="${d(V)}" rx="${Xe}"`,G=Ie(T.label,0,T.rows.length>0?v+T.headH/2:0,` class="pele-label"${W}`,l),te=gt(N.alias||N.label);if(/ internal-link(?: |$)/.test($+" ")&&G!==""&&n.links!==!1){let B=Ar(zn(te),n)!==void 0,K=je(te);G=`<a class="internal-link"${B?` href="${K}"${xr(n)}`:""} data-href="${K}">${G}</a>`,q.push({id:N.label,href:te,internal:!0})}let Z;if(T.rows.length===0)Z=`<rect ${H}${fg}${T.style.shape}/>`+G;else{let B=Math.round(T.rowSize*1.5),K=T.style.stroke?je(T.style.stroke):"var(--_b)",ee="",ae="",J=v+T.headH;for(let me=0;me<T.rows.length;me++){let Ae=T.rows[me];if(me%2===0){let xe=`x="${d(O)}" width="${d(X)}"`;me===T.rows.length-1?ee+=`<rect ${xe} y="${d(J)}" height="${d(Ae.h)}" rx="${Xe}"/><rect ${xe} y="${d(J)}" height="${d(Ae.h/2)}"/>`:ee+=`<rect ${xe} y="${d(J)}" height="${d(Ae.h)}"/>`}let de=J+au/2+B/2+T.rowSize*.35,[oe,ye,ce,fe]=Ae.cells;ae+=Qa(oe,O+T.cols[0],de,` class="pele-er-type" fill="var(--_m)"${W}`,l)+Qa(ye,O+T.cols[1],de,` class="pele-er-name"${W}`,l)+Qa(ce,O+T.cols[2],de,` class="pele-er-keys" font-size="${T.keySize}" fill="var(--_m)"${W}`,l)+Qa(fe,O+T.cols[3],de,` class="pele-er-comment" fill="var(--_m)"${W}`,l),J+=Ae.h}let se=d(v+T.headH);Z=`<rect ${H}${fg}${T.style.shape}/><g class="pele-er-stripes" fill="var(--_bg)"${T.style.shape.includes("fill:")?' opacity="0.6"':""}>${ee}</g><path class="pele-er-divider" d="M${d(O)},${se}H${d(O+X)}" stroke="${K}"/><rect ${H} fill="none" stroke="var(--_b)"${T.style.line}/>`+G+`<g class="pele-er-attributes" font-size="${T.rowSize}">${ae}</g>`}L+=`<g class="pele-node pele-entity${$}" data-id="${$e(N.label)}" transform="translate(${d(b.x)},${d(b.y)})">${Z}</g>`}for(let[A,T]of x){let b=p[A],N=0;for(let V of T)N+=V.band;let $=Math.min(1,Math.max((b.below?b.w:b.h)-8,0)/N),X=-N*$/2;for(let V of T)V.band*=$,V.at=X+V.band/2,X+=V.band}let F="",E="";for(let A=0;A<m.length;A++){let T=m[A],b=g[A],N=h[A],$,X,V,O=y[A];if(O){let W=u[T.src],H=p[T.src],G=Math.max(Math.min(O.band/2-6,13),1),te=lr+mo*.75+6;if(H.below){let Z=W.x+O.at,B=W.y+H.h/2,K=d(B+lr),ee=d(B+lr+mo);$=`M${d(Z-G)},${d(B)}V${K}C${d(Z-G)},${ee} ${d(Z+G)},${ee} ${d(Z+G)},${K}V${d(B)}`,X=Cs(b.arrowTypeStart,Z-G,B,0,-1),V=Cs(b.arrowTypeEnd,Z+G,B,0,-1),T.labelX=Z,T.labelY=B+te+N.height/2}else{let Z=W.x+H.w/2,B=W.y+O.at,K=d(Z+lr),ee=d(Z+lr+mo);$=`M${d(Z)},${d(B-G)}H${K}C${ee},${d(B-G)} ${ee},${d(B+G)} ${K},${d(B+G)}H${d(Z)}`,X=Cs(b.arrowTypeStart,Z,B-G,-1,0),V=Cs(b.arrowTypeEnd,Z,B+G,-1,0),T.labelX=Z+te+N.width/2,T.labelY=B}}else{let W=aR(T.route);if(W.length<6)continue;mg(W,0,p[T.src],u[T.src]),mg(W,W.length-3,p[T.dst],u[T.dst]);let H=Math.abs(W[W.length-3]-W[0]),G=Math.abs(W[W.length-2]-W[1]),Z=W.length===6&&(H<.01||G<.01||Math.hypot(H,G)<=3*lr)?0:lr,B=yn(W,void 0,Z,Z);$=Z>0?`M${d(B.sx)},${d(B.sy)}L${B.d.slice(1)}L${d(B.ex)},${d(B.ey)}`:B.d,X=Cs(b.arrowTypeStart,B.sx,B.sy,B.sdx,B.sdy),V=Cs(b.arrowTypeEnd,B.ex,B.ey,B.edx,B.edy)}let v=b.pattern==="dashed";if(F+=`<g class="pele-edge pele-er-${v?"non-identifying":"identifying"}" data-id="${$e(b.id)}"><path d="${$}"${v?' stroke-dasharray="4 3"':""}/>`+X+V+"</g>",N.width>0){let W=T.labelX,H=T.labelY;E+=nn(b.id,N,W,H,"",l)}}return{svg:Ze("er",M,Q,s,n,e,Ie(k,M/2,c+k.height/2,' class="pele-title" font-weight="var(--_tw)"')+(R?`<g class="pele-clusters">${R}</g>`:"")+(F?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${F}</g>`:"")+(E?`<g class="pele-edge-labels" font-size="${a}">${E}</g>`:"")+`<g class="pele-nodes">${L}</g>`),width:M,height:Q,links:q}}function aR(e){let t=e.slice(0,3);for(let n=3;n<e.length;n+=3){let r=t.length-3,o=s=>Math.abs(t[r+s]-e[n+s])<.01&&Math.abs(e[n+s]-e[n+3+s])<.01;n+3<e.length&&(o(0)||o(1))||t.push(e[n],e[n+1],e[n+2])}return t}function cR(e,t,n){let r=new Map,o=(s,a,i,c)=>{let l=t[s],f=a[i]-l.x,p=a[i+1]-l.y,u;if(Math.abs(Math.abs(p)-l.h/2)<.5)u=p<0?0:2;else if(Math.abs(Math.abs(f)-l.w/2)<.5)u=f<0?3:1;else return;let m=s*4+u,h={route:a,at:i,toward:a[c+(u&1?1:0)]},g=r.get(m);g?g.push(h):r.set(m,[h])};for(let s of e){let a=s.route.length-3;s.src===s.dst||a<3||(o(s.src,s.route,0,3),o(s.dst,s.route,a,a-3))}for(let[s,a]of r){if(a.length<2)continue;let i=s>>2,c=(s&1)===1,l=t[i].isGroup?t[i]:n[i],f=c?l.h:l.w,p=Math.max(Math.min(iR,(f-2*oR)/(a.length-1)),0),u=c?t[i].y:t[i].x;a.sort((m,h)=>m.toward-h.toward);for(let m=0;m<a.length;m++)a[m].route[a[m].at+(c?1:0)]=u+(m-(a.length-1)/2)*p}}function mg(e,t,n,r){if(r.isGroup)return;let o=e[t]-r.x,s=e[t+1]-r.y;r.w!==n.w&&Math.abs(Math.abs(o)-r.w/2)<.5&&(e[t]-=Math.sign(o)*(r.w-n.w)/2),r.h!==n.h&&Math.abs(Math.abs(s)-r.h/2)<.5&&(e[t+1]-=Math.sign(s)*(r.h-n.h)/2)}var bg={type:"er",parse(e,t,n){let r=new ja;return n&&(r.title=n),sg(e,r),r},render:gg};var lR=new Map([["ui","ui"],["pcr","processor"],["processor","processor"],["rmo","readmodel"],["readmodel","readmodel"],["cmd","command"],["command","command"],["evt","event"],["event","event"]]),dR=new Map([["trigger",[0,"UI/Automation","UI/A: "]],["state",[100,"Command/Read Model","C/RM: "]],["stream",[200,"Events","Stream: "]]]);function uR(e){return e==="ui"||e==="processor"?"trigger":e==="event"?"stream":"state"}function du(e){let t=e.indexOf("{"),n=e.lastIndexOf("}"),o=(t!==-1&&n>t?e.slice(t+1,n):t===-1&&e.length>=2?e.slice(1,-1):"").replace(/\r/g,"").split(`
72
+ `);for(;o.length>0&&o[0].trim()==="";)o.shift();for(;o.length>0&&o[o.length-1].trim()==="";)o.pop();let s=1/0;for(let a of o)a.trim()!==""&&(s=Math.min(s,a.length-a.trimStart().length));return o.map(a=>a.slice(Math.min(s,a.length)).trimEnd()).join(`
73
+ `)}function yg(e,t){let n=new Set;for(let p of e.frames){if(n.has(p.name)){let u=vi(e.$source,p.$offset).line;throw new Ge(`Duplicate event modeling frame ID "${p.name}" on line ${u}`,"semantic",{type:"eventmodeling",line:u})}n.add(p.name)}let r=new Map;for(let p of e.dataEntities)r.has(p.name)||r.set(p.name,p.dataBlockValue);let o=new Map,s=new Map,a=(p,u)=>{let m=uR(p),h=u===void 0?m:`${m} ${u}`,g=o.get(h);if(!g){let[x,y,_]=dR.get(m),S=x;u!==void 0&&(S=s.get(m)??x+1,s.set(m,S+1)),g={index:S,label:u===void 0?y:_+u,group:m,namespace:u},o.set(h,g)}return g},i=[],c=new Map,l=[];e.frames.forEach((p,u)=>{let m=p.entityIdentifier.split("."),h=m.length===2?m[0]:void 0,g=lR.get(p.modelEntityType)??"event",x=p.dataInlineValue===void 0?void 0:du(p.dataInlineValue);if(p.dataReference){let _=r.get(p.dataReference.$refText);_!==void 0&&(x=du(_))}let y={id:p.name,kind:g,entity:p.entityIdentifier,name:m.length===2?m[1]:p.entityIdentifier,namespace:h,reset:p.$type==="EmResetFrame",lane:a(g,h),data:x,dataType:p.dataType};if(i.push(y),c.set(y.id,y),p.sourceFrames.length>0){let _=new Set(p.sourceFrames.map(S=>S.$refText));for(let S of i)_.has(S.id)&&l.push({source:S,target:y})}else if(u>0&&!y.reset){for(let _=u-1;_>=0;_--)if(i[_].lane!==y.lane){l.push({source:i[_],target:y});break}}});let f=p=>p.map(u=>u.entityIdentifier.$refText);return{type:"eventmodeling",title:e.title&&Bt(e.title)||t,accTitle:e.accTitle?Ft(e.accTitle).replace(/^\s+/g,""):void 0,accDescr:e.accDescr?Wt(e.accDescr).replace(/\n\s+/g,`
74
+ `):void 0,boxes:i,lanes:[...o.values()].sort((p,u)=>p.index-u.index),relations:l,notes:e.noteEntities.map(p=>({frame:p.sourceFrame.$refText,text:du(p.dataBlockValue),dataType:p.dataType})),specifications:e.gwtEntities.map(p=>({frame:p.sourceFrame.$refText,given:f(p.givenStatements),when:f(p.whenStatements),then:f(p.thenStatements)})),entities:e.modelEntities.map(p=>p.name)}}var uu=/[\t ]*accDescr(?:[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)|\s*({))/y;function fR(){let e=!1;return(t,n)=>{uu.lastIndex=n;let r=uu.exec(t);if(r===null)return-1;let o=uu.lastIndex;if(r[1]===void 0)return o;if(e)return-1;let s=t.indexOf("}",o);return e=s===-1,s+1||-1}}function pi(e="ACC_DESCR"){return{...Zt,name:e,scanner:fR}}var pu={name:"EM_ID",pattern:/[_a-zA-Z][\w_]*/y},hi=e=>({name:e,pattern:e,longer:[pu]}),go=e=>({name:e,pattern:e}),pR=["resetframe","readmodel","processor","timeframe","command","entity","event","jsobj","figma","given","json","salt","html","text","data","note","when","then","rmo","cmd","evt","pcr","uri"],hu=[{...Vt("eventmodeling"),longer:[pu]},...pR.map(hi),go("->>"),hi("gwt"),hi("ui"),hi("md"),hi("tf"),go("[["),go("]]"),hi("rf"),go("`"),go("."),pu,{name:"EM_FID",pattern:/\d{1,3}/y},{name:"EM_DATA_INLINE",pattern:/\{(.*)\}|"(.*)"|'(.*)'/y},{name:"EM_DATA_BLOCK",pattern:/\{[\t ]*\r?\n(?:[\S\s]*?\r?\n)?\}(?:\r?\n|(?!\S))/y},pi("EM_ACC_DESCR"),{...Yt,name:"EM_ACC_TITLE"},{...Ht,name:"EM_TITLE"},{name:"EM_WS",pattern:/\s+/y,hidden:!0},{...Pt,name:"EM_YAML"},{...Kt,name:"EM_DIRECTIVE"},{...zt,name:"EM_SINGLE_LINE_COMMENT"},{name:"EM_ML_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0},{name:"EM_SL_COMMENT",pattern:/\/\/[^\n\r]*/y,hidden:!0}],jt=e=>hu.findIndex(t=>t.name===e),Za=e=>new Set(e.map(jt)),It={keyword:0,arrow:jt("->>"),open:jt("[["),close:jt("]]"),tick:jt("`"),dot:jt("."),id:jt("EM_ID"),frameId:jt("EM_FID"),inline:jt("EM_DATA_INLINE"),block:jt("EM_DATA_BLOCK"),accDescr:jt("EM_ACC_DESCR"),accTitle:jt("EM_ACC_TITLE"),title:jt("EM_TITLE"),entity:jt("entity"),data:jt("data"),note:jt("note"),gwt:jt("gwt"),given:jt("given"),when:jt("when"),then:jt("then")},Eg=Za(["tf","timeframe"]),hR=Za(["rf","resetframe"]),fu=Za(["rmo","readmodel","ui","cmd","command","evt","event","pcr","processor"]),mR=Za(["json","jsobj","figma","salt","uri","md","html","text"]);function Ag(e){let t=new Dt(vt(e,hu,"eventmodeling"),hu,"eventmodeling"),n={$type:"EventModel",modelEntities:[],frames:[],dataEntities:[],noteEntities:[],gwtEntities:[],$source:e},r=c=>t.kinds[t.i]===c,o=(c,l)=>c.has(t.kinds[t.i])?t.take():t.fail(l),s=()=>{let c=t.expect(It.id);for(;t.accept(It.dot);)c+="."+t.expect(It.id);return c},a=()=>{if(!t.accept(It.tick))return;let c=o(mR,"a data type");return t.expect(It.tick),c},i=()=>{let c=[];do o(fu,"an entity type"),c.push({$type:"EmGwtStatement",entityIdentifier:{$refText:t.expect(It.id)}});while(fu.has(t.kinds[t.i]));return c};for(t.expect(It.keyword);!r(-1);){let c=t.kinds[t.i];if(c===It.accDescr)n.accDescr=t.take();else if(c===It.accTitle)n.accTitle=t.take();else if(c===It.title)n.title=t.take();else if(c===It.entity)t.i++,n.modelEntities.push({$type:"EmModelEntity",name:s()});else if(Eg.has(c)||hR.has(c)){let l={$type:Eg.has(c)?"EmTimeFrame":"EmResetFrame",name:"",modelEntityType:"",entityIdentifier:"",sourceFrames:[],$offset:t.tokens.starts[t.i]};for(t.i++,l.name=t.expect(It.frameId),l.modelEntityType=o(fu,"an entity type"),l.entityIdentifier=s();t.accept(It.arrow);)l.sourceFrames.push({$refText:t.expect(It.frameId)});if(t.accept(It.open)&&(l.dataReference={$refText:t.expect(It.id)},t.expect(It.close)),r(It.tick)||r(It.inline)){let f=a();f!==void 0&&(l.dataType=f),l.dataInlineValue=t.expect(It.inline)}n.frames.push(l)}else if(c===It.data){t.i++;let l={$type:"EmDataEntity",name:t.expect(It.id),dataBlockValue:""},f=a();f!==void 0&&(l.dataType=f),l.dataBlockValue=t.expect(It.block),n.dataEntities.push(l)}else if(c===It.note){t.i++;let l={$type:"EmNoteEntity",sourceFrame:{$refText:t.expect(It.frameId)},dataBlockValue:""},f=a();f!==void 0&&(l.dataType=f),l.dataBlockValue=t.expect(It.block),n.noteEntities.push(l)}else if(c===It.gwt){t.i++;let l={$type:"EmGwt",sourceFrame:{$refText:t.expect(It.frameId)},givenStatements:[],whenStatements:[],thenStatements:[]};t.expect(It.given),l.givenStatements=i(),t.accept(It.when)&&(l.whenStatements=i()),t.expect(It.then),l.thenStatements=i(),n.gwtEntities.push(l)}else t.fail("a frame, an entity, a data block, a note, or a specification")}return n}var Rg=new Map([["command",0],["event",1],["readmodel",2],["processor",6]]),sn=12,kn=10,gR=96,xg=16,bR=80,Ja=12,Sg=8,yR=48,_g=80,Tg=8;function mu(e,t){let n=[];for(let r of gt(e).split(`
75
+ `)){if(r.length<=t){n.push(r);continue}for(let o=0;o<r.length;o+=t)n.push(r.slice(o,o+t))}return n}function ec(e,t,n,r,o){let s="";for(let a=0;a<e.length;a++)e[a]!==""&&(s+=`<tspan x="${d(t)}" y="${d(n+a*r)}">${je(e[a])}</tspan>`);return s===""?"":`<text${o} xml:space="preserve">${s}</text>`}function Cg(e,t,n){return Nt(n,r=>ER(e,t,n,r))}function ER(e,t,n,r){if(r)return SR(e,n);let o=n.fontSize??16,s=Math.round(o*.875),a=Math.round(o*.8125),i=Math.round(o*.75),c=Math.round(i*1.4),l=Math.round(a*1.5),f=n.measurer??Je(n.fontFamily,n.fontFamilyMono),p=n.padding??8,u=(b,N,$)=>{let X=0;for(let V of b)X=Math.max(X,f.width(V,N,$));return X},m=new Map,h=0;for(let b of e.lanes){let N=De(b.label,!1,f,a,4e3,1);h=Math.max(h,N.width),m.set(b,{lane:b,label:N,right:-1/0,y:0,h:0})}h+=2*Ja;let g=[],x=new Map,y;for(let b of e.boxes){let N=m.get(b.lane),$=De(b.name,!1,f,s,4e3,1),X=b.data?mu(b.data,yR):[],V=Math.max(gR,Math.max($.width,u(X,i,4))+2*sn),O=2*kn+$.height+(X.length>0?6+X.length*c:0),v=0;if(y){let H=y.x+Math.max(y.w/2,y.w-bR);v=y.box.lane===b.lane?N.right+xg:Math.max(H,N.right+xg)}let W={box:b,name:$,data:X,x:v,y:0,w:V,h:O};N.right=v+V,N.h=Math.max(N.h,O),g.push(W),x.set(b,W),y=W}let _=0;for(let b of g)_=Math.max(_,b.x+b.w);let S=h+_+Ja,P=De(e.title,!1,f,o,4e3,1),k=P.height>0?P.height+12:0,w=p,I=p+k,D=I,U="";for(let b of m.values())b.y=D,b.h+=2*Ja,U+=`<g class="pele-cluster pele-em-lane" data-id="${$e(b.lane.label)}"><rect x="${d(w)}" y="${d(D)}" width="${d(S)}" height="${d(b.h)}" rx="${Xe}" fill="var(--_s)"/>`+Ie(b.label,w+Ja+b.label.width/2,D+b.h/2,` class="pele-cluster-label" font-size="${a}" font-weight="var(--_hw)" fill="var(--_m)"`)+"</g>",D+=b.h+Sg;let M=m.size>0?D-Sg:I,Q="";for(let b of g){let N=m.get(b.box.lane);b.x+=w+h,b.y=N.y+(N.h-b.h)/2;let $=Rg.get(b.box.kind),X=`x="${d(b.x)}" y="${d(b.y)}" width="${d(b.w)}" height="${d(b.h)}" rx="${Xe}"`,V=$===void 0?`<rect ${X} fill="var(--_bg)" stroke="var(--_b)"/>`:`<rect ${X} fill="var(--_bg)"/><rect ${X} fill="${ct($)}" fill-opacity="0.22" stroke="${ct($)}"/>`,O=b.y+kn+b.name.height/2,v=Ie(b.name,b.x+b.w/2,O,` class="pele-label" font-size="${s}" font-weight="var(--_hw)"`)+ec(b.data,b.x+sn,b.y+kn+b.name.height+6+c/2+i*.35,c,` class="pele-em-data" font-family="${Vi}" font-size="${i}"`);Q+=`<g class="pele-node pele-em-${b.box.kind}${b.box.reset?" pele-em-reset":""}" data-id="${$e(b.box.id)}">${V}${v}</g>`}let q="",Y=ht("arrow_point");for(let b of e.relations){let N=x.get(b.source),$=x.get(b.target);if(!N||!$||N===$)continue;let X,V;if(N.box.lane===$.box.lane){let O=$.x>=N.x,v=O?N.x+N.w:N.x,W=O?$.x:$.x+$.w,H=N.y+N.h/2,G=$.y+$.h/2,te=W>=v?1:-1;X=`M${d(v)},${d(H)}L${d(W-te*Y)},${d(G)}`,V=bt("arrow_point",W,G,te,0,"var(--_l)")}else{let O=$.y>N.y,v=Math.max(N.x,$.x),W=Math.min(N.x+N.w,$.x+$.w),H=J=>Math.min(24,J/4),G=W-v>=16?(v+W)/2:$.x>N.x?N.x+N.w-H(N.w):N.x+H(N.w),te=W-v>=16?G:$.x>N.x?$.x+H($.w):$.x+$.w-H($.w),Z=O?N.y+N.h:N.y,B=O?$.y:$.y+$.h,K=O?1:-1,ee=B-K*Y,ae=(Z+ee)/2;X=G===te?`M${d(G)},${d(Z)}V${d(ee)}`:`M${d(G)},${d(Z)}C${d(G)},${d(ae)} ${d(te)},${d(ae)} ${d(te)},${d(ee)}`,V=bt("arrow_point",te,B,0,K,"var(--_l)")}q+=`<g class="pele-edge" data-id="${$e(b.source.id)}-${$e(b.target.id)}"><path d="${X}" fill="none" stroke="var(--_l)"/>${V}</g>`}let z=new Map;for(let b of e.boxes)z.set(b.id,b.name);let R="",L=0,F=(b,N,$,X)=>{let V=De(`${N} · ${$}${z.has($)?" "+z.get($):""}`,!1,f,a,4e3,1),O=Math.max(V.width,u(X,a,0))+2*sn,v=2*kn+V.height+X.length*l,W=M+(R===""&&m.size===0?0:Tg);R+=`<g class="pele-em-${b}" data-id="${$e($)}"><rect x="${d(w)}" y="${d(W)}" width="${d(O)}" height="${d(v)}" rx="${Xe}" fill="var(--_bg)" stroke="var(--_b)"/>`+Ie(V,w+sn+V.width/2,W+kn+V.height/2,` font-size="${a}" font-weight="var(--_hw)"`)+ec(X,w+sn,W+kn+V.height+l/2+a*.35,l,` font-size="${a}"`)+"</g>",M=W+v,L=Math.max(L,O)};for(let b of e.notes)F("note","Note",b.frame,mu(b.text,_g));for(let b of e.specifications){let N=[`Given ${b.given.join(", ")}`];b.when.length>0&&N.push(`When ${b.when.join(", ")}`),N.push(`Then ${b.then.join(", ")}`),F("specification","Given / When / Then",b.frame,N.flatMap($=>mu($,_g)))}let E=Math.max(m.size>0?S:0,L,P.width),C=Math.ceil(E+2*p),A=Math.ceil(M+p),T=Ie(P,C/2,p+P.height/2,' class="pele-title" font-weight="var(--_tw)"')+U+q+Q+R;return{svg:Ze("eventmodeling",C,A,o,n,e,T),width:C,height:A,links:[]}}var wg=8,AR=120,xR=20;function SR(e,t){let n=t.fontSize??16,r=Math.round(n*.875),o=Math.round(n*.75),s=t.padding??8,a=t.measurer??Je(t.fontFamily,t.fontFamilyMono),i=Math.max(160,(t.maxWidth??320)-2*s),c=new Map(e.boxes.map((z,R)=>[z,R])),l=new Map,f=new Set;for(let z of e.relations){let R=c.get(z.source),L=c.get(z.target);if(R===void 0||L===void 0||R===L)continue;if(Math.abs(R-L)<2){f.add(e.boxes[Math.max(R,L)]);continue}let F=l.get(z.target);F?(F[0]=Math.min(F[0],R),F[1]=Math.max(F[1],R)):l.set(z.target,[Math.min(R,L),Math.max(R,L)])}let p=new Map,u=[];for(let[z,[R,L]]of[...l].sort((F,E)=>F[1][0]-E[1][0])){let F=u.findIndex(E=>E<R);F<0&&(F=u.length),u[F]=L,p.set(z,F)}let m=24+wg*Math.max(0,u.length-1),h=Math.max(AR,i-m),g=h-2*sn,x=De(e.title,!1,a,n,i,1),y=s+(x.height?x.height+12:0),_=s+x.height,S=Math.max(x.width,h+m),P="",k="",w="",I=new Map,D=(z,R,L=0)=>Ss(gt(z),a,R,g,L);e.boxes.forEach((z,R)=>{let L=f.has(z)?g-xR:g,F=ci(De(z.lane.label,!1,a,r,L,1),a,L),E=De(z.name,!1,a,r,g-36,1),C=z.data?D(z.data,o,4):void 0,A=Math.max(h,F.width+2*sn,E.width+2*sn+36,(C?.width??0)+2*sn),T=F.height+12,b=2*kn+E.height+(C?C.height+6:0),N=Rg.get(z.kind),$=y+T,X=`x="${d(s)}" y="${d($)}" width="${d(A)}" height="${d(b)}" rx="${Xe}"`;P+=`<g class="pele-cluster pele-em-lane" data-id="${$e(z.lane.label)}">`+wr(F,s+sn,y,` class="pele-cluster-label" font-size="${r}" font-weight="var(--_hw)" fill="var(--_m)"`)+`<g class="pele-node pele-em-${z.kind}${z.reset?" pele-em-reset":""}" data-id="${$e(z.id)}"><rect ${X} fill="var(--_bg)" stroke="var(--_b)"/>`+(N===void 0?"":`<rect ${X} fill="${ct(N)}" fill-opacity="0.22" stroke="${ct(N)}"/>`)+Ie(E,s+sn+E.width/2,$+kn+E.height/2,` class="pele-label" font-size="${r}" font-weight="var(--_hw)"`)+`<text class="pele-em-frame" x="${d(s+A-sn)}" y="${d($+kn+r)}" text-anchor="end" font-size="${o}" fill="var(--_m)">${je(z.id)}</text>`+(C?ec(C.lines.map(V=>V.map(O=>O.text).join("")),s+sn,$+kn+E.height+6+C.lineHeight/2+o*.35,C.lineHeight,` class="pele-em-data" font-family="${Vi}" font-size="${o}"`):"")+"</g></g>",I.set(z,{y:$,h:b,w:A,index:R,lane:F.width}),S=Math.max(S,A+m),_=$+b,y=_+28});for(let z of e.relations){let R=I.get(z.source),L=I.get(z.target);if(!R||!L||R===L)continue;let F=L.y>R.y,E=F?1:-1,C=F?R.y+R.h:R.y,A=F?L.y:L.y+L.h,T,b;if(Math.abs(R.index-L.index)===1){let N=s+Math.max(Math.min(R.w,L.w)/2,sn+(F?L:R).lane+16);T=`M${d(N)},${d(C)}V${d(A-E*ht("arrow_point"))}`,b=bt("arrow_point",N,A,0,E,"var(--_l)")}else{let N=s+S-m+12+wg*(p.get(z.target)??0),$=R.y+R.h/2-5,X=L.y+L.h/2+5;T=`M${d(s+R.w)},${d($)}H${d(N)}V${d(X)}H${d(s+L.w+ht("arrow_point"))}`,b=bt("arrow_point",s+L.w,X,-1,0,"var(--_l)")}k+=`<g class="pele-edge" data-id="${$e(z.source.id)}-${$e(z.target.id)}"><path d="${T}" fill="none" stroke="var(--_l)"/>${b}</g>`}let U=new Map(e.boxes.map(z=>[z.id,z.name])),M=(z,R,L,F)=>{let E=De(`${R} · ${L}${U.has(L)?" "+U.get(L):""}`,!1,a,r,g,1),C=D(F,r),A=Math.max(h,E.width+2*sn,C.width+2*sn),T=2*kn+E.height+C.height;w+=`<g class="pele-em-${z}" data-id="${$e(L)}"><rect x="${d(s)}" y="${d(y)}" width="${d(A)}" height="${d(T)}" rx="${Xe}" fill="var(--_bg)" stroke="var(--_b)"/>`+Ie(E,s+sn+E.width/2,y+kn+E.height/2,` font-size="${r}" font-weight="var(--_hw)"`)+ec(C.lines.map(b=>b.map(N=>N.text).join("")),s+sn,y+kn+E.height+C.lineHeight/2+r*.35,C.lineHeight,` font-size="${r}"`)+"</g>",_=y+T,y=_+Tg,S=Math.max(S,A)};for(let z of e.notes)M("note","Note",z.frame,z.text);for(let z of e.specifications){let R=[`Given ${z.given.join(", ")}`];z.when.length&&R.push(`When ${z.when.join(", ")}`),R.push(`Then ${z.then.join(", ")}`),M("specification","Given / When / Then",z.frame,R.join(`
76
+ `))}let Q=Math.ceil(S+2*s),q=Math.ceil(_+s),Y=Ie(x,Q/2,s+x.height/2,' class="pele-title" font-weight="var(--_tw)"')+k+P+w;return{svg:Ze("eventmodeling",Q,q,n,t,e,Y),width:Q,height:q,links:[]}}var Ig={type:"eventmodeling",keepComments:!0,parse:(e,t,n)=>yg(Ag(e),n),render:Cg};function gu(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function Ng(e){return e.startsWith('"')&&e.endsWith('"')?e.substring(1,e.length-1):e}function _R(e,t){let n=0;for(let r=0;r<t.length;r++)t[r]===e&&n++;return n}function wR(e){let t=e.trim(),n="arrow_open";switch(t[0]){case"<":n="arrow_point",t=t.slice(1);break;case"x":n="arrow_cross",t=t.slice(1);break;case"o":n="arrow_circle",t=t.slice(1);break}let r="normal";return t.includes("=")&&(r="thick"),t.includes(".")&&(r="dotted"),{type:n,stroke:r}}function RR(e){let t=e.trim(),n=t.slice(0,-1),r="arrow_open";switch(t.slice(-1)){case"x":r="arrow_cross",t.startsWith("x")&&(r="double_"+r,n=n.slice(1));break;case">":r="arrow_point",t.startsWith("<")&&(r="double_"+r,n=n.slice(1));break;case"o":r="arrow_circle",t.startsWith("o")&&(r="double_"+r,n=n.slice(1));break}let o="normal",s=n.length-1;n.startsWith("=")&&(o="thick"),n.startsWith("~")&&(o="invisible");let a=_R(".",n);return a&&(o="dotted",s=a),{type:r,stroke:o,length:s}}var tc=class{type="flowchart";direction;nodes=new Map;edges=[];subgraphs=[];classes=new Map;tooltips=new Map;defaultEdgeStyle;defaultInterpolate;title;accTitle;accDescr;subgraphLookup=new Map;members=new Set;edgeById=new Map;pairCount=new Map;subCount=0;options;constructor(t={}){this.options=t}addVertex(t,n,r,o,s,a,i={},c){if(!t||t.trim().length===0)return;let l;if(c!==void 0){let h=c.includes(`
77
+ `)?c+`
78
+ `:`{
79
+ `+c+`
80
+ }`,g;try{g=Hn(h)}catch(x){throw new Ge(`Metadata of "${t}" is not valid YAML. ${x.message}`,"syntax",{type:"flowchart"})}l=g!==null&&typeof g=="object"&&!Array.isArray(g)?g:void 0}let f=this.subgraphLookup.get(t);if(f&&l){f.metadata={...f.metadata,...l};return}let p=this.edgeById.get(t);if(p){l?.animate!==void 0&&(p.animate=l.animate),l?.animation!==void 0&&(p.animation=l.animation),l?.curve!==void 0&&(p.interpolate=l.curve);return}let u=this.nodes.get(t);if(u===void 0&&(n===void 0&&r===void 0&&o!==void 0&&o!==null&&this.options.warn?.(`Style applied to unknown node "${t}". This may indicate a typo. The node will be created automatically.`),u={id:t,labelType:"text",styles:[],classes:[]},this.nodes.set(t,u)),n!==void 0?(u.labelType=n.type,u.text=Ng(n.text.trim())):u.text===void 0&&(u.text=t),r!==void 0&&(u.type=r),o!=null)for(let h of o)u.styles.push(h);if(s!=null)for(let h of s)u.classes.push(h);if(a!==void 0&&(u.dir=a),u.props===void 0?u.props=i:i!==void 0&&Object.assign(u.props,i),l===void 0)return;if(l.shape){let h=String(l.shape);if(h!==h.toLowerCase()||h.includes("_"))throw new Ge(`No such shape: ${h}. Shape names should be lowercase.`,"semantic",{type:"flowchart"});if(!ra(h))throw new Ge(`No such shape: ${h}.`,"semantic",{type:"flowchart"});u.type=h}let m=typeof l.label=="string"?l.label:void 0;l.label&&(u.text=String(l.label),u.labelType=gu(l.labelType)),l.icon&&(u.icon=String(l.icon),!m?.trim()&&u.text===t&&(u.text="")),l.form&&(u.form=String(l.form)),l.pos&&(u.pos=String(l.pos)),l.img&&(u.img=String(l.img),!m?.trim()&&u.text===t&&(u.text="")),l.constraint&&(u.constraint=String(l.constraint)),l.w&&(u.assetWidth=Number(l.w)),l.h&&(u.assetHeight=Number(l.h))}addSingleLink(t,n,r,o){let s={start:t,end:n,type:void 0,text:"",labelType:"text",classes:[],isUserDefinedId:!1,interpolate:this.defaultInterpolate},a=r?.text;if(a!==void 0&&(s.text=Ng(a.text.trim()),s.labelType=gu(a.type)),r!==void 0&&(s.type=r.type,s.stroke=r.stroke,s.length=r.length>10?10:r.length),o&&!this.edgeById.has(o))s.id=o,s.isUserDefinedId=!0;else{let l=this.pairCount.get(t+"\0"+n)??0;s.id=`L_${t}_${n}_${l===0?0:l+1}`}let i=this.options.maxEdges;if(i!==void 0&&this.edges.length>=i)throw new Ge(`Edge limit exceeded. ${this.edges.length} edges found, but the limit is ${i}.`,"limit",{type:"flowchart"});this.edges.push(s);let c=t+"\0"+n;this.pairCount.set(c,(this.pairCount.get(c)??0)+1),this.edgeById.has(s.id)||this.edgeById.set(s.id,s)}addLink(t,n,r){let o=typeof r?.id=="string"?r.id.replace("@",""):void 0,s=t[t.length-1],a=n[0];for(let i of t)for(let c of n)this.addSingleLink(i,c,r,i===s&&c===a?o:void 0)}updateLinkInterpolate(t,n){for(let r of t)r==="default"?this.defaultInterpolate=n:this.edgeAt(r).interpolate=n}updateLink(t,n){for(let r of t){if(r==="default"){this.defaultEdgeStyle=n;continue}let o=this.edgeAt(r);o.style=n,n.length>0&&!n.some(s=>s?.startsWith("fill"))&&n.push("fill:none")}}edgeAt(t){let n=this.edges[Number(t)];if(n===void 0)throw new Ge(`The index ${t} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${this.edges.length-1}. (Help: Ensure that the index is within the range of existing edges.)`,"semantic",{type:"flowchart"});return n}addClass(t,n){let r=n.join().replace(/\\,/g,"§§§").replace(/,/g,";").replace(/§§§/g,",").split(";");for(let o of t.split(",")){let s=this.classes.get(o);s===void 0&&(s={id:o,styles:[],textStyles:[]},this.classes.set(o,s));for(let a of r)a.includes("color")&&s.textStyles.push(a.replace("fill","bgFill")),s.styles.push(a)}}setDirection(t){let n=t.trim();n.includes("<")&&(n="RL"),n.includes("^")&&(n="BT"),n.includes(">")&&(n="LR"),n.includes("v")&&(n="TB"),n==="TD"&&(n="TB"),this.direction=n}setClass(t,n){for(let r of t.split(","))this.nodes.get(r)?.classes.push(n),this.edgeById.get(r)?.classes.push(n),this.subgraphLookup.get(r)?.classes.push(n)}setTooltip(t,n){if(n!==void 0)for(let r of t.split(","))this.tooltips.set(r,n)}setLink(t,n,r){let o=n.trim();for(let s of t.split(",")){let a=this.nodes.get(s);a!==void 0&&(a.link=o?vn(o):void 0,a.linkTarget=r)}this.setClass(t,"clickable")}setClickEvent(t,n,r){this.setClass(t,"clickable")}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
81
+ `)}addSubGraph(t,n,r){let o=t?.text.trim(),s=r?.text??"";t!==void 0&&t===r&&/\s/.test(s)&&(o=void 0);let a=new Set,i=[],c;for(let u of n)if(typeof u=="string")u.trim()!==""&&!a.has(u)&&(a.add(u),i.push(u));else if(Array.isArray(u))for(let m of u)m.trim()!==""&&!a.has(m)&&(a.add(m),i.push(m));else c=u.value;c??=this.options.inheritDir?this.direction??this.options.direction:void 0,o??="subGraph"+this.subCount,s=s||"",this.subCount++;let l={id:o,nodes:i,title:s.trim(),classes:[],dir:c,labelType:gu(r?.type)},f=this.members;l.nodes=i.filter(u=>!f.has(u)&&u!==o);for(let u of l.nodes)f.add(u);let p=this.subgraphLookup.get(o);if(p)for(let u of l.nodes)p.nodes.push(u);else this.subgraphs.push(l);return this.subgraphLookup.set(o,p??l),o}exists(t,n){for(let r of t)if(r.nodes.includes(n))return!0;return!1}makeUniq(t,n){let r=new Set;for(let o of n)for(let s of o.nodes)r.add(s);return{nodes:t.nodes.filter(o=>!r.has(o))}}destructLink(t,n){let r=RR(t);if(!n)return r;let o=wR(n);if(o.stroke!==r.stroke)return{type:"INVALID",stroke:"INVALID"};if(o.type==="arrow_open")o.type=r.type;else{if(o.type!==r.type)return{type:"INVALID",stroke:"INVALID"};o.type="double_"+o.type}return o.type==="double_arrow"&&(o.type="double_arrow_point"),o.length=r.length,o}subgraph(t){return this.subgraphLookup.get(t)}};var bu=["$end","INVALID","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","SHAPE_DATA","CALLBACKNAME","CALLBACKARGS","MD_STR","STR","STYLE","DEFAULT","LINKSTYLE","INTERPOLATE","CLASSDEF","CLASS","HREF","CLICK","GRAPH","subgraph","end","LINK_TARGET","NODIR","DIR","direction_tb","direction_bt","direction_rl","direction_lr","direction_td","LINK_ID","NUM","BRKT","STYLE_SEPARATOR","COLON","AMP","SEMI","COMMA","MULT","LINK","START_LINK","EDGE_TEXT","-)","TEXT","(-","STADIUMEND","STADIUMSTART","SUBROUTINEEND","SUBROUTINESTART","VERTEX_WITH_PROPS_START","TAGEND","CYLINDEREND","CYLINDERSTART","DOUBLECIRCLEEND","DOUBLECIRCLESTART","TRAPEND","INVTRAPEND","TRAPSTART","INVTRAPSTART","TAGSTART","UP","SEP","DOWN","NODE_STRING","MINUS","UNICODE_TEXT","PIPE","PE","PS","SQE","SQS","DIAMOND_STOP","DIAMOND_START","NEWLINE","SPACE","EOF"];var $g=new Uint8Array(128);for(let e of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")$g[e.charCodeAt(0)]=1;var TR=/accTitle\s*:\s*/y,CR=/accDescr\s*:\s*/y,IR=/accDescr\s*\{\s*/y,NR=/call\s+/y,MR=/click\s+/y,kR=/(?:\r?\n)*\s*\n/y,LR=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,$R=/\s*[<>^]/y,DR=/\s*v\b/y,OR=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y,/.*direction\s+TD[^\n]*/y],yu=/[\n\r\u2028\u2029]/g,Mg=/\s*[xo<]?--+[-xo>]\s*/y,vR=/\s*[xo<]?--\s*/y,kg=/\s*[xo<]?==+[=xo>]\s*/y,PR=/\s*[xo<]?==\s*/y,Eu=/\s*[xo<]?-?\.+-[xo>]?\s*/y,BR=/\s*[xo<]?-\.\s*/y,Lg=/\s*~~~+\s*/y,FR=/(?:\r?\n)+/y,WR=/[^\S\n\r]+/y,UR=/\(\s*\)/y,GR=/\n\s*/g;function Dg(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=!0,l=e.indexOf("direction"),f=e.indexOf("@"),p=-1,u=0,m=0,h=-1,g=-1,x=-1,y=(L,F,E)=>{n.push(L),r.push(e.slice(F,E)),o.push(F),i=E},_=L=>{s.push(a),a=L},S=()=>{s.length>0&&(a=s.pop())},P=(L,F)=>(L.lastIndex=F,L.test(e)?L.lastIndex:-1),k=L=>e.startsWith(L,i)&&!Qe(e.charCodeAt(i+L.length)),w=L=>{let F=L;if(L>=g&&L<=x)F=x;else if(Be(e.charCodeAt(L))){for(;F<t&&Be(e.charCodeAt(F));)F++;g=L,x=F}let E=e.charCodeAt(F);return E===120||E===111||E===60?e.charCodeAt(F+1):E},I=L=>{let F=L;if(L>=g&&L<=x)F=x;else if(Be(e.charCodeAt(L))){for(;F<t&&Be(e.charCodeAt(F));)F++;g=L,x=F}return e.charCodeAt(F)===126},D=()=>{e.charCodeAt(i+1)===96?(_(2),i+=2):(_(1),i++)},U=()=>{if(!I(i))return!1;let L=P(Lg,i);return L<0?!1:(y(40,i,L),!0)},M=L=>{let F=e.charCodeAt(i+1);return L===40?(F===45?(_(8),y(45,i,i+2)):F===91?(_(7),y(47,i,i+2)):F===40&&e.charCodeAt(i+2)===40?(_(7),y(55,i,i+3)):(_(7),y(69,i,i+1)),!0):L===91?(F===91?(_(7),y(49,i,i+2)):F===40?(_(7),y(53,i,i+2)):F===47?(_(9),y(58,i,i+2)):F===92?(_(9),y(59,i,i+2)):(_(7),y(71,i,i+1)),!0):L===124?(_(7),y(67,i,i+1),!0):L===123?(_(7),y(73,i,i+1),!0):!1},Q=L=>{c&&(c=!1,_(6)),y(20,i,i+L)},q=()=>{let L=i;for(;L<t;){let F=e.charCodeAt(L);if(F<128&&$g[F]===1)L++;else if(F===45&&L+1<t){let E=e.charCodeAt(L+1);if(E===62||E===45||E===46)break;L++}else break}return L===i?!1:(y(64,i,L),!0)},Y=L=>{let F=w(i),E;if(F===45){if((E=P(Mg,i))>=0)return y(40,i,E),!0;if((E=P(vR,i))>=0)return _(10),y(41,i,E),!0;if((E=P(Eu,i))>=0)return y(40,i,E),!0;if((E=P(BR,i))>=0)return _(12),y(41,i,E),!0}else if(F===61){if((E=P(kg,i))>=0)return y(40,i,E),!0;if((E=P(PR,i))>=0)return _(11),y(41,i,E),!0}else if(F===46&&(E=P(Eu,i))>=0)return y(40,i,E),!0;return L!==45&&L!==61&&L!==46&&U()},z=L=>{let F;switch(L){case 97:if(e.startsWith("acc",i)){if((F=P(TR,i))>=0)return _(3),y(2,i,F),!0;if((F=P(CR,i))>=0)return _(4),y(4,i,F),!0;if((F=P(IR,i))>=0)return _(5),i=F,!0}break;case 64:if(e.charCodeAt(i+1)===123)return _(16),n.push(7),r.push(""),o.push(i),i+=2,!0;break;case 99:if((F=P(NR,i))>=0)return _(14),i=F,!0;if(k("classDef"))return y(16,i,i+8),!0;if(k("class"))return y(17,i,i+5),!0;if((F=P(MR,i))>=0)return _(13),i=F,!0;break;case 34:return D(),!0;case 115:if(k("style"))return y(12,i,i+5),!0;if(k("swimlane-beta"))return Q(13),!0;if(k("subgraph"))return y(21,i,i+8),!0;break;case 100:if(k("default"))return y(13,i,i+7),!0;break;case 108:if(k("linkStyle"))return y(14,i,i+9),!0;break;case 105:if(k("interpolate"))return y(15,i,i+11),!0;break;case 104:if(e.startsWith("href",i)&&Be(e.charCodeAt(i+4)))return y(18,i,i+5),!0;break;case 102:if(k("flowchart-elk"))return Q(13),!0;if(k("flowchart"))return Q(9),!0;break;case 103:if(k("graph"))return Q(5),!0;break;case 101:if(k("end")){for(F=i+3;F<t&&Be(e.charCodeAt(F));)F++;return y(22,i,F),!0}break;case 95:if(k("_self"))return y(23,i,i+5),!0;if(k("_blank"))return y(23,i,i+6),!0;if(k("_parent"))return y(23,i,i+7),!0;if(k("_top"))return y(23,i,i+4),!0;break}if(l!==-1&&i>=u&&(l<i&&(l=e.indexOf("direction",i)),l!==-1&&(p<i&&(yu.lastIndex=i,p=yu.test(e)?yu.lastIndex-1:t),l<p))){for(let E=0;E<5;E++)if((F=P(OR[E],i))>=0)return y(26+E,i,F),!0;u=p}if(f!==-1&&L!==34&&!Be(L)){if(i>=m){f<i&&(f=e.indexOf("@",i));let E=i;for(;E<t;){let C=e.charCodeAt(E);if(C===34||Be(C))break;E++}if(m=E,h=-1,f!==-1&&f<E)for(let C=Math.min(E,t-1)-1;C>=f;C--){if(e.charCodeAt(C)!==64)continue;let A=e.charCodeAt(C+1);if(A!==123&&A!==34){h=C;break}}}if(h>i)return y(31,i,h+1),!0}if(L>=48&&L<=57){let E=i+1;for(;E<t;){let C=e.charCodeAt(E);if(C<48||C>57)break;E++}return y(32,i,E),!0}switch(L){case 35:return y(33,i,i+1),!0;case 58:return e.charCodeAt(i+1)===58&&e.charCodeAt(i+2)===58?y(34,i,i+3):y(35,i,i+1),!0;case 38:return y(36,i,i+1),!0;case 59:return y(37,i,i+1),!0;case 44:return y(38,i,i+1),!0;case 42:return y(39,i,i+1),!0;case 120:case 111:return Y(L)||q();case 60:return Y(L)||y(60,i,i+1),!0;case 45:return Y(L)||q()||y(65,i,i+1),!0;case 61:return Y(L);case 46:return Y(L)||q();case 126:return U();case 40:return M(L);case 91:return e.charCodeAt(i+1)===124?(y(50,i,i+2),!0):M(L);case 124:case 123:return M(L);case 62:return _(7),y(51,i,i+1),!0;case 94:return y(61,i,i+1),!0;case 92:return e.charCodeAt(i+1)===124?(y(62,i,i+2),!0):q();case 118:return Qe(e.charCodeAt(i+1))?q():(y(63,i,i+1),!0)}return Be(L)?Y(L)?!0:(F=P(FR,i))>=0?(y(74,i,F),!0):(F=P(WR,i))>=0?(y(75,i,F),!0):!1:L<128?q():Js(L)?(y(66,i,i+1),!0):!1},R=(L,F,E,C)=>{if(L===34)return D(),!0;let A=w(i);if(A===E||A===C){let b=P(F,i);if(b>=0)return S(),y(40,i,b),!0}if(L===E&&(E!==45||e.charCodeAt(i+1)===45))return!1;let T=i+1;for(;T<t;){let b=e.charCodeAt(T);if(b===34)break;if(b===E){if(E!==45||e.charCodeAt(T+1)===45)break}else if(b===120||b===111||b===60||b===C||Be(b)){let N=w(T);if((N===E||N===C)&&P(F,T)>=0)break}T++}return y(42,i,T),!0};e:for(;;){if(i>=t){let E=-1;switch(a){case 0:E=76;break;case 3:E=3;break;case 4:E=5;break;case 5:E=6;break;case 13:E=19;break;case 14:E=8;break;case 15:E=9;break}E!==-1&&y(E,t,t);break}let L=e.charCodeAt(i),F=!0;switch(a){case 0:F=z(L);break;case 1:if(L===34)e.charCodeAt(i+1)===96?(_(2),i+=2):(S(),i++);else{let E=e.indexOf('"',i);y(11,i,E===-1?t:E)}break;case 2:if(L===96)e.charCodeAt(i+1)===34?(S(),i+=2):F=!1;else if(L===34)D();else{let E=i+1;for(;E<t;){let C=e.charCodeAt(E);if(C===96||C===34)break;E++}y(10,i,E)}break;case 3:case 4:{let E=e.indexOf(`
82
+ `,i);E===-1&&(E=t);let C=a===3?3:5;S(),y(C,i,E);break}case 5:if(L===125)S(),i++;else{let E=e.indexOf("}",i);E===-1&&(E=t),y(6,i,E)}break;case 6:{let E;L===34?D():(E=P(kR,i))>=0?(S(),y(24,i,E)):(E=P(LR,i))>=0||(E=P($R,i))>=0||(E=P(DR,i))>=0?(S(),y(25,i,E)):F=U()||M(L);break}case 7:{let E=e.charCodeAt(i+1);switch(L){case 34:D();break;case 40:case 91:case 123:M(L);break;case 93:S(),E===41?y(46,i,i+2):E===93?y(48,i,i+2):y(70,i,i+1);break;case 41:S(),E===93?y(52,i,i+2):E===41&&e.charCodeAt(i+2)===41?y(54,i,i+3):y(68,i,i+1);break;case 124:S(),y(67,i,i+1);break;case 125:S(),y(72,i,i+1);break;default:{if((L===126||Be(L))&&U())break;let C=i+1;for(;C<t;){let A=e.charCodeAt(C);if(A===91||A===93||A===40||A===41||A===123||A===125||A===124||A===34)break;C++}y(44,i,C)}}break}case 8:{let E=e.charCodeAt(i+1);if(L===34)D();else{if((L===126||Be(L))&&U())break;if((L===45||L===47||L===41)&&E===41)S(),y(43,i,i+2);else if(L===40||L===91||L===123)M(L);else if(L===41||L===93||L===125)F=!1;else{let C=i+1;for(;C<t;){let A=e.charCodeAt(C);if(A===34||A===40||A===41||A===91||A===93||A===123||A===125||(A===45||A===47)&&e.charCodeAt(C+1)===41||(A===126||Be(A))&&I(C)&&P(Lg,C)>=0)break;C++}y(44,i,C)}}break}case 9:{let E=e.charCodeAt(i+1);if(L===34){D();break}if((L===126||Be(L))&&U())break;switch(L){case 40:E===45||E===91||E===40&&e.charCodeAt(i+2)===40?M(L):E===93?(S(),y(56,i,i+2)):M(L);break;case 91:case 123:M(L);break;case 92:E===93?(S(),y(56,i,i+2)):y(44,i,i+1);break;case 47:E===93?(S(),y(57,i,i+2)):y(44,i,i+1);break;case 93:case 41:E===93?(S(),y(56,i,i+2)):F=!1;break;case 125:F=!1;break;default:{if((L===63||L===61)&&E===93){S(),y(56,i,i+2);break}let C=i+1;for(;C<t;){let A=e.charCodeAt(C);if(A===92||A===91||A===93||A===40||A===41||A===123||A===125||A===47)break;C++}y(44,i,C)}}break}case 10:F=R(L,Mg,45,-1);break;case 11:F=R(L,kg,61,-1);break;case 12:F=R(L,Eu,46,45);break;case 13:if(L===34)D();else if(Be(L))S(),i++;else{let E=i+1;for(;E<t&&!Be(e.charCodeAt(E));)E++;y(19,i,E)}break;case 14:if(L===40){let E=P(UR,i);S(),E>=0?i=E:(_(15),i++)}else{let E=e.indexOf("(",i);E===-1&&(E=t),y(8,i,E)}break;case 15:if(L===41)S(),i++;else{let E=e.indexOf(")",i);E===-1&&(E=t),y(9,i,E)}break;case 16:if(L===34)_(17),y(7,i,i+1);else if(L===125)S(),i++;else if(L===94)F=!1;else{let E=i+1;for(;E<t;){let C=e.charCodeAt(E);if(C===125||C===94||C===34)break;E++}y(7,i,E)}break;case 17:if(L===34)S(),y(7,i,i+1);else{let E=e.indexOf('"',i);E===-1&&(E=t),n.push(7),r.push(e.slice(i,E).replace(GR,"<br/>")),o.push(i),i=E}break}if(!F)return n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o};continue e}return n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o}}var nc=new Uint8Array(77);for(let e of[32,64,63,65,13,38,35,36,33,39,66])nc[e]=1;var Au=new Uint8Array(77);for(let e of[32,66,64,25,63,65,38,35,36,33,39])Au[e]=1;var xu=new Uint8Array(77);for(let e of[32,64,75,65,36,66,35,39,33,12,14,16,17,19,20,25,21,22,63,61,41])xu[e]=1;var Su=new Uint8Array(77);for(let e of[32,64,35,75,33,12])Su[e]=1;var Og="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",bo=[],YR=/}\s*\n/g;function Pg(e,t){let n=e.includes("}")?e.replace(YR,`}
83
+ `):e,{types:r,texts:o,starts:s}=Dg(n),a=0,i,c=R=>{let L=r[a];throw L===1?it("flowchart",n,s[a],"",!0):it("flowchart",n,s[a],`Expecting ${R}, got '${bu[L]}'`)},l=(R,L="")=>(r[a]!==R&&c(`'${bu[R]}'${L?", "+L:""}`),o[a++]),f=()=>{let R=r[a];R!==74&&R!==37&&R!==76&&c("'SEMI', 'NEWLINE', 'EOF'"),a++},p=()=>{nc[r[a]]===0&&c("'NODE_STRING'");let R=o[a++];for(;nc[r[a]]===1;)R+=o[a++];return R},u=()=>{Au[r[a]]===0&&c("'NODE_STRING'");let R=o[a++];for(;Au[r[a]]===1;)R+=o[a++];return R},m=()=>{let R=r[a],L;if(R===11)L="string";else if(R===10)L="markdown";else if(R===44||R===60||R===51||R===66)L="text";else return c(`${Og}, 'TAGEND', 'STR', 'MD_STR'`);let F=o[a++];for(;;){let E=r[a];if(E!==44&&E!==60&&E!==51&&E!==66)break;F+=o[a++]}return{text:F,type:L}},h=R=>{l(R,Og)},g=()=>{let R=r[a],L;if(R===11)L="string";else if(R===10)L="markdown";else if(R===42||R===66)L="text";else return c("'EDGE_TEXT', 'STR', 'MD_STR'");let F=o[a++];for(;r[a]===42||r[a]===66;)F+=o[a++];return{text:F,type:L}},x=()=>{let R=r[a],L;if(R===11)L="text";else if(R===10)L="markdown";else if(xu[R]===1)L="text";else return c("'NODE_STRING', 'STR', 'MD_STR'");let F=o[a++];for(;xu[r[a]]===1;)F+=o[a++];return{text:F,type:L}},y=()=>{let R=o[a++];for(;r[a]===7;)R+=o[a++];return R},_=()=>{let R=p(),L;switch(r[a]){case 71:a++,L=m(),h(70),t.addVertex(R,L,"square");break;case 55:a++,L=m(),h(54),t.addVertex(R,L,"doublecircle");break;case 69:a++,r[a]===69?(a++,L=m(),h(68),l(68),t.addVertex(R,L,"circle")):(L=m(),h(68),t.addVertex(R,L,"round"));break;case 45:a++,L=m(),h(43),t.addVertex(R,L,"ellipse");break;case 47:a++,L=m(),h(46),t.addVertex(R,L,"stadium");break;case 49:a++,L=m(),h(48),t.addVertex(R,L,"subroutine");break;case 50:{a++;let F=l(64);l(35);let E=l(64);l(67),L=m(),h(70),t.addVertex(R,L,"rect",void 0,void 0,void 0,{[F]:E});break}case 53:a++,L=m(),h(52),t.addVertex(R,L,"cylinder");break;case 73:a++,r[a]===73?(a++,L=m(),h(72),l(72),t.addVertex(R,L,"hexagon")):(L=m(),h(72),t.addVertex(R,L,"diamond"));break;case 51:a++,L=m(),h(70),t.addVertex(R,L,"odd");break;case 58:a++,L=m(),r[a]===57?(a++,t.addVertex(R,L,"lean_right")):(h(56),t.addVertex(R,L,"trapezoid"));break;case 59:a++,L=m(),r[a]===56?(a++,t.addVertex(R,L,"lean_left")):(h(57),t.addVertex(R,L,"inv_trapezoid"));break;default:t.addVertex(R)}return R},S=()=>{let R=_();return r[a]===34&&(a++,t.setClass(R,p())),R},P=()=>{let R=[S()];for(i=void 0;;){let L=r[a]===7?y():void 0;if(r[a]!==75)return i=L,R;do a++;while(r[a]===75);if(r[a]!==36)return L!==void 0&&c("'AMP'"),R;a++,r[a]!==75&&c("'SPACE'");do a++;while(r[a]===75);let F=S();L!==void 0&&t.addVertex(R[R.length-1],void 0,void 0,void 0,void 0,void 0,void 0,L),R.push(F)}},k=()=>{let R;if(r[a]===31&&(R=o[a++]),r[a]===40){let L=t.destructLink(o[a++]);return R!==void 0&&(L.id=R),r[a]===67&&(a++,L.text=m(),h(67),r[a]===75&&a++),L}if(r[a]===41){let L=o[a++],F=g(),E=l(40,"'EDGE_TEXT'"),C=t.destructLink(E,L);return C.text=F,R!==void 0&&(C.id=R),C}return c("'LINK', 'START_LINK'")},w=()=>{let R=P();i!==void 0&&t.addVertex(R[R.length-1],void 0,void 0,void 0,void 0,void 0,void 0,i);let L=R;for(;;){let F=r[a];if(F!==40&&F!==41&&F!==31)return L;let E=k(),C=P();i!==void 0&&t.addVertex(C[C.length-1],void 0,void 0,void 0,void 0,void 0,void 0,i),t.addLink(R,C,E),L=C.concat(L),R=C}},I=()=>{Su[r[a]]===0&&c("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let R=o[a++];for(;Su[r[a]]===1;)R+=o[a++];return R},D=()=>{let R=[I()];for(;r[a]===38;)a++,R.push(I());return R},U=()=>{a++,l(75);let R;if(r[a]===13)R=[o[a++]];else for(R=[l(32,"'DEFAULT'")];r[a]===38;)a++,R.push(l(32));if(l(75),r[a]!==15){t.updateLink(R,D());return}a++,l(75);let L=u();if(r[a]===75){a++;let F=D();t.updateLinkInterpolate(R,L),t.updateLink(R,F)}else t.updateLinkInterpolate(R,L)},M=(R,L)=>{if(r[a]!==75){t.setLink(R,L);return}if(a++,r[a]===23){t.setLink(R,L,o[a++]);return}let F=l(11,"'LINK_TARGET'");r[a]===75?(a++,t.setLink(R,L,l(23))):t.setLink(R,L),t.setTooltip(R,F)},Q=()=>{let R=o[a++];switch(r[a]){case 8:{let L=o[a++],F=r[a]===9,E=F?o[a++]:void 0,C;r[a]===75&&(a++,C=l(11)),F?t.setClickEvent(R,L,E):t.setClickEvent(R,L),C!==void 0&&t.setTooltip(R,C);return}case 18:a++,M(R,l(11));return;case 11:M(R,o[a++]);return;default:{let L=u();if(r[a]===75){a++;let F=l(11);t.setClickEvent(R,L),t.setTooltip(R,F)}else t.setClickEvent(R,L)}}},q=()=>{a++;let R=r[a];if(R===74||R===37||R===76)return a++,{id:void 0,title:void 0,list:[],collect:!1};l(75,"'SEMI', 'NEWLINE', 'EOF'");let L=x(),F=L;return r[a]===71&&(a++,F=m(),h(70)),R=r[a],R!==74&&R!==37&&R!==76&&c("'SEMI', 'NEWLINE', 'EOF', 'SQS'"),a++,{id:L,title:F,list:[],collect:!1}},Y=()=>{let R=r[a];switch(R){case 12:{a++,l(75);let L=p();return l(75),t.addVertex(L,void 0,void 0,D()),f(),bo}case 14:return U(),f(),bo;case 16:{a++,l(75);let L=p();return l(75),t.addClass(L,D()),f(),bo}case 17:{a++,l(75);let L=p();return l(75),t.setClass(L,p()),f(),bo}case 19:return Q(),f(),bo;case 26:case 27:case 28:case 29:case 30:return a++,{stmt:"dir",value:HR[R-26]};case 2:{a++;let L=l(3).trim();return t.setAccTitle(L),L}case 4:{a++;let L=l(5).trim();return t.setAccDescription(L),L}case 6:{let L=o[a++].trim();return t.setAccDescription(L),L}default:{nc[R]===0&&c(vg);let L=w();return f(),L}}},z=()=>{let R=[],L=[],F=!1;for(;;){let E=r[a];if(E===0)break;if(E===22){let C=R.pop();if(C===void 0)break;a++;let A=t.addSubGraph(C.id,L,C.title);L=C.list,F=C.collect,F&&L.push(A)}else if(E===37||E===74||E===75||E===76)F&&L.push(o[a]),a++;else if(E===21){let C=q();C.list=L,C.collect=F,R.push(C),L=[],F=!0}else{let C=Y();F&&(!Array.isArray(C)||C.length>0)&&L.push(C)}}R.length>0&&c("'end'")};for(;r[a]===75||r[a]===74;)a++;if(l(20,"'SPACE', 'NEWLINE'"),r[a]===24)a++,t.setDirection("TB");else{let R=l(25,"'NODIR'"),L=r[a];if(L===75){do a++;while(r[a]===75);L=r[a],L!==74&&c("'NEWLINE', 'SPACE'")}else L!==37&&L!==74&&c("'SEMI', 'NEWLINE', 'SPACE'");a++,t.setDirection(R)}z(),r[a]!==0&&c(vg)}var HR=["TB","BT","RL","LR","TD"],vg="'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'subgraph', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'";function KR(e){if(e.img)return"imageSquare";if(e.icon)return e.form==="circle"?"iconCircle":e.form==="square"?"iconSquare":e.form==="rounded"?"iconRounded":"icon";switch(e.type){case"square":case void 0:return"squareRect";case"round":return"roundedRect";default:return e.type}}function zR(e){switch(e){case"arrow_point":case"arrow_circle":case"arrow_cross":return["none",e];case"double_arrow_point":case"double_arrow_circle":case"double_arrow_cross":{let t=e.replace("double_","");return[t,t]}}return["none","arrow_point"]}function Bg(e,t){let n=[],r=[],o=e.subgraphs,s=S=>{let P=[];for(let k of S){let w=e.classes.get(k);w?.styles&&(P=[...P,...w.styles].map(I=>I.trim())),w?.textStyles&&(P=[...P,...w.textStyles].map(I=>I.trim()))}return P},a=new Map;for(let S of o)for(let P of S.nodes)e.subgraph(P)&&a.set(P,S.id);let i=new Map,c=new Map;for(let S of o){let P=a.get(S.id);if(P===void 0)continue;let k=c.get(P);k?k.push(S.id):c.set(P,[S.id])}let l=0;for(let S of o){if(a.has(S.id))continue;let P=[S.id];for(;P.length>0;){let k=P.pop();if(i.has(k))continue;i.set(k,l++);let w=c.get(k);if(w)for(let I=w.length-1;I>=0;I--)P.push(w[I])}}let f=S=>e.subgraph(S)?.metadata?.view==="collapsed",p=!1;for(let S of o)S.metadata?.view==="collapsed"&&(p=!0);let u=new Map,m=S=>{let P=[],k=new Set,w=S;for(;w!==void 0&&!u.has(w)&&!k.has(w);)k.add(w),P.push(w),w=a.get(w);let I=w!==void 0?u.get(w):void 0;for(let D=P.length-1;D>=0;D--)I===void 0&&f(P[D])&&(I=P[D]),u.set(P[D],I);return I},h=new Set,g=new Map;for(let S of p?o:[]){let P=m(S.id);if(P!==void 0){S.id!==P&&(h.add(S.id),g.set(S.id,P));for(let k of S.nodes)k!==P&&(h.add(k),g.set(k,P))}}let x=new Map,y=new Set;for(let S=o.length-1;S>=0;S--){let P=o[S];if(!h.has(P.id)){P.nodes.length>0&&y.add(P.id);for(let k of P.nodes)x.set(k,P.id)}}let _=new Map;for(let S=o.length-1;S>=0;S--){let P=o[S];if(h.has(P.id))continue;let k=P.metadata?.view==="collapsed",w={id:P.id,label:P.title,labelType:P.labelType,parentId:x.get(P.id),cssStyles:[],cssCompiledStyles:s(P.classes),cssClasses:P.classes.join(" "),shape:k?"collapsedGroup":"rect",dir:P.dir,isGroup:!k,colorIndex:i.get(P.id)};k||(w.metadata=P.metadata),n.push(w),_.set(P.id,w)}for(let S of e.nodes.values()){if(h.has(S.id))continue;let P=_.get(S.id);if(P){P.cssStyles=S.styles,P.cssCompiledStyles=s(S.classes),P.cssClasses=S.classes.join(" ");continue}let k=y.has(S.id),w={id:S.id,label:S.text,labelType:S.labelType,parentId:x.get(S.id),cssStyles:S.styles,cssCompiledStyles:s(["default","node",...S.classes]),cssClasses:"default "+S.classes.join(" "),dir:S.dir,link:S.link,linkTarget:S.linkTarget,tooltip:e.tooltips.get(S.id),icon:S.icon,pos:S.pos,img:S.img,assetWidth:S.assetWidth,assetHeight:S.assetHeight,constraint:S.constraint,isGroup:k,shape:k?"rect":KR(S)};n.push(w),_.set(S.id,w)}return e.edges.forEach((S,P)=>{let k=g.get(S.start)??S.start,w=g.get(S.end)??S.end;if(k===w&&(g.has(S.start)||g.has(S.end)))return;let[I,D]=zR(S.type),U=[...e.defaultEdgeStyle??[]];S.style&&U.push(...S.style);let M=S.stroke==="invisible"||S.type==="arrow_open";r.push({id:S.id||`L_${k}_${w}_${P}`,isUserDefinedId:S.isUserDefinedId,start:k,end:w,type:S.type??"normal",label:S.text,labelType:S.labelType,thickness:S.stroke,pattern:S.stroke,minlen:S.length,classes:S.stroke==="invisible"?"":"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:M?"none":I,arrowTypeEnd:M?"none":D,cssCompiledStyles:s(S.classes),style:U,animate:S.animate,animation:S.animation,curve:S.interpolate||e.defaultInterpolate||t})}),{nodes:n,edges:r}}var VR=40,jR=16,XR=48,Fg=20,_u=26,wu=' fill="var(--_s)" stroke="var(--_b)"',qR=' stroke="var(--_b)"';function Ru(e,t,n){let r=e[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}function yo(e,t){return e!==void 0&&e>0&&e<=4e3?e:t}function rc(e,t,n,r){let o=s=>pn(n,a=>QR(e,t,n,r,s,a));return _n(e.direction)?Nt(n,o):o(!1)}function QR(e,t,n,r,o,s){let a=s?12:Fg,i=r?t[r.type]:void 0,c=typeof i=="object"&&i!==null&&!Array.isArray(i)?i:t.flowchart??{},l=Bg(e,typeof c.curve=="string"?c.curve:void 0);r?.prepare(l);let f=n.fontSize??16,p=Math.round(f*.875),u=n.measurer??Je(n.fontFamily),m=Math.min(Ru(c,"wrappingWidth",200),r&&s?100:1/0),h=n.padding??8,g=n.icons,x=new Map,y=[],_=[];l.nodes.forEach((v,W)=>x.set(v.id,W));for(let v of l.nodes){let W=At(v.cssStyles.length>0?v.cssCompiledStyles.concat(v.cssStyles):v.cssCompiledStyles),H=(W.bold?1:0)|(W.italic?2:0),G=v.labelType==="markdown",te=W.fontSize??f,Z,B;if(v.isGroup){let K=De(v.label,G,u,te,r&&s?Math.max(80,Rt(n)/2):4e3,H);Z={node:v,style:W,label:K,shape:"group",w:0,h:0,dy:0,loops:0},B=$t(0,0),B.isGroup=!0,B.dir=v.dir?tn(v.dir):void 0,B.padX=a,B.padTop=K.height>0?K.height+16:Fg,B.padBottom=a,B.minW=K.width+2*a-12}else{let K=sa(v.shape),ee=v.img||v.icon||Sh(K)?v.label:void 0,ae=De(ee,G,u,te,m,H),J,se,me=0;if(v.img||v.icon){let Ae=v.img?80:48,de=yo(v.assetWidth,Ae),oe=yo(v.assetHeight,Ae);J=Math.max(de,ae.width+8),se=oe+(ae.height>0?ae.height+6:0),me=v.pos==="t"?-oe/2:oe/2,ae.height===0&&(me=0)}else{let Ae=Br(K,ae.width,ae.height);J=Ae.w,se=Ae.h,me=Ae.dy}Z={node:v,style:W,label:ae,shape:K,w:J,h:se,dy:me,loops:0},B=$t(J,se)}B.seq=y.length,y.push(Z),_.push(B)}l.nodes.forEach((v,W)=>{_[W].parent=v.parentId!==void 0?x.get(v.parentId)??-1:-1});let S=o?"TB":tn(e.direction),P=v=>{let W;for(let H=_[v].parent,G=0;H>=0&&W===void 0&&G<1e4;H=_[H].parent,G++)W=_[H].dir;return W??=S,W==="LR"||W==="RL"};y.forEach((v,W)=>{v.node.isGroup?_[W].span=1/0:!v.node.img&&!v.node.icon&&(_[W].span=xh(v.shape,v.w,v.h,P(W)))});let k=[],w=[],I=[];for(let v of l.edges){let W=x.get(v.start),H=x.get(v.end);if(W===void 0||H===void 0)continue;let G=De(v.label,v.labelType==="markdown",u,p,m);W===H&&(y[W].loops++,P(W)?_[W].h+=2*(_u+(G.height>0?G.height+8:0)):_[W].w+=2*(_u+(G.width>0?G.width+12:0))),I.push(v),w.push(G),k.push({src:W,dst:H,minlen:v.minlen??1,labelW:G.width>0?G.width+12:0,labelH:G.height>0?G.height+4:0,route:[],labelX:0,labelY:0})}let D={nodeSep:Ru(c,"nodeSpacing",VR)*(s?.5:1),edgeSep:jR,rankSep:Ru(c,"rankSpacing",XR)*(s?.75:1),portSep:20,tracks:typeof c.curve=="string"&&/^step/.test(c.curve),straight:c.curve==="linear",headRoom:ht("arrow_point")},U=r?r.layout(_,k,S,D,s):Sn(_,k,S,D),M=De(e.title,!1,u,f,s?Rt(n):4e3,1),Q=M.height>0?M.height+12:0,q=Math.max(U.width,M.width),Y=h+(q-U.width)/2,z=h+Q;vr(_,k,Y,z);let R=Math.ceil(q+2*h),L=Math.ceil(U.height+Q+2*h),F=[],E=new Map,C=!1;for(let v of _)v.isGroup&&(C=!0);if(C)for(let v of k)Vn(E,v.route);let A="",T="",b="";for(let v=0;v<y.length;v++){let W=y[v],H=_[v],G=W.node,te=H.x,Z=H.y,B=wt(G.cssClasses.replace(/^default\s?/,"")),K=$e(G.id);if(H.isGroup&&r?.drawGroup&&H.parent<0){A+=r.drawGroup(H,W.label,W.style,B,K,S,g);continue}if(H.isGroup){let de=Pr(H,W.label.width,E,a),oe=Z-H.h/2+8+W.label.height/2,ye=` class="pele-cluster-label" fill="var(--_m)"${W.style.text}`,ce=da(H,W.label.width,de,E);ce&&(T+=ua(W.label,de,oe,ye,K,_,v,g)),A+=`<g class="pele-cluster${B}" data-id="${K}"><rect x="${d(te-H.w/2)}" y="${d(Z-H.h/2)}" width="${d(H.w)}" height="${d(H.h)}" rx="${Xe}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${W.style.shape}/>`+(ce?"":Ie(W.label,de,oe,ye,g))+"</g>";continue}let ee=W.w,ae=W.h,J;if(G.img){let de=yo(G.assetWidth,80),oe=yo(G.assetHeight,80),ye=W.label.height>0?G.pos==="t"?ae/2-oe:-ae/2:-oe/2,ce=Hp(vn(G.img),n);J=ce===void 0?"":`<image href="${je(ce)}" x="${d(-de/2)}" y="${d(ye)}" width="${d(de)}" height="${d(oe)}" preserveAspectRatio="${G.constraint==="on"?"xMidYMid meet":"none"}"/>`}else if(G.icon){let de=yo(G.assetHeight,48),oe=W.label.height>0?G.pos==="t"?ae/2-de:-ae/2:-de/2,ye=G.shape==="icon"?"":G.shape==="iconCircle"?`<circle cy="${d(oe+de/2)}" r="${d(de/2)}"${wu}${W.style.shape}/>`:`<rect x="${d(-de/2)}" y="${d(oe)}" width="${d(de)}" height="${d(de)}" rx="${G.shape==="iconRounded"?8:0}"${wu}${W.style.shape}/>`,ce=de*.6;J=ye+`<svg class="pele-icon" data-icon="${$e(G.icon)}" x="${d(-ce/2)}" y="${d(oe+(de-ce)/2)}" width="${d(ce)}" height="${d(ce)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${g?.(G.icon)??""}</svg>`}else J=Xn(W.shape,ee,ae,wu+W.style.shape,qR+W.style.line);let se=Ie(W.label,0,W.dy,` class="pele-label"${W.style.text}`,g);if(/ internal-link(?: |$)/.test(B+" ")&&G.label&&n.links!==!1){let de=gt(G.label),oe=Ar(zn(de),n)!==void 0,ye=je(de);se=`<a class="internal-link"${oe?` href="${ye}"${xr(n)}`:""} data-href="${ye}">${se}</a>`,F.push({id:G.id,href:de,internal:!0})}let Ae=J+se;G.tooltip&&(Ae=`<title>${$e(G.tooltip)}</title>`+Ae),G.link&&(Ae=Pn(Ae,G.link,G.id,F,n,G.linkTarget?` target="${je(G.linkTarget)}"`:"")),b+=`<g class="pele-node pele-shape-${W.shape}${B}" data-id="${K}" transform="translate(${d(te)},${d(Z)})">${Ae}</g>`}let N=pa();for(let v=0;v<k.length;v++){let W=k[v];W.src===W.dst||I[v].thickness==="invisible"||W.route.length<6||(N.add(W.src,Bn(W.route,0,_[W.src]),I[v].arrowTypeStart),N.add(W.dst,Bn(W.route,W.route.length-3,_[W.dst]),I[v].arrowTypeEnd))}let $="",X="",V=new Map;for(let v=0;v<k.length;v++){let W=k[v],H=I[v],G=w[v],te=H.style.length>0||H.cssCompiledStyles.length>0?At(H.cssCompiledStyles.concat(H.style)):void 0;if(H.thickness!=="invisible"){let Z=H.arrowTypeStart,B=H.arrowTypeEnd,K;if(W.src===W.dst){let se=y[W.src],me=V.get(W.src)??0;V.set(W.src,me+1),K=ha(_[W.src],se.w,se.h,me,P(W.src),_u,ht(B),W)}else{let se=W.route.slice(),me=N.of(W.src,Bn(se,0,_[W.src])),Ae=N.of(W.dst,Bn(se,se.length-3,_[W.dst]));Es(se,0,y[W.src],_[W.src]),Es(se,se.length-3,y[W.dst],_[W.dst]),K=yn(se,H.curve,ht(Z),ht(B),me,Ae)}let ee=te?.stroke&&H.thickness!=="invisible"?je(te.stroke):"var(--_l)",ae="";H.thickness==="thick"?ae+=' stroke-width="2.5"':H.thickness==="dotted"&&(ae+=' stroke-dasharray="3 4"');let J=wt(H.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));$+=`<g class="pele-edge${J}" data-id="${$e(H.id)}"${te?.line??""}><path d="${K.d}"${ae}/>`+bt(Z,K.sx,K.sy,K.sdx,K.sdy,ee)+bt(B,K.ex,K.ey,K.edx,K.edy,ee)+"</g>"}if(G.width>0){let Z=W.labelX,B=W.labelY;X+=nn(H.id,G,Z,B,te?.text??"",g)}}return{svg:Ze(r?.type??"flowchart",R,L,f,n,e,Ie(M,R/2,h+M.height/2,' class="pele-title" font-weight="var(--_tw)"')+(A?`<g class="pele-clusters">${A}</g>`:"")+($?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${$}</g>`:"")+(T?`<g class="pele-cluster-titles">${T}</g>`:"")+(X?`<g class="pele-edge-labels" font-size="${p}">${X}</g>`:"")+`<g class="pele-nodes">${b}</g>`),width:R,height:L,links:F}}var sc={type:"flowchart",parse(e,t,n,r,o){let s=t.flowchart??{},a=new tc({inheritDir:s.inheritDir===!0,maxEdges:o.maxEdges});return n&&(a.title=n),Pg(e,a),a},render:rc};var Is=["January","February","March","April","May","June","July","August","September","October","November","December"],Rr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function mi(e){return!Number.isNaN(e.getTime())}function Ln(e,t){let n=String(e);return n.length>=t?n:"0".repeat(t-n.length)+n}function jg(e){let t=["th","st","nd","rd"],n=e%100;return e+(t[(n-20)%10]||t[n]||t[0])}function Tu(e){let t=-Math.round(e.getTimezoneOffset()/15)*15;return t===0?0:t}function Wg(e){let t=Tu(e),n=Math.abs(t);return(t>=0?"+":"-")+Ln(Math.floor(n/60),2)+":"+Ln(n%60,2)}function Xg(e){return e.getDay()||7}function dr(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function ZR(e){let t=new Date(e.getFullYear(),e.getMonth()+1,0);return t.setHours(23,59,59,999),t.getDate()}function Ug(e,t){let n=new Date(e);return n.setDate(1),t(n),n.setDate(Math.min(e.getDate(),ZR(n))),n}function oc(e,t,n){switch(n){case"M":return Ug(e,r=>r.setMonth(e.getMonth()+t));case"y":return Ug(e,r=>r.setFullYear(e.getFullYear()+t));case"d":return dr(e,Math.round(t));case"w":return dr(e,Math.round(7*t));case"h":return new Date(e.getTime()+t*36e5);case"m":return new Date(e.getTime()+t*6e4);case"s":return new Date(e.getTime()+t*1e3);default:return new Date(e.getTime()+t)}}function qg(e){return dr(e,4-Xg(e))}function Gg(e){let t=qg(e),n=new Date(t.getFullYear(),0,1),r=Xg(n),o=dr(n,4-r+(r>4?7:0)),s=(Tu(o)-Tu(t))*6e4,a=(t.getTime()-o.getTime()-s)/6048e5;return(a<0?Math.ceil(a)||0:Math.floor(a))+1}var JR=/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,eT=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,tT="YYYY-MM-DDTHH:mm:ssZ";function Cu(e,t){if(!mi(e))return"Invalid Date";let n=t||tT;if(n==="YYYY-MM-DD")return Iu(e);let r=!1,o=n.replace(JR,a=>{switch(a){case"Q":return String(Math.ceil((e.getMonth()+1)/3));case"Do":return"["+jg(e.getDate())+"]";case"GGGG":return String(qg(e).getFullYear());case"W":return String(Gg(e));case"WW":return Ln(Gg(e),2);case"k":return String(e.getHours()||24);case"kk":return Ln(e.getHours()||24,2);case"X":return String(Math.floor(e.getTime()/1e3));case"x":return String(e.getTime());case"gggg":case"wo":case"w":case"ww":case"z":case"zzz":return r=!0,a;default:return a}});if(r)return;let s=e.getHours();return o.replace(eT,(a,i)=>{if(i)return i;switch(a){case"YY":return String(e.getFullYear()).slice(-2);case"YYYY":return Ln(e.getFullYear(),4);case"M":return String(e.getMonth()+1);case"MM":return Ln(e.getMonth()+1,2);case"MMM":return Is[e.getMonth()].slice(0,3);case"MMMM":return Is[e.getMonth()];case"D":return String(e.getDate());case"DD":return Ln(e.getDate(),2);case"d":return String(e.getDay());case"dd":return Rr[e.getDay()].slice(0,2);case"ddd":return Rr[e.getDay()].slice(0,3);case"dddd":return Rr[e.getDay()];case"H":return String(s);case"HH":return Ln(s,2);case"h":return String(s%12||12);case"hh":return Ln(s%12||12,2);case"a":return s<12?"am":"pm";case"A":return s<12?"AM":"PM";case"m":return String(e.getMinutes());case"mm":return Ln(e.getMinutes(),2);case"s":return String(e.getSeconds());case"ss":return Ln(e.getSeconds(),2);case"SSS":return Ln(e.getMilliseconds(),3);case"Z":return Wg(e);default:return Wg(e).replace(":","")}})}function Iu(e){let t=e.getFullYear(),n=e.getMonth()+1,r=e.getDate();return(t>=1e3&&t<=9999?t:Ln(t,4))+(n<10?"-0":"-")+n+(r<10?"-0":"-")+r}var nT=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,rT=/\[[^\]]+]/g,Yg=/\d/,Eo=/\d\d/,sT=/\d{3}/,iT=/\d{4}/,Qn=/\d\d?/,oT=/[+-]?\d+/,Hg=/[+-]\d\d:?(\d\d)?|Z/,Ao=/\d*[^-_:/,()\s\d]+/;function gn(e){return(t,n)=>(t[e]=+n,!0)}var Kg=(e,t)=>{if(t==="Z")return e.offset=0,!0;let n=t.match(/([+-]|\d\d)/g),r=+n[1]*60+(+n[2]||0);return e.offset=r===0?0:n[0]==="+"?-r:r,!0};function zg(e){return(t,n)=>{let r=e.indexOf(n)+1;return r<1?!1:(t.month=r%12||r,!0)}}var aT=new Map([["A",{re:Ao,read:(e,t)=>(e.afternoon=t==="PM",!0)}],["a",{re:Ao,read:(e,t)=>(e.afternoon=t==="pm",!0)}],["Q",{re:Yg,read:(e,t)=>(e.month=(+t-1)*3+1,!0)}],["S",{re:Yg,read:(e,t)=>(e.milliseconds=+t*100,!0)}],["SS",{re:Eo,read:(e,t)=>(e.milliseconds=+t*10,!0)}],["SSS",{re:sT,read:(e,t)=>(e.milliseconds=+t,!0)}],["s",{re:Qn,read:gn("seconds")}],["ss",{re:Qn,read:gn("seconds")}],["m",{re:Qn,read:gn("minutes")}],["mm",{re:Qn,read:gn("minutes")}],["H",{re:Qn,read:gn("hours")}],["h",{re:Qn,read:gn("hours")}],["HH",{re:Qn,read:gn("hours")}],["hh",{re:Qn,read:gn("hours")}],["D",{re:Qn,read:gn("day")}],["DD",{re:Eo,read:gn("day")}],["Do",{re:Ao,read:(e,t)=>{let n=t.match(/\d+/);if(!n)return!1;e.day=+n[0],e.dayGiven=!0;for(let r=1;r<=31;r++)jg(r)===t&&(e.day=r);return!0}}],["w",{re:Qn,read:gn("week")}],["ww",{re:Eo,read:gn("week")}],["M",{re:Qn,read:gn("month")}],["MM",{re:Eo,read:gn("month")}],["MMM",{re:Ao,read:zg(Is.map(e=>e.slice(0,3)))}],["MMMM",{re:Ao,read:zg(Is)}],["Y",{re:oT,read:gn("year")}],["YY",{re:Eo,read:(e,t)=>(e.year=+t+(+t>68?1900:2e3),!0)}],["YYYY",{re:iT,read:gn("year")}],["Z",{re:Hg,read:Kg}],["ZZ",{re:Hg,read:Kg}]]),Vg,ic=null;function cT(e){if(e===Vg)return ic;if(Vg=e,ic=null,/[Ll]/.test(e.replace(rT,"")))return null;let t=e.match(nT);return t?(ic=t.map(n=>aT.get(n)??n.replace(/^\[|\]$/g,"")),ic):null}function lT(e,t,n){if(t==="x"||t==="X")return new Date((t==="X"?1e3:1)*Number(e));let r=cT(t);if(!r)return;let o={},s=e,a=0;for(let h of r){if(typeof h=="string"){a+=h.length;continue}let g=h.re.exec(s.slice(a));if(!g||!h.read(o,g[0]))return;s=s.replace(g[0],"")}o.afternoon!==void 0&&o.hours!==void 0&&(o.afternoon?o.hours<12&&(o.hours+=12):o.hours===12&&(o.hours=0));let i=o.dayGiven||o.day?o.day:!o.year&&!o.month?n.getDate():1,c=o.year||n.getFullYear(),l=0;o.year&&!o.month||(l=o.month>0?o.month-1:n.getMonth());let f=o.hours||0,p=o.minutes||0,u=o.seconds||0,m=o.milliseconds||0;if(o.offset!==void 0)return new Date(Date.UTC(c,l,i,f,p,u,m+o.offset*6e4));if(!o.week)return new Date(c,l,i,f,p,u,m)}function Qg(e,t,n){let r=lT(e,t,n);return r&&mi(r)&&Cu(r,t)===e?r:void 0}var dT=/^[YMDHhmsSZXx\-/.:, T]*$/,uT=/^\s*(active|done|crit|milestone|vert)\s*$/,fT=/^after\s+([\d\w- ]+)/,pT=/^until\s+([\d\w- ]+)/,hT=/^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/,mT=/[\s,]+/,gT=/^\d+$/,bT=new Set(Rr.map(e=>e.toLowerCase())),yT=4e8,ET=400,AT=200,xT=400;function Nu(e){let t=e===void 0?NaN:+e;return Number.isFinite(t)?t:Date.now()}function ST(e){let t=hT.exec(e.trim());return t?[Number.parseFloat(t[1]),t[2]]:[NaN,"ms"]}function Zg(e,t){let n=new Set(e);for(let r of t.toLowerCase().split(mT))r!==""&&n.add(r);return[...n]}var ac=class{type="gantt";title;accTitle;accDescr;dateFormat="";axisFormat="";tickInterval;todayMarker="";includes=[];excludes=[];inclusiveEndDates=!1;topAxis=!1;displayMode="";weekday;weekend="saturday";sections=[];links=new Map;tasks=[];byId=new Map;currentSection="";taskCount=0;lastOrder=0;lastTaskId;options;now=0;work=0;includeSet=new Set;excludeSet=new Set;excludedDays=[];datedTokens=!1;constructor(t={}){this.options=t}setDateFormat(t){this.dateFormat=t}enableInclusiveEndDates(){this.inclusiveEndDates=!0}TopAxis(){this.topAxis=!0}setAxisFormat(t){this.axisFormat=t}setTickInterval(t){this.tickInterval=t}setTodayMarker(t){this.todayMarker=t}setIncludes(t){this.includes=Zg(this.includes,t)}setExcludes(t){this.excludes=Zg(this.excludes,t)}setWeekday(t){this.weekday=t}setWeekend(t){this.weekend=t}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
84
+ `)}addSection(t){this.currentSection=t,this.sections.push(t)}addTask(t,n){let r=(n.startsWith(":")?n.slice(1):n).split(","),o={id:"",task:t,section:this.currentSection,startTime:void 0,endTime:void 0,renderEndTime:null,manualEndTime:!1,processed:!1,active:!1,done:!1,crit:!1,milestone:!1,vert:!1,order:-1,classes:[],prevTaskId:this.lastTaskId,raw:{data:n,start:void 0,end:""}},s;for(;r.length>0&&(s=uT.exec(r[0]))!==null;)o[s[1]]=!0,r.shift();if(r.length===0)throw new Ge(`Task "${t.trim()}" needs a duration or an end date.`,"semantic",{type:"gantt"});if(r.length>3)throw new Ge(`Task "${t.trim()}" has too many fields. A task takes an id, a start, and an end or duration.`,"semantic",{type:"gantt"});for(let a=0;a<r.length;a++)r[a]=r[a].trim();r.length===3?o.id=r[0]:(this.taskCount++,o.id="task"+this.taskCount),r.length>1&&(o.raw.start=r[r.length-2]),o.raw.end=r[r.length-1],o.vert||(o.order=this.lastOrder++),this.tasks.push(o),this.lastTaskId=o.id,this.byId.set(o.id,o)}setLink(t,n){let r=vn(n);for(let o of t.split(","))this.byId.has(o)&&this.links.set(o,r);this.setClass(t,"clickable")}setClickEvent(t,n,r){this.setClass(t,"clickable")}setClass(t,n){for(let r of t.split(","))this.byId.get(r)?.classes.push(n)}getTasks(t){this.now=Nu(t),this.work=0,this.includeSet=new Set(this.includes),this.excludeSet=new Set(this.excludes);let n=this.weekend==="friday"?5:this.weekend==="saturday"?6:NaN,r=this.excludeSet.has("weekends");this.excludedDays=Rr.map((s,a)=>{let i=a||7;return r&&(i===n||i===n+1)||this.excludeSet.has(s.toLowerCase())}),this.datedTokens=this.includes.length>0||!dT.test(this.dateFormat.trim());for(let s of this.excludes)s!=="weekends"&&!bT.has(s)&&(this.datedTokens=!0);for(let s of this.tasks)s.startTime=s.endTime=void 0,s.renderEndTime=null,s.processed=s.manualEndTime=!1;let o=this.compileTasks();for(let s=0;!o&&s<10;s++)o=this.compileTasks();return this.tasks}isInvalidDate(t){let n=this.excludedDays[t.getDay()];if(!this.datedTokens)return n;let r=this.dateFormat.trim(),o=Iu(t),s=o;this.spend(AT),r!=="YYYY-MM-DD"&&(this.spend(xT+r.length*8),s=Cu(t,r));let a=i=>i.has(o)||s!==void 0&&i.has(s);return a(this.includeSet)?!1:n||a(this.excludeSet)}spend(t){if(this.work+=t,this.work>yT)throw new Ge("The gantt chart takes too much work to schedule.","limit",{type:"gantt"})}parse(t,n){return this.spend((n.length+1)*(t.length+1)),Qg(t,n,new Date(this.now))}today(){let t=new Date(this.now);return t.setHours(0,0,0,0),t}warn(t){this.options.warn&&this.options.warn(t())}compileTasks(){let t=!0;for(let n of this.tasks)this.compileTask(n),t=t&&n.processed;return t}compileTask(t){let n=t.raw.start;if(n===void 0){let r=t.prevTaskId===void 0?void 0:this.byId.get(t.prevTaskId);t.startTime=r?r.endTime:this.today()}else{let r=this.getStartDate(n);r&&(t.startTime=r)}t.startTime&&(t.endTime=this.getEndDate(t.startTime,t.raw.end),t.endTime&&(t.processed=!0,t.manualEndTime=this.parse(t.raw.end,"YYYY-MM-DD")!==void 0,this.checkTaskDates(t)))}references(t,n){let r=[],o;for(let s of n.split(" ")){if(s==="")continue;let a=this.byId.get(s);a?r.push(a):(o??=[]).push(s)}if(o){let s=o;this.warn(()=>`Gantt: "${t}" refers to task ids that do not exist: ${s.join(", ")}.`)}return r}getStartDate(t){let n=t.trim(),r=this.dateFormat.trim();if((r==="x"||r==="X")&&gT.test(n))return this.checked(new Date(Number(n)),n);let o=fT.exec(n);if(o!==null){let i=this.references("after",o[1]),c;for(let l of i)(!c||l.endTime>c.endTime)&&(c=l);return c?c.endTime:this.today()}let s=this.parse(n,r);if(s)return s;let a=new Date(n);if(!mi(a)||a.getFullYear()<-1e4||a.getFullYear()>1e4)throw new Ge("Invalid date:"+n,"semantic",{type:"gantt"});return a}checked(t,n){if(!mi(t))throw new Ge("Invalid date:"+n,"semantic",{type:"gantt"});return t}getEndDate(t,n){let r=n.trim(),o=pT.exec(r);if(o!==null){let f=this.references("until",o[1]),p;for(let u of f)(!p||u.startTime<p.startTime)&&(p=u);return p?p.startTime:this.today()}let s=this.dateFormat.trim(),a=this.parse(r,s);if(a)return this.inclusiveEndDates?dr(a,1):a;let[i,c]=ST(r);if(Number.isNaN(i))return this.warn(()=>`Gantt: "${r}" is neither a date in the "${s}" format nor a duration such as "3d", so the task gets no duration.`),new Date(t);let l=oc(t,i,c);return mi(l)?l:new Date(t)}checkTaskDates(t){if(this.excludes.length===0||t.manualEndTime)return;let n=dr(t.startTime,1),r=new Date(t.endTime),o=+dr(r,1e4),s=!1,a=null;for(;+n<=+r;){if(this.spend(ET),s||(a=+r),s=this.isInvalidDate(n),s&&(r.setDate(r.getDate()+1),+r>o))throw new Ge("Failed to find a valid date that was not excluded by `excludes` after 10,000 iterations.","semantic",{type:"gantt"});n.setDate(n.getDate()+1)}t.endTime=r,t.renderEndTime=a===null?null:new Date(a)}};var Jg=["$end","INVALID","open_directive","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","NL","href","callbackname","callbackargs","click","gantt","dateFormat","inclusiveEndDates","topAxis","axisFormat","tickInterval","includes","excludes","todayMarker","weekday_monday","weekday_tuesday","weekday_wednesday","weekday_thursday","weekday_friday","weekday_saturday","weekday_sunday","weekend_friday","weekend_saturday","date","title","accDescription","section","taskTxt","taskData",":","EOF"];var _T=/accTitle\s*:\s*/iy,wT=/accDescr\s*:\s*/iy,RT=/accDescr\s*\{\s*/iy,TT=/href\s+"/iy,CT=/call\s+/iy,IT=/click\s+/iy,NT=/\(\s*\)/y,Mu=/weekday\s+(monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/iy,MT=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],ku=/weekend\s+(?:(friday)|saturday)\b/iy,kT=/\d\d\d\d-\d\d-\d\d\b/y,LT=new Map([[97,[[/axisFormat\s[^#\n;]+/iy,17],[/accDescription\s[^#\n;]+/iy,33]]],[103,[[/gantt\b/iy,13]]],[100,[[/dateFormat\s[^#\n;]+/iy,14]]],[105,[[/inclusiveEndDates\b/iy,15],[/includes\s[^#\n;]+/iy,19]]],[116,[[/topAxis\b/iy,16],[/tickInterval\s[^#\n;]+/iy,18],[/todayMarker\s[^\n;]+/iy,21],[/title\s[^\n]+/iy,32]]],[101,[[/excludes\s[^#\n;]+/iy,20]]],[115,[[/section\s[^\n]+/iy,34]]]]);function eb(e){let t=e.length,n=[],r=[],o=[],s=0,a=0,i=(p,u,m)=>{n.push(p),r.push(e.slice(u,m)),o.push(u),a=m},c=p=>(p.lastIndex=a,p.test(e)?p.lastIndex:-1),l=(p,u)=>{let m=e.indexOf(p,u);return m===-1?t:m},f=p=>{let u;switch(p|32){case 97:if((u=c(_T))>=0)return s=1,i(3,a,u),!0;if((u=c(wT))>=0)return s=2,i(5,a,u),!0;if((u=c(RT))>=0)return s=3,a=u,!0;break;case 104:if((u=c(TT))>=0)return s=4,a=u,!0;break;case 99:if((u=c(CT))>=0)return s=5,a=u,!0;if((u=c(IT))>=0)return s=7,a=u,!0;break;case 119:{Mu.lastIndex=a;let h=Mu.exec(e);if(h)return i(22+MT.indexOf(h[1].toLowerCase()),a,Mu.lastIndex),!0;if(ku.lastIndex=a,h=ku.exec(e),h)return i(h[1]!==void 0?29:30,a,ku.lastIndex),!0;break}}let m=LT.get(p|32);if(m){for(let[h,g]of m)if((u=c(h))>=0)return i(g,a,u),!0}return!1};for(;;){if(a>=t){let u=38;switch(s){case 1:u=4;break;case 2:u=6;break;case 3:u=7;break;case 4:u=9;break;case 5:u=10;break;case 6:u=11;break;case 7:u=12;break}i(u,t,t);break}let p=e.charCodeAt(a);switch(s){case 0:{let u=e.charCodeAt(a+1);if(p===37)if(u!==37){let m=l(`
85
+ `,a+1);for(;e.charCodeAt(m)===10;)m++;a=m}else{if(e.charCodeAt(a+2)===123)return i(2,a,a+3),i(1,a,a),{types:n,texts:r,starts:o};a=l(`
86
+ `,a+2)}else if(p!==125&&u===37)a=l(`
87
+ `,a+2);else if(p===10){let m=a+1;for(;e.charCodeAt(m)===10;)m++;i(8,a,m)}else if(Be(p))for(a++;a<t&&Be(e.charCodeAt(a));)a++;else{if(f(p))break;if(p>=48&&p<=57&&c(kT)>=0)i(31,a,a+10);else if(p!==58){let m=a+1;for(;m<t;){let h=e.charCodeAt(m);if(h===58||h===10)break;m++}i(35,a,m)}else{let m=a+1;for(;m<t;){let h=e.charCodeAt(m);if(h===35||h===10||h===59)break;m++}i(m>a+1?36:37,a,m)}}break}case 1:case 2:{let u=s===1?4:6;s=0,i(u,a,l(`
88
+ `,a));break}case 3:p===125?(s=0,a++):i(7,a,l("}",a));break;case 4:p===34?(s=0,a++):i(9,a,l('"',a));break;case 5:if(p===40){let u=c(NT);u>=0?(s=0,a=u):(s=6,a++)}else i(10,a,l("(",a));break;case 6:p===41?(s=0,a++):i(11,a,l(")",a));break;case 7:if(Be(p))s=0,a++;else{let u=a+1;for(;u<t&&!Be(e.charCodeAt(u));)u++;i(12,a,u)}break}}return n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o}}var $T=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],tb="'EOF', 'SPACE', 'NL', 'weekday_monday', 'weekday_tuesday', 'weekday_wednesday', 'weekday_thursday', 'weekday_friday', 'weekday_saturday', 'weekday_sunday', 'weekend_friday', 'weekend_saturday', 'dateFormat', 'inclusiveEndDates', 'topAxis', 'axisFormat', 'tickInterval', 'excludes', 'includes', 'todayMarker', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskTxt', 'click'",cc=new Uint8Array(39);for(let e=22;e<=30;e++)cc[e]=1;for(let e of[38,8,14,15,16,17,18,20,19,21,32,3,5,7,34,35,12])cc[e]=1;function nb(e,t){let{types:n,texts:r,starts:o}=eb(e),s=0,a=c=>{let l=n[s];throw it("gantt",e,o[s],`Expecting ${c}, got '${l===0?"1":Jg[l]}'`)},i=(c="")=>{cc[n[s]]!==1&&a(tb+c)};for(n[s]!==13&&a("'gantt'"),s++;;){let c=n[s],l=r[s];switch(cc[c]!==1&&a(tb),s++,c){case 38:if(n[s]===0)return;i();break;case 8:break;case 14:i(),t.setDateFormat(l.slice(11));break;case 15:i(),t.enableInclusiveEndDates();break;case 16:i(),t.TopAxis();break;case 17:i(),t.setAxisFormat(l.slice(11));break;case 18:i(),t.setTickInterval(l.slice(13));break;case 20:i(),t.setExcludes(l.slice(9));break;case 19:i(),t.setIncludes(l.slice(9));break;case 21:i(),t.setTodayMarker(l.slice(12));break;case 29:i(),t.setWeekend("friday");break;case 30:i(),t.setWeekend("saturday");break;case 32:i(),t.setDiagramTitle(l.slice(6));break;case 3:{n[s]!==4&&a("'acc_title_value'");let f=r[s++];i(),t.setAccTitle(f.trim());break}case 5:{n[s]!==6&&a("'acc_descr_value'");let f=r[s++];i(),t.setAccDescription(f.trim());break}case 7:i(),t.setAccDescription(l.trim());break;case 34:i(),t.addSection(l.slice(8));break;case 35:{n[s]!==36&&a("'taskData'");let f=r[s++];i(),t.addTask(l,f);break}case 12:{let f,p=null,u;n[s]===10?(f=r[s++],n[s]===11&&(p=r[s++]),n[s]===9?(u=r[s++],i()):i(p===null?", 'callbackargs', 'href'":", 'href'")):n[s]===9?(u=r[s++],n[s]===10?(f=r[s++],n[s]===11?(p=r[s++],i()):i(", 'callbackargs'")):i(", 'callbackname'")):a("'callbackname', 'href'"),f!==void 0&&t.setClickEvent(l,f,p),u!==void 0&&t.setLink(l,u);break}default:i(),t.setWeekday($T[c-22])}}}var Tr=1e3,Cr=60*Tr,Ns=60*Cr,Ms=24*Ns,_o=7*Ms,$u=30*Ms,uc=365*Ms;function lc(e){e.setHours(0,0,0,0)}function pc(e){return{floor(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),lc(t)},offset:(t,n)=>t.setDate(t.getDate()+n*7),cycle:1/0,ms:_o}}var xo={millisecond:{floor:()=>{},offset:(e,t)=>e.setTime(+e+t),cycle:1/0,ms:1},second:{floor:e=>e.setTime(+e-e.getMilliseconds()),offset:(e,t)=>e.setTime(+e+t*Tr),field:e=>e.getUTCSeconds(),cycle:60,ms:Tr},minute:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*Tr),offset:(e,t)=>e.setTime(+e+t*Cr),field:e=>e.getMinutes(),cycle:60,ms:Cr},hour:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*Tr-e.getMinutes()*Cr),offset:(e,t)=>e.setTime(+e+t*Ns),field:e=>e.getHours(),cycle:24,ms:Ns},day:{floor:lc,offset:(e,t)=>e.setDate(e.getDate()+t),field:e=>e.getDate()-1,cycle:31,ms:Ms},month:{floor(e){e.setDate(1),lc(e)},offset:(e,t)=>e.setMonth(e.getMonth()+t),field:e=>e.getMonth(),cycle:12,ms:$u},year:{floor(e){e.setMonth(0,1),lc(e)},offset:(e,t)=>e.setFullYear(e.getFullYear()+t),cycle:1/0,ms:uc}};function fc(e,t,n){return Math.floor((+t-+e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Cr)/n)}function DT(e,t){return(e%t+t)%t}function dc(e,t,n){let r=e==="week"?pc(n):xo[e];if(t<=1)return r;if(e==="millisecond")return{...r,floor:a=>a.setTime(Math.floor(+a/t)*t),offset:(a,i)=>a.setTime(+a+i*t)};if(e==="year")return{...r,floor(a){a.setFullYear(Math.floor(a.getFullYear()/t)*t),r.floor(a)},offset:(a,i)=>a.setFullYear(a.getFullYear()+i*t)};if(e==="week"){let a=new Date(0);return r.floor(a),{...r,floor(i){r.floor(i),r.offset(i,-DT(fc(a,i,_o),t))},offset:(i,c)=>r.offset(i,c*t)}}let o=r.field,s=a=>o(a)%t===0;return{...r,floor(a){for(r.floor(a);Number.isFinite(+a)&&!s(a);r.floor(a))a.setTime(+a-1)},offset(a,i){for(let c=0;c<i&&Number.isFinite(+a);c++)do r.offset(a,1);while(Number.isFinite(+a)&&!s(a))}}}function ib(e,t,n,r){let o=new Date(t-1);e.floor(o),e.offset(o,1),e.floor(o);let s=[],a=-1/0;for(;+o<=n&&+o>a;){if(s.length>=r)return;a=+o,s.push(a),e.offset(o,1),e.floor(o)}return s}function rb(e,t,n){let r=(t-e)/Math.max(0,n),o=Math.floor(Math.log10(r)),s=r/Math.pow(10,o),a=s>=Math.sqrt(50)?10:s>=Math.sqrt(10)?5:s>=Math.SQRT2?2:1;return Math.pow(10,o)*a}var gi=[["second",1,Tr],["second",5,5*Tr],["second",15,15*Tr],["second",30,30*Tr],["minute",1,Cr],["minute",5,5*Cr],["minute",15,15*Cr],["minute",30,30*Cr],["hour",1,Ns],["hour",3,3*Ns],["hour",6,6*Ns],["hour",12,12*Ns],["day",1,Ms],["day",2,2*Ms],["week",1,_o],["month",1,$u],["month",3,3*$u],["year",1,uc]];function ob(e,t,n){let r=(t-e)/n,o=0;for(;o<gi.length&&gi[o][2]<=r;)o++;let s;if(o===gi.length)s=dc("year",Math.max(1,rb(e/uc,t/uc,n)),0);else if(o===0)s=dc("millisecond",Math.max(rb(e,t,n),1),0);else{let[a,i]=gi[r/gi[o-1][2]<gi[o][2]/r?o-1:o];s=dc(a,i,0)}return ib(s,e,t,4*n+8)??[]}var OT=/^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/,vT=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function ab(e,t,n,r,o){let s=OT.exec(e);if(!s)return;let a=parseInt(s[1],10),i=s[2],c=dc(i,a,Math.max(0,vT.indexOf(t)));if(!((r-n)/(Math.min(a,c.cycle)*c.ms)>o))return ib(c,n,r,o)}function on(e,t,n){let r=e<0?"-":"",o=String(r?-e:e);return r+(o.length<n?t.repeat(n-o.length)+o:o)}function zr(e,t){let n=new Date(+e);return t.floor(n),n}function sb(e,t){let n=pc(t),r=zr(e,xo.year);return fc(zr(new Date(+r-1),n),zr(e,n),_o)}function Lu(e){let t=pc(4),n=e.getDay(),r=zr(n>=4||n===0?e:new Date(+e-1),t);return n>=4||n===0||(t.offset(r,1),t.floor(r)),r}var PT=new Map([["-",""],["_"," "],["0","0"]]);function So(e,t){let n="",r=0,o=e.length;for(let s=0;s<o;s++){if(e.charCodeAt(s)!==37)continue;n+=e.slice(r,s);let a=e.charAt(++s),i=PT.get(a);i!==void 0?a=e.charAt(++s):i=a==="e"?" ":"0",n+=BT(a,t,i),r=s+1}return n+e.slice(r)}function BT(e,t,n){switch(e){case"a":return Rr[t.getDay()].slice(0,3);case"A":return Rr[t.getDay()];case"b":return Is[t.getMonth()].slice(0,3);case"B":return Is[t.getMonth()];case"c":return So("%x, %X",t);case"d":case"e":return on(t.getDate(),n,2);case"f":return on(t.getMilliseconds(),n,3)+"000";case"g":return on(Lu(t).getFullYear()%100,n,2);case"G":return on(Lu(t).getFullYear()%1e4,n,4);case"H":return on(t.getHours(),n,2);case"I":return on(t.getHours()%12||12,n,2);case"j":return on(1+fc(zr(t,xo.year),zr(t,xo.day),Ms),n,3);case"L":return on(t.getMilliseconds(),n,3);case"m":return on(t.getMonth()+1,n,2);case"M":return on(t.getMinutes(),n,2);case"p":return t.getHours()>=12?"PM":"AM";case"q":return String(1+Math.floor(t.getMonth()/3));case"Q":return String(+t);case"s":return String(Math.floor(+t/1e3));case"S":return on(t.getSeconds(),n,2);case"u":return String(t.getDay()||7);case"U":return on(sb(t,0),n,2);case"V":{let r=Lu(t),o=zr(r,xo.year),s=zr(o,pc(4));return on(fc(s,r,_o)+(o.getDay()===4?1:0),n,2)}case"w":return String(t.getDay());case"W":return on(sb(t,1),n,2);case"x":return So("%-m/%-d/%Y",t);case"X":return So("%-I:%M:%S %p",t);case"y":return on(t.getFullYear()%100,n,2);case"Y":return on(t.getFullYear()%1e4,n,4);case"Z":{let r=t.getTimezoneOffset(),o=Math.abs(r);return(r>0?"-":"+")+on(Math.floor(o/60),"0",2)+on(o%60,"0",2)}case"%":return"%";default:return e}}var FT=800,WT=240,bi=8,UT=/<br\s*\/?>/gi;function ur(e,t,n,r){let o=e.gantt?.[t];return typeof o=="number"&&Number.isFinite(o)?Math.min(r,Math.max(n,o)):void 0}function Du(e,t){let n=e.gantt?.[t];return typeof n=="string"?n:void 0}function GT(e,t){return e.gantt?.[t]===!0}function cb(e,t,n){let r=De(e.replace(UT," "),!1,t,n,4e3);return r.lines.length<=1?r:{...r,lines:[r.lines[0]],widths:[r.widths[0]],width:r.widths[0],height:r.lineHeight}}function hc(e){return Number.isFinite(+e.startTime)&&Number.isFinite(+e.endTime)}function YT(e,t,n){let r=e.filter(hc).sort((a,i)=>+a.startTime-+i.startTime||a.order-i.order),o=[];for(let a of r){let i=+a.startTime,c=0;for(;c<o.length&&i<o[c];)c++;o[c]=+a.endTime,n.set(a,t+c)}let s=o.length;for(let a of e)n.has(a)||n.set(a,t+s++);return Math.max(s,1)}function lb(e,t,n){let r=n.fontSize??16,o=n.measurer??Je(n.fontFamily),s=n.padding??8,a=Nu(n.now),i=ur(t,"fontSize",4,72)??Math.round(r*.8125),c=ur(t,"sectionFontSize",4,72)??i,l=Math.round(r*.75),f=ur(t,"barHeight",4,400)??Math.round(i*1.85),p=ur(t,"barGap",0,400)??Math.round(f/4),u=f+p,m=Math.round(ur(t,"numberSectionStyles",1,1e3)??4),h=e.displayMode==="compact",g=e.topAxis||GT(t,"topAxis"),x=e.getTasks(a),y=x.filter(_e=>!_e.vert),_=x.filter(_e=>_e.vert&&hc(_e)),S=new Map;for(let _e of y)S.has(_e.section)||S.set(_e.section,S.size);let P=new Map,k=[];if(h){let _e=new Map;for(let Pe of y){let Ye=_e.get(Pe.section);Ye?Ye.push(Pe):_e.set(Pe.section,[Pe])}for(let[Pe,Ye]of _e){let Ue=YT(Ye,k.length,P);for(let he=0;he<Ue;he++)k.push(Pe)}}else for(let _e of y)P.set(_e,k.length),k.push(_e.section);let w=k.length,I=1/0,D=-1/0;for(let _e of x)hc(_e)&&(I=Math.min(I,+_e.startTime),D=Math.max(D,+_e.endTime));let U=I<=D,M=De(e.title,!1,o,r,4e3,1),Q=M.height>0?M.height+16:0;if(!U){let _e=Math.ceil(Math.max(M.width,1)+2*s),Pe=Math.ceil(Math.max(M.height,1)+2*s),Ye=Ie(M,_e/2,s+M.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:Ze("gantt",_e,Pe,r,n,e,Ye),width:_e,height:Pe,links:[]}}let q=new Map,Y=0;for(let _e of S.keys()){let Pe=De(_e,!1,o,c,180);q.set(_e,Pe),Y=Math.max(Y,Pe.width)}let z=e.axisFormat||(e.dateFormat==="D"?"%d":Du(t,"axisFormat")??"%Y-%m-%d"),R=_e=>So(z,new Date(_e)),L=Math.max(o.width(R(I),l,0),o.width(R(D),l,0)),F=s+(ur(t,"leftPadding",0,2e3)??Math.max(Y>0?Y+24:0,L/2)),E=ur(t,"rightPadding",0,2e3)??Math.max(16,L/2),C=Wr(n,ur(t,"useWidth",100,2e4)??FT,280),A=Math.max(WT,C-F-E-s),T=F+A,b=D>I?A/(D-I):0,N=_e=>b===0?F+A/2:F+(_e-I)*b,$=Math.round(l*1.75),X=ur(t,"topPadding",0,2e3),V=ur(t,"gridLineStartPadding",0,2e3),O=s+Q+(g?$:0),v=Math.max(O,X??0),W=X!==void 0&&V!==void 0?Math.max(0,Math.min(X-V,v-O)):0,H=Math.max(w,1)*u,G=v+H,te=[],Z=T+E;for(let _e of y){let Pe=cb(_e.task,o,i),Ye=P.get(_e);if(!hc(_e)){let Re=F+bi+Pe.width/2;Z=Math.max(Z,Re+Pe.width/2),te.push({task:_e,label:Pe,row:Ye,x0:NaN,x1:NaN,labelX:Re,inside:!1});continue}let Ue=N(+_e.startTime),he=Math.max(N(+(_e.renderEndTime??_e.endTime)),Ue+(_e.milestone?0:2));if(_e.milestone){let Re=Ue+(N(+_e.endTime)-Ue)/2;Ue=Re-f/2,he=Re+f/2}let ne=!_e.milestone&&Pe.width+2*bi<=he-Ue,pe=(Ue+he)/2;if(!ne){let Re=he+bi+Pe.width<=T+E,le=Ue-bi-Pe.width>=F;pe=Re||!le?he+bi+Pe.width/2:Ue-bi-Pe.width/2,Z=Math.max(Z,pe+Pe.width/2)}te.push({task:_e,label:Pe,row:Ye,x0:Ue,x1:he,labelX:pe,inside:ne})}let B=e.tickInterval||Du(t,"tickInterval")||"",K=e.weekday??Du(t,"weekday")??"sunday",ee=Math.max(2,Math.min(10,Math.floor(A/(L+24)))),ae=ab(B,K,I,D,Math.ceil(A/3))??ob(I,D,ee),J="",se="",me="",Ae=-1/0,de="",oe=G+$/2+2,ye=v-W-$/2-2;for(let _e of ae){let Pe=N(_e);J+=`M${d(Pe)},${d(v-W)}V${d(G)}`;let Ye=R(_e),Ue=o.width(Ye,l,0);if(Pe-Ue/2<Ae+8||Ye===de)continue;Ae=Pe+Ue/2,de=Ye,Z=Math.max(Z,Ae);let he=`text-anchor="middle">${je(Ye)}</text>`;se+=`<text x="${d(Pe)}" y="${d(oe+l*.35)}" ${he}`,g&&(me+=`<text x="${d(Pe)}" y="${d(ye+l*.35)}" ${he}`)}let ce="",fe="",xe=[],be=G+$+4,re=Math.round(i*1.5);for(let _e of[..._].sort((Pe,Ye)=>+Pe.startTime-+Ye.startTime)){let Pe=N(+_e.startTime),Ye=cb(_e.task,o,i),Ue=Math.max(s+Ye.width/2,Pe),he=0;for(;he<xe.length&&Ue-Ye.width/2<xe[he]+8;)he++;xe[he]=Ue+Ye.width/2,Z=Math.max(Z,xe[he]),ce+=`<path class="pele-vert" data-id="${$e(_e.id)}" d="M${d(Pe)},${d(v-W)}V${d(G)}"/>`,fe+=Ie(Ye,Ue,be+he*re+re/2,` class="pele-vert-label" data-id="${$e(_e.id)}"`)}let j=Math.ceil(Math.max(Z,s+M.width)+s),ie=Math.ceil(G+$+(xe.length>0?4+xe.length*re:0)+s),ue="",ge="";for(let _e=0;_e<w;){let Pe=k[_e],Ye=_e+1;for(;Ye<w&&k[Ye]===Pe;)Ye++;let Ue=S.get(Pe)%m,he=v+_e*u,ne=(Ye-_e)*u;(S.size>1||Pe!=="")&&(ue+=`<rect class="pele-section pele-section-${Ue}" x="0" y="${d(he)}" width="${j}" height="${d(ne)}" fill="${Ue%2===0?"var(--_s)":"none"}"/>`);let pe=q.get(Pe);ge+=Ie(pe,s+8+pe.width/2,he+ne/2,` class="pele-section-label" data-id="${$e(Pe)}"`,n.icons),_e=Ye}let Se="";if((e.excludes.length>0||e.includes.length>0)&&+oc(new Date(I),6,"y")>D){let _e,Pe,Ye=()=>{if(!_e||!Pe)return;let Ue=new Date(_e);Ue.setHours(0,0,0,0);let he=new Date(Pe);he.setHours(23,59,59,999);let ne=Math.max(F,N(+Ue)),pe=Math.min(T,N(+he));pe>ne&&(Se+=`<rect x="${d(ne)}" y="${d(v)}" width="${d(pe-ne)}" height="${d(H)}"/>`),_e=Pe=void 0};for(let Ue=new Date(I);+Ue<=D;Ue=dr(Ue,1))e.isInvalidDate(Ue)?(_e??=Ue,Pe=Ue):Ye();Ye()}let we=[],ke="";for(let _e of te){let Pe=_e.task,Ye=v+_e.row*u+u/2,Ue=Pe.active?"active":Pe.done?"done":"",he="pele-task";Ue&&(he+=" pele-"+Ue),Pe.crit&&(he+=" pele-crit"),Pe.milestone&&(he+=" pele-milestone"),Pe.classes.includes("clickable")&&(he+=" pele-clickable");let ne="",pe="";if(Number.isNaN(_e.x0))he+=" pele-unscheduled",pe=' fill="var(--_m)"';else{let Ee=Pe.crit?ji:"var(--_c)",Ne=Ue==="done"?'fill="var(--_a)"':Ue==="active"?`fill="${Ee}" fill-opacity="0.25"`:`fill="${Ee}"`,Me=`stroke="${Ue==="done"&&!Pe.crit?"var(--_b)":Ee}"`;if(Pe.milestone){let Ce=(_e.x0+_e.x1)/2,Oe=f/2;ne=`<path d="M${d(Ce)},${d(Ye-Oe)}L${d(Ce+Oe)},${d(Ye)}L${d(Ce)},${d(Ye+Oe)}L${d(Ce-Oe)},${d(Ye)}Z" ${Ne} ${Me} stroke-linejoin="round"/>`}else ne=`<rect x="${d(_e.x0)}" y="${d(Ye-f/2)}" width="${d(_e.x1-_e.x0)}" height="${d(f)}" rx="${Xe}" ${Ne} ${Me}/>`;_e.inside?pe=Ue===""?' fill="var(--_bg)"':"":Ue==="done"&&(pe=' fill="var(--_m)"')}let Re=ne+Ie(_e.label,_e.labelX,Ye,` class="pele-label"${pe}`),le=e.links.get(Pe.id);le!==void 0&&(Re=Pn(Re,le,Pe.id,we,n)),ke+=`<g class="${he}" data-id="${$e(Pe.id)}">${Re}</g>`}let Le="";if(e.todayMarker!=="off"&&a>=I&&a<=D&&D>I){let _e=N(a),Pe=v-W,Ye=e.todayMarker?At(e.todayMarker.split(",")).line:"";Le=`<g class="pele-today"><path d="M${d(_e)},${d(Pe)}V${d(G)}" fill="none" stroke="var(--_c)" stroke-width="2"${Ye}/>`+(Ye?"":`<path d="M${d(_e-4)},${d(Pe-5)}H${d(_e+4)}L${d(_e)},${d(Pe+1)}Z" fill="var(--_c)"/>`)+"</g>"}let Fe=`M${d(F)},${d(G)}H${d(T)}`+(g?`M${d(F)},${d(v-W)}H${d(T)}`:""),He=Ie(M,j/2,s+M.height/2,' class="pele-title" font-weight="var(--_tw)"')+(ue?`<g class="pele-sections">${ue}</g>`:"")+(Se?`<g class="pele-excluded" fill="var(--_a)">${Se}</g>`:"")+`<g class="pele-grid" fill="none"><path d="${J}" stroke="var(--_b)" stroke-dasharray="1 3"/><path d="${Fe}" stroke="var(--_b)"/></g>`+(ce?`<g class="pele-verts" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-dasharray="4 3">${ce}</g>`:"")+Le+`<g class="pele-tasks" font-size="${d(i)}">${ke}</g><g class="pele-section-labels" font-size="${d(c)}">${ge}</g><g class="pele-axis" font-size="${l}" fill="var(--_m)">${se}${me}</g>`+(fe?`<g class="pele-vert-labels" font-size="${d(i)}">${fe}</g>`:"");return{svg:Ze("gantt",j,ie,r,n,e,He),width:j,height:ie,links:we}}var db={type:"gantt",parse(e,t,n){let r=new ac;n&&(r.title=n);let o=t.gantt?.displayMode;return typeof o=="string"&&(r.displayMode=o),nb(e,r),r},render:lb};var Xt={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4};function Rn(e){throw new Ge(e,"semantic",{type:"gitGraph"})}function ub(e){return e==="REVERSE"?Xt.REVERSE:e==="HIGHLIGHT"?Xt.HIGHLIGHT:Xt.NORMAL}function HT(e,t){e.dir&&t.setDirection(e.dir);for(let n of e.statements)KT(n,t)}function KT(e,t){switch(e.$type){case"Commit":t.commit({id:e.id,msg:e.message??"",type:e.type!==void 0?ub(e.type):Xt.NORMAL,tags:e.tags??void 0});break;case"Branch":t.branch({name:e.name,order:e.order??0});break;case"Merge":t.merge({branch:e.branch,id:e.id??"",type:e.type!==void 0?ub(e.type):void 0,tags:e.tags??void 0});break;case"Checkout":t.checkout(e.branch);break;case"CherryPicking":t.cherryPick({id:e.id,targetId:"",tags:e.tags?.length===0?void 0:e.tags,parent:e.parent});break}}function fb(e,t,n){let r=t.gitGraph,o=typeof r?.mainBranchName=="string"?r.mainBranchName:"main",s=typeof r?.mainBranchOrder=="number"?r.mainBranchOrder:0,a=new Map,i=new Map([[o,null]]),c=new Map([[o,s]]),l=[],f=null,p=o,u="LR",m=0,h=()=>{for(let _=m+1;;_+=2654435761){let S=`${m}-${(Math.imul(_,2654435761)>>>0).toString(16).padStart(8,"0").slice(0,7)}`;if(!a.has(S))return S}},g=_=>{f=_,a.set(_.id,_),i.set(p,_.id)},x=_=>{i.has(_)||Rn(`Trying to checkout branch which is not yet created. (Help try using "branch ${_}")`),p=_;let S=i.get(_);f=S?a.get(S)??null:null};HT(e,{setDirection(_){u=_},commit({msg:_,id:S,type:P,tags:k}){let w={id:S||h(),message:_,seq:m++,type:P??Xt.NORMAL,tags:k?[...k]:[],parents:f===null?[]:[f.id],branch:p};a.has(w.id)&&l.push(`Commit ID ${w.id} already exists`),g(w)},branch({name:_,order:S}){i.has(_)&&Rn(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${_}")`),i.set(_,f!==null?f.id:null),c.set(_,S),x(_)},merge({branch:_,id:S,type:P,tags:k}){let w=i.get(p),I=i.get(_),D=w?a.get(w):void 0,U=I?a.get(I):void 0;D&&U&&D.branch===_&&Rn(`Cannot merge branch '${_}' into itself.`),p===_&&Rn('Incorrect usage of "merge". Cannot merge a branch to itself'),D===void 0&&Rn(`Incorrect usage of "merge". Current branch (${p})has no commits`),i.has(_)||Rn(`Incorrect usage of "merge". Branch to be merged (${_}) does not exist`),U===void 0&&Rn(`Incorrect usage of "merge". Branch to be merged (${_}) has no commits`),D===U&&Rn('Incorrect usage of "merge". Both branches have same head'),S&&a.has(S)&&Rn(`Incorrect usage of "merge". Commit with id:${S} already exists, use different custom id`),g({id:S||h(),message:`merged branch ${_} into ${p}`,seq:m++,parents:f===null?[]:[f.id,I||""],branch:p,type:Xt.MERGE,customType:P,customId:!!S,tags:k?[...k]:[]})},cherryPick({id:_,targetId:S,tags:P,parent:k}){let w=_?a.get(_):void 0;if(w===void 0&&Rn('Incorrect usage of "cherryPick". Source commit id should exist and provided'),k&&!w.parents.includes(k)&&Rn("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit."),w.type===Xt.MERGE&&!k&&Rn("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified."),S&&a.has(S))return;w.branch===p&&Rn('Incorrect usage of "cherryPick". Source commit is already on current branch');let I=i.get(p);(!I||!a.has(I))&&Rn(`Incorrect usage of "cherry-pick". Current branch (${p})has no commits`),g({id:h(),message:`cherry-picked ${w.message} into ${p}`,seq:m++,parents:f===null?[]:[f.id,w.id],branch:p,type:Xt.CHERRY_PICK,tags:P?P.filter(Boolean):[`cherry-pick:${w.id}${w.type===Xt.MERGE?`|parent:${k}`:""}`]})},checkout:x});let y=[...c].map(([_,S],P)=>({name:_,order:S??parseFloat(`0.${P}`)})).sort((_,S)=>_.order-S.order).map(_=>_.name);return{type:"gitGraph",title:e.title||n,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
89
+ `):void 0,direction:u,commits:a,branches:i,lanes:y,currentBranch:p,head:f,warnings:l}}var hb={name:"REFERENCE",pattern:/\w([-\./\w]*[-\w])?/y},mb=[hb];function Fn(e){return{name:e,pattern:e,longer:mb}}var pb=[Fn("cherry-pick"),{name:"gitGraph:",pattern:"gitGraph:"},Fn("HIGHLIGHT"),{...Vt("gitGraph"),longer:mb},Fn("checkout"),Fn("REVERSE"),{name:"parent:",pattern:"parent:"},Fn("commit"),Fn("NORMAL"),Fn("branch"),{name:"order:",pattern:"order:"},Fn("switch"),{name:"type:",pattern:"type:"},Fn("merge"),{name:"msg:",pattern:"msg:"},{name:"tag:",pattern:"tag:"},{name:"id:",pattern:"id:"},Fn("LR"),Fn("TB"),Fn("BT"),{name:":",pattern:":"},{...Zt,opener:/[\t ]*accDescr\s*{/y},Yt,Ht,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},wn,hn,mn,Pt,Kt,zt,hb];function gb(e){let t=new Dt(vt(e,pb,"gitGraph"),pb,"gitGraph"),n={$type:"GitGraph",statements:[]},r=()=>{if(t.kind!==-1)for(t.kind!==26&&t.fail("a line break or the end of input");t.kind===26;)t.i++},o=()=>t.kind===31?t.take():t.kind===25?rn(t.take()):t.fail("a branch name"),s=()=>rn(t.expect(25)),a=()=>(t.kind!==8&&t.kind!==5&&t.kind!==2&&t.fail("NORMAL, REVERSE, or HIGHLIGHT"),t.take());for(;t.kind===26;)t.i++;if(!t.accept(1)){t.expect(3);let i=t.kinds[t.i+1];(t.kind===17||t.kind===18||t.kind===19)&&i===20?(n.$type="Direction",n.dir=t.take(),t.i++):t.accept(20)}for(;t.kind!==-1;)switch(t.kind){case 26:t.i++;break;case 21:n.accDescr=Wt(t.take()),r();break;case 22:n.accTitle=Ft(t.take()),r();break;case 23:n.title=Bt(t.take()),r();break;case 7:{t.i++;let i={$type:"Commit",tags:[]};for(;;)if(t.accept(16))i.id=s();else if(t.accept(15))i.tags.push(s());else if(t.accept(12))i.type=a();else if(t.accept(14)||t.kinds[t.i]===25)i.message=s();else break;r(),n.statements.push(i);break}case 9:{t.i++;let i={$type:"Branch",name:o()};t.accept(10)&&(i.order=parseInt(t.expect(24))),r(),n.statements.push(i);break}case 13:{t.i++;let i={$type:"Merge",branch:o(),tags:[]};for(;;)if(t.accept(16))i.id=s();else if(t.accept(15))i.tags.push(s());else if(t.accept(12))i.type=a();else break;r(),n.statements.push(i);break}case 4:case 11:{t.i++;let i={$type:"Checkout",branch:o()};r(),n.statements.push(i);break}case 0:{t.i++;let i={$type:"CherryPicking",tags:[]};for(;;)if(t.accept(16))i.id=s();else if(t.accept(15))i.tags.push(s());else if(t.accept(6))i.parent=s();else break;r(),n.statements.push(i);break}default:t.fail("a statement, a title, or a line break")}return n}var zT=/<(?!br\s*\/?>)/gi,VT=/:fa-/g,jT=/<br\s*\/?>|fl°°?\w+¶ß|&#?\w+;|[\ud800-\udbff][\udc00-\udfff]|[\s\S]/gi;function Zn(e,t,n,r,o=0){let s=e;return s!==void 0&&(s.includes("<")&&(s=s.replace(zT,"&lt;")),s.includes(":fa-")&&(s=s.replace(VT,"&colon;fa-"))),De(s,!1,t,n,r,o)}function Tn(e,t,n,r,o=0){let s=Zn(e,t,n,r,o);if(e===void 0||s.width<=r)return s;let a="",i=0;for(let c of e.match(jT)??[]){if(c.trim()===""||c.length>2&&c[0]==="<")i=0;else{let l=t.width(c.length>2?"x":c,n,o);i>0&&i+l>r&&(a+=`
90
+ `,i=0),i+=l}a+=c}return Zn(a,t,n,r,o)}var qt=7,XT=44,qT=44,mc=36,gc=8,ks=20,wo=20,Ro=7,bb=6,Ou=Math.SQRT1_2,yb=["normal","reverse","highlight","merge","cherry-pick"];function bc(e,t,n){let r=e.gitGraph?.[t];return typeof r=="boolean"?r:n}function Eb(e){return Ro+4+e.width+6}function QT(e,t,n,r){let o=`cx="${d(t)}" cy="${d(n)}"`;if(e===Xt.HIGHLIGHT)return`<rect x="${d(t-qt-1)}" y="${d(n-qt-1)}" width="${2*qt+2}" height="${2*qt+2}" rx="2" fill="${r}"/>`;if(e===Xt.MERGE)return`<circle ${o} r="${qt-1}" fill="var(--_bg)" stroke="${r}" stroke-width="2"/><circle ${o} r="2.5" fill="${r}"/>`;let s=`<circle ${o} r="${qt}" fill="${r}"/>`;return e===Xt.REVERSE?s+`<path d="M${d(t-3)},${d(n-3)}l6,6M${d(t-3)},${d(n+3)}l6,-6" fill="none" stroke="var(--_bg)" stroke-width="1.5" stroke-linecap="round"/>`:e===Xt.CHERRY_PICK?s+`<path d="M${d(t-2.6)},${d(n+1)}L${d(t+.8)},${d(n-4.2)}L${d(t+2.6)},${d(n+1)}" fill="none" stroke="var(--_bg)" stroke-linejoin="round"/><circle cx="${d(t-2.6)}" cy="${d(n+2.2)}" r="1.8" fill="var(--_bg)"/><circle cx="${d(t+2.6)}" cy="${d(n+2.2)}" r="1.8" fill="var(--_bg)"/>`:s}function xb(e,t,n){return e.direction!=="LR"?Ab(e,t,n,e.direction):Nt(n,r=>Ab(e,t,n,r?"TB":"LR"))}function Ab(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.75),a=n.measurer??Je(n.fontFamily),i=n.padding??8,c=bc(t,"showBranches",!0),l=bc(t,"showCommitLabel",!0),f=bc(t,"rotateCommitLabel",!0),p=bc(t,"parallelCommits",!1),u=r!=="LR",m=r==="BT",h=new Map;e.lanes.forEach((B,K)=>h.set(B,K));let g=e.lanes.length,x=Math.round(o*.875),y=e.lanes.map(B=>Zn(c?B:"",a,x,4e3)),_=[],S=new Map;for(let B of[...e.commits.values()].sort((K,ee)=>K.seq-ee.seq)){let K=l&&B.type!==Xt.CHERRY_PICK&&(B.type!==Xt.MERGE||B.customId===!0),ee=[];for(let J of B.tags){let se=Zn(J,a,s,4e3);se.lines.length>0&&ee.push(se)}let ae={commit:B,index:_.length,lane:h.get(B.branch)??0,m:0,label:K?Zn(B.id,a,s,4e3):void 0,tags:ee};_.push(ae),S.set(B.id,ae)}let P=new Float64Array(_.length),k=new Float64Array(_.length),w=new Float64Array(g).fill(qt),I=new Float64Array(g).fill(qt);_.forEach((B,K)=>{let{label:ee,tags:ae}=B,J=0,se=0;for(let ce of ae){let fe=Eb(ce);u?(J=Math.max(J,ce.height),se+=fe+4):(J=Math.max(J,fe),se+=ce.height+3)}let me=0,Ae=0;ee!==void 0&&ee.lines.length>0&&(f?Ae=3+Ou*(ee.width+ee.height):(me=u?ee.height:ee.width,Ae=6+(u?ee.width:ee.height))),P[K]=Math.max(qt,J/2,me/2),k[K]=J/2;let de=qt+(ae.length>0?bb+se:0),oe=qt+Ae,ye=B.lane;w[ye]=Math.max(w[ye],u?oe:de),I[ye]=Math.max(I[ye],u?de:oe)});let D=new Float64Array(_.length);u||_.forEach((B,K)=>{if(k[K]!==0)for(let ee of B.commit.parents){let ae=S.get(ee);ae!==void 0&&ae.lane<B.lane&&(D[K]=k[K]+4)}});let U=(B,K)=>Math.max(XT,P[B]+P[K]+gc,D[K]>0?P[B]+mc+D[K]:0);_.forEach((B,K)=>{if(!p){B.m=K===0?0:_[K-1].m+U(K-1,K);return}let ee=0;for(let ae of B.commit.parents){let J=S.get(ae);J===void 0||J.index>=K||(ee=Math.max(ee,J.m+U(J.index,K)))}B.m=ee});let M=0;for(let B of _)M=Math.max(M,B.m);let Q=new Float64Array(g);for(let B=0;B<g;B++){let K=y[B],ee=K.lines.length===0?0:u?K.width/2+8:K.height/2+2;w[B]=Math.max(w[B],ee),I[B]=Math.max(I[B],ee),B>0&&(Q[B]=Q[B-1]+Math.max(qT,I[B-1]+w[B]+gc))}let q=(B,K)=>u?K:B,Y=(B,K)=>u?m?-B:B:K,z=(B,K)=>`${d(q(B,K))},${d(Y(B,K))}`,R=1/0,L=1/0,F=-1/0,E=-1/0,C=(B,K,ee,ae)=>{B<R&&(R=B),K<L&&(L=K),ee>F&&(F=ee),ae>E&&(E=ae)},A="";if(c)for(let B=0;B<g;B++){let K=y[B],ee=ct(B),ae=Q[B],J=K.width+16,se=K.height+4,me=K.lines.length===0?-ks:-ks-(u?se:J),Ae=q(me+(u?se:J)/2,ae),de=Y(me+(u?se:J)/2,ae);C(q(-ks,ae),Y(-ks,ae),q(-ks,ae),Y(-ks,ae)),C(q(M+wo,ae),Y(M+wo,ae),q(M+wo,ae),Y(M+wo,ae)),A+=`<g class="pele-branch" data-id="${$e(e.lanes[B])}"><path class="pele-lane" d="M${z(-ks,ae)}L${z(M+wo,ae)}" stroke="${ee}" stroke-dasharray="2 4"/>`,K.lines.length>0&&(C(Ae-J/2,de-se/2,Ae+J/2,de+se/2),A+=`<rect x="${d(Ae-J/2)}" y="${d(de-se/2)}" width="${d(J)}" height="${d(se)}" rx="${Xe}" fill="${ee}"/>`+Ie(K,Ae,de,' class="pele-label" fill="var(--_bg)"')),A+="</g>"}let T=Array.from({length:g},()=>[]);for(let B of _)T[B.lane].push(B.m);if(p)for(let B of T)B.sort((K,ee)=>K-ee);let b=(B,K,ee)=>{let ae=T[B],J=0,se=ae.length;for(;J<se;){let me=J+se>>1;ae[me]<=K?J=me+1:se=me}return J<ae.length&&ae[J]<ee},N="",$="";for(let B of _){let{commit:K}=B,ee=Q[B.lane],ae=B.m;for(let J=0;J<K.parents.length;J++){let se=S.get(K.parents[J]);if(se===void 0||se===B)continue;let me=Q[se.lane],Ae=se.m;if(se.lane===B.lane){$+=`<path class="pele-edge" d="M${z(Ae,me)}L${z(ae,ee)}" stroke="${ct(B.lane)}"/>`;continue}let de=J>0&&K.type===Xt.MERGE,oe=J>0&&!de,ye=`M${z(Ae,me)}`;if(ae<=Ae){let ce=(Ae+ae)/2;ye+=`C${z(ce,me)} ${z(ce,ee)} ${z(ae,ee)}`}else if(!de&&!b(B.lane,Ae,ae)){let ce=Math.min(mc,ae-Ae);ye+=`C${z(Ae+ce/2,me)} ${z(Ae+ce/2,ee)} ${z(Ae+ce,ee)}L${z(ae,ee)}`}else{let ce=se.lane<B.lane&&ae-D[B.index]>Ae?ae-D[B.index]:ae,fe=Math.min(mc,ce-Ae),xe=me;(!de||b(se.lane,Ae,ae))&&(xe=me>ee?ee+I[B.lane]+gc/2:ee-w[B.lane]-gc/2,fe=Math.min(mc,(ce-Ae)/2),ye+=`C${z(Ae+fe/2,me)} ${z(Ae+fe/2,xe)} ${z(Ae+fe,xe)}`),ye+=`L${z(ce-fe,xe)}C${z(ce-fe/2,xe)} ${z(ce-fe/2,ee)} ${z(ce,ee)}`,ce<ae&&(ye+=`L${z(ae,ee)}`)}N+=`<path class="pele-edge${de?" pele-edge-merge":oe?" pele-edge-cherry-pick":""}" d="${ye}" stroke="${ct(de?se.lane:B.lane)}"${oe?' stroke-dasharray="4 3"':""}/>`}}let X="";for(let B of _){let{commit:K,label:ee,tags:ae}=B,J=q(B.m,Q[B.lane]),se=Y(B.m,Q[B.lane]),me=K.customType??K.type;C(J-qt-1,se-qt-1,J+qt+1,se+qt+1);let de=K.type<Xt.MERGE&&K.message!==""?`<title>${$e(K.message)}</title>`:"";if(de+=QT(me,J,se,ct(B.lane)),ee!==void 0&&ee.lines.length>0){let ce=ee.width,fe=ee.height,xe=(be,re)=>`<rect x="${d(be-ce/2-2)}" y="${d(re-fe/2+2)}" width="${d(ce+4)}" height="${d(fe-4)}" rx="3" fill="var(--_bg)"/>`;if(f){let be=Ou*fe/2,re=u?J-qt-3-be:J+3,j=u?se:se+qt+3+be,ie=Ou*ce+be;C(re-ie,m?j-ie:j-be,re+be,m?j+be:j+ie),de+=`<g class="pele-commit-label" transform="rotate(${m?45:-45} ${d(re)} ${d(j)})">`+xe(re-ce/2,j)+Ie(ee,re-ce/2,j,"")+"</g>"}else{let be=u?J-qt-6-ce/2:J,re=u?se:se+qt+6+fe/2;C(be-ce/2,re-fe/2,be+ce/2,re+fe/2),de+=`<g class="pele-commit-label">${xe(be,re)}${Ie(ee,be,re,"")}</g>`}}let oe=qt+bb;for(let ce=u?0:ae.length-1;ce>=0&&ce<ae.length;ce+=u?1:-1){let fe=ae[ce],xe=Eb(fe),be=fe.height,re=u?J+oe:J-xe/2,j=u?se:se-oe-be/2;oe+=u?xe+4:be+3,C(re,j-be/2,re+xe,j+be/2),de+=`<g class="pele-tag"><path d="M${d(re)},${d(j)}L${d(re+Ro)},${d(j-be/2)}H${d(re+xe)}V${d(j+be/2)}H${d(re+Ro)}Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/><circle cx="${d(re+Ro)}" cy="${d(j)}" r="1.5" fill="var(--_b)"/>`+Ie(fe,re+Ro+4+fe.width/2,j,' fill="var(--_fg)"')+"</g>"}let ye=K.type===Xt.MERGE&&me!==Xt.MERGE?" pele-commit-merge":"";X+=`<g class="pele-commit pele-commit-${yb[me]??yb[0]}${ye}" data-id="${$e(K.id)}">${de}</g>`}R>F&&C(0,0,0,0);let V=De(e.title,!1,a,o,4e3,1),O=V.height>0?V.height+16:0,v=Math.max(F-R,V.width),W=Math.ceil(v+2*i),H=Math.ceil(E-L+O+2*i),G=i-R+(v-(F-R))/2,te=i+O-L,Z=Ie(V,W/2,i+V.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(G)},${d(te)})">`+(A?`<g class="pele-branches" fill="none" font-size="${x}">${A}</g>`:"")+(N||$?`<g class="pele-edges" fill="none" stroke-width="2" stroke-linecap="round">${N}${$}</g>`:"")+(X?`<g class="pele-commits" font-size="${s}" fill="var(--_m)">${X}</g>`:"")+"</g>";return{svg:Ze("gitGraph",W,H,o,n,e,Z),width:W,height:H,links:[]}}var Sb={type:"gitGraph",parse:(e,t,n)=>fb(gb(e),t,n),render:xb};function _b(e,t){return{type:"info",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
91
+ `):void 0}}var wb=[Vt("showInfo"),Vt("info"),Zt,Yt,Ht,hn,mn,Pt,Kt,zt];function Rb(e){let t=new Dt(vt(e,wb,"info"),wb,"info"),n={$type:"Info"};for(;t.kind===5;)t.i++;for(t.expect(1);t.kind===5;)t.i++;if(t.accept(0))for(;t.kind===5;)t.i++;for(;t.kind!==-1;){let r=t.kind;if(r===2?n.accDescr=Wt(t.take()):r===3?n.accTitle=Ft(t.take()):r===4?n.title=Bt(t.take()):t.fail("a title or the end of input"),t.kind===-1)break;for(t.kind!==5&&t.fail("a line break or the end of input");t.kind===5;)t.i++}return n}var Tb="1.6.0";function Cb(e,t,n){let r=n.fontSize??16,o=n.measurer??Je(n.fontFamily),s=n.padding??8,a=De(e.title,!1,o,r,4e3,1),i=a.height>0?a.height+8:0,c=De(`Pele v${Tb}`,!1,o,r,4e3),l=Math.ceil(Math.max(a.width,c.width)+2*s),f=Math.ceil(i+c.height+2*s),p=Ie(a,l/2,s+a.height/2,' class="pele-title" font-weight="var(--_tw)"')+Ie(c,l/2,s+i+c.height/2,' class="pele-version" fill="var(--_m)"');return{svg:Ze("info",l,f,r,n,e,p),width:l,height:f,links:[]}}var Ib={type:"info",parse:(e,t,n)=>_b(Rb(e),n),render:Cb};var yc=class{type="ishikawa";title;root;stack=[];baseLevel;addNode(t,n){let r={text:n,children:[]};if(!this.root){this.root=r,this.stack=[{level:0,node:r}];return}this.baseLevel??=t;let o=Math.max(t-this.baseLevel+1,1),s=this.stack;for(;s.length>1&&s[s.length-1].level>=o;)s.pop();s[s.length-1].node.children.push(r),s.push({level:o,node:r})}};var Nb=["$end","EOF","SPACELINE","NL","ISHIKAWA","SPACELIST","TEXT"];function JT(e,t){let n="ishikawa-beta",r=0;for(;r<13;){let o=e.charCodeAt(t+r),s=n.charCodeAt(r);if(o!==s&&(o+32!==s||o<65||o>90))break;r++}return r===13&&!Qe(e.charCodeAt(t+13))?13:r>=8&&!Qe(e.charCodeAt(t+8))?8:0}function Mb(e){let t=[],n=[],r=[],o=e.length,s=0;for(;s<o;){let a=s,i=-1;for(;a<o&&Be(e.charCodeAt(a));)e.charCodeAt(a)===10&&(i=a),a++;let c,l;if(e.charCodeAt(a)===37&&e.charCodeAt(a+1)===37)for(c=2,l=a+2;l<o;){let f=e.charCodeAt(l);if(f===10||f===13||f===8232||f===8233)break;l++}else if(a===s){let f=JT(e,s);f>0?(c=4,l=s+f):(c=6,l=e.indexOf(`
92
+ `,s),l===-1&&(l=o))}else i>s?(c=2,l=i+1):i===s?(c=3,l=s+1):(c=5,l=a);t.push(c),n.push(s),r.push(l),s=l}return t.push(1,0),n.push(o,o),r.push(o,o),{types:t,starts:n,ends:r}}var vu="'SPACELINE', 'NL', 'EOF'";function kb(e,t){let{types:n,starts:r,ends:o}=Mb(e),s=0,a=i=>{throw it("ishikawa",e,r[s],`Expecting ${i}, got '${Nb[n[s]]}'`)};if(n[s]===2){for(s++;n[s]===2||n[s]===3;)s++;n[s]!==4&&a("'SPACELINE', 'NL', 'ISHIKAWA'")}else n[s]!==4&&a("'SPACELINE', 'ISHIKAWA'");for(s++,n[s]===3&&s++;;){let i=n[s];if(i===6||i===5&&n[s+1]===6){let c=i===6?s:s+1;s=c+1,n[s]!==2&&n[s]!==3&&n[s]!==1&&a(vu),t.addNode(i===6?0:o[c-1]-r[c-1],e.slice(r[c],o[c]).trim())}else i===2||i===5?(s++,n[s]!==2&&n[s]!==3&&n[s]!==1&&a(i===5?`${vu}, 'TEXT'`:vu)):a("'SPACELINE', 'SPACELIST', 'TEXT'");for(s++;n[s]===3||n[s]===1;)s++;if(n[s]===0)return}}var Ac=.5,Ec=Math.hypot(Ac,1),e2=14,t2=6,n2=8,Lb=22,r2=18,Pu=5,s2=26,$b=34,i2=28,o2=10,a2=5;function c2(e,t,n,r,o){let s=De(e.text,!1,n,r,180),a=Math.round(o*1.5),i=[],c=[],l=[],f=(h,g,x)=>{let y=h.length;for(let _=y-1;_>=0;_--)l.push({node:h[t?y-1-_:_],depth:g,parent:x,slot:_,bone:-1})};for(f(e.children,2,-1);l.length>0;){let h=l.pop();if(h.bone!==-1){c.push(h.bone);continue}let g=i.length;i.push({label:De(h.node.text,!1,n,o,200),depth:h.depth,parent:h.parent,slot:h.slot,kids:h.node.children.length,rise:0,at:0,textEnd:0}),h.depth%2===0?c.push(g):(h.bone=g,l.push(h)),f(h.node.children,h.depth+1,g)}let p=e2;for(let h of c){let g=Math.max(i[h].label.height,a)+t2;i[h].rise=p+g/2,p+=g}let u=s.width+2*o2,m=u/2;for(let h of i){let g=h.parent===-1?void 0:i[h.parent];h.depth%2===0?(h.at=g?g.at:0,h.textEnd=h.at-(h.kids>0?(h.kids+1)*Lb:r2)-Pu):(h.at=g.at-(g.kids-h.slot)*Lb,h.textEnd=h.at-Pu),m=Math.max(m,h.label.width-h.textEnd)}return{node:e,label:s,boxW:u,boxH:s.height+2*a2,bones:i,rise:p+n2,reach:m}}function Db(e,t,n){return Nt(n,r=>l2(e,t,n,r))}function l2(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.875),a=n.measurer??Je(n.fontFamily),i=n.padding??8;if(r)return d2(e,n);let c=e.root,l=De(e.title,!1,a,o,4e3,1),f=l.height>0?l.height+12:0,p="",u=0,m=0,h=0,g=0;if(c){let w=De(c.text,!1,a,o,200,1),I=Math.max(w.height+24,48),D=w.width+24+I/2,U=c.children.map((R,L)=>c2(R,L%2===0,a,o,s));for(let R of U)R.rise=Math.max(R.rise,I/2+14);let M=[],Q=-$b;for(let R=0;R<U.length;R+=2){if(R>0){let L=0;for(let F=0;F<2;F++){let E=U[R-2+F],C=U[R+F];E&&(L=Math.max(L,E.reach+(C?C.boxW/2:0)))}Q-=L+s2}M.push(Q,Q)}let q=U.length>0?Q-i2:-$b;m=D,u=q,h=-I/2,g=I/2;let Y="";U.forEach((R,L)=>{let F=L%2===0?-1:1,E=M[L],C=(V,O)=>E+V-O*Ac,A=C(0,R.rise),T=F*R.rise,b=kt-1,N=`M${d(E-Ac/Ec*b)},${d(F*b/Ec)}L${d(A)},${d(T)}`,$="";for(let V of R.bones){let O=F*V.rise;if(V.depth%2===0)N+=`M${d(C(V.at,V.rise))},${d(O)}H${d(C(V.textEnd+Pu,V.rise))}`;else{let W=R.bones[V.parent].rise;N+=`M${d(C(V.at,W))},${d(F*W)}L${d(C(V.at,V.rise))},${d(O)}`}let v=C(V.textEnd,V.rise);$+=Ie(V.label,v-V.label.width/2,O,V.depth>2?' fill="var(--_m)"':""),u=Math.min(u,v-V.label.width)}let X=T+F*(R.boxH/2);u=Math.min(u,A-R.boxW/2),m=Math.max(m,A+R.boxW/2),h=Math.min(h,X-R.boxH/2),g=Math.max(g,X+R.boxH/2),Y+=`<g class="pele-ishikawa-category" data-id="${$e(R.node.text)}"><path class="pele-ishikawa-bones" d="${N}" fill="none" stroke="var(--_l)"/>`+bt("arrow_point",E,0,Ac/Ec,-F/Ec,"var(--_l)")+`<rect x="${d(A-R.boxW/2)}" y="${d(X-R.boxH/2)}" width="${d(R.boxW)}" height="${d(R.boxH)}" rx="${Xe}" fill="var(--_s)" stroke="var(--_b)"/>`+Ie(R.label,A,X,' class="pele-label"')+($?`<g class="pele-ishikawa-causes" font-size="${s}">${$}</g>`:"")+"</g>"});let z=I/2;p=`<path class="pele-ishikawa-spine" d="M${d(q)},0H${d(-(kt-1))}" fill="none" stroke="var(--_l)"/>`+bt("arrow_point",0,0,1,0,"var(--_l)")+Y+`<g class="pele-ishikawa-head" data-id="${$e(c.text)}"><path d="M0,${d(-z)}H${d(D-z)}A${d(z)},${d(z)} 0 0 1 ${d(D-z)},${d(z)}H0Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/>`+Ie(w,12+w.width/2,0,' class="pele-label" font-weight="var(--_hw)"')+"</g>"}let x=Math.max(m-u,l.width),y=Math.ceil(x+2*i),_=Math.ceil(g-h+f+2*i),S=i+(x-(m-u))/2-u,P=i+f-h;return{svg:Ze("ishikawa",y,_,o,n,{},Ie(l,y/2,i+l.height/2,' class="pele-title" font-weight="var(--_tw)"')+(p?`<g transform="translate(${d(S)},${d(P)})">${p}</g>`:"")),width:y,height:_,links:[]}}function d2(e,t){let n=t.fontSize??16,r=Math.round(n*.875),o=t.measurer??Je(t.fontFamily),s=t.padding??8,a=Math.max(140,(t.maxWidth??320)-2*s),i=De(e.title,!1,o,n,Rt(t),1),c=[],l=e.root?[{node:e.root,depth:0,parent:-1}]:[],f=0;for(;l.length;){let S=l.pop(),P=c.length;c.push({...S,x:0,y:0,w:0,h:0}),f=Math.max(f,S.depth);for(let k=S.node.children.length-1;k>=0;k--)l.push({node:S.node.children[k],depth:S.depth+1,parent:P})}let p=Math.min(20,Math.max(2,(a-120)/Math.max(1,f))),u=s+(i.height?i.height+12:0),m=i.width,h="",g="";for(let S of c){S.x=s+S.depth*p;let P=Math.max(60,a-S.depth*p-20);S.label=ci(De(S.node.text,!1,o,S.depth<2?n:r,P,S.depth<2?1:0),o,P),S.w=S.label.width+20,S.h=S.label.height+12,S.y=u,u+=S.h+12,m=Math.max(m,S.x-s+S.w);let k=S.depth<2;if(h+=`<g class="pele-node ${S.depth===0?"pele-ishikawa-head":S.depth===1?"pele-ishikawa-category":"pele-ishikawa-cause"}" data-id="${$e(S.node.text)}">`+(k?`<rect x="${d(S.x)}" y="${d(S.y)}" width="${d(S.w)}" height="${d(S.h)}" rx="${S.depth===0?12:4}" fill="var(--_s)" stroke="var(--_b)"/>`:"")+Ie(S.label,S.x+S.w/2,S.y+S.h/2,` class="pele-label"${S.depth<2?' font-weight="var(--_hw)"':""}${S.depth>1?` font-size="${r}"`:""}`)+"</g>",S.parent>=0){let w=c[S.parent],I=w.x+p/2;g+=`<path class="pele-edge" d="M${d(I)},${d(w.y+w.h)}V${d(S.y+S.h/2)}H${d(S.x)}" fill="none" stroke="var(--_b)"/>`}}let x=Math.ceil(m+2*s),y=Math.ceil(Math.max(s+i.height,u-12)+s),_=Ie(i,x/2,s+i.height/2,' class="pele-title" font-weight="var(--_tw)"')+g+h;return{svg:Ze("ishikawa",x,y,n,t,{},_),width:x,height:y,links:[]}}var Ob={type:"ishikawa",parse(e,t,n){let r=new yc;return r.title=n,kb(e,r),r},render:Db};function Sc(e){let t=new Set;for(let n of e)for(let r of n.people)t.add(r);return[...t].sort()}var xc=class{type="journey";title;accTitle;accDescr;sections=[];tasks=[];currentSection="";setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
93
+ `)}addSection(t){this.currentSection=t,this.sections.push(t)}addTask(t,n){let r=n.substring(1).split(":"),o=r.length===1?[]:r[1].split(",").map(s=>s.trim());this.tasks.push({task:t,score:Number(r[0]),people:o,section:this.currentSection})}getActors(){return Sc(this.tasks)}};function yi(e,t){let n=e.indexOf(`
94
+ `,t);return n===-1?e.length:n}function Wn(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function _c(e,t){let n=e.length,r=t;for(;r<n;){let o=e.charCodeAt(r);if(o===37&&e.charCodeAt(r+1)!==123)r=yi(e,r);else if(o!==125&&e.charCodeAt(r+1)===37&&e.charCodeAt(r+2)===37)r=yi(e,r+3);else{if(o===10)return r;if(Be(o))do r++;while(r<n&&Be(e.charCodeAt(r)));else if(o===35)r=yi(e,r);else return r}}return r}function Bu(e,t){let n=t;for(;Be(e.charCodeAt(n));)n++;return n}function wc(e,t,n,r){let o=Wn(e,t,"accdescr");if(!o&&!Wn(e,t,"acctitle"))return t;let s=e.length,a=Bu(e,t+8),i=e.charCodeAt(a),c=(l,f,p)=>{n.types.push(l),n.texts.push(e.slice(f,p)),n.starts.push(f)};if(i===58){a=Bu(e,a+1);let l=yi(e,a);return c(o?r+2:r,t,a),c(o?r+3:r+1,a,l),l}if(!o||i!==123)return t;for(a=Bu(e,a+1);e.charCodeAt(a)!==125;){let l=e.indexOf("}",a);if(l===-1&&(l=s),c(r+4,a,l),a===s)return s;a=l}return a+1}var vb=["$end","EOF","INVALID","NEWLINE","journey","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","section","taskName","taskData",":"];function Rc(e,t,n){let r=e.length,o=t;for(;o<r;o++){let s=e.charCodeAt(o);if(s===35||s===10||s===59||n&&s===58)break}return o}function Pb(e){let t=e.length,n=[],r=[],o=[],s={types:n,texts:r,starts:o},a=0,i=(c,l)=>{n.push(c),r.push(e.slice(a,l)),o.push(a),a=l};for(;a=_c(e,a),!(a>=t);){let c=e.charCodeAt(a),l=a+1;if(c===10){for(;e.charCodeAt(l)===10;)l++;i(3,l);continue}if(Wn(e,a,"journey")&&!Qe(e.charCodeAt(a+7))){i(4,a+7);continue}if(Wn(e,a,"title")&&Be(e.charCodeAt(a+5))&&(l=Rc(e,a+6,!1),l>a+6)){i(5,l);continue}if(l=wc(e,a,s,6),l!==a){a=l;continue}if(Wn(e,a,"section")&&Be(e.charCodeAt(a+7))&&(l=Rc(e,a+8,!0),l>a+8)){i(11,l);continue}c===58?(l=Rc(e,a+1,!1),i(l>a+1?13:14,l>a+1?l:a+1)):c===59?i(2,a+1):i(12,Rc(e,a+1,!0))}return(o.length===0||o[o.length-1]<t)&&i(1,t),i(0,t),s}var u2="'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskName'";function Bb(e,t){let{types:n,texts:r,starts:o}=Pb(e),s=(a,i)=>{let c=n[a]===0?"1":vb[n[a]];throw it("journey",e,o[a],`Expecting ${i}, got '${c}'`)};n[0]!==4&&s(0,"'journey'");for(let a=1;;a++){let i=r[a];switch(n[a]){case 3:break;case 5:t.setDiagramTitle(i.substring(6));break;case 6:t.setAccTitle(r[++a].trim());break;case 8:t.setAccDescription(r[++a].trim());break;case 10:t.setAccDescription(i.trim());break;case 11:t.addSection(i.substring(8));break;case 12:n[++a]!==13&&s(a,"'taskData'"),t.addTask(i,r[a]);break;case 1:return;default:s(a,u2)}}}var Cc=10,Vr=8,f2=124,p2=200,Tc=12,Fb=6,Fu=24,Wu=26,Ei=11,fr=5,h2=13,m2=20,g2='<circle cx="-3.6" cy="-2.8" r="1.3"/><circle cx="3.6" cy="-2.8" r="1.3"/>',b2={happy:"M-5,2A6,6 0 0 0 5,2",neutral:"M-4.5,4.5H4.5",sad:"M-5,6.5A6,6 0 0 1 5,6.5"};function Wb(e,t,n){return`<g class="pele-face pele-face-${n}" transform="translate(${d(e)},${d(t)})"><circle r="${Ei}" fill="var(--_bg)" stroke="var(--_l)"/><g fill="var(--_l)">${g2}</g><path d="${b2[n]}" fill="none" stroke="var(--_l)" stroke-linecap="round"/></g>`}function Ub(e,t,n){return Nt(n,r=>y2(e,t,n,r))}function y2(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.875),a=Math.round(o*.75),i=n.measurer??Je(n.fontFamily),c=n.padding??8;if(r)return E2(e,n);let l=e.tasks,f=l.length,p=Sc(l).filter(W=>W!==""),u=new Map;p.forEach((W,H)=>u.set(W,H));let m=f2,h=l.map(W=>Zn(W.task,i,s,m)),g=0;for(let W of h)g=Math.max(g,W.width);g>m&&(m=Math.min(Math.ceil(g),p2),h=l.map(W=>Tn(W.task,i,s,m)));let x=m+2*Cc,y=x+Tc,_=f>0?f*y-Tc:0,S=Math.round(s*1.5),P=Math.max(_,240),k=[],w=0,I=0,D=0;for(let W of p){let H=Tn(W,i,s,P-2*fr-6),G=2*fr+6+H.width;D>0&&D+G>P&&(D=0,I+=4);let te=D>0?k[k.length-1].y:I,Z=Math.max(H.height,S);k.push({name:W,label:H,x:D,y:te,h:Z}),D+=G,w=Math.max(w,D),I=Math.max(I,te+Z),D+=m2}let U=f>0?Fu+_:0,M=Tn(e.title,i,o,Math.max(U,320),1),Q=M.height>0?M.height+16:0,q=Math.max(U,M.width,f>0?Fu+w:0),Y=c+(q-U)/2+Fu,z=c+Q,R=[],L=0;for(let W=0;W<f;){let H=W+1;for(;H<f&&l[H].section===l[W].section;)H++;let G;l[W].section!==""&&(G=Tn(l[W].section,i,s,(H-W)*y-Tc-2*Cc,1),L=Math.max(L,Math.max(G.height,S)+2*Fb)),R.push({start:W,count:H-W,label:G}),W=H}let F=S;for(let W of h)F=Math.max(F,W.height);let E=p.length>0?2*fr+6:0,C=F+E+2*Vr,A=z+(L>0?L+Fb:0),T=A+C+Ei+16,b=T+4*Wu,N=Y+_,$="",X=z;if(f>0){let W="",H="";for(let K=5;K>=1;K--){let ee=T+(5-K)*Wu;W+=`M${d(Y-6)},${d(ee)}H${d(N)}`,H+=`<text x="${d(Y-12)}" y="${d(ee+a*.35)}">${K}</text>`}$+=`<path class="pele-grid" d="${W}" fill="none" stroke="var(--_a)"/><g class="pele-scale" font-size="${a}" text-anchor="end" fill="var(--_m)">${H}</g>`;let G="",te="",Z="",B=[];l.forEach((K,ee)=>{let ae=Y+ee*y,J=ae+x/2,se=K.score,me=Number.isNaN(se)?3:Math.min(5,Math.max(1,se)),Ae=T+(5-me)*Wu;G+=`${ee===0?"M":"L"}${d(J)},${d(Ae)}`,te+=`M${d(J)},${d(A+C)}V${d(Ae-Ei)}`,Z+=Wb(J,Ae,se>3?"happy":se<3?"sad":"neutral");let de="",oe=K.people.filter(ce=>ce!==""),ye=Math.min(h2,(x-2*Cc-2*fr)/Math.max(oe.length-1,1));oe.forEach((ce,fe)=>{de+=`<circle class="pele-actor" cx="${d(J+(fe-(oe.length-1)/2)*ye)}" cy="${d(A+C-Vr-fr)}" r="${fr}" fill="${ct(u.get(ce)??0)}" stroke="var(--_s)"><title>${$e(ce)}</title></circle>`}),B.push(`<g class="pele-node pele-task" data-id="${$e(K.task.trim())}"><rect x="${d(ae)}" y="${d(A)}" width="${d(x)}" height="${d(C)}" rx="${Xe}" fill="var(--_s)" stroke="var(--_b)"/>`+Ie(h[ee],J,A+Vr+F/2,` font-size="${s}"`)+de+"</g>")}),$+=`<path class="pele-stems" d="${te}" fill="none" stroke="var(--_b)" stroke-dasharray="2 3"/>`+(f>1?`<path class="pele-edge" d="${G}" fill="none" stroke="var(--_l)" stroke-linejoin="round"/>`:"")+Z;for(let K of R){let ee=B.slice(K.start,K.start+K.count).join("");if(!K.label){$+=ee;continue}let ae=Y+K.start*y,J=K.count*y-Tc;$+=`<g class="pele-cluster pele-section" data-id="${$e(l[K.start].section.trim())}"><rect x="${d(ae)}" y="${d(z)}" width="${d(J)}" height="${d(L)}" rx="${Xe}" fill="var(--_a)"/>`+Ie(K.label,ae+J/2,z+L/2,` font-size="${s}" font-weight="var(--_hw)"`)+ee+"</g>"}if(X=b+Ei,k.length>0){let K=Y+(_-w)/2,ee=X+16,ae="";for(let J of k){let se=ee+J.y+J.h/2;ae+=`<g class="pele-legend-item" data-id="${$e(J.name)}"><circle cx="${d(K+J.x+fr)}" cy="${d(se)}" r="${fr}" fill="${ct(u.get(J.name)??0)}"/>`+Ie(J.label,K+J.x+2*fr+6+J.label.width/2,se,"")+"</g>"}$+=`<g class="pele-legend" font-size="${s}">${ae}</g>`,X=ee+I}}let V=Math.ceil(q+2*c),O=Math.ceil(Math.max(X,c)+c),v=Ie(M,c+q/2,c+M.height/2,' class="pele-title" font-weight="var(--_tw)"')+$;return{svg:Ze("journey",V,O,o,n,e,v),width:V,height:O,links:[]}}function E2(e,t){let n=t.fontSize??16,r=Math.round(n*.875),o=t.measurer??Je(t.fontFamily),s=t.padding??8,a=Math.max(140,(t.maxWidth??320)-2*s),i=Tn(e.title,o,n,a,1),c=Sc(e.tasks).filter(y=>y!==""),l=new Map(c.map((y,_)=>[y,_])),f=s+(i.height?i.height+16:0),p,u="",m=i.width;e.tasks.forEach((y,_)=>{if(y.section!==p){p=y.section;let M=Tn(p,o,n,a-16,1);M.height&&(u+=Ie(M,s+8+M.width/2,f+M.height/2,' class="pele-cluster-label" font-weight="var(--_hw)"'),m=Math.max(m,M.width+16),f+=M.height+8)}let S=Tn(y.task,o,r,a-72),P=y.people.filter(M=>M!=="").map(M=>({name:M,label:Tn(M,o,r,a-44)})),k=Math.max(S.height,42),w=2*Vr+k;for(let M of P)w+=Math.max(16,M.label.height)+4;let I=Math.max(a,S.width+72);u+=`<g class="pele-node pele-journey-step" data-id="${_}"><rect x="${d(s)}" y="${d(f)}" width="${d(I)}" height="${d(w)}" rx="${Xe}" fill="var(--_s)" stroke="var(--_b)"/>`,u+=Ie(S,s+Cc+S.width/2,f+Vr+S.height/2,' class="pele-label"');let D=s+I-28;u+=Wb(D,f+Vr+Ei,y.score>3?"happy":y.score<3?"sad":"neutral"),Number.isNaN(y.score)||(u+=`<text class="pele-journey-score" x="${d(D)}" y="${d(f+Vr+2*Ei+r)}" font-size="${r}" text-anchor="middle">${d(Math.min(5,Math.max(1,y.score)))}</text>`);let U=f+Vr+k+4;for(let M of P){let Q=Math.max(16,M.label.height);u+=`<circle class="pele-actor" cx="${d(s+16)}" cy="${d(U+Q/2)}" r="${fr}" fill="${ct(l.get(M.name))}"/>`+Ie(M.label,s+28+M.label.width/2,U+Q/2,` class="pele-journey-actor" font-size="${r}"`),U+=Q+4}u+="</g>",f+=w,_+1<e.tasks.length&&(u+=`<path class="pele-edge" d="M${d(s+I/2)},${d(f)}v16" fill="none" stroke="var(--_l)"/>`),f+=16,m=Math.max(m,I)});let h=Math.ceil(m+2*s),g=Math.ceil(Math.max(s+i.height,f-(e.tasks.length?16:0))+s),x=Ie(i,h/2,s+i.height/2,' class="pele-title" font-weight="var(--_tw)"')+u;return{svg:Ze("journey",h,g,n,t,e,x),width:h,height:g,links:[]}}var Gb={type:"journey",parse(e,t,n){let r=new xc;return r.title=n,Bb(e,r),r},render:Ub};var A2=["1","INVALID","SPACELINE","NL","EOF","","SPACELIST","ICON","CLASS","NODE_DSTART","NODE_ID","NODE_DESCR","NODE_DEND","SHAPE_DATA"];function Yb(e,t){return e===5?t?"KANBAN":"MINDMAP":A2[e]}var jr={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6};function Ic(e,t){switch(e){case"[":return jr.RECT;case"(":return t===")"?jr.ROUNDED_RECT:jr.CLOUD;case"((":return jr.CIRCLE;case")":return jr.CLOUD;case"))":return jr.BANG;case"{{":return jr.HEXAGON;default:return jr.DEFAULT}}var x2=/\s+/y,Uu=/.+/y,S2=/[^([\n){}]+/y,_2=/[^([\n){}@]+/y,w2=/[^)\](}]+/y,R2=/[^`"]+/y,T2=/[^}^"]+/y,C2=/\n\s*/g;function Hb(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function Gu(e,t){let n=e.length,r=[],o=[],s=[],a=t?"kanban":"mindmap",i=t?_2:S2,c=0,l=0,f=-1,p=(g,x,y)=>{r.push(g),o.push(x),s.push(l),l=y},u=(g,x,y)=>{p(g,e.slice(l,x),x),c=y},m=(g,x)=>(g.lastIndex=x,g.test(e)?g.lastIndex:-1),h=g=>{let x=e.indexOf(g,l);return x===-1?n:x};for(;l<n;){let g=e.charCodeAt(l),x=e.charCodeAt(l+1),y;if(c===0){let _=g<=32||g>=160?Math.max(m(x2,l),l):l;if(t&&g===64&&x===123)p(13,"",l+2),c=6;else if(e.charCodeAt(_)===37&&e.charCodeAt(_+1)===37)u(2,m(Uu,_),0);else if(_>l)f<l&&(f=h(`
95
+ `)),f>=_?u(6,_,0):(y=e.lastIndexOf(`
96
+ `,_-1))>l?u(2,y+1,0):u(3,l+1,0);else if(Hb(e,l,a)&&!Qe(e.charCodeAt(l+a.length)))u(5,l+a.length,0);else if(g===58&&x===58&&e.charCodeAt(l+2)===58)l+=3,c=1;else if(g===58&&x===58&&Hb(e,l+2,"icon")&&e.charCodeAt(l+6)===40)l+=7,c=2;else if(g===45&&x===41||g===40&&(x===45||x===40)||(g===41||g===123)&&x===g)u(9,l+2,3);else if(g===41||g===40||g===91)u(9,l+1,3);else if((y=m(i,l))!==-1)u(10,y,0);else break}else if(c===3)g===34?(c=x===96?5:4,l+=x===96?2:1):g===41||g===40?u(12,x===g||g===40&&x===45?l+2:l+1,0):g===93?u(12,l+1,0):g===125&&x===125||g===45&&x===41?u(12,l+2,0):u(11,m(g===125?Uu:w2,l),3);else if(c===4)g===34?(l++,c=3):u(11,h('"'),4);else if(c===5)if(g===96&&x===34)l+=2,c=3;else if((y=m(R2,l))!==-1)u(11,y,5);else break;else if(c===1)if((y=m(Uu,l))!==-1)u(8,y,0);else if(g===10)l++,c=0;else break;else if(c===2)g===41?(l++,c=0):u(7,h(")"),2);else if(c===6)if(g===34)u(13,l+1,7);else if(g===125)l++,c=0;else if((y=m(T2,l))!==-1)u(13,y,6);else break;else g===34?u(13,l+1,6):(y=h('"'),p(13,e.slice(l,y).replace(C2,"<br/>"),y))}return l<n?p(1,"",l):(c===0&&p(4,"",n),p(0,"",n)),{types:r,texts:o,starts:s}}var Ls="'SPACELINE', 'NL', 'EOF'",Kb=new Uint8Array(14);for(let e of[2,6,7,8,9,10])Kb[e]=1;function Ai(e){return e===2||e===3||e===4}function Nc(e,t,n){let r=n?"kanban":"mindmap",{types:o,texts:s,starts:a}=Gu(e,n),i=n?", 'SHAPE_DATA'":"",c=0,l=u=>{let m=o[c];throw m===1?it(r,e,a[c],"",!0):it(r,e,a[c],`Expecting ${u}, got '${Yb(m,n)}'`)},f=`'${Yb(5,n)}'`;if(o[c]===2){for(c++;o[c]===2||o[c]===3;)c++;o[c]!==5&&l(`'SPACELINE', 'NL', ${f}`)}else o[c]!==5&&l(`'SPACELINE', ${f}`);c++;let p="'SPACELINE', 'NL', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'";for(o[c]===3&&(c++,p="'SPACELINE', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'");;){let u=o[c],m=0,h=u===6;if(h&&(m=s[c++].length,u=o[c]),u===10||u===9){let g,x,y=0;if(u===10&&(g=s[c++]),o[c]===9){let _=s[c++];o[c]!==11&&l("'NODE_DESCR'"),x=s[c++],o[c]!==12&&l("'NODE_DEND'");let S=s[c++];!Ai(o[c])&&o[c]!==13&&l(Ls+i),y=t.getType(_,S)}else!Ai(o[c])&&o[c]!==13&&l(Ls+", 'NODE_DSTART'"+i),x=g;if(o[c]===13){let _=s[c++];for(;o[c]===13;)_+=s[c++];Ai(o[c])||l(Ls+i),t.addNode(m,g??x,x,y,_)}else t.addNode(m,g??x,x,y)}else if(u===7||u===8){let g=s[c++];Ai(o[c])||l(Ls),t.decorateNode(u===7?{icon:g}:{class:g})}else h?Ai(u)||l(Ls+", 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'"):u===2?Ai(o[++c])||l(Ls):l(p);for(c++;o[c]===3||o[c]===4;)c++;if(o[c]===0)return;Kb[o[c]]===0&&l(Ls+", 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'")}}var Mc=class{type="kanban";title;sections=[];getType=Ic;last;sectionLevel=0;misplaced;addNode(t,n,r,o,s){let a={id:n,level:t,label:r};if(s!==void 0){let c=s.includes(`
97
+ `)?s+`
98
+ `:`{
99
+ `+s+`
100
+ }`,l;try{l=Hn(c)}catch(f){throw new Ge(`Metadata of "${a.id}" is not valid YAML. ${f.message}`,"syntax",{type:"kanban"})}if(l!==null&&typeof l=="object"&&!Array.isArray(l)){let f=l.shape?String(l.shape):"";if(f!==f.toLowerCase()||f.includes("_"))throw new Ge(`No such shape: ${f}. Shape names should be lowercase.`,"semantic",{type:"kanban"});l.label&&(a.label=String(l.label)),l.icon&&(a.icon=String(l.icon)),l.assigned&&(a.assigned=String(l.assigned)),l.ticket&&(a.ticket=String(l.ticket)),l.priority&&(a.priority=String(l.priority))}}if(this.misplaced)throw new Ge(`Items without section detected, found section ("${this.misplaced.label}")`,"semantic",{type:"kanban"});let i=this.sections;if(i.length===0&&(this.sectionLevel=t),this.last=a,t===this.sectionLevel){let c=a;c.items=[],i.push(c)}else i[i.length-1].items.push(a),t<this.sectionLevel&&(this.misplaced=a)}decorateNode(t){let n=this.last;!t||!n||(t.icon&&(n.icon=t.icon),t.class&&(n.cssClasses=t.class))}};function zb(e,t){Nc(e,t,!0)}function To(e,t,n,r,o){return`<svg class="pele-icon" data-icon="${$e(e)}" x="${d(t)}" y="${d(n)}" width="${d(r)}" height="${d(r)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${o?.(e)??""}</svg>`}var pr=12,Xr=8,hr=10,Yu=8,I2=4,Hu=6,N2=new Map([["very high",`stroke="${ji}"`],["high",`stroke="${ji}" opacity="0.5"`],["low",'stroke="var(--_m)" opacity="0.5"'],["very low",'stroke="var(--_m)"']]);function kc(e,t,n,r,o,s=0){let a=De(e,t,n,r,o,s);if(a.width<=o)return a;let i=[],c=[],l=0,f=[],p=0,u=()=>{i.push(f),c.push(p),l=Math.max(l,p),f=[],p=0};for(let m=0;m<a.lines.length;m++){if(a.widths[m]<=o){f=a.lines[m],p=a.widths[m],u();continue}for(let h of a.lines[m]){if(h.icon!==void 0){p>0&&p+h.width>o&&u(),f.push(h),p+=h.width;continue}let g="",x=p;for(let y of h.text){let _=n.width(y,r,h.style);p>0&&p+_>o&&(g&&f.push({text:g,style:h.style,width:p-x}),u(),g="",x=0),g+=y,p+=_}g&&f.push({text:g,style:h.style,width:p-x})}u()}return{...a,lines:i,widths:c,width:l,height:i.length*a.lineHeight}}function Co(e,t,n,r,o,s=!1){let a="";for(let i=0;i<e.lines.length;i++){let c=e.lines[i],l=n+(i+.5)*e.lineHeight;if(c.length===1&&c[0].icon===void 0)a+=`<text${Kn(r,c[0].style)} x="${d(t)}" y="${d(l+e.size*.35)}"${s?' text-anchor="end"':""}>${je(c[0].text)}</text>`;else{let f=e.widths[i],p={...e,lines:[c],widths:[f],width:f,height:e.lineHeight};a+=Ie(p,t+(s?-f:f)/2,l,r,o)}}return a}var Lc=e=>!!e&&js(e)!=="";function Vb(e,t,n){let r=n.fontSize??16,o=Math.round(r*.875),s=Math.round(r*1.5),a=Math.round(o*1.5),i=n.measurer??Je(n.fontFamily),c=n.padding??8,l=n.icons,f=t.kanban??{},p=f.sectionWidth,u=typeof p=="number"&&p>0?Math.min(Math.max(p,80),2e3):200,m=n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*c:1/0,h=e.sections.length,g=h*(u+pr)-pr<=m,x=g?Math.max(h,1):Math.max(1,Math.floor((m+pr)/(u+pr))),y=g?u:Math.max(Math.min(u,m),Math.min(Math.floor((m+pr)/x)-pr,u*2)),_=typeof f.ticketBaseUrl=="string"?f.ticketBaseUrl:"",S=y-2*Xr,P=S-2*hr,k=o*1.25,w=[],I=e.sections,D=[],U=[],M=[],Q=s,q=[];for(let V of I){let O=i.width(String(V.items.length),o,0),v=O+12+(Lc(V.icon)?k+Hu:0),W=kc(V.label,!0,i,r,S-8-v,1);Q=Math.max(Q,W.height),U.push(O),D.push(W);let H=[],G=0;for(let te of V.items){let Z=kc(te.label,!0,i,o,P-(Lc(te.icon)?k+Hu:0)),B=kc(te.ticket,!1,i,o,P),K=kc(te.assigned,!1,i,o,P),ee=B.width+K.width+8>P?B.height+K.height:Math.max(B.height,K.height),ae=2*hr+Math.max(Z.height,a)+(ee?I2+ee:0);H.push({item:te,label:Z,ticket:B,assigned:K,meta:ee,height:ae}),G+=ae+Yu}M.push(H),q.push(G)}Q+=2*Xr;let Y=[],z=[];for(let V=0,O=0;V<I.length;V+=x){let v=Yu;for(let W=V;W<Math.min(V+x,I.length);W++)v=Math.max(v,q[W]);z.push(O),Y.push(Q+v),O+=Q+v+pr}let R=Y.length>0?z[z.length-1]+Y[Y.length-1]:0,L=De(e.title,!1,i,r,Rt(n),1),F=L.height>0?L.height+16:0,E=Math.max(Math.min(I.length,x)*(y+pr)-pr,0),C=Math.max(E,L.width),A=c+(C-E)/2,T=y-Xr-4,b="";for(let V=0;V<I.length;V++){let O=I[V],v=Math.floor(V/x),W=`<rect width="${y}" height="${d(Y[v])}" rx="${Xe}" fill="var(--_s)"/>`+Co(D[V],Xr+4,Xr,' class="pele-cluster-label" font-weight="var(--_hw)"',l)+`<text class="pele-count" x="${T}" y="${d(Xr+s/2+o*.35)}" text-anchor="end" font-size="${o}" fill="var(--_m)">${O.items.length}</text>`;Lc(O.icon)&&(W+=To(O.icon,T-U[V]-Hu-k,Xr+(s-k)/2,k,l));let H=Q;for(let G of M[V]){let te=G.item,Z=(te.priority??"").trim().toLowerCase(),B=N2.get(Z),K=`<rect width="${S}" height="${d(G.height)}" rx="${Xe}" fill="var(--_bg)" stroke="var(--_b)"/>`;B!==void 0&&(K+=`<path class="pele-priority" d="M2.5,5V${d(G.height-5)}" fill="none" ${B} stroke-width="3" stroke-linecap="round"/>`),K+=Co(G.label,hr,hr,' class="pele-label"',l),Lc(te.icon)&&(K+=To(te.icon,S-hr-k,hr+(a-k)/2,k,l));let ee=G.height-hr;if(te.ticket){let ae=ee-G.meta,J=_?Ar(vn(_.replace("#TICKET#",()=>te.ticket)),n):void 0;J===void 0?K+=Co(G.ticket,hr,ae,' class="pele-ticket" fill="var(--_m)"',l):(K+=`<a href="${je(J)}" target="_blank"${xr(n)}>`+Co(G.ticket,hr,ae,' class="pele-ticket" fill="var(--_c)"',l)+"</a>",w.push({id:te.id,href:J,internal:!1}))}te.assigned&&(K+=Co(G.assigned,S-hr,ee-G.assigned.height,' class="pele-assigned" fill="var(--_m)"',l,!0)),W+=`<g class="pele-node pele-card${B===void 0?"":" pele-priority-"+Z.replace(" ","-")}${wt(te.cssClasses??"")}" data-id="${$e(te.id)}" transform="translate(${Xr},${d(H)})" font-size="${o}">${K}</g>`,H+=G.height+Yu}b+=`<g class="pele-cluster pele-column${wt(O.cssClasses??"")}" data-id="${$e(O.id)}" transform="translate(${d(A+V%x*(y+pr))},${d(c+F+z[v])})">${W}</g>`}let N=Math.ceil(C+2*c),$=Math.ceil(R+F+2*c),X=Ie(L,N/2,c+L.height/2,' class="pele-title" font-weight="var(--_tw)"')+b;return{svg:Ze("kanban",N,$,r,n,{},X),width:N,height:$,links:w}}var jb={type:"kanban",parse(e,t,n){let r=new Mc;return r.title=n,zb(e,r),r},render:Vb};var M2=11,$c=class{type="mindmap";title;nodes=[];getType=Ic;baseLevel=0;open=[];addNode(t,n,r,o){let s=this.nodes.length===0;s&&(this.baseLevel=t),t-=this.baseLevel;let a=this.open,i=a.length;for(;i>0&&a[i-1].level>=t;)i--;let c=a[i-1];if(!c&&!s)throw new Ge(`There can be only one root. No parent could be found for ("${r}")`,"semantic",{type:"mindmap"});let l={id:this.nodes.length,nodeId:n,level:t,descr:r,type:o,children:[],isRoot:s};c&&(l.section=c.isRoot?c.children.length%M2:c.section,c.children.push(l)),a.length=i,a.push(l),this.nodes.push(l)}decorateNode(t){let n=this.nodes[this.nodes.length-1];!t||!n||(t.icon&&(n.icon=t.icon),t.class&&(n.class=t.class))}};function Xb(e,t){Nc(e,t,!1)}var k2=["","rounded","rect","circle","cloud","bang","hex"],qb="stadium",L2=36,$2=8,D2=18,O2=52,Qb=28,Zb=6,v2=12,P2=.22,Ku=6,zu=28,Jb=12,ey=8,ty=10;function B2(e,t,n,r){if(e.lines.length<2)return Ie(e,t+e.width/2,n,' class="pele-label"',r);let o="";for(let s=0;s<e.lines.length;s++){let a=e.widths[s],i={lines:[e.lines[s]],widths:[a],width:a,height:e.lineHeight,size:e.size,lineHeight:e.lineHeight};o+=Ie(i,t+a/2,n+(s-(e.lines.length-1)/2)*e.lineHeight,' class="pele-label"',r)}return o}function ny(e,t,n){return Nt(n,r=>F2(e,t,n,r))}function F2(e,t,n,r){let o=n.fontSize??16,s=n.measurer??Je(n.fontFamily),a=n.padding??8,i=n.icons,c=t.mindmap?.maxNodeWidth,l=typeof c=="number"&&c>0?Math.min(c,2e3):200,f=o*1.25,p=e.nodes,u=p.length,m=new Int32Array(u),h=new Int32Array(u);for(let Z=0;Z<u;Z++)for(let B of p[Z].children)m[B.id]=Z,h[B.id]=h[Z]+1;let g=r&&n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*a:1/0,x=new Array(u),y=new Array(u),_=new Float64Array(u),S=new Float64Array(u),P=new Float64Array(u),k=new Float64Array(u),w=new Uint8Array(u);for(let Z=0;Z<u;Z++){let B=p[Z];w[Z]=B.icon!==void 0&&js(B.icon)!==""?1:0;let K=Math.min(l,Math.max(72,g-h[Z]*zu-2*Zb-(w[Z]?f+Ku:0))),ee=x[Z]=De(B.descr,!0,s,o,K),ae=ee.width+(w[Z]?f+(ee.width>0?Ku:0):0),J=Math.max(ee.height,Math.round(o*1.5)),se=k2[B.type]||(Z===0?qb:"");if(r&&Z===0&&se!=="rect"&&se!=="rounded"&&(se=qb),y[Z]=se,se===""){let me=B.children.length>0;_[Z]=ae+2*(me?v2:Zb),S[Z]=J+(me?6:0),k[Z]=S[Z]/2}else{let me=Br(se,ae,J);_[Z]=me.w,S[Z]=me.h,P[Z]=me.dy,k[Z]=me.h/2}}let I=new Float64Array(u),D=new Float64Array(u),U=new Float64Array(u),M=new Float64Array(u),Q=0,q=(Z,B,K,ee)=>{let ae=0,J=0;for(let Ae=B;Ae<K;Ae++){let de=Z[Ae].id;D[de]=ae,J=Z[Ae].children.length>0||Ae+1<K&&Z[Ae+1].children.length>0?Math.max(ee,D2):ee,ae+=I[de]+J}Q=ae-J;let se=Z[B].id,me=Z[K-1].id;return(D[se]+U[se]+k[se]+D[me]+U[me]+k[me])/2};for(let Z=u-1;Z>0;Z--){let B=p[Z].children;if(B.length===0){I[Z]=S[Z];continue}let K=q(B,0,B.length,$2)-k[Z],ee=Math.min(0,K);I[Z]=Math.max(Q,K+S[Z])-ee,U[Z]=K-ee,M[Z]=-ee}let Y=new Float64Array(u),z=new Float64Array(u),R=new Float64Array(u),L=new Int8Array(u),F=new Float64Array(u);if(r){let Z=0;for(let B=0;B<u;B++)B>0&&m[B]===0&&(Z+=ty),Y[B]=h[B]*zu+_[B]/2,z[B]=Z,Z+=S[B]+ty}else if(u>0){let Z=p[0].children,B=Z.length,K=0;for(let se of Z)K+=I[se.id];let ee=B,ae=1/0,J=0;for(let se=1;se<B;se++){J+=I[Z[se-1].id];let me=Math.abs(2*J-K+(2*se-B)*Qb);me<ae&&(ae=me,ee=se)}for(let se=0,me=ee,Ae=1;se<B;se=me,me=B,Ae=-1){let de=q(Z,se,me,Qb);for(let oe=se;oe<me;oe++){let ye=Z[oe].id;R[ye]=D[ye]-de,L[ye]=Ae}}z[0]=-S[0]/2;for(let se=0;se<u;se++){se>0&&(z[se]=R[se]+U[se]);for(let me of p[se].children){let Ae=me.id;se>0&&(L[Ae]=L[se],R[Ae]=R[se]+M[se]+D[Ae]),Y[Ae]=Y[se]+L[Ae]*(_[se]/2+(se>0?L2:O2)+_[Ae]/2)}}}let E=0,C=0,A=0,T=0,b="",N="",$="",X="",V=Z=>{$!==""&&(b+=`<g class="pele-branch pele-section-${Z??0}"><g class="pele-edges" fill="none" stroke="${X}" stroke-width="1.5">${N}</g>${$}</g>`,N=$="")};for(let Z=1;Z<=u;Z++){let B=Z%u,K=p[B],ee=y[B],ae=x[B],J=Y[B],se=z[B];if(E=Math.min(E,J-_[B]/2),C=Math.max(C,J+_[B]/2),A=Math.min(A,se),T=Math.max(T,se+S[B]),(B===0||m[B]===0)&&V(p[Z-1].section),B>0&&r){m[B]===0&&(X=ct(K.section??0));let ce=m[B],fe=ce===0?Math.min(Math.max(Jb,S[0]/2),zu-ey):Jb,xe=Y[ce]-_[ce]/2+Math.min(fe,_[ce]/2),be=F[ce]||z[ce]+S[ce],j=J-_[B]/2+(ee?_r(ee,_[B],S[B],3):0),ie=se+k[B],ue=Math.max(0,Math.min(ey,j-xe,ie-be));F[ce]=ie-ue,N+=`<path class="pele-edge" d="M${d(xe)},${d(be)}V${d(ie-ue)}Q${d(xe)},${d(ie)} ${d(xe+ue)},${d(ie)}H${d(j)}"/>`}else if(B>0){m[B]===0&&(X=ct(K.section??0));let ce=m[B],fe=L[B],xe=fe>0?1:3,be=Y[ce]+fe*(_[ce]/2-(y[ce]?_r(y[ce],_[ce],S[ce],xe):0)),re=z[ce]+k[ce],ie=J-fe*_[B]/2+(ee?fe*_r(ee,_[B],S[B],4-xe):0),ue=se+k[B],ge=d((be+ie)/2);N+=`<path class="pele-edge" d="M${d(be)},${d(re)}C${ge},${d(re)} ${ge},${d(ue)} ${d(ie)},${d(ue)}"/>`}let me=!ee&&K.children.length>0,Ae=` fill="${X}" fill-opacity="${P2}" stroke="${X}"`,de="";ee?de=B>0?Xn(ee,_[B],S[B],Ae,` stroke="${X}"`):Xn(ee,_[B],S[B],' fill="var(--_s)" stroke="var(--_b)"',' stroke="var(--_b)"'):me&&(de=`<rect x="${d(-_[B]/2)}" y="${d(-S[B]/2)}" width="${d(_[B])}" height="${d(S[B])}" rx="${d(S[B]/2)}"${Ae}/>`);let oe=0;K.icon&&w[B]&&(oe=(f+(ae.width>0?Ku:0))/2,de+=To(K.icon,-oe-ae.width/2,P[B]-f/2,f,i));let ye=`<g class="pele-node pele-shape-${ee||(me?"branch":"text")}${B>0?"":" pele-root"}${wt(K.class??"")}" data-id="${$e(K.nodeId)}" transform="translate(${d(J)},${d(se+S[B]/2)})">`+de+(r&&!ee?B2(ae,oe-ae.width/2,P[B],i):Ie(ae,oe,P[B],' class="pele-label"',i))+"</g>";B>0?$+=ye:b+=ye}let O=De(e.title,!1,s,o,Rt(n),1),v=O.height>0?O.height+16:0,W=Math.max(C-E,O.width),H=Math.ceil(W+2*a),G=Math.ceil(T-A+v+2*a),te=Ie(O,H/2,a+O.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(a-E+(W-C+E)/2)},${d(a+v-A)})">${b}</g>`;return{svg:Ze("mindmap",H,G,o,n,{},te),width:H,height:G,links:[]}}var ry={type:"mindmap",parse(e,t,n){let r=new $c;return r.title=n,Xb(e,r),r},render:ny};var W2=1e4;function xi(e,t,n,r,o){let s=e.packet?.[t];return typeof s=="number"&&s>=r?Math.min(s,o):n}function Vu(e){return new Ge(e,"semantic",{type:"packet"})}function sy(e,t,n){let r=Math.floor(xi(t,"bitsPerRow",32,1,4096)),o=[],s=-1,a=[],i=1;for(let c of e.blocks){let{start:l,end:f,bits:p}=c;if(l!==void 0&&f!==void 0&&f<l)throw Vu(`Packet block ${l} - ${f} is invalid. End must be greater than start.`);if(l??=s+1,l!==s+1)throw Vu(`Packet block ${l} - ${f??l} is not contiguous. It should start from ${s+1}.`);if(p===0)throw Vu(`Packet block ${l} is invalid. Cannot have a zero bit field.`);for(f??=l+(p??1)-1,p??=f-l+1,s=f;a.length<=r+1&&o.length<W2;){let u=i*r-1;if(f<=u){a.push({start:l,end:f,bits:p,label:c.label}),f===u&&(o.push(a),a=[],i++);break}a.push({start:l,end:u,bits:u-l,label:c.label}),o.push(a),a=[],i++,l=u+1,p=f-l}}return a.length>0&&o.push(a),{type:"packet",title:e.title||n,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
101
+ `):void 0,bitsPerRow:r,rows:o}}var iy=[{name:"packet-beta",pattern:"packet-beta"},Vt("packet"),{name:"-",pattern:"-",longer:[Pt]},{name:"+",pattern:"+"},{name:":",pattern:":"},Zt,Yt,Ht,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},wn,hn,mn,Pt,Kt,zt];function oy(e){let t=new Dt(vt(e,iy,"packet"),iy,"packet"),n={$type:"Packet",blocks:[]},r=()=>{if(t.kind!==-1)for(t.kind!==10&&t.fail("a line break or the end of input");t.kind===10;)t.i++};for(;t.kind===10;)t.i++;for(t.accept(0)||t.expect(1);t.kind!==-1;)switch(t.kind){case 10:t.i++;break;case 5:n.accDescr=Wt(t.take()),r();break;case 6:n.accTitle=Ft(t.take()),r();break;case 7:n.title=Bt(t.take()),r();break;case 8:case 3:{let o={$type:"PacketBlock",label:""};t.accept(3)?o.bits=Number(t.expect(8)):(o.start=Number(t.take()),t.accept(2)&&(o.end=Number(t.expect(8)))),t.expect(4),o.label=rn(t.expect(9)),n.blocks.push(o),r();break}default:t.fail("a field, a title, or a line break")}return n}function Io(e,t,n,r,o,s=0){if(e===""||t<=0)return;let a=o.width(e,n,s);if(a<=t)return{text:e,size:n,width:a};let i=Math.max(r,Math.floor(n*t/a));for(;i>=r;){if(a=o.width(e,i,s),a<=t)return{text:e,size:i,width:a};i--}let c=Array.from(e),l=0,f=c.length-1;for(;l<f;){let u=l+f+1>>1;o.width(c.slice(0,u).join("").trimEnd()+"…",r,s)<=t?l=u:f=u-1}if(l===0)return;let p=c.slice(0,l).join("").trimEnd()+"…";return a=o.width(p,r,s),a<=t?{text:p,size:r,width:a}:void 0}function ay(e,t,n){return Nt(n,r=>U2(e,t,n,r))}function U2(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.875),a=Math.round(o*.625),i=n.measurer??Je(n.fontFamily),c=n.padding??8,l=t.packet??{},f=xi(t,"rowHeight",32,1,400),p=xi(t,"bitWidth",32,1,400),u=xi(t,"paddingX",5,0,400),m=xi(t,"paddingY",5,0,400),h=l.showBits!==!1,g=l.bitOrder==="descending",x=e.bitsPerRow,y=e.rows;if(r){let C=Math.max(1,Math.floor(((n.maxWidth??320)-2*c)/Math.min(p,18)));x=Math.min(x,Math.max(8,2**Math.floor(Math.log2(C))));let A=e.rows[e.rows.length-1],T=A?.[A.length-1]?.end??0;Math.ceil((T+1)/x)>1e4&&(x=e.bitsPerRow),p=Math.min(p,Math.max(18,((n.maxWidth??320)-2*c)/x));let b=$=>$.bits===$.end-$.start,N=[];for(let $ of e.rows)for(let X of $){let V=N[N.length-1];V&&b(V)&&b(X)&&V.label===X.label&&X.start===V.end+1&&X.start%e.bitsPerRow===0?(V.end=X.end,V.bits=V.end-V.start):N.push({...X})}y=[];for(let $ of N)for(let X=$.start;X<=$.end;){let V=Math.min($.end,(Math.floor(X/x)+1)*x-1),O=Math.floor(X/x);(y[O]??(y[O]=[])).push({...$,start:X,end:V}),X=V+1}}let _=new Map;if(r)for(let C of y)for(let A of C){let T=Math.max(1,(A.end-A.start+1)*p-Math.min(u,p-1)-6),b=Ss(gt(A.label).trim(),i,s,T);_.set(A,b)}let S=h?a+4:0,P=y.map(C=>{let A=f;if(r)for(let T of C)A=Math.max(A,_.get(T).height+10);return A}),k=[],w=0;for(let C of P)k.push(w),w+=S+C+m;y.length&&(w-=m);let I=Math.min(u,p-1),D=y.length>0?x*p-I:0,U=De(e.title,!1,i,o,r?Rt(n):4e3,1),M=U.height>0?U.height+(w>0?12:0):0,Q=new Map,q=(C,A)=>{let T=Q.get(C);return T||Q.set(C,T=new Map),T.has(A)||T.set(A,Io(gt(C).trim(),A,s,Math.round(o*.5),i)),T.get(A)},Y=c+Math.max(0,(U.width-D)/2),z="",R="";y.forEach((C,A)=>{let T=c+k[A]+S,b=P[A];for(let N of C){let $=N.end-N.start+1,X=N.start%x,V=Y+(g?x-X-$:X)*p,O=$*p-I,v=r?void 0:q(N.label,O-6);if(z+=`<g class="pele-node" data-id="${N.start}-${N.end}"><rect x="${d(V)}" y="${d(T)}" width="${d(O)}" height="${d(b)}" rx="${Xe}" fill="var(--_s)" stroke="var(--_b)"/>`+(r?Ie(_.get(N),V+O/2,T+b/2,""):v&&v.size<=b?`<text x="${d(V+O/2)}" y="${d(T+b/2+v.size*.35)}"${v.size===s?"":` font-size="${d(v.size)}"`}>${je(v.text)}</text>`:"")+"</g>",!h)continue;let W=g?N.end:N.start,H=g?N.start:N.end;$===1?R+=`<text x="${d(V+O/2)}" y="${d(T-4)}" text-anchor="middle">${W}</text>`:R+=`<text x="${d(V)}" y="${d(T-4)}">${W}</text><text x="${d(V+O)}" y="${d(T-4)}" text-anchor="end">${H}</text>`}});let L=Math.ceil(Math.max(D,U.width)+2*c),F=Math.ceil(w+M+2*c),E=(z?`<g class="pele-packet-fields" font-size="${s}" text-anchor="middle">${z}</g>`:"")+(R?`<g class="pele-packet-bits" font-size="${a}" fill="var(--_m)">${R}</g>`:"")+Ie(U,L/2,F-c-U.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:Ze("packet",L,F,o,n,e,E),width:L,height:F,links:[]}}var cy={type:"packet",parse:(e,t,n)=>sy(oy(e),t,n),render:ay};function ly(e,t){let n=new Map;for(let{label:r,value:o}of e.sections){if(o<0)throw new Ge(`"${r}" has invalid value: ${o}. Negative values are not allowed in pie charts. All slice values must be >= 0.`,"semantic",{type:"pie"});n.has(r)||n.set(r,o)}return{type:"pie",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
102
+ `):void 0,showData:e.showData,sections:n}}function dy(e,t){let n=t;for(let r=e.charCodeAt(n);r>=48&&r<=57;r=e.charCodeAt(n))n++;return n}function G2(){let e=0,t=0,n=-1;return(r,o)=>{let s=r.charCodeAt(o)===45?o+1:o;if((s<e||s>=t)&&(e=s,t=dy(r,s),n=-1,t>s&&r.charCodeAt(t)===46)){let a=dy(r,t+1),i=a-t-1;i>0&&r.charCodeAt(a)!==46?n=a:i>1&&(n=a-1)}return t===s?-1:n>=0?n:r.charCodeAt(s)===48?r.charCodeAt(s+1)===46?-1:s+1:r.charCodeAt(t)!==46?t:t-1>s?t-1:-1}}var uy=[Vt("showData"),Vt("pie"),{name:":",pattern:":"},{name:"NUMBER_PIE",pattern:/(?:-?[0-9]+\.[0-9]+(?!\.))|(?:-?(0|[1-9][0-9]*)(?!\.))/y,scanner:G2,first:"-0123456789"},Zt,Yt,Ht,wn,hn,mn,Pt,Kt,zt];function fy(e){let t=new Dt(vt(e,uy,"pie"),uy,"pie"),n={$type:"Pie",showData:!1,sections:[]},r=()=>{if(t.kind!==-1)for(t.kind!==8&&t.fail("a line break or the end of input");t.kind===8;)t.i++};for(;t.kind===8;)t.i++;for(t.expect(1),n.showData=t.accept(0);t.kind!==-1;)switch(t.kind){case 8:t.i++;break;case 4:n.accDescr=Wt(t.take()),r();break;case 5:n.accTitle=Ft(t.take()),r();break;case 6:n.title=Bt(t.take()),r();break;case 7:{let o=rn(t.take());t.expect(2);let s=Number(t.expect(3));n.sections.push({$type:"PieSection",label:o,value:s}),r();break}default:t.fail("a section, a title, or a line break")}return n}var Y2=120,No=12,ju=26,Xu=32,py=28;function qu(e,t){return e.pie?.[t]}function Si(e,t){return`${d(Math.sin(e)*t)},${d(-Math.cos(e)*t)}`}function H2(e,t,n,r){if(t-e>=Math.PI*2-1e-9){let s=(a,i)=>`M0,${d(-a)}A${d(a)},${d(a)} 0 1 ${i} 0,${d(a)}A${d(a)},${d(a)} 0 1 ${i} 0,${d(-a)}Z`;return s(n,1)+(r>0?s(r,0):"")}let o=t-e>Math.PI?1:0;return r<=0?`M0,0L${Si(e,n)}A${d(n)},${d(n)} 0 ${o} 1 ${Si(t,n)}Z`:`M${Si(e,n)}A${d(n)},${d(n)} 0 ${o} 1 ${Si(t,n)}L${Si(t,r)}A${d(r)},${d(r)} 0 ${o} 0 ${Si(e,r)}Z`}function hy(e,t,n){return Fr(n,Y2*2,140,(r,o)=>K2(e,t,n,r/2,o))}function K2(e,t,n,r,o){let s=n.fontSize??16,a=Math.round(s*.875),i=n.measurer??Je(n.fontFamily),c=n.padding??8,l=qu(t,"textPosition"),f=typeof l=="number"&&l>=0&&l<=1?l:.75,p=qu(t,"donutHole"),u=typeof p=="number"&&p>0&&p<=.9?p*r:0,m=String(qu(t,"legendPosition")??"right"),h=o&&(m==="left"||m==="right")?"bottom":m,g=[...e.sections],x=0;for(let[,H]of g)x+=H;let y=g.map(([H,G])=>De(e.showData?`${H} [${G}]`:H,!1,i,a,4e3)),_=0;for(let H of y)_=Math.max(_,H.width);_+=y.length>0?No+8:0;let S=y.length*ju,P=De(e.title,!1,i,s,Rt(n),1),k=P.height>0?P.height+16:0,w=g.map(([,H])=>{let G=x>0?H/x:0;return G*100>=1&&(G*100).toFixed(0)!=="0"?G:0}),I=w.map(H=>H===0||H>=.5?!1:2*r*f*Math.sin(H*Math.PI)<i.width((H*100).toFixed(0)+"%",a,0)+6),D=I.includes(!0)?py:0,U=h==="left"||h==="right"||h==="center"?h:"",M=h==="top"||h==="bottom",Q=(r+D)*2,q=Q,Y=Q;U==="left"||U==="right"?(q+=_>0?Xu+_:0,Y=Math.max(Y,S)):M&&(q=Math.max(q,_),Y+=S>0?20+S:0),q=Math.max(q,P.width);let z=c+(U==="left"?_+Xu+Q/2:U==="right"?Q/2:q/2),R=c+k,L=R+(h==="top"?S+20+Q/2:M?Q/2:Y/2),F="",E="",C="",A=0,T=r+py/2,b=[],N=(H,G,te)=>b.every(Z=>Math.abs(H-Z.x)>=(te+Z.width)/2+2||Math.abs(G-Z.y)>=a+2);g.forEach(([H],G)=>{let te=w[G];if(te===0)return;let Z=A+te*Math.PI*2;F+=`<path class="pele-slice" data-id="${$e(H)}" d="${H2(A,Z,r,u)}" fill="${ct(G)}"/>`;let B=(A+Z)/2,K=(te*100).toFixed(0)+"%";if(I[G]){let ee=i.width(K,a,0),ae=B;for(let me=0;me<360&&!N(Math.sin(ae)*T,-Math.cos(ae)*T,ee);me++)ae+=2/T;let J=Math.sin(ae)*T,se=-Math.cos(ae)*T;b.push({x:J,y:se,width:ee}),C+=`<text x="${d(J)}" y="${d(se+a*.35)}">${K}</text>`}else{let ee=r*f;E+=`<text x="${d(Math.sin(B)*ee)}" y="${d(-Math.cos(B)*ee+a*.35)}">${K}</text>`}A=Z}),F===""&&(F=`<circle class="pele-slice" r="${r}" fill="none" stroke="var(--_b)"/>`);let $="",X,V;U==="right"?(X=z+Q/2+Xu,V=R+(Y-S)/2):U==="left"?(X=c,V=R+(Y-S)/2):U==="center"?(X=z-_/2,V=L-S/2):(X=c+(q-_)/2,V=h==="top"?R:R+Q+20),y.forEach((H,G)=>{let te=V+G*ju+ju/2;$+=`<g class="pele-legend-item" data-id="${$e(g[G][0])}"><rect x="${d(X)}" y="${d(te-No/2)}" width="${No}" height="${No}" rx="2" fill="${ct(G)}"/>`+Ie(H,X+No+8+H.width/2,te,"")+"</g>"});let O=Math.ceil(q+2*c),v=Math.ceil(Y+k+2*c),W=Ie(P,O/2,c+P.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-slices" transform="translate(${d(z)},${d(L)})" stroke="var(--_bg)" stroke-width="1" stroke-linejoin="round">${F}</g>`+(E?`<g class="pele-slice-labels" transform="translate(${d(z)},${d(L)})" font-size="${a}" text-anchor="middle" fill="var(--_bg)">${E}</g>`:"")+(C?`<g class="pele-slice-labels" transform="translate(${d(z)},${d(L)})" font-size="${a}" text-anchor="middle">${C}</g>`:"")+($?`<g class="pele-legend" font-size="${a}">${$}</g>`:"");return{svg:Ze("pie",O,v,s,n,e,W),width:O,height:v,links:[]}}var my={type:"pie",parse:(e,t,n)=>ly(fy(e),n),render:hy};var z2=/^\d+$/,gy=/^#?([\dA-Fa-f]{6}|[\dA-Fa-f]{3})$/,V2=/^\d+px$/;function Dc(e,t,n){return new Ge(`value for ${e} ${t} is invalid, please use a valid ${n}`,"semantic",{type:"quadrantChart"})}function j2(e){let t=e.trim(),n=t.indexOf(":");if(n===-1)return[t,"undefined"];let r=t.slice(n+1).trimStart(),o=r.indexOf(":");return[t.slice(0,n).trimEnd(),o===-1?r:r.slice(0,o).trimEnd()]}function by(e){let t={};for(let n of e){let[r,o]=j2(n);if(r==="radius"){if(!z2.test(o))throw Dc(r,o,"number");t.radius=parseInt(o)}else if(r==="color"){if(!gy.test(o))throw Dc(r,o,"hex code");t.color=o}else if(r==="stroke-color"){if(!gy.test(o))throw Dc(r,o,"hex code");t.strokeColor=o}else if(r==="stroke-width"){if(!V2.test(o))throw Dc(r,o,"number of pixels (eg. 10px)");t.strokeWidth=o}else throw new Ge(`style named ${r} is not supported.`,"semantic",{type:"quadrantChart"})}return t}function Ir(e){return{text:e.text.trim(),type:e.type}}var Oc=class{type="quadrantChart";title;accTitle;accDescr;quadrants=[void 0,void 0,void 0,void 0];xAxisLeft;xAxisRight;yAxisBottom;yAxisTop;points=[];classes=new Map;setQuadrant1Text(t){this.quadrants[0]=Ir(t)}setQuadrant2Text(t){this.quadrants[1]=Ir(t)}setQuadrant3Text(t){this.quadrants[2]=Ir(t)}setQuadrant4Text(t){this.quadrants[3]=Ir(t)}setXAxisLeftText(t){this.xAxisLeft=Ir(t)}setXAxisRightText(t){this.xAxisRight=Ir(t)}setYAxisBottomText(t){this.yAxisBottom=Ir(t)}setYAxisTopText(t){this.yAxisTop=Ir(t)}addPoint(t,n,r,o,s){this.points.push({x:Number(r),y:Number(o),text:Ir(t),className:n,...by(s)})}addClass(t,n){this.classes.set(t,by(n))}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
103
+ `)}};function an(e,t,n){for(let r=0;r<n.length;r++){let o=e.charCodeAt(t+r),s=n.charCodeAt(r);if(o!==s&&!(s>=97&&s<=122&&o===s-32))return!1}return!0}var Qu=["$end","INVALID","NEWLINE","title","title_value","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","X-AXIS","Y-AXIS","AXIS-TEXT-DELIMITER","QUADRANT_1","QUADRANT_2","QUADRANT_3","QUADRANT_4","CLASSDEF","MD_STR","STR","class_name","point_start","point_x","point_y","QUADRANT","ALPHA","UNICODE_TEXT","COLON","PLUS","COMMA","EQUALS","MULT","BRKT","UNDERSCORE","DOT","AMP","MINUS","NUM","SPACE","SEMI","PUNCTUATION","EOF"];var Zu=[41,4,6,8,9,19],Ju=new Uint8Array(128);for(let[e,t]of[[":",27],["+",28],[",",29],["=",30],["*",31],["#",32],["_",33],[".",34],["&",35],["-",36],[" \v\f",38],[";",39],["!$%'`?\\/",40]])for(let n=0;n<e.length;n++)Ju[e.charCodeAt(n)]=t;function yy(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=0,l=0,f=0,p=0,u=0,m=0,h=0,g=0,x=(I,D,U)=>{n.push(I),r.push(e.slice(D,U)),o.push(D),i=U},y=I=>{s.push(a),a=I},_=()=>{s.length>0&&(a=s.pop())},S=I=>{let D=e.indexOf(`
104
+ `,I);return D===-1?t:D},P=I=>{for(;e.charCodeAt(I)===32;)I++;return I},k=I=>{for(;I<t&&Be(e.charCodeAt(I));)I++;return I},w=I=>{let D=e.charCodeAt(I);if(D===49)return I+1;if(D!==48)return-1;let U=I+1;if(U<t&&!ps(e.charCodeAt(U))&&ft(e.charCodeAt(U+1)))for(U+=2;ft(e.charCodeAt(U));)U++;return U};e:for(;i<t;){let I=e.charCodeAt(i),D=e.charCodeAt(i+1);switch(a){case 0:break;case 1:case 2:case 3:x(Zu[a],i,S(i)),_();continue;case 4:if(I===125)i++,_();else{let R=e.indexOf("}",i);x(9,i,R===-1?t:R)}continue;case 5:if(I===34)i++,_();else{let R=e.indexOf('"',i);x(19,i,R===-1?t:R)}continue;case 6:if(I===96&&D===34){i+=2,_();continue}if(I!==96&&I!==34){let R=i+1;for(let L=e.charCodeAt(R);R<t&&L!==96&&L!==34;L=e.charCodeAt(++R));x(18,i,R);continue}break e;case 7:if(Qe(I)){let R=i+1;for(;Qe(e.charCodeAt(R));)R++;x(20,i,R),_();continue}break e;case 8:{let R=w(i);if(R!==-1){x(22,i,R),y(9);continue}let L=k(i);if(e.charCodeAt(L)===93){i=P(L+1),_();continue}break e}case 9:{let R=k(i);if(e.charCodeAt(R)===44){i=k(R+1),a=10;continue}break e}case 10:{let R=w(i);if(R!==-1){x(23,i,R),_();continue}break e}}if(I===37&&D===37){i=S(i+2);continue}if(I!==125&&D===37&&e.charCodeAt(i+2)===37){i=S(i+3);continue}if(I===10||I===13){let R=i+1;for(let L=e.charCodeAt(R);L===10||L===13;L=e.charCodeAt(++R));x(2,i,R);continue}let U=I|32;if(U===116&&an(e,i,"title")&&!Qe(e.charCodeAt(i+5))){x(3,i,i+5),y(1);continue}if(U===97&&an(e,i,"acc")){let R=an(e,i+3,"descr");if(R||an(e,i+3,"title")){let L=k(i+8),F=e.charCodeAt(L);if(F===58){x(R?7:5,i,k(L+1)),y(R?3:2);continue}if(F===123&&R){i=k(L+1),y(4);continue}}}let M=i;I===32&&((i<c||i>=l)&&(c=i,l=P(i)),M=l);let Q=e.charCodeAt(M),q=Q|32,Y=0,z=0;if(q===120&&an(e,M,"x-axis"))Y=10,z=M+6;else if(q===121&&an(e,M,"y-axis"))Y=11,z=M+6;else if(Q===45){if(M<f||M>=p)for(f=M,p=M;e.charCodeAt(p)===45;)p++;p-M>=2&&e.charCodeAt(p)===62&&(Y=12,z=p+1)}else if(q===113&&an(e,M,"quadrant")){let R=e.charCodeAt(M+9);e.charCodeAt(M+8)===45&&R>=49&&R<=52?(Y=13+R-49,z=M+10):an(e,M+8,"chart")&&(Y=24,z=M+13)}if(Y!==0){x(Y,i,P(z));continue}if(U===99&&an(e,i,"classdef")&&!Qe(e.charCodeAt(i+8))){x(17,i,i+8);continue}if(I===34){D===96?(i+=2,y(6)):(i++,y(5));continue}if(I===58&&D===58&&e.charCodeAt(i+2)===58){i+=3,y(7);continue}if(I===58||Be(I)){let R=i;if(I!==58&&((i<u||i>=m)&&(u=i,m=k(i)),R=m),e.charCodeAt(R)===58&&((R+1<h||R+1>=g)&&(h=R+1,g=k(R+1)),e.charCodeAt(g)===91)){x(21,i,k(g+1)),y(8);continue}}if(yr(I)){let R=i+1;for(;yr(e.charCodeAt(R));)R++;x(25,i,R);continue}if(I>=128){let R=i+1;for(;e.charCodeAt(R)>=128;)R++;x(26,i,R);continue}if(ft(I)){let R=i+1;for(;ft(e.charCodeAt(R));)R++;x(37,i,R);continue}if(Ju[I]!==0){x(Ju[I],i,i+1);continue}break}return i<t?(n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o}):(a<Zu.length&&(n.push(Zu[a]),r.push(""),o.push(t)),n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o})}function vc(...e){let t=new Uint8Array(42);for(let n of e)t[n]=1;return t}var Ey=vc(40,35,37,25,29,28,30,31,34,32,33,26),Ay=vc(25,37,36,29,27,35,32,31,26),ef=vc(25,37,27,38,32,36),xy=vc(2,39,41),X2=["setQuadrant1Text","setQuadrant2Text","setQuadrant3Text","setQuadrant4Text"],q2="'STR', 'MD_STR', 'ALPHA', 'NUM', 'UNICODE_TEXT', 'PUNCTUATION'";function Sy(e,t){let{types:n,texts:r,starts:o}=yy(e),s=0,a=p=>{let u=n[s];throw u===1?it("quadrantChart",e,o[s],"",!0):it("quadrantChart",e,o[s],`Expecting ${p}, got '${Qu[u]}'`)},i=p=>(n[s]!==p&&a(`'${Qu[p]}'`),r[s++]),c=p=>p===19||p===18||Ey[p]===1,l=()=>{let p=n[s];c(p)||a(q2);let u=r[s++];for(;Ey[n[s]]===1||n[s]===38||n[s]===36;)u+=r[s++];return{text:u,type:p===18?"markdown":"text"}},f=()=>{let p=[];for(;;){ef[n[s]]===0&&a("'ALPHA', 'NUM', 'COLON', 'SPACE', 'BRKT', 'MINUS'");let u=r[s++];for(;ef[n[s]]===1;)u+=r[s++];if(p.push(u.trim()),n[s]!==29)return p;s++}};for(;xy[n[s]]===1||n[s]===38;)s++;for(i(24);n[s]!==0;){for(;n[s]===38;)s++;let p=n[s];switch(p){case 17:{s++,i(38),Ay[n[s]]===0&&a("'ALPHA', 'NUM', 'UNICODE_TEXT'");let u=r[s++];for(;Ay[n[s]]===1;)u+=r[s++];i(38),t.addClass(u,f());break}case 10:case 11:{s++;let u=l(),m;n[s]===12&&(s++,c(n[s])?m=l():u.text+=" ⟶ "),p===10?(t.setXAxisLeftText(u),m&&t.setXAxisRightText(m)):(t.setYAxisBottomText(u),m&&t.setYAxisTopText(m));break}case 13:case 14:case 15:case 16:s++,t[X2[p-13]](l());break;case 3:s++,t.setDiagramTitle(i(4).trim());break;case 5:s++,t.setAccTitle(i(6).trim());break;case 7:s++,t.setAccDescription(i(8).trim());break;case 9:t.setAccDescription(r[s++].trim());break;default:if(c(p)){let u=l(),m=n[s]===20?r[s++]:"";i(21);let h=i(22),g=i(23);t.addPoint(u,m,h,g,ef[n[s]]===1?f():[])}}xy[n[s]]===0&&a("'NEWLINE', 'SEMI', 'EOF'"),s++}}var _y=4,Q2=300;function tf(e,t){return e.quadrantChart?.[t]}function Nr(e,t,n,r){let o=tf(e,t);return typeof o=="number"&&o>=0?Math.min(o,r):n}function wy(e){return e.startsWith("#")?e:"#"+e}function Ry(e,t,n){let r=n.fontSize??16,o=Math.round(r*.875),s=Math.round(r*.75),a=n.measurer??Je(n.fontFamily),i=Math.round(Math.max(100,Nr(t,"chartWidth",500,4e3))),c=Math.round(Wr(n,i,280)),l=Math.round(Math.max(100,Nr(t,"chartHeight",500,4e3))*c/i),f=Nr(t,"quadrantPadding",n.padding??8,200),p=Nr(t,"xAxisLabelPadding",5,200),u=Nr(t,"yAxisLabelPadding",5,200),m=e.points.length>0,h=(K,ee,ae)=>De(K?.text,K?.type==="markdown",a,ee,Math.max(ae,40)),g=De(e.title,!1,a,r,Math.max(c-2*f,40),1),x=Nr(t,"titlePadding",10,200),y=g.height>0?g.height+x:0,_=!!(e.xAxisLeft?.text||e.xAxisRight?.text),S=!!(e.yAxisBottom?.text||e.yAxisTop?.text),P=m||tf(t,"xAxisPosition")==="bottom",k=tf(t,"yAxisPosition")==="right",w=c-2*f,I=h(e.xAxisLeft,o,e.xAxisRight?w/2-16:w),D=h(e.xAxisRight,o,w/2-16),U=Math.max(I.height,D.height),M=_?U+p:0,Q=l-2*f-y-M,q=h(e.yAxisBottom,o,e.yAxisTop?Q/2-16:Q),Y=h(e.yAxisTop,o,Q/2-16),z=Math.max(q.height,Y.height),R=S?z+u:0,L=f+(k?0:R),F=f+y+(P?0:M),E=Math.max(0,w-R),C=Math.max(0,Q),A=Math.max(0,(E-_y)/2),T=Math.max(0,(C-_y)/2),b=[L+A,F,L+E-A,F+C,L,F+T,L+E,F+C-T],N=(K,ee,ae,J,se)=>{for(let me=K;me<b.length;me+=4)if(ee<b[me+2]&&J>b[me]&&ae<b[me+3]&&se>b[me+1])return!1;return!0},$=Nr(t,"quadrantTextTopPadding",5,200),X="";for(let K=0;K<4;K++){let ee=K===0||K===3?L+E-A:L,ae=K<2?F:F+C-T,J=h(e.quadrants[K],r,A-16),se=ee+A/2,me=m?ae+$+J.height/2:ae+T/2;b.push(se-J.width/2,me-J.height/2,se+J.width/2,me+J.height/2),X+=`<g class="pele-quadrant" data-id="${K+1}"><rect x="${d(ee)}" y="${d(ae)}" width="${d(A)}" height="${d(T)}" rx="${Xe}"/>`+Ie(J,se,me,' class="pele-label" fill="var(--_fg)" stroke="none"')+"</g>"}let V="";if(_){let K=P?F+C+p+U/2:F-p-U/2;V+=Ie(I,D.height>0?L+E/4:L+I.width/2,K,"")+Ie(D,L+E*3/4,K,"")}if(S){let K=k?L+E+u+z/2:L-u-z/2,ee=(ae,J)=>ae.height>0?`<g transform="translate(${d(K)},${d(J)}) rotate(-90)">${Ie(ae,0,0,"")}</g>`:"";V+=ee(q,Y.height>0?F+C*3/4:F+C-q.width/2)+ee(Y,F+C/4)}let O=Nr(t,"pointRadius",5,200),v=Nr(t,"pointTextPadding",5,200),W=ct(0),H=[],G=[];for(let K of e.points){if(!(K.x>=0&&K.x<=1&&K.y>=0&&K.y<=1))continue;let ee=e.classes.get(K.className),ae=Math.min(K.radius??ee?.radius??O,2e3),J=K.color??ee?.color,se=K.strokeColor??ee?.strokeColor,me=K.strokeWidth??ee?.strokeWidth,Ae=[];J&&Ae.push("fill:"+wy(J)),me&&(se&&Ae.push("stroke:"+wy(se)),Ae.push("stroke-width:"+me));let de=L+K.x*E,oe=F+(1-K.y)*C;H.push({cx:de,cy:oe,reach:ae+(me?Math.min(parseInt(me),400)/2:0),text:h(K.text,s,200)}),G.push(`<circle class="pele-point${wt(K.className)}" data-id="${$e(K.text.text)}" cx="${d(de)}" cy="${d(oe)}" r="${d(ae)}"${me&&!se?` stroke="${W}"`:""}${At(Ae).shape}/>`)}let te=H.length<=Q2;if(te)for(let{cx:K,cy:ee,reach:ae}of H)b.push(K-ae,ee-ae,K+ae,ee+ae);let Z="";for(let{cx:K,cy:ee,reach:ae,text:J}of H){let se=J.width/2,me=J.size*.6+(J.height-J.lineHeight)/2,Ae=ae+v,de=[K,ee+Ae+me,K,ee-Ae-me,K+Ae+se,ee,K-Ae-se,ee],oe=K,ye=de[1],ce=!1;for(let fe=0;fe<16;fe+=2){let xe=fe%8,be=xe<4&&J.width<E?Math.min(Math.max(de[xe],L+se),L+E-se):de[xe],re=de[xe+1];if(be-se<L||be+se>L+E||re-me<F||re+me>F+C)continue;let j=!te||N(fe<8?0:8,be-se,re-me,be+se,re+me);if((!ce||j)&&(oe=be,ye=re,ce=!0),j)break}te&&b.push(oe-se,ye-me,oe+se,ye+me),Z+=Ie(J,oe,ye,' class="pele-label"')}let B=Ie(g,c/2,x/2+g.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-quadrants" fill="var(--_s)" stroke="var(--_b)">${X}</g>`+(V?`<g class="pele-axis-labels" font-size="${o}" fill="var(--_m)">${V}</g>`:"")+(H.length>0?`<g class="pele-points" fill="${W}">${G.reverse().join("")}</g><g class="pele-point-labels" font-size="${s}">${Z}</g>`:"");return{svg:Ze("quadrantChart",c,l,r,n,e,B),width:c,height:l,links:[]}}var Ty={type:"quadrantChart",parse(e,t,n){let r=new Oc;return r.title=n,Sy(e,r),r},render:Ry};var Cy=32;function Iy(e){return new Ge(e,"semantic",{type:"radar"})}function Ny(e,t){let n=e.axes.map(s=>({name:s.name,label:s.label??s.name})),r=e.curves.map(s=>{let a;if(s.entries[0].axis===void 0)a=s.entries.map(i=>i.value);else{if(n.length===0)throw Iy("Axes must be populated before curves for reference entries");let i=new Map;for(let c of s.entries)c.axis!==void 0&&!i.has(c.axis.$refText)&&i.set(c.axis.$refText,c.value);a=n.map(c=>{let l=i.get(c.name);if(l===void 0)throw Iy("Missing entry for axis "+c.label);return l})}return{name:s.name,label:s.label??s.name,entries:a}}),o={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"};for(let s of e.options)s.name==="showLegend"?o.showLegend=s.value:s.name==="graticule"?o.graticule=s.value:o[s.name]=s.value;return o.ticks>Cy&&(o.ticks=Cy),{type:"radar",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
105
+ `):void 0,axes:n,curves:r,options:o}}var sf=0,Pc=0;function My(e,t){let n=t;for(let r=e.charCodeAt(n);r>=48&&r<=57;r=e.charCodeAt(n))n++;return n}function Z2(e,t){(t<sf||t>=Pc)&&(sf=t,Pc=My(e,t));let n=Pc;if(n===t)return-1;let r=e.charCodeAt(n)===46;if(r){let o=My(e,n+1),s=o-n-1;if(s>0&&e.charCodeAt(o)!==46)return o;if(s>1)return o-1}return e.charCodeAt(t)===48?t+1:r?n-1>t?n-1:-1:n}var nf=Zt.pattern,rf=/[\t ]*accDescr\s*{/y,Bc=-2;function J2(e,t){return rf.lastIndex=t,rf.test(e)&&(Bc===-2&&(Bc=e.lastIndexOf("}")),rf.lastIndex>Bc)?-1:(nf.lastIndex=t,nf.test(e)?nf.lastIndex:-1)}var of={name:"ID",pattern:/[\w]([-\w]*\w)?/y},$s=e=>({name:e,pattern:e,longer:[of]}),Ds=e=>({name:e,pattern:e}),ky=[Ds("radar-beta:"),{...Vt("radar-beta"),longer:[of]},$s("showLegend"),$s("graticule"),$s("curve"),$s("ticks"),$s("axis"),$s("max"),$s("min"),Ds(":"),Ds(","),Ds("["),Ds("]"),Ds("{"),Ds("}"),{name:"GRATICULE",pattern:/circle|polygon/y},{name:"BOOLEAN",pattern:/true|false/y},{...Zt,match:J2},Yt,Ht,{name:"NUMBER",pattern:/(?:[0-9]+\.[0-9]+(?!\.))|(?:0|[1-9][0-9]*(?!\.))/y,match:Z2},wn,of,hn,mn,Pt,Kt,zt];function eC(e){return sf=Pc=0,Bc=-2,vt(e,ky,"radar")}function Ly(e){let t=new Dt(eC(e),ky,"radar"),n={$type:"Radar",axes:[],curves:[],options:[]},r=()=>{for(;t.kind===23;)t.i++},o=()=>{t.kind!==-1&&(t.kind!==23&&t.fail("a line break or the end of input"),r())},s=()=>{if(!t.accept(11))return;let p=rn(t.expect(21));return t.expect(12),p},a=p=>{if(!p)return{$type:"Entry",value:Number(t.expect(20))};let u={$refText:t.expect(22)};return t.accept(9),{$type:"Entry",axis:u,value:Number(t.expect(20))}},i=()=>{let p=t.expect(22),u=s(),m={$type:"Curve",name:p,entries:[]};u!==void 0&&(m.label=u),t.expect(13),r(),t.kind!==20&&t.kind!==22&&t.fail("a number or an axis name");let h=t.kind===22;for(m.entries.push(a(h));t.accept(10);)r(),m.entries.push(a(h));return r(),t.expect(14),m},c=()=>{let p={$type:"Axis",name:t.expect(22)},u=s();return u!==void 0&&(p.label=u),p},l=()=>{let p=t.kind,u=t.take(),m;return p===2?m=t.expect(16)==="true":p===3?m=t.expect(15):m=Number(t.expect(20)),{$type:"Option",name:u,value:m}},f=()=>t.kind===2||t.kind===5||t.kind===7||t.kind===8||t.kind===3;for(r(),t.accept(0)||(t.expect(1),t.accept(9)),r();t.kind!==-1;)switch(t.kind){case 23:t.i++;break;case 17:n.accDescr=Wt(t.take()),o();break;case 18:n.accTitle=Ft(t.take()),o();break;case 19:n.title=Bt(t.take()),o();break;case 6:t.i++;do n.axes.push(c());while(t.accept(10));break;case 4:t.i++;do n.curves.push(i());while(t.accept(10));break;default:for(f()||t.fail("an axis, a curve, an option, a title, or a line break"),n.options.push(l());t.accept(10);)f()||t.fail("an option"),n.options.push(l())}return n}var _i=12,af=26,$y=24;function Mr(e,t,n,r,o){let s=e.radar?.[t];return typeof s=="number"&&s>=r?Math.min(s,o):n}function tC(e,t,n,r){let o=Math.min(Math.max(e,t),n);return r*(o-t)/(n-t)}function nC(e,t){let n=e.length,r=`M${d(e[0].x)},${d(e[0].y)}`;for(let o=0;o<n;o++){let s=e[(o-1+n)%n],a=e[o],i=e[(o+1)%n],c=e[(o+2)%n];r+=` C${d(a.x+(i.x-s.x)*t)},${d(a.y+(i.y-s.y)*t)} ${d(i.x-(c.x-a.x)*t)},${d(i.y-(c.y-a.y)*t)} ${d(i.x)},${d(i.y)}`}return r+" Z"}function Dy(e){let t="";for(let n of e)t+=(t?" ":"")+d(n.x)+","+d(n.y);return t}function Oy(e,t,n){let r=Mr(t,"width",320,1,4e3);return Fr(n,r,160,(o,s)=>rC(e,t,n,o,Mr(t,"height",320,1,4e3)*o/r,s))}function rC(e,t,n,r,o,s){let a=n.fontSize??16,i=Math.round(a*.875),c=n.measurer??Je(n.fontFamily),l=n.padding??8,f=Mr(t,"axisScaleFactor",1,0,10),p=Mr(t,"axisLabelFactor",1.05,0,10),u=Mr(t,"curveTension",.17,0,1),m=Math.min(r,o)/2,{axes:h,curves:g}=e,{ticks:x,graticule:y,min:_}=e.options,S=h.length,P=h.map((O,v)=>{let W=2*Math.PI*v/S-Math.PI/2;return{x:Math.cos(W),y:Math.sin(W)}}),k=e.options.max;if(k===null){k=-1/0;for(let O of g)for(let v of O.entries)v>k&&(k=v)}let w=-r/2-Mr(t,"marginLeft",16,0,2e3),I=r/2+Mr(t,"marginRight",16,0,2e3),D=-o/2-Mr(t,"marginTop",16,0,2e3),U=o/2+Mr(t,"marginBottom",16,0,2e3),M="";for(let O=0;O<x;O++){let v=Math.min(m,m*(O+1)/x);y==="circle"?M+=`<circle r="${d(v)}"/>`:M+=`<polygon points="${Dy(P.map(W=>({x:W.x*v,y:W.y*v})))}"/>`}let Q="",q="";P.forEach((O,v)=>{let W=m*f;Q+=`M0,0L${d(O.x*W)},${d(O.y*W)}`;let H=De(h[v].label,!1,c,i,4e3),G=m*p+6,te=O.x*G+(O.x>.01?H.width/2:O.x<-.01?-H.width/2:0),Z=O.y*G+(O.y>.01?H.height/2:O.y<-.01?-H.height/2:0);q+=`<g class="pele-axis-label" data-id="${$e(h[v].name)}">${Ie(H,te,Z,"")}</g>`,w=Math.min(w,te-H.width/2),I=Math.max(I,te+H.width/2),D=Math.min(D,Z-H.height/2),U=Math.max(U,Z+H.height/2)});let Y="";g.forEach((O,v)=>{if(O.entries.length!==S)return;let W=O.entries.map((te,Z)=>{let B=tC(te,_,k,m),K=Number.isFinite(B)?B:0;return{x:P[Z].x*K,y:P[Z].y*K}}),H=ct(v),G=` class="pele-curve" data-id="${$e(O.name)}" fill="${H}" stroke="${H}"`;Y+=y==="circle"?`<path${G} d="${nC(W,u)}"/>`:`<polygon${G} points="${Dy(W)}"/>`});let z=e.options.showLegend?g.map(O=>De(O.label,!1,c,i,4e3)):[],R=0;for(let O of z)R=Math.max(R,O.width);let L=z.length*af,F=s?-(_i+8+R)/2:I+$y,E=s?U+$y/2:-L/2;z.length>0&&s?(w=Math.min(w,F),I=Math.max(I,-F),U=E+L):z.length>0&&(I=F+_i+8+R,D=Math.min(D,-L/2),U=Math.max(U,L/2));let C="";z.forEach((O,v)=>{let W=E+v*af+af/2,H=ct(v);C+=`<g class="pele-legend-item" data-id="${$e(g[v].name)}"><rect x="${d(F)}" y="${d(W-_i/2)}" width="${_i}" height="${_i}" rx="2" fill="${H}" fill-opacity="0.4" stroke="${H}"/>`+Ie(O,F+_i+8+O.width/2,W,"")+"</g>"});let A=De(e.title,!1,c,a,Rt(n),1),T=A.height>0?A.height+8:0,b=Math.max(I-w,A.width),N=Math.ceil(b+2*l),$=Math.ceil(U-D+T+2*l),X=`translate(${d(l+(b-(I-w))/2-w)},${d(l+T-D)})`,V=Ie(A,N/2,l+A.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="${X}">`+(M?`<g class="pele-graticule" fill="none" stroke="var(--_a)">${M}</g>`:"")+(Q?`<path class="pele-axes" d="${Q}" fill="none" stroke="var(--_b)"/>`:"")+(Y?`<g class="pele-curves" fill-opacity="0.2" stroke-width="1.5" stroke-linejoin="round">${Y}</g>`:"")+(q?`<g class="pele-axis-labels" font-size="${i}">${q}</g>`:"")+(C?`<g class="pele-legend" font-size="${i}">${C}</g>`:"")+"</g>";return{svg:Ze("radar",N,$,a,n,e,V),width:N,height:$,links:[]}}var vy={type:"radar",parse:(e,t,n)=>Ny(Ly(e),n),render:Oy};function cf(e){return e===32||e>=9&&e<=13||e>127&&/\s/.test(String.fromCharCode(e))}function sC(){let e=1/0;return(t,n)=>{if(!t.startsWith("accDescr",n))return-1;let r=t.length,o=n+8;for(;o<r&&(t.charCodeAt(o)===32||t.charCodeAt(o)===9);)o++;if(t.charCodeAt(o)===58){for(o++;o<r;o++){let a=t.charCodeAt(o);if(a===10||a===13||a===37&&t.charCodeAt(o+1)===37)break}return o}for(;o<r&&cf(t.charCodeAt(o));)o++;if(t.charCodeAt(o)!==123||o>=e)return-1;let s=t.indexOf("}",o+1);return s===-1&&(e=o),s+1||-1}}var lf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",qr={name:"TITLE",pattern:/title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:"t"},Qr={name:"ACC_TITLE",pattern:/accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:"a"},Zr={name:"ACC_DESCR",pattern:/accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:"a",scanner:sC};function pt(e,t){return{name:e,pattern:e,longer:t}}function Jr(e,t){return{...Vt(e),longer:[t]}}function wi(e){return{name:e,pattern:/[A-Z_a-z][\w-]*/y,first:lf+"_"}}function Ri(e){return{name:e,pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`}}function es(e){return[{name:e+"_WHITESPACE",pattern:/[\t \r\n]+/y,hidden:!0,first:` \r
106
+ `},{...Pt,name:e+"_YAML",first:"-"},{...Kt,name:e+"_DIRECTIVE",first:" %"},{...zt,name:e+"_SINGLE_LINE_COMMENT",first:" %"}]}function kr(e){if(!e.includes("\\"))return e.slice(1,-1);let t=e.length-1,n="";for(let r=1;r<t;r++){let o=e[r];o==="\\"&&r+1<t?(o=e[++r],n+=o==="n"?`
107
+ `:o==="r"?"\r":o==="t"?" ":o):n+=o}return n}function ts(e,t,n,r,o,s){let a=new Dt(vt(e,t,"railroad"),t,"railroad"),i={$type:n,rules:[]};for(a.expect(0);;){let c=a.kind;if(c===r){let l=Bt(a.take()),f=l[0];i.title=(f==='"'||f==="'")&&l.endsWith(f)?o(l):l}else if(c===r+1)i.accTitle=Ft(a.take());else if(c===r+2)i.accDescr=Wt(a.take());else break}for(;a.kind!==-1;)i.rules.push(s(a));return i}var df=[];function Fc(e){let t=e,n=t.element??t.primary??t.suffix,r=t.alternatives??t.elements??(n?[n]:df);if(t.base){r=[t.base];for(let o of t.postfixes)o.except&&r.push(o.except)}return r}var Lr=e=>({type:"terminal",value:e}),ns=e=>({type:"nonterminal",name:e}),Os=e=>({type:"special",text:e}),mr=e=>({type:"optional",element:e}),$r=(e,t,n=1/0)=>({type:"repetition",element:e,min:t,max:n});function rs(e){return e.length===1?e[0]:{type:"sequence",elements:e}}function ss(e){return e.length===1?e[0]:{type:"choice",alternatives:e}}function is(e,t){return e.rules.map(n=>({name:n.name,definition:uf(n.definition,Fc,t)}))}function uf(e,t,n){let r=[e],o=[t(e)],s=[[]];for(;;){let a=r.length-1,i=s[a];if(i.length<o[a].length){let c=o[a][i.length];r.push(c),o.push(t(c)),s.push([])}else{let c=n(r[a],i);if(a===0)return c;r.pop(),o.pop(),s.pop(),s[a-1].push(c)}}}var Py="0123456789",By={name:"ABNF_RULENAME",pattern:/[A-Za-z][A-Za-z0-9-]*/y,first:lf},Fy={name:"ABNF_COMMENT",pattern:/;[^\n\r]*/y,hidden:!0,first:";"},Uy=[Jr("railroad-abnf-beta",By),pt("="),pt(";",[Fy]),pt("/"),pt("("),pt(")"),pt("["),pt("]"),qr,Qr,Zr,By,{name:"ABNF_STRING",pattern:/"[^"]*"/y,first:'"'},{name:"ABNF_NUMVAL",pattern:/%[xXdDbB][0-9A-Fa-f]+(?:-[0-9A-Fa-f]+|\.[0-9A-Fa-f]+)*/y,first:"%"},{name:"ABNF_REPEAT",pattern:/[0-9]*\*[0-9]*/y,first:Py+"*"},{name:"ABNF_EXACT_REPEAT",pattern:/[0-9]+/y,first:Py},...es("ABNF"),Fy];function Wy(e,t,n,r){let o={$type:"AbnfConcatenation",elements:[]};return t.alternatives.push(o),{alternation:t,concatenation:o,node:e,close:n,repeat:r}}function iC(e){let t=[],n=Wy(void 0,{$type:"AbnfAlternation",alternatives:[]},-2,void 0);for(;;){let r=e.kind===14||e.kind===15?e.take():void 0,o,s=e.kind;switch(s){case 12:o={$type:"AbnfStringLiteral",value:e.take().slice(1,-1)};break;case 13:o={$type:"AbnfNumVal",value:e.take()};break;case 11:o={$type:"AbnfRuleName",name:e.take()};break;case 4:case 6:{e.i++;let a={$type:"AbnfAlternation",alternatives:[]};t.push(n),n=Wy({$type:s===4?"AbnfGroup":"AbnfOptionalGroup",element:a},a,s+1,r);continue}default:e.fail("a string, a number, a name, or an opening bracket")}for(;;){n.concatenation.elements.push(r===void 0?{$type:"AbnfElement",primary:o}:{$type:"AbnfElement",repeat:r,primary:o});let a=e.kind;if(a===n.close){e.i++,o=n.node,r=n.repeat,n=t.pop();continue}if(a===3)e.i++,n.concatenation={$type:"AbnfConcatenation",elements:[]},n.alternation.alternatives.push(n.concatenation);else if(a!==12&&a!==13&&a!==11&&a!==4&&a!==6&&a!==14&&a!==15){if(t.length===0)return n.alternation;e.fail(`token of type '${Uy[n.close].name}'`)}break}}}function Gy(e){return ts(e,Uy,"RailroadAbnf",8,t=>t.slice(1,-1),t=>{let n=t.expect(11);t.expect(1);let r=iC(t);return t.expect(2),{$type:"AbnfRule",name:n,definition:r}})}function oC(e,t){switch(e.$type){case"AbnfAlternation":return ss(t);case"AbnfConcatenation":return rs(t);case"AbnfElement":{let n=e.repeat;if(!n)return t[0];let r=n.indexOf("*"),o=r===-1,s=r>0||o?parseInt(n,10):0,a=o?s:r<n.length-1?parseInt(n.slice(r+1),10):1/0;return s===0&&a===1?mr(t[0]):$r(t[0],s,a)}case"AbnfStringLiteral":case"AbnfNumVal":return Lr(e.value);case"AbnfRuleName":return ns(e.name);case"AbnfGroup":return t[0];case"AbnfOptionalGroup":return mr(t[0])}}var Yy=e=>is(e,oC);function aC(e,t){if(e.charCodeAt(t)!==63)return-1;let n=!1;for(let r=t+1;r<e.length;r++){let o=e.charCodeAt(r);if(o===63)return n?r+1:-1;if(o===59)return-1;n||=!cf(o)}return-1}var Hy=wi("EBNF_ID"),Ky={name:"EBNF_SPECIAL_SEQUENCE",pattern:/\?(?=[^?;]*[^?\s;][^?;]*\?)[^?;]*\?/y,first:"?",scanner:()=>aC},zy=es("EBNF"),Vy={name:"EBNF_ISO_COMMENT",pattern:/\(\*[\s\S]*?\*\)/y,hidden:!0,first:"(",opener:/\(\*/y},Xy=[Jr("railroad-ebnf-beta",Hy),pt("::="),pt("="),pt(";"),pt("|"),pt(","),pt("(",[Vy]),pt(")"),pt("["),pt("]"),pt("{"),pt("}"),pt("?",[Ky]),pt("*"),pt("+"),pt("-",[zy[1]]),qr,Qr,Zr,Hy,Ri("EBNF_STRING"),Ky,...zy,{name:"EBNF_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y},Vy];function jy(e,t,n,r){let o={$type:"EbnfSequence",elements:[]};return t.alternatives.push(o),{choice:t,sequence:o,term:void 0,node:e,close:n,except:r}}var cC=["EbnfGroup","EbnfOptional","EbnfRepetition"];function lC(e){let t=[],n=jy(void 0,{$type:"EbnfChoice",alternatives:[]},-2,!1),r=!1;for(;;){let o,s=e.kind;switch(s){case 20:o={$type:"EbnfTerminal",value:kr(e.take())};break;case 19:o={$type:"EbnfNonTerminal",name:e.take()};break;case 21:o={$type:"EbnfSpecial",text:e.take().slice(1,-1).trim()};break;case 6:case 8:case 10:{e.i++;let a={$type:"EbnfChoice",alternatives:[]};t.push(n),n=jy({$type:cC[s-6>>1],element:a},a,s+1,r),r=!1;continue}default:e.fail("a terminal, a name, or an opening bracket")}for(;;){r?(n.term.postfixes.push({$type:"EbnfExceptionPostfix",except:o}),r=!1):(n.term={$type:"EbnfTerm",base:o,postfixes:[]},n.sequence.elements.push(n.term));let a=n.term.postfixes;for(;;){let c=e.kind;if(c===12)a.push({$type:"EbnfOptionalPostfix",operator:e.take()});else if(c===13)a.push({$type:"EbnfZeroOrMorePostfix",operator:e.take()});else if(c===14)a.push({$type:"EbnfOneOrMorePostfix",operator:e.take()});else break}let i=e.kind;if(i===n.close){e.i++,o=n.node,r=n.except,n=t.pop();continue}if(i===15)e.i++,r=!0;else if(i===5)e.i++;else if(i===4)e.i++,n.sequence={$type:"EbnfSequence",elements:[]},n.choice.alternatives.push(n.sequence);else if(i!==20&&i!==19&&i!==21&&i!==6&&i!==8&&i!==10){if(t.length===0)return n.choice;e.fail(`token of type '${Xy[n.close].name}'`)}break}}}function qy(e){return ts(e,Xy,"RailroadEbnf",16,kr,t=>{let n=t.expect(19);t.accept(2)||t.expect(1);let r={$type:"EbnfRule",name:n,definition:lC(t)};return t.expect(3),r})}function dC(e,t){switch(e.$type){case"EbnfChoice":return ss(t);case"EbnfSequence":return rs(t);case"EbnfTerm":{let n=t[0],r=1;for(let o of e.postfixes)o.$type==="EbnfOptionalPostfix"?n=mr(n):o.$type==="EbnfExceptionPostfix"?n={type:"sequence",elements:[n,Lr("-"),t[r++]]}:n=$r(n,o.$type==="EbnfOneOrMorePostfix"?1:0);return n}case"EbnfTerminal":return Lr(e.value);case"EbnfNonTerminal":return ns(e.name);case"EbnfSpecial":return Os(e.text);case"EbnfGroup":return t[0];case"EbnfOptional":return mr(t[0]);case"EbnfRepetition":return $r(t[0],0)}}var Qy=e=>is(e,dC);var hf=wi("RR_ID"),os=e=>pt(e,[hf]),uC=[Jr("railroad-beta",hf),os("nonterminal"),os("zeroOrMore"),os("oneOrMore"),os("sequence"),os("optional"),os("terminal"),os("special"),os("choice"),pt("="),pt(";"),pt("("),pt(","),pt(")"),qr,Qr,Zr,hf,Ri("RR_STRING"),...es("RR"),{name:"RR_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y}];function ff(e){e.i++,e.expect(11);let t=kr(e.expect(18));return e.expect(13),t}function pf(e){return{$type:e,element:void 0}}function fC(e){let t=[];for(;;){let n;switch(e.kind){case 6:n={$type:"RailroadTerminalExpr",value:ff(e)};break;case 1:n={$type:"RailroadNonTerminalExpr",name:ff(e)};break;case 7:n={$type:"RailroadSpecialExpr",text:ff(e)};break;case 4:n={$type:"RailroadSequenceExpr",elements:[]};break;case 8:n={$type:"RailroadChoiceExpr",alternatives:[]};break;case 5:n=pf("RailroadOptionalExpr");break;case 3:n=pf("RailroadOneOrMoreExpr");break;case 2:n=pf("RailroadZeroOrMoreExpr");break;default:e.fail("an expression")}if("elements"in n||"alternatives"in n||"element"in n){e.i++,e.expect(11),t.push(n);continue}for(;;){let r=t[t.length-1];if(r===void 0)return n;if("element"in r)r.element=n;else if(("elements"in r?r.elements:r.alternatives).push(n),e.accept(12))break;e.expect(13),t.pop(),n=r}}}function Zy(e){return ts(e,uC,"Railroad",14,kr,t=>{let n=t.expect(17);t.expect(9);let r=fC(t);return t.expect(10),{$type:"RailroadRule",name:n,definition:r}})}function pC(e,t){switch(e.$type){case"RailroadTerminalExpr":return Lr(e.value);case"RailroadNonTerminalExpr":return ns(e.name);case"RailroadSpecialExpr":return Os(e.text);case"RailroadSequenceExpr":return rs(t);case"RailroadChoiceExpr":return ss(t);case"RailroadOptionalExpr":return mr(t[0]);default:return $r(t[0],e.$type==="RailroadOneOrMoreExpr"?1:0)}}var Jy=e=>is(e,pC);var eE=wi("PEG_ID"),hC=[Jr("railroad-peg-beta",eE),pt("<-"),pt(";"),pt("/"),pt("&"),pt("!"),pt("?"),pt("*"),pt("+"),pt("("),pt(")"),pt("."),qr,Qr,Zr,eE,Ri("PEG_STRING"),...es("PEG"),{name:"PEG_LINE_COMMENT",pattern:/#[^\n\r]*/y,hidden:!0,first:"#"}];function tE(e,t,n){let r={$type:"PegSequence",elements:[]};return t.alternatives.push(r),{choice:t,sequence:r,node:e,operator:n}}function mC(e){let t=[],n=tE(void 0,{$type:"PegOrderedChoice",alternatives:[]},void 0);for(;;){let r=e.kind===4||e.kind===5?e.take():void 0,o;switch(e.kind){case 16:o={$type:"PegLiteral",value:kr(e.take())};break;case 15:o={$type:"PegIdentifier",name:e.take()};break;case 11:o={$type:"PegAny",dot:e.take()};break;case 9:{e.i++;let a={$type:"PegOrderedChoice",alternatives:[]};t.push(n),n=tE({$type:"PegGroup",element:a},a,r);continue}default:e.fail("a literal, a name, a dot, or an opening parenthesis")}for(;;){let a={$type:"PegSuffix",primary:o};(e.kind===6||e.kind===7||e.kind===8)&&(a.operator=e.take()),n.sequence.elements.push(r===void 0?{$type:"PegPrefix",suffix:a}:{$type:"PegPrefix",operator:r,suffix:a});let i=e.kind;if(i===10&&t.length>0){e.i++,o=n.node,r=n.operator,n=t.pop();continue}if(i===3)e.i++,n.sequence={$type:"PegSequence",elements:[]},n.choice.alternatives.push(n.sequence);else if(i!==4&&i!==5&&i!==16&&i!==15&&i!==11&&i!==9){if(t.length===0)return n.choice;e.fail("token of type ')'")}break}}}function nE(e){return ts(e,hC,"RailroadPeg",12,kr,t=>{let n=t.expect(15);t.expect(1);let r={$type:"PegRule",name:n,definition:mC(t)};return t.expect(2),r})}function gC(e){switch(e.type){case"terminal":return`"${e.value}"`;case"nonterminal":return e.name;case"special":return e.text;default:return"(...)"}}function bC(e,t){let n=t[0];switch(e.$type){case"PegOrderedChoice":return ss(t);case"PegSequence":return rs(t);case"PegPrefix":return e.operator?Os(e.operator+gC(n)):n;case"PegSuffix":return e.operator?e.operator==="?"?mr(n):$r(n,e.operator==="+"?1:0):n;case"PegLiteral":return Lr(e.value);case"PegIdentifier":return ns(e.name);case"PegAny":return Os(e.dot);case"PegGroup":return n}}var rE=e=>is(e,bC);var mf=class{type="railroad";notation="railroad";title;accTitle;accDescr;rules=[];byName=new Map;setTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
108
+ `)}addRule(t){this.rules.push(t),this.byName.set(t.name,t)}getRule(t){return this.byName.get(t)}},yC=/^\s*railroad-(ebnf-|abnf-|peg-)?beta/i;function EC(e){let t=yC.exec(e);if(t===null)return;let n=t[1]?.toLowerCase();return n==="ebnf-"?"ebnf":n==="abnf-"?"abnf":n==="peg-"?"peg":"railroad"}function AC(e,t){switch(t){case"ebnf":{let n=qy(e);return[n,Qy(n)]}case"abnf":{let n=Gy(e);return[n,Yy(n)]}case"peg":{let n=nE(e);return[n,rE(n)]}default:{let n=Zy(e);return[n,Jy(n)]}}}function xC(e,t,n){let[r,o]=AC(t,n);e.notation=n,r.accDescr&&e.setAccDescription(r.accDescr),r.accTitle&&e.setAccTitle(r.accTitle),r.title&&e.setTitle(r.title);for(let s of o)e.addRule(s)}function sE(e,t){let n=EC(e);if(n===void 0)throw new Ge("No railroad diagram keyword found.","syntax",{type:"railroad"});let r=new mf;return t&&(r.title=t),xC(r,e,n),r}var gf=12,SC=6,_C=18,Gc=12,Jn=7;function vs(e,t,n,r){let o=e.railroad?.[t];return typeof o=="number"&&o>=0?Math.min(o,r):n}var wC=/[\n\r\t]/g;function Uc(e){return(e.includes("¶ß")?gt(e.replace(/&/g,"&amp;")):e).replace(wC,n=>n===`
109
+ `?"\\n":n==="\r"?"\\r":"\\t")}function Wc(e,t){for(let n=t,r=e.length-1;n<r;n++,r--){let o=e[n];e[n]=e[r],e[r]=o}}function yf(e){return Math.ceil(e/2)*2}function bf(e,t,n,r,o){let s=o.height/2,a=Math.max(yf(o.measurer.width(t,o.size,r)+2*o.padding),o.height);return{kind:e,width:a,up:s,down:s,kids:df,text:t,id:n,reach:0}}function RC(e,t){if(t===1/0&&e<=1)return"";let n=r=>Number.isFinite(r)?String(r):"∞";return e===t?n(e)+"×":t===1/0?"≥"+n(e)+"×":e===0?"≤"+n(t)+"×":n(e)+"–"+n(t)+"×"}function oE(e,t,n,r){return Math.max(e+t.down+r.sep+n.up,2*r.arc)}function iE(e,t){let n=Math.max(e.up+t.sep,2*t.arc);return{kind:5,width:e.width+4*t.arc,up:n,down:e.down,kids:[e],text:"",id:"",reach:n}}function TC(e,t,n=1/0){let r=new Map,o=[[e,n]];for(let s=0;n!==1/0&&s<o.length;s++){let[a,i]=o[s];r.set(a,i);let c=a.type==="choice"||a.type==="optional"?4*t.arc:a.type==="repetition"?(a.min===0?6:2)*t.arc:a.type==="sequence"?6*t.arc:0;for(let l of Fc(a))o.push([l,Math.max(40,i-c)])}return uf(e,Fc,(s,a)=>{let i=r.get(s)??1/0;switch(s.type){case"terminal":{let c=Uc(s.value);return bf(0,/^ +$/.test(c)?"␣".repeat(c.length):c,"",4,t)}case"nonterminal":return bf(1,Uc(s.name),s.name,0,t);case"special":return bf(2,"? "+Uc(s.text)+" ?","",2,t);case"sequence":{let c=Math.max(0,a.length-1)*t.gap,l=0,f=0;for(let _ of a)c+=_.width,l=Math.max(l,_.up),f=Math.max(f,_.down);let p={kind:3,width:c,up:l,down:f,kids:a,text:"",id:"",reach:0};if(c<=i||a.length<2)return p;let u=[],m=[],h=0,g=()=>{let _=0,S=0;for(let P of m)_=Math.max(_,P.up),S=Math.max(S,P.down);u.push({kind:3,width:h,up:_,down:S,kids:m,text:"",id:"",reach:0}),m=[],h=0};for(let _ of a)m.length&&h+t.gap+_.width>Math.max(40,i-6*t.arc)&&g(),h+=(m.length?t.gap:0)+_.width,m.push(_);if(g(),u.length<2)return p;let x=0,y=0;for(let _=0;_<u.length;_++)x=Math.max(x,u[_].width),_&&(y+=u[_-1].down+Math.max(t.sep,2*t.arc)+u[_].up);return{kind:7,width:x+6*t.arc,up:u[0].up,down:y+u[u.length-1].down,kids:u,text:"",id:"",reach:0}}case"choice":{let c=0,l=0;for(let p=0;p<a.length;p++)c=Math.max(c,a[p].width),p>0&&(l=oE(l,a[p-1],a[p],t));let f=a[a.length-1];return{kind:4,width:c+4*t.arc,up:a.length>0?a[0].up:0,down:f?l+f.down:0,kids:a,text:"",id:"",reach:0}}case"optional":return iE(a[0],t);case"repetition":{let{min:c,max:l}=s,f=a[0];if(c===1&&l===1)return f;let p=RC(c,l),u=Math.max(f.down+t.sep,2*t.arc),m=p===""?0:yf(t.measurer.width(p,Gc,0)),h={kind:6,width:Math.max(f.width,m)+2*t.arc,up:f.up,down:u+(p===""?Jn/2+1:Gc+6),kids:[f],text:p,id:"",reach:u};return c===0?iE(h,t):h}}})}function aE(e,t,n){return pn(n,r=>CC(e,t,n,r))}function CC(e,t,n,r){let o=n.fontSize??16,s=vs(t,"fontSize",0,200),a=s||Math.round(o*.875),i=s||o,c=vs(t,"padding",-1,200),l=Math.round(a*1.5),f={measurer:n.measurer??Je(n.fontFamily,n.fontFamilyMono),size:a,padding:c<0?12:c,height:yf(l+(c<0?9:2*c)),gap:Math.min(vs(t,"horizontalSeparation",16,500),r?12:1/0),sep:vs(t,"verticalSeparation",10,500),arc:Math.min(vs(t,"arcRadius",10,200),r?6:1/0)},p=t.railroad?.showMarkers===!1?0:vs(t,"markerRadius",4,50),u=vs(t,"strokeWidth",0,20),m=u>0?` stroke-width="${d(u)}"`:"",h=n.padding??8,{arc:g}=f,x=d(g),y=(X,V,O)=>`a${x},${x} 0 0 ${X} ${V}${x},${O}${x}`,_=y(1,"",""),S=y(0,"",""),P=y(0,"","-"),k=y(1,"","-"),w=y(0,"-",""),I=y(0,"-","-"),D=De(e.title,!1,f.measurer,o,r?Rt(n):4e3,1),U=D.height>0?D.height+16:0,M=Math.round(i*1.5),Q=a*.35,q=f.height/2,Y="",z="",R="",L=(X,V,O)=>{O>X&&(Y+=`M${d(X)},${d(V)}H${d(O)}`)},F=(X,V,O)=>{let v=[X],W=[V,O];for(;v.length>0;){let H=v.pop(),G=W.pop(),te=W.pop(),Z=H.kids,B=te+H.width;switch(H.kind){case 3:{let K=B;for(let ee=Z.length-1;ee>=0;ee--)K-=Z[ee].width,v.push(Z[ee]),W.push(K,G),ee>0&&L(K-f.gap,G,K),K-=f.gap;break}case 7:{let K=te+2*g,ee=v.length,ae=0;L(te,G,K);for(let J=0;J<Z.length;J++){let se=Z[J],me=G+ae;if(v.push(se),W.push(me,K),J+1<Z.length){let Ae=Z[J+1],de=ae+se.down+Math.max(f.sep,2*g)+Ae.up,oe=G+ae+se.down+Math.max(f.sep,2*g)/2;Y+=`M${d(K+se.width)},${d(me)}H${d(B-2*g)}V${d(oe)}H${d(te+g)}V${d(G+de)}H${d(K)}`,z+=`M${d(K-Jn)},${d(G+de-Jn/2)}l${Jn},${Jn/2}l${-Jn},${Jn/2}z`,ae=de}else Y+=`M${d(K+se.width)},${d(me)}H${d(B-g)}V${d(G)}H${d(B)}`}Wc(v,ee),Wc(W,2*ee);break}case 4:{let K=H.width-4*g,ee=te+g,ae=B-g,J=v.length,se=0;for(let me=0;me<Z.length;me++){let Ae=Z[me];me>0&&(se=oE(se,Z[me-1],Ae,f));let de=G+se,oe=te+2*g+(K-Ae.width)/2,ye=me===Z.length-1;me===0?(L(te,G,oe),L(oe+Ae.width,G,B)):Y+=(ye?`M${d(te)},${d(G)}${_}V${d(de-g)}`:`M${d(ee)},${d(de-g)}`)+S+(oe>ee+g?`H${d(oe)}`:"")+`M${d(oe+Ae.width)},${d(de)}`+(oe>ee+g?`H${d(ae-g)}`:"")+P+(ye?`V${d(G+g)}${k}`:""),v.push(Ae),W.push(de,oe)}Wc(v,J),Wc(W,2*J);break}case 5:{let K=Z[0],ee=te+2*g;L(te,G,ee),L(ee+K.width,G,B),Y+=`M${d(te)},${d(G)}${P}V${d(G-H.reach+g)}${k}H${d(B-2*g)}${_}V${d(G-g)}${S}`,v.push(K),W.push(ee,G);break}case 6:{let K=Z[0],ee=te+(H.width-K.width)/2,ae=G+H.reach,J=te+H.width/2;L(te,G,ee),L(ee+K.width,G,B),Y+=`M${d(te+g)},${d(G)}${w}V${d(ae-g)}${S}H${d(B-g)}${P}V${d(G+g)}${I}`,z+=`M${d(J-Jn/2)},${d(ae)}l${Jn},${-Jn/2}v${Jn}z`,H.text!==""&&(R+=`<text class="pele-edge-label pele-count" x="${d(J)}" y="${d(ae+Gc+3)}" font-size="${Gc}" fill="var(--_m)">${je(H.text)}</text>`),v.push(K),W.push(ee,G);break}default:{let K=H.text,ee=K.startsWith(" ")||K.endsWith(" ")||K.includes(" ")?' xml:space="preserve"':"",ae=`<rect x="${d(te)}" y="${d(G-q)}" width="${d(H.width)}" height="${d(f.height)}"`,J=`<text x="${d(te+H.width/2)}" y="${d(G+Q)}"${ee}`;H.kind===0?R+=`<g class="pele-node pele-terminal">${ae} rx="${d(q)}" fill="var(--_s)" stroke="var(--_b)"${m}/>${J} font-family="${Vi}">${je(K)}</text></g>`:H.kind===1?R+=`<g class="pele-node pele-nonterminal" data-id="${$e(H.id)}">${ae} rx="${Xe}" fill="var(--_bg)" stroke="var(--_b)"${m}/>${J}>${je(K)}</text></g>`:R+=`<g class="pele-node pele-special">${ae} rx="${Xe}" fill="var(--_bg)" stroke="var(--_b)" stroke-dasharray="4 3"${m}/>${J} font-style="italic"><tspan fill="var(--_m)">? </tspan>${je(K.slice(2,-2))}<tspan fill="var(--_m)"> ?</tspan></text></g>`}}}},E="",C=D.width,A=h+U,T=h+D.height;for(let X of e.rules){let V=TC(X.definition,f,r?Math.max(80,(n.maxWidth??320)-2*h-4*p-2*gf-1):1/0),O=Uc(X.name),v=A+M+SC+V.up,W=h+2*p,H=W+gf,G=H+V.width+gf;Y="",z="",R="",L(W,v,H),L(H+V.width,v,G),F(V,H,v);let te=p>0?`<circle class="pele-marker pele-start" cx="${d(h+p)}" cy="${d(v)}" r="${d(p)}" fill="var(--_l)"/><circle class="pele-marker pele-end" cx="${d(G+p)}" cy="${d(v)}" r="${d(p)}" fill="var(--_l)"/>`:"";E+=`<g class="pele-rule" data-id="${$e(X.name)}"><text class="pele-rule-name" x="${d(h)}" y="${d(A+M/2+i*.35)}" font-size="${d(i)}" font-weight="var(--_hw)" text-anchor="start">${je(O)}</text><path class="pele-edge pele-track" d="${Y}" fill="none" stroke="var(--_l)"${m}/>`+(z?`<path class="pele-marker" d="${z}" fill="var(--_l)"/>`:"")+te+R+"</g>",C=Math.max(C,G+2*p-h,f.measurer.width(O,i,1)),T=v+V.down,A=T+f.sep+_C}let b=Math.ceil(C+2*h),N=Math.ceil(T+h),$=Ie(D,b/2,h+D.height/2,' class="pele-title" font-weight="var(--_tw)"')+(E?`<g class="pele-rules" transform="translate(0.5,0.5)" font-size="${d(a)}" text-anchor="middle">${E}</g>`:"");return{svg:Ze("railroad",b,N,o,n,e,$),width:b,height:N,links:[]}}var cE={type:"railroad",parse:(e,t,n)=>sE(e,n),render:aE};var Ps={REQUIREMENT:"Requirement",FUNCTIONAL_REQUIREMENT:"Functional Requirement",INTERFACE_REQUIREMENT:"Interface Requirement",PERFORMANCE_REQUIREMENT:"Performance Requirement",PHYSICAL_REQUIREMENT:"Physical Requirement",DESIGN_CONSTRAINT:"Design Constraint"},Hc={LOW_RISK:"Low",MED_RISK:"Medium",HIGH_RISK:"High"},Mo={VERIFY_ANALYSIS:"Analysis",VERIFY_DEMONSTRATION:"Demonstration",VERIFY_INSPECTION:"Inspection",VERIFY_TEST:"Test"},gr={CONTAINS:"contains",COPIES:"copies",DERIVES:"derives",SATISFIES:"satisfies",VERIFIES:"verifies",REFINES:"refines",TRACES:"traces"},IC=1e6,Yc=class{type="requirement";direction="TB";requirements=new Map;elements=new Map;relations=[];classes=new Map;title;accTitle;accDescr;newId="";newText="";newRisk="";newVerifyMethod="";newElementType="";newDocRef="";styleCopies=0;copy(t,n){if(this.styleCopies+=n.length,this.styleCopies>IC)throw new Ge("Requirement diagram applies too many style declarations.","limit",{type:"requirement"});for(let r of n)t.push(r)}setDirection(t){this.direction=t}addRequirement(t,n){let r=this.requirements.get(t);return r===void 0&&(r={name:t,type:n,requirementId:this.newId,text:this.newText,risk:this.newRisk,verifyMethod:this.newVerifyMethod,cssStyles:[],classes:["default"]},this.requirements.set(t,r)),this.newId=this.newText=this.newRisk=this.newVerifyMethod="",r}setNewReqId(t){this.newId=t}setNewReqText(t){this.newText=t}setNewReqRisk(t){this.newRisk=t}setNewReqVerifyMethod(t){this.newVerifyMethod=t}addElement(t){let n=this.elements.get(t);return n===void 0&&(n={name:t,type:this.newElementType,docRef:this.newDocRef,cssStyles:[],classes:["default"]},this.elements.set(t,n)),this.newElementType=this.newDocRef="",n}setNewElementType(t){this.newElementType=t}setNewElementDocRef(t){this.newDocRef=t}addRelationship(t,n,r){this.relations.push({type:t,src:n,dst:r})}node(t){return this.requirements.get(t)??this.elements.get(t)}setCssStyle(t,n){for(let r of t){let o=this.node(r);if(!n||!o)return;for(let s of n)this.copy(o.cssStyles,s.includes(",")?s.split(","):[s])}}setClass(t,n){for(let r of t){let o=this.node(r);if(o)for(let s of n){o.classes.push(s);let a=this.classes.get(s)?.styles;a&&this.copy(o.cssStyles,a)}}}defineClass(t,n){for(let r of t){let o=this.classes.get(r);o===void 0&&(o={id:r,styles:[],textStyles:[]},this.classes.set(r,o));for(let a of n)a.includes("color")&&o.textStyles.push(a.replace("fill","bgFill")),o.styles.push(a);let s=n.flatMap(a=>a.split(","));for(let a of this.requirements.values())a.classes.includes(r)&&this.copy(a.cssStyles,s);for(let a of this.elements.values())a.classes.includes(r)&&this.copy(a.cssStyles,s)}}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
110
+ `)}};var Ef=["$end","INVALID","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","direction_tb","direction_bt","direction_rl","direction_lr","NEWLINE","EOF","RD","STRUCT_START","STRUCT_STOP","STYLE_SEPARATOR","COLONSEP","ID","TEXT","RISK","VERIFYMTHD","REQUIREMENT","FUNCTIONAL_REQUIREMENT","INTERFACE_REQUIREMENT","PERFORMANCE_REQUIREMENT","PHYSICAL_REQUIREMENT","DESIGN_CONSTRAINT","LOW_RISK","MED_RISK","HIGH_RISK","VERIFY_ANALYSIS","VERIFY_DEMONSTRATION","VERIFY_INSPECTION","VERIFY_TEST","ELEMENT","CONTAINS","COPIES","DERIVES","SATISFIES","VERIFIES","REFINES","TRACES","TYPE","DOCREF","STYLE","CLASSDEF","CLASS","ALPHA","COLON","SEMICOLON","PERCENT","MINUS","BRKT","END_ARROW_L","END_ARROW_R","LINE","qString","unqString","COMMA"],lE=new Map([["requirementdiagram",14],["id",19],["text",20],["risk",21],["verifymethod",22],["requirement",23],["functionalrequirement",24],["interfacerequirement",25],["performancerequirement",26],["physicalrequirement",27],["designconstraint",28],["low",29],["medium",30],["high",31],["analysis",32],["demonstration",33],["inspection",34],["test",35],["element",36],["contains",37],["copies",38],["derives",39],["satisfies",40],["verifies",41],["refines",42],["traces",43],["type",44],["docref",45],["style",46],["classdef",47],["class",48]]);var MC=/accTitle\s*:\s*/iy,kC=/accDescr\s*:\s*/iy,LC=/accDescr\s*\{\s*/iy,Kc=/direction\s+(?:(TB)|(BT)|(RL)|LR)/gi,Af=/[\n\r\u2028\u2029]/g,$C=22,dE=new Uint8Array(128);for(let e of`:,\r
111
+ {<>-=`)dE[e.charCodeAt(0)]=1;function uE(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=[[],[],[],[]],l=[[],[],[],[]],f=[0,0,0,0],p=!1,u=-1;Kc.lastIndex=0;for(let w=Kc.exec(e);w!==null;w=Kc.exec(e)){let I=w[1]!==void 0?0:w[2]!==void 0?1:w[3]!==void 0?2:3;c[I].push(w.index),l[I].push(Kc.lastIndex),p=!0}let m=(w,I,D)=>{n.push(w),r.push(e.slice(I,D)),o.push(I),i=D},h=w=>{s.push(a),a=w},g=()=>{s.length>0&&(a=s.pop())},x=(w,I)=>(w.lastIndex=I,w.test(e)?w.lastIndex:-1),y=w=>{let I=e.indexOf(`
112
+ `,w);return I===-1?t:I},_=()=>{if(u<i){Af.lastIndex=i,u=Af.test(e)?Af.lastIndex-1:t;for(let w=0;w<4;w++){let I=c[w],D=f[w];for(;D<I.length&&I[D]<=u;)D++;f[w]=D}}for(let w=0;w<4;w++){let I=f[w]-1;if(I>=0&&c[w][I]>=i)return m(8+w,i,y(l[w][I])),!0}return!1},S=w=>{let I=w|32;if(I===116&&e.slice(i+1,i+5).toLowerCase()==="itle"&&Be(e.charCodeAt(i+5))){let D=i+6;for(;D<t;){let U=e.charCodeAt(D);if(U===35||U===10||U===59)break;D++}if(D>i+6)return m(2,i,D),!0}if(I===97&&(e.charCodeAt(i+1)|32)===99&&(e.charCodeAt(i+2)|32)===99){let D;if((D=x(MC,i))>=0)return h(3),m(3,i,D),!0;if((D=x(kC,i))>=0)return h(4),m(5,i,D),!0;if((D=x(LC,i))>=0)return h(5),i=D,!0}if(p&&!ps(w)&&_())return!0;if(w===10||w===13&&e.charCodeAt(i+1)===10){let D=i;for(;D<t;){let U=e.charCodeAt(D);if(U===10)D++;else if(U===13&&e.charCodeAt(D+1)===10)D+=2;else break}return m(12,i,D),!0}if(Be(w)){for(i++;i<t&&Be(e.charCodeAt(i));)i++;return!0}if(w===35||w===37)return i=y(i),!0;if(Qe(w)){let D=i+1;for(;D<t&&Qe(e.charCodeAt(D));)D++;if(D-i<=$C){let U=lE.get(e.slice(i,D).toLowerCase());if(U!==void 0)return(U===46||U===47||U===48)&&h(2),m(U,i,D),!0}for(;D<t;){let U=e.charCodeAt(D);if(U<128&&dE[U]===1)break;D++}return n.push(59),r.push(e.slice(i,D).trim()),o.push(i),i=D,!0}switch(w){case 123:return m(15,i,i+1),!0;case 125:return m(16,i,i+1),!0;case 58:return e.charCodeAt(i+1)===58&&e.charCodeAt(i+2)===58?m(17,i,i+3):m(18,i,i+1),!0;case 60:return e.charCodeAt(i+1)!==45?!1:(m(55,i,i+2),!0);case 45:return e.charCodeAt(i+1)===62?m(56,i,i+2):m(57,i,i+1),!0;case 34:return h(1),i++,!0;case 44:return m(60,i,i+1),!0}return!1},P=w=>{if(Qe(w)){let I=i+1;for(;I<t&&Qe(e.charCodeAt(I));)I++;return m(49,i,I),!0}switch(w){case 58:return m(50,i,i+1),!0;case 59:return m(51,i,i+1),!0;case 37:return m(52,i,i+1),!0;case 45:return m(53,i,i+1),!0;case 35:return m(54,i,i+1),!0;case 32:return i++,!0;case 34:return h(1),i++,!0;case 10:return g(),i++,!0;case 44:return m(60,i,i+1),!0}return!1};for(;i<t;){let w=e.charCodeAt(i),I=!0;switch(a){case 0:I=S(w);break;case 2:I=P(w);break;case 1:if(w===34)g(),i++;else{let D=e.indexOf('"',i);m(58,i,D===-1?t:D)}break;case 3:g(),m(4,i,y(i));break;case 4:g(),m(6,i,y(i));break;case 5:if(w===125)g(),i++;else{let D=e.indexOf("}",i);m(7,i,D===-1?t:D)}break}if(!I)return n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o}}let k=a===0?13:a===1?58:a===3?4:a===4?6:a===5?7:-1;return k!==-1&&m(k,t,t),m(0,t,t),{types:n,texts:r,starts:o}}var DC=[Ps.REQUIREMENT,Ps.FUNCTIONAL_REQUIREMENT,Ps.INTERFACE_REQUIREMENT,Ps.PERFORMANCE_REQUIREMENT,Ps.PHYSICAL_REQUIREMENT,Ps.DESIGN_CONSTRAINT,Hc.LOW_RISK,Hc.MED_RISK,Hc.HIGH_RISK,Mo.VERIFY_ANALYSIS,Mo.VERIFY_DEMONSTRATION,Mo.VERIFY_INSPECTION,Mo.VERIFY_TEST,"",gr.CONTAINS,gr.COPIES,gr.DERIVES,gr.SATISFIES,gr.VERIFIES,gr.REFINES,gr.TRACES];function fE(e){return e===49||e===50||e===54||e===53||e===51}function pE(e,t){let{types:n,texts:r,starts:o}=uE(e),s=0,a=[],i=[],c=(y,_=y,...S)=>{let P=n[s];if(P===1)throw it("requirement",e,o[s],"",!0);for(let w=_;w>=y;w--)S.unshift(w);let k=S.map(w=>`'${Ef[w]}'`).join(", ");throw it("requirement",e,o[s],`Expecting ${k}, got '${Ef[P]}'`)},l=y=>(n[s]!==y&&c(y),r[s++]),f=(y,_)=>{let S=n[s];return(S<y||S>_)&&c(y,_),s++,DC[S-23]},p=()=>{let y=n[s];return y!==59&&y!==58&&c(58,59),r[s++]},u=()=>{let y=n[s];if(y===3)s++,t.setAccTitle(l(4).trim());else if(y===5)s++,t.setAccDescription(l(6).trim());else if(y===7)t.setAccDescription(r[s++].trim());else return!1;return!0},m=()=>{let y=[];for(;;){let _=n[s];if(_!==49&&_!==59&&_!==58&&c(58,59,49),y.push(r[s++]),n[s]!==60)return y;s++}},h=()=>{let y=[];for(;;){fE(n[s])||c(49,51,53,54);let _=r[s++];for(;fE(n[s]);)_+=r[s++];if(y.push(_),n[s]!==60)return y;s++}},g=()=>{let y;return n[s]===17?(s++,y=m(),l(15)):n[s]===15?s++:c(15,15,17),l(12),y},x=y=>{for(a.length=0,i.length=0;;){let _=n[s];if(_===16){s++;break}if(_===12){s++;continue}(y?_<19||_>22:_!==44&&_!==45)&&(y&&c(19,22,12,16),c(44,45,12,16)),s++,l(18),i.push(_===21?f(29,31):_===22?f(32,35):p()),a.push(_),l(12)}for(let _=a.length-1;_>=0;_--){let S=i[_];switch(a[_]){case 19:t.setNewReqId(S);break;case 20:t.setNewReqText(S);break;case 21:t.setNewReqRisk(S);break;case 22:t.setNewReqVerifyMethod(S);break;case 44:t.setNewElementType(S);break;default:t.setNewElementDocRef(S)}}};for(;u();)n[s]===12&&s++;for(n[s]!==14&&c(14,14,3,5,7),s++,l(12);;){let y=n[s];if(y===13)return;if(y===12)s++;else{if(u())continue;if(y>=8&&y<=11)s++,t.setDirection(y===8?"TB":y===9?"BT":y===10?"RL":"LR");else if(y>=23&&y<=28){let _=f(23,28),S=p(),P=g();x(!0),t.addRequirement(S,_),P&&t.setClass([S],P)}else if(y===36){s++;let _=p(),S=g();x(!1),t.addElement(_),S&&t.setClass([_],S)}else if(y===46){s++;let _=m();t.setCssStyle(_,h())}else if(y===47){s++;let _=m();t.defineClass(_,h())}else if(y===48){s++;let _=m();t.setClass(_,m())}else if(y===59||y===58){let _=r[s++],S=n[s];if(S===17)s++,t.setClass([_],m());else if(S===55||S===57){s++;let P=f(37,43);l(S===57?56:57);let k=p();S===57?t.addRelationship(P,_,k):t.addRelationship(P,k,_)}else c(17,17,55,57)}else c(12,13,3,5,7,8,9,10,11,23,24,25,26,27,28,36,47,48,46,59,58)}}}function hE(e){let t=[];for(let o of e.requirements.values())t.push({id:o.name,requirement:o,element:void 0,cssStyles:o.cssStyles,cssClasses:o.classes.join(" ")});for(let o of e.elements.values())t.push({id:o.name,requirement:void 0,element:o,cssStyles:o.cssStyles,cssClasses:o.classes.join(" ")});let n=o=>e.requirements.has(o)||e.elements.has(o)?o:void 0,r=e.relations.map((o,s)=>({id:`${o.src}-${o.dst}-${s}`,start:n(o.src),end:n(o.dst),type:o.type,contains:o.type===gr.CONTAINS}));return{nodes:t,edges:r,direction:e.direction}}var OC=40,vC=16,PC=56,zc=14,ko=10,xf=2,mE=12,BC=120,FC=280,WC=240,Sf=26,EE=6,gE=9,Vc=4.5,UC=28,GC=14;function jc(e,t,n){if(t===0||e.lines.length===0)return e;let r=0,o=[],s=e.lines.map(a=>{let i=0,c=a.map(l=>{let f=l.style|t,p=l.icon!==void 0?l.width:n.width(l.text,e.size,f);return i+=p,{...l,style:f,width:p}});return o.push(i),i>r&&(r=i),c});return{...e,lines:s,widths:o,width:r}}function bE(e,t,n,r){let o=n+e.lineHeight/2+e.size*.35,s=Er(e),a="";for(let i of e.lines){let c=!0;for(let l of i)l.icon!==void 0||l.text===""||(a+=`<tspan${c?` x="${d(t)}" y="${d(o)}"`:""}${rr(l.style&~s)}>${je(l.text)}</tspan>`,c=!1);o+=e.lineHeight}return a===""?"":`<text${Kn(r,s)} text-anchor="start" xml:space="preserve">${a}</text>`}function YC(e,t,n,r){let o=EE,s=e-n*o,a=t-r*o;return`<circle class="pele-marker" cx="${d(s)}" cy="${d(a)}" r="${o}"/><path class="pele-marker" d="M${d(s-n*o)},${d(a-r*o)}L${d(s+n*o)},${d(a+r*o)}M${d(s+r*o)},${d(a-n*o)}L${d(s-r*o)},${d(a+n*o)}"/>`}function HC(e,t,n,r){let o=e-n*gE,s=t-r*gE;return`<path class="pele-marker" d="M${d(o-r*Vc)},${d(s+n*Vc)}L${d(e)},${d(t)}L${d(o+r*Vc)},${d(s-n*Vc)}" stroke-linejoin="round"/>`}function KC(e,t,n){let r=new Map;for(let o of t){let s=o.route;if(!(o.src===o.dst||s.length<6))for(let a of[0,s.length-3]){let i=a===0?o.src:o.dst,c=e[i],l=s[a]-c.x,f=s[a+1]-c.y,p=a===0?3:a-3,u;if(Math.abs(Math.abs(f)-c.h/2)<.5)u=f<0?0:2;else if(Math.abs(Math.abs(l)-c.w/2)<.5)u=l<0?3:1;else continue;let m=i*4+u,h={route:s,at:a,toward:s[u%2===0?p:p+1]},g=r.get(m);g?g.push(h):r.set(m,[h])}}for(let[o,s]of r){if(s.length<2)continue;let a=o>>2,i=o%2===1,c=(i?n[a].h:n[a].w)-2*GC,l=Math.max(0,Math.min(UC,c/(s.length-1)));s.sort((f,p)=>f.toward-p.toward);for(let f=0;f<s.length;f++){let p=(f-(s.length-1)/2)*l;i?s[f].route[s[f].at+1]=e[a].y+p:s[f].route[s[f].at]=e[a].x+p}}}function AE(e,t,n){return _n(e.direction)?Nt(n,r=>yE(e,t,n,r)):yE(e,t,n,!1)}function yE(e,t,n,r){let o=hE(e),s=n.fontSize??16,a=Math.round(s*.875),i=n.measurer??Je(n.fontFamily),c=n.padding??8,l=new Map,f=[],p=[];for(let z of o.nodes){let R=At(z.cssStyles),L=(R.bold?1:0)|(R.italic?2:0),F=R.fontSize??s,E=R.fontSize??a,C=z.requirement,A=z.element,T=jc(De(`«${C?C.type:"Element"}»`,!1,i,E,4e3),L,i),b=jc(De(z.id,!0,i,F,FC),L|1,i),N=C?[["ID",C.requirementId],["Text",C.text],["Risk",C.risk],["Verification",C.verifyMethod]]:[["Type",A.type],["Doc Ref",A.docRef]],$=[],X=0,V=0,O=0;for(let[G,te]of N){if(!te)continue;let Z=jc(De(G,!1,i,E,4e3),L,i),B=jc(De(te,!0,i,E,WC),L,i),K=Math.max(Z.height,B.height);$.push({key:Z,value:B,height:K}),X=Math.max(X,Z.width),V=Math.max(V,B.width),O+=K+xf}$.length>0&&(O+=2*ko-xf);let v=2*ko+T.height+b.height,W=Math.max(BC,Math.max(T.width,b.width)+2*zc,$.length>0?X+mE+V+2*zc:0);l.has(z.id)||l.set(z.id,f.length);let H=$t(W,v+O);H.seq=f.length,f.push({node:z,style:R,kind:T,name:b,rows:$,keyWidth:X,headHeight:v,w:W,h:v+O}),p.push(H)}let u=r?"TB":tn(o.direction),m=u==="LR"||u==="RL",h=[],g=[],x=[];for(let z of o.edges){let R=z.start===void 0?void 0:l.get(z.start),L=z.end===void 0?void 0:l.get(z.end);if(R===void 0||L===void 0)continue;let F=De(`«${z.type}»`,!1,i,a,4e3);R===L&&(m?p[R].h+=2*(Sf+F.height+8):p[R].w+=2*(Sf+F.width+12)),x.push(z),g.push(F),h.push({src:R,dst:L,minlen:1,labelW:F.width+12,labelH:F.height+4,route:[],labelX:0,labelY:0})}let y=Sn(p,h,u,{nodeSep:OC,edgeSep:vC,rankSep:PC,portSep:20});KC(p,h,f);let _=De(e.title,!1,i,s,4e3,1),S=_.height>0?_.height+12:0,P=Math.max(y.width,_.width),k=c+(P-y.width)/2,w=c+S,I=Math.ceil(P+2*c),D=Math.ceil(y.height+S+2*c),U="";for(let z=0;z<f.length;z++){let R=f[z],{w:L,h:F,style:E}=R,C=-L/2,A=-F/2,T=`<rect x="${d(C)}" y="${d(A)}" width="${d(L)}" height="${d(F)}" rx="${Xe}" fill="var(--_s)" stroke="var(--_b)"${E.shape}/>`+Ie(R.kind,0,A+ko+R.kind.height/2,` class="pele-stereotype" font-size="${R.kind.size}" fill="var(--_m)"${E.text}`)+Ie(R.name,0,A+ko+R.kind.height+R.name.height/2,` class="pele-label" font-size="${R.name.size}" font-weight="var(--_hw)"${E.text}`);if(R.rows.length>0){let b=A+R.headHeight;T+=`<path class="pele-divider" d="M${d(C)},${d(b)}H${d(-C)}" stroke="var(--_b)"${E.line}/>`;let N=b+ko,$="";for(let X of R.rows)$+=bE(X.key,C+zc,N,` class="pele-field" fill="var(--_m)"${E.text}`)+bE(X.value,C+zc+R.keyWidth+mE,N,` class="pele-value"${E.text}`),N+=X.height+xf;T+=`<g class="pele-fields" font-size="${R.rows[0].key.size}">${$}</g>`}U+=`<g class="pele-node ${R.node.requirement?"pele-requirement":"pele-element"}${wt(R.node.cssClasses.replace(/^default\s?/,""))}" data-id="${$e(R.node.id)}" transform="translate(${d(p[z].x+k)},${d(p[z].y+w)})">${T}</g>`}let M="",Q="",q=new Map;for(let z=0;z<h.length;z++){let R=h[z],L=x[z],F=g[z],E=L.contains?2*EE:0,C,A=R.labelX+k,T=R.labelY+w;if(R.src===R.dst){let b=f[R.src],N=p[R.src].x+k,$=p[R.src].y+w,X=q.get(R.src)??0;q.set(R.src,X+1);let V=(m?b.w:b.h)/2,O=Math.min(V-4,12+X*6),v=Sf+X*8,W=(G,te)=>m?`${d(N+te)},${d($+b.h/2+G)}`:`${d(N+b.w/2+G)},${d($+te)}`,H=v/.75;C={d:`M${W(E,-O)}C${W(H,-O)} ${W(H,O)} ${W(0,O)}`,sx:m?N-O:N+b.w/2,sy:m?$+b.h/2:$-O,sdx:m?0:-1,sdy:m?-1:0,ex:m?N+O:N+b.w/2,ey:m?$+b.h/2:$+O,edx:m?0:-1,edy:m?-1:0},m?(A=N,T=$+b.h/2+v+4+R.labelH/2):(A=N+b.w/2+v+4+R.labelW/2,T=$)}else{let b=R.route.slice();for(let N=0;N<b.length;N+=3)b[N]+=k,b[N+1]+=w;C=yn(b,void 0,E,0)}M+=`<g class="pele-edge pele-relationship-${L.contains?"contains":"arrow"}" data-id="${$e(L.id)}"><path d="${C.d}"${L.contains?"":' stroke-dasharray="5 4"'}/>`+(L.contains?YC(C.sx,C.sy,C.sdx,C.sdy):HC(C.ex,C.ey,C.edx,C.edy))+"</g>",Q+=nn(L.id,F,A,T,"")}return{svg:Ze("requirement",I,D,s,n,e,Ie(_,I/2,c+_.height/2,' class="pele-title" font-weight="var(--_tw)"')+(M?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${M}</g>`:"")+(Q?`<g class="pele-edge-labels" font-size="${a}" fill="var(--_m)">${Q}</g>`:"")+`<g class="pele-nodes">${U}</g>`),width:I,height:D,links:[]}}var xE={type:"requirement",parse(e,t,n){let r=new Yc;return n&&(r.title=n),pE(e,r),r},render:AE};var Xc=class{type="sankey";nodes=[];links=[];title;accTitle;accDescr;lookup=new Map;findOrCreateNode(t){let n=this.lookup.get(t);return n===void 0&&(n={id:t,index:this.nodes.length},this.lookup.set(t,n),this.nodes.push(n)),n}addLink(t,n,r){this.links.push({source:t,target:n,value:r})}};var qc=["$end","STUCK","SANKEY","NEWLINE","COMMA","DQUOTE","NON_ESCAPED_TEXT","ESCAPED_TEXT","EOF"];function SE(e){return e>=32&&e<=126&&e!==34&&e!==44}function _E(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=(f,p,u)=>{n.push(f),r.push(e.slice(p,u)),o.push(p),i=u},l=f=>e.slice(i,i+f.length).toLowerCase()===f&&!Qe(e.charCodeAt(i+f.length));for(;i<t;){let f=e.charCodeAt(i),p=i,u=i;if(a===2){if(f===34&&e.charCodeAt(i+1)!==34){s.length>0&&(a=s.pop()),c(5,i,i+1);continue}for(;u<t;){let m=e.charCodeAt(u);if(SE(m)||m===44||m===13||m===10)u++;else if(m===34&&e.charCodeAt(u+1)===34)u+=2;else break}c(7,i,u)}else{if(a===0&&(f|32)===115){let m=l("sankey-beta")?11:l("sankey")?6:0;if(m>0){s.push(a),a=1,c(2,i,i+m);continue}}if(f===10||f===13&&e.charCodeAt(i+1)===10){c(3,i,f===10?i+1:i+2);continue}if(f===44){c(4,i,i+1);continue}if(f===34){s.push(a),a=2,c(5,i,i+1);continue}for(;u<t&&SE(e.charCodeAt(u));)u++;c(6,i,u)}if(u===p)return c(1,i,i),{types:n,texts:r,starts:o}}return c(a===2?7:8,t,t),c(0,t,t),{types:n,texts:r,starts:o}}var zC=/[\n\r]+/g;function wE(e){return e===10||e===13?!1:e<128?e===32||e===9||e===11||e===12:e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function RE(e){let t=0,n=e.length;for(;t<n&&wE(e.charCodeAt(t));)t++;for(;n>t&&wE(e.charCodeAt(n-1));)n--;return e.slice(t,n).replace(zC,`
113
+ `).trim()}function TE(e,t){let{types:n,texts:r,starts:o}=_E(e),s=0,a=f=>{let p=n[s],u=p===1?qc[n[s-1]]:qc[p];throw it("sankey",e,o[s],`Expecting ${f}, got '${u}'`)},i=(f,p="")=>{n[s]!==f&&a(`'${qc[f]}'${p}`),s++},c=()=>{if(n[s]===6)return r[s++];n[s]!==5&&a("'DQUOTE', 'NON_ESCAPED_TEXT'"),s++,n[s]!==7&&a("'ESCAPED_TEXT'");let f=r[s++];return i(5),f},l=()=>c().trim().replaceAll('""','"');for(i(2),i(3);;){let f=l();i(4,", 'NEWLINE', 'EOF'");let p=l();i(4,", 'NEWLINE', 'EOF'");let u=c(),m=t.findOrCreateNode(f),h=t.findOrCreateNode(p);if(t.addLink(m,h,parseFloat(u.trim())),n[s]!==3)break;s++}n[s]===8&&s++,n[s]!==0&&a("'NEWLINE', 'EOF'")}var VC=6;function _f(e,t){if(e.length>8){e.sort(t);return}for(let n=1;n<e.length;n++){let r=e[n],o=n-1;for(;o>=0&&t(e[o],r)>0;)e[o+1]=e[o],o--;e[o+1]=r}}function CE(e,t){let n=e.nodes.length,r=e.links.map(F=>({source:F.source.index,target:F.target.index,value:Number.isFinite(F.value)&&F.value>0?F.value:0,thickness:0,sourceY:0,targetY:0})),o=[],s=[];for(let F=0;F<n;F++)o.push([]),s.push([]);r.forEach((F,E)=>{o[F.source].push(E),s[F.target].push(E)});let a=new Int32Array(n),i=new Int32Array(n),c=[];for(let F=0;F<n;F++)i[F]=s[F].length,i[F]===0&&c.push(F);for(let F=0;F<c.length;F++){let E=c[F];for(let C of o[E]){let A=r[C].target;a[A]<a[E]+1&&(a[A]=a[E]+1),--i[A]===0&&c.push(A)}}if(c.length<n){let F=0;for(;i[F]===0;)F++;let E=new Uint8Array(n);for(;E[F]===0;){E[F]=1;for(let C of s[F])if(i[r[C].source]>0){F=r[C].source;break}}throw new Ge(`Sankey diagrams cannot have circular links, and "${e.nodes[F].id}" is part of one.`,"semantic",{type:"sankey"})}let l=1;for(let F=0;F<n;F++)a[F]+1>l&&(l=a[F]+1);let f=new Int32Array(n);for(let F=n-1;F>=0;F--){let E=c[F];for(let C of o[E])f[E]<f[r[C].target]+1&&(f[E]=f[r[C].target]+1)}let p=0;for(let F of r)F.value>p&&(p=F.value);let u=p>0?1/p:0,m=[],h=new Float64Array(n),g=[];for(let F=0;F<l;F++)g.push([]);let x=l>1?(t.width-t.nodeWidth)/(l-1):0;for(let F=0;F<n;F++){let E;if(t.alignment==="left")E=a[F];else if(t.alignment==="right")E=l-1-f[F];else if(t.alignment==="center"){if(E=a[F],s[F].length===0&&o[F].length>0){E=l;for(let N of o[F])a[r[N].target]-1<E&&(E=a[r[N].target]-1)}}else E=o[F].length>0?a[F]:l-1;let C=0,A=0,T=0,b=0;for(let N of s[F])C+=r[N].value*u,T+=r[N].value;for(let N of o[F])A+=r[N].value*u,b+=r[N].value;h[F]=Math.max(C,A),m.push({layer:E,value:Math.max(T,b),x:E*x,y:0,height:0}),g[E].push(F)}let y=1;for(let F of g)F.length>y&&(y=F.length);let _=y>1?Math.min(t.nodePadding,t.height/(y-1)):t.nodePadding,S=1/0;for(let F of g){let E=0;for(let C of F)E+=h[C];E>0&&(S=Math.min(S,(t.height-(F.length-1)*_)/E))}(!Number.isFinite(S)||S<0)&&(S=0);let P=Math.max(0,t.labelHeight-_),k=F=>{for(let E of g){let C=(E.length-1)*_;for(let A of E)C+=Math.max(h[A]*F,P);if(C>t.height+1e-6)return!1}return!0};if(P>0&&!k(S))if(k(0)){let F=0;for(let E=0;E<40;E++){let C=(F+S)/2;k(C)?F=C:S=C}S=F}else P=0;let w=new Float64Array(n);for(let F of r)F.thickness=F.value*u*S;for(let F of g){let E=0;for(let A of F)m[A].height=h[A]*S,w[A]=Math.max(0,P-m[A].height)/2,m[A].y=E+w[A],E+=m[A].height+2*w[A]+_;let C=(t.height-E+_)/(F.length+1);F.forEach((A,T)=>m[A].y+=C*(T+1))}let I=F=>m[F].y+m[F].height/2,D=new Float64Array(r.length),U=new Float64Array(r.length),M=(F,E)=>I(r[F].target)-I(r[E].target)||F-E,Q=(F,E)=>I(r[F].source)-I(r[E].source)||F-E,q=(F,E)=>I(F)-I(E)||F-E,Y=F=>{let E=0;_f(o[F],M);for(let C of o[F])D[C]=E+r[C].thickness/2,E+=r[C].thickness},z=F=>{let E=0;_f(s[F],Q);for(let C of s[F])U[C]=E+r[C].thickness/2,E+=r[C].thickness},R=()=>{for(let F=0;F<n;F++)Y(F),z(F)},L=(F,E,C)=>{for(let T of F){let b=C?s[T]:o[T];if(b.length===0)continue;C?z(T):Y(T);let N=0,$=0,X=0;for(let O of b){let v=C?m[r[O].source].y+D[O]-U[O]:m[r[O].target].y+U[O]-D[O];N+=v*r[O].thickness,$+=r[O].thickness,X+=I(C?r[O].source:r[O].target)-m[T].height/2}let V=$>0?N/$:X/b.length;m[T].y+=(V-m[T].y)*E}_f(F,q);let A=0;for(let T of F)m[T].y-w[T]<A&&(m[T].y=A+w[T]),A=m[T].y+m[T].height+w[T]+_;A=t.height;for(let T=F.length-1;T>=0;T--){let b=F[T];m[b].y+m[b].height+w[b]>A&&(m[b].y=A-m[b].height-w[b]),A=m[b].y-w[b]-_}};R();for(let F=0;F<VC;F++){let E=Math.pow(.99,F);for(let C=l-2;C>=0;C--)L(g[C],E,!1);R();for(let C=1;C<l;C++)L(g[C],E,!0);R()}for(let F=0;F<r.length;F++)r[F].sourceY=m[r[F].source].y+D[F],r[F].targetY=m[r[F].target].y+U[F];return{nodes:m,links:r}}var IE=6,jC=15;function LE(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Qc(e,t,n,r,o){let s=e[t];return typeof s=="number"&&s>=r?Math.min(s,o):n}function NE(e,t){let n=e[t];return typeof n=="string"||typeof n=="number"&&Number.isFinite(n)?String(n):""}function ME(e){return Math.abs(e)<1e15?Math.round(e*100)/100:e}function kE(e){return typeof e=="string"?At([`fill:${e}`]).shape:""}function $E(e,t,n){let r=LE(t.sankey)?t.sankey:{};return Fr(n,Qc(r,"width",600,1,1e4),160,o=>XC(e,r,n,o))}function XC(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.875),a=n.measurer??Je(n.fontFamily),i=n.padding??8,c=Qc(t,"height",400,1,1e4),l=Math.min(Qc(t,"nodeWidth",10,1,200),r),f=t.showValues!==!1,p=NE(t,"prefix"),u=NE(t,"suffix"),m=t.labelStyle==="outlined",h=t.nodeAlignment==="left"||t.nodeAlignment==="right"||t.nodeAlignment==="center"?t.nodeAlignment:"justify",g=typeof t.linkColor=="string"?t.linkColor:"gradient",{nodes:x,links:y}=CE(e,{width:r,height:c,nodeWidth:l,nodePadding:Qc(t,"nodePadding",12,0,200)+(f?jC:0),labelHeight:s*1.15,alignment:h}),_=new Map;if(LE(t.nodeColors))for(let[b,N]of Object.entries(t.nodeColors)){let $=kE(N);$&&_.set(b,$)}let S=b=>_.get(e.nodes[b].id)??"",P=0,k=0;x.forEach(b=>{b.value>k&&(k=b.value,P=b.layer)});let w=0,I=r,D=0,U=c,M="",Q="";x.forEach((b,N)=>{let $=e.nodes[N].id,X=Math.max(b.height,1);Q+=`<rect class="pele-sankey-node" data-id="${$e($)}" x="${d(b.x)}" y="${d(b.y)}" width="${d(l)}" height="${d(X)}" rx="${d(Math.min(2,X/2))}" fill="${ct(N)}"${S(N)}/>`;let V=f?`${p}${ME(b.value)}${u}`:"",O=m?b.layer>=P:b.x<r/2,v=a.width(V?`${$} ${V}`:$,s,0),W=O?b.x+l+IE:b.x-IE,H=b.y+b.height/2;w=Math.min(w,O?W:W-v),I=Math.max(I,O?W+v:W),D=Math.min(D,H-s*.75),U=Math.max(U,H+s*.75);let G=` x="${d(W)}" y="${d(H+s*.35)}" text-anchor="${O?"start":"end"}"`,te=je($)+(V?` <tspan class="pele-sankey-value" fill="var(--_m)">${je(V)}</tspan>`:"");M+=`<g class="pele-label" data-id="${$e($)}">`+(m?`<text${G} fill="none" stroke="var(--_bg)" stroke-width="3" stroke-linejoin="round">${je($)}${V?" "+je(V):""}</text>`:"")+`<text${G}>${te}</text></g>`});let q=g==="gradient"||g==="source"||g==="target"?"":kE(g),Y="";for(let b of y){let N=g==="target"?b.target:b.source,$=Math.max(b.thickness,1)/2,X=x[b.source].x+l,V=x[b.target].x,O=d((X+V)/2),v=$e(e.nodes[b.source].id),W=$e(e.nodes[b.target].id);Y+=`<path class="pele-sankey-link" data-id="${v}-&gt;${W}" d="M${d(X)},${d(b.sourceY-$)}C${O},${d(b.sourceY-$)} ${O},${d(b.targetY-$)} ${d(V)},${d(b.targetY-$)}L${d(V)},${d(b.targetY+$)}C${O},${d(b.targetY+$)} ${O},${d(b.sourceY+$)} ${d(X)},${d(b.sourceY+$)}Z" fill="${ct(N)}"${q||S(N)}><title>${v} → ${W}: ${$e(p)}${ME(b.value)}${$e(u)}</title></path>`}let z=De(e.title,!1,a,o,Rt(n),1),R=z.height>0?z.height+12:0,L=Math.max(I-w,z.width),F=i-w+(L-(I-w))/2,E=i+R-D,C=Math.ceil(L+2*i),A=Math.ceil(U-D+R+2*i);return{svg:Ze("sankey",C,A,o,n,e,Ie(z,C/2,i+z.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(F)},${d(E)})"><g class="pele-sankey-links" fill-opacity="0.4">${Y}</g><g class="pele-sankey-nodes">${Q}</g><g class="pele-labels" font-size="${s}">${M}</g></g>`),width:C,height:A,links:[]}}var DE={type:"sankey",parse(e,t,n){let r=new Xc;return n&&(r.title=n),TE(RE(e),r),r},render:$E};var qC="aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen transparent currentcolor inherit initial unset revert accentcolor accentcolortext activetext buttonborder buttonface buttontext canvas canvastext field fieldtext graytext highlight highlighttext linktext mark marktext selecteditem selecteditemtext visitedtext activeborder activecaption appworkspace background buttonhighlight buttonshadow captiontext inactiveborder inactivecaption inactivecaptiontext infobackground infotext menu menutext scrollbar threeddarkshadow threedface threedhighlight threedlightshadow threedshadow window windowframe windowtext",OE,QC=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(%|deg|grad|rad|turn)?$/i;function vE(e){if(e.toLowerCase()==="none")return 4;let t=QC.exec(e);return t?t[1]===void 0?1:t[1]==="%"?2:3:0}function ZC(e,t){let n=vE(e);return n===1||n===2||t&&n===4}function JC(e){let t=e.startsWith("hsl"),n=e.indexOf("("),r=e.slice(0,n);if(r!=="rgb"&&r!=="rgba"&&r!=="hsl"&&r!=="hsla"||e.length>120||e.indexOf(")")!==e.length-1)return!1;let o=e.slice(n+1,-1).trim(),s,a,i=o.includes(",");if(i)s=o.split(",").map(l=>l.trim()),s.length===4&&(a=s.pop());else{let l=o.split("/");if(l.length>2)return!1;s=l[0].trim().split(/\s+/),l.length===2&&(a=l[1].trim())}if(s.length!==3||a!==void 0&&!ZC(a,!i))return!1;let c=s.map(vE);if(i)return t?(c[0]===1||c[0]===3)&&c[1]===2&&c[2]===2:(c[0]===1||c[0]===2)&&c[1]===c[0]&&c[2]===c[0];for(let l=0;l<3;l++){let f=c[l];if(!(f===1||f===4||(t&&l===0?f===3:f===2)))return!1}return!0}function PE(e){return e.includes("(")?JC(e):(OE??=new Set(qC.split(" ")),OE.has(e.toLowerCase()))}var eI=/^:?wrap:/,tI=/^:?nowrap:/,nI=/^:?(?:no)?wrap:/,rI=/^(?:rgba?|hsla?)\s*\(/,BE=/[\r\u2028\u2029]/,sI=/^\w*/;function Lo(e){throw new Ge(e,"semantic",{type:"sequence"})}function FE(e){let t=e.trim(),n=eI.test(t)?!0:tI.test(t)?!1:void 0;return{text:(n===void 0?t:t.replace(nI,"")).trim(),wrap:n}}function iI(e){let t=rI.exec(e);if(t){let r=e.lastIndexOf(")");if(r>=t[0].length)return BE.test(e.slice(t[0].length))?void 0:[e.slice(0,r+1),e.slice(r+1)]}if(BE.test(e))return;let n=sI.exec(e)[0];return[n,e.slice(n.length)]}function WE(e){return typeof e=="string"?[...e].map((t,n)=>[String(n),t]):e!==null&&typeof e=="object"?Object.entries(e):[]}var Zc=class{type="sequence";actors=new Map;createdActors=new Map;destroyedActors=new Map;boxes=[];messages=[];notes=[];title;accTitle;accDescr;prevActor;currentBox;lastCreated;lastDestroyed;wrapEnabled;sequenceWrap;active=new Map;constructor(t={}){this.wrapEnabled=t.wrap,this.sequenceWrap=t.sequenceWrap??!1}autoWrap(){return this.wrapEnabled??this.sequenceWrap}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
114
+ `)}setDiagramTitle(t){this.title=t}parseMessage(t){return FE(t)}parseBoxData(t){let n=iI(t),r=n?.[0]?n[0].trim():"transparent",o=n?.[1]?n[1].trim():void 0;if(PE(r)||(r="transparent",o=t.trim()),o===void 0)return{text:void 0,color:r,wrap:void 0};let{text:s,wrap:a}=FE(o);return{text:s||void 0,color:r,wrap:a}}addBox(t){this.currentBox={name:t.text,wrap:t.wrap??this.autoWrap(),fill:t.color,actorKeys:[]},this.boxes.push(this.currentBox)}addActor(t,n,r,o,s){let a=this.currentBox,i;if(s!==void 0){let p;try{p=Hn(s.includes(`
115
+ `)?s+`
116
+ `:`{
117
+ `+s+`
118
+ }`)}catch(u){throw new Ge(`Config of participant "${t}" is not valid YAML. ${u.message}`,"syntax",{type:"sequence"})}p!==null&&typeof p=="object"&&!Array.isArray(p)&&(i=p)}let c=i&&Object.prototype.hasOwnProperty.call(i,"type")?i.type:void 0,l=i&&Object.prototype.hasOwnProperty.call(i,"alias")?i.alias:void 0;c!=null&&(o=String(c)),l&&(!r||r.text===n)&&(r={text:String(l),wrap:r?.wrap,type:o});let f=this.actors.get(t);if(!(f&&(this.currentBox&&f.box&&this.currentBox!==f.box&&Lo(`A same participant should only be defined in one Box: ${f.name} can't be in '${f.box.name}' and in '${this.currentBox.name}' at the same time.`),a=f.box?f.box:this.currentBox,f.box=a,n===f.name&&r==null))){if((r?.text==null||o==null)&&(r={text:n,type:o}),this.actors.set(t,{box:a,name:n,description:r.text,wrap:r.wrap??this.autoWrap(),prevActor:this.prevActor,links:new Map,properties:new Map,type:o??"participant"}),this.prevActor){let p=this.actors.get(this.prevActor);p&&(p.nextActor=t)}this.currentBox&&this.currentBox.actorKeys.push(t),this.prevActor=t}}addMessage(t,n,r,o){this.messages.push({id:String(this.messages.length),from:t,to:n,message:r.text,wrap:r.wrap??this.autoWrap(),answer:o})}addSignal(t,n,r,o,s=!1,a){if(o===18){let i=t?this.active.get(t)??0:0;i<1&&Lo(`Trying to inactivate an inactive participant (${t})`),this.active.set(t,i-1)}else o===17&&t&&this.active.set(t,(this.active.get(t)??0)+1);return this.messages.push({id:String(this.messages.length),from:t,to:n,message:r?.text??"",wrap:r?.wrap??this.autoWrap(),type:o,activate:s,centralConnection:a??0}),!0}addNote(t,n,r){let o=r.wrap??this.autoWrap(),s={actor:t,placement:n,message:r.text,wrap:o},a=typeof t=="string"?[t,t]:t;this.notes.push(s),this.messages.push({id:String(this.messages.length),from:a[0],to:a[1],message:r.text,wrap:o,type:2,placement:n})}addLinks(t,n){let r=this.actors.get(t);if(r)try{let o=JSON.parse(n.text);for(let[s,a]of WE(o))r.links.set(s,a)}catch{return}}addALink(t,n){let r=this.actors.get(t);if(!r)return;let o=n.text.indexOf("@");r.links.set(n.text.slice(0,o-1).trim(),n.text.slice(o+1).trim())}addProperties(t,n){let r=this.actors.get(t);if(r)try{let o=JSON.parse(n.text);for(let[s,a]of WE(o))r.properties.set(s,a)}catch{return}}addDetails(t,n){let r=this.actors.get(t);r&&(r.details=n.text)}apply(t){let n=[],r=[],o=t;for(;;){o!==void 0&&(Array.isArray(o)?(n.push(o),r.push(0)):typeof o!="string"&&this.applyOne(o));let s=n.length-1;if(s<0)return;let a=n[s];r[s]<a.length?o=a[r[s]++]:(n.pop(),r.pop(),o=void 0)}}applyOne(t){let n=t.actor;switch(t.type){case"sequenceIndex":this.messages.push({id:String(this.messages.length),from:void 0,to:void 0,message:{start:t.sequenceIndex,step:t.sequenceIndexStep,visible:t.sequenceVisible===!0},wrap:!1,type:t.signalType});break;case"addParticipant":this.addActor(n,n,t.description,t.draw,t.config);break;case"createParticipant":this.actors.has(n)&&Lo("It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior"),this.lastCreated=n,this.addActor(n,n,t.description,t.draw,t.config),this.createdActors.set(n,this.messages.length);break;case"destroyParticipant":this.lastDestroyed=n,this.destroyedActors.set(n,this.messages.length);break;case"activeStart":case"activeEnd":case"centralConnection":case"centralConnectionReverse":this.addSignal(n,void 0,void 0,t.signalType);break;case"addNote":this.addNote(t.actor,t.placement,t.text);break;case"addLinks":this.addLinks(n,t.text);break;case"addALink":this.addALink(n,t.text);break;case"addProperties":this.addProperties(n,t.text);break;case"addDetails":this.addDetails(n,t.text);break;case"addMessage":this.lastCreated?(t.to!==this.lastCreated&&Lo(`The created participant ${this.lastCreated} does not have an associated creating message after its declaration. Please check the sequence diagram.`),this.lastCreated=void 0):this.lastDestroyed&&(t.to!==this.lastDestroyed&&t.from!==this.lastDestroyed&&Lo(`The destroyed participant ${this.lastDestroyed} does not have an associated destroying message after its declaration. Please check the sequence diagram.`),this.lastDestroyed=void 0),this.addSignal(t.from,t.to,t.msg,t.signalType,t.activate,t.centralConnection);break;case"boxStart":this.addBox(t.boxData);break;case"boxEnd":this.currentBox=void 0;break;case"loopStart":this.addSignal(void 0,void 0,t.loopText,t.signalType);break;case"rectStart":this.addSignal(void 0,void 0,t.color,t.signalType);break;case"optStart":this.addSignal(void 0,void 0,t.optText,t.signalType);break;case"altStart":case"else":this.addSignal(void 0,void 0,t.altText,t.signalType);break;case"parStart":case"and":this.addSignal(void 0,void 0,t.parText,t.signalType);break;case"criticalStart":this.addSignal(void 0,void 0,t.criticalText,t.signalType);break;case"option":this.addSignal(void 0,void 0,t.optionText,t.signalType);break;case"breakStart":this.addSignal(void 0,void 0,t.breakText,t.signalType);break;case"loopEnd":case"rectEnd":case"optEnd":case"altEnd":case"parEnd":case"criticalEnd":case"breakEnd":this.addSignal(void 0,void 0,void 0,t.signalType);break}}};var wf=["$end","INVALID","INVALID","NEWLINE","SD","create","box","restOfLine","end","autonumber","NUM","off","activate","deactivate","title","legacy_title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","loop","rect","opt","alt","par","par_over","critical","break","option","and","else","participant","AS","participant_actor","destroy","note","over","links","link","properties","details",",","left_of","right_of","+","-","()","ACTOR","CONFIG_START","CONFIG_CONTENT","CONFIG_END","TXT","SOLID_OPEN_ARROW","DOTTED_OPEN_ARROW","SOLID_ARROW","BIDIRECTIONAL_SOLID_ARROW","DOTTED_ARROW","BIDIRECTIONAL_DOTTED_ARROW","SOLID_CROSS","DOTTED_CROSS","SOLID_POINT","DOTTED_POINT","SOLID_ARROW_TOP","SOLID_ARROW_BOTTOM","STICK_ARROW_TOP","STICK_ARROW_BOTTOM","SOLID_ARROW_TOP_DOTTED","SOLID_ARROW_BOTTOM_DOTTED","STICK_ARROW_TOP_DOTTED","STICK_ARROW_BOTTOM_DOTTED","SOLID_ARROW_TOP_REVERSE","SOLID_ARROW_BOTTOM_REVERSE","STICK_ARROW_TOP_REVERSE","STICK_ARROW_BOTTOM_REVERSE","SOLID_ARROW_TOP_REVERSE_DOTTED","SOLID_ARROW_BOTTOM_REVERSE_DOTTED","STICK_ARROW_TOP_REVERSE_DOTTED","STICK_ARROW_BOTTOM_REVERSE_DOTTED"];var UE=new Uint8Array(128);for(let e=0;e<128;e++){let t=String.fromCharCode(e),n=e===32||e>=9&&e<=13,r=0;`/\\+()<->:
119
+ ,;`.includes(t)||(r|=1),`+<->:
120
+ ,;`.includes(t)||(r|=2),`<>:
121
+ ,;@`.includes(t)||(r|=8|(n?0:4)),`#
122
+ ;`.includes(t)||(r|=16),!`/\\+()<>:
123
+ ,;-`.includes(t)&&!n&&(r|=32),UE[e]=r}function GE(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=-1,l=(E,C,A)=>{n.push(E),r.push(e.slice(C,A)),o.push(C),i=A},f=(E,C,A,T)=>{n.push(E),r.push(T),o.push(C),i=A},p=E=>{s.push(a),a=E},u=()=>{s.length>0&&(a=s.pop())},m=E=>(c<E&&(c=e.indexOf(`
124
+ `,E),c===-1&&(c=t)),c),h=(E,C)=>{let A=e.charCodeAt(E);return A<128?(UE[A]&C)!==0:C===4||C===32?!Be(A):!0},g=(E,C)=>{for(let A=0;A<C.length;A++){let T=C.charCodeAt(A),b=e.charCodeAt(E+A);if(T>=97&&T<=122?(b|32)!==T:b!==T)return!1}return!0},x=E=>g(i,E)&&!Qe(e.charCodeAt(i+E.length)),y=E=>{for(;E<t&&Be(e.charCodeAt(E));)E++;return E},_=()=>{let E=i;for(;E<t;){let C=e.charCodeAt(E);if(C===10||!Be(C))break;E++}return E===i?!1:(i=E,!0)},S=E=>{for(;E<t&&h(E,16);)E++;return E},P=(E,C,A)=>{l(E,i,i+C),p(A)},k=(E,C,A=-1)=>x(E)?(l(C,i,i+E.length),A>=0&&p(A),!0):!1,w=(E,C)=>{if(!g(i,E))return!1;let A=i+E.length,T=e.charCodeAt(A);if(T!==32&&T!==9)return!1;for(;T===32||T===9;)T=e.charCodeAt(++A);return A>=t||!h(A,32)?!1:(l(C,i,i+E.length),!0)},I=E=>{let C=e.charCodeAt(E),A=e.charCodeAt(E+1);if(C===45){if(A===120||A===88||A===41||A===92||A===47||A===45)return!0;let T=e.charCodeAt(E+2);return A===124&&(T===92||T===47)}return C===47||C===92?(A===124||A===C)&&e.charCodeAt(E+2)===45:C===40&&A===41},D=()=>{let E=i+1;for(;E<t&&h(E,1);)E++;for(;E<t&&!I(E);){let C=E;for(;e.charCodeAt(C)===45;)C++;if(C>=t||!h(C,2))break;for(C++;C<t&&h(C,2);)C++;E=C}f(48,i,E,e.slice(i,E).trim())},U=()=>{let E=i;for(;ft(e.charCodeAt(E));)E++;let C=E>i;if(e.charCodeAt(E)===46&&ft(e.charCodeAt(E+1))){let T=ft(e.charCodeAt(E+2))?E+3:E+2,b=e.charCodeAt(T);if(b===32||b===10)return l(10,i,T),!0}let A=e.charCodeAt(E);return C&&(A===32||A===10)?(l(10,i,E),!0):!1},M=()=>{let E=e.charCodeAt(i+1),C=e.charCodeAt(i+2);if(E===62)l(C===62?55:53,i,i+(C===62?3:2));else if(E===120||E===88)l(59,i,i+2);else if(E===41)l(61,i,i+2);else if(E===124&&C===92)l(63,i,i+3);else if(E===124&&C===47)l(64,i,i+3);else if(E===92&&C===92)l(65,i,i+3);else if(E===47&&C===47)l(66,i,i+3);else if(E===45){let A=e.charCodeAt(i+3);C===62?l(A===62?57:54,i,i+(A===62?4:3)):C===120||C===88?l(60,i,i+3):C===41?l(62,i,i+3):C===124&&A===92?l(67,i,i+4):C===124&&A===47?l(68,i,i+4):C===92&&A===92?l(69,i,i+4):C===47&&A===47?l(70,i,i+4):l(46,i,i+1)}else l(46,i,i+1)},Q=E=>{let C=e.charCodeAt(i+1);if(C!==124&&C!==E||e.charCodeAt(i+2)!==45)return!1;let A=e.charCodeAt(i+3)===45,T=E===47,b;return C===124?A?b=T?75:76:b=T?71:72:A?b=T?77:78:b=T?73:74,l(b,i,i+(A?4:3)),!0},q=()=>{if(!g(i,"title"))return!1;let E=i+5,C=e.charCodeAt(E)===58;return C&&E++,!Be(e.charCodeAt(E))||E+1>=t||!h(E+1,16)?!1:(l(C?15:14,i,S(E+1)),!0)},Y=()=>{let E=g(i,"accdescr");if(!E&&!g(i,"acctitle"))return!1;let C=y(i+8),A=e.charCodeAt(C);return A===58?(l(E?18:16,i,y(C+1)),p(E?6:5),!0):E&&A===123?(i=y(C+1),p(7),!0):!1},z=E=>{switch(E|32){case 97:return k("actor",34,1)||k("alt",24,3)||k("and",30,3)||k("activate",12,1)||Y()||k("autonumber",9);case 98:return k("box",6,3)||k("break",28,3);case 99:return k("create",5)||k("critical",27,3);case 100:return k("destroy",35,1)||w("details",41)||k("deactivate",13,1);case 101:return k("else",31,3)||k("end",8);case 108:return k("loop",21,3)||k("left of",43)||w("links",38)||w("link",39);case 110:return k("note",36);case 111:return k("opt",23,3)||k("option",29,3)||k("over",37)||k("off",11);case 112:return k("participant",32,1)||k("par",25,3)||k("par_over",26,3)||w("properties",40);case 114:return k("rect",22,3)||k("right of",44);case 115:return k("sequencediagram",4);case 116:return q();default:return!1}},R=()=>{let E=e.charCodeAt(i);if(E===10){let C=i+1;for(;e.charCodeAt(C)===10;)C++;l(3,i,C);return}if(Be(E)){i=y(i+1);return}if(E===35||E===37&&e.charCodeAt(i+1)!==123){i=m(i);return}if(E!==125&&e.charCodeAt(i+1)===37&&e.charCodeAt(i+2)===37){i=m(i);return}if(!((ft(E)||E===46)&&U())&&!(E<128&&(E|32)>=97&&(E|32)<=122&&z(E)))if(E===44)l(42,i,i+1);else if(E===59)l(3,i,i+1);else if(h(i,1))D();else if(E===45)M();else if(E===60&&e.startsWith("<<->>",i))l(56,i,i+5);else if(E===60&&e.startsWith("<<-->>",i))l(58,i,i+6);else{if((E===47||E===92)&&Q(E))return;E===58?l(52,i,S(i+1)):E===43?l(45,i,i+1):E===40&&e.charCodeAt(i+1)===41?l(47,i,i+2):l(2,i,i+1)}},L=()=>{if(_())return!0;let E=e.charCodeAt(i);if(E===35)return i=m(i),!0;if(E===64&&e.charCodeAt(i+1)===123)return P(49,2,4),!0;let C=i;for(;C<t&&h(C,4);)C++;if(C>i){let T=y(C);if(e.charCodeAt(T)===64&&e.charCodeAt(T+1)===123)return l(48,i,C),!0;if(T>C&&g(T,"as")&&Be(e.charCodeAt(T+2)))return l(48,i,C),p(2),!0}let A=C;for(;A<t&&h(A,8);)A++;if(A>i){let T=e.charCodeAt(A),b=A;if(A<t&&T!==10&&T!==59)for(b--;b>i&&e.charCodeAt(b)!==35;)b--;if(b>i)return f(48,i,b,e.slice(i,b).trim()),u(),!0}if(e.charCodeAt(A)===60)return l(2,i,m(i)),u(),!0;if(E!==10){let T=m(i);return f(2,i,T,e.slice(i,T).trim()),u(),!0}return!1},F=()=>{switch(a){case 0:return R(),!0;case 1:return L();case 2:return _()?!0:e.charCodeAt(i)===35?(i=m(i),!0):(u(),u(),x("as")?P(33,2,3):l(3,i,i),!0);case 3:return _()?!0:e.charCodeAt(i)===35?(i=m(i),!0):(l(7,i,S(i)),u(),!0);case 4:if(e.charCodeAt(i)!==125){let E=e.indexOf("}",i);return E===-1&&(E=t),l(50,i,E),!0}else{let E=y(i+1),C=E>i+1&&g(E,"as")&&Be(e.charCodeAt(E+2));return l(51,i,i+1),u(),C?p(2):u(),!0}case 5:case 6:return l(a===5?17:19,i,m(i)),u(),!0;default:if(e.charCodeAt(i)===125)i++,u();else{let E=e.indexOf("}",i);E===-1&&(E=t),l(20,i,E)}return!0}};for(;i<t;)if(!F())return n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o};return a===0||a===2?l(3,t,t):a===3?l(7,t,t):a===5?l(17,t,t):a===6?l(19,t,t):a===7&&l(20,t,t),n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o}}var Lt=new Int8Array(79).fill(-1);Lt[53]=5;Lt[54]=6;Lt[55]=0;Lt[57]=1;Lt[56]=33;Lt[58]=34;Lt[59]=3;Lt[60]=4;Lt[61]=24;Lt[62]=25;Lt[63]=41;Lt[64]=42;Lt[65]=43;Lt[66]=44;Lt[67]=51;Lt[68]=52;Lt[69]=53;Lt[70]=54;Lt[71]=45;Lt[72]=46;Lt[73]=47;Lt[74]=48;Lt[75]=55;Lt[76]=56;Lt[77]=57;Lt[78]=58;var br=new Int8Array(79).fill(-1);br[21]=2;br[22]=3;br[23]=4;br[28]=5;br[24]=6;br[25]=7;br[26]=7;br[27]=8;br[6]=1;var oI="'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'SOLID_POINT', 'DOTTED_POINT'";function YE(e,t){let{types:n,texts:r,starts:o}=GE(e),s=0,a=S=>{let P=n[s];throw P===1?it("sequence",e,o[s],"",!0):it("sequence",e,o[s],`Expecting ${S}, got '${wf[P]}'`)},i=S=>(n[s]!==S&&a(`'${wf[S]}'`),r[s++]),c=()=>{let S=n[s];return S!==48&&S!==39&&a("'ACTOR'"),{type:"addParticipant",actor:r[s++]}},l=()=>t.parseMessage(i(52).trim().substring(1)),f=()=>{let S=n[s++];if(S===35){let k=c();return i(3),k.type="destroyParticipant",k}let P=c();if(n[s]===49&&n[s-1]===48){s++;let k=i(50);i(51),P.config=k.trim()}if(P.draw=S===32?"participant":"actor",n[s]===33){s++;let k=i(7);i(3),P.description=t.parseMessage(k)}else n[s]===3?s++:a("'AS', 'NEWLINE'");return P},p=S=>{let P=!1;n[s]===47&&(P=!0,s++);let k=Lt[n[s]];k<0&&a(oI),s++;let w=n[s];(w===47||!P&&(w===45||w===46))&&s++;let I=c(),D=l(),U={type:"addMessage",from:S.actor,to:I.actor,signalType:k,msg:D},M=[S,I,U];if(P){let Q=w===47;U.activate=Q,U.centralConnection=Q?61:60,Q&&M.push({type:"centralConnection",signalType:59,actor:I.actor}),M.push({type:"centralConnectionReverse",signalType:60,actor:S.actor})}else w===45?(U.activate=!0,M.push({type:"activeStart",signalType:17,actor:I.actor})):w===46?M.push({type:"activeEnd",signalType:18,actor:S.actor}):w===47&&(U.activate=!0,U.centralConnection=59,M.push({type:"centralConnection",signalType:59,actor:I.actor}));return M},u=S=>{s++;let P=c();return[P,{type:S,actor:P.actor,text:l()}]},m=()=>{s++;let S=n[s];if(S===37){s++;let w=c(),I=w,D=[w.actor,w.actor];if(n[s]===42){s++;let U=c();I=[w,U],D=[w.actor,U.actor]}return[I,{type:"addNote",placement:2,actor:D,text:l()}]}S!==43&&S!==44&&a("'over', 'left_of', 'right_of'"),s++;let P=c(),k=S===43?0:1;return[P,{type:"addNote",placement:k,actor:P.actor,text:l()}]},h=()=>{s++;let S={type:"sequenceIndex",sequenceVisible:!0,signalType:26};return n[s]===10?(S.sequenceIndex=Number(r[s++]),S.sequenceIndexStep=n[s]===10?Number(r[s++]):1):n[s]===11&&(s++,S.sequenceVisible=!1),n[s]!==3&&a("'NEWLINE', 'NUM', 'off'"),s++,S},g=(S,P,k,w)=>{let I=S.list,D=S.sections;if(D)for(let U=D.length-2;U>=0;U-=2){let M={type:P,signalType:w};M[k]=t.parseMessage(D[U+1]),I=D[U].concat([M,I])}return I},x=S=>{let P=S.text,k=S.list;switch(S.kind){case 1:k[0]={type:"boxStart",boxData:t.parseBoxData(P)},k.push({type:"boxEnd",boxText:P});break;case 2:k[0]={type:"loopStart",loopText:t.parseMessage(P),signalType:10},k.push({type:"loopEnd",loopText:P,signalType:11});break;case 3:k[0]={type:"rectStart",color:t.parseMessage(P),signalType:22},k.push({type:"rectEnd",color:t.parseMessage(P),signalType:23});break;case 4:k[0]={type:"optStart",optText:t.parseMessage(P),signalType:15},k.push({type:"optEnd",optText:t.parseMessage(P),signalType:16});break;case 5:k[0]={type:"breakStart",breakText:t.parseMessage(P),signalType:30},k.push({type:"breakEnd",optText:t.parseMessage(P),signalType:31});break;case 6:k=g(S,"else","altText",13),k[0]={type:"altStart",altText:t.parseMessage(P),signalType:12},k.push({type:"altEnd",signalType:14});break;case 7:k=g(S,"and","parText",20),k[0]={type:"parStart",parText:t.parseMessage(P),signalType:S.startType},k.push({type:"parEnd",signalType:21});break;default:k=g(S,"option","optionText",28),k[0]={type:"criticalStart",criticalText:t.parseMessage(P),signalType:27},k.push({type:"criticalEnd",signalType:29})}return k};for(;n[s]===3;)s++;i(4);let y=[],_={kind:0,text:"",startType:0,list:[],sections:void 0};for(;;){let S=n[s],P=_.list;if(_.kind===1){if(S===32||S===34||S===35)P.push(f());else if(S===3)P.push([]),s++;else if(S===8){s++;let k=x(_);_=y.pop(),_.list.push(k)}else a("'end', 'NEWLINE', 'participant', 'participant_actor', 'destroy'");continue}switch(S){case 3:case 2:P.push([]),s++;break;case 32:case 34:case 35:P.push(f());break;case 5:{s++;let k=n[s];k!==32&&k!==34&&k!==35&&a("'participant', 'participant_actor', 'destroy'");let w=f();w.type="createParticipant",P.push(w);break}case 48:P.push(p(c())),i(3);break;case 39:{let k=n[s+1];P.push(k===48||k===39?u("addALink"):p(c())),i(3);break}case 38:P.push(u("addLinks")),i(3);break;case 40:P.push(u("addProperties")),i(3);break;case 41:P.push(u("addDetails")),i(3);break;case 36:P.push(m()),i(3);break;case 9:P.push(h());break;case 12:case 13:{s++;let k=c();i(3),P.push(S===12?{type:"activeStart",signalType:17,actor:k.actor}:{type:"activeEnd",signalType:18,actor:k.actor});break}case 14:case 15:{let k=r[s++].substring(S===14?6:7);t.setDiagramTitle(k),P.push(k);break}case 16:{s++;let k=i(17).trim();t.setAccTitle(k),P.push(k);break}case 18:{s++;let k=i(19).trim();t.setAccDescription(k),P.push(k);break}case 20:{let k=r[s++].trim();t.setAccDescription(k),P.push(k);break}case 21:case 22:case 23:case 28:case 24:case 25:case 26:case 27:case 6:{s++;let k=i(7);y.push(_),_={kind:br[S],text:k,startType:S===26?32:19,list:[[]],sections:void 0};break}case 31:case 30:case 29:{_.kind!==(S===31?6:S===30?7:8)&&a("'end'"),s++;let w=i(7);(_.sections??=[]).push(P,w),_.list=[];break}case 8:{_.kind===0&&a("'NEWLINE', 'EOF'"),s++;let k=x(_);_=y.pop(),_.list.push(k);break}case 0:_.kind!==0&&a("'end'"),t.apply(P);return;default:a("'NEWLINE', 'ACTOR', 'participant', 'note', 'end'")}}}var aI=16,cI=10,HE=34,KE=4,Fs=5,Bs=6,Dr=' fill="var(--_s)" stroke="var(--_b)"',Ti=' fill="none" stroke="var(--_b)"',lI=new Set(["participant","actor","boundary","control","entity","database","collections","queue"]),dI=new Set(["actor","boundary","control","entity","database"]);function zE(e){return lI.has(e)?e:"participant"}function Jc(e){return dI.has(e)}function VE(e,t,n,r,o=aI){if(Jc(e))return{w:Math.max(40,t.width+8),h:HE+(t.height>0?KE+t.height:0)};let s=e==="collections"?Fs:e==="queue"?2*Bs:0;return{w:Math.max(n,t.width+2*o)+s,h:Math.max(r,t.height+2*cI)+(e==="collections"?Fs:0)}}function uI(e,t,n){let r=d(t),o=s=>d(n+s);switch(e){case"actor":return`<circle cx="${r}" cy="${o(7)}" r="6"${Dr}/><path d="M${r},${o(13)}V${o(24)}M${d(t-10)},${o(17)}H${d(t+10)}M${d(t-8)},${o(34)}L${r},${o(24)}L${d(t+8)},${o(34)}"${Ti}/>`;case"boundary":return`<path d="M${d(t-19)},${o(6)}V${o(28)}M${d(t-19)},${o(17)}H${d(t-8)}"${Ti}/><circle cx="${d(t+3)}" cy="${o(17)}" r="11"${Dr}/>`;case"control":return`<circle cx="${r}" cy="${o(21)}" r="11"${Dr}/><path d="M${d(t+5)},${o(5)}L${d(t-1)},${o(10)}L${d(t+5)},${o(15)}"${Ti}/>`;case"entity":return`<circle cx="${r}" cy="${o(15)}" r="11"${Dr}/><path d="M${d(t-11)},${o(30)}H${d(t+11)}"${Ti}/>`;default:{let s=d(t-14),a=d(t+14);return`<path d="M${s},${o(7)}V${o(27)}A14,5 0 0 0 ${a},${o(27)}V${o(7)}A14,5 0 0 0 ${s},${o(7)}Z"${Dr}/><path d="M${s},${o(7)}A14,5 0 0 0 ${a},${o(7)}"${Ti}/>`}}}function jE(e,t,n,r,o,s){let{w:a,h:i}=r,c=' class="pele-label"';if(Jc(e))return uI(e,t,n)+Ie(o,t,n+HE+KE+o.height/2,c,s);let l=t-a/2;if(e==="collections"){let f=a-Fs,p=i-Fs,u=`<rect x="${d(l+Fs)}" y="${d(n)}" width="${d(f)}" height="${d(p)}" rx="${Xe}"${Dr}/>`,m=`<rect x="${d(l)}" y="${d(n+Fs)}" width="${d(f)}" height="${d(p)}" rx="${Xe}"${Dr}/>`;return u+m+Ie(o,l+f/2,n+Fs+p/2,c,s)}if(e==="queue"){let f=d(l+Bs),p=d(l+a-Bs),u=d(n+i),m=d(i/2);return`<path d="M${f},${d(n)}H${p}A${Bs},${m} 0 0 1 ${p},${u}H${f}A${Bs},${m} 0 0 1 ${f},${d(n)}Z"${Dr}/><path d="M${p},${d(n)}A${Bs},${m} 0 0 0 ${p},${u}"${Ti}/>`+Ie(o,t-Bs/2,n+i/2,c,s)}return`<rect x="${d(l)}" y="${d(n)}" width="${d(a)}" height="${d(i)}" rx="${Xe}"${Dr}/>`+Ie(o,t,n+i/2,c,s)}var Cf=[];function cn(e,t,n,r=1,o=!1){Cf[e]={dotted:t,head:n,atStart:r!==1,atEnd:r!==0,bottom:o}}cn(0,!1,1);cn(1,!0,1);cn(3,!1,2);cn(4,!0,2);cn(5,!1,0);cn(6,!0,0);cn(24,!1,3);cn(25,!0,3);cn(33,!1,1,2);cn(34,!0,1,2);for(let e of[!1,!0]){let t=e?10:0;cn(41+t,e,4),cn(42+t,e,4,1,!0),cn(43+t,e,5),cn(44+t,e,5,1,!0),cn(45+t,e,4,0),cn(46+t,e,4,0,!0),cn(47+t,e,5,0),cn(48+t,e,5,0,!0)}var fI=new Map([[10,"loop"],[12,"alt"],[15,"opt"],[19,"par"],[32,"par"],[27,"critical"],[30,"break"],[22,"rect"]]),pI=12,Rf=28,XE=22,er=10,qE=4,hI=14,Ci=10,mI=16,gI=20,bI=10,el=20,QE=240,tl=16,Ii=4,ZE=' stroke-dasharray="4 4"';function Tf(e){return e!==void 0&&Cf[e]!==void 0}function yI(e,t){let n=new Array(e.length),r=new Array(e.length),o=1,s=1,a=!1;for(let i=0;i<e.length;i++){let c=e[i];if(n[i]=NaN,r[i]=!1,c.type===26){let l=c.message;o=l.start||o,s=l.step||s,a=l.visible}else Tf(c.type)&&(n[i]=o,r[i]=a||t,o=Math.round((o+s)*100)/100)}return{index:n,shown:r,visible:a}}var JE={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function Ws(e,t,n){let r=e[t];return typeof r=="number"&&r>=0&&r<=2e3?r:n}function e0(e,t,n,r,o){let s=d(e-n*kt);return o?`<path class="pele-marker" d="M${d(e)},${d(t)}L${s},${d(t+r*5)}"/>`:`<path class="pele-marker" d="M${d(e)},${d(t)}L${s},${d(t+r*4.5)}V${d(t)}Z" fill="var(--_l)" stroke="none"/>`}function nl(e,t,n,r,o){switch(e){case 1:return bt("arrow_point",t,n,r,0,"var(--_l)");case 2:return bt("arrow_cross",t,n,r,0,"var(--_l)");case 3:return`<path class="pele-marker" d="M${d(t-r*kt)},${d(n-4.5)}L${d(t)},${d(n)}L${d(t-r*kt)},${d(n+4.5)}" stroke-linejoin="round"/>`;case 4:return e0(t,n,r,o,!1);case 5:return e0(t,n,r,o,!0);default:return""}}function EI(e){return e===1?kt-1:e===2?4:0}function t0(e,t,n){return pn(n,r=>AI(e,t,n,r))}function AI(e,t,n,r){let o=t.sequence??{},s=n.fontSize??16,a=Math.round(s*.875),i=Math.round(s*.75),c=n.measurer??Je(n.fontFamily),l=n.icons,f=n.padding??8,p=o.mirrorActors!==!1,u=o.rightAngles===!0,m=Math.min(Ws(o,"actorMargin",40),r?8:1/0),h=Math.min(Ws(o,"width",64),r?48:1/0),g=Ws(o,"height",Math.round(s*1.5)+20),x=Math.min(Ws(o,"width",160),r?Math.max(32,((n.maxWidth??320)-2*f)/Math.max(1,e.actors.size)-m-24):1/0),y=Math.max(4,14+Ws(o,"messageMargin",35)-35),_=Math.min(Ws(o,"noteMargin",10),r?6:1/0),S=Math.min(Ws(o,"boxMargin",10),r?6:1/0),P=o.messageAlign==="left"?-1:o.messageAlign==="right"?1:0,k=r?6:pI,w=r?8:mI,I=r?12:gI,D=r?6:bI,U=e.messages,M=U.length,Q=yI(U,o.showSequenceNumbers===!0),q=(he,ne,pe,Re=x,le=0)=>{let Ee=De(he,!1,c,ne,r||pe?Re:1/0,le);return r?ci(Ee,c,Math.max(120,Re)):Ee},Y;if(o.hideUnusedParticipants===!0){Y=new Set;for(let he of U)Y.add(he.from).add(he.to)}let z=new Int32Array(M+1);z[M]=-1;for(let he=M-1;he>=0;he--)z[he]=Tf(U[he].type)?he:z[he+1];let R=[],L=new Map;for(let[he,ne]of e.actors){if(Y&&!Y.has(he))continue;let pe=zE(ne.type),Re=q(ne.description,s,ne.wrap),le=e.createdActors.get(he),Ee=e.destroyedActors.get(he),Ne=le===void 0?-1:z[Math.min(le,M)];Ne>=0&&U[Ne].to!==he&&(Ne=-1);let Me=Ee===void 0?-1:z[Math.min(Ee,M)];Me>=0&&U[Me].to!==he&&U[Me].from!==he&&(Me=-1),L.set(he,R.length),R.push({id:he,actor:ne,kind:pe,label:Re,size:VE(pe,Re,h,g,r?8:void 0),x:0,createAt:Ne,destroyAt:Me,top:0,lifeStart:0,lifeEnd:-1,activations:[]})}let F=R.length-1,E=new Map,C=(he,ne,pe)=>{if(he<0||ne>F)return;let Re=he*R.length+ne;(E.get(Re)??0)<pe&&E.set(Re,pe)},A=he=>Q.shown[he]?Math.max(tl,c.width(String(Q.index[he]),i,0)+8):0,T=new Array(M);for(let he=0;he<M;he++){let ne=U[he],pe=ne.from===void 0?void 0:L.get(ne.from),Re=ne.to===void 0?void 0:L.get(ne.to);if(!(pe===void 0||Re===void 0||typeof ne.message!="string")){if(ne.type===2){let le=q(ne.message,a,ne.wrap),Ee=le.width+2*_;ne.placement===0?C(pe-1,pe,Ee+2*Ci+er):ne.placement===1?C(pe,pe+1,Ee+2*Ci+er):pe===Re?(C(pe-1,pe,Ee/2+Ci),C(pe,pe+1,Ee/2+Ci)):C(Math.min(pe,Re),Math.max(pe,Re),Ee-2*w),T[he]={kind:2,a:pe,b:Re,label:le,x:0,w:Ee}}else if(Tf(ne.type)){let le=q(ne.message,a,ne.wrap),Ee=A(he);if(pe===Re)C(pe,pe+1,Rf+8+le.width+16+er+Ee),T[he]={kind:1,a:pe,b:Re,label:le,x:0,w:0};else{let Ne=R[Re].createAt===he?R[Re].size.w/2:0,Me=ne.centralConnection?4*Ii:0;C(Math.min(pe,Re),Math.max(pe,Re),(r?Math.min(le.width,Math.max(16,x-16)):le.width)+2*k+er+Ee+Ne+Me),T[he]={kind:0,a:pe,b:Re,label:le,x:0,w:0}}}}}let b=[];for(let he=0;he<=F;he++){let ne=R[he].actor.box,pe=b[b.length-1];ne&&pe&&pe.box===ne&&pe.last===he-1?pe.last=he:ne&&b.push({box:ne,first:he,last:he,title:q(ne.name,a,ne.wrap),grow:0})}let N=new Array(Math.max(F,0));for(let he=0;he<F;he++){let ne=R[he],pe=R[he+1],Re=ne.actor.box!==pe.actor.box?(ne.actor.box?S:0)+(pe.actor.box?S:0):0;N[he]=Math.max(ne.size.w/2+pe.size.w/2+m+Re,E.get(he*R.length+he+1)??0)}let $=[];for(let[he,ne]of E){let pe=Math.floor(he/R.length),Re=he%R.length;Re-pe>1&&$.push([pe,Re,ne])}$.sort((he,ne)=>he[1]-he[0]-(ne[1]-ne[0])||he[0]-ne[0]);for(let[he,ne,pe]of $){let Re=0;for(let Ee=he;Ee<ne;Ee++)Re+=N[Ee];if(Re>=pe)continue;let le=(pe-Re)/(ne-he);for(let Ee=he;Ee<ne;Ee++)N[Ee]+=le}let X=()=>{for(let he=1;he<=F;he++)R[he].x=R[he-1].x+N[he-1]};X();for(let he of b){let ne=R[he.last].x+R[he.last].size.w/2-(R[he.first].x-R[he.first].size.w/2);he.grow=Math.max(0,(he.title.width-ne)/2),he.grow!==0&&(he.first>0&&(N[he.first-1]+=he.grow),he.last<F&&(N[he.last]+=he.grow))}X();let V=1/0,O=-1/0,v=(he,ne)=>{he<V&&(V=he),ne>O&&(O=ne)};for(let he of R)v(he.x-he.size.w/2,he.x+he.size.w/2);for(let he of b)v(R[he.first].x-R[he.first].size.w/2-S-he.grow,R[he.last].x+R[he.last].size.w/2+S+he.grow);let W=new Array(M),H=[],G=()=>F<0?[0,120]:[R[0].x-I,R[F].x+I];for(let he=0;he<M;he++){let ne=U[he],pe=ne.type,Re=pe===void 0?void 0:fI.get(pe),le=T[he];if(Re!==void 0){let Ee={kind:Re,x0:1/0,x1:-1/0,top:0,title:JE,tabW:0,fill:Re==="rect"&&typeof ne.message=="string"?ne.message:"",dividers:[he],dividerY:[],dividerLabels:[]};W[he]=Ee,H.push(Ee)}else if(pe===13||pe===20||pe===28)H[H.length-1]?.dividers.push(he);else if(pe===11||pe===14||pe===16||pe===21||pe===29||pe===31||pe===23){let Ee=H.pop();if(!Ee)continue;if(W[he]=Ee,Ee.x0>Ee.x1&&([Ee.x0,Ee.x1]=G()),Ee.kind!=="rect"){Ee.tabW=c.width(Ee.kind,i,1)+14;for(let Me=0;Me<Ee.dividers.length;Me++){let Ce=U[Ee.dividers[Me]].message,Oe=Me===0?Ee.tabW+8:0,We=Ee.x1-Ee.x0-16-Oe,Te=Ce?q(`[${Ce}]`,a,!0,Math.max(We,r?Math.min(QE,x):QE)):JE;Te.width>We&&(Ee.x1+=Te.width-We),Me===0?Ee.title=Te:Ee.dividerLabels.push(Te)}}v(Ee.x0,Ee.x1);let Ne=H[H.length-1];Ne&&(Ne.x0=Math.min(Ne.x0,Ee.x0-D),Ne.x1=Math.max(Ne.x1,Ee.x1+D))}else if(le){let Ee=R[le.a],Ne=R[le.b],Me,Ce;if(le.kind===2){if(ne.placement===0)le.x=Ee.x-Ci-le.w;else if(ne.placement===1)le.x=Ee.x+Ci;else if(le.a===le.b)le.x=Ee.x-le.w/2;else{let We=Math.min(Ee.x,Ne.x)-w,Te=Math.max(Ee.x,Ne.x)+w;(r||ne.wrap)&&(le.label=q(ne.message,a,!0,Math.max(x,Te-We-2*_))),le.w=Math.max(Te-We,le.label.width+2*_),le.x=(We+Te-le.w)/2}Me=le.x,Ce=le.x+le.w}else le.kind===1?(Me=Ee.x,Ce=Ee.x+er+Rf+8+le.label.width+A(he)):(Me=Math.min(Ee.x,Ne.x),Ce=Math.max(Ee.x,Ne.x),(r||ne.wrap)&&(le.label=q(ne.message,a,!0,Math.max(x,Ce-Me-2*k-er))),Ne.createAt===he&&(Ne.x>Ee.x?Ce+=Ne.size.w/2:Me-=Ne.size.w/2));v(Me,Ce);let Oe=H[H.length-1];Oe&&(Oe.x0=Math.min(Oe.x0,Me-I),Oe.x1=Math.max(Oe.x1,Ce+I))}}let te=0;for(let he of b)te=Math.max(te,he.title.height);let Z=b.length>0?S+(te>0?te+4:0):0,B=0;for(let he of R)he.createAt<0&&(B=Math.max(B,he.size.h));let K=Z+B;for(let he of R)he.top=K-he.size.h,he.lifeStart=K;let ee=R.map(he=>he.x),ae=(he,ne)=>{let pe=0,Re=ee.length;for(;pe<Re;){let le=pe+Re>>1;ee[le]<=he?pe=le+1:Re=le}return pe<ee.length&&ee[pe]<ne},J=(he,ne,pe,Re)=>{if(he.width===0)return"";let le=ne-he.width/2;return(ae(le,le+he.width)?`<rect x="${d(le-3)}" y="${d(pe-he.height/2+2)}" width="${d(he.width+6)}" height="${d(he.height-4)}" rx="3" fill="var(--_bg)" stroke="none"/>`:"")+Ie(he,ne,pe,Re,l)},se=(he,ne=0)=>he.activations.length+ne>0?he.x-er/2:he.x,me=(he,ne=0)=>{let pe=he.activations.length+ne;return pe>0?he.x+er/2+(pe-1)*qE:he.x},Ae=[],de=[],oe="",ye="",ce="",fe="",xe="",be="",re=(he,ne)=>{let pe=he.activations.pop(),Re=Math.max(ne,pe+hI),le=he.x-er/2+he.activations.length*qE;return v(le,le+er),de.push(`<rect class="pele-activation" data-id="${$e(he.id)}" x="${d(le)}" y="${d(pe)}" width="${er}" height="${d(Re-pe)}" rx="2"/>`),Re},j=(he,ne)=>{let pe=he.x,Re=ne+16;return he.lifeEnd=Re,be+=`<path class="pele-destroy" data-id="${$e(he.id)}" d="M${d(pe-6)},${d(Re-6)}L${d(pe+6)},${d(Re+6)}M${d(pe+6)},${d(Re-6)}L${d(pe-6)},${d(Re+6)}"/>`,Re+6},ie=(he,ne,pe)=>{let Re=he.actor.properties.get("class");return`<g class="pele-node pele-actor pele-actor-${he.kind}${pe?" pele-actor-footer":""}${typeof Re=="string"?wt(Re):""}" data-id="${$e(he.id)}">`+jE(he.kind,he.x,ne,he.size,he.label,l)+"</g>"},ue=(he,ne,pe,Re)=>`<g class="pele-sequence-number"><rect x="${d(ne-Re/2)}" y="${d(pe-tl/2)}" width="${d(Re)}" height="${tl}" rx="${tl/2}" fill="var(--_l)" stroke="none"/><text x="${d(ne)}" y="${d(pe+i*.35)}" text-anchor="middle" font-size="${i}" fill="var(--_bg)" stroke="none">${je(String(Q.index[he]))}</text></g>`,ge=K+6,Se=[];for(let he=0;he<M;he++){let ne=U[he],pe=ne.type,Re=T[he],le=W[he];if(pe===17){let Ee=ne.from===void 0?void 0:L.get(ne.from);Ee!==void 0&&R[Ee].activations.push(ge)}else if(pe===18){let Ee=ne.from===void 0?void 0:L.get(ne.from);Ee!==void 0&&R[Ee].activations.length>0&&(ge=Math.max(ge,re(R[Ee],ge)))}else if(le&&le.dividers[0]===he)Se.push(le),le.kind==="rect"?(le.top=ge+8,ge=le.top):(le.top=ge+12,ge=le.top+Math.max(el,le.title.height+2));else if(le){Se.pop();let Ee=ge+12,Ne=d(le.x0),Me=d(le.x1-le.x0);if(le.kind==="rect"){let Ce=le.fill?At([`fill:${le.fill}`]).shape:"";Ae.push(`<rect class="pele-rect" x="${Ne}" y="${d(le.top)}" width="${Me}" height="${d(Ee-le.top)}" rx="${Xe}"${Ce?"":' fill-opacity="0.5"'}${Ce}/>`)}else{let Ce=`<rect x="${Ne}" y="${d(le.top)}" width="${Me}" height="${d(Ee-le.top)}" rx="${Xe}" fill="none"/>`;for(let Oe=0;Oe<le.dividerY.length;Oe++){let We=le.dividerY[Oe],Te=le.dividerLabels[Oe];Ce+=`<path d="M${Ne},${d(We)}H${d(le.x1)}"${ZE}/>`+J(Te,le.x0+8+Te.width/2,We+2+Te.height/2,' class="pele-frame-label" fill="var(--_m)" stroke="none"')}Ce+=`<rect x="${Ne}" y="${d(le.top)}" width="${d(le.tabW)}" height="${el}" rx="${Xe}" fill="var(--_s)"/><text class="pele-frame-kind" x="${d(le.x0+le.tabW/2)}" y="${d(le.top+el/2+i*.35)}" text-anchor="middle" font-size="${i}" font-weight="var(--_hw)" fill="var(--_m)" stroke="none">${le.kind}</text>`+J(le.title,le.x0+le.tabW+8+le.title.width/2,le.top+Math.max(el,le.title.height)/2,' class="pele-frame-label" fill="var(--_m)" stroke="none"'),oe+=`<g class="pele-frame pele-frame-${le.kind}">${Ce}</g>`}ge=Ee}else if(pe===13||pe===20||pe===28){let Ee=Se[Se.length-1];if(Ee){let Ne=Ee.dividerLabels[Ee.dividerY.length];Ee.dividerY.push(ge+12),ge+=12+(Ne.height>0?Ne.height:0)}}else if(Re&&Re.kind===2){let Ee=R[Re.a],Ne=Re.label.height+2*Math.max(4,_-4),Me=ge+10,Ce=Re.x;ne.placement===1?Ce+=me(Ee)-Ee.x:ne.placement===0&&(Ce+=se(Ee)-Ee.x),v(Ce,Ce+Re.w),fe+=`<g class="pele-note" data-id="i${$e(ne.id)}"><rect x="${d(Ce)}" y="${d(Me)}" width="${d(Re.w)}" height="${d(Ne)}" rx="${Xe}"/>`+Ie(Re.label,Ce+Re.w/2,Me+Ne/2,' class="pele-label" stroke="none" fill="var(--_fg)"',l)+"</g>",ge=Me+Ne}else if(Re){let Ee=Cf[pe],Ne=R[Re.a],Me=R[Re.b],Ce=Re.label,Oe=A(he),We=0;for(let rt=he+1;rt<M;rt++){let Ve=U[rt].type;if(Ve===17)U[rt].from===ne.to&&We++;else if(Ve!==18&&Ve!==59&&Ve!==60)break}let Te=Ee.bottom?1:-1,Ke=Ee.dotted?ZE:"",ze=ne.centralConnection,at=ze===59||ze===61,et=ze===60||ze===61,nt=(rt,Ve)=>`<circle class="pele-central" cx="${d(rt)}" cy="${d(Ve)}" r="${Ii}" fill="var(--_l)" stroke="none"/>`,Tt=Ee.atStart&&!Ee.atEnd,lt=EI(Ee.head),Et="",ot;if(Re.kind===1){let rt=ge+y+Math.max(0,(Ce.height-XE)/2),Ve=rt+XE,st=et?Ne.x+Ii:me(Ne),dt=at?Ne.x+Ii:me(Ne,We),ut=Math.max(st,dt)+Rf+Oe/2;et&&(Et+=nt(Ne.x,rt)),at&&(Et+=nt(Ne.x,Ve)),Oe>0&&(Et+=ue(he,Tt?dt:st,Tt?Ve:rt,Oe),Tt?dt+=Oe/2:st+=Oe/2);let en=(Ee.atStart?nl(Ee.head,st,rt,-1,Te):"")+(Ee.atEnd?nl(Ee.head,dt,Ve,-1,-Te):""),xt=d(st+(Ee.atStart?lt:0)),qe=d(dt+(Ee.atEnd?lt:0));Et=`<path d="${u?`M${xt},${d(rt)}H${d(ut)}V${d(Ve)}H${qe}`:`M${xt},${d(rt)}H${d(ut-6)}A6,6 0 0 1 ${d(ut)},${d(rt+6)}V${d(Ve-6)}A6,6 0 0 1 ${d(ut-6)},${d(Ve)}H${qe}`}"${Ke}/>`+en+Et,v(Ne.x,ut+8+Ce.width),Ce.width>0&&(ce+=`<g class="pele-edge-label" data-id="i${$e(ne.id)}">${Ie(Ce,ut+8+Ce.width/2,(rt+Ve)/2,"",l)}</g>`),ot=Ve}else{let rt=Me.x>Ne.x?1:-1,Ve=Me.createAt===he;ot=ge+y+Math.max(Ce.height>0?Ce.height+2:6,Ve?Me.size.h/2-y+6:0);let st=rt>0?me(Ne):se(Ne),dt=rt>0?se(Me,We):me(Me,We);if(Ve&&(Me.top=ot-Me.size.h/2,Me.lifeStart=Me.top+Me.size.h,dt=Me.x-rt*(Jc(Me.kind)?18:Me.size.w/2+1)),et&&(Et+=nt(Ne.x,ot),st=Ne.x+rt*Ii),at&&(Et+=nt(Me.x,ot),dt=Me.x-rt*Ii),Oe>0)if(Tt){let qe=at?dt-rt*(Oe/2+2):dt;Et+=ue(he,qe,ot,Oe),dt=qe-rt*Oe/2}else{let qe=et?st+rt*(Oe/2+2):st;Et+=ue(he,qe,ot,Oe),st=qe+rt*Oe/2}let ut=(Ee.atStart?nl(Ee.head,st,ot,-rt,Te*rt):"")+(Ee.atEnd?nl(Ee.head,dt,ot,rt,Te*rt):""),en=st+(Ee.atStart?rt*lt:0),xt=dt-(Ee.atEnd?rt*lt:0);if(Et=`<path d="M${d(en)},${d(ot)}H${d(xt)}"${Ke}/>`+ut+Et,Ce.width>0){let qe=Math.min(st,dt),_t=Math.max(st,dt),St=P<0?qe+k+Ce.width/2:P>0?_t-k-Ce.width/2:(qe+_t)/2;v(St-Ce.width/2,St+Ce.width/2),ce+=`<g class="pele-edge-label" data-id="i${$e(ne.id)}">${J(Ce,St,ot-4-Ce.height/2,"")}</g>`}Ve&&(ge=ot+Me.size.h/2-6)}ye+=`<g class="pele-edge pele-message" data-id="i${$e(ne.id)}">${Et}</g>`,ge=Math.max(ge,ot),Ne.destroyAt===he&&(ge=Math.max(ge,j(Ne,ot))),Me.destroyAt===he&&Me!==Ne&&(ge=Math.max(ge,j(Me,ot)))}}ge+=20;for(let he of R)for(;he.activations.length>0;)re(he,ge);let we=ge;if(p){let he=0;for(let ne of R)ne.lifeEnd>=0||(he=Math.max(he,ne.size.h),xe+=ie(ne,ge,!0));we=ge+he}let ke="";for(let he of R){xe+=ie(he,he.top,!1);let ne=he.lifeEnd>=0?he.lifeEnd:ge;ne>he.lifeStart&&(ke+=`<path class="pele-lifeline" data-id="${$e(he.id)}" d="M${d(he.x)},${d(he.lifeStart)}V${d(ne)}"/>`)}let Le="";for(let he of b){let ne=R[he.first].x-R[he.first].size.w/2-S-he.grow,pe=R[he.last].x+R[he.last].size.w/2+S+he.grow,Re=he.box.fill==="transparent"?"":At([`fill:${he.box.fill}`]).shape;Le+=`<g class="pele-cluster pele-box"${he.box.name?` data-id="${$e(he.box.name)}"`:""}><rect x="${d(ne)}" y="0" width="${d(pe-ne)}" height="${d(we+S)}" rx="${Xe}" fill="var(--_a)" stroke="var(--_b)"${Re?"":' fill-opacity="0.5"'}${Re}/>`+Ie(he.title,(ne+pe)/2,S/2+2+he.title.height/2,' class="pele-cluster-label" fill="var(--_m)"',l)+"</g>"}b.length>0&&(we+=S);let Fe=0,He="",_e=q(e.title,s,!1,r?Rt(n):x,1);if(V>O&&v(0,Math.max(_e.width,40)),_e.width>0){let he=(V+O)/2;v(he-_e.width/2,he+_e.width/2),Fe=-_e.height-12,He=Ie(_e,he,Fe+_e.height/2,' class="pele-title" font-weight="var(--_tw)"',l)}let Pe=Math.ceil(O-V+2*f),Ye=Math.ceil(we-Fe+2*f);return{svg:Ze("sequence",Pe,Ye,s,n,e,`<g transform="translate(${d(f-V)},${d(f-Fe)})">`+He+(Le?`<g class="pele-boxes" font-size="${a}">${Le}</g>`:"")+(Ae.length>0?`<g class="pele-rects" fill="var(--_a)">${Ae.reverse().join("")}</g>`:"")+(ke?`<g class="pele-lifelines" fill="none" stroke="var(--_b)">${ke}</g>`:"")+(de.length>0?`<g class="pele-activations" fill="var(--_s)" stroke="var(--_b)">${de.reverse().join("")}</g>`:"")+(oe?`<g class="pele-frames" font-size="${a}" stroke="var(--_b)">${oe}</g>`:"")+(ye?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${ye}</g>`:"")+(be?`<g class="pele-destroys" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-linecap="round">${be}</g>`:"")+(ce?`<g class="pele-edge-labels" font-size="${a}">${ce}</g>`:"")+(fe?`<g class="pele-notes" font-size="${a}" fill="var(--_a)" stroke="var(--_b)">${fe}</g>`:"")+(xe?`<g class="pele-nodes">${xe}</g>`:"")+"</g>"),width:Pe,height:Ye,links:[]}}var n0={type:"sequence",parse(e,t,n){let r=t.sequence??{},o=new Zc({wrap:typeof t.wrap=="boolean"?t.wrap:void 0,sequenceWrap:r.wrap===!0});return n&&o.setDiagramTitle(n),YE(e,o),o},render:t0};function xI(e){let t="TB";for(let n of e)typeof n!="string"&&n.stmt==="dir"&&(t=n.value);return t}function r0(e,t,n){let r=[],o=[],s=new Map,a=new Map,i=new Map,c=0,l=0,f=m=>{if(!m.id||m.id==="</join></fork>"||m.id==="</choice>")return;if(m.cssClasses){let g;for(let x of m.cssClasses.split(" ")){let y=n.get(x);if(y){g??=m.cssCompiledStyles.slice();for(let _ of y.styles)g.push(_)}}g&&(m.cssCompiledStyles=g)}let h=s.get(m.id);if(h){let g=m.parentId??h.parentId;Object.assign(h,m),g!==void 0&&(h.parentId=g)}else s.set(m.id,m),r.push(m)},p=(m,h,g)=>{let x=h.id;if(x==="root")return;let y=t.get(x),_=y?.classes?.join(" ")??"",S=y?.styles??[],P=a.get(x);if(!P){let Y="rect";h.start===!0?Y="stateStart":h.start===!1&&(Y="stateEnd"),h.type!=="default"&&(Y=h.type),P={shape:Y,description:x,cssClasses:`${_} statediagram-state`,cssStyles:S,type:void 0,dir:void 0,colorIndex:void 0},a.set(x,P)}if(h.description&&(Array.isArray(P.description)?(P.shape="rectWithTitle",P.description=P.description.concat(h.description)):P.description.length>0?(P.shape="rectWithTitle",P.description=P.description===x?[h.description].flat():[P.description,h.description].flat()):(P.shape="rect",P.description=Array.isArray(h.description)?h.description.slice():h.description)),P.description.length===1&&P.shape==="rectWithTitle"&&(P.shape=P.type==="group"?"roundedWithTitle":"rect"),!P.type&&h.doc){if(P.type="group",P.dir=xI(h.doc),P.shape=h.type==="divider"?"divider":"roundedWithTitle",P.shape==="divider"&&m?.id!==void 0&&i.has(m.id))P.colorIndex=i.get(m.id);else{let Y=l++;P.colorIndex=_.trim()!==""||S.length>0?void 0:Y}i.set(x,P.colorIndex),P.cssClasses=`${P.cssClasses} statediagram-cluster ${g?"statediagram-cluster-alt":""}`}let k=P.description,w={id:x,shape:P.shape,label:Array.isArray(k)?k[0]:k,description:Array.isArray(k)?k.slice(1):[],cssClasses:P.cssClasses,cssCompiledStyles:[],cssStyles:P.cssStyles,type:P.type,isGroup:P.type==="group",dir:P.dir,colorIndex:P.colorIndex};w.shape==="divider"&&(w.label=""),m&&m.id!=="root"&&(w.parentId=m.id);let I=h.note;if(!I){f(w);return}let D=(Y,z,R,L)=>({id:Y,shape:z,label:I.text,description:[],cssClasses:R,cssCompiledStyles:[],cssStyles:[],type:L?"group":"node",isGroup:L,dir:void 0,position:I.position}),U=D(`${x}----note-${c++}`,"note","statediagram-note",!1);U.parentId=`${x}----parent`,U.noteFor=x,f(D(U.parentId,"noteGroup",P.cssClasses,!0)),f(U),f(w);let M=I.position==="left of",Q=M?U.id:x,q=M?x:U.id;o.push({id:`${Q}-${q}`,start:Q,end:q,label:"",classes:"transition note-edge",pattern:"dashed"})},u=[{item:void 0,doc:e,at:0,alt:!0}];for(;u.length>0;){let m=u[u.length-1];if(m.at>=m.doc.length){u.pop();continue}let h=m.doc[m.at++];typeof h!="string"&&(h.stmt==="state"?(p(m.item,h,m.alt),h.doc&&u.push({item:h,doc:h.doc,at:0,alt:!m.alt})):h.stmt==="relation"&&(p(m.item,h.state1,m.alt),p(m.item,h.state2,m.alt),o.push({id:`edge${c++}`,start:h.state1.id,end:h.state2.id,label:h.description??"",classes:"transition"})))}for(let m of r)if(m.isGroup&&m.description.length>0)throw new Ge(`Group nodes can only have label. Remove the additional description for node [${m.id}]`,"semantic",{type:"state"});return{nodes:r,edges:o}}var rl=class{type="state";rootDoc=[];states=new Map;relations=[];classes=new Map;links=new Map;graph={nodes:[],edges:[]};title;accTitle;accDescr;dividerCount=0;get direction(){let t="TB";for(let n of this.rootDoc)typeof n!="string"&&n.stmt==="dir"&&(t=n.value);return t}setRootDoc(t){this.rootDoc=t,this.translate(),this.extract(t)}extract(t){this.states=new Map,this.relations=[],this.classes=new Map;let n=Array.isArray(t)?t:t.doc;for(let r of n)if(typeof r!="string")switch(r.stmt){case"state":this.addState(r.id.trim(),r.type,r.doc,r.description,r.note);break;case"relation":this.addRelation(r.state1,r.state2,r.description);break;case"classDef":this.addStyleClass(r.id.trim(),r.classes);break;case"style":{let o=r.styleClass.split(",").map(s=>s.replace(/;/g,"").trim());for(let s of this.named(r.id.trim()))s.styles=o.slice();break}case"applyClass":this.setCssClass(r.id.trim(),r.styleClass);break;case"click":this.addLink(typeof r.id=="string"?r.id:r.id.id,r.url,r.tooltip);break}this.graph=r0(n,this.states,this.classes)}translate(){let t=[["root",{stmt:"root",id:"root",doc:this.rootDoc},!0]];for(;t.length>0;){let[n,r,o]=t.pop();if(typeof r=="string")continue;if(r.stmt==="relation"){t.push([n,r.state2,!1],[n,r.state1,!0]);continue}if(r.stmt==="state")r.id==="[*]"?(r.id=n+(o?"_start":"_end"),r.start=o):r.id=r.id.trim();else if(r.stmt!=="root")continue;if(!r.doc)continue;let s=[],a=[];for(let i of r.doc)typeof i!="string"&&i.stmt==="state"&&i.type==="divider"&&!i.doc?(s.push({...i,doc:a}),a=[]):a.push(i);s.length>0&&(a.length>0&&s.push({stmt:"state",id:this.getDividerId(),type:"divider",doc:a}),r.doc=s);for(let i=r.doc.length-1;i>=0;i--)t.push([r.id,r.doc[i],!0])}}addState(t,n="default",r,o,s,a){let i=t.trim(),c=this.states.get(i);if(c?(c.doc||(c.doc=r),c.type||(c.type=n)):(c={stmt:"state",id:i,descriptions:[],type:n,doc:r,note:s,classes:[],styles:[],textStyles:[]},this.states.set(i,c)),o)for(let l of Array.isArray(o)?o:[o])this.addDescription(i,l.trim());if(s&&(c.note=s),a)for(let l of a)this.setCssClass(i,l.trim())}getState(t){return this.states.get(t)}addLink(t,n,r){this.links.set(t,{url:n,tooltip:r})}addRelation(t,n,r=""){for(let o of[t,n])this.addState(o.id,o.type,o.doc,o.description,o.note,o.classes);this.relations.push({id1:t.id.trim(),id2:n.id.trim(),relationTitle:r})}addDescription(t,n){this.states.get(t)?.descriptions?.push(n.startsWith(":")?n.replace(":","").trim():n)}getDividerId(){return`divider-id-${++this.dividerCount}`}addStyleClass(t,n=""){let r=this.classes.get(t);if(r||(r={id:t,styles:[],textStyles:[]},this.classes.set(t,r)),!!n)for(let o of n.split(",")){let s=o.replace(";","").trim();o.includes("color")&&r.textStyles.push(s.replace("fill","bgFill").replace("color","fill")),r.styles.push(s)}}setCssClass(t,n){for(let r of this.named(t))r.classes?.push(n)}getDirection(){for(let t of this.rootDoc)if(typeof t!="string"&&t.stmt==="dir")return t.value;return"TB"}setDirection(t){for(let n of this.rootDoc)if(typeof n!="string"&&n.stmt==="dir"){n.value=t;return}this.rootDoc.unshift({stmt:"dir",value:t})}trimColon(t){return t.startsWith(":")?t.slice(1).trim():t.trim()}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
125
+ `)}named(t){let n=[];for(let r of t.split(",")){let o=this.states.get(r);o||(this.addState(r),o=this.states.get(r.trim())),o&&n.push(o)}return n}};var If=["$end","INVALID","NL","SD","DESCR","-->","HIDE_EMPTY","scale","WIDTH","COMPOSIT_STATE","STRUCT_START","STRUCT_STOP","STATE_DESCR","AS","ID","FORK","JOIN","CHOICE","CONCURRENT","note","NOTE_TEXT","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","CLICK","STRING","HREF","classDef","CLASSDEF_ID","DEFAULT_CLASSDEF_ID","CLASSDEF_STYLEOPTS","DEFAULT","style","STYLE_IDS","STYLEDEF_STYLEOPTS","class","CLASSENTITY_IDS","STYLECLASS","direction_tb","direction_bt","direction_rl","direction_lr","EDGE_STATE","STYLE_SEPARATOR","left_of","right_of","INVALID"];var SI=/direction/gi,_I=/<<(?:fork|join|choice)>>|\[\[(?:fork|join|choice)\]\]/gi,wI=/[\n\r\u2028\u2029]/g,RI=/%%/g,TI=/\{/g;function $o(e,t){let n=0,r=-2;return o=>{if(r===-2||o<n||r!==-1&&o>r){e.lastIndex=o;let s=e.exec(t);r=s?s.index:-1,n=o}return r}}function s0(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c,l=$o(SI,e),f=$o(_I,e),p=$o(wI,e),u=$o(RI,e),m=$o(TI,e),h=-1,g=-1,x=[-1,-1,-1,-1],y=[0,0,0,0],_=-1,S=-1,P=[-1,-1,-1,-1,-1,-1],k=(E,C,A)=>{n.push(E),r.push(e.slice(C,A)),o.push(C),i=A},w=(E,C,A,T)=>{n.push(E),r.push(C),o.push(A),i=T},I=E=>{s.push(a),a=E},D=()=>{s.length>0&&(a=s.pop())},U=(E,C)=>{for(let A=0;A<E.length;A++){let T=E.charCodeAt(A),b=e.charCodeAt(C+A);if(b!==T&&!(T>=97&&T<=122&&b===T-32))return!1}return!0},M=E=>{let C=E;for(;C<t&&Be(e.charCodeAt(C));)C++;return C},Q=E=>{let C=E;for(;C<t&&Qe(e.charCodeAt(C));)C++;return C},q=E=>{let C=e.indexOf(`
126
+ `,E);return C===-1?t:C},Y=E=>{let C=p(E);return C===-1?t:C},z=E=>{if(E<h||E>g){let C=l(E),A=C===-1?t:Y(E);h=E,g=A,x[0]=x[1]=x[2]=x[3]=-1;for(let T=C;T!==-1&&T<A;T=l(T+1)){let b=M(T+9);if(b===T+9)continue;let N=U("tb",b)?0:U("bt",b)?1:U("rl",b)?2:U("lr",b)?3:-1;N!==-1&&(x[N]=T,y[N]=b+2)}}for(let C=0;C<4;C++)if(x[C]>=E)return C;return-1},R=E=>{if(E<_||E>S){let C=f(E),A=C===-1?t:Y(E);_=E,S=A,P.fill(-1);for(let T=C;T!==-1&&T<A;T=f(T+1)){let b=e.charCodeAt(T+2)|32;P[(e.charCodeAt(T)===60?0:3)+(b===102?0:b===106?1:2)]=T}}for(let C=0;C<6;C++)if(P[C]>=E)return C;return-1},L=(E,C)=>{let A=u(E);return A===-1||A+2>C?(k(14,E,C),!0):A===E?(i=C,!1):(k(14,E,A),!0)},F=E=>(n.push(E),r.push(""),o.push(i),{types:n,texts:r,starts:o,error:c});for(;;){if(i>=t){switch(a){case 0:k(2,t,t);break;case 6:k(22,t,t);break;case 7:k(24,t,t);break;case 8:k(25,t,t);break;case 10:k(32,t,t);break;case 12:k(39,t,t);break;case 14:k(36,t,t);break;case 3:k(12,t,t);break;case 18:k(20,t,t);break;case 4:case 19:k(14,t,t);break}return F(0)}let E=e.charCodeAt(i);switch(a){case 0:case 1:{let C=a===0,A=E|32;if(C){if(A===99&&U("click",i)&&!Qe(e.charCodeAt(i+5))){k(26,i,i+5);continue}if(A===104&&U("href",i)&&!Qe(e.charCodeAt(i+4))){k(28,i,i+4);continue}if(E===34){let N=e.indexOf('"',i+1);if(N!==-1){k(27,i,N+1);continue}}if(A===100&&U("default",i)&&!Qe(e.charCodeAt(i+7))){k(33,i,i+7);continue}let b=z(i);if(b!==-1){k(40+b,i,q(y[b]));continue}if(E===10){let N=i+1;for(;e.charCodeAt(N)===10;)N++;k(2,i,N);continue}if(Be(E)){i=M(i);continue}}else if(E!==10&&Be(E)){let b=i+1;for(;b<t&&e.charCodeAt(b)!==10&&Be(e.charCodeAt(b));)b++;i=b;continue}if(E===35||E===37&&e.charCodeAt(i+1)===37&&e.charCodeAt(i+2)!==123){i=q(i);continue}if(A===115){if(C&&U("scale",i)){let b=M(i+5);if(b>i+5){k(7,i,b),I(5);continue}}if(U("style",i)){let b=M(i+5);if(b>i+5){k(34,i,b),I(13);continue}}if(U("state",i)){let b=M(i+5);if(b>i+5){i=b,I(2);continue}if(C&&U("diagram",i+5)){let N=U("-v2",i+12)?i+15:i+12;if(b=M(N),b>N){k(3,i,b);continue}}}}else if(A===99){if(U("class",i)){let b=U("def",i+5),N=b?i+8:i+5,$=M(N);if($>N){k(b?29:37,i,$),I(b?9:11);continue}}}else if(A===97&&C&&(U("acctitle",i)||U("accdescr",i))){let b=(e.charCodeAt(i+3)|32)===116,N=M(i+8),$=e.charCodeAt(N);if($===58){k(b?21:23,i,M(N+1)),I(b?6:7);continue}if($===123&&!b){i=M(N+1),I(8);continue}}if(C){if(E===123){k(10,i,i+1),I(1);continue}}else{let b=z(i);if(b!==-1){k(40+b,i,q(y[b]));continue}if(E===125){k(11,i,i+1),D();continue}if(E===10){i++;continue}}if(A===110&&U("note",i)){let b=M(i+4);if(b>i+4){k(19,i,b),I(15);continue}}if(C&&A===104&&U("hide empty description",i)&&!Qe(e.charCodeAt(i+22))){k(6,i,i+22);continue}if(E===91&&e.charCodeAt(i+1)===42&&e.charCodeAt(i+2)===93){k(44,i,i+3);continue}let T=i;for(;T<t;){let b=e.charCodeAt(T);if(b===58||b===45||b===123||Be(b))break;T++}if(T>i){L(i,T);continue}if(E===58){for(T=i+1;T<t;){let b=e.charCodeAt(T);if(b===10||b===59)break;if(b===58){let N=e.charCodeAt(T+1);if(T+1>=t||N===58||N===10||N===59)break;T++}T++}if(T>i+1){w(4,e.slice(i,T).trim(),i,T);continue}if(e.charCodeAt(i+1)===58&&e.charCodeAt(i+2)===58){k(45,i,i+3);continue}}else if(E===45&&e.charCodeAt(i+1)===45){if(e.charCodeAt(i+2)===62){k(5,i,i+3);continue}if(!C){k(18,i,i+2);continue}}if(!C)return F(1);k(48,i,i+1);continue}case 2:{if(E!==10&&Be(E)){let b=i+1;for(;b<t&&e.charCodeAt(b)!==10&&Be(e.charCodeAt(b));)b++;i=b;continue}if(E===35||E===37&&e.charCodeAt(i+1)===37&&e.charCodeAt(i+2)!==123){i=q(i);continue}let C=R(i);if(C!==-1){let b=P[C],N=C===2||C===5;w(N?17:C%3===0?15:16,e.slice(i,b).trim(),i,b+(N?10:8)),D();continue}if(E===34){i++,I(3);continue}let A=E===10?M(i):i;if(U("as",A)){let b=M(A+2);if(b>A+2){k(13,i,b),I(4);continue}}if(E===10){i++,D();continue}if(E===123){k(10,i,i+1),D(),I(1);continue}if(Qe(E)){let b=Q(i),N=M(b);if(N>b&&Qe(e.charCodeAt(N))){let $=m(N+1);if($!==-1&&$<Y(N))return c=`Error: State name must be a single word. Found: "${e.slice(i,$+1).trim()}"`,F(1)}}let T=i+1;for(;T<t;){let b=e.charCodeAt(T);if(b===123||Be(b))break;T++}k(9,i,T);continue}case 3:{if(E===34){i++,D();continue}let C=e.indexOf('"',i);k(12,i,C===-1?t:C);continue}case 4:{let C=i;for(;C<t;){let A=e.charCodeAt(C);if(A===10||A===123)break;C++}L(i,C)&&D();continue}case 5:{if(E>=48&&E<=57){let A=i+1;for(;A<t&&e.charCodeAt(A)>=48&&e.charCodeAt(A)<=57;)A++;k(8,i,A);continue}let C=M(i);if(C>i&&U("width",C)&&!Qe(e.charCodeAt(C+5))){i=C+5,D();continue}return F(1)}case 6:k(22,i,q(i)),D();continue;case 7:k(24,i,q(i)),D();continue;case 8:{if(E===125){i++,D();continue}let C=e.indexOf("}",i);k(25,i,C===-1?t:C);continue}case 9:{let C=U("default",i)&&M(i+7)>i+7,A=C?i+7:Q(i),T=M(A);if(A===i||T===A)return F(1);k(C?31:30,i,T),D(),I(10);continue}case 10:k(32,i,q(i)),D();continue;case 11:{let C=Q(i);if(C===i)return F(1);for(;e.charCodeAt(C)===44;){let A=M(C+1),T=Q(A);if(T===A)break;C=T}k(38,i,C),D(),I(12);continue}case 12:k(39,i,q(i)),D();continue;case 13:{let C=i;for(;C<t&&(Qe(e.charCodeAt(C))||e.charCodeAt(C)===44);)C++;let A=M(C);if(C===i||A===C)return F(1);k(35,i,A),D(),I(14);continue}case 14:k(36,i,q(i)),D();continue;case 15:{if(U("left of",i)&&!Qe(e.charCodeAt(i+7))){k(46,i,i+7),D(),I(16);continue}if(U("right of",i)&&!Qe(e.charCodeAt(i+8))){k(47,i,i+8),D(),I(16);continue}if(E===34){i++,D(),I(18);continue}return F(1)}case 16:{let C=M(i),A=C;for(;A<t;){let T=e.charCodeAt(A);if(T===58||T===45||Be(T))break;A++}if(A===C)return F(1);L(i,A)&&(D(),I(17));continue}case 17:{let C=M(i);if(e.charCodeAt(C)===58){let b=C+1;for(;b<t;){let N=e.charCodeAt(b);if(N===58||N===10||N===59)break;b++}if(b>C+1){w(20,e.slice(i+2,b).trim(),i,b),D();continue}}let A=e.indexOf(`
127
+ `,i),T=-1;for(;A!==-1&&(T=M(A),!(U("end note",T)&&!Qe(e.charCodeAt(T+8))));)A=e.indexOf(`
128
+ `,T);if(A===-1)return F(1);w(20,e.slice(i,T).trim(),i,T+8),D();continue}case 18:{let C=M(i);if(U("as",C)){k(13,i,M(C+2)),D(),I(19);continue}if(E===34){i++;continue}let A=e.indexOf('"',i);k(20,i,A===-1?t:A);continue}case 19:L(i,q(i))&&D();continue}}}var CI=["TB","BT","RL","LR"],sl="'NL', 'ID', 'HIDE_EMPTY', 'scale', 'COMPOSIT_STATE', 'STATE_DESCR', 'FORK', 'JOIN', 'CHOICE', 'CONCURRENT', 'note', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'CLICK', 'classDef', 'style', 'class', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'EDGE_STATE'";function i0(e,t){let{types:n,texts:r,starts:o,error:s}=s0(e),a=0,i=h=>{let g=n[a];throw g===1?s!==void 0?new Ge(s,"syntax",{type:"state",...vi(e,o[a])}):it("state",e,o[a],"",!0):it("state",e,o[a],`Expecting ${h}, got '${If[g]}'`)},c=h=>(n[a]!==h&&i(`'${If[h]}'`),r[a++]),l=()=>{let h=n[a];h!==14&&h!==44&&i("'ID', 'EDGE_STATE'");let g=r[a++].trim();return n[a]!==45?{stmt:"state",id:g,type:"default",description:""}:(a++,{stmt:"state",id:g,classes:[c(14).trim()],type:"default",description:""})};for(;n[a]===2;)a++;n[a]!==3&&i("'NL', 'SD'"),a++;let f=[],p=[],u=h=>{h!=="nl"&&f.push(h)},m=(h,g)=>{a++;let x=[];f.push({stmt:"state",id:h,type:"default",description:g,doc:x}),p.push(f),f=x};for(;;){let h=n[a];switch(h){case 2:a++;break;case 14:case 44:{let g=l();if(n[a]===4)g.description=t.trimColon(r[a++]),u(g);else if(n[a]===5){a++;let x=l();n[a]===4?u({stmt:"relation",state1:g,state2:x,description:t.trimColon(r[a++])}):u({stmt:"relation",state1:g,state2:x})}else u(g);break}case 6:u(r[a++]);break;case 7:a++,c(8),u(r[a-2]);break;case 9:n[a+1]===10?m(r[a++],""):u(r[a++]);break;case 12:{let g=r[a++];c(13);let x=c(14);if(n[a]===10)m(x,g);else if(x.includes(":")){let y=x.split(":");u({stmt:"state",id:y[0],type:"default",description:[g.trim(),y[1]]})}else u({stmt:"state",id:x,type:"default",description:g.trim()});break}case 15:u({stmt:"state",id:r[a++],type:"fork"});break;case 16:u({stmt:"state",id:r[a++],type:"join"});break;case 17:u({stmt:"state",id:r[a++],type:"choice"});break;case 18:a++,u({stmt:"state",id:t.getDividerId(),type:"divider"});break;case 19:{let g=r[a++];if(n[a]===46||n[a]===47){let x=r[a++].trim(),y=c(14).trim();u({stmt:"state",id:y,note:{position:x,text:c(20).trim()}})}else n[a]!==20&&i("'NOTE_TEXT', 'left_of', 'right_of'"),a++,c(13),c(14),u(g);break}case 40:case 41:case 42:case 43:{let g=CI[h-40];a++,t.setDirection(g),u({stmt:"dir",value:g});break}case 21:{a++;let g=c(22).trim();t.setAccTitle(g),u(g);break}case 23:{a++;let g=c(24).trim();t.setAccDescription(g),u(g);break}case 25:{let g=r[a++].trim();t.setAccDescription(g),u(g);break}case 26:{a++;let g=l(),x,y="";n[a]===28?(a++,x=c(27)):(n[a]!==27&&i("'STRING', 'HREF'"),x=r[a++],y=c(27)),c(2),u({stmt:"click",id:g,url:x,tooltip:y});break}case 29:{a++;let g=c(30).trim();u({stmt:"classDef",id:g,classes:c(32).trim()});break}case 34:{a++;let g=c(35).trim();u({stmt:"style",id:g,styleClass:c(36).trim()});break}case 37:{a++;let g=c(38).trim();u({stmt:"applyClass",id:g,styleClass:c(39).trim()});break}case 11:p.length===0&&i(`'$end', ${sl}`),a++,f=p.pop();break;case 0:return p.length>0&&i(`'STRUCT_STOP', ${sl}`),t.setRootDoc(f),f;default:i(p.length>0?`'STRUCT_STOP', ${sl}`:`'$end', ${sl}`)}}}var II=40,NI=16,MI=44,Ni=16,Nf=10,kI=16,o0=10,Mf=26,a0=8,LI=320,kf=10,c0=8,l0=' fill="var(--_s)" stroke="var(--_b)"',il=' fill="none" stroke="var(--_b)"',$I=/(?:^| )statediagram-(?:state|cluster-alt|cluster|note)(?= |$)/g;var DI=new Map([["rectWithTitle",1],["stateStart",2],["stateEnd",3],["choice",4],["fork",5],["join",6],["note",7],["divider",10]]),OI=["pele-node pele-state","pele-node pele-state","pele-node pele-state-start","pele-node pele-state-end","pele-node pele-state-choice","pele-node pele-state-fork","pele-node pele-state-join","pele-note","pele-cluster pele-state-composite"];function d0(e){return e==="TB"||e==="BT"}function Lf(e,t,n){let r=e.state?.[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}function u0(e){let t=0,n=e.length;for(;t<n&&e.charCodeAt(t)===34;)t++;for(;n>t&&e.charCodeAt(n-1)===34;)n--;return e.slice(t,n)}function f0(e,t,n){return e<t?t:e>n?n:e}function ol(e,t,n,r,o){return`<rect x="${d(e)}" y="${d(t)}" width="${d(n)}" height="${d(r)}"${o}/>`}function al(e,t,n,r){let o=$t(0,0);return o.isGroup=!0,o.dir=e,o.padX=t,o.padTop=n,o.padBottom=r,o}function h0(e,t,n){return _n(e.direction)?Nt(n,r=>p0(e,t,n,r)):p0(e,t,n,!1)}function p0(e,t,n,r){let o=e.graph,s=n.fontSize??16,a=Math.round(s*.875),i=n.measurer??Je(n.fontFamily),c=Lf(t,"wrappingWidth",200),l=n.padding??8,f=n.icons,p=r?"TB":tn(e.direction),u=De(void 0,!1,i,s,0),m=(de,oe,ye,ce=0)=>De(de,!0,i,oe,ye,ce),h=new Map,g=[],x=[],y=(de,oe,ye)=>(g.push({node:de,kind:oe,style:void 0,label:u,lines:[],w:0,h:0,titleH:0}),ye&&x.push(ye),g.length-1);for(let de of o.nodes){if(de.shape==="noteGroup")continue;let oe=de.isGroup?de.shape==="divider"?9:8:DI.get(de.shape)??0;h.set(de.id,y(de,oe,void 0))}let _=g.length,S=[];for(let de=0;de<_;de++){let oe=g[de].node.parentId,ye=oe===void 0?void 0:h.get(oe);S.push(ye!==void 0&&ye!==de&&g[ye].node.isGroup?ye:-1)}{let de=[];for(let be=0;be<_;be++)de.push([]);let oe=[],ye=new Uint8Array(_);for(let be=0;be<_;be++)S[be]===-1?(ye[be]=1,oe.push(be)):de[S[be]].push(be);let ce=0,fe=()=>{for(;ce<oe.length;ce++)for(let be of de[oe[ce]])ye[be]||(ye[be]=1,oe.push(be))};fe();let xe=new Int32Array(_).fill(-1);for(let be=0;be<_;be++){if(ye[be])continue;let re=be;for(;xe[re]!==be;)xe[re]=be,re=S[re];S[re]=-1,ye[re]=1,oe.push(re),fe()}}let P=new Int32Array(_).fill(-1);for(let de=0;de<_;de++){let oe=g[de].node.noteFor,ye=oe===void 0?void 0:h.get(oe);ye!==void 0&&(P[de]=ye,S[de]=S[ye])}let k=de=>tn(g[de].node.dir),w=de=>d0(S[de]===-1?p:k(S[de])),I=new Int32Array(_),D=new Uint8Array(_),U=new Array(_).fill(1/0),M=0,Q=new Int32Array(2*_);for(let de of o.edges){let oe=h.get(de.start),ye=h.get(de.end);if(!(oe===void 0||ye===void 0)){if(de.pattern==="dashed"){D[g[oe].kind===7?ye:oe]=1;continue}I[oe]=Math.max(I[oe],++Q[2*oe]),I[ye]=Math.max(I[ye],++Q[2*ye+1]),U[oe]===1/0&&(U[oe]=M++),U[ye]===1/0&&(U[ye]=M++)}}for(let de=0;de<_;de++){let oe=g[de],ye=oe.node,ce=At(ye.cssStyles.length>0?ye.cssCompiledStyles.concat(ye.cssStyles):ye.cssCompiledStyles),fe=(ce.bold?1:0)|(ce.italic?2:0),xe=ce.fontSize??s;oe.style=ce;let be;switch(oe.kind){case 8:oe.label=m(ye.label,xe,4e3,fe),oe.titleH=oe.label.height>0?oe.label.height+12:0,be=al(k(de),Ni,oe.titleH+Ni,Ni),be.minW=oe.label.width+2*Ni;break;case 9:be=al(k(de),Nf,Nf,Nf);break;case 2:oe.w=oe.h=14;break;case 3:oe.w=oe.h=18;break;case 4:oe.w=oe.h=30;break;case 5:case 6:{let re=f0(40*I[de]+16,72,320);oe.w=w(de)?re:c0,oe.h=w(de)?c0:re;break}case 10:break;case 7:oe.label=m(ye.label,a,Math.max(c,LI)),oe.w=oe.label.width+24,oe.h=oe.label.height+16;break;default:{oe.label=m(ye.label,xe,c,fe);let re=oe.label.width,j=oe.label.height+2*o0;if(oe.kind===1){j+=14;for(let ie of ye.description){let ue=m(ie===""?" ":ie,a,c,fe);oe.lines.push(ue),ue.width>re&&(re=ue.width),j+=ue.height}}oe.w=Math.max(re+2*kI,56),oe.h=j}}be??=$t(oe.w,oe.h),(oe.kind===0||oe.kind===1)&&(be.span=(w(de)?oe.w:oe.h)-24),x.push(be)}let q=[],Y=[],z=[],R=new Int32Array(_),L=new Float64Array(_),F=new Float64Array(_),E=new Map,C=(de,oe)=>{if(!x[de].isGroup)return!1;for(let ye=S[oe];ye!==-1;ye=S[ye])if(ye===de)return!0;return!1},A=(de,oe)=>(E.set(q.length,de),U.push(oe?-1:1/0),y(void 0,10,$t(0,0,de)));for(let de of o.edges){let oe=h.get(de.start),ye=h.get(de.end);if(oe===void 0||ye===void 0)continue;let ce=m(de.label,a,c),fe=ce.width>0?ce.width+12:0;oe===ye?(R[oe]++,L[oe]=Math.max(L[oe],fe),F[oe]+=ce.height):C(oe,ye)?oe=A(oe,!0):C(ye,oe)&&(ye=A(ye,!1)),z.push(de),Y.push(ce),q.push({src:oe,dst:ye,minlen:1,labelW:fe,labelH:ce.height>0?ce.height+4:0,route:[],labelX:0,labelY:0})}for(let de=0;de<_;de++){if(P[de]!==-1)continue;let oe=x[de],ye=0;if(R[de]>0){let fe=Mf+(R[de]-1)*8;ye=w(de)?fe+L[de]:fe*.75+4+F[de],oe.isGroup||(w(de)?(oe.w+=2*ye,oe.h=Math.max(oe.h,F[de])):(oe.h+=2*ye,oe.w=Math.max(oe.w,L[de])),ye=0)}if(!D[de]&&ye===0){oe.parent=S[de];continue}let ce=w(de)?al("LR",ye,0,0):al("TB",0,ye,ye);ce.parent=S[de],U.push(U[de]),x[de].parent=y(void 0,10,ce)}for(let de=0;de<_;de++)P[de]!==-1&&(x[de].parent=x[P[de]].parent);{let de=[];for(let be=0;be<x.length;be++)de.push([]);let oe=[];for(let be=0;be<x.length;be++){let re=x[be].parent;re>=0?de[re].push(be):oe.push(be)}let ye=be=>g[be].kind===2?0:1,ce=(be,re)=>ye(be)-ye(re)||(U[be]===U[re]?0:U[be]<U[re]?-1:1)||be-re,fe=0,xe=oe.sort(ce).reverse();for(;xe.length>0;){let be=xe.pop();x[be].seq=fe++;let re=de[be].sort(ce);for(let j=re.length-1;j>=0;j--)xe.push(re[j])}}let T=Sn(x,q,p,{nodeSep:Lf(t,"nodeSpacing",II),edgeSep:NI,rankSep:Lf(t,"rankSpacing",MI),portSep:20,headRoom:ht("arrow_point")}),b=Math.ceil(T.width+2*l),N=Math.ceil(T.height+2*l),$=[],X=new Map;for(let de of q){let oe=de.route;for(let ye=3;ye<oe.length-3;ye+=3){let ce=Math.round(oe[ye+1]),fe=X.get(ce);fe?fe.push(oe[ye]):X.set(ce,[oe[ye]])}}let V=[];for(let de=0;de<x.length;de++)V.push([]);let O=[];for(let de=0;de<x.length;de++){let oe=x[de].parent;oe>=0?V[oe].push(de):O.push(de)}let v=O.slice();for(let de=0;de<O.length;de++)for(let oe of V[O[de]])O.push(oe);let W="",H="",G="",te="",Z=(de,oe,ye,ce,fe)=>{let xe=de.filter(j=>g[j].kind===9);if(xe.length<2)return;let be=(j,ie)=>ie?x[j].x-x[j].w/2:x[j].y-x[j].h/2,re=(j,ie)=>ie?x[j].x+x[j].w/2:x[j].y+x[j].h/2;for(let j of[!0,!1]){let ie=xe.slice().sort((ge,Se)=>be(ge,j)-be(Se,j)||ge-Se),ue=!0;for(let ge=1;ge<ie.length;ge++)re(ie[ge-1],j)>be(ie[ge],j)+.5&&(ue=!1);if(ue){for(let ge=1;ge<ie.length;ge++){let Se=d((re(ie[ge-1],j)+be(ie[ge],j))/2+l);H+=`<path class="pele-divider" d="M${j?`${Se},${d(ye)}V${d(fe)}`:`${d(oe)},${Se}H${d(ce)}`}"/>`}return}}for(let j of xe){let ie=x[j];H+=ol(ie.x-ie.w/2+l,ie.y-ie.h/2+l,ie.w,ie.h,` class="pele-divider" rx="${kf}"`)}};Z(v,l/2,l/2,b-l/2,N-l/2);for(let de of O){let oe=g[de],ye=oe.node,ce=oe.style;if(ye===void 0||ce===void 0||oe.kind>=9)continue;let fe=x[de],xe=fe.x+l,be=fe.y+l,re=oe.w,j=oe.h,ie=` class="pele-label"${ce.text}`,ue;switch(oe.kind){case 8:{let we=xe-fe.w/2,ke=be-fe.h/2;ue=ol(we,ke,fe.w,fe.h,` rx="${kf}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${ce.shape}`),oe.titleH>0&&(ue+=`<path d="M${d(we)},${d(ke+oe.titleH)}H${d(we+fe.w)}"${il}${ce.line}/>`+Ie(oe.label,vI(fe,oe.label.width,X)+l,ke+oe.titleH/2,` class="pele-cluster-label"${ce.text}`,f)),Z(V[de],we,ke+oe.titleH,we+fe.w,ke+fe.h);break}case 2:ue=`<circle r="7" fill="var(--_l)"${ce.shape}/>`;break;case 3:ue=`<circle r="8.5" fill="var(--_bg)" stroke="var(--_l)"${ce.line}/><circle r="5" fill="var(--_l)"${ce.shape}/>`;break;case 4:ue=`<polygon points="0,${d(-j/2)} ${d(re/2)},0 0,${d(j/2)} ${d(-re/2)},0"${l0}${ce.shape}/>`;break;case 5:case 6:ue=ol(-re/2,-j/2,re,j,` rx="2" fill="var(--_l)"${ce.shape}`);break;case 7:{let we=d(re/2),ke=d(j/2),Le=d(re/2-a0),Fe=d(a0-j/2);ue=`<path d="M-${we},-${ke}H${Le}L${we},${Fe}V${ke}H-${we}Z" fill="var(--_bg)" stroke="var(--_b)"/><path d="M${Le},-${ke}V${Fe}H${we}"${il}/>`+Ie(oe.label,0,0,` class="pele-label" font-size="${a}" fill="var(--_m)"`,f);break}default:{if(ue=ol(-re/2,-j/2,re,j,` rx="${d(Math.min(kf,j/2))}"${l0}${ce.shape}`),oe.kind===0){ue+=Ie(oe.label,0,0,ie,f);break}let we=o0-j/2+oe.label.height;ue+=`<path d="M${d(-re/2)},${d(we+6)}H${d(re/2)}"${il}${ce.line}/>`+Ie(oe.label,0,we-oe.label.height/2,ie,f),we+=14;for(let ke of oe.lines)ue+=Ie(ke,0,we+ke.height/2,` class="pele-state-description" font-size="${a}"${ce.text}`,f),we+=ke.height}}let ge=e.links.get(ye.id);if(ge){let we=gt(u0(ge.tooltip));we&&(ue=`<title>${je(we)}</title>`+ue),ue=Pn(ue,vn(u0(ge.url)),ye.id,$,n,' target="_blank"')}let Se=`<g class="${OI[oe.kind]}${wt(ye.cssClasses.replace($I,""))}" data-id="${$e(ye.id)}"`;oe.kind===8?W+=`${Se}>${ue}</g>`:oe.kind===7?te+=`${Se} transform="translate(${d(xe)},${d(be)})">${ue}</g>`:G+=`${Se} transform="translate(${d(xe)},${d(be)})">${ue}</g>`}let B=(de,oe,ye)=>{let ce=x[ye];if(ce.isGroup)return;let fe=g[ye],xe=fe.kind===5||fe.kind===6,be=oe===0?3:oe-3;for(let re of[1,0]){let j=re?ce.h:ce.w,ie=re?fe.h:fe.w,ue=re?fe.w:fe.h,ge=(re?ce.y:ce.x)+l,Se=(re?ce.x:ce.y)+l,we=de[oe+re]-ge;if(!(Math.abs(Math.abs(we)-j/2)>=.5)){de[oe+re]-=Math.sign(we)*(j-ie)/2,xe&&ue>ie&&(de[oe+1-re]=f0(de[be+1-re],Se-ue/2+6,Se+ue/2-6));return}}},K=pa();for(let de=0;de<q.length;de++){let oe=q[de];oe.src===oe.dst||oe.route.length<6||z[de].pattern==="dashed"||K.add(oe.dst,Bn(oe.route,oe.route.length-3,x[oe.dst]),"arrow_point")}let ee="",ae="",J=new Int32Array(_),se=new Float64Array(_);for(let de=0;de<q.length;de++){let oe=q[de],ye=z[de],ce=Y[de],fe=ye.pattern==="dashed",xe=fe?"none":"arrow_point",be;if(oe.src===oe.dst){let re=x[oe.src],j=g[oe.src],ie=J[oe.src]++,ue=w(oe.src),ge=re.isGroup?re.w:j.w,Se=re.isGroup?re.h:j.h,we=(ue?ge:Se)/2,ke=Math.max(Math.min((ue?Se:ge)/2-4,8+ie*6),2),Le=Mf+ie*8,Fe=ht(xe)/(Math.hypot(Le,ke)||1),He=(ne,pe)=>re.x+l+(ue?we+ne:-pe),_e=(ne,pe)=>re.y+l+(ue?pe:we+ne),Pe=(ne,pe)=>`${d(He(ne,pe))},${d(_e(ne,pe))}`;be={d:`M${Pe(0,-ke)}C${Pe(Le,-2*ke)} ${Pe(Le,2*ke)} ${Pe(Le*Fe,ke+ke*Fe)}`,sx:0,sy:0,sdx:0,sdy:0,ex:He(0,ke),ey:_e(0,ke),edx:He(-Le,-ke)-He(0,0),edy:_e(-Le,-ke)-_e(0,0)};let Ye=Math.hypot(be.edx,be.edy)||1;be.edx/=Ye,be.edy/=Ye;let Ue=Mf+(R[oe.src]-1)*8,he=se[oe.src]+ce.height/2;se[oe.src]+=ce.height,oe.labelX=ue?re.x+we+Ue+4+oe.labelW/2:re.x,oe.labelY=ue?re.y-F[oe.src]/2+he:re.y+we+Ue*.75+4+he}else{let re=oe.route.slice(),j=K.of(oe.src,Bn(re,0,x[oe.src])),ie=K.of(oe.dst,Bn(re,re.length-3,x[oe.dst]));for(let ge=0;ge<re.length;ge+=3)re[ge]+=l,re[ge+1]+=l;B(re,0,oe.src),B(re,re.length-3,oe.dst);let ue=E.get(de);if(ue!==void 0&&re.length>=6){let ge=x[ue],Se=g[oe.src].kind===10,we=Se?0:re.length-3,ke=(ge.dir==="TB"||ge.dir==="LR")===Se,Le=d0(ge.dir)?[re[we],ge.y+l+(ke?g[ue].titleH-ge.h/2:ge.h/2),0]:[ge.x+l+(ke?-ge.w/2:ge.w/2),re[we+1],1];re=Se?Le.concat(re):re.concat(Le)}be=yn(re,void 0,0,ht(xe),j,ie)}if(ee+=`<g class="pele-edge ${fe?'pele-note-edge" stroke="var(--_b)" stroke-dasharray="3 4':"pele-transition"}" data-id="${$e(ye.id)}"><path d="${be.d}"/>`+bt(xe,be.ex,be.ey,be.edx,be.edy,"var(--_l)")+"</g>",ce.width>0){let re=oe.labelX+l,j=oe.labelY+l;ae+=nn(ye.id,ce,re,j,"",f)}}let me=Ba(e.title,i,s,l,b,N,(W?`<g class="pele-clusters">${W}</g>`:"")+(H?`<g class="pele-dividers" stroke-dasharray="4 4"${il}>${H}</g>`:"")+(ee?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${ee}</g>`:"")+(ae?`<g class="pele-edge-labels" font-size="${a}">${ae}</g>`:"")+`<g class="pele-nodes">${G}${te}</g>`);return{svg:Ze("state",me.width,me.height,s,n,e,me.content),width:me.width,height:me.height,links:$}}function vI(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(r===void 0||t===0)return e.x;let o=e.x-e.w/2,s=t/2,a=e.x,i=-1;for(let c of[e.x,o+Ni+s,o+e.w-Ni-s]){let l=1/0;for(let f of r)f>o&&f<o+e.w&&(l=Math.min(l,Math.abs(f-c)-s));if(l>=6)return c;l>i+.5&&(i=l,a=c)}return a}var m0={type:"state",parse(e,t,n){let r=new rl;return n&&(r.title=n),i0(e,r),r},render:h0};var PI=34,BI=24,FI=8,WI=2e4,g0=1e4,$f=2e6,b0=4,UI=3,y0=8,Df=20,E0=20,A0=14,GI=3;function S0(e,t,n,r,o=BI){let s=e.length;if(s===0)return{width:0,height:0};let a=n==="LR"||n==="RL",i=n==="BT"||n==="RL",c=[];for(let Y=s-1;Y>=0;Y--)e[Y].parent<0&&e[Y].isGroup&&c.push(Y);let l=Math.max(1,c.length),f=new Int32Array(s).fill(-1);c.forEach((Y,z)=>f[Y]=z);let p=new Uint8Array(s);for(let Y=0;Y<s;Y++)e[Y].parent>=0&&(p[e[Y].parent]=1);let u=new Float64Array(l).fill(o),m=o,h=Y=>{let z=Y,R=o;for(let F=0;e[z].parent>=0&&F<g0;F++)z=e[z].parent,f[z]<0&&(R+=Math.max(e[z].padX,e[z].padTop,e[z].padBottom));let L=Math.max(0,f[z]);return R>u[L]&&(u[L]=R),R>m&&(m=R),L},g=new Int32Array(s).fill(-1),x=[];for(let Y=0;Y<s;Y++)f[Y]>=0||(!e[Y].isGroup||!p[Y])&&(g[Y]=x.length,x.push(Y));let y=Y=>a?Y.w:Y.h,_=Y=>a?Y.h:Y.w,S=x.map(Y=>ti(_(e[Y]),y(e[Y]))),P=[],k=[],w=1;{let Y=new Set;for(let z=0;z<t.length;z++){let R=t[z],L=g[R.src],F=g[R.dst];if(L<0||F<0||L===F)continue;let E=Math.min(L,F)*x.length+Math.max(L,F);(R.labelW>0||Y.has(E))&&(w=2),Y.add(E),P.push(ni(L,F,R.minlen,a?R.labelH:R.labelW,a?R.labelW:R.labelH)),k.push(z)}}Hi(S,P),Ki(S,P,w);let I=P.length,D=Int32Array.from(x,h),U=(Y,z)=>{let R=u.map((ne,pe)=>z[pe]?Math.max(ne,E0):ne),L=new Uint8Array(l),F=0,E=new Int32Array(I);for(let ne=0;ne<I;ne++)E[ne]=Math.abs(S[P[ne].head].rank-S[P[ne].tail].rank),Y[ne]||(F+=E[ne]-1);let C=F>WI,A=x.length+(C?0:F),T=new Int32Array(A),b=new Int32Array(A),N=new Float64Array(A),$=new Float64Array(A),X=new Uint8Array(A),V=0;for(let ne=0;ne<x.length;ne++)T[ne]=S[ne].rank,b[ne]=D[ne],N[ne]=S[ne].w,$[ne]=S[ne].h,T[ne]>V&&(V=T[ne]);let O=new Int32Array(I).fill(-1),v=new Int32Array(I).fill(-1),W=[];{let ne=x.length;for(let pe=0;pe<I;pe++){let Re=P[pe],le=Re.reversed?Re.head:Re.tail,Ee=Re.reversed?Re.tail:Re.head;if(C||E[pe]<2||Y[pe]){W.push(le,Ee);continue}let Ne=T[le],Me=T[Ee],Ce=-1;Re.labelW>0&&(Ce=Ne+(Me-Ne>>1),w===2&&(Ce&1)===0&&Ce--),O[pe]=ne;let Oe=le;for(let We=Ne+1;We<Me;We++){let Te=ne++;T[Te]=We,b[Te]=b[le]+Math.round((b[Ee]-b[le])*(We-Ne)/(Me-Ne)),X[Te]=1,We===Ce&&(N[Te]=Re.labelW,$[Te]=Re.labelH,v[pe]=Te),W.push(Oe,Te),Oe=Te}W.push(Oe,Ee)}}let H=new Int32Array(A+1),G=new Int32Array(A+1);for(let ne=0;ne<W.length;ne+=2)G[W[ne]+1]++,H[W[ne+1]+1]++;for(let ne=0;ne<A;ne++)H[ne+1]+=H[ne],G[ne+1]+=G[ne];let te=new Int32Array(W.length/2),Z=new Int32Array(W.length/2);{let ne=H.slice(0,A),pe=G.slice(0,A);for(let Re=0;Re<W.length;Re+=2)Z[pe[W[Re]]++]=W[Re+1],te[ne[W[Re+1]]++]=W[Re]}let B=[];for(let ne=0;ne<=V;ne++)B.push([]);for(let ne=0;ne<A;ne++)B[T[ne]].push(ne);let K=new Float64Array(A),ee=new Float64Array(A),ae=ne=>{ne.sort((pe,Re)=>b[pe]-b[Re]||ee[pe]-ee[Re]||pe-Re);for(let pe=0;pe<ne.length;pe++)K[ne[pe]]=pe};for(let ne of B){for(let pe=0;pe<ne.length;pe++)ee[ne[pe]]=pe;ae(ne)}for(let ne=0;ne<FI&&V>0;ne++){let pe=(ne&1)===0;for(let Re=1;Re<=V;Re++){let le=B[pe?Re:V-Re],Ee=pe?H:G,Ne=pe?te:Z;for(let Me of le){let Ce=0,Oe=Ee[Me+1]-Ee[Me];for(let We=Ee[Me];We<Ee[Me+1];We++)Ce+=K[Ne[We]];ee[Me]=Oe>0?Ce/Oe:K[Me]}ae(le)}}let J=(ne,pe)=>X[ne]||X[pe]?r.edgeSep:r.nodeSep,se=(ne,pe)=>{let Re=0;for(;Re<ne.length;){let le=Re;for(;le+1<ne.length&&b[ne[le+1]]===b[ne[Re]];)le++;pe(ne,Re,le),Re=le+1}},me=(ne,pe,Re)=>{let le=N[ne[pe]];for(let Ee=pe;Ee<Re;Ee++)le+=J(ne[Ee],ne[Ee+1])+N[ne[Ee+1]];return le},Ae=new Float64Array(l),de=c.length>0?PI:0;for(let ne=0;ne<c.length;ne++){let pe=e[c[ne]];Ae[ne]=Math.max(0,pe.minW-2*R[ne]),pe.padTop>de&&(de=pe.padTop)}for(let ne of B)se(ne,(pe,Re,le)=>{let Ee=me(ne,Re,le);Ee>Ae[b[ne[Re]]]&&(Ae[b[ne[Re]]]=Ee)});let oe=new Float64Array(l+1);for(let ne=0;ne<l;ne++)oe[ne+1]=oe[ne]+Ae[ne]+2*R[ne];let ye=new Float64Array(A),ce=new Float64Array(A),fe=(ne,pe,Re)=>{let le=b[ne[pe]],Ee=(oe[le]+R[le]+(oe[le+1]-R[le])-me(ne,pe,Re))/2;for(let Ne=pe;Ne<=Re;Ne++)ye[ne[Ne]]=Ee+N[ne[Ne]]/2,Ne<Re&&(Ee+=N[ne[Ne]]+J(ne[Ne],ne[Ne+1]))},xe=(ne,pe,Re)=>{let le=b[ne[pe]],Ee=oe[le]+R[le];for(let Me=pe;Me<=Re;Me++){let Ce=ne[Me];ye[Ce]=Math.max(ce[Ce],Ee+N[Ce]/2),Me<Re&&(Ee=ye[Ce]+N[Ce]/2+J(Ce,ne[Me+1]))}let Ne=oe[le+1]-R[le];for(let Me=Re;Me>=pe;Me--){let Ce=ne[Me];ye[Ce]=Math.min(ye[Ce],Ne-N[Ce]/2),Me>pe&&(Ne=ye[Ce]-N[Ce]/2-J(ne[Me-1],Ce))}};for(let ne of B)se(ne,fe);for(let ne=0;ne<4&&V>0;ne++){let pe=(ne&1)===0;for(let Re=1;Re<=V;Re++){let le=B[pe?Re:V-Re],Ee=pe?H:G,Ne=pe?te:Z;for(let Me of le){let Ce=0,Oe=0;for(let We=Ee[Me];We<Ee[Me+1];We++)b[Ne[We]]===b[Me]&&(Ce+=ye[Ne[We]],Oe++);ce[Me]=Oe>0?Ce/Oe:ye[Me]}se(le,xe)}}let be=new Float64Array(V+1),re=new Float64Array(V+1),j=new Float64Array(V+1).fill(r.rankSep/w);if(Y.some(ne=>ne===1)){let ne=r.rankSep/w;j.fill(ne/GI);for(let pe=0;pe<I;pe++){let Re=P[pe],le=Re.reversed?Re.head:Re.tail,Ee=Re.reversed?Re.tail:Re.head;if(Y[pe]){if(Re.labelH<=0||E[pe]>w)continue;let Me=Math.min(ne,(Re.labelH+2*Df-Math.min($[le],$[Ee])/2)/E[pe]);for(let Ce=T[le];Ce<T[Ee];Ce++)Me>j[Ce]&&(j[Ce]=Me);continue}let Ne=O[pe];if(Ne<0||E[pe]<=w*Re.minlen){for(let Me=T[le];Me<T[Ee];Me++)j[Me]=ne;continue}for(let Me=Ne-1;Me<Ne+E[pe]-1;Me++){let Ce=Me<Ne?le:Me,Oe=Me+1<Ne+E[pe]-1?Me+1:Ee;(b[Ce]!==b[Oe]||Math.abs(ye[Ce]-ye[Oe])>=.5)&&(j[T[Ce]]=ne)}}}let ie=de+m;for(let ne=0;ne<=V;ne++){let pe=0;for(let Re of B[ne])$[Re]>pe&&(pe=$[Re]);be[ne]=ie,re[ne]=ie+pe,ie+=pe+(ne===V?0:j[ne])}let ue=ie+m,ge=oe[l],Se=ne=>i?de+ue-ne:ne,we=(ne,pe)=>a?Se(pe):ne,ke=(ne,pe)=>a?ne:Se(pe),Le=a?1:0;for(let ne=0;ne<x.length;ne++){let pe=e[x[ne]],Re=(be[T[ne]]+re[T[ne]])/2;pe.x=we(ye[ne],Re),pe.y=ke(ye[ne],Re)}for(let ne=0;ne<c.length;ne++){let pe=e[c[ne]],Re=(oe[ne]+oe[ne+1])/2,le=oe[ne+1]-oe[ne];pe.x=a?ue/2:Re,pe.y=a?Re:ue/2,pe.w=a?ue:le,pe.h=a?le:ue,pe.padTop=de}let Fe=new Int32Array(s),He=[];for(let ne=0;ne<s;ne++){if(!e[ne].isGroup||f[ne]>=0||g[ne]>=0)continue;let pe=0;for(let Re=e[ne].parent;Re>=0&&pe<g0;Re=e[Re].parent)pe++;Fe[ne]=pe,He.push(ne)}He.sort((ne,pe)=>Fe[pe]-Fe[ne]||ne-pe);let _e=new Float64Array(s*4);for(let ne=0;ne<s;ne++)_e[ne*4]=1/0,_e[ne*4+1]=1/0,_e[ne*4+2]=-1/0,_e[ne*4+3]=-1/0;let Pe=(ne,pe)=>{pe.x-pe.w/2<_e[ne*4]&&(_e[ne*4]=pe.x-pe.w/2),pe.y-pe.h/2<_e[ne*4+1]&&(_e[ne*4+1]=pe.y-pe.h/2),pe.x+pe.w/2>_e[ne*4+2]&&(_e[ne*4+2]=pe.x+pe.w/2),pe.y+pe.h/2>_e[ne*4+3]&&(_e[ne*4+3]=pe.y+pe.h/2)};for(let ne of x)e[ne].parent>=0&&f[e[ne].parent]<0&&Pe(e[ne].parent,e[ne]);for(let ne of He){let pe=e[ne];if(_e[ne*4]===1/0)continue;let Re=Math.max(_e[ne*4+2]-_e[ne*4]+2*pe.padX,pe.minW);pe.x=(_e[ne*4]+_e[ne*4+2])/2,pe.w=Re,pe.y=(_e[ne*4+1]-pe.padTop+_e[ne*4+3]+pe.padBottom)/2,pe.h=_e[ne*4+3]-_e[ne*4+1]+pe.padTop+pe.padBottom,pe.parent>=0&&f[pe.parent]<0&&Pe(pe.parent,pe)}for(let ne of t)ne.route=[];for(let ne=0;ne<I;ne++){let pe=P[ne],Re=t[k[ne]],le=pe.reversed?pe.head:pe.tail,Ee=pe.reversed?pe.tail:pe.head,Ne=[ye[le],re[T[le]]-(re[T[le]]-be[T[le]]-$[le])/2],Me=O[ne];if(Me>=0)for(let We=Me;We<Me+E[ne]-1;We++)Ne.push(ye[We],be[T[We]]),re[T[We]]>be[T[We]]&&Ne.push(ye[We],re[T[We]]);Ne.push(ye[Ee],be[T[Ee]]+(re[T[Ee]]-be[T[Ee]]-$[Ee])/2);let Ce=[];for(let We=0;We<Ne.length;We+=2)Ce.push(we(Ne[We],Ne[We+1]),ke(Ne[We],Ne[We+1]),Le);if(pe.reversed)for(let We=0,Te=Ce.length-3;We<Te;We+=3,Te-=3)for(let Ke=0;Ke<2;Ke++){let ze=Ce[We+Ke];Ce[We+Ke]=Ce[Te+Ke],Ce[Te+Ke]=ze}Re.route=Ce;let Oe=v[ne];if(Oe>=0){let We=(be[T[Oe]]+re[T[Oe]])/2;Re.labelX=we(ye[Oe],We),Re.labelY=ke(ye[Oe],We)}else Re.labelX=(Ce[0]+Ce[Ce.length-3])/2,Re.labelY=(Ce[1]+Ce[Ce.length-2])/2}for(let ne of t){if(ne.route.length>0||ne.src===ne.dst)continue;let pe=e[ne.src],Re=e[ne.dst],[le,Ee]=x0(pe,Re),[Ne,Me]=x0(Re,pe),Ce=Math.abs(Ne-le)>Math.abs(Me-Ee)?1:0;ne.route=[le,Ee,Ce,Ne,Me,Ce],ne.labelX=(le+Ne)/2,ne.labelY=(Ee+Me)/2}let Ye=new Uint8Array(I),Ue=t.reduce((ne,pe)=>ne+pe.route.length/3,0),he=I*(x.length+t.length+Ue);if(he<=$f){let ne=Ce=>(be[T[Ce]]+re[T[Ce]])/2,pe=t.map(Ce=>[a?Ce.labelY:Ce.labelX,Se(a?Ce.labelX:Ce.labelY)]),Re=(Ce,Oe,We,Te,Ke,ze,at,et)=>We>Ke-at/2&&Ce<Ke+at/2&&Te>ze-et/2&&Oe<ze+et/2,le=(Ce,Oe,We,Te,Ke,ze,at)=>{for(let et=0;et<x.length;et++)if(et!==Ke&&et!==ze&&Re(Ce,Oe,We,Te,ye[et],ne(et),N[et]+8,$[et]+8))return!1;for(let et=0;et<t.length;et++){let nt=t[et];if(et!==at&&nt.labelW>0&&nt.src!==nt.dst&&Re(Ce,Oe,We,Te,pe[et][0],pe[et][1],a?nt.labelH:nt.labelW,a?nt.labelW:nt.labelH))return!1}return!0},Ee=(Ce,Oe,We,Te,Ke)=>{let ze=0;for(let at=0;at<t.length;at++){if(at===Ke)continue;let et=t[at].route;for(let nt=3;nt<et.length;nt+=3)if(Math.max(et[nt-3],et[nt])>Ce&&Math.min(et[nt-3],et[nt])<We&&Math.max(et[nt-2],et[nt+1])>Oe&&Math.min(et[nt-2],et[nt+1])<Te){ze++;break}}return ze},Ne=(Ce,Oe,We)=>{let Te=0;for(let Ke=0;Ke<t.length;Ke++){let ze=t[Ke].route;if(Ke===We||ze.length===0)continue;let at=ze.length-3;(Math.abs(ze[0]-Ce)<1&&Math.abs(ze[1]-Oe)<1||Math.abs(ze[at]-Ce)<1&&Math.abs(ze[at+1]-Oe)<1)&&Te++}return Te},Me=(Ce,Oe,We,Te,Ke)=>{let ze=Math.abs(We-Ce)<.5,at=ze?Math.min(Oe,Te):Math.min(Ce,We),et=ze?Math.max(Oe,Te):Math.max(Ce,We),nt=ze?Ce:Oe;for(let Tt=0;Tt<t.length;Tt++){let lt=t[Tt];if(Tt===Ke||lt.src===t[Ke].src||lt.dst===t[Ke].dst)continue;let Et=lt.route;for(let ot=3;ot<Et.length;ot+=3){let rt=Et[ot-3+(ze?0:1)],Ve=Et[ot+(ze?0:1)];if(Math.abs(rt-nt)>=b0||Math.abs(Ve-nt)>=b0)continue;let st=Et[ot-3+(ze?1:0)],dt=Et[ot+(ze?1:0)];if(Math.min(et,Math.max(st,dt))-Math.max(at,Math.min(st,dt))>1)return!0}}return!1};for(let Ce=0;Ce<I;Ce++){let Oe=P[Ce],We=k[Ce],Te=t[We],Ke=Oe.tail,ze=Oe.head;if(b[Ke]===b[ze]||Math.abs(ye[ze]-ye[Ke])<1)continue;let at=ye[Ke],et=ye[ze],nt=ne(Ke),Tt=ne(ze),lt=Math.sign(et-at),Et=Math.sign(Tt-nt),ot=(Ve,st)=>{for(let qe=2;qe<Ve.length;qe+=2)if(!le(Math.min(Ve[qe-2],Ve[qe])-st,Math.min(Ve[qe-1],Ve[qe+1])-st,Math.max(Ve[qe-2],Ve[qe])+st,Math.max(Ve[qe-1],Ve[qe+1])+st,Ke,ze,We)||Me(we(Ve[qe-2],Ve[qe-1]),ke(Ve[qe-2],Ve[qe-1]),we(Ve[qe],Ve[qe+1]),ke(Ve[qe],Ve[qe+1]),We))return!1;let dt=0,ut=0,en=-1;if(Te.labelW>0){let qe=Oe.labelW,_t=Oe.labelH;for(let St=2;St<Ve.length;St+=2){let Mt=(Ve[St-2]+Ve[St])/2,Gt=(Ve[St-1]+Ve[St+1])/2,un=Math.abs(Ve[St]-Ve[St-2]),us=Math.abs(Ve[St+1]-Ve[St-1]),Yn=un+us;if(Yn<=en||(un>0?un<qe+8:us<_t+8)||Mt-qe/2<0||Mt+qe/2>ge||Gt-_t/2<0||Gt+_t/2>ue||!le(Mt-qe/2,Gt-_t/2,Mt+qe/2,Gt+_t/2,-1,-1,We))continue;let Di=we(Mt,Gt),Oi=ke(Mt,Gt);Ee(Di-Te.labelW/2,Oi-Te.labelH/2,Di+Te.labelW/2,Oi+Te.labelH/2,We)>0||(dt=Mt,ut=Gt,en=Yn)}if(en<0)return!1}let xt=[Ve[0],Ve[1]];for(let qe=2;qe<Ve.length;qe+=2){let _t=Ve[qe]-Ve[qe-2],St=Ve[qe+1]-Ve[qe-1],Mt=Math.abs(_t)+Math.abs(St),Gt=qe>2?Df:0,un=qe+2<Ve.length?Df:0;Mt>Gt+un+1&&(Gt&&xt.push(Ve[qe-2]+_t/Mt*Gt,Ve[qe-1]+St/Mt*Gt),un&&xt.push(Ve[qe]-_t/Mt*un,Ve[qe+1]-St/Mt*un)),xt.push(Ve[qe],Ve[qe+1])}Te.route=[];for(let qe=0;qe<xt.length;qe+=2){let _t=qe===0?xt[0]!==xt[2]:xt[qe]!==xt[qe-2];Te.route.push(we(xt[qe],xt[qe+1]),ke(xt[qe],xt[qe+1]),_t?1-Le:Le)}return Te.labelW>0&&(Te.labelX=we(dt,ut),Te.labelY=ke(dt,ut),pe[We]=[dt,ut]),Ye[Ce]=1,!0};if(ot([at+lt*N[Ke]/2,nt,et,nt,et,Tt-Et*$[ze]/2],2)||ot([at,nt+Et*$[Ke]/2,at,Tt,et-lt*N[ze]/2,Tt],2)||he>$f/y0)continue;let rt=[];for(let Ve of b[Ke]<b[ze]?[b[ze],b[Ke]]:[b[Ke],b[ze]]){let st=Math.max(R[Ve]-A0,Math.min(R[Ve]/2,E0-A0));for(let dt of[oe[Ve]+st,oe[Ve+1]-st]){if(Math.abs(dt-at)<N[Ke]/2+4||Math.abs(dt-et)<N[ze]/2+4)continue;let ut=[at+Math.sign(dt-at)*N[Ke]/2,nt,dt,nt,dt,Tt,et+Math.sign(dt-et)*N[ze]/2,Tt],en=(Ne(we(ut[0],ut[1]),ke(ut[0],ut[1]),We)+Ne(we(ut[6],ut[7]),ke(ut[6],ut[7]),We))*1e6;for(let xt=2;xt<ut.length;xt+=2){let qe=we(ut[xt-2],ut[xt-1]),_t=ke(ut[xt-2],ut[xt-1]),St=we(ut[xt],ut[xt+1]),Mt=ke(ut[xt],ut[xt+1]);en+=Ee(Math.min(qe,St),Math.min(_t,Mt),Math.max(qe,St),Math.max(_t,Mt),We)*1e6+Math.abs(St-qe)+Math.abs(Mt-_t)}rt.push({pts:ut,cost:en,lane:Ve})}}rt.sort((Ve,st)=>Ve.cost-st.cost);for(let Ve of rt)if(ot(Ve.pts,1)){L[Ve.lane]=1;break}}}return{width:a?ue:ge,height:a?ge:ue,routed:Ye,margins:L,work:he}},M=new Uint8Array(I),Q=new Uint8Array(l),q=U(M,Q);for(let Y=0;Y<UI&&q.work<=$f/y0;Y++){let z=Y===0?q.routed:M.map((R,L)=>R&q.routed[L]);if(z.every((R,L)=>R===M[L])&&q.margins.every((R,L)=>R===Q[L]))break;M=z,Q=q.margins,q=U(M,Q)}return M.some((Y,z)=>Y&&!q.routed[z])&&(q=U(new Uint8Array(I),new Uint8Array(l))),{width:q.width,height:q.height}}function x0(e,t){let n=t.x-e.x,r=t.y-e.y,o=Math.max(e.w/2,.5),s=Math.max(e.h/2,.5);if(Math.abs(n)<o&&Math.abs(r)<s){let i=o-Math.abs(n),c=s-Math.abs(r);return i<c?[e.x+(n<0?-o:o),t.y]:[t.x,e.y+(r<0?-s:s)]}let a=Math.min(n!==0?o/Math.abs(n):1/0,r!==0?s/Math.abs(r):1/0);return[e.x+n*a,e.y+r*a]}var _0="__swimlane_default__";function YI(e){let t=!1;for(let n of e.nodes)n.isGroup?n.dir=void 0:n.parentId===void 0&&(t=!0);if(t){for(let n of e.nodes)!n.isGroup&&n.parentId===void 0&&(n.parentId=_0);e.nodes.push({id:_0,label:void 0,labelType:"text",shape:"rect",isGroup:!0,parentId:void 0,cssStyles:[],cssCompiledStyles:[],cssClasses:"",dir:void 0})}}function HI(e,t,n,r,o,s,a){let i=e.x-e.w/2,c=e.y-e.h/2,l=s==="LR"||s==="RL",f=l?i+e.padTop/2:e.x,p=l?e.y:c+e.padTop/2,u=Ie(t,f,p,` class="pele-cluster-label" fill="var(--_m)"${n.text}`,a);return`<g class="pele-cluster pele-lane${r}" data-id="${o}"><rect x="${d(i)}" y="${d(c)}" width="${d(e.w)}" height="${d(e.h)}" fill="none" stroke="var(--_b)"/><rect x="${d(i)}" y="${d(c)}" width="${d(l?e.padTop:e.w)}" height="${d(l?e.h:e.padTop)}" fill="var(--_a)" stroke="var(--_b)"${n.shape}/>`+(l&&u?`<g transform="rotate(-90 ${d(f)} ${d(p)})">${u}</g>`:u)+"</g>"}var KI={type:"swimlane",prepare:YI,layout:(e,t,n,r,o)=>S0(e,t,n,r,o?12:void 0),drawGroup:HI},w0={type:"swimlane",parse:sc.parse,render:(e,t,n)=>rc(e,t,n,KI)};var cl=class{type="timeline";title;accTitle;accDescr;direction="LR";sections=[];periods=[];currentSection="";getCommonDb(){return this}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
129
+ `)}setDirection(t){this.direction=t}addSection(t){this.currentSection=t,this.sections.push(t)}addTask(t,n,r){this.periods.push({text:t,events:r?[r]:[],section:this.currentSection,sectionIndex:this.sections.length-1})}addEvent(t){let n=this.periods[this.periods.length-1];if(!n)throw new Ge("An event needs a time period before it.","semantic",{type:"timeline"});n.events.push(t)}};var R0=["$end","EOF","INVALID","NEWLINE","timeline","timeline_lr","timeline_td","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","section","period","event"];function T0(e){let t=e.length,n=[],r=[],o=[],s={types:n,texts:r,starts:o},a=0,i=(c,l)=>{n.push(c),r.push(e.slice(a,l)),o.push(a),a=l};for(;a=_c(e,a),!(a>=t);){let c=e.charCodeAt(a),l=a+1;if(c===10){for(;e.charCodeAt(l)===10;)l++;i(3,l);continue}if(Wn(e,a,"timeline")){for(l=a+8;e.charCodeAt(l)===32||e.charCodeAt(l)===9;)l++;let f=Wn(e,l,"lr");if(l>a+8&&(f||Wn(e,l,"td"))&&!Qe(e.charCodeAt(l+2))){i(f?5:6,l+2);continue}if(!Qe(e.charCodeAt(a+8))){i(4,a+8);continue}}if(Wn(e,a,"title")&&Be(e.charCodeAt(a+5))&&a+6<t&&e.charCodeAt(a+6)!==10){i(7,yi(e,a+6));continue}if(l=wc(e,a,s,8),l!==a){a=l;continue}if(Wn(e,a,"section")&&Be(e.charCodeAt(a+7))){for(l=a+8;l<t&&e.charCodeAt(l)!==58&&e.charCodeAt(l)!==10;)l++;if(l>a+8){i(13,l);continue}}if(c!==58){l=a+1;for(let f=e.charCodeAt(l);l<t&&f!==35&&f!==58&&f!==10;f=e.charCodeAt(++l));i(14,l);continue}if(Be(e.charCodeAt(a+1))){for(l=a+2;l<t;l++){let f=e.charCodeAt(l);if(f===10||f===58&&Be(e.charCodeAt(l+1)))break}if(l>a+2){i(15,l);continue}}i(2,a+1)}return(o.length===0||o[o.length-1]<t)&&i(1,t),i(0,t),s}var zI="'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'period', 'event'";function C0(e,t){let{types:n,texts:r,starts:o}=T0(e),s=(i,c)=>{let l=n[i]===0?"1":R0[n[i]];throw it("timeline",e,o[i],`Expecting ${c}, got '${l}'`)},a=n[0];a!==4&&a!==5&&a!==6&&s(0,"'timeline', 'timeline_lr', 'timeline_td'"),a!==4&&t.setDirection(a===5?"LR":"TD");for(let i=1;;i++){let c=r[i];switch(n[i]){case 3:break;case 7:t.getCommonDb().setDiagramTitle(c.substring(6));break;case 8:t.getCommonDb().setAccTitle(r[++i].trim());break;case 10:t.getCommonDb().setAccDescription(r[++i].trim());break;case 12:t.getCommonDb().setAccDescription(c.trim());break;case 13:t.addSection(c.substring(8));break;case 14:t.addTask(c,0,"");break;case 15:t.addEvent(c.substring(2));break;case 1:return;default:s(i,zI)}}}var ll=12,I0=8,VI=152,jI=216,XI=264,Us=20,Mi=20,dl=14,Do=8,Of=8,ul=12,N0=' fill="var(--_bg)"',M0=' fill="none" stroke="var(--_b)"';function vf(e,t,n,r,o){return`<rect x="${d(e)}" y="${d(t)}" width="${d(n)}" height="${d(r)}" rx="${Xe}"${o}/>`}function L0(e,t,n){return e.direction==="TD"?k0(e,t,n,!0):Nt(n,r=>k0(e,t,n,r))}function k0(e,t,n,r){let o=n.fontSize??16,s=Math.round(o*.875),a=n.measurer??Je(n.fontFamily),i=n.padding??8,c=t.timeline?.disableMulticolor!==!0,l=e.periods,f=e.sections.length>0,p=e.sections.map((K,ee)=>({section:ee,periods:[]})),u={section:-1,periods:[]};l.forEach((K,ee)=>(p[K.sectionIndex]??u).periods.push(ee)),u.periods.length>0&&p.unshift(u);let m=r&&n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*i:1/0,h=Mi+dl*2+4*ll,g=Math.min(VI,Math.max(80,Math.round((m-h)*.38))),x=Math.min(XI,Math.max(110,m-h-g)),y=g,_=()=>r?x:y,S=l.map(K=>Zn(K.text,a,o,y)),P=l.map(K=>K.events.map(ee=>Zn(ee,a,s,_()))),k=0;for(let K of S)k=Math.max(k,K.width);if(!r)for(let K of P)for(let ee of K)k=Math.max(k,ee.width);let w=k>y;if(r)for(let K of P)for(let ee of K)w||=ee.width>x;w&&(y=Math.min(Math.max(Math.ceil(k),g),m===1/0?jI:g),S=l.map(K=>Tn(K.text,a,o,y)),P=l.map(K=>K.events.map(ee=>Tn(ee,a,s,_()))));let I=Math.round(o*1.5),D=y+2*ll,U=_()+2*ll,M=K=>Math.max(K.height,I)+2*I0,Q=K=>Math.max(K.height,Math.round(s*1.5))+2*I0,q=(K,ee)=>K.section>=0?ct(K.section):f?"var(--_m)":ct(c?ee:0),Y=!1;for(let K of P)K.length>0&&(Y=!0);let z=0;for(let K of p)z+=Math.max(K.periods.length,1);let R=D+Us,L=l.length>0,F=r?D+(Y?Mi+dl*2+U:L?Mi+ul:0):z>0?z*R-Us+(L?ul+kt:0):0,E=Tn(e.title,a,o,Math.max(F,320),1),C=E.height>0?E.height+16:0,A=Math.max(F,E.width),T=i+(A-F)/2,b=i+C,N=(K,ee)=>Tn(e.sections[K.section],a,o,ee-2*ll,1),$=(K,ee,ae,J,se,me)=>vf(ae,J,se,me,` fill="${ct(K.section)}"`)+Ie(ee,ae+se/2,J+me/2,' font-weight="var(--_hw)"'+N0),X=(K,ee,ae,J,se)=>vf(ae,J,D,se,` fill="${ee}"`)+Ie(S[K],ae+D/2,J+se/2,N0),V=(K,ee,ae,J,se)=>'<g class="pele-node pele-event">'+vf(ae,J,U,se,` fill="${ee}" fill-opacity="0.16"`)+Ie(K,ae+U/2,J+se/2,` font-size="${s}"`)+"</g>",O=(K,ee,ae)=>`<circle class="pele-dot" cx="${d(K)}" cy="${d(ee)}" r="4" fill="${ae}" stroke="var(--_bg)" stroke-width="2"/>`,v=K=>K.section>=0?`<g class="pele-cluster pele-section" data-id="${$e(e.sections[K.section].trim())}">`:"",W=K=>`<g class="pele-node pele-period" data-id="${$e(l[K].text.trim())}">`,H="",G;if(r){let K=T+D+Mi,ee=K+dl,ae=ee+dl,J=b;for(let se of p){if(H+=v(se),se.section>=0){let me=N(se,F),Ae=M(me);H+=$(se,me,T,J,F,Ae),J+=Ae+Of+4}for(let me of se.periods){let Ae=q(se,me),de=M(S[me]),oe=J+de/2,ye=`M${d(T+D)},${d(oe)}H${d(K)}`,ce="",fe=J,xe=oe;for(let be of P[me]){let re=Q(be);xe=fe+re/2,ye+=`M${d(ee)},${d(xe)}H${d(ae)}`,ce+=V(be,Ae,ae,fe,re),fe+=re+Do}ce&&(ye+=`M${d(K)},${d(oe)}H${d(ee)}V${d(xe)}`),H+=W(me)+X(me,Ae,T,J,de)+`<path class="pele-edge" d="${ye}"${M0}/>`+O(K,oe,Ae)+ce+"</g>",J=Math.max(J+de,fe-Do)+Us}se.periods.length===0&&(J+=Us-Of-4),se.section>=0&&(H+="</g>")}if(p.length>0&&(J-=Us),L){let se=J+ul+kt;H=`<path class="pele-axis" d="M${d(K)},${d(b)}V${d(se-kt+1)}" fill="none" stroke="var(--_l)"/>`+bt("arrow_point",K,se,0,1,"var(--_l)")+H,J=se}G=J+i}else{let K=0,ee=p.map(oe=>{if(oe.section<0)return;let ye=N(oe,Math.max(oe.periods.length,1)*R-Us);return K=Math.max(K,M(ye)),ye}),ae=0;for(let oe of S)ae=Math.max(ae,M(oe));let J=b+(f?K+Of:0),se=J+ae+(ae>0?Mi:0),me=se+Mi,Ae=L?se+ul:b+K,de=0;if(p.forEach((oe,ye)=>{let ce=Math.max(oe.periods.length,1),fe=T+de*R;H+=v(oe);let xe=ee[ye];xe&&(H+=$(oe,xe,fe,b,ce*R-Us,K)),oe.periods.forEach((be,re)=>{let j=q(oe,be),ie=fe+re*R,ue=ie+D/2,ge=`M${d(ue)},${d(J+ae)}V${d(P[be].length>0?me:se)}`,Se="",we=me;for(let ke of P[be]){let Le=Q(ke);we>me&&(ge+=`M${d(ue)},${d(we-Do)}V${d(we)}`),Se+=V(ke,j,ie,we,Le),we+=Le+Do}Ae=Math.max(Ae,we-Do),H+=W(be)+X(be,j,ie,J,ae)+`<path class="pele-edge" d="${ge}"${M0}/>`+O(ue,se,j)+Se+"</g>"}),oe.section>=0&&(H+="</g>"),de+=ce}),L){let oe=T+F;H=`<path class="pele-axis" d="M${d(T)},${d(se)}H${d(oe-kt+1)}" fill="none" stroke="var(--_l)"/>`+bt("arrow_point",oe,se,1,0,"var(--_l)")+H}G=Ae+i}let te=Math.ceil(A+2*i),Z=Math.ceil(Math.max(G,i*2)),B=Ie(E,te/2,i+E.height/2,' class="pele-title" font-weight="var(--_tw)"')+H;return{svg:Ze("timeline",te,Z,o,n,e,B),width:te,height:Z,links:[]}}var $0={type:"timeline",parse(e,t,n){let r=new cl;return r.title=n,C0(e,r),r},render:L0};var Pf=/[─━│┃└┗├┣]/,v0=/[└┗├┣]/,qI=/[─━]/,D0=/^[\s│┃]+$/,QI=/^[\s─━│┃└┗├┣]+$/,ZI=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,JI=/^\s*%%/,eN=" ";function tN(e){return e.some(t=>Pf.test(t))}function nN(e){for(let t of e){let n=v0.exec(t);if(n?.index&&n.index>0)return n.index}return 4}function Bf(e,t){return e.replace(/\bline\s+(\d+)\b/gi,(n,r)=>{let o=t.get(parseInt(r,10));return o?`line ${o}`:n})}function O0(e,t){throw new Ge(`Line ${e}: ${t}`,"syntax",{type:"treeView",line:e})}function P0(e){let t=new Map;if(!Pf.test(e))return{text:e,lineMap:t};let n=e.split(`
130
+ `),r=-1;for(let l=0;l<n.length;l++)if(n[l].trim()==="treeView-beta"){r=l;break}if(r===-1)return{text:e,lineMap:t};let o=l=>l.trim()===""||JI.test(l)||ZI.test(l),s=[];for(let l=r+1;l<n.length;l++){let f=n[l];o(f)||D0.test(f)||s.push(f.replace(/\t/g," "))}if(!tN(s))return{text:e,lineMap:t};let a=nN(s),i=[],c=(l,f)=>{i.push(l),t.set(i.length,f+1)};for(let l=0;l<=r;l++)c(n[l],l);for(let l=r+1;l<n.length;l++){let f=n[l];if(o(f)){c(f,l);continue}if(D0.test(f))continue;let p=f.replace(/\t/g," "),u=v0.exec(p);if(u){let m=Math.round(u.index/a)+1,h=u.index+1;for(;h<p.length&&qI.test(p[h]);)h++;for(;h<p.length&&p[h]===" ";)h++;let g=p.slice(h).trimEnd();g||O0(l+1,"Empty node — expected a filename or directory name after the box-drawing prefix"),c(eN.repeat(m)+g,l)}else{if(QI.test(p))continue;Pf.test(p)?c(f,l):/^\s+/.test(p)?O0(l+1,"Unexpected indentation without box-drawing characters. In box-drawing format, use ├── or └── prefixes for indented nodes."):c(f,l)}}return{text:i.join(`
131
+ `),lineMap:t}}function rN(e,t){if(e.startsWith("##",t)||e.startsWith("icon(",t))return!0;if(!e.startsWith(":::",t))return!1;let n=t+3;for(;On(e.charCodeAt(n));)n++;let r=e.charCodeAt(n);return r>=65&&r<=90||r>=97&&r<=122||r===95}function sN(e,t){let n=e.charCodeAt(t);if(On(n)||n===10||n===13||n===34||n===39||e.startsWith(":::",t)||e.startsWith("icon(",t)||e.startsWith("##",t))return-1;let r=e.length,o=t+1;for(;o<r;){let s=e.charCodeAt(o);if(s===10||s===13)break;if(On(s)){let a=o+1;for(;On(e.charCodeAt(a));)a++;if(rN(e,a))break;o=a}else o++}return o}var B0={name:"BARE_NAME",pattern:/(?!:::|icon\(|##)[^ \t\n\r"'](?:(?![ \t]+:::[ \t]*[A-Za-z_]|[ \t]+icon\(|[ \t]+##)[^\n\r])*/y,match:sN},F0=[{...Vt("treeView-beta"),longer:[B0]},pi(),Yt,Ht,{name:"CLASS_ANNOTATION",pattern:/[ \t]+:::[ \t]*[A-Za-z_][\w-]*/y},{name:"ICON_ANNOTATION",pattern:/[ \t]+icon\([\w-]*(?::[\w-]+)?\)/y},{name:"DESC_ANNOTATION",pattern:/[ \t]+##[^\n\r]*/y},{name:"INDENTATION",pattern:/[ \t]{1,}/y},{name:"QUOTED_NAME",pattern:/"[^"]*"|'[^']*'/y},{name:"WS",pattern:/[ \t]+/y,hidden:!0},{name:"ML_COMMENT",pattern:/\%\%[^\n]*/y,hidden:!0},{name:"NL",pattern:/\r?\n/y,hidden:!0},B0];function W0(e){let t=e.length;for(;t>0&&On(e.charCodeAt(t-1));)t--;return t===e.length?e:e.slice(0,t)}function Ff(e,t){switch(e){case"INDENTATION":return t?.length||0;case"QUOTED_NAME":return t.substring(1,t.length-1);case"BARE_NAME":return W0(t);case"CLASS_ANNOTATION":return t.trim().substring(3).trim();case"ICON_ANNOTATION":{let n=t.trim();return n.substring(5,n.length-1)}case"DESC_ANNOTATION":return t.trim().substring(2).trim();default:return}}function U0(e){let t=new Dt(vt(e,F0,"treeView"),F0,"treeView"),n={$type:"TreeView",nodes:[]};for(t.expect(0);;)if(t.kind===1)n.accDescr=Wt(t.take());else if(t.kind===2)n.accTitle=Ft(t.take());else if(t.kind===3)n.title=Bt(t.take());else break;for(;t.kind!==-1;){let r={$type:"TreeNode",name:""};if(t.kind===7&&(r.indent=t.take().length),t.kind===8){let o=t.take();r.name=o.substring(1,o.length-1)}else t.kind===12?r.name=W0(t.take()):t.fail("a name");for(;;)if(t.kind===4)r.classAnnotation=Ff("CLASS_ANNOTATION",t.take());else if(t.kind===5)r.iconAnnotation=Ff("ICON_ANNOTATION",t.take());else if(t.kind===6)r.descAnnotation=Ff("DESC_ANNOTATION",t.take());else break;n.nodes.push(r)}return n}var Wf=class{count=1;root={id:0,level:-1,name:"/",nodeType:"directory",children:[]};stack=[this.root];addNode(t,n,r,o,s,a){let i=this.stack;for(;t<=i[i.length-1].level;)i.pop();let c={id:this.count++,level:t,name:n,nodeType:r,icon:s,cssClass:o,description:a,children:[]};i[i.length-1].children.push(c),i.push(c)}};function iN(e,t){for(let n of e.nodes){let r=typeof n.indent=="number"?n.indent:0,o=n.name,s=o.endsWith("/");s&&(o=o.slice(0,-1));let a=n.iconAnnotation;t.addNode(r,o,s?"directory":"file",n.classAnnotation||void 0,a!==void 0?a||"none":void 0,n.descAnnotation||void 0)}}function G0(e){let{text:t,lineMap:n}=P0(e);try{return U0(t)}catch(r){if(n.size===0||!(r instanceof Ge))throw r;let o=r.message.indexOf(`
132
+ `),s=o===-1?Bf(r.message,n):Bf(r.message.slice(0,o),n)+r.message.slice(o);throw new Ge(s,r.code,{type:r.type,line:n.get(r.line)??r.line,column:r.column,snippet:r.snippet})}}function Y0(e,t){let n=new Wf;return iN(e,n),{type:"treeView",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
133
+ `):void 0,root:n.root,count:n.count}}var Oo="mermaid-treeview",fl=new Map([["folder","M3 6.5A1.5 1.5 0 0 1 4.5 5h4.6l2.4 2.5h8A1.5 1.5 0 0 1 21 9v9a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 18z"],["file","M6.5 3h7L19 8.5v11a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 5 19.5v-15A1.5 1.5 0 0 1 6.5 3zM13.5 3v5.5H19"]]);function Uf(e,t){if(e===void 0||!Object.prototype.hasOwnProperty.call(e,t))return;let n=e[t];return typeof n=="string"?n:void 0}function oN(e,t){let n=Uf(t?.filenameIcons,e);if(n)return n;let r=e.lastIndexOf(".");if(r>0){let o=e.substring(r).toLowerCase();return Uf(t?.extensionIcons,o)??Uf(t?.extensionIcons,o.slice(1))}}function H0(e,t){return e.includes(":")?e:fl.has(e)||!t?`${Oo}:${e}`:`${t}:${e}`}function Gf(e,t){if(e.icon!=="none"){if(e.icon)return H0(e.icon,t.defaultIconPack);if(t.showIcons){if(e.nodeType==="file"){let n=oN(e.name,t);if(n==="none")return;if(n)return H0(n,t.defaultIconPack)}return`${Oo}:${e.nodeType==="directory"?"folder":"file"}`}}}function K0(e){let t=r=>typeof r=="object"&&r!==null&&!Array.isArray(r)?r:void 0,n=t(e.treeView)??{};return{showIcons:!!n.showIcons,defaultIconPack:typeof n.defaultIconPack=="string"?n.defaultIconPack:"",filenameIcons:t(n.filenameIcons),extensionIcons:t(n.extensionIcons)}}var aN=6,cN=16,lN=7,dN=4,pl=4;function hl(e,t,n,r,o){let s=e.treeView?.[t];return typeof s=="number"&&s>=r&&s<=o?s:n}function uN(e){return{paddingX:hl(e,"paddingX",5,0,100),paddingY:hl(e,"paddingY",2,0,100),rowIndent:hl(e,"rowIndent",15,0,400),lineThickness:hl(e,"lineThickness",1,.25,12)}}function z0(e,t,n){return pn(n,r=>fN(e,t,n,r))}function fN(e,t,n,r){let o=n.fontSize??16,s=n.measurer??Je(n.fontFamily),a=n.padding??8,i=K0(t),{paddingX:c,paddingY:l,rowIndent:f,lineThickness:p}=uN(t),u=0,m=e.root.children.map(T=>[T,0]);for(let T=0;r&&T<m.length;T++){let[b,N]=m[T];u=Math.max(u,N);for(let $ of b.children)m.push([$,N+1])}let h=r?Math.min(f+c,Math.max(2,((n.maxWidth??320)-120)/Math.max(1,u))):f+c,g=Math.round(o*1.5)+2*l,x=o,y=De(e.title,!1,s,o,r?Rt(n):4e3,1),_=y.height>0?y.height+12:0,S=T=>T.some(b=>Gf(b,i)!==void 0),P=[],k=new Map,w=[],I=(T,b)=>{let N=S(T);for(let $=T.length-1;$>=0;$--)w.push([T[$],b,N])};I(e.root.children,0);let D=0,U=!1,M=0;for(;w.length>0;){let[T,b,N]=w.pop(),$=b*h,X=gt(T.name),V=$+(N?x+aN:0),O=Math.max(40,(n.maxWidth??320)-2*a-2*pl-V),v=r?Ss(X,s,o,O,T.nodeType==="directory"?1:0):void 0,W=r&&T.description?Ss(gt(T.description),s,o,O,2):void 0,H=v?v.width:s.width(X,o,T.nodeType==="directory"?1:0);V+H>D&&(D=V+H);let G=T.cssClass!==void 0&&T.cssClass.split(/\s+/).includes("highlight");G&&(U=!0);let te=r?Math.max(g,(v?.height??0)+(W?.height??0)+2*l):g,Z=M+(r?l+Math.max(x,v?.height??0)/2:te/2),B={node:T,x:$,cy:Z,icon:Gf(T,i),text:X,labelX:V,highlighted:G,label:v,description:W,top:M,height:te};M+=te,P.push(B),k.set(T,B),I(T.children,b+1)}let Q=D+cN,q=D;for(let T of P){let b=T.node.description;if(!b)continue;let N=T.description?T.description.width:s.width(gt(b),o,2);q=Math.max(q,(r?T.labelX:Q)+N)}q=Math.max(q,y.width);let Y=a+(U?pl:0),z=a+_,R=Math.ceil(q+2*Y),L=Math.ceil(z+M+a),F="";for(let T of P){let b=T.node.children;if(b.length===0)continue;let N=Y+T.x+lN,$=Math.max(N,Y+T.x+h-c),X=z+k.get(b[b.length-1]).cy,V=Math.min(dN,$-N),O=`M${d(N)},${d(z+T.top+T.height-2)}V${d(X-V)}`;V>0&&(O+=`Q${d(N)},${d(X)} ${d(N+V)},${d(X)}H${d($)}`);for(let v=0;v<b.length-1&&$>N;v++)O+=`M${d(N)},${d(z+k.get(b[v]).cy)}H${d($)}`;F+=`<path d="${O}"/>`}let E=o*.35,C="";for(let T of P){let b=T.node,N=z+T.cy,$=b.nodeType==="directory",X="";if(T.highlighted){let V=Y+T.x-pl;X+=`<rect class="pele-tree-highlight" x="${d(V)}" y="${d(z+T.top+1)}" width="${d(R-Y+pl-V)}" height="${d(T.height-2)}" rx="${Xe}" fill="var(--_c)" fill-opacity="0.14"/>`}if(T.icon!==void 0){let V=T.icon.startsWith(Oo+":")?T.icon.slice(Oo.length+1):"",O=fl.get(V)??fl.get($?"folder":"file"),v=n.icons?.(T.icon)??`<path d="${O}" stroke="var(--_m)" stroke-width="1.5"/>`;X+=`<svg class="pele-icon" data-icon="${$e(T.icon)}" x="${d(Y+T.x)}" y="${d(N-x/2)}" width="${d(x)}" height="${d(x)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${v}</svg>`}T.label?X+=wr(T.label,Y+T.labelX,z+T.top+l,` class="pele-label"${$?' font-weight="var(--_hw)"':""}`):T.text!==""&&(X+=`<text class="pele-label" x="${d(Y+T.labelX)}" y="${d(N+E)}"${$?' font-weight="var(--_hw)"':""} xml:space="preserve">${je(T.text)}</text>`),T.description?X+=wr(T.description,Y+T.labelX,z+T.top+l+(T.label?.height??0),' class="pele-tree-description" font-style="italic" fill="var(--_m)"'):b.description&&(X+=`<text class="pele-tree-description" x="${d(Y+Q)}" y="${d(N+E)}" font-style="italic" fill="var(--_m)" xml:space="preserve">${je(gt(b.description))}</text>`),C+=`<g class="pele-node pele-tree-${$?"dir":"file"}${wt(b.cssClass??"")}" data-id="${$e(b.name)}">${X}</g>`}let A=Ie(y,R/2,a+y.height/2,' class="pele-title" font-weight="var(--_tw)"')+(F?`<g class="pele-tree-guides" fill="none" stroke="var(--_b)" stroke-width="${d(p)}">${F}</g>`:"")+C;return{svg:Ze("treeView",R,L,o,n,e,A),width:R,height:L,links:[]}}var V0={type:"treeView",parse:(e,t,n)=>Y0(G0(e),n),render:z0};function pN(e){let t=[],n=[];for(let r of e){let o=r.type==="Leaf",s={name:r.name,children:o?void 0:[]};for(s.classSelector=r.classSelector,r.cssCompiledStyles&&(s.cssCompiledStyles=r.cssCompiledStyles),o&&r.value!==void 0&&(s.value=r.value);n.length>0&&n[n.length-1].level>=r.level;)n.pop();n.length===0?t.push(s):n[n.length-1].node.children.push(s),o||n.push({node:s,level:r.level})}return t}function j0(e,t){let n=new Map;for(let o of e.TreemapRows){if(o.$type!=="ClassDefStatement")continue;let s=n.get(o.className);s||n.set(o.className,s=[]);let a=(o.styleText??"").replace(/\\,/g,"§§§").replace(/,/g,";").replace(/§§§/g,",");for(let i of a.split(";"))s.push(i)}let r=[];for(let o of e.TreemapRows){if(o.$type!=="TreemapRow")continue;let s=o.item,a=s.classSelector?n.get(s.classSelector):void 0;r.push({level:o.indent??0,name:s.name,type:s.$type,value:s.$type==="Leaf"?s.value:void 0,classSelector:s.classSelector,cssCompiledStyles:a&&a.length>0?a:void 0})}return{type:"treemap",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
134
+ `):void 0,roots:pN(r),classes:n}}var X0=[Zt,Yt,Ht,{name:"TREEMAP_KEYWORD",pattern:/treemap-beta|treemap/y},{name:"CLASS_DEF",pattern:/classDef\s+([a-zA-Z_][a-zA-Z0-9_]+)(?:\s+([^;\r\n]*))?(?:;)?/y},{name:"STYLE_SEPARATOR",pattern:/:::/y},{name:"SEPARATOR",pattern:/:/y},{name:"COMMA",pattern:/,/y},{name:"INDENTATION",pattern:/[ \t]{1,}/y},{name:"WS",pattern:/[ \t]+/y,hidden:!0},{name:"ML_COMMENT",pattern:/\%\%[^\n]*/y,hidden:!0},{name:"NL",pattern:/\r?\n/y,hidden:!0},{name:"ID2",pattern:/[a-zA-Z_][a-zA-Z0-9_]*/y},{name:"NUMBER2",pattern:/[0-9_\.\,]+/y},{name:"STRING2",pattern:/"[^"]*"|'[^']*'/y}],hN=/classDef\s+([A-Z_a-z]\w+)(?:\s+([^\n\r;]*))?;?/;function q0(e){let t=new Dt(vt(e,X0,"treemap"),X0,"treemap"),n=t.kinds,r={$type:"Treemap",TreemapRows:[]},o=()=>t.accept(5)?t.expect(12):void 0;for(t.expect(3);t.kind!==-1;){let s=t.kind;if(s===0){r.accDescr=Wt(t.take());continue}if(s===1){r.accTitle=Ft(t.take());continue}if(s===2){r.title=Bt(t.take());continue}s!==8&&s!==14&&s!==4&&t.fail("a node, a class definition, or a title");let a=s===8?t.take().length:void 0;if(t.kind===4){let u=hN.exec(t.take()),m={$type:"ClassDefStatement",className:u[1]};u[2]&&(m.styleText=u[2]),a!==void 0&&(m.indent=a),r.TreemapRows.push(m);continue}let i=t.expect(14).slice(1,-1),c=n[t.i]===8?t.i+1:t.i,l;n[c]===6||n[c]===7?(t.i=c+1,t.accept(8),l={$type:"Leaf",name:i,value:parseFloat(t.expect(13).replace(/,/g,""))}):l={$type:"Section",name:i};let f=o();f!==void 0&&(l.classSelector=f);let p={$type:"TreemapRow",item:l};a!==void 0&&(p.indent=a),r.TreemapRows.push(p)}return r}var Q0=/^(?:.?[<>=^])?([-+( ])?(\$)?0?\d*(,)?(?:\.(\d+))?(~)?([a-zA-Z%])?$/;function Z0(e){let t="";for(let n=e.length;n>0;n-=3)t=e.slice(Math.max(0,n-3),n)+(t?","+t:"");return t}function J0(e){let t=Q0.exec(e==="$0,0"?"$,":e)??Q0.exec(","),n=t[1]==="+",r=t[3]!==void 0,o=t[4]===void 0?void 0:Math.min(Number(t[4]),20),s=t[6]??"";return a=>{let i=Math.abs(a),c,l="";if(s==="f"?c=i.toFixed(o??6):s==="%"?(c=(i*100).toFixed(o??6),l="%"):s==="d"?c=Math.round(i).toFixed(0):s==="e"?c=i.toExponential(o??6):c=String(Number(i.toPrecision(Math.max(1,o??12)))),t[5]&&c.includes(".")&&!c.includes("e")&&(c=c.replace(/\.?0+$/,"")),r&&!c.includes("e")){let f=c.indexOf(".");c=f===-1?Z0(c):Z0(c.slice(0,f))+c.slice(f)}return(a<0?"-":n?"+":"")+(t[2]??"")+c+l}}function eA(e,t,n){let r=e.children===void 0&&Number.isFinite(e.value)&&e.value>0?e.value:0;return{node:e,parent:t,series:n,value:r,children:[],x:0,y:0,w:0,h:0}}function mN(e,t,n,r,o,s,a){let i=t,c=0;for(;c<e.length;){let l=o*s/i,f=Math.min(o,s),p=e[c].value*l,u=p,m=Math.max(f*f*u/(p*p),p*p/(f*f*u)),h=c+1;for(;h<e.length;){let y=e[h].value*l,_=p+y,S=Math.max(f*f*u/(_*_),_*_/(f*f*y));if(S>m)break;m=S,p=_,h++}let g=p/f,x=0;for(let y=c;y<h;y++){let _=e[y],S=y===h-1?f-x:_.value*l/g,P=o>=s?n:n+x,k=o>=s?r+x:r,w=Math.round(P+a/2),I=Math.round(k+a/2);_.x=w,_.y=I,_.w=Math.round(P+(o>=s?g:S)-a/2)-w,_.h=Math.round(k+(o>=s?S:g)-a/2)-I,x+=S,i-=_.value}o>=s?(n+=g,o-=g):(r+=g,s-=g),c=h}}function tA(e,t,n,r){let o=e.map((p,u)=>eA(p,void 0,u)),s=o.slice();for(let p=0;p<s.length;p++){let u=s[p];for(let m of u.node.children??[]){let h=eA(m,u,u.series);u.children.push(h),s.push(h)}}for(let p=s.length-1;p>=0;p--){let u=s[p];u.parent&&(u.parent.value+=u.value)}let{gap:a,header:i,side:c}=r,l=[],f=(p,u,m,h,g)=>{if(h<=0||g<=0)return;let x=p.filter(_=>_.value>0).sort((_,S)=>S.value-_.value),y=0;for(let _ of x)y+=_.value;if(!(x.length===0||!Number.isFinite(y))){mN(x,y,u-a/2,m-a/2,h+a,g+a,a);for(let _ of x)_.w>0&&_.h>0&&l.push(_)}};f(o,0,0,t,n);for(let p=0;p<l.length;p++){let u=l[p];u.children.length>0&&f(u.children,u.x+c,u.y+i,u.w-2*c,u.h-i-c)}return l}var Yf=28,ml=6,gl=1.25;function bl(e,t,n,r,o){let s=e.treemap?.[t];return typeof s=="number"&&s>=r?Math.min(s,o):n}function nA(e,t,n){let r=n.fontSize??16,o=Math.round(r*.875),s=Math.round(r*.75),a=Math.round(r*.5625),i=n.measurer??Je(n.fontFamily),c=t.treemap??{},l=n.padding??bl(t,"diagramPadding",8,0,2e3),f=Math.round(Wr(n,bl(t,"nodeWidth",64,1,400)*10,200,2*l)),p=Math.round(bl(t,"nodeHeight",40,1,400)*10),u=c.showValues!==!1,m=J0(typeof c.valueFormat=="string"?c.valueFormat:","),h=tA(e.roots,f,p,{gap:bl(t,"padding",4,0,200),header:Yf,side:ml}),g=De(e.title,!1,i,r,Rt(n),1),x=g.height>0?g.height+8:0,y=l+Math.max(0,(g.width-f)/2),_=l+x,S="",P="";for(let D of h){let U=D.node,M=At(U.cssCompiledStyles??[]),Q=ct(D.series),q=y+D.x,Y=_+D.y,z=gt(U.name).trim(),R=u?m(D.value):"",L=`data-id="${$e(U.name)}">`,F=`<rect x="${d(q)}" y="${d(Y)}" width="${d(D.w)}" height="${d(D.h)}" rx="${Xe}" fill="${Q}"`;if(U.children!==void 0){let b="";if(D.h>=Yf){let $=D.w-2*ml-4,X=R?i.width(R,s,0):0,V=X>0&&$-X-12>=3*o,O=Io(z,V?$-X-12:$,o,o,i,1),v=Y+Yf/2+1;O&&(b+=`<text x="${d(q+ml+2)}" y="${d(v+o*.35)}" font-weight="var(--_hw)"${M.text}>${je(O.text)}</text>`),V&&(b+=`<text class="pele-value" x="${d(q+D.w-ml-2)}" y="${d(v+s*.35)}" font-size="${s}" text-anchor="end" fill="var(--_m)"${M.text}>${je(R)}</text>`)}let N=/[";]fill:/.test(M.shape)?"":' fill-opacity="0.12"';S+=`<g class="pele-node pele-section${wt(U.classSelector??"")}" ${L}${F}${N} stroke="${Q}"${M.shape}/>${b}</g>`;continue}let E="",C=D.w-8,A=Math.min(r,Math.floor((D.h-4)/gl)),T=A>=a?Io(z,C,A,a,i):void 0;if(T){let b=d(q+D.w/2),N=Y+D.h/2,$=Math.max(a,Math.round(T.size*.8)),X=(T.size+$)*gl;if(R&&X<=D.h-4&&i.width(R,$,0)<=C){let V=N-X/2+T.size*gl/2,O=N+X/2-$*gl/2;E=`<text x="${b}" y="${d(V+T.size*.35)}" font-size="${d(T.size)}"${M.text}>${je(T.text)}</text><text class="pele-value" x="${b}" y="${d(O+$*.35)}" font-size="${d($)}"${M.text}>${je(R)}</text>`}else E=`<text x="${b}" y="${d(N+T.size*.35)}" font-size="${d(T.size)}"${M.text}>${je(T.text)}</text>`}P+=`<g class="pele-node pele-leaf${wt(U.classSelector??"")}" ${L}${F}${M.shape}/>${E}</g>`}let k=Math.ceil(Math.max(f,g.width)+2*l),w=Math.ceil(p+x+2*l),I=Ie(g,k/2,l+g.height/2,' class="pele-title" font-weight="var(--_tw)"')+(S?`<g class="pele-sections" font-size="${o}">${S}</g>`:"")+(P?`<g class="pele-leaves" text-anchor="middle" fill="var(--_bg)">${P}</g>`:"");return{svg:Ze("treemap",k,w,r,n,e,I),width:k,height:w,links:[]}}var rA={type:"treemap",parse:(e,t,n)=>j0(q0(e),n),render:nA};var Hf="EOF USECASE ACTOR SYSTEM_BOUNDARY END DIRECTION TD TB BT LR RL NOTE FOR JSON CLASS_DEF CLASS STYLE INCLUDE EXTEND TRUE FALSE IDENTIFIER NUMBER AT COMMA COLON HASH_COLOR CSS_IDENTIFIER CSS_ESCAPED_COMMA DASH DOT PERCENT CSS_PUNCTUATION LABEL_PUNCTUATION LABEL_SYMBOL PLAIN_STRING MARKDOWN_STRING UNCLOSED_MARKDOWN_STRING COMMENT NEWLINE ACC_DESCR_BLOCK ACC_TITLE_LINE ACC_DESCR_LINE JSON_DECLARATION_START JSON_OBJECT_LITERAL UNCLOSED_JSON_OBJECT_LITERAL GENERALIZATION DEPENDENCY_ARROW STEREOTYPE_START STEREOTYPE_END STEREOTYPE_TEXT UNCLOSED_STEREOTYPE_TEXT CLASS_SEPARATOR FORWARD_SOLID BACKWARD_SOLID FORWARD_CIRCLE BACKWARD_CIRCLE FORWARD_CROSS BACKWARD_CROSS MARKERLESS_SOLID METADATA_START LBRACE RBRACE LBRACKET RBRACKET LPAREN RPAREN".split(" ");var vo=1,oA=2,as=new Uint8Array(128);for(let e=48;e<=57;e++)as[e]=vo;for(let e=65;e<=90;e++)as[e]=as[e+32]=vo;as[95]=vo;for(let e of"!#$&*+/=?^|~")as[e.charCodeAt(0)]=oA;var sA=[0,12,5,14,3,9,2,2,2,2,2,4,3,4,8,5,5,7,6,4,5];function yl(e){return e<128&&(as[e]&vo)!==0}function Kf(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function gN(e,t,n){switch(n){case 97:return e.startsWith("actor",t)?2:0;case 115:return e.startsWith("systemBoundary",t)?3:e.startsWith("style",t)?16:0;case 101:return e.startsWith("end",t)?4:Kf(e,t,"extend")?18:0;case 69:return Kf(e,t,"extend")?18:0;case 100:return e.startsWith("direction",t)?5:0;case 84:return e.startsWith("TD",t)?6:e.startsWith("TB",t)?7:0;case 66:return e.startsWith("BT",t)?8:0;case 76:return e.startsWith("LR",t)?9:0;case 82:return e.startsWith("RL",t)?10:0;case 110:return e.startsWith("note",t)?11:0;case 102:return e.startsWith("for",t)?12:e.startsWith("false",t)?20:0;case 106:return e.startsWith("json",t)?13:0;case 99:return e.startsWith("classDef",t)?14:e.startsWith("class",t)?15:0;case 105:case 73:return Kf(e,t,"include")?17:0;case 116:return e.startsWith("true",t)?19:0;case 117:return e.startsWith("usecase-beta",t)?1:0;default:return 0}}function Gs(e,t){let n=1,r=0;for(let o=0;o<t;o++){let s=e.charCodeAt(o);s!==10&&s!==13||(s===13&&o+1<t&&e.charCodeAt(o+1)===10&&o++,n++,r=o+1)}return[n,t-r+1]}function aA(e,t,n){let[r,o]=Gs(e,t);return`line ${r}, column ${o} [${t},${n})`}function cA(e,t,n){for(let r=t+1;r<e.length;r++){let o=e.charCodeAt(r);if(o===n)return r+1;if(o===10||o===13)return-1}return-1}function bN(e,t){let n=e.charCodeAt(t);return n!==34&&n!==39?!0:n===34&&e.charCodeAt(t+1)===96||cA(e,t,n)!==-1}function iA(e,t,n){let[r,o]=Gs(e,t);return new Ge(`Error lexing usecase diagram: unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters. at line ${r}, column ${o} [${t},${t+n})`,"syntax",{type:"usecase",line:r,column:o})}function lA(e){let t=[],n=[],r=[],o=e.length,s=0,a=!0,i=!1;for(;s<o;){let c=e.charCodeAt(s);if(c===32||c===9){s++;continue}let l,f=s+1,p=!1;if(c<128&&(as[c]&vo)!==0){if(l=0,c===97&&a&&e.startsWith("acc",s)){let u=e.startsWith("Descr",s+3);if(u||e.startsWith("Title",s+3)){let m=s+8;for(;On(e.charCodeAt(m));)m++;let h=e.charCodeAt(m);if(h===58)for(l=u?42:41,f=m+1;f<o&&e.charCodeAt(f)!==10&&e.charCodeAt(f)!==13;)f++;else if(h===123&&u&&!i){let g=e.indexOf("}",m+1);g===-1?i=!0:(l=40,f=g+1)}}}else if(c===106&&e.startsWith("json",s)&&On(e.charCodeAt(s+4))){let u=s+5;for(;On(e.charCodeAt(u));)u++;let m=u;for(;yl(e.charCodeAt(u));)u++;if(u>m){for(;On(e.charCodeAt(u));)u++;if(e.charCodeAt(u)===64){for(u++;On(e.charCodeAt(u));)u++;if(e.charCodeAt(u)===123){t.push(43),n.push(s),r.push(u),s=u;let h=0,g=!1,x=!1,y=u;for(;y<o;y++){let _=e.charCodeAt(y);if(g)x?x=!1:_===92?x=!0:_===34&&(g=!1);else if(_===34)g=!0;else if(_===123)h++;else if(_===125&&--h===0)break}t.push(y<o?44:45),n.push(u),s=y<o?y+1:o,r.push(s),a=!1;continue}}}}if(l===0){for(;f<o&&yl(e.charCodeAt(f));)f++;let u=gN(e,s,c);if(u!==0)u===1||f-s===sA[u]?(l=u,f=s+sA[u]):l=21;else if((c===111||c===120)&&e.charCodeAt(s+1)===45&&e.charCodeAt(s+2)===45)l=c===111?56:58,f=s+3;else if(ft(c)){let m=s+1;for(;ft(e.charCodeAt(m));)m++;if(e.charCodeAt(m)===46&&ft(e.charCodeAt(m+1))){for(l=22,f=m+2;ft(e.charCodeAt(f));)f++;for(;yr(e.charCodeAt(f));)f++}else l=21}else for(l=21;e.charCodeAt(f)===45&&yl(e.charCodeAt(f+1));)for(l=27,f+=2;yl(e.charCodeAt(f));)f++}}else if(c===10)l=39,p=!0;else if(c===13)l=39,p=!0,e.charCodeAt(f)===10&&f++;else if(c===34||c===39){if(c===34&&e.charCodeAt(s+1)===96){let u=e.indexOf('`"',s+2);l=u===-1?37:36,f=u===-1?o:u+2}else if(l=35,f=cA(e,s,c),f===-1){let u=s+1;for(;u<o&&!bN(e,u);)u++;throw iA(e,s,u-s)}}else if(c===37)if(a&&e.charCodeAt(f)===37)for(l=38;f<o&&e.charCodeAt(f)!==10&&e.charCodeAt(f)!==13;)f++;else l=31;else if(c===45)if(e.charCodeAt(f)!==45)l=29;else{for(;e.charCodeAt(f)===45;)f++;let u=e.charCodeAt(f),m=f-s===2;m&&u===124&&e.charCodeAt(f+1)===62?(l=46,f+=2):u===62?(l=53,f++):m&&(u===111||u===120)?(l=u===111?55:57,f++):l=59}else if(c===46){let u=e.charCodeAt(f);if(u===46&&e.charCodeAt(f+1)===62)l=47,f+=2;else if(ft(u)){for(l=22;ft(e.charCodeAt(f));)f++;for(;yr(e.charCodeAt(f));)f++}else l=30}else if(c===60)if(e.charCodeAt(f)===60){if(t.push(48),n.push(s),r.push(s+2),a=!1,s+=2,s>=o)break;if(e.charCodeAt(s)===62&&e.charCodeAt(s+1)===62)l=49,f=s+2;else{let u=s,m=!1;for(;u<o;u++){let h=e.charCodeAt(u);if(h===10||h===13)break;if(h===62&&e.charCodeAt(u+1)===62){m=!0;break}}if(m&&e.slice(s,u).trim()!=="")t.push(50),n.push(s),r.push(u),l=49,s=u,f=u+2;else{for(;u<o&&e.charCodeAt(u)!==10&&e.charCodeAt(u)!==13;)u++;if(u===s){for(;u<o&&(e.charCodeAt(u)===10||e.charCodeAt(u)===13);)u++;throw iA(e,s,u-s)}l=51,f=u}}}else if(e.charCodeAt(f)===45&&e.charCodeAt(f+1)===45)for(l=54,f+=2;e.charCodeAt(f)===45;)f++;else l=33;else if(c===58)e.charCodeAt(f)===58&&e.charCodeAt(f+1)===58?(l=52,f+=2):l=25;else if(c===64)e.charCodeAt(f)===123?(l=60,f++):l=23;else if(c===123)l=61;else if(c===125)l=62;else if(c===91)l=63;else if(c===93)l=64;else if(c===40)l=65;else if(c===41)l=66;else if(c===44)l=24;else if(c===35){for(;qo(e.charCodeAt(f));)f++;l=f>s+1?26:32}else if(c===92)e.charCodeAt(f)===44?(l=28,f++):l=33;else if(c<127&&c>32)l=(as[c]&oA)!==0?32:33;else for(l=34;f<o;){let u=e.charCodeAt(f);if(u>=32&&u<127||u===9||u===10||u===13)break;f++}t.push(l),n.push(s),r.push(f),s=f,a=p}for(let c=0;c<3;c++)t.push(0),n.push(o),r.push(o);return{types:t,starts:n,ends:r}}function dA(){return{type:"usecase",actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,direction:"LR",title:void 0,accTitle:"",accDescr:"",accDescription:"",source:"",headerSpan:[0,0],statements:[]}}function uA(){return{elements:[],boundaries:[],jsons:[],relationships:[],notes:[],metadata:[],classes:[],styles:[],classDefs:[],direction:void 0,accTitle:"",accDescription:""}}function zf(e,t){if(t.length===0)return;let n=new Set(e);for(let r of t)n.has(r)||(n.add(r),e.push(r))}function yN(e){let t=new Set(["actor","usecase","boundary","edge"]);for(let{key:n,value:r}of e)if(n==="icon")t.clear(),t.add("actor");else if(n==="animate"||n==="animation")t.clear(),t.add("edge");else if(n==="type")t.clear(),r==="rect"||r==="package"?t.add("boundary"):(r==="normal"||r==="hollow"||r==="awesome")&&t.add("actor");else if(n==="business")t.delete("boundary"),t.delete("edge");else return;return t.size===1?[...t][0]:void 0}function fA(e,t,n,r,o){let s=dA(),{actors:a,useCases:i,systemBoundaries:c}=s,l=new Map,f=new Map,p=new Map,u=new Map,m=new Map,h=A=>aA(e,A[0],A[1]),g=(A,T)=>{let[b,N]=Gs(e,T[0]);return new Ge(A,"semantic",{type:"usecase",line:b,column:N})},x=(A,T)=>{throw g(`${A} at ${h(T)}`,T)},y=(A,T,b,N,$)=>{let X=V=>V===void 0?"":` (label "${V}")`;throw g(`${A} at ${h(T)}${X(N)}; previous declaration at ${h(b)}${X($)}`,T)},_=(A,T,b)=>x(`Metadata property '${b.key}' is invalid for ${T} '${A}'`,b.keySpan),S=(A,T)=>{let b=m.get(A);(b===void 0||T<b)&&m.set(A,T)},P=A=>[...A].sort((T,b)=>(m.get(T.id)??0)-(m.get(b.id)??0)),k=(A,T)=>{l.set(A.id,{kind:T,span:A.span,generated:A.generated,label:A.label.text})},w=(A,T)=>{let b=l.get(A.id);if(!b)return;let N=A.generated?A.label.text:void 0,$=b.generated?b.label:void 0;b.kind!==T&&y(`ID '${A.id}' is declared as both ${b.kind} and ${T}`,A.span,b.span,N,$),(b.generated||A.generated)&&y(`Generated ID '${A.id}' collides with another declaration`,A.span,b.span,N,$)},I=(A,T,b)=>{let N=l.get(A);N&&y(`ID '${A}' is declared more than once (${N.kind} and ${T})`,b,N.span,void 0,N.generated?N.label:void 0),l.set(A,{kind:T,span:b,generated:!1})},D=(A,T,b)=>{let{key:N,value:$}=T,X=V=>{!b&&V!==void 0&&V!==$&&y(`Actor '${A.id}' has conflicting ${N} metadata`,T.keySpan,A.span)};N==="type"&&($==="normal"||$==="hollow"||$==="awesome")?(X(A.actorType),A.actorType=$):N==="icon"&&typeof $=="string"?(X(A.icon),A.icon=$):N==="business"&&typeof $=="boolean"?(X(A.business),A.business=$):_(A.id,"actor",T)},U=(A,T,b)=>{for(let N of T??[])A.kind==="actor"?D(A,N,b):N.key==="business"&&typeof N.value=="boolean"?(!b&&A.business!==void 0&&A.business!==N.value&&y(`Use case '${A.id}' has conflicting business metadata`,N.keySpan,A.span),A.business=N.value):_(A.id,"usecase",N)},M=A=>{let T;if(A.kind==="actor"){i.delete(A.id);let b={id:A.id,label:A.label.text,labelType:A.label.type,business:A.business??!1,classes:[...A.classes],type:A.icon?"icon":A.actorType??"normal",styles:a.get(A.id)?.styles??[]};A.icon&&(b.icon=A.icon),a.set(A.id,b),T=b}else a.delete(A.id),T={id:A.id,label:A.label.text,labelType:A.label.type,business:A.business??!1,classes:[...A.classes],shape:A.shape??"ellipse",styles:i.get(A.id)?.styles??[]},i.set(A.id,T);A.stereotype&&(T.stereotype=A.stereotype),A.parent?.id&&(T.parentId=A.parent.id)},Q=A=>{w(A,A.kind);let T=A.parent?.id?A.parent:void 0,b=f.get(A.id);if(!b){let N={kind:A.kind,id:A.id,label:A.label,span:A.span,generated:A.generated,classes:[...A.classes],parent:T,shape:A.shape,stereotype:A.stereotype,stereotypeSpan:A.stereotype?A.span:void 0};U(N,A.metadata,!1),f.set(A.id,N),k(A,A.kind);return}(b.label.text!==A.label.text||b.label.type!==A.label.type)&&y(`ID '${A.id}' has conflicting labels`,A.span,b.span),A.shape&&b.shape&&A.shape!==b.shape&&y(`Use case '${A.id}' has conflicting shapes`,A.span,b.span),T&&b.parent?.id&&T.id!==b.parent.id&&y(`Element '${A.id}' belongs to more than one system boundary`,T.span,b.parent.span),A.stereotype&&b.stereotype&&A.stereotype!==b.stereotype&&y(`Element '${A.id}' has conflicting stereotypes`,A.span,b.stereotypeSpan??b.span),b.shape??=A.shape,b.parent??=A.parent,b.stereotype??=A.stereotype,b.stereotypeSpan??=A.stereotype?A.span:void 0,zf(b.classes,A.classes),U(b,A.metadata,!1)},q=A=>{w(A,"boundary");let T=p.get(A.id);if(T){(T.label.text!==A.label.text||T.label.type!==A.label.type)&&y(`Boundary '${A.id}' has conflicting titles`,A.span,T.span),zf(T.classes,A.classes);return}p.set(A.id,{...A,classes:[...A.classes],members:[]}),k(A,"boundary")},Y=A=>{A.classed&&!A.declares&&x(`Relationship endpoint '${A.id}' uses ::: without declaring the node`,A.span);let T=l.get(A.id);return T?T.kind:(f.set(A.id,{...A,kind:"usecase",shape:"ellipse",classes:[]}),k(A,"usecase"),S(A.id,A.span[0]),"usecase")},z=(A,T)=>{let b=l.get(A)?.kind;return(b==="actor"?a.get(A):b==="usecase"?i.get(A):b==="boundary"?c.get(A):b==="json"?s.jsonNodes.get(A):u.get(A))??x(`Class/style target '${A}' is unresolved or anonymous`,T)},R=[];for(let{source:A,target:T}of t.relationships)S(A.id,A.span[0]),S(T.id,T.span[0]);for(let A of t.elements)S(A.id,A.span[0]),R.push({offset:A.span[0],run:()=>Q(A)});for(let A of t.boundaries)S(A.id,A.span[0]),R.push({offset:A.span[0],run:()=>q(A)});for(let A of t.jsons)S(A.id,A.span[0]),R.push({offset:A.span[0],run:()=>I(A.id,"json",A.span)});for(let{id:A,idSpan:T}of t.relationships)A&&T&&R.push({offset:T[0],run:()=>I(A,"edge",T)});R.sort((A,T)=>A.offset-T.offset);for(let A of R)A.run();for(let A of P(f.values()))M(A);for(let A of P(p.values()))c.set(A.id,{id:A.id,label:A.label.text,labelType:A.label.type,type:"rect",members:[],classes:[],styles:[]});for(let A of P(t.jsons))s.jsonNodes.set(A.id,{id:A.id,value:A.value,propertyOrder:A.propertyOrder,classes:[...A.classes],styles:[]});let L=0;for(let A of t.relationships){let{source:T,target:b,type:N}=A,$=Y(T),X=Y(b),V=W=>W==="actor"||W==="usecase"||W==="json";V($)||y(`Relationship source '${T.id}' cannot be ${$}`,T.span,l.get(T.id).span),V(X)||y(`Relationship target '${b.id}' cannot be ${X}`,b.span,l.get(b.id).span),(N==="include"||N==="extend")&&($!=="usecase"||X!=="usecase")&&x(`${N} relationship requires use-case endpoints`,A.span),N==="generalization"&&($==="json"||$!==X)&&x("Generalization requires actor-to-actor or use-case-to-use-case endpoints",A.span),N==="association"&&($==="json"||X==="json")&&A.arrowType>2&&x(`JSON relationship '${T.id}' to '${b.id}' permits only point, reversed-point, or markerless solid association`,A.span);let O=A.id??`edge-${L++}`,v={id:O,explicitId:!!A.id,source:T.id,target:b.id,type:N,arrowType:A.arrowType,minlen:A.minlen,classes:[],styles:[],animate:!1};A.label&&(v.label=A.label.text,v.labelType=A.label.type),s.relationships.push(v),u.set(O,v)}let F=new Map(a),E=new Map(i);a.clear(),i.clear();for(let A of P(f.values())){let T=F.get(A.id),b=E.get(A.id);T?a.set(A.id,T):b?i.set(A.id,b):M(A)}for(let{target:A,span:T,properties:b,statement:N}of t.metadata){let $=l.get(A);if(!$){let v=yN(b);return x(`Metadata target '${A}' is unresolved${v?` (metadata implies ${v})`:""}`,T)}let X=$.kind;X==="actor"||X==="usecase"?U(f.get(A),b,!0):X==="edge"&&(N.kind="edgeMetadata",N.edges=[{id:A,span:N.span,idSpan:T,metadata:N.metadata}],delete N.nodes);let V=p.get(A),O=u.get(A);for(let v of X==="actor"||X==="usecase"?[]:b){let{key:W,value:H}=v;X==="boundary"&&V&&W==="type"&&(H==="rect"||H==="package")?V.type=H:X==="edge"&&O&&W==="animate"&&typeof H=="boolean"?O.animate=H:X==="edge"&&O&&W==="animation"&&(H==="fast"||H==="slow")?(O.animation=H,O.animate=!0):_(A,X,v)}}for(let A of s.relationships)A.animation&&(A.animate=!0);for(let A of f.values())A.kind==="actor"?(A.icon&&A.actorType&&A.actorType!=="normal"&&x(`Actor '${A.id}' cannot combine icon with type '${A.actorType}'`,A.span),A.business&&(A.icon||A.actorType==="awesome")&&x(`Business actor '${A.id}' must use normal or hollow geometry`,A.span)):A.shape==="rect"&&A.business&&x(`Rectangular use case '${A.id}' cannot be a business use case`,A.span),M(A);for(let A of[...t.elements].sort((T,b)=>T.span[0]-b.span[0])){if(!A.parent?.id)continue;let T=p.get(A.parent.id).members;T.includes(A.id)||T.push(A.id)}for(let A of p.values()){let T=c.get(A.id);T.type=A.type??"rect",T.members=A.members,T.classes=[...A.classes]}let C=0;for(let A of t.notes){let T=l.get(A.target);if(!T)return x(`Note target '${A.target}' is unresolved`,A.span);T.kind!=="actor"&&T.kind!=="usecase"&&y(`Note target '${A.target}' must be an actor or use case, not ${T.kind}`,A.span,T.span);let b=`note-${C++}`;s.notes.set(b,{id:b,target:A.target,label:A.label.text,labelType:A.label.type})}for(let A of t.classDefs)for(let T of A.ids)s.classDefs.set(T,{id:T,styles:[...A.styles]});for(let A of t.classes)for(let T of A.targets)zf(z(T.id,T.span).classes,A.classes);for(let A of t.styles)z(A.target,A.span).styles.push(...A.styles);return s.direction=t.direction??s.direction,s.title=o,s.accTitle=t.accTitle,s.accDescription=t.accDescription,s.accDescr=t.accDescription.replace(/\n\s+/g,`
135
+ `),s.source=e,s.headerSpan=n,s.statements=r,s}var bn=class extends Error{constructor(n){super("Invalid JSON token");this.offset=n}offset};function pA(e){let t=new Map,n=[],r=[],o=e.length,s=0,a="",i=0,c=()=>{for(;s<o;){let u=e.charCodeAt(s);if(u!==32&&u!==9&&u!==10&&u!==13)return;s++}},l=u=>{s++;let m="";for(;s<o;){let h=s,g=e[s++];if(g==='"')return m;if(g.charCodeAt(0)<32)throw new bn(h);if(g!=="\\"){u&&(m+=g);continue}let x=s,y=e[s++],_;if(y==='"'||y==="\\"||y==="/")_=y;else if(y==="b")_="\b";else if(y==="f")_="\f";else if(y==="n")_=`
136
+ `;else if(y==="r")_="\r";else if(y==="t")_=" ";else if(y==="u"){let S=e.slice(s,s+4);if(!/^[\dA-Fa-f]{4}$/.test(S))throw new bn(s);_=String.fromCharCode(parseInt(S,16)),s+=4}else throw new bn(x);u&&(m+=_)}throw new bn(s)},f=u=>{for(let m=0;m<u.length;m++)if(e[s+m]!==u[m])throw new bn(s+m);s+=u.length},p=()=>{if(e.charCodeAt(s)===45&&s++,e.charCodeAt(s)===48)s++;else if(ft(e.charCodeAt(s)))for(;ft(e.charCodeAt(s));)s++;else throw new bn(s);if(e.charCodeAt(s)===46){if(s++,!ft(e.charCodeAt(s)))throw new bn(s);for(;ft(e.charCodeAt(s));)s++}if((e.charCodeAt(s)|32)===101){if(s++,(e.charCodeAt(s)===43||e.charCodeAt(s)===45)&&s++,!ft(e.charCodeAt(s)))throw new bn(s);for(;ft(e.charCodeAt(s));)s++}};for(c();;)if(i===0){c();let u=e.charCodeAt(s);if(i=2,u===123){s++;let m=[];t.set(a,m),n.push(a),c(),e.charCodeAt(s)===125?s++:(r.push({object:!0,pointer:a,keys:m,ranges:new Map,key:"",from:0,index:0}),i=1)}else if(u===91)s++,c(),e.charCodeAt(s)===93?s++:(r.push({object:!1,pointer:a,keys:[],ranges:new Map,key:"",from:0,index:0}),a+="/0",i=0);else if(u===34)l(!1);else if(u===116)f("true");else if(u===102)f("false");else if(u===110)f("null");else if(u===45||ft(u))p();else throw new bn(s)}else if(i===1){let u=r[r.length-1];if(e.charCodeAt(s)!==34)throw new bn(s);let m=l(!0),h=u.ranges.get(m);if(h===void 0)u.keys.push(m);else for(let g=h[0];g<h[1];g++)t.delete(n[g]);if(u.key=m,u.from=n.length,c(),e.charCodeAt(s)!==58)throw new bn(s);s++,a=`${u.pointer}/${m.replaceAll("~","~0").replaceAll("/","~1")}`,i=0}else{let u=r[r.length-1];if(u===void 0)break;u.object?u.ranges.set(u.key,[u.from,n.length]):u.index++,c();let m=e.charCodeAt(s);if(m===(u.object?125:93))s++,r.pop();else{if(m!==44)throw new bn(s);s++,c(),a=`${u.pointer}/${u.index}`,i=u.object?1:0}}if(c(),s!==o)throw new bn(s);return t}function Vf(e,t,n,r){let o=Math.min(Math.max(t,0),e.length);for(let s=0;s<o;s++){let a=e.charCodeAt(s);a===13?(n++,r=1):a===10?(s===0||e.charCodeAt(s-1)!==13)&&(n++,r=1):r++}return[n,r]}function EN(e,t,n,r){let o=/\bposition (\d+)\b/.exec(e);if(o)return Vf(t,parseInt(o[1],10),n,r);let s=/\bline (\d+) column (\d+)\b/.exec(e);if(s){let a=parseInt(s[1],10),i=parseInt(s[2],10);return[n+a-1,a===1?r+i-1:i]}if(/unexpected end|end of json input/i.test(e))return Vf(t,t.length,n,r)}function hA(e,t,n){return new Ge(`${e} (line ${t}, column ${n})`,"syntax",{type:"usecase",line:t,column:n})}function mA(e,t){let n;try{n=JSON.parse(e)}catch(r){let o=r instanceof Error?r.message:String(r),[s,a]=t(),i=EN(o,e,s,a);if(!i){let c=0;try{pA(e)}catch(l){l instanceof bn&&(c=l.offset)}i=Vf(e,c,s,a)}throw hA(`Invalid JSON: ${o}`,i[0],i[1])}if(typeof n!="object"||n===null||Array.isArray(n)){let[r,o]=t();throw hA("JSON value must have an object root",r,o)}return{value:n,propertyOrder:pA(e)}}var _A=1,Zf=2,qf=4,wA=8,RA=16,TA=32,CA=64,_l="DEPENDENCY_ARROW|GENERALIZATION|FORWARD_SOLID|BACKWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|BACKWARD_CIRCLE|FORWARD_CROSS|BACKWARD_CROSS",wl="IDENTIFIER|PLAIN_STRING|MARKDOWN_STRING",AN="PLAIN_STRING|MARKDOWN_STRING|LABEL_TEXT",IA="ACC_TITLE_LINE|ACC_DESCR_LINE|ACC_DESCR_BLOCK|DIRECTION|ACTOR|SYSTEM_BOUNDARY|NOTE|JSON_DECLARATION_START|CLASS_DEF|CLASS|STYLE",NA="WORD|PLAIN_STRING|NUMBER|HASH_COLOR|CSS_IDENTIFIER|CSS_ESCAPED_COMMA|DASH|DOT|PERCENT|CSS_PUNCTUATION|COLON|LPAREN|RPAREN|LBRACKET|RBRACKET|LBRACE|RBRACE|AT|MARKERLESS_SOLID",nr=new Uint8Array(67);function Ks(e,t){for(let n of e.split("|"))if(n==="WORD")for(let r=1;r<=21;r++)nr[r]|=t;else nr[Hf.indexOf(n)]|=t}Ks(`NEWLINE|COMMENT|${IA}|${wl}`,_A);Ks(`IDENTIFIER|${_l}`,Zf);Ks(NA,qf);Ks(`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${_l}|NEWLINE|EOF`,wA);Ks(`NEWLINE|COMMENT|ACTOR|${wl}`,RA);Ks("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS",TA);Ks("NEWLINE|IDENTIFIER|PLAIN_STRING|RBRACE",CA);var xN=new Set(["allowmixing","newpage","package","rectangle","skinparam"]),Cn="",tt=[],dn=[],xn=[],ve=0,MA=0,ln,xl,Al=[],kA=0,LA=0;function Qt(e){return Cn.slice(dn[e],xn[e])}function $n(e){return[dn[e],xn[e]]}function Rl(e){let[t,n]=Gs(Cn,dn[ve]);throw new Ge(`Error parsing usecase diagram: ${e} at line ${t}, column ${n} [${dn[ve]},${xn[ve]})`,"syntax",{type:"usecase",line:t,column:n})}function $A(e){Rl(`Expecting token of type --> ${e} <-- but found --> '${Qt(ve)}' <--`)}function Jt(e){return tt[ve]!==e&&$A(Hf[e]),ve++}function Un(e){let t=e.split("|").map((n,r)=>` ${r+1}. [${n}]`);Rl(`Expecting: one of these possible Token sequences:
137
+ ${t.join(`
138
+ `)}
139
+ but found: '${Qt(ve)}'`)}function gA(){let e=wl.split("|"),t=e.flatMap(o=>["NEWLINE","IDENTIFIER","PLAIN_STRING","RBRACE"].map(s=>`${o}, METADATA_START, ${s}`)),n=`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${_l}|NEWLINE|EOF`.split("|"),r=e.flatMap((o,s)=>(s===0?["LPAREN","LBRACKET",...n]:n).map(a=>`${o}, ${a}`));return[IA,...t,...r,...t].join("|")}function bA(e){return e>=1&&e<=21}function yA(e){return e>=1&&e<=34}function Hs(){MA=xn[ve-1],tt[ve]===39?ve++:tt[ve]!==0&&Un("NEWLINE|EOF")}function Fo(e){let t=tt[e]===36?2:tt[e]===35?1:0;return[dn[e]+t,xn[e]-t]}function Qf(e){let t=Fo(e);return{text:Cn.slice(t[0],t[1]),type:tt[e]===36?"markdown":"text",span:t}}function DA(e){return e.replace(/\W/g,"_")}function Bo(){let e=tt[ve];if(e===35||e===36)return Qf(ve++);yA(e)||Un(AN);let t=ve;for(;yA(tt[ve]);)ve++;let n=[dn[t],xn[ve-1]];return{text:Cn.slice(n[0],n[1]),type:"text",span:n}}function Ys(e){return e===21||e===35}function EA(){let e=ve;Ys(tt[ve])||Un("IDENTIFIER|PLAIN_STRING"),ve++,Jt(25);let t=ve,n=tt[ve];!Ys(n)&&n!==19&&n!==20&&Un("IDENTIFIER|PLAIN_STRING|TRUE|FALSE"),ve++;let r=Fo(e),o=Fo(t);return{key:Cn.slice(r[0],r[1]),value:n===19?!0:n===20?!1:Cn.slice(o[0],o[1]),span:[dn[e],xn[t]],keySpan:r,valueSpan:o}}function SN(){let e=tt[ve],t=tt[ve+1],n=tt[ve+2];return e===24?Ys(t)||t===39&&(n===39||Ys(n)):e!==39?!1:t===24||Ys(t)||t===39&&(n===39||n===24||Ys(n))}function Jf(){Jt(60);let e=[];for(;tt[ve]===39;)ve++;if(Ys(tt[ve])){for(e.push(EA());SN();){if(tt[ve]===24)ve++;else{for(;tt[ve]===39;)ve++;tt[ve]===24&&ve++}for(;tt[ve]===39;)ve++;e.push(EA())}for(tt[ve]===24&&ve++;tt[ve]===39;)ve++}return Jt(62),e}function ep(e){return e.map(({key:t,span:n,keySpan:r,valueSpan:o})=>({key:t,span:n,keySpan:r,valueSpan:o}))}function tp(e,t){do{ve++;let n=Jt(21);e.push(Qt(n)),t.push($n(n))}while(tt[ve]===24)}function OA(e){let t=ve,n=tt[ve],r={id:"",label:void 0,span:Fo(t),generated:n!==21,classes:[],classSpans:[],explicit:!1,nodeSpan:[0,0]};if(n===21){ve++,r.id=Qt(t);let o=tt[ve];o===65||e&&o===63?(ve++,r.label=Bo(),Jt(o===65?66:64),r.shape=o===65?"ellipse":"rect"):r.label=Qf(t)}else n===35||n===36?(ve++,r.label=Qf(t),r.id=DA(r.label.text)):Un(wl);return r}function Sl(e){let t=ve,n=OA(!e);if(e&&(n.shape=void 0),tt[ve]===60&&(n.metadata=Jf()),tt[ve]===48){ve++;let r=Jt(50);Jt(49),n.stereotype=Qt(r).trim(),n.stereotypeSpan=$n(r)}return tt[ve]===52&&tp(n.classes,n.classSpans),n.explicit=!!(n.shape||n.metadata||n.stereotype),n.nodeSpan=[dn[t],xn[ve-1]],n}function np(e,t){return{id:e.id,kind:t,label:e.label,span:e.span,generated:e.generated,parent:xl,shape:e.shape,metadata:e.metadata,stereotype:e.stereotype,classes:e.classes}}function AA(e,t){return{id:e.id,label:e.label,span:e.span,generated:e.generated,declares:t,classed:e.classes.length>0}}function rp(e,t){let n={id:e.id,span:e.nodeSpan,idSpan:e.span,labelSpan:e.label.span};return t&&(n.defines=!0),e.stereotypeSpan&&(n.stereotypeSpan=e.stereotypeSpan),e.metadata&&(n.metadata=ep(e.metadata)),e.classSpans.length>0&&(n.classSpans=e.classSpans),n}function jf(e){if(tt[ve]<1||tt[ve]>36)return!1;for(let t=ve+1;;t++){let n=tt[t];if(n===59||(nr[n]&e)!==0)return!0;if(n<1||n>36)return!1}}function Po(e){let t=xn[e]-dn[e]-(tt[e]===59?0:1);return Math.max(1,t-1)}function vA(){let e=ve,t={type:"association",arrowType:0,minlen:1,target:void 0,span:[0,0]};tt[ve]===21&&tt[ve+1]===23&&(t.explicitId=Qt(ve),t.explicitIdSpan=$n(ve),ve+=2);let n=ve,r=tt[ve++];if(r===47)Jt(25),tt[ve]!==17&&tt[ve]!==18&&Un("INCLUDE|EXTEND"),t.type=tt[ve]===17?"include":"extend",t.label={text:t.type,type:"text",span:$n(ve)},ve++;else if(r===46)t.type="generalization";else if(r===53)t.minlen=Po(n);else if(r===54)t.arrowType=1,xn[n]-dn[n]===3&&jf(0)?(t.label=Bo(),t.minlen=Po(Jt(59))):t.minlen=Po(n);else if(r===59)if(t.arrowType=2,xn[n]-dn[n]===2&&jf(TA)){t.label=Bo();let o=tt[ve];o===53?t.arrowType=0:o===55?t.arrowType=3:o===57?t.arrowType=4:o!==59&&Un("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS"),(t.arrowType===0||t.arrowType===2)&&(t.minlen=Po(ve)),ve++}else t.minlen=Po(n);else r===55?t.arrowType=3:r===57?t.arrowType=4:r===56||r===58?(t.arrowType=r===56?5:6,jf(0)&&(t.label=Bo(),Jt(59))):(ve--,Un(_l));return t.target=Sl(!1),t.span=[dn[e],xn[ve-1]],t}function tr(e){return{kind:e,span:[0,0]}}function PA(e,t,n,r){let o=n.target;o.explicit&&ln.elements.push(np(o,"usecase")),ln.relationships.push({source:AA(e,t),target:AA(o,o.explicit),span:n.span,id:n.explicitId,idSpan:n.explicitIdSpan,type:n.type,arrowType:n.arrowType,label:n.label,minlen:n.minlen}),r.push(rp(o,o.explicit));let s=tr("edge");return s.nodes=r,s.edges=[{id:n.explicitId??`edge-${kA++}`,span:s.span}],n.explicitIdSpan&&(s.edges[0].idSpan=n.explicitIdSpan),n.label&&(s.edges[0].labelSpan=n.label.span),s}function BA(e){let t=tr("node");return t.nodes=e,t}function FA(e){ve++;let t=[Sl(!0)],n;if(tt[ve]===24)do ve++,t.push(Sl(!0));while(tt[ve]===24);else e&&(nr[tt[ve]]&Zf)!==0&&(n=vA());Hs();for(let o of t)ln.elements.push(np(o,"actor"));let r=t.map(o=>rp(o,!0));return n?PA(t[0],!0,n,r):BA(r)}function WA(e){let t=Sl(!1),n=e&&(nr[tt[ve]]&Zf)!==0?vA():void 0;Hs(),n||(t.explicit=!0,t.shape??="ellipse"),t.explicit&&ln.elements.push(np(t,"usecase"));let r=[rp(t,t.explicit)];return n?PA(t,t.explicit,n,r):BA(r)}function _N(){ve++;let e=OA(!0),t={id:e.id,label:e.label,span:e.span,generated:e.generated,classes:e.classes},n=tt[ve]===60?Jf():void 0;tt[ve]===52&&tp(e.classes,e.classSpans),Hs(),ln.boundaries.push(t),xl=t;let r=[];for(;(nr[tt[ve]]&RA)!==0;)r.push(UA(!1));xl=void 0;let o=Jt(4);Hs();let s=tr("group");return s.group=t.id,s.idSpan=t.span,s.titleSpan=t.label.span,s.endSpan=$n(o),s.classSpans=e.classSpans,r.length>0&&(s.children=r),n&&(s.metadata=ep(n),ln.metadata.push({target:t.id,span:t.span,properties:n,statement:s})),s}function xA(){let e=ve,t=tt[ve];for(bA(t)||t===27?ve++:t===59?(ve++,bA(tt[ve])||$A("WORD"),ve++):Un("WORD|CSS_IDENTIFIER|MARKERLESS_SOLID"),Jt(25),(nr[tt[ve]]&qf)===0&&Rl(`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
140
+ <[${NA.replaceAll("|","] ,[")}]>
141
+ but found: '${Qt(ve)}'`);(nr[tt[ve]]&qf)!==0;)ve++;return Cn.slice(dn[e],xn[ve-1]).replaceAll("\\,",",")}function SA(){let e=[xA()];for(;tt[ve]===24;)ve++,e.push(xA());return e}function Xf(){let e=[Jt(21)];for(;tt[ve]===24;)ve++,e.push(Jt(21));return e}function El(e){let t=Fo(e);return{id:Qt(e),span:t,idSpan:t}}function wN(){let e=ve,t=tt[ve],n;if(t===41||t===42||t===40){ve++;let r=Qt(e);t===40?ln.accDescription=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim():t===42?ln.accDescription=r.slice(r.indexOf(":")+1).trim():ln.accTitle=r.slice(r.indexOf(":")+1).trim(),n=tr(t===41?"accTitle":"accDescr")}else if(t===5){ve++;let r=tt[ve];(r<6||r>10)&&Un("TD|TB|BT|LR|RL"),ln.direction=r===6?"TB":Qt(ve),ve++,n=tr("direction")}else{if(t===2)return FA(!0);if(t===3)return _N();if(t===11){ve++,Jt(12);let r=Jt(21),o=Bo();ln.notes.push({target:Qt(r),span:$n(r),label:o}),n=tr("note"),n.ref=`note-${LA++}`,n.refSpan=o.span,n.nodes=[El(r)]}else if(t===43){ve++;let r=Jt(44),o=[],s=[];tt[ve]===52&&tp(o,s);let a=dn[e]+4;for(;Cn.charCodeAt(a)===32||Cn.charCodeAt(a)===9;)a++;let i=a;for(;/\w/.test(Cn.charAt(i));)i++;let c={id:Cn.slice(a,i),value:{},propertyOrder:new Map,span:[a,i],classes:o};ln.jsons.push(c),Al.push([c,r]),n=tr("json"),n.nodes=[{id:c.id,span:c.span,idSpan:c.span,defines:!0,classSpans:s}],n.classSpans=s}else if(t===14){ve++;let r=Xf();ln.classDefs.push({ids:r.map(Qt),styles:SA()}),n=tr("classDef"),n.ref=Qt(r[0]),n.refSpan=$n(r[0])}else if(t===15){ve++;let r=Xf(),o=Xf();ln.classes.push({targets:r.map(s=>({id:Qt(s),span:$n(s)})),classes:o.map(Qt)}),n=tr("classAssign"),n.ref=Qt(o[0]),n.refSpan=$n(o[0]),n.nodes=r.map(El)}else if(t===16){ve++;let r=Jt(21);ln.styles.push({target:Qt(r),span:$n(r),styles:SA()}),n=tr("style"),n.nodes=[El(r)]}else{let r=tt[ve+1];if(r===60){(nr[tt[ve+2]]&CA)===0&&Un(gA()),ve++;let o=El(e);t!==21&&(o.id=DA(Cn.slice(o.span[0],o.span[1])));let s=Jf();n=tr("metadata"),n.nodes=[o],n.metadata=ep(s),ln.metadata.push({target:o.id,span:o.span,properties:s,statement:n})}else return(!((nr[r]&wA)!==0||t===21&&(r===65||r===63))||t===21&&xN.has(Qt(e).toLowerCase()))&&Un(gA()),WA(!0)}}return Hs(),n}function UA(e){let t=ve,n=tt[ve];if(n===39)return ve++,{kind:"blank",span:$n(t)};if(n===38)return ve++,Hs(),{kind:"comment",span:$n(t)};let r=e?wN():n===2?FA(!1):WA(!1);if(r.span=[dn[t],MA],r.edges)for(let o of r.edges)o.span=r.span;return r}function GA(e,t){Cn=e,{types:tt,starts:dn,ends:xn}=lA(e),ve=0,ln=uA(),xl=void 0,Al=[],kA=0,LA=0;try{let n=Jt(1);Hs();let r=[];for(;(nr[tt[ve]]&_A)!==0;)r.push(UA(!0));tt[ve]!==0&&Rl(`Redundant input, expecting EOF but found: ${Qt(ve)}`);for(let[o,s]of Al){let a=mA(Qt(s),()=>Gs(e,dn[s]));o.value=a.value,o.propertyOrder=a.propertyOrder}return fA(e,ln,$n(n),r,t)}finally{Cn="",tt=dn=xn=Al=[]}}var RN={normal:"usecaseActor",hollow:"usecaseActorHollow",awesome:"usecaseActorAwesome",icon:"usecaseActorIcon"},sp=[["none","arrow_point"],["arrow_point","none"],["none","none"],["none","arrow_circle"],["none","arrow_cross"],["arrow_circle","none"],["arrow_cross","none"]];function YA(e){return typeof e=="string"?e:e===null?"null":String(e)}function TN(e){let t=[],n=[[e.value,"",""]],r=[];for(;n.length>0;){let[o,s,a]=n.pop();if(r.length=0,Array.isArray(o))o.length===0?t.push({key:s,accessibleKey:s,value:"[]"}):o.every(i=>i===null||typeof i!="object")?o.forEach((i,c)=>t.push({key:c===0?s:"",accessibleKey:s,value:YA(i)})):o.forEach((i,c)=>r.push([i,`${s}[${c}]`,`${a}/${c}`]));else if(o!==null&&typeof o=="object"){let i=o,c=e.propertyOrder.get(a)??Object.keys(i);c.length===0&&t.push({key:s,accessibleKey:s,value:"{}"});for(let l of c)r.push([Object.prototype.hasOwnProperty.call(i,l)?i[l]:void 0,s?`${s}.${l}`:l,`${a}/${l.replaceAll("~","~0").replaceAll("/","~1")}`])}else t.push({key:s,accessibleKey:s,value:YA(o)});for(let i=r.length-1;i>=0;i--)n.push(r[i])}return t}function Wo(...e){return e.filter(Boolean).join(" ")}function CN(e){return e.type==="generalization"?["none","extension"]:e.type!=="association"?sp[0]:sp[e.arrowType]??sp[2]}function HA(e){let t=[],n=[],r=o=>{let s=new Map;for(let a of["default",...o]){let i=e.classDefs.get(a);if(i)for(let c of i.styles){let l=c.trim(),f=l.indexOf(":"),p=(f===-1?l:l.slice(0,f)).trim();p&&s.set(p,l)}}return[...s.values()]};for(let o of e.actors.values())t.push({id:o.id,label:o.label,labelType:o.labelType,shape:RN[o.type],isGroup:!1,padding:10,cssClasses:Wo("default","usecase-actor",`usecase-actor-${o.type}`,o.business&&"usecase-business",...o.classes),cssStyles:[...o.styles],cssCompiledStyles:r(o.classes),actorType:o.type,business:o.business,icon:o.icon||void 0,stereotype:o.stereotype||void 0,parentId:o.parentId||void 0});for(let o of e.useCases.values()){let s=o.shape==="ellipse";t.push({id:o.id,label:o.label,labelType:o.labelType,shape:s?o.business?"usecaseBusiness":"usecaseEllipse":"rect",isGroup:!1,padding:s?20:10,cssClasses:Wo("default","usecase-element",`usecase-${o.shape}`,o.business&&"usecase-business",...o.classes),cssStyles:[...o.styles],cssCompiledStyles:r(o.classes),business:o.business,stereotype:o.stereotype||void 0,parentId:o.parentId||void 0})}for(let o of e.notes.values())t.push({id:o.id,label:o.label,labelType:o.labelType,shape:"note",isGroup:!1,padding:10,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:r([]),noteTarget:o.target});for(let o of e.jsonNodes.values())t.push({id:o.id,label:o.id,labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,cssClasses:Wo("default","usecase-json-table",...o.classes),cssStyles:[...o.styles],cssCompiledStyles:r(o.classes),jsonRows:TN(o)});for(let o of e.systemBoundaries.values())t.push({id:o.id,label:o.label,labelType:o.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,cssClasses:Wo("default","system-boundary",`system-boundary-${o.type}`,...o.classes),cssStyles:[...o.styles],cssCompiledStyles:r(o.classes),boundaryType:o.type});for(let o of e.relationships){let s=o.type==="include"||o.type==="extend",[a,i]=CN(o),c=o.animate||o.animation!==void 0,l={id:o.id,start:o.source,end:o.target,relationshipType:o.type,pattern:s?"dotted":"solid",arrowTypeStart:a,arrowTypeEnd:i,classes:Wo("default","relationship",`relationship-${o.type}`,...o.classes,c&&`edge-animation-${o.animation??"fast"}`),style:[...o.styles],cssCompiledStyles:r(o.classes),animate:o.animate,animation:o.animation,minlen:o.minlen,explicitId:o.explicitId,internal:!1};s?(l.label=o.type,l.labelType="text"):o.type==="association"&&(o.label&&(l.label=o.label),o.labelType&&(l.labelType=o.labelType)),n.push(l)}for(let o of e.notes.values())n.push({id:`${o.id}-edge`,start:o.id,end:o.target,relationshipType:"note",pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",classes:"default relationship relationship-note",style:[],cssCompiledStyles:r([]),animate:!1,minlen:1,explicitId:!1,internal:!0});return{nodes:t,edges:n}}var IN=32,NN=16,MN=72,Tl=20,ip=26,lp=40,Go=60,KA=6,op=6,Uo=10,ap=8,Cl=9,Nl=12,kN=14,Yo=' fill="var(--_s)" stroke="var(--_b)"';function zA(e,t,n){let r=e.usecase?.[t];return typeof r=="number"&&r>0?Math.min(r,2e3):n}function LN(e){return e.replace(/[&<>\\]/g,t=>`&#${t.charCodeAt(0)};`)}function cs(e,t,n,r,o,s=0){return De(e&&!t?LN(e):e,t,n,r,o,s)}function cp(e,t,n,r){let o=n===1||n===2?1:-1,s=n===1||n===3,a=(s?e.w:e.h)/2,i=0;if(e.kind===0)s?(a=lp/2+3,i=(Go-e.h)/2):a+=2;else if(e.kind===1){let c=(s?e.h:e.w)/2;a*=Math.sqrt(Math.max(1-(r/c)**2,0))}return s?[t.x+o*a,t.y+i+r]:[t.x+r,t.y+o*a]}function XA(e,t){let n=t===1||t===3;if(e.kind===0)return n?Go*.5:lp*.6;let r=n?e.h:e.w;return e.kind===1?r*.6:r-16}function $N(e,t,n){let r=new Map,o=(s,a,i,c)=>{let l=t[s];if(l.isGroup)return;let f=a[i]-l.x,p=a[i+1]-l.y,u;if(Math.abs(Math.abs(p)-l.h/2)<.5)u=p<0?0:2;else if(Math.abs(Math.abs(f)-l.w/2)<.5)u=f<0?3:1;else return;let m=s*4+u,h={route:a,at:i,toward:a[c+(u&1?1:0)]},g=r.get(m);g?g.push(h):r.set(m,[h])};for(let s of e){let a=s.route.length-3;s.src===s.dst||a<3||(o(s.src,s.route,0,3),o(s.dst,s.route,a,a-3))}for(let[s,a]of r){let i=s>>2,c=s&3,l=n[i],f=a.length>1?Math.min(kN,XA(l,c)/(a.length-1)):0;a.sort((p,u)=>p.toward-u.toward);for(let p=0;p<a.length;p++){let[u,m]=cp(l,t[i],c,(p-(a.length-1)/2)*f);a[p].route[a[p].at]=u,a[p].route[a[p].at+1]=m}}}function DN(e,t,n,r,o){let s=e-n*Nl,a=t-r*Nl,i=Nl*.5;return`<path class="pele-marker" d="M${d(e)},${d(t)}L${d(s-r*i)},${d(a+n*i)}L${d(s+r*i)},${d(a-n*i)}Z" fill="var(--_bg)" stroke="${o}" stroke-linejoin="round"/>`}function Il(e){return e==="extension"?Nl:ht(e)}function VA(e,t,n,r,o,s){return e==="extension"?DN(t,n,r,o,s):bt(e,t,n,r,o,s)}function ON(e,t){let n=e.node,r=e.style.shape,o=` fill="none" stroke="var(--_b)"${e.style.line}`,s=-21,a=9,i;return n.actorType==="hollow"?(a=8,i=`<circle cy="-21" r="8" fill="var(--_bg)" stroke="var(--_b)"${r}/><path d="M-20,-9H20V0H5.5L20,15.5L12,25.5L0,12L-12,25.5L-20,15.5L-5.5,0H-20Z" fill="var(--_bg)" stroke="var(--_b)" stroke-linejoin="round"${r}/>`):n.actorType==="awesome"?i=`<path d="M0,-30A11,11 0 1 1 0,-8A11,11 0 1 1 0,-30ZM-20,25C-20,9 -12,-3 0,-3C12,-3 20,9 20,25C20,28 18,30 15,30H-15C-18,30 -20,28 -20,25Z" fill="var(--_b)"${r}/>`:n.actorType==="icon"?(s=-14,a=12,i=`<rect x="-22" y="-26" width="44" height="44" rx="${Xe}"${Yo}${r}/><svg class="pele-icon" data-icon="${$e(n.icon??"")}" x="-14" y="-18" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${t?.(n.icon??"")??""}</svg>`):i=`<circle cy="-21" r="9"${Yo}${r}/><path d="M0,-12V10M-14,-3H14M0,10L-12,30M0,10L12,30"${o}/>`,n.business&&(i+=`<path class="pele-business" d="M${d(.12*a)},${d(s+.99*a)}L${d(.92*a)},${d(s-.39*a)}"${o}/>`),i}function qA(e,t,n){return _n(e.direction)?Nt(n,r=>jA(e,t,n,r)):jA(e,t,n,!1)}function jA(e,t,n,r){let o=HA(e),s=n.fontSize??16,a=Math.round(s*.875),i=Math.round(s*.8125),c=n.measurer??Je(n.fontFamily),l=n.padding??8,f=n.icons,p=r?"TB":tn(e.direction),u=p==="LR"||p==="RL",m=new Map,h=[],g=[];o.nodes.forEach((E,C)=>m.set(E.id,C));for(let E of o.nodes){let C=At(E.cssStyles.length>0?E.cssCompiledStyles.concat(E.cssStyles):E.cssCompiledStyles),A=(C.bold?1:0)|(C.italic?2:0),T=C.fontSize??s,b=E.labelType==="markdown",N=cs(E.stereotype&&`«${E.stereotype}»`,!1,c,i,200,A),$={node:E,kind:2,style:C,label:N,stereotype:N,w:0,h:0,rows:[],keyW:0,headH:0,loops:0},X;if(E.isGroup){$.kind=4,$.label=cs(E.label,b,c,T,4e3,A);let V=$.label.height;X=$t(0,0),X.isGroup=!0,X.padX=Tl,X.padBottom=Tl,X.padTop=E.boundaryType==="package"?V+2*op+16:V>0?V+16:Tl,X.minW=$.label.width+2*Tl}else{if(E.jsonRows){$.kind=3,$.label=cs(E.label,!1,c,T,4e3,A|1);let V=0;for(let O of E.jsonRows){let v=cs(O.key,!1,c,a,4e3,A),W=cs(O.value,!1,c,a,260,A);$.rows.push([v,W]),$.keyW=Math.max($.keyW,v.width),V=Math.max(V,W.width),$.h+=Math.max(W.height,Math.round(a*1.5))+ap}$.keyW>0&&($.keyW+=2*Uo),$.headH=Math.max($.label.height,Math.round(T*1.5))+ap,$.w=Math.max($.label.width+2*Uo,$.rows.length>0?$.keyW+V+2*Uo:0,72),$.h+=$.headH}else if(E.actorType)$.kind=0,$.label=cs(E.label,b,c,T,140,A),$.w=Math.max(lp,$.label.width,N.width),$.h=Go+KA+N.height+$.label.height;else{$.label=cs(E.label,b,c,E.shape==="note"?a:T,180,A);let V=Math.max($.label.width,N.width),O=$.label.height+N.height;E.shape==="usecaseEllipse"||E.shape==="usecaseBusiness"?($.kind=1,$.w=Math.max(V+2*E.padding+(E.business?16:4),88),$.h=Math.max(O+28,48)):E.shape==="note"?($.w=V+2*E.padding+6,$.h=O+18):($.w=Math.max(V+2*E.padding+12,80),$.h=Math.max(O+24,44))}X=$t($.w,$.h)}X.seq=h.length,h.push($),g.push(X)}o.nodes.forEach((E,C)=>{g[C].parent=E.parentId!==void 0?m.get(E.parentId)??-1:-1});let x=[],y=[],_=[];for(let E of o.edges){let C=m.get(E.start),A=m.get(E.end);if(C===void 0||A===void 0)continue;let T=E.relationshipType==="include"||E.relationshipType==="extend",b=cs(T?`«${E.label}»`:E.label,E.labelType==="markdown",c,a,200);C===A&&(h[C].loops++,u?g[C].h+=2*(ip+(b.height>0?b.height+8:0)):g[C].w+=2*(ip+(b.width>0?b.width+12:0))),_.push(E),y.push(b),x.push({src:C,dst:A,minlen:E.minlen,labelW:b.width>0?b.width+12:0,labelH:b.height>0?b.height+4:0,route:[],labelX:0,labelY:0})}let S=Sn(g,x,p,{nodeSep:zA(t,"nodeSpacing",IN),edgeSep:NN,rankSep:zA(t,"rankSpacing",MN),portSep:20}),P=De(e.title,!1,c,s,4e3,1),k=P.height>0?P.height+12:0,w=Math.max(S.width,P.width),I=l+(w-S.width)/2,D=l+k;vr(g,x,I,D);let U=Math.ceil(w+2*l),M=Math.ceil(S.height+k+2*l),Q=new Map;for(let E of x)Vn(Q,E.route);$N(x,g,h);let q="",Y="";for(let E=0;E<h.length;E++){let C=h[E],A=g[E],T=C.node,b=wt(T.cssClasses.replace(/^default\s?/,"")),N=$e(T.id),$=C.style.text,X=C.style.shape,V=C.w,O=C.h;if(C.kind===4){let H=A.x-A.w/2,G=A.y-A.h/2,te=` fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${X}`,Z=` class="pele-cluster-label" fill="var(--_m)"${$}`,B;if(T.boundaryType==="package"){let K=Math.min(C.label.width+2*op+8,A.w),ee=C.label.height+2*op;B=`<rect class="pele-boundary-tab" x="${d(H)}" y="${d(G)}" width="${d(K)}" height="${d(ee)}"${te}/><rect x="${d(H)}" y="${d(G+ee)}" width="${d(A.w)}" height="${d(A.h-ee)}"${te}/>`+Ie(C.label,H+K/2,G+ee/2,Z,f)}else B=`<rect x="${d(H)}" y="${d(G)}" width="${d(A.w)}" height="${d(A.h)}" rx="${Xe}"${te}/>`+Ie(C.label,vN(A,C.label.width,Q),G+8+C.label.height/2,Z,f);q+=`<g class="pele-cluster pele-boundary${b}" data-id="${N}">${B}</g>`;continue}let v,W;if(C.kind===0){W="pele-actor";let H=-O/2,G=H+Go+KA+C.stereotype.height/2;v=`<g class="pele-actor-figure" transform="translate(0,${d(H+Go/2)})">${ON(C,f)}</g>`+Ie(C.stereotype,0,G,` class="pele-stereotype" font-size="${i}" fill="var(--_m)"`,f)+Ie(C.label,0,O/2-C.label.height/2,` class="pele-label"${$}`,f)}else if(C.kind===3){W="pele-json";let H=-V/2,G=-O/2+C.headH,te="",Z=`M${d(H)},${d(G)}H${d(H+V)}`;C.keyW>0&&(Z+=`M${d(H+C.keyW)},${d(G)}V${d(O/2)}`);for(let[B,K]of C.rows){let ee=Math.max(K.height,Math.round(a*1.5))+ap;te+=Ie(B,H+Uo+B.width/2,G+ee/2,' class="pele-json-key" fill="var(--_m)"',f)+PN(K,H+C.keyW+Uo,G+ee/2,` class="pele-json-value"${$}`,f),G+=ee}v=`<rect x="${d(H)}" y="${d(-O/2)}" width="${d(V)}" height="${d(O)}" rx="${Xe}"${Yo}${X}/><path class="pele-json-lines" d="${Z}" fill="none" stroke="var(--_b)"${C.style.line}/>`+Ie(C.label,0,-O/2+C.headH/2,` class="pele-label" font-weight="var(--_hw)"${$}`,f)+`<g font-size="${a}">${te}</g>`}else{let H=C.stereotype.height/2,G;if(C.kind===1){if(W="pele-usecase",G=`<ellipse rx="${d(V/2)}" ry="${d(O/2)}"${Yo}${X}/>`,T.business){let te=V/2-15,Z=V/2-5,B=K=>O/2*Math.sqrt(1-(K/(V/2))**2);G+=`<path class="pele-business" d="M${d(te)},${d(B(te))}L${d(Z)},${d(-B(Z))}" fill="none" stroke="var(--_b)"${C.style.line}/>`}}else if(T.shape==="note"){W="pele-note";let te=V/2,Z=O/2;G=`<path d="M${d(-te)},${d(-Z)}H${d(te-Cl)}L${d(te)},${d(Cl-Z)}V${d(Z)}H${d(-te)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"${X}/><path d="M${d(te-Cl)},${d(-Z)}V${d(Cl-Z)}H${d(te)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"${C.style.line}/>`}else W="pele-usecase",G=`<rect x="${d(-V/2)}" y="${d(-O/2)}" width="${d(V)}" height="${d(O)}" rx="${Xe}"${Yo}${X}/>`;v=G+Ie(C.stereotype,0,-C.label.height/2,` class="pele-stereotype" font-size="${i}" fill="var(--_m)"`,f)+Ie(C.label,0,H,` class="pele-label"${T.shape==="note"?` font-size="${a}"`:""}${$}`,f)}Y+=`<g class="pele-node ${W}${b}" data-id="${N}" transform="translate(${d(A.x)},${d(A.y)})">${v}</g>`}let z="",R="",L=new Map;for(let E=0;E<x.length;E++){let C=x[E],A=_[E],T=y[E],b=A.style.length>0||A.cssCompiledStyles.length>0?At(A.cssCompiledStyles.concat(A.style)):void 0,N=A.arrowTypeStart,$=A.arrowTypeEnd,X;if(C.src===C.dst){let v=g[C.src],W=h[C.src],H=L.get(C.src)??0;L.set(C.src,H+1);let G=u?2:1,te=Math.min(XA(W,G)/2,8+H*6),Z=ip+H*8,[B,K]=cp(W,v,G,-te),[ee,ae]=cp(W,v,G,te),J=Math.hypot(Z,te)||1,se=u?te/J:Z/J,me=u?Z/J:te/J,Ae=Il(N),de=Il($),oe=(be,re,j,ie)=>u?`${d(be+j*te*(ie?1:0))},${d(re+ie)}`:`${d(be+ie)},${d(re+j*te*(ie?1:0))}`,ye=u?B-se*Ae:B+se*Ae,ce=u?K+me*Ae:K-me*Ae,fe=ee+se*de,xe=ae+me*de;X={d:`M${d(ye)},${d(ce)}C${oe(B,K,-1,Z)} ${oe(ee,ae,1,Z)} ${d(fe)},${d(xe)}`,sx:B,sy:K,sdx:u?se:-se,sdy:u?-me:me,ex:ee,ey:ae,edx:-se,edy:-me},u?(C.labelX=v.x,C.labelY=Math.max(K,ae)+Z*.75+6+T.height/2):(C.labelX=Math.max(B,ee)+Z*.75+8+T.width/2,C.labelY=v.y)}else{if(C.route.length<6)continue;X=yn(C.route,void 0,Il(N),Il($))}let V=b?.stroke?je(b.stroke):"var(--_l)",O=A.internal?"2 3":A.pattern==="dotted"?"5 4":A.animate?"9 5":"";if(z+=`<g class="pele-edge pele-${A.relationshipType}${wt(A.classes.replace(/^default relationship relationship-\S+\s?/,""))}" data-id="${$e(A.id)}"${b?.line??""}><path d="${X.d}"${O?` stroke-dasharray="${O}"`:""}/>`+VA(N,X.sx,X.sy,X.sdx,X.sdy,V)+VA($,X.ex,X.ey,X.edx,X.edy,V)+"</g>",T.width>0){let v=C.labelX,W=C.labelY,H=A.relationshipType==="include"||A.relationshipType==="extend";R+=nn(A.id,T,v,W,(H?' fill="var(--_m)"':"")+(b?.text??""),f)}}return{svg:Ze("usecase",U,M,s,n,e,Ie(P,U/2,l+P.height/2,' class="pele-title" font-weight="var(--_tw)"')+(q?`<g class="pele-clusters">${q}</g>`:"")+(z?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${z}</g>`:"")+(R?`<g class="pele-edge-labels" font-size="${a}">${R}</g>`:"")+`<g class="pele-nodes">${Y}</g>`),width:U,height:M,links:[]}}function vN(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(t===0||r===void 0)return e.x;let o=e.x-e.w/2+6,s=e.x+e.w/2-6,a=r.filter(u=>u>o&&u<s).sort((u,m)=>u-m);a.push(s);let i=t/2+6,c=e.x,l=1/0,f=0,p=o;for(let u of a){if(u-p>=2*i){let m=Math.min(Math.max(e.x,p+i),u-i);Math.abs(m-e.x)<l&&(l=Math.abs(m-e.x),c=m)}else l===1/0&&u-p>f&&(f=u-p,c=(p+u)/2);p=u}return c}function PN(e,t,n,r,o){if(e.lines.length<2)return Ie(e,t+e.width/2,n,r,o);let s="";for(let a=0;a<e.lines.length;a++){let i={...e,lines:[e.lines[a]],widths:[e.widths[a]],height:e.lineHeight};s+=Ie(i,t+e.widths[a]/2,n-e.height/2+(a+.5)*e.lineHeight,r,o)}return s}var QA={type:"usecase",parse:(e,t,n)=>GA(e,n),render:qA};function ls(e){let t=e.trim();return t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function dp(e){return e.map(ls).sort()}var Ml=class{type="venn";title;subsets=[];textNodes=[];styles=[];known=new Set;current;indent=!1;setDiagramTitle(t){this.title=t}addSubsetData(t,n,r){let o=dp(t);this.current=o,o.length===1&&this.known.add(o[0]),this.subsets.push({sets:o,size:r??10/t.length**2,label:n?ls(n):void 0})}addTextData(t,n,r){this.textNodes.push({sets:dp(t),id:ls(n),label:r?ls(r):void 0})}addStyleData(t,n){let r=new Map;for(let[o,s]of n)r.set(o,s&&ls(s));this.styles.push({targets:dp(t),styles:r})}validateUnionIdentifiers(t){let n=t.map(ls).filter(r=>!this.known.has(r));if(n.length>0)throw new Ge(`unknown set identifier: ${n.join(", ")}`,"semantic",{type:"venn"})}getCurrentSets(){return this.current}getIndentMode(){return this.indent}setIndentMode(t){this.indent=t}};var up=["$end","INVALID","EOF","NEWLINE","VENN","TITLE","SET","UNION","TEXT","INDENT_TEXT","STYLE","BRACKET_LABEL","NUMERIC","HEXCOLOR","RGBCOLOR","RGBACOLOR","IDENTIFIER","STRING","COMMA","COLON"],BN=[["venn-beta",4],["set",6],["union",7],["text",8],["style",10]],kl=class{constructor(t,n){this.src=t;this.host=n}src;host;text="";start=0;at=0;lineStart=!1;ended=!1;word(t,n){let r=this.src;for(let o=0;o<n.length;o++){let s=r.charCodeAt(t+o),a=n.charCodeAt(o);if(s!==a&&(s+32!==a||s<65||s>90))return!1}return!0}keyword(t,n){return this.word(t,n)&&!Qe(this.src.charCodeAt(t+n.length))}color(t,n){let r=this.src,o=t+1;for(let s=0;s<n;s++){for(;Be(r.charCodeAt(o));)o++;let a=o;for(;ft(r.charCodeAt(o))||r.charCodeAt(o)===46;)o++;if(o===a)return-1;for(;Be(r.charCodeAt(o));)o++;if(r.charCodeAt(o)!==(s===n-1?41:44))return-1;o++}return o}lineEnd(t){let n=this.src.indexOf(`
142
+ `,t);return n===-1?this.src.length:n}next(){let t=this.src,n=t.length;for(;;){let r=this.at;if(this.start=r,this.text="",r>=n)return this.ended?0:(this.ended=!0,2);let o=t.charCodeAt(r);if(o===37&&t.charCodeAt(r+1)===37&&t.charCodeAt(r+2)!==123||o!==125&&t.charCodeAt(r+1)===37&&t.charCodeAt(r+2)===37){this.at=this.lineEnd(r+2);continue}if(this.lineStart){if(o===32||o===9){let s=r+1;for(;t.charCodeAt(s)===32||t.charCodeAt(s)===9;)s++;if(this.at=s,this.keyword(s,"text")&&this.host.getIndentMode())return this.at=s+4,this.lineStart=!1,this.text=t.slice(r,s),9;continue}o!==10&&o!==13&&(this.host.setIndentMode(!1),this.lineStart=!1)}if(o===10||o===13){for(r++;t.charCodeAt(r)===10||t.charCodeAt(r)===13;)r++;return this.lineStart=!0,this.token(3,r)}if(o===37&&t.charCodeAt(r+1)===37){this.at=this.lineEnd(r);continue}if(o===32||o===9){for(r++;t.charCodeAt(r)===32||t.charCodeAt(r)===9;)r++;this.at=r;continue}if((o|32)>=97&&(o|32)<=122||o===95){if(this.word(r,"title")&&Be(t.charCodeAt(r+5))){let s=r+6;for(;s<n;){let a=t.charCodeAt(s);if(a===35||a===10||a===59)break;s++}if(s>r+6)return this.token(5,s)}for(let[s,a]of BN)if(this.keyword(r,s))return this.token(a,r+s.length);if(this.word(r,"rgb")){let s=(t.charCodeAt(r+3)|32)===97,a=r+(s?4:3),i=t.charCodeAt(a)===40?this.color(a,s?4:3):-1;if(i!==-1)return this.token(s?15:14,i)}for(r++;Qe(t.charCodeAt(r))||t.charCodeAt(r)===45;)r++;return this.token(16,r)}if(o===91){if(t.charCodeAt(r+1)===34){let a=t.indexOf('"',r+2);return a===-1||t.charCodeAt(a+1)!==93?1:(this.at=a+2,this.text=t.slice(r+2,a),11)}let s=r+1;for(;s<n&&t.charCodeAt(s)!==93&&t.charCodeAt(s)!==34;)s++;return s===r+1||t.charCodeAt(s)!==93?1:(this.at=s+1,this.text=t.slice(r+1,s).trim(),11)}if(ft(o)||o===46||o===43||o===45){(o===43||o===45)&&r++;let s=r;for(;ft(t.charCodeAt(r));)r++;if(r>s){if(t.charCodeAt(r)===46&&ft(t.charCodeAt(r+1)))for(r+=2;ft(t.charCodeAt(r));)r++}else if(t.charCodeAt(r)===46&&ft(t.charCodeAt(r+1)))for(r+=2;ft(t.charCodeAt(r));)r++;else return 1;return this.token(12,r)}if(o===35){let s=r+1;for(;s<r+9&&qo(t.charCodeAt(s));)s++;return s>=r+4?this.token(13,s):1}if(o===34){let s=t.indexOf('"',r+1);return s===-1?1:this.token(17,s+1)}return o===44?this.token(18,r+1):o===58?this.token(19,r+1):1}}token(t,n){return this.text=this.src.slice(this.at,n),this.at=n,t}};var FN="'EOF', 'NEWLINE', 'TITLE', 'SET', 'UNION', 'TEXT', 'INDENT_TEXT', 'STYLE'",WN="'NUMERIC', 'IDENTIFIER', 'STRING', 'HEXCOLOR', 'RGBCOLOR', 'RGBACOLOR'";function ZA(e,t){let n=new kl(e,t),r=-1,o=()=>r===-1?r=n.next():r,s=m=>{throw o()===1?it("venn",e,n.start,"",!0):it("venn",e,n.start,`Expecting ${m}, got '${up[r]}'`)},a=()=>(r=-1,n.text),i=m=>(o()!==m&&s(`'${up[m]}'`),a()),c=()=>(o()!==16&&r!==17&&s("'IDENTIFIER', 'STRING'"),a()),l=()=>{let m=[c()];for(;o()===18;)a(),m.push(c());return m},f=(m,h)=>{let g=o()===11?a():void 0,x;if(o()===19&&(a(),x=parseFloat(i(12))),h){if(m.length<2)throw new Ge("union requires multiple identifiers","semantic",{type:"venn"});t.validateUnionIdentifiers(m)}t.addSubsetData(m,g,x),t.setIndentMode(!0)},p=m=>{let h=o();h!==16&&h!==17&&h!==12&&s("'NUMERIC', 'IDENTIFIER', 'STRING'");let g=a(),x=h!==12&&o()===11?a():void 0;t.addTextData(m(),g,x)},u=()=>{let m=l(),h=[];for(;;){let g=i(16);i(19);let x;if(o()===17)x=a();else{let y=[];for(;o()===16||r>=12&&r<=15;)y.push(a());y.length===0&&s(WN),x=y.join(" ")}if(h.push([g,x]),o()!==18)break;a()}t.addStyleData(m,h)};for(;o()===3;)a();for(i(4);;){let m=o();if(m===2)return;if((m<3||m>10||m===4)&&s(FN),a(),m===5)t.setDiagramTitle(n.text.slice(6));else if(m===6)f([c()],!1);else if(m===7)f(l(),!0);else if(m===8){let h=l();p(()=>h)}else m===9?p(()=>{let h=t.getCurrentSets();if(!h)throw new Ge("text requires set","semantic",{type:"venn"});return h}):m===10&&u()}}var Ll=Math.PI*2;function UN(e){let t=new Set,n=new Map;for(let o of e)t.add(JSON.stringify([...o.sets].sort())),o.sets.length===1&&n.set(o.sets[0],o.size);let r=[];for(let o of e){if(o.sets.length<3)continue;let s=[...o.sets].sort();for(let a=0;a<s.length-1;a++)for(let i=a+1;i<s.length;i++){let c=[s[a],s[i]],l=JSON.stringify(c);if(t.has(l))continue;t.add(l);let f=n.get(c[0]),p=n.get(c[1]);r.push({sets:c,size:f!==void 0&&p!==void 0?Math.min(f,p)/4:2.5,label:""})}}return r.length>0?[...e,...r]:e}function GN(e,t,n){if(n>=e+t)return 0;let r=Math.min(e,t);if(n<=Math.abs(e-t))return Math.PI*r*r;let o=e*e*Math.acos((n*n+e*e-t*t)/(2*n*e)),s=t*t*Math.acos((n*n+t*t-e*e)/(2*n*t)),a=.5*Math.sqrt(Math.max((-n+e+t)*(n+e-t)*(n-e+t)*(n+e+t),0));return o+s-a}function YN(e,t,n){let r=Math.abs(e-t),o=e+t;if(!(n>0))return o;if(n>=Math.PI*Math.min(e,t)**2)return r;for(let s=0;s<48;s++){let a=(r+o)/2;GN(e,t,a)>n?r=a:o=a}return(r+o)/2}function JA(e,t,n,r,o,s){let a=1/0;for(let i of t){let c=e[i],l=r-c.x,f=o-c.y,p=c.r-Math.sqrt(l*l+f*f);if(p<a){if(p<s)return p;a=p}}for(let i of n){let c=e[i],l=r-c.x,f=o-c.y,p=Math.sqrt(l*l+f*f)-c.r;if(p<a){if(p<s)return p;a=p}}return a}function $l(e,t,n){let r=0,o=0,s=e[t[0]];for(let h of t){let g=e[h];r+=g.x/t.length,o+=g.y/t.length,g.r<s.r&&(s=g)}let a=s.r,i=r,c=o,l=JA(e,t,n,i,c,-1/0),f=0,p=(h,g)=>{let x=JA(e,t,n,h,g,l-a*1e-9);if(!(x>l-a*1e-9))return!1;let y=Math.hypot(h-r,g-o);return x>l+a*1e-9||y<f-a*1e-9?(l=x,f=y,i=h,c=g,!0):!1},u=10;for(let h=-u;h<=u;h++)for(let g=-u;g<=u;g++)g*g+h*h<=u*u&&p(s.x+g*a/u,s.y+h*a/u);let m=a/u;for(let h=0;h<40&&m>a*1e-6;h++){let g=!1;for(let x=0;x<8;x++){let y=x*Ll/8;p(i+Math.cos(y)*m,c+Math.sin(y)*m)&&(g=!0)}g||(m/=2)}return{x:i,y:c,margin:l}}function ex(e){let t=new Map;for(let x of e)for(let y of x.sets)t.has(y)||t.set(y,10);for(let x of e)x.sets.length===1&&t.set(x.sets[0],x.size);let n=new Map,r=[],o=0;for(let x of t.values())Number.isFinite(x)&&x>o&&(o=x);o===0&&(o=10);let s=Math.sqrt(o/Math.PI);for(let[x,y]of t){n.set(x,r.length);let _=Number.isFinite(y)&&y>0?Math.sqrt(y/Math.PI):0;r.push({id:x,x:0,y:0,r:Math.max(_,s*.3)})}let a=r.length;if(a<2)return r;let i=new Map;for(let x of UN(e)){if(x.sets.length!==2)continue;let y=n.get(x.sets[0]),_=n.get(x.sets[1]);y!==_&&i.set(Math.min(y,_)*a+Math.max(y,_),x.size)}let c=new Map;for(let[x,y]of i)c.set(x,YN(r[Math.floor(x/a)].r,r[x%a].r,y));let l=s*.15,f=(x,y)=>c.get(x*a+y)??r[x].r+r[y].r+l;if(a===2)return r[1].x=f(0,1),r;if(a===3){let x=f(0,1),y=f(0,2),_=f(1,2),S=e.some(P=>new Set(P.sets).size===3);for(let P=0;P<40;P++){let k=x>0?(x*x+y*y-_*_)/(2*x):0;if(r[1].x=x,r[2].x=Math.max(-y,Math.min(y,k)),r[2].y=Math.sqrt(Math.max(y*y-k*k,0)),!S||$l(r,[0,1,2],[]).margin>s*.12)break;x*=.94,y*=.94,_*=.94}return r}let p=0;for(let x of r)p+=2*x.r+l;let u=Math.min(300,Math.floor(3e6/(a*a)));if(a<=64){let x=p/Ll;r.forEach((y,_)=>{let S=_*Ll/a-Math.PI/2;y.x=Math.cos(S)*x,y.y=Math.sin(S)*x})}else{let x=Math.ceil(Math.sqrt(a)),y=2*s+l;r.forEach((_,S)=>{_.x=S%x*y,_.y=Math.floor(S/x)*y})}let m=new Float64Array(a),h=new Float64Array(a),g=new Int32Array(a);for(let x=0;x<u;x++){m.fill(0),h.fill(0),g.fill(0);for(let y=0;y<a;y++)for(let _=y+1;_<a;_++){let S=c.get(y*a+_),P=r[y].r+r[_].r+l,k=r[_].x-r[y].x,w=r[_].y-r[y].y,I=Math.hypot(k,w);if(S===void 0&&I>=P)continue;I<1e-9&&(k=Math.cos(y+_),w=Math.sin(y+_),I=1);let D=(I-(S??P))/2/I;m[y]+=k*D,h[y]+=w*D,m[_]-=k*D,h[_]-=w*D,g[y]++,g[_]++}for(let y=0;y<a;y++)g[y]!==0&&(r[y].x+=m[y]/g[y],r[y].y+=h[y]/g[y])}return r}function tx(e,t){let n=c=>`M${t(c.x-c.r)},${t(c.y)}A${t(c.r)},${t(c.r)} 0 1 1 ${t(c.x+c.r)},${t(c.y)}A${t(c.r)},${t(c.r)} 0 1 1 ${t(c.x-c.r)},${t(c.y)}Z`;if(e.length===1)return n(e[0]);let r=(c,l,f,p)=>{for(let u of e)if(u!==f&&u!==p&&Math.hypot(c-u.x,l-u.y)>u.r*(1+1e-9))return!1;return!0},o=[];for(let c=0;c<e.length;c++)for(let l=c+1;l<e.length;l++){let f=e[c],p=e[l],u=Math.hypot(p.x-f.x,p.y-f.y);if(u>=f.r+p.r||u<=Math.abs(f.r-p.r)||u===0)continue;let m=(f.r*f.r-p.r*p.r+u*u)/(2*u),h=Math.sqrt(Math.max(f.r*f.r-m*m,0)),g=f.x+(p.x-f.x)*m/u,x=f.y+(p.y-f.y)*m/u;for(let y of[1,-1]){let _=g+y*h*(p.y-f.y)/u,S=x-y*h*(p.x-f.x)/u;r(_,S,f,p)&&o.push({x:_,y:S,a:f,b:p})}}if(o.length<2){let c=e[0];for(let l of e)l.r<c.r&&(c=l);for(let l of e)if(l!==c&&Math.hypot(l.x-c.x,l.y-c.y)+c.r>l.r*(1+1e-9))return"";return n(c)}let s=0,a=0;for(let c of o)s+=c.x/o.length,a+=c.y/o.length;o.sort((c,l)=>Math.atan2(c.y-a,c.x-s)-Math.atan2(l.y-a,l.x-s));let i="";for(let c=0;c<o.length;c++){let l=o[c],f=o[(c+1)%o.length];c===0&&(i=`M${t(l.x)},${t(l.y)}`);let p,u=0,m=1/0;for(let h of[l.a,l.b]){if(h!==f.a&&h!==f.b)continue;let g=Math.atan2(l.y-h.y,l.x-h.x),x=Math.atan2(f.y-h.y,f.x-h.x)-g;x<=0&&(x+=Ll);let y=h.x+h.r*Math.cos(g+x/2),_=h.y+h.r*Math.sin(g+x/2),S=Math.hypot(y-(l.x+f.x)/2,_-(l.y+f.y)/2);S<m&&(m=S,p=h,u=x>Math.PI?1:0)}p===void 0?i+=`L${t(f.x)},${t(f.y)}`:i+=`A${t(p.r)},${t(p.r)} 0 ${u} 1 ${t(f.x)},${t(f.y)}`}return i+"Z"}var HN=100,KN=1.6,nx=At([]);function fp(e){return e.length===1?e[0]:JSON.stringify(e)}function rx(e,t,n){let r=n.fontSize??16,o=Math.round(r*.875),s=Math.round(r*.8125),a=n.measurer??Je(n.fontFamily),i=n.padding??8,c=ex(e.subsets),l=new Map;c.forEach((E,C)=>l.set(E.id,C));let f=new Map;for(let{targets:E,styles:C}of e.styles){let A=fp(E),T=f.get(A);T||f.set(A,T=new Map);for(let[b,N]of C)T.set(b,N)}let p=E=>{let C=f.get(E);if(!C)return nx;let A=[];for(let[T,b]of C)A.push(`${T}:${b}`);return At(A)},u=c.map(()=>[]);for(let E=0;E<c.length;E++)for(let C=E+1;C<c.length;C++)Math.hypot(c[E].x-c[C].x,c[E].y-c[C].y)<c[E].r+c[C].r&&(u[E].push(C),u[C].push(E));let m=new Map;for(let E of e.subsets)m.set(fp(E.sets),E);let h=new Map;for(let[E,C]of m){let A=[...new Set(C.sets)],T=A.map(W=>l.get(W)),b=new Set(T),N=T[0];for(let W of T)c[W].r<c[N].r&&(N=W);let $=p(E),X=C.label??(C.sets.length===1?C.sets[0]:void 0),V=($.bold?1:0)|($.italic?2:0),O=$l(c,T,u[N].filter(W=>!b.has(W)));O.margin<c[N].r*.2&&(O=$l(c,T,[]));let v={sets:A,inside:T,spot:O,lines:[],style:$};if(X){let W=A.length===1?r:o;v.lines.push({id:void 0,raw:X,size:W,base:V,label:De(X,!1,a,W,4e3,V)})}h.set(E,v)}for(let E of e.textNodes){let C=E.label??E.id;h.get(fp(E.sets))?.lines.push({id:E.id,raw:C,size:s,base:0,label:De(C,!1,a,s,4e3)})}let g=0;for(let E of c)E.r>g&&(g=E.r);let x=g>0?HN/g:1,y=1;for(let E of h.values()){if(E.spot.margin<=0)continue;let C=0,A=0;for(let b of E.lines)C=Math.max(C,b.label.width),A+=b.label.height;let T=Math.hypot(C,A)/2+4;y=Math.max(y,Math.min(T/(E.spot.margin*x),KN))}x*=y;for(let E of h.values()){let C=Math.max(E.spot.margin*x*1.8,72);for(let A of E.lines)A.label.width>C&&(A.label=De(A.raw,!1,a,A.size,C,A.base))}let _=1/0,S=1/0,P=-1/0,k=-1/0;for(let E of c)_=Math.min(_,(E.x-E.r)*x),S=Math.min(S,(E.y-E.r)*x),P=Math.max(P,(E.x+E.r)*x),k=Math.max(k,(E.y+E.r)*x);for(let E of h.values()){let C=0,A=0;for(let T of E.lines)C=Math.max(C,T.label.width),A+=T.label.height;_=Math.min(_,E.spot.x*x-C/2),P=Math.max(P,E.spot.x*x+C/2),S=Math.min(S,E.spot.y*x-A/2),k=Math.max(k,E.spot.y*x+A/2)}c.length===0&&(_=S=P=k=0);let w=De(e.title&&ls(e.title),!1,a,r,4e3,1),I=w.height>0?w.height+12:0,D=Math.max(P-_,w.width),U=i+(D-(P-_))/2-_,M=i+I-S,Q=Math.ceil(D+2*i),q=Math.ceil(k-S+I+2*i),Y=c.map(E=>({id:E.id,x:E.x*x+U,y:E.y*x+M,r:E.r*x})),z="";Y.forEach((E,C)=>{let A=ct(C),T=h.get(E.id)?.style??nx;z+=`<circle class="pele-venn-set" data-id="${$e(E.id)}" cx="${d(E.x)}" cy="${d(E.y)}" r="${d(E.r)}" fill="${A}" fill-opacity="0.2" stroke="${A}"${T.shape}/>`});let R="",L="";for(let E of h.values()){let C=$e(E.sets.join("|"));if(E.sets.length>1&&E.style.shape!==""){let $=tx(E.inside.map(X=>Y[X]),d);$!==""&&(R+=`<path class="pele-venn-overlap" data-id="${C}" d="${$}" fill="none"${E.style.shape}/>`)}let A=0;for(let $ of E.lines)A+=$.label.height;if(A===0)continue;let T=E.spot.x*x+U,b=E.spot.y*x+M-A/2,N="";for(let $ of E.lines){let X=$.id===void 0?` class="pele-label"${$.size===r?"":` font-size="${$.size}"`}${E.style.text}`:` class="pele-venn-text" data-id="${$e($.id)}" font-size="${s}" fill="var(--_m)"${p($.id).text}`;N+=Ie($.label,T,b+$.label.height/2,X),b+=$.label.height}L+=`<g class="pele-venn-region" data-id="${C}">${N}</g>`}return{svg:Ze("venn",Q,q,r,n,{},Ie(w,Q/2,i+w.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-venn-sets">${z}</g>`+(R?`<g class="pele-venn-overlaps">${R}</g>`:"")+(L?`<g class="pele-venn-labels">${L}</g>`:"")),width:Q,height:q,links:[]}}var sx={type:"venn",parse(e,t,n){let r=new Ml;return n&&(r.title=n),ZA(e,r),r},render:rx};var Dl=class{nodes=new Map;labels;links=[];trends=new Map;pipelines=new Map;annotations=[];notes=[];accelerators=[];deaccelerators=[];annotationsBox;axes={};size;addNode(t){let n=this.nodes.get(t.id)??{id:t.id,label:t.label};this.nodes.set(t.id,{...n,...t,className:t.className??n.className,labelOffsetX:t.labelOffsetX??n.labelOffsetX,labelOffsetY:t.labelOffsetY??n.labelOffsetY}),this.labels=void 0}addLink(t){this.links.push(t)}addTrend(t){this.trends.set(t.nodeId,t)}startPipeline(t){this.pipelines.set(t,{nodeId:t,componentIds:[]});let n=this.nodes.get(t);n&&(n.isPipelineParent=!0)}addPipelineComponent(t,n){this.pipelines.get(t)?.componentIds.push(n);let r=this.nodes.get(n);r&&(r.inPipeline=!0)}addAnnotation(t){this.annotations.push(t)}addNote(t){this.notes.push(t)}addAccelerator(t){this.accelerators.push(t)}addDeaccelerator(t){this.deaccelerators.push(t)}setAnnotationsBox(t,n){this.annotationsBox={x:t,y:n}}setAxes(t){this.axes={...this.axes,...t}}setSize(t,n){this.size={width:t,height:n}}getNode(t){return this.nodes.get(t)}resolveNodeId(t){if(this.nodes.has(t))return t;if(!this.labels){this.labels=new Map;for(let[n,r]of this.nodes)this.labels.has(r.label)||this.labels.set(r.label,n)}return this.labels.get(t)??t}build(){let t=[];for(let n of this.nodes.values()){if(typeof n.x!="number"||typeof n.y!="number")throw new Ge(`Node "${n.label}" is missing coordinates`,"semantic",{type:"wardley"});t.push(n)}return{nodes:t,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}};function Ol(e,t){let n=e<=1?e*100:e;if(n<0||n>100)throw new Ge(`${t} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`,"semantic",{type:"wardley"});return n}function zs(e,t,n){return{x:Ol(t,`${n} evolution`),y:Ol(e,`${n} visibility`)}}function ix(e){return e==="+<>"?"bidirectional":e==="+<"?"backward":e==="+>"?"forward":void 0}function zN(e){if(!e?.startsWith("+"))return{};let t=e.indexOf("'",2),n=e[1]==="'"&&t!==-1?e.slice(2,t):void 0;return e.includes("<>")?{flow:"bidirectional",label:n}:e.includes("<")?{flow:"backward",label:n}:e.includes(">")?{flow:"forward",label:n}:{label:n}}function ox(e){return e?[(e.negX?-1:1)*e.offsetX,(e.negY?-1:1)*e.offsetY]:[void 0,void 0]}function VN(e,t){e.size&&t.setSize(e.size.width,e.size.height),e.evolution&&t.setAxes({stages:e.evolution.stages.map(n=>n.secondName?`${n.name.trim()} / ${n.secondName.trim()}`:n.name.trim()),stageBoundaries:e.evolution.stages.filter(n=>n.boundary!==void 0).map(n=>n.boundary)});for(let n of e.anchors){let r=zs(n.visibility,n.evolution,`Anchor "${n.name}"`);t.addNode({id:n.name,label:n.name,x:r.x,y:r.y,className:"anchor"})}for(let n of e.components){let r=zs(n.visibility,n.evolution,`Component "${n.name}"`),[o,s]=ox(n.label);t.addNode({id:n.name,label:n.name,x:r.x,y:r.y,className:"component",labelOffsetX:o,labelOffsetY:s,inertia:n.inertia,sourceStrategy:n.decorator?.strategy})}for(let n of e.notes){let r=zs(n.visibility,n.evolution,`Note "${n.text}"`);t.addNote({text:n.text,x:r.x,y:r.y})}for(let n of e.pipelines){let r=t.getNode(n.parent);if(!r||typeof r.y!="number")throw new Ge(`Pipeline "${n.parent}" must reference an existing component with coordinates.`,"semantic",{type:"wardley"});let o=r.y;t.startPipeline(n.parent);for(let s of n.components){let a=`${n.parent}_${s.name}`,[i,c]=ox(s.label),l=Ol(s.evolution,`Pipeline component "${s.name}" evolution`);t.addNode({id:a,label:s.name,x:l,y:o,className:"pipeline-component",labelOffsetX:i,labelOffsetY:c,inertia:void 0,sourceStrategy:void 0}),t.addPipelineComponent(n.parent,a)}}for(let n of e.links){let r=!!n.arrow&&(n.arrow.includes("-.->")||n.arrow.includes(".-.")),o=zN(n.arrow),s=ix(n.fromPort)??ix(n.toPort)??o.flow;t.addLink({source:t.resolveNodeId(n.from),target:t.resolveNodeId(n.to),dashed:r,label:o.label??n.linkLabel,flow:s})}for(let n of e.evolves){let r=t.getNode(n.component);r?.y!==void 0&&t.addTrend({nodeId:n.component,targetX:Ol(n.target,`Evolve target for "${n.component}"`),targetY:r.y})}if(e.annotations.length>0){let n=zs(e.annotations[0].x,e.annotations[0].y,"Annotations box");t.setAnnotationsBox(n.x,n.y)}for(let n of e.annotation){let r=zs(n.x,n.y,`Annotation ${n.number}`);t.addAnnotation({number:n.number,coordinates:[{x:r.x,y:r.y}],text:n.text})}for(let n of e.accelerators){let r=zs(n.x,n.y,`Accelerator "${n.name}"`);t.addAccelerator({name:n.name,x:r.x,y:r.y})}for(let n of e.deaccelerators){let r=zs(n.x,n.y,`Deaccelerator "${n.name}"`);t.addDeaccelerator({name:n.name,x:r.x,y:r.y})}}function ax(e,t){let n=new Dl;return VN(e,n),{type:"wardley",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
143
+ `):void 0,...n.build()}}function cx(e,t){let n=t;for(let r=e.charCodeAt(n);r>=48&&r<=57;r=e.charCodeAt(n))n++;return n}function jN(){let e=0,t=0;return(n,r)=>{if((r<e||r>=t)&&(e=r,t=cx(n,r)),t===r||n.charCodeAt(t)!==46)return-1;let o=cx(n,t+1);return o>t+1?o:-1}}var lx={name:"ARROW",pattern:/->/y,first:"-"},dx={name:"LINK_ARROW",pattern:/-->|-\.->|>|\+'[^']*'<>|\+'[^']*'<|\+'[^']*'>/y,first:"->+"},In=(e,t)=>({name:e,pattern:new RegExp(t,"y"),first:t[0]}),ux=[{name:"[",pattern:"["},{name:",",pattern:","},{name:"]",pattern:"]"},{name:"@",pattern:"@"},{name:"/",pattern:"/"},{name:"(",pattern:"("},{name:")",pattern:")"},{name:"-",pattern:"-",longer:[lx,dx,Pt]},{name:"{",pattern:"{"},{name:"}",pattern:"}"},{name:"WARDLEY_NUMBER",pattern:/[0-9]+\.[0-9]+/y,first:"0123456789",scanner:jN},lx,{name:"LINK_PORT",pattern:/\+<>|\+>|\+</y,first:"+"},dx,{name:"LINK_LABEL",pattern:/;[^\n\r]+/y,first:";"},{name:"STRATEGY",pattern:/build|buy|outsource|market/y,first:"bom"},In("KW_WARDLEY","wardley-beta"),In("KW_SIZE","size"),In("KW_EVOLUTION","evolution"),In("KW_ANCHOR","anchor"),In("KW_COMPONENT","component"),In("KW_LABEL","label"),In("KW_INERTIA","inertia"),In("KW_EVOLVE","evolve"),In("KW_PIPELINE","pipeline"),In("KW_NOTE","note"),In("KW_ANNOTATIONS","annotations"),In("KW_ANNOTATION","annotation"),In("KW_ACCELERATOR","accelerator"),In("KW_DEACCELERATOR","deaccelerator"),{name:"NAME_WITH_SPACES",pattern:/(?!title\s|accTitle|accDescr)[A-Za-z](?:[A-Za-z0-9_()&]|-(?!>))*(?:[ \t]+[A-Za-z(](?:[A-Za-z0-9_()&]|-(?!>))*)*/y,first:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},{name:"WS",pattern:/[ \t]+/y,hidden:!0,first:" "},pi(),Yt,Ht,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y,first:"0123456789"},wn,{name:"ID",pattern:/[\w]([-\w]*\w)?/y,first:"_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},hn,mn,Pt,Kt,zt];function fx(e){let t=new Dt(vt(e,ux,"wardley"),ux,"wardley"),n={$type:"Wardley",anchors:[],components:[],links:[],evolves:[],pipelines:[],notes:[],annotations:[],annotation:[],accelerators:[],deaccelerators:[]},r=m=>t.kinds[t.i]===m,o=()=>r(36)||r(37)||r(30),s=()=>r(36)?rn(t.take()):r(37)||r(30)?t.take():t.fail("a name"),a=()=>Number(t.expect(10)),i=()=>parseInt(t.expect(35)),c=()=>r(10)?Number(t.take()):parseInt(t.expect(35)),l=()=>{if(!r(-1))for(r(38)||t.fail("a line break or the end of input");r(38);)t.i++},f=m=>{t.expect(0);let h=m();t.expect(1);let g=m();return t.expect(2),[h,g]},p=()=>{t.expect(21),t.expect(0);let m=t.accept(7),h=i();t.expect(1);let g=t.accept(7),x=i();return t.expect(2),{$type:"Label",negX:m,offsetX:h,negY:g,offsetY:x}},u=()=>{let m={$type:"EvolutionStage",name:s()};return t.accept(3)&&(m.boundary=a()),t.accept(4)&&(m.secondName=s()),m};for(;r(38);)t.i++;for(t.expect(16);!r(-1);)switch(t.kind){case 38:t.i++;break;case 32:n.accDescr=Wt(t.take()),l();break;case 33:n.accTitle=Ft(t.take()),l();break;case 34:n.title=Bt(t.take()),l();break;case 17:{t.i++;let[m,h]=f(i);l(),n.size={$type:"Size",width:m,height:h};break}case 18:{t.i++;let m=[u()];for(t.expect(11),m.push(u());t.accept(11);)m.push(u());l(),n.evolution={$type:"Evolution",stages:m};break}case 19:{t.i++;let m=s(),[h,g]=f(a);l(),n.anchors.push({$type:"Anchor",name:m,visibility:h,evolution:g});break}case 20:{t.i++;let m={$type:"Component",name:s(),visibility:0,evolution:0,inertia:!1};[m.visibility,m.evolution]=f(a),r(21)&&(m.label=p()),r(5)&&t.kinds[t.i+1]===15&&(t.i++,m.decorator={$type:"Decorator",strategy:t.take()},t.expect(6)),t.accept(22)?m.inertia=!0:t.accept(5)&&(t.expect(22),t.expect(6),m.inertia=!0),l(),n.components.push(m);break}case 23:{t.i++;let m=s(),h=a();l(),n.evolves.push({$type:"Evolve",component:m,target:h});break}case 24:{t.i++;let m=s();for(t.expect(8),t.expect(38);r(38);)t.i++;let h=[];do{t.expect(20);let g={$type:"PipelineComponent",name:s(),evolution:0};t.expect(0),g.evolution=a(),t.expect(2),r(21)&&(g.label=p()),l(),h.push(g)}while(r(20));t.expect(9),l(),n.pipelines.push({$type:"Pipeline",parent:m,components:h});break}case 25:{t.i++;let m=rn(t.expect(36)),[h,g]=f(a);l(),n.notes.push({$type:"Note",text:m,visibility:h,evolution:g});break}case 26:{t.i++;let[m,h]=f(c);l(),n.annotations.push({$type:"Annotations",x:m,y:h});break}case 27:{t.i++;let m=i();t.expect(1);let[h,g]=f(c),x=rn(t.expect(36));l(),n.annotation.push({$type:"Annotation",number:m,x:h,y:g,text:x});break}case 28:case 29:{let m=t.kind===29;t.i++;let h=s(),[g,x]=f(a);l(),m?n.deaccelerators.push({$type:"Deaccelerator",name:h,x:g,y:x}):n.accelerators.push({$type:"Accelerator",name:h,x:g,y:x});break}default:{o()||t.fail("a statement");let m={$type:"Link",from:s(),to:""};r(12)&&(m.fromPort=t.take()),(r(13)||r(11))&&(m.arrow=t.take()),m.to=s(),r(12)&&(m.toPort=t.take()),r(14)&&(m.linkLabel=t.take().substring(1).trim()),l(),n.links.push(m)}}return n}var XN=["Genesis","Custom Built","Product","Commodity"],qN=48,Ot=6,Vs=10,QN=8,vl=15,Ho=60,ZN=30,px=20,pp="var(--_c)",Dn="var(--_l)";function JN(e,t,n,r,o){let s=e["wardley-beta"]?.[t];return typeof s=="number"&&s>=r&&s<=o?s:n}function ki(e,t,n){return e<t?t:e>n?n:e}function hx(e,t,n,r){let o=Er(e),s="",a=n;for(let i of e.lines){let c=!0;for(let l of i){if(l.icon!==void 0)continue;let f=rr(l.style&~o);s+=`<tspan${c?` x="${d(t)}" y="${d(a)}"`:""}${f}>${je(l.text)}</tspan>`,c=!1}a+=e.lineHeight}return s===""?"":`<text${Kn(r,o)} xml:space="preserve">${s}</text>`}function mx(e,t,n,r){let o=typeof t=="number"&&Number.isFinite(t)?t:JN(e,n,r,1,1e6);return ki(o,200,1e4)-2*qN}function gx(e,t,n){let r=mx(t,e.size?.width,"width",900);return Fr(n,r,160,(o,s)=>eM(e,t,n,o,r,s))}function eM(e,t,n,r,o,s){let a=n.fontSize??16,i=Math.round(a*.8125),c=Math.round(a*.6875),l=n.measurer??Je(n.fontFamily),f=n.padding??8,p=mx(t,e.size?.height,"height",600)*Math.max(.75,r/o),u=t["wardley-beta"]?.showGrid===!0,m=0,h=0,g=r,x=p,y=(ce,fe,xe,be)=>{ce<m&&(m=ce),fe<h&&(h=fe),xe>g&&(g=xe),be>x&&(x=be)},_=(ce,fe,xe,be)=>(y(fe-ce.width/2,xe-ce.height/2,fe+ce.width/2,xe+ce.height/2),Ie(ce,fe,xe,be,n.icons)),S=(ce,fe,xe,be)=>(y(fe,xe-ce.size,fe+ce.width,xe-ce.size+ce.height+4),hx(ce,fe,xe,be)),P=(ce,fe,xe=s?Math.max(64,Math.min(120,r/2)):4e3,be=0)=>De(ce,!1,l,fe,xe,be),k=ce=>ce/100*r,w=ce=>p-ce/100*p,I=e.axes.stages&&e.axes.stages.length>0?e.axes.stages:XN,D=e.axes.stageBoundaries,U=D!==void 0&&D.length===I.length,M="",Q="",q=p,Y=0;if(I.forEach((ce,fe)=>{let xe=U?Y:fe/I.length,be=U?ki(D[fe],0,1):(fe+1)/I.length;Y=be,fe>0&&(M+=`<path class="pele-wardley-stage" d="M${d(xe*r)},0V${d(p)}" stroke="var(--_b)" stroke-dasharray="4 4"/>`);let re=P(ce,i,Math.max(48,Math.abs(be-xe)*r-12));Q+=_(re,(xe+be)/2*r,p+8+re.height/2,` class="pele-wardley-stage-label" font-size="${i}" fill="var(--_m)"`),q=Math.max(q,p+8+re.height)}),u)for(let ce=1;ce<4;ce++)M+=`<path class="pele-wardley-grid" d="M${d(r*ce/4)},0V${d(p)}M0,${d(p*ce/4)}H${d(r)}" stroke="var(--_b)" stroke-dasharray="2 6"/>`;M+=`<path class="pele-wardley-axis" d="M0,0V${d(p)}H${d(r)}" stroke="${Dn}"/>`;let z=P(e.axes.xLabel??"Evolution",i),R=P(e.axes.yLabel??"Visibility",i),L=` class="pele-wardley-axis-label" font-size="${i}" font-weight="var(--_hw)"`,F=_(z,r/2,q+6+z.height/2,L)+Ie(R,-16,p/2,`${L} transform="rotate(-90 -16 ${d(p/2)})"`);y(-16-R.height/2,0,0,0);let E=q+6+z.height+10,C=new Map;for(let ce of e.nodes)C.set(ce.id,{x:k(ce.x),y:w(ce.y),node:ce});let A="",T=new Map;for(let ce of e.pipelines){T.set(ce.nodeId,new Set(ce.componentIds));let fe=[];for(let ue of ce.componentIds){let ge=C.get(ue);ge&&fe.push(ge)}if(fe.length===0)continue;fe.sort((ue,ge)=>ue.x-ge.x);let xe=fe[0].x,be=fe[fe.length-1].x,re=fe[0].y,j=re-2*Ot,ie=C.get(ce.nodeId);ie&&(ie.x=(xe+be)/2,ie.y=j-Vs/6),y(xe-vl,j,be+vl,j+4*Ot),A+=`<g class="pele-wardley-pipeline" data-id="${$e(ce.nodeId)}"><rect x="${d(xe-vl)}" y="${d(j)}" width="${d(be-xe+2*vl)}" height="${d(4*Ot)}" rx="${Xe}" fill="var(--_s)" stroke="var(--_b)"/>`+(fe.length>1?`<path d="M${d(xe)},${d(re)}H${d(be)}" stroke="${Dn}" stroke-dasharray="4 4"/>`:"")+"</g>"}let b=new Map,N=(ce,fe,xe)=>{let be=ce.node;if(be.className==="anchor"){let re=b.get(be);return re||b.set(be,re=P(be.label,i,s?Math.max(64,r/2):4e3,1)),1/Math.hypot(fe/(re.width/2+5),xe/(i*.8))}return be.isPipelineParent?Vs/Math.SQRT2:be.sourceStrategy?2*Ot:Ot},$=new Map,X=(ce,fe,xe)=>{Math.abs(fe)<.25||Math.abs(xe)<.25||$.set(ce,($.get(ce)??0)|(fe>0?xe<0?1:2:xe<0?4:8))},V="";for(let ce of e.links){let fe=C.get(ce.source),xe=C.get(ce.target);if(!fe||!xe||fe===xe||T.get(ce.target)?.has(ce.source))continue;let be=xe.x-fe.x,re=xe.y-fe.y,j=Math.hypot(be,re);if(j<.01)continue;let ie=be/j,ue=re/j,ge=N(fe,ie,ue),Se=N(xe,ie,ue);if(ge+Se>=j)continue;X(fe,ie,ue),X(xe,-ie,-ue);let we=fe.x+ie*ge,ke=fe.y+ue*ge,Le=xe.x-ie*Se,Fe=xe.y-ue*Se,He="";(ce.flow==="forward"||ce.flow==="bidirectional")&&(He+=bt("arrow_point",Le,Fe,ie,ue,Dn),Le-=ie*ht("arrow_point"),Fe-=ue*ht("arrow_point")),(ce.flow==="backward"||ce.flow==="bidirectional")&&(He+=bt("arrow_point",we,ke,-ie,-ue,Dn),we+=ie*ht("arrow_point"),ke+=ue*ht("arrow_point"));let _e="";if(ce.label){let Pe=P(ce.label,c+1,200),Ye=ie>=0?1:-1,Ue=ue*Ye,he=-ie*Ye,ne=5+Math.abs(Ue)*Pe.width/2+Math.abs(he)*Pe.height/2;_e=_(Pe,(fe.x+xe.x)/2+Ue*ne,(fe.y+xe.y)/2+he*ne,` class="pele-edge-label" font-size="${c+1}" fill="var(--_m)"`)}V+=`<g class="pele-edge${ce.dashed?" pele-wardley-dashed":""}" data-id="${$e(ce.source)}-${$e(ce.target)}"><path d="M${d(we)},${d(ke)}L${d(Le)},${d(Fe)}" stroke="${Dn}"${ce.dashed?' stroke-dasharray="6 6"':""}/>`+He+_e+"</g>"}let O="";for(let ce of e.trends){let fe=C.get(ce.nodeId);if(!fe)continue;let xe=k(ce.targetX),be=w(ce.targetY),re=xe-fe.x,j=be-fe.y,ie=Math.hypot(re,j),ue="",ge=ie>0?N(fe,re/ie,j/ie):0;if(ie>ge+Ot+4){let Se=re/ie,we=j/ie,ke=xe-Se*(Ot+2),Le=be-we*(Ot+2);ue=`<path d="M${d(fe.x+Se*ge)},${d(fe.y+we*ge)}L${d(ke-Se*ht("arrow_point"))},${d(Le-we*ht("arrow_point"))}" stroke="${pp}" stroke-dasharray="4 4"/>`+bt("arrow_point",ke,Le,Se,we,pp)}y(xe-Ot,be-Ot,xe+Ot,be+Ot),O+=`<g class="pele-wardley-trend" data-id="${$e(ce.nodeId)}">${ue}<circle cx="${d(xe)}" cy="${d(be)}" r="${Ot}" fill="var(--_bg)" stroke="${pp}"/></g>`}let v="",W=1.2*Ot,H=.7*Ot;for(let ce of C.values()){let fe=ce.node,{x:xe,y:be}=ce,re=fe.className==="anchor",j=fe.sourceStrategy,ie="";if(j){let we=j==="outsource"?"var(--_m)":j==="buy"?"var(--_a)":j==="build"?"var(--_s)":"var(--_bg)";ie+=`<circle class="pele-wardley-${j}" cx="${d(xe)}" cy="${d(be)}" r="${2*Ot}" fill="${we}" stroke="${Dn}"/>`}if(j==="market"){let we=W*Math.cos(Math.PI/6),ke=be+W*Math.sin(Math.PI/6);ie+=`<path d="M${d(xe)},${d(be-W)}L${d(xe-we)},${d(ke)}H${d(xe+we)}Z" fill="none" stroke="${Dn}"/>`;for(let[Le,Fe]of[[xe,be-W],[xe-we,ke],[xe+we,ke]])ie+=`<circle cx="${d(Le)}" cy="${d(Fe)}" r="${d(H)}" fill="var(--_bg)" stroke="${Dn}"/>`}else fe.isPipelineParent?ie+=`<rect x="${d(xe-Vs/2)}" y="${d(be-Vs/2)}" width="${Vs}" height="${Vs}" fill="var(--_bg)" stroke="${Dn}"/>`:re||(ie+=`<circle cx="${d(xe)}" cy="${d(be)}" r="${Ot}" fill="var(--_bg)" stroke="${Dn}"/>`);if(fe.inertia===!0){let we=(fe.isPipelineParent?Vs/2:Ot)+10+(j?Ot+4:0);ie+=`<rect class="pele-wardley-inertia" x="${d(xe+we)}" y="${d(be-Ot)}" width="4" height="${2*Ot}" fill="${Dn}"/>`}let ue=fe.labelOffsetX===void 0?void 0:ki(fe.labelOffsetX,-5e3,5e3),ge=fe.labelOffsetY===void 0?void 0:ki(fe.labelOffsetY,-5e3,5e3),Se;if(re){let we=b.get(fe)??P(fe.label,i,s?Math.max(64,r/2):4e3,1);Se=_(we,xe+(ue??0),be+(ge??-3),` class="pele-label" font-size="${i}" font-weight="var(--_hw)"`)}else{let we=P(fe.label,i),ke=` class="pele-label" font-size="${i}"`,Le=QN+(j?10:0);if(ue!==void 0||ge!==void 0)Se=S(we,xe+(ue??Le),be+(ge??-Le),ke);else if(fe.inPipeline)Se=_(we,xe,be+2*Ot+4+we.height/2,ke);else{let Fe=$.get(ce)??0,He=(Fe&1)===0?1:(Fe&2)===0?2:(Fe&4)===0?4:(Fe&8)===0?8:1,_e=He===1||He===2,Pe=He===1||He===4;Se=S(we,_e?xe+Le:xe-Le-we.width,Pe?be-Le:be+Le+i*.75,ke)}}y(xe-2*Ot,be-2*Ot,xe+2*Ot+20,be+2*Ot),v+=`<g class="pele-node pele-wardley-${re?"anchor":fe.isPipelineParent?"pipeline-parent":fe.inPipeline?"pipeline-component":"component"}" data-id="${$e(fe.id)}">${ie}${Se}</g>`}let G="";for(let ce of e.annotations){let fe=P(String(ce.number),c,4e3,1),xe="";for(let be of ce.coordinates){let re=k(be.x),j=w(be.y),ie=Math.max(10,fe.width/2+4);y(re-ie,j-ie,re+ie,j+ie),xe+=`<circle cx="${d(re)}" cy="${d(j)}" r="${d(ie)}" fill="var(--_bg)" stroke="${Dn}"/>`+Ie(fe,re,j,` font-size="${c}" font-weight="var(--_hw)"`)}G+=`<g class="pele-wardley-annotation" data-id="${$e(String(ce.number))}">${xe}</g>`}let te=e.annotations.filter(ce=>ce.text).sort((ce,fe)=>ce.number-fe.number);if(te.length>0){let ce=te.map(ge=>P(`${ge.number}. ${ge.text}`,i,s?Math.max(80,r-20):320)),fe=0,xe=0;for(let ge of ce)fe=Math.max(fe,ge.width),xe+=ge.height;fe+=20,xe+=14;let be=e.annotationsBox,re=be?ki(k(be.x),0,Math.max(0,r-fe)):0,j=be?ki(w(be.y),0,Math.max(0,p-xe)):E;y(re,j,re+fe,j+xe);let ie="",ue=j+7;for(let ge of ce)ie+=hx(ge,re+10,ue+ge.lineHeight/2+i*.35,` font-size="${i}"`),ue+=ge.height;G+=`<g class="pele-wardley-annotations"><rect x="${d(re)}" y="${d(j)}" width="${d(fe)}" height="${d(xe)}" rx="${Xe}" fill="var(--_bg)" stroke="var(--_b)"/>${ie}</g>`}let Z="";for(let ce of e.notes)Z+=S(P(ce.text,i,Math.min(360,r*.6),1),k(ce.x),w(ce.y),` class="pele-wardley-note" font-size="${i}" font-weight="var(--_hw)"`);let B="",K=(ce,fe,xe,be)=>{let re=k(fe),j=w(xe),ie=ZN/2,ue=be?re+Ho:re,ge=be?re:re+Ho,Se=be?re+Ho-px:re+px,we=`M${d(ge)},${d(j-ie)}H${d(Se)}V${d(j-ie-8)}L${d(ue)},${d(j)}L${d(Se)},${d(j+ie+8)}V${d(j+ie)}H${d(ge)}Z`;y(re,j-ie-8,re+Ho,j+ie+8),B+=`<g class="pele-wardley-${be?"accelerator":"deaccelerator"}" data-id="${$e(ce)}"><path d="${we}" fill="var(--_s)" stroke="${Dn}"/>`+_(P(ce,c+1,160,1),re+Ho/2,j+ie+8+12,` font-size="${c+1}" font-weight="var(--_hw)"`)+"</g>"};for(let ce of e.accelerators)K(ce.name,ce.x,ce.y,!0);for(let ce of e.deaccelerators)K(ce.name,ce.x,ce.y,!1);let ee=De(e.title,!1,l,a,s?Math.max(80,r):4e3,1),ae=ee.height>0?ee.height+12:0,J=Math.min(m,r/2-ee.width/2),se=Math.max(g,r/2+ee.width/2),me=f-J,Ae=f+ae-h,de=Math.ceil(se-J+2*f),oe=Math.ceil(x-h+ae+2*f),ye=Ie(ee,me+r/2,f+ee.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(me)},${d(Ae)})"><g class="pele-wardley-frame" fill="none">${M}</g>`+Q+F+A+(V?`<g class="pele-edges" fill="none">${V}</g>`:"")+(O?`<g class="pele-wardley-trends" fill="none">${O}</g>`:"")+v+G+Z+B+"</g>";return{svg:Ze("wardley",de,oe,a,n,e,ye),width:de,height:oe,links:[]}}var bx={type:"wardley",section:"wardley-beta",parse:(e,t,n)=>ax(fx(e),n),render:gx};var Pl=class{type="xychart";title;accTitle;accDescr;orientation;xAxis={type:"band",title:"",categories:[]};yAxis={type:"linear",title:"",min:1/0,max:-1/0};hasSetXAxis=!1;hasSetYAxis=!1;plots=[];setOrientation(t){this.orientation=t==="horizontal"?"horizontal":"vertical"}setXAxisTitle(t){this.xAxis.title=t.text.trim()}setXAxisRangeData(t,n){this.xAxis={type:"linear",title:this.xAxis.title,min:t,max:n},this.hasSetXAxis=!0}setXAxisBand(t){this.xAxis={type:"band",title:this.xAxis.title,categories:t.map(n=>n.text.trim())},this.hasSetXAxis=!0}setYAxisTitle(t){this.yAxis.title=t.text.trim()}setYAxisRangeData(t,n){this.yAxis={type:"linear",title:this.yAxis.title,min:t,max:n},this.hasSetYAxis=!0}plotData(t){if(t.length===0)return[];this.hasSetXAxis||this.setXAxisRangeData(1,t.length);let n=this.xAxis;if(n.type==="band"&&t.length>n.categories.length&&(t=t.slice(0,n.categories.length)),!this.hasSetYAxis){let{min:o,max:s}=this.yAxis;for(let a of t)a<o&&(o=a),a>s&&(s=a);this.yAxis={type:"linear",title:this.yAxis.title,min:o,max:s}}if(n.type==="band")return n.categories.map((o,s)=>[o,t[s]]);if(t.length===1)return[[`${n.min}`,t[0]]];let r=(n.max-n.min)/(t.length-1);return t.map((o,s)=>[`${n.min+s*r}`,o])}addPlot(t,n,r){let o={type:t,title:n.text.trim(),data:this.plotData(r.map(s=>s.value))};t==="line"&&r.some(s=>s.label.trim()!=="")&&(o.pointLabels=r.map(s=>s.label.trim())),this.plots.push(o)}setLineData(t,n){this.addPlot("line",t,n)}setBarData(t,n){this.addPlot("bar",t,n)}setDiagramTitle(t){this.title=t}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"")}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,`
144
+ `)}};var hp=["$end","INVALID","NEWLINE","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","XYCHART","CHART_ORIENTATION","X_AXIS","Y_AXIS","ARROW_DELIMITER","LINE","BAR","NUMBER_WITH_DECIMAL","SQUARE_BRACES_START","SQUARE_BRACES_END","STR","ALPHA","COLON","PLUS","COMMA","EQUALS","MULT","BRKT","UNDERSCORE","DOT","AMP","MINUS","NUM","SEMI","EOF"];var yx=[33,33,33,33,33,19,5,7,8],Ex="`)"+" ".repeat(36)+'{ this.pushstate(md_string); }\n<md_string>(?:(?!`").)+'+" ".repeat(18)+"{ return md_str; }\n<md_string>(?:`",mp=new Uint8Array(128);for(let[e,t]of[[":",21],["+",22],[",",23],["=",24],["*",25],["#",26],["_",27],[".",28],["&",29],["-",30],[";",32]])mp[e.charCodeAt(0)]=t;function Ax(e){let t=e.length,n=[],r=[],o=[],s=[],a=0,i=0,c=(g,x,y)=>{n.push(g),r.push(e.slice(x,y)),o.push(x),i=y},l=g=>{s.push(a),a=g},f=()=>{s.length>0&&(a=s.pop())},p=g=>{let x=e.indexOf(`
145
+ `,g);return x===-1?t:x},u=g=>{for(;g<t&&Be(e.charCodeAt(g));)g++;return g},m=g=>{for(;ft(e.charCodeAt(g));)g++;return g},h=g=>an(e,i,g)&&!Qe(e.charCodeAt(i+g.length));for(;i<t;){let g=e.charCodeAt(i);if(a===5){if(g===34)i++,f();else{let y=e.indexOf('"',i);c(19,i,y===-1?t:y)}continue}if(a===6||a===7){c(yx[a],i,p(i)),f();continue}if(a===8){if(g===125)i++,f();else{let y=e.indexOf("}",i);c(8,i,y===-1?t:y)}continue}let x=e.charCodeAt(i+1);if(g===37&&x===37){i=p(i+2);continue}if(g!==125&&x===37&&e.charCodeAt(i+2)===37){i=p(i+3);continue}if(g===10||g===13){if((a===1||a===3)&&(g===10||x===10)){c(2,i,g===10?i+1:i+2),f();continue}let y=i+1;for(let _=e.charCodeAt(y);_===10||_===13;_=e.charCodeAt(++y));c(2,i,y);continue}switch(g|32){case 116:if(h("title")){c(3,i,i+5);continue}break;case 97:if(an(e,i,"acc")){let y=an(e,i+3,"descr");if(y||an(e,i+3,"title")){let _=u(i+8),S=e.charCodeAt(_);if(S===58){c(y?6:4,i,u(_+1)),l(y?7:6);continue}if(S===123&&y){i=u(_+1),l(8);continue}}}break;case 120:if(h("xychart-beta")){c(9,i,i+12);continue}if(h("xychart")){c(9,i,i+7);continue}if(h("x-axis")){c(11,i,i+6),l(1);continue}break;case 121:if(h("y-axis")){c(12,i,i+6),l(1);continue}break;case 118:if(an(e,i,"vertical")){c(10,i,i+8);continue}break;case 104:if(an(e,i,"horizontal")){c(10,i,i+10);continue}break;case 108:if(h("line")){c(14,i,i+4),l(3);continue}break;case 98:if(h("bar")){c(15,i,i+3),l(3);continue}break}if(g===91){a===1?l(2):a===3&&l(4),c(17,i,i+1);continue}if(g===93){(a===4||a===2)&&f(),c(18,i,i+1);continue}if(a===1&&g===45&&x===45&&e.charCodeAt(i+2)===62){c(13,i,i+3);continue}if(a===1||a===4){let y=g===43||g===45?i+1:i,_=e.charCodeAt(y),S=-1;if(ft(_)?(S=m(y+1),e.charCodeAt(S)===46&&ft(e.charCodeAt(S+1))&&(S=m(S+2))):_===46&&ft(e.charCodeAt(y+1))&&(S=m(y+2)),S!==-1){c(16,i,S);continue}}if(g===96&&an(e,i,Ex)){i+=Ex.length,f();continue}if(g===34){i++,l(5);continue}if(yr(g)){let y=i+1;for(;yr(e.charCodeAt(y));)y++;c(20,i,y);continue}if(ft(g)){c(31,i,m(i+1));continue}if(Be(g)){i=u(i+1);continue}if(g<128&&mp[g]!==0){c(mp[g],i,i+1);continue}break}return i<t?(n.push(1),r.push(""),o.push(i),{types:n,texts:r,starts:o}):(n.push(yx[a]),r.push(""),o.push(t),n.push(0),r.push(""),o.push(t),{types:n,texts:r,starts:o})}function _x(...e){let t=new Uint8Array(34);for(let n of e)t[n]=1;return t}var xx=_x(29,31,20,22,24,25,28,26,30,27),Sx=_x(2,32,33);function wx(e,t){let{types:n,texts:r,starts:o}=Ax(e),s=0,a=u=>{let m=n[s];throw m===1?it("xychart",e,o[s],"",!0):it("xychart",e,o[s],`Expecting ${u}, got '${hp[m]}'`)},i=u=>(n[s]!==u&&a(`'${hp[u]}'`),r[s++]),c=u=>u===19||xx[u]===1,l=()=>{c(n[s])||a("'STR', 'ALPHA', 'NUM'");let u=r[s++];if(n[s-1]!==19)for(;xx[n[s]]===1;)u+=r[s++];return{text:u,type:"text"}},f=()=>{let u=Number(i(16));return i(13),[u,Number(i(16))]},p=()=>{let u=[];for(i(17);;){let m=Number(i(16));if(u.push({value:m,label:n[s]===19?r[s++]:""}),n[s]!==23)break;s++}return i(18),u};for(;;)if(Sx[n[s]]===1)s++;else{if(n[s]!==9)break;n[++s]===10&&t.setOrientation(r[s++])}for(;n[s]!==0;){let u=n[s++];switch(u){case 3:t.setDiagramTitle(l().text.trim());break;case 11:case 12:{let m=c(n[s])?l():void 0;if(u===11&&n[s]===17){let h=[];do s++,h.push(l());while(n[s]===23);i(18),t.setXAxisBand(h)}else if(n[s]===16||m===void 0){let[h,g]=f();u===11?t.setXAxisRangeData(h,g):t.setYAxisRangeData(h,g)}u===11?t.setXAxisTitle(m??{type:"text",text:""}):t.setYAxisTitle(m??{type:"text",text:""});break}case 14:case 15:{let m=n[s]===17?{text:"",type:"text"}:l(),h=p();u===14?t.setLineData(m,h):t.setBarData(m,h);break}case 4:t.setAccTitle(i(5).trim());break;case 6:t.setAccDescription(i(7).trim());break;case 8:t.setAccDescription(r[s-1].trim());break;default:s--,a("'title', 'X_AXIS', 'Y_AXIS', 'LINE', 'BAR', 'acc_title', 'acc_descr', 'acc_descr_multiline_value'")}for(;Sx[n[s]]===1;)s++}}function gp(e,t){let n=e/Math.max(t,1),r=Math.floor(Math.log10(n)),o=n/10**r,s=o>=7.07?10:o>=3.16?5:o>=1.41?2:1;return r<0?-(10**-r)/s:s*10**r}function Ko(e,t){return e>0?t/e:t*-e}function Li(e,t){return e>0?t*e:t/-e}function bp(e,t,n){let r=Math.round(Ko(n,e));Li(n,r)<e&&r++;let o=Math.round(Ko(n,t));Li(n,o)>t&&o--;let s=[];for(let a=r;a<=o&&s.length<100;a++)s.push(Li(n,a));return s}var Rx=4,$i=12,Tx=26,Cx=24,Ix=1e300;function yp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function Gn(e,t,n=!0){let r=e[t];return typeof r=="boolean"?r:n}function Nx(e,t){return typeof e=="number"&&e>0?Math.round(Math.min(Math.max(e,100),4e3)):t}function ds(e){return typeof e=="number"&&isFinite(e)?Math.min(Math.max(e,-Ix),Ix):void 0}function tM(e){let t=0;for(let n of e)t=Math.max(t,n.label.width);return t}function Bl(e,t,n,r){let o=e.lines.length===1?e.lines[0]:void 0;return o&&o.length===1&&o[0].icon===void 0&&o[0].style===0?`<text x="${d(t)}" y="${d(n+e.size*.35)}" text-anchor="${r}">${je(o[0].text)}</text>`:Ie(e,t+(r==="start"?e.width/2:r==="end"?-e.width/2:0),n,"")}function Mx(e,t,n){if(e.plots.length===0)throw new Ge("No Plot to render, please provide a plot with some data","semantic",{type:"xychart"});let r=yp(t.xyChart),o=n.fontSize??16,s=Math.round(o*.875),a=Math.round(o*.75),i=n.measurer??Je(n.fontFamily),c=n.padding??8,l=Nx(r.width,700),f=Wr(n,l,240),p=Math.round(Nx(r.height,500)*Math.max(.6,f/l)),u=(e.orientation??r.chartOrientation)==="horizontal",m=Gn(r,"showDataLabel",!1),h=e.xAxis,g=e.plots,x=(Te,Ke,ze)=>De(Te,!1,i,Ke,ze),y=x("0",s,4e3).height,_=x("0",a,4e3).height,S=De(Gn(r,"showTitle")?e.title:void 0,!1,i,o,f-2*c,1),P=S.height>0?S.height+12:0,k=[],w=0;Gn(r,"showLegend")&&g.forEach((Te,Ke)=>{if(Te.title==="")return;let ze=x(Te.title,s,f*.3);k.push({index:Ke,label:ze}),w=Math.max(w,ze.width+$i+8)});let I=k.length>0?w+Cx:0,D=g.filter(Te=>Te.type==="bar").length,U=e.yAxis.min,M=e.yAxis.max,Q=e.hasSetYAxis&&isFinite(U)&&isFinite(M)&&U!==M;if(Q)U=ds(U),M=ds(M);else{U=1/0,M=-1/0;for(let Te of g)for(let[,Ke]of Te.data){let ze=ds(Ke);ze!==void 0&&(ze<U&&(U=ze),ze>M&&(M=ze))}U>M&&(U=M=0),D>0&&(U=Math.min(U,0),M=Math.max(M,0)),U===M&&(U===0?M=1:(U-=Math.abs(U)/2,M+=Math.abs(M)/2))}let q=(Te,Ke)=>{let ze=gp(Math.abs(M-U),Math.max(2,Math.min(10,Math.floor(Te/Ke))));return Q||(U=Li(ze,Math.floor(Ko(ze,U)+1e-9)),M=Li(ze,Math.ceil(Ko(ze,M)-1e-9))),bp(Math.min(U,M),Math.max(U,M),ze).map(at=>({at:(at-U)/(M-U),label:x(String(at),s,4e3)}))},Y=1;if(h.type==="band")Y=Math.max(h.categories.length,1);else for(let Te of g)Y=Math.max(Y,Te.data.length);let z=1/Y,R=h.type==="band"||D>0?z/2:0,L=ds(h.type==="linear"?h.min:void 0),F=ds(h.type==="linear"?h.max:void 0),E=L!==void 0&&F!==void 0&&L!==F,C=(Te,Ke)=>h.type==="band"?(Te+.5)*z:R+(Ke>1?Te/(Ke-1):E?0:.5)*(1-2*R),A=yp(r.xAxis),T=yp(r.yAxis),b=u?A:T,N=u?T:A,$=x(Gn(b,"showTitle")?u?h.title:e.yAxis.title:void 0,s,p*.8),X=x(Gn(N,"showTitle")?u?e.yAxis.title:h.title:void 0,s,f*.8),V=Gn(b,"showTick")?Rx:0,O=Gn(N,"showTick")?Rx:0,v=Gn(b,"showLabel"),W=Gn(N,"showLabel"),H=u?f*.3:Math.max(48,(f-2*c-64-I)*z-8),G=h.type==="band"&&Gn(A,"showLabel")?h.categories.map(Te=>x(Te,s,H)):[],te=0,Z=0;for(let Te of G)te=Math.max(te,Te.width),Z=Math.max(Z,Te.height);let B=Te=>{let Ke=[];if(h.type==="band"){let ze=G.length===0?8:u?Z:te+12,at=Math.max(1,Math.ceil(ze/(Te*z)));for(let et=0;et<h.categories.length;et+=at)Ke.push({at:(et+.5)*z,label:G[et]??x(void 0,s,0)})}else if(E){let ze=gp(Math.abs(F-L),Math.max(2,Math.min(10,Math.floor(Te/(u?32:80)))));for(let at of bp(Math.min(L,F),Math.max(L,F),ze))Ke.push({at:R+(at-L)/(F-L)*(1-2*R),label:x(String(at),s,4e3)})}else L!==void 0&&Ke.push({at:.5,label:x(String(L),s,4e3)});return Ke},K=0,ee=0;for(let Te of g){for(let Ke of Te.pointLabels??[])K=Math.max(K,i.width(Ke,a,0));if(m&&u&&Te.type==="bar")for(let[,Ke]of Te.data)ee=Math.max(ee,i.width(String(ds(Ke)??""),a,0))}let ae=W?u||h.type!=="band"?y:Z:0,J=O+(ae>0?ae+4:0)+(X.height>0?X.height+4:0),se=u?0:K>0||m?_+4:v?y/2:0,me=c+P+se,Ae=Math.max(1,p-c-J-me),de=me+Ae,oe=u?B(Ae):q(Ae,56),ye=v?tM(oe):0,ce=c+($.height>0?$.height+6:0)+(ye>0?ye+6:0)+V,fe=Math.max(K>0?K+12:0,ee>0?ee+8:0),xe=u?Math.min(f*.25,fe):0,be=Math.max(1,f-c-ce-I-xe),re=u?q(be,80):B(be);if(W&&I+xe===0){let Te=0;for(let Ke of re)Te=Math.max(Te,Ke.at*be+Ke.label.width/2-be);be=Math.max(1,be-Te)}let j=ce+be,ie=(Te,Ke)=>u?ce+Ke*be:ce+Te*be,ue=(Te,Ke)=>u?me+Te*Ae:de-Ke*Ae,ge=Te=>(Te-U)/(M-U),Se=Te=>Math.min(Math.max(Te,0),1),we=Te=>u?`M${d(ie(0,Te))},${d(me)}V${d(de)}`:`M${d(ce)},${d(ue(0,Te))}H${d(j)}`,ke="";for(let Te of u?re:oe)ke+=we(Te.at);let Le="",Fe="";Gn(b,"showAxisLine")&&(Le+=`M${d(ce)},${d(me)}V${d(de)}`),Gn(N,"showAxisLine")&&(Le+=`M${d(ce)},${d(de)}H${d(j)}`);for(let Te of oe){let Ke=u?me+Te.at*Ae:de-Te.at*Ae;V&&(Le+=`M${d(ce)},${d(Ke)}h${-V}`),v&&(Fe+=Bl(Te.label,ce-V-6,Ke,"end"))}for(let Te of re){let Ke=ce+Te.at*be;O&&(Le+=`M${d(Ke)},${d(de)}v${O}`),W&&(Fe+=Bl(Te.label,Ke,de+O+4+Te.label.height/2,"middle"))}let He=(u?Ae:be)*z,Pe=He*.7/Math.max(D,1),Ye=D>1?Math.min(2,Pe*.2):0,Ue=Se(ge(0));D>0&&Ue>0&&Ue<1&&(Le+=we(Ue));let he="",ne="",pe="",Re="",le=0;g.forEach((Te,Ke)=>{let ze=ct(Ke),at=Te.title?` data-id="${$e(Te.title)}"`:"",et=h.type==="band"?Math.min(Te.data.length,Y):Te.data.length;if(Te.type==="bar"){let rt=(le++-(D-1)/2)*Pe-(Pe-Ye)/2,Ve="";for(let st=0;st<et;st++){let dt=ds(Te.data[st][1]);if(dt===void 0)continue;let ut=C(st,et),en=Se(ge(dt)),xt=Math.min(Ue,en),qe=Math.max(Ue,en),_t=u?ie(ut,xt):ie(ut,0)+rt,St=u?ue(ut,0)+rt:ue(ut,qe),Mt=u?(qe-xt)*be:Pe-Ye,Gt=u?Pe-Ye:(qe-xt)*Ae;if(Ve+=`<rect x="${d(_t)}" y="${d(St)}" width="${d(Mt)}" height="${d(Gt)}"/>`,!m)continue;let un=String(dt),us=i.width(un,a,0),Yn=en>=Ue?1:-1,Di=_t+Mt/2,Oi=St+Gt/2,Ep="middle";if(u){if(Gt<a)continue;Di=(Yn>0?_t+Mt:_t)+Yn*6,Ep=Yn>0?"start":"end"}else{if(us+2>He/D)continue;Oi=(Yn>0?St:St+Gt)-Yn*(_/2+2)}pe+=`<text x="${d(Di)}" y="${d(Oi+a*.35)}" text-anchor="${Ep}">${un}</text>`}he+=`<g class="pele-series pele-bars"${at} fill="${ze}">${Ve}</g>`;return}let nt="",Tt="",lt=!1,Et=0,ot=NaN;for(let rt=0;rt<et;rt++){let Ve=ds(Te.data[rt][1]);if(Ve===void 0){ot=NaN;continue}let st=C(rt,et),dt=ge(Ve),ut=dt>=0&&dt<=1;if(ot!==ot)ut&&(nt+=`M${d(ie(st,dt))},${d(ue(st,dt))}`),lt=ut;else{let _t=dt-ot,St=0,Mt=1;if(_t!==0){let Gt=-ot/_t,un=(1-ot)/_t;St=Math.max(St,Math.min(Gt,un)),Mt=Math.min(Mt,Math.max(Gt,un))}else ut||(St=2);if(St<=Mt){let Gt=Et+(st-Et)*St,un=ot+_t*St,us=Et+(st-Et)*Mt,Yn=ot+_t*Mt;(!lt||St>0)&&(nt+=`M${d(ie(Gt,un))},${d(ue(Gt,un))}`),nt+=`L${d(ie(us,Yn))},${d(ue(us,Yn))}`}lt=ut}if(Et=st,ot=dt,!ut)continue;let en=ie(st,dt),xt=ue(st,dt);He>=12&&(Tt+=`<circle cx="${d(en)}" cy="${d(xt)}" r="3"/>`);let qe=x(Te.pointLabels?.[rt],a,4e3);if(qe.height>0){let _t=qe.width/2;Re+=u?Bl(qe,en+10,xt,"start"):Bl(qe,Math.max(Math.min(en,j-_t),ce+_t),xt-6-qe.height/2,"middle")}}ne+=`<g class="pele-series pele-line"${at} fill="${ze}">`+(nt?`<path d="${nt}" fill="none" stroke="${ze}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`:"")+Tt+"</g>"});let Ee="";$.height>0&&(Ee+=`<g transform="translate(${d(c+$.height/2)},${d(me+Ae/2)}) rotate(-90)">${Ie($,0,0,"")}</g>`),Ee+=Ie(X,ce+be/2,p-c-X.height/2,"");let Ne="",Me=0;for(let Te of k)Me+=Math.max(Tx,Te.label.height+6);let Ce=me+Math.max(0,(Ae-Me)/2),Oe=j+xe+Cx;for(let{index:Te,label:Ke}of k){let ze=Math.max(Tx,Ke.height+6);if(Ce+ze>p)break;let at=Ce+ze/2,et=ct(Te);Ne+=`<g class="pele-legend-item" data-id="${$e(g[Te].title)}">`+(g[Te].type==="bar"?`<rect x="${d(Oe)}" y="${d(at-$i/2)}" width="${$i}" height="${$i}" rx="2" fill="${et}"/>`:`<path d="M${d(Oe)},${d(at)}h${$i}" stroke="${et}" stroke-width="2" stroke-linecap="round"/>`)+Ie(Ke,Oe+$i+8+Ke.width/2,at,"")+"</g>",Ce+=ze}let We=Ie(S,f/2,c+S.height/2,' class="pele-title" font-weight="var(--_tw)"')+(ke?`<path class="pele-grid" d="${ke}" stroke="var(--_a)"/>`:"")+`<g class="pele-plot">${he}${ne}</g>`+(Le?`<path class="pele-axis" d="${Le}" fill="none" stroke="var(--_b)"/>`:"")+(Fe?`<g class="pele-axis-labels" font-size="${s}" fill="var(--_m)">${Fe}</g>`:"")+(Ee?`<g class="pele-axis-titles" font-size="${s}">${Ee}</g>`:"")+(pe?`<g class="pele-data-labels" font-size="${a}">${pe}</g>`:"")+(Re?`<g class="pele-point-labels" font-size="${a}">${Re}</g>`:"")+(Ne?`<g class="pele-legend" font-size="${s}">${Ne}</g>`:"");return{svg:Ze("xychart",f,p,o,n,e,We),width:f,height:p,links:[]}}var kx={type:"xychart",section:"xyChart",parse(e,t,n){let r=new Pl;return r.title=n,wx(e,r),r},render:Mx};var Lx=[sc,my,bg,ry,jb,$0,Gb,Wm,Ty,kx,m0,db,jh,xE,DE,cy,vy,rA,Ib,n0,Sb,Cm,dm,cE,$h,V0,eg,bx,Ig,QA,sx,Ob,w0];$p(...Lx);export{Ge as PeleError,NS as detectType,mS as enableZoom,Xl as forgetTextWidths,MM as mount,MS as parse,$p as register,IM as registered,kS as render,NM as supports};