semiotic 3.8.8 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (501) hide show
  1. package/README.md +82 -66
  2. package/agent-skill/semiotic-charts/SKILL.md +11 -2
  3. package/ai/behaviorContracts.cjs +33 -3
  4. package/ai/cli.js +53 -2
  5. package/ai/componentMetadata.cjs +15 -0
  6. package/ai/dist/mcp-server.js +1530 -611
  7. package/ai/examples.md +48 -42
  8. package/{CLAUDE.md → ai/reference.md} +46 -24
  9. package/ai/schema.json +10704 -825
  10. package/ai/surface-manifest.json +643 -2
  11. package/ai/system-prompt.md +83 -130
  12. package/dist/c-3BLJEQNG.min.js +1 -0
  13. package/dist/c-3KZD6AXJ.min.js +1 -0
  14. package/dist/c-4TWEX5HG.min.js +1 -0
  15. package/dist/c-52TEGIUJ.min.js +1 -0
  16. package/dist/c-5YCIX3VZ.min.js +1 -0
  17. package/dist/c-6FEKTA3U.min.js +1 -0
  18. package/dist/c-6O5EVOPH.min.js +1 -0
  19. package/dist/c-74HEEZGK.min.js +1 -0
  20. package/dist/c-AKAF6JAD.min.js +1 -0
  21. package/dist/c-BBKITSXB.min.js +1 -0
  22. package/dist/c-BWNB6USU.min.js +1 -0
  23. package/dist/c-C25ENHIK.min.js +1 -0
  24. package/dist/c-CDR5AO3R.min.js +1 -0
  25. package/dist/c-COHXCW3Q.min.js +1 -0
  26. package/dist/{chunk-scatterplotMatrixBrushOverlay-SDIZSN66.module.min.js → c-DADXPJXV.min.js} +0 -1
  27. package/dist/c-E3JFRRMI.min.js +1 -0
  28. package/dist/c-EBFPQHHO.min.js +1 -0
  29. package/dist/c-G36WS6LN.min.js +1 -0
  30. package/dist/c-GIKRQI4X.min.js +1 -0
  31. package/dist/c-GPYOFETM.min.js +1 -0
  32. package/dist/c-IDUHYYSI.min.js +1 -0
  33. package/dist/{chunk-chunk-FQPKOAIH.module.min.js → c-IUHFPMHD.min.js} +0 -1
  34. package/dist/c-J5G56TUH.min.js +1 -0
  35. package/dist/c-JAZ73J32.min.js +1 -0
  36. package/dist/c-KG3NXHAL.min.js +1 -0
  37. package/dist/c-KII3PLZE.min.js +1 -0
  38. package/dist/c-LIXGXMNS.min.js +1 -0
  39. package/dist/c-LVEY6D6B.min.js +1 -0
  40. package/dist/c-M4Y3BHFR.min.js +1 -0
  41. package/dist/c-MAIICR2Z.min.js +1 -0
  42. package/dist/c-MG5DM6VE.min.js +1 -0
  43. package/dist/{chunk-minimapBrushOverlay-JU57U7NM.module.min.js → c-MNF2S4AA.min.js} +0 -1
  44. package/dist/c-MT3WBK7M.min.js +1 -0
  45. package/dist/c-NY3JWV2K.min.js +1 -0
  46. package/dist/c-O6U6K4CW.min.js +1 -0
  47. package/dist/c-OCI56QF2.min.js +1 -0
  48. package/dist/c-OQ7M4AGV.min.js +1 -0
  49. package/dist/c-OXYMVK7Q.min.js +1 -0
  50. package/dist/c-PPWDL5ZI.min.js +1 -0
  51. package/dist/c-QHF5YON3.min.js +1 -0
  52. package/dist/c-RR3GO5SW.min.js +1 -0
  53. package/dist/{chunk-chunk-J5QD4RAM.module.min.js → c-RSVIHIQ4.min.js} +0 -1
  54. package/dist/{chunk-chunk-EMO5NUGE.module.min.js → c-S2BXNNJN.min.js} +0 -1
  55. package/dist/{chunk-chunk-YCQYG6J5.module.min.js → c-SLGMUBUL.min.js} +0 -1
  56. package/dist/c-SUILCHWU.min.js +1 -0
  57. package/dist/c-TZW3JGJ5.min.js +1 -0
  58. package/dist/c-US5ZFT6E.min.js +1 -0
  59. package/dist/{chunk-chunk-RZH7VZYS.module.min.js → c-USFMFKIH.min.js} +0 -1
  60. package/dist/c-UUKVD4WB.min.js +1 -0
  61. package/dist/{chunk-chunk-SV4XAZ3Q.module.min.js → c-VGW3VG3I.min.js} +0 -1
  62. package/dist/c-W3CE4A4S.min.js +1 -0
  63. package/dist/{chunk-chunk-2NVFEB7P.module.min.js → c-WJCD5EUY.min.js} +0 -1
  64. package/dist/{chunk-chunk-2JGJ5GUG.module.min.js → c-X5UBGU2V.min.js} +0 -1
  65. package/dist/c-YDAY2WFR.min.js +1 -0
  66. package/dist/c-ZOWWU34K.min.js +1 -0
  67. package/dist/components/AccessibleNavTree.d.ts +1 -1
  68. package/dist/components/CategoryColors.d.ts +1 -1
  69. package/dist/components/GradientLegend.d.ts +14 -0
  70. package/dist/components/Legend.d.ts +2 -7
  71. package/dist/components/LinkedCharts.d.ts +1 -1
  72. package/dist/components/MobileAnnotationCalloutList.d.ts +1 -1
  73. package/dist/components/ObservationReadout.d.ts +45 -0
  74. package/dist/components/ThemeProvider.d.ts +4 -4
  75. package/dist/components/Tooltip/FlippingTooltip.d.ts +5 -7
  76. package/dist/components/Tooltip/Tooltip.d.ts +83 -5
  77. package/dist/components/Tooltip/tooltipChrome.d.ts +43 -0
  78. package/dist/components/ai/chartCapabilityTypes.d.ts +86 -2
  79. package/dist/components/ai/chartClinic.d.ts +2 -0
  80. package/dist/components/ai/deriveProfileFields.d.ts +40 -0
  81. package/dist/components/ai/evaluateChart.d.ts +85 -0
  82. package/dist/components/ai/fieldPolicy.d.ts +7 -0
  83. package/dist/components/ai/fieldRoles.d.ts +24 -0
  84. package/dist/components/ai/generativeChart.d.ts +18 -2
  85. package/dist/components/ai/inferIntent.d.ts +26 -2
  86. package/dist/components/ai/intents.d.ts +35 -0
  87. package/dist/components/ai/navigationTree.d.ts +2 -2
  88. package/dist/components/ai/observedSceneAudit.d.ts +2 -1
  89. package/dist/components/ai/profileData.d.ts +11 -0
  90. package/dist/components/ai/repairChartConfig.d.ts +2 -3
  91. package/dist/components/ai/semanticEvidence.d.ts +4 -0
  92. package/dist/components/ai/semanticViability.d.ts +11 -0
  93. package/dist/components/ai/semanticViabilityRegistry.d.ts +5 -0
  94. package/dist/components/ai/streamingTypes.d.ts +4 -0
  95. package/dist/components/ai/suggestCharts.d.ts +5 -6
  96. package/dist/components/ai/suggestDashboard.d.ts +2 -3
  97. package/dist/components/ai/suggestStreamCharts.d.ts +1 -1
  98. package/dist/components/ai/suggestStretchCharts.d.ts +2 -3
  99. package/dist/components/ai/suggestionPropContracts.d.ts +20 -0
  100. package/dist/components/ai/variantDiscovery.d.ts +3 -1
  101. package/dist/components/charts/custom/NetworkCustomChart.d.ts +3 -0
  102. package/dist/components/charts/custom/OrdinalCustomChart.d.ts +3 -0
  103. package/dist/components/charts/custom/XYCustomChart.d.ts +1 -1
  104. package/dist/components/charts/geo/ChoroplethMap.d.ts +3 -1
  105. package/dist/components/charts/geo/DistanceCartogram.d.ts +2 -7
  106. package/dist/components/charts/geo/cartogramOverlay.d.ts +28 -0
  107. package/dist/components/charts/index.d.ts +4 -3
  108. package/dist/components/charts/network/ProcessSankey.d.ts +2 -136
  109. package/dist/components/charts/network/ProcessSankeyProps.d.ts +139 -0
  110. package/dist/components/charts/network/Treemap.d.ts +2 -1
  111. package/dist/components/charts/network/processSankey/boundaryHubOrdering.d.ts +23 -0
  112. package/dist/components/charts/network/processSankey/layoutGeometry.d.ts +2 -0
  113. package/dist/components/charts/network/processSankey/ordering.d.ts +3 -41
  114. package/dist/components/charts/network/processSankey/orderingTypes.d.ts +32 -0
  115. package/dist/components/charts/network/processSankey/packing.d.ts +1 -1
  116. package/dist/components/charts/network/processSankey/packingCache.d.ts +1 -1
  117. package/dist/components/charts/network/processSankey/packingOptimization.d.ts +72 -0
  118. package/dist/components/charts/ordinal/BarChart.d.ts +4 -3
  119. package/dist/components/charts/ordinal/FunnelChart.d.ts +2 -0
  120. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +3 -2
  121. package/dist/components/charts/ordinal/StackedBarChart.d.ts +4 -3
  122. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +2 -2
  123. package/dist/components/charts/physics/GaltonBoardChart.d.ts +2 -9
  124. package/dist/components/charts/physics/GauntletChart.d.ts +10 -41
  125. package/dist/components/charts/physics/ProcessFlowChart.d.ts +1 -1
  126. package/dist/components/charts/physics/chainReactionAccessibleTable.d.ts +9 -0
  127. package/dist/components/charts/physics/chainReactionRuntime.d.ts +2 -1
  128. package/dist/components/charts/physics/chainReactionTypes.d.ts +6 -1
  129. package/dist/components/charts/physics/crucibleBodyRenderers.d.ts +2 -2
  130. package/dist/components/charts/physics/crucibleClone.d.ts +6 -0
  131. package/dist/components/charts/physics/crucibleEffects.d.ts +1 -2
  132. package/dist/components/charts/physics/crucibleRecord.d.ts +7 -0
  133. package/dist/components/charts/physics/gauntletChrome.d.ts +4 -4
  134. package/dist/components/charts/physics/gauntletPhysics.d.ts +1 -0
  135. package/dist/components/charts/physics/gauntletPublic.d.ts +4 -0
  136. package/dist/components/charts/physics/packetFlowOverlay.d.ts +7 -0
  137. package/dist/components/charts/physics/physicsChartLayout.d.ts +8 -0
  138. package/dist/components/charts/physics/physicsChartShared.d.ts +3 -1
  139. package/dist/components/charts/physics/physicsChartUtils.d.ts +1 -1
  140. package/dist/components/charts/physics/physicsHocUtils.d.ts +26 -13
  141. package/dist/components/charts/physics/physicsProjectionOverlays.d.ts +24 -0
  142. package/dist/components/charts/physics/processFlowOverlays.d.ts +9 -0
  143. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +17 -12
  144. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +12 -7
  145. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +37 -14
  146. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +23 -14
  147. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +22 -13
  148. package/dist/components/charts/realtime/aggregate.d.ts +4 -1
  149. package/dist/components/charts/realtime/eventTime.d.ts +4 -0
  150. package/dist/components/charts/realtime/realtimeChartRuntime.d.ts +27 -0
  151. package/dist/components/charts/realtime/realtimeChartTypes.d.ts +30 -0
  152. package/dist/components/charts/realtime/useRealtimeCategoryColors.d.ts +30 -0
  153. package/dist/components/charts/shared/FrameTextAnnotationSVG.d.ts +10 -0
  154. package/dist/components/charts/shared/annotationActivation.d.ts +3 -7
  155. package/dist/components/charts/shared/annotationBandFill.d.ts +6 -0
  156. package/dist/components/charts/shared/annotationDispatch.d.ts +31 -0
  157. package/dist/components/charts/shared/annotationIdentity.d.ts +8 -0
  158. package/dist/components/charts/shared/annotationRules.d.ts +1 -15
  159. package/dist/components/charts/shared/boundedCategoryRegistry.d.ts +8 -0
  160. package/dist/components/charts/shared/chainReactionChartSpec.d.ts +3 -0
  161. package/dist/components/charts/shared/chartMode.d.ts +3 -2
  162. package/dist/components/charts/shared/chartSpecCore.d.ts +1 -0
  163. package/dist/components/charts/shared/formatUtils.d.ts +40 -9
  164. package/dist/components/charts/shared/frameTextAnnotation.d.ts +63 -0
  165. package/dist/components/charts/shared/gradient.d.ts +16 -0
  166. package/dist/components/charts/shared/hatchFill.d.ts +15 -0
  167. package/dist/components/charts/shared/hooks.d.ts +4 -4
  168. package/dist/components/charts/shared/legendUtils.d.ts +1 -0
  169. package/dist/components/charts/shared/streamPropsHelpers.d.ts +3 -1
  170. package/dist/components/charts/shared/styleRules.d.ts +9 -2
  171. package/dist/components/charts/shared/styleRulesWireSchema.d.ts +353 -0
  172. package/dist/components/charts/shared/types.d.ts +26 -10
  173. package/dist/components/charts/shared/useChartLegend.d.ts +43 -9
  174. package/dist/components/charts/shared/useChartSetup.d.ts +3 -1
  175. package/dist/components/charts/shared/useCustomChartSetup.d.ts +5 -2
  176. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +5 -1
  177. package/dist/components/charts/shared/useOrdinalBrush.d.ts +3 -3
  178. package/dist/components/charts/shared/useStreamingLegend.d.ts +6 -1
  179. package/dist/components/charts/value/types.d.ts +1 -1
  180. package/dist/components/charts/xy/BubbleChart.d.ts +1 -1
  181. package/dist/components/charts/xy/BumpChart.capability.d.ts +14 -1
  182. package/dist/components/charts/xy/BumpChart.d.ts +13 -73
  183. package/dist/components/charts/xy/BumpChart.semanticViability.d.ts +5 -0
  184. package/dist/components/charts/xy/CandlestickChart.d.ts +2 -2
  185. package/dist/components/charts/xy/LineChart.d.ts +2 -2
  186. package/dist/components/charts/xy/Scatterplot.d.ts +1 -1
  187. package/dist/components/charts/xy/bumpData.d.ts +44 -0
  188. package/dist/components/charts/xy/bumpIdentity.d.ts +2 -0
  189. package/dist/components/charts/xy/bumpLayout.d.ts +45 -0
  190. package/dist/components/charts/xy/bumpTooltip.d.ts +20 -0
  191. package/dist/components/legendLayout.d.ts +131 -4
  192. package/dist/components/realtime/ReorderBuffer.d.ts +2 -0
  193. package/dist/components/realtime/types.d.ts +10 -1
  194. package/dist/components/recipes/balanceSnapshotsToFlows.d.ts +42 -0
  195. package/dist/components/recipes/directedReachability.d.ts +14 -0
  196. package/dist/components/recipes/gofishDisplayListFixtures.generated.d.ts +6 -6
  197. package/dist/components/recipes/gridObservatory.d.ts +1 -1
  198. package/dist/components/recipes/networkAnalysis.d.ts +1 -18
  199. package/dist/components/recipes/physics.d.ts +7 -4
  200. package/dist/components/recipes/processPhysics.d.ts +0 -1
  201. package/dist/components/recipes/waffle.d.ts +7 -4
  202. package/dist/components/semiotic-ai-core.d.ts +13 -4
  203. package/dist/components/semiotic-ai-observations.d.ts +3 -0
  204. package/dist/components/semiotic-ai.d.ts +16 -9
  205. package/dist/components/semiotic-client-shared.d.ts +10 -0
  206. package/dist/components/semiotic-experimental.d.ts +1 -1
  207. package/dist/components/semiotic-geo.d.ts +4 -1
  208. package/dist/components/semiotic-network.d.ts +7 -4
  209. package/dist/components/semiotic-ordinal.d.ts +4 -1
  210. package/dist/components/semiotic-physics.d.ts +11 -4
  211. package/dist/components/semiotic-realtime-core.d.ts +11 -4
  212. package/dist/components/semiotic-realtime-react.d.ts +4 -3
  213. package/dist/components/semiotic-realtime.d.ts +3 -1
  214. package/dist/components/semiotic-recipes-core.d.ts +7 -5
  215. package/dist/components/semiotic-server-edge.d.ts +3 -2
  216. package/dist/components/semiotic-server.d.ts +3 -2
  217. package/dist/components/semiotic-themes-core.d.ts +5 -48
  218. package/dist/components/semiotic-utils-core.d.ts +11 -5
  219. package/dist/components/semiotic-utils-react.d.ts +2 -0
  220. package/dist/components/semiotic-xy.d.ts +4 -1
  221. package/dist/components/semiotic.d.ts +68 -25
  222. package/dist/components/server/animatedGif.d.ts +1 -1
  223. package/dist/components/server/renderEvidence.d.ts +25 -2
  224. package/dist/components/server/renderToStaticSVG.d.ts +15 -7
  225. package/dist/components/server/serverChartConfigShared.d.ts +8 -1
  226. package/dist/components/server/serverChartConfigs.d.ts +1 -0
  227. package/dist/components/server/serverChartConfigsNetwork.d.ts +3 -3
  228. package/dist/components/server/serverChartConfigsNetworkChord.d.ts +2 -0
  229. package/dist/components/server/serverChartConfigsNetworkForce.d.ts +2 -0
  230. package/dist/components/server/serverChartConfigsNetworkHierarchy.d.ts +3 -0
  231. package/dist/components/server/serverChartConfigsXY.d.ts +3 -3
  232. package/dist/components/server/serverChartConfigsXYBubble.d.ts +5 -0
  233. package/dist/components/server/serverChartConfigsXYBump.d.ts +7 -0
  234. package/dist/components/server/serverChartConfigsXYScatter.d.ts +5 -0
  235. package/dist/components/server/staticAnnotationFallbacks.d.ts +10 -0
  236. package/dist/components/server/staticAnnotations.d.ts +28 -1
  237. package/dist/components/server/staticAxisTickLabel.d.ts +13 -0
  238. package/dist/components/server/staticLegend.d.ts +1 -1
  239. package/dist/components/server/staticLegendMargin.d.ts +41 -0
  240. package/dist/components/server/staticOrdinal.d.ts +8 -2
  241. package/dist/components/server/staticPhysics.d.ts +13 -1
  242. package/dist/components/server/staticPhysicsChrome.d.ts +20 -0
  243. package/dist/components/server/staticRawLegend.d.ts +15 -0
  244. package/dist/components/server/staticSVGChrome.d.ts +16 -55
  245. package/dist/components/server/staticXYAxes.d.ts +27 -0
  246. package/dist/components/server/staticXYAxisTicks.d.ts +39 -0
  247. package/dist/components/server/staticXYGrid.d.ts +11 -0
  248. package/dist/components/server/themeResolver.d.ts +5 -1
  249. package/dist/components/store/ThemeStore.d.ts +2 -98
  250. package/dist/components/store/designTokens.d.ts +1 -1
  251. package/dist/components/store/themeCSSVariables.d.ts +10 -0
  252. package/dist/components/store/themeCore.d.ts +91 -0
  253. package/dist/components/store/themePresets.d.ts +81 -0
  254. package/dist/components/store/themeSerialization.d.ts +2 -1
  255. package/dist/components/stream/AccessibleDataTable.d.ts +12 -14
  256. package/dist/components/stream/AccessibleTablePortalImpl.d.ts +6 -0
  257. package/dist/components/stream/GeoTileRenderer.d.ts +3 -0
  258. package/dist/components/stream/NetworkCanvasHitTester.d.ts +3 -1
  259. package/dist/components/stream/NetworkSSRFrame.d.ts +2 -1
  260. package/dist/components/stream/NetworkSVGOverlay.d.ts +3 -31
  261. package/dist/components/stream/OrdinalCanvasHitTester.d.ts +2 -0
  262. package/dist/components/stream/SVGChartTitle.d.ts +9 -0
  263. package/dist/components/stream/SVGOverlay.d.ts +1 -21
  264. package/dist/components/stream/SVGUnderlay.d.ts +24 -0
  265. package/dist/components/stream/SceneToSVG.d.ts +1 -1
  266. package/dist/components/stream/StreamGeoFrame.d.ts +1 -1
  267. package/dist/components/stream/StreamOrdinalFrame.d.ts +1 -1
  268. package/dist/components/stream/StreamXYFrame.d.ts +1 -1
  269. package/dist/components/stream/accessibleDataRows.d.ts +11 -0
  270. package/dist/components/stream/accessibleDataTableModel.d.ts +40 -0
  271. package/dist/components/stream/accessibleTableTypes.d.ts +11 -0
  272. package/dist/components/stream/axisTickUtils.d.ts +19 -0
  273. package/dist/components/stream/canvasBackground.d.ts +10 -0
  274. package/dist/components/stream/canvasSetup.d.ts +24 -4
  275. package/dist/components/stream/frameCursorInteraction.d.ts +25 -0
  276. package/dist/components/stream/frameDefaultMargins.d.ts +37 -0
  277. package/dist/components/stream/frameGraphics.d.ts +18 -0
  278. package/dist/components/stream/frameGraphicsSubscription.d.ts +26 -0
  279. package/dist/components/stream/frameLegendOptions.d.ts +18 -0
  280. package/dist/components/stream/geoFrameCursorInteraction.d.ts +9 -0
  281. package/dist/components/stream/geoFrameHelpers.d.ts +29 -1
  282. package/dist/components/stream/geoTypes.d.ts +12 -11
  283. package/dist/components/stream/hitTarget.d.ts +61 -2
  284. package/dist/components/stream/moduleWorkerSession.d.ts +6 -0
  285. package/dist/components/stream/networkAnnotationAnchors.d.ts +37 -0
  286. package/dist/components/stream/networkCustomLayout.d.ts +2 -2
  287. package/dist/components/stream/networkFrameCursorInteraction.d.ts +12 -0
  288. package/dist/components/stream/networkFrameInteraction.d.ts +2 -0
  289. package/dist/components/stream/networkFramePaint.d.ts +15 -0
  290. package/dist/components/stream/networkPipelineConfig.d.ts +1 -1
  291. package/dist/components/stream/networkTypes.d.ts +32 -32
  292. package/dist/components/stream/normalizeXYData.d.ts +7 -0
  293. package/dist/components/stream/ordinalFrameCursorInteraction.d.ts +7 -0
  294. package/dist/components/stream/ordinalFrameInteraction.d.ts +29 -0
  295. package/dist/components/stream/ordinalSceneSVG.d.ts +10 -0
  296. package/dist/components/stream/ordinalTypes.d.ts +12 -4
  297. package/dist/components/stream/physics/PhysicsBodySpatialIndex.d.ts +9 -1
  298. package/dist/components/stream/physics/PhysicsCanvasTheme.d.ts +25 -0
  299. package/dist/components/stream/physics/PhysicsControllers.d.ts +0 -3
  300. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +4 -1
  301. package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +3 -24
  302. package/dist/components/stream/physics/PhysicsSettledSVG.d.ts +9 -21
  303. package/dist/components/stream/physics/PhysicsSettledSVGElement.d.ts +37 -0
  304. package/dist/components/stream/physics/PhysicsSettledScene.d.ts +7 -3
  305. package/dist/components/stream/physics/StreamPhysicsFrame.d.ts +1 -1
  306. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +25 -4
  307. package/dist/components/stream/physics/physicsAnnotationContext.d.ts +19 -0
  308. package/dist/components/stream/physics/physicsBodyCanvas.d.ts +4 -0
  309. package/dist/components/stream/physics/physicsSettledChrome.d.ts +7 -0
  310. package/dist/components/stream/physics/usePhysicsCanvasPointer.d.ts +32 -0
  311. package/dist/components/stream/physics/usePhysicsSemanticNavigation.d.ts +36 -0
  312. package/dist/components/stream/pipelineConfig.d.ts +8 -17
  313. package/dist/components/stream/pipelineDomainResolution.d.ts +2 -2
  314. package/dist/components/stream/renderBackend.d.ts +2 -0
  315. package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +13 -2
  316. package/dist/components/stream/renderers/resolveCSSColor.d.ts +7 -0
  317. package/dist/components/stream/responsiveSize.d.ts +17 -0
  318. package/dist/components/stream/sceneCursor.d.ts +41 -0
  319. package/dist/components/stream/sceneRevisionDiagnostics.d.ts +1 -1
  320. package/dist/components/stream/svgOverlayUtils.d.ts +22 -1
  321. package/dist/components/stream/types.d.ts +33 -13
  322. package/dist/components/stream/useCanvasFrameHost.d.ts +12 -1
  323. package/dist/components/stream/useFrame.d.ts +24 -1
  324. package/dist/components/stream/useResponsiveSize.d.ts +6 -1
  325. package/dist/components/stream/useStalenessCheck.d.ts +1 -1
  326. package/dist/components/stream/xyFrameAxisTypes.d.ts +20 -4
  327. package/dist/components/stream/xyFrameCursorInteraction.d.ts +6 -0
  328. package/dist/components/stream/xySceneBuilders/swarmScene.d.ts +1 -1
  329. package/dist/components/stream/xySceneBuilders/types.d.ts +6 -26
  330. package/dist/components/types/legendTypes.d.ts +6 -0
  331. package/dist/components/types/marginType.d.ts +7 -8
  332. package/dist/controls.min.js +1 -1
  333. package/dist/controls.module.min.js +1 -1
  334. package/dist/forceLayoutWorker.js +1 -1
  335. package/dist/geo.min.js +1 -1
  336. package/dist/geo.module.min.js +1 -1
  337. package/dist/network.min.js +1 -1
  338. package/dist/network.module.min.js +1 -1
  339. package/dist/ordinal.min.js +1 -1
  340. package/dist/ordinal.module.min.js +1 -1
  341. package/dist/physics-matter.module.min.js +1 -1
  342. package/dist/physics-rapier.module.min.js +1 -1
  343. package/dist/physics.min.js +1 -1
  344. package/dist/physics.module.min.js +1 -1
  345. package/dist/physicsWorker.js +1 -1
  346. package/dist/processSankeyLayoutWorker.js +1 -1
  347. package/dist/realtime.min.js +1 -1
  348. package/dist/realtime.module.min.js +1 -1
  349. package/dist/rough.min.js +1 -1
  350. package/dist/rough.module.min.js +1 -1
  351. package/dist/semiotic-ai-core.d.ts +13 -4
  352. package/dist/semiotic-ai-core.min.js +1 -1
  353. package/dist/semiotic-ai-core.module.min.js +1 -1
  354. package/dist/semiotic-ai.d.ts +16 -9
  355. package/dist/semiotic-ai.min.js +1 -1
  356. package/dist/semiotic-ai.module.min.js +1 -1
  357. package/dist/semiotic-client-cjs-shared.min.js +1 -0
  358. package/dist/semiotic-client-glyph.module.min.js +2 -0
  359. package/dist/semiotic-client-responsive.module.min.js +2 -0
  360. package/dist/semiotic-client-shared.module.min.js +2 -0
  361. package/dist/semiotic-custom-layout-selection-cjs-shared.min.js +2 -0
  362. package/dist/semiotic-data.min.js +1 -1
  363. package/dist/semiotic-data.module.min.js +1 -1
  364. package/dist/semiotic-experimental-auxiliary.module.min.js +2 -0
  365. package/dist/semiotic-experimental-node-auxiliary.module.min.js +2 -0
  366. package/dist/semiotic-experimental-node.module.min.js +2 -0
  367. package/dist/semiotic-experimental-react-shared.module.min.js +2 -0
  368. package/dist/semiotic-experimental-vacp.min.js +1 -1
  369. package/dist/semiotic-experimental-vacp.module.min.js +1 -1
  370. package/dist/semiotic-experimental.d.ts +1 -1
  371. package/dist/semiotic-experimental.min.js +1 -1
  372. package/dist/semiotic-experimental.module.min.js +1 -1
  373. package/dist/semiotic-geo.d.ts +4 -1
  374. package/dist/semiotic-network.d.ts +7 -4
  375. package/dist/semiotic-ordinal.d.ts +4 -1
  376. package/dist/semiotic-physics.d.ts +11 -4
  377. package/dist/semiotic-realtime-core.d.ts +11 -4
  378. package/dist/semiotic-realtime-core.min.js +2 -1
  379. package/dist/semiotic-realtime-core.module.min.js +2 -1
  380. package/dist/semiotic-realtime-react.d.ts +4 -3
  381. package/dist/semiotic-realtime-react.min.js +1 -1
  382. package/dist/semiotic-realtime-react.module.min.js +1 -1
  383. package/dist/semiotic-realtime.d.ts +3 -1
  384. package/dist/semiotic-recipes-core-cjs-base.min.js +1 -0
  385. package/dist/semiotic-recipes-core.d.ts +7 -5
  386. package/dist/semiotic-recipes-core.min.js +9 -1
  387. package/dist/semiotic-recipes-core.module.min.js +1 -1
  388. package/dist/semiotic-recipes-geo-cjs.min.js +1 -0
  389. package/dist/semiotic-recipes-react.min.js +1 -1
  390. package/dist/semiotic-recipes-react.module.min.js +1 -1
  391. package/dist/semiotic-recipes.min.js +7 -1
  392. package/dist/semiotic-recipes.module.min.js +2 -1
  393. package/dist/semiotic-server-edge-node.module.min.js +1 -0
  394. package/dist/semiotic-server-edge.d.ts +3 -2
  395. package/dist/semiotic-server-edge.min.js +1 -1
  396. package/dist/semiotic-server-edge.module.min.js +1 -1
  397. package/dist/semiotic-server-node.min.js +1 -1
  398. package/dist/semiotic-server-node.module.min.js +1 -1
  399. package/dist/semiotic-server.d.ts +3 -2
  400. package/dist/semiotic-themes-core.d.ts +5 -48
  401. package/dist/semiotic-themes-core.min.js +1 -1
  402. package/dist/semiotic-themes-core.module.min.js +1 -1
  403. package/dist/semiotic-themes-react.min.js +1 -1
  404. package/dist/semiotic-themes-react.module.min.js +1 -1
  405. package/dist/semiotic-themes.min.js +1 -1
  406. package/dist/semiotic-themes.module.min.js +1 -1
  407. package/dist/semiotic-utils-core.d.ts +11 -5
  408. package/dist/semiotic-utils-core.min.js +1 -1
  409. package/dist/semiotic-utils-core.module.min.js +1 -1
  410. package/dist/semiotic-utils-react.d.ts +2 -0
  411. package/dist/semiotic-utils-react.min.js +1 -1
  412. package/dist/semiotic-utils-react.module.min.js +1 -1
  413. package/dist/semiotic-utils.min.js +2 -1
  414. package/dist/semiotic-utils.module.min.js +2 -1
  415. package/dist/semiotic-value.min.js +1 -1
  416. package/dist/semiotic-value.module.min.js +1 -1
  417. package/dist/semiotic-xy.d.ts +4 -1
  418. package/dist/semiotic.d.ts +68 -25
  419. package/dist/semiotic.min.js +1 -1
  420. package/dist/semiotic.module.min.js +1 -1
  421. package/dist/server.min.js +1 -1
  422. package/dist/server.module.min.js +1 -1
  423. package/dist/xy.min.js +1 -1
  424. package/dist/xy.module.min.js +1 -1
  425. package/package.json +53 -19
  426. package/dist/__tests__/scenarios/mcpProtocolTypes.d.ts +0 -20
  427. package/dist/chunk-OrdinalBrushOverlay-PXHQYDB2.module.min.js +0 -2
  428. package/dist/chunk-XYBrushOverlay-ECZJJLAJ.module.min.js +0 -1
  429. package/dist/chunk-XYBrushOverlay-EP2SV3UI.module.min.js +0 -2
  430. package/dist/chunk-chartContainerDataAudit-IQ3NBN3Q.module.min.js +0 -2
  431. package/dist/chunk-chunk-2B3AIKUZ.module.min.js +0 -2
  432. package/dist/chunk-chunk-2CXCXRB4.module.min.js +0 -1
  433. package/dist/chunk-chunk-3GCILWPB.module.min.js +0 -2
  434. package/dist/chunk-chunk-46KRGJQP.module.min.js +0 -1
  435. package/dist/chunk-chunk-4ITOQRXM.module.min.js +0 -2
  436. package/dist/chunk-chunk-4MLLQUGW.module.min.js +0 -2
  437. package/dist/chunk-chunk-57RBPDBQ.module.min.js +0 -2
  438. package/dist/chunk-chunk-5UKL5W76.module.min.js +0 -2
  439. package/dist/chunk-chunk-5VVNW5AZ.module.min.js +0 -1
  440. package/dist/chunk-chunk-66PCWJUG.module.min.js +0 -1
  441. package/dist/chunk-chunk-6V5VQVCT.module.min.js +0 -2
  442. package/dist/chunk-chunk-7LE56WAE.module.min.js +0 -2
  443. package/dist/chunk-chunk-7T25U75Z.module.min.js +0 -2
  444. package/dist/chunk-chunk-ACLDBMRH.module.min.js +0 -2
  445. package/dist/chunk-chunk-AF53TBSN.module.min.js +0 -2
  446. package/dist/chunk-chunk-BTZYH2IE.module.min.js +0 -1
  447. package/dist/chunk-chunk-BWV55BZK.module.min.js +0 -2
  448. package/dist/chunk-chunk-BZNOAHJV.module.min.js +0 -2
  449. package/dist/chunk-chunk-CD6PVVS3.module.min.js +0 -2
  450. package/dist/chunk-chunk-DTSNLGRK.module.min.js +0 -2
  451. package/dist/chunk-chunk-FC3NZWYR.module.min.js +0 -2
  452. package/dist/chunk-chunk-FEPXDKJP.module.min.js +0 -1
  453. package/dist/chunk-chunk-FJ76HWQZ.module.min.js +0 -1
  454. package/dist/chunk-chunk-FRGBMTZR.module.min.js +0 -1
  455. package/dist/chunk-chunk-G75OPF5N.module.min.js +0 -2
  456. package/dist/chunk-chunk-H5IFO6CU.module.min.js +0 -2
  457. package/dist/chunk-chunk-HADHLMY5.module.min.js +0 -1
  458. package/dist/chunk-chunk-HBFA4NN6.module.min.js +0 -1
  459. package/dist/chunk-chunk-HCNDE26Q.module.min.js +0 -2
  460. package/dist/chunk-chunk-IY7RYD4S.module.min.js +0 -1
  461. package/dist/chunk-chunk-J3QOW4OE.module.min.js +0 -0
  462. package/dist/chunk-chunk-J3XWETBJ.module.min.js +0 -2
  463. package/dist/chunk-chunk-JJ4BSUYL.module.min.js +0 -2
  464. package/dist/chunk-chunk-JRHXQGEV.module.min.js +0 -2
  465. package/dist/chunk-chunk-KTWEBFMX.module.min.js +0 -2
  466. package/dist/chunk-chunk-L6FFYGYS.module.min.js +0 -1
  467. package/dist/chunk-chunk-LJDH3WV3.module.min.js +0 -2
  468. package/dist/chunk-chunk-LSJUXBMF.module.min.js +0 -1
  469. package/dist/chunk-chunk-N3Q33XCB.module.min.js +0 -2
  470. package/dist/chunk-chunk-NWIGA3UK.module.min.js +0 -1
  471. package/dist/chunk-chunk-OG3TTJGJ.module.min.js +0 -2
  472. package/dist/chunk-chunk-OZK46A5U.module.min.js +0 -1
  473. package/dist/chunk-chunk-PMR47KRY.module.min.js +0 -2
  474. package/dist/chunk-chunk-Q2YADC2V.module.min.js +0 -2
  475. package/dist/chunk-chunk-QQJNG23C.module.min.js +0 -2
  476. package/dist/chunk-chunk-RGJ6TKAH.module.min.js +0 -2
  477. package/dist/chunk-chunk-ROP4HI7H.module.min.js +0 -2
  478. package/dist/chunk-chunk-SFLUSZ73.module.min.js +0 -2
  479. package/dist/chunk-chunk-TCMHJWFJ.module.min.js +0 -1
  480. package/dist/chunk-chunk-TSCFL235.module.min.js +0 -1
  481. package/dist/chunk-chunk-U66USBWU.module.min.js +0 -1
  482. package/dist/chunk-chunk-UEZ6SHW5.module.min.js +0 -2
  483. package/dist/chunk-chunk-UOQRPGPK.module.min.js +0 -2
  484. package/dist/chunk-chunk-VUWYT7DY.module.min.js +0 -2
  485. package/dist/chunk-chunk-W5HWGQMD.module.min.js +0 -2
  486. package/dist/chunk-chunk-WFHZHWT7.module.min.js +0 -1
  487. package/dist/chunk-chunk-WGROBM3I.module.min.js +0 -2
  488. package/dist/chunk-chunk-WSDJFBKX.module.min.js +0 -2
  489. package/dist/chunk-chunk-YHNZCPOZ.module.min.js +0 -2
  490. package/dist/chunk-chunk-YWZB3KPI.module.min.js +0 -2
  491. package/dist/chunk-statisticalOverlays-HMYYSGPE.module.min.js +0 -2
  492. package/dist/components/stream/test-utils/frameScheduler.d.ts +0 -12
  493. package/dist/components/stream/test-utils/revisionConsumption.d.ts +0 -13
  494. package/dist/test-utils/canvasMock.d.ts +0 -86
  495. package/dist/test-utils/capturedFrameProps.d.ts +0 -67
  496. package/dist/test-utils/frameMock.d.ts +0 -81
  497. package/dist/test-utils/ordinalFixtures.d.ts +0 -48
  498. /package/dist/{chunk-chunk-JJ2OOIET.module.min.js → c-GGISSW5E.min.js} +0 -0
  499. /package/dist/{chunk-chunk-SIRIJ3DY.module.min.js → c-N4G2L7ID.min.js} +0 -0
  500. /package/dist/{chunk-chunk-CA3YDW6F.module.min.js → c-S6U5CGT5.min.js} +0 -0
  501. /package/dist/components/recipes/{mobileAnnotationStrategy.d.ts → mobileAnnotationBehavior.d.ts} +0 -0
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export*from"./semiotic-experimental-node-auxiliary.module.min.js";export*from"./semiotic-experimental-vacp.module.min.js";export{SemioticVACPBridge as unstable_SemioticVACPBridge}from"./semiotic-experimental-react-shared.module.min.js";export{BuiltInPhysicsEngineAdapter as unstable_BuiltInPhysicsEngineAdapter,createDefaultPhysicsEngineAdapter as unstable_createDefaultPhysicsEngineAdapter,PhysicsPipelineStore as unstable_PhysicsPipelineStore,evaluatePhysicsBodyBudget as unstable_evaluatePhysicsBodyBudget,PhysicsSedimentAccumulator as unstable_PhysicsSedimentAccumulator,sedimentHeightfield as unstable_sedimentHeightfield,StreamPhysicsFrame as unstable_StreamPhysicsFrame,PhysicsCustomChart as unstable_PhysicsCustomChart}from"./physics.module.min.js";
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{buildReaderGrounding as e,toConfig as t}from"./c-EBFPQHHO.min.js";import"./c-IUHFPMHD.min.js";import{useEffect as n,useRef as r}from"react";import{useObservationSelector as o}from"./semiotic-client-shared.module.min.js";import{useSelectionSelector as i}from"./semiotic-client-shared.module.min.js";function a(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function s(e,t={}){const n="number"==typeof t.maxDepth&&Number.isFinite(t.maxDepth)?Math.max(1,Math.floor(t.maxDepth)):10,r="number"==typeof t.maxArrayLength&&Number.isFinite(t.maxArrayLength)?Math.max(1,Math.floor(t.maxArrayLength)):1e3,o=new WeakSet,i=(e,t)=>{if(null==e||"string"==typeof e||"boolean"==typeof e)return e;if("number"==typeof e)return Number.isFinite(e)?e:e+"";if("bigint"==typeof e)return""+e;if("function"==typeof e||"symbol"==typeof e||void 0===e)return;if(e instanceof Date)return e.toISOString();if(t>=n)return"[depth limit]";if("object"!=typeof e)return e+"";if("$$typeof"in e)return;if(o.has(e))return"[circular]";if(o.add(e),Array.isArray(e)){const n=e.slice(0,r).map(e=>i(e,t+1)).filter(e=>void 0!==e);return o.delete(e),n}if(e instanceof Set){const n=Array.from(e).slice(0,r).map(e=>i(e,t+1)).filter(e=>void 0!==e);return o.delete(e),n}if(e instanceof Map){const n=Object.create(null);let a=0;for(const[o,s]of e){if(a++>=r)break;const e=i(s,t+1);void 0!==e&&(n[o+""]=e)}return o.delete(e),n}const a=Object.create(null);for(const n of Object.keys(e).sort()){const r=i(e[n],t+1);void 0!==r&&(a[n]=r)}return o.delete(e),a};return i(e,0)}function c(e){const t=s(e);return a(t)?t:{}}function l(e){if(Array.isArray(e))return e.map(l);if(!a(e))return e;const t=Object.create(null);for(const n of Object.keys(e).sort())t[n]=l(e[n]);return t}function f(e){return JSON.stringify(l(s(e)))}function d(e){return function(e){let t=BigInt("14695981039346656037");const n=BigInt("1099511628211"),r=BigInt("0xffffffffffffffff");for(let o=0;e.length>o;o++)t^=BigInt(e.charCodeAt(o)),t=t*n&r;return t.toString(16).padStart(16,"0")}(f(e))}function u(e){if(!e?.length)return;const t=Array.from(new Set(e.filter(e=>"string"==typeof e&&e.length))).sort();return t.length?t:void 0}function m(e,t){return t.some(t=>e===t||e.startsWith(t+"/"))}function p(e,t){const n=u(t.refs),r=!1!==t.includeSummary;if(!n)return{snapshot:{version:e.version,createdAt:e.createdAt,state:e.state,...r&&e.summary?{summary:e.summary}:{}}};const o={};for(const[t,r]of Object.entries(e.state))m(t,n)&&(o[t]=r);const i={};if(r&&e.summary)for(const[t,r]of Object.entries(e.summary))m(t,n)&&(i[t]=r);return{snapshot:{version:e.version,createdAt:e.createdAt,state:o,...Object.keys(i).length?{summary:i}:{}},refs:n}}function h(e,t){const n={},r=[];for(const[r,o]of Object.entries(t.state))Object.prototype.hasOwnProperty.call(e.state,r)&&f(e.state[r])===f(o)||(n[r]=o);for(const n of Object.keys(e.state))Object.prototype.hasOwnProperty.call(t.state,n)||r.push(n);const o={},i=[],a=e.summary??{},s=t.summary??{};for(const[e,t]of Object.entries(s))Object.prototype.hasOwnProperty.call(a,e)&&f(a[e])===f(t)||(o[e]=t);for(const e of Object.keys(a))Object.prototype.hasOwnProperty.call(s,e)||i.push(e);return{changed:n,removed:r.sort(),...Object.keys(o).length?{summaryChanged:o}:{},...i.length?{summaryRemoved:i.sort()}:{}}}function g(e){return null==e?"NULL":"number"==typeof e?"DOUBLE":"string"==typeof e?"VARCHAR":"boolean"==typeof e?"BOOLEAN":e instanceof Date?"TIMESTAMP":Array.isArray(e)?"ARRAY":"OBJECT"}var y="semiotic.set_point_selection",b="semiotic.set_interval_selection",v="semiotic.clear_selection",w="semiotic.activate_navigation_node",A="semiotic.inspect_data",R="0.1.0",I="vacp.data_schema";function S(e,t){if(!t.descriptor.name.trim())throw Error("VACP action names must be non-empty.");if(e.some(e=>e.descriptor.name===t.descriptor.name))throw Error(`Duplicate VACP action "${t.descriptor.name}".`);e.push(t)}function x(e,t){if(!a(e))throw Error(t+" expects an object parameter payload.");return e}function k(e,t){return"number"==typeof e&&Number.isFinite(e)?Math.max(1,Math.floor(e)):t}function O(e,t,n){if("string"!=typeof e.selectionRef)throw Error("params.selectionRef must be a VACP selection ref.");const r=t.find(t=>t.ref===e.selectionRef);if(!r)throw Error(`Unknown selection ref "${e.selectionRef}".`);if(n&&!r.modes.has(n))throw Error(`Selection "${r.name}" does not accept ${n} state.`);return r}function j(e){return null==e||"string"==typeof e||"number"==typeof e&&Number.isFinite(e)||"boolean"==typeof e||e instanceof Date&&Number.isFinite(e.getTime())}function C(e,t,n){const r=[],o=e.dataHandles.map(e=>e.ref);o.length&&S(r,{descriptor:{name:I,title:"Describe Semiotic data",description:"Return columns, types, row count, and optional bounded summaries for a chart DataHandle.",targetRef:n.view,parameters:{type:"object",properties:{handleRef:{type:"string",enum:o},detail:{type:"string",enum:["columns","full"]},sampleRows:{type:"number",minimum:1}},required:["handleRef"]}},execute(n){const r=x(n,I);if("string"!=typeof r.handleRef)throw Error("params.handleRef must be a DataHandle ref.");const o=e.dataHandles.find(e=>e.ref===r.handleRef);if(!o)throw Error(`Unknown DataHandle "${r.handleRef}".`);const i=void 0===r.detail||"columns"===r.detail?"columns":"full"===r.detail?"full":(()=>{throw Error('params.detail must be "columns" or "full".')})(),s="number"==typeof r.sampleRows&&Number.isFinite(r.sampleRows)?Math.max(1,Math.floor(r.sampleRows)):"full"===i?1e3:Math.min(o.rows.length,1e3),c=k(t.dataAccess?.maxSchemaRows,5e3);return function(e){const t=e.rows.slice(0,Math.max(0,e.sampleRows)),n=function(e){const t=new Map;for(const n of e)if(a(n))for(const[e,r]of Object.entries(n)){const n=t.get(e)??new Set;n.add(g(r)),t.set(e,n)}return Array.from(t).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>{const n=Array.from(t).filter(e=>"NULL"!==e);return{name:e,type:0===n.length?"NULL":1===new Set(n).size?n[0]:"MIXED"}})}(e.rows),r=n.map(e=>e.name);if("columns"===e.detail)return{handleRef:e.handleRef,detail:e.detail,table:null,rowCount:e.rows.length,columns:n};const o=function(e,t){const n=Object.create(null);for(const r of t){const t=[];for(const n of e){if(!a(n))continue;const e=n[r];"number"==typeof e&&Number.isFinite(e)&&t.push(e)}if(!t.length)continue;let o=t[0],i=t[0],s=0;for(const e of t)o=Math.min(o,e),i=Math.max(i,e),s+=e;n[r]={min:o,max:i,avg:s/t.length}}return Object.keys(n).length?n:void 0}(t,r),i=function(e,t){const n=Object.create(null);for(const r of t){const t=[];for(const n of e){if(!a(n))continue;const e=n[r];e instanceof Date&&Number.isFinite(e.getTime())&&t.push(e.getTime())}if(!t.length)continue;const o=Math.min(...t),i=Math.max(...t);n[r]={minIso:new Date(o).toISOString(),maxIso:new Date(i).toISOString(),minEpochMs:o,maxEpochMs:i}}return Object.keys(n).length?n:void 0}(t,r),s=function(e,t){const n=Object.create(null);for(const r of t){const t=new Map;for(const n of e){if(!a(n))continue;const e=n[r];if("string"!=typeof e&&"boolean"!=typeof e)continue;const o=e+"";t.set(o,(t.get(o)??0)+1)}t.size&&(n[r]=Array.from(t).sort(([e,t],[n,r])=>r-t||e.localeCompare(n)).slice(0,10).map(([e,t])=>({value:e,n:t})))}return Object.keys(n).length?n:void 0}(t,r);return{handleRef:e.handleRef,detail:e.detail,table:null,rowCount:e.rows.length,columns:n,...o?{numeric:o}:{},...i?{temporal:i}:{},...s?{categoricalTopValues:s}:{},sampledRows:t.length}}({handleRef:o.ref,rows:o.rows,detail:i,sampleRows:Math.min(s,c)})}}),o.length&&t.dataAccess?.sample&&S(r,{descriptor:{name:A,title:"Inspect bounded Semiotic rows",description:"Return a bounded JSON sample from a chart DataHandle. This action is opt-in.",targetRef:n.view,parameters:{type:"object",properties:{handleRef:{type:"string",enum:o},offset:{type:"number",minimum:0},limit:{type:"number",minimum:1}},required:["handleRef"]}},execute(n){const r=x(n,A);if("string"!=typeof r.handleRef)throw Error("params.handleRef must be a DataHandle ref.");const o=e.dataHandles.find(e=>e.ref===r.handleRef);if(!o)throw Error(`Unknown DataHandle "${r.handleRef}".`);const i="number"==typeof r.offset&&Number.isFinite(r.offset)?Math.max(0,Math.floor(r.offset)):0,a=k(t.dataAccess?.maxSampleRows,50),c="number"==typeof r.limit&&Number.isFinite(r.limit)?Math.max(1,Math.floor(r.limit)):Math.min(20,a),l=Math.min(c,a),f=o.rows.slice(i,i+l);return{handleRef:o.ref,offset:i,limit:l,rowCount:o.rows.length,rows:s(f,{maxArrayLength:a}),truncated:o.rows.length>i+f.length}}});const i=e.selections.map(e=>e.ref),l=e.selections.filter(e=>e.modes.has("point"));l.length&&t.selectionActions?.setPointSelection&&S(r,{descriptor:{name:y,title:"Set point selection",description:"Set a named LinkedCharts point-selection clause with allowlisted fields.",targetRef:n.view,parameters:{type:"object",properties:{selectionRef:{type:"string",enum:l.map(e=>e.ref)},fields:{type:"object"}},required:["selectionRef","fields"]}},async execute(n){const r=x(n,y),o=O(r,e.selections,"point"),i=function(e,t){if(!a(e)||!Object.keys(e).length)throw Error("params.fields must be a non-empty object.");const n=Object.create(null);for(const[r,o]of Object.entries(e)){if(!t.includes(r))throw Error(`Field "${r}" is not allowed for this selection.`);if(!Array.isArray(o)||!o.length)throw Error(`Point selection field "${r}" requires values[].`);for(const e of o)if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&("number"!=typeof e||!Number.isFinite(e)))throw Error(`Point selection field "${r}" only accepts JSON primitive values.`);n[r]=[...o]}return n}(r.fields,o.fields);return await(t.selectionActions?.setPointSelection?.(o.name,o.clientId,i)),{selectionRef:o.ref,fields:i}}});const f=e.selections.filter(e=>e.modes.has("interval"));f.length&&t.selectionActions?.setIntervalSelection&&S(r,{descriptor:{name:b,title:"Set interval selection",description:"Set a named LinkedCharts interval-selection clause in data units.",targetRef:n.view,parameters:{type:"object",properties:{selectionRef:{type:"string",enum:f.map(e=>e.ref)},fields:{type:"object"}},required:["selectionRef","fields"]}},async execute(n){const r=x(n,b),o=O(r,e.selections,"interval"),i=function(e,t){if(!a(e)||!Object.keys(e).length)throw Error("params.fields must be a non-empty object.");const n=Object.create(null);for(const[r,o]of Object.entries(e)){if(!t.includes(r))throw Error(`Field "${r}" is not allowed for this selection.`);if(!Array.isArray(o)||2!==o.length||"number"!=typeof o[0]||"number"!=typeof o[1]||!Number.isFinite(o[0])||!Number.isFinite(o[1]))throw Error(`Interval selection field "${r}" requires [min,max].`);n[r]=[Math.min(o[0],o[1]),Math.max(o[0],o[1])]}return n}(r.fields,o.fields);return await(t.selectionActions?.setIntervalSelection?.(o.name,o.clientId,i)),{selectionRef:o.ref,fields:i}}}),i.length&&t.selectionActions?.clearSelection&&S(r,{descriptor:{name:v,title:"Clear selection",description:"Clear every active clause from one named LinkedCharts selection.",targetRef:n.view,parameters:{type:"object",properties:{selectionRef:{type:"string",enum:i}},required:["selectionRef"]}},async execute(n){const r=O(x(n,v),e.selections);return await(t.selectionActions?.clearSelection?.(r.name)),{selectionRef:r.ref,cleared:!0}}});const u=e.charts.map(e=>e.navigation).filter(e=>!!e&&e.index.valid&&!!e.binding.onActiveChange);u.length&&S(r,{descriptor:{name:w,title:"Activate chart navigation target",description:"Move an accessible chart navigation tree to a uniquely identified datum.",targetRef:n.view,parameters:{type:"object",properties:{navigationRef:{type:"string",enum:u.map(e=>e.ref)},match:{type:"object"}},required:["navigationRef","match"]}},execute(e){const t=x(e,w);if("string"!=typeof t.navigationRef)throw Error("params.navigationRef must be a navigation ref.");const n=u.find(e=>e.ref===t.navigationRef);if(!n)throw Error(`Unknown navigation ref "${t.navigationRef}".`);const r=function(e,t){if(!a(e))throw Error("params.match must be an object.");for(const n of Object.keys(e))if(!t.includes(n))throw Error(`params.match includes undeclared field "${n}".`);const n=Object.create(null);for(const r of t){if(!Object.prototype.hasOwnProperty.call(e,r)||!j(e[r]))throw Error(`params.match requires a primitive value for "${r}".`);n[r]=e[r]instanceof Date?e[r].toISOString():e[r]}return n}(t.match,n.index.matchFields),o=n.index.byKey.get(d(r));if(!o)throw Error("No navigation datum matches params.match.");return n.binding.onActiveChange?.(o),{navigationRef:n.ref,targetRef:n.index.targetRef(r),match:r}}});const m="function"==typeof t.actions?t.actions():t.actions;for(const e of m??[])e.available&&!e.available()||S(r,{descriptor:{...e.descriptor,...e.descriptor.parameters?{parameters:c(e.descriptor.parameters)}:{}},async execute(t){const n=e.validate?.(t);if("string"==typeof n&&n)throw Error(n);return e.execute(t)}});return r}var E=["data","nodes","edges","points","areas","lines","flows"],M=[["xAccessor","x"],["yAccessor","y"],["categoryAccessor","category"],["valueAccessor","value"],["colorBy","color"],["sizeAccessor","size"],["lineBy","series"],["groupAccessor","group"],["oAccessor","ordinal"],["rAccessor","radial"],["sourceAccessor","source"],["targetAccessor","target"],["nodeIDAccessor","id"]];function D(e,t){const n=e.trim();if(!n)throw Error(t+" must be a non-empty string.");return encodeURIComponent(n)}function $(e,...t){return`${e}/${t.map(e=>D(e,"VACP ref segment")).join("/")}`}function F(e){const t=e.now?.()??new Date,n=t instanceof Date?t:new Date(t);if(!Number.isFinite(n.getTime()))throw Error("VACP bridge clock returned an invalid date.");return n.toISOString()}function N(e){try{const{createdAt:n,...r}=t(e.component,e.props,{includeData:!1});return c(r)}catch(t){const n=Object.create(null);for(const[t,r]of Object.entries(e.props)){if(E.includes(t)||"function"==typeof r)continue;const e=s(r);void 0!==e&&(n[t]=e)}return{component:e.component,props:n,version:"unregistered",warning:t instanceof Error?t.message:"Chart config could not be serialized by toConfig."}}}function P(t){return e(t.component,t.props,{...t.grounding,audience:t.audience,includeStructure:!0,maxLeaves:1})}function L(e,t){const n=[];for(const r of E){const o=e.props[r];Array.isArray(o)&&n.push({ref:t.data(e.chartId,r),chartId:e.chartId,collection:r,rows:o})}return n}function V(e,t){t(e);for(const n of e.children??[])V(n,t)}function z(e,t){if(!t)return;let n;return V(e,e=>{n||e.id!==t||(n=e)}),n}function H(e){return null==e||"string"==typeof e||"number"==typeof e&&Number.isFinite(e)||"boolean"==typeof e||e instanceof Date&&Number.isFinite(e.getTime())}function _(e,t){if("datum"!==e.role||!e.datum)return;const n=Object.create(null);for(const r of t){if(!Object.prototype.hasOwnProperty.call(e.datum,r)||!H(e.datum[r]))return;n[r]=e.datum[r]instanceof Date?e.datum[r].toISOString():e.datum[r]}return n}function q(e,t){const n=Array.from(new Set(e.matchFields.map(e=>e.trim()).filter(Boolean))),r=new Map;if(!n.length)return{valid:!1,diagnostic:"Navigation actions require at least one durable match field.",byKey:r,matchFields:n,targetRef:()=>$(t,"target","invalid")};let o,i=0,a=0,s=!1;return V(e.tree,e=>{if("datum"!==e.role)return;i++;const t=_(e,n);if(!t)return void a++;const o=d(t);r.has(o)?s=!0:r.set(o,e)}),i?a?o=a+" navigation leaves lack durable primitive match-field values.":s&&(o="Navigation match fields do not uniquely identify every datum leaf."):o="Navigation tree has no datum leaves.",{valid:!o,...o?{diagnostic:o}:{},byKey:r,matchFields:n,targetRef:e=>$(t,"target",d(e))}}function T(e,t){const{chart:n,ref:r,configRef:o,grounding:i}=e,s=[{ref:r,kind:"Visualization",layer:"VisualizationLayer",title:n.title??(n.props.title??n.component)+"",description:n.description??i.text,data:c({component:n.component,grounding:{description:i.description,intent:i.intent,physics:i.physics,text:i.text},audience:n.audience})},{ref:o,kind:"Param",layer:"ConfigLayer",title:n.component+" configuration",description:"Serializable Semiotic chart configuration with raw data collections omitted.",data:e.config}],l=[{from:e.ref,to:o,kind:"contains"}],f=(i.structure?.children??[]).filter(e=>"axis"===e.role).map(e=>e.label);let d=0;for(const[e,t]of M){const o=n.props[e];if("string"!=typeof o||!o.trim())continue;const i=$(r,"encoding",t);if(s.push({ref:i,kind:"EncodingChannel",layer:"VisualizationLayer",title:`${t} → ${o}`,data:{channel:t,field:o,accessorProp:e}}),l.push({from:r,to:i,kind:"contains"}),"x"===t||"y"===t||"category"===t||"value"===t||"ordinal"===t||"radial"===t){const e=$(r,"axis",t);s.push({ref:e,kind:"Axis",layer:"VisualizationLayer",title:f[d++]??`${t} axis: ${o}`,data:{channel:t,field:o}}),l.push({from:r,to:e,kind:"contains"}),l.push({from:e,to:i,kind:"derivedFrom"})}}for(const o of e.dataHandles)s.push({ref:o.ref,kind:"DataHandle",layer:"DataLayer",title:`${n.chartId}.${o.collection}`,description:"Bounded details-on-demand handle. Use vacp.data_schema before requesting an opt-in sample.",data:{collection:o.collection,rowCount:o.rows.length,schemaAction:I,...t.dataAccess?.sample?{inspectAction:A}:{}}}),l.push({from:r,to:o.ref,kind:"contains"});if(e.navigation){const{navigation:t}=e;s.push({ref:t.ref,kind:"Selection",layer:"InteractionFeedbackLayer",title:(n.title??n.component)+" structured navigation",description:t.index.diagnostic??"Active accessible-navigation target identified by durable datum fields.",data:{matchFields:t.index.matchFields,targetCount:t.index.byKey.size,status:t.index.valid?t.binding.onActiveChange?"actionable":"read-only":"ambiguous"}}),l.push({from:r,to:t.ref,kind:"contains"})}if(t.getObservations){const e=$(r,"interaction","latest-observation");s.push({ref:e,kind:"InteractionTarget",layer:"InteractionFeedbackLayer",title:(n.title??n.component)+" latest observation",description:"Latest semantic hover, focus, selection, brush, activation, or control observation."}),l.push({from:r,to:e,kind:"contains"})}const u=Array.isArray(n.props.annotations)?n.props.annotations:[],m=new Set;for(const e of u){if(!a(e))continue;const t=a(e.provenance)?e.provenance:void 0,o=e.id??e.stableId??t?.stableId,i=null==o||""===o?void 0:o+"";if(!i)continue;const f=a(e.note)?e.note:void 0,d=a(e.noteData)?e.noteData:void 0,u=$(r,"annotation",i);if(m.has(u))throw Error(`Duplicate stable annotation id "${i.trim()}" in VACP chart "${n.chartId}".`);m.add(u),s.push({ref:u,kind:"InteractionTarget",layer:"VisualizationLayer",title:(e.label??f?.label??d?.label??"Annotation "+i)+"",description:"string"==typeof e.note?e.note:"string"==typeof e.description?e.description:void 0,data:c({id:i,provenance:t,lifecycle:e.lifecycle})}),l.push({from:r,to:u,kind:"contains"})}return{nodes:s,edges:l}}function K(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if(r.chartId===t)return r}}function B(e,t){const n=function(e,t){const n=function(e){const t="function"==typeof e?e():e,n=new Set;for(const e of t){const t=e.chartId.trim();if(!t)throw Error("Every VACP chart requires a non-empty chartId.");if(n.has(t))throw Error(`Duplicate VACP chartId "${t}".`);n.add(t)}return t}(e.charts),r=n.map(e=>{const n=t.visualization(e.chartId),r=e.navigation?{ref:t.navigation(e.chartId),chartRef:n,chartId:e.chartId,binding:e.navigation,index:q(e.navigation,t.navigation(e.chartId))}:void 0;return{chart:e,ref:n,configRef:t.config(e.chartId),grounding:P(e),config:N(e),dataHandles:L(e,t),...r?{navigation:r}:{}}}),o=function(e,t){const n=new Map;for(const t of e)for(const e of t.chart.selections??[]){const r=e.name.trim();if(!r)throw Error("VACP selection names must be non-empty.");const o=n.get(r)??{fields:new Set,modes:new Set,chartRefs:new Set};for(const t of e.fields.map(e=>e.trim()))t&&o.fields.add(t);if("interval"!==e.mode&&o.modes.add("point"),"point"!==e.mode&&o.modes.add("interval"),e.clientId){if(o.clientId&&o.clientId!==e.clientId)throw Error(`Selection "${r}" declares conflicting VACP clientIds.`);o.clientId=e.clientId}o.chartRefs.add(t.ref),n.set(r,o)}return Array.from(n).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>{if(0===n.fields.size)throw Error(`Selection "${e}" requires at least one allowlisted field.`);return{ref:t.selection(e),name:e,fields:Array.from(n.fields).sort(),modes:n.modes,clientId:n.clientId??"__semiotic-vacp__:"+e,chartRefs:Array.from(n.chartRefs)}})}(r,t),i=r.flatMap(e=>e.dataHandles),a=[{ref:t.app,kind:"App",layer:"ViewLayer",title:e.title??e.appId,description:"Semiotic application state exposed through the experimental VACP 0.1.0 bridge.",data:{provider:"semiotic",protocol:R}},{ref:t.view,kind:"View",layer:"ViewLayer",title:e.title??e.viewId??"Semiotic charts"}],s=[{from:t.app,to:t.view,kind:"contains"}];for(const n of r){const r=T(n,e);a.push(...r.nodes),s.push(...r.edges),s.push({from:t.view,to:n.ref,kind:"contains"})}for(const e of o){a.push({ref:e.ref,kind:"Selection",layer:"InteractionFeedbackLayer",title:"Selection: "+e.name,description:"Named LinkedCharts selection. Agent mutations are restricted to declared fields and modes.",data:{name:e.name,fields:e.fields,modes:Array.from(e.modes).sort()}}),s.push({from:t.view,to:e.ref,kind:"contains"});for(const t of e.chartRefs)s.push({from:e.ref,to:t,kind:"controls"})}return{charts:r,selections:o,dataHandles:i,nodes:a,edges:s}}(e,t);return{...n,actions:C(n,e,t)}}function U(e){const t=e.viewId?.trim()||"main",n=function(e,t){const n="vacp://"+D(e,"appId"),r=$(n,"view",t),o=e=>$(r,"visualization",e);return{app:n,view:r,visualization:o,config:e=>$(o(e),"config"),data:(e,t="data")=>$(o(e),"data",t),selection:e=>$(r,"selection",e),navigation:e=>$(o(e),"navigation"),observation:e=>$(o(e),"interaction","latest-observation")}}(e.appId,t),r="number"==typeof e.stateCacheSize&&Number.isFinite(e.stateCacheSize)?Math.max(1,Math.floor(e.stateCacheSize)):64,o=new Map;return{version:R,refs:n,getCapabilities:t=>{const r=B(e,n),o={version:R,createdAt:F(e),graph:{version:R,nodes:r.nodes,edges:r.edges,actions:r.actions.map(e=>e.descriptor)}};return t?function(e,t){const n=function(e){return{refs:u(e.refs),prefixes:u(e.prefixes),kinds:e.kinds?.length?new Set(e.kinds):void 0,layers:e.layers?.length?new Set(e.layers):void 0,includeActions:!1!==e.includeActions,includeEdges:!1!==e.includeEdges,includeNodeData:!1!==e.includeNodeData}}(t),r=e.graph.nodes.filter(e=>function(e,t){return!((t.refs?.length||t.prefixes?.length)&&!t.refs?.includes(e.ref)&&!t.prefixes?.some(t=>e.ref===t||e.ref.startsWith(t+"/")))&&(!t.kinds||t.kinds.has(e.kind))&&(!t.layers||t.layers.has(e.layer))}(e,n)).map(e=>{if(n.includeNodeData)return e;const{data:t,...r}=e;return r}),o=new Set(r.map(e=>e.ref)),i=n.includeActions?e.graph.actions.filter(e=>{if(!e.targetRef)return!0;if(o.has(e.targetRef))return!0;for(const t of o)if(t.startsWith(e.targetRef+"/"))return!0;return!1}):[];return{version:e.version,createdAt:e.createdAt,graph:{version:e.graph.version,nodes:r,edges:n.includeEdges?e.graph.edges.filter(e=>o.has(e.from)&&o.has(e.to)):[],actions:i}}}(o,t):o},getState:async function(t){const i=function(e,t,n){const r={},o={},i=t.getSelections?.()??{},a=t.getObservations?.()??[];for(const i of e.charts){r[i.ref]=c({component:i.chart.component,description:i.grounding.description,intent:i.grounding.intent,physics:i.grounding.physics,audience:i.chart.audience}),r[i.configRef]=i.config,o[i.ref]={component:i.chart.component,dataHandles:i.dataHandles.length};for(const e of i.dataHandles)r[e.ref]={kind:"DataHandle",collection:e.collection,rowCount:e.rows.length},o[e.ref]={rowCount:e.rows.length};if(i.navigation){const e=z(i.navigation.binding.tree,i.navigation.binding.activeId),t=e?_(e,i.navigation.index.matchFields):void 0;r[i.navigation.ref]=c({kind:"Selection",status:i.navigation.index.valid?"ready":"ambiguous",activeRole:e?.role,activeLabel:e?.label,activeMatch:t,activeTargetRef:t?i.navigation.index.targetRef(t):void 0,diagnostic:i.navigation.index.diagnostic}),o[i.navigation.ref]={targetCount:i.navigation.index.byKey.size}}if(t.getObservations){const e=K(a,i.chart.chartId);r[n.observation(i.chart.chartId)]=e?c(e):null,e&&(o[n.observation(i.chart.chartId)]={type:e.type,timestamp:e.timestamp})}}for(const t of e.selections){const e=i[t.name];r[t.ref]=(e?c(e):void 0)??{name:t.name,resolution:"union",clauses:[]},o[t.ref]={active:!!e?.clauses.length,clauseCount:e?.clauses.length??0,fields:t.fields}}return{version:R,createdAt:F(t),state:r,...Object.keys(o).length?{summary:o}:{}}}(B(e,n),e,n);if(!t)return i;const{snapshot:a,refs:s}=p(i,t),l="st_"+d({state:(f=a).state,...f.summary?{summary:f.summary}:{}});var f;const u=t.since?o.get(t.since):void 0;let m;if("full"!==t.mode&&t.since&&u){const e=p(u,t).snapshot;m={version:R,createdAt:a.createdAt,mode:"delta",token:l,baseToken:t.since,...s?{scope:{refs:s}}:{},delta:h(e,a)}}else m={version:R,createdAt:a.createdAt,mode:"full",token:l,...s?{scope:{refs:s}}:{},snapshot:a};return((e,t)=>{for(o.has(e)&&o.delete(e),o.set(e,t);o.size>r;){const e=o.keys().next().value;if("string"!=typeof e)break;o.delete(e)}})(l,i),m},execute:async t=>{const r=t&&"string"==typeof t.callId?t.callId:"";try{if(!t||"string"!=typeof t.name||!t.name.trim())throw Error("VACP action call requires a non-empty name.");if(!r)throw Error("VACP action call requires a callId.");const o=B(e,n),i=o.actions.find(e=>e.descriptor.name===t.name);if(!i)return{callId:r,ok:!1,error:{message:`Unknown or currently unavailable VACP action "${t.name}".`,details:{available:o.actions.map(e=>e.descriptor.name)}}};const a=s(await i.execute(t.params));return{callId:r,ok:!0,...void 0!==a?{result:a}:{}}}catch(e){return{callId:r,ok:!1,error:{message:e instanceof Error?e.message:"VACP action failed."}}}}}}function J(e){const t=Object.create(null);for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)};return t}function W(e){const t=Object.create(null);for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:[r[0],r[1]]};return t}function Q(e){const t=i(e=>e.selections),a=i(e=>e.setClause),s=i(e=>e.clearSelection),c=o(e=>e.observations),l=o(e=>e.version),f=r(null);return f.current={...e,selections:t,setClause:a,clearSelection:s,observations:c,observationVersion:l},n(()=>{const e=f.current;if(!e)return;const t={appId:e.appId,viewId:e.viewId,stateCacheSize:e.stateCacheSize,get title(){return f.current?.title},charts:()=>{const e=f.current?.charts??[];return"function"==typeof e?e():e},getSelections:()=>{const e=f.current;return e?function(e){const t=Object.create(null);for(const[n,r]of e){const e=[];for(const[,t]of r.clauses){const n=Object.create(null);for(const[e,r]of Object.entries(t.fields))n[e]="point"===r.type?{type:"point",values:Array.from(r.values)}:{type:"interval",range:r.range};e.push({clientId:t.clientId,type:t.type,fields:n})}t[n]={name:r.name,resolution:r.resolution,clauses:e}}return t}(e.selections):{}},getObservations:()=>{const e=f.current;return e?e.observations:[]},selectionActions:{setPointSelection(e,t,n){f.current?.setClause(e,{clientId:t,type:"point",fields:J(n)})},setIntervalSelection(e,t,n){f.current?.setClause(e,{clientId:t,type:"interval",fields:W(n)})},clearSelection(e){f.current?.clearSelection(e)}},get dataAccess(){return f.current?.dataAccess},actions:()=>{const e=f.current?.actions;return("function"==typeof e?e():e)??[]},now:()=>f.current?.now?.()??new Date},n=function(e,t={}){const n=t.globalKey?.trim()||"__vacp",r=t.target??("undefined"!=typeof window?window:void 0);if(!r)return{installed:!1,globalKey:n,bridge:e,reason:`Refused to install "${n}" without a browser window or an explicit target.`,cleanup:()=>!1};if("__proto__"===n||"prototype"===n||"constructor"===n)return{installed:!1,globalKey:n,bridge:e,reason:`Refused unsafe global key "${n}".`,cleanup:()=>!1};const o=r[n];if(void 0!==o&&o!==e)return{installed:!1,globalKey:n,bridge:e,reason:`Refused to replace existing global "${n}".`,cleanup:()=>!1};try{r[n]=e}catch(t){return{installed:!1,globalKey:n,bridge:e,reason:t instanceof Error?`Could not install "${n}": ${t.message}`:`Could not install "${n}".`,cleanup:()=>!1}}return{installed:!0,globalKey:n,bridge:e,cleanup:()=>{if(r[n]!==e)return!1;try{return delete r[n]}catch{return!1}}}}(U(t),{globalKey:e.globalKey});return f.current?.onInstallationChange?.(n),()=>{n.cleanup()}},[]),null}export{Q as SemioticVACPBridge};
@@ -1 +1 @@
1
- var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,a={};function i(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function s(e,t={}){const n="number"==typeof t.maxDepth&&Number.isFinite(t.maxDepth)?Math.max(1,Math.floor(t.maxDepth)):10,r="number"==typeof t.maxArrayLength&&Number.isFinite(t.maxArrayLength)?Math.max(1,Math.floor(t.maxArrayLength)):1e3,o=new WeakSet,a=(e,t)=>{if(null==e||"string"==typeof e||"boolean"==typeof e)return e;if("number"==typeof e)return Number.isFinite(e)?e:e+"";if("bigint"==typeof e)return""+e;if("function"==typeof e||"symbol"==typeof e||void 0===e)return;if(e instanceof Date)return e.toISOString();if(t>=n)return"[depth limit]";if("object"!=typeof e)return e+"";if("$$typeof"in e)return;if(o.has(e))return"[circular]";if(o.add(e),Array.isArray(e)){const n=e.slice(0,r).map(e=>a(e,t+1)).filter(e=>void 0!==e);return o.delete(e),n}if(e instanceof Set){const n=Array.from(e).slice(0,r).map(e=>a(e,t+1)).filter(e=>void 0!==e);return o.delete(e),n}if(e instanceof Map){const n=Object.create(null);let i=0;for(const[o,s]of e){if(i++>=r)break;const e=a(s,t+1);void 0!==e&&(n[o+""]=e)}return o.delete(e),n}const i=Object.create(null);for(const n of Object.keys(e).sort()){const r=a(e[n],t+1);void 0!==r&&(i[n]=r)}return o.delete(e),i};return a(e,0)}function l(e){const t=s(e);return i(t)?t:{}}function c(e){if(Array.isArray(e))return e.map(c);if(!i(e))return e;const t=Object.create(null);for(const n of Object.keys(e).sort())t[n]=c(e[n]);return t}function u(e){return JSON.stringify(c(s(e)))}function d(e){return function(e){let t=BigInt("14695981039346656037");const n=BigInt("1099511628211"),r=BigInt("0xffffffffffffffff");for(let o=0;e.length>o;o++)t^=BigInt(e.charCodeAt(o)),t=t*n&r;return t.toString(16).padStart(16,"0")}(u(e))}function f(e){if(!e?.length)return;const t=Array.from(new Set(e.filter(e=>"string"==typeof e&&e.length))).sort();return t.length?t:void 0}function h(e,t){return t.some(t=>e===t||e.startsWith(t+"/"))}function m(e,t){const n=f(t.refs),r=!1!==t.includeSummary;if(!n)return{snapshot:{version:e.version,createdAt:e.createdAt,state:e.state,...r&&e.summary?{summary:e.summary}:{}}};const o={};for(const[t,r]of Object.entries(e.state))h(t,n)&&(o[t]=r);const a={};if(r&&e.summary)for(const[t,r]of Object.entries(e.summary))h(t,n)&&(a[t]=r);return{snapshot:{version:e.version,createdAt:e.createdAt,state:o,...Object.keys(a).length?{summary:a}:{}},refs:n}}function p(e,t){const n={},r=[];for(const[r,o]of Object.entries(t.state))Object.prototype.hasOwnProperty.call(e.state,r)&&u(e.state[r])===u(o)||(n[r]=o);for(const n of Object.keys(e.state))Object.prototype.hasOwnProperty.call(t.state,n)||r.push(n);const o={},a=[],i=e.summary??{},s=t.summary??{};for(const[e,t]of Object.entries(s))Object.prototype.hasOwnProperty.call(i,e)&&u(i[e])===u(t)||(o[e]=t);for(const e of Object.keys(i))Object.prototype.hasOwnProperty.call(s,e)||a.push(e);return{changed:n,removed:r.sort(),...Object.keys(o).length?{summaryChanged:o}:{},...a.length?{summaryRemoved:a.sort()}:{}}}function g(e){return null==e?"NULL":"number"==typeof e?"DOUBLE":"string"==typeof e?"VARCHAR":"boolean"==typeof e?"BOOLEAN":e instanceof Date?"TIMESTAMP":Array.isArray(e)?"ARRAY":"OBJECT"}((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(a,{unstable_SEMIOTIC_VACP_ACTIVATE_NAVIGATION_ACTION:()=>$,unstable_SEMIOTIC_VACP_CLEAR_SELECTION_ACTION:()=>v,unstable_SEMIOTIC_VACP_INSPECT_DATA_ACTION:()=>w,unstable_SEMIOTIC_VACP_SET_INTERVAL_SELECTION_ACTION:()=>b,unstable_SEMIOTIC_VACP_SET_POINT_SELECTION_ACTION:()=>y,unstable_VACP_DATA_SCHEMA_ACTION:()=>A,unstable_VACP_SCHEMA_VERSION:()=>C,unstable_createSemioticVACPBridge:()=>lt,unstable_installSemioticVACPBridge:()=>ct}),module.exports=(e=a,((e,a,i,s)=>{if(a)for(let i of r(a))o.call(e,i)||void 0===i||t(e,i,{get:()=>a[i],enumerable:!(s=n(a,i))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var y="semiotic.set_point_selection",b="semiotic.set_interval_selection",v="semiotic.clear_selection",$="semiotic.activate_navigation_node",w="semiotic.inspect_data",C="0.1.0",A="vacp.data_schema";function S(e,t){if(!t.descriptor.name.trim())throw Error("VACP action names must be non-empty.");if(e.some(e=>e.descriptor.name===t.descriptor.name))throw Error(`Duplicate VACP action "${t.descriptor.name}".`);e.push(t)}function x(e,t){if(!i(e))throw Error(t+" expects an object parameter payload.");return e}function k(e,t){return"number"==typeof e&&Number.isFinite(e)?Math.max(1,Math.floor(e)):t}function j(e,t,n){if("string"!=typeof e.selectionRef)throw Error("params.selectionRef must be a VACP selection ref.");const r=t.find(t=>t.ref===e.selectionRef);if(!r)throw Error(`Unknown selection ref "${e.selectionRef}".`);if(n&&!r.modes.has(n))throw Error(`Selection "${r.name}" does not accept ${n} state.`);return r}function I(e){return null==e||"string"==typeof e||"number"==typeof e&&Number.isFinite(e)||"boolean"==typeof e||e instanceof Date&&Number.isFinite(e.getTime())}function P(e,t,n){const r=[],o=e.dataHandles.map(e=>e.ref);o.length&&S(r,{descriptor:{name:A,title:"Describe Semiotic data",description:"Return columns, types, row count, and optional bounded summaries for a chart DataHandle.",targetRef:n.view,parameters:{type:"object",properties:{handleRef:{type:"string",enum:o},detail:{type:"string",enum:["columns","full"]},sampleRows:{type:"number",minimum:1}},required:["handleRef"]}},execute(n){const r=x(n,A);if("string"!=typeof r.handleRef)throw Error("params.handleRef must be a DataHandle ref.");const o=e.dataHandles.find(e=>e.ref===r.handleRef);if(!o)throw Error(`Unknown DataHandle "${r.handleRef}".`);const a=void 0===r.detail||"columns"===r.detail?"columns":"full"===r.detail?"full":(()=>{throw Error('params.detail must be "columns" or "full".')})(),s="number"==typeof r.sampleRows&&Number.isFinite(r.sampleRows)?Math.max(1,Math.floor(r.sampleRows)):"full"===a?1e3:Math.min(o.rows.length,1e3),l=k(t.dataAccess?.maxSchemaRows,5e3);return function(e){const t=e.rows.slice(0,Math.max(0,e.sampleRows)),n=function(e){const t=new Map;for(const n of e)if(i(n))for(const[e,r]of Object.entries(n)){const n=t.get(e)??new Set;n.add(g(r)),t.set(e,n)}return Array.from(t).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>{const n=Array.from(t).filter(e=>"NULL"!==e);return{name:e,type:0===n.length?"NULL":1===new Set(n).size?n[0]:"MIXED"}})}(e.rows),r=n.map(e=>e.name);if("columns"===e.detail)return{handleRef:e.handleRef,detail:e.detail,table:null,rowCount:e.rows.length,columns:n};const o=function(e,t){const n=Object.create(null);for(const r of t){const t=[];for(const n of e){if(!i(n))continue;const e=n[r];"number"==typeof e&&Number.isFinite(e)&&t.push(e)}if(!t.length)continue;let o=t[0],a=t[0],s=0;for(const e of t)o=Math.min(o,e),a=Math.max(a,e),s+=e;n[r]={min:o,max:a,avg:s/t.length}}return Object.keys(n).length?n:void 0}(t,r),a=function(e,t){const n=Object.create(null);for(const r of t){const t=[];for(const n of e){if(!i(n))continue;const e=n[r];e instanceof Date&&Number.isFinite(e.getTime())&&t.push(e.getTime())}if(!t.length)continue;const o=Math.min(...t),a=Math.max(...t);n[r]={minIso:new Date(o).toISOString(),maxIso:new Date(a).toISOString(),minEpochMs:o,maxEpochMs:a}}return Object.keys(n).length?n:void 0}(t,r),s=function(e,t){const n=Object.create(null);for(const r of t){const t=new Map;for(const n of e){if(!i(n))continue;const e=n[r];if("string"!=typeof e&&"boolean"!=typeof e)continue;const o=e+"";t.set(o,(t.get(o)??0)+1)}t.size&&(n[r]=Array.from(t).sort(([e,t],[n,r])=>r-t||e.localeCompare(n)).slice(0,10).map(([e,t])=>({value:e,n:t})))}return Object.keys(n).length?n:void 0}(t,r);return{handleRef:e.handleRef,detail:e.detail,table:null,rowCount:e.rows.length,columns:n,...o?{numeric:o}:{},...a?{temporal:a}:{},...s?{categoricalTopValues:s}:{},sampledRows:t.length}}({handleRef:o.ref,rows:o.rows,detail:a,sampleRows:Math.min(s,l)})}}),o.length&&t.dataAccess?.sample&&S(r,{descriptor:{name:w,title:"Inspect bounded Semiotic rows",description:"Return a bounded JSON sample from a chart DataHandle. This action is opt-in.",targetRef:n.view,parameters:{type:"object",properties:{handleRef:{type:"string",enum:o},offset:{type:"number",minimum:0},limit:{type:"number",minimum:1}},required:["handleRef"]}},execute(n){const r=x(n,w);if("string"!=typeof r.handleRef)throw Error("params.handleRef must be a DataHandle ref.");const o=e.dataHandles.find(e=>e.ref===r.handleRef);if(!o)throw Error(`Unknown DataHandle "${r.handleRef}".`);const a="number"==typeof r.offset&&Number.isFinite(r.offset)?Math.max(0,Math.floor(r.offset)):0,i=k(t.dataAccess?.maxSampleRows,50),l="number"==typeof r.limit&&Number.isFinite(r.limit)?Math.max(1,Math.floor(r.limit)):Math.min(20,i),c=Math.min(l,i),u=o.rows.slice(a,a+c);return{handleRef:o.ref,offset:a,limit:c,rowCount:o.rows.length,rows:s(u,{maxArrayLength:i}),truncated:o.rows.length>a+u.length}}});const a=e.selections.map(e=>e.ref),c=e.selections.filter(e=>e.modes.has("point"));c.length&&t.selectionActions?.setPointSelection&&S(r,{descriptor:{name:y,title:"Set point selection",description:"Set a named LinkedCharts point-selection clause with allowlisted fields.",targetRef:n.view,parameters:{type:"object",properties:{selectionRef:{type:"string",enum:c.map(e=>e.ref)},fields:{type:"object"}},required:["selectionRef","fields"]}},async execute(n){const r=x(n,y),o=j(r,e.selections,"point"),a=function(e,t){if(!i(e)||!Object.keys(e).length)throw Error("params.fields must be a non-empty object.");const n=Object.create(null);for(const[r,o]of Object.entries(e)){if(!t.includes(r))throw Error(`Field "${r}" is not allowed for this selection.`);if(!Array.isArray(o)||!o.length)throw Error(`Point selection field "${r}" requires values[].`);for(const e of o)if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&("number"!=typeof e||!Number.isFinite(e)))throw Error(`Point selection field "${r}" only accepts JSON primitive values.`);n[r]=[...o]}return n}(r.fields,o.fields);return await(t.selectionActions?.setPointSelection?.(o.name,o.clientId,a)),{selectionRef:o.ref,fields:a}}});const u=e.selections.filter(e=>e.modes.has("interval"));u.length&&t.selectionActions?.setIntervalSelection&&S(r,{descriptor:{name:b,title:"Set interval selection",description:"Set a named LinkedCharts interval-selection clause in data units.",targetRef:n.view,parameters:{type:"object",properties:{selectionRef:{type:"string",enum:u.map(e=>e.ref)},fields:{type:"object"}},required:["selectionRef","fields"]}},async execute(n){const r=x(n,b),o=j(r,e.selections,"interval"),a=function(e,t){if(!i(e)||!Object.keys(e).length)throw Error("params.fields must be a non-empty object.");const n=Object.create(null);for(const[r,o]of Object.entries(e)){if(!t.includes(r))throw Error(`Field "${r}" is not allowed for this selection.`);if(!Array.isArray(o)||2!==o.length||"number"!=typeof o[0]||"number"!=typeof o[1]||!Number.isFinite(o[0])||!Number.isFinite(o[1]))throw Error(`Interval selection field "${r}" requires [min,max].`);n[r]=[Math.min(o[0],o[1]),Math.max(o[0],o[1])]}return n}(r.fields,o.fields);return await(t.selectionActions?.setIntervalSelection?.(o.name,o.clientId,a)),{selectionRef:o.ref,fields:a}}}),a.length&&t.selectionActions?.clearSelection&&S(r,{descriptor:{name:v,title:"Clear selection",description:"Clear every active clause from one named LinkedCharts selection.",targetRef:n.view,parameters:{type:"object",properties:{selectionRef:{type:"string",enum:a}},required:["selectionRef"]}},async execute(n){const r=j(x(n,v),e.selections);return await(t.selectionActions?.clearSelection?.(r.name)),{selectionRef:r.ref,cleared:!0}}});const f=e.charts.map(e=>e.navigation).filter(e=>!!e&&e.index.valid&&!!e.binding.onActiveChange);f.length&&S(r,{descriptor:{name:$,title:"Activate chart navigation target",description:"Move an accessible chart navigation tree to a uniquely identified datum.",targetRef:n.view,parameters:{type:"object",properties:{navigationRef:{type:"string",enum:f.map(e=>e.ref)},match:{type:"object"}},required:["navigationRef","match"]}},execute(e){const t=x(e,$);if("string"!=typeof t.navigationRef)throw Error("params.navigationRef must be a navigation ref.");const n=f.find(e=>e.ref===t.navigationRef);if(!n)throw Error(`Unknown navigation ref "${t.navigationRef}".`);const r=function(e,t){if(!i(e))throw Error("params.match must be an object.");for(const n of Object.keys(e))if(!t.includes(n))throw Error(`params.match includes undeclared field "${n}".`);const n=Object.create(null);for(const r of t){if(!Object.prototype.hasOwnProperty.call(e,r)||!I(e[r]))throw Error(`params.match requires a primitive value for "${r}".`);n[r]=e[r]instanceof Date?e[r].toISOString():e[r]}return n}(t.match,n.index.matchFields),o=n.index.byKey.get(d(r));if(!o)throw Error("No navigation datum matches params.match.");return n.binding.onActiveChange?.(o),{navigationRef:n.ref,targetRef:n.index.targetRef(r),match:r}}});const h="function"==typeof t.actions?t.actions():t.actions;for(const e of h??[])e.available&&!e.available()||S(r,{descriptor:{...e.descriptor,...e.descriptor.parameters?{parameters:l(e.descriptor.parameters)}:{}},async execute(t){const n=e.validate?.(t);if("string"==typeof n&&n)throw Error(n);return e.execute(t)}});return r}var O=["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","RidgelinePlot","DotPlot","PieChart","DonutChart","GaugeChart","FunnelChart","SwimlaneChart","LikertChart","LineChart","BumpChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","BubbleChart","Heatmap","QuadrantChart","MultiAxisLineChart","CandlestickChart","ConnectedScatterplot","ScatterplotMatrix","MinimapChart","ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram","TreeDiagram","Treemap","CirclePack","OrbitDiagram","ChoroplethMap","ProportionalSymbolMap","FlowMap","DistanceCartogram","RealtimeLineChart","RealtimeHistogram","TemporalHistogram","RealtimeSwarmChart","RealtimeWaterfallChart","RealtimeHeatmap","GaltonBoardChart","EventDropChart","UnitPileChart","CollisionSwarmChart","GauntletChart","CrucibleChart","ProcessFlowChart","PacketFlowChart","ChainReactionChart","BigNumber"],R=new Set(O);function F(e,t=new Set){if(null===e)return!0;const n=typeof e;if("string"===n||"boolean"===n)return!0;if("number"===n)return Number.isFinite(e);if("object"!==n)return!1;if(t.has(e))return!1;t.add(e);const r=Array.isArray(e)?e.every(e=>F(e,t)):Object.entries(e).every(([,e])=>F(e,t));return t.delete(e),r}var D=Symbol.for("semiotic.chartRecipeRegistry");function N(e){return function(){const e=globalThis;return e[D]||(e[D]={recipes:new Map,capabilities:new Map,layouts:new Map}),e[D]}().recipes.get(e)}function L(e){return"string"==typeof e?N(e):e&&"object"==typeof e&&"string"==typeof e.id?e:void 0}function M(e){return"string"==typeof e?e:e.id??e.name}function E(e){return e.layoutConfig&&"object"==typeof e.layoutConfig?e.layoutConfig:{}}function T(e){return Array.isArray(e.data)?e.data:Array.isArray(e.nodes)?e.nodes:Array.isArray(e.points)?e.points:Array.isArray(e.areas)?e.areas:[]}function B(e,t,n){return n??L(t.recipe)??L(t.recipeId)??N(e)}function _(e,t,n=[]){const r=e.accessor?t[e.accessor]:void 0;if("string"==typeof r&&r)return r;if(e.field)return e.field;const o=n.find(e=>e&&"object"==typeof e);if(!o)return;const a=Object.entries(o).filter(([e,t])=>!e.startsWith("_")&&null!=t);return"quantitative"===e.semanticType?a.find(([,e])=>"number"==typeof e)?.[0]:"identifier"===e.semanticType?["id","key","name"].find(e=>e in o):a.find(([,e])=>"string"==typeof e)?.[0]}function V(e,t){return e.dataRoles.find(e=>e.role===t)}function z(e,t){return e.dataRoles.find(e=>t.includes(e.semanticType))}function H(e,t,n,r,o,a={}){const i={...a};if(t)for(const[e,n]of Object.entries(t))i[e]=n;for(const e of n.dataRoles){const n=_(e,r,o),a=t&&n?t[n]:n;void 0!==a&&(i[e.role]=a)}return e.replace(/\{([^}]+)\}/g,(e,t)=>{const n=i[t];return null==n?`{${t}}`:n+""})}var q="1",G=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend","recipe","layout"]),U=new Set(["data","nodes","edges","points","areas","lines","flows"]);function K(e){if(null==e)return e;if("function"==typeof e)return;if("object"!=typeof e)return e;if(e.$$typeof)return;if(Array.isArray(e))return e.map(K).filter(e=>void 0!==e);if(e instanceof Date)return e;const t={};for(const[n,r]of Object.entries(e)){if("function"==typeof r)continue;if(r&&"object"==typeof r&&r.$$typeof)continue;const e=K(r);void 0!==e&&(t[n]=e)}return t}function J(e,t){return!!U.has(e)&&("areas"!==e||"string"!=typeof t)}var W="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function Q(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function X(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}var Y=new Set(["LineChart","AreaChart","StackedAreaChart","DifferenceChart","Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","MultiAxisLineChart","MinimapChart"]),Z=new Set(["BarChart","StackedBarChart","GroupedBarChart","DotPlot"]),ee=new Set(["PieChart","DonutChart","FunnelChart"]),te=new Set(["Histogram","BoxPlot","ViolinPlot","RidgelinePlot","SwarmPlot"]);function ne(e,t){return Z.has(e)||ee.has(e)||"SwimlaneChart"===e||"GaugeChart"===e?{measure:t.valueAccessor,measureFallback:"value",dimension:t.categoryAccessor??t.stepAccessor,dimensionFallback:"category"}:{measure:t.yAccessor??t.valueAccessor,measureFallback:"y",dimension:t.xAccessor,dimensionFallback:"x"}}function re(e){for(const t of["lineBy","areaBy","stackBy","groupBy","colorBy"]){const n=e[t];if("string"==typeof n&&n)return n}}function oe(e,t){return null==e?"—":e instanceof Date?e.toISOString().slice(0,10):"number"==typeof e?t(e):e+""}function ae(e,t={}){const n=!0===t.showRetractedAnnotations,r=!0===t.showSupersededAnnotations,o=new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!n)return!1;const t=e?.provenance?.stableId;return!(t&&o.has(t)&&!r)})}var ie={LineChart:"line chart",AreaChart:"area chart",StackedAreaChart:"stacked area chart",DifferenceChart:"difference chart",Scatterplot:"scatter plot",BubbleChart:"bubble chart",ConnectedScatterplot:"connected scatter plot",QuadrantChart:"quadrant chart",MultiAxisLineChart:"dual-axis line chart",CandlestickChart:"candlestick chart",Heatmap:"heatmap",MinimapChart:"line chart",BarChart:"bar chart",StackedBarChart:"stacked bar chart",GroupedBarChart:"grouped bar chart",DotPlot:"dot plot",Histogram:"histogram",BoxPlot:"box plot",ViolinPlot:"violin plot",RidgelinePlot:"ridgeline plot",SwarmPlot:"swarm plot",PieChart:"pie chart",DonutChart:"donut chart",FunnelChart:"funnel chart",GaugeChart:"gauge",LikertChart:"Likert chart",SwimlaneChart:"swimlane chart",ForceDirectedGraph:"network graph",SankeyDiagram:"Sankey diagram",ProcessSankey:"temporal Sankey diagram",ChordDiagram:"chord diagram",TreeDiagram:"tree diagram",Treemap:"treemap",CirclePack:"circle-packing chart",OrbitDiagram:"orbit diagram",ChoroplethMap:"choropleth map",ProportionalSymbolMap:"proportional-symbol map",FlowMap:"flow map",DistanceCartogram:"distance cartogram",BigNumber:"single value",StreamPhysicsFrame:"physics stream frame",EventDropChart:"event-drop physics chart",GaltonBoardChart:"Galton board chart",UnitPileChart:"physics pile chart",CollisionSwarmChart:"collision swarm chart",PacketFlowChart:"physical flow chart",ProcessFlowChart:"process flow physics chart",CrucibleChart:"crucible physics chart",PhysicsCustomChart:"custom physics chart"},se=new Set(["ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram"]),le=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","GauntletChart","CrucibleChart","PhysicsCustomChart"]);function ce(e){return ie[e]||e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()+" chart"}function ue(e){const t="number"==typeof e?e:"string"==typeof e?Number(e):NaN;return Number.isFinite(t)?t:void 0}var de=new Set(["Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","ScatterplotMatrix"]),fe={"outlier-detection":"alerting","change-detection":"alerting",trend:"tracking","composition-over-time":"apportioning","compare-series":"comparing","compare-categories":"comparing",rank:"ranking","part-to-whole":"apportioning",distribution:"characterizing",correlation:"relating",flow:"tracing",hierarchy:"nesting",geo:"locating"},he={"time-series":"tracking",categorical:"comparing",distribution:"characterizing",relationship:"relating",flow:"tracing",network:"tracing",hierarchy:"nesting",geo:"locating",realtime:"tracking",value:"presenting",custom:"presenting"},me=["trend","compare-series","compare-categories","rank","part-to-whole","distribution","correlation","flow","hierarchy","geo","composition-over-time","change-detection","outlier-detection"],pe={alerting:"alerting",tracking:"trend",comparing:"comparison",ranking:"ranking",apportioning:"composition",characterizing:"distribution",relating:"correlation",tracing:"flow",nesting:"hierarchy",locating:"locator",presenting:"single-value"};function ge(e,t){const n=function(e){if(e){if("fits"in e||"buildProps"in e){const t=e,n={};for(const[e,r]of Object.entries(t.intentScores))"number"==typeof r&&Number.isFinite(r)&&(n[e]=r);return{family:t.family,intentScores:Object.keys(n).length?n:void 0}}return e}}(t);if(n?.act)return n.act;if(n?.intentScores){const e=function(e){let t,n=0;for(const[r,o]of Object.entries(e))if("number"==typeof o&&o>0)if(o>n)t=r,n=o;else if(o===n&&void 0!==t){const e=me.indexOf(r),n=me.indexOf(t);-1===e||-1!==n&&e>=n||(t=r)}return t}(n.intentScores);if(e&&fe[e]&&(n.intentScores[e]??0)>=3)return fe[e]}return n?.family?he[n.family]:function(e){return ee.has(e)||"StackedAreaChart"===e?"apportioning":de.has(e)?"relating":Z.has(e)?"comparing":te.has(e)?"characterizing":Y.has(e)?"tracking":se.has(e)?"tracing":"BigNumber"===e?"presenting":void 0}(e)}var ye=new Set(["y-threshold","x-threshold","band","x-band","callout","label"]),be=new Set(["system","agent","watcher"]),ve=new Set(["ai","agent","system","computed","dbt","great-expectations"]),$e=new Set(["rule","statistical-test","llm-inference","computed"]);function we(e){const t=e.annotations;return!!Array.isArray(t)&&t.some(e=>{if(!e||"object"!=typeof e)return!1;const t=e;if("string"!=typeof t.type||!ye.has(t.type))return!1;const n=t.provenance;return!(!n||"object"!=typeof n)&&(be.has(n.authorKind)||ve.has(n.source)||$e.has(n.basis))})}function Ce(e="en"){let t,n;try{t=new Intl.NumberFormat(e,{notation:"compact",maximumFractionDigits:1}),n=new Intl.NumberFormat(e,{maximumFractionDigits:2})}catch{t=new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}),n=new Intl.NumberFormat("en",{maximumFractionDigits:2})}return e=>Number.isFinite(e)?1e4>Math.abs(e)?n.format(e):t.format(e):e+""}var Ae={"y-threshold":"a threshold line","x-threshold":"a threshold line",band:"a highlighted band","x-band":"a highlighted band",label:"a label",callout:"a callout","callout-circle":"a callout","callout-rect":"a callout",text:"a text note",bracket:"a bracket",enclose:"an enclosure","rect-enclose":"an enclosure",highlight:"a highlight",widget:"a widget",trend:"a trend line",envelope:"an envelope","anomaly-band":"an anomaly band",forecast:"a forecast","category-highlight":"a category highlight"};function Se(e){const t=Ae["string"==typeof e.type?e.type:"annotation"]||"an annotation",n=function(e){const t=e.provenance&&"object"==typeof e.provenance?e.provenance:null,n=t?.authorKind??t?.source??t?.basis;return"watcher"===n?"a watcher-flagged ":"agent"===n||"ai"===n||"llm-inference"===n?"an AI-suggested ":""}(e),r=n?n+t.replace(/^an? /,""):t,o="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:void 0;return o?`${r} labeled "${o}"`:r}function xe(e){const t=Array.isArray(e.annotations)?e.annotations:null;if(!t||0===t.length)return;const n=ae(t.filter(e=>!!e&&"object"==typeof e));if(0===n.length)return;const r=n.map(Se),o=r.slice(0,5),a=r.length-o.length,i=function(e){return e.length>1?2===e.length?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")}, and ${e[e.length-1]}`:e[0]??""}(o)+(a>0?`, and ${a} more`:""),s=n.length;return`The author has marked ${1===s?"one feature":s+" features"} on this chart: ${i}.`}function ke(e,t,n={}){const r=void 0!==n.levels,o=new Set(n.levels??["l1","l2","l3"]);r||!n.capability&&!we(t)||o.add("l4");const a=B(e,t,n.recipe);if(a){const e=["l1","l2","l3","l4"].filter(e=>o.has(e));r||e.includes("l4")||e.push("l4");const i=function(e,t,n={}){const r=T(t),o=E(t),a=n.locale??"en",i="function"==typeof e.description?e.description({data:r,config:o,locale:a}):void 0,s=i?.levels??function(e,t,n,r){const o=z(e,["nominal","ordinal"]),a=z(e,["quantitative"]),i=o?_(o,n,t):void 0,s=a?_(a,n,t):void 0,l=o?.role??i??"category",c=a?.role??s??"value",u=e.encodings??[],d=u.length?u.slice(0,3).map(e=>e.meaning.replace(/\.$/,"")).join("; "):`${l} and ${c} are mapped through the recipe's declared visual semantics`,{number:f,percent:h}=function(e){try{return{number:new Intl.NumberFormat(e,{maximumFractionDigits:2}),percent:new Intl.NumberFormat(e,{style:"percent",maximumFractionDigits:1})}}catch{return{number:new Intl.NumberFormat("en",{maximumFractionDigits:2}),percent:new Intl.NumberFormat("en",{style:"percent",maximumFractionDigits:1})}}}(r),m=new Map;if(i&&s)for(const e of t){const t=(e[i]??"Uncategorized")+"",n=Number(e[s]);Number.isFinite(n)&&m.set(t,(m.get(t)??0)+n)}const p=[...m].sort((e,t)=>t[1]-e[1]),g=p.reduce((e,[,t])=>e+t,0),y=p[0],b=p[1],v=g>0?((y?.[1]??0)+(b?.[1]??0))/g:0,$=e.intents.map(e=>({id:M(e),strength:"string"==typeof e?void 0:e.strength})).sort((e,t)=>"primary"===e.strength?-1:"primary"===t.strength?1:0)[0]?.id,w=e.audience?.primary??e.audienceFit?.find(e=>"strong"===e.fit)?.audience;return{l1:`A ${e.name.toLowerCase()} encodes ${l} and ${c}. ${C=d,C?C.charAt(0).toUpperCase()+C.slice(1):C}.`,l2:p.length>0?`${p.length} categories total ${f.format(g)}. ${y[0]} accounts for ${f.format(y[1])}${g>0?` (${h.format(y[1]/g)})`:""}${b?`, followed by ${b[0]} at ${f.format(b[1])}`:""}.`:`${t.length} data ${1===t.length?"item is":"items are"} represented.`,l3:2>p.length?y?y[0]+" is the only represented category.":"No quantitative pattern can be derived from the available data.":.5>v?`The total is distributed across ${p.length} categories without the first two forming a majority.`:`Most of the total is concentrated in ${y[0]} and ${b[0]}, which together account for ${h.format(v)}.`,l4:`The chart is intended for ${$??"explanation"}${w?` with a ${w} audience`:""}: ${e.designContract.whyCustom}`};var C}(e,r,o,a),l=n.levels??["l1","l2","l3","l4"],c={};for(const e of l)s[e]&&(c[e]=s[e]);const u=["l1","l2","l3","l4"].map(e=>c[e]).filter(e=>!!e).join(" "),d=n.includeCaveats?[...e.reception?.risks??[],...e.caveats??[],...(e.designContract.misuse??[]).map(e=>"Misuse: "+e)]:void 0;return{text:u,levels:c,...d?.length?{caveats:d}:{}}}(a,t,{levels:e,locale:n.locale,audience:n.audience,includeCaveats:n.includeCaveats}),s=xe(t);return{...i,text:s?`${s} ${i.text}`.trim():i.text,...s?{annotations:s}:{}}}const i=Ce(n.locale??"en"),s=ce(e),l=Array.isArray(t.data)?t.data:null,c=re(t),u=le.has(e)?function(e,t){const n=e.physics&&"object"==typeof e.physics?e.physics:null,r=e.settledProjection&&"object"==typeof e.settledProjection?e.settledProjection:null,o=[e.settledProjectionRows,e.projectionRows,r?.rows,n?.settledProjectionRows,n?.projectionRows,n?.settledProjection&&"object"==typeof n.settledProjection?n.settledProjection.rows:void 0].find(e=>Array.isArray(e));return Array.isArray(o)?o.map((e,n)=>{if(!e||"object"!=typeof e)return null;const r=e,o=ue(r.count??r.value??r.total??r.bodies??r.events);if(null==o)return null;const a=r.label??r.id??r.name??"container "+(n+1),i=ue(r.secondary??r.secondaryCount),s=ue(r.observed??r.observedCount);return{label:oe(a,t),count:o,...null!=i?{secondary:i}:{},..."string"==typeof r.secondaryLabel&&r.secondaryLabel?{secondaryLabel:r.secondaryLabel}:{},...null!=s?{observed:s}:{}}}).filter(e=>null!=e):null}(t,i):null,{measure:d,measureFallback:f,dimension:h,dimensionFallback:m}=ne(e,t),p="string"==typeof d&&d?d:f,g="string"==typeof h&&h?h:m,y={};if(le.has(e)&&function(e,t,n,r,o,a){const i=function(e){return"EventDropChart"===e?"time window":"GaltonBoardChart"===e?"bin":"CollisionSwarmChart"===e?"group lane":"PacketFlowChart"===e?"flow node":"CrucibleChart"===e?"result group":"container"}(e),s=function(e){return"EventDropChart"===e?"event":"GaltonBoardChart"===e?"sample":"CollisionSwarmChart"===e?"point":"PacketFlowChart"===e?"packet":"CrucibleChart"===e?"settled item":"body"}(e);if(o.has("l1")&&(r.l1=function(e,t){return"EventDropChart"===e?"An event-drop physics chart that collapses moving events into a settled projection by event-time window.":"GaltonBoardChart"===e?"A Galton board chart that collapses falling samples into a settled histogram projection.":"UnitPileChart"===e?"A physics pile chart that collapses moving bodies into a settled bar-style projection by container.":"CollisionSwarmChart"===e?"A collision swarm chart that separates overlapping points while preserving their quantitative axis position.":"PacketFlowChart"===e?"A physical flow chart that keeps authored routes visible while packet bodies show throughput and proximity events.":"CrucibleChart"===e?"A crucible physics chart that replays authored phases and events into declared products and outlets; the settled ledger, not collisions, determines the result.":`A ${t} whose accessible reading is the settled projection rather than individual trajectories.`}(e,t)),!o.has("l2")&&!o.has("l3"))return;if(!n||0===n.length)return void(o.has("l2")&&(r.l2="No settled projection is loaded yet."));const l=n.reduce((e,t)=>e+t.count,0),c=n.filter(e=>e.count>0).sort((e,t)=>t.count-e.count),u=c[0]??n.slice().sort((e,t)=>t.count-e.count)[0];if(!u)return;const d=n.reduce((e,t)=>e+(t.secondary??0),0),f=n.find(e=>e.secondaryLabel)?.secondaryLabel??"secondary";if(o.has("l2"))if(0===c.length)r.l2=`The settled projection contains ${a(l)} ${Ie(l,s)} across ${n.length} ${Ie(n.length,i)}; no ${Ie(2,i)} are non-empty yet.`;else{const e=d>0?` ${a(d)} ${Ie(d,s)} ${1===d?"is":"are"} marked ${f}.`:"";r.l2=`The settled projection contains ${a(l)} ${Ie(l,s)} across ${n.length} ${Ie(n.length,i)}; ${c.length} ${Ie(c.length,i)} ${1===c.length?"is":"are"} non-empty. The largest ${i} is ${u.label} with ${a(u.count)} ${Ie(u.count,s)}.${e}`}if(o.has("l3")&&l>0&&c.length>0){const e=c.find(e=>e!==u),t=function(e,t){if(0>=t)return"0%";const n=e/t*100;return(10>n?Math.round(10*n)/10:Math.round(n))+"%"}(u.count,l);r.l3=e?`The settled projection is most concentrated in ${u.label}, which holds ${a(u.count)} ${Ie(u.count,s)} (${t}); ${e.label} follows with ${a(e.count)} ${Ie(e.count,s)}.`:`The settled projection is concentrated in ${u.label}, which holds all ${a(u.count)} ${Ie(u.count,s)}.`}}(e,s,u,y,o,i),o.has("l1")&&!le.has(e))if(Y.has(e)||Z.has(e))y.l1=`A ${s} of ${p} by ${g}`+(c?`, split by ${c}.`:".");else if(ee.has(e))y.l1=`A ${s} showing ${p} across ${g} categories.`;else if(te.has(e))y.l1=`A ${s} of the distribution of ${p}`+(c?` by ${c}.`:".");else if(se.has(e)){const e=Array.isArray(t.nodes)?t.nodes.length:void 0,n=Array.isArray(t.edges)?t.edges.length:void 0,r=[null!=e?`${e} ${Ie(e,"node")}`:null,null!=n?`${n} ${Ie(n,"edge")}`:null].filter(Boolean);y.l1=`A ${s}${r.length?" with "+r.join(" and "):""}.`}else if("BigNumber"===e){const e="string"==typeof t.label?t.label:p;y.l1=`A single value${e?" for "+e:""}.`}else y.l1=`A ${s}.`;const b=Y.has(e)||Z.has(e)||ee.has(e)||te.has(e);let v=null;if((o.has("l2")||o.has("l3")||o.has("l4"))&&b&&l&&l.length>0&&(v=function(e,t,n,r){let o=0,a=0,i=1/0,s=-1/0,l=null,c=null,u=0,d=0,f=null,h=null,m=NaN,p=NaN;for(const n of e){const e=t(n);Number.isFinite(e)&&(0===o&&(m=e,f=n),p=e,h=n,i>e&&(i=e,l=n,u=o),e>s&&(s=e,c=n,d=o),o++,a+=e)}return 0===o?null:{count:o,min:i,max:s,mean:a/o,minLabel:oe(null!=l?n(l):null,r),maxLabel:oe(null!=c?n(c):null,r),first:m,last:p,firstLabel:oe(null!=f?n(f):null,r),lastLabel:oe(null!=h?n(h):null,r),minIndex:u,maxIndex:d}}(l,Q(d,f),X(h,m),i)),o.has("l2")&&b&&(l&&0!==l.length?v&&(y.l2=ee.has(e)?`${v.count} segments totaling ${i(function(e){return e.mean*e.count}(v))}. Largest is ${v.maxLabel} at ${i(v.max)}; smallest is ${v.minLabel} at ${i(v.min)}.`:`${p} ranges from ${i(v.min)} (${v.minLabel}) to ${i(v.max)} (${v.maxLabel}), with a mean of ${i(v.mean)} across ${v.count} points.`):y.l2="No data is loaded yet."),o.has("l3")&&v&&!c&&Y.has(e)?y.l3=function(e,t,n){const{first:r,last:o,min:a,max:i,maxLabel:s,minLabel:l,firstLabel:c,lastLabel:u,minIndex:d,maxIndex:f,count:h}=e,m=i-a,p=o-r;if(0===m)return`${je(t)} is constant at ${n(r)} across the series.`;if(.04>m/(Math.abs(e.mean)||1))return`${je(t)} ends roughly where it started (${n(r)} at ${c} to ${n(o)} at ${u}), ranging between ${n(a)} and ${n(i)}.`;const g=f>0&&h-1>f,y=d>0&&h-1>d,b=(i-Math.max(r,o))/m,v=(Math.min(r,o)-a)/m;return g&&b>.15?`Overall ${t} climbs to a peak of ${n(i)} (${s}), then falls to ${n(o)} (${u}).`:y&&v>.15?`Overall ${t} drops to a low of ${n(a)} (${l}), then recovers to ${n(o)} (${u}).`:.05>Math.abs(p)/m?`${je(t)} ends roughly where it started (${n(r)} at ${c} to ${n(o)} at ${u}), ranging between ${n(a)} and ${n(i)}.`:p>0?f===h-1?`Overall ${t} rises from ${n(r)} (${c}) to a peak of ${n(o)} (${u}).`:`Overall ${t} rises from ${n(r)} (${c}) to ${n(o)} (${u}), after peaking at ${n(i)} (${s}).`:d===h-1?`Overall ${t} falls from ${n(r)} (${c}) to a low of ${n(o)} (${u}).`:`Overall ${t} falls from ${n(r)} (${c}) to ${n(o)} (${u}), after dipping to ${n(a)} (${l}).`}(v,p,i):o.has("l3")&&v&&!c&&Z.has(e)&&(y.l3=`The highest ${g} is ${v.maxLabel} and the lowest is ${v.minLabel}.`),o.has("l4")){const r=we(t)?"alerting":ge(e,n.capability);r&&(y.l4=function(e,t,n,r,o,a,i,s){const l=pe[e],c=/^[aeiou]/i.test(l)?"an":"a";let u,d;switch(e){case"locating":u="This is a map",d="read values by location";break;case"presenting":u="This is a single-value display",d=`read ${"string"==typeof n.label&&n.label?n.label:o} as the headline number`;break;case"tracing":u=`This is ${c} ${l} chart`,d="follow the movement between states";break;case"nesting":u=`This is ${c} ${l} chart`,d="read it for nested structure and how children sum into their parents";break;case"relating":u=`This is ${c} ${l} chart`,d=`read it for whether ${a} and ${o} move together`;break;default:u=`This is ${c} ${l} chart`,d=function(e,t,n,r,o,a){if(!t)switch(e){case"alerting":return"watch for points that break from the rest";case"tracking":return"read it for the overall direction of "+n;case"comparing":return`compare ${n} across ${r}`;case"ranking":return"read it top to bottom by "+n;case"apportioning":return`read each ${r}'s share of the whole`;case"characterizing":return"read it for the spread and shape of "+n;default:return"read the highlighted features"}switch(e){case"alerting":return function(e,t,n){if(Z.has(n)||ee.has(n))return`${e.maxLabel} stands out at ${t(e.max)} — check it first`;const{first:r,last:o,min:a,max:i,minLabel:s,maxLabel:l,lastLabel:c,minIndex:u,maxIndex:d,count:f}=e,h=i-a;if(h>0){const e=d>0&&f-1>d,n=u>0&&f-1>u,m=(i-Math.max(r,o))/h,p=(Math.min(r,o)-a)/h;if(e&&m>.15)return`the peak of ${t(i)} at ${l} is the point to investigate`;if(n&&p>.15)return`the dip to ${t(a)} at ${s} is the point to investigate`;if(o>=i)return`the climb to ${t(o)} at ${c} warrants a closer look`;if(a>=o)return`the drop to ${t(o)} at ${c} warrants a closer look`}return`the extremes — ${l} (${t(i)}) and ${s} (${t(a)}) — are the points to check`}(t,o,a);case"tracking":return`read it for the trajectory of ${n}, which ${function(e){const t=e.max-e.min,n=e.last-e.first;return 0===t||.05>Math.abs(n)/t?"holds roughly steady":n>0?"rises":"falls"}(t)} from ${o(t.first)} (${t.firstLabel}) to ${o(t.last)} (${t.lastLabel})`;case"comparing":return`compare ${n} across ${r}; ${t.maxLabel} leads at ${o(t.max)}`;case"ranking":return`read it top to bottom by ${n}; ${t.maxLabel} ranks highest at ${o(t.max)}`;case"apportioning":{const e=t.mean*t.count,n=e>0?Math.round(t.max/e*100):null;return`read each ${r}'s share of the ${o(e)} total; ${t.maxLabel} is the largest at ${o(t.max)}${null!=n?` (${n}%)`:""}`}case"characterizing":return`read it for the spread of ${n}, from ${o(t.min)} to ${o(t.max)}`;default:return"read the highlighted features"}}(e,r,o,a,i,t)}return`${u}; ${d}.${function(e,t){if(!t)return"";const n=t.familiarity?.[e];return"number"!=typeof n||n>2?"":` This ${ce(e)} may be unfamiliar${t.name?` to ${t.name.toLowerCase()} readers`:""} — lean on this description.`}(t,s)}`}(r,e,t,c?null:v,p,g,i,n.audience))}const $=["l1","l2","l3","l4"].filter(e=>o.has(e)&&y[e]).map(e=>y[e]).join(" "),w=xe(t);return{text:w?`${w} ${$}`.trim():$,levels:y,...w?{annotations:w}:{}}}function je(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function Ie(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function Pe(e){return((e??"unknown")+"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function Oe(e,t,n={}){const r=n.locale??"en",o=Math.max(1,n.maxLeaves??200),a=Ce(r),i=B(e,t,n.recipe);if(i)return function(e,t,n={}){const r=T(t),o=E(t),a=Math.max(1,n.maxLeaves??200);if("function"==typeof e.navigation)return e.navigation({data:r,config:o,locale:n.locale??"en"});const i=(s=e.navigation)&&"object"==typeof s?e.navigation:void 0;var s;const l=(i?.groupByRole?V(e,i.groupByRole):void 0)??(i?.groupBy?.[0]?V(e,i.groupBy[0])??e.dataRoles.find(e=>e.field===i.groupBy?.[0]):void 0)??z(e,["nominal","ordinal"]),c=l?_(l,o,r):void 0,u=(i?.idRole?V(e,i.idRole):void 0)??z(e,["identifier"]),d=u?_(u,o,r):void 0,f={id:"root",role:"chart",label:i?.summaryTemplate?H(i.summaryTemplate,void 0,e,o,r,{count:r.length}):`${e.name}: ${r.length} ${1===r.length?"item":"items"} represented.`,level:1,children:[]};let h=0;const m=(t,n,a)=>{const s=d?t[d]:void 0,l=i?.itemLabelTemplate?H(i.itemLabelTemplate,t,e,o,r,{count:r.length}):function(e,t,n,r){const o=z(t,["nominal","ordinal"]),a=t.dataRoles.filter(e=>"quantitative"===e.semanticType),i=o?_(o,n,r):void 0,s=[];i&&null!=e[i]&&s.push(e[i]+"");for(const t of a){const o=_(t,n,r);o&&null!=e[o]&&s.push(`${t.role}: ${e[o]+""}`)}return s.length>0?s.join(", "):"Data item"}(t,e,o,r);return{id:"datum-"+Pe(s??n),role:"datum",label:l,level:a,datum:t}};if(c){const e=new Map;for(const t of r){const n=(t[c]??"Uncategorized")+"",r=e.get(n);r?r.push(t):e.set(n,[t])}f.children=[...e].map(([e,t],n)=>{const r=t.slice(0,Math.max(0,a-h));h+=r.length;const o=r.map((e,t)=>m(e,1e5*n+t,3));return t.length>r.length&&o.push({id:"more-"+Pe(e),role:"datum",label:`…and ${t.length-r.length} more items`,level:3}),{id:"group-"+Pe(e),role:"series",label:`${e}: ${t.length} ${1===t.length?"item":"items"}.`,level:2,children:o}})}else{const e=r.slice(0,a);f.children=e.map((e,t)=>m(e,t,2)),r.length>e.length&&f.children.push({id:"more",role:"datum",label:`…and ${r.length-e.length} more items`,level:2})}return f}(i,t,{maxLeaves:o,locale:r});const s={id:"root",role:"chart",label:ke(e,t,{locale:r}).text||"Chart.",level:1,children:[]},l=function(e,t){const n=Array.isArray(e.annotations)?e.annotations:null;if(!n)return null;const r=ae(n.filter(e=>!!e&&"object"==typeof e));if(0===r.length)return null;let o=0;const a=r.slice(0,t).map(e=>{const t=e.lifecycle?.status,n=t&&"accepted"!==t?` (${t})`:"";return{id:"annotation-"+o++,role:"annotation",level:3,label:`${r=Se(e),r?r.charAt(0).toUpperCase()+r.slice(1):r}${n}.`,datum:e};var r});r.length>t&&a.push({id:"annotation-"+o++,role:"annotation",level:3,label:`…and ${r.length-t} more annotations.`});const i=r.length;return{id:"annotations",role:"annotation",level:2,label:`Annotations: ${1===i?"one marked feature":i+" marked features"}.`,children:a}}(t,o),c=Array.isArray(t.data)?t.data:null,u=Y.has(e)||Z.has(e)||ee.has(e)||te.has(e);if(!c||0===c.length||!u)return l&&(s.children=[l]),s;const{measure:d,measureFallback:f,dimension:h,dimensionFallback:m}=ne(e,t),p=Q(d,f),g=X(h,m),y="string"==typeof d&&d?d:f,b="string"==typeof h&&h?h:m,v=re(t);let $=0;const w=e=>`${e}-${$++}`,C=(e,t)=>{const n=e.slice(0,o).map(e=>((e,t)=>{const n=p(e),r=oe(g(e),a);return{id:w("datum"),role:"datum",level:t,label:`${r}: ${Number.isFinite(n)?a(n):"—"}`,value:Number.isFinite(n)?n:void 0,datum:e}})(e,t));return e.length>o&&n.push({id:w("more"),role:"datum",level:t,label:`…and ${e.length-o} more points`}),n},A=[];if(Y.has(e)||Z.has(e)){let t=1/0,n=-1/0,r=1/0,o=-1/0;const i=[];let s=!0;for(const e of c){const a=p(e);Number.isFinite(a)&&(t>a&&(t=a),a>n&&(n=a));const l=g(e);i.push(l),"number"==typeof l&&Number.isFinite(l)?(r>l&&(r=l),l>o&&(o=l)):s=!1}const l=new Set,u=[];for(const e of i){const t=e+"";l.has(t)||(l.add(t),u.push(e))}const d=s?`${a(r)} to ${a(o)}`:`${oe(u[0],a)} to ${oe(u[u.length-1],a)} (${Z.has(e)?u.length+" categories":c.length+" points"})`;A.push({id:w("axis"),role:"axis",level:2,label:`${Z.has(e)?"Category axis":"X axis"}: ${b}, ${d}.`}),t>n||A.push({id:w("axis"),role:"axis",level:2,label:`Value axis: ${y}, ${a(t)} to ${a(n)}.`})}if(v){const n=X(v,v),o=new Map;for(const e of c){const t=(n(e)??"—")+"",r=o.get(t);r?r.push(e):o.set(t,[e])}const a=[];for(const[n,i]of o){const o=ke(e,{...t,data:i},{levels:["l2","l3"],locale:r}).text;a.push({id:w("series"),role:"series",level:2,label:`Series ${n}: ${o}`,children:C(i,3)})}s.children=[...A,...a]}else s.children=[...A,...C(c,2)];return l&&s.children.push(l),s}var Re=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","PhysicsCustomChart"]);function Fe(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function De(e){return Fe(e)?e:void 0}function Ne(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function Le(e){const t=Ne(e);return null==t?void 0:Math.max(0,Math.floor(t))}function Me(...e){return e.map(De).find(Boolean)}function Ee(...e){return e.find(Array.isArray)}function Te(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t}function Be(e,t,n){return e["string"==typeof t&&t?t:n]}function _e(e){return e instanceof Date?e.toISOString():"number"==typeof e?Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+"":(e??"—")+""}function Ve(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function ze(e){return Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+""}function He(e,t,n){const r=e?.filter(e=>!0===De(e)?.sensor).length,o=De(t?.observation),a=De(o?.sensors),i=Ee(n?.activeSensors);return Math.max(r??0,a?Object.keys(a).length:0,i?.length??0)||void 0}function qe(e,t,n={}){const{capability:r,audience:o,locale:a}=n,i=n.levels??["l1","l2","l3"],s=!1!==n.includeStructure,l=ge(e,r),c=ke(e,t,{levels:l?[...i,"l4"]:i,locale:a,capability:r,audience:o}),{l4:u,...d}=c.levels,f=["l1","l2","l3"].map(e=>c.levels[e]).filter(Boolean).join(" "),h={levels:d,text:c.annotations?`${c.annotations} ${f}`.trim():f,...c.annotations?{annotations:c.annotations}:{}};let m;if(l&&u){const e=(p=r)?"fits"in p||"buildProps"in p?{family:p.family}:{family:p.family,intentScores:p.intentScores}:{};m={act:l,sentence:u,family:e.family,intentScores:e.intentScores}}var p;const g=s?Oe(e,t,{maxLeaves:n.maxLeaves,locale:a}):void 0,y=function(e,t,n){if(!1===n)return;const r=Fe(n)?n:void 0,o=De(t.physics),a=Me(r?.snapshot,o?.snapshot,t.physicsSnapshot,function(e){const t=De(e);return!!t&&(Fe(t.world)||"simulationState"in t||"liveBodyOrder"in t)}(t.snapshot)?t.snapshot:void 0),i=Me(r?.evidence,o?.evidence,t.physicsEvidence,t.settledEvidence),s=Me(r?.config,o?.config,a?.config,t.config),l=Me(De(a?.world),De(o?.world)),c=Me(De(s?.kernel),De(l?.options)),u=Ee(l?.bodies),d=Ee(l?.colliders,s?.colliders),f=Ee(a?.queue,o?.queue),h=Ee(a?.liveBodyOrder),m=Ee(l?.springs),p=Ee(a?.activeSensorPairs),g=function(e){if(!e||0===e.length)return;const t=e.map((e,t)=>{const n=De(e);if(!n)return;const r=Ne(n.count??n.value??n.total??n.bodies??n.events);if(null==r)return;const o=(n.label??n.id??n.name??"container "+(t+1))+"",a=null==n.id?void 0:n.id+"",i=Ne(n.secondary??n.secondaryCount),s=Ne(n.observed??n.observedCount);return Te({id:a,label:o,count:r,secondary:i,secondaryLabel:"string"==typeof n.secondaryLabel?n.secondaryLabel:void 0,observed:s})}).filter(e=>null!=e);if(0===t.length)return;const n=t.reduce((e,t)=>e+t.count,0),r=t.filter(e=>e.count>0).length,o=t.slice().sort((e,t)=>t.count-e.count)[0];return{rows:t,totalCount:n,populatedCount:r,...o?{leader:o}:{}}}(function(e,t,n,r){const o=De(e.settledProjection),a=De(t?.settledProjection);return Ee(n?.projectionRows,n?.aggregates,e.settledProjectionRows,e.projectionRows,o?.rows,t?.settledProjectionRows,t?.projectionRows,a?.rows,r?.binCounts)}(t,o,r,i)),y=function(e,t){const n=e?.map((e,t)=>{const n=De(e);if(!n)return;const r=Ne(n.count)??0,o=Ne(n.total),a={label:(n.label??n.id??"sediment "+(t+1))+"",count:r};return null!=n.id&&(a.id=n.id+""),null!=o&&(a.total=o),a}).filter(e=>null!=e),r=Le(t?.bins)??n?.length??0,o=Ne(t?.count)??n?.reduce((e,t)=>e+t.count,0)??0,a=Ne(t?.total)??n?.reduce((e,t)=>e+(t.total??0),0),i=n?.slice().sort((e,t)=>t.count-e.count)[0];if(0!==r||0!==o||a)return{bins:r,count:o,...null!=a&&a>0?{total:a}:{},...i?{leader:i}:{}}}(Ee(r?.sediment,o?.sediment,a?.sediment),Me(r?.sedimentTotals,o?.sedimentTotals)),b=h?.length??u?.length??Le(i?.bodyCount),v=function(e){if(e)return e.filter(e=>!0===De(e)?.sleeping).length}(u)??Le(i?.sleepingCount),$=f?.length,w="string"==typeof a?.simulationState?a.simulationState:void 0,C="boolean"==typeof i?.settled?i.settled:w?"settled"===w:null!=b||null!=v||null!=$?null!=b&&v===b&&0===($??0):void 0,A=De(c?.gravity),S=Ne(A?.x),x=Ne(A?.y),k=Te({state:w,settled:C,elapsedSeconds:Ne(a?.elapsedSeconds),paused:"boolean"==typeof a?.paused?a.paused:void 0,visible:"boolean"==typeof a?.visible?a.visible:void 0,seed:Ne(c?.seed),gravity:null!=S&&null!=x?{x:S,y:x}:void 0,fixedDt:Ne(s?.fixedDt??c?.fixedDt),timeScale:Ne(s?.timeScale),maxSubsteps:Le(s?.maxSubsteps),liveBodies:b,sleepingBodies:v,queued:$,bodyLimit:Ne(s?.bodyLimit),eviction:"string"==typeof s?.eviction?s.eviction:void 0}),j=Te({colliders:d?.length,sensors:He(d,s,l),springs:m?.length,activeSensorPairs:p?.length}),I=Object.keys(j).length>0,P=Re.has(e);if(!(Object.keys(k).length>0||I||g||y)||!P&&null==n)return;const O={simulation:k,...I?{geometry:j}:{},...g?{aggregates:g}:{},...y?{sediment:y}:{}},R=function(e){const t=[],n=e.simulation,r=[n.state??(n.settled?"settled":void 0),null!=n.liveBodies?`${n.liveBodies} live ${Ve(n.liveBodies,"body")}`:void 0,null!=n.sleepingBodies?n.sleepingBodies+" sleeping":void 0,null!=n.queued?n.queued+" queued":void 0,null!=n.seed?"seed "+ze(n.seed):void 0,n.gravity?`gravity (${ze(n.gravity.x)}, ${ze(n.gravity.y)})`:void 0,null!=n.fixedDt?`fixed step ${ze(n.fixedDt)}s`:void 0,null!=n.timeScale?ze(n.timeScale)+"x time":void 0].filter(Boolean);r.length>0&&t.push(`Physics simulation: ${r.join("; ")}.`);const o=e.geometry;if(o){const e=[null!=o.colliders?`${o.colliders} ${Ve(o.colliders,"collider")}`:void 0,null!=o.sensors?`${o.sensors} ${Ve(o.sensors,"sensor")}`:void 0,null!=o.springs?`${o.springs} ${Ve(o.springs,"spring")}`:void 0,null!=o.activeSensorPairs?`${o.activeSensorPairs} active sensor ${Ve(o.activeSensorPairs,"pair")}`:void 0].filter(Boolean);e.length>0&&t.push(`Physics geometry: ${e.join("; ")}.`)}const a=e.aggregates;if(a){const e=a.leader,n=e?` Largest is ${e.label} with ${ze(e.count)}.`:"";t.push(`Physics aggregates: ${ze(a.totalCount)} settled ${Ve(a.totalCount,"body")} across ${a.rows.length} ${Ve(a.rows.length,"container")}; ${a.populatedCount} populated.${n}`)}const i=e.sediment;if(i){const e=null!=i.total?", value total "+ze(i.total):"",n=i.leader?`; largest sediment bin is ${i.leader.label} with ${ze(i.leader.count)}`:"";t.push(`Physics sediment: ${i.count} retained ${Ve(i.count,"body")} in ${i.bins} ${Ve(i.bins,"bin")}${e}${n}.`)}return t.join(" ")}(O);return{...O,text:R}}(e,t,n.physics),b=function(e,t,n){const r=[];if("GaugeChart"===e){"number"==typeof t.value&&Number.isFinite(t.value)&&r.push(`Current value is ${_e(t.value)}.`);const e="number"==typeof t.min&&Number.isFinite(t.min)?t.min:0,n="number"==typeof t.max&&Number.isFinite(t.max)?t.max:100;r.push(`The gauge scale runs from ${_e(e)} to ${_e(n)}.`)}if("SankeyDiagram"===e||"ProcessSankey"===e){const o=Array.isArray(t.edges)?t.edges:[];if("ProcessSankey"===e&&Array.isArray(t.domain)&&2===t.domain.length&&r.push(`The ProcessSankey time domain runs from ${_e(t.domain[0])} to ${_e(t.domain[1])}.`),o.length>0){r.push(`${o.length} source flow${1===o.length?"":"s"} are supplied.`);for(const a of o.slice(0,n)){const n=Be(a,t.sourceAccessor,"source"),o=Be(a,t.targetAccessor,"target"),i=Be(a,t.valueAccessor,"value");r.push("ProcessSankey"!==e||null==a.startTime&&null==a.endTime?`${_e(n)} to ${_e(o)} has value ${_e(i)}.`:`${_e(n)} to ${_e(o)} has value ${_e(i)} over ${_e(a.startTime)}–${_e(a.endTime)}.`)}}}if("Treemap"===e||"CirclePack"===e||"TreeDiagram"===e||"OrbitDiagram"===e){const e=De(t.data),o="string"==typeof t.childrenAccessor&&t.childrenAccessor?t.childrenAccessor:"children",a="string"==typeof t.valueAccessor&&t.valueAccessor?t.valueAccessor:"value",i="string"==typeof t.nodeIdAccessor&&t.nodeIdAccessor?t.nodeIdAccessor:"string"==typeof t.nodeIDAccessor&&t.nodeIDAccessor?t.nodeIDAccessor:"name",s=[],l=e=>{const t=Array.isArray(e[o])?e[o]:[];if(0!==t.length)for(const e of t){const t=De(e);t&&l(t)}else s.push(e)};if(e&&l(e),s.length>0){r.push(s.length+" hierarchy leaves are supplied.");for(const e of s.slice(0,n))r.push(`${_e(e[i])} has value ${_e(e[a])}.`)}}if(Re.has(e)&&Array.isArray(t.data)){const n=t.data;r.push(`${n.length} observed source row${1===n.length?"":"s"} are supplied.`);const o="CollisionSwarmChart"===e?t.xAccessor:t.valueAccessor,a="CollisionSwarmChart"===e?"x":"value",i=n.map(e=>Ne(Be(e,o,a))).filter(e=>null!=e);i.length>0&&r.push(`Observed ${"string"==typeof o?o:a} ranges from ${_e(Math.min(...i))} to ${_e(Math.max(...i))}.`)}if(0!==r.length)return{source:"chart-props",statements:r,text:"Exact chart-prop facts: "+r.join(" ")}}(e,t,Math.max(1,n.maxLeaves??200)),v=[h.text,m?.sentence,y?.text,b?.text].filter(Boolean).join(" ");return{component:e,description:h,intent:m,structure:g,physics:y,facts:b,text:v}}var Ge=["data","nodes","edges","points","areas","lines","flows"],Ue=[["xAccessor","x"],["yAccessor","y"],["categoryAccessor","category"],["valueAccessor","value"],["colorBy","color"],["sizeAccessor","size"],["lineBy","series"],["groupAccessor","group"],["oAccessor","ordinal"],["rAccessor","radial"],["sourceAccessor","source"],["targetAccessor","target"],["nodeIDAccessor","id"]],Ke=1;function Je(e,t){const n=e.trim();if(!n)throw Error(t+" must be a non-empty string.");return encodeURIComponent(n)}function We(e,...t){return`${e}/${t.map(e=>Je(e,"VACP ref segment")).join("/")}`}function Qe(e){const t=e.now?.()??new Date,n=t instanceof Date?t:new Date(t);if(!Number.isFinite(n.getTime()))throw Error("VACP bridge clock returned an invalid date.");return n.toISOString()}function Xe(e){try{const{createdAt:t,...n}=function(e,t,n){const r=N(e)??L(t.recipe)??L(t.recipeId);if(r)return function(e,t,n){const r=function(e,t,n){const r={};for(const[o,a]of Object.entries(e))if(null!=a&&!G.has(o)&&"recipeId"!==o&&(t||!J(o,a)))if("function"==typeof a||a?.$$typeof){if(n)throw Error(`Portable recipe prop "${o}" is not JSON-safe.`)}else if(F(a))r[o]=W(a);else if(n)throw Error(`Portable recipe prop "${o}" is not JSON-safe.`);return r}(t,!1!==n?.includeData,"portable"===e.portability),o=e.intents.map(M).filter(e=>!!e),a={name:e.name,intents:o,...e.audience?.primary?{audience:[e.audience.primary]}:{},frameFamily:e.frameFamily};if("portable"===e.portability){if(!F(r))throw Error(`Portable recipe "${e.id}" contains non-JSON-safe props or layoutConfig.`);return{component:"ChartRecipe",recipeId:e.id,portable:!0,props:r,manifest:a,version:q,createdAt:(new Date).toISOString(),...n?.selections?{selections:n.selections}:{}}}return{component:"ChartRecipe",recipeId:e.id,portable:!1,reason:"Recipe contains or may depend on non-serializable local layout callbacks.",warnings:["This config is inspectable but cannot be rendered remotely by CLI or MCP."],props:r,manifest:a,version:q,createdAt:(new Date).toISOString(),...n?.selections?{selections:n.selections}:{}}}(r,t,n);if(!function(e){return R.has(e)}(e))throw Error(`Unknown component "${e}". Known components: ${O.join(", ")}`);const o=!1!==n?.includeData,a={};for(const[e,n]of Object.entries(t))if(null!=n&&!G.has(e)&&(o||!J(e,n))&&"function"!=typeof n&&!n?.$$typeof)try{a[e]=W(K(n))}catch{}return{component:e,props:a,version:q,createdAt:(new Date).toISOString(),...n?.selections?{selections:n.selections}:{}}}(e.component,e.props,{includeData:!1});return l(n)}catch(t){const n=Object.create(null);for(const[t,r]of Object.entries(e.props)){if(Ge.includes(t)||"function"==typeof r)continue;const e=s(r);void 0!==e&&(n[t]=e)}return{component:e.component,props:n,version:"unregistered",warning:t instanceof Error?t.message:"Chart config could not be serialized by toConfig."}}}function Ye(e){return qe(e.component,e.props,{...e.grounding,audience:e.audience,includeStructure:!0,maxLeaves:Ke})}function Ze(e,t){const n=[];for(const r of Ge){const o=e.props[r];Array.isArray(o)&&n.push({ref:t.data(e.chartId,r),chartId:e.chartId,collection:r,rows:o})}return n}function et(e,t){t(e);for(const n of e.children??[])et(n,t)}function tt(e,t){if(!t)return;let n;return et(e,e=>{n||e.id!==t||(n=e)}),n}function nt(e){return null==e||"string"==typeof e||"number"==typeof e&&Number.isFinite(e)||"boolean"==typeof e||e instanceof Date&&Number.isFinite(e.getTime())}function rt(e,t){if("datum"!==e.role||!e.datum)return;const n=Object.create(null);for(const r of t){if(!Object.prototype.hasOwnProperty.call(e.datum,r)||!nt(e.datum[r]))return;n[r]=e.datum[r]instanceof Date?e.datum[r].toISOString():e.datum[r]}return n}function ot(e,t){const n=Array.from(new Set(e.matchFields.map(e=>e.trim()).filter(Boolean))),r=new Map;if(!n.length)return{valid:!1,diagnostic:"Navigation actions require at least one durable match field.",byKey:r,matchFields:n,targetRef:()=>We(t,"target","invalid")};let o,a=0,i=0,s=!1;return et(e.tree,e=>{if("datum"!==e.role)return;a++;const t=rt(e,n);if(!t)return void i++;const o=d(t);r.has(o)?s=!0:r.set(o,e)}),a?i?o=i+" navigation leaves lack durable primitive match-field values.":s&&(o="Navigation match fields do not uniquely identify every datum leaf."):o="Navigation tree has no datum leaves.",{valid:!o,...o?{diagnostic:o}:{},byKey:r,matchFields:n,targetRef:e=>We(t,"target",d(e))}}function at(e,t){const{chart:n,ref:r,configRef:o,grounding:a}=e,s=[{ref:r,kind:"Visualization",layer:"VisualizationLayer",title:n.title??(n.props.title??n.component)+"",description:n.description??a.text,data:l({component:n.component,grounding:{description:a.description,intent:a.intent,physics:a.physics,text:a.text},audience:n.audience})},{ref:o,kind:"Param",layer:"ConfigLayer",title:n.component+" configuration",description:"Serializable Semiotic chart configuration with raw data collections omitted.",data:e.config}],c=[{from:e.ref,to:o,kind:"contains"}],u=(a.structure?.children??[]).filter(e=>"axis"===e.role).map(e=>e.label);let d=0;for(const[e,t]of Ue){const o=n.props[e];if("string"!=typeof o||!o.trim())continue;const a=We(r,"encoding",t);if(s.push({ref:a,kind:"EncodingChannel",layer:"VisualizationLayer",title:`${t} → ${o}`,data:{channel:t,field:o,accessorProp:e}}),c.push({from:r,to:a,kind:"contains"}),"x"===t||"y"===t||"category"===t||"value"===t||"ordinal"===t||"radial"===t){const e=We(r,"axis",t);s.push({ref:e,kind:"Axis",layer:"VisualizationLayer",title:u[d++]??`${t} axis: ${o}`,data:{channel:t,field:o}}),c.push({from:r,to:e,kind:"contains"}),c.push({from:e,to:a,kind:"derivedFrom"})}}for(const o of e.dataHandles)s.push({ref:o.ref,kind:"DataHandle",layer:"DataLayer",title:`${n.chartId}.${o.collection}`,description:"Bounded details-on-demand handle. Use vacp.data_schema before requesting an opt-in sample.",data:{collection:o.collection,rowCount:o.rows.length,schemaAction:A,...t.dataAccess?.sample?{inspectAction:w}:{}}}),c.push({from:r,to:o.ref,kind:"contains"});if(e.navigation){const{navigation:t}=e;s.push({ref:t.ref,kind:"Selection",layer:"InteractionFeedbackLayer",title:(n.title??n.component)+" structured navigation",description:t.index.diagnostic??"Active accessible-navigation target identified by durable datum fields.",data:{matchFields:t.index.matchFields,targetCount:t.index.byKey.size,status:t.index.valid?t.binding.onActiveChange?"actionable":"read-only":"ambiguous"}}),c.push({from:r,to:t.ref,kind:"contains"})}if(t.getObservations){const e=We(r,"interaction","latest-observation");s.push({ref:e,kind:"InteractionTarget",layer:"InteractionFeedbackLayer",title:(n.title??n.component)+" latest observation",description:"Latest semantic hover, focus, selection, brush, activation, or control observation."}),c.push({from:r,to:e,kind:"contains"})}const f=Array.isArray(n.props.annotations)?n.props.annotations:[],h=new Set;for(const e of f){if(!i(e))continue;const t=i(e.provenance)?e.provenance:void 0,o=e.id??e.stableId??t?.stableId,a=null==o||""===o?void 0:o+"";if(!a)continue;const u=i(e.note)?e.note:void 0,d=i(e.noteData)?e.noteData:void 0,f=We(r,"annotation",a);if(h.has(f))throw Error(`Duplicate stable annotation id "${a.trim()}" in VACP chart "${n.chartId}".`);h.add(f),s.push({ref:f,kind:"InteractionTarget",layer:"VisualizationLayer",title:(e.label??u?.label??d?.label??"Annotation "+a)+"",description:"string"==typeof e.note?e.note:"string"==typeof e.description?e.description:void 0,data:l({id:a,provenance:t,lifecycle:e.lifecycle})}),c.push({from:r,to:f,kind:"contains"})}return{nodes:s,edges:c}}function it(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if(r.chartId===t)return r}}function st(e,t){const n=function(e,t){const n=function(e){const t="function"==typeof e?e():e,n=new Set;for(const e of t){const t=e.chartId.trim();if(!t)throw Error("Every VACP chart requires a non-empty chartId.");if(n.has(t))throw Error(`Duplicate VACP chartId "${t}".`);n.add(t)}return t}(e.charts),r=n.map(e=>{const n=t.visualization(e.chartId),r=e.navigation?{ref:t.navigation(e.chartId),chartRef:n,chartId:e.chartId,binding:e.navigation,index:ot(e.navigation,t.navigation(e.chartId))}:void 0;return{chart:e,ref:n,configRef:t.config(e.chartId),grounding:Ye(e),config:Xe(e),dataHandles:Ze(e,t),...r?{navigation:r}:{}}}),o=function(e,t){const n=new Map;for(const t of e)for(const e of t.chart.selections??[]){const r=e.name.trim();if(!r)throw Error("VACP selection names must be non-empty.");const o=n.get(r)??{fields:new Set,modes:new Set,chartRefs:new Set};for(const t of e.fields.map(e=>e.trim()))t&&o.fields.add(t);if("interval"!==e.mode&&o.modes.add("point"),"point"!==e.mode&&o.modes.add("interval"),e.clientId){if(o.clientId&&o.clientId!==e.clientId)throw Error(`Selection "${r}" declares conflicting VACP clientIds.`);o.clientId=e.clientId}o.chartRefs.add(t.ref),n.set(r,o)}return Array.from(n).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>{if(0===n.fields.size)throw Error(`Selection "${e}" requires at least one allowlisted field.`);return{ref:t.selection(e),name:e,fields:Array.from(n.fields).sort(),modes:n.modes,clientId:n.clientId??"__semiotic-vacp__:"+e,chartRefs:Array.from(n.chartRefs)}})}(r,t),a=r.flatMap(e=>e.dataHandles),i=[{ref:t.app,kind:"App",layer:"ViewLayer",title:e.title??e.appId,description:"Semiotic application state exposed through the experimental VACP 0.1.0 bridge.",data:{provider:"semiotic",protocol:C}},{ref:t.view,kind:"View",layer:"ViewLayer",title:e.title??e.viewId??"Semiotic charts"}],s=[{from:t.app,to:t.view,kind:"contains"}];for(const n of r){const r=at(n,e);i.push(...r.nodes),s.push(...r.edges),s.push({from:t.view,to:n.ref,kind:"contains"})}for(const e of o){i.push({ref:e.ref,kind:"Selection",layer:"InteractionFeedbackLayer",title:"Selection: "+e.name,description:"Named LinkedCharts selection. Agent mutations are restricted to declared fields and modes.",data:{name:e.name,fields:e.fields,modes:Array.from(e.modes).sort()}}),s.push({from:t.view,to:e.ref,kind:"contains"});for(const t of e.chartRefs)s.push({from:e.ref,to:t,kind:"controls"})}return{charts:r,selections:o,dataHandles:a,nodes:i,edges:s}}(e,t);return{...n,actions:P(n,e,t)}}function lt(e){const t=e.viewId?.trim()||"main",n=function(e,t){const n="vacp://"+Je(e,"appId"),r=We(n,"view",t),o=e=>We(r,"visualization",e);return{app:n,view:r,visualization:o,config:e=>We(o(e),"config"),data:(e,t="data")=>We(o(e),"data",t),selection:e=>We(r,"selection",e),navigation:e=>We(o(e),"navigation"),observation:e=>We(o(e),"interaction","latest-observation")}}(e.appId,t),r="number"==typeof e.stateCacheSize&&Number.isFinite(e.stateCacheSize)?Math.max(1,Math.floor(e.stateCacheSize)):64,o=new Map;return{version:C,refs:n,getCapabilities:t=>{const r=st(e,n),o={version:C,createdAt:Qe(e),graph:{version:C,nodes:r.nodes,edges:r.edges,actions:r.actions.map(e=>e.descriptor)}};return t?function(e,t){const n=function(e){return{refs:f(e.refs),prefixes:f(e.prefixes),kinds:e.kinds?.length?new Set(e.kinds):void 0,layers:e.layers?.length?new Set(e.layers):void 0,includeActions:!1!==e.includeActions,includeEdges:!1!==e.includeEdges,includeNodeData:!1!==e.includeNodeData}}(t),r=e.graph.nodes.filter(e=>function(e,t){return!((t.refs?.length||t.prefixes?.length)&&!t.refs?.includes(e.ref)&&!t.prefixes?.some(t=>e.ref===t||e.ref.startsWith(t+"/")))&&(!t.kinds||t.kinds.has(e.kind))&&(!t.layers||t.layers.has(e.layer))}(e,n)).map(e=>{if(n.includeNodeData)return e;const{data:t,...r}=e;return r}),o=new Set(r.map(e=>e.ref)),a=n.includeActions?e.graph.actions.filter(e=>{if(!e.targetRef)return!0;if(o.has(e.targetRef))return!0;for(const t of o)if(t.startsWith(e.targetRef+"/"))return!0;return!1}):[];return{version:e.version,createdAt:e.createdAt,graph:{version:e.graph.version,nodes:r,edges:n.includeEdges?e.graph.edges.filter(e=>o.has(e.from)&&o.has(e.to)):[],actions:a}}}(o,t):o},getState:async function(t){const a=function(e,t,n){const r={},o={},a=t.getSelections?.()??{},i=t.getObservations?.()??[];for(const a of e.charts){r[a.ref]=l({component:a.chart.component,description:a.grounding.description,intent:a.grounding.intent,physics:a.grounding.physics,audience:a.chart.audience}),r[a.configRef]=a.config,o[a.ref]={component:a.chart.component,dataHandles:a.dataHandles.length};for(const e of a.dataHandles)r[e.ref]={kind:"DataHandle",collection:e.collection,rowCount:e.rows.length},o[e.ref]={rowCount:e.rows.length};if(a.navigation){const e=tt(a.navigation.binding.tree,a.navigation.binding.activeId),t=e?rt(e,a.navigation.index.matchFields):void 0;r[a.navigation.ref]=l({kind:"Selection",status:a.navigation.index.valid?"ready":"ambiguous",activeRole:e?.role,activeLabel:e?.label,activeMatch:t,activeTargetRef:t?a.navigation.index.targetRef(t):void 0,diagnostic:a.navigation.index.diagnostic}),o[a.navigation.ref]={targetCount:a.navigation.index.byKey.size}}if(t.getObservations){const e=it(i,a.chart.chartId);r[n.observation(a.chart.chartId)]=e?l(e):null,e&&(o[n.observation(a.chart.chartId)]={type:e.type,timestamp:e.timestamp})}}for(const t of e.selections){const e=a[t.name];r[t.ref]=(e?l(e):void 0)??{name:t.name,resolution:"union",clauses:[]},o[t.ref]={active:!!e?.clauses.length,clauseCount:e?.clauses.length??0,fields:t.fields}}return{version:C,createdAt:Qe(t),state:r,...Object.keys(o).length?{summary:o}:{}}}(st(e,n),e,n);if(!t)return a;const{snapshot:i,refs:s}=m(a,t),c="st_"+d({state:(u=i).state,...u.summary?{summary:u.summary}:{}});var u;const f=t.since?o.get(t.since):void 0;let h;if("full"!==t.mode&&t.since&&f){const e=m(f,t).snapshot;h={version:C,createdAt:i.createdAt,mode:"delta",token:c,baseToken:t.since,...s?{scope:{refs:s}}:{},delta:p(e,i)}}else h={version:C,createdAt:i.createdAt,mode:"full",token:c,...s?{scope:{refs:s}}:{},snapshot:i};return((e,t)=>{for(o.has(e)&&o.delete(e),o.set(e,t);o.size>r;){const e=o.keys().next().value;if("string"!=typeof e)break;o.delete(e)}})(c,a),h},execute:async t=>{const r=t&&"string"==typeof t.callId?t.callId:"";try{if(!t||"string"!=typeof t.name||!t.name.trim())throw Error("VACP action call requires a non-empty name.");if(!r)throw Error("VACP action call requires a callId.");const o=st(e,n),a=o.actions.find(e=>e.descriptor.name===t.name);if(!a)return{callId:r,ok:!1,error:{message:`Unknown or currently unavailable VACP action "${t.name}".`,details:{available:o.actions.map(e=>e.descriptor.name)}}};const i=s(await a.execute(t.params));return{callId:r,ok:!0,...void 0!==i?{result:i}:{}}}catch(e){return{callId:r,ok:!1,error:{message:e instanceof Error?e.message:"VACP action failed."}}}}}}function ct(e,t={}){const n=t.globalKey?.trim()||"__vacp",r=t.target??("undefined"!=typeof window?window:void 0);if(!r)return{installed:!1,globalKey:n,bridge:e,reason:`Refused to install "${n}" without a browser window or an explicit target.`,cleanup:()=>!1};if("__proto__"===n||"prototype"===n||"constructor"===n)return{installed:!1,globalKey:n,bridge:e,reason:`Refused unsafe global key "${n}".`,cleanup:()=>!1};const o=r[n];if(void 0!==o&&o!==e)return{installed:!1,globalKey:n,bridge:e,reason:`Refused to replace existing global "${n}".`,cleanup:()=>!1};try{r[n]=e}catch(t){return{installed:!1,globalKey:n,bridge:e,reason:t instanceof Error?`Could not install "${n}": ${t.message}`:`Could not install "${n}".`,cleanup:()=>!1}}return{installed:!0,globalKey:n,bridge:e,cleanup:()=>{if(r[n]!==e)return!1;try{return delete r[n]}catch{return!1}}}}
1
+ var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,a={};function i(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function s(e,t={}){const n="number"==typeof t.maxDepth&&Number.isFinite(t.maxDepth)?Math.max(1,Math.floor(t.maxDepth)):10,r="number"==typeof t.maxArrayLength&&Number.isFinite(t.maxArrayLength)?Math.max(1,Math.floor(t.maxArrayLength)):1e3,o=new WeakSet,a=(e,t)=>{if(null==e||"string"==typeof e||"boolean"==typeof e)return e;if("number"==typeof e)return Number.isFinite(e)?e:e+"";if("bigint"==typeof e)return""+e;if("function"==typeof e||"symbol"==typeof e||void 0===e)return;if(e instanceof Date)return e.toISOString();if(t>=n)return"[depth limit]";if("object"!=typeof e)return e+"";if("$$typeof"in e)return;if(o.has(e))return"[circular]";if(o.add(e),Array.isArray(e)){const n=e.slice(0,r).map(e=>a(e,t+1)).filter(e=>void 0!==e);return o.delete(e),n}if(e instanceof Set){const n=Array.from(e).slice(0,r).map(e=>a(e,t+1)).filter(e=>void 0!==e);return o.delete(e),n}if(e instanceof Map){const n=Object.create(null);let i=0;for(const[o,s]of e){if(i++>=r)break;const e=a(s,t+1);void 0!==e&&(n[o+""]=e)}return o.delete(e),n}const i=Object.create(null);for(const n of Object.keys(e).sort()){const r=a(e[n],t+1);void 0!==r&&(i[n]=r)}return o.delete(e),i};return a(e,0)}function l(e){const t=s(e);return i(t)?t:{}}function c(e){if(Array.isArray(e))return e.map(c);if(!i(e))return e;const t=Object.create(null);for(const n of Object.keys(e).sort())t[n]=c(e[n]);return t}function u(e){return JSON.stringify(c(s(e)))}function d(e){return function(e){let t=BigInt("14695981039346656037");const n=BigInt("1099511628211"),r=BigInt("0xffffffffffffffff");for(let o=0;e.length>o;o++)t^=BigInt(e.charCodeAt(o)),t=t*n&r;return t.toString(16).padStart(16,"0")}(u(e))}function f(e){if(!e?.length)return;const t=Array.from(new Set(e.filter(e=>"string"==typeof e&&e.length))).sort();return t.length?t:void 0}function h(e,t){return t.some(t=>e===t||e.startsWith(t+"/"))}function m(e,t){const n=f(t.refs),r=!1!==t.includeSummary;if(!n)return{snapshot:{version:e.version,createdAt:e.createdAt,state:e.state,...r&&e.summary?{summary:e.summary}:{}}};const o={};for(const[t,r]of Object.entries(e.state))h(t,n)&&(o[t]=r);const a={};if(r&&e.summary)for(const[t,r]of Object.entries(e.summary))h(t,n)&&(a[t]=r);return{snapshot:{version:e.version,createdAt:e.createdAt,state:o,...Object.keys(a).length?{summary:a}:{}},refs:n}}function p(e,t){const n={},r=[];for(const[r,o]of Object.entries(t.state))Object.prototype.hasOwnProperty.call(e.state,r)&&u(e.state[r])===u(o)||(n[r]=o);for(const n of Object.keys(e.state))Object.prototype.hasOwnProperty.call(t.state,n)||r.push(n);const o={},a=[],i=e.summary??{},s=t.summary??{};for(const[e,t]of Object.entries(s))Object.prototype.hasOwnProperty.call(i,e)&&u(i[e])===u(t)||(o[e]=t);for(const e of Object.keys(i))Object.prototype.hasOwnProperty.call(s,e)||a.push(e);return{changed:n,removed:r.sort(),...Object.keys(o).length?{summaryChanged:o}:{},...a.length?{summaryRemoved:a.sort()}:{}}}function g(e){return null==e?"NULL":"number"==typeof e?"DOUBLE":"string"==typeof e?"VARCHAR":"boolean"==typeof e?"BOOLEAN":e instanceof Date?"TIMESTAMP":Array.isArray(e)?"ARRAY":"OBJECT"}((e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})})(a,{unstable_SEMIOTIC_VACP_ACTIVATE_NAVIGATION_ACTION:()=>$,unstable_SEMIOTIC_VACP_CLEAR_SELECTION_ACTION:()=>v,unstable_SEMIOTIC_VACP_INSPECT_DATA_ACTION:()=>w,unstable_SEMIOTIC_VACP_SET_INTERVAL_SELECTION_ACTION:()=>b,unstable_SEMIOTIC_VACP_SET_POINT_SELECTION_ACTION:()=>y,unstable_VACP_DATA_SCHEMA_ACTION:()=>A,unstable_VACP_SCHEMA_VERSION:()=>C,unstable_createSemioticVACPBridge:()=>vt,unstable_installSemioticVACPBridge:()=>$t}),module.exports=(e=a,((e,a,i,s)=>{if(a)for(let i of r(a))o.call(e,i)||void 0===i||t(e,i,{get:()=>a[i],enumerable:!(s=n(a,i))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var y="semiotic.set_point_selection",b="semiotic.set_interval_selection",v="semiotic.clear_selection",$="semiotic.activate_navigation_node",w="semiotic.inspect_data",C="0.1.0",A="vacp.data_schema";function k(e,t){if(!t.descriptor.name.trim())throw Error("VACP action names must be non-empty.");if(e.some(e=>e.descriptor.name===t.descriptor.name))throw Error(`Duplicate VACP action "${t.descriptor.name}".`);e.push(t)}function S(e,t){if(!i(e))throw Error(t+" expects an object parameter payload.");return e}function x(e,t){return"number"==typeof e&&Number.isFinite(e)?Math.max(1,Math.floor(e)):t}function j(e,t,n){if("string"!=typeof e.selectionRef)throw Error("params.selectionRef must be a VACP selection ref.");const r=t.find(t=>t.ref===e.selectionRef);if(!r)throw Error(`Unknown selection ref "${e.selectionRef}".`);if(n&&!r.modes.has(n))throw Error(`Selection "${r.name}" does not accept ${n} state.`);return r}function I(e){return null==e||"string"==typeof e||"number"==typeof e&&Number.isFinite(e)||"boolean"==typeof e||e instanceof Date&&Number.isFinite(e.getTime())}function P(e,t,n){const r=[],o=e.dataHandles.map(e=>e.ref);o.length&&k(r,{descriptor:{name:A,title:"Describe Semiotic data",description:"Return columns, types, row count, and optional bounded summaries for a chart DataHandle.",targetRef:n.view,parameters:{type:"object",properties:{handleRef:{type:"string",enum:o},detail:{type:"string",enum:["columns","full"]},sampleRows:{type:"number",minimum:1}},required:["handleRef"]}},execute(n){const r=S(n,A);if("string"!=typeof r.handleRef)throw Error("params.handleRef must be a DataHandle ref.");const o=e.dataHandles.find(e=>e.ref===r.handleRef);if(!o)throw Error(`Unknown DataHandle "${r.handleRef}".`);const a=void 0===r.detail||"columns"===r.detail?"columns":"full"===r.detail?"full":(()=>{throw Error('params.detail must be "columns" or "full".')})(),s="number"==typeof r.sampleRows&&Number.isFinite(r.sampleRows)?Math.max(1,Math.floor(r.sampleRows)):"full"===a?1e3:Math.min(o.rows.length,1e3),l=x(t.dataAccess?.maxSchemaRows,5e3);return function(e){const t=e.rows.slice(0,Math.max(0,e.sampleRows)),n=function(e){const t=new Map;for(const n of e)if(i(n))for(const[e,r]of Object.entries(n)){const n=t.get(e)??new Set;n.add(g(r)),t.set(e,n)}return Array.from(t).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>{const n=Array.from(t).filter(e=>"NULL"!==e);return{name:e,type:0===n.length?"NULL":1===new Set(n).size?n[0]:"MIXED"}})}(e.rows),r=n.map(e=>e.name);if("columns"===e.detail)return{handleRef:e.handleRef,detail:e.detail,table:null,rowCount:e.rows.length,columns:n};const o=function(e,t){const n=Object.create(null);for(const r of t){const t=[];for(const n of e){if(!i(n))continue;const e=n[r];"number"==typeof e&&Number.isFinite(e)&&t.push(e)}if(!t.length)continue;let o=t[0],a=t[0],s=0;for(const e of t)o=Math.min(o,e),a=Math.max(a,e),s+=e;n[r]={min:o,max:a,avg:s/t.length}}return Object.keys(n).length?n:void 0}(t,r),a=function(e,t){const n=Object.create(null);for(const r of t){const t=[];for(const n of e){if(!i(n))continue;const e=n[r];e instanceof Date&&Number.isFinite(e.getTime())&&t.push(e.getTime())}if(!t.length)continue;const o=Math.min(...t),a=Math.max(...t);n[r]={minIso:new Date(o).toISOString(),maxIso:new Date(a).toISOString(),minEpochMs:o,maxEpochMs:a}}return Object.keys(n).length?n:void 0}(t,r),s=function(e,t){const n=Object.create(null);for(const r of t){const t=new Map;for(const n of e){if(!i(n))continue;const e=n[r];if("string"!=typeof e&&"boolean"!=typeof e)continue;const o=e+"";t.set(o,(t.get(o)??0)+1)}t.size&&(n[r]=Array.from(t).sort(([e,t],[n,r])=>r-t||e.localeCompare(n)).slice(0,10).map(([e,t])=>({value:e,n:t})))}return Object.keys(n).length?n:void 0}(t,r);return{handleRef:e.handleRef,detail:e.detail,table:null,rowCount:e.rows.length,columns:n,...o?{numeric:o}:{},...a?{temporal:a}:{},...s?{categoricalTopValues:s}:{},sampledRows:t.length}}({handleRef:o.ref,rows:o.rows,detail:a,sampleRows:Math.min(s,l)})}}),o.length&&t.dataAccess?.sample&&k(r,{descriptor:{name:w,title:"Inspect bounded Semiotic rows",description:"Return a bounded JSON sample from a chart DataHandle. This action is opt-in.",targetRef:n.view,parameters:{type:"object",properties:{handleRef:{type:"string",enum:o},offset:{type:"number",minimum:0},limit:{type:"number",minimum:1}},required:["handleRef"]}},execute(n){const r=S(n,w);if("string"!=typeof r.handleRef)throw Error("params.handleRef must be a DataHandle ref.");const o=e.dataHandles.find(e=>e.ref===r.handleRef);if(!o)throw Error(`Unknown DataHandle "${r.handleRef}".`);const a="number"==typeof r.offset&&Number.isFinite(r.offset)?Math.max(0,Math.floor(r.offset)):0,i=x(t.dataAccess?.maxSampleRows,50),l="number"==typeof r.limit&&Number.isFinite(r.limit)?Math.max(1,Math.floor(r.limit)):Math.min(20,i),c=Math.min(l,i),u=o.rows.slice(a,a+c);return{handleRef:o.ref,offset:a,limit:c,rowCount:o.rows.length,rows:s(u,{maxArrayLength:i}),truncated:o.rows.length>a+u.length}}});const a=e.selections.map(e=>e.ref),c=e.selections.filter(e=>e.modes.has("point"));c.length&&t.selectionActions?.setPointSelection&&k(r,{descriptor:{name:y,title:"Set point selection",description:"Set a named LinkedCharts point-selection clause with allowlisted fields.",targetRef:n.view,parameters:{type:"object",properties:{selectionRef:{type:"string",enum:c.map(e=>e.ref)},fields:{type:"object"}},required:["selectionRef","fields"]}},async execute(n){const r=S(n,y),o=j(r,e.selections,"point"),a=function(e,t){if(!i(e)||!Object.keys(e).length)throw Error("params.fields must be a non-empty object.");const n=Object.create(null);for(const[r,o]of Object.entries(e)){if(!t.includes(r))throw Error(`Field "${r}" is not allowed for this selection.`);if(!Array.isArray(o)||!o.length)throw Error(`Point selection field "${r}" requires values[].`);for(const e of o)if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&("number"!=typeof e||!Number.isFinite(e)))throw Error(`Point selection field "${r}" only accepts JSON primitive values.`);n[r]=[...o]}return n}(r.fields,o.fields);return await(t.selectionActions?.setPointSelection?.(o.name,o.clientId,a)),{selectionRef:o.ref,fields:a}}});const u=e.selections.filter(e=>e.modes.has("interval"));u.length&&t.selectionActions?.setIntervalSelection&&k(r,{descriptor:{name:b,title:"Set interval selection",description:"Set a named LinkedCharts interval-selection clause in data units.",targetRef:n.view,parameters:{type:"object",properties:{selectionRef:{type:"string",enum:u.map(e=>e.ref)},fields:{type:"object"}},required:["selectionRef","fields"]}},async execute(n){const r=S(n,b),o=j(r,e.selections,"interval"),a=function(e,t){if(!i(e)||!Object.keys(e).length)throw Error("params.fields must be a non-empty object.");const n=Object.create(null);for(const[r,o]of Object.entries(e)){if(!t.includes(r))throw Error(`Field "${r}" is not allowed for this selection.`);if(!Array.isArray(o)||2!==o.length||"number"!=typeof o[0]||"number"!=typeof o[1]||!Number.isFinite(o[0])||!Number.isFinite(o[1]))throw Error(`Interval selection field "${r}" requires [min,max].`);n[r]=[Math.min(o[0],o[1]),Math.max(o[0],o[1])]}return n}(r.fields,o.fields);return await(t.selectionActions?.setIntervalSelection?.(o.name,o.clientId,a)),{selectionRef:o.ref,fields:a}}}),a.length&&t.selectionActions?.clearSelection&&k(r,{descriptor:{name:v,title:"Clear selection",description:"Clear every active clause from one named LinkedCharts selection.",targetRef:n.view,parameters:{type:"object",properties:{selectionRef:{type:"string",enum:a}},required:["selectionRef"]}},async execute(n){const r=j(S(n,v),e.selections);return await(t.selectionActions?.clearSelection?.(r.name)),{selectionRef:r.ref,cleared:!0}}});const f=e.charts.map(e=>e.navigation).filter(e=>!!e&&e.index.valid&&!!e.binding.onActiveChange);f.length&&k(r,{descriptor:{name:$,title:"Activate chart navigation target",description:"Move an accessible chart navigation tree to a uniquely identified datum.",targetRef:n.view,parameters:{type:"object",properties:{navigationRef:{type:"string",enum:f.map(e=>e.ref)},match:{type:"object"}},required:["navigationRef","match"]}},execute(e){const t=S(e,$);if("string"!=typeof t.navigationRef)throw Error("params.navigationRef must be a navigation ref.");const n=f.find(e=>e.ref===t.navigationRef);if(!n)throw Error(`Unknown navigation ref "${t.navigationRef}".`);const r=function(e,t){if(!i(e))throw Error("params.match must be an object.");for(const n of Object.keys(e))if(!t.includes(n))throw Error(`params.match includes undeclared field "${n}".`);const n=Object.create(null);for(const r of t){if(!Object.prototype.hasOwnProperty.call(e,r)||!I(e[r]))throw Error(`params.match requires a primitive value for "${r}".`);n[r]=e[r]instanceof Date?e[r].toISOString():e[r]}return n}(t.match,n.index.matchFields),o=n.index.byKey.get(d(r));if(!o)throw Error("No navigation datum matches params.match.");return n.binding.onActiveChange?.(o),{navigationRef:n.ref,targetRef:n.index.targetRef(r),match:r}}});const h="function"==typeof t.actions?t.actions():t.actions;for(const e of h??[])e.available&&!e.available()||k(r,{descriptor:{...e.descriptor,...e.descriptor.parameters?{parameters:l(e.descriptor.parameters)}:{}},async execute(t){const n=e.validate?.(t);if("string"==typeof n&&n)throw Error(n);return e.execute(t)}});return r}var O=["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","RidgelinePlot","DotPlot","PieChart","DonutChart","GaugeChart","FunnelChart","SwimlaneChart","LikertChart","LineChart","BumpChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","BubbleChart","Heatmap","QuadrantChart","MultiAxisLineChart","CandlestickChart","ConnectedScatterplot","ScatterplotMatrix","MinimapChart","ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram","TreeDiagram","Treemap","CirclePack","OrbitDiagram","ChoroplethMap","ProportionalSymbolMap","FlowMap","DistanceCartogram","RealtimeLineChart","RealtimeHistogram","TemporalHistogram","RealtimeSwarmChart","RealtimeWaterfallChart","RealtimeHeatmap","GaltonBoardChart","EventDropChart","UnitPileChart","CollisionSwarmChart","GauntletChart","CrucibleChart","ProcessFlowChart","PacketFlowChart","ChainReactionChart","BigNumber"],R=new Set(O);function D(e,t=new Set){if(null===e)return!0;const n=typeof e;if("string"===n||"boolean"===n)return!0;if("number"===n)return Number.isFinite(e);if("object"!==n)return!1;if(t.has(e))return!1;t.add(e);const r=Array.isArray(e)?e.every(e=>D(e,t)):Object.entries(e).every(([,e])=>D(e,t));return t.delete(e),r}var M=Symbol.for("semiotic.chartRecipeRegistry");function F(e){return function(){const e=globalThis;return e[M]||(e[M]={recipes:new Map,capabilities:new Map,layouts:new Map}),e[M]}().recipes.get(e)}function L(e){return"string"==typeof e?F(e):e&&"object"==typeof e&&"string"==typeof e.id?e:void 0}function N(e){return"string"==typeof e?e:e.id??e.name}function E(e){return e.layoutConfig&&"object"==typeof e.layoutConfig?e.layoutConfig:{}}function T(e){return Array.isArray(e.data)?e.data:Array.isArray(e.nodes)?e.nodes:Array.isArray(e.points)?e.points:Array.isArray(e.areas)?e.areas:[]}function B(e,t,n){return n??L(t.recipe)??L(t.recipeId)??F(e)}function _(e,t,n=[]){const r=e.accessor?t[e.accessor]:void 0;if("string"==typeof r&&r)return r;if(e.field)return e.field;const o=n.find(e=>e&&"object"==typeof e);if(!o)return;const a=Object.entries(o).filter(([e,t])=>!e.startsWith("_")&&null!=t);return"quantitative"===e.semanticType?a.find(([,e])=>"number"==typeof e)?.[0]:"identifier"===e.semanticType?["id","key","name"].find(e=>e in o):a.find(([,e])=>"string"==typeof e)?.[0]}function V(e,t){return e.dataRoles.find(e=>e.role===t)}function z(e,t){return e.dataRoles.find(e=>t.includes(e.semanticType))}function H(e,t,n,r,o,a={}){const i={...a};if(t)for(const[e,n]of Object.entries(t))i[e]=n;for(const e of n.dataRoles){const n=_(e,r,o),a=t&&n?t[n]:n;void 0!==a&&(i[e.role]=a)}return e.replace(/\{([^}]+)\}/g,(e,t)=>{const n=i[t];return null==n?`{${t}}`:n+""})}var q="1",G=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend","recipe","layout"]),U=new Set(["data","nodes","edges","points","areas","lines","flows"]);function K(e){if(null==e)return e;if("function"==typeof e)return;if("object"!=typeof e)return e;if(e.$$typeof)return;if(Array.isArray(e))return e.map(K).filter(e=>void 0!==e);if(e instanceof Date)return e;const t={};for(const[n,r]of Object.entries(e)){if("function"==typeof r)continue;if(r&&"object"==typeof r&&r.$$typeof)continue;const e=K(r);void 0!==e&&(t[n]=e)}return t}function J(e,t){return!!U.has(e)&&("areas"!==e||"string"!=typeof t)}var W="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function Q(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function X(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}var Y=new Set(["LineChart","AreaChart","StackedAreaChart","DifferenceChart","Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","MultiAxisLineChart","MinimapChart"]),Z=new Set(["BarChart","StackedBarChart","GroupedBarChart","DotPlot"]),ee=new Set(["PieChart","DonutChart","FunnelChart"]),te=new Set(["Histogram","BoxPlot","ViolinPlot","RidgelinePlot","SwarmPlot"]);function ne(e,t){return Z.has(e)||ee.has(e)||"SwimlaneChart"===e||"GaugeChart"===e?{measure:t.valueAccessor,measureFallback:"value",dimension:t.categoryAccessor??t.stepAccessor,dimensionFallback:"category"}:{measure:t.yAccessor??t.valueAccessor,measureFallback:"y",dimension:t.xAccessor,dimensionFallback:"x"}}function re(e){for(const t of["lineBy","areaBy","stackBy","groupBy","colorBy"]){const n=e[t];if("string"==typeof n&&n)return n}}function oe(e,t){return null==e?"—":e instanceof Date?e.toISOString().slice(0,10):"number"==typeof e?t(e):e+""}function ae(e,t={}){const n=!0===t.showRetractedAnnotations,r=!0===t.showSupersededAnnotations,o=new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!n)return!1;const t=e?.provenance?.stableId;return!(t&&o.has(t)&&!r)})}var ie={LineChart:"line chart",AreaChart:"area chart",StackedAreaChart:"stacked area chart",DifferenceChart:"difference chart",Scatterplot:"scatter plot",BubbleChart:"bubble chart",ConnectedScatterplot:"connected scatter plot",QuadrantChart:"quadrant chart",MultiAxisLineChart:"dual-axis line chart",CandlestickChart:"candlestick chart",BumpChart:"bump chart",Heatmap:"heatmap",MinimapChart:"line chart",BarChart:"bar chart",StackedBarChart:"stacked bar chart",GroupedBarChart:"grouped bar chart",DotPlot:"dot plot",Histogram:"histogram",BoxPlot:"box plot",ViolinPlot:"violin plot",RidgelinePlot:"ridgeline plot",SwarmPlot:"swarm plot",PieChart:"pie chart",DonutChart:"donut chart",FunnelChart:"funnel chart",GaugeChart:"gauge",LikertChart:"Likert chart",SwimlaneChart:"swimlane chart",ForceDirectedGraph:"network graph",SankeyDiagram:"Sankey diagram",ProcessSankey:"temporal Sankey diagram",ChordDiagram:"chord diagram",TreeDiagram:"tree diagram",Treemap:"treemap",CirclePack:"circle-packing chart",OrbitDiagram:"orbit diagram",ChoroplethMap:"choropleth map",ProportionalSymbolMap:"proportional-symbol map",FlowMap:"flow map",DistanceCartogram:"distance cartogram",BigNumber:"single value",StreamPhysicsFrame:"physics stream frame",EventDropChart:"event-drop physics chart",GaltonBoardChart:"Galton board chart",UnitPileChart:"physics pile chart",CollisionSwarmChart:"collision swarm chart",PacketFlowChart:"physical flow chart",ProcessFlowChart:"process flow physics chart",CrucibleChart:"crucible physics chart",PhysicsCustomChart:"custom physics chart"},se=new Set(["ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram"]),le=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","GauntletChart","CrucibleChart","PhysicsCustomChart"]);function ce(e){return ie[e]||e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()+" chart"}function ue(e){const t="number"==typeof e?e:"string"==typeof e?Number(e):NaN;return Number.isFinite(t)?t:void 0}var de=new Set(["Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","ScatterplotMatrix"]),fe={"outlier-detection":"alerting","change-detection":"alerting",trend:"tracking","composition-over-time":"apportioning","compare-series":"comparing","compare-categories":"comparing",rank:"ranking","part-to-whole":"apportioning",distribution:"characterizing",correlation:"relating",flow:"tracing",hierarchy:"nesting",geo:"locating"},he={"time-series":"tracking",categorical:"comparing",distribution:"characterizing",relationship:"relating",flow:"tracing",network:"tracing",hierarchy:"nesting",geo:"locating",realtime:"tracking",value:"presenting",custom:"presenting"},me=["trend","compare-series","compare-categories","rank","part-to-whole","distribution","correlation","flow","hierarchy","geo","composition-over-time","change-detection","outlier-detection"],pe={alerting:"alerting",tracking:"trend",comparing:"comparison",ranking:"ranking",apportioning:"composition",characterizing:"distribution",relating:"correlation",tracing:"flow",nesting:"hierarchy",locating:"locator",presenting:"single-value"};function ge(e,t){const n=function(e){if(e){if("fits"in e||"buildProps"in e){const t=e,n={};for(const[e,r]of Object.entries(t.intentScores))"number"==typeof r&&Number.isFinite(r)&&(n[e]=r);return{family:t.family,intentScores:Object.keys(n).length?n:void 0}}return e}}(t);if(n?.act)return n.act;if(n?.intentScores){const e=function(e){let t,n=0;for(const[r,o]of Object.entries(e))if("number"==typeof o&&o>0)if(o>n)t=r,n=o;else if(o===n&&void 0!==t){const e=me.indexOf(r),n=me.indexOf(t);-1===e||-1!==n&&e>=n||(t=r)}return t}(n.intentScores);if(e&&fe[e]&&(n.intentScores[e]??0)>=3)return fe[e]}return n?.family?he[n.family]:function(e){return"BumpChart"===e?"ranking":ee.has(e)||"StackedAreaChart"===e?"apportioning":de.has(e)?"relating":Z.has(e)?"comparing":te.has(e)?"characterizing":Y.has(e)?"tracking":se.has(e)?"tracing":"BigNumber"===e?"presenting":void 0}(e)}var ye=new Set(["y-threshold","x-threshold","band","x-band","callout","label"]),be=new Set(["system","agent","watcher"]),ve=new Set(["ai","agent","system","computed","dbt","great-expectations"]),$e=new Set(["rule","statistical-test","llm-inference","computed"]);function we(e){const t=e.annotations;return!!Array.isArray(t)&&t.some(e=>{if(!e||"object"!=typeof e)return!1;const t=e;if("string"!=typeof t.type||!ye.has(t.type))return!1;const n=t.provenance;return!(!n||"object"!=typeof n)&&(be.has(n.authorKind)||ve.has(n.source)||$e.has(n.basis))})}function Ce(e="en"){let t,n;try{t=new Intl.NumberFormat(e,{notation:"compact",maximumFractionDigits:1}),n=new Intl.NumberFormat(e,{maximumFractionDigits:2})}catch{t=new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}),n=new Intl.NumberFormat("en",{maximumFractionDigits:2})}return e=>Number.isFinite(e)?1e4>Math.abs(e)?n.format(e):t.format(e):e+""}var Ae={"y-threshold":"a threshold line","x-threshold":"a threshold line",band:"a highlighted band","x-band":"a highlighted band",label:"a label",callout:"a callout","callout-circle":"a callout","callout-rect":"a callout",text:"a text note",bracket:"a bracket",enclose:"an enclosure","rect-enclose":"an enclosure",highlight:"a highlight",widget:"a widget",trend:"a trend line",envelope:"an envelope","anomaly-band":"an anomaly band",forecast:"a forecast","category-highlight":"a category highlight"};function ke(e){const t=Ae["string"==typeof e.type?e.type:"annotation"]||"an annotation",n=function(e){const t=e.provenance&&"object"==typeof e.provenance?e.provenance:null,n=t?.authorKind??t?.source??t?.basis;return"watcher"===n?"a watcher-flagged ":"agent"===n||"ai"===n||"llm-inference"===n?"an AI-suggested ":""}(e),r=n?n+t.replace(/^an? /,""):t,o="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:void 0;return o?`${r} labeled "${o}"`:r}function Se(e){const t=Array.isArray(e.annotations)?e.annotations:null;if(!t||0===t.length)return;const n=ae(t.filter(e=>!!e&&"object"==typeof e));if(0===n.length)return;const r=n.map(ke),o=r.slice(0,5),a=r.length-o.length,i=function(e){return e.length>1?2===e.length?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")}, and ${e[e.length-1]}`:e[0]??""}(o)+(a>0?`, and ${a} more`:""),s=n.length;return`The author has marked ${1===s?"one feature":s+" features"} on this chart: ${i}.`}function xe(e,t,n={}){const r=void 0!==n.levels,o=new Set(n.levels??["l1","l2","l3"]);r||!n.capability&&!we(t)||o.add("l4");const a=B(e,t,n.recipe);if(a){const e=["l1","l2","l3","l4"].filter(e=>o.has(e));r||e.includes("l4")||e.push("l4");const i=function(e,t,n={}){const r=T(t),o=E(t),a=n.locale??"en",i="function"==typeof e.description?e.description({data:r,config:o,locale:a}):void 0,s=i?.levels??function(e,t,n,r){const o=z(e,["nominal","ordinal"]),a=z(e,["quantitative"]),i=o?_(o,n,t):void 0,s=a?_(a,n,t):void 0,l=o?.role??i??"category",c=a?.role??s??"value",u=e.encodings??[],d=u.length?u.slice(0,3).map(e=>e.meaning.replace(/\.$/,"")).join("; "):`${l} and ${c} are mapped through the recipe's declared visual semantics`,{number:f,percent:h}=function(e){try{return{number:new Intl.NumberFormat(e,{maximumFractionDigits:2}),percent:new Intl.NumberFormat(e,{style:"percent",maximumFractionDigits:1})}}catch{return{number:new Intl.NumberFormat("en",{maximumFractionDigits:2}),percent:new Intl.NumberFormat("en",{style:"percent",maximumFractionDigits:1})}}}(r),m=new Map;if(i&&s)for(const e of t){const t=(e[i]??"Uncategorized")+"",n=Number(e[s]);Number.isFinite(n)&&m.set(t,(m.get(t)??0)+n)}const p=[...m].sort((e,t)=>t[1]-e[1]),g=p.reduce((e,[,t])=>e+t,0),y=p[0],b=p[1],v=g>0?((y?.[1]??0)+(b?.[1]??0))/g:0,$=e.intents.map(e=>({id:N(e),strength:"string"==typeof e?void 0:e.strength})).sort((e,t)=>"primary"===e.strength?-1:"primary"===t.strength?1:0)[0]?.id,w=e.audience?.primary??e.audienceFit?.find(e=>"strong"===e.fit)?.audience;return{l1:`A ${e.name.toLowerCase()} encodes ${l} and ${c}. ${C=d,C?C.charAt(0).toUpperCase()+C.slice(1):C}.`,l2:p.length>0?`${p.length} categories total ${f.format(g)}. ${y[0]} accounts for ${f.format(y[1])}${g>0?` (${h.format(y[1]/g)})`:""}${b?`, followed by ${b[0]} at ${f.format(b[1])}`:""}.`:`${t.length} data ${1===t.length?"item is":"items are"} represented.`,l3:2>p.length?y?y[0]+" is the only represented category.":"No quantitative pattern can be derived from the available data.":.5>v?`The total is distributed across ${p.length} categories without the first two forming a majority.`:`Most of the total is concentrated in ${y[0]} and ${b[0]}, which together account for ${h.format(v)}.`,l4:`The chart is intended for ${$??"explanation"}${w?` with a ${w} audience`:""}: ${e.designContract.whyCustom}`};var C}(e,r,o,a),l=n.levels??["l1","l2","l3","l4"],c={};for(const e of l)s[e]&&(c[e]=s[e]);const u=["l1","l2","l3","l4"].map(e=>c[e]).filter(e=>!!e).join(" "),d=n.includeCaveats?[...e.reception?.risks??[],...e.caveats??[],...(e.designContract.misuse??[]).map(e=>"Misuse: "+e)]:void 0;return{text:u,levels:c,...d?.length?{caveats:d}:{}}}(a,t,{levels:e,locale:n.locale,audience:n.audience,includeCaveats:n.includeCaveats}),s=Se(t);return{...i,text:s?`${s} ${i.text}`.trim():i.text,...s?{annotations:s}:{}}}const i=Ce(n.locale??"en"),s=ce(e),l=Array.isArray(t.data)?t.data:null,c=re(t),u=le.has(e)?function(e,t){const n=e.physics&&"object"==typeof e.physics?e.physics:null,r=e.settledProjection&&"object"==typeof e.settledProjection?e.settledProjection:null,o=[e.settledProjectionRows,e.projectionRows,r?.rows,n?.settledProjectionRows,n?.projectionRows,n?.settledProjection&&"object"==typeof n.settledProjection?n.settledProjection.rows:void 0].find(e=>Array.isArray(e));return Array.isArray(o)?o.map((e,n)=>{if(!e||"object"!=typeof e)return null;const r=e,o=ue(r.count??r.value??r.total??r.bodies??r.events);if(null==o)return null;const a=r.label??r.id??r.name??"container "+(n+1),i=ue(r.secondary??r.secondaryCount),s=ue(r.observed??r.observedCount);return{label:oe(a,t),count:o,...null!=i?{secondary:i}:{},..."string"==typeof r.secondaryLabel&&r.secondaryLabel?{secondaryLabel:r.secondaryLabel}:{},...null!=s?{observed:s}:{}}}).filter(e=>null!=e):null}(t,i):null,{measure:d,measureFallback:f,dimension:h,dimensionFallback:m}=ne(e,t),p="string"==typeof d&&d?d:f,g="string"==typeof h&&h?h:m,y={};if(le.has(e)&&function(e,t,n,r,o,a){const i=function(e){return"EventDropChart"===e?"time window":"GaltonBoardChart"===e?"bin":"CollisionSwarmChart"===e?"group lane":"PacketFlowChart"===e?"flow node":"CrucibleChart"===e?"result group":"container"}(e),s=function(e){return"EventDropChart"===e?"event":"GaltonBoardChart"===e?"sample":"CollisionSwarmChart"===e?"point":"PacketFlowChart"===e?"packet":"CrucibleChart"===e?"settled item":"body"}(e);if(o.has("l1")&&(r.l1=function(e,t){return"EventDropChart"===e?"An event-drop physics chart that collapses moving events into a settled projection by event-time window.":"GaltonBoardChart"===e?"A Galton board chart that collapses falling samples into a settled histogram projection.":"UnitPileChart"===e?"A physics pile chart that collapses moving bodies into a settled bar-style projection by container.":"CollisionSwarmChart"===e?"A collision swarm chart that separates overlapping points while preserving their quantitative axis position.":"PacketFlowChart"===e?"A physical flow chart that keeps authored routes visible while packet bodies show throughput and proximity events.":"CrucibleChart"===e?"A crucible physics chart that replays authored phases and events into declared products and outlets; the settled ledger, not collisions, determines the result.":`A ${t} whose accessible reading is the settled projection rather than individual trajectories.`}(e,t)),!o.has("l2")&&!o.has("l3"))return;if(!n||0===n.length)return void(o.has("l2")&&(r.l2="No settled projection is loaded yet."));const l=n.reduce((e,t)=>e+t.count,0),c=n.filter(e=>e.count>0).sort((e,t)=>t.count-e.count),u=c[0]??n.slice().sort((e,t)=>t.count-e.count)[0];if(!u)return;const d=n.reduce((e,t)=>e+(t.secondary??0),0),f=n.find(e=>e.secondaryLabel)?.secondaryLabel??"secondary";if(o.has("l2"))if(0===c.length)r.l2=`The settled projection contains ${a(l)} ${Ie(l,s)} across ${n.length} ${Ie(n.length,i)}; no ${Ie(2,i)} are non-empty yet.`;else{const e=d>0?` ${a(d)} ${Ie(d,s)} ${1===d?"is":"are"} marked ${f}.`:"";r.l2=`The settled projection contains ${a(l)} ${Ie(l,s)} across ${n.length} ${Ie(n.length,i)}; ${c.length} ${Ie(c.length,i)} ${1===c.length?"is":"are"} non-empty. The largest ${i} is ${u.label} with ${a(u.count)} ${Ie(u.count,s)}.${e}`}if(o.has("l3")&&l>0&&c.length>0){const e=c.find(e=>e!==u),t=function(e,t){if(0>=t)return"0%";const n=e/t*100;return(10>n?Math.round(10*n)/10:Math.round(n))+"%"}(u.count,l);r.l3=e?`The settled projection is most concentrated in ${u.label}, which holds ${a(u.count)} ${Ie(u.count,s)} (${t}); ${e.label} follows with ${a(e.count)} ${Ie(e.count,s)}.`:`The settled projection is concentrated in ${u.label}, which holds all ${a(u.count)} ${Ie(u.count,s)}.`}}(e,s,u,y,o,i),o.has("l1")&&!le.has(e))if("BumpChart"===e)y.l1=`A ${s} ranking ${c??"series"} by ${p} across ${g}.`;else if(Y.has(e)||Z.has(e))y.l1=`A ${s} of ${p} by ${g}`+(c?`, split by ${c}.`:".");else if(ee.has(e))y.l1=`A ${s} showing ${p} across ${g} categories.`;else if(te.has(e))y.l1=`A ${s} of the distribution of ${p}`+(c?` by ${c}.`:".");else if(se.has(e)){const e=Array.isArray(t.nodes)?t.nodes.length:void 0,n=Array.isArray(t.edges)?t.edges.length:void 0,r=[null!=e?`${e} ${Ie(e,"node")}`:null,null!=n?`${n} ${Ie(n,"edge")}`:null].filter(Boolean);y.l1=`A ${s}${r.length?" with "+r.join(" and "):""}.`}else if("BigNumber"===e){const e="string"==typeof t.label?t.label:p;y.l1=`A single value${e?" for "+e:""}.`}else y.l1=`A ${s}.`;const b=Y.has(e)||"BumpChart"===e||Z.has(e)||ee.has(e)||te.has(e);let v=null;if((o.has("l2")||o.has("l3")||o.has("l4"))&&b&&l&&l.length>0&&(v=function(e,t,n,r){let o=0,a=0,i=1/0,s=-1/0,l=null,c=null,u=0,d=0,f=null,h=null,m=NaN,p=NaN;for(const n of e){const e=t(n);Number.isFinite(e)&&(0===o&&(m=e,f=n),p=e,h=n,i>e&&(i=e,l=n,u=o),e>s&&(s=e,c=n,d=o),o++,a+=e)}return 0===o?null:{count:o,min:i,max:s,mean:a/o,minLabel:oe(null!=l?n(l):null,r),maxLabel:oe(null!=c?n(c):null,r),first:m,last:p,firstLabel:oe(null!=f?n(f):null,r),lastLabel:oe(null!=h?n(h):null,r),minIndex:u,maxIndex:d}}(l,Q(d,f),X(h,m),i)),o.has("l2")&&b&&(l&&0!==l.length?v&&(y.l2=ee.has(e)?`${v.count} segments totaling ${i(function(e){return e.mean*e.count}(v))}. Largest is ${v.maxLabel} at ${i(v.max)}; smallest is ${v.minLabel} at ${i(v.min)}.`:`${p} ranges from ${i(v.min)} (${v.minLabel}) to ${i(v.max)} (${v.maxLabel}), with a mean of ${i(v.mean)} across ${v.count} points.`):y.l2="No data is loaded yet."),o.has("l3")&&v&&!c&&Y.has(e)?y.l3=function(e,t,n){const{first:r,last:o,min:a,max:i,maxLabel:s,minLabel:l,firstLabel:c,lastLabel:u,minIndex:d,maxIndex:f,count:h}=e,m=i-a,p=o-r;if(0===m)return`${je(t)} is constant at ${n(r)} across the series.`;if(.04>m/(Math.abs(e.mean)||1))return`${je(t)} ends roughly where it started (${n(r)} at ${c} to ${n(o)} at ${u}), ranging between ${n(a)} and ${n(i)}.`;const g=f>0&&h-1>f,y=d>0&&h-1>d,b=(i-Math.max(r,o))/m,v=(Math.min(r,o)-a)/m;return g&&b>.15?`Overall ${t} climbs to a peak of ${n(i)} (${s}), then falls to ${n(o)} (${u}).`:y&&v>.15?`Overall ${t} drops to a low of ${n(a)} (${l}), then recovers to ${n(o)} (${u}).`:.05>Math.abs(p)/m?`${je(t)} ends roughly where it started (${n(r)} at ${c} to ${n(o)} at ${u}), ranging between ${n(a)} and ${n(i)}.`:p>0?f===h-1?`Overall ${t} rises from ${n(r)} (${c}) to a peak of ${n(o)} (${u}).`:`Overall ${t} rises from ${n(r)} (${c}) to ${n(o)} (${u}), after peaking at ${n(i)} (${s}).`:d===h-1?`Overall ${t} falls from ${n(r)} (${c}) to a low of ${n(o)} (${u}).`:`Overall ${t} falls from ${n(r)} (${c}) to ${n(o)} (${u}), after dipping to ${n(a)} (${l}).`}(v,p,i):o.has("l3")&&v&&!c&&Z.has(e)&&(y.l3=`The highest ${g} is ${v.maxLabel} and the lowest is ${v.minLabel}.`),o.has("l4")){const r=we(t)?"alerting":ge(e,n.capability);r&&(y.l4=function(e,t,n,r,o,a,i,s){const l=pe[e],c=/^[aeiou]/i.test(l)?"an":"a";let u,d;switch(e){case"locating":u="This is a map",d="read values by location";break;case"presenting":u="This is a single-value display",d=`read ${"string"==typeof n.label&&n.label?n.label:o} as the headline number`;break;case"tracing":u=`This is ${c} ${l} chart`,d="follow the movement between states";break;case"nesting":u=`This is ${c} ${l} chart`,d="read it for nested structure and how children sum into their parents";break;case"relating":u=`This is ${c} ${l} chart`,d=`read it for whether ${a} and ${o} move together`;break;default:u=`This is ${c} ${l} chart`,d=function(e,t,n,r,o,a){if(!t)switch(e){case"alerting":return"watch for points that break from the rest";case"tracking":return"read it for the overall direction of "+n;case"comparing":return`compare ${n} across ${r}`;case"ranking":return"read it top to bottom by "+n;case"apportioning":return`read each ${r}'s share of the whole`;case"characterizing":return"read it for the spread and shape of "+n;default:return"read the highlighted features"}switch(e){case"alerting":return function(e,t,n){if(Z.has(n)||ee.has(n))return`${e.maxLabel} stands out at ${t(e.max)} — check it first`;const{first:r,last:o,min:a,max:i,minLabel:s,maxLabel:l,lastLabel:c,minIndex:u,maxIndex:d,count:f}=e,h=i-a;if(h>0){const e=d>0&&f-1>d,n=u>0&&f-1>u,m=(i-Math.max(r,o))/h,p=(Math.min(r,o)-a)/h;if(e&&m>.15)return`the peak of ${t(i)} at ${l} is the point to investigate`;if(n&&p>.15)return`the dip to ${t(a)} at ${s} is the point to investigate`;if(o>=i)return`the climb to ${t(o)} at ${c} warrants a closer look`;if(a>=o)return`the drop to ${t(o)} at ${c} warrants a closer look`}return`the extremes — ${l} (${t(i)}) and ${s} (${t(a)}) — are the points to check`}(t,o,a);case"tracking":return`read it for the trajectory of ${n}, which ${function(e){const t=e.max-e.min,n=e.last-e.first;return 0===t||.05>Math.abs(n)/t?"holds roughly steady":n>0?"rises":"falls"}(t)} from ${o(t.first)} (${t.firstLabel}) to ${o(t.last)} (${t.lastLabel})`;case"comparing":return`compare ${n} across ${r}; ${t.maxLabel} leads at ${o(t.max)}`;case"ranking":return`read it top to bottom by ${n}; ${t.maxLabel} ranks highest at ${o(t.max)}`;case"apportioning":{const e=t.mean*t.count,n=e>0?Math.round(t.max/e*100):null;return`read each ${r}'s share of the ${o(e)} total; ${t.maxLabel} is the largest at ${o(t.max)}${null!=n?` (${n}%)`:""}`}case"characterizing":return`read it for the spread of ${n}, from ${o(t.min)} to ${o(t.max)}`;default:return"read the highlighted features"}}(e,r,o,a,i,t)}return`${u}; ${d}.${function(e,t){if(!t)return"";const n=t.familiarity?.[e];return"number"!=typeof n||n>2?"":` This ${ce(e)} may be unfamiliar${t.name?` to ${t.name.toLowerCase()} readers`:""} — lean on this description.`}(t,s)}`}(r,e,t,c?null:v,p,g,i,n.audience))}const $=["l1","l2","l3","l4"].filter(e=>o.has(e)&&y[e]).map(e=>y[e]).join(" "),w=Se(t);return{text:w?`${w} ${$}`.trim():$,levels:y,...w?{annotations:w}:{}}}function je(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function Ie(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function Pe(e){return((e??"unknown")+"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}var Oe=new Set(["ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram"]),Re=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),De=new Set(["ChoroplethMap","ProportionalSymbolMap","FlowMap","DistanceCartogram"]);function Me(e,t,n){return"function"==typeof t?t(e):e["string"==typeof t&&t?t:n]}function Fe(e,t="—"){return null==e||""===e?t:"object"==typeof e?Fe(e.id??e.name??e.label,t):e+""}function Le(e){const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:void 0}function Ne(e){return Fe(e,"unknown").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function Ee(e,t){const n=[];return(e.linkedHover||e.selection||e.linkedBrush)&&n.push("network"===t?"Use linked highlighting to trace related marks.":"Use linked highlighting to compare related locations."),(e.enableHover||e.tooltip)&&n.push("Hover or focus a mark for its details."),n.length>0?" "+n.join(" "):""}function Te(e,t){t&&e.children?.push(t)}function Be(e,t){const n=Me(e,t,"children");return Array.isArray(n)?n:[]}function _e(e,t,n){const r=Me(e,t,n);if(void 0!==r)return r;const o=e.properties;return o&&"object"==typeof o?Me(o,t,n):void 0}function Ve(e,t,n={}){const r=n.locale??"en",o=Math.max(1,n.maxLeaves??200),a=Ce(r),i=B(e,t,n.recipe);if(i)return function(e,t,n={}){const r=T(t),o=E(t),a=Math.max(1,n.maxLeaves??200);if("function"==typeof e.navigation)return e.navigation({data:r,config:o,locale:n.locale??"en"});const i=(s=e.navigation)&&"object"==typeof s?e.navigation:void 0;var s;const l=(i?.groupByRole?V(e,i.groupByRole):void 0)??(i?.groupBy?.[0]?V(e,i.groupBy[0])??e.dataRoles.find(e=>e.field===i.groupBy?.[0]):void 0)??z(e,["nominal","ordinal"]),c=l?_(l,o,r):void 0,u=(i?.idRole?V(e,i.idRole):void 0)??z(e,["identifier"]),d=u?_(u,o,r):void 0,f={id:"root",role:"chart",label:i?.summaryTemplate?H(i.summaryTemplate,void 0,e,o,r,{count:r.length}):`${e.name}: ${r.length} ${1===r.length?"item":"items"} represented.`,level:1,children:[]};let h=0;const m=(t,n,a)=>{const s=d?t[d]:void 0,l=i?.itemLabelTemplate?H(i.itemLabelTemplate,t,e,o,r,{count:r.length}):function(e,t,n,r){const o=z(t,["nominal","ordinal"]),a=t.dataRoles.filter(e=>"quantitative"===e.semanticType),i=o?_(o,n,r):void 0,s=[];i&&null!=e[i]&&s.push(e[i]+"");for(const t of a){const o=_(t,n,r);o&&null!=e[o]&&s.push(`${t.role}: ${e[o]+""}`)}return s.length>0?s.join(", "):"Data item"}(t,e,o,r);return{id:"datum-"+Pe(s??n),role:"datum",label:l,level:a,datum:t}};if(c){const e=new Map;for(const t of r){const n=(t[c]??"Uncategorized")+"",r=e.get(n);r?r.push(t):e.set(n,[t])}f.children=[...e].map(([e,t],n)=>{const r=t.slice(0,Math.max(0,a-h));h+=r.length;const o=r.map((e,t)=>m(e,1e5*n+t,3));return t.length>r.length&&o.push({id:"more-"+Pe(e),role:"datum",label:`…and ${t.length-r.length} more items`,level:3}),{id:"group-"+Pe(e),role:"series",label:`${e}: ${t.length} ${1===t.length?"item":"items"}.`,level:2,children:o}})}else{const e=r.slice(0,a);f.children=e.map((e,t)=>m(e,t,2)),r.length>e.length&&f.children.push({id:"more",role:"datum",label:`…and ${r.length-e.length} more items`,level:2})}return f}(i,t,{maxLeaves:o,locale:r});const s={id:"root",role:"chart",label:xe(e,t,{locale:r}).text||"Chart.",level:1,children:[]},l=function(e,t){const n=Array.isArray(e.annotations)?e.annotations:null;if(!n)return null;const r=ae(n.filter(e=>!!e&&"object"==typeof e));if(0===r.length)return null;let o=0;const a=r.slice(0,t).map(e=>{const t=e.lifecycle?.status,n=t&&"accepted"!==t?` (${t})`:"";return{id:"annotation-"+o++,role:"annotation",level:3,label:`${r=ke(e),r?r.charAt(0).toUpperCase()+r.slice(1):r}${n}.`,datum:e};var r});r.length>t&&a.push({id:"annotation-"+o++,role:"annotation",level:3,label:`…and ${r.length-t} more annotations.`});const i=r.length;return{id:"annotations",role:"annotation",level:2,label:`Annotations: ${1===i?"one marked feature":i+" marked features"}.`,children:a}}(t,o);if(Oe.has(e)){const n=function(e,t,n,r){const o=Array.isArray(t.nodes)?t.nodes:[],a=Array.isArray(t.edges)?t.edges:Array.isArray(t.flows)?t.flows:[],i=t.nodeIdAccessor??t.nodeIDAccessor,s=t.sourceAccessor??"source",l=t.targetAccessor??"target",c=t.valueAccessor??"value",u=e=>Fe(Me(e,i,"id"),"unknown"),d=(e,t)=>Fe(Me(e,t,""),"unknown"),f=new Set;for(const e of a)f.add(d(e,s)),f.add(d(e,l));const h=o.length>0?o:[...f].map(e=>({id:e})),m=new Map;for(const e of h)m.set(u(e),{links:0,value:0});for(const e of a){const t=d(e,s),n=d(e,l),r=Le(Me(e,c,"value"))??0;for(const e of[t,n]){const t=m.get(e)??{links:0,value:0};t.links+=1,t.value+=r,m.set(e,t)}}const p={id:"root",role:"chart",level:1,label:`A ${"SankeyDiagram"===e||"ProcessSankey"===e?"flow diagram":"ChordDiagram"===e?"chord diagram":"network graph"} with ${h.length} nodes and ${a.length} links.${Ee(t,"network")}`,children:[]};let g=0;const y=new Map,b=t.colorBy??"group";for(const e of h){const t=Fe(Me(e,b,"group"),"Ungrouped"),n=y.get(t);n?n.push(e):y.set(t,[e])}const v=[...y].map(([e,t],o)=>{const a=[];for(const[e,i]of t.entries()){if(g>=n)break;g+=1;const t=u(i),s=m.get(t)??{links:0,value:0},l=s.value>0?`, ${r(s.value)} total flow`:"";a.push({id:`node-${o}-${e}-${Ne(t)}`,role:"datum",level:3,label:`${t}: ${s.links} ${1===s.links?"link":"links"}${l}.`,value:s.value>0?s.value:void 0,datum:i})}return{id:`nodes-${o}-${Ne(e)}`,role:"series",level:2,label:`${e}: ${t.length} ${1===t.length?"node":"nodes"}.`,children:a}});v.length>0&&p.children?.push(...v);const $=a.slice(0,n).map((e,t)=>{const n=d(e,s),o=d(e,l),a=Le(Me(e,c,"value"));return{id:`link-${Ne(n)}-${Ne(o)}-${t}`,role:"datum",level:3,label:`${n} to ${o}${null==a?"":": "+r(a)}.`,value:a,datum:e}});return a.length>n&&$.push({id:"links-more",role:"datum",level:3,label:`…and ${a.length-n} more links.`,value:void 0}),$.length>0&&p.children?.push({id:"links",role:"series",level:2,label:`Links: ${a.length} ${1===a.length?"connection":"connections"}.`,children:$}),p}(e,t,o,a);return Te(n,l),n}if(Re.has(e)){const n=function(e,t,n,r){const o=t.data&&"object"==typeof t.data?t.data:null,a=t.childrenAccessor??"children",i=t.valueAccessor??"value",s=t.nodeLabel??t.nodeIdAccessor;let l=0;const c=new WeakMap,u=e=>{const t=c.get(e);if(t)return t;const n=Be(e,a),r=0===n.length?{leaves:1,value:Le(Me(e,i,"value"))??0,depth:1}:n.reduce((e,t)=>{const n=u(t);return{leaves:e.leaves+n.leaves,value:e.value+n.value,depth:Math.max(e.depth,n.depth+1)}},{leaves:0,value:0,depth:1});return c.set(e,r),r},d=(e,t,o)=>{const i=Be(e,a),c=Fe(Me(e,s,"name"),"item "+o),f=u(e),h=f.value;if(0===i.length)return n>l?(l+=1,{id:`hierarchy-${Ne(o)}-${Ne(c)}`,role:"datum",level:t,label:`${c}${h>0?": "+r(h):""}.`,value:h>0?h:void 0,datum:e}):null;const m=i.map((e,n)=>d(e,t+1,`${o}-${n}`)).filter(e=>null!==e);return 0!==m.length||n>l||m.push({id:`hierarchy-${Ne(o)}-more`,role:"datum",level:t+1,label:"More hierarchy items are not shown."}),{id:`hierarchy-${Ne(o)}-${Ne(c)}`,role:"series",level:t,label:`${c}: ${f.leaves} ${1===f.leaves?"descendant":"descendants"}${h>0?", total "+r(h):""}.`,children:m}},f=o?u(o):null,h={id:"root",role:"chart",label:o?`A ${"TreeDiagram"===e?"tree":"Treemap"===e?"treemap":"CirclePack"===e?"circle-packing":"orbit"} chart with ${f.leaves} leaves across ${f.depth} hierarchy levels.`:"A hierarchy chart with no hierarchy data loaded.",level:1,children:[]};if(o){const e=d(o,2,"root");e&&(h.children="series"===e.role&&""===Fe(Me(o,s,"name"),"")?e.children:[e])}return h}(e,t,o,a);return Te(n,l),n}if(De.has(e)){const n=function(e,t,n,r){const o=function(e){if(Array.isArray(e))return e;if(!e||"object"!=typeof e)return[];const t=e;return Array.isArray(t.features)?t.features:"Feature"===t.type?[t]:[]}(t.areas),a="FlowMap"===e&&Array.isArray(t.nodes)?t.nodes:Array.isArray(t.points)?t.points:[],i=Array.isArray(t.flows)?t.flows:[],s=Array.isArray(t.lines)?t.lines:[],l=t.valueAccessor??t.sizeBy??t.costAccessor??"value",c=t.pointIdAccessor??t.nodeIdAccessor??"id",u={id:"root",role:"chart",level:1,label:`${"ChoroplethMap"===e?`A choropleth map with ${o.length} regions.`:"FlowMap"===e?`A flow map with ${i.length} flows and ${a.length} locations.`:"DistanceCartogram"===e?`A distance cartogram with ${a.length} locations and ${s.length} routes.`:`A proportional-symbol map with ${a.length} locations.`}${Ee(t,"geo")}`,children:[]},d=[],f="ChoroplethMap"===e?o:a;f.slice(0,n).forEach((n,o)=>{const a=Fe(_e(n,"ChoroplethMap"===e?t.idAccessor:c,"id")??_e(n,"name","name")??_e(n,"label","label"),`${"ChoroplethMap"===e?"region":"location"} ${o+1}`),i=Le(_e(n,l,"value"));d.push({id:`geo-${Ne(a)}-${o}`,role:"datum",level:2,label:`${a}${null==i?"":": "+r(i)}.`,value:i,datum:n})}),f.length>n&&d.push({id:"geo-more",role:"datum",level:2,label:`…and ${f.length-n} more locations.`}),d.length>0&&u.children?.push({id:"ChoroplethMap"===e?"regions":"locations",role:"series",level:2,label:`${"ChoroplethMap"===e?"Regions":"Locations"}: ${f.length} marks.`,children:d.map(e=>({...e,level:3}))});const h="FlowMap"===e?i:s;if(h.length>0){const e=h.slice(0,n).map((e,t)=>{const n=Fe(e.source,"unknown"),o=Fe(e.target,"unknown"),a=Le(Me(e,l,"value"));return{id:`route-${Ne(n)}-${Ne(o)}-${t}`,role:"datum",level:3,label:`${n} to ${o}${null==a?"":": "+r(a)}.`,value:a,datum:e}});u.children?.push({id:"routes",role:"series",level:2,label:`Routes: ${h.length} ${1===h.length?"route":"routes"}.`,children:e})}return u}(e,t,o,a);return Te(n,l),n}const c=Array.isArray(t.data)?t.data:null,u=Y.has(e)||Z.has(e)||ee.has(e)||te.has(e);if(!c||0===c.length||!u)return l&&(s.children=[l]),s;const{measure:d,measureFallback:f,dimension:h,dimensionFallback:m}=ne(e,t),p=Q(d,f),g=X(h,m),y="string"==typeof d&&d?d:f,b="string"==typeof h&&h?h:m,v=re(t);let $=0;const w=e=>`${e}-${$++}`,C=(e,t)=>{const n=e.slice(0,o).map(e=>((e,t)=>{const n=p(e),r=oe(g(e),a);return{id:w("datum"),role:"datum",level:t,label:`${r}: ${Number.isFinite(n)?a(n):"—"}`,value:Number.isFinite(n)?n:void 0,datum:e}})(e,t));return e.length>o&&n.push({id:w("more"),role:"datum",level:t,label:`…and ${e.length-o} more points`}),n},A=[];if(Y.has(e)||Z.has(e)){let t=1/0,n=-1/0,r=1/0,o=-1/0;const i=[];let s=!0;for(const e of c){const a=p(e);Number.isFinite(a)&&(t>a&&(t=a),a>n&&(n=a));const l=g(e);i.push(l),"number"==typeof l&&Number.isFinite(l)?(r>l&&(r=l),l>o&&(o=l)):s=!1}const l=new Set,u=[];for(const e of i){const t=e+"";l.has(t)||(l.add(t),u.push(e))}const d=s?`${a(r)} to ${a(o)}`:`${oe(u[0],a)} to ${oe(u[u.length-1],a)} (${Z.has(e)?u.length+" categories":c.length+" points"})`;A.push({id:w("axis"),role:"axis",level:2,label:`${Z.has(e)?"Category axis":"X axis"}: ${b}, ${d}.`}),t>n||A.push({id:w("axis"),role:"axis",level:2,label:`Value axis: ${y}, ${a(t)} to ${a(n)}.`})}if(v){const n=X(v,v),o=new Map;for(const e of c){const t=(n(e)??"—")+"",r=o.get(t);r?r.push(e):o.set(t,[e])}const a=[];for(const[n,i]of o){const o=xe(e,{...t,data:i},{levels:["l2","l3"],locale:r}).text;a.push({id:w("series"),role:"series",level:2,label:`Series ${n}: ${o}`,children:C(i,3)})}s.children=[...A,...a]}else s.children=[...A,...C(c,2)];return l&&s.children.push(l),s}var ze=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","PhysicsCustomChart"]);function He(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function qe(e){return He(e)?e:void 0}function Ge(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function Ue(e){const t=Ge(e);return null==t?void 0:Math.max(0,Math.floor(t))}function Ke(...e){return e.map(qe).find(Boolean)}function Je(...e){return e.find(Array.isArray)}function We(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t}function Qe(e,t,n){return e["string"==typeof t&&t?t:n]}function Xe(e){return e instanceof Date?e.toISOString():"number"==typeof e?Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+"":(e??"—")+""}function Ye(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function Ze(e){return Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+""}function et(e,t,n){const r=e?.filter(e=>!0===qe(e)?.sensor).length,o=qe(t?.observation),a=qe(o?.sensors),i=Je(n?.activeSensors);return Math.max(r??0,a?Object.keys(a).length:0,i?.length??0)||void 0}function tt(e,t,n={}){const{capability:r,audience:o,locale:a}=n,i=n.levels??["l1","l2","l3"],s=!1!==n.includeStructure,l=ge(e,r),c=xe(e,t,{levels:l?[...i,"l4"]:i,locale:a,capability:r,audience:o}),{l4:u,...d}=c.levels,f=["l1","l2","l3"].map(e=>c.levels[e]).filter(Boolean).join(" "),h={levels:d,text:c.annotations?`${c.annotations} ${f}`.trim():f,...c.annotations?{annotations:c.annotations}:{}};let m;if(l&&u){const e=(p=r)?"fits"in p||"buildProps"in p?{family:p.family}:{family:p.family,intentScores:p.intentScores}:{};m={act:l,sentence:u,family:e.family,intentScores:e.intentScores}}var p;const g=s?Ve(e,t,{maxLeaves:n.maxLeaves,locale:a}):void 0,y=function(e,t,n){if(!1===n)return;const r=He(n)?n:void 0,o=qe(t.physics),a=Ke(r?.snapshot,o?.snapshot,t.physicsSnapshot,function(e){const t=qe(e);return!!t&&(He(t.world)||"simulationState"in t||"liveBodyOrder"in t)}(t.snapshot)?t.snapshot:void 0),i=Ke(r?.evidence,o?.evidence,t.physicsEvidence,t.settledEvidence),s=Ke(r?.config,o?.config,a?.config,t.config),l=Ke(qe(a?.world),qe(o?.world)),c=Ke(qe(s?.kernel),qe(l?.options)),u=Je(l?.bodies),d=Je(l?.colliders,s?.colliders),f=Je(a?.queue,o?.queue),h=Je(a?.liveBodyOrder),m=Je(l?.springs),p=Je(a?.activeSensorPairs),g=function(e){if(!e||0===e.length)return;const t=e.map((e,t)=>{const n=qe(e);if(!n)return;const r=Ge(n.count??n.value??n.total??n.bodies??n.events);if(null==r)return;const o=(n.label??n.id??n.name??"container "+(t+1))+"",a=null==n.id?void 0:n.id+"",i=Ge(n.secondary??n.secondaryCount),s=Ge(n.observed??n.observedCount);return We({id:a,label:o,count:r,secondary:i,secondaryLabel:"string"==typeof n.secondaryLabel?n.secondaryLabel:void 0,observed:s})}).filter(e=>null!=e);if(0===t.length)return;const n=t.reduce((e,t)=>e+t.count,0),r=t.filter(e=>e.count>0).length,o=t.slice().sort((e,t)=>t.count-e.count)[0];return{rows:t,totalCount:n,populatedCount:r,...o?{leader:o}:{}}}(function(e,t,n,r){const o=qe(e.settledProjection),a=qe(t?.settledProjection);return Je(n?.projectionRows,n?.aggregates,e.settledProjectionRows,e.projectionRows,o?.rows,t?.settledProjectionRows,t?.projectionRows,a?.rows,r?.binCounts)}(t,o,r,i)),y=function(e,t){const n=e?.map((e,t)=>{const n=qe(e);if(!n)return;const r=Ge(n.count)??0,o=Ge(n.total),a={label:(n.label??n.id??"sediment "+(t+1))+"",count:r};return null!=n.id&&(a.id=n.id+""),null!=o&&(a.total=o),a}).filter(e=>null!=e),r=Ue(t?.bins)??n?.length??0,o=Ge(t?.count)??n?.reduce((e,t)=>e+t.count,0)??0,a=Ge(t?.total)??n?.reduce((e,t)=>e+(t.total??0),0),i=n?.slice().sort((e,t)=>t.count-e.count)[0];if(0!==r||0!==o||a)return{bins:r,count:o,...null!=a&&a>0?{total:a}:{},...i?{leader:i}:{}}}(Je(r?.sediment,o?.sediment,a?.sediment),Ke(r?.sedimentTotals,o?.sedimentTotals)),b=h?.length??u?.length??Ue(i?.bodyCount),v=function(e){if(e)return e.filter(e=>!0===qe(e)?.sleeping).length}(u)??Ue(i?.sleepingCount),$=f?.length,w="string"==typeof a?.simulationState?a.simulationState:void 0,C="boolean"==typeof i?.settled?i.settled:w?"settled"===w:null!=b||null!=v||null!=$?null!=b&&v===b&&0===($??0):void 0,A=qe(c?.gravity),k=Ge(A?.x),S=Ge(A?.y),x=We({state:w,settled:C,elapsedSeconds:Ge(a?.elapsedSeconds),paused:"boolean"==typeof a?.paused?a.paused:void 0,visible:"boolean"==typeof a?.visible?a.visible:void 0,seed:Ge(c?.seed),gravity:null!=k&&null!=S?{x:k,y:S}:void 0,fixedDt:Ge(s?.fixedDt??c?.fixedDt),timeScale:Ge(s?.timeScale),maxSubsteps:Ue(s?.maxSubsteps),liveBodies:b,sleepingBodies:v,queued:$,bodyLimit:Ge(s?.bodyLimit),eviction:"string"==typeof s?.eviction?s.eviction:void 0}),j=We({colliders:d?.length,sensors:et(d,s,l),springs:m?.length,activeSensorPairs:p?.length}),I=Object.keys(j).length>0,P=ze.has(e);if(!(Object.keys(x).length>0||I||g||y)||!P&&null==n)return;const O={simulation:x,...I?{geometry:j}:{},...g?{aggregates:g}:{},...y?{sediment:y}:{}},R=function(e){const t=[],n=e.simulation,r=[n.state??(n.settled?"settled":void 0),null!=n.liveBodies?`${n.liveBodies} live ${Ye(n.liveBodies,"body")}`:void 0,null!=n.sleepingBodies?n.sleepingBodies+" sleeping":void 0,null!=n.queued?n.queued+" queued":void 0,null!=n.seed?"seed "+Ze(n.seed):void 0,n.gravity?`gravity (${Ze(n.gravity.x)}, ${Ze(n.gravity.y)})`:void 0,null!=n.fixedDt?`fixed step ${Ze(n.fixedDt)}s`:void 0,null!=n.timeScale?Ze(n.timeScale)+"x time":void 0].filter(Boolean);r.length>0&&t.push(`Physics simulation: ${r.join("; ")}.`);const o=e.geometry;if(o){const e=[null!=o.colliders?`${o.colliders} ${Ye(o.colliders,"collider")}`:void 0,null!=o.sensors?`${o.sensors} ${Ye(o.sensors,"sensor")}`:void 0,null!=o.springs?`${o.springs} ${Ye(o.springs,"spring")}`:void 0,null!=o.activeSensorPairs?`${o.activeSensorPairs} active sensor ${Ye(o.activeSensorPairs,"pair")}`:void 0].filter(Boolean);e.length>0&&t.push(`Physics geometry: ${e.join("; ")}.`)}const a=e.aggregates;if(a){const e=a.leader,n=e?` Largest is ${e.label} with ${Ze(e.count)}.`:"";t.push(`Physics aggregates: ${Ze(a.totalCount)} settled ${Ye(a.totalCount,"body")} across ${a.rows.length} ${Ye(a.rows.length,"container")}; ${a.populatedCount} populated.${n}`)}const i=e.sediment;if(i){const e=null!=i.total?", value total "+Ze(i.total):"",n=i.leader?`; largest sediment bin is ${i.leader.label} with ${Ze(i.leader.count)}`:"";t.push(`Physics sediment: ${i.count} retained ${Ye(i.count,"body")} in ${i.bins} ${Ye(i.bins,"bin")}${e}${n}.`)}return t.join(" ")}(O);return{...O,text:R}}(e,t,n.physics),b=function(e,t,n){const r=[];if("GaugeChart"===e){"number"==typeof t.value&&Number.isFinite(t.value)&&r.push(`Current value is ${Xe(t.value)}.`);const e="number"==typeof t.min&&Number.isFinite(t.min)?t.min:0,n="number"==typeof t.max&&Number.isFinite(t.max)?t.max:100;r.push(`The gauge scale runs from ${Xe(e)} to ${Xe(n)}.`)}if("SankeyDiagram"===e||"ProcessSankey"===e){const o=Array.isArray(t.edges)?t.edges:[];if("ProcessSankey"===e&&Array.isArray(t.domain)&&2===t.domain.length&&r.push(`The ProcessSankey time domain runs from ${Xe(t.domain[0])} to ${Xe(t.domain[1])}.`),o.length>0){r.push(`${o.length} source flow${1===o.length?"":"s"} are supplied.`);for(const a of o.slice(0,n)){const n=Qe(a,t.sourceAccessor,"source"),o=Qe(a,t.targetAccessor,"target"),i=Qe(a,t.valueAccessor,"value");r.push("ProcessSankey"!==e||null==a.startTime&&null==a.endTime?`${Xe(n)} to ${Xe(o)} has value ${Xe(i)}.`:`${Xe(n)} to ${Xe(o)} has value ${Xe(i)} over ${Xe(a.startTime)}–${Xe(a.endTime)}.`)}}}if("Treemap"===e||"CirclePack"===e||"TreeDiagram"===e||"OrbitDiagram"===e){const e=qe(t.data),o="string"==typeof t.childrenAccessor&&t.childrenAccessor?t.childrenAccessor:"children",a="string"==typeof t.valueAccessor&&t.valueAccessor?t.valueAccessor:"value",i="string"==typeof t.nodeIdAccessor&&t.nodeIdAccessor?t.nodeIdAccessor:"string"==typeof t.nodeIDAccessor&&t.nodeIDAccessor?t.nodeIDAccessor:"name",s=[],l=e=>{const t=Array.isArray(e[o])?e[o]:[];if(0!==t.length)for(const e of t){const t=qe(e);t&&l(t)}else s.push(e)};if(e&&l(e),s.length>0){r.push(s.length+" hierarchy leaves are supplied.");for(const e of s.slice(0,n))r.push(`${Xe(e[i])} has value ${Xe(e[a])}.`)}}if(ze.has(e)&&Array.isArray(t.data)){const n=t.data;r.push(`${n.length} observed source row${1===n.length?"":"s"} are supplied.`);const o="CollisionSwarmChart"===e?t.xAccessor:t.valueAccessor,a="CollisionSwarmChart"===e?"x":"value",i=n.map(e=>Ge(Qe(e,o,a))).filter(e=>null!=e);i.length>0&&r.push(`Observed ${"string"==typeof o?o:a} ranges from ${Xe(Math.min(...i))} to ${Xe(Math.max(...i))}.`)}if(0!==r.length)return{source:"chart-props",statements:r,text:"Exact chart-prop facts: "+r.join(" ")}}(e,t,Math.max(1,n.maxLeaves??200)),v=[h.text,m?.sentence,y?.text,b?.text].filter(Boolean).join(" ");return{component:e,description:h,intent:m,structure:g,physics:y,facts:b,text:v}}var nt=["data","nodes","edges","points","areas","lines","flows"],rt=[["xAccessor","x"],["yAccessor","y"],["categoryAccessor","category"],["valueAccessor","value"],["colorBy","color"],["sizeAccessor","size"],["lineBy","series"],["groupAccessor","group"],["oAccessor","ordinal"],["rAccessor","radial"],["sourceAccessor","source"],["targetAccessor","target"],["nodeIDAccessor","id"]],ot=1;function at(e,t){const n=e.trim();if(!n)throw Error(t+" must be a non-empty string.");return encodeURIComponent(n)}function it(e,...t){return`${e}/${t.map(e=>at(e,"VACP ref segment")).join("/")}`}function st(e){const t=e.now?.()??new Date,n=t instanceof Date?t:new Date(t);if(!Number.isFinite(n.getTime()))throw Error("VACP bridge clock returned an invalid date.");return n.toISOString()}function lt(e){try{const{createdAt:t,...n}=function(e,t,n){const r=F(e)??L(t.recipe)??L(t.recipeId);if(r)return function(e,t,n){const r=function(e,t,n){const r={};for(const[o,a]of Object.entries(e))if(null!=a&&!G.has(o)&&"recipeId"!==o&&(t||!J(o,a)))if("function"==typeof a||a?.$$typeof){if(n)throw Error(`Portable recipe prop "${o}" is not JSON-safe.`)}else if(D(a))r[o]=W(a);else if(n)throw Error(`Portable recipe prop "${o}" is not JSON-safe.`);return r}(t,!1!==n?.includeData,"portable"===e.portability),o=e.intents.map(N).filter(e=>!!e),a={name:e.name,intents:o,...e.audience?.primary?{audience:[e.audience.primary]}:{},frameFamily:e.frameFamily};if("portable"===e.portability){if(!D(r))throw Error(`Portable recipe "${e.id}" contains non-JSON-safe props or layoutConfig.`);return{component:"ChartRecipe",recipeId:e.id,portable:!0,props:r,manifest:a,version:q,createdAt:(new Date).toISOString(),...n?.selections?{selections:n.selections}:{}}}return{component:"ChartRecipe",recipeId:e.id,portable:!1,reason:"Recipe contains or may depend on non-serializable local layout callbacks.",warnings:["This config is inspectable but cannot be rendered remotely by CLI or MCP."],props:r,manifest:a,version:q,createdAt:(new Date).toISOString(),...n?.selections?{selections:n.selections}:{}}}(r,t,n);if(!function(e){return R.has(e)}(e))throw Error(`Unknown component "${e}". Known components: ${O.join(", ")}`);const o=!1!==n?.includeData,a={};for(const[e,n]of Object.entries(t))if(null!=n&&!G.has(e)&&(o||!J(e,n))&&"function"!=typeof n&&!n?.$$typeof)try{a[e]=W(K(n))}catch{}return{component:e,props:a,version:q,createdAt:(new Date).toISOString(),...n?.selections?{selections:n.selections}:{}}}(e.component,e.props,{includeData:!1});return l(n)}catch(t){const n=Object.create(null);for(const[t,r]of Object.entries(e.props)){if(nt.includes(t)||"function"==typeof r)continue;const e=s(r);void 0!==e&&(n[t]=e)}return{component:e.component,props:n,version:"unregistered",warning:t instanceof Error?t.message:"Chart config could not be serialized by toConfig."}}}function ct(e){return tt(e.component,e.props,{...e.grounding,audience:e.audience,includeStructure:!0,maxLeaves:ot})}function ut(e,t){const n=[];for(const r of nt){const o=e.props[r];Array.isArray(o)&&n.push({ref:t.data(e.chartId,r),chartId:e.chartId,collection:r,rows:o})}return n}function dt(e,t){t(e);for(const n of e.children??[])dt(n,t)}function ft(e,t){if(!t)return;let n;return dt(e,e=>{n||e.id!==t||(n=e)}),n}function ht(e){return null==e||"string"==typeof e||"number"==typeof e&&Number.isFinite(e)||"boolean"==typeof e||e instanceof Date&&Number.isFinite(e.getTime())}function mt(e,t){if("datum"!==e.role||!e.datum)return;const n=Object.create(null);for(const r of t){if(!Object.prototype.hasOwnProperty.call(e.datum,r)||!ht(e.datum[r]))return;n[r]=e.datum[r]instanceof Date?e.datum[r].toISOString():e.datum[r]}return n}function pt(e,t){const n=Array.from(new Set(e.matchFields.map(e=>e.trim()).filter(Boolean))),r=new Map;if(!n.length)return{valid:!1,diagnostic:"Navigation actions require at least one durable match field.",byKey:r,matchFields:n,targetRef:()=>it(t,"target","invalid")};let o,a=0,i=0,s=!1;return dt(e.tree,e=>{if("datum"!==e.role)return;a++;const t=mt(e,n);if(!t)return void i++;const o=d(t);r.has(o)?s=!0:r.set(o,e)}),a?i?o=i+" navigation leaves lack durable primitive match-field values.":s&&(o="Navigation match fields do not uniquely identify every datum leaf."):o="Navigation tree has no datum leaves.",{valid:!o,...o?{diagnostic:o}:{},byKey:r,matchFields:n,targetRef:e=>it(t,"target",d(e))}}function gt(e,t){const{chart:n,ref:r,configRef:o,grounding:a}=e,s=[{ref:r,kind:"Visualization",layer:"VisualizationLayer",title:n.title??(n.props.title??n.component)+"",description:n.description??a.text,data:l({component:n.component,grounding:{description:a.description,intent:a.intent,physics:a.physics,text:a.text},audience:n.audience})},{ref:o,kind:"Param",layer:"ConfigLayer",title:n.component+" configuration",description:"Serializable Semiotic chart configuration with raw data collections omitted.",data:e.config}],c=[{from:e.ref,to:o,kind:"contains"}],u=(a.structure?.children??[]).filter(e=>"axis"===e.role).map(e=>e.label);let d=0;for(const[e,t]of rt){const o=n.props[e];if("string"!=typeof o||!o.trim())continue;const a=it(r,"encoding",t);if(s.push({ref:a,kind:"EncodingChannel",layer:"VisualizationLayer",title:`${t} → ${o}`,data:{channel:t,field:o,accessorProp:e}}),c.push({from:r,to:a,kind:"contains"}),"x"===t||"y"===t||"category"===t||"value"===t||"ordinal"===t||"radial"===t){const e=it(r,"axis",t);s.push({ref:e,kind:"Axis",layer:"VisualizationLayer",title:u[d++]??`${t} axis: ${o}`,data:{channel:t,field:o}}),c.push({from:r,to:e,kind:"contains"}),c.push({from:e,to:a,kind:"derivedFrom"})}}for(const o of e.dataHandles)s.push({ref:o.ref,kind:"DataHandle",layer:"DataLayer",title:`${n.chartId}.${o.collection}`,description:"Bounded details-on-demand handle. Use vacp.data_schema before requesting an opt-in sample.",data:{collection:o.collection,rowCount:o.rows.length,schemaAction:A,...t.dataAccess?.sample?{inspectAction:w}:{}}}),c.push({from:r,to:o.ref,kind:"contains"});if(e.navigation){const{navigation:t}=e;s.push({ref:t.ref,kind:"Selection",layer:"InteractionFeedbackLayer",title:(n.title??n.component)+" structured navigation",description:t.index.diagnostic??"Active accessible-navigation target identified by durable datum fields.",data:{matchFields:t.index.matchFields,targetCount:t.index.byKey.size,status:t.index.valid?t.binding.onActiveChange?"actionable":"read-only":"ambiguous"}}),c.push({from:r,to:t.ref,kind:"contains"})}if(t.getObservations){const e=it(r,"interaction","latest-observation");s.push({ref:e,kind:"InteractionTarget",layer:"InteractionFeedbackLayer",title:(n.title??n.component)+" latest observation",description:"Latest semantic hover, focus, selection, brush, activation, or control observation."}),c.push({from:r,to:e,kind:"contains"})}const f=Array.isArray(n.props.annotations)?n.props.annotations:[],h=new Set;for(const e of f){if(!i(e))continue;const t=i(e.provenance)?e.provenance:void 0,o=e.id??e.stableId??t?.stableId,a=null==o||""===o?void 0:o+"";if(!a)continue;const u=i(e.note)?e.note:void 0,d=i(e.noteData)?e.noteData:void 0,f=it(r,"annotation",a);if(h.has(f))throw Error(`Duplicate stable annotation id "${a.trim()}" in VACP chart "${n.chartId}".`);h.add(f),s.push({ref:f,kind:"InteractionTarget",layer:"VisualizationLayer",title:(e.label??u?.label??d?.label??"Annotation "+a)+"",description:"string"==typeof e.note?e.note:"string"==typeof e.description?e.description:void 0,data:l({id:a,provenance:t,lifecycle:e.lifecycle})}),c.push({from:r,to:f,kind:"contains"})}return{nodes:s,edges:c}}function yt(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if(r.chartId===t)return r}}function bt(e,t){const n=function(e,t){const n=function(e){const t="function"==typeof e?e():e,n=new Set;for(const e of t){const t=e.chartId.trim();if(!t)throw Error("Every VACP chart requires a non-empty chartId.");if(n.has(t))throw Error(`Duplicate VACP chartId "${t}".`);n.add(t)}return t}(e.charts),r=n.map(e=>{const n=t.visualization(e.chartId),r=e.navigation?{ref:t.navigation(e.chartId),chartRef:n,chartId:e.chartId,binding:e.navigation,index:pt(e.navigation,t.navigation(e.chartId))}:void 0;return{chart:e,ref:n,configRef:t.config(e.chartId),grounding:ct(e),config:lt(e),dataHandles:ut(e,t),...r?{navigation:r}:{}}}),o=function(e,t){const n=new Map;for(const t of e)for(const e of t.chart.selections??[]){const r=e.name.trim();if(!r)throw Error("VACP selection names must be non-empty.");const o=n.get(r)??{fields:new Set,modes:new Set,chartRefs:new Set};for(const t of e.fields.map(e=>e.trim()))t&&o.fields.add(t);if("interval"!==e.mode&&o.modes.add("point"),"point"!==e.mode&&o.modes.add("interval"),e.clientId){if(o.clientId&&o.clientId!==e.clientId)throw Error(`Selection "${r}" declares conflicting VACP clientIds.`);o.clientId=e.clientId}o.chartRefs.add(t.ref),n.set(r,o)}return Array.from(n).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>{if(0===n.fields.size)throw Error(`Selection "${e}" requires at least one allowlisted field.`);return{ref:t.selection(e),name:e,fields:Array.from(n.fields).sort(),modes:n.modes,clientId:n.clientId??"__semiotic-vacp__:"+e,chartRefs:Array.from(n.chartRefs)}})}(r,t),a=r.flatMap(e=>e.dataHandles),i=[{ref:t.app,kind:"App",layer:"ViewLayer",title:e.title??e.appId,description:"Semiotic application state exposed through the experimental VACP 0.1.0 bridge.",data:{provider:"semiotic",protocol:C}},{ref:t.view,kind:"View",layer:"ViewLayer",title:e.title??e.viewId??"Semiotic charts"}],s=[{from:t.app,to:t.view,kind:"contains"}];for(const n of r){const r=gt(n,e);i.push(...r.nodes),s.push(...r.edges),s.push({from:t.view,to:n.ref,kind:"contains"})}for(const e of o){i.push({ref:e.ref,kind:"Selection",layer:"InteractionFeedbackLayer",title:"Selection: "+e.name,description:"Named LinkedCharts selection. Agent mutations are restricted to declared fields and modes.",data:{name:e.name,fields:e.fields,modes:Array.from(e.modes).sort()}}),s.push({from:t.view,to:e.ref,kind:"contains"});for(const t of e.chartRefs)s.push({from:e.ref,to:t,kind:"controls"})}return{charts:r,selections:o,dataHandles:a,nodes:i,edges:s}}(e,t);return{...n,actions:P(n,e,t)}}function vt(e){const t=e.viewId?.trim()||"main",n=function(e,t){const n="vacp://"+at(e,"appId"),r=it(n,"view",t),o=e=>it(r,"visualization",e);return{app:n,view:r,visualization:o,config:e=>it(o(e),"config"),data:(e,t="data")=>it(o(e),"data",t),selection:e=>it(r,"selection",e),navigation:e=>it(o(e),"navigation"),observation:e=>it(o(e),"interaction","latest-observation")}}(e.appId,t),r="number"==typeof e.stateCacheSize&&Number.isFinite(e.stateCacheSize)?Math.max(1,Math.floor(e.stateCacheSize)):64,o=new Map;return{version:C,refs:n,getCapabilities:t=>{const r=bt(e,n),o={version:C,createdAt:st(e),graph:{version:C,nodes:r.nodes,edges:r.edges,actions:r.actions.map(e=>e.descriptor)}};return t?function(e,t){const n=function(e){return{refs:f(e.refs),prefixes:f(e.prefixes),kinds:e.kinds?.length?new Set(e.kinds):void 0,layers:e.layers?.length?new Set(e.layers):void 0,includeActions:!1!==e.includeActions,includeEdges:!1!==e.includeEdges,includeNodeData:!1!==e.includeNodeData}}(t),r=e.graph.nodes.filter(e=>function(e,t){return!((t.refs?.length||t.prefixes?.length)&&!t.refs?.includes(e.ref)&&!t.prefixes?.some(t=>e.ref===t||e.ref.startsWith(t+"/")))&&(!t.kinds||t.kinds.has(e.kind))&&(!t.layers||t.layers.has(e.layer))}(e,n)).map(e=>{if(n.includeNodeData)return e;const{data:t,...r}=e;return r}),o=new Set(r.map(e=>e.ref)),a=n.includeActions?e.graph.actions.filter(e=>{if(!e.targetRef)return!0;if(o.has(e.targetRef))return!0;for(const t of o)if(t.startsWith(e.targetRef+"/"))return!0;return!1}):[];return{version:e.version,createdAt:e.createdAt,graph:{version:e.graph.version,nodes:r,edges:n.includeEdges?e.graph.edges.filter(e=>o.has(e.from)&&o.has(e.to)):[],actions:a}}}(o,t):o},getState:async function(t){const a=function(e,t,n){const r={},o={},a=t.getSelections?.()??{},i=t.getObservations?.()??[];for(const a of e.charts){r[a.ref]=l({component:a.chart.component,description:a.grounding.description,intent:a.grounding.intent,physics:a.grounding.physics,audience:a.chart.audience}),r[a.configRef]=a.config,o[a.ref]={component:a.chart.component,dataHandles:a.dataHandles.length};for(const e of a.dataHandles)r[e.ref]={kind:"DataHandle",collection:e.collection,rowCount:e.rows.length},o[e.ref]={rowCount:e.rows.length};if(a.navigation){const e=ft(a.navigation.binding.tree,a.navigation.binding.activeId),t=e?mt(e,a.navigation.index.matchFields):void 0;r[a.navigation.ref]=l({kind:"Selection",status:a.navigation.index.valid?"ready":"ambiguous",activeRole:e?.role,activeLabel:e?.label,activeMatch:t,activeTargetRef:t?a.navigation.index.targetRef(t):void 0,diagnostic:a.navigation.index.diagnostic}),o[a.navigation.ref]={targetCount:a.navigation.index.byKey.size}}if(t.getObservations){const e=yt(i,a.chart.chartId);r[n.observation(a.chart.chartId)]=e?l(e):null,e&&(o[n.observation(a.chart.chartId)]={type:e.type,timestamp:e.timestamp})}}for(const t of e.selections){const e=a[t.name];r[t.ref]=(e?l(e):void 0)??{name:t.name,resolution:"union",clauses:[]},o[t.ref]={active:!!e?.clauses.length,clauseCount:e?.clauses.length??0,fields:t.fields}}return{version:C,createdAt:st(t),state:r,...Object.keys(o).length?{summary:o}:{}}}(bt(e,n),e,n);if(!t)return a;const{snapshot:i,refs:s}=m(a,t),c="st_"+d({state:(u=i).state,...u.summary?{summary:u.summary}:{}});var u;const f=t.since?o.get(t.since):void 0;let h;if("full"!==t.mode&&t.since&&f){const e=m(f,t).snapshot;h={version:C,createdAt:i.createdAt,mode:"delta",token:c,baseToken:t.since,...s?{scope:{refs:s}}:{},delta:p(e,i)}}else h={version:C,createdAt:i.createdAt,mode:"full",token:c,...s?{scope:{refs:s}}:{},snapshot:i};return((e,t)=>{for(o.has(e)&&o.delete(e),o.set(e,t);o.size>r;){const e=o.keys().next().value;if("string"!=typeof e)break;o.delete(e)}})(c,a),h},execute:async t=>{const r=t&&"string"==typeof t.callId?t.callId:"";try{if(!t||"string"!=typeof t.name||!t.name.trim())throw Error("VACP action call requires a non-empty name.");if(!r)throw Error("VACP action call requires a callId.");const o=bt(e,n),a=o.actions.find(e=>e.descriptor.name===t.name);if(!a)return{callId:r,ok:!1,error:{message:`Unknown or currently unavailable VACP action "${t.name}".`,details:{available:o.actions.map(e=>e.descriptor.name)}}};const i=s(await a.execute(t.params));return{callId:r,ok:!0,...void 0!==i?{result:i}:{}}}catch(e){return{callId:r,ok:!1,error:{message:e instanceof Error?e.message:"VACP action failed."}}}}}}function $t(e,t={}){const n=t.globalKey?.trim()||"__vacp",r=t.target??("undefined"!=typeof window?window:void 0);if(!r)return{installed:!1,globalKey:n,bridge:e,reason:`Refused to install "${n}" without a browser window or an explicit target.`,cleanup:()=>!1};if("__proto__"===n||"prototype"===n||"constructor"===n)return{installed:!1,globalKey:n,bridge:e,reason:`Refused unsafe global key "${n}".`,cleanup:()=>!1};const o=r[n];if(void 0!==o&&o!==e)return{installed:!1,globalKey:n,bridge:e,reason:`Refused to replace existing global "${n}".`,cleanup:()=>!1};try{r[n]=e}catch(t){return{installed:!1,globalKey:n,bridge:e,reason:t instanceof Error?`Could not install "${n}": ${t.message}`:`Could not install "${n}".`,cleanup:()=>!1}}return{installed:!0,globalKey:n,bridge:e,cleanup:()=>{if(r[n]!==e)return!1;try{return delete r[n]}catch{return!1}}}}