@inkeep/open-knowledge 0.86.18 → 0.86.19-beta.1

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 (158) hide show
  1. package/dist/THIRD_PARTY_NOTICES.md +2 -2
  2. package/dist/cli.mjs +6 -6
  3. package/dist/constants-DTpS5DPL.mjs +1 -0
  4. package/dist/{dist-CbA9Te53.mjs → dist-DRgSOIS6.mjs} +468 -468
  5. package/dist/{dist-dkuaYp-W.mjs → dist-DyVcFCkj.mjs} +1 -1
  6. package/dist/index.mjs +81 -81
  7. package/dist/{init-CkPbFkR2.mjs → init-Cc3pxAas.mjs} +2 -2
  8. package/dist/init-rFslisPX.mjs +1 -0
  9. package/dist/{launch-json-removal-DmAd4dyj.mjs → launch-json-removal-Ca30Nixh.mjs} +1 -1
  10. package/dist/{loader-2OYXo10U.mjs → loader-BwPvEjuE.mjs} +1 -1
  11. package/dist/loader-Cy9oZb72.mjs +1 -0
  12. package/dist/{open-browser-foWNoVBg.mjs → open-browser-CFW5reH2.mjs} +1 -1
  13. package/dist/{preview-ZGsL-Uwx.mjs → preview-BKERSD2q.mjs} +1 -1
  14. package/dist/preview-CJewZ-WB.mjs +1 -0
  15. package/dist/public/assets/{AboutSection-1db6GHW2.js → AboutSection-LPELvEUl.js} +1 -1
  16. package/dist/public/assets/{AccountSection-nOUz0-XO.js → AccountSection-DlWsbV8D.js} +1 -1
  17. package/dist/public/assets/{ActivityModeContent-oDazjwS5.js → ActivityModeContent-DkGHz9Ku.js} +1 -1
  18. package/dist/public/assets/{AddPropertiesButton-NmSFHeqp.js → AddPropertiesButton-D__sehWQ.js} +1 -1
  19. package/dist/public/assets/{AgentConnectionsSection--iYEJFNT.js → AgentConnectionsSection-DhbJCdHu.js} +1 -1
  20. package/dist/public/assets/{AgentDiffPane-DthmBv1_.js → AgentDiffPane-xuZ1KudZ.js} +1 -1
  21. package/dist/public/assets/{AgentIconCluster-Ys-JZNda.js → AgentIconCluster-DYP1yNXm.js} +1 -1
  22. package/dist/public/assets/{AppMenubar-DDyx__mD.js → AppMenubar-ClplcAeM.js} +1 -1
  23. package/dist/public/assets/{AttachmentsSection-CdJEk9iY.js → AttachmentsSection-CHLjnxc0.js} +1 -1
  24. package/dist/public/assets/{CodeMirrorPropInput-BgNaaq8o.js → CodeMirrorPropInput-BpHUFt_h.js} +11 -11
  25. package/dist/public/assets/{ConfigSharingInfoTooltip-l_ayrcN2.js → ConfigSharingInfoTooltip-DSloJmkE.js} +1 -1
  26. package/dist/public/assets/{ConsentDialogBody-CYoQuVtn.js → ConsentDialogBody-CaPp8huq.js} +1 -1
  27. package/dist/public/assets/{ContentRulesSection-n5_Uq6lF.js → ContentRulesSection-wbtHcBqr.js} +1 -1
  28. package/dist/public/assets/{CopyButton-qKG_Y_eK.js → CopyButton-BTy3joJd.js} +1 -1
  29. package/dist/public/assets/{DocumentContext-DEUbe-Z2.js → DocumentContext-CQ2e0uie.js} +13 -13
  30. package/dist/public/assets/EditorModeToggle-B_E4wnhm.js +1 -0
  31. package/dist/public/assets/{ExcalidrawDocEditor-CSIWz9Xb.js → ExcalidrawDocEditor-BcoRuAVp.js} +1 -1
  32. package/dist/public/assets/FeedbackForm-DhJSsu3n.js +1 -0
  33. package/dist/public/assets/{GraphPanel-KRwmAWVK.js → GraphPanel-D1tkoAHM.js} +2 -2
  34. package/dist/public/assets/{HotkeysSection-BMjtAkGn.js → HotkeysSection-C9sCf3j3.js} +1 -1
  35. package/dist/public/assets/{ImageAttachments-BWXjEZGr.js → ImageAttachments-BDh-av0V.js} +1 -1
  36. package/dist/public/assets/{ImportSkillDialog-CN46mvgE.js → ImportSkillDialog-lBL0HNJp.js} +1 -1
  37. package/dist/public/assets/{IntegrationsSection-DoiLVCsa.js → IntegrationsSection-D3htSKMO.js} +1 -1
  38. package/dist/public/assets/{LinkPreviewsSection-CRyMimUF.js → LinkPreviewsSection-CULpqlH7.js} +1 -1
  39. package/dist/public/assets/{LintConfigEditor-DBUpKLAE.js → LintConfigEditor-6YyaXnFA.js} +1 -1
  40. package/dist/public/assets/{LintingSection-I4kdwFqj.js → LintingSection-DSwALvf4.js} +1 -1
  41. package/dist/public/assets/{ManagedArtifactProperties-DL5zmaf5.js → ManagedArtifactProperties-vvyx0y7Q.js} +1 -1
  42. package/dist/public/assets/ManagedArtifactProperties-wzj7pm-b.js +1 -0
  43. package/dist/public/assets/{McpConsentDialogBody-DKAfUcdT.js → McpConsentDialogBody-BwguVGDQ.js} +1 -1
  44. package/dist/public/assets/{Mermaid-BUWNFmOJ.js → Mermaid-DqNhHNi1.js} +2 -2
  45. package/dist/public/assets/{MermaidDocEditor-DUBLFQmb.js → MermaidDocEditor-BqqrJSxz.js} +1 -1
  46. package/dist/public/assets/{NetworkAccessSection-BV64VxAs.js → NetworkAccessSection-CJ-k8kEB.js} +1 -1
  47. package/dist/public/assets/{OkCliPathRow-XzRstb3V.js → OkCliPathRow-CIrEL7IY.js} +1 -1
  48. package/dist/public/assets/{OkignoreSection-CItndbA4.js → OkignoreSection-BudJQycp.js} +1 -1
  49. package/dist/public/assets/{OpenInAgentMenuItem-BFQfpofi.js → OpenInAgentMenuItem-DUU1-QP7.js} +1 -1
  50. package/dist/public/assets/{ProjectTemplatesSection-CF-P6d-M.js → ProjectTemplatesSection-DCliKsre.js} +1 -1
  51. package/dist/public/assets/{PropertyDisplayRow-aSFDp_7w.js → PropertyDisplayRow-Cm34goFj.js} +1 -1
  52. package/dist/public/assets/{PublishToGitHubDialog-DZR6cdaM.js → PublishToGitHubDialog-jx0Tzybl.js} +1 -1
  53. package/dist/public/assets/{ReportBugDialogBody-Cuv8swjY.js → ReportBugDialogBody-J5o6Nxwn.js} +1 -1
  54. package/dist/public/assets/{ReportBugMenuTrigger-DCel1VGa.js → ReportBugMenuTrigger-CAUKQKXn.js} +1 -1
  55. package/dist/public/assets/{RowDisclosure-gIio7LxD.js → RowDisclosure-Bj2sD4-N.js} +1 -1
  56. package/dist/public/assets/{SchemaConfigEditor-Dxa3qMiC.js → SchemaConfigEditor-co1_VbGJ.js} +1 -1
  57. package/dist/public/assets/{SearchSection-DTYxFQGg.js → SearchSection-CU6mVIBD.js} +1 -1
  58. package/dist/public/assets/{SessionsHost-CHxDnXNN.js → SessionsHost-Ve1-rpr4.js} +2 -2
  59. package/dist/public/assets/{SettingsDialogBody-nzUdIG66.js → SettingsDialogBody-Du3F7eab.js} +2 -2
  60. package/dist/public/assets/{SettingsSectionHeader-BiiyXKRM.js → SettingsSectionHeader-DDNA1hrR.js} +1 -1
  61. package/dist/public/assets/{ShareBranchSwitchDialog-cMvRsP7t.js → ShareBranchSwitchDialog-BNGZhCgr.js} +1 -1
  62. package/dist/public/assets/{ShareReceiveMissDialog-CT0s6SZD.js → ShareReceiveMissDialog-Bsh7llP0.js} +1 -1
  63. package/dist/public/assets/{SharingSection-DZKx4kGQ.js → SharingSection-Y4AD8HPt.js} +1 -1
  64. package/dist/public/assets/{SkillCostValue-CAF_ekD2.js → SkillCostValue-DBT6aDG-.js} +1 -1
  65. package/dist/public/assets/{SkillInstallMenu-Do_U4WMQ.js → SkillInstallMenu-DyKWxkEY.js} +1 -1
  66. package/dist/public/assets/{SkillOriginInline-RclplHSV.js → SkillOriginInline-D6YyylB6.js} +1 -1
  67. package/dist/public/assets/{SkillPluginBundleDialog-8mBM4DTV.js → SkillPluginBundleDialog-BmLQqQms.js} +1 -1
  68. package/dist/public/assets/{SkillToolbarControls-BmBSoXUZ.js → SkillToolbarControls-Dg0uH9dc.js} +1 -1
  69. package/dist/public/assets/{SkillsManagerSection-B5aptPCM.js → SkillsManagerSection-C0pgRzfs.js} +1 -1
  70. package/dist/public/assets/{SlidesPluginSection-DBHq4ZBE.js → SlidesPluginSection-B8KiQkqa.js} +1 -1
  71. package/dist/public/assets/{SlidesToolbarControls-BSo10McR.js → SlidesToolbarControls-DxIDubwo.js} +1 -1
  72. package/dist/public/assets/{SourceEditor-BKESs3iE.js → SourceEditor-BxraIyxO.js} +1 -1
  73. package/dist/public/assets/SpellingSettings-CElN7mrA.js +1 -0
  74. package/dist/public/assets/{SyncSection-DG4NKKV6.js → SyncSection-CI62AsGJ.js} +1 -1
  75. package/dist/public/assets/{SyncStatusBadge-DbPwIAZ6.js → SyncStatusBadge--DiNAARL.js} +1 -1
  76. package/dist/public/assets/{TemplateRow-C40fof6w.js → TemplateRow-DsoFn6-i.js} +1 -1
  77. package/dist/public/assets/{TerminalLaunchContext-CREkMahV.js → TerminalLaunchContext-DWUMDSpw.js} +1 -1
  78. package/dist/public/assets/{TerminalPanel-DYLjq5_k.js → TerminalPanel-ByCiyPt3.js} +1 -1
  79. package/dist/public/assets/{TerminalSection-Dn5Zx9la.js → TerminalSection-BWcfGvEV.js} +1 -1
  80. package/dist/public/assets/{TerminalWindowApp-B1S9JVI5.js → TerminalWindowApp-BXHW_7B9.js} +1 -1
  81. package/dist/public/assets/{TextDocEditor-t0PyPTxV.js → TextDocEditor-C8zsOMpH.js} +1 -1
  82. package/dist/public/assets/{ThemePluginSection-CpNh8zVh.js → ThemePluginSection-McKmY5If.js} +1 -1
  83. package/dist/public/assets/{ThreadView-C5kp9I_d.js → ThreadView-CjKcF5Bj.js} +1 -1
  84. package/dist/public/assets/{TimelineDiffPane-CY_w4ApS.js → TimelineDiffPane-BScs4tYQ.js} +1 -1
  85. package/dist/public/assets/{agent-connections-5LGp4_96.js → agent-connections-DSKODCmO.js} +1 -1
  86. package/dist/public/assets/auth-prompt-store-C_-QXZFC.js +1 -0
  87. package/dist/public/assets/{client-version-B5RMgZIK.js → client-version-Dyx1KpjP.js} +1 -1
  88. package/dist/public/assets/{cm-theme-BoQxNVQo.js → cm-theme-Dml6DrPs.js} +1 -1
  89. package/dist/public/assets/{comment-chips-wISZaR8q.js → comment-chips-BTYU41zd.js} +1 -1
  90. package/dist/public/assets/{config-provider-CLiLqORc.js → config-provider-Bu33ODD8.js} +1 -1
  91. package/dist/public/assets/{context-menu-DWPgomGa.js → context-menu-B5MxEep2.js} +1 -1
  92. package/dist/public/assets/{dist-CxQmGY4K.js → dist-BUMFJcXg.js} +13 -12
  93. package/dist/public/assets/{dist-ecS2llwR.js → dist-BzicVdNV.js} +1 -1
  94. package/dist/public/assets/{dist-UouvQIiM.js → dist-C0nuYMFu.js} +1 -1
  95. package/dist/public/assets/{dist-D1AbXGbs.js → dist-Cj3Bpren.js} +1 -1
  96. package/dist/public/assets/{dist-YVu4MRkZ2.js → dist-DXjgFhPl2.js} +1 -1
  97. package/dist/public/assets/dist-DjMGDcCv.js +161 -0
  98. package/dist/public/assets/{dist-d0R4nnoB.js → dist-d2WYntJB.js} +1 -1
  99. package/dist/public/assets/{doc-undo-manager-Dq0xUVqE.js → doc-undo-manager-CPZo2IhT.js} +1 -1
  100. package/dist/public/assets/{dropdown-menu-DtLu9NwU.js → dropdown-menu-5XqyQTVx.js} +1 -1
  101. package/dist/public/assets/field-controls-CCcf2ybM.js +1 -0
  102. package/dist/public/assets/field-controls-CKb1JSHS.js +6 -0
  103. package/dist/public/assets/{floating-ui.dom-DkPPH5vF.js → floating-ui.dom-BYl7JZd0.js} +1 -1
  104. package/dist/public/assets/globals-Cr0S8PDH.css +1 -0
  105. package/dist/public/assets/{ime-composition-Dvok5Aig.js → ime-composition-_BDVzXn4.js} +1 -1
  106. package/dist/public/assets/index-DQZmjexO.js +2209 -0
  107. package/dist/public/assets/{lint-plugins-B2ISAGv1.js → lint-plugins-Cv7WvUlN.js} +1 -1
  108. package/dist/public/assets/{markdownlint-rule-browser-Ct2gBGg7.js → markdownlint-rule-browser-BQ4c4vDN.js} +1 -1
  109. package/dist/public/assets/{pending-receive-nav-store-BVdZUxyv.js → pending-receive-nav-store-6bXbTZhv.js} +1 -1
  110. package/dist/public/assets/{popover-BNtf9SIu.js → popover-Mb1GgB61.js} +1 -1
  111. package/dist/public/assets/{preferred-session-events-DyF-zGVw.js → preferred-session-events-BytmLBUB.js} +1 -1
  112. package/dist/public/assets/preview-frame.html +9 -0
  113. package/dist/public/assets/{prod-tc4sAE_j.js → prod-CN58f7_5.js} +1 -1
  114. package/dist/public/assets/{progress-UaljIhan.js → progress-Ba4KJbjQ.js} +1 -1
  115. package/dist/public/assets/{project-paths-DVH_uA_B.js → project-paths-BFzGZn4G.js} +1 -1
  116. package/dist/public/assets/{schema-section-ayoRsG9p.js → schema-section-CalUQFIh.js} +1 -1
  117. package/dist/public/assets/{select-Bu4Wm3Rf.js → select-pACXgFe2.js} +1 -1
  118. package/dist/public/assets/{selection-context-DUCgNUF1.js → selection-context-BdkqiHSg.js} +1 -1
  119. package/dist/public/assets/{src-B0QKvZvz.js → src-BKxD4aGX.js} +1 -1
  120. package/dist/public/assets/{tag-pill-input-ez8oOC69.js → tag-pill-input-D6mNhknm.js} +1 -1
  121. package/dist/public/assets/{telemetry-impl-DxN46IeS.js → telemetry-impl-lt4HgP_f.js} +1 -1
  122. package/dist/public/assets/{telemetry-startup-D6Eiqg0a.js → telemetry-startup-COAksO_l.js} +1 -1
  123. package/dist/public/assets/{tooltip-DBqLYfio.js → tooltip-Bz6z4_se.js} +1 -1
  124. package/dist/public/assets/{typing-burst-detector-DVA93P7-.js → typing-burst-detector-Ceucd7lf.js} +1 -1
  125. package/dist/public/assets/{uninstall-CoAbS5TW.js → uninstall-DFTOzPT_.js} +1 -1
  126. package/dist/public/assets/{use-activity-panel-COfLk6p7.js → use-activity-panel-ClZw0uAV.js} +1 -1
  127. package/dist/public/assets/{use-installed-clis-DBO1ohE8.js → use-installed-clis-BopBqnEZ.js} +2 -2
  128. package/dist/public/assets/{use-open-skill-C_H2GP75.js → use-open-skill-BufHQt2J.js} +1 -1
  129. package/dist/public/assets/{use-terminal-enabled-B6tq2SSg.js → use-terminal-enabled-kUXuNyA3.js} +1 -1
  130. package/dist/public/assets/{use-timeline-entry-diff-DYB18Q1p.js → use-timeline-entry-diff-DIXfdlmY.js} +1 -1
  131. package/dist/public/index.html +51 -51
  132. package/dist/public/uninstall.html +3 -3
  133. package/dist/{registry-probes-BlQKMPi4.mjs → registry-probes-BzVs0MZl.mjs} +1 -1
  134. package/dist/{removal-file-path-D9yKcMpY.mjs → removal-file-path-DjVZJivF.mjs} +1 -1
  135. package/dist/{repair-launch-json-B0OX3YQi.mjs → repair-launch-json-DaJc8F0u.mjs} +1 -1
  136. package/dist/{repair-mcp-configs-CGq6k6H_.mjs → repair-mcp-configs-GI1XgsXr.mjs} +1 -1
  137. package/dist/{src-CjXfLoyT.mjs → src-CiJt-PQj.mjs} +1 -1
  138. package/dist/src-Dt5ff2eL.mjs +1 -0
  139. package/dist/{start-BbxRMheZ.mjs → start-CNmN3UB5.mjs} +3 -3
  140. package/dist/start-CTAc0UYC.mjs +1 -0
  141. package/package.json +4 -4
  142. package/dist/constants-DUiVsIOs.mjs +0 -1
  143. package/dist/init-l9cfH71w.mjs +0 -1
  144. package/dist/loader-YYzZ4B4e.mjs +0 -1
  145. package/dist/preview-B7Sklqw2.mjs +0 -1
  146. package/dist/public/assets/EditorModeToggle-CP1ztRWC.js +0 -1
  147. package/dist/public/assets/FeedbackForm-DORFfDxS.js +0 -1
  148. package/dist/public/assets/ManagedArtifactProperties-C-4znHTQ.js +0 -1
  149. package/dist/public/assets/SpellingSettings-Br-26Hbn.js +0 -1
  150. package/dist/public/assets/auth-prompt-store-BVF1DJFW.js +0 -1
  151. package/dist/public/assets/dist-JrdDgCNs.js +0 -124
  152. package/dist/public/assets/field-controls-CXow0RGZ.js +0 -1
  153. package/dist/public/assets/field-controls-DdrxD5BW.js +0 -6
  154. package/dist/public/assets/globals-BXqkmCJW.css +0 -1
  155. package/dist/public/assets/index-Cc2rvqNG.js +0 -2209
  156. package/dist/src-h06ZmOk0.mjs +0 -1
  157. package/dist/start-BdARbmeL.mjs +0 -1
  158. /package/dist/public/assets/{globals-IGp2_ZaI.js → globals-DHDe92Ga.js} +0 -0
@@ -1,14 +1,15 @@
1
1
  function e(e,t){let n=!1,r=e=>{let n=t.getText().length;return e.filter(e=>e.end>e.start&&e.end<=n).sort((e,t)=>e.start-t.start)},i=[e.on(`change`,({origin:i,edits:a,code:o})=>{if(i!==`code`){n=!0;try{let e=t.getText().length;t.applyEdits(a.map(t=>({start:Math.min(t.start,e),end:Math.min(t.end,e),text:t.text}))),t.getText()!==o&&t.setText(o)}finally{n=!1}}t.setHighlights(r(e.selectionSpans()))}),e.on(`selectionChange`,({spans:e,origin:n})=>{t.setHighlights(r(e)),n===`canvas`&&e[0]&&t.revealPosition?.(e[0].start)})];return{get applying(){return n},notifyTextChange(){n||e.setCode(t.getText(),`code`)},notifyCaretMove(t){if(n)return;let r=e.entityAt(t);e.setSelection(r?[r]:[],`code`)},undo:()=>e.undo(),redo:()=>e.redo(),dispose:()=>i.forEach(e=>e())}}var t=`https://mermaid.js.org`,n=[{id:`flowchart`,name:`Flowchart`,match:/^(flowchart|graph)\b/,capability:`edit`,docsUrl:`${t}/syntax/flowchart.html`},{id:`sequence`,name:`Sequence Diagram`,match:/^sequenceDiagram\b/,capability:`edit`,docsUrl:`${t}/syntax/sequenceDiagram.html`},{id:`class`,name:`Class Diagram`,match:/^classDiagram(-v2)?\b/,capability:`edit`,docsUrl:`${t}/syntax/classDiagram.html`},{id:`state`,name:`State Diagram`,match:/^stateDiagram(-v2)?\b/,capability:`edit`,docsUrl:`${t}/syntax/stateDiagram.html`},{id:`er`,name:`Entity Relationship`,match:/^erDiagram\b/,capability:`edit`,docsUrl:`${t}/syntax/entityRelationshipDiagram.html`},{id:`journey`,name:`User Journey`,match:/^journey\b/,capability:`edit`,docsUrl:`${t}/syntax/userJourney.html`},{id:`gantt`,name:`Gantt`,match:/^gantt\b/,capability:`edit`,docsUrl:`${t}/syntax/gantt.html`},{id:`pie`,name:`Pie Chart`,match:/^pie\b/,capability:`edit`,docsUrl:`${t}/syntax/pie.html`},{id:`quadrant`,name:`Quadrant Chart`,match:/^quadrantChart\b/,capability:`edit`,docsUrl:`${t}/syntax/quadrantChart.html`},{id:`requirement`,name:`Requirement Diagram`,match:/^requirement(Diagram)?\b/,capability:`edit`,docsUrl:`${t}/syntax/requirementDiagram.html`},{id:`gitgraph`,name:`Gitgraph`,match:/^gitGraph\b/,capability:`edit`,docsUrl:`${t}/syntax/gitgraph.html`},{id:`c4`,name:`C4 Diagram`,match:/^C4(Context|Container|Component|Dynamic|Deployment)\b/,capability:`edit`,docsUrl:`${t}/syntax/c4.html`},{id:`mindmap`,name:`Mindmap`,match:/^mindmap\b/,capability:`edit`,docsUrl:`${t}/syntax/mindmap.html`},{id:`timeline`,name:`Timeline`,match:/^timeline\b/,capability:`edit`,docsUrl:`${t}/syntax/timeline.html`},{id:`zenuml`,name:`ZenUML`,match:/^zenuml\b/,capability:`render`,docsUrl:`${t}/syntax/zenuml.html`,requiresPlugin:`@mermaid-js/mermaid-zenuml`},{id:`sankey`,name:`Sankey`,match:/^sankey(-beta)?\b/,capability:`edit`,docsUrl:`${t}/syntax/sankey.html`},{id:`xychart`,name:`XY Chart`,match:/^xychart(-beta)?\b/,capability:`edit`,docsUrl:`${t}/syntax/xyChart.html`},{id:`block`,name:`Block Diagram`,match:/^block(-beta)?\b/,capability:`edit`,docsUrl:`${t}/syntax/block.html`},{id:`packet`,name:`Packet`,match:/^packet(-beta)?\b/,capability:`edit`,docsUrl:`${t}/syntax/packet.html`},{id:`kanban`,name:`Kanban`,match:/^kanban\b/,capability:`edit`,docsUrl:`${t}/syntax/kanban.html`},{id:`architecture`,name:`Architecture`,match:/^architecture(-beta)?\b/,capability:`edit`,docsUrl:`${t}/syntax/architecture.html`},{id:`radar`,name:`Radar`,match:/^radar(-beta)?\b/,capability:`edit`,docsUrl:`${t}/syntax/radar.html`},{id:`treemap`,name:`Treemap`,match:/^treemap(-beta)?\b/,capability:`edit`,docsUrl:`${t}/syntax/treemap.html`}];function r(e){let t=e.trim();for(let e of n)if(e.match.test(t))return e;return null}function i(e){let t=[],n=0,r=0;for(;n<=e.length;){let i=e.indexOf(`
2
- `,n);i===-1&&(i=e.length);let a=e.slice(n,i),o=/^[ \t]*/.exec(a)[0];if(t.push({index:r,kind:`statement`,text:a,start:n,end:i,indent:o}),r++,i===e.length)break;n=i+1}return t}function a(e){let t=-1,n=!1,r=!1,i=!1;for(let a of e){let e=a.text.trim();if(!i&&!r&&e===`---`)if(n){n=!1,r=!0,a.kind=`frontmatter`;continue}else{n=!0,a.kind=`frontmatter`;continue}if(n){a.kind=`frontmatter`;continue}if(e===``){a.kind=`blank`;continue}if(e.startsWith(`%%{`)){a.kind=`directive`;continue}if(e.startsWith(`%%`)){a.kind=`comment`;continue}if(t===-1){a.kind=`header`,t=a.index,i=!0;continue}a.kind=`statement`,i=!0}return{headerIndex:t}}function o(e,t){let n=[...t].sort((e,t)=>e.start-t.start);for(let e=1;e<n.length;e++)if(n[e].start<n[e-1].end)throw Error(`Overlapping text edits`);let r=``,i=0,a=[],o=0;for(let t of n)r+=e.slice(i,t.start),r+=t.text,a.push({start:t.start+o,end:t.start+o+t.text.length,text:e.slice(t.start,t.end)}),o+=t.text.length-(t.end-t.start),i=t.end;return r+=e.slice(i),{text:r,inverse:a}}function s(e,t){if(e===t)return null;let n=0,r=e.length,i=t.length,a=Math.min(r,i);for(;n<a&&e[n]===t[n];)n++;let o=r,s=i;for(;o>n&&s>n&&e[o-1]===t[s-1];)o--,s--;return{start:n,end:o,text:t.slice(n,s)}}function c(e,t){let n=e;for(let r of[...t].sort((e,t)=>e.start-t.start))r.end<=e?n+=r.text.length-(r.end-r.start):r.start<e&&(n=r.start+r.text.length);return n}var l=[{open:`(((`,close:[`)))`]},{open:`([`,close:[`])`]},{open:`[[`,close:[`]]`]},{open:`[(`,close:[`)]`]},{open:`[/`,close:[`/]`,`\\]`]},{open:`[\\`,close:[`\\]`,`/]`]},{open:`((`,close:[`))`]},{open:`{{`,close:[`}}`]},{open:`{`,close:[`}`]},{open:`(`,close:[`)`]},{open:`[`,close:[`]`]},{open:`>`,close:[`]`]}],u={"(((|)))":`doublecircle`,"((|))":`circle`,"([|])":`stadium`,"[[|]]":`subroutine`,"[(|)]":`cylinder`,"[/|/]":`lean_r`,"[/|\\]":`trap_b`,"[\\|\\]":`lean_l`,"[\\|/]":`trap_t`,"{{|}}":`hexagon`,"{|}":`diamond`,"(|)":`round`,"[|]":`rect`,">|]":`odd`},d={rect:{open:`[`,close:`]`},round:{open:`(`,close:`)`},stadium:{open:`([`,close:`])`},subroutine:{open:`[[`,close:`]]`},cylinder:{open:`[(`,close:`)]`},circle:{open:`((`,close:`))`},doublecircle:{open:`(((`,close:`)))`},diamond:{open:`{`,close:`}`},hexagon:{open:`{{`,close:`}}`},lean_r:{open:`[/`,close:`/]`},lean_l:{open:`[\\`,close:`\\]`},trap_t:{open:`[\\`,close:`/]`},trap_b:{open:`[/`,close:`\\]`},odd:{open:`>`,close:`]`}},f=/[A-Za-z0-9_.]/,p=class{text;pos=0;end;base;constructor(e){this.text=e.text,this.base=e.start;let t=this.text.length;for(;t>0&&/[;\s]/.test(this.text[t-1]);)t--;this.end=t;let n=0;for(;n<t&&/[ \t]/.test(this.text[n]);)n++;this.pos=n}skipWs(){for(;this.pos<this.end&&/[ \t]/.test(this.text[this.pos]);)this.pos++}atEnd(){return this.pos>=this.end}abs(e){return this.base+e}parseNodeRef(){let e=this.pos,t=this.pos;for(;this.pos<this.end&&f.test(this.text[this.pos]);)this.pos++;if(this.pos===t)return null;let n=this.text.slice(t,this.pos),r={start:this.abs(t),end:this.abs(this.pos)},i=null,a=null,o=null,s=!1;for(let e of l)if(this.text.startsWith(e.open,this.pos)){let t=this.pos+e.open.length,n=null,r,c,l;if(this.text[t]===`"`){let i=this.text.indexOf(`"`,t+1);if(i===-1||i>=this.end)return null;r=t+1,c=i,l=i+1,s=!0;for(let t of e.close)if(this.text.startsWith(t,l)){n=t;break}if(!n)return null;this.pos=l+n.length}else{let i=-1;for(let r of e.close){let e=this.text.indexOf(r,t);e!==-1&&e<this.end&&(i===-1||e<i)&&(i=e,n=r)}if(i===-1||!n)return null;r=t,c=i,this.pos=i+n.length}i=u[`${e.open}|${n}`]??`rect`,a=this.text.slice(r,c),o={start:this.abs(r),end:this.abs(c)};break}let c=null;if(this.text.startsWith(`@{`,this.pos)){let e=this.text.indexOf(`}`,this.pos+2);if(e===-1||e>=this.end+1)return null;c=this.text.slice(this.pos,e+1),this.pos=e+1}let d=[];for(;this.text.startsWith(`:::`,this.pos);){let e=this.pos+3,t=e;for(;e<this.end&&/[A-Za-z0-9_-]/.test(this.text[e]);)e++;if(e===t)return null;d.push(this.text.slice(t,e)),this.pos=e}return{id:n,span:{start:this.abs(e),end:this.abs(this.pos)},idSpan:r,shape:i,label:a,labelSpan:o,quoted:s,attrsRaw:c,classNames:d}}parseGroup(){let e=this.parseNodeRef();if(!e)return null;let t=[e];for(;;){let e=this.pos;if(this.skipWs(),this.text[this.pos]===`&`){this.pos++,this.skipWs();let e=this.parseNodeRef();if(!e)return null;t.push(e)}else{this.pos=e;break}}return t}parseEdge(){let e=this.pos,t=this.text.slice(this.pos,this.end),n=/^(?:(x|o|<)(?=[-=.~]))?(-{2,}|={2,}|-\.+-+|-\.+|~{3,})(>|x|o)?/.exec(t);if(!n)return null;let r=n[0];this.pos+=r.length;let i=n[1]??null,a=n[3]??null,o=n[2],s=null,c=null;if(!a&&/^(-{2}|={2}|-\.+-*)$/.test(o)&&this.text[this.pos]===` `){let e=o[0]===`=`?/\s(={2,}(>|x|o)?)/:o.includes(`.`)?/\s(\.*-*\.+->|\.+-+(>|x|o)?|\.->)/:/\s(-{2,}(>|x|o)?)/,t=this.text.slice(this.pos,this.end),n=e.exec(t);if(n&&n.index>=0){let e=this.pos+1,t=this.pos+n.index;if(t>e-1){s=this.text.slice(e,t),c={start:this.abs(e),end:this.abs(t)};let r=n[1];this.pos=this.pos+n.index+n[0].length,a=/[>xo]$/.test(r)?r[r.length-1]:null}}}let l=this.pos;if(this.skipWs(),this.text[this.pos]===`|`){let e=this.text.indexOf(`|`,this.pos+1);e!==-1&&e<this.end?(s=this.text.slice(this.pos+1,e),c={start:this.abs(this.pos+1),end:this.abs(e)},this.pos=e+1):this.pos=l}else this.pos=l;r=this.text.slice(e,this.pos);let u=o[0]===`=`?`thick`:o.includes(`.`)?`dotted`:o[0]===`~`?`invisible`:`solid`,d=e=>e===`>`?`arrow`:e===`x`?`cross`:e===`o`?`circle`:`open`;return{span:{start:this.abs(e),end:this.abs(this.pos)},raw:r,line:u,arrowEnd:d(a),arrowStart:i?i===`<`?`arrow`:d(i):`open`,label:s,labelSpan:c}}};function m(e){let t=e.text.trim(),n=e.index;if(t===`end`)return{kind:`end`,lineIndex:n,ids:[],idsSpan:null};let r=/^direction\s+(TB|TD|BT|RL|LR)\s*;?\s*$/.exec(t);if(r)return{kind:`direction`,lineIndex:n,ids:[r[1]],idsSpan:null};if(/^subgraph\s+(.*)$/.exec(t)){let t=new p(e);t.pos=e.text.indexOf(`subgraph`)+8,t.skipWs();let r=t.pos;for(;t.pos<t.end&&/[^\s[]/.test(e.text[t.pos]);)t.pos++;let i=e.text.slice(r,t.pos),a=null,o=null;if(t.skipWs(),e.text[t.pos]===`[`){let n=e.text.lastIndexOf(`]`);if(n>t.pos){let r=t.pos+1,i=n;e.text[r]===`"`&&e.text[i-1]===`"`&&(r++,i--),a=e.text.slice(r,i),o={start:e.start+r,end:e.start+i}}}return{kind:`subgraphOpen`,lineIndex:n,id:i,title:a,titleSpan:o}}if(/^classDef\b/.test(t))return{kind:`classDef`,lineIndex:n,ids:[],idsSpan:null};if(/^linkStyle\b/.test(t))return{kind:`linkStyle`,lineIndex:n,ids:[],idsSpan:null};let i=/^class\s+([A-Za-z0-9_.,\s]+?)\s+([A-Za-z0-9_-]+)\s*;?\s*$/.exec(t);if(i){let t=i[1].split(`,`).map(e=>e.trim()).filter(Boolean),r=e.text.indexOf(i[1]);return{kind:`classAssign`,lineIndex:n,ids:t,idsSpan:{start:e.start+r,end:e.start+r+i[1].length}}}let a=/^style\s+([A-Za-z0-9_.]+)\b/.exec(t);if(a)return{kind:`style`,lineIndex:n,ids:[a[1]],idsSpan:null};let o=/^click\s+([A-Za-z0-9_.]+)\b/.exec(t);if(o)return{kind:`click`,lineIndex:n,ids:[o[1]],idsSpan:null};let s=new p(e),c=[],l=[],u=s.parseGroup();if(u){c.push(u);let e=!0;for(;s.skipWs(),!s.atEnd();){let t=s.parseEdge();if(!t){e=!1;break}s.skipWs();let n=s.parseGroup();if(!n){e=!1;break}l.push(t),c.push(n)}if(e)return{kind:`chain`,lineIndex:n,groups:c,edges:l}}return{kind:`unknown`,lineIndex:n,ids:[],idsSpan:null}}function h(e){let t=/^(\s*)(flowchart|graph)(\s+)?(TB|TD|BT|RL|LR)?/.exec(e.text);if(!t)return{keyword:`flowchart`,direction:null,directionSpan:null};let n=t[2],r=t[4]??null,i=null;if(r){let a=e.start+t[1].length+n.length+(t[3]?.length??0);i={start:a,end:a+r.length}}return{keyword:n,direction:r,directionSpan:i}}function g(e,t){let n=h(e[t]),r=new Map,i=[],a=[],o=new Map,s=[],c=new Map,l=t,u=(e,t)=>{let n=r.get(e.id);n||(n={entityId:`node:${e.id}`,id:e.id,label:e.id,shape:`rect`,refs:[],primary:null,classes:[],subgraph:s.length?s[s.length-1].id:null},r.set(e.id,n)),n.refs.push({lineIndex:t,ref:e}),e.shape&&(n.primary={lineIndex:t,ref:e},n.shape=e.shape,e.label!==null&&(n.label=e.label));for(let t of e.classNames)n.classes.includes(t)||n.classes.push(t);return n};for(let n of e){if(n.index===t){l=n.index;continue}if(n.kind!==`statement`)continue;let e=m(n);if(o.set(n.index,e),l=n.index,e.kind===`subgraphOpen`){let t={entityId:`subgraph:${e.id}`,id:e.id,title:e.title,titleSpan:e.titleSpan,openLine:e.lineIndex,endLine:-1,parent:s.length?s[s.length-1].id:null};a.push(t),s.push(t)}else if(e.kind===`end`){let t=s.pop();t&&(t.endLine=e.lineIndex)}else if(e.kind===`chain`){for(let t of e.groups)for(let n of t)u(n,e.lineIndex);e.edges.forEach((t,n)=>{for(let r of e.groups[n])for(let a of e.groups[n+1]){let o=`${r.id}->${a.id}`,s=c.get(o)??0;c.set(o,s+1),i.push({entityId:`edge:${o}#${s}`,source:r.id,target:a.id,lineIndex:e.lineIndex,segIndex:n,seg:t,sourceRef:r,targetRef:a,label:t.label,order:i.length})}})}else if(e.kind===`classAssign`){let t=/\s([A-Za-z0-9_-]+)\s*;?\s*$/.exec(n.text)?.[1];if(t)for(let n of e.ids){let e=r.get(n);e&&!e.classes.includes(t)&&e.classes.push(t)}}}return{keyword:n.keyword,direction:n.direction,directionSpan:n.directionSpan,headerLine:t,nodes:[...r.values()],edges:i,subgraphs:a,nodeById:r,statements:o,lastContentLine:l}}function _(e,t,n){if(n.startsWith(`node:`)){let t=e.nodeById.get(n.slice(5));return t?t.refs.map(e=>e.ref.span):[]}if(n.startsWith(`edge:`)){let t=e.edges.find(e=>e.entityId===n);return t?[{start:t.sourceRef.span.start,end:t.targetRef.span.end}]:[]}if(n.startsWith(`subgraph:`)){let r=e.subgraphs.find(e=>e.entityId===n);if(!r)return[];let i=t[r.openLine];return[{start:i.start+i.indent.length,end:i.end}]}return[]}function v(e,t){for(let n of e.nodes)for(let e of n.refs)if(t>=e.ref.span.start&&t<=e.ref.span.end)return n.entityId;for(let n of e.edges)if(t>=n.seg.span.start&&t<=n.seg.span.end||t>=n.sourceRef.span.start&&t<=n.targetRef.span.end)return n.entityId;return null}var ee=/[[\]{}()|<>\\/&%#;]|^\s|\s$/;function y(e,t){let n=e.replace(/"/g,`'`);return t||ee.test(n)?`"${n}"`:n}function b(e,t){let n=t===`arrow`?`>`:t===`cross`?`x`:t===`circle`?`o`:``;switch(e){case`thick`:return n?`==${n}`:`===`;case`dotted`:return n?`-.-${n}`:`-.-`;case`invisible`:return`~~~`;default:return n?`--${n}`:`---`}}function x(e){for(let t of e.lines)if(t.kind===`statement`&&t.index!==e.graph.headerLine&&t.text.trim()!==``)return t.indent;return` `}function S(e,t,n){let r=e.lines[t];return{start:r.end,end:r.end,text:n.map(e=>`
3
- ${e}`).join(``)}}function C(e,t){let n=e.lines[t];return n.end<e.code.length?{start:n.start,end:n.end+1,text:``}:n.start>0?{start:n.start-1,end:n.end,text:``}:{start:n.start,end:n.end,text:``}}function w(e,t,n){if(n.length===0)return C(e,t);let r=e.lines[t];return{start:r.start,end:r.end,text:n.join(`
4
- `)}}function T(e,t){return e.code.slice(t.start,t.end)}function te(e,t){let n=new Set(e.nodes.map(e=>e.id));if(t&&!n.has(t))return t;if(e.nodes.length>0&&e.nodes.every(e=>/^[A-Z]$/.test(e.id)))for(let e=0;e<26;e++){let t=String.fromCharCode(65+e);if(!n.has(t))return t}let r=1;for(;n.has(`n${r}`);)r++;return`n${r}`}function ne(e,t){let n=e.lastContentLine,r=-1;for(let n of t){let t=e.nodeById.get(n);if(t)for(let e of t.refs)r=Math.max(r,e.lineIndex)}return r===-1?n:r}function re(e,t,n,r){let i=e.lines[t],a=i.indent,o=[];n.edges.forEach((e,t)=>{for(let e of n.groups[t])for(let r of n.groups[t+1])o.push({a:e,b:r,segIndex:t})});let s=o.filter(e=>!(r.dropNodeId&&(e.a.id===r.dropNodeId||e.b.id===r.dropNodeId)||r.dropEdge&&e.segIndex===r.dropEdge.segIndex&&e.a.id===r.dropEdge.source&&e.b.id===r.dropEdge.target));if(s.length===o.length&&!r.dropNodeId)return[i.text];let c=new Set;for(let e of s)c.add(e.a),c.add(e.b);let l=[],u=``,d=null;for(let t of s){let r=T(e,n.edges[t.segIndex].span);d===t.a&&u?u+=` ${r} ${T(e,t.b.span)}`:(u&&l.push(a+u),u=`${T(e,t.a.span)} ${r} ${T(e,t.b.span)}`),d=t.b}u&&l.push(a+u);for(let i of n.groups)for(let n of i){if(n.id===r.dropNodeId||c.has(n))continue;let i=e.graph.nodeById.get(n.id);if(!i)continue;let o=i.refs.some(e=>e.ref!==n&&e.ref.shape),s=i.refs.some(e=>e.lineIndex!==t||e.ref!==n&&c.has(e.ref));(n.shape&&!o||!s&&!n.shape)&&l.push(a+T(e,n.span))}return l}function E(e,t){return e.edges.find(e=>e.entityId===t)??null}function D(e,t){let n=[];for(let[r,i]of e.graph.statements){if(i.kind!==`linkStyle`)continue;let a=e.lines[r],o=/^(\s*linkStyle\s+)(\d+)\b/.exec(a.text);if(!o)continue;let s=Number(o[2]),c=t(s);if(c===null)n.push(C(e,r));else if(c!==s){let e=a.start+o[1].length;n.push({start:e,end:e+o[2].length,text:String(c)})}}return n}function O(e,t){return e.nodeById.get(t)??null}function ie(e,t){let{graph:n}=e;switch(t.type){case`addNode`:{let r=te(n,t.id),i=t.shape??`rect`,a=t.label??r,{open:o,close:s}=d[i],c=`${x(e)}${r}${o}${y(a,!1)}${s}`;return{edits:[S(e,n.lastContentLine,[c])],created:[`node:${r}`]}}case`connect`:{let r=O(n,t.source),i=O(n,t.target);if(!r||!i)return null;let a=b(t.line??`solid`,t.arrowEnd??`arrow`),o=t.label?`|${t.label.replace(/\|/g,``)}|`:``,s=ne(n,[t.source,t.target]),c=`${e.lines[s].kind===`statement`?e.lines[s].indent:x(e)}${t.source} ${a}${o} ${t.target}`,l=n.edges.filter(e=>e.source===t.source&&e.target===t.target).length,u=n.edges.filter(e=>e.lineIndex<=s).length;return{edits:[S(e,s,[c]),...D(e,e=>e>=u?e+1:e)],created:[`edge:${t.source}->${t.target}#${l}`]}}case`renameNode`:{let e=O(n,t.id);if(!e)return null;if(e.primary&&e.primary.ref.labelSpan){let n=e.primary.ref,r=n.labelSpan;return n.quoted?{edits:[{start:r.start,end:r.end,text:t.label.replace(/"/g,`'`)}]}:{edits:[{start:r.start,end:r.end,text:y(t.label,!1)}]}}let r=e.refs[0];if(!r)return null;let i=r.ref.idSpan.end;return{edits:[{start:i,end:i,text:`[${y(t.label,!1)}]`}]}}case`setNodeShape`:{let e=O(n,t.id);if(!e)return null;let{open:r,close:i}=d[t.shape];if(e.primary&&e.primary.ref.labelSpan){let t=e.primary.ref,n=d[t.shape],a=+!!t.quoted,o=t.idSpan.end,s=t.labelSpan.start-a,c=t.labelSpan.end+a,l=c+n.close.length;return{edits:[{start:o,end:s,text:r},{start:c,end:l,text:i}]}}let a=e.refs[0];if(!a)return null;let o=a.ref.idSpan.end;return{edits:[{start:o,end:o,text:`${r}${y(e.label,!1)}${i}`}]}}case`setEdgeLabel`:{let e=E(n,t.edgeId);if(!e)return null;let r=t.label.replace(/\|/g,``);if(e.seg.labelSpan){if(r===``){let t=b(e.seg.line,e.seg.arrowEnd);return{edits:[{start:e.seg.span.start,end:e.seg.span.end,text:t}]}}return{edits:[{start:e.seg.labelSpan.start,end:e.seg.labelSpan.end,text:r}]}}return r===``?{edits:[]}:{edits:[{start:e.seg.span.end,end:e.seg.span.end,text:`|${r}|`}]}}case`setEdgeStyle`:{let e=E(n,t.edgeId);if(!e)return null;let r=b(t.line??e.seg.line,t.arrowEnd??e.seg.arrowEnd),i=e.seg.label===null?``:`|${e.seg.label.replace(/\|/g,``)}|`;return{edits:[{start:e.seg.span.start,end:e.seg.span.end,text:`${r}${i}`}]}}case`setDirection`:{if(n.directionSpan)return{edits:[{start:n.directionSpan.start,end:n.directionSpan.end,text:t.direction}]};let r=e.lines[n.headerLine],i=r.start+r.indent.length+n.keyword.length;return{edits:[{start:i,end:i,text:` ${t.direction}`}]}}case`deleteEdge`:{let r=E(n,t.edgeId);if(!r)return null;let i=n.statements.get(r.lineIndex);if(!i||i.kind!==`chain`)return null;let a=re(e,r.lineIndex,i,{dropEdge:{segIndex:r.segIndex,source:r.source,target:r.target}}),o=r.order;return{edits:[w(e,r.lineIndex,a),...D(e,e=>e===o?null:e>o?e-1:e)]}}case`deleteNode`:{let r=O(n,t.id);if(!r)return null;let i=[],a=new Set;for(let e of r.refs)a.add(e.lineIndex);for(let r of a){let a=n.statements.get(r);if(!a||a.kind!==`chain`)continue;let o=re(e,r,a,{dropNodeId:t.id});i.push(w(e,r,o))}for(let[r,a]of n.statements)if(a.kind===`classAssign`&&a.ids.includes(t.id)&&a.idsSpan){let n=a.ids.filter(e=>e!==t.id);n.length===0?i.push(C(e,r)):i.push({start:a.idsSpan.start,end:a.idsSpan.end,text:n.join(`,`)})}else (a.kind===`style`||a.kind===`click`)&&a.ids[0]===t.id&&i.push(C(e,r));let o=n.edges.filter(e=>e.source===t.id||e.target===t.id).map(e=>e.order).sort((e,t)=>e-t);return i.push(...D(e,e=>o.includes(e)?null:e-o.filter(t=>t<e).length)),{edits:i}}case`duplicateNode`:{let r=O(n,t.id);if(!r)return null;let i=te(n),{open:a,close:o}=d[r.shape],s=r.classes.length?`:::${r.classes[0]}`:``,c=r.primary?.lineIndex??r.refs[0]?.lineIndex??n.lastContentLine;return{edits:[S(e,c,[`${e.lines[c].kind===`statement`?e.lines[c].indent:x(e)}${i}${a}${y(r.label,!1)}${o}${s}`])],created:[`node:${i}`]}}case`reverseEdge`:{let r=E(n,t.edgeId);if(!r)return null;let i=n.statements.get(r.lineIndex);if(!i||i.kind!==`chain`||i.groups.length!==2||i.groups[0].length!==1||i.groups[1].length!==1)return null;let a=T(e,r.sourceRef.span),o=T(e,r.targetRef.span);return{edits:[{start:r.sourceRef.span.start,end:r.sourceRef.span.end,text:o},{start:r.targetRef.span.start,end:r.targetRef.span.end,text:a}]}}case`setNodeColor`:{if(!O(n,t.id))return null;let r=-1;for(let[e,i]of n.statements)if(i.kind===`style`&&i.ids[0]===t.id){r=e;break}let i=new Map;if(r>=0){let n=e.lines[r].text.trim().replace(RegExp(`^style\\s+${t.id}\\s*`),``);for(let e of n.split(`,`)){let t=e.indexOf(`:`);t>0&&i.set(e.slice(0,t).trim(),e.slice(t+1).trim())}}t.value===null?i.delete(t.prop):i.set(t.prop,t.value),i.has(`stroke`)&&!i.has(`stroke-width`)&&i.set(`stroke-width`,`2px`),i.has(`stroke`)||i.delete(`stroke-width`);let a=`${r>=0?e.lines[r].indent:x(e)}style ${t.id} ${[...i].map(([e,t])=>`${e}:${t}`).join(`,`)}`;return r>=0?{edits:[i.size===0?C(e,r):w(e,r,[a])]}:i.size===0?{edits:[]}:{edits:[S(e,n.lastContentLine,[a])]}}case`setEdgeColor`:{let r=E(n,t.edgeId);if(!r)return null;let i=-1;for(let[t,a]of n.statements){if(a.kind!==`linkStyle`)continue;let n=/^linkStyle\s+(\d+)\b/.exec(e.lines[t].text.trim());if(n&&Number(n[1])===r.order){i=t;break}}if(t.value===null)return i===-1?{edits:[]}:{edits:[C(e,i)]};let a=`${i>=0?e.lines[i].indent:x(e)}linkStyle ${r.order} stroke:${t.value},stroke-width:2px`;return i>=0?{edits:[w(e,i,[a])]}:{edits:[S(e,n.lastContentLine,[a])]}}case`renameSubgraph`:{let r=n.subgraphs.find(e=>e.id===t.id);if(!r)return null;if(r.titleSpan)return{edits:[{start:r.titleSpan.start,end:r.titleSpan.end,text:t.title.replace(/[\]"]/g,``)}]};let i=e.lines[r.openLine];return{edits:[{start:i.end,end:i.end,text:` [${t.title.replace(/[\]"]/g,``)}]`}]}}}}var ae=[`participant`,`actor`,`boundary`,`control`,`entity`,`database`,`collections`,`queue`],oe=[{op:`->`,label:`solid line`},{op:`->>`,label:`solid arrow`},{op:`-->`,label:`dotted line`},{op:`-->>`,label:`dotted arrow`},{op:`-x`,label:`solid cross`},{op:`--x`,label:`dotted cross`},{op:`-)`,label:`solid async`},{op:`--)`,label:`dotted async`}],se=/^(.+?)(--?(?:>>|>|[x)]))([+-])?([^:+-][^:]*):(.*)$/,ce=/^(participant|actor)\s+(.+?)(?:\s+as\s+(.+?))?\s*(@\{.*\})?\s*;?\s*$/,le=/^[Nn]ote\s+(over|left of|right of)\s+([^:]+):(.*)$/,ue=/^(alt|opt|loop|par|critical|break|rect|box)\b/,de=/^(else|and|option)\b/,fe=/^(activate|deactivate)\s+(.+?)\s*;?\s*$/,pe=/^(title|accTitle|accDescr|links?|properties|create|destroy)\b/;function k(e,t,n){return{start:e.start+t,end:e.start+n}}function me(e){if(!e)return null;let t=/["']?type["']?\s*:\s*["'](\w+)["']/.exec(e);return t&&ae.includes(t[1])?t[1]:null}function he(e){let t=e.text,n=t.trim(),r=e.index,i=t.length-t.trimStart().length;if(n===`end`)return{kind:`end`,lineIndex:r,parts:[]};if(/^autonumber\b/.test(n))return{kind:`autonumber`,lineIndex:r,parts:[]};let a=ue.exec(n);if(a)return{kind:`blockOpen`,lineIndex:r,parts:[a[1]]};let o=de.exec(n);if(o)return{kind:`blockMid`,lineIndex:r,parts:[o[1]]};let s=fe.exec(n);if(s)return{kind:`activation`,lineIndex:r,parts:[s[1],s[2]]};let c=ce.exec(n);if(c){let n=c[1],a=c[2],o=c[3]??null,s=c[4]??null,l=i,u=t.indexOf(a,l+n.length),d=o?t.indexOf(o,u+a.length):-1,f=s?t.indexOf(s,d===-1?u+a.length:d):-1;return{kind:`participant`,lineIndex:r,keyword:n,keywordSpan:k(e,l,l+n.length),id:a,idSpan:k(e,u,u+a.length),alias:o,aliasSpan:o?k(e,d,d+o.length):null,attrsRaw:s,attrsSpan:s?k(e,f,f+s.length):null,ptype:me(s)??(n===`actor`?`actor`:`participant`)}}let l=le.exec(n);if(l){let a=l[1],o=l[2],s=i+n.indexOf(o,5),c=t.indexOf(`:`,s+o.length-1)+1;return{kind:`note`,lineIndex:r,placement:a,targets:o.split(`,`).map(e=>e.trim()).filter(Boolean),targetsSpan:k(e,s,s+o.trimEnd().length),text:t.slice(c).trim(),textSpan:k(e,c,t.length)}}let u=se.exec(n);if(u){let[,n,a,o,s]=u,c=n.trim(),l=s.trim();if(c&&l){let u=i+n.indexOf(c),d=i+n.length,f=i+n.length+a.length+ +!!o+s.indexOf(l),p=t.indexOf(`:`,f+l.length);return{kind:`message`,lineIndex:r,source:c,sourceSpan:k(e,u,u+c.length),op:a,opSpan:k(e,d,d+a.length),activation:o??null,target:l,targetSpan:k(e,f,f+l.length),text:t.slice(p+1).trim(),textSpan:k(e,p+1,t.length)}}}return pe.test(n)?{kind:`other`,lineIndex:r,parts:[]}:{kind:`unknown`,lineIndex:r,parts:[]}}function ge(e,t){let n=new Map,r=[],i=new Map,a={enabled:!1,lineIndex:null},o=t,s=t,c=e=>{let t=n.get(e);return t||(t={entityId:`participant:${e}`,id:e,label:e,ptype:`participant`,decl:null,order:n.size},n.set(e,t)),t};for(let n of e){if(n.kind!==`statement`||n.index===t){n.index===t&&(o=n.index);continue}let e=he(n);switch(i.set(n.index,e),o=n.index,e.kind){case`participant`:{let t=c(e.id);t.decl=e,t.ptype=e.ptype,e.alias&&(t.label=e.alias),s=e.lineIndex;break}case`message`:c(e.source),c(e.target),r.push({kind:`message`,entityId:`event:${e.lineIndex}`,lineIndex:e.lineIndex,stmt:e});break;case`note`:for(let t of e.targets)c(t);r.push({kind:`note`,entityId:`event:${e.lineIndex}`,lineIndex:e.lineIndex,stmt:e});break;case`autonumber`:a={enabled:!0,lineIndex:e.lineIndex};break;default:break}}return{headerLine:t,participants:[...n.values()],participantById:n,events:r,autonumber:a,statements:i,lastContentLine:o,lastDeclLine:s}}function _e(e,t,n){if(n.startsWith(`participant:`)){let r=e.participantById.get(n.slice(12));if(!r)return[];let i=[];if(r.decl){let e=t[r.decl.lineIndex];i.push({start:e.start+e.indent.length,end:e.end})}for(let t of e.events)t.kind===`message`?(t.stmt.source===r.id&&i.push(t.stmt.sourceSpan),t.stmt.target===r.id&&i.push(t.stmt.targetSpan)):t.stmt.targets.includes(r.id)&&i.push(t.stmt.targetsSpan);return i}if(n.startsWith(`event:`)){let r=e.events.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}return[]}function ve(e,t,n){for(let r of e.events){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end){if(r.kind===`message`){if(n>=r.stmt.sourceSpan.start&&n<=r.stmt.sourceSpan.end)return`participant:${r.stmt.source}`;if(n>=r.stmt.targetSpan.start&&n<=r.stmt.targetSpan.end)return`participant:${r.stmt.target}`}return r.entityId}}for(let r of e.participants)if(r.decl){let e=t[r.decl.lineIndex];if(n>=e.start&&n<=e.end)return r.entityId}return null}var ye={loop:`loop Repeat`,alt:`alt Condition`,opt:`opt Optional`,par:`par Parallel`,critical:`critical Required`,break:`break Break`,rect:`rect rgb(107, 114, 148, 0.25)`};function A(e,t){return e.events.find(e=>e.entityId===t)??null}function j(e){for(let t of e.lines)if(t.kind===`statement`&&t.index!==e.graph.headerLine&&t.text.trim()!==``)return t.indent;return` `}function M(e,t,n){let r=e.lines[t];return{start:r.end,end:r.end,text:n.map(e=>`
5
- ${e}`).join(``)}}function N(e,t){let n=e.lines[t];return n.end<e.code.length?{start:n.start,end:n.end+1,text:``}:n.start>0?{start:n.start-1,end:n.end,text:``}:{start:n.start,end:n.end,text:``}}function P(e,t){let{graph:n}=e;if(t){let r=A(n,t);if(r)return{lineIndex:r.lineIndex,indent:e.lines[r.lineIndex].indent}}if(t===null&&n.events.length>0){let t=n.events[0];return{lineIndex:t.lineIndex-1,indent:e.lines[t.lineIndex].indent}}let r=n.events[n.events.length-1];return r?{lineIndex:r.lineIndex,indent:e.lines[r.lineIndex].indent}:{lineIndex:n.lastContentLine,indent:j(e)}}function be(e){return e===`actor`?{keyword:`actor`,attrs:null}:e===`participant`?{keyword:`participant`,attrs:null}:{keyword:`participant`,attrs:`@{ "type" : "${e}" }`}}function xe(e,t){let n=new Set(e.participants.map(e=>e.id));if(t&&!n.has(t))return t;let r=1;for(;n.has(`P${r}`);)r++;return`P${r}`}function Se(e,t){let{graph:n,lines:r}=e;switch(t.type){case`seq.addParticipant`:{let r=xe(n,t.name),{keyword:i,attrs:a}=be(t.ptype??`participant`),o=`${j(e)}${i} ${r}${a||``}`;return{edits:[M(e,n.lastDeclLine,[o])],created:[`participant:${r}`]}}case`seq.renameParticipant`:{let e=n.participantById.get(t.id);if(!e)return null;let i=t.name.trim().replace(/[:;]/g,``);if(!i)return null;if(e.decl?.alias&&e.decl.aliasSpan)return{edits:[{start:e.decl.aliasSpan.start,end:e.decl.aliasSpan.end,text:i}]};let a=[];e.decl&&a.push({start:e.decl.idSpan.start,end:e.decl.idSpan.end,text:i});for(let e of n.events)if(e.kind===`message`)e.stmt.source===t.id&&a.push({...e.stmt.sourceSpan,text:i}),e.stmt.target===t.id&&a.push({...e.stmt.targetSpan,text:i});else if(e.stmt.targets.includes(t.id)){let n=e.stmt.targets.map(e=>e===t.id?i:e).join(`,`);a.push({start:e.stmt.targetsSpan.start,end:e.stmt.targetsSpan.end,text:n})}for(let[e,o]of n.statements)if(o.kind===`activation`&&o.parts[1]===t.id){let t=r[e],n=t.start+t.text.lastIndexOf(o.parts[1]);a.push({start:n,end:n+o.parts[1].length,text:i})}return{edits:a.map(e=>({start:e.start,end:e.end,text:e.text}))}}case`seq.setParticipantType`:{let r=n.participantById.get(t.id);if(!r)return null;let{keyword:i,attrs:a}=be(t.ptype);if(r.decl){let t=[{start:r.decl.keywordSpan.start,end:r.decl.keywordSpan.end,text:i}];if(r.decl.attrsSpan){let n=r.decl.attrsSpan.start,i=e.code[n-1]===` `&&!a?n-1:n;t.push({start:i,end:r.decl.attrsSpan.end,text:a||``})}else if(a){let e=r.decl.aliasSpan?r.decl.aliasSpan.end:r.decl.idSpan.end;t.push({start:e,end:e,text:a})}return{edits:t}}let o=`${j(e)}${i} ${t.id}${a||``}`;return{edits:[M(e,n.lastDeclLine,[o])]}}case`seq.deleteParticipant`:{let r=n.participantById.get(t.id);if(!r)return null;let i=new Set;r.decl&&i.add(r.decl.lineIndex);let a=[];for(let e of n.events)if(e.kind===`message`)(e.stmt.source===t.id||e.stmt.target===t.id)&&i.add(e.lineIndex);else if(e.stmt.targets.includes(t.id))if(e.stmt.targets.length===1)i.add(e.lineIndex);else{let n=e.stmt.targets.filter(e=>e!==t.id).join(`,`);a.push({start:e.stmt.targetsSpan.start,end:e.stmt.targetsSpan.end,text:n})}for(let[e,r]of n.statements)r.kind===`activation`&&r.parts[1]===t.id&&i.add(e);for(let t of i)a.push(N(e,t));return{edits:a}}case`seq.addMessage`:{let n=P(e,t.afterEvent),r=`${n.indent}${t.source}${t.op??`->>`}${t.target}: ${t.text??`message`}`,i=n.lineIndex+1;return{edits:[M(e,n.lineIndex,[r])],created:[`event:${i}`]}}case`seq.addNote`:{let n=P(e,t.afterEvent),r=`${n.indent}Note ${t.placement} ${t.participant}: ${t.text??`note`}`;return{edits:[M(e,n.lineIndex,[r])],created:[`event:${n.lineIndex+1}`]}}case`seq.setMessageOp`:{let e=A(n,t.eventId);return!e||e.kind!==`message`?null:{edits:[{start:e.stmt.opSpan.start,end:e.stmt.opSpan.end,text:t.op}]}}case`seq.reverseMessage`:{let e=A(n,t.eventId);return!e||e.kind!==`message`?null:{edits:[{start:e.stmt.sourceSpan.start,end:e.stmt.sourceSpan.end,text:e.stmt.target},{start:e.stmt.targetSpan.start,end:e.stmt.targetSpan.end,text:e.stmt.source}]}}case`seq.setEventText`:{let e=A(n,t.eventId);if(!e)return null;let r=` ${t.text.trim().replace(/[;]/g,``)}`,i=(e.kind,e.stmt.textSpan);return{edits:[{start:i.start,end:i.end,text:r}]}}case`seq.deleteEvent`:{let r=A(n,t.eventId);return r?{edits:[N(e,r.lineIndex)]}:null}case`seq.moveEvent`:{let r=A(n,t.eventId);if(!r||t.afterEvent===t.eventId)return null;let i=P(e,t.afterEvent);if(i.lineIndex===r.lineIndex||i.lineIndex===r.lineIndex-1)return{edits:[]};let a=e.lines[r.lineIndex],o=`${i.indent}${a.text.trim()}`,s=i.lineIndex<r.lineIndex?i.lineIndex+1:i.lineIndex;return{edits:[N(e,r.lineIndex),M(e,i.lineIndex,[o])],created:[`event:${s}`]}}case`seq.wrapInFragment`:{let e=A(n,t.eventId);if(!e)return null;let i=r[e.lineIndex],a=i.indent,o=i.text.trim(),s=`${a}${ye[t.kind]}
2
+ `,n);i===-1&&(i=e.length);let a=e.slice(n,i),o=/^[ \t]*/.exec(a)[0];if(t.push({index:r,kind:`statement`,text:a,start:n,end:i,indent:o}),r++,i===e.length)break;n=i+1}return t}function a(e){let t=-1,n=!1,r=!1,i=!1;for(let a of e){let e=a.text.trim();if(!i&&!r&&e===`---`)if(n){n=!1,r=!0,a.kind=`frontmatter`;continue}else{n=!0,a.kind=`frontmatter`;continue}if(n){a.kind=`frontmatter`;continue}if(e===``){a.kind=`blank`;continue}if(e.startsWith(`%%{`)){a.kind=`directive`;continue}if(e.startsWith(`%%`)){a.kind=`comment`;continue}if(t===-1){a.kind=`header`,t=a.index,i=!0;continue}a.kind=`statement`,i=!0}return{headerIndex:t}}function o(e,t){let n=[...t].sort((e,t)=>e.start-t.start);for(let e=1;e<n.length;e++)if(n[e].start<n[e-1].end)throw Error(`Overlapping text edits`);let r=``,i=0,a=[],o=0;for(let t of n)r+=e.slice(i,t.start),r+=t.text,a.push({start:t.start+o,end:t.start+o+t.text.length,text:e.slice(t.start,t.end)}),o+=t.text.length-(t.end-t.start),i=t.end;return r+=e.slice(i),{text:r,inverse:a}}function s(e,t){if(e===t)return null;let n=0,r=e.length,i=t.length,a=Math.min(r,i);for(;n<a&&e[n]===t[n];)n++;let o=r,s=i;for(;o>n&&s>n&&e[o-1]===t[s-1];)o--,s--;return{start:n,end:o,text:t.slice(n,s)}}function c(e,t){let n=e;for(let r of[...t].sort((e,t)=>e.start-t.start))r.end<=e?n+=r.text.length-(r.end-r.start):r.start<e&&(n=r.start+r.text.length);return n}var l=[{open:`(((`,close:[`)))`]},{open:`([`,close:[`])`]},{open:`[[`,close:[`]]`]},{open:`[(`,close:[`)]`]},{open:`[/`,close:[`/]`,`\\]`]},{open:`[\\`,close:[`\\]`,`/]`]},{open:`((`,close:[`))`]},{open:`{{`,close:[`}}`]},{open:`{`,close:[`}`]},{open:`(`,close:[`)`]},{open:`[`,close:[`]`]},{open:`>`,close:[`]`]}],u={"(((|)))":`doublecircle`,"((|))":`circle`,"([|])":`stadium`,"[[|]]":`subroutine`,"[(|)]":`cylinder`,"[/|/]":`lean_r`,"[/|\\]":`trap_b`,"[\\|\\]":`lean_l`,"[\\|/]":`trap_t`,"{{|}}":`hexagon`,"{|}":`diamond`,"(|)":`round`,"[|]":`rect`,">|]":`odd`},d={rect:{open:`[`,close:`]`},round:{open:`(`,close:`)`},stadium:{open:`([`,close:`])`},subroutine:{open:`[[`,close:`]]`},cylinder:{open:`[(`,close:`)]`},circle:{open:`((`,close:`))`},doublecircle:{open:`(((`,close:`)))`},diamond:{open:`{`,close:`}`},hexagon:{open:`{{`,close:`}}`},lean_r:{open:`[/`,close:`/]`},lean_l:{open:`[\\`,close:`\\]`},trap_t:{open:`[\\`,close:`/]`},trap_b:{open:`[/`,close:`\\]`},odd:{open:`>`,close:`]`}},f=/[A-Za-z0-9_.]/,p=class{text;pos=0;end;base;constructor(e){this.text=e.text,this.base=e.start;let t=this.text.length;for(;t>0&&/[;\s]/.test(this.text[t-1]);)t--;this.end=t;let n=0;for(;n<t&&/[ \t]/.test(this.text[n]);)n++;this.pos=n}skipWs(){for(;this.pos<this.end&&/[ \t]/.test(this.text[this.pos]);)this.pos++}atEnd(){return this.pos>=this.end}abs(e){return this.base+e}parseNodeRef(){let e=this.pos,t=this.pos;for(;this.pos<this.end&&f.test(this.text[this.pos]);)this.pos++;if(this.pos===t)return null;let n=this.text.slice(t,this.pos),r={start:this.abs(t),end:this.abs(this.pos)},i=null,a=null,o=null,s=!1;for(let e of l)if(this.text.startsWith(e.open,this.pos)){let t=this.pos+e.open.length,n=null,r,c,l;if(this.text[t]===`"`){let i=this.text.indexOf(`"`,t+1);if(i===-1||i>=this.end)return null;r=t+1,c=i,l=i+1,s=!0;for(let t of e.close)if(this.text.startsWith(t,l)){n=t;break}if(!n)return null;this.pos=l+n.length}else{let i=-1;for(let r of e.close){let e=this.text.indexOf(r,t);e!==-1&&e<this.end&&(i===-1||e<i)&&(i=e,n=r)}if(i===-1||!n)return null;r=t,c=i,this.pos=i+n.length}i=u[`${e.open}|${n}`]??`rect`,a=this.text.slice(r,c),o={start:this.abs(r),end:this.abs(c)};break}let c=null;if(this.text.startsWith(`@{`,this.pos)){let e=this.text.indexOf(`}`,this.pos+2);if(e===-1||e>=this.end+1)return null;c=this.text.slice(this.pos,e+1),this.pos=e+1}let d=[];for(;this.text.startsWith(`:::`,this.pos);){let e=this.pos+3,t=e;for(;e<this.end&&/[A-Za-z0-9_-]/.test(this.text[e]);)e++;if(e===t)return null;d.push(this.text.slice(t,e)),this.pos=e}return{id:n,span:{start:this.abs(e),end:this.abs(this.pos)},idSpan:r,shape:i,label:a,labelSpan:o,quoted:s,attrsRaw:c,classNames:d}}parseGroup(){let e=this.parseNodeRef();if(!e)return null;let t=[e];for(;;){let e=this.pos;if(this.skipWs(),this.text[this.pos]===`&`){this.pos++,this.skipWs();let e=this.parseNodeRef();if(!e)return null;t.push(e)}else{this.pos=e;break}}return t}parseEdge(){let e=this.pos,t=this.text.slice(this.pos,this.end),n=/^(?:(x|o|<)(?=[-=.~]))?(-{2,}|={2,}|-\.+-+|-\.+|~{3,})(>|x|o)?/.exec(t);if(!n)return null;let r=n[0];this.pos+=r.length;let i=n[1]??null,a=n[3]??null,o=n[2],s=null,c=null;if(!a&&/^(-{2}|={2}|-\.+-*)$/.test(o)&&this.text[this.pos]===` `){let e=o[0]===`=`?/\s(={2,}(>|x|o)?)/:o.includes(`.`)?/\s(\.*-*\.+->|\.+-+(>|x|o)?|\.->)/:/\s(-{2,}(>|x|o)?)/,t=this.text.slice(this.pos,this.end),n=e.exec(t);if(n&&n.index>=0){let e=this.pos+1,t=this.pos+n.index;if(t>e-1){s=this.text.slice(e,t),c={start:this.abs(e),end:this.abs(t)};let r=n[1];this.pos=this.pos+n.index+n[0].length,a=/[>xo]$/.test(r)?r[r.length-1]:null}}}let l=this.pos;if(this.skipWs(),this.text[this.pos]===`|`){let e=this.text.indexOf(`|`,this.pos+1);e!==-1&&e<this.end?(s=this.text.slice(this.pos+1,e),c={start:this.abs(this.pos+1),end:this.abs(e)},this.pos=e+1):this.pos=l}else this.pos=l;r=this.text.slice(e,this.pos);let u=o[0]===`=`?`thick`:o.includes(`.`)?`dotted`:o[0]===`~`?`invisible`:`solid`,d=e=>e===`>`?`arrow`:e===`x`?`cross`:e===`o`?`circle`:`open`;return{span:{start:this.abs(e),end:this.abs(this.pos)},raw:r,line:u,arrowEnd:d(a),arrowStart:i?i===`<`?`arrow`:d(i):`open`,label:s,labelSpan:c}}};function m(e){let t=e.text.trim(),n=e.index;if(t===`end`)return{kind:`end`,lineIndex:n,ids:[],idsSpan:null};let r=/^direction\s+(TB|TD|BT|RL|LR)\s*;?\s*$/.exec(t);if(r)return{kind:`direction`,lineIndex:n,ids:[r[1]],idsSpan:null};if(/^subgraph\s+(.*)$/.exec(t)){let t=new p(e);t.pos=e.text.indexOf(`subgraph`)+8,t.skipWs();let r=t.pos;for(;t.pos<t.end&&/[^\s[]/.test(e.text[t.pos]);)t.pos++;let i=e.text.slice(r,t.pos),a=null,o=null;if(t.skipWs(),e.text[t.pos]===`[`){let n=e.text.lastIndexOf(`]`);if(n>t.pos){let r=t.pos+1,i=n;e.text[r]===`"`&&e.text[i-1]===`"`&&(r++,i--),a=e.text.slice(r,i),o={start:e.start+r,end:e.start+i}}}return{kind:`subgraphOpen`,lineIndex:n,id:i,title:a,titleSpan:o}}if(/^classDef\b/.test(t))return{kind:`classDef`,lineIndex:n,ids:[],idsSpan:null};if(/^linkStyle\b/.test(t))return{kind:`linkStyle`,lineIndex:n,ids:[],idsSpan:null};let i=/^class\s+([A-Za-z0-9_.,\s]+?)\s+([A-Za-z0-9_-]+)\s*;?\s*$/.exec(t);if(i){let t=i[1].split(`,`).map(e=>e.trim()).filter(Boolean),r=e.text.indexOf(i[1]);return{kind:`classAssign`,lineIndex:n,ids:t,idsSpan:{start:e.start+r,end:e.start+r+i[1].length}}}let a=/^style\s+([A-Za-z0-9_.]+)\b/.exec(t);if(a)return{kind:`style`,lineIndex:n,ids:[a[1]],idsSpan:null};let o=/^click\s+([A-Za-z0-9_.]+)\b/.exec(t);if(o)return{kind:`click`,lineIndex:n,ids:[o[1]],idsSpan:null};let s=new p(e),c=[],l=[],u=s.parseGroup();if(u){c.push(u);let e=!0;for(;s.skipWs(),!s.atEnd();){let t=s.parseEdge();if(!t){e=!1;break}s.skipWs();let n=s.parseGroup();if(!n){e=!1;break}l.push(t),c.push(n)}if(e)return{kind:`chain`,lineIndex:n,groups:c,edges:l}}return{kind:`unknown`,lineIndex:n,ids:[],idsSpan:null}}function h(e){let t=/^(\s*)(flowchart|graph)(\s+)?(TB|TD|BT|RL|LR)?/.exec(e.text);if(!t)return{keyword:`flowchart`,direction:null,directionSpan:null};let n=t[2],r=t[4]??null,i=null;if(r){let a=e.start+t[1].length+n.length+(t[3]?.length??0);i={start:a,end:a+r.length}}return{keyword:n,direction:r,directionSpan:i}}function g(e,t){let n=h(e[t]),r=new Map,i=[],a=[],o=new Map,s=[],c=new Map,l=t,u=(e,t)=>{let n=r.get(e.id);n||(n={entityId:`node:${e.id}`,id:e.id,label:e.id,shape:`rect`,refs:[],primary:null,classes:[],subgraph:s.length?s[s.length-1].id:null},r.set(e.id,n)),n.refs.push({lineIndex:t,ref:e}),e.shape&&(n.primary={lineIndex:t,ref:e},n.shape=e.shape,e.label!==null&&(n.label=e.label));for(let t of e.classNames)n.classes.includes(t)||n.classes.push(t);return n};for(let n of e){if(n.index===t){l=n.index;continue}if(n.kind!==`statement`)continue;let e=m(n);if(o.set(n.index,e),l=n.index,e.kind===`subgraphOpen`){let t={entityId:`subgraph:${e.id}`,id:e.id,title:e.title,titleSpan:e.titleSpan,openLine:e.lineIndex,endLine:-1,parent:s.length?s[s.length-1].id:null};a.push(t),s.push(t)}else if(e.kind===`end`){let t=s.pop();t&&(t.endLine=e.lineIndex)}else if(e.kind===`chain`){for(let t of e.groups)for(let n of t)u(n,e.lineIndex);e.edges.forEach((t,n)=>{for(let r of e.groups[n])for(let a of e.groups[n+1]){let o=`${r.id}->${a.id}`,s=c.get(o)??0;c.set(o,s+1),i.push({entityId:`edge:${o}#${s}`,source:r.id,target:a.id,lineIndex:e.lineIndex,segIndex:n,seg:t,sourceRef:r,targetRef:a,label:t.label,order:i.length})}})}else if(e.kind===`classAssign`){let t=/\s([A-Za-z0-9_-]+)\s*;?\s*$/.exec(n.text)?.[1];if(t)for(let n of e.ids){let e=r.get(n);e&&!e.classes.includes(t)&&e.classes.push(t)}}}return{keyword:n.keyword,direction:n.direction,directionSpan:n.directionSpan,headerLine:t,nodes:[...r.values()],edges:i,subgraphs:a,nodeById:r,statements:o,lastContentLine:l}}function _(e,t,n){if(n.startsWith(`node:`)){let t=e.nodeById.get(n.slice(5));return t?t.refs.map(e=>e.ref.span):[]}if(n.startsWith(`edge:`)){let t=e.edges.find(e=>e.entityId===n);return t?[{start:t.sourceRef.span.start,end:t.targetRef.span.end}]:[]}if(n.startsWith(`subgraph:`)){let r=e.subgraphs.find(e=>e.entityId===n);if(!r)return[];let i=t[r.openLine];return[{start:i.start+i.indent.length,end:i.end}]}return[]}function v(e,t){for(let n of e.nodes)for(let e of n.refs)if(t>=e.ref.span.start&&t<=e.ref.span.end)return n.entityId;for(let n of e.edges)if(t>=n.seg.span.start&&t<=n.seg.span.end||t>=n.sourceRef.span.start&&t<=n.targetRef.span.end)return n.entityId;return null}var y=/[[\]{}()|<>\\/&%#;]|^\s|\s$/;function b(e,t){let n=e.replace(/"/g,`'`);return t||y.test(n)?`"${n}"`:n}function x(e,t,n=`open`){let r=t===`arrow`?`>`:t===`cross`?`x`:t===`circle`?`o`:``,i=n===`arrow`?`<`:n===`cross`?`x`:n===`circle`?`o`:``;switch(e){case`thick`:return i&&!r?`${i}==>`:r?`${i}==${r}`:`===`;case`dotted`:return i&&!r?`${i}-.->`:r?`${i}-.-${r}`:`-.-`;case`invisible`:return`~~~`;default:return i&&!r?`${i}-->`:r?`${i}--${r}`:`---`}}function S(e){for(let t of e.lines)if(t.kind===`statement`&&t.index!==e.graph.headerLine&&t.text.trim()!==``)return t.indent;return` `}function C(e,t,n){let r=e.lines[t];return{start:r.end,end:r.end,text:n.map(e=>`
3
+ ${e}`).join(``)}}function w(e,t){let n=e.lines[t];return n.end<e.code.length?{start:n.start,end:n.end+1,text:``}:n.start>0?{start:n.start-1,end:n.end,text:``}:{start:n.start,end:n.end,text:``}}function T(e,t,n){if(n.length===0)return w(e,t);let r=e.lines[t];return{start:r.start,end:r.end,text:n.join(`
4
+ `)}}function E(e,t){return e.code.slice(t.start,t.end)}function ee(e,t){let n=new Set(e.nodes.map(e=>e.id));if(t&&!n.has(t))return t;if(e.nodes.length>0&&e.nodes.every(e=>/^[A-Z]$/.test(e.id)))for(let e=0;e<26;e++){let t=String.fromCharCode(65+e);if(!n.has(t))return t}let r=1;for(;n.has(`n${r}`);)r++;return`n${r}`}function te(e,t){let n=e.lastContentLine,r=-1;for(let n of t){let t=e.nodeById.get(n);if(t)for(let e of t.refs)r=Math.max(r,e.lineIndex)}return r===-1?n:r}function ne(e,t,n,r){let i=e.lines[t],a=i.indent,o=[];n.edges.forEach((e,t)=>{for(let e of n.groups[t])for(let r of n.groups[t+1])o.push({a:e,b:r,segIndex:t})});let s=o.filter(e=>!(r.dropNodeId&&(e.a.id===r.dropNodeId||e.b.id===r.dropNodeId)||r.dropEdge&&e.segIndex===r.dropEdge.segIndex&&e.a.id===r.dropEdge.source&&e.b.id===r.dropEdge.target));if(s.length===o.length&&!r.dropNodeId)return[i.text];let c=new Set;for(let e of s)c.add(e.a),c.add(e.b);let l=[],u=``,d=null;for(let t of s){let r=E(e,n.edges[t.segIndex].span);d===t.a&&u?u+=` ${r} ${E(e,t.b.span)}`:(u&&l.push(a+u),u=`${E(e,t.a.span)} ${r} ${E(e,t.b.span)}`),d=t.b}u&&l.push(a+u);for(let i of n.groups)for(let n of i){if(n.id===r.dropNodeId||c.has(n))continue;let i=e.graph.nodeById.get(n.id);if(!i)continue;let o=i.refs.some(e=>e.ref!==n&&e.ref.shape),s=i.refs.some(e=>e.lineIndex!==t||e.ref!==n&&c.has(e.ref));(n.shape&&!o||!s&&!n.shape)&&l.push(a+E(e,n.span))}return l}function D(e,t){return e.edges.find(e=>e.entityId===t)??null}function O(e,t){let n=[];for(let[r,i]of e.graph.statements){if(i.kind!==`linkStyle`)continue;let a=e.lines[r],o=/^(\s*linkStyle\s+)(\d+)\b/.exec(a.text);if(!o)continue;let s=Number(o[2]),c=t(s);if(c===null)n.push(w(e,r));else if(c!==s){let e=a.start+o[1].length;n.push({start:e,end:e+o[2].length,text:String(c)})}}return n}function k(e,t){return e.nodeById.get(t)??null}function re(e,t,n,r){let i=D(t,n);if(!i)return null;let a=-1;for(let[n,r]of t.statements){if(r.kind!==`linkStyle`)continue;let t=/^linkStyle\s+(\d+)\b/.exec(e.lines[n].text.trim());if(t&&Number(t[1])===i.order){a=n;break}}let o=new Map;if(a>=0){let t=e.lines[a].text.trim().replace(/^linkStyle\s+\d+\s*/,``);for(let e of t.split(`,`)){let t=e.indexOf(`:`);t>0&&o.set(e.slice(0,t).trim(),e.slice(t+1).trim())}}for(let[e,t]of Object.entries(r))t===null?o.delete(e):o.set(e,t);if(o.size===0)return a===-1?{edits:[]}:{edits:[w(e,a)]};let s=`${a>=0?e.lines[a].indent:S(e)}linkStyle ${i.order} ${[...o].map(([e,t])=>`${e}:${t}`).join(`,`)}`;return a>=0?{edits:[T(e,a,[s])]}:{edits:[C(e,t.lastContentLine,[s])]}}function ie(e){let t=-1;for(let n of e.lines)if(n.kind===`frontmatter`)t=n.index;else if(t>=0)break;return t<0?0:e.lines[t].end+1}function ae(e,t){let n=/^\s*%%\{\s*init\s*:\s*(\{[\s\S]*?\})\s*\}%%\s*$/m.exec(e.code),r=`%%{init: {'flowchart': {'curve': '${t}'}}}%%`;if(!n){if(t===`basis`)return{edits:[]};let n=ie(e);return{edits:[{start:n,end:n,text:`${r}
5
+ `}]}}return{edits:[{start:n.index+n[0].search(/%%\{/),end:n.index+n[0].length,text:t===`basis`?``:r}]}}function oe(e,t){let{graph:n}=e;switch(t.type){case`addNode`:{let r=ee(n,t.id),i=t.shape??`rect`,a=t.label??r,{open:o,close:s}=d[i],c=`${S(e)}${r}${o}${b(a,!1)}${s}`;return{edits:[C(e,n.lastContentLine,[c])],created:[`node:${r}`]}}case`connect`:{let r=k(n,t.source),i=k(n,t.target);if(!r||!i)return null;let a=x(t.line??`solid`,t.arrowEnd??`arrow`),o=t.label?`|${t.label.replace(/\|/g,``)}|`:``,s=te(n,[t.source,t.target]),c=`${e.lines[s].kind===`statement`?e.lines[s].indent:S(e)}${t.source} ${a}${o} ${t.target}`,l=n.edges.filter(e=>e.source===t.source&&e.target===t.target).length,u=n.edges.filter(e=>e.lineIndex<=s).length;return{edits:[C(e,s,[c]),...O(e,e=>e>=u?e+1:e)],created:[`edge:${t.source}->${t.target}#${l}`]}}case`renameNode`:{let e=k(n,t.id);if(!e)return null;if(e.primary&&e.primary.ref.labelSpan){let n=e.primary.ref,r=n.labelSpan;return n.quoted?{edits:[{start:r.start,end:r.end,text:t.label.replace(/"/g,`'`)}]}:{edits:[{start:r.start,end:r.end,text:b(t.label,!1)}]}}let r=e.refs[0];if(!r)return null;let i=r.ref.idSpan.end;return{edits:[{start:i,end:i,text:`[${b(t.label,!1)}]`}]}}case`setNodeShape`:{let e=k(n,t.id);if(!e)return null;let{open:r,close:i}=d[t.shape];if(e.primary&&e.primary.ref.labelSpan){let t=e.primary.ref,n=d[t.shape],a=+!!t.quoted,o=t.idSpan.end,s=t.labelSpan.start-a,c=t.labelSpan.end+a,l=c+n.close.length;return{edits:[{start:o,end:s,text:r},{start:c,end:l,text:i}]}}let a=e.refs[0];if(!a)return null;let o=a.ref.idSpan.end;return{edits:[{start:o,end:o,text:`${r}${b(e.label,!1)}${i}`}]}}case`setEdgeLabel`:{let e=D(n,t.edgeId);if(!e)return null;let r=t.label.replace(/\|/g,``);if(e.seg.labelSpan){if(r===``){let t=x(e.seg.line,e.seg.arrowEnd,e.seg.arrowStart);return{edits:[{start:e.seg.span.start,end:e.seg.span.end,text:t}]}}return{edits:[{start:e.seg.labelSpan.start,end:e.seg.labelSpan.end,text:r}]}}return r===``?{edits:[]}:{edits:[{start:e.seg.span.end,end:e.seg.span.end,text:`|${r}|`}]}}case`setEdgeStyle`:{let e=D(n,t.edgeId);if(!e)return null;let r=t.line??e.seg.line,i=t.arrowEnd??e.seg.arrowEnd,a=t.arrowStart??e.seg.arrowStart;r===`invisible`&&(i!==`open`||a!==`open`)&&(r=`solid`);let o=x(r,i,a),s=e.seg.label===null?``:`|${e.seg.label.replace(/\|/g,``)}|`;return{edits:[{start:e.seg.span.start,end:e.seg.span.end,text:`${o}${s}`}]}}case`setDirection`:{if(n.directionSpan)return{edits:[{start:n.directionSpan.start,end:n.directionSpan.end,text:t.direction}]};let r=e.lines[n.headerLine],i=r.start+r.indent.length+n.keyword.length;return{edits:[{start:i,end:i,text:` ${t.direction}`}]}}case`deleteEdge`:{let r=D(n,t.edgeId);if(!r)return null;let i=n.statements.get(r.lineIndex);if(!i||i.kind!==`chain`)return null;let a=ne(e,r.lineIndex,i,{dropEdge:{segIndex:r.segIndex,source:r.source,target:r.target}}),o=r.order;return{edits:[T(e,r.lineIndex,a),...O(e,e=>e===o?null:e>o?e-1:e)]}}case`deleteNode`:{let r=k(n,t.id);if(!r)return null;let i=[],a=new Set;for(let e of r.refs)a.add(e.lineIndex);for(let r of a){let a=n.statements.get(r);if(!a||a.kind!==`chain`)continue;let o=ne(e,r,a,{dropNodeId:t.id});i.push(T(e,r,o))}for(let[r,a]of n.statements)if(a.kind===`classAssign`&&a.ids.includes(t.id)&&a.idsSpan){let n=a.ids.filter(e=>e!==t.id);n.length===0?i.push(w(e,r)):i.push({start:a.idsSpan.start,end:a.idsSpan.end,text:n.join(`,`)})}else (a.kind===`style`||a.kind===`click`)&&a.ids[0]===t.id&&i.push(w(e,r));let o=n.edges.filter(e=>e.source===t.id||e.target===t.id).map(e=>e.order).sort((e,t)=>e-t);return i.push(...O(e,e=>o.includes(e)?null:e-o.filter(t=>t<e).length)),{edits:i}}case`duplicateNode`:{let r=k(n,t.id);if(!r)return null;let i=ee(n),{open:a,close:o}=d[r.shape],s=r.classes.length?`:::${r.classes[0]}`:``,c=r.primary?.lineIndex??r.refs[0]?.lineIndex??n.lastContentLine;return{edits:[C(e,c,[`${e.lines[c].kind===`statement`?e.lines[c].indent:S(e)}${i}${a}${b(r.label,!1)}${o}${s}`])],created:[`node:${i}`]}}case`reverseEdge`:{let r=D(n,t.edgeId);if(!r)return null;let i=n.statements.get(r.lineIndex);if(!i||i.kind!==`chain`||i.groups.length!==2||i.groups[0].length!==1||i.groups[1].length!==1)return null;let a=E(e,r.sourceRef.span),o=E(e,r.targetRef.span);return{edits:[{start:r.sourceRef.span.start,end:r.sourceRef.span.end,text:o},{start:r.targetRef.span.start,end:r.targetRef.span.end,text:a}]}}case`setNodeColor`:{if(!k(n,t.id))return null;let r=-1;for(let[e,i]of n.statements)if(i.kind===`style`&&i.ids[0]===t.id){r=e;break}let i=new Map;if(r>=0){let n=e.lines[r].text.trim().replace(RegExp(`^style\\s+${t.id}\\s*`),``);for(let e of n.split(`,`)){let t=e.indexOf(`:`);t>0&&i.set(e.slice(0,t).trim(),e.slice(t+1).trim())}}t.value===null?i.delete(t.prop):i.set(t.prop,t.value),i.has(`stroke`)&&!i.has(`stroke-width`)&&i.set(`stroke-width`,`2px`),i.has(`stroke`)||i.delete(`stroke-width`);let a=`${r>=0?e.lines[r].indent:S(e)}style ${t.id} ${[...i].map(([e,t])=>`${e}:${t}`).join(`,`)}`;return r>=0?{edits:[i.size===0?w(e,r):T(e,r,[a])]}:i.size===0?{edits:[]}:{edits:[C(e,n.lastContentLine,[a])]}}case`setEdgeColor`:return re(e,n,t.edgeId,{stroke:t.value,"stroke-width":t.value===null?null:`2px`});case`setEdgeAnimation`:{if(t.value===`none`)return re(e,n,t.edgeId,{"stroke-dasharray":null,"animation-name":null,"animation-duration":null,"animation-timing-function":null,"animation-iteration-count":null});let r=t.value===`slow`?`2s`:`0.6s`;return re(e,n,t.edgeId,{"stroke-dasharray":`8`,"animation-name":`vsmr-flow`,"animation-duration":r,"animation-timing-function":`linear`,"animation-iteration-count":`infinite`})}case`setFlowCurve`:return ae(e,t.value);case`renameSubgraph`:{let r=n.subgraphs.find(e=>e.id===t.id);if(!r)return null;if(r.titleSpan)return{edits:[{start:r.titleSpan.start,end:r.titleSpan.end,text:t.title.replace(/[\]"]/g,``)}]};let i=e.lines[r.openLine];return{edits:[{start:i.end,end:i.end,text:` [${t.title.replace(/[\]"]/g,``)}]`}]}}}}var se=[`participant`,`actor`,`boundary`,`control`,`entity`,`database`,`collections`,`queue`],ce=[{op:`->`,label:`solid line`},{op:`->>`,label:`solid arrow`},{op:`-->`,label:`dotted line`},{op:`-->>`,label:`dotted arrow`},{op:`-x`,label:`solid cross`},{op:`--x`,label:`dotted cross`},{op:`-)`,label:`solid async`},{op:`--)`,label:`dotted async`}],le=/^(.+?)(--?(?:>>|>|[x)]))([+-])?([^:+-][^:]*):(.*)$/,ue=/^(participant|actor)\s+(.+?)(?:\s+as\s+(.+?))?\s*(@\{.*\})?\s*;?\s*$/,de=/^[Nn]ote\s+(over|left of|right of)\s+([^:]+):(.*)$/,fe=/^(alt|opt|loop|par|critical|break|rect|box)\b/,pe=/^(else|and|option)\b/,me=/^(activate|deactivate)\s+(.+?)\s*;?\s*$/,he=/^(title|accTitle|accDescr|links?|properties|create|destroy)\b/;function A(e,t,n){return{start:e.start+t,end:e.start+n}}function ge(e){if(!e)return null;let t=/["']?type["']?\s*:\s*["'](\w+)["']/.exec(e);return t&&se.includes(t[1])?t[1]:null}function _e(e){let t=e.text,n=t.trim(),r=e.index,i=t.length-t.trimStart().length;if(n===`end`)return{kind:`end`,lineIndex:r,parts:[]};if(/^autonumber\b/.test(n))return{kind:`autonumber`,lineIndex:r,parts:[]};let a=fe.exec(n);if(a)return{kind:`blockOpen`,lineIndex:r,parts:[a[1]]};let o=pe.exec(n);if(o)return{kind:`blockMid`,lineIndex:r,parts:[o[1]]};let s=me.exec(n);if(s)return{kind:`activation`,lineIndex:r,parts:[s[1],s[2]]};let c=ue.exec(n);if(c){let n=c[1],a=c[2],o=c[3]??null,s=c[4]??null,l=i,u=t.indexOf(a,l+n.length),d=o?t.indexOf(o,u+a.length):-1,f=s?t.indexOf(s,d===-1?u+a.length:d):-1;return{kind:`participant`,lineIndex:r,keyword:n,keywordSpan:A(e,l,l+n.length),id:a,idSpan:A(e,u,u+a.length),alias:o,aliasSpan:o?A(e,d,d+o.length):null,attrsRaw:s,attrsSpan:s?A(e,f,f+s.length):null,ptype:ge(s)??(n===`actor`?`actor`:`participant`)}}let l=de.exec(n);if(l){let a=l[1],o=l[2],s=i+n.indexOf(o,5),c=t.indexOf(`:`,s+o.length-1)+1;return{kind:`note`,lineIndex:r,placement:a,targets:o.split(`,`).map(e=>e.trim()).filter(Boolean),targetsSpan:A(e,s,s+o.trimEnd().length),text:t.slice(c).trim(),textSpan:A(e,c,t.length)}}let u=le.exec(n);if(u){let[,n,a,o,s]=u,c=n.trim(),l=s.trim();if(c&&l){let u=i+n.indexOf(c),d=i+n.length,f=i+n.length+a.length+ +!!o+s.indexOf(l),p=t.indexOf(`:`,f+l.length);return{kind:`message`,lineIndex:r,source:c,sourceSpan:A(e,u,u+c.length),op:a,opSpan:A(e,d,d+a.length),activation:o??null,target:l,targetSpan:A(e,f,f+l.length),text:t.slice(p+1).trim(),textSpan:A(e,p+1,t.length)}}}return he.test(n)?{kind:`other`,lineIndex:r,parts:[]}:{kind:`unknown`,lineIndex:r,parts:[]}}function ve(e,t){let n=new Map,r=[],i=new Map,a={enabled:!1,lineIndex:null},o=t,s=t,c=e=>{let t=n.get(e);return t||(t={entityId:`participant:${e}`,id:e,label:e,ptype:`participant`,decl:null,order:n.size},n.set(e,t)),t};for(let n of e){if(n.kind!==`statement`||n.index===t){n.index===t&&(o=n.index);continue}let e=_e(n);switch(i.set(n.index,e),o=n.index,e.kind){case`participant`:{let t=c(e.id);t.decl=e,t.ptype=e.ptype,e.alias&&(t.label=e.alias),s=e.lineIndex;break}case`message`:c(e.source),c(e.target),r.push({kind:`message`,entityId:`event:${e.lineIndex}`,lineIndex:e.lineIndex,stmt:e});break;case`note`:for(let t of e.targets)c(t);r.push({kind:`note`,entityId:`event:${e.lineIndex}`,lineIndex:e.lineIndex,stmt:e});break;case`autonumber`:a={enabled:!0,lineIndex:e.lineIndex};break;default:break}}return{headerLine:t,participants:[...n.values()],participantById:n,events:r,autonumber:a,statements:i,lastContentLine:o,lastDeclLine:s}}function ye(e,t,n){if(n.startsWith(`participant:`)){let r=e.participantById.get(n.slice(12));if(!r)return[];let i=[];if(r.decl){let e=t[r.decl.lineIndex];i.push({start:e.start+e.indent.length,end:e.end})}for(let t of e.events)t.kind===`message`?(t.stmt.source===r.id&&i.push(t.stmt.sourceSpan),t.stmt.target===r.id&&i.push(t.stmt.targetSpan)):t.stmt.targets.includes(r.id)&&i.push(t.stmt.targetsSpan);return i}if(n.startsWith(`event:`)){let r=e.events.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}return[]}function be(e,t,n){for(let r of e.events){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end){if(r.kind===`message`){if(n>=r.stmt.sourceSpan.start&&n<=r.stmt.sourceSpan.end)return`participant:${r.stmt.source}`;if(n>=r.stmt.targetSpan.start&&n<=r.stmt.targetSpan.end)return`participant:${r.stmt.target}`}return r.entityId}}for(let r of e.participants)if(r.decl){let e=t[r.decl.lineIndex];if(n>=e.start&&n<=e.end)return r.entityId}return null}var xe={loop:`loop Repeat`,alt:`alt Condition`,opt:`opt Optional`,par:`par Parallel`,critical:`critical Required`,break:`break Break`,rect:`rect rgb(107, 114, 148, 0.25)`};function j(e,t){return e.events.find(e=>e.entityId===t)??null}function M(e){for(let t of e.lines)if(t.kind===`statement`&&t.index!==e.graph.headerLine&&t.text.trim()!==``)return t.indent;return` `}function N(e,t,n){let r=e.lines[t];return{start:r.end,end:r.end,text:n.map(e=>`
6
+ ${e}`).join(``)}}function P(e,t){let n=e.lines[t];return n.end<e.code.length?{start:n.start,end:n.end+1,text:``}:n.start>0?{start:n.start-1,end:n.end,text:``}:{start:n.start,end:n.end,text:``}}function F(e,t){let{graph:n}=e;if(t){let r=j(n,t);if(r)return{lineIndex:r.lineIndex,indent:e.lines[r.lineIndex].indent}}if(t===null&&n.events.length>0){let t=n.events[0];return{lineIndex:t.lineIndex-1,indent:e.lines[t.lineIndex].indent}}let r=n.events[n.events.length-1];return r?{lineIndex:r.lineIndex,indent:e.lines[r.lineIndex].indent}:{lineIndex:n.lastContentLine,indent:M(e)}}function Se(e){return e===`actor`?{keyword:`actor`,attrs:null}:e===`participant`?{keyword:`participant`,attrs:null}:{keyword:`participant`,attrs:`@{ "type" : "${e}" }`}}function Ce(e,t){let n=new Set(e.participants.map(e=>e.id));if(t&&!n.has(t))return t;let r=1;for(;n.has(`P${r}`);)r++;return`P${r}`}function we(e,t){let{graph:n,lines:r}=e;switch(t.type){case`seq.addParticipant`:{let r=Ce(n,t.name),{keyword:i,attrs:a}=Se(t.ptype??`participant`),o=`${M(e)}${i} ${r}${a||``}`;return{edits:[N(e,n.lastDeclLine,[o])],created:[`participant:${r}`]}}case`seq.renameParticipant`:{let e=n.participantById.get(t.id);if(!e)return null;let i=t.name.trim().replace(/[:;]/g,``);if(!i)return null;if(e.decl?.alias&&e.decl.aliasSpan)return{edits:[{start:e.decl.aliasSpan.start,end:e.decl.aliasSpan.end,text:i}]};let a=[];e.decl&&a.push({start:e.decl.idSpan.start,end:e.decl.idSpan.end,text:i});for(let e of n.events)if(e.kind===`message`)e.stmt.source===t.id&&a.push({...e.stmt.sourceSpan,text:i}),e.stmt.target===t.id&&a.push({...e.stmt.targetSpan,text:i});else if(e.stmt.targets.includes(t.id)){let n=e.stmt.targets.map(e=>e===t.id?i:e).join(`,`);a.push({start:e.stmt.targetsSpan.start,end:e.stmt.targetsSpan.end,text:n})}for(let[e,o]of n.statements)if(o.kind===`activation`&&o.parts[1]===t.id){let t=r[e],n=t.start+t.text.lastIndexOf(o.parts[1]);a.push({start:n,end:n+o.parts[1].length,text:i})}return{edits:a.map(e=>({start:e.start,end:e.end,text:e.text}))}}case`seq.setParticipantType`:{let r=n.participantById.get(t.id);if(!r)return null;let{keyword:i,attrs:a}=Se(t.ptype);if(r.decl){let t=[{start:r.decl.keywordSpan.start,end:r.decl.keywordSpan.end,text:i}];if(r.decl.attrsSpan){let n=r.decl.attrsSpan.start,i=e.code[n-1]===` `&&!a?n-1:n;t.push({start:i,end:r.decl.attrsSpan.end,text:a||``})}else if(a){let e=r.decl.aliasSpan?r.decl.aliasSpan.end:r.decl.idSpan.end;t.push({start:e,end:e,text:a})}return{edits:t}}let o=`${M(e)}${i} ${t.id}${a||``}`;return{edits:[N(e,n.lastDeclLine,[o])]}}case`seq.deleteParticipant`:{let r=n.participantById.get(t.id);if(!r)return null;let i=new Set;r.decl&&i.add(r.decl.lineIndex);let a=[];for(let e of n.events)if(e.kind===`message`)(e.stmt.source===t.id||e.stmt.target===t.id)&&i.add(e.lineIndex);else if(e.stmt.targets.includes(t.id))if(e.stmt.targets.length===1)i.add(e.lineIndex);else{let n=e.stmt.targets.filter(e=>e!==t.id).join(`,`);a.push({start:e.stmt.targetsSpan.start,end:e.stmt.targetsSpan.end,text:n})}for(let[e,r]of n.statements)r.kind===`activation`&&r.parts[1]===t.id&&i.add(e);for(let t of i)a.push(P(e,t));return{edits:a}}case`seq.addMessage`:{let n=F(e,t.afterEvent),r=`${n.indent}${t.source}${t.op??`->>`}${t.target}: ${t.text??`message`}`,i=n.lineIndex+1;return{edits:[N(e,n.lineIndex,[r])],created:[`event:${i}`]}}case`seq.addNote`:{let n=F(e,t.afterEvent),r=`${n.indent}Note ${t.placement} ${t.participant}: ${t.text??`note`}`;return{edits:[N(e,n.lineIndex,[r])],created:[`event:${n.lineIndex+1}`]}}case`seq.setMessageOp`:{let e=j(n,t.eventId);return!e||e.kind!==`message`?null:{edits:[{start:e.stmt.opSpan.start,end:e.stmt.opSpan.end,text:t.op}]}}case`seq.reverseMessage`:{let e=j(n,t.eventId);return!e||e.kind!==`message`?null:{edits:[{start:e.stmt.sourceSpan.start,end:e.stmt.sourceSpan.end,text:e.stmt.target},{start:e.stmt.targetSpan.start,end:e.stmt.targetSpan.end,text:e.stmt.source}]}}case`seq.setEventText`:{let e=j(n,t.eventId);if(!e)return null;let r=` ${t.text.trim().replace(/[;]/g,``)}`,i=(e.kind,e.stmt.textSpan);return{edits:[{start:i.start,end:i.end,text:r}]}}case`seq.deleteEvent`:{let r=j(n,t.eventId);return r?{edits:[P(e,r.lineIndex)]}:null}case`seq.moveEvent`:{let r=j(n,t.eventId);if(!r||t.afterEvent===t.eventId)return null;let i=F(e,t.afterEvent);if(i.lineIndex===r.lineIndex||i.lineIndex===r.lineIndex-1)return{edits:[]};let a=e.lines[r.lineIndex],o=`${i.indent}${a.text.trim()}`,s=i.lineIndex<r.lineIndex?i.lineIndex+1:i.lineIndex;return{edits:[P(e,r.lineIndex),N(e,i.lineIndex,[o])],created:[`event:${s}`]}}case`seq.wrapInFragment`:{let e=j(n,t.eventId);if(!e)return null;let i=r[e.lineIndex],a=i.indent,o=i.text.trim(),s=`${a}${xe[t.kind]}
6
7
  ${a} ${o}
7
- ${a}end`;return{edits:[{start:i.start,end:i.end,text:s}],created:[`event:${e.lineIndex+1}`]}}case`seq.toggleAutonumber`:return n.autonumber.enabled&&n.autonumber.lineIndex!==null?{edits:[N(e,n.autonumber.lineIndex)]}:{edits:[M(e,n.headerLine,[`${j(e)}autonumber`])]}}}var Ce=String.raw`(?:\[\*\]|[\w-]+)`,we=new RegExp(String.raw`^(${Ce})\s*-->\s*(${Ce})\s*(?::(.*))?$`),Te=/^state\s+"([^"]*)"\s+as\s+([\w-]+)\s*(\{)?\s*$/,Ee=/^state\s+([\w-]+)\s*(<<\w+>>)?\s*(\{)?\s*$/,De=/^([\w-]+)\s*:\s*(.*)$/,Oe=/^note\s+(left|right)\s+of\s+[\w-]+\s*:/i,ke=/^note\s+(left|right)\s+of\s+[\w-]+\s*$/i;function F(e,t,n){return{start:e.start+t,end:e.start+n}}function I(e){let t=e.text,n=t.trim(),r=e.index,i=t.length-t.trimStart().length;if(n===`}`)return{kind:`blockClose`,lineIndex:r,parts:[]};if(n===`--`)return{kind:`divider`,lineIndex:r,parts:[]};let a=/^direction\s+(TB|TD|BT|RL|LR)\s*$/.exec(n);if(a)return{kind:`direction`,lineIndex:r,parts:[a[1]]};if(/^end\s+note$/i.test(n))return{kind:`noteBlockEnd`,lineIndex:r,parts:[]};if(Oe.test(n))return{kind:`note`,lineIndex:r,parts:[]};if(ke.test(n))return{kind:`noteBlockOpen`,lineIndex:r,parts:[]};if(/^classDef\b/.test(n))return{kind:`classDef`,lineIndex:r,parts:[]};if(/^style\b/.test(n))return{kind:`style`,lineIndex:r,parts:[]};let o=/^class\s+([\w-,\s]+)\s+([\w-]+)\s*$/.exec(n);if(o)return{kind:`classAssign`,lineIndex:r,parts:o[1].split(`,`).map(e=>e.trim())};let s=we.exec(n);if(s){let[,a,o,c]=s,l=i+n.indexOf(a),u=t.indexOf(`-->`,l+a.length),d=t.indexOf(o,u+3),f=null,p=null;if(c!==void 0){let n=t.indexOf(`:`,d+o.length);f=t.slice(n+1).trim(),p=F(e,n+1,t.length)}return{kind:`transition`,lineIndex:r,source:a,sourceSpan:F(e,l,l+a.length),target:o,targetSpan:F(e,d,d+o.length),label:f,labelSpan:p}}let c=Te.exec(n);if(c){let n=c[1],i=c[2],a=t.indexOf(`"`)+1,o=t.indexOf(i,a+n.length+1);return{kind:`decl`,lineIndex:r,id:i,idSpan:F(e,o,o+i.length),label:n,labelSpan:F(e,a,a+n.length),form:`quoted`,opensBlock:!!c[3],stereotype:null}}let l=Ee.exec(n);if(l){let n=l[1],a=t.indexOf(n,i+5);return{kind:`decl`,lineIndex:r,id:n,idSpan:F(e,a,a+n.length),label:null,labelSpan:null,form:`state`,opensBlock:!!l[3],stereotype:l[2]??null}}let u=De.exec(n);if(u){let n=u[1],a=i,o=t.indexOf(`:`,a+n.length);return{kind:`decl`,lineIndex:r,id:n,idSpan:F(e,a,a+n.length),label:u[2].trim(),labelSpan:F(e,o+1,t.length),form:`desc`,opensBlock:!1,stereotype:null}}return{kind:`unknown`,lineIndex:r,parts:[]}}function Ae(e,t){let n=new Map,r=[],i=new Map,a=[],o=new Map,s=null,c=t,l=!1,u=(e,t)=>{if(e===`[*]`)return null;let r=n.get(e);return r||(r={entityId:`state:${e}`,id:e,label:e,decl:null,declLines:[],refLines:[],firstRefLine:t,parent:a.length?a[a.length-1]:null,isComposite:!1,stereotype:null,typeDeclLine:null},n.set(e,r)),r};for(let n of e){if(n.kind!==`statement`||n.index===t){n.index===t&&(c=n.index);continue}if(l){I(n).kind===`noteBlockEnd`&&(l=!1),i.set(n.index,{kind:`unknown`,lineIndex:n.index,parts:[]}),c=n.index;continue}let e=I(n);switch(i.set(n.index,e),c=n.index,e.kind){case`noteBlockOpen`:l=!0;break;case`decl`:{let t=u(e.id,e.lineIndex);t&&(t.declLines.push(e.lineIndex),e.label!==null&&(t.decl=e,t.label=e.label),e.form===`state`&&(t.typeDeclLine=e.lineIndex,e.stereotype&&(t.stereotype=e.stereotype.replace(/[<>]/g,``))),e.opensBlock&&(t.isComposite=!0,a.push(e.id)));break}case`blockClose`:a.pop();break;case`transition`:{let t=u(e.source,e.lineIndex),n=u(e.target,e.lineIndex);t?.refLines.push(e.lineIndex),n?.refLines.push(e.lineIndex);let i=`${e.source}->${e.target}`,a=o.get(i)??0;o.set(i,a+1),r.push({entityId:`trans:${i}#${a}`,source:e.source,target:e.target,lineIndex:e.lineIndex,stmt:e,label:e.label,order:r.length});break}case`direction`:s={value:e.parts[0],lineIndex:e.lineIndex};break;default:break}}return{headerLine:t,states:[...n.values()],stateById:n,transitions:r,statements:i,direction:s,lastContentLine:c}}function je(e,t,n){if(n.startsWith(`state:`)){let r=e.stateById.get(n.slice(6));if(!r)return[];let i=[];for(let e of r.declLines){let n=t[e];i.push({start:n.start+n.indent.length,end:n.end})}for(let t of e.transitions)t.source===r.id&&i.push(t.stmt.sourceSpan),t.target===r.id&&i.push(t.stmt.targetSpan);return i}if(n.startsWith(`trans:`)){let r=e.transitions.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}return[]}function Me(e,t,n){for(let r of e.transitions){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end)return n>=r.stmt.sourceSpan.start&&n<=r.stmt.sourceSpan.end&&r.source!==`[*]`?`state:${r.source}`:n>=r.stmt.targetSpan.start&&n<=r.stmt.targetSpan.end&&r.target!==`[*]`?`state:${r.target}`:r.entityId}for(let r of e.states)for(let e of r.declLines){let i=t[e];if(n>=i.start&&n<=i.end)return r.entityId}return null}function L(e){for(let t of e.lines)if(t.kind===`statement`&&t.index!==e.graph.headerLine&&t.text.trim()!==``)return t.indent;return` `}function R(e,t,n){let r=e.lines[t];return{start:r.end,end:r.end,text:n.map(e=>`
8
- ${e}`).join(``)}}function Ne(e,t){let n=e.lines[t];return n.end<e.code.length?{start:n.start,end:n.end+1,text:``}:n.start>0?{start:n.start-1,end:n.end,text:``}:{start:n.start,end:n.end,text:``}}function z(e,t){return e.transitions.find(e=>e.entityId===t)??null}function Pe(e,t){let n=new Set(e.states.map(e=>e.id));if(t&&!n.has(t))return t;let r=1;for(;n.has(`s${r}`);)r++;return`s${r}`}function B(e){return e.trim().replace(/[:{}]/g,``)}function Fe(e,t){let{graph:n,lines:r}=e;switch(t.type){case`st.addState`:{let r=Pe(n,t.id),i=t.label?B(t.label):null,a=i?`${L(e)}${r}: ${i}`:`${L(e)}state ${r}`;return{edits:[R(e,n.lastContentLine,[a])],created:[`state:${r}`]}}case`st.connect`:{if(t.source!==`[*]`&&!n.stateById.has(t.source)||t.target!==`[*]`&&!n.stateById.has(t.target))return null;let i=n.lastContentLine,a=-1;for(let e of[t.source,t.target]){let t=n.stateById.get(e);if(t)for(let e of[...t.declLines,...t.refLines])a=Math.max(a,e)}a>=0&&(i=a);let o=r[i].kind===`statement`?r[i].indent:L(e),s=t.label?`: ${B(t.label)}`:``,c=n.transitions.filter(e=>e.source===t.source&&e.target===t.target).length;return{edits:[R(e,i,[`${o}${t.source} --> ${t.target}${s}`])],created:[`trans:${t.source}->${t.target}#${c}`]}}case`st.setStateType`:{let i=n.stateById.get(t.id);if(!i||i.isComposite)return null;let a=t.stype===`state`?``:` <<${t.stype}>>`;if(i.typeDeclLine!==null){let e=r[i.typeDeclLine];return{edits:[{start:e.start,end:e.end,text:`${e.indent}state ${i.id}${a}`}]}}return t.stype===`state`?{edits:[]}:{edits:[R(e,n.headerLine,[`${L(e)}state ${i.id}${a}`])]}}case`st.addStateNote`:{let i=n.stateById.get(t.id);if(!i)return null;let a=`${r[i.firstRefLine].indent}note ${t.side} of ${i.id}: ${B(t.text??`note`)}`;return{edits:[R(e,i.firstRefLine,[a])]}}case`st.reverseTransition`:{let e=z(n,t.transId);return e?{edits:[{start:e.stmt.sourceSpan.start,end:e.stmt.sourceSpan.end,text:e.target},{start:e.stmt.targetSpan.start,end:e.stmt.targetSpan.end,text:e.source}]}:null}case`st.moveToComposite`:{let r=n.stateById.get(t.id);if(!r||r.isComposite||r.parent)return null;let i=new Set(n.states.map(e=>e.id)),a=t.name?.replace(/[^\w-]/g,``)||``;if(!a||i.has(a)){let e=1;for(;i.has(`Composite${e}`);)e++;a=`Composite${e}`}let o=L(e);return{edits:[R(e,n.headerLine,[`${o}state ${a} {`,`${o} ${r.id}`,`${o}}`])],created:[`state:${a}`]}}case`st.setStateLabel`:{let i=n.stateById.get(t.id);if(!i)return null;let a=B(t.label);if(!a)return null;if(i.decl?.labelSpan){let e=i.decl.form===`quoted`?a.replace(/"/g,`'`):` ${a}`;return{edits:[{start:i.decl.labelSpan.start,end:i.decl.labelSpan.end,text:e}]}}let o=r[i.firstRefLine];return{edits:[R(e,i.firstRefLine,[`${o.indent}${i.id}: ${a}`])]}}case`st.setTransitionLabel`:{let e=z(n,t.transId);if(!e)return null;let i=B(t.label);return e.stmt.labelSpan?i?{edits:[{start:e.stmt.labelSpan.start,end:e.stmt.labelSpan.end,text:` ${i}`}]}:{edits:[{start:e.stmt.targetSpan.end,end:r[e.lineIndex].end,text:``}]}:i?{edits:[{start:e.stmt.targetSpan.end,end:e.stmt.targetSpan.end,text:`: ${i}`}]}:{edits:[]}}case`st.deleteTransition`:{let r=z(n,t.transId);return r?{edits:[Ne(e,r.lineIndex)]}:null}case`st.deleteState`:{let r=n.stateById.get(t.id);if(!r||r.isComposite)return null;let i=new Set(r.declLines);for(let e of n.transitions)(e.source===r.id||e.target===r.id)&&i.add(e.lineIndex);return{edits:[...i].map(t=>Ne(e,t))}}case`st.setDirection`:if(n.direction){let e=r[n.direction.lineIndex];return{edits:[{start:e.start,end:e.end,text:`${e.indent}direction ${t.direction}`}]}}return{edits:[R(e,n.headerLine,[`${L(e)}direction ${t.direction}`])]}}}var Ie=[`<|--`,`--|>`,`<|..`,`..|>`,`*--`,`--*`,`o--`,`--o`,`<--`,`-->`,`<..`,`..>`,`--`,`..`],Le=String.raw`[\w.~]+`,Re=Ie.map(e=>e.replace(/[|*.]/g,e=>`\\${e}`)).join(`|`),ze=new RegExp(String.raw`^(${Le})\s*(?:"([^"]*)"\s*)?(${Re})\s*(?:"([^"]*)"\s*)?(${Le})\s*(?::\s*(.*))?$`),Be=/^class\s+([\w.~]+)(?:\["([^"]*)"\])?\s*(\{)?\s*$/,Ve=/^([\w.~]+)\s*:\s*(.+)$/;function V(e,t,n){return{start:e.start+t,end:e.start+n}}function He(e,t){let n=e.text,r=n.trim(),i=e.index,a=n.length-n.trimStart().length;if(t!==null)return r===`}`?{kind:`blockClose`,lineIndex:i,parts:[]}:/^<<\w+>>$/.test(r)?{kind:`annotation`,lineIndex:i,parts:[r]}:{kind:`member`,lineIndex:i,classId:null,text:r,textSpan:V(e,a,n.length)};if(r===`}`)return{kind:`blockClose`,lineIndex:i,parts:[]};if(/^direction\s+(TB|TD|BT|RL|LR)\s*$/.test(r))return{kind:`direction`,lineIndex:i,parts:[r.split(/\s+/)[1]]};if(/^note\b/i.test(r))return{kind:`note`,lineIndex:i,parts:[]};if(/^(classDef|style|cssClass|click|callback|link|namespace)\b/.test(r))return{kind:`passthrough`,lineIndex:i,parts:[]};let o=/^<<(\w+)>>\s+([\w.~]+)$/.exec(r);if(o)return{kind:`annotation`,lineIndex:i,parts:[o[1],o[2]]};let s=Be.exec(r);if(s){let t=s[1],r=n.indexOf(t,a+5),o=null,c=null;if(s[2]!==void 0){let i=n.indexOf(`"`,r+t.length)+1;o=s[2],c=V(e,i,i+s[2].length)}return{kind:`classDecl`,lineIndex:i,id:t,idSpan:V(e,r,r+t.length),label:o,labelSpan:c,opensBlock:!!s[3]}}let c=ze.exec(r);if(c){let[,t,o,s,l,u,d]=c,f=a+r.indexOf(t),p=null,m=f+t.length;if(o!==void 0){let t=n.indexOf(`"${o}"`,m);p=V(e,t+1,t+1+o.length),m=t+o.length+2}let h=n.indexOf(s,m),g=null;if(m=h+s.length,l!==void 0){let t=n.indexOf(`"${l}"`,m);g=V(e,t+1,t+1+l.length),m=t+l.length+2}let _=n.indexOf(u,m),v=null,ee=null;if(d!==void 0){let t=n.indexOf(`:`,_+u.length);v=n.slice(t+1).trim(),ee=V(e,t+1,n.length)}return{kind:`relation`,lineIndex:i,source:t,sourceSpan:V(e,f,f+t.length),target:u,targetSpan:V(e,_,_+u.length),op:s,opSpan:V(e,h,h+s.length),label:v,labelSpan:ee,sourceCard:o??null,sourceCardSpan:p,targetCard:l??null,targetCardSpan:g}}let l=Ve.exec(r);if(l){let t=n.indexOf(`:`,a+l[1].length);return{kind:`member`,lineIndex:i,classId:l[1],text:l[2].trim(),textSpan:V(e,t+1,n.length)}}return{kind:`unknown`,lineIndex:i,parts:[]}}function Ue(e,t){let n=new Map,r=[],i=new Map,a=new Map,o=null,s=t,c=null,l=(e,t)=>{let r=n.get(e);return r||(r={entityId:`class:${e}`,id:e,label:e,decl:null,block:null,members:[],extraLines:[],refLines:[],firstRefLine:t},n.set(e,r)),r};for(let u of e){if(u.kind!==`statement`||u.index===t){u.index===t&&(s=u.index);continue}let e=He(u,c);switch(i.set(u.index,e),s=u.index,e.kind){case`classDecl`:{let t=l(e.id,e.lineIndex);t.decl=e,e.label!==null&&(t.label=e.label),t.refLines.push(e.lineIndex),e.opensBlock&&(t.block={open:e.lineIndex,close:-1},c=e.id);break}case`blockClose`:if(c){let t=n.get(c);t?.block&&(t.block.close=e.lineIndex),c=null}break;case`member`:{let t=e.classId??c;if(t){let n=l(t,e.lineIndex);n.members.push({lineIndex:e.lineIndex,text:e.text,textSpan:e.textSpan}),e.classId&&n.extraLines.push(e.lineIndex)}break}case`annotation`:e.parts.length===2&&l(e.parts[1],e.lineIndex).extraLines.push(e.lineIndex);break;case`relation`:{let t=l(e.source,e.lineIndex),n=l(e.target,e.lineIndex);t.refLines.push(e.lineIndex),n.refLines.push(e.lineIndex);let i=`${e.source}->${e.target}`,o=a.get(i)??0;a.set(i,o+1),r.push({entityId:`rel:${i}#${o}`,source:e.source,target:e.target,lineIndex:e.lineIndex,stmt:e,label:e.label,order:r.length});break}case`direction`:o={value:e.parts[0],lineIndex:e.lineIndex};break;default:break}}return{headerLine:t,classes:[...n.values()],classById:n,relations:r,statements:i,direction:o,lastContentLine:s}}function We(e,t,n){if(n.startsWith(`class:`)){let r=e.classById.get(n.slice(6));if(!r)return[];let i=[];if(r.decl){let e=t[r.decl.lineIndex];i.push({start:e.start+e.indent.length,end:e.end})}for(let t of e.relations)t.source===r.id&&i.push(t.stmt.sourceSpan),t.target===r.id&&i.push(t.stmt.targetSpan);return i}if(n.startsWith(`rel:`)){let r=e.relations.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}return[]}function Ge(e,t,n){for(let r of e.relations){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end)return n>=r.stmt.sourceSpan.start&&n<=r.stmt.sourceSpan.end?`class:${r.source}`:n>=r.stmt.targetSpan.start&&n<=r.stmt.targetSpan.end?`class:${r.target}`:r.entityId}for(let r of e.classes){let e=[...r.decl?[r.decl.lineIndex]:[],...r.members.map(e=>e.lineIndex),...r.extraLines];for(let i of e){let e=t[i];if(n>=e.start&&n<=e.end)return r.entityId}}return null}function H(e){for(let t of e.lines)if(t.kind===`statement`&&t.index!==e.graph.headerLine&&t.text.trim()!==``)return t.indent;return` `}function U(e,t,n){let r=e.lines[t];return{start:r.end,end:r.end,text:n.map(e=>`
9
- ${e}`).join(``)}}function W(e,t){let n=e.lines[t];return n.end<e.code.length?{start:n.start,end:n.end+1,text:``}:n.start>0?{start:n.start-1,end:n.end,text:``}:{start:n.start,end:n.end,text:``}}function G(e,t){return e.relations.find(e=>e.entityId===t)??null}function Ke(e,t){let n=new Set(e.classes.map(e=>e.id));if(t&&!n.has(t))return t;let r=1;for(;n.has(`Class${r}`);)r++;return`Class${r}`}function K(e){return e.trim().replace(/[{}]/g,``)}function qe(e,t){let{graph:n,lines:r}=e;switch(t.type){case`cl.addClass`:{let r=Ke(n,t.name?.replace(/[^\w.~]/g,``)),i=H(e);return{edits:[U(e,n.lastContentLine,[`${i}class ${r} {`,`${i}}`])],created:[`class:${r}`]}}case`cl.connect`:{if(!n.classById.has(t.source)||!n.classById.has(t.target))return null;let i=n.lastContentLine,a=-1;for(let e of[t.source,t.target]){let t=n.classById.get(e);if(t)for(let e of t.refLines)a=Math.max(a,t.block&&e===t.block.open?t.block.close:e)}a>=0&&(i=a);let o=r[i].kind===`statement`?r[i].indent:H(e),s=t.label?` : ${K(t.label)}`:``,c=n.relations.filter(e=>e.source===t.source&&e.target===t.target).length;return{edits:[U(e,i,[`${o}${t.source} ${t.op??`-->`} ${t.target}${s}`])],created:[`rel:${t.source}->${t.target}#${c}`]}}case`cl.renameClass`:{let e=n.classById.get(t.id);if(!e)return null;let i=t.name.trim().replace(/[^\w.~]/g,``);if(!i||n.classById.has(i))return null;let a=[];e.decl&&a.push({start:e.decl.idSpan.start,end:e.decl.idSpan.end,text:i});for(let e of n.relations)e.source===t.id&&a.push({start:e.stmt.sourceSpan.start,end:e.stmt.sourceSpan.end,text:i}),e.target===t.id&&a.push({start:e.stmt.targetSpan.start,end:e.stmt.targetSpan.end,text:i});for(let n of e.extraLines){let e=r[n],o=e.start+e.text.indexOf(t.id);o>=e.start&&a.push({start:o,end:o+t.id.length,text:i})}return{edits:a}}case`cl.setRelationType`:{let e=G(n,t.relId);return e?{edits:[{start:e.stmt.opSpan.start,end:e.stmt.opSpan.end,text:t.op}]}:null}case`cl.setRelationLabel`:{let e=G(n,t.relId);if(!e)return null;let i=K(t.label);return e.stmt.labelSpan?i?{edits:[{start:e.stmt.labelSpan.start,end:e.stmt.labelSpan.end,text:` ${i}`}]}:{edits:[{start:e.stmt.targetSpan.end,end:r[e.lineIndex].end,text:``}]}:i?{edits:[{start:e.stmt.targetSpan.end,end:e.stmt.targetSpan.end,text:` : ${i}`}]}:{edits:[]}}case`cl.reverseRelation`:{let e=G(n,t.relId);return e?{edits:[{start:e.stmt.sourceSpan.start,end:e.stmt.sourceSpan.end,text:e.target},{start:e.stmt.targetSpan.start,end:e.stmt.targetSpan.end,text:e.source}]}:null}case`cl.addMember`:{let i=n.classById.get(t.id);if(!i)return null;let a=K(t.text??`+attribute`);if(i.block&&i.block.close>=0){let t=r[i.block.open],n=i.members.length?r[i.members[i.members.length-1].lineIndex].indent:`${t.indent} `;return{edits:[U(e,i.members.length?i.members[i.members.length-1].lineIndex:i.block.open,[`${n}${a}`])]}}let o=i.decl?.lineIndex??i.firstRefLine,s=r[o];return{edits:[U(e,o,[`${s.indent}${i.id} : ${a}`])]}}case`cl.setMemberText`:{let r=n.classById.get(t.id);if(!r)return null;let i=r.members.find(e=>e.lineIndex===t.memberLine);if(!i)return null;let a=K(t.text);if(!a)return{edits:[W(e,i.lineIndex)]};let o=e.code.slice(i.textSpan.start-1,i.textSpan.start)===`:`?` `:``;return{edits:[{start:i.textSpan.start,end:i.textSpan.end,text:`${o}${a}`}]}}case`cl.deleteMember`:{let r=n.classById.get(t.id);return!r||!r.members.some(e=>e.lineIndex===t.memberLine)?null:{edits:[W(e,t.memberLine)]}}case`cl.deleteClass`:{let r=n.classById.get(t.id);if(!r)return null;let i=new Set;if(r.decl&&i.add(r.decl.lineIndex),r.block&&r.block.close>=0)for(let e=r.block.open;e<=r.block.close;e++)i.add(e);for(let e of r.extraLines)i.add(e);for(let e of r.members)i.add(e.lineIndex);for(let e of n.relations)(e.source===r.id||e.target===r.id)&&i.add(e.lineIndex);return{edits:[...i].map(t=>W(e,t))}}case`cl.deleteRelation`:{let r=G(n,t.relId);return r?{edits:[W(e,r.lineIndex)]}:null}case`cl.setAnnotation`:{let i=n.classById.get(t.id);if(!i)return null;let a=t.annotation?.replace(/[<>\s]/g,``)??null,o=-1;for(let[e,r]of n.statements)if(r.kind===`annotation`&&r.parts[1]===t.id){o=e;break}if(o>=0){if(!a)return{edits:[W(e,o)]};let n=r[o];return{edits:[{start:n.start,end:n.end,text:`${n.indent}<<${a}>> ${t.id}`}]}}if(!a)return{edits:[]};let s=i.decl?.lineIndex??i.firstRefLine,c=r[s];return{edits:[U(e,s,[`${c.indent}<<${a}>> ${t.id}`])]}}case`cl.addNoteFor`:{if(!n.classById.get(t.id))return null;let r=(t.text??`note`).replace(/"/g,`'`);return{edits:[U(e,n.lastContentLine,[`${H(e)}note for ${t.id} "${r}"`])]}}case`cl.setCardinality`:{let e=G(n,t.relId);if(!e)return null;let r=t.value?.replace(/"/g,``).trim()??null,i=t.side===`source`?e.stmt.sourceCardSpan:e.stmt.targetCardSpan;return i?r===null||r===``?{edits:[{start:i.start-2,end:i.end+1,text:``}]}:{edits:[{start:i.start,end:i.end,text:r}]}:r===null||r===``?{edits:[]}:t.side===`source`?{edits:[{start:e.stmt.sourceSpan.end,end:e.stmt.sourceSpan.end,text:` "${r}"`}]}:{edits:[{start:e.stmt.targetSpan.start,end:e.stmt.targetSpan.start,text:`"${r}" `}]}}case`cl.setDirection`:if(n.direction){let e=r[n.direction.lineIndex];return{edits:[{start:e.start,end:e.end,text:`${e.indent}direction ${t.direction}`}]}}return{edits:[U(e,n.headerLine,[`${H(e)}direction ${t.direction}`])]}}}var Je=String.raw`[\w-]+`,Ye=new RegExp(String.raw`^(${Je})\s*([|}o]{2})(--|\.\.)([o|{]{2})\s*(${Je})\s*:\s*(.*)$`),Xe=new RegExp(String.raw`^(${Je})(\[[^\]]*\])?\s*(\{)?\s*$`);function q(e,t,n){return{start:e.start+t,end:e.start+n}}function Ze(e,t){let n=e.text,r=n.trim(),i=e.index,a=n.length-n.trimStart().length;if(r===`}`)return{kind:`blockClose`,lineIndex:i,parts:[]};if(t)return{kind:`attribute`,lineIndex:i,text:r,textSpan:q(e,a,n.length)};if(/^(direction|style|classDef|class)\b/.test(r))return{kind:`passthrough`,lineIndex:i,parts:[]};let o=Ye.exec(r);if(o){let[,t,r,s,c,l]=o,u=a,d=n.indexOf(r,u+t.length),f=d+r.length,p=f+s.length,m=n.indexOf(l,p+c.length),h=n.indexOf(`:`,m+l.length);return{kind:`relation`,lineIndex:i,source:t,sourceSpan:q(e,u,u+t.length),target:l,targetSpan:q(e,m,m+l.length),leftCard:r,leftCardSpan:q(e,d,d+r.length),rightCard:c,rightCardSpan:q(e,p,p+c.length),line:s,lineSpan:q(e,f,f+s.length),label:n.slice(h+1).trim(),labelSpan:q(e,h+1,n.length)}}let s=Xe.exec(r);return s?{kind:`entityDecl`,lineIndex:i,id:s[1],idSpan:q(e,a,a+s[1].length),alias:s[2]?s[2].slice(1,-1):null,opensBlock:!!s[3]}:{kind:`unknown`,lineIndex:i,parts:[]}}function Qe(e,t){let n=new Map,r=[],i=new Map,a=new Map,o=t,s=null,c=(e,t)=>{let r=n.get(e);return r||(r={entityId:`entity:${e}`,id:e,label:e,decl:null,block:null,attributes:[],refLines:[],firstRefLine:t},n.set(e,r)),r};for(let l of e){if(l.kind!==`statement`||l.index===t){l.index===t&&(o=l.index);continue}let e=Ze(l,s!==null);switch(i.set(l.index,e),o=l.index,e.kind){case`entityDecl`:{let t=c(e.id,e.lineIndex);t.decl=e,e.alias&&(t.label=e.alias),t.refLines.push(e.lineIndex),e.opensBlock&&(t.block={open:e.lineIndex,close:-1},s=e.id);break}case`blockClose`:if(s){let t=n.get(s);t?.block&&(t.block.close=e.lineIndex),s=null}break;case`attribute`:s&&c(s,e.lineIndex).attributes.push({lineIndex:e.lineIndex,text:e.text,textSpan:e.textSpan});break;case`relation`:{let t=c(e.source,e.lineIndex),n=c(e.target,e.lineIndex);t.refLines.push(e.lineIndex),n.refLines.push(e.lineIndex);let i=`${e.source}->${e.target}`,o=a.get(i)??0;a.set(i,o+1),r.push({entityId:`erel:${i}#${o}`,source:e.source,target:e.target,lineIndex:e.lineIndex,stmt:e,label:e.label,order:r.length});break}default:break}}return{headerLine:t,entities:[...n.values()],entityById:n,relations:r,statements:i,lastContentLine:o}}function $e(e,t,n){if(n.startsWith(`entity:`)){let r=e.entityById.get(n.slice(7));if(!r)return[];let i=[];if(r.decl){let e=t[r.decl.lineIndex];i.push({start:e.start+e.indent.length,end:e.end})}for(let t of e.relations)t.source===r.id&&i.push(t.stmt.sourceSpan),t.target===r.id&&i.push(t.stmt.targetSpan);return i}if(n.startsWith(`erel:`)){let r=e.relations.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}return[]}function et(e,t,n){for(let r of e.relations){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end)return n>=r.stmt.sourceSpan.start&&n<=r.stmt.sourceSpan.end?`entity:${r.source}`:n>=r.stmt.targetSpan.start&&n<=r.stmt.targetSpan.end?`entity:${r.target}`:r.entityId}for(let r of e.entities){let e=[...r.decl?[r.decl.lineIndex]:[],...r.attributes.map(e=>e.lineIndex)];for(let i of e){let e=t[i];if(n>=e.start&&n<=e.end)return r.entityId}}return null}var tt={"zero-or-one":`|o`,"exactly-one":`||`,"zero-or-more":`}o`,"one-or-more":`}|`},nt={"zero-or-one":`o|`,"exactly-one":`||`,"zero-or-more":`o{`,"one-or-more":`|{`};function rt(e){for(let[t,n]of Object.entries(tt))if(n===e)return t;for(let[t,n]of Object.entries(nt))if(n===e)return t;return`exactly-one`}function it(e){for(let t of e.lines)if(t.kind===`statement`&&t.index!==e.graph.headerLine&&t.text.trim()!==``)return t.indent;return` `}function J(e,t,n){let r=e.lines[t];return{start:r.end,end:r.end,text:n.map(e=>`
10
- ${e}`).join(``)}}function Y(e,t){let n=e.lines[t];return n.end<e.code.length?{start:n.start,end:n.end+1,text:``}:n.start>0?{start:n.start-1,end:n.end,text:``}:{start:n.start,end:n.end,text:``}}function X(e,t){return e.relations.find(e=>e.entityId===t)??null}function at(e,t){let{graph:n,lines:r}=e;switch(t.type){case`er.addEntity`:{let r=new Set(n.entities.map(e=>e.id)),i=t.name?.replace(/[^\w-]/g,``)||``;if(!i||r.has(i)){let e=1;for(;r.has(`ENTITY${e}`);)e++;i=`ENTITY${e}`}let a=it(e);return{edits:[J(e,n.lastContentLine,[`${a}${i} {`,`${a} string id`,`${a}}`])],created:[`entity:${i}`]}}case`er.connect`:{if(!n.entityById.has(t.source)||!n.entityById.has(t.target))return null;let i=n.lastContentLine,a=-1;for(let e of[t.source,t.target]){let t=n.entityById.get(e);if(t)for(let e of t.refLines)a=Math.max(a,t.block&&e===t.block.open?t.block.close:e)}a>=0&&(i=a);let o=r[i].kind===`statement`?r[i].indent:it(e),s=(t.label??`relates`).replace(/[:{}]/g,``).trim()||`relates`,c=n.relations.filter(e=>e.source===t.source&&e.target===t.target).length;return{edits:[J(e,i,[`${o}${t.source} ||--o{ ${t.target} : ${s}`])],created:[`erel:${t.source}->${t.target}#${c}`]}}case`er.renameEntity`:{let e=n.entityById.get(t.id);if(!e)return null;let r=t.name.trim().replace(/[^\w-]/g,``);if(!r||n.entityById.has(r))return null;let i=[];e.decl&&i.push({start:e.decl.idSpan.start,end:e.decl.idSpan.end,text:r});for(let e of n.relations)e.source===t.id&&i.push({start:e.stmt.sourceSpan.start,end:e.stmt.sourceSpan.end,text:r}),e.target===t.id&&i.push({start:e.stmt.targetSpan.start,end:e.stmt.targetSpan.end,text:r});return{edits:i}}case`er.setCardinality`:{let e=X(n,t.relId);return e?t.side===`left`?{edits:[{start:e.stmt.leftCardSpan.start,end:e.stmt.leftCardSpan.end,text:tt[t.card]}]}:{edits:[{start:e.stmt.rightCardSpan.start,end:e.stmt.rightCardSpan.end,text:nt[t.card]}]}:null}case`er.setIdentifying`:{let e=X(n,t.relId);return e?{edits:[{start:e.stmt.lineSpan.start,end:e.stmt.lineSpan.end,text:t.identifying?`--`:`..`}]}:null}case`er.setRelationLabel`:{let e=X(n,t.relId);if(!e)return null;let r=t.label.replace(/[:{}]/g,``).trim()||`relates`;return{edits:[{start:e.stmt.labelSpan.start,end:e.stmt.labelSpan.end,text:` ${r}`}]}}case`er.addAttribute`:{let i=n.entityById.get(t.id);if(!i)return null;let a=(t.text??`string attribute`).replace(/[{}]/g,``).trim();if(i.block&&i.block.close>=0){let t=r[i.block.open],n=i.attributes.length?r[i.attributes[i.attributes.length-1].lineIndex].indent:`${t.indent} `;return{edits:[J(e,i.attributes.length?i.attributes[i.attributes.length-1].lineIndex:i.block.open,[`${n}${a}`])]}}let o=r[i.firstRefLine];return{edits:[J(e,i.firstRefLine,[`${o.indent}${i.id} {`,`${o.indent} ${a}`,`${o.indent}}`])]}}case`er.setAttributeText`:{let i=n.entityById.get(t.id);if(!i)return null;let a=i.attributes.find(e=>e.lineIndex===t.attrLine);if(!a)return null;let o=t.text.replace(/[{}]/g,``).trim();if(!o)return{edits:[Y(e,a.lineIndex)]};let s=r[a.lineIndex];return{edits:[{start:s.start,end:s.end,text:`${s.indent}${o}`}]}}case`er.deleteEntity`:{let r=n.entityById.get(t.id);if(!r)return null;let i=new Set;if(r.decl&&i.add(r.decl.lineIndex),r.block&&r.block.close>=0)for(let e=r.block.open;e<=r.block.close;e++)i.add(e);for(let e of n.relations)(e.source===r.id||e.target===r.id)&&i.add(e.lineIndex);return{edits:[...i].map(t=>Y(e,t))}}case`er.deleteRelation`:{let r=X(n,t.relId);return r?{edits:[Y(e,r.lineIndex)]}:null}}}var ot=/^"([^"]*)"\s*:\s*([\d.]+)\s*$/;function st(e,t){let n=[],r=t;for(let i of e){if(i.kind!==`statement`||i.index===t){i.index===t&&(r=i.index);continue}r=i.index;let e=ot.exec(i.text.trim());if(!e)continue;let a=i.start+i.text.indexOf(`"`)+1,o=i.start+i.text.lastIndexOf(e[2]);n.push({entityId:`slice:${i.index}`,label:e[1],value:Number(e[2]),lineIndex:i.index,labelSpan:{start:a,end:a+e[1].length},valueSpan:{start:o,end:o+e[2].length}})}return{headerLine:t,showData:/\bshowData\b/.test(e[t]?.text??``),slices:n,lastContentLine:r}}function ct(e,t){let{graph:n,lines:r}=e,i=e=>n.slices.find(t=>t.entityId===e)??null;switch(t.type){case`pie.setValue`:{let e=i(t.sliceId);return!e||!Number.isFinite(t.value)||t.value<0?null:{edits:[{start:e.valueSpan.start,end:e.valueSpan.end,text:String(t.value)}]}}case`pie.setLabel`:{let e=i(t.sliceId);return e?{edits:[{start:e.labelSpan.start,end:e.labelSpan.end,text:t.label.replace(/"/g,`'`)}]}:null}case`pie.addSlice`:{let e=n.slices.length?n.slices[n.slices.length-1].lineIndex:n.lastContentLine,i=r[e],a=`${n.slices.length?i.indent:` `}"${(t.label??`New slice`).replace(/"/g,`'`)}" : ${t.value??10}`;return{edits:[{start:i.end,end:i.end,text:`
11
- ${a}`}],created:[`slice:${e+1}`]}}case`pie.deleteSlice`:{let n=i(t.sliceId);if(!n)return null;let a=r[n.lineIndex];return a.end<e.code.length?{edits:[{start:a.start,end:a.end+1,text:``}]}:{edits:[{start:Math.max(0,a.start-1),end:a.end,text:``}]}}}}function lt(e,t,n){let r=e.slices.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}function ut(e,t,n){for(let r of e.slices){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end)return r.entityId}return null}var dt=/^(dateFormat|axisFormat|tickInterval|excludes|includes|todayMarker|title|weekday|inclusiveEndDates|topAxis)\b/,ft=/^section\s+(.+)$/,pt=/^(.+?)\s*:\s*(.+)$/;function mt(e,t){let n=[],r=[],i=null,a=t;for(let o of e){if(o.kind!==`statement`||o.index===t){o.index===t&&(a=o.index);continue}a=o.index;let e=o.text.trim();if(dt.test(e))continue;let s=ft.exec(e);if(s){i=s[1].trim(),r.push({name:i,lineIndex:o.index});continue}let c=pt.exec(e);if(c){let e=o.start+o.indent.length,t=o.text.indexOf(`:`,o.indent.length+c[1].length-1),r=o.start+t+1;n.push({entityId:`task:${o.index}`,name:c[1].trim(),meta:c[2].trim(),lineIndex:o.index,nameSpan:{start:e,end:e+c[1].trimEnd().length},metaSpan:{start:r,end:o.end},section:i})}}return{headerLine:t,tasks:n,sections:r,lastContentLine:a}}function ht(e,t){let{graph:n,lines:r}=e,i=e=>n.tasks.find(t=>t.entityId===e)??null;switch(t.type){case`gantt.setTaskName`:{let e=i(t.taskId);if(!e)return null;let n=t.name.trim().replace(/[:#]/g,``);return n?{edits:[{start:e.nameSpan.start,end:e.nameSpan.end,text:n}]}:null}case`gantt.setTaskMeta`:{let e=i(t.taskId);if(!e)return null;let n=t.meta.trim().replace(/:/g,``);return n?{edits:[{start:e.metaSpan.start,end:e.metaSpan.end,text:` ${n}`}]}:null}case`gantt.addTask`:{let e=t.section?n.tasks.filter(e=>e.section===t.section):n.tasks,i=e.length?e[e.length-1].lineIndex:n.sections.length?n.sections[n.sections.length-1].lineIndex:n.lastContentLine,a=r[i],o=e.length?a.indent:`${a.indent} `,s=(t.name??`New task`).replace(/[:#]/g,``),c=(t.meta??`1d`).replace(/:/g,``);return{edits:[{start:a.end,end:a.end,text:`
12
- ${o}${s} :${c}`}],created:[`task:${i+1}`]}}case`gantt.deleteTask`:{let n=i(t.taskId);if(!n)return null;let a=r[n.lineIndex];return a.end<e.code.length?{edits:[{start:a.start,end:a.end+1,text:``}]}:{edits:[{start:Math.max(0,a.start-1),end:a.end,text:``}]}}}}function gt(e,t,n){let r=e.tasks.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}function _t(e,t,n){for(let r of e.tasks){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end)return r.entityId}return null}var Z=e=>/"([^"]+)"/.exec(e)?.[1]??null,Q=e=>{let t=/\[([^\]]+)\]|\(\(([^)]+)\)\)|\(([^)]+)\)|\{\{([^}]+)\}\}/.exec(e);return t?(t[1]??t[2]??t[3]??t[4])?.replace(/^"|"$/g,``)??null:null},vt=e=>{let t=e.indexOf(`:`);return t>0?e.slice(0,t).trim():null},yt=(e,t)=>{let n=t.exec(e);return n&&e.slice(n[0].length).trim()||null},bt={journey:{match:e=>yt(e,/^(title|section)\s+/)??vt(e),addTemplate:`New task: 3: Me`},timeline:{match:e=>{let t=yt(e,/^title\s+/);if(t)return t;let n=e.split(`:`).map(e=>e.trim()).filter(Boolean);return n.length?n[n.length-1]:null},addTemplate:`2030 : New event`},quadrant:{match:e=>/^(title|x-axis|y-axis|quadrant-\d)/.test(e)?null:vt(e),addTemplate:`New point: [0.5, 0.5]`},kanban:{match:e=>Q(e)??(/^\S/.test(e)?e:null),addTemplate:` [New card]`},mindmap:{match:e=>Q(e)??(e.replace(/^::icon.*$/,``)||null),addTemplate:` New idea`},treemap:{match:e=>Z(e),addTemplate:`"New item": 10`},packet:{match:e=>Z(e),addTemplate:`96-127: "New Field"`},sankey:{match:e=>e.split(`,`)[0]?.trim().replace(/^"|"$/g,``)||null,addTemplate:`Source,Target,10`},radar:{match:e=>Z(e),addTemplate:`curve new["New"]{50, 50, 50}`},gitgraph:{match:e=>Z(e)??yt(e,/^(branch|checkout|merge)\s+/),addTemplate:`commit`},xychart:{match:e=>/^title\b/.test(e)?Z(e):null,addTemplate:`bar [10, 20, 30]`},architecture:{match:e=>Q(e),addTemplate:`service new1(server)[New Service]`},requirement:{match:e=>/^(requirement|element|functionalRequirement|interface|performanceRequirement|physicalRequirement|designConstraint)\s+(\w+)/.exec(e)?.[2]??null,addTemplate:`element new_element {`},c4:{match:e=>Z(e),addTemplate:`Person(newPerson, "New Person", "Description")`},block:{match:e=>Q(e)??(/^[\w]+$/.test(e)?e:null),addTemplate:`newBlock["New Block"]`}};function xt(e,t,n){let r=bt[n];if(!r)return null;let i=[],a=t;for(let n of e){if(n.kind!==`statement`||n.index===t){n.index===t&&(a=n.index);continue}a=n.index;let e=n.text.trim();e===`}`||e===`end`||i.push({entityId:`item:${n.index}`,text:e,matchText:r.match(e),lineIndex:n.index})}return{typeId:n,headerLine:t,items:i,lastContentLine:a,addTemplate:r.addTemplate}}function St(e,t){let{graph:n,lines:r}=e,i=e=>n.items.find(t=>t.entityId===e)??null;switch(t.type){case`li.setLine`:{let n=i(t.itemId);if(!n)return null;let a=t.text.replace(/\n/g,` `).trim(),o=r[n.lineIndex];return a?{edits:[{start:o.start,end:o.end,text:`${o.indent}${a}`}]}:o.end<e.code.length?{edits:[{start:o.start,end:o.end+1,text:``}]}:{edits:[{start:Math.max(0,o.start-1),end:o.end,text:``}]}}case`li.addItem`:{let e=n.items.length?n.items[n.items.length-1].lineIndex:n.lastContentLine,i=r[e],a=n.items.length?i.indent:` `,o=(t.text??n.addTemplate).replace(/\n/g,` `);return{edits:[{start:i.end,end:i.end,text:`
13
- ${a}${o.trim()}`}],created:[`item:${e+1}`]}}case`li.deleteItem`:{let n=i(t.itemId);if(!n)return null;let a=r[n.lineIndex];return a.end<e.code.length?{edits:[{start:a.start,end:a.end+1,text:``}]}:{edits:[{start:Math.max(0,a.start-1),end:a.end,text:``}]}}}}function Ct(e,t,n){let r=e.items.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}function wt(e,t,n){for(let r of e.items){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end)return r.entityId}return null}function $(e){let t=i(e),{headerIndex:n}=a(t),o=n>=0?r(t[n].text):null,s=null,c=null,l=null,u=null,d=null,f=null,p=null,m=null;try{o?.id===`flowchart`?s=g(t,n):o?.id===`sequence`?c=ge(t,n):o?.id===`state`?l=Ae(t,n):o?.id===`class`?u=Ue(t,n):o?.id===`er`?d=Qe(t,n):o?.id===`pie`?f=st(t,n):o?.id===`gantt`?p=mt(t,n):o&&bt[o.id]&&(m=xt(t,n,o.id))}catch{}return{code:e,lines:t,headerIndex:n,typeInfo:o,flowchart:s,sequence:c,state:l,classGraph:u,er:d,pie:f,gantt:p,lineItems:m}}var Tt=class{_code;_result;_selection=[];undoStack=[];redoStack=[];listeners={change:new Set,selectionChange:new Set,diagnostics:new Set};coalesceMs;_diagnostics=[];constructor(e={}){this._code=e.code??`flowchart TD
14
- A[Start] --> B[End]`,this.coalesceMs=e.coalesceMs??750,this._result=$(this._code)}get code(){return this._code}get result(){return this._result}get selection(){return this._selection}get diagnostics(){return this._diagnostics}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}on(e,t){return this.listeners[e].add(t),()=>this.listeners[e].delete(t)}emit(e,t){for(let n of this.listeners[e])n(t)}setDiagnostics(e){this._diagnostics=e,this.emit(`diagnostics`,e)}applyEdits(e,t=`api`){if(e.length===0)return;let{text:n,inverse:r}=o(this._code,e);if(n===this._code)return;let i={edits:e,inverse:r,origin:t,selectionBefore:[...this._selection],selectionAfter:[...this._selection],time:Date.now()};this.commit(n,i,t)}setCode(e,t=`code`){let n=s(this._code,e);if(!n)return;let{text:r,inverse:i}=o(this._code,[n]),a=Date.now(),c=this.undoStack[this.undoStack.length-1];if(t===`code`&&c&&c.origin===`code`&&a-c.time<this.coalesceMs&&this.redoStack.length===0){let e=o(this._code,c.inverse).text,i=s(e,r),l=s(r,e);c.edits=i?[i]:[],c.inverse=l?[l]:[],c.time=a,this._code=r,this._result=$(r),this.pruneSelection(),this.emit(`change`,{code:r,edits:[n],origin:t,result:this._result});return}let l={edits:[n],inverse:i,origin:t,selectionBefore:[...this._selection],selectionAfter:[...this._selection],time:a};this.commit(r,l,t)}commit(e,t,n){this._code=e,this._result=$(e),this.undoStack.push(t),this.redoStack=[],this.pruneSelection(),t.selectionAfter=[...this._selection],this.emit(`change`,{code:e,edits:t.edits,origin:n,result:this._result})}undo(){let e=this.undoStack.pop();if(!e)return!1;let{text:t}=o(this._code,e.inverse);return this.redoStack.push(e),this._code=t,this._result=$(t),this._selection=e.selectionBefore.filter(e=>this.entityExists(e)),this.emit(`change`,{code:t,edits:e.inverse,origin:`history`,result:this._result}),this.emit(`selectionChange`,{entityIds:this._selection,spans:this.selectionSpans(),origin:`history`}),!0}redo(){let e=this.redoStack.pop();if(!e)return!1;let{text:t}=o(this._code,e.edits);return this.undoStack.push(e),this._code=t,this._result=$(t),this._selection=e.selectionAfter.filter(e=>this.entityExists(e)),this.emit(`change`,{code:t,edits:e.edits,origin:`history`,result:this._result}),this.emit(`selectionChange`,{entityIds:this._selection,spans:this.selectionSpans(),origin:`history`}),!0}dispatch(e,t=`canvas`){let{flowchart:n,sequence:r,state:i,classGraph:a,er:o,pie:s,gantt:c,lineItems:l,lines:u}=this._result,d=null;if(e.type.startsWith(`seq.`)){if(!r)return null;d=Se({code:this._code,lines:u,graph:r},e)}else if(e.type.startsWith(`st.`)){if(!i)return null;d=Fe({code:this._code,lines:u,graph:i},e)}else if(e.type.startsWith(`cl.`)){if(!a)return null;d=qe({code:this._code,lines:u,graph:a},e)}else if(e.type.startsWith(`er.`)){if(!o)return null;d=at({code:this._code,lines:u,graph:o},e)}else if(e.type.startsWith(`pie.`)){if(!s)return null;d=ct({code:this._code,lines:u,graph:s},e)}else if(e.type.startsWith(`gantt.`)){if(!c)return null;d=ht({code:this._code,lines:u,graph:c},e)}else if(e.type.startsWith(`li.`)){if(!l)return null;d=St({code:this._code,lines:u,graph:l},e)}else{if(!n)return null;d=ie({code:this._code,lines:u,graph:n},e)}return!d||d.edits.length===0?d:(this.applyEdits(d.edits,t),d.created?.length&&this.setSelection(d.created,t),d)}deleteEntities(e,t=`canvas`){let n=e=>e.startsWith(`edge:`)||e.startsWith(`event:`)||e.startsWith(`trans:`)||e.startsWith(`rel:`)||e.startsWith(`erel:`)?0:1;for(let r of[...e].sort((e,t)=>n(e)-n(t)))this.entityExists(r)&&(r.startsWith(`edge:`)?this.dispatch({type:`deleteEdge`,edgeId:r},t):r.startsWith(`node:`)?this.dispatch({type:`deleteNode`,id:r.slice(5)},t):r.startsWith(`event:`)?this.dispatch({type:`seq.deleteEvent`,eventId:r},t):r.startsWith(`participant:`)?this.dispatch({type:`seq.deleteParticipant`,id:r.slice(12)},t):r.startsWith(`trans:`)?this.dispatch({type:`st.deleteTransition`,transId:r},t):r.startsWith(`state:`)?this.dispatch({type:`st.deleteState`,id:r.slice(6)},t):r.startsWith(`rel:`)?this.dispatch({type:`cl.deleteRelation`,relId:r},t):r.startsWith(`class:`)?this.dispatch({type:`cl.deleteClass`,id:r.slice(6)},t):r.startsWith(`erel:`)?this.dispatch({type:`er.deleteRelation`,relId:r},t):r.startsWith(`entity:`)?this.dispatch({type:`er.deleteEntity`,id:r.slice(7)},t):r.startsWith(`slice:`)?this.dispatch({type:`pie.deleteSlice`,sliceId:r},t):r.startsWith(`task:`)?this.dispatch({type:`gantt.deleteTask`,taskId:r},t):r.startsWith(`item:`)&&this.dispatch({type:`li.deleteItem`,itemId:r},t))}entityExists(e){let t=this._result.flowchart;if(t){if(e.startsWith(`node:`))return t.nodeById.has(e.slice(5));if(e.startsWith(`edge:`))return t.edges.some(t=>t.entityId===e);if(e.startsWith(`subgraph:`))return t.subgraphs.some(t=>t.entityId===e)}let n=this._result.sequence;if(n){if(e.startsWith(`participant:`))return n.participantById.has(e.slice(12));if(e.startsWith(`event:`))return n.events.some(t=>t.entityId===e)}let r=this._result.state;if(r){if(e.startsWith(`state:`))return r.stateById.has(e.slice(6));if(e.startsWith(`trans:`))return r.transitions.some(t=>t.entityId===e)}let i=this._result.classGraph;if(i){if(e.startsWith(`class:`))return i.classById.has(e.slice(6));if(e.startsWith(`rel:`))return i.relations.some(t=>t.entityId===e)}let a=this._result.er;if(a){if(e.startsWith(`entity:`))return a.entityById.has(e.slice(7));if(e.startsWith(`erel:`))return a.relations.some(t=>t.entityId===e)}let o=this._result.pie;if(o&&e.startsWith(`slice:`))return o.slices.some(t=>t.entityId===e);let s=this._result.gantt;if(s&&e.startsWith(`task:`))return s.tasks.some(t=>t.entityId===e);let c=this._result.lineItems;return c&&e.startsWith(`item:`)?c.items.some(t=>t.entityId===e):!1}setSelection(e,t=`api`){let n=e.filter(e=>this.entityExists(e));n.length===this._selection.length&&n.every((e,t)=>e===this._selection[t])||(this._selection=n,this.emit(`selectionChange`,{entityIds:n,spans:this.selectionSpans(),origin:t}))}clearSelection(e=`api`){this.setSelection([],e)}pruneSelection(){this._selection=this._selection.filter(e=>this.entityExists(e))}selectionSpans(){return this._selection.flatMap(e=>this.entityRanges(e))}entityRanges(e){let{flowchart:t,sequence:n,state:r,classGraph:i,er:a,pie:o,gantt:s,lineItems:c,lines:l}=this._result;return t?_(t,l,e):n?_e(n,l,e):r?je(r,l,e):i?We(i,l,e):a?$e(a,l,e):o?lt(o,l,e):s?gt(s,l,e):c?Ct(c,l,e):[]}entityAt(e){let{flowchart:t,sequence:n,state:r,classGraph:i,er:a,pie:o,gantt:s,lineItems:c,lines:l}=this._result;return t?v(t,e):n?ve(n,l,e):r?Me(r,l,e):i?Ge(i,l,e):a?et(a,l,e):o?ut(o,l,e):s?_t(s,l,e):c?wt(c,l,e):null}};export{n as DIAGRAM_TYPES,bt as LINE_ITEM_CONFIGS,oe as MESSAGE_OPS,Tt as MermaidWysiwygEditor,ae as PARTICIPANT_TYPES,Ie as RELATION_OPS,d as SHAPE_DELIMS,o as applyEdits,e as bindTextPane,Ue as buildClassGraph,Qe as buildErGraph,g as buildFlowGraph,mt as buildGanttGraph,xt as buildLineItemsGraph,st as buildPieGraph,ge as buildSequenceGraph,Ae as buildStateGraph,rt as cardinalityFromGlyph,Ge as classEntityAt,We as classEntitySpans,a as classifyLines,qe as compileClassOp,at as compileErOp,ie as compileFlowchartOp,ht as compileGanttOp,St as compileLineItemOp,ct as compilePieOp,Se as compileSequenceOp,Fe as compileStateOp,r as detectDiagramType,s as diffText,v as entityAtOffset,_ as entitySpans,et as erEntityAt,$e as erEntitySpans,_t as ganttEntityAt,gt as ganttEntitySpans,wt as lineItemAt,Ct as lineItemSpans,c as mapOffset,$ as parse,He as parseClassStatement,Ze as parseErStatement,h as parseFlowHeader,m as parseFlowStatement,he as parseSequenceStatement,I as parseStateStatement,ut as pieEntityAt,lt as pieEntitySpans,i as scanLines,ve as sequenceEntityAt,_e as sequenceEntitySpans,Me as stateEntityAt,je as stateEntitySpans};
8
+ ${a}end`;return{edits:[{start:i.start,end:i.end,text:s}],created:[`event:${e.lineIndex+1}`]}}case`seq.toggleAutonumber`:return n.autonumber.enabled&&n.autonumber.lineIndex!==null?{edits:[P(e,n.autonumber.lineIndex)]}:{edits:[N(e,n.headerLine,[`${M(e)}autonumber`])]}}}var Te=String.raw`(?:\[\*\]|[\w-]+)`,Ee=new RegExp(String.raw`^(${Te})\s*-->\s*(${Te})\s*(?::(.*))?$`),De=/^state\s+"([^"]*)"\s+as\s+([\w-]+)\s*(\{)?\s*$/,Oe=/^state\s+([\w-]+)\s*(<<\w+>>)?\s*(\{)?\s*$/,ke=/^([\w-]+)\s*:\s*(.*)$/,Ae=/^note\s+(left|right)\s+of\s+[\w-]+\s*:/i,je=/^note\s+(left|right)\s+of\s+[\w-]+\s*$/i;function I(e,t,n){return{start:e.start+t,end:e.start+n}}function Me(e){let t=e.text,n=t.trim(),r=e.index,i=t.length-t.trimStart().length;if(n===`}`)return{kind:`blockClose`,lineIndex:r,parts:[]};if(n===`--`)return{kind:`divider`,lineIndex:r,parts:[]};let a=/^direction\s+(TB|TD|BT|RL|LR)\s*$/.exec(n);if(a)return{kind:`direction`,lineIndex:r,parts:[a[1]]};if(/^end\s+note$/i.test(n))return{kind:`noteBlockEnd`,lineIndex:r,parts:[]};if(Ae.test(n))return{kind:`note`,lineIndex:r,parts:[]};if(je.test(n))return{kind:`noteBlockOpen`,lineIndex:r,parts:[]};if(/^classDef\b/.test(n))return{kind:`classDef`,lineIndex:r,parts:[]};if(/^style\b/.test(n))return{kind:`style`,lineIndex:r,parts:[]};let o=/^class\s+([\w-,\s]+)\s+([\w-]+)\s*$/.exec(n);if(o)return{kind:`classAssign`,lineIndex:r,parts:o[1].split(`,`).map(e=>e.trim())};let s=Ee.exec(n);if(s){let[,a,o,c]=s,l=i+n.indexOf(a),u=t.indexOf(`-->`,l+a.length),d=t.indexOf(o,u+3),f=null,p=null;if(c!==void 0){let n=t.indexOf(`:`,d+o.length);f=t.slice(n+1).trim(),p=I(e,n+1,t.length)}return{kind:`transition`,lineIndex:r,source:a,sourceSpan:I(e,l,l+a.length),target:o,targetSpan:I(e,d,d+o.length),label:f,labelSpan:p}}let c=De.exec(n);if(c){let n=c[1],i=c[2],a=t.indexOf(`"`)+1,o=t.indexOf(i,a+n.length+1);return{kind:`decl`,lineIndex:r,id:i,idSpan:I(e,o,o+i.length),label:n,labelSpan:I(e,a,a+n.length),form:`quoted`,opensBlock:!!c[3],stereotype:null}}let l=Oe.exec(n);if(l){let n=l[1],a=t.indexOf(n,i+5);return{kind:`decl`,lineIndex:r,id:n,idSpan:I(e,a,a+n.length),label:null,labelSpan:null,form:`state`,opensBlock:!!l[3],stereotype:l[2]??null}}let u=ke.exec(n);if(u){let n=u[1],a=i,o=t.indexOf(`:`,a+n.length);return{kind:`decl`,lineIndex:r,id:n,idSpan:I(e,a,a+n.length),label:u[2].trim(),labelSpan:I(e,o+1,t.length),form:`desc`,opensBlock:!1,stereotype:null}}return{kind:`unknown`,lineIndex:r,parts:[]}}function Ne(e,t){let n=new Map,r=[],i=new Map,a=[],o=new Map,s=null,c=t,l=!1,u=(e,t)=>{if(e===`[*]`)return null;let r=n.get(e);return r||(r={entityId:`state:${e}`,id:e,label:e,decl:null,declLines:[],refLines:[],firstRefLine:t,parent:a.length?a[a.length-1]:null,isComposite:!1,stereotype:null,typeDeclLine:null},n.set(e,r)),r};for(let n of e){if(n.kind!==`statement`||n.index===t){n.index===t&&(c=n.index);continue}if(l){Me(n).kind===`noteBlockEnd`&&(l=!1),i.set(n.index,{kind:`unknown`,lineIndex:n.index,parts:[]}),c=n.index;continue}let e=Me(n);switch(i.set(n.index,e),c=n.index,e.kind){case`noteBlockOpen`:l=!0;break;case`decl`:{let t=u(e.id,e.lineIndex);t&&(t.declLines.push(e.lineIndex),e.label!==null&&(t.decl=e,t.label=e.label),e.form===`state`&&(t.typeDeclLine=e.lineIndex,e.stereotype&&(t.stereotype=e.stereotype.replace(/[<>]/g,``))),e.opensBlock&&(t.isComposite=!0,a.push(e.id)));break}case`blockClose`:a.pop();break;case`transition`:{let t=u(e.source,e.lineIndex),n=u(e.target,e.lineIndex);t?.refLines.push(e.lineIndex),n?.refLines.push(e.lineIndex);let i=`${e.source}->${e.target}`,a=o.get(i)??0;o.set(i,a+1),r.push({entityId:`trans:${i}#${a}`,source:e.source,target:e.target,lineIndex:e.lineIndex,stmt:e,label:e.label,order:r.length});break}case`direction`:s={value:e.parts[0],lineIndex:e.lineIndex};break;default:break}}return{headerLine:t,states:[...n.values()],stateById:n,transitions:r,statements:i,direction:s,lastContentLine:c}}function Pe(e,t,n){if(n.startsWith(`state:`)){let r=e.stateById.get(n.slice(6));if(!r)return[];let i=[];for(let e of r.declLines){let n=t[e];i.push({start:n.start+n.indent.length,end:n.end})}for(let t of e.transitions)t.source===r.id&&i.push(t.stmt.sourceSpan),t.target===r.id&&i.push(t.stmt.targetSpan);return i}if(n.startsWith(`trans:`)){let r=e.transitions.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}return[]}function Fe(e,t,n){for(let r of e.transitions){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end)return n>=r.stmt.sourceSpan.start&&n<=r.stmt.sourceSpan.end&&r.source!==`[*]`?`state:${r.source}`:n>=r.stmt.targetSpan.start&&n<=r.stmt.targetSpan.end&&r.target!==`[*]`?`state:${r.target}`:r.entityId}for(let r of e.states)for(let e of r.declLines){let i=t[e];if(n>=i.start&&n<=i.end)return r.entityId}return null}function L(e){for(let t of e.lines)if(t.kind===`statement`&&t.index!==e.graph.headerLine&&t.text.trim()!==``)return t.indent;return` `}function R(e,t,n){let r=e.lines[t];return{start:r.end,end:r.end,text:n.map(e=>`
9
+ ${e}`).join(``)}}function Ie(e,t){let n=e.lines[t];return n.end<e.code.length?{start:n.start,end:n.end+1,text:``}:n.start>0?{start:n.start-1,end:n.end,text:``}:{start:n.start,end:n.end,text:``}}function z(e,t){return e.transitions.find(e=>e.entityId===t)??null}function Le(e,t){let n=new Set(e.states.map(e=>e.id));if(t&&!n.has(t))return t;let r=1;for(;n.has(`s${r}`);)r++;return`s${r}`}function B(e){return e.trim().replace(/[:{}]/g,``)}function Re(e,t){let{graph:n,lines:r}=e;switch(t.type){case`st.addState`:{let r=Le(n,t.id),i=t.label?B(t.label):null,a=i?`${L(e)}${r}: ${i}`:`${L(e)}state ${r}`;return{edits:[R(e,n.lastContentLine,[a])],created:[`state:${r}`]}}case`st.connect`:{if(t.source!==`[*]`&&!n.stateById.has(t.source)||t.target!==`[*]`&&!n.stateById.has(t.target))return null;let i=n.lastContentLine,a=-1;for(let e of[t.source,t.target]){let t=n.stateById.get(e);if(t)for(let e of[...t.declLines,...t.refLines])a=Math.max(a,e)}a>=0&&(i=a);let o=r[i].kind===`statement`?r[i].indent:L(e),s=t.label?`: ${B(t.label)}`:``,c=n.transitions.filter(e=>e.source===t.source&&e.target===t.target).length;return{edits:[R(e,i,[`${o}${t.source} --> ${t.target}${s}`])],created:[`trans:${t.source}->${t.target}#${c}`]}}case`st.setStateType`:{let i=n.stateById.get(t.id);if(!i||i.isComposite)return null;let a=t.stype===`state`?``:` <<${t.stype}>>`;if(i.typeDeclLine!==null){let e=r[i.typeDeclLine];return{edits:[{start:e.start,end:e.end,text:`${e.indent}state ${i.id}${a}`}]}}return t.stype===`state`?{edits:[]}:{edits:[R(e,n.headerLine,[`${L(e)}state ${i.id}${a}`])]}}case`st.addStateNote`:{let i=n.stateById.get(t.id);if(!i)return null;let a=`${r[i.firstRefLine].indent}note ${t.side} of ${i.id}: ${B(t.text??`note`)}`;return{edits:[R(e,i.firstRefLine,[a])]}}case`st.reverseTransition`:{let e=z(n,t.transId);return e?{edits:[{start:e.stmt.sourceSpan.start,end:e.stmt.sourceSpan.end,text:e.target},{start:e.stmt.targetSpan.start,end:e.stmt.targetSpan.end,text:e.source}]}:null}case`st.moveToComposite`:{let r=n.stateById.get(t.id);if(!r||r.isComposite||r.parent)return null;let i=new Set(n.states.map(e=>e.id)),a=t.name?.replace(/[^\w-]/g,``)||``;if(!a||i.has(a)){let e=1;for(;i.has(`Composite${e}`);)e++;a=`Composite${e}`}let o=L(e);return{edits:[R(e,n.headerLine,[`${o}state ${a} {`,`${o} ${r.id}`,`${o}}`])],created:[`state:${a}`]}}case`st.setStateLabel`:{let i=n.stateById.get(t.id);if(!i)return null;let a=B(t.label);if(!a)return null;if(i.decl?.labelSpan){let e=i.decl.form===`quoted`?a.replace(/"/g,`'`):` ${a}`;return{edits:[{start:i.decl.labelSpan.start,end:i.decl.labelSpan.end,text:e}]}}let o=r[i.firstRefLine];return{edits:[R(e,i.firstRefLine,[`${o.indent}${i.id}: ${a}`])]}}case`st.setTransitionLabel`:{let e=z(n,t.transId);if(!e)return null;let i=B(t.label);return e.stmt.labelSpan?i?{edits:[{start:e.stmt.labelSpan.start,end:e.stmt.labelSpan.end,text:` ${i}`}]}:{edits:[{start:e.stmt.targetSpan.end,end:r[e.lineIndex].end,text:``}]}:i?{edits:[{start:e.stmt.targetSpan.end,end:e.stmt.targetSpan.end,text:`: ${i}`}]}:{edits:[]}}case`st.deleteTransition`:{let r=z(n,t.transId);return r?{edits:[Ie(e,r.lineIndex)]}:null}case`st.deleteState`:{let r=n.stateById.get(t.id);if(!r||r.isComposite)return null;let i=new Set(r.declLines);for(let e of n.transitions)(e.source===r.id||e.target===r.id)&&i.add(e.lineIndex);return{edits:[...i].map(t=>Ie(e,t))}}case`st.setDirection`:if(n.direction){let e=r[n.direction.lineIndex];return{edits:[{start:e.start,end:e.end,text:`${e.indent}direction ${t.direction}`}]}}return{edits:[R(e,n.headerLine,[`${L(e)}direction ${t.direction}`])]}}}var ze=[`<|--`,`--|>`,`<|..`,`..|>`,`*--`,`--*`,`o--`,`--o`,`<--`,`-->`,`<..`,`..>`,`--`,`..`],Be=String.raw`[\w.~]+`,Ve=ze.map(e=>e.replace(/[|*.]/g,e=>`\\${e}`)).join(`|`),He=new RegExp(String.raw`^(${Be})\s*(?:"([^"]*)"\s*)?(${Ve})\s*(?:"([^"]*)"\s*)?(${Be})\s*(?::\s*(.*))?$`),Ue=/^class\s+([\w.~]+)(?:\["([^"]*)"\])?\s*(\{)?\s*$/,We=/^([\w.~]+)\s*:\s*(.+)$/;function V(e,t,n){return{start:e.start+t,end:e.start+n}}function Ge(e,t){let n=e.text,r=n.trim(),i=e.index,a=n.length-n.trimStart().length;if(t!==null)return r===`}`?{kind:`blockClose`,lineIndex:i,parts:[]}:/^<<\w+>>$/.test(r)?{kind:`annotation`,lineIndex:i,parts:[r]}:{kind:`member`,lineIndex:i,classId:null,text:r,textSpan:V(e,a,n.length)};if(r===`}`)return{kind:`blockClose`,lineIndex:i,parts:[]};if(/^direction\s+(TB|TD|BT|RL|LR)\s*$/.test(r))return{kind:`direction`,lineIndex:i,parts:[r.split(/\s+/)[1]]};if(/^note\b/i.test(r))return{kind:`note`,lineIndex:i,parts:[]};if(/^(classDef|style|cssClass|click|callback|link|namespace)\b/.test(r))return{kind:`passthrough`,lineIndex:i,parts:[]};let o=/^<<(\w+)>>\s+([\w.~]+)$/.exec(r);if(o)return{kind:`annotation`,lineIndex:i,parts:[o[1],o[2]]};let s=Ue.exec(r);if(s){let t=s[1],r=n.indexOf(t,a+5),o=null,c=null;if(s[2]!==void 0){let i=n.indexOf(`"`,r+t.length)+1;o=s[2],c=V(e,i,i+s[2].length)}return{kind:`classDecl`,lineIndex:i,id:t,idSpan:V(e,r,r+t.length),label:o,labelSpan:c,opensBlock:!!s[3]}}let c=He.exec(r);if(c){let[,t,o,s,l,u,d]=c,f=a+r.indexOf(t),p=null,m=f+t.length;if(o!==void 0){let t=n.indexOf(`"${o}"`,m);p=V(e,t+1,t+1+o.length),m=t+o.length+2}let h=n.indexOf(s,m),g=null;if(m=h+s.length,l!==void 0){let t=n.indexOf(`"${l}"`,m);g=V(e,t+1,t+1+l.length),m=t+l.length+2}let _=n.indexOf(u,m),v=null,y=null;if(d!==void 0){let t=n.indexOf(`:`,_+u.length);v=n.slice(t+1).trim(),y=V(e,t+1,n.length)}return{kind:`relation`,lineIndex:i,source:t,sourceSpan:V(e,f,f+t.length),target:u,targetSpan:V(e,_,_+u.length),op:s,opSpan:V(e,h,h+s.length),label:v,labelSpan:y,sourceCard:o??null,sourceCardSpan:p,targetCard:l??null,targetCardSpan:g}}let l=We.exec(r);if(l){let t=n.indexOf(`:`,a+l[1].length);return{kind:`member`,lineIndex:i,classId:l[1],text:l[2].trim(),textSpan:V(e,t+1,n.length)}}return{kind:`unknown`,lineIndex:i,parts:[]}}function Ke(e,t){let n=new Map,r=[],i=new Map,a=new Map,o=null,s=t,c=null,l=(e,t)=>{let r=n.get(e);return r||(r={entityId:`class:${e}`,id:e,label:e,decl:null,block:null,members:[],extraLines:[],refLines:[],firstRefLine:t},n.set(e,r)),r};for(let u of e){if(u.kind!==`statement`||u.index===t){u.index===t&&(s=u.index);continue}let e=Ge(u,c);switch(i.set(u.index,e),s=u.index,e.kind){case`classDecl`:{let t=l(e.id,e.lineIndex);t.decl=e,e.label!==null&&(t.label=e.label),t.refLines.push(e.lineIndex),e.opensBlock&&(t.block={open:e.lineIndex,close:-1},c=e.id);break}case`blockClose`:if(c){let t=n.get(c);t?.block&&(t.block.close=e.lineIndex),c=null}break;case`member`:{let t=e.classId??c;if(t){let n=l(t,e.lineIndex);n.members.push({lineIndex:e.lineIndex,text:e.text,textSpan:e.textSpan}),e.classId&&n.extraLines.push(e.lineIndex)}break}case`annotation`:e.parts.length===2&&l(e.parts[1],e.lineIndex).extraLines.push(e.lineIndex);break;case`relation`:{let t=l(e.source,e.lineIndex),n=l(e.target,e.lineIndex);t.refLines.push(e.lineIndex),n.refLines.push(e.lineIndex);let i=`${e.source}->${e.target}`,o=a.get(i)??0;a.set(i,o+1),r.push({entityId:`rel:${i}#${o}`,source:e.source,target:e.target,lineIndex:e.lineIndex,stmt:e,label:e.label,order:r.length});break}case`direction`:o={value:e.parts[0],lineIndex:e.lineIndex};break;default:break}}return{headerLine:t,classes:[...n.values()],classById:n,relations:r,statements:i,direction:o,lastContentLine:s}}function qe(e,t,n){if(n.startsWith(`class:`)){let r=e.classById.get(n.slice(6));if(!r)return[];let i=[];if(r.decl){let e=t[r.decl.lineIndex];i.push({start:e.start+e.indent.length,end:e.end})}for(let t of e.relations)t.source===r.id&&i.push(t.stmt.sourceSpan),t.target===r.id&&i.push(t.stmt.targetSpan);return i}if(n.startsWith(`rel:`)){let r=e.relations.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}return[]}function Je(e,t,n){for(let r of e.relations){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end)return n>=r.stmt.sourceSpan.start&&n<=r.stmt.sourceSpan.end?`class:${r.source}`:n>=r.stmt.targetSpan.start&&n<=r.stmt.targetSpan.end?`class:${r.target}`:r.entityId}for(let r of e.classes){let e=[...r.decl?[r.decl.lineIndex]:[],...r.members.map(e=>e.lineIndex),...r.extraLines];for(let i of e){let e=t[i];if(n>=e.start&&n<=e.end)return r.entityId}}return null}function H(e){for(let t of e.lines)if(t.kind===`statement`&&t.index!==e.graph.headerLine&&t.text.trim()!==``)return t.indent;return` `}function U(e,t,n){let r=e.lines[t];return{start:r.end,end:r.end,text:n.map(e=>`
10
+ ${e}`).join(``)}}function W(e,t){let n=e.lines[t];return n.end<e.code.length?{start:n.start,end:n.end+1,text:``}:n.start>0?{start:n.start-1,end:n.end,text:``}:{start:n.start,end:n.end,text:``}}function G(e,t){return e.relations.find(e=>e.entityId===t)??null}function Ye(e,t){let n=new Set(e.classes.map(e=>e.id));if(t&&!n.has(t))return t;let r=1;for(;n.has(`Class${r}`);)r++;return`Class${r}`}function K(e){return e.trim().replace(/[{}]/g,``)}function Xe(e,t){let{graph:n,lines:r}=e;switch(t.type){case`cl.addClass`:{let r=Ye(n,t.name?.replace(/[^\w.~]/g,``)),i=H(e);return{edits:[U(e,n.lastContentLine,[`${i}class ${r} {`,`${i}}`])],created:[`class:${r}`]}}case`cl.connect`:{if(!n.classById.has(t.source)||!n.classById.has(t.target))return null;let i=n.lastContentLine,a=-1;for(let e of[t.source,t.target]){let t=n.classById.get(e);if(t)for(let e of t.refLines)a=Math.max(a,t.block&&e===t.block.open?t.block.close:e)}a>=0&&(i=a);let o=r[i].kind===`statement`?r[i].indent:H(e),s=t.label?` : ${K(t.label)}`:``,c=n.relations.filter(e=>e.source===t.source&&e.target===t.target).length;return{edits:[U(e,i,[`${o}${t.source} ${t.op??`-->`} ${t.target}${s}`])],created:[`rel:${t.source}->${t.target}#${c}`]}}case`cl.renameClass`:{let e=n.classById.get(t.id);if(!e)return null;let i=t.name.trim().replace(/[^\w.~]/g,``);if(!i||n.classById.has(i))return null;let a=[];e.decl&&a.push({start:e.decl.idSpan.start,end:e.decl.idSpan.end,text:i});for(let e of n.relations)e.source===t.id&&a.push({start:e.stmt.sourceSpan.start,end:e.stmt.sourceSpan.end,text:i}),e.target===t.id&&a.push({start:e.stmt.targetSpan.start,end:e.stmt.targetSpan.end,text:i});for(let n of e.extraLines){let e=r[n],o=e.start+e.text.indexOf(t.id);o>=e.start&&a.push({start:o,end:o+t.id.length,text:i})}return{edits:a}}case`cl.setRelationType`:{let e=G(n,t.relId);return e?{edits:[{start:e.stmt.opSpan.start,end:e.stmt.opSpan.end,text:t.op}]}:null}case`cl.setRelationLabel`:{let e=G(n,t.relId);if(!e)return null;let i=K(t.label);return e.stmt.labelSpan?i?{edits:[{start:e.stmt.labelSpan.start,end:e.stmt.labelSpan.end,text:` ${i}`}]}:{edits:[{start:e.stmt.targetSpan.end,end:r[e.lineIndex].end,text:``}]}:i?{edits:[{start:e.stmt.targetSpan.end,end:e.stmt.targetSpan.end,text:` : ${i}`}]}:{edits:[]}}case`cl.reverseRelation`:{let e=G(n,t.relId);return e?{edits:[{start:e.stmt.sourceSpan.start,end:e.stmt.sourceSpan.end,text:e.target},{start:e.stmt.targetSpan.start,end:e.stmt.targetSpan.end,text:e.source}]}:null}case`cl.addMember`:{let i=n.classById.get(t.id);if(!i)return null;let a=K(t.text??`+attribute`);if(i.block&&i.block.close>=0){let t=r[i.block.open],n=i.members.length?r[i.members[i.members.length-1].lineIndex].indent:`${t.indent} `;return{edits:[U(e,i.members.length?i.members[i.members.length-1].lineIndex:i.block.open,[`${n}${a}`])]}}let o=i.decl?.lineIndex??i.firstRefLine,s=r[o];return{edits:[U(e,o,[`${s.indent}${i.id} : ${a}`])]}}case`cl.setMemberText`:{let r=n.classById.get(t.id);if(!r)return null;let i=r.members.find(e=>e.lineIndex===t.memberLine);if(!i)return null;let a=K(t.text);if(!a)return{edits:[W(e,i.lineIndex)]};let o=e.code.slice(i.textSpan.start-1,i.textSpan.start)===`:`?` `:``;return{edits:[{start:i.textSpan.start,end:i.textSpan.end,text:`${o}${a}`}]}}case`cl.deleteMember`:{let r=n.classById.get(t.id);return!r||!r.members.some(e=>e.lineIndex===t.memberLine)?null:{edits:[W(e,t.memberLine)]}}case`cl.deleteClass`:{let r=n.classById.get(t.id);if(!r)return null;let i=new Set;if(r.decl&&i.add(r.decl.lineIndex),r.block&&r.block.close>=0)for(let e=r.block.open;e<=r.block.close;e++)i.add(e);for(let e of r.extraLines)i.add(e);for(let e of r.members)i.add(e.lineIndex);for(let e of n.relations)(e.source===r.id||e.target===r.id)&&i.add(e.lineIndex);return{edits:[...i].map(t=>W(e,t))}}case`cl.deleteRelation`:{let r=G(n,t.relId);return r?{edits:[W(e,r.lineIndex)]}:null}case`cl.setAnnotation`:{let i=n.classById.get(t.id);if(!i)return null;let a=t.annotation?.replace(/[<>\s]/g,``)??null,o=-1;for(let[e,r]of n.statements)if(r.kind===`annotation`&&r.parts[1]===t.id){o=e;break}if(o>=0){if(!a)return{edits:[W(e,o)]};let n=r[o];return{edits:[{start:n.start,end:n.end,text:`${n.indent}<<${a}>> ${t.id}`}]}}if(!a)return{edits:[]};let s=i.decl?.lineIndex??i.firstRefLine,c=r[s];return{edits:[U(e,s,[`${c.indent}<<${a}>> ${t.id}`])]}}case`cl.addNoteFor`:{if(!n.classById.get(t.id))return null;let r=(t.text??`note`).replace(/"/g,`'`);return{edits:[U(e,n.lastContentLine,[`${H(e)}note for ${t.id} "${r}"`])]}}case`cl.setCardinality`:{let e=G(n,t.relId);if(!e)return null;let r=t.value?.replace(/"/g,``).trim()??null,i=t.side===`source`?e.stmt.sourceCardSpan:e.stmt.targetCardSpan;return i?r===null||r===``?{edits:[{start:i.start-2,end:i.end+1,text:``}]}:{edits:[{start:i.start,end:i.end,text:r}]}:r===null||r===``?{edits:[]}:t.side===`source`?{edits:[{start:e.stmt.sourceSpan.end,end:e.stmt.sourceSpan.end,text:` "${r}"`}]}:{edits:[{start:e.stmt.targetSpan.start,end:e.stmt.targetSpan.start,text:`"${r}" `}]}}case`cl.setDirection`:if(n.direction){let e=r[n.direction.lineIndex];return{edits:[{start:e.start,end:e.end,text:`${e.indent}direction ${t.direction}`}]}}return{edits:[U(e,n.headerLine,[`${H(e)}direction ${t.direction}`])]}}}var Ze=String.raw`[\w-]+`,Qe=new RegExp(String.raw`^(${Ze})\s*([|}o]{2})(--|\.\.)([o|{]{2})\s*(${Ze})\s*:\s*(.*)$`),$e=new RegExp(String.raw`^(${Ze})(\[[^\]]*\])?\s*(\{)?\s*$`);function q(e,t,n){return{start:e.start+t,end:e.start+n}}function et(e,t){let n=e.text,r=n.trim(),i=e.index,a=n.length-n.trimStart().length;if(r===`}`)return{kind:`blockClose`,lineIndex:i,parts:[]};if(t)return{kind:`attribute`,lineIndex:i,text:r,textSpan:q(e,a,n.length)};if(/^(direction|style|classDef|class)\b/.test(r))return{kind:`passthrough`,lineIndex:i,parts:[]};let o=Qe.exec(r);if(o){let[,t,r,s,c,l]=o,u=a,d=n.indexOf(r,u+t.length),f=d+r.length,p=f+s.length,m=n.indexOf(l,p+c.length),h=n.indexOf(`:`,m+l.length);return{kind:`relation`,lineIndex:i,source:t,sourceSpan:q(e,u,u+t.length),target:l,targetSpan:q(e,m,m+l.length),leftCard:r,leftCardSpan:q(e,d,d+r.length),rightCard:c,rightCardSpan:q(e,p,p+c.length),line:s,lineSpan:q(e,f,f+s.length),label:n.slice(h+1).trim(),labelSpan:q(e,h+1,n.length)}}let s=$e.exec(r);return s?{kind:`entityDecl`,lineIndex:i,id:s[1],idSpan:q(e,a,a+s[1].length),alias:s[2]?s[2].slice(1,-1):null,opensBlock:!!s[3]}:{kind:`unknown`,lineIndex:i,parts:[]}}function tt(e,t){let n=new Map,r=[],i=new Map,a=new Map,o=t,s=null,c=(e,t)=>{let r=n.get(e);return r||(r={entityId:`entity:${e}`,id:e,label:e,decl:null,block:null,attributes:[],refLines:[],firstRefLine:t},n.set(e,r)),r};for(let l of e){if(l.kind!==`statement`||l.index===t){l.index===t&&(o=l.index);continue}let e=et(l,s!==null);switch(i.set(l.index,e),o=l.index,e.kind){case`entityDecl`:{let t=c(e.id,e.lineIndex);t.decl=e,e.alias&&(t.label=e.alias),t.refLines.push(e.lineIndex),e.opensBlock&&(t.block={open:e.lineIndex,close:-1},s=e.id);break}case`blockClose`:if(s){let t=n.get(s);t?.block&&(t.block.close=e.lineIndex),s=null}break;case`attribute`:s&&c(s,e.lineIndex).attributes.push({lineIndex:e.lineIndex,text:e.text,textSpan:e.textSpan});break;case`relation`:{let t=c(e.source,e.lineIndex),n=c(e.target,e.lineIndex);t.refLines.push(e.lineIndex),n.refLines.push(e.lineIndex);let i=`${e.source}->${e.target}`,o=a.get(i)??0;a.set(i,o+1),r.push({entityId:`erel:${i}#${o}`,source:e.source,target:e.target,lineIndex:e.lineIndex,stmt:e,label:e.label,order:r.length});break}default:break}}return{headerLine:t,entities:[...n.values()],entityById:n,relations:r,statements:i,lastContentLine:o}}function nt(e,t,n){if(n.startsWith(`entity:`)){let r=e.entityById.get(n.slice(7));if(!r)return[];let i=[];if(r.decl){let e=t[r.decl.lineIndex];i.push({start:e.start+e.indent.length,end:e.end})}for(let t of e.relations)t.source===r.id&&i.push(t.stmt.sourceSpan),t.target===r.id&&i.push(t.stmt.targetSpan);return i}if(n.startsWith(`erel:`)){let r=e.relations.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}return[]}function rt(e,t,n){for(let r of e.relations){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end)return n>=r.stmt.sourceSpan.start&&n<=r.stmt.sourceSpan.end?`entity:${r.source}`:n>=r.stmt.targetSpan.start&&n<=r.stmt.targetSpan.end?`entity:${r.target}`:r.entityId}for(let r of e.entities){let e=[...r.decl?[r.decl.lineIndex]:[],...r.attributes.map(e=>e.lineIndex)];for(let i of e){let e=t[i];if(n>=e.start&&n<=e.end)return r.entityId}}return null}var it={"zero-or-one":`|o`,"exactly-one":`||`,"zero-or-more":`}o`,"one-or-more":`}|`},at={"zero-or-one":`o|`,"exactly-one":`||`,"zero-or-more":`o{`,"one-or-more":`|{`};function ot(e){for(let[t,n]of Object.entries(it))if(n===e)return t;for(let[t,n]of Object.entries(at))if(n===e)return t;return`exactly-one`}function st(e){for(let t of e.lines)if(t.kind===`statement`&&t.index!==e.graph.headerLine&&t.text.trim()!==``)return t.indent;return` `}function J(e,t,n){let r=e.lines[t];return{start:r.end,end:r.end,text:n.map(e=>`
11
+ ${e}`).join(``)}}function ct(e,t){let n=e.lines[t];return n.end<e.code.length?{start:n.start,end:n.end+1,text:``}:n.start>0?{start:n.start-1,end:n.end,text:``}:{start:n.start,end:n.end,text:``}}function Y(e,t){return e.relations.find(e=>e.entityId===t)??null}function lt(e,t){let{graph:n,lines:r}=e;switch(t.type){case`er.addEntity`:{let r=new Set(n.entities.map(e=>e.id)),i=t.name?.replace(/[^\w-]/g,``)||``;if(!i||r.has(i)){let e=1;for(;r.has(`ENTITY${e}`);)e++;i=`ENTITY${e}`}let a=st(e);return{edits:[J(e,n.lastContentLine,[`${a}${i} {`,`${a} string id`,`${a}}`])],created:[`entity:${i}`]}}case`er.connect`:{if(!n.entityById.has(t.source)||!n.entityById.has(t.target))return null;let i=n.lastContentLine,a=-1;for(let e of[t.source,t.target]){let t=n.entityById.get(e);if(t)for(let e of t.refLines)a=Math.max(a,t.block&&e===t.block.open?t.block.close:e)}a>=0&&(i=a);let o=r[i].kind===`statement`?r[i].indent:st(e),s=(t.label??`relates`).replace(/[:{}]/g,``).trim()||`relates`,c=n.relations.filter(e=>e.source===t.source&&e.target===t.target).length;return{edits:[J(e,i,[`${o}${t.source} ||--o{ ${t.target} : ${s}`])],created:[`erel:${t.source}->${t.target}#${c}`]}}case`er.renameEntity`:{let e=n.entityById.get(t.id);if(!e)return null;let r=t.name.trim().replace(/[^\w-]/g,``);if(!r||n.entityById.has(r))return null;let i=[];e.decl&&i.push({start:e.decl.idSpan.start,end:e.decl.idSpan.end,text:r});for(let e of n.relations)e.source===t.id&&i.push({start:e.stmt.sourceSpan.start,end:e.stmt.sourceSpan.end,text:r}),e.target===t.id&&i.push({start:e.stmt.targetSpan.start,end:e.stmt.targetSpan.end,text:r});return{edits:i}}case`er.setCardinality`:{let e=Y(n,t.relId);return e?t.side===`left`?{edits:[{start:e.stmt.leftCardSpan.start,end:e.stmt.leftCardSpan.end,text:it[t.card]}]}:{edits:[{start:e.stmt.rightCardSpan.start,end:e.stmt.rightCardSpan.end,text:at[t.card]}]}:null}case`er.setIdentifying`:{let e=Y(n,t.relId);return e?{edits:[{start:e.stmt.lineSpan.start,end:e.stmt.lineSpan.end,text:t.identifying?`--`:`..`}]}:null}case`er.setRelationLabel`:{let e=Y(n,t.relId);if(!e)return null;let r=t.label.replace(/[:{}]/g,``).trim()||`relates`;return{edits:[{start:e.stmt.labelSpan.start,end:e.stmt.labelSpan.end,text:` ${r}`}]}}case`er.addAttribute`:{let i=n.entityById.get(t.id);if(!i)return null;let a=(t.text??`string attribute`).replace(/[{}]/g,``).trim();if(i.block&&i.block.close>=0){let t=r[i.block.open],n=i.attributes.length?r[i.attributes[i.attributes.length-1].lineIndex].indent:`${t.indent} `;return{edits:[J(e,i.attributes.length?i.attributes[i.attributes.length-1].lineIndex:i.block.open,[`${n}${a}`])]}}let o=r[i.firstRefLine];return{edits:[J(e,i.firstRefLine,[`${o.indent}${i.id} {`,`${o.indent} ${a}`,`${o.indent}}`])]}}case`er.setAttributeText`:{let i=n.entityById.get(t.id);if(!i)return null;let a=i.attributes.find(e=>e.lineIndex===t.attrLine);if(!a)return null;let o=t.text.replace(/[{}]/g,``).trim();if(!o)return{edits:[ct(e,a.lineIndex)]};let s=r[a.lineIndex];return{edits:[{start:s.start,end:s.end,text:`${s.indent}${o}`}]}}case`er.deleteEntity`:{let r=n.entityById.get(t.id);if(!r)return null;let i=new Set;if(r.decl&&i.add(r.decl.lineIndex),r.block&&r.block.close>=0)for(let e=r.block.open;e<=r.block.close;e++)i.add(e);for(let e of n.relations)(e.source===r.id||e.target===r.id)&&i.add(e.lineIndex);return{edits:[...i].map(t=>ct(e,t))}}case`er.deleteRelation`:{let r=Y(n,t.relId);return r?{edits:[ct(e,r.lineIndex)]}:null}}}var ut=/^"([^"]*)"\s*:\s*([\d.]+)\s*$/;function dt(e,t){let n=[],r=t;for(let i of e){if(i.kind!==`statement`||i.index===t){i.index===t&&(r=i.index);continue}r=i.index;let e=ut.exec(i.text.trim());if(!e)continue;let a=i.start+i.text.indexOf(`"`)+1,o=i.start+i.text.lastIndexOf(e[2]);n.push({entityId:`slice:${i.index}`,label:e[1],value:Number(e[2]),lineIndex:i.index,labelSpan:{start:a,end:a+e[1].length},valueSpan:{start:o,end:o+e[2].length}})}return{headerLine:t,showData:/\bshowData\b/.test(e[t]?.text??``),slices:n,lastContentLine:r}}function ft(e,t){let{graph:n,lines:r}=e,i=e=>n.slices.find(t=>t.entityId===e)??null;switch(t.type){case`pie.setValue`:{let e=i(t.sliceId);return!e||!Number.isFinite(t.value)||t.value<0?null:{edits:[{start:e.valueSpan.start,end:e.valueSpan.end,text:String(t.value)}]}}case`pie.setLabel`:{let e=i(t.sliceId);return e?{edits:[{start:e.labelSpan.start,end:e.labelSpan.end,text:t.label.replace(/"/g,`'`)}]}:null}case`pie.addSlice`:{let e=n.slices.length?n.slices[n.slices.length-1].lineIndex:n.lastContentLine,i=r[e],a=`${n.slices.length?i.indent:` `}"${(t.label??`New slice`).replace(/"/g,`'`)}" : ${t.value??10}`;return{edits:[{start:i.end,end:i.end,text:`
12
+ ${a}`}],created:[`slice:${e+1}`]}}case`pie.deleteSlice`:{let n=i(t.sliceId);if(!n)return null;let a=r[n.lineIndex];return a.end<e.code.length?{edits:[{start:a.start,end:a.end+1,text:``}]}:{edits:[{start:Math.max(0,a.start-1),end:a.end,text:``}]}}}}function pt(e,t,n){let r=e.slices.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}function mt(e,t,n){for(let r of e.slices){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end)return r.entityId}return null}var ht=/^(dateFormat|axisFormat|tickInterval|excludes|includes|todayMarker|title|weekday|inclusiveEndDates|topAxis)\b/,gt=/^section\s+(.+)$/,_t=/^(.+?)\s*:\s*(.+)$/;function vt(e,t){let n=[],r=[],i=null,a=t;for(let o of e){if(o.kind!==`statement`||o.index===t){o.index===t&&(a=o.index);continue}a=o.index;let e=o.text.trim();if(ht.test(e))continue;let s=gt.exec(e);if(s){i=s[1].trim(),r.push({name:i,lineIndex:o.index});continue}let c=_t.exec(e);if(c){let e=o.start+o.indent.length,t=o.text.indexOf(`:`,o.indent.length+c[1].length-1),r=o.start+t+1;n.push({entityId:`task:${o.index}`,name:c[1].trim(),meta:c[2].trim(),lineIndex:o.index,nameSpan:{start:e,end:e+c[1].trimEnd().length},metaSpan:{start:r,end:o.end},section:i})}}return{headerLine:t,tasks:n,sections:r,lastContentLine:a}}function yt(e,t){let{graph:n,lines:r}=e,i=e=>n.tasks.find(t=>t.entityId===e)??null;switch(t.type){case`gantt.setTaskName`:{let e=i(t.taskId);if(!e)return null;let n=t.name.trim().replace(/[:#]/g,``);return n?{edits:[{start:e.nameSpan.start,end:e.nameSpan.end,text:n}]}:null}case`gantt.setTaskMeta`:{let e=i(t.taskId);if(!e)return null;let n=t.meta.trim().replace(/:/g,``);return n?{edits:[{start:e.metaSpan.start,end:e.metaSpan.end,text:` ${n}`}]}:null}case`gantt.addTask`:{let e=t.section?n.tasks.filter(e=>e.section===t.section):n.tasks,i=e.length?e[e.length-1].lineIndex:n.sections.length?n.sections[n.sections.length-1].lineIndex:n.lastContentLine,a=r[i],o=e.length?a.indent:`${a.indent} `,s=(t.name??`New task`).replace(/[:#]/g,``),c=(t.meta??`1d`).replace(/:/g,``);return{edits:[{start:a.end,end:a.end,text:`
13
+ ${o}${s} :${c}`}],created:[`task:${i+1}`]}}case`gantt.deleteTask`:{let n=i(t.taskId);if(!n)return null;let a=r[n.lineIndex];return a.end<e.code.length?{edits:[{start:a.start,end:a.end+1,text:``}]}:{edits:[{start:Math.max(0,a.start-1),end:a.end,text:``}]}}}}function bt(e,t,n){let r=e.tasks.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}function xt(e,t,n){for(let r of e.tasks){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end)return r.entityId}return null}var X=e=>/"([^"]+)"/.exec(e)?.[1]??null,Z=e=>{let t=/\[([^\]]+)\]|\(\(([^)]+)\)\)|\(([^)]+)\)|\{\{([^}]+)\}\}/.exec(e);return t?(t[1]??t[2]??t[3]??t[4])?.replace(/^"|"$/g,``)??null:null},St=e=>{let t=e.indexOf(`:`);return t>0?e.slice(0,t).trim():null},Ct=(e,t)=>{let n=t.exec(e);return n&&e.slice(n[0].length).trim()||null},Q={journey:{match:e=>Ct(e,/^(title|section)\s+/)??St(e),addTemplate:`New task: 3: Me`},timeline:{match:e=>{let t=Ct(e,/^title\s+/);if(t)return t;let n=e.split(`:`).map(e=>e.trim()).filter(Boolean);return n.length?n[n.length-1]:null},addTemplate:`2030 : New event`},quadrant:{match:e=>/^(title|x-axis|y-axis|quadrant-\d)/.test(e)?null:St(e),addTemplate:`New point: [0.5, 0.5]`},kanban:{match:e=>Z(e)??(/^\S/.test(e)?e:null),addTemplate:` [New card]`},mindmap:{match:e=>Z(e)??(e.replace(/^::icon.*$/,``)||null),addTemplate:` New idea`},treemap:{match:e=>X(e),addTemplate:`"New item": 10`},packet:{match:e=>X(e),addTemplate:`96-127: "New Field"`},sankey:{match:e=>e.split(`,`)[0]?.trim().replace(/^"|"$/g,``)||null,addTemplate:`Source,Target,10`},radar:{match:e=>X(e),addTemplate:`curve new["New"]{50, 50, 50}`},gitgraph:{match:e=>X(e)??Ct(e,/^(branch|checkout|merge)\s+/),addTemplate:`commit`},xychart:{match:e=>/^title\b/.test(e)?X(e):null,addTemplate:`bar [10, 20, 30]`},architecture:{match:e=>Z(e),addTemplate:`service new1(server)[New Service]`},requirement:{match:e=>/^(requirement|element|functionalRequirement|interface|performanceRequirement|physicalRequirement|designConstraint)\s+(\w+)/.exec(e)?.[2]??null,addTemplate:`element new_element {`},c4:{match:e=>X(e),addTemplate:`Person(newPerson, "New Person", "Description")`},block:{match:e=>Z(e)??(/^[\w]+$/.test(e)?e:null),addTemplate:`newBlock["New Block"]`}};function wt(e,t,n){let r=Q[n];if(!r)return null;let i=[],a=t;for(let n of e){if(n.kind!==`statement`||n.index===t){n.index===t&&(a=n.index);continue}a=n.index;let e=n.text.trim();e===`}`||e===`end`||i.push({entityId:`item:${n.index}`,text:e,matchText:r.match(e),lineIndex:n.index})}return{typeId:n,headerLine:t,items:i,lastContentLine:a,addTemplate:r.addTemplate}}function Tt(e,t){let{graph:n,lines:r}=e,i=e=>n.items.find(t=>t.entityId===e)??null;switch(t.type){case`li.setLine`:{let n=i(t.itemId);if(!n)return null;let a=t.text.replace(/\n/g,` `).trim(),o=r[n.lineIndex];return a?{edits:[{start:o.start,end:o.end,text:`${o.indent}${a}`}]}:o.end<e.code.length?{edits:[{start:o.start,end:o.end+1,text:``}]}:{edits:[{start:Math.max(0,o.start-1),end:o.end,text:``}]}}case`li.addItem`:{let e=n.items.length?n.items[n.items.length-1].lineIndex:n.lastContentLine,i=r[e],a=n.items.length?i.indent:` `,o=(t.text??n.addTemplate).replace(/\n/g,` `);return{edits:[{start:i.end,end:i.end,text:`
14
+ ${a}${o.trim()}`}],created:[`item:${e+1}`]}}case`li.deleteItem`:{let n=i(t.itemId);if(!n)return null;let a=r[n.lineIndex];return a.end<e.code.length?{edits:[{start:a.start,end:a.end+1,text:``}]}:{edits:[{start:Math.max(0,a.start-1),end:a.end,text:``}]}}}}function Et(e,t,n){let r=e.items.find(e=>e.entityId===n);if(!r)return[];let i=t[r.lineIndex];return[{start:i.start+i.indent.length,end:i.end}]}function Dt(e,t,n){for(let r of e.items){let e=t[r.lineIndex];if(n>=e.start&&n<=e.end)return r.entityId}return null}function $(e){let t=i(e),{headerIndex:n}=a(t),o=n>=0?r(t[n].text):null,s=null,c=null,l=null,u=null,d=null,f=null,p=null,m=null;try{o?.id===`flowchart`?s=g(t,n):o?.id===`sequence`?c=ve(t,n):o?.id===`state`?l=Ne(t,n):o?.id===`class`?u=Ke(t,n):o?.id===`er`?d=tt(t,n):o?.id===`pie`?f=dt(t,n):o?.id===`gantt`?p=vt(t,n):o&&Q[o.id]&&(m=wt(t,n,o.id))}catch{}return{code:e,lines:t,headerIndex:n,typeInfo:o,flowchart:s,sequence:c,state:l,classGraph:u,er:d,pie:f,gantt:p,lineItems:m}}var Ot=class{_code;_result;_selection=[];undoStack=[];redoStack=[];listeners={change:new Set,selectionChange:new Set,diagnostics:new Set};coalesceMs;_diagnostics=[];constructor(e={}){this._code=e.code??`flowchart TD
15
+ A[Start] --> B[End]`,this.coalesceMs=e.coalesceMs??750,this._result=$(this._code)}get code(){return this._code}get result(){return this._result}get selection(){return this._selection}get diagnostics(){return this._diagnostics}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}on(e,t){return this.listeners[e].add(t),()=>this.listeners[e].delete(t)}emit(e,t){for(let n of this.listeners[e])n(t)}setDiagnostics(e){this._diagnostics=e,this.emit(`diagnostics`,e)}applyEdits(e,t=`api`){if(e.length===0)return;let{text:n,inverse:r}=o(this._code,e);if(n===this._code)return;let i={edits:e,inverse:r,origin:t,selectionBefore:[...this._selection],selectionAfter:[...this._selection],time:Date.now()};this.commit(n,i,t)}setCode(e,t=`code`){let n=s(this._code,e);if(!n)return;let{text:r,inverse:i}=o(this._code,[n]),a=Date.now(),c=this.undoStack[this.undoStack.length-1];if(t===`code`&&c&&c.origin===`code`&&a-c.time<this.coalesceMs&&this.redoStack.length===0){let e=o(this._code,c.inverse).text,i=s(e,r),l=s(r,e);c.edits=i?[i]:[],c.inverse=l?[l]:[],c.time=a,this._code=r,this._result=$(r),this.pruneSelection(),this.emit(`change`,{code:r,edits:[n],origin:t,result:this._result});return}let l={edits:[n],inverse:i,origin:t,selectionBefore:[...this._selection],selectionAfter:[...this._selection],time:a};this.commit(r,l,t)}commit(e,t,n){this._code=e,this._result=$(e),this.undoStack.push(t),this.redoStack=[],this.pruneSelection(),t.selectionAfter=[...this._selection],this.emit(`change`,{code:e,edits:t.edits,origin:n,result:this._result})}undo(){let e=this.undoStack.pop();if(!e)return!1;let{text:t}=o(this._code,e.inverse);return this.redoStack.push(e),this._code=t,this._result=$(t),this._selection=e.selectionBefore.filter(e=>this.entityExists(e)),this.emit(`change`,{code:t,edits:e.inverse,origin:`history`,result:this._result}),this.emit(`selectionChange`,{entityIds:this._selection,spans:this.selectionSpans(),origin:`history`}),!0}redo(){let e=this.redoStack.pop();if(!e)return!1;let{text:t}=o(this._code,e.edits);return this.undoStack.push(e),this._code=t,this._result=$(t),this._selection=e.selectionAfter.filter(e=>this.entityExists(e)),this.emit(`change`,{code:t,edits:e.edits,origin:`history`,result:this._result}),this.emit(`selectionChange`,{entityIds:this._selection,spans:this.selectionSpans(),origin:`history`}),!0}dispatch(e,t=`canvas`){let{flowchart:n,sequence:r,state:i,classGraph:a,er:o,pie:s,gantt:c,lineItems:l,lines:u}=this._result,d=null;if(e.type.startsWith(`seq.`)){if(!r)return null;d=we({code:this._code,lines:u,graph:r},e)}else if(e.type.startsWith(`st.`)){if(!i)return null;d=Re({code:this._code,lines:u,graph:i},e)}else if(e.type.startsWith(`cl.`)){if(!a)return null;d=Xe({code:this._code,lines:u,graph:a},e)}else if(e.type.startsWith(`er.`)){if(!o)return null;d=lt({code:this._code,lines:u,graph:o},e)}else if(e.type.startsWith(`pie.`)){if(!s)return null;d=ft({code:this._code,lines:u,graph:s},e)}else if(e.type.startsWith(`gantt.`)){if(!c)return null;d=yt({code:this._code,lines:u,graph:c},e)}else if(e.type.startsWith(`li.`)){if(!l)return null;d=Tt({code:this._code,lines:u,graph:l},e)}else{if(!n)return null;d=oe({code:this._code,lines:u,graph:n},e)}return!d||d.edits.length===0?d:(this.applyEdits(d.edits,t),d.created?.length&&this.setSelection(d.created,t),d)}deleteEntities(e,t=`canvas`){let n=e=>e.startsWith(`edge:`)||e.startsWith(`event:`)||e.startsWith(`trans:`)||e.startsWith(`rel:`)||e.startsWith(`erel:`)?0:1;for(let r of[...e].sort((e,t)=>n(e)-n(t)))this.entityExists(r)&&(r.startsWith(`edge:`)?this.dispatch({type:`deleteEdge`,edgeId:r},t):r.startsWith(`node:`)?this.dispatch({type:`deleteNode`,id:r.slice(5)},t):r.startsWith(`event:`)?this.dispatch({type:`seq.deleteEvent`,eventId:r},t):r.startsWith(`participant:`)?this.dispatch({type:`seq.deleteParticipant`,id:r.slice(12)},t):r.startsWith(`trans:`)?this.dispatch({type:`st.deleteTransition`,transId:r},t):r.startsWith(`state:`)?this.dispatch({type:`st.deleteState`,id:r.slice(6)},t):r.startsWith(`rel:`)?this.dispatch({type:`cl.deleteRelation`,relId:r},t):r.startsWith(`class:`)?this.dispatch({type:`cl.deleteClass`,id:r.slice(6)},t):r.startsWith(`erel:`)?this.dispatch({type:`er.deleteRelation`,relId:r},t):r.startsWith(`entity:`)?this.dispatch({type:`er.deleteEntity`,id:r.slice(7)},t):r.startsWith(`slice:`)?this.dispatch({type:`pie.deleteSlice`,sliceId:r},t):r.startsWith(`task:`)?this.dispatch({type:`gantt.deleteTask`,taskId:r},t):r.startsWith(`item:`)&&this.dispatch({type:`li.deleteItem`,itemId:r},t))}entityExists(e){let t=this._result.flowchart;if(t){if(e.startsWith(`node:`))return t.nodeById.has(e.slice(5));if(e.startsWith(`edge:`))return t.edges.some(t=>t.entityId===e);if(e.startsWith(`subgraph:`))return t.subgraphs.some(t=>t.entityId===e)}let n=this._result.sequence;if(n){if(e.startsWith(`participant:`))return n.participantById.has(e.slice(12));if(e.startsWith(`event:`))return n.events.some(t=>t.entityId===e)}let r=this._result.state;if(r){if(e.startsWith(`state:`))return r.stateById.has(e.slice(6));if(e.startsWith(`trans:`))return r.transitions.some(t=>t.entityId===e)}let i=this._result.classGraph;if(i){if(e.startsWith(`class:`))return i.classById.has(e.slice(6));if(e.startsWith(`rel:`))return i.relations.some(t=>t.entityId===e)}let a=this._result.er;if(a){if(e.startsWith(`entity:`))return a.entityById.has(e.slice(7));if(e.startsWith(`erel:`))return a.relations.some(t=>t.entityId===e)}let o=this._result.pie;if(o&&e.startsWith(`slice:`))return o.slices.some(t=>t.entityId===e);let s=this._result.gantt;if(s&&e.startsWith(`task:`))return s.tasks.some(t=>t.entityId===e);let c=this._result.lineItems;return c&&e.startsWith(`item:`)?c.items.some(t=>t.entityId===e):!1}setSelection(e,t=`api`){let n=e.filter(e=>this.entityExists(e));n.length===this._selection.length&&n.every((e,t)=>e===this._selection[t])||(this._selection=n,this.emit(`selectionChange`,{entityIds:n,spans:this.selectionSpans(),origin:t}))}clearSelection(e=`api`){this.setSelection([],e)}pruneSelection(){this._selection=this._selection.filter(e=>this.entityExists(e))}selectionSpans(){return this._selection.flatMap(e=>this.entityRanges(e))}entityRanges(e){let{flowchart:t,sequence:n,state:r,classGraph:i,er:a,pie:o,gantt:s,lineItems:c,lines:l}=this._result;return t?_(t,l,e):n?ye(n,l,e):r?Pe(r,l,e):i?qe(i,l,e):a?nt(a,l,e):o?pt(o,l,e):s?bt(s,l,e):c?Et(c,l,e):[]}entityAt(e){let{flowchart:t,sequence:n,state:r,classGraph:i,er:a,pie:o,gantt:s,lineItems:c,lines:l}=this._result;return t?v(t,e):n?be(n,l,e):r?Fe(r,l,e):i?Je(i,l,e):a?rt(a,l,e):o?mt(o,l,e):s?xt(s,l,e):c?Dt(c,l,e):null}};export{n as DIAGRAM_TYPES,Q as LINE_ITEM_CONFIGS,ce as MESSAGE_OPS,Ot as MermaidWysiwygEditor,se as PARTICIPANT_TYPES,ze as RELATION_OPS,d as SHAPE_DELIMS,o as applyEdits,e as bindTextPane,Ke as buildClassGraph,tt as buildErGraph,g as buildFlowGraph,vt as buildGanttGraph,wt as buildLineItemsGraph,dt as buildPieGraph,ve as buildSequenceGraph,Ne as buildStateGraph,ot as cardinalityFromGlyph,Je as classEntityAt,qe as classEntitySpans,a as classifyLines,Xe as compileClassOp,lt as compileErOp,oe as compileFlowchartOp,yt as compileGanttOp,Tt as compileLineItemOp,ft as compilePieOp,we as compileSequenceOp,Re as compileStateOp,r as detectDiagramType,s as diffText,v as entityAtOffset,_ as entitySpans,rt as erEntityAt,nt as erEntitySpans,xt as ganttEntityAt,bt as ganttEntitySpans,Dt as lineItemAt,Et as lineItemSpans,c as mapOffset,$ as parse,Ge as parseClassStatement,et as parseErStatement,h as parseFlowHeader,m as parseFlowStatement,_e as parseSequenceStatement,Me as parseStateStatement,mt as pieEntityAt,pt as pieEntitySpans,i as scanLines,be as sequenceEntityAt,ye as sequenceEntitySpans,Fe as stateEntityAt,Pe as stateEntitySpans};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{c as r,i,l as a,o,t as s}from"./dist-DTFuvKje.js";import{_ as c,a as l,c as u,d,f,g as p,h as m,i as h,l as g,m as _,n as ee,o as te,p as ne,r as re,s as ie,t as v,u as y}from"./dist-d0R4nnoB.js";var b=e(n(),1),x=t(),S=`ContextMenu`,[C,ae]=r(S,[c]),w=c(),[oe,T]=C(S),E=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:a=!0}=e,[o,c]=b.useState(!1),l=w(t),u=s(r),d=b.useCallback(e=>{c(e),u(e)},[u]);return(0,x.jsx)(oe,{scope:t,open:o,onOpenChange:d,modal:a,children:(0,x.jsx)(f,{...l,dir:i,open:o,onOpenChange:d,modal:a,children:n})})};E.displayName=S;var D=`ContextMenuTrigger`,O=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,s=T(D,n),c=w(n),l=b.useRef({x:0,y:0}),u=b.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=b.useRef(0),f=b.useCallback(()=>window.clearTimeout(d.current),[]),p=e=>{l.current={x:e.clientX,y:e.clientY},s.onOpenChange(!0)};return b.useEffect(()=>f,[f]),b.useEffect(()=>void(r&&f()),[r,f]),(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(v,{...c,virtualRef:u}),(0,x.jsx)(a.span,{"data-state":s.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:o(e.onContextMenu,e=>{f(),p(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:o(e.onPointerDown,Q(e=>{f(),d.current=window.setTimeout(()=>p(e),700)})),onPointerMove:r?e.onPointerMove:o(e.onPointerMove,Q(f)),onPointerCancel:r?e.onPointerCancel:o(e.onPointerCancel,Q(f)),onPointerUp:r?e.onPointerUp:o(e.onPointerUp,Q(f))})]})});O.displayName=D;var se=`ContextMenuPortal`,k=e=>{let{__scopeContextMenu:t,...n}=e,r=w(t);return(0,x.jsx)(g,{...r,...n})};k.displayName=se;var A=`ContextMenuContent`,j=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=T(A,n),a=w(n),o=b.useRef(!1);return(0,x.jsx)(h,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});j.displayName=A;var M=`ContextMenuGroup`,N=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(l,{...i,...r,ref:t})});N.displayName=M;var P=`ContextMenuLabel`,F=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(u,{...i,...r,ref:t})});F.displayName=P;var I=`ContextMenuItem`,L=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(te,{...i,...r,ref:t})});L.displayName=I;var R=`ContextMenuCheckboxItem`,z=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(re,{...i,...r,ref:t})});z.displayName=R;var B=`ContextMenuRadioGroup`,V=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(y,{...i,...r,ref:t})});V.displayName=B;var H=`ContextMenuRadioItem`,U=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(d,{...i,...r,ref:t})});U.displayName=H;var W=`ContextMenuItemIndicator`,G=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(ie,{...i,...r,ref:t})});G.displayName=W;var K=`ContextMenuSeparator`,q=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(ne,{...i,...r,ref:t})});q.displayName=K;var ce=`ContextMenuArrow`,le=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(ee,{...i,...r,ref:t})});le.displayName=ce;var J=`ContextMenuSub`,Y=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:a,defaultOpen:o}=e,s=w(t),[c,l]=i({prop:a,defaultProp:o??!1,onChange:r,caller:J});return(0,x.jsx)(_,{...s,open:c,onOpenChange:l,children:n})};Y.displayName=J;var ue=`ContextMenuSubTrigger`,X=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(p,{...i,...r,ref:t})});X.displayName=ue;var de=`ContextMenuSubContent`,Z=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(m,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Z.displayName=de;function Q(e){return t=>t.pointerType===`mouse`?void 0:e(t)}var fe=E,pe=O,me=k,he=j,ge=N,$=F,_e=L,ve=z,ye=G,be=q,xe=Y,Se=X,Ce=Z;export{ye as a,fe as c,Ce as d,Se as f,_e as i,be as l,he as n,$ as o,pe as p,ge as r,me as s,ve as t,xe as u};
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{c as r,i,l as a,o,t as s}from"./dist-DTFuvKje.js";import{_ as c,a as l,c as u,d,f,g as p,h as m,i as h,l as g,m as _,n as ee,o as te,p as ne,r as re,s as ie,t as v,u as y}from"./dist-d2WYntJB.js";var b=e(n(),1),x=t(),S=`ContextMenu`,[C,ae]=r(S,[c]),w=c(),[oe,T]=C(S),E=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:a=!0}=e,[o,c]=b.useState(!1),l=w(t),u=s(r),d=b.useCallback(e=>{c(e),u(e)},[u]);return(0,x.jsx)(oe,{scope:t,open:o,onOpenChange:d,modal:a,children:(0,x.jsx)(f,{...l,dir:i,open:o,onOpenChange:d,modal:a,children:n})})};E.displayName=S;var D=`ContextMenuTrigger`,O=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,s=T(D,n),c=w(n),l=b.useRef({x:0,y:0}),u=b.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=b.useRef(0),f=b.useCallback(()=>window.clearTimeout(d.current),[]),p=e=>{l.current={x:e.clientX,y:e.clientY},s.onOpenChange(!0)};return b.useEffect(()=>f,[f]),b.useEffect(()=>void(r&&f()),[r,f]),(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(v,{...c,virtualRef:u}),(0,x.jsx)(a.span,{"data-state":s.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:o(e.onContextMenu,e=>{f(),p(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:o(e.onPointerDown,Q(e=>{f(),d.current=window.setTimeout(()=>p(e),700)})),onPointerMove:r?e.onPointerMove:o(e.onPointerMove,Q(f)),onPointerCancel:r?e.onPointerCancel:o(e.onPointerCancel,Q(f)),onPointerUp:r?e.onPointerUp:o(e.onPointerUp,Q(f))})]})});O.displayName=D;var se=`ContextMenuPortal`,k=e=>{let{__scopeContextMenu:t,...n}=e,r=w(t);return(0,x.jsx)(g,{...r,...n})};k.displayName=se;var A=`ContextMenuContent`,j=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=T(A,n),a=w(n),o=b.useRef(!1);return(0,x.jsx)(h,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});j.displayName=A;var M=`ContextMenuGroup`,N=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(l,{...i,...r,ref:t})});N.displayName=M;var P=`ContextMenuLabel`,F=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(u,{...i,...r,ref:t})});F.displayName=P;var I=`ContextMenuItem`,L=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(te,{...i,...r,ref:t})});L.displayName=I;var R=`ContextMenuCheckboxItem`,z=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(re,{...i,...r,ref:t})});z.displayName=R;var B=`ContextMenuRadioGroup`,V=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(y,{...i,...r,ref:t})});V.displayName=B;var H=`ContextMenuRadioItem`,U=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(d,{...i,...r,ref:t})});U.displayName=H;var W=`ContextMenuItemIndicator`,G=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(ie,{...i,...r,ref:t})});G.displayName=W;var K=`ContextMenuSeparator`,q=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(ne,{...i,...r,ref:t})});q.displayName=K;var ce=`ContextMenuArrow`,le=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(ee,{...i,...r,ref:t})});le.displayName=ce;var J=`ContextMenuSub`,Y=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:a,defaultOpen:o}=e,s=w(t),[c,l]=i({prop:a,defaultProp:o??!1,onChange:r,caller:J});return(0,x.jsx)(_,{...s,open:c,onOpenChange:l,children:n})};Y.displayName=J;var ue=`ContextMenuSubTrigger`,X=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(p,{...i,...r,ref:t})});X.displayName=ue;var de=`ContextMenuSubContent`,Z=b.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=w(n);return(0,x.jsx)(m,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Z.displayName=de;function Q(e){return t=>t.pointerType===`mouse`?void 0:e(t)}var fe=E,pe=O,me=k,he=j,ge=N,$=F,_e=L,ve=z,ye=G,be=q,xe=Y,Se=X,Ce=Z;export{ye as a,fe as c,Ce as d,Se as f,_e as i,be as l,he as n,$ as o,pe as p,ge as r,me as s,ve as t,xe as u};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{i as r}from"./dist-CSCUSbQc.js";import{c as i,i as a,l as o,n as s,o as c}from"./dist-DTFuvKje.js";import{_ as l,a as u,c as d,d as f,f as p,g as m,h,i as ee,l as g,m as te,n as _,o as v,p as y,r as ne,s as re,t as b,u as x}from"./dist-d0R4nnoB.js";var S=e(n(),1),C=t(),w=`DropdownMenu`,[T,ie]=i(w,[l]),E=l(),[D,O]=T(w),k=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:c,modal:l=!0}=e,u=E(t),d=S.useRef(null),[f,m]=a({prop:i,defaultProp:o??!1,onChange:c,caller:w});return(0,C.jsx)(D,{scope:t,triggerId:s(),triggerRef:d,contentId:s(),open:f,onOpenChange:m,onOpenToggle:S.useCallback(()=>m(e=>!e),[m]),modal:l,children:(0,C.jsx)(p,{...u,open:f,onOpenChange:m,dir:r,modal:l,children:n})})};k.displayName=w;var A=`DropdownMenuTrigger`,j=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:i=!1,...a}=e,s=O(A,n),l=E(n);return(0,C.jsx)(b,{asChild:!0,...l,children:(0,C.jsx)(o.button,{type:`button`,id:s.triggerId,"aria-haspopup":`menu`,"aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?`open`:`closed`,"data-disabled":i?``:void 0,disabled:i,...a,ref:r(t,s.triggerRef),onPointerDown:c(e.onPointerDown,e=>{!i&&e.button===0&&e.ctrlKey===!1&&(s.onOpenToggle(),s.open||e.preventDefault())}),onKeyDown:c(e.onKeyDown,e=>{i||([`Enter`,` `].includes(e.key)&&s.onOpenToggle(),e.key===`ArrowDown`&&s.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});j.displayName=A;var M=`DropdownMenuPortal`,N=e=>{let{__scopeDropdownMenu:t,...n}=e,r=E(t);return(0,C.jsx)(g,{...r,...n})};N.displayName=M;var P=`DropdownMenuContent`,F=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=O(P,n),a=E(n),o=S.useRef(!1);return(0,C.jsx)(ee,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:c(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:c(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});F.displayName=P;var I=`DropdownMenuGroup`,L=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(u,{...i,...r,ref:t})});L.displayName=I;var R=`DropdownMenuLabel`,z=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(d,{...i,...r,ref:t})});z.displayName=R;var B=`DropdownMenuItem`,V=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(v,{...i,...r,ref:t})});V.displayName=B;var H=`DropdownMenuCheckboxItem`,U=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(ne,{...i,...r,ref:t})});U.displayName=H;var W=`DropdownMenuRadioGroup`,G=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(x,{...i,...r,ref:t})});G.displayName=W;var K=`DropdownMenuRadioItem`,q=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(f,{...i,...r,ref:t})});q.displayName=K;var J=`DropdownMenuItemIndicator`,Y=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(re,{...i,...r,ref:t})});Y.displayName=J;var X=`DropdownMenuSeparator`,Z=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(y,{...i,...r,ref:t})});Z.displayName=X;var ae=`DropdownMenuArrow`,oe=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(_,{...i,...r,ref:t})});oe.displayName=ae;var se=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:o}=e,s=E(t),[c,l]=a({prop:r,defaultProp:o??!1,onChange:i,caller:`DropdownMenuSub`});return(0,C.jsx)(te,{...s,open:c,onOpenChange:l,children:n})},ce=`DropdownMenuSubTrigger`,Q=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(m,{...i,...r,ref:t})});Q.displayName=ce;var le=`DropdownMenuSubContent`,$=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(h,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});$.displayName=le;var ue=k,de=j,fe=N,pe=F,me=L,he=z,ge=V,_e=U,ve=G,ye=q,be=Y,xe=Z,Se=se,Ce=Q,we=$;export{be as a,ve as c,xe as d,Se as f,de as h,ge as i,ye as l,Ce as m,pe as n,he as o,we as p,me as r,fe as s,_e as t,ue as u};
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{i as r}from"./dist-CSCUSbQc.js";import{c as i,i as a,l as o,n as s,o as c}from"./dist-DTFuvKje.js";import{_ as l,a as u,c as d,d as f,f as p,g as m,h,i as ee,l as g,m as te,n as _,o as v,p as y,r as ne,s as re,t as b,u as x}from"./dist-d2WYntJB.js";var S=e(n(),1),C=t(),w=`DropdownMenu`,[T,ie]=i(w,[l]),E=l(),[D,O]=T(w),k=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:c,modal:l=!0}=e,u=E(t),d=S.useRef(null),[f,m]=a({prop:i,defaultProp:o??!1,onChange:c,caller:w});return(0,C.jsx)(D,{scope:t,triggerId:s(),triggerRef:d,contentId:s(),open:f,onOpenChange:m,onOpenToggle:S.useCallback(()=>m(e=>!e),[m]),modal:l,children:(0,C.jsx)(p,{...u,open:f,onOpenChange:m,dir:r,modal:l,children:n})})};k.displayName=w;var A=`DropdownMenuTrigger`,j=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:i=!1,...a}=e,s=O(A,n),l=E(n);return(0,C.jsx)(b,{asChild:!0,...l,children:(0,C.jsx)(o.button,{type:`button`,id:s.triggerId,"aria-haspopup":`menu`,"aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?`open`:`closed`,"data-disabled":i?``:void 0,disabled:i,...a,ref:r(t,s.triggerRef),onPointerDown:c(e.onPointerDown,e=>{!i&&e.button===0&&e.ctrlKey===!1&&(s.onOpenToggle(),s.open||e.preventDefault())}),onKeyDown:c(e.onKeyDown,e=>{i||([`Enter`,` `].includes(e.key)&&s.onOpenToggle(),e.key===`ArrowDown`&&s.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});j.displayName=A;var M=`DropdownMenuPortal`,N=e=>{let{__scopeDropdownMenu:t,...n}=e,r=E(t);return(0,C.jsx)(g,{...r,...n})};N.displayName=M;var P=`DropdownMenuContent`,F=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=O(P,n),a=E(n),o=S.useRef(!1);return(0,C.jsx)(ee,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:c(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:c(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});F.displayName=P;var I=`DropdownMenuGroup`,L=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(u,{...i,...r,ref:t})});L.displayName=I;var R=`DropdownMenuLabel`,z=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(d,{...i,...r,ref:t})});z.displayName=R;var B=`DropdownMenuItem`,V=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(v,{...i,...r,ref:t})});V.displayName=B;var H=`DropdownMenuCheckboxItem`,U=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(ne,{...i,...r,ref:t})});U.displayName=H;var W=`DropdownMenuRadioGroup`,G=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(x,{...i,...r,ref:t})});G.displayName=W;var K=`DropdownMenuRadioItem`,q=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(f,{...i,...r,ref:t})});q.displayName=K;var J=`DropdownMenuItemIndicator`,Y=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(re,{...i,...r,ref:t})});Y.displayName=J;var X=`DropdownMenuSeparator`,Z=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(y,{...i,...r,ref:t})});Z.displayName=X;var ae=`DropdownMenuArrow`,oe=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(_,{...i,...r,ref:t})});oe.displayName=ae;var se=e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:o}=e,s=E(t),[c,l]=a({prop:r,defaultProp:o??!1,onChange:i,caller:`DropdownMenuSub`});return(0,C.jsx)(te,{...s,open:c,onOpenChange:l,children:n})},ce=`DropdownMenuSubTrigger`,Q=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(m,{...i,...r,ref:t})});Q.displayName=ce;var le=`DropdownMenuSubContent`,$=S.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=E(n);return(0,C.jsx)(h,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});$.displayName=le;var ue=k,de=j,fe=N,pe=F,me=L,he=z,ge=V,_e=U,ve=G,ye=q,be=Y,xe=Z,Se=se,Ce=Q,we=$;export{be as a,ve as c,xe as d,Se as f,de as h,ge as i,ye as l,Ce as m,pe as n,he as o,we as p,me as r,fe as s,_e as t,ue as u};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{a as r,n as i}from"./dist-CSCUSbQc.js";import{c as a,i as o,l as s,n as c,o as l,r as u}from"./dist-DTFuvKje.js";import{n as d,t as f}from"./dist-CxbWbOvU.js";import{i as p,n as m,r as h,t as g}from"./es2015-Dtr4fzLT.js";import{a as _,i as v,n as y,r as b,t as x}from"./dist-YVu4MRkZ2.js";var S=e(n(),1),C=t(),w=`Popover`,[T,ee]=a(w,[_]),E=_(),[D,O]=T(w),k=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:s=!1}=e,l=E(t),u=S.useRef(null),[d,f]=S.useState(!1),[p,m]=o({prop:r,defaultProp:i??!1,onChange:a,caller:w});return(0,C.jsx)(v,{...l,children:(0,C.jsx)(D,{scope:t,contentId:c(),triggerRef:u,open:p,onOpenChange:m,onOpenToggle:S.useCallback(()=>m(e=>!e),[m]),hasCustomAnchor:d,onCustomAnchorAdd:S.useCallback(()=>f(!0),[]),onCustomAnchorRemove:S.useCallback(()=>f(!1),[]),modal:s,children:n})})};k.displayName=w;var A=`PopoverAnchor`,j=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=O(A,n),a=E(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return S.useEffect(()=>(o(),()=>s()),[o,s]),(0,C.jsx)(x,{...a,...r,ref:t})});j.displayName=A;var M=`PopoverTrigger`,N=S.forwardRef((e,t)=>{let{__scopePopover:n,...i}=e,a=O(M,n),o=E(n),c=r(t,a.triggerRef),u=(0,C.jsx)(s.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":J(a.open),...i,ref:c,onClick:l(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?u:(0,C.jsx)(x,{asChild:!0,...o,children:u})});N.displayName=M;var P=`PopoverPortal`,[F,I]=T(P,{forceMount:void 0}),L=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=O(P,t);return(0,C.jsx)(F,{scope:t,forceMount:n,children:(0,C.jsx)(u,{present:n||a.open,children:(0,C.jsx)(f,{asChild:!0,container:i,children:r})})})};L.displayName=P;var R=`PopoverContent`,z=S.forwardRef((e,t)=>{let n=I(R,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=O(R,e.__scopePopover);return(0,C.jsx)(u,{present:r||a.open,children:a.modal?(0,C.jsx)(V,{...i,ref:t}):(0,C.jsx)(H,{...i,ref:t})})});z.displayName=R;var B=i(`PopoverContent.RemoveScroll`),V=S.forwardRef((e,t)=>{let n=O(R,e.__scopePopover),i=S.useRef(null),a=r(t,i),o=S.useRef(!1);return S.useEffect(()=>{let e=i.current;if(e)return g(e)},[]),(0,C.jsx)(m,{as:B,allowPinchZoom:!0,children:(0,C.jsx)(U,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:l(e.onCloseAutoFocus,e=>{e.preventDefault(),o.current||n.triggerRef.current?.focus()}),onPointerDownOutside:l(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;o.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:l(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),H=S.forwardRef((e,t)=>{let n=O(R,e.__scopePopover),r=S.useRef(!1),i=S.useRef(!1);return(0,C.jsx)(U,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),U=S.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...f}=e,m=O(R,n),g=E(n);return h(),(0,C.jsx)(p,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,C.jsx)(d,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>m.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,C.jsx)(b,{"data-state":J(m.open),role:`dialog`,id:m.contentId,...g,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),W=`PopoverClose`,G=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=O(W,n);return(0,C.jsx)(s.button,{type:`button`,...r,ref:t,onClick:l(e.onClick,()=>i.onOpenChange(!1))})});G.displayName=W;var K=`PopoverArrow`,q=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=E(n);return(0,C.jsx)(y,{...i,...r,ref:t})});q.displayName=K;function J(e){return e?`open`:`closed`}var Y=k,X=j,Z=N,Q=L,$=z,te=G,ne=q;export{Q as a,$ as i,ne as n,Y as o,te as r,Z as s,X as t};
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{a as r,n as i}from"./dist-CSCUSbQc.js";import{c as a,i as o,l as s,n as c,o as l,r as u}from"./dist-DTFuvKje.js";import{n as d,t as f}from"./dist-CxbWbOvU.js";import{i as p,n as m,r as h,t as g}from"./es2015-Dtr4fzLT.js";import{a as _,i as v,n as y,r as b,t as x}from"./dist-DXjgFhPl2.js";var S=e(n(),1),C=t(),w=`Popover`,[T,ee]=a(w,[_]),E=_(),[D,O]=T(w),k=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:s=!1}=e,l=E(t),u=S.useRef(null),[d,f]=S.useState(!1),[p,m]=o({prop:r,defaultProp:i??!1,onChange:a,caller:w});return(0,C.jsx)(v,{...l,children:(0,C.jsx)(D,{scope:t,contentId:c(),triggerRef:u,open:p,onOpenChange:m,onOpenToggle:S.useCallback(()=>m(e=>!e),[m]),hasCustomAnchor:d,onCustomAnchorAdd:S.useCallback(()=>f(!0),[]),onCustomAnchorRemove:S.useCallback(()=>f(!1),[]),modal:s,children:n})})};k.displayName=w;var A=`PopoverAnchor`,j=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=O(A,n),a=E(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return S.useEffect(()=>(o(),()=>s()),[o,s]),(0,C.jsx)(x,{...a,...r,ref:t})});j.displayName=A;var M=`PopoverTrigger`,N=S.forwardRef((e,t)=>{let{__scopePopover:n,...i}=e,a=O(M,n),o=E(n),c=r(t,a.triggerRef),u=(0,C.jsx)(s.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":J(a.open),...i,ref:c,onClick:l(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?u:(0,C.jsx)(x,{asChild:!0,...o,children:u})});N.displayName=M;var P=`PopoverPortal`,[F,I]=T(P,{forceMount:void 0}),L=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=O(P,t);return(0,C.jsx)(F,{scope:t,forceMount:n,children:(0,C.jsx)(u,{present:n||a.open,children:(0,C.jsx)(f,{asChild:!0,container:i,children:r})})})};L.displayName=P;var R=`PopoverContent`,z=S.forwardRef((e,t)=>{let n=I(R,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=O(R,e.__scopePopover);return(0,C.jsx)(u,{present:r||a.open,children:a.modal?(0,C.jsx)(V,{...i,ref:t}):(0,C.jsx)(H,{...i,ref:t})})});z.displayName=R;var B=i(`PopoverContent.RemoveScroll`),V=S.forwardRef((e,t)=>{let n=O(R,e.__scopePopover),i=S.useRef(null),a=r(t,i),o=S.useRef(!1);return S.useEffect(()=>{let e=i.current;if(e)return g(e)},[]),(0,C.jsx)(m,{as:B,allowPinchZoom:!0,children:(0,C.jsx)(U,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:l(e.onCloseAutoFocus,e=>{e.preventDefault(),o.current||n.triggerRef.current?.focus()}),onPointerDownOutside:l(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;o.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:l(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),H=S.forwardRef((e,t)=>{let n=O(R,e.__scopePopover),r=S.useRef(!1),i=S.useRef(!1);return(0,C.jsx)(U,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),U=S.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...f}=e,m=O(R,n),g=E(n);return h(),(0,C.jsx)(p,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,C.jsx)(d,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>m.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,C.jsx)(b,{"data-state":J(m.open),role:`dialog`,id:m.contentId,...g,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),W=`PopoverClose`,G=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=O(W,n);return(0,C.jsx)(s.button,{type:`button`,...r,ref:t,onClick:l(e.onClick,()=>i.onOpenChange(!1))})});G.displayName=W;var K=`PopoverArrow`,q=S.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=E(n);return(0,C.jsx)(y,{...i,...r,ref:t})});q.displayName=K;function J(e){return e?`open`:`closed`}var Y=k,X=j,Z=N,Q=L,$=z,te=G,ne=q;export{Q as a,$ as i,ne as n,Y as o,te as r,Z as s,X as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{t as r}from"./react-dom-DPxgxlDT.js";import{a as i}from"./dist-CSCUSbQc.js";import{a,c as o,l as s,t as c}from"./dist-DTFuvKje.js";import{t as l}from"./dist-CRjqnzU7.js";import{a as u,c as d,d as f,i as p,l as m,o as h,r as g,t as _,u as v}from"./floating-ui.dom-DkPPH5vF.js";var y=e(n(),1),ee=e(r(),1),b=typeof document<`u`?y.useLayoutEffect:function(){};function x(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!x(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!x(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function S(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function C(e,t){let n=S(e);return Math.round(t*n)/n}function w(e){let t=y.useRef(e);return b(()=>{t.current=e}),t}function T(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,m]=y.useState(r);x(f,r)||m(r);let[h,g]=y.useState(null),[_,v]=y.useState(null),T=y.useCallback(e=>{e!==k.current&&(k.current=e,g(e))},[]),E=y.useCallback(e=>{e!==A.current&&(A.current=e,v(e))},[]),D=a||h,O=o||_,k=y.useRef(null),A=y.useRef(null),j=y.useRef(u),M=c!=null,N=w(c),P=w(i),F=w(l),I=y.useCallback(()=>{if(!k.current||!A.current)return;let e={placement:t,strategy:n,middleware:f};P.current&&(e.platform=P.current),p(k.current,A.current,e).then(e=>{let t={...e,isPositioned:F.current!==!1};L.current&&!x(j.current,t)&&(j.current=t,ee.flushSync(()=>{d(t)}))})},[f,t,n,P,F]);b(()=>{l===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let L=y.useRef(!1);b(()=>(L.current=!0,()=>{L.current=!1}),[]),b(()=>{if(D&&(k.current=D),O&&(A.current=O),D&&O){if(N.current)return N.current(D,O,I);I()}},[D,O,I,N,M]);let R=y.useMemo(()=>({reference:k,floating:A,setReference:T,setFloating:E}),[T,E]),z=y.useMemo(()=>({reference:D,floating:O}),[D,O]),B=y.useMemo(()=>{let e={position:n,left:0,top:0};if(!z.floating)return e;let t=C(z.floating,u.x),r=C(z.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...S(z.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,z.floating,u.x,u.y]);return y.useMemo(()=>({...u,update:I,refs:R,elements:z,floatingStyles:B}),[u,I,R,z,B])}var E=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:_({element:r.current,padding:i}).fn(n):r?_({element:r,padding:i}).fn(n):{}}}},D=(e,t)=>{let n=m(e);return{name:n.name,fn:n.fn,options:[e,t]}},O=(e,t)=>{let n=v(e);return{name:n.name,fn:n.fn,options:[e,t]}},k=(e,t)=>({fn:d(e).fn,options:[e,t]}),A=(e,t)=>{let n=u(e);return{name:n.name,fn:n.fn,options:[e,t]}},j=(e,t)=>{let n=f(e);return{name:n.name,fn:n.fn,options:[e,t]}},M=(e,t)=>{let n=h(e);return{name:n.name,fn:n.fn,options:[e,t]}},N=(e,t)=>{let n=E(e);return{name:n.name,fn:n.fn,options:[e,t]}},P=t(),F=`Arrow`,I=y.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,P.jsx)(s.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,P.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});I.displayName=F;var L=I,R=`Popper`,[z,B]=o(R),[te,ne]=z(R),V=e=>{let{__scopePopper:t,children:n}=e,[r,i]=y.useState(null),[a,o]=y.useState(void 0);return(0,P.jsx)(te,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};V.displayName=R;var H=`PopperAnchor`,U=y.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...a}=e,o=ne(H,n),c=y.useRef(null),l=o.onAnchorChange,u=i(t,y.useCallback(e=>{c.current=e,e&&l(e)},[l])),d=y.useRef(null);y.useEffect(()=>{if(!r)return;let e=d.current;d.current=r.current,e!==d.current&&l(d.current)});let f=o.placementState&&Y(o.placementState),p=f?.[0],m=f?.[1];return r?null:(0,P.jsx)(s.div,{"data-radix-popper-side":p,"data-radix-popper-align":m,...a,ref:u})});U.displayName=H;var W=`PopperContent`,[re,ie]=z(W),G=y.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:o=0,align:u=`center`,alignOffset:d=0,arrowPadding:f=0,avoidCollisions:p=!0,collisionBoundary:m=[],collisionPadding:h=0,sticky:_=`partial`,hideWhenDetached:v=!1,updatePositionStrategy:ee=`optimized`,onPlaced:b,...x}=e,S=ne(W,n),[C,w]=y.useState(null),E=i(t,e=>w(e)),[F,I]=y.useState(null),L=l(F),R=L?.width??0,z=L?.height??0,B=r+(u===`center`?``:`-`+u),te=typeof h==`number`?h:{top:0,right:0,bottom:0,left:0,...h},V=Array.isArray(m)?m:[m],H=V.length>0,U={padding:te,boundary:V.filter(ae),altBoundary:H},{refs:ie,floatingStyles:G,placement:K,isPositioned:q,middlewareData:J}=T({strategy:`fixed`,placement:B,whileElementsMounted:(...e)=>g(...e,{animationFrame:ee===`always`}),elements:{reference:S.anchor},middleware:[D({mainAxis:o+z,alignmentAxis:d}),p&&O({mainAxis:!0,crossAxis:!1,limiter:_===`partial`?k():void 0,...U}),p&&A({...U}),j({...U,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),F&&N({element:F,padding:f}),oe({arrowWidth:R,arrowHeight:z}),v&&M({strategy:`referenceHidden`,...U,boundary:H?U.boundary:void 0})]}),X=S.setPlacementState;a(()=>(X(K),()=>{X(void 0)}),[K,X]);let[Z,Q]=Y(K),$=c(b);a(()=>{q&&$?.()},[q,$]);let se=J.arrow?.x,ce=J.arrow?.y,le=J.arrow?.centerOffset!==0,[ue,de]=y.useState();return a(()=>{C&&de(window.getComputedStyle(C).zIndex)},[C]),(0,P.jsx)(`div`,{ref:ie.setFloating,"data-radix-popper-content-wrapper":``,style:{...G,transform:q?G.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ue,"--radix-popper-transform-origin":[J.transformOrigin?.x,J.transformOrigin?.y].join(` `),...J.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,P.jsx)(re,{scope:n,placedSide:Z,placedAlign:Q,onArrowChange:I,arrowX:se,arrowY:ce,shouldHideArrow:le,children:(0,P.jsx)(s.div,{"data-side":Z,"data-align":Q,...x,ref:E,style:{...x.style,animation:q?void 0:`none`}})})})});G.displayName=W;var K=`PopperArrow`,q={top:`bottom`,right:`left`,bottom:`top`,left:`right`},J=y.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=ie(K,n),a=q[i.placedSide];return(0,P.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,P.jsx)(L,{...r,ref:t,style:{...r.style,display:`block`}})})});J.displayName=K;function ae(e){return e!==null}var oe=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Y(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Y(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var X=V,Z=U,Q=G,$=J;export{B as a,D as c,T as d,X as i,O as l,$ as n,A as o,Q as r,k as s,Z as t,j as u};
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{t as n}from"./react-f2sANaYj.js";import{t as r}from"./react-dom-DPxgxlDT.js";import{a as i}from"./dist-CSCUSbQc.js";import{a,c as o,l as s,t as c}from"./dist-DTFuvKje.js";import{t as l}from"./dist-CRjqnzU7.js";import{a as u,c as d,d as f,f as p,i as m,l as h,o as g,r as _,t as v}from"./floating-ui.dom-BYl7JZd0.js";var y=e(n(),1),ee=e(r(),1),b=typeof document<`u`?y.useLayoutEffect:function(){};function x(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!x(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!x(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function S(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function C(e,t){let n=S(e);return Math.round(t*n)/n}function w(e){let t=y.useRef(e);return b(()=>{t.current=e}),t}function T(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=y.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=y.useState(r);x(f,r)||p(r);let[h,g]=y.useState(null),[_,v]=y.useState(null),T=y.useCallback(e=>{e!==k.current&&(k.current=e,g(e))},[]),E=y.useCallback(e=>{e!==A.current&&(A.current=e,v(e))},[]),D=a||h,O=o||_,k=y.useRef(null),A=y.useRef(null),j=y.useRef(u),M=c!=null,N=w(c),P=w(i),F=w(l),I=y.useCallback(()=>{if(!k.current||!A.current)return;let e={placement:t,strategy:n,middleware:f};P.current&&(e.platform=P.current),m(k.current,A.current,e).then(e=>{let t={...e,isPositioned:F.current!==!1};L.current&&!x(j.current,t)&&(j.current=t,ee.flushSync(()=>{d(t)}))})},[f,t,n,P,F]);b(()=>{l===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let L=y.useRef(!1);b(()=>(L.current=!0,()=>{L.current=!1}),[]),b(()=>{if(D&&(k.current=D),O&&(A.current=O),D&&O){if(N.current)return N.current(D,O,I);I()}},[D,O,I,N,M]);let R=y.useMemo(()=>({reference:k,floating:A,setReference:T,setFloating:E}),[T,E]),z=y.useMemo(()=>({reference:D,floating:O}),[D,O]),B=y.useMemo(()=>{let e={position:n,left:0,top:0};if(!z.floating)return e;let t=C(z.floating,u.x),r=C(z.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...S(z.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,z.floating,u.x,u.y]);return y.useMemo(()=>({...u,update:I,refs:R,elements:z,floatingStyles:B}),[u,I,R,z,B])}var E=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:v({element:r.current,padding:i}).fn(n):r?v({element:r,padding:i}).fn(n):{}}}},D=(e,t)=>{let n=h(e);return{name:n.name,fn:n.fn,options:[e,t]}},O=(e,t)=>{let n=f(e);return{name:n.name,fn:n.fn,options:[e,t]}},k=(e,t)=>({fn:d(e).fn,options:[e,t]}),A=(e,t)=>{let n=u(e);return{name:n.name,fn:n.fn,options:[e,t]}},j=(e,t)=>{let n=p(e);return{name:n.name,fn:n.fn,options:[e,t]}},M=(e,t)=>{let n=g(e);return{name:n.name,fn:n.fn,options:[e,t]}},N=(e,t)=>{let n=E(e);return{name:n.name,fn:n.fn,options:[e,t]}},P=t(),F=`Arrow`,I=y.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,P.jsx)(s.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,P.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});I.displayName=F;var L=I,R=`Popper`,[z,B]=o(R),[te,ne]=z(R),V=e=>{let{__scopePopper:t,children:n}=e,[r,i]=y.useState(null),[a,o]=y.useState(void 0);return(0,P.jsx)(te,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};V.displayName=R;var H=`PopperAnchor`,U=y.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...a}=e,o=ne(H,n),c=y.useRef(null),l=o.onAnchorChange,u=i(t,y.useCallback(e=>{c.current=e,e&&l(e)},[l])),d=y.useRef(null);y.useEffect(()=>{if(!r)return;let e=d.current;d.current=r.current,e!==d.current&&l(d.current)});let f=o.placementState&&Y(o.placementState),p=f?.[0],m=f?.[1];return r?null:(0,P.jsx)(s.div,{"data-radix-popper-side":p,"data-radix-popper-align":m,...a,ref:u})});U.displayName=H;var W=`PopperContent`,[re,ie]=z(W),G=y.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:o=0,align:u=`center`,alignOffset:d=0,arrowPadding:f=0,avoidCollisions:p=!0,collisionBoundary:m=[],collisionPadding:h=0,sticky:g=`partial`,hideWhenDetached:v=!1,updatePositionStrategy:ee=`optimized`,onPlaced:b,...x}=e,S=ne(W,n),[C,w]=y.useState(null),E=i(t,e=>w(e)),[F,I]=y.useState(null),L=l(F),R=L?.width??0,z=L?.height??0,B=r+(u===`center`?``:`-`+u),te=typeof h==`number`?h:{top:0,right:0,bottom:0,left:0,...h},V=Array.isArray(m)?m:[m],H=V.length>0,U={padding:te,boundary:V.filter(ae),altBoundary:H},{refs:ie,floatingStyles:G,placement:K,isPositioned:q,middlewareData:J}=T({strategy:`fixed`,placement:B,whileElementsMounted:(...e)=>_(...e,{animationFrame:ee===`always`}),elements:{reference:S.anchor},middleware:[D({mainAxis:o+z,alignmentAxis:d}),p&&O({mainAxis:!0,crossAxis:!1,limiter:g===`partial`?k():void 0,...U}),p&&A({...U}),j({...U,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),F&&N({element:F,padding:f}),oe({arrowWidth:R,arrowHeight:z}),v&&M({strategy:`referenceHidden`,...U,boundary:H?U.boundary:void 0})]}),X=S.setPlacementState;a(()=>(X(K),()=>{X(void 0)}),[K,X]);let[Z,Q]=Y(K),$=c(b);a(()=>{q&&$?.()},[q,$]);let se=J.arrow?.x,ce=J.arrow?.y,le=J.arrow?.centerOffset!==0,[ue,de]=y.useState();return a(()=>{C&&de(window.getComputedStyle(C).zIndex)},[C]),(0,P.jsx)(`div`,{ref:ie.setFloating,"data-radix-popper-content-wrapper":``,style:{...G,transform:q?G.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ue,"--radix-popper-transform-origin":[J.transformOrigin?.x,J.transformOrigin?.y].join(` `),...J.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,P.jsx)(re,{scope:n,placedSide:Z,placedAlign:Q,onArrowChange:I,arrowX:se,arrowY:ce,shouldHideArrow:le,children:(0,P.jsx)(s.div,{"data-side":Z,"data-align":Q,...x,ref:E,style:{...x.style,animation:q?void 0:`none`}})})})});G.displayName=W;var K=`PopperArrow`,q={top:`bottom`,right:`left`,bottom:`top`,left:`right`},J=y.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=ie(K,n),a=q[i.placedSide];return(0,P.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,P.jsx)(L,{...r,ref:t,style:{...r.style,display:`block`}})})});J.displayName=K;function ae(e){return e!==null}var oe=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Y(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Y(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var X=V,Z=U,Q=G,$=J;export{B as a,D as c,T as d,X as i,O as l,$ as n,A as o,Q as r,k as s,Z as t,j as u};