@draftably/editor 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/README.md +26 -2
  2. package/dist/LICENSE +21 -0
  3. package/dist/assets/engine.worker-DmHew5f6.js +6813 -0
  4. package/dist/assets/import-d2.worker-CnXfFXoa.js +5395 -0
  5. package/dist/chunks/abnfDiagram-WEYOIA3C-llcpthp5.js +87 -0
  6. package/dist/chunks/arc-rJj0TtXf.js +83 -0
  7. package/dist/chunks/architectureDiagram-ZHVYKT53-CfiXg0Lk.js +4781 -0
  8. package/dist/chunks/blockDiagram-RJAE7QA3-CO-14jWz.js +1440 -0
  9. package/dist/chunks/browser-iNhbPsGc.js +40 -0
  10. package/dist/chunks/c4Diagram-XDPPPE54-DYKuxA4n.js +1524 -0
  11. package/dist/chunks/channel-qMvPU6eH.js +5 -0
  12. package/dist/chunks/chunk-2E7WHVMD-BEZwsFS3.js +670 -0
  13. package/dist/chunks/chunk-2Q5K7J3B-gqtzQ8ux.js +18 -0
  14. package/dist/chunks/chunk-4EMNKR2T-MC54CXVe.js +262 -0
  15. package/dist/chunks/chunk-55XCU76K-DkZUAaqC.js +68 -0
  16. package/dist/chunks/chunk-5VM5RSS4-CaKe4sjM.js +19 -0
  17. package/dist/chunks/chunk-JWPE2WC7-CnAFS2xF.js +8 -0
  18. package/dist/chunks/chunk-VQ5W62QI-CXRv7FiX.js +19 -0
  19. package/dist/chunks/chunk-XXDRQBXY-B-AMQgD2.js +8 -0
  20. package/dist/chunks/chunk-ZCHMQSOR-BALpdc3g.js +451 -0
  21. package/dist/chunks/classDiagram-v2-4MYWR3UA-wPjgJTg4.js +1570 -0
  22. package/dist/chunks/cose-bilkent-JH36ORCC-Bbh5ggBc.js +2608 -0
  23. package/dist/chunks/cynefin-EF2NZ3EQ-Bt6b88hY.js +22361 -0
  24. package/dist/chunks/cynefinDiagram-WF24UDRP-BHWZvxoF.js +299 -0
  25. package/dist/chunks/cytoscape.esm-CRsF_JA3.js +18791 -0
  26. package/dist/chunks/dagre-NK4GIZVX-Cz37yPrT.js +2157 -0
  27. package/dist/chunks/defaultLocale-BgPVtth8.js +171 -0
  28. package/dist/chunks/diagram-CBK3MWTC-Q2R6FJ0B.js +531 -0
  29. package/dist/chunks/diagram-I5XIIV2D-a2Kdu_wA.js +153 -0
  30. package/dist/chunks/diagram-ODIL2UCW-DTWXxcOn.js +346 -0
  31. package/dist/chunks/diagram-PFBEJUXE-DIAQQ5KX.js +480 -0
  32. package/dist/chunks/diagram-RJA3I4VV-BPD0GghS.js +219 -0
  33. package/dist/chunks/diagram-TYUNFSNR-BmdkONfG.js +2586 -0
  34. package/dist/chunks/dot-importer-B23jwEkx.js +1547 -0
  35. package/dist/chunks/ebnfDiagram-V4P3TTPT-C5IKvYlb.js +109 -0
  36. package/dist/chunks/elk-QONTBCTQ-CtdQFvh2.js +49229 -0
  37. package/dist/chunks/erDiagram-KYQIGQAA-5wguK9Dx.js +1064 -0
  38. package/dist/chunks/flowDiagram-IUGLLWBU-BijvFPku.js +1771 -0
  39. package/dist/chunks/ganttDiagram-R7GPNTJY-BaqGPz-O.js +2729 -0
  40. package/dist/chunks/gitGraphDiagram-PDYL7XHY-DZfMGyHE.js +815 -0
  41. package/dist/chunks/graph-CKJmgLki.js +1541 -0
  42. package/dist/chunks/import-core-C-I1wGfw.js +145 -0
  43. package/dist/chunks/infoDiagram-MVDRKAX5-C2vH_59e.js +24 -0
  44. package/dist/chunks/init-DjUOC4st.js +16 -0
  45. package/dist/chunks/ishikawaDiagram-HPEHV2GE-q149MFlV.js +624 -0
  46. package/dist/chunks/journeyDiagram-BOSHW7O7-D-2Z3VtR.js +834 -0
  47. package/dist/chunks/kanban-definition-FNSA4HC5-wvAjV5ub.js +724 -0
  48. package/dist/chunks/katex-BsrBVQKd.js +11314 -0
  49. package/dist/chunks/linear-4t7D_ros.js +259 -0
  50. package/dist/chunks/mermaid-facade-BoLWBerE.js +289 -0
  51. package/dist/chunks/mermaid-importer-Cgx1IhmR.js +478 -0
  52. package/dist/chunks/mermaid.core-DXv6D2Sm.js +19244 -0
  53. package/dist/chunks/mindmap-definition-6OY57UG3-r9wTKul_.js +837 -0
  54. package/dist/chunks/mount-C1Xk_GQz.js +22131 -0
  55. package/dist/chunks/ordinal-DfAQgscy.js +61 -0
  56. package/dist/chunks/pegDiagram-ECIUJNBX-CmKlFWiP.js +95 -0
  57. package/dist/chunks/pieDiagram-GNMPY74T-DNTw_qan.js +208 -0
  58. package/dist/chunks/quadrantDiagram-D57K4MC3-CT_tvVub.js +1029 -0
  59. package/dist/chunks/railroadDiagram-Y72NRBL7-C5TUvZBe.js +77 -0
  60. package/dist/chunks/requirementDiagram-EQYSW5RA-C_c65aCa.js +889 -0
  61. package/dist/chunks/sankeyDiagram-SY24JHO5-CKcbizM1.js +859 -0
  62. package/dist/chunks/sequenceDiagram-BLEHNHQU-GpVnHOjf.js +2972 -0
  63. package/dist/chunks/sizeCapture-INFHLROL-CToN3JSu.js +46 -0
  64. package/dist/chunks/stateDiagram-v2-A6IESKWZ-rJYd2FfM.js +1520 -0
  65. package/dist/chunks/swimlanes-B3ENRKFQ-C7w5pfxG.js +4991 -0
  66. package/dist/chunks/swimlanesDiagram-AYQRV4AK-BpGY_bvE.js +13 -0
  67. package/dist/chunks/timeline-definition-JXYKGLGB-ChKFPBKc.js +1058 -0
  68. package/dist/chunks/usecaseDiagram-WPOLBNNX-skXH8Dcu.js +7945 -0
  69. package/dist/chunks/vennDiagram-Q3Y3IDCW-C5KknmJf.js +1578 -0
  70. package/dist/chunks/wardleyDiagram-IVAIDKWA-DY4Lkfpu.js +678 -0
  71. package/dist/chunks/xychartDiagram-4URNHDU4-BHScsL7h.js +1536 -0
  72. package/dist/element.js +36 -0
  73. package/dist/index.js +4 -0
  74. package/dist/types/src/cli/links.d.ts +4 -0
  75. package/dist/types/src/cli/pdf.d.ts +29 -0
  76. package/dist/types/src/cli/png.d.ts +23 -0
  77. package/dist/types/src/cli/svg.d.ts +4 -0
  78. package/dist/types/src/components/Icon.d.ts +14 -0
  79. package/dist/types/src/components/LayoutPreviewBar.d.ts +2 -0
  80. package/dist/types/src/components/canvas/Canvas.d.ts +15 -0
  81. package/dist/types/src/components/canvas/Frame.d.ts +22 -0
  82. package/dist/types/src/components/canvas/InlineEditor.d.ts +2 -0
  83. package/dist/types/src/components/canvas/Notes.d.ts +5 -0
  84. package/dist/types/src/components/canvas/Overlay.d.ts +2 -0
  85. package/dist/types/src/components/canvas/StateBar.d.ts +5 -0
  86. package/dist/types/src/components/canvas/TextHits.d.ts +6 -0
  87. package/dist/types/src/components/canvas/ZoomControls.d.ts +1 -0
  88. package/dist/types/src/components/canvas/text-boxes.d.ts +24 -0
  89. package/dist/types/src/components/controls.d.ts +88 -0
  90. package/dist/types/src/components/scene/EdgeView.d.ts +22 -0
  91. package/dist/types/src/components/scene/GroupView.d.ts +22 -0
  92. package/dist/types/src/components/scene/Lifelines.d.ts +15 -0
  93. package/dist/types/src/components/scene/LinkMark.d.ts +11 -0
  94. package/dist/types/src/components/scene/NodeView.d.ts +18 -0
  95. package/dist/types/src/components/scene/parts.d.ts +50 -0
  96. package/dist/types/src/components/sculpt/BrushDock.d.ts +2 -0
  97. package/dist/types/src/components/sculpt/TimelineDeck.d.ts +2 -0
  98. package/dist/types/src/components/session-context.d.ts +486 -0
  99. package/dist/types/src/dsl/cells.d.ts +91 -0
  100. package/dist/types/src/dsl/channels.d.ts +53 -0
  101. package/dist/types/src/dsl/compile.d.ts +162 -0
  102. package/dist/types/src/dsl/frame.d.ts +38 -0
  103. package/dist/types/src/dsl/lanes.d.ts +23 -0
  104. package/dist/types/src/dsl/layout-edits.d.ts +58 -0
  105. package/dist/types/src/dsl/legend-notes.d.ts +3 -0
  106. package/dist/types/src/dsl/project.d.ts +39 -0
  107. package/dist/types/src/dsl/source-edits.d.ts +37 -0
  108. package/dist/types/src/dsl/syntax.d.ts +317 -0
  109. package/dist/types/src/dsl/translate.d.ts +69 -0
  110. package/dist/types/src/editor/Editor.d.ts +6 -0
  111. package/dist/types/src/editor/element.d.ts +15 -0
  112. package/dist/types/src/editor/mount.d.ts +23 -0
  113. package/dist/types/src/import/browser.d.ts +3 -0
  114. package/dist/types/src/import/detect.d.ts +31 -0
  115. package/dist/types/src/import/dot-importer.d.ts +3 -0
  116. package/dist/types/src/import/import-core.d.ts +105 -0
  117. package/dist/types/src/import/mermaid-facade.d.ts +120 -0
  118. package/dist/types/src/import/mermaid-importer.d.ts +4 -0
  119. package/dist/types/src/import/mermaid-sequence.d.ts +8 -0
  120. package/dist/types/src/import/scratch.d.ts +3 -0
  121. package/dist/types/src/lib/engine-tasks.d.ts +88 -0
  122. package/dist/types/src/lib/font-data.d.ts +9 -0
  123. package/dist/types/src/lib/saved-diagram.d.ts +4 -0
  124. package/dist/types/src/lib/scene-cache.d.ts +4 -0
  125. package/dist/types/src/lib/source-hash.d.ts +7 -0
  126. package/dist/types/src/lib/svg-export.d.ts +15 -0
  127. package/dist/types/src/model/appearance.d.ts +209 -0
  128. package/dist/types/src/model/bounds.d.ts +19 -0
  129. package/dist/types/src/model/camera.d.ts +21 -0
  130. package/dist/types/src/model/candidates.d.ts +53 -0
  131. package/dist/types/src/model/colors.d.ts +22 -0
  132. package/dist/types/src/model/document.d.ts +24 -0
  133. package/dist/types/src/model/edits.d.ts +133 -0
  134. package/dist/types/src/model/embed.d.ts +17 -0
  135. package/dist/types/src/model/examples.d.ts +15 -0
  136. package/dist/types/src/model/font-faces.d.ts +24 -0
  137. package/dist/types/src/model/fonts.d.ts +47 -0
  138. package/dist/types/src/model/footnote.d.ts +34 -0
  139. package/dist/types/src/model/frame.d.ts +71 -0
  140. package/dist/types/src/model/geometry.d.ts +29 -0
  141. package/dist/types/src/model/graph.d.ts +53 -0
  142. package/dist/types/src/model/heading.d.ts +38 -0
  143. package/dist/types/src/model/icons.d.ts +2 -0
  144. package/dist/types/src/model/label-hits.d.ts +27 -0
  145. package/dist/types/src/model/labels.d.ts +88 -0
  146. package/dist/types/src/model/legend.d.ts +25 -0
  147. package/dist/types/src/model/link.d.ts +63 -0
  148. package/dist/types/src/model/markers.d.ts +47 -0
  149. package/dist/types/src/model/note.d.ts +75 -0
  150. package/dist/types/src/model/panels.d.ts +11 -0
  151. package/dist/types/src/model/rich-text.d.ts +24 -0
  152. package/dist/types/src/model/routes.d.ts +170 -0
  153. package/dist/types/src/model/samples.d.ts +11 -0
  154. package/dist/types/src/model/stack.d.ts +8 -0
  155. package/dist/types/src/model/static-scene.d.ts +15 -0
  156. package/dist/types/src/model/status.d.ts +84 -0
  157. package/dist/types/src/model/styles.d.ts +13 -0
  158. package/dist/types/src/model/surface.d.ts +31 -0
  159. package/dist/types/src/model/types.d.ts +277 -0
  160. package/dist/types/src/runtime/svg-renderer.d.ts +38 -0
  161. package/dist/types/src/server/file-session.d.ts +19 -0
  162. package/dist/types/src/server/workspace.d.ts +21 -0
  163. package/dist/types/src/state/active-session.d.ts +479 -0
  164. package/dist/types/src/state/commands.d.ts +529 -0
  165. package/dist/types/src/state/comparison.d.ts +151 -0
  166. package/dist/types/src/state/files.d.ts +61 -0
  167. package/dist/types/src/state/keyboard.d.ts +6 -0
  168. package/dist/types/src/state/keys.d.ts +5 -0
  169. package/dist/types/src/state/launch.d.ts +61 -0
  170. package/dist/types/src/state/links.d.ts +11 -0
  171. package/dist/types/src/state/session/actions.d.ts +77 -0
  172. package/dist/types/src/state/session/canvas-text.d.ts +24 -0
  173. package/dist/types/src/state/session/document.d.ts +84 -0
  174. package/dist/types/src/state/session/editor.d.ts +81 -0
  175. package/dist/types/src/state/session/emphasis.d.ts +11 -0
  176. package/dist/types/src/state/session/file-session.d.ts +98 -0
  177. package/dist/types/src/state/session/index.d.ts +496 -0
  178. package/dist/types/src/state/session/layout.d.ts +79 -0
  179. package/dist/types/src/state/session/pointer.d.ts +19 -0
  180. package/dist/types/src/state/session/routing.d.ts +20 -0
  181. package/dist/types/src/state/session/scene.d.ts +144 -0
  182. package/dist/types/src/state/session/sculpt.d.ts +70 -0
  183. package/dist/types/src/state/toast.d.ts +14 -0
  184. package/dist/types/src/state/ui.d.ts +39 -0
  185. package/package.json +41 -3
@@ -0,0 +1,5 @@
1
+ import { ao as r, ap as n } from "./mermaid.core-DXv6D2Sm.js";
2
+ const t = (a, o) => r.lang.round(n.parse(a)[o]);
3
+ export {
4
+ t as c
5
+ };
@@ -0,0 +1,670 @@
1
+ import { _ as p, l as w, Q as L, L as E, A as I, R as X, d as H, j as q, c as G } from "./mermaid.core-DXv6D2Sm.js";
2
+ var z = "", b = "", N = "", A = [], R = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ p((e) => q(e, G()), "sanitizeText"), F = /* @__PURE__ */ p((e) => {
3
+ switch (e.type) {
4
+ case "terminal":
5
+ return { ...e, value: k(e.value) };
6
+ case "nonterminal":
7
+ return { ...e, name: k(e.name) };
8
+ case "sequence":
9
+ return { ...e, elements: e.elements.map(F) };
10
+ case "choice":
11
+ return { ...e, alternatives: e.alternatives.map(F) };
12
+ case "optional":
13
+ return { ...e, element: F(e.element) };
14
+ case "repetition":
15
+ return {
16
+ ...e,
17
+ element: F(e.element),
18
+ separator: e.separator ? F(e.separator) : void 0
19
+ };
20
+ case "special":
21
+ return { ...e, text: k(e.text) };
22
+ }
23
+ }, "sanitizeAstNode"), U = /* @__PURE__ */ p(() => {
24
+ z = "", b = "", N = "", A.length = 0, R.clear(), I(), w.debug("[Railroad] Database cleared");
25
+ }, "clear"), _ = /* @__PURE__ */ p((e) => {
26
+ z = k(e), w.debug("[Railroad] Title set:", e);
27
+ }, "setTitle"), W = /* @__PURE__ */ p(() => z, "getTitle"), j = /* @__PURE__ */ p((e) => {
28
+ const i = {
29
+ ...e,
30
+ name: k(e.name),
31
+ definition: F(e.definition),
32
+ comment: e.comment ? k(e.comment) : void 0
33
+ };
34
+ w.debug("[Railroad] Adding rule:", i.name), R.has(i.name) && w.warn(`[Railroad] Rule '${i.name}' is already defined. Overwriting.`), A.push(i), R.set(i.name, i);
35
+ }, "addRule"), K = /* @__PURE__ */ p(() => A, "getRules"), Q = /* @__PURE__ */ p((e) => R.get(e), "getRule"), J = /* @__PURE__ */ p((e) => {
36
+ b = k(e).replace(/^\s+/g, ""), w.debug("[Railroad] Accessibility title set:", e);
37
+ }, "setAccTitle"), Z = /* @__PURE__ */ p(() => b, "getAccTitle"), V = /* @__PURE__ */ p((e) => {
38
+ N = k(e).replace(/\n\s+/g, `
39
+ `), w.debug("[Railroad] Accessibility description set:", e);
40
+ }, "setAccDescription"), ee = /* @__PURE__ */ p(() => N, "getAccDescription"), te = _, re = W, ie = {
41
+ clear: U,
42
+ setTitle: _,
43
+ getTitle: W,
44
+ addRule: j,
45
+ getRules: K,
46
+ getRule: Q,
47
+ setAccTitle: J,
48
+ getAccTitle: Z,
49
+ setAccDescription: V,
50
+ getAccDescription: ee,
51
+ setDiagramTitle: te,
52
+ getDiagramTitle: re
53
+ }, g = {
54
+ // Layout
55
+ compactMode: !1,
56
+ // Spacing
57
+ padding: 10,
58
+ verticalSeparation: 8,
59
+ horizontalSeparation: 10,
60
+ arcRadius: 10,
61
+ // Typography
62
+ fontSize: 14,
63
+ fontFamily: "monospace",
64
+ // Colors - Terminal
65
+ terminalFill: "#FFFFC0",
66
+ terminalStroke: "#000000",
67
+ terminalTextColor: "#000000",
68
+ // Colors - Non-terminal
69
+ nonTerminalFill: "#FFFFFF",
70
+ nonTerminalStroke: "#000000",
71
+ nonTerminalTextColor: "#000000",
72
+ // Colors - Lines
73
+ lineColor: "#000000",
74
+ strokeWidth: 2,
75
+ // Colors - Markers
76
+ markerFill: "#000000",
77
+ // Colors - Comment
78
+ commentFill: "#E8E8E8",
79
+ commentStroke: "#888888",
80
+ commentTextColor: "#666666",
81
+ // Colors - Special
82
+ specialFill: "#F0E0FF",
83
+ specialStroke: "#8800CC",
84
+ // Other
85
+ ruleNameColor: "#000066",
86
+ showMarkers: !0,
87
+ markerRadius: 5
88
+ }, ne = /^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$|^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch)\([\d\s%+,./-]+\)$|^[a-z]+$/i, ae = /^[\w "',.-]+$/, oe = /* @__PURE__ */ new Set([
89
+ "compactMode",
90
+ "padding",
91
+ "verticalSeparation",
92
+ "horizontalSeparation",
93
+ "arcRadius",
94
+ "fontSize",
95
+ "fontFamily",
96
+ "terminalFill",
97
+ "terminalStroke",
98
+ "terminalTextColor",
99
+ "nonTerminalFill",
100
+ "nonTerminalStroke",
101
+ "nonTerminalTextColor",
102
+ "lineColor",
103
+ "strokeWidth",
104
+ "markerFill",
105
+ "commentFill",
106
+ "commentStroke",
107
+ "commentTextColor",
108
+ "specialFill",
109
+ "specialStroke",
110
+ "ruleNameColor",
111
+ "showMarkers",
112
+ "markerRadius"
113
+ ]), B = /* @__PURE__ */ p((e) => e ? Object.keys(e).every(
114
+ (i) => i === "railroad" || oe.has(i)
115
+ ) : !1, "isRailroadStyleOptions"), le = /* @__PURE__ */ p((e) => e ? "railroad" in e && e.railroad ? e.railroad : B(e) ? e : {} : {}, "extractRailroadOverrides"), se = /* @__PURE__ */ p((e) => {
116
+ if (!e || B(e))
117
+ return {};
118
+ const {
119
+ railroad: i,
120
+ svgId: a,
121
+ theme: r,
122
+ look: t,
123
+ ...n
124
+ } = e;
125
+ return n;
126
+ }, "extractThemeOverrides"), m = /* @__PURE__ */ p((e, i) => {
127
+ if (typeof e != "string")
128
+ return i;
129
+ const a = e.trim();
130
+ return ne.test(a) ? a : i;
131
+ }, "sanitizeColorValue"), Y = /* @__PURE__ */ p((e, i) => {
132
+ if (typeof e != "string")
133
+ return i;
134
+ const a = e.trim();
135
+ return ae.test(a) ? a : i;
136
+ }, "sanitizeFontFamilyValue"), S = /* @__PURE__ */ p((e, i) => {
137
+ const a = typeof e == "number" ? e : typeof e == "string" ? Number.parseFloat(e) : Number.NaN;
138
+ return Number.isFinite(a) && a >= 0 ? a : i;
139
+ }, "sanitizeNumberValue"), de = /* @__PURE__ */ p((e) => {
140
+ const i = typeof e == "number" ? e : typeof e == "string" ? Number.parseFloat(e) : Number.NaN;
141
+ return Number.isFinite(i) && i > 0 ? i : void 0;
142
+ }, "parseThemeFontSize"), ce = /* @__PURE__ */ p((e) => {
143
+ const i = Y(
144
+ e.fontFamily,
145
+ g.fontFamily
146
+ ), a = de(e.fontSize) ?? g.fontSize;
147
+ return {
148
+ ...g,
149
+ fontFamily: i,
150
+ fontSize: a,
151
+ terminalFill: m(
152
+ e.secondBkg ?? e.secondaryColor,
153
+ g.terminalFill
154
+ ),
155
+ terminalStroke: m(
156
+ e.secondaryBorderColor ?? e.lineColor,
157
+ g.terminalStroke
158
+ ),
159
+ terminalTextColor: m(
160
+ e.secondaryTextColor ?? e.textColor,
161
+ g.terminalTextColor
162
+ ),
163
+ nonTerminalFill: m(
164
+ e.mainBkg ?? e.background,
165
+ g.nonTerminalFill
166
+ ),
167
+ nonTerminalStroke: m(
168
+ e.primaryBorderColor ?? e.lineColor,
169
+ g.nonTerminalStroke
170
+ ),
171
+ nonTerminalTextColor: m(
172
+ e.primaryTextColor ?? e.textColor,
173
+ g.nonTerminalTextColor
174
+ ),
175
+ lineColor: m(e.lineColor, g.lineColor),
176
+ markerFill: m(e.lineColor, g.markerFill),
177
+ commentFill: m(
178
+ e.labelBackground ?? e.tertiaryColor,
179
+ g.commentFill
180
+ ),
181
+ commentStroke: m(
182
+ e.tertiaryBorderColor ?? e.lineColor,
183
+ g.commentStroke
184
+ ),
185
+ commentTextColor: m(
186
+ e.tertiaryTextColor ?? e.textColor,
187
+ g.commentTextColor
188
+ ),
189
+ specialFill: m(
190
+ e.tertiaryColor ?? e.secondaryColor,
191
+ g.specialFill
192
+ ),
193
+ specialStroke: m(
194
+ e.tertiaryBorderColor ?? e.secondaryBorderColor,
195
+ g.specialStroke
196
+ ),
197
+ ruleNameColor: m(
198
+ e.titleColor ?? e.textColor,
199
+ g.ruleNameColor
200
+ )
201
+ };
202
+ }, "buildThemeDefaults"), M = /* @__PURE__ */ p((e) => {
203
+ const i = E(), a = {
204
+ ...X(),
205
+ ...i.themeVariables ?? {},
206
+ ...se(e)
207
+ }, r = ce(a), t = {
208
+ ...i.railroad ?? {},
209
+ ...le(e)
210
+ };
211
+ return {
212
+ compactMode: t.compactMode ?? r.compactMode,
213
+ padding: S(t.padding, r.padding),
214
+ verticalSeparation: S(
215
+ t.verticalSeparation,
216
+ r.verticalSeparation
217
+ ),
218
+ horizontalSeparation: S(
219
+ t.horizontalSeparation,
220
+ r.horizontalSeparation
221
+ ),
222
+ arcRadius: S(t.arcRadius, r.arcRadius),
223
+ fontSize: S(t.fontSize, r.fontSize),
224
+ fontFamily: Y(t.fontFamily, r.fontFamily),
225
+ terminalFill: m(t.terminalFill, r.terminalFill),
226
+ terminalStroke: m(
227
+ t.terminalStroke,
228
+ r.terminalStroke
229
+ ),
230
+ terminalTextColor: m(
231
+ t.terminalTextColor,
232
+ r.terminalTextColor
233
+ ),
234
+ nonTerminalFill: m(
235
+ t.nonTerminalFill,
236
+ r.nonTerminalFill
237
+ ),
238
+ nonTerminalStroke: m(
239
+ t.nonTerminalStroke,
240
+ r.nonTerminalStroke
241
+ ),
242
+ nonTerminalTextColor: m(
243
+ t.nonTerminalTextColor,
244
+ r.nonTerminalTextColor
245
+ ),
246
+ lineColor: m(t.lineColor, r.lineColor),
247
+ strokeWidth: S(t.strokeWidth, r.strokeWidth),
248
+ markerFill: m(t.markerFill, r.markerFill),
249
+ commentFill: m(t.commentFill, r.commentFill),
250
+ commentStroke: m(t.commentStroke, r.commentStroke),
251
+ commentTextColor: m(
252
+ t.commentTextColor,
253
+ r.commentTextColor
254
+ ),
255
+ specialFill: m(t.specialFill, r.specialFill),
256
+ specialStroke: m(t.specialStroke, r.specialStroke),
257
+ ruleNameColor: m(t.ruleNameColor, r.ruleNameColor),
258
+ showMarkers: t.showMarkers ?? r.showMarkers,
259
+ markerRadius: S(t.markerRadius, r.markerRadius)
260
+ };
261
+ }, "buildRailroadStyleOptions"), ue = /* @__PURE__ */ p((e) => {
262
+ const {
263
+ fontFamily: i,
264
+ fontSize: a,
265
+ terminalFill: r,
266
+ terminalStroke: t,
267
+ terminalTextColor: n,
268
+ nonTerminalFill: h,
269
+ nonTerminalStroke: s,
270
+ nonTerminalTextColor: o,
271
+ lineColor: u,
272
+ strokeWidth: c,
273
+ markerFill: d,
274
+ commentFill: x,
275
+ commentStroke: l,
276
+ commentTextColor: f,
277
+ specialFill: y,
278
+ specialStroke: v,
279
+ ruleNameColor: C
280
+ } = M(e);
281
+ return `
282
+ .railroad-diagram {
283
+ font-family: ${i};
284
+ font-size: ${a}px;
285
+ }
286
+
287
+ .railroad-terminal rect {
288
+ fill: ${r};
289
+ stroke: ${t};
290
+ stroke-width: ${c}px;
291
+ }
292
+
293
+ .railroad-terminal text {
294
+ fill: ${n};
295
+ font-family: ${i};
296
+ font-size: ${a}px;
297
+ text-anchor: middle;
298
+ dominant-baseline: middle;
299
+ }
300
+
301
+ .railroad-nonterminal rect {
302
+ fill: ${h};
303
+ stroke: ${s};
304
+ stroke-width: ${c}px;
305
+ }
306
+
307
+ .railroad-nonterminal text {
308
+ fill: ${o};
309
+ font-family: ${i};
310
+ font-size: ${a}px;
311
+ text-anchor: middle;
312
+ dominant-baseline: middle;
313
+ }
314
+
315
+ .railroad-line {
316
+ stroke: ${u};
317
+ stroke-width: ${c}px;
318
+ fill: none;
319
+ }
320
+
321
+ .railroad-start circle,
322
+ .railroad-end circle {
323
+ fill: ${d};
324
+ }
325
+
326
+ .railroad-comment ellipse {
327
+ fill: ${x};
328
+ stroke: ${l};
329
+ stroke-width: ${c}px;
330
+ }
331
+
332
+ .railroad-comment text {
333
+ fill: ${f};
334
+ font-style: italic;
335
+ font-family: ${i};
336
+ font-size: ${a}px;
337
+ text-anchor: middle;
338
+ dominant-baseline: middle;
339
+ }
340
+
341
+ .railroad-special rect {
342
+ fill: ${y};
343
+ stroke: ${v};
344
+ stroke-width: ${c}px;
345
+ stroke-dasharray: 5,3;
346
+ }
347
+
348
+ .railroad-special text {
349
+ fill: ${o};
350
+ font-family: ${i};
351
+ font-size: ${a}px;
352
+ text-anchor: middle;
353
+ dominant-baseline: middle;
354
+ }
355
+
356
+ .railroad-rule-name {
357
+ font-weight: bold;
358
+ fill: ${C};
359
+ font-family: ${i};
360
+ font-size: ${a}px;
361
+ }
362
+
363
+ .railroad-group {
364
+ /* Grouping container, no specific styles */
365
+ }
366
+ `;
367
+ }, "getStyles"), T = class {
368
+ constructor() {
369
+ this.d = "";
370
+ }
371
+ static {
372
+ p(this, "PathBuilder");
373
+ }
374
+ moveTo(e, i) {
375
+ return this.d += `M ${e} ${i} `, this;
376
+ }
377
+ lineTo(e, i) {
378
+ return this.d += `L ${e} ${i} `, this;
379
+ }
380
+ horizontalTo(e) {
381
+ return this.d += `H ${e} `, this;
382
+ }
383
+ verticalTo(e) {
384
+ return this.d += `V ${e} `, this;
385
+ }
386
+ arcTo(e, i, a, r, t, n, h) {
387
+ return this.d += `A ${e} ${i} ${a} ${r ? 1 : 0} ${t ? 1 : 0} ${n} ${h} `, this;
388
+ }
389
+ build() {
390
+ return this.d.trim();
391
+ }
392
+ }, me = class {
393
+ constructor(e, i = M()) {
394
+ this.textCache = /* @__PURE__ */ new Map(), this.svg = e, this.config = i;
395
+ }
396
+ static {
397
+ p(this, "RailroadRenderer");
398
+ }
399
+ /**
400
+ * Measure text dimensions
401
+ */
402
+ measureText(e) {
403
+ if (this.textCache.has(e))
404
+ return this.textCache.get(e);
405
+ const i = this.svg.append("text").attr("font-family", this.config.fontFamily).attr("font-size", this.config.fontSize).text(e), a = i.node().getBBox(), r = { width: a.width, height: a.height };
406
+ return i.remove(), this.textCache.set(e, r), r;
407
+ }
408
+ /**
409
+ * Render terminal symbol (rounded rectangle)
410
+ */
411
+ renderTerminal(e, i) {
412
+ const a = this.measureText(i), r = a.width + this.config.padding * 2, t = a.height + this.config.padding * 2, n = e.append("g").attr("class", "railroad-terminal");
413
+ return n.append("rect").attr("x", 0).attr("y", 0).attr("width", r).attr("height", t).attr("rx", 10).attr("ry", 10), n.append("text").attr("x", r / 2).attr("y", t / 2).text(i), {
414
+ element: n.node(),
415
+ dimensions: {
416
+ width: r,
417
+ height: t,
418
+ up: t / 2,
419
+ down: t / 2
420
+ }
421
+ };
422
+ }
423
+ /**
424
+ * Render non-terminal symbol (rectangle)
425
+ */
426
+ renderNonTerminal(e, i) {
427
+ const a = this.measureText(i), r = a.width + this.config.padding * 2, t = a.height + this.config.padding * 2, n = e.append("g").attr("class", "railroad-nonterminal");
428
+ return n.append("rect").attr("x", 0).attr("y", 0).attr("width", r).attr("height", t), n.append("text").attr("x", r / 2).attr("y", t / 2).text(i), {
429
+ element: n.node(),
430
+ dimensions: {
431
+ width: r,
432
+ height: t,
433
+ up: t / 2,
434
+ down: t / 2
435
+ }
436
+ };
437
+ }
438
+ /**
439
+ * Render sequence (horizontal concatenation)
440
+ */
441
+ renderSequence(e, i) {
442
+ const a = i.map((o) => this.renderExpression(e, o));
443
+ let r = 0, t = 0, n = 0;
444
+ for (const o of a)
445
+ r += o.dimensions.width, t = Math.max(t, o.dimensions.up), n = Math.max(n, o.dimensions.down);
446
+ r += (a.length - 1) * this.config.horizontalSeparation;
447
+ const h = e.append("g").attr("class", "railroad-sequence");
448
+ let s = 0;
449
+ for (let o = 0; o < a.length; o++) {
450
+ const u = a[o], c = t - u.dimensions.up;
451
+ if (h.node().appendChild(u.element).setAttribute("transform", `translate(${s}, ${c})`), o < a.length - 1) {
452
+ const x = s + u.dimensions.width, l = x + this.config.horizontalSeparation, f = t;
453
+ h.append("path").attr("class", "railroad-line").attr("d", new T().moveTo(x, f).lineTo(l, f).build());
454
+ }
455
+ s += u.dimensions.width + this.config.horizontalSeparation;
456
+ }
457
+ return {
458
+ element: h.node(),
459
+ dimensions: {
460
+ width: r,
461
+ height: t + n,
462
+ up: t,
463
+ down: n
464
+ }
465
+ };
466
+ }
467
+ /**
468
+ * Render choice (vertical alternatives)
469
+ */
470
+ renderChoice(e, i) {
471
+ const a = i.map((d) => this.renderExpression(e, d));
472
+ let r = 0, t = 0;
473
+ for (const d of a)
474
+ r = Math.max(r, d.dimensions.width), t += d.dimensions.height;
475
+ t += (a.length - 1) * this.config.verticalSeparation;
476
+ const n = this.config.arcRadius, h = n * 4, s = r + h, o = e.append("g").attr("class", "railroad-choice");
477
+ let u = 0;
478
+ const c = t / 2;
479
+ for (const d of a) {
480
+ const x = u, l = x + d.dimensions.up, f = n * 2 + (r - d.dimensions.width) / 2;
481
+ o.node().appendChild(d.element).setAttribute("transform", `translate(${f}, ${x})`);
482
+ const v = new T(), C = l > c;
483
+ l === c ? v.moveTo(0, c).lineTo(f, l) : v.moveTo(0, c).arcTo(
484
+ n,
485
+ n,
486
+ 0,
487
+ !1,
488
+ C,
489
+ n,
490
+ c + (C ? n : -n)
491
+ ).lineTo(n, l - (C ? n : -n)).arcTo(n, n, 0, !1, !C, n * 2, l).lineTo(f, l), o.append("path").attr("class", "railroad-line").attr("d", v.build());
492
+ const $ = new T(), O = f + d.dimensions.width, P = s - n * 2;
493
+ l === c ? $.moveTo(O, l).lineTo(s, c) : $.moveTo(O, l).lineTo(P, l).arcTo(
494
+ n,
495
+ n,
496
+ 0,
497
+ !1,
498
+ !C,
499
+ s - n,
500
+ l + (C ? -n : n)
501
+ ).lineTo(s - n, c + (C ? n : -n)).arcTo(n, n, 0, !1, C, s, c), o.append("path").attr("class", "railroad-line").attr("d", $.build()), u += d.dimensions.height + this.config.verticalSeparation;
502
+ }
503
+ return {
504
+ element: o.node(),
505
+ dimensions: {
506
+ width: s,
507
+ height: t,
508
+ up: c,
509
+ down: t - c
510
+ }
511
+ };
512
+ }
513
+ /**
514
+ * Render optional (bypass path above)
515
+ */
516
+ renderOptional(e, i) {
517
+ const a = this.renderExpression(e, i), r = this.config.arcRadius, t = r * 2, n = a.dimensions.width + r * 4, h = a.dimensions.height + t, s = e.append("g").attr("class", "railroad-optional"), o = r * 2, u = t;
518
+ s.node().appendChild(a.element).setAttribute("transform", `translate(${o}, ${u})`);
519
+ const d = u + a.dimensions.up, x = new T().moveTo(0, d).lineTo(r * 2, d);
520
+ s.append("path").attr("class", "railroad-line").attr("d", x.build());
521
+ const l = new T().moveTo(o + a.dimensions.width, d).lineTo(n, d);
522
+ s.append("path").attr("class", "railroad-line").attr("d", l.build());
523
+ const f = new T().moveTo(0, d).arcTo(r, r, 0, !1, !1, r, d - r).lineTo(r, r).arcTo(r, r, 0, !1, !0, r * 2, 0).lineTo(n - r * 2, 0).arcTo(r, r, 0, !1, !0, n - r, r).lineTo(n - r, d - r).arcTo(r, r, 0, !1, !1, n, d);
524
+ return s.append("path").attr("class", "railroad-line").attr("d", f.build()), {
525
+ element: s.node(),
526
+ dimensions: {
527
+ width: n,
528
+ height: h,
529
+ up: d,
530
+ down: h - d
531
+ }
532
+ };
533
+ }
534
+ /**
535
+ * Render repetition (loop back path)
536
+ */
537
+ renderRepetition(e, i, a) {
538
+ const r = this.renderExpression(e, i), t = this.config.arcRadius, n = t * 2, h = r.dimensions.width + t * 4, s = a === 0, o = r.dimensions.height + n + (s ? n : 0), u = e.append("g").attr("class", "railroad-repetition"), c = t * 2, d = s ? n : 0;
539
+ u.node().appendChild(r.element).setAttribute("transform", `translate(${c}, ${d})`);
540
+ const l = d + r.dimensions.up;
541
+ u.append("path").attr("class", "railroad-line").attr(
542
+ "d",
543
+ new T().moveTo(0, l).lineTo(t * 2, l).build()
544
+ ), u.append("path").attr("class", "railroad-line").attr(
545
+ "d",
546
+ new T().moveTo(c + r.dimensions.width, l).lineTo(h, l).build()
547
+ );
548
+ const f = d + r.dimensions.height + t, y = new T().moveTo(c + r.dimensions.width, l).arcTo(
549
+ t,
550
+ t,
551
+ 0,
552
+ !1,
553
+ !0,
554
+ c + r.dimensions.width + t,
555
+ l + t
556
+ ).lineTo(c + r.dimensions.width + t, f).arcTo(
557
+ t,
558
+ t,
559
+ 0,
560
+ !1,
561
+ !0,
562
+ c + r.dimensions.width,
563
+ f + t
564
+ ).lineTo(t * 2, f + t).arcTo(t, t, 0, !1, !0, t, f).lineTo(t, l + t).arcTo(t, t, 0, !1, !0, t * 2, l);
565
+ if (u.append("path").attr("class", "railroad-line").attr("d", y.build()), s) {
566
+ const v = new T().moveTo(0, l).arcTo(t, t, 0, !1, !1, t, l - t).lineTo(t, t).arcTo(t, t, 0, !1, !0, t * 2, 0).lineTo(h - t * 2, 0).arcTo(t, t, 0, !1, !0, h - t, t).lineTo(h - t, l - t).arcTo(t, t, 0, !1, !1, h, l);
567
+ u.append("path").attr("class", "railroad-line").attr("d", v.build());
568
+ }
569
+ return {
570
+ element: u.node(),
571
+ dimensions: {
572
+ width: h,
573
+ height: o,
574
+ up: l,
575
+ down: o - l
576
+ }
577
+ };
578
+ }
579
+ /**
580
+ * Render special sequence
581
+ */
582
+ renderSpecial(e, i) {
583
+ const a = this.measureText("? " + i + " ?"), r = a.width + this.config.padding * 2, t = a.height + this.config.padding * 2, n = e.append("g").attr("class", "railroad-special");
584
+ return n.append("rect").attr("x", 0).attr("y", 0).attr("width", r).attr("height", t), n.append("text").attr("x", r / 2).attr("y", t / 2).text("? " + i + " ?"), {
585
+ element: n.node(),
586
+ dimensions: {
587
+ width: r,
588
+ height: t,
589
+ up: t / 2,
590
+ down: t / 2
591
+ }
592
+ };
593
+ }
594
+ /**
595
+ * Render an expression (recursive)
596
+ */
597
+ renderExpression(e, i) {
598
+ switch (i.type) {
599
+ case "terminal":
600
+ return this.renderTerminal(e, i.value);
601
+ case "nonterminal":
602
+ return this.renderNonTerminal(e, i.name);
603
+ case "sequence":
604
+ return this.renderSequence(e, i.elements);
605
+ case "choice":
606
+ return this.renderChoice(e, i.alternatives);
607
+ case "optional":
608
+ return this.renderOptional(e, i.element);
609
+ case "repetition":
610
+ return this.renderRepetition(e, i.element, i.min);
611
+ case "special":
612
+ return this.renderSpecial(e, i.text);
613
+ default:
614
+ throw new Error(`Unknown node type: ${i.type}`);
615
+ }
616
+ }
617
+ /**
618
+ * Render a single rule
619
+ */
620
+ renderRule(e, i) {
621
+ const a = this.svg.append("g").attr("class", "railroad-rule").attr("transform", `translate(0, ${i})`), r = e.name + " =", t = this.measureText(r).width + 20, n = t + 20, h = a.append("g"), s = this.renderExpression(h, e.definition), o = Math.max(20, s.dimensions.up), u = o - s.dimensions.up;
622
+ return h.attr("transform", `translate(${n}, ${u})`), a.append("g").attr("class", "railroad-rule-name-group").append("text").attr("class", "railroad-rule-name").attr("x", 0).attr("y", o).text(r), a.append("g").attr("class", "railroad-start").append("circle").attr("cx", t).attr("cy", o).attr("r", this.config.markerRadius), a.append("g").attr("class", "railroad-end").append("circle").attr("cx", n + s.dimensions.width + 10).attr("cy", o).attr("r", this.config.markerRadius), a.append("path").attr("class", "railroad-line").attr(
623
+ "d",
624
+ new T().moveTo(t + this.config.markerRadius, o).lineTo(n, o).build()
625
+ ), a.append("path").attr("class", "railroad-line").attr(
626
+ "d",
627
+ new T().moveTo(n + s.dimensions.width, o).lineTo(n + s.dimensions.width + 10 - this.config.markerRadius, o).build()
628
+ ), {
629
+ height: Math.max(40, u + s.dimensions.height + this.config.padding * 2),
630
+ width: n + s.dimensions.width + 10 + this.config.markerRadius
631
+ };
632
+ }
633
+ /**
634
+ * Render all rules
635
+ */
636
+ renderDiagram(e) {
637
+ let i = this.config.padding, a = 0;
638
+ for (const r of e) {
639
+ const t = this.renderRule(r, i);
640
+ i += t.height + this.config.verticalSeparation, a = Math.max(a, t.width);
641
+ }
642
+ return {
643
+ width: a + this.config.padding * 2,
644
+ height: i + this.config.padding
645
+ };
646
+ }
647
+ }, D = /* @__PURE__ */ p((e, i, a) => {
648
+ H(e, i.height, i.width, a), e.attr("viewBox", `0 0 ${i.width} ${i.height}`);
649
+ }, "configureRailroadSvgSize"), he = /* @__PURE__ */ p((e, i, a) => {
650
+ w.debug(`[Railroad] Rendering diagram
651
+ ` + e);
652
+ try {
653
+ const r = L(i);
654
+ r.attr("class", "railroad-diagram");
655
+ const n = E().railroad?.useMaxWidth ?? !0, h = ie.getRules();
656
+ if (w.debug(`[Railroad] Rendering ${h.length} rules`), h.length === 0) {
657
+ w.warn("[Railroad] No rules to render"), D(r, { height: 100, width: 200 }, n);
658
+ return;
659
+ }
660
+ const o = new me(r, M()).renderDiagram(h);
661
+ D(r, o, n), w.debug("[Railroad] Render complete");
662
+ } catch (r) {
663
+ throw w.error("[Railroad] Render error:", r), r;
664
+ }
665
+ }, "draw"), ge = { draw: he };
666
+ export {
667
+ ie as d,
668
+ ue as g,
669
+ ge as r
670
+ };
@@ -0,0 +1,18 @@
1
+ import { _ as i } from "./mermaid.core-DXv6D2Sm.js";
2
+ var r = class {
3
+ /**
4
+ * @param init - Function that creates the default state.
5
+ */
6
+ constructor(t) {
7
+ this.init = t, this.records = this.init();
8
+ }
9
+ static {
10
+ i(this, "ImperativeState");
11
+ }
12
+ reset() {
13
+ this.records = this.init();
14
+ }
15
+ };
16
+ export {
17
+ r as I
18
+ };