reactive-md 0.6.1 → 0.8.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 (471) hide show
  1. package/CHANGELOG-ch.md +66 -0
  2. package/CHANGELOG.md +66 -0
  3. package/CONTRIBUTING-ch.md +6 -62
  4. package/CONTRIBUTING.md +5 -63
  5. package/README-ch.md +232 -67
  6. package/README-en.md +209 -71
  7. package/README.md +209 -71
  8. package/SECURITY-ch.md +3 -1
  9. package/SECURITY.md +3 -1
  10. package/THIRD_PARTY_NOTICES.md +1909 -87
  11. package/cli/args.mjs +33 -1
  12. package/cli/build.mjs +62 -1
  13. package/cli/check.mjs +444 -0
  14. package/cli/help.mjs +181 -3
  15. package/cli/init.mjs +1577 -0
  16. package/cli/main.mjs +11 -1
  17. package/cli/package-loader.mjs +41 -0
  18. package/dist-library/LocalDocumentView-6trX7xJc.js +97920 -0
  19. package/dist-library/{authoring-BEVyth5X.js → authoring-BsfSwQRm.js} +237 -209
  20. package/dist-library/compiler--ea2CKQF.js +61 -0
  21. package/dist-library/compiler-core-kPiH-gOV.js +11805 -0
  22. package/dist-library/component-state-Cq2K5gkS.js +490 -0
  23. package/dist-library/component-state-D_cw_EHe.js +54 -0
  24. package/dist-library/config-validation-DXTynAw7.js +3005 -0
  25. package/dist-library/default-components-Z_YMio5P.js +2346 -0
  26. package/dist-library/identity-MYJXKSkB.js +1443 -0
  27. package/dist-library/math-display-BJz4gbFc.js +24000 -0
  28. package/dist-library/math-sample-BGEW49zY.js +1124 -0
  29. package/dist-library/options-CX5m5n-J.js +115 -0
  30. package/dist-library/parser-standard-DlCk7sLo.js +10122 -0
  31. package/dist-library/props-DGlBk0e5.js +183 -0
  32. package/dist-library/react-ByOHunUW.js +122 -0
  33. package/dist-library/reactive-md-authoring.js +712 -1077
  34. package/dist-library/reactive-md-build.js +7966 -0
  35. package/dist-library/reactive-md-compiler-standard.js +33 -0
  36. package/dist-library/reactive-md-compiler.js +22 -0
  37. package/dist-library/reactive-md-default-packs.js +71 -0
  38. package/dist-library/reactive-md-default-preset.js +10 -0
  39. package/dist-library/reactive-md-export.js +111 -0
  40. package/dist-library/reactive-md-print.css +18 -3
  41. package/dist-library/reactive-md-react-runtime.js +251 -0
  42. package/dist-library/reactive-md-react-server.js +55 -0
  43. package/dist-library/reactive-md-react-unstyled.js +9 -1
  44. package/dist-library/reactive-md-react.js +9 -1
  45. package/dist-library/reactive-md-runtime-browser.js +51 -0
  46. package/dist-library/reactive-md-runtime.js +3 -0
  47. package/dist-library/reactive-md-sdk.js +6 -0
  48. package/dist-library/reactive-md-standalone-host.js +442 -0
  49. package/dist-library/reactive-md-testing-browser.js +523 -0
  50. package/dist-library/reactive-md-testing-react.js +221 -0
  51. package/dist-library/reactive-md-testing.js +638 -0
  52. package/dist-library/reactive-md-vite.js +959 -0
  53. package/dist-library/reactive-md.css +1 -1
  54. package/dist-library/reactive-md.js +1080 -795
  55. package/dist-library/registry-B9Jc3FVe.js +1174 -0
  56. package/dist-library/resources-BGt8mpDA.js +204 -0
  57. package/dist-library/runtime-C-sbfpOX.js +1157 -0
  58. package/dist-library/runtime-Dkq7ldyg.js +172 -0
  59. package/dist-library/schema-ZFufO8V0.js +39 -0
  60. package/dist-library/shareable-DDVL4Fi9.js +844 -0
  61. package/dist-library/types/authoring/catalog.d.ts +168 -0
  62. package/dist-library/types/authoring/conformance.d.ts +24 -0
  63. package/dist-library/types/{editor → authoring}/editor-i18n.d.ts +3 -24
  64. package/dist-library/types/authoring/extensions.d.ts +13 -0
  65. package/dist-library/types/authoring/index.d.ts +14 -11
  66. package/dist-library/types/authoring/insert.d.ts +16 -0
  67. package/dist-library/types/{editor → authoring}/native-components.d.ts +19 -2
  68. package/dist-library/types/authoring/templates.d.ts +65 -0
  69. package/dist-library/types/build/diagnostics.d.ts +8 -0
  70. package/dist-library/types/build/digest.d.ts +5 -0
  71. package/dist-library/types/build/entry.d.ts +9 -0
  72. package/dist-library/types/build/host.d.ts +36 -0
  73. package/dist-library/types/build/index.d.ts +99 -0
  74. package/dist-library/types/build/notices.d.ts +29 -0
  75. package/dist-library/types/build/resources.d.ts +60 -0
  76. package/dist-library/types/build/vite.d.ts +15 -0
  77. package/dist-library/types/compiler/index.d.ts +22 -0
  78. package/dist-library/types/compiler/result.d.ts +30 -0
  79. package/dist-library/types/compiler/standard.d.ts +16 -0
  80. package/dist-library/types/compiler/types.d.ts +69 -0
  81. package/dist-library/types/components/chart-motion.d.ts +12 -0
  82. package/dist-library/types/components/controls.d.ts +21 -0
  83. package/dist-library/types/{local → components}/data-table.d.ts +10 -24
  84. package/dist-library/types/components/default-chart-types.d.ts +22 -0
  85. package/dist-library/types/components/default-chart.d.ts +2 -0
  86. package/dist-library/types/components/default-preset.d.ts +10 -0
  87. package/dist-library/types/components/diagram-inspector.d.ts +24 -0
  88. package/dist-library/types/components/gallery.d.ts +6 -0
  89. package/dist-library/types/components/layout.d.ts +23 -0
  90. package/dist-library/types/components/mafs-plot-grid.d.ts +57 -0
  91. package/dist-library/types/components/mafs-visuals.d.ts +40 -0
  92. package/dist-library/types/components/numeric-sliders.d.ts +3 -0
  93. package/dist-library/types/components/uiarc/calendar/calendar.d.ts +26 -0
  94. package/dist-library/types/components/uiarc/date-picker/date-picker.d.ts +29 -0
  95. package/dist-library/types/components/uiarc/lib/motion-tokens.d.ts +2 -0
  96. package/dist-library/types/components/uiarc/lib/use-today.d.ts +2 -0
  97. package/dist-library/types/components/uiarc/motion-tokens.d.ts +60 -0
  98. package/dist-library/types/components/uiarc/rmd-motion.d.ts +12 -0
  99. package/dist-library/types/components/uiarc/select/select.d.ts +21 -0
  100. package/dist-library/types/components/uiarc/slider/slider.d.ts +53 -0
  101. package/dist-library/types/components/use-hydrated.d.ts +6 -0
  102. package/dist-library/types/components/visuals.d.ts +13 -0
  103. package/dist-library/types/export/component-state.d.ts +39 -0
  104. package/dist-library/types/export/index.d.ts +47 -0
  105. package/dist-library/types/export/requirements.d.ts +23 -0
  106. package/dist-library/types/export/resources.d.ts +8 -0
  107. package/dist-library/types/export/restoration.d.ts +52 -0
  108. package/dist-library/types/index.d.ts +1 -0
  109. package/dist-library/types/local/compilation/compiler-core.d.ts +16 -0
  110. package/dist-library/types/local/compilation/compiler-services.d.ts +64 -0
  111. package/dist-library/types/local/compilation/compiler-structure.d.ts +46 -0
  112. package/dist-library/types/local/compilation/compiler-values.d.ts +9 -0
  113. package/dist-library/types/local/compilation/compiler.d.ts +34 -0
  114. package/dist-library/types/local/compilation/component-kernel.d.ts +487 -0
  115. package/dist-library/types/local/{dependencies.d.ts → compilation/dependencies.d.ts} +4 -3
  116. package/dist-library/types/local/{diagnostics.d.ts → configuration/diagnostic-messages.d.ts} +193 -65
  117. package/dist-library/types/local/configuration/diagnostics.d.ts +58 -0
  118. package/dist-library/types/local/{limits.d.ts → configuration/limits.d.ts} +15 -2
  119. package/dist-library/types/local/configuration/options-core.d.ts +120 -0
  120. package/dist-library/types/local/configuration/options.d.ts +17 -0
  121. package/dist-library/types/local/configuration/portable-options.d.ts +3 -0
  122. package/dist-library/types/local/configuration/schema-core.d.ts +32 -0
  123. package/dist-library/types/local/configuration/schema.d.ts +12 -0
  124. package/dist-library/types/local/contracts/types.d.ts +519 -0
  125. package/dist-library/types/local/{version.d.ts → contracts/version.d.ts} +1 -1
  126. package/dist-library/types/local/{computations.d.ts → evaluation/computations.d.ts} +6 -3
  127. package/dist-library/types/local/{expression.d.ts → evaluation/expression.d.ts} +2 -2
  128. package/dist-library/types/local/{math-display.d.ts → evaluation/math-display.d.ts} +2 -16
  129. package/dist-library/types/local/evaluation/math-sample.d.ts +23 -0
  130. package/dist-library/types/local/evaluation/math.d.ts +73 -0
  131. package/dist-library/types/local/{validation.d.ts → evaluation/validation.d.ts} +1 -1
  132. package/dist-library/types/local/html/html-details.d.ts +16 -0
  133. package/dist-library/types/local/html/html-entities.d.ts +7 -0
  134. package/dist-library/types/local/html/html-policy.d.ts +43 -0
  135. package/dist-library/types/local/html/html-recovery.d.ts +16 -0
  136. package/dist-library/types/local/html/html-table-names.d.ts +9 -0
  137. package/dist-library/types/local/{html-table.d.ts → html/html-table.d.ts} +2 -6
  138. package/dist-library/types/local/{html.d.ts → html/html.d.ts} +1 -1
  139. package/dist-library/types/local/index.d.ts +31 -24
  140. package/dist-library/types/local/markdown/fast-markdown.d.ts +137 -0
  141. package/dist-library/types/local/{footnotes.d.ts → markdown/footnotes.d.ts} +1 -1
  142. package/dist-library/types/local/{heading-anchors.d.ts → markdown/heading-anchors.d.ts} +12 -2
  143. package/dist-library/types/local/markdown/markdown-blocks.d.ts +55 -0
  144. package/dist-library/types/local/markdown/markdown-structure.d.ts +3 -0
  145. package/dist-library/types/local/markdown/plain-paragraphs.d.ts +10 -0
  146. package/dist-library/types/local/parsing/lexical.d.ts +21 -0
  147. package/dist-library/types/local/parsing/parse-budget.d.ts +67 -0
  148. package/dist-library/types/local/parsing/parser-capabilities.d.ts +42 -0
  149. package/dist-library/types/local/parsing/parser-core.d.ts +65 -0
  150. package/dist-library/types/local/parsing/parser-standard.d.ts +7 -0
  151. package/dist-library/types/local/parsing/parser.d.ts +16 -0
  152. package/dist-library/types/local/parsing/rmd-recovery.d.ts +48 -0
  153. package/dist-library/types/local/{LocalDocumentView.d.ts → rendering/LocalDocumentView.d.ts} +67 -24
  154. package/dist-library/types/local/rendering/legacy-component-adapter.d.ts +36 -0
  155. package/dist-library/types/local/rendering/render-types.d.ts +57 -0
  156. package/dist-library/types/local/rendering/view-revision.d.ts +75 -0
  157. package/dist-library/types/local/{retention.d.ts → runtime/retention.d.ts} +1 -1
  158. package/dist-library/types/local/runtime/runtime.d.ts +34 -0
  159. package/dist-library/types/local/{state.d.ts → runtime/state.d.ts} +4 -4
  160. package/dist-library/types/local/session/compiler-cache.d.ts +44 -0
  161. package/dist-library/types/local/session/incremental.d.ts +48 -0
  162. package/dist-library/types/local/session/parse-session.d.ts +62 -0
  163. package/dist-library/types/local/session/row-reuse.d.ts +46 -0
  164. package/dist-library/types/local/{authoring.d.ts → source/authoring.d.ts} +11 -3
  165. package/dist-library/types/local/source/node-walk.d.ts +3 -0
  166. package/dist-library/types/local/source/source-context.d.ts +63 -0
  167. package/dist-library/types/local/{source-migration.d.ts → source/source-migration.d.ts} +2 -2
  168. package/dist-library/types/local/{i18n.d.ts → theme/i18n.d.ts} +2 -2
  169. package/dist-library/types/local/theme/theme-name.d.ts +3 -0
  170. package/dist-library/types/local/{theme.d.ts → theme/theme.d.ts} +3 -3
  171. package/dist-library/types/local/transport/compile-patch.d.ts +127 -0
  172. package/dist-library/types/local/{compiled-data.d.ts → transport/compiled-data.d.ts} +1 -1
  173. package/dist-library/types/local/transport/flat-compiled-data.d.ts +17 -0
  174. package/dist-library/types/local/transport/shared-data.d.ts +10 -0
  175. package/dist-library/types/local/transport/worker.d.ts +265 -0
  176. package/dist-library/types/local/widgets/visuals.d.ts +25 -0
  177. package/dist-library/types/presets/default-authoring.d.ts +50 -0
  178. package/dist-library/types/presets/default-components.d.ts +4 -0
  179. package/dist-library/types/presets/default-semantics.d.ts +8 -0
  180. package/dist-library/types/presets/default.d.ts +11 -0
  181. package/dist-library/types/presets/identity.d.ts +7 -0
  182. package/dist-library/types/presets/packs.d.ts +4 -0
  183. package/dist-library/types/react/component-api.d.ts +260 -0
  184. package/dist-library/types/react/component-primitives.d.ts +21 -0
  185. package/dist-library/types/react/component-utils.d.ts +125 -0
  186. package/dist-library/types/react/default-theme.d.ts +6 -0
  187. package/dist-library/types/react/field-validation.d.ts +11 -0
  188. package/dist-library/types/react/index.d.ts +17 -5
  189. package/dist-library/types/react/overflow-text-tooltip.d.ts +6 -0
  190. package/dist-library/types/react/package.d.ts +69 -0
  191. package/dist-library/types/react/runtime/common.d.ts +4 -0
  192. package/dist-library/types/react/runtime/index.d.ts +8 -0
  193. package/dist-library/types/react/runtime/useComponentState.d.ts +30 -0
  194. package/dist-library/types/react/runtime/useKeys.d.ts +16 -0
  195. package/dist-library/types/react/runtime/useSwipe.d.ts +27 -0
  196. package/dist-library/types/react/runtime/useTicker.d.ts +17 -0
  197. package/dist-library/types/react/sdk.d.ts +110 -0
  198. package/dist-library/types/react/server.d.ts +15 -0
  199. package/dist-library/types/react/tooltip-layer.d.ts +10 -0
  200. package/dist-library/types/react/use-draft-field.d.ts +17 -0
  201. package/dist-library/types/runtime-services/browser/index.d.ts +63 -0
  202. package/dist-library/types/runtime-services/component-state.d.ts +152 -0
  203. package/dist-library/types/runtime-services/identity.d.ts +41 -0
  204. package/dist-library/types/runtime-services/index.d.ts +10 -0
  205. package/dist-library/types/runtime-services/random.d.ts +42 -0
  206. package/dist-library/types/runtime-services/runtime.d.ts +51 -0
  207. package/dist-library/types/runtime-services/scheduler.d.ts +44 -0
  208. package/dist-library/types/sdk/assembly.d.ts +73 -0
  209. package/dist-library/types/sdk/compat-profile.d.ts +57 -0
  210. package/dist-library/types/sdk/compiler-config.d.ts +33 -0
  211. package/dist-library/types/sdk/config-validation.d.ts +33 -0
  212. package/dist-library/types/sdk/config.d.ts +35 -0
  213. package/dist-library/types/sdk/hash.d.ts +9 -0
  214. package/dist-library/types/sdk/index.d.ts +10 -0
  215. package/dist-library/types/sdk/manifest.d.ts +49 -0
  216. package/dist-library/types/sdk/pattern.d.ts +11 -0
  217. package/dist-library/types/sdk/preset-core.d.ts +11 -0
  218. package/dist-library/types/sdk/preset.d.ts +9 -0
  219. package/dist-library/types/sdk/props.d.ts +33 -0
  220. package/dist-library/types/sdk/registry-core.d.ts +16 -0
  221. package/dist-library/types/sdk/registry.d.ts +18 -0
  222. package/dist-library/types/sdk/theme.d.ts +73 -0
  223. package/dist-library/types/sdk/types.d.ts +221 -0
  224. package/dist-library/types/sdk/version.d.ts +49 -0
  225. package/dist-library/types/shareable.d.ts +29 -3
  226. package/dist-library/types/standalone/diagnostics.d.ts +16 -0
  227. package/dist-library/types/standalone/events.d.ts +4 -0
  228. package/dist-library/types/standalone/library.d.ts +6 -0
  229. package/dist-library/types/standalone/payload.d.ts +15 -0
  230. package/dist-library/types/standalone/prepare.d.ts +21 -0
  231. package/dist-library/types/standalone/session.d.ts +68 -0
  232. package/dist-library/types/standalone/version.d.ts +7 -0
  233. package/dist-library/types/testing/behavior.d.ts +19 -0
  234. package/dist-library/types/testing/browser.d.ts +126 -0
  235. package/dist-library/types/testing/cases.d.ts +16 -0
  236. package/dist-library/types/testing/index.d.ts +13 -0
  237. package/dist-library/types/testing/manifest.d.ts +10 -0
  238. package/dist-library/types/testing/react.d.ts +45 -0
  239. package/dist-library/types/testing/report.d.ts +20 -0
  240. package/dist-library/types/testing/types.d.ts +125 -0
  241. package/dist-library/types/testing/values.d.ts +22 -0
  242. package/dist-library/types/vite/client.d.ts +36 -0
  243. package/dist-library/types/vite/discovery.d.ts +51 -0
  244. package/dist-library/types/vite/index.d.ts +31 -0
  245. package/dist-library/types/vite/registration.d.ts +109 -0
  246. package/dist-library/types-BFCrMrg0.js +52 -0
  247. package/dist-library/validation-W-bmny-x.js +2253 -0
  248. package/dist-library/values-CIt8AjiU.js +134 -0
  249. package/dist-standalone/reactive-md-standalone.css +1 -1
  250. package/dist-standalone/reactive-md-standalone.js +591 -95
  251. package/docs/README-ch.md +90 -0
  252. package/docs/README.md +87 -81
  253. package/docs/compatibility/compatibility-ch.md +22 -14
  254. package/docs/compatibility/compatibility-en.md +22 -14
  255. package/docs/compatibility/source-versioning-ch.md +15 -12
  256. package/docs/compatibility/source-versioning-en.md +16 -13
  257. package/docs/development/component-development-ch.md +51 -195
  258. package/docs/development/component-development-en.md +51 -195
  259. package/docs/development/component-development-reference-ch.md +253 -0
  260. package/docs/development/component-development-reference-en.md +238 -0
  261. package/docs/development/component-protocol-ch.md +51 -50
  262. package/docs/development/component-protocol-en.md +52 -49
  263. package/docs/development/local-module-layout-ch.md +59 -0
  264. package/docs/development/local-module-layout-en.md +59 -0
  265. package/docs/development/performance-overview-ch.md +402 -0
  266. package/docs/development/performance-overview-en.md +402 -0
  267. package/docs/development/releasing-ch.md +8 -104
  268. package/docs/development/releasing-en.md +8 -104
  269. package/docs/guides/local-guide-ch.md +28 -9
  270. package/docs/guides/local-guide-en.md +31 -12
  271. package/docs/integration/author-tools-ch.md +4 -2
  272. package/docs/integration/author-tools-en.md +4 -2
  273. package/docs/integration/codemirror-ch.md +52 -0
  274. package/docs/integration/codemirror-en.md +29 -0
  275. package/docs/integration/compiler-ch.md +47 -0
  276. package/docs/integration/compiler-en.md +34 -0
  277. package/docs/integration/directory-discovery-ch.md +53 -0
  278. package/docs/integration/directory-discovery-en.md +31 -0
  279. package/docs/integration/editor-ch.md +48 -21
  280. package/docs/integration/editor-en.md +48 -21
  281. package/docs/integration/extension-sdk-ch.md +392 -0
  282. package/docs/integration/extension-sdk-en.md +377 -0
  283. package/docs/integration/local-integration-ch.md +63 -9
  284. package/docs/integration/local-integration-en.md +89 -13
  285. package/docs/integration/repository-split-ch.md +40 -0
  286. package/docs/integration/repository-split-en.md +23 -0
  287. package/docs/integration/shareable-export-ch.md +46 -2
  288. package/docs/integration/shareable-export-en.md +46 -2
  289. package/docs/reference/computations-formatting-ch.md +4 -2
  290. package/docs/reference/computations-formatting-en.md +4 -2
  291. package/docs/reference/constraints-collections-ch.md +21 -1
  292. package/docs/reference/constraints-collections-en.md +21 -1
  293. package/docs/reference/diagnostics-counting-ch.md +1 -1
  294. package/docs/reference/diagnostics-counting-en.md +1 -1
  295. package/docs/reference/html-compatibility-ch.md +4 -0
  296. package/docs/reference/html-compatibility-en.md +4 -0
  297. package/docs/reference/local-components-v2-ch.md +2 -0
  298. package/docs/reference/local-components-v2-en.md +2 -0
  299. package/docs/reference/local-interaction-syntax-ch.md +51 -15
  300. package/docs/reference/local-interaction-syntax-en.md +58 -14
  301. package/docs/reference/theme-protocol-ch.md +79 -7
  302. package/docs/reference/theme-protocol-en.md +79 -7
  303. package/docs/reference/tolerance-ch.md +64 -0
  304. package/docs/reference/tolerance-en.md +57 -0
  305. package/docs/releases/release-0.4.0-ch.md +2 -0
  306. package/docs/releases/release-0.4.0-en.md +2 -0
  307. package/docs/releases/release-0.4.1-ch.md +2 -0
  308. package/docs/releases/release-0.4.1-en.md +2 -0
  309. package/docs/releases/release-0.5.0-ch.md +2 -0
  310. package/docs/releases/release-0.5.0-en.md +2 -0
  311. package/docs/releases/release-0.5.1-ch.md +2 -0
  312. package/docs/releases/release-0.5.1-en.md +2 -0
  313. package/docs/releases/release-0.5.2-ch.md +2 -0
  314. package/docs/releases/release-0.5.2-en.md +2 -0
  315. package/docs/releases/release-0.5.3-ch.md +2 -0
  316. package/docs/releases/release-0.5.3-en.md +2 -0
  317. package/docs/releases/release-0.6.0-ch.md +2 -0
  318. package/docs/releases/release-0.6.0-en.md +2 -0
  319. package/docs/releases/release-0.6.1-ch.md +2 -0
  320. package/docs/releases/release-0.6.1-en.md +2 -0
  321. package/docs/releases/release-0.7.0-ch.md +86 -0
  322. package/docs/releases/release-0.7.0-en.md +86 -0
  323. package/docs/releases/release-0.8.0-ch.md +126 -0
  324. package/docs/releases/release-0.8.0-en.md +126 -0
  325. package/examples/component-package/LICENSE +21 -0
  326. package/examples/component-package/NOTICES.md +12 -0
  327. package/examples/component-package/README-ch.md +101 -0
  328. package/examples/component-package/README.md +133 -0
  329. package/examples/component-package/package.json +35 -0
  330. package/examples/component-package/sample/document.reactive.md +14 -0
  331. package/examples/component-package/scripts/build-export.mjs +44 -0
  332. package/examples/component-package/scripts/build.mjs +130 -0
  333. package/examples/component-package/scripts/verify.mjs +257 -0
  334. package/examples/component-package/src/assets/notice.svg +4 -0
  335. package/examples/component-package/src/component.css +40 -0
  336. package/examples/component-package/src/components.tsx +105 -0
  337. package/examples/component-package/src/harness.tsx +34 -0
  338. package/examples/component-package/src/manifests.ts +71 -0
  339. package/examples/component-package/src/node-entry.ts +18 -0
  340. package/examples/component-package/src/sample.ts +4 -0
  341. package/examples/component-package/src/theme.css +44 -0
  342. package/examples/component-package/src/theme.ts +22 -0
  343. package/examples/component-package/tsconfig.json +15 -0
  344. package/examples/conformance/README-ch.md +55 -0
  345. package/examples/conformance/README.md +2 -0
  346. package/examples/conformance/local-draft-3.json +296 -0
  347. package/examples/game-2048-package/LICENSE +21 -0
  348. package/examples/game-2048-package/NOTICES.md +11 -0
  349. package/examples/game-2048-package/README-ch.md +97 -0
  350. package/examples/game-2048-package/README.md +102 -0
  351. package/examples/game-2048-package/package.json +35 -0
  352. package/examples/game-2048-package/sample/document.reactive.md +17 -0
  353. package/examples/game-2048-package/scripts/build-export.mjs +44 -0
  354. package/examples/game-2048-package/scripts/build.mjs +130 -0
  355. package/examples/game-2048-package/scripts/verify.mjs +180 -0
  356. package/examples/game-2048-package/src/component.css +161 -0
  357. package/examples/game-2048-package/src/components.tsx +326 -0
  358. package/examples/game-2048-package/src/game-engine.ts +228 -0
  359. package/examples/game-2048-package/src/harness.tsx +34 -0
  360. package/examples/game-2048-package/src/manifest.ts +85 -0
  361. package/examples/game-2048-package/src/node-entry.ts +30 -0
  362. package/examples/game-2048-package/src/sample.ts +4 -0
  363. package/examples/game-2048-package/tsconfig.json +15 -0
  364. package/examples/integration/README-ch.md +63 -0
  365. package/examples/integration/README.md +17 -1
  366. package/examples/integration/extension-sdk/README-ch.md +24 -0
  367. package/examples/integration/extension-sdk/README.md +24 -0
  368. package/examples/integration/extension-sdk/advanced-standalone.ts +6 -0
  369. package/examples/integration/extension-sdk/advanced.tsx +101 -0
  370. package/examples/integration/extension-sdk/env.d.ts +2 -0
  371. package/examples/integration/extension-sdk/extensions.tsx +97 -0
  372. package/examples/integration/extension-sdk/index.html +3 -0
  373. package/examples/integration/extension-sdk/main.tsx +10 -0
  374. package/examples/integration/extension-sdk/package.json +6 -0
  375. package/examples/integration/extension-sdk/standalone.ts +7 -0
  376. package/examples/integration/extension-sdk/tsconfig.json +8 -0
  377. package/examples/integration/react-comprehensive/index.html +12 -0
  378. package/examples/integration/react-comprehensive/main.jsx +123 -0
  379. package/examples/integration/react-comprehensive/package.json +18 -0
  380. package/examples/local/README-ch.md +76 -0
  381. package/examples/local/README.md +4 -2
  382. package/examples/local/scenarios/blog-zh.reactive.md +71 -0
  383. package/examples/local/scenarios/blog.reactive.md +71 -0
  384. package/examples/local/scenarios/classroom-zh.reactive.md +97 -0
  385. package/examples/local/scenarios/classroom.reactive.md +97 -0
  386. package/examples/local/scenarios/proposal-zh.reactive.md +79 -0
  387. package/examples/local/scenarios/proposal.reactive.md +79 -0
  388. package/examples/local/scenarios/survey-zh.reactive.md +74 -0
  389. package/examples/local/scenarios/survey.reactive.md +74 -0
  390. package/examples/local/showcase/README-ch.md +22 -0
  391. package/examples/local/showcase/README.md +9 -3
  392. package/examples/local/showcase/features.reactive.md +637 -0
  393. package/examples/local/showcase/zh/features.reactive.md +637 -0
  394. package/examples/sci-fi-theme/README-ch.md +131 -0
  395. package/examples/sci-fi-theme/README.md +146 -0
  396. package/examples/sci-fi-theme/demo/demo.css +532 -0
  397. package/examples/sci-fi-theme/demo/document.reactive.md +185 -0
  398. package/examples/sci-fi-theme/demo/index.html +13 -0
  399. package/examples/sci-fi-theme/demo/main.tsx +180 -0
  400. package/examples/sci-fi-theme/docs/design-system-ch.md +245 -0
  401. package/examples/sci-fi-theme/docs/design-system.md +474 -0
  402. package/examples/sci-fi-theme/package.json +27 -0
  403. package/examples/sci-fi-theme/scripts/screenshot.mjs +98 -0
  404. package/examples/sci-fi-theme/src/components.css +1460 -0
  405. package/examples/sci-fi-theme/src/index.ts +6 -0
  406. package/examples/sci-fi-theme/src/sci-fi.css +5 -0
  407. package/examples/sci-fi-theme/src/theme.ts +37 -0
  408. package/examples/sci-fi-theme/src/tokens.css +408 -0
  409. package/examples/sci-fi-theme/tsconfig.json +20 -0
  410. package/examples/sci-fi-theme/vite.config.ts +24 -0
  411. package/examples/tetris-package/LICENSE +21 -0
  412. package/examples/tetris-package/NOTICES.md +11 -0
  413. package/examples/tetris-package/README-ch.md +91 -0
  414. package/examples/tetris-package/README.md +95 -0
  415. package/examples/tetris-package/package.json +35 -0
  416. package/examples/tetris-package/sample/document.reactive.md +16 -0
  417. package/examples/tetris-package/scripts/build-export.mjs +44 -0
  418. package/examples/tetris-package/scripts/build.mjs +130 -0
  419. package/examples/tetris-package/scripts/verify.mjs +173 -0
  420. package/examples/tetris-package/src/component.css +145 -0
  421. package/examples/tetris-package/src/components.tsx +334 -0
  422. package/examples/tetris-package/src/harness.tsx +34 -0
  423. package/examples/tetris-package/src/manifests.ts +93 -0
  424. package/examples/tetris-package/src/node-entry.ts +16 -0
  425. package/examples/tetris-package/src/sample.ts +4 -0
  426. package/examples/tetris-package/src/tetris-engine.ts +325 -0
  427. package/examples/tetris-package/tsconfig.json +15 -0
  428. package/package.json +98 -44
  429. package/dist-library/compiler-Cm3ppMxG.js +0 -46044
  430. package/dist-library/react-Bh7_oxZp.js +0 -59655
  431. package/dist-library/reactive-md-editor.css +0 -2
  432. package/dist-library/reactive-md-editor.js +0 -3853
  433. package/dist-library/runtime-DlFYQ4s_.js +0 -498
  434. package/dist-library/types/editor/ReactiveMarkdownEditor.d.ts +0 -7
  435. package/dist-library/types/editor/editor-toolbar.d.ts +0 -24
  436. package/dist-library/types/editor/editor-view-bar.d.ts +0 -11
  437. package/dist-library/types/editor/extended-native-components.d.ts +0 -58
  438. package/dist-library/types/editor/index.d.ts +0 -9
  439. package/dist-library/types/editor/locale.d.ts +0 -13
  440. package/dist-library/types/editor/source-authoring.d.ts +0 -59
  441. package/dist-library/types/editor/types.d.ts +0 -48
  442. package/dist-library/types/editor/use-gutter-metrics.d.ts +0 -5
  443. package/dist-library/types/editor/use-source-history.d.ts +0 -16
  444. package/dist-library/types/local/compiler.d.ts +0 -4
  445. package/dist-library/types/local/math.d.ts +0 -48
  446. package/dist-library/types/local/options.d.ts +0 -36
  447. package/dist-library/types/local/parser.d.ts +0 -13
  448. package/dist-library/types/local/render-types.d.ts +0 -27
  449. package/dist-library/types/local/runtime.d.ts +0 -2
  450. package/dist-library/types/local/schema.d.ts +0 -77
  451. package/dist-library/types/local/types.d.ts +0 -263
  452. package/dist-library/types/local/visuals.d.ts +0 -12
  453. package/dist-library/types/local/worker.d.ts +0 -98
  454. package/docs/development/performance-ch.md +0 -76
  455. package/docs/development/performance-en.md +0 -76
  456. /package/dist-library/types/{editor → authoring}/command-types.d.ts +0 -0
  457. /package/dist-library/types/{editor → authoring}/editor-commands.d.ts +0 -0
  458. /package/dist-library/types/local/{locale.d.ts → contracts/locale.d.ts} +0 -0
  459. /package/dist-library/types/local/{collection-functions.d.ts → evaluation/collection-functions.d.ts} +0 -0
  460. /package/dist-library/types/local/{data-functions.d.ts → evaluation/data-functions.d.ts} +0 -0
  461. /package/dist-library/types/local/{dates.d.ts → evaluation/dates.d.ts} +0 -0
  462. /package/dist-library/types/local/{formatting.d.ts → evaluation/formatting.d.ts} +0 -0
  463. /package/dist-library/types/local/{html-names.d.ts → html/html-names.d.ts} +0 -0
  464. /package/dist-library/types/local/{text-length.d.ts → source/text-length.d.ts} +0 -0
  465. /package/dist-library/types/local/{colors.d.ts → theme/colors.d.ts} +0 -0
  466. /package/dist-library/types/local/{code-block.d.ts → widgets/code-block.d.ts} +0 -0
  467. /package/dist-library/types/local/{code-languages.d.ts → widgets/code-languages.d.ts} +0 -0
  468. /package/dist-library/types/local/{diagram-layout.d.ts → widgets/diagram-layout.d.ts} +0 -0
  469. /package/dist-library/types/local/{image-view.d.ts → widgets/image-view.d.ts} +0 -0
  470. /package/dist-library/types/local/{math-view.d.ts → widgets/math-view.d.ts} +0 -0
  471. /package/dist-library/types/local/{table-surface.d.ts → widgets/table-surface.d.ts} +0 -0
@@ -0,0 +1,1124 @@
1
+ import { f as e, h as t, n } from "./compiler-core-kPiH-gOV.js";
2
+ import "./identity-MYJXKSkB.js";
3
+ import { et as r } from "./validation-W-bmny-x.js";
4
+ import { n as i } from "./math-display-BJz4gbFc.js";
5
+ import { i as a, n as o, r as s } from "./parser-standard-DlCk7sLo.js";
6
+ import { u as c } from "./registry-B9Jc3FVe.js";
7
+ import { n as l, t as u } from "./options-CX5m5n-J.js";
8
+ import { n as d } from "./compiler--ea2CKQF.js";
9
+ import { c as f, r as p } from "./schema-ZFufO8V0.js";
10
+ // src/local/session/compiler-cache.ts
11
+ var m = () => ({
12
+ expressionsCompiled: 0,
13
+ expressionsReused: 0,
14
+ typesInferred: 0,
15
+ typesReused: 0,
16
+ attributesValidated: 0,
17
+ attributesReused: 0,
18
+ bindingsResolved: 0,
19
+ bindingsReused: 0,
20
+ formulasCompiled: 0,
21
+ formulasReused: 0,
22
+ displaysInspected: 0,
23
+ displaysReused: 0
24
+ }), h = class {
25
+ capacity;
26
+ maxWeight;
27
+ key;
28
+ values = /* @__PURE__ */ new Map();
29
+ weight = 0;
30
+ counts = m();
31
+ constructor(e = 16384, t = 8e6) {
32
+ this.capacity = e, this.maxWeight = t;
33
+ }
34
+ begin(e) {
35
+ this.key !== e && (this.clear(), this.key = e), this.counts = m();
36
+ }
37
+ get stats() {
38
+ return {
39
+ ...this.counts,
40
+ entries: this.values.size
41
+ };
42
+ }
43
+ clear() {
44
+ this.values.clear(), this.weight = 0, this.key = void 0, this.counts = m();
45
+ }
46
+ get(e) {
47
+ let t = this.values.get(e);
48
+ return t !== void 0 && (this.values.delete(e), this.values.set(e, t)), t;
49
+ }
50
+ put(e, t) {
51
+ let n = e.length + 128;
52
+ if (!(n > this.maxWeight)) for (this.values.has(e) && (this.values.delete(e), this.weight -= n), this.values.set(e, t), this.weight += n; this.values.size > this.capacity || this.weight > this.maxWeight;) {
53
+ let e = this.values.keys().next().value;
54
+ this.values.delete(e), this.weight -= e.length + 128;
55
+ }
56
+ }
57
+ expression(e) {
58
+ let t = "expression:" + e, n = this.get(t);
59
+ if (n) return this.counts.expressionsReused++, n;
60
+ let i = r(e);
61
+ return this.counts.expressionsCompiled++, this.put(t, i), i;
62
+ }
63
+ infer(e, t) {
64
+ let n = e.dependencies.map((e) => [e, Object.hasOwn(t, e) ? t[e] : null]), r = "type:" + JSON.stringify([e.source, n]), i = this.get(r);
65
+ if (i !== void 0) return this.counts.typesReused++, i;
66
+ let a = e.inferType(t);
67
+ return this.counts.typesInferred++, this.put(r, a), a;
68
+ }
69
+ attributes(e) {
70
+ let t = this.get("attributes:" + e);
71
+ return t ? this.counts.attributesReused++ : this.counts.attributesValidated++, t;
72
+ }
73
+ rememberAttributes(e, t, n) {
74
+ this.put("attributes:" + e, {
75
+ origin: t,
76
+ value: n
77
+ });
78
+ }
79
+ binding(e) {
80
+ let t = this.get("binding:" + e);
81
+ return t === void 0 ? this.counts.bindingsResolved++ : this.counts.bindingsReused++, t;
82
+ }
83
+ rememberBinding(e, t) {
84
+ this.put("binding:" + e, t);
85
+ }
86
+ latex(e) {
87
+ let n = "latex:" + e, r = this.get(n);
88
+ if (r) return this.counts.formulasReused++, r;
89
+ let i = t(e);
90
+ return this.counts.formulasCompiled++, this.put(n, i), i;
91
+ }
92
+ display(e, t) {
93
+ let n = "display:" + JSON.stringify([e, t]), r = this.get(n);
94
+ if (r) return this.counts.displaysReused++, r;
95
+ let a = i(e, t);
96
+ return this.counts.displaysInspected++, this.put(n, a), a;
97
+ }
98
+ }, g = 128, _ = 512, v = 32, y = 131072, b = (e) => JSON.parse(JSON.stringify(e));
99
+ function x(e) {
100
+ return typeof e == "object" && !!e && e.strict === !1;
101
+ }
102
+ var S = class {
103
+ limit;
104
+ byteLimit;
105
+ entries = /* @__PURE__ */ new Map();
106
+ bytes = 0;
107
+ constructor(e, t) {
108
+ this.limit = e, this.byteLimit = t;
109
+ }
110
+ get size() {
111
+ return this.entries.size;
112
+ }
113
+ read(e) {
114
+ let t = this.entries.get(e);
115
+ return t === void 0 ? { hit: !1 } : (this.entries.delete(e), this.entries.set(e, t), {
116
+ hit: !0,
117
+ value: t.value
118
+ });
119
+ }
120
+ write(e, t) {
121
+ if (!(e.length > this.byteLimit / 2)) for (this.entries.get(e) !== void 0 && (this.entries.delete(e), this.bytes -= e.length), this.entries.set(e, { value: t }), this.bytes += e.length; this.entries.size > this.limit || this.bytes > this.byteLimit;) {
122
+ let e = this.entries.keys().next();
123
+ if (e.done) break;
124
+ this.entries.delete(e.value), this.bytes -= e.value.length;
125
+ }
126
+ }
127
+ clear() {
128
+ this.entries.clear(), this.bytes = 0;
129
+ }
130
+ }, C = class {
131
+ disposed = !1;
132
+ optionKey;
133
+ recoveryMode;
134
+ plans = new S(g, 524288);
135
+ inline = new S(_, 262144);
136
+ trees = new S(v, 524288);
137
+ counts = {
138
+ hits: 0,
139
+ misses: 0,
140
+ reusedBlocks: 0,
141
+ reusedRows: 0,
142
+ reusedItems: 0,
143
+ reusedRowNodes: 0,
144
+ reusedItemNodes: 0,
145
+ reusedAst: 0
146
+ };
147
+ parse(e, t, n, r) {
148
+ if (this.disposed) throw Error("Local parse session is disposed");
149
+ let i = u(t), a = x(t);
150
+ return (i !== this.optionKey || a !== this.recoveryMode) && (this.optionKey = i, this.recoveryMode = a, this.reset()), f(e, t, n, this, r);
151
+ }
152
+ clear() {
153
+ this.optionKey = void 0, this.recoveryMode = void 0, this.reset();
154
+ }
155
+ dispose() {
156
+ this.clear(), this.disposed = !0;
157
+ }
158
+ get stats() {
159
+ return {
160
+ hits: this.counts.hits,
161
+ misses: this.counts.misses,
162
+ reusedBlocks: this.counts.reusedBlocks,
163
+ reusedRows: this.counts.reusedRows,
164
+ reusedItems: this.counts.reusedItems,
165
+ reusedRowNodes: this.counts.reusedRowNodes,
166
+ reusedItemNodes: this.counts.reusedItemNodes,
167
+ entries: this.plans.size + this.inline.size + this.trees.size
168
+ };
169
+ }
170
+ reset() {
171
+ this.plans.clear(), this.inline.clear(), this.trees.clear(), this.counts = {
172
+ hits: 0,
173
+ misses: 0,
174
+ reusedBlocks: 0,
175
+ reusedRows: 0,
176
+ reusedItems: 0,
177
+ reusedRowNodes: 0,
178
+ reusedItemNodes: 0,
179
+ reusedAst: 0
180
+ };
181
+ }
182
+ counters() {
183
+ return { ...this.counts };
184
+ }
185
+ readPlan(e) {
186
+ return this.lookup(this.plans, e);
187
+ }
188
+ writePlan(e, t) {
189
+ this.plans.write(e, t);
190
+ }
191
+ readInline(e) {
192
+ return this.lookup(this.inline, e);
193
+ }
194
+ writeInline(e, t) {
195
+ e.length > y || this.inline.write(b(e), t?.map((e) => ({
196
+ ...e,
197
+ value: b(e.value)
198
+ })));
199
+ }
200
+ notePlanReuse() {
201
+ this.counts.reusedBlocks += 1;
202
+ }
203
+ noteInlineReuse(e) {
204
+ e === "row" ? this.counts.reusedRows += 1 : this.counts.reusedItems += 1;
205
+ }
206
+ noteRowReuse(e) {
207
+ e === "row" ? this.counts.reusedRowNodes += 1 : this.counts.reusedItemNodes += 1;
208
+ }
209
+ readTree(e) {
210
+ return this.lookup(this.trees, e, !0);
211
+ }
212
+ writeTree(e, t) {
213
+ this.trees.write(e, t);
214
+ }
215
+ lookup(e, t, n = !1) {
216
+ let r = e.read(t);
217
+ return r.hit ? (this.counts.hits += 1, n && (this.counts.reusedAst += 1)) : this.counts.misses += 1, r;
218
+ }
219
+ }, w = /* @__PURE__ */ new WeakSet();
220
+ function T(e, t) {
221
+ let n = 0, r = 0, i = /* @__PURE__ */ new WeakMap(), a = [], o = (e, t, n) => {
222
+ e && (Object.defineProperty(e.output, t, {
223
+ value: n,
224
+ enumerable: !0,
225
+ writable: !0,
226
+ configurable: !0
227
+ }), e.old && Object.hasOwn(e.old, t) && e.old[t] === n || (e.equal = !1));
228
+ }, s = (e, t, r, o) => {
229
+ if (typeof t != "object" || !t) return t;
230
+ if (e === t) return n++, e;
231
+ if (e === void 0 && w.has(t)) return n++, t;
232
+ if (i.has(t)) return i.get(t);
233
+ let s = Array.isArray(t), c = typeof e == "object" && e && Array.isArray(e) === s ? e : void 0, l = Object.keys(t), u = c ? Object.keys(c) : [], d = s ? Array(t.length) : {};
234
+ i.set(t, d);
235
+ let f = s && Array.isArray(e) ? new Map(e.filter((e) => e && typeof e == "object" && typeof e.id == "string").map((e) => [e.id, e])) : void 0, p = !!c && l.length === u.length && (!s || e.length === t.length);
236
+ return a.push({
237
+ before: e,
238
+ after: t,
239
+ old: c,
240
+ keys: l,
241
+ index: 0,
242
+ output: d,
243
+ equal: p,
244
+ byId: f,
245
+ parent: r,
246
+ key: o
247
+ }), d;
248
+ }, c = s(e, t);
249
+ for (; a.length;) {
250
+ let e = a[a.length - 1];
251
+ if (e.index < e.keys.length) {
252
+ let t = e.keys[e.index++], n = e.after[t], r = e.byId && n && typeof n == "object" && typeof n.id == "string" ? e.byId.get(n.id) : e.old?.[t], i = a.length, c = s(r, n, e, t);
253
+ a.length === i && o(e, t, c);
254
+ continue;
255
+ }
256
+ a.pop();
257
+ let t;
258
+ e.equal ? (t = e.before, n++) : (r++, t = Object.isFrozen(e.after) ? Object.freeze(e.output) : e.output, w.add(t)), i.set(e.after, t), e.parent ? o(e.parent, e.key, t) : c = t;
259
+ }
260
+ return {
261
+ value: c,
262
+ reused: n,
263
+ created: r
264
+ };
265
+ }
266
+ function ee(e, t) {
267
+ if (!e?.ok || !t.ok) return 0;
268
+ let n = /* @__PURE__ */ new Set(), r = [...e.document.nodes];
269
+ for (; r.length;) {
270
+ let e = r.pop();
271
+ n.add(e), e.children && r.push(...e.children);
272
+ }
273
+ let i = 0, a = [...t.document.nodes];
274
+ for (; a.length;) {
275
+ let e = a.pop();
276
+ n.has(e) && i++, e.children && a.push(...e.children);
277
+ }
278
+ return i;
279
+ }
280
+ // src/local/session/row-reuse.ts
281
+ function E(e) {
282
+ if (e.nodes.length !== 1) return;
283
+ let t = e.nodes[0], n, r;
284
+ if (t.type === "list") n = "item", r = "listItem";
285
+ else if (t.type === "table") n = "row", r = "tableRow";
286
+ else return;
287
+ let i = t.children ?? [];
288
+ if (!i.length) return;
289
+ let a = [];
290
+ for (let t of i) {
291
+ if (t.type !== r) return;
292
+ let n = t.range.start - e.origin, i = t.range.end - e.origin;
293
+ if (!Number.isInteger(n) || !Number.isInteger(i) || n < 0 || i > e.text.length || i <= n) return;
294
+ let o = e.text.slice(n, i);
295
+ if (o.includes("\n") || o.includes("\r")) return;
296
+ a.push({
297
+ text: o,
298
+ node: t
299
+ });
300
+ }
301
+ return {
302
+ kind: n,
303
+ parent: t,
304
+ rows: a
305
+ };
306
+ }
307
+ function D(e, t) {
308
+ if (e === t) return !0;
309
+ if (typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
310
+ let n = Object.keys(e), r = Object.keys(t);
311
+ if (n.length !== r.length) return !1;
312
+ for (let r of n) if (!Object.hasOwn(t, r) || !D(e[r], t[r])) return !1;
313
+ return !0;
314
+ }
315
+ function O(e, t, n, r) {
316
+ if (e.type !== t.type || e.range.start - n !== t.range.start - r || e.range.end - n !== t.range.end - r) return !1;
317
+ let i = Object.keys(e), a = Object.keys(t);
318
+ if (i.length !== a.length) return !1;
319
+ for (let n of i) if (n !== "id" && n !== "range" && n !== "children" && (!Object.hasOwn(t, n) || !D(e[n], t[n]))) return !1;
320
+ let o = e.children ?? [], s = t.children ?? [];
321
+ if (o.length !== s.length) return !1;
322
+ for (let e = 0; e < o.length; e++) if (!O(o[e], s[e], n, r)) return !1;
323
+ return !0;
324
+ }
325
+ function k(e, t) {
326
+ let n = {
327
+ ...e,
328
+ range: {
329
+ start: e.range.start + t,
330
+ end: e.range.end + t
331
+ }
332
+ };
333
+ return e.attrs && (n.attrs = { ...e.attrs }), e.align && (n.align = [...e.align]), e.children && (n.children = e.children.map((e) => k(e, t))), n;
334
+ }
335
+ function A(e, t) {
336
+ if (t.add(e.id), e.children) for (let n of e.children) A(n, t);
337
+ }
338
+ function j(e, t) {
339
+ if (!e) return;
340
+ let n = E(e), r = E(t);
341
+ if (!n || !r || n.kind !== r.kind) return;
342
+ let i = n.rows, a = r.rows, o = Math.min(i.length, a.length), s = 0;
343
+ for (; s < o && i[s].text === a[s].text;) s += 1;
344
+ let c = 0;
345
+ for (; c < o - s && i[i.length - 1 - c].text === a[a.length - 1 - c].text;) c += 1;
346
+ if (s === 0 && c === 0) return;
347
+ let l = /* @__PURE__ */ new Set(), u = 0, d = a.map((e, t) => {
348
+ let n;
349
+ if (t < s ? n = t : t >= a.length - c && (n = i.length - (a.length - t)), n === void 0) return e.node;
350
+ let r = i[n];
351
+ if (!O(r.node, e.node, r.node.range.start, e.node.range.start)) return e.node;
352
+ let o = e.node.range.start - r.node.range.start, d = o === 0 ? r.node : k(r.node, o);
353
+ return u += 1, A(d, l), d;
354
+ });
355
+ if (!u) return;
356
+ let f = {
357
+ ...r.parent,
358
+ id: n.parent.id,
359
+ children: d
360
+ };
361
+ return l.add(n.parent.id), {
362
+ nodes: [f],
363
+ reused: u,
364
+ kind: r.kind,
365
+ reusedIds: l
366
+ };
367
+ }
368
+ // src/local/session/incremental.ts
369
+ function M(e) {
370
+ return typeof e == "object" && !!e && e.strict === !1;
371
+ }
372
+ function N(e) {
373
+ return Object.hasOwn(e, "recoveries") && e.recoveries !== void 0;
374
+ }
375
+ var P = s.configure(o), F = "\n\n<!-- incremental-boundary -->\n\n";
376
+ function I(e) {
377
+ let t = [], n = [...e].reverse();
378
+ for (; n.length;) {
379
+ let e = n.pop();
380
+ if (t.push(e), e.children) for (let t = e.children.length - 1; t >= 0; t--) n.push(e.children[t]);
381
+ }
382
+ return t;
383
+ }
384
+ function L(e, t, n) {
385
+ return t === 0 && !n ? e : e.map((e) => ({
386
+ ...e,
387
+ id: n?.get(e.id) ?? e.id,
388
+ range: {
389
+ start: e.range.start + t,
390
+ end: e.range.end + t
391
+ },
392
+ ...e.attrs ? { attrs: { ...e.attrs } } : {},
393
+ ...e.align ? { align: [...e.align] } : {},
394
+ ...e.children ? { children: L(e.children, t, n) } : {}
395
+ }));
396
+ }
397
+ function R(e, t, n) {
398
+ let r = Object.create(null);
399
+ for (let i of I(e)) r[n?.get(i.id) ?? i.id] = t.dependencies?.[i.id] ?? null;
400
+ return r;
401
+ }
402
+ function z(e) {
403
+ let t = !1;
404
+ for (let n of I([e])) {
405
+ if ([
406
+ "definition",
407
+ "footnoteDefinition",
408
+ "footnoteReference",
409
+ "linkReference",
410
+ "imageReference"
411
+ ].includes(n.type) || n.type === "hostComponent" || n.type === "htmlDocument" || n.type === "fallback") return "unsupported";
412
+ if (n.type === "component") {
413
+ if (["anchor", "jump"].includes(n.name ?? "") || !p(n.name ?? "")) return "unsupported";
414
+ t = !0;
415
+ }
416
+ n.type === "comment" && (t = !0);
417
+ }
418
+ return t ? "context" : "fragment";
419
+ }
420
+ function B(e, t) {
421
+ let n = "", r = 0;
422
+ for (let i of t) n += e.slice(r, i.from) + i.text.replace(/[^\r\n]/g, " "), r = i.to;
423
+ return n + e.slice(r);
424
+ }
425
+ function V(e, t, n) {
426
+ let r = e.cursor();
427
+ do
428
+ if (r.name === "LinkReference") return null;
429
+ while (r.next());
430
+ let i = [], a = 0;
431
+ for (let r = e.topNode.firstChild; r; r = r.nextSibling) {
432
+ let e = r.from, o = r.to;
433
+ for (; e > 0 && (n[e - 1] === " " || n[e - 1] === " ");) e--;
434
+ for (e > 0 && n[e - 1] !== "\r" && n[e - 1] !== "\n" && (e = r.from); n[o] === " " || n[o] === " ";) o++;
435
+ for (; a < t.length && t[a].to <= e;) a++;
436
+ if (a < t.length && t[a].from < o) return null;
437
+ i.push({
438
+ start: e,
439
+ end: o
440
+ });
441
+ }
442
+ return i;
443
+ }
444
+ function H(e, t) {
445
+ let n = 0, r = e.length, i = t.length;
446
+ for (; n < r && n < i && e.charCodeAt(n) === t.charCodeAt(n);) n++;
447
+ for (; r > n && i > n && e.charCodeAt(r - 1) === t.charCodeAt(i - 1);) r--, i--;
448
+ return {
449
+ from: n,
450
+ oldTo: r,
451
+ newTo: i,
452
+ delta: i - r
453
+ };
454
+ }
455
+ function U(e, t) {
456
+ let n = e.parsed?.plans;
457
+ if (n?.length) {
458
+ for (let e of n) if (e.source === t) return e.rows;
459
+ if (n.length === 1) return n[0].rows;
460
+ }
461
+ }
462
+ var W = class {
463
+ disposed = !1;
464
+ snapshot = null;
465
+ deferred = null;
466
+ parseSession = new C();
467
+ semantic = new h();
468
+ services = {
469
+ parser: this.parseSession,
470
+ semantic: this.semantic
471
+ };
472
+ shared = null;
473
+ sharedKey;
474
+ sharedMode;
475
+ epoch = 0;
476
+ cacheBuilds = 0;
477
+ serial = 0;
478
+ lastStats = {
479
+ mode: "full",
480
+ totalBlocks: 0,
481
+ compiledBlocks: 0,
482
+ reusedBlocks: 0,
483
+ compiledCharacters: 0
484
+ };
485
+ get stats() {
486
+ return {
487
+ ...this.lastStats,
488
+ cacheBuilds: this.cacheBuilds
489
+ };
490
+ }
491
+ compile(e, t) {
492
+ let r = this.compileShared(e, t), i = performance.now(), a = n(r);
493
+ return this.lastStats = {
494
+ ...this.lastStats,
495
+ stages: {
496
+ ...this.lastStats.stages,
497
+ publicSnapshotMs: performance.now() - i
498
+ }
499
+ }, a;
500
+ }
501
+ compileShared(e, t) {
502
+ if (this.disposed) throw Error("Local compile session is disposed");
503
+ this.epoch++;
504
+ let n = u(t), r = M(t);
505
+ (n !== this.sharedKey || r !== this.sharedMode) && (this.shared = null, this.sharedKey = n, this.sharedMode = r);
506
+ let i = this.compileCore(e, t), a = performance.now(), o = this.shared, s = T(o ?? void 0, i).value;
507
+ return this.shared = s, this.lastStats = {
508
+ ...this.lastStats,
509
+ sharedNodes: ee(o, s),
510
+ parse: this.parseSession.stats,
511
+ semantic: this.lastStats.semantic ?? this.semantic.stats,
512
+ stages: {
513
+ ...this.lastStats.stages,
514
+ sharedPublicationMs: performance.now() - a
515
+ }
516
+ }, s;
517
+ }
518
+ compileCore(e, t) {
519
+ if (this.disposed) throw Error("Local compile session is disposed");
520
+ this.cacheBuilds = 0;
521
+ let r = u(t), i = l(t), a = M(t), o = a ? "recovery-reference" : "initial", s = !1, f = this.deferred;
522
+ if (this.deferred = null, !a && f && f.key === r && i.ok && !i.htmlActive && typeof e == "string" && e.length <= 1e6) {
523
+ if (e === f.source) return this.deferred = f, this.lastStats = {
524
+ mode: "cached",
525
+ totalBlocks: this.lastStats.totalBlocks,
526
+ compiledBlocks: 0,
527
+ reusedBlocks: this.lastStats.totalBlocks,
528
+ compiledCharacters: 0
529
+ }, f.tracked.result;
530
+ s = !0, o = "scope-or-boundary";
531
+ let n = H(f.source, e), i = (e) => n.from <= e.end && n.oldTo >= e.start, a = f.tracked.parsed;
532
+ if (a && !/[`\\~]/.test(f.source.slice(n.from, n.oldTo) + e.slice(n.from, n.newTo)) && !a.nodes.some((e) => i(e.range) && z(e) !== "fragment") && ![a.versionDeclaration?.range, a.themeRange].some((e) => e && i(e))) try {
533
+ this.snapshot = this.seed(f.source, r, f.tracked, t);
534
+ } catch {
535
+ this.snapshot = null;
536
+ }
537
+ } else f && (o = a ? "recovery-reference" : "options-or-limits");
538
+ let p = this.snapshot;
539
+ if (!a && p && p.key === r && i.ok && !i.htmlActive && typeof e == "string" && e.length <= 1e6) {
540
+ if (e === p.source) return this.lastStats = {
541
+ mode: "cached",
542
+ totalBlocks: p.blocks.length,
543
+ compiledBlocks: 0,
544
+ reusedBlocks: p.blocks.length,
545
+ compiledCharacters: 0
546
+ }, this.publish(p);
547
+ let n = null;
548
+ try {
549
+ n = this.update(p, e, t, i.maxSyntaxNodes);
550
+ } catch {}
551
+ if (n) return this.snapshot = n, this.publish(n);
552
+ o = "scope-or-boundary", s = !0;
553
+ } else p && (o = a ? "recovery-reference" : "options-or-limits");
554
+ this.snapshot = null;
555
+ let m = d(e, t, this.services);
556
+ if (this.lastStats = {
557
+ mode: "full",
558
+ totalBlocks: m.parsed?.nodes.length ?? 0,
559
+ compiledBlocks: m.parsed?.nodes.length ?? 0,
560
+ reusedBlocks: 0,
561
+ compiledCharacters: typeof e == "string" ? e.length : 0,
562
+ fallbackReason: o,
563
+ semantic: m.semantic,
564
+ stages: m.timings
565
+ }, !a && m.result.ok && m.result.diagnostics.length === 0 && !N(m.result) && i.ok && !i.htmlActive && r !== "invalid") {
566
+ if (s) {
567
+ let i = t === void 0 ? void 0 : n(t), a = i;
568
+ if (i?.config !== void 0) try {
569
+ a = {
570
+ ...i,
571
+ config: c(i.config)
572
+ };
573
+ } catch {}
574
+ this.deferred = {
575
+ source: e,
576
+ key: r,
577
+ tracked: m,
578
+ options: a
579
+ };
580
+ } else try {
581
+ this.snapshot = this.seed(e, r, m, t);
582
+ } catch {
583
+ this.snapshot = null;
584
+ }
585
+ this.snapshot && (this.lastStats.totalBlocks = this.lastStats.compiledBlocks = this.snapshot.blocks.length);
586
+ }
587
+ return this.snapshot ? this.publish(this.snapshot) : m.result;
588
+ }
589
+ seed(e, t, n, r, i) {
590
+ if (this.cacheBuilds++, !n.result.ok || !n.parsed || N(n.result) || e.includes("[^") || e.includes("")) return null;
591
+ let a = n.parsed.nodes, o = a.map(z), s = a.length === 1 && o[0] === "fragment" && (a[0].type === "list" || a[0].type === "table");
592
+ if (o.includes("unsupported") || !s && o.filter((e) => e === "fragment").length < 2) return null;
593
+ let c = {
594
+ ...n.result.document,
595
+ nodes: [],
596
+ source: ""
597
+ }, l = new Map(n.result.document.nodes.map((e) => [e.id, e])), u = [], d = [];
598
+ for (let t = 0; t < a.length; t++) {
599
+ let n = a[t];
600
+ if (o[t] === "fragment") d.push(n);
601
+ else {
602
+ let t = l.has(n.id) ? [l.get(n.id)] : [];
603
+ u.push({
604
+ from: n.range.start,
605
+ to: n.range.end,
606
+ origin: n.range.start,
607
+ text: e.slice(n.range.start, n.range.end),
608
+ nodes: t,
609
+ dependencies: R(t, c),
610
+ cost: 0
611
+ });
612
+ }
613
+ }
614
+ for (let t of [n.parsed.versionDeclaration?.range, n.parsed.themeRange]) t && !u.some((e) => t.start >= e.from && t.end <= e.to) && u.push({
615
+ from: t.start,
616
+ to: t.end,
617
+ origin: t.start,
618
+ text: e.slice(t.start, t.end),
619
+ nodes: [],
620
+ dependencies: {},
621
+ cost: 0
622
+ });
623
+ u.sort((e, t) => e.from - t.from);
624
+ let f = B(e, u);
625
+ if (f.includes("<")) return null;
626
+ let p = i ?? P.parse(f), m = V(p, u, f);
627
+ if (!m) return null;
628
+ let h = [], g = 0;
629
+ for (let t of m) {
630
+ let r = [];
631
+ for (; g < d.length && d[g].range.start < t.end;) {
632
+ let e = d[g];
633
+ if (e.range.start < t.start || e.range.end > t.end) return null;
634
+ r.push(e), g++;
635
+ }
636
+ if (!r.length) return null;
637
+ let i = r.flatMap((e) => l.has(e.id) ? [l.get(e.id)] : []), a = I(i).length, o = e.slice(t.start, t.end);
638
+ h.push({
639
+ from: t.start,
640
+ to: t.end,
641
+ origin: t.start,
642
+ text: o,
643
+ nodes: i,
644
+ dependencies: R(i, c),
645
+ cost: a,
646
+ rowPlans: U(n, o)
647
+ });
648
+ }
649
+ if (g !== d.length) return null;
650
+ let _ = u.length ? u.map((e) => e.text).join(F) + F : "", v = _ ? this.parseSession.parse(_, r) : null;
651
+ if (v?.diagnostics.length) return null;
652
+ let y = (n.parsed.syntaxNodes ?? 0) - h.reduce((e, t) => e + t.cost, 0);
653
+ return y < 0 ? null : (c.nodes = [], c.source = "", delete c.dependencies, {
654
+ source: e,
655
+ key: t,
656
+ tree: p,
657
+ metadata: c,
658
+ blocks: h,
659
+ context: u,
660
+ contextCost: y,
661
+ prefix: _,
662
+ prefixCost: v?.syntaxNodes ?? 0
663
+ });
664
+ }
665
+ update(e, t, n, r) {
666
+ if (t.includes("[^") || t.includes("")) return null;
667
+ let i = H(e.source, t);
668
+ if (/[`\\~]/.test(e.source.slice(i.from, i.oldTo) + t.slice(i.from, i.newTo))) return null;
669
+ let o = [];
670
+ for (let n of e.context) {
671
+ if (i.from <= n.to && i.oldTo >= n.from) return null;
672
+ let e = n.from >= i.oldTo ? i.delta : 0, r = {
673
+ ...n,
674
+ from: n.from + e,
675
+ to: n.to + e
676
+ };
677
+ if (t.slice(r.from, r.to) !== n.text) return null;
678
+ o.push(r);
679
+ }
680
+ let s = a.applyChanges(a.addTree(e.tree), [{
681
+ fromA: i.from,
682
+ toA: i.oldTo,
683
+ fromB: i.from,
684
+ toB: i.newTo
685
+ }], 0), c = B(t, o);
686
+ if (c.includes("<")) return null;
687
+ let l = P.parse(c, s), u = V(l, o, c);
688
+ if (!u) return null;
689
+ let f = new Map(e.blocks.map((e) => [`${e.from}:${e.to}`, e])), p = [], m = /* @__PURE__ */ new Set(), h = 0, g = 0, _ = 0, v = e.contextCost;
690
+ for (let a of u) {
691
+ let o = a.start >= i.newTo ? i.delta : 0, s = a.end <= i.from || a.start >= i.newTo ? f.get(`${a.start - o}:${a.end - o}`) : void 0, c = t.slice(a.start, a.end);
692
+ if (s && s.text === c) {
693
+ p.push({
694
+ ...s,
695
+ from: a.start,
696
+ to: a.end
697
+ }), h++, v += s.cost;
698
+ for (let e of I(s.nodes)) m.add(e.id);
699
+ } else {
700
+ let t = e.prefix.length, r = e.blocks.find((e) => {
701
+ let t = e.from >= i.oldTo ? e.from + i.delta : e.from, n = e.to >= i.oldTo ? e.to + i.delta : e.to;
702
+ return t < a.end && n > a.start;
703
+ }), o = r?.rowPlans ? {
704
+ ...this.services,
705
+ rowPlans: r.rowPlans
706
+ } : this.services, s = d(e.prefix + c, n, o);
707
+ if (_ += t + c.length, g++, !s.result.ok || s.result.diagnostics.length || !s.parsed || N(s.result)) return null;
708
+ let l = s.parsed.nodes.filter((e) => e.range.start >= t);
709
+ if (!l.length || l.some((e) => z(e) !== "fragment")) return null;
710
+ let u = s.result.document.nodes.filter((e) => e.range.start >= t), f = new Map(I(u).map((e) => [e.id, `incremental-${++this.serial}-${e.id}`])), h = L(u, 0, f), y = r ? j({
711
+ text: r.text,
712
+ origin: r.origin,
713
+ nodes: r.nodes
714
+ }, {
715
+ text: c,
716
+ origin: t,
717
+ nodes: h
718
+ }) : void 0;
719
+ if (y) {
720
+ for (let e of y.reusedIds) if (m.has(e)) {
721
+ y = void 0;
722
+ break;
723
+ }
724
+ }
725
+ let b = y?.nodes ?? h, x = (s.parsed.syntaxNodes ?? 0) - e.prefixCost;
726
+ if (x < I(b).length) return null;
727
+ let S = R(u, s.result.document, f), C = Object.create(null);
728
+ for (let e of I(b)) C[e.id] = S[e.id] ?? null;
729
+ if (y && r) {
730
+ let e = r.nodes[0]?.id, t = h[0]?.id;
731
+ for (let n of y.reusedIds) C[n] = n === e && t !== void 0 ? S[t] ?? null : r.dependencies[n] ?? null, m.add(n);
732
+ for (let e = 0; e < y.reused; e++) this.parseSession.noteRowReuse(y.kind);
733
+ }
734
+ p.push({
735
+ from: a.start,
736
+ to: a.end,
737
+ origin: t,
738
+ text: c,
739
+ nodes: b,
740
+ dependencies: C,
741
+ cost: x,
742
+ rowPlans: U(s, c)
743
+ }), v += x;
744
+ }
745
+ if (v > r) return null;
746
+ }
747
+ return v > r ? null : (this.lastStats = {
748
+ mode: "incremental",
749
+ totalBlocks: p.length,
750
+ compiledBlocks: g,
751
+ reusedBlocks: h,
752
+ compiledCharacters: _
753
+ }, {
754
+ ...e,
755
+ source: t,
756
+ tree: l,
757
+ context: o,
758
+ blocks: p
759
+ });
760
+ }
761
+ publish(e) {
762
+ let t = n(e.metadata);
763
+ t.source = e.source;
764
+ let r = [...e.blocks, ...e.context].sort((e, t) => e.from - t.from), i = new Map(this.shared?.ok ? this.shared.document.nodes.map((e) => [e.id, e]) : []);
765
+ t.nodes = r.flatMap((e) => {
766
+ let t = e.from - e.origin;
767
+ if (e.publication?.delta === t) return e.publication.nodes;
768
+ let n = T(e.publication?.nodes ?? e.nodes.map((e) => i.get(e.id)).filter((e) => !!e), L(e.nodes, t)).value;
769
+ return e.publication = {
770
+ delta: t,
771
+ nodes: n
772
+ }, n;
773
+ });
774
+ let a = {};
775
+ for (let e of r) for (let [t, n] of Object.entries(e.dependencies)) Object.defineProperty(a, t, {
776
+ value: n === null ? null : Object.freeze([...n]),
777
+ enumerable: !0
778
+ });
779
+ t.dependencies = Object.freeze(a);
780
+ let o = (t) => {
781
+ let n = e.context.find((e) => t.start >= e.origin && t.end <= e.origin + e.text.length), r = n ? n.from - n.origin : 0;
782
+ return {
783
+ start: t.start + r,
784
+ end: t.end + r
785
+ };
786
+ };
787
+ t.versionDeclaration && (t.versionDeclaration.range = o(t.versionDeclaration.range)), t.themeRange &&= o(t.themeRange);
788
+ for (let e of Object.values(t.computations ?? {})) e.range = o(e.range);
789
+ for (let e of t.validations ?? []) e.range = o(e.range);
790
+ for (let e of Object.values(t.externals ?? {})) e.range = o(e.range);
791
+ for (let e of Object.values(t.dynamicConstraints ?? {})) for (let t of Object.values(e)) t.offset = o({
792
+ start: t.offset,
793
+ end: t.offset
794
+ }).start;
795
+ return {
796
+ ok: !0,
797
+ document: t,
798
+ diagnostics: []
799
+ };
800
+ }
801
+ get hasPendingPreparation() {
802
+ return !this.disposed && this.deferred !== null;
803
+ }
804
+ prepare() {
805
+ if (this.disposed || !this.deferred) return !1;
806
+ let e = this.deferred, t = this.epoch, n = this.cacheBuilds;
807
+ try {
808
+ let n = this.seed(e.source, e.key, e.tracked, e.options);
809
+ return this.disposed || t !== this.epoch || this.deferred !== e ? !1 : (this.snapshot = n, this.deferred = null, n !== null);
810
+ } catch {
811
+ return !1;
812
+ } finally {
813
+ this.cacheBuilds = n;
814
+ }
815
+ }
816
+ async prepareAsync(e, t = () => new Promise((e) => setTimeout(e, 0))) {
817
+ if (this.disposed || !this.deferred || e?.aborted) return !1;
818
+ let n = this.deferred, r = this.epoch, i = () => !this.disposed && !e?.aborted && this.epoch === r && this.deferred === n;
819
+ if (await t(), !i() || !n.tracked.result.ok || !n.tracked.parsed) return !1;
820
+ let a = [], o = n.tracked.parsed.nodes;
821
+ for (let e = 0; e < o.length; e++) {
822
+ let r = o[e], s = z(r);
823
+ if (s === "unsupported" || (s === "context" && a.push({
824
+ from: r.range.start,
825
+ to: r.range.end,
826
+ origin: r.range.start,
827
+ text: n.source.slice(r.range.start, r.range.end),
828
+ nodes: [],
829
+ dependencies: {},
830
+ cost: 0
831
+ }), e % 64 == 63 && (await t(), !i()))) return !1;
832
+ }
833
+ for (let e of [n.tracked.parsed.versionDeclaration?.range, n.tracked.parsed.themeRange]) e && !a.some((t) => e.start >= t.from && e.end <= t.to) && a.push({
834
+ from: e.start,
835
+ to: e.end,
836
+ origin: e.start,
837
+ text: n.source.slice(e.start, e.end),
838
+ nodes: [],
839
+ dependencies: {},
840
+ cost: 0
841
+ });
842
+ a.sort((e, t) => e.from - t.from);
843
+ let s = B(n.source, a);
844
+ if (s.includes("<")) return !1;
845
+ let c = P.startParse(s), l = null;
846
+ for (; !l;) if (l = c.advance(), !l && (await t(), !i())) return !1;
847
+ if (await t(), !i()) return !1;
848
+ let u = this.cacheBuilds;
849
+ try {
850
+ let e = this.seed(n.source, n.key, n.tracked, n.options, l);
851
+ return i() ? (this.snapshot = e, this.deferred = null, e !== null) : !1;
852
+ } catch {
853
+ return !1;
854
+ } finally {
855
+ this.cacheBuilds = u;
856
+ }
857
+ }
858
+ clear() {
859
+ this.epoch++, this.snapshot = null, this.deferred = null, this.serial = 0, this.cacheBuilds = 0, this.shared = null, this.sharedKey = void 0, this.sharedMode = void 0, this.parseSession.clear(), this.semantic.clear();
860
+ }
861
+ dispose() {
862
+ this.clear(), this.parseSession.dispose(), this.disposed = !0;
863
+ }
864
+ };
865
+ function G() {
866
+ return new W();
867
+ }
868
+ // src/local/evaluation/math-sample.ts
869
+ var K = 2e3, te = 5, q = 1e6;
870
+ function J(t, n, r, i) {
871
+ try {
872
+ return t.evaluate(n, r, i);
873
+ } catch (t) {
874
+ if (t instanceof e) {
875
+ if (t.code === "latex-budget") throw t;
876
+ return null;
877
+ }
878
+ throw t;
879
+ }
880
+ }
881
+ function Y(e) {
882
+ if (e.length === 0) return 0;
883
+ let t = [...e].sort((e, t) => e - t);
884
+ return t[Math.floor(t.length / 2)];
885
+ }
886
+ function ne(e, t, n, r, i, a) {
887
+ let o = n - e;
888
+ if (!(o > 0)) return !1;
889
+ let s = 0, c = 0;
890
+ for (let i = 1; i <= te; i += 1) {
891
+ let l = 1 << i, u = o / l, d = t, f = 0;
892
+ for (let t = 1; t <= l; t += 1) {
893
+ let i = t === l ? n : e + t * u, o = t === l ? r : a(i);
894
+ if (o === null) return !0;
895
+ let s = Math.abs(o - d) / u;
896
+ s > f && (f = s), d = o;
897
+ }
898
+ i === 2 && (s = f), c = f;
899
+ }
900
+ return c > Math.max(s * 6, i * 12, 1e-9);
901
+ }
902
+ function re(t, n, r, i, a = 200, o) {
903
+ if (!Number.isFinite(r) || !Number.isFinite(i)) throw new e("latex-plot-range", "Plot min/max must be finite numbers.", 0);
904
+ if (!(r < i)) throw new e("latex-plot-range", "Plot min must be less than max.", 0);
905
+ if (!Number.isInteger(a) || a < 2 || a > K) throw new e("latex-plot-samples", `Sample count must be an integer between 2 and ${K}.`, 0);
906
+ let s = {
907
+ steps: 0,
908
+ limit: Math.max(q, a * 1024)
909
+ }, c = (e) => {
910
+ let r = s.limit - s.steps, i = o ? Number.isFinite(o.limit) && Number.isFinite(o.steps) ? o.limit - o.steps : 0 : Infinity, a = {
911
+ steps: 0,
912
+ limit: Math.max(0, Math.min(r, i))
913
+ };
914
+ try {
915
+ return J(t, e, n, a);
916
+ } finally {
917
+ s.steps += a.steps, o && (o.steps = Number.isFinite(o.steps) ? o.steps + a.steps : a.steps);
918
+ }
919
+ }, l = (i - r) / (a - 1), u = [];
920
+ for (let e = 0; e < a; e += 1) {
921
+ let t = e === a - 1 ? i : r + e * l;
922
+ u.push({
923
+ x: t,
924
+ y: c(t)
925
+ });
926
+ }
927
+ let d = u.map((e) => e.y).filter((e) => e !== null).map((e) => Math.abs(e)), f = Math.max(1e-9, Y(d) * 8);
928
+ for (let e = 1; e < u.length - 1; e += 1) {
929
+ let t = u[e - 1].y, n = u[e].y, r = u[e + 1].y;
930
+ t !== null && n !== null && r !== null && Math.abs(n) > Math.max(1, Math.abs(t), Math.abs(r)) * 100 && Math.abs(n) > f && (u[e] = {
931
+ x: u[e].x,
932
+ y: null
933
+ });
934
+ }
935
+ let p = u.length - 1, m = u[p].y, h = p > 0 ? u[p - 1].y : null;
936
+ m !== null && h !== null && Math.abs(m) > Math.max(1, Math.abs(h)) * 100 && Math.abs(m) > f && (m = null, u[p] = {
937
+ x: u[p].x,
938
+ y: null
939
+ });
940
+ let g = [], _ = [];
941
+ for (let e = 0; e < u.length - 1; e += 1) {
942
+ let t = u[e], n = u[e + 1];
943
+ if (t.y === null || n.y === null) continue;
944
+ let r = Math.abs(n.y - t.y);
945
+ g.push(r);
946
+ let i = n.x - t.x;
947
+ i > 0 && _.push(r / i);
948
+ }
949
+ let v = Y(g), y = Y(_);
950
+ for (let e = 0; e < u.length - 1; e += 1) {
951
+ let t = u[e], n = u[e + 1], r = t.y, i = n.y;
952
+ if (r === null || i === null) continue;
953
+ let a = () => {
954
+ u[e + 1] = {
955
+ x: n.x,
956
+ y: null
957
+ };
958
+ }, o = c(t.x + (n.x - t.x) / 2);
959
+ if (o === null) {
960
+ a();
961
+ continue;
962
+ }
963
+ let s = Math.abs(i - r);
964
+ (Math.abs(o - (r + i) / 2) > Math.max(s * .25, v * .4, 1e-9) || s > Math.max(v * 16, 1e-9)) && ne(t.x, r, n.x, i, y, (e) => c(e)) && a();
965
+ }
966
+ return {
967
+ points: u,
968
+ endpoint: m
969
+ };
970
+ }
971
+ function X(t, n, r, i) {
972
+ if (!Number.isFinite(t) || !Number.isFinite(n)) throw new e("latex-plot-range", "Plot min/max must be finite numbers.", 0);
973
+ if (!(t < n)) throw new e("latex-plot-range", "Plot min must be less than max.", 0);
974
+ if (!Number.isInteger(r) || r < 2 || r > i) throw new e("latex-plot-samples", `Sample count must be an integer between 2 and ${i}.`, 0);
975
+ }
976
+ function Z(e, t) {
977
+ let n = e.limit - e.steps, r = t ? Number.isFinite(t.limit) && Number.isFinite(t.steps) ? t.limit - t.steps : 0 : Infinity;
978
+ return {
979
+ steps: 0,
980
+ limit: Math.max(0, Math.min(n, r))
981
+ };
982
+ }
983
+ function Q(e, t, n) {
984
+ e.steps += n.steps, t && (t.steps = Number.isFinite(t.steps) ? t.steps + n.steps : n.steps);
985
+ }
986
+ function ie(e, t, n, r, i, a = 200, o) {
987
+ X(r, i, a, K);
988
+ let s = {
989
+ steps: 0,
990
+ limit: Math.max(q, a * 2048)
991
+ }, c = (i - r) / (a - 1), l = [];
992
+ for (let u = 0; u < a; u += 1) {
993
+ let d = u === a - 1 ? i : r + u * c, f = {
994
+ ...n,
995
+ t: d
996
+ }, p = Z(s, o), m = null;
997
+ try {
998
+ m = J(e, d, f, p);
999
+ } finally {
1000
+ Q(s, o, p);
1001
+ }
1002
+ let h = Z(s, o), g = null;
1003
+ try {
1004
+ g = m === null ? null : J(t, d, f, h);
1005
+ } finally {
1006
+ Q(s, o, h);
1007
+ }
1008
+ l.push({
1009
+ x: m === null || !Number.isFinite(m) ? NaN : m,
1010
+ y: m === null || g === null || !Number.isFinite(g) ? null : g,
1011
+ t: d
1012
+ });
1013
+ }
1014
+ let u = l[l.length - 1];
1015
+ return {
1016
+ points: l,
1017
+ endpoint: u && u.y !== null ? u.y : null
1018
+ };
1019
+ }
1020
+ function $(e, t, n, r, i, a) {
1021
+ let o = n - a, s = o === 0 ? .5 : Math.max(0, Math.min(1, n / o));
1022
+ return {
1023
+ x: e + (r - e) * s,
1024
+ y: t + (i - t) * s
1025
+ };
1026
+ }
1027
+ function ae(e, t) {
1028
+ switch (e) {
1029
+ case 1: return [[3, 0]];
1030
+ case 2: return [[0, 1]];
1031
+ case 3: return [[3, 1]];
1032
+ case 4: return [[1, 2]];
1033
+ case 5: return t ? [[0, 1], [2, 3]] : [[3, 0], [1, 2]];
1034
+ case 6: return [[0, 2]];
1035
+ case 7: return [[3, 2]];
1036
+ case 8: return [[2, 3]];
1037
+ case 9: return [[0, 2]];
1038
+ case 10: return t ? [[3, 0], [1, 2]] : [[0, 1], [2, 3]];
1039
+ case 11: return [[1, 2]];
1040
+ case 12: return [[3, 1]];
1041
+ case 13: return [[0, 1]];
1042
+ case 14: return [[3, 0]];
1043
+ default: return [];
1044
+ }
1045
+ }
1046
+ function oe(e, t, n, r, i) {
1047
+ if (e.length === 0) return [];
1048
+ let a = n - t || 1, o = i - r || 1, s = (e) => `${Math.round((e.x - t) / a * 1e7)},${Math.round((e.y - r) / o * 1e7)}`, c = /* @__PURE__ */ new Map(), l = (e, t) => {
1049
+ let n = c.get(e);
1050
+ n ? n.push(t) : c.set(e, [t]);
1051
+ };
1052
+ e.forEach((e, t) => {
1053
+ l(s(e.a), t), l(s(e.b), t);
1054
+ });
1055
+ let u = new Uint8Array(e.length), d = [], f = (t, n) => {
1056
+ let r = c.get(s(n));
1057
+ if (!r) return !1;
1058
+ for (let i of r) {
1059
+ if (u[i]) continue;
1060
+ let r = e[i], a = s(r.a) === s(n) ? r.b : r.a;
1061
+ if (s(a) === s(n)) u[i] = 1;
1062
+ else return u[i] = 1, t.push(a), !0;
1063
+ }
1064
+ return !1;
1065
+ };
1066
+ for (let t = 0; t < e.length; t += 1) {
1067
+ if (u[t]) continue;
1068
+ let n = e[t];
1069
+ if (s(n.a) === s(n.b)) {
1070
+ u[t] = 1;
1071
+ continue;
1072
+ }
1073
+ u[t] = 1;
1074
+ let r = [n.a, n.b], i = 0;
1075
+ for (; i < e.length && f(r, r[r.length - 1]);) i += 1;
1076
+ for (r.reverse(), i = 0; i < e.length && f(r, r[r.length - 1]);) i += 1;
1077
+ r.reverse(), d.push(r);
1078
+ }
1079
+ return d;
1080
+ }
1081
+ function se(t, n, r, i, a, o, s = 100, c) {
1082
+ if (X(r, i, s, 100), !Number.isFinite(a) || !Number.isFinite(o) || !(a < o)) throw new e("latex-plot-range", "The vertical plot range must be finite and increasing.", 0);
1083
+ let l = {
1084
+ steps: 0,
1085
+ limit: Math.max(q, s * s * 2048)
1086
+ }, u = s + 1, d = Array(u * u).fill(null), f = (i - r) / s, p = (o - a) / s;
1087
+ for (let e = 0; e <= s; e += 1) {
1088
+ let m = e === s ? o : a + e * p, h = {
1089
+ ...n,
1090
+ y: m
1091
+ };
1092
+ for (let n = 0; n <= s; n += 1) {
1093
+ let a = n === s ? i : r + n * f, o = Z(l, c), p = null;
1094
+ try {
1095
+ p = J(t, a, h, o);
1096
+ } finally {
1097
+ Q(l, c, o);
1098
+ }
1099
+ d[e * u + n] = p !== null && Number.isFinite(p) ? p : null;
1100
+ }
1101
+ }
1102
+ let m = [], h = (e, t) => d[t * u + e];
1103
+ for (let e = 0; e < s; e += 1) {
1104
+ let t = e + 1 === s, n = t ? o - p : a + e * p, c = t ? o : a + (e + 1) * p;
1105
+ for (let t = 0; t < s; t += 1) {
1106
+ let a = t + 1 === s, o = a ? i - f : r + t * f, l = a ? i : r + (t + 1) * f, u = h(t, e), d = h(t + 1, e), p = h(t + 1, e + 1), g = h(t, e + 1);
1107
+ if (u === null || d === null || p === null || g === null) continue;
1108
+ let _ = u >= 0 | (d >= 0 ? 2 : 0) | (p >= 0 ? 4 : 0) | (g >= 0 ? 8 : 0);
1109
+ if (_ === 0 || _ === 15) continue;
1110
+ let v = [
1111
+ $(o, n, u, l, n, d),
1112
+ $(l, n, d, l, c, p),
1113
+ $(o, c, g, l, c, p),
1114
+ $(o, n, u, o, c, g)
1115
+ ], y = (u + d + p + g) / 4;
1116
+ for (let [e, t] of ae(_, y >= 0)) m.push({
1117
+ a: v[e],
1118
+ b: v[t]
1119
+ });
1120
+ }
1121
+ }
1122
+ return oe(m, r, i, a, o);
1123
+ }
1124
+ export { G as a, W as i, ie as n, re as r, se as t };