semiotic 3.10.1 → 3.10.3

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 (353) hide show
  1. package/README.md +64 -63
  2. package/ai/artifact-surface-inventory.json +4 -1
  3. package/ai/behaviorContracts.cjs +1 -1
  4. package/ai/dist/mcp-server.js +25 -24
  5. package/ai/examples.md +28 -0
  6. package/ai/reference.md +9 -4
  7. package/ai/schema.json +121 -5
  8. package/ai/surface-manifest.json +3 -2
  9. package/ai/system-prompt.md +1 -1
  10. package/ai/task-packets/compare-category-totals.json +7 -53
  11. package/ai/task-packets/compare-category-totals.md +4 -4
  12. package/ai/task-packets/correct-published-chart.json +7 -53
  13. package/ai/task-packets/correct-published-chart.md +4 -4
  14. package/ai/task-packets/index.json +9 -9
  15. package/ai/task-packets/update-live-chart.json +8 -54
  16. package/ai/task-packets/update-live-chart.md +4 -4
  17. package/dist/c-27DCB5T6.min.js +18 -0
  18. package/dist/c-2MONF2P6.min.js +1 -0
  19. package/dist/c-3AGX252H.min.js +1 -0
  20. package/dist/c-3B6JZEZT.min.js +1 -0
  21. package/dist/c-3BYZXCX3.min.js +4 -0
  22. package/dist/c-3DIPZJDO.min.js +1 -0
  23. package/dist/c-3FOUMWLR.min.js +1 -0
  24. package/dist/c-3NA6I656.min.js +2 -0
  25. package/dist/c-3OFVBWQY.min.js +1 -0
  26. package/dist/{c-QA3HMQJP.min.js → c-3PFVJFBK.min.js} +1 -1
  27. package/dist/c-3PPO7ZJF.min.js +4 -0
  28. package/dist/c-3YEW2PK6.min.js +1 -0
  29. package/dist/c-43XNOQNQ.min.js +391 -0
  30. package/dist/c-4JKDJUYD.min.js +1 -0
  31. package/dist/c-4LKK5YWB.min.js +1 -0
  32. package/dist/c-4V3CD337.min.js +1 -0
  33. package/dist/c-4XLHPQTP.min.js +1 -0
  34. package/dist/c-5NYONM6V.min.js +5 -0
  35. package/dist/c-5PIKBUMF.min.js +1 -0
  36. package/dist/c-6IVBV5NO.min.js +1 -0
  37. package/dist/c-7APWCEPL.min.js +1 -0
  38. package/dist/{c-ORLEBW72.min.js → c-7FKPPCGN.min.js} +1 -1
  39. package/dist/c-ABMGCCLT.min.js +1 -0
  40. package/dist/c-AINGQGUN.min.js +1 -0
  41. package/dist/c-AXJ2QI3F.min.js +1 -0
  42. package/dist/c-BQYD7T4E.min.js +1 -0
  43. package/dist/{c-V4XMSLC3.min.js → c-BYJJ7EMG.min.js} +1 -1
  44. package/dist/c-C4SXYFXL.min.js +1 -0
  45. package/dist/c-CLDCKFBE.min.js +1 -0
  46. package/dist/c-CLJCJSFU.min.js +1 -0
  47. package/dist/c-CLLCX3PT.min.js +2 -0
  48. package/dist/c-CO4NDAD6.min.js +51 -0
  49. package/dist/c-ECHBKW7U.min.js +1 -0
  50. package/dist/c-EPJWM2UT.min.js +1 -0
  51. package/dist/c-FD2BXSRG.min.js +1 -0
  52. package/dist/c-FHNY57SO.min.js +209 -0
  53. package/dist/c-FMCUQ6JX.min.js +1 -0
  54. package/dist/c-FOTTQHOO.min.js +1 -0
  55. package/dist/c-FU7A5KSY.min.js +1 -0
  56. package/dist/c-GHN6IR4Y.min.js +1 -0
  57. package/dist/{c-J6DVC236.min.js → c-GK263BF4.min.js} +1 -1
  58. package/dist/c-GSCO3FWL.min.js +1 -0
  59. package/dist/c-GYLOSK7M.min.js +1 -0
  60. package/dist/c-HK4OSLZA.min.js +1 -0
  61. package/dist/c-HLGTD5SJ.min.js +1 -0
  62. package/dist/c-HNHKIMIV.min.js +61 -0
  63. package/dist/{c-D6HAAPTX.min.js → c-IBRLFKWA.min.js} +1 -1
  64. package/dist/c-IIV73MUW.min.js +1 -0
  65. package/dist/c-IJCZGUG6.min.js +31 -0
  66. package/dist/c-ISA6IJ6V.min.js +41 -0
  67. package/dist/c-JC76YAHB.min.js +33 -0
  68. package/dist/c-JJKRER47.min.js +1 -0
  69. package/dist/c-JO6AYCU4.min.js +1 -0
  70. package/dist/c-JOPGDP6N.min.js +1 -0
  71. package/dist/c-JWHPG6S2.min.js +1 -0
  72. package/dist/c-JXVYIXTV.min.js +1 -0
  73. package/dist/c-K2ZIYDI3.min.js +1 -0
  74. package/dist/c-K37JAIWA.min.js +4 -0
  75. package/dist/c-KXH7LFIL.min.js +26 -0
  76. package/dist/c-M43PK7K4.min.js +1 -0
  77. package/dist/c-MTX2AO5S.min.js +1 -0
  78. package/dist/c-N5WT7TXG.min.js +1 -0
  79. package/dist/c-NATWERHZ.min.js +1 -0
  80. package/dist/{c-42PLDTX7.min.js → c-O53GOO7H.min.js} +1 -1
  81. package/dist/c-OVQB75PE.min.js +1 -0
  82. package/dist/c-P3SKRNZN.min.js +1 -0
  83. package/dist/c-P5NXQWIM.min.js +1 -0
  84. package/dist/c-P7BQMVQQ.min.js +1 -0
  85. package/dist/{c-GNTXRXRN.min.js → c-PDQHLOKU.min.js} +1 -1
  86. package/dist/c-PITYSOPK.min.js +1 -0
  87. package/dist/c-QPO24R7Q.min.js +1 -0
  88. package/dist/c-QXLDCATV.min.js +1 -0
  89. package/dist/c-R2HUSWKB.min.js +1 -0
  90. package/dist/{c-HYW2XA4Q.min.js → c-RHDOOQ4X.min.js} +1 -1
  91. package/dist/c-RZPP5ERV.min.js +1 -0
  92. package/dist/c-SAP5KY6R.min.js +9 -0
  93. package/dist/{c-WUWXGQYA.min.js → c-SJIB5RNI.min.js} +1 -1
  94. package/dist/c-SQNEVNWT.min.js +1 -0
  95. package/dist/c-STHZWF3D.min.js +1 -0
  96. package/dist/c-TIDKVMMZ.min.js +1 -0
  97. package/dist/c-TIMGODBG.min.js +1 -0
  98. package/dist/c-TR7OHUAO.min.js +2 -0
  99. package/dist/c-TVKZC4BY.min.js +1 -0
  100. package/dist/c-U5XVLSHN.min.js +1 -0
  101. package/dist/c-U6NLVFN4.min.js +1 -0
  102. package/dist/{c-VJTDST2R.min.js → c-UBHICVSC.min.js} +1 -1
  103. package/dist/c-UMGHCBH5.min.js +114 -0
  104. package/dist/c-UOPPO26M.min.js +1 -0
  105. package/dist/c-UUDAON4Z.min.js +1 -0
  106. package/dist/c-V32TPPY2.min.js +1 -0
  107. package/dist/c-V5KFJWQQ.min.js +1 -0
  108. package/dist/c-VEMCBQZZ.min.js +100 -0
  109. package/dist/{c-P65V6HLO.min.js → c-VN557BQE.min.js} +1 -1
  110. package/dist/c-WD2RL76M.min.js +116 -0
  111. package/dist/c-Y342FJ6K.min.js +1 -0
  112. package/dist/c-YL7HJL5J.min.js +1 -0
  113. package/dist/c-YM6CT4LJ.min.js +1 -0
  114. package/dist/{c-MVR3RWF3.min.js → c-YMFUIO54.min.js} +1 -1
  115. package/dist/c-YQVOKPKR.min.js +1 -0
  116. package/dist/c-YRJ3BJQZ.min.js +1 -0
  117. package/dist/c-YT5KPVNP.min.js +1 -0
  118. package/dist/c-Z6GRGS53.min.js +1 -0
  119. package/dist/c-ZVOFLE2P.min.js +46 -0
  120. package/dist/components/CategoryColors.d.ts +7 -0
  121. package/dist/components/LinkedCharts.d.ts +2 -1
  122. package/dist/components/ai/audienceProfile.d.ts +18 -1
  123. package/dist/components/ai/describeChart.d.ts +5 -1
  124. package/dist/components/ai/intentManifest.d.ts +16 -0
  125. package/dist/components/ai/intentRegistry.d.ts +12 -0
  126. package/dist/components/ai/intents.d.ts +6 -6
  127. package/dist/components/ai/streamSchema.d.ts +19 -0
  128. package/dist/components/ai/streamingTypes.d.ts +57 -11
  129. package/dist/components/ai/suggestCharts.d.ts +1 -1
  130. package/dist/components/ai/suggestStreamCharts.d.ts +43 -8
  131. package/dist/components/ai/suggestStreamDashboard.d.ts +35 -0
  132. package/dist/components/ai/variantDiscovery.d.ts +1 -1
  133. package/dist/components/charts/ordinal/BarChart.streamCapability.d.ts +2 -0
  134. package/dist/components/charts/ordinal/DonutChart.streamCapability.d.ts +2 -0
  135. package/dist/components/charts/ordinal/GroupedBarChart.streamCapability.d.ts +2 -0
  136. package/dist/components/charts/ordinal/PieChart.streamCapability.d.ts +2 -0
  137. package/dist/components/charts/ordinal/StackedBarChart.streamCapability.d.ts +2 -0
  138. package/dist/components/charts/realtime/RealtimeAccumulator.d.ts +14 -0
  139. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +6 -5
  140. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -1
  141. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +2 -161
  142. package/dist/components/charts/realtime/RealtimeLineChart.types.d.ts +175 -0
  143. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +6 -5
  144. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +6 -5
  145. package/dist/components/charts/realtime/aggregate.d.ts +11 -1
  146. package/dist/components/charts/realtime/resolveWindowSize.d.ts +1 -1
  147. package/dist/components/charts/shared/DirectLabelLayer.d.ts +25 -0
  148. package/dist/components/charts/shared/directLabels.d.ts +12 -0
  149. package/dist/components/charts/shared/knownChartComponents.d.ts +4 -1
  150. package/dist/components/charts/shared/lineSeriesSsr.d.ts +0 -12
  151. package/dist/components/charts/shared/useChartSetup.d.ts +3 -1
  152. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +1 -1
  153. package/dist/components/charts/value/BigNumber.streamCapability.d.ts +2 -0
  154. package/dist/components/charts/value/GaugeChart.streamCapability.d.ts +2 -0
  155. package/dist/components/charts/xy/BubbleChart.d.ts +4 -1
  156. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +4 -1
  157. package/dist/components/charts/xy/LineChart.d.ts +4 -1
  158. package/dist/components/charts/xy/Scatterplot.d.ts +7 -0
  159. package/dist/components/data/transforms.d.ts +1 -0
  160. package/dist/components/realtime/HyperLogLog.d.ts +19 -0
  161. package/dist/components/realtime/ReorderBuffer.d.ts +2 -2
  162. package/dist/components/realtime/TDigest.d.ts +22 -0
  163. package/dist/components/realtime/WindowAccumulator.d.ts +22 -5
  164. package/dist/components/realtime/applyChangelog.d.ts +38 -0
  165. package/dist/components/realtime/minHeap.d.ts +3 -0
  166. package/dist/components/recipes/atlas/flowCircuitChartProps.d.ts +1 -1
  167. package/dist/components/recipes/layout1d.d.ts +2 -20
  168. package/dist/components/recipes/minGapPlacement.d.ts +20 -0
  169. package/dist/components/semiotic-ai-core.d.ts +8 -3
  170. package/dist/components/semiotic-ai-stream.d.ts +10 -0
  171. package/dist/components/semiotic-ai.d.ts +4 -6
  172. package/dist/components/semiotic-realtime-core.d.ts +6 -2
  173. package/dist/components/semiotic-stream-types.d.ts +14 -0
  174. package/dist/components/semiotic-xy.d.ts +1 -0
  175. package/dist/components/semiotic.d.ts +3 -11
  176. package/dist/components/server/encodeSvgFramesToGif.d.ts +2 -0
  177. package/dist/components/server/rasterizeSVG.d.ts +2 -0
  178. package/dist/components/server/registerServerXYPlugins.d.ts +2 -0
  179. package/dist/components/server/renderEvidence.d.ts +4 -0
  180. package/dist/components/server/serverChartConfigs.d.ts +5 -0
  181. package/dist/components/server/serverChartConfigsRealtime.d.ts +6 -0
  182. package/dist/components/server/serverRealtimeCategoryColors.d.ts +3 -0
  183. package/dist/components/server/staticAnnotations.d.ts +9 -0
  184. package/dist/components/stream/SceneGraph.d.ts +3 -3
  185. package/dist/components/stream/StalenessBadge.d.ts +5 -2
  186. package/dist/components/stream/pipelinePathJoin.d.ts +27 -0
  187. package/dist/components/stream/pipelineTransitionTypes.d.ts +43 -0
  188. package/dist/components/stream/pipelineTransitions.d.ts +5 -35
  189. package/dist/components/stream/seriesGeometry.d.ts +2 -1
  190. package/dist/components/stream/streamEncodingTypes.d.ts +9 -0
  191. package/dist/components/stream/types.d.ts +25 -2
  192. package/dist/components/text/axisLabelAssessment.d.ts +15 -0
  193. package/dist/components/text/browserAxisLabelAssessment.d.ts +1 -0
  194. package/dist/components/text/browserLabelMeasurement.d.ts +3 -0
  195. package/dist/components/text/labelMeasurement.d.ts +19 -0
  196. package/dist/components/text/labelPlacement.d.ts +71 -0
  197. package/dist/components/text/useAxisLabelAssessment.d.ts +6 -0
  198. package/dist/components/text/useLabelMeasurer.d.ts +3 -0
  199. package/dist/controls.module.min.js +71 -1
  200. package/dist/geo.min.js +231 -1
  201. package/dist/geo.module.min.js +31 -1
  202. package/dist/network.module.min.js +1 -1
  203. package/dist/ordinal.module.min.js +1 -1
  204. package/dist/physics-matter.module.min.js +1 -1
  205. package/dist/physics-rapier.module.min.js +1 -1
  206. package/dist/physics.module.min.js +1 -1
  207. package/dist/physicsWorker.js +1 -1
  208. package/dist/rough.min.js +2 -1
  209. package/dist/rough.module.min.js +2 -1
  210. package/dist/semiotic-access.module.min.js +1 -1
  211. package/dist/semiotic-ai-artifact-policy-constants.module.min.js +1 -1
  212. package/dist/semiotic-ai-core.d.ts +8 -3
  213. package/dist/semiotic-ai-core.min.js +4 -1
  214. package/dist/semiotic-ai-core.module.min.js +4 -1
  215. package/dist/semiotic-ai-hash-primitives.module.min.js +1 -1
  216. package/dist/semiotic-ai.d.ts +4 -6
  217. package/dist/semiotic-ai.module.min.js +14 -1
  218. package/dist/semiotic-artifact-react.min.js +269 -1
  219. package/dist/semiotic-artifact-react.module.min.js +137 -1
  220. package/dist/semiotic-artifact.min.js +3 -1
  221. package/dist/semiotic-artifact.module.min.js +3 -1
  222. package/dist/semiotic-atlas-core.min.js +2 -1
  223. package/dist/semiotic-atlas-core.module.min.js +1 -1
  224. package/dist/semiotic-atlas-selection.module.min.js +1 -1
  225. package/dist/semiotic-atlas.module.min.js +11 -1
  226. package/dist/semiotic-client-cjs-shared.min.js +1530 -1
  227. package/dist/semiotic-client-glyph.module.min.js +3 -1
  228. package/dist/semiotic-client-responsive.module.min.js +1 -1
  229. package/dist/semiotic-client-shared.module.min.js +1 -1
  230. package/dist/semiotic-custom-layout-selection-cjs-shared.min.js +2 -1
  231. package/dist/semiotic-data.min.js +1 -1
  232. package/dist/semiotic-data.module.min.js +1 -1
  233. package/dist/semiotic-evidence.min.js +3 -1
  234. package/dist/semiotic-evidence.module.min.js +3 -1
  235. package/dist/semiotic-experimental-auxiliary.module.min.js +8 -1
  236. package/dist/semiotic-experimental-node-auxiliary.module.min.js +8 -1
  237. package/dist/semiotic-experimental-react-shared.module.min.js +1 -1
  238. package/dist/semiotic-experimental-vacp.min.js +1 -1
  239. package/dist/semiotic-experimental-vacp.module.min.js +1 -1
  240. package/dist/semiotic-line.module.min.js +1 -1
  241. package/dist/semiotic-realtime-core.d.ts +6 -2
  242. package/dist/semiotic-realtime-core.module.min.js +1 -1
  243. package/dist/semiotic-realtime-react.module.min.js +1 -1
  244. package/dist/semiotic-recipes-core-cjs-base.min.js +160 -1
  245. package/dist/semiotic-recipes-core.module.min.js +72 -1
  246. package/dist/semiotic-recipes-geo-cjs.min.js +1 -1
  247. package/dist/semiotic-recipes-react.min.js +3 -1
  248. package/dist/semiotic-server-edge-node.module.min.js +391 -1
  249. package/dist/semiotic-server-edge.min.js +651 -1
  250. package/dist/semiotic-server-edge.module.min.js +372 -1
  251. package/dist/semiotic-server-node.min.js +651 -1
  252. package/dist/semiotic-server-node.module.min.js +1 -1
  253. package/dist/semiotic-text.min.js +1 -1
  254. package/dist/semiotic-text.module.min.js +1 -1
  255. package/dist/semiotic-themes-core.min.js +1 -1
  256. package/dist/semiotic-themes-core.module.min.js +1 -1
  257. package/dist/semiotic-themes.min.js +1 -1
  258. package/dist/semiotic-themes.module.min.js +1 -1
  259. package/dist/semiotic-utils-core.min.js +11 -1
  260. package/dist/semiotic-utils-core.module.min.js +8 -1
  261. package/dist/semiotic-value.module.min.js +15 -1
  262. package/dist/semiotic-xy.d.ts +1 -0
  263. package/dist/semiotic.d.ts +3 -11
  264. package/dist/semiotic.module.min.js +10 -1
  265. package/dist/server.min.js +651 -1
  266. package/dist/server.module.min.js +1 -1
  267. package/dist/xy.module.min.js +1 -1
  268. package/package.json +8 -7
  269. package/dist/c-2N7IU2NY.min.js +0 -1
  270. package/dist/c-2RL2QPZJ.min.js +0 -1
  271. package/dist/c-2WK7YJLL.min.js +0 -1
  272. package/dist/c-45CQWZZ6.min.js +0 -1
  273. package/dist/c-4BRHKVKV.min.js +0 -1
  274. package/dist/c-7242NXSG.min.js +0 -1
  275. package/dist/c-7DVPSB5C.min.js +0 -1
  276. package/dist/c-7EGHJU2F.min.js +0 -1
  277. package/dist/c-A7OGOFSL.min.js +0 -1
  278. package/dist/c-AFBSWT77.min.js +0 -1
  279. package/dist/c-AH5HWZWS.min.js +0 -1
  280. package/dist/c-AJ7EC32V.min.js +0 -1
  281. package/dist/c-AQADQNY7.min.js +0 -1
  282. package/dist/c-ATM475SA.min.js +0 -1
  283. package/dist/c-AVO3Q7T7.min.js +0 -1
  284. package/dist/c-B7GW7IHJ.min.js +0 -1
  285. package/dist/c-BNFJMDHN.min.js +0 -1
  286. package/dist/c-BOHCQILI.min.js +0 -1
  287. package/dist/c-C3TZLTZK.min.js +0 -1
  288. package/dist/c-CGQAQWBV.min.js +0 -1
  289. package/dist/c-CPV4N35K.min.js +0 -1
  290. package/dist/c-DIPEYUOW.min.js +0 -1
  291. package/dist/c-E4JDJH4I.min.js +0 -1
  292. package/dist/c-E72OTUZU.min.js +0 -1
  293. package/dist/c-E7I2L7CU.min.js +0 -1
  294. package/dist/c-ELDWAO2V.min.js +0 -1
  295. package/dist/c-EUBTECGM.min.js +0 -1
  296. package/dist/c-EUMPMDCS.min.js +0 -1
  297. package/dist/c-EZZT2WAE.min.js +0 -1
  298. package/dist/c-FHBVFCQB.min.js +0 -1
  299. package/dist/c-G4HCO2IQ.min.js +0 -1
  300. package/dist/c-G5VIJEOK.min.js +0 -1
  301. package/dist/c-GHVOXAYH.min.js +0 -1
  302. package/dist/c-GXV3C3MO.min.js +0 -1
  303. package/dist/c-HHTK2R75.min.js +0 -1
  304. package/dist/c-HLLFJYTY.min.js +0 -1
  305. package/dist/c-HP4ZFM47.min.js +0 -1
  306. package/dist/c-HPOYKCCG.min.js +0 -1
  307. package/dist/c-HYDTS5OP.min.js +0 -1
  308. package/dist/c-I4QJ6YLM.min.js +0 -1
  309. package/dist/c-IK33LNZ6.min.js +0 -1
  310. package/dist/c-IK3PZHRY.min.js +0 -1
  311. package/dist/c-JIMJF6F6.min.js +0 -1
  312. package/dist/c-JUKIWTBJ.min.js +0 -1
  313. package/dist/c-KKPMHAZC.min.js +0 -1
  314. package/dist/c-L6WNDBHV.min.js +0 -1
  315. package/dist/c-LDEX5OFW.min.js +0 -1
  316. package/dist/c-LESEUVC5.min.js +0 -1
  317. package/dist/c-LYQMZMZQ.min.js +0 -1
  318. package/dist/c-MB6CV5NC.min.js +0 -1
  319. package/dist/c-MOKJOIPE.min.js +0 -1
  320. package/dist/c-N3FXLRNT.min.js +0 -1
  321. package/dist/c-N5NPTJVJ.min.js +0 -1
  322. package/dist/c-NHBL4J67.min.js +0 -1
  323. package/dist/c-ODG6TFSY.min.js +0 -1
  324. package/dist/c-PRIKOLTE.min.js +0 -1
  325. package/dist/c-PSKKFZNP.min.js +0 -1
  326. package/dist/c-PSNI6KAZ.min.js +0 -1
  327. package/dist/c-QAVFOEUY.min.js +0 -1
  328. package/dist/c-R2P4RR7Q.min.js +0 -1
  329. package/dist/c-RFC7UAG7.min.js +0 -1
  330. package/dist/c-S3AZX5PP.min.js +0 -1
  331. package/dist/c-SGAURYHG.min.js +0 -1
  332. package/dist/c-SJMWU6UX.min.js +0 -1
  333. package/dist/c-STIIGQOD.min.js +0 -1
  334. package/dist/c-T2ASIJVZ.min.js +0 -1
  335. package/dist/c-T2V7O2LO.min.js +0 -1
  336. package/dist/c-TKG2NP7G.min.js +0 -1
  337. package/dist/c-TX3THUTO.min.js +0 -1
  338. package/dist/c-TX7XJM3Z.min.js +0 -1
  339. package/dist/c-UC7SIU2W.min.js +0 -1
  340. package/dist/c-UMXSJIOV.min.js +0 -1
  341. package/dist/c-VRSXMLYF.min.js +0 -1
  342. package/dist/c-VSLWSAN2.min.js +0 -1
  343. package/dist/c-VXLOLYTO.min.js +0 -1
  344. package/dist/c-W4ZUKSEQ.min.js +0 -1
  345. package/dist/c-WCBRPILW.min.js +0 -1
  346. package/dist/c-WGHT7OCY.min.js +0 -1
  347. package/dist/c-WWCW3APR.min.js +0 -1
  348. package/dist/c-XSB27XPS.min.js +0 -1
  349. package/dist/c-Y6PYUMFU.min.js +0 -1
  350. package/dist/c-YDECTEUW.min.js +0 -1
  351. package/dist/c-YF3YKVQI.min.js +0 -1
  352. package/dist/c-YLZIV3VS.min.js +0 -1
  353. package/dist/c-ZIVPFTOC.min.js +0 -1
@@ -1 +1 @@
1
- function e(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function t(e){const t=e.fixedPosition;Number.isFinite(t?.x)&&(e.x=e.prevX=t.x,e.vx=0),Number.isFinite(t?.y)&&(e.y=e.prevY=t.y,e.vy=0)}function s(e){if(!e)return;const t=Number.isFinite(e.x)?e.x:void 0,s=Number.isFinite(e.y)?e.y:void 0;return null==t&&null==s?void 0:{x:t,y:s}}function i(e,t,s){const i="x"===s?"y":"x",n=Math.abs(t[s]-e[s]),o=t[i]-e[i],r=(e,t)=>"circle"===e.shape.type?e.shape.radius:("x"===t?e.shape.width:e.shape.height)/2;let a;if("circle"===e.shape.type&&"circle"===t.shape.type){const s=e.shape.radius+t.shape.radius;a=Math.sqrt(Math.max(0,s*s-n*n))}else if("aabb"===e.shape.type&&"aabb"===t.shape.type)a=r(e,i)+r(t,i);else{const o="circle"===e.shape.type?e:t,d="aabb"===e.shape.type?e:t,h=r(o,s),c=Math.max(0,n-r(d,s));a=r(d,i)+Math.sqrt(Math.max(0,h*h-c*c))}const d=o<0?-1:1;return{nx:"x"===i?d:0,ny:"y"===i?d:0,penetration:Math.max(0,a-Math.abs(o))}}function n(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function o(e){return"aabb"===e.type?{type:"aabb",x:e.x,y:e.y,width:e.width,height:e.height}:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:e.thickness}}function r(e){return{id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,bodyCollisions:e.bodyCollisions,...e.fixedPosition?{fixedPosition:s(e.fixedPosition)}:{},shape:n(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function a(e){return e&&"function"!=typeof e?{property:e.property,equals:e.equals,notEquals:e.notEquals,oneOf:e.oneOf?.slice(),notOneOf:e.notOneOf?.slice()}:e}function d(e){return{id:e.id,shape:o(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:a(e.bodyFilter),index:e.index}}var h={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},c=1e-9,l=.005;function u(e,t,s){return Math.max(t,Math.min(s,e))}function p(e,t,s){return Math.min(e??s,t??s)}function v(e,t,s){return u(Math.max(e??s,t??s),0,1)}function y(e){return e<0?-1:1}function f(e){if("circle"===e.shape.type){const t=e.shape.radius;return{minX:e.x-t,minY:e.y-t,maxX:e.x+t,maxY:e.y+t}}const t=e.shape.width/2,s=e.shape.height/2;return{minX:e.x-t,minY:e.y-s,maxX:e.x+t,maxY:e.y+s}}function m(e){const t=e.shape;if("aabb"===t.type){const e=t.width/2,s=t.height/2;return{minX:t.x-e,minY:t.y-s,maxX:t.x+e,maxY:t.y+s}}const s=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-s,minY:Math.min(t.y1,t.y2)-s,maxX:Math.max(t.x1,t.x2)+s,maxY:Math.max(t.y1,t.y2)+s}}function x(e,t){return e.minX<=t.maxX&&e.maxX>=t.minX&&e.minY<=t.maxY&&e.maxY>=t.minY}function b(e,t,s,i,n,o,r,a){const d=n-e,h=(s+r)/2-Math.abs(d);if(h<=0)return null;const c=o-t,l=(i+a)/2-Math.abs(c);return l<=0?null:h<l?{nx:y(d),ny:0,penetration:h}:{nx:0,ny:y(c),penetration:l}}function g(e,t,s,i,n,o,r){const a=o/2,d=r/2,h=e-u(e,i-a,i+a),l=t-u(t,n-d,n+d),p=h*h+l*l;if(p>s*s)return null;if(p<=c){const o=Math.abs(e-(i-a)),r=Math.abs(e-(i+a)),h=Math.abs(t-(n-d)),c=Math.abs(t-(n+d)),l=Math.min(o,r,h,c);return l===o?{nx:-1,ny:0,penetration:s+o}:l===r?{nx:1,ny:0,penetration:s+r}:l===h?{nx:0,ny:-1,penetration:s+h}:{nx:0,ny:1,penetration:s+c}}const v=Math.sqrt(p);return{nx:h/v,ny:l/v,penetration:s-v}}function S(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return function(e,t,s,i,n,o){const r=i-e,a=n-t,d=s+o,h=r*r+a*a;if(h>=d*d)return null;if(h<=c)return{nx:1,ny:0,penetration:d};const l=Math.sqrt(h);return{nx:r/l,ny:a/l,penetration:d-l}}(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.radius);if("aabb"===e.shape.type&&"aabb"===t.shape.type)return b(e.x,e.y,e.shape.width,e.shape.height,t.x,t.y,t.shape.width,t.shape.height);if("circle"===e.shape.type&&"aabb"===t.shape.type){const s=g(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height);return s?{nx:-s.nx,ny:-s.ny,penetration:s.penetration}:null}return"aabb"===e.shape.type&&"circle"===t.shape.type?g(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function w(e,t){const s=t.shape;if("aabb"===s.type)return"circle"===e.shape.type?g(e.x,e.y,e.shape.radius,s.x,s.y,s.width,s.height):b(s.x,s.y,s.width,s.height,e.x,e.y,e.shape.width,e.shape.height);const i="circle"===e.shape.type?e.shape.radius:Math.sqrt(e.shape.width*e.shape.width+e.shape.height*e.shape.height)/2;return function(e,t,s,i,n,o,r,a=0){const d=o-i,h=r-n,l=d*d+h*h,p=l<=c?0:u(((e-i)*d+(t-n)*h)/l,0,1),v=s+a/2,y=e-(i+d*p),f=t-(n+h*p),m=y*y+f*f;if(m>=v*v)return null;if(m<=c){const e=Math.sqrt(l);return e<=c?{nx:1,ny:0,penetration:v}:{nx:-h/e,ny:d/e,penetration:v}}const x=Math.sqrt(m);return{nx:y/x,ny:f/x,penetration:v-x}}(e.x,e.y,i,s.x1,s.y1,s.x2,s.y2,s.thickness??0)}function I(e,t){return`${e}\0${t}`}function B(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function M(e,t){return Boolean(t?.some(t=>Object.is(e,t)))}function O(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const s=function(e,t){if(!t)return;let s=e;for(const e of t.split(".")){if(null==s||"object"!=typeof s)return;if(!Object.prototype.hasOwnProperty.call(s,e))return;s=s[e]}return s}(e,t.property);return!("equals"in t&&!Object.is(s,t.equals))&&((!("notEquals"in t)||!Object.is(s,t.notEquals))&&(!(t.oneOf&&!M(s,t.oneOf))&&(!t.notOneOf||!M(s,t.notOneOf))))}function q(e,t){return O(t,e.bodyFilter)}var k=class{constructor(t={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...h,...t},this.random=e(this.options.seed)}init(t={}){this.options={...h,...t},this.random=e(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(e){const i={id:e.id,x:e.x,y:e.y,prevX:e.x,prevY:e.y,vx:e.vx??0,vy:e.vy??0,angle:e.angle??0,mass:Math.max(c,e.mass??1),bodyCollisions:e.bodyCollisions??!0,...e.fixedPosition?{fixedPosition:s(e.fixedPosition)}:{},shape:n(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};t(i),this.nextBodyIndex+=1,this.bodies.set(e.id,i)}remove(e){for(const t of e){this.bodies.delete(t);for(const e of Array.from(this.activeSensors))B(e).bodyId===t&&this.activeSensors.delete(e)}}setColliders(e){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const t of e)this.colliders.set(t.id,{...t,shape:o(t.shape),bodyFilter:a(t.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(e){const t=e.id??`spring-${this.nextSpringIndex}`;return this.springs.set(t,{id:t,bodyId:e.bodyId,target:e.target,restLength:e.restLength??0,stiffness:e.stiffness??40,damping:e.damping??3}),this.nextSpringIndex+=1,t}removeConstraint(e){this.springs.delete(e)}applyImpulse(e,s,i){const n=this.bodies.get(e);n&&(n.vx+=s/n.mass,n.vy+=i/n.mass,t(n),this.wake(n))}step(e=this.options.fixedDt){const s=Math.max(0,e);if(this.lastEvents=[],0===s)return;const i=this.sortedBodies();for(const e of i)e.prevX=e.x,e.prevY=e.y;this.applySprings(s);const n=this.options.maxVelocity;for(const e of i)if(!e.sleeping){if(e.vx+=this.options.gravity.x*s,e.vy+=this.options.gravity.y*s,e.vx*=this.options.velocityDamping,e.vy*=this.options.velocityDamping,t(e),n>0){const t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>n){const s=n/t;e.vx*=s,e.vy*=s}}e.x+=e.vx*s,e.y+=e.vy*s}this.supportedThisStep.clear();const o=this.bodyPairKeys(i),r=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;e<this.options.collisionIterations;e+=1)this.resolveBodyPairs(i,o,0===e),this.resolveColliders(i,r,0===e);this.updateSensors(i),this.updateSleeping(i,s)}settle(e=1200,t=this.options.fixedDt){let s=0;for(;s<e&&!this.allSleeping();)this.step(t),s+=1;return s}readState(e=[]){e.length=0;for(const t of this.sortedBodies())e.push({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,...t.fixedPosition?{fixedPosition:s(t.fixedPosition)}:{},shape:n(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(B)}allSleeping(){for(const e of this.bodies.values())if(!e.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(r),colliders:this.sortedColliders().map(d),springs:Array.from(this.springs.values()).map(e=>({...e,target:{...e.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(s){this.options={...s.options,gravity:{...s.options.gravity}},this.random=e(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(s.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const e of s.bodies){const s=r(e);t(s),this.bodies.set(s.id,s),this.nextBodyIndex=Math.max(this.nextBodyIndex,s.index+1)}this.nextColliderIndex=0;for(const e of s.colliders){const t=d(e);this.colliders.set(t.id,t),this.nextColliderIndex=Math.max(this.nextColliderIndex,t.index+1)}this.nextSpringIndex=0;for(const e of s.springs){this.springs.set(e.id,{...e,target:{...e.target}});const t=/^spring-(\d+)$/.exec(e.id);t&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(t[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((e,t)=>e.index-t.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((e,t)=>e.index-t.index)}applySprings(e){for(const t of Array.from(this.springs.values()).sort((e,t)=>e.id.localeCompare(t.id))){const s=this.bodies.get(t.bodyId);if(!s||s.sleeping)continue;const i="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!i)continue;const n=i.x-s.x,o=i.y-s.y,r=n*n+o*o,a=Math.sqrt(r);if(a<=c)continue;const d=n/a,h=o/a,l="vx"in i?i.vx:0,u="vy"in i?i.vy:0,p=(l-s.vx)*d+(u-s.vy)*h,v=(a-t.restLength)*t.stiffness+p*t.damping;s.vx+=v*d*e/s.mass,s.vy+=v*h*e/s.mass}}resolveBodyPairs(e,t,s){for(const i of t){const[t,n]=i.split(":").map(Number),o=e[t],r=e[n];if(!o||!r)continue;const a=S(o,r);a&&(this.resolveDynamicCollision(o,r,a),s&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:r.id,sensor:!1}))}}bodyPairKeys(e){const t=Math.max(1,this.options.cellSize),s=new Map;for(let i=0;i<e.length;i+=1){if(!1===e[i].bodyCollisions)continue;const n=f(e[i]),o=Math.floor(n.minX/t),r=Math.floor(n.maxX/t),a=Math.floor(n.minY/t),d=Math.floor(n.maxY/t);for(let e=o;e<=r;e+=1)for(let t=a;t<=d;t+=1){const n=`${e}:${t}`,o=s.get(n);o?o.push(i):s.set(n,[i])}}const i=new Set;for(const t of Array.from(s.keys()).sort()){const n=s.get(t)??[];n.sort((e,t)=>e-t);for(let t=0;t<n.length;t+=1)for(let s=t+1;s<n.length;s+=1){const o=n[t],r=n[s];!1!==e[o].bodyCollisions&&!1!==e[r].bodyCollisions&&(x(f(e[o]),f(e[r]))&&i.add(`${o}:${r}`))}}return Array.from(i).sort((e,t)=>{const[s,i]=e.split(":").map(Number),[n,o]=t.split(":").map(Number);return s===n?i-o:s-n})}resolveDynamicCollision(e,t,s){(e.fixedPosition||t.fixedPosition)&&(!e.sleeping&&null==e.fixedPosition?.x||!t.sleeping&&null==t.fixedPosition?.x?!e.sleeping&&null==e.fixedPosition?.y||!t.sleeping&&null==t.fixedPosition?.y||(s=i(e,t,"y")):s=i(e,t,"x")),e.sleeping&&this.contactOpposesGravity(s.nx,s.ny)&&this.supportedThisStep.add(t.id),t.sleeping&&this.contactOpposesGravity(-s.nx,-s.ny)&&this.supportedThisStep.add(e.id);const n=e.sleeping?0:1/e.mass,o=t.sleeping?0:1/t.mass,r=null==e.fixedPosition?.x?n:0,a=null==e.fixedPosition?.y?n:0,d=null==t.fixedPosition?.x?o:0,h=null==t.fixedPosition?.y?o:0,u=e.fixedPosition||t.fixedPosition?s.nx**2*(r+d)+s.ny**2*(a+h):n+o;if(u<=c)return;const v=Math.max(0,s.penetration-l)/u;e.x-=s.nx*v*r,e.y-=s.ny*v*a,t.x+=s.nx*v*d,t.y+=s.ny*v*h;const y=t.vx-e.vx,f=t.vy-e.vy,m=y*s.nx+f*s.ny;if(m>0)return;const x=Math.abs(m),b=-(1+p(e.restitution,t.restitution,this.options.restitution))*m/u,g=b*s.nx,S=b*s.ny;e.vx-=g*r,e.vy-=S*a,t.vx+=g*d,t.vy+=S*h,this.applyFriction(e,t,s,b,n,o),x>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,s,i,n,o){const r=-s.ny,a=s.nx,d=(t.vx-e.vx)*r+(t.vy-e.vy)*a,h=null==e.fixedPosition?.x?n:0,l=null==e.fixedPosition?.y?n:0,p=null==t.fixedPosition?.x?o:0,y=null==t.fixedPosition?.y?o:0,f=e.fixedPosition||t.fixedPosition?r**2*(h+p)+a**2*(l+y):n+o;if(Math.abs(d)<=c||f<=c)return;const m=v(e.friction,t.friction,this.options.friction),x=u(-d/f,-i*m,i*m),b=x*r,g=x*a;e.vx-=b*h,e.vy-=g*l,t.vx+=b*p,t.vy+=g*y}resolveColliders(e,t,s){for(const i of e)for(const e of t){if(!q(e,i))continue;if(!x(f(i),m(e)))continue;const t=w(i,e);t&&(this.resolveStaticCollision(i,e,t),this.contactOpposesGravity(t.nx,t.ny)&&this.supportedThisStep.add(i.id),s&&this.lastEvents.push({type:"contact",bodyId:i.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,s,i){e.x+=i.nx*Math.max(0,i.penetration-l),e.y+=i.ny*Math.max(0,i.penetration-l);const n=e.vx*i.nx+e.vy*i.ny;if(n<0){const t=p(e.restitution,s.restitution,this.options.restitution);e.vx-=(1+t)*n*i.nx,e.vy-=(1+t)*n*i.ny;const o=-i.ny,r=i.nx,a=e.vx*o+e.vy*r,d=v(e.friction,s.friction,this.options.friction);e.vx-=a*o*d,e.vy-=a*r*d}t(e)}updateSensors(e){const t=new Set,s=this.sortedColliders().filter(e=>e.sensor);for(const i of e){const e=f(i);for(const n of s){if(!q(n,i))continue;if(!x(e,m(n)))continue;if(!w(i,n))continue;const s=I(n.id,i.id);t.add(s),this.activeSensors.has(s)||this.lastEvents.push({type:"sensor-enter",bodyId:i.id,sensorId:n.id})}}for(const e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;const{sensorId:s,bodyId:i}=B(e);this.lastEvents.push({type:"sensor-exit",bodyId:i,sensorId:s})}this.activeSensors=t}updateSleeping(e,t){const s=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const i of e){const e=Math.sqrt(i.vx*i.vx+i.vy*i.vy),n=Math.sqrt((i.x-i.prevX)*(i.x-i.prevX)+(i.y-i.prevY)*(i.y-i.prevY));!(e<this.options.sleepSpeed&&n<this.options.sleepSpeed*t)||s&&!this.supportedThisStep.has(i.id)?i.sleeping?this.wake(i):i.sleepTime=0:(i.sleepTime+=t,!i.sleeping&&i.sleepTime>=this.options.sleepAfter&&(i.sleeping=!0,i.vx=0,i.vy=0,this.lastEvents.push({type:"sleep",bodyId:i.id})))}}contactOpposesGravity(e,t){const{x:s,y:i}=this.options.gravity,n=Math.hypot(s,i);return n<=1e-9||(e*s+t*i)/n<-.2}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},P=class{constructor(e={}){this.id="builtin",this.capabilities={...(new k).capabilities,engine:"builtin"},this.world=new k(e)}init(e={}){this.world.init(e)}spawn(e){this.world.spawn(e)}remove(e){this.world.remove(e)}setColliders(e){this.world.setColliders(e)}setConstraint(e){return this.world.setConstraint(e)}removeConstraint(e){this.world.removeConstraint(e)}applyImpulse(e,t,s){this.world.applyImpulse(e,t,s)}step(e){this.world.step(e)}settle(e,t){return this.world.settle(e,t)}readState(e){return this.world.readState(e)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(e){this.world.restore(e)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function C(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new P(e)}(t)}var T=["binId","targetBin","category","windowIndex","lane","group"];function A(){return{count:0,total:0,mean:0,m2:0,min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY}}function D(e,t){if(!Number.isFinite(t))return;e.count+=1,e.total+=t,e.min=Math.min(e.min,t),e.max=Math.max(e.max,t);const s=t-e.mean;e.mean+=s/e.count;const i=t-e.mean;e.m2+=s*i}function R(e){return{count:e.count,total:e.total,mean:e.count>0?e.mean:0,min:e.count>0?e.min:0,max:e.count>0?e.max:0,variance:e.count>1?e.m2/(e.count-1):0}}function N(e){return{count:e.count,total:e.total,mean:e.mean,m2:e.variance*Math.max(0,e.count-1),min:e.count>0?e.min:Number.POSITIVE_INFINITY,max:e.count>0?e.max:Number.NEGATIVE_INFINITY}}function E(e,t){const s=e;if(null!=s[t])return s[t];const i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function F(e,t,s){return"function"==typeof e?e(t,s):"string"==typeof e?E(t,e):void 0}function Y(e){if(null==e)return;const t=String(e);return t.trim()?t:void 0}function X(e){const t=R(e.value);return{id:e.id,label:e.label,count:t.count,total:t.total,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:R(e.x),y:R(e.y),value:t}}var L=class{constructor(e=!1){this.bins=new Map,this.nextIndex=0,this.config=e}updateConfig(e){void 0!==e&&(this.config=e,!1===e&&this.clear())}isEnabled(){return!1!==this.config}add(e){if(!1===this.config)return null;const t=this.nextIndex;this.nextIndex+=1;const s=Y(F(this.config.binAccessor,e,t))??function(e){for(const t of T){const s=Y(E(e,t));if(s)return s}return"sediment"}(e),i=Y(F(this.config.labelAccessor,e,t))??s,n=function(e,t,s){if("number"==typeof e)return e;const i="function"==typeof e?e(t,s):"string"==typeof e?E(t,e):1,n="number"==typeof i?i:Number(i);return Number.isFinite(n)?n:1}(this.config.valueAccessor,e,t),o=Math.max(0,Math.floor(this.config.retainBodyIds??12));let r=this.bins.get(s);return r||(r={id:s,label:i,bodyIds:[],x:A(),y:A(),value:A()},this.bins.set(s,r)),r.label=i,r.lastBodyId=e.id,r.lastDatum=e.datum,D(r.x,e.x),D(r.y,e.y),D(r.value,n),o>0&&(r.bodyIds.push(e.id),r.bodyIds.length>o&&(r.bodyIds=r.bodyIds.slice(r.bodyIds.length-o))),X(r)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(X)}restore(e=[]){this.bins.clear();for(const t of e)this.bins.set(t.id,{id:t.id,label:t.label,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:N(t.x),y:N(t.y),value:N(t.value)});this.nextIndex=e.reduce((e,t)=>e+t.count,0)}totals(){const e=this.snapshot();return{bins:e.length,count:e.reduce((e,t)=>e+t.count,0),total:e.reduce((e,t)=>e+t.total,0)}}};function K(e){const t=Number(e);if(Number.isFinite(t)&&!(t<=0))return Math.floor(t)}function H(e){const t=Math.max(0,Math.floor(e.liveBodies)),s=Math.max(0,Math.floor(e.queuedBodies??0)),i=t+s,n=K(e.bodyLimit),o=K(e.engineMaxBodiesHint),r=function(e,t,s){if(!1===s)return;const i=K(s?.warnAt);return null!=i?i:null!=e?Math.max(1,Math.floor(.8*e)):null!=t?Math.max(1,Math.floor(.8*t)):void 0}(n,o,e.options),a=null==n?0:Math.max(0,t-n),d=a>0?"overflow":null!=r&&i>=r?"warning":"ok";return{action:"overflow"!==d?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:n,engineMaxBodiesHint:o,liveBodies:t,overflow:a,projectedBodies:i,queuedBodies:s,state:d,warnAt:r}}var W={bodyLimit:Number.POSITIVE_INFINITY,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},j={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function V(e={},t=j){return{chartId:e.chartId??t.chartId,chartType:e.chartType??t.chartType,sensors:e.sensors??t.sensors,onObservation:e.onObservation??t.onObservation,onSimulationStateChange:e.onSimulationStateChange??t.onSimulationStateChange}}function $(e){return{...e,shape:{...e.shape},...e.fixedPosition?{fixedPosition:{...e.fixedPosition}}:{},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function z(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:void 0}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function G(e,t){const s=e;if(null!=s[t])return s[t];const i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function _(e,t={}){const s=z(t.startAt)??0,i=t.pacing??"immediate";if("arrival"===i){const i=e.map((e,s)=>function(e,t,s){return"function"==typeof s?z(s(e,t)):"string"==typeof s?z(G(e,s)):z(e.spawnAt)??z(G(e,"arrivalTime"))??z(G(e,"timestamp"))??z(G(e,"time"))??z(G(e,"eventTime"))}(e,s,t.timeAccessor)),n=i.filter(e=>null!=e),o=n.length>0?Math.min(...n):0,r=z(t.timeScale)??1,a=r>0?r:1;return e.map((e,t)=>{const n=i[t],r=null==n?0:Math.max(0,n-o);return{...$(e),spawnAt:s+r/a}})}if("object"==typeof i){const t=z(i.ratePerSec);if(t&&t>0)return e.map((e,i)=>({...$(e),spawnAt:s+i/t}))}return e.map(e=>({...$(e),spawnAt:s}))}function U(e){return{...$(e),sequence:e.sequence,spawnAt:e.spawnAt}}function Q(e){return e.map(e=>({...e,shape:{...e.shape},bodyFilter:e.bodyFilter&&"function"!=typeof e.bodyFilter?{...e.bodyFilter,oneOf:e.bodyFilter.oneOf?.slice(),notOneOf:e.bodyFilter.notOneOf?.slice()}:e.bodyFilter}))}function J(e){return!1!==e&&{...e}}function Z(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function ee(e){return{...e,gravity:{...e.gravity}}}function te(e,t,s,i){if("circle"===e.shape.type){const n=e.x-t,o=e.y-s,r=e.shape.radius+i,a=n*n+o*o;return a<=r*r?a:null}const n=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),o=Math.max(Math.abs(s-e.y)-e.shape.height/2,0),r=n*n+o*o;return r<=i*i?r:null}function se(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}var ie={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function ne(e,t){const s={...e};for(const e of t){s[ie[e]]++}return s}function oe(e,t,s){const i=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:i,revisions:ne(s,i)}}var re=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=oe({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const s=oe(e,t,this.revisions);this.revisions=s.revisions,this.latest=s;for(const e of[...this.listeners])e();return s}};import{quadtree as ae}from"d3-quadtree";var de=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,s,i,n,o=0,r){const a=this.ensure(e,t);if(!a)return null;let d=null,h=Number.POSITIVE_INFINITY;const c=Math.max(0,r?.searchRadius??Math.max(0,o)+this.maxSearchRadius),l=i-c,u=i+c,p=n-c,v=n+c;return a.visit((e,t,a,c,y)=>{if(c<l||t>u||y<p||a>v)return!0;if(e.length)return!1;let f=e;for(;f;){const e=f.data;if(e&&(!r?.include||r.include(e))){const t=r?.distanceSquared?r.distanceSquared(e,i,n):te(e,i,n,Math.max(0,o));null!=t&&(t<h||t===h&&s.indexOf(e.id)>s.indexOf(d?.id??""))&&(d=e,h=t)}f=f.next}return!1}),d}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;const s=e.readState();return 0===s.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=s.reduce((e,t)=>Math.max(e,function(e){return"circle"===e.shape.type?e.shape.radius:Math.hypot(e.shape.width,e.shape.height)/2}(t)),0),this.tree=ae().x(e=>e.x).y(e=>e.y).addAll(s),this.revision=t,this.tree)}};var he=["data","scene-geometry","data-paint","accessibility","evidence"],ce=["scene-geometry","data-paint","accessibility","evidence"],le=["overlay","accessibility","evidence"],ue=(e,t)=>({retainedData:e,invalidations:t}),pe=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ve=["scene-geometry","data-paint","accessibility","evidence"],ye=[],fe={engine:ue("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:ue("preserve",ve),colliders:ue("preserve",ve),sediment:ue("preserve",ve),bodyBudget:ue("preserve",pe),bodyLimit:ue("preserve",pe),eviction:ue("preserve",pe),fixedDt:ue("preserve",ye),maxDeltaSeconds:ue("preserve",ye),maxSubsteps:ue("preserve",ye),settleStepLimit:ue("preserve",ye),timeScale:ue("preserve",ye),observation:ue("preserve",ye)},me=ue("preserve",pe);function xe(e){let t="preserve";const s=new Set;for(const i of e){const e=fe[i]??me;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)s.add(t)}return{retainedData:t,invalidations:s}}var be=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function ge(e,t){return e===t||!(!e||!t)&&(e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&be.every(s=>e[s]===t[s]))}function Se(e,t,s,i){return e||!t?"paused":s||!i?"running":"settled"}function we(e,t,s,i,n,o){const r={evicted:[],sedimented:[],liveBodyOrder:n};if(!1===s)return r;const a=Math.max(0,Math.floor(i));if(!Number.isFinite(a))return r;const d=n.length-a;if(d<=0)return r;const h=function(e,t,s){if("sleeping-first"!==t)return s.slice();const i=new Map(e.readState().map(e=>[e.id,e.sleeping])),n=[],o=[];for(const e of s)i.get(e)?n.push(e):o.push(e);return[...n,...o]}(e,s,n),c=h.slice(0,d);if(0===c.length)return r;const l=function(e,t,s,i){const n=new Map(e.readState().map(e=>[e.id,e])),o=[];for(const e of s){const s=n.get(e);if(!s)continue;const r=t.add(s);r&&(o.push(e),i.emit({type:"physics-sediment",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:e,datum:s.datum,x:s.x,y:s.y,binId:r.id,count:r.count,total:r.total}))}return o}(e,t,c,o);e.remove(c);const u=new Set(c);return{evicted:c,sedimented:l,liveBodyOrder:n.filter(e=>!u.has(e))}}var Ie=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(e){this.speed=function(e){const t=e?.sleepSpeed;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:8}(e)}reset(){this.seconds=0}isAtRest(){return this.seconds>=.6}refresh(e,t,s){if(s>0)return void(this.seconds=0);const i=e.readState(this.scratch),n=this.speed*this.speed;let o=!0;for(const e of i)if(!e.sleeping&&e.vx*e.vx+e.vy*e.vy>=n){o=!1;break}this.seconds=o?this.seconds+Math.max(0,t):0}};function Be(e,t,s,i={}){let n,o=0;for(;o<t&&!i.shouldStop?.()&&(!1===i.stopAtRest||e.queueSize()>0||!e.atRest()||i.continueWhile?.());){e.step(e.fixedDt),e.advanceTime(e.fixedDt);const t=e.drainEvents();s.events&&(s.events.push(...t),e.observeKernelEvents(t,s.observations),e.observeSensorTransitions(s.observations));const r=[];if(e.spawnDue(r,s.observations),r.length>0){s.spawned.push(...r),n=e.observeBodyBudget(s.observations);const t=e.evictOverflow(s.observations);s.evicted?.push(...t.evicted),s.sedimented?.push(...t.sedimented)}o+=1,e.refreshQuiescence(e.fixedDt,r.length),i.afterStep?.()}return{steps:o,budget:n}}var Me=class{constructor(e={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new de,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new re,this.simulationState="settled",this.visible=!0,this.quiescence=new Ie;const{bodyBudget:t,colliders:s,engine:i,kernel:n,observation:o,sediment:r,...a}=e;this.config={...W,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=i,this.observation=V(o),this.sediment=new L(r??!1),this.world=C(i,{fixedDt:this.config.fixedDt,...n}),this.quiescence.setKernelOptions(n),s&&this.world.setColliders(Q(s))}updateConfig(e){const t=function(e,t){return Object.keys(e).filter(s=>"kernel"===s?!ge(e.kernel,t.kernel):e[s]!==t[s])}(e,this.configInput),{colliders:s,bodyBudget:i,engine:n,kernel:o,observation:r,sediment:a,...d}=e;if(this.config={...this.config,...d},void 0!==i&&(this.bodyBudget=i,!1===i&&(this.bodyBudgetObservationKey="ok")),n&&n!==this.engineInput){const e=this.world.snapshot();this.world.dispose(),this.engineInput=n,this.world=C(n,e.options),this.world.restore(e),this.revision+=1}if(o&&!ge(o,this.configInput.kernel)){const e=this.world.snapshot(),t={...e.options,...o,gravity:{...e.options.gravity,...o.gravity}};this.world.restore({...e,options:t}),this.quiescence.setKernelOptions(t),this.revision+=1}r&&(this.observation=V(r,this.observation)),this.sediment.updateConfig(a),s&&(this.world.setColliders(Q(s)),this.revision+=1),this.configInput={...this.configInput,...e};const h=xe(t);this.updateResults.record({kind:"config",keys:t},h.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(Q(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},xe(["colliders"]).invalidations)}enqueue(e,t){const s=Array.isArray(e)?e:[e],i=t?_(s,{...t,startAt:t.startAt??this.elapsedSeconds}):s;for(const e of i)this.queue.push({...$(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(Z),i.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:i.length},i.length?he:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne($(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},he)}materializeDueSpawns(){const e=this.revision,t=[],s=[];return this.spawnDue(t,s),0===t.length||(this.observeBodyBudget(s),this.evictOverflow(s),this.syncSimulationState(s),this.revision+=1,this.updateResults.record({kind:"enqueue",count:t.length},this.revision!==e?he:[])),t}clear(){const e=this.world.snapshot().options;this.world.init({...e,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.quiescence.reset(),this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},he)}tick(e,t){const s=this.revision,i=[],n=[],o=[],r=[],a=[];if(this.paused||!this.visible){const e=this.result(0,i,n,o,r,a,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}const d=Math.max(0,Math.min(Number.isFinite(e)?e:0,this.config.maxDeltaSeconds))*this.config.timeScale;this.spawnDue(i,a);const h=this.observeBodyBudget(a),c=this.evictOverflow(a);n.push(...c.evicted),o.push(...c.sedimented),this.syncSimulationState(a),i.length>0&&this.quiescence.reset(),this.accumulator+=d;const l=this.stepObserver(t,{spawned:i,evicted:n,sedimented:o,events:r,observations:a}),u=d>0?Math.floor((this.accumulator+1e-9*this.config.fixedDt)/this.config.fixedDt):0,{steps:p,budget:v}=Be(this.settleHost(),Math.min(u,this.config.maxSubsteps),{spawned:i,evicted:n,sedimented:o,events:r,observations:a},{stopAtRest:!1,shouldStop:()=>this.paused||!this.visible,afterStep:l});this.accumulator=Math.max(0,this.accumulator-p*this.config.fixedDt),p===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(p>0||i.length>0||n.length>0||o.length>0||r.length>0)&&(this.revision+=1);const y=this.result(p,i,n,o,r,a,void 0,v??h);return this.updateResults.record({kind:"tick",count:p},this.revision!==s?i.length||n.length||o.length?he:ce:[]),y}settle(e=this.config.settleStepLimit){return this.runSettle(e,!1).steps}settleWithObservations(e=this.config.settleStepLimit,t){return this.runSettle(e,!0,t)}stepObserver(e,t){return function(e,t){if(!e)return;const s=["spawned","evicted","sedimented","events","observations"],i={spawned:0,evicted:0,sedimented:0,events:0,observations:0},n=n=>{const o=t(n),r={...o,spawned:o.spawned.slice(i.spawned),evicted:o.evicted.slice(i.evicted),sedimented:o.sedimented.slice(i.sedimented),events:o.events.slice(i.events),observations:o.observations.slice(i.observations)};for(const e of s)i[e]=o[e].length;e.onStep(r)};return n(0),()=>n(1)}(e,e=>(e&&(this.revision+=1),this.result(e,t.spawned,t.evicted,t.sedimented,t.events,t.observations)))}settleHost(){return{fixedDt:this.config.fixedDt,queueSize:()=>this.queue.length,atRest:()=>this.atRest(),advanceTime:e=>{this.elapsedSeconds+=e},spawnDue:(e,t)=>this.spawnDue(e,t),observeBodyBudget:e=>this.observeBodyBudget(e),evictOverflow:e=>this.evictOverflow(e),step:e=>this.world.step(e),drainEvents:()=>this.world.events(),observeKernelEvents:(e,t)=>this.observeKernelEvents(e,t),observeSensorTransitions:e=>this.observeSensorTransitions(e),refreshQuiescence:(e,t)=>this.quiescence.refresh(this.world,e,t)}}runSettle(e,t,s){const i=this.revision,n=[],o=[],r=[],a=[],d=t?[]:void 0;if(t&&(this.paused||!this.visible)){const e=this.result(0,n,o,r,a,d??[],!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(n,d);const h=this.observeBodyBudget(d),c=this.evictOverflow(d);o.push(...c.evicted),r.push(...c.sedimented),this.syncSimulationState(d),n.length>0&&this.quiescence.reset();const l=t?{spawned:n,evicted:o,sedimented:r,events:a,observations:d}:{spawned:n},u=this.stepObserver(s,{spawned:n,evicted:o,sedimented:r,events:a,observations:d??[]}),{steps:p,budget:v}=Be(this.settleHost(),e,l,{afterStep:u,continueWhile:s?.continueWhile,shouldStop:t?()=>this.paused||!this.visible:void 0}),y=n.length+o.length+r.length>0;(p>0||y||a.length>0)&&(this.revision+=1);const f=this.result(p,n,o,r,a,d??[],void 0,v??h);return this.updateResults.record({kind:"settle",count:p},this.revision===i?[]:y?he:ce),f}readBodies(e=[]){return this.world.readState(e)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(e={}){return function(e,t={}){const{baselineY:s=0,binWidth:i=24,gap:n=2,maxHeight:o=80,value:r="count",x:a}=t,d=Math.max(1,...e.map(e=>e[r]));return e.map((e,t)=>{const h=Math.max(0,e[r]/d*o),c=a?.(e,t)??t*(i+n);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:c,y:s-h,width:i,height:h,meanX:e.x.mean,meanY:e.y.mean}})}(this.readSediment(),e)}hitTest(e,t,s=0,i){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,s,i)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}atRest(){return this.world.allSleeping()||this.quiescence.isAtRest()}hasPendingWork(){return this.queue.length>0||!this.atRest()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(e){const{timestamp:t,chartType:s,chartId:i,...n}=e,o={...n,timestamp:t??this.elapsedSeconds,chartType:s??this.observation.chartType,chartId:i??this.observation.chartId};return this.emitObservation(o),this.updateResults.record({kind:"update",count:1},["evidence"]),o}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(e){return this.updateResults.subscribe(e)}version(){return this.revision}setPaused(e){const t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?le:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?le:[])}remove(e){const t=new Set(e),s=new Set(this.liveBodyOrder),i=new Set(this.queue.map(e=>e.id));this.queue=this.queue.filter(e=>!t.has(e.id)),this.liveBodyOrder=this.liveBodyOrder.filter(e=>!t.has(e)),this.world.remove(e),this.removeActiveSensorPairsForBodies(t);const n=e.filter(e=>s.has(e)||i.has(e));return n.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:n,count:n.length},n.length?he:[]),n}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},ce),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},ce)}applyImpulse(e,t,s){this.world.applyImpulse(e,t,s),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},ce)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,s,i)=>e.applyImpulse(t,s,i),clear:()=>e.clear(),hitTest:(t,s,i)=>e.hitTest(t,s,i),pause:()=>e.setPaused(!0),push:(t,s)=>e.enqueue(t,s),pushMany:(t,s)=>e.enqueue(t,s),bodyBudgetStatus:()=>e.bodyBudgetStatus(),readBodies:t=>e.readBodies(t),readSediment:()=>e.readSediment(),recordObservation:t=>e.recordObservation(t),remove:t=>e.remove(t),restore:t=>e.restore(t),resume:()=>e.setPaused(!1),settle:t=>e.settle(t),settleWithObservations:t=>e.settleWithObservations(t),snapshot:()=>e.snapshot(),sedimentHeightfield:t=>e.sedimentHeightfield(t),sedimentTotals:()=>e.sedimentTotals(),step:t=>e.tick(t)};var e}snapshot(){const e=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:J(this.bodyBudget),config:{...this.config,kernel:ee(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(U),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:e}}restore(e){const t=this.simulationState;this.config={bodyLimit:e.config.bodyLimit,eviction:e.config.eviction,fixedDt:e.config.fixedDt,maxDeltaSeconds:e.config.maxDeltaSeconds,maxSubsteps:e.config.maxSubsteps,settleStepLimit:e.config.settleStepLimit,timeScale:e.config.timeScale},this.configInput={...e.config,bodyBudget:J(e.bodyBudget??{}),kernel:ee(e.world.options)},this.bodyBudget=J(e.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.quiescence.setKernelOptions(e.world.options),this.quiescence.reset(),this.activeSensorPairs=new Set(e.activeSensorPairs),this.accumulator=e.accumulator,this.elapsedSeconds=e.elapsedSeconds,this.paused=e.paused,this.queue=e.queue.map(U).sort(Z),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Se(e.paused,e.visible,e.queue.length>0,e.world.bodies.every(e=>e.sleeping)),this.liveBodyOrder=e.liveBodyOrder.slice(),this.visible=e.visible,this.nextSequence=this.queue.reduce((e,t)=>Math.max(e,t.sequence),-1)+1,this.world.restore(e.world),this.updateResults.record({kind:"restore"},he),this.simulationState!==t&&this.observation.onSimulationStateChange?.(this.simulationState,t)}spawnDue(e,t){for(;this.queue.length>0&&this.queue[0].spawnAt<=this.elapsedSeconds+1e-9*this.config.fixedDt;){const s=this.queue.shift();if(!s)return;this.spawnOne(s,t),e.push(s.id)}}spawnOne(e,t){this.liveBodyOrder=this.liveBodyOrder.filter(t=>t!==e.id),this.removeActiveSensorPairsForBodies(new Set([e.id])),this.world.spawn(e),this.liveBodyOrder.push(e.id);for(const t of e.springs??[])this.world.setConstraint({...t,bodyId:e.id});const s=this.world.readState().find(t=>t.id===e.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:e.id,datum:s?.datum??e.datum,x:s?.x??e.x,y:s?.y??e.y},t)}result(e,t,s,i,n,o,r,a=this.evaluateBodyBudget()){this.syncSimulationState(o);const d=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:s,events:n,observations:o,queueSize:this.queue.length,revision:this.revision,shouldContinue:r??(!this.paused&&this.visible&&(this.queue.length>0||!this.atRest())),sleeping:d,sedimented:i,spawned:t,steps:e}}observeKernelEvents(e,t){!function(e,t,s){if(0===t.length)return;const i=new Map(e.readState().map(e=>[e.id,e]));for(const e of t){if("sleep"!==e.type)continue;const t=i.get(e.bodyId);s.emit({type:"physics-settle",timestamp:s.elapsedSeconds,chartType:s.observation.chartType,chartId:s.observation.chartId,bodyId:e.bodyId,datum:t?.datum,x:t?.x,y:t?.y})}}(this.world,e,this.observationContext(t))}observeSensorTransitions(e){this.activeSensorPairs=function(e,t,s){const i=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===i.size&&0===t.size)return i;const n=new Map(e.readState().map(e=>[e.id,e])),o=(e,t)=>{const{sensorId:i,bodyId:o}=se(t),r=s.observation.sensors[i],a=n.get(o);s.emit({type:"enter"===e?r?.enterType??"physics-bin-enter":r?.exitType??"physics-bin-exit",timestamp:s.elapsedSeconds,chartType:s.observation.chartType,chartId:s.observation.chartId,bodyId:o,datum:a?.datum,x:a?.x,y:a?.y,sensorId:i,binId:r?.binId??i})};for(const e of Array.from(i).sort())t.has(e)||o("enter",e);for(const e of Array.from(t).sort())i.has(e)||o("exit",e);return i}(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){!function(e,t){for(const s of e)t.has(se(s).bodyId)&&e.delete(s)}(this.activeSensorPairs,e)}observationContext(e){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:t=>this.emitObservation(t,e)}}emitObservation(e,t){t?.push(e),this.observation.onObservation?.(e)}evaluateBodyBudget(){return H({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(e){const t=this.evaluateBodyBudget();if("ok"===t.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",t;const s=`${t.state}:${t.action}`;return s===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=s,function(e,t){t.emit({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:t.elapsedSeconds,chartType:t.observation.chartType,chartId:t.observation.chartId,budgetAction:e.action,bodyLimit:e.bodyLimit,engineMaxBodiesHint:e.engineMaxBodiesHint,liveBodies:e.liveBodies,overflow:e.overflow,projectedBodies:e.projectedBodies,queuedBodies:e.queuedBodies,warnAt:e.warnAt})}(t,this.observationContext(e))),t}syncSimulationState(e){const t=Se(this.paused,this.visible,this.queue.length>0,this.atRest());if(t===this.simulationState)return;const s=this.simulationState;this.simulationState=t,function(e,t,s){s.observation.onSimulationStateChange?.(t,e),"running"!==t&&"settled"!==t||s.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:s.elapsedSeconds,chartType:s.observation.chartType,chartId:s.observation.chartId,simulationState:t,previousSimulationState:e})}(s,t,this.observationContext(e))}evictOverflow(e){const{evicted:t,sedimented:s,liveBodyOrder:i}=we(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(e));return t.length>0&&(this.liveBodyOrder=i,this.removeActiveSensorPairsForBodies(new Set(t))),{evicted:t,sedimented:s}}};function Oe(e,t){return function(e,t,s=[],i){const n=new Array(t.length),o=new Float32Array(2*t.length),r=new Float32Array(2*t.length),a=new Uint8Array(t.length);return t.forEach((e,t)=>{const s=2*t;n[t]=e.id,o[s]=e.x,o[s+1]=e.y,r[s]=e.vx,r[s+1]=e.vy,a[t]=e.sleeping?1:0}),{bodies:t,ids:n,positions:o,result:e,sediment:s,sleeping:a,snapshot:i,velocities:r}}(t,e.readBodies(),e.readSediment(),e.snapshot())}function qe(e){return Oe(e,e.tick(0))}var ke=function(){let e=new Me;return{handle(t){switch(t.type){case"init":return e=new Me(t.config),t.snapshot?e.restore(t.snapshot):t.initialSpawns?.length&&e.enqueue(t.initialSpawns,t.initialSpawnPacing),{type:"frame",frame:qe(e)};case"configure":return e.updateConfig(t.config),{type:"frame",frame:qe(e)};case"enqueue":return e.enqueue(t.spawns,t.pacing),{type:"frame",frame:qe(e)};case"tick":return{type:"frame",frame:Oe(e,e.tick(t.deltaSeconds))};case"settle":return{type:"frame",frame:Oe(e,e.settleWithObservations(t.maxSteps))};case"snapshot":return{type:"snapshot",snapshot:e.snapshot()};case"restore":return e.restore(t.snapshot),{type:"frame",frame:qe(e)};case"clear":return e.clear(),{type:"frame",frame:qe(e)};case"remove":return{type:"removed",removed:e.remove(t.ids),frame:qe(e)};case"applyImpulse":return e.applyImpulse(t.id,t.ix,t.iy),{type:"frame",frame:qe(e)};case"setPaused":return e.setPaused(t.paused),{type:"frame",frame:qe(e)};case"setVisible":return e.setVisible(t.visible),{type:"frame",frame:qe(e)}}}}}();function Pe(e){return e instanceof Error?{message:e.message,name:e.name,stack:e.stack}:{message:String(e)}}self.onmessage=e=>{const t=e.data;try{const e=ke.handle(t.command);self.postMessage({ok:!0,payload:e,requestId:t.requestId},function(e){return"frame"===e.type||"removed"===e.type?[(t=e.frame).positions.buffer,t.velocities.buffer,t.sleeping.buffer]:[];var t}(e))}catch(e){self.postMessage({error:Pe(e),ok:!1,requestId:t.requestId})}};
1
+ function e(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function t(e){const t=e.fixedPosition;Number.isFinite(t?.x)&&(e.x=e.prevX=t.x,e.vx=0),Number.isFinite(t?.y)&&(e.y=e.prevY=t.y,e.vy=0)}function s(e){if(!e)return;const t=Number.isFinite(e.x)?e.x:void 0,s=Number.isFinite(e.y)?e.y:void 0;return null==t&&null==s?void 0:{x:t,y:s}}function i(e,t,s){const i="x"===s?"y":"x",n=Math.abs(t[s]-e[s]),o=t[i]-e[i],r=(e,t)=>"circle"===e.shape.type?e.shape.radius:("x"===t?e.shape.width:e.shape.height)/2;let a;if("circle"===e.shape.type&&"circle"===t.shape.type){const s=e.shape.radius+t.shape.radius;a=Math.sqrt(Math.max(0,s*s-n*n))}else if("aabb"===e.shape.type&&"aabb"===t.shape.type)a=r(e,i)+r(t,i);else{const o="circle"===e.shape.type?e:t,d="aabb"===e.shape.type?e:t,h=r(o,s),c=Math.max(0,n-r(d,s));a=r(d,i)+Math.sqrt(Math.max(0,h*h-c*c))}const d=o<0?-1:1;return{nx:"x"===i?d:0,ny:"y"===i?d:0,penetration:Math.max(0,a-Math.abs(o))}}function n(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function o(e){return"aabb"===e.type?{type:"aabb",x:e.x,y:e.y,width:e.width,height:e.height}:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:e.thickness}}function r(e){return{id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,bodyCollisions:e.bodyCollisions,...e.fixedPosition?{fixedPosition:s(e.fixedPosition)}:{},shape:n(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function a(e){return e&&"function"!=typeof e?{property:e.property,equals:e.equals,notEquals:e.notEquals,oneOf:e.oneOf?.slice(),notOneOf:e.notOneOf?.slice()}:e}function d(e){return{id:e.id,shape:o(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:a(e.bodyFilter),index:e.index}}var h={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},c=1e-9,l=.005;function u(e,t,s){return Math.max(t,Math.min(s,e))}function p(e,t,s){return Math.min(e??s,t??s)}function v(e,t,s){return u(Math.max(e??s,t??s),0,1)}function y(e){return e<0?-1:1}function f(e){if("circle"===e.shape.type){const t=e.shape.radius;return{minX:e.x-t,minY:e.y-t,maxX:e.x+t,maxY:e.y+t}}const t=e.shape.width/2,s=e.shape.height/2;return{minX:e.x-t,minY:e.y-s,maxX:e.x+t,maxY:e.y+s}}function m(e){const t=e.shape;if("aabb"===t.type){const e=t.width/2,s=t.height/2;return{minX:t.x-e,minY:t.y-s,maxX:t.x+e,maxY:t.y+s}}const s=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-s,minY:Math.min(t.y1,t.y2)-s,maxX:Math.max(t.x1,t.x2)+s,maxY:Math.max(t.y1,t.y2)+s}}function x(e,t){return e.minX<=t.maxX&&e.maxX>=t.minX&&e.minY<=t.maxY&&e.maxY>=t.minY}function b(e,t,s,i,n,o,r,a){const d=n-e,h=(s+r)/2-Math.abs(d);if(h<=0)return null;const c=o-t,l=(i+a)/2-Math.abs(c);return l<=0?null:h<l?{nx:y(d),ny:0,penetration:h}:{nx:0,ny:y(c),penetration:l}}function g(e,t,s,i,n,o,r){const a=o/2,d=r/2,h=e-u(e,i-a,i+a),l=t-u(t,n-d,n+d),p=h*h+l*l;if(p>s*s)return null;if(p<=c){const o=Math.abs(e-(i-a)),r=Math.abs(e-(i+a)),h=Math.abs(t-(n-d)),c=Math.abs(t-(n+d)),l=Math.min(o,r,h,c);return l===o?{nx:-1,ny:0,penetration:s+o}:l===r?{nx:1,ny:0,penetration:s+r}:l===h?{nx:0,ny:-1,penetration:s+h}:{nx:0,ny:1,penetration:s+c}}const v=Math.sqrt(p);return{nx:h/v,ny:l/v,penetration:s-v}}function S(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return function(e,t,s,i,n,o){const r=i-e,a=n-t,d=s+o,h=r*r+a*a;if(h>=d*d)return null;if(h<=c)return{nx:1,ny:0,penetration:d};const l=Math.sqrt(h);return{nx:r/l,ny:a/l,penetration:d-l}}(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.radius);if("aabb"===e.shape.type&&"aabb"===t.shape.type)return b(e.x,e.y,e.shape.width,e.shape.height,t.x,t.y,t.shape.width,t.shape.height);if("circle"===e.shape.type&&"aabb"===t.shape.type){const s=g(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height);return s?{nx:-s.nx,ny:-s.ny,penetration:s.penetration}:null}return"aabb"===e.shape.type&&"circle"===t.shape.type?g(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function w(e,t){const s=t.shape;if("aabb"===s.type)return"circle"===e.shape.type?g(e.x,e.y,e.shape.radius,s.x,s.y,s.width,s.height):b(s.x,s.y,s.width,s.height,e.x,e.y,e.shape.width,e.shape.height);const i="circle"===e.shape.type?e.shape.radius:Math.sqrt(e.shape.width*e.shape.width+e.shape.height*e.shape.height)/2;return function(e,t,s,i,n,o,r,a=0){const d=o-i,h=r-n,l=d*d+h*h,p=l<=c?0:u(((e-i)*d+(t-n)*h)/l,0,1),v=s+a/2,y=e-(i+d*p),f=t-(n+h*p),m=y*y+f*f;if(m>=v*v)return null;if(m<=c){const e=Math.sqrt(l);return e<=c?{nx:1,ny:0,penetration:v}:{nx:-h/e,ny:d/e,penetration:v}}const x=Math.sqrt(m);return{nx:y/x,ny:f/x,penetration:v-x}}(e.x,e.y,i,s.x1,s.y1,s.x2,s.y2,s.thickness??0)}function I(e,t){return`${e}\0${t}`}function B(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function M(e,t){return Boolean(t?.some(t=>Object.is(e,t)))}function O(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const s=function(e,t){if(!t)return;let s=e;for(const e of t.split(".")){if(null==s||"object"!=typeof s)return;if(!Object.prototype.hasOwnProperty.call(s,e))return;s=s[e]}return s}(e,t.property);return!("equals"in t&&!Object.is(s,t.equals))&&((!("notEquals"in t)||!Object.is(s,t.notEquals))&&(!(t.oneOf&&!M(s,t.oneOf))&&(!t.notOneOf||!M(s,t.notOneOf))))}function q(e,t){return O(t,e.bodyFilter)}var k=class{constructor(t={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...h,...t},this.random=e(this.options.seed)}init(t={}){this.options={...h,...t},this.random=e(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(e){const i={id:e.id,x:e.x,y:e.y,prevX:e.x,prevY:e.y,vx:e.vx??0,vy:e.vy??0,angle:e.angle??0,mass:Math.max(c,e.mass??1),bodyCollisions:e.bodyCollisions??!0,...e.fixedPosition?{fixedPosition:s(e.fixedPosition)}:{},shape:n(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};t(i),this.nextBodyIndex+=1,this.bodies.set(e.id,i)}remove(e){for(const t of e){this.bodies.delete(t);for(const e of Array.from(this.activeSensors))B(e).bodyId===t&&this.activeSensors.delete(e)}}setColliders(e){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const t of e)this.colliders.set(t.id,{...t,shape:o(t.shape),bodyFilter:a(t.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(e){const t=e.id??`spring-${this.nextSpringIndex}`;return this.springs.set(t,{id:t,bodyId:e.bodyId,target:e.target,restLength:e.restLength??0,stiffness:e.stiffness??40,damping:e.damping??3}),this.nextSpringIndex+=1,t}removeConstraint(e){this.springs.delete(e)}applyImpulse(e,s,i){const n=this.bodies.get(e);n&&(n.vx+=s/n.mass,n.vy+=i/n.mass,t(n),this.wake(n))}step(e=this.options.fixedDt){const s=Math.max(0,e);if(this.lastEvents=[],0===s)return;const i=this.sortedBodies();for(const e of i)e.prevX=e.x,e.prevY=e.y;this.applySprings(s);const n=this.options.maxVelocity;for(const e of i)if(!e.sleeping){if(e.vx+=this.options.gravity.x*s,e.vy+=this.options.gravity.y*s,e.vx*=this.options.velocityDamping,e.vy*=this.options.velocityDamping,t(e),n>0){const t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>n){const s=n/t;e.vx*=s,e.vy*=s}}e.x+=e.vx*s,e.y+=e.vy*s}this.supportedThisStep.clear();const o=this.bodyPairKeys(i),r=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;e<this.options.collisionIterations;e+=1)this.resolveBodyPairs(i,o,0===e),this.resolveColliders(i,r,0===e);this.updateSensors(i),this.updateSleeping(i,s)}settle(e=1200,t=this.options.fixedDt){let s=0;for(;s<e&&!this.allSleeping();)this.step(t),s+=1;return s}readState(e=[]){e.length=0;for(const t of this.sortedBodies())e.push({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,...t.fixedPosition?{fixedPosition:s(t.fixedPosition)}:{},shape:n(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(B)}allSleeping(){for(const e of this.bodies.values())if(!e.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(r),colliders:this.sortedColliders().map(d),springs:Array.from(this.springs.values()).map(e=>({...e,target:{...e.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(s){this.options={...s.options,gravity:{...s.options.gravity}},this.random=e(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(s.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const e of s.bodies){const s=r(e);t(s),this.bodies.set(s.id,s),this.nextBodyIndex=Math.max(this.nextBodyIndex,s.index+1)}this.nextColliderIndex=0;for(const e of s.colliders){const t=d(e);this.colliders.set(t.id,t),this.nextColliderIndex=Math.max(this.nextColliderIndex,t.index+1)}this.nextSpringIndex=0;for(const e of s.springs){this.springs.set(e.id,{...e,target:{...e.target}});const t=/^spring-(\d+)$/.exec(e.id);t&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(t[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((e,t)=>e.index-t.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((e,t)=>e.index-t.index)}applySprings(e){for(const t of Array.from(this.springs.values()).sort((e,t)=>e.id.localeCompare(t.id))){const s=this.bodies.get(t.bodyId);if(!s||s.sleeping)continue;const i="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!i)continue;const n=i.x-s.x,o=i.y-s.y,r=n*n+o*o,a=Math.sqrt(r);if(a<=c)continue;const d=n/a,h=o/a,l="vx"in i?i.vx:0,u="vy"in i?i.vy:0,p=(l-s.vx)*d+(u-s.vy)*h,v=(a-t.restLength)*t.stiffness+p*t.damping;s.vx+=v*d*e/s.mass,s.vy+=v*h*e/s.mass}}resolveBodyPairs(e,t,s){for(const i of t){const[t,n]=i.split(":").map(Number),o=e[t],r=e[n];if(!o||!r)continue;const a=S(o,r);a&&(this.resolveDynamicCollision(o,r,a),s&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:r.id,sensor:!1}))}}bodyPairKeys(e){const t=Math.max(1,this.options.cellSize),s=new Map;for(let i=0;i<e.length;i+=1){if(!1===e[i].bodyCollisions)continue;const n=f(e[i]),o=Math.floor(n.minX/t),r=Math.floor(n.maxX/t),a=Math.floor(n.minY/t),d=Math.floor(n.maxY/t);for(let e=o;e<=r;e+=1)for(let t=a;t<=d;t+=1){const n=`${e}:${t}`,o=s.get(n);o?o.push(i):s.set(n,[i])}}const i=new Set;for(const t of Array.from(s.keys()).sort()){const n=s.get(t)??[];n.sort((e,t)=>e-t);for(let t=0;t<n.length;t+=1)for(let s=t+1;s<n.length;s+=1){const o=n[t],r=n[s];!1!==e[o].bodyCollisions&&!1!==e[r].bodyCollisions&&(x(f(e[o]),f(e[r]))&&i.add(`${o}:${r}`))}}return Array.from(i).sort((e,t)=>{const[s,i]=e.split(":").map(Number),[n,o]=t.split(":").map(Number);return s===n?i-o:s-n})}resolveDynamicCollision(e,t,s){(e.fixedPosition||t.fixedPosition)&&(!e.sleeping&&null==e.fixedPosition?.x||!t.sleeping&&null==t.fixedPosition?.x?!e.sleeping&&null==e.fixedPosition?.y||!t.sleeping&&null==t.fixedPosition?.y||(s=i(e,t,"y")):s=i(e,t,"x")),e.sleeping&&this.contactOpposesGravity(s.nx,s.ny)&&this.supportedThisStep.add(t.id),t.sleeping&&this.contactOpposesGravity(-s.nx,-s.ny)&&this.supportedThisStep.add(e.id);const n=e.sleeping?0:1/e.mass,o=t.sleeping?0:1/t.mass,r=null==e.fixedPosition?.x?n:0,a=null==e.fixedPosition?.y?n:0,d=null==t.fixedPosition?.x?o:0,h=null==t.fixedPosition?.y?o:0,u=e.fixedPosition||t.fixedPosition?s.nx**2*(r+d)+s.ny**2*(a+h):n+o;if(u<=c)return;const v=Math.max(0,s.penetration-l)/u;e.x-=s.nx*v*r,e.y-=s.ny*v*a,t.x+=s.nx*v*d,t.y+=s.ny*v*h;const y=t.vx-e.vx,f=t.vy-e.vy,m=y*s.nx+f*s.ny;if(m>0)return;const x=Math.abs(m),b=-(1+p(e.restitution,t.restitution,this.options.restitution))*m/u,g=b*s.nx,S=b*s.ny;e.vx-=g*r,e.vy-=S*a,t.vx+=g*d,t.vy+=S*h,this.applyFriction(e,t,s,b,n,o),x>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,s,i,n,o){const r=-s.ny,a=s.nx,d=(t.vx-e.vx)*r+(t.vy-e.vy)*a,h=null==e.fixedPosition?.x?n:0,l=null==e.fixedPosition?.y?n:0,p=null==t.fixedPosition?.x?o:0,y=null==t.fixedPosition?.y?o:0,f=e.fixedPosition||t.fixedPosition?r**2*(h+p)+a**2*(l+y):n+o;if(Math.abs(d)<=c||f<=c)return;const m=v(e.friction,t.friction,this.options.friction),x=u(-d/f,-i*m,i*m),b=x*r,g=x*a;e.vx-=b*h,e.vy-=g*l,t.vx+=b*p,t.vy+=g*y}resolveColliders(e,t,s){for(const i of e)for(const e of t){if(!q(e,i))continue;if(!x(f(i),m(e)))continue;const t=w(i,e);t&&(this.resolveStaticCollision(i,e,t),this.contactOpposesGravity(t.nx,t.ny)&&this.supportedThisStep.add(i.id),s&&this.lastEvents.push({type:"contact",bodyId:i.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,s,i){e.x+=i.nx*Math.max(0,i.penetration-l),e.y+=i.ny*Math.max(0,i.penetration-l);const n=e.vx*i.nx+e.vy*i.ny;if(n<0){const t=p(e.restitution,s.restitution,this.options.restitution);e.vx-=(1+t)*n*i.nx,e.vy-=(1+t)*n*i.ny;const o=-i.ny,r=i.nx,a=e.vx*o+e.vy*r,d=v(e.friction,s.friction,this.options.friction);e.vx-=a*o*d,e.vy-=a*r*d}t(e)}updateSensors(e){const t=new Set,s=this.sortedColliders().filter(e=>e.sensor);for(const i of e){const e=f(i);for(const n of s){if(!q(n,i))continue;if(!x(e,m(n)))continue;if(!w(i,n))continue;const s=I(n.id,i.id);t.add(s),this.activeSensors.has(s)||this.lastEvents.push({type:"sensor-enter",bodyId:i.id,sensorId:n.id})}}for(const e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;const{sensorId:s,bodyId:i}=B(e);this.lastEvents.push({type:"sensor-exit",bodyId:i,sensorId:s})}this.activeSensors=t}updateSleeping(e,t){const s=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const i of e){const e=Math.sqrt(i.vx*i.vx+i.vy*i.vy),n=Math.sqrt((i.x-i.prevX)*(i.x-i.prevX)+(i.y-i.prevY)*(i.y-i.prevY));!(e<this.options.sleepSpeed&&n<this.options.sleepSpeed*t)||s&&!this.supportedThisStep.has(i.id)?i.sleeping?this.wake(i):i.sleepTime=0:(i.sleepTime+=t,!i.sleeping&&i.sleepTime>=this.options.sleepAfter&&(i.sleeping=!0,i.vx=0,i.vy=0,this.lastEvents.push({type:"sleep",bodyId:i.id})))}}contactOpposesGravity(e,t){const{x:s,y:i}=this.options.gravity,n=Math.hypot(s,i);return n<=1e-9||(e*s+t*i)/n<-.2}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},P=class{constructor(e={}){this.id="builtin",this.capabilities={...(new k).capabilities,engine:"builtin"},this.world=new k(e)}init(e={}){this.world.init(e)}spawn(e){this.world.spawn(e)}remove(e){this.world.remove(e)}setColliders(e){this.world.setColliders(e)}setConstraint(e){return this.world.setConstraint(e)}removeConstraint(e){this.world.removeConstraint(e)}applyImpulse(e,t,s){this.world.applyImpulse(e,t,s)}step(e){this.world.step(e)}settle(e,t){return this.world.settle(e,t)}readState(e){return this.world.readState(e)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(e){this.world.restore(e)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function C(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new P(e)}(t)}var T=["binId","targetBin","category","windowIndex","lane","group"];function A(){return{count:0,total:0,mean:0,m2:0,min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY}}function D(e,t){if(!Number.isFinite(t))return;e.count+=1,e.total+=t,e.min=Math.min(e.min,t),e.max=Math.max(e.max,t);const s=t-e.mean;e.mean+=s/e.count;const i=t-e.mean;e.m2+=s*i}function R(e){return{count:e.count,total:e.total,mean:e.count>0?e.mean:0,min:e.count>0?e.min:0,max:e.count>0?e.max:0,variance:e.count>1?e.m2/(e.count-1):0}}function N(e){return{count:e.count,total:e.total,mean:e.mean,m2:e.variance*Math.max(0,e.count-1),min:e.count>0?e.min:Number.POSITIVE_INFINITY,max:e.count>0?e.max:Number.NEGATIVE_INFINITY}}function E(e,t){const s=e;if(null!=s[t])return s[t];const i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function F(e,t,s){return"function"==typeof e?e(t,s):"string"==typeof e?E(t,e):void 0}function Y(e){if(null==e)return;const t=String(e);return t.trim()?t:void 0}function X(e){const t=R(e.value);return{id:e.id,label:e.label,count:t.count,total:t.total,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:R(e.x),y:R(e.y),value:t}}var L=class{constructor(e=!1){this.bins=new Map,this.nextIndex=0,this.config=e}updateConfig(e){void 0!==e&&(this.config=e,!1===e&&this.clear())}isEnabled(){return!1!==this.config}add(e){if(!1===this.config)return null;const t=this.nextIndex;this.nextIndex+=1;const s=Y(F(this.config.binAccessor,e,t))??function(e){for(const t of T){const s=Y(E(e,t));if(s)return s}return"sediment"}(e),i=Y(F(this.config.labelAccessor,e,t))??s,n=function(e,t,s){if("number"==typeof e)return e;const i="function"==typeof e?e(t,s):"string"==typeof e?E(t,e):1,n="number"==typeof i?i:Number(i);return Number.isFinite(n)?n:1}(this.config.valueAccessor,e,t),o=Math.max(0,Math.floor(this.config.retainBodyIds??12));let r=this.bins.get(s);return r||(r={id:s,label:i,bodyIds:[],x:A(),y:A(),value:A()},this.bins.set(s,r)),r.label=i,r.lastBodyId=e.id,r.lastDatum=e.datum,D(r.x,e.x),D(r.y,e.y),D(r.value,n),o>0&&(r.bodyIds.push(e.id),r.bodyIds.length>o&&(r.bodyIds=r.bodyIds.slice(r.bodyIds.length-o))),X(r)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(X)}restore(e=[]){this.bins.clear();for(const t of e)this.bins.set(t.id,{id:t.id,label:t.label,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:N(t.x),y:N(t.y),value:N(t.value)});this.nextIndex=e.reduce((e,t)=>e+t.count,0)}totals(){const e=this.snapshot();return{bins:e.length,count:e.reduce((e,t)=>e+t.count,0),total:e.reduce((e,t)=>e+t.total,0)}}};function K(e){const t=Number(e);if(Number.isFinite(t)&&!(t<=0))return Math.floor(t)}function H(e){const t=Math.max(0,Math.floor(e.liveBodies)),s=Math.max(0,Math.floor(e.queuedBodies??0)),i=t+s,n=K(e.bodyLimit),o=K(e.engineMaxBodiesHint),r=function(e,t,s){if(!1===s)return;const i=K(s?.warnAt);return null!=i?i:null!=e?Math.max(1,Math.floor(.8*e)):null!=t?Math.max(1,Math.floor(.8*t)):void 0}(n,o,e.options),a=null==n?0:Math.max(0,t-n),d=a>0?"overflow":null!=r&&i>=r?"warning":"ok";return{action:"overflow"!==d?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:n,engineMaxBodiesHint:o,liveBodies:t,overflow:a,projectedBodies:i,queuedBodies:s,state:d,warnAt:r}}var W={bodyLimit:Number.POSITIVE_INFINITY,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},j={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function V(e={},t=j){return{chartId:e.chartId??t.chartId,chartType:e.chartType??t.chartType,sensors:e.sensors??t.sensors,onObservation:e.onObservation??t.onObservation,onSimulationStateChange:e.onSimulationStateChange??t.onSimulationStateChange}}function $(e){return{...e,shape:{...e.shape},...e.fixedPosition?{fixedPosition:{...e.fixedPosition}}:{},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function z(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:void 0}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function G(e,t){const s=e;if(null!=s[t])return s[t];const i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function _(e,t={}){const s=z(t.startAt)??0,i=t.pacing??"immediate";if("arrival"===i){let i=1/0;const n=e.map((e,s)=>{const n=function(e,t,s){return"function"==typeof s?z(s(e,t)):"string"==typeof s?z(G(e,s)):z(e.spawnAt)??z(G(e,"arrivalTime"))??z(G(e,"timestamp"))??z(G(e,"time"))??z(G(e,"eventTime"))}(e,s,t.timeAccessor);return null!=n&&(i=Math.min(i,n)),n}),o=z(t.timeScale)??1,r=o>0?o:1;return e.map((e,t)=>{const o=n[t],a=null==o?0:Math.max(0,o-i);return{...$(e),spawnAt:s+a/r}})}if("object"==typeof i){const t=z(i.ratePerSec);if(t&&t>0)return e.map((e,i)=>({...$(e),spawnAt:s+i/t}))}return e.map(e=>({...$(e),spawnAt:s}))}function U(e){return{...$(e),sequence:e.sequence,spawnAt:e.spawnAt}}function Q(e){return e.map(e=>({...e,shape:{...e.shape},bodyFilter:e.bodyFilter&&"function"!=typeof e.bodyFilter?{...e.bodyFilter,oneOf:e.bodyFilter.oneOf?.slice(),notOneOf:e.bodyFilter.notOneOf?.slice()}:e.bodyFilter}))}function J(e){return!1!==e&&{...e}}function Z(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function ee(e){return{...e,gravity:{...e.gravity}}}function te(e,t,s,i){if("circle"===e.shape.type){const n=e.x-t,o=e.y-s,r=e.shape.radius+i,a=n*n+o*o;return a<=r*r?a:null}const n=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),o=Math.max(Math.abs(s-e.y)-e.shape.height/2,0),r=n*n+o*o;return r<=i*i?r:null}function se(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}var ie={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function ne(e,t){const s={...e};for(const e of t){s[ie[e]]++}return s}function oe(e,t,s){const i=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:i,revisions:ne(s,i)}}var re=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=oe({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const s=oe(e,t,this.revisions);this.revisions=s.revisions,this.latest=s;for(const e of[...this.listeners])e();return s}};import{quadtree as ae}from"d3-quadtree";var de=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,s,i,n,o=0,r){const a=this.ensure(e,t);if(!a)return null;let d=null,h=Number.POSITIVE_INFINITY;const c=Math.max(0,r?.searchRadius??Math.max(0,o)+this.maxSearchRadius),l=i-c,u=i+c,p=n-c,v=n+c;return a.visit((e,t,a,c,y)=>{if(c<l||t>u||y<p||a>v)return!0;if(e.length)return!1;let f=e;for(;f;){const e=f.data;if(e&&(!r?.include||r.include(e))){const t=r?.distanceSquared?r.distanceSquared(e,i,n):te(e,i,n,Math.max(0,o));null!=t&&(t<h||t===h&&s.indexOf(e.id)>s.indexOf(d?.id??""))&&(d=e,h=t)}f=f.next}return!1}),d}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;const s=e.readState();return 0===s.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=s.reduce((e,t)=>Math.max(e,function(e){return"circle"===e.shape.type?e.shape.radius:Math.hypot(e.shape.width,e.shape.height)/2}(t)),0),this.tree=ae().x(e=>e.x).y(e=>e.y).addAll(s),this.revision=t,this.tree)}};var he=["data","scene-geometry","data-paint","accessibility","evidence"],ce=["scene-geometry","data-paint","accessibility","evidence"],le=["overlay","accessibility","evidence"],ue=(e,t)=>({retainedData:e,invalidations:t}),pe=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ve=["scene-geometry","data-paint","accessibility","evidence"],ye=[],fe={engine:ue("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:ue("preserve",ve),colliders:ue("preserve",ve),sediment:ue("preserve",ve),bodyBudget:ue("preserve",pe),bodyLimit:ue("preserve",pe),eviction:ue("preserve",pe),fixedDt:ue("preserve",ye),maxDeltaSeconds:ue("preserve",ye),maxSubsteps:ue("preserve",ye),settleStepLimit:ue("preserve",ye),timeScale:ue("preserve",ye),observation:ue("preserve",ye)},me=ue("preserve",pe);function xe(e){let t="preserve";const s=new Set;for(const i of e){const e=fe[i]??me;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)s.add(t)}return{retainedData:t,invalidations:s}}var be=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function ge(e,t){return e===t||!(!e||!t)&&(e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&be.every(s=>e[s]===t[s]))}function Se(e,t,s,i){return e||!t?"paused":s||!i?"running":"settled"}function we(e,t,s,i,n,o){const r={evicted:[],sedimented:[],liveBodyOrder:n};if(!1===s)return r;const a=Math.max(0,Math.floor(i));if(!Number.isFinite(a))return r;const d=n.length-a;if(d<=0)return r;const h=function(e,t,s){if("sleeping-first"!==t)return s.slice();const i=new Map(e.readState().map(e=>[e.id,e.sleeping])),n=[],o=[];for(const e of s)i.get(e)?n.push(e):o.push(e);return[...n,...o]}(e,s,n),c=h.slice(0,d);if(0===c.length)return r;const l=function(e,t,s,i){const n=new Map(e.readState().map(e=>[e.id,e])),o=[];for(const e of s){const s=n.get(e);if(!s)continue;const r=t.add(s);r&&(o.push(e),i.emit({type:"physics-sediment",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:e,datum:s.datum,x:s.x,y:s.y,binId:r.id,count:r.count,total:r.total}))}return o}(e,t,c,o);e.remove(c);const u=new Set(c);return{evicted:c,sedimented:l,liveBodyOrder:n.filter(e=>!u.has(e))}}var Ie=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(e){this.speed=function(e){const t=e?.sleepSpeed;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:8}(e)}reset(){this.seconds=0}isAtRest(){return this.seconds>=.6}refresh(e,t,s){if(s>0)return void(this.seconds=0);const i=e.readState(this.scratch),n=this.speed*this.speed;let o=!0;for(const e of i)if(!e.sleeping&&e.vx*e.vx+e.vy*e.vy>=n){o=!1;break}this.seconds=o?this.seconds+Math.max(0,t):0}};function Be(e,t,s,i={}){let n,o=0;for(;o<t&&!i.shouldStop?.()&&(!1===i.stopAtRest||e.queueSize()>0||!e.atRest()||i.continueWhile?.());){e.step(e.fixedDt),e.advanceTime(e.fixedDt);const t=e.drainEvents();s.events&&(s.events.push(...t),e.observeKernelEvents(t,s.observations),e.observeSensorTransitions(s.observations));const r=[];if(e.spawnDue(r,s.observations),r.length>0){s.spawned.push(...r),n=e.observeBodyBudget(s.observations);const t=e.evictOverflow(s.observations);s.evicted?.push(...t.evicted),s.sedimented?.push(...t.sedimented)}o+=1,e.refreshQuiescence(e.fixedDt,r.length),i.afterStep?.()}return{steps:o,budget:n}}var Me=class{constructor(e={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new de,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new re,this.simulationState="settled",this.visible=!0,this.quiescence=new Ie;const{bodyBudget:t,colliders:s,engine:i,kernel:n,observation:o,sediment:r,...a}=e;this.config={...W,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=i,this.observation=V(o),this.sediment=new L(r??!1),this.world=C(i,{fixedDt:this.config.fixedDt,...n}),this.quiescence.setKernelOptions(n),s&&this.world.setColliders(Q(s))}updateConfig(e){const t=function(e,t){return Object.keys(e).filter(s=>"kernel"===s?!ge(e.kernel,t.kernel):e[s]!==t[s])}(e,this.configInput),{colliders:s,bodyBudget:i,engine:n,kernel:o,observation:r,sediment:a,...d}=e;if(this.config={...this.config,...d},void 0!==i&&(this.bodyBudget=i,!1===i&&(this.bodyBudgetObservationKey="ok")),n&&n!==this.engineInput){const e=this.world.snapshot();this.world.dispose(),this.engineInput=n,this.world=C(n,e.options),this.world.restore(e),this.revision+=1}if(o&&!ge(o,this.configInput.kernel)){const e=this.world.snapshot(),t={...e.options,...o,gravity:{...e.options.gravity,...o.gravity}};this.world.restore({...e,options:t}),this.quiescence.setKernelOptions(t),this.revision+=1}r&&(this.observation=V(r,this.observation)),this.sediment.updateConfig(a),s&&(this.world.setColliders(Q(s)),this.revision+=1),this.configInput={...this.configInput,...e};const h=xe(t);this.updateResults.record({kind:"config",keys:t},h.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(Q(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},xe(["colliders"]).invalidations)}enqueue(e,t){const s=Array.isArray(e)?e:[e],i=t?_(s,{...t,startAt:t.startAt??this.elapsedSeconds}):s;for(const e of i)this.queue.push({...$(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(Z),i.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:i.length},i.length?he:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne($(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},he)}materializeDueSpawns(){const e=this.revision,t=[],s=[];return this.spawnDue(t,s),0===t.length||(this.observeBodyBudget(s),this.evictOverflow(s),this.syncSimulationState(s),this.revision+=1,this.updateResults.record({kind:"enqueue",count:t.length},this.revision!==e?he:[])),t}clear(){const e=this.world.snapshot().options;this.world.init({...e,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.quiescence.reset(),this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},he)}tick(e,t){const s=this.revision,i=[],n=[],o=[],r=[],a=[];if(this.paused||!this.visible){const e=this.result(0,i,n,o,r,a,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}const d=Math.max(0,Math.min(Number.isFinite(e)?e:0,this.config.maxDeltaSeconds))*this.config.timeScale;this.spawnDue(i,a);const h=this.observeBodyBudget(a),c=this.evictOverflow(a);n.push(...c.evicted),o.push(...c.sedimented),this.syncSimulationState(a),i.length>0&&this.quiescence.reset(),this.accumulator+=d;const l=this.stepObserver(t,{spawned:i,evicted:n,sedimented:o,events:r,observations:a}),u=d>0?Math.floor((this.accumulator+1e-9*this.config.fixedDt)/this.config.fixedDt):0,{steps:p,budget:v}=Be(this.settleHost(),Math.min(u,this.config.maxSubsteps),{spawned:i,evicted:n,sedimented:o,events:r,observations:a},{stopAtRest:!1,shouldStop:()=>this.paused||!this.visible,afterStep:l});this.accumulator=Math.max(0,this.accumulator-p*this.config.fixedDt),p===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(p>0||i.length>0||n.length>0||o.length>0||r.length>0)&&(this.revision+=1);const y=this.result(p,i,n,o,r,a,void 0,v??h);return this.updateResults.record({kind:"tick",count:p},this.revision!==s?i.length||n.length||o.length?he:ce:[]),y}settle(e=this.config.settleStepLimit){return this.runSettle(e,!1).steps}settleWithObservations(e=this.config.settleStepLimit,t){return this.runSettle(e,!0,t)}stepObserver(e,t){return function(e,t){if(!e)return;const s=["spawned","evicted","sedimented","events","observations"],i={spawned:0,evicted:0,sedimented:0,events:0,observations:0},n=n=>{const o=t(n),r={...o,spawned:o.spawned.slice(i.spawned),evicted:o.evicted.slice(i.evicted),sedimented:o.sedimented.slice(i.sedimented),events:o.events.slice(i.events),observations:o.observations.slice(i.observations)};for(const e of s)i[e]=o[e].length;e.onStep(r)};return n(0),()=>n(1)}(e,e=>(e&&(this.revision+=1),this.result(e,t.spawned,t.evicted,t.sedimented,t.events,t.observations)))}settleHost(){return{fixedDt:this.config.fixedDt,queueSize:()=>this.queue.length,atRest:()=>this.atRest(),advanceTime:e=>{this.elapsedSeconds+=e},spawnDue:(e,t)=>this.spawnDue(e,t),observeBodyBudget:e=>this.observeBodyBudget(e),evictOverflow:e=>this.evictOverflow(e),step:e=>this.world.step(e),drainEvents:()=>this.world.events(),observeKernelEvents:(e,t)=>this.observeKernelEvents(e,t),observeSensorTransitions:e=>this.observeSensorTransitions(e),refreshQuiescence:(e,t)=>this.quiescence.refresh(this.world,e,t)}}runSettle(e,t,s){const i=this.revision,n=[],o=[],r=[],a=[],d=t?[]:void 0;if(t&&(this.paused||!this.visible)){const e=this.result(0,n,o,r,a,d??[],!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(n,d);const h=this.observeBodyBudget(d),c=this.evictOverflow(d);o.push(...c.evicted),r.push(...c.sedimented),this.syncSimulationState(d),n.length>0&&this.quiescence.reset();const l=t?{spawned:n,evicted:o,sedimented:r,events:a,observations:d}:{spawned:n},u=this.stepObserver(s,{spawned:n,evicted:o,sedimented:r,events:a,observations:d??[]}),{steps:p,budget:v}=Be(this.settleHost(),e,l,{afterStep:u,continueWhile:s?.continueWhile,shouldStop:t?()=>this.paused||!this.visible:void 0}),y=n.length+o.length+r.length>0;(p>0||y||a.length>0)&&(this.revision+=1);const f=this.result(p,n,o,r,a,d??[],void 0,v??h);return this.updateResults.record({kind:"settle",count:p},this.revision===i?[]:y?he:ce),f}readBodies(e=[]){return this.world.readState(e)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(e={}){return function(e,t={}){const{baselineY:s=0,binWidth:i=24,gap:n=2,maxHeight:o=80,value:r="count",x:a}=t,d=e.reduce((e,t)=>Math.max(e,t[r]),1);return e.map((e,t)=>{const h=Math.max(0,e[r]/d*o),c=a?.(e,t)??t*(i+n);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:c,y:s-h,width:i,height:h,meanX:e.x.mean,meanY:e.y.mean}})}(this.readSediment(),e)}hitTest(e,t,s=0,i){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,s,i)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}atRest(){return this.world.allSleeping()||this.quiescence.isAtRest()}hasPendingWork(){return this.queue.length>0||!this.atRest()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(e){const{timestamp:t,chartType:s,chartId:i,...n}=e,o={...n,timestamp:t??this.elapsedSeconds,chartType:s??this.observation.chartType,chartId:i??this.observation.chartId};return this.emitObservation(o),this.updateResults.record({kind:"update",count:1},["evidence"]),o}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(e){return this.updateResults.subscribe(e)}version(){return this.revision}setPaused(e){const t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?le:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?le:[])}remove(e){const t=new Set(e),s=new Set(this.liveBodyOrder),i=new Set(this.queue.map(e=>e.id));this.queue=this.queue.filter(e=>!t.has(e.id)),this.liveBodyOrder=this.liveBodyOrder.filter(e=>!t.has(e)),this.world.remove(e),this.removeActiveSensorPairsForBodies(t);const n=e.filter(e=>s.has(e)||i.has(e));return n.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:n,count:n.length},n.length?he:[]),n}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},ce),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},ce)}applyImpulse(e,t,s){this.world.applyImpulse(e,t,s),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},ce)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,s,i)=>e.applyImpulse(t,s,i),clear:()=>e.clear(),hitTest:(t,s,i)=>e.hitTest(t,s,i),pause:()=>e.setPaused(!0),push:(t,s)=>e.enqueue(t,s),pushMany:(t,s)=>e.enqueue(t,s),bodyBudgetStatus:()=>e.bodyBudgetStatus(),readBodies:t=>e.readBodies(t),readSediment:()=>e.readSediment(),recordObservation:t=>e.recordObservation(t),remove:t=>e.remove(t),restore:t=>e.restore(t),resume:()=>e.setPaused(!1),settle:t=>e.settle(t),settleWithObservations:t=>e.settleWithObservations(t),snapshot:()=>e.snapshot(),sedimentHeightfield:t=>e.sedimentHeightfield(t),sedimentTotals:()=>e.sedimentTotals(),step:t=>e.tick(t)};var e}snapshot(){const e=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:J(this.bodyBudget),config:{...this.config,kernel:ee(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(U),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:e}}restore(e){const t=this.simulationState;this.config={bodyLimit:e.config.bodyLimit,eviction:e.config.eviction,fixedDt:e.config.fixedDt,maxDeltaSeconds:e.config.maxDeltaSeconds,maxSubsteps:e.config.maxSubsteps,settleStepLimit:e.config.settleStepLimit,timeScale:e.config.timeScale},this.configInput={...e.config,bodyBudget:J(e.bodyBudget??{}),kernel:ee(e.world.options)},this.bodyBudget=J(e.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.quiescence.setKernelOptions(e.world.options),this.quiescence.reset(),this.activeSensorPairs=new Set(e.activeSensorPairs),this.accumulator=e.accumulator,this.elapsedSeconds=e.elapsedSeconds,this.paused=e.paused,this.queue=e.queue.map(U).sort(Z),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Se(e.paused,e.visible,e.queue.length>0,e.world.bodies.every(e=>e.sleeping)),this.liveBodyOrder=e.liveBodyOrder.slice(),this.visible=e.visible,this.nextSequence=this.queue.reduce((e,t)=>Math.max(e,t.sequence),-1)+1,this.world.restore(e.world),this.updateResults.record({kind:"restore"},he),this.simulationState!==t&&this.observation.onSimulationStateChange?.(this.simulationState,t)}spawnDue(e,t){for(;this.queue.length>0&&this.queue[0].spawnAt<=this.elapsedSeconds+1e-9*this.config.fixedDt;){const s=this.queue.shift();if(!s)return;this.spawnOne(s,t),e.push(s.id)}}spawnOne(e,t){this.liveBodyOrder=this.liveBodyOrder.filter(t=>t!==e.id),this.removeActiveSensorPairsForBodies(new Set([e.id])),this.world.spawn(e),this.liveBodyOrder.push(e.id);for(const t of e.springs??[])this.world.setConstraint({...t,bodyId:e.id});const s=this.world.readState().find(t=>t.id===e.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:e.id,datum:s?.datum??e.datum,x:s?.x??e.x,y:s?.y??e.y},t)}result(e,t,s,i,n,o,r,a=this.evaluateBodyBudget()){this.syncSimulationState(o);const d=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:s,events:n,observations:o,queueSize:this.queue.length,revision:this.revision,shouldContinue:r??(!this.paused&&this.visible&&(this.queue.length>0||!this.atRest())),sleeping:d,sedimented:i,spawned:t,steps:e}}observeKernelEvents(e,t){!function(e,t,s){if(0===t.length)return;const i=new Map(e.readState().map(e=>[e.id,e]));for(const e of t){if("sleep"!==e.type)continue;const t=i.get(e.bodyId);s.emit({type:"physics-settle",timestamp:s.elapsedSeconds,chartType:s.observation.chartType,chartId:s.observation.chartId,bodyId:e.bodyId,datum:t?.datum,x:t?.x,y:t?.y})}}(this.world,e,this.observationContext(t))}observeSensorTransitions(e){this.activeSensorPairs=function(e,t,s){const i=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===i.size&&0===t.size)return i;const n=new Map(e.readState().map(e=>[e.id,e])),o=(e,t)=>{const{sensorId:i,bodyId:o}=se(t),r=s.observation.sensors[i],a=n.get(o);s.emit({type:"enter"===e?r?.enterType??"physics-bin-enter":r?.exitType??"physics-bin-exit",timestamp:s.elapsedSeconds,chartType:s.observation.chartType,chartId:s.observation.chartId,bodyId:o,datum:a?.datum,x:a?.x,y:a?.y,sensorId:i,binId:r?.binId??i})};for(const e of Array.from(i).sort())t.has(e)||o("enter",e);for(const e of Array.from(t).sort())i.has(e)||o("exit",e);return i}(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){!function(e,t){for(const s of e)t.has(se(s).bodyId)&&e.delete(s)}(this.activeSensorPairs,e)}observationContext(e){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:t=>this.emitObservation(t,e)}}emitObservation(e,t){t?.push(e),this.observation.onObservation?.(e)}evaluateBodyBudget(){return H({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(e){const t=this.evaluateBodyBudget();if("ok"===t.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",t;const s=`${t.state}:${t.action}`;return s===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=s,function(e,t){t.emit({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:t.elapsedSeconds,chartType:t.observation.chartType,chartId:t.observation.chartId,budgetAction:e.action,bodyLimit:e.bodyLimit,engineMaxBodiesHint:e.engineMaxBodiesHint,liveBodies:e.liveBodies,overflow:e.overflow,projectedBodies:e.projectedBodies,queuedBodies:e.queuedBodies,warnAt:e.warnAt})}(t,this.observationContext(e))),t}syncSimulationState(e){const t=Se(this.paused,this.visible,this.queue.length>0,this.atRest());if(t===this.simulationState)return;const s=this.simulationState;this.simulationState=t,function(e,t,s){s.observation.onSimulationStateChange?.(t,e),"running"!==t&&"settled"!==t||s.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:s.elapsedSeconds,chartType:s.observation.chartType,chartId:s.observation.chartId,simulationState:t,previousSimulationState:e})}(s,t,this.observationContext(e))}evictOverflow(e){const{evicted:t,sedimented:s,liveBodyOrder:i}=we(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(e));return t.length>0&&(this.liveBodyOrder=i,this.removeActiveSensorPairsForBodies(new Set(t))),{evicted:t,sedimented:s}}};function Oe(e,t){return function(e,t,s=[],i){const n=new Array(t.length),o=new Float32Array(2*t.length),r=new Float32Array(2*t.length),a=new Uint8Array(t.length);return t.forEach((e,t)=>{const s=2*t;n[t]=e.id,o[s]=e.x,o[s+1]=e.y,r[s]=e.vx,r[s+1]=e.vy,a[t]=e.sleeping?1:0}),{bodies:t,ids:n,positions:o,result:e,sediment:s,sleeping:a,snapshot:i,velocities:r}}(t,e.readBodies(),e.readSediment(),e.snapshot())}function qe(e){return Oe(e,e.tick(0))}var ke=function(){let e=new Me;return{handle(t){switch(t.type){case"init":return e=new Me(t.config),t.snapshot?e.restore(t.snapshot):t.initialSpawns?.length&&e.enqueue(t.initialSpawns,t.initialSpawnPacing),{type:"frame",frame:qe(e)};case"configure":return e.updateConfig(t.config),{type:"frame",frame:qe(e)};case"enqueue":return e.enqueue(t.spawns,t.pacing),{type:"frame",frame:qe(e)};case"tick":return{type:"frame",frame:Oe(e,e.tick(t.deltaSeconds))};case"settle":return{type:"frame",frame:Oe(e,e.settleWithObservations(t.maxSteps))};case"snapshot":return{type:"snapshot",snapshot:e.snapshot()};case"restore":return e.restore(t.snapshot),{type:"frame",frame:qe(e)};case"clear":return e.clear(),{type:"frame",frame:qe(e)};case"remove":return{type:"removed",removed:e.remove(t.ids),frame:qe(e)};case"applyImpulse":return e.applyImpulse(t.id,t.ix,t.iy),{type:"frame",frame:qe(e)};case"setPaused":return e.setPaused(t.paused),{type:"frame",frame:qe(e)};case"setVisible":return e.setVisible(t.visible),{type:"frame",frame:qe(e)}}}}}();function Pe(e){return e instanceof Error?{message:e.message,name:e.name,stack:e.stack}:{message:String(e)}}self.onmessage=e=>{const t=e.data;try{const e=ke.handle(t.command);self.postMessage({ok:!0,payload:e,requestId:t.requestId},function(e){return"frame"===e.type||"removed"===e.type?[(t=e.frame).positions.buffer,t.velocities.buffer,t.sleeping.buffer]:[];var t}(e))}catch(e){self.postMessage({error:Pe(e),ok:!1,requestId:t.requestId})}};
package/dist/rough.min.js CHANGED
@@ -1 +1,2 @@
1
- function e(t,r){if(!r)return r;const i=function(e){const t=e.trim();if(!t.startsWith("var(")||!t.endsWith(")"))return null;const r=t.slice(4,-1),i=r.indexOf(",");if(-1===i){const e=r.trim();return e.startsWith("--")?{name:e}:null}const n=r.slice(0,i).trim(),a=r.slice(i+1).trim();return n.startsWith("--")?{name:n,fallback:a||void 0}:null}(r);if(!i)return r;const n=()=>i.fallback?e(t,i.fallback):r,a=t.canvas;if(!a)return n();let o=D.get(a);o&&o.version===w||(o={version:w,map:new Map},D.set(a,o));const s=o.map.get(r);if(void 0!==s)return s;const l=getComputedStyle(a).getPropertyValue(i.name).trim()||n()||r;return o.map.set(r,l),l}function t(e){return"number"==typeof e&&Number.isFinite(e)}function r(e){if(!Array.isArray(e))return null;const r=[];for(const i of e){if(!Array.isArray(i)||!t(i[0])||!t(i[1]))return null;r.push([i[0],i[1]])}return r}function i(e){if(e.style?.icon||e.fillGradient||e.strokeGradient||e.colorThresholds||e.clipRect)return null;if("rect"===e.type&&t(e.x)&&t(e.y)&&t(e.w)&&t(e.h))return{kind:"rectangle",x:e.x,y:e.y,width:e.w,height:e.h};if("point"===e.type&&t(e.x)&&t(e.y)&&t(e.r))return{kind:"circle",x:e.x,y:e.y,diameter:2*e.r};if("circle"===e.type&&t(e.cx)&&t(e.cy)&&t(e.r))return{kind:"circle",x:e.cx,y:e.cy,diameter:2*e.r};if("line"===e.type){const i=r(e.path);if(i&&i.length>=2&&!e._decayOpacities)return{kind:"linearPath",points:i};if(t(e.x1)&&t(e.y1)&&t(e.x2)&&t(e.y2))return{kind:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2}}if("area"===e.type){const t=r(e.topPath),i=r(e.bottomPath);if(t&&i&&t.length>1&&i.length>1&&!e._decayOpacities)return{kind:"polygon",points:[...t,...i.slice().reverse()]}}if("geoarea"===e.type&&"string"==typeof e.pathData&&e.pathData)return{kind:"path",d:e.pathData};if(("bezier"===e.type||"ribbon"===e.type||"curved"===e.type)&&"string"==typeof e.pathD&&e.pathD)return{kind:"path",d:e.pathD};if("trapezoid"===e.type){const t=r(e.points);if(t&&t.length>=3)return{kind:"polygon",points:t}}if("connector"===e.type&&t(e.x1)&&t(e.y1)&&t(e.x2)&&t(e.y2))return{kind:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2};if("violin"===e.type&&"string"==typeof e.pathString&&t(e.translateX)&&t(e.translateY))return{kind:"path",d:e.pathString,transform:{x:e.translateX,y:e.translateY}};if("symbol"===e.type&&"string"==typeof e.path){const r=t(e.x)?e.x:e.cx,i=t(e.y)?e.y:e.cy;if(t(r)&&t(i))return{kind:"path",d:e.path,transform:{x:r,y:i,rotation:t(e.rotation)?e.rotation:void 0}}}return"arc"===e.type&&t(e.cx)&&t(e.cy)&&t(e.outerR)&&t(e.startAngle)&&t(e.endAngle)?{kind:"arc",x:e.cx,y:e.cy,width:2*e.outerR,height:2*e.outerR,start:e.startAngle,stop:e.endAngle,closed:!0}:null}function n(e,t=new WeakSet){if(null==e||"string"==typeof e||"boolean"==typeof e)return e;if("number"==typeof e)return Number.isFinite(e)?e:e+"";if("object"!=typeof e)return e+"";if(t.has(e))return"[Circular]";if(t.add(e),Array.isArray(e))return e.map(e=>n(e,t));const r=e;return Object.fromEntries(Object.keys(r).sort().map(e=>[e,n(r[e],t)]))}function a(e){return JSON.stringify(n(e))??e+""}function o(e){const t="string"==typeof e?e:a(e);let r=2166136261;for(let e=0;t.length>e;e+=1)r^=t.charCodeAt(e),r=Math.imul(r,16777619);return(r>>>0)%W+1}function s(e){const t=e.datum&&"object"==typeof e.datum?e.datum:void 0;return e._transitionKey??e.pointId??e.id??e.category??e.group??t?.id??t?.key??t?.name??null}function l(e){return{fill:"string"==typeof e.fill?e.fill:e.fill?"[CanvasPattern]":void 0,fillOpacity:e.fillOpacity,opacity:e.opacity,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.strokeDasharray,strokeLinecap:e.strokeLinecap}}function c(e){if(!e)return;const t=e.split(/[\s,]+/).map(Number).filter(Number.isFinite);return t.length?t:void 0}function f(e,t,r){switch(t.kind){case"rectangle":return e.rectangle(t.x,t.y,t.width,t.height,r);case"circle":return e.circle(t.x,t.y,t.diameter,r);case"line":return e.line(t.x1,t.y1,t.x2,t.y2,r);case"linearPath":return e.linearPath(t.points,r);case"polygon":return e.polygon(t.points,r);case"path":return e.path(t.d,r);case"arc":return e.arc(t.x,t.y,t.width,t.height,t.start,t.stop,t.closed,r)}}function u(e,t,r){e.beginPath();for(const i of t.ops){const t="number"!=typeof r||0>r?i.data:i.data.map(e=>+e.toFixed(r));"move"===i.op?e.moveTo(t[0],t[1]):"lineTo"===i.op?e.lineTo(t[0],t[1]):"bcurveTo"===i.op&&e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5])}}function p(r={}){function n(e,t){const r=i(e);return a({backend:"roughjs",identity:s(e),type:e.type,geometry:r,style:l(t),options:g,seed:y})}function p(t,r,l){const u=i(t);if(!u)return null;const p=function(e,t){if(t.fill&&"string"!=typeof t.fill)return null;if("string"==typeof t.fill&&t.fill.startsWith("url("))return null;const r="string"==typeof t.fill&&"none"!==t.fill?t.fill:void 0,i=t.stroke&&"none"!==t.stroke?t.stroke:void 0;switch(e.type){case"line":case"connector":case"curved":return{stroke:i??"#007bff"};case"bezier":case"ribbon":return{fill:r??"#999999",stroke:i??"none"};case"geoarea":return{fill:r??"#e0e0e0",stroke:i??"none"};case"point":case"circle":case"rect":case"area":case"trapezoid":case"violin":case"arc":return{fill:r??"#4e79a7",stroke:i??"none"};case"symbol":return{fill:r,stroke:i??(r?"none":"#4e79a7")};default:return{fill:r,stroke:i??"#007bff"}}}(t,r);if(!p)return null;const g=l?{fill:p.fill?e(l,p.fill)||p.fill:void 0,stroke:e(l,p.stroke)||p.stroke}:p,b=`${n(t,r)}:${a(g)}`,x=m.get(b);if(x)return m.delete(b),m.set(b,x),x;const v=o(`${y}:${s(t)??a(u)}`),O={...d,seed:v,fill:g.fill,stroke:g.stroke,strokeWidth:r.strokeWidth??1,strokeLineDash:c(r.strokeDasharray)},D={drawable:f(k,u,O),geometry:u,style:r};for(m.set(b,D);m.size>h;){const e=m.keys().next().value;if(void 0===e)break;m.delete(e)}return D}const y=function(e){return t(e)&&Math.trunc(Math.abs(e))%W||S}(r.seed),h=t(r.cacheSize)?Math.max(1,Math.trunc(r.cacheSize)):1e3,d=Object.fromEntries(Object.entries({roughness:r.roughness,bowing:r.bowing,maxRandomnessOffset:r.maxRandomnessOffset,curveFitting:r.curveFitting,curveTightness:r.curveTightness,curveStepCount:r.curveStepCount,fillStyle:r.fillStyle,fillWeight:r.fillWeight,hachureAngle:r.hachureAngle,hachureGap:r.hachureGap,dashOffset:r.dashOffset,dashGap:r.dashGap,zigzagOffset:r.zigzagOffset,disableMultiStroke:r.disableMultiStroke,disableMultiStrokeFill:r.disableMultiStrokeFill,preserveVertices:r.preserveVertices,simplification:r.simplification,fixedDecimalPlaceDigits:r.fixedDecimalPlaceDigits}).filter(([,e])=>void 0!==e)),g=a({...d,seed:y}),k=O.default.generator(),m=new Map,b={id:"roughjs",seed:y,cacheKey:n,drawCanvas({context:e,node:t,style:r}){const i=p(t,r,e);return!!i&&(function(e,t){const{drawable:r,geometry:i,style:n}=t,a=r.options,o=e.globalAlpha,s="path"===i.kind?i.transform:void 0;s&&(e.translate(s.x,s.y),s.rotation&&e.rotate(s.rotation));for(const t of r.sets){if(e.save(),"path"===t.type)e.strokeStyle="none"===a.stroke?"transparent":a.stroke,e.lineWidth=a.strokeWidth,e.globalAlpha=o*(n.opacity??1),a.strokeLineDash&&e.setLineDash(a.strokeLineDash),a.strokeLineDashOffset&&(e.lineDashOffset=a.strokeLineDashOffset),u(e,t,a.fixedDecimalPlaceDigits),e.stroke();else if("fillPath"===t.type)e.fillStyle=a.fill??"transparent",e.globalAlpha=o*(n.opacity??1)*(n.fillOpacity??1),u(e,t,a.fixedDecimalPlaceDigits),e.fill("curve"===r.shape||"polygon"===r.shape||"path"===r.shape?"evenodd":"nonzero");else{const r=0>a.fillWeight?a.strokeWidth/2:a.fillWeight;e.strokeStyle=a.fill??"transparent",e.lineWidth=r,e.globalAlpha=o*(n.opacity??1)*(n.fillOpacity??1),a.fillLineDash&&e.setLineDash(a.fillLineDash),a.fillLineDashOffset&&(e.lineDashOffset=a.fillLineDashOffset),u(e,t,a.fixedDecimalPlaceDigits),e.stroke()}e.restore()}}(e,i),!0)},renderStaticSVG({node:e,style:t,key:r}){const i=p(e,t);if(!i)return null;const n="path"===i.geometry.kind?i.geometry.transform:void 0,a=k.toPaths(i.drawable).map((e,i)=>(0,P.jsx)("path",{d:e.d,fill:e.fill??"none",fillOpacity:e.fill&&"none"!==e.fill?t.fillOpacity:void 0,stroke:e.stroke,strokeWidth:e.strokeWidth,opacity:t.opacity,strokeLinecap:t.strokeLinecap,strokeDasharray:t.strokeDasharray},`${r}-path-${i}`));return(0,P.jsx)("g",{"data-semiotic-render-backend":"roughjs",transform:n?`translate(${n.x} ${n.y})${n.rotation?` rotate(${180*n.rotation/Math.PI})`:""}`:void 0,children:a},r)},clearCache(){m.clear()},get cacheEntries(){return m.size}};return b}var y,h=Object.create,d=Object.defineProperty,g=Object.getOwnPropertyDescriptor,k=Object.getOwnPropertyNames,m=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty,x=(e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of k(t))b.call(e,n)||n===r||d(e,n,{get:()=>t[n],enumerable:!(i=g(t,n))||i.enumerable});return e},v={};((e,t)=>{for(var r in t)d(e,r,{get:t[r],enumerable:!0})})(v,{createRoughRenderMode:()=>p,stableRoughSeed:()=>o}),module.exports=(y=v,x(d({},"__esModule",{value:!0}),y));var O=((e,t,r)=>(r=null!=e?h(m(e)):{},x(e&&e.__esModule?r:d(r,"default",{value:e,enumerable:!0}),e)))(require("roughjs")),D=new WeakMap,w=0,P=require("react/jsx-runtime"),S=1,W=2147483647;
1
+ function e(e){const t=e.trim();if(!t.startsWith("var(")||!t.endsWith(")"))return null;const r=t.slice(4,-1),i=r.indexOf(",");if(-1===i){const e=r.trim();return e.startsWith("--")?{name:e}:null}const n=r.slice(0,i).trim(),a=r.slice(i+1).trim();return n.startsWith("--")?{name:n,fallback:a||void 0}:null}function t(r,i){if(!i)return i;const n=e(i);if(!n)return i;const a=()=>n.fallback?t(r,n.fallback):i,o=r.canvas;if(!o)return a();let s=W.get(o);s&&s.version===j||(s={version:j,map:/* @__PURE__ */new Map},W.set(o,s));const l=s.map.get(i);if(void 0!==l)return l;const c=getComputedStyle(o).getPropertyValue(n.name).trim()||a()||i;return s.map.set(i,c),c}function r(e){return"number"==typeof e&&Number.isFinite(e)}function i(e){if(!Array.isArray(e))return null;const t=[];for(const i of e){if(!Array.isArray(i)||!r(i[0])||!r(i[1]))return null;t.push([i[0],i[1]])}return t}function n(e){if(e.style?.icon||e.fillGradient||e.strokeGradient||e.colorThresholds||e.clipRect)return null;if("rect"===e.type&&r(e.x)&&r(e.y)&&r(e.w)&&r(e.h))return{kind:"rectangle",x:e.x,y:e.y,width:e.w,height:e.h};if("point"===e.type&&r(e.x)&&r(e.y)&&r(e.r))return{kind:"circle",x:e.x,y:e.y,diameter:2*e.r};if("circle"===e.type&&r(e.cx)&&r(e.cy)&&r(e.r))return{kind:"circle",x:e.cx,y:e.cy,diameter:2*e.r};if("line"===e.type){const t=i(e.path);if(t&&t.length>=2&&!e._decayOpacities)return{kind:"linearPath",points:t};if(r(e.x1)&&r(e.y1)&&r(e.x2)&&r(e.y2))return{kind:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2}}if("area"===e.type){const t=i(e.topPath),r=i(e.bottomPath);if(t&&r&&t.length>1&&r.length>1&&!e._decayOpacities)return{kind:"polygon",points:[...t,...r.slice().reverse()]}}if("geoarea"===e.type&&"string"==typeof e.pathData&&e.pathData)return{kind:"path",d:e.pathData};if(("bezier"===e.type||"ribbon"===e.type||"curved"===e.type)&&"string"==typeof e.pathD&&e.pathD)return{kind:"path",d:e.pathD};if("trapezoid"===e.type){const t=i(e.points);if(t&&t.length>=3)return{kind:"polygon",points:t}}if("connector"===e.type&&r(e.x1)&&r(e.y1)&&r(e.x2)&&r(e.y2))return{kind:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2};if("violin"===e.type&&"string"==typeof e.pathString&&r(e.translateX)&&r(e.translateY))return{kind:"path",d:e.pathString,transform:{x:e.translateX,y:e.translateY}};if("symbol"===e.type&&"string"==typeof e.path){const t=r(e.x)?e.x:e.cx,i=r(e.y)?e.y:e.cy;if(r(t)&&r(i))return{kind:"path",d:e.path,transform:{x:t,y:i,rotation:r(e.rotation)?e.rotation:void 0}}}return"arc"===e.type&&r(e.cx)&&r(e.cy)&&r(e.outerR)&&r(e.startAngle)&&r(e.endAngle)?{kind:"arc",x:e.cx,y:e.cy,width:2*e.outerR,height:2*e.outerR,start:e.startAngle,stop:e.endAngle,closed:!0}:null}function a(e,t=/* @__PURE__ */new WeakSet){if(null==e||"string"==typeof e||"boolean"==typeof e)return e;if("number"==typeof e)return Number.isFinite(e)?e:e+"";if("object"!=typeof e)return e+"";if(t.has(e))return"[Circular]";if(t.add(e),Array.isArray(e))return e.map(e=>a(e,t));const r=e;return Object.fromEntries(Object.keys(r).sort().map(e=>[e,a(r[e],t)]))}function o(e){return JSON.stringify(a(e))??e+""}function s(e){const t="string"==typeof e?e:o(e);let r=2166136261;for(let e=0;t.length>e;e+=1)r^=t.charCodeAt(e),r=Math.imul(r,16777619);return(r>>>0)%L+1}function l(e){return r(e)&&Math.trunc(Math.abs(e))%L||M}function c(e){const t=e.datum&&"object"==typeof e.datum?e.datum:void 0;return e._transitionKey??e.pointId??e.id??e.category??e.group??t?.id??t?.key??t?.name??null}function f(e){return{fill:"string"==typeof e.fill?e.fill:e.fill?"[CanvasPattern]":void 0,fillOpacity:e.fillOpacity,opacity:e.opacity,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.strokeDasharray,strokeLinecap:e.strokeLinecap}}function u(e){if(!e)return;const t=e.split(/[\s,]+/).map(Number).filter(Number.isFinite);return t.length?t:void 0}function p(e,t){if(t.fill&&"string"!=typeof t.fill)return null;if("string"==typeof t.fill&&t.fill.startsWith("url("))return null;const r="string"==typeof t.fill&&"none"!==t.fill?t.fill:void 0,i=t.stroke&&"none"!==t.stroke?t.stroke:void 0;switch(e.type){case"line":case"connector":case"curved":return{stroke:i??"#007bff"};case"bezier":case"ribbon":return{fill:r??"#999999",stroke:i??"none"};case"geoarea":return{fill:r??"#e0e0e0",stroke:i??"none"};case"point":case"circle":case"rect":case"area":case"trapezoid":case"violin":case"arc":return{fill:r??"#4e79a7",stroke:i??"none"};case"symbol":return{fill:r,stroke:i??(r?"none":"#4e79a7")};default:return{fill:r,stroke:i??"#007bff"}}}function y(e,t,r){switch(t.kind){case"rectangle":return e.rectangle(t.x,t.y,t.width,t.height,r);case"circle":return e.circle(t.x,t.y,t.diameter,r);case"line":return e.line(t.x1,t.y1,t.x2,t.y2,r);case"linearPath":return e.linearPath(t.points,r);case"polygon":return e.polygon(t.points,r);case"path":return e.path(t.d,r);case"arc":return e.arc(t.x,t.y,t.width,t.height,t.start,t.stop,t.closed,r)}}function h(e,t,r){e.beginPath();for(const i of t.ops){const t="number"!=typeof r||0>r?i.data:i.data.map(e=>+e.toFixed(r));"move"===i.op?e.moveTo(t[0],t[1]):"lineTo"===i.op?e.lineTo(t[0],t[1]):"bcurveTo"===i.op&&e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5])}}function d(e,t){const{drawable:r,geometry:i,style:n}=t,a=r.options,o=e.globalAlpha,s="path"===i.kind?i.transform:void 0;s&&(e.translate(s.x,s.y),s.rotation&&e.rotate(s.rotation));for(const t of r.sets){if(e.save(),"path"===t.type)e.strokeStyle="none"===a.stroke?"transparent":a.stroke,e.lineWidth=a.strokeWidth,e.globalAlpha=o*(n.opacity??1),a.strokeLineDash&&e.setLineDash(a.strokeLineDash),a.strokeLineDashOffset&&(e.lineDashOffset=a.strokeLineDashOffset),h(e,t,a.fixedDecimalPlaceDigits),e.stroke();else if("fillPath"===t.type)e.fillStyle=a.fill??"transparent",e.globalAlpha=o*(n.opacity??1)*(n.fillOpacity??1),h(e,t,a.fixedDecimalPlaceDigits),e.fill("curve"===r.shape||"polygon"===r.shape||"path"===r.shape?"evenodd":"nonzero");else{const r=0>a.fillWeight?a.strokeWidth/2:a.fillWeight;e.strokeStyle=a.fill??"transparent",e.lineWidth=r,e.globalAlpha=o*(n.opacity??1)*(n.fillOpacity??1),a.fillLineDash&&e.setLineDash(a.fillLineDash),a.fillLineDashOffset&&(e.lineDashOffset=a.fillLineDashOffset),h(e,t,a.fixedDecimalPlaceDigits),e.stroke()}e.restore()}}function g(e={}){function i(e,t){const r=n(e);return o({backend:"roughjs",identity:c(e),type:e.type,geometry:r,style:f(t),options:m,seed:h})}function a(e,r,a){const l=n(e);if(!l)return null;const f=p(e,r);if(!f)return null;const d=a?{fill:f.fill?t(a,f.fill)||f.fill:void 0,stroke:t(a,f.stroke)||f.stroke}:f,m=`${i(e,r)}:${o(d)}`,v=x.get(m);if(v)return x.delete(m),x.set(m,v),v;const O=s(`${h}:${c(e)??o(l)}`),D={...k,seed:O,fill:d.fill,stroke:d.stroke,strokeWidth:r.strokeWidth??1,strokeLineDash:u(r.strokeDasharray)},w={drawable:y(b,l,D),geometry:l,style:r};for(x.set(m,w);x.size>g;){const e=x.keys().next().value;if(void 0===e)break;x.delete(e)}return w}const h=l(e.seed),g=r(e.cacheSize)?Math.max(1,Math.trunc(e.cacheSize)):1e3,k=Object.fromEntries(Object.entries({roughness:e.roughness,bowing:e.bowing,maxRandomnessOffset:e.maxRandomnessOffset,curveFitting:e.curveFitting,curveTightness:e.curveTightness,curveStepCount:e.curveStepCount,fillStyle:e.fillStyle,fillWeight:e.fillWeight,hachureAngle:e.hachureAngle,hachureGap:e.hachureGap,dashOffset:e.dashOffset,dashGap:e.dashGap,zigzagOffset:e.zigzagOffset,disableMultiStroke:e.disableMultiStroke,disableMultiStrokeFill:e.disableMultiStrokeFill,preserveVertices:e.preserveVertices,simplification:e.simplification,fixedDecimalPlaceDigits:e.fixedDecimalPlaceDigits}).filter(([,e])=>void 0!==e)),m=o({...k,seed:h}),b=S.default.generator(),x=/* @__PURE__ */new Map;return{id:"roughjs",seed:h,cacheKey:i,drawCanvas({context:e,node:t,style:r}){const i=a(t,r,e);return!!i&&(d(e,i),!0)},renderStaticSVG({node:e,style:t,key:r}){const i=a(e,t);if(!i)return null;const n="path"===i.geometry.kind?i.geometry.transform:void 0,o=b.toPaths(i.drawable).map((e,i)=>/* @__PURE__ */ /* @__PURE__ */(0,A.jsx)("path",{d:e.d,fill:e.fill??"none",fillOpacity:e.fill&&"none"!==e.fill?t.fillOpacity:void 0,stroke:e.stroke,strokeWidth:e.strokeWidth,opacity:t.opacity,strokeLinecap:t.strokeLinecap,strokeDasharray:t.strokeDasharray},`${r}-path-${i}`));/* @__PURE__ */ /* @__PURE__ */
2
+ return(0,A.jsx)("g",{"data-semiotic-render-backend":"roughjs",transform:n?`translate(${n.x} ${n.y})${n.rotation?` rotate(${180*n.rotation/Math.PI})`:""}`:void 0,children:o},r)},clearCache(){x.clear()},get cacheEntries(){return x.size}}}var k,m=Object.create,b=Object.defineProperty,x=Object.getOwnPropertyDescriptor,v=Object.getOwnPropertyNames,O=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty,w=(e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of v(t))D.call(e,n)||n===r||b(e,n,{get:()=>t[n],enumerable:!(i=x(t,n))||i.enumerable});return e},P={};((e,t)=>{for(var r in t)b(e,r,{get:t[r],enumerable:!0})})(P,{createRoughRenderMode:()=>g,stableRoughSeed:()=>s}),module.exports=(k=P,w(b({},"__esModule",{value:!0}),k));var S=((e,t,r)=>(r=null!=e?m(O(e)):{},w(e&&e.__esModule?r:b(r,"default",{value:e,enumerable:!0}),e)))(require("roughjs")),W=/* @__PURE__ */new WeakMap,j=0,A=require("react/jsx-runtime"),M=1,L=2147483647;
@@ -1 +1,2 @@
1
- function e(e){return"number"==typeof e&&Number.isFinite(e)}function t(t){if(!Array.isArray(t))return null;let r=[];for(let i of t){if(!Array.isArray(i)||!e(i[0])||!e(i[1]))return null;r.push([i[0],i[1]])}return r}function r(r){if(r.style?.icon||r.fillGradient||r.strokeGradient||r.colorThresholds||r.clipRect)return null;if("rect"===r.type&&e(r.x)&&e(r.y)&&e(r.w)&&e(r.h))return{kind:"rectangle",x:r.x,y:r.y,width:r.w,height:r.h};if("point"===r.type&&e(r.x)&&e(r.y)&&e(r.r))return{kind:"circle",x:r.x,y:r.y,diameter:2*r.r};if("circle"===r.type&&e(r.cx)&&e(r.cy)&&e(r.r))return{kind:"circle",x:r.cx,y:r.cy,diameter:2*r.r};if("line"===r.type){let i=t(r.path);if(i&&i.length>=2&&!r._decayOpacities)return{kind:"linearPath",points:i};if(e(r.x1)&&e(r.y1)&&e(r.x2)&&e(r.y2))return{kind:"line",x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2}}if("area"===r.type){let e=t(r.topPath),i=t(r.bottomPath);if(e&&i&&e.length>1&&i.length>1&&!r._decayOpacities)return{kind:"polygon",points:[...e,...i.slice().reverse()]}}if("geoarea"===r.type&&"string"==typeof r.pathData&&r.pathData)return{kind:"path",d:r.pathData};if(("bezier"===r.type||"ribbon"===r.type||"curved"===r.type)&&"string"==typeof r.pathD&&r.pathD)return{kind:"path",d:r.pathD};if("trapezoid"===r.type){let e=t(r.points);if(e&&e.length>=3)return{kind:"polygon",points:e}}if("connector"===r.type&&e(r.x1)&&e(r.y1)&&e(r.x2)&&e(r.y2))return{kind:"line",x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2};if("violin"===r.type&&"string"==typeof r.pathString&&e(r.translateX)&&e(r.translateY))return{kind:"path",d:r.pathString,transform:{x:r.translateX,y:r.translateY}};if("symbol"===r.type&&"string"==typeof r.path){let t=e(r.x)?r.x:r.cx,i=e(r.y)?r.y:r.cy;if(e(t)&&e(i))return{kind:"path",d:r.path,transform:{x:t,y:i,rotation:e(r.rotation)?r.rotation:void 0}}}return"arc"===r.type&&e(r.cx)&&e(r.cy)&&e(r.outerR)&&e(r.startAngle)&&e(r.endAngle)?{kind:"arc",x:r.cx,y:r.cy,width:2*r.outerR,height:2*r.outerR,start:r.startAngle,stop:r.endAngle,closed:!0}:null}function i(e,t=new WeakSet){if(null==e||"string"==typeof e||"boolean"==typeof e)return e;if("number"==typeof e)return Number.isFinite(e)?e:e+"";if("object"!=typeof e)return e+"";if(t.has(e))return"[Circular]";if(t.add(e),Array.isArray(e))return e.map(e=>i(e,t));let r=e;return Object.fromEntries(Object.keys(r).sort().map(e=>[e,i(r[e],t)]))}function n(e){return JSON.stringify(i(e))??e+""}function a(e){let t="string"==typeof e?e:n(e),r=2166136261;for(let e=0;t.length>e;e+=1)r^=t.charCodeAt(e),r=Math.imul(r,16777619);return(r>>>0)%d+1}function l(e){let t=e.datum&&"object"==typeof e.datum?e.datum:void 0;return e._transitionKey??e.pointId??e.id??e.category??e.group??t?.id??t?.key??t?.name??null}function o(e){return{fill:"string"==typeof e.fill?e.fill:e.fill?"[CanvasPattern]":void 0,fillOpacity:e.fillOpacity,opacity:e.opacity,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.strokeDasharray,strokeLinecap:e.strokeLinecap}}function s(e){if(!e)return;let t=e.split(/[\s,]+/).map(Number).filter(Number.isFinite);return t.length?t:void 0}function f(e,t,r){switch(t.kind){case"rectangle":return e.rectangle(t.x,t.y,t.width,t.height,r);case"circle":return e.circle(t.x,t.y,t.diameter,r);case"line":return e.line(t.x1,t.y1,t.x2,t.y2,r);case"linearPath":return e.linearPath(t.points,r);case"polygon":return e.polygon(t.points,r);case"path":return e.path(t.d,r);case"arc":return e.arc(t.x,t.y,t.width,t.height,t.start,t.stop,t.closed,r)}}function c(e,t,r){e.beginPath();for(let i of t.ops){let t="number"!=typeof r||0>r?i.data:i.data.map(e=>+e.toFixed(r));"move"===i.op?e.moveTo(t[0],t[1]):"lineTo"===i.op?e.lineTo(t[0],t[1]):"bcurveTo"===i.op&&e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5])}}function p(t={}){function i(e,t){let i=r(e);return n({backend:"roughjs",identity:l(e),type:e.type,geometry:i,style:o(t),options:x,seed:g})}function p(e,t,o){let c=r(e);if(!c)return null;let p=function(e,t){if(t.fill&&"string"!=typeof t.fill||"string"==typeof t.fill&&t.fill.startsWith("url("))return null;let r="string"==typeof t.fill&&"none"!==t.fill?t.fill:void 0,i=t.stroke&&"none"!==t.stroke?t.stroke:void 0;switch(e.type){case"line":case"connector":case"curved":return{stroke:i??"#007bff"};case"bezier":case"ribbon":return{fill:r??"#999999",stroke:i??"none"};case"geoarea":return{fill:r??"#e0e0e0",stroke:i??"none"};case"point":case"circle":case"rect":case"area":case"trapezoid":case"violin":case"arc":return{fill:r??"#4e79a7",stroke:i??"none"};case"symbol":return{fill:r,stroke:i??(r?"none":"#4e79a7")};default:return{fill:r,stroke:i??"#007bff"}}}(e,t);if(!p)return null;let h=o?{fill:p.fill?u(o,p.fill)||p.fill:void 0,stroke:u(o,p.stroke)||p.stroke}:p,y=`${i(e,t)}:${n(h)}`,d=v.get(y);if(d)return v.delete(y),v.set(y,d),d;let x=a(`${g}:${l(e)??n(c)}`),D={...m,seed:x,fill:h.fill,stroke:h.stroke,strokeWidth:t.strokeWidth??1,strokeLineDash:s(t.strokeDasharray)},O={drawable:f(b,c,D),geometry:c,style:t};for(v.set(y,O);v.size>k;){let e=v.keys().next().value;if(void 0===e)break;v.delete(e)}return O}let g=function(t){return e(t)&&Math.trunc(Math.abs(t))%d||1}(t.seed),k=e(t.cacheSize)?Math.max(1,Math.trunc(t.cacheSize)):1e3,m=Object.fromEntries(Object.entries({roughness:t.roughness,bowing:t.bowing,maxRandomnessOffset:t.maxRandomnessOffset,curveFitting:t.curveFitting,curveTightness:t.curveTightness,curveStepCount:t.curveStepCount,fillStyle:t.fillStyle,fillWeight:t.fillWeight,hachureAngle:t.hachureAngle,hachureGap:t.hachureGap,dashOffset:t.dashOffset,dashGap:t.dashGap,zigzagOffset:t.zigzagOffset,disableMultiStroke:t.disableMultiStroke,disableMultiStrokeFill:t.disableMultiStrokeFill,preserveVertices:t.preserveVertices,simplification:t.simplification,fixedDecimalPlaceDigits:t.fixedDecimalPlaceDigits}).filter(([,e])=>void 0!==e)),x=n({...m,seed:g}),b=h.generator(),v=new Map;return{id:"roughjs",seed:g,cacheKey:i,drawCanvas({context:e,node:t,style:r}){let i=p(t,r,e);return!!i&&(function(e,t){let{drawable:r,geometry:i,style:n}=t,a=r.options,l=e.globalAlpha,o="path"===i.kind?i.transform:void 0;o&&(e.translate(o.x,o.y),o.rotation&&e.rotate(o.rotation));for(let t of r.sets){if(e.save(),"path"===t.type)e.strokeStyle="none"===a.stroke?"transparent":a.stroke,e.lineWidth=a.strokeWidth,e.globalAlpha=l*(n.opacity??1),a.strokeLineDash&&e.setLineDash(a.strokeLineDash),a.strokeLineDashOffset&&(e.lineDashOffset=a.strokeLineDashOffset),c(e,t,a.fixedDecimalPlaceDigits),e.stroke();else if("fillPath"===t.type)e.fillStyle=a.fill??"transparent",e.globalAlpha=l*(n.opacity??1)*(n.fillOpacity??1),c(e,t,a.fixedDecimalPlaceDigits),e.fill("curve"===r.shape||"polygon"===r.shape||"path"===r.shape?"evenodd":"nonzero");else{let r=0>a.fillWeight?a.strokeWidth/2:a.fillWeight;e.strokeStyle=a.fill??"transparent",e.lineWidth=r,e.globalAlpha=l*(n.opacity??1)*(n.fillOpacity??1),a.fillLineDash&&e.setLineDash(a.fillLineDash),a.fillLineDashOffset&&(e.lineDashOffset=a.fillLineDashOffset),c(e,t,a.fixedDecimalPlaceDigits),e.stroke()}e.restore()}}(e,i),!0)},renderStaticSVG({node:e,style:t,key:r}){let i=p(e,t);if(!i)return null;let n="path"===i.geometry.kind?i.geometry.transform:void 0,a=b.toPaths(i.drawable).map((e,i)=>y("path",{d:e.d,fill:e.fill??"none",fillOpacity:e.fill&&"none"!==e.fill?t.fillOpacity:void 0,stroke:e.stroke,strokeWidth:e.strokeWidth,opacity:t.opacity,strokeLinecap:t.strokeLinecap,strokeDasharray:t.strokeDasharray},`${r}-path-${i}`));return y("g",{"data-semiotic-render-backend":"roughjs",transform:n?`translate(${n.x} ${n.y})${n.rotation?` rotate(${180*n.rotation/Math.PI})`:""}`:void 0,children:a},r)},clearCache(){v.clear()},get cacheEntries(){return v.size}}}import{resolveCSSColor as u}from"./c-UC7SIU2W.min.js";import h from"roughjs";import{jsx as y}from"react/jsx-runtime";var d=2147483647;export{p as createRoughRenderMode,a as stableRoughSeed};
1
+ function e(e){return"number"==typeof e&&Number.isFinite(e)}function t(t){if(!Array.isArray(t))return null;let r=[];for(let i of t){if(!Array.isArray(i)||!e(i[0])||!e(i[1]))return null;r.push([i[0],i[1]])}return r}function r(r){if(r.style?.icon||r.fillGradient||r.strokeGradient||r.colorThresholds||r.clipRect)return null;if("rect"===r.type&&e(r.x)&&e(r.y)&&e(r.w)&&e(r.h))return{kind:"rectangle",x:r.x,y:r.y,width:r.w,height:r.h};if("point"===r.type&&e(r.x)&&e(r.y)&&e(r.r))return{kind:"circle",x:r.x,y:r.y,diameter:2*r.r};if("circle"===r.type&&e(r.cx)&&e(r.cy)&&e(r.r))return{kind:"circle",x:r.cx,y:r.cy,diameter:2*r.r};if("line"===r.type){let i=t(r.path);if(i&&i.length>=2&&!r._decayOpacities)return{kind:"linearPath",points:i};if(e(r.x1)&&e(r.y1)&&e(r.x2)&&e(r.y2))return{kind:"line",x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2}}if("area"===r.type){let e=t(r.topPath),i=t(r.bottomPath);if(e&&i&&e.length>1&&i.length>1&&!r._decayOpacities)return{kind:"polygon",points:[...e,...i.slice().reverse()]}}if("geoarea"===r.type&&"string"==typeof r.pathData&&r.pathData)return{kind:"path",d:r.pathData};if(("bezier"===r.type||"ribbon"===r.type||"curved"===r.type)&&"string"==typeof r.pathD&&r.pathD)return{kind:"path",d:r.pathD};if("trapezoid"===r.type){let e=t(r.points);if(e&&e.length>=3)return{kind:"polygon",points:e}}if("connector"===r.type&&e(r.x1)&&e(r.y1)&&e(r.x2)&&e(r.y2))return{kind:"line",x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2};if("violin"===r.type&&"string"==typeof r.pathString&&e(r.translateX)&&e(r.translateY))return{kind:"path",d:r.pathString,transform:{x:r.translateX,y:r.translateY}};if("symbol"===r.type&&"string"==typeof r.path){let t=e(r.x)?r.x:r.cx,i=e(r.y)?r.y:r.cy;if(e(t)&&e(i))return{kind:"path",d:r.path,transform:{x:t,y:i,rotation:e(r.rotation)?r.rotation:void 0}}}return"arc"===r.type&&e(r.cx)&&e(r.cy)&&e(r.outerR)&&e(r.startAngle)&&e(r.endAngle)?{kind:"arc",x:r.cx,y:r.cy,width:2*r.outerR,height:2*r.outerR,start:r.startAngle,stop:r.endAngle,closed:!0}:null}function i(e,t=/* @__PURE__ */new WeakSet){if(null==e||"string"==typeof e||"boolean"==typeof e)return e;if("number"==typeof e)return Number.isFinite(e)?e:e+"";if("object"!=typeof e)return e+"";if(t.has(e))return"[Circular]";if(t.add(e),Array.isArray(e))return e.map(e=>i(e,t));let r=e;return Object.fromEntries(Object.keys(r).sort().map(e=>[e,i(r[e],t)]))}function n(e){return JSON.stringify(i(e))??e+""}function a(e){let t="string"==typeof e?e:n(e),r=2166136261;for(let e=0;t.length>e;e+=1)r^=t.charCodeAt(e),r=Math.imul(r,16777619);return(r>>>0)%m+1}function l(t){return e(t)&&Math.trunc(Math.abs(t))%m||1}function o(e){let t=e.datum&&"object"==typeof e.datum?e.datum:void 0;return e._transitionKey??e.pointId??e.id??e.category??e.group??t?.id??t?.key??t?.name??null}function s(e){return{fill:"string"==typeof e.fill?e.fill:e.fill?"[CanvasPattern]":void 0,fillOpacity:e.fillOpacity,opacity:e.opacity,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.strokeDasharray,strokeLinecap:e.strokeLinecap}}function f(e){if(!e)return;let t=e.split(/[\s,]+/).map(Number).filter(Number.isFinite);return t.length?t:void 0}function c(e,t){if(t.fill&&"string"!=typeof t.fill||"string"==typeof t.fill&&t.fill.startsWith("url("))return null;let r="string"==typeof t.fill&&"none"!==t.fill?t.fill:void 0,i=t.stroke&&"none"!==t.stroke?t.stroke:void 0;switch(e.type){case"line":case"connector":case"curved":return{stroke:i??"#007bff"};case"bezier":case"ribbon":return{fill:r??"#999999",stroke:i??"none"};case"geoarea":return{fill:r??"#e0e0e0",stroke:i??"none"};case"point":case"circle":case"rect":case"area":case"trapezoid":case"violin":case"arc":return{fill:r??"#4e79a7",stroke:i??"none"};case"symbol":return{fill:r,stroke:i??(r?"none":"#4e79a7")};default:return{fill:r,stroke:i??"#007bff"}}}function p(e,t,r){switch(t.kind){case"rectangle":return e.rectangle(t.x,t.y,t.width,t.height,r);case"circle":return e.circle(t.x,t.y,t.diameter,r);case"line":return e.line(t.x1,t.y1,t.x2,t.y2,r);case"linearPath":return e.linearPath(t.points,r);case"polygon":return e.polygon(t.points,r);case"path":return e.path(t.d,r);case"arc":return e.arc(t.x,t.y,t.width,t.height,t.start,t.stop,t.closed,r)}}function u(e,t,r){e.beginPath();for(let i of t.ops){let t="number"!=typeof r||0>r?i.data:i.data.map(e=>+e.toFixed(r));"move"===i.op?e.moveTo(t[0],t[1]):"lineTo"===i.op?e.lineTo(t[0],t[1]):"bcurveTo"===i.op&&e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5])}}function h(e,t){let{drawable:r,geometry:i,style:n}=t,a=r.options,l=e.globalAlpha,o="path"===i.kind?i.transform:void 0;o&&(e.translate(o.x,o.y),o.rotation&&e.rotate(o.rotation));for(let t of r.sets){if(e.save(),"path"===t.type)e.strokeStyle="none"===a.stroke?"transparent":a.stroke,e.lineWidth=a.strokeWidth,e.globalAlpha=l*(n.opacity??1),a.strokeLineDash&&e.setLineDash(a.strokeLineDash),a.strokeLineDashOffset&&(e.lineDashOffset=a.strokeLineDashOffset),u(e,t,a.fixedDecimalPlaceDigits),e.stroke();else if("fillPath"===t.type)e.fillStyle=a.fill??"transparent",e.globalAlpha=l*(n.opacity??1)*(n.fillOpacity??1),u(e,t,a.fixedDecimalPlaceDigits),e.fill("curve"===r.shape||"polygon"===r.shape||"path"===r.shape?"evenodd":"nonzero");else{let r=0>a.fillWeight?a.strokeWidth/2:a.fillWeight;e.strokeStyle=a.fill??"transparent",e.lineWidth=r,e.globalAlpha=l*(n.opacity??1)*(n.fillOpacity??1),a.fillLineDash&&e.setLineDash(a.fillLineDash),a.fillLineDashOffset&&(e.lineDashOffset=a.fillLineDashOffset),u(e,t,a.fixedDecimalPlaceDigits),e.stroke()}e.restore()}}function y(t={}){function i(e,t){let i=r(e);return n({backend:"roughjs",identity:o(e),type:e.type,geometry:i,style:s(t),options:b,seed:y})}function u(e,t,l){let s=r(e);if(!s)return null;let u=c(e,t);if(!u)return null;let h=l?{fill:u.fill?d(l,u.fill)||u.fill:void 0,stroke:d(l,u.stroke)||u.stroke}:u,g=`${i(e,t)}:${n(h)}`,k=D.get(g);if(k)return D.delete(g),D.set(g,k),k;let b=a(`${y}:${o(e)??n(s)}`),O={...x,seed:b,fill:h.fill,stroke:h.stroke,strokeWidth:t.strokeWidth??1,strokeLineDash:f(t.strokeDasharray)},S={drawable:p(v,s,O),geometry:s,style:t};for(D.set(g,S);D.size>m;){let e=D.keys().next().value;if(void 0===e)break;D.delete(e)}return S}let y=l(t.seed),m=e(t.cacheSize)?Math.max(1,Math.trunc(t.cacheSize)):1e3,x=Object.fromEntries(Object.entries({roughness:t.roughness,bowing:t.bowing,maxRandomnessOffset:t.maxRandomnessOffset,curveFitting:t.curveFitting,curveTightness:t.curveTightness,curveStepCount:t.curveStepCount,fillStyle:t.fillStyle,fillWeight:t.fillWeight,hachureAngle:t.hachureAngle,hachureGap:t.hachureGap,dashOffset:t.dashOffset,dashGap:t.dashGap,zigzagOffset:t.zigzagOffset,disableMultiStroke:t.disableMultiStroke,disableMultiStrokeFill:t.disableMultiStrokeFill,preserveVertices:t.preserveVertices,simplification:t.simplification,fixedDecimalPlaceDigits:t.fixedDecimalPlaceDigits}).filter(([,e])=>void 0!==e)),b=n({...x,seed:y}),v=g.generator(),D=/* @__PURE__ */new Map;return{id:"roughjs",seed:y,cacheKey:i,drawCanvas({context:e,node:t,style:r}){let i=u(t,r,e);return!!i&&(h(e,i),!0)},renderStaticSVG({node:e,style:t,key:r}){let i=u(e,t);if(!i)return null;let n="path"===i.geometry.kind?i.geometry.transform:void 0,a=v.toPaths(i.drawable).map((e,i)=>/* @__PURE__ */k("path",{d:e.d,fill:e.fill??"none",fillOpacity:e.fill&&"none"!==e.fill?t.fillOpacity:void 0,stroke:e.stroke,strokeWidth:e.strokeWidth,opacity:t.opacity,strokeLinecap:t.strokeLinecap,strokeDasharray:t.strokeDasharray},`${r}-path-${i}`));/* @__PURE__ */
2
+ return k("g",{"data-semiotic-render-backend":"roughjs",transform:n?`translate(${n.x} ${n.y})${n.rotation?` rotate(${180*n.rotation/Math.PI})`:""}`:void 0,children:a},r)},clearCache(){D.clear()},get cacheEntries(){return D.size}}}import{a as d}from"./c-3FOUMWLR.min.js";import g from"roughjs";import{jsx as k}from"react/jsx-runtime";var m=2147483647;export{y as createRoughRenderMode,a as stableRoughSeed};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- function e(e,t){return!0===e?.supportsAccessibleTable&&!1!==t.accessibleTable}function t(e){return"string"==typeof e&&e.trim().length>0}function a(e){if(0===e.length)return;let t=e.map(e=>"idle"===e.status?"no data received":"active"===e.status?"receiving data":"not receiving new data"),a=[...new Set(t)],r=1===a.length?a[0]:t.join(", then ");return`Last ${e.length} stream ${1===e.length?"status":"statuses"}: ${r}.`}function r(e,t){return e?!e.supportsLegend||!1===t.showLegend||!0!==t.showLegend&&null==t.legend&&!["colorBy","lineBy","areaBy","stackBy","groupBy"].some(e=>null!=t[e])?"not-applicable":"isolate"===t.legendInteraction||"highlight"===t.legendInteraction?"built-in":"not-enabled":"unsupported"}function i({component:i,props:u,options:d={}}){let p=c[i],h=p?p.realtime:!0===d.realtime,m=s(i,u,{...d.locale?{locale:d.locale}:{}}),g=l(i,u),v=g||!0===p?.recipeNavigation,b=g&&!1!==d.navigable?o(i,u,{...d.locale?{locale:d.locale}:{}}):void 0,C=n(i,u,{inChartContainer:!0===d.inChartContainer,describe:!0===d.describe||t(u.summary),navigable:!1!==d.navigable&&v}),y=h?function(e){let t=e?.streamStatus;return t?(Array.isArray(t)?t:[t]).filter(e=>!!e&&"string"==typeof e.status).slice(-(e?.streamHistoryLimit??5)):[]}(d):[],f=function(e,t){return e?"delegated"===e.markNavigation||"not-applicable"===e.markNavigation?e.markNavigation:t?"built-in":"unsupported":"unsupported"}(p,v);return{schemaVersion:1,component:i,text:{...t(u.title)?{title:u.title}:{},...t(u.description)?{description:u.description}:{},...t(u.summary)?{summary:u.summary}:{},accessibleTable:e(p,u)},keyboard:{markNavigation:f,legendInteraction:r(p,u),focusRing:f},navigation:{supported:v,composition:"chart-container",...b?{tree:b}:void 0,...b?{}:{note:v?g?"Structured datum navigation is available through ChartContainer; enable its navigable option to materialize the tree.":"Structured datum navigation is declared for this built-in recipe; load its recipe manifest through semiotic/ai before materializing the tree.":"No datum-level structured navigation is registered for this chart. Exact-value table access may still be available."}},table:{enabled:e(p,u),source:"scene",pagination:"built-in"},mediaPreferences:{reducedMotion:p?"built-in":"unknown",forcedColors:p?"css-custom-properties":"unknown",note:p?"Runtime detection is available through useReducedMotion and useHighContrast; canvas styling uses CSS custom properties so forced-colors changes cascade.":"No generated runtime capability record exists for this component; media-preference support is unknown."},streamStatus:h?{supported:!0,status:y.at(-1)?.status??"idle",lastPushTime:y.at(-1)?.lastPushTime??null,history:y,historyLimit:d.streamHistoryLimit??5,...a(y)?{accessibleDescription:a(y)}:{},note:"Hosts may expose this bounded, non-visible description to screen readers or agents. Do not render it in visible UI."}:{supported:!1,note:"Static chart; no push-ingest lifecycle."},ssr:!0===p?.supportsSSR?{supported:!0,evidence:d.ssrEvidence,note:d.ssrEvidence?"Server rendering is registered and attached render evidence records the observed scene.":"Server rendering is registered; supply renderChartWithEvidence output before claiming a non-empty scene."}:{supported:!1,...d.ssrEvidence?{evidence:d.ssrEvidence}:{},note:h?"Live push charts intentionally omit static SSR; capture a supported bounded-window static twin before claiming server evidence.":p?"The chart capability registry does not expose this component through renderChart; do not claim server evidence for the HOC surface.":"No generated capability record exists for this component; SSR support is unknown and therefore reported as unsupported."},evidence:{audit:C,description:m}}}import{auditAccessibility as n}from"./c-HYDTS5OP.min.js";import{buildNavigationTree as o,describeChart as s,supportsStructuredNavigation as l}from"./c-2WK7YJLL.min.js";var c=Object.freeze(Object.fromEntries([["AreaChart",13],["BubbleChart",13],["BumpChart",13],["CandlestickChart",13],["ConnectedScatterplot",13],["DifferenceChart",13],["Heatmap",13],["LineChart",13],["MinimapChart",13,"delegated"],["MultiAxisLineChart",13],["QuadrantChart",13],["Scatterplot",13],["ScatterplotMatrix",13,"delegated"],["StackedAreaChart",13],["WaterfallChart",13],["BarChart",13],["BoxPlot",13],["DonutChart",13],["DotPlot",13],["FunnelChart",13],["GaugeChart",5],["GroupedBarChart",13],["Histogram",13],["LikertChart",13],["PieChart",13],["RadarChart",13],["RidgelinePlot",13],["StackedBarChart",13],["SwarmPlot",13],["SwimlaneChart",13],["ViolinPlot",13],["ChordDiagram",13],["CirclePack",13],["DependencyForestChart",1],["ForceDirectedGraph",13],["MotifBraidChart",1],["OrbitDiagram",13],["ProcessSankey",13],["SankeyDiagram",13],["TreeDiagram",13],["Treemap",13],["ChoroplethMap",13],["DistanceCartogram",13],["FlowMap",13],["ProportionalSymbolMap",13],["RealtimeHeatmap",14],["RealtimeHistogram",14],["RealtimeLineChart",14],["RealtimeSwarmChart",14],["RealtimeWaterfallChart",14],["TemporalHistogram",13],["ChainReactionChart",5],["CollisionSwarmChart",13],["CrucibleChart",5],["EventDropChart",13],["FlowCircuitChart",1],["GaltonBoardChart",13],["GauntletChart",5],["PacketFlowChart",13],["ProcessFlowChart",13],["UnitPileChart",13],["BigNumber",1,"not-applicable"],["ParallelCoordinatesRecipe",21],["CalendarHeatmapRecipe",21]].map(([e,t,a="unsupported"])=>[e,{supportsSSR:!!(1&t),realtime:!!(2&t),supportsAccessibleTable:!!(4&t),supportsLegend:!!(8&t),...16&t?{recipeNavigation:!0}:{},markNavigation:a}]))),u=1,d=i({component:"LineChart",props:{data:[{date:"2026-01-01",value:12},{date:"2026-02-01",value:18},{date:"2026-03-01",value:15}],xAccessor:"date",yAccessor:"value",title:"Weekly active users",description:"Daily active users from January through March, with a February peak.",summary:"Use keyboard mark navigation to inspect each point; the linked table lists exact values."},options:{navigable:!0}}),p=i({component:"BarChart",props:{data:[{region:"North",total:42},{region:"South",total:31},{region:"East",total:27}],categoryAccessor:"region",valueAccessor:"total",title:"Orders by region",description:"Three regions compared by order count; North leads and East trails.",summary:"The accessible table preserves category labels and numeric totals for exact reading."},options:{navigable:!0}}),h=i({component:"RealtimeLineChart",props:{data:[{time:1,value:4},{time:2,value:7}],timeAccessor:"time",valueAccessor:"value",title:"Requests per second",description:"A bounded live window of requests per second with stale-state indication available through useStreamStatus.",summary:"The current window is exposed as an accessible table; status changes should be announced by the host application."},options:{realtime:!0,navigable:!1,streamStatus:[{status:"idle",lastPushTime:null},{status:"active",lastPushTime:1e3},{status:"active",lastPushTime:2e3},{status:"active",lastPushTime:3e3},{status:"stale",lastPushTime:4e3}],streamHistoryLimit:5}});export{p as BAR_CHART_ACCESS_CONTRACT,u as CHART_ACCESS_CONTRACT_VERSION,d as LINE_CHART_ACCESS_CONTRACT,h as REALTIME_LINE_CHART_ACCESS_CONTRACT,i as createChartAccessContract};
2
+ function e(e,t){return!0===e?.supportsAccessibleTable&&!1!==t.accessibleTable}function t(e){return"string"==typeof e&&e.trim().length>0}function a(e){let t=e?.streamStatus;return t?(Array.isArray(t)?t:[t]).filter(e=>!!e&&"string"==typeof e.status).slice(-(e?.streamHistoryLimit??5)):[]}function r(e){if(0===e.length)return;let t=e.map(e=>"idle"===e.status?"no data received":"active"===e.status?"receiving data":"not receiving new data"),a=[...new Set(t)],r=1===a.length?a[0]:t.join(", then ");return`Last ${e.length} stream ${1===e.length?"status":"statuses"}: ${r}.`}function i(e,t){return e?!e.supportsLegend||!1===t.showLegend||!0!==t.showLegend&&null==t.legend&&!["colorBy","lineBy","areaBy","stackBy","groupBy"].some(e=>null!=t[e])?"not-applicable":"isolate"===t.legendInteraction||"highlight"===t.legendInteraction?"built-in":"not-enabled":"unsupported"}function s(e,t){return e?"delegated"===e.markNavigation||"not-applicable"===e.markNavigation?e.markNavigation:t?"built-in":"unsupported":"unsupported"}function o({component:o,props:p,options:h={}}){let m=d[o],g=m?m.realtime:!0===h.realtime,C=l(o,p,{...h.locale?{locale:h.locale}:{}}),v=c(o,p),b=v||!0===m?.recipeNavigation,y=v&&!1!==h.navigable?u(o,p,{...h.locale?{locale:h.locale}:{}}):void 0,S=n(o,p,{inChartContainer:!0===h.inChartContainer,describe:!0===h.describe||t(p.summary),navigable:!1!==h.navigable&&b}),f=g?a(h):[],T=s(m,b);return{schemaVersion:1,component:o,text:{...t(p.title)?{title:p.title}:{},...t(p.description)?{description:p.description}:{},...t(p.summary)?{summary:p.summary}:{},accessibleTable:e(m,p)},keyboard:{markNavigation:T,legendInteraction:i(m,p),focusRing:T},navigation:{supported:b,composition:"chart-container",...y?{tree:y}:void 0,...y?{}:{note:b?v?"Structured datum navigation is available through ChartContainer; enable its navigable option to materialize the tree.":"Structured datum navigation is declared for this built-in recipe; load its recipe manifest through semiotic/ai before materializing the tree.":"No datum-level structured navigation is registered for this chart. Exact-value table access may still be available."}},table:{enabled:e(m,p),source:"scene",pagination:"built-in"},mediaPreferences:{reducedMotion:m?"built-in":"unknown",forcedColors:m?"css-custom-properties":"unknown",note:m?"Runtime detection is available through useReducedMotion and useHighContrast; canvas styling uses CSS custom properties so forced-colors changes cascade.":"No generated runtime capability record exists for this component; media-preference support is unknown."},streamStatus:g?{supported:!0,status:f.at(-1)?.status??"idle",lastPushTime:f.at(-1)?.lastPushTime??null,history:f,historyLimit:h.streamHistoryLimit??5,...r(f)?{accessibleDescription:r(f)}:{},note:"Hosts may expose this bounded, non-visible description to screen readers or agents. Do not render it in visible UI."}:{supported:!1,note:"Static chart; no push-ingest lifecycle."},ssr:!0===m?.supportsSSR?{supported:!0,evidence:h.ssrEvidence,note:h.ssrEvidence?"Server rendering is registered and attached render evidence records the observed scene.":"Server rendering is registered; supply renderChartWithEvidence output before claiming a non-empty scene."}:{supported:!1,...h.ssrEvidence?{evidence:h.ssrEvidence}:{},note:g?"Live push charts intentionally omit static SSR; capture a supported bounded-window static twin before claiming server evidence.":m?"The chart capability registry does not expose this component through renderChart; do not claim server evidence for the HOC surface.":"No generated capability record exists for this component; SSR support is unknown and therefore reported as unsupported."},evidence:{audit:S,description:C}}}import{o as n}from"./c-2MONF2P6.min.js";import{j as l,k as c,l as u}from"./c-UOPPO26M.min.js";var d=Object.freeze(Object.fromEntries([["AreaChart",13],["BubbleChart",13],["BumpChart",13],["CandlestickChart",13],["ConnectedScatterplot",13],["DifferenceChart",13],["Heatmap",13],["LineChart",13],["MinimapChart",13,"delegated"],["MultiAxisLineChart",13],["QuadrantChart",13],["Scatterplot",13],["ScatterplotMatrix",13,"delegated"],["StackedAreaChart",13],["WaterfallChart",13],["BarChart",13],["BoxPlot",13],["DonutChart",13],["DotPlot",13],["FunnelChart",13],["GaugeChart",5],["GroupedBarChart",13],["Histogram",13],["LikertChart",13],["PieChart",13],["RadarChart",13],["RidgelinePlot",13],["StackedBarChart",13],["SwarmPlot",13],["SwimlaneChart",13],["ViolinPlot",13],["ChordDiagram",13],["CirclePack",13],["DependencyForestChart",1],["ForceDirectedGraph",13],["MotifBraidChart",1],["OrbitDiagram",13],["ProcessSankey",13],["SankeyDiagram",13],["TreeDiagram",13],["Treemap",13],["ChoroplethMap",13],["DistanceCartogram",13],["FlowMap",13],["ProportionalSymbolMap",13],["RealtimeHeatmap",15],["RealtimeHistogram",15],["RealtimeLineChart",15],["RealtimeSwarmChart",15],["RealtimeWaterfallChart",15],["TemporalHistogram",13],["ChainReactionChart",5],["CollisionSwarmChart",13],["CrucibleChart",5],["EventDropChart",13],["FlowCircuitChart",1],["GaltonBoardChart",13],["GauntletChart",5],["PacketFlowChart",13],["ProcessFlowChart",13],["UnitPileChart",13],["BigNumber",1,"not-applicable"],["ParallelCoordinatesRecipe",21],["CalendarHeatmapRecipe",21]].map(([e,t,a="unsupported"])=>[e,{supportsSSR:!!(1&t),realtime:!!(2&t),supportsAccessibleTable:!!(4&t),supportsLegend:!!(8&t),...16&t?{recipeNavigation:!0}:{},markNavigation:a}]))),p=1,h=o({component:"LineChart",props:{data:[{date:"2026-01-01",value:12},{date:"2026-02-01",value:18},{date:"2026-03-01",value:15}],xAccessor:"date",yAccessor:"value",title:"Weekly active users",description:"Daily active users from January through March, with a February peak.",summary:"Use keyboard mark navigation to inspect each point; the linked table lists exact values."},options:{navigable:!0}}),m=o({component:"BarChart",props:{data:[{region:"North",total:42},{region:"South",total:31},{region:"East",total:27}],categoryAccessor:"region",valueAccessor:"total",title:"Orders by region",description:"Three regions compared by order count; North leads and East trails.",summary:"The accessible table preserves category labels and numeric totals for exact reading."},options:{navigable:!0}}),g=o({component:"RealtimeLineChart",props:{data:[{time:1,value:4},{time:2,value:7}],timeAccessor:"time",valueAccessor:"value",title:"Requests per second",description:"A bounded live window of requests per second with stale-state indication available through useStreamStatus.",summary:"The current window is exposed as an accessible table; status changes should be announced by the host application."},options:{realtime:!0,navigable:!1,streamStatus:[{status:"idle",lastPushTime:null},{status:"active",lastPushTime:1e3},{status:"active",lastPushTime:2e3},{status:"active",lastPushTime:3e3},{status:"stale",lastPushTime:4e3}],streamHistoryLimit:5}});export{m as BAR_CHART_ACCESS_CONTRACT,p as CHART_ACCESS_CONTRACT_VERSION,h as LINE_CHART_ACCESS_CONTRACT,g as REALTIME_LINE_CHART_ACCESS_CONTRACT,o as createChartAccessContract};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{ARTIFACT_POLICIES as m}from"./c-S3AZX5PP.min.js";import{ARTIFACT_FIELD_POLICIES as o}from"./c-BOHCQILI.min.js";export{o as ARTIFACT_FIELD_POLICIES,m as ARTIFACT_POLICIES};
2
+ import{c as I}from"./c-GHN6IR4Y.min.js";import{a as m}from"./c-YT5KPVNP.min.js";export{m as ARTIFACT_FIELD_POLICIES,I as ARTIFACT_POLICIES};
@@ -58,9 +58,14 @@ export type { ChartRecipe, ChartRecipeFrameFamily, ChartRecipePortability, DataR
58
58
  export { getChartRecipe, getRegisteredRecipeCapabilities, hasRegisteredRecipeCapabilities, listChartRecipes, registerChartRecipe, resolveChartRecipe, unregisterChartRecipe } from "./components/ai/chartRecipeRegistry";
59
59
  export { suggestDashboard } from "./components/ai/suggestDashboard";
60
60
  export type { DashboardPanel, DashboardSuggestion, SuggestDashboardOptions } from "./components/ai/suggestDashboard";
61
- export { suggestStreamCharts } from "./components/ai/suggestStreamCharts";
62
- export type { SuggestStreamChartsOptions } from "./components/ai/suggestStreamCharts";
63
- export type { StreamSchema, StreamSuggestion } from "./components/ai/streamingTypes";
61
+ export { applyAudienceBias, effectiveFamiliarity, stretchFamiliarityCeiling, receivabilityBias } from "./components/ai/audienceProfile";
62
+ export type { AudienceProfile, AudienceTarget, AudienceBiasResult, ReceptionModality, ReceivabilitySignal, DashboardLayoutPolicy } from "./components/ai/audienceProfile";
63
+ export { suggestStreamCharts, explainStreamCapabilityFit, registerStreamChartCapability, unregisterStreamChartCapability, getStreamCapabilities } from "./components/ai/suggestStreamCharts";
64
+ export type { SuggestStreamChartsOptions, SuggestStreamChartsResult, RejectedStreamCapability, StreamStretchSuggestion } from "./components/ai/suggestStreamCharts";
65
+ export type { StreamSchema, StreamFieldSchema, StreamFieldKind, StreamFieldRole, StreamShape, StreamThroughput, StreamThroughputBand, StreamThroughputThresholds, StreamChartCapability, StreamIntentScorer, StreamSuggestion } from "./components/ai/streamingTypes";
66
+ export { resolveStreamShape, streamKeyFields, streamThroughputBand, pickValueField, pickCategoryField, pickTimeField, pickSeriesField } from "./components/ai/streamSchema";
67
+ export { suggestStreamDashboard } from "./components/ai/suggestStreamDashboard";
68
+ export type { StreamDashboardPanel, StreamDashboardSuggestion, SuggestStreamDashboardOptions } from "./components/ai/suggestStreamDashboard";
64
69
  export { suggestStretchCharts } from "./components/ai/suggestStretchCharts";
65
70
  export type { StretchSuggestion, SuggestStretchChartsOptions } from "./components/ai/suggestStretchCharts";
66
71
  export { repairChartConfig } from "./components/ai/repairChartConfig";