@hraness/design-kit 0.31.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 (345) hide show
  1. package/ARTICLE_COPY.md +208 -0
  2. package/HERO_FIELDS.md +55 -0
  3. package/ICONS.md +56 -0
  4. package/LANTERN_MATERIAL.md +60 -0
  5. package/LICENSE +21 -0
  6. package/MARKETING_COPY.md +49 -0
  7. package/MARKETING_PRESET.md +108 -0
  8. package/PALETTES.md +90 -0
  9. package/PAPER_THEME.md +128 -0
  10. package/README.md +745 -0
  11. package/STATUS_PAGES.md +67 -0
  12. package/STYLE.md +245 -0
  13. package/WRITING.md +72 -0
  14. package/dist/browser/index.js +2345 -0
  15. package/dist/chunk-44djxk16.js +6872 -0
  16. package/dist/chunk-5gtx3pza.js +9 -0
  17. package/dist/chunk-77391vmq.js +454 -0
  18. package/dist/chunk-7b1586eb.js +1209 -0
  19. package/dist/chunk-8834fh4n.js +6 -0
  20. package/dist/chunk-9t8xyqte.js +870 -0
  21. package/dist/chunk-cejpzyfh.js +446 -0
  22. package/dist/chunk-eh71jz57.js +429 -0
  23. package/dist/chunk-evb02bc1.js +516 -0
  24. package/dist/chunk-h4k7yv6x.js +368 -0
  25. package/dist/chunk-he8eznb1.js +760 -0
  26. package/dist/chunk-mr1vdcjq.js +404 -0
  27. package/dist/chunk-wzvdn8ey.js +116 -0
  28. package/dist/fonts/nebula-sans/social-fonts.generated.js +53 -0
  29. package/dist/icons.js +48 -0
  30. package/dist/index.js +237 -0
  31. package/dist/launch.js +41 -0
  32. package/dist/mockups/client.js +422 -0
  33. package/dist/mockups/index.js +1850 -0
  34. package/dist/portfolio.js +1549 -0
  35. package/dist/provider-marks.js +19 -0
  36. package/dist/react/charts.js +11 -0
  37. package/dist/react/hero-backdrop.js +8 -0
  38. package/dist/react/index.js +7252 -0
  39. package/dist/react/platform-install.js +10 -0
  40. package/dist/react/server.js +137 -0
  41. package/dist/stylex-manifest.json +1 -0
  42. package/dist/stylex.css +5392 -0
  43. package/dist/syntax-highlighting.js +15 -0
  44. package/dist/testing.js +250 -0
  45. package/package.json +377 -0
  46. package/portfolio-inventory.json +31 -0
  47. package/scripts/check-lantern-material-snapshot.d.mts +26 -0
  48. package/scripts/check-lantern-material-snapshot.mjs +126 -0
  49. package/scripts/check-marketing-snapshot.d.mts +12 -0
  50. package/scripts/check-marketing-snapshot.mjs +58 -0
  51. package/scripts/lantern-material-snapshot.ts +101 -0
  52. package/scripts/marketing-textures.ts +48 -0
  53. package/scripts/paper-theme-snapshot.ts +97 -0
  54. package/scripts/product-marketing-snapshot.ts +149 -0
  55. package/src/appearance-menu.css +266 -0
  56. package/src/appearance.ts +32 -0
  57. package/src/article-html.ts +269 -0
  58. package/src/article.ts +686 -0
  59. package/src/browser/appearance-menu.ts +604 -0
  60. package/src/browser/artifact-share.ts +164 -0
  61. package/src/browser/design-palette.ts +197 -0
  62. package/src/browser/foil.ts +124 -0
  63. package/src/browser/hero-light.ts +11 -0
  64. package/src/browser/index.ts +29 -0
  65. package/src/browser/status-field.ts +432 -0
  66. package/src/browser/status-page.ts +100 -0
  67. package/src/browser/sticky-offset.ts +82 -0
  68. package/src/browser/theme-color-sync.ts +213 -0
  69. package/src/charts.css +7 -0
  70. package/src/compiler-components.css +34 -0
  71. package/src/compiler-foundation.css +18 -0
  72. package/src/compiler-palettes.css +7 -0
  73. package/src/compiler-tokens.css +342 -0
  74. package/src/components.css +3 -0
  75. package/src/design-gallery.css +431 -0
  76. package/src/effects.css +14 -0
  77. package/src/fonts/geist-mono/GeistMono[wght].woff2 +0 -0
  78. package/src/fonts/geist-mono/OFL.txt +93 -0
  79. package/src/fonts/geist-mono/PROVENANCE.md +12 -0
  80. package/src/fonts/instrument-serif/OFL.txt +93 -0
  81. package/src/fonts/instrument-serif/UPSTREAM.md +14 -0
  82. package/src/fonts/instrument-serif/instrument-serif-latin-400.woff2 +0 -0
  83. package/src/fonts/nebula-sans/LICENSE.txt +96 -0
  84. package/src/fonts/nebula-sans/NebulaSans-Black.woff2 +0 -0
  85. package/src/fonts/nebula-sans/NebulaSans-BlackItalic.woff2 +0 -0
  86. package/src/fonts/nebula-sans/NebulaSans-Bold.otf +0 -0
  87. package/src/fonts/nebula-sans/NebulaSans-Bold.woff2 +0 -0
  88. package/src/fonts/nebula-sans/NebulaSans-BoldItalic.woff2 +0 -0
  89. package/src/fonts/nebula-sans/NebulaSans-Book.otf +0 -0
  90. package/src/fonts/nebula-sans/NebulaSans-Book.woff2 +0 -0
  91. package/src/fonts/nebula-sans/NebulaSans-BookItalic.woff2 +0 -0
  92. package/src/fonts/nebula-sans/NebulaSans-Light.woff2 +0 -0
  93. package/src/fonts/nebula-sans/NebulaSans-LightItalic.woff2 +0 -0
  94. package/src/fonts/nebula-sans/NebulaSans-Medium.woff2 +0 -0
  95. package/src/fonts/nebula-sans/NebulaSans-MediumItalic.woff2 +0 -0
  96. package/src/fonts/nebula-sans/NebulaSans-Semibold.woff2 +0 -0
  97. package/src/fonts/nebula-sans/NebulaSans-SemiboldItalic.woff2 +0 -0
  98. package/src/fonts/nebula-sans/PROVENANCE.md +14 -0
  99. package/src/fonts/nebula-sans/social-fonts.generated.ts +3873 -0
  100. package/src/fonts.css +106 -0
  101. package/src/icons/act60/act60.svg +5 -0
  102. package/src/icons/act60/application.svg +9 -0
  103. package/src/icons/act60/chapter-compare.svg +3 -0
  104. package/src/icons/act60/decree-residence.svg +6 -0
  105. package/src/icons/act60/estimate.svg +7 -0
  106. package/src/icons/act60/export-services.svg +4 -0
  107. package/src/icons/act60/investor.svg +13 -0
  108. package/src/icons/act60/presence.svg +7 -0
  109. package/src/icons/aicharts/aicharts.svg +6 -0
  110. package/src/icons/aicharts/cost-compare.svg +4 -0
  111. package/src/icons/aicharts/task-audio.svg +7 -0
  112. package/src/icons/aicharts/task-coding.svg +6 -0
  113. package/src/icons/aicharts/task-images.svg +3 -0
  114. package/src/icons/aicharts/task-reasoning.svg +9 -0
  115. package/src/icons/aicharts/task-research.svg +5 -0
  116. package/src/icons/aicharts/task-video.svg +4 -0
  117. package/src/icons/manifest.json +1371 -0
  118. package/src/icons/platonik/conversation.svg +3 -0
  119. package/src/icons/platonik/creature.svg +7 -0
  120. package/src/icons/platonik/economy.svg +4 -0
  121. package/src/icons/platonik/keep-light.svg +6 -0
  122. package/src/icons/platonik/platonik.svg +7 -0
  123. package/src/icons/platonik/spark-route.svg +15 -0
  124. package/src/icons/receipts/act60-retry.receipt.json +888 -0
  125. package/src/icons/receipts/act60.receipt.json +1366 -0
  126. package/src/icons/receipts/aicharts.receipt.json +1546 -0
  127. package/src/icons/receipts/platonik.receipt.json +1011 -0
  128. package/src/icons/receipts/roughday.receipt.json +770 -0
  129. package/src/icons/receipts/shared.receipt.json +1296 -0
  130. package/src/icons/receipts/slopcamera.receipt.json +1495 -0
  131. package/src/icons/receipts/soundfish-retry.receipt.json +460 -0
  132. package/src/icons/receipts/soundfish.receipt.json +1709 -0
  133. package/src/icons/receipts/sponge.receipt.json +1743 -0
  134. package/src/icons/receipts/stripe-history-retry.receipt.json +145 -0
  135. package/src/icons/receipts/stripe-history.receipt.json +1202 -0
  136. package/src/icons/receipts/wordcell.receipt.json +1924 -0
  137. package/src/icons/roughday/finance.svg +7 -0
  138. package/src/icons/roughday/roughday.svg +6 -0
  139. package/src/icons/roughday/technology.svg +4 -0
  140. package/src/icons/roughday/world.svg +4 -0
  141. package/src/icons/sets/act60.json +63 -0
  142. package/src/icons/sets/aicharts.json +63 -0
  143. package/src/icons/sets/platonik.json +39 -0
  144. package/src/icons/sets/roughday.json +25 -0
  145. package/src/icons/sets/shared.json +12 -0
  146. package/src/icons/sets/slopcamera.json +47 -0
  147. package/src/icons/sets/soundfish.json +43 -0
  148. package/src/icons/sets/sponge.json +51 -0
  149. package/src/icons/sets/stripe-history.json +39 -0
  150. package/src/icons/sets/wordcell.json +51 -0
  151. package/src/icons/shared/agent-skill.svg +4 -0
  152. package/src/icons/shared/cli.svg +5 -0
  153. package/src/icons/shared/privacy.svg +3 -0
  154. package/src/icons/shared/research.svg +7 -0
  155. package/src/icons/shared/sdk.svg +3 -0
  156. package/src/icons/slopcamera/diagram.svg +3 -0
  157. package/src/icons/slopcamera/direct-scene.svg +5 -0
  158. package/src/icons/slopcamera/edit-video.svg +17 -0
  159. package/src/icons/slopcamera/mcp.svg +3 -0
  160. package/src/icons/slopcamera/native-world.svg +3 -0
  161. package/src/icons/slopcamera/slopcamera.svg +11 -0
  162. package/src/icons/soundfish/agent-ui.svg +7 -0
  163. package/src/icons/soundfish/collaborate.svg +5 -0
  164. package/src/icons/soundfish/compose.svg +3 -0
  165. package/src/icons/soundfish/hear.svg +6 -0
  166. package/src/icons/soundfish/human-ui.svg +6 -0
  167. package/src/icons/soundfish/share.svg +3 -0
  168. package/src/icons/soundfish/soundfish.svg +6 -0
  169. package/src/icons/sponge/api.svg +3 -0
  170. package/src/icons/sponge/documents.svg +3 -0
  171. package/src/icons/sponge/library.svg +3 -0
  172. package/src/icons/sponge/one-question.svg +5 -0
  173. package/src/icons/sponge/people-direct.svg +5 -0
  174. package/src/icons/sponge/read.svg +3 -0
  175. package/src/icons/sponge/save.svg +4 -0
  176. package/src/icons/sponge/sponge.svg +7 -0
  177. package/src/icons/stripe-history/company-history.svg +3 -0
  178. package/src/icons/stripe-history/evidence.svg +4 -0
  179. package/src/icons/stripe-history/independence.svg +7 -0
  180. package/src/icons/stripe-history/publications.svg +11 -0
  181. package/src/icons/stripe-history/sources.svg +6 -0
  182. package/src/icons/stripe-history/stripe-history.svg +3 -0
  183. package/src/icons/wordcell/backlinks.svg +6 -0
  184. package/src/icons/wordcell/capture.svg +6 -0
  185. package/src/icons/wordcell/git-provenance.svg +4 -0
  186. package/src/icons/wordcell/kb.svg +4 -0
  187. package/src/icons/wordcell/markdown.svg +4 -0
  188. package/src/icons/wordcell/scopes.svg +3 -0
  189. package/src/icons/wordcell/search.svg +7 -0
  190. package/src/icons.generated.ts +734 -0
  191. package/src/icons.ts +51 -0
  192. package/src/index.ts +275 -0
  193. package/src/lantern-material.css +213 -0
  194. package/src/launch.ts +624 -0
  195. package/src/marketing-assets/UPSTREAM.md +18 -0
  196. package/src/marketing-assets/cells.svg +1 -0
  197. package/src/marketing-assets/grain.svg +1 -0
  198. package/src/marketing-forced-colors.css +12 -0
  199. package/src/mockups/client.tsx +415 -0
  200. package/src/mockups/core.tsx +318 -0
  201. package/src/mockups/frames.tsx +368 -0
  202. package/src/mockups/index.ts +14 -0
  203. package/src/mockups/surfaces.tsx +681 -0
  204. package/src/mockups.css +2607 -0
  205. package/src/palette-appearance.ts +45 -0
  206. package/src/palette-bridge.css +124 -0
  207. package/src/palette-color.ts +41 -0
  208. package/src/palette-system.css +721 -0
  209. package/src/palette-themes.ts +23 -0
  210. package/src/palette-tokens.stylex.ts +519 -0
  211. package/src/palettes.css +3 -0
  212. package/src/palettes.ts +161 -0
  213. package/src/paper-theme.css +244 -0
  214. package/src/plain-publication.css +1241 -0
  215. package/src/plain-site.css +397 -0
  216. package/src/platforms.ts +151 -0
  217. package/src/portfolio.generated.json +1595 -0
  218. package/src/portfolio.generated.ts +1596 -0
  219. package/src/portfolio.ts +226 -0
  220. package/src/product-marketing-foundation.css +433 -0
  221. package/src/product-marketing-preset.css +261 -0
  222. package/src/product-marketing.css +2186 -0
  223. package/src/provider-marks.generated.ts +112 -0
  224. package/src/provider-marks.ts +143 -0
  225. package/src/react/animated-rail-stage.stylex.ts +15 -0
  226. package/src/react/animated-rail-stage.tsx +51 -0
  227. package/src/react/app-shell.stylex.ts +104 -0
  228. package/src/react/app-shell.tsx +121 -0
  229. package/src/react/article.tsx +602 -0
  230. package/src/react/aurora-dots-background.tsx +34 -0
  231. package/src/react/charts.stylex.ts +563 -0
  232. package/src/react/charts.tsx +610 -0
  233. package/src/react/chat.stylex.ts +34 -0
  234. package/src/react/chat.tsx +155 -0
  235. package/src/react/design-gallery.tsx +943 -0
  236. package/src/react/design-palette.stylex.ts +124 -0
  237. package/src/react/design-palette.tsx +196 -0
  238. package/src/react/design-theme-context.tsx +41 -0
  239. package/src/react/effects.stylex.ts +325 -0
  240. package/src/react/fader.stylex.ts +71 -0
  241. package/src/react/fader.tsx +151 -0
  242. package/src/react/foil-card-math.ts +100 -0
  243. package/src/react/foil-card-surface.stylex.ts +326 -0
  244. package/src/react/foil-card-surface.tsx +742 -0
  245. package/src/react/foil-mark.tsx +35 -0
  246. package/src/react/foil.stylex.ts +163 -0
  247. package/src/react/haptics.ts +228 -0
  248. package/src/react/hero-backdrop.tsx +22 -0
  249. package/src/react/index.ts +38 -0
  250. package/src/react/keyboard-shortcuts.ts +228 -0
  251. package/src/react/lantern-material-gallery.tsx +166 -0
  252. package/src/react/lantern-material.stylex.ts +39 -0
  253. package/src/react/launch-beats.tsx +73 -0
  254. package/src/react/navigation-rail.stylex.ts +130 -0
  255. package/src/react/navigation-rail.tsx +228 -0
  256. package/src/react/particle-halo.tsx +115 -0
  257. package/src/react/phaser-dots.tsx +501 -0
  258. package/src/react/platform-icons.tsx +94 -0
  259. package/src/react/platform-install.stylex.ts +385 -0
  260. package/src/react/platform-install.tsx +389 -0
  261. package/src/react/playback-transport.stylex.ts +14 -0
  262. package/src/react/playback-transport.tsx +112 -0
  263. package/src/react/procedural-backdrop.tsx +192 -0
  264. package/src/react/procedural-recipe.ts +323 -0
  265. package/src/react/product-marketing.stylex.ts +4469 -0
  266. package/src/react/product-marketing.tsx +1611 -0
  267. package/src/react/production-data-preview-notice.stylex.ts +40 -0
  268. package/src/react/production-data-preview-notice.tsx +34 -0
  269. package/src/react/provider-mark.stylex.ts +132 -0
  270. package/src/react/provider-mark.tsx +120 -0
  271. package/src/react/relative-time.tsx +117 -0
  272. package/src/react/route-state.stylex.ts +39 -0
  273. package/src/react/route-state.tsx +350 -0
  274. package/src/react/server.ts +11 -0
  275. package/src/react/social-kit-panel.tsx +103 -0
  276. package/src/react/sticky-offset.tsx +33 -0
  277. package/src/react/surfaces.stylex.ts +179 -0
  278. package/src/react/surfaces.tsx +330 -0
  279. package/src/react/syntax-code.tsx +33 -0
  280. package/src/react/theme-color-sync.ts +1 -0
  281. package/src/react/theme-resolution.ts +11 -0
  282. package/src/react/theme.stylex.ts +276 -0
  283. package/src/react/theme.tsx +402 -0
  284. package/src/reading.css +72 -0
  285. package/src/relative-time.ts +185 -0
  286. package/src/reset.css +2 -0
  287. package/src/site-shell.css +16 -0
  288. package/src/status-page-html.ts +63 -0
  289. package/src/status-page.css +276 -0
  290. package/src/status-page.ts +323 -0
  291. package/src/styles.css +21 -0
  292. package/src/syntax-code-lexers.ts +303 -0
  293. package/src/syntax-highlighting.css +78 -0
  294. package/src/syntax-highlighting.ts +477 -0
  295. package/src/syntax-tokens.ts +33 -0
  296. package/src/testing.ts +307 -0
  297. package/src/tokens.css +3 -0
  298. package/src/typography.css +86 -0
  299. package/vendor/evilcharts/LICENSE +21 -0
  300. package/vendor/evilcharts/UPSTREAM.md +14 -0
  301. package/vendor/platform-marks/LICENSE +30 -0
  302. package/vendor/platform-marks/UPSTREAM.md +15 -0
  303. package/vendor/platform-marks/apple.svg +1 -0
  304. package/vendor/platform-marks/linux.svg +1 -0
  305. package/vendor/provider-marks/CRUSH-LICENSE.md +134 -0
  306. package/vendor/provider-marks/LICENSE +21 -0
  307. package/vendor/provider-marks/UPSTREAM.md +27 -0
  308. package/vendor/provider-marks/aider.svg +3 -0
  309. package/vendor/provider-marks/crush-heartbit.svg +8 -0
  310. package/vendor/provider-marks/lobehub/alibabacloud-color.svg +1 -0
  311. package/vendor/provider-marks/lobehub/alibabacloud.svg +1 -0
  312. package/vendor/provider-marks/lobehub/amp-color.svg +1 -0
  313. package/vendor/provider-marks/lobehub/amp.svg +1 -0
  314. package/vendor/provider-marks/lobehub/anthropic.svg +1 -0
  315. package/vendor/provider-marks/lobehub/claude-color.svg +1 -0
  316. package/vendor/provider-marks/lobehub/claude.svg +1 -0
  317. package/vendor/provider-marks/lobehub/claudecode-color.svg +1 -0
  318. package/vendor/provider-marks/lobehub/claudecode.svg +1 -0
  319. package/vendor/provider-marks/lobehub/codex-color.svg +1 -0
  320. package/vendor/provider-marks/lobehub/codex.svg +1 -0
  321. package/vendor/provider-marks/lobehub/cursor.svg +1 -0
  322. package/vendor/provider-marks/lobehub/deepseek-color.svg +1 -0
  323. package/vendor/provider-marks/lobehub/deepseek.svg +1 -0
  324. package/vendor/provider-marks/lobehub/devin-color.svg +1 -0
  325. package/vendor/provider-marks/lobehub/devin.svg +1 -0
  326. package/vendor/provider-marks/lobehub/gemini-color.svg +1 -0
  327. package/vendor/provider-marks/lobehub/gemini.svg +1 -0
  328. package/vendor/provider-marks/lobehub/geminicli-color.svg +1 -0
  329. package/vendor/provider-marks/lobehub/geminicli.svg +1 -0
  330. package/vendor/provider-marks/lobehub/goose.svg +1 -0
  331. package/vendor/provider-marks/lobehub/meta-color.svg +1 -0
  332. package/vendor/provider-marks/lobehub/meta.svg +1 -0
  333. package/vendor/provider-marks/lobehub/mistral-color.svg +1 -0
  334. package/vendor/provider-marks/lobehub/mistral.svg +1 -0
  335. package/vendor/provider-marks/lobehub/moonshot.svg +1 -0
  336. package/vendor/provider-marks/lobehub/nvidia-color.svg +1 -0
  337. package/vendor/provider-marks/lobehub/nvidia.svg +1 -0
  338. package/vendor/provider-marks/lobehub/openai.svg +1 -0
  339. package/vendor/provider-marks/lobehub/opencode.svg +1 -0
  340. package/vendor/provider-marks/lobehub/perplexity-color.svg +1 -0
  341. package/vendor/provider-marks/lobehub/perplexity.svg +1 -0
  342. package/vendor/provider-marks/lobehub/qwen-color.svg +1 -0
  343. package/vendor/provider-marks/lobehub/qwen.svg +1 -0
  344. package/vendor/provider-marks/lobehub/xai.svg +1 -0
  345. package/vendor/provider-marks/lobehub/zai.svg +1 -0
@@ -0,0 +1,760 @@
1
+ // src/syntax-highlighting.ts
2
+ import { highlight } from "sugar-high";
3
+
4
+ // src/syntax-tokens.ts
5
+ function escapeHtml(value) {
6
+ return value.replace(/[&<>"']/gu, (character) => {
7
+ switch (character) {
8
+ case "&":
9
+ return "&amp;";
10
+ case "<":
11
+ return "&lt;";
12
+ case ">":
13
+ return "&gt;";
14
+ case '"':
15
+ return "&quot;";
16
+ case "'":
17
+ return "&#39;";
18
+ default:
19
+ return character;
20
+ }
21
+ });
22
+ }
23
+ function token(kind, value) {
24
+ return `<span class="syntax-token syntax-token--${kind}">${escapeHtml(value)}</span>`;
25
+ }
26
+
27
+ // src/syntax-code-lexers.ts
28
+ var rustKeywords = new Set("as async await break const continue crate dyn else enum extern false fn for if impl in let loop match mod move mut pub ref return self Self static struct super trait true type unsafe use where while union yield".split(" "));
29
+ var rustTypes = new Set("bool char str usize isize u8 u16 u32 u64 u128 i8 i16 i32 i64 i128 f32 f64".split(" "));
30
+ var leanKeywords = new Set("abbrev axiom by case class deriving do else end example exists export false for forall fun have if import in inductive instance let match namespace noncomputable opaque open partial private protected public return section simp simpa structure termination_by theorem then true universe variable where with def".split(" "));
31
+ var tlaKeywords = new Set("ACTION ASSUME ASSUMPTION AXIOM BOOLEAN BY CASE CHOOSE CONSTANT CONSTANTS COROLLARY DEF DEFINE DEFS DOMAIN ELSE ENABLED EXCEPT EXTENDS FALSE HAVE HIDE IF IN INSTANCE LAMBDA LEMMA LET LOCAL MODULE NEW OBVIOUS OMITTED ONLY OTHER PICK PROOF PROPOSITION PROVE QED RECURSIVE STATE SUBSET SUFFICES TAKE TEMPORAL THEOREM THEN TRUE UNCHANGED UNION USE VARIABLE VARIABLES WITH WITNESS".split(" "));
32
+ function matchAt(pattern, source, cursor) {
33
+ pattern.lastIndex = cursor;
34
+ return pattern.exec(source)?.[0] ?? "";
35
+ }
36
+ function lineEnd(source, start) {
37
+ let cursor = start;
38
+ while (cursor < source.length && source[cursor] !== `
39
+ ` && source[cursor] !== "\r")
40
+ cursor += 1;
41
+ return cursor;
42
+ }
43
+ function blockCommentEnd(source, start, open, close) {
44
+ let cursor = start + open.length;
45
+ let depth = 1;
46
+ while (cursor < source.length) {
47
+ if (source.startsWith(open, cursor)) {
48
+ depth += 1;
49
+ cursor += open.length;
50
+ } else if (source.startsWith(close, cursor)) {
51
+ depth -= 1;
52
+ cursor += close.length;
53
+ if (depth === 0)
54
+ return cursor;
55
+ } else
56
+ cursor += 1;
57
+ }
58
+ return cursor;
59
+ }
60
+ function rustRawStringEnd(source, start) {
61
+ let cursor = start;
62
+ if (source.startsWith("br", cursor) || source.startsWith("cr", cursor))
63
+ cursor += 1;
64
+ if (source[cursor] !== "r")
65
+ return null;
66
+ cursor += 1;
67
+ const hashesStart = cursor;
68
+ while (source[cursor] === "#")
69
+ cursor += 1;
70
+ const hashes = cursor - hashesStart;
71
+ if (source[cursor] !== '"')
72
+ return null;
73
+ cursor += 1;
74
+ while (cursor < source.length) {
75
+ if (source[cursor++] !== '"')
76
+ continue;
77
+ let seen = 0;
78
+ while (seen < hashes && source[cursor] === "#") {
79
+ seen += 1;
80
+ cursor += 1;
81
+ }
82
+ if (seen === hashes)
83
+ return cursor;
84
+ }
85
+ return cursor;
86
+ }
87
+ function quotedEnd(source, start, quote, escapes, doubled = false) {
88
+ let cursor = start + 1;
89
+ while (cursor < source.length) {
90
+ const character = source[cursor++];
91
+ if (escapes && character === "\\" && cursor < source.length)
92
+ cursor += 1;
93
+ else if (character === quote) {
94
+ if (doubled && source[cursor] === quote)
95
+ cursor += 1;
96
+ else
97
+ return cursor;
98
+ }
99
+ }
100
+ return cursor;
101
+ }
102
+ function followingCharacter(source, start) {
103
+ let cursor = start;
104
+ while (/\s/u.test(source[cursor] ?? "") && cursor < source.length)
105
+ cursor += 1;
106
+ return source[cursor] ?? "";
107
+ }
108
+ function identifierAt(source, start) {
109
+ let cursor = start;
110
+ while (cursor < source.length) {
111
+ const code = source.codePointAt(cursor) ?? 0;
112
+ const ascii = code === 95 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || cursor > start && code >= 48 && code <= 57;
113
+ if (!ascii && (code < 128 || /[\s«»∀∃→←↔∧∨¬≤≥≠∈]/u.test(String.fromCodePoint(code))))
114
+ break;
115
+ cursor += code > 65535 ? 2 : 1;
116
+ }
117
+ return source.slice(start, cursor);
118
+ }
119
+ function highlightProgram(source, language) {
120
+ const html = [];
121
+ const numbers = /(?:0[xX][0-9a-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|[0-9][0-9_]*(?:\.(?![.A-Za-z_\u0080-\u{10ffff}])[0-9_]*)?(?:[eE][+-]?[0-9_]+)?)(?:[iu](?:8|16|32|64|128|size)|f(?:32|64))?/uy;
122
+ const rustCharacters = /b?'(?:\\(?:[nrt0\\'"]|x[0-9a-fA-F]{2}|u\{[0-9a-fA-F_]{1,6}\})|[^'\\\r\n])'/uy;
123
+ const tlaWords = /\\[A-Za-z]+/y;
124
+ const keywords = language === "rust" ? rustKeywords : language === "lean" ? leanKeywords : tlaKeywords;
125
+ const lineComment = language === "rust" ? "//" : language === "lean" ? "--" : "\\*";
126
+ const openComment = language === "rust" ? "/*" : language === "lean" ? "/-" : "(*";
127
+ const closeComment = language === "rust" ? "*/" : language === "lean" ? "-/" : "*)";
128
+ let cursor = 0;
129
+ const emit = (kind, end) => {
130
+ html.push(token(kind, source.slice(cursor, end)));
131
+ cursor = end;
132
+ };
133
+ while (cursor < source.length) {
134
+ if (source.startsWith(lineComment, cursor)) {
135
+ emit("comment", lineEnd(source, cursor));
136
+ continue;
137
+ }
138
+ if (source.startsWith(openComment, cursor)) {
139
+ emit("comment", blockCommentEnd(source, cursor, openComment, closeComment));
140
+ continue;
141
+ }
142
+ if (language === "rust") {
143
+ const rawEnd = rustRawStringEnd(source, cursor);
144
+ if (rawEnd !== null) {
145
+ emit("string", rawEnd);
146
+ continue;
147
+ }
148
+ const character2 = matchAt(rustCharacters, source, cursor);
149
+ if (character2 !== "") {
150
+ emit("string", cursor + character2.length);
151
+ continue;
152
+ }
153
+ const lifetime = source[cursor] === "'" ? identifierAt(source, cursor + 1) : "";
154
+ if (lifetime !== "") {
155
+ emit("variable", cursor + 1 + lifetime.length);
156
+ continue;
157
+ }
158
+ if (source.startsWith('b"', cursor) || source.startsWith('c"', cursor)) {
159
+ emit("string", quotedEnd(source, cursor + 1, '"', true));
160
+ continue;
161
+ }
162
+ if (source.startsWith("r#", cursor)) {
163
+ const identifier2 = identifierAt(source, cursor + 2);
164
+ if (identifier2 !== "") {
165
+ emit("variable", cursor + 2 + identifier2.length);
166
+ continue;
167
+ }
168
+ }
169
+ }
170
+ if (source[cursor] === '"') {
171
+ emit("string", quotedEnd(source, cursor, '"', true));
172
+ continue;
173
+ }
174
+ if (language === "lean" && source[cursor] === "«") {
175
+ const end = source.indexOf("»", cursor + 1);
176
+ emit("variable", end === -1 ? source.length : end + 1);
177
+ continue;
178
+ }
179
+ if (language === "tla") {
180
+ const word = matchAt(tlaWords, source, cursor);
181
+ if (word !== "") {
182
+ emit("keyword", cursor + word.length);
183
+ continue;
184
+ }
185
+ }
186
+ const number = matchAt(numbers, source, cursor);
187
+ if (number !== "") {
188
+ emit("number", cursor + number.length);
189
+ continue;
190
+ }
191
+ const identifier = identifierAt(source, cursor);
192
+ if (identifier !== "") {
193
+ const end = cursor + identifier.length;
194
+ const next = followingCharacter(source, end);
195
+ const kind = keywords.has(identifier) ? "keyword" : language === "rust" && rustTypes.has(identifier) ? "type" : next === "(" || language === "rust" && source[end] === "!" && source[end + 1] !== "=" ? "function" : /^[A-Z]/u.test(identifier) ? "type" : null;
196
+ if (kind === null) {
197
+ html.push(escapeHtml(identifier));
198
+ cursor = end;
199
+ } else
200
+ emit(kind, end);
201
+ continue;
202
+ }
203
+ const character = source[cursor] ?? "";
204
+ if (/[{}()[\];,.#:+*/%&|!<>=?~^\\'∀∃λ→←↔∧∨¬≤≥≠∈-]/u.test(character))
205
+ emit("operator", cursor + 1);
206
+ else {
207
+ html.push(escapeHtml(character));
208
+ cursor += 1;
209
+ }
210
+ }
211
+ return html.join("");
212
+ }
213
+ function tomlStringEnd(source, start) {
214
+ const quote = source[start] ?? '"';
215
+ const triple = quote.repeat(3);
216
+ if (!source.startsWith(triple, start))
217
+ return quotedEnd(source, start, quote, quote === '"');
218
+ let cursor = start + 3;
219
+ while (cursor < source.length) {
220
+ if (source[cursor] === "\\" && quote === '"') {
221
+ cursor += Math.min(2, source.length - cursor);
222
+ continue;
223
+ }
224
+ if (source.startsWith(triple, cursor)) {
225
+ cursor += 3;
226
+ for (let extra = 0;extra < 2 && source[cursor] === quote; extra += 1)
227
+ cursor += 1;
228
+ return cursor;
229
+ }
230
+ cursor += 1;
231
+ }
232
+ return cursor;
233
+ }
234
+ function highlightToml(source) {
235
+ const html = [];
236
+ const bare = /[A-Za-z0-9_-]+/y;
237
+ const scalar = /(?:[+-]?(?:inf|nan)|true|false|[+-]?(?:0x[0-9a-fA-F_]+|0o[0-7_]+|0b[01_]+|[0-9][0-9_]*(?:\.[0-9_]+)?(?:[eE][+-]?[0-9_]+)?))(?![A-Za-z0-9_-])/y;
238
+ const date = /[0-9]{4}-[0-9]{2}-[0-9]{2}(?:[Tt ][0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]+)?(?:[Zz]|[+-][0-9]{2}:[0-9]{2})?)?|[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]+)?/y;
239
+ let cursor = 0;
240
+ let expectsKey = true;
241
+ let lineStart = true;
242
+ let table = false;
243
+ const containers = [];
244
+ const emit = (kind, end) => {
245
+ html.push(token(kind, source.slice(cursor, end)));
246
+ cursor = end;
247
+ };
248
+ while (cursor < source.length) {
249
+ const character = source[cursor] ?? "";
250
+ if (character === `
251
+ ` || character === "\r") {
252
+ html.push(character);
253
+ cursor += 1;
254
+ lineStart = true;
255
+ table = false;
256
+ if (containers.length === 0)
257
+ expectsKey = true;
258
+ continue;
259
+ }
260
+ if (/\s/u.test(character)) {
261
+ html.push(escapeHtml(character));
262
+ cursor += 1;
263
+ continue;
264
+ }
265
+ if (character === "#") {
266
+ emit("comment", lineEnd(source, cursor));
267
+ continue;
268
+ }
269
+ if (lineStart && character === "[" && containers.length === 0) {
270
+ table = true;
271
+ expectsKey = true;
272
+ }
273
+ lineStart = false;
274
+ if (character === '"' || character === "'") {
275
+ emit(expectsKey ? "property" : "string", tomlStringEnd(source, cursor));
276
+ continue;
277
+ }
278
+ if (!expectsKey) {
279
+ const value = matchAt(date, source, cursor) || matchAt(scalar, source, cursor);
280
+ if (value !== "") {
281
+ emit(value === "true" || value === "false" ? "keyword" : "number", cursor + value.length);
282
+ continue;
283
+ }
284
+ }
285
+ const word = matchAt(bare, source, cursor);
286
+ if (word !== "") {
287
+ if (expectsKey)
288
+ emit("property", cursor + word.length);
289
+ else {
290
+ html.push(escapeHtml(word));
291
+ cursor += word.length;
292
+ }
293
+ continue;
294
+ }
295
+ if (character === "=")
296
+ expectsKey = false;
297
+ else if (character === "{" || !table && character === "[") {
298
+ containers.push(character);
299
+ expectsKey = character === "{";
300
+ } else if (!table && (character === "}" || character === "]")) {
301
+ containers.pop();
302
+ expectsKey = false;
303
+ } else if (character === ",")
304
+ expectsKey = containers.at(-1) === "{";
305
+ if (/[=.,{}[\]]/u.test(character))
306
+ emit("operator", cursor + 1);
307
+ else {
308
+ html.push(escapeHtml(character));
309
+ cursor += 1;
310
+ }
311
+ }
312
+ return html.join("");
313
+ }
314
+ function yamlBlockEnd(source, headerEnd, parentIndent, explicitIndent) {
315
+ let cursor = headerEnd;
316
+ let contentIndent = explicitIndent === 0 ? null : parentIndent + explicitIndent;
317
+ while (cursor < source.length) {
318
+ const start = cursor;
319
+ if (source[cursor] === "\r")
320
+ cursor += 1;
321
+ if (source[cursor] === `
322
+ `)
323
+ cursor += 1;
324
+ const lineStart = cursor;
325
+ while (source[cursor] === " ")
326
+ cursor += 1;
327
+ const indent = cursor - lineStart;
328
+ const end = lineEnd(source, cursor);
329
+ if (cursor === end) {
330
+ cursor = end;
331
+ continue;
332
+ }
333
+ if (contentIndent === null)
334
+ contentIndent = indent > parentIndent ? indent : null;
335
+ if (contentIndent === null || indent < contentIndent)
336
+ return start;
337
+ cursor = end;
338
+ }
339
+ return cursor;
340
+ }
341
+ function highlightYaml(source) {
342
+ const html = [];
343
+ const names = /[&*][^\s,[\]{}]+/y;
344
+ const scalar = /(?:true|false|null|~|[+-]?(?:\.inf|\.nan|0x[0-9a-fA-F_]+|0o[0-7_]+|[0-9][0-9_]*(?:\.[0-9_]*)?(?:[eE][+-]?[0-9_]+)?))(?=$|[\s,\]}])/iy;
345
+ let cursor = 0;
346
+ let lineStart = 0;
347
+ let cachedLineEnd = -1;
348
+ const currentLineEnd = () => {
349
+ if (cachedLineEnd < cursor)
350
+ cachedLineEnd = lineEnd(source, cursor);
351
+ return cachedLineEnd;
352
+ };
353
+ const emit = (kind, end) => {
354
+ html.push(token(kind, source.slice(cursor, end)));
355
+ cursor = end;
356
+ };
357
+ while (cursor < source.length) {
358
+ const character = source[cursor] ?? "";
359
+ if (character === `
360
+ ` || character === "\r") {
361
+ html.push(character);
362
+ cursor += 1;
363
+ lineStart = cursor;
364
+ continue;
365
+ }
366
+ if (/\s/u.test(character)) {
367
+ html.push(escapeHtml(character));
368
+ cursor += 1;
369
+ continue;
370
+ }
371
+ if (character === "#") {
372
+ emit("comment", currentLineEnd());
373
+ continue;
374
+ }
375
+ if (character === '"' || character === "'") {
376
+ const end2 = quotedEnd(source, cursor, character, character === '"', character === "'");
377
+ emit(followingCharacter(source, end2) === ":" ? "property" : "string", end2);
378
+ continue;
379
+ }
380
+ const name = matchAt(names, source, cursor);
381
+ if (name !== "") {
382
+ emit("variable", cursor + name.length);
383
+ continue;
384
+ }
385
+ if ((character === "|" || character === ">") && /^(?:[1-9][+-]?|[+-][1-9]?|)[ \t]*(?:#.*)?$/u.test(source.slice(cursor + 1, currentLineEnd()))) {
386
+ const end2 = currentLineEnd();
387
+ const header = source.slice(cursor, end2);
388
+ const explicit = /[1-9]/u.exec(header)?.[0];
389
+ let indentation = lineStart;
390
+ while (source[indentation] === " ")
391
+ indentation += 1;
392
+ emit("operator", cursor + 1 + (header.slice(1).match(/^[1-9+-]{0,2}/u)?.[0].length ?? 0));
393
+ const comment = source.indexOf("#", cursor);
394
+ if (comment !== -1 && comment < end2) {
395
+ html.push(escapeHtml(source.slice(cursor, comment)));
396
+ cursor = comment;
397
+ emit("comment", end2);
398
+ } else {
399
+ html.push(escapeHtml(source.slice(cursor, end2)));
400
+ cursor = end2;
401
+ }
402
+ const bodyEnd = yamlBlockEnd(source, end2, indentation - lineStart, Number(explicit ?? 0));
403
+ if (bodyEnd > cursor)
404
+ emit("string", bodyEnd);
405
+ continue;
406
+ }
407
+ if ((source.startsWith("---", cursor) || source.startsWith("...", cursor)) && cursor === lineStart && /^\s?$/u.test(source[cursor + 3] ?? "")) {
408
+ emit("marker", cursor + 3);
409
+ continue;
410
+ }
411
+ if (/[{}[\],]/u.test(character) || (character === ":" || character === "-" || character === "?") && /^\s?$/u.test(source[cursor + 1] ?? "")) {
412
+ emit("operator", cursor + 1);
413
+ continue;
414
+ }
415
+ const value = matchAt(scalar, source, cursor);
416
+ if (value !== "") {
417
+ emit(/^(?:true|false|null|~)$/iu.test(value) ? "keyword" : "number", cursor + value.length);
418
+ continue;
419
+ }
420
+ let end = cursor;
421
+ while (end < source.length && source[end] !== `
422
+ ` && source[end] !== "\r") {
423
+ if (/[{}[\],]/u.test(source[end] ?? "") || source[end] === ":" && /^\s?$/u.test(source[end + 1] ?? "") || source[end] === "#" && end > cursor && /\s/u.test(source[end - 1] ?? ""))
424
+ break;
425
+ end += 1;
426
+ }
427
+ if (end === cursor)
428
+ end += 1;
429
+ const valueEnd = source.slice(cursor, end).trimEnd().length + cursor;
430
+ if (source[end] === ":" && valueEnd > cursor)
431
+ emit("property", valueEnd);
432
+ else {
433
+ html.push(escapeHtml(source.slice(cursor, end)));
434
+ cursor = end;
435
+ }
436
+ }
437
+ return html.join("");
438
+ }
439
+ function highlightCodeLexer(source, language) {
440
+ if (language === "toml")
441
+ return highlightToml(source);
442
+ if (language === "yaml")
443
+ return highlightYaml(source);
444
+ return highlightProgram(source, language);
445
+ }
446
+
447
+ // src/syntax-highlighting.ts
448
+ var syntaxLanguages = ["css", "html", "json", "lean", "markdown", "rust", "shell", "text", "tla", "toml", "typescript", "yaml"];
449
+ var maximumSyntaxCharacters = 128 * 1024;
450
+ function classOnlySyntax(html) {
451
+ const result = html.replace(/<span class="sh__token--(class|comment|entity|identifier|jsxliterals|keyword|property|sign|space|string)" style="color:var\(--sh-\1\)">/gu, '<span class="sh__token--$1">');
452
+ if (/<[A-Za-z][^<>]*\sstyle\s*=/iu.test(result)) {
453
+ throw new Error("Unrecognized inline style in class-only syntax output.");
454
+ }
455
+ return result;
456
+ }
457
+ var shellKeywords = new Set(["case", "do", "done", "elif", "else", "esac", "fi", "for", "function", "if", "in", "select", "then", "time", "until", "while"]);
458
+ var shellKeywordsFollowedByCommand = new Set(["do", "elif", "if", "then", "until", "while"]);
459
+ function languageToken(input) {
460
+ const tokens = input.trim().toLowerCase().split(/\s+/u);
461
+ const languageClass = tokens.find((token2) => token2.startsWith("language-"));
462
+ return (languageClass ?? tokens[0] ?? "").replace(/^language-/u, "");
463
+ }
464
+ function resolveSyntaxLanguage(input) {
465
+ if (typeof input !== "string")
466
+ return "text";
467
+ switch (languageToken(input)) {
468
+ case "css":
469
+ return "css";
470
+ case "htm":
471
+ case "html":
472
+ case "xml":
473
+ return "html";
474
+ case "json":
475
+ case "jsonc":
476
+ return "json";
477
+ case "lean":
478
+ case "lean4":
479
+ return "lean";
480
+ case "rust":
481
+ case "rs":
482
+ return "rust";
483
+ case "tla":
484
+ case "tla+":
485
+ case "tlaplus":
486
+ return "tla";
487
+ case "toml":
488
+ return "toml";
489
+ case "yaml":
490
+ case "yml":
491
+ return "yaml";
492
+ case "markdown":
493
+ case "md":
494
+ case "mdx":
495
+ return "markdown";
496
+ case "bash":
497
+ case "console":
498
+ case "sh":
499
+ case "shell":
500
+ case "zsh":
501
+ return "shell";
502
+ case "javascript":
503
+ case "js":
504
+ case "jsx":
505
+ case "ts":
506
+ case "tsx":
507
+ case "typescript":
508
+ return "typescript";
509
+ case "plaintext":
510
+ case "text":
511
+ case "txt":
512
+ default:
513
+ return "text";
514
+ }
515
+ }
516
+ function inferSyntaxLanguage(code) {
517
+ if (code.length > maximumSyntaxCharacters)
518
+ return "text";
519
+ const trimmed = code.trim();
520
+ if (trimmed === "")
521
+ return "text";
522
+ if (trimmed[0] === "{" || trimmed[0] === "[") {
523
+ try {
524
+ const value = JSON.parse(trimmed);
525
+ if (value !== null && typeof value === "object")
526
+ return "json";
527
+ } catch {}
528
+ }
529
+ const first = (trimmed.split(`
530
+ `, 1)[0] ?? "").slice(0, 2048);
531
+ if (/^#!\s*(?:\/bin\/(?:ba|z)?sh|\/usr\/bin\/env\s+(?:ba|z)?sh)(?:\s|$)/u.test(first) || /^(?:\$\s+)?(?:bun|npm|pnpm|yarn)\s+(?:add|install|run|test|build|remove|update|exec|dlx|create|init|ci|publish|pack)\b/u.test(first) || /^(?:\$\s+)?(?:bunx|npx)\s+(?:skills\s+add\b|create-[\w-]+\b|@[\w-]+\/[\w-]+\b|[\w-]+\s+--?[A-Za-z])/u.test(first) || /^(?:\$\s+)?git\s+(?:clone|status|diff|log|show|fetch|pull|push|checkout|switch|add|commit|branch|tag)\b/u.test(first) || /^(?:\$\s+)?curl\s+(?:--?[A-Za-z]|https?:\/\/)/u.test(first))
532
+ return "shell";
533
+ if (/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*:[^=]+)?\s*=/u.test(first) || /^import\s+(?:[\w*{].*\s+from\s+)?["']/u.test(first) || /^(?:export\s+)?(?:async\s+)?function\s+[A-Za-z_$][\w$]*\s*\(/u.test(first))
534
+ return "typescript";
535
+ if (/^#{1,6}\s+\S/u.test(first) || /^`{3,}\w*/u.test(first))
536
+ return "markdown";
537
+ if (/^<!doctype\s+html\b/iu.test(first) || /^<([a-z][\w:-]*)(?:\s[^<>]*|)>(?:[^]*?)<\/\1\s*>/iu.test(trimmed))
538
+ return "html";
539
+ const opening = trimmed.indexOf("{");
540
+ if (opening > 0 && opening < 2048 && /^[.#]?[a-zA-Z_][\w.# :>+~,-]*$/u.test(trimmed.slice(0, opening).trimEnd())) {
541
+ const declaration = trimmed.slice(opening + 1, opening + 2049).trimStart();
542
+ const colon = declaration.indexOf(":");
543
+ if (colon > 0 && /^-{0,2}[a-zA-Z][a-zA-Z-]*$/u.test(declaration.slice(0, colon).trimEnd()) && /^[^{};]+[;}]/u.test(declaration.slice(colon + 1).trimStart()))
544
+ return "css";
545
+ }
546
+ return "text";
547
+ }
548
+ function tokenHtml(kind, html) {
549
+ return `<span class="syntax-token syntax-token--${kind}">${html}</span>`;
550
+ }
551
+ function highlightMarkdownInline(value) {
552
+ let html = "";
553
+ let cursor = 0;
554
+ for (const match of value.matchAll(/`[^`\n]+`/gu)) {
555
+ const index = match.index;
556
+ const inlineCode = match[0];
557
+ html += escapeHtml(value.slice(cursor, index));
558
+ html += token("inline", inlineCode);
559
+ cursor = index + inlineCode.length;
560
+ }
561
+ return html + escapeHtml(value.slice(cursor));
562
+ }
563
+ function isMarkdownWhitespace(codeUnit) {
564
+ return codeUnit === 9 || codeUnit === 10 || codeUnit === 11 || codeUnit === 12 || codeUnit === 13 || codeUnit === 32 || codeUnit === 160 || codeUnit === 5760 || codeUnit >= 8192 && codeUnit <= 8202 || codeUnit === 8232 || codeUnit === 8233 || codeUnit === 8239 || codeUnit === 8287 || codeUnit === 12288 || codeUnit === 65279;
565
+ }
566
+ function isMarkdownLineTerminator(codeUnit) {
567
+ return codeUnit === 10 || codeUnit === 13 || codeUnit === 8232 || codeUnit === 8233;
568
+ }
569
+ function isAsciiDigit(codeUnit) {
570
+ return codeUnit >= 48 && codeUnit <= 57;
571
+ }
572
+ function markdownLineParts(line, kind) {
573
+ let markerStart = 0;
574
+ while (markerStart < line.length && isMarkdownWhitespace(line.charCodeAt(markerStart))) {
575
+ markerStart += 1;
576
+ }
577
+ let markerEnd = markerStart;
578
+ if (kind === "fence") {
579
+ const fence = line.charCodeAt(markerStart);
580
+ if (fence !== 96 && fence !== 126)
581
+ return null;
582
+ while (markerEnd < line.length && line.charCodeAt(markerEnd) === fence) {
583
+ markerEnd += 1;
584
+ }
585
+ if (markerEnd - markerStart < 3)
586
+ return null;
587
+ } else if (kind === "heading") {
588
+ while (markerEnd < line.length && markerEnd - markerStart < 6 && line.charCodeAt(markerEnd) === 35) {
589
+ markerEnd += 1;
590
+ }
591
+ if (markerEnd === markerStart)
592
+ return null;
593
+ } else {
594
+ const first = line.charCodeAt(markerStart);
595
+ if (first === 42 || first === 43 || first === 45) {
596
+ markerEnd += 1;
597
+ } else if (isAsciiDigit(first)) {
598
+ while (markerEnd < line.length && isAsciiDigit(line.charCodeAt(markerEnd))) {
599
+ markerEnd += 1;
600
+ }
601
+ if (line.charCodeAt(markerEnd) !== 46)
602
+ return null;
603
+ markerEnd += 1;
604
+ } else {
605
+ return null;
606
+ }
607
+ }
608
+ const separatorStart = markerEnd;
609
+ if (kind !== "fence") {
610
+ while (markerEnd < line.length && isMarkdownWhitespace(line.charCodeAt(markerEnd))) {
611
+ markerEnd += 1;
612
+ }
613
+ if (markerEnd === separatorStart)
614
+ return null;
615
+ }
616
+ for (let cursor = markerEnd;cursor < line.length; cursor += 1) {
617
+ if (isMarkdownLineTerminator(line.charCodeAt(cursor)))
618
+ return null;
619
+ }
620
+ return {
621
+ content: line.slice(markerEnd),
622
+ indentation: line.slice(0, markerStart),
623
+ marker: line.slice(markerStart, separatorStart),
624
+ separator: line.slice(separatorStart, markerEnd)
625
+ };
626
+ }
627
+ function highlightMarkdownLine(line) {
628
+ const fence = markdownLineParts(line, "fence");
629
+ if (fence !== null) {
630
+ return `${escapeHtml(fence.indentation)}${token("marker", fence.marker)}${token("keyword", fence.content)}`;
631
+ }
632
+ const heading = markdownLineParts(line, "heading");
633
+ if (heading !== null) {
634
+ return `${escapeHtml(heading.indentation)}${token("marker", heading.marker)}${escapeHtml(heading.separator)}${tokenHtml("heading", highlightMarkdownInline(heading.content))}`;
635
+ }
636
+ const listItem = markdownLineParts(line, "list");
637
+ if (listItem !== null) {
638
+ return `${escapeHtml(listItem.indentation)}${token("marker", listItem.marker)}${escapeHtml(listItem.separator)}${highlightMarkdownInline(listItem.content)}`;
639
+ }
640
+ const quote = /^(\s*)(>)(\s?)(.*)$/u.exec(line);
641
+ if (quote !== null) {
642
+ return `${escapeHtml(quote[1] ?? "")}${token("marker", quote[2] ?? "")}${escapeHtml(quote[3] ?? "")}${highlightMarkdownInline(quote[4] ?? "")}`;
643
+ }
644
+ return highlightMarkdownInline(line);
645
+ }
646
+ function highlightMarkdown(value) {
647
+ return value.split(`
648
+ `).map(highlightMarkdownLine).join(`
649
+ `);
650
+ }
651
+ function isShellOperator(character) {
652
+ return character === "&" || character === "(" || character === ")" || character === ";" || character === "<" || character === ">" || character === "|";
653
+ }
654
+ function isShellWhitespace(character) {
655
+ return /\s/u.test(character);
656
+ }
657
+ function isEscaped(line, index) {
658
+ let backslashes = 0;
659
+ for (let cursor = index - 1;cursor >= 0 && line[cursor] === "\\"; cursor -= 1) {
660
+ backslashes += 1;
661
+ }
662
+ return backslashes % 2 === 1;
663
+ }
664
+ function highlightShellLine(line) {
665
+ let cursor = 0;
666
+ let expectsCommand = true;
667
+ let html = "";
668
+ while (cursor < line.length) {
669
+ const character = line[cursor] ?? "";
670
+ if (isShellWhitespace(character)) {
671
+ html += escapeHtml(character);
672
+ cursor += 1;
673
+ continue;
674
+ }
675
+ if (character === "#") {
676
+ html += token("comment", line.slice(cursor));
677
+ break;
678
+ }
679
+ if (character === "'" || character === '"') {
680
+ const quote = character;
681
+ let end2 = cursor + 1;
682
+ while (end2 < line.length) {
683
+ const next = line[end2] ?? "";
684
+ end2 += 1;
685
+ if (next === quote && (quote === "'" || !isEscaped(line, end2 - 1)))
686
+ break;
687
+ }
688
+ html += token("string", line.slice(cursor, end2));
689
+ cursor = end2;
690
+ expectsCommand = false;
691
+ continue;
692
+ }
693
+ if (character === "$") {
694
+ if (line.slice(0, cursor).trim() === "" && /\s/u.test(line[cursor + 1] ?? "")) {
695
+ html += token("operator", character);
696
+ cursor += 1;
697
+ continue;
698
+ }
699
+ const variable = /^\$(?:\{[^}\n]*\}|[A-Za-z_][A-Za-z0-9_]*|[?$!#*@0-9-])/u.exec(line.slice(cursor))?.[0] ?? "$";
700
+ html += token("variable", variable);
701
+ cursor += variable.length;
702
+ expectsCommand = false;
703
+ continue;
704
+ }
705
+ if (isShellOperator(character)) {
706
+ const pair = line.slice(cursor, cursor + 2);
707
+ const operator = pair === "&&" || pair === "||" || pair === ">>" || pair === "<<" ? pair : character;
708
+ html += token("operator", operator);
709
+ cursor += operator.length;
710
+ expectsCommand = operator === ";" || operator === "&&" || operator === "||" || operator === "|";
711
+ continue;
712
+ }
713
+ let end = cursor + 1;
714
+ while (end < line.length) {
715
+ const next = line[end] ?? "";
716
+ if (isShellWhitespace(next) || isShellOperator(next) || next === "$" || next === "'" || next === '"') {
717
+ break;
718
+ }
719
+ end += 1;
720
+ }
721
+ const word = line.slice(cursor, end);
722
+ if (shellKeywords.has(word)) {
723
+ html += token("keyword", word);
724
+ expectsCommand = shellKeywordsFollowedByCommand.has(word);
725
+ } else if (word.startsWith("-")) {
726
+ html += token("flag", word);
727
+ expectsCommand = false;
728
+ } else if (expectsCommand && !word.includes("=")) {
729
+ html += token("command", word);
730
+ expectsCommand = false;
731
+ } else if (/^[A-Za-z_][A-Za-z0-9_]*=/u.test(word)) {
732
+ html += token("variable", word);
733
+ } else {
734
+ html += escapeHtml(word);
735
+ expectsCommand = false;
736
+ }
737
+ cursor = end;
738
+ }
739
+ return html;
740
+ }
741
+ function highlightShell(value) {
742
+ return value.split(`
743
+ `).map(highlightShellLine).join(`
744
+ `);
745
+ }
746
+ function highlightCode(code, languageHint, options = {}) {
747
+ const styles = options.styles ?? "inline";
748
+ if (styles !== "inline" && styles !== "classes") {
749
+ throw new Error("Syntax styles must be inline or classes.");
750
+ }
751
+ const language = code.length > maximumSyntaxCharacters ? "text" : languageHint === undefined || languageHint.trim() === "" || languageHint === "auto" ? inferSyntaxLanguage(code) : resolveSyntaxLanguage(languageHint);
752
+ const html = language === "text" ? escapeHtml(code) : language === "markdown" ? highlightMarkdown(code) : language === "shell" ? highlightShell(code) : language === "rust" || language === "toml" || language === "yaml" || language === "lean" || language === "tla" ? highlightCodeLexer(code, language) : highlight(code);
753
+ return Object.freeze({
754
+ className: `syntax-code language-${language}`,
755
+ html: styles === "classes" ? classOnlySyntax(html) : html,
756
+ language
757
+ });
758
+ }
759
+
760
+ export { syntaxLanguages, maximumSyntaxCharacters, resolveSyntaxLanguage, inferSyntaxLanguage, highlightCode };