reactive-md 0.9.3 → 0.10.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 (299) hide show
  1. package/CHANGELOG-ch.md +34 -0
  2. package/CHANGELOG.md +34 -0
  3. package/README-ch.md +7 -7
  4. package/README-en.md +7 -7
  5. package/README.md +7 -7
  6. package/THIRD_PARTY_NOTICES.md +0 -57
  7. package/cli/help.mjs +6 -4
  8. package/cli/init.mjs +1 -1
  9. package/cli/migrate.mjs +1 -1
  10. package/dist-library/{LocalDocumentView-D6zQkTkt.js → LocalDocumentView-CP2QG86k.js} +46 -44
  11. package/dist-library/{LocalDocumentViewCore-CmJhemcA.js → LocalDocumentViewCore-Cd6yMEkg.js} +284 -265
  12. package/dist-library/{LocalReactiveDocumentCore-lAKOGAZ7.js → LocalReactiveDocumentCore-VuYpZqdn.js} +7 -7
  13. package/dist-library/LocalStaticDocumentView-DfX6bemE.js +147 -0
  14. package/dist-library/authoring-Bwu_zCWs.js +768 -0
  15. package/dist-library/choice-values-BItGjPD2.js +58 -0
  16. package/dist-library/compile-B35rfzKr.js +1742 -0
  17. package/dist-library/{compile-cache-key-6GgpETz_.js → compile-cache-key-D21X2Obx.js} +5 -5
  18. package/dist-library/{compiler-DLkKUK4t.js → compiler-DBwLawMZ.js} +4 -4
  19. package/dist-library/{compiler-core-Niqhp9wV.js → compiler-core-kkDiQ1RK.js} +3146 -2055
  20. package/dist-library/{component-kernel-IG4wOO0i.js → component-kernel-CsJSabHX.js} +42 -26
  21. package/dist-library/{component-state-Ht-hOK0W.js → component-state-Da0G8Ajc.js} +1 -1
  22. package/dist-library/{component-utils-eSj5IdG4.js → component-utils-ZM3jUJNy.js} +80 -79
  23. package/dist-library/conditional-branches-CIhJXasR.js +17 -0
  24. package/dist-library/{config-validation-Cpol91_M.js → config-validation-DbmsWAEV.js} +165 -152
  25. package/dist-library/{controls-B-CLSK8Q.js → controls-DRy5rzzN.js} +271 -228
  26. package/dist-library/{coordinate-PyLPMIQK.js → coordinate-c54pHfgf.js} +29 -29
  27. package/dist-library/data-table-CSAkm1eU.js +290 -0
  28. package/dist-library/data-table-model-DruztQFt.js +391 -0
  29. package/dist-library/{data-visuals-_Z7QqYTk.js → data-visuals-rZQUeQM0.js} +14 -14
  30. package/dist-library/{default-components-jugH7Ubr.js → default-components-B-39etG9.js} +233 -71
  31. package/dist-library/{default-config-DIrRpuQz.js → default-config-CCa8rm2k.js} +236 -216
  32. package/dist-library/default-options-By16CVw1.js +131 -0
  33. package/dist-library/{default-registry-BlloaZi7.js → default-registry-DXJy66xj.js} +3 -3
  34. package/dist-library/{default-schema-Ch-Vznpm.js → default-schema-CeYiEW1K.js} +3 -3
  35. package/dist-library/display-Bb6hAG5T.js +2065 -0
  36. package/dist-library/{document-theme-DBAfnk7y.js → document-theme-CJvN-nC1.js} +190 -3
  37. package/dist-library/{export-heVBqgxA.js → export-BSV4E0jv.js} +105 -106
  38. package/dist-library/font-aliases-CKYjwn4o.js +4 -0
  39. package/dist-library/{gallery-Q6VPS2ep.js → gallery-DM2yTVZJ.js} +1 -1
  40. package/dist-library/{html-CCnvzan1.js → html-CY9mC3Sr.js} +5 -5
  41. package/dist-library/{incremental-Bzvh8_lB.js → incremental-B-wW4H3F.js} +251 -245
  42. package/dist-library/{display-y4v9v0Qd.js → katex-4ukd4ZxT.js} +1555 -3618
  43. package/dist-library/layout-CPQggKxk.js +592 -0
  44. package/dist-library/{layout-BnfDeUNy.js → layout-CaDWsDof.js} +1 -1
  45. package/dist-library/{math-view-B0jthpRw.js → math-view-CyGTS6kv.js} +1 -1
  46. package/dist-library/{mount-preset-C_i37FvY.js → mount-preset-DtrCX4G8.js} +4 -4
  47. package/dist-library/{numeric-sliders-CkWS0-ja.js → numeric-sliders-BmJ1LCLx.js} +190 -190
  48. package/dist-library/{observability-CYLuvFfL.js → observability-BVQ16ByQ.js} +5 -4
  49. package/dist-library/{package-core-9UK5ZdqB.js → package-core-Cu_r_qs7.js} +7 -6
  50. package/dist-library/{parser-9yNJxGip.js → parser-BHl9Lxbw.js} +2 -2
  51. package/dist-library/{parser-standard-BPIy4HOu.js → parser-standard-DDAKv_DZ.js} +247 -247
  52. package/dist-library/{plugin-packs-CZb46nuv.js → plugin-packs-CkI0floL.js} +3 -3
  53. package/dist-library/{preset-core-BW3NWZJ9.js → preset-core-BKPbH_Nv.js} +377 -306
  54. package/dist-library/{props-pJRrfDc6.js → props-0iDqxlTk.js} +56 -61
  55. package/dist-library/{react-BSo0o998.js → react-74jdGBmu.js} +2 -2
  56. package/dist-library/reactive-md-authoring.js +277 -269
  57. package/dist-library/reactive-md-build.js +327 -33
  58. package/dist-library/reactive-md-compiler-session.js +3 -3
  59. package/dist-library/reactive-md-compiler-standard.js +10 -10
  60. package/dist-library/reactive-md-compiler.js +3 -3
  61. package/dist-library/reactive-md-contracts.js +4 -4
  62. package/dist-library/reactive-md-default-packs.js +4 -3
  63. package/dist-library/reactive-md-default-preset.js +3 -3
  64. package/dist-library/reactive-md-export.js +6 -6
  65. package/dist-library/reactive-md-minimal-preset.js +3 -2
  66. package/dist-library/reactive-md-minimal-react-preset.js +18 -17
  67. package/dist-library/reactive-md-minimal.css +1 -1
  68. package/dist-library/reactive-md-observability.js +2 -2
  69. package/dist-library/reactive-md-pack-style-manifest.js +8 -0
  70. package/dist-library/reactive-md-plugin-chart.js +13 -9
  71. package/dist-library/reactive-md-plugin-data.js +4 -4
  72. package/dist-library/reactive-md-plugin-diagram.js +3 -3
  73. package/dist-library/reactive-md-plugin-forms.js +5 -5
  74. package/dist-library/reactive-md-plugin-gallery.js +3 -3
  75. package/dist-library/reactive-md-plugin-navigation.js +10 -10
  76. package/dist-library/reactive-md-plugin-network.js +5 -5
  77. package/dist-library/reactive-md-plugin-plot.js +4 -4
  78. package/dist-library/reactive-md-react-component-accordion.js +3 -3
  79. package/dist-library/reactive-md-react-component-alert.js +3 -3
  80. package/dist-library/reactive-md-react-component-anchor.js +3 -3
  81. package/dist-library/reactive-md-react-component-badge.js +3 -3
  82. package/dist-library/reactive-md-react-component-card.js +3 -3
  83. package/dist-library/reactive-md-react-component-chart.js +2 -2
  84. package/dist-library/reactive-md-react-component-checkbox.js +2 -2
  85. package/dist-library/reactive-md-react-component-checklist.js +2 -2
  86. package/dist-library/reactive-md-react-component-choices.js +2 -2
  87. package/dist-library/reactive-md-react-component-column.js +1 -1
  88. package/dist-library/reactive-md-react-component-coordinate.js +2 -2
  89. package/dist-library/reactive-md-react-component-counter.js +2 -2
  90. package/dist-library/reactive-md-react-component-data-table.js +2 -2
  91. package/dist-library/reactive-md-react-component-date.js +2 -2
  92. package/dist-library/reactive-md-react-component-diagram.js +2 -2
  93. package/dist-library/reactive-md-react-component-disclosure.js +3 -3
  94. package/dist-library/reactive-md-react-component-edge.js +1 -1
  95. package/dist-library/reactive-md-react-component-else.js +10 -0
  96. package/dist-library/reactive-md-react-component-gallery-item.js +2 -2
  97. package/dist-library/reactive-md-react-component-gallery.js +2 -2
  98. package/dist-library/reactive-md-react-component-grid.js +3 -3
  99. package/dist-library/reactive-md-react-component-if.js +3 -3
  100. package/dist-library/reactive-md-react-component-input.js +2 -2
  101. package/dist-library/reactive-md-react-component-jump.js +3 -3
  102. package/dist-library/reactive-md-react-component-multi-select.js +2 -2
  103. package/dist-library/reactive-md-react-component-node.js +2 -2
  104. package/dist-library/reactive-md-react-component-number.js +2 -2
  105. package/dist-library/reactive-md-react-component-option.js +1 -1
  106. package/dist-library/reactive-md-react-component-panel.js +3 -3
  107. package/dist-library/reactive-md-react-component-plot.js +2 -2
  108. package/dist-library/reactive-md-react-component-progress.js +2 -2
  109. package/dist-library/reactive-md-react-component-quiz.js +2 -2
  110. package/dist-library/reactive-md-react-component-radio-group.js +2 -2
  111. package/dist-library/reactive-md-react-component-range-slider.js +2 -2
  112. package/dist-library/reactive-md-react-component-section.js +3 -3
  113. package/dist-library/reactive-md-react-component-select.js +2 -2
  114. package/dist-library/reactive-md-react-component-slider.js +2 -2
  115. package/dist-library/reactive-md-react-component-step.js +3 -3
  116. package/dist-library/reactive-md-react-component-steps.js +3 -3
  117. package/dist-library/reactive-md-react-component-tab.js +3 -3
  118. package/dist-library/reactive-md-react-component-table.js +2 -2
  119. package/dist-library/reactive-md-react-component-tabs.js +3 -3
  120. package/dist-library/reactive-md-react-component-text.js +3 -3
  121. package/dist-library/reactive-md-react-component-textarea.js +2 -2
  122. package/dist-library/reactive-md-react-component-timeline.js +2 -2
  123. package/dist-library/reactive-md-react-component-timer.js +2 -2
  124. package/dist-library/reactive-md-react-component-toggle.js +2 -2
  125. package/dist-library/reactive-md-react-component-tooltip.js +3 -3
  126. package/dist-library/reactive-md-react-component-validation.js +3 -3
  127. package/dist-library/reactive-md-react-minimal.js +4 -4
  128. package/dist-library/reactive-md-react-pack-controls.js +4 -4
  129. package/dist-library/reactive-md-react-pack-data.js +3 -3
  130. package/dist-library/reactive-md-react-pack-layout.js +25 -24
  131. package/dist-library/reactive-md-react-pack-visuals.js +2 -2
  132. package/dist-library/reactive-md-react-packed.js +6 -6
  133. package/dist-library/reactive-md-react-server.js +37 -36
  134. package/dist-library/reactive-md-react-static-server.js +2 -2
  135. package/dist-library/reactive-md-react-static.js +1 -1
  136. package/dist-library/reactive-md-react-unstyled.js +12 -12
  137. package/dist-library/reactive-md-react.js +12 -12
  138. package/dist-library/reactive-md-scan.js +1 -1
  139. package/dist-library/reactive-md-sdk.js +23 -9
  140. package/dist-library/reactive-md-standalone-configured.js +2 -2
  141. package/dist-library/reactive-md-standalone-host.js +2 -2
  142. package/dist-library/reactive-md-testing-browser.js +2 -2
  143. package/dist-library/reactive-md-testing-react.js +6 -6
  144. package/dist-library/reactive-md-testing.js +6 -6
  145. package/dist-library/reactive-md-vite.js +25 -9
  146. package/dist-library/reactive-md-worker-pool.js +3 -3
  147. package/dist-library/reactive-md.css +1 -1
  148. package/dist-library/reactive-md.js +52 -43
  149. package/dist-library/{registry-core-CziAIP5P.js → registry-core-DxEaxhJ6.js} +3 -2
  150. package/dist-library/{render-nodes-DKjg_TR1.js → render-nodes-B6j6Ip5I.js} +766 -731
  151. package/dist-library/{requirements-DhIkxAbl.js → requirements-C56sFIEs.js} +2 -2
  152. package/dist-library/{resources-B_nbROgj.js → resources-6VaNgk-h.js} +2 -2
  153. package/dist-library/rmd-pack-layout.css +9 -0
  154. package/dist-library/rmd-pack-resource-layout.css +9 -0
  155. package/dist-library/runtime-BHeuLOv_.js +1369 -0
  156. package/dist-library/{runtime-requirement-C4-vNcf5.js → runtime-requirement-DzPO8raU.js} +166 -163
  157. package/dist-library/{schema-core-4sd1Vu7V.js → schema-core-CDXfxdID.js} +24 -1
  158. package/dist-library/{sdk-core-BLsW9cCy.js → sdk-core-CnE-n0Z7.js} +469 -314
  159. package/dist-library/{session-core-DLBRPV7f.js → session-core-C071yQwV.js} +140 -127
  160. package/dist-library/{validation-XXlb-spV.js → sha256-utf16-Bmandi_H.js} +392 -315
  161. package/dist-library/shareable-CHCDnl6j.js +844 -0
  162. package/dist-library/types/authoring/catalog.d.ts +3 -1
  163. package/dist-library/types/authoring/index.d.ts +1 -1
  164. package/dist-library/types/components/chart/default-chart-types.d.ts +3 -0
  165. package/dist-library/types/components/chart/default-chart.d.ts +7 -0
  166. package/dist-library/types/components/entries/else.d.ts +3 -0
  167. package/dist-library/types/components/layout/layout.d.ts +5 -0
  168. package/dist-library/types/components/shared/visuals.d.ts +1 -1
  169. package/dist-library/types/components/table/data-table-model.d.ts +95 -2
  170. package/dist-library/types/components/table/data-table.d.ts +2 -2
  171. package/dist-library/types/contracts/component-kernel.d.ts +5 -0
  172. package/dist-library/types/contracts/font-aliases.d.ts +18 -0
  173. package/dist-library/types/contracts/number-literal.d.ts +2 -0
  174. package/dist-library/types/contracts/sha256-utf16.d.ts +2 -0
  175. package/dist-library/types/export/index.d.ts +4 -1
  176. package/dist-library/types/local/compilation/compiler-choices.d.ts +4 -0
  177. package/dist-library/types/local/compilation/compiler-declarations.d.ts +2 -1
  178. package/dist-library/types/local/compilation/compiler-expressions.d.ts +12 -1
  179. package/dist-library/types/local/compilation/compiler-macros.d.ts +18 -0
  180. package/dist-library/types/local/compilation/compiler-structure.d.ts +8 -2
  181. package/dist-library/types/local/compilation/compiler-tables.d.ts +1 -0
  182. package/dist-library/types/local/compilation/compiler-validation.d.ts +11 -0
  183. package/dist-library/types/local/compilation/compiler-values.d.ts +1 -2
  184. package/dist-library/types/local/configuration/diagnostic-messages.d.ts +173 -2
  185. package/dist-library/types/local/configuration/diagnostic-runtime-messages.d.ts +40 -0
  186. package/dist-library/types/local/evaluation/choice-values.d.ts +22 -0
  187. package/dist-library/types/local/evaluation/computations.d.ts +13 -5
  188. package/dist-library/types/local/evaluation/dataset.d.ts +4 -0
  189. package/dist-library/types/local/evaluation/expression/collection-functions.d.ts +13 -0
  190. package/dist-library/types/local/evaluation/expression/compile.d.ts +11 -4
  191. package/dist-library/types/local/evaluation/expression/data-functions.d.ts +23 -0
  192. package/dist-library/types/local/evaluation/expression/evaluation.d.ts +3 -1
  193. package/dist-library/types/local/evaluation/expression/internal-names.d.ts +8 -0
  194. package/dist-library/types/local/evaluation/expression/syntax.d.ts +19 -2
  195. package/dist-library/types/local/evaluation/expression/transform-budget.d.ts +13 -0
  196. package/dist-library/types/local/evaluation/expression/values.d.ts +9 -1
  197. package/dist-library/types/local/evaluation/validation.d.ts +8 -6
  198. package/dist-library/types/local/index.d.ts +4 -3
  199. package/dist-library/types/local/parsing/conditional-branches.d.ts +4 -0
  200. package/dist-library/types/local/parsing/source-revision.d.ts +3 -0
  201. package/dist-library/types/local/runtime/runtime-choices.d.ts +11 -0
  202. package/dist-library/types/local/runtime/runtime.d.ts +3 -1
  203. package/dist-library/types/local/runtime/state.d.ts +30 -15
  204. package/dist-library/types/local/source/authoring-requirements.d.ts +3 -0
  205. package/dist-library/types/local/source/authoring-syntax.d.ts +3 -2
  206. package/dist-library/types/local/source/authoring.d.ts +10 -0
  207. package/dist-library/types/local/source/source-migration.d.ts +1 -0
  208. package/dist-library/types/local/types.d.ts +33 -2
  209. package/dist-library/types/react/component-api.d.ts +21 -2
  210. package/dist-library/types/react/component-utils.d.ts +11 -0
  211. package/dist-library/types/react/font-aliases.d.ts +2 -0
  212. package/dist-library/types/react/package-core.d.ts +3 -0
  213. package/dist-library/types/react/rendering/document/validation-state.d.ts +1 -1
  214. package/dist-library/types/react/rendering/document/view-revision.d.ts +3 -12
  215. package/dist-library/types/react/rendering/table/data-table.d.ts +1 -1
  216. package/dist-library/types/react/sdk-core.d.ts +3 -1
  217. package/dist-library/types/sdk/assembly.d.ts +3 -0
  218. package/dist-library/types/sdk/font.d.ts +13 -0
  219. package/dist-library/types/sdk/index.d.ts +1 -0
  220. package/dist-library/types/sdk/theme.d.ts +5 -0
  221. package/dist-library/types/sdk/types.d.ts +6 -0
  222. package/dist-library/types/sdk/version.d.ts +1 -1
  223. package/dist-library/types/shareable.d.ts +15 -3
  224. package/dist-library/types/standalone/prepare.d.ts +4 -2
  225. package/dist-library/types/standalone/session-core.d.ts +4 -1
  226. package/dist-library/types/vite/index.d.ts +3 -0
  227. package/dist-library/types/vite/registration.d.ts +1 -0
  228. package/dist-library/{types-Bza88SGK.js → types-B4qG8J4S.js} +1 -1
  229. package/dist-library/types-FYhRWRn9.js +3 -0
  230. package/dist-library/use-hydrated-D1gFY2Dq.js +2655 -0
  231. package/dist-library/validation-DRuW0Wl9.js +433 -0
  232. package/dist-library/{version-B0G1699c.js → version-4wzhbvDG.js} +1 -1
  233. package/dist-library/{visual-helpers-CRmaqCHX.js → visual-helpers-UU6xiL8g.js} +3 -3
  234. package/dist-library/visuals-7xzoL9ql.js +49340 -0
  235. package/dist-library/{worker-D6WMV8xJ.js → worker-3ldRjOEG.js} +9 -9
  236. package/dist-standalone/reactive-md-standalone.css +1 -1
  237. package/dist-standalone/reactive-md-standalone.js +128 -368
  238. package/docs/README-ch.md +3 -1
  239. package/docs/README.md +3 -1
  240. package/docs/compatibility/api-stability-ch.md +1 -1
  241. package/docs/compatibility/api-stability-en.md +1 -1
  242. package/docs/compatibility/compatibility-ch.md +15 -15
  243. package/docs/compatibility/compatibility-en.md +15 -15
  244. package/docs/compatibility/compatibility-manifest.schema.json +3 -2
  245. package/docs/compatibility/deprecation-ch.md +2 -2
  246. package/docs/compatibility/deprecation-en.md +2 -2
  247. package/docs/compatibility/source-versioning-ch.md +22 -14
  248. package/docs/compatibility/source-versioning-en.md +22 -13
  249. package/docs/compatibility/support-matrix-ch.md +4 -3
  250. package/docs/compatibility/support-matrix-en.md +4 -3
  251. package/docs/development/component-development-ch.md +2 -2
  252. package/docs/development/component-development-en.md +2 -2
  253. package/docs/development/component-protocol-ch.md +18 -18
  254. package/docs/development/component-protocol-en.md +14 -14
  255. package/docs/guides/local-guide-ch.md +109 -20
  256. package/docs/guides/local-guide-en.md +109 -20
  257. package/docs/integration/author-tools-ch.md +1 -1
  258. package/docs/integration/author-tools-en.md +1 -1
  259. package/docs/integration/editor-ch.md +3 -3
  260. package/docs/integration/editor-en.md +3 -3
  261. package/docs/integration/extension-sdk-ch.md +29 -3
  262. package/docs/integration/extension-sdk-en.md +29 -3
  263. package/docs/integration/local-integration-ch.md +3 -3
  264. package/docs/integration/local-integration-en.md +3 -3
  265. package/docs/integration/pdf-export-ch.md +42 -0
  266. package/docs/integration/pdf-export-en.md +42 -0
  267. package/docs/integration/shareable-export-ch.md +11 -19
  268. package/docs/integration/shareable-export-en.md +11 -19
  269. package/docs/reference/diagnostics-counting-ch.md +24 -1
  270. package/docs/reference/diagnostics-counting-en.md +24 -1
  271. package/docs/reference/local-interaction-syntax-ch.md +222 -33
  272. package/docs/reference/local-interaction-syntax-en.md +220 -31
  273. package/docs/reference/public-api-ch.md +24 -18
  274. package/docs/reference/public-api-en.md +24 -18
  275. package/docs/reference/theme-protocol-ch.md +1 -1
  276. package/docs/reference/theme-protocol-en.md +1 -1
  277. package/docs/releases/release-0.10.0-ch.md +45 -0
  278. package/docs/releases/release-0.10.0-en.md +45 -0
  279. package/examples/conformance/README-ch.md +3 -3
  280. package/examples/conformance/README.md +3 -3
  281. package/examples/conformance/local-draft-4.json +441 -0
  282. package/examples/integration/README-ch.md +3 -3
  283. package/examples/integration/README.md +3 -3
  284. package/examples/integration/chat-session/package.json +1 -1
  285. package/examples/local/README-ch.md +1 -1
  286. package/examples/local/README.md +1 -1
  287. package/package.json +6 -1
  288. package/dist-library/LocalStaticDocumentView-2J7w0sKm.js +0 -143
  289. package/dist-library/authoring-B14SsOXZ.js +0 -893
  290. package/dist-library/compile-D50B5_Ww.js +0 -1249
  291. package/dist-library/computations-CffoW7Ff.js +0 -340
  292. package/dist-library/data-table-Kv_ZA2Z2.js +0 -297
  293. package/dist-library/default-options-DU5dxuU6.js +0 -125
  294. package/dist-library/layout-BfUzzO2b.js +0 -553
  295. package/dist-library/runtime-CuJndKqK.js +0 -1289
  296. package/dist-library/shareable-C6mUerpQ.js +0 -817
  297. package/dist-library/types-daDo2c_w.js +0 -3
  298. package/dist-library/use-hydrated-W-laKPhY.js +0 -22975
  299. package/dist-library/visuals-CoVSjVD8.js +0 -49159
@@ -0,0 +1,1369 @@
1
+ import { E as e } from "./limits-CFERRrlC.js";
2
+ import { _ as t, l as n, o as r, y as i } from "./document-theme-CJvN-nC1.js";
3
+ import { _ as a, a as o, b as s, o as c, r as l, t as u, x as d } from "./compile-B35rfzKr.js";
4
+ import { i as f, n as p, r as m, t as h } from "./choice-values-BItGjPD2.js";
5
+ import { a as g, c as _, f as v, g as y, i as b, n as x, o as S, p as C, r as ee, t as w, v as T } from "./validation-DRuW0Wl9.js";
6
+ import { n as te, t as E } from "./types-FYhRWRn9.js";
7
+ import { t as D } from "./component-kernel-CsJSabHX.js";
8
+ import { t as O } from "./default-registry-DXJy66xj.js";
9
+ import { x as ne } from "./component-state-CwKX_SN5.js";
10
+ import { i as re, t as ie } from "./identity-BUx0Q_-d.js";
11
+ import { n as ae } from "./runtime-BDnnimPA.js";
12
+ // src/local/runtime/runtime-values.ts
13
+ function k(e, t) {
14
+ return e.attrs?.[t];
15
+ }
16
+ function oe(e, t) {
17
+ let n = k(e, t);
18
+ if (n === "true") return !0;
19
+ if (n === "false") return !1;
20
+ }
21
+ function se(e, t) {
22
+ let n = k(e, t);
23
+ if (n === void 0) return;
24
+ let r = Number(n);
25
+ return Number.isFinite(r) ? r : void 0;
26
+ }
27
+ function A(e) {
28
+ return t(e);
29
+ }
30
+ function j(e, t) {
31
+ return {
32
+ ok: !1,
33
+ detail: n(e, t)
34
+ };
35
+ }
36
+ function M(e, t) {
37
+ if (t !== void 0) return k(e, t);
38
+ }
39
+ function N(e, t) {
40
+ if (t !== void 0) return se(e, t);
41
+ }
42
+ function ce(t, n, r, i = {}) {
43
+ for (let a of r) if (a.kind === "date") {
44
+ if (!D(n)) return j("local.runtime.value.date-invalid");
45
+ let e = i.required ?? (a.required !== void 0 && oe(t, a.required) === !0);
46
+ if (n === "" && e) return j("local.runtime.value.date-required");
47
+ let r = i.min ?? M(t, a.min), o = i.max ?? M(t, a.max);
48
+ if (n !== "" && r && n < r) return j("local.runtime.value.date-earlier", { min: r });
49
+ if (n !== "" && o && n > o) return j("local.runtime.value.date-later", { max: o });
50
+ } else if (a.kind === "required") {
51
+ let e = i.required ?? oe(t, a.required) === !0;
52
+ if (n === "" && e) return j("local.runtime.value.field-required");
53
+ } else if (a.kind === "length") {
54
+ let e = A(n), r = N(t, a.min), i = N(t, a.max);
55
+ if (r !== void 0 && r > 0 && n !== "" && e < r) return j("local.runtime.value.min-length", { min: r });
56
+ if (i !== void 0 && e > i) return j("local.runtime.value.max-length", { max: i });
57
+ } else if (a.kind === "email" && (M(t, a.type) ?? "text") === a.value && n !== "") {
58
+ if (n.length > 254) return j("local.runtime.value.email-length", { limit: 254 });
59
+ if (!e(n)) return j("local.runtime.value.email-invalid");
60
+ }
61
+ return {
62
+ ok: !0,
63
+ value: n
64
+ };
65
+ }
66
+ var P = /* @__PURE__ */ new Map();
67
+ function F(e) {
68
+ if (!e.name) return I;
69
+ let t = P.get(e.name);
70
+ if (t !== void 0) return t ?? I;
71
+ let n = O(e.name), r = n ? T(n) : I;
72
+ return P.set(e.name, n ? r : null), r;
73
+ }
74
+ var I = Object.freeze([]);
75
+ function L(e, t, n, i, a, o = !1) {
76
+ switch (e.type) {
77
+ case "number": {
78
+ if (typeof n != "number" || !Number.isFinite(n)) return j("local.runtime.value.finite-number", { name: e.name });
79
+ let r = e.step ?? 1, a = e.min ?? 0;
80
+ for (let r of t) {
81
+ let t = i(r, "min");
82
+ if (t.present && !t.ok) return j("local.runtime.value.constraint", {
83
+ name: e.name,
84
+ attribute: "min"
85
+ });
86
+ if (t.present && t.ok) {
87
+ if (typeof t.value != "number" || !Number.isFinite(t.value)) return j("local.runtime.value.constraint", {
88
+ name: e.name,
89
+ attribute: "min"
90
+ });
91
+ if (a = t.value, n < t.value) return j("local.runtime.value.min", {
92
+ name: e.name,
93
+ min: t.value
94
+ });
95
+ }
96
+ let o = i(r, "max");
97
+ if (o.present && !o.ok) return j("local.runtime.value.constraint", {
98
+ name: e.name,
99
+ attribute: "max"
100
+ });
101
+ if (o.present && o.ok) {
102
+ if (typeof o.value != "number" || !Number.isFinite(o.value)) return j("local.runtime.value.constraint", {
103
+ name: e.name,
104
+ attribute: "max"
105
+ });
106
+ if (n > o.value) return j("local.runtime.value.max", {
107
+ name: e.name,
108
+ max: o.value
109
+ });
110
+ }
111
+ if (t.present && t.ok && o.present && o.ok && typeof t.value == "number" && typeof o.value == "number" && t.value > o.value) return j("local.runtime.value.constraint-range", { name: e.name });
112
+ }
113
+ return e.min !== void 0 && n < e.min ? j("local.runtime.value.min", {
114
+ name: e.name,
115
+ min: e.min
116
+ }) : e.max !== void 0 && n > e.max ? j("local.runtime.value.max", {
117
+ name: e.name,
118
+ max: e.max
119
+ }) : r > 0 && !ue(n, a, r) ? j("local.runtime.value.step", {
120
+ name: e.name,
121
+ step: r,
122
+ base: a
123
+ }) : {
124
+ ok: !0,
125
+ value: n
126
+ };
127
+ }
128
+ case "boolean": return typeof n == "boolean" ? {
129
+ ok: !0,
130
+ value: n
131
+ } : j("local.runtime.value.boolean", { name: e.name });
132
+ case "string": {
133
+ if (typeof n != "string") return j("local.runtime.value.string", { name: e.name });
134
+ let s = d(n);
135
+ if (s) return j("local.runtime.value.budget", {
136
+ name: e.name,
137
+ detail: r(s),
138
+ detailKey: s.key,
139
+ ...s.params
140
+ });
141
+ for (let r of t) {
142
+ let t = a?.get(r.id) ?? (o ? F(r) : I);
143
+ if (!t.length) continue;
144
+ let s = {};
145
+ for (let n of t) {
146
+ if (n.kind === "date") {
147
+ for (let t of ["min", "max"]) {
148
+ if (n[t] === void 0) continue;
149
+ let a = i(r, t);
150
+ if (a.present) {
151
+ if (!a.ok || typeof a.value != "string" || !D(a.value)) return j("local.runtime.value.constraint-date", {
152
+ name: e.name,
153
+ attribute: t
154
+ });
155
+ s[t] = a.value;
156
+ }
157
+ }
158
+ let t = s.min ?? M(r, n.min), a = s.max ?? M(r, n.max);
159
+ if (t && a && D(t) && D(a) && t > a) return j("local.runtime.value.constraint-range", { name: e.name });
160
+ }
161
+ if ((n.kind === "date" || n.kind === "required" ? n.required : void 0) !== void 0) {
162
+ let t = i(r, "required");
163
+ if (t.present) {
164
+ if (!t.ok || typeof t.value != "boolean") return j("local.runtime.value.constraint", {
165
+ name: e.name,
166
+ attribute: "required"
167
+ });
168
+ s.required = t.value;
169
+ }
170
+ }
171
+ }
172
+ let c = ce(r, n, t, s);
173
+ if (!c.ok) return c;
174
+ }
175
+ return e.options?.length && !e.options.includes(n) ? j("local.runtime.value.option", {
176
+ value: n,
177
+ options: e.options.join(", ")
178
+ }) : {
179
+ ok: !0,
180
+ value: n
181
+ };
182
+ }
183
+ case "array": {
184
+ if (!Array.isArray(n)) return j("local.runtime.value.array", { name: e.name });
185
+ let t = d(n);
186
+ if (t) return j("local.runtime.value.budget", {
187
+ name: e.name,
188
+ detail: r(t),
189
+ detailKey: t.key,
190
+ ...t.params
191
+ });
192
+ for (let t of n) if (typeof t != "string") return j("local.runtime.value.array-members", { name: e.name });
193
+ if (e.family === "collection") return e.maxItems !== void 0 && n.length > e.maxItems ? j("local.runtime.value.max-items", {
194
+ name: e.name,
195
+ max: e.maxItems
196
+ }) : {
197
+ ok: !0,
198
+ value: n.slice()
199
+ };
200
+ let i = /* @__PURE__ */ new Set();
201
+ for (let t of n) {
202
+ if (e.options && !e.options.includes(t)) return j("local.runtime.value.checklist-option", { value: t });
203
+ i.add(t);
204
+ }
205
+ let a = e.options ? e.options.filter((e) => i.has(e)) : [...i];
206
+ return e.maxItems !== void 0 && a.length > e.maxItems ? j("local.runtime.value.max-items", {
207
+ name: e.name,
208
+ max: e.maxItems
209
+ }) : {
210
+ ok: !0,
211
+ value: a
212
+ };
213
+ }
214
+ case "number-array": {
215
+ if (!Array.isArray(n)) return j("local.runtime.value.number-array", { name: e.name });
216
+ let t = d(n);
217
+ if (t) return j("local.runtime.value.budget", {
218
+ name: e.name,
219
+ detail: r(t),
220
+ detailKey: t.key,
221
+ ...t.params
222
+ });
223
+ for (let t of n) if (typeof t != "number" || !Number.isFinite(t)) return j("local.runtime.value.number-array-members", { name: e.name });
224
+ return e.maxItems !== void 0 && n.length > e.maxItems ? j("local.runtime.value.max-items", {
225
+ name: e.name,
226
+ max: e.maxItems
227
+ }) : {
228
+ ok: !0,
229
+ value: n.slice()
230
+ };
231
+ }
232
+ case "null": return n === null ? {
233
+ ok: !0,
234
+ value: n
235
+ } : j("local.runtime.value.null", { name: e.name });
236
+ }
237
+ return j("local.runtime.value.unsupported-type", { name: e.name });
238
+ }
239
+ function R(e) {
240
+ return e instanceof a ? e : new a("expression-eval", e instanceof Error ? e.message : String(e), 0);
241
+ }
242
+ function le(e, t) {
243
+ switch (e) {
244
+ case "string": {
245
+ if (typeof t != "string") return {
246
+ ok: !1,
247
+ key: "local.runtime.external-value",
248
+ params: { kind: "string" }
249
+ };
250
+ let e = d(t);
251
+ return e ? {
252
+ ok: !1,
253
+ key: "local.runtime.external-budget",
254
+ params: {
255
+ detailKey: e.key,
256
+ ...e.params ?? {}
257
+ }
258
+ } : {
259
+ ok: !0,
260
+ value: t
261
+ };
262
+ }
263
+ case "number": return typeof t == "number" && Number.isFinite(t) ? {
264
+ ok: !0,
265
+ value: t
266
+ } : {
267
+ ok: !1,
268
+ key: "local.runtime.external-value",
269
+ params: { kind: "number" }
270
+ };
271
+ case "boolean": return typeof t == "boolean" ? {
272
+ ok: !0,
273
+ value: t
274
+ } : {
275
+ ok: !1,
276
+ key: "local.runtime.external-value",
277
+ params: { kind: "boolean" }
278
+ };
279
+ case "array": {
280
+ if (!Array.isArray(t)) return {
281
+ ok: !1,
282
+ key: "local.runtime.external-value",
283
+ params: { kind: "string-array" }
284
+ };
285
+ for (let e of t) if (typeof e != "string") return {
286
+ ok: !1,
287
+ key: "local.runtime.external-value",
288
+ params: { kind: "string-array" }
289
+ };
290
+ let e = d(t);
291
+ return e ? {
292
+ ok: !1,
293
+ key: "local.runtime.external-budget",
294
+ params: {
295
+ detailKey: e.key,
296
+ ...e.params ?? {}
297
+ }
298
+ } : {
299
+ ok: !0,
300
+ value: t.slice()
301
+ };
302
+ }
303
+ case "number-array": {
304
+ if (!Array.isArray(t)) return {
305
+ ok: !1,
306
+ key: "local.runtime.external-value",
307
+ params: { kind: "number-array" }
308
+ };
309
+ for (let e of t) if (typeof e != "number" || !Number.isFinite(e)) return {
310
+ ok: !1,
311
+ key: "local.runtime.external-value",
312
+ params: { kind: "number-array" }
313
+ };
314
+ let e = d(t);
315
+ return e ? {
316
+ ok: !1,
317
+ key: "local.runtime.external-budget",
318
+ params: {
319
+ detailKey: e.key,
320
+ ...e.params ?? {}
321
+ }
322
+ } : {
323
+ ok: !0,
324
+ value: t.slice()
325
+ };
326
+ }
327
+ default: return {
328
+ ok: !1,
329
+ key: "local.runtime.external-value",
330
+ params: { kind: String(e) }
331
+ };
332
+ }
333
+ }
334
+ var z = 1e-9;
335
+ function B(e) {
336
+ return Array.isArray(e) ? e.slice() : e;
337
+ }
338
+ function ue(e, t, n) {
339
+ let r = (e - t) / n;
340
+ return Math.abs(r - Math.round(r)) <= z * Math.max(1, Math.abs(r));
341
+ }
342
+ function V(e, t, n, i) {
343
+ let a = Math.max(0, Math.min(e.source.length, t.range.start)), o = e.source.slice(0, a).split("\n");
344
+ return {
345
+ code: n,
346
+ message: r(i),
347
+ severity: "error",
348
+ range: {
349
+ start: a,
350
+ end: Math.max(a + 1, Math.min(e.source.length, t.range.end))
351
+ },
352
+ line: o.length,
353
+ column: (o.at(-1) ?? "").length + 1,
354
+ messageKey: i.key,
355
+ phase: "runtime",
356
+ recoverable: !0,
357
+ ...i.params ? { params: i.params } : {}
358
+ };
359
+ }
360
+ function H(e, t, n) {
361
+ return {
362
+ code: e,
363
+ message: t,
364
+ severity: "error",
365
+ range: {
366
+ start: 0,
367
+ end: 0
368
+ },
369
+ line: 1,
370
+ column: 1,
371
+ phase: "runtime",
372
+ recoverable: !0,
373
+ ...n ? {
374
+ messageKey: n.key,
375
+ ...n.params ? { params: n.params } : {}
376
+ } : {}
377
+ };
378
+ }
379
+ // src/local/runtime/runtime-document.ts
380
+ function U(e, t) {
381
+ let n = e.document.bindings[t];
382
+ if (!n) return;
383
+ let { nodeIds: r, owner: i, ...a } = n, o = (e.controls.get(t) ?? []).map((t) => {
384
+ let n = e.document.dynamicConstraints?.[t.id] ?? {};
385
+ return {
386
+ name: t.name ?? null,
387
+ attrs: t.attrs ?? {},
388
+ dynamic: Object.fromEntries(Object.entries(n).map(([e, t]) => [e, t ? {
389
+ source: t.source,
390
+ numeric: t.numeric ?? null
391
+ } : null])),
392
+ rules: e.valueRules.get(t.id) ?? null
393
+ };
394
+ });
395
+ return JSON.stringify({
396
+ facts: a,
397
+ legacy: e.legacyValueRules,
398
+ controls: o
399
+ });
400
+ }
401
+ function W(e, t) {
402
+ let n = t.get(e);
403
+ if (n) return {
404
+ expression: n,
405
+ error: null
406
+ };
407
+ try {
408
+ let n = u(e);
409
+ if (t.size >= 200) {
410
+ let e = t.keys().next().value;
411
+ e !== void 0 && t.delete(e);
412
+ }
413
+ return t.set(e, n), {
414
+ expression: n,
415
+ error: null
416
+ };
417
+ } catch (e) {
418
+ return {
419
+ expression: null,
420
+ error: R(e)
421
+ };
422
+ }
423
+ }
424
+ function de(e, t) {
425
+ let n = /* @__PURE__ */ new Map();
426
+ for (let t of i(e.nodes)) n.set(t.id, t);
427
+ let c = {}, l = /* @__PURE__ */ new Map();
428
+ for (let [t, i] of Object.entries(e.bindings)) {
429
+ let e = d(i.initial);
430
+ if (e) throw new a("expression-budget", `Parameter "${t}": ${r(e)}`, 0);
431
+ c[t] = B(i.initial);
432
+ let o = [];
433
+ for (let e of i.nodeIds) {
434
+ let t = n.get(e);
435
+ t && o.push(t);
436
+ }
437
+ l.set(t, o);
438
+ }
439
+ let u = /* @__PURE__ */ new Map();
440
+ for (let [t, n] of Object.entries(e.bindingSlots ?? {})) u.set(t, { ...n });
441
+ let f = y(e), p = new Map(Object.entries(f?.valueRules ?? {})), m = f === void 0, h = /* @__PURE__ */ new Map();
442
+ if (f) for (let e of f.slotRelations) {
443
+ let t = u.get(e.nodeId), n = t?.[e.lower], r = t?.[e.upper];
444
+ if (!n || !r) continue;
445
+ let i = h.get(e.nodeId) ?? [];
446
+ i.push({
447
+ lower: n,
448
+ upper: r
449
+ }), h.set(e.nodeId, i);
450
+ }
451
+ else for (let [e, t] of u) t.start && t.end && h.set(e, [{
452
+ lower: t.start,
453
+ upper: t.end
454
+ }]);
455
+ let _ = /* @__PURE__ */ new Map();
456
+ for (let [t, n] of Object.entries(e.bindings)) for (let e of n.nodeIds) {
457
+ if (u.has(e)) continue;
458
+ let n = _.get(e);
459
+ (n === void 0 || n.startsWith("@") && !t.startsWith("@")) && _.set(e, t);
460
+ }
461
+ let v = Object.freeze(Object.keys(e.bindings).filter((e) => !e.startsWith("@")).sort()), b = /* @__PURE__ */ new Map();
462
+ for (let [e, t] of u) for (let n of Object.values(t)) {
463
+ if (n.startsWith("@")) continue;
464
+ let t = b.get(n) ?? /* @__PURE__ */ new Set();
465
+ t.add(e), b.set(n, t);
466
+ }
467
+ let x = e.computations ?? {}, ee = Object.keys(x), w = /* @__PURE__ */ new Map();
468
+ for (let [e, n] of Object.entries(x)) {
469
+ if (n.kind === "const" && Object.hasOwn(n, "value")) continue;
470
+ let r = W(n.source, t);
471
+ r.expression && w.set(e, r.expression);
472
+ }
473
+ let { order: T, cyclic: te } = C(x), E = o(), D = {}, O = /* @__PURE__ */ new Map();
474
+ for (let e of T) {
475
+ let t = x[e];
476
+ if (!t || t.kind !== "const") continue;
477
+ if (Object.hasOwn(t, "value")) {
478
+ let n = t.value, r = s(n);
479
+ if (r) {
480
+ O.set(e, new a("expression-budget", `Constant "${e}": ${r}`, 0));
481
+ continue;
482
+ }
483
+ D[e] = B(n);
484
+ continue;
485
+ }
486
+ let n = w.get(e);
487
+ if (!n) O.set(e, new a("expression-eval", `Constant "${e}" cannot be evaluated.`, 0));
488
+ else try {
489
+ let t = n.evaluate({ ...D }, E), r = s(t);
490
+ if (r) {
491
+ O.set(e, new a("expression-budget", `Constant "${e}": ${r}`, 0));
492
+ continue;
493
+ }
494
+ D[e] = B(t);
495
+ } catch (t) {
496
+ O.set(e, R(t));
497
+ }
498
+ }
499
+ let ne = /* @__PURE__ */ new Map();
500
+ for (let e of te) ne.set(e, new a("expression-cycle", `Computation "${e}" is part of a dependency cycle.`, 0));
501
+ let re = [];
502
+ if (Array.isArray(e.validations)) for (let n of e.validations) {
503
+ if (!g(n)) continue;
504
+ let e = W(n.expression, t);
505
+ re.push({
506
+ rule: n,
507
+ expression: e.expression,
508
+ error: e.error
509
+ });
510
+ }
511
+ return {
512
+ document: e,
513
+ nodeIndex: n,
514
+ controls: l,
515
+ slotKeys: u,
516
+ publicNames: v,
517
+ publicSlotOwners: b,
518
+ initial: c,
519
+ valueRules: p,
520
+ legacyValueRules: m,
521
+ slotRelations: h,
522
+ bindingByNode: _,
523
+ computationMetadata: x,
524
+ computationNames: ee,
525
+ computationOrder: T,
526
+ cyclicComputations: te,
527
+ computationExpressions: w,
528
+ constValues: D,
529
+ constErrors: O,
530
+ cycleErrors: ne,
531
+ validationRules: re,
532
+ validationLineStarts: S(typeof e.source == "string" ? e.source : "")
533
+ };
534
+ }
535
+ function fe(e) {
536
+ return !e || e.syntax !== "local" ? "createLocalRuntime requires a local interaction document." : e.syntaxVersion !== void 0 && e.syntaxVersion !== "local-draft-4" || e.versionDeclaration && e.versionDeclaration.version !== "local-draft-4" ? `createLocalRuntime requires ${E}; migrate the source before constructing a runtime.` : null;
537
+ }
538
+ function G(e, t) {
539
+ return (e.controls.get(t.name) ?? [])[0] ?? (t.owner ? e.nodeIndex.get(t.owner) : void 0) ?? (t.nodeIds[0] ? e.nodeIndex.get(t.nodeIds[0]) : void 0);
540
+ }
541
+ function K(e, t, n) {
542
+ let i = G(e, t);
543
+ return i ? V(e.document, i, "local.runtime.value", n) : H("local.runtime.value", r(n));
544
+ }
545
+ function q(e, t, n) {
546
+ let r = e.slotRelations.get(t);
547
+ return r?.length ? r.some(({ lower: e, upper: t }) => {
548
+ let r = n[e], i = n[t];
549
+ return typeof r == "number" && typeof i == "number" && r > i;
550
+ }) : !1;
551
+ }
552
+ function pe(e, t) {
553
+ let i = e.nodeIndex.get(t);
554
+ return i ? V(e.document, i, "local.runtime.value", n("local.runtime.value.range-order")) : H("local.runtime.value", r(n("local.runtime.value.range-order")));
555
+ }
556
+ // src/local/runtime/retention.ts
557
+ function me(e) {
558
+ let t = /* @__PURE__ */ new Map();
559
+ for (let n of i(e.nodes)) t.set(n.id, n);
560
+ return t;
561
+ }
562
+ function J(e, t, n) {
563
+ let r = e.bindingSlots?.[t.id];
564
+ return r !== void 0 && Object.values(r).includes(n);
565
+ }
566
+ function he(e, t, n) {
567
+ let r = t.name ? O(t.name) : void 0;
568
+ if (r?.bindings) {
569
+ let i = e.bindingSlots?.[t.id];
570
+ for (let [e, a] of Object.entries(r.bindings)) if (t.attrs?.[a.bind] === n || e !== "value" && i?.[e] === n) return a.retain === !1 ? void 0 : a.initial;
571
+ } else if (t.attrs?.bind === n || J(e, t, n)) return "initial";
572
+ }
573
+ function ge(e) {
574
+ let t = me(e), n = y(e), r = new Set(n?.retentionExclusions ?? []), i = /* @__PURE__ */ new Map();
575
+ for (let [a, o] of Object.entries(e.bindings)) {
576
+ let s = o.nodeIds.flatMap((e) => {
577
+ let n = t.get(e);
578
+ return n ? [n] : [];
579
+ });
580
+ if (!s.length || a.startsWith("@") || r.has(a)) continue;
581
+ let c;
582
+ if (n === void 0) {
583
+ let t = s.map((t) => he(e, t, a));
584
+ if (t.some((e) => e === void 0)) continue;
585
+ c = t;
586
+ } else {
587
+ let e = n.bindingAttributes?.[a]?.initial ?? "initial";
588
+ c = s.map(() => e);
589
+ }
590
+ let l = s.flatMap((e, t) => Object.hasOwn(e.attrs ?? {}, c[t]) ? [e.attrs[c[t]]] : []).sort();
591
+ i.set(a, {
592
+ type: o.type,
593
+ initialDefinition: JSON.stringify([o.initial, l])
594
+ });
595
+ }
596
+ return i;
597
+ }
598
+ function Y(e, t) {
599
+ return Object.freeze({
600
+ name: e,
601
+ reason: t
602
+ });
603
+ }
604
+ function _e(e) {
605
+ let t = ge(e.previous), n = ge(e.next), r = {}, i = [], a = [];
606
+ for (let o of Object.keys(e.state).sort()) {
607
+ if (o.startsWith("@")) {
608
+ a.push(Y(o, "internal"));
609
+ continue;
610
+ }
611
+ if (!Object.hasOwn(e.previous.bindings, o) || !Object.hasOwn(e.next.bindings, o)) {
612
+ a.push(Y(o, "unknown"));
613
+ continue;
614
+ }
615
+ let s = t.get(o), c = n.get(o);
616
+ if (!s || !c) {
617
+ a.push(Y(o, "unretainable"));
618
+ continue;
619
+ }
620
+ if (s.type !== c.type) {
621
+ a.push(Y(o, "type"));
622
+ continue;
623
+ }
624
+ if (s.initialDefinition !== c.initialDefinition) {
625
+ a.push(Y(o, "initial"));
626
+ continue;
627
+ }
628
+ let l = e.state[o];
629
+ r[o] = Array.isArray(l) ? Object.freeze([...l]) : l, i.push(o);
630
+ }
631
+ return Object.freeze({
632
+ values: Object.freeze(r),
633
+ retained: Object.freeze(i),
634
+ dropped: Object.freeze(a)
635
+ });
636
+ }
637
+ function ve(e, t, n) {
638
+ return Object.freeze({
639
+ retained: Object.freeze([...e]),
640
+ dropped: Object.freeze(t.map((e) => Object.freeze({ ...e }))),
641
+ diagnostics: Object.freeze([...n])
642
+ });
643
+ }
644
+ function ye(e, t) {
645
+ let n = Object.keys(t.values).sort();
646
+ if (!e.setParameters(t.values).length) return ve(n, t.dropped, []);
647
+ let r = [], i = n, a = [];
648
+ for (; i.length;) {
649
+ let n = [];
650
+ a = [];
651
+ for (let o of i) {
652
+ let i = e.setParameter(o, t.values[o]);
653
+ i.length ? (n.push(o), a.push(...i)) : r.push(o);
654
+ }
655
+ if (n.length === i.length) break;
656
+ i = n;
657
+ }
658
+ r.sort();
659
+ let o = [...t.dropped, ...i.map((e) => Y(e, "invalid"))];
660
+ return o.sort((e, t) => e.name < t.name ? -1 : +(e.name > t.name)), ve(r, o, a);
661
+ }
662
+ // src/local/runtime/runtime-migration.ts
663
+ function be(e, t, n, r, i) {
664
+ let a = _e({
665
+ previous: e.document,
666
+ state: t,
667
+ next: n
668
+ }), o = {}, s = n.macroConfigKey !== void 0 && n.macroConfigKey === e.document.macroConfigKey && n.source === e.document.source;
669
+ for (let [e, r] of Object.entries(n.bindings)) o[e] = B(s && e.startsWith("@macro:") && Object.hasOwn(t, e) ? t[e] : r.initial);
670
+ let c = /* @__PURE__ */ new Map();
671
+ for (let e of a.dropped) c.set(e.name, Object.freeze({ ...e }));
672
+ let l = [], u = {}, d = [], f = /* @__PURE__ */ new Set(), p, m = (n) => {
673
+ let o = e.document.bindings[n], s = e.controls.get(n) ?? [];
674
+ return !o || !s.some((t) => e.document.dynamicConstraints?.[t.id]) || (p ??= i({}, e, t), L(o, s, a.values[n], p, e.valueRules, e.legacyValueRules).ok) ? !1 : U(e, n) === U(r, n);
675
+ };
676
+ for (let e of a.retained) {
677
+ let t = n.bindings[e];
678
+ if (!t) continue;
679
+ if (m(e)) {
680
+ f.add(e), u[e] = B(a.values[e]), d.push(e);
681
+ continue;
682
+ }
683
+ let s = L(t, r.controls.get(e) ?? [], a.values[e], i(a.values, r, o), r.valueRules, r.legacyValueRules);
684
+ s.ok ? (u[e] = B(s.value), d.push(e)) : (l.push(K(r, t, s.detail)), c.set(e, Object.freeze({
685
+ name: e,
686
+ reason: "invalid"
687
+ })));
688
+ }
689
+ let h = {
690
+ ...o,
691
+ ...u
692
+ }, g = /* @__PURE__ */ new Set();
693
+ for (let e of d) for (let t of r.publicSlotOwners.get(e) ?? []) g.add(t);
694
+ let _ = !1;
695
+ for (let e of [...g].sort()) if (q(r, e, h)) {
696
+ _ = !0;
697
+ break;
698
+ }
699
+ let v;
700
+ if (!_) Object.assign(o, u), v = d;
701
+ else {
702
+ v = [];
703
+ for (let e of d) {
704
+ let t = o[e];
705
+ o[e] = u[e];
706
+ let n = !1;
707
+ for (let t of [...r.publicSlotOwners.get(e) ?? []].sort()) q(r, t, o) && (l.push(pe(r, t)), n = !0);
708
+ n ? (o[e] = t, c.set(e, Object.freeze({
709
+ name: e,
710
+ reason: "invalid"
711
+ }))) : v.push(e);
712
+ }
713
+ }
714
+ for (let [e, t] of r.slotRelations) if (q(r, e, o)) {
715
+ for (let e of t) for (let t of [e.lower, e.upper]) {
716
+ let e = n.bindings[t];
717
+ if (!e) continue;
718
+ o[t] = B(e.initial);
719
+ let r = v.indexOf(t);
720
+ r >= 0 && v.splice(r, 1), c.set(t, Object.freeze({
721
+ name: t,
722
+ reason: "invalid"
723
+ }));
724
+ }
725
+ if (l.push(pe(r, e)), q(r, e, o)) return {
726
+ values: {},
727
+ retained: [],
728
+ dropped: [],
729
+ diagnostics: []
730
+ };
731
+ }
732
+ let y = !0;
733
+ for (; y;) {
734
+ let e = i({}, r, o), t = [];
735
+ for (let i of v) {
736
+ if (f.has(i)) continue;
737
+ let a = n.bindings[i], s = L(a, r.controls.get(i) ?? [], o[i], e, r.valueRules, r.legacyValueRules);
738
+ s.ok || (l.push(K(r, a, s.detail)), t.push(i));
739
+ }
740
+ for (let e of t) o[e] = B(n.bindings[e].initial), v.splice(v.indexOf(e), 1), c.set(e, Object.freeze({
741
+ name: e,
742
+ reason: "invalid"
743
+ }));
744
+ y = t.length > 0;
745
+ }
746
+ let b = [...c.values()].sort((e, t) => e.name < t.name ? -1 : +(e.name > t.name));
747
+ return v.sort(), {
748
+ values: o,
749
+ retained: v,
750
+ dropped: b,
751
+ diagnostics: l
752
+ };
753
+ }
754
+ // src/local/runtime/runtime-choices.ts
755
+ function xe(e, t, n, r) {
756
+ try {
757
+ if (e.kind === "options") {
758
+ let i = n(e.source);
759
+ return i ? f(i.evaluate(t, r)) : null;
760
+ }
761
+ let i = e.staticKeys[0], a = e.staticKeys.every((e) => i && e.length === i.length && e.every((e, t) => e === i?.[t]));
762
+ for (let o of e.sources) {
763
+ let e = n(o.rows)?.evaluate(t, r), s = n(o.key);
764
+ if (!e || !s) return null;
765
+ if (!Array.isArray(e) || e.length > o.maxRows) return [];
766
+ let c = /* @__PURE__ */ new Set();
767
+ for (let [n, i] of e.entries()) {
768
+ let e = h(s.evaluate(p(i, n, s.dependencies, (e) => t[e]), r));
769
+ if (e === null || c.has(e)) return [];
770
+ c.add(e);
771
+ }
772
+ let l = [...c];
773
+ i && (l.length !== i.length || l.some((e, t) => e !== i?.[t])) && (a = !1), i ??= l;
774
+ }
775
+ return a ? [...i ?? []] : [];
776
+ } catch {
777
+ return null;
778
+ }
779
+ }
780
+ function Se(e, t, n, r, i) {
781
+ if (r === null) return i && n !== "" && (!Array.isArray(n) || n.length !== 0) ? { ok: !1 } : {
782
+ ok: !0,
783
+ value: n
784
+ };
785
+ if (!i && t.kind === "options") return {
786
+ ok: !0,
787
+ value: m(r, n, e.type === "array", e.maxItems) ?? n
788
+ };
789
+ if (e.type === "array") {
790
+ let t = new Set(Array.isArray(n) ? n : []), a = r.filter((e) => t.has(e));
791
+ return i && a.length !== t.size ? { ok: !1 } : {
792
+ ok: !0,
793
+ value: a.slice(0, e.maxItems ?? a.length)
794
+ };
795
+ }
796
+ let a = t.kind === "rows" ? "" : r[0] ?? "";
797
+ return typeof n == "string" && (n === a || r.includes(n)) ? {
798
+ ok: !0,
799
+ value: n
800
+ } : i ? { ok: !1 } : {
801
+ ok: !0,
802
+ value: a
803
+ };
804
+ }
805
+ // src/local/runtime/runtime.ts
806
+ function Ce(e) {
807
+ return {
808
+ ...e,
809
+ range: { ...e.range },
810
+ ...e.details ? { details: { ...e.details } } : {}
811
+ };
812
+ }
813
+ function X(e, t) {
814
+ return Array.isArray(e) || Array.isArray(t) ? !Array.isArray(e) || !Array.isArray(t) || e.length !== t.length ? !1 : e.every((e, n) => e === t[n]) : e === t;
815
+ }
816
+ function we(e) {
817
+ for (let [t, n] of Object.entries(e)) Array.isArray(n) && !Object.isFrozen(n) && (e[t] = Object.freeze([...n]));
818
+ return Object.freeze(e);
819
+ }
820
+ var Z = /* @__PURE__ */ new WeakMap();
821
+ function Q(e, t) {
822
+ let n = Z.get(e);
823
+ if (n) return n.restore(t);
824
+ let r = Object.entries(t);
825
+ if (r.some(([e]) => e.startsWith("@"))) throw TypeError("Private state restoration requires a runtime created by createLocalRuntime.");
826
+ let i = e.getParameters(), a = new Set(e.document.choiceConstraints?.map((e) => e.binding)), o = new Set(Object.values(e.document.bindingSlots ?? {}).flatMap((e) => Object.values(e)));
827
+ return e.setParameters(Object.fromEntries(r.filter(([e, t]) => a.has(e) || o.has(e) || !X(i[e], t))));
828
+ }
829
+ function $(e) {
830
+ return Object.freeze({
831
+ ok: e.ok,
832
+ changed: e.changed,
833
+ revision: e.revision,
834
+ retained: Object.freeze([...e.retained]),
835
+ dropped: Object.freeze(e.dropped.map((e) => Object.freeze({ ...e }))),
836
+ diagnostics: Object.freeze([...e.diagnostics])
837
+ });
838
+ }
839
+ function Te(e, t, n) {
840
+ let r = Z.get(e);
841
+ if (!r) throw TypeError("updateLocalRuntime requires a runtime created by createLocalRuntime.");
842
+ return r.update(t, n?.notify !== !1);
843
+ }
844
+ function Ee(e) {
845
+ Z.get(e)?.notify();
846
+ }
847
+ function De(e, t, n) {
848
+ return Z.get(e)?.bindNetworkExternals(t, n) ?? (() => {});
849
+ }
850
+ function Oe(e, t) {
851
+ let s = fe(e);
852
+ if (s) throw Error(s);
853
+ let f = t?.services === void 0, p = ne(t?.network), m = /* @__PURE__ */ new Map(), h = re(e.source), g = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), S = de(e, y), C = () => S, T = () => {
854
+ let e = /* @__PURE__ */ new Set();
855
+ for (let n of i(S.document.nodes)) n.name !== void 0 && e.add(ie({
856
+ documentId: t?.documentId,
857
+ sourceDigest: h,
858
+ nodeId: n.id,
859
+ stateKey: n.attrs?.["state-key"]
860
+ }));
861
+ return e;
862
+ }, E = t?.services ?? ae({
863
+ documentId: t?.documentId,
864
+ sourceDigest: h,
865
+ randomSeed: t?.randomSeed,
866
+ componentState: t?.componentState,
867
+ ...t?.componentStateStorage === void 0 ? {} : { componentStateStorage: t.componentStateStorage },
868
+ ...t?.componentStateWriteDelayMs === void 0 ? {} : { componentStateWriteDelayMs: t.componentStateWriteDelayMs },
869
+ ...t?.configKey === void 0 ? {} : { configKey: t.configKey },
870
+ ...t?.legacyConfigKeys === void 0 ? {} : { legacyConfigKeys: t.legacyConfigKeys },
871
+ ...f ? { knownStateKeys: T } : {}
872
+ }), D = {}, O = /* @__PURE__ */ new Map();
873
+ for (let [n, r] of Object.entries(e.externals ?? {})) {
874
+ let e = t?.externalValues?.[n];
875
+ if (e === void 0) continue;
876
+ let i = le(r.type, e);
877
+ i.ok && (D[n] = i.value);
878
+ }
879
+ let k = (e, t) => {
880
+ let n = {};
881
+ for (let [r, i] of Object.entries(e.document.externals ?? {})) {
882
+ if (!Object.hasOwn(t, r)) continue;
883
+ let e = le(i.type, t[r]);
884
+ e.ok && (n[r] = e.value);
885
+ }
886
+ return n;
887
+ }, oe = (e) => {
888
+ let t = k(e, D);
889
+ for (let n of O.keys()) Object.assign(t, k(e, n));
890
+ return t;
891
+ }, se = (e, t, n, r, i) => {
892
+ let a = r.document.dynamicConstraints?.[e.id]?.[t];
893
+ if (!a) return { present: !1 };
894
+ let o = W(a.source, y);
895
+ if (!o.expression) return {
896
+ present: !0,
897
+ ok: !1
898
+ };
899
+ try {
900
+ let e = o.expression.evaluate(n, i), t = a.numeric;
901
+ return t && (typeof e != "number" || !Number.isFinite(e) || t.integer === !0 && !Number.isInteger(e) || t.min !== void 0 && e < t.min || t.max !== void 0 && e > t.max) ? {
902
+ present: !0,
903
+ ok: !1
904
+ } : {
905
+ present: !0,
906
+ ok: !0,
907
+ value: e
908
+ };
909
+ } catch {
910
+ return {
911
+ present: !0,
912
+ ok: !1
913
+ };
914
+ }
915
+ }, A = S.initial, j = 0, M = {}, N = {}, ce = {
916
+ revision: 0,
917
+ state: we({})
918
+ }, P = !1, F = null, I = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Map(), z = () => {
919
+ if (P) throw Error("The local interaction runtime has been disposed.");
920
+ };
921
+ function ue(e, t) {
922
+ if (!t.startsWith("@") && Object.hasOwn(e.document.bindings, t)) return Object.hasOwn(A, t) ? A[t] : void 0;
923
+ }
924
+ let U = (e, t, n) => {
925
+ let r = oe(e), i = /* @__PURE__ */ new Map();
926
+ for (let t of Object.keys(e.document.externals ?? {})) Object.hasOwn(r, t) || i.set(t, new a("external-missing", "External data \"" + t + "\" is not available.", 0));
927
+ let o = {
928
+ ...t,
929
+ ...r
930
+ }, s = {}, c = { ...o }, l = i;
931
+ if (e.computationNames.length > 0) {
932
+ let t = v(e.computationMetadata, e.computationOrder, e.computationExpressions, o, e.constValues, i, n);
933
+ s = t.values, c = t.environment, l = [...e.constErrors, ...e.cycleErrors];
934
+ }
935
+ for (let [e, t] of l) Object.hasOwn(c, e) || Object.defineProperty(c, e, {
936
+ enumerable: !0,
937
+ configurable: !0,
938
+ get() {
939
+ throw t;
940
+ }
941
+ });
942
+ return {
943
+ environment: c,
944
+ snapshotState: {
945
+ ...o,
946
+ ...s
947
+ }
948
+ };
949
+ }, G = (e, t, r = [], i = o()) => {
950
+ let a = t, s, c = [], l = new Set(r);
951
+ for (let r of e.document.choiceConstraints ?? []) {
952
+ let o = r.binding;
953
+ if (!Object.hasOwn(e.document.bindings, o)) continue;
954
+ let u = e.document.bindings[o];
955
+ s ??= U(e, a, i);
956
+ let d = xe(r, s.environment, (e) => W(e, y).expression, i), f = Se(u, r, a[o], d, l.has(o));
957
+ f.ok ? X(f.value, a[o]) || (a === t && (a = { ...t }), a[o] = f.value, e.computationNames.length ? s = void 0 : (s.environment[o] = f.value, s.snapshotState[o] = f.value)) : c.push(K(e, u, n(d === null ? "local.runtime.choice.unavailable" : "local.runtime.choice.member")));
958
+ }
959
+ return {
960
+ values: a,
961
+ layer: s ?? U(e, a, i),
962
+ diagnostics: c,
963
+ stage: i
964
+ };
965
+ }, me = ({ values: e, layer: t }) => {
966
+ A = e, M = t.environment, N = t.snapshotState;
967
+ }, J = (e, t = C(), n = A) => {
968
+ let r;
969
+ return (i, a) => t.document.dynamicConstraints?.[i.id]?.[a] ? (r ??= G(t, {
970
+ ...n,
971
+ ...e
972
+ }, Object.keys(e)), se(i, a, r.layer.environment, t, r.stage)) : { present: !1 };
973
+ }, he = () => {
974
+ ce = {
975
+ revision: j,
976
+ state: we(N)
977
+ };
978
+ }, ge = () => {
979
+ for (let e of I) e();
980
+ }, Y = (e, t) => {
981
+ let n = G(C(), e, t);
982
+ return n.diagnostics.length ? n.diagnostics : (t && n.values !== e && Object.keys(n.values).every((e) => X(A[e], n.values[e])) || (me(n), j += 1, he(), ge()), []);
983
+ }, _e = () => {
984
+ Y(A);
985
+ }, ve = (e, t = D) => {
986
+ if (z(), typeof e != "object" || !e || Array.isArray(e)) throw TypeError("setExternalValues requires an object of external values.");
987
+ let i = [], a = {}, o = Object.keys(e).sort();
988
+ for (let t of o) {
989
+ if (t === "__proto__") {
990
+ i.push(H("local.runtime.external", "External names cannot be \"__proto__\"."));
991
+ continue;
992
+ }
993
+ let o = C().document.externals ?? {}, s = Object.hasOwn(o, t) ? o[t] : void 0;
994
+ if (!s) {
995
+ let e = n("local.runtime.external", { name: t });
996
+ i.push(H("local.runtime.external", r(e), e));
997
+ continue;
998
+ }
999
+ let c = le(s.type, e[t]);
1000
+ if (c.ok) a[t] = c.value;
1001
+ else {
1002
+ let e = n(c.key, {
1003
+ name: t,
1004
+ ...c.params ?? {}
1005
+ });
1006
+ i.push(H("local.runtime.external", r(e), e));
1007
+ }
1008
+ }
1009
+ return i.length ? i : (o.some((e) => !X(t[e], a[e])) && (Object.assign(t, a), _e()), []);
1010
+ }, ye = (e, t) => {
1011
+ if (P) return () => {};
1012
+ let n = {}, r = e.bindExternalValues((e) => {
1013
+ if (P || !O.has(n)) return;
1014
+ let r = ve(e, n);
1015
+ r.length && t?.(r);
1016
+ });
1017
+ return r ? (O.set(n, r), () => {
1018
+ O.delete(n) && (r(), !P && Object.keys(n).length && _e());
1019
+ }) : () => {};
1020
+ }, Q = (e, t = !1) => {
1021
+ z();
1022
+ let n = C(), r = [], i = {}, a = Object.keys(e).sort(), o = J(e);
1023
+ for (let s of a) {
1024
+ if (s === "__proto__") {
1025
+ r.push(H("local.runtime.parameter", "Parameter names cannot be \"__proto__\"."));
1026
+ continue;
1027
+ }
1028
+ if (!t && s.startsWith("@")) {
1029
+ r.push(H("local.runtime.parameter", `Internal parameter "${s}" cannot be written by name.`));
1030
+ continue;
1031
+ }
1032
+ if (!Object.hasOwn(n.document.bindings, s)) {
1033
+ r.push(H("local.runtime.parameter", `Unknown parameter "${s}".`));
1034
+ continue;
1035
+ }
1036
+ let a = n.document.bindings[s], c = n.controls.get(s) ?? [];
1037
+ if (t && X(A[s], e[s]) && (e[s] === "" && a.initial === "" || c.every((e) => !n.document.dynamicConstraints?.[e.id]))) {
1038
+ i[s] = A[s];
1039
+ continue;
1040
+ }
1041
+ let l = L(a, c, e[s], o, n.valueRules, n.legacyValueRules);
1042
+ l.ok ? i[s] = B(l.value) : r.push(K(n, a, l.detail));
1043
+ }
1044
+ if (r.length) return r;
1045
+ if (!a.some((e) => !X(A[e], i[e]))) return [];
1046
+ let s = {
1047
+ ...A,
1048
+ ...i
1049
+ }, c = /* @__PURE__ */ new Set();
1050
+ for (let e of a) {
1051
+ let r = t ? n.document.bindings[e].nodeIds : n.publicSlotOwners.get(e) ?? [];
1052
+ for (let e of r) n.slotKeys.has(e) && c.add(e);
1053
+ }
1054
+ for (let e of [...c].sort()) q(n, e, s) && r.push(pe(n, e));
1055
+ return r.length ? r : Y(s, a);
1056
+ }, Te = (e) => {
1057
+ let t = g.get(e);
1058
+ if (!t) {
1059
+ if (t = u(e), g.size >= 200) {
1060
+ let e = g.keys().next().value;
1061
+ e !== void 0 && g.delete(e);
1062
+ }
1063
+ g.set(e, t);
1064
+ }
1065
+ return t;
1066
+ }, Ee = () => {
1067
+ let e = o(), t = C(), n = [], r = typeof t.document.source == "string" ? t.document.source : "";
1068
+ for (let i of t.validationRules) {
1069
+ if (i.error) {
1070
+ n.push(_(r, t.validationLineStarts, i.rule, w, b(`Validation expression is invalid: ${i.error.message}`)));
1071
+ continue;
1072
+ }
1073
+ if (!i.expression) continue;
1074
+ let a;
1075
+ try {
1076
+ a = i.expression.evaluate(M, e);
1077
+ } catch (e) {
1078
+ n.push(_(r, t.validationLineStarts, i.rule, w, b(`Validation expression failed: ${e instanceof Error ? e.message : String(e)}`)));
1079
+ continue;
1080
+ }
1081
+ typeof a == "boolean" ? a || n.push(_(r, t.validationLineStarts, i.rule, x, De(i.rule.message, e))) : n.push(_(r, t.validationLineStarts, i.rule, w, "Validation expression must evaluate to a boolean."));
1082
+ }
1083
+ return n;
1084
+ }, De = (e, t) => {
1085
+ let n;
1086
+ try {
1087
+ n = l(e, M, t);
1088
+ } catch {
1089
+ n = ee;
1090
+ }
1091
+ return b(n);
1092
+ }, Oe = (e, t) => {
1093
+ if (z(), e === S.document) return $({
1094
+ ok: !0,
1095
+ changed: !1,
1096
+ revision: j,
1097
+ retained: [],
1098
+ dropped: [],
1099
+ diagnostics: []
1100
+ });
1101
+ if (fe(e)) return $({
1102
+ ok: !1,
1103
+ changed: !1,
1104
+ revision: j,
1105
+ retained: [],
1106
+ dropped: [],
1107
+ diagnostics: []
1108
+ });
1109
+ let n;
1110
+ try {
1111
+ n = de(e, y);
1112
+ } catch {
1113
+ return $({
1114
+ ok: !1,
1115
+ changed: !1,
1116
+ revision: j,
1117
+ retained: [],
1118
+ dropped: [],
1119
+ diagnostics: []
1120
+ });
1121
+ }
1122
+ let r = be(S, A, e, n, J);
1123
+ if (Object.keys(r.values).length === 0 && Object.keys(e.bindings).length > 0) return $({
1124
+ ok: !1,
1125
+ changed: !1,
1126
+ revision: j,
1127
+ retained: [],
1128
+ dropped: [],
1129
+ diagnostics: []
1130
+ });
1131
+ let i;
1132
+ try {
1133
+ i = G(n, r.values);
1134
+ } catch {
1135
+ return $({
1136
+ ok: !1,
1137
+ changed: !1,
1138
+ revision: j,
1139
+ retained: [],
1140
+ dropped: [],
1141
+ diagnostics: []
1142
+ });
1143
+ }
1144
+ for (let e of [D, ...O.keys()]) {
1145
+ let t = k(n, e);
1146
+ for (let t of Object.keys(e)) delete e[t];
1147
+ Object.assign(e, t);
1148
+ }
1149
+ if (S = n, me(i), F = null, j += 1, he(), t) for (let e of I) e();
1150
+ let a = r.retained.filter((e) => X(r.values[e], A[e])), o = r.retained.filter((e) => !X(r.values[e], A[e])), s = [...r.dropped, ...o.map((e) => ({
1151
+ name: e,
1152
+ reason: "invalid"
1153
+ }))];
1154
+ return $({
1155
+ ok: !0,
1156
+ changed: !0,
1157
+ revision: j,
1158
+ retained: a,
1159
+ dropped: s.sort((e, t) => e.name < t.name ? -1 : +(e.name > t.name)),
1160
+ diagnostics: r.diagnostics
1161
+ });
1162
+ }, ke = (e) => {
1163
+ let t = /* @__PURE__ */ new Set();
1164
+ for (let n of i([e])) t.add(n.id);
1165
+ return t;
1166
+ }, Ae = {
1167
+ network: p.network,
1168
+ get document() {
1169
+ return S.document;
1170
+ },
1171
+ services: E,
1172
+ snapshot() {
1173
+ return z(), ce;
1174
+ },
1175
+ get(e, t) {
1176
+ z();
1177
+ let n = C(), r = n.nodeIndex.get(e.id);
1178
+ if (!r) return null;
1179
+ let i = t === void 0 ? n.slotKeys.get(r.id)?.value ?? n.bindingByNode.get(r.id) ?? te(r) : n.slotKeys.get(r.id)?.[t];
1180
+ return i && Object.hasOwn(A, i) ? B(A[i]) : null;
1181
+ },
1182
+ set(e, t, r) {
1183
+ z();
1184
+ let i = C(), a = i.nodeIndex.get(e.id);
1185
+ if (!a) return [V(i.document, e, "local.runtime.binding", n("local.runtime.binding.no-writable"))];
1186
+ let o = i.slotKeys.get(a.id), s;
1187
+ if (r === void 0) {
1188
+ if (o && !o.value) return [V(i.document, a, "local.runtime.binding", n("local.runtime.binding.needs-slot"))];
1189
+ s = o?.value ?? i.bindingByNode.get(a.id) ?? te(a);
1190
+ } else if (s = o?.[r], !s) return [V(i.document, a, "local.runtime.binding", n("local.runtime.binding.unknown-slot", { slot: r }))];
1191
+ let c = Object.hasOwn(i.document.bindings, s) ? i.document.bindings[s] : void 0;
1192
+ if (!c) return [V(i.document, a, "local.runtime.binding", n("local.runtime.binding.no-writable"))];
1193
+ let l = L(c, i.controls.get(s) ?? [], t, J({ [s]: t }), i.valueRules, i.legacyValueRules);
1194
+ if (!l.ok) return [V(i.document, a, "local.runtime.value", l.detail)];
1195
+ let u = B(l.value);
1196
+ if (X(A[s], u)) return [];
1197
+ let d = {
1198
+ ...A,
1199
+ [s]: u
1200
+ };
1201
+ return q(i, a.id, d) ? [V(i.document, a, "local.runtime.value", n("local.runtime.value.range-order"))] : Y(d, [s]);
1202
+ },
1203
+ setMany(e, t) {
1204
+ z();
1205
+ let r = C(), i = r.nodeIndex.get(e.id);
1206
+ if (!i) return [V(r.document, e, "local.runtime.binding", n("local.runtime.binding.no-writable"))];
1207
+ let a = r.slotKeys.get(i.id);
1208
+ if (!a) return [V(r.document, i, "local.runtime.binding", n("local.runtime.binding.no-multi-slot"))];
1209
+ let o = Object.entries(t);
1210
+ if (!o.length) return [];
1211
+ let s = { ...A }, c = Object.fromEntries(o.map(([e, t]) => [a[e], t])), l = J(c, r);
1212
+ for (let [e, t] of o) {
1213
+ let o = a[e];
1214
+ if (!o || !Object.hasOwn(r.document.bindings, o)) return [V(r.document, i, "local.runtime.binding", n("local.runtime.binding.unknown-slot", { slot: e }))];
1215
+ let c = L(r.document.bindings[o], r.controls.get(o) ?? [], t, l, r.valueRules, r.legacyValueRules);
1216
+ if (!c.ok) return [V(r.document, i, "local.runtime.value", c.detail)];
1217
+ s[o] = B(c.value);
1218
+ }
1219
+ return q(r, i.id, s) ? [V(r.document, i, "local.runtime.value", n("local.runtime.value.range-order"))] : o.every(([e, t]) => X(A[a[e]], t)) ? [] : Y(s, o.map(([e]) => a[e]));
1220
+ },
1221
+ parameterNames() {
1222
+ return z(), C().publicNames;
1223
+ },
1224
+ getParameter(e) {
1225
+ z();
1226
+ let t = ue(C(), e);
1227
+ return t === void 0 ? void 0 : B(t);
1228
+ },
1229
+ getParameters() {
1230
+ z();
1231
+ let e = C(), t = {};
1232
+ for (let n of e.publicNames) {
1233
+ let e = A[n];
1234
+ t[n] = Array.isArray(e) ? Object.freeze([...e]) : e;
1235
+ }
1236
+ return Object.freeze(t);
1237
+ },
1238
+ readSubmissionFields(e) {
1239
+ z();
1240
+ let t = C(), n = /* @__PURE__ */ new Map(), r = o(), i = (e, n) => se(e, n, M, t, r);
1241
+ if (e.length === 0) return {
1242
+ ok: !1,
1243
+ field: "",
1244
+ reason: "unavailable"
1245
+ };
1246
+ for (let r of e) {
1247
+ let e = ue(t, r);
1248
+ if (e === void 0 || n.has(r)) return {
1249
+ ok: !1,
1250
+ field: r,
1251
+ reason: "unavailable"
1252
+ };
1253
+ let a = L(t.document.bindings[r], t.controls.get(r) ?? [], e, i, t.valueRules, t.legacyValueRules);
1254
+ if (!a.ok) {
1255
+ let e = a.detail.key;
1256
+ return {
1257
+ ok: !1,
1258
+ field: r,
1259
+ reason: e === "local.runtime.value.field-required" || e === "local.runtime.value.date-required" ? "required" : "invalid"
1260
+ };
1261
+ }
1262
+ n.set(r, e);
1263
+ }
1264
+ let a = Object.create(null);
1265
+ for (let [e, r] of n) {
1266
+ for (let [n, i] of m.get(e) ?? []) {
1267
+ if (!t.controls.get(e)?.some((e) => e.id === i)) continue;
1268
+ let a = n(B(r));
1269
+ if (a) return {
1270
+ ok: !1,
1271
+ field: e,
1272
+ reason: a
1273
+ };
1274
+ }
1275
+ a[e] = Array.isArray(r) ? Object.freeze([...r]) : r;
1276
+ }
1277
+ return {
1278
+ ok: !0,
1279
+ payload: Object.freeze(a)
1280
+ };
1281
+ },
1282
+ registerSubmissionField(e, t) {
1283
+ if (P) return () => {};
1284
+ let n = C(), r = n.slotKeys.get(e.id)?.value ?? n.bindingByNode.get(e.id);
1285
+ if (!r || r.startsWith("@")) return () => {};
1286
+ let i = m.get(r);
1287
+ return i || m.set(r, i = /* @__PURE__ */ new Map()), i.set(t, e.id), () => {
1288
+ i.delete(t), i.size === 0 && m.get(r) === i && m.delete(r);
1289
+ };
1290
+ },
1291
+ setParameter(e, t) {
1292
+ z();
1293
+ let n = Object.create(null);
1294
+ return n[e] = t, Q(n);
1295
+ },
1296
+ setParameters(e) {
1297
+ if (z(), typeof e != "object" || !e || Array.isArray(e)) throw TypeError("setParameters requires an object of parameter values.");
1298
+ return Q(e);
1299
+ },
1300
+ getExternal(e) {
1301
+ if (z(), Object.hasOwn(C().document.externals ?? {}, e) && Object.hasOwn(N, e)) return B(N[e]);
1302
+ },
1303
+ getExternalValues() {
1304
+ z();
1305
+ let e = {};
1306
+ for (let [t, n] of Object.entries(oe(C()))) e[t] = Array.isArray(n) ? Object.freeze([...n]) : n;
1307
+ return Object.freeze(e);
1308
+ },
1309
+ setExternalValues(e) {
1310
+ return ve(e);
1311
+ },
1312
+ evaluate(e) {
1313
+ z();
1314
+ let t = Te(e).evaluate(M, c() ?? o());
1315
+ return Array.isArray(t) ? t.slice() : t;
1316
+ },
1317
+ validate() {
1318
+ if (z(), F && F.revision === j) return F.diagnostics.map(Ce);
1319
+ let e = Ee();
1320
+ return F = {
1321
+ revision: j,
1322
+ diagnostics: e
1323
+ }, e.map(Ce);
1324
+ },
1325
+ text(e) {
1326
+ return z(), l(e, M, c() ?? o());
1327
+ },
1328
+ reset(e) {
1329
+ z();
1330
+ let t = C(), n = t.nodeIndex.get(e.id);
1331
+ if (!n) return;
1332
+ let i = ke(n), o = { ...A };
1333
+ for (let [e, n] of Object.entries(t.document.bindings)) {
1334
+ if (!(t.controls.get(e) ?? []).some((e) => i.has(e.id))) continue;
1335
+ let s = d(n.initial);
1336
+ if (s) throw new a("expression-budget", `Parameter "${e}": ${r(s)}`, 0);
1337
+ o[e] = B(n.initial);
1338
+ }
1339
+ for (let e of i) R.set(e, (R.get(e) ?? 0) + 1);
1340
+ Y(o);
1341
+ },
1342
+ resetToken(e) {
1343
+ z();
1344
+ let t = C().nodeIndex.get(e.id);
1345
+ return t ? R.get(t.id) ?? 0 : 0;
1346
+ },
1347
+ subscribe(e) {
1348
+ return z(), I.add(e), () => {
1349
+ I.delete(e);
1350
+ };
1351
+ },
1352
+ dispose() {
1353
+ if (!P) {
1354
+ P = !0, p.dispose();
1355
+ for (let e of O.values()) e();
1356
+ O.clear(), m.clear(), E.state.flush(), f && E.scheduler.dispose(), I.clear(), g.clear(), y.clear(), S.computationExpressions.clear(), S.constErrors.clear(), S.cycleErrors.clear(), S.validationRules.length = 0, R.clear();
1357
+ }
1358
+ }
1359
+ };
1360
+ return Z.set(Ae, {
1361
+ update: Oe,
1362
+ restore: (e) => Q(e, !0),
1363
+ bindNetworkExternals: ye,
1364
+ notify() {
1365
+ if (!P) for (let e of I) e();
1366
+ }
1367
+ }), me(G(C(), A)), he(), ye(p), Ae;
1368
+ }
1369
+ export { Te as a, Q as i, Oe as n, ye as o, Ee as r, _e as s, De as t };