semiotic 3.7.4 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (517) hide show
  1. package/CLAUDE.md +60 -15
  2. package/README.md +135 -24
  3. package/agent-skill/semiotic-charts/SKILL.md +146 -0
  4. package/ai/cli.js +133 -45
  5. package/ai/componentMetadata.cjs +6 -1
  6. package/ai/dist/mcp-server.js +1651 -154
  7. package/ai/examples.md +174 -0
  8. package/ai/schema.json +2934 -517
  9. package/ai/surface-manifest.json +200 -0
  10. package/ai/system-prompt.md +19 -3
  11. package/dist/components/Annotation.d.ts +4 -0
  12. package/dist/components/CategoryColors.d.ts +1 -1
  13. package/dist/components/ChartContainer.d.ts +91 -0
  14. package/dist/components/ChartGrid.d.ts +11 -1
  15. package/dist/components/CircularBrush.d.ts +61 -0
  16. package/dist/components/ContextLayout.d.ts +5 -1
  17. package/dist/components/DataSummaryContext.d.ts +1 -0
  18. package/dist/components/DirectManipulationControl.d.ts +63 -0
  19. package/dist/components/LinkedCharts.d.ts +3 -1
  20. package/dist/components/MobileAnnotationCalloutList.d.ts +13 -0
  21. package/dist/components/MobileChartContainer.d.ts +51 -0
  22. package/dist/components/MobileStandardControls.d.ts +68 -0
  23. package/dist/components/SmallMultipleChart.d.ts +84 -0
  24. package/dist/components/Tooltip/FlippingTooltip.d.ts +21 -0
  25. package/dist/components/ai/ChartRecipe.d.ts +16 -0
  26. package/dist/components/ai/IntentMark.d.ts +15 -0
  27. package/dist/components/ai/chartCapabilities.d.ts +8 -1
  28. package/dist/components/ai/chartCapabilityTypes.d.ts +42 -1
  29. package/dist/components/ai/chartClinic.d.ts +91 -0
  30. package/dist/components/ai/chartRecipeRegistry.d.ts +14 -0
  31. package/dist/components/ai/chartRecipes.d.ts +278 -0
  32. package/dist/components/ai/dataPitfallsBridge.d.ts +203 -0
  33. package/dist/components/ai/dataQualityBridge.d.ts +201 -0
  34. package/dist/components/ai/describeChart.d.ts +9 -0
  35. package/dist/components/ai/describeRecipeChart.d.ts +16 -0
  36. package/dist/components/ai/generativeChart.d.ts +170 -0
  37. package/dist/components/ai/intentManifest.d.ts +62 -0
  38. package/dist/components/ai/navigationTree.d.ts +3 -0
  39. package/dist/components/ai/observedSceneAudit.d.ts +72 -0
  40. package/dist/components/ai/readerGrounding.d.ts +83 -0
  41. package/dist/components/ai/recipeCapability.d.ts +8 -0
  42. package/dist/components/ai/recipeNavigation.d.ts +13 -0
  43. package/dist/components/ai/recipeSemantics.d.ts +11 -0
  44. package/dist/components/ai/repairChartConfig.d.ts +9 -0
  45. package/dist/components/ai/suggestCharts.d.ts +11 -1
  46. package/dist/components/charts/custom/GeoCustomChart.d.ts +48 -0
  47. package/dist/components/charts/custom/NetworkCustomChart.d.ts +22 -3
  48. package/dist/components/charts/custom/OrdinalCustomChart.d.ts +8 -2
  49. package/dist/components/charts/custom/XYCustomChart.d.ts +11 -2
  50. package/dist/components/charts/geo/DistanceCartogram.d.ts +1 -1
  51. package/dist/components/charts/geo/FlowMap.d.ts +1 -1
  52. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +1 -1
  53. package/dist/components/charts/geo/index.d.ts +2 -0
  54. package/dist/components/charts/index.d.ts +29 -1
  55. package/dist/components/charts/network/ChordDiagram.d.ts +1 -1
  56. package/dist/components/charts/network/CirclePack.d.ts +1 -1
  57. package/dist/components/charts/network/ForceDirectedGraph.d.ts +15 -5
  58. package/dist/components/charts/network/OrbitDiagram.d.ts +1 -1
  59. package/dist/components/charts/network/ProcessSankey.d.ts +1 -1
  60. package/dist/components/charts/network/SankeyDiagram.d.ts +1 -1
  61. package/dist/components/charts/network/TreeDiagram.d.ts +1 -1
  62. package/dist/components/charts/network/Treemap.d.ts +1 -1
  63. package/dist/components/charts/network/useForceLayout.d.ts +17 -0
  64. package/dist/components/charts/ordinal/BarChart.d.ts +1 -1
  65. package/dist/components/charts/ordinal/BoxPlot.d.ts +1 -1
  66. package/dist/components/charts/ordinal/DonutChart.d.ts +1 -1
  67. package/dist/components/charts/ordinal/DotPlot.d.ts +1 -1
  68. package/dist/components/charts/ordinal/FunnelChart.d.ts +1 -1
  69. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +1 -1
  70. package/dist/components/charts/ordinal/Histogram.d.ts +1 -1
  71. package/dist/components/charts/ordinal/PieChart.d.ts +1 -1
  72. package/dist/components/charts/ordinal/RidgelinePlot.d.ts +1 -1
  73. package/dist/components/charts/ordinal/StackedBarChart.d.ts +1 -1
  74. package/dist/components/charts/ordinal/SwarmPlot.d.ts +8 -1
  75. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +1 -1
  76. package/dist/components/charts/ordinal/ViolinPlot.d.ts +1 -1
  77. package/dist/components/charts/physics/ChainReactionChart.d.ts +9 -0
  78. package/dist/components/charts/physics/CollisionSwarmChart.capability.d.ts +2 -0
  79. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +47 -0
  80. package/dist/components/charts/physics/EventDropChart.capability.d.ts +2 -0
  81. package/dist/components/charts/physics/EventDropChart.d.ts +53 -0
  82. package/dist/components/charts/physics/GaltonBoardChart.capability.d.ts +2 -0
  83. package/dist/components/charts/physics/GaltonBoardChart.d.ts +66 -0
  84. package/dist/components/charts/physics/GauntletChart.capability.d.ts +2 -0
  85. package/dist/components/charts/physics/GauntletChart.d.ts +73 -0
  86. package/dist/components/charts/physics/PhysicalFlowChart.capability.d.ts +2 -0
  87. package/dist/components/charts/physics/PhysicalFlowChart.d.ts +63 -0
  88. package/dist/components/charts/physics/PhysicsCustomChart.d.ts +120 -0
  89. package/dist/components/charts/physics/PhysicsPileChart.capability.d.ts +2 -0
  90. package/dist/components/charts/physics/PhysicsPileChart.d.ts +53 -0
  91. package/dist/components/charts/physics/ProcessFlowChart.capability.d.ts +2 -0
  92. package/dist/components/charts/physics/ProcessFlowChart.d.ts +96 -0
  93. package/dist/components/charts/physics/chainReactionOverlay.d.ts +22 -0
  94. package/dist/components/charts/physics/chainReactionRuntime.d.ts +37 -0
  95. package/dist/components/charts/physics/chainReactionTypes.d.ts +97 -0
  96. package/dist/components/charts/physics/collisionSwarmPhysics.d.ts +27 -0
  97. package/dist/components/charts/physics/dependencyMachine.d.ts +188 -0
  98. package/dist/components/charts/physics/eventDropPhysics.d.ts +64 -0
  99. package/dist/components/charts/physics/galtonBoardPhysics.d.ts +28 -0
  100. package/dist/components/charts/physics/gauntletChartProps.d.ts +67 -0
  101. package/dist/components/charts/physics/gauntletChrome.d.ts +33 -0
  102. package/dist/components/charts/physics/gauntletController.d.ts +73 -0
  103. package/dist/components/charts/physics/gauntletEffects.d.ts +36 -0
  104. package/dist/components/charts/physics/gauntletPhysics.d.ts +71 -0
  105. package/dist/components/charts/physics/gauntletRuntime.d.ts +42 -0
  106. package/dist/components/charts/physics/gauntletTypes.d.ts +213 -0
  107. package/dist/components/charts/physics/physicalFlowPhysics.d.ts +57 -0
  108. package/dist/components/charts/physics/physicsChartShared.d.ts +41 -0
  109. package/dist/components/charts/physics/physicsChartUtils.d.ts +18 -0
  110. package/dist/components/charts/physics/physicsEncoding.d.ts +142 -0
  111. package/dist/components/charts/physics/physicsHocHandle.d.ts +53 -0
  112. package/dist/components/charts/physics/physicsHocUtils.d.ts +128 -0
  113. package/dist/components/charts/physics/physicsPilePhysics.d.ts +41 -0
  114. package/dist/components/charts/physics/physicsProcessPrimitives.d.ts +38 -0
  115. package/dist/components/charts/physics/processFlowPhysics.d.ts +97 -0
  116. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +9 -1
  117. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +9 -1
  118. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +30 -1
  119. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +16 -2
  120. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +9 -1
  121. package/dist/components/charts/realtime/aggregate.d.ts +51 -0
  122. package/dist/components/charts/realtime/eventTime.d.ts +26 -0
  123. package/dist/components/charts/shared/auditMobileVisualization.d.ts +91 -0
  124. package/dist/components/charts/shared/chartDefinitionPilot.d.ts +145 -0
  125. package/dist/components/charts/shared/chartFamilySets.d.ts +20 -0
  126. package/dist/components/charts/shared/chartSpecCore.d.ts +165 -0
  127. package/dist/components/charts/shared/chartSpecs.d.ts +8 -127
  128. package/dist/components/charts/shared/chartSpecsGeo.d.ts +2 -0
  129. package/dist/components/charts/shared/chartSpecsNetwork.d.ts +2 -0
  130. package/dist/components/charts/shared/chartSpecsOrdinal.d.ts +2 -0
  131. package/dist/components/charts/shared/chartSpecsPhysics.d.ts +2 -0
  132. package/dist/components/charts/shared/chartSpecsRealtime.d.ts +2 -0
  133. package/dist/components/charts/shared/chartSpecsValue.d.ts +2 -0
  134. package/dist/components/charts/shared/chartSpecsXY.d.ts +2 -0
  135. package/dist/components/charts/shared/colorContrast.d.ts +3 -0
  136. package/dist/components/charts/shared/colorPalettes.d.ts +2 -0
  137. package/dist/components/charts/shared/colorUtils.d.ts +17 -13
  138. package/dist/components/charts/shared/diagnoseAnnotationChecks.d.ts +4 -0
  139. package/dist/components/charts/shared/diagnoseConfig.d.ts +9 -14
  140. package/dist/components/charts/shared/diagnoseMisleadingChecks.d.ts +9 -0
  141. package/dist/components/charts/shared/diagnosePhysicsChecks.d.ts +3 -0
  142. package/dist/components/charts/shared/diagnoseTypes.d.ts +10 -0
  143. package/dist/components/charts/shared/hooks.d.ts +28 -5
  144. package/dist/components/charts/shared/minMax.d.ts +3 -0
  145. package/dist/components/charts/shared/motionEncoding.d.ts +145 -0
  146. package/dist/components/charts/shared/radialGeometry.d.ts +0 -18
  147. package/dist/components/charts/shared/responsiveRules.d.ts +56 -0
  148. package/dist/components/charts/shared/smartTooltip.d.ts +27 -0
  149. package/dist/components/charts/shared/statisticalOverlays.d.ts +35 -0
  150. package/dist/components/charts/shared/streamPropsHelpers.d.ts +12 -2
  151. package/dist/components/charts/shared/temporalStrings.d.ts +7 -0
  152. package/dist/components/charts/shared/tooltipUtils.d.ts +2 -0
  153. package/dist/components/charts/shared/types.d.ts +49 -1
  154. package/dist/components/charts/shared/useChartSetup.d.ts +10 -3
  155. package/dist/components/charts/shared/useCustomChartSetup.d.ts +15 -6
  156. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +6 -2
  157. package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +1 -1
  158. package/dist/components/charts/shared/useStreamingLegend.d.ts +1 -1
  159. package/dist/components/charts/shared/useSyncedPushData.d.ts +49 -0
  160. package/dist/components/charts/shared/validateChartData.d.ts +1 -1
  161. package/dist/components/charts/shared/validationMap.d.ts +0 -11
  162. package/dist/components/charts/xy/AreaChart.d.ts +1 -1
  163. package/dist/components/charts/xy/BubbleChart.d.ts +1 -1
  164. package/dist/components/charts/xy/LineChart.d.ts +1 -1
  165. package/dist/components/charts/xy/MinimapChart.d.ts +1 -1
  166. package/dist/components/charts/xy/MultiAxisLineChart.d.ts +2 -2
  167. package/dist/components/charts/xy/QuadrantChart.d.ts +1 -1
  168. package/dist/components/charts/xy/Scatterplot.d.ts +10 -1
  169. package/dist/components/charts/xy/ScatterplotMatrix.d.ts +11 -1
  170. package/dist/components/charts/xy/StackedAreaChart.d.ts +9 -4
  171. package/dist/components/controls/controlAudit.d.ts +24 -0
  172. package/dist/components/controls/controlContract.d.ts +57 -0
  173. package/dist/components/data/fromArrow.d.ts +54 -0
  174. package/dist/components/data/fromFlintChart.d.ts +74 -0
  175. package/dist/components/data/fromMermaid.d.ts +47 -0
  176. package/dist/components/data/fromObservablePlot.d.ts +69 -0
  177. package/dist/components/data/fromVegaLite.d.ts +27 -0
  178. package/dist/components/data/portability/index.d.ts +17 -0
  179. package/dist/components/data/portability/result.d.ts +52 -0
  180. package/dist/components/data/portability/spec.d.ts +160 -0
  181. package/dist/components/data/portability/vegaLite.d.ts +80 -0
  182. package/dist/components/export/chartConfig.d.ts +11 -0
  183. package/dist/components/realtime/ReorderBuffer.d.ts +54 -0
  184. package/dist/components/realtime/RunningStats.d.ts +66 -0
  185. package/dist/components/realtime/WindowAccumulator.d.ts +105 -0
  186. package/dist/components/realtime/parseWindowDuration.d.ts +12 -0
  187. package/dist/components/realtime/types.d.ts +11 -0
  188. package/dist/components/recipes/annotationLayout.d.ts +29 -0
  189. package/dist/components/recipes/axisFixedForce.d.ts +119 -0
  190. package/dist/components/recipes/boba.d.ts +23 -0
  191. package/dist/components/recipes/customTooltip.d.ts +31 -0
  192. package/dist/components/recipes/cyclical.d.ts +39 -0
  193. package/dist/components/recipes/edgeRouter.d.ts +103 -0
  194. package/dist/components/recipes/forceLayout.d.ts +48 -0
  195. package/dist/components/recipes/forceLayoutAsync.d.ts +17 -0
  196. package/dist/components/recipes/gofishBobaHandwritten.d.ts +3 -0
  197. package/dist/components/recipes/gofishDisplayListFixtures.generated.d.ts +37 -0
  198. package/dist/components/recipes/gofishIR.d.ts +215 -0
  199. package/dist/components/recipes/gofishIRExamples.d.ts +38 -0
  200. package/dist/components/recipes/intervalLanes.d.ts +87 -0
  201. package/dist/components/recipes/intervals.d.ts +80 -0
  202. package/dist/components/recipes/isometricLandmarks.d.ts +88 -0
  203. package/dist/components/recipes/isotypeGlyphs.d.ts +17 -0
  204. package/dist/components/recipes/mermaidDag.d.ts +44 -0
  205. package/dist/components/recipes/mobileAnnotationStrategy.d.ts +48 -0
  206. package/dist/components/recipes/mobileChartFamilyRecipes.d.ts +59 -0
  207. package/dist/components/recipes/networkAnalysis.d.ts +102 -0
  208. package/dist/components/recipes/networkLayouts.d.ts +83 -0
  209. package/dist/components/recipes/packedClusterMatrix.d.ts +166 -0
  210. package/dist/components/recipes/physics.d.ts +122 -0
  211. package/dist/components/recipes/physicsReference.d.ts +102 -0
  212. package/dist/components/recipes/processAggregates.d.ts +32 -0
  213. package/dist/components/recipes/processChrome.d.ts +67 -0
  214. package/dist/components/recipes/processJourney.d.ts +54 -0
  215. package/dist/components/recipes/processPhysics.d.ts +300 -0
  216. package/dist/components/recipes/processVolumeGeometry.d.ts +28 -0
  217. package/dist/components/recipes/radialCoords.d.ts +69 -0
  218. package/dist/components/recipes/random.d.ts +2 -0
  219. package/dist/components/recipes/recipeChrome.d.ts +191 -0
  220. package/dist/components/recipes/recipeGlyph.d.ts +42 -0
  221. package/dist/components/recipes/recipeLegend.d.ts +109 -0
  222. package/dist/components/recipes/recipeUtils.d.ts +157 -0
  223. package/dist/components/recipes/runs.d.ts +59 -0
  224. package/dist/components/recipes/tokenEncoding.d.ts +157 -0
  225. package/dist/components/recipes/tokenLayer.d.ts +79 -0
  226. package/dist/components/recipes/unitize.d.ts +108 -0
  227. package/dist/components/recipes/vector.d.ts +28 -0
  228. package/dist/components/recipes/waffle.d.ts +43 -0
  229. package/dist/components/semiotic-ai-core.d.ts +47 -0
  230. package/dist/components/semiotic-ai.d.ts +52 -4
  231. package/dist/components/semiotic-controls.d.ts +18 -0
  232. package/dist/components/semiotic-data.d.ts +2 -0
  233. package/dist/components/semiotic-experimental.d.ts +49 -0
  234. package/dist/components/semiotic-geo.d.ts +11 -0
  235. package/dist/components/semiotic-network.d.ts +14 -1
  236. package/dist/components/semiotic-ordinal.d.ts +10 -0
  237. package/dist/components/semiotic-physics-matter.d.ts +10 -0
  238. package/dist/components/semiotic-physics-rapier.d.ts +9 -0
  239. package/dist/components/semiotic-physics.d.ts +56 -0
  240. package/dist/components/semiotic-realtime-core.d.ts +34 -0
  241. package/dist/components/semiotic-realtime-react.d.ts +10 -0
  242. package/dist/components/semiotic-realtime.d.ts +4 -22
  243. package/dist/components/semiotic-recipes-core.d.ts +92 -0
  244. package/dist/components/semiotic-recipes-react.d.ts +7 -0
  245. package/dist/components/semiotic-recipes.d.ts +4 -26
  246. package/dist/components/semiotic-server-edge.d.ts +8 -0
  247. package/dist/components/semiotic-server-node.d.ts +5 -0
  248. package/dist/components/semiotic-server.d.ts +2 -2
  249. package/dist/components/semiotic-themes-core.d.ts +53 -0
  250. package/dist/components/semiotic-themes-react.d.ts +4 -0
  251. package/dist/components/semiotic-themes.d.ts +6 -74
  252. package/dist/components/semiotic-utils-core.d.ts +46 -0
  253. package/dist/components/semiotic-utils-react.d.ts +5 -0
  254. package/dist/components/semiotic-utils.d.ts +3 -39
  255. package/dist/components/semiotic-xy.d.ts +10 -0
  256. package/dist/components/semiotic.d.ts +39 -7
  257. package/dist/components/server/animatedGif.d.ts +36 -0
  258. package/dist/components/server/renderEvidence.d.ts +1 -1
  259. package/dist/components/server/renderToStaticSVG.d.ts +3 -35
  260. package/dist/components/server/serverChartConfigShared.d.ts +17 -0
  261. package/dist/components/server/serverChartConfigs.d.ts +19 -9
  262. package/dist/components/server/serverChartConfigsCustom.d.ts +5 -0
  263. package/dist/components/server/serverChartConfigsGeo.d.ts +9 -0
  264. package/dist/components/server/serverChartConfigsNetwork.d.ts +8 -0
  265. package/dist/components/server/serverChartConfigsOrdinal.d.ts +16 -0
  266. package/dist/components/server/serverChartConfigsPhysics.d.ts +9 -0
  267. package/dist/components/server/serverChartConfigsXY.d.ts +11 -0
  268. package/dist/components/server/staticGeo.d.ts +4 -0
  269. package/dist/components/server/staticLegend.d.ts +1 -1
  270. package/dist/components/server/staticNetwork.d.ts +8 -0
  271. package/dist/components/server/staticOrdinal.d.ts +11 -0
  272. package/dist/components/server/staticPhysics.d.ts +3 -0
  273. package/dist/components/server/staticSVGChrome.d.ts +110 -0
  274. package/dist/components/server/staticXY.d.ts +4 -0
  275. package/dist/components/store/ObservationStore.d.ts +23 -3
  276. package/dist/components/store/SelectionStore.d.ts +1 -1
  277. package/dist/components/store/ThemeStore.d.ts +1 -1
  278. package/dist/components/store/TooltipStore.d.ts +1 -1
  279. package/dist/components/store/createStore.d.ts +1 -1
  280. package/dist/components/store/designTokens.d.ts +15 -0
  281. package/dist/components/store/themeSerialization.d.ts +32 -0
  282. package/dist/components/store/useChartInterrogation.d.ts +9 -0
  283. package/dist/components/stream/AccessibleDataTable.d.ts +3 -13
  284. package/dist/components/stream/FocusRing.d.ts +4 -2
  285. package/dist/components/stream/GeoCanvasHitTester.d.ts +1 -1
  286. package/dist/components/stream/GeoPipelineStore.d.ts +28 -0
  287. package/dist/components/stream/NetworkHtmlMarksLayer.d.ts +44 -0
  288. package/dist/components/stream/NetworkPipelineStore.d.ts +62 -25
  289. package/dist/components/stream/NetworkSVGOverlay.d.ts +15 -0
  290. package/dist/components/stream/OrdinalPipelineStore.d.ts +64 -2
  291. package/dist/components/stream/PipelineStore.d.ts +100 -162
  292. package/dist/components/stream/SceneGraph.d.ts +14 -2
  293. package/dist/components/stream/StreamGeoFrame.d.ts +1 -1
  294. package/dist/components/stream/StreamNetworkFrame.d.ts +1 -1
  295. package/dist/components/stream/StreamOrdinalFrame.d.ts +1 -1
  296. package/dist/components/stream/StreamXYFrame.d.ts +2 -18
  297. package/dist/components/stream/accessibleDataRows.d.ts +33 -0
  298. package/dist/components/stream/accessorUtils.d.ts +23 -10
  299. package/dist/components/stream/brushAccessibility.d.ts +25 -0
  300. package/dist/components/stream/canvasBackground.d.ts +24 -0
  301. package/dist/components/stream/canvasSetup.d.ts +4 -1
  302. package/dist/components/stream/customLayout.d.ts +20 -0
  303. package/dist/components/stream/customLayoutDiagnostics.d.ts +11 -0
  304. package/dist/components/stream/customLayoutFailure.d.ts +33 -0
  305. package/dist/components/stream/customLayoutPalette.d.ts +19 -9
  306. package/dist/components/stream/customLayoutSelection.d.ts +52 -0
  307. package/dist/components/stream/frameThemeColors.d.ts +24 -0
  308. package/dist/components/stream/geoAnnotationAnchors.d.ts +14 -0
  309. package/dist/components/stream/geoCartogram.d.ts +17 -0
  310. package/dist/components/stream/geoCustomLayout.d.ts +59 -0
  311. package/dist/components/stream/geoDefaultTooltip.d.ts +11 -0
  312. package/dist/components/stream/geoFrameHelpers.d.ts +34 -0
  313. package/dist/components/stream/geoPipelineHelpers.d.ts +46 -0
  314. package/dist/components/stream/geoTypes.d.ts +56 -7
  315. package/dist/components/stream/glyphDef.d.ts +98 -0
  316. package/dist/components/stream/hitTarget.d.ts +170 -0
  317. package/dist/components/stream/hoverUtils.d.ts +3 -0
  318. package/dist/components/stream/keyboardNav.d.ts +4 -1
  319. package/dist/components/stream/layouts/forceLayoutPlugin.d.ts +9 -1
  320. package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +57 -0
  321. package/dist/components/stream/networkBezier.d.ts +10 -0
  322. package/dist/components/stream/networkColorAccessors.d.ts +49 -0
  323. package/dist/components/stream/networkCustomLayout.d.ts +66 -1
  324. package/dist/components/stream/networkDefaultTooltip.d.ts +10 -0
  325. package/dist/components/stream/networkFrameInteraction.d.ts +37 -0
  326. package/dist/components/stream/networkFramePaint.d.ts +43 -0
  327. package/dist/components/stream/networkPipelineConfig.d.ts +22 -0
  328. package/dist/components/stream/networkPipelineHelpers.d.ts +12 -0
  329. package/dist/components/stream/networkRealtimeEncoding.d.ts +41 -0
  330. package/dist/components/stream/networkTypes.d.ts +104 -5
  331. package/dist/components/stream/ordinalCanvasRenderers.d.ts +7 -0
  332. package/dist/components/stream/ordinalCustomLayout.d.ts +17 -1
  333. package/dist/components/stream/ordinalDataIndex.d.ts +5 -0
  334. package/dist/components/stream/ordinalDefaultTooltip.d.ts +10 -0
  335. package/dist/components/stream/ordinalDomain.d.ts +38 -0
  336. package/dist/components/stream/ordinalPipelineUpdateResults.d.ts +12 -0
  337. package/dist/components/stream/ordinalPulse.d.ts +10 -0
  338. package/dist/components/stream/ordinalPulseResources.d.ts +3 -0
  339. package/dist/components/stream/ordinalSceneBuilders/sceneBuilderMap.d.ts +5 -0
  340. package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -0
  341. package/dist/components/stream/ordinalSpatialIndex.d.ts +9 -0
  342. package/dist/components/stream/ordinalTypes.d.ts +56 -8
  343. package/dist/components/stream/paintNeeds.d.ts +31 -0
  344. package/dist/components/stream/physics/CapacityQueueController.d.ts +5 -0
  345. package/dist/components/stream/physics/CapacityQueueTypes.d.ts +134 -0
  346. package/dist/components/stream/physics/MatterPhysicsEngineAdapter.d.ts +42 -0
  347. package/dist/components/stream/physics/PhysicsAccessibility.d.ts +48 -0
  348. package/dist/components/stream/physics/PhysicsAnnotations.d.ts +58 -0
  349. package/dist/components/stream/physics/PhysicsBodyBudget.d.ts +26 -0
  350. package/dist/components/stream/physics/PhysicsBodySpatialIndex.d.ts +10 -0
  351. package/dist/components/stream/physics/PhysicsCanvasTheme.d.ts +26 -0
  352. package/dist/components/stream/physics/PhysicsControllers.d.ts +75 -0
  353. package/dist/components/stream/physics/PhysicsEngineAdapter.d.ts +59 -0
  354. package/dist/components/stream/physics/PhysicsEngineConformance.d.ts +23 -0
  355. package/dist/components/stream/physics/PhysicsEvidence.d.ts +25 -0
  356. package/dist/components/stream/physics/PhysicsKernel.d.ts +207 -0
  357. package/dist/components/stream/physics/PhysicsOptionalEngineAdapters.d.ts +12 -0
  358. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +84 -0
  359. package/dist/components/stream/physics/PhysicsPipelineTypes.d.ts +181 -0
  360. package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +72 -0
  361. package/dist/components/stream/physics/PhysicsSediment.d.ts +69 -0
  362. package/dist/components/stream/physics/PhysicsSettledSVG.d.ts +18 -0
  363. package/dist/components/stream/physics/PhysicsSettledScene.d.ts +21 -0
  364. package/dist/components/stream/physics/PhysicsWorkerClient.d.ts +24 -0
  365. package/dist/components/stream/physics/PhysicsWorkerProtocol.d.ts +101 -0
  366. package/dist/components/stream/physics/PhysicsWorkerRuntime.d.ts +5 -0
  367. package/dist/components/stream/physics/RapierPhysicsEngineAdapter.d.ts +18 -0
  368. package/dist/components/stream/physics/ServiceOperationsControllers.d.ts +27 -0
  369. package/dist/components/stream/physics/ServiceOperationsTypes.d.ts +89 -0
  370. package/dist/components/stream/physics/StreamPhysicsFrame.d.ts +6 -0
  371. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +302 -0
  372. package/dist/components/stream/physics/physicsBodyCanvas.d.ts +27 -0
  373. package/dist/components/stream/physics/physicsPipelineControls.d.ts +4 -0
  374. package/dist/components/stream/physics/physicsPipelineHelpers.d.ts +41 -0
  375. package/dist/components/stream/physics/physicsPipelineObservations.d.ts +14 -0
  376. package/dist/components/stream/physics/physicsPipelineUpdateResults.d.ts +9 -0
  377. package/dist/components/stream/physics/physicsRegionRuntime.d.ts +54 -0
  378. package/dist/components/stream/physics/physicsSemanticUI.d.ts +20 -0
  379. package/dist/components/stream/physics/usePhysicsFrameLifecyclePolicy.d.ts +16 -0
  380. package/dist/components/stream/pipelineBufferUtils.d.ts +26 -0
  381. package/dist/components/stream/pipelineConfig.d.ts +177 -0
  382. package/dist/components/stream/pipelineDecay.d.ts +20 -2
  383. package/dist/components/stream/pipelineDomainResolution.d.ts +62 -0
  384. package/dist/components/stream/pipelineIdentityOps.d.ts +26 -0
  385. package/dist/components/stream/pipelinePulse.d.ts +16 -2
  386. package/dist/components/stream/pipelineRibbons.d.ts +41 -0
  387. package/dist/components/stream/pipelineSpatialIndex.d.ts +12 -0
  388. package/dist/components/stream/pipelineStoreUpdateResults.d.ts +12 -0
  389. package/dist/components/stream/pipelineStyleResolvers.d.ts +46 -0
  390. package/dist/components/stream/pipelineTransitions.d.ts +2 -0
  391. package/dist/components/stream/pipelineUpdateContract.d.ts +62 -0
  392. package/dist/components/stream/pulseFrameRefresh.d.ts +22 -0
  393. package/dist/components/stream/renderers/glyphCanvasRenderer.d.ts +6 -0
  394. package/dist/components/stream/renderers/networkSymbolRenderer.d.ts +2 -0
  395. package/dist/components/stream/renderers/resolveCSSColor.d.ts +6 -0
  396. package/dist/components/stream/renderers/symbolCanvasRenderer.d.ts +2 -0
  397. package/dist/components/stream/sceneRevisionDiagnostics.d.ts +18 -0
  398. package/dist/components/stream/stalenessBands.d.ts +28 -0
  399. package/dist/components/stream/streamStoreSync.d.ts +37 -0
  400. package/dist/components/stream/symbolPath.d.ts +24 -0
  401. package/dist/components/stream/types.d.ts +206 -9
  402. package/dist/components/stream/useFrame.d.ts +21 -2
  403. package/dist/components/stream/useHydration.d.ts +6 -0
  404. package/dist/components/stream/useLegendCategoryEmission.d.ts +5 -0
  405. package/dist/components/stream/useStalenessCheck.d.ts +6 -1
  406. package/dist/components/stream/workerModuleUrl.d.ts +10 -0
  407. package/dist/components/stream/xyAnnotationAnchors.d.ts +13 -0
  408. package/dist/components/stream/xyCanvasRenderers.d.ts +7 -0
  409. package/dist/components/stream/xyCrosshair.d.ts +11 -0
  410. package/dist/components/stream/xyDateTicks.d.ts +9 -0
  411. package/dist/components/stream/xyDefaultTooltip.d.ts +10 -0
  412. package/dist/components/stream/xySceneBuilders/pointScene.d.ts +2 -2
  413. package/dist/components/stream/xySceneBuilders/types.d.ts +9 -4
  414. package/dist/controls.min.js +2 -0
  415. package/dist/controls.module.min.js +2 -0
  416. package/dist/forceLayoutWorker.js +1 -0
  417. package/dist/geo.min.js +1 -1
  418. package/dist/geo.module.min.js +1 -1
  419. package/dist/network.min.js +1 -1
  420. package/dist/network.module.min.js +1 -1
  421. package/dist/ordinal.min.js +1 -1
  422. package/dist/ordinal.module.min.js +1 -1
  423. package/dist/physics-matter.min.js +1 -0
  424. package/dist/physics-matter.module.min.js +1 -0
  425. package/dist/physics-rapier.min.js +1 -0
  426. package/dist/physics-rapier.module.min.js +1 -0
  427. package/dist/physics.min.js +2 -0
  428. package/dist/physics.module.min.js +2 -0
  429. package/dist/physicsWorker.js +1 -0
  430. package/dist/realtime.min.js +1 -1
  431. package/dist/realtime.module.min.js +1 -1
  432. package/dist/semiotic-ai-chunk-OG7BQUUW.module.min.js +2 -0
  433. package/dist/semiotic-ai-core.d.ts +47 -0
  434. package/dist/semiotic-ai-core.min.js +1 -0
  435. package/dist/semiotic-ai-core.module.min.js +1 -0
  436. package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +2 -0
  437. package/dist/semiotic-ai.d.ts +52 -4
  438. package/dist/semiotic-ai.min.js +1 -1
  439. package/dist/semiotic-ai.module.min.js +1 -1
  440. package/dist/semiotic-chunk-3FSVZ46U.module.min.js +2 -0
  441. package/dist/semiotic-controls.d.ts +18 -0
  442. package/dist/semiotic-data.d.ts +2 -0
  443. package/dist/semiotic-data.min.js +1 -1
  444. package/dist/semiotic-data.module.min.js +1 -1
  445. package/dist/semiotic-experimental.d.ts +49 -0
  446. package/dist/semiotic-experimental.min.js +1 -0
  447. package/dist/semiotic-experimental.module.min.js +1 -0
  448. package/dist/semiotic-geo.d.ts +11 -0
  449. package/dist/semiotic-network.d.ts +14 -1
  450. package/dist/semiotic-ordinal.d.ts +10 -0
  451. package/dist/semiotic-physics-matter.d.ts +10 -0
  452. package/dist/semiotic-physics-rapier.d.ts +9 -0
  453. package/dist/semiotic-physics.d.ts +56 -0
  454. package/dist/semiotic-realtime-core.d.ts +34 -0
  455. package/dist/semiotic-realtime-core.min.js +1 -0
  456. package/dist/semiotic-realtime-core.module.min.js +1 -0
  457. package/dist/semiotic-realtime-react.d.ts +10 -0
  458. package/dist/semiotic-realtime-react.min.js +2 -0
  459. package/dist/semiotic-realtime-react.module.min.js +2 -0
  460. package/dist/semiotic-realtime.d.ts +4 -22
  461. package/dist/semiotic-recipes-core.d.ts +92 -0
  462. package/dist/semiotic-recipes-core.min.js +1 -0
  463. package/dist/semiotic-recipes-core.module.min.js +1 -0
  464. package/dist/semiotic-recipes-react.d.ts +7 -0
  465. package/dist/semiotic-recipes-react.min.js +2 -0
  466. package/dist/semiotic-recipes-react.module.min.js +2 -0
  467. package/dist/semiotic-recipes.d.ts +4 -26
  468. package/dist/semiotic-recipes.min.js +1 -1
  469. package/dist/semiotic-recipes.module.min.js +1 -1
  470. package/dist/semiotic-server-edge.d.ts +8 -0
  471. package/dist/semiotic-server-edge.min.js +1 -0
  472. package/dist/semiotic-server-edge.module.min.js +1 -0
  473. package/dist/semiotic-server-node.d.ts +5 -0
  474. package/dist/semiotic-server-node.min.js +1 -0
  475. package/dist/semiotic-server-node.module.min.js +1 -0
  476. package/dist/semiotic-server.d.ts +2 -2
  477. package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +2 -0
  478. package/dist/semiotic-themes-core.d.ts +53 -0
  479. package/dist/semiotic-themes-core.min.js +1 -0
  480. package/dist/semiotic-themes-core.module.min.js +1 -0
  481. package/dist/semiotic-themes-react.d.ts +4 -0
  482. package/dist/semiotic-themes-react.min.js +2 -0
  483. package/dist/semiotic-themes-react.module.min.js +2 -0
  484. package/dist/semiotic-themes.d.ts +6 -74
  485. package/dist/semiotic-themes.min.js +1 -2
  486. package/dist/semiotic-themes.module.min.js +1 -2
  487. package/dist/semiotic-utils-core.d.ts +46 -0
  488. package/dist/semiotic-utils-core.min.js +1 -0
  489. package/dist/semiotic-utils-core.module.min.js +1 -0
  490. package/dist/semiotic-utils-react.d.ts +5 -0
  491. package/dist/semiotic-utils-react.min.js +2 -0
  492. package/dist/semiotic-utils-react.module.min.js +2 -0
  493. package/dist/semiotic-utils.d.ts +3 -39
  494. package/dist/semiotic-utils.min.js +1 -2
  495. package/dist/semiotic-utils.module.min.js +1 -2
  496. package/dist/semiotic-value.min.js +1 -1
  497. package/dist/semiotic-value.module.min.js +1 -1
  498. package/dist/semiotic-xy.d.ts +10 -0
  499. package/dist/semiotic.d.ts +39 -7
  500. package/dist/semiotic.min.js +1 -1
  501. package/dist/semiotic.module.min.js +1 -1
  502. package/dist/server.min.js +1 -1
  503. package/dist/server.module.min.js +1 -1
  504. package/dist/xy-chunk-IWD6IB6V.module.min.js +2 -0
  505. package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +2 -0
  506. package/dist/xy.min.js +1 -1
  507. package/dist/xy.module.min.js +1 -1
  508. package/package.json +246 -86
  509. package/spec/README.md +152 -0
  510. package/spec/bindings/README.md +35 -0
  511. package/spec/bindings/vega-lite.mjs +112 -0
  512. package/spec/v0.1/annotation-provenance.schema.json +127 -0
  513. package/spec/v0.1/audience-profile.schema.json +67 -0
  514. package/spec/v0.1/chart-capability.schema.json +186 -0
  515. package/dist/semiotic-ai-statisticalOverlays-C2PPlmXv.js +0 -1
  516. package/dist/semiotic-statisticalOverlays-C3DsOgr_.js +0 -1
  517. package/dist/xy-statisticalOverlays-C2PPlmXv.js +0 -1
@@ -0,0 +1 @@
1
+ "use strict";var e,t=Object.create,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,a=(e,t,o,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of r(t))s.call(e,c)||c===o||n(e,c,{get:()=>t[c],enumerable:!(a=i(t,c))||a.enumerable});return e},c=(e,i,r)=>(r=null!=e?t(o(e)):{},a(!i&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)),l={};((e,t)=>{for(var i in t)n(e,i,{get:t[i],enumerable:!0})})(l,{generateFrameSVGs:()=>ig,generateFrameSequence:()=>rg,generatePhysicsFrameSVGs:()=>sg,renderChart:()=>Zy,renderChartWithEvidence:()=>Qy,renderDashboard:()=>eg,renderGeoToStaticSVG:()=>Uy,renderNetworkToStaticSVG:()=>Vy,renderOrdinalToStaticSVG:()=>Gy,renderToStaticSVG:()=>Hy,renderXYToStaticSVG:()=>Xy,resolveTheme:()=>Xh,themeStyles:()=>Gh}),module.exports=(e=l,a(n({},"__esModule",{value:!0}),e));var u=c(require("react-dom/server")),d=c(require("react")),h=require("d3-scale");function f(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function p(e,t,n){const i=e=>e.toString(16).padStart(2,"0");return`#${i(e)}${i(t)}${i(n)}`}function y(e){const t=e.map(f),n=t.length-1;return e=>{if(0>=e){const[e,n,i]=t[0];return p(e,n,i)}if(e>=1){const[e,i,r]=t[n];return p(e,i,r)}const i=e*n,r=Math.floor(i),o=i-r,[s,a,c]=t[r],[l,u,d]=t[r+1];return p(Math.round(s+(l-s)*o),Math.round(a+(u-a)*o),Math.round(c+(d-c)*o))}}var g=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],m=y(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),x=y(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),b=y(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),v=y(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),w=y(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),k=y(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),S=y(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),A=y(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),M=y(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),P=y(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),_=y(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),j=y(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),C={blues:m,reds:x,greens:b,viridis:S,oranges:v,purples:w,greys:k,plasma:A,inferno:M,magma:P,cividis:_,turbo:j};y(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),y(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),y(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),y(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),y(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),y(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),y(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var I={category10:g,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...C},T=g,R=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],L=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function $(e,t,n){if("function"==typeof t){const i=t(e);return n&&i&&"string"==typeof i&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||L.has(t)}(i)?n(i):i}const i=e?.[t]+"";return n?n(i):T[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(i))%T.length]}function E(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function D(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>E(e,t)??"#999"}const i=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),r=i.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return(0,h.scaleOrdinal)().domain(i).range(n).unknown("#999");const o=I[n]||I.category10;if(r&&"function"==typeof o){let e=-1/0;for(const t of i){const n=Number(t);n>e&&(e=n)}return t=>o(Number(t)/e)}{const e=Array.isArray(o)?o:T;return(0,h.scaleOrdinal)().domain(i).range(e).unknown("#999")}}var z=Object.freeze([]);function B(e){if(!e)return z;let t=!1;for(let n=0;e.length>n;n++){const i=e[n];if(null==i||"object"!=typeof i){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}function F(e,t){return"touch"===t?Math.max(e,24):e}function N(e){return Array.isArray(e)?e[0]:e}function O(e,t,n,i){return{data:N(e),x:t,y:n,__semioticHoverData:!0,...i}}var W=["name","label","title"],q=["type","kind","category","group","class","status","role","shape"],Y=["value","amount","total","count","weight","score"],H=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function X(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}var G=require("react/jsx-runtime"),V={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function U(e,t){return"function"==typeof t?t(e):e[t]}function K(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Z(e={}){const{fields:t,title:n,format:i,style:r={},className:o=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(n){const t=U(e,n);s=K(t,i)}if(t&&t.length>0)t.forEach(t=>{let n,r,o;"string"==typeof t?(n=t,r=t,o=i):(n=t.label,r=t.accessor||t.key||"",o=t.format||i);const s=U(e,r);a.push({label:n,value:K(s,o)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=K(e[n],i);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=K(e[t[0]],i))}}const c={...V,...r};return(0,G.jsxs)("div",{className:("semiotic-tooltip "+o).trim(),style:c,children:[s&&(0,G.jsx)("div",{style:{fontWeight:a.length>0?"bold":"normal"},children:s}),a.map((e,t)=>(0,G.jsxs)("div",{style:{marginTop:0===t&&s?"4px":0},children:[e.label&&(0,G.jsxs)("span",{children:[e.label,": "]}),e.value]},t))]})}}function Q(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{let n=N(!0===e?.__semioticHoverData||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?e.data??{}:e);("node"===e?.nodeOrEdge&&"number"==typeof n?.x0&&"number"==typeof n?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof n?.sankeyWidth)&&n.data&&"object"==typeof n.data&&(n=n.data);const i=t(n);return null==i?null:(0,G.jsx)("div",{className:"semiotic-tooltip",style:V,children:i})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Z(e):Z())}}function J(e){const{title:t,description:n,summary:i,accessibleTable:r,className:o,animate:s,axisExtent:a,autoPlaceAnnotations:c}=e,l={};return t&&(l.title=t),n&&(l.description=n),i&&(l.summary=i),void 0!==r&&(l.accessibleTable=r),o&&(l.className=o),null!=s&&(l.animate=s),void 0!==a&&(l.axisExtent=a),void 0!==c&&(l.autoPlaceAnnotations=c),l}function ee(e){const{linkedHover:t,selection:n,onObservation:i,onClick:r,hoverRadius:o,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:c,mobileInteraction:l,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,f={},p=l?.enabled?Math.max(o??30,Math.ceil((l.targetSize||44)/2),24):o;return(a||t||i||r||s)&&(f.customHoverBehavior=u),d&&(c||(h?i||r||t:i||r)||l?.enabled&&(l.tapToSelect||l.tapToLockTooltip)&&(t||s||n))&&(f.customClickBehavior=d),null!=p&&(f.hoverRadius=p),f}var te=require("react"),ne=c(require("react")),ie=require("react"),re=require("react"),oe=require("d3-selection"),se=require("d3-brush"),ae=c(require("react")),ce=require("react/jsx-runtime");function le(e,t,n,i){const[r,o]=[Math.min(...t),Math.max(...t)],s=(o-r)/20;let[a,c]=e;if(i)0>n?a=Math.max(r,a-s):c=Math.min(o,c+s);else{const e=c-a;a=Math.max(r,Math.min(o-e,a+n*s)),c=a+e}return[a,c]}function ue(e,t){let n=0,i=t.length-1;for(;i>n;){const r=n+i+1>>1;t[r]>e?i=r-1:n=r}return t[n]}function de(e,t){let n=0,i=t.length-1;for(;i>n;){const r=n+i>>1;e>t[r]?n=r+1:i=r}return t[n]}function he({width:e,height:t,totalWidth:n,totalHeight:i,margin:r,dimension:o,scales:s,onBrush:a,binSize:c,snap:l,binBoundaries:u,snapDuring:d,streaming:h}){const f=(0,re.useRef)(null),p=(0,re.useRef)(null),y=(0,re.useRef)(a);y.current=a;const g=(0,re.useRef)(s);g.current=s;const m=(0,re.useMemo)(()=>u?[...u].sort((e,t)=>e-t):void 0,[u]),x=(0,re.useRef)(m);x.current=m;const b=(0,re.useRef)(!1),v=(0,re.useRef)(null),w=function({label:e="Data range brush",description:t="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it.",onAction:n}={}){const i=ae.useId().replace(/:/g,""),r=ae.useRef(n);return r.current=n,{description:t,descriptionId:"semiotic-brush-description-"+i,svgProps:{role:"region",tabIndex:0,"aria-label":e,"aria-describedby":"semiotic-brush-description-"+i,onKeyDown:ae.useCallback(e=>{const t=function(e){return"Escape"===e.key?{type:"clear"}:"ArrowLeft"===e.key?{type:"nudge",direction:"left",resize:e.shiftKey}:"ArrowRight"===e.key?{type:"nudge",direction:"right",resize:e.shiftKey}:"ArrowUp"===e.key?{type:"nudge",direction:"up",resize:e.shiftKey}:"ArrowDown"===e.key?{type:"nudge",direction:"down",resize:e.shiftKey}:null}(e);t&&(e.preventDefault(),r.current?.(t))},[])}}}({label:"xy"===o?"Two-dimensional data range brush":o.toUpperCase()+" data range brush",onAction:e=>{const t=g.current,n=p.current;if(!t||!n||!f.current)return;const i=(0,oe.select)(f.current).select(".brush-g");if("clear"===e.type)return b.current=!0,i.call(n.move,null),b.current=!1,v.current=null,void y.current(null);const r=t.x.domain(),s=t.y.domain(),a=v.current;let c=a?.x??[r[0]+.4*(r[1]-r[0]),r[0]+.6*(r[1]-r[0])],l=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===e.direction||"right"===e.direction,d="left"===e.direction||"down"===e.direction?-1:1;if(u&&"y"!==o&&(c=le(c,r,d,e.resize)),u||"x"===o||(l=le(l,s,d,e.resize)),u&&"y"===o||!u&&"x"===o)return;const h={x:c,y:l};b.current=!0,i.call(n.move,"x"===o?[t.x(c[0]),t.x(c[1])]:"y"===o?[t.y(l[1]),t.y(l[0])]:[[t.x(c[0]),t.y(l[1])],[t.x(c[1]),t.y(l[0])]]),b.current=!1,v.current=h,y.current(h)}});return(0,re.useEffect)(()=>{if(!f.current)return;const n=(0,oe.select)(f.current).select(".brush-g"),i="x"===o?(0,se.brushX)():"y"===o?(0,se.brushY)():(0,se.brush)();return i.extent([[0,0],[e,t]]),i.on("brush end",r=>{if(b.current)return;const s=g.current;if(!s)return;if(!r.selection)return v.current=null,void y.current(null);let a,u;if("x"===o){const[e,n]=r.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(t),s.y.invert(0)]}else if("y"===o){const[t,n]=r.selection;a=[s.x.invert(0),s.x.invert(e)],u=[s.y.invert(n),s.y.invert(t)]}else{const[[e,t],[n,i]]=r.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(i),s.y.invert(t)]}if("bin"===l&&"y"!==o&&("end"===r.type||"brush"===r.type&&d)){const e=x.current;e&&e.length>0?a=function(e,t){return 0===t.length?e:[ue(e[0],t),de(e[1],t)]}(a,e):c&&c>0&&(a=[Math.floor(a[0]/c)*c,Math.ceil(a[1]/c)*c]);const t=s.x(a[0]),l=s.x(a[1]);if(b.current=!0,"x"===o)n.call(i.move,[t,l]);else if("xy"===o){const e=r.selection;n.call(i.move,[[t,e[0][1]],[l,e[1][1]]])}b.current=!1}const h={x:a,y:u};v.current=h,y.current(h)}),n.call(i),p.current=i,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),p.current=null}},[e,t,o,l,c,d]),(0,re.useEffect)(()=>{if(!(h&&s&&p.current&&v.current))return;if(!f.current)return;if("y"===o)return;const e=v.current,t=s.x.domain()[0],n=(0,oe.select)(f.current).select(".brush-g");if(t>=e.x[1])return b.current=!0,n.call(p.current.move,null),b.current=!1,v.current=null,void y.current(null);let i=e.x[0],r=!1;if(t>e.x[0]){if(i=t,"bin"===l){const e=x.current;e&&e.length>0?i=de(t,e):c&&c>0&&(i=Math.ceil(t/c)*c)}if(i>=e.x[1])return b.current=!0,n.call(p.current.move,null),b.current=!1,v.current=null,void y.current(null);r=!0}const a=s.x(i),u=s.x(e.x[1]);if(b.current=!0,"x"===o)n.call(p.current.move,[a,u]);else{const t=s.y(e.y[1]),i=s.y(e.y[0]);n.call(p.current.move,[[a,t],[u,i]])}if(b.current=!1,r){const t={x:[i,e.x[1]],y:e.y};v.current=t,y.current(t)}},[s,h,o,l,c]),(0,ce.jsxs)("svg",{ref:f,width:n,height:i,...w.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[(0,ce.jsx)("title",{children:w.svgProps["aria-label"]}),(0,ce.jsx)("desc",{id:w.descriptionId,children:w.description}),(0,ce.jsx)("g",{className:"brush-g",transform:`translate(${r.left},${r.top})`})]})}var fe=class{constructor(e,t){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=t?.chunkThreshold??5e3,this.chunkSize=t?.chunkSize??5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e=B(e),this.lastBoundedData===e)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const i=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,i),bounded:!1}),t=i,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=B(e),this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const i=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,i),bounded:!1}),t=i,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let n=0;e.length>n;n++){const i=e[n];null!=i&&"object"==typeof i&&(this.pushBuffer.push(i),t++)}0!==t&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}},pe=require("react"),ye=require("react/jsx-runtime");function ge(e){let t=null;const n=()=>(t||(t=(0,pe.createContext)(null)),t),i=me(e);return[function({children:t,initialState:i}){const r=(0,pe.useRef)(i),o=(0,pe.useMemo)(()=>me(e,r.current),[]),s=n();return(0,ye.jsx)(s.Provider,{value:o,children:t})},(e,t)=>{const r=n(),o=(0,pe.useContext)(r)??i,s=(0,pe.useRef)(e);s.current=e;const a=(0,pe.useRef)({hasValue:!1,value:void 0}),c=(0,pe.useCallback)(()=>{const e=s.current(o.getState()),n=a.current;return n.hasValue&&t&&t(n.value,e)?n.value:(a.current={hasValue:!0,value:e},e)},[o,t]),l=(0,pe.useCallback)(()=>s.current(o.getState()),[o]);return(0,pe.useSyncExternalStore)(o.subscribe,c,l)}]}function me(e,t){const n=new Set;let i={...e(function(e){const t=e(i);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){i={...i,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>i,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function xe(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function be(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:ve}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var ve=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],we={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},ke={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Se={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:ve,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function Ae(e,t){if("light"===t)return we;if("dark"===t)return ke;if("high-contrast"===t)return Se;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?ke:we;return be({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return be({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[Me,Pe]=ge(e=>({theme:we,setTheme(t){e(e=>({theme:Ae(e.theme,t)}))}})),_e=class{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;return{next:()=>this._size>e?{done:!1,value:this.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray();let n=0,i=[];t.length>e&&(n=t.length-e,i=t.slice(0,n)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=n;t.length>e;e++)this.push(t[e]);return i}update(e,t){const n=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const o=(i+r)%this._capacity,s=this.buffer[o];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(e),this.buffer[o]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(i=>{e(i)?n.push(i):t.push(i)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},je=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function Ce(e,t){return e===t}function Ie(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function Te(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function Re(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var Le=/^\d{4}-\d{1,2}$/;function $e(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=Le.test(t)?t+"-01":t;if(n===t&&10>t.length)return NaN;const i=Date.parse(n);return Number.isFinite(i)?i:NaN}function Ee(e){return e instanceof Date?e.getTime():"string"==typeof e?$e(e):+e}function De(e){return new Set(Array.isArray(e)?e:[e])}function ze(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Be(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Fe(e,t,n){return e+(t-e)*n}function Ne(){return"undefined"!=typeof performance?performance.now():Date.now()}function Oe(e,t,n){if(1>=n)return 1;const i=n-1;return function(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const i=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(i>0?i:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}({age:i-t,extent:i,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function We(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function qe(e,t,n){const i=e.duration??500,r=n-t;return i>r?1-r/i:0}function Ye(e,t,n,i){let r=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,r=!0),e._pulseColor!==n&&(e._pulseColor=n,r=!0),e._pulseGlowRadius!==i&&(e._pulseGlowRadius=i,r=!0),r):(0!==e._pulseIntensity&&(e._pulseIntensity=0,r=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,r=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,r=!0),r)}function He(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const i=e.duration??500,r=t.peek();return null!=r&&i>n-r}function Xe(e,t,n){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),i=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${i}`;if(null!=n&&null!=i)return`p:${n}:${i}`}return"p:"+n;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+n;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Ge(e,t,n,i,r,o){const s=[];for(const r of e){const e=n(r),o=i(r);Number.isFinite(e)&&Number.isFinite(o)&&s.push({px:t.x(e),py:t.y(o),rawY:o,d:r})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],c[e]=t.rawY,l[e]=t.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:o}}function Ve(e,t,n,i,r,o,s,a){const c=[];for(const o of e){const e=n(o),s=i(o);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const l=t.x(e),u=a?a(o):r;c.push({px:l,topY:t.y(s),botY:t.y(u)})}c.sort((e,t)=>e.px-t.px);const l=Array(c.length),u=Array(c.length);for(let e=0;c.length>e;e++){const t=c[e];l[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:l,bottomPath:u,style:o,datum:e,group:s}}function Ue(e,t,n,i){const r=new Map;if("silhouette"===i)for(const i of e){let e=0;for(const r of t)e+=n(r,i)||0;r.set(i,-e/2)}else if("wiggle"===i){e.length>0&&r.set(e[0],0);for(let i=1;e.length>i;i++){const o=e[i-1],s=e[i];let a=0,c=0,l=0;for(const e of t){const t=n(e,s)||0;a+=(2*l+t)*(t-(n(e,o)||0)),c+=t,l+=t}const u=r.get(o)??0;r.set(s,u-(c>0?a/(2*c):0))}if(e.length>0){let i=0;for(const o of e){let e=0;for(const i of t)e+=n(i,o)||0;i+=(r.get(o)??0)+e/2}const o=i/e.length;for(const t of e)r.set(t,(r.get(t)??0)-o)}}else for(const t of e)r.set(t,0);return r}function Ke(e,t,n,i,r,o,s){const a=n(e),c=i(e);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:t.x(a),y:t.y(c),r:r,style:o,datum:e};return void 0!==s&&(l.pointId=s),l}function Ze(e,t,n,i,r,o,s,a){const c=n(e),l=i(e);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:t.x(c),y:t.y(l),size:r,symbolType:o,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function Qe(e,t,n,i,r,o,s){return{type:"rect",x:e,y:t,w:n,h:i,style:r,datum:o,group:s}}function Je(e,t,n,i,r,o,s){const a={type:"heatcell",x:e,y:t,w:n,h:i,fill:r,datum:o};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function et(e,t,n,i){return"function"==typeof t.style?t.style(i||{},n):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(n,i)}function tt(e,t,n,i){if(!e.scales)return null;const r=[],o=[];for(const n of t){const t=e.getX(n);if(!Number.isFinite(t))continue;const s=i.getTop(n),a=i.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=e.scales.x(t),l=e.scales.y(s),u=e.scales.y(a);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(r.push([c,l]),o.push([c,u]))}return 2>r.length?null:{type:"area",topPath:r,bottomPath:o,style:et(e,i,n,t[0]),datum:t,group:n,interactive:i.interactive}}function nt(e){const t=[],n=[];if(!e)return{perSeries:t,aggregate:n};for(const i of e)i.perSeries?t.push(i):n.push(i);return{perSeries:t,aggregate:n}}function it(e,t,n){const i=[];for(const r of n){const n=tt(e,t,"__ribbon_aggregate",r);n&&i.push(n)}return i}function rt(e,t,n,i){const r=[];for(const o of i){const i=tt(e,t,n,o);i&&r.push(i)}return r}function ot(e,t){if(!e)return{};if(!t||0===t.length)return e;const n=[];for(const i of t){if("band"!==i.kind)continue;const t=i.getTop(e),r=i.getBottom(e);Number.isFinite(r)&&Number.isFinite(t)&&n.push({y0:r,y1:t})}return 0===n.length?e:{...e,band:n[0],bands:n}}function st(e,t,n,i){if(!e.config.pointStyle)return;const r=i??e.getY;for(const i of t){const t=e.resolveGroupColor(i.key);for(const o of i.data){let i=e.config.pointStyle(o);!i.fill&&t&&(i={...i,fill:t});const s=i.r??3,a=e.getPointId?e.getPointId(o)+"":void 0,c=Ke(o,e.scales,e.getX,r,s,i,a);c&&n.push(c)}}}var at={topOpacity:.8,bottomOpacity:.05};function ct(e){if(e)return!0===e?at:"colorStops"in e?e:{topOpacity:e.topOpacity??at.topOpacity,bottomOpacity:e.bottomOpacity??at.bottomOpacity}}var lt=require("d3-shape"),ut={circle:lt.symbolCircle,square:lt.symbolSquare,triangle:lt.symbolTriangle,diamond:lt.symbolDiamond,star:lt.symbolStar,cross:lt.symbolCross,wye:lt.symbolWye},dt=["circle","triangle","diamond","star","square","chevron","cross","wye"];function ht(e,t,n){if(n)return n;const i=e??"circle";return"chevron"===i?function(e){const t=1.5*ft(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):(0,lt.symbol)(ut[i]??lt.symbolCircle,Math.max(1,t))()??""}function ft(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var pt=new Map;function yt(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){const i=Math.max(1,Math.floor(e.config.heatmapXBins??20)),r=Math.max(1,Math.floor(e.config.heatmapYBins??20)),o=e.config.heatmapAggregation??"count",s=Ie(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,c]=e.scales.x.domain(),[l,u]=e.scales.y.domain(),d=(c-a||1)/i,h=(u-l||1)/r,f=i*r;if(f>1e6)return[];const p=new Int32Array(f),y=new Float64Array(f);for(let n=0;t.length>n;n++){const o=t[n],c=e.getX(o),u=e.getY(o);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/d),i-1),g=Math.min(Math.floor((u-l)/h),r-1);if(0>f||0>g)continue;const m=g*i+f;p[m]++;const x=s(o);y[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let e=0;f>e;e++){if(0===p[e])continue;let t;switch(o){case"sum":t=y[e];break;case"mean":t=y[e]/p[e];break;default:t=p[e]}g>t&&(g=t),t>m&&(m=t)}if(!isFinite(g))return[];const x=m-g||1,b=n.width/i,v=n.height/r,w=e.config.showValues,k=e.config.heatmapValueFormat,S=[];for(let e=0;r>e;e++){const t=e*i;for(let n=0;i>n;n++){const i=t+n;if(0===p[i])continue;let s;switch(o){case"sum":s=y[i];break;case"mean":s=y[i]/p[i];break;default:s=p[i]}const c=(s-g)/x;S.push(Je(n*b,(r-1-e)*v,b,v,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:n,yi:e,value:s,count:p[i],sum:y[i],xCenter:a+(n+.5)*d,yCenter:l+(e+.5)*h,agg:o},w?{value:s,showValues:!0,valueFormat:k}:void 0))}}return S}(e,t,n);if(0===t.length)return[];const i=Ie(e.config.valueAccessor,"value"),r=Te(e.config.xAccessor,"x"),o=Te(e.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(t.length),l=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],i=r(n),u=o(n);c[e]=i,l[e]=u,s.has(i)||s.set(i,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(a.keys()),p=h.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e));if(p){h.sort((e,t)=>e-t),s.clear();for(let e=0;h.length>e;e++)s.set(h[e],e)}if(y){f.sort((e,t)=>e-t),a.clear();for(let e=0;f.length>e;e++)a.set(f[e],e)}const g=new Float64Array(t.length),x=new Float64Array(t.length),b=Array(t.length),v=new Map;let w=0;for(let e=0;t.length>e;e++){const n=t[e],r=s.get(c[e]),o=a.get(l[e]);if(void 0===r||void 0===o)continue;const d=i(n),h=o*u+r,f=v.get(h);let p;void 0!==f?p=f:(p=w++,v.set(h,p)),g[p]=h,x[p]=d,b[p]=n}let k=1/0,S=-1/0;for(let e=0;w>e;e++){const t=x[e];isFinite(t)&&(k>t&&(k=t),t>S&&(S=t))}if(!isFinite(k)||!isFinite(S))return[];const A=function(e){const t=e in C?e:"blues";let n=pt.get(t);if(n)return n;n=Array(256);const i=(r=t)&&C[r]||m;var r;for(let e=0;256>e;e++)n[e]=i(e/255);return pt.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),M=255/(S-k||1),P=n.width/u,_=n.height/d,j=e.config.showValues,I=e.config.heatmapValueFormat,T=[];for(let e=0;w>e;e++){const t=x[e];if(!isFinite(t))continue;const n=g[e],i=n%u;T.push(Je(i*P,(d-1-(n-i)/u)*_,P,_,A[Math.min((t-k)*M+.5|0,255)],b[e],j?{value:t,showValues:!0,valueFormat:I}:void 0))}return T}function gt(e,t,n,i,r){const o=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const c=Math.floor(e/i)*i;let l=o.get(c);if(l||(l={start:c,end:c+i,total:0,categories:new Map},o.set(c,l)),l.total+=a,r){const e=r(s);l.categories.set(e,(l.categories.get(e)||0)+a)}}return o}function mt(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:i,warned:r}=e;xt(i)&&0===n.length&&bt(r,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&bt(r,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function xt(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(xt))}function bt(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function vt(e,t,n,i){const r=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),o="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:o,message:`Semiotic ${e} ${o} failed: ${r.message}`,error:r,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:i}}function wt(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function kt(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,i=wt(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=Ie(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=i(e);if(!Number.isFinite(t))return NaN;const r=n(e);return Number.isFinite(r)&&0!==r?t+r:t},getBottom:e=>{const t=i(e);if(!Number.isFinite(t))return NaN;const r=n(e);return Number.isFinite(r)&&0!==r?t-r:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const n=Array.isArray(e.band)?e.band:[e.band];for(const e of n)t.push({kind:"band",getTop:wt(e.y1Accessor,"y1"),getBottom:wt(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}var St=require("d3-scale");function At(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function Mt(e,t,n){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return(0,St.scaleLog)().domain(e).range(n).clamp(!0)}return"symlog"===e?(0,St.scaleSymlog)().domain(t).range(n):"time"===e?(0,St.scaleTime)().domain([new Date(t[0]),new Date(t[1])]).range(n):(0,St.scaleLinear)().domain(t).range(n)}function Pt(e,t,n){t>e.capacity&&(e.resize(t),n&&t>n.capacity&&n.resize(t))}function _t(e,t){const n=new _e(e.capacity);return e.forEach(()=>n.push(t)),n}function jt(e,t,n,i){const r=e.push(t);return n&&n.push(i),r}function Ct(e,t,n){if(!t||0===t.size)return;const i=new Set;if(e.forEach((e,t)=>{n(e)&&i.add(t)}),0===i.size)return;const r=t.toArray();t.clear();for(let e=0;r.length>e;e++)i.has(e)||t.push(r[e])}var It={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function Tt(e,t){const n={...e};for(const e of t)n[It[e]]++;return n}function Rt(e,t,n){const i=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:i,revisions:Tt(n,i)}}var Lt=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=Rt({kind:"initialize"},[],this.revisions)}get last(){return this.latest}record(e,t){const n=Rt(e,t,this.revisions);return this.revisions=n.revisions,this.latest=n,n}},$t=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Et=["scene-style","data-paint","accessibility","evidence"],Dt=new Set(["lineStyle","pointStyle","areaStyle","barStyle","swarmStyle","waterfallStyle","candlestickStyle","boundsStyle","colorScheme","themeCategorical","themeSemantic","barColors"]),zt=class{constructor(){this.tracker=new Lt}get last(){return this.tracker.last}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},$t)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Et):this.recordNoop("restyle")}recordConfig(e,t,n){return this.tracker.record({kind:"config",keys:e},t?function(e,t){const n=new Set(["layout","scene-geometry","data-paint","overlay","accessibility","evidence"]);return t&&n.add("domain"),e.some(e=>Dt.has(e))&&n.add("scene-style"),n}(e,n):[])}},Bt=require("d3-quadtree"),Ft=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let n=0,i=0;for(const e of t)"point"===e.type&&(n++,e.r>i&&(i=e.r));if(this.maxRadius=i,500>=n)return void(this.tree=null);const r=Array(n);let o=0;for(const e of t)"point"===e.type&&(r[o++]=e);this.tree=(0,Bt.quadtree)().x(e=>e.x).y(e=>e.y).addAll(r)}},Nt=class e{constructor(e){if(this.xExtent=new je,this.yExtent=new je,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new zt,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new Ft,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,i,r,o=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;const l=r??(()=>{const e=new Map;for(let t=0;n.length>t;t++)e.set(n[t],t);return e})();for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let r=0,a=!1;for(const n of t){const t=l.get(n);if(null==t)continue;a=!0;const s=i.get(t);if(null==s)continue;const c=qe(e,s,o);c>r&&(r=c)}a&&(c=Ye(n,r,s)||c);continue}const t=l.get(n.datum);if(null==t)continue;const r=i.get(t);c=Ye(n,null==r?0:qe(e,r,o),s,a)||c}return c}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this._stylePaintPending=!1,this.config=e,this.buffer=new _e(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=Ie(e.timeAccessor||e.xAccessor,"time"),this.getY=Ie(e.valueAccessor||e.yAccessor,"value")):(this.getX=Ie(e.xAccessor,"x"),this.getY=Ie(e.yAccessor,"y")),this.getGroup=Re(e.groupAccessor),this.getCategory=Re(e.categoryAccessor),this.getSize=e.sizeAccessor?Ie(e.sizeAccessor,"size"):void 0,this.getColor=Re(e.colorAccessor),this.getSymbol=Re(e.symbolAccessor),this.getY0=e.y0Accessor?Ie(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=kt(e),this.getPointId=Re(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?Ie(e.openAccessor,"open"):void 0,this.getHigh=Ie(e.highAccessor,"high"),this.getLow=Ie(e.lowAccessor,"low"),this.getClose=n?Ie(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new _e(e.windowSize))}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=_t(this.buffer,Ne())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),i=t.getBottom(e);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(i)&&this.yExtent.push(i)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),i=t.getBottom(e);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(i)&&this.yExtent.evict(i)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;const t=Ne();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=n?Ie(this.config.timeAccessor||this.config.xAccessor,"time"):Ie(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(t):t[n||"x"],r=i instanceof Date,o="string"==typeof i&&Number.isFinite($e(i));if(this.xIsDate=r||o,o){const e="string"==typeof n?n:void 0;this.getX=e?t=>Ee(t[e]):e=>Ee(n(e))}}Pt(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)jt(this.buffer,n,this.timestampBuffer,t),this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n)}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity??1e5;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const e=jt(this.buffer,n,this.timestampBuffer,t);this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){const{config:t,buffer:n}=this,i=this.scales,r=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(n,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const o=this.getBufferArray(),s=this.yExtent.extent;let a=At(this.xExtent.extent,t.xExtent),c=At(s,t.yExtent);const l=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const d="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!l&&n.size>0){const e=function(e){const{config:t,groups:n,getX:i,getY:r}=e,o="exact"===t.axisExtent;if(t.normalize){const n=[0,o?1:1+t.extentPadding];return{yDomain:n,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:n}}}const s=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===s)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,d=new Map;for(const e of n){const t=new Map;let n=0;for(const o of e.data){const e=i(o),s=r(o);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),c.add(e),n+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>l&&(l=a)}a.set(e.key,t),d.set(e.key,n)}const h=t.stackOrder??"key",f=(e,t)=>t>e?-1:e>t?1:0;let p,y;if("input"===h)p=n.map(e=>e.key);else if("insideOut"===h){const e=[...n].map(e=>e.key).sort((e,t)=>{const n=(d.get(t)??0)-(d.get(e)??0);return 0!==n?n:f(e,t)}),t=[],i=[];let r=0,o=0;for(const n of e)o>r?(t.push(n),r+=d.get(n)??0):(i.push(n),o+=d.get(n)??0);p=[...i.reverse(),...t]}else p="asc"===h?n.map(e=>e.key).sort((e,t)=>{const n=(d.get(e)??0)-(d.get(t)??0);return 0!==n?n:f(e,t)}):"desc"===h?n.map(e=>e.key).sort((e,t)=>{const n=(d.get(t)??0)-(d.get(e)??0);return 0!==n?n:f(e,t)}):n.map(e=>e.key).sort(f);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),n=Ue(e,p,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let i=1/0,r=-1/0;for(const t of e){const e=n.get(t)??0,o=u.get(t)??0;i>e&&(i=e),e+o>r&&(r=e+o)}Number.isFinite(i)&&Number.isFinite(r)||(i=0,r=0);const s=r-i,l=o?0:s>0?s*t.extentPadding:1;y=[i-l,r+l]}else if("diverging"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),[n,i]=function(e,t,n){let i=0,r=0;for(const o of e){let e=0,s=0;for(const i of t){const t=n(i,o)||0;0>t?s+=t:e+=t}i>s&&(i=s),e>r&&(r=e)}return[i,r]}(e,p,(e,t)=>a.get(e)?.get(t)||0),r=i-n,s=o?0:r>0?r*t.extentPadding:1;y=[n-s,i+s]}else y=[0,l+(o?0:l>0?l*t.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}({config:t,groups:this.groupData(o),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!l&&n.size>0?c=function(e,t,n,i,r,o,s){const[,a]=function(e,t,n,i,r){const o=gt(e,t,n,i,r);if(0===o.size)return[0,0];let s=0;for(const e of o.values())e.total>s&&(s=e.total);return[0,s]}(e,t,n,i,r);return[0,s?a:a+a*o]}(n,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,d):"waterfall"===t.chartType&&!l&&n.size>0?c=function(e,t,n,i){const[r,o]=function(e,t){let n=0,i=0,r=0;for(const o of e){const e=t(o);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>i&&(i=r))}return[n,i]}(e,t),s=o-r,a=i?0:s>0?s*n:1;return[Math.min(0,r-Math.abs(a)),Math.max(0,o+Math.abs(a))]}(n,this.getY,t.extentPadding,d):l||c[0]===1/0||(c=function(e,t,n){if(!n.length)return e;let[i,r]=e;for(const e of t)for(const t of n){const n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&(i>n&&(i=n),n>r&&(r=n)),Number.isFinite(o)&&(i>o&&(i=o),o>r&&(r=o))}return[i,r]}(c,o,this.resolvedRibbons),c=function(e,t){const n=e[1]-e[0],i=t.exactMode?0:n>0?n*t.extentPadding:1,r=[null!=t.userMin?e[0]:e[0]-i,null!=t.userMax?e[1]:e[1]+i];return"log"!==t.yScaleType||r[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(r[0]=t.dataYDomain[0]/(1+t.extentPadding)),r}(c,{exactMode:d,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=function(e,t,n){if(!t||n)return e;const i=t[0],r=t[1];return null==i&&null==r?e:[null!=i?i:e[0],null!=r?r:e[1]]}(c,t.yExtent,!!l),({xDomain:a,yDomain:c}=function(e,t,n){let i=e,r=t;if(i[0]===1/0||i[1]===-1/0)if("time"===n){const e=Date.now();i=[e-864e5,e]}else i=[0,1];return r[0]!==1/0&&r[1]!==-1/0||(r=[0,1]),{xDomain:i,yDomain:r}}(a,c,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:i,yDomain:r}=e,o="streaming"===t.runtimeMode,s=Math.max(0,Math.min(t.scalePadding||0,Math.min(n.width,n.height)/2-1));if(o){if("x"==("up"===(a=t.arrowOfTime)||"down"===a?"y":"x")){const e="right"===t.arrowOfTime?[s,n.width-s]:[n.width-s,s];return{x:(0,St.scaleLinear)().domain(i).range(e),y:Mt(t.yScaleType,r,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Mt(t.yScaleType,r,[s,n.width-s]),y:(0,St.scaleLinear)().domain(i).range(e)}}var a;return{x:Mt(t.xScaleType,i,[s,n.width-s]),y:Mt(t.yScaleType,r,[n.height-s,s])}}({config:t,layout:e,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const h=this.buildSceneNodes(e,o);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.lastLayout=r):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=h,this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const i of e.path)i[0]*=t,i[1]*=n;break;case"area":for(const i of e.topPath)i[0]*=t,i[1]*=n;for(const i of e.bottomPath)i[0]*=t,i[1]*=n;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*n,width:e.clipRect.width*t,height:e.clipRect.height*n});break;case"point":case"glyph":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const i=this.scales.x.domain(),r=this.scales.y.domain(),o=this.scales.x.range(),s=this.scales.y.range(),a=Mt,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,i,o[0]>o[1]?[e.width-c,c]:[c,e.width-c]),y:a(this.config.yScaleType,r,l?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:n,scales:i}=this;if(!i)return[];if(n.customLayout){const r={data:t,scales:i,dimensions:{width:e.width,height:e.height,margin:n.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:n.themeSemantic??{},categorical:n.themeCategorical??R},resolveColor:(e,t)=>{const i=this.resolveGroupColor(e);if(i)return i;const r=this.resolveLineStyle(e,t);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let o;try{o=n.customLayout(r)}catch(e){const t=null!==this.lastCustomLayoutResult,i=vt("xy",e,t,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e);try{n.onLayoutError?.(i)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;const s=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of s)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(s,n.layoutSelection??null)}return mt({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];const r={scales:i,config:n,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(n.chartType){case"line":return function(e,t){const n=e.groupData(t),i=[],r=e.config.annotations?.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:o}=nt(e.ribbons);if(o.length>0&&i.push(...it(e,t,o)),r.length>0)for(const t of n)i.push(...rt(e,t.data,t.key,r))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),o=Ge(t.data,e.scales,e.getX,e.getY,n,t.key);r&&r.length>0&&(o.colorThresholds=r),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),i.push(o)}return st(e,n,i),i}(r,t);case"area":return function(e,t){const n=e.groupData(t),i=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:o}=nt(e.ribbons);if(o.length>0&&i.push(...it(e,t,o)),r.length>0)for(const t of n)i.push(...rt(e,t.data,t.key,r))}const r=e.scales.y.domain()[0],o=e.getY0?t=>{const n=e.getY0(t);return null==n?r:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=Ve(t.data,e.scales,e.getX,e.getY,r,n,t.key,o),a=ct(e.config.gradientFill);a&&(s.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),i.push(s)}return st(e,n,i),i}(r,t);case"mixed":return function(e,t){const n=e.groupData(t),i=[],r=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:o}=nt(e.ribbons);if(o.length>0&&i.push(...it(e,t,o)),r.length>0)for(const t of n)i.push(...rt(e,t.data,t.key,r))}const o=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?o:n}:void 0;for(const t of n)if(r.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),r=Ve(t.data,e.scales,e.getX,e.getY,o,n,t.key,s),a=ct(e.config.gradientFill);a&&(r.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),i.push(r)}else{const n=e.resolveLineStyle(t.key,t.data[0]),r=Ge(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),i.push(r)}return st(e,n,i),i}(r,t);case"stackedarea":return function(e,t){const n=e.groupData(t),i=e.config.stackOrder??"key",r=()=>n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===i);else if("key"===i)r();else if("asc"===i||"desc"===i||"insideOut"===i){const t=new Map;for(const i of n){let n=0;for(const t of i.data){const i=e.getX(t),r=e.getY(t);Number.isFinite(i)&&Number.isFinite(r)&&(n+=r)}t.set(i.key,n)}const r=(e,t)=>t>e?-1:e>t?1:0;if("asc"===i)n.sort((e,n)=>{const i=(t.get(e.key)??0)-(t.get(n.key)??0);return 0!==i?i:r(e.key,n.key)});else if("desc"===i)n.sort((e,n)=>{const i=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==i?i:r(e.key,n.key)});else{const e=[...n].sort((e,n)=>{const i=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==i?i:r(e.key,n.key)}),i=[],o=[];let s=0,a=0;for(const n of e)a>s?(i.push(n),s+=t.get(n.key)??0):(o.push(n),a+=t.get(n.key)??0);n.length=0,n.push(...o.reverse(),...i)}}else r();const o=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,s=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:a,stackedTops:c}=function(e,t,n,i,r,o,s,a="zero"){const c=new Set;for(const t of e)for(const e of t.data){const t=n(e);Number.isFinite(t)&&c.add(t)}const l=Array.from(c).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),o=i(r);Number.isFinite(t)&&Number.isFinite(o)&&e.set(t,(e.get(t)||0)+o)}u.set(t.key,e)}let d;if(o){d=new Map;for(const t of l){let n=0;for(const i of e)n+=u.get(i.key)?.get(t)||0;d.set(t,n||1)}}const h=Ue(l,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,a),f="diverging"===a&&!o,p=[],y=new Map,g=new Map,m=new Map,x=new Map;for(const e of l)g.set(e,h.get(e)??0),m.set(e,0),x.set(e,0);for(const n of e){const e=u.get(n.key),i=new Map;let a=[],c=[];const h=()=>{if(a.length>=2){const e={type:"area",topPath:a,bottomPath:c,style:r(n.key,n.data[0]),datum:n.data,group:n.key};s&&(e.curve=s),p.push(e)}a=[],c=[]};for(const n of l){const r=e.has(n);let s,l,u=r?e.get(n):0;if(o&&r&&(u/=d.get(n)),!r||!Number.isFinite(u)||0===u){h();continue}f?u>0?(s=m.get(n),l=s+u,m.set(n,l)):(s=x.get(n),l=s+u,x.set(n,l)):(s=g.get(n),l=s+u,g.set(n,l));const p=t.x(n);c.push([p,t.y(s)]),a.push([p,t.y(l)]),i.set(n,l)}h(),y.set(n.key,i)}return{nodes:p,stackedTops:y}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,o,s),l=a;if(e.config.pointStyle){const t=new WeakMap;for(const i of n){const n=c.get(i.key);if(n)for(const r of i.data){const i=e.getX(r),o=e.getY(r);null==i||Number.isNaN(i)||null==o||Number.isNaN(o)||!n.has(i)||t.set(r,n.get(i))}}const i=n=>t.get(n)??e.getY(n);st(e,n,l,i)}return l}(r,t);case"scatter":case"bubble":return function(e,t){const n=[],i="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let o=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const i of n)e>i&&(e=i),i>t&&(t=i);o=n=>e===t?(r[0]+r[1])/2:r[0]+(n-e)/(t-e)*(r[1]-r[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",c=e.getSymbol,l=e.config.symbolMap,u=new Map;let d=0;const h=e=>{const t=l?.[e];if(t)return t;let n=u.get(e);return n||(n=dt[d%dt.length],d++,u.set(e,n)),n};for(const r of t){let t=e.config.pointStyle?e.config.pointStyle(r):{fill:a,opacity:.8},l=t.r||i;if(o&&e.getSize){const t=e.getSize(r);null==t||Number.isNaN(t)||(l=o(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(r);n&&s.has(n)&&(t={...t,fill:s.get(n)})}const u=e.getPointId?e.getPointId(r)+"":void 0;if(c){const i=h(c(r)+""),o=Ze(r,e.scales,e.getX,e.getY,Math.PI*l*l,i,t,u);o&&n.push(o)}else{const i=Ke(r,e.scales,e.getX,e.getY,l,t,u);i&&n.push(i)}}return n}(r,t);case"heatmap":return yt(r,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=gt(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let i=null;if(e.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const r=e.config.barColors?Object.keys(e.config.barColors):[],o=new Set(r),s=Array.from(t).filter(e=>!o.has(e)).sort(),a=r.filter(e=>t.has(e)),c=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===c?i=e.barCategoryCache.order:(i=[...a,...s],e.barCategoryCache={key:c,order:i})}const r=[],o=e.scales,[s,a]=o.x.domain(),c=e.config.barStyle,l=e.config.themeSemantic?.primary,u=c?.gap,d="number"!=typeof u||0>u?1:u,h={};c?.stroke&&(h.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(h.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(h.opacity=c.opacity);for(const t of n.values()){const n=Math.max(t.start,s),u=Math.min(t.end,a);if(n>=u)continue;const f=o.x(n),p=o.x(u),y=Math.abs(p-f),g=y>d+1?d:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(i&&t.categories.size>0){let n=0;for(const s of i){const i=t.categories.get(s)||0;if(0===i)continue;const a=o.y(n),u=o.y(n+i);r.push(Qe(m,Math.min(a,u),x,Math.abs(a-u),{fill:e.config.barColors?.[s]||c?.fill||l||"#4e79a7",...h},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:i},s)),n+=i}}else{const e=o.y(0),n=o.y(t.total);r.push(Qe(m,Math.min(e,n),x,Math.abs(e-n),{fill:c?.fill||l||"#007bff",...h},{binStart:t.start,binEnd:t.end,total:t.total}))}}const f=new Set;for(const e of n.values())f.add(e.start),f.add(e.end);return{nodes:r,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(r,t);return this._barCategoryCache=r.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const n=[],i=e.config.swarmStyle||{},r=i.radius??3,o=i.fill??e.config.themeSemantic?.primary??"#007bff",s=i.opacity??.7,a=i.stroke,c=i.strokeWidth;for(const i of t){const t=e.getX(i),l=e.getY(i);if(null==l||Number.isNaN(l))continue;const u=e.scales.x(t),d=e.scales.y(l);let h=o;if(e.getCategory){const t=e.getCategory(i);h=e.config.barColors?.[t]||h}const{r:f,...p}=e.config.pointStyle?.(i)??{},y={type:"point",x:u,y:d,r:f??r,style:{fill:h,opacity:s,stroke:a,strokeWidth:c,...p},datum:i};e.getPointId&&(y.pointId=e.getPointId(i)+""),n.push(y)}return n}(r,t);case"waterfall":return function(e,t,n){const i=[],r=e.scales,o=e.config.waterfallStyle,s=t.filter(t=>{const n=e.getY(t),i=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=i&&isFinite(i)});if(0===s.length)return i;const a=o?.positiveColor??e.config.themeSemantic?.success??"#28a745",c=o?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",l=o?.gap??1,u=o?.stroke,d=o?.strokeWidth,h=o?.opacity;let f=0;for(let t=0;s.length>t;t++){const p=s[t],y=e.getX(p),g=e.getY(p),m=f+g;let x;x=s.length-1>t?e.getX(s[t+1])-y:t>0?y-e.getX(s[t-1]):0;const b=r.x(y),v=0!==x?r.x(y+x):b+n.width/10,w=Math.min(b,v)+l/2,k=Math.max(b,v)-l/2-w;if(0>=k){f=m;continue}const S=r.y(f),A=r.y(m),M=Math.min(S,A),P=Math.abs(S-A),_={fill:0>g?c:a,stroke:u,strokeWidth:d};null!=h&&(_.opacity=h),i.push(Qe(w,M,k,P,_,{...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:o?.connectorStroke,_connectorWidth:o?.connectorWidth})),f=m}return i}(r,t,e);case"candlestick":return function(e,t){if(!e.getHigh||!e.getLow||!e.scales)return[];const n=e.config.candlestickRangeMode??!1;if(!(n||e.getOpen&&e.getClose))return[];const i=[],r=e.config.candlestickStyle||{},o=r.rangeColor||"#6366f1",s=n?o:r.upColor||"#28a745",a=n?o:r.downColor||"#dc3545",c=n?o:r.wickColor||"#333",l=r.wickWidth||(n?2:1),u=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let d=r.bodyWidth??0;if(null==r.bodyWidth)if(u.length>1){let t=1/0;for(let n=1;u.length>n;n++){const i=Math.abs(e.scales.x(u[n])-e.scales.x(u[n-1]));i>0&&t>i&&(t=i)}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6;for(const r of t){const t=e.getX(r);if(null==t||Number.isNaN(t))continue;const o=e.getHigh(r),u=e.getLow(r);if(null==o||Number.isNaN(o)||null==u||Number.isNaN(u))continue;const h=n?o:e.getOpen(r),f=n?u:e.getClose(r);if(!n&&[h,f].some(e=>null==e||Number.isNaN(e)))continue;const p=f>=h,y={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(h),closeY:e.scales.y(f),highY:e.scales.y(o),lowY:e.scales.y(u),bodyWidth:d,upColor:s,downColor:a,wickColor:c,wickWidth:l,isUp:p,datum:r};n&&(y.isRange=!0),i.push(y)}return i}(r,t);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,n,i){const r=e.boundsStyle;return"function"==typeof r?r(n||{},t):r&&"object"==typeof r?r:{fill:i(t,n).stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Oe(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=We(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,n,i=We(n)){const r=n.length;if(r>1)for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const o=Array(t.length);let s=!1;for(let n=0;t.length>n;n++){const a=i.get(t[n]);null!=a?(o[n]=Oe(e,a,r),1>o[n]&&(s=!0)):o[n]=1}s&&(n._decayOpacities=o);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:t.length;if(2>o)continue;if(t.length===o){const s=Array(o);let a=!1;for(let n=0;t.length>n;n++){const o=i.get(t[n]);null!=o?(s[n]=Oe(e,o,r),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of t){const t=i.get(n);if(null!=t){const n=Oe(e,t,r);s>n&&(s=n)}}if(1>s){const e=Array(o);e.fill(s),n._decayOpacities=e}}continue}const t=i.get(n.datum);if(null==t)continue;const o=Oe(e,t,r);"heatcell"===n.type?n.style={opacity:o}:"candlestick"===n.type?n._decayOpacity=o:n.style={...n.style,opacity:(n.style?.opacity??1)*o}}}(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&He(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(Ne())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,i){n.clear(),i.clear();for(let r=0;t.length>r;r++){const o=t[r],s=Xe(e,o,r);s&&("point"===o.type?n.set(s,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"glyph"===o.type?n.set(s,{x:o.x,y:o.y,r:o.size,opacity:o.style.opacity,glyph:o.glyph}):"rect"===o.type?n.set(s,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"heatcell"===o.type?n.set(s,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style?.opacity}):"candlestick"===o.type?n.set(s,{x:o.x,y:o.openY,w:o.bodyWidth,openY:o.openY,closeY:o.closeY,highY:o.highY,lowY:o.lowY,opacity:o.style?.opacity}):"line"===o.type?i.set(s,{path:o.path.map(e=>[e[0],e[1]]),opacity:o.style?.opacity}):"area"===o.type&&i.set(s,{topPath:o.topPath.map(e=>[e[0],e[1]]),bottomPath:o.bottomPath.map(e=>[e[0],e[1]]),opacity:o.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],i=Xe(this.transitionContext,n,t);i&&("point"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(i,{x:n.x,y:e,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(i,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(i,{topPath:n.topPath.map(e=>[e[0],e[1]]),bottomPath:n.bottomPath.map(e=>[e[0],e[1]]),opacity:n.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,i,r){if(0===i.size&&0===r.size)return n;const o=t.duration??300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let s=!1;const a=new Set,c=new Set;for(let t=0;n.scene.length>t;t++){const o=n.scene[t],l=Xe(e,o,t);if(!l)continue;if(o._transitionKey=l,"line"===o.type||"area"===o.type){const e=r.get(l);if(e){if(c.add(l),"line"===o.type&&e.path&&e.path.length===o.path.length){o._targetPath=o.path.map(e=>[e[0],e[1]]),o._prevPath=e.path;for(let t=0;o.path.length>t;t++)o.path[t]=[e.path[t][0],e.path[t][1]];s=!0}else if("area"===o.type&&e.topPath&&e.bottomPath&&e.topPath.length===o.topPath.length&&e.bottomPath.length===o.bottomPath.length){o._targetTopPath=o.topPath.map(e=>[e[0],e[1]]),o._targetBottomPath=o.bottomPath.map(e=>[e[0],e[1]]),o._prevTopPath=e.topPath,o._prevBottomPath=e.bottomPath;for(let t=0;o.topPath.length>t;t++)o.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;o.bottomPath.length>t;t++)o.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];s=!0}o._targetOpacity=o.style.opacity??1,o._startOpacity=e.opacity??o.style.opacity??1}else o._targetOpacity=o.style.opacity??1,o._startOpacity=0,o.style={...o.style,opacity:0},s=!0;continue}const u=i.get(l);if("point"===o.type)if(u){a.add(l);const e={x:o.x,y:o.y,r:o.r};o._targetOpacity=o.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.r||(o._targetX=e.x,o._targetY=e.y,o._targetR=e.r,o.x=u.x,o.y=u.y,o.r=u.r??o.r,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("glyph"===o.type)if(u){a.add(l);const e={x:o.x,y:o.y,size:o.size};o._targetOpacity=o.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.size||(o._targetX=e.x,o._targetY=e.y,o._targetR=e.size,o.x=u.x,o.y=u.y,o.size=u.r??o.size,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("rect"===o.type)if(u){a.add(l);const e={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=o.style.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(o._targetX=e.x,o._targetY=e.y,o._targetW=e.w,o._targetH=e.h,o.x=u.x,o.y=u.y,o.w=u.w??o.w,o.h=u.h??o.h,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("heatcell"===o.type)if(u){a.add(l);const e={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=o.style?.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(o._targetX=e.x,o._targetY=e.y,o._targetW=e.w,o._targetH=e.h,o.x=u.x,o.y=u.y,o.w=u.w??o.w,o.h=u.h??o.h,s=!0)}else o._targetOpacity=o.style?.opacity??1,o.style={...o.style||{},opacity:0},s=!0;else if("candlestick"===o.type)if(u&&null!=u.openY){a.add(l);const e={x:o.x,openY:o.openY,closeY:o.closeY,highY:o.highY,lowY:o.lowY};o._targetOpacity=o.style?.opacity??1,(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(o._targetX=e.x,o._targetOpenY=e.openY,o._targetCloseY=e.closeY,o._targetHighY=e.highY,o._targetLowY=e.lowY,o.x=u.x,o.openY=u.openY,o.closeY=u.closeY??o.closeY,o.highY=u.highY??o.highY,o.lowY=u.lowY??o.lowY,s=!0)}else o._targetOpacity=o.style?.opacity??1,o.style={...o.style||{},opacity:0},s=!0}for(const[e,t]of r)if(!c.has(e))if(e.startsWith("l:")&&t.path){const i={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(i),s=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const i={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(i),s=!0}for(const[e,t]of i)if(!a.has(e)){if(e.startsWith("p:"))n.exitNodes.push({type:"point",x:t.x,y:t.y,r:t.r??3,style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("g:")&&t.glyph)n.exitNodes.push({type:"glyph",x:t.x,y:t.y,size:t.r??12,glyph:t.glyph,color:"#999",accent:"#999",style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))n.exitNodes.push({type:"rect",x:t.x,y:t.y,w:t.w??0,h:t.h??0,style:{opacity:t.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("h:"))n.exitNodes.push({type:"heatcell",x:t.x,y:t.y,w:t.w??0,h:t.h??0,fill:"#999",datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e});else if(e.startsWith("c:")){const i=t.openY??t.y;n.exitNodes.push({type:"candlestick",x:t.x,openY:i,closeY:t.closeY??i,highY:t.highY??i,lowY:t.lowY??i,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}s=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),s&&(n.activeTransition={startTime:Ne(),duration:o}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,i){if(!n.activeTransition)return!1;const r=Be(e,n.activeTransition),o=ze(r,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style.opacity=Fe(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),e.y=Fe(n.y,e._targetY,o),void 0!==e._targetR&&void 0!==n.r&&(e.r=Fe(n.r,e._targetR,o))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style.opacity=Fe(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),e.y=Fe(n.y,e._targetY,o),void 0!==e._targetR&&void 0!==n.r&&(e.size=Fe(n.r,e._targetR,o))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style.opacity=Fe(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),e.y=Fe(n.y,e._targetY,o),void 0!==n.w&&(e.w=Fe(n.w,e._targetW,o)),void 0!==n.h&&(e.h=Fe(n.h,e._targetH,o))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style={...e.style||{},opacity:Fe(n?n.opacity??1:0,e._targetOpacity,o)}}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),e.y=Fe(n.y,e._targetY,o),void 0!==n.w&&(e.w=Fe(n.w,e._targetW,o)),void 0!==n.h&&(e.h=Fe(n.h,e._targetH,o))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?i.get(t):void 0;e.style={...e.style||{},opacity:Fe(n?n.opacity??1:0,e._targetOpacity,o)}}if(void 0===e._targetX)continue;if(!t)continue;const n=i.get(t);if(!n)continue;e.x=Fe(n.x,e._targetX,o),void 0!==n.openY&&(e.openY=Fe(n.openY,e._targetOpenY,o)),void 0!==n.closeY&&(e.closeY=Fe(n.closeY,e._targetCloseY,o)),void 0!==n.highY&&(e.highY=Fe(n.highY,e._targetHighY,o)),void 0!==n.lowY&&(e.lowY=Fe(n.lowY,e._targetLowY,o))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Fe(e._startOpacity??0,e._targetOpacity,o)}),void 0!==e._introClipFraction&&(e._introClipFraction=o);const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let i=0;e.path.length>i;i++)e.path[i][0]=Fe(t[i][0],n[i][0],o),e.path[i][1]=Fe(t[i][1],n[i][1],o)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Fe(e._startOpacity??0,e._targetOpacity,o)}),void 0!==e._introClipFraction&&(e._introClipFraction=o);const t=e._prevTopPath,n=e._prevBottomPath,i=e._targetTopPath,r=e._targetBottomPath;if(t&&i&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=Fe(t[n][0],i[n][0],o),e.topPath[n][1]=Fe(t[n][1],i[n][1],o);if(n&&r&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Fe(n[t][0],r[t][0],o),e.bottomPath[t][1]=Fe(n[t][1],r[t][1],o)}}if(r>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style="line"===e.type||"area"===e.type?{...e.style,opacity:0===t?0:t}:{...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("glyph"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.size=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("candlestick"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,void 0!==e._targetOpenY&&(e.openY=e._targetOpenY),void 0!==e._targetCloseY&&(e.closeY=e._targetCloseY),void 0!==e._targetHighY&&(e.highY=e._targetHighY),void 0!==e._targetLowY&&(e.lowY=e._targetLowY),e._targetX=void 0,e._targetOpenY=void 0,e._targetCloseY=void 0,e._targetHighY=void 0,e._targetLowY=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const e of this.scene)"line"!==e.type&&"area"!==e.type||(e._introClipFraction=void 0)}groupData(e){const{result:t,cache:n}=function(e,t,n,i){if(i&&i.version===n&&i.group===t&&i.data===e)return{result:i.result,cache:i};let r;if(t){const n=new Map;for(const i of e){const e=t(i);n.has(e)||n.set(e,[]),n.get(e).push(i)}r=Array.from(n.entries()).map(([e,t])=>({key:e,data:t}))}else r=[{key:"_default",data:e}];return{result:r,cache:{version:n,group:t,data:e,result:r}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,t}resolveColorMap(e){const{map:t,cache:n}=function(e,t,n,i,r){if(r&&r.version===i)return{map:r.map,cache:r};const o=new Set;if(t)for(const n of e){const e=t(n);e&&o.add(e)}const s=Array.from(o).sort(),a=s.join("\0");if(r&&r.key===a){const e={...r,version:i};return{map:e.map,cache:e}}const c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||R,l=new Map;for(let e=0;s.length>e;e++)l.set(s[e],c[e%c.length]);return{map:l,cache:{key:a,map:l,version:i}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,t}resolveLineStyle(e,t){return function(e,t,n,i){const r=e.lineStyle;if("function"==typeof r){const e=r(n||{},t);if(e&&!e.stroke&&t){const n=i(t);if(n)return{...e,stroke:n}}return e}const o=e.themeSemantic?.primary;return r&&"object"==typeof r?{stroke:r.stroke||o||"#007bff",strokeWidth:r.strokeWidth||2,strokeDasharray:r.strokeDasharray,fill:r.fill,fillOpacity:r.fillOpacity,opacity:r.opacity}:{stroke:i(t)||o||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,n,i){if(e.areaStyle){const r=e.areaStyle(n||{});if(r&&!r.fill&&t){const e=i(t);if(e)return{...r,fill:e,stroke:r.stroke||e}}return r}const r=e.lineStyle;if("function"==typeof r){const e=r(n||{},t);if(e&&!e.fill&&t){const n=i(t);if(n)return{...e,fill:n,stroke:e.stroke||n}}return e}const o=e.themeSemantic?.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||o||"#4e79a7",fillOpacity:r.fillOpacity??.7,stroke:r.stroke||o||"#4e79a7",strokeWidth:r.strokeWidth||2};const s=i(t)||o||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:n,groupColorCounter:i}=function(e){const{group:t,colorMapCache:n,groupColorMap:i,groupColorMapCap:r,config:o}=e;let{groupColorCounter:s}=e;if(n){const e=n.map.get(t);if(e)return{color:e,groupColorCounter:s}}const a=i.get(t);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(o.colorScheme)&&o.colorScheme.length>0?o.colorScheme:null)||(Array.isArray(o.themeCategorical)&&o.themeCategorical.length>0?o.themeCategorical:null)||R;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,i.set(t,l),i.size>r){const e=i.keys().next().value;void 0!==e&&i.delete(e)}return{color:l,groupColorCounter:s}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=i,n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}getLastUpdateResult(){return this.updateResults.last}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=De(e),n=this.getPointId,i=e=>t.has(n(e));Ct(this.buffer,this.timestampBuffer,i);const r=this.buffer.remove(i);if(0===r.length)return this.updateResults.recordNoop("remove"),r;for(const e of r)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=Ne(),this.updateResults.recordData("remove",r.length),r}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=De(e),i=this.getPointId,r=new Set;this.buffer.forEach((e,t)=>{n.has(i(e))&&r.add(t)});const o=this.buffer.update(e=>n.has(i(e)),t);if(0===o.length)return this.updateResults.recordNoop("update"),o;for(const e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{r.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=Ne(),this.updateResults.recordData("update",o.length),o}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}setLayoutSelection(e){this.config.layoutSelection=e}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const i of e){const e=this._baseStyles.get(i)??i.style??{},r=n(i,t);i.style=r?{...e,...r}:e}}consumeStylePaintPending(){const e=this._stylePaintPending;return this._stylePaintPending=!1,e}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this._stylePaintPending=!0,this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const t={...this.config},n=Object.keys(e).filter(n=>e[n]!==t[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let i=!1,r=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const o="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(o||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,n=e&&this.config.valueAccessor||this.config.yAccessor,s=e&&t.valueAccessor||t.yAccessor,a=o||!Ce(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=o||!Ce(n,s);(a||c)&&(e?(this.getX=Ie(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Ie(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Ie(this.config.xAccessor,"x"),this.getY=Ie(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=kt(this.config)),i=!0,r=!0)}if("groupAccessor"in e&&!Ce(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Re(this.config.groupAccessor):void 0,i=!0),"categoryAccessor"in e&&!Ce(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Re(this.config.categoryAccessor):void 0,i=!0),"sizeAccessor"in e&&!Ce(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Ie(this.config.sizeAccessor,"size"):void 0,i=!0),"symbolAccessor"in e&&!Ce(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Re(this.config.symbolAccessor):void 0,i=!0),"colorAccessor"in e&&!Ce(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Re(this.config.colorAccessor):void 0,i=!0),"y0Accessor"in e&&!Ce(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?Ie(this.config.y0Accessor,"y0"):void 0,i=!0,r=!0),("boundsAccessor"in e&&!Ce(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=kt(this.config),i=!0,r=!0),"pointIdAccessor"in e&&!Ce(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Re(this.config.pointIdAccessor):void 0,i=!0),"candlestick"===this.config.chartType&&(o||"openAccessor"in e&&!Ce(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!Ce(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!Ce(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!Ce(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?Ie(this.config.openAccessor,"open"):void 0,this.getHigh=Ie(this.config.highAccessor,"high"),this.getLow=Ie(this.config.lowAccessor,"low"),this.getClose=t?Ie(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,i=!0,r=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(i=!0,r=!0),!i){const n=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const r of n)if(e[r]!==t[r]){i=!0;break}}i&&(r&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n,i,r)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};Nt.GROUP_COLOR_MAP_CAP=1e3;var Ot=Nt,Wt={sceneGeometry:0,layout:0,domain:0},qt="production"!==process.env.NODE_ENV,Yt={revisions:Wt,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},Ht=class{constructor(){this.lastConsumed=Wt,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}beforeCompute(e,t){if(!qt)return Yt;const n=function(e){const{domain:t,layout:n,sceneGeometry:i}=e.revisions;return{domain:t,layout:n,sceneGeometry:i}}(e),i=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),r=!((o=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&o.layout===s.layout&&o.domain===s.domain);var o,s;return{revisions:n,signature:i,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:r,warnUnconsumed:!t&&r&&this.lastUnconsumedWarning!==i}}afterCompute(e,t,n){if(qt){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] StreamXYFrame observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] StreamXYFrame performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}},Xt=c(require("react"));function Gt(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:Xt.createElement(Xt.Fragment,null,...t)}var Vt=c(require("react")),Ut=require("react/jsx-runtime"),Kt=Vt.createContext(null);function Zt({value:e,children:t}){return(0,Ut.jsx)(Kt.Provider,{value:e,children:t})}function Qt(e,t){return null!=e?(0,Ut.jsx)(Zt,{value:t,children:e}):e}var Jt=require("react");function en(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function tn(e,t=30){return Math.max((e??4)+5,12,t)}function nn(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function rn(e,t){const n=nn(e);if(!n)return!1;const i=nn(t);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}var on=[40,40],sn=[.5,.5];function an(e,t){const[n,i]=e.viewBox??on,[r,o]=e.anchor??sn,s=i>0?i:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-o*l}}function cn(e,t,n,i){if("none"!==e)return"color"===e||null==e?t??i:"accent"===e?n:e}var ln=null;function un(e){if("undefined"==typeof Path2D)return null;ln||(ln=new Map);const t=ln.get(e);if(t)return t;const n=new Path2D(e);return ln.size>1024&&ln.clear(),ln.set(e,n),n}function dn(e,t,n=0,i="horizontal"){const[r,o]=e.viewBox??on,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===i?{x:0,y:o*(1-a),width:r,height:o*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:o}:null:{x:0,y:0,width:0,height:0}}function hn(e,t){const n=an(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function fn(e,t,n,i,r,o=e=>e){for(const s of t.parts){const t=un(s.d);if(!t)continue;const a=s.opacity??1,c=e.globalAlpha;1!==a&&(e.globalAlpha=c*a);const l=r?"none"===s.fill?void 0:r:cn(s.fill,n,i);l&&(e.fillStyle=o(l),e.fill(t));const u=r?s.stroke&&"none"!==s.stroke?r:void 0:cn(s.stroke??"none",n,i);u&&(e.strokeStyle=o(u),e.lineWidth=s.strokeWidth??1,e.lineCap=s.strokeLinecap??"butt",e.lineJoin=s.strokeLinejoin??"miter",e.stroke(t)),1!==a&&(e.globalAlpha=c)}}var pn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,yn=new WeakMap,gn=0,mn=!1,xn=null,bn=null;function vn(e,t){if(!t)return t;const n=pn.exec(t);if(!n)return t;const i=e.canvas;if(!i)return n[2]?.trim()||t;!function(){if(mn)return;if("undefined"==typeof window||"undefined"==typeof document)return;mn=!0;const e=()=>{gn++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]}),"function"==typeof window.matchMedia)try{xn=window.matchMedia("(prefers-color-scheme: dark)"),bn=e,"function"==typeof xn.addEventListener?xn.addEventListener("change",bn):"function"==typeof xn.addListener&&xn.addListener(bn)}catch{}}();let r=yn.get(i);r&&r.version===gn||(r={version:gn,map:new Map},yn.set(i,r));const o=r.map.get(t);if(void 0!==o)return o;const s=getComputedStyle(i).getPropertyValue(n[1]).trim()||n[2]?.trim()||t;return r.map.set(t,s),s}var wn=require("d3-shape");function kn(e){switch(e){case"monotoneX":return wn.curveMonotoneX;case"monotoneY":return wn.curveMonotoneY;case"cardinal":return wn.curveCardinal;case"catmullRom":return wn.curveCatmullRom;case"step":return wn.curveStep;case"stepBefore":return wn.curveStepBefore;case"stepAfter":return wn.curveStepAfter;case"basis":return wn.curveBasis;case"natural":return wn.curveNatural;default:return null}}function Sn(e,t,n){return null==t?n:"string"!=typeof t?t:vn(e,t)||n}function An(e,t,n,i,r,o,s){if("colorStops"in t){const n=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>n.length)return null;const a=e.createLinearGradient(i,r,o,s);for(const e of n)a.addColorStop(e.offset,e.color);return a}const{topOpacity:a,bottomOpacity:c}=t;if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,c)),d=e.createLinearGradient(i,r,o,s),[h,f,p]=function(e,t){const n=e.fillStyle,i="#010203";try{e.fillStyle=i,e.fillStyle=t}catch{return e.fillStyle=n,[78,121,167]}const r=e.fillStyle;if(e.fillStyle=n,"string"!=typeof r)return[78,121,167];if(r.toLowerCase()===i&&t.trim().toLowerCase()!==i)return[78,121,167];if(r.startsWith("#"))return[parseInt(r.slice(1,3),16),parseInt(r.slice(3,5),16),parseInt(r.slice(5,7),16)];const o=r.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return o?[+o[1],+o[2],+o[3]]:[78,121,167]}(e,n);return d.addColorStop(0,`rgba(${h},${f},${p},${l})`),d.addColorStop(1,`rgba(${h},${f},${p},${u})`),d}function Mn(e,t,n,i,r,o){const s=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>s.length)return null;const a=e.createLinearGradient(n,i,r,o);for(const e of s)a.addColorStop(e.offset,e.color);return a}var Pn=require("d3-shape"),_n=new WeakMap;function jn(e,t){const n=kn(t);if(!n)return e;const i=_n.get(e);if(i)return i;const r=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const i=[];let r=null;const o={moveTo(e,t){r=[e,t],i.push([e,t])},lineTo(e,t){r=[e,t],i.push([e,t])},bezierCurveTo(e,t,o,s,a,c){if(!r)return r=[a,c],void i.push([a,c]);const[l,u]=r;for(let r=1;n>=r;r++){const d=r/n,h=1-d;i.push([h*h*h*l+3*h*h*d*e+3*h*d*d*o+d*d*d*a,h*h*h*u+3*h*h*d*t+3*h*d*d*s+d*d*d*c])}r=[a,c]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,o){r=[n,o],i.push([n,o])}};return(0,Pn.line)().x(e=>e[0]).y(e=>e[1]).curve(t).context(o)(e),i}(e,n);return _n.set(e,r),r}function Cn(e,t,n,i=30,r,o=0){let s=null;if(r){const e=function(e,t,n,i,r,o=e=>e.x,s=e=>e.y,a=e=>e.r){const c=Math.max(i,r+5,12),l=t-c,u=t+c,d=n-c,h=n+c;let f=null,p=1/0;return e.visit((e,r,c,y,g)=>{if(r>u||l>y||c>h||d>g)return!0;if(!e.length){let r=e;do{const e=r.data,c=o(e)-t,l=s(e)-n,u=Math.sqrt(c*c+l*l);tn(a(e),i)>=u&&p>u&&(f=e,p=u),r=r.next}while(r)}return!1}),f?{node:f,distance:p}:null}(r,t,n,i,o);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const o of e){let e=null;switch(o.type){case"point":if(r)break;e=Tn(o,t,n,i);break;case"symbol":e=Rn(o,t,n,i);break;case"glyph":e=Ln(o,t,n,i);break;case"line":e=$n(o,t,n,i);break;case"rect":if(null==o.datum)break;e=Dn(o,t,n);break;case"heatcell":e=zn(o,t,n);break;case"area":if(!1===o.interactive)break;e=Fn(o,t,n);break;case"candlestick":e=Bn(o,t,n)}e&&i>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function In(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const i=Nn(e,t);if(0>i)return null;if(Math.abs(e[i][0]-t)>n)return null;let r=i,o=i;i>0&&e[i][0]>=t?(r=i-1,o=i):e.length-1>i&&(r=i,o=i+1);const[s,a]=e[r],[c,l]=e[o];return c===s?a:a+Math.max(0,Math.min(1,(t-s)/(c-s)))*(l-a)}function Tn(e,t,n,i=30){const r=t-e.x,o=n-e.y,s=Math.sqrt(r*r+o*o);return s>tn(e.r,i)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Rn(e,t,n,i=30){const r=t-e.x,o=n-e.y,s=Math.sqrt(r*r+o*o);return s>tn(ft(e.size),i)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Ln(e,t,n,i=30){if(null==e.datum)return null;const r=hn(e.glyph,e.size),o=e.x+r.centerDx,s=e.y+r.centerDy,a=t-o,c=n-s,l=Math.sqrt(a*a+c*c);return l>tn(r.radius,i)?null:{node:e,datum:e.datum,x:o,y:s,distance:l}}function $n(e,t,n,i=30){if(0===e.path.length)return null;const r=Nn(e.path,t);if(0>r)return null;const[o,s]=e.path[r];let a;if(e.path.length>1){let i=1/0;const o=Math.max(0,r-1),s=Math.min(e.path.length-2,r);for(let r=o;s>=r;r++){const[o,s]=e.path[r],[a,c]=e.path[r+1],l=En(t,n,o,s,a,c);i>l&&(i=l)}a=i}else{const e=t-o,i=n-s;a=Math.sqrt(e*e+i*i)}const c=e.style;return a>Math.max(5,(c.strokeWidth??c.lineWidth??1)/2+2,i)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:o,y:s,distance:a}}function En(e,t,n,i,r,o){const s=r-n,a=o-i,c=s*s+a*a;if(0===c)return Math.sqrt((e-n)**2+(t-i)**2);let l=((e-n)*s+(t-i)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((e-(n+l*s))**2+(t-(i+l*a))**2)}function Dn(e,t,n){const i=en(t,n,e);return i.hit?{node:e,datum:e.datum,x:i.cx,y:i.cy,distance:0}:null}function zn(e,t,n){const i=en(t,n,e);return i.hit?{node:e,datum:e.datum,x:i.cx,y:i.cy,distance:0}:null}function Bn(e,t,n){const i=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-i-3>t||t>e.x+i+3||e.highY-3>n||n>e.lowY+3)){const i=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,o=t-e.x,s=n-i;return{node:e,datum:e.datum,x:e.x,y:i,distance:Math.sqrt(o*o+s*s)}}return null}function Fn(e,t,n){if(0===e.topPath.length)return null;const i=Nn(e.topPath,t);if(0>i)return null;const[r,o]=e.topPath[i],s=t-r,a=n-o,c=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[i]?e.datum[i]:e.datum,x:r,y:o,distance:c}}function Nn(e,t){if(0===e.length)return-1;let n=0,i=e.length-1;for(;i>n;){const r=n+i>>1;t>e[r][0]?n=r+1:i=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function On(e,t,n){const i=e.byGroup.get(t);let r=0,o=Math.abs(i[0].x-n.x);for(let e=1;i.length>e;e++){const t=Math.abs(i[e].x-n.x);o>t&&(o=t,r=e)}return i[r]._flatIndex}function Wn(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}var qn=require("react"),Yn={fresh:1,aging:.7,stale:.45,expired:.25},Hn={alpha:1,band:"fresh",isStale:!1};function Xn(e,t){if(!e||0>=t)return Hn;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,i=e.graded;if(i){const e="object"==typeof i?i:{},r=function(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}(t,n,e.thresholds);return{alpha:{...Yn,...e.opacities??{}}[r],band:r,isStale:"fresh"!==r}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:Hn}var Gn=require("react/jsx-runtime");function Vn({isStale:e,position:t}){return(0,Gn.jsx)("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}var Un=require("react"),Kn=c(require("react")),Zn=require("react/jsx-runtime"),Qn={fill:(e,t)=>(0,Zn.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,Zn.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Jn(e,t,n,i,r){let o;return o="function"==typeof n?n(e):(0,Qn[n])(i(e,t),r),o}function ei({swatchSize:e}){return(0,Zn.jsx)("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function ti(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var ni=(e,t,n,i,r,o,s,a,c,l,u)=>{const{type:d="fill",styleFn:h,items:f}=e,p=[];let y=0;const g=!(!t&&!n),m="isolate"===l||void 0===l&&null!=r,{swatchSize:x,labelGap:b,rowHeight:v}=u;return f.forEach((e,l)=>{const u=Jn(e,l,d,h,x),w=ti(e,i,r),k=r&&r.size>0&&r.has(e.label);p.push((0,Zn.jsxs)("g",{transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===o&&l===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?k||!1:void 0,"aria-current":g&&!m&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:g?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(l+("ArrowDown"===n.key?1:-1)+f.length)%f.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{c(a,l),n&&n(e);const i=t.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.setAttribute("visibility","visible")}:void 0,onBlur:g?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&(0,Zn.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+b+2+7*e.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,k&&(0,Zn.jsx)(ei,{swatchSize:x}),(0,Zn.jsx)("text",{y:x/2,x:x+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+l)),y+=v}),p};function ii({config:e,orientation:t="vertical",width:n=100}){const{colorFn:i,domain:r,label:o,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+Kn.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,Zn.jsx)("stop",{offset:100*t+"%",stopColor:i(r[0]+t*(r[1]-r[0]))},e))}return(0,Zn.jsxs)("g",{"aria-label":o||"Gradient legend",children:[(0,Zn.jsx)("defs",{children:(0,Zn.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),o&&(0,Zn.jsx)("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:o}),(0,Zn.jsx)("rect",{x:s,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),(0,Zn.jsx)("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])}),(0,Zn.jsx)("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])})]})}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,Zn.jsx)("stop",{offset:100*t+"%",stopColor:i(r[1]-t*(r[1]-r[0]))},e))}return(0,Zn.jsxs)("g",{"aria-label":o||"Gradient legend",children:[o&&(0,Zn.jsx)("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:o}),(0,Zn.jsx)("defs",{children:(0,Zn.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),(0,Zn.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),(0,Zn.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])}),(0,Zn.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])})]})}function ri(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,legendInteraction:s,title:a="Legend",width:c=100,height:l=20,orientation:u="vertical",legendLayout:d}=e,h=function(e){const t=Math.max(1,e?.swatchSize??16),n=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}(d),[f,p]=Kn.useState(0),[y,g]=Kn.useState(0),m=Kn.useCallback((e,t)=>{p(e),g(t)},[]),x="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:l,metrics:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push((0,Zn.jsx)("line",{stroke:"gray",x1:0,y1:d,x2:t,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,e.label&&(d+=16,h.push((0,Zn.jsx)("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d+=8),h.push((0,Zn.jsx)("g",{className:"legend-item",transform:`translate(0,${d})`,children:ni(e,n,i,r,o,s,a,f,c,l,u)},"legend-group-"+f)),d+=e.items.length*u.rowHeight+8}),h})({legendGroups:t||[],width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:u,metrics:d})=>{let h=0;const f=[];e.forEach((e,t)=>{let p=0;e.label&&(p+=16);const y=((e,t,n,i,r,o,s,a,c,l,u,d)=>{const{type:h="fill",styleFn:f,items:p}=e,y=[],{swatchSize:g,labelGap:m,itemGap:x,rowHeight:b,align:v}=u,w=!(!t&&!n),k="isolate"===l||void 0===l&&null!=r,S=p.map(e=>g+m+7*e.label.length),A=[];let M=0,P=0;S.forEach((e,t)=>{const n=0===P?e:P+x+e;d&&d>0&&P>0&&n>d?(A.push({start:M,end:t,width:P}),M=t,P=e):P=n}),p.length>0&&A.push({start:M,end:p.length,width:P}),A.forEach((e,l)=>{let u="center"===v?Math.max(0,((d??e.width)-e.width)/2):"end"===v?Math.max(0,(d??e.width)-e.width):0;for(let d=e.start;e.end>d;d++){const e=p[d],v=Jn(e,d,h,f,g),A=ti(e,i,r),M=r&&r.size>0&&r.has(e.label);y.push((0,Zn.jsxs)("g",{transform:`translate(${u},${l*b})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:w?a===o&&d===s?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&k?M||!1:void 0,"aria-current":w&&!k&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:w?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(d+("ArrowRight"===n.key?1:-1)+p.length)%p.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:w?t=>{c(a,d),n&&n(e);const i=t.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.setAttribute("visibility","visible")}:void 0,onBlur:w?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&(0,Zn.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+m+2+7*e.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,M&&(0,Zn.jsx)(ei,{swatchSize:g}),(0,Zn.jsx)("text",{y:g/2,x:g+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+d)),u+=S[d]+x}});const _=Math.max(0,...A.map(e=>e.width)),j=A.length;return{items:y,offset:_,totalRows:j,totalHeight:j*b}})(e,i,r,o,s,a,c,t,l,u,d,d.maxWidth??n);p+=y.offset+5,f.push({label:e.label,...y,offset:p,totalRows:y.totalRows,totalHeight:y.totalHeight}),h+=p+12});const p=d.maxWidth??n;let y=h>p?0:"center"===d.align?Math.max(0,(p-h)/2):"end"===d.align?Math.max(0,p-h):0;const g=[];return f.forEach((n,i)=>{const r=e[i];r.label&&(g.push((0,Zn.jsx)("text",{transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+i)),y+=16),g.push((0,Zn.jsx)("g",{className:"legend-item",transform:`translate(${y},0)`,children:n.items},"legend-group-"+i)),y+=n.offset+5,e[i+1]&&g.push((0,Zn.jsx)("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+i)),y+=12}),(0,Zn.jsx)("g",{children:g})})({legendGroups:t||[],title:a,height:l,width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}),b=!(!n&&!i);return(0,Zn.jsxs)("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==o))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&(0,Zn.jsx)("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),x]})}function oi(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function si(e){return"object"==typeof e&&null!==e&&"gradient"in e}var ai=require("react/jsx-runtime");function ci(e){const{legend:t,totalWidth:n,totalHeight:i,margin:r,legendPosition:o="right",legendLayout:s,title:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!t)return null;const f="top"===o||"bottom"===o,p=!!a,y=Math.max(0,n-r.left-r.right),g=Math.max(1,f?s?.maxWidth??y:100);let m,x;return"left"===o?(m=Math.max(4,r.left-g-10),x=r.top):"top"===o?(m=r.left,x=p?32:8):"bottom"===o?(m=r.left,x=i-r.bottom+38):(m=n-r.right+10,x=r.top),(0,ai.jsx)("g",{transform:`translate(${m}, ${x})`,children:si(t)?(0,ai.jsx)(ii,{config:t.gradient,orientation:f?"horizontal":"vertical",width:g}):oi(t)?(0,ai.jsx)(ri,{legendGroups:t.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:c,customClickBehavior:l,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):t})}var li=require("react"),ui=require("d3-array");function di(e){let t=1/0,n=-1/0;for(const i of e)t>i&&(t=i),i>n&&(n=i);return[t,n]}function hi(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}var fi=require("react/jsx-runtime");function pi(e){return"string"==typeof e?{type:e}:e}function yi({orient:e,config:t,values:n,scale:i,size:r,length:o}){const s=function(e){return{type:e.type,bins:e.bins??20,fill:e.fill??"#4e79a7",fillOpacity:e.fillOpacity??.5,stroke:e.stroke??"none",strokeWidth:e.strokeWidth??1}}(t),a="top"===e||"bottom"===e,c=(0,li.useMemo)(()=>{if(0===n.length)return null;const t=i.domain(),c=r-8;if("boxplot"===s.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const i=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],o=t[Math.floor(.75*n)],s=o-i;return{q1:i,median:r,q3:o,whiskerLow:Math.max(t[0],i-1.5*s),whiskerHigh:Math.min(t[n-1],o+1.5*s)}}(n);if(!t)return null;const{q1:r,median:o,q3:l,whiskerLow:u,whiskerHigh:d}=t,h=Math.min(.5*c,20),f=(c-h)/2+4;if(a){const t=i(r),n=i(l),a=i(o),c=i(u),p=i(d),y="top"===e?-1:1,g=0;return(0,fi.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,fi.jsx)("line",{x1:c,y1:g+y*(f+h/2),x2:p,y2:g+y*(f+h/2),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:c,y1:g+y*f,x2:c,y2:g+y*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:p,y1:g+y*f,x2:p,y2:g+y*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("rect",{x:Math.min(t,n),y:"top"===e?g-f-h:g+f,width:Math.abs(n-t),height:h,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:a,y1:"top"===e?g-f-h:g+f,x2:a,y2:"top"===e?g-f:g+f+h,stroke:s.fill,strokeWidth:2})]})}{const t=i(r),n=i(l),a=i(o),c=i(u),p=i(d),y="left"===e?-1:1,g=0;return(0,fi.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,fi.jsx)("line",{x1:g+y*(f+h/2),y1:c,x2:g+y*(f+h/2),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:g+y*f,y1:c,x2:g+y*(f+h),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:g+y*f,y1:p,x2:g+y*(f+h),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,fi.jsx)("rect",{x:"left"===e?g-f-h:g+f,y:Math.min(t,n),width:h,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,fi.jsx)("line",{x1:"left"===e?g-f-h:g+f,y1:a,x2:"left"===e?g-f:g+f+h,y2:a,stroke:s.fill,strokeWidth:2})]})}}const l=(0,ui.bin)().domain(t).thresholds(s.bins)(n);if(0===l.length)return null;const u=hi(l.map(e=>e.length));if(0===u)return null;if("histogram"===s.type)return(0,fi.jsx)("g",{"data-testid":"marginal-histogram-"+e,children:l.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const r=t.length/u*c;if(a){const o=i(t.x0),a=i(t.x1)-i(t.x0);return(0,fi.jsx)("rect",{x:o,y:"top"===e?-4-r:4,width:Math.max(a,.5),height:r,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const o=i(t.x0),a=i(t.x1)-i(t.x0);return(0,fi.jsx)("rect",{x:"left"===e?-4-r:4,y:Math.min(o,o+a),width:r,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const t=c/2+4,n=[];for(const r of l){if(null==r.x0||null==r.x1)continue;const o=r.length/u*(c/2),s=i((r.x0+r.x1)/2);n.push(a?`${s},${"top"===e?-(t-o):t-o}`:`${"left"===e?-(t-o):t-o},${s}`)}for(let r=l.length-1;r>=0;r--){const o=l[r];if(null==o.x0||null==o.x1)continue;const s=o.length/u*(c/2),d=i((o.x0+o.x1)/2);n.push(a?`${d},${"top"===e?-(t+s):t+s}`:`${"left"===e?-(t+s):t+s},${d}`)}return(0,fi.jsx)("g",{"data-testid":"marginal-violin-"+e,children:(0,fi.jsx)("polygon",{points:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}if("ridgeline"===s.type){const t=[];if(a){const n=0,r=null!=l[0].x0?i(l[0].x0):0;t.push(`M${r},${n}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const r=n.length/u*c,o=i((n.x0+n.x1)/2);t.push(`L${o},${"top"===e?-r-4:r+4}`)}const s=null!=l[l.length-1].x1?i(l[l.length-1].x1):o;t.push(`L${s},${n}`),t.push("Z")}else{const n=0,r=null!=l[0].x0?i(l[0].x0):0;t.push(`M${n},${r}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const r=n.length/u*c,o=i((n.x0+n.x1)/2);t.push(`L${"left"===e?-r-4:r+4},${o}`)}const s=null!=l[l.length-1].x1?i(l[l.length-1].x1):o;t.push(`L${n},${s}`),t.push("Z")}return(0,fi.jsx)("g",{"data-testid":"marginal-ridgeline-"+e,children:(0,fi.jsx)("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,i,s,r,o,e,a,4]);return c?(0,fi.jsx)("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:c}):null}var gi=c(require("react")),mi=require("react/jsx-runtime");function xi(e,t=120,n=8){if(!e)return[];const i=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),o=[];let s="";for(const e of r)s&&s.length+1+e.length>i?(o.push(s),s=e):s=s?`${s} ${e}`:e;return s&&o.push(s),o}function bi(e,t,n,i){return"curly"===e?i?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:i?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function vi(e,t,n,i){if(!e)return(0,mi.jsx)("g",{className:"annotation-note"});const{label:r,title:o,orientation:s,align:a,wrap:c=120,noWrap:l}=e;if(!r&&!o)return(0,mi.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,p=o?l?[o]:xi(o,c):[],y=r?l?[r]:xi(r,c):[],g="leftRight"===u?"end"===h?-4:4:0;let m=0;const x=[],b=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?x.push((0,mi.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===h?g-c:"middle"===h?g-c/2:g,y:-16,width:c,height:Math.max(f,(p.length+y.length)*f+(o&&r?2:0))+f,style:{overflow:"visible"},children:(0,mi.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[o&&(0,mi.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:o}),r&&(0,mi.jsx)("div",{className:"annotation-note-label",children:r})]})},"annotation-note-html")):(p.length>0&&(x.push((0,mi.jsx)("text",{className:"annotation-note-title",fill:b,textAnchor:h,fontWeight:"bold",children:p.map((e,t)=>(0,mi.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=p.length*f),y.length>0&&x.push((0,mi.jsx)("text",{className:"annotation-note-label",fill:b,textAnchor:h,y:m,children:y.map((e,t)=>(0,mi.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let v=null;if((o||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(c,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),v=(0,mi.jsx)("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+y.length)*f+(y.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),v=(0,mi.jsx)("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let k=0;return"topBottom"===u?k=0>n?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),(0,mi.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,mi.jsx)("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:x}),v]})}function wi(e,t,n,i,r){const o=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&o.push((0,mi.jsx)("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,i=t?.height||0;(e>0||i>0)&&o.push((0,mi.jsx)("rect",{width:e,height:i,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&o.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=i||0,s=r||0;if(void 0!==t?.x){const i=(t.x||0)-e;o.push((0,mi.jsx)("line",{x1:i,y1:(t.y1||0)-s,x2:i,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const i=(t.y||0)-s;o.push((0,mi.jsx)("line",{x1:(t.x1||0)-e,y1:i,x2:(t.x2||0)-e,y2:i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?o.push((0,mi.jsx)("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||o.push((0,mi.jsx)("line",{x1:0,y1:(t.y1||0)-s,x2:0,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",i=t?.width??t?.height;void 0!==i&&o.push((0,mi.jsx)("path",{d:bi(e,i,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,mi.jsx)("g",{className:"annotation-subject",children:o})}function ki(e,t,n,i,r,o){const s=[];let a=0,c=0;if("callout-circle"!==r&&"label"!==r||!o?.radius){if("callout-rect"===r&&o){const n=o.width||0,i=o.height||0;if(n>0||i>0){const r=n/2,o=i/2,s=e-r,l=t-o;if(0!==s||0!==l){const e=Math.abs(s),t=Math.abs(l),u=n/2,d=i/2,h=e*d>t*u?u/e:d/t;a=r+s*h,c=o+l*h}}}else if("bracket"===r&&o){const e=o.width,t=o.height,n=o.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=n,c=t/2)}}else{const n=(o.radius||0)+(o.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const i=Math.atan2(t,e);a=Math.cos(i)*n,c=Math.sin(i)*n}}const l=Math.sqrt((e-a)**2+(t-c)**2);if(l>.5){const r=i||"var(--semiotic-text-secondary, currentColor)",o="curve"===n?.type;let u=Math.atan2(t-c,e-a);if(o){const i=(a+e)/2,o=(c+t)/2,d=-(t-c)/l,h=(e-a)/l,f=(n?.curve??.25)*l,p=i+d*f,y=o+h*f;s.push((0,mi.jsx)("path",{className:"connector-curve",d:`M${a},${c}Q${p},${y} ${e},${t}`,fill:"none",stroke:r},"connector-line")),u=Math.atan2(y-c,p-a)}else s.push((0,mi.jsx)("line",{x1:a,y1:c,x2:e,y2:t,stroke:r},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push((0,mi.jsx)("path",{d:`M${a},${c}L${a+e*Math.cos(u+t)},${c+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${c+e*Math.sin(u-t)}Z`,fill:r,stroke:"none"},"connector-arrow"))}}return(0,mi.jsx)("g",{className:"annotation-connector",children:s})}function Si(e){const{x:t=0,y:n=0,dx:i,dy:r,nx:o,ny:s,note:a,connector:c,subject:l,type:u,color:d,className:h,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=e,x=Array.isArray(t)?t[0]??0:t,b=Array.isArray(n)?n[0]??0:n,v=new Set(Array.isArray(f)?f:[]);let w=i||0,k=r||0;null!=o&&(w=o-x),null!=s&&(k=s-b);const S="string"==typeof u?u:"label";if("bracket"===S&&l&&0===w&&0===k)if(void 0!==l.width){w=l.width/2;const e=l.depth||30;k=e+(0>e?-5:5)}else if(void 0!==l.height){const e=l.depth||30;w=e+(0>e?-5:5),k=l.height/2}return(0,mi.jsxs)("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.has("connector")&&ki(w,k,c,d,S,l),!v.has("subject")&&wi(S,l,d,x,b),!v.has("note")&&vi(a,w,k,d)]})}function Ai(e){const{noteData:t}=e,{screenCoordinates:n}=t,i="string"==typeof t.type?t.type:"label",r=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),r=t.ny||n[0][1]+(t.dy??0),o=n.map((n,o)=>{const s=Object.assign({},t,{note:0===o?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:r});return(0,mi.jsx)(Si,{"data-testid":"semiotic-annotation",...s,type:i},"multi-annotation-"+o)});return(0,mi.jsx)("g",{children:o})}const o=t.note||{title:"none",label:t.label},s=`${o.label}-${o.title}-${t.i}`;return(0,mi.jsx)(Si,{"data-testid":"semiotic-annotation",events:r,...t,type:i},s)}var Mi=require("d3-hierarchy"),Pi=require("d3-shape"),_i=c(require("regression"));function ji(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function Ci(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function Ii(e){return null==e?null:e+""}function Ti(e,t,n){return t.stickyPositionCache?.set(e,n),n}function Ri(e,t,n){const i=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===i){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let i=n.pointNodes.length-1;i>=0;i--){const r=n.pointNodes[i];if(r.pointId===e.pointId)return Ti(t,n,{x:r.x,y:r.y})}const i=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],i=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!i||!r)return null;const o=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==o||null==s?null:{x:i(o),y:r(s)}}(n);return i?Ti(t,n,i):null}if("semantic"===i){const i=function(e,t,n){const i=function(e){return Ii(e.provenance?.stableId??e.stableId)}(e);if(!i)return null;const r=n.pointNodes?.find(e=>Ii(e.pointId)===i);if(r)return Ti(t,n,{x:r.x,y:r.y});const o=n.data?.find(e=>function(e){return Ii(e.stableId??e.id??e.provenance?.stableId)}(e)===i);if(!o)return null;const s=ji(o,n),a=Ci(o,n);return null==s||null==a?null:Ti(t,n,{x:s,y:a})}(e,t,n);if(i)return i}let r=null,o=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,o=t.y)}if(null!=r&&null!=o||(r=ji(e,n),o=Ci(e,n)),null!=r&&null!=o)return Ti(t,n,{x:r,y:o});if("sticky"===i){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function Li(e,t,n,i=50){return!(-i>e||e>(n.width||0)+i||-i>t||t>(n.height||0)+i)}var $i=require("react/jsx-runtime"),Ei={secondary:0,primary:3},Di=1,zi=2,Bi=.6,Fi="0.88em",Ni=.95,Oi=.72,Wi=.06,qi=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}",Yi=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}";function Hi(e){return!0===e?._annotationDeferred}function Xi(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Gi(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function Vi(e){return Math.max(Oi,Ni-e*Wi)}function Ui(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:Gi(e.annotation),readingOrder:null,rank:Di};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),i=e.some(e=>Hi(e.annotation)),r=e.some(e=>null!=Xi(e.annotation)),o=e.some(e=>"layer"===Xi(e.annotation));if(!n&&!i&&!r)return e.map(e=>e.node);const s=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);s.forEach((e,t)=>{e.readingOrder=t,e.rank=zi-t/Math.max(1,s.length)});for(const e of t)e.emphasis&&(e.rank=Ei[e.emphasis]);const a=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:i,readingOrder:r}=e,o=Hi(t.annotation);let s=t.node;if("primary"===i||"secondary"===i||null!=r){const e=null==i&&null!=r;s=(0,$i.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+i,..."secondary"===i?{opacity:Bi,fontSize:Fi}:{},...e?{opacity:Vi(r),"data-annotation-reading-order":r}:{},children:t.node},"annotation-emphasis-"+n)}const a=Xi(t.annotation);return a&&(s=(0,$i.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),o&&(s=(0,$i.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return i&&a.unshift((0,$i.jsx)("style",{children:qi},"annotation-disclosure-style")),o&&a.unshift((0,$i.jsx)("style",{children:Yi},"annotation-cohesion-style")),a}var Ki=require("react/jsx-runtime"),Zi={linear:Pi.curveLinear,monotoneX:Pi.curveMonotoneX,monotoneY:Pi.curveMonotoneY,step:Pi.curveStep,stepAfter:Pi.curveStepAfter,stepBefore:Pi.curveStepBefore,basis:Pi.curveBasis,cardinal:Pi.curveCardinal,catmullRom:Pi.curveCatmullRom};function Qi(e,t,n,i){const r=[];return e.forEach((e,o)=>{let s;if(n){const r=n(e,o,i);s=null!=r?r:t(e,o,i)}else s=t(e,o,i);s&&r.push({node:s,annotation:e})}),Ui(r)}function Ji(e){return function(e,t,n){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const i=Ri(e,t,n);if(!i)return null;const{x:r,y:o}=i;if(!Li(r,o,n))return null;const s="callout"===e.type?"callout-circle":e.type,a="callout-circle"===s?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===s?{width:e.width,height:e.height}:void 0;return(0,Ki.jsx)(Ai,{noteData:{x:r,y:o,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:s,...a?{subject:a}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+t)}case"x-threshold":{const i=ji(null!=e.value?{...e,x:e.value}:e,n);if(null==i)return null;const r=e.color||"#f97316",o=e.labelPosition||"top";let s;s="bottom"===o?(n.height||0)-4:"center"===o?(n.height||0)/2:12;const a=i>.6*(n.width||0),c=a?i-4:i+4,l=a?"end":"start";return(0,Ki.jsxs)("g",{opacity:e.opacity,children:[(0,Ki.jsx)("line",{x1:i,y1:0,x2:i,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ki.jsx)("text",{x:c,y:s,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"y-threshold":{const i=Ci(null!=e.value?{...e,y:e.value}:e,n);if(null==i)return null;const r=e.color||"#f97316",o=e.labelPosition||"right";let s,a;return"left"===o?(s=4,a="start"):"center"===o?(s=(n.width||0)/2,a="middle"):(s=(n.width||0)-4,a="end"),(0,Ki.jsxs)("g",{opacity:e.opacity,children:[(0,Ki.jsx)("line",{x1:0,y1:i,x2:n.width||0,y2:i,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ki.jsx)("text",{x:s,y:i-4,textAnchor:a,fill:r,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"enclose":{const i=(e.coordinates||[]).map(e=>({x:ji({...e,type:"point"},n),y:Ci({...e,type:"point"},n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=(0,Mi.packEnclose)(i),o=e.padding||10;return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("circle",{cx:r.x,cy:r.y,r:r.r+o,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Ki.jsx)("text",{x:r.x,y:r.y-r.r-o-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+t)}case"rect-enclose":{const i=(e.coordinates||[]).map(e=>({x:ji({...e,type:"point"},n),y:Ci({...e,type:"point"},n)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=e.padding||10,o=i.map(e=>e.x),s=i.map(e=>e.y),[a,c]=di(o),[l,u]=di(s),d=a-r,h=c+r,f=l-r;return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("rect",{x:d,y:f,width:h-d,height:u+r-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Ki.jsx)("text",{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+t)}case"highlight":{const i=n.data||[],r="function"==typeof e.filter?i.filter(e.filter):e.field&&null!=e.value?i.filter(t=>t[e.field]===e.value):[],o={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return(0,Ki.jsx)("g",{children:r.map((t,i)=>{const r=ji(t,n),s=Ci(t,n);if(null==r||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,c="function"==typeof e.style?e.style(t):e.style||o;return(0,Ki.jsx)("circle",{cx:r,cy:s,r:a,...c},"hl-"+i)})},"ann-"+t)}case"bracket":{const i=ji(e,n),r=Ci(e,n);return(0,Ki.jsx)(Ai,{noteData:{x:i??0,y:r??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+t)}case"trend":{const i=n.data||[];if(2>i.length)return null;const r=n.xAccessor||"x",o=n.yAccessor||"y",s="ordinal"===n.frameType,a="horizontal"===n.projection,c=s?r:null,l=s?o:null;let u;const d=[],h=new Map;if(s&&c&&l){for(const e of i){const t=e[c];if(null==t)continue;const n=t+"";h.has(n)||(h.set(n,d.length),d.push(n))}u=i.map(e=>{const t=e[c],n=e[l];if(null==t||null==n)return null;const i=h.get(t+"");return null!=i?[i,+n]:null}).filter(e=>null!==e)}else u=i.map(e=>[e[r],e[o]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=n.scales?.x??n.scales?.time,p=n.scales?.y??n.scales?.value;if(!f||!p)return null;const y=e=>t=>{const n=Math.max(0,Math.floor(t)),i=Math.min(d.length-1,n+1),r=t-n,o=e(d[n]);return o+(e(d[i])-o)*r},g=f,m=p;let x;if(s)if(a){const e=y(m);x=(t,n)=>[g(n),e(t)]}else{const e=y(g);x=(t,n)=>[e(t),m(n)]}else x=(e,t)=>[g(e),m(t)];const b=e.method||"linear";let v;v="loess"===b?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const i=e.slice().sort((e,t)=>e[0]-t[0]),r=i.map(e=>e[0]),o=i.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=r[e],i=r.map(e=>Math.abs(e-t)),c=i.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,l=[];for(let e=0;n>e;e++){const t=0===c?0:i[e]/c;l[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,p=0;for(let e=0;n>e;e++){const t=l[e];0!==t&&(u+=t,d+=t*r[e],h+=t*o[e],f+=t*r[e]*r[e],p+=t*r[e]*o[e])}if(0===u){a.push([t,o[e]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))a.push([t,h/u]);else{const e=(u*p-d*h)/y;a.push([t,(h-e*d)/u+e*t])}}return a}(u,e.bandwidth??.3):("polynomial"===b?_i.default.polynomial(u,{order:e.order||2}):_i.default.linear(u)).points;const w=v.map(([e,t])=>{const[n,i]=x(e,t);return`${n},${i}`}).join(" "),k=e.color||"#6366f1",S=v[v.length-1],[A,M]=x(S[0],S[1]);return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ki.jsx)("text",{x:A+4,y:M-4,fill:k,fontSize:11,children:e.label})]},"ann-"+t)}case"band":{const i=n.scales?.y??n.scales?.value,r=i?.(e.y0)??0,o=i?.(e.y1)??(n.height||0);return(0,Ki.jsxs)("g",{opacity:e.opacity,children:[(0,Ki.jsx)("rect",{x:0,y:Math.min(r,o),width:n.width||0,height:Math.abs(o-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&(0,Ki.jsx)("text",{x:(n.width||0)-4,y:Math.max(Math.min(r,o),0)+13,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"x-band":{const i=n.scales?.x??n.scales?.time,r=null!=e.x0&&i?i(e.x0):null,o=null!=e.x1&&i?i(e.x1):null;return null==r||null==o?null:(0,Ki.jsxs)("g",{opacity:e.opacity,children:[(0,Ki.jsx)("rect",{x:Math.min(r,o),y:0,width:Math.abs(o-r),height:n.height||0,fill:e.fill||e.color||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity??.1}),e.label&&(0,Ki.jsx)("text",{x:Math.min(r,o)+4,y:13,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"envelope":{const i=n.data||[];if(2>i.length)return null;const r=n.xAccessor||"x",o=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!o||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",l=e.filter,u=i.filter(e=>null!=e[a]&&null!=e[c]&&!(l&&!l(e))).sort((e,t)=>e[r]-t[r]);if(2>u.length)return null;const d=Zi[n.curve||"linear"]||Pi.curveLinear,h=(0,Pi.area)().x(e=>o(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(d)(u);if(!h)return null;const f=e.fill||"#6366f1";return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,Ki.jsx)("text",{x:o(u[u.length-1][r])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+t)}case"anomaly-band":{const i=n.data||[];if(2>i.length)return null;const r=n.yAccessor||"y",o=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!o||!s)return null;const a=i.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,l=a.reduce((e,t)=>e+(t-c)**2,0)/a.length,u=Math.sqrt(l),d=e.threshold??2,h=c-d*u,f=!1!==e.showBand,p=e.fill||"#6366f1",y=e.fillOpacity??.1,g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,x=s(c+d*u),b=s(h),v=i.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>d*u});return(0,Ki.jsxs)("g",{children:[f&&(0,Ki.jsx)("rect",{x:0,y:Math.min(x,b),width:n.width||0,height:Math.abs(b-x),fill:p,fillOpacity:y}),v.map((e,t)=>{const i=ji(e,n),r=Ci(e,n);return null==i||null==r?null:(0,Ki.jsx)("circle",{cx:i,cy:r,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,Ki.jsx)("text",{x:(n.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:p,fontSize:11,children:e.label})]},"ann-"+t)}case"forecast":{const i=n.data||[];if(3>i.length)return null;const r=n.xAccessor||"x",o=n.yAccessor||"y",s=n.scales?.x??n.scales?.time,a=n.scales?.y??n.scales?.value;if(!s||!a)return null;const c=i.map(e=>[e[r],e[o]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let l;if("polynomial"===(e.method||"linear")){const t=_i.default.polynomial(c,{order:e.order||2}).equation;l=e=>t.reduce((t,n,i)=>t+n*Math.pow(e,i),0)}else{const e=c.length;let t=0,n=0,i=0,r=0;for(const[e,o]of c)t+=e,n+=o,i+=e*e,r+=e*o;const o=e*i-t*t;if(1e-12>Math.abs(o))return null;const s=(e*r-t*n)/o,a=(n-s*t)/e;l=e=>a+s*e}const u=c.length,d=c.map(([e,t])=>t-l(e)).reduce((e,t)=>e+t*t,0),h=Math.sqrt(d/Math.max(u-2,1)),f=c.reduce((e,t)=>e+t[0],0)/u,p=c.reduce((e,t)=>e+(t[0]-f)**2,0),y=e.confidence??.95,g=.99>y?.95>y?.9>y?1:1.645:1.96:2.576,m=e.steps??5,x=c[u-1][0],b=(x-c[0][0])/Math.max(u-1,1),v=[];for(let e=1;m>=e;e++)v.push(x+e*b);const w=[];for(const e of v){const t=l(e),n=h*Math.sqrt(1+1/u+(p>0?(e-f)**2/p:0))*g;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const k=`M${w.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,S=w.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),A=`${s(x)},${a(l(x))}`,M=e.strokeColor||"#6366f1";return(0,Ki.jsxs)("g",{children:[(0,Ki.jsx)("path",{d:k,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,Ki.jsx)("polyline",{points:`${A} ${S}`,fill:"none",stroke:M,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&w.length>0&&(0,Ki.jsx)("text",{x:s(w[w.length-1].x)+4,y:a(w[w.length-1].yCenter)-4,fill:M,fontSize:11,children:e.label})]},"ann-"+t)}case"widget":{let i,r;if(null!=e.px&&null!=e.py)i=e.px,r=e.py;else{const o=Ri(e,t,n);if(!o)return null;i=o.x,r=o.y}if(!Li(i,r,n))return null;const o=e.width??32,s=e.height??32;return(0,Ki.jsx)("foreignObject",{x:i+(e.dx??0)-o/2,y:r+(e.dy??0)-s/2,width:o,height:s,style:{overflow:"visible",pointerEvents:"auto"},children:(0,Ki.jsx)("div",{style:{width:o,height:s,display:"flex",alignItems:"center",justifyContent:"center"},children:e.content??(0,Ki.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"})})},"ann-"+t)}case"text":{const i=Ri(e,t,n);if(!i)return null;const{x:r,y:o}=i,s=r+(e.dx||0),a=o+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",l=(0,Ki.jsx)("text",{x:s,y:a,fill:c,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?gi.cloneElement(l,{key:"ann-text-"+t}):(0,Ki.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,Ki.jsx)("line",{x1:r,y1:o,x2:s,y2:a,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),gi.cloneElement(l,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+t)}case"category-highlight":{const i=e.category;if(null==i)return null;const r=e=>"function"==typeof e&&"function"==typeof e.bandwidth,o=n.scales?.o,s=n.scales?.x,a=n.scales?.y,c=r(o)?o:r(s)?s:r(a)?a:null;if(!c)return null;const l=c(i+"");if(null==l)return null;const u=c.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,f=e.label;return(0,Ki.jsxs)("g",(n.projection?"vertical"===n.projection:c===s)?{children:[(0,Ki.jsx)("rect",{x:l,y:0,width:u,height:n.height||0,fill:d,fillOpacity:h}),f&&(0,Ki.jsx)("text",{x:l+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]}:{children:[(0,Ki.jsx)("rect",{x:0,y:l,width:n.width||0,height:u,fill:d,fillOpacity:h}),f&&(0,Ki.jsx)("text",{x:12,y:l+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+t)}default:return null}}}var er=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function tr(e){return!!e&&"object"==typeof e&&er.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}new Set(["label","callout","callout-circle","callout-rect"]);var nr=2e4,ir=1;function rr(e){return"primary"===e?.emphasis||!0===e?.defensive}function or(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:nr))):1/0}function sr(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const i=e?.provenance?.confidence;switch("number"==typeof i&&Number.isFinite(i)&&(t+=15*Math.max(0,Math.min(1,i))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}var ar=32,cr=6,lr=4,ur=8,dr=72,hr=30,fr=-30,pr=8,yr=480,gr=3;var mr={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function xr(e){if(!br(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function br(e){return tr(e)}function vr(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),i=e.split(/\s+/).filter(Boolean),r=[];let o="";for(const e of i)o&&o.length+e.length+1>n?(r.push(o),o=e):o=o?`${o} ${e}`:e;return o&&r.push(o),r}function wr(e,t,n,i,r){const o=e+n,s=t+i;return Math.abs(n)>Math.abs(i)?{x:0>n?o-r.width-4:o+4,y:0>i?s-r.height:s,width:r.width,height:r.height}:{x:0>n?o-r.width:o,y:0>i?s-r.height-4:s+4,width:r.width,height:r.height}}function kr(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Sr(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Ar(e,t,n,i,r,o,s,a){const c=kr(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,i){const r=Math.max(0,i-e.x),o=Math.max(0,i-e.y);return(r+Math.max(0,e.x+e.width-(t-i)))*e.height+(o+Math.max(0,e.y+e.height-(n-i)))*e.width}(c,r,o,a);for(const e of n)l+=12*Sr(c,e);for(const e of i)l+=4*Sr(c,e);return l}function Mr(e){const{annotations:t,context:n,defaultOffset:i=ar,notePadding:r=cr,markPadding:o=lr,edgePadding:s=ur,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=dr,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:p,cohesion:y,audience:g}=e,m=n.width||0,x=n.height||0,b="object"==typeof p?p:{},v=b.breakpoint??yr,w=!!p&&v>=m,k=w&&!1!==b.preferShortText?t.map(xr):t,S=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,A=d||w&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),M=w&&!f?b.responsive??{minWidth:v}:f,P=w&&!y?b.cohesion:y;if(0===k.length||0>=m||0>=x)return k.slice();const _=[],j=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,o);let C=!1;const I=k.map((e,t)=>{if(!br(e))return e;const o=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const i=e.pointId??e.nodeId;if(null!=i&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===i);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,o=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&o){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=o([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?Ri(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!o)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...vr("string"==typeof e.title?e.title:void 0,t),...vr("string"==typeof e.label?e.label:void 0,t)],i=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*i)+10),height:Math.max(18,16*n.length+6)}}(e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:hr,dy:fr}}(e);return _.push(kr(wr(o.x,o.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),r)),e}var d;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(i)){const t=Ar(wr(o.x,o.y,e.dx,e.dy,u),e,_,j,m,x,r,s);f>t&&(h=e,f=t)}if(!h)return e;const p=kr(wr(o.x,o.y,h.dx,h.dy,u),r);_.push(p);const y=Math.hypot(h.dx,h.dy),g=c&&y>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return C=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),T=C?I:k.slice();let R=T;if(h){let e=!1;const t=T.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)<pr?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});R=e?t:T}{let e=!1;const t=R.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?mr[t.source]??t.source:null,i="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!i)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,i].filter(Boolean).join(" · "),o="string"==typeof e.label?e.label:"";return o.includes(`(${r})`)?e:{...e,label:o?`${o} (${r})`:`(${r})`}}(t);return n!==t&&(e=!0),n});R=e?t:R}const L=new Set;if(S){const e="object"==typeof S?S:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return gr;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?gr:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??or(m,x,e))*t))},{deferred:i}=function(e){const{annotations:t,width:n,height:i}=e,r=Math.max(0,e.minVisible??ir),o=or(n,i,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,tr(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||o>=a.length)return{visible:t.slice(),deferred:[],budget:o};const c=a.filter(e=>rr(e.annotation)),l=a.filter(e=>!rr(e.annotation)).sort((e,t)=>sr(t.annotation)-sr(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,o-c.length),Math.max(0,r-c.length))),d=new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:o}}({annotations:R,width:m,height:x,...n});for(const e of i)L.add(e)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:yr)>=m)for(const e of R)br(e)&&"secondary"===e.emphasis&&L.add(e);if(L.size>0)for(const e of R)!0===e?.defensive&&L.delete(e);let $;return $=0===L.size?R:A?R.map(e=>L.has(e)?{...e,_annotationDeferred:!0}:e):R.filter(e=>!L.has(e)),P?function(e,t){let n=!1;const i=e.map(e=>br(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?i:e}($,P):$}var Pr=require("react"),_r={positions:new Map},jr=new Set;function Cr(){for(const e of jr)e()}function Ir(e,t){const n=_r.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const i=new Map(_r.positions);i.delete(e),_r={positions:i},Cr()}function Tr(e,t){const n=_r.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const i=new Map(_r.positions);i.delete(e),_r={positions:i},Cr()}function Rr(){return _r}function Lr(e){return jr.add(e),()=>jr.delete(e)}var $r={positions:new Map};function Er(){return()=>{}}function Dr(){return $r}function zr(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),i=n[0],r=n[n.length-1],o=i instanceof Date,s=i instanceof Date?i.getTime():i,a=r instanceof Date?r.getTime():r;if(2>t||s===a)return o?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(t-1),l=Array(t);for(let e=0;t>e;e++){const n=e===t-1?a:s+e*c;l[e]=o?new Date(n):n}return l}(e,t):e.ticks(t)}var Br=require("react/jsx-runtime");function Fr(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function Nr(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function Or(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const i of e)t>i.pixel&&(t=i.pixel),i.pixel>n&&(n=i.pixel);return{min:t,max:n}}function Wr(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function qr(e,t,n){if("left"===e||"right"===e){const i="left"===e?n:0,r="left"===e?-1:1,o=Math.ceil(t/8);let s="M0,"+i;for(let e=0;o>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${i+4*r}`,s+=`L${Math.min(n,t)},${i}`}return s}{const i="bottom"===e?0:t,r="bottom"===e?1:-1,o=Math.ceil(n/8);let s=`M${i},0`;for(let e=0;o>e;e++){const t=8*(e+1);s+=`L${i+4*r},${Math.min(8*e+4,n)}`,s+=`L${i},${Math.min(t,n)}`}return s}}function Yr(e){const{width:t,height:n,totalWidth:i,totalHeight:r,margin:o,scales:s,showAxes:a,axes:c,showGrid:l,xFormat:u,yFormat:d,axisExtent:h}=e,f=(0,Un.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||Hr,i=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,o="exact"===h?Math.max(2,r):Math.min(r,i),a=e?.tickValues??zr(s.x,o,h),l=a.map(e=>e.valueOf()),d=a.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,l)})),f=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return Xr(d,Math.max(55,f+8))},[s,c,u,t,h]),p=(0,Un.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||d||Hr,i=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,o="exact"===h?Math.max(2,r):Math.min(r,i);return Xr((e?.tickValues??zr(s.y,o,h)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[s,c,d,n,h]),y=l&&s,g=a&&s;if(!y&&!g)return null;const m=c?.find(e=>"bottom"===e.orient),x=c?.find(e=>"left"===e.orient),b=g&&(!m||!1!==m.baseline),v=g&&(!x||!1!==x.baseline),w=m?.jaggedBase||!1,k=x?.jaggedBase||!1,S="var(--semiotic-border, #ccc)";return(0,Br.jsx)("svg",{width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:(0,Br.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[y&&(()=>{const e=Wr(c?.find(e=>"bottom"===e.orient)?.gridStyle),i=Wr(c?.find(e=>"left"===e.orient)?.gridStyle);return(0,Br.jsxs)("g",{className:"stream-grid",children:[f.map((t,i)=>(0,Br.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+i)),p.map((e,n)=>(0,Br.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),b&&!w&&(0,Br.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:S,strokeWidth:1}),w&&(0,Br.jsx)("path",{d:qr("bottom",t,n),fill:"none",stroke:S,strokeWidth:1}),v&&!k&&(0,Br.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:S,strokeWidth:1}),k&&(0,Br.jsx)("path",{d:qr("left",t,n),fill:"none",stroke:S,strokeWidth:1})]})})}function Hr(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Xr(e,t){if(2>=e.length)return e;const n=[e[0]];for(let i=1;e.length-1>i;i++)t>Math.abs(e[i].pixel-n[n.length-1].pixel)||n.push(e[i]);const i=e[e.length-1];return t>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function Gr(e){const{width:t,height:n,totalWidth:i,totalHeight:r,margin:o,scales:s,showAxes:a,axes:c,xLabel:l,yLabel:u,yLabelRight:d,xFormat:h,yFormat:f,axisExtent:p,showGrid:y,title:g,legend:m,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:v,legendIsolatedCategories:w,legendPosition:k="right",legendLayout:S,foregroundGraphics:A,marginalGraphics:M,xValues:P,yValues:_,annotations:j,autoPlaceAnnotations:C,svgAnnotationRules:I,xAccessor:T,yAccessor:R,annotationData:L,pointNodes:$,curve:E,underlayRendered:D,canvasObscuresUnderlay:z=!0,linkedCrosshairName:B,linkedCrosshairSourceId:F,children:N}=e,O=(0,Un.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||h||Hr,i=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,o="exact"===p?Math.max(2,r):Math.min(r,i),l=e?.tickValues??zr(s.x,o,p),u=l.map(e=>e.valueOf()),d=l.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,u)})),f=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),y=e?.autoRotate?Math.max(20,Math.min(f+8,55)):Math.max(55,f+8);let g=Xr(d,y);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==p&&!e?.tickValues){const e=s.x.domain()[1],t=s.x(e),i=g[g.length-1].pixel;if(Math.abs(t-i)>1){const r=n(e,g.length,u);y>t-i&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:r})}}return g},[a,s,c,h,t,p]),W=(0,Un.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||f||Hr,i=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,o="exact"===p?Math.max(2,r):Math.min(r,i);let l=Xr((e?.tickValues??zr(s.y,o,p)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22);if(l.length>1&&(l=l.filter((e,t)=>0===t||e.label+""!=l[t-1].label+"")),e?.includeMax&&l.length>0&&"exact"!==p&&!e?.tickValues){const e=s.y.domain()[1],n=s.y(e),i=l[l.length-1].pixel;if(Math.abs(n-i)>1){const r=t(e);22>Math.abs(n-i)&&l.length>1&&(l=l.slice(0,-1)),l.push({value:e,pixel:n,label:r})}}return l},[a,s,c,f,n,p]),q=(0,Un.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||f||Hr,i=Math.max(2,Math.floor(n/30)),r=e.ticks??5;return Xr((e.tickValues??zr(s.y,"exact"===p?Math.max(2,r):Math.min(r,i),p)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[a,s,c,f,n,p]),Y=(0,Un.useRef)(new Map),H=(0,Un.useRef)(j?.length??0),X=j?.length??0;H.current!==X&&(H.current=X,Y.current=new Map);const G=(0,Un.useMemo)(()=>{if(!j||0===j.length)return null;const e=Ji(),i={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:T,yAccessor:R,width:t,height:n,data:L,frameType:"xy",pointNodes:$,curve:E,stickyPositionCache:Y.current};return Qi(C?Mr({annotations:j,context:i,..."object"==typeof C?C:{}}):j,e,I,i)},[j,C,I,t,n,T,R,L,s,$,E]),V=function(e){const t=(0,Pr.useSyncExternalStore)(e?Lr:Er,e?Rr:Dr,e?Rr:Dr);return e?t.positions.get(e)??null:null}(B);return(0,Un.useEffect)(()=>{if(!V?.locked||!B)return;const e=e=>{"Escape"===e.key&&Tr(B)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[V?.locked,B]),a||g||m||A||M||G&&G.length>0||y||N||V?(0,Br.jsxs)("svg",{role:"img",width:i,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,Br.jsx)("title",{children:"string"==typeof g?g:"XY Chart"}),(0,Br.jsx)("desc",{children:"string"==typeof g?g+" — XY data visualization":"XY data visualization"}),(0,Br.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[y&&s&&(!D||z)&&(()=>{const e=Wr(c?.find(e=>"bottom"===e.orient)?.gridStyle),i=Wr(c?.find(e=>"left"===e.orient)?.gridStyle);return(0,Br.jsxs)("g",{className:"stream-grid",children:[O.map((t,i)=>(0,Br.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+i)),W.map((e,n)=>(0,Br.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),a&&s&&(()=>{const e=c?.find(e=>"left"===e.orient),i=c?.find(e=>"bottom"===e.orient),r=!e||!1!==e.baseline,s=!i||!1!==i.baseline,a=e?.jaggedBase||!1,h=i?.jaggedBase||!1,f=i?.landmarkTicks,p=e?.landmarkTicks,y="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",x=!!i?.autoRotate&&O.length>1&&(()=>{const e=t/Math.max(O.length-1,1);return O.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),b=x?12:18,v=n+(x?58:40),w={fontSize:"var(--semiotic-tick-font-size, 12px)"},k={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},S={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},A=i?.tickAnchor,M=e?.tickAnchor,P=Or(O),_=Or(W);return(0,Br.jsxs)("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(0,Br.jsxs)("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!D||z)&&s&&!h&&(0,Br.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:y,strokeWidth:1}),(!D||z)&&h&&(0,Br.jsx)("path",{d:qr("bottom",t,n),fill:"none",stroke:y,strokeWidth:1}),O.map((e,t)=>{const i=!!f&&("function"==typeof f?f(e.value,t):rn(e.value,t>0?O[t-1].value:void 0));return(0,Br.jsxs)("g",{transform:`translate(${e.pixel},${n})`,children:[(0,Br.jsx)("line",{y2:5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Br.jsx)("text",{y:b,textAnchor:x?"end":Fr(A,e.pixel===P.min,e.pixel===P.max),fontWeight:i?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...i?k:w},transform:x?"rotate(-45)":void 0,children:e.label}):(0,Br.jsx)("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:(0,Br.jsx)("div",{style:{textAlign:"center",userSelect:"none",...w},children:e.label})})]},"xtick-"+t)}),l&&(0,Br.jsx)("text",{x:t/2,y:v,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:l})]}),(0,Br.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!D||z)&&r&&!a&&(0,Br.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:y,strokeWidth:1}),(!D||z)&&a&&(0,Br.jsx)("path",{d:qr("left",t,n),fill:"none",stroke:y,strokeWidth:1}),W.map((e,t)=>{const n=!!p&&("function"==typeof p?p(e.value,t):rn(e.value,t>0?W[t-1].value:void 0));return(0,Br.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Br.jsx)("line",{x2:-5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Br.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:Nr(M,e.pixel===_.min,e.pixel===_.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?k:w},children:e.label}):(0,Br.jsx)("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Br.jsx)("div",{style:{textAlign:"right",userSelect:"none",...w},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?(0,Br.jsx)("text",{x:15-o.left,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-o.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===q.length)return null;const i=!1!==e.baseline,r=e.landmarkTicks,s=e.label||d,a=e.tickAnchor,l=Or(q);return(0,Br.jsxs)("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[i&&(0,Br.jsx)("line",{x1:t,y1:0,x2:t,y2:n,stroke:y,strokeWidth:1}),q.map((e,n)=>{const i=!!r&&("function"==typeof r?r(e.value,n):rn(e.value,n>0?q[n-1].value:void 0));return(0,Br.jsxs)("g",{transform:`translate(${t},${e.pixel})`,children:[(0,Br.jsx)("line",{x2:5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Br.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:Nr(a,e.pixel===l.min,e.pixel===l.max),fontWeight:i?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...i?k:w},children:e.label}):(0,Br.jsx)("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Br.jsx)("div",{style:{textAlign:"left",userSelect:"none",...w},children:e.label})})]},"ytick-r-"+n)}),s&&(0,Br.jsx)("text",{x:t+o.right-15,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${t+o.right-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:s})]})})()]})})(),G,M&&s&&P&&_&&(0,Br.jsxs)(Br.Fragment,{children:[M.top&&(0,Br.jsx)("g",{transform:"translate(0, 0)",children:(0,Br.jsx)(yi,{orient:"top",config:pi(M.top),values:P,scale:s.x,size:o.top,length:t})}),M.bottom&&(0,Br.jsx)("g",{transform:`translate(0, ${n})`,children:(0,Br.jsx)(yi,{orient:"bottom",config:pi(M.bottom),values:P,scale:s.x,size:o.bottom,length:t})}),M.left&&(0,Br.jsx)("g",{transform:"translate(0, 0)",children:(0,Br.jsx)(yi,{orient:"left",config:pi(M.left),values:_,scale:s.y,size:o.left,length:n})}),M.right&&(0,Br.jsx)("g",{transform:`translate(${t}, 0)`,children:(0,Br.jsx)(yi,{orient:"right",config:pi(M.right),values:_,scale:s.y,size:o.right,length:n})})]}),A,V&&V.sourceId!==F&&s?.x&&(()=>{const e=s.x(V.xValue);if(null==e||0>e||e>t)return null;const i=V.locked;return(0,Br.jsx)("line",{x1:e,y1:0,x2:e,y2:n,stroke:i?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:i?1.5:1,strokeDasharray:i?"6,3":"4,4",pointerEvents:"none"})})(),N]}),g&&(0,Br.jsx)("text",{x:i/2,y:20,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:"string"==typeof g?g:null}),ci({legend:m,totalWidth:i,totalHeight:r,margin:o,legendPosition:k,title:g,legendLayout:S,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:v,legendIsolatedCategories:w})]}):null}var Vr=c(require("react")),Ur=require("d3-shape");function Kr(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function Zr(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(e.w,e.h)/2,i=e=>Math.max(0,Math.min(e??0,n));return{tl:i(t.tl),tr:i(t.tr),br:i(t.br),bl:i(t.bl)}}var Qr=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function Jr(e){const{innerRadius:t,outerRadius:n,startAngle:i,endAngle:r}=e,o=0>=t;if(0>=(e.cornerRadius??0)||!e.roundStart&&!e.roundEnd){if(o){const e=Qr(n,i),t=Qr(n,r);return`M0,0 L${e.x},${e.y} A${n},${n} 0 ${r-i>Math.PI?1:0} 1 ${t.x},${t.y} Z`}const e=Qr(n,i),s=Qr(n,r),a=Qr(t,r),c=Qr(t,i),l=r-i>Math.PI?1:0;return`M${e.x},${e.y} A${n},${n} 0 ${l} 1 ${s.x},${s.y} L${a.x},${a.y} A${t},${t} 0 ${l} 0 ${c.x},${c.y} Z`}const s=Math.max(0,Math.min(e.cornerRadius??0,(n-t)/2));if(0===s)return Jr({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,n-s))),c=o?0:Math.asin(Math.min(1,s/Math.max(1e-9,t+s))),l=r-i,u=e.roundStart&&e.roundEnd?l/2:l,d=!!e.roundStart&&u>a,h=!!e.roundEnd&&u>a;if(!d&&!h)return Jr({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=i+(d?a:0),p=r-(h?a:0),y=i+(d?c:0),g=r-(h?c:0),m=Qr(n,f),x=Qr(n,p),b=(n-s)*Math.cos(a),v=Qr(b,i),w=Qr(b,r),k=o?null:Qr(t,g),S=o?null:Qr(t,y),A=o?0:(t+s)*Math.cos(c),M=o?null:Qr(A,i),P=o?null:Qr(A,r),_=p-f>Math.PI?1:0,j=o?0:g-y>Math.PI?1:0;let C="";if(d)C+=`M${v.x},${v.y}`,C+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const e=Qr(n,i);C+=`M${e.x},${e.y}`}if(h)C+=` A${n},${n} 0 ${_} 1 ${x.x},${x.y}`,C+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const e=Qr(n,r);C+=` A${n},${n} 0 ${_} 1 ${e.x},${e.y}`}if(o)C+=" L0,0";else{if(h)C+=` L${P.x},${P.y}`,C+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const e=Qr(t,r);C+=` L${e.x},${e.y}`}if(d)C+=` A${t},${t} 0 ${j} 0 ${S.x},${S.y}`,C+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const e=Qr(t,i);C+=` A${t},${t} 0 ${j} 0 ${e.x},${e.y}`}}return C+=" Z",C}var eo=require("react/jsx-runtime"),to={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function no(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}function io(e,t,n){const i=ht(e.symbolType,e.size,e.path);return(0,eo.jsx)("path",{d:i,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?no(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${n??""}symbol-${t}`)}function ro(e,t,n,i){const r=e.glyph;if(!r?.parts?.length||0>=e.size)return null;const o=an(r,e.size);if(0>=o.scale)return null;const s=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${o.offsetX},${o.offsetY}) scale(${o.scale})`,a=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),c=dn(r,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?oo(i+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>r.parts.map((n,i)=>{const r=t?"none"===n.fill?void 0:t:cn(n.fill,a,e.accent),o=t?n.stroke&&"none"!==n.stroke?t:void 0:cn(n.stroke??"none",a,e.accent);return r||o?(0,eo.jsx)("path",{d:n.d,fill:r??"none",stroke:o,strokeWidth:o?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},i):null});return(0,eo.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&(0,eo.jsx)("clipPath",{id:l,children:(0,eo.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&e.ghostColor?(0,eo.jsx)("g",{children:d(e.ghostColor)}):null,c&&l?(0,eo.jsx)("g",{clipPath:`url(#${l})`,children:d()}):d()]},i)}function oo(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function so(e,t,n){switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const i="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return(0,eo.jsx)("path",{d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity},"line-"+t)}case"area":{const i=e;if(0===i.topPath.length)return null;const r=`M${i.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...i.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`;if(i.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return(0,eo.jsxs)("g",{children:[(0,eo.jsx)("defs",{children:(0,eo.jsx)("clipPath",{id:e,children:(0,eo.jsx)("rect",{x:i.clipRect.x,y:i.clipRect.y,width:i.clipRect.width,height:i.clipRect.height})})}),(0,eo.jsx)("path",{d:r,fill:no(i.style.fill),fillOpacity:i.style.fillOpacity??i.style.opacity??.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+t)}return(0,eo.jsx)("path",{d:r,fill:no(i.style.fill),fillOpacity:i.style.fillOpacity??i.style.opacity??.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},"area-"+t)}case"point":{const n=e;return(0,eo.jsx)("circle",{cx:n.x,cy:n.y,r:n.r,fill:no(n.style.fill),opacity:n.style.opacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"point-"+t)}case"symbol":return io(e,t);case"glyph":return ro(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const n=e;return(0,eo.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:no(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"rect-"+t)}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[i,r,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),s=.299*i+.587*r+.114*o>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return(0,eo.jsxs)("g",{children:[(0,eo.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),(0,eo.jsx)("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:e})]},"heatcell-"+t)}return(0,eo.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+t)}case"candlestick":{const n=e,i=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),o=n.isUp?n.upColor:n.downColor;return(0,eo.jsxs)("g",{children:[(0,eo.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,eo.jsx)("rect",{x:n.x-n.bodyWidth/2,y:i,width:n.bodyWidth,height:r,fill:o,stroke:o,strokeWidth:1})]},"candle-"+t)}default:return null}}function ao(e,t,n){const i=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",r=n=>`ord-${e.type}-${i}-${t}-${n}`,o=`ord-${e.type}-${i}-${t}`;switch(e.type){case"rect":{const t=e,n=oo(o)+"-grad",i=function(e,t){const n=e.fillGradient;if(!n)return null;let i=e.x,r=e.y,o=e.x,s=e.y+e.h;"bottom"===e.roundedEdge?(r=e.y+e.h,s=e.y):"right"===e.roundedEdge?(i=e.x+e.w,r=e.y,o=e.x,s=e.y):"left"===e.roundedEdge&&(i=e.x,r=e.y,o=e.x+e.w,s=e.y);const a=[];if("colorStops"in n){const e=n.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>e.length)return null;for(let t=0;e.length>t;t++)a.push((0,eo.jsx)("stop",{offset:e[t].offset,stopColor:e[t].color},t))}else{const t=no(e.style.fill);a.push((0,eo.jsx)("stop",{offset:0,stopColor:t,stopOpacity:n.topOpacity},"0")),a.push((0,eo.jsx)("stop",{offset:1,stopColor:t,stopOpacity:n.bottomOpacity},"1"))}return(0,eo.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:i,y1:r,x2:o,y2:s,children:a})}(t,n),r=i?`url(#${n})`:no(t.style.fill);if(t.cornerRadii&&Kr(t.cornerRadii)){const e=function(e){const{x:t,y:n,w:i,h:r}=e,{tl:o,tr:s,br:a,bl:c}=Zr(e);let l=`M${t+o},${n}`;return l+=` L${t+i-s},${n}`,s>0&&(l+=` A${s},${s} 0 0 1 ${t+i},${n+s}`),l+=` L${t+i},${n+r-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${t+i-a},${n+r}`),l+=` L${t+c},${n+r}`,c>0&&(l+=` A${c},${c} 0 0 1 ${t},${n+r-c}`),l+=` L${t},${n+o}`,o>0&&(l+=` A${o},${o} 0 0 1 ${t+o},${n}`),l+=" Z",l}(t);return(0,eo.jsxs)(Vr.Fragment,{children:[i&&(0,eo.jsx)("defs",{children:i}),(0,eo.jsx)("path",{d:e,fill:r,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},o)}if(t.roundedTop&&t.roundedTop>0){const e=Math.min(t.roundedTop,t.w/2,t.h/2),{x:n,y:s,w:a,h:c}=t;let l;switch(t.roundedEdge){case"right":l=`M${n},${s} L${n+a-e},${s} A${e},${e} 0 0 1 ${n+a},${s+e} L${n+a},${s+c-e} A${e},${e} 0 0 1 ${n+a-e},${s+c} L${n},${s+c} Z`;break;case"left":l=`M${n+a},${s} L${n+e},${s} A${e},${e} 0 0 0 ${n},${s+e} L${n},${s+c-e} A${e},${e} 0 0 0 ${n+e},${s+c} L${n+a},${s+c} Z`;break;case"bottom":l=`M${n},${s} L${n+a},${s} L${n+a},${s+c-e} A${e},${e} 0 0 1 ${n+a-e},${s+c} L${n+e},${s+c} A${e},${e} 0 0 1 ${n},${s+c-e} Z`;break;default:l=`M${n},${s+c} L${n},${s+e} A${e},${e} 0 0 1 ${n+e},${s} L${n+a-e},${s} A${e},${e} 0 0 1 ${n+a},${s+e} L${n+a},${s+c} Z`}return(0,eo.jsxs)(Vr.Fragment,{children:[i&&(0,eo.jsx)("defs",{children:i}),(0,eo.jsx)("path",{d:l,fill:r,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},o)}return(0,eo.jsxs)(Vr.Fragment,{children:[i&&(0,eo.jsx)("defs",{children:i}),(0,eo.jsx)("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:r,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},o)}case"point":{const t=e;return(0,eo.jsx)("circle",{cx:t.x,cy:t.y,r:t.r,fill:no(t.style.fill),opacity:t.style.opacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},o)}case"symbol":return io(e,t,n);case"glyph":return ro(e,e.x,e.y,`${n??""}ord-glyph-${e.pointId??t}`);case"wedge":{const i=e;if(i._gradientBand&&i._gradientBand.colors.length>0){const e=oo(`${n?n+"-":""}gauge-grad-${i.category||o}-${t}`),{clipPath:r,slices:s}=function(e){const t=Jr({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),n=[],i=e.colors;if(i.length>0){const t=(e.endAngle-e.startAngle)/i.length;for(let r=0;i.length>r;r++)n.push({d:Jr({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+r*t,endAngle:e.endAngle}),color:i[r]})}return{clipPath:t,slices:n}}({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:i.roundedEnds?.start??!0,roundEnd:i.roundedEnds?.end??!0,colors:i._gradientBand.colors});return(0,eo.jsxs)("g",{transform:`translate(${i.cx},${i.cy})`,opacity:i.style.opacity,fillOpacity:i.style.fillOpacity,children:[(0,eo.jsx)("defs",{children:(0,eo.jsx)("clipPath",{id:e,children:(0,eo.jsx)("path",{d:r})})}),(0,eo.jsx)("g",{clipPath:`url(#${e})`,children:s.map((e,t)=>(0,eo.jsx)("path",{d:e.d,fill:no(e.color)},t))}),i.style.stroke&&"none"!==i.style.stroke&&(0,eo.jsx)("path",{d:r,fill:"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},o)}let r;if(i.roundedEnds)r=Jr({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:i.roundedEnds.start,roundEnd:i.roundedEnds.end});else{const e=(0,Ur.arc)().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&e.cornerRadius(i.cornerRadius),r=e(to)||""}return(0,eo.jsx)("path",{d:r,transform:`translate(${i.cx},${i.cy})`,fill:no(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},o)}case"boxplot":{const t=e,n=t.columnWidth/2;return(0,eo.jsxs)("g","vertical"===t.projection?{children:[(0,eo.jsx)("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("rect",{x:t.x-n,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:no(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("line",{x1:t.x-n,y1:t.medianPos,x2:t.x+n,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,eo.jsx)("line",{x1:t.x-.5*n,y1:t.minPos,x2:t.x+.5*n,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("line",{x1:t.x-.5*n,y1:t.maxPos,x2:t.x+.5*n,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1})]}:{children:[(0,eo.jsx)("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-n,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:no(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("line",{x1:t.medianPos,y1:t.y-n,x2:t.medianPos,y2:t.y+n,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,eo.jsx)("line",{x1:t.minPos,y1:t.y-.5*n,x2:t.minPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,eo.jsx)("line",{x1:t.maxPos,y1:t.y-.5*n,x2:t.maxPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1})]},o)}case"violin":{const t=e,n=[(0,eo.jsx)("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:no(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1},r("path"))];if(t.iqrLine&&t.bounds){const e=t.bounds,i=e.x+e.width/2,o=e.y+e.height/2;e.height>e.width?n.push((0,eo.jsx)("line",{x1:i,y1:t.iqrLine.q1Pos,x2:i,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,eo.jsx)("circle",{cx:i,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med"))):n.push((0,eo.jsx)("line",{x1:t.iqrLine.q1Pos,y1:o,x2:t.iqrLine.q3Pos,y2:o,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,eo.jsx)("circle",{cx:t.iqrLine.medianPos,cy:o,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med")))}return(0,eo.jsx)("g",{children:n},o)}case"connector":return(0,eo.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity??.5},o);case"trapezoid":{const t=e,n=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");return(0,eo.jsx)("polygon",{points:n,fill:no(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},o)}default:return null}}var co="undefined"==typeof window||"undefined"==typeof document,lo=require("react"),uo="undefined"!=typeof window?lo.useLayoutEffect:lo.useEffect;function ho(){const[e,t]=(0,lo.useState)(!1);return uo(()=>{t(!0)},[]),e}var fo=()=>()=>{},po=()=>!1,yo=()=>!0;function go(){const e=(0,lo.useSyncExternalStore)(fo,po,yo);return(0,lo.useRef)(e).current}function mo(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:i,dirtyRef:r,renderFnRef:o,cancelRender:s,cleanup:a}=e;uo(()=>{t&&n&&i.current?.cancelIntroAnimation?.(),r.current=!0,s?.(),o.current()},[t,n]);const c=(0,lo.useRef)(a);c.current=a,(0,lo.useEffect)(()=>()=>c.current?.(),[])}var xo=require("react");function bo(e,t){const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!Object.is(e[i],t[i]))return!1}return!0}function vo(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function wo(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}var ko={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff",background:""};function So(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],i=n[2],r=n[3];return`#${e}${e}${i}${i}${r}${r}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const i=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return i?`rgba(${i[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}var Ao=c(require("react")),Mo=c(require("react")),Po=(require("react/jsx-runtime"),Mo.createContext(null));function _o(){return Mo.useContext(Po)}function jo(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,i]of Object.entries(e))n.startsWith("_")||null!=i&&""!==i&&("number"==typeof i?Number.isFinite(i)&&(t[n]=i):"string"==typeof i?t[n]=i:"boolean"==typeof i?t[n]=i+"":i instanceof Date&&(t[n]=i.toISOString().slice(0,10)));return t}function Co(e){return e&&"object"==typeof e?e:{}}function Io(e){return Co(e.accessibility).tableFields??e.accessibleDatum??e.datum}var To=require("react/jsx-runtime"),Ro={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Lo(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e){if(null===t?.datum)continue;const e=t.type+"";n[e]=(n[e]||0)+1}if(0===Object.keys(n).length)return t+", empty";const i=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},o=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((e,t)=>{const n=o.indexOf(e),i=o.indexOf(t);return(-1===n?999:n)-(-1===i?999:i)});for(const e of s)i.push(`${n[e]} ${r[e]||e}`);return`${t}, ${i.join(", ")}`}var $o=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Eo="semiotic-accessible-data-table",Do=Eo+" semiotic-accessible-data-table-hidden",zo=Eo+" semiotic-accessible-data-table-visible",Bo={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Fo={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},No={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Oo={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Wo={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},qo={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Yo={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Ho={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Xo({scene:e,chartType:t,tableId:n,chartTitle:i}){const[r,o]=Ao.useState(!1),[s,a]=Ao.useState(5),c=_o(),l=c?.visible??!1,u=r||l,d=Ao.useRef(null),h=i?"Data summary for "+i:n?`Data summary for ${t} ${n}`:"Data summary for "+t;Ao.useEffect(()=>{u||a(5)},[u]);const f=Ao.useCallback(e=>{e.target===e.currentTarget&&(r||l||o(!0))},[r,l]),p=Ao.useCallback(e=>{l||d.current?.contains(e.relatedTarget)||o(!1)},[l]);if(!e||0===e.length)return n?(0,To.jsx)("span",{id:n,tabIndex:-1,style:Ro}):null;if(!u)return(0,To.jsx)("div",{id:n,className:Do,tabIndex:-1,onFocus:f,style:Ro,role:"region","aria-label":h,children:(0,To.jsxs)("button",{type:"button",onClick:()=>o(!0),children:["View data summary (",e.length," elements)"]})});const y=function(e){const t=[];if(!Array.isArray(e))return t;const n=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const i of e)if(i&&"object"==typeof i&&null!==i.datum)try{switch(i.type){case"point":if(n)break;t.push({label:"Point",values:jo(Io(i))});break;case"line":case"area":{const e=Io(i),n=Array.isArray(e)?e:[],r="line"===i.type?"Line point":"Area point";for(const e of n)t.push({label:r,values:jo(e)});break}case"rect":{const e=Io(i),n=null!=e&&"object"==typeof e?e:{},r=n.category??i.group??"",o=n.value??n.__aggregateValue??n.total,s=jo(n);null==s.category&&""!==r&&(s.category=r+""),null==s.value&&null!=o&&(s.value="number"==typeof o||"string"==typeof o?o:o+""),t.push({label:"Bar",values:s});break}case"heatcell":{const e=jo(Io(i));null==e.value&&"number"==typeof i.value&&Number.isFinite(i.value)&&(e.value=i.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Io(i),n=jo(e);if(null==n.category){const t=Co(e),i=t.category??t.label;null!=i&&(n.category=i+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:jo(Io(i))});break;case"arc":t.push({label:"Arc",values:jo(Io(i))});break;case"candlestick":t.push({label:"Candlestick",values:jo(Io(i))});break;case"geoarea":{const e=Co(Io(i)),n=jo(e);if(null==n.name){const t=Co(e.properties).name??e.name;null!=t&&(n.name=t+"")}t.push({label:"Region",values:n});break}}}catch{}return t}(e),g=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const i of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[i];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],o=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),o+=n;n.push({name:i,count:t.length,numeric:!0,min:e,max:r,mean:o/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:i,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(y),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${$o(e.min)} to ${$o(e.max)}, mean ${$o(e.mean)}.`);else{const t=e.uniqueValues,i=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${i}.`)}return n.join(" ")}(y.length,g),x=Math.min(s,y.length),b=y.slice(0,x),v=y.length-x,w=new Set;for(const e of b)for(const t of Object.keys(e.values))w.add(t);const k=Array.from(w);return(0,To.jsxs)("div",{ref:d,id:n,className:zo,tabIndex:-1,onBlur:p,style:Bo,role:"region","aria-label":h,children:[(0,To.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{l&&c&&c.setVisible(!1),o(!1)},"aria-label":"Close data summary",style:No,children:"×"}),(0,To.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Fo,children:m}),(0,To.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:Oo,children:[(0,To.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Yo,children:v>0?`First ${x} of ${y.length} data points`:`All ${y.length} data points`}),(0,To.jsx)("thead",{children:(0,To.jsxs)("tr",{children:[(0,To.jsx)("th",{style:Wo,children:"type"}),k.map(e=>(0,To.jsx)("th",{style:Wo,children:e},e))]})}),(0,To.jsx)("tbody",{children:b.map((e,t)=>(0,To.jsxs)("tr",{children:[(0,To.jsx)("td",{style:qo,children:e.label}),k.map(t=>{return(0,To.jsx)("td",{style:qo,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":$o(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),v>0&&(0,To.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Ho,children:["Show ",Math.min(25,v)," more"," ",1===v?"row":"rows"," (",v," remaining)"]})]})}function Go({summary:e}){return e?(0,To.jsx)("div",{role:"note",style:Ro,children:e}):null}function Vo({tableId:e}){return(0,To.jsx)("a",{href:"#"+e,style:Ro,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Ro)},children:"Skip to data table"})}function Uo({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return(0,To.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:Ro,children:t})}var Ko=require("react/jsx-runtime"),Zo="var(--semiotic-focus, #005fcc)";function Qo({active:e,hoverPoint:t,margin:n,size:i,shape:r="circle",width:o,height:s,pathData:a}){if(!e||!t)return null;const c=t.x+n.left,l=t.y+n.top;let u;if("geoarea"!==r&&"path"!==r||!a)if("rect"===r&&null!=o&&null!=s){const e=Math.max(o,4),t=Math.max(s,4);u=(0,Ko.jsx)("rect",{x:c-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:Zo,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,Ko.jsx)("circle","wedge"===r?{cx:c,cy:l,r:12,fill:"none",stroke:Zo,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:c,cy:l,r:8,fill:"none",stroke:Zo,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,Ko.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,Ko.jsx)("path",{d:a,fill:"none",stroke:Zo,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,Ko.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:i[0],height:i[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var Jo=c(require("react")),es=require("react/jsx-runtime");function ts({x:e,y:t,containerWidth:n,containerHeight:i,margin:r,children:o,className:s="stream-frame-tooltip",zIndex:a=1}){const c=Number.isFinite(e)&&Number.isFinite(t),l=Jo.useRef(null),[u,d]=Jo.useState(null);Jo.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[o,s,n,i]);let h;h=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>i-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*i>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!Jo.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const i=n.style;if(i&&"object"==typeof i){if(null!=i.background&&""!==i.background&&"transparent"!==i.background)return!0;if(null!=i.backgroundColor&&""!==i.backgroundColor&&"transparent"!==i.backgroundColor)return!0}return!1}(o),p=f?null:V;return c?(0,es.jsx)("div",{ref:l,className:f?s:(s+" semiotic-tooltip").trim(),style:{...p||{},position:"absolute",left:r.left+e,top:r.top+t,transform:h,pointerEvents:"none",zIndex:a,width:"max-content"},children:o}):null}var ns=c(require("react")),is=require("react"),rs=require("react");var os=require("react"),ss="undefined"==typeof window?is.useEffect:is.useLayoutEffect,as={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function cs(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function ls(e){const t=function(){const[e,t]=(0,rs.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,rs.useEffect)(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=(0,is.useRef)(t);n.current=t;const[i,r]=function(e,t,n){const i=(0,os.useRef)(null),[r,o]=(0,os.useState)(null);return(0,os.useEffect)(()=>{if(!t&&!n)return;const e=i.current;if(!e)return;const r=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;o(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return r.observe(e),()=>r.disconnect()},[t,n]),[i,[t&&r?r.w:e[0],n&&r?r.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),o=(0,is.useMemo)(()=>({...e.marginDefault,...e.userMargin}),[e.marginDefault,e.userMargin]),s=r[0]-o.left-o.right,a=r[1]-o.top-o.bottom,c=cs(e.foregroundGraphics,r,o),l=cs(e.backgroundGraphics,r,o),u=Pe(e=>e.theme),{transition:d,introEnabled:h}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),f="semiotic-table-"+ns.useId(),p=(0,is.useRef)(null),y=(0,is.useRef)(e.frameScheduler??as);y.current=e.frameScheduler??as;const g=(0,is.useRef)(null),m=(0,is.useRef)(!1),x=(0,is.useRef)(()=>{}),b=(0,is.useCallback)(()=>{if(null!==p.current||m.current)return;const e=y.current;let t=!1,n=!1;const i=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(m.current=!0),p.current=null,g.current=null;try{x.current()}finally{e&&(m.current=!1)}});n=!0,t||(p.current=i,g.current=e)},[]),v=(0,is.useCallback)(()=>{null!==p.current&&((g.current??y.current).cancelAnimationFrame(p.current),p.current=null,g.current=null)},[]);(0,is.useEffect)(()=>()=>{v()},[v]);const w=(0,is.useRef)(()=>{}),k=(0,is.useRef)(()=>{}),S=(0,is.useRef)(null),A=(0,is.useRef)(null),M=(0,is.useRef)(null),P=(0,is.useCallback)(()=>{const e=S.current;S.current=null,e&&w.current(e)},[]),_=(0,is.useCallback)(e=>{if(S.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===A.current){const e=y.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,A.current=null,M.current=null,P()});t||(A.current=n,M.current=e)}},[P]),j=(0,is.useCallback)(()=>{S.current=null,null!==A.current&&((M.current??y.current).cancelAnimationFrame(A.current),A.current=null,M.current=null),k.current()},[]);(0,is.useEffect)(()=>()=>{S.current=null,null!==A.current&&((M.current??y.current).cancelAnimationFrame(A.current),A.current=null,M.current=null)},[]);const C=e.themeDirtyRef;return ss(()=>{C&&(gn++,C.current=!0,b())},[u,b,C]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:i,size:r,margin:o,adjustedWidth:s,adjustedHeight:a,resolvedForeground:c,resolvedBackground:l,currentTheme:u,transition:d,introEnabled:h,tableId:f,rafRef:p,renderFnRef:x,scheduleRender:b,cancelRender:v,hoverHandlerRef:w,hoverLeaveRef:k,onPointerMove:_,onPointerLeave:j}}function us(e,t,n,i){const r=e.getContext("2d");if(!r)return null;const o=Math.round(t[0]*i),s=Math.round(t[1]*i),a=o/t[0],c=s/t[1],l=t[0]+"px",u=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==u&&(e.style.height=u),e.width===o&&e.height===s||(e.width=o,e.height=s),r.setTransform(a,0,0,c,0,0),r.translate(n.left,n.top),r}function ds(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}var hs=require("react");function fs(e,t,n,i){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:i,fn:t}:{key:void 0,fn:null}}var ps=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ys=3156e7;function gs(e){const t=e[1]-e[0];return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:ys>t?e=>{const t=new Date(e);return`${ps[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*ys>t?e=>{const t=new Date(e);return`${ps[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function ms(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("symbol"===n.type)t.push({pointId:n.pointId,x:n.x,y:n.y,r:ft(n.size)});else if("glyph"===n.type){const e=hn(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}var xs=require("d3-shape");function bs(e,t,n){let i=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(i=n.color):e>n.value&&(i=n.color);return i}function vs(e,t,n,i,r,o){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],i=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+i*i))}const a=s[s.length-1];if(0===a)return;const c=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=i,e.lineCap=o;for(let n=0;t.length-1>n;n++){const i=(s[n]+s[n+1])/2;let o=r;c>i&&(o*=i/c),c>a-i&&(o*=(a-i)/c),e.globalAlpha=Math.max(0,o),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var ws=(e,t,n,i)=>{const r=t.filter(e=>"line"===e.type);for(const t of r){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,i.width*n,i.height),e.clip());const r=t.style.stroke||"#007bff",o=vn(e,r)||r,s=t.style.strokeWidth||2,a=t.colorThresholds,c=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),e.lineWidth=s,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){vs(e,t.path,o,s,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const l=kn(t.curve),u=a&&a.length>0&&c&&c.length===t.path.length,d=t._decayOpacities;if(d&&d.length===t.path.length&&!u){e.strokeStyle=o;const n=t.style.opacity??1;for(let i=0;t.path.length-1>i;i++)e.globalAlpha=.5*(d[i]+d[i+1])*n,e.beginPath(),e.moveTo(t.path[i][0],t.path[i][1]),e.lineTo(t.path[i+1][0],t.path[i+1][1]),e.stroke()}else if(u){let n=function(t,n,i){e.beginPath(),e.strokeStyle=t,e.moveTo(n,i),d=!0},i=function(){d&&(e.stroke(),d=!1)},r=null,s=null,l=null,u=null,d=!1;for(let d=0;t.path.length>d;d++){const[h,f]=t.path[d],p=c[d],y=bs(p,a,o);if(null!==r&&null!==u&&null!==l){if(y===u)e.lineTo(h,f);else{const t=[];for(const e of a){const n=e.value;(l>n||n>p)&&(n>l||p>n)||l===n||p===n||t.push({t:(n-l)/(p-l)})}t.sort((e,t)=>e.t-t.t);for(const c of t){const t=r+(h-r)*c.t,u=s+(f-s)*c.t,d=bs(l+(p-l)*Math.min(c.t+1e-4,1),a,o);e.lineTo(t,u),i(),n(d,t,u)}e.lineTo(h,f)}r=h,s=f,l=p,u=y}else n(y,h,f),r=h,s=f,l=p,u=y}i()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?Mn(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||o,l)(0,xs.line)().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,i]=t.path[0];e.moveTo(n,i);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}e.stroke()}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=Sn(e,t.style.fill,t.style.fill),l&&!u)(0,xs.line)().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,i]=t.path[0];e.moveTo(n,i);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}const n=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],i.height),e.lineTo(n,i.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function ks(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ss(e,t,n=.3){ks(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function As(e,t,n=.6){if(!ks(t))return;const i=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,r=t.cx??t.x??0,o=t.cy??t.y??0;e.beginPath(),e.arc(r,o,i,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Ms(e,t,n,i=.35){ks(t)&&(e.globalAlpha=t._pulseIntensity*i,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}var Ps=require("d3-shape");function _s(e,t){const n=kn(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const i=(0,Ps.area)().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),i(t.topPath)}}var js=(e,t,n,i)=>{const r=t.filter(e=>"area"===e.type);for(const t of r){if(2>t.topPath.length)continue;let n=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),n=!0);const r=t._introClipFraction;void 0!==r&&1>r&&(e.save(),e.beginPath(),e.rect(0,0,i.width*r,i.height),e.clip());const o=Sn(e,t.style.fill,"#4e79a7"),s=t._decayOpacities;if(s&&s.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=o;for(let i=0;t.topPath.length-1>i;i++)e.globalAlpha=.5*(s[i]+s[i+1])*n,e.beginPath(),e.moveTo(t.topPath[i][0],t.topPath[i][1]),e.lineTo(t.topPath[i+1][0],t.topPath[i+1][1]),e.lineTo(t.bottomPath[i+1][0],t.bottomPath[i+1][1]),e.lineTo(t.bottomPath[i][0],t.bottomPath[i][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=vn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(s[n]+s[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const a=t.style.opacity??1;if(_s(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let i=-1/0;for(const e of t.bottomPath)e[1]>i&&(i=e[1]);const r=An(e,t.fillGradient,"string"==typeof o?o:"#4e79a7",0,n,0,i);e.fillStyle=r||o,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=o;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(_s(e,t),Ms(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?Mn(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||vn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const i=kn(t.curve);if(e.beginPath(),i)(0,Ps.line)().x(e=>e[0]).y(e=>e[1]).curve(i).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}void 0!==r&&1>r&&e.restore(),n&&e.restore(),e.globalAlpha=1}},Cs=(e,t,n,i)=>{const r=t.filter(e=>"point"===e.type);if(0!==r.length){e.save();try{const t=e.globalAlpha;for(const n of r)e.beginPath(),e.arc(n.x,n.y,n.r,0,2*Math.PI),e.globalAlpha=t*(n.style.opacity??n.style.fillOpacity??1),e.fillStyle=Sn(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=Sn(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),As(e,n)}finally{e.restore()}}},Is=new Map;function Ts(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=Is.get(t);return n||(n=new Path2D(ht(e.symbolType,e.size)),Is.size>256&&Is.clear(),Is.set(t,n)),n}catch{return null}}var Rs=(e,t)=>{const n=e.globalAlpha;for(const i of t){if("symbol"!==i.type)continue;const t=i;if(0>=t.size)continue;const r=Ts(t);if(!r)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const o=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*o*(t.style.fillOpacity??1),e.fillStyle=Sn(e,t.style.fill,"#4e79a7"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*o,e.strokeStyle=Sn(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}e.globalAlpha=n};function Ls(e,t,n,i,r){if(0>=t.size)return;const o=t.glyph;if(!o||!o.parts?.length)return;const s=an(o,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const c=t=>{const n=Sn(e,t,t);return"string"==typeof n?n:t},l=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,i),t.rotation&&e.rotate(t.rotation),e.translate(s.offsetX,s.offsetY),e.scale(s.scale,s.scale),e.globalAlpha=r*a*(t.style.fillOpacity??1);const u=dn(o,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&fn(e,o,l,t.accent,t.ghostColor,c),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),fn(e,o,l,t.accent,void 0,c),e.restore()}function $s(e,t){const{x:n,y:i,w:r,h:o}=t,{tl:s,tr:a,br:c,bl:l}=Zr(t);e.beginPath(),e.moveTo(n+s,i),e.lineTo(n+r-a,i),a>0&&e.arcTo(n+r,i,n+r,i+a,a),e.lineTo(n+r,i+o-c),c>0&&e.arcTo(n+r,i+o,n+r-c,i+o,c),e.lineTo(n+l,i+o),l>0&&e.arcTo(n,i+o,n,i+o-l,l),e.lineTo(n,i+s),s>0&&e.arcTo(n,i,n+s,i,s),e.closePath()}function Es(e){switch(e.roundedEdge){case"bottom":return{x0:e.x,y0:e.y+e.h,x1:e.x,y1:e.y};case"right":return{x0:e.x+e.w,y0:e.y,x1:e.x,y1:e.y};case"left":return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y};default:return{x0:e.x,y0:e.y,x1:e.x,y1:e.y+e.h}}}var Ds=(e,t,n,i)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)zs(e,t);else if(t.cornerRadii&&Kr(t.cornerRadii)){const n=Sn(e,t.style.fill,vn(e,"var(--semiotic-primary, #007bff)")),i=Es(t),r=t.fillGradient&&"string"==typeof n?An(e,t.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;e.fillStyle=r||n,$s(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=vn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=Sn(e,t.style.fill,vn(e,"var(--semiotic-primary, #007bff)")),i=Es(t),r=t.fillGradient&&"string"==typeof n?An(e,t.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;e.fillStyle=r||n;const o=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:c,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+c-o,a),e.arcTo(s+c,a,s+c,a+o,o),e.lineTo(s+c,a+l-o),e.arcTo(s+c,a+l,s+c-o,a+l,o),e.lineTo(s,a+l);break;case"left":e.moveTo(s+c,a),e.lineTo(s+o,a),e.arcTo(s,a,s,a+o,o),e.lineTo(s,a+l-o),e.arcTo(s,a+l,s+o,a+l,o),e.lineTo(s+c,a+l);break;case"bottom":e.moveTo(s,a),e.lineTo(s+c,a),e.lineTo(s+c,a+l-o),e.arcTo(s+c,a+l,s+c-o,a+l,o),e.lineTo(s+o,a+l),e.arcTo(s,a+l,s,a+l-o,o);break;default:e.moveTo(s,a+l),e.lineTo(s,a+o),e.arcTo(s,a,s+o,a,o),e.lineTo(s+c-o,a),e.arcTo(s+c,a,s+c,a+o,o),e.lineTo(s+c,a+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=vn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=Sn(e,t.style.fill,vn(e,"var(--semiotic-primary, #007bff)")),i=Es(t),r=t.fillGradient&&"string"==typeof n?An(e,t.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;e.fillStyle=r||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=vn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}Ss(e,t),e.globalAlpha=1}};function zs(e,t){const n=t.style.icon,i=t.style.iconPadding||2,r=Math.min(t.w,t.h)-i;if(0>=r)return;const o=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),o){const o=r+i,s=t.x+(t.w-r)/2;for(let i=t.y+t.h-r;i>=t.y-r;i-=o)e.drawImage(n,s,i,r,r)}else{const o=r+i,s=t.y+(t.h-r)/2;for(let i=t.x;t.x+t.w>i;i+=o)e.drawImage(n,i,s,r,r)}e.restore()}function Bs(e){const[t,n,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*i>128?"#000":"#fff"}function Fs(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var Ns=(e,t,n,i)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;if(null!=n?.opacity&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=vn(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Ss(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):Fs(t.value),i=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,o=t.y+t.h/2;e.fillStyle=Bs(t.fill),e.font=i+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,o)}}}finally{e.restore()}},Os=(e,t,n,i)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const r=(t._decayOpacity??1)*(t.style?.opacity??1);1!==r&&(e.globalAlpha=r);const o=vn(e,t.wickColor)||t.wickColor,s=60>i.height,a=s?Math.max(t.wickWidth,2):t.wickWidth,c=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=o,e.lineWidth=a,e.stroke()};if(s||c(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*i.height));e.fillStyle=o,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),i=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor,o=vn(e,r)||r;e.fillStyle=o,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(i,1)),e.strokeStyle=o,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(i,1))}s&&c(),e.restore()}},Ws={line:[js,ws,Cs],area:[js,Cs],stackedarea:[js,Cs],scatter:[Cs,Rs],bubble:[Cs,Rs],heatmap:[Ns],bar:[Ds],swarm:[Cs],waterfall:[(e,t,n,i)=>{Ds(e,t);const r=t.filter(e=>"rect"===e.type);if(2>r.length)return;const o=r[0].datum,s=o?._connectorStroke;if(s){e.save(),e.strokeStyle=vn(e,s)||s,e.lineWidth=o?._connectorWidth??1,e.setLineDash([]);for(let t=0;r.length-1>t;t++){const i=r[t],o=r[t+1],s=i.datum,a=o.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const c=n.y(s.cumEnd),l=i.x+i.w,u=o.x;e.beginPath(),e.moveTo(l,c),e.lineTo(u,c),e.stroke()}e.restore()}}],candlestick:[Os],mixed:[js,ws,Cs],custom:[js,Ds,Ns,ws,Cs,Rs,(e,t)=>{const n=e.globalAlpha;for(const i of t)"glyph"===i.type&&Ls(e,i,i.x,i.y,n);e.globalAlpha=n},Os]};require("react/jsx-runtime");var qs=require("react/jsx-runtime");function Ys(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function Hs({hover:e}){const t=e.data??{},n=t.y??t.value,i=t.x??t.time;if(void 0===n&&void 0===i){const e=function(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,i=!1!==t.skipPositional,r=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(i&&H.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&r.push({key:t,lower:t.toLowerCase(),value:n})}if(0===r.length)return{entries:[]};let o=r.findIndex(e=>W.includes(e.lower));const s=o>=0;0>o&&(o=r.findIndex(e=>"id"===e.lower)),0>o&&(o=r.findIndex(e=>"string"==typeof e.value));const a=0>o?void 0:r[o];let c=r.filter((e,t)=>t!==o);s&&(c=c.filter(e=>"id"!==e.lower));const l=X(c,q),u=X(c,Y),d=new Set(q),h=new Set(Y),f=[];l&&f.push({key:l.key,value:l.value}),u&&f.push({key:u.key,value:u.value});for(const e of c){if(f.length>=n)break;e!==l&&e!==u&&(d.has(e.lower)||h.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}(t);if(null!=e.title||e.entries.length>0)return(0,qs.jsxs)("div",{className:"semiotic-tooltip",style:V,children:[null!=e.title&&(0,qs.jsx)("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>(0,qs.jsxs)("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",(0,qs.jsx)("span",{style:{fontWeight:600},children:Ys(e.value)})]},e.key))]})}return(0,qs.jsxs)("div",{className:"semiotic-tooltip",style:V,children:[(0,qs.jsx)("div",{style:{fontWeight:600,marginBottom:2},children:Ys(n)}),(0,qs.jsx)("div",{style:{opacity:.7,fontSize:11},children:Ys(i)})]})}Hs.ownsChrome=!0;var Xs=require("react/jsx-runtime"),Gs={top:20,right:20,bottom:30,left:40},Vs=ko;function Us(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var Ks=(0,ie.memo)((0,ie.forwardRef)(function(e,t){const{chartType:n,runtimeMode:i,data:r,chunkThreshold:o,chunkSize:s,xAccessor:a,yAccessor:c,accessorRevision:l,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:f,groupAccessor:p,lineDataAccessor:y,curve:g,normalize:m,baseline:x,stackOrder:b,binSize:v,valueAccessor:w,arrowOfTime:k="right",windowMode:S="sliding",windowSize:A=200,timeAccessor:M,xExtent:P,yExtent:_,extentPadding:j=.1,scalePadding:C,sizeRange:I,size:T=[500,300],responsiveWidth:R,responsiveHeight:L,margin:$,className:E,background:D,lineStyle:z,pointStyle:N,areaStyle:W,barStyle:q,waterfallStyle:Y,swarmStyle:H,barColors:X,colorScheme:G,boundsAccessor:V,boundsStyle:U,y0Accessor:K,band:Z,gradientFill:Q,lineGradient:J,areaGroups:ee,openAccessor:te,highAccessor:re,lowAccessor:oe,closeAccessor:se,candlestickStyle:ae,showAxes:ce=!0,axes:le,xLabel:ue,yLabel:de,yLabelRight:pe,xFormat:ye,yFormat:ge,axisExtent:me,tickFormatTime:be,tickFormatValue:ve,hoverAnnotation:we,tooltipContent:ke,customHoverBehavior:Se,customClickBehavior:Ae,enableHover:Me,hoverRadius:Pe=30,tooltipMode:_e,annotations:je,autoPlaceAnnotations:Ce,svgAnnotationRules:Ie,showGrid:Te,legend:Re,legendHoverBehavior:Le,legendClickBehavior:$e,legendHighlightedCategory:Ee,legendIsolatedCategories:De,legendPosition:ze,legendLayout:Be,legendCategoryAccessor:Fe,onCategoriesChange:Ne,backgroundGraphics:Oe,foregroundGraphics:We,canvasPreRenderers:qe,svgPreRenderers:Ye,title:He,categoryAccessor:Xe,brush:Ge,onBrush:Ve,decay:Ue,pulse:Ke,transition:Ze,animate:Qe,staleness:Je,heatmapAggregation:et,heatmapXBins:tt,heatmapYBins:nt,showValues:it,heatmapValueFormat:rt,marginalGraphics:st,pointIdAccessor:at,xScaleType:ct,yScaleType:lt,accessibleTable:ut=!0,description:dt,summary:ht,linkedCrosshairName:ft,linkedCrosshairSourceId:pt,customLayout:yt,onLayoutError:gt,layoutConfig:mt,layoutSelection:xt}=e,bt=(0,ie.useId)().replace(/:/g,""),vt=(0,ie.useRef)(!1),wt=(0,ie.useRef)({w:-1,h:-1}),kt=(0,ie.useRef)(!1),St=ls({sizeProp:T,responsiveWidth:R,responsiveHeight:L,userMargin:$,marginDefault:Gs,animate:Qe,transitionProp:Ze,themeDirtyRef:vt}),At=ho(),Mt=go(),{reducedMotionRef:Pt,responsiveRef:_t,size:jt,currentTheme:Ct,transition:It,introEnabled:Tt,tableId:Rt,rafRef:Lt,renderFnRef:$t,scheduleRender:Et,cancelRender:Dt}=St;let zt=St.margin;if(st){const e=60,t={...St.margin};st.top&&e>t.top&&(t.top=e),st.bottom&&e>t.bottom&&(t.bottom=e),st.left&&e>t.left&&(t.left=e),st.right&&e>t.right&&(t.right=e),zt=t}const Bt=jt[0]-zt.left-zt.right,Ft=jt[1]-zt.top-zt.bottom,Nt=(0,ie.useMemo)(()=>B(r),[r]),Wt=we??Me,qt=(0,ie.useRef)(null),Yt=(0,ie.useRef)(null),[Xt,Vt]=(0,ie.useState)(0),Ut=(0,ie.useRef)(0),[Kt,Zt]=(0,ie.useState)(null),en=(e,t)=>"function"==typeof e?e({size:jt,margin:zt,scales:t}):e,tn=en(We,Kt),nn=en(Oe,Kt),rn=(0,ie.useRef)(null),on=(0,ie.useRef)(null),sn=(0,ie.useRef)(void 0),[an,cn]=(0,ie.useState)(null),ln=(0,ie.useRef)(Vs.primary),un=(0,ie.useRef)(function(){let e=-1,t=ko;return{resolve(n){if(!n)return ko;const i=gn;return i===e||(t=function(e){if(!e)return ko;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),i=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),o=t.getPropertyValue("--semiotic-primary").trim(),s=i||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),c=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return s||a||n||o?{axisStroke:c||ko.axisStroke,tickText:s||ko.tickText,crosshair:s?So(s,"66"):ko.crosshair,hoverFill:l?So(l,"4D"):ko.hoverFill,hoverStroke:s?So(s,"99"):ko.hoverStroke,pointRing:l||ko.pointRing,primary:o||ko.primary,background:l||ko.background}:ko}(n),e=i),t},invalidate(){e=-1}}}()),dn=(0,ie.useRef)(!1),fn=(0,ie.useRef)(new Ht),pn=(0,ie.useRef)([]),yn=(0,ie.useRef)(Fe),mn=(0,ie.useRef)(Ne);yn.current=Fe,mn.current=Ne;const[xn,bn]=(0,ie.useState)(!1),[wn,kn]=(0,ie.useState)([]),[Sn,An]=(0,ie.useState)([]),Mn="streaming"===i||["bar","swarm","waterfall"].includes(n),Pn=function(e){const t=(0,xo.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return vo(e,t);if(!wo(e)||!wo(t))return!1;const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;const n=e[i],r=t[i];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!vo(n,r))return!1}else{if(!wo(n)||!wo(r))return!1;if(!bo(n,r))return!1}}return!0}(t.current,e)||(t.current=e),t.current}((0,ie.useMemo)(()=>({chartType:n,runtimeMode:Mn?"streaming":"bounded",windowSize:A,windowMode:S,arrowOfTime:Mn?k:"right",extentPadding:j,scalePadding:C,axisExtent:me,xAccessor:a,yAccessor:c,accessorRevision:l,timeAccessor:Mn?M:void 0,valueAccessor:w,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:f,groupAccessor:p||(y?"_lineGroup":void 0),categoryAccessor:Xe,lineDataAccessor:y,xScaleType:ct,yScaleType:lt,xExtent:P,yExtent:_,sizeRange:I,binSize:v,normalize:m,baseline:x,stackOrder:b,boundsAccessor:V,boundsStyle:U,y0Accessor:K,band:Z,gradientFill:!0===Q?{topOpacity:.8,bottomOpacity:.05}:!1===Q?void 0:Q,areaGroups:ee?new Set(ee):void 0,lineGradient:J,openAccessor:te,highAccessor:re,lowAccessor:oe,closeAccessor:se,candlestickStyle:ae,lineStyle:z,pointStyle:N,areaStyle:W,swarmStyle:H,waterfallStyle:Y,colorScheme:G,barColors:X,barStyle:q,annotations:je,decay:Ue,pulse:Ke,transition:It,introAnimation:Tt,staleness:Je,heatmapAggregation:et,heatmapXBins:tt,heatmapYBins:nt,showValues:it,heatmapValueFormat:rt,pointIdAccessor:at,curve:g,themeCategorical:Ct?.colors?.categorical,themeSemantic:xe(Ct),themeSequential:Ct?.colors?.sequential,themeDiverging:Ct?.colors?.diverging,customLayout:yt,onLayoutError:gt,layoutConfig:mt,layoutMargin:zt}),[n,A,S,k,j,C,me,a,c,l,M,w,ct,lt,u,d,h,f,p,Xe,y,P,_,I,v,m,x,b,V,U,K,Z,Q,J,ee,te,re,oe,se,ae,z,N,W,H,Y,q,G,X,je,Ue,Ke,It?.duration,It?.easing,Tt,Je,et,tt,nt,it,rt,Mn,at,g,Ct,yt,gt,mt,zt])),_n=(0,ie.useRef)(null);_n.current||(_n.current=new Ot(Pn));const Tn=function(e,t,n,i){return(0,hs.useCallback)(()=>{const r=t.current,o=n.current;if(!o||!r)return;const s=function(e,t){if(!t)return[];const n=new Set,i=[];for(const r of e){if(!r||"object"!=typeof r)continue;const e="function"==typeof t?t(r):r[t];if(null==e)continue;const o=e+"";n.has(o)||(n.add(o),i.push(o))}return i}(e.current?.getData()??[],r);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(s,i.current)||(i.current=s,o(s))},[t,n,i,e])}(_n,yn,mn,pn);!function(e,t,n,i){(0,Jt.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,i()},[t,i,e,n])}(_n,Pn,vt,Et),function(e,t,n,i){const r=(0,Jt.useRef)(null);(0,Jt.useEffect)(()=>{const o=e.current;if(!o)return;const s=t??null;r.current!==s&&(r.current=s,o.setLayoutSelection(s),o.hasCustomRestyle?o.restyleScene(s):n.current=!0,i())},[t,i,e,n])}(_n,xt,vt,Et);const Rn=(0,ie.useRef)(null);Rn.current||(Rn.current=new fe(e=>{const t=_n.current;t&&t.ingest(e)&&(vt.current=!0,Et())},{chunkThreshold:o,chunkSize:s})),(0,ie.useEffect)(()=>{Rn.current?.updateChunkOptions({chunkThreshold:o,chunkSize:s})},[o,s]);const Ln=(0,ie.useCallback)(e=>{Rn.current?.push(e)},[]),$n=(0,ie.useCallback)(e=>{Rn.current?.pushMany(e)},[]),En=(0,ie.useCallback)(()=>{Rn.current?.clear(),_n.current?.clear(),vt.current=!0,Et()},[Et]);(0,ie.useImperativeHandle)(t,()=>({push:Ln,pushMany:$n,remove:e=>{Rn.current?.flush();const t=_n.current?.remove(e)??[];return t.length>0&&(rn.current&&t.some(e=>e===rn.current?.data)&&(rn.current=null,cn(null)),vt.current=!0,Et()),t},update:(e,t)=>{Rn.current?.flush();const n=_n.current?.update(e,t)??[];return n.length>0&&(vt.current=!0,Et()),n},clear:En,getData:()=>(Rn.current?.flush(),_n.current?.getData()??[]),getScales:()=>_n.current?.scales??null,getExtents:()=>_n.current?.getExtents()??null,getCustomLayout:()=>_n.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>_n.current?.lastCustomLayoutFailure??null}),[Ln,$n,En,Et]),(0,ie.useEffect)(()=>{if(r){if(y&&Nt.length>0&&"object"==typeof Nt[0]&&null!==Nt[0]){const e="string"==typeof y?y:"coordinates";if(Array.isArray(Nt[0][e])){const t=[];for(const n of Nt){const i=n[e];if(Array.isArray(i)){const e=n.label||n.id||n.key;if(null!=e)for(const n of i)t.push({...n,_lineGroup:e});else for(const e of i)t.push(e)}}return void Rn.current?.setBoundedData(t)}}Rn.current?.setBoundedData(Nt)}},[r,Nt,y]);const{hoverHandlerRef:Dn,hoverLeaveRef:zn,onPointerMove:Bn,onPointerLeave:Fn}=St;Dn.current=e=>{if(!Wt)return;const t=qt.current;if(!t)return;const i=t.getBoundingClientRect(),r=e.clientX-i.left-zt.left,o=e.clientY-i.top-zt.top;if(0>r||r>Bt||0>o||o>Ft)return void(rn.current&&(rn.current=null,on.current=null,cn(null),Se&&(Se(null),vt.current=!0),Et()));const s=_n.current;if(!s||0===s.scene.length)return;const c=F(Pe,e.pointerType),l=Cn(s.scene,r,o,c,s.quadtree,s.maxPointRadius),u="multi"===_e,d=()=>{rn.current&&(rn.current=null,on.current=null,cn(null),Se&&Se(null),Et())};if(!l&&!u)return void d();const h=u||!l?r:l.x,f=u||!l?o:l.y,p=l?.datum?ot(l.datum,s.resolvedRibbons):{},y=s.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=O(p,h,f,null!=g?{xValue:g,xPx:h}:void 0);if(u&&s.scene.length>0&&s.scales){const e=function(e,t,n=30){const i=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const o=In(jn(e.path,e.curve),t,n);if(null===o)continue;const s=Nn(e.path,t);i.push({node:r,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:o,group:e.group,color:e.style.stroke})}else if("area"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const o=jn(e.topPath,e.curve),s=jn(e.bottomPath,e.curve),a=In(o,t,n);if(null===a)continue;const c=In(s,t,n),l=Nn(e.topPath,t);i.push({node:r,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.topPath[l][0],y:a,y0:c??void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return i}(s.scene,h,Math.max(c,Bt));if(e.length>0){const t=s.scales.y.invert,i=ln.current,r=y?y(h):h;if(l)m.xValue=r,m.xPx=h;else{const e={xValue:r};"string"==typeof a&&(e[a]=r),m=O(e,h,f,{xValue:r,xPx:h})}m.allSeries=e.map(e=>{const r=t?t(e.y):e.y,o=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===n&&null!=o?r-o:r,valuePx:e.y,color:e.color||i,datum:ot(e.datum,s.resolvedRibbons)}})}}l||m.allSeries?.length?(rn.current=m,on.current=l?.node??null,cn(m),Se&&(Se(m),vt.current=!0),Et()):d()},zn.current=()=>{rn.current&&(rn.current=null,on.current=null,cn(null),Se&&(Se(null),vt.current=!0),Et())};const Yn=(0,ie.useRef)(()=>{});Yn.current=e=>{if(!Ae)return;const t=qt.current;if(!t)return;const n=t.getBoundingClientRect(),i=e.clientX-n.left-zt.left,r=e.clientY-n.top-zt.top;if(0>i||i>Bt||0>r||r>Ft)return void Ae(null);const o=_n.current;if(!o||0===o.scene.length)return void Ae(null);const s=F(Pe,sn.current),a=Cn(o.scene,i,r,s,o.quadtree,o.maxPointRadius);if(!a)return void Ae(null);const c=a.datum||{},l=o.scales?.x?.invert,u="function"==typeof l?l(a.x):void 0;Ae(O(c,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0))};const Hn=(0,ie.useCallback)(e=>Yn.current(e),[]),Gn=(0,ie.useRef)(-1),Un=(0,ie.useRef)(null),Kn=(0,ie.useRef)(null),Zn=(0,ie.useCallback)(e=>{const t=_n.current;if(!t||0===t.scene.length)return;const n=t.version;let i;if(Kn.current&&Kn.current.version===n)i=Kn.current.graph;else{const e=function(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const e=hn(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"});break}case"line":{const e=n,i=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.path.length>n&&i.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:i[n],shape:"circle",group:r});break}case"area":{const e=n,i=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.topPath.length>n&&i.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:i[n],shape:"circle",group:r});break}case"rect":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===e.length)return;i=function(e){const t=new Map;for(const n of e){const e=n.group??"_default";let i=t.get(e);i||(i=[],t.set(e,i)),i.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const i=t.get(e),r=t.get(n);return(i.length>0?i[0].y:0)-(r.length>0?r[0].y:0)}),i=Array.from(t.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const r=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=i[e].datum?.id;null!=t&&r.set(t+"",e)}return{flat:i,groups:n,byGroup:t,idToIdx:r}}(e),Kn.current={version:n,graph:i}}const r=Gn.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Gn.current=0;const n=i.flat[0];Un.current={shape:n.shape,w:n.w,h:n.h};const r=Wn({...n,datum:ot(n.datum,t.resolvedRibbons)});return rn.current=r,cn(r),Se&&Se(r),void Et()}const o=function(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[n];return{flatIndex:n,group:i.group??"_default",indexInGroup:i._groupIndex??0}}(i,r),s=function(e,t,n){const{group:i,indexInGroup:r}=t,o=n.byGroup.get(i);switch(e){case"ArrowRight":return o.length-1>r?o[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?o[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(i);return n.groups.length-1>e?On(n,n.groups[e+1],o[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(i);return e>0?On(n,n.groups[e-1],o[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}(e.key,o,i);if(null===s)return;if(e.preventDefault(),0>s)return Gn.current=-1,Un.current=null,rn.current=null,on.current=null,cn(null),Se&&Se(null),void Et();Gn.current=s;const a=i.flat[s];Un.current={shape:a.shape,w:a.w,h:a.h};const c=Wn({...a,datum:ot(a.datum,t.resolvedRibbons)});rn.current=c,cn(c),Se&&Se(c),Et()},[Se,Et]),Qn=(0,ie.useCallback)(e=>{sn.current=e.pointerType,Gn.current=-1,Un.current=null,Bn(e)},[Bn]),Jn=(0,ie.useCallback)(e=>{sn.current="mouse",Gn.current=-1,Un.current=null,Bn({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[Bn]),ei=(0,ie.useCallback)(e=>{sn.current=e.pointerType},[]);$t.current=()=>{Lt.current=null;const e=qt.current,t=Yt.current;if(!e||!t)return;const i=_n.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),o=i.advanceTransition(Pt.current?r+1e6:r),s=!Pt.current&&o,l=wt.current.w!==Bt||wt.current.h!==Ft,u=vt.current||o||l,d=i.consumeStylePaintPending();let h=!1;const f=i.getLastUpdateResult(),p=fn.current.beforeCompute(f,s);!u||s&&!l||(i.computeScene({width:Bt,height:Ft}),wt.current={w:Bt,h:Ft},h=!0,Tn()),fn.current.afterCompute(p,h,l);const y=function(e,t,n,i){const r=i.current,o=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,s=!o&&e.hasActivePulsesAt(t),a=!(n||o||!s&&!r)&&e.refreshPulse(t);return i.current=s,{changed:a,pending:s}}(i,r,h,kt),g=ds(),m=un.current.resolve(e);ln.current=m.primary;const x=Xn(Je,i.lastIngestTime>0?r-i.lastIngestTime:0),b=Je&&x.isStale;if(u||d||y.changed){const t=us(e,jt,zt,g);if(t){if(t.clearRect(-zt.left,-zt.top,jt[0],jt[1]),Je&&1>x.alpha&&(t.globalAlpha=x.alpha),function(e,t){const{background:n,hasBackgroundGraphics:i=!1,themeBackground:r="",x:o=0,y:s=0,width:a,height:c}=t;if("transparent"===n)return!1;if(i)return!1;const l=n||(r&&"transparent"!==r?r:"")||null;if(!l)return!1;const u=vn(e,l);u&&(e.fillStyle=u,e.fillRect(o,s,a,c))}(t,{background:D,hasBackgroundGraphics:!!Oe,themeBackground:m.background,x:-zt.left,y:-zt.top,width:jt[0],height:jt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Bt,Ft),t.clip()),qe&&i.scales)for(const e of qe)t.save(),e(t,i.scene,i.scales,{width:Bt,height:Ft}),t.restore();const e=yt?Ws.custom:Ws[n];if(e&&i.scales)for(const n of e)n(t,i.scene,i.scales,{width:Bt,height:Ft});t.restore(),Je&&1>x.alpha&&(t.globalAlpha=1)}}const v=!!(Wt&&rn.current&&i.scales),w=!!(on.current&&Array.isArray(we)&&we.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),k=v||w;if(k||dn.current){const e=us(t,jt,zt,g);if(e&&(e.clearRect(-zt.left,-zt.top,jt[0],jt[1]),v&&rn.current&&function(e,t,n,i,r,o,s){if(!1===r.crosshair)return;const a=t.allSeries,c=a&&a.length>0,l=t.xPx??t.x;e.save();const u="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=u.stroke||s.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(c?l:t.x,0),e.lineTo(c?l:t.x,i),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),c){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(l,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const n=r.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(o)||s.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,rn.current,Bt,Ft,"object"==typeof Wt?Wt:{},on.current,m),w&&on.current&&Array.isArray(we))){const t=we.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,i,r){if(!n)return;const o="group"in n?n.group:void 0;if(void 0!==o)for(const n of t){if("line"!==n.type)continue;if(n.group!==o)continue;if(2>n.path.length)continue;const t="function"==typeof i.style?n.datum?i.style(n.datum):{}:i.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||r.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,i.scene,on.current,t,m)}dn.current=k}u&&e&&e.setAttribute("aria-label",Lo(i.scene,n+" chart"));const S=vt.current;if(vt.current=S&&s&&!h,S&&i.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!Kt||e(Kt.x.domain()[0])!==e(i.scales.x.domain()[0])||e(Kt.x.domain()[1])!==e(i.scales.x.domain()[1])||e(Kt.y.domain()[0])!==e(i.scales.y.domain()[0])||e(Kt.y.domain()[1])!==e(i.scales.y.domain()[1])||Kt.x.range()[0]!==i.scales.x.range()[0]||Kt.x.range()[1]!==i.scales.x.range()[1]||Kt.y.range()[0]!==i.scales.y.range()[0]||Kt.y.range()[1]!==i.scales.y.range()[1])&&Zt(i.scales),st){const e=i.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof c?c:e=>e[c||"y"];kn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),An(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((je&&je.length>0||yt)&&(h||s))||!h&&33>r-Ut.current||(Vt(e=>e+1),Ut.current=r),Je?.showBadge&&bn(!!b),(s||null!=i.activeTransition||y.pending)&&Et()},mo({hydrated:At,wasHydratingFromSSR:Mt,storeRef:_n,dirtyRef:vt,renderFnRef:$t,cancelRender:Dt,cleanup:()=>Rn.current?.clear()}),(0,ie.useEffect)(()=>{vt.current=!0,Et()},[n,Bt,Ft,ce,D,Oe,z,qe,Et]),function(e,t,n,i,r,o){const s=(0,qn.useRef)("fresh");(0,qn.useEffect)(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=Xn(e,c-a.lastIngestTime);l.band===s.current&&l.isStale===r||(s.current=l.band,l.isStale!==r&&o(l.isStale),n.current=!0,i())},1e3);return()=>clearInterval(a)},[e,r,i])}(Je,_n,vt,Et,xn,bn);const ti=(0,ie.useMemo)(()=>{if(ye||be)return;const e=_n.current;return e?.xIsDate&&Kt?gs(Kt.x.domain()):void 0},[ye,be,Kt]),ni=ye||be||ti,ii=Wt&&an?ke?ke(an):(0,Xs.jsx)(Hs,{hover:an}):null,ri=ii?(0,Xs.jsx)(ts,{x:an.x,y:an.y,containerWidth:Bt,containerHeight:Ft,margin:zt,className:"stream-frame-tooltip",children:ii}):null,oi=Un.current,si=(0,Xs.jsx)(Qo,{active:Gn.current>=0,hoverPoint:an,margin:zt,size:jt,shape:oi?.shape,width:oi?.w,height:oi?.h}),ai=fs(a,M,"__semiotic_resolvedX","__semiotic_resolvedTime"),ci=fs(c,w,"__semiotic_resolvedY","__semiotic_resolvedValue"),li=ai.key,ui=ci.key,di=function(e,t,n){return i=>{if(!i||!n||!e.fn&&!t.fn)return i;let r=!1;const o=i.map(n=>{const i=e.fn&&e.key&&!(e.key in n),o=t.fn&&t.key&&!(t.key in n);if(!i&&!o)return n;r=!0;const s={...n};return i&&(s[e.key]=e.fn(n)),o&&(s[t.key]=t.fn(n)),s});return r?o:i}}(ai,ci,je&&je.length>0||!1);if(co||!At&&Mt){const e=_n.current;e&&r&&(e.ingest({inserts:Nt,bounded:!0}),e.computeScene({width:Bt,height:Ft}));const t=e?.scene??[],n=e?.scales??null,i=en(We,n),o=en(Oe,n),s=ni||(()=>{if(e?.xIsDate&&n)return gs(n.x.domain())})();return(0,Xs.jsxs)("div",{ref:_t,className:"stream-xy-frame"+(E?" "+E:""),role:"img","aria-label":dt||("string"==typeof He?He:"XY chart"),style:{position:"relative",width:R?"100%":jt[0],height:L?"100%":jt[1]},children:[(0,Xs.jsx)(Go,{summary:ht}),(0,Xs.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:jt[0],height:jt[1],style:{position:"absolute",left:0,top:0},children:[(0,Xs.jsx)("g",{transform:`translate(${zt.left},${zt.top})`,children:o}),(0,Xs.jsxs)("g",{transform:`translate(${zt.left},${zt.top})`,children:[D&&(0,Xs.jsx)("rect",{x:0,y:0,width:Bt,height:Ft,fill:D}),Ye&&n&&Ye.map((e,i)=>(0,Xs.jsx)(ne.Fragment,{children:e(t,n,{width:Bt,height:Ft})},"svgpre-"+i)),t.map((e,t)=>so(e,t,bt)).filter(Boolean)]})]}),(0,Xs.jsx)(Gr,{width:Bt,height:Ft,totalWidth:jt[0],totalHeight:jt[1],margin:zt,scales:n,showAxes:ce,axes:le,xLabel:ue,yLabel:de,yLabelRight:pe,xFormat:s,yFormat:ge||ve,axisExtent:me,showGrid:Te,title:He,legend:Re,legendHoverBehavior:Le,legendClickBehavior:$e,legendHighlightedCategory:Ee,legendIsolatedCategories:De,legendPosition:ze,legendLayout:Be,foregroundGraphics:Gt(i,Qt(_n.current?.customLayoutOverlays,xt??null)),marginalGraphics:st,xValues:[],yValues:[],annotations:je,autoPlaceAnnotations:Ce,svgAnnotationRules:Ie,annotationFrame:0,xAccessor:li,yAccessor:ui,annotationData:di(e?.getData()),pointNodes:ms(e?.scene),curve:"string"==typeof g?g:void 0,linkedCrosshairName:ft,linkedCrosshairSourceId:pt})]})}return(0,Xs.jsxs)("div",{ref:_t,className:"stream-xy-frame"+(E?" "+E:""),role:"group","aria-label":dt||("string"==typeof He?He:"XY chart"),tabIndex:0,style:{position:"relative",width:R?"100%":jt[0],height:L?"100%":jt[1],overflow:"visible",touchAction:Us(Ge)},onKeyDown:Zn,children:[ut&&(0,Xs.jsx)(Vo,{tableId:Rt}),ut&&(0,Xs.jsx)(Xo,{scene:_n.current?.scene??[],chartType:n+" chart",tableId:Rt,chartTitle:"string"==typeof He?He:void 0}),(0,Xs.jsx)(Go,{summary:ht}),(0,Xs.jsx)(Uo,{hoverPoint:an}),(0,Xs.jsxs)("div",{role:"img","aria-label":dt||("string"==typeof He?He:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:Wt?Qn:void 0,onMouseMove:Wt?Jn:void 0,onPointerLeave:Wt?Fn:void 0,onMouseLeave:Wt?Fn:void 0,onPointerDown:Wt||Ae?ei:void 0,onClick:Ae?Hn:void 0,children:[nn&&(0,Xs.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:jt[0],height:jt[1],pointerEvents:"none"},children:(0,Xs.jsx)("g",{transform:`translate(${zt.left},${zt.top})`,children:nn})}),(0,Xs.jsx)(Yr,{width:Bt,height:Ft,totalWidth:jt[0],totalHeight:jt[1],margin:zt,scales:Kt,showAxes:ce,axes:le,showGrid:Te,xFormat:ni,yFormat:ge||ve,axisExtent:me}),(0,Xs.jsx)("canvas",{ref:qt,"aria-label":Lo(_n.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),(0,Xs.jsx)("canvas",{ref:Yt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,Xs.jsx)(Gr,{width:Bt,height:Ft,totalWidth:jt[0],totalHeight:jt[1],margin:zt,scales:Kt,showAxes:ce,axes:le,xLabel:ue,yLabel:de,yLabelRight:pe,xFormat:ni,yFormat:ge||ve,axisExtent:me,showGrid:Te,title:He,legend:Re,legendHoverBehavior:Le,legendClickBehavior:$e,legendHighlightedCategory:Ee,legendIsolatedCategories:De,legendPosition:ze,legendLayout:Be,foregroundGraphics:Gt(tn,Qt(_n.current?.customLayoutOverlays,xt??null)),marginalGraphics:st,xValues:wn,yValues:Sn,annotations:je,autoPlaceAnnotations:Ce,svgAnnotationRules:Ie,annotationFrame:Xt,xAccessor:li,yAccessor:ui,annotationData:di(_n.current?.getData()),pointNodes:ms(_n.current?.scene),curve:"string"==typeof g?g:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==D&&!Oe,linkedCrosshairName:ft,linkedCrosshairSourceId:pt}),(Ge||Ve)&&(0,Xs.jsx)(he,{width:Bt,height:Ft,totalWidth:jt[0],totalHeight:jt[1],margin:zt,dimension:Ge?.dimension??"xy",scales:Kt,onBrush:Ve??(()=>{}),binSize:v,snap:Ge?.snap,binBoundaries:Ge?.binBoundaries??("bar"===n?_n.current?.getBinBoundaries():void 0),snapDuring:Ge?.snapDuring,streaming:"streaming"===i}),Je?.showBadge&&(0,Xs.jsx)(Vn,{isStale:xn,position:Je.badgePosition}),si,ri]})]})}));Ks.displayName="StreamXYFrame";var Zs=Ks,Qs=require("react"),Js=require("react"),ea=(require("react/jsx-runtime"),(0,Js.createContext)(null));function ta(){return(0,Js.useContext)(ea)}var na=require("react");function ia(e){const t=[];for(const[n,i]of Object.entries(e.fields))if("point"===i.type)t.push(e=>i.values.has(e[n]));else{const[e,r]=i.range;t.push(t=>{const i=t[n];return i>=e&&r>=i})}return e=>t.every(t=>t(e))}function ra(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function oa(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[sa,aa]=ge(e=>({selections:new Map,setClause(t,n){e(e=>{const i=e.selections.get(t),r=i?.clauses.get(n.clientId);if(r&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,i]of n){const n=t.fields[e];if(!n||!oa(i,n))return!1}return!0}(r,n))return{};const o=new Map(e.selections),s=ra(o,t),a=new Map(s.clauses);return a.set(n.clientId,n),o.set(t,{...s,clauses:a}),{selections:o}})},clearClause(t,n){e(e=>{const i=e.selections.get(t);if(!i||!i.clauses.has(n))return{};const r=new Map(e.selections),o=new Map(i.clauses);return o.delete(n),r.set(t,{...i,clauses:o}),{selections:r}})},setResolution(t,n){e(e=>{const i=e.selections.get(t);if(i?.resolution===n)return{};const r=new Map(e.selections),o=ra(r,t);return r.set(t,{...o,resolution:n}),{selections:r}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const i=new Map(e.selections);return i.set(t,{...n,clauses:new Map}),{selections:i}})}})),[ca,la]=ge(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}})),ua=require("react");function da(e){const t=(0,ua.useId)(),n=e.clientId||t,{name:i}=e,r=aa(e=>e.selections.get(i)),o=aa(e=>e.setClause),s=aa(e=>e.clearClause),a=(0,ua.useMemo)(()=>!!r&&r.clauses.size>0,[r]);return{predicate:(0,ua.useMemo)(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[i,r]of e.clauses)"crossfilter"===e.resolution&&i===t||n.push(ia(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,n):()=>!0,[r,n]),isActive:a,selectPoints:(0,ua.useCallback)(e=>{const t={};let r=!1;for(const[n,i]of Object.entries(e))t[n]={type:"point",values:new Set(i)},r=!0;r&&o(i,{clientId:n,type:"point",fields:t})},[n,i,o]),selectInterval:(0,ua.useCallback)(e=>{const t={};let r=!1;for(const[n,i]of Object.entries(e))t[n]={type:"interval",range:i},r=!0;r&&o(i,{clientId:n,type:"interval",fields:t})},[n,i,o]),clear:(0,ua.useCallback)(()=>{s(i,n)},[s,i,n]),clientId:n}}require("react/jsx-runtime");var ha=(0,na.createContext)(!1);(0,na.createContext)(!1);var fa=(0,na.createContext)(null),pa="undefined"==typeof window?na.useEffect:na.useLayoutEffect;var ya=c(require("react")),ga={light:we,dark:ke,"high-contrast":Se,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#64717f",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#c63b3b",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function ma(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function xa(e,t,n){const i=e.xValue??t?.[n];if(null==i)return null;const r=Number(i);return Number.isFinite(r)?r:null}function ba(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}function va(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}require("react/jsx-runtime"),ya.createContext(void 0);var wa={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function ka(e,t={}){const n=t.mobileSemantics?.interaction,i="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,r="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,o=!!n||void 0!==i,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!r&&!o)return wa;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??i??44,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??44,standardControls:a.standardControls??!1}}function Sa(){const e=Pe(e=>e.theme),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function Aa({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:i=!1,onObservation:r,chartType:o,chartId:s,onClick:a,hoverHighlight:c,colorByField:l,mobileInteraction:u}){const d=(0,Qs.useId)(),h=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),f="series"===h?.mode?[h.seriesField||l||n[0]].filter(e=>!!e):h?.fields||n||[],p=da({name:e?.name||"__unused__",fields:f}),y=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:i,isActive:r,selectPoints:o,clear:s}=da({name:t,fields:n});return{onHover:(0,ua.useCallback)(e=>{if(!e)return void s();const t={};for(const i of n){const n=e[i];void 0!==n&&(t[i]=[n])}(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(t)&&o(t)},[n,o,s,t]),predicate:i,isActive:r}}({name:h?.name||"hover",fields:f}),g=la(e=>e.pushObservation),m=e?{isActive:p.isActive,predicate:p.predicate}:null,[x,b]=(0,Qs.useState)(null),v=(0,Qs.useRef)(!1),w=l||n[0],k=(0,Qs.useMemo)(()=>{if(!c||null==x||!w)return null;const e=x,t=w;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[c,x,w]),S=(0,Qs.useCallback)(e=>{const n=!e&&v.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===h?.mode&&h.xField){const n=xa(e,t,h.xField);null!=n&&function(e,t,n){const i=_r.positions.get(e);i?.locked||i&&i.xValue===t&&i.sourceId===n||(_r={positions:new Map(_r.positions).set(e,{xValue:t,sourceId:n})},Cr())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&y.onHover(t)}else"x-position"!==h?.mode||n||Ir(h.name||"hover",d),"x-position"===h?.mode||n||y.onHover(null);if(c&&w)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[w];b(null!=n?n+"":null)}else n||b(null);if(r||g){const t={timestamp:Date.now(),chartType:o||"unknown",chartId:s};if(e){const n=ba(e),i={...t,type:"hover",datum:n||{},x:e.x??0,y:e.y??0};r&&r(i),g&&g(i)}else{const e={...t,type:"hover-end"};r&&r(e),g&&g(e)}}},[t,y,h,d,r,o,s,g,c,w,u]),A=(0,Qs.useCallback)((n=!0)=>{v.current=!1,t&&"x-position"!==h?.mode&&y.onHover(null),e&&u?.tapToSelect&&p.clear(),n&&c&&b(null),"x-position"===h?.mode&&(Tr(h.name||"hover",d),Ir(h.name||"hover",d))},[t,h,y,e,u,p,c,d]),M=(0,Qs.useCallback)(n=>{const i=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),l=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===h?.mode&&h.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=xa(n,e,h.xField);null!=t&&function(e,t,n){const i=_r.positions.get(e);if(i?.locked){const t=new Map(_r.positions);return t.delete(e),_r={positions:t},Cr(),!1}_r={positions:new Map(_r.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Cr()}(h.name||"hover",t,d)}if(i)if(n){v.current=!0;const i=ba(n);if(t&&"x-position"!==h?.mode&&y.onHover(i),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=i[t];void 0!==n&&(e[t]=[n])}va(e)&&p.selectPoints(e)}if(c&&w){const e=i?.[w];b(null!=e?e+"":null)}}else l&&A();if(n||l){if(n&&a){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),a(e,{x:n.x??0,y:n.y??0})}if(r||g){const e={timestamp:Date.now(),chartType:o||"unknown",chartId:s};if(n){const t=ba(n),i={...e,type:"click",datum:t||{},x:n.x??0,y:n.y??0};r&&r(i),g&&g(i)}else{const t={...e,type:"click-end"};r&&r(t),g&&g(t)}}}},[a,r,g,o,s,h,d,u,t,y,e,p,f,c,w,A]);return(0,Qs.useEffect)(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&v.current&&A()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,A]),(0,Qs.useEffect)(()=>()=>{v.current&&A(!1)},[A]),(0,Qs.useEffect)(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{Tr(e,d),Ir(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:m,hoverSelectionHook:k,customHoverBehavior:S,customClickBehavior:M,crosshairSourceId:d}}function Ma({data:e,colorBy:t,colorScale:n,showLegend:i,legendPosition:r="right",userMargin:o,defaults:s={top:50,bottom:60,left:70,right:40},categories:a}){const c=(0,na.useContext)(ha),l=null!==(0,na.useContext)(fa),u=void 0!==i?i:!c&&!!t,d=!!t&&(u||l),h=(0,Qs.useMemo)(()=>{if(!d)return[];if(void 0!==a)return a;const n=new Set;for(const i of e){const e="function"==typeof t?t(i):i[t];null!=e&&n.add(e+"")}return Array.from(n)},[a,t,e,d]);!function(e){const t=(0,na.useContext)(fa),n=(0,na.useId)(),i=function(e){const t=new Set,n=[];for(const i of e)t.has(i)||(t.add(i),n.push(i));return n}(e),r=(0,na.useRef)([]);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(r.current,i)||(r.current=i);const o=r.current;pa(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),pa(()=>{t&&t.registerCategories(n,o)},[t,n,o])}(l&&t?h:[]);const f=(0,Qs.useMemo)(()=>{if(!u||!t)return;const i=function({data:e,colorBy:t,colorScale:n,getColor:i,strokeColor:r,strokeWidth:o,categories:s}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==o&&(n.strokeWidth=o),n},type:"fill",items:(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,o)=>{const s=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=s?i(s,t,n):n?n(r):R[o%R.length];return{label:r+"",color:a}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:$,categories:h});return 0!==i.legendGroups.reduce((e,t)=>e+t.items.length,0)?i:void 0},[u,t,e,n,h]),p=(0,Qs.useMemo)(()=>{const e="number"==typeof o?{top:o,bottom:o,left:o,right:o}:o??{},t=t=>{const n=e[t];return"number"==typeof n?n:s[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},i=t=>"number"==typeof e[t];return f&&("right"===r&&!i("right")&&110>n.right?n.right=110:"left"===r&&!i("left")&&110>n.left?n.left=110:"top"===r&&!i("top")&&50>n.top?n.top=50:"bottom"===r&&!i("bottom")&&80>n.bottom&&(n.bottom=80)),n},[s,o,f,r]);return{legend:f,margin:p,legendPosition:r}}var Pa={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function _a(e,t,n){const i=Pa[e||"primary"],r=e&&"primary"!==e||!n?.width?i.width:n.width,o=e&&"primary"!==e||!n?.height?i.height:n.height,s=function(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const i=n.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){const{when:n}=e,i=t.width,r=t.height,o=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),s=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>i||"number"==typeof n.maxWidth&&i>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof r||n.minHeight>r)||"number"==typeof n.maxHeight&&("number"!=typeof r||r>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof o||n.minAspectRatio>o)||"number"==typeof n.maxAspectRatio&&("number"!=typeof o||o>n.maxAspectRatio)||n.orientation&&s!==n.orientation)}(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:i.reduce((e,t)=>function(e,t){const n={...e,...t};for(const i of["margin","frameProps","mobileSemantics","style"])ma(e[i])&&ma(t[i])&&(n[i]={...e[i],...t[i]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:i}}({...t,mode:e},{width:t.width??r,height:t.height??o}).props,a=s.mode||e,c=Pa[a||"primary"],l="context"===a||"sparkline"===a,u=a&&"primary"!==a||!n?.width?c.width:n.width;return{width:s.width??u,height:s.height??(a&&"primary"!==a||!n?.height?c.height:n.height),showAxes:s.showAxes??c.showAxes,showGrid:s.showGrid??c.showGrid,enableHover:s.enableHover??(!!s.linkedHover||c.enableHover),showLegend:s.showLegend??c.showLegend,showLabels:s.showLabels??c.showLabels,title:l?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:l?void 0:s.xLabel,yLabel:l?void 0:s.yLabel,categoryLabel:l?void 0:s.categoryLabel,valueLabel:l?void 0:s.valueLabel,marginDefaults:ja(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:ka(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function ja(e,t,n){if(!1!==t)return e;const i={...e};return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}var Ca=c(require("react")),Ia=require("react/jsx-runtime");function Ta({componentName:e,message:t,diagnosticHint:n,width:i,height:r}){return(0,Ia.jsx)("div",{role:"alert",style:{width:i,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:(0,Ia.jsxs)("div",{style:{textAlign:"center",maxWidth:400},children:[(0,Ia.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),(0,Ia.jsx)("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&(0,Ia.jsx)("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:n})]})})}var Ra=require("react/jsx-runtime"),La=class extends Ca.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:(0,Ra.jsx)(Ta,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}},$a=require("react/jsx-runtime");function Ea({componentName:e,width:t,height:n,children:i}){return(0,$a.jsx)(La,{fallback:i=>(0,$a.jsx)(Ta,{componentName:e,message:i.message,width:t,height:n}),children:i})}"undefined"!=typeof process&&process;var Da={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},za={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Ba(e,t,n,i){return!1===i||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,$a.jsx)("div",{style:{...Da,width:t,height:n},children:i||"No data available"}):null}function Fa(e,t,n,i){if(!e)return null;if(!1===i)return null;if(null!=i)return(0,$a.jsx)("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:i});const r=Math.min(5,Math.floor(n/40)),o=Math.max(8,Math.floor(n/(3*r))),s=Math.max(6,Math.floor(n/(2.5*r))),a=Math.floor((n-(r*(o+s)-s))/2);return(0,$a.jsx)("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(e,n)=>(0,$a.jsx)("div",{className:"semiotic-loading-bar",style:{...za,position:"absolute",top:a+n*(o+s),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:o,opacity:.5+n%2*.2}},n))})}var Na=require("react"),Oa=require("react");var Wa=require("react/jsx-runtime");function qa(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();if("string"==typeof e){if(""===e.trim())return NaN;const t=+e;return Number.isFinite(t)?t:NaN}return NaN}function Ya(e,t,n,i){if(!e.length)return[];const r=e.filter(e=>Number.isFinite(t(e))).sort((e,n)=>t(e)-t(n)),o=[];let s=0,a=null,c=null,l=[];const u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${s}-${e}`,h=e=>o.push(e),f=(e,t)=>{h({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;r.length>e;e++){const o=r[e],p=t(o),y=n(o),g=i(o);if(!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(g))continue;const m=u(y,g);if(null!==m)if(null!=a){if(c&&c.w!==m){let e,t;if(l.length>0)e=l[0].x,t=l[0].y;else{const n=y-c.a-(g-c.b);if(0!==n){const i=Math.max(0,Math.min(1,(c.b-c.a)/n));e=c.x+i*(p-c.x),t=c.a+i*(y-c.a)}else e=c.x,t=c.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t}),s++,a=m,h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;l.length>e;e++)f(l[e],a)}else for(const e of l)f(e,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:o}),c={x:p,a:y,b:g,w:m}}else{a=m;for(const e of l)f(e,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:o}),c={x:p,a:y,b:g,w:m}}else l.push({x:p,y:y,datum:o})}for(const e of l)f(e,a??"A");return o}var Ha=(0,te.forwardRef)(function(e,t){const n=(0,te.useRef)(null),i=_a(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:r,margin:o,className:s,xFormat:a,yFormat:c,xAccessor:l="x",seriesAAccessor:u="a",seriesBAccessor:d="b",seriesALabel:h="A",seriesBLabel:f="B",seriesAColor:p="var(--semiotic-danger, #dc2626)",seriesBColor:y="var(--semiotic-info, #2563eb)",showLines:g=!0,lineWidth:m=1.5,showPoints:x=!1,pointRadius:b=3,curve:v="linear",areaOpacity:w=.6,gradientFill:k,tooltip:S,annotations:A,xExtent:M,yExtent:P,frameProps:_={},selection:j,linkedHover:C,onObservation:I,onClick:T,hoverHighlight:L,chartId:$,loading:E,loadingContent:z,emptyContent:F,legendInteraction:N,legendPosition:O,pointIdAccessor:W,windowSize:q}=e,{width:Y,height:H,enableHover:X,showGrid:G,showLegend:U,title:K,description:Z,summary:ne,accessibleTable:ie,xLabel:re,yLabel:oe}=i,se=(0,te.useMemo)(()=>"function"==typeof l?e=>qa(l(e)):e=>qa(e[l]),[l]),ae=(0,te.useMemo)(()=>"function"==typeof u?e=>qa(u(e)):e=>qa(e[u]),[u]),ce=(0,te.useMemo)(()=>"function"==typeof d?e=>qa(d(e)):e=>qa(e[d]),[d]),[le,ue]=(0,te.useState)([]),de=(0,te.useRef)([]),he=null==r,fe=(0,te.useMemo)(()=>B(he?le:r),[he,le,r]),pe=(0,te.useMemo)(()=>Ya(fe,se,ae,ce),[fe,se,ae,ce]),ye=(0,te.useMemo)(()=>g?function(e,t,n,i){if(!e.length)return[];const r=e.filter(e=>Number.isFinite(t(e))).sort((e,n)=>t(e)-t(n)),o=[];for(const e of r){const r=t(e),s=n(e),a=i(e);Number.isFinite(s)&&o.push({__x:r,__y:s,__diffSegment:"line-A"}),Number.isFinite(a)&&o.push({__x:r,__y:a,__diffSegment:"line-B"})}return o}(fe,se,ae,ce):[],[g,fe,se,ae,ce]),ge=(0,te.useMemo)(()=>[...pe,...ye],[pe,ye]),me=(0,te.useMemo)(()=>{const e=new Set;for(const t of pe)e.add(t.__diffSegment);return Array.from(e)},[pe]);(0,te.useImperativeHandle)(t,()=>{const e=e=>{const t=q&&e.length>q?e.slice(e.length-q):e;de.current=t,ue(t)},t=W?"function"==typeof W?W:e=>e[W]:null;return{push:t=>e([...de.current,t]),pushMany:t=>e([...de.current,...t]),remove:n=>{if(!t)return[];const i=Array.isArray(n)?n:[n],r=[],o=[];for(const e of de.current)i.includes(t(e))?r.push(e):o.push(e);return e(o),r},update:(n,i)=>{if(!t)return[];const r=Array.isArray(n)?n:[n],o=[],s=de.current.map(e=>{if(r.includes(t(e))){const t=i(e);return o.push(t),t}return e});return e(s),o},clear:()=>e([]),getData:()=>he?de.current:fe,getScales:()=>n.current?.getScales()??null}},[he,fe,W,q]);const xe=function(e){const{data:t,rawData:n,colorBy:i,colorScheme:r,legendInteraction:o,legendPosition:s,selection:a,linkedHover:c,fallbackFields:l,unwrapData:u=!1,onObservation:d,chartType:h,chartId:f,showLegend:p,userMargin:y,marginDefaults:g,onClick:m,hoverHighlight:x,mobileInteraction:b,mobileSemantics:v,loading:w,loadingContent:k,emptyContent:S,width:A,height:M}=e,P=void 0===n,_=(0,Na.useMemo)(()=>B(t),[t]),[j,C]=(0,Na.useState)([]),I=(0,Na.useCallback)(e=>{C(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),T="string"==typeof e.colorBy?e.colorBy:void 0,L=(0,Na.useMemo)(()=>ka(b,{width:A,mobileSemantics:v}),[b,A,v]),{activeSelectionHook:$,hoverSelectionHook:E,customHoverBehavior:z,customClickBehavior:F,crosshairSourceId:N}=Aa({selection:a,linkedHover:c,fallbackFields:l,unwrapData:u,onObservation:d,chartType:h,chartId:f,onClick:m,hoverHighlight:x,colorByField:T,mobileInteraction:L}),O=function(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===n?.mode)return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}(c,N),W=function(e,t,n){const i=ta(),r=Sa();return(0,Qs.useMemo)(()=>{if(!t)return;const o=i??void 0,s=n??(r&&r.length>0?r:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(o&&va(o)){const e=D(n.map(e=>({_cat:e})),"_cat",s);return t=>o[t]||e(t)}return D(n.map(e=>({_cat:e})),"_cat",s)}if(o&&va(o)){const n=D(e,t,s);return e=>o[e]||n(e)}return D(e,t,s)}if(o&&va(o)){const e=D([{_:"a"}],"_",s);return t=>o[t]||e(t)}},[e,t,n,i,r])}(_,i,r),q=(0,Na.useMemo)(()=>{if(!i)return[];const e=new Set;for(const t of _){const n="function"==typeof i?i(t):t[i];null!=n&&e.add(n+"")}return Array.from(e)},[_,i]),Y=(0,Na.useMemo)(()=>P&&j.length>0?j:q,[P,j,q]),H=function(e,t,n){const[i,r]=(0,Qs.useState)(null),[o,s]=(0,Qs.useState)(new Set),a=(0,Qs.useMemo)(()=>new Set,[]),c=(0,Qs.useCallback)(t=>{"highlight"===e&&r(t?t.label:null)},[e]),l=(0,Qs.useCallback)(t=>{"isolate"===e&&s(e=>{const i=new Set(e);return i.has(t.label)?i.delete(t.label):i.add(t.label),i.size===n.length?new Set:i})},[e,n.length]),u=(0,Qs.useMemo)(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=i?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===i}:"isolate"===e&&o.size>0?{isActive:!0,predicate:e=>{const i=n?e[n]:"function"==typeof t?t(e):null;return o.has(i)}}:null},[e,t,i,o]);return{highlightedCategory:"highlight"===e?i:null,isolatedCategories:"isolate"===e?o:a,onLegendHover:c,onLegendClick:l,legendSelectionHook:u}}(o,i,Y),X=(0,Na.useMemo)(()=>E||(H.legendSelectionHook?H.legendSelectionHook:$),[E,H.legendSelectionHook,$]),G=function(e){const t=Pe(e=>e.theme.colors.selectionOpacity);return(0,Oa.useMemo)(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}(a),V=Sa(),U=ta(),K=(0,Na.useMemo)(()=>{if(W)return W;if(!i||0===Y.length)return;const e=Array.isArray(r)&&r.length>0||"string"==typeof r&&r.length>0?r:V&&V.length>0?V:R,t="__streamCat",n=D(Y.map(e=>({[t]:e})),t,e);return e=>U?.[e]||n(e)||"#999"},[W,i,Y,r,V,U]),{legend:Z,margin:Q,legendPosition:J}=Ma({data:_,colorBy:i,colorScale:K,showLegend:p,legendPosition:s,userMargin:y,defaults:g,categories:Y}),ee=(0,Na.useMemo)(()=>{const e={};return Z&&(e.legend=Z,e.legendPosition=J),o&&"none"!==o&&(e.legendHoverBehavior=H.onLegendHover,e.legendClickBehavior=H.onLegendClick,e.legendHighlightedCategory=H.highlightedCategory,e.legendIsolatedCategories=H.isolatedCategories),P&&i&&(e.legendCategoryAccessor=i,e.onCategoriesChange=I),e},[Z,J,o,H.onLegendHover,H.onLegendClick,H.highlightedCategory,H.isolatedCategories,P,i,I]),te=Array.isArray(n)?B(n):n,ne=Fa(w,A,M,k),ie=ne?null:Ba(te,A,M,S);return{data:_,colorScale:W,allCategories:Y,legendState:H,effectiveSelectionHook:X,activeSelectionHook:$,customHoverBehavior:z,customClickBehavior:F,mobileInteraction:L,legend:Z,margin:Q,legendPosition:J,earlyReturn:ne||ie||null,legendBehaviorProps:ee,crosshairProps:O,resolvedSelection:G}}({data:fe,rawData:r,colorBy:"__diffWinner",colorScheme:[p,y],legendInteraction:N,legendPosition:O,selection:j,linkedHover:C,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:I,onClick:T,hoverHighlight:L,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"DifferenceChart",chartId:$,showLegend:U,userMargin:o,marginDefaults:i.marginDefaults,loading:E,loadingContent:z,emptyContent:F,width:Y,height:H}),be=(0,te.useMemo)(()=>{if(!1!==U)return{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:h,color:p},{label:f,color:y}]}]}},[U,h,f,p,y]),ve=(0,te.useCallback)(e=>{const t=e.__diffSegment;return{fill:"A"==(t?.endsWith("-A")?"A":"B")?p:y,stroke:"none",fillOpacity:w}},[p,y,w]),we=(0,te.useCallback)(e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?p:y,strokeWidth:m,fill:"none"}),[p,y,m]),ke=(0,te.useCallback)(e=>({fill:"A"==("line-A"===e.__diffSegment?"A":"B")?p:y,r:b}),[p,y,b]),Se=(0,te.useCallback)(e=>{const t=e.data,n=e.allSeries,i=e.xValue??t?.__x;let r=t?.__valA,o=t?.__valB;if(n&&n.length>0){const e=n.find(e=>"line-A"===e.group),t=n.find(e=>"line-B"===e.group);null!=e?.value&&Number.isFinite(e.value)&&(r=e.value),null!=t?.value&&Number.isFinite(t.value)&&(o=t.value)}if(null!=i&&(null==r||null==o)){const e=fe.find(e=>se(e)===i);e&&(null==r&&(r=ae(e)),null==o&&(o=ce(e)))}const s=e=>null!=e&&Number.isFinite(e)?""+Math.round(100*e)/100:"—",c=a&&null!=i?a(i):null!=i?i+"":"";return(0,Wa.jsxs)("div",{className:"semiotic-tooltip",style:V,children:[c&&(0,Wa.jsx)("div",{style:{fontWeight:600,marginBottom:4},children:c}),(0,Wa.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,Wa.jsx)("span",{style:{width:10,height:10,background:p,display:"inline-block",borderRadius:2}}),(0,Wa.jsxs)("span",{children:[h,": ",s(r)]})]}),(0,Wa.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,Wa.jsx)("span",{style:{width:10,height:10,background:y,display:"inline-block",borderRadius:2}}),(0,Wa.jsxs)("span",{children:[f,": ",s(o)]})]}),null!=r&&null!=o&&Number.isFinite(r)&&Number.isFinite(o)&&(0,Wa.jsxs)("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",s(r-o)]})]})},[fe,se,ae,ce,a,p,y,h,f]),Ae="multi"===S,Me=(0,te.useMemo)(()=>!1===S?()=>null:Ae?Se:Q(S)||Se,[S,Ae,Se]);if(xe.earlyReturn)return xe.earlyReturn;const _e={chartType:"mixed",data:ge,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:me,curve:v,areaStyle:ve,lineStyle:we,...x&&{pointStyle:ke},size:[Y,H],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:xe.margin,showAxes:i.showAxes,xLabel:re,yLabel:oe,xFormat:a,yFormat:c,enableHover:X,showGrid:G,...k&&{gradientFill:!0===k?{topOpacity:.85,bottomOpacity:.15}:k},...be&&{legend:be,legendPosition:xe.legendPosition},...J({title:K,description:Z,summary:ne,accessibleTable:ie,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),tooltipContent:Me,...Ae&&{tooltipMode:"multi"},...ee({linkedHover:C,selection:j,onObservation:I,onClick:T,hoverHighlight:L,mobileInteraction:xe.mobileInteraction,customHoverBehavior:xe.customHoverBehavior,customClickBehavior:xe.customClickBehavior}),...A&&A.length>0&&{annotations:A},...M&&{xExtent:M},...P&&{yExtent:P},...xe.crosshairProps,..._};return(0,Wa.jsx)(Ea,{componentName:"DifferenceChart",width:Y,height:H,children:(0,Wa.jsx)(Zs,{ref:n,..._e})})});function Xa(e,t,n){return"function"==typeof e?e(n):n[e||t]}function Ga(e){return e instanceof Date?e.getTime():Number(e)}function Va(e,t){return S(1===t?.5:e/(t-1))}"function"==typeof Ha&&(Ha.displayName="DifferenceChart");var Ua={frameType:"xy",buildProps:(e,t,n,i,r)=>{const o=r.xAccessor||"x",s=r.seriesAAccessor||"a",a=r.seriesBAccessor||"b",c=e=>Ga(Xa(o,"x",e)),l=e=>Ga(Xa(s,"a",e)),u=e=>Ga(Xa(a,"b",e)),d=r.seriesAColor||"var(--semiotic-danger, #dc2626)",h=r.seriesBColor||"var(--semiotic-info, #2563eb)",f=r.areaOpacity??.6,p=r.lineWidth??1.5,y=!1!==r.showLines,g=Ya(Array.isArray(e)?e:[],c,l,u),m=[];if(y&&Array.isArray(e)){const t=e.filter(e=>Number.isFinite(c(e))).sort((e,t)=>c(e)-c(t));for(const e of t){const t=c(e),n=l(e),i=u(e);Number.isFinite(n)&&m.push({__x:t,__y:n,__diffSegment:"line-A"}),Number.isFinite(i)&&m.push({__x:t,__y:i,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...g,...m],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(g.map(e=>e.__diffSegment))),areaStyle:e=>{const t=e.__diffSegment;return{fill:"A"==(t?.endsWith("-A")?"A":"B")?d:h,stroke:"none",fillOpacity:f}},lineStyle:e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?d:h,strokeWidth:p,fill:"none"}),curve:r.curve||"linear",...i}}},Ka={frameType:"xy",buildProps:(e,t,n,i,r)=>{const o=t||r.areaBy,s="string"==typeof o&&Array.isArray(e)?D(e,o,n):void 0;return{chartType:"stackedarea",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:o,colorScheme:n,normalize:r.normalize,stackOrder:r.stackOrder,lineStyle:null==r.areaOpacity?void 0:e=>{const t=null==o?void 0:$(e,o,s),n=r.showLine??!0;return{fill:r.color??t,stroke:n?r.stroke??t:"none",...n?{strokeWidth:r.strokeWidth??r.lineWidth??2}:{},fillOpacity:r.areaOpacity,...null==r.opacity?{}:{opacity:r.opacity}}},...i}}},Za={frameType:"xy",buildProps:(e,t,n,i,r)=>{const o=r.xCenter,s=r.yCenter,a=r.quadrants,c=r.centerlineStyle||{},l=!1!==r.showQuadrantLabels,u=r.quadrantLabelSize??12,h=c.stroke||"#999",f=c.strokeWidth??1,p=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,y=d.createElement,g=a?[(e,t,n)=>{if(!t?.x||!t?.y)return null;const i=n.width,r=n.height,c=null!=o?t.x(o):i/2,g=null!=s?t.y(s):r/2;if(null!=o&&!Number.isFinite(c))return null;if(null!=s&&!Number.isFinite(g))return null;const m=Math.max(0,Math.min(i,c)),x=Math.max(0,Math.min(r,g)),b=[{c:a.topLeft,x:0,y:0,w:m,h:x},{c:a.topRight,x:m,y:0,w:i-m,h:x},{c:a.bottomLeft,x:0,y:x,w:m,h:r-x},{c:a.bottomRight,x:m,y:x,w:i-m,h:r-x}],v=l?[y("text",{key:"ltl",x:8,y:8+u,fill:a.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.topLeft.label),y("text",{key:"ltr",x:i-8,y:8+u,fill:a.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.topRight.label),y("text",{key:"lbl",x:8,y:r-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.bottomLeft.label),y("text",{key:"lbr",x:i-8,y:r-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return y(d.Fragment,null,...b.map((e,t)=>e.w>0&&e.h>0?y("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.c.color,opacity:e.c.opacity??.08}):null),y("line",{key:"vc",x1:m,y1:0,x2:m,y2:r,stroke:h,strokeWidth:f,strokeDasharray:p}),y("line",{key:"hc",x1:0,y1:x,x2:i,y2:x,stroke:h,strokeWidth:f,strokeDasharray:p}),...v)}]:void 0;return{chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange,colorScheme:n,pointStyle:r.pointStyle,...i,...g&&{svgPreRenderers:g}}}},Qa={frameType:"xy",buildProps:(e,t,n,i,r)=>{const o=function(e,t){if(!Array.isArray(e))return{data:e,orderMap:new WeakMap};const n=t.xAccessor||"x",i=t.yAccessor||"y",r=t.orderAccessor?[...e].sort((e,n)=>null==e||"object"!=typeof e?1:null==n||"object"!=typeof n?-1:Ga(Xa(t.orderAccessor,"order",e))-Ga(Xa(t.orderAccessor,"order",n))):e,o=new WeakMap;let s=0;for(const e of r){if(null==e||"object"!=typeof e)continue;const t=Ga(Xa(n,"x",e)),r=Ga(Xa(i,"y",e));Number.isFinite(t)&&Number.isFinite(r)&&s++}let a=0;for(const e of r){if(null==e||"object"!=typeof e)continue;const t=Ga(Xa(n,"x",e)),r=Ga(Xa(i,"y",e));Number.isFinite(t)&&Number.isFinite(r)&&o.set(e,{idx:a++,total:s})}return{data:r,orderMap:o}}(e,r),s=r.pointRadius??4;return{chartType:"line",data:o.data,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,colorScheme:n,lineStyle:r.lineStyle||{stroke:r.stroke||"#6366f1",strokeWidth:r.strokeWidth??s,opacity:r.opacity},pointStyle:e=>{const t=o.orderMap.get(e),n=t?.idx??0,i=t?.total??1;return{fill:i>0?Va(n,i):"#6366f1",stroke:"white",strokeWidth:1,r:s,fillOpacity:1}},...i}}};function Ja(e){return Math.max(0,Math.min(1,e))}function ec(e){const t=e.trim();if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e.split("").map(e=>e+e).join("")),6===e.length&&/^[0-9a-f]{6}$/i.test(e))return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(n){const e=[Number(n[1]),Number(n[2]),Number(n[3])];if(e.every(Number.isFinite))return e}return null}function tc(e,t,n){const i=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${i(e)}${i(t)}${i(n)}`}function nc(e,t){const n=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Ja(e.offset),color:e.color})).sort((e,t)=>e.offset-t.offset);if(0===n.length)return"#999999";if(1===n.length)return n[0].color;const i=Ja(t);if(n[0].offset>=i)return n[0].color;if(i>=n[n.length-1].offset)return n[n.length-1].color;for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1];if(t.offset>i||i>r.offset)continue;const o=r.offset-t.offset,s=o>0?(i-t.offset)/o:0,a=ec(t.color),c=ec(r.color);if(!a||!c)return.5>s?t.color:r.color;const[l,u,d]=a,[h,f,p]=c;return tc(l+(h-l)*s,u+(f-u)*s,d+(p-d)*s)}return n[n.length-1].color}function ic(e,t,n){return null==n?`${e}-${t}`:`${e}-${t}-${n}`}var rc={frameType:"ordinal",buildProps:(e,t,n,i,r)=>{const o=r.min??0,s=r.max??100,a=r.sweep??240,c=r.arcWidth??.3,l=180+(360-a)/2,u=r.thresholds||[{value:s,color:r.color||"#4e79a7"}],d=i.gradientFill,h=function(e){const{min:t,max:n,value:i,thresholds:r,fillColor:o,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=e,d=n-t||1,h=(Math.max(t,Math.min(n,i))-t)/d;let f=r&&r.length>0?[...r].sort((e,t)=>e.value-t.value):[{value:n,color:o||"#007bff"}];f=f.map(e=>({...e,value:Math.max(t,Math.min(n,e.value))})),n>f[f.length-1].value&&f.push({value:n,color:f[f.length-1].color});const p=!!l&&l.colorStops.length>=2,y=[],g=new Map,m=[];if(p){const e=a?h:1,t=ic("bg",0);if(y.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),g.set(t,{fill:s,opacity:.4}),e>0){const t=Math.max(1,Math.floor(u)),n=Math.max(1,Math.min(t,Math.round(e*t))),i=[];for(let t=0;n>t;t++)i.push(nc(l.colorStops,e*(t+.5)/n));const r=ic("fill",0);y.push({category:r,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:i}}),g.set(r,{fill:i[0]||s})}}else{let e=t;for(let n=0;f.length>n;n++){const i=f[n],r=(i.value-e)/d,o=(e-t)/d,c=(i.value-t)/d,l=Math.max(0,(a?Math.min(h,c):c)-o),u=a?Math.max(0,r-l):0;if(l>0){const e=ic("fill",n);y.push({category:e,value:l,_zone:i.label||"Zone "+(n+1),_isFill:!0}),g.set(e,{fill:i.color})}if(u>0){const e=ic("bg",n);y.push({category:e,value:u,_zone:i.label||"Zone "+(n+1),_isFill:!1}),g.set(e,{fill:s,opacity:.4})}e=i.value}}if(c&&r&&r.length>0)for(const e of r)e.value>t&&n>e.value&&m.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:y,pieceStyle:(e,t)=>g.get(t||e.category)||{fill:s},gaugeAnnotations:m}}({min:o,max:s,value:r.value,thresholds:u,fillColor:r.color,backgroundColor:r.backgroundColor||"#e0e0e0",fillZones:!1!==r.fillZones,showScaleLabels:!1!==r.showScaleLabels,gradientFill:d&&"object"==typeof d&&"colorStops"in d?d:void 0}),f=i.margin||{top:20,right:20,bottom:30,left:40},[p,y]=i.size||[300,300];return{chartType:"donut",data:h.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(p-(f.left||0)-(f.right||0),y-(f.top||0)-(f.bottom||0))/2*(1-c)),sweepAngle:a,startAngle:l,oSort:!1,pieceStyle:h.pieceStyle,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...i,showAxes:!1,annotations:[...Array.isArray(i.annotations)?i.annotations:[],...h.gaugeAnnotations],__gauge:{gMin:o,gMax:s,sweep:a,arcWidth:c,value:r.value,startAngleDeg:l,thresholds:u}}}},oc=require("d3-scale");function sc(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function ac(e,t,n){const i=t.incoming[e.id],r=t.outgoing[e.id],o=[];for(const e of i)o.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of r)o.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{o.sort((e,t)=>e.time-t.time||(s[e.kind]??99)-(s[t.kind]??99))},c=o.length?function(e,t=1/0){let n=t;for(const t of e)n>t&&(n=t);return n}(o.map(e=>e.time)):null,l=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,u=null!=l?l-1:null!=c&&Number.isFinite(c)?c-1:null,d=[...new Set(o.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;d.length>e;e++)h.set(d[e],d[e-1]);const f=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=u?u:e};a();const p=[];let y=0,g=0;for(const e of o)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:g);if(n>0){const t="top"===e.side?"bot":"top",i=Math.min(n,"top"===t?y:g);if(i>0){const r=f(e.time);p.push({time:r,delta:-i,kind:"transfer-out",side:t}),p.push({time:r,delta:+i,kind:"transfer-in",side:e.side}),"top"===t?y-=i:g-=i,"top"===e.side?y+=i:g+=i,n-=i}n>0&&null!==u&&(p.push({time:u,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:g+=n)}"top"===e.side?y-=t:g-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:g+=t}o.push(...p),a();let m=0,x=0,b=0,v=0,w=0;const k=[],S=new Map;for(const e of o){if(k.push({t:e.time,topMass:m,botMass:x}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:x;S.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?m+=e.delta:x+=e.delta,m+x>b&&(b=m+x),m>v&&(v=m),x>w&&(w=x),k.push({t:e.time,topMass:m,botMass:x})}const A=[];let M=0;for(;k.length>M;){let e=M;for(;k.length>e+1&&k[e+1].t===k[M].t;)e++;A.push(k[M]);for(let t=M+1;e>=t;t++){const e=A[A.length-1];k[t].topMass===e.topMass&&k[t].botMass===e.botMass||A.push(k[t])}M=e+1}const P=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let _=null;for(const e of r)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===_||_>e.systemInTime)&&(_=e.systemInTime);let j=null;for(const e of i)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===j||e.systemOutTime>j)&&(j=e.systemOutTime);if(A.length>0){const e=A[A.length-1],t=Math.max(null!=P?P:-1/0,null!=j?j:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&A.push({t:t,topMass:e.topMass,botMass:e.botMass});const n=A[0],i=Math.min(null!=l?l:1/0,null!=_?_:1/0);Number.isFinite(i)&&n.t>i&&n.topMass+n.botMass>0&&A.unshift({t:i,topMass:n.topMass,botMass:n.botMass})}return{samples:A,peak:b,topPeak:v,botPeak:w,localAttachments:S}}function cc(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function lc(e,t){return e.map(e=>({t:cc(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function uc(e,t,n){const i=e.value*n;if("out"===e.kind){const r=e.sideMassBefore*n;if("top"===e.side){const e=t-r;return[e,e+i]}const o=t+r;return[o-i,o]}const r=e.sideMassAfter*n;if("top"===e.side){const e=t-r;return[e,e+i]}const o=t+r;return[o-i,o]}function dc(e,t){let n=0;for(let i=0;t.length>i;i++)for(let r=i+1;t.length>r;r++){const o=t[i],s=t[r];o.source!==s.source&&o.target!==s.target&&o.source!==s.target&&o.target!==s.source&&(Math.min(o.endTime,s.endTime)>Math.max(o.startTime,s.startTime)&&e[s.source]>e[o.source]!=e[s.target]>e[o.target]&&n++)}return n}function hc(e,t){let n=0;for(const i of t)n+=Math.abs(e[i.source]-e[i.target])*(i.value||1);return n}function fc(e,t){return 1e3*dc(e,t)+hc(e,t)}function pc(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function yc(e,t,n){e.length>8||n.length>40?(function(e,t,n,i=6){const r=e.length;if(1>=r)return;let o=pc(e,t),s=fc(t,n);for(let a=0;i>a;a++){const i=Array(r).fill(0),a=Array(r).fill(0);for(const e of n){const n=t[e.source],r=t[e.target];i[n]+=r*(e.value||1),a[n]+=e.value||1,i[r]+=n*(e.value||1),a[r]+=e.value||1}const c=Array.from({length:r},(e,t)=>t).sort((e,t)=>(a[e]>0?i[e]/a[e]:e)-(a[t]>0?i[t]/a[t]:t)),l=c.map(t=>e[t]),u=new Map;c.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of l)e.push(t);const d=fc(t,n);if(s>d)s=d,o=pc(e,t);else if(d===s)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,o)}(e,t,n,6),function(e,t,n,i=6){const r=e.length;if(1>=r)return;let o=fc(t,n);for(let s=0;i>s;s++){let i=!1;for(let s=0;r-1>s;s++){const r=e[s];e[s]=e[s+1],e[s+1]=r;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s);const a=fc(t,n);if(o>a)o=a,i=!0;else{const n=e[s];e[s]=e[s+1],e[s+1]=n;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s)}}if(!i)break}}(e,t,n,6)):function(e,t,n){const i=e.length;if(1>=i)return;const r={...t},o=Object.keys(r),s=Array.from({length:i},(e,t)=>t),a=s.slice(),c={...r};let l=s.slice(),u=1/0;const d=()=>{for(const e of o)c[e]=a[r[e]];const e=fc(c,n);u>e&&(u=e,l=s.slice())},h=(e,t)=>{const n=s[e],i=s[t];s[e]=i,s[t]=n,a[n]=t,a[i]=e};d();const f=Array(i).fill(0);let p=0;for(;i>p;)p>f[p]?(h(p%2==0?0:f[p],p),d(),f[p]++,p=0):(f[p]=0,p++);const y=l.map(t=>e[t]),g=new Map;l.forEach((e,t)=>g.set(e,t));for(const e of Object.keys(t))t[e]=g.get(t[e]);e.length=0;for(const t of y)e.push(t)}(e,t,n)}function gc(e,t,n,i,r){const{plotH:o,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="full"}=r,d={},h={};for(const t of e)d[t.id]=n[t.id].topPeak||0,h[t.id]=n[t.id].botPeak||0;const f="half"===u,p={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let r=null!=e&&Number.isFinite(e)?e:1/0,o=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of i.outgoing[t.id]){r>e.startTime&&(r=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&r>e.systemInTime&&(r=e.systemInTime);const t=f?(e.startTime+e.endTime)/2:e.endTime;t>o&&(o=t)}for(const e of i.incoming[t.id]){const t=f?(e.startTime+e.endTime)/2:e.startTime;r>t&&(r=t),e.endTime>o&&(o=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>o&&(o=e.systemOutTime)}p[t.id]={start:Number.isFinite(r)?r:null,end:Number.isFinite(o)?o:null}}const y={},g=[];if("reuse"===c){const n=new Map;for(const t of e)n.set(t.id,0);const r=new Map;for(const t of e)r.set(t.id,0);for(const e of t)r.set(e.target,(r.get(e.target)??0)+1);const o=[];for(const t of e)0===(r.get(t.id)??0)&&o.push(t.id);for(;o.length;){const e=o.shift();for(const t of i.outgoing[e]??[]){const i=(n.get(e)??0)+1;i>(n.get(t.target)??0)&&n.set(t.target,i),r.set(t.target,r.get(t.target)-1),0===r.get(t.target)&&o.push(t.target)}}const s=[...e].filter(e=>null!==p[e.id].start).sort((e,t)=>{const i=n.get(e.id)??0,r=n.get(t.id)??0;return i!==r?i-r:p[e.id].start-p[t.id].start}),a=e.filter(e=>null===p[e.id].start);for(const e of[...s,...a]){const t=p[e.id];let n=-1;for(let e=0;g.length>e;e++){const i=g[e].occupants[g[e].occupants.length-1];if(null===t.start||void 0===i||t.start>=i.end){n=e;break}}-1===n&&(g.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=g.length-1),g[n].occupants.push({id:e.id,end:t?.end??-1/0}),g[n].peak.topPeak=Math.max(g[n].peak.topPeak,d[e.id]),g[n].peak.botPeak=Math.max(g[n].peak.botPeak,h[e.id]),y[e.id]=n}}else e.forEach((e,t)=>{g.push({occupants:[{id:e.id,end:p[e.id]?.end??-1/0}],peak:{topPeak:d[e.id],botPeak:h[e.id]}}),y[e.id]=t});let m=null,x=null,b=null,v=null;const w=()=>{m=dc(y,t),b=hc(y,t)},k=()=>{x=dc(y,t),v=hc(y,t)};"crossing-min"===l?(w(),yc(g,y,t),k()):"inside-out"===l?(w(),function(e,t){const n=e.length;if(1>=n)return;const i=e=>e.peak.topPeak+e.peak.botPeak,r=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>i(t.slot)-i(e.slot)),o=Array(n),s=Math.floor((n-1)/2);o[s]=r[0].idx;let a=s-1,c=s+1;for(let e=1;r.length>e;e++)e%2==1&&n>c||0>a?o[c++]=r[e].idx:o[a--]=r[e].idx;const l=o.map(t=>e[t]),u=new Map;o.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of l)e.push(t)}(g,y),k()):"crossing-min+inside-out"===l&&(w(),yc(g,y,t),function(e,t,n){const i=e.length;if(1>=i)return;const r=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),o=Math.floor((i-1)/2);let s=fc(t,n);for(const{slot:a}of r){const r=e.indexOf(a);if(0>r)continue;const c=o;if(r===c)continue;const l=e[r];e.splice(r,1),e.splice(c,0,l);const u=new Map;for(let e=0;i>e;e++)u.set(e,e);if(c>r){for(let e=r+1;c>=e;e++)u.set(e,e-1);u.set(r,c)}else{for(let e=c;r>e;e++)u.set(e,e+1);u.set(r,c)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const d=fc(t,n);if(d>s){const n=e[c];e.splice(c,1),e.splice(r,0,n);const o=new Map;for(let e=0;i>e;e++)o.set(e,e);if(r>c){for(let e=c+1;r>=e;e++)o.set(e,e-1);o.set(c,r)}else{for(let e=r;c>e;e++)o.set(e,e+1);o.set(c,r)}for(const e of Object.keys(t))t[e]=o.get(t[e])}else s=d}}(g,y,t),k());const S=g.map(e=>{const t=new Map;for(const i of e.occupants){const e=n[i.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),A=(e,t)=>{let n={top:0,bot:0};for(const[i,r]of e){if(i>t)break;n=r}return n},M=[];for(let e=0;g.length-1>e;e++){const t=S[e],n=S[e+1],i=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let r=0;for(const e of i){const i=A(t,e),o=A(n,e);i.bot+o.top>r&&(r=i.bot+o.top)}M.push(r)}const P=[];let _=s+(g[0]?.peak.topPeak??0)*a;g.length>0&&P.push(_);for(let e=1;g.length>e;e++)_+=M[e-1]*a+s,P.push(_);if(g.length>0&&(_+=g[g.length-1].peak.botPeak*a+s),_>o){const e=o/_;for(let t=0;P.length>t;t++)P[t]*=e}const j=0===g.length?0:g[0].peak.topPeak+M.reduce((e,t)=>e+t,0)+g[g.length-1].peak.botPeak,C={};for(const t of e)C[t.id]=P[y[t.id]];return{effectiveSlotsHeight:j,centerlines:C,laneLifetime:p,slots:g,slotByNode:y,slotCenter:P,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:v}}function mc(e){const{sx:t,sTop:n,sBot:i,tx:r,tTop:o,tBot:s,cp1X:a,cp2X:c}=e,l=(n+i)/2,u=(o+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${c},${o} ${r},${o}`,`L${r},${s}`,`C${c},${s} ${a},${i} ${t},${i}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:a,y:l},{x:c,y:u},{x:r,y:u}],halfWidth:(i-n)/2}}}function xc(e){const{nodes:t,edges:n,domain:i,plotW:r,plotH:o,ribbonLane:s,edgeOpacity:a,colorOf:c,layoutOpts:l}=e,u=function(e,t,n){const i=[],r=new Set(e.map(e=>e.id)),o=Array.isArray(n)&&2===n.length,s=o&&Number.isFinite(n[0])&&Number.isFinite(n[1]);o&&s&&s&&n[1]>=n[0]||i.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||i.push({kind:"invalid-node-time",id:t.id}));for(const e of t)r.has(e.source)||i.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),r.has(e.target)||i.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||i.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||i.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):i.push({kind:"invalid-edge-time",id:e.id});return i}(t,n,i),d=(0,oc.scaleTime)().domain(i).range([0,r]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:d};const h=function(e,t,n){const{plotH:i,pairing:r="temporal",packing:o="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=n,c=function(e,t){const n={},i={};for(const t of e)n[t.id]=[],i[t.id]=[];for(const e of t)i[e.source]&&i[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:i}}(e,t),l=function(e,t,n,i="value"){const r="temporal"===i?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,o="temporal"===i?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,s=new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const n=new Map;for(const i of e){const e=i[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const r=n.get(e);r.edges.push(i),r.total+=i.value,r.earliestStart=Math.min(r.earliestStart,i.startTime),r.latestEnd=Math.max(r.latestEnd,i.endTime)}const s=[...n.values()];s.sort("temporal"===i?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.latestEnd:(e,t)=>t.total-e.total);for(const e of s)e.edges.sort("target"===t?o:r);return s};for(const t of e){const e=n.outgoing[t.id],i=n.incoming[t.id];if(0===i.length)a(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=n});else if(0===e.length)a(i,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=n});else{const t=a(i,"source"),n=a(e,"target"),r=Math.max(t.length,n.length);for(let e=0;r>e;e++){const i=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)s.get(n.id).targetSide=i;if(n[e])for(const t of n[e].edges)s.get(t.id).sourceSide=i}}}return s}(e,t,c,r);let u={};for(const t of e)u[t.id]=ac(t,c,l);const d=gc(e,t,u,c,{plotH:i,padding:12,valueScale:1,packing:o,laneOrder:s,lifetimeMode:a}),h=new Set;for(const e of t){const t=d.slotByNode[e.source],n=d.slotByNode[e.target];if(void 0===t||void 0===n)continue;const i=l.get(e.id);t!==n?t>n?(i.sourceSide="top",i.targetSide="bot"):(i.sourceSide="bot",i.targetSide="top"):(h.add(e.id),i.sourceSide="bot",i.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],n=c.incoming[t.id],i=new Set(e.map(e=>l.get(e.id).sourceSide)),r=new Set(n.map(e=>l.get(e.id).targetSide));if(1===i.size&&n.length>0){const e=[...i][0];for(const t of n)d.slotByNode[t.source]===d.slotByNode[t.target]&&(l.get(t.id).targetSide=e)}if(1===r.size&&e.length>0){const t=[...r][0];for(const n of e)d.slotByNode[n.source]===d.slotByNode[n.target]&&(l.get(n.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],n=c.outgoing[t.id];if(0===e.length||0===n.length)continue;const i=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===l.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===l.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},r=(e,t)=>{const r=i(),o="top"===e?r.outTop-r.inTop:r.outBot-r.inBot,s="top"===t?r.inTop-r.outTop:r.inBot-r.outBot;if(0>=o||0>=s)return!1;const a=Math.min(o,s),c=n.filter(t=>!h.has(t.id)&&l.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==c.length&&(l.get(c[0].id).sourceSide=t,!0)};let o=n.length+1;for(;o-- >0&&(r("top","bot")||r("bot","top")););}u={};for(const t of e)u[t.id]=ac(t,c,l);const f=gc(e,t,u,c,{plotH:i,padding:12,valueScale:1,packing:o,laneOrder:s,lifetimeMode:a}),p=f.effectiveSlotsHeight??f.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),y=Math.min(12,.35*i/Math.max(f.slots.length+1,1)),g=p>0?Math.max(0,(i-y*(f.slots.length+1))/p):1,m=gc(e,t,u,c,{plotH:i,padding:y,valueScale:g,packing:o,laneOrder:s,lifetimeMode:a});return{nodeData:u,sides:l,valueScale:g,padding:y,compressedPadding:12>y,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(t,n,{plotH:o,...l}),{centerlines:f,nodeData:p,valueScale:y}=h,g=[],m=[];t.forEach((e,t)=>{const r=p[e.id];if(!r||0===r.samples.length)return;const o=function(e,t,n,i,r){if(0===e.length)return null;const o=lc(e,r),s=e=>t-o[e].topMass*n,a=e=>t+o[e].botMass*n;let c=`M${i(o[0].t)},${s(0)}`;for(let e=1;o.length>e;e++)c+=` L${i(o[e].t)},${s(e)}`;c+=` L${i(o[o.length-1].t)},${a(o.length-1)}`;for(let e=o.length-2;e>=0;e--)c+=` L${i(o[e].t)},${a(e)}`;return c+" Z"}(r.samples,f[e.id],y,d,i);if(!o)return;const s=lc(r.samples,i),a=s.find(e=>e.topMass+e.botMass>0)||s[0],l=f[e.id]+(a.botMass-a.topMass)*y/2,u=c(e.id,t),m=function(e,t,n,i,r){const o=n.nodeData[e];if(!o||0===o.samples.length)return[];const s=n.valueScale,a=n.centerlines[e],c=lc(o.samples,r),l=c.find(e=>e.topMass+e.botMass>0)||c[0],u=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],d=i(l.t),h=i(u.t),f=e=>i(cc(e,r)),p=[],y=(e,t,n,i)=>`M${e},${t} L${n},${t} L${n},${i} L${e},${i} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=o.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=f(n.systemInTime),i=f(n.startTime),r=t-20,o=Math.max(d,r);if(i>o){const[n,c]=uc(e,a,s);p.push({pathD:y(o,n,i,c),x0:r,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=o.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=f(n.systemOutTime),i=f(n.endTime),r=t+20,o=Math.min(h,r);if(o>i){const[n,c]=uc(e,a,s);p.push({pathD:y(i,n,o,c),x0:t,x1:r,from:1,to:0})}}}}return p}(e.id,n,h,d,i);g.push({id:e.id,pathD:o,fill:u,stroke:u,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:e.__raw??e,labelX:d(a.t)-4,labelY:l,labelText:e.id})});const x=new Map;return t.forEach((e,t)=>x.set(e.id,t)),n.forEach(e=>{const t=p[e.source]?.localAttachments.get(e.id),n=p[e.target]?.localAttachments.get(e.id);if(!t||!n)return;const r=x.get(e.source)??0,o=c(e.source,r),l=function(e,t,n,i,r,o,s,a){const c=r,l=e=>a?Math.max(a[0],Math.min(a[1],e)):e,u=o(l(e.time)),d=o(l(n.time)),h=e.value*c,f=n.value*c,p=e.sideMassBefore*c,y=n.sideMassAfter*c;let g,m,x,b;"top"===e.side?(g=t-p,m=g+h):(m=t+p,g=m-h),"top"===n.side?(x=i-y,b=x+f):(b=i+y,x=b-f);const v="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:g,sBot:m,tx:d,tTop:x,tBot:b,cp1X:v,cp2X:v}}(t,f[e.source],n,f[e.target],y,d,s,i),{pathD:u,bezier:h}=mc(l);m.push({id:e.id,pathD:u,fill:o,opacity:a,rawDatum:e.__raw??e,bezier:h})}),{layout:h,layoutConfig:{bands:g,ribbons:m,showLabels:!0},issues:[],xScale:d}}var bc=e=>{const{bands:t=[],ribbons:n=[],showLabels:i=!0}=e.config,r=[];for(const e of n)r.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const n=e.gradientStubs[t];r.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)r.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const o=i?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:r,labels:o}},vc={frameType:"network",buildProps:(e,t,n,i,r)=>{const{edgeWidth:o,edgeColor:s,edgeOpacity:a}=r;return{chartType:"force",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,colorBy:t,colorScheme:n,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize,nodeSizeRange:r.nodeSizeRange,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle??(void 0!==o||void 0!==s||void 0!==a?e=>{const t=e?.data||e;let n=1;if("number"==typeof o)n=o;else if("function"==typeof o)n=o(t);else if("string"==typeof o){const e=t?.[o],i="number"==typeof e?e:Number(e);n=Number.isFinite(i)&&i>0?i:1}return{stroke:s??"#999",strokeWidth:n,opacity:a??.6}}:void 0),...i}}},wc={frameType:"network",buildProps:(e,t,n,i,r)=>{const o=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),s=r.sourceAccessor||"source",a=r.targetAccessor||"target",c=r.valueAccessor||"value",l=r.nodeIdAccessor||"id",u=r.startTimeAccessor||"startTime",d=r.endTimeAccessor||"endTime",h=r.systemInTimeAccessor,f=r.systemOutTimeAccessor,p=r.xExtentAccessor||"xExtent",y=r.edgeIdAccessor||"id",g=(e,t)=>"function"==typeof e?e(t):t[e],m=Array.isArray(r.edges)?r.edges:[],x=Array.isArray(r.nodes)?r.nodes:[],b=x.length>0?x:function(e,t,n,i){const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],o="function"==typeof i?i(e):e[i];r.add(t),r.add(o)}),Array.from(r).map(e=>({id:e}))}(0,m,s,a),v=[o(r.domain?.[0]),o(r.domain?.[1])],w=b.map(e=>{const t=g(l,e)+"",n=g(p,e),i={id:t,__raw:e};if(Array.isArray(n)&&2===n.length){const e=o(n[0]),t=o(n[1]);Number.isFinite(e)&&Number.isFinite(t)&&(i.xExtent=[e,t])}return i}),k=m.map((e,t)=>{const n=g(y,e),i={id:null!=n?n+"":`${g(s,e)}-${g(a,e)}-${t}`,source:g(s,e)+"",target:g(a,e)+"",value:Number(g(c,e)),startTime:o(g(u,e)),endTime:o(g(d,e)),__raw:e};if(h){const t=o(g(h,e));Number.isFinite(t)&&(i.systemInTime=t)}if(f){const t=o(g(f,e));Number.isFinite(t)&&(i.systemOutTime=t)}return i}),[S,A]=i.size??[600,400],M={top:20,right:20,bottom:20,left:20,...i.margin},P=i.legendPosition??"right";i.showLegend&&("right"===P?M.right=Math.max(M.right,100):"left"===P?M.left=Math.max(M.left,100):"bottom"===P?M.bottom=Math.max(M.bottom,70):"top"===P&&(M.top=Math.max(M.top,40)));const _=M,j=S-_.left-_.right,C=A-_.top-_.bottom,I=Array.isArray(n)?n:null,T=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],R="function"==typeof t?t:null,L=R?b.map(e=>({_cat:R(e)})):b,E=R?"_cat":"string"==typeof t?t:void 0,z=E?D(L,E,n):null,B=new Map;for(const e of w)B.set(e.id,e.__raw);const{layoutConfig:F,issues:N}=xc({nodes:w,edges:k,domain:v,plotW:j,plotH:C,ribbonLane:r.ribbonLane||"both",edgeOpacity:"number"==typeof r.edgeOpacity?r.edgeOpacity:.35,colorOf:(e,n)=>{if(t&&B.has(e)){const n=B.get(e);return R?$({_cat:R(n)},"_cat",z??void 0):$(n,t,z??void 0)}const i=I||T;return i[n%i.length]},layoutOpts:{pairing:r.pairing||"temporal",packing:r.packing||"reuse",laneOrder:r.laneOrder||"crossing-min",lifetimeMode:r.lifetimeMode||"half"}});if(N.length>0){const e=N.map(sc).join("; ");throw Error("ProcessSankey: data invalid — "+e)}return{chartType:"force",nodes:b,edges:m,customNetworkLayout:bc,layoutConfig:F,sourceAccessor:s,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:t,colorScheme:n,...i,margin:_}}},kc={frameType:"geo",buildProps:(e,t,n,i,r)=>{const o=(Array.isArray(e)?e:null)||r.flows||[],s=r.nodeIdAccessor||"id",a=r.valueAccessor||"value",c=r.xAccessor||"lon",l=r.yAccessor||"lat",u="function"==typeof c?c:e=>e[c],d="function"==typeof l?l:e=>e[l],h=(r.nodes||[]).map(e=>({...e,x:u(e),y:d(e)})),f=new Map;for(const e of h)f.set(e[s]+"",e);const p=r.edgeColorBy??t,y="function"==typeof p,g=o.map(e=>{if(!e||null==e.source||null==e.target)return null;const t=f.get(e.source+""),n=f.get(e.target+"");return t&&n?{...e,coordinates:[{x:t.x,y:t.y},{x:n.x,y:n.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?D(g.map(e=>({[m]:p(e)})),m,n||"category10"):D(g,p,n||"category10"):null,b=e=>p&&x?$(e,p,x):"#007bff";let v=1/0,w=-1/0;for(const e of g){const t=Number(e[a]??0);isFinite(t)&&(v>t&&(v=t),t>w&&(w=t))}const k=w>v?w-v:0,[S,A]=r.edgeWidthRange??[1,8],M=A-S,P=r.edgeOpacity??.6,_=r.edgeLinecap??"round";return{lines:g,points:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:n,lineStyle:e=>{const t=Number(e?.[a]),n=Number.isFinite(t)?t:v,i=S+Math.max(0,Math.min(1,k>0?(n-v)/k:0))*M;return{stroke:b(e),strokeWidth:i,strokeLinecap:_,opacity:P,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...i}}};function Sc(e){const[t,n]=e;return{width:t,height:n,plot:{x:32,y:24,width:Math.max(80,t-64),height:Math.max(80,n-58)}}}function Ac(e){const t=(e??"")+"";if(!t)return"#4e79a7";const n=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let i=0;for(let e=0;t.length>e;e+=1)i=31*i+t.charCodeAt(e)>>>0;return n[i%n.length]}function Mc(e,t="#4e79a7"){return n=>{const i=n.datum,r=i&&e?"function"==typeof e?e(i,0):i[e]:void 0;return{fill:null==r?t:Ac(r),stroke:"#111827",strokeWidth:1,opacity:.9}}}function Pc(e,t,n,i){return{fixedDt:1/120,maxSubsteps:8,colliders:t,observation:{chartType:n},kernel:{seed:e,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...i}}}function _c(e,t,n){return"function"==typeof n?n(e,t):e[n]}function jc(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:null}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Cc(e,t,n){return Math.max(t,Math.min(n,e))}function Ic(e,t){const n=jc(e);return null!=n&&n>0?n:t}function Tc(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function Rc(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}var Lc=require("d3-scale");function $c(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}var Ec={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},Dc=1e-9,zc=.005;function Bc(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function Fc(e){return"aabb"===e.type?{type:"aabb",x:e.x,y:e.y,width:e.width,height:e.height}:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:e.thickness}}function Nc(e,t,n){return Math.max(t,Math.min(n,e))}function Oc(e){return 0>e?-1:1}function Wc(e){if("circle"===e.shape.type){const t=e.shape.radius;return{minX:e.x-t,minY:e.y-t,maxX:e.x+t,maxY:e.y+t}}const t=e.shape.width/2,n=e.shape.height/2;return{minX:e.x-t,minY:e.y-n,maxX:e.x+t,maxY:e.y+n}}function qc(e){const t=e.shape;if("aabb"===t.type){const e=t.width/2,n=t.height/2;return{minX:t.x-e,minY:t.y-n,maxX:t.x+e,maxY:t.y+n}}const n=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-n,minY:Math.min(t.y1,t.y2)-n,maxX:Math.max(t.x1,t.x2)+n,maxY:Math.max(t.y1,t.y2)+n}}function Yc(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function Hc(e,t,n,i,r,o,s,a){const c=r-e,l=(n+s)/2-Math.abs(c);if(0>=l)return null;const u=o-t,d=(i+a)/2-Math.abs(u);return d>0?d>l?{nx:Oc(c),ny:0,penetration:l}:{nx:0,ny:Oc(u),penetration:d}:null}function Xc(e,t,n,i,r,o,s){const a=o/2,c=s/2;let l=e-Nc(e,i-a,i+a),u=t-Nc(t,r-c,r+c);const d=l*l+u*u;if(d>n*n)return null;if(Dc>=d){const o=Math.abs(e-(i-a)),s=Math.abs(e-(i+a)),d=Math.abs(t-(r-c)),h=Math.abs(t-(r+c)),f=Math.min(o,s,d,h);return f===o?(l=-1,u=0,{nx:l,ny:u,penetration:n+o}):f===s?(l=1,u=0,{nx:l,ny:u,penetration:n+s}):f===d?(l=0,u=-1,{nx:l,ny:u,penetration:n+d}):(l=0,u=1,{nx:l,ny:u,penetration:n+h})}const h=Math.sqrt(d);return{nx:l/h,ny:u/h,penetration:n-h}}function Gc(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return function(e,t,n,i,r,o){const s=i-e,a=r-t,c=n+o,l=s*s+a*a;if(l>=c*c)return null;if(Dc>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/u,penetration:c-u}}(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.radius);if("aabb"===e.shape.type&&"aabb"===t.shape.type)return Hc(e.x,e.y,e.shape.width,e.shape.height,t.x,t.y,t.shape.width,t.shape.height);if("circle"===e.shape.type&&"aabb"===t.shape.type){const n=Xc(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height);return n?{nx:-n.nx,ny:-n.ny,penetration:n.penetration}:null}return"aabb"===e.shape.type&&"circle"===t.shape.type?Xc(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function Vc(e,t){const n=t.shape;return"aabb"===n.type?"circle"===e.shape.type?Xc(e.x,e.y,e.shape.radius,n.x,n.y,n.width,n.height):Hc(n.x,n.y,n.width,n.height,e.x,e.y,e.shape.width,e.shape.height):function(e,t,n,i,r,o,s,a=0){const c=o-i,l=s-r,u=c*c+l*l,d=u>Dc?Nc(((e-i)*c+(t-r)*l)/u,0,1):0,h=n+a/2,f=e-(i+c*d),p=t-(r+l*d),y=f*f+p*p;if(y>=h*h)return null;if(Dc>=y){const e=Math.sqrt(u);return e>Dc?{nx:-l/e,ny:c/e,penetration:h}:{nx:1,ny:0,penetration:h}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:h-g}}(e.x,e.y,"circle"===e.shape.type?e.shape.radius:Math.sqrt(e.shape.width*e.shape.width+e.shape.height*e.shape.height)/2,n.x1,n.y1,n.x2,n.y2,n.thickness??0)}function Uc(e,t){return`${e}\0${t}`}function Kc(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function Zc(e){return{id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,bodyCollisions:e.bodyCollisions,shape:Bc(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function Qc(e){return e&&"function"!=typeof e?{property:e.property,equals:e.equals,notEquals:e.notEquals,oneOf:e.oneOf?.slice(),notOneOf:e.notOneOf?.slice()}:e}function Jc(e){return{id:e.id,shape:Fc(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:Qc(e.bodyFilter),index:e.index}}function el(e,t){return!!t?.some(t=>Object.is(e,t))}function tl(e,t){const n=e.bodyFilter;if(!n)return!0;if("function"==typeof n)return n(t);const i=function(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}(t,n.property);return!("equals"in n&&!Object.is(i,n.equals)||"notEquals"in n&&Object.is(i,n.notEquals)||n.oneOf&&!el(i,n.oneOf)||n.notOneOf&&el(i,n.notOneOf))}var nl=class{constructor(e={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...Ec,...e},this.random=$c(this.options.seed)}init(e={}){this.options={...Ec,...e},this.random=$c(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(e){const t={id:e.id,x:e.x,y:e.y,prevX:e.x,prevY:e.y,vx:e.vx??0,vy:e.vy??0,angle:e.angle??0,mass:Math.max(Dc,e.mass??1),bodyCollisions:e.bodyCollisions??!0,shape:Bc(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(e.id,t)}remove(e){for(const t of e){this.bodies.delete(t);for(const e of Array.from(this.activeSensors))Kc(e).bodyId===t&&this.activeSensors.delete(e)}}setColliders(e){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const t of e)this.colliders.set(t.id,{...t,shape:Fc(t.shape),bodyFilter:Qc(t.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(e){const t=e.id??"spring-"+this.nextSpringIndex;return this.springs.set(t,{id:t,bodyId:e.bodyId,target:e.target,restLength:e.restLength??0,stiffness:e.stiffness??40,damping:e.damping??3}),this.nextSpringIndex+=1,t}removeConstraint(e){this.springs.delete(e)}applyImpulse(e,t,n){const i=this.bodies.get(e);i&&(i.vx+=t/i.mass,i.vy+=n/i.mass,this.wake(i))}step(e=this.options.fixedDt){const t=Math.max(0,e);if(this.lastEvents=[],0===t)return;const n=this.sortedBodies();for(const e of n)e.prevX=e.x,e.prevY=e.y;this.applySprings(t);const i=this.options.maxVelocity;for(const e of n)if(!e.sleeping){if(e.vx+=this.options.gravity.x*t,e.vy+=this.options.gravity.y*t,e.vx*=this.options.velocityDamping,e.vy*=this.options.velocityDamping,i>0){const t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>i){const n=i/t;e.vx*=n,e.vy*=n}}e.x+=e.vx*t,e.y+=e.vy*t}this.supportedThisStep.clear();const r=this.bodyPairKeys(n),o=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;this.options.collisionIterations>e;e+=1)this.resolveBodyPairs(n,r,0===e),this.resolveColliders(n,o,0===e);this.updateSensors(n),this.updateSleeping(n,t)}settle(e=1200,t=this.options.fixedDt){let n=0;for(;e>n&&!this.allSleeping();)this.step(t),n+=1;return n}readState(e=[]){e.length=0;for(const t of this.sortedBodies())e.push({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:Bc(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Kc)}allSleeping(){for(const e of this.bodies.values())if(!e.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(Zc),colliders:this.sortedColliders().map(Jc),springs:Array.from(this.springs.values()).map(e=>({...e,target:{...e.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(e){this.options={...e.options,gravity:{...e.options.gravity}},this.random=$c(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const t of e.bodies){const e=Zc(t);this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(const t of e.colliders){const e=Jc(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(const t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});const e=/^spring-(\d+)$/.exec(t.id);e&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(e[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((e,t)=>e.index-t.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((e,t)=>e.index-t.index)}applySprings(e){for(const t of Array.from(this.springs.values()).sort((e,t)=>e.id.localeCompare(t.id))){const n=this.bodies.get(t.bodyId);if(!n||n.sleeping)continue;const i="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!i)continue;const r=i.x-n.x,o=i.y-n.y,s=Math.sqrt(r*r+o*o);if(Dc>=s)continue;const a=r/s,c=o/s,l=(s-t.restLength)*t.stiffness+((("vx"in i?i.vx:0)-n.vx)*a+(("vy"in i?i.vy:0)-n.vy)*c)*t.damping;n.vx+=l*a*e/n.mass,n.vy+=l*c*e/n.mass}}resolveBodyPairs(e,t,n){for(const i of t){const[t,r]=i.split(":").map(Number),o=e[t],s=e[r];if(!o||!s)continue;const a=Gc(o,s);a&&(this.resolveDynamicCollision(o,s,a),n&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(e){const t=Math.max(1,this.options.cellSize),n=new Map;for(let i=0;e.length>i;i+=1){if(!1===e[i].bodyCollisions)continue;const r=Wc(e[i]),o=Math.floor(r.minX/t),s=Math.floor(r.maxX/t),a=Math.floor(r.minY/t),c=Math.floor(r.maxY/t);for(let e=o;s>=e;e+=1)for(let t=a;c>=t;t+=1){const r=`${e}:${t}`,o=n.get(r);o?o.push(i):n.set(r,[i])}}const i=new Set;for(const t of Array.from(n.keys()).sort()){const r=n.get(t)??[];r.sort((e,t)=>e-t);for(let t=0;r.length>t;t+=1)for(let n=t+1;r.length>n;n+=1){const o=r[t],s=r[n];!1!==e[o].bodyCollisions&&!1!==e[s].bodyCollisions&&Yc(Wc(e[o]),Wc(e[s]))&&i.add(`${o}:${s}`)}}return Array.from(i).sort((e,t)=>{const[n,i]=e.split(":").map(Number),[r,o]=t.split(":").map(Number);return n===r?i-o:n-r})}resolveDynamicCollision(e,t,n){e.sleeping&&this.supportedThisStep.add(t.id),t.sleeping&&this.supportedThisStep.add(e.id);const i=e.sleeping?0:1/e.mass,r=t.sleeping?0:1/t.mass,o=i+r;if(Dc>=o)return;const s=Math.max(0,n.penetration-zc)/o;e.x-=n.nx*s*i,e.y-=n.ny*s*i,t.x+=n.nx*s*r,t.y+=n.ny*s*r;const a=(t.vx-e.vx)*n.nx+(t.vy-e.vy)*n.ny;if(a>0)return;const c=Math.abs(a),l=-(1+Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution))*a/o,u=l*n.nx,d=l*n.ny;e.vx-=u*i,e.vy-=d*i,t.vx+=u*r,t.vy+=d*r,this.applyFriction(e,t,n,l,i,r),c>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,n,i,r,o){const s=-n.ny,a=n.nx,c=(t.vx-e.vx)*s+(t.vy-e.vy)*a,l=r+o;if(Dc>=Math.abs(c)||Dc>=l)return;const u=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction))),d=Nc(-c/l,-i*u,i*u),h=d*s,f=d*a;e.vx-=h*r,e.vy-=f*r,t.vx+=h*o,t.vy+=f*o}resolveColliders(e,t,n){for(const i of e)for(const e of t){if(!tl(e,i))continue;if(!Yc(Wc(i),qc(e)))continue;const t=Vc(i,e);t&&(this.resolveStaticCollision(i,e,t),this.supportedThisStep.add(i.id),n&&this.lastEvents.push({type:"contact",bodyId:i.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,t,n){e.x+=n.nx*Math.max(0,n.penetration-zc),e.y+=n.ny*Math.max(0,n.penetration-zc);const i=e.vx*n.nx+e.vy*n.ny;if(0>i){const r=Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution);e.vx-=(1+r)*i*n.nx,e.vy-=(1+r)*i*n.ny;const o=-n.ny,s=n.nx,a=e.vx*o+e.vy*s,c=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction)));e.vx-=a*o*c,e.vy-=a*s*c}}updateSensors(e){const t=new Set,n=this.sortedColliders().filter(e=>e.sensor);for(const i of e){const e=Wc(i);for(const r of n){if(!tl(r,i))continue;if(!Yc(e,qc(r)))continue;if(!Vc(i,r))continue;const n=Uc(r.id,i.id);t.add(n),this.activeSensors.has(n)||this.lastEvents.push({type:"sensor-enter",bodyId:i.id,sensorId:r.id})}}for(const e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;const{sensorId:n,bodyId:i}=Kc(e);this.lastEvents.push({type:"sensor-exit",bodyId:i,sensorId:n})}this.activeSensors=t}updateSleeping(e,t){const n=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const i of e)Math.sqrt(i.vx*i.vx+i.vy*i.vy)>=this.options.sleepSpeed||Math.sqrt((i.x-i.prevX)*(i.x-i.prevX)+(i.y-i.prevY)*(i.y-i.prevY))>=this.options.sleepSpeed*t||n&&!this.supportedThisStep.has(i.id)?i.sleeping?this.wake(i):i.sleepTime=0:(i.sleepTime+=t,i.sleeping||this.options.sleepAfter>i.sleepTime||(i.sleeping=!0,i.vx=0,i.vy=0,this.lastEvents.push({type:"sleep",bodyId:i.id})))}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},il=class{constructor(e={}){this.id="builtin",this.capabilities={...(new nl).capabilities,engine:"builtin"},this.world=new nl(e)}init(e={}){this.world.init(e)}spawn(e){this.world.spawn(e)}remove(e){this.world.remove(e)}setColliders(e){this.world.setColliders(e)}setConstraint(e){return this.world.setConstraint(e)}removeConstraint(e){this.world.removeConstraint(e)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n)}step(e){this.world.step(e)}settle(e,t){return this.world.settle(e,t)}readState(e){return this.world.readState(e)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(e){this.world.restore(e)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function rl(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new il(e)}(t)}var ol=["binId","targetBin","category","windowIndex","lane","group"];function sl(e,t){if(!Number.isFinite(t))return;e.count+=1,e.total+=t,e.min=Math.min(e.min,t),e.max=Math.max(e.max,t);const n=t-e.mean;e.mean+=n/e.count,e.m2+=n*(t-e.mean)}function al(e){return{count:e.count,total:e.total,mean:e.count>0?e.mean:0,min:e.count>0?e.min:0,max:e.count>0?e.max:0,variance:e.count>1?e.m2/(e.count-1):0}}function cl(e){return{count:e.count,total:e.total,mean:e.mean,m2:e.variance*Math.max(0,e.count-1),min:e.count>0?e.min:1/0,max:e.count>0?e.max:-1/0}}function ll(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function ul(e,t,n){return"function"==typeof e?e(t,n):"string"==typeof e?ll(t,e):void 0}function dl(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function hl(e){const t=al(e.value);return{id:e.id,label:e.label,count:t.count,total:t.total,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:al(e.x),y:al(e.y),value:t}}var fl=class{constructor(e=!1){this.bins=new Map,this.nextIndex=0,this.config=e}updateConfig(e){void 0!==e&&(this.config=e,!1===e&&this.clear())}isEnabled(){return!1!==this.config}add(e){if(!1===this.config)return null;const t=this.nextIndex;this.nextIndex+=1;const n=dl(ul(this.config.binAccessor,e,t))??function(e){for(const t of ol){const n=dl(ll(e,t));if(n)return n}return"sediment"}(e),i=dl(ul(this.config.labelAccessor,e,t))??n,r=function(e,t,n){if("number"==typeof e)return e;const i="function"==typeof e?e(t,n):"string"==typeof e?ll(t,e):1,r="number"==typeof i?i:Number(i);return Number.isFinite(r)?r:1}(this.config.valueAccessor,e,t),o=Math.max(0,Math.floor(this.config.retainBodyIds??12));let s=this.bins.get(n);return s||(s={id:n,label:i,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(n,s)),s.label=i,s.lastBodyId=e.id,s.lastDatum=e.datum,sl(s.x,e.x),sl(s.y,e.y),sl(s.value,r),o>0&&(s.bodyIds.push(e.id),s.bodyIds.length>o&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-o))),hl(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(hl)}restore(e=[]){this.bins.clear();for(const t of e)this.bins.set(t.id,{id:t.id,label:t.label,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:cl(t.x),y:cl(t.y),value:cl(t.value)});this.nextIndex=e.reduce((e,t)=>e+t.count,0)}totals(){const e=this.snapshot();return{bins:e.length,count:e.reduce((e,t)=>e+t.count,0),total:e.reduce((e,t)=>e+t.total,0)}}};function pl(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}var yl={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},gl={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function ml(e={},t=gl){return{chartId:e.chartId??t.chartId,chartType:e.chartType??t.chartType,sensors:e.sensors??t.sensors,onObservation:e.onObservation??t.onObservation,onSimulationStateChange:e.onSimulationStateChange??t.onSimulationStateChange}}function xl(e){return{...e,shape:{...e.shape},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function bl(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:void 0}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function vl(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function wl(e){return{...xl(e),sequence:e.sequence,spawnAt:e.spawnAt}}function kl(e){return e.map(e=>({...e,shape:{...e.shape},bodyFilter:e.bodyFilter&&"function"!=typeof e.bodyFilter?{...e.bodyFilter,oneOf:e.bodyFilter.oneOf?.slice(),notOneOf:e.bodyFilter.notOneOf?.slice()}:e.bodyFilter}))}function Sl(e){return!1!==e&&{...e}}function Al(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function Ml(e){return{...e,gravity:{...e.gravity}}}function Pl(e,t,n,i){if("circle"===e.shape.type){const r=e.x-t,o=e.y-n,s=e.shape.radius+i,a=r*r+o*o;return a>s*s?null:a}const r=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),o=Math.max(Math.abs(n-e.y)-e.shape.height/2,0),s=r*r+o*o;return s>i*i?null:s}function _l(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function jl(e,t={}){const{idPrefix:n="plot",includeFloor:i=!0,includeCeiling:r=!1,includeLeftWall:o=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2;return i&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*a,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*a,height:c}}),o&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-a/2,y:d,width:a,height:e.height+2*c}}),s&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+a/2,y:d,width:a,height:e.height+2*c}}),l}function Cl(e){const{idPrefix:t="bin",count:n,domainStart:i,domainStep:r,xScale:o,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:f=Math.max(2,c)}=e,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?n:n-1;if(u||l)for(let e=l?0:1;m>=e;e+=1){if(!u&&e>0&&n>e)continue;const s=o(i+e*r);p.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=d)for(let e=0;n>e;e+=1){const n=i+e*r,s=n+r;if(s>=d)continue;const a=o(n),l=o(s);p.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:f}})}return p}var Il=require("d3-quadtree"),Tl=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,n,i,r,o=0){const s=this.ensure(e,t);if(!s)return null;let a=null,c=1/0;const l=Math.max(0,o)+this.maxSearchRadius,u=i-l,d=i+l,h=r-l,f=r+l;return s.visit((e,t,s,l,p)=>{if(u>l||t>d||h>p||s>f)return!0;if(e.length)return!1;let y=e;for(;y;){const e=y.data;if(e){const t=Pl(e,i,r,Math.max(0,o));null!=t&&(c>t||t===c&&n.indexOf(e.id)>n.indexOf(a?.id??""))&&(a=e,c=t)}y=y.next}return!1}),a}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;const n=e.readState();return 0===n.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=n.reduce((e,t)=>Math.max(e,function(e){return"circle"===e.shape.type?e.shape.radius:Math.hypot(e.shape.width,e.shape.height)/2}(t)),0),this.tree=(0,Il.quadtree)().x(e=>e.x).y(e=>e.y).addAll(n),this.revision=t,this.tree)}},Rl=["data","scene-geometry","data-paint","accessibility","evidence"],Ll=["scene-geometry","data-paint","accessibility","evidence"],$l=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],El=["overlay","accessibility","evidence"],Dl=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function zl(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&Dl.every(n=>e[n]===t[n])}function Bl(e,t,n,i){return e||!t?"paused":n||!i?"running":"settled"}var Fl=class{constructor(e={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new Tl,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new Lt,this.simulationState="settled",this.visible=!0;const{bodyBudget:t,colliders:n,engine:i,kernel:r,observation:o,sediment:s,...a}=e;this.config={...yl,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=i,this.observation=ml(o),this.sediment=new fl(s??!1),this.world=rl(i,{fixedDt:this.config.fixedDt,...r}),n&&this.world.setColliders(kl(n))}updateConfig(e){const t=function(e,t){return Object.keys(e).filter(n=>"kernel"===n?!zl(e.kernel,t.kernel):e[n]!==t[n])}(e,this.configInput),{colliders:n,bodyBudget:i,engine:r,kernel:o,observation:s,sediment:a,...c}=e;if(this.config={...this.config,...c},void 0!==i&&(this.bodyBudget=i,!1===i&&(this.bodyBudgetObservationKey="ok")),r&&r!==this.engineInput){const e=this.world.snapshot();this.world.dispose(),this.engineInput=r,this.world=rl(r,e.options),this.world.restore(e),this.revision+=1}if(o&&!zl(o,this.configInput.kernel)){const e=this.world.snapshot(),t={...e.options,...o,gravity:{...e.options.gravity,...o.gravity}};this.world.restore({...e,options:t}),this.revision+=1}s&&(this.observation=ml(s,this.observation)),this.sediment.updateConfig(a),n&&(this.world.setColliders(kl(n)),this.revision+=1),this.configInput={...this.configInput,...e},this.updateResults.record({kind:"config",keys:t},t.length?$l:[])}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(kl(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},$l)}enqueue(e,t){const n=Array.isArray(e)?e:[e],i=t?function(e,t={}){const n=bl(t.startAt)??0,i=t.pacing??"immediate";if("arrival"===i){const i=e.map((e,n)=>function(e,t,n){return"function"==typeof n?bl(n(e,t)):"string"==typeof n?bl(vl(e,n)):bl(e.spawnAt)??bl(vl(e,"arrivalTime"))??bl(vl(e,"timestamp"))??bl(vl(e,"time"))??bl(vl(e,"eventTime"))}(e,n,t.timeAccessor)),r=i.filter(e=>null!=e),o=r.length>0?Math.min(...r):0,s=bl(t.timeScale)??1,a=s>0?s:1;return e.map((e,t)=>{const r=i[t],s=null==r?0:Math.max(0,r-o);return{...xl(e),spawnAt:n+s/a}})}if("object"==typeof i){const t=bl(i.ratePerSec);if(t&&t>0)return e.map((e,i)=>({...xl(e),spawnAt:n+i/t}))}return e.map(e=>({...xl(e),spawnAt:n}))}(n,{...t,startAt:t.startAt??this.elapsedSeconds}):n;for(const e of i)this.queue.push({...xl(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(Al),i.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:i.length},i.length?Rl:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(xl(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},Rl)}clear(){const e=this.world.snapshot().options;this.world.init({...e,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},Rl)}tick(e){const t=this.revision,n=[],i=[],r=[],o=[],s=[];if(this.paused||!this.visible){const e=this.result(0,n,i,r,o,s,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}const a=Math.max(0,Math.min(e,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(n,s);const c=this.observeBodyBudget(s),l=this.evictOverflow(s);i.push(...l.evicted),r.push(...l.sedimented),this.syncSimulationState(s),this.accumulator+=a;let u=0;for(;this.accumulator>=this.config.fixedDt&&this.config.maxSubsteps>u;){this.world.step(this.config.fixedDt);const e=this.world.events();o.push(...e),this.observeKernelEvents(e,s),this.observeSensorTransitions(s),this.accumulator-=this.config.fixedDt,u+=1}u===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(u>0||n.length>0||i.length>0||r.length>0||o.length>0)&&(this.revision+=1);const d=this.result(u,n,i,r,o,s,void 0,c);return this.updateResults.record({kind:"tick",count:u},this.revision!==t?n.length||i.length||r.length?Rl:Ll:[]),d}settle(e=this.config.settleStepLimit){const t=this.revision;this.spawnDue([],[]);const n=this.world.settle(e,this.config.fixedDt);return n>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:n},this.revision!==t?Ll:[]),n}settleWithObservations(e=this.config.settleStepLimit){const t=this.revision,n=[],i=[],r=[],o=[],s=[];if(this.paused||!this.visible){const e=this.result(0,n,i,r,o,s,!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(n,s);const a=this.observeBodyBudget(s),c=this.evictOverflow(s);i.push(...c.evicted),r.push(...c.sedimented),this.syncSimulationState(s);let l=0;for(;e>l&&!this.world.allSleeping();){this.world.step(this.config.fixedDt);const e=this.world.events();o.push(...e),this.observeKernelEvents(e,s),this.observeSensorTransitions(s),l+=1}(l>0||n.length>0||i.length>0||r.length>0||o.length>0)&&(this.revision+=1);const u=this.result(l,n,i,r,o,s,void 0,a);return this.updateResults.record({kind:"settle",count:l},this.revision!==t?n.length||i.length||r.length?Rl:Ll:[]),u}readBodies(e=[]){return this.world.readState(e)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(e={}){return function(e,t={}){const{baselineY:n=0,binWidth:i=24,gap:r=2,maxHeight:o=80,value:s="count",x:a}=t,c=Math.max(1,...e.map(e=>e[s]));return e.map((e,t)=>{const l=Math.max(0,e[s]/c*o),u=a?.(e,t)??t*(i+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:i,height:l,meanX:e.x.mean,meanY:e.y.mean}})}(this.readSediment(),e)}hitTest(e,t,n=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,n)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}hasPendingWork(){return this.queue.length>0||!this.world.allSleeping()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(e){const{timestamp:t,chartType:n,chartId:i,...r}=e,o={...r,timestamp:t??this.elapsedSeconds,chartType:n??this.observation.chartType,chartId:i??this.observation.chartId};return this.emitObservation(o),this.updateResults.record({kind:"update",count:1},["evidence"]),o}getLastUpdateResult(){return this.updateResults.last}version(){return this.revision}setPaused(e){const t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?El:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?El:[])}remove(e){const t=new Set(e),n=new Set(this.liveBodyOrder),i=new Set(this.queue.map(e=>e.id));this.queue=this.queue.filter(e=>!t.has(e.id)),this.liveBodyOrder=this.liveBodyOrder.filter(e=>!t.has(e)),this.world.remove(e),this.removeActiveSensorPairsForBodies(t);const r=e.filter(e=>n.has(e)||i.has(e));return r.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:r,count:r.length},r.length?Rl:[]),r}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},Ll),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},Ll)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},Ll)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,n,i)=>e.applyImpulse(t,n,i),clear:()=>e.clear(),hitTest:(t,n,i)=>e.hitTest(t,n,i),pause:()=>e.setPaused(!0),push:(t,n)=>e.enqueue(t,n),pushMany:(t,n)=>e.enqueue(t,n),bodyBudgetStatus:()=>e.bodyBudgetStatus(),readBodies:t=>e.readBodies(t),readSediment:()=>e.readSediment(),recordObservation:t=>e.recordObservation(t),remove:t=>e.remove(t),restore:t=>e.restore(t),resume:()=>e.setPaused(!1),settle:t=>e.settle(t),settleWithObservations:t=>e.settleWithObservations(t),snapshot:()=>e.snapshot(),sedimentHeightfield:t=>e.sedimentHeightfield(t),sedimentTotals:()=>e.sedimentTotals(),step:t=>e.tick(t)};var e}snapshot(){const e=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:Sl(this.bodyBudget),config:{...this.config,kernel:Ml(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(wl),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:e}}restore(e){this.config={bodyLimit:e.config.bodyLimit,eviction:e.config.eviction,fixedDt:e.config.fixedDt,maxDeltaSeconds:e.config.maxDeltaSeconds,maxSubsteps:e.config.maxSubsteps,settleStepLimit:e.config.settleStepLimit,timeScale:e.config.timeScale},this.configInput={...e.config,bodyBudget:Sl(e.bodyBudget??{}),kernel:Ml(e.world.options)},this.bodyBudget=Sl(e.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.activeSensorPairs=new Set(e.activeSensorPairs),this.accumulator=e.accumulator,this.elapsedSeconds=e.elapsedSeconds,this.paused=e.paused,this.queue=e.queue.map(wl).sort(Al),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Bl(e.paused,e.visible,e.queue.length>0,e.world.bodies.every(e=>e.sleeping)),this.liveBodyOrder=e.liveBodyOrder.slice(),this.visible=e.visible,this.nextSequence=this.queue.reduce((e,t)=>Math.max(e,t.sequence),-1)+1,this.world.restore(e.world),this.updateResults.record({kind:"restore"},$l)}spawnDue(e,t){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const n=this.queue.shift();if(!n)return;this.spawnOne(n,t),e.push(n.id)}}spawnOne(e,t){this.liveBodyOrder=this.liveBodyOrder.filter(t=>t!==e.id),this.removeActiveSensorPairsForBodies(new Set([e.id])),this.world.spawn(e),this.liveBodyOrder.push(e.id);for(const t of e.springs??[])this.world.setConstraint({...t,bodyId:e.id});const n=this.world.readState().find(t=>t.id===e.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:e.id,datum:n?.datum??e.datum,x:n?.x??e.x,y:n?.y??e.y},t)}result(e,t,n,i,r,o,s,a=this.evaluateBodyBudget()){this.syncSimulationState(o);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:n,events:r,observations:o,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!c),sleeping:c,sedimented:i,spawned:t,steps:e}}observeKernelEvents(e,t){!function(e,t,n){if(0===t.length)return;const i=new Map(e.readState().map(e=>[e.id,e]));for(const e of t){if("sleep"!==e.type)continue;const t=i.get(e.bodyId);n.emit({type:"physics-settle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:e.bodyId,datum:t?.datum,x:t?.x,y:t?.y})}}(this.world,e,this.observationContext(t))}observeSensorTransitions(e){this.activeSensorPairs=function(e,t,n){const i=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===i.size&&0===t.size)return i;const r=new Map(e.readState().map(e=>[e.id,e])),o=(e,t)=>{const{sensorId:i,bodyId:o}=_l(t),s=n.observation.sensors[i],a=r.get(o);n.emit({type:"enter"===e?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:o,datum:a?.datum,x:a?.x,y:a?.y,sensorId:i,binId:s?.binId??i})};for(const e of Array.from(i).sort())t.has(e)||o("enter",e);for(const e of Array.from(t).sort())i.has(e)||o("exit",e);return i}(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){!function(e,t){for(const n of e)t.has(_l(n).bodyId)&&e.delete(n)}(this.activeSensorPairs,e)}observationContext(e){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:t=>this.emitObservation(t,e)}}emitObservation(e,t){t?.push(e),this.observation.onObservation?.(e)}evaluateBodyBudget(){return function(e){const t=Math.max(0,Math.floor(e.liveBodies)),n=Math.max(0,Math.floor(e.queuedBodies??0)),i=t+n,r=pl(e.bodyLimit),o=pl(e.engineMaxBodiesHint),s=function(e,t,n){if(!1===n)return;const i=pl(n?.warnAt);return null!=i?i:null!=e?Math.max(1,Math.floor(.8*e)):null!=t?Math.max(1,Math.floor(.8*t)):void 0}(r,o,e.options),a=null==r?0:Math.max(0,t-r),c=a>0?"overflow":null==s||s>i?"ok":"warning";return{action:"overflow"!==c?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:r,engineMaxBodiesHint:o,liveBodies:t,overflow:a,projectedBodies:i,queuedBodies:n,state:c,warnAt:s}}({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(e){const t=this.evaluateBodyBudget();if("ok"===t.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",t;const n=`${t.state}:${t.action}`;return n===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=n,this.emitObservation({type:"overflow"===t.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:t.action,bodyLimit:t.bodyLimit,engineMaxBodiesHint:t.engineMaxBodiesHint,liveBodies:t.liveBodies,overflow:t.overflow,projectedBodies:t.projectedBodies,queuedBodies:t.queuedBodies,warnAt:t.warnAt},e)),t}syncSimulationState(e){const t=Bl(this.paused,this.visible,this.queue.length>0,this.world.allSleeping());if(t===this.simulationState)return;const n=this.simulationState;this.simulationState=t,function(e,t,n){n.observation.onSimulationStateChange?.(t,e),"running"!==t&&"settled"!==t||n.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,simulationState:t,previousSimulationState:e})}(n,t,this.observationContext(e))}evictOverflow(e){if(!1===this.config.eviction)return{evicted:[],sedimented:[]};const t=Math.max(0,Math.floor(this.config.bodyLimit));if(!Number.isFinite(t))return{evicted:[],sedimented:[]};const n=this.liveBodyOrder.length-t;if(0>=n)return{evicted:[],sedimented:[]};const i=("sleeping-first"===this.config.eviction?this.sleepingFirstEvictionOrder():this.liveBodyOrder.slice()).slice(0,n);if(0===i.length)return{evicted:[],sedimented:[]};const r=this.absorbSediment(i,e);this.world.remove(i);const o=new Set(i);return this.liveBodyOrder=this.liveBodyOrder.filter(e=>!o.has(e)),this.removeActiveSensorPairsForBodies(o),{evicted:i,sedimented:r}}absorbSediment(e,t){const n=new Map(this.world.readState().map(e=>[e.id,e])),i=[];for(const r of e){const e=n.get(r);if(!e)continue;const o=this.sediment.add(e);o&&(i.push(r),this.emitObservation({type:"physics-sediment",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:r,datum:e.datum,x:e.x,y:e.y,binId:o.id,count:o.count,total:o.total},t))}return i}sleepingFirstEvictionOrder(){const e=new Map(this.world.readState().map(e=>[e.id,e.sleeping])),t=[],n=[];for(const i of this.liveBodyOrder)e.get(i)?t.push(i):n.push(i);return[...t,...n]}};var Nl=require("d3-scale");function Ol(e){const{count:t,idPrefix:n,wallThickness:i,xScale:r,yBottom:o,yTop:s,yTopForIndex:a}=e;return Array.from({length:t+1},(e,t)=>{const c=Math.min(o-1,a?.(t)??s),l=Math.max(1,o-c);return{id:`${n}-wall-${t}`,shape:{type:"aabb",x:r(t),y:c+l/2,width:i,height:l}}})}var Wl=require("d3-scale");function ql(e){if(Array.isArray(e)&&e.length>=2){const t=jc(e[0]),n=jc(e[1]);return null!=t&&null!=n?{x:t,y:n}:null}if(e&&"object"==typeof e){const t=e,n=jc(t.x),i=jc(t.y);return null!=n&&null!=i?{x:n,y:i}:null}return null}function Yl(e){return Array.isArray(e)?e.map(ql).filter(e=>null!=e):[]}function Hl(e,t,n){return"normalized"===n?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:Cc(e.x,t.plot.x,t.plot.x+t.plot.width),y:Cc(e.y,t.plot.y,t.plot.y+t.plot.height)}}function Xl(e){let t=0;for(let n=1;e.length>n;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}function Gl(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const n=Cc(t,0,1)*Xl(e);let i=0;for(let t=1;e.length>t;t+=1){const r=e[t-1],o=e[t],s=Math.hypot(o.x-r.x,o.y-r.y);if(s>0){if(i+s>=n){const e=(n-i)/s;return{x:r.x+(o.x-r.x)*e,y:r.y+(o.y-r.y)*e}}i+=s}}return{...e[e.length-1]}}function Vl(e,t){const n=Gl(e,Math.max(0,t-.02)),i=Gl(e,Math.min(1,t+.02)),r=i.x-n.x,o=i.y-n.y,s=Math.hypot(r,o)||1;return{x:r/s,y:o/s}}function Ul(e,t,n){return Math.max(t,Math.min(n,e))}function Kl(e,t,n,i,r,o={}){return{id:e,friction:o.friction,restitution:o.restitution,bodyFilter:o.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:i,y2:r,thickness:o.thickness??8}}}function Zl(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,n=e.y,i=e.width,r=e.height,{type:"aabb",x:t,y:n,width:i,height:r}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:e.attributes,onEnter:e.onEnter,onExit:e.onExit};var t,n,i,r}function Ql(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...Zl({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function Jl(e,t=12){return"number"==typeof e?{x:e,y:0}:e&&"object"==typeof e?{x:Number.isFinite(e.x)?Number(e.x):t,y:Number.isFinite(e.y)?Number(e.y):0}:{x:t,y:0}}function eu(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const n=e.size,i=Sc(n),r=Cc(e.ballRadius??6,2,18),o=e.seed??1,s=Rc(o),a=e.idAccessor,c=e.stageAccessor??"stage",l=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,f=e.groupCompletion??(l?"allAbsorbed":"none"),p=e.springStiffness??.28,y=e.springDamping??.72,g=!0===e.settle,m=t.map(e=>({id:e.id,label:e.label??e.id,description:e.description,share:e.share})),x=function(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),i=Math.max(1,Math.round(e.height)),r=e.padX??46,o=e.padY??72,s=r,a=n-r,c=o,l=i-Math.max(24,Math.round(.45*o)),u=(c+l)/2,d=Math.max(1,l-c),h=Ul(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=Ul(d*h+p,.06*d,.5*d),g=y/2,m=u-g,x=u+g,b=e.idPrefix??"process",v=e.friction??.58,w=e.restitution??.18,k=e.wallThickness??8,S=e.stages;if(!S.length)throw Error("processStageLayout requires at least one stage");const A=Ul(e.centerStageIndex??Math.floor(S.length/2),0,S.length-1),M=function(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}(S),P=a-s;let _=s;const j=S.map((e,t)=>{const n=_,i=t===S.length-1?a:_+(e.share??1)/M*P;return _=i,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:i,x:(n+i)/2,width:i-n,y:u,height:d}}),C=j[A],I=C.x0,T=C.x1,R=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=Ul((e-s)/Math.max(1,a-s),0,1);return"top"===n?c+(m-c)*t:l+(x-l)*t}if(I>=e){const t=Ul((e-s)/Math.max(1,I-s),0,1);return"top"===n?c+(m-c)*t:l+(x-l)*t}if(T>=e)return"top"===n?m:x;const i=Ul((e-T)/Math.max(1,a-T),0,1);return"top"===n?m+(c-m)*i:x+(l-x)*i},L=j.map(e=>{const t=Math.min(R(e.x0,"top"),R(e.x1,"top")),n=Math.max(R(e.x0,"bottom"),R(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),$={thickness:k,friction:v,restitution:w},E=[];"lane"===t?E.push(Kl(b+"-top",s,c,a,c,$),Kl(b+"-bottom",s,l,a,l,$),Kl(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),Kl(b+"-right",a,c,a,l,{...$,thickness:Math.max(6,k)})):"funnel"===t?E.push(Kl(b+"-top",s,c,a,m,$),Kl(b+"-bottom",s,l,a,x,$),Kl(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),Kl(b+"-right",a,m,a,x,{...$,thickness:Math.max(6,k)})):E.push(Kl(b+"-left-top",s,c,I,m,$),Kl(b+"-left-bottom",s,l,I,x,$),Kl(b+"-center-top",I,m,T,m,$),Kl(b+"-center-bottom",I,x,T,x,$),Kl(b+"-right-top",T,m,a,c,$),Kl(b+"-right-bottom",T,x,a,l,$),Kl(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),Kl(b+"-right",a,c,a,l,{...$,thickness:Math.max(6,k)}));const D=e.membraneDampingScale??.5,z=s,B=Math.max(1,("bowtie"===t?I:a)-z),F=(e.membranes??[]).map(e=>{const t=z+Ul(e.offset,0,1)*B,n=e.width??18+18*e.cost,i=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:i}}),N=!1===e.includeMembraneRegions?[]:F.map(e=>function(e){const t=e.dampingScale??.5,n=e.energyScale??1,i=Ul(e.cost,0,2);return{...Zl({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:i,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:i*t,energyDelta:-i*n}}({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??D,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:i,padX:r,padY:o,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:I,centerRight:T,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:L,membranes:F,colliders:E,regionEffects:N,boundaryY:R}}({width:n[0],height:n[1],shape:"lane",padX:Math.max(28,i.plot.x),padY:Math.max(36,i.plot.y+8),stages:m,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((e,t)=>[e.id,t])),v=new Map(x.stages.map(e=>[e.id,e])),w=x.stages[0].id,k=x.stages[0],S=new Set(t.filter(e=>e.absorb).map(e=>e.id)),A=t.map(e=>{const t=v.get(e.id)??k;return function(e,t){const n={id:"process-stage-"+e.id,label:e.label??e.id,description:e.description,x:t.x,y:t.y,width:Math.max(12,.92*t.width),height:Math.max(40,.88*t.height),semanticItem:!1,attributes:{stageId:e.id}};if(e.absorb)return function(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...Zl({...e,kind:e.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}({...n,kind:e.kind??"sink",force:Jl(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...n.attributes,primitive:"absorb"}});if(e.portal){const t=e.portal.force??e.force??{x:-40,y:0};return i={...n,kind:e.kind??"force-field",force:Jl(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...n.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...Zl({...i,kind:i.kind??"force-field",attributes:{primitive:"portal",targetStage:i.targetStage,..."object"==typeof i.attributes&&i.attributes?i.attributes:{}}}),force:i.force,impulseOnEnter:i.impulseOnEnter,damping:i.damping??.08}}var i;if(e.capacity){const t=Math.max(.1,e.capacity.unitsPerSecond);return function(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...Zl({...e,kind:e.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping,charge:e.charge??e.capacity}}({...n,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:Jl(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...n.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){const t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return function(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,i=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...Zl({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n+t*i,energyDelta:r?-t*r:void 0,force:e.force}}({...n,kind:e.kind??"membrane",pressure:t.pressure,occupancy:t.occupancy,baseDamping:t.baseDamping??e.damping??.1,dampingPerUnit:t.dampingPerUnit??.1,energyPerUnit:t.energyPerUnit??0,force:Jl(e.force,8),attributes:{...n.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?Ql({...n,kind:e.kind??"force-field",force:Jl(e.force,14),damping:e.damping??.02,attributes:{...n.attributes,primitive:"routeSurface"}}):function(e){return{...Zl({...e,kind:e.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}({...n,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...n.attributes,primitive:"forceField"}})}(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});A.unshift(Ql({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(x.left+x.right)/2,y:x.midY,width:x.right-x.left,height:x.bottomY-x.topY-12,force:8,damping:.012,semanticItem:!1}));const M=new Map;for(const e of x.stages)M.set(e.id,0);const P=[];e.data.forEach((e,t)=>{const n=(a?_c(e,t,a)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",i=(_c(e,t,c)??w)+"",o=b.has(i)?i:w;M.set(o,(M.get(o)??0)+1);const s=l?(_c(e,t,l)??"")+"":void 0,f=s&&u?(_c(e,t,u)??s)+"":s,p=d?jc(_c(e,t,d))??1:1,y=h?jc(_c(e,t,h)):null,g=Cc(null!=y&&y>0?y:r,2,18);P.push({datum:e,id:n,stageId:o,groupId:s||void 0,groupLabel:f||void 0,work:p,radius:g,index:t})});const _=new Map,j=new Map;for(const e of P){if(!e.groupId)continue;const t=_.get(e.groupId)??[];t.push(e.id),_.set(e.groupId,t),e.groupLabel&&j.set(e.groupId,e.groupLabel)}const C=Cc(e.groupAnchorAlong??.55,.15,.9),I=x.left+(x.right-x.left)*C,T=Array.from(_.keys()),R=T.map((e,n)=>{const i=_.get(e)??[],r=T.length>1?x.topY+28+n/Math.max(1,T.length-1)*(x.bottomY-x.topY-56):x.midY;return function(e){const t=e.x??e.anchor?.x??0,n=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}({id:e,label:j.get(e)??e,bodyIds:i,anchor:{x:I,y:r},x:I,y:r,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),L=function(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],i=t.filter(e=>!n.has(e)),r=t.length-i.length,o=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s?.[e];return Number.isFinite(t)&&Number(t)>=0?Number(t):1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(n.has(t)?a(t):0),0),u=e.completion?.threshold,d="threshold"===o?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:o,complete:t.length>0&&("anyAbsorbed"===o?r>0:"threshold"===o?l>=(d??c):0===i.length),absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:i}})}(R,P.filter(e=>S.has(e.stageId)).map(e=>e.id)),$=new Map(R.map(e=>[e.id,e])),E=P.map((e,t)=>{const n=v.get(e.stageId)??k,i=n.x+(s()-.5)*Math.min(24,.2*n.width),r=x.boundaryY(i,"top")+e.radius+10,o=x.boundaryY(i,"bottom")-e.radius-10,a=o>r?r+s()*Math.max(1,o-r):x.midY,c=g?i:x.left+18+t%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:i,y:a},restLength:.45*e.radius,stiffness:p,damping:y}];if(e.groupId){const t=$.get(e.groupId);t?.anchor&&!S.has(e.stageId)&&u.push({target:{type:"point",x:t.anchor.x,y:t.anchor.y},restLength:t.tether?.restLength??22,stiffness:t.tether?.stiffness??.05,damping:.8})}return{id:e.id,x:c,y:l,vx:g?0:40+40*s(),vy:g?0:20*(s()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:g?0:.03*t,springs:u,datum:{...e.datum,id:e.id,stage:e.stageId,groupId:e.groupId,groupLabel:e.groupLabel,work:e.work,__processFlow:!0}}}),D={kernel:{seed:o,gravity:{x:e.gravityX??22,y:e.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},z=x.stages.map(e=>({label:e.label??e.id,value:M.get(e.id)??0})),B=t.map(e=>{const t=v.get(e.id)??k;return{id:e.id,label:e.label??e.id,x:t.x,width:t.width,count:M.get(e.id)??0,capacity:e.capacity?.unitsPerSecond,absorb:!0===e.absorb,portalTarget:e.portal?.targetStageId}});return{config:D,initialSpawns:E,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:z,metadata:{kind:"process-flow",plot:i.plot,volume:x,stages:B,groups:R,groupCompletion:L,regionEffects:A}}}var tu=require("react"),nu=require("d3-scale");function iu(e,t,n){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=I[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}function ru(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&E(n,e)||"#4e79a7":t=>{if(n){const e=E(n,t);if(e)return e}let i=0;for(let e=0;t.length>e;e++)i=31*i+t.charCodeAt(e)|0;return e[Math.abs(i)%e.length]??"#4e79a7"}}var ou=c(require("react")),su=require("react"),au={names:["--semiotic-bg","--surface-1","--surface-0"],fallback:"#f8fafc"},cu={names:["--semiotic-border","--surface-3"],fallback:"#334155"},lu={names:["--semiotic-danger","--viz-4"],fallback:"#dc2626"},uu={names:["--semiotic-focus","--accent","--viz-9"],fallback:"#f97316"},du={names:["--semiotic-grid","--surface-3"],fallback:"#cbd5e1"},hu={names:["--semiotic-primary","--accent","--viz-5"],fallback:"#0ea5e9"},fu={names:["--semiotic-success","--viz-2"],fallback:"#22c55e"},pu={names:["--semiotic-text","--text-primary"],fallback:"#0f172a"},yu={names:["--semiotic-text-secondary","--text-secondary"],fallback:"#475569"},gu={names:["--semiotic-warning","--viz-9","--viz-3"],fallback:"#f97316"};function mu(e,t){const n=e.canvas;if("function"!=typeof getComputedStyle||!n)return t.fallback;const i=getComputedStyle(n);for(const n of t.names){const t=i.getPropertyValue(n).trim();if(t)return vn(e,t)??t}return t.fallback}function xu(e,t){const n=Math.max(0,Math.min(1,t)),i=e.trim(),r=i.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i);if(r){const[,e,t,i]=r;return xu(`#${e}${e}${t}${t}${i}${i}`,n)}const o=i.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(o){const[,e,t,i]=o;return`rgba(${parseInt(e,16)}, ${parseInt(t,16)}, ${parseInt(i,16)}, ${n})`}const s=i.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);if(s)return`rgba(${s[1]}, ${n})`;const a=i.match(/^rgba\s*\(\s*([^,]+,\s*[^,]+,\s*[^,]+),\s*[^)]+\)$/i);return a?`rgba(${a[1]}, ${n})`:i}var bu=c(require("react")),vu=require("d3-scale"),wu=require("react/jsx-runtime");function ku(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function Su(e){const{width:t,height:n,totalWidth:i,totalHeight:r,margin:o,title:s,legend:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d,legendPosition:h="right",legendLayout:f,pointNodes:p=[],annotations:y,autoPlaceAnnotations:g,svgAnnotationRules:m,children:x}=e,b=bu.useMemo(()=>function(e){return e?.length?e.map(e=>null!=e.pointId||null==e.bodyId?e:{...e,pointId:e.bodyId+""}):e}(y),[y]),v=bu.useMemo(()=>function(e){const{width:t,height:n,pointNodes:i=[],data:r}=e;return{scales:{x:(0,vu.scaleLinear)().domain([0,Math.max(1,t)]).range([0,Math.max(1,t)]),y:(0,vu.scaleLinear)().domain([0,Math.max(1,n)]).range([0,Math.max(1,n)])},width:t,height:n,frameType:"network",pointNodes:i,data:r,xAccessor:"x",yAccessor:"y"}}({width:t,height:n,pointNodes:p}),[n,p,t]),w=bu.useMemo(()=>b&&g?Mr({annotations:b,context:v,..."object"==typeof g?g:{}}):b,[v,g,b]),k=bu.useMemo(()=>Ji(),[]),S=w?Qi(w.filter(e=>"widget"!==e.type),k,m,v):null,A=!0===w?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,wu.jsxs)(wu.Fragment,{children:[A?(0,wu.jsx)("style",{children:qi},"physics-annotation-disclosure-style"):null,(0,wu.jsxs)("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,wu.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[S,x]}),s&&"string"==typeof s?(0,wu.jsx)("text",{x:i/2,y:16,textAnchor:"middle",fontWeight:600,fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?(0,wu.jsx)("foreignObject",{x:0,y:0,width:i,height:Math.max(o.top,28),children:s}):null,a?ci({legend:a,totalWidth:i,totalHeight:r,margin:o,legendPosition:h,legendLayout:f,title:s,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d}):null]})]})}function Au(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Mu(e,t){const n="sensor"===e.physics?t.sensorThickness:t.barrierThickness;return Math.max(0,Au(e.thickness)??Au(n)??Au(t.thickness)??4)}var Pu=2500;function _u(e){return"function"==typeof e}function ju(e){return void 0===e||!1===e||!_u(e.binAccessor)&&!_u(e.labelAccessor)&&!_u(e.valueAccessor)}function Cu(e){if(void 0!==e){if(!1===e)return!1;if(!ju(e))throw new TypeError("Physics worker sediment config only supports string or numeric accessors");return{binAccessor:"string"==typeof e.binAccessor?e.binAccessor:void 0,labelAccessor:"string"==typeof e.labelAccessor?e.labelAccessor:void 0,valueAccessor:"string"==typeof e.valueAccessor||"number"==typeof e.valueAccessor?e.valueAccessor:void 0,retainBodyIds:e.retainBodyIds}}}function Iu(e){if(e)return{chartId:e.chartId,chartType:e.chartType,sensors:e.sensors}}function Tu(e){return function(e){return!_u(e?.timeAccessor)}(e)}function Ru(e={}){if(e.engine)throw new TypeError("Physics workers use the built-in kernel adapter");const{engine:t,observation:n,sediment:i,...r}=e;return{...r,observation:Iu(n),sediment:Cu(i)}}var Lu={};function $u(){if("undefined"!=typeof DOMException)return new DOMException("Physics worker request aborted","AbortError");const e=Error("Physics worker request aborted");return e.name="AbortError",e}var Eu=class{constructor(e=function(){const e="string"==typeof Lu.url&&Lu.url?new URL("./physicsWorker.js",Lu.url):function(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}("physicsWorker.js");return new Worker(e,{type:"module",name:"semiotic-physics"})}()){this.nextRequestId=1,this.pending=new Map,this.worker=e,this.worker.onmessage=e=>{const t=e.data,n=this.pending.get(t.requestId);n&&(this.pending.delete(t.requestId),n.cleanup(),t.ok?n.resolve(t.payload):n.reject(function(e){const t=Error(e.error.message);return t.name=e.error.name??"Error",e.error.stack&&(t.stack=e.error.stack),t}(t)))},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Physics worker failed")),this.worker.terminate()}}request(e,t){if(t?.aborted)return Promise.reject($u());const n=this.nextRequestId;this.nextRequestId+=1;const i={command:e,requestId:n};return new Promise((e,r)=>{const o=()=>{this.pending.delete(n),t?.removeEventListener("abort",o),r($u())},s=()=>t?.removeEventListener("abort",o);this.pending.set(n,{cleanup:s,reject:r,resolve:e}),t?.addEventListener("abort",o,{once:!0});try{this.worker.postMessage(i)}catch(e){this.pending.delete(n),s(),r(e)}})}async init(e,t,n,i){if(!Tu(n))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const r=await this.request({type:"init",config:Ru(e),initialSpawns:t,initialSpawnPacing:n},i);if("frame"!==r.type)throw Error("Physics worker returned a non-frame init response");return r.frame}async restore(e,t){const n=await this.request({type:"restore",snapshot:e},t);if("frame"!==n.type)throw Error("Physics worker returned a non-frame restore response");return n.frame}async initFromSnapshot(e,t,n){const i=await this.request({type:"init",config:Ru(e),snapshot:t},n);if("frame"!==i.type)throw Error("Physics worker returned a non-frame init response");return i.frame}async enqueue(e,t,n){if(!Tu(t))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const i=await this.request({type:"enqueue",spawns:e,pacing:t},n);if("frame"!==i.type)throw Error("Physics worker returned a non-frame enqueue response");return i.frame}async tick(e,t){const n=await this.request({type:"tick",deltaSeconds:e},t);if("frame"!==n.type)throw Error("Physics worker returned a non-frame tick response");return n.frame}async settle(e,t){const n=await this.request({type:"settle",maxSteps:e},t);if("frame"!==n.type)throw Error("Physics worker returned a non-frame settle response");return n.frame}async snapshot(e){const t=await this.request({type:"snapshot"},e);if("snapshot"!==t.type)throw Error("Physics worker returned a non-snapshot response");return t.snapshot}async remove(e,t){const n=await this.request({type:"remove",ids:e},t);if("removed"!==n.type)throw Error("Physics worker returned a non-remove response");return{frame:n.frame,removed:n.removed}}terminate(){this.rejectAll(Error("Physics worker terminated")),this.worker.terminate()}rejectAll(e){for(const[t,n]of this.pending)this.pending.delete(t),n.cleanup(),n.reject(e)}},Du=c(require("react-dom/server"));function zu(e=[]){return e.map(e=>({id:e.id,label:e.label,count:e.count,...null!=e.secondary?{secondary:e.secondary}:{},...e.secondaryLabel?{secondaryLabel:e.secondaryLabel}:{},...null!=e.observed?{observed:e.observed}:{}}))}var Bu={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function Fu(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function Nu(e,t){const n="function"==typeof t?t(e):t;return{...Bu,...n??{}}}function Ou(e,t={}){return e.map(e=>function(e,t={}){const n=function(e){return e.datum&&"object"==typeof e.datum?e.datum:null}(e),i={label:t.getBodyLabel?.(e)??Fu(e)},r={style:Nu(e,t.bodyStyle),datum:n,accessibleDatum:n,accessibility:i,_transitionKey:e.id};return"aabb"===e.shape.type?{type:"rect",x:e.x-e.shape.width/2,y:e.y-e.shape.height/2,w:e.shape.width,h:e.shape.height,...r}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...r}}(e,t))}var Wu=require("react/jsx-runtime");function qu(e,t={}){const{width:n=640,height:i=360,title:r,description:o,background:s,className:a,idPrefix:c="physics",...l}=t,u=function(e,t={}){const n=e.settle(t.maxSteps),i=e.readBodies(),r=e.snapshot(),o=Ou(i,t),s=function(e,t={}){const n=t.bodies??function(e){return e.world.bodies.map(e=>({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:{...e.shape},sleeping:e.sleeping,datum:e.datum}))}(e),i=n.filter(e=>e.sleeping).length;return{bodyCount:n.length,sleepingCount:i,settled:"settled"===e.simulationState&&0===e.queue.length&&i===n.length,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:zu(t.projectionRows)}}(r,{bodies:i,projectionRows:t.projectionRows,stepsRun:n});return{snapshot:r,bodies:i,sceneNodes:o,evidence:s,stepsRun:n}}(e,l),d=function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}(c),h=r?d+"-title":void 0,f=o?d+"-desc":void 0,p=[h,f].filter(Boolean).join(" ")||void 0;return{svg:Du.renderToStaticMarkup((0,Wu.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:a??"stream-physics-frame",width:n,height:i,viewBox:`0 0 ${n} ${i}`,role:"img","aria-labelledby":p,children:[r&&(0,Wu.jsx)("title",{id:h,children:r}),o&&(0,Wu.jsx)("desc",{id:f,children:o}),s&&"transparent"!==s?(0,Wu.jsx)("rect",{x:0,y:0,width:n,height:i,fill:s}):null,(0,Wu.jsx)("g",{id:d+"-data-area",children:u.sceneNodes.map((e,t)=>so(e,t,d))})]})),scene:u,evidence:u.evidence}}function Yu(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const i=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(i)&&i>0?i:1}function Hu(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&(n+"").length>0)return n+""}else if(t){const n=Gu(e.datum,t),i=Gu(e,t),r=n??i;if(null!=r&&(r+"").length>0)return r+""}return e.id}function Xu(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),i=Math.floor(n);return e[i]+(e[Math.ceil(n)]-e[i])*(n-i)}function Gu(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}function Vu(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=Gu(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!t.oneOf.some(e=>Object.is(n,e))||t.notOneOf&&t.notOneOf.some(e=>Object.is(n,e)))}function Uu(e){const t=e.regionId,n=Math.max(0,e.unitsPerSecond),i=e.queueLayout??"lane",r=e.queueSlotSpacing??14,o=e.queueStiffness??.35,s=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):1/0,a=Math.max(.25,e.metricWindowSeconds??30),c=Math.max(1/60,e.snapshotIntervalSeconds??.25),l=e.releaseImpulse??{x:90,y:0},u=new Map,d=new Map,h=new Map,f=new Map,p=new Map,y=new Map,g=new Map,m=[];let x=0,b=new Map,v=new Map,w=0,k=0,S=0,A=null,M=0,P=0,_=0,j=0,C=0,I=0,T=0,R=0,L=0,$=0,E=0,D=0,z=-1,B=!1;function F(e,n){const i=n(e);return!!i&&i.activeRegionIds.includes(t)}function N(){D+=1}function O(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:t,work:e.total,queuedAt:e.queuedAt}}function W(n,i,r,o){const s={bodyId:n.id,jobId:i.jobId,visitId:i.visitId,visit:i.visit,remaining:i.work,total:i.work,queuedAt:i.queuedAt,sequence:o};return u.set(i.jobId,s),g.delete(n.id),y.set(n.id,i.jobId),P+=1,_+=i.work,N(),function(n,i,r){const o=O(i);e.onQueued?.(n,o),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:n.id,datum:n.datum,x:n.x,y:n.y,regionId:t,work:i.total,jobId:i.jobId,visitId:i.visitId,visit:i.visit,queuedAt:i.queuedAt,queueDepth:u.size})}(n,s,r),s}function q(e){if(u.size>=s||0===d.size)return;const t=Array.from(d.values()).sort((e,t)=>e.sequence-t.sequence);for(const n of t){if(u.size>=s)break;const t=p.get(n.jobId);t&&h.has(n.jobId)?(d.delete(n.jobId),g.delete(n.bodyId),W(t,n,e,n.sequence)):d.delete(n.jobId)}}function Y(){let e=0;for(const t of u.values())e+=t.remaining;return e}function H(){L=Math.max(L,u.size),$=Math.max($,Y())}function X(){const e=S-a,t=Math.max(0,Math.min(a,S-(A??S)));let i=0,r=0,o=0,s=0,c=0;for(const t of m){if(e>t.end)continue;i+=t.arrivals,r+=t.arrivalWork,o+=t.completions,s+=t.completedWork;const n=t.end-t.start;c+=n>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/n):t.processedWork}const l=t>0?r/t:0;return{seconds:t,arrivals:i,arrivalWork:r,completions:o,completedWork:s,processedWork:c,arrivalsPerSecond:t>0?i/t:0,throughputPerSecond:t>0?o/t:0,utilization:t>0&&n>0?Math.max(0,Math.min(1,c/(n*t))):0,pressure:n>0?l/n:0}}return{id:e.id??"capacity-queue:"+t,continuous:!1!==e.continuous,tick:i=>{const r=i.controls.readBodies(),o=new Map,P=new Map;for(const t of r){if(o.set(t.id,t),!F(t.id,i.getRegionState))continue;if(!Vu(t,e.bodyFilter))continue;const n=Hu(t,e.jobKey),r=P.get(n)??[];r.push(t),P.set(n,r)}const _=Number.isFinite(i.dt)?Math.max(0,i.dt):0;if(!B){const e=Number.isFinite(i.elapsed)?Math.max(0,i.elapsed):_;S=Math.max(0,e-_),B=!0}const L=S,$=L+_;S=$,A=null==A?L:Math.min(A,L);const D={start:L,end:$,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},Y=new Map;for(const[e,t]of P){const n=h.get(e)?.bodyId,i=t.find(e=>e.id===n)??t[0];Y.set(e,i),p.set(e,i)}for(const[n,r]of h){if(Y.has(n))continue;const s=u.get(n),a=o.get(r.bodyId)??p.get(n);if(s){u.delete(n),y.delete(s.bodyId),T+=1,R+=s.remaining,N();const o={...O(s),abandonedAt:S,remainingWork:s.remaining,queueSeconds:Math.max(0,S-s.queuedAt)};a&&e.onAbandoned?.(a,o),i.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:r.bodyId,datum:a?.datum,x:a?.x,y:a?.y,regionId:t,work:s.total,remainingWork:s.remaining,jobId:n,visitId:s.visitId,visit:s.visit,queuedAt:s.queuedAt,abandonedAt:S,queueSeconds:o.queueSeconds,queueDepth:u.size})}d.delete(n),g.delete(r.bodyId),h.delete(n),p.delete(n)}for(const[n,r]of Y){if(h.has(n))continue;const o=(f.get(n)??0)+1;f.set(n,o);const a=Yu(r,e.unitAccessor),c={bodyId:r.id,jobId:n,visitId:`${t}:${n}:${o}`,visit:o,regionId:t,work:a,queuedAt:S};h.set(n,c),M+=1,D.arrivals+=1,D.arrivalWork+=a;const l=x++;if(s>u.size)W(r,c,i,l);else{const s={...c,blockedAt:S,sequence:l};d.set(n,s),g.set(r.id,n),I+=1,N(),e.onBlocked?.(r,s),i.controls.recordObservation({type:"physics-capacity-blocked",bodyId:r.id,datum:r.datum,x:r.x,y:r.y,regionId:t,work:a,jobId:n,visitId:c.visitId,visit:o,queuedAt:S,blockedAt:S,queueDepth:u.size,blockedDepth:d.size})}}q(i),H();const X=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);let G=n*_;for(const n of X){if(0>=G)break;const r=Math.min(n.remaining,G);if(n.remaining-=r,G-=r,j+=r,D.processedWork+=r,n.remaining>1e-6)continue;u.delete(n.jobId),y.delete(n.bodyId),k+=1,C+=n.total,D.completions+=1,D.completedWork+=n.total;const s=Math.max(0,S-n.queuedAt);E+=s,N();const a=o.get(n.bodyId);if(!a)continue;i.controls.applyImpulse(n.bodyId,l.x??0,l.y??0);const c={...O(n),completedAt:S,queueSeconds:s};e.onProcessed?.(a,c),i.controls.recordObservation({type:"physics-capacity-processed",bodyId:n.bodyId,datum:a.datum,x:a.x,y:a.y,regionId:t,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,completedAt:S,queueSeconds:s,queueDepth:u.size})}q(i),H(),function(){const e=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);b=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(d.values()).sort((e,t)=>e.sequence-t.sequence);v=new Map(t.map((e,t)=>[e.bodyId,t])),w=e.length}(),function(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&m.push(e);const t=S-a;for(;m.length>0&&t>m[0].end;)m.shift()}(D);const V=Math.floor(S/c);V!==z&&(z=V,N())},getSnapshot:()=>{const e=Y(),i=function(){let e=0;for(const t of d.values())e+=t.work;return e}(),r=u.size,o=Array.from(u.values()).map(e=>Math.max(0,S-e.queuedAt)).sort((e,t)=>e-t),s=o.reduce((e,t)=>e+t,0);return{regionId:t,queueDepth:r,processedCount:k,unitsPerSecond:n,remainingWork:e,meanRemainingWork:r>0?e/r:0,waitingWork:e+i,blockedDepth:d.size,blockedWork:i,arrivalCount:M,admittedCount:P,admittedWork:_,processedWork:j,completedWork:C,blockedCount:I,abandonedCount:T,abandonedWork:R,peakQueueDepth:L,peakRemainingWork:$,queueAge:{count:o.length,meanSeconds:o.length>0?s/o.length:0,p50Seconds:Xu(o,.5),p95Seconds:Xu(o,.95),oldestSeconds:o.at(-1)??0},meanCompletedQueueSeconds:k>0?E/k:0,window:X(),simulatedAt:S,metricRevision:D}},bodyForce:e=>{if("none"===i)return null;const n=y.get(e.body.id),s=g.get(e.body.id),a=n?u.get(n):void 0,c=s?d.get(s):void 0;if(!a&&!c)return null;const l=a?b.get(e.body.id):v.get(e.body.id);if(null==l)return null;let h;const f=e.regions;if(f)for(let e=0;f.length>e;e+=1)if(f[e].id===t){const t=f[e].shape;t&&"aabb"===t.type&&(h=t);break}return h?{x:((c?h.x-.44*h.width:h.x-.22*h.width-l*(.15*r))-e.body.x)*o,y:(h.y-(l-((c?d.size:w)-1)/2)*r/Math.max(1,Math.sqrt(c?d.size:w))-e.body.y)*o*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function Ku(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}var Zu=require("react");function Qu(){return"undefined"==typeof document||!document.hidden}function Ju(e,t,n){const i=n.fill??"#4e79a7",r=n.stroke,o=n.strokeWidth??0,s=n.opacity??1,a=n.fillOpacity??1,c=function(e,t){const n=t.mark;if(n)return n;const i=e.datum,r=i?.__physicsMark??i?.mark;return"circle"===r||"halo"===r||"faceted"===r||"pill"===r||"diamond"===r||"square"===r?r:"circle"===e.shape.type?"circle":"square"}(t,n),l="circle"===t.shape.type?n.r??t.shape.radius:Math.max(t.shape.width,t.shape.height)/2;if(e.save(),e.globalAlpha*=s,e.beginPath(),"pill"===c||"square"===c||"aabb"===t.shape.type){const n="pill"===c?2.4*l:"aabb"===t.shape.type?t.shape.width:1.7*l,i="pill"===c?1.35*l:"aabb"===t.shape.type?t.shape.height:1.7*l,r=t.x-n/2,o=t.y-i/2,s="pill"===c?i/2:Math.min(4,n/4);e.moveTo(r+s,o),e.arcTo(r+n,o,r+n,o+i,s),e.arcTo(r+n,o+i,r,o+i,s),e.arcTo(r,o+i,r,o,s),e.arcTo(r,o,r+n,o,s),e.closePath()}else if("diamond"===c)e.moveTo(t.x,t.y-l),e.lineTo(t.x+l,t.y),e.lineTo(t.x,t.y+l),e.lineTo(t.x-l,t.y),e.closePath();else if("faceted"===c){const n=6;for(let i=0;n>i;i+=1){const r=2*Math.PI*i/n-Math.PI/2,o=t.x+Math.cos(r)*l,s=t.y+Math.sin(r)*l;0===i?e.moveTo(o,s):e.lineTo(o,s)}e.closePath()}else e.arc(t.x,t.y,l,0,2*Math.PI);i&&(e.save(),e.globalAlpha*=a,e.fillStyle=i,e.fill(),e.restore()),"halo"===c&&(e.beginPath(),e.arc(t.x,t.y,1.35*l,0,2*Math.PI),e.strokeStyle=r??i,e.lineWidth=Math.max(1.5,o||1.5),e.globalAlpha*=.55,e.stroke(),e.globalAlpha/=.55),r&&o>0&&(e.strokeStyle=r,e.lineWidth=o,n.strokeDasharray&&e.setLineDash(n.strokeDasharray.split(/[,\s]+/).map(e=>Number(e)).filter(e=>Number.isFinite(e))),e.stroke()),e.restore()}function ed(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function td(e){return e.sensorId??"stream-region-"+e.id}function nd(e){const t=td(e),n={bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution};if("boundary"===e.collider&&"aabb"===e.shape.type){const i=e.colliderThickness??8,r=e.shape.x-e.shape.width/2,o=e.shape.x+e.shape.width/2,s=e.shape.y-e.shape.height/2,a=e.shape.y+e.shape.height/2;return[{...n,id:t+"-top",shape:{type:"segment",x1:r,y1:s,x2:o,y2:s,thickness:i}},{...n,id:t+"-right",shape:{type:"segment",x1:o,y1:s,x2:o,y2:a,thickness:i}},{...n,id:t+"-bottom",shape:{type:"segment",x1:o,y1:a,x2:r,y2:a,thickness:i}},{...n,id:t+"-left",shape:{type:"segment",x1:r,y1:a,x2:r,y2:s,thickness:i}}]}return e.collider?[{...n,id:t+"-collider",shape:e.shape}]:[]}function id(e){if(e)return{activeRegionIds:Array.from(e.activeRegionIds),regionIds:Array.from(e.regionIds),charges:{...e.charges},attributes:{...e.attributes},energy:e.energy}}function rd(e,t){const n="function"==typeof e?e(t):e;if(!n)return null;const i=Number(n.x??0),r=Number(n.y??0);return Number.isFinite(i)||Number.isFinite(r)?{x:Number.isFinite(i)?i:0,y:Number.isFinite(r)?r:0}:null}function od(e){if(!1===e.semanticItem)return null;const t=e.shape,n=e.semanticItem??{},i="aabb"===t.type?{id:e.id,label:e.label??e.id,description:e.description,group:e.kind??"region",x:t.x,y:t.y,width:t.width,height:t.height}:{id:e.id,label:e.label??e.id,description:e.description,group:e.kind??"region",x:(t.x1+t.x2)/2,y:(t.y1+t.y2)/2,pathData:`M ${t.x1} ${t.y1} L ${t.x2} ${t.y2}`};return{...i,...n,id:n.id??i.id}}function sd(e){return e.some(e=>null!=e.force||null!=e.damping||null!=e.impulseOnEnter||null!=e.impulseOnExit)}function ad(e,t){const n="function"==typeof e?e(t):e;if(!n)return null;const i=Number(n.x??0),r=Number(n.y??0);return Number.isFinite(i)||Number.isFinite(r)?{x:Number.isFinite(i)?i:0,y:Number.isFinite(r)?r:0}:null}var cd=[];function ld(e){const t=e.store.controls(),n=e.store.snapshot(),i=Math.max(0,e.result.steps*(n.config.fixedDt||1/60)),r=function(e,t,n,i){const r=Number.isFinite(i)?Math.max(0,i):0;if(0>=r||!sd(t))return!1;const o=new Map(t.map(e=>[e.id,e])),s=e.readBodies();let a=!1;for(const t of s){const i=n.get(t.id);if(!i||!i.activeRegionIds.size)continue;const s=id(i);if(s)for(const n of i.activeRegionIds){const i=o.get(n);if(!i)continue;const c=rd(i.force,{body:t,region:i,regionState:s}),l=Number(i.damping??0),u=(c?.x??0)*r-(Number.isFinite(l)?t.vx*l*r:0),d=(c?.y??0)*r-(Number.isFinite(l)?t.vy*l*r:0);(u||d)&&(e.applyImpulse(t.id,u,d),a=!0)}}return a}(t,e.regionEffects,e.regionState,i),o=function(e,t,n,i,r,o){const s=Number.isFinite(o)?Math.max(0,o):0;if(0>=s||!t)return!1;const a=new Map(n.map(e=>[e.id,e])),c=e.readBodies();let l=!1;for(let n=0;c.length>n;n+=1){const o=c[n],u=i.get(o.id),d=id(u);let h=cd;if(u&&u.activeRegionIds.size>0){const e=[];for(const t of u.activeRegionIds){const n=a.get(t);n&&e.push(n)}h=e}const f=ad(t,{body:o,bodies:c,index:n,regionState:d,regions:h,simulationState:r});if(!f)continue;const p=(f.x??0)*s,y=(f.y??0)*s;(p||y)&&(e.applyImpulse(o.id,p,y),l=!0)}return l}(t,e.bodyForces,e.regionEffects,e.regionState,n.simulationState,i);return e.composed&&e.composed.onTick(e.result,t,{dt:i,elapsed:e.result.elapsedSeconds,getRegionState:t=>id(e.regionState.get(t))}),e.onTick?.(e.result,t),{regionEffectsApplied:r,bodyForcesApplied:o,snapshot:n}}function ud(e,t,n,i,r,o,s,a,c,l){const u=function(e,t){return!!t?.isActive&&(t.predicate?.(e)??!0)}(e,r),d={selected:u,simulationState:t,regionState:o,regions:s},h="function"==typeof n?n(e,d):n,f=s.reduce((t,n)=>n.bodyStyle?{...t,..."function"==typeof n.bodyStyle?n.bodyStyle(e,d):n.bodyStyle}:t,{}),p=u?"function"==typeof i?i(e,d):i:void 0;return{fill:l?.color??a,stroke:l?.stroke??c,strokeWidth:l?.strokeWidth??1,opacity:l?.opacity??.9,...h,...f,...p}}var dd=c(require("react")),hd=require("react/jsx-runtime"),fd={border:0,clip:"rect(0 0 0 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1},pd="semiotic-accessible-data-table",yd=pd+" semiotic-accessible-data-table-hidden",gd=pd+" semiotic-accessible-data-table-visible",md={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},xd={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},bd={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},vd={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},wd={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},kd={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Sd={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Ad={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Md(e){return null==e?null:"string"==typeof e||"number"==typeof e||"boolean"==typeof e?e+"":null}function Pd(e){return{__semioticHoverData:!0,body:e,data:e.datum??e,id:e.id,type:"body",x:e.x,y:e.y}}function _d(e){if("circle"===e.shape.type){const t=Math.max(4,2*e.shape.radius);return{height:t,shape:"circle",width:t}}return{height:e.shape.height,shape:"rect",width:e.shape.width}}function jd(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e+""}return e.id}function Cd(e){const t=Id(e.datum??e);return t.length?t.map(([e,t])=>`${e}: ${t}`).join(", "):"Physics body "+e.id}function Id(e){return e&&"object"==typeof e?Object.entries(e).map(([e,t])=>{if(e.startsWith("_"))return null;const n=Md(t);return null==n?null:[e,n]}).filter(e=>null!=e).slice(0,8):[]}function Td({hover:e}){const t=Id(e.data);return(0,hd.jsxs)("div",{className:"semiotic-tooltip",style:V,children:[(0,hd.jsx)("div",{style:{fontWeight:700,marginBottom:t.length?4:0},children:e.id}),t.map(([e,t])=>(0,hd.jsxs)("div",{children:[(0,hd.jsxs)("span",{style:{opacity:.72},children:[e,": "]}),(0,hd.jsx)("span",{children:t})]},e))]})}function Rd(e){return e.datum&&"object"==typeof e.datum?Object.entries(e.datum).map(([e,t])=>{const n=Md(t);return null==n?null:`${e}: ${n}`}).filter(e=>null!=e).slice(0,8).join(", "):""}function Ld(e){const t=[`${e.length} semantic item${1===e.length?"":"s"}.`],n=new Map;for(const t of e)t.group&&n.set(t.group,(n.get(t.group)??0)+1);return n.size&&t.push(Array.from(n).map(([e,t])=>`${e}: ${t}`).join(", ")),t.join(" ")}function $d(e){const{chartTitle:t,items:n,tableId:i}=e,[r,o]=dd.useState(!1),[s,a]=dd.useState(5),c=_o(),l=c?.visible??!1,u=r||l,d=dd.useRef(null),h="Data summary for "+(t??"physics chart");dd.useEffect(()=>{u||a(5)},[u]);const f=dd.useCallback(e=>{e.target===e.currentTarget&&(r||l||o(!0))},[r,l]),p=dd.useCallback(e=>{l||d.current?.contains(e.relatedTarget)||o(!1)},[l]);if(!n.length)return(0,hd.jsx)("span",{id:i,tabIndex:-1,style:fd});if(!u)return(0,hd.jsx)("div",{id:i,className:yd,role:"region","aria-label":h,tabIndex:-1,style:fd,onFocus:f,children:(0,hd.jsxs)("button",{type:"button",onClick:()=>o(!0),children:["View data summary (",n.length," semantic items)"]})});const y=Math.min(s,n.length),g=n.slice(0,y),m=n.length-y;return(0,hd.jsxs)("div",{ref:d,id:i,className:gd,role:"region","aria-label":h,tabIndex:-1,onBlur:p,style:md,children:[(0,hd.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close","aria-label":"Close data summary",onClick:()=>{l&&c&&c.setVisible(!1),o(!1)},style:bd,children:"×"}),(0,hd.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:xd,children:Ld(n)}),(0,hd.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Semantic items for "+(t??"physics chart"),style:vd,children:[(0,hd.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Sd,children:m>0?`First ${y} of ${n.length} semantic items`:`All ${n.length} semantic items`}),(0,hd.jsx)("thead",{children:(0,hd.jsxs)("tr",{children:[(0,hd.jsx)("th",{scope:"col",style:wd,children:"Item"}),(0,hd.jsx)("th",{scope:"col",style:wd,children:"Description"}),(0,hd.jsx)("th",{scope:"col",style:wd,children:"Group"}),(0,hd.jsx)("th",{scope:"col",style:wd,children:"Position"}),(0,hd.jsx)("th",{scope:"col",style:wd,children:"Data"})]})}),(0,hd.jsx)("tbody",{children:g.map((e,t)=>(0,hd.jsxs)("tr",{children:[(0,hd.jsx)("th",{scope:"row",style:kd,children:e.label}),(0,hd.jsx)("td",{style:kd,children:e.description??e.label}),(0,hd.jsx)("td",{style:kd,children:e.group??""}),(0,hd.jsxs)("td",{style:kd,children:[Math.round(e.x),", ",Math.round(e.y)]}),(0,hd.jsx)("td",{style:kd,children:Rd(e)})]},e.id??`${e.label}-${t}`))})]}),m>0?(0,hd.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Ad,children:["Show ",Math.min(25,m)," more"," ",1===m?"row":"rows"," (",m," remaining)"]}):null]})}Td.ownsChrome=!0;var Ed=require("react/jsx-runtime"),Dd=[640,360],zd={top:0,right:0,bottom:0,left:0},Bd=new Set(["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function Fd(e,t,n){const i=new Fl(e);return t?.length&&i.enqueue(t,n),i}var Nd="StreamPhysicsFrame";function Od(){return"undefined"!=typeof performance?performance.now():Date.now()}var Wd=(0,su.memo)((0,su.forwardRef)(function(e,t){const{accessibleTable:n=!0,annotations:i,autoPlaceAnnotations:r,background:o,backgroundGraphics:s,bodySemanticItemLimit:a=200,bodySemanticItems:c=!1,bodySemanticUpdateMs:l=200,bodyForces:u,bodyStyle:d,chartId:h,className:f,frameScheduler:p,clock:y,color:g,config:m,controllers:x,continuous:b=!1,description:v,emphasis:w,chartMode:k,enableHover:S=!0,foregroundGraphics:A,hoverRadius:M=16,initialSpawns:P,initialSpawnPacing:_,legend:j,legendClickBehavior:C,legendHighlightedCategory:I,legendHoverBehavior:T,legendIsolatedCategories:R,legendLayout:L,legendPosition:$,margin:E,onClick:D,onObservation:z,onRegionEvent:B,onSimulationExecutionChange:F,onBodyHover:N,onBodyPointerDown:O,onSemanticItemActivate:W,onSemanticItemFocus:q,onTick:Y,opacity:H,paused:X=!1,regionEffects:G=[],responsiveHeight:V,responsiveWidth:U,selectedBodyStyle:K={stroke:"#111827",strokeWidth:2,opacity:1},selection:Z,semanticItems:Q=[],simulationExecution:J="auto",size:ee=Dd,stroke:te,strokeWidth:ne,summary:ie,suspendWhenHidden:re=!0,svgAnnotationRules:oe,title:se,tooltipContent:ae,workerBodyThreshold:ce=Pu,renderBody:le,beforePaint:ue,afterPaint:de}=e,he=ou.useMemo(()=>({color:g,stroke:te,strokeWidth:ne,opacity:H}),[g,H,te,ne]),fe=(0,su.useRef)(z);fe.current=z;const pe=(0,su.useRef)(h);pe.current=h;const ye=(0,su.useRef)(new Map),ge=(0,su.useRef)(G);ge.current=G;const me=(0,su.useRef)(u);me.current=u;const xe=(0,su.useRef)(Y);xe.current=Y;const be=ou.useMemo(()=>function(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,i)=>{const r={result:e,controls:n,dt:i.dt,elapsed:i.elapsed,getRegionState:i.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const i of t)i.bodyForce&&(n=Ku(n,i.bodyForce(e)));return n}}}(x),[x]),ve=(0,su.useRef)(be);ve.current=be;const we=b||!!be?.continuous,ke=(0,su.useRef)(we);ke.current=we;const Se=ou.useMemo(()=>{if(!u&&!be?.bodyForce)return u;if(!be?.bodyForce)return u;if(!u)return be.bodyForce;const e=be.bodyForce;return t=>{const n="function"==typeof u?u(t):u,i="function"==typeof e?e(t):e;return n||i?{x:(n?.x??0)+(i?.x??0),y:(n?.y??0)+(i?.y??0)}:null}},[u,be]);me.current=Se;const Ae=ou.useMemo(()=>new Map(G.map(e=>[td(e),e])),[G]),Me=ou.useMemo(()=>new Map(G.map(e=>[e.id,e])),[G]),Pe=ou.useMemo(()=>G.map(od).filter(e=>null!=e),[G]),[_e,je]=ou.useState([]),Ce=ou.useMemo(()=>_e.length||Pe.length?[...Q,..._e,...Pe]:Q,[_e,Pe,Q]),Ie=ou.useMemo(()=>sd(G),[G]),Te=!!Se,Re=(0,su.useRef)(null),Le=(0,su.useRef)(y??Od);Le.current=y??Od;const $e=(0,su.useCallback)((e,t,n)=>{const i=Re.current;if(!i||!n)return!1;const r=i.readBodies().find(t=>t.id===e),o=id(ye.current.get(e));if(!r||!o)return!1;const s=rd(n,{body:r,region:t,regionState:o});return!(!s||!s.x&&!s.y||(i.applyImpulse(e,s.x??0,s.y??0),0))},[]),Ee=(0,su.useCallback)((e,t,n)=>{if(!n.bodyId)return;const i=id(ye.current.get(n.bodyId));if(!i)return;const r={bodyId:n.bodyId,datum:n.datum,observation:n,region:t,regionState:i,type:e};"region-enter"===e?t.onEnter?.(r):t.onExit?.(r),B?.(r)},[B]),De=(0,su.useCallback)(e=>{const t=e.sensorId?Ae.get(e.sensorId):void 0;if(!t||!e.bodyId)return;const n=function(e,t){let n=e.get(t);return n||(n={activeRegionIds:new Set,attributes:{},charges:{},energy:0,regionIds:new Set},e.set(t,n)),n}(ye.current,e.bodyId),i=Re.current?.readBodies().find(t=>t.id===e.bodyId),r=id(n),o=i&&r?{body:i,region:t,regionState:r}:null;if("physics-proximity-enter"===e.type){if(n.activeRegionIds.add(t.id),n.regionIds.add(t.id),n.energy+=t.energyDelta??0,o){!function(e,t,n){const i="function"==typeof e.attributes?e.attributes(t):e.attributes;i&&(n.attributes={...n.attributes,...i})}(t,o,n);const e=function(e,t){return void 0!==e.charge?"function"==typeof e.charge?e.charge(t):e.charge:"charge-gate"===e.kind?1:void 0}(t,o);void 0!==e&&(n.charges[t.id]=e)}$e(e.bodyId,t,t.impulseOnEnter),Ee("region-enter",t,e)}else"physics-proximity-exit"===e.type&&(n.activeRegionIds.delete(t.id),$e(e.bodyId,t,t.impulseOnExit),Ee("region-exit",t,e))},[$e,Ee,Ae]),ze=ou.useMemo(()=>{if(!i?.length)return[];const e=i.filter(e=>"barrier"===e.physics||"sensor"===e.physics);return e.length?function(e=[],t={}){const n=t.idPrefix?t.idPrefix+"-":"",i=[];for(const r of e){if("barrier"!==r.physics&&"sensor"!==r.physics)continue;const e=r.axis??t.defaultAxis??"x",o=Mu(r,t),s=r.colliderId??`${n}${r.id}`;let a;if("x"===e){const e=Au(r.x),n=Au(r.y1)??Au(t.plotBounds?.y)??Au(r.y),i=Au(r.y2)??(t.plotBounds?t.plotBounds.y+t.plotBounds.height:void 0)??Au(r.y);if(null==e||null==n||null==i)continue;a={type:"segment",x1:e,y1:n,x2:e,y2:i,thickness:o}}else{const e=Au(r.y),n=Au(r.x1)??Au(t.plotBounds?.x)??Au(r.x),i=Au(r.x2)??(t.plotBounds?t.plotBounds.x+t.plotBounds.width:void 0)??Au(r.x);if(null==e||null==n||null==i)continue;a={type:"segment",x1:n,y1:e,x2:i,y2:e,thickness:o}}i.push({id:s,shape:a,sensor:"sensor"===r.physics,..."barrier"!==r.physics||null==r.restitution&&null==t.barrierRestitution?{}:{restitution:Au(r.restitution)??Au(t.barrierRestitution)},..."barrier"!==r.physics||null==r.friction&&null==t.barrierFriction?{}:{friction:Au(r.friction)??Au(t.barrierFriction)}})}return i}(e,{idPrefix:h?h+"-ann":"physics-ann",plotBounds:{x:0,y:0,width:ee?.[0]??Dd[0],height:ee?.[1]??Dd[1]}}):[]},[i,h,ee]),Be=ou.useMemo(()=>{const e=G.flatMap(e=>[{id:td(e),sensor:!0,shape:e.shape,bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution},...nd(e)]),t=Object.fromEntries(G.map(e=>[td(e),{binId:e.binId??e.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),n=m?.observation,i=G.length>0;return i||e.length>0||ze.length>0||null!=h||n?{...m,colliders:[...m?.colliders??[],...e,...ze],observation:{...n,chartId:h??n?.chartId,chartType:n?.chartType??Nd,sensors:{...n?.sensors??{},...t},onObservation:e=>{i&&De(e),n?.onObservation?.(e)}}}:m},[ze,h,m,De,G]);if(!Re.current){const e=Fd(Be,P,_);e.setPaused(X),re&&e.setVisible(Qu()),Re.current=e}const Fe=(0,su.useRef)(null),Ne=(0,su.useRef)(-1),Oe=(0,su.useRef)(null),We=(0,su.useRef)(!0),qe=(0,su.useRef)(""),Ye=(0,su.useId)().replace(/:/g,""),He=(0,su.useRef)(!1),Xe=(0,su.useRef)(!1),Ge=(0,su.useRef)(0),Ve=(0,su.useRef)(!1),Ue=(0,su.useRef)(null),Ke=(0,su.useRef)(!1),Ze=ls({sizeProp:ee,responsiveWidth:U,responsiveHeight:V,userMargin:E,marginDefault:zd,foregroundGraphics:A,backgroundGraphics:s,frameScheduler:p}),{margin:Qe,rafRef:Je,reducedMotionRef:et,renderFnRef:tt,cancelRender:nt,resolvedBackground:it,resolvedForeground:rt,responsiveRef:ot,scheduleRender:st,size:at}=Ze,ct=ho(),lt=go(),[ut,dt]=ou.useState(null),[ht,ft]=ou.useState(null),pt=(0,su.useRef)(null),yt=(0,su.useRef)(0),gt=(0,su.useRef)(new Map),mt=Ye+"-physics-live",xt=(0,su.useCallback)((e,t,n=!1)=>{if(!c)return void je(e=>e.length?[]:e);const i=Le.current();if(!n&&l>0&&l>i-yt.current)return;yt.current=i;const r=function(e,t,n,i){if(!n)return[];const r=Math.max(0,Math.floor(i));if(!r)return[];const o=[];for(let i=0;e.length>i&&r>o.length;i+=1){const r=e[i],s="function"==typeof n?n(r,{index:i,simulationState:t}):void 0;if(!1===s)continue;const a=_d(r);o.push({datum:r.datum??r,description:Cd(r),group:"body",label:jd(r),...a,...s??{},bodyId:s?.bodyId??r.id,id:s?.id??"body:"+r.id,x:s?.x??r.x,y:s?.y??r.y})}return o}(e,t,c,a);je(e=>function(e,t){if(e.length!==t.length)return!0;for(let n=0;e.length>n;n+=1){const i=e[n],r=t[n];if(i.id!==r.id||i.label!==r.label||i.description!==r.description||i.group!==r.group||i.bodyId!==r.bodyId||Math.round(i.x)!==Math.round(r.x)||Math.round(i.y)!==Math.round(r.y))return!0}return!1}(e,r)?r:e)},[a,c,l]),bt=(0,su.useCallback)(e=>{if(!Ce.length)return;const t=Math.max(0,Math.min(e,Ce.length-1));Ne.current=t;const n=Ce[t];if(pt.current=n.bodyId??null,dt(n),q?.(n),n.bodyId&&Re.current){const e=Re.current.readBodies().find(e=>e.id===n.bodyId);if(e){const t=Pd(e);ft(t),N?.(e,t)}}},[Ce,N,q]),vt=(0,su.useCallback)(()=>{Ne.current=-1,pt.current=null,dt(null),q?.(null)},[q]),wt=(0,su.useCallback)((e,t)=>{const n=fe.current;if(!n)return;const i=Le.current();n("hover"!==e&&"click"!==e?{type:e,timestamp:i,chartType:Nd,chartId:pe.current}:{type:e,datum:t?.datum??{},x:t?.x??0,y:t?.y??0,timestamp:i,chartType:Nd,chartId:pe.current})},[]),kt=(0,su.useCallback)(()=>{ft(e=>e?(N?.(null,null),wt("hover-end"),null):e)},[wt,N]),St=(0,su.useCallback)(e=>{if(!S||!Re.current)return;const t=e.currentTarget.getBoundingClientRect(),n=Re.current.hitTest(e.clientX-t.left,e.clientY-t.top,M);if(!n)return void kt();const i=Pd(n);ft(e=>e&&e.id===i.id&&e.x===i.x&&e.y===i.y?e:(N?.(n,i),wt("hover",{datum:n.datum,x:n.x,y:n.y}),i))},[kt,wt,S,M,N]),At=(0,su.useCallback)(e=>{vt();const t=Re.current,n=e.currentTarget.getBoundingClientRect(),i=e.clientX-n.left,r=e.clientY-n.top,o=t?t.hitTest(i,r,Math.max(16,M)):null;O?.(o,e),o?(wt("click",{datum:o.datum,x:o.x,y:o.y}),D?.(o.datum??null,{x:o.x,y:o.y,body:o})):(wt("click-end"),D?.(null,{x:i,y:r,body:null}),kt())},[kt,vt,wt,M,O,D]);(0,su.useEffect)(()=>{if(!Ce.length)return void vt();const e=Ne.current;if(Ce.length>e){if(e>=0){const t=Ce[e];if(pt.current=t.bodyId??null,dt(e=>null!=e&&e.id===t.id&&Math.round(e.x)===Math.round(t.x)&&Math.round(e.y)===Math.round(t.y)?e:t),t.bodyId&&Re.current){const e=Re.current.readBodies().find(e=>e.id===t.bodyId);if(e){const t=Pd(e);ft(e=>e?.id===t.id&&Math.round(e.x)===Math.round(t.x)&&Math.round(e.y)===Math.round(t.y)?e:t)}}}}else bt(Ce.length-1)},[Ce,vt,bt]),(0,su.useEffect)(()=>{S||kt()},[kt,S]);const Mt=(0,su.useCallback)(e=>{if(!Ce.length)return;if("Escape"===e.key)return e.preventDefault(),void vt();if(("Enter"===e.key||" "===e.key)&&Ne.current>=0)return e.preventDefault(),void W?.(Ce[Ne.current]);if(!Bd.has(e.key))return;e.preventDefault();const t=Ne.current;if(0>t)return void bt(0);const n=Math.max(1,Math.floor(.1*Ce.length));let i=t;"Home"===e.key?i=0:"End"===e.key?i=Ce.length-1:"PageDown"===e.key?i=Math.min(Ce.length-1,t+n):"PageUp"===e.key?i=Math.max(0,t-n):"ArrowRight"===e.key||"ArrowDown"===e.key?i=Math.min(Ce.length-1,t+1):"ArrowLeft"!==e.key&&"ArrowUp"!==e.key||(i=Math.max(0,t-1)),bt(i)},[vt,bt,W,Ce]),[Pt,_t]=ou.useState([]),jt=(0,su.useRef)(0),Ct=!!i?.length&&i.some(e=>null!=e.pointId||null!=e.bodyId||"latest"===e.anchor),It=(0,su.useCallback)(()=>{const e=Fe.current,t=Re.current;if(!e||!t)return;const n=ds(),i=us(e,at,Qe,n);if(!i)return;const r=function(e){const t=mu(e,hu),n=mu(e,lu),i=mu(e,gu),r=mu(e,fu),o=mu(e,cu),s=mu(e,au),a=mu(e,pu),c=mu(e,yu),l=mu(e,uu),u=mu(e,du);return{annotationBackground:xu(s,.94),annotationStroke:o,annotationText:a,background:s,border:o,closedWindowFill:xu(n,.08),closedWindowStroke:xu(n,.55),danger:n,focus:l,grid:u,gutterFill:xu(c,.14),lateFill:i,openWindowFill:xu(t,.07),openWindowStroke:xu(t,.3),primary:t,selectedFill:i,selectedStroke:l,success:r,text:a,textSecondary:c,warning:i}}(i);i.clearRect(-Qe.left,-Qe.top,at[0],at[1]),s||"transparent"===o||(i.fillStyle=o??r.background,i.fillRect(-Qe.left,-Qe.top,at[0],at[1]));const a=t.snapshot(),c=t.readBodies();if(xt(c,a.simulationState),Ct){const e=Le.current();if(e-jt.current>=100){jt.current=e;const t=function(e){return e.map(e=>({pointId:e.id,x:e.x,y:e.y,r:Math.max(1,ku(e))}))}(c);_t(e=>e.length===t.length&&e.every((e,n)=>e.pointId===t[n].pointId&&Math.round(e.x)===Math.round(t[n].x)&&Math.round(e.y)===Math.round(t[n].y))?e:t)}}ue&&(i.save(),ue(i,c),i.restore());for(const e of c){const t=ye.current.get(e.id),n=t?Array.from(t.activeRegionIds).map(e=>Me.get(e)).filter(e=>null!=e):[],o=ud(e,a.simulationState,d,K,Z,id(t),n,r.primary,r.text,he);le?(i.save(),le(i,e,o),i.restore()):Ju(i,e,o)}de&&(i.save(),de(i,c),i.restore()),function(e,t,n){let i=!1;for(const[r,o]of t){const s=Math.min(1,Math.max(0,(n-o.startedAt)/o.durationMs));if(s>=1){t.delete(r);continue}i=!0;const a=1-Math.pow(1-s,3),{body:c}=o,l=o.radius+28*a,u=1-s;e.save(),e.globalAlpha*=u,e.strokeStyle=o.color,e.fillStyle=o.color,e.lineWidth=2.4*u+.4,e.beginPath(),e.arc(c.x,c.y,l,0,2*Math.PI),e.stroke(),e.globalAlpha*=.18,e.beginPath(),e.arc(c.x,c.y,.52*l,0,2*Math.PI),e.fill(),e.restore(),e.save(),e.globalAlpha*=u,e.strokeStyle=o.color,e.lineWidth=1.8;for(let t=0;8>t;t+=1){const n=t*(Math.PI/4)+1.4*s,i=o.radius+5+12*a,r=o.radius+12+34*a;e.beginPath(),e.moveTo(c.x+Math.cos(n)*i,c.y+Math.sin(n)*i),e.lineTo(c.x+Math.cos(n)*r,c.y+Math.sin(n)*r),e.stroke()}e.restore()}}(i,gt.current,Le.current()),We.current=!1},[de,o,s,ue,d,Qe,Ct,Me,le,K,Z,he,xt,at]),Tt=(0,su.useCallback)((e,t)=>{const n=Re.current,i=`${J}:${e}:${t??""}`;qe.current!==i&&(qe.current=i,F?.({execution:e,liveBodies:n?.liveBodyCount()??0,queuedBodies:n?.queueSize()??0,reason:t,requested:J}))},[F,J]),Rt=(0,su.useCallback)((e,t=!0)=>{Ge.current+=1,He.current=!1,Ve.current=!1,Ke.current=!1,Ue.current?.terminate(),Ue.current=null,t&&Tt("sync",e)},[Tt]),Lt=(0,su.useCallback)(()=>ct?"undefined"==typeof window||"undefined"==typeof Worker?"worker unavailable":Ie?"runtime region effects require sync":Te?"body forces require sync":be?"physics controllers require sync":function(e){return!e||!e.engine&&ju(e.sediment)&&(!(t=e.colliders)||t.every(e=>{const t=e.bodyFilter;return!t||"function"!=typeof t}));var t}(Be??{})?Tu(_)?Xe.current?"worker fallback":null:"spawn pacing is not worker-cloneable":"config is not worker-cloneable":"hydrating",[Be,be,Te,Ie,ct,_]),$t=(0,su.useCallback)(()=>{const e=Re.current,t=Lt();if(!e||t)return{reason:t,useWorker:!1};const n=e.liveBodyCount(),i=e.queueSize(),r=function(e,t,n=0,i=Pu){return"sync"!==e&&("worker"===e||t+n>=i)}(J,n,i,ce);return{reason:r?"worker"===J?"forced worker":"body threshold":"below threshold",useWorker:r}},[J,ce,Lt]),Et=(0,su.useCallback)(e=>{const t=Re.current;return t&&e.snapshot?(t.restore(e.snapshot),We.current=!0,t):t},[]),Dt=(0,su.useCallback)((e,t=!0)=>{const n=Et(e);if(!n)return;t&&Y?.(e.result,n.controls()),It();const i=n.snapshot();!e.result.shouldContinue&&gt.current.size<=0||i.paused||!i.visible||et.current||st()},[Et,Y,It,et,st]),zt=(0,su.useCallback)(e=>{Xe.current=!0,Rt("worker failed: "+((e instanceof Error?e.message:e+"")||"unknown error"))},[Rt]),Bt=(0,su.useCallback)(()=>{const e=Re.current;if(!e)return!1;const t=$t();if(!t.useWorker)return He.current||Ke.current?Rt(t.reason??"sync fallback"):Tt("sync",t.reason??"sync"),!1;if(He.current||Ke.current)return!0;const n=Ue.current??new Eu;Ue.current=n,Ke.current=!0;const i=Ge.current+1;return Ge.current=i,n.initFromSnapshot(Be??{},e.snapshot()).then(e=>{if(Ge.current!==i)return;Ke.current=!1,He.current=!0,Xe.current=!1,Et(e),Tt("worker",t.reason??"worker"),It();const n=Re.current?.snapshot();e.result.shouldContinue&&n&&!n.paused&&n.visible&&!et.current&&(Oe.current=null,st())}).catch(e=>{Ge.current===i&&zt(e)}),!0},[Et,Be,zt,It,et,Tt,st,Rt,$t]),Ft=(0,su.useCallback)(e=>"frame"===e.type||"removed"===e.type?e.frame:null,[]),Nt=(0,su.useCallback)((e,t=!0)=>{const n=Ue.current;if(!n||!He.current)return;const i=Ge.current;n.request(e).then(e=>{if(Ge.current!==i)return;const n=Ft(e);n&&Dt(n,t)}).catch(zt)},[Dt,Ft,zt]),Ot=(0,su.useCallback)(()=>{const e=Re.current;if(!e)return;const t=Bt(),n=e.snapshot(),i=we||Te||Ie||!!be;n.paused||!n.visible||!e.hasPendingWork()&&!i||et.current?tt.current():t&&Ke.current||(Oe.current=null,st())},[be,we,Te,Ie,et,tt,st,Bt]),Wt=(0,su.useCallback)(()=>{nt(),Je.current=null;const e=Re.current;if(!e)return;if(He.current&&Ue.current){if(Ve.current)return;let t=0;if(!et.current){const e=Le.current();t=null!==Oe.current?(e-Oe.current)/1e3:0,Oe.current=e}const n=Ue.current,i=Ge.current;return Ve.current=!0,void(et.current?n.settle():n.tick(t)).then(e=>{Ve.current=!1,Ge.current===i&&Dt(e)}).catch(n=>{if(Ve.current=!1,Ge.current!==i)return;zt(n);const r=et.current?e.settleWithObservations():e.tick(t);ld({store:e,result:r,regionEffects:ge.current,regionState:ye.current,bodyForces:me.current,composed:ve.current,onTick:xe.current}),It()})}let t;if(et.current)t=e.settleWithObservations();else{const n=Le.current(),i=null!==Oe.current?(n-Oe.current)/1e3:0;Oe.current=n,t=e.tick(i)}const n=ve.current,{regionEffectsApplied:i,bodyForcesApplied:r,snapshot:o}=ld({store:e,result:t,regionEffects:ge.current,regionState:ye.current,bodyForces:me.current,composed:n,onTick:xe.current});It(),(ke.current||t.shouldContinue||i||r||n||gt.current.size>0)&&!o.paused&&o.visible&&!et.current&&st()},[Dt,zt,It,nt,st,et,Je]);tt.current=Wt,mo({hydrated:ct,wasHydratingFromSSR:lt,storeRef:Re,dirtyRef:We,renderFnRef:tt,cancelRender:nt}),(0,su.useEffect)(()=>{Xe.current=!1,(He.current||Ke.current)&&Rt("config changed",!1),Re.current?.updateConfig(Be??{}),Ot()},[Be,Rt]),(0,su.useEffect)(()=>{Xe.current=!1,Ot()},[ct,J,ce]),function({cancelRender:e,lastFrameTimeRef:t,paused:n,postWorkerCommand:i,requestRender:r,storeRef:o,suspendWhenHidden:s}){const a=(0,Zu.useRef)(i);a.current=i;const c=(0,Zu.useRef)(r);c.current=r,(0,Zu.useEffect)(()=>{const i=o.current;i&&(i.setPaused(n),n&&(t.current=null,e()),a.current({type:"setPaused",paused:n},!1),c.current())},[e,n]),(0,Zu.useEffect)(()=>{if(!s||"undefined"==typeof document)return;const n=()=>{const n=o.current;if(!n)return;const i=Qu();n.setVisible(i),i||(t.current=null,e()),a.current({type:"setVisible",visible:i},!1),c.current()};return n(),document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[e,s])}({cancelRender:nt,lastFrameTimeRef:Oe,paused:X,postWorkerCommand:Nt,requestRender:Ot,storeRef:Re,suspendWhenHidden:re}),(0,su.useEffect)(()=>()=>Rt("unmount",!1),[Rt]),(0,su.useEffect)(()=>{It()},[It]),(0,su.useImperativeHandle)(t,()=>({...Re.current.controls(),applyImpulse:(e,t,n)=>{Re.current.applyImpulse(e,t,n),Nt({type:"applyImpulse",id:e,ix:t,iy:n}),Ot()},clear:()=>{Re.current.clear(),ye.current.clear(),gt.current.clear(),Nt({type:"clear"}),Ot()},clearRegionState:e=>{e?ye.current.delete(e):ye.current.clear(),Ot()},getData:()=>Re.current.readBodies(),getRegionState:e=>e?id(ye.current.get(e)):function(e){const t={};return e.forEach((e,n)=>{const i=id(e);i&&(t[n]=i)}),t}(ye.current),getStore:()=>Re.current,pause:()=>{Re.current.setPaused(!0),Nt({type:"setPaused",paused:!0},!1),Ot()},push:(e,t)=>{Re.current.enqueue(e,t),Tu(t)?Nt({type:"enqueue",spawns:[e],pacing:t}):(He.current||Ke.current)&&Rt("spawn pacing is not worker-cloneable"),Ot()},pushMany:(e,t)=>{Re.current.enqueue(e,t),Tu(t)?Nt({type:"enqueue",spawns:e,pacing:t}):(He.current||Ke.current)&&Rt("spawn pacing is not worker-cloneable"),Ot()},popBodies:(e,t={})=>{const n=Re.current,i=new Map(n.readBodies().map(e=>[e.id,e])),r=n.remove(e),o=Le.current();for(const e of r){const n=i.get(e);n&&(ye.current.delete(e),gt.current.set(e,{body:n,color:t.color??"#f59e0b",durationMs:Math.max(120,t.durationMs??520),radius:t.radius??ed(n),startedAt:o}),pt.current===e&&(pt.current=null,dt(null)),ft(t=>t?.id===e?null:t))}return r.length&&(Nt({type:"remove",ids:r}),Ot()),r},remove:e=>{const t=Re.current.remove(e);for(const t of e)ye.current.delete(t);return Nt({type:"remove",ids:e}),Ot(),t},restore:e=>{Re.current.restore(e),ye.current.clear(),gt.current.clear(),Nt({type:"restore",snapshot:e},!1),Ot()},resume:()=>{Re.current.setPaused(!1),Nt({type:"setPaused",paused:!1},!1),Ot()},settle:e=>{const t=Re.current.settle(e);return Nt({type:"settle",maxSteps:e}),Ot(),t},settleWithObservations:e=>{const t=Re.current.settleWithObservations(e);return Nt({type:"settle",maxSteps:e}),Ot(),t},step:e=>{const t=Re.current,n=t.tick(e);return ld({store:t,result:n,regionEffects:ge.current,regionState:ye.current,bodyForces:me.current,composed:ve.current,onTick:xe.current}),Nt({type:"tick",deltaSeconds:e}),It(),n}}),[It,Nt,Ot,Rt]);const qt=co||!ct&&lt,Yt=["stream-physics-frame",k?"stream-physics-frame--mode-"+k:null,w?"stream-physics-frame--emphasis-"+w:null,f].filter(Boolean).join(" "),Ht=v??("string"==typeof se?se:void 0)??"Physics chart",Xt=Ye+"-physics-table",Gt=Math.max(1,at[0]-Qe.left-Qe.right),Vt=Math.max(1,at[1]-Qe.top-Qe.bottom),Ut=S&&ht?ae?ae(ht):(0,Ed.jsx)(Td,{hover:ht}):null,Kt=Ut&&ht?(0,Ed.jsx)(ts,{x:ht.x-Qe.left,y:ht.y-Qe.top,containerWidth:Math.max(1,at[0]-Qe.left-Qe.right),containerHeight:Math.max(1,at[1]-Qe.top-Qe.bottom),margin:Qe,className:"stream-physics-tooltip",children:Ut}):null;if(qt){const e=Re.current??Fd(Be,P,_),t="string"==typeof se?se:void 0,{svg:n}=qu(e,{width:at[0],height:at[1],title:t,description:v,background:"transparent"===o?void 0:o,className:"stream-physics-frame__svg",idPrefix:"physics-"+Ye});return(0,Ed.jsxs)("div",{ref:ot,className:Yt,"data-semiotic-mode":k,role:"img","aria-label":Ht,style:{width:at[0],height:at[1]},children:[(0,Ed.jsx)(Go,{summary:ie}),(0,Ed.jsx)("div",{dangerouslySetInnerHTML:{__html:n}})]})}return(0,Ed.jsxs)("div",{ref:ot,className:Yt,"data-semiotic-mode":k,role:"group","aria-label":Ht,"aria-describedby":ut?mt:void 0,tabIndex:0,style:{position:"relative",width:at[0],height:at[1]},onKeyDown:Mt,children:[n?(0,Ed.jsx)(Vo,{tableId:Xt}):null,n?(0,Ed.jsx)($d,{chartTitle:"string"==typeof se?se:Ht,items:Ce,tableId:Xt}):null,(0,Ed.jsx)(Go,{summary:ie}),(0,Ed.jsx)(Uo,{hoverPoint:ht}),(0,Ed.jsx)("div",{id:mt,"aria-live":"polite","aria-atomic":"true",style:fd,children:ut?ut.description??ut.label:""}),(0,Ed.jsxs)("div",{role:"img","aria-label":Ht,style:{position:"relative",width:"100%",height:"100%"},children:[it,(0,Ed.jsx)("canvas",{ref:Fe,width:at[0],height:at[1],"aria-hidden":"true",onPointerDown:At,onPointerMove:S?St:void 0,onPointerLeave:S?kt:void 0}),rt,(0,Ed.jsx)(Su,{width:Gt,height:Vt,totalWidth:at[0],totalHeight:at[1],margin:Qe,title:se,legend:j,legendPosition:$,legendLayout:L,legendHoverBehavior:T,legendClickBehavior:C,legendHighlightedCategory:I,legendIsolatedCategories:R,pointNodes:Pt,annotations:i,autoPlaceAnnotations:r,svgAnnotationRules:oe}),(0,Ed.jsx)(Qo,{active:null!=ut,hoverPoint:ut?{x:ut.x,y:ut.y}:null,margin:Qe,size:at,shape:ut?.shape,width:ut?.width,height:ut?.height,pathData:ut?.pathData}),Kt]})]})}));Wd.displayName="StreamPhysicsFrame";var qd=Wd,Yd=require("react");function Hd(e,t){if(!t?.length)return[e];const n=t.filter(t=>{if(t.id===e||t.id.startsWith(e+"-"))return!0;const n=t.datum;return!(!n||"object"!=typeof n||null==n.id)&&n.id+""===e}).map(e=>e.id);return n.length?n:[e]}function Xd(e,t,n){if("function"==typeof n)return n(e,t)+"";if("string"==typeof n){const t=e[n];if(null!=t)return t+""}return null!=e&&"object"==typeof e&&"id"in e&&null!=e.id?e.id+"":"physics-row-"+t}function Gd(e,t){const n=e?.getData().find(e=>e.id===t),i=n?.datum;if(i&&"object"==typeof i)return i}var Vd=require("react"),Ud=require("react/jsx-runtime"),Kd=new Set(["sample","mechanical"]);function Zd(e,t,n){const i=n?.hasSimulationMode?function(e){const t=e=>"string"==typeof e&&Kd.has(e);return e.simulationMode?{chartMode:t(e.mode)?void 0:e.mode,simulationMode:e.simulationMode}:t(e.mode)?{chartMode:void 0,simulationMode:e.mode}:{chartMode:e.mode,simulationMode:"sample"}}({mode:e.mode,simulationMode:e.simulationMode}):{chartMode:"sample"===e.mode||"mechanical"===e.mode?void 0:e.mode,simulationMode:"sample"},r=_a(i.chartMode,{width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:t[0],height:t[1]}),o=e.size?.[0],s=e.size?.[1],a=t[0],c=t[1],l=(0,Vd.useMemo)(()=>{return e=[a,c],(null!=o&&null!=s?[o,s]:void 0)??[r.width??e[0],r.height??e[1]];var e},[c,a,r.height,r.width,s,o]),u=r.compactMode?"sparkline"===i.chartMode?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0};const d=e.showProjection??!r.compactMode,h=e.showChrome??!r.compactMode,f=th(e.tooltip,void 0),p=void 0!==f.enableHover?f.enableHover:r.enableHover,y=r.compactMode?r.title:r.title??e.title,g=[e.className,i.chartMode&&"primary"!==i.chartMode?"semiotic-physics--"+i.chartMode:null].filter(Boolean).join(" ")||void 0;return{chartMode:i.chartMode,simulationMode:i.simulationMode,resolved:r,chartSize:l,margin:u,showProjection:d,showChrome:h,enableHover:p,title:y,description:r.description??e.description,summary:r.summary??e.summary,accessibleTable:r.accessibleTable??e.accessibleTable,className:g,compactMode:r.compactMode,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics}}function Qd(e){const[t,n]=e.size;return Fa(e.loading,t,n,e.loadingContent)||Ba(e.data,t,n,e.emptyContent)}function Jd(e,t,n){return(0,Ud.jsx)(Ea,{componentName:e,width:t[0],height:t[1],children:n})}function eh(e,t){return e?t?n=>(0,Ud.jsxs)(Ud.Fragment,{children:["function"==typeof e?e(n):e,"function"==typeof t?t(n):t]}):e:t}function th(e,t){return!1===e?{enableHover:!1}:{enableHover:t?.enableHover,tooltipContent:Q(e)||t?.tooltipContent}}function nh(e,t,n,i){return{accessibleTable:i?.accessibleTable??e.accessibleTable??t?.accessibleTable,annotations:e.annotations??t?.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations??t?.autoPlaceAnnotations,background:e.background??t?.background,chartId:e.chartId??t?.chartId,chartMode:i?.chartMode??t?.chartMode,className:i?.className??e.className??t?.className,color:e.color??t?.color,description:i?.description??e.description??t?.description,emphasis:e.emphasis??t?.emphasis,enableHover:i?.enableHover??t?.enableHover,hoverRadius:e.hoverRadius??t?.hoverRadius,legend:e.legend??t?.legend,legendLayout:e.legendLayout??t?.legendLayout,legendPosition:e.legendPosition??t?.legendPosition,margin:i?.margin??t?.margin,onClick:null!=e.onClick?(t,n)=>{e.onClick?.(t,{x:n.x,y:n.y})}:t?.onClick,onObservation:e.onObservation??t?.onObservation,opacity:e.opacity??t?.opacity,semanticItems:t?.semanticItems??n,stroke:e.stroke??t?.stroke,strokeWidth:e.strokeWidth??t?.strokeWidth,summary:i?.summary??e.summary??t?.summary,svgAnnotationRules:e.svgAnnotationRules??t?.svgAnnotationRules,title:i?.title??e.title??t?.title}}var ih=require("react/jsx-runtime");function rh(e,t){const n=t.config??{},i=(t.sensors??[]).map(e=>({...e,sensor:!0})),r=[...t.colliders??[],...i],o=[...e.colliders??[],...n.colliders??[],...r];return{...e,...n,observation:{...e.observation,...n.observation},...o.length>0&&{colliders:o}}}function oh(e){const t=function(e,t,n){const i=e?.observation;return{...e,observation:{...i,chartId:t??i?.chartId??"physics-custom",chartType:i?.chartType??"PhysicsCustomChart",onObservation:n??i?.onObservation}}}(e.config,e.chartId,e.onObservation),n=iu(e.colorScheme,e.themeCategorical,g),i=Sc(e.size),r={data:e.data,scales:{x:(0,nu.scaleLinear)().domain(e.xExtent??[0,1]).range([i.plot.x,i.plot.x+i.plot.width]),y:(0,nu.scaleLinear)().domain(e.yExtent??[0,1]).range([i.plot.y+i.plot.height,i.plot.y])},dimensions:i,theme:{semantic:e.semantic,categorical:[...n]},resolveColor:ru(n,e.colorScheme),config:e.layoutConfig??{},world:new Fl(t)},o=e.skipLayout?{}:e.layout(r)??{},s=function(e,t){if(!t?.length)return e;const n=new Map;for(const e of t){const{bodyId:t,...i}=e,r=n.get(t)??[];r.push(i),n.set(t,r)}return e.map(e=>{const t=n.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}([...o.initialSpawns??o.bodies??[]],o.constraints);return{config:rh(t,o),context:r,initialSpawnPacing:o.initialSpawnPacing,initialSpawns:s,result:o}}(0,tu.forwardRef)(function(e,t){const{chartId:n,color:i,colorBy:r,colorScheme:o,config:s,controllers:a,data:c,emptyContent:l,frameProps:u={},layout:d,layoutConfig:h,loading:f,loadingContent:p,onObservation:y,opacity:g,paused:m,spawnDatum:x,stroke:b,strokeWidth:v,title:w,xExtent:k,yExtent:S}=e,A=Zd(e,[700,380]),{chartSize:M,className:P,title:_,chartMode:j,margin:C,enableHover:I,description:T,summary:R,accessibleTable:L}=A,$=(0,tu.useRef)(null),E=(0,tu.useRef)(null),D=(0,tu.useRef)(""),z=Qd({data:c,emptyContent:l,loading:f,loadingContent:p,size:M}),F=null!=z,N=(0,tu.useMemo)(()=>B(c??[]),[c]),O=Pe(e=>e.theme),W=(0,tu.useMemo)(()=>xe(O)??{},[O]),q=O?.colors?.categorical??we.colors.categorical,Y=(0,tu.useMemo)(()=>[M[0],M[1],N.length,N.map((e,t)=>(e.id??t)+"").join("|"),k?.join(",")??"",S?.join(",")??""].join("::"),[M,N,k,S]),H=(0,tu.useMemo)(()=>oh({chartId:n,colorScheme:o,config:s,data:N,layout:d,layoutConfig:h,onObservation:y,semantic:W,skipLayout:F,size:M,themeCategorical:q,xExtent:k,yExtent:S}),[n,M,o,s,d,h,y,N,W,F,q,k,S]);D.current===Y&&null!=E.current||(D.current=Y,E.current=H.initialSpawns);const X=E.current,G=(0,tu.useMemo)(()=>{const e=[...H.result.controllers??[],...a??[],...u.controllers??[]];return e.length?e:void 0},[u.controllers,a,H.result.controllers]),V=(0,tu.useMemo)(()=>{const e=[...H.result.regionEffects??[],...u.regionEffects??[]];return e.length?e:void 0},[u.regionEffects,H.result.regionEffects]),U=(0,tu.useCallback)(e=>{const t=e.datum,n=t&&r?function(e,t,n){return"function"==typeof n?n(e,0):e[n]}(t,0,r)+"":e.id;return{fill:i??H.context.resolveColor(n,t),stroke:b??"#111827",strokeWidth:v??1,opacity:g??.9}},[i,r,g,H.context,b,v]);!function(e,t){const{frameRef:n,spawnDatum:i,seedRows:r,idAccessor:o,bodyIdsForSeed:s,seedSpawns:a}=t,c=(0,Yd.useRef)(new Map),l=(0,Yd.useRef)(new Map),u=(0,Yd.useRef)(""),d=r?r.map((e,t)=>Xd(e,t,o)).join("\0"):"";if(d!==u.current&&(u.current=d,r))for(let e=0;r.length>e;e+=1){const t=r[e],n=Xd(t,e,o);c.current.set(n,t),l.current.set(n,s?.(t,n,e)??Hd(n,a))}(0,Yd.useImperativeHandle)(e,()=>{const e=c.current,t=l.current;function r(e,t){const n=i(e,t);return{datumId:n.datumId||Xd(e,t,o),spawns:n.spawns.map(e=>({...e,spawnAt:void 0}))}}function s(i){const r=[];for(const{datum:n,result:o}of i)e.set(o.datumId,n),t.set(o.datumId,o.spawns.map(e=>e.id)),r.push(...o.spawns);if(!r.length)return;const o=n.current;o?(o.pushMany(r),o.step(0)):"production"!==process.env.NODE_ENV&&console.warn("[semiotic/physics] push() called before the physics frame mounted (loading/empty early-return). Omit data for push mode and ensure the chart is mounted.")}function a(i){const r=e.get(i);if(r)return r;const o=t.get(i)??[i];for(const r of o){const o=Gd(n.current,r);if(o)return e.set(i,o),t.has(i)||t.set(i,[r]),o}}return{push:t=>{s([{datum:t,result:r(t,e.size)}])},pushMany:t=>{const n=e.size;s(t.map((e,t)=>({datum:e,result:r(e,n+t)})))},remove:i=>{const r=Array.isArray(i)?i:[i],o=[],s=[];for(const n of r){const i=a(n);i&&o.push(i),e.delete(n),s.push(...t.get(n)??[n]),t.delete(n)}return s.length&&n.current?.remove(s),o},update:(i,o)=>{const c=Array.isArray(i)?i:[i],l=[];for(const i of c){const c=a(i);if(!c)continue;l.push(c);const u=t.get(i)??[i];n.current?.remove(u),e.delete(i),t.delete(i);const d=o(c);s([{datum:d,result:r(d,e.size)}])}return l},clear:()=>{e.clear(),t.clear(),u.current="",n.current?.clear()},getData:()=>{const t=n.current;if(!t)return Array.from(e.values());const i=t.getData().map(e=>e.datum).filter(e=>!!e&&"object"==typeof e);return i.length?i:Array.from(e.values())},getScales:()=>null,getCustomLayout:()=>n.current?.snapshot()??null,popBodies:(e,t)=>n.current?.popBodies(e,t)??[]}},[s,n,o,i])}(t,{frameRef:$,spawnDatum:(0,tu.useCallback)((e,t)=>{const i=e;if(x)return function(e,t,n){return Array.isArray(n)?{datumId:(e.id??n[0]?.id??"physics-custom-"+t)+"",spawns:n}:"spawns"in n?n:{datumId:(e.id??n.id??"physics-custom-"+t)+"",spawns:[n]}}(e,t,x(i,t,H.context));const r=oh({chartId:n,colorScheme:o,config:s,data:[i],layout:d,layoutConfig:h,onObservation:y,semantic:W,size:M,themeCategorical:q,xExtent:k,yExtent:S}),a=r.initialSpawns.length?r.initialSpawns:[{id:(e.id??"physics-custom-"+t)+"",x:r.context.dimensions.plot.x+r.context.dimensions.plot.width/2,y:r.context.dimensions.plot.y+12,mass:1,shape:{type:"circle",radius:5},datum:e}];return{datumId:(e.id??a[0].id)+"",spawns:a}},[n,M,o,s,x,d,h,y,H.context,W,q,k,S]),seedRows:N,seedSpawns:X});const K=(0,tu.useCallback)((e,t)=>{u.onBodyPointerDown?.(e,t)},[u]);if(z)return z;const Z=th(e.tooltip,u),Q=nh(e,u,H.result.semanticItems,{chartMode:j,className:P,title:_??w,description:T,summary:R,accessibleTable:L,enableHover:I,margin:C});return Jd("PhysicsCustomChart",M,(0,ih.jsx)(qd,{...u,...Z,...Q,ref:$,backgroundGraphics:eh(u.backgroundGraphics,H.result.backgroundOverlays),bodyForces:H.result.bodyForces??u.bodyForces,bodyStyle:H.result.bodyStyle??u.bodyStyle??U,config:H.config,controllers:G,foregroundGraphics:eh(u.foregroundGraphics,H.result.overlays),initialSpawnPacing:H.initialSpawnPacing,initialSpawns:X,onBodyPointerDown:K,paused:m,regionEffects:V,responsiveHeight:e.responsiveHeight,responsiveWidth:e.responsiveWidth,selectedBodyStyle:H.result.selectedBodyStyle??u.selectedBodyStyle,size:M}))}).displayName="PhysicsCustomChart";var sh=require("react"),ah="gauntlet-core",ch="gauntlet-positive",lh="gauntlet-negative";function uh(e){return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:28,y2:e.floorY,thickness:8}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:e.width-30,y2:76,thickness:8}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:e.floorY,x2:e.width-30,y2:e.floorY,thickness:8}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-30,y1:76,x2:e.width-30,y2:e.floorY,thickness:8}}]}function dh(e,t,n,i){return n?"function"==typeof n?n(e,t):e[n]??i:i}function hh(e){return e?.label??e?.id??"property"}function fh(e){return`gauntlet:${e}:core`}function ph(e,t){return`gauntlet:${e}:positive:${t}`}function yh(e,t,n){return`gauntlet:${e}:negative:${t}:${n}`}function gh(e,t,n,i){const r=Math.max(2,n+2),o=80+r,s=i.floorY-r;return{x:Math.max(32+r,Math.min(i.width-30-4-r,e)),y:Math.max(o,Math.min(s,t))}}function mh(e,t,n){const[i,r]=e,o=Math.round(.48*r),s=r-36,a=(t??[]).filter(e=>!1!==e.enabled),c=Math.max(1,a.length),l=.22*i,u=c>1?(.78*i-l)/(c-1):0,d=Math.max(Math.round(.14*i),110);return{crashY:s-n,floorY:s,gates:a.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(l+t*u),width:e.width??Math.max(54,Math.round(.07*i))})),graveyardX:Math.round(.84*i),graveyardY:s-4,height:r,routeY:o,socketX:Math.round(.92*i),startX:d,width:i}}function xh(e){return{graveyardX:e.graveyardX,graveyardY:e.graveyardY,routeY:e.routeY,socketX:e.socketX,socketY:e.routeY-4,startX:e.startX,startY:e.routeY}}function bh(e,t,n,i){const r=xh(n),o=i?.(e,t,n)??{};return{...r,...o,startY:o.startY??o.routeY??r.startY,socketY:o.socketY??o.routeY??r.socketY,graveyardY:o.graveyardY??r.graveyardY}}function vh(e,t){const n=[...e].sort((e,t)=>e.localeCompare(t)),i=Math.max(0,n.indexOf(t));return{angle:.82*-Math.PI+(n.length>1?i/(n.length-1):.5)*Math.PI*.64,index:i,radius:48+i%2*6}}function wh(e,t,n){const i=e.activePositiveIds.reduce((e,n)=>e+(t.get(n)?.value??1),0),r=e.missingPositiveIds.length+e.poppedPositiveIds.length,o=e.negativeIds.reduce((e,t)=>e+(n.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*i-8*o-1.2*e.delay-5*r))}function kh(e,t,n,i,r){const o=dh(e,t,n.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",s=i.map(e=>e.id),a=[...dh(e,t,n.positiveAccessor,s)],c=[...dh(e,t,n.negativeAccessor,[])].filter(e=>r.has(e));return{id:o,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...dh(e,t,n.metricsAccessor,{})},missingPositiveIds:s.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(dh(e,t,n.startTimeAccessor,0))||0),stage:"project filed",viability:dh(e,t,n.initialViability,100)}}function Sh(e,t,n,i,r,o,s){const a=i.startX,c=i.startY+(i.startY===n.routeY?38*t:0),l=s?.(e,t,n,i)??{},u={__gauntlet:!0,kind:ah,projectId:e.id,sourceDatum:e.datum},d=[{...l,id:fh(e.id),x:l.x??a,y:l.y??c,vx:l.vx??42,vy:l.vy??0,mass:l.mass??7,bodyCollisions:l.bodyCollisions??!0,shape:l.shape??{type:"circle",radius:28},spawnAt:l.spawnAt??e.startedAt,datum:u}],h=gh(a,c,l.shape&&"radius"in l.shape&&Number(l.shape.radius)||28,n);d[0].x=h.x,d[0].y=h.y;for(const t of e.activePositiveIds){const i=r.get(t);if(!i)continue;const o=vh(e.activePositiveIds,t),s=i.radius??10,a=gh(h.x+Math.cos(o.angle)*o.radius,h.y+Math.sin(o.angle)*o.radius,s,n);d.push({id:ph(e.id,t),x:a.x,y:a.y,vx:18*Math.cos(o.angle),vy:18*Math.sin(o.angle),mass:i.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:l.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:ch,projectId:e.id,property:i,sourceDatum:e.datum},springs:!1===i.spring?[]:[{target:{type:"body",bodyId:fh(e.id)},stiffness:.56,damping:.9,restLength:52+o.index%2*4,...i.spring??{}}]})}return e.negativeIds.forEach((t,i)=>{const r=o.get(t);r&&d.push(Ah(e,r,i,h.x,h.y,n,l.spawnAt??e.startedAt))}),d}function Ah(e,t,n,i,r,o,s){const a=t.radius??7.2,c=gh(i-12+n%4*12,r+54+12*Math.floor(n/4),a,o);return{id:yh(e.id,t.id,n),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:s,datum:{__gauntlet:!0,kind:lh,projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:fh(e.id)},stiffness:.62,damping:.92,restLength:52+n%4*3,...t.spring??{}}]}}function Mh(e){return e?Array.isArray(e)?[...e]:Object.entries(e).flatMap(([e,t])=>Array.from({length:Math.max(0,Math.round(Number(t)||0))},()=>e)):[]}function Ph(e,t){return t?Array.isArray(t)?[...t]:t.ids?[...t.ids]:t.candidates?t.candidates.filter(t=>e.includes(t)).slice(0,t.count??1):[]:[]}function _h(e,t){return Ph(e.activePositiveIds,t.popPositive)}function jh(e,t){const n=Ph(e.negativeIds,t.popNegative);if(!n.length)return[];const i=new Map;for(const e of n)i.set(e,(i.get(e)??0)+1);const r=[];return e.negativeIds.forEach((e,t)=>{const n=i.get(e)??0;n>0&&(r.push({propertyId:e,index:t}),i.set(e,n-1))}),r}function Ch(e,t,n){if(t.when&&!t.when(n))return e;let i={...e};const r=_h(i,t);r.length&&(i={...i,activePositiveIds:i.activePositiveIds.filter(e=>!r.includes(e)),poppedPositiveIds:Array.from(new Set([...i.poppedPositiveIds,...r]))});const o=jh(i,t);if(o.length){const e=new Set(o.map(e=>e.index));i={...i,negativeIds:i.negativeIds.filter((t,n)=>!e.has(n)),poppedNegativeIds:[...i.poppedNegativeIds,...o.map(e=>e.propertyId)]}}const s=Mh(t.addPositive);s.length&&(i={...i,activePositiveIds:Array.from(new Set([...i.activePositiveIds,...s])),missingPositiveIds:i.missingPositiveIds.filter(e=>!s.includes(e))});const a=Mh(t.addNegative);if(a.length&&(i={...i,negativeIds:[...i.negativeIds,...a]}),t.delayDelta&&(i={...i,delay:i.delay+t.delayDelta}),t.metricsDelta){const e={...i.metrics};for(const[n,i]of Object.entries(t.metricsDelta))e[n]=Number(e[n]??0)+i;i={...i,metrics:e}}return t.viabilityDelta&&(i={...i,viability:i.viability+t.viabilityDelta}),t.stage&&(i={...i,stage:t.stage}),t.outcome&&(i={...i,outcome:t.outcome}),i}function Ih(e,t){return{id:e.id,label:e.label??e.id,summary:e.summary??t.find(e=>e.summary)?.summary,time:e.time}}function Th(e,t){return e.eventsApplied.includes(t.id)?e:{...e,eventsApplied:[...e.eventsApplied,t.id],eventHistory:[...e.eventHistory??[],t],lastEvent:t,stage:t.label??e.stage}}function Rh(e,t){const n=e.datum;return!(!n?.__gauntlet||n.projectId!==t||n.kind!==lh)}function Lh(e){const t=e.id.slice(e.id.lastIndexOf(":")+1),n=Number(t);return Number.isFinite(n)?n:-1}var $h=require("react/jsx-runtime");function Eh(e){const t=e.data;return t?.__gauntlet?(0,$h.jsxs)("div",{className:"semiotic-tooltip",style:{background:"var(--semiotic-tooltip-bg, rgba(15, 23, 42, 0.94))",color:"var(--semiotic-tooltip-text, #f8fafc)",padding:"8px 12px",borderRadius:6,boxShadow:"var(--semiotic-tooltip-shadow, 0 8px 24px rgba(0,0,0,0.35))",maxWidth:280},children:[(0,$h.jsx)("strong",{children:t.kind===ah?"string"==typeof t.sourceDatum?.label?t.sourceDatum.label:t.projectId:hh(t.property)}),(0,$h.jsx)("div",{children:t.kind===ch?"Positive property":t.kind===lh?"Negative property":"Project core"})]}):null}function Dh(e,t,n){const i=t.datum;if(!i?.__gauntlet)return;const r="circle"===t.shape.type?t.shape.radius:8;if(e.save(),e.translate(t.x,t.y),i.kind===ah)e.fillStyle=zh(e,n.fill,"#0f766e"),e.strokeStyle=zh(e,n.stroke,"#f8fafc"),e.lineWidth=2.4,e.beginPath(),e.arc(0,0,r,0,2*Math.PI),e.fill(),e.stroke();else{const t=i.property;e.fillStyle=zh(e,n.fill??t?.color,"#38bdf8"),e.strokeStyle=zh(e,n.stroke,"#0f172a"),e.lineWidth=1.1,e.beginPath(),i.kind===lh?e.rect(-r,-r,2*r,2*r):e.arc(0,0,r,0,2*Math.PI),e.fill(),e.stroke(),e.fillStyle=zh(e,"var(--semiotic-background, #07111f)","#07111f"),e.font=`900 ${i.kind===lh?9:8}px system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(t?.short??t?.id?.slice(0,1).toUpperCase()??"?",0,.5)}e.restore()}function zh(e,t,n){if("string"!=typeof t)return n;if("function"!=typeof getComputedStyle||!e.canvas)return t||n;const i=t.startsWith("var(")?t.match(/var\((--[^,\s)]+)/)?.[1]:t.startsWith("--")?t:null;return i?getComputedStyle(e.canvas).getPropertyValue(i).trim()||n:t||n}function Bh({layout:e,states:t}){return(0,$h.jsxs)("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,$h.jsx)("path",{d:`M ${e.startX-42} ${e.routeY} C ${.24*e.width} ${e.routeY-70}, ${.42*e.width} ${e.routeY+78}, ${.58*e.width} ${e.routeY} S ${.78*e.width} ${e.routeY-82}, ${e.socketX+36} ${e.routeY}`,fill:"none",stroke:"var(--semiotic-accent, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),(0,$h.jsx)("line",{x1:Math.round(.06*e.width),x2:Math.round(.94*e.width),y1:e.crashY,y2:e.crashY,stroke:"var(--semiotic-negative, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),(0,$h.jsx)("text",{x:Math.round(.07*e.width),y:e.crashY-8,fill:"var(--semiotic-negative, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),e.gates.map(t=>(0,$h.jsxs)("g",{children:[(0,$h.jsx)("rect",{x:t.x-t.width/2,y:Math.max(80,e.routeY-180),width:t.width,height:Math.min(360,e.height-170),rx:12,fill:t.color??"var(--semiotic-accent, #38bdf8)",fillOpacity:.1,stroke:t.color??"var(--semiotic-accent, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),(0,$h.jsx)("text",{x:t.x,y:Math.max(64,e.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:t.label??t.id})]},t.id)),(0,$h.jsxs)("g",{children:[(0,$h.jsx)("rect",{x:e.socketX-52,y:e.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-positive, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-positive, #22c55e)",strokeWidth:1.5}),(0,$h.jsx)("text",{x:e.socketX,y:e.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),(0,$h.jsxs)("g",{children:[(0,$h.jsx)("rect",{x:e.graveyardX-82,y:e.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-negative, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-negative, #ef4444)",strokeOpacity:.7}),(0,$h.jsx)("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-negative, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),(0,$h.jsx)("text",{x:e.graveyardX,y:e.graveyardY+12,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,textAnchor:"middle",children:t.some(e=>e.killed)?"lift shut off":"too heavy or too small"})]})]})}function Fh(e){const t=e.datum;return!!t?.__gauntlet&&(t.kind===ah?{label:t.projectId+" project core",group:"project",description:"Project core carrying positive and negative properties."}:{label:`${hh(t.property)} ${t.kind===ch?"positive":"negative"} property`,group:t.kind===ch?"positive property":"negative property",description:`${hh(t.property)} attached to ${t.projectId}.`})}function Nh({states:e,layout:t}){const n=function(e){return e.map(e=>({label:e.id,value:Math.max(0,Number(e.viability)||0),outcome:e.outcome||e.stage||"in-process"}))}(e);if(!n.length)return null;const i=Math.max(1,...n.map(e=>e.value)),r=Math.max(40,(t.width-80)/n.length);return(0,$h.jsxs)("svg",{"aria-hidden":"true","data-testid":"gauntlet-projection-overlay",width:t.width,height:t.height,viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,$h.jsx)("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),n.map((e,t)=>{const n=40+t*r,o=Math.max(2,e.value/i*28),s=/kill|crash|block|grave/i.test(e.outcome);return(0,$h.jsxs)("g",{children:[(0,$h.jsx)("rect",{x:n+.18*r,y:28-o+22,width:Math.max(10,.45*r),height:o,rx:2,fill:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),(0,$h.jsx)("text",{x:n+.4*r,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}var Oh=require("react/jsx-runtime"),Wh=require("react"),qh=[];function Yh(e){return e.map(e=>({...e,spawnAt:void 0}))}(0,sh.forwardRef)(function(e,t){const{bodyGroups:n,coreBody:i,coreForceMode:r="route",crashDetection:o=!0,crashOffset:s=30,data:a,emptyContent:c,events:l,frameProps:u={},gates:d,initialSpawnPacing:h,loading:f,loadingContent:p,negativeProperties:y,onCapacityChange:g,onClick:m,onStateChange:x,outcome:b,paused:v,positiveProperties:w=qh,projectPlacement:k,responsiveHeight:S,responsiveWidth:A,showTethers:M=!0,terminalBehavior:P="outcome",viability:_}=e,j=(0,sh.useRef)(null),C=(0,sh.useMemo)(()=>({idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor}),[e.idAccessor,e.initialViability,e.metricsAccessor,e.negativeAccessor,e.positiveAccessor,e.startTimeAccessor]),I=Zd(e,[900,520]),{chartSize:T,showProjection:R,showChrome:L,className:$,title:E,chartMode:D,margin:z,enableHover:F,description:N,summary:O,accessibleTable:W}=I,q=Qd({data:a,emptyContent:c,loading:f,loadingContent:p,size:T}),Y=(0,sh.useMemo)(()=>B(a??[]),[a]),H=(0,sh.useMemo)(()=>Y.map((e,t)=>dh(e,t,C.idAccessor,null!=e.id?e.id+"":"project-"+t)+"").join("|"),[Y,C.idAccessor]),X=(0,sh.useMemo)(()=>new Map(w.map(e=>[e.id,e])),[w]),G=(0,sh.useMemo)(()=>new Map(y.map(e=>[e.id,e])),[y]),V=(0,sh.useMemo)(()=>mh(T,d,s),[T,s,d]),U=(0,sh.useMemo)(()=>new Map(V.gates.map(e=>[e.id,e])),[V.gates]),K=(0,sh.useMemo)(()=>V.gates.map(e=>({kind:"force-field",damping:.035,force:{x:12,y:0},semanticItem:!1,...e.regionEffect,id:"gauntlet-gate-"+e.id,label:e.label??e.id,description:e.description,bodyFilter:e.capacity?{property:"datum.kind",equals:ah}:e.regionEffect?.bodyFilter,shape:{type:"aabb",x:e.x,y:V.routeY,width:e.capacity?e.capacity.sensorWidth??Math.max(96,6*e.width):Math.max(e.width,54),height:Math.min(360,V.height-170)}})),[V.gates,V.height,V.routeY]),[Z,Q]=(0,sh.useState)(()=>Y.map((e,t)=>{const n=kh(e,t,C,w,G);return{...n,viability:_?.(n,{negativeProperties:G,positiveProperties:X})??wh(n,X,G)}})),J=(0,sh.useRef)(Z),ee=(0,sh.useRef)(0),te=(0,sh.useRef)(new Map),ne=(0,sh.useRef)([]),ie=(0,sh.useRef)(g);ie.current=g;const re=(0,sh.useMemo)(()=>function(e){const{dataKey:t,gates:n,statesRef:i,processedGateVisitsRef:r}=e;return n.flatMap(e=>e.capacity&&e.capacity.unitsPerSecond>0?[Uu({id:`gauntlet-capacity-${t}-${e.id}`,regionId:"gauntlet-gate-"+e.id,unitsPerSecond:e.capacity.unitsPerSecond,bodyFilter:{property:"datum.kind",equals:ah},maxQueue:e.capacity.maxQueue,queueLayout:e.capacity.queueLayout,queueSlotSpacing:e.capacity.queueSlotSpacing,queueStiffness:e.capacity.queueStiffness??24,releaseImpulse:{x:36,y:0},unitAccessor:t=>{const n=t.datum,r=n?.sourceDatum,o=e.capacity?.unitAccessor,s=i.current.find(e=>e.id===n?.projectId);let a;"function"==typeof o?a=s?o(s):void 0:o&&(a=r?.[o]);const c=Number(a??r?.reviewWork??r?.work??s?.metrics.reviewWork??r?.points);return Number.isFinite(c)&&c>0?c:1},onProcessed:t=>{const n=t.datum;if(!n?.projectId)return;const i=`${n.projectId}:${e.id}`;r.current.set(i,(r.current.get(i)??0)+1)}})]:[])}({dataKey:H,gates:V.gates,statesRef:J,processedGateVisitsRef:te}),[H,V.gates]),oe=(0,sh.useMemo)(()=>[...re,...u.controllers??[]],[re,u.controllers]),se=(0,sh.useRef)(Y);se.current=Y;const ae=(0,sh.useRef)(x);ae.current=x;const ce=(0,sh.useRef)({negativeById:G,positiveById:X,positiveProperties:w,stateAccessors:C,viability:_});ce.current={negativeById:G,positiveById:X,positiveProperties:w,stateAccessors:C,viability:_};const le=(0,sh.useCallback)((e,t,n=0)=>{const i=ce.current,r=kh(e,t,i.stateAccessors,i.positiveProperties,i.negativeById);return i.stateAccessors.startTimeAccessor||(r.startedAt=Math.max(0,n)),{...r,viability:i.viability?.(r,{negativeProperties:i.negativeById,positiveProperties:i.positiveById})??wh(r,i.positiveById,i.negativeById)}},[]);(0,sh.useEffect)(()=>{te.current.clear(),ne.current=[];const e=se.current.map((e,t)=>le(e,t));J.current=e,Q(e)},[le,H]),(0,sh.useEffect)(()=>{J.current=Z,ae.current?.(Z)},[Z]);const ue=(0,sh.useCallback)(e=>[...("function"==typeof l?l(e,V):l)??[]].sort((e,t)=>e.time-t.time),[l,V]),de=(0,sh.useCallback)((e,t,n)=>{if(!t.gateId||!U.get(t.gateId)?.capacity)return!0;const i=Number(t.gateVisit),r=Number.isFinite(i)&&i>0?Math.floor(i):n.filter(e=>e.gateId===t.gateId).findIndex(e=>e.id===t.id)+1;return r>0&&(te.current.get(`${e.id}:${t.gateId}`)??0)>=r},[U]),he=(0,sh.useCallback)(()=>{if(!re.length)return;const e=re.flatMap(e=>{const t=e.getSnapshot?.();return t?[t]:[]});var t,n;(t=ne.current).length===(n=e).length&&t.every((e,t)=>{const i=n[t];return!!i&&e.regionId===i.regionId&&e.queueDepth===i.queueDepth&&e.blockedDepth===i.blockedDepth&&e.processedCount===i.processedCount&&e.metricRevision===i.metricRevision})||(ne.current=e,ie.current?.(e))},[re]),fe=(0,sh.useMemo)(()=>Z.flatMap((e,t)=>{const n=bh(e,t,V,k);return Sh(e,t,V,n,X,G,i)}),[i,V,G,X,k,Z]),pe=(0,sh.useCallback)((e,t)=>{let n=!1;const i=J.current.map(i=>{if(i.id!==e)return i;const r=t(i);return n=n||r!==i,r});n&&(J.current=i,Q(i))},[]);(0,sh.useImperativeHandle)(t,()=>function(e){const{statesRef:t,setStates:n,elapsedRef:i,frameRef:r,layout:o,projectPlacement:s,positiveById:a,negativeById:c,coreBody:l,createState:u}=e;return{push:e=>{const d=u(e,t.current.length,i.current),h=bh(d,t.current.length,o,s),f=Sh(d,t.current.length,o,h,a,c,l),p=[...t.current,d];t.current=p,n(p),r.current?.pushMany(f),r.current?.step(0)},pushMany:e=>{const d=[...t.current],h=[],f=i.current;e.forEach(e=>{const t=u(e,d.length,f),n=bh(t,d.length,o,s);h.push(...Sh(t,d.length,o,n,a,c,l)),d.push(t)}),t.current=d,n(d),h.length&&r.current?.pushMany(h),r.current?.step(0)},remove:e=>{const i=Array.isArray(e)?e:[e],o=[],s=[];for(const e of i){const n=t.current.find(t=>t.id===e);n&&(o.push(n.datum),s.push(fh(n.id),...n.activePositiveIds.map(e=>ph(n.id,e))),n.negativeIds.forEach((e,t)=>{s.push(yh(n.id,e,t))}))}return t.current=t.current.filter(e=>!i.includes(e.id)),n(t.current),r.current?.remove(s),o},update:(e,d)=>{const h=Array.isArray(e)?e:[e],f=[];for(const e of h){const n=t.current.find(t=>t.id===e);if(!n)continue;const h=t.current.findIndex(t=>t.id===e);f.push(n.datum);const p=d(n.datum),y=u(p,0>h?t.current.length:h,n.startedAt??i.current),g=bh(y,0>h?t.current.length:h,o,s);r.current?.remove([fh(n.id),...n.activePositiveIds.map(e=>ph(n.id,e)),...n.negativeIds.map((e,t)=>yh(n.id,e,t))]),r.current?.pushMany(Sh(y,0>h?t.current.length:h,o,g,a,c,l)),t.current=t.current.map(t=>t.id===e?y:t)}return n(t.current),f},clear:()=>{t.current=[],n([]),r.current?.clear()},getData:()=>t.current.map(e=>e.datum),getScales:()=>null,getCustomLayout:()=>r.current?.snapshot()??null,popBodies:(e,t)=>r.current?.popBodies(e,t)??[]}}({statesRef:J,setStates:Q,elapsedRef:ee,frameRef:j,layout:V,projectPlacement:k,positiveById:X,negativeById:G,coreBody:i,createState:le}),[i,le,V,G,X,k]);const ye=(0,sh.useCallback)((e,t,n)=>{!function(e){const{project:t,effect:n,controls:i,layout:r,positiveById:o,negativeById:s,coreBody:a,popBodies:c}=e,l=i.readBodies().find(e=>e.id===fh(t.id)),u=i.readBodies(),d=l?.x??r.startX,h=l?.y??r.routeY,f=function(e,t){let n=-1;for(const i of t)Rh(i,e.id)&&(n=Math.max(n,Lh(i)));return Math.max(e.negativeIds.length,n+1)}(t,u),p=Mh(n.addNegative).flatMap((e,n)=>{const i=s.get(e);return i?[Ah(t,i,f+n,d,h,r)]:[]}),y=Mh(n.addPositive).flatMap(e=>{if(!o.get(e)||t.activePositiveIds.includes(e))return[];const n={...xh(r),routeY:h,socketY:h,startX:d,startY:h};return Sh({...t,activePositiveIds:[e],negativeIds:[]},0,r,n,o,s,a).filter(e=>e.id.includes(":positive:"))});(p.length||y.length)&&i.pushMany([...p,...y]);const g=_h(t,n);for(const e of g){const n=o.get(e);c([ph(t.id,e)],{color:n?.popColor??n?.color,durationMs:900,radius:(n?.radius??10)+3})}const m=jh(t,n),x=function(e,t,n){const i=t.filter(t=>Rh(t,e.id)).sort((e,t)=>Lh(e)-Lh(t)||e.id.localeCompare(t.id)),r=new Set;return n.map(t=>{const n=i.find(e=>!r.has(e.id)&&e.datum.property?.id===t.propertyId);return n?(r.add(n.id),n.id):yh(e.id,t.propertyId,t.index)})}(t,u,m);m.forEach((e,t)=>{const n=s.get(e.propertyId);c([x[t]],{color:n?.popColor??n?.color,durationMs:900,radius:(n?.radius??7)+3})})}({project:e,effect:t,controls:n,layout:V,positiveById:X,negativeById:G,coreBody:i,popBodies:(e,t)=>j.current?.popBodies(e,t)})},[i,V,G,X]),ge=(0,sh.useCallback)(({body:e,bodies:t})=>function(e){const{body:t,bodies:n,layout:i,states:r,projectPlacement:o,positiveById:s,negativeById:a,projectEvents:c,gateById:l,coreForceMode:u,terminalBehavior:d,elapsed:h}=e,f=t.datum;if(!f?.__gauntlet)return null;const p=r.findIndex(e=>e.id===f.projectId),y=0>p?void 0:r[p];if(!y)return null;const g=bh(y,p,i,o),m=n.find(e=>e.id===fh(y.id)),x=y.negativeIds.reduce((e,t)=>e+(a.get(t)?.load??1),0),b=y.killed?0:58;if(f.kind!==ah){if(!m)return null;let e;const r=f.property;if(r?.target){const o=n.filter(e=>{const t=e.datum;return t?.__gauntlet&&t.projectId===y.id&&t.kind===f.kind}).sort((e,t)=>(e.id+"").localeCompare(t.id+"")),s=Math.max(0,o.findIndex(e=>e.id===t.id));e=r.target({body:t,bodies:n,core:m,index:s,layout:i,placement:g,project:y})??{x:m.x,y:m.y}}else if(f.kind===ch&&f.property){const t=vh(y.activePositiveIds,f.property.id);e={x:m.x+Math.cos(t.angle)*t.radius,y:m.y+Math.sin(t.angle)*t.radius-2}}else{const i=n.filter(e=>e.datum?.kind===lh&&e.datum.projectId===y.id).sort((e,t)=>(e.id+"").localeCompare(t.id+"")),r=Math.max(0,i.findIndex(e=>e.id===t.id)),o=Math.floor(r/4);e={x:m.x+18*(r%4-(Math.min(4,i.length-4*o)-1)/2),y:m.y+54+13*o}}const o="circle"===t.shape.type?t.shape.radius:8;e=gh(e.x,e.y,o,i);const s=gh(t.x,t.y,o,i);if(Math.abs(s.x-t.x)>.5||Math.abs(s.y-t.y)>.5)return{x:48*(s.x-t.x)-6*t.vx,y:48*(s.y-t.y)-6*t.vy};const a=f.kind!==ch||y.killed?0:3.2*(r?.buoyancy??r?.value??1),c=f.kind===lh?{x:.22*(r?.pull?.x??-8),y:.22*(r?.pull?.y??22)}:{x:0,y:0};return{x:28*(e.x-t.x)-3*(t.vx-m.vx)+c.x+.01*b,y:28*(e.y-t.y)-3*(t.vy-m.vy)+c.y-a}}if(y.killed)return{x:44*((y.crashX??y.metrics.lastX??t.x)-t.x)-9*t.vx,y:160+12*x-1.6*t.vy};const v=c(y),w=function(e,t,n,i,r,o,s){if(t.killed)return{x:t.metrics.lastX??i.graveyardX,y:i.graveyardY};const a=r[r.length-1];if(!a)return{x:i.socketX,y:i.routeY};const c=r.find(n=>e>=n.time&&!t.eventsApplied.includes(n.id)&&!(!n.gateId||!o.get(n.gateId)?.capacity)),l=c?Math.min(e,c.time):e,u="built"===t.outcome||"built_diminished"===t.outcome;if(l>a.time+.85){if("hold-last"===s){const e=a.gateId?o.get(a.gateId):void 0;return{x:a.routeX??e?.x??i.socketX,y:a.routeY??i.routeY}}return u?{x:i.socketX,y:i.socketY}:{x:i.graveyardX,y:i.graveyardY-14}}const d=.85*t.delay+12*t.negativeIds.length+8*(t.poppedPositiveIds.length+t.missingPositiveIds.length),h=[{time:0,x:i.startX,y:i.startY},...r.map(e=>{const t=e.gateId?o.get(e.gateId):void 0;return{time:e.time,x:e.routeX??t?.x??i.startX,y:e.routeY??i.routeY+.28*Math.min(180,d)}})].sort((e,t)=>e.time-t.time);let f=h[0],p=h[h.length-1];for(let e=1;h.length>e;e+=1){if(h[e].time>=l){p=h[e];break}f=h[e]}const y=Math.max(0,Math.min(1,(l-f.time)/Math.max(.1,p.time-f.time))),g=y*y*(3-2*y);return{x:f.x+(p.x-f.x)*g,y:f.y+(p.y-f.y)*g+7*Math.sin(2.6*l)}}(Math.max(0,h-(y.startedAt??0)),y,0,g,v,l,d),k=y.activePositiveIds.reduce((e,t)=>e+(s.get(t)?.buoyancy??s.get(t)?.value??1),0);return"net"===u?{x:15*(w.x-t.x)-1.8*t.vx+.18*b,y:1.25*(g.routeY-t.y)-1.4*t.vy+32*(x-k)}:{x:15*(w.x-t.x)-1.8*t.vx+.18*b,y:15*(w.y-t.y)-1.8*t.vy+13*x-2.2*k}}({body:e,bodies:t,layout:V,states:J.current,projectPlacement:k,positiveById:X,negativeById:G,projectEvents:ue,gateById:U,coreForceMode:r,terminalBehavior:P,elapsed:ee.current}),[r,U,V,G,X,ue,k,P]),me=(0,sh.useCallback)((e,t)=>{!function(e,t,n){const{frameProps:i,elapsedRef:r,statesRef:o,crashDetection:s,layout:a,projectEvents:c,gateById:l,capacityEventReady:u,addBodiesForEffect:d,updateProjectState:h,viability:f,positiveById:p,negativeById:y,outcome:g,reportCapacity:m}=n;i.onTick?.(e,t),r.current=e.elapsedSeconds??t.snapshot().elapsedSeconds,m();for(const e of o.current){const n=t.readBodies().find(t=>t.id===fh(e.id));if(!n)continue;if(s&&!e.killed&&n.y+("circle"===n.shape.type?n.shape.radius:28)>=a.crashY){t.readBodies().forEach(n=>{const i=n.datum;i?.__gauntlet&&i.projectId===e.id&&t.applyImpulse(n.id,-n.vx*n.mass,0)}),h(e.id,e=>{const t={appliedAt:Math.max(0,r.current-(e.startedAt??0)),id:"gauntlet-crash-line",label:"Crash Line",summary:"The project hit the crash threshold; lift and forward motion shut off.",time:Math.max(0,r.current-(e.startedAt??0))};return{...e,crashX:n.x,eventHistory:[...e.eventHistory??[],t],killed:!0,lastEvent:t,metrics:{...e.metrics,lastX:n.x},outcome:"bad_design_crash",stage:"Crash Line",viability:Math.min(0,e.viability)}});continue}if(e.killed)continue;const i=Math.max(0,r.current-(e.startedAt??0)),o=c(e),m=o.filter(t=>i>=t.time&&!e.eventsApplied.includes(t.id)&&u(e,t,o));let x=e;for(const n of m){const r=n.gateId?l.get(n.gateId):void 0,o=n.effects??[];for(const e of o){const i={event:n,gate:r,negativeProperties:y,positiveProperties:p,project:x};e.when&&!e.when(i)||(d(x,e,t),x=Ch(x,e,i))}const s={...Ih(n,o),appliedAt:i};x=Th(x,s),h(e.id,e=>{let t=Th(e,s);if(t===e)return e;for(const e of o)t=Ch(t,e,{event:n,gate:r,negativeProperties:y,positiveProperties:p,project:t});const i=f?.(t,{negativeProperties:y,positiveProperties:p})??wh(t,p,y);return t={...t,viability:i},n.final&&(t={...t,outcome:n.outcome??g?.(t,{layout:a,negativeProperties:y,positiveProperties:p})??(t.viability>20?"built":"approved_not_built")}),t})}}}(e,t,{frameProps:u,elapsedRef:ee,statesRef:J,crashDetection:o,layout:V,projectEvents:ue,gateById:U,capacityEventReady:de,addBodiesForEffect:ye,updateProjectState:pe,viability:_,positiveById:X,negativeById:G,outcome:b,reportCapacity:he})},[ye,de,o,u,U,V,G,b,X,ue,he,pe,_]),xe=(0,sh.useCallback)((e,t)=>{const n="function"==typeof u.bodyStyle?u.bodyStyle(e,t):u.bodyStyle,i=e.datum;return i?.__gauntlet?{fill:i.kind===ah?"var(--semiotic-accent, #0f766e)":i.property?.color??"var(--semiotic-accent, #38bdf8)",stroke:i.kind===ah?"#f8fafc":"#0f172a",opacity:.96,...n}:n??{}},[u]),be=(0,sh.useMemo)(()=>"function"==typeof n?n(Z,V):n??[],[n,V,Z]),ve=(0,sh.useMemo)(()=>be.flatMap(e=>{if(!1===e.semanticItem)return[];const t=e.semanticItem??{},n={id:e.id,label:e.label??e.id,description:e.description,datum:e.datum,group:e.group??e.state??"body group",x:e.x??0,y:e.y??0,width:e.width,height:e.height};return[{...n,...t,id:t.id??n.id}]}),[be]),we=(0,sh.useMemo)(()=>R?function(e,t){if(!e.length)return[];const n=Math.max(40,(t.width-80)/e.length);return e.map((e,t)=>{const i=`${e.id}: viability ${Math.round(e.viability)}, ${e.outcome||e.stage}`;return{id:"gauntlet-projection-"+e.id,label:i,description:i,datum:e,x:40+(t+.5)*n,y:28,shape:"rect",width:Math.max(16,.55*n),height:22,group:"settled projection"}})}(Z,V):[],[V,R,Z]),ke=(0,sh.useMemo)(()=>[...we,...ve],[ve,we]),Se=(0,sh.useCallback)((e,t)=>{u.onBodyPointerDown?.(e,t)},[u]),Ae=(0,sh.useCallback)((e,t)=>{m&&m(e&&"object"==typeof e&&e.__gauntlet?e.sourceDatum:e,{x:t.x,y:t.y})},[m]);if(q)return q;const Me=th(e.tooltip,u),Pe=nh(e,u,ke,{chartMode:D,className:$,title:E,description:N,summary:O,accessibleTable:W,enableHover:F,margin:z}),_e=R?(0,Oh.jsx)(Nh,{states:Z,layout:V}):void 0,je=eh(L?(0,Oh.jsx)(Bh,{layout:V,states:Z}):void 0,u.backgroundGraphics),Ce=eh(_e,u.foregroundGraphics),Ie=u.renderBody??Dh,Te=Me.tooltipContent??Eh;return Jd("GauntletChart",T,(0,Wh.createElement)(qd,{...u,...Me,...Pe,key:`${T[0]}x${T[1]}:${H}`,ref:j,accessibleTable:e.accessibleTable??u.accessibleTable,backgroundGraphics:je,bodyForces:ge,bodySemanticItems:u.bodySemanticItems??Fh,bodyStyle:xe,beforePaint:(e,t)=>{u.beforePaint?.(e,t),M&&function(e,t){const n=new Map(t.filter(e=>e.datum?.kind===ah).map(e=>[e.datum.projectId,e]));e.save(),e.lineWidth=1.1,e.setLineDash([3,4]);for(const i of t){const t=i.datum;if(!t?.__gauntlet||t.kind===ah)continue;const r=n.get(t.projectId);r&&(e.globalAlpha=t.kind===lh?.24:.36,e.strokeStyle=t.kind===lh?"#d94a45":"#7a8794",e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(i.x,i.y),e.stroke())}e.restore()}(e,t)},onClick:m?Ae:Pe.onClick,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7,...u.config?.kernel??{}},colliders:[...uh(V),...u.config?.colliders??[]]},controllers:oe,enableHover:Me.enableHover??!0,foregroundGraphics:Ce,hoverRadius:e.hoverRadius??u.hoverRadius??18,initialSpawns:fe,initialSpawnPacing:h,onBodyPointerDown:Se,onTick:me,paused:v,regionEffects:[...K,...u.regionEffects??[]],renderBody:Ie,responsiveHeight:S,responsiveWidth:A,size:T,tooltipContent:Te}))}).displayName="GauntletChart";var Hh={Sparkline:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"line",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||t,colorAccessor:t,...i,showAxes:!1,margin:i.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"line",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||t,colorAccessor:t,colorScheme:n,lineStyle:r.lineStyle,...i})},AreaChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"area",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||t,colorAccessor:t,colorScheme:n,...i})},DifferenceChart:Ua,StackedAreaChart:Ka,Scatterplot:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,colorScheme:n,...i})},CandlestickChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"candlestick",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.highAccessor||"high",highAccessor:r.highAccessor||"high",lowAccessor:r.lowAccessor||"low",openAccessor:r.openAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle,...i})},BubbleChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:n,...i})},ConnectedScatterplot:Qa,QuadrantChart:Za,Heatmap:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"heatmap",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:n||r.colorScheme||"blues",showValues:r.showValues,cellBorderColor:r.cellBorderColor,...i})},XYCustomChart:{frameType:"xy",buildProps:(e,t,n,i,r)=>({chartType:"custom",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,colorScheme:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...i,showAxes:i.showAxes??!1})},BarChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"bar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:r.sort??!1,colorAccessor:t,colorScheme:n,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...i})},StackedBarChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"bar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:t||r.stackBy,colorScheme:n,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...i})},GroupedBarChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"clusterbar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:t||r.groupBy,colorScheme:n,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...i})},PieChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"pie",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:t||r.categoryAccessor,colorScheme:n,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...i})},DonutChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"donut",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",innerRadius:r.innerRadius||60,colorAccessor:t||r.categoryAccessor,colorScheme:n,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...i})},Histogram:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"histogram",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal",bins:r.bins,colorAccessor:t,colorScheme:n,...i})},BoxPlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"boxplot",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorScheme:n,...i})},ViolinPlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"violin",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,colorScheme:n,...i})},SwarmPlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"swarm",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:n,...i})},DotPlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"point",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:n,...i,showGrid:i.showGrid??!0})},SwimlaneChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"swimlane",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:t||r.subcategoryAccessor,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:n,projection:"horizontal"===r.orientation?"horizontal":"vertical",...i})},RidgelinePlot:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"ridgeline",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,amplitude:r.amplitude,...i})},LikertChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"bar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.levelAccessor||"level",colorAccessor:t||r.levelAccessor||"level",colorScheme:n,normalize:!0,projection:"vertical"===r.orientation?"vertical":"horizontal",...i})},FunnelChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>{const o="vertical"===r.orientation;return{chartType:o?"bar-funnel":"funnel",data:e,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:t||r.categoryAccessor,categoryAccessor:r.categoryAccessor,projection:o?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,barPadding:o?40:0,showAxes:o,showGrid:o,colorScheme:n,...i}}},GaugeChart:rc,OrdinalCustomChart:{frameType:"ordinal",buildProps:(e,t,n,i,r)=>({chartType:"custom",data:e,oAccessor:r.categoryAccessor||r.oAccessor||"category",rAccessor:r.valueAccessor||r.rAccessor||"value",projection:r.projection||"vertical",colorAccessor:t,colorScheme:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...i,showAxes:i.showAxes??!1})},ForceDirectedGraph:vc,NetworkCustomChart:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"force",nodes:r.nodes||e||[],edges:r.edges||[],nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor||"id",sourceAccessor:r.sourceAccessor||"source",targetAccessor:r.targetAccessor||"target",valueAccessor:r.valueAccessor||"value",colorBy:t,colorScheme:n,customNetworkLayout:r.layout||r.customNetworkLayout,layoutConfig:r.layoutConfig,...i})},SankeyDiagram:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"sankey",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,orientation:r.orientation,nodeAlign:r.nodeAlign,nodeWidth:r.nodeWidth,nodePaddingRatio:r.nodePaddingRatio,showLabels:r.showLabels,nodeLabel:r.nodeLabel,colorBy:t,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle,colorScheme:n,...i})},ProcessSankey:wc,ChordDiagram:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"chord",nodes:r.nodes,edges:r.edges,valueAccessor:r.valueAccessor,padAngle:r.padAngle,groupWidth:r.groupWidth,showLabels:r.showLabels,colorBy:t,edgeColorBy:r.edgeColorBy,colorScheme:n,...i})},TreeDiagram:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"cluster"===r.layout?"cluster":"tree",data:e,childrenAccessor:r.childrenAccessor,colorBy:t,colorByDepth:r.colorByDepth,orientation:r.orientation,showLabels:r.showLabels,colorScheme:n,...i})},Treemap:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"treemap",data:e,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:t,colorByDepth:r.colorByDepth,showLabels:r.showLabels,colorScheme:n,...i})},CirclePack:{frameType:"network",buildProps:(e,t,n,i,r)=>({chartType:"circlepack",data:e,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:t,colorByDepth:r.colorByDepth,colorScheme:n,...i})},ChoroplethMap:{frameType:"geo",buildProps:(e,t,n,i,r)=>({areas:r.areas,projection:r.projection||"equalEarth",areaStyle:r.areaStyle,valueAccessor:r.valueAccessor,colorScheme:n||"blues",graticule:r.graticule,fitPadding:r.fitPadding,...i})},ProportionalSymbolMap:{frameType:"geo",buildProps:(e,t,n,i,r)=>({points:e||r.points,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle,sizeBy:r.sizeBy,colorBy:t,colorScheme:n,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,...i})},FlowMap:kc,GeoCustomChart:{frameType:"geo",buildProps:(e,t,n,i,r)=>({points:r.points||e||[],areas:r.areas||[],lines:r.lines||[],projection:r.projection||"equirectangular",xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",lineDataAccessor:r.lineDataAccessor,colorBy:t,colorScheme:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...i})},GaltonBoardChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[600,400],s=r.bins??21,a=r.seed??1,c=Math.max(1,Math.round(r.pegRows??s-1)),l="mechanical"===r.mode,u=l?function(e){const t=Math.max(2,Math.round(e.bins)),n=Math.max(1,Math.round(e.pegRows??t-1)),i=Math.max(1,Math.round(e.count??Math.max(64,4*t))),r=Cc(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),o=Rc(e.seed??1),s=e.idPrefix??"mechanical";return Array.from({length:i},(e,t)=>{let i=0;for(let e=0;n>e;e+=1)o()<r&&(i+=1);const a=n/2;return{id:`${s}-${t}`,value:i,mechanical:!0,pegRows:n,branchProbability:r,pathRights:i,side:a>i?"left":i>a?"right":"center"}})}({bins:s,branchProbability:r.branchProbability,count:r.mechanicalCount,pegRows:c,seed:a}):Array.isArray(e)?e:[],d=function(e){const{data:t,valueAccessor:n,bins:i,ballRadius:r,seed:o,size:s,valueExtent:a}=e,c=Sc(s),l=t.map((e,t)=>jc(_c(e,t,n))).filter(e=>null!=e),u=function(e){if(!e)return;const t=jc(e[0]),n=jc(e[1]);return null!=t&&null!=n?t>n?[n,t]:[t,n]:void 0}(a),d=u?.[0]??(l.length?Math.min(...l):0),h=u?.[1]??(l.length?Math.max(...l):1),f=h===d?1:h-d,p=(0,Lc.scaleLinear)().domain([0,i]).range([c.plot.x,c.plot.x+c.plot.width]),y=Array.from({length:i},()=>0),g=[];t.forEach((e,t)=>{const o=jc(_c(e,t,n));if(null==o)return;const s=Math.max(0,Math.min(i-1,Math.floor((o-d)/f*i)));y[s]+=1,g.push({id:(e.id??"galton-"+t)+"",x:p(s+.5),y:c.plot.y+r+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:r},datum:{...e,value:o,bin:s}})});const m=c.plot.y+c.plot.height;return{config:Pc(o,[...jl({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...Cl({idPrefix:"galton-bin",count:i,domainStart:0,domainStep:1,xScale:p,yTop:c.plot.y-400,yBottom:m,wallThickness:6})],"GaltonBoardChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:y.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:i,plot:c.plot,valueExtent:[d,h]}}}({data:u,valueAccessor:r.valueAccessor||"value",bins:s,ballRadius:r.ballRadius??4,seed:a,size:o,valueExtent:l?[0,c]:void 0});return{...i,config:d.config,initialSpawns:Yh(d.initialSpawns),projectionRows:d.projectionRows,bodyStyle:Mc(t||r.colorBy||(l?"side":void 0))}}},EventDropChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[600,400],s=function(e){const{data:t,timeAccessor:n,arrivalAccessor:i,windows:r,watermark:o,ballRadius:s,seed:a,size:c,timeExtent:l,timeScale:u=1}=e,d=Sc(c),h=t.map((e,t)=>jc(_c(e,t,n))).filter(e=>null!=e),f=jc(l?.[0]),p=jc(l?.[1]),y=h.length?Math.min(...h):0,g=h.length?Math.max(...h):y+r.size,m=Math.min(f??y,y),x=Math.max(p??g,g),b=Math.floor(m/r.size)*r.size,v=Math.max(1,Math.ceil((x-b+r.size)/r.size)),w=h.length?Math.max(...h):0,k="function"==typeof o?o(w):jc(o?.value)??w-(o?.delay??r.size),S=Math.max(0,Math.min(v,Array.from({length:v},(e,t)=>t).reduce((e,t)=>b+(t+1)*r.size>k?e:e+1,0))),A=function(e,t){const n=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:n,height:e.plot.height},windowPlot:{x:e.plot.x+n,y:e.plot.y,width:Math.max(40,e.plot.width-n),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}(d,s),M=b+v*r.size,P=(0,Nl.scaleLinear)().domain([b,M]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),_=Array.from({length:v},()=>({value:0,secondary:0})),j=[];t.forEach((e,t)=>{const o=jc(_c(e,t,n));if(null==o)return;const a=jc(_c(e,t,i))??o,c=Math.max(0,Math.min(v-1,Math.floor((o-b)/r.size))),l=k>=b+(c+1)*r.size;_[c].value+=l?0:1,_[c].secondary+=l?1:0,j.push({id:(e.id??"event-"+t)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,P(o))),y:d.plot.y+s+2,vx:8*(t%3-1),vy:0,mass:1,friction:.02,spawnAt:a,shape:{type:"circle",radius:s},datum:{...e,eventTime:o,arrivalTime:a,windowIndex:c,late:l}})});const C=d.plot.y+d.plot.height,I=function(e,t){const n=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!n)return[];const i=e.windowStart,r=e.windowStart+e.windowCount*e.windowSize,o=(0,Nl.scaleLinear)().domain([i,r]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),s=o(e.windowStart+n*e.windowSize),a=e.windowPlot.x,c=t+Math.max(18,Math.min(.3*e.windowPlot.height,s-a)),l=e=>s===a?t:c+(e-a)/(s-a)*(t-c),u=[];for(let t=0;n>t;t+=1){const n=e.windowStart+t*e.windowSize,i=n+e.windowSize,r=o(n),s=o(i);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:r,y1:l(r),x2:s,y2:l(s)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:d.plot,windowCount:v,windowPlot:A.windowPlot,windowSize:r.size,windowStart:b},d.plot.y+.28*d.plot.height);return{config:Pc(a,[...jl({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...Ol({idPrefix:"eventdrop-window",count:v,xScale:e=>P(b+e*r.size),yTop:A.wallTop,yTopForIndex:e=>{const t=(e=>{if(0>e||e>S)return null;const t=0===e?I[0]?.y1:I[e-1]?.y2??I[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null})(e);return null==t?A.wallTop:t+1.25*s},yBottom:C,wallThickness:6}),...I.map(e=>({id:e.id,shape:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:j,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>e.datum?.arrivalTime,timeScale:u},projectionRows:_.map((e,t)=>({label:`${b+t*r.size}-${b+(t+1)*r.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:I,lateCount:_.reduce((e,t)=>e+t.secondary,0),plot:d.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:v,windowSize:r.size,windowStart:b}}}({data:Array.isArray(e)?e:[],timeAccessor:r.timeAccessor||"time",arrivalAccessor:r.arrivalAccessor||"arrivalTime",windows:r.windows||{size:10},watermark:r.watermark,ballRadius:r.ballRadius??5,seed:r.seed??1,size:o,timeExtent:r.timeExtent,timeScale:r.timeScale??1});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Mc(t||r.colorBy)}}},PhysicsPileChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[600,400],s="mechanical"===r.mode,a=function(e){const{data:t,categoryAccessor:n,valueAccessor:i,unitValue:r,ballRadius:o,seed:s,size:a}=e,c=Ic(r,1),l=Sc(a),u=[],d=new Map,h=new Map,f=[];function p(e){let t=d.get(e);return null==t&&(t=u.length,u.push(e),d.set(e,t)),t}t.forEach((e,t)=>{p((_c(e,t,n)??"unknown")+"")});const y=Math.max(1,u.length),g=function(e,t,n){const i=e.width/Math.max(1,t),r=Math.max(2,2*n),o=Math.min(.7*i,Math.max(3.2*r,r+8)),s=Math.max(1,Math.floor(o/r));return{laneWidth:i,tubeWidth:o,ballDiameter:r,perRow:s,centerX:t=>e.x+(t+.5)*i,pileHeight:e=>Math.ceil(Math.max(0,e)/s)*r}}(l.plot,y,o),m=Math.max(0,g.tubeWidth/2-o-1),x=u.map(()=>[]);t.forEach((e,t)=>{const r=(_c(e,t,n)??"unknown")+"",s=p(r),a=i?jc(_c(e,t,i)):1,u=Math.max(0,Math.round((a??0)/c)),d=g.centerX(s);for(let n=0;u>n;n+=1){const i=h.get(r)??0,a=g.perRow>1?((g.perRow>1?i%g.perRow:0)/(g.perRow-1)*2-1)*m:0;h.set(r,i+1),x[s].push({id:`${(e.id??"pile-"+t)+""}-${n}`,x:d+a,y:l.plot.y+o+2,vx:(n%3-1)*o/2,vy:0,mass:1,shape:{type:"circle",radius:o},datum:{...e,category:r,unitIndex:n}})}});const b=x.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;b>e;e+=1)for(const t of x)t.length>e&&f.push(t[e]);const v=l.plot.y+l.plot.height,w=[...jl({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=l.plot.y-400;for(let e=0;y>e;e+=1){const t=g.centerX(e);for(const n of[-1,1])w.push({id:`pile-tube-${e}-${0>n?"l":"r"}`,shape:{type:"aabb",x:t+n*g.tubeWidth/2,y:(k+v)/2,width:6,height:v-k}})}return{config:Pc(s,w,"PhysicsPileChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(e=>({label:e,value:h.get(e)??0}))}}({data:s?function(e={}){const t=(e.categories?.length?e.categories:["Intake","Review","Build","Ship"]).map(e=>(e+"").trim()).filter(Boolean),n=t.length?t:["Intake"],i=Math.max(n.length,Math.round(e.count??Math.max(48,12*n.length))),r=Ic(e.unitValue,1),o=Rc(e.seed??1),s=e.idPrefix??"mechanical-pile",a=n.map(()=>.65+.9*o()),c=a.reduce((e,t)=>e+t,0)||1,l=i-n.length,u=a.map(e=>e/c*l),d=u.map(e=>1+Math.floor(e));let h=i-d.reduce((e,t)=>e+t,0);const f=u.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;h>0;e=(e+1)%f.length)d[f[e].index]+=1,h-=1;return n.map((e,t)=>({id:`${s}-${t}`,category:e,value:d[t]*r,mechanical:!0,unitCount:d[t],unitValue:r,share:d[t]/i}))}({categories:r.mechanicalCategories,count:r.mechanicalCount,seed:r.seed??1,unitValue:r.unitValue??1}):Array.isArray(e)?e:[],categoryAccessor:r.categoryAccessor||"category",valueAccessor:r.valueAccessor||(s?"value":void 0),unitValue:r.unitValue??1,ballRadius:r.ballRadius??5,seed:r.seed??1,size:o});return{...i,config:a.config,initialSpawns:Yh(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:Mc(t||r.colorBy||(s?"category":void 0))}}},CollisionSwarmChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[600,360],s=function(e){const{data:t,xAccessor:n,groupAccessor:i,radiusAccessor:r,pointRadius:o,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=e,d=Sc(a),h=Rc(s),f=[],p=[],y=new Map;t.forEach((e,t)=>{const s=jc(_c(e,t,n));if(null==s)return;const a=i?(_c(e,t,i)??"All")+"":"All",c=r?jc(_c(e,t,r)):null,l=Cc(null!=c&&c>0?c:o,2,18);!function(e){let t=y.get(e);null==t&&(t=p.length,p.push(e),y.set(e,t))}(a),f.push({datum:e,index:t,value:s,group:a,radius:l})});const g=f.map(e=>e.value),m=c?jc(c[0]):null,x=c?jc(c[1]):null,b=g.length?Math.min(...g):0,v=g.length?Math.max(...g):1;let w=m??b,k=x??v;if(w===k&&(w-=.5,k+=.5),w>k){const e=k;k=w,w=e}const S=Math.max(o,...f.map(e=>e.radius)),A=d.plot.x+S+8,M=d.plot.x+d.plot.width-S-8,P=(0,Wl.scaleLinear)().domain([w,k]).range([A,M]),_=Math.max(1,p.length),j=d.plot.y+Math.max(28,3*S),C=Math.max(0,d.plot.y+d.plot.height-Math.max(28,3*S)-j),I=e=>{const t=y.get(e)??0;return 1===_?d.plot.y+.54*d.plot.height:j+t/(_-1)*C},T=new Map,R=f.map((e,t)=>{T.set(e.group,(T.get(e.group)??0)+1);const n=P(e.value),i=I(e.group),r=(h()-.5)*e.radius*1.6,o=(h()-.5)*e.radius*1.6;return{id:(e.datum.id??"collision-swarm-"+t)+"",x:u?n+r:Cc(n+(t%9-4)*e.radius*2.5,A,M),y:u?i+o:d.plot.y-18-t%12*e.radius,vx:u?0:22*(h()-.5),vy:u?0:24+18*h(),mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:n,targetY:i},springs:[{target:{type:"point",x:n,y:i},restLength:0,stiffness:34,damping:5.5}]}});return{config:Pc(s,jl({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(l??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:R,projectionRows:p.map(e=>({label:e,value:T.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,M],groups:p.map(e=>({label:e,y:I(e),count:T.get(e)??0})),plot:d.plot}}}({data:Array.isArray(e)?e:[],xAccessor:r.xAccessor||"x",groupAccessor:r.groupAccessor,radiusAccessor:r.radiusAccessor,pointRadius:r.pointRadius??5,seed:r.seed??1,size:o,xExtent:r.xExtent,collisionIterations:r.collisionIterations,settle:r.settle});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Mc(t||r.colorBy||r.groupAccessor)}}},ProcessFlowChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[900,420],s=Array.isArray(r.stages)?r.stages:[],a=eu({data:Array.isArray(e)?e:[],stages:s,size:o,idAccessor:r.idAccessor,stageAccessor:r.stageAccessor||"stage",groupBy:r.groupBy,groupLabelAccessor:r.groupLabelAccessor,workAccessor:r.workAccessor,radiusAccessor:r.radiusAccessor,ballRadius:r.ballRadius??6,seed:r.seed??1,groupCompletion:r.groupCompletion,groupAnchorAlong:r.groupAnchorAlong,settle:r.settle??!0,gravityX:r.gravityX,gravityY:r.gravityY}),c=a.metadata;return{...i,config:a.config,initialSpawns:Yh(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,bodyStyle:Mc(t||r.colorBy||r.groupBy)}}},GauntletChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[900,520],s=function(e){const t=mh(e.size??[900,520],e.gates,e.crashOffset??30),n=e.positiveProperties??[],i=new Map(n.map(e=>[e.id,e])),r=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),o={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},s=(e.data??[]).map((t,s)=>{const a=kh(t,s,o,n,r);return{...a,viability:e.viability?.(a,{negativeProperties:r,positiveProperties:i})??wh(a,i,r)}}).flatMap((n,o)=>{const s=bh(n,o,t,e.projectPlacement);return Sh(n,o,t,s,i,r,e.coreBody)});return{layout:t,initialSpawns:s,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:uh(t)}}}({data:Array.isArray(e)?e:[],size:o,gates:r.gates,positiveProperties:r.positiveProperties,negativeProperties:r.negativeProperties,crashOffset:r.crashOffset,idAccessor:r.idAccessor,positiveAccessor:r.positiveAccessor,negativeAccessor:r.negativeAccessor,metricsAccessor:r.metricsAccessor,initialViability:r.initialViability,projectPlacement:r.projectPlacement,coreBody:r.coreBody,viability:r.viability});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:[],bodyStyle:Mc(t||r.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[760,420],s=function(e){const{coordinateMode:t,flowSpeed:n,links:i,maxParticles:r,nodeIdAccessor:o,nodeXAccessor:s,nodeYAccessor:a,nodes:c,particleRadius:l,particleRate:u,pathAccessor:d,pathConstraint:h="path",reducedMotion:f,seed:p,size:y,sourceAccessor:g,targetAccessor:m,throughputAccessor:x}=e,b=Sc(y),v=Rc(p),w=new Map,k=new Map,S=[];function A(e){if(e&&"object"==typeof e){const t=e;if("function"==typeof o){const e=o(t,0);if(null!=e)return e+""}if("string"==typeof o&&null!=t[o])return t[o]+"";if(null!=t.id)return t.id+""}return(e??"unknown")+""}c.forEach((e,t)=>{const n=(_c(e,t,o)??e.id??t)+"",i=jc(_c(e,t,s)),r=jc(_c(e,t,a));if(null!=i&&null!=r){const e={x:i,y:r};w.set(n,e),S.push(e)}k.set(n,(e.label??e.name??n)+"")});const M=[];i.forEach((e,t)=>{const n=A(_c(e,t,g)),i=A(_c(e,t,m)),r=Math.max(0,jc(_c(e,t,x))??0),o=Yl(d?_c(e,t,d):void 0),s=o.length?o:Yl(e.path??e.points??e.route);s.forEach(e=>S.push(e)),M.push({id:(e.id??`physical-flow-${n}-${i}-${t}`)+"",link:e,index:t,source:n,target:i,throughput:r,rawPath:s})});const P=(j=S,"normalized"===(_=t)||"pixels"===_?_:j.length>0&&j.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels");var _,j;const C=new Map;for(const[e,t]of w)C.set(e,Hl(t,b,P));const I=[];for(const e of M){let t=e.rawPath.map(e=>Hl(e,b,P));if(2>t.length){const n=C.get(e.source),i=C.get(e.target);n&&i&&(t=[n,i])}else C.has(e.source)||C.set(e.source,t[0]),C.has(e.target)||C.set(e.target,t[t.length-1]);t.length>=2&&e.throughput>0&&(k.has(e.source)||k.set(e.source,e.source),k.has(e.target)||k.set(e.target,e.target),I.push({...e,path:t,packetCount:0}))}const T=Ic(u,.12),R=Math.max(1,Math.round(r)),L=I.map(e=>Math.max(1,Math.round(e.throughput*T))),$=L.reduce((e,t)=>e+t,0),E=$>R?R/$:1;I.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(L[t]*E))});let D=I.reduce((e,t)=>e+t.packetCount,0);for(;D>R;){const e=I.reduce((e,t,n)=>t.packetCount>1&&(-1===e||t.packetCount>I[e].packetCount)?n:e,-1);if(-1===e)break;I[e].packetCount-=1,D-=1}const z=new Map,B=new Map,F=[],N=Ic(n,90),O=Ic(l,4);I.forEach((e,t)=>{z.set(e.target,(z.get(e.target)??0)+e.throughput),B.set(e.source,(B.get(e.source)??0)+e.throughput);const n=Xl(e.path);for(let i=0;e.packetCount>i;i+=1){const r=(i+.5)/e.packetCount,o=f?r:Cc(.12+.84*r+.04*(v()-.5),.04,.98),s=f?o:Math.max(0,o-(.18+.12*v())),a=Gl(e.path,s),c=Gl(e.path,o),l=Vl(e.path,s),u={x:-l.y,y:l.x},d=(v()-.5)*O*1.5;F.push({id:`${e.id}-packet-${i}`,x:a.x+u.x*d,y:a.y+u.y*d,vx:f?0:l.x*N+10*(v()-.5),vy:f?0:l.y*N+10*(v()-.5),mass:.8,spawnAt:f?0:.04*t+i/32,shape:{type:"circle",radius:O},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:i,packetCount:e.packetCount,routeProgress:o,flowPath:e.path,flowPathLength:n,flowRouteId:e.id,flowSpeed:N,sourceLabel:k.get(e.source)??e.source,targetLabel:k.get(e.target)??e.target},springs:"none"!==h&&f?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*O,stiffness:26,damping:4.25}]:void 0})}});const W=Math.max(18,5*O),q=Array.from(C,([e,t])=>({nodeId:e,label:k.get(e)??e,sensorId:"physical-flow-node-"+Tc(e),point:t})),Y=q.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:W,height:W}})),H=Object.fromEntries(q.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),X=Pc(p,[...jl({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...Y],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*O),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});X.bodyLimit=R,X.eviction="oldest",X.observation={...X.observation,sensors:H};const G=Array.from(C,([e,t])=>({id:e,label:k.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+Tc(e),incoming:z.get(e)??0,outgoing:B.get(e)??0})),V=I.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:k.get(e.source)??e.source,targetLabel:k.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:X,initialSpawns:F,projectionRows:G.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:P,particleCount:F.length,totalThroughput:I.reduce((e,t)=>e+t.throughput,0),plot:b.plot,nodes:G,links:V}}}({nodes:Array.isArray(r.nodes)?r.nodes:[],links:Array.isArray(r.links)?r.links:Array.isArray(r.edges)?r.edges:Array.isArray(e)?e:[],nodeIdAccessor:r.nodeIdAccessor||"id",nodeXAccessor:r.nodeXAccessor||"x",nodeYAccessor:r.nodeYAccessor||"y",sourceAccessor:r.sourceAccessor||"source",targetAccessor:r.targetAccessor||"target",throughputAccessor:r.throughputAccessor||"value",pathAccessor:r.pathAccessor||"path",coordinateMode:r.coordinateMode||"auto",particleRate:r.particleRate??.16,maxParticles:r.maxParticles??180,particleRadius:r.particleRadius??4,flowSpeed:r.flowSpeed??90,pathConstraint:r.pathConstraint||"path",reducedMotion:!0,seed:r.seed??1,size:o});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Mc(t||r.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(e,t,n,i,r)=>{const o=i.size??[700,380],s=oh({chartId:r.chartId,colorScheme:n,config:r.config,data:Array.isArray(e)?e:[],layout:r.layout,layoutConfig:r.layoutConfig,semantic:xe(we)??{},size:o,themeCategorical:we.colors.categorical,xExtent:r.xExtent,yExtent:r.yExtent});return{...i,config:s.config,initialSpawns:Yh(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??Mc(t||r.colorBy)}}}};function Xh(e){if(!e)return we;if("string"==typeof e){if("light"===e)return we;if("dark"===e)return ke;if("high-contrast"===e)return Se;return ga[e]||we}const t="dark"===e.mode?ke:we;return be({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}})}function Gh(e){return{background:e.colors.background,text:e.colors.text,textSecondary:e.colors.textSecondary,grid:e.colors.grid,border:e.colors.border,primary:e.colors.primary,fontFamily:e.typography.fontFamily,titleSize:e.typography.titleSize,labelSize:e.typography.labelSize,tickSize:e.typography.tickSize,categorical:e.colors.categorical,annotation:e.colors.annotation??e.colors.text,legendSize:e.typography.legendSize??e.typography.labelSize,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}function Vh(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Uh(e){if(!e||2>e.length)return;const t=Vh(e[0]),n=Vh(e[e.length-1]);return null!==t&&null!==n?[t,n]:void 0}function Kh(e){const{count:t,byType:n}=function(e){const t={};for(const n of e){const e="string"==typeof n?.type&&n.type.length>0?n.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}(e.marks),i=0===t,r=[...e.extraWarnings??[]];return i&&!r.includes("EMPTY_SCENE")&&r.push("EMPTY_SCENE"),{component:"",frameType:e.frameType,status:i?"empty":"ok",empty:i,markCount:t,markCountByType:n,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:Array.isArray(e.annotations)?e.annotations.length:0,ariaLabel:"string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,warnings:r}}var Zh=c(require("react")),Qh=c(require("react-dom/server")),Jh=require("d3-scale"),ef=require("react/jsx-runtime"),tf=14,nf=20,rf=6,of=8;function sf(e){return"left"===e?"start":"right"===e?"end":e??"start"}function af(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function cf(e,t,n,i){const r=af(i);return t+n+Math.ceil(e.length*r*.58)}function lf(e){const{categories:t,theme:n,position:i="right",totalWidth:r,totalHeight:o,margin:s,legendLayout:a}=e,c=Math.max(1,a?.swatchSize??tf),l=Math.max(0,a?.labelGap??rf),u=Math.max(0,a?.itemGap??of),d=Math.max(c,a?.rowHeight??nf),h=c+l,f=Math.min(2,c/2),p="top"===i||"bottom"===i,y=Math.max(c,r-s.left-s.right),g=Math.max(d,o-s.top-s.bottom),m=t.map(e=>cf(e,c,l,n));if(p){const e=Math.max(c,a?.maxWidth??y),n=[];let i=0,r=0;m.forEach((t,o)=>{const s=0===r?t:r+u+t;r>0&&s>e?(n.push({start:i,end:o,width:r}),i=o,r=t):r=s}),t.length>0&&n.push({start:i,end:t.length,width:r});const o=sf(a?.align),s=[];return n.forEach((n,i)=>{let r="center"===o?Math.max(0,(e-n.width)/2):"end"===o?Math.max(0,e-n.width):0;for(let e=n.start;n.end>e;e++)s.push({category:t[e],width:m[e],x:r,y:i*d}),r+=m[e]+u}),{items:s,width:Math.max(0,...n.map(e=>e.width)),height:n.length*d,swatchSize:c,labelOffset:h,swatchRadius:f}}const x=Math.max(0,...m),b=Math.max(1,Math.floor(g/d)),v=Math.max(1,Math.ceil(t.length/b));return{items:t.map((e,t)=>({category:e,width:m[t],x:Math.floor(t/b)*(x+u),y:t%b*d})),width:v*x+Math.max(0,v-1)*u,height:Math.min(t.length,b)*d,swatchSize:c,labelOffset:h,swatchRadius:f}}function uf(e){const{legendGroups:t,theme:n,position:i="right",totalWidth:r,totalHeight:o,margin:s,legendLayout:a}=e,c=Math.max(1,a?.swatchSize??tf),l=Math.max(0,a?.labelGap??rf),u=Math.max(0,a?.itemGap??of),d=Math.max(c,a?.rowHeight??nf),h=c+l,f=Math.min(2,c/2),p=Math.max(12,af(n)),y="top"===i||"bottom"===i,g=Math.max(c,r-s.left-s.right),m=Math.max(d,o-s.top-s.bottom);if(y){const i=Math.max(c,a?.maxWidth??g),r=sf(a?.align);let o=0,s=0;const l=[];for(const r of t){const t=r.items.map(e=>e.label),u=lf({...e,categories:t,legendLayout:{...a,maxWidth:Math.max(c,i-p-8),align:"start"}}),d=r.label?p:0,h=r.label?cf(r.label,0,0,n):0,f=d>0?d+8:0,y=f+u.width,g=Math.max(u.height,h);l.push({group:r,x:o,y:0,itemOffsetX:f,itemOffsetY:0,width:y,height:g,items:u.items}),o+=y+12,s=Math.max(s,g)}const u=l.length>0?o-12:0,d=u>i?0:"center"===r?Math.max(0,(i-u)/2):"end"===r?Math.max(0,i-u):0;return{groups:l.map(e=>({...e,x:e.x+d})),width:u,height:s,swatchSize:c,labelOffset:h,swatchRadius:f}}let x=0,b=0;const v=[];for(const e of t){const t=e.items.map(e=>e.label).map(e=>cf(e,c,l,n)),i=Math.max(0,...t),r=Math.max(1,Math.min(e.items.length||1,Math.max(1,Math.floor(Math.max(d,m-x)/d)))),o=Math.max(1,Math.ceil(e.items.length/r)),s=e.items.map((e,n)=>({category:e.label,width:t[n],x:Math.floor(n/r)*(i+u),y:n%r*d})),a=o*i+Math.max(0,o-1)*u,h=Math.min(e.items.length,r)*d,f=e.label?cf(e.label,0,0,n):0,y=e.label?p+8:0,g=y+h+12,w=Math.max(a,f);v.push({group:e,x:0,y:x,itemOffsetX:0,itemOffsetY:y,width:w,height:g,items:s}),b=Math.max(b,w),x+=g}return{groups:v,width:b,height:Math.max(0,x),swatchSize:c,labelOffset:h,swatchRadius:f}}function df(e){const t="top"===e.position||"bottom"===e.position,n=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??n,200),height:e.gradient.label?34:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?124:108,swatchSize:14}}function hf(e){const{categories:t,colorScheme:n,theme:i,position:r="right",totalWidth:o,totalHeight:s,margin:a,hasTitle:c=!1}=e;if(!t||0===t.length)return null;const l=function(e,t,n){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>E(e,t)??"#999"}const i=Array.isArray(t)?t:n.colors.categorical.length>0?n.colors.categorical:g;return(0,Jh.scaleOrdinal)().domain(e).range(i)}(t,n,i),u="top"===r||"bottom"===r,d=lf(e);let h,f;if("left"===r?(h=Math.max(4,a.left-d.width-10),f=a.top):"top"===r?(h=a.left,f=c?32:8):"bottom"===r?(h=a.left,f=Math.min(s-a.bottom+38,s-d.height-2)):(h=Math.min(o-d.width-4,o-a.right+10),f=a.top),u){const e=d.items.map((e,t)=>(0,ef.jsxs)("g",{transform:`translate(${e.x},${e.y})`,children:[(0,ef.jsx)("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),(0,ef.jsx)("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:af(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return(0,ef.jsx)("g",{className:"semiotic-legend",transform:`translate(${h},${f})`,children:e})}const p=d.items.map((e,t)=>(0,ef.jsxs)("g",{transform:`translate(${e.x},${e.y})`,children:[(0,ef.jsx)("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),(0,ef.jsx)("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:af(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return(0,ef.jsx)("g",{className:"semiotic-legend",transform:`translate(${h},${f})`,children:p})}function ff(e,t){if(!t||!e||0===e.length)return[];const n="function"==typeof t?t:e=>e[t],i=new Set;for(const t of e){const e=n(t);null!=e&&i.add(e+"")}return Array.from(i)}var pf=require("react/jsx-runtime");function yf(e,t){return e.color||t.colors.annotation||t.colors.text}function gf(e,t,n){return null!=e.x&&t.x?t.x(e.x):n&&null!=e[n]&&t.x?t.x(e[n]):"number"==typeof e.x?e.x:null}function mf(e,t,n){return null!=e.y&&t.y?t.y(e.y):n&&null!=e[n]&&t.y?t.y(e[n]):"number"==typeof e.y?e.y:null}function xf(e){const{annotations:t}=e;if(!t||0===t.length)return null;const n=e.autoPlaceAnnotations?Mr({annotations:t,context:{scales:{x:e.scales.x,y:e.scales.y,time:e.scales.x,value:e.scales.y,o:e.scales.o,geoProjection:e.scales.geoProjection},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,frameType:e.projection?"ordinal":"xy",projection:"horizontal"===e.projection?"horizontal":"vertical"},..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):t,i=[];for(let t=0;n.length>t;t++){const r=bf(n[t],t,e);r&&i.push({node:r,annotation:n[t]})}const r=Ui(i);return r.length>0?(0,pf.jsx)("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:r}):null}function bf(e,t,n){const{scales:i,layout:r,theme:o,xAccessor:s,yAccessor:a}=n;switch(e.type){case"y-threshold":{const s=e.value;if(null==s)return null;const a=yf(e,o),c=e.label,l=e.labelPosition||"right",u=e.strokeDasharray||"6,4",d=e.strokeWidth??1.5;if("horizontal"===n.projection&&i.r){const n=i.r(s);return null==n?null:(0,pf.jsxs)("g",{opacity:e.opacity,children:[(0,pf.jsx)("line",{x1:n,y1:0,x2:n,y2:r.height,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&(0,pf.jsx)("text",{x:n+4,y:12,textAnchor:"start",fontSize:o.typography.tickSize,fill:a,fontFamily:o.typography.fontFamily,children:c})]},"ann-ythresh-"+t)}const h=i.y?i.y(s):i.r?i.r(s):null;return null==h?null:(0,pf.jsxs)("g",{children:[(0,pf.jsx)("line",{x1:0,y1:h,x2:r.width,y2:h,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&(0,pf.jsx)("text",{x:"left"===l?4:"center"===l?r.width/2:r.width-4,y:h-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:o.typography.tickSize,fill:a,fontFamily:o.typography.fontFamily,children:c})]},"ann-ythresh-"+t)}case"x-threshold":{const n=e.value;if(null==n||!i.x)return null;const s=i.x(n);if(null==s)return null;const a=yf(e,o),c=e.label,l=e.labelPosition||"top";return(0,pf.jsxs)("g",{opacity:e.opacity,children:[(0,pf.jsx)("line",{x1:s,y1:0,x2:s,y2:r.height,stroke:a,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||"6,4"}),c&&(0,pf.jsx)("text",{x:s>.6*r.width?s-4:s+4,y:"bottom"===l?r.height-4:"center"===l?r.height/2:12,textAnchor:s>.6*r.width?"end":"start",fontSize:o.typography.tickSize,fill:a,fontFamily:o.typography.fontFamily,stroke:o.colors.background,strokeWidth:3,paintOrder:"stroke",children:c})]},"ann-xthresh-"+t)}case"band":{const n=null!=e.y0&&i.y?i.y(e.y0):null,s=null!=e.y1&&i.y?i.y(e.y1):null;if(null==n||null==s)return null;const a=Math.min(n,s),c=Math.abs(s-n),l=e.fill||yf(e,o);return(0,pf.jsxs)("g",{opacity:e.opacity,children:[(0,pf.jsx)("rect",{x:0,y:a,width:r.width,height:c,fill:l,fillOpacity:e.fillOpacity??.1}),e.label&&(0,pf.jsx)("text",{x:r.width-4,y:Math.max(a,0)+13,textAnchor:"end",fontSize:o.typography.tickSize,fill:e.color||yf(e,o),fontFamily:o.typography.fontFamily,fontWeight:"bold",stroke:o.colors.background,strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-band-"+t)}case"x-band":{const n=null!=e.x0&&i.x?i.x(e.x0):null,s=null!=e.x1&&i.x?i.x(e.x1):null;if(null==n||null==s)return null;const a=Math.min(n,s),c=Math.abs(s-n),l=e.fill||yf(e,o);return(0,pf.jsxs)("g",{opacity:e.opacity,children:[(0,pf.jsx)("rect",{x:a,y:0,width:c,height:r.height,fill:l,fillOpacity:e.fillOpacity??.1}),e.label&&(0,pf.jsx)("text",{x:a+4,y:13,textAnchor:"start",fontSize:o.typography.tickSize,fill:e.color||yf(e,o),fontFamily:o.typography.fontFamily,fontWeight:"bold",stroke:o.colors.background,strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-xband-"+t)}case"category-highlight":{if(!e.category||!i.o)return null;const s=i.o(e.category);if(null==s)return null;const a=i.o.bandwidth?i.o.bandwidth():40,c=yf(e,o),l=e.opacity??.1;return(0,pf.jsx)("rect","horizontal"===n.projection?{x:0,y:s,width:r.width,height:a,fill:c,opacity:l}:{x:s,y:0,width:a,height:r.height,fill:c,opacity:l},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:n,y:r}=function(e,t,n,i){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){const n=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(n)return{x:n[0],y:n[1]}}return{x:gf(e,t,n),y:mf(e,t,i)}}(e,i,s,a);if(null==n||null==r)return null;const c="text"===e.type,l=e.dx??(c?0:30),u=e.dy??(c?0:-30),d=e.color||o.colors.text;if(!c){const i="callout"===e.type?"callout-circle":e.type,o="callout-circle"===i?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===i?{width:e.width,height:e.height}:void 0;return(0,pf.jsx)(Ai,{noteData:{x:n,y:r,dx:l,dy:u,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:i,...o?{subject:o}:{},connector:e.connector||{end:"arrow"},color:d,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}return(0,pf.jsx)("g",{children:(0,pf.jsx)("text",{x:n+l,y:r+u,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||o.typography.labelSize,fill:d,fontFamily:o.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}var vf=require("react/jsx-runtime");function wf(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function kf(e,t){if(0===t.categories.length)return;const n=t.position||"right",i=function(e){const{width:t,height:n,swatchSize:i}=lf(e);return{width:t,height:n,swatchSize:i}}({categories:t.categories,colorScheme:t.colorScheme,theme:t.theme,position:n,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout});"right"===n?e.right=Math.max(e.right,i.width+14):"left"===n?e.left=Math.max(e.left,i.width+14):"top"===n?e.top=Math.max(e.top,(t.hasTitle?32:8)+i.height+4):e.bottom=Math.max(e.bottom,38+i.height+4)}function Sf(e,t){const n=t.position||"right",i={theme:t.theme,position:n,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout},r=oi(t.legend)?function(e){const{width:t,height:n,swatchSize:i}=uf(e);return{width:t,height:n,swatchSize:i}}({...i,legendGroups:t.legend.legendGroups}):si(t.legend)?df({...i,gradient:t.legend.gradient}):null;r&&("right"===n?e.right=Math.max(e.right,r.width+14):"left"===n?e.left=Math.max(e.left,r.width+14):"top"===n?e.top=Math.max(e.top,(t.hasTitle?32:8)+r.height+4):e.bottom=Math.max(e.bottom,38+r.height+4))}function Af(e,t){const n={theme:t.theme,position:t.position||"right",totalWidth:t.size[0],totalHeight:t.size[1],margin:t.margin,hasTitle:t.hasTitle,legendLayout:t.legendLayout,idPrefix:t.idPrefix};return oi(e)?function(e){if(0===(t=e.legendGroups,t.flatMap(e=>e.items.map((t,n)=>({group:e,item:t,itemIndex:n,label:t.label})))).length)return null;var t;const n=uf(e),i="top"===e.position||"bottom"===e.position,r=e.theme.colors.grid||e.theme.colors.textSecondary;let o,s;"left"===e.position?(o=Math.max(4,e.margin.left-n.width-10),s=e.margin.top):"top"===e.position?(o=e.margin.left,s=e.hasTitle?32:8):"bottom"===e.position?(o=e.margin.left,s=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-n.height-2)):(o=Math.min(e.totalWidth-n.width-4,e.totalWidth-e.margin.right+10),s=e.margin.top);const a=n.groups.flatMap((t,o)=>{const{group:s}=t,a=s.type??"fill",c=[];if(s.label&&c.push((0,ef.jsx)("text",i?{transform:`translate(${t.x},${t.y}) rotate(90)`,textAnchor:"start",fontSize:af(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:s.label}:{x:t.x,y:t.y+af(e.theme),fontSize:af(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:s.label},"legend-group-label-"+o)),c.push(...t.items.map((i,r)=>{const c=s.items[r],l=s.styleFn(c,r),u="function"==typeof a?a(c):"line"===a?(0,ef.jsx)("line",{x1:0,y1:0,x2:n.swatchSize,y2:n.swatchSize,style:l}):(0,ef.jsx)("rect",{width:n.swatchSize,height:n.swatchSize,rx:n.swatchRadius,style:l});return(0,ef.jsxs)("g",{transform:`translate(${t.x+t.itemOffsetX+i.x},${t.y+t.itemOffsetY+i.y})`,children:[u,(0,ef.jsx)("text",{x:n.labelOffset,y:n.swatchSize/2,dominantBaseline:"central",fontSize:af(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.category})]},`legend-${o}-${r}`)})),!i&&n.groups.length-1>o)c.push((0,ef.jsx)("line",{x1:0,y1:t.y+t.height-6,x2:n.width,y2:t.y+t.height-6,stroke:r},"legend-group-separator-"+o));else if(i&&n.groups.length-1>o){const e=t.x+t.width+6;c.push((0,ef.jsx)("line",{x1:e,y1:0,x2:e,y2:n.height,stroke:r},"legend-group-separator-"+o))}return c});return(0,ef.jsx)("g",{className:"semiotic-legend",transform:`translate(${o},${s})`,"data-orientation":i?"horizontal":"vertical",children:a})}({...n,legendGroups:e.legendGroups}):si(e)?function(e){const t=df(e),n="top"===e.position||"bottom"===e.position,i=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",r=e.gradient.format||(e=>Math.round(100*e)/100+"");let o,s;"left"===e.position?(o=Math.max(4,e.margin.left-t.width-10),s=e.margin.top):"top"===e.position?(o=e.margin.left,s=e.hasTitle?32:8):"bottom"===e.position?(o=e.margin.left,s=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-t.height-2)):(o=Math.min(e.totalWidth-t.width-4,e.totalWidth-e.margin.right+10),s=e.margin.top);const a=Array.from({length:17},(t,i)=>{const r=i/16;return(0,ef.jsx)("stop",{offset:100*r+"%",stopColor:e.gradient.colorFn(n?e.gradient.domain[0]+r*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-r*(e.gradient.domain[1]-e.gradient.domain[0]))},i)});if(n){const n=12,c=e.gradient.label?0:void 0,l=e.gradient.label?8:0;return(0,ef.jsxs)("g",{className:"semiotic-legend",transform:`translate(${o},${s})`,children:[(0,ef.jsx)("defs",{children:(0,ef.jsx)("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),e.gradient.label&&(0,ef.jsx)("text",{x:t.width/2,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),(0,ef.jsx)("rect",{x:0,y:l,width:t.width,height:n,fill:`url(#${i})`,rx:2}),(0,ef.jsx)("text",{x:0,y:l+n+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[0])}),(0,ef.jsx)("text",{x:t.width,y:l+n+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[1])})]})}const c=e.gradient.label?-6:void 0;return(0,ef.jsxs)("g",{className:"semiotic-legend",transform:`translate(${o},${s+(e.gradient.label?12:0)})`,children:[(0,ef.jsx)("defs",{children:(0,ef.jsx)("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),e.gradient.label&&(0,ef.jsx)("text",{x:7,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),(0,ef.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${i})`,rx:2}),(0,ef.jsx)("text",{x:19,y:10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[1])}),(0,ef.jsx)("text",{x:19,y:100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[0])})]})}({...n,gradient:e.gradient}):null}function Mf(e){return Math.round(100*e)/100+""}function Pf(e,t){const n=Gh(t.theme),i=t.idPrefix?t.idPrefix+"-":"",r="string"==typeof t.title?t.title:void 0,o=r?i+"semiotic-title":void 0,s=t.description?i+"semiotic-desc":void 0,a=[o,s].filter(Boolean).join(" ")||void 0;return(0,vf.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":a,style:{fontFamily:n.fontFamily},children:[r&&(0,vf.jsx)("title",{id:o,children:r}),t.description&&(0,vf.jsx)("desc",{id:s,children:t.description}),t.defs&&(0,vf.jsx)("defs",{children:t.defs}),t.background&&"transparent"!==t.background&&(0,vf.jsx)("rect",{x:0,y:0,width:t.width,height:t.height,fill:t.background}),(0,vf.jsx)("g",{id:i+"data-area",transform:t.innerTransform,children:e}),r&&(0,vf.jsx)("text",{id:i+"chart-title",x:t.width/2,y:16,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily,children:r}),t.legend&&(0,vf.jsx)("g",{id:i+"legend",children:t.legend}),t.outerElements]})}var _f=require("react/jsx-runtime");function jf(e,t){const n=Xh(e.theme),i=e.size||[500,300],r={top:20,right:20,bottom:30,left:40,...e.margin},o=B(e.data),s=e.showLegend?ff(o,e.colorAccessor||e.groupAccessor):[],a=e.legendPosition;oi(e.legend)||si(e.legend)?Sf(r,{legend:e.legend,theme:n,position:a||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&s.length>0&&kf(r,{categories:s,colorScheme:e.colorScheme,theme:n,position:a||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout});const c=i[0]-r.left-r.right,l=i[1]-r.top-r.bottom,u="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),d=e.colorScheme||n.colors.categorical,h={chartType:e.chartType,windowSize:e.windowSize??200,windowMode:e.windowMode??"sliding",arrowOfTime:u?e.arrowOfTime??"right":"right",extentPadding:e.extentPadding??.1,xAccessor:u?void 0:e.xAccessor,yAccessor:u?void 0:e.yAccessor,timeAccessor:u?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,stackOrder:e.stackOrder,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:!0===e.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===e.gradientFill?void 0:e.gradientFill,lineGradient:e.lineGradient,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,barStyle:e.barStyle,waterfallStyle:e.waterfallStyle,swarmStyle:e.swarmStyle,colorScheme:d,themeCategorical:n.colors.categorical,themeSemantic:xe(n),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,layoutSelection:e.layoutSelection,barColors:e.barColors},f=new Ot(h);if(e.data&&f.ingest({inserts:o,bounded:!0}),f.computeScene({width:c,height:l}),!f.scales||0===f.scene.length)return t&&(t.evidence=Kh({frameType:"xy",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),Qh.renderToStaticMarkup(Pf(null,{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,idPrefix:e._idPrefix}));t&&(t.evidence=Kh({frameType:"xy",width:i[0],height:i[1],marks:f.scene,title:e.title,description:e.description,annotations:e.annotations,xDomain:Uh(f.scales.x?.domain?.()),yDomain:Uh(f.scales.y?.domain?.()),legendItems:s.length>0?s.length:void 0}));const p=e._idPrefix,y=e.showGrid?function(e,t,n,i){const{grid:r}=Gh(n),o=i?i+"-":"",s=e.x.ticks(5),a=e.y.ticks(5);return(0,vf.jsxs)("g",{id:o+"grid",className:"semiotic-grid",opacity:.8,children:[s.map((n,i)=>{const o=e.x(n);return(0,vf.jsx)("line",{x1:o,y1:0,x2:o,y2:t.height,stroke:r,strokeWidth:.5},"gx-"+i)}),a.map((n,i)=>{const o=e.y(n);return(0,vf.jsx)("line",{x1:0,y1:o,x2:t.width,y2:o,stroke:r,strokeWidth:.5},"gy-"+i)})]})}(f.scales,{width:c,height:l},n,p):null,g=f.scene.map((e,t)=>so(e,t,p)).filter(Boolean),m=!1!==e.showAxes?function(e,t,n,i,r){const o=Gh(i),s=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(n.xFormat||n.tickFormatTime||Mf)(t)})),a=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(n.yFormat||n.tickFormatValue||Mf)(t)}));return(0,vf.jsxs)("g",{id:(r?r+"-":"")+"axes",className:"stream-axes",children:[(0,vf.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:o.border,strokeWidth:1}),s.map((e,n)=>(0,vf.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,vf.jsx)("line",{y2:5,stroke:o.border,strokeWidth:1}),(0,vf.jsx)("text",{y:18,textAnchor:"middle",fontSize:o.tickSize,fill:o.textSecondary,fontFamily:o.fontFamily,children:e.label})]},"xtick-"+n)),n.xLabel&&(0,vf.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:o.labelSize,fill:o.text,fontFamily:o.fontFamily,children:n.xLabel}),(0,vf.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:o.border,strokeWidth:1}),a.map((e,t)=>(0,vf.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,vf.jsx)("line",{x2:-5,stroke:o.border,strokeWidth:1}),(0,vf.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o.tickSize,fill:o.textSecondary,fontFamily:o.fontFamily,children:e.label})]},"ytick-"+t)),n.yLabel&&(0,vf.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:o.labelSize,fill:o.text,fontFamily:o.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:n.yLabel})]})}(f.scales,{width:c,height:l},e,n,p):null,x=e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{x:f.scales.x,y:f.scales.y},layout:{width:c,height:l},theme:n,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:p}):null,b=e.svgPreRenderers&&f.scales?e.svgPreRenderers.map((e,t)=>{try{return(0,_f.jsx)(Zh.Fragment,{children:e(f.scene,f.scales,{width:c,height:l})},"pre-"+t)}catch{return null}}).filter(Boolean):null,v=e.showLegend?0===s.length?null:hf({categories:s,colorScheme:e.colorScheme,theme:n,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,w=Zh.isValidElement(e.legend)?e.legend:Af(e.legend,{theme:n,position:e.legendPosition||"right",size:i,margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||v;return Qh.renderToStaticMarkup(Pf((0,_f.jsxs)(_f.Fragment,{children:[e.backgroundGraphics,b,y,g,m,x,e.foregroundGraphics,f.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,legend:w,idPrefix:e._idPrefix}))}var Cf=c(require("react")),If=c(require("react-dom/server")),Tf=require("d3-scale");function Rf(e){const t=e.getSymbol;if(!t)return null;const n=e.config.symbolMap,i=new Map;let r=0;return e=>{const o=t(e)+"",s=n?.[o];if(s)return s;let a=i.get(o);return a||(a=dt[r%dt.length],r++,i.set(o,a)),a}}function Lf(e,t,n,i,r,o,s){e.push(t?{type:"symbol",x:i,y:r,size:Math.PI*o*o,symbolType:t(n),style:s,datum:n}:{type:"point",x:i,y:r,r:o,style:s,datum:n})}function $f(e,t){const{columns:n,config:i,resolvePieceStyle:r}=e,o=[],s=Math.min(t.width,t.height)/2-4,a="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,l=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,u=null!=i.sweepAngle&&360>i.sweepAngle,d=Object.values(n),h=d.some(e=>{const t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),f=u&&!h&&d.length>1&&(i.cornerRadius??0)>0;for(let e=0;d.length>e;e++){const t=d[e],n=t.pieceData[0],u="number"==typeof n?._pctStart?n._pctStart:t.pctStart,h=c+u*l,p=c+(u+("number"==typeof n?._pct?n._pct:t.pct))*l,y=r(t.pieceData[0],t.name),g=0===e,m=e===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:h,endAngle:p,...i.cornerRadius&&{cornerRadius:i.cornerRadius},style:y,datum:n?._nonInteractive?null:t.pieceData,category:t.name};n?._roundedEnds?x.roundedEnds=n._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),n?._gradientBand&&(x._gradientBand=n._gradientBand),o.push(x)}return o}var Ef=require("d3-array");function Df(e){const t=e.length,n=e[0],i=e[t-1];return{n:t,min:n,q1:(0,Ef.quantile)(e,.25)??n,median:(0,Ef.quantile)(e,.5)??(n+i)/2,q3:(0,Ef.quantile)(e,.75)??i,max:i,mean:e.reduce((e,t)=>e+t,0)/t}}var zf=require("d3-scale"),Bf={bar:function(e,t){const{scales:n,columns:i,config:r,getR:o,getStack:s,resolvePieceStyle:a}=e,{r:c,projection:l}=n,u=[],d="vertical"===l,h="horizontal"===l,f=r.normalize,p=[];if(s){const e=new Set;for(const t of Object.values(i))for(const n of t.pieceData){const t=s(n);e.has(t)||(e.add(t),p.push(t))}}else p.push("_default");for(const e of Object.values(i)){const t=new Map;for(const n of e.pieceData){const e=s?s(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e);i.total+=o(n),i.pieces.push(n)}let n=0;if(f)for(const e of t.values())n+=Math.abs(e.total);let i=0,r=0;for(const o of p){const l=t.get(o);if(!l)continue;let p=l.total;f&&n>0&&(p/=n);const y=a(l.pieces[0],s?o:e.name),g={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:e.name};if(d){const t=c(0>p?r:i+p),n=0>p?c(r+p)-c(r):c(i)-c(i+p);u.push(Qe(e.x,t,e.width,Math.abs(n),y,g,o)),0>p?r+=p:i+=p}else if(h){const t=c(0>p?r+p:i),n=0>p?c(r)-c(r+p):c(i+p)-c(i);u.push(Qe(t,e.x,Math.abs(n),e.width,y,g,o)),0>p?r+=p:i+=p}}}const y="vertical"===l,g=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;const t=e.datum?.__aggregateValue??0;e.roundedEdge=y?0>t?"bottom":"top":0>t?"left":"right",r.gradientFill&&(e.fillGradient=r.gradientFill)}if(g>0){const e=new Map;for(const t of u){if("rect"!==t.type)continue;const n=t.datum?.category||"";e.has(n)||e.set(n,[]),e.get(n).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),n=t.filter(e=>0>(e.datum?.__aggregateValue??0));e.length>0&&(e.reduce(y?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=g),n.length>0&&(n.reduce(y?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=g)}}return u},clusterbar:function(e,t){const{scales:n,columns:i,config:r,getR:o,getGroup:s,resolvePieceStyle:a}=e,{r:c,projection:l}=n,u=[],d="vertical"===l,h=[],f=new Set;for(const e of Object.values(i))for(const t of e.pieceData){const e=s?s(t):"_default";f.has(e)||(f.add(e),h.push(e))}const p=h.length||1;for(const e of Object.values(i)){const t=e.width/p,n=.2*t,i=t-n,r=new Map;for(const t of e.pieceData){const e=s?s(t):"_default";r.has(e)||r.set(e,[]),r.get(e).push(t)}for(let s=0;h.length>s;s++){const l=r.get(h[s])||[];for(const r of l){const l=o(r),f=a(r,h[s]);if(d){const o=e.x+s*t+n/2,a=c(0),d=c(l);u.push(Qe(o,Math.min(a,d),i,Math.abs(a-d),f,r,h[s]))}else{const o=e.x+s*t+n/2,a=c(0),d=c(l);u.push(Qe(Math.min(a,d),o,Math.abs(d-a),i,f,r,h[s]))}}}}const y=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;if(null==e.datum)continue;const t=o(e.datum);y>0&&(e.roundedTop=y),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",r.gradientFill&&(e.fillGradient=r.gradientFill)}return u},point:function(e,t){const{scales:n,columns:i,getR:r,multiScales:o,resolvePieceStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d="radial"===c,h=o.length>0,f=Rf(e),p=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const n=t.__rIndex??0,i=t.__rValue??r(t),c=h&&o[n]||a,g=s(t,e.name),m=g.r||5;let x,b;if(d){const t=y+(e.pctStart+e.pct/2)*p,n=c(i);x=Math.cos(t)*n,b=Math.sin(t)*n}else u?(x=e.middle,b=c(i)):(x=c(i),b=e.middle);Lf(l,f,t,x,b,m,g)}return l},swarm:function(e,t){const{scales:n,columns:i,getR:r,resolvePieceStyle:o}=e,{r:s,projection:a}=n,c=[],l="vertical"===a,u=Rf(e);for(const e of Object.values(i)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const i=e.pieceData[n],a=r(i),d=o(i,e.name),h=d.r||4,f=(7919*n%100/100-.5)*t*.8;Lf(c,u,i,l?e.middle+f:s(a),l?s(a):e.middle+f,h,d)}}return c},pie:$f,donut:$f,boxplot:function(e,t){const{scales:n,columns:i,config:r,getR:o,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d=!1!==r.showOutliers;for(const t of Object.values(i)){const n=t.pieceData.map(e=>o(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===n.length)continue;const i=n[0],r=n[n.length-1],c=(0,Ef.quantile)(n,.25)??i,h=(0,Ef.quantile)(n,.5)??(i+r)/2,f=(0,Ef.quantile)(n,.75)??r,p=f-c,y=c-1.5*p,g=f+1.5*p,m=n.find(e=>e>=y)??i,x=[...n].reverse().find(e=>g>=e)??r,b=s(t.pieceData[0],t.name),v=[];if(d)for(const e of t.pieceData){const n=o(e);if(y>n||n>g){const i=u?t.middle:a(n),r=u?a(n):t.middle;v.push({px:i,py:r,value:n,datum:e})}}if(l.push({type:"boxplot",x:u?t.middle:0,y:u?0:t.middle,projection:u?"vertical":"horizontal",columnWidth:.6*t.width,minPos:a(m),q1Pos:a(c),medianPos:a(h),q3Pos:a(f),maxPos:a(x),stats:{n:n.length,min:m,q1:c,median:h,q3:f,max:x,mean:n.reduce((e,t)=>e+t,0)/n.length},style:b,datum:t.pieceData,category:t.name,outliers:v}),d)for(const t of v)l.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:b.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6},datum:t.datum})}return l},violin:function(e,t){const{scales:n,columns:i,config:r,getR:o,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d=r.bins||20,h=!1!==r.showIQR;for(const e of Object.values(i)){const t=e.pieceData.map(e=>o(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],i=t[t.length-1],r=(i-n)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-n)/r),d-1)]++;const f=hi(c,1),p=e.width/2*.9;let y;if(u){y=`M ${e.middle} ${a(n)}`;for(let t=0;d>t;t++){const i=a(n+(t+.5)*r);y+=` L ${e.middle+c[t]/f*p} ${i}`}y+=` L ${e.middle} ${a(i)}`;for(let t=d-1;t>=0;t--){const i=a(n+(t+.5)*r);y+=` L ${e.middle-c[t]/f*p} ${i}`}y+=" Z"}else{y=`M ${a(n)} ${e.middle}`;for(let t=0;d>t;t++)y+=` L ${a(n+(t+.5)*r)} ${e.middle-c[t]/f*p}`;y+=` L ${a(i)} ${e.middle}`;for(let t=d-1;t>=0;t--)y+=` L ${a(n+(t+.5)*r)} ${e.middle+c[t]/f*p}`;y+=" Z"}const g=s(e.pieceData[0],e.name);let m;if(h&&t.length>=4){const r=(0,Ef.quantile)(t,.25)??n,o=(0,Ef.quantile)(t,.5)??(n+i)/2,s=(0,Ef.quantile)(t,.75)??i;m={q1Pos:a(r),medianPos:a(o),q3Pos:a(s),centerPos:e.middle,isVertical:u}}const x=u?{x:e.x,y:Math.min(a(i),a(n)),width:e.width,height:Math.abs(a(i)-a(n))}:{x:Math.min(a(n),a(i)),y:e.x,width:Math.abs(a(i)-a(n)),height:e.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:Df(t),style:g,datum:e.pieceData,category:e.name})}return l},histogram:function(e,t){const{scales:n,columns:i,config:r,getR:o,resolveSummaryStyle:s}=e,{r:a}=n,c=[],l=r.bins||25,u=r.normalize,d=a.domain?.(),h=d?+d[0]:void 0,f=d?+d[1]:void 0;for(const e of Object.values(i)){const t=e.pieceData.map(e=>o(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const[n,i]=di(t),r=null!=h&&isFinite(h)?h:n,d=null!=f&&isFinite(f)?f:i,p=(d-r)/l||1,y=Array(l).fill(0);for(const e of t)r>e||e>d||y[Math.min(Math.floor((e-r)/p),l-1)]++;const g=t.length,m=hi(y,1),x=s(e.pieceData[0],e.name);for(let t=0;l>t;t++){if(0===y[t])continue;const n=(u?y[t]/g:y[t]/m)*e.width*.9,i=a(r+t*p),o=a(r+(t+1)*p);c.push(Qe(Math.min(i,o),e.x+e.width-n,Math.abs(o-i),n,x,{bin:t,count:y[t],range:[r+t*p,r+(t+1)*p],category:e.name},e.name))}}return c},ridgeline:function(e,t){const{scales:n,columns:i,config:r,getR:o,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u=r.bins||20,d="horizontal"===c,h=r.amplitude||1.5;for(const e of Object.values(i)){const t=e.pieceData.map(e=>o(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],i=t[t.length-1],r=(i-n)/u||1,c=Array(u).fill(0);for(const e of t)n>e||e>i||c[Math.min(Math.floor((e-n)/r),u-1)]++;const f=hi(c,1),p=s(e.pieceData[0],e.name),y=e.width*h;let g;if(d){const t=e.x+e.width;g=`M ${a(n)} ${t}`;for(let e=0;u>e;e++)g+=` L ${a(n+(e+.5)*r)} ${t-c[e]/f*y}`;g+=` L ${a(i)} ${t} Z`}else{const t=e.x;g=`M ${t} ${a(n)}`;for(let e=0;u>e;e++){const i=a(n+(e+.5)*r);g+=` L ${t+c[e]/f*y} ${i}`}g+=` L ${t} ${a(i)} Z`}const m=d?{x:Math.min(a(n),a(i)),y:e.x,width:Math.abs(a(i)-a(n)),height:e.width}:{x:e.x,y:Math.min(a(i),a(n)),width:e.width,height:Math.abs(a(i)-a(n))};l.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:m,stats:Df(t),style:{...p,fillOpacity:p.fillOpacity??.5},datum:e.pieceData,category:e.name})}return l},timeline:function(e,t){const{scales:n,columns:i,getRawRange:r,resolvePieceStyle:o}=e,{r:s,projection:a}=n,c=[],l="horizontal"===a;for(const e of Object.values(i))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[i,a]=n,u=o(t,e.name);if(l){const n=s(Math.min(i,a)),r=s(Math.max(i,a));c.push(Qe(n,e.x,r-n,e.width,u,t,e.name))}else{const n=s(Math.max(i,a)),r=s(Math.min(i,a));c.push(Qe(e.x,n,e.width,r-n,u,t,e.name))}}return c},funnel:function(e,t){const{columns:n,getR:i,getStack:r,resolvePieceStyle:o}=e,s=[],a=t.width/2,c=!1!==e.config.showLabels,l=e.scales.o.domain().map(e=>n[e]).filter(Boolean);if(0===l.length)return s;const u=[],d=new Set;for(const e of l)for(const t of e.pieceData){const e=r?r(t):"_default";d.has(e)||(d.add(e),u.push(e))}const h=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const e of l){const t=new Map;let n=0;for(const o of e.pieceData){const e=r?r(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=i(o);s.total+=a,s.pieces.push(o),n+=a}f.push({col:e,groups:t,stepTotal:n}),h||n>p&&(p=n)}if(h)for(const e of f){let t=0,n=0;for(let i=0;u.length>i;i++){const r=e.groups.get(u[i]);r&&(i%2==0?t+=r.total:n+=r.total)}const i=Math.max(t,n);i>p&&(p=i)}if(0===p)return s;const y=new Map;for(const e of u){const t=f[0].groups.get(e);y.set(e,t?.total??0)}const g=f[0].stepTotal,m=h?.95*a:.9*t.width,x=(0,zf.scaleLinear)().domain([0,p]).range([0,m]),b=e.config.connectorOpacity??.3;let v=new Map;for(let t=0;f.length>t;t++){const n=f[t],i=n.col,r=0===t,l=i.width,d=.55*l,p=i.x+(l-d)/2,m=new Map;if(h){let e=0;for(const t of u){const i=n.groups.get(t);i&&(e+=x(i.total))}let t=a,l=a;for(let h=0;u.length>h;h++){const f=u[h],g=n.groups.get(f);if(!g)continue;const b=x(g.total),v=h%2==0,w=v?t:l-b;v?t+=b:l-=b;const k=o(g.pieces[0],f),S=y.get(f)??g.total,A={...g.pieces[0],__funnelValue:g.total,__funnelPercent:S>0?g.total/S*100:0,__funnelStep:i.name,__funnelIsFirstStep:r,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};c&&(0===h&&(A.__funnelStepLabel=i.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=p,A.__funnelRowWidth=e),A.__funnelValueLabelX=w+b/2,A.__funnelValueLabelY=p,A.__funnelBarW=b),s.push(Qe(w,p,b,d,k,A,f)),m.set(f,{x:w,y:p,w:b,h:d})}}else{const e=n.stepTotal,t=x(e),l=a-t/2,h=u[0],f="_default"!==h,y=n.groups.get(h)?.pieces[0]??i.pieceData[0],b=f?h:i.name,v=o(y,b),w=g>0?e/g*100:0,k={...y,__funnelValue:e,__funnelPercent:w,__funnelStep:i.name,__funnelIsFirstStep:r,category:f?h:i.name};c&&(k.__funnelStepLabel=i.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=t,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=t),s.push(Qe(l,p,t,d,v,k,b)),m.set(h,{x:l,y:p,w:t,h:d})}if(t>0&&v.size>0){const t=h?u:[u[0]];for(const r of t){const t=v.get(r),a=m.get(r);if(!t||!a)continue;const c=(()=>{const e=n.groups.get(r);return o(e?e.pieces[0]:i.pieceData[0],"_default"===r?i.name:r)})(),l={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:c.fill||e.config.themeSemantic?.secondary||"#999",opacity:b},datum:n.groups.get(r)?.pieces[0]??i.pieceData[0],category:"_default"===r?i.name:r};s.push(l)}}v=m}return s},"bar-funnel":function(e,t){const{columns:n,getR:i,getStack:r,resolvePieceStyle:o,scales:s}=e,a=[],c=s.o.domain().map(e=>n[e]).filter(Boolean);if(0===c.length)return a;const l=[],u=new Set;for(const e of c)for(const t of e.pieceData){const e=r?r(t):"_default";u.has(e)||(u.add(e),l.push(e))}const d=l.length>1&&"_default"!==l[0],h=[];for(const e of c){const t=new Map;let n=0;for(const o of e.pieceData){const e=r?r(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=i(o);s.total+=a,s.pieces.push(o),n+=a}h.push({col:e,groups:t,stepTotal:n})}const f=new Map;for(const e of l){const t=h[0]?.groups.get(e);f.set(e,t?.total??0)}const p=s.r,y=d?l.length:1,g=d?.15:0;for(let e=0;h.length>e;e++){const t=h[e],n=t.col,i=0===e,r=e>0?h[e-1]:null,s=n.width/y,c=s*g,u=s-c;for(let e=0;l.length>e;e++){const h=l[e],y=t.groups.get(h);if(!y)continue;const g=y.total,m=f.get(h)??g,x=m>0?g/m*100:0,b=r?.groups.get(h),v=i?0:Math.max(0,(b?.total??g)-g),w=n.x+e*s+c/2,k=p(g),S=p(0)-k,A=o(y.pieces[0],d?h:n.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:i,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(Qe(w,k,u,S,A,M,d?h:n.name)),v>0){const e=p(g+v),t=k-e,i={...A},r={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name};a.push(Qe(w,e,u,t,i,r,d?h:n.name))}}}return a},swimlane:function(e,t){const{scales:n,columns:i,getR:r,getStack:o,resolvePieceStyle:s}=e,{r:a,projection:c}=n,l=[],u="horizontal"===c,d=e.config.gradientFill,h=u?"left":"bottom",f=e.config.trackFill;if(f){const e="string"==typeof f?f:f.color,t="string"==typeof f?1:f.opacity??1,[n,r]=a.range(),o=Math.min(n,r),s=Math.abs(r-n);for(const n of Object.values(i)){const i={fill:e,opacity:t},r=u?Qe(o,n.x,s,n.width,i,null,"__track__"):Qe(n.x,o,n.width,s,i,null,"__track__");l.push(r)}}const p=e.config.roundedTop&&e.config.roundedTop>0?Math.max(0,e.config.roundedTop):0;for(const e of Object.values(i)){let t=0;const n=l.length;for(const n of e.pieceData){const i=Math.abs(r(n));if(0===i)continue;const c=o?o(n):e.name,f=s(n,c);let p;if(u){const r=a(t),o=a(t+i);p=Qe(r,e.x,o-r,e.width,f,n,c)}else{const r=a(t+i),o=a(t);p=Qe(e.x,r,e.width,o-r,f,n,c)}d&&(p.fillGradient=d,p.roundedEdge=h),l.push(p),t+=i}if(p>0&&l.length>n){const e=l.slice(n),t=e[0],i=e[e.length-1];1===e.length?t.cornerRadii={tl:p,tr:p,br:p,bl:p}:u?(t.cornerRadii={tl:p,bl:p},i.cornerRadii={tr:p,br:p}):(t.cornerRadii={bl:p,br:p},i.cornerRadii={tl:p,tr:p})}}return l}},Ff=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Nf=["scene-style","data-paint","accessibility","evidence"],Of=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Wf=new Set(["accessorRevision","axisExtent","categoryAccessor","chartType","extentPadding","groupBy","multiAxis","normalize","oAccessor","oExtent","oSort","rAccessor","rExtent","runtimeMode","stackBy","timeAccessor","valueAccessor"]),qf=new Set(["barColors","colorScheme","connectorStyle","pieceStyle","summaryStyle","themeCategorical","themeDiverging","themeSemantic","themeSequential"]),Yf=class{constructor(){this.tracker=new Lt}get last(){return this.tracker.last}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Ff)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Nf):this.recordNoop("restyle")}recordConfig(e){if(0===e.length)return this.tracker.record({kind:"config",keys:e},[]);const t=new Set(Of);return e.some(e=>Wf.has(e))&&t.add("domain"),e.some(e=>qf.has(e))&&t.add("scene-style"),this.tracker.record({kind:"config",keys:e},t)}},Hf=require("d3-quadtree"),Xf=class{constructor(e){this.rExtent=new je,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new Yf,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new _e(e.windowSize),this.getO=Re(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>Ie(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new je)):(this.getR=Ie(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=Re(e.stackBy),this.getGroup=Re(e.groupBy),this.getColor=Re(e.colorAccessor),this.getSymbol=Re(e.symbolAccessor),this.getConnector=Re(e.connectorAccessor),this.getDataId=Re(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new _e(e.windowSize))}syncPulseTimestampBuffer(){var e,t,n,i;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,n=this.timestampBuffer,i=Ne(),e?null!=n&&n.capacity===t.capacity&&n.size===t.size?n:_t(t,i):null)}ingest(e){const t=Ne();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),Pt(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)jt(this.buffer,n,this.timestampBuffer,t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of e.inserts){const e=jt(this.buffer,n,this.timestampBuffer,t);this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=e&&this.evictValueExtent(e)}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;const n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this,i=this.scales,r=this.multiScales,o=this.columns;if(0===n.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const s=this.getBufferArray(),a=t.projection||"vertical",c=t.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,d="radial"===a,h=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===a?e.width:e.height):.1));let f,p;if(d){f=(0,Tf.scaleBand)().domain(c).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,i=t.innerRadius||0;p=(0,Tf.scaleLinear)().domain(l).range([i,n])}else u?(f=(0,Tf.scaleBand)().domain(c).range([0,e.height]).padding(h),p=(0,Tf.scaleLinear)().domain(l).range([0,e.width])):(f=(0,Tf.scaleBand)().domain(c).range([0,e.width]).padding(h),p=(0,Tf.scaleLinear)().domain(l).range([e.height,0]));this.scales={o:f,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((i,r)=>{const o=this.rExtents[r];o.dirty&&o.recalculate(n,i);let[s,a]=o.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(t.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?(0,Tf.scaleLinear)().domain([s,a]).range([0,e.width]):(0,Tf.scaleLinear)().domain([s,a]).range([e.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(e=>this.rAccessors.map((t,n)=>({...e,__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(y,c,f,a,e),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.multiScales=r,this.columns=o):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=g,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,s),this.config.pulse&&this.applyPulse(this.scene,s),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++)}resolveRAccessorName(e){const t=this.config.valueAccessor||this.config.rAccessor,n=Array.isArray(t)?t[e]:t;return"string"==typeof n?n:"value"+e}resolveCategories(e){const t=this.config.oSort,n="streaming"===this.config.runtimeMode||this._hasStreamingData,i="auto"===t?void 0:t;let r=null;if(n){r=new Set;for(const t of e)r.add(this.getO(t))}const o=r?Array.from(this.categories).filter(e=>r.has(e)):Array.from(this.categories);if(n&&void 0===i){const e=Math.max(50,3*r.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;r.has(e)||(this.categories.delete(e),t--)}}return o}if(!1===i)return o;if("function"==typeof i)return o.sort(i);const s=new Map;for(const t of e){const e=this.getO(t);s.set(e,(s.get(e)||0)+Math.abs(this.getR(t)))}return o.sort("asc"===i?(e,t)=>(s.get(e)||0)-(s.get(t)||0):(e,t)=>(s.get(t)||0)-(s.get(e)||0))}computeValueDomain(e,t){return function(e){const{data:t,chartType:n,projection:i,normalize:r,rExtent:o,extentPadding:s=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:d,rawRExtent:h}=e,f=s;if("radial"===i&&("pie"===n||"donut"===n))return[0,1];let p=0,y=0;if("bar"===n&&d&&r)p=0,y=1;else if("bar"===n&&d){const e=new Map,n=new Map;for(const i of t){const t=l(i),r=u(i);0>r?n.set(t,(n.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>y&&(y=t);for(const e of n.values())p>e&&(p=e)}else if("bar"===n){const e=new Map;for(const n of t){const t=l(n),i=u(n);e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>y&&(y=t),p>t&&(p=t)}else if("swimlane"===n){const e=new Map;for(const n of t){const t=l(n),i=Math.abs(u(n));e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>y&&(y=t)}else if("clusterbar"===n||"bar-funnel"===n)for(const e of t){const t=u(e);t>y&&(y=t),p>t&&(p=t)}else{const e=h[0],t=h[1];e!==1/0&&(p=e),t!==-1/0&&(y=t)}o&&(null!=o[0]&&(p=o[0]),null!=o[1]&&(y=o[1]));const g="bar"===n||"clusterbar"===n||"bar-funnel"===n||"swimlane"===n;if(g&&null==o?.[0]&&null==o?.[1]&&(p>0&&(p=0),0>y&&(y=0)),"bar-funnel"!==n&&"exact"!==c){const e=y-p,t=e>0?e*f:1,i=g&&!a&&0===p,r=g&&!a&&0===y||"swimlane"===n;null!=o?.[0]||i||(p-=t),null!=o?.[1]||r||(y+=t)}return[p,y]}({data:e,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(e,t,n,i,r){return function(e){const{data:t,oExtent:n,oScale:i,projection:r,layout:o,dynamicColumnWidth:s,getO:a,getR:c}=e,l={},u=new Map;for(const e of t){const t=a(e);u.has(t)||u.set(t,[]),u.get(t).push(e)}let d=0;if("radial"===r)for(const e of t)d+=Math.abs(c(e));let h=null;if(s&&"radial"!==r){h=new Map;let e=0;for(const t of n){const n=u.get(t)||[];let i;i="string"==typeof s?n.reduce((e,t)=>e+(Number(t[s])||0),0):s(n),h.set(t,i),e+=i}const t=("horizontal"===r?o.height:o.width)-i.padding()*i.step()*n.length;if(e>0)for(const[n,i]of h)h.set(n,i/e*t)}let f=0,p=0;for(const e of n){const t=u.get(e)||[],n=t.reduce((e,t)=>e+Math.abs(c(t)),0),r=d>0?n/d:0;let o,s;h?(o=p,s=h.get(e)||i.bandwidth(),p+=s+i.padding()*i.step()):(o=i(e)??0,s=i.bandwidth()),l[e]={name:e,x:o,y:0,width:s,middle:o+s/2,padding:i.padding()*i.step(),pieceData:t,pct:r,pctStart:f},f+=r}return l}({data:e,oExtent:t,oScale:n,projection:i,layout:r,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){const n=this.buildLayoutContext(e,t);let i;try{i=this.config.customLayout(n)}catch(e){const t=null!==this.lastCustomLayoutResult,n=vt("ordinal",e,t,this.version);this.lastCustomLayoutFailure=n,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",e);try{this.config.onLayoutError?.(n)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null;const r=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of r)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(r,this.config.layoutSelection??null)}return mt({label:"ordinal customLayout",nodes:r,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),r}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const n=this.getSceneContext(),i=Bf[this.config.chartType];let r=i?i(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:i,getConnector:r,getO:o}=e;if(!r||!n)return[];const s=[],{projection:a}=n,c=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=r(t);if(!n)continue;let i,s;"point"===e.type?(i=e.x,s=e.y):(i=e.x+e.w/2,s=e.y+("vertical"===a?0:e.h/2)),c.has(n)||c.set(n,[]),c.get(n).push({x:i,y:s,datum:t,category:o(t)})}const l=n.o.domain(),u=i.connectorStyle;for(const[t,n]of c)if(n.length>=2){n.sort((e,t)=>l.indexOf(e.category)-l.indexOf(t.category));for(let i=0;n.length-1>i;i++){const r=n[i],o=n[i+1],a="function"==typeof u?u(r.datum):u||{stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:r.x,y1:r.y,x2:o.x,y2:o.y,style:a,datum:r.datum,group:t})}}return s}(n,r);r=[...e,...r]}return r}buildLayoutContext(e,t){const n=this.config,i=n.layoutMargin??{top:0,right:0,bottom:0,left:0},r=iu(n.colorScheme,n.themeCategorical,R),o=this.scales;return{data:e,scales:{o:o.o,r:o.r,projection:o.projection},dimensions:{width:t.width,height:t.height,margin:i,plot:"radial"===o.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:n.themeSemantic??{},categorical:[...r]},resolveColor:ru(r,n.colorScheme),config:n.layoutConfig??{},selection:n.layoutSelection??null}}resolvePieceStyle(e,t){if("function"==typeof this.config.pieceStyle){const n=this.config.pieceStyle(e,t);return n&&!n.fill&&t?{...n,fill:this.getColorFromScheme(t)}:n}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||R,i=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,i),i}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Oe(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=We(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const t=function(e,t){const n="function"==typeof t,i=n?null:t||"category",r=new Map;for(let o=0;e.length>o;o++){const s=e[o],a=n?t(s):s[i],c=r.get(a);c?c.push(o):r.set(a,[o])}return r}(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){const e=function(e){let t=0,n=0;for(const i of e)"point"===i.type&&(t++,i.r>n&&(n=i.r));if(500>=t)return{quadtree:null,maxRadius:n};const i=Array(t);let r=0;for(const t of e)"point"===t.type&&(i[r++]=t);return{maxRadius:n,quadtree:(0,Hf.quadtree)().x(e=>e.x).y(e=>e.y).addAll(i)}}(this.scene);this._pointQuadtree=e.quadtree,this._maxPointRadius=e.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){if(!this.config.decay)return;const n=t.length;if(1>=n)return;const i=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const r=this.computeDecayOpacity(e,n);t.style={...t.style,opacity:(t.style?.opacity??1)*r}}}applyPulse(e,t,n=Ne()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,i,r,o){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;for(const l of t){if("connector"===l.type||"violin"===l.type||"boxplot"===l.type)continue;if("wedge"===l.type){const t=l.category;if(!t)continue;let i=0;for(const s of r(t)??[]){const t=n.get(s);null!=t&&(i=Math.max(i,qe(e,t,o)))}c=Ye(l,i,s)||c;continue}if(null==l.datum)continue;const t=i.get(l.datum);if(null==t)continue;const u=n.get(t);c=Ye(l,null==u?0:qe(e,u,o),s,a)||c}return c}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),n)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&He(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(Ne())}synthesizeIntroPositions(){this.prevPositionMap.clear();const e=new Map,t=this.scales?.r(0)??0,n="horizontal"!==this.scales?.projection;let i;for(let r=0;this.scene.length>r;r++){const o=this.scene[r],s=this.getNodeKey(o,e);s&&("rect"===o.type?this.prevPositionMap.set(s,n?{x:o.x,y:t,w:o.w,h:0,opacity:o.style.opacity??1}:{x:t,y:o.y,w:0,h:o.h,opacity:o.style.opacity??1}):"point"===o.type?this.prevPositionMap.set(s,{x:o.x,y:o.y,r:0,opacity:0}):"wedge"===o.type&&(void 0===i&&(i=o.startAngle),this.prevPositionMap.set(s,{x:o.cx,y:o.cy,startAngle:i,endAngle:i,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){const n=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,i=t.get(n)||0;return t.set(n,i+1),`${n}:${i}`}return"rect"===e.type?`r:${e.group||""}:${e.datum?.category??""}`:"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const e=new Map;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],i=this.getNodeKey(n,e);i&&("point"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"wedge"===n.type&&this.prevPositionMap.set(i,{x:n.cx,y:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:n.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const e=this.config.transition.duration??300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1;const n=new Set,i=new Map;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],o=this.getNodeKey(r,i);if(!o)continue;r._transitionKey=o;const s=this.prevPositionMap.get(o);if("point"===r.type)s?(n.add(o),r._targetOpacity=r.style.opacity??1,(s.x!==r.x||s.y!==r.y||void 0!==s.r&&s.r!==r.r)&&(r._targetX=r.x,r._targetY=r.y,r._targetR=r.r,r.x=s.x,r.y=s.y,void 0!==s.r&&(r.r=s.r),t=!0)):(r._targetOpacity=r.style.opacity??1,r._targetR=r.r,r.r=0,r.style={...r.style,opacity:0},t=!0);else if("rect"===r.type)s?(n.add(o),r._targetOpacity=r.style.opacity??1,s.x===r.x&&s.y===r.y&&s.w===r.w&&s.h===r.h||(r._targetX=r.x,r._targetY=r.y,r._targetW=r.w,r._targetH=r.h,r.x=s.x,r.y=s.y,r.w=s.w??r.w,r.h=s.h??r.h,t=!0)):(r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},t=!0);else if("wedge"===r.type)if(s)n.add(o),r._targetOpacity=r.style.opacity??1,s.startAngle===r.startAngle&&s.endAngle===r.endAngle||(r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle,r.startAngle=s.startAngle,r.endAngle=s.endAngle,t=!0);else{r._targetOpacity=r.style.opacity??1,r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle;const e=r.startAngle;r.startAngle=e,r.endAngle=e,r.style={...r.style,opacity:0},this.prevPositionMap.set(o,{x:r.cx,y:r.cy,startAngle:e,endAngle:e,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(const[e,i]of this.prevPositionMap)if(!n.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:i.x,y:i.y,r:i.r??3,style:{opacity:i.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:i.x,y:i.y,w:i.w??0,h:i.h??0,style:{opacity:i.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((i.startAngle??0)+(i.endAngle??0))/2,n={type:"wedge",cx:i.x,cy:i.y,innerRadius:i.innerRadius??0,outerRadius:i.outerRadius??100,startAngle:i.startAngle??0,endAngle:i.endAngle??0,style:{opacity:i.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:Ne(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;const t=Be(e,this.activeTransition),n=ze(t,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=Fe(i?i.opacity??1:0,e._targetOpacity,n)}const i=this.prevPositionMap.get(t);void 0!==e._targetX&&i&&(e.x=Fe(i.x,e._targetX,n),e.y=Fe(i.y,e._targetY,n)),void 0!==e._targetR&&void 0!==i?.r&&(e.r=Fe(i.r,e._targetR,n))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=Fe(i?i.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX)continue;const i=this.prevPositionMap.get(t);if(!i)continue;e.x=Fe(i.x,e._targetX,n),e.y=Fe(i.y,e._targetY,n),void 0!==i.w&&(e.w=Fe(i.w,e._targetW,n),e.h=Fe(i.h,e._targetH,n))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style={...e.style,opacity:Fe(i?i.opacity??1:0,e._targetOpacity,n)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const i=this.prevPositionMap.get(t);i&&void 0!==i.startAngle&&(e.startAngle=Fe(i.startAngle,e._targetStartAngle,n),e.endAngle=Fe(i.endAngle,e._targetEndAngle,n))}}}if(t>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style={...e.style||{},opacity:0===e._targetOpacity?0:e._targetOpacity},e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(e.x=e._targetX,e.y=e._targetY),void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}getLastUpdateResult(){return this.updateResults.last}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=De(e),n=this.getDataId,i=e=>t.has(n(e));Ct(this.buffer,this.timestampBuffer,i);const r=this.buffer.remove(i);if(0===r.length)return this.updateResults.recordNoop("remove"),r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=Ne(),this.updateResults.recordData("remove",r.length),r}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=De(e),i=this.getDataId,r=new Set;this.buffer.forEach((e,t)=>{n.has(i(e))&&r.add(t)});const o=this.buffer.update(e=>n.has(i(e)),t);if(0===o.length)return this.updateResults.recordNoop("update"),o;for(const e of o)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),r.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=Ne(),this.updateResults.recordData("update",o.length),o}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this._colorSchemeMap=null,this._colorSchemeIndex=0,this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}setLayoutSelection(e){this.config.layoutSelection=e}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const i of e){const e=this._baseStyles.get(i)??i.style??{},r=n(i,t);i.style=r?{...e,...r}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){const t={...this.config},n=Object.keys(e).filter(n=>e[n]!==t[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!Ce(e.colorAccessor,t.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in e&&!Ce(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!Ce(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let i=!1;("categoryAccessor"in e||"oAccessor"in e)&&(Ce(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=Re(this.config.categoryAccessor||this.config.oAccessor,"category"),i=!0));let r=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,n=t.valueAccessor||t.rAccessor,i=Array.isArray(e)?e:[e],o=Array.isArray(n)?n:[n];if(r=i.length!==o.length||i.some((e,t)=>!Ce(e,o[t])),r){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>Ie(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new je)):(this.getR=Ie(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!Ce(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?Re(this.config.stackBy):void 0),"groupBy"in e&&!Ce(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?Re(this.config.groupBy):void 0),"colorAccessor"in e&&!Ce(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Re(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!Ce(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Re(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!Ce(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?Re(this.config.connectorAccessor):void 0),(i||r||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}},Gf=require("react/jsx-runtime"),Vf=require("react/jsx-runtime");function Uf(e,t){const n=Xh(e.theme),i=e.size||[500,400],r={top:20,right:20,bottom:30,left:40,...e.margin},o=B(e.data),s=e.showLegend?ff(o,e.colorAccessor||e.stackBy||e.groupBy):[],a=e.legendPosition;oi(e.legend)||si(e.legend)?Sf(r,{legend:e.legend,theme:n,position:a||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&s.length>0&&kf(r,{categories:s,colorScheme:e.colorScheme,theme:n,position:a||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout});const c=i[0]-r.left-r.right,l=i[1]-r.top-r.bottom,u=e.projection||"vertical",d="radial"===u,h={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:u,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme||n.colors.categorical,themeCategorical:n.colors.categorical,themeSemantic:xe(n),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,layoutSelection:e.layoutSelection,barColors:e.barColors},f=new Xf(h);if(e.data&&f.ingest({inserts:o,bounded:!0}),f.computeScene({width:c,height:l}),!f.scales||0===f.scene.length)return t&&(t.evidence=Kh({frameType:"ordinal",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),If.renderToStaticMarkup(Pf(null,{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,idPrefix:e._idPrefix}));if(t){const n=f.scales.o?.domain?.();t.evidence=Kh({frameType:"ordinal",width:i[0],height:i[1],marks:f.scene,title:e.title,description:e.description,annotations:e.annotations,yDomain:Uh(f.scales.r?.domain?.()),categories:Array.isArray(n)?n.map(String):void 0})}const p=e._idPrefix,y=e.showGrid?function(e,t,n,i){const r=e.scales;if(!r||"radial"===r.projection)return null;const{grid:o}=Gh(n),s=i?i+"-":"",a="vertical"===r.projection,c=r.r.ticks(5);return(0,vf.jsx)("g",a?{id:s+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,n)=>{const i=r.r(e);return(0,vf.jsx)("line",{x1:0,y1:i,x2:t.width,y2:i,stroke:o,strokeWidth:.5},"gr-"+n)})}:{id:s+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,n)=>{const i=r.r(e);return(0,vf.jsx)("line",{x1:i,y1:0,x2:i,y2:t.height,stroke:o,strokeWidth:.5},"gr-"+n)})})}(f,{width:c,height:l},n,p):null;let g=null;if(f.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){const t=function(e){const t=e._idPrefix||e.chartId;if(t){const e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:"c"+e}const n=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`;let i=0;for(let e=0;n.length>e;e++)i=31*i+n.charCodeAt(e)|0;return"c"+(i>>>0).toString(36)}(e),i=new Set;for(const e of f.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&i.add("string"==typeof e.style.fill?e.style.fill:"#666");g=Array.from(i).map((e,i)=>function(e){const{id:t,background:n="transparent",stroke:i="#000",lineWidth:r=1.5,spacing:o=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*o));return(0,Gf.jsxs)("pattern",{id:t,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&(0,Gf.jsx)("rect",{width:a,height:a,fill:n}),(0,Gf.jsx)("line",{x1:0,y1:0,x2:0,y2:a,stroke:i,strokeWidth:r}),(0,Gf.jsx)("line",{x1:o,y1:0,x2:o,y2:a,stroke:i,strokeWidth:r})]},t)}({id:`funnel-hatch-${t}-${i}`,background:e,stroke:"transparent"===n.colors.background?"#fff":n.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(i).forEach((e,n)=>r.set(e,`funnel-hatch-${t}-${n}`));for(const e of f.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${r.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}const m=f.scene.map((e,t)=>ao(e,t,p)).filter(Boolean),x=!1!==e.showAxes?function(e,t,n,i,r){const o=e.scales;if(!o)return null;if("radial"===o.projection)return null;const s=Gh(i),a="vertical"===o.projection,c=n.categoryFormat||n.oFormat,l=n.valueFormat||n.rFormat,u=n.categoryLabel||n.oLabel,d=n.valueLabel||n.rLabel,h=Object.values(e.columns).map(e=>({pixel:e.middle,label:(c||String)(e.name)})),f=o.r.ticks(5).map(e=>({pixel:o.r(e),label:(l||Mf)(e)}));return(0,Vf.jsxs)("g",a?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,Vf.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:s.border,strokeWidth:1}),h.map((e,n)=>(0,Vf.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,Vf.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Vf.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oxtick-"+n)),u&&(0,Vf.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:u}),(0,Vf.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:s.border,strokeWidth:1}),f.map((e,t)=>(0,Vf.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Vf.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Vf.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oytick-"+t)),d&&(0,Vf.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:d})]}:{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,Vf.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:s.border,strokeWidth:1}),f.map((e,n)=>(0,Vf.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,Vf.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Vf.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oxtick-"+n)),d&&(0,Vf.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:d}),(0,Vf.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:s.border,strokeWidth:1}),h.map((e,t)=>(0,Vf.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Vf.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Vf.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oytick-"+t)),u&&(0,Vf.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:u})]})}(f,{width:c,height:l},e,n,p):null,b=e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{r:f.scales.r,y:"vertical"===f.scales.projection?f.scales.r:void 0},layout:{width:c,height:l},theme:n,projection:u,idPrefix:p}):null,v=e.showLegend?0===s.length?null:hf({categories:s,colorScheme:e.colorScheme,theme:n,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,w=Cf.isValidElement(e.legend)?e.legend:Af(e.legend,{theme:n,position:e.legendPosition||"right",size:i,margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||v,k=d?r.left+c/2:r.left,S=d?r.top+l/2:r.top;return If.renderToStaticMarkup(Pf((0,Vf.jsxs)(Vf.Fragment,{children:[e.backgroundGraphics,y,m,x,b,e.foregroundGraphics,f.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${k},${S})`,innerWidth:c,innerHeight:l,legend:w,defs:g,idPrefix:e._idPrefix}))}var Kf=c(require("react")),Zf=c(require("react-dom/server"));function Qf(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Jf(e,t){var n,i=[],r=[],o=[],s={},a=[];function c(e){o[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],o[t]&&c(t)})}function l(e){var t,i,d=!1;for(r.push(e),o[e]=!0,t=0;a[e].length>t;t++)(i=a[e][t])===n?(u(n,r),d=!0):o[i]||(d=l(i));if(d)c(e);else for(t=0;a[e].length>t;t++){var h=s[i=a[e][t]];h||(s[i]=h={}),h[i]=!0}return r.pop(),d}function u(e,n){var r=[].concat(n).concat(e);t?t(r):i.push(r)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,i=function(e){for(var t=e.length,n=Array(t),i=Array(t),r=Array(t),o=Array(t),s=Array(t),a=Array(t),c=0;t>c;++c)n[c]=-1,i[c]=0,r[c]=!1,o[c]=0,s[c]=-1,a[c]=[];var l,u=0,d=[],h=[];function f(t){var c=[t],l=[t];for(n[t]=i[t]=u,r[t]=!0,u+=1;l.length>0;){var f=e[t=l[l.length-1]];if(f.length>o[t]){for(var p=o[t];f.length>p;++p){var y=f[p];if(0>n[y]){n[y]=i[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(i[t]=0|Math.min(i[t],i[y])),0>s[y]||a[t].push(s[y])}o[t]=p}else{if(i[t]===n[t]){var g=[],m=[],x=0;for(p=c.length-1;p>=0;--p){var b=c[p];if(r[b]=!1,g.push(b),m.push(a[b]),x+=a[b].length,s[b]=d.length,b===t){c.length=p;break}}d.push(g);var v=Array(x);for(p=0;m.length>p;p++)for(var w=0;m[p].length>w;w++)v[--x]=m[p][w];h.push(v)}l.pop()}}}for(c=0;t>c;++c)0>n[c]&&f(c);for(c=0;h.length>c;c++){var p=h[c];if(0!==p.length){p.sort(function(e,t){return e-t}),l=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&l.push(p[y]);h[c]=l}}return{components:d,adjacencyList:h}}(e),r=i.components.filter(function(e){return e.length>1}),o=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)o>r[s][a]&&(o=r[s][a],n=s);var c=r[n];return!!c&&{leastVertex:o,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var p=0;a.length>p;p++)for(var y=0;a[p].length>y;y++){var g=a[p][y];o[+g]=!1,s[g]={}}l(n),n+=1}else n=h}return t?void 0:i}function ep(e){return e.y0-e.y1>0?"up":"down"}function tp(e,t){return t(e.source)==t(e.target)}function np(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function ip(e){return e.target.x0-e.source.x1}function rp(e,t){var n=sp(e),i=ip(t)/Math.tan(n);return"up"==ep(e)?e.y1-i:e.y1+i}function op(e,t){var n=sp(e),i=ip(t)/Math.tan(n);return"up"==ep(e)?e.y1+i:e.y1-i}function sp(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function ap(e,t){return t(e)}function cp(e){return up(e.source)}function lp(e){return up(e.target)}function up(e){return(e.y0+e.y1)/2}function dp(e){return e.virtual?0:e.value}function hp(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!tp(e,t)?n+1:n});var i=0;return e.targetLinks.forEach(function(e){i=e.circular&&!tp(e,t)?i+1:i}),n+i}function fp(e){return e.target.depth}function pp(e,t){return e.sourceLinks.length?e.depth:t-1}function yp(e,t){return e.y0-t.y0}function gp(e,t){return t.y0-e.y0}function mp(e,t){return e.y1-t.y1}function xp(e,t){return t.y1-e.y1}function bp(e,t){return wp(e.source,t.source)||e.index-t.index}function vp(e,t){return wp(e.target,t.target)||e.index-t.index}function wp(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function kp(e,t){return Sp(e)==Sp(t)?"bottom"==e.circularLinkType?gp(e,t):yp(e,t):Sp(t)-Sp(e)}function Sp(e){return e.target.column-e.source.column}function Ap(e,t){return Mp(e)==Mp(t)}function Mp(e){return e.y0-e.y1>0?"up":"down"}var Pp=require("d3-array");function _p(e,t,n,i,r){let o=e;var s=Math.max(8,.15*(o.y1-o.y0));o.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var a=(0,Pp.min)(o.links,function(e){return e.source.y0});o.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=o.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),jp(o.links.filter(function(e){return"top"==e.circularLinkType}),t,n),jp(o.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),o.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+i,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,tp(e,t)&&np(e))e.circularPathData.rightSmallArcRadius=i+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=i+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=i+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=i+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,c=e.circularLinkType,l=o.links.filter(function(e){return e.source.column==s&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?gp:yp);var u=0;l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=i+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=i+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),s=e.target.column,(l=o.links.filter(function(e){return e.target.column==s&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?xp:mp),u=0,l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=i+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=i+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(o.y1,e.source.y1,e.target.y1)+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,i=e.target.x0,r=e.y1,o=(t+i)/2;return"M"+t+","+n+"C"+o+","+n+" "+o+","+r+" "+i+","+r}(e)}),o}function jp(e,t,n){e.sort(kp);var i=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var o=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(tp(e,t)&&np(e))e.circularPathData.verticalBuffer=o+e._circularWidth/2;else{for(var s=0;i.length>s;s++){var a=i[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Cp(e,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;o=c>o?c:o}}e.circularPathData.verticalBuffer=o+e._circularWidth/2}}),e}function Cp(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var Ip=require("d3-array");function Tp(e){return function(){return e}}function Rp(e){return e.index}function Lp(e){return e.nodes}function $p(e){return e.links}function Ep(e,t,n){var i=(0,Ip.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});i.forEach(function(r,o){var s=r.length;if(t)r.sort(t);else if(o>0){var a=new Map;r.forEach(function(e,t){var n,i,r,o=(i=0,r=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=up(e.source)*t,i+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=up(e.target)*t,i+=t}}),i>0?r/i:NaN);a.set(e,{bc:o,idx:t})}),r.sort(function(e,t){var n=a.get(e),i=a.get(t),r=n.bc,o=i.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(r)||isNaN(o)?isNaN(r)?isNaN(o)?n.idx-i.idx:1:-1:r-o})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?hp(t,n)-hp(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});r.forEach(function(t,r){t.depth==i.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==hp(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+r,t.y1=t.y0+t.value*e.ky)})})}function Dp(e,t,n,i,r,o){var s=(0,Ip.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var a=1,c=o;c>0;--c)l(a*=.99,n),u();function l(t,n){var i=s.length;s.forEach(function(r){var o=r.length,s=r[0].depth;r.forEach(function(r){var a;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&hp(r,n)>0){var c=(0,Ip.mean)(r.sourceLinks,lp),l=(0,Ip.mean)(r.targetLinks,cp),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-up(r))*t*.3;r.y0+=d,r.y1+=d}}else if(0==s&&1==o)r.y0=e.y1/2-(a=r.y1-r.y0)/2,r.y1=e.y1/2+a/2;else if(s==i-1&&1==o)r.y0=e.y1/2-(a=r.y1-r.y0)/2,r.y1=e.y1/2+a/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)a=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+a;else{var h=(0,Ip.mean)(r.sourceLinks,lp),f=(0,Ip.mean)(r.targetLinks,cp),p=((h&&f?(h+f)/2:h||f)-up(r))*t;r.y0+=p,r.y1+=p}})})}function u(){s.forEach(function(n){var o,s,a,c=e.y0,l=n.length;for(n.sort(t||wp),a=0;l>a;++a)(s=c-(o=n[a]).y0)>0&&(o.y0+=s,o.y1+=s),c=o.y1+i;if((s=c-i-e.y1)>0)for(c=o.y0-=s,o.y1-=s,a=l-2;a>=0;--a)(s=(o=n[a]).y1+r-c)>0&&(o.y0-=s,o.y1-=s),c=o.y0})}}function zp(e){e.nodes.forEach(function(e){e.sourceLinks.sort(vp),e.targetLinks.sort(bp)}),e.nodes.forEach(function(e){var t=e.y0,n=t,i=e.y1,r=i;e.sourceLinks.forEach(function(e){e.circular?(e.y0=i-e.width/2,i-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function Bp(){var e=0,t=0,n=1,i=1,r=24,o=8,s=null,a=Rp,c=pp,l=void 0,u=32,d=2,h=Lp,f=$p;function p(){var p={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=i,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return(0,Ip.group)(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var i=e.source,r=e.target;"object"!=typeof i&&(i=e.source=Qf(n,i)),"object"!=typeof r&&(r=e.target=Qf(n,r)),i.sourceLinks.push(e),r.targetLinks.push(e)})}(h,a),function(e,t){var n=0;if(null==t){for(var i=[],r=0;e.links.length>r;r++){var o=e.links[r],s=o.source.index,a=o.target.index;i[s]||(i[s]=[]),i[a]||(i[a]=[]),-1===i[s].indexOf(a)&&i[s].push(a)}var c=Jf(i);c.sort(function(e,t){return e.length-t.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,i=e.source.index;t===i||l[i]&&l[i][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(h,l),function(e,t){var n=0,i=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:i>n?"top":"bottom","top"==r.circularLinkType?n++:i++,e.nodes.forEach(function(e){ap(e,t)!=ap(r.source,t)&&ap(e,t)!=ap(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),tp(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,Ip.sum)(e.sourceLinks,dp),(0,Ip.sum)(e.targetLinks,dp)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(h),function(e,t,n){var i,r,o;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(i=e.nodes,r=[],o=0;i.length;++o,i=r,r=[])i.forEach(function(e){e.depth=o,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(i=e.nodes,r=[],o=0;i.length;++o,i=r,r=[])i.forEach(function(e){e.height=o,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,o):e.column})}(h,l,c);var f=o;if(null!==s){var p=(0,Ip.groups)(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=(0,Ip.max)(p,function(e){return e.length});y>1&&(f=Math.max(1,(i-t)*s/(y-1)))}(function(e,t,n){var i=(0,Ip.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var r=(0,Ip.min)(i,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,Ip.sum)(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var o=(0,Ip.max)(e.nodes,function(e){return e.column});e.nodes.forEach(o>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/o),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(h,f,r),Ep(h,l,a),Dp(h,l,a,f,f,u),zp(h),_p(h,a,d,10,8),Ep(h,l,a),Dp(h,l,a,f,f,u),zp(h),_p(h,a,d,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var i=n.links.filter(function(n){return ap(n.source,t)==ap(e,t)}),r=i.length;r>1&&i.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Ap(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=rp(t,e);return e.y1-n}if(t.target.column>e.target.column)return rp(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var o=e.y0;i.forEach(function(e){e.y0=o+e.width/2,o+=e.width}),i.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var o=n+1,s=0;r>o;o++)s+=i[o].width;t.y0=e.y1-s-t.width/2}})})}(h,a),function(e,t){let n=e;n.nodes.forEach(function(e){var i=n.links.filter(function(n){return ap(n.target,t)==ap(e,t)}),r=i.length;r>1&&i.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Ap(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=op(t,e);return e.y0-n}if(t.source.column>e.source.column)return op(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var o=e.y0;i.forEach(function(e){e.y1=o+e.width/2,o+=e.width}),i.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var o=n+1,s=0;r>o;o++)s+=i[o].width;t.y1=e.y1-s-t.width/2}})})}(h,a),function(e){var t=e.nodes,n=e.links,i=!1,r=!1;if(n.forEach(function(e){"top"==e.circularLinkType?i=!0:"bottom"==e.circularLinkType&&(r=!0)}),0==i||0==r){let i=function(t){return(t-o)/(s-o)*(e.y1-e.y0)+e.y0};var o=(0,Ip.min)(t,function(e){return e.y0}),s=(0,Ip.max)(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-o);1>a?(t.forEach(function(e){e.y0=i(e.y0),e.y1=i(e.y1)}),n.forEach(function(e){e.y0=i(e.y0),e.y1=i(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,n=i(e.y0)-e.y0;e.y0=i(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(h),_p(h,a,d,10,8)}(p),p}return p.update=function(e){return zp(e),_p(e,a,d,10,8),e},p.nodeWidth=function(e){return arguments.length?(r=+e,p):r},p.nodePadding=function(e){return arguments.length?(o=+e,p):o},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Tp(e),p):h},p.links=function(e){return arguments.length?(f="function"==typeof e?e:Tp(e),p):f},p.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:Tp(e),p):a},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Tp(e),p):c},p.nodeSort=function(e){return arguments.length?(l=e,p):l},p.iterations=function(e){return arguments.length?(u=+e,p):u},p.circularLinkGap=function(e){return arguments.length?(d=+e,p):d},p.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],i=+r[1][1],p):[[e,t],[n,i]]},p.size=function(r){return arguments.length?(e=t=0,n=+r[0],i=+r[1],p):[n-e,i-t]},p}var Fp=require("d3-interpolate"),Np=(require("d3-shape"),.5),Op=e=>{let t,n,i,r,o,s,a,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,i=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,o=e.source.x1,s=e.target.x0,a=(0,Fp.interpolateNumber)(o,s),c=a(Np),l=a(.5),`M${t},${o}C${t},${c} ${n},${l} ${n},${s}L${i},${s}C${i},${l} ${r},${c} ${r},${o}Z`;const u=e.sankeyWidth/2,d=(0,Fp.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=mc({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(Np),cp2X:d(.5)});return h};function Wp(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,i=e.circularPathData;if(!i)return null;if("down"===e.direction)return null;if(e._circularStub){const n=i.sourceX,r=i.sourceY,o=i.targetX,s=i.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-n))),c=Math.max(15,Math.min(40,.33*(o-i.leftFullExtent)));return`M${n},${r-t}L${n+a},${r-t}L${n+a},${r+t}L${n},${r+t}ZM${o},${s-t}L${o-c},${s-t}L${o-c},${s+t}L${o},${s+t}Z`}const r=i.sourceX,o=i.sourceY,s=i.targetX,a=i.targetY,c=i.rightFullExtent,l=i.leftFullExtent,u=i.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(n,15));return`M${r},${o-d*t}L${c},${o-d*t}L${c+n},${o-d*t+d*h}L${c+n},${u+d*n-d*h}L${c+n-h},${u+d*n}L${l-n+h},${u+d*n}L${l-n},${u+d*n-d*h}L${l-n},${a-d*t+d*h}L${l-n+h},${a-d*t}L${s},${a-d*t}L${s},${a+d*t}L${l+n},${a+d*t}L${l+n},${u-d*n}L${c-n},${u-d*n}L${c-n},${o+d*t}L${r},${o+d*t}Z`}var qp=new Set,Yp=new WeakMap;function Hp(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Yp.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Yp.set(e,n);const i=new Proxy(e,{get(e,n,i){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;qp.has(e)||(qp.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,i)}});return n.set(t,i),i}var Xp={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(fp))-1:0},justify:pp};function Gp(e){return"string"==typeof e?e:e.id}var Vp={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,i){if(0===e.length)return;const r="vertical"===n.orientation?"down":"right",o=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,c=n.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===r?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const h=Bp().extent(d).links(u).nodes(l).nodeAlign(Xp[o]||pp).nodeId(e=>e.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(a),h();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const i of l)e>i.x0&&(e=i.x0),i.x1>t&&(t=i.x1),n>i.y0&&(n=i.y0),i.y1>r&&(r=i.y1);for(const i of u){if(!i.circular||!i.circularPathData)continue;const o=i.circularPathData,s=(i._circularWidth??i.width??0)/2;e>o.leftFullExtent-s&&(e=o.leftFullExtent-s),o.rightFullExtent+s>t&&(t=o.rightFullExtent+s),n>o.verticalFullExtent-s&&(n=o.verticalFullExtent-s),o.verticalFullExtent+s>r&&(r=o.verticalFullExtent+s)}const o=t-e,s=r-n,a=i[0],c=i[1];if(o>0&&s>0&&(0>e||0>n||t>a||r>c)){const t=Math.min(a/o,c/s),i=-e*t+(a-o*t)/2,r=-n*t+(c-s*t)/2;for(const e of l)e.x0=e.x0*t+i,e.x1=e.x1*t+i,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of u)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+i,n.targetX=n.targetX*t+i,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+i,n.leftFullExtent=n.leftFullExtent*t+i,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+i,n.leftInnerExtent=n.leftInnerExtent*t+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of l){const t=f.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const p=new Map;for(const e of t)p.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=Gp(e.source),n=Gp(e.target),i=p.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=e.width??0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=r;const o=f.get(t),s=f.get(n);o&&(i.source=o),s&&(i.target=s)}}},buildScene(e,t,n,i){const r="vertical"===n.orientation?"down":"right",o=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,c=n.edgeColorBy||"source",l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:g,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const d=[],h=[],f=[],p=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const i=o?o(Hp(t,"nodeStyle")):{},s={fill:i.fill||u.get(t.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};p.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===r?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:s,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:s,datum:t,id:t.id,label:t.id})}const y=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of y){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;if(!t||!i)continue;let r=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";r="function"==typeof c?c(e)||r:"target"===c?p.get(i.id)||u.get(i.id)||r:p.get(t.id)||u.get(t.id)||r;const o=s?s(Hp(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=o.fill||r;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+i},${t.sourceY-n}L${t.sourceX+i},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:o.fillOpacity??a,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+i}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:o.fillOpacity??a,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let l;(l=e.circular&&e.circularPathData?Wp(e):Op(e),l)&&h.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:o.fill||r,fillOpacity:o.fillOpacity??a,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity},datum:e})}if(!1!==n.showLabels){const t=(m=n.nodeLabel)?"function"==typeof m?m:e=>e[m]||e.id:null;for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;const s=t?t(n):n.id;if(!s)continue;let a,c,l;"down"===r?(a=n.y0+(n.y1-n.y0)/2,c=n.x1+14,l="start"):(i[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),c=n.y0+o/2),f.push({x:a,y:c,text:s+"",anchor:"down"===r?"middle":l,baseline:"middle",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:h,labels:f}}},Up=require("d3-force"),Kp=require("d3-scale"),Zp={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,i){if(0===e.length)return;const r=n.forceStrength??.1,o=i[0]/2,s=i[1]/2,a=n.__previousPositions;let c=0;const l=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=a?.get(t.id);e?c++:n?(t.x=n.x,t.y=n.y,c++):l.push(t)}const u=c>0&&.3>=(e.length>0?l.length/e.length:1);if(u){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of l){const i=Qp(e.id,t,n);if(i.length>0){let t=0,n=0;for(const e of i)t+=e.x,n+=e.y;const r=Jp(e.id),o=r%360*(Math.PI/180),s=10+r%20;e.x=t/i.length+s*Math.cos(o),e.y=n/i.length+s*Math.sin(o)}else{const t=Jp(e.id),n=t%360*(Math.PI/180),i=15+t%30;e.x=o+i*Math.cos(n),e.y=s+i*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const i=e[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const e=10*Math.sqrt(n+.5),r=n*t;i.x=o+e*Math.cos(r),i.y=s+e*Math.sin(r)}}}const d=n.__skipForceSimulation||0===n.iterations?0:u?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),h=ey(n.nodeSize,n.nodeSizeRange,e),f=e=>h(e);if(d>0){const n=new Map,i=new Map;for(const t of e)n.set(t.id,0),i.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,i="string"==typeof e.target?e.target:e.target.id;n.set(t,(n.get(t)??0)+1),n.set(i,(n.get(i)??0)+1)}const a=(0,Up.forceLink)().strength(e=>{const t=e.weight,i="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(n.get("string"==typeof e.source?e.source:e.source.id)??1,n.get(i)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*r/(.1*o))}).distance(e=>{const t="string"==typeof e.source?i.get(e.source):e.source,n="string"==typeof e.target?i.get(e.target):e.target,r=(t?f(t):0)+(n?f(n):0)+12;return Math.max(40,r)}).id(e=>e.id),c=(0,Up.forceSimulation)().force("charge",(0,Up.forceManyBody)().strength(e=>{const t=n.get(e.id)??0;return-15*f(e)*Math.sqrt(t+1)})).force("collide",(0,Up.forceCollide)(e=>f(e)+3).strength(.9).iterations(2)).force("center",(0,Up.forceCenter)(o,s).strength(.8)).force("x",(0,Up.forceX)(o).strength(.06)).force("y",(0,Up.forceY)(s).strength(.06));if(c.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));a.links(e),c.force("link",a)}u?c.alpha(.3):.1>c.alpha()&&c.alpha(1),c.stop();for(let e=0;d>e;++e)c.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(t);t.x=Math.max(e,Math.min(i[0]-e,t.x)),t.y=Math.max(e,Math.min(i[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=p.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=p.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,i){const r=n.nodeStyle,o=n.edgeStyle,s=ey(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:g,c=new Map;e.forEach((e,t)=>{c.set(e.id,a[t%a.length])});const l=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Hp(t,"nodeSize")),i=r?r(Hp(t,"nodeStyle")):{},o={fill:i.fill||c.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??2,opacity:i.opacity};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),i="object"==typeof e.target?e.target:h.get(e.target);if(!t||!i)continue;if(null==t.x||null==t.y)continue;if(null==i.x||null==i.y)continue;const r=o?o(Hp(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:i.x,y2:i.y,style:{stroke:r.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const i=s(Hp(n,"nodeSize"));d.push({x:n.x,y:n.y-i-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:l,sceneEdges:u,labels:d}}};function Qp(e,t,n){const i=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,o="string"==typeof r.target?r.target:r.target.id;let s=null;if(t===e?s=o:o===e&&(s=t),s){const e=n.get(s);!e||0===e.x&&0===e.y||i.push({x:e.x,y:e.y})}}return i}function Jp(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function ey(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const i=t||[5,20],r=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&r.push(n)}if(0===r.length)return()=>i[0];const[o,s]=di(r);if(o===s)return()=>(i[0]+i[1])/2;const a=(0,Kp.scaleLinear)().domain([o,s]).range(i).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?i[0]:a(n)}}var ty=require("d3-chord"),ny=require("d3-shape"),iy=g,ry={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,i){if(0===e.length)return;const{padAngle:r=.01,groupWidth:o=20,sortGroups:s}=n,a=Math.min(i[0],i[1])/2,c=a-o,l=i[0]/2,u=i[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const p=e.length,y=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),i=f.get(t);if(void 0===n||void 0===i)continue;const r=d(e);y[n][i]=r}const g=(0,ty.chord)().padAngle(r);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,ny.arc)().innerRadius(c).outerRadius(a);for(const t of x){const n=e[t.index],i=b.centroid({innerRadius:c,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});n.x=i[0]+l,n.y=i[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=v.get("string"==typeof e.source?e.source:e.source.id),i=v.get(t);n&&(e.source=n),i&&(e.target=i)}const w=new Map;for(const e of t)w.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,i=e[t.target.index].id,r=w.get(`${n}\0${i}`)||w.get(`${i}\0${n}`);r&&(r.__chordData=t)}},buildScene(e,t,n,i){const{groupWidth:r=20,edgeOpacity:o=.5}=n,s=Math.min(i[0],i[1])/2,a=s-r,c=i[0]/2,l=i[1]/2,u=n.nodeStyle,d=n.edgeStyle,h=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:iy,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});const y=(0,ty.ribbon)().radius(a),g=[],m=[],x=[];for(let t=0;e.length>t;t++){const n=e[t],i=n.__arcData;if(!i)continue;let r;r=u?u(Hp(n,"nodeStyle")).fill||p.get(n.id)||f[t%f.length]:p.get(n.id)||f[t%f.length];const o=u?u(Hp(n,"nodeStyle")):{};g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:{fill:r,stroke:o.stroke||"black",strokeWidth:o.strokeWidth??1,opacity:o.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const i=y(t);if(!i)continue;const r=oy(i,c,l);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)s=d(Hp(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===h&&n?s=p.get(n.id)||s:t&&(s=p.get(t.id)||s)}const a=d?d(Hp(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:r,style:{fill:s,fillOpacity:a.fillOpacity??o,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:e})}if(!1!==n.showLabels){const t=(b=n.nodeLabel)?"function"==typeof b?b:e=>e[b]||e.id:null,i=s+12;for(const n of e){const e=n.__arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const o=(e.startAngle+e.endAngle)/2,s=o-Math.PI/2;x.push({x:c+Math.cos(s)*i,y:l+Math.sin(s)*i,text:r+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:g,sceneEdges:m,labels:x}}};function oy(e,t,n){const i=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return e;const r=[];let o=0;for(;i.length>o;){const e=i[o];if("M"===e||"L"===e)for(r.push(e),o++;i.length>o&&!isNaN(Number(i[o]));)r.push(Number(i[o])+t+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("C"===e)for(r.push(e),o++;i.length>o&&!isNaN(Number(i[o]));)for(let e=0;3>e&&i.length>o&&!isNaN(Number(i[o]));e++)r.push(Number(i[o])+t+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("Q"===e)for(r.push(e),o++;i.length>o&&!isNaN(Number(i[o]));)for(let e=0;2>e&&i.length>o&&!isNaN(Number(i[o]));e++)r.push(Number(i[o])+t+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("A"===e)for(r.push(e),o++;i.length>o&&!isNaN(Number(i[o]));)r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&(r.push(Number(i[o])+t+""),o++),i.length>o&&(r.push(Number(i[o])+n+""),o++);else"Z"===e||"z"===e?(r.push(e),o++):(r.push(i[o]),o++)}return r.join(" ")}var sy=require("d3-hierarchy"),ay=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function cy(e){const[t,n,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*i>150?"#222":"#fff"}function ly(e,t,n){const i=t.nodeIDAccessor;return"function"==typeof i?i(e.data)+"":"string"==typeof i&&void 0!==e.data[i]?e.data[i]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function uy(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function dy(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:ay}function hy(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function fy(e,t,n,i,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${i} ${n},${i}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+i)/2} T ${n},${i}`}{const r=(t+i)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${i}`}}var py={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,i){const r=n.__hierarchyRoot;if(!r)return;const o=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,l=(0,sy.hierarchy)(r,s);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=i;switch(o){case"tree":!function(e,t,n,i){const r=t.treeOrientation||"vertical",o=(0,sy.tree)();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(e)}(l,n,u,d);break;case"cluster":!function(e,t,n,i){const r=t.treeOrientation||"vertical",o=(0,sy.cluster)();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(e)}(l,n,u,d);break;case"treemap":!function(e,t,n,i){const r=t.padding??4,o=t.paddingTop??0,s=(0,sy.treemap)().size([n,i]).tile(sy.treemapBinary).padding(r);o>0&&s.paddingTop(o),s(e)}(l,n,u,d);break;case"circlepack":!function(e,t,n,i){const r=t.padding??4;(0,sy.pack)().size([n,i]).padding(r)(e)}(l,n,u,d);break;case"partition":!function(e,t,n,i){(0,sy.partition)().size([n,i]).padding(t.padding??1)(e)}(l,n,u,d)}const h=l.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;h.length>t;t++){const i=h[t],r={id:ly(i,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:i.value??0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===o||"cluster"===o?yy(r,i,n):"treemap"===o||"partition"===o?gy(r,i):"circlepack"===o&&my(r,i),r.__hierarchyNode=i,e.push(r),f.set(i,r)}if("tree"===o||"cluster"===o)for(const e of h)if(e.parent){const n=f.get(e.parent),i=f.get(e);n&&i&&t.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,i){const r=n.nodeStyle||(()=>({})),o=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,i,r,o){const s=[],a=[],c=[],l=n.treeOrientation||"vertical",u="radial"===l,d=i[0]/2,h=i[1]/2,f="number"==typeof(p=n.nodeSize)?p:5;var p;for(const t of e){let e=t.x,i=t.y;u&&(e+=d,i+=h);const o=r(Hp(t,"nodeStyle"));let a=o.fill||hy(n);if(n.colorByDepth&&void 0!==t.depth){const e=dy(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:i,r:f,style:{fill:a,stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const y=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;if(!t||!i)continue;let r=t.x,s=t.y,c=i.x,f=i.y;u&&(r+=d,s+=h,c+=d,f+=h);const p=fy(r,s,c,f,l),g=o(Hp(e,"edgeStyle"));a.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y},datum:e})}if(!1!==n.showLabels){const t=uy(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let i,r,o,s=n.x,a=n.y;if(u&&(s+=d,a+=h),u){const e=s-d,t=a-h,n=Math.sqrt(e*e+t*t);n>0?(i=s+e/n*10,r=a+t/n*10,o=0>e?"end":"start"):(i=s,r=a-12,o="middle")}else"horizontal"===l?(n.data?.children&&0!==n.data.children.length?(i=s-f-6,o="end"):(i=s+f+6,o="start"),r=a):(i=s,r=a+f+14,o="middle");c.push({x:i,y:r,text:e+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(e,t,n,i,r,o);case"treemap":case"partition":return function(e,t,n,i){const r=[],o=[];for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;const s=i(Hp(n,"nodeStyle"));let a=s.fill||hy(t);if(t.colorByDepth&&void 0!==n.depth){const e=dy(t);a=e[n.depth%e.length]}r.push({type:"rect",x:n.x0,y:n.y0,w:e,h:o,style:{fill:a,stroke:s.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=uy(t.nodeLabel),r=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,c=a.y1-a.y0;if(0>=e||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===r&&!l)continue;if("parent"===r&&l)continue}const u=n?n(a):a.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let d=i(Hp(a,"nodeStyle")).fill||hy(t);if(t.colorByDepth&&void 0!==a.depth){const e=dy(t);d=e[a.depth%e.length]}const h="string"==typeof d?cy(d):t.themeSemantic?.text??"#000";o.push(l?{x:a.x0+e/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:h}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:r,sceneEdges:[],labels:o}}(e,n,0,r);case"circlepack":return function(e,t,n,i){const r=[],o=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const o=i(Hp(n,"nodeStyle"));let s=o.fill||hy(t);if(t.colorByDepth&&void 0!==n.depth){const e=dy(t);s=e[n.depth%e.length]}r.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:s,stroke:o.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=uy(t.nodeLabel);for(const r of e){const e=r.__radius??5,s=n?n(r):r.id;if(!s)continue;if(15>e)continue;const a=!(r.data?.children&&r.data.children.length>0);let c=i(Hp(r,"nodeStyle")).fill||hy(t);if(t.colorByDepth&&void 0!==r.depth){const e=dy(t);c=e[r.depth%e.length]}if(a){const n="string"==typeof c?cy(c):t.themeSemantic?.text??"#000";o.push({x:r.x,y:r.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else o.push({x:r.x,y:r.y-e+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:r,sceneEdges:[],labels:o}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function yy(e,t,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=t.x,i=t.y;e.x=i*Math.cos(n-Math.PI/2),e.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function gy(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function my(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}var xy=require("d3-shape");function by(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var vy={sankey:Vp,force:Zp,chord:ry,tree:py,cluster:py,treemap:py,circlepack:py,partition:py,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,i){const r=n.__hierarchyRoot;r&&function(e,t,n,i,r){const o=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),s=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),a=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),c=n.orbitSize??2.95,l=n.orbitEccentricity??1,u="number"==typeof c?()=>c:c,d="number"==typeof l?()=>l:l,h=by(n);h.metaMap.clear(),i.length=0,r.length=0;const f=new Map;function p(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const y=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,x=p(s(e));i.push({id:x,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,c,l,f,y,g){const m=o(t);if(!m?.length)return;const x=m.length;let b=0,v=0,w=0;for(;x>v;)v+=a[Math.min(w,a.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){const v=a[Math.min(x,a.length-1)],w=m.slice(k,k+v);if(!w.length)break;const S=(x+1)/b,A={id:n,depth:y,data:t,parentId:n},M=g?f/u(A)*S:f*S,P=(0,xy.pie)().value(e=>{const t=o(e)?.length;return t?4:1}).sort(null)(w),_=d(A);for(let t=0;w.length>t;t++){const o=(P[t].startAngle+P[t].endAngle)/2,a=w[t],u=p(s(a)),d=c+M*Math.sin(o),f=l+M*Math.cos(o)*_;i.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),h.metaMap.set(u,{ring:M,angle:o,depth:y,parentId:n,eccentricity:_}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(a,u,d,f,M,y+1,!0)}k+=v}}(e,x,y,g,m,1,!1)}(r,i,n,e,t)},buildScene(e,t,n,i){const r=n.nodeStyle,o=n.nodeSize,s="number"==typeof o?()=>o:"function"==typeof o?o:()=>6,a=[],c=[],l=[];if(!1!==n.orbitShowRings){const t=by(n),i=new Map;for(const t of e)i.set(t.id,t);const r=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=i.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;r.has(n)||r.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const o=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:i}]of r)for(let r=0;o>r;r++){const a=r/o*Math.PI*2,l=(r+1)/o*Math.PI*2;c.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*i,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*i,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Hp(t,"nodeSize")),i=r?r(Hp(t,"nodeStyle")):{};a.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:i.fill||n.themeSemantic?.primary||"#6366f1",stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&c.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=s(Hp(n,"nodeSize"));if(4>=e)continue;const i="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;l.push({x:n.x,y:n.y+e+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(e,t,n,i,r)=>!1!==n.orbitAnimated&&(function(e,t){const n=by(t),i=t.orbitSpeed??.25,r=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),o=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=i*(Math.PI/6),a=new Map;for(const t of e)a.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const i=a.get(e.parentId);if(!i)continue;const c=e.angle+o*s*r({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=i.x+e.ring*Math.sin(c),t.y=i.y+e.ring*Math.cos(c)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}},wy=require("react/jsx-runtime");function ky(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}var Sy=new Set(["tree","cluster","treemap","circlepack","partition"]);function Ay(e,t){const n=Xh(e.theme),i=e.chartType||"force",r=()=>Kh({frameType:"network",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,nodeCount:0,edgeCount:0}),o=e.size||[500,500],s={top:20,right:20,bottom:20,left:20,...e.margin},a=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;if(!t)return[];const i=B(e.nodes||[]);if(i.length>0)return ff(i,t);const r=Array.isArray(e.edges)?B(e.edges):[];if(0===r.length)return[];const o=ky(e.sourceAccessor,"source"),s=ky(e.targetAccessor,"target");return ff(Array.from(new Set(r.flatMap(e=>[o(e),s(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[],c=e.legendPosition;oi(e.legend)||si(e.legend)?Sf(s,{legend:e.legend,theme:n,position:c||"right",size:o,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&a.length>0&&kf(s,{categories:a,colorScheme:e.colorScheme,theme:n,position:c||"right",size:o,hasTitle:!!e.title,legendLayout:e.legendLayout});const l=o[0]-s.left-s.right,u=o[1]-s.top-s.bottom,d=function(e){return vy[e]}(i);if(!d&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${i}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const h={chartType:i,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||n.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let f,p;if(Sy.has(i)){const i=e.data||e.edges;if(!i||Array.isArray(i))return t&&(t.evidence=r()),Zf.renderToStaticMarkup(Pf(null,{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,idPrefix:e._idPrefix}));h.__hierarchyRoot=i,f=[],p=[]}else{const i=B(e.nodes||[]),a=Array.isArray(e.edges)?B(e.edges):[];if(0===i.length&&0===a.length)return t&&(t.evidence=r()),Zf.renderToStaticMarkup(Pf(null,{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,idPrefix:e._idPrefix}));if(p=function(e,t){const n=ky(t.sourceAccessor,"source"),i=ky(t.targetAccessor,"target"),r=ky(t.valueAccessor,"value");return e.map(e=>({source:n(e)+"",target:i(e)+"",value:Number(r(e))||1,y0:0,y1:0,sankeyWidth:0,data:e}))}(a,h),0===i.length&&p.length>0){const e=new Set;for(const t of p){const n=wf(t.source),i=wf(t.target);n&&e.add(n),i&&e.add(i)}f=Array.from(e).map(e=>({id:e,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:e}}))}else f=function(e,t){const n=ky(t.nodeIDAccessor,"id");return e.map(e=>({id:n(e)+"",x:e.x??0,y:e.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:e}))}(i,h)}let y=[],m=[],x=[],b=null;if(h.customNetworkLayout){const e=h.colorScheme,t=iu(e,n.colors.categorical,g),i=ru(t,e),r={nodes:f,edges:p,dimensions:{width:l,height:u,plot:{x:0,y:0,width:l,height:u}},theme:{semantic:n.colors,categorical:[...t]},resolveColor:i,config:h.layoutConfig??{}},o=h.customNetworkLayout(r);y=o.sceneNodes??[],m=o.sceneEdges??[],x=o.labels??[],b=o.overlays??null}else if(d){d.computeLayout(f,p,h,[l,u]);const e=d.buildScene(f,p,h,[l,u]);y=e.sceneNodes,m=e.sceneEdges,x=e.labels}const v=Gh(n);for(const e of x)e.fill||(e.fill=v.text);t&&(t.evidence=Kh({frameType:"network",width:o[0],height:o[1],marks:[...y.map(e=>({type:"node:"+(e.type??"node")})),...m.map(e=>({type:"edge:"+(e.type??"edge")}))],title:e.title,description:e.description,annotations:e.annotations,nodeCount:y.length,edgeCount:m.length}));const w=m.map((e,t)=>function(e,t){switch(e.type){case"line":return(0,eo.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e;return(0,eo.jsx)("path",{d:n.pathD,fill:no(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return(0,eo.jsx)("path",{d:n.pathD,fill:no(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"curved":{const n=e;return(0,eo.jsx)("path",{d:n.pathD,fill:no(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)).filter(Boolean),k=y.map((e,t)=>function(e,t){switch(e.type){case"circle":{const n=e;return(0,eo.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:no(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-circle-"+t)}case"rect":{const n=e;return(0,eo.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:no(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+t)}case"arc":{const n=e,i=(0,Ur.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(to)||"";return(0,eo.jsx)("path",{d:i,transform:`translate(${n.cx},${n.cy})`,fill:no(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+t)}case"symbol":{const n=e,i=ht(n.symbolType,n.size,n.path);return(0,eo.jsx)("path",{d:i,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?no(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return ro(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)).filter(Boolean),S=x.map((e,t)=>function(e,t){return(0,eo.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean),A=e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{},layout:{width:l,height:u},theme:n,idPrefix:e._idPrefix}):null,M=e.showLegend?(()=>{const t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;if(!t)return[];const r=ff(f.length>0?f.map(e=>e.data||{id:e.id}):Array.from(new Set(p.flatMap(e=>[wf(e.source),wf(e.target)]).filter(Boolean))).map(e=>({id:e})),t);return 0===r.length?null:hf({categories:r,colorScheme:e.colorScheme,theme:n,position:e.legendPosition||"right",totalWidth:o[0],totalHeight:o[1],margin:s,hasTitle:!!e.title,legendLayout:e.legendLayout})})():null,P=Kf.isValidElement(e.legend)?e.legend:Af(e.legend,{theme:n,position:e.legendPosition||"right",size:o,margin:s,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||M;return Zf.renderToStaticMarkup(Pf((0,wy.jsxs)(wy.Fragment,{children:[e.backgroundGraphics,w,k,S,A,e.foregroundGraphics,b]}),{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,legend:P,idPrefix:e._idPrefix}))}var My=c(require("react")),Py=c(require("react-dom/server")),_y=require("d3-geo"),jy=require("d3-quadtree"),Cy=require("d3-geo"),Iy={mercator:Cy.geoMercator,equalEarth:Cy.geoEqualEarth,albersUsa:Cy.geoAlbersUsa,orthographic:Cy.geoOrthographic,naturalEarth:Cy.geoNaturalEarth1,equirectangular:Cy.geoEquirectangular};function Ty(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Ry(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function Ly(e,t,n){return e?"function"==typeof e?{...n,...e(t)}:{...n,...e}:{...n}}function $y(e,t){if(2>e.length)return[e];const n=.4*t,i=[];let r=[e[0]];for(let t=1;e.length>t;t++){const o=e[t];Math.abs(o[0]-e[t-1][0])>n?(2>r.length||i.push(r),r=[o]):r.push(o)}return 2>r.length||i.push(r),i}function Ey(e,t,n=24){const i=t[0]-e[0],r=t[1]-e[1],o=Math.sqrt(i*i+r*r);if(0===o)return[e,t];const s=-r/o,a=i/o,c=Math.min(.3*o,80),l=(e[0]+t[0])/2+s*c,u=(e[1]+t[1])/2+a*c,d=[];for(let i=0;n>=i;i++){const r=i/n,o=1-r;d.push([o*o*e[0]+2*o*r*l+r*r*t[0],o*o*e[1]+2*o*r*u+r*r*t[1]])}return d}function Dy(e,t){if(2>e.length)return e;const n=t/2+1,i=[];for(let t=0;e.length>t;t++){const r=e[t];let o,s;0===t?(o=e[1][0]-r[0],s=e[1][1]-r[1]):t===e.length-1?(o=r[0]-e[t-1][0],s=r[1]-e[t-1][1]):(o=e[t+1][0]-e[t-1][0],s=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(o*o+s*s)||1;i.push([r[0]+s/a*n,r[1]+-o/a*n])}return i}function zy(e,t,n,i,r){const o=t[0]-e[0],s=t[1]-e[1],a=Math.sqrt(o*o+s*s);if(0===a)return[e,t];const c=s/a,l=-o/a,u=r/2+1;return[[e[0]+c*u,e[1]+l*u],[t[0]+c*u,t[1]+l*u]]}var By=require("d3-scale"),Fy=class e{constructor(e){this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this._stylePaintPending=!1,this.config=e}updateConfig(e){this.config={...this.config,...e},"customLayout"in e&&!e.customLayout&&(this.lastCustomLayoutFailure=null)}setAreas(e){this.areas=e}setPoints(e){this.pointData=e,this.streaming=!1}setLines(e){this.lineData=e.slice()}initStreaming(e=500){this.pointBuffer=new _e(e),this.timestampBuffer=new _e(e),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=Ne();jt(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t}pushMany(e){this.pointBuffer||this.initStreaming();const t=Ne();for(const n of e)jt(this.pointBuffer,n,this.timestampBuffer,t);this.lastIngestTime=t}pushLine(e){null!=e&&"object"==typeof e&&(this.lineData.push(e),this.version++)}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return;const t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){for(const e of t)this.lineData.push(e);this.version++}}removeLine(e){const{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");const n="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]),r=[];return this.lineData=this.lineData.filter(e=>!i.has(n(e)+"")||(r.push(e),!1)),r.length>0&&this.version++,r}getLines(){return this.lineData.slice()}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>i.has(n(e)+"");Ct(this.pointBuffer,this.timestampBuffer,e);const t=this.pointBuffer.remove(e);return t.length>0&&this.version++,t}{const e=[];return this.pointData=this.pointData.filter(t=>!i.has(n(t)+"")||(e.push(t),!1)),e.length>0&&this.version++,e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++}setLayoutSelection(e){this.config.layoutSelection=e}consumeStylePaintPending(){const e=this._stylePaintPending;return this._stylePaintPending=!1,e}restyleScene(e){const t=this._customRestyle;if(t){for(const n of this.scene){const i=this._baseStyles.get(n)??n.style,r=t(n,e);n.style=r?{...i,...r}:i}this._stylePaintPending=!0}}computeScene(e){const{config:t}=this,n=this.projection,i=this.geoPath,r=this.scales,o=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(e){if(!e)return(0,Cy.geoEqualEarth)();if("string"==typeof e){const t=Iy[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),(0,Cy.geoEqualEarth)())}if("object"==typeof e&&"type"in e){const t=Iy[e.type],n=t?t():(0,Cy.geoEqualEarth)();return e.rotate&&"rotate"in n&&n.rotate(e.rotate),e.center&&"center"in n&&n.center(e.center),n}return e}(t.projection),this.geoPath=(0,_y.geoPath)(this.projection),this.fitProjection(e),this.geoPath=(0,_y.geoPath)(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(e,t)=>l([e,t]),invertedPoint:(e,t)=>l.invert?l.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=n,this.geoPath=i,this.scales=r,this.baseScale=o,this.baseTranslate=s,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){const t=e.width/2,n=e.height/2,i=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:n}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,t.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(e){const t=this.projection,n=this.config,i=[...this.areas],r=Ty(n.xAccessor,"lon"),o=Ty(n.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const e=s.map(e=>[r(e),o(e)]);i.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const a=Ry(n.lineDataAccessor);for(const e of this.lineData){const t=a(e);if(t&&t.length>0){const e=t.map(e=>[r(e),o(e)]);i.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==i.length){if(n.projectionExtent){const[[i,r],[o,s]]=n.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[i,r],[o,r],[o,s],[i,s],[i,r]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const i=n.fitPadding??0,r=Math.min(e.width,e.height);t.scale(r/2-r*i),t.translate([e.width/2,e.height/2])}else{const r={type:"FeatureCollection",features:i},o=n.fitPadding??0;1>o||"undefined"==typeof process||"production"===process.env.NODE_ENV||console.warn(`[semiotic] fitPadding=${o} looks like pixels, but it's a fraction of the plot (0–0.5). A value >= 1 collapses the projection off-canvas — use e.g. 0.06.`);const s=e.width*o,a=e.height*o;t.fitExtent([[s,a],[e.width-s,e.height-a]],r)}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const n=this.projection;if(!n)return;const i=this.geoPath,r=this.scales,o=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*e.k),n.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=(0,_y.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(o),n.translate(s),this.currentZoom=a,this.geoPath=i,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const n=this.projection;if(!n)return;const i=this.geoPath,r=this.scales,o=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*e),n.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=(0,_y.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(o),n.translate(s),this.currentZoom=a,this.geoPath=i,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const n=this.projection;if(!n||!n.rotate)return;const i=this.geoPath,r=this.scales,o=[...n.rotate()];n.rotate(e),this.geoPath=(0,_y.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.rotate(o),this.geoPath=i,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,n=0;for(const e of this.scene)"point"===e.type&&(n++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=n)return void(this._quadtree=null);const i=Array(n);let r=0;for(const e of this.scene)"point"===e.type&&(i[r++]=e);this._quadtree=(0,jy.quadtree)().x(e=>e.x).y(e=>e.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,n=this.projection,i=this.geoPath,r=Ty(t.xAccessor,"lon"),o=Ty(t.yAccessor,"lat");if(t.customLayout&&this.scales){const n=t.layoutMargin??{top:0,right:0,bottom:0,left:0},i=iu(t.colorScheme,t.themeCategorical,R),r={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:n,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...i]},resolveColor:ru(i,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null};let o;try{o=t.customLayout(r)}catch(e){const n=null!==this.lastCustomLayoutResult,i=vt("geo",e,n,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",e);try{t.onLayoutError?.(i)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return n?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const s=o.nodes??[];if(this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null,this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const e of s)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return mt({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap;const s=[],a=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(t),c=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(t),l=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(t);if(t.graticule){const n=!0===t.graticule?{}:t.graticule,r=(0,_y.geoGraticule)();n.step&&r.step(n.step);const o=i(r())||"";o&&s.push({type:"geoarea",pathData:o,centroid:[e.width/2,e.height/2],bounds:[[0,0],[e.width,e.height]],screenArea:0,style:{fill:"none",stroke:n.stroke||"#e0e0e0",strokeWidth:n.strokeWidth||.5,strokeDasharray:n.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of this.areas){const n=i(e);if(!n)continue;const r=i.centroid(e),o=i.bounds(e),c=i.area(e),l=Ly(t.areaStyle,e,a);s.push({type:"geoarea",pathData:n,centroid:r,bounds:o,screenArea:c,style:l,datum:e,interactive:!0})}const u=Ry(t.lineDataAccessor);for(const i of this.lineData){const a=u(i);if(!a||2>a.length)continue;let l=[];if("geo"===t.lineType){const e=Array(a.length);for(let t=0;a.length>t;t++)e[t]=[r(a[t]),o(a[t])];for(let t=0;e.length-1>t;t++){const i=e[t],r=e[t+1],o=(0,_y.geoDistance)(i,r)||0,s=Math.max(2,Math.ceil(o/(Math.PI/180))),a=(0,_y.geoInterpolate)(i,r);for(let e=0;s>=e;e++){if(t>0&&0===e)continue;const i=n(a(e/s));null!=i&&l.push(i)}}}else for(let e=0;a.length>e;e++){const t=a[e],i=n([r(t),o(t)]);null!=i&&l.push(i)}if(2>l.length)continue;const d=Ly(t.lineStyle,i,c),h="number"==typeof d.strokeWidth?d.strokeWidth:1;2!==a.length||2>l.length||"arc"!==t.flowStyle?2!==a.length||2>l.length||"offset"!==t.flowStyle||(l="geo"===t.lineType?Dy(l,h):zy(l[0],l[l.length-1],0,0,h)):l=Ey(l[0],l[l.length-1]);const f=$y(l,e.width);if(f.length>1)for(const e of f){if(2>e.length)continue;const t={type:"line",path:e,style:{...d,_edgeFade:!0},datum:i};s.push(t)}else s.push({type:"line",path:2>l.length&&f[0]||l,style:d,datum:i})}const d=this.getPoints(),h=t.pointIdAccessor?"function"==typeof t.pointIdAccessor?t.pointIdAccessor:e=>e[t.pointIdAccessor]:null,f=n.clipAngle?n.clipAngle()??0:0,p=f>0?f*Math.PI/180:null,y=n.rotate?n.rotate():[0,0,0],g="function"==typeof n.center?n.center():[0,0],m=[(g[0]??0)-y[0],(g[1]??0)-y[1]];for(let e=0;d.length>e;e++){const i=d[e],a=r(i),c=o(i);if(null!=p&&(0,_y.geoDistance)([a,c],m)>p)continue;const u=n([a,c]);if(!u)continue;const f=t.pointStyle?t.pointStyle(i):{...l},y={type:"point",x:u[0],y:u[1],r:f.r||4,style:f,datum:i,pointId:h?h(i)+"":void 0};s.push(y)}return s}applyCartogramTransform(e,t){const n=function(e,t,n,i){const r=e.filter(e=>"point"===e.type);if(2>r.length)return null;const o=t.strength??1;if(0===o)return null;const s=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,a="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],c=r.find(e=>e.datum&&s(e.datum)+""==t.center+"");if(!c)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const l=c.x,u=c.y,d=hi(r.map(e=>e.datum?a(e.datum):NaN).filter(e=>isFinite(e)&&e>=0),1),h=Math.min(n.width,n.height)/2,f=(0,By.scaleLinear)().domain([0,d]).range([0,h]);i>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let t=e.length-1;t>=0;t--){const n=e[t];"geoarea"===n.type&&n.interactive&&e.splice(t,1)}for(const e of r){if(e===c)continue;if(!e.datum)continue;const t=Math.atan2(e.y-u,e.x-l),n=Math.sqrt((e.x-l)**2+(e.y-u)**2),i=a(e.datum),r=n+((isFinite(i)?f(i):n)-n)*o;e.x=l+Math.cos(t)*r,e.y=u+Math.sin(t)*r}const p=n.width/2,y=n.height/2,g=p-c.x,m=y-c.y;if(Math.abs(g)>.5||Math.abs(m)>.5)for(const e of r)e.x+=g,e.y+=m;const x={cx:p,cy:y,maxCost:d,availableRadius:h},b=e.filter(e=>"line"===e.type);if(b.length>0&&"fractional"!==t.lineMode){const e=new Map;for(const t of r)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of b){const n=t.datum?.source,i=t.datum?.target;if(n&&i){const r=e.get(n+""),o=e.get(i+"");r&&o&&(t.path=[r,o])}}}return x}(this.scene,e,t,this.areas.length);n&&(this.cartogramLayout=n)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const n=this.scene.filter(e=>"point"===e.type);for(let i=0;n.length>i;i++){const r=Oe(e,i,t);n[i]._decayOpacity=r,n[i].style={...n[i].style,opacity:r}}}applyPulse(){const e=this.config.pulse;if(!e||!this.timestampBuffer)return;const t=Ne(),n=this.scene.filter(e=>"point"===e.type),i=this.timestampBuffer.toArray();for(let r=0;n.length>r&&i.length>r;r++){const o=qe(e,i[r],t);o>0&&(n[r]._pulseIntensity=o,n[r]._pulseColor=e.color||"rgba(255,255,255,0.6)",n[r]._pulseGlowRadius=e.glowRadius??4)}}get hasActivePulses(){return He(this.config.pulse??{},this.timestampBuffer)}startTransition(e){const t=this.config.transition?.duration??300;if(0>=t)return;const n=new Map;for(const t of e)"point"===t.type&&t.pointId&&n.set(t.pointId,[t.x,t.y]);const i=this.scene.filter(e=>"point"===e.type);let r=!1;for(const e of i)if(e.pointId){const t=n.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(r=!0))}for(const e of i)e.pointId&&!n.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??1,e.style={...e.style,opacity:0},r=!0);r&&(this.activeTransition={startTime:Ne(),duration:t})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(e){if(!this.activeTransition)return!1;const t=Be(e,this.activeTransition),n=ze(t),i=this.scene.filter(e=>"point"===e.type);for(const e of i){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=Fe(e.x,e._targetX,n),e.y=Fe(t,e._targetY,n)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*n})}if(t>=1){for(const e of i)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0),null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};Fy.QUADTREE_THRESHOLD=500;var Ny=Fy,Oy=require("react/jsx-runtime");function Wy(e,t){const n=Xh(e.theme),i=e.size||[e.width||600,e.height||400],r={top:10,right:10,bottom:10,left:10,...e.margin},o=Array.isArray(e.areas)?B(e.areas):e.areas,s=B(e.points),a=B(e.lines),c=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;return ff(s.length>0?s:Array.isArray(o)&&o.length>0?"string"==typeof t?o.map(e=>({...e.properties||{},...e})):o:[],t)})():[],l=e.legendPosition;oi(e.legend)||si(e.legend)?Sf(r,{legend:e.legend,theme:n,position:l||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout}):e.showLegend&&c.length>0&&kf(r,{categories:c,colorScheme:e.colorScheme,theme:n,position:l||"right",size:i,hasTitle:!!e.title,legendLayout:e.legendLayout});const u=i[0]-(r.left??0)-(r.right??0),d=i[1]-(r.top??0)-(r.bottom??0),h={projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,themeCategorical:n.colors.categorical,themeSemantic:xe(n)},f=new Ny(h);if(o){if("string"==typeof o)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${o}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${o}')\` before calling renderGeoToStaticSVG.`);f.setAreas(o)}if(e.points&&f.setPoints(s),e.lines&&f.setLines(a),f.computeScene({width:u,height:d}),t&&(t.evidence=Kh({frameType:"geo",width:i[0],height:i[1],marks:f.scene,title:e.title,description:e.description,annotations:e.annotations,legendItems:c.length>0?c.length:void 0})),0===f.scene.length){const t=e.backgroundGraphics||e.foregroundGraphics||e.annotations||f.customLayoutOverlays?(0,Oy.jsxs)(Oy.Fragment,{children:[e.backgroundGraphics,e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([e,t])=>f.scales.projectedPoint(e,t):void 0},layout:{width:u,height:d},theme:n,idPrefix:e._idPrefix}):null,e.foregroundGraphics,f.customLayoutOverlays]}):null;return Py.renderToStaticMarkup(Pf(t,{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:d,idPrefix:e._idPrefix}))}const p=f.scene.map((e,t)=>function(e,t){switch(e.type){case"geoarea":{const n=e;return n.pathData?(0,eo.jsx)("path",{d:n.pathData,fill:no(n.style.fill,"#e0e0e0"),fillOpacity:n.style.fillOpacity??1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:n._decayOpacity??1},"geoarea-"+t):null}case"point":{const n=e;return(0,eo.jsx)("circle",{cx:n.x,cy:n.y,r:n.r,fill:no(n.style.fill),fillOpacity:n.style.fillOpacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n._decayOpacity??n.style.opacity??1},"point-"+t)}case"line":{const n=e;if(2>n.path.length)return null;const i="M"+n.path.map(e=>`${e[0]},${e[1]}`).join("L");return(0,eo.jsx)("path",{d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||1.5,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity??1},"line-"+t)}case"glyph":return ro(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}(e,t)).filter(Boolean),y=e.annotations?xf({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([e,t])=>f.scales.projectedPoint(e,t):void 0},layout:{width:u,height:d},theme:n,idPrefix:e._idPrefix}):null,g=e.showLegend?0===c.length?null:hf({categories:c,colorScheme:e.colorScheme,theme:n,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout}):null,m=My.isValidElement(e.legend)?e.legend:Af(e.legend,{theme:n,position:e.legendPosition||"right",size:i,margin:r,hasTitle:!!e.title,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||g;return Py.renderToStaticMarkup(Pf((0,Oy.jsxs)(Oy.Fragment,{children:[e.backgroundGraphics,p,y,e.foregroundGraphics,f.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:d,legend:m,idPrefix:e._idPrefix}))}function qy(e,t){const n=e.size??[e.width??600,e.height??400],i=new Fl(e.config);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&i.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));const r=qu(i,{...e,width:n[0],height:n[1],idPrefix:e.idPrefix??e._idPrefix??"physics"});return t&&(t.evidence=Kh({frameType:"physics",width:n[0],height:n[1],marks:r.scene.sceneNodes,title:e.title,description:e.description,annotations:[],extraWarnings:0===r.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),r.svg}var Yy=require("react/jsx-runtime");function Hy(e,t){switch(e){case"xy":return jf(t);case"ordinal":return Uf(t);case"network":return Ay(t);case"geo":return Wy(t);case"physics":return qy(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function Xy(e){return jf(e)}function Gy(e){return Uf(e)}function Vy(e){return Ay(e)}function Uy(e){return Wy(e)}var Ky=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout"];function Zy(e,t,n){return Jy(e,t).svg}function Qy(e,t,n){const i={},{svg:r,frameType:o}=Jy(e,t,0,i),s=i.evidence??Kh({frameType:o,width:"number"==typeof t.width?t.width:600,height:"number"==typeof t.height?t.height:400,marks:[],title:"string"==typeof t.title?t.title:void 0,description:"string"==typeof t.description?t.description:void 0,annotations:t.annotations,extraWarnings:["NO_EVIDENCE"]});return s.component=e,{svg:r,evidence:s}}function Jy(e,t,n,i){const{data:r,width:o=600,height:s=400,theme:a,title:c,description:l,showLegend:d,showGrid:h,background:f,className:p,annotations:y,margin:g,colorScheme:m,colorBy:x,legendPosition:b,...v}=t,w=[o,s],k={...v.frameProps||{},...function(e,t){const n={};for(const i of t)void 0!==e[i]&&(n[i]=e[i]);return n}(v,Ky),theme:a,title:c,description:l,showLegend:d,showGrid:h,background:f,className:p,annotations:y,size:w,...void 0!==g&&{margin:g},...void 0!==m&&{colorScheme:m},...void 0!==b&&{legendPosition:b},_idPrefix:v._idPrefix},S=Hh[e];if(!S)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const A=S.buildProps(r,x,m,k,v);let M=(0,{xy:jf,ordinal:Uf,network:Ay,geo:Wy,physics:qy}[S.frameType])(A,i);if("GaugeChart"===e&&A.__gauge){const e=A.__gauge,t=k.margin||{top:20,right:20,bottom:30,left:40},n=(o||300)-t.left-t.right,i=(s||300)-t.top-t.bottom,r=Math.min(n,i)/2*.85,c=t.left+n/2,l=t.top+i/2,d=(e.startAngleDeg+(e.gMax===e.gMin?0:(Math.max(e.gMin,Math.min(e.gMax,e.value??e.gMin))-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,h=Xh(a).colors.text,f=u.renderToStaticMarkup((0,Yy.jsxs)(Yy.Fragment,{children:[(0,Yy.jsx)("line",{x1:c,y1:l,x2:c+r*Math.cos(d),y2:l+r*Math.sin(d),stroke:h,strokeWidth:2.5,strokeLinecap:"round"}),(0,Yy.jsx)("circle",{cx:c,cy:l,r:4,fill:h})]}));M=M.replace("</svg>",f+"</svg>")}return{svg:M,frameType:S.frameType}}function eg(e,t={}){const{title:n,subtitle:i,theme:r,width:o=1200,height:s,layout:a={},background:c}=t,l=Gh(Xh(r)),d=a.columns||2,h=a.gap??16;let f=0;n&&(f+=30),i&&(f+=20),f>0&&(f+=10);const p=Math.floor((o-h-h*(d-1))/d),y=[];let g=0,m=f+h,x=0;for(const t of e){const e=Math.min(t.colSpan||1,d),n=t.props.height||300;g+e>d&&(m+=x+h,g=0,x=0),y.push({chart:t,x:h/2+g*(p+h),y:m,w:p*e+h*(e-1),h:n}),x=Math.max(x,n),g+=e}const b=s||m+x+h,v=y.map((e,t)=>{const{chart:n,x:i,y:o,w:s,h:a}=e,c={...n.props,width:s,height:a,theme:r,_idPrefix:"chart-"+t};let l;return l=n.component?Zy(n.component,c):n.frameType?Hy(n.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,(0,Yy.jsx)("g",{transform:`translate(${i},${o})`,children:(0,Yy.jsx)("foreignObject",{width:s,height:a,children:(0,Yy.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+t)});return u.renderToStaticMarkup((0,Yy.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:b,role:"img","aria-label":n||"Dashboard",style:{fontFamily:l.fontFamily},children:[n&&(0,Yy.jsx)("title",{children:n}),c&&(0,Yy.jsx)("rect",{x:0,y:0,width:o,height:b,fill:c}),n&&(0,Yy.jsx)("text",{x:o/2,y:24,textAnchor:"middle",fontSize:l.titleSize+4,fontWeight:"bold",fill:l.text,fontFamily:l.fontFamily,children:n}),i&&(0,Yy.jsx)("text",{x:o/2,y:n?46:20,textAnchor:"middle",fontSize:l.labelSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:i}),v]}))}var tg=c(require("react-dom/server")),ng=require("react/jsx-runtime");function ig(e,t,n,i={}){const{stepSize:r,windowSize:o,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:d="ease-out",decay:h}=i,f=n.width||600,p=n.height||400,y=Xh(n.theme),g={...n,...a&&{xExtent:a},...c&&{yExtent:c}};if(!t||0===t.length)return[];const m=r||Math.max(1,Math.ceil(t.length/(s||Math.min(60,Math.max(10,t.length))))),x=[];for(let e=m;t.length>=e;e+=m)x.push(e);x[x.length-1]!==t.length&&x.push(t.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),v={top:20,right:20,bottom:30,left:40,...n.margin},w=f-v.left-v.right,k=p-v.top-v.bottom,S=[];if(b)for(let i=0;x.length>i;i++){const r=x[i],s=t.slice(o?Math.max(0,r-o):0,r),a={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:n.projection||"vertical",oAccessor:n.oAccessor||n.categoryAccessor||"category",rAccessor:n.rAccessor||n.valueAccessor||"value",colorAccessor:n.colorAccessor||n.colorBy,stackBy:n.stackBy,groupBy:n.groupBy,barPadding:n.barPadding,innerRadius:n.innerRadius,normalize:n.normalize,bins:n.bins,colorScheme:n.colorScheme||y.colors.categorical,...h&&{decay:h}},c=new Xf(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:w,height:k}),c.scene.length>0&&S.push(lg(c.scene,f,p,y,g))}else for(let i=0;x.length>i;i++){const r=x[i],s=t.slice(o?Math.max(0,r-o):0,r),m={chartType:e,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:n.colorAccessor||n.colorBy,groupAccessor:n.groupAccessor||n.lineBy,lineDataAccessor:n.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:n.colorScheme||y.colors.categorical,lineStyle:n.lineStyle,pointStyle:n.pointStyle,areaStyle:n.areaStyle,sizeAccessor:n.sizeAccessor||n.sizeBy,sizeRange:n.sizeRange,...h&&{decay:h},...l>0&&{transition:{duration:l*(1e3/u),easing:d}}},b=new Ot(m);if(b.ingest({inserts:s,bounded:!0}),b.computeScene({width:w,height:k}),0===b.scene.length)continue;const v=b.scales?{y:b.scales.y}:void 0;if(S.push(cg(b.scene,f,p,y,g,v)),l>0&&i>0&&b.activeTransition){const e=l*(1e3/u);for(let t=1;l>=t;t++)b.advanceTransition(b.activeTransition.startTime+t/l*e),S.push(cg(b.scene,f,p,y,g,v))}}return S}function rg(e,t,n={}){return t.map(t=>{try{return Zy(e,{...n,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width||t.width||600}" height="${n.height||t.height||400}"></svg>`}})}function og(e,t,n){const i=t.size??[t.width??600,t.height??400],r=Xh(t.theme),o=Gh(r),s=t.background||r.colors.background,a=t.idPrefix??"physics-gif",c=t.title?`${a}-title-${n}`:void 0,l=t.description?`${a}-desc-${n}`:void 0,u=[c,l].filter(Boolean).join(" ")||void 0,d=Ou(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),h=(0,ng.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,role:"img","aria-labelledby":u,style:{fontFamily:o.fontFamily},children:[t.title&&(0,ng.jsx)("title",{id:c,children:t.title}),t.description&&(0,ng.jsx)("desc",{id:l,children:t.description}),s&&"transparent"!==s?(0,ng.jsx)("rect",{x:0,y:0,width:i[0],height:i[1],fill:s}):null,(0,ng.jsx)("g",{id:`${a}-frame-${n}`,children:d.map((e,t)=>so(e,t,`${a}-${n}`))})]});return tg.renderToStaticMarkup(h)}function sg(e,t={}){const{fps:n=12,frameCount:i,durationSeconds:r=2,includeInitialFrame:o=!0,stepDt:s,stepsPerFrame:a,background:c}=t,l=Math.max(.001,s??e.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,n)/l)),d=i??Math.max(1,Math.ceil(r*Math.max(1,n))),h=c?{...e,background:c}:e,f=new Fl(e.config);e.initialSpawns?.length&&f.enqueue(e.initialSpawns,e.initialSpawnPacing);const p=[];for(o&&(f.tick(0),p.push(og(f,h,0)));d>p.length;){for(let e=0;u>e;e+=1)f.tick(l);p.push(og(f,h,p.length))}return p}function ag(e,t){const n=e.background||t.colors.background;return n&&"transparent"!==n?n:null}function cg(e,t,n,i,r,o){const s=Gh(i),a={top:20,right:20,bottom:30,left:40,...r.margin},c=t-a.left-a.right,l=n-a.top-a.bottom,u=ag(r,i),d=e.map((e,t)=>so(e,t)).filter(Boolean),h=function(e,t,n,i,r,o){if(!e||0===e.length)return null;const s=Gh(i),a=[];for(let i=0;e.length>i;i++){const c=e[i];if("y-threshold"===c.type&&null!=c.value){let e=null;if(o)e=o(c.value);else if(r){const[t,i]=r,o=i-t;if(0===o)continue;e=n-(c.value-t)/o*n}if(null==e)continue;const l=c.color||s.primary,u=c.labelPosition||"right";a.push((0,ng.jsxs)("g",{children:[(0,ng.jsx)("line",{x1:0,y1:e,x2:t,y2:e,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&(0,ng.jsx)("text",{x:"left"===u?4:"center"===u?t/2:t-4,y:e-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:s.tickSize,fill:l,fontFamily:s.fontFamily,children:c.label})]},"ann-"+i))}}return a.length>0?(0,ng.jsx)(ng.Fragment,{children:a}):null}(r.annotations,c,l,i,r.yExtent,o?.y),f="string"==typeof r.title?r.title:void 0,p="string"==typeof r.description?r.description:void 0,y=f?"semiotic-title":void 0,g=p?"semiotic-desc":void 0,m=[y,g].filter(Boolean).join(" ")||void 0;return tg.renderToStaticMarkup((0,ng.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,role:"img","aria-labelledby":m,style:{fontFamily:s.fontFamily},children:[f&&(0,ng.jsx)("title",{id:y,children:f}),p&&(0,ng.jsx)("desc",{id:g,children:p}),u&&(0,ng.jsx)("rect",{x:0,y:0,width:t,height:n,fill:u}),(0,ng.jsxs)("g",{transform:`translate(${a.left},${a.top})`,children:[h,d]}),f&&(0,ng.jsx)("text",{x:t/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:f})]}))}function lg(e,t,n,i,r){const o=Gh(i),s={top:20,right:20,bottom:30,left:40,...r.margin},a="radial"===r.projection,c=a?s.left+(t-s.left-s.right)/2:s.left,l=a?s.top+(n-s.top-s.bottom)/2:s.top,u=ag(r,i),d=e.map((e,t)=>ao(e,t)).filter(Boolean),h="string"==typeof r.title?r.title:void 0,f="string"==typeof r.description?r.description:void 0,p=h?"semiotic-title":void 0,y=f?"semiotic-desc":void 0,g=[p,y].filter(Boolean).join(" ")||void 0;return tg.renderToStaticMarkup((0,ng.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,role:"img","aria-labelledby":g,style:{fontFamily:o.fontFamily},children:[h&&(0,ng.jsx)("title",{id:p,children:h}),f&&(0,ng.jsx)("desc",{id:y,children:f}),u&&(0,ng.jsx)("rect",{x:0,y:0,width:t,height:n,fill:u}),(0,ng.jsx)("g",{transform:`translate(${c},${l})`,children:d}),h&&(0,ng.jsx)("text",{x:t/2,y:16,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:h})]}))}