semiotic 3.7.5 → 3.8.1

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 (575) hide show
  1. package/CLAUDE.md +63 -18
  2. package/README.md +121 -27
  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 +1741 -163
  7. package/ai/examples.md +174 -0
  8. package/ai/schema.json +2733 -536
  9. package/ai/surface-manifest.json +201 -0
  10. package/ai/system-prompt.md +20 -4
  11. package/dist/__tests__/scenarios/mcpProtocolTypes.d.ts +20 -0
  12. package/dist/components/AccessibleNavTree.d.ts +7 -1
  13. package/dist/components/CategoryColors.d.ts +1 -1
  14. package/dist/components/ChartContainer.d.ts +91 -0
  15. package/dist/components/ChartGrid.d.ts +11 -1
  16. package/dist/components/CircularBrush.d.ts +61 -0
  17. package/dist/components/ContextLayout.d.ts +5 -1
  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 +26 -1
  29. package/dist/components/ai/chartClinic.d.ts +91 -0
  30. package/dist/components/ai/chartClinicMetadata.generated.d.ts +15 -0
  31. package/dist/components/ai/chartRecipeRegistry.d.ts +14 -0
  32. package/dist/components/ai/chartRecipes.d.ts +278 -0
  33. package/dist/components/ai/dataPitfallsBridge.d.ts +102 -0
  34. package/dist/components/ai/describeChart.d.ts +7 -0
  35. package/dist/components/ai/describeRecipeChart.d.ts +16 -0
  36. package/dist/components/ai/generativeChart.d.ts +28 -3
  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/ai/useNavigationSync.d.ts +17 -2
  47. package/dist/components/chartContainerMobile.d.ts +9 -0
  48. package/dist/components/charts/custom/GeoCustomChart.d.ts +48 -0
  49. package/dist/components/charts/custom/NetworkCustomChart.d.ts +8 -2
  50. package/dist/components/charts/custom/OrdinalCustomChart.d.ts +8 -2
  51. package/dist/components/charts/custom/XYCustomChart.d.ts +11 -2
  52. package/dist/components/charts/geo/ChoroplethMap.d.ts +19 -2
  53. package/dist/components/charts/geo/DistanceCartogram.d.ts +15 -3
  54. package/dist/components/charts/geo/FlowMap.d.ts +11 -7
  55. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +15 -3
  56. package/dist/components/charts/geo/index.d.ts +2 -0
  57. package/dist/components/charts/index.d.ts +35 -1
  58. package/dist/components/charts/network/ChordDiagram.d.ts +10 -2
  59. package/dist/components/charts/network/CirclePack.d.ts +1 -1
  60. package/dist/components/charts/network/ForceDirectedGraph.d.ts +26 -5
  61. package/dist/components/charts/network/OrbitDiagram.d.ts +1 -1
  62. package/dist/components/charts/network/ProcessSankey.d.ts +1 -1
  63. package/dist/components/charts/network/SankeyDiagram.d.ts +10 -2
  64. package/dist/components/charts/network/TreeDiagram.d.ts +1 -1
  65. package/dist/components/charts/network/Treemap.d.ts +1 -1
  66. package/dist/components/charts/network/useForceLayout.d.ts +17 -0
  67. package/dist/components/charts/ordinal/BarChart.d.ts +22 -1
  68. package/dist/components/charts/ordinal/BoxPlot.d.ts +1 -1
  69. package/dist/components/charts/ordinal/DonutChart.d.ts +1 -1
  70. package/dist/components/charts/ordinal/DotPlot.d.ts +1 -1
  71. package/dist/components/charts/ordinal/FunnelChart.d.ts +1 -1
  72. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +12 -1
  73. package/dist/components/charts/ordinal/Histogram.d.ts +1 -1
  74. package/dist/components/charts/ordinal/PieChart.d.ts +1 -1
  75. package/dist/components/charts/ordinal/RidgelinePlot.d.ts +1 -1
  76. package/dist/components/charts/ordinal/StackedBarChart.d.ts +12 -1
  77. package/dist/components/charts/ordinal/SwarmPlot.d.ts +1 -1
  78. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +1 -1
  79. package/dist/components/charts/ordinal/ViolinPlot.d.ts +1 -1
  80. package/dist/components/charts/physics/ChainReactionChart.d.ts +9 -0
  81. package/dist/components/charts/physics/CollisionSwarmChart.capability.d.ts +2 -0
  82. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +54 -0
  83. package/dist/components/charts/physics/EventDropChart.capability.d.ts +2 -0
  84. package/dist/components/charts/physics/EventDropChart.d.ts +60 -0
  85. package/dist/components/charts/physics/GaltonBoardChart.capability.d.ts +2 -0
  86. package/dist/components/charts/physics/GaltonBoardChart.d.ts +74 -0
  87. package/dist/components/charts/physics/GauntletChart.capability.d.ts +2 -0
  88. package/dist/components/charts/physics/GauntletChart.d.ts +73 -0
  89. package/dist/components/charts/physics/PhysicalFlowChart.capability.d.ts +2 -0
  90. package/dist/components/charts/physics/PhysicalFlowChart.d.ts +63 -0
  91. package/dist/components/charts/physics/PhysicsCustomChart.d.ts +99 -0
  92. package/dist/components/charts/physics/PhysicsPileChart.capability.d.ts +2 -0
  93. package/dist/components/charts/physics/PhysicsPileChart.d.ts +60 -0
  94. package/dist/components/charts/physics/ProcessFlowChart.capability.d.ts +2 -0
  95. package/dist/components/charts/physics/ProcessFlowChart.d.ts +96 -0
  96. package/dist/components/charts/physics/chainReactionOverlay.d.ts +22 -0
  97. package/dist/components/charts/physics/chainReactionRuntime.d.ts +37 -0
  98. package/dist/components/charts/physics/chainReactionTypes.d.ts +97 -0
  99. package/dist/components/charts/physics/collisionSwarmPhysics.d.ts +27 -0
  100. package/dist/components/charts/physics/dependencyMachine.d.ts +188 -0
  101. package/dist/components/charts/physics/eventDropPhysics.d.ts +64 -0
  102. package/dist/components/charts/physics/galtonBoardPhysics.d.ts +28 -0
  103. package/dist/components/charts/physics/gauntletChartProps.d.ts +67 -0
  104. package/dist/components/charts/physics/gauntletChrome.d.ts +33 -0
  105. package/dist/components/charts/physics/gauntletController.d.ts +73 -0
  106. package/dist/components/charts/physics/gauntletEffects.d.ts +36 -0
  107. package/dist/components/charts/physics/gauntletPhysics.d.ts +71 -0
  108. package/dist/components/charts/physics/gauntletRuntime.d.ts +42 -0
  109. package/dist/components/charts/physics/gauntletTypes.d.ts +213 -0
  110. package/dist/components/charts/physics/physicalFlowPhysics.d.ts +57 -0
  111. package/dist/components/charts/physics/physicsChartShared.d.ts +57 -0
  112. package/dist/components/charts/physics/physicsChartUtils.d.ts +18 -0
  113. package/dist/components/charts/physics/physicsCustomLayout.d.ts +32 -0
  114. package/dist/components/charts/physics/physicsEncoding.d.ts +142 -0
  115. package/dist/components/charts/physics/physicsHocHandle.d.ts +53 -0
  116. package/dist/components/charts/physics/physicsHocUtils.d.ts +128 -0
  117. package/dist/components/charts/physics/physicsPilePhysics.d.ts +41 -0
  118. package/dist/components/charts/physics/physicsProcessPrimitives.d.ts +38 -0
  119. package/dist/components/charts/physics/processFlowPhysics.d.ts +97 -0
  120. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +9 -1
  121. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +9 -1
  122. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +9 -1
  123. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +16 -2
  124. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +9 -1
  125. package/dist/components/charts/shared/AnnotationLabel.d.ts +88 -0
  126. package/dist/components/charts/shared/annotationActivation.d.ts +35 -0
  127. package/dist/components/charts/shared/annotationLabelLayout.d.ts +5 -0
  128. package/dist/components/charts/shared/annotationRules.d.ts +2 -1
  129. package/dist/components/charts/shared/auditMobileVisualization.d.ts +91 -0
  130. package/dist/components/charts/shared/chartDefinitionPilot.d.ts +145 -0
  131. package/dist/components/charts/shared/chartFamilySets.d.ts +20 -0
  132. package/dist/components/charts/shared/chartSelectionUtils.d.ts +4 -0
  133. package/dist/components/charts/shared/chartSpecCore.d.ts +165 -0
  134. package/dist/components/charts/shared/chartSpecs.d.ts +8 -127
  135. package/dist/components/charts/shared/chartSpecsGeo.d.ts +2 -0
  136. package/dist/components/charts/shared/chartSpecsNetwork.d.ts +2 -0
  137. package/dist/components/charts/shared/chartSpecsOrdinal.d.ts +2 -0
  138. package/dist/components/charts/shared/chartSpecsPhysics.d.ts +2 -0
  139. package/dist/components/charts/shared/chartSpecsRealtime.d.ts +2 -0
  140. package/dist/components/charts/shared/chartSpecsValue.d.ts +2 -0
  141. package/dist/components/charts/shared/chartSpecsXY.d.ts +2 -0
  142. package/dist/components/charts/shared/colorContrast.d.ts +3 -0
  143. package/dist/components/charts/shared/colorUtils.d.ts +16 -1
  144. package/dist/components/charts/shared/datumTypes.d.ts +2 -0
  145. package/dist/components/charts/shared/diagnoseAnnotationChecks.d.ts +6 -0
  146. package/dist/components/charts/shared/diagnoseConfig.d.ts +9 -14
  147. package/dist/components/charts/shared/diagnoseMisleadingChecks.d.ts +9 -0
  148. package/dist/components/charts/shared/diagnosePhysicsChecks.d.ts +3 -0
  149. package/dist/components/charts/shared/diagnoseTypes.d.ts +10 -0
  150. package/dist/components/charts/shared/formatUtils.d.ts +3 -3
  151. package/dist/components/charts/shared/hatchFill.d.ts +87 -0
  152. package/dist/components/charts/shared/hooks.d.ts +34 -10
  153. package/dist/components/charts/shared/knownChartComponents.d.ts +9 -0
  154. package/dist/components/charts/shared/leastSquaresRegression.d.ts +16 -0
  155. package/dist/components/charts/shared/mergeShapeStyle.d.ts +3 -2
  156. package/dist/components/charts/shared/motionEncoding.d.ts +145 -0
  157. package/dist/components/charts/shared/responsiveRules.d.ts +56 -0
  158. package/dist/components/charts/shared/semanticInteractions.d.ts +42 -0
  159. package/dist/components/charts/shared/sparseArray.d.ts +1 -1
  160. package/dist/components/charts/shared/streamPropsHelpers.d.ts +17 -5
  161. package/dist/components/charts/shared/styleRules.d.ts +205 -0
  162. package/dist/components/charts/shared/temporalStrings.d.ts +7 -0
  163. package/dist/components/charts/shared/tooltipUtils.d.ts +22 -9
  164. package/dist/components/charts/shared/types.d.ts +58 -7
  165. package/dist/components/charts/shared/useAreaSeriesSetup.d.ts +16 -2
  166. package/dist/components/charts/shared/useChartSetup.d.ts +11 -4
  167. package/dist/components/charts/shared/useCustomChartSetup.d.ts +17 -5
  168. package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +1 -2
  169. package/dist/components/charts/shared/useLikertAggregation.d.ts +4 -4
  170. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +6 -2
  171. package/dist/components/charts/shared/useOrdinalBrush.d.ts +2 -1
  172. package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +25 -2
  173. package/dist/components/charts/shared/useStreamingLegend.d.ts +2 -2
  174. package/dist/components/charts/shared/useSyncedPushData.d.ts +49 -0
  175. package/dist/components/charts/shared/useXYLineStyle.d.ts +10 -0
  176. package/dist/components/charts/shared/useXYPointStyle.d.ts +19 -1
  177. package/dist/components/charts/shared/validateChartData.d.ts +7 -5
  178. package/dist/components/charts/shared/validationMap.d.ts +7 -9
  179. package/dist/components/charts/shared/validationMap.generated.d.ts +6 -0
  180. package/dist/components/charts/shared/withChartWrapper.d.ts +4 -3
  181. package/dist/components/charts/value/targetPresentation.d.ts +22 -0
  182. package/dist/components/charts/value/types.d.ts +5 -6
  183. package/dist/components/charts/xy/AreaChart.d.ts +9 -1
  184. package/dist/components/charts/xy/BubbleChart.d.ts +10 -1
  185. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +7 -0
  186. package/dist/components/charts/xy/DifferenceChart.d.ts +1 -52
  187. package/dist/components/charts/xy/Heatmap.d.ts +2 -2
  188. package/dist/components/charts/xy/LineChart.d.ts +12 -1
  189. package/dist/components/charts/xy/MinimapChart.d.ts +1 -1
  190. package/dist/components/charts/xy/MultiAxisLineChart.d.ts +2 -2
  191. package/dist/components/charts/xy/QuadrantChart.d.ts +8 -1
  192. package/dist/components/charts/xy/Scatterplot.d.ts +11 -1
  193. package/dist/components/charts/xy/ScatterplotMatrix.d.ts +11 -1
  194. package/dist/components/charts/xy/StackedAreaChart.d.ts +16 -4
  195. package/dist/components/charts/xy/differenceSegments.d.ts +49 -0
  196. package/dist/components/charts/xy/scatterplotMatrixInteractionTypes.d.ts +12 -0
  197. package/dist/components/controls/SentenceFilter.d.ts +97 -0
  198. package/dist/components/controls/controlAudit.d.ts +24 -0
  199. package/dist/components/controls/controlContract.d.ts +57 -0
  200. package/dist/components/data/fromFlintChart.d.ts +74 -0
  201. package/dist/components/data/fromVegaLite.d.ts +46 -9
  202. package/dist/components/data/portability/index.d.ts +6 -3
  203. package/dist/components/data/portability/result.d.ts +52 -0
  204. package/dist/components/data/portability/spec.d.ts +31 -0
  205. package/dist/components/data/portability/vegaLite.d.ts +24 -6
  206. package/dist/components/export/chartConfig.d.ts +11 -0
  207. package/dist/components/realtime/types.d.ts +11 -0
  208. package/dist/components/recipes/annotationLayout.d.ts +29 -0
  209. package/dist/components/recipes/axisFixedForce.d.ts +119 -0
  210. package/dist/components/recipes/{gofishBoba.d.ts → boba.d.ts} +2 -2
  211. package/dist/components/recipes/cyclical.d.ts +39 -0
  212. package/dist/components/recipes/edgeRouter.d.ts +103 -0
  213. package/dist/components/recipes/forceLayout.d.ts +48 -0
  214. package/dist/components/recipes/forceLayoutAsync.d.ts +17 -0
  215. package/dist/components/recipes/gofishBobaHandwritten.d.ts +3 -0
  216. package/dist/components/recipes/gofishDisplayListFixtures.generated.d.ts +37 -0
  217. package/dist/components/recipes/gofishIR.d.ts +178 -132
  218. package/dist/components/recipes/gofishIRExamples.d.ts +30 -81
  219. package/dist/components/recipes/intervalLanes.d.ts +87 -0
  220. package/dist/components/recipes/intervals.d.ts +80 -0
  221. package/dist/components/recipes/isometricLandmarks.d.ts +88 -0
  222. package/dist/components/recipes/isotypeGlyphs.d.ts +17 -0
  223. package/dist/components/recipes/mobileAnnotationStrategy.d.ts +48 -0
  224. package/dist/components/recipes/mobileChartFamilyRecipes.d.ts +59 -0
  225. package/dist/components/recipes/networkAnalysis.d.ts +102 -0
  226. package/dist/components/recipes/networkLayouts.d.ts +83 -0
  227. package/dist/components/recipes/physics.d.ts +122 -0
  228. package/dist/components/recipes/physicsReference.d.ts +102 -0
  229. package/dist/components/recipes/processAggregates.d.ts +32 -0
  230. package/dist/components/recipes/processChrome.d.ts +67 -0
  231. package/dist/components/recipes/processJourney.d.ts +54 -0
  232. package/dist/components/recipes/processPhysics.d.ts +300 -0
  233. package/dist/components/recipes/processVolumeGeometry.d.ts +28 -0
  234. package/dist/components/recipes/radialCoords.d.ts +69 -0
  235. package/dist/components/recipes/random.d.ts +2 -0
  236. package/dist/components/recipes/recipeChrome.d.ts +91 -0
  237. package/dist/components/recipes/recipeGlyph.d.ts +42 -0
  238. package/dist/components/recipes/recipeLegend.d.ts +53 -1
  239. package/dist/components/recipes/recipeUtils.d.ts +52 -0
  240. package/dist/components/recipes/runs.d.ts +59 -0
  241. package/dist/components/recipes/tokenEncoding.d.ts +157 -0
  242. package/dist/components/recipes/tokenLayer.d.ts +79 -0
  243. package/dist/components/recipes/unitize.d.ts +108 -0
  244. package/dist/components/recipes/vector.d.ts +28 -0
  245. package/dist/components/recipes/waffle.d.ts +43 -0
  246. package/dist/components/rough/createRoughRenderMode.d.ts +46 -0
  247. package/dist/components/semiotic-ai-core.d.ts +47 -0
  248. package/dist/components/semiotic-ai.d.ts +53 -9
  249. package/dist/components/semiotic-controls.d.ts +20 -0
  250. package/dist/components/semiotic-experimental.d.ts +38 -9
  251. package/dist/components/semiotic-geo.d.ts +15 -0
  252. package/dist/components/semiotic-network.d.ts +15 -0
  253. package/dist/components/semiotic-ordinal.d.ts +14 -0
  254. package/dist/components/semiotic-physics-matter.d.ts +10 -0
  255. package/dist/components/semiotic-physics-rapier.d.ts +9 -0
  256. package/dist/components/semiotic-physics.d.ts +60 -0
  257. package/dist/components/semiotic-realtime-core.d.ts +34 -0
  258. package/dist/components/semiotic-realtime-react.d.ts +10 -0
  259. package/dist/components/semiotic-realtime.d.ts +4 -30
  260. package/dist/components/semiotic-recipes-core.d.ts +92 -0
  261. package/dist/components/semiotic-recipes-react.d.ts +7 -0
  262. package/dist/components/semiotic-recipes.d.ts +4 -43
  263. package/dist/components/semiotic-rough.d.ts +4 -0
  264. package/dist/components/semiotic-server-edge.d.ts +8 -0
  265. package/dist/components/semiotic-server-node.d.ts +5 -0
  266. package/dist/components/semiotic-server.d.ts +2 -2
  267. package/dist/components/semiotic-themes-core.d.ts +53 -0
  268. package/dist/components/semiotic-themes-react.d.ts +4 -0
  269. package/dist/components/semiotic-themes.d.ts +6 -76
  270. package/dist/components/semiotic-utils-core.d.ts +50 -0
  271. package/dist/components/semiotic-utils-react.d.ts +5 -0
  272. package/dist/components/semiotic-utils.d.ts +3 -39
  273. package/dist/components/semiotic-xy.d.ts +12 -0
  274. package/dist/components/semiotic.d.ts +44 -8
  275. package/dist/components/server/animatedGif.d.ts +36 -0
  276. package/dist/components/server/optionalImageTypes.d.ts +37 -0
  277. package/dist/components/server/renderEvidence.d.ts +1 -1
  278. package/dist/components/server/renderToStaticSVG.d.ts +3 -35
  279. package/dist/components/server/serverChartConfigShared.d.ts +21 -0
  280. package/dist/components/server/serverChartConfigs.d.ts +22 -12
  281. package/dist/components/server/serverChartConfigsCustom.d.ts +5 -0
  282. package/dist/components/server/serverChartConfigsGeo.d.ts +9 -0
  283. package/dist/components/server/serverChartConfigsNetwork.d.ts +8 -0
  284. package/dist/components/server/serverChartConfigsOrdinal.d.ts +16 -0
  285. package/dist/components/server/serverChartConfigsPhysics.d.ts +9 -0
  286. package/dist/components/server/serverChartConfigsXY.d.ts +11 -0
  287. package/dist/components/server/staticAnnotations.d.ts +6 -3
  288. package/dist/components/server/staticGeo.d.ts +4 -0
  289. package/dist/components/server/staticLegend.d.ts +2 -2
  290. package/dist/components/server/staticNetwork.d.ts +8 -0
  291. package/dist/components/server/staticOrdinal.d.ts +11 -0
  292. package/dist/components/server/staticPhysics.d.ts +3 -0
  293. package/dist/components/server/staticSVGChrome.d.ts +110 -0
  294. package/dist/components/server/staticXY.d.ts +4 -0
  295. package/dist/components/store/ObservationStore.d.ts +23 -2
  296. package/dist/components/store/themeSerialization.d.ts +32 -0
  297. package/dist/components/store/useChartInterrogation.d.ts +9 -0
  298. package/dist/components/stream/AccessibleDataTable.d.ts +7 -23
  299. package/dist/components/stream/AriaLiveTooltip.d.ts +9 -0
  300. package/dist/components/stream/CanvasHitTester.d.ts +4 -4
  301. package/dist/components/stream/DataSourceAdapter.d.ts +1 -1
  302. package/dist/components/stream/FocusRing.d.ts +4 -2
  303. package/dist/components/stream/FrameRuntime.d.ts +57 -0
  304. package/dist/components/stream/GeoCanvasHitTester.d.ts +1 -1
  305. package/dist/components/stream/GeoParticlePool.d.ts +1 -1
  306. package/dist/components/stream/GeoPipelineStore.d.ts +62 -3
  307. package/dist/components/stream/GeoSVGOverlay.d.ts +64 -0
  308. package/dist/components/stream/NetworkCanvasHitTester.d.ts +2 -1
  309. package/dist/components/stream/NetworkPipelineStore.d.ts +44 -36
  310. package/dist/components/stream/NetworkSSRFrame.d.ts +17 -0
  311. package/dist/components/stream/NetworkSVGOverlay.d.ts +10 -1
  312. package/dist/components/stream/OrdinalCanvasHitTester.d.ts +2 -2
  313. package/dist/components/stream/OrdinalPipelineStore.d.ts +55 -11
  314. package/dist/components/stream/OrdinalSVGOverlay.d.ts +9 -1
  315. package/dist/components/stream/OrdinalStyleResolver.d.ts +12 -0
  316. package/dist/components/stream/ParticlePool.d.ts +1 -1
  317. package/dist/components/stream/PipelineStore.d.ts +81 -174
  318. package/dist/components/stream/SVGOverlay.d.ts +6 -0
  319. package/dist/components/stream/SceneGraph.d.ts +12 -4
  320. package/dist/components/stream/StreamGeoFrame.d.ts +1 -1
  321. package/dist/components/stream/StreamNetworkFrame.d.ts +1 -1
  322. package/dist/components/stream/StreamOrdinalFrame.d.ts +1 -1
  323. package/dist/components/stream/StreamXYFrame.d.ts +2 -18
  324. package/dist/components/stream/accessibleDataRows.d.ts +33 -0
  325. package/dist/components/stream/accessorUtils.d.ts +25 -12
  326. package/dist/components/stream/annotationAccessorResolver.d.ts +2 -2
  327. package/dist/components/stream/brushAccessibility.d.ts +25 -0
  328. package/dist/components/stream/canvasBackground.d.ts +24 -0
  329. package/dist/components/stream/canvasSetup.d.ts +4 -1
  330. package/dist/components/stream/customLayoutFailure.d.ts +33 -0
  331. package/dist/components/stream/customLayoutPalette.d.ts +19 -9
  332. package/dist/components/stream/frameGraphics.d.ts +4 -0
  333. package/dist/components/stream/frameKeyboardNavigation.d.ts +45 -0
  334. package/dist/components/stream/frameThemeColors.d.ts +24 -0
  335. package/dist/components/stream/geoAnnotationAnchors.d.ts +14 -0
  336. package/dist/components/stream/geoCartogram.d.ts +17 -0
  337. package/dist/components/stream/geoCustomLayout.d.ts +59 -0
  338. package/dist/components/stream/geoDefaultTooltip.d.ts +11 -0
  339. package/dist/components/stream/geoFrameHelpers.d.ts +34 -0
  340. package/dist/components/stream/geoPipelineHelpers.d.ts +46 -0
  341. package/dist/components/stream/geoPipelineUpdateResults.d.ts +34 -0
  342. package/dist/components/stream/geoSceneBuilder.d.ts +16 -0
  343. package/dist/components/stream/geoTypes.d.ts +97 -15
  344. package/dist/components/stream/glyphDef.d.ts +98 -0
  345. package/dist/components/stream/hitTarget.d.ts +170 -0
  346. package/dist/components/stream/hitTestUtils.d.ts +2 -2
  347. package/dist/components/stream/hoverUtils.d.ts +7 -2
  348. package/dist/components/stream/keyboardNav.d.ts +4 -1
  349. package/dist/components/stream/layouts/forceLayoutPlugin.d.ts +9 -1
  350. package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +58 -0
  351. package/dist/components/stream/layouts/hierarchyUtils.d.ts +2 -2
  352. package/dist/components/stream/networkBezier.d.ts +10 -0
  353. package/dist/components/stream/networkColorAccessors.d.ts +49 -0
  354. package/dist/components/stream/networkCustomLayoutRunner.d.ts +23 -0
  355. package/dist/components/stream/networkCustomRestyle.d.ts +15 -0
  356. package/dist/components/stream/networkDefaultTooltip.d.ts +10 -0
  357. package/dist/components/stream/networkFrameAnimation.d.ts +7 -0
  358. package/dist/components/stream/networkFrameHandleTypes.d.ts +39 -0
  359. package/dist/components/stream/networkFrameInteraction.d.ts +37 -0
  360. package/dist/components/stream/networkFrameObservations.d.ts +15 -0
  361. package/dist/components/stream/networkFramePaint.d.ts +52 -0
  362. package/dist/components/stream/networkInteractionTypes.d.ts +26 -0
  363. package/dist/components/stream/networkPipelineConfig.d.ts +22 -0
  364. package/dist/components/stream/networkPipelineHelpers.d.ts +12 -0
  365. package/dist/components/stream/networkPipelineUpdateResults.d.ts +38 -0
  366. package/dist/components/stream/networkRealtimeEncoding.d.ts +41 -0
  367. package/dist/components/stream/networkTypes.d.ts +103 -51
  368. package/dist/components/stream/ordinalCanvasRenderers.d.ts +7 -0
  369. package/dist/components/stream/ordinalDataIndex.d.ts +5 -0
  370. package/dist/components/stream/ordinalDefaultTooltip.d.ts +10 -0
  371. package/dist/components/stream/ordinalDomain.d.ts +38 -0
  372. package/dist/components/stream/ordinalPipelineUpdateResults.d.ts +31 -0
  373. package/dist/components/stream/ordinalPulse.d.ts +10 -0
  374. package/dist/components/stream/ordinalPulseResources.d.ts +3 -0
  375. package/dist/components/stream/ordinalSceneBuilders/sceneBuilderMap.d.ts +5 -0
  376. package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -2
  377. package/dist/components/stream/ordinalSpatialIndex.d.ts +9 -0
  378. package/dist/components/stream/ordinalTypes.d.ts +68 -9
  379. package/dist/components/stream/paintNeeds.d.ts +31 -0
  380. package/dist/components/stream/physics/CapacityQueueController.d.ts +5 -0
  381. package/dist/components/stream/physics/CapacityQueueTypes.d.ts +134 -0
  382. package/dist/components/stream/physics/MatterPhysicsEngineAdapter.d.ts +42 -0
  383. package/dist/components/stream/physics/PhysicsAccessibility.d.ts +48 -0
  384. package/dist/components/stream/physics/PhysicsAnnotations.d.ts +58 -0
  385. package/dist/components/stream/physics/PhysicsBodyBudget.d.ts +26 -0
  386. package/dist/components/stream/physics/PhysicsBodySpatialIndex.d.ts +10 -0
  387. package/dist/components/stream/physics/PhysicsCanvasTheme.d.ts +26 -0
  388. package/dist/components/stream/physics/PhysicsControllers.d.ts +75 -0
  389. package/dist/components/stream/physics/PhysicsEngineAdapter.d.ts +59 -0
  390. package/dist/components/stream/physics/PhysicsEngineConformance.d.ts +23 -0
  391. package/dist/components/stream/physics/PhysicsEvidence.d.ts +25 -0
  392. package/dist/components/stream/physics/PhysicsKernel.d.ts +207 -0
  393. package/dist/components/stream/physics/PhysicsOptionalEngineAdapters.d.ts +12 -0
  394. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +86 -0
  395. package/dist/components/stream/physics/PhysicsPipelineTypes.d.ts +181 -0
  396. package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +78 -0
  397. package/dist/components/stream/physics/PhysicsSediment.d.ts +69 -0
  398. package/dist/components/stream/physics/PhysicsSettledSVG.d.ts +18 -0
  399. package/dist/components/stream/physics/PhysicsSettledScene.d.ts +21 -0
  400. package/dist/components/stream/physics/PhysicsWorkerClient.d.ts +24 -0
  401. package/dist/components/stream/physics/PhysicsWorkerProtocol.d.ts +101 -0
  402. package/dist/components/stream/physics/PhysicsWorkerRuntime.d.ts +5 -0
  403. package/dist/components/stream/physics/RapierPhysicsEngineAdapter.d.ts +18 -0
  404. package/dist/components/stream/physics/ServiceOperationsControllers.d.ts +27 -0
  405. package/dist/components/stream/physics/ServiceOperationsTypes.d.ts +89 -0
  406. package/dist/components/stream/physics/StreamPhysicsFrame.d.ts +6 -0
  407. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +317 -0
  408. package/dist/components/stream/physics/physicsBodyCanvas.d.ts +27 -0
  409. package/dist/components/stream/physics/physicsFrameObservations.d.ts +19 -0
  410. package/dist/components/stream/physics/physicsFrameSetup.d.ts +4 -0
  411. package/dist/components/stream/physics/physicsPipelineControls.d.ts +4 -0
  412. package/dist/components/stream/physics/physicsPipelineHelpers.d.ts +41 -0
  413. package/dist/components/stream/physics/physicsPipelineObservations.d.ts +14 -0
  414. package/dist/components/stream/physics/physicsPipelineUpdateResults.d.ts +27 -0
  415. package/dist/components/stream/physics/physicsRegionRuntime.d.ts +54 -0
  416. package/dist/components/stream/physics/physicsSemanticUI.d.ts +20 -0
  417. package/dist/components/stream/physics/usePhysicsFrameLifecyclePolicy.d.ts +18 -0
  418. package/dist/components/stream/pipelineBufferUtils.d.ts +26 -0
  419. package/dist/components/stream/pipelineConfig.d.ts +179 -0
  420. package/dist/components/stream/pipelineDecay.d.ts +21 -3
  421. package/dist/components/stream/pipelineDomainResolution.d.ts +62 -0
  422. package/dist/components/stream/pipelineIdentityOps.d.ts +26 -0
  423. package/dist/components/stream/pipelinePulse.d.ts +17 -3
  424. package/dist/components/stream/pipelineRibbons.d.ts +41 -0
  425. package/dist/components/stream/pipelineSpatialIndex.d.ts +12 -0
  426. package/dist/components/stream/pipelineStoreUpdateResults.d.ts +33 -0
  427. package/dist/components/stream/pipelineStyleResolvers.d.ts +46 -0
  428. package/dist/components/stream/pipelineTransitions.d.ts +3 -1
  429. package/dist/components/stream/pipelineUpdateContract.d.ts +69 -0
  430. package/dist/components/stream/pipelineUpdateStore.d.ts +21 -0
  431. package/dist/components/stream/pulseFrameRefresh.d.ts +22 -0
  432. package/dist/components/stream/renderBackend.d.ts +27 -0
  433. package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +15 -1
  434. package/dist/components/stream/renderers/geoCanvasRenderer.d.ts +3 -2
  435. package/dist/components/stream/renderers/glyphCanvasRenderer.d.ts +6 -0
  436. package/dist/components/stream/renderers/networkParticleRenderer.d.ts +1 -1
  437. package/dist/components/stream/renderers/resolveCSSColor.d.ts +6 -0
  438. package/dist/components/stream/sceneRenderBackendTypes.d.ts +28 -0
  439. package/dist/components/stream/sceneRevisionDiagnostics.d.ts +45 -0
  440. package/dist/components/stream/streamSemanticTypes.d.ts +16 -0
  441. package/dist/components/stream/streamStoreSync.d.ts +37 -0
  442. package/dist/components/stream/streamThemeTypes.d.ts +14 -0
  443. package/dist/components/stream/svgOverlayUtils.d.ts +10 -0
  444. package/dist/components/stream/test-utils/frameScheduler.d.ts +12 -0
  445. package/dist/components/stream/test-utils/revisionConsumption.d.ts +13 -0
  446. package/dist/components/stream/titleLayout.d.ts +31 -0
  447. package/dist/components/stream/types.d.ts +165 -72
  448. package/dist/components/stream/useCanvasFrameHost.d.ts +71 -0
  449. package/dist/components/stream/useFrame.d.ts +44 -2
  450. package/dist/components/stream/useHydration.d.ts +6 -0
  451. package/dist/components/stream/useLegendCategoryEmission.d.ts +5 -0
  452. package/dist/components/stream/useSemanticFrameInteractions.d.ts +22 -0
  453. package/dist/components/stream/useUpdateResultSnapshot.d.ts +7 -0
  454. package/dist/components/stream/workerModuleUrl.d.ts +10 -0
  455. package/dist/components/stream/xyAnnotationAnchors.d.ts +13 -0
  456. package/dist/components/stream/xyCanvasRenderers.d.ts +7 -0
  457. package/dist/components/stream/xyCrosshair.d.ts +11 -0
  458. package/dist/components/stream/xyDateTicks.d.ts +9 -0
  459. package/dist/components/stream/xyDefaultTooltip.d.ts +10 -0
  460. package/dist/components/stream/xyFrameAxisTypes.d.ts +50 -0
  461. package/dist/components/stream/xySceneBuilders/types.d.ts +10 -9
  462. package/dist/controls.min.js +2 -0
  463. package/dist/controls.module.min.js +2 -0
  464. package/dist/forceLayoutWorker.js +1 -0
  465. package/dist/geo.min.js +1 -1
  466. package/dist/geo.module.min.js +1 -1
  467. package/dist/network.min.js +1 -1
  468. package/dist/network.module.min.js +1 -1
  469. package/dist/ordinal.min.js +1 -1
  470. package/dist/ordinal.module.min.js +1 -1
  471. package/dist/physics-matter.min.js +1 -0
  472. package/dist/physics-matter.module.min.js +1 -0
  473. package/dist/physics-rapier.min.js +1 -0
  474. package/dist/physics-rapier.module.min.js +1 -0
  475. package/dist/physics.min.js +2 -0
  476. package/dist/physics.module.min.js +2 -0
  477. package/dist/physicsWorker.js +1 -0
  478. package/dist/realtime.min.js +1 -1
  479. package/dist/realtime.module.min.js +1 -1
  480. package/dist/rough.min.js +1 -0
  481. package/dist/rough.module.min.js +1 -0
  482. package/dist/semiotic-ai-chunk-OG7BQUUW.module.min.js +2 -0
  483. package/dist/semiotic-ai-core.d.ts +47 -0
  484. package/dist/semiotic-ai-core.min.js +1 -0
  485. package/dist/semiotic-ai-core.module.min.js +1 -0
  486. package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +2 -0
  487. package/dist/semiotic-ai.d.ts +53 -9
  488. package/dist/semiotic-ai.min.js +1 -1
  489. package/dist/semiotic-ai.module.min.js +1 -1
  490. package/dist/semiotic-chunk-3FSVZ46U.module.min.js +2 -0
  491. package/dist/semiotic-controls.d.ts +20 -0
  492. package/dist/semiotic-data.min.js +1 -1
  493. package/dist/semiotic-data.module.min.js +1 -1
  494. package/dist/semiotic-experimental.d.ts +38 -9
  495. package/dist/semiotic-experimental.min.js +1 -1
  496. package/dist/semiotic-experimental.module.min.js +1 -1
  497. package/dist/semiotic-geo.d.ts +15 -0
  498. package/dist/semiotic-network.d.ts +15 -0
  499. package/dist/semiotic-ordinal.d.ts +14 -0
  500. package/dist/semiotic-physics-matter.d.ts +10 -0
  501. package/dist/semiotic-physics-rapier.d.ts +9 -0
  502. package/dist/semiotic-physics.d.ts +60 -0
  503. package/dist/semiotic-realtime-core.d.ts +34 -0
  504. package/dist/semiotic-realtime-core.min.js +1 -0
  505. package/dist/semiotic-realtime-core.module.min.js +1 -0
  506. package/dist/semiotic-realtime-react.d.ts +10 -0
  507. package/dist/semiotic-realtime-react.min.js +2 -0
  508. package/dist/semiotic-realtime-react.module.min.js +2 -0
  509. package/dist/semiotic-realtime.d.ts +4 -30
  510. package/dist/semiotic-recipes-core.d.ts +92 -0
  511. package/dist/semiotic-recipes-core.min.js +1 -0
  512. package/dist/semiotic-recipes-core.module.min.js +1 -0
  513. package/dist/semiotic-recipes-react.d.ts +7 -0
  514. package/dist/semiotic-recipes-react.min.js +2 -0
  515. package/dist/semiotic-recipes-react.module.min.js +2 -0
  516. package/dist/semiotic-recipes.d.ts +4 -43
  517. package/dist/semiotic-recipes.min.js +1 -1
  518. package/dist/semiotic-recipes.module.min.js +1 -1
  519. package/dist/semiotic-rough.d.ts +4 -0
  520. package/dist/semiotic-server-edge.d.ts +8 -0
  521. package/dist/semiotic-server-edge.min.js +1 -0
  522. package/dist/semiotic-server-edge.module.min.js +1 -0
  523. package/dist/semiotic-server-node.d.ts +5 -0
  524. package/dist/semiotic-server-node.min.js +1 -0
  525. package/dist/semiotic-server-node.module.min.js +1 -0
  526. package/dist/semiotic-server.d.ts +2 -2
  527. package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +2 -0
  528. package/dist/semiotic-themes-core.d.ts +53 -0
  529. package/dist/semiotic-themes-core.min.js +1 -0
  530. package/dist/semiotic-themes-core.module.min.js +1 -0
  531. package/dist/semiotic-themes-react.d.ts +4 -0
  532. package/dist/semiotic-themes-react.min.js +2 -0
  533. package/dist/semiotic-themes-react.module.min.js +2 -0
  534. package/dist/semiotic-themes.d.ts +6 -76
  535. package/dist/semiotic-themes.min.js +1 -2
  536. package/dist/semiotic-themes.module.min.js +1 -2
  537. package/dist/semiotic-utils-core.d.ts +50 -0
  538. package/dist/semiotic-utils-core.min.js +1 -0
  539. package/dist/semiotic-utils-core.module.min.js +1 -0
  540. package/dist/semiotic-utils-react.d.ts +5 -0
  541. package/dist/semiotic-utils-react.min.js +2 -0
  542. package/dist/semiotic-utils-react.module.min.js +2 -0
  543. package/dist/semiotic-utils.d.ts +3 -39
  544. package/dist/semiotic-utils.min.js +1 -2
  545. package/dist/semiotic-utils.module.min.js +1 -2
  546. package/dist/semiotic-value.min.js +1 -1
  547. package/dist/semiotic-value.module.min.js +1 -1
  548. package/dist/semiotic-xy.d.ts +12 -0
  549. package/dist/semiotic.d.ts +44 -8
  550. package/dist/semiotic.min.js +1 -1
  551. package/dist/semiotic.module.min.js +1 -1
  552. package/dist/server.min.js +1 -1
  553. package/dist/server.module.min.js +1 -1
  554. package/dist/test-utils/capturedFrameProps.d.ts +67 -0
  555. package/dist/test-utils/frameMock.d.ts +12 -9
  556. package/dist/xy-chunk-IWD6IB6V.module.min.js +2 -0
  557. package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +2 -0
  558. package/dist/xy.min.js +1 -1
  559. package/dist/xy.module.min.js +1 -1
  560. package/package.json +259 -88
  561. package/spec/README.md +152 -0
  562. package/spec/bindings/README.md +35 -0
  563. package/spec/bindings/vega-lite.mjs +112 -0
  564. package/spec/v0.1/annotation-provenance.schema.json +127 -0
  565. package/spec/v0.1/audience-profile.schema.json +67 -0
  566. package/spec/v0.1/chart-capability.schema.json +186 -0
  567. package/dist/components/recipes/gofish.d.ts +0 -207
  568. package/dist/components/recipes/gofishInterpreter.d.ts +0 -52
  569. package/dist/components/recipes/gofishLambdas.d.ts +0 -145
  570. package/dist/semiotic-ai-semiotic-ai-u954ylUn.js +0 -2
  571. package/dist/semiotic-ai-statisticalOverlays-CU7jW05Q.js +0 -1
  572. package/dist/semiotic-semiotic-BmrYbi99.js +0 -2
  573. package/dist/semiotic-statisticalOverlays-IjZw8Lsu.js +0 -1
  574. package/dist/xy-semiotic-xy-Dufu3D0-.js +0 -2
  575. package/dist/xy-statisticalOverlays-3Ni9bRph.js +0 -1
@@ -1 +1 @@
1
- import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import*as o from"react";import{useRef as i,useMemo as r,useContext as s,useCallback as a,useSyncExternalStore as l,createContext as c,useEffect as u,useState as d,useLayoutEffect as h,forwardRef as f,useId as g,useImperativeHandle as y}from"react";import*as p from"react-dom/server";import{scaleOrdinal as m,scaleLinear as v,scaleLog as b,scaleTime as x,scaleBand as k}from"d3-scale";import{quadtree as w}from"d3-quadtree";import{symbol as A,symbolCircle as S,symbolWye as M,symbolCross as _,symbolStar as P,symbolDiamond as O,symbolTriangle as T,symbolSquare as $,arc as j,pie as L,curveNatural as C,curveBasis as z,curveStepAfter as D,curveStepBefore as E,curveStep as R,curveCatmullRom as N,curveCardinal as F,curveMonotoneY as W,curveMonotoneX as B,line as I,area as Y,curveLinear as G}from"d3-shape";import{min as H,groups as X,max as q,sum as V,mean as U,group as Z,quantile as Q,bin as K}from"d3-array";import{interpolateNumber as J}from"d3-interpolate";import{forceLink as tt,forceSimulation as et,forceManyBody as nt,forceCenter as ot,forceX as it,forceY as rt}from"d3-force";import{ribbon as st,chord as at}from"d3-chord";import{hierarchy as lt,partition as ct,pack as ut,treemap as dt,treemapBinary as ht,cluster as ft,tree as gt,packEnclose as yt}from"d3-hierarchy";import{geoPath as pt,geoGraticule as mt,geoDistance as vt,geoInterpolate as bt,geoEqualEarth as xt,geoEquirectangular as kt,geoNaturalEarth1 as wt,geoOrthographic as At,geoAlbersUsa as St,geoMercator as Mt}from"d3-geo";import{select as _t}from"d3-selection";import{brushX as Pt,brushY as Ot,brush as Tt}from"d3-brush";import $t from"regression";function jt(t,e,n,o){return new(n||(n=Promise))(function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){t.done?i(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}l((o=o.apply(t,e||[])).next())})}function Lt(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function Ct(t){return"object"==typeof t&&null!==t&&"gradient"in t}"function"==typeof SuppressedError&&SuppressedError;class zt{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+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 t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}update(t,e){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const r=(o+i)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(t),this.buffer[r]=e(s)}}return n}remove(t){const e=[],n=[];if(this.forEach(o=>{t(o)?n.push(o):e.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);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}}class Dt{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}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 Et(t,e,n,o,i){const r=new Map;for(const s of t){const t=e(s),a=n(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=Math.floor(t/o)*o;let c=r.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},r.set(l,c)),c.total+=a,i){const t=i(s);c.categories.set(t,(c.categories.get(t)||0)+a)}}return r}function Rt(t,e,n,o,i,r){const s=[];for(const i of t){const t=n(i),r=o(i);Number.isFinite(t)&&Number.isFinite(r)&&s.push({px:e.x(t),py:e.y(r),rawY:r,d:i})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],l[t]=e.rawY,c[t]=e.d}return{type:"line",path:a,rawValues:l,style:i,datum:c,group:r}}function Nt(t,e,n,o,i,r,s,a){const l=[];for(const r of t){const t=n(r),s=o(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const c=e.x(t),u=a?a(r):i;l.push({px:c,topY:e.y(s),botY:e.y(u)})}l.sort((t,e)=>t.px-e.px);const c=Array(l.length),u=Array(l.length);for(let t=0;l.length>t;t++){const e=l[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:r,datum:t,group:s}}function Ft(t,e,n,o){var i,r,s;const a=new Map;if("silhouette"===o)for(const o of t){let t=0;for(const i of e)t+=n(i,o)||0;a.set(o,-t/2)}else if("wiggle"===o){t.length>0&&a.set(t[0],0);for(let o=1;t.length>o;o++){const r=t[o-1],s=t[o];let l=0,c=0,u=0;for(const t of e){const e=n(t,s)||0;l+=(2*u+e)*(e-(n(t,r)||0)),c+=e,u+=e}const d=null!==(i=a.get(r))&&void 0!==i?i:0;a.set(s,d-(c>0?l/(2*c):0))}if(t.length>0){let o=0;for(const i of t){let t=0;for(const o of e)t+=n(o,i)||0;o+=(null!==(r=a.get(i))&&void 0!==r?r:0)+t/2}const i=o/t.length;for(const e of t)a.set(e,(null!==(s=a.get(e))&&void 0!==s?s:0)-i)}}else for(const e of t)a.set(e,0);return a}function Wt(t,e,n,o,i,r,s){const a=n(t),l=o(t);if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c={type:"point",x:e.x(a),y:e.y(l),r:i,style:r,datum:t};return void 0!==s&&(c.pointId=s),c}function Bt(t,e,n,o,i,r,s,a){const l=n(t),c=o(t);if(!Number.isFinite(l)||!Number.isFinite(c))return null;const u={type:"symbol",x:e.x(l),y:e.y(c),size:i,symbolType:r,style:s,datum:t};return void 0!==a&&(u.pointId=a),u}function It(t,e,n,o,i,r,s){return{type:"rect",x:t,y:e,w:n,h:o,style:i,datum:r,group:s}}function Yt(t,e,n,o,i,r,s){const a={type:"heatcell",x:t,y:e,w:n,h:o,fill:i,datum:r};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Gt(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function Ht(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function Xt(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function qt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}function Vt(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function Ut(t,e,n){const o=t=>t.toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(n)}`}function Zt(t){const e=t.map(Vt),n=e.length-1;return t=>{if(0>=t){const[t,n,o]=e[0];return Ut(t,n,o)}if(t>=1){const[t,o,i]=e[n];return Ut(t,o,i)}const o=t*n,i=Math.floor(o),r=o-i,[s,a,l]=e[i],[c,u,d]=e[i+1];return Ut(Math.round(s+(c-s)*r),Math.round(a+(u-a)*r),Math.round(l+(d-l)*r))}}const Qt=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Kt=Zt(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Jt=Zt(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),te=Zt(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),ee=Zt(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),ne=Zt(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),oe=Zt(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),ie=Zt(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),re=Zt(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),se=Zt(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),ae=Zt(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),le=Zt(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),ce=Zt(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ue={blues:Kt,reds:Jt,greens:te,viridis:ie,oranges:ee,purples:ne,greys:oe,plasma:re,inferno:se,magma:ae,cividis:le,turbo:ce};Zt(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Zt(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Zt(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),Zt(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Zt(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Zt(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Zt(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const de=Object.assign({category10:Qt,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"]},ue),he=Qt,fe=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],ge=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 ye(t,e,n){if("function"==typeof e){const o=e(t);return n&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||ge.has(e)}(o)?n(o):o}const o=(null==t?void 0:t[e])+"";return n?n(o):he[Math.abs(function(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n),e&=e;return Math.abs(e)}(o))%he.length]}function pe(t,e,n="category10"){const o=Array.from(new Set(t.map(t=>null==t?void 0:t[e]).filter(t=>null!=t).map(t=>t+""))),i=o.every(t=>!isNaN(Number(t)));if(Array.isArray(n))return m().domain(o).range(n).unknown("#999");const r=de[n]||de.category10;if(i&&"function"==typeof r){let t=-1/0;for(const e of o){const n=Number(e);n>t&&(t=n)}return e=>r(Number(e)/t)}{const t=Array.isArray(r)?r:he;return m().domain(o).range(t).unknown("#999")}}function me(t,e,n){var o,i,r;if(1>=n)return 1;const s=null!==(o=t.minOpacity)&&void 0!==o?o:.1,a=n-1-e;switch(t.type){case"linear":return s+(1-a/(n-1))*(1-s);case"exponential":{const e=null!==(i=t.halfLife)&&void 0!==i?i:n/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(r=t.stepThreshold)&&void 0!==r?r:.5*n)>a?1:s;default:return 1}}function ve(t,e,n){var o;const i=null!==(o=t.duration)&&void 0!==o?o:500,r=n-e;return i>r?1-r/i:0}function be(t,e){var n;if(!e||0===e.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=t.duration)&&void 0!==n?n:500,r=e.peek();return null!=r&&i>o-r}function xe(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function ke(t,e){return Math.min((t-e.startTime)/e.duration,1)}function we(t,e,n){return t+(e-t)*n}function Ae(){return"undefined"!=typeof performance?performance.now():Date.now()}function Se(t,e,n){var o,i,r,s;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(s=null!==(i=null===(o=e.datum)||void 0===o?void 0:o.binStart)&&void 0!==i?i:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function Me(t,e,n,o){return"function"==typeof e.style?e.style(o||{},n):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(n,o)}function _e(t,e,n,o){if(!t.scales)return null;const i=[],r=[];for(const n of e){const e=t.getX(n);if(!Number.isFinite(e))continue;const s=o.getTop(n),a=o.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const l=t.scales.x(e),c=t.scales.y(s),u=t.scales.y(a);Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(u)&&(i.push([l,c]),r.push([l,u]))}return 2>i.length?null:{type:"area",topPath:i,bottomPath:r,style:Me(t,o,n,e[0]),datum:e,group:n,interactive:o.interactive}}function Pe(t){const e=[],n=[];if(!t)return{perSeries:e,aggregate:n};for(const o of t)o.perSeries?e.push(o):n.push(o);return{perSeries:e,aggregate:n}}function Oe(t,e,n){const o=[];for(const i of n){const n=_e(t,e,"__ribbon_aggregate",i);n&&o.push(n)}return o}function Te(t,e,n,o){const i=[];for(const r of o){const o=_e(t,e,n,r);o&&i.push(o)}return i}function $e(t,e){if(!t)return{};if(!e||0===e.length)return t;const n=[];for(const o of e){if("band"!==o.kind)continue;const e=o.getTop(t),i=o.getBottom(t);Number.isFinite(i)&&Number.isFinite(e)&&n.push({y0:i,y1:e})}return 0===n.length?t:Object.assign(Object.assign({},t),{band:n[0],bands:n})}function je(t,e,n,o){var i;if(!t.config.pointStyle)return;const r=null!=o?o:t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const s of o.data){let o=t.config.pointStyle(s);!o.fill&&e&&(o=Object.assign(Object.assign({},o),{fill:e}));const a=null!==(i=o.r)&&void 0!==i?i:3,l=t.getPointId?t.getPointId(s)+"":void 0,c=Wt(s,t.scales,t.getX,r,a,o,l);c&&n.push(c)}}}const Le={topOpacity:.8,bottomOpacity:.05};function Ce(t){var e,n;if(t)return!0===t?Le:"colorStops"in t?t:{topOpacity:null!==(e=t.topOpacity)&&void 0!==e?e:Le.topOpacity,bottomOpacity:null!==(n=t.bottomOpacity)&&void 0!==n?n:Le.bottomOpacity}}const ze={circle:S,square:$,triangle:T,diamond:O,star:P,cross:_,wye:M},De=["circle","triangle","diamond","star","square","chevron","cross","wye"];function Ee(t,e,n){var o,i;if(n)return n;const r=null!=t?t:"circle";if("chevron"===r)return function(t){const e=1.5*Re(t),n=.92*e;return`M0,${-e}L${n},${(.78*e).toFixed(3)}L0,${(.28*e).toFixed(3)}L${-n},${(.78*e).toFixed(3)}Z`}(e);const s=null!==(o=ze[r])&&void 0!==o?o:S;return null!==(i=A(s,Math.max(1,e))())&&void 0!==i?i:""}function Re(t){return Math.sqrt(Math.max(1,t)/Math.PI)}const Ne=new Map;function Fe(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var o,i,r;const s=Math.max(1,Math.floor(null!==(o=t.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(i=t.config.heatmapYBins)&&void 0!==i?i:20)),l=null!==(r=t.config.heatmapAggregation)&&void 0!==r?r:"count",c=Ht(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.scales.y.domain(),g=(d-u||1)/s,y=(f-h||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),v=new Float64Array(p);for(let n=0;e.length>n;n++){const o=e[n],i=t.getX(o),r=t.getY(o);if(!isFinite(i)||!isFinite(r))continue;const l=Math.min(Math.floor((i-u)/g),s-1),d=Math.min(Math.floor((r-h)/y),a-1);if(0>l||0>d)continue;const f=d*s+l;m[f]++;const p=c(o);v[f]+=isFinite(p)?p:0}let b=1/0,x=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(l){case"sum":e=v[t];break;case"mean":e=v[t]/m[t];break;default:e=m[t]}b>e&&(b=e),e>x&&(x=e)}if(!isFinite(b))return[];const k=x-b||1,w=n.width/s,A=n.height/a,S=t.config.showValues,M=t.config.heatmapValueFormat,_=[];for(let t=0;a>t;t++){const e=t*s;for(let n=0;s>n;n++){const o=e+n;if(0===m[o])continue;let i;switch(l){case"sum":i=v[o];break;case"mean":i=v[o]/m[o];break;default:i=m[o]}const r=(i-b)/k;_.push(Yt(n*w,(a-1-t)*A,w,A,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:n,yi:t,value:i,count:m[o],sum:v[o],xCenter:u+(n+.5)*g,yCenter:h+(t+.5)*y,agg:l},S?{value:i,showValues:!0,valueFormat:M}:void 0))}}return _}(t,e,n);if(0===e.length)return[];const o=Ht(t.config.valueAccessor,"value"),i=Xt(t.config.xAccessor,"x"),r=Xt(t.config.yAccessor,"y"),s=new Map,a=new Map,l=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],o=i(n),u=r(n);l[t]=o,c[t]=u,s.has(o)||s.set(o,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()),g=h.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){h.sort((t,e)=>t-e),s.clear();for(let t=0;h.length>t;t++)s.set(h[t],t)}if(y){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const p=new Float64Array(e.length),m=new Float64Array(e.length),v=Array(e.length),b=new Map;let x=0;for(let t=0;e.length>t;t++){const n=e[t],i=s.get(l[t]),r=a.get(c[t]);if(void 0===i||void 0===r)continue;const d=o(n),h=r*u+i,f=b.get(h);let g;void 0!==f?g=f:(g=x++,b.set(h,g)),p[g]=h,m[g]=d,v[g]=n}let k=1/0,w=-1/0;for(let t=0;x>t;t++){const e=m[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const A=function(t){const e=t in ue?t:"blues";let n=Ne.get(e);if(n)return n;n=Array(256);const o=(i=e)&&ue[i]||Kt;var i;for(let t=0;256>t;t++)n[t]=o(t/255);return Ne.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),S=255/(w-k||1),M=n.width/u,_=n.height/d,P=t.config.showValues,O=t.config.heatmapValueFormat,T=[];for(let t=0;x>t;t++){const e=m[t];if(!isFinite(e))continue;const n=p[t],o=n%u;T.push(Yt(o*M,(d-1-(n-o)/u)*_,M,_,A[Math.min((e-k)*S+.5|0,255)],v[t],P?{value:e,showValues:!0,valueFormat:O}:void 0))}return T}function We(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:n,overlays:o,warned:i}=t;Be(o)&&0===n.length&&Ie(i,"overlay-only",`[semiotic] ${e} 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(t=>null==t.datum)&&Ie(i,"null-datums",`[semiotic] ${e} 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 Be(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(Be))}function Ie(t,e,n){t.has(e)||(t.add(e),console.warn(n))}function Ye(t,e){const n="function"==typeof t?t:n=>n[t||e];return t=>{const e=n(t);return null==e?NaN:+e}}function Ge(t){const e=[],n=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,o=Ye(n&&t.valueAccessor||t.yAccessor,n?"value":"y");if(t.boundsAccessor){const n=Ht(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const i=n(t);return Number.isFinite(i)&&0!==i?e+i:e},getBottom:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const i=n(t);return Number.isFinite(i)&&0!==i?e-i:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const n=Array.isArray(t.band)?t.band:[t.band];for(const t of n)e.push({kind:"band",getTop:Ye(t.y1Accessor,"y1"),getBottom:Ye(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}class He{constructor(t){if(this.xExtent=new Dt,this.yExtent=new Dt,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._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this._lastBoundedInsertsRef=null,this.config=t,this.buffer=new zt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=Ht(t.timeAccessor||t.xAccessor,"time"),this.getY=Ht(t.valueAccessor||t.yAccessor,"value")):(this.getX=Ht(t.xAccessor,"x"),this.getY=Ht(t.yAccessor,"y")),this.getGroup=qt(t.groupAccessor),this.getCategory=qt(t.categoryAccessor),this.getSize=t.sizeAccessor?Ht(t.sizeAccessor,"size"):void 0,this.getColor=qt(t.colorAccessor),this.getSymbol=qt(t.symbolAccessor),this.getY0=t.y0Accessor?Ht(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=Ge(t),this.getPointId=qt(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?Ht(t.openAccessor,"open"):void 0,this.getHigh=Ht(t.highAccessor,"high"),this.getLow=Ht(t.lowAccessor,"low"),this.getClose=n?Ht(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new zt(t.windowSize))}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),o=e.getBottom(t);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(o)&&this.yExtent.push(o)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return!1;const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){if(this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?Ht(this.config.timeAccessor||this.config.xAccessor,"time"):Ht(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,o="function"==typeof n?n(e):e[n||"x"],i=o instanceof Date,r="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=i||r,r){const t="string"==typeof n?n:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(n(t)instanceof Date?n(t):new Date(n(t)))}}const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)if(this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n));else{this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n));for(const t of this.resolvedRibbons){const e=t.getTop(n),o=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(o)&&this.yExtent.push(o)}}}else for(const n of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(n);if(this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n));else{this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n));for(const t of this.resolvedRibbons){const e=t.getTop(n),o=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(o)&&this.yExtent.push(o)}}if(null!=t)if(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t));else{this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),o=e.getBottom(t);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(o)&&this.yExtent.evict(o)}}}return!0}computeScene(t){var e,n,o,i,r,s,a,l,c,u,d,h,f,g;const{config:y,buffer:p}=this;if(!this.needsFullRebuild&&!y.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(p,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const m=this.getBufferArray(),k=this.xExtent.extent,w=this.yExtent.extent;let A=y.xExtent?[null!==(n=y.xExtent[0])&&void 0!==n?n:k[0],null!==(o=y.xExtent[1])&&void 0!==o?o:k[1]]:k,S=y.yExtent?[null!==(i=y.yExtent[0])&&void 0!==i?i:w[0],null!==(r=y.yExtent[1])&&void 0!==r?r:w[1]]:w;const M=y.yExtent&&null!=y.yExtent[0]&&null!=y.yExtent[1],_="exact"===y.axisExtent;if("stackedarea"===y.chartType&&!M&&p.size>0)if(y.normalize)S=[0,_?1:1+y.extentPadding];else{const t=`${p.size}:${this._ingestVersion}:${null!==(s=y.baseline)&&void 0!==s?s:"zero"}:${null!==(a=y.stackOrder)&&void 0!==a?a:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)S=this._stackExtentCache.yDomain;else{const e=this.groupData(m),n=new Map,o=new Set;let i=0;const r=new Map,s=new Map;for(const t of e){const e=new Map;let a=0;for(const n of t.data){const t=this.getX(n),s=this.getY(n);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),o.add(t),a+=s;const l=(r.get(t)||0)+s;r.set(t,l),l>i&&(i=l)}n.set(t.key,e),s.set(t.key,a)}const a=null!==(l=y.stackOrder)&&void 0!==l?l:"key",f=(t,e)=>e>t?-1:t>e?1:0;let g;if("insideOut"===a){const t=[...e].map(t=>t.key).sort((t,e)=>{var n,o;const i=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(o=s.get(t))&&void 0!==o?o:0);return 0!==i?i:f(t,e)}),n=[],o=[];let i=0,r=0;for(const e of t)r>i?(n.push(e),i+=null!==(c=s.get(e))&&void 0!==c?c:0):(o.push(e),r+=null!==(u=s.get(e))&&void 0!==u?u:0);g=[...o.reverse(),...n]}else g="asc"===a?e.map(t=>t.key).sort((t,e)=>{var n,o;const i=(null!==(n=s.get(t))&&void 0!==n?n:0)-(null!==(o=s.get(e))&&void 0!==o?o:0);return 0!==i?i:f(t,e)}):"desc"===a?e.map(t=>t.key).sort((t,e)=>{var n,o;const i=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(o=s.get(t))&&void 0!==o?o:0);return 0!==i?i:f(t,e)}):e.map(t=>t.key).sort(f);if("wiggle"===y.baseline||"silhouette"===y.baseline){const t=Array.from(o).sort((t,e)=>t-e),e=Ft(t,g,(t,e)=>{var o;return(null===(o=n.get(t))||void 0===o?void 0:o.get(e))||0},y.baseline);let i=1/0,s=-1/0;for(const n of t){const t=null!==(d=e.get(n))&&void 0!==d?d:0,o=null!==(h=r.get(n))&&void 0!==h?h:0;i>t&&(i=t),t+o>s&&(s=t+o)}Number.isFinite(i)&&Number.isFinite(s)||(i=0,s=0);const a=s-i,l=_?0:a>0?a*y.extentPadding:1;S=[i-l,s+l]}else S=[0,i+(_?0:i>0?i*y.extentPadding:1)];this._stackExtentCache={key:t,yDomain:S}}}else if("bar"===y.chartType&&y.binSize&&!M&&p.size>0){const[,t]=function(t,e,n,o,i){const r=Et(t,e,n,o,i);if(0===r.size)return[0,0];let s=0;for(const t of r.values())t.total>s&&(s=t.total);return[0,s]}(p,this.getX,this.getY,y.binSize,this.getCategory);S=[0,_?t:t+t*y.extentPadding]}else if("waterfall"===y.chartType&&!M&&p.size>0){const[t,e]=function(t,e){let n=0,o=0,i=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(i+=t,n>i&&(n=i),i>o&&(o=i))}return[n,o]}(p,this.getY),n=e-t,o=_?0:n>0?n*y.extentPadding:1;S=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!M&&S[0]!==1/0){if(this.resolvedRibbons.length>0)for(const t of m)for(const e of this.resolvedRibbons){const n=e.getTop(t),o=e.getBottom(t);Number.isFinite(n)&&(S[0]>n&&(S[0]=n),n>S[1]&&(S[1]=n)),Number.isFinite(o)&&(S[0]>o&&(S[0]=o),o>S[1]&&(S[1]=o))}const t=S[1]-S[0],e=_?0:t>0?t*y.extentPadding:1,n=null===(f=y.yExtent)||void 0===f?void 0:f[0],o=null===(g=y.yExtent)||void 0===g?void 0:g[1];S=[null!=n?S[0]:S[0]-e,null!=o?S[1]:S[1]+e],"log"!==y.yScaleType||S[0]>0||0>=w[0]||_||(S[0]=null!=n?S[0]:w[0]/(1+y.extentPadding))}if(y.yExtent&&!M){const t=y.yExtent[0],e=y.yExtent[1];null==t&&null==e||(S=[null!=t?t:S[0],null!=e?e:S[1]])}if(A[0]===1/0||A[1]===-1/0)if("time"===y.xScaleType){const t=Date.now();A=[t-864e5,t]}else A=[0,1];S[0]!==1/0&&S[1]!==-1/0||(S=[0,1]);const P="streaming"===y.runtimeMode,O=Math.max(0,Math.min(y.scalePadding||0,Math.min(t.width,t.height)/2-1));if(P)if("x"==("up"===(T=y.arrowOfTime)||"down"===T?"y":"x")){const e="right"===y.arrowOfTime?[O,t.width-O]:[t.width-O,O];this.scales={x:v().domain(A).range(e),y:v().domain(S).range([t.height-O,O])}}else{const e="down"===y.arrowOfTime?[O,t.height-O]:[t.height-O,O];this.scales={x:v().domain(S).range([O,t.width-O]),y:v().domain(A).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return b().domain(t).range(n).clamp(!0)}return"time"===t?x().domain([new Date(e[0]),new Date(e[1])]).range(n):v().domain(e).range(n)};this.scales={x:e(y.xScaleType,A,[O,t.width-O]),y:e(y.yScaleType,S,[t.height-O,O])}}var T;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,m),this.config.decay&&this.applyDecay(this.scene,m),this.config.pulse&&this.applyPulse(this.scene,m),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.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return this._quadtree=null,void(this._maxPointRadius=0);let e=0,n=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>n&&(n=t.r));if(this._maxPointRadius=n,He.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const o=Array(e);let i=0;for(const t of this.scene)"point"===t.type&&(o[i++]=t);this._quadtree=w().x(t=>t.x).y(t=>t.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const o of t.path)o[0]*=e,o[1]*=n;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=n;for(const o of t.bottomPath)o[0]*=e,o[1]*=n;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*n,width:t.clipRect.width*e,height:t.clipRect.height*n});break;case"point":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const o=this.scales.x.domain(),i=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),a=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return b().domain(t).range(n).clamp(!0)}return"time"===t?x().domain([new Date(e[0]),new Date(e[1])]).range(n):v().domain(e).range(n)},l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),c=s[1]>s[0];this.scales={x:a(this.config.xScaleType,o,r[0]>r[1]?[t.width-l,l]:[l,t.width-l]),y:a(this.config.yScaleType,i,c?[l,t.height-l]:[t.height-l,l])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n,o,i,r,s,a,l,c,u;const{config:d,scales:h}=this;if(!h)return[];if(d.customLayout){const u=null!==(n=d.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},f={data:e,scales:h,dimensions:{width:t.width,height:t.height,margin:u,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:null!==(o=d.themeSemantic)&&void 0!==o?o:{},categorical:null!==(i=d.themeCategorical)&&void 0!==i?i:fe},resolveColor:(t,e)=>{var n,o;const i=this.resolveGroupColor(t);if(i)return i;const r=this.resolveLineStyle(t,e);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:null!==(o=null===(n=d.themeSemantic)||void 0===n?void 0:n.primary)&&void 0!==o?o:"#4e79a7"},config:null!==(r=d.layoutConfig)&&void 0!==r?r:{},selection:null!==(s=d.layoutSelection)&&void 0!==s?s:null};let g;try{g=d.customLayout(f)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t),this.customLayoutOverlays=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,[]}this.customLayoutOverlays=null!==(a=g.overlays)&&void 0!==a?a:null;const y=null!==(l=g.nodes)&&void 0!==l?l:[];if(this._customRestyle=g.restyle,this.hasCustomRestyle=!!g.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of y)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(y,null!==(c=d.layoutSelection)&&void 0!==c?c:null)}return We({label:"customLayout",nodes:y,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),y}if(this.customLayoutOverlays=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===e.length)return[];const f={scales:h,config:d,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:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(d.chartType){case"line":return function(t,e){var n;const o=t.groupData(e),i=[],r=null===(n=t.config.annotations)||void 0===n?void 0:n.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=Pe(t.ribbons);if(r.length>0&&i.push(...Oe(t,e,r)),n.length>0)for(const e of o)i.push(...Te(t,e.data,e.key,n))}for(const e of o){const n=t.resolveLineStyle(e.key,e.data[0]),o=Rt(e.data,t.scales,t.getX,t.getY,n,e.key);r&&r.length>0&&(o.colorThresholds=r),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return je(t,o,i),i}(f,e);case"area":return function(t,e){const n=t.groupData(e),o=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:r}=Pe(t.ribbons);if(r.length>0&&o.push(...Oe(t,e,r)),i.length>0)for(const e of n)o.push(...Te(t,e.data,e.key,i))}const i=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?i:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),s=Nt(e.data,t.scales,t.getX,t.getY,i,n,e.key,r),a=Ce(t.config.gradientFill);a&&(s.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return je(t,n,o),o}(f,e);case"mixed":return function(t,e){const n=t.groupData(e),o=[],i=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:r}=Pe(t.ribbons);if(r.length>0&&o.push(...Oe(t,e,r)),i.length>0)for(const e of n)o.push(...Te(t,e.data,e.key,i))}const r=t.scales.y.domain()[0],s=t.getY0?e=>{const n=t.getY0(e);return null==n?r:n}:void 0;for(const e of n)if(i.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),i=Nt(e.data,t.scales,t.getX,t.getY,r,n,e.key,s),a=Ce(t.config.gradientFill);a&&(i.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}else{const n=t.resolveLineStyle(e.key,e.data[0]),i=Rt(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return je(t,n,o),o}(f,e);case"stackedarea":return function(t,e){var n,o,i,r;const s=t.groupData(e),a=null!==(n=t.config.stackOrder)&&void 0!==n?n:"key",l=()=>s.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("key"===a)l();else if("asc"===a||"desc"===a||"insideOut"===a){const e=new Map;for(const n of s){let o=0;for(const e of n.data){const n=t.getX(e),i=t.getY(e);Number.isFinite(n)&&Number.isFinite(i)&&(o+=i)}e.set(n.key,o)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===a)s.sort((t,o)=>{var i,r;const s=(null!==(i=e.get(t.key))&&void 0!==i?i:0)-(null!==(r=e.get(o.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,o.key)});else if("desc"===a)s.sort((t,o)=>{var i,r;const s=(null!==(i=e.get(o.key))&&void 0!==i?i:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,o.key)});else{const t=[...s].sort((t,o)=>{var i,r;const s=(null!==(i=e.get(o.key))&&void 0!==i?i:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,o.key)}),r=[],a=[];let l=0,c=0;for(const n of t)c>l?(r.push(n),l+=null!==(o=e.get(n.key))&&void 0!==o?o:0):(a.push(n),c+=null!==(i=e.get(n.key))&&void 0!==i?i:0);s.length=0,s.push(...a.reverse(),...r)}}else l();const c=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,u=t.config.normalize?"zero":null!==(r=t.config.baseline)&&void 0!==r?r:"zero",{nodes:d,stackedTops:h}=function(t,e,n,o,i,r,s,a="zero"){var l,c;const u=new Set;for(const e of t)for(const t of e.data){const e=n(t);Number.isFinite(e)&&u.add(e)}const d=Array.from(u).sort((t,e)=>t-e),h=new Map;for(const e of t){const t=new Map;for(const i of e.data){const e=n(i),r=o(i);Number.isFinite(e)&&Number.isFinite(r)&&t.set(e,(t.get(e)||0)+r)}h.set(e.key,t)}let f;if(r){f=new Map;for(const e of d){let n=0;for(const o of t)n+=(null===(l=h.get(o.key))||void 0===l?void 0:l.get(e))||0;f.set(e,n||1)}}const g=Ft(d,t.map(t=>t.key),(t,e)=>{var n;return(null===(n=h.get(t))||void 0===n?void 0:n.get(e))||0},a),y=[],p=new Map,m=new Map;for(const t of d)m.set(t,null!==(c=g.get(t))&&void 0!==c?c:0);for(const n of t){const t=h.get(n.key),o=[],a=[],l=new Map;for(const n of d){let i=t.get(n)||0;const s=m.get(n);r&&(i/=f.get(n));const c=s+i,u=e.x(n);a.push([u,e.y(s)]),o.push([u,e.y(c)]),m.set(n,c),l.set(n,c)}p.set(n.key,l);const c={type:"area",topPath:o,bottomPath:a,style:i(n.key,n.data[0]),datum:n.data,group:n.key};s&&(c.curve=s),y.push(c)}return{nodes:y,stackedTops:p}}(s,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,c,u),f=d;if(t.config.pointStyle){const e=new WeakMap;for(const n of s){const o=h.get(n.key);if(o)for(const i of n.data){const n=t.getX(i),r=t.getY(i);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!o.has(n)||e.set(i,o.get(n))}}const n=n=>{var o;return null!==(o=e.get(n))&&void 0!==o?o:t.getY(n)};je(t,s,f,n)}return f}(f,e);case"scatter":case"bubble":return function(t,e){var n;const o=[],i="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let s=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const o of n)t>o&&(t=o),o>e&&(e=o);s=n=>t===e?(r[0]+r[1])/2:r[0]+(n-t)/(e-t)*(r[1]-r[0])}}const a=t.getColor?t.resolveColorMap(e):null,l=(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",c=t.getSymbol,u=t.config.symbolMap,d=new Map;let h=0;const f=t=>{const e=null==u?void 0:u[t];if(e)return e;let n=d.get(t);return n||(n=De[h%De.length],h++,d.set(t,n)),n};for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:l,opacity:.8},r=e.r||i;if(s&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(r=s(e))}if(a&&t.getColor&&!e.fill){const o=t.getColor(n);o&&a.has(o)&&(e=Object.assign(Object.assign({},e),{fill:a.get(o)}))}const u=t.getPointId?t.getPointId(n)+"":void 0;if(c){const i=f(c(n)+""),s=Bt(n,t.scales,t.getX,t.getY,Math.PI*r*r,i,e,u);s&&o.push(s)}else{const i=Wt(n,t.scales,t.getX,t.getY,r,e,u);i&&o.push(i)}}return o}(f,e);case"heatmap":return Fe(f,e,t);case"bar":{const t=function(t,e){var n,o;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const i=Et(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===i.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of i.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],o=new Set(n),s=Array.from(e).filter(t=>!o.has(t)).sort(),a=n.filter(t=>e.has(t)),l=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===l?r=t.barCategoryCache.order:(r=[...a,...s],t.barCategoryCache={key:l,order:r})}const s=[],a=t.scales,[l,c]=a.x.domain(),u=t.config.barStyle,d=null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary,h=null==u?void 0:u.gap,f="number"!=typeof h||0>h?1:h,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const e of i.values()){const n=Math.max(e.start,l),i=Math.min(e.end,c);if(n>=i)continue;const h=a.x(n),y=a.x(i),p=Math.abs(y-h),m=p>f+1?f:0,v=Math.min(h,y)+m/2,b=Math.max(p-m,1);if(b>0)if(r&&e.categories.size>0){let n=0;for(const i of r){const r=e.categories.get(i)||0;if(0===r)continue;const l=a.y(n),c=a.y(n+r),h=(null===(o=t.config.barColors)||void 0===o?void 0:o[i])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push(It(v,Math.min(l,c),b,Math.abs(l-c),Object.assign({fill:h},g),{binStart:e.start,binEnd:e.end,total:e.total,category:i,categoryValue:r},i)),n+=r}}else{const t=a.y(0),n=a.y(e.total);s.push(It(v,Math.min(t,n),b,Math.abs(t-n),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of i.values())y.add(t.start),y.add(t.end);return{nodes:s,binBoundaries:Array.from(y).sort((t,e)=>t-e)}}(f,e);return this._barCategoryCache=null!==(u=f.barCategoryCache)&&void 0!==u?u:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,o,i,r,s,a;const l=[],c=t.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(o=c.fill)&&void 0!==o?o:null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary)&&void 0!==r?r:"#007bff",h=null!==(s=c.opacity)&&void 0!==s?s:.7,f=c.stroke,g=c.strokeWidth;for(const n of e){const e=t.getX(n),o=t.getY(n);if(null==o||Number.isNaN(o))continue;const i=t.scales.x(e),r=t.scales.y(o);let s=d;if(t.getCategory){const e=t.getCategory(n);s=(null===(a=t.config.barColors)||void 0===a?void 0:a[e])||s}const c={type:"point",x:i,y:r,r:u,style:{fill:s,opacity:h,stroke:f,strokeWidth:g},datum:n};t.getPointId&&(c.pointId=t.getPointId(n)+""),l.push(c)}return l}(f,e);case"waterfall":return function(t,e,n){var o,i,r,s,a,l,c;const u=[],d=t.scales,h=t.config.waterfallStyle,f=e.filter(e=>{const n=t.getY(e),o=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===f.length)return u;const g=null!==(r=null!==(o=null==h?void 0:h.positiveColor)&&void 0!==o?o:null===(i=t.config.themeSemantic)||void 0===i?void 0:i.success)&&void 0!==r?r:"#28a745",y=null!==(l=null!==(s=null==h?void 0:h.negativeColor)&&void 0!==s?s:null===(a=t.config.themeSemantic)||void 0===a?void 0:a.danger)&&void 0!==l?l:"#dc3545",p=null!==(c=null==h?void 0:h.gap)&&void 0!==c?c:1,m=null==h?void 0:h.stroke,v=null==h?void 0:h.strokeWidth,b=null==h?void 0:h.opacity;let x=0;for(let e=0;f.length>e;e++){const o=f[e],i=t.getX(o),r=t.getY(o),s=x+r;let a;a=f.length-1>e?t.getX(f[e+1])-i:e>0?i-t.getX(f[e-1]):0;const l=d.x(i),c=0!==a?d.x(i+a):l+n.width/10,k=Math.min(l,c)+p/2,w=Math.max(l,c)-p/2-k;if(0>=w){x=s;continue}const A=d.y(x),S=d.y(s),M=Math.min(A,S),_=Math.abs(A-S),P={fill:0>r?y:g,stroke:m,strokeWidth:v};null!=b&&(P.opacity=b),u.push(It(k,M,w,_,P,Object.assign(Object.assign({},o),{baseline:x,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),x=s}return u}(f,e,t);case"candlestick":return function(t,e){var n,o;if(!t.getHigh||!t.getLow||!t.scales)return[];const i=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(i||t.getOpen&&t.getClose))return[];const r=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",l=i?a:s.upColor||"#28a745",c=i?a:s.downColor||"#dc3545",u=i?a:s.wickColor||"#333",d=s.wickWidth||(i?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(null==s.bodyWidth)if(h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const o=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));o>0&&e>o&&(e=o)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const o=t.getHigh(n),s=t.getLow(n);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=i?o:t.getOpen(n),h=i?s:t.getClose(n);if(!i&&[a,h].some(t=>null==t||Number.isNaN(t)))continue;const g=h>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(h),highY:t.scales.y(o),lowY:t.scales.y(s),bodyWidth:f,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:g,datum:n};i&&(y.isRange=!0),r.push(y)}return r}(f,e);default:return[]}}resolveBoundsStyle(t,e){var n;const o=this.config.boundsStyle;return"function"==typeof o?o(e||{},t):o&&"object"==typeof o?o:{fill:this.resolveLineStyle(t,e).stroke||(null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?me(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var o,i;const r=n.length;if(1>=r)return;const s=new Map;for(let t=0;n.length>t;t++)s.set(n[t],t);for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const o=Array(e.length);let i=!1;for(let n=0;e.length>n;n++){const a=s.get(e[n]);null!=a?(o[n]=me(t,a,r),1>o[n]&&(i=!0)):o[n]=1}i&&(n._decayOpacities=o);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:e.length;if(2>o)continue;if(e.length===o){const i=Array(o);let a=!1;for(let n=0;e.length>n;n++){const o=s.get(e[n]);null!=o?(i[n]=me(t,o,r),1>i[n]&&(a=!0)):i[n]=1}a&&(n._decayOpacities=i)}else{let i=1;for(const n of e){const e=s.get(n);if(null!=e){const n=me(t,e,r);i>n&&(i=n)}}if(1>i){const t=Array(o);t.fill(i),n._decayOpacities=t}}continue}const e=s.get(n.datum);if(null==e)continue;const a=me(t,e,r);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const t=null!==(i=null===(o=n.style)||void 0===o?void 0:o.opacity)&&void 0!==i?i:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,o){var i,r;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=t.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",l=null!==(r=t.glowRadius)&&void 0!==r?r:4,c=new Map;for(let t=0;n.length>t;t++)c.set(n[t],t);for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let i=0;for(const n of e){const e=c.get(n);if(null==e)continue;const r=o.get(e);if(null==r)continue;const a=ve(t,r,s);a>i&&(i=a)}i>0&&(n._pulseIntensity=i,n._pulseColor=a);continue}const e=c.get(n.datum);if(null==e)continue;const i=o.get(e);if(null==i)continue;const r=ve(t,i,s);r>0&&(n._pulseIntensity=r,n._pulseColor=a,n._pulseGlowRadius=l)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&be(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,o){var i,r,s,a;n.clear(),o.clear();for(let l=0;e.length>l;l++){const c=e[l],u=Se(t,c,l);u&&("point"===c.type?n.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(i=c.style)||void 0===i?void 0:i.opacity}):"candlestick"===c.type?n.set(u,{x:c.x,y:c.openY,w:c.bodyWidth,openY:c.openY,closeY:c.closeY,highY:c.highY,lowY:c.lowY,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"line"===c.type?o.set(u,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}):"area"===c.type&&o.set(u,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=c.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const o=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=Se(this.transitionContext,e,t);i&&("point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(i,{x:e.x,y:o,w:e.w,h:0,opacity:null!==(n=e.style.opacity)&&void 0!==n?n:1}):"heatcell"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(i,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(i,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,o,i){var r,s,a,l,c,u,d,h,f,g,y,p,m,v,b,x,k,w,A,S,M,_,P,O,T,$,j,L,C,z,D,E,R,N,F,W,B,I,Y,G,H;if(0===o.size&&0===i.size)return n;const X=null!==(r=e.duration)&&void 0!==r?r:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let q=!1;const V=new Set,U=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],$=Se(t,r,e);if(!$)continue;if(r._transitionKey=$,"line"===r.type||"area"===r.type){const t=i.get($);if(t){if(U.add($),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];q=!0}else if("area"===r.type&&t.topPath&&t.bottomPath&&t.topPath.length===r.topPath.length&&t.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(t=>[t[0],t[1]]),r._targetBottomPath=r.bottomPath.map(t=>[t[0],t[1]]),r._prevTopPath=t.topPath,r._prevBottomPath=t.bottomPath;for(let e=0;r.topPath.length>e;e++)r.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;r.bottomPath.length>e;e++)r.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];q=!0}r._targetOpacity=null!==(s=r.style.opacity)&&void 0!==s?s:1,r._startOpacity=null!==(l=null!==(a=t.opacity)&&void 0!==a?a:r.style.opacity)&&void 0!==l?l:1}else r._targetOpacity=null!==(c=r.style.opacity)&&void 0!==c?c:1,r._startOpacity=0,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;continue}const j=o.get($);if("point"===r.type)if(j){V.add($);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,j.x===t.x&&j.y===t.y&&j.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=j.x,r.y=j.y,r.r=null!==(d=j.r)&&void 0!==d?d:r.r,q=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;else if("rect"===r.type)if(j){V.add($);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(f=r.style.opacity)&&void 0!==f?f:1,j.x===t.x&&j.y===t.y&&j.w===t.w&&j.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=j.x,r.y=j.y,r.w=null!==(g=j.w)&&void 0!==g?g:r.w,r.h=null!==(y=j.h)&&void 0!==y?y:r.h,q=!0)}else r._targetOpacity=null!==(p=r.style.opacity)&&void 0!==p?p:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;else if("heatcell"===r.type)if(j){V.add($);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(v=null===(m=r.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,j.x===t.x&&j.y===t.y&&j.w===t.w&&j.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=j.x,r.y=j.y,r.w=null!==(b=j.w)&&void 0!==b?b:r.w,r.h=null!==(x=j.h)&&void 0!==x?x:r.h,q=!0)}else r._targetOpacity=null!==(w=null===(k=r.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),q=!0;else if("candlestick"===r.type)if(j&&null!=j.openY){V.add($);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(S=null===(A=r.style)||void 0===A?void 0:A.opacity)&&void 0!==S?S:1,(j.x!==t.x||j.openY!==t.openY||j.closeY!==t.closeY||j.highY!==t.highY||j.lowY!==t.lowY)&&(r._targetX=t.x,r._targetOpenY=t.openY,r._targetCloseY=t.closeY,r._targetHighY=t.highY,r._targetLowY=t.lowY,r.x=j.x,r.openY=j.openY,r.closeY=null!==(M=j.closeY)&&void 0!==M?M:r.closeY,r.highY=null!==(_=j.highY)&&void 0!==_?_:r.highY,r.lowY=null!==(P=j.lowY)&&void 0!==P?P:r.lowY,q=!0)}else r._targetOpacity=null!==(T=null===(O=r.style)||void 0===O?void 0:O.opacity)&&void 0!==T?T:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),q=!0}for(const[t,e]of i)if(!U.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==($=e.opacity)&&void 0!==$?$:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(o),q=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(j=e.opacity)&&void 0!==j?j:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(o),q=!0}for(const[t,e]of o)if(!V.has(t)){if(t.startsWith("p:")){const o={type:"point",x:e.x,y:e.y,r:null!==(L=e.r)&&void 0!==L?L:3,style:{opacity:null!==(C=e.opacity)&&void 0!==C?C:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}else if(t.startsWith("r:")){const o={type:"rect",x:e.x,y:e.y,w:null!==(z=e.w)&&void 0!==z?z:0,h:null!==(D=e.h)&&void 0!==D?D:0,style:{opacity:null!==(E=e.opacity)&&void 0!==E?E:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}else if(t.startsWith("h:")){const o={type:"heatcell",x:e.x,y:e.y,w:null!==(R=e.w)&&void 0!==R?R:0,h:null!==(N=e.h)&&void 0!==N?N:0,fill:"#999",datum:null,style:{opacity:null!==(F=e.opacity)&&void 0!==F?F:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}else if(t.startsWith("c:")){const o=null!==(W=e.openY)&&void 0!==W?W:e.y,i={type:"candlestick",x:e.x,openY:o,closeY:null!==(B=e.closeY)&&void 0!==B?B:o,highY:null!==(I=e.highY)&&void 0!==I?I:o,lowY:null!==(Y=e.lowY)&&void 0!==Y?Y:o,bodyWidth:null!==(G=e.w)&&void 0!==G?G:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(H=e.opacity)&&void 0!==H?H:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}q=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),q&&(n.activeTransition={startTime:Ae(),duration:X}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,o){var i,r,s,a,l,c;if(!n.activeTransition)return!1;const u=ke(t,n.activeTransition),d=xe(u,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=we(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=we(n.x,t._targetX,d),t.y=we(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=we(n.r,t._targetR,d))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style.opacity=we(i,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=we(n.x,t._targetX,d),t.y=we(n.y,t._targetY,d),void 0!==n.w&&(t.w=we(n.w,t._targetW,d)),void 0!==n.h&&(t.h=we(n.h,t._targetH,d))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,i=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:we(i,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=we(n.x,t._targetX,d),t.y=we(n.y,t._targetY,d),void 0!==n.w&&(t.w=we(n.w,t._targetW,d)),void 0!==n.h&&(t.h=we(n.h,t._targetH,d))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,i=n?null!==(a=n.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:we(i,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=we(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=we(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=we(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=we(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=we(n.lowY,t._targetLowY,d))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(l=t._startOpacity)&&void 0!==l?l:0;t.style=Object.assign(Object.assign({},t.style),{opacity:we(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=we(e[o][0],n[o][0],d),t.path[o][1]=we(e[o][1],n[o][1],d)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:we(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevTopPath,n=t._prevBottomPath,o=t._targetTopPath,i=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=we(e[n][0],o[n][0],d),t.topPath[n][1]=we(e[n][1],o[n][1],d);if(n&&i&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=we(n[e][0],i[e][0],d),t.bottomPath[e][1]=we(n[e][1],i[e][1],d)}}if(u>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){if(this._groupDataCache&&this._groupDataCache.version===this._ingestVersion&&this._groupDataCache.group===this.getGroup&&this._groupDataCache.data===t)return this._groupDataCache.result;let e;if(this.getGroup){const n=new Map;for(const e of t){const t=this.getGroup(e);n.has(t)||n.set(t,[]),n.get(t).push(e)}e=Array.from(n.entries()).map(([t,e])=>({key:t,data:e}))}else e=[{key:"_default",data:t}];return this._groupDataCache={version:this._ingestVersion,group:this.getGroup,data:t,result:e},e}resolveColorMap(t){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.from(e).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||fe,r=new Map;for(let t=0;n.length>t;t++)r.set(n[t],i[t%i.length]);return this._colorMapCache={key:o,map:r,version:this._ingestVersion},r}resolveLineStyle(t,e){var n;const o=this.config.lineStyle;if("function"==typeof o){const n=o(e||{},t);if(n&&!n.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{stroke:e})}return n}const i=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;return o&&"object"==typeof o?{stroke:o.stroke||i||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:this.resolveGroupColor(t)||i||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n,o;if(this.config.areaStyle){const n=this.config.areaStyle(e||{});if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const i=this.config.lineStyle;if("function"==typeof i){const n=i(e||{},t);if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const r=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||r||"#4e79a7",fillOpacity:null!==(o=i.fillOpacity)&&void 0!==o?o:.7,stroke:i.stroke||r||"#4e79a7",strokeWidth:i.strokeWidth||2};const s=this.resolveGroupColor(t)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const n=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||fe;if(0===n.length)return null;const o=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,o),this._groupColorMap.size>He.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getPointId,o=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{o(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const i=this.buffer.remove(o);if(0===i.length)return i;for(const t of i)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),i}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),o=this.getPointId,i=new Set;this.buffer.forEach((t,e)=>{n.has(o(t))&&i.add(e)});const r=this.buffer.update(t=>n.has(o(t)),e);if(0===r.length)return r;for(const t of r)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{i.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),r}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.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._maxPointRadius=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}setLayoutSelection(t){this.config.layoutSelection=t}applyCustomRestyle(t,e){var n,o;const i=this._customRestyle;if(i)for(const r of t){const t=null!==(o=null!==(n=this._baseStyles.get(r))&&void 0!==n?n:r.style)&&void 0!==o?o:{},s=i(r,e);r.style=s?Object.assign(Object.assign({},t),s):t}}restyleScene(t){this._customRestyle&&this.applyCustomRestyle(this.scene,t)}updateConfig(t){var e,n,o,i;const r=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let s=!1,a=!1;Object.assign(this.config,t);const l="chartType"in t&&t.chartType!==r.chartType||"runtimeMode"in t&&t.runtimeMode!==r.runtimeMode;if(l||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=l||!Gt(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),u=l||!Gt(null!==(o=t.yAccessor)&&void 0!==o?o:t.valueAccessor,null!==(i=r.yAccessor)&&void 0!==i?i:r.valueAccessor);(c||u)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=Ht(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Ht(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Ht(this.config.xAccessor,"x"),this.getY=Ht(this.config.yAccessor,"y")),u&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=Ge(this.config)),s=!0,a=!0)}if("groupAccessor"in t&&!Gt(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?qt(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!Gt(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?qt(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!Gt(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Ht(this.config.sizeAccessor,"size"):void 0,s=!0),"symbolAccessor"in t&&!Gt(t.symbolAccessor,r.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?qt(this.config.symbolAccessor):void 0,s=!0),"colorAccessor"in t&&!Gt(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?qt(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!Gt(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?Ht(this.config.y0Accessor,"y0"):void 0,s=!0,a=!0),("boundsAccessor"in t&&!Gt(t.boundsAccessor,r.boundsAccessor)||"band"in t&&t.band!==r.band||"boundsStyle"in t&&t.boundsStyle!==r.boundsStyle)&&(this.resolvedRibbons=Ge(this.config),s=!0,a=!0),"pointIdAccessor"in t&&!Gt(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?qt(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(l||"openAccessor"in t&&!Gt(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!Gt(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!Gt(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!Gt(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?Ht(this.config.openAccessor,"open"):void 0,this.getHigh=Ht(this.config.highAccessor,"high"),this.getLow=Ht(this.config.lowAccessor,"low"),this.getClose=e?Ht(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0,a=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==r[n]){s=!0;break}}s&&(a&&this.rebuildExtents(),this.needsFullRebuild=!0)}}function Xe(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function qe(t,e){var n,o=[],i=[],r=[],s={},a=[];function l(t){r[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],r[e]&&l(e)})}function c(t){var e,o,d=!1;for(i.push(t),r[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===n?(u(n,i),d=!0):r[o]||(d=c(o));if(d)l(t);else for(e=0;a[t].length>e;e++){var h=s[o=a[t][e]];h||(s[o]=h={}),h[o]=!0}return i.pop(),d}function u(t,e){var n=[].concat(e).concat(t);o.push(n)}function d(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,o=function(t){for(var e=t.length,n=Array(e),o=Array(e),i=Array(e),r=Array(e),s=Array(e),a=Array(e),l=0;e>l;++l)n[l]=-1,o[l]=0,i[l]=!1,r[l]=0,s[l]=-1,a[l]=[];var c,u=0,d=[],h=[];function f(e){var l=[e],c=[e];for(n[e]=o[e]=u,i[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>r[e]){for(var g=r[e];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=o[y]=u,i[y]=!0,u+=1,l.push(y),c.push(y);break}i[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}r[e]=g}else{if(o[e]===n[e]){var p=[],m=[],v=0;for(g=l.length-1;g>=0;--g){var b=l[g];if(i[b]=!1,p.push(b),m.push(a[b]),v+=a[b].length,s[b]=d.length,b===e){l.length=g;break}}d.push(p);var x=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--v]=m[g][k];h.push(x)}c.pop()}}}for(l=0;e>l;++l)0>n[l]&&f(l);for(l=0;h.length>l;l++){var g=h[l];if(0!==g.length){g.sort(function(t,e){return t-e}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[l]=c}}return{components:d,adjacencyList:h}}(t),i=o.components.filter(function(t){return t.length>1}),r=1/0,s=0;i.length>s;s++)for(var a=0;i[s].length>a;a++)r>i[s][a]&&(r=i[s][a],n=s);var l=i[n];if(!l)return!1;var c=t.map(function(t,e){return-1===l.indexOf(e)?[]:t.filter(function(t){return-1!==l.indexOf(t)})});return{leastVertex:r,adjList:c}}n=0;for(var h=t.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];r[+p]=!1,s[p]={}}c(n),n+=1}else n=h}return o}function Ve(t){return t.y0-t.y1>0?"up":"down"}function Ue(t,e){return e(t.source)==e(t.target)}function Ze(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function Qe(t){return t.target.x0-t.source.x1}function Ke(t,e){var n=tn(t),o=Qe(e)/Math.tan(n);return"up"==Ve(t)?t.y1-o:t.y1+o}function Je(t,e){var n=tn(t),o=Qe(e)/Math.tan(n);return"up"==Ve(t)?t.y1+o:t.y1-o}function tn(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function en(t,e){return e(t)}function nn(t){return rn(t.source)}function on(t){return rn(t.target)}function rn(t){return(t.y0+t.y1)/2}function sn(t){return t.virtual?0:t.value}function an(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Ue(t,e)?n+1:n});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Ue(t,e)?o+1:o}),n+o}function ln(t){return t.target.depth}function cn(t,e){return t.sourceLinks.length?t.depth:e-1}function un(t,e){return t.y0-e.y0}function dn(t,e){return e.y0-t.y0}function hn(t,e){return t.y1-e.y1}function fn(t,e){return e.y1-t.y1}function gn(t,e){return pn(t.source,e.source)||t.index-e.index}function yn(t,e){return pn(t.target,e.target)||t.index-e.index}function pn(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function mn(t,e){return vn(t)==vn(e)?"bottom"==t.circularLinkType?dn(t,e):un(t,e):vn(e)-vn(t)}function vn(t){return t.target.column-t.source.column}function bn(t,e){return xn(t)==xn(e)}function xn(t){return t.y0-t.y1>0?"up":"down"}function kn(t,e,n,o,i){let r=t;var s=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=H(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=r.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),wn(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),wn(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+o,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Ue(t,e)&&Ze(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+i+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,l=t.circularLinkType,c=r.links.filter(function(t){return t.source.column==s&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?dn:un);var u=0;c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),s=t.target.column,(c=r.links.filter(function(t){return t.target.column==s&&t.circularLinkType==l})).sort("bottom"==t.circularLinkType?fn:hn),u=0,c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+i+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,o=t.target.x0,i=t.y1,r=(e+o)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+i+" "+o+","+i}(t)}),r}function wn(t,e,n){t.sort(mn);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,i){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Ue(t,e)&&Ze(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&An(t,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;r=l>r?l:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function An(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function Sn(t){return function(){return t}}function Mn(t){return t.index}function _n(t){return t.nodes}function Pn(t){return t.links}function On(t,e,n){var o=X(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(i,r){var s=i.length;if(e)i.sort(e);else if(r>0){var a=new Map;i.forEach(function(t,e){var n,o,i,r=(o=0,i=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=rn(t.source)*e,o+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=rn(t.target)*e,o+=e}}),o>0?i/o:NaN);a.set(t,{bc:r,idx:e})}),i.sort(function(t,e){var n=a.get(t),o=a.get(e),i=n.bc,r=o.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(i)||isNaN(r)?isNaN(i)?isNaN(r)?n.idx-o.idx:1:-1:i-r})}else i.sort(function(t,e){return t.circularLinkType==e.circularLinkType?an(e,n)-an(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});i.forEach(function(e,i){e.depth==o.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==an(e,n)?(e.y0=t.y1/2+i,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+i,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-i,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*i,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+i,e.y1=e.y0+e.value*t.ky)})})}function Tn(t,e,n,o,i,r){var s=X(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,l=r;l>0;--l)c(a*=.99,n),u();function c(e,n){var o=s.length;s.forEach(function(i){var r=i.length,s=i[0].depth;i.forEach(function(i){var a;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&an(i,n)>0){var l=U(i.sourceLinks,on),c=U(i.targetLinks,nn),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-rn(i))*e*.3;i.y0+=d,i.y1+=d}}else if(0==s&&1==r)i.y0=t.y1/2-(a=i.y1-i.y0)/2,i.y1=t.y1/2+a/2;else if(s==o-1&&1==r)i.y0=t.y1/2-(a=i.y1-i.y0)/2,i.y1=t.y1/2+a/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)a=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+a;else{var h=U(i.sourceLinks,on),f=U(i.targetLinks,nn),g=((h&&f?(h+f)/2:h||f)-rn(i))*e;i.y0+=g,i.y1+=g}})})}function u(){s.forEach(function(n){var r,s,a,l=t.y0,c=n.length;for(n.sort(e||pn),a=0;c>a;++a)(s=l-(r=n[a]).y0)>0&&(r.y0+=s,r.y1+=s),l=r.y1+o;if((s=l-o-t.y1)>0)for(l=r.y0-=s,r.y1-=s,a=c-2;a>=0;--a)(s=(r=n[a]).y1+i-l)>0&&(r.y0-=s,r.y1-=s),l=r.y0})}}function $n(t){t.nodes.forEach(function(t){t.sourceLinks.sort(yn),t.targetLinks.sort(gn)}),t.nodes.forEach(function(t){var e=t.y0,n=e,o=t.y1,i=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=i-t.width/2,i-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function jn(){var t=0,e=0,n=1,o=1,i=24,r=8,s=null,a=Mn,l=cn,c=void 0,u=32,d=2,h=_n,f=Pn;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=t,h.y0=e,h.x1=n,h.y1=o,h.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return Z(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var o=t.source,i=t.target;"object"!=typeof o&&(o=t.source=Xe(n,o)),"object"!=typeof i&&(i=t.target=Xe(n,i)),o.sourceLinks.push(t),i.targetLinks.push(t)})}(h,a),function(t,e){var n=0;if(null==e){for(var o=[],i=0;t.links.length>i;i++){var r=t.links[i],s=r.source.index,a=r.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var l=qe(o);l.sort(function(t,e){return t.length-e.length});var c={};for(i=0;l.length>i;i++){var u=l[i].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||c[o]&&c[o][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(h,c),function(t,e){var n=0,o=0;t.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:o>n?"top":"bottom","top"==i.circularLinkType?n++:o++,t.nodes.forEach(function(t){en(t,e)!=en(i.source,e)&&en(t,e)!=en(i.target,e)||(t.circularLinkType=i.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Ue(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(h,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(V(t.sourceLinks,sn),V(t.targetLinks,sn)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(h),function(t,e,n){var o,i,r;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,i=[],r=0;o.length;++r,o=i,i=[])o.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>i.indexOf(t.target)&&!t.circular&&i.push(t.target)})});for(o=t.nodes,i=[],r=0;o.length;++r,o=i,i=[])o.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>i.indexOf(t.source)&&!t.circular&&i.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(h,c,l);var f=r;if(null!==s){var g=X(h.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=q(g,function(t){return t.length});y>1&&(f=Math.max(1,(o-e)*s/(y-1)))}(function(t,e,n){var o=X(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var i=H(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/V(e,function(t){return t.value})});t.ky=i,t.links.forEach(function(e){e.width=e.value*t.ky});var r=q(t.nodes,function(t){return t.column});t.nodes.forEach(r>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/r),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(h,f,i),On(h,c,a),Tn(h,c,a,f,f,u),$n(h),kn(h,a,d,10,8),On(h,c,a),Tn(h,c,a,f,f,u),$n(h),kn(h,a,d,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var o=n.links.filter(function(n){return en(n.source,e)==en(t,e)}),i=o.length;i>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!bn(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Ke(e,t);return t.y1-n}if(e.target.column>t.target.column)return Ke(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),o.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;i>r;r++)s+=o[r].width;e.y0=t.y1-s-e.width/2}})})}(h,a),function(t,e){let n=t;n.nodes.forEach(function(t){var o=n.links.filter(function(n){return en(n.target,e)==en(t,e)}),i=o.length;i>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!bn(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Je(e,t);return t.y0-n}if(e.source.column>t.source.column)return Je(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),o.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;i>r;r++)s+=o[r].width;e.y1=t.y1-s-e.width/2}})})}(h,a),function(t){var e=t.nodes,n=t.links,o=!1,i=!1;if(n.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(i=!0)}),0==o||0==i){var r=H(e,function(t){return t.y0}),s=q(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);function l(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1)}),n.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=l(t.y0)-t.y0;t.y0=l(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(h),kn(h,a,d,10,8)}(g),g}return g.update=function(t){return $n(t),kn(t,a,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(i=+t,g):i},g.nodePadding=function(t){return arguments.length?(r=+t,g):r},g.nodePaddingRatio=function(t){return arguments.length?(s=+t,g):s},g.nodes=function(t){return arguments.length?(h="function"==typeof t?t:Sn(t),g):h},g.links=function(t){return arguments.length?(f="function"==typeof t?t:Sn(t),g):f},g.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:Sn(t),g):a},g.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:Sn(t),g):l},g.nodeSort=function(t){return arguments.length?(c=t,g):c},g.iterations=function(t){return arguments.length?(u=+t,g):u},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],n=+i[1][0],o=+i[1][1],g):[[t,e],[n,o]]},g.size=function(i){return arguments.length?(t=e=0,n=+i[0],o=+i[1],g):[n-t,o-e]},g}function Ln(t){const{sx:e,sTop:n,sBot:o,tx:i,tTop:r,tBot:s,cp1X:a,cp2X:l}=t,c=(n+o)/2,u=(r+s)/2;return{pathD:[`M${e},${n}`,`C${a},${n} ${l},${r} ${i},${r}`,`L${i},${s}`,`C${l},${s} ${a},${o} ${e},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:c},{x:a,y:c},{x:l,y:u},{x:i,y:u}],halfWidth:(o-n)/2}}}He.GROUP_COLOR_MAP_CAP=1e3,He.QUADTREE_THRESHOLD=500;const Cn=t=>{let e,n,o,i,r,s,a,l,c;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,i=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,a=J(r,s),l=a(.5),c=a(.5),`M${e},${r}C${e},${l} ${n},${c} ${n},${s}L${o},${s}C${o},${c} ${i},${l} ${i},${r}Z`;const u=t.sankeyWidth/2,d=J(t.source.x1,t.target.x0),{pathD:h}=Ln({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:d(.5),cp2X:d(.5)});return h};function zn(t){var e;const n=t.sankeyWidth/2,o=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,i=t.circularPathData;if(!i)return null;if("down"===t.direction)return null;if(t._circularStub){const e=i.sourceX,o=i.sourceY,r=i.targetX,s=i.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-e))),l=Math.max(15,Math.min(40,.33*(r-i.leftFullExtent)));return`M${e},${o-n}L${e+a},${o-n}L${e+a},${o+n}L${e},${o+n}ZM${r},${s-n}L${r-l},${s-n}L${r-l},${s+n}L${r},${s+n}Z`}const r=i.sourceX,s=i.sourceY,a=i.targetX,l=i.targetY,c=i.rightFullExtent,u=i.leftFullExtent,d=i.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${r},${s-h*n}L${c},${s-h*n}L${c+o},${s-h*n+h*f}L${c+o},${d+h*o-h*f}L${c+o-f},${d+h*o}L${u-o+f},${d+h*o}L${u-o},${d+h*o-h*f}L${u-o},${l-h*n+h*f}L${u-o+f},${l-h*n}L${a},${l-h*n}L${a},${l+h*n}L${u+o},${l+h*n}L${u+o},${d-h*o}L${c-o},${d-h*o}L${c-o},${s+h*n}L${r},${s+h*n}Z`}const Dn=new Set,En=new WeakMap;function Rn(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=En.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,En.set(t,n);const o=new Proxy(t,{get(t,n,o){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;Dn.has(t)||(Dn.add(t),console.warn(`[Semiotic] "${e}" 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(t,n,o)}});return n.set(e,o),o}const Nn={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(ln))-1:0},justify:cn};function Fn(t){return"string"==typeof t?t:t.id}const Wn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,o){var i,r,s,a,l,c,u;if(0===t.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(i=n.nodeWidth)&&void 0!==i?i:15,g=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,y=null!==(s=n.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let v;v="down"===d?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const b=jn().extent(v).links(m).nodes(p).nodeAlign(Nn[h]||cn).nodeId(t=>t.id).nodeWidth(f).iterations(y);b.nodePaddingRatio&&b.nodePaddingRatio(g),b();{let t=1/0,e=-1/0,n=1/0,i=-1/0;for(const o of p)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),n>o.y0&&(n=o.y0),o.y1>i&&(i=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const r=o.circularPathData,s=(null!==(l=null!==(a=o._circularWidth)&&void 0!==a?a:o.width)&&void 0!==l?l:0)/2;t>r.leftFullExtent-s&&(t=r.leftFullExtent-s),r.rightFullExtent+s>e&&(e=r.rightFullExtent+s),n>r.verticalFullExtent-s&&(n=r.verticalFullExtent-s),r.verticalFullExtent+s>i&&(i=r.verticalFullExtent+s)}const r=e-t,s=i-n,u=o[0],d=o[1];if(r>0&&s>0&&(0>t||0>n||e>u||i>d)){const e=Math.min(u/r,d/s),o=-t*e+(u-r*e)/2,i=-n*e+(d-s*e)/2;for(const t of p)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+i,t.y1=t.y1*e+i;for(const t of m)if(t.y0=t.y0*e+i,t.y1=t.y1*e+i,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+o,n.targetX=n.targetX*e+o,n.sourceY=n.sourceY*e+i,n.targetY=n.targetY*e+i,n.rightFullExtent=n.rightFullExtent*e+o,n.leftFullExtent=n.leftFullExtent*e+o,n.verticalFullExtent=n.verticalFullExtent*e+i,n.rightInnerExtent=n.rightInnerExtent*e+o,n.leftInnerExtent=n.leftInnerExtent*e+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+i,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+i,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of p){const e=x.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=Fn(t.source),n=Fn(t.target),o=k.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=d;const i=x.get(e),r=x.get(n);i&&(o.source=i),r&&(o.target=r)}}},buildScene(t,e,n,o){var i,r,s,a,l,c;const u="vertical"===n.orientation?"down":"right",d=n.nodeStyle,h=n.edgeStyle,f=null!==(i=n.edgeOpacity)&&void 0!==i?i:.5,g=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Qt,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const m=[],v=[],b=[],x=new Map;for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const o=d?d(Rn(e,"nodeStyle")):{},i={fill:o.fill||p.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};x.set(e.id,("string"==typeof i.fill?i.fill:null)||p.get(e.id)||"#4d430c"),m.push("down"===u?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:i,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:i,datum:e,id:e.id,label:e.id})}const k=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of k){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let i=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";i="function"==typeof g?g(t)||i:"target"===g?x.get(o.id)||p.get(o.id)||i:x.get(e.id)||p.get(e.id)||i;const u=h?h(Rn(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),r=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),s=u.fill||i;v.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+o},${e.sourceY-n}L${e.sourceX+o},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:s,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),v.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-r},${e.targetY-n}L${e.targetX-r},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:s,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-r,x1:e.targetX}});continue}let d;if(d=t.circular&&t.circularPathData?zn(t):Cn(t),!d)continue;const y={fill:u.fill||i,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};v.push({type:"bezier",pathD:d,bezierCache:t.bezier,style:y,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null;for(const n of t){const t=n.x1-n.x0,i=n.y1-n.y0;if(0>=t||0>=i)continue;const r=e?e(n):n.id;if(!r)continue;let s,a,l;"down"===u?(s=n.y0+(n.y1-n.y0)/2,a=n.x1+14,l="start"):(o[0]/2>n.x0+t/2?(s=n.x0-6,l="end"):(s=n.x1+6,l="start"),a=n.y0+i/2),b.push({x:s,y:a,text:r+"",anchor:"down"===u?"middle":l,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:m,sceneEdges:v,labels:b}}};function Bn(t){let e=1/0,n=-1/0;for(const o of t)e>o&&(e=o),o>n&&(n=o);return[e,n]}function In(t,e=-1/0){let n=e;for(const e of t)e>n&&(n=e);return n}const Yn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,o){var i,r;if(0===t.length)return;const s=null!==(i=n.forceStrength)&&void 0!==i?i:.1,a=o[0]/2,l=o[1]/2,c=n.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const h=u>0&&.3>=(t.length>0?d.length/t.length:1);if(h){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const o=Gn(t.id,e,n);if(o.length>0){let e=0,n=0;for(const t of o)e+=t.x,n+=t.y;const i=Hn(t.id),r=i%360*(Math.PI/180),s=10+i%20;t.x=e/o.length+s*Math.cos(r),t.y=n/o.length+s*Math.sin(r)}else{const e=Hn(t.id),n=e%360*(Math.PI/180),o=15+e%30;t.x=a+o*Math.cos(n),t.y=l+o*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const o=t[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(n+.5),i=n*e;o.x=a+t*Math.cos(i),o.y=l+t*Math.sin(i)}}}const f=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=0===n.iterations?0:h?40:f,y=Xn(n.nodeSize,n.nodeSizeRange,t),p=t=>y(t);if(g>0){const n=tt().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),o=et().force("charge",nt().strength(t=>-25*p(t))).force("center",ot(a,l).strength(.8)).force("x",it(a).strength(.15)).force("y",rt(l).strength(.15));if(o.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));n.links(t),o.force("link",n)}h?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let t=0;g>t;++t)o.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=p(e);e.x=Math.max(t,Math.min(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=m.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=m.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,o){var i,r,s,a,l,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=Xn(n.nodeSize,n.nodeSizeRange,t),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Qt,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],m=[],v=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(Rn(e,"nodeSize")),o=d?d(Rn(e,"nodeStyle")):{},a={fill:o.fill||y.get(e.id)||(null===(i=n.themeSemantic)||void 0===i?void 0:i.primary)||"#007bff",stroke:o.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:2,opacity:o.opacity};p.push({type:"circle",cx:e.x,cy:e.y,r:t,style:a,datum:e,id:e.id,label:e.id})}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:b.get(t.source),o="object"==typeof t.target?t.target:b.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const i=h?h(Rn(t,"edgeStyle")):{},r={stroke:i.stroke||(null===(a=n.themeSemantic)||void 0===a?void 0:a.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",strokeWidth:null!==(c=i.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=i.opacity)&&void 0!==u?u:.6};m.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:r,datum:t})}if(!1!==n.showLabels){const e=(x=n.nodeLabel)?"function"==typeof x?x:t=>t[x]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const o=f(Rn(n,"nodeSize"));v.push({x:n.x,y:n.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:m,labels:v}}};function Gn(t,e,n){const o=[];for(const i of e){const e="string"==typeof i.source?i.source:i.source.id,r="string"==typeof i.target?i.target:i.target.id;let s=null;if(e===t?s=r:r===t&&(s=e),s){const t=n.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function Hn(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return Math.abs(e)}function Xn(t,e,n){var o;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const i=e||[5,20],r=[];for(const e of n){const n=null===(o=e.data)||void 0===o?void 0:o[t];"number"==typeof n&&r.push(n)}if(0===r.length)return()=>i[0];const[s,a]=Bn(r);if(s===a)return()=>(i[0]+i[1])/2;const l=v().domain([s,a]).range(i).clamp(!0);return e=>{var n;const o=null===(n=e.data)||void 0===n?void 0:n[t];return null==o||"number"!=typeof o?i[0]:l(o)}}const qn=Qt,Vn={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,o){if(0===t.length)return;const{padAngle:i=.01,groupWidth:r=20,sortGroups:s}=n,a=Math.min(o[0],o[1])/2,l=a-r,c=o[0]/2,u=o[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:t=>{var e;return null!==(e=t[h])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var h;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const g=t.length,y=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),o=f.get(e);if(void 0===n||void 0===o)continue;const i=d(t);y[n][o]=i}const p=at().padAngle(i);s&&p.sortGroups(s);const m=p(y),v=m.groups,b=j().innerRadius(l).outerRadius(a);for(const e of v){const n=t[e.index],o=b.centroid({innerRadius:l,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});n.x=o[0]+c,n.y=o[1]+u,n.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=x.get("string"==typeof t.source?t.source:t.source.id),o=x.get(e);n&&(t.source=n),o&&(t.target=o)}const k=new Map;for(const t of e)k.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const n=t[e.source.index].id,o=t[e.target.index].id,i=k.get(`${n}\0${o}`)||k.get(`${o}\0${n}`);i&&(i.__chordData=e)}},buildScene(t,e,n,o){var i,r,s,a;const{groupWidth:l=20,edgeOpacity:c=.5}=n,u=Math.min(o[0],o[1])/2,d=u-l,h=o[0]/2,f=o[1]/2,g=n.nodeStyle,y=n.edgeStyle,p=n.edgeColorBy||"source",m=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:qn,v=new Map;t.forEach((t,e)=>{v.set(t.id,m[e%m.length])});const b=st().radius(d),x=[],k=[],w=[];for(let e=0;t.length>e;e++){const n=t[e],o=n.__arcData;if(!o)continue;let r;r=g?g(Rn(n,"nodeStyle")).fill||v.get(n.id)||m[e%m.length]:v.get(n.id)||m[e%m.length];const s=g?g(Rn(n,"nodeStyle")):{},a={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:s.opacity};x.push({type:"arc",cx:h,cy:f,innerR:d,outerR:u,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const o=b(e);if(!o)continue;const i=Un(o,h,f);let l=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(y)l=y(Rn(t,"edgeStyle")).fill||l;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===p&&n?l=v.get(n.id)||l:e&&(l=v.get(e.id)||l)}const u=y?y(Rn(t,"edgeStyle")):{},d={fill:l,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};k.push({type:"ribbon",pathD:i,style:d,datum:t})}if(!1!==n.showLabels){const e=(A=n.nodeLabel)?"function"==typeof A?A:t=>t[A]||t.id:null,o=u+12;for(const n of t){const t=n.__arcData;if(!t)continue;const i=e?e(n):n.id;if(!i)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;w.push({x:h+Math.cos(s)*o,y:f+Math.sin(s)*o,text:i+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:x,sceneEdges:k,labels:w}}};function Un(t,e,n){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const i=[];let r=0;for(;o.length>r;){const t=o[r];if("M"===t||"L"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("C"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;3>t&&o.length>r&&!isNaN(Number(o[r]));t++)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("Q"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;2>t&&o.length>r&&!isNaN(Number(o[r]));t++)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("A"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&(i.push(Number(o[r])+e+""),r++),o.length>r&&(i.push(Number(o[r])+n+""),r++);else"Z"===t||"z"===t?(i.push(t),r++):(i.push(o[r]),r++)}return i.join(" ")}const Zn=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Qn(t){const[e,n,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*o>150?"#222":"#fff"}function Kn(t,e,n){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function Jn(t){if(!t)return null;if("function"==typeof t){const e=t;return t=>{var n;return e(null!==(n=t.data)&&void 0!==n?n:t)}}return e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}}function to(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Zn}function eo(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function no(t,e,n,o,i){if("horizontal"===i){const i=(t+n)/2;return`M ${t},${e} C ${i},${e} ${i},${o} ${n},${o}`}if("radial"===i){const i=(t+n)/2;return`M ${t},${e} Q ${i},${e} ${i},${(e+o)/2} T ${n},${o}`}{const i=(e+o)/2;return`M ${t},${e} C ${t},${i} ${n},${i} ${n},${o}`}}const oo={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,o){var i;const r=n.__hierarchyRoot;if(!r)return;const s=n.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),l=n.hierarchySum,c="function"==typeof l?l:"string"==typeof l?t=>Number(t[l])||0:t=>Number(t.value)||0,u=lt(r,a);u.sum(c),u.sort((t,e)=>{var n,o;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(o=t.value)&&void 0!==o?o:0)});const[d,h]=o;switch(s){case"tree":!function(t,e,n,o){const i=e.treeOrientation||"vertical",r=gt();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(t)}(u,n,d,h);break;case"cluster":!function(t,e,n,o){const i=e.treeOrientation||"vertical",r=ft();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(t)}(u,n,d,h);break;case"treemap":!function(t,e,n,o){var i,r;const s=null!==(i=e.padding)&&void 0!==i?i:4,a=null!==(r=e.paddingTop)&&void 0!==r?r:0,l=dt().size([n,o]).tile(ht).padding(s);a>0&&l.paddingTop(a),l(t)}(u,n,d,h);break;case"circlepack":!function(t,e,n,o){var i;const r=null!==(i=e.padding)&&void 0!==i?i:4;ut().size([n,o]).padding(r)(t)}(u,n,d,h);break;case"partition":!function(t,e,n,o){var i;ct().size([n,o]).padding(null!==(i=e.padding)&&void 0!==i?i:1)(t)}(u,n,d,h)}const f=u.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;f.length>e;e++){const o=f[e],r={id:Kn(o,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(i=o.value)&&void 0!==i?i:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?io(r,o,n):"treemap"===s||"partition"===s?ro(r,o):"circlepack"===s&&so(r,o),r.__hierarchyNode=o,t.push(r),g.set(o,r)}if("tree"===s||"cluster"===s)for(const t of f)if(t.parent){const n=g.get(t.parent),o=g.get(t);n&&o&&e.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,o){const i=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,o,i,r){var s,a,l,c,u,d,h,f;const g=[],y=[],p=[],m=n.treeOrientation||"vertical",v="radial"===m,b=o[0]/2,x=o[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const e of t){let t=e.x,o=e.y;v&&(t+=b,o+=x);const r=i(Rn(e,"nodeStyle"));let l=r.fill||eo(n);if(n.colorByDepth&&void 0!==e.depth){const t=to(n);l=t[e.depth%t.length]}const c={fill:l,stroke:r.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:r.opacity};g.push({type:"circle",cx:t,cy:o,r:k,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const A=null!==(l=n.edgeOpacity)&&void 0!==l?l:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let i=e.x,s=e.y,a=o.x,l=o.y;v&&(i+=b,s+=x,a+=b,l+=x);const f=no(i,s,a,l,m),g=r(Rn(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=n.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=g.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:A};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==n.showLabels){const e=Jn(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let o,i,r,s=n.x,a=n.y;if(v&&(s+=b,a+=x),v){const t=s-b,e=a-x,n=Math.sqrt(t*t+e*e);n>0?(o=s+t/n*10,i=a+e/n*10,r=0>t?"end":"start"):(o=s,i=a-12,r="middle")}else"horizontal"===m?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(o=s-k-6,r="end"):(o=s+k+6,r="start"),i=a):(o=s,i=a+k+14,r="middle");p.push({x:o,y:i,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,n,o,i,r);case"treemap":case"partition":return function(t,e,n,o){var i,r,s,a,l;const c=[],u=[];for(const n of t){const t=n.x1-n.x0,s=n.y1-n.y0;if(0>=t||0>=s)continue;const a=o(Rn(n,"nodeStyle"));let l=a.fill||eo(e);if(e.colorByDepth&&void 0!==n.depth){const t=to(e);l=t[n.depth%t.length]}const u={fill:l,stroke:a.stroke||(null===(i=e.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:t,h:s,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Jn(e.nodeLabel),i=e.labelMode||"leaf",r="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,d=c.y1-c.y0;if(0>=t||0>=d)continue;const h=!((null===(s=c.data)||void 0===s?void 0:s.children)&&c.data.children.length>0);if(!r){if("leaf"===i&&!h)continue;if("parent"===i&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>t||(h?16:14)>d)continue;let g=o(Rn(c,"nodeStyle")).fill||eo(e);if(e.colorByDepth&&void 0!==c.depth){const t=to(e);g=t[c.depth%t.length]}const y="string"==typeof g?Qn(g):null!==(l=null===(a=e.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==l?l:"#000";u.push(h?{x:c.x0+t/2,y:c.y0+d/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,d)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,i);case"circlepack":return function(t,e,n,o){var i,r,s,a,l,c,u,d,h,f;const g=[],y=[];for(const n of t){const t=null!==(i=n.__radius)&&void 0!==i?i:5;if(0>=t)continue;const l=o(Rn(n,"nodeStyle"));let c=l.fill||eo(e);if(e.colorByDepth&&void 0!==n.depth){const t=to(e);c=t[n.depth%t.length]}const u={fill:c,stroke:l.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=l.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.7};g.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Jn(e.nodeLabel);for(const i of t){const t=null!==(l=i.__radius)&&void 0!==l?l:5,r=n?n(i):i.id;if(!r)continue;if(15>t)continue;const s=!((null===(c=i.data)||void 0===c?void 0:c.children)&&i.data.children.length>0);let a=o(Rn(i,"nodeStyle")).fill||eo(e);if(e.colorByDepth&&void 0!==i.depth){const t=to(e);a=t[i.depth%t.length]}if(s){const n="string"==typeof a?Qn(a):null!==(d=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";y.push({x:i.x,y:i.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else y.push({x:i.x,y:i.y-t+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(h=e.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(t,n,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function io(t,e,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=e.x,o=e.y;t.x=o*Math.cos(n-Math.PI/2),t.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function ro(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function so(t,e){var n;const o=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-o,t.x1=e.x+o,t.y0=e.y-o,t.y1=e.y+o,t.width=2*o,t.height=2*o,t.__radius=o}function ao(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}const lo={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,o){const i=n.__hierarchyRoot;i&&function(t,e,n,o,i){var r,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),l=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var n;return(null!==(n=t[e])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),c=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),u=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,d=null!==(s=n.orbitEccentricity)&&void 0!==s?s:1,h="number"==typeof u?()=>u:u,f="number"==typeof d?()=>d:d,g=ao(n);g.metaMap.clear(),o.length=0,i.length=0;const y=new Map;function p(t){var e;const n=null!==(e=y.get(t))&&void 0!==e?e:0;return y.set(t,n+1),0===n?t:`${t}__${n}`}const m=e[0]/2,v=e[1]/2,b=Math.min(e[0],e[1])/2*.85,x=p(l(t));o.push({id:x,x:m,y:v,x0:m,x1:m,y0:v,y1:v,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(x,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,r,s,u,d,y){const m=a(e);if(!(null==m?void 0:m.length))return;const v=m.length;let b=0,x=0,k=0;for(;v>x;)x+=c[Math.min(k,c.length-1)],k++,b++;let w=0;for(let v=0;b>v;v++){const x=c[Math.min(v,c.length-1)],k=m.slice(w,w+x);if(!k.length)break;const A=(v+1)/b,S={id:n,depth:d,data:e,parentId:n},M=y?u/h(S)*A:u*A,_=L().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=_(k),O=f(S);for(let e=0;k.length>e;e++){const a=(P[e].startAngle+P[e].endAngle)/2,c=k[e],u=p(l(c)),h=r+M*Math.sin(a),f=s+M*Math.cos(a)*O;o.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:c}),g.metaMap.set(u,{ring:M,angle:a,depth:d,parentId:n,eccentricity:O}),i.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(c,u,h,f,M,d+1,!0)}w+=x}}(t,x,m,v,b,1,!1)}(i,o,n,t,e)},buildScene(t,e,n,o){var i,r,s,a,l,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],y=[],p=[];if(!1!==n.orbitShowRings){const e=ao(n),o=new Map;for(const e of t)o.set(e.id,e);const i=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;i.has(n)||i.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:o}]of i)for(let i=0;r>i;i++){const a=i/r*Math.PI*2,l=(i+1)/r*Math.PI*2;y.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*o,x2:t+n*Math.sin(l),y2:e+n*Math.cos(l)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(Rn(e,"nodeSize")),o=d?d(Rn(e,"nodeStyle")):{},c={fill:o.fill||(null===(i=n.themeSemantic)||void 0===i?void 0:i.primary)||"#6366f1",stroke:o.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:0===(null!==(l=e.depth)&&void 0!==l?l:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:m.get(t.source),n="object"==typeof t.target?t.target:m.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&y.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=f(Rn(n,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(n):e&&null!==(u=null===(c=n.data)||void 0===c?void 0:c[e])&&void 0!==u?u:n.id;p.push({x:n.x,y:n.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,n,o,i)=>!1!==n.orbitAnimated&&(function(t,e){var n,o;const i=ao(e),r=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,s=null!==(o=e.orbitRevolution)&&void 0!==o?o:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const n=null!==(e=t.depth)&&void 0!==e?e:0;return(n%2==0?1:-1)/(n+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,l=r*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=i.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const o=t.angle+a*l*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(o),e.y=n.y+t.ring*Math.cos(o)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},co={sankey:Wn,force:Yn,chord:Vn,tree:oo,cluster:oo,treemap:oo,circlepack:oo,partition:oo,orbit:lo};function uo(t,e,n){if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=de[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}function ho(t){return 0===t.length?()=>"#4e79a7":e=>{var n;let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return null!==(n=t[Math.abs(o)%t.length])&&void 0!==n?n:"#4e79a7"}}function fo(t){const e=t.getSymbol;if(!e)return null;const n=t.config.symbolMap,o=new Map;let i=0;return t=>{const r=e(t)+"",s=null==n?void 0:n[r];if(s)return s;let a=o.get(r);return a||(a=De[i%De.length],i++,o.set(r,a)),a}}function go(t,e,n,o,i,r,s){t.push(e?{type:"symbol",x:o,y:i,size:Math.PI*r*r,symbolType:e(n),style:s,datum:n}:{type:"point",x:o,y:i,r:r,style:s,datum:n})}function yo(t,e){var n;const{columns:o,config:i,resolvePieceStyle:r}=t,s=[],a=Math.min(e.width,e.height)/2-4,l="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,u=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,d=null!=i.sweepAngle&&360>i.sweepAngle,h=Object.values(o),f=h.some(t=>{const e=t.pieceData[0];return e&&("number"==typeof e._pct||"number"==typeof e._pctStart||null!=e._roundedEnds)}),g=d&&!f&&h.length>1&&(null!==(n=i.cornerRadius)&&void 0!==n?n:0)>0;for(let t=0;h.length>t;t++){const e=h[t],n=e.pieceData[0],o="number"==typeof(null==n?void 0:n._pctStart)?n._pctStart:e.pctStart,d=c+o*u,f=c+(o+("number"==typeof(null==n?void 0:n._pct)?n._pct:e.pct))*u,y=r(e.pieceData[0],e.name),p=0===t,m=t===h.length-1,v=Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:l,outerRadius:a,startAngle:d,endAngle:f},i.cornerRadius&&{cornerRadius:i.cornerRadius}),{style:y,datum:(null==n?void 0:n._nonInteractive)?null:e.pieceData,category:e.name});(null==n?void 0:n._roundedEnds)?v.roundedEnds=n._roundedEnds:g&&(v.roundedEnds={start:p,end:m}),(null==n?void 0:n._gradientBand)&&(v._gradientBand=n._gradientBand),s.push(v)}return s}function po(t){var e,n,o;const i=t.length,r=t[0],s=t[i-1];return{n:i,min:r,q1:null!==(e=Q(t,.25))&&void 0!==e?e:r,median:null!==(n=Q(t,.5))&&void 0!==n?n:(r+s)/2,q3:null!==(o=Q(t,.75))&&void 0!==o?o:s,max:s,mean:t.reduce((t,e)=>t+e,0)/i}}const mo={bar:function(t,e){var n,o,i;const{scales:r,columns:s,config:a,getR:l,getStack:c,resolvePieceStyle:u}=t,{r:d,projection:h}=r,f=[],g="vertical"===h,y="horizontal"===h,p=a.normalize,m=[];if(c){const t=new Set;for(const e of Object.values(s))for(const n of e.pieceData){const e=c(n);t.has(e)||(t.add(e),m.push(e))}}else m.push("_default");for(const t of Object.values(s)){const e=new Map;for(const n of t.pieceData){const t=c?c(n):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=l(n),o.pieces.push(n)}let n=0;if(p)for(const t of e.values())n+=Math.abs(t.total);let o=0,i=0;for(const r of m){const s=e.get(r);if(!s)continue;let a=s.total;p&&n>0&&(a/=n);const l=u(s.pieces[0],c?r:t.name),h=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(g){const e=d(0>a?i:o+a),n=0>a?d(i+a)-d(i):d(o)-d(o+a);f.push(It(t.x,e,t.width,Math.abs(n),l,h,r)),0>a?i+=a:o+=a}else if(y){const e=d(0>a?i+a:o),n=0>a?d(i)-d(i+a):d(o+a)-d(o);f.push(It(e,t.x,Math.abs(n),t.width,l,h,r)),0>a?i+=a:o+=a}}}const v="vertical"===h,b=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const t of f){if("rect"!==t.type)continue;const e=null!==(o=null===(n=t.datum)||void 0===n?void 0:n.__aggregateValue)&&void 0!==o?o:0;t.roundedEdge=v?0>e?"bottom":"top":0>e?"left":"right",a.gradientFill&&(t.fillGradient=a.gradientFill)}if(b>0){const t=new Map;for(const e of f){if("rect"!==e.type)continue;const n=(null===(i=e.datum)||void 0===i?void 0:i.category)||"";t.has(n)||t.set(n,[]),t.get(n).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>{var e,n;return(null!==(n=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==n?n:0)>=0}),n=e.filter(t=>{var e,n;return 0>(null!==(n=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==n?n:0)});t.length>0&&(t.reduce(v?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=b),n.length>0&&(n.reduce(v?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=b)}}return f},clusterbar:function(t,e){const{scales:n,columns:o,config:i,getR:r,getGroup:s,resolvePieceStyle:a}=t,{r:l,projection:c}=n,u=[],d="vertical"===c,h=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),h.push(t))}const g=h.length||1;for(const t of Object.values(o)){const e=t.width/g,n=.2*e,o=e-n,i=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";i.has(t)||i.set(t,[]),i.get(t).push(e)}for(let s=0;h.length>s;s++){const c=i.get(h[s])||[];for(const i of c){const c=r(i),f=a(i,h[s]);if(d){const r=t.x+s*e+n/2,a=l(0),d=l(c);u.push(It(r,Math.min(a,d),o,Math.abs(a-d),f,i,h[s]))}else{const r=t.x+s*e+n/2,a=l(0),d=l(c);u.push(It(Math.min(a,d),r,Math.abs(d-a),o,f,i,h[s]))}}}}const y=i.roundedTop&&i.roundedTop>0?Math.max(0,i.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=r(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=d?0>e?"bottom":"top":0>e?"left":"right",i.gradientFill&&(t.fillGradient=i.gradientFill)}return u},point:function(t,e){var n,o;const{scales:i,columns:r,getR:s,multiScales:a,resolvePieceStyle:l}=t,{r:c,projection:u}=i,d=[],h="vertical"===u,f="radial"===u,g=a.length>0,y=fo(t),p=2*Math.PI,m=-Math.PI/2;for(const t of Object.values(r))for(const e of t.pieceData){const i=null!==(n=e.__rIndex)&&void 0!==n?n:0,r=null!==(o=e.__rValue)&&void 0!==o?o:s(e),u=g&&a[i]||c,v=l(e,t.name),b=v.r||5;let x,k;if(f){const e=m+(t.pctStart+t.pct/2)*p,n=u(r);x=Math.cos(e)*n,k=Math.sin(e)*n}else h?(x=t.middle,k=u(r)):(x=u(r),k=t.middle);go(d,y,e,x,k,b,v)}return d},swarm:function(t,e){const{scales:n,columns:o,getR:i,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="vertical"===a,u=fo(t);for(const t of Object.values(o)){const e=t.width/2;for(let n=0;t.pieceData.length>n;n++){const o=t.pieceData[n],a=i(o),d=r(o,t.name),h=d.r||4,f=(7919*n%100/100-.5)*e*.8;go(l,u,o,c?t.middle+f:s(a),c?s(a):t.middle+f,h,d)}}return l},pie:yo,donut:yo,boxplot:function(t,e){var n,o,i,r,s,a;const{scales:l,columns:c,config:u,getR:d,resolveSummaryStyle:h}=t,{r:f,projection:g}=l,y=[],p="vertical"===g,m=!1!==u.showOutliers;for(const e of Object.values(c)){const l=e.pieceData.map(t=>d(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===l.length)continue;const c=l[0],u=l[l.length-1],g=null!==(n=Q(l,.25))&&void 0!==n?n:c,v=null!==(o=Q(l,.5))&&void 0!==o?o:(c+u)/2,b=null!==(i=Q(l,.75))&&void 0!==i?i:u,x=b-g,k=g-1.5*x,w=b+1.5*x,A=null!==(r=l.find(t=>t>=k))&&void 0!==r?r:c,S=null!==(s=[...l].reverse().find(t=>w>=t))&&void 0!==s?s:u,M=h(e.pieceData[0],e.name),_=[];if(m)for(const t of e.pieceData){const n=d(t);if(k>n||n>w){const o=p?e.middle:f(n),i=p?f(n):e.middle;_.push({px:o,py:i,value:n,datum:t})}}if(y.push({type:"boxplot",x:p?e.middle:0,y:p?0:e.middle,projection:p?"vertical":"horizontal",columnWidth:.6*e.width,minPos:f(A),q1Pos:f(g),medianPos:f(v),q3Pos:f(b),maxPos:f(S),stats:{n:l.length,min:A,q1:g,median:v,q3:b,max:S,mean:l.reduce((t,e)=>t+e,0)/l.length},style:M,datum:e.pieceData,category:e.name,outliers:_}),m)for(const e of _)y.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:M.fill||(null===(a=t.config.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",opacity:.6},datum:e.datum})}return y},violin:function(t,e){var n,o,i;const{scales:r,columns:s,config:a,getR:l,resolveSummaryStyle:c}=t,{r:u,projection:d}=r,h=[],f="vertical"===d,g=a.bins||20,y=!1!==a.showIQR;for(const t of Object.values(s)){const e=t.pieceData.map(t=>l(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const r=e[0],s=e[e.length-1],a=(s-r)/g||1,d=Array(g).fill(0);for(const t of e)d[Math.min(Math.floor((t-r)/a),g-1)]++;const p=In(d,1),m=t.width/2*.9;let v="";if(f){v=`M ${t.middle} ${u(r)}`;for(let e=0;g>e;e++){const n=u(r+(e+.5)*a);v+=` L ${t.middle+d[e]/p*m} ${n}`}v+=` L ${t.middle} ${u(s)}`;for(let e=g-1;e>=0;e--){const n=u(r+(e+.5)*a);v+=` L ${t.middle-d[e]/p*m} ${n}`}v+=" Z"}else{v=`M ${u(r)} ${t.middle}`;for(let e=0;g>e;e++)v+=` L ${u(r+(e+.5)*a)} ${t.middle-d[e]/p*m}`;v+=` L ${u(s)} ${t.middle}`;for(let e=g-1;e>=0;e--)v+=` L ${u(r+(e+.5)*a)} ${t.middle+d[e]/p*m}`;v+=" Z"}const b=c(t.pieceData[0],t.name);let x;if(y&&e.length>=4){const a=null!==(n=Q(e,.25))&&void 0!==n?n:r,l=null!==(o=Q(e,.5))&&void 0!==o?o:(r+s)/2,c=null!==(i=Q(e,.75))&&void 0!==i?i:s;x={q1Pos:u(a),medianPos:u(l),q3Pos:u(c),centerPos:t.middle,isVertical:f}}const k=f?{x:t.x,y:Math.min(u(s),u(r)),width:t.width,height:Math.abs(u(s)-u(r))}:{x:Math.min(u(r),u(s)),y:t.x,width:Math.abs(u(s)-u(r)),height:t.width};h.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:k,iqrLine:x,stats:po(e),style:b,datum:t.pieceData,category:t.name})}return h},histogram:function(t,e){var n;const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:a}=t,{r:l}=o,c=[],u=r.bins||25,d=r.normalize,h=null===(n=l.domain)||void 0===n?void 0:n.call(l),f=h?+h[0]:void 0,g=h?+h[1]:void 0;for(const t of Object.values(i)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const[n,o]=Bn(e),i=null!=f&&isFinite(f)?f:n,r=null!=g&&isFinite(g)?g:o,h=(r-i)/u||1,y=Array(u).fill(0);for(const t of e)i>t||t>r||y[Math.min(Math.floor((t-i)/h),u-1)]++;const p=e.length,m=In(y,1),v=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===y[e])continue;const n=(d?y[e]/p:y[e]/m)*t.width*.9,o=l(i+e*h),r=l(i+(e+1)*h);c.push(It(Math.min(o,r),t.x+t.width-n,Math.abs(r-o),n,v,{bin:e,count:y[e],range:[i+e*h,i+(e+1)*h],category:t.name},t.name))}}return c},ridgeline:function(t,e){var n;const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:a}=t,{r:l,projection:c}=o,u=[],d=r.bins||20,h="horizontal"===c,f=r.amplitude||1.5;for(const t of Object.values(i)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],i=e[e.length-1],r=(i-o)/d||1,c=Array(d).fill(0);for(const t of e)o>t||t>i||c[Math.min(Math.floor((t-o)/r),d-1)]++;const g=In(c,1),y=a(t.pieceData[0],t.name),p=t.width*f;let m="";if(h){const e=t.x+t.width;m=`M ${l(o)} ${e}`;for(let t=0;d>t;t++)m+=` L ${l(o+(t+.5)*r)} ${e-c[t]/g*p}`;m+=` L ${l(i)} ${e} Z`}else{const e=t.x;m=`M ${e} ${l(o)}`;for(let t=0;d>t;t++){const n=l(o+(t+.5)*r);m+=` L ${e+c[t]/g*p} ${n}`}m+=` L ${e} ${l(i)} Z`}const v=h?{x:Math.min(l(o),l(i)),y:t.x,width:Math.abs(l(i)-l(o)),height:t.width}:{x:t.x,y:Math.min(l(i),l(o)),width:t.width,height:Math.abs(l(i)-l(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:po(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(n=y.fillOpacity)&&void 0!==n?n:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:n,columns:o,getRawRange:i,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const n=i(e);if(!n)continue;const[o,a]=n,u=r(e,t.name);if(c){const n=s(Math.min(o,a)),i=s(Math.max(o,a));l.push(It(n,t.x,i-n,t.width,u,e,t.name))}else{const n=s(Math.max(o,a)),i=s(Math.min(o,a));l.push(It(t.x,n,t.width,i-n,u,e,t.name))}}return l},funnel:function(t,e){var n,o,i,r,s,a,l,c;const{columns:u,getR:d,getStack:h,resolvePieceStyle:f}=t,g=[],y=e.width/2,p=!1!==t.config.showLabels,m=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===m.length)return g;const b=[],x=new Set;for(const t of m)for(const e of t.pieceData){const t=h?h(e):"_default";x.has(t)||(x.add(t),b.push(t))}const k=b.length>1&&"_default"!==b[0],w=[];let A=0;for(const t of m){const e=new Map;let n=0;for(const o of t.pieceData){const t=h?h(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t),r=d(o);i.total+=r,i.pieces.push(o),n+=r}w.push({col:t,groups:e,stepTotal:n}),k||n>A&&(A=n)}if(k)for(const t of w){let e=0,n=0;for(let o=0;b.length>o;o++){const i=t.groups.get(b[o]);i&&(o%2==0?e+=i.total:n+=i.total)}const o=Math.max(e,n);o>A&&(A=o)}if(0===A)return g;const S=new Map;for(const t of b){const e=w[0].groups.get(t);S.set(t,null!==(n=null==e?void 0:e.total)&&void 0!==n?n:0)}const M=w[0].stepTotal,_=k?.95*y:.9*e.width,P=v().domain([0,A]).range([0,_]),O=null!==(o=t.config.connectorOpacity)&&void 0!==o?o:.3;let T=new Map;for(let e=0;w.length>e;e++){const n=w[e],o=n.col,u=0===e,d=o.width,h=.55*d,m=o.x+(d-h)/2,v=new Map;if(k){let t=0;for(const e of b){const o=n.groups.get(e);o&&(t+=P(o.total))}let e=y,i=y;for(let r=0;b.length>r;r++){const a=b[r],l=n.groups.get(a);if(!l)continue;const c=P(l.total),d=r%2==0,x=d?e:i-c;d?e+=c:i-=c;const k=f(l.pieces[0],a),w=null!==(s=S.get(a))&&void 0!==s?s:l.total,A=w>0?l.total/w*100:0,M=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:A,__funnelStep:o.name,__funnelIsFirstStep:u,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:a});p&&(0===r&&(M.__funnelStepLabel=o.name,M.__funnelStepLabelX=y,M.__funnelStepLabelY=m,M.__funnelRowWidth=t),M.__funnelValueLabelX=x+c/2,M.__funnelValueLabelY=m,M.__funnelBarW=c),g.push(It(x,m,c,h,k,M,a)),v.set(a,{x:x,y:m,w:c,h:h})}}else{const t=n.stepTotal,e=P(t),s=y-e/2,a=b[0],l="_default"!==a,c=null!==(r=null===(i=n.groups.get(a))||void 0===i?void 0:i.pieces[0])&&void 0!==r?r:o.pieceData[0],d=l?a:o.name,x=f(c,d),k=M>0?t/M*100:0,w=Object.assign(Object.assign({},c),{__funnelValue:t,__funnelPercent:k,__funnelStep:o.name,__funnelIsFirstStep:u,category:l?a:o.name});p&&(w.__funnelStepLabel=o.name,w.__funnelStepLabelX=y,w.__funnelStepLabelY=m,w.__funnelRowWidth=e,w.__funnelValueLabelX=y,w.__funnelValueLabelY=m,w.__funnelBarW=e),g.push(It(s,m,e,h,x,w,d)),v.set(a,{x:s,y:m,w:e,h:h})}if(e>0&&T.size>0){const e=k?b:[b[0]];for(const i of e){const e=T.get(i),r=v.get(i);if(!e||!r)continue;const s=(()=>{const t=n.groups.get(i);return f(t?t.pieces[0]:o.pieceData[0],"_default"===i?o.name:i)})(),u={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:s.fill||(null===(a=t.config.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",opacity:O},datum:null!==(c=null===(l=n.groups.get(i))||void 0===l?void 0:l.pieces[0])&&void 0!==c?c:o.pieceData[0],category:"_default"===i?o.name:i};g.push(u)}}T=v}return g},"bar-funnel":function(t,e){var n,o,i,r;const{columns:s,getR:a,getStack:l,resolvePieceStyle:c,scales:u}=t,d=[],h=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===h.length)return d;const f=[],g=new Set;for(const t of h)for(const e of t.pieceData){const t=l?l(e):"_default";g.has(t)||(g.add(t),f.push(t))}const y=f.length>1&&"_default"!==f[0],p=[];for(const t of h){const e=new Map;let n=0;for(const o of t.pieceData){const t=l?l(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t),r=a(o);i.total+=r,i.pieces.push(o),n+=r}p.push({col:t,groups:e,stepTotal:n})}const m=new Map;for(const t of f){const e=null===(n=p[0])||void 0===n?void 0:n.groups.get(t);m.set(t,null!==(o=null==e?void 0:e.total)&&void 0!==o?o:0)}const v=u.r,b=y?f.length:1,x=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],n=e.col,o=0===t,s=t>0?p[t-1]:null,a=n.width/b,l=a*x,u=a-l;for(let t=0;f.length>t;t++){const h=f[t],g=e.groups.get(h);if(!g)continue;const p=g.total,b=null!==(i=m.get(h))&&void 0!==i?i:p,x=b>0?p/b*100:0,k=null==s?void 0:s.groups.get(h),w=null!==(r=null==k?void 0:k.total)&&void 0!==r?r:p,A=o?0:Math.max(0,w-p),S=n.x+t*a+l/2,M=v(p),_=v(0)-M,P=c(g.pieces[0],y?h:n.name),O=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:x,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===h?void 0:h,category:y?h:n.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:v(p+A)});if(d.push(It(S,M,u,_,P,O,y?h:n.name)),A>0){const t=v(p+A),e=M-t,o=Object.assign({},P),i=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:b>0?A/b*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:y?h:n.name});d.push(It(S,t,u,e,o,i,y?h:n.name))}}}return d},swimlane:function(t,e){var n;const{scales:o,columns:i,getR:r,getStack:s,resolvePieceStyle:a}=t,{r:l,projection:c}=o,u=[],d="horizontal"===c,h=t.config.gradientFill,f=d?"left":"bottom",g=t.config.trackFill;if(g){const t="string"==typeof g?g:g.color,e="string"==typeof g?1:null!==(n=g.opacity)&&void 0!==n?n:1,[o,r]=l.range(),s=Math.min(o,r),a=Math.abs(r-o);for(const n of Object.values(i)){const o={fill:t,opacity:e},i=d?It(s,n.x,a,n.width,o,null,"__track__"):It(n.x,s,n.width,a,o,null,"__track__");u.push(i)}}const y=t.config.roundedTop&&t.config.roundedTop>0?Math.max(0,t.config.roundedTop):0;for(const t of Object.values(i)){let e=0;const n=u.length;for(const n of t.pieceData){const o=Math.abs(r(n));if(0===o)continue;const i=s?s(n):t.name,c=a(n,i);let g;if(d){const r=l(e),s=l(e+o);g=It(r,t.x,s-r,t.width,c,n,i)}else{const r=l(e+o),s=l(e);g=It(t.x,r,t.width,s-r,c,n,i)}h&&(g.fillGradient=h,g.roundedEdge=f),u.push(g),e+=o}if(y>0&&u.length>n){const t=u.slice(n),e=t[0],o=t[t.length-1];1===t.length?e.cornerRadii={tl:y,tr:y,br:y,bl:y}:d?(e.cornerRadii={tl:y,bl:y},o.cornerRadii={tr:y,br:y}):(e.cornerRadii={bl:y,br:y},o.cornerRadii={tl:y,tr:y})}}return u}};class vo{constructor(t){this.rExtent=new Dt,this.rExtents=[],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._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.version=0,this._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new zt(t.windowSize),this.getO=qt(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>Ht(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new Dt)):(this.getR=Ht(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=qt(t.stackBy),this.getGroup=qt(t.groupBy),this.getColor=qt(t.colorAccessor),this.getSymbol=qt(t.symbolAccessor),this.getConnector=qt(t.connectorAccessor),this.getDataId=qt(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new zt(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of t.inserts){const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.valueAccessor||this.config.rAccessor;if(!e)return null;const n="function"==typeof e?e(t):t[e];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(t){const{config:e,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const o=n.toArray(),i=e.projection||"vertical",r=e.oExtent||this.resolveCategories(o),s=this.computeValueDomain(o,r),a="horizontal"===i,l="radial"===i,c=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===i?t.width:t.height):.1));let u,d;if(l){u=k().domain(r).range([0,1]).padding(0);const n=Math.min(t.width,t.height)/2,o=e.innerRadius||0;d=v().domain(s).range([o,n])}else a?(u=k().domain(r).range([0,t.height]).padding(c),d=v().domain(s).range([0,t.width])):(u=k().domain(r).range([0,t.width]).padding(c),d=v().domain(s).range([t.height,0]));this.scales={o:u,r:d,projection:i},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((o,i)=>{var r;const s=this.rExtents[i];s.dirty&&s.recalculate(n,o);let[l,c]=s.extent;l===1/0&&(l=0,c=1);const u=null!==(r=e.extentPadding)&&void 0!==r?r:.05,d=c-l,h=d>0?d*u:1;return l-=h,c+=h,l>0&&(l=0),a?v().domain([l,c]).range([0,t.width]):v().domain([l,c]).range([t.height,0])}):[];let h=o;this.rAccessors.length>1&&(h=o.flatMap(t=>this.rAccessors.map((e,n)=>Object.assign(Object.assign({},t),{__rIndex:n,__rValue:e(t),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(h,r,u,i,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(h,t),this.rebuildPointQuadtree(),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.startTransition(),this.version++}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,n=Array.isArray(e)?e[t]:e;return"string"==typeof n?n:"value"+t}resolveCategories(t){const e=this.config.oSort,n="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let i=null;if(n){i=new Set;for(const e of t)i.add(this.getO(e))}const r=i?Array.from(this.categories).filter(t=>i.has(t)):Array.from(this.categories);if(n&&void 0===o){const t=Math.max(50,3*i.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;i.has(t)||(this.categories.delete(t),e--)}}return r}if(!1===o)return r;if("function"==typeof o)return r.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return r.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){var n,o,i,r,s;const a=this.config.chartType,l=null!==(n=this.config.extentPadding)&&void 0!==n?n:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let c=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)c=0,u=1;else if("bar"===a&&this.getStack){const e=new Map,n=new Map;for(const o of t){const t=this.getO(o),i=this.getR(o);0>i?n.set(t,(n.get(t)||0)+i):e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>u&&(u=t);for(const t of n.values())c>t&&(c=t)}else if("bar"===a){const e=new Map;for(const n of t){const t=this.getO(n),o=this.getR(n);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t),c>t&&(c=t)}else if("swimlane"===a){const e=new Map;for(const n of t){const t=this.getO(n),o=Math.abs(this.getR(n));e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>u&&(u=t),c>t&&(c=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(c=t),e!==-1/0&&(u=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(c=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const d="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(d&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[0])&&null==(null===(i=this.config.rExtent)||void 0===i?void 0:i[1])&&(c>0&&(c=0),0>u&&(u=0)),"bar-funnel"!==a&&"exact"!==this.config.axisExtent){const t=u-c,e=t>0?t*l:1;null!=(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])||d&&!this.config.baselinePadding&&0===c||(c-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||d&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=e)}return[c,u]}buildColumns(t,e,n,o,i){var r;const s={},a=new Map;for(const e of t){const t=this.getO(e);a.has(t)||a.set(t,[]),a.get(t).push(e)}let l=0;if("radial"===o)for(const e of t)l+=Math.abs(this.getR(e));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let t=0;for(const n of e){const e=a.get(n)||[];let o;o="string"==typeof c?e.reduce((t,e)=>t+(Number(e[c])||0),0):c(e),u.set(n,o),t+=o}const r=("horizontal"===o?i.height:i.width)-n.padding()*n.step()*e.length;if(t>0)for(const[e,n]of u)u.set(e,n/t*r)}let d=0,h=0;for(const t of e){const e=a.get(t)||[],o=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),i=l>0?o/l:0;let c,f;u?(c=h,f=u.get(t)||n.bandwidth(),h+=f+n.padding()*n.step()):(c=null!==(r=n(t))&&void 0!==r?r:0,f=n.bandwidth()),s[t]={name:t,x:c,y:0,width:f,middle:c+f/2,padding:n.padding()*n.step(),pieceData:e,pct:i,pctStart:d},d+=i}return s}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:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){var n,o,i;if(!this.scales)return[];if(this.config.customLayout){const r=this.buildLayoutContext(t,e);let s;try{s=this.config.customLayout(r)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t),this.customLayoutOverlays=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,[]}this.customLayoutOverlays=null!==(n=s.overlays)&&void 0!==n?n:null;const a=null!==(o=s.nodes)&&void 0!==o?o:[];if(this._customRestyle=s.restyle,this.hasCustomRestyle=!!s.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of a)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(a,null!==(i=this.config.layoutSelection)&&void 0!==i?i:null)}return We({label:"ordinal customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}this.customLayoutOverlays=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const r=this.getSceneContext(),s=mo[this.config.chartType];let a=s?s(r,e):[];if(this.getConnector&&this.scales){const t=function(t,e){var n,o;const{scales:i,config:r,getConnector:s,getO:a}=t;if(!s||!i)return[];const l=[],{projection:c}=i,u=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const n=s(e);if(!n)continue;let o,i;"point"===t.type?(o=t.x,i=t.y):(o=t.x+t.w/2,i=t.y+("vertical"===c?0:t.h/2)),u.has(n)||u.set(n,[]),u.get(n).push({x:o,y:i,datum:e,category:a(e)})}const d=i.o.domain(),h=r.connectorStyle;for(const[e,i]of u)if(i.length>=2){i.sort((t,e)=>d.indexOf(t.category)-d.indexOf(e.category));for(let r=0;i.length-1>r;r++){const s=i[r],a=i[r+1],c="function"==typeof h?h(s.datum):h||{stroke:(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.border)||(null===(o=t.config.themeSemantic)||void 0===o?void 0:o.secondary)||"#999",strokeWidth:1,opacity:.5};l.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:c,datum:s.datum,group:e})}}return l}(r,a);a=[...t,...a]}return a}buildLayoutContext(t,e){var n,o,i,r;const s=this.config,a=null!==(n=s.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},l=uo(s.colorScheme,s.themeCategorical,fe),c=this.scales;return{data:t,scales:{o:c.o,r:c.r,projection:c.projection},dimensions:{width:e.width,height:e.height,margin:a,plot:"radial"===c.projection?{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height}:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:null!==(o=s.themeSemantic)&&void 0!==o?o:{},categorical:[...l]},resolveColor:ho(l),config:null!==(i=s.layoutConfig)&&void 0!==i?i:{},selection:null!==(r=s.layoutSelection)&&void 0!==r?r:null}}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const n=this.config.pieceStyle(t,e);return n&&!n.fill&&e?Object.assign(Object.assign({},n),{fill:this.getColorFromScheme(e)}):n}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||fe,o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,o),o}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?me(n,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=new Map;for(let n=0;t.length>n;n++)e.set(t[n],n);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=this.config.categoryAccessor||this.config.oAccessor,n="function"==typeof e,o=n?null:e||"category",i=new Map;for(let r=0;t.length>r;r++){const s=t[r],a=n?e(s):s[o];let l=i.get(a);l||(l=[],i.set(a,l)),l.push(r)}return this._categoryIndexCache={version:this._dataVersion,map:i},i}rebuildPointQuadtree(){let t=0,e=0;for(const n of this.scene)"point"===n.type&&(t++,n.r>e&&(e=n.r));if(this._maxPointRadius=e,vo.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const n=Array(t);let o=0;for(const t of this.scene)"point"===t.type&&(n[o++]=t);this._pointQuadtree=w().x(t=>t.x).y(t=>t.y).addAll(n)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){var n,o;if(!this.config.decay)return;const i=e.length;if(1>=i)return;const r=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=r.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,i),a=null!==(o=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var n,o,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,c=this.getDatumIndexMap(e);let u=null;for(const n of t){if("connector"===n.type||"violin"===n.type||"boxplot"===n.type)continue;if("wedge"===n.type){const t=n.category;if(!t)continue;u||(u=this.getCategoryIndexMap(e));const o=u.get(t);if(!o)continue;let i=0;for(let t=0;o.length>t;t++){const e=this.timestampBuffer.get(o[t]);if(null==e)continue;const n=r-e;if(s>n){const t=1-n/s;t>i&&(i=t)}}i>0&&(n._pulseIntensity=i,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const o=this.timestampBuffer.get(t);if(null==o)continue;const i=r-o;s>i&&(n._pulseIntensity=1-i/s,n._pulseColor=a,n._pulseGlowRadius=l)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,o=this.timestampBuffer.peek();return null!=o&&n>e-o}synthesizeIntroPositions(){var t,e,n,o,i;this.prevPositionMap.clear();const r=new Map,s=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.r(0))&&void 0!==e?e:0,a="horizontal"!==(null===(n=this.scales)||void 0===n?void 0:n.projection);let l;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],n=this.getNodeKey(e,r);n&&("rect"===e.type?this.prevPositionMap.set(n,a?{x:e.x,y:s,w:e.w,h:0,opacity:null!==(o=e.style.opacity)&&void 0!==o?o:1}:{x:s,y:e.y,w:0,h:e.h,opacity:null!==(i=e.style.opacity)&&void 0!==i?i:1}):"point"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,r:0,opacity:0}):"wedge"===e.type&&(void 0===l&&(l=e.startAngle),this.prevPositionMap.set(n,{x:e.cx,y:e.cy,startAngle:l,endAngle:l,innerRadius:e.innerRadius,outerRadius:e.outerRadius,opacity:0})))}}getNodeKey(t,e){var n,o,i;if("point"===t.type){const n=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(n)||0;return e.set(n,o+1),`${n}:${o}`}return"rect"===t.type?`r:${t.group||""}:${null!==(o=null===(n=t.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:""}`:"wedge"===t.type?"w:"+(null!==(i=t.category)&&void 0!==i?i:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let n=0;this.scene.length>n;n++){const o=this.scene[n],i=this.getNodeKey(o,e);i&&("point"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(i,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:null!==(t=o.style.opacity)&&void 0!==t?t:1}))}}startTransition(){var t,e,n,o,i,r,s,a,l,c,u,d,h,f,g,y,p,m,v,b,x;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let w=!1;const A=new Set,S=new Map;for(let t=0;this.scene.length>t;t++){const c=this.scene[t],u=this.getNodeKey(c,S);if(!u)continue;c._transitionKey=u;const d=this.prevPositionMap.get(u);if("point"===c.type)d?(A.add(u),c._targetOpacity=null!==(e=c.style.opacity)&&void 0!==e?e:1,(d.x!==c.x||d.y!==c.y||void 0!==d.r&&d.r!==c.r)&&(c._targetX=c.x,c._targetY=c.y,c._targetR=c.r,c.x=d.x,c.y=d.y,void 0!==d.r&&(c.r=d.r),w=!0)):(c._targetOpacity=null!==(n=c.style.opacity)&&void 0!==n?n:1,c._targetR=c.r,c.r=0,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("rect"===c.type)d?(A.add(u),c._targetOpacity=null!==(o=c.style.opacity)&&void 0!==o?o:1,d.x===c.x&&d.y===c.y&&d.w===c.w&&d.h===c.h||(c._targetX=c.x,c._targetY=c.y,c._targetW=c.w,c._targetH=c.h,c.x=d.x,c.y=d.y,c.w=null!==(i=d.w)&&void 0!==i?i:c.w,c.h=null!==(r=d.h)&&void 0!==r?r:c.h,w=!0)):(c._targetOpacity=null!==(s=c.style.opacity)&&void 0!==s?s:1,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("wedge"===c.type)if(d)A.add(u),c._targetOpacity=null!==(a=c.style.opacity)&&void 0!==a?a:1,d.startAngle===c.startAngle&&d.endAngle===c.endAngle||(c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle,c.startAngle=d.startAngle,c.endAngle=d.endAngle,w=!0);else{c._targetOpacity=null!==(l=c.style.opacity)&&void 0!==l?l:1,c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle;const t=c.startAngle;c.startAngle=t,c.endAngle=t,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),this.prevPositionMap.set(u,{x:c.cx,y:c.cy,startAngle:t,endAngle:t,innerRadius:c.innerRadius,outerRadius:c.outerRadius,opacity:0}),w=!0}}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)if(!A.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(c=e.r)&&void 0!==c?c:3,style:{opacity:null!==(u=e.opacity)&&void 0!==u?u:1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(d=e.w)&&void 0!==d?d:0,h:null!==(h=e.h)&&void 0!==h?h:0,style:{opacity:null!==(f=e.opacity)&&void 0!==f?f:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const n=((null!==(g=e.startAngle)&&void 0!==g?g:0)+(null!==(y=e.endAngle)&&void 0!==y?y:0))/2,o={type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(p=e.innerRadius)&&void 0!==p?p:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(v=e.startAngle)&&void 0!==v?v:0,endAngle:null!==(b=e.endAngle)&&void 0!==b?b:0,style:{opacity:null!==(x=e.opacity)&&void 0!==x?x:1},datum:null,category:t.slice(2),_targetStartAngle:n,_targetEndAngle:n,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(o)}w=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),w&&(this.activeTransition={startTime:Ae(),duration:k})}advanceTransition(t){var e,n,o,i;if(!this.activeTransition)return!1;const r=ke(t,this.activeTransition),s=xe(r,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e),i=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;t.style.opacity=we(i,t._targetOpacity,s)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=we(o.x,t._targetX,s),t.y=we(o.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==o?void 0:o.r)&&(t.r=we(o.r,t._targetR,s))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=this.prevPositionMap.get(e),i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=we(i,t._targetOpacity,s)}if(void 0===t._targetX)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=we(n.x,t._targetX,s),t.y=we(n.y,t._targetY,s),void 0!==n.w&&(t.w=we(n.w,t._targetW,s),t.h=we(n.h,t._targetH,s))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const n=this.prevPositionMap.get(e),o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style=Object.assign(Object.assign({},t.style),{opacity:we(o,t._targetOpacity,s)})}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const n=this.prevPositionMap.get(e);n&&void 0!==n.startAngle&&(t.startAngle=we(n.startAngle,t._targetStartAngle,s),t.endAngle=we(n.endAngle,t._targetEndAngle,s))}}}if(r>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX&&void 0===t._targetR)continue;void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY),void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0);if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getDataId,o=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{o(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const i=this.buffer.remove(o);if(0===i.length)return i;for(const t of i)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),i}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),o=this.getDataId,i=new Set;this.buffer.forEach((t,e)=>{n.has(o(t))&&i.add(e)});const r=this.buffer.update(t=>n.has(o(t)),e);if(0===r.length)return r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),i.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,this.lastIngestTime="undefined"!=typeof performance?performance.now():Date.now(),r}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._pointQuadtree=null,this._maxPointRadius=0,this._colorSchemeMap=null,this._colorSchemeIndex=0,this._dataVersion++,this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}setLayoutSelection(t){this.config.layoutSelection=t}applyCustomRestyle(t,e){var n,o;const i=this._customRestyle;if(i)for(const r of t){const t=null!==(o=null!==(n=this._baseStyles.get(r))&&void 0!==n?n:r.style)&&void 0!==o?o:{},s=i(r,e);r.style=s?Object.assign(Object.assign({},t),s):t}}restyleScene(t){this._customRestyle&&this.applyCustomRestyle(this.scene,t)}updateConfig(t){const e=Object.assign({},this.config);if(("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!Gt(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!Gt(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!Gt(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(Gt(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=qt(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const n=t.valueAccessor||t.rAccessor,o=e.valueAccessor||e.rAccessor,i=Array.isArray(n)?n:[n],r=Array.isArray(o)?o:[o];if(i.length!==r.length||i.some((t,e)=>!Gt(t,r[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>Ht(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new Dt)):(this.getR=Ht(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!Gt(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?qt(this.config.stackBy):void 0),"groupBy"in t&&!Gt(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?qt(this.config.groupBy):void 0),"colorAccessor"in t&&!Gt(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?qt(this.config.colorAccessor):void 0),"symbolAccessor"in t&&!Gt(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?qt(this.config.symbolAccessor):void 0),"connectorAccessor"in t&&!Gt(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?qt(this.config.connectorAccessor):void 0)}}vo.QUADTREE_THRESHOLD=500;const bo={mercator:Mt,equalEarth:xt,albersUsa:St,orthographic:At,naturalEarth:wt,equirectangular:kt};function xo(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function ko(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function wo(t,e,n){return t?Object.assign(Object.assign({},n),"function"==typeof t?t(e):t):Object.assign({},n)}function Ao(t,e){if(2>t.length)return[t];const n=.4*e,o=[];let i=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>n?(2>i.length||o.push(i),i=[r]):i.push(r)}return 2>i.length||o.push(i),o}function So(t,e,n=24){const o=e[0]-t[0],i=e[1]-t[1],r=Math.sqrt(o*o+i*i);if(0===r)return[t,e];const s=-i/r,a=o/r,l=Math.min(.3*r,80),c=(t[0]+e[0])/2+s*l,u=(t[1]+e[1])/2+a*l,d=[];for(let o=0;n>=o;o++){const i=o/n,r=1-i;d.push([r*r*t[0]+2*r*i*c+i*i*e[0],r*r*t[1]+2*r*i*u+i*i*e[1]])}return d}function Mo(t,e){if(2>t.length)return t;const n=e/2+1,o=[];for(let e=0;t.length>e;e++){const i=t[e];let r,s;0===e?(r=t[1][0]-i[0],s=t[1][1]-i[1]):e===t.length-1?(r=i[0]-t[e-1][0],s=i[1]-t[e-1][1]):(r=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(r*r+s*s)||1;o.push([i[0]+s/a*n,i[1]+-r/a*n])}return o}function _o(t,e,n,o,i){const r=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(r*r+s*s);if(0===a)return[t,e];const l=s/a,c=-r/a,u=i/2+1;return[[t[0]+l*u,t[1]+c*u],[e[0]+l*u,e[1]+c*u]]}class Po{constructor(t){this.scene=[],this.scales=null,this.version=0,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.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t.slice()}initStreaming(t=500){this.pointBuffer=new zt(t),this.timestampBuffer=new zt(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const n of t)this.pointBuffer.push(n),this.timestampBuffer.push(e);this.lastIngestTime=e}pushLine(t){null!=t&&"object"==typeof t&&(this.lineData.push(t),this.version++)}pushManyLines(t){if(!Array.isArray(t)||0===t.length)return;const e=t.filter(t=>null!=t&&"object"==typeof t);if(0!==e.length){for(const t of e)this.lineData.push(t);this.version++}}removeLine(t){const{lineIdAccessor:e}=this.config;if(!e)throw Error("removeLine() requires lineIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]),i=[];return this.lineData=this.lineData.filter(t=>!o.has(n(t)+"")||(i.push(t),!1)),i.length>0&&this.version++,i}getLines(){return this.lineData.slice()}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(n(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),n=new Set;this.pointBuffer.forEach((e,o)=>{t(e)&&n.add(o)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)n.has(t)||this.timestampBuffer.push(e[t])}const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(n(e)+"")||(t.push(e),!1)),t.length>0&&this.version++,t}}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.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return xt();if("string"==typeof t){const e=bo[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),xt())}if("object"==typeof t&&"type"in t){const e=bo[t.type],n=e?e():xt();return t.rotate&&"rotate"in n&&n.rotate(t.rotate),t.center&&"center"in n&&n.center(t.center),n}return t}(e.projection),this.geoPath=pt(this.projection),this.fitProjection(t),this.geoPath=pt(this.projection);const n=this.projection;this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null};const o=this.scene;if(this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,n=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:n}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(t){var e,n,o,i,r;const s=this.projection,a=this.config,l=[...this.areas],c=xo(a.xAccessor,"lon"),u=xo(a.yAccessor,"lat"),d=this.getPoints();if(d.length>0){const t=d.map(t=>[c(t),u(t)]);l.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const h=ko(a.lineDataAccessor);for(const t of this.lineData){const e=h(t);if(e&&e.length>0){const t=e.map(t=>[c(t),u(t)]);l.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==l.length){if(a.projectionExtent){const[[e,n],[o,i]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,n],[o,n],[o,i],[e,i],[e,n]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(n=a.fitPadding)&&void 0!==n?n:0,o=Math.min(t.width,t.height);s.scale(o/2-o*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(o=a.fitPadding)&&void 0!==o?o:0,n=t.width*e,i=t.height*e;s.fitExtent([[n,i],[t.width-n,t.height-i]],{type:"FeatureCollection",features:l})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(r=null===(i=s.rotate)||void 0===i?void 0:i.call(s))&&void 0!==r?r:[0,0,0]}}applyZoomTransform(t,e){const n=this.projection;n&&(n.scale(this.baseScale*t.k),n.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=pt(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const n=this.projection;n&&(n.scale(this.baseScale*t),n.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=pt(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const n=this.projection;n&&n.rotate&&(n.rotate(t),this.geoPath=pt(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,n;return null!==(n=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==n?n: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,e=0;for(const n of this.scene)"point"===n.type&&(e++,n.r>t&&(t=n.r));if(this._maxPointRadius=t,Po.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const n=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(n[o++]=t);this._quadtree=w().x(t=>t.x).y(t=>t.y).addAll(n)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){var e,n,o;const i=[],{config:r}=this,s=this.projection,a=this.geoPath,l=xo(r.xAccessor,"lon"),c=xo(r.yAccessor,"lat"),u=function(t){var e,n;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.surface)||"#e0e0e0",stroke:(null===(n=t.themeSemantic)||void 0===n?void 0:n.border)||"#999",strokeWidth:.5,fillOpacity:1}}(r),d=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(r),h=function(t){var e;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",r:4,fillOpacity:.8}}(r);if(r.graticule){const e=!0===r.graticule?{}:r.graticule,n=mt();e.step&&n.step(e.step);const o=a(n())||"";o&&i.push({type:"geoarea",pathData:o,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const n=a.centroid(t),o=a.bounds(t),s=a.area(t),l=wo(r.areaStyle,t,u);i.push({type:"geoarea",pathData:e,centroid:n,bounds:o,screenArea:s,style:l,datum:t,interactive:!0})}const f=ko(r.lineDataAccessor);for(const e of this.lineData){const n=f(e);if(!n||2>n.length)continue;let o=[];if("geo"===r.lineType){const t=Array(n.length);for(let e=0;n.length>e;e++)t[e]=[l(n[e]),c(n[e])];for(let e=0;t.length-1>e;e++){const n=t[e],i=t[e+1],r=vt(n,i)||0,a=Math.max(2,Math.ceil(r/(Math.PI/180))),l=bt(n,i);for(let t=0;a>=t;t++){if(e>0&&0===t)continue;const n=s(l(t/a));null!=n&&o.push(n)}}}else for(let t=0;n.length>t;t++){const e=n[t],i=s([l(e),c(e)]);null!=i&&o.push(i)}if(2>o.length)continue;const a=wo(r.lineStyle,e,d),u="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==n.length||2>o.length||"arc"!==r.flowStyle?2!==n.length||2>o.length||"offset"!==r.flowStyle||(o="geo"===r.lineType?Mo(o,u):_o(o[0],o[o.length-1],0,0,u)):o=So(o[0],o[o.length-1]);const h=Ao(o,t.width);if(h.length>1)for(const t of h){if(2>t.length)continue;const n={type:"line",path:t,style:Object.assign(Object.assign({},a),{_edgeFade:!0}),datum:e};i.push(n)}else i.push({type:"line",path:2>o.length&&h[0]||o,style:a,datum:e})}const g=this.getPoints(),y=r.pointIdAccessor?"function"==typeof r.pointIdAccessor?r.pointIdAccessor:t=>t[r.pointIdAccessor]:null,p=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,m=p>0?p*Math.PI/180:null,v=s.rotate?s.rotate():[0,0,0],b="function"==typeof s.center?s.center():[0,0],x=[(null!==(n=b[0])&&void 0!==n?n:0)-v[0],(null!==(o=b[1])&&void 0!==o?o:0)-v[1]];for(let t=0;g.length>t;t++){const e=g[t],n=l(e),o=c(e);if(null!=m&&vt([n,o],x)>m)continue;const a=s([n,o]);if(!a)continue;const u=r.pointStyle?r.pointStyle(e):Object.assign({},h),d={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:y?y(e)+"":void 0};i.push(d)}return i}applyCartogramTransform(t,e){var n,o,i;const r=this.scene.filter(t=>"point"===t.type);if(2>r.length)return;const s=null!==(n=t.strength)&&void 0!==n?n:1;if(0===s)return;const a=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],c=r.find(e=>e.datum&&a(e.datum)+""==t.center+"");if(!c)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const u=c.x,d=c.y,h=In(r.map(t=>t.datum?l(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),1),f=Math.min(e.width,e.height)/2,g=v().domain([0,h]).range([0,f]);this.cartogramLayout={cx:u,cy:d,maxCost:h,availableRadius:f},this.areas.length>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."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of r){if(t===c)continue;if(!t.datum)continue;const e=Math.atan2(t.y-d,t.x-u),n=Math.sqrt(Math.pow(t.x-u,2)+Math.pow(t.y-d,2)),o=l(t.datum),i=n+((isFinite(o)?g(o):n)-n)*s;t.x=u+Math.cos(e)*i,t.y=d+Math.sin(e)*i}const y=e.width/2,p=e.height/2,m=y-c.x,b=p-c.y;if(Math.abs(m)>.5||Math.abs(b)>.5)for(const t of r)t.x+=m,t.y+=b;this.cartogramLayout={cx:y,cy:p,maxCost:h,availableRadius:f};const x=this.scene.filter(t=>"line"===t.type);if(x.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of r)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of x){const n=null===(o=e.datum)||void 0===o?void 0:o.source,r=null===(i=e.datum)||void 0===i?void 0:i.target;if(n&&r){const o=t.get(n+""),i=t.get(r+"");o&&i&&(e.path=[o,i])}}}}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const n=this.scene.filter(t=>"point"===t.type);for(let o=0;n.length>o;o++){const i=me(t,o,e);n[o]._decayOpacity=i,n[o].style=Object.assign(Object.assign({},n[o].style),{opacity:i})}}applyPulse(){var t;const e=this.config.pulse;if(!e||!this.timestampBuffer)return;const n=performance.now(),o=this.scene.filter(t=>"point"===t.type),i=this.timestampBuffer.toArray();for(let r=0;o.length>r&&i.length>r;r++){const s=ve(e,i[r],n);s>0&&(o[r]._pulseIntensity=s,o[r]._pulseColor=e.color||"rgba(255,255,255,0.6)",o[r]._pulseGlowRadius=null!==(t=e.glowRadius)&&void 0!==t?t:4)}}get hasActivePulses(){var t;return be(null!==(t=this.config.pulse)&&void 0!==t?t:{},this.timestampBuffer)}startTransition(t){var e,n,o,i;const r=null!==(n=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==n?n:300;if(0>=r)return;const s=new Map;for(const e of t)"point"===e.type&&e.pointId&&s.set(e.pointId,[e.x,e.y]);const a=this.scene.filter(t=>"point"===t.type);let l=!1;for(const t of a)if(t.pointId){const e=s.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(l=!0))}for(const t of a)t.pointId&&!s.has(t.pointId)&&(t._targetOpacity=null!==(i=null===(o=t.style)||void 0===o?void 0:o.opacity)&&void 0!==i?i:1,t.style=Object.assign(Object.assign({},t.style),{opacity:0}),l=!0);l&&(this.activeTransition={startTime:performance.now(),duration:r})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=ke(t,this.activeTransition),n=xe(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=we(t.x,t._targetX,n),t.y=we(e,t._targetY,n)}null!=t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style),{opacity:t._targetOpacity*n}))}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0),null!=t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style),{opacity:t._targetOpacity}),t._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}}function Oo(t){const e=t instanceof Date?t.getTime():"number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function To(t){if(!t||2>t.length)return;const e=Oo(t[0]),n=Oo(t[t.length-1]);return null!==e&&null!==n?[e,n]:void 0}function $o(t){var e;const{count:n,byType:o}=function(t){var e;const n={};for(const o of t){const t="string"==typeof(null==o?void 0:o.type)&&o.type.length>0?o.type:"node";n[t]=(null!==(e=n[t])&&void 0!==e?e:0)+1}return{count:t.length,byType:n}}(t.marks),i=0===n,r=[...null!==(e=t.extraWarnings)&&void 0!==e?e:[]];i&&!r.includes("EMPTY_SCENE")&&r.push("EMPTY_SCENE");const s=Array.isArray(t.annotations)?t.annotations.length:0,a="string"==typeof t.description&&t.description||"string"==typeof t.title&&t.title||`${t.frameType} chart, ${n} marks`;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({component:"",frameType:t.frameType,status:i?"empty":"ok",empty:i,markCount:n,markCountByType:o,width:t.width,height:t.height},t.xDomain?{xDomain:t.xDomain}:{}),t.yDomain?{yDomain:t.yDomain}:{}),t.categories?{categories:t.categories}:{}),void 0!==t.nodeCount?{nodeCount:t.nodeCount}:{}),void 0!==t.edgeCount?{edgeCount:t.edgeCount}:{}),void 0!==t.legendItems?{legendItems:t.legendItems}:{}),{annotationCount:s,ariaLabel:a,warnings:r})}function jo(t){var e,n,o,i;return(null!==(e=t.tl)&&void 0!==e?e:0)>0||(null!==(n=t.tr)&&void 0!==n?n:0)>0||(null!==(o=t.br)&&void 0!==o?o:0)>0||(null!==(i=t.bl)&&void 0!==i?i:0)>0}function Lo(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(t.w,t.h)/2,o=t=>Math.max(0,Math.min(null!=t?t:0,n));return{tl:o(e.tl),tr:o(e.tr),br:o(e.br),bl:o(e.bl)}}Po.QUADTREE_THRESHOLD=500;const Co=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function zo(t){var e,n;const{innerRadius:o,outerRadius:i,startAngle:r,endAngle:s}=t,a=0>=o;if(0>=(null!==(e=t.cornerRadius)&&void 0!==e?e:0)||!t.roundStart&&!t.roundEnd){if(a){const t=Co(i,r),e=Co(i,s);return`M0,0 L${t.x},${t.y} A${i},${i} 0 ${s-r>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=Co(i,r),e=Co(i,s),n=Co(o,s),l=Co(o,r),c=s-r>Math.PI?1:0;return`M${t.x},${t.y} A${i},${i} 0 ${c} 1 ${e.x},${e.y} L${n.x},${n.y} A${o},${o} 0 ${c} 0 ${l.x},${l.y} Z`}const l=Math.max(0,Math.min(null!==(n=t.cornerRadius)&&void 0!==n?n:0,(i-o)/2));if(0===l)return zo(Object.assign(Object.assign({},t),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const c=Math.asin(Math.min(1,l/Math.max(1e-9,i-l))),u=a?0:Math.asin(Math.min(1,l/Math.max(1e-9,o+l))),d=s-r,h=t.roundStart&&t.roundEnd?d/2:d,f=!!t.roundStart&&h>c,g=!!t.roundEnd&&h>c;if(!f&&!g)return zo(Object.assign(Object.assign({},t),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const y=r+(f?c:0),p=s-(g?c:0),m=r+(f?u:0),v=s-(g?u:0),b=Co(i,y),x=Co(i,p),k=(i-l)*Math.cos(c),w=Co(k,r),A=Co(k,s),S=a?null:Co(o,v),M=a?null:Co(o,m),_=a?0:(o+l)*Math.cos(u),P=a?null:Co(_,r),O=a?null:Co(_,s),T=p-y>Math.PI?1:0,$=a?0:v-m>Math.PI?1:0;let j="";if(f)j+=`M${w.x},${w.y}`,j+=` A${l},${l} 0 0 1 ${b.x},${b.y}`;else{const t=Co(i,r);j+=`M${t.x},${t.y}`}if(g)j+=` A${i},${i} 0 ${T} 1 ${x.x},${x.y}`,j+=` A${l},${l} 0 0 1 ${A.x},${A.y}`;else{const t=Co(i,s);j+=` A${i},${i} 0 ${T} 1 ${t.x},${t.y}`}if(a)j+=" L0,0";else{if(g)j+=` L${O.x},${O.y}`,j+=` A${l},${l} 0 0 1 ${S.x},${S.y}`;else{const t=Co(o,s);j+=` L${t.x},${t.y}`}if(f)j+=` A${o},${o} 0 ${$} 0 ${M.x},${M.y}`,j+=` A${l},${l} 0 0 1 ${P.x},${P.y}`;else{const t=Co(o,r);j+=` A${o},${o} 0 ${$} 0 ${t.x},${t.y}`}}return j+=" Z",j}const Do={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Eo(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function Ro(e,n,o){const i=Ee(e.symbolType,e.size,e.path);return t("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?Eo(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${null!=o?o:""}symbol-${n}`)}function No(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function Fo(n,o,i){var r,s,a,l,c;switch(n.type){case"line":{const e=n;if(0===e.path.length)return null;const i="M"+e.path.map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:i,fill:"none",stroke:e.style.stroke||"#4e79a7",strokeWidth:e.style.strokeWidth||2,strokeDasharray:e.style.strokeDasharray,opacity:e.style.opacity},"line-"+o)}case"area":{const c=n;if(0===c.topPath.length)return null;const u=`M${c.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...c.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(c.clipRect){const n=`${i?i+"-":""}area-clip-${o}`;return e("g",{children:[t("defs",{children:t("clipPath",{id:n,children:t("rect",{x:c.clipRect.x,y:c.clipRect.y,width:c.clipRect.width,height:c.clipRect.height})})}),t("path",{d:u,fill:Eo(c.style.fill),fillOpacity:null!==(s=null!==(r=c.style.fillOpacity)&&void 0!==r?r:c.style.opacity)&&void 0!==s?s:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth,clipPath:`url(#${n})`})]},"area-"+o)}return t("path",{d:u,fill:Eo(c.style.fill),fillOpacity:null!==(l=null!==(a=c.style.fillOpacity)&&void 0!==a?a:c.style.opacity)&&void 0!==l?l:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth},"area-"+o)}case"point":{const e=n;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:Eo(e.style.fill),opacity:null!==(c=e.style.opacity)&&void 0!==c?c:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"point-"+o)}case"symbol":return Ro(n,o);case"rect":{const e=n;return t("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:Eo(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"rect-"+o)}case"heatcell":{const i=n;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const n=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[r,s,a]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(i.fill),l=.299*r+.587*s+.114*a>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return e("g",{children:[t("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),t("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:c+"px",children:n})]},"heatcell-"+o)}return t("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill},"heatcell-"+o)}case"candlestick":{const i=n,r=Math.min(i.openY,i.closeY),s=Math.max(Math.abs(i.openY-i.closeY),1),a=i.isUp?i.upColor:i.downColor;return e("g",{children:[t("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),t("rect",{x:i.x-i.bodyWidth/2,y:r,width:i.bodyWidth,height:s,fill:a,stroke:a,strokeWidth:1})]},"candle-"+o)}default:return null}}function Wo(n,i,r){var s,a,l,c,u,d,h,f,g;const y=("category"in n?n.category:void 0)||("group"in n?n.group:void 0)||"",p=t=>`ord-${n.type}-${y}-${i}-${t}`,m=`ord-${n.type}-${y}-${i}`;switch(n.type){case"rect":{const i=n,r=No(m)+"-grad",s=function(e,n){const o=e.fillGradient;if(!o)return null;let i=e.x,r=e.y,s=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(r=e.y+e.h,a=e.y):"right"===e.roundedEdge?(i=e.x+e.w,r=e.y,s=e.x,a=e.y):"left"===e.roundedEdge&&(i=e.x,r=e.y,s=e.x+e.w,a=e.y);const l=[];if("colorStops"in o){const e=o.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;for(let n=0;e.length>n;n++)l.push(t("stop",{offset:e[n].offset,stopColor:e[n].color},n))}else{const n=Eo(e.style.fill);l.push(t("stop",{offset:0,stopColor:n,stopOpacity:o.topOpacity},"0")),l.push(t("stop",{offset:1,stopColor:n,stopOpacity:o.bottomOpacity},"1"))}return t("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:i,y1:r,x2:s,y2:a,children:l})}(i,r),a=s?`url(#${r})`:Eo(i.style.fill);if(i.cornerRadii&&jo(i.cornerRadii)){const n=function(t){const{x:e,y:n,w:o,h:i}=t,{tl:r,tr:s,br:a,bl:l}=Lo(t);let c=`M${e+r},${n}`;return c+=` L${e+o-s},${n}`,s>0&&(c+=` A${s},${s} 0 0 1 ${e+o},${n+s}`),c+=` L${e+o},${n+i-a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${e+o-a},${n+i}`),c+=` L${e+l},${n+i}`,l>0&&(c+=` A${l},${l} 0 0 1 ${e},${n+i-l}`),c+=` L${e},${n+r}`,r>0&&(c+=` A${r},${r} 0 0 1 ${e+r},${n}`),c+=" Z",c}(i);return e(o.Fragment,{children:[s&&t("defs",{children:s}),t("path",{d:n,fill:a,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},m)}if(i.roundedTop&&i.roundedTop>0){const n=Math.min(i.roundedTop,i.w/2,i.h/2),{x:r,y:l,w:c,h:u}=i;let d;switch(i.roundedEdge){case"right":d=`M${r},${l} L${r+c-n},${l} A${n},${n} 0 0 1 ${r+c},${l+n} L${r+c},${l+u-n} A${n},${n} 0 0 1 ${r+c-n},${l+u} L${r},${l+u} Z`;break;case"left":d=`M${r+c},${l} L${r+n},${l} A${n},${n} 0 0 0 ${r},${l+n} L${r},${l+u-n} A${n},${n} 0 0 0 ${r+n},${l+u} L${r+c},${l+u} Z`;break;case"bottom":d=`M${r},${l} L${r+c},${l} L${r+c},${l+u-n} A${n},${n} 0 0 1 ${r+c-n},${l+u} L${r+n},${l+u} A${n},${n} 0 0 1 ${r},${l+u-n} Z`;break;default:d=`M${r},${l+u} L${r},${l+n} A${n},${n} 0 0 1 ${r+n},${l} L${r+c-n},${l} A${n},${n} 0 0 1 ${r+c},${l+n} L${r+c},${l+u} Z`}return e(o.Fragment,{children:[s&&t("defs",{children:s}),t("path",{d:d,fill:a,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},m)}return e(o.Fragment,{children:[s&&t("defs",{children:s}),t("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:a,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},m)}case"point":{const e=n;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:Eo(e.style.fill),opacity:null!==(s=e.style.opacity)&&void 0!==s?s:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},m)}case"symbol":return Ro(n,i,r);case"wedge":{const o=n;if(o._gradientBand&&o._gradientBand.colors.length>0){const n=No(`${r?r+"-":""}gauge-grad-${o.category||m}-${i}`),{clipPath:s,slices:d}=function(t){const e=zo({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),n=[],o=t.colors;if(o.length>0){const e=(t.endAngle-t.startAngle)/o.length;for(let i=0;o.length>i;i++)n.push({d:zo({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+i*e,endAngle:t.endAngle}),color:o[i]})}return{clipPath:e,slices:n}}({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:null===(l=null===(a=o.roundedEnds)||void 0===a?void 0:a.start)||void 0===l||l,roundEnd:null===(u=null===(c=o.roundedEnds)||void 0===c?void 0:c.end)||void 0===u||u,colors:o._gradientBand.colors});return e("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[t("defs",{children:t("clipPath",{id:n,children:t("path",{d:s})})}),t("g",{clipPath:`url(#${n})`,children:d.map((e,n)=>t("path",{d:e.d,fill:Eo(e.color)},n))}),o.style.stroke&&"none"!==o.style.stroke&&t("path",{d:s,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},m)}let s;if(o.roundedEnds)s=zo({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{const t=j().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&t.cornerRadius(o.cornerRadius),s=t(Do)||""}return t("path",{d:s,transform:`translate(${o.cx},${o.cy})`,fill:Eo(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},m)}case"boxplot":{const o=n,i=o.columnWidth/2;return e("g","vertical"===o.projection?{children:[t("line",{x1:o.x,y1:o.minPos,x2:o.x,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1}),t("rect",{x:o.x-i,y:Math.min(o.q1Pos,o.q3Pos),width:o.columnWidth,height:Math.abs(o.q3Pos-o.q1Pos),fill:Eo(o.style.fill),fillOpacity:null!==(d=o.style.fillOpacity)&&void 0!==d?d:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.x-i,y1:o.medianPos,x2:o.x+i,y2:o.medianPos,stroke:o.style.stroke||"#333",strokeWidth:2}),t("line",{x1:o.x-.5*i,y1:o.minPos,x2:o.x+.5*i,y2:o.minPos,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.x-.5*i,y1:o.maxPos,x2:o.x+.5*i,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1})]}:{children:[t("line",{x1:o.minPos,y1:o.y,x2:o.maxPos,y2:o.y,stroke:o.style.stroke||"#333",strokeWidth:1}),t("rect",{x:Math.min(o.q1Pos,o.q3Pos),y:o.y-i,width:Math.abs(o.q3Pos-o.q1Pos),height:o.columnWidth,fill:Eo(o.style.fill),fillOpacity:null!==(h=o.style.fillOpacity)&&void 0!==h?h:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.medianPos,y1:o.y-i,x2:o.medianPos,y2:o.y+i,stroke:o.style.stroke||"#333",strokeWidth:2}),t("line",{x1:o.minPos,y1:o.y-.5*i,x2:o.minPos,y2:o.y+.5*i,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.maxPos,y1:o.y-.5*i,x2:o.maxPos,y2:o.y+.5*i,stroke:o.style.stroke||"#333",strokeWidth:1})]},m)}case"violin":{const e=n,o=[t("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:Eo(e.style.fill),fillOpacity:null!==(f=e.style.fillOpacity)&&void 0!==f?f:.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1},p("path"))];if(e.iqrLine&&e.bounds){const n=e.bounds,i=n.x+n.width/2,r=n.y+n.height/2;n.height>n.width?o.push(t("line",{x1:i,y1:e.iqrLine.q1Pos,x2:i,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},p("iqr")),t("circle",{cx:i,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},p("med"))):o.push(t("line",{x1:e.iqrLine.q1Pos,y1:r,x2:e.iqrLine.q3Pos,y2:r,stroke:e.style.stroke||"#333",strokeWidth:2},p("iqr")),t("circle",{cx:e.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},p("med")))}return t("g",{children:o},m)}case"connector":return t("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:null!==(g=n.style.opacity)&&void 0!==g?g:.5},m);case"trapezoid":{const e=n,o=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t("polygon",{points:o,fill:Eo(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},m)}default:return null}}const Bo="undefined"==typeof window||"undefined"==typeof document;function Io(e){let n=null;const o=()=>(n||(n=c(null)),n),u=Yo(e);return[function({children:n,initialState:s}){const a=i(s),l=r(()=>Yo(e,a.current),[]),c=o();return t(c.Provider,{value:l,children:n})},(t,e)=>{var n;const r=o(),c=null!==(n=s(r))&&void 0!==n?n:u,d=i(t);d.current=t;const h=i({hasValue:!1,value:void 0}),f=a(()=>{const t=d.current(c.getState()),n=h.current;return n.hasValue&&e&&e(n.value,t)?n.value:(h.current={hasValue:!0,value:t},t)},[c,e]),g=a(()=>d.current(c.getState()),[c]);return l(c.subscribe,f,g)}]}function Yo(t,e){const n=new Set;let o=Object.assign(Object.assign({},t(function(t){const e=t(o);if(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}(e)){o=Object.assign(Object.assign({},o),e);for(const t of n)t()}})),null!=e?e:{});return{getState:()=>o,subscribe:function(t){return n.add(t),()=>{n.delete(t)}}}}function Go(t){if(!(null==t?void 0:t.colors))return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function Ho(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:Xo})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}const Xo=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],qo={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}},Vo={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}},Uo={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Xo,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 Zo(t,e){if("light"===e)return qo;if("dark"===e)return Vo;if("high-contrast"===e)return Uo;if("string"==typeof e)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${e}". Keeping current theme.`),t;if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?Vo:qo;return Ho(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}return Ho(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}const[Qo,Ko]=Io(t=>({theme:qo,setTheme(e){t(t=>({theme:Zo(t.theme,e)}))}})),Jo={light:qo,dark:Vo,"high-contrast":Uo,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 ti(t){if(!t)return qo;if("string"==typeof t){if("light"===t)return qo;if("dark"===t)return Vo;if("high-contrast"===t)return Uo;return Jo[t]||qo}const e="dark"===t.mode?Vo:qo;return Ho(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{}),tooltip:Object.assign(Object.assign({},e.tooltip),t.tooltip||{})}))}function ei(t){var e,n,o,i;return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:null!==(e=t.colors.annotation)&&void 0!==e?e:t.colors.text,legendSize:null!==(n=t.typography.legendSize)&&void 0!==n?n:t.typography.labelSize,titleFontSize:null!==(o=t.typography.titleFontSize)&&void 0!==o?o:t.typography.titleSize,tickFontFamily:null!==(i=t.typography.tickFontFamily)&&void 0!==i?i:t.typography.fontFamily}}function ni(t){return"left"===t?"start":"right"===t?"end":null!=t?t:"start"}function oi(t){var e,n;return Number(null!==(n=null!==(e=t.typography.legendSize)&&void 0!==e?e:t.typography.labelSize)&&void 0!==n?n:t.typography.tickSize)||11}function ii(t,e,n,o){const i=oi(o);return e+n+Math.ceil(t.length*i*.58)}function ri(t){var e,n,o,i,r;const{categories:s,theme:a,position:l="right",totalWidth:c,totalHeight:u,margin:d,legendLayout:h}=t,f=Math.max(1,null!==(e=null==h?void 0:h.swatchSize)&&void 0!==e?e:14),g=Math.max(0,null!==(n=null==h?void 0:h.labelGap)&&void 0!==n?n:6),y=Math.max(0,null!==(o=null==h?void 0:h.itemGap)&&void 0!==o?o:8),p=Math.max(f,null!==(i=null==h?void 0:h.rowHeight)&&void 0!==i?i:20),m=f+g,v=Math.min(2,f/2),b="top"===l||"bottom"===l,x=Math.max(f,c-d.left-d.right),k=Math.max(p,u-d.top-d.bottom),w=s.map(t=>ii(t,f,g,a));if(b){const t=Math.max(f,null!==(r=null==h?void 0:h.maxWidth)&&void 0!==r?r:x),e=[];let n=0,o=0;w.forEach((i,r)=>{const s=0===o?i:o+y+i;o>0&&s>t?(e.push({start:n,end:r,width:o}),n=r,o=i):o=s}),s.length>0&&e.push({start:n,end:s.length,width:o});const i=ni(null==h?void 0:h.align),a=[];return e.forEach((e,n)=>{let o="center"===i?Math.max(0,(t-e.width)/2):"end"===i?Math.max(0,t-e.width):0;for(let t=e.start;e.end>t;t++)a.push({category:s[t],width:w[t],x:o,y:n*p}),o+=w[t]+y}),{items:a,width:Math.max(0,...e.map(t=>t.width)),height:e.length*p,swatchSize:f,labelOffset:m,swatchRadius:v}}const A=Math.max(0,...w),S=Math.max(1,Math.floor(k/p)),M=Math.max(1,Math.ceil(s.length/S));return{items:s.map((t,e)=>({category:t,width:w[e],x:Math.floor(e/S)*(A+y),y:e%S*p})),width:M*A+Math.max(0,M-1)*y,height:Math.min(s.length,S)*p,swatchSize:f,labelOffset:m,swatchRadius:v}}function si(t){var e,n,o,i,r;const{legendGroups:s,theme:a,position:l="right",totalWidth:c,totalHeight:u,margin:d,legendLayout:h}=t,f=Math.max(1,null!==(e=null==h?void 0:h.swatchSize)&&void 0!==e?e:14),g=Math.max(0,null!==(n=null==h?void 0:h.labelGap)&&void 0!==n?n:6),y=Math.max(0,null!==(o=null==h?void 0:h.itemGap)&&void 0!==o?o:8),p=Math.max(f,null!==(i=null==h?void 0:h.rowHeight)&&void 0!==i?i:20),m=f+g,v=Math.min(2,f/2),b=Math.max(12,oi(a)),x="top"===l||"bottom"===l,k=Math.max(f,c-d.left-d.right),w=Math.max(p,u-d.top-d.bottom);if(x){const e=Math.max(f,null!==(r=null==h?void 0:h.maxWidth)&&void 0!==r?r:k),n=ni(null==h?void 0:h.align);let o=0,i=0;const l=[];for(const n of s){const r=n.items.map(t=>t.label),s=ri(Object.assign(Object.assign({},t),{categories:r,legendLayout:Object.assign(Object.assign({},h),{maxWidth:Math.max(f,e-b-8),align:"start"})})),c=n.label?b:0,u=n.label?ii(n.label,0,0,a):0,d=c>0?c+8:0,g=d+s.width,y=Math.max(s.height,u);l.push({group:n,x:o,y:0,itemOffsetX:d,itemOffsetY:0,width:g,height:y,items:s.items}),o+=g+12,i=Math.max(i,y)}const c=l.length>0?o-12:0,u=c>e?0:"center"===n?Math.max(0,(e-c)/2):"end"===n?Math.max(0,e-c):0;return{groups:l.map(t=>Object.assign(Object.assign({},t),{x:t.x+u})),width:c,height:i,swatchSize:f,labelOffset:m,swatchRadius:v}}let A=0,S=0;const M=[];for(const t of s){const e=t.items.map(t=>t.label).map(t=>ii(t,f,g,a)),n=Math.max(0,...e),o=Math.max(1,Math.min(t.items.length||1,Math.max(1,Math.floor(Math.max(p,w-A)/p)))),i=Math.max(1,Math.ceil(t.items.length/o)),r=t.items.map((t,i)=>({category:t.label,width:e[i],x:Math.floor(i/o)*(n+y),y:i%o*p})),s=i*n+Math.max(0,i-1)*y,l=Math.min(t.items.length,o)*p,c=t.label?ii(t.label,0,0,a):0,u=t.label?b+8:0,d=u+l+12,h=Math.max(s,c);M.push({group:t,x:0,y:A,itemOffsetX:0,itemOffsetY:u,width:h,height:d,items:r}),S=Math.max(S,h),A+=d}return{groups:M,width:S,height:Math.max(0,A),swatchSize:f,labelOffset:m,swatchRadius:v}}function ai(t){var e,n;return"top"===t.position||"bottom"===t.position?{width:Math.min(null!==(n=null===(e=t.legendLayout)||void 0===e?void 0:e.maxWidth)&&void 0!==n?n:Math.max(1,t.totalWidth-t.margin.left-t.margin.right),200),height:t.gradient.label?34:26,swatchSize:12}:{width:t.gradient.label?86:72,height:t.gradient.label?124:108,swatchSize:14}}function li(n){const{categories:o,colorScheme:i,theme:r,position:s="right",totalWidth:a,totalHeight:l,margin:c,hasTitle:u=!1}=n;if(!o||0===o.length)return null;const d=function(t,e,n){const o=Array.isArray(e)?e:n.colors.categorical.length>0?n.colors.categorical:Qt;return m().domain(t).range(o)}(o,i,r),h="top"===s||"bottom"===s,f=ri(n);let g,y;if("left"===s?(g=Math.max(4,c.left-f.width-10),y=c.top):"top"===s?(g=c.left,y=u?32:8):"bottom"===s?(g=c.left,y=Math.min(l-c.bottom+38,l-f.height-2)):(g=Math.min(a-f.width-4,a-c.right+10),y=c.top),h){const n=f.items.map((n,o)=>e("g",{transform:`translate(${n.x},${n.y})`,children:[t("rect",{width:f.swatchSize,height:f.swatchSize,fill:d(n.category),rx:f.swatchRadius}),t("text",{x:f.labelOffset,y:f.swatchSize/2,dominantBaseline:"central",fontSize:oi(r),fill:r.colors.text,fontFamily:r.typography.fontFamily,children:n.category})]},"legend-"+o));return t("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:n})}const p=f.items.map((n,o)=>e("g",{transform:`translate(${n.x},${n.y})`,children:[t("rect",{width:f.swatchSize,height:f.swatchSize,fill:d(n.category),rx:f.swatchRadius}),t("text",{x:f.labelOffset,y:f.swatchSize/2,dominantBaseline:"central",fontSize:oi(r),fill:r.colors.text,fontFamily:r.typography.fontFamily,children:n.category})]},"legend-"+o));return t("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:p})}function ci(t,e){if(!e||!t||0===t.length)return[];const n="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=n(e);null!=t&&o.add(t+"")}return Array.from(o)}function ui(t,e=120,n=8){if(!t)return[];const o=Math.max(1,Math.floor(e/n)),i=t.split(/\s+/),r=[];let s="";for(const t of i)s&&s.length+1+t.length>o?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function di(t,e,n,o){return"curly"===t?o?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:o?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function hi(n,o,i,r){if(!n)return t("g",{className:"annotation-note"});const{label:s,title:a,orientation:l,align:c,wrap:u=120,noWrap:d}=n;if(!s&&!a)return t("g",{className:"annotation-note"});let h=l;h||(h=Math.abs(o)>Math.abs(i)?"leftRight":"topBottom");let f=c;f&&"dynamic"!==f||(f="topBottom"===h?0>o?"right":"left":0>i?"bottom":"top");let g="start";"topBottom"===h?"right"===f?g="end":"middle"===f&&(g="middle"):g=0>o?"end":"start";const y=16,p=a?d?[a]:ui(a,u):[],m=s?d?[s]:ui(s,u):[],v="leftRight"===h?"end"===g?-4:4:0;let b=0;const x=[],k=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";n.useHTML||n.html?(x.push(t("foreignObject",{className:"annotation-note-html",x:"end"===g?v-u:"middle"===g?v-u/2:v,y:-16,width:u,height:Math.max(y,(p.length+m.length)*y+(a&&s?2:0))+y,style:{overflow:"visible"},children:e("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:k,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===g?"right":"middle"===g?"center":"left",whiteSpace:d?"nowrap":"normal",wordBreak:"break-word"},children:[a&&t("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:a}),s&&t("div",{className:"annotation-note-label",children:s})]})},"annotation-note-html")),b=p.length*y):(p.length>0&&(x.push(t("text",{className:"annotation-note-title",fill:k,textAnchor:g,fontWeight:"bold",children:p.map((e,n)=>t("tspan",{x:v,dy:0===n?0:y,children:e},n))},"annotation-note-title")),b=p.length*y),m.length>0&&x.push(t("text",{className:"annotation-note-label",fill:k,textAnchor:g,y:b,children:m.map((e,n)=>t("tspan",{x:v,dy:0===n?0:y,children:e},n))},"annotation-note-label")));let w=null;if((a||s)&&(0!==o||0!==i))if("topBottom"===h){const e=Math.min(u,120);let n=0,o=e;"end"===g?(n=-e,o=0):"middle"===g&&(n=-e/2,o=e/2),w=t("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+m.length)*y+(m.length>0?y:0);let n=0,o=e;"bottom"===f?(n=-e,o=0):"middle"===f&&(n=-e/2,o=e/2),w=t("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const A=Math.max(0,p.length+m.length-1)*y;let S=0;return"topBottom"===h?S=0>i?-(A+2):18:"leftRight"===h&&(S="middle"===f?-(A+y+(m.length>0&&p.length>0?2:0))/2+8:"bottom"===f||0>i?-(A+2):18),e("g",{className:"annotation-note",transform:`translate(${o},${i})`,children:[t("g",{className:"annotation-note-content",transform:0!==S?`translate(0,${S})`:void 0,children:x}),w]})}function fi(e,n,o,i,r){var s;const a=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&a.push(t("circle",{r:e,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,i=(null==n?void 0:n.height)||0;(e>0||i>0)&&a.push(t("rect",{width:e,height:i,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=i||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-e;a.push(t("line",{x1:i,y1:(n.y1||0)-s,x2:i,y2:(n.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-s;a.push(t("line",{x1:(n.x1||0)-e,y1:i,x2:(n.x2||0)-e,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(t("line",{x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(t("line",{x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==e&&a.push(t("path",{d:di((null==n?void 0:n.type)||"curly",e,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return t("g",{className:"annotation-subject",children:a})}function gi(e,n,o,i,r,s){var a;const l=[];let c=0,u=0;if("callout-circle"!==r&&"label"!==r||!(null==s?void 0:s.radius)){if("callout-rect"===r&&s){const t=s.width||0,o=s.height||0;if(t>0||o>0){const i=t/2,r=o/2,s=e-i,a=n-r;if(0!==s||0!==a){const e=Math.abs(s),n=Math.abs(a),l=t/2,d=o/2,h=e*d>n*l?l/e:d/n;c=i+s*h,u=r+a*h}}}else if("bracket"===r&&s){const t=s.width,e=s.height,n=s.depth||30;void 0!==t?(c=t/2,u=n):void 0!==e&&(c=n,u=e/2)}}else{const t=(s.radius||0)+(s.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const o=Math.atan2(n,e);c=Math.cos(o)*t,u=Math.sin(o)*t}}const d=Math.sqrt(Math.pow(e-c,2)+Math.pow(n-u,2));if(d>.5){const r=i||"var(--semiotic-text-secondary, currentColor)",s="curve"===(null==o?void 0:o.type);let h=Math.atan2(n-u,e-c);if(s){const i=(null!==(a=null==o?void 0:o.curve)&&void 0!==a?a:.25)*d,s=(c+e)/2+-(n-u)/d*i,f=(u+n)/2+(e-c)/d*i;l.push(t("path",{className:"connector-curve",d:`M${c},${u}Q${s},${f} ${e},${n}`,fill:"none",stroke:r},"connector-line")),h=Math.atan2(f-u,s-c)}else l.push(t("line",{x1:c,y1:u,x2:e,y2:n,stroke:r},"connector-line"));if("arrow"===(null==o?void 0:o.end)){const e=10,n=16/180*Math.PI;l.push(t("path",{d:`M${c},${u}L${c+e*Math.cos(h+n)},${u+e*Math.sin(h+n)}L${c+e*Math.cos(h-n)},${u+e*Math.sin(h-n)}Z`,fill:r,stroke:"none"},"connector-arrow"))}}return t("g",{className:"annotation-connector",children:l})}function yi(t){var n,o;const{x:i=0,y:r=0,dx:s,dy:a,nx:l,ny:c,note:u,connector:d,subject:h,type:f,color:g,className:y,disable:p,opacity:m,strokeDasharray:v,events:b={},"data-testid":x}=t,k=Array.isArray(i)?null!==(n=i[0])&&void 0!==n?n:0:i,w=Array.isArray(r)?null!==(o=r[0])&&void 0!==o?o:0:r,A=new Set(Array.isArray(p)?p:[]);let S=s||0,M=a||0;null!=l&&(S=l-k),null!=c&&(M=c-w);const _="string"==typeof f?f:"label";if("bracket"===_&&h&&0===S&&0===M)if(void 0!==h.width){S=h.width/2;const t=h.depth||30;M=t+(0>t?-5:5)}else if(void 0!==h.height){const t=h.depth||30;S=t+(0>t?-5:5),M=h.height/2}return e("g",Object.assign({className:("annotation "+(y||"")).trim(),transform:`translate(${k},${w})`,"data-testid":x},null!=m&&{opacity:m},v&&{strokeDasharray:v},b,{children:[!A.has("connector")&&gi(S,M,d,g,_,h),!A.has("subject")&&fi(_,h,g,k,w),!A.has("note")&&hi(u,S,M,g)]}))}function pi(e){var n,o;const{noteData:i}=e,{screenCoordinates:r}=i,s="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const e=i.nx||r[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),a=i.ny||r[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),l=r.map((n,o)=>{const r=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:e,ny:a});return t(yi,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+o)});return t("g",{children:l})}const l=i.note||{title:"none",label:i.label},c=`${l.label}-${l.title}-${i.i}`;return t(yi,Object.assign({"data-testid":"semiotic-annotation",events:a},i,{type:s}),c)}const mi={secondary:0,primary:3};function vi(t){return!0===(null==t?void 0:t._annotationDeferred)}function bi(t){return"blended"===(null==t?void 0:t.cohesion)||"layer"===(null==t?void 0:t.cohesion)?t.cohesion:null}function xi(t){var e;const n=null===(e=null==t?void 0:t.provenance)||void 0===e?void 0:e.confidence;return"number"==typeof n&&Number.isFinite(n)?Math.max(0,Math.min(1,n)):null}function ki(t){return Math.max(.72,.95-.06*t)}function wi(e){const n=e.map((t,e)=>{return{p:t,i:e,emphasis:(n=t.annotation,"primary"===(null==n?void 0:n.emphasis)||"secondary"===(null==n?void 0:n.emphasis)?n.emphasis:null),confidence:xi(t.annotation),readingOrder:null,rank:1};var n}),o=n.some(t=>null!=t.emphasis||null!=t.confidence),i=e.some(t=>vi(t.annotation)),r=e.some(t=>null!=bi(t.annotation)),s=e.some(t=>"layer"===bi(t.annotation));if(!o&&!i&&!r)return e.map(t=>t.node);const a=n.filter(t=>null==t.emphasis&&null!=t.confidence).slice().sort((t,e)=>{var n,o;return(null!==(n=e.confidence)&&void 0!==n?n:0)-(null!==(o=t.confidence)&&void 0!==o?o:0)||t.i-e.i});a.forEach((t,e)=>{t.readingOrder=e,t.rank=2-e/Math.max(1,a.length)});for(const t of n)t.emphasis&&(t.rank=mi[t.emphasis]);const l=n.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(e=>{const{p:n,i:o,emphasis:i,readingOrder:r}=e,s=vi(n.annotation);let a=n.node;if("primary"===i||"secondary"===i||null!=r){const e=null==i&&null!=r;a=t("g",Object.assign({className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+i},"secondary"===i?{opacity:.6,fontSize:"0.88em"}:{},e?{opacity:ki(r),"data-annotation-reading-order":r}:{},{children:n.node}),"annotation-emphasis-"+o)}const l=bi(n.annotation);return l&&(a=t("g",{className:"annotation-cohesion--"+l,children:a},"annotation-cohesion-"+o)),s&&(a=t("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+o)),a});return i&&l.unshift(t("style",{children:".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}}"},"annotation-disclosure-style")),s&&l.unshift(t("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),l}function Ai(t,e){var n,o,i;const r=null!==(o=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(i=e.scales)||void 0===i?void 0:i.time;return r?null!=t.x?r(t.x):e.xAccessor&&null!=t[e.xAccessor]?r(t[e.xAccessor]):null:null}function Si(t,e){var n,o,i;const r=null!==(o=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(i=e.scales)||void 0===i?void 0:i.value;return r?null!=t.y?r(t.y):e.yAccessor&&null!=t[e.yAccessor]?r(t[e.yAccessor]):null:null}function Mi(t){return null==t?null:t+""}function _i(t,e,n){var o;return null===(o=e.stickyPositionCache)||void 0===o||o.set(t,n),n}function Pi(t,e,n){var o,i;const r=t.anchor||(null===(o=t.lifecycle)||void 0===o?void 0:o.anchor)||"fixed";if("latest"===r){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const i=n.pointNodes[o];if(i.pointId===t.pointId)return _i(e,n,{x:i.x,y:i.y})}const o=function(t){var e,n,o,i,r,s;const a=t.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(o=t.scales)||void 0===o?void 0:o.time,u=null!==(r=null===(i=t.scales)||void 0===i?void 0:i.y)&&void 0!==r?r:null===(s=t.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=l[t.xAccessor||"x"],h=l[t.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return o?_i(e,n,o):null}if("semantic"===r){const o=function(t,e,n){var o,i;const r=function(t){var e,n;return Mi(null!==(n=null===(e=t.provenance)||void 0===e?void 0:e.stableId)&&void 0!==n?n:t.stableId)}(t);if(!r)return null;const s=null===(o=n.pointNodes)||void 0===o?void 0:o.find(t=>Mi(t.pointId)===r);if(s)return _i(e,n,{x:s.x,y:s.y});const a=null===(i=n.data)||void 0===i?void 0:i.find(t=>function(t){var e,n,o;return Mi(null!==(n=null!==(e=t.stableId)&&void 0!==e?e:t.id)&&void 0!==n?n:null===(o=t.provenance)||void 0===o?void 0:o.stableId)}(t)===r);if(!a)return null;const l=Ai(a,n),c=Si(a,n);return null==l||null==c?null:_i(e,n,{x:l,y:c})}(t,e,n);if(o)return o}let s=null,a=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(s=e.x,a=e.y)}if(null!=s&&null!=a||(s=Ai(t,n),a=Si(t,n)),null!=s&&null!=a)return _i(e,n,{x:s,y:a});if("sticky"===r){const t=null===(i=n.stickyPositionCache)||void 0===i?void 0:i.get(e);if(t)return t}return null}function Oi(t,e,n,o=50){return!(-o>t||t>(n.width||0)+o||-o>e||e>(n.height||0)+o)}const Ti=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function $i(t){return!!t&&"object"==typeof t&&Ti.has(function(t){return"string"==typeof(null==t?void 0:t.type)?t.type:""}(t))}function ji(t){return"primary"===(null==t?void 0:t.emphasis)||!0===(null==t?void 0:t.defensive)}function Li(t,e,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):t>0&&e>0?Math.max(1,Math.round(t*e/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function Ci(t){var e,n;let o;const i=null==t?void 0:t.emphasis;o="primary"===i?100:"secondary"===i?10:50;const r=null===(e=null==t?void 0:t.provenance)||void 0===e?void 0:e.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(o+=15*function(t){return Math.max(0,Math.min(1,t))}(r)),null===(n=null==t?void 0:t.lifecycle)||void 0===n?void 0:n.freshness){case"fresh":o+=8;break;case"aging":o+=4;break;case"stale":o+=1;break;case"expired":o-=200}return o}new Set(["label","callout","callout-circle","callout-rect"]);const zi=32,Di=6,Ei=4,Ri=8,Ni=72;const Fi={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Wi(t){return $i(t)}function Bi(t,e){if(!t)return[];const n=Math.max(1,Math.floor(e/7)),o=t.split(/\s+/).filter(Boolean),i=[];let r="";for(const t of o)r&&r.length+t.length+1>n?(i.push(r),r=t):r=r?`${r} ${t}`:t;return r&&i.push(r),i}function Ii(t,e,n,o,i){const r=t+n,s=e+o;return Math.abs(n)>Math.abs(o)?{x:0>n?r-i.width-4:r+4,y:0>o?s-i.height:s,width:i.width,height:i.height}:{x:0>n?r-i.width:r,y:0>o?s-i.height-4:s+4,width:i.width,height:i.height}}function Yi(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function Gi(t,e){return Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x))*Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}function Hi(t,e,n,o,i,r,s,a){const l=Yi(t,s);let c=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,n,o){const i=Math.max(0,o-t.x),r=Math.max(0,o-t.y);return(i+Math.max(0,t.x+t.width-(e-o)))*t.height+(r+Math.max(0,t.y+t.height-(n-o)))*t.width}(l,i,r,a);for(const t of n)c+=12*Gi(l,t);for(const t of o)c+=4*Gi(l,t);return c}function Xi(t){var e;const{annotations:n,context:o,defaultOffset:i=zi,notePadding:r=Di,markPadding:s=Ei,edgePadding:a=Ri,preserveManualOffsets:l=!0,routeLongConnectors:c=!0,connectorThreshold:u=Ni,density:d,progressiveDisclosure:h=!1,redundantCues:f=!1,responsive:g,cohesion:y,audience:p}=t,m=o.width||0,v=o.height||0;if(0===n.length||0>=m||0>=v)return n.slice();const b=[],x=function(t,e){return(t.pointNodes||[]).map(t=>{const n=Math.max(1,t.r||1)+e;return{x:t.x-n,y:t.y-n,width:2*n,height:2*n}})}(o,s);let k=!1;const w=n.map((t,e)=>{if(!Wi(t))return t;const n=function(t,e,n){var o,i;if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const r=null!==(o=t.pointId)&&void 0!==o?o:t.nodeId;if(null!=r&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===r);if(t)return{x:t.x,y:t.y}}const s=t.coordinates,a=null===(i=n.scales)||void 0===i?void 0:i.geoProjection;if(Array.isArray(s)&&s.length>=2&&a){const t=s[0],e=s[1];if("number"==typeof t&&"number"==typeof e){const n=a([t,e]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof t.x||"number"!=typeof t.y?Pi(t,e,n):{x:t.x,y:t.y}}(t,e,o);if(!n)return t;const s=function(t){if("widget"===t.type)return{width:"number"==typeof t.width?t.width:32,height:"number"==typeof t.height?t.height:32};const e="number"==typeof t.wrap?t.wrap:120,n=[...Bi("string"==typeof t.title?t.title:void 0,e),...Bi("string"==typeof t.label?t.label:void 0,e)],o=n.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*o)+10),height:Math.max(18,16*n.length+6)}}(t);if(l&&("number"==typeof(d=t).dx||"number"==typeof d.dy)){const e=function(t){return"text"===t.type||"widget"===t.type?{dx:0,dy:0}:{dx:30,dy:-30}}(t);return b.push(Yi(Ii(n.x,n.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,s),r)),t}var d;let h=null,f=1/0;for(const t of function(t){const e=1.6*t;return[{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t},{dx:t,dy:0},{dx:-t,dy:0},{dx:0,dy:-t},{dx:0,dy:t},{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e}]}(i)){const e=Hi(Ii(n.x,n.y,t.dx,t.dy,s),t,b,x,m,v,r,a);f>e&&(h=t,f=e)}if(!h)return t;const g=Yi(Ii(n.x,n.y,h.dx,h.dy,s),r);b.push(g);const y=Math.hypot(h.dx,h.dy),p=c&&y>=u&&"text"!==t.type&&"widget"!==t.type?Object.assign(Object.assign({},t.connector||{end:"arrow"}),{type:"curve"}):t.connector;return k=!0,Object.assign(Object.assign(Object.assign({},t),{dx:h.dx,dy:h.dy}),p?{connector:p}:{})}),A=k?w:n.slice();let S=A;if(f){let t=!1;const e=A.map(e=>{const n=function(t){return"text"!==t.type||"string"!=typeof t.color||8>Math.hypot("number"==typeof t.dx?t.dx:0,"number"==typeof t.dy?t.dy:0)?t:Object.assign(Object.assign({},t),{_redundantConnector:!0})}(e);return n!==e&&(t=!0),n});S=t?e:A}{let t=!1;const e=S.map(e=>{if(!0!==(null==e?void 0:e.defensive))return e;const n=function(t){var e;const n=null==t?void 0:t.provenance;if(!n||"object"!=typeof n)return t;const o="string"==typeof n.source?null!==(e=Fi[n.source])&&void 0!==e?e:n.source:null,i="number"==typeof n.confidence&&Number.isFinite(n.confidence)?Math.round(100*Math.max(0,Math.min(1,n.confidence)))+"%":null;if(!o&&!i)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const r=[o,i].filter(Boolean).join(" · "),s="string"==typeof t.label?t.label:"";return s.includes(`(${r})`)?t:Object.assign(Object.assign({},t),{label:s?`${s} (${r})`:`(${r})`})}(e);return n!==e&&(t=!0),n});S=t?e:S}const M=new Set;if(d){const t="object"==typeof d?d:{},n=function(t){if(!t)return 1;const e=function(t){const e=null==t?void 0:t.familiarity;if(!e)return 3;const n=Object.values(e).filter(t=>"number"==typeof t&&Number.isFinite(t));return 0===n.length?3:n.reduce((t,e)=>t+e,0)/n.length}(t);return e>2?4>e?1:.6:1.5}(p),o=1===n?t:Object.assign(Object.assign({},t),{maxAnnotations:Math.max(0,Math.round((null!==(e=t.maxAnnotations)&&void 0!==e?e:Li(m,v,t))*n))}),{deferred:i}=function(t){var e;const{annotations:n,width:o,height:i}=t,r=Math.max(0,null!==(e=t.minVisible)&&void 0!==e?e:1),s=Li(o,i,t),a=n.map((t,e)=>{return{annotation:t,index:e,note:(n=t,$i(n))};var n}),l=a.filter(t=>t.note);if(0===l.length||s>=l.length)return{visible:n.slice(),deferred:[],budget:s};const c=l.filter(t=>ji(t.annotation)),u=l.filter(t=>!ji(t.annotation)).sort((t,e)=>Ci(e.annotation)-Ci(t.annotation)||t.index-e.index),d=Math.min(u.length,Math.max(Math.max(0,s-c.length),Math.max(0,r-c.length))),h=new Set([...c.map(t=>t.index),...u.slice(0,d).map(t=>t.index)]),f=[],g=[];for(const{annotation:t,index:e,note:n}of a)!n||h.has(e)?f.push(t):g.push(t);return{visible:f,deferred:g,budget:s}}(Object.assign({annotations:S,width:m,height:v},o));for(const t of i)M.add(t)}if(g&&("object"==typeof g&&"number"==typeof g.minWidth?g.minWidth:480)>=m)for(const t of S)Wi(t)&&"secondary"===t.emphasis&&M.add(t);if(M.size>0)for(const t of S)!0===(null==t?void 0:t.defensive)&&M.delete(t);let _;return _=0===M.size?S:h?S.map(t=>M.has(t)?Object.assign(Object.assign({},t),{_annotationDeferred:!0}):t):S.filter(t=>!M.has(t)),y?function(t,e){let n=!1;const o=t.map(t=>Wi(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(n=!0,Object.assign(Object.assign({},t),{cohesion:e})):t);return n?o:t}(_,y):_}function qi(t,e){return t.color||e.colors.annotation||e.colors.text}function Vi(t,e,n){return null!=t.x&&e.x?e.x(t.x):n&&null!=t[n]&&e.x?e.x(t[n]):"number"==typeof t.x?t.x:null}function Ui(t,e,n){return null!=t.y&&e.y?e.y(t.y):n&&null!=t[n]&&e.y?e.y(t[n]):"number"==typeof t.y?t.y:null}function Zi(e){const{annotations:n}=e;if(!n||0===n.length)return null;const o=e.autoPlaceAnnotations?Xi(Object.assign({annotations:n,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:{})):n,i=[];for(let t=0;o.length>t;t++){const n=Qi(o[t],t,e);n&&i.push({node:n,annotation:o[t]})}const r=wi(i);return r.length>0?t("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:r}):null}function Qi(n,o,i){var r,s,a,l,c,u,d;const{scales:h,layout:f,theme:g,xAccessor:y,yAccessor:p}=i;switch(n.type){case"y-threshold":{const s=n.value;if(null==s)return null;const a=qi(n,g),l=n.label,c=n.labelPosition||"right",u=n.strokeDasharray||"6,4",d=null!==(r=n.strokeWidth)&&void 0!==r?r:1.5;if("horizontal"===i.projection&&h.r){const i=h.r(s);return null==i?null:e("g",{opacity:n.opacity,children:[t("line",{x1:i,y1:0,x2:i,y2:f.height,stroke:a,strokeWidth:d,strokeDasharray:u}),l&&t("text",{x:i+4,y:12,textAnchor:"start",fontSize:g.typography.tickSize,fill:a,fontFamily:g.typography.fontFamily,children:l})]},"ann-ythresh-"+o)}const y=h.y?h.y(s):h.r?h.r(s):null;return null==y?null:e("g",{children:[t("line",{x1:0,y1:y,x2:f.width,y2:y,stroke:a,strokeWidth:d,strokeDasharray:u}),l&&t("text",{x:"left"===c?4:"center"===c?f.width/2:f.width-4,y:y-6,textAnchor:"left"===c?"start":"center"===c?"middle":"end",fontSize:g.typography.tickSize,fill:a,fontFamily:g.typography.fontFamily,children:l})]},"ann-ythresh-"+o)}case"x-threshold":{const i=n.value;if(null==i||!h.x)return null;const r=h.x(i);if(null==r)return null;const a=qi(n,g),l=n.label,c=n.labelPosition||"top",u=null!==(s=n.strokeWidth)&&void 0!==s?s:1.5;return e("g",{opacity:n.opacity,children:[t("line",{x1:r,y1:0,x2:r,y2:f.height,stroke:a,strokeWidth:u,strokeDasharray:n.strokeDasharray||"6,4"}),l&&t("text",{x:r>.6*f.width?r-4:r+4,y:"bottom"===c?f.height-4:"center"===c?f.height/2:12,textAnchor:r>.6*f.width?"end":"start",fontSize:g.typography.tickSize,fill:a,fontFamily:g.typography.fontFamily,stroke:g.colors.background,strokeWidth:3,paintOrder:"stroke",children:l})]},"ann-xthresh-"+o)}case"band":{const i=null!=n.y0&&h.y?h.y(n.y0):null,r=null!=n.y1&&h.y?h.y(n.y1):null;if(null==i||null==r)return null;const s=Math.min(i,r),l=Math.abs(r-i),c=n.fill||qi(n,g),u=null!==(a=n.fillOpacity)&&void 0!==a?a:.1;return e("g",{opacity:n.opacity,children:[t("rect",{x:0,y:s,width:f.width,height:l,fill:c,fillOpacity:u}),n.label&&t("text",{x:f.width-4,y:Math.max(s,0)+13,textAnchor:"end",fontSize:g.typography.tickSize,fill:n.color||qi(n,g),fontFamily:g.typography.fontFamily,fontWeight:"bold",stroke:g.colors.background,strokeWidth:3,paintOrder:"stroke",children:n.label})]},"ann-band-"+o)}case"category-highlight":{if(!n.category||!h.o)return null;const e=h.o(n.category);if(null==e)return null;const r=h.o.bandwidth?h.o.bandwidth():40,s=qi(n,g),a=null!==(l=n.opacity)&&void 0!==l?l:.1;return t("rect","horizontal"===i.projection?{x:0,y:e,width:f.width,height:r,fill:s,opacity:a}:{x:e,y:0,width:r,height:f.height,fill:s,opacity:a},"ann-cathighlight-"+o)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:e,y:i}=function(t,e,n,o){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const n=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(n)return{x:n[0],y:n[1]}}return{x:Vi(t,e,n),y:Ui(t,e,o)}}(n,h,y,p);if(null==e||null==i)return null;const r="text"===n.type,s=null!==(c=n.dx)&&void 0!==c?c:r?0:30,a=null!==(u=n.dy)&&void 0!==u?u:r?0:-30,l=n.color||g.colors.text;if(!r){const r="callout"===n.type?"callout-circle":n.type,c="callout-circle"===r?{radius:null!==(d=n.radius)&&void 0!==d?d:12,radiusPadding:n.radiusPadding}:"callout-rect"===r?{width:n.width,height:n.height}:void 0;return t(pi,{noteData:Object.assign(Object.assign({x:e,y:i,dx:s,dy:a,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:r},c?{subject:c}:{}),{connector:n.connector||{end:"arrow"},color:l,disable:n.disable,opacity:n.opacity,strokeDasharray:n.strokeDasharray,className:n.className})},"ann-label-"+o)}return t("g",{children:t("text",{x:e+s,y:i+a,textAnchor:n.textAnchor||"start",fontSize:n.fontSize||g.typography.labelSize,fill:l,fontFamily:g.typography.fontFamily,fontWeight:n.fontWeight,opacity:n.opacity,strokeDasharray:n.strokeDasharray,children:n.label||n.title})},"ann-label-"+o)}default:return null}}function Ki(t){return Math.max(0,Math.min(1,t))}function Ji(t){const e=t.trim();if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t.split("").map(t=>t+t).join("")),6===t.length&&/^[0-9a-f]{6}$/i.test(t))return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const n=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(n){const t=[Number(n[1]),Number(n[2]),Number(n[3])];if(t.every(Number.isFinite))return t}return null}function tr(t,e,n){const o=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(n)}`}function er(t,e){const n=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Ki(t.offset),color:t.color})).sort((t,e)=>t.offset-e.offset);if(0===n.length)return"#999999";if(1===n.length)return n[0].color;const o=Ki(e);if(n[0].offset>=o)return n[0].color;if(o>=n[n.length-1].offset)return n[n.length-1].color;for(let t=0;n.length-1>t;t++){const e=n[t],i=n[t+1];if(e.offset>o||o>i.offset)continue;const r=i.offset-e.offset,s=r>0?(o-e.offset)/r:0,a=Ji(e.color),l=Ji(i.color);if(!a||!l)return.5>s?e.color:i.color;const[c,u,d]=a,[h,f,g]=l;return tr(c+(h-c)*s,u+(f-u)*s,d+(g-d)*s)}return n[n.length-1].color}function nr(t,e,n){return`${t}-${e}`}function or(t){return"invalid-node-time"===t.kind?`node ${t.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===t.kind?`edge ${t.id} has an invalid startTime or endTime`:"invalid-domain"===t.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===t.kind?`edge ${t.id} must have a positive finite value`:"missing-node"===t.kind?`edge ${t.id} references missing ${t.endpoint} node "${t.nodeId}"`:"backward-edge"===t.kind?`edge ${t.id} (${t.source}->${t.target}) ends before it starts`:t.kind}function ir(t,e,n){const o=e.incoming[t.id],i=e.outgoing[t.id],r=[];for(const t of o)r.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:n.get(t.id).targetSide});for(const t of i)r.push({time:t.startTime,delta:-t.value,edge:t,kind:"out",side:n.get(t.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((t,e)=>{var n,o;return t.time-e.time||(null!==(n=s[t.kind])&&void 0!==n?n:99)-(null!==(o=s[e.kind])&&void 0!==o?o:99)})},l=r.length?function(t,e=1/0){let n=e;for(const e of t)n>e&&(n=e);return n}(r.map(t=>t.time)):null,c=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[0])?t.xExtent[0]:null,u=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,d=[...new Set(r.map(t=>t.time))].sort((t,e)=>t-e),h=new Map;for(let t=1;d.length>t;t++)h.set(d[t],d[t-1]);const f=t=>{const e=h.get(t);return null!=e?(e+t)/2:null!=u?u:t};a();const g=[];let y=0,p=0;for(const t of r)if("out"===t.kind){const e=Math.abs(t.delta);let n=e-("top"===t.side?y:p);if(n>0){const e="top"===t.side?"bot":"top",o=Math.min(n,"top"===e?y:p);if(o>0){const i=f(t.time);g.push({time:i,delta:-o,kind:"transfer-out",side:e}),g.push({time:i,delta:+o,kind:"transfer-in",side:t.side}),"top"===e?y-=o:p-=o,"top"===t.side?y+=o:p+=o,n-=o}n>0&&null!==u&&(g.push({time:u,delta:+n,kind:"create",side:t.side}),"top"===t.side?y+=n:p+=n)}"top"===t.side?y-=e:p-=e}else if("in"===t.kind){const e=Math.abs(t.delta);"top"===t.side?y+=e:p+=e}r.push(...g),a();let m=0,v=0,b=0,x=0,k=0;const w=[],A=new Map;for(const t of r){if(w.push({t:t.time,topMass:m,botMass:v}),("in"===t.kind||"out"===t.kind)&&t.edge){const e="top"===t.side?m:v;A.set(t.edge.id,{side:t.side,time:t.time,sideMassBefore:e,sideMassAfter:e+t.delta,kind:t.kind,value:Math.abs(t.delta)})}"top"===t.side?m+=t.delta:v+=t.delta,m+v>b&&(b=m+v),m>x&&(x=m),v>k&&(k=v),w.push({t:t.time,topMass:m,botMass:v})}const S=[];let M=0;for(;w.length>M;){let t=M;for(;w.length>t+1&&w[t+1].t===w[M].t;)t++;S.push(w[M]);for(let e=M+1;t>=e;e++){const t=S[S.length-1];w[e].topMass===t.topMass&&w[e].botMass===t.botMass||S.push(w[e])}M=t+1}const _=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;let P=null;for(const t of i)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===P||P>t.systemInTime)&&(P=t.systemInTime);let O=null;for(const t of o)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===O||t.systemOutTime>O)&&(O=t.systemOutTime);if(S.length>0){const t=S[S.length-1],e=Math.max(null!=_?_:-1/0,null!=O?O:-1/0);Number.isFinite(e)&&e>t.t&&t.topMass+t.botMass>0&&S.push({t:e,topMass:t.topMass,botMass:t.botMass});const n=S[0],o=Math.min(null!=c?c:1/0,null!=P?P:1/0);Number.isFinite(o)&&n.t>o&&n.topMass+n.botMass>0&&S.unshift({t:o,topMass:n.topMass,botMass:n.botMass})}return{samples:S,peak:b,topPeak:x,botPeak:k,localAttachments:A}}function rr(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function sr(t,e){return t.map(t=>({t:rr(t.t,e),topMass:t.topMass,botMass:t.botMass}))}function ar(t,e,n){const o=t.value*n;if("out"===t.kind){const i=t.sideMassBefore*n;if("top"===t.side){const t=e-i;return[t,t+o]}const r=e+i;return[r-o,r]}const i=t.sideMassAfter*n;if("top"===t.side){const t=e-i;return[t,t+o]}const r=e+i;return[r-o,r]}function lr(t,e){let n=0;for(let o=0;e.length>o;o++)for(let i=o+1;e.length>i;i++){const r=e[o],s=e[i];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&t[s.source]>t[r.source]!=t[s.target]>t[r.target]&&n++)}return n}function cr(t,e){let n=0;for(const o of e)n+=Math.abs(t[o.source]-t[o.target])*(o.value||1);return n}function ur(t,e){return 1e3*lr(t,e)+cr(t,e)}function dr(t,e){return{slots:t.map(t=>({peak:Object.assign({},t.peak),occupants:t.occupants.slice()})),map:Object.assign({},e)}}function hr(t,e,n){t.length>8||n.length>40?(function(t,e,n,o=6){const i=t.length;if(1>=i)return;let r=dr(t,e),s=ur(e,n);for(let a=0;o>a;a++){const o=Array(i).fill(0),a=Array(i).fill(0);for(const t of n){const n=e[t.source],i=e[t.target];o[n]+=i*(t.value||1),a[n]+=t.value||1,o[i]+=n*(t.value||1),a[i]+=t.value||1}const l=Array.from({length:i},(t,e)=>e).sort((t,e)=>(a[t]>0?o[t]/a[t]:t)-(a[e]>0?o[e]/a[e]:e)),c=l.map(e=>t[e]),u=new Map;l.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of c)t.push(e);const d=ur(e,n);if(s>d)s=d,r=dr(t,e);else if(d===s)break}!function(t,e,n){t.length=0;for(const e of n.slots)t.push(e);for(const t of Object.keys(e))delete e[t];for(const t of Object.keys(n.map))e[t]=n.map[t]}(t,e,r)}(t,e,n,6),function(t,e,n,o=6){const i=t.length;if(1>=i)return;let r=ur(e,n);for(let s=0;o>s;s++){let o=!1;for(let s=0;i-1>s;s++){const i=t[s];t[s]=t[s+1],t[s+1]=i;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s);const a=ur(e,n);if(r>a)r=a,o=!0;else{const n=t[s];t[s]=t[s+1],t[s+1]=n;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s)}}if(!o)break}}(t,e,n,6)):function(t,e,n){const o=t.length;if(1>=o)return;const i=Object.assign({},e),r=Object.keys(i),s=Array.from({length:o},(t,e)=>e),a=s.slice(),l=Object.assign({},i);let c=s.slice(),u=1/0;const d=()=>{for(const t of r)l[t]=a[i[t]];const t=ur(l,n);u>t&&(u=t,c=s.slice())},h=(t,e)=>{const n=s[t],o=s[e];s[t]=o,s[e]=n,a[n]=e,a[o]=t};d();const f=Array(o).fill(0);let g=0;for(;o>g;)g>f[g]?(h(g%2==0?0:f[g],g),d(),f[g]++,g=0):(f[g]=0,g++);const y=c.map(e=>t[e]),p=new Map;c.forEach((t,e)=>p.set(t,e));for(const t of Object.keys(e))e[t]=p.get(e[t]);t.length=0;for(const e of y)t.push(e)}(t,e,n)}function fr(t,e,n,o,i){var r,s,a,l,c,u,d,h;const{plotH:f,padding:g,valueScale:y,packing:p,laneOrder:m,lifetimeMode:v="full"}=i,b={},x={};for(const e of t)b[e.id]=n[e.id].topPeak||0,x[e.id]=n[e.id].botPeak||0;const k="half"===v,w={};for(const e of t){const t=Array.isArray(e.xExtent)?e.xExtent[0]:null,n=Array.isArray(e.xExtent)?e.xExtent[1]:null;let i=null!=t&&Number.isFinite(t)?t:1/0,r=null!=n&&Number.isFinite(n)?n:-1/0;for(const t of o.outgoing[e.id]){i>t.startTime&&(i=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&i>t.systemInTime&&(i=t.systemInTime);const e=k?(t.startTime+t.endTime)/2:t.endTime;e>r&&(r=e)}for(const t of o.incoming[e.id]){const e=k?(t.startTime+t.endTime)/2:t.startTime;i>e&&(i=e),t.endTime>r&&(r=t.endTime),null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>r&&(r=t.systemOutTime)}w[e.id]={start:Number.isFinite(i)?i:null,end:Number.isFinite(r)?r:null}}const A={},S=[];if("reuse"===p){const n=new Map;for(const e of t)n.set(e.id,0);const i=new Map;for(const e of t)i.set(e.id,0);for(const t of e)i.set(t.target,(null!==(r=i.get(t.target))&&void 0!==r?r:0)+1);const d=[];for(const e of t)0===(null!==(s=i.get(e.id))&&void 0!==s?s:0)&&d.push(e.id);for(;d.length;){const t=d.shift();for(const e of null!==(a=o.outgoing[t])&&void 0!==a?a:[]){const o=(null!==(l=n.get(t))&&void 0!==l?l:0)+1;o>(null!==(c=n.get(e.target))&&void 0!==c?c:0)&&n.set(e.target,o),i.set(e.target,i.get(e.target)-1),0===i.get(e.target)&&d.push(e.target)}}const h=[...t].filter(t=>null!==w[t.id].start).sort((t,e)=>{var o,i;const r=null!==(o=n.get(t.id))&&void 0!==o?o:0,s=null!==(i=n.get(e.id))&&void 0!==i?i:0;return r!==s?r-s:w[t.id].start-w[e.id].start}),f=t.filter(t=>null===w[t.id].start);for(const t of[...h,...f]){const e=w[t.id];let n=-1;for(let t=0;S.length>t;t++){const o=S[t].occupants[S[t].occupants.length-1];if(null===e.start||void 0===o||e.start>=o.end){n=t;break}}-1===n&&(S.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=S.length-1),S[n].occupants.push({id:t.id,end:null!==(u=null==e?void 0:e.end)&&void 0!==u?u:-1/0}),S[n].peak.topPeak=Math.max(S[n].peak.topPeak,b[t.id]),S[n].peak.botPeak=Math.max(S[n].peak.botPeak,x[t.id]),A[t.id]=n}}else t.forEach((t,e)=>{var n,o;S.push({occupants:[{id:t.id,end:null!==(o=null===(n=w[t.id])||void 0===n?void 0:n.end)&&void 0!==o?o:-1/0}],peak:{topPeak:b[t.id],botPeak:x[t.id]}}),A[t.id]=e});let M=null,_=null,P=null,O=null;const T=()=>{M=lr(A,e),P=cr(A,e)},$=()=>{_=lr(A,e),O=cr(A,e)};"crossing-min"===m?(T(),hr(S,A,e),$()):"inside-out"===m?(T(),function(t,e){const n=t.length;if(1>=n)return;const o=t=>t.peak.topPeak+t.peak.botPeak,i=t.map((t,e)=>({slot:t,idx:e})).sort((t,e)=>o(e.slot)-o(t.slot)),r=Array(n),s=Math.floor((n-1)/2);r[s]=i[0].idx;let a=s-1,l=s+1;for(let t=1;i.length>t;t++)t%2==1&&n>l||0>a?r[l++]=i[t].idx:r[a--]=i[t].idx;const c=r.map(e=>t[e]),u=new Map;r.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of c)t.push(e)}(S,A),$()):"crossing-min+inside-out"===m&&(T(),hr(S,A,e),function(t,e,n){const o=t.length;if(1>=o)return;const i=t.map(t=>{return{slot:t,size:(e=t,e.peak.topPeak+e.peak.botPeak)};var e}).sort((t,e)=>e.size-t.size),r=Math.floor((o-1)/2);let s=ur(e,n);for(const{slot:a}of i){const i=t.indexOf(a);if(0>i)continue;const l=r;if(i===l)continue;const c=t[i];t.splice(i,1),t.splice(l,0,c);const u=new Map;for(let t=0;o>t;t++)u.set(t,t);if(l>i){for(let t=i+1;l>=t;t++)u.set(t,t-1);u.set(i,l)}else{for(let t=l;i>t;t++)u.set(t,t+1);u.set(i,l)}for(const t of Object.keys(e))e[t]=u.get(e[t]);const d=ur(e,n);if(d>s){const n=t[l];t.splice(l,1),t.splice(i,0,n);const r=new Map;for(let t=0;o>t;t++)r.set(t,t);if(i>l){for(let t=l+1;i>=t;t++)r.set(t,t-1);r.set(l,i)}else{for(let t=i;l>t;t++)r.set(t,t+1);r.set(l,i)}for(const t of Object.keys(e))e[t]=r.get(e[t])}else s=d}}(S,A,e),$());const j=S.map(t=>{const e=new Map;for(const o of t.occupants){const t=n[o.id];if(t)for(const n of t.samples){const t=e.get(n.t)||{top:0,bot:0};e.set(n.t,{top:Math.max(t.top,n.topMass),bot:Math.max(t.bot,n.botMass)})}}return[...e.entries()].sort((t,e)=>t[0]-e[0])}),L=(t,e)=>{let n={top:0,bot:0};for(const[o,i]of t){if(o>e)break;n=i}return n},C=[];for(let t=0;S.length-1>t;t++){const e=j[t],n=j[t+1],o=new Set([...e.map(t=>t[0]),...n.map(t=>t[0])]);let i=0;for(const t of o){const o=L(e,t),r=L(n,t);o.bot+r.top>i&&(i=o.bot+r.top)}C.push(i)}const z=[];let D=g+(null!==(h=null===(d=S[0])||void 0===d?void 0:d.peak.topPeak)&&void 0!==h?h:0)*y;S.length>0&&z.push(D);for(let t=1;S.length>t;t++)D+=C[t-1]*y+g,z.push(D);if(S.length>0&&(D+=S[S.length-1].peak.botPeak*y+g),D>f){const t=f/D;for(let e=0;z.length>e;e++)z[e]*=t}const E=0===S.length?0:S[0].peak.topPeak+C.reduce((t,e)=>t+e,0)+S[S.length-1].peak.botPeak,R={};for(const e of t)R[e.id]=z[A[e.id]];return{effectiveSlotsHeight:E,centerlines:R,laneLifetime:w,slots:S,slotByNode:A,slotCenter:z,crossingsBefore:M,crossingsAfter:_,lengthBefore:P,lengthAfter:O}}function gr(t){const{nodes:e,edges:n,domain:o,plotW:i,plotH:r,ribbonLane:s,edgeOpacity:a,colorOf:l,layoutOpts:c}=t,u=function(t,e,n){const o=[],i=new Set(t.map(t=>t.id)),r=Array.isArray(n)&&2===n.length,s=r&&Number.isFinite(n[0])&&Number.isFinite(n[1]);r&&s&&s&&n[1]>=n[0]||o.push({kind:"invalid-domain"});for(const e of t)null!=e.xExtent&&(Array.isArray(e.xExtent)&&2===e.xExtent.length&&Number.isFinite(e.xExtent[0])&&Number.isFinite(e.xExtent[1])&&e.xExtent[1]>=e.xExtent[0]||o.push({kind:"invalid-node-time",id:e.id}));for(const t of e)i.has(t.source)||o.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),i.has(t.target)||o.push({kind:"missing-node",id:t.id,endpoint:"target",nodeId:t.target}),Number.isFinite(t.startTime)&&Number.isFinite(t.endTime)?(Number.isFinite(t.value)&&t.value>0||o.push({kind:"invalid-value",id:t.id}),t.endTime>t.startTime||o.push({kind:"backward-edge",id:t.id,source:t.source,target:t.target})):o.push({kind:"invalid-edge-time",id:t.id});return o}(e,n,o),d=x().domain(o).range([0,i]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:d};const h=function(t,e,n){var o;const{plotH:i,pairing:r="temporal",packing:s="reuse",laneOrder:a="crossing-min",lifetimeMode:l="half"}=n,c=function(t,e){const n={},o={};for(const e of t)n[e.id]=[],o[e.id]=[];for(const t of e)o[t.source]&&o[t.source].push(t),n[t.target]&&n[t.target].push(t);return{incoming:n,outgoing:o}}(t,e),u=function(t,e,n,o="value"){const i="temporal"===o?(t,e)=>t.endTime-e.endTime:(t,e)=>e.value-t.value,r="temporal"===o?(t,e)=>t.startTime-e.startTime:(t,e)=>e.value-t.value,s=new Map;for(const t of e)s.set(t.id,{});const a=(t,e)=>{const n=new Map;for(const o of t){const t=o[e];n.has(t)||n.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const i=n.get(t);i.edges.push(o),i.total+=o.value,i.earliestStart=Math.min(i.earliestStart,o.startTime),i.latestEnd=Math.max(i.latestEnd,o.endTime)}const s=[...n.values()];s.sort("temporal"===o?(t,n)=>"target"===e?t.earliestStart-n.earliestStart:t.latestEnd-n.latestEnd:(t,e)=>e.total-t.total);for(const t of s)t.edges.sort("target"===e?r:i);return s};for(const e of t){const t=n.outgoing[e.id],o=n.incoming[e.id];if(0===o.length)a(t,"target").forEach((t,e)=>{const n=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).sourceSide=n});else if(0===t.length)a(o,"source").forEach((t,e)=>{const n=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).targetSide=n});else{const e=a(o,"source"),n=a(t,"target"),i=Math.max(e.length,n.length);for(let t=0;i>t;t++){const o=t%2==0?"top":"bot";if(e[t])for(const n of e[t].edges)s.get(n.id).targetSide=o;if(n[t])for(const e of n[t].edges)s.get(e.id).sourceSide=o}}}return s}(t,e,c,r);let d={};for(const e of t)d[e.id]=ir(e,c,u);const h=fr(t,e,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),f=new Set;for(const t of e){const e=h.slotByNode[t.source],n=h.slotByNode[t.target];if(void 0===e||void 0===n)continue;const o=u.get(t.id);e!==n?e>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(f.add(t.id),o.sourceSide="bot",o.targetSide="bot")}for(const e of t){const t=c.outgoing[e.id],n=c.incoming[e.id],o=new Set(t.map(t=>u.get(t.id).sourceSide)),i=new Set(n.map(t=>u.get(t.id).targetSide));if(1===o.size&&n.length>0){const t=[...o][0];for(const e of n)h.slotByNode[e.source]===h.slotByNode[e.target]&&(u.get(e.id).targetSide=t)}if(1===i.size&&t.length>0){const e=[...i][0];for(const n of t)h.slotByNode[n.source]===h.slotByNode[n.target]&&(u.get(n.id).sourceSide=e)}}for(const e of t){const t=c.incoming[e.id],n=c.outgoing[e.id];if(0===t.length||0===n.length)continue;const o=()=>{const e={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of t)"top"===u.get(n.id).targetSide?e.inTop+=n.value:e.inBot+=n.value;for(const t of n)"top"===u.get(t.id).sourceSide?e.outTop+=t.value:e.outBot+=t.value;return e},i=(t,e)=>{const i=o(),r="top"===t?i.outTop-i.inTop:i.outBot-i.inBot,s="top"===e?i.inTop-i.outTop:i.inBot-i.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),l=n.filter(e=>!f.has(e.id)&&u.get(e.id).sourceSide===t&&a>=e.value).sort((t,e)=>e.value-t.value);return 0!==l.length&&(u.get(l[0].id).sourceSide=e,!0)};let r=n.length+1;for(;r-- >0&&(i("top","bot")||i("bot","top")););}d={};for(const e of t)d[e.id]=ir(e,c,u);const g=fr(t,e,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),y=null!==(o=g.effectiveSlotsHeight)&&void 0!==o?o:g.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),p=Math.min(12,.35*i/Math.max(g.slots.length+1,1)),m=y>0?Math.max(0,(i-p*(g.slots.length+1))/y):1,v=fr(t,e,d,c,{plotH:i,padding:p,valueScale:m,packing:s,laneOrder:a,lifetimeMode:l});return{nodeData:d,sides:u,valueScale:m,padding:p,compressedPadding:12>p,centerlines:v.centerlines,laneLifetime:v.laneLifetime,slots:v.slots,slotByNode:v.slotByNode,crossingsBefore:v.crossingsBefore,crossingsAfter:v.crossingsAfter,lengthBefore:v.lengthBefore,lengthAfter:v.lengthAfter}}(e,n,Object.assign({plotH:r},c)),{centerlines:f,nodeData:g,valueScale:y}=h,p=[],m=[];e.forEach((t,e)=>{var i;const r=g[t.id];if(!r||0===r.samples.length)return;const s=function(t,e,n,o,i){if(0===t.length)return null;const r=sr(t,i),s=t=>e-r[t].topMass*n,a=t=>e+r[t].botMass*n;let l=`M${o(r[0].t)},${s(0)}`;for(let t=1;r.length>t;t++)l+=` L${o(r[t].t)},${s(t)}`;l+=` L${o(r[r.length-1].t)},${a(r.length-1)}`;for(let t=r.length-2;t>=0;t--)l+=` L${o(r[t].t)},${a(t)}`;return l+" Z"}(r.samples,f[t.id],y,d,o);if(!s)return;const a=sr(r.samples,o),c=a.find(t=>t.topMass+t.botMass>0)||a[0],u=f[t.id]+(c.botMass-c.topMass)*y/2,m=l(t.id,e),v=function(t,e,n,o,i){const r=n.nodeData[t];if(!r||0===r.samples.length)return[];const s=n.valueScale,a=n.centerlines[t],l=sr(r.samples,i),c=l.find(t=>t.topMass+t.botMass>0)||l[0],u=[...l].reverse().find(t=>t.topMass+t.botMass>0)||l[l.length-1],d=o(c.t),h=o(u.t),f=t=>o(rr(t,i)),g=[],y=(t,e,n,o)=>`M${t},${e} L${n},${e} L${n},${o} L${t},${o} Z`;for(const n of e){if(n.source===t&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const t=r.localAttachments.get(n.id);if(t&&"out"===t.kind&&n.startTime>n.systemInTime){const e=f(n.systemInTime),o=f(n.startTime),i=e-20,r=Math.max(d,i);if(o>r){const[n,l]=ar(t,a,s);g.push({pathD:y(r,n,o,l),x0:i,x1:e,from:0,to:1})}}}if(n.target===t&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const t=r.localAttachments.get(n.id);if(t&&"in"===t.kind&&n.systemOutTime>n.endTime){const e=f(n.systemOutTime),o=f(n.endTime),i=e+20,r=Math.min(h,i);if(r>o){const[n,l]=ar(t,a,s);g.push({pathD:y(o,n,r,l),x0:e,x1:i,from:1,to:0})}}}}return g}(t.id,n,h,d,o);p.push(Object.assign(Object.assign({id:t.id,pathD:s,fill:m,stroke:m,strokeWidth:.5},v.length>0&&{gradientStubs:v}),{rawDatum:null!==(i=t.__raw)&&void 0!==i?i:t,labelX:d(c.t)-4,labelY:u,labelText:t.id}))});const v=new Map;return e.forEach((t,e)=>v.set(t.id,e)),n.forEach(t=>{var e,n,i,r;const c=null===(e=g[t.source])||void 0===e?void 0:e.localAttachments.get(t.id),u=null===(n=g[t.target])||void 0===n?void 0:n.localAttachments.get(t.id);if(!c||!u)return;const h=null!==(i=v.get(t.source))&&void 0!==i?i:0,p=l(t.source,h),b=function(t,e,n,o,i,r,s,a){const l=i,c=t=>a?Math.max(a[0],Math.min(a[1],t)):t,u=r(c(t.time)),d=r(c(n.time)),h=t.value*l,f=n.value*l,g=t.sideMassBefore*l,y=n.sideMassAfter*l;let p,m,v,b;"top"===t.side?(p=e-g,m=p+h):(m=e+g,p=m-h),"top"===n.side?(v=o-y,b=v+f):(b=o+y,v=b-f);const x="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:p,sBot:m,tx:d,tTop:v,tBot:b,cp1X:x,cp2X:x}}(c,f[t.source],u,f[t.target],y,d,s,o),{pathD:x,bezier:k}=Ln(b);m.push({id:t.id,pathD:x,fill:p,opacity:a,rawDatum:null!==(r=t.__raw)&&void 0!==r?r:t,bezier:k})}),{layout:h,layoutConfig:{bands:p,ribbons:m,showLabels:!0},issues:[],xScale:d}}const yr=t=>{var e,n;const{bands:o=[],ribbons:i=[],showLabels:r=!0}=t.config,s=[];for(const t of i)s.push(Object.assign(Object.assign({type:"bezier",pathD:t.pathD},t.bezier&&{bezierCache:t.bezier}),{style:{fill:t.fill,opacity:t.opacity,stroke:"none"},datum:{__kind:"ribbon",data:t.rawDatum,id:t.id}}));for(const t of o)if(t.gradientStubs)for(let e=0;t.gradientStubs.length>e;e++){const n=t.gradientStubs[e];s.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:t.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:t.rawDatum,id:`${t.id}__stub${e}`}})}for(const t of o)s.push({type:"bezier",pathD:t.pathD,style:Object.assign(Object.assign({},t.gradientStubs&&t.gradientStubs.length>0?{fill:"none"}:{fill:t.fill,fillOpacity:.86}),{stroke:null!==(e=t.stroke)&&void 0!==e?e:t.fill,strokeWidth:null!==(n=t.strokeWidth)&&void 0!==n?n:.5}),datum:{__kind:"band",data:t.rawDatum,id:t.id}});const a=r?o.map(t=>({x:t.labelX,y:t.labelY,text:t.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:o.map(t=>({type:"circle",id:t.id,cx:-1e4,cy:-1e4,r:0,style:{fill:t.fill},datum:{__kind:"band",data:t.rawDatum,id:t.id}})),sceneEdges:s,labels:a}},pr=Object.freeze([]);function mr(t){if(!t)return pr;let e=!1;for(let n=0;t.length>n;n++){const o=t[n];if(null==o||"object"!=typeof o){e=!0;break}}if(!e)return t;const n=[];for(const e of t)null!=e&&"object"==typeof e&&n.push(e);return n}function vr(t){return Array.isArray(t)?t[0]:t}function br(t,e,n,o){return Object.assign({data:vr(t),x:e,y:n,__semioticHoverData:!0},o)}const xr={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 kr(t,e){return"function"==typeof e?e(t):t[e]}function wr(t,e){if(e)return e(t);if(null==t)return"";if("number"==typeof t){if(!Number.isFinite(t))return t+"";const e=Number.isInteger(t)?t:parseFloat(t.toPrecision(6));return Math.abs(e)>9999?e.toLocaleString():e+""}return t instanceof Date?t.toLocaleDateString():"object"==typeof t&&null!==t?void 0!==t.id?t.id+"":void 0!==t.name?t.name+"":JSON.stringify(t):t+""}function Ar(n={}){const{fields:o,title:i,format:r,style:s={},className:a=""}=n;return n=>{if(!n||"object"!=typeof n)return null;let l;const c=[];if(i){const t=kr(n,i);l=wr(t,r)}if(o&&o.length>0)o.forEach(t=>{let e,o,i;"string"==typeof t?(e=t,o=t,i=r):(e=t.label,o=t.accessor||t.key||"",i=t.format||r);const s=kr(n,o);c.push({label:e,value:wr(s,i)})});else if(!i){const t=["value","y","name","id","label"];for(const e of t)if(void 0!==n[e]){l=wr(n[e],r);break}if(!l){const t=Object.keys(n).filter(t=>!t.startsWith("_"));t.length>0&&(l=wr(n[t[0]],r))}}const u=Object.assign(Object.assign({},xr),s);return e("div",{className:("semiotic-tooltip "+a).trim(),style:u,children:[l&&t("div",{style:{fontWeight:c.length>0?"bold":"normal"},children:l}),c.map((t,n)=>e("div",{style:{marginTop:0===n&&l?"4px":0},children:[t.label&&e("span",{children:[t.label,": "]}),t.value]},n))]})}}function Sr(t,e){let n=0,o=e.length-1;for(;o>n;){const i=n+o+1>>1;e[i]>t?o=i-1:n=i}return e[n]}function Mr(t,e){let n=0,o=e.length-1;for(;o>n;){const i=n+o>>1;t>e[i]?n=i+1:o=i}return e[n]}function _r({width:e,height:n,totalWidth:o,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:d,binSize:h,snap:f,binBoundaries:g,snapDuring:y,streaming:p}){const m=i(null),v=i(null),b=i(d);b.current=d;const x=i(c);x.current=c;const k=r(()=>g?[...g].sort((t,e)=>t-e):void 0,[g]),w=i(k);w.current=k;const A=i(!1),S=i(null);return u(()=>{if(!m.current)return;const t=_t(m.current).select(".brush-g"),o="x"===l?Pt():"y"===l?Ot():Tt();return o.extent([[0,0],[e,n]]),o.on("brush end",i=>{if(A.current)return;const r=x.current;if(!r)return;if(!i.selection)return S.current=null,void b.current(null);let s,a;if("x"===l){const[t,e]=i.selection;s=[r.x.invert(t),r.x.invert(e)],a=[r.y.invert(n),r.y.invert(0)]}else if("y"===l){const[t,n]=i.selection;s=[r.x.invert(0),r.x.invert(e)],a=[r.y.invert(n),r.y.invert(t)]}else{const[[t,e],[n,o]]=i.selection;s=[r.x.invert(t),r.x.invert(n)],a=[r.y.invert(o),r.y.invert(e)]}if("bin"===f&&"y"!==l&&("end"===i.type||"brush"===i.type&&y)){const e=w.current;e&&e.length>0?s=function(t,e){return 0===e.length?t:[Sr(t[0],e),Mr(t[1],e)]}(s,e):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const n=r.x(s[0]),a=r.x(s[1]);if(A.current=!0,"x"===l)t.call(o.move,[n,a]);else if("xy"===l){const e=i.selection;t.call(o.move,[[n,e[0][1]],[a,e[1][1]]])}A.current=!1}const c={x:s,y:a};S.current=c,b.current(c)}),t.call(o),v.current=o,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),v.current=null}},[e,n,l,f,h,y]),u(()=>{if(!(p&&c&&v.current&&S.current))return;if(!m.current)return;if("y"===l)return;const t=S.current,e=c.x.domain()[0],n=_t(m.current).select(".brush-g");if(e>=t.x[1])return A.current=!0,n.call(v.current.move,null),A.current=!1,S.current=null,void b.current(null);let o=t.x[0],i=!1;if(e>t.x[0]){if(o=e,"bin"===f){const t=w.current;t&&t.length>0?o=Mr(e,t):h&&h>0&&(o=Math.ceil(e/h)*h)}if(o>=t.x[1])return A.current=!0,n.call(v.current.move,null),A.current=!1,S.current=null,void b.current(null);i=!0}const r=c.x(o),s=c.x(t.x[1]);if(A.current=!0,"x"===l)n.call(v.current.move,[r,s]);else{const e=c.y(t.y[1]),o=c.y(t.y[0]);n.call(v.current.move,[[r,e],[s,o]])}if(A.current=!1,i){const e={x:[o,t.x[1]],y:t.y};S.current=e,b.current(e)}},[c,p,l,f,h]),t("svg",{ref:m,width:o,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`})})}class Pr{constructor(t,e){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=null!==(n=null==e?void 0:e.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==e?void 0:e.chunkSize)&&void 0!==o?o:5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(t=mr(t),this.lastBoundedData===t)return;if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,o),bounded:!1}),e=o,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(t=mr(t),this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,o),bounded:!1}),e=o,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){null!=t&&"object"==typeof t&&(this.pushBuffer.push(t),this.scheduleFlush())}pushMany(t){if(0===t.length)return;let e=0;for(let n=0;t.length>n;n++){const o=t[n];null!=o&&"object"==typeof o&&(this.pushBuffer.push(o),e++)}0!==e&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function Or(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:o.createElement(o.Fragment,null,...e)}const Tr=o.createContext(null);function $r({value:e,children:n}){return t(Tr.Provider,{value:e,children:n})}function jr(e,n){return null!=e?t($r,{value:n,children:e}):e}function Lr(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>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 Cr(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function zr(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function Dr(t,e){const n=zr(t);if(!n)return!1;const o=zr(e);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}const Er=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Rr=new WeakMap;let Nr=0,Fr=!1,Wr=null,Br=null,Ir=null;function Yr(t,e){var n,o;if(!e)return e;const i=Er.exec(e);if(!i)return e;const r=t.canvas;if(!r)return(null===(n=i[2])||void 0===n?void 0:n.trim())||e;!function(){if(Fr)return;if("undefined"==typeof window||"undefined"==typeof document)return;Fr=!0;const t=()=>{Nr++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Wr=new MutationObserver(t),Wr.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Br=window.matchMedia("(prefers-color-scheme: dark)"),Ir=t,"function"==typeof Br.addEventListener?Br.addEventListener("change",Ir):"function"==typeof Br.addListener&&Br.addListener(Ir)}catch(t){}}();let s=Rr.get(r);s&&s.version===Nr||(s={version:Nr,map:new Map},Rr.set(r,s));const a=s.map.get(e);if(void 0!==a)return a;const l=getComputedStyle(r).getPropertyValue(i[1]).trim()||(null===(o=i[2])||void 0===o?void 0:o.trim())||e;return s.map.set(e,l),l}function Gr(t){switch(t){case"monotoneX":return B;case"monotoneY":return W;case"cardinal":return F;case"catmullRom":return N;case"step":return R;case"stepBefore":return E;case"stepAfter":return D;case"basis":return z;case"natural":return C;default:return null}}function Hr(t,e,n){return null==e?n:"string"!=typeof e?e:Yr(t,e)||n}function Xr(t,e,n,o,i,r,s){if("colorStops"in e){const n=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>n.length)return null;const a=t.createLinearGradient(o,i,r,s);for(const t of n)a.addColorStop(t.offset,t.color);return a}const{topOpacity:a,bottomOpacity:l}=e;if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,l)),d=t.createLinearGradient(o,i,r,s),[h,f,g]=function(t,e){const n=t.fillStyle,o="#010203";try{t.fillStyle=o,t.fillStyle=e}catch(e){return t.fillStyle=n,[78,121,167]}const i=t.fillStyle;if(t.fillStyle=n,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===o&&e.trim().toLowerCase()!==o)return[78,121,167];if(i.startsWith("#"))return[parseInt(i.slice(1,3),16),parseInt(i.slice(3,5),16),parseInt(i.slice(5,7),16)];const r=i.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}(t,n);return d.addColorStop(0,`rgba(${h},${f},${g},${c})`),d.addColorStop(1,`rgba(${h},${f},${g},${u})`),d}function qr(t,e,n,o,i,r){const s=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>s.length)return null;const a=t.createLinearGradient(n,o,i,r);for(const t of s)a.addColorStop(t.offset,t.color);return a}const Vr=new WeakMap;function Ur(t,e){const n=Gr(e);if(!n)return t;const o=Vr.get(t);if(o)return o;const i=function(t,e,n=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const o=[];let i=null;const r={moveTo(t,e){i=[t,e],o.push([t,e])},lineTo(t,e){i=[t,e],o.push([t,e])},bezierCurveTo(t,e,r,s,a,l){if(!i)return i=[a,l],void o.push([a,l]);const[c,u]=i;for(let i=1;n>=i;i++){const d=i/n,h=1-d;o.push([h*h*h*c+3*h*h*d*t+3*h*d*d*r+d*d*d*a,h*h*h*u+3*h*h*d*e+3*h*d*d*s+d*d*d*l])}i=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,n,r){i=[n,r],o.push([n,r])}};return I().x(t=>t[0]).y(t=>t[1]).curve(e).context(r)(t),o}(t,n);return Vr.set(t,i),i}function Zr(t,e,n,o=30,i,r=0){let s=null;if(i){const t=function(t,e,n,o,i,r=t=>t.x,s=t=>t.y,a=t=>t.r){const l=Math.max(o,i+5,12),c=e-l,u=e+l,d=n-l,h=n+l;let f=null,g=1/0;return t.visit((t,i,l,y,p)=>{if(i>u||c>y||l>h||d>p)return!0;if(!t.length){let i=t;do{const t=i.data,l=r(t)-e,c=s(t)-n,u=Math.sqrt(l*l+c*c);Cr(a(t),o)>=u&&g>u&&(f=t,g=u),i=i.next}while(i)}return!1}),f?{node:f,distance:g}:null}(i,e,n,o,r);t&&(s={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const r of t){let t=null;switch(r.type){case"point":if(i)break;t=Kr(r,e,n,o);break;case"symbol":t=Jr(r,e,n,o);break;case"line":t=ts(r,e,n,o);break;case"rect":if(null==r.datum)break;t=ns(r,e,n);break;case"heatcell":t=os(r,e,n);break;case"area":if(!1===r.interactive)break;t=rs(r,e,n);break;case"candlestick":t=is(r,e,n)}t&&o>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function Qr(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const o=ss(t,e);if(0>o)return null;if(Math.abs(t[o][0]-e)>n)return null;let i=o,r=o;o>0&&t[o][0]>=e?(i=o-1,r=o):t.length-1>o&&(i=o,r=o+1);const[s,a]=t[i],[l,c]=t[r];return l===s?a:a+Math.max(0,Math.min(1,(e-s)/(l-s)))*(c-a)}function Kr(t,e,n,o=30){const i=e-t.x,r=n-t.y,s=Math.sqrt(i*i+r*r);return s>Cr(t.r,o)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Jr(t,e,n,o=30){const i=e-t.x,r=n-t.y,s=Math.sqrt(i*i+r*r);return s>Cr(Re(t.size),o)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function ts(t,e,n,o=30){var i,r;if(0===t.path.length)return null;const s=ss(t.path,e);if(0>s)return null;const[a,l]=t.path[s];let c;if(t.path.length>1){let o=1/0;const i=Math.max(0,s-1),r=Math.min(t.path.length-2,s);for(let s=i;r>=s;s++){const[i,r]=t.path[s],[a,l]=t.path[s+1],c=es(e,n,i,r,a,l);o>c&&(o=c)}c=o}else{const t=e-a,o=n-l;c=Math.sqrt(t*t+o*o)}const u=t.style,d=null!==(r=null!==(i=u.strokeWidth)&&void 0!==i?i:u.lineWidth)&&void 0!==r?r:1;return c>Math.max(5,d/2+2,o)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:a,y:l,distance:c}}function es(t,e,n,o,i,r){const s=i-n,a=r-o,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-o,2));let c=((t-n)*s+(e-o)*a)/l;c=Math.max(0,Math.min(1,c));const u=o+c*a;return Math.sqrt(Math.pow(t-(n+c*s),2)+Math.pow(e-u,2))}function ns(t,e,n){const o=Lr(e,n,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function os(t,e,n){const o=Lr(e,n,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function is(t,e,n){const o=t.bodyWidth/2,i=Math.min(t.openY,t.closeY);if(!(t.x-o-3>e||e>t.x+o+3||t.highY-3>n||n>t.lowY+3)){const o=i+Math.max(Math.max(t.openY,t.closeY)-i,1)/2,r=e-t.x,s=n-o;return{node:t,datum:t.datum,x:t.x,y:o,distance:Math.sqrt(r*r+s*s)}}return null}function rs(t,e,n){if(0===t.topPath.length)return null;const o=ss(t.topPath,e);if(0>o)return null;const[i,r]=t.topPath[o],s=e-i,a=n-r,l=Math.sqrt(s*s+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[o]?t.datum[o]:t.datum,x:i,y:r,distance:l}}function ss(t,e){if(0===t.length)return-1;let n=0,o=t.length-1;for(;o>n;){const i=n+o>>1;e>t[i][0]?n=i+1:o=i}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function as(t,e,n){const o=t.byGroup.get(e);let i=0,r=Math.abs(o[0].x-n.x);for(let t=1;o.length>t;t++){const e=Math.abs(o[t].x-n.x);r>e&&(r=e,i=t)}return o[i]._flatIndex}function ls(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}const cs={fresh:1,aging:.7,stale:.45,expired:.25},us={alpha:1,band:"fresh",isStale:!1};function ds(t,e){var n,o;if(!t||0>=e)return us;const i=null!=t.threshold&&t.threshold>0?t.threshold:5e3,r=t.graded;if(r){const t="object"==typeof r?r:{},o=function(t,e,n={}){var o,i,r;if(!Number.isFinite(e)||0>=e)return"fresh";if(Number.isNaN(t))return"fresh";if(t===1/0)return"expired";if(0>t)return"fresh";const s=null!==(o=n.fresh)&&void 0!==o?o:1,a=null!==(i=n.aging)&&void 0!==i?i:1.5,l=null!==(r=n.stale)&&void 0!==r?r:3;return e*s>t?"fresh":e*a>t?"aging":e*l>t?"stale":"expired"}(e,i,t.thresholds);return{alpha:Object.assign(Object.assign({},cs),null!==(n=t.opacities)&&void 0!==n?n:{})[o],band:o,isStale:"fresh"!==o}}return e>i?{alpha:null!==(o=t.dimOpacity)&&void 0!==o?o:.5,band:"stale",isStale:!0}:us}function hs({isStale:e,position:n}){return t("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===n?{top:4,left:4}:"bottom-left"===n?{bottom:4,left:4}:"bottom-right"===n?{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"})}const fs={fill:(e,n)=>t("rect",{style:e,width:n,height:n}),line:(e,n)=>t("line",{style:e,x1:0,y1:0,x2:n,y2:n})};function gs(t,e,n,o,i){let r;return r="function"==typeof n?n(t):(0,fs[n])(o(t,e),i),r}function ys({swatchSize:e}){return t("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 ps(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const ms=(n,o,i,r,s,a,l,c,u,d,h)=>{const{type:f="fill",styleFn:g,items:y}=n,p=[];let m=0;const v=!(!o&&!i),b="isolate"===d||void 0===d&&null!=s,{swatchSize:x,labelGap:k,rowHeight:w}=h;return y.forEach((n,d)=>{const h=gs(n,d,f,g,x),A=ps(n,r,s),S=s&&s.size>0&&s.has(n.label);p.push(e("g",{transform:`translate(0,${m})`,onClick:o?()=>o(n):void 0,onMouseEnter:i?()=>i(n):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:v?c===a&&d===l?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?S||!1:void 0,"aria-current":v&&!b&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:v?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o&&o(n)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const n=(d+("ArrowDown"===t.key?1:-1)+y.length)%y.length;u(c,n);const o=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:v?t=>{u(c,d),i&&i(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:v?t=>{i&&i(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[v&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+k+2+7*n.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),h,S&&t(ys,{swatchSize:x}),t("text",{y:x/2,x:x+k,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+d)),m+=w}),p};function vs({config:n,orientation:i="vertical",width:r=100}){const{colorFn:s,domain:a,label:l,format:c}=n,u=c||(t=>Math.round(100*t)/100+""),d="grad-legend-"+o.useId();if("horizontal"===i){const n=12,o=Math.min(r,200),i=Math.max(0,(r-o)/2),c=[];for(let e=0;64>=e;e++){const n=e/64;c.push(t("stop",{offset:100*n+"%",stopColor:s(a[0]+n*(a[1]-a[0]))},e))}return e("g",{"aria-label":l||"Gradient legend",children:[t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),l&&t("text",{x:i+o/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:l}),t("rect",{x:i,y:0,width:o,height:n,fill:`url(#${d})`,rx:2}),t("text",{x:i,y:n+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[0])}),t("text",{x:i+o,y:n+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[1])})]})}const h=[];for(let e=0;64>=e;e++){const n=e/64;h.push(t("stop",{offset:100*n+"%",stopColor:s(a[1]-n*(a[1]-a[0]))},e))}return e("g",{"aria-label":l||"Gradient legend",children:[l&&t("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:l}),t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:h})}),t("rect",{x:0,y:0,width:14,height:100,fill:`url(#${d})`,rx:2}),t("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[1])}),t("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[0])})]})}function bs(n){const{legendGroups:i,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,legendInteraction:c,title:u="Legend",width:d=100,height:h=20,orientation:f="vertical",legendLayout:g}=n,y=function(t){var e,n,o,i,r;const s=Math.max(1,null!==(e=null==t?void 0:t.swatchSize)&&void 0!==e?e:16),a=Math.max(s,null!==(n=null==t?void 0:t.rowHeight)&&void 0!==n?n:22);return{swatchSize:s,labelGap:Math.max(0,null!==(o=null==t?void 0:t.labelGap)&&void 0!==o?o:6),itemGap:Math.max(0,null!==(i=null==t?void 0:t.itemGap)&&void 0!==i?i:10),rowHeight:a,align:"left"===(null==t?void 0:t.align)?"start":"right"===(null==t?void 0:t.align)?"end":null!==(r=null==t?void 0:t.align)&&void 0!==r?r:"start",maxWidth:null==t?void 0:t.maxWidth}}(g),[p,m]=o.useState(0),[v,b]=o.useState(0),x=o.useCallback((t,e)=>{m(t),b(e)},[]),k="vertical"===f?(({legendGroups:e,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=24;const f=[];return e.forEach((e,g)=>{h+=5,f.push(t("line",{stroke:"gray",x1:0,y1:h,x2:n,y2:h},"legend-top-line legend-symbol-"+g)),h+=8,e.label&&(h+=16,f.push(t("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+g)),h+=8),f.push(t("g",{className:"legend-item",transform:`translate(0,${h})`,children:ms(e,o,i,r,s,a,l,g,c,u,d)},"legend-group-"+g)),h+=e.items.length*d.rowHeight+8}),f})({legendGroups:i||[],width:d,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:p,focusedItemIndex:v,onFocusedIndexChange:x,legendInteraction:c,metrics:y}):(({legendGroups:n,height:o,width:i,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:c,focusedItemIndex:u,onFocusedIndexChange:d,legendInteraction:h,metrics:f})=>{var g;let y=0;const p=[];n.forEach((n,o)=>{var g;let m=0;n.label&&(m+=16);const v=((n,o,i,r,s,a,l,c,u,d,h,f)=>{const{type:g="fill",styleFn:y,items:p}=n,m=[],{swatchSize:v,labelGap:b,itemGap:x,rowHeight:k,align:w}=h,A=!(!o&&!i),S="isolate"===d||void 0===d&&null!=s,M=p.map(t=>v+b+7*t.label.length),_=[];let P=0,O=0;M.forEach((t,e)=>{const n=0===O?t:O+x+t;f&&f>0&&O>0&&n>f?(_.push({start:P,end:e,width:O}),P=e,O=t):O=n}),p.length>0&&_.push({start:P,end:p.length,width:O}),_.forEach((n,d)=>{let h="center"===w?Math.max(0,((null!=f?f:n.width)-n.width)/2):"end"===w?Math.max(0,(null!=f?f:n.width)-n.width):0;for(let f=n.start;n.end>f;f++){const n=p[f],w=gs(n,f,g,y,v),_=ps(n,r,s),P=s&&s.size>0&&s.has(n.label);m.push(e("g",{transform:`translate(${h},${d*k})`,onClick:o?()=>o(n):void 0,onMouseEnter:i?()=>i(n):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:A?c===a&&f===l?0:-1:void 0,role:A?"option":void 0,"aria-selected":A&&S?P||!1:void 0,"aria-current":A&&!S&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:A?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o&&o(n)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const n=(f+("ArrowRight"===t.key?1:-1)+p.length)%p.length;u(c,n);const o=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:A?t=>{u(c,f),i&&i(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:A?t=>{i&&i(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:A?"pointer":"default",opacity:_,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[A&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:v+b+2+7*n.label.length,height:v+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),w,P&&t(ys,{swatchSize:v}),t("text",{y:v/2,x:v+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+f)),h+=M[f]+x}});const T=Math.max(0,..._.map(t=>t.width)),$=_.length;return{items:m,offset:T,totalRows:$,totalHeight:$*k}})(n,r,s,a,l,c,u,o,d,h,f,null!==(g=f.maxWidth)&&void 0!==g?g:i);m+=v.offset+5,p.push(Object.assign(Object.assign({label:n.label},v),{offset:m,totalRows:v.totalRows,totalHeight:v.totalHeight})),y+=m+12});const m=null!==(g=f.maxWidth)&&void 0!==g?g:i;let v=y>m?0:"center"===f.align?Math.max(0,(m-y)/2):"end"===f.align?Math.max(0,m-y):0;const b=[];return p.forEach((e,i)=>{const r=n[i];r.label&&(b.push(t("text",{transform:`translate(${v},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)),v+=16),b.push(t("g",{className:"legend-item",transform:`translate(${v},0)`,children:e.items},"legend-group-"+i)),v+=e.offset+5,n[i+1]&&b.push(t("line",{stroke:"gray",x1:v,y1:-8,x2:v,y2:(e.totalHeight||o)+0+8},"legend-top-line legend-symbol-"+i)),v+=12}),t("g",{children:b})})({legendGroups:i||[],title:u,height:h,width:d,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:p,focusedItemIndex:v,onFocusedIndexChange:x,legendInteraction:c,metrics:y}),w=!(!r&&!s);return e("g",{role:w?"listbox":void 0,"aria-multiselectable":!(!w||"isolate"!==c&&(void 0!==c||null==l))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==u&&""!==u&&"vertical"===f&&t("text",{className:"legend-title",y:16,x:d/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:u}),k]})}function xs(e){var n;const{legend:o,totalWidth:i,totalHeight:r,margin:s,legendPosition:a="right",legendLayout:l,title:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendInteraction:g}=e;if(!o)return null;const y="top"===a||"bottom"===a,p=!!c,m=Math.max(1,y?null!==(n=null==l?void 0:l.maxWidth)&&void 0!==n?n:Math.max(0,i-s.left-s.right):100);let v,b;return"left"===a?(v=Math.max(4,s.left-m-10),b=s.top):"top"===a?(v=s.left,b=p?32:8):"bottom"===a?(v=s.left,b=r-s.bottom+38):(v=i-s.right+10,b=s.top),t("g",{transform:`translate(${v}, ${b})`,children:Ct(o)?t(vs,{config:o.gradient,orientation:y?"horizontal":"vertical",width:m}):Lt(o)?t(bs,{legendGroups:o.legendGroups,title:"",width:m,orientation:y?"horizontal":"vertical",legendLayout:l,customHoverBehavior:u,customClickBehavior:d,highlightedCategory:h,isolatedCategories:f,legendInteraction:g}):o})}function ks(t){return"string"==typeof t?{type:t}:t}function ws({orient:n,config:o,values:i,scale:s,size:a,length:l}){const c=function(t){var e,n,o,i,r;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=t.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(i=t.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(o),u="top"===n||"bottom"===n,d=r(()=>{if(0===i.length)return null;const o=s.domain(),r=a-8;if("boxplot"===c.type){const o=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const o=e[Math.floor(.25*n)],i=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-o;return{q1:o,median:i,q3:r,whiskerLow:Math.max(e[0],o-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(i);if(!o)return null;const{q1:a,median:l,q3:d,whiskerLow:h,whiskerHigh:f}=o,g=Math.min(.5*r,20),y=(r-g)/2+4;if(u){const o=s(a),i=s(d),r=s(l),u=s(h),p=s(f),m="top"===n?-1:1,v=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:u,y1:v+m*(y+g/2),x2:p,y2:v+m*(y+g/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:u,y1:v+m*y,x2:u,y2:v+m*(y+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:p,y1:v+m*y,x2:p,y2:v+m*(y+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:Math.min(o,i),y:"top"===n?v-y-g:v+y,width:Math.abs(i-o),height:g,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:r,y1:"top"===n?v-y-g:v+y,x2:r,y2:"top"===n?v-y:v+y+g,stroke:c.fill,strokeWidth:2})]})}{const o=s(a),i=s(d),r=s(l),u=s(h),p=s(f),m="left"===n?-1:1,v=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:v+m*(y+g/2),y1:u,x2:v+m*(y+g/2),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:v+m*y,y1:u,x2:v+m*(y+g),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:v+m*y,y1:p,x2:v+m*(y+g),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:"left"===n?v-y-g:v+y,y:Math.min(o,i),width:g,height:Math.abs(i-o),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:"left"===n?v-y-g:v+y,y1:r,x2:"left"===n?v-y:v+y+g,y2:r,stroke:c.fill,strokeWidth:2})]})}}const d=K().domain(o).thresholds(c.bins)(i);if(0===d.length)return null;const h=In(d.map(t=>t.length));if(0===h)return null;if("histogram"===c.type)return t("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/h*r;if(u){const r=s(e.x0),a=s(e.x1)-s(e.x0);return t("rect",{x:r,y:"top"===n?-4-i:4,width:Math.max(a,.5),height:i,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},o)}{const r=s(e.x0),a=s(e.x1)-s(e.x0);return t("rect",{x:"left"===n?-4-i:4,y:Math.min(r,r+a),width:i,height:Math.abs(a),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},o)}})});if("violin"===c.type){const e=r/2+4,o=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*(r/2),a=s((t.x0+t.x1)/2);o.push(u?`${a},${"top"===n?-(e-i):e-i}`:`${"left"===n?-(e-i):e-i},${a}`)}for(let t=d.length-1;t>=0;t--){const i=d[t];if(null==i.x0||null==i.x1)continue;const a=i.length/h*(r/2),l=s((i.x0+i.x1)/2);o.push(u?`${l},${"top"===n?-(e+a):e+a}`:`${"left"===n?-(e+a):e+a},${l}`)}return t("g",{"data-testid":"marginal-violin-"+n,children:t("polygon",{points:o.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const e=[];if(u){const t=0,o=null!=d[0].x0?s(d[0].x0):0;e.push(`M${o},${t}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*r,i=s((t.x0+t.x1)/2);e.push(`L${i},${"top"===n?-o-4:o+4}`)}const i=null!=d[d.length-1].x1?s(d[d.length-1].x1):l;e.push(`L${i},${t}`),e.push("Z")}else{const t=0,o=null!=d[0].x0?s(d[0].x0):0;e.push(`M${t},${o}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*r,i=s((t.x0+t.x1)/2);e.push(`L${"left"===n?-o-4:o+4},${i}`)}const i=null!=d[d.length-1].x1?s(d[d.length-1].x1):l;e.push(`L${t},${i}`),e.push("Z")}return t("g",{"data-testid":"marginal-ridgeline-"+n,children:t("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[i,s,c,a,l,n,u,4]);return d?t("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}const As={linear:G,monotoneX:B,monotoneY:W,step:R,stepAfter:D,stepBefore:E,basis:z,cardinal:F,catmullRom:N};let Ss={positions:new Map};const Ms=new Set;function _s(){for(const t of Ms)t()}function Ps(t,e){const n=Ss.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const o=new Map(Ss.positions);o.delete(t),Ss={positions:o},_s()}function Os(t,e){const n=Ss.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const o=new Map(Ss.positions);o.delete(t),Ss={positions:o},_s()}function Ts(){return Ss}function $s(t){return Ms.add(t),()=>Ms.delete(t)}const js={positions:new Map};function Ls(){return()=>{}}function Cs(){return js}function zs(t,e,n){return"exact"===n?function(t,e){const n=t.domain(),o=n[0],i=n[n.length-1],r=o instanceof Date,s=o instanceof Date?o.getTime():o,a=i instanceof Date?i.getTime():i;if(2>e||s===a)return r?[new Date(s),new Date(a)]:[s,a];const l=(a-s)/(e-1),c=Array(e);for(let t=0;e>t;t++){const n=t===e-1?a:s+t*l;c[t]=r?new Date(n):n}return c}(t,e):t.ticks(e)}function Ds(t,e,n){if("edges"===t){if(e)return"start";if(n)return"end"}return"middle"}function Es(t,e,n){if("edges"===t){if(e)return"hanging";if(n)return"auto"}return"middle"}function Rs(t){if(0===t.length)return{min:null,max:null};let e=1/0,n=-1/0;for(const o of t)e>o.pixel&&(e=o.pixel),o.pixel>n&&(n=o.pixel);return{min:e,max:n}}function Ns(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Fs(t,e,n){if("left"===t||"right"===t){const o="left"===t?n:0,i="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+o;for(let t=0;r>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${o+4*i}`,s+=`L${Math.min(n,e)},${o}`}return s}{const o="bottom"===t?0:e,i="bottom"===t?1:-1,r=Math.ceil(n/8);let s=`M${o},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${o+4*i},${Math.min(8*t+4,n)}`,s+=`L${o},${Math.min(e,n)}`}return s}}function Ws(n){const{width:o,height:i,totalWidth:s,totalHeight:a,margin:l,scales:c,showAxes:u,axes:d,showGrid:h,xFormat:f,yFormat:g,axisExtent:y}=n,p=r(()=>{var t,e;if(!c)return[];const n=null==d?void 0:d.find(t=>"bottom"===t.orient),i=(null==n?void 0:n.tickFormat)||f||Bs,r=Math.max(2,Math.floor(o/70)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5,a=null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:zs(c.x,"exact"===y?Math.max(2,s):Math.min(s,r),y),l=a.map(t=>t.valueOf()),u=a.map((t,e)=>({value:t,pixel:c.x(t),label:i(t,e,l)})),h=u.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return Is(u,Math.max(55,h+8))},[c,d,f,o,y]),m=r(()=>{var t,e;if(!c)return[];const n=null==d?void 0:d.find(t=>"left"===t.orient),o=(null==n?void 0:n.tickFormat)||g||Bs,r=Math.max(2,Math.floor(i/30)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;return Is((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:zs(c.y,"exact"===y?Math.max(2,s):Math.min(s,r),y)).map(t=>({value:t,pixel:c.y(t),label:o(t)})),22)},[c,d,g,i,y]),v=h&&c,b=u&&c;if(!v&&!b)return null;const x=null==d?void 0:d.find(t=>"bottom"===t.orient),k=null==d?void 0:d.find(t=>"left"===t.orient),w=b&&(!x||!1!==x.baseline),A=b&&(!k||!1!==k.baseline),S=(null==x?void 0:x.jaggedBase)||!1,M=(null==k?void 0:k.jaggedBase)||!1,_="var(--semiotic-border, #ccc)";return t("svg",{width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e("g",{transform:`translate(${l.left},${l.top})`,children:[v&&(()=>{var n,r;const s=Ns(null===(n=null==d?void 0:d.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),a=Ns(null===(r=null==d?void 0:d.find(t=>"left"===t.orient))||void 0===r?void 0:r.gridStyle);return e("g",{className:"stream-grid",children:[p.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"xgrid-"+n)),m.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:o,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:a},"ygrid-"+n))]})})(),w&&!S&&t("line",{x1:0,y1:i,x2:o,y2:i,stroke:_,strokeWidth:1}),S&&t("path",{d:Fs("bottom",o,i),fill:"none",stroke:_,strokeWidth:1}),A&&!M&&t("line",{x1:0,y1:0,x2:0,y2:i,stroke:_,strokeWidth:1}),M&&t("path",{d:Fs("left",o,i),fill:"none",stroke:_,strokeWidth:1})]})})}function Bs(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function Is(t,e){if(2>=t.length)return t;const n=[t[0]];for(let o=1;t.length-1>o;o++)e>Math.abs(t[o].pixel-n[n.length-1].pixel)||n.push(t[o]);const o=t[t.length-1];return e>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function Ys(s){var a,c;const{width:d,height:h,totalWidth:f,totalHeight:g,margin:y,scales:p,showAxes:m,axes:v,xLabel:b,yLabel:x,yLabelRight:k,xFormat:w,yFormat:A,axisExtent:S,showGrid:M,title:_,legend:P,legendHoverBehavior:O,legendClickBehavior:T,legendHighlightedCategory:$,legendIsolatedCategories:j,legendPosition:L="right",legendLayout:C,foregroundGraphics:z,marginalGraphics:D,xValues:E,yValues:R,annotations:N,autoPlaceAnnotations:F,svgAnnotationRules:W,xAccessor:B,yAccessor:I,annotationData:H,pointNodes:X,curve:q,underlayRendered:V,canvasObscuresUnderlay:U=!0,linkedCrosshairName:Z,linkedCrosshairSourceId:Q,children:K}=s,J=r(()=>{var t,e;if(!m||!p)return[];const n=null==v?void 0:v.find(t=>"bottom"===t.orient),o=(null==n?void 0:n.tickFormat)||w||Bs,i=Math.max(2,Math.floor(d/70)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5,s=null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:zs(p.x,"exact"===S?Math.max(2,r):Math.min(r,i),S),a=s.map(t=>t.valueOf()),l=s.map((t,e)=>({value:t,pixel:p.x(t),label:o(t,e,a)})),c=l.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),u=(null==n?void 0:n.autoRotate)?Math.max(20,Math.min(c+8,55)):Math.max(55,c+8);let h=Is(l,u);if(h.length>1&&(h=h.filter((t,e)=>0===e||t.label+""!=h[e-1].label+"")),(null==n?void 0:n.includeMax)&&h.length>0&&"exact"!==S&&!(null==n?void 0:n.tickValues)){const t=p.x.domain()[1],e=p.x(t),n=h[h.length-1].pixel;if(Math.abs(e-n)>1){const i=o(t,h.length,a);u>e-n&&h.length>1&&(h=h.slice(0,-1)),h.push({value:t,pixel:e,label:i})}}return h},[m,p,v,w,d,S]),tt=r(()=>{var t,e;if(!m||!p)return[];const n=null==v?void 0:v.find(t=>"left"===t.orient),o=(null==n?void 0:n.tickFormat)||A||Bs,i=Math.max(2,Math.floor(h/30)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;let s=Is((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:zs(p.y,"exact"===S?Math.max(2,r):Math.min(r,i),S)).map(t=>({value:t,pixel:p.y(t),label:o(t)})),22);if(s.length>1&&(s=s.filter((t,e)=>0===e||t.label+""!=s[e-1].label+"")),(null==n?void 0:n.includeMax)&&s.length>0&&"exact"!==S&&!(null==n?void 0:n.tickValues)){const t=p.y.domain()[1],e=p.y(t),n=s[s.length-1].pixel;if(Math.abs(e-n)>1){const i=o(t);22>Math.abs(e-n)&&s.length>1&&(s=s.slice(0,-1)),s.push({value:t,pixel:e,label:i})}}return s},[m,p,v,A,h,S]),et=r(()=>{var t,e;if(!m||!p)return[];const n=null==v?void 0:v.find(t=>"right"===t.orient);if(!n)return[];const o=n.tickFormat||A||Bs,i=Math.max(2,Math.floor(h/30)),r=null!==(t=n.ticks)&&void 0!==t?t:5;return Is((null!==(e=n.tickValues)&&void 0!==e?e:zs(p.y,"exact"===S?Math.max(2,r):Math.min(r,i),S)).map(t=>({value:t,pixel:p.y(t),label:o(t)})),22)},[m,p,v,A,h,S]),nt=i(new Map),ot=i(null!==(a=null==N?void 0:N.length)&&void 0!==a?a:0),it=null!==(c=null==N?void 0:N.length)&&void 0!==c?c:0;ot.current!==it&&(ot.current=it,nt.current=new Map);const rt=r(()=>{if(!N||0===N.length)return null;const n=function(n,i,r){var s,a,l,c,u,d,h,f,g,y,p,m,v,b,x,k,w,A,S,M,_,P,O,T,$,j,L,C,z,D,E,R,N,F,W,B,I,H,X,q,V,U,Z,Q,K,J,tt,et,nt,ot,it;switch(n.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const e=Pi(n,i,r);if(!e)return null;const{x:o,y:c}=e;if(!Oi(o,c,r))return null;const u="callout"===n.type?"callout-circle":n.type,d="callout-circle"===u?{radius:null!==(s=n.radius)&&void 0!==s?s:12,radiusPadding:n.radiusPadding}:"callout-rect"===u?{width:n.width,height:n.height}:void 0;return t(pi,{noteData:Object.assign(Object.assign({x:o,y:c,dx:null!==(a=n.dx)&&void 0!==a?a:30,dy:null!==(l=n.dy)&&void 0!==l?l:-30,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:u},d?{subject:d}:{}),{connector:n.connector||{end:"arrow"},color:n.color,disable:n.disable,opacity:n.opacity,strokeDasharray:n.strokeDasharray,className:n.className})},"ann-"+i)}case"x-threshold":{const o=Ai(null!=n.value?Object.assign(Object.assign({},n),{x:n.value}):n,r);if(null==o)return null;const s=n.color||"#f97316",a=n.labelPosition||"top";let l;l="bottom"===a?(r.height||0)-4:"center"===a?(r.height||0)/2:12;const c=o>.6*(r.width||0),u=c?o-4:o+4,d=c?"end":"start";return e("g",{opacity:n.opacity,children:[t("line",{x1:o,y1:0,x2:o,y2:r.height||0,stroke:s,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:u,y:l,textAnchor:d,fill:s,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:n.label})]},"ann-"+i)}case"y-threshold":{const o=Si(null!=n.value?Object.assign(Object.assign({},n),{y:n.value}):n,r);if(null==o)return null;const s=n.color||"#f97316",a=n.labelPosition||"right";let l,c;return"left"===a?(l=4,c="start"):"center"===a?(l=(r.width||0)/2,c="middle"):(l=(r.width||0)-4,c="end"),e("g",{opacity:n.opacity,children:[t("line",{x1:0,y1:o,x2:r.width||0,y2:o,stroke:s,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:l,y:o-4,textAnchor:c,fill:s,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:n.label})]},"ann-"+i)}case"enclose":{const o=(n.coordinates||[]).map(t=>({x:Ai(Object.assign(Object.assign({},t),{type:"point"}),r),y:Si(Object.assign(Object.assign({},t),{type:"point"}),r),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const s=yt(o),a=n.padding||10;return e("g",{children:[t("circle",{cx:s.x,cy:s.y,r:s.r+a,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:s.x,y:s.y-s.r-a-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+i)}case"rect-enclose":{const o=(n.coordinates||[]).map(t=>({x:Ai(Object.assign(Object.assign({},t),{type:"point"}),r),y:Si(Object.assign(Object.assign({},t),{type:"point"}),r)})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const s=n.padding||10,a=o.map(t=>t.x),l=o.map(t=>t.y),[c,u]=Bn(a),[d,h]=Bn(l),f=c-s,g=u+s,y=d-s;return e("g",{children:[t("rect",{x:f,y:y,width:g-f,height:h+s-y,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:(f+g)/2,y:y-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+i)}case"highlight":{const e=r.data||[],o="function"==typeof n.filter?e.filter(n.filter):n.field&&null!=n.value?e.filter(t=>t[n.field]===n.value):[],s={stroke:n.color||"#f97316",strokeWidth:2,fill:"none"};return t("g",{children:o.map((e,o)=>{const i=Ai(e,r),a=Si(e,r);if(null==i||null==a)return null;const l="function"==typeof n.r?n.r(e):n.r||6,c="function"==typeof n.style?n.style(e):n.style||s;return t("circle",Object.assign({cx:i,cy:a,r:l},c),"hl-"+o)})},"ann-"+i)}case"bracket":{const e=Ai(n,r),o=Si(n,r);return t(pi,{noteData:{x:null!=e?e:0,y:null!=o?o:0,dx:n.dx||0,dy:n.dy||0,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"bracket",subject:{type:n.bracketType||"curly",width:n.width,height:n.height,depth:n.depth||30},color:n.color}},"ann-"+i)}case"trend":{const o=r.data||[];if(2>o.length)return null;const s=r.xAccessor||"x",a=r.yAccessor||"y",l="ordinal"===r.frameType,p="horizontal"===r.projection,m=l?s:null,v=l?a:null;let b;const x=[],k=new Map;if(l&&m&&v){for(const t of o){const e=t[m];if(null==e)continue;const n=e+"";k.has(n)||(k.set(n,x.length),x.push(n))}b=o.map(t=>{const e=t[m],n=t[v];if(null==e||null==n)return null;const o=k.get(e+"");return null!=o?[o,+n]:null}).filter(t=>null!==t)}else b=o.map(t=>[t[s],t[a]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>b.length)return null;const w=null!==(u=null===(c=r.scales)||void 0===c?void 0:c.x)&&void 0!==u?u:null===(d=r.scales)||void 0===d?void 0:d.time,A=null!==(f=null===(h=r.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(g=r.scales)||void 0===g?void 0:g.value;if(!w||!A)return null;const S=t=>e=>{const n=Math.max(0,Math.floor(e)),o=Math.min(x.length-1,n+1),i=e-n,r=t(x[n]);return r+(t(x[o])-r)*i},M=w,_=A;let P;if(l)if(p){const t=S(_);P=(e,n)=>[M(n),t(e)]}else{const t=S(M);P=(e,n)=>[t(e),_(n)]}else P=(t,e)=>[M(t),_(e)];const O=n.method||"linear";let T;T="loess"===O?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const o=t.slice().sort((t,e)=>t[0]-e[0]),i=o.map(t=>t[0]),r=o.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=i[t],o=i.map(t=>Math.abs(t-e)),l=o.slice().sort((t,e)=>t-e)[Math.min(s-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===l?0:o[t]/l;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*i[t],h+=e*r[t],f+=e*i[t]*i[t],g+=e*i[t]*r[t])}if(0===u){a.push([e,r[t]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))a.push([e,h/u]);else{const t=(u*g-d*h)/y;a.push([e,(h-t*d)/u+t*e])}}return a}(b,null!==(y=n.bandwidth)&&void 0!==y?y:.3):("polynomial"===O?$t.polynomial(b,{order:n.order||2}):$t.linear(b)).points;const $=T.map(([t,e])=>{const[n,o]=P(t,e);return`${n},${o}`}).join(" "),j=n.color||"#6366f1",L=T[T.length-1],[C,z]=P(L[0],L[1]);return e("g",{children:[t("polyline",{points:$,fill:"none",stroke:j,strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:C+4,y:z-4,fill:j,fontSize:11,children:n.label})]},"ann-"+i)}case"band":{const o=null!==(m=null===(p=r.scales)||void 0===p?void 0:p.y)&&void 0!==m?m:null===(v=r.scales)||void 0===v?void 0:v.value,s=null!==(b=null==o?void 0:o(n.y0))&&void 0!==b?b:0,a=null!==(x=null==o?void 0:o(n.y1))&&void 0!==x?x:r.height||0;return e("g",{opacity:n.opacity,children:[t("rect",{x:0,y:Math.min(s,a),width:r.width||0,height:Math.abs(a-s),fill:n.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:n.fillOpacity||.1}),n.label&&t("text",{x:(r.width||0)-4,y:Math.max(Math.min(s,a),0)+13,textAnchor:"end",fill:n.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:n.label})]},"ann-"+i)}case"envelope":{const o=r.data||[];if(2>o.length)return null;const s=r.xAccessor||"x",a=null!==(w=null===(k=r.scales)||void 0===k?void 0:k.x)&&void 0!==w?w:null===(A=r.scales)||void 0===A?void 0:A.time,l=null!==(M=null===(S=r.scales)||void 0===S?void 0:S.y)&&void 0!==M?M:null===(_=r.scales)||void 0===_?void 0:_.value;if(!a||!l)return null;const c=n.upperAccessor||"upperBounds",u=n.lowerAccessor||"lowerBounds",d=n.filter,h=o.filter(t=>null!=t[c]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[s]-e[s]);if(2>h.length)return null;const f=As[r.curve||"linear"]||G,g=Y().x(t=>a(t[s])).y0(t=>l(t[u])).y1(t=>l(t[c])).curve(f)(h);if(!g)return null;const y=n.fill||"#6366f1";return e("g",{children:[t("path",{d:g,fill:y,fillOpacity:null!==(P=n.fillOpacity)&&void 0!==P?P:.15,stroke:"none"}),n.label&&h.length>0&&t("text",{x:a(h[h.length-1][s])+4,y:l(h[h.length-1][c])-4,fill:y,fontSize:11,children:n.label})]},"ann-"+i)}case"anomaly-band":{const o=r.data||[];if(2>o.length)return null;const s=r.yAccessor||"y",a=null!==(T=null===(O=r.scales)||void 0===O?void 0:O.x)&&void 0!==T?T:null===($=r.scales)||void 0===$?void 0:$.time,l=null!==(L=null===(j=r.scales)||void 0===j?void 0:j.y)&&void 0!==L?L:null===(C=r.scales)||void 0===C?void 0:C.value;if(!a||!l)return null;const c=o.map(t=>t[s]).filter(t=>null!=t&&isFinite(t));if(2>c.length)return null;const u=c.reduce((t,e)=>t+e,0)/c.length,d=c.reduce((t,e)=>t+Math.pow(e-u,2),0)/c.length,h=Math.sqrt(d),f=null!==(z=n.threshold)&&void 0!==z?z:2,g=u-f*h,y=!1!==n.showBand,p=n.fill||"#6366f1",m=null!==(D=n.fillOpacity)&&void 0!==D?D:.1,v=n.anomalyColor||"#ef4444",b=null!==(E=n.anomalyRadius)&&void 0!==E?E:6,x=l(u+f*h),k=l(g),w=o.filter(t=>{const e=t[s];return null!=e&&Math.abs(e-u)>f*h});return e("g",{children:[y&&t("rect",{x:0,y:Math.min(x,k),width:r.width||0,height:Math.abs(k-x),fill:p,fillOpacity:m}),w.map((e,n)=>{const o=Ai(e,r),i=Si(e,r);return null==o||null==i?null:t("circle",{cx:o,cy:i,r:b,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5},"anomaly-"+n)}),n.label&&t("text",{x:(r.width||0)-4,y:Math.min(x,k)-4,textAnchor:"end",fill:p,fontSize:11,children:n.label})]},"ann-"+i)}case"forecast":{const o=r.data||[];if(3>o.length)return null;const s=r.xAccessor||"x",a=r.yAccessor||"y",l=null!==(N=null===(R=r.scales)||void 0===R?void 0:R.x)&&void 0!==N?N:null===(F=r.scales)||void 0===F?void 0:F.time,c=null!==(B=null===(W=r.scales)||void 0===W?void 0:W.y)&&void 0!==B?B:null===(I=r.scales)||void 0===I?void 0:I.value;if(!l||!c)return null;const u=o.map(t=>[t[s],t[a]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>u.length)return null;let d;if("polynomial"===(n.method||"linear")){const t=$t.polynomial(u,{order:n.order||2}).equation;d=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const t=u.length;let e=0,n=0,o=0,i=0;for(const[t,r]of u)e+=t,n+=r,o+=t*t,i+=t*r;const r=t*o-e*e;if(1e-12>Math.abs(r))return null;const s=(t*i-e*n)/r,a=(n-s*e)/t;d=t=>a+s*t}const h=u.length,f=u.map(([t,e])=>e-d(t)).reduce((t,e)=>t+e*e,0),g=Math.sqrt(f/Math.max(h-2,1)),y=u.reduce((t,e)=>t+e[0],0)/h,p=u.reduce((t,e)=>t+Math.pow(e[0]-y,2),0),m=null!==(H=n.confidence)&&void 0!==H?H:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(X=n.steps)&&void 0!==X?X:5,x=u[h-1][0],k=(x-u[0][0])/Math.max(h-1,1),w=[];for(let t=1;b>=t;t++)w.push(x+t*k);const A=[];for(const t of w){const e=d(t),n=g*Math.sqrt(1+1/h+(p>0?Math.pow(t-y,2)/p:0))*v;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const S=`M${A.map(t=>`${l(t.x)},${c(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${l(t.x)},${c(t.yLower)}`).join(" L")} Z`,M=A.map(t=>`${l(t.x)},${c(t.yCenter)}`).join(" "),_=`${l(x)},${c(d(x))}`,P=n.strokeColor||"#6366f1";return e("g",{children:[t("path",{d:S,fill:n.fill||"#6366f1",fillOpacity:null!==(q=n.fillOpacity)&&void 0!==q?q:.15,stroke:"none"}),t("polyline",{points:`${_} ${M}`,fill:"none",stroke:P,strokeWidth:null!==(V=n.strokeWidth)&&void 0!==V?V:2,strokeDasharray:null!==(U=n.strokeDasharray)&&void 0!==U?U:"6,3"}),n.label&&A.length>0&&t("text",{x:l(A[A.length-1].x)+4,y:c(A[A.length-1].yCenter)-4,fill:P,fontSize:11,children:n.label})]},"ann-"+i)}case"widget":{let e=null,o=null;if(null!=n.px&&null!=n.py)e=n.px,o=n.py;else{const t=Pi(n,i,r);if(!t)return null;e=t.x,o=t.y}if(null==e||null==o)return null;if(!Oi(e,o,r))return null;const s=null!==(Z=n.dx)&&void 0!==Z?Z:0,a=null!==(Q=n.dy)&&void 0!==Q?Q:0,l=null!==(K=n.width)&&void 0!==K?K:32,c=null!==(J=n.height)&&void 0!==J?J:32,u=null!==(tt=n.content)&&void 0!==tt?tt:t("span",{style:{fontSize:18,cursor:"default"},title:n.label||"Info",children:"ℹ️"});return t("foreignObject",{x:e+s-l/2,y:o+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+i)}case"text":{const s=Pi(n,i,r);if(!s)return null;const{x:a,y:l}=s,c=a+(n.dx||0),u=l+(n.dy||0),d=n.color||"var(--semiotic-text, #333)",h=t("text",{x:c,y:u,fill:d,fontSize:n.fontSize||11,opacity:n.opacity,strokeDasharray:n.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:n.label});return!0!==n._redundantConnector?o.cloneElement(h,{key:"ann-text-"+i}):e("g",{opacity:n.opacity,strokeDasharray:n.strokeDasharray,children:[t("line",{x1:a,y1:l,x2:c,y2:u,stroke:d,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),o.cloneElement(h,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+i)}case"category-highlight":{const o=n.category;if(null==o)return null;const s=t=>"function"==typeof t&&"function"==typeof t.bandwidth,a=null===(et=r.scales)||void 0===et?void 0:et.o,l=null===(nt=r.scales)||void 0===nt?void 0:nt.x,c=null===(ot=r.scales)||void 0===ot?void 0:ot.y,u=s(a)?a:s(l)?l:s(c)?c:null;if(!u)return null;const d=u(o+"");if(null==d)return null;const h=u.bandwidth(),f=n.color||"var(--semiotic-primary, #4589ff)",g=null!==(it=n.opacity)&&void 0!==it?it:.15,y=n.label;return e("g",(r.projection?"vertical"===r.projection:u===l)?{children:[t("rect",{x:d,y:0,width:h,height:r.height||0,fill:f,fillOpacity:g}),y&&t("text",{x:d+h/2,y:12,textAnchor:"middle",fill:f,fontSize:12,fontWeight:"bold",children:y})]}:{children:[t("rect",{x:0,y:d,width:r.width||0,height:h,fill:f,fillOpacity:g}),y&&t("text",{x:12,y:d+h/2,dominantBaseline:"middle",fill:f,fontSize:12,fontWeight:"bold",children:y})]},"ann-"+i)}default:return null}},i={scales:p?{x:p.x,y:p.y,time:p.x,value:p.y}:null,timeAxis:"x",xAccessor:B,yAccessor:I,width:d,height:h,data:H,frameType:"xy",pointNodes:X,curve:q,stickyPositionCache:nt.current};return function(t,e,n,o){const i=[];return t.forEach((t,r)=>{let s;if(n){const i=n(t,r,o);s=null!=i?i:e(t,r,o)}else s=e(t,r,o);s&&i.push({node:s,annotation:t})}),wi(i)}(F?Xi(Object.assign({annotations:N,context:i},"object"==typeof F?F:{})):N,n,W,i)},[N,F,W,d,h,B,I,H,p,X,q]),st=function(t){var e;const n=l(t?$s:Ls,t?Ts:Cs,t?Ts:Cs);return t&&null!==(e=n.positions.get(t))&&void 0!==e?e:null}(Z);return u(()=>{if(!(null==st?void 0:st.locked)||!Z)return;const t=t=>{"Escape"===t.key&&Os(Z)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==st?void 0:st.locked,Z]),m||_||P||z||D||rt&&rt.length>0||M||K||st?e("svg",{role:"img",width:f,height:g,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t("title",{children:"string"==typeof _?_:"XY Chart"}),t("desc",{children:"string"==typeof _?_+" — XY data visualization":"XY data visualization"}),e("g",{transform:`translate(${y.left},${y.top})`,children:[M&&p&&(!V||U)&&(()=>{var n,o;const i=Ns(null===(n=null==v?void 0:v.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),r=Ns(null===(o=null==v?void 0:v.find(t=>"left"===t.orient))||void 0===o?void 0:o.gridStyle);return e("g",{className:"stream-grid",children:[J.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:h,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"xgrid-"+n)),tt.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:d,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),m&&p&&(()=>{const n=null==v?void 0:v.find(t=>"left"===t.orient),o=null==v?void 0:v.find(t=>"bottom"===t.orient),i=!n||!1!==n.baseline,r=!o||!1!==o.baseline,s=(null==n?void 0:n.jaggedBase)||!1,a=(null==o?void 0:o.jaggedBase)||!1,l=null==o?void 0:o.landmarkTicks,c=null==n?void 0:n.landmarkTicks,u="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",g="var(--semiotic-text, #333)",p=!!(null==o?void 0:o.autoRotate)&&J.length>1&&(()=>{const t=d/Math.max(J.length-1,1),e=J.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0);return e+8>t})(),m={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},A={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},S=null==o?void 0:o.tickAnchor,M=null==n?void 0:n.tickAnchor,_=Rs(J),P=Rs(tt);return e("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[e("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!V||U)&&r&&!a&&t("line",{x1:0,y1:h,x2:d,y2:h,stroke:u,strokeWidth:1}),(!V||U)&&a&&t("path",{d:Fs("bottom",d,h),fill:"none",stroke:u,strokeWidth:1}),J.map((n,o)=>{const i=!!l&&("function"==typeof l?l(n.value,o):Dr(n.value,o>0?J[o-1].value:void 0));return e("g",{transform:`translate(${n.pixel},${h})`,children:[t("line",{y2:5,stroke:u,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{y:p?10:18,textAnchor:p?"end":Ds(S,n.pixel===_.min,n.pixel===_.max),fontWeight:i?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},i?w:m),transform:p?"rotate(-45)":void 0,children:n.label}):t("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"center",userSelect:"none"},m),children:n.label})})]},"xtick-"+o)}),b&&t("text",{x:d/2,y:h+40,textAnchor:"middle",fill:g,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:b})]}),e("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!V||U)&&i&&!s&&t("line",{x1:0,y1:0,x2:0,y2:h,stroke:u,strokeWidth:1}),(!V||U)&&s&&t("path",{d:Fs("left",d,h),fill:"none",stroke:u,strokeWidth:1}),tt.map((n,o)=>{const i=!!c&&("function"==typeof c?c(n.value,o):Dr(n.value,o>0?tt[o-1].value:void 0));return e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:u,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:-8,textAnchor:"end",dominantBaseline:Es(M,n.pixel===P.min,n.pixel===P.max),fontWeight:i?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},i?w:m),children:n.label}):t("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"right",userSelect:"none"},m),children:n.label})})]},"ytick-"+o)}),(()=>{const e=(null==n?void 0:n.label)||x;return e?t("text",{x:15-y.left,y:h/2,textAnchor:"middle",fill:g,transform:`rotate(-90, ${15-y.left}, ${h/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:e}):null})()]}),(()=>{const n=null==v?void 0:v.find(t=>"right"===t.orient);if(!n||0===et.length)return null;const o=!1!==n.baseline,i=n.landmarkTicks,r=n.label||k,s=n.tickAnchor,a=Rs(et);return e("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[o&&t("line",{x1:d,y1:0,x2:d,y2:h,stroke:u,strokeWidth:1}),et.map((n,o)=>{const r=!!i&&("function"==typeof i?i(n.value,o):Dr(n.value,o>0?et[o-1].value:void 0));return e("g",{transform:`translate(${d},${n.pixel})`,children:[t("line",{x2:5,stroke:u,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:8,textAnchor:"start",dominantBaseline:Es(s,n.pixel===a.min,n.pixel===a.max),fontWeight:r?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},r?w:m),children:n.label}):t("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"left",userSelect:"none"},m),children:n.label})})]},"ytick-r-"+o)}),r&&t("text",{x:d+y.right-15,y:h/2,textAnchor:"middle",fill:g,transform:`rotate(90, ${d+y.right-15}, ${h/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:r})]})})()]})})(),rt,D&&p&&E&&R&&e(n,{children:[D.top&&t("g",{transform:"translate(0, 0)",children:t(ws,{orient:"top",config:ks(D.top),values:E,scale:p.x,size:y.top,length:d})}),D.bottom&&t("g",{transform:`translate(0, ${h})`,children:t(ws,{orient:"bottom",config:ks(D.bottom),values:E,scale:p.x,size:y.bottom,length:d})}),D.left&&t("g",{transform:"translate(0, 0)",children:t(ws,{orient:"left",config:ks(D.left),values:R,scale:p.y,size:y.left,length:h})}),D.right&&t("g",{transform:`translate(${d}, 0)`,children:t(ws,{orient:"right",config:ks(D.right),values:R,scale:p.y,size:y.right,length:h})})]}),z,st&&st.sourceId!==Q&&(null==p?void 0:p.x)&&(()=>{const e=p.x(st.xValue);if(null==e||0>e||e>d)return null;const n=st.locked;return t("line",{x1:e,y1:0,x2:e,y2:h,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),K]}),_&&t("text",{x:f/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 _?_:null}),xs({legend:P,totalWidth:f,totalHeight:g,margin:y,legendPosition:L,title:_,legendLayout:C,legendHoverBehavior:O,legendClickBehavior:T,legendHighlightedCategory:$,legendIsolatedCategories:j})]}):null}const Gs="undefined"!=typeof window?h:u,Hs=()=>()=>{},Xs=()=>!1,qs=()=>!0;function Vs(t,e){const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))return!1;if(!Object.is(t[o],e[o]))return!1}return!0}function Us(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(!Object.is(t[n],e[n]))return!1;return!0}function Zs(t){if(null===t||"object"!=typeof t)return!1;if(Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}const Qs=o.createContext(null),Ks={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Js(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t){if(null===(null==e?void 0:e.datum))continue;const t=e.type+"";n[t]=(n[t]||0)+1}if(0===Object.keys(n).length)return e+", empty";const o=[],i={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},r=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((t,e)=>{const n=r.indexOf(t),o=r.indexOf(e);return(-1===n?999:n)-(-1===o?999:o)});for(const t of s)o.push(`${n[t]} ${i[t]||t}`);return`${e}, ${o.join(", ")}`}const ta=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""};function ea(t){const e={};if(null==t||"object"!=typeof t)return e;for(const[n,o]of Object.entries(t))n.startsWith("_")||null!=o&&""!==o&&("number"==typeof o?Number.isFinite(o)&&(e[n]=o):"string"==typeof o?e[n]=o:"boolean"==typeof o?e[n]=o+"":o instanceof Date&&(e[n]=o.toISOString().slice(0,10)));return e}const na="semiotic-accessible-data-table",oa=na+" semiotic-accessible-data-table-hidden",ia=na+" semiotic-accessible-data-table-visible",ra={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"},sa={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},aa={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)"},la={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},ca={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))"},ua={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},da={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},ha={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 fa({scene:n,chartType:i,tableId:r,chartTitle:s}){var a;const[l,c]=o.useState(!1),[u,d]=o.useState(5),h=o.useContext(Qs),f=null!==(a=null==h?void 0:h.visible)&&void 0!==a&&a,g=l||f,y=o.useRef(null),p=s?"Data summary for "+s:r?`Data summary for ${i} ${r}`:"Data summary for "+i;o.useEffect(()=>{g||d(5)},[g]);const m=o.useCallback(t=>{t.target===t.currentTarget&&(l||f||c(!0))},[l,f]),v=o.useCallback(t=>{var e;f||(null===(e=y.current)||void 0===e?void 0:e.contains(t.relatedTarget))||c(!1)},[f]);if(!n||0===n.length)return r?t("span",{id:r,tabIndex:-1,style:Ks}):null;if(!g)return t("div",{id:r,className:oa,tabIndex:-1,onFocus:m,style:Ks,role:"region","aria-label":p,children:e("button",{type:"button",onClick:()=>c(!0),children:["View data summary (",n.length," elements)"]})});const b=function(t){var e,n,o,i,r,s,a,l,c,u,d,h,f,g,y,p,m;const v=[];if(!Array.isArray(t))return v;const b=t.some(t=>t&&("line"===t.type||"area"===t.type));for(const x of t)if(x&&"object"==typeof x&&null!==x.datum)try{switch(x.type){case"point":if(b)break;v.push({label:"Point",values:ea(x.datum)});break;case"line":case"area":{const t=Array.isArray(x.datum)?x.datum:[],e="line"===x.type?"Line point":"Area point";for(const n of t)v.push({label:e,values:ea(n)});break}case"rect":{const t=null!=x.datum&&"object"==typeof x.datum?x.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:x.group)&&void 0!==n?n:"",s=null!==(i=null!==(o=t.value)&&void 0!==o?o:t.__aggregateValue)&&void 0!==i?i:t.total;v.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":{const t=ea(x.datum);null==t.value&&"number"==typeof x.value&&Number.isFinite(x.value)&&(t.value=x.value),v.push({label:"Cell",values:t});break}case"wedge":v.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(r=x.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(a=x.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=x.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":v.push({label:"Node",values:ea(x.datum)});break;case"arc":v.push({label:"Arc",values:ea(x.datum)});break;case"candlestick":v.push({label:"Candlestick",values:ea(x.datum)});break;case"geoarea":v.push({label:"Region",values:{name:null!==(y=null!==(f=null===(h=null===(d=x.datum)||void 0===d?void 0:d.properties)||void 0===h?void 0:h.name)&&void 0!==f?f:null===(g=x.datum)||void 0===g?void 0:g.name)&&void 0!==y?y:"",value:null!==(m=null===(p=x.datum)||void 0===p?void 0:p.value)&&void 0!==m?m:""}})}}catch(t){}return v}(n),x=function(t){if(!t||0===t.length)return[];const e=new Set;for(const n of t)if(n&&n.values)for(const t of Object.keys(n.values))e.add(t);const n=[];for(const o of e){const e=[],i=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[o];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&i.add(t+""))}if(e.length>0){let t=e[0],i=e[0],r=0;for(const n of e)t>n&&(t=n),n>i&&(i=n),r+=n;n.push({name:o,count:e.length,numeric:!0,min:t,max:i,mean:r/e.length})}else if(i.size>0){const t=Array.from(i);n.push({name:o,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(b),k=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${ta(t.min)} to ${ta(t.max)}, mean ${ta(t.mean)}.`);else{const e=t.uniqueValues,o=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${o}.`)}return n.join(" ")}(b.length,x),w=Math.min(u,b.length),A=b.slice(0,w),S=b.length-w,M=new Set;for(const t of A)for(const e of Object.keys(t.values))M.add(e);const _=Array.from(M);return e("div",{ref:y,id:r,className:ia,tabIndex:-1,onBlur:v,style:ra,role:"region","aria-label":p,children:[t("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{f&&h&&h.setVisible(!1),c(!1)},"aria-label":"Close data summary",style:aa,children:"×"}),t("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:sa,children:k}),e("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+i,style:la,children:[t("caption",{className:"semiotic-accessible-data-table-caption",style:da,children:S>0?`First ${w} of ${b.length} data points`:`All ${b.length} data points`}),t("thead",{children:e("tr",{children:[t("th",{style:ca,children:"type"}),_.map(e=>t("th",{style:ca,children:e},e))]})}),t("tbody",{children:A.map((n,o)=>e("tr",{children:[t("td",{style:ua,children:n.label}),_.map(e=>{return t("td",{style:ua,children:(o=n.values[e],null==o||""===o?"—":"number"==typeof o?Number.isNaN(o)?"—":ta(o):"boolean"==typeof o?o?"true":"false":"object"==typeof o?"—":o+"")},e);var o})]},o))})]}),S>0&&e("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>d(t=>t+25),style:ha,children:["Show ",Math.min(25,S)," more"," ",1===S?"row":"rows"," (",S," remaining)"]})]})}function ga({summary:e}){return e?t("div",{role:"note",style:Ks,children:e}):null}function ya({tableId:e}){return t("a",{href:"#"+e,style:Ks,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.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:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,Ks)},children:"Skip to data table"})}function pa({hoverPoint:e}){let n="";if(e){const t=e.data||e;n="object"==typeof t?"Data point: "+Object.entries(t).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Data point: "+t}return t("div",{"aria-live":"polite","aria-atomic":"true",style:Ks,children:n})}const ma="var(--semiotic-focus, #005fcc)";function va({active:e,hoverPoint:n,margin:o,size:i,shape:r="circle",width:s,height:a}){if(!e||!n)return null;const l=n.x+o.left,c=n.y+o.top;let u;if("rect"===r&&null!=s&&null!=a){const e=Math.max(s,4),n=Math.max(a,4);u=t("rect",{x:l-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:ma,strokeWidth:2,strokeDasharray:"4,2"})}else u=t("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:ma,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:ma,strokeWidth:2,strokeDasharray:"4,2"});return t("svg",{style:{position:"absolute",left:0,top:0,width:i[0],height:i[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function ba({x:e,y:n,containerWidth:i,containerHeight:r,margin:s,children:a,className:l="stream-frame-tooltip",zIndex:c=1}){const u=Number.isFinite(e)&&Number.isFinite(n),d=o.useRef(null),[h,f]=o.useState(null);o.useLayoutEffect(()=>{const t=d.current;if(!t)return;const e=t.getBoundingClientRect();f(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[a,l,i,r]);let g;g=h?`translate(${h.width+12>i-e?"calc(-100% - 12px)":"12px"}, ${h.height+12>r-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*i?"calc(-100% - 12px)":"12px"}, ${.3*r>n?"4px":"calc(-100% - 4px)"})`;const y=function(t){if(!o.isValidElement(t))return!1;const e=t.type;if("string"!=typeof e&&e&&!0===e.ownsChrome)return!0;const n=t.props;if("string"==typeof n.className&&n.className.trim().length>0)return!0;const i=n.style;if(i&&"object"==typeof i){if(null!=i.background&&""!==i.background)return!0;if(null!=i.backgroundColor&&""!==i.backgroundColor)return!0}return!1}(a),p=y?null:xr;return u?t("div",{ref:d,className:y?l:(l+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},p||{}),{position:"absolute",left:s.left+e,top:s.top+n,transform:g,pointerEvents:"none",zIndex:c,width:"max-content"}),children:a}):null}const xa="undefined"==typeof window?u:h;function ka(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function wa(t){const e=function(){const[t,e]=d(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return u(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(t.matches),function(t,e){if("function"==typeof t.addEventListener)return t.addEventListener("change",e),()=>t.removeEventListener("change",e);const n=t;return n.addListener(e),()=>n.removeListener(e)}(t,t=>e(t.matches))},[]),t}(),n=i(e);n.current=e;const[s,l]=function(t,e,n){const o=i(null),[r,s]=d(null);return u(()=>{if(!e&&!n)return;const t=o.current;if(!t)return;const i=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;s(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return i.observe(t),()=>i.disconnect()},[e,n]),[o,[e&&r?r.w:t[0],n&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),c=r(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),h=l[0]-c.left-c.right,f=l[1]-c.top-c.bottom,g=ka(t.foregroundGraphics,l,c),y=ka(t.backgroundGraphics,l,c),p=Ko(t=>t.theme),{transition:m,introEnabled:v}=function(t,e){var n,o;if(!1===t)return{transition:void 0,introEnabled:!1};const i="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:t?!0===t?{duration:300}:{duration:null!==(o=t.duration)&&void 0!==o?o:300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(i||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),b="semiotic-table-"+o.useId(),x=i(0),k=i(()=>{}),w=a(()=>{x.current||(x.current=requestAnimationFrame(()=>k.current()))},[]);u(()=>()=>{x.current&&(cancelAnimationFrame(x.current),x.current=0)},[]);const A=i(()=>{}),S=i(()=>{}),M=i(null),_=i(0),P=a(()=>{_.current=0;const t=M.current;M.current=null,t&&A.current(t)},[]),O=a(t=>{M.current={clientX:t.clientX,clientY:t.clientY},0===_.current&&(_.current=requestAnimationFrame(P))},[P]),T=a(()=>{M.current=null,0!==_.current&&(cancelAnimationFrame(_.current),_.current=0),S.current()},[]);u(()=>()=>{M.current=null,0!==_.current&&(cancelAnimationFrame(_.current),_.current=0)},[]);const $=t.themeDirtyRef;return xa(()=>{$&&(Nr++,$.current=!0,w())},[p,w,$]),{reducedMotion:e,reducedMotionRef:n,responsiveRef:s,size:l,margin:c,adjustedWidth:h,adjustedHeight:f,resolvedForeground:g,resolvedBackground:y,currentTheme:p,transition:m,introEnabled:v,tableId:b,rafRef:x,renderFnRef:k,scheduleRender:w,hoverHandlerRef:A,hoverLeaveRef:S,onPointerMove:O,onPointerLeave:T}}function Aa(t,e,n,o){const i=t.getContext("2d");if(!i)return null;const r=e[0]*o,s=e[1]*o,a=e[0]+"px",l=e[1]+"px";return t.style.width!==a&&(t.style.width=a),t.style.height!==l&&(t.style.height=l),t.width===r&&t.height===s||(t.width=r,t.height=s),i.setTransform(o,0,0,o,0,0),i.translate(n.left,n.top),i}function Sa(t,e,n){let o=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(o=n.color):t>n.value&&(o=n.color);return o}function Ma(t,e,n,o,i,r){if(2>e.length)return;const s=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],o=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=o,t.lineCap=r;for(let n=0;e.length-1>n;n++){const o=(s[n]+s[n+1])/2;let r=i;l>o&&(r*=o/l),l>a-o&&(r*=(a-o)/l),t.globalAlpha=Math.max(0,r),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}const _a=(t,e,n,o)=>{var i,r;const s=e.filter(t=>"line"===t.type);for(const a of s){if(2>a.path.length)continue;const l=a._introClipFraction;void 0!==l&&1>l&&(t.save(),t.beginPath(),t.rect(0,0,o.width*l,o.height),t.clip());const c=a.style.stroke||"#007bff",u=Yr(t,c)||c,d=a.style.strokeWidth||2,h=a.colorThresholds,f=a.rawValues;if(t.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(t.globalAlpha=a.style.opacity),t.lineWidth=d,t.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const m=null!==(i=a.style.opacity)&&void 0!==i?i:1;Ma(t,a.path,u,d,m,a.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const g=Gr(a.curve),y=h&&h.length>0&&f&&f.length===a.path.length,p=a._decayOpacities;if(p&&p.length===a.path.length&&!y){t.strokeStyle=u;const v=null!==(r=a.style.opacity)&&void 0!==r?r:1;for(let b=0;a.path.length-1>b;b++)t.globalAlpha=.5*(p[b]+p[b+1])*v,t.beginPath(),t.moveTo(a.path[b][0],a.path[b][1]),t.lineTo(a.path[b+1][0],a.path[b+1][1]),t.stroke()}else if(y){let x=null,k=null,w=null,A=null,S=!1;function M(e,n,o){t.beginPath(),t.strokeStyle=e,t.moveTo(n,o),S=!0}function _(){S&&(t.stroke(),S=!1)}for(let P=0;a.path.length>P;P++){const[O,T]=a.path[P],$=f[P],j=Sa($,h,u);if(null!==x&&null!==A&&null!==w){if(j===A)t.lineTo(O,T);else{const L=[];for(const C of h){const z=C.value;(w>z||z>$)&&(z>w||$>z)||w===z||$===z||L.push({t:(z-w)/($-w)})}L.sort((t,e)=>t.t-e.t);for(const D of L){const E=x+(O-x)*D.t,R=k+(T-k)*D.t,N=Sa(w+($-w)*Math.min(D.t+1e-4,1),h,u);t.lineTo(E,R),_(),M(N,E,R)}t.lineTo(O,T)}x=O,k=T,w=$,A=j}else M(j,O,T),x=O,k=T,w=$,A=j}_()}else{t.beginPath();const F=a.strokeGradient&&a.path.length>=2?qr(t,a.strokeGradient,a.path[0][0],0,a.path[a.path.length-1][0],0):null;if(t.strokeStyle=F||u,g)I().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(a.path);else{const[W,B]=a.path[0];t.moveTo(W,B);for(let Y=1;a.path.length>Y;Y++)t.lineTo(a.path[Y][0],a.path[Y][1])}t.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=a.style.fillOpacity,t.fillStyle=Hr(t,a.style.fill,a.style.fill),g&&!y)I().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(a.path);else{const[H,X]=a.path[0];t.moveTo(H,X);for(let q=1;a.path.length>q;q++)t.lineTo(a.path[q][0],a.path[q][1])}const G=a.path[0][0];t.lineTo(a.path[a.path.length-1][0],o.height),t.lineTo(G,o.height),t.closePath(),t.fill()}void 0!==l&&1>l&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function Pa(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function Oa(t,e,n=.3){Pa(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function Ta(t,e,n=.6){var o,i,r,s,a;if(!Pa(e))return;const l=null!==(o=e._pulseGlowRadius)&&void 0!==o?o:4,c=e.r+l*e._pulseIntensity,u=null!==(r=null!==(i=e.cx)&&void 0!==i?i:e.x)&&void 0!==r?r:0,d=null!==(a=null!==(s=e.cy)&&void 0!==s?s:e.y)&&void 0!==a?a:0;t.beginPath(),t.arc(u,d,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function $a(t,e,n,o=.35){Pa(e)&&(t.globalAlpha=e._pulseIntensity*o,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function ja(t,e){const n=Gr(e.curve);if(!n||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath()}else{const o=Y().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),o(e.topPath)}}const La=(t,e,n,o)=>{var i,r,s;const a=e.filter(t=>"area"===t.type);for(const e of a){if(2>e.topPath.length)continue;let n=!1;e.clipRect&&(t.save(),t.beginPath(),t.rect(e.clipRect.x,e.clipRect.y,e.clipRect.width,e.clipRect.height),t.clip(),n=!0);const a=e._introClipFraction;void 0!==a&&1>a&&(t.save(),t.beginPath(),t.rect(0,0,o.width*a,o.height),t.clip());const l=Hr(t,e.style.fill,"#4e79a7"),c=e._decayOpacities;if(c&&c.length===e.topPath.length){const n=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.7;t.fillStyle=l;for(let o=0;e.topPath.length-1>o;o++)t.globalAlpha=.5*(c[o]+c[o+1])*n,t.beginPath(),t.moveTo(e.topPath[o][0],e.topPath[o][1]),t.lineTo(e.topPath[o+1][0],e.topPath[o+1][1]),t.lineTo(e.bottomPath[o+1][0],e.bottomPath[o+1][1]),t.lineTo(e.bottomPath[o][0],e.bottomPath[o][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=Yr(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(c[n]+c[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const u=null!==(r=e.style.opacity)&&void 0!==r?r:1;if(ja(t,e),e.fillGradient&&("colorStops"in e.fillGradient&&e.fillGradient.colorStops.length>=2||"topOpacity"in e.fillGradient)&&e.fillGradient){let n=1/0;for(const t of e.topPath)n>t[1]&&(n=t[1]);let o=-1/0;for(const t of e.bottomPath)t[1]>o&&(o=t[1]);const i=Xr(t,e.fillGradient,"string"==typeof l?l:"#4e79a7",0,n,0,o);t.fillStyle=i||l,t.globalAlpha=u}else{const n=null!==(s=e.style.fillOpacity)&&void 0!==s?s:.7;t.globalAlpha=n*u,t.fillStyle=l}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(ja(t,e),$a(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=u;const n=e.strokeGradient&&e.topPath.length>=2?qr(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||Yr(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const o=Gr(e.curve);if(t.beginPath(),o)I().x(t=>t[0]).y(t=>t[1]).curve(o).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}void 0!==a&&1>a&&t.restore(),n&&t.restore(),t.globalAlpha=1}},Ca=(t,e,n,o)=>{var i,r;const s=e.filter(t=>"point"===t.type);if(0!==s.length){t.save();try{const e=t.globalAlpha;for(const n of s){t.beginPath(),t.arc(n.x,n.y,n.r,0,2*Math.PI);const o=null!==(r=null!==(i=n.style.opacity)&&void 0!==i?i:n.style.fillOpacity)&&void 0!==r?r:1;t.globalAlpha=e*o,t.fillStyle=Hr(t,n.style.fill,"#4e79a7"),t.fill(),n.style.stroke&&(t.strokeStyle=Hr(t,n.style.stroke,n.style.stroke),t.lineWidth=n.style.strokeWidth||1,t.stroke()),Ta(t,n)}}finally{t.restore()}}},za=new Map;function Da(t){var e;try{if(t.path)return new Path2D(t.path);const n=`${null!==(e=t.symbolType)&&void 0!==e?e:"circle"}:${Math.round(t.size)}`;let o=za.get(n);return o||(o=new Path2D(Ee(t.symbolType,t.size)),za.size>256&&za.clear(),za.set(n,o)),o}catch(t){return null}}const Ea=(t,e)=>{var n,o,i,r;const s=t.globalAlpha;for(const a of e){if("symbol"!==a.type)continue;const e=a;if(0>=e.size)continue;const l=Da(e);if(!l)continue;t.save(),t.translate(e.x,e.y),e.rotation&&t.rotate(e.rotation);const c=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*(null!==(o=e._decayOpacity)&&void 0!==o?o:1);e.style.fill&&(t.globalAlpha=s*c*(null!==(i=e.style.fillOpacity)&&void 0!==i?i:1),t.fillStyle=Hr(t,e.style.fill,"#4e79a7"),t.fill(l)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=s*c,t.strokeStyle=Hr(t,e.style.stroke,e.style.stroke),t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.stroke(l)),t.restore()}t.globalAlpha=s};function Ra(t,e){const{x:n,y:o,w:i,h:r}=e,{tl:s,tr:a,br:l,bl:c}=Lo(e);t.beginPath(),t.moveTo(n+s,o),t.lineTo(n+i-a,o),a>0&&t.arcTo(n+i,o,n+i,o+a,a),t.lineTo(n+i,o+r-l),l>0&&t.arcTo(n+i,o+r,n+i-l,o+r,l),t.lineTo(n+c,o+r),c>0&&t.arcTo(n,o+r,n,o+r-c,c),t.lineTo(n,o+s),s>0&&t.arcTo(n,o,n+s,o,s),t.closePath()}function Na(t){switch(t.roundedEdge){case"bottom":return{x0:t.x,y0:t.y+t.h,x1:t.x,y1:t.y};case"right":return{x0:t.x+t.w,y0:t.y,x1:t.x,y1:t.y};case"left":return{x0:t.x,y0:t.y,x1:t.x+t.w,y1:t.y};default:return{x0:t.x,y0:t.y,x1:t.x,y1:t.y+t.h}}}const Fa=(t,e,n,o)=>{const i=e.filter(t=>"rect"===t.type);for(const e of i){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)Wa(t,e);else if(e.cornerRadii&&jo(e.cornerRadii)){const n=Hr(t,e.style.fill,Yr(t,"var(--semiotic-primary, #007bff)")),o=Na(e),i=e.fillGradient&&"string"==typeof n?Xr(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n,Ra(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Yr(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const n=Hr(t,e.style.fill,Yr(t,"var(--semiotic-primary, #007bff)")),o=Na(e),i=e.fillGradient&&"string"==typeof n?Xr(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n;const r=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:s,y:a,w:l,h:c}=e;switch(e.roundedEdge){case"right":t.moveTo(s,a),t.lineTo(s+l-r,a),t.arcTo(s+l,a,s+l,a+r,r),t.lineTo(s+l,a+c-r),t.arcTo(s+l,a+c,s+l-r,a+c,r),t.lineTo(s,a+c);break;case"left":t.moveTo(s+l,a),t.lineTo(s+r,a),t.arcTo(s,a,s,a+r,r),t.lineTo(s,a+c-r),t.arcTo(s,a+c,s+r,a+c,r),t.lineTo(s+l,a+c);break;case"bottom":t.moveTo(s,a),t.lineTo(s+l,a),t.lineTo(s+l,a+c-r),t.arcTo(s+l,a+c,s+l-r,a+c,r),t.lineTo(s+r,a+c),t.arcTo(s,a+c,s,a+c-r,r);break;default:t.moveTo(s,a+c),t.lineTo(s,a+r),t.arcTo(s,a,s+r,a,r),t.lineTo(s+l-r,a),t.arcTo(s+l,a,s+l,a+r,r),t.lineTo(s+l,a+c)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Yr(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=Hr(t,e.style.fill,Yr(t,"var(--semiotic-primary, #007bff)")),o=Na(e),i=e.fillGradient&&"string"==typeof n?Xr(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Yr(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}Oa(t,e),t.globalAlpha=1}};function Wa(t,e){const n=e.style.icon,o=e.style.iconPadding||2,i=Math.min(e.w,e.h)-o;if(0>=i)return;const r=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),r){const r=i+o,s=e.x+(e.w-i)/2;for(let o=e.y+e.h-i;o>=e.y-i;o-=r)t.drawImage(n,s,o,i,i)}else{const r=i+o,s=e.y+(e.h-i)/2;for(let o=e.x;e.x+e.w>o;o+=r)t.drawImage(n,o,s,i,i)}t.restore()}function Ba(t){const[e,n,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*o>128?"#000":"#fff"}function Ia(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Ya=(t,e,n,o)=>{const i=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of i){const n=e.style;if(null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle=Yr(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),Oa(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const n=e.valueFormat?e.valueFormat(e.value):Ia(e.value),o=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),i=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=Ba(e.fill),t.font=o+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,i,r)}}}finally{t.restore()}},Ga=(t,e,n,o)=>{var i,r,s;for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const a=(null!==(i=e._decayOpacity)&&void 0!==i?i:1)*(null!==(s=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==s?s:1);1!==a&&(t.globalAlpha=a);const l=Yr(t,e.wickColor)||e.wickColor,c=60>o.height,u=c?Math.max(e.wickWidth,2):e.wickWidth,d=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=l,t.lineWidth=u,t.stroke()};if(c||d(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*o.height));t.fillStyle=l,t.beginPath(),t.arc(e.x,e.highY,n,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,n,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const n=Math.min(e.openY,e.closeY),o=Math.abs(e.openY-e.closeY),i=e.isUp?e.upColor:e.downColor,r=Yr(t,i)||i;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(o,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(o,1))}c&&d(),t.restore()}};function Ha(t,e,n,o){return"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:o,fn:e}:{key:void 0,fn:null}}const Xa=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function qa(t){const e=t[1]-t[0],n=3156e7;return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:n>e?t=>{const e=new Date(t);return`${Xa[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${Xa[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const Va={line:[La,_a,Ca],area:[La,Ca],stackedarea:[La,Ca],scatter:[Ca,Ea],bubble:[Ca,Ea],heatmap:[Ya],bar:[Fa],swarm:[Ca],waterfall:[(t,e,n,o)=>{var i;Fa(t,e);const r=e.filter(t=>"rect"===t.type);if(2>r.length)return;const s=r[0].datum,a=null==s?void 0:s._connectorStroke;if(a){t.save(),t.strokeStyle=Yr(t,a)||a,t.lineWidth=null!==(i=null==s?void 0:s._connectorWidth)&&void 0!==i?i:1,t.setLineDash([]);for(let e=0;r.length-1>e;e++){const o=r[e],i=r[e+1],s=o.datum,a=i.datum;if(null==(null==s?void 0:s.cumEnd)||null==(null==a?void 0:a.baseline))continue;const l=n.y(s.cumEnd),c=o.x+o.w,u=i.x;t.beginPath(),t.moveTo(c,l),t.lineTo(u,l),t.stroke()}t.restore()}}],candlestick:[Ga],mixed:[La,_a,Ca],custom:[La,Fa,Ya,_a,Ca,Ea,Ga]},Ua={top:20,right:20,bottom:30,left:40},Za={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"};function Qa(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],o=n[2],i=n[3];return`#${t}${t}${o}${o}${i}${i}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}const Ka={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Ja({hover:n}){var o,i,r;const s=t=>null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+"",a=null!==(o=n.data)&&void 0!==o?o:{},l=null!==(i=a.y)&&void 0!==i?i:a.value,c=null!==(r=a.x)&&void 0!==r?r:a.time;return e("div",{className:"semiotic-tooltip",style:Ka,children:[t("div",{style:{fontWeight:600,marginBottom:2},children:s(l)}),t("div",{style:{opacity:.7,fontSize:11},children:s(c)})]})}Ja.ownsChrome=!0;const tl=f(function(n,s){var c,h,f,p,m,v,b,x,k,w,A,S,M;const{chartType:_,runtimeMode:P,data:O,chunkThreshold:T,chunkSize:$,xAccessor:j,yAccessor:L,colorAccessor:C,sizeAccessor:z,symbolAccessor:D,symbolMap:E,groupAccessor:R,lineDataAccessor:N,curve:F,normalize:W,baseline:B,stackOrder:I,binSize:Y,valueAccessor:G,arrowOfTime:H="right",windowMode:X="sliding",windowSize:q=200,timeAccessor:V,xExtent:U,yExtent:Z,extentPadding:Q=.1,scalePadding:K,sizeRange:J,size:tt=[500,300],responsiveWidth:et,responsiveHeight:nt,margin:ot,className:it,background:rt,lineStyle:st,pointStyle:at,areaStyle:lt,barStyle:ct,waterfallStyle:ut,swarmStyle:dt,barColors:ht,colorScheme:ft,boundsAccessor:gt,boundsStyle:yt,y0Accessor:pt,band:mt,gradientFill:vt,lineGradient:bt,areaGroups:xt,openAccessor:kt,highAccessor:wt,lowAccessor:At,closeAccessor:St,candlestickStyle:Mt,showAxes:_t=!0,axes:Pt,xLabel:Ot,yLabel:Tt,yLabelRight:$t,xFormat:jt,yFormat:Lt,axisExtent:Ct,tickFormatTime:zt,tickFormatValue:Dt,hoverAnnotation:Et,tooltipContent:Rt,customHoverBehavior:Nt,customClickBehavior:Ft,enableHover:Wt,hoverRadius:Bt=30,tooltipMode:It,annotations:Yt,autoPlaceAnnotations:Gt,svgAnnotationRules:Ht,showGrid:Xt,legend:qt,legendHoverBehavior:Vt,legendClickBehavior:Ut,legendHighlightedCategory:Zt,legendIsolatedCategories:Qt,legendPosition:Kt,legendLayout:Jt,legendCategoryAccessor:te,onCategoriesChange:ee,backgroundGraphics:ne,foregroundGraphics:oe,canvasPreRenderers:ie,svgPreRenderers:re,title:se,categoryAccessor:ae,brush:le,onBrush:ce,decay:ue,pulse:de,transition:he,animate:fe,staleness:ge,heatmapAggregation:ye,heatmapXBins:pe,heatmapYBins:me,showValues:ve,heatmapValueFormat:be,marginalGraphics:xe,pointIdAccessor:ke,xScaleType:we,yScaleType:Ae,accessibleTable:Se=!0,description:Me,summary:_e,linkedCrosshairName:Pe,linkedCrosshairSourceId:Oe,customLayout:Te,layoutConfig:je,layoutSelection:Le}=n,Ce=g().replace(/:/g,""),ze=i(!1),De=i({w:-1,h:-1}),Ee=wa({sizeProp:tt,responsiveWidth:et,responsiveHeight:nt,userMargin:ot,marginDefault:Ua,animate:fe,transitionProp:he,themeDirtyRef:ze}),Re=function(){const[t,e]=d(!1);return Gs(()=>{e(!0)},[]),t}(),Ne=function(){const t=l(Hs,Xs,qs);return i(t).current}(),{reducedMotionRef:Fe,responsiveRef:We,size:Be,currentTheme:Ie,transition:Ye,introEnabled:Ge,tableId:Xe,rafRef:qe,renderFnRef:Ve,scheduleRender:Ue}=Ee;let Ze=Ee.margin;if(xe){const t=60,e=Object.assign({},Ee.margin);xe.top&&t>e.top&&(e.top=t),xe.bottom&&t>e.bottom&&(e.bottom=t),xe.left&&t>e.left&&(e.left=t),xe.right&&t>e.right&&(e.right=t),Ze=e}const Qe="function"==typeof oe?oe({size:Be,margin:Ze}):oe,Ke="function"==typeof ne?ne({size:Be,margin:Ze}):ne,Je=Be[0]-Ze.left-Ze.right,tn=Be[1]-Ze.top-Ze.bottom,en=r(()=>mr(O),[O]),nn=null!=Et?Et:Wt,on=i(null),rn=i(null),[sn,an]=d(0),ln=i(0),[cn,un]=d(null),dn=i(null),hn=i(null),[fn,gn]=d(null),yn=i(Za.primary),pn=i([]),mn=i(te),vn=i(ee);mn.current=te,vn.current=ee;const[bn,xn]=d(!1),[kn,wn]=d([]),[An,Sn]=d([]),Mn="streaming"===P||["bar","swarm","waterfall"].includes(_),_n=r(()=>{var t,e,n;return{chartType:_,runtimeMode:Mn?"streaming":"bounded",windowSize:q,windowMode:X,arrowOfTime:Mn?H:"right",extentPadding:Q,scalePadding:K,axisExtent:Ct,xAccessor:j,yAccessor:L,timeAccessor:Mn?V:void 0,valueAccessor:G,colorAccessor:C,sizeAccessor:z,symbolAccessor:D,symbolMap:E,groupAccessor:R||(N?"_lineGroup":void 0),categoryAccessor:ae,lineDataAccessor:N,xScaleType:we,yScaleType:Ae,xExtent:U,yExtent:Z,sizeRange:J,binSize:Y,normalize:W,baseline:B,stackOrder:I,boundsAccessor:gt,boundsStyle:yt,y0Accessor:pt,band:mt,gradientFill:!0===vt?{topOpacity:.8,bottomOpacity:.05}:!1===vt?void 0:vt,areaGroups:xt?new Set(xt):void 0,lineGradient:bt,openAccessor:kt,highAccessor:wt,lowAccessor:At,closeAccessor:St,candlestickStyle:Mt,lineStyle:st,pointStyle:at,areaStyle:lt,swarmStyle:dt,waterfallStyle:ut,colorScheme:ft,barColors:ht,barStyle:ct,annotations:Yt,decay:ue,pulse:de,transition:Ye,introAnimation:Ge,staleness:ge,heatmapAggregation:ye,heatmapXBins:pe,heatmapYBins:me,showValues:ve,heatmapValueFormat:be,pointIdAccessor:ke,curve:F,themeCategorical:null===(t=null==Ie?void 0:Ie.colors)||void 0===t?void 0:t.categorical,themeSemantic:Go(Ie),themeSequential:null===(e=null==Ie?void 0:Ie.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==Ie?void 0:Ie.colors)||void 0===n?void 0:n.diverging,customLayout:Te,layoutConfig:je,layoutMargin:Ze}},[_,q,X,H,Q,K,Ct,j,L,V,G,we,Ae,C,z,D,E,R,ae,N,U,Z,J,Y,W,B,I,gt,yt,pt,mt,vt,bt,xt,kt,wt,At,St,Mt,st,at,lt,dt,ut,ct,ft,ht,Yt,ue,de,null==Ye?void 0:Ye.duration,null==Ye?void 0:Ye.easing,Ge,ge,ye,pe,me,ve,be,Mn,ke,F,Ie,Te,je,Ze]),Pn=function(t){const e=i(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return Us(t,e);if(!Zs(t)||!Zs(e))return!1;const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))return!1;const n=t[o],i=e[o];if(!Object.is(n,i))if(Array.isArray(n)&&Array.isArray(i)){if(!Us(n,i))return!1}else{if(!Zs(n)||!Zs(i))return!1;if(!Vs(n,i))return!1}}return!0}(e.current,t)||(e.current=t),e.current}(_n),On=i(null);On.current||(On.current=new He(Pn));const Tn=a(()=>{var t,e;const n=mn.current,o=vn.current;if(!o||!n)return;const i=function(t,e){if(!e)return[];const n=new Set,o=[];for(const i of t){if(!i||"object"!=typeof i)continue;const t="function"==typeof e?e(i):i[e];if(null==t)continue;const r=t+"";n.has(r)||(n.add(r),o.push(r))}return o}(null!==(e=null===(t=On.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[],n);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(i,pn.current)||(pn.current=i,o(i))},[]);u(()=>{var t;null===(t=On.current)||void 0===t||t.updateConfig(Pn),ze.current=!0,Ue()},[Pn,Ue]);const $n=i(null);u(()=>{const t=On.current;if(!t)return;const e=null!=Le?Le:null;$n.current!==e&&($n.current=e,t.setLayoutSelection(e),t.hasCustomRestyle?t.restyleScene(e):ze.current=!0,Ue())},[Le,Ue]);const jn=i(null);jn.current||(jn.current=new Pr(t=>{const e=On.current;e&&e.ingest(t)&&(ze.current=!0,Ue())},{chunkThreshold:T,chunkSize:$})),u(()=>{var t;null===(t=jn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:T,chunkSize:$})},[T,$]);const Ln=a(t=>{var e;null===(e=jn.current)||void 0===e||e.push(t)},[]),Cn=a(t=>{var e;null===(e=jn.current)||void 0===e||e.pushMany(t)},[]),zn=a(()=>{var t,e;null===(t=jn.current)||void 0===t||t.clear(),null===(e=On.current)||void 0===e||e.clear(),ze.current=!0,Ue()},[Ue]);y(s,()=>({push:Ln,pushMany:Cn,remove:t=>{var e,n,o;null===(e=jn.current)||void 0===e||e.flush();const i=null!==(o=null===(n=On.current)||void 0===n?void 0:n.remove(t))&&void 0!==o?o:[];return i.length>0&&(dn.current&&i.some(t=>{var e;return t===(null===(e=dn.current)||void 0===e?void 0:e.data)})&&(dn.current=null,gn(null)),ze.current=!0,Ue()),i},update:(t,e)=>{var n,o,i;null===(n=jn.current)||void 0===n||n.flush();const r=null!==(i=null===(o=On.current)||void 0===o?void 0:o.update(t,e))&&void 0!==i?i:[];return r.length>0&&(ze.current=!0,Ue()),r},clear:zn,getData:()=>{var t,e,n;return null===(t=jn.current)||void 0===t||t.flush(),null!==(n=null===(e=On.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=On.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=On.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[Ln,Cn,zn,Ue]),u(()=>{var t,e;if(O){if(N&&en.length>0&&"object"==typeof en[0]&&null!==en[0]){const e="string"==typeof N?N:"coordinates";if(Array.isArray(en[0][e])){const n=[];for(const t of en){const o=t[e];if(Array.isArray(o)){const e=t.label||t.id||t.key;if(null!=e)for(const t of o)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of o)n.push(t)}}return void(null===(t=jn.current)||void 0===t||t.setBoundedData(n))}}null===(e=jn.current)||void 0===e||e.setBoundedData(en)}},[O,en,N]);const{hoverHandlerRef:Dn,hoverLeaveRef:En,onPointerMove:Rn,onPointerLeave:Nn}=Ee;Dn.current=t=>{var e,n,o,i;if(!nn)return;const r=on.current;if(!r)return;const s=r.getBoundingClientRect(),a=t.clientX-s.left-Ze.left,l=t.clientY-s.top-Ze.top;if(0>a||a>Je||0>l||l>tn)return void(dn.current&&(dn.current=null,hn.current=null,gn(null),Nt&&(Nt(null),ze.current=!0),Ue()));const c=On.current;if(!c||0===c.scene.length)return;const u=Zr(c.scene,a,l,Bt,c.quadtree,c.maxPointRadius),d="multi"===It,h=()=>{dn.current&&(dn.current=null,hn.current=null,gn(null),Nt&&Nt(null),Ue())};if(!u&&!d)return void h();const f=d||!u?a:u.x,g=d||!u?l:u.y,y=(null==u?void 0:u.datum)?$e(u.datum,c.resolvedRibbons):{},p=null===(n=null===(e=c.scales)||void 0===e?void 0:e.x)||void 0===n?void 0:n.invert,m="function"==typeof p?p(f):void 0;let v=br(y,f,g,null!=m?{xValue:m,xPx:f}:void 0);if(d&&c.scene.length>0&&c.scales){const t=function(t,e,n=30){const o=[];for(const i of t)if("line"===i.type){const t=i;if(2>t.path.length)continue;const r=Qr(Ur(t.path,t.curve),e,n);if(null===r)continue;const s=ss(t.path,e);o.push({node:i,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:t.path[s][0],y:r,group:t.group,color:t.style.stroke})}else if("area"===i.type){const t=i;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=Ur(t.topPath,t.curve),s=Ur(t.bottomPath,t.curve),a=Qr(r,e,n);if(null===a)continue;const l=Qr(s,e,n),c=ss(t.topPath,e);o.push({node:i,datum:Array.isArray(t.datum)&&t.datum[c]?t.datum[c]:t.datum,x:t.topPath[c][0],y:a,y0:null!=l?l:void 0,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return o}(c.scene,f,Math.max(Bt,Je));if(t.length>0){const e=c.scales.y.invert,n=yn.current,o=p?p(f):f;if(u)v.xValue=o,v.xPx=f;else{const t={xValue:o};"string"==typeof j&&(t[j]=o),v=br(t,f,g,{xValue:o,xPx:f})}v.allSeries=t.map(t=>{const o=e?e(t.y):t.y,i=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===_&&null!=i?o-i:o,valuePx:t.y,color:t.color||n,datum:$e(t.datum,c.resolvedRibbons)}})}}u||(null===(o=v.allSeries)||void 0===o?void 0:o.length)?(dn.current=v,hn.current=null!==(i=null==u?void 0:u.node)&&void 0!==i?i:null,gn(v),Nt&&(Nt(v),ze.current=!0),Ue()):h()},En.current=()=>{dn.current&&(dn.current=null,hn.current=null,gn(null),Nt&&(Nt(null),ze.current=!0),Ue())};const Fn=i(()=>{});Fn.current=t=>{var e,n;if(!Ft)return;const o=on.current;if(!o)return;const i=o.getBoundingClientRect(),r=t.clientX-i.left-Ze.left,s=t.clientY-i.top-Ze.top;if(0>r||r>Je||0>s||s>tn)return void Ft(null);const a=On.current;if(!a||0===a.scene.length)return void Ft(null);const l=Zr(a.scene,r,s,Bt,a.quadtree,a.maxPointRadius);if(!l)return void Ft(null);const c=l.datum||{},u=null===(n=null===(e=a.scales)||void 0===e?void 0:e.x)||void 0===n?void 0:n.invert,d="function"==typeof u?u(l.x):void 0;Ft(br(c,l.x,l.y,null!=d?{xValue:d,xPx:l.x}:void 0))};const Wn=a(t=>Fn.current(t),[]),Bn=i(-1),In=i(null),Yn=i(null),Gn=a(t=>{const e=On.current;if(!e||0===e.scene.length)return;const n=e.version;let o;if(Yn.current&&Yn.current.version===n)o=Yn.current.graph;else{const t=function(t){var e,n,o;const i=[];for(const r of t)switch(r.type){case"point":i.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=r.size)break;i.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"line":{const t=r,n=Array.isArray(t.datum)?t.datum:[],o=null!==(e=t.group)&&void 0!==e?e:"_default";for(let e=0;t.path.length>e&&n.length>e;e++)i.push({x:t.path[e][0],y:t.path[e][1],datum:n[e],shape:"circle",group:o});break}case"area":{const t=r,e=Array.isArray(t.datum)?t.datum:[],o=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.topPath.length>n&&e.length>n;n++)i.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:e[n],shape:"circle",group:o});break}case"rect":i.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:null!==(o=r.group)&&void 0!==o?o:"_default"});break;case"heatcell":i.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:"_default"})}return i.sort((t,e)=>t.x-e.x||t.y-e.y),i}(e.scene);if(0===t.length)return;o=function(t){var e,n;const o=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let i=o.get(t);i||(i=[],o.set(t,i)),i.push(n)}for(const t of o.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const i=Array.from(o.keys()).sort((t,e)=>{const n=o.get(t),i=o.get(e);return(n.length>0?n[0].y:0)-(i.length>0?i[0].y:0)}),r=Array.from(o.values()).flat();r.sort((t,e)=>t.x-e.x||t.y-e.y);const s=new Map;for(let t=0;r.length>t;t++){r[t]._flatIndex=t;const e=null===(n=r[t].datum)||void 0===n?void 0:n.id;null!=e&&s.set(e+"",t)}return{flat:r,groups:i,byGroup:o,idToIdx:s}}(t),Yn.current={version:n,graph:o}}const i=Bn.current;if(0>i){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Bn.current=0;const n=o.flat[0];In.current={shape:n.shape,w:n.w,h:n.h};const i=ls(Object.assign(Object.assign({},n),{datum:$e(n.datum,e.resolvedRibbons)}));return dn.current=i,gn(i),Nt&&Nt(i),void Ue()}const r=function(t,e){var n,o;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const i=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[i];return{flatIndex:i,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=r._groupIndex)&&void 0!==o?o:0}}(o,i),s=function(t,e,n){const{group:o,indexInGroup:i}=e,r=n.byGroup.get(o);switch(t){case"ArrowRight":return r.length-1>i?r[i+1]._flatIndex:e.flatIndex;case"ArrowLeft":return i>0?r[i-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(o);return n.groups.length-1>t?as(n,n.groups[t+1],r[i]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(o);return t>0?as(n,n.groups[t-1],r[i]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.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}}(t.key,r,o);if(null===s)return;if(t.preventDefault(),0>s)return Bn.current=-1,In.current=null,dn.current=null,hn.current=null,gn(null),Nt&&Nt(null),void Ue();Bn.current=s;const a=o.flat[s];In.current={shape:a.shape,w:a.w,h:a.h};const l=ls(Object.assign(Object.assign({},a),{datum:$e(a.datum,e.resolvedRibbons)}));dn.current=l,gn(l),Nt&&Nt(l),Ue()},[Nt,Ue]),Hn=a(t=>{Bn.current=-1,In.current=null,Rn(t)},[Rn]);Ve.current=()=>{qe.current=0;const t=on.current,e=rn.current;if(!t||!e)return;const n=On.current;if(!n)return;const o="undefined"!=typeof performance?performance.now():Date.now(),i=n.advanceTransition(Fe.current?o+1e6:o),r=!Fe.current&&i,s=De.current.w!==Je||De.current.h!==tn,a=ze.current||i||s;let l=!1;!a||r&&!s||(n.computeScene({width:Je,height:tn}),De.current={w:Je,h:tn},l=!0,Tn());const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(t){if(!t)return Za;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),o=e.getPropertyValue("--semiotic-text-secondary").trim(),i=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),s=o||e.getPropertyValue("--text-secondary").trim(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),c=i||e.getPropertyValue("--surface-0").trim();return s||a||n||r?{axisStroke:l||Za.axisStroke,tickText:s||Za.tickText,crosshair:s?Qa(s,"66"):Za.crosshair,hoverFill:c?Qa(c,"4D"):Za.hoverFill,hoverStroke:s?Qa(s,"99"):Za.hoverStroke,pointRing:c||Za.pointRing,primary:r||Za.primary}:Za}(t);yn.current=u.primary;const d=ds(ge,n.lastIngestTime>0?o-n.lastIngestTime:0),h=ge&&d.isStale;if(a){const e=Aa(t,Be,Ze,c);if(e){if(e.clearRect(-Ze.left,-Ze.top,Be[0],Be[1]),ge&&1>d.alpha&&(e.globalAlpha=d.alpha),"transparent"!==rt&&!ne){const n=getComputedStyle(t).getPropertyValue("--semiotic-bg").trim(),o=rt||(n&&"transparent"!==n?n:null),i=o?Yr(e,o):null;i&&(e.fillStyle=i,e.fillRect(-Ze.left,-Ze.top,Be[0],Be[1]))}if(e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Je,tn),e.clip()),ie&&n.scales)for(const t of ie)e.save(),t(e,n.scene,n.scales,{width:Je,height:tn}),e.restore();const o=Te?Va.custom:Va[_];if(o&&n.scales)for(const t of o)t(e,n.scene,n.scales,{width:Je,height:tn});e.restore(),ge&&1>d.alpha&&(e.globalAlpha=1)}}{const t=Aa(e,Be,Ze,c);if(t&&(t.clearRect(-Ze.left,-Ze.top,Be[0],Be[1]),nn&&dn.current&&n.scales&&function(t,e,n,o,i,r,s){var a;if(!1===i.crosshair)return;const l=e.allSeries,c=l&&l.length>0,u=null!==(a=e.xPx)&&void 0!==a?a:e.x;t.save();const d="object"==typeof i.crosshair?i.crosshair:{};if(t.strokeStyle=d.stroke||s.crosshair,t.lineWidth=d.strokeWidth||1,t.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(c?u:e.x,0),t.lineTo(c?u:e.x,o),t.stroke(),c||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),c){t.lineWidth=2,t.strokeStyle=s.pointRing;for(const e of l)null!=e.valuePx&&(t.beginPath(),t.arc(u,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||s.primary,t.fill(),t.stroke())}else{const n=i.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const n="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||n||null:n||e.stroke||null}(r)||s.primary;t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=n,t.fill(),t.strokeStyle=s.pointRing,t.lineWidth=2,t.stroke()}}(t,dn.current,Je,tn,"object"==typeof nn?nn:{},hn.current,u),hn.current&&Array.isArray(Et))){const e=Et.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,o,i){var r;if(!n)return;const s="group"in n?n.group:void 0;if(void 0!==s)for(const n of e){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const e="function"==typeof o.style?n.datum?o.style(n.datum):{}:o.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||i.primary,t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(r=e.opacity)&&void 0!==r?r:1,t.stroke(),t.restore()}}(t,n.scene,hn.current,e,u)}}a&&t&&t.setAttribute("aria-label",Js(n.scene,_+" chart"));const f=ze.current;if(ze.current=f&&r&&!l,f&&n.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!cn||t(cn.x.domain()[0])!==t(n.scales.x.domain()[0])||t(cn.x.domain()[1])!==t(n.scales.x.domain()[1])||t(cn.y.domain()[0])!==t(n.scales.y.domain()[0])||t(cn.y.domain()[1])!==t(n.scales.y.domain()[1])||cn.x.range()[0]!==n.scales.x.range()[0]||cn.x.range()[1]!==n.scales.x.range()[1]||cn.y.range()[0]!==n.scales.y.range()[0]||cn.y.range()[1]!==n.scales.y.range()[1])&&un(n.scales),xe){const t=n.getData(),e="function"==typeof j?j:t=>t[j||"x"],o="function"==typeof L?L:t=>t[L||"y"];wn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Sn(t.map(t=>o(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}!((Yt&&Yt.length>0||Te)&&(l||r))||!l&&33>o-ln.current||(an(t=>t+1),ln.current=o),(null==ge?void 0:ge.showBadge)&&xn(!!h),(r||null!=n.activeTransition||n.hasActivePulses)&&(qe.current=requestAnimationFrame(()=>Ve.current()))},function(t){const{hydrated:e,wasHydratingFromSSR:n,storeRef:o,dirtyRef:r,renderFnRef:s,cleanup:a}=t;Gs(()=>{var t,i;e&&n&&(null===(i=null===(t=o.current)||void 0===t?void 0:t.cancelIntroAnimation)||void 0===i||i.call(t)),r.current=!0,s.current()},[e,n]);const l=i(a);l.current=a,u(()=>()=>{var t;return null===(t=l.current)||void 0===t?void 0:t.call(l)},[])}({hydrated:Re,wasHydratingFromSSR:Ne,storeRef:On,dirtyRef:ze,renderFnRef:Ve,cleanup:()=>{var t;return null===(t=jn.current)||void 0===t?void 0:t.clear()}}),u(()=>{ze.current=!0,Ue()},[_,Je,tn,_t,rt,st,ie,Ue]),function(t,e,n,o,r,s){const a=i("fresh");u(()=>{if(!t)return;const i=setInterval(()=>{const i=e.current;if(!i||0===i.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=ds(t,l-i.lastIngestTime);c.band===a.current&&c.isStale===r||(a.current=c.band,c.isStale!==r&&s(c.isStale),n.current=!0,o())},1e3);return()=>clearInterval(i)},[t,r,o])}(ge,On,ze,Ue,bn,xn);const Xn=r(()=>{if(jt||zt)return;const t=On.current;return(null==t?void 0:t.xIsDate)&&cn?qa(cn.x.domain()):void 0},[jt,zt,cn]),qn=jt||zt||Xn,Vn=nn&&fn?Rt?Rt(fn):t(Ja,{hover:fn}):null,Un=Vn?t(ba,{x:fn.x,y:fn.y,containerWidth:Je,containerHeight:tn,margin:Ze,className:"stream-frame-tooltip",children:Vn}):null,Zn=In.current,Qn=t(va,{active:Bn.current>=0,hoverPoint:fn,margin:Ze,size:Be,shape:null==Zn?void 0:Zn.shape,width:null==Zn?void 0:Zn.w,height:null==Zn?void 0:Zn.h}),Kn=Ha(j,V,"__semiotic_resolvedX","__semiotic_resolvedTime"),Jn=Ha(L,G,"__semiotic_resolvedY","__semiotic_resolvedValue"),to=Kn.key,eo=Jn.key,no=function(t,e,n){return o=>{if(!o||!n||!t.fn&&!e.fn)return o;let i=!1;const r=o.map(n=>{const o=t.fn&&t.key&&!(t.key in n),r=e.fn&&e.key&&!(e.key in n);if(!o&&!r)return n;i=!0;const s=Object.assign({},n);return o&&(s[t.key]=t.fn(n)),r&&(s[e.key]=e.fn(n)),s});return i?r:o}}(Kn,Jn,Yt&&Yt.length>0||!1);if(Bo||!Re&&Ne){const n=On.current;n&&O&&(n.ingest({inserts:en,bounded:!0}),n.computeScene({width:Je,height:tn}));const i=null!==(c=null==n?void 0:n.scene)&&void 0!==c?c:[],r=null!==(h=null==n?void 0:n.scales)&&void 0!==h?h:null,s=qn||(()=>{if((null==n?void 0:n.xIsDate)&&r)return qa(r.x.domain())})();return e("div",{ref:We,className:"stream-xy-frame"+(it?" "+it:""),role:"img","aria-label":Me||("string"==typeof se?se:"XY chart"),style:{position:"relative",width:et?"100%":Be[0],height:nt?"100%":Be[1]},children:[t(ga,{summary:_e}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:Be[0],height:Be[1],style:{position:"absolute",left:0,top:0},children:[t("g",{transform:`translate(${Ze.left},${Ze.top})`,children:Ke}),e("g",{transform:`translate(${Ze.left},${Ze.top})`,children:[rt&&t("rect",{x:0,y:0,width:Je,height:tn,fill:rt}),re&&r&&re.map((e,n)=>t(o.Fragment,{children:e(i,r,{width:Je,height:tn})},"svgpre-"+n)),i.map((t,e)=>Fo(t,e,Ce)).filter(Boolean)]})]}),t(Ys,{width:Je,height:tn,totalWidth:Be[0],totalHeight:Be[1],margin:Ze,scales:r,showAxes:_t,axes:Pt,xLabel:Ot,yLabel:Tt,yLabelRight:$t,xFormat:s,yFormat:Lt||Dt,axisExtent:Ct,showGrid:Xt,title:se,legend:qt,legendHoverBehavior:Vt,legendClickBehavior:Ut,legendHighlightedCategory:Zt,legendIsolatedCategories:Qt,legendPosition:Kt,legendLayout:Jt,foregroundGraphics:Or(Qe,jr(null===(f=On.current)||void 0===f?void 0:f.customLayoutOverlays,null!=Le?Le:null)),marginalGraphics:xe,xValues:[],yValues:[],annotations:Yt,autoPlaceAnnotations:Gt,svgAnnotationRules:Ht,annotationFrame:0,xAccessor:to,yAccessor:eo,annotationData:no(null==n?void 0:n.getData()),pointNodes:null==n?void 0:n.scene.filter(t=>"point"===t.type),curve:"string"==typeof F?F:void 0,linkedCrosshairName:Pe,linkedCrosshairSourceId:Oe})]})}return e("div",{ref:We,className:"stream-xy-frame"+(it?" "+it:""),role:"group","aria-label":Me||("string"==typeof se?se:"XY chart"),tabIndex:0,style:{position:"relative",width:et?"100%":Be[0],height:nt?"100%":Be[1],overflow:"visible"},onKeyDown:Gn,children:[Se&&t(ya,{tableId:Xe}),Se&&t(fa,{scene:null!==(m=null===(p=On.current)||void 0===p?void 0:p.scene)&&void 0!==m?m:[],chartType:_+" chart",tableId:Xe,chartTitle:"string"==typeof se?se:void 0}),t(ga,{summary:_e}),t(pa,{hoverPoint:fn}),e("div",{role:"img","aria-label":Me||("string"==typeof se?se:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:nn?Hn:void 0,onMouseLeave:nn?Nn:void 0,onClick:Ft?Wn:void 0,children:[Ke&&t("svg",{style:{position:"absolute",left:0,top:0,width:Be[0],height:Be[1],pointerEvents:"none"},children:t("g",{transform:`translate(${Ze.left},${Ze.top})`,children:Ke})}),t(Ws,{width:Je,height:tn,totalWidth:Be[0],totalHeight:Be[1],margin:Ze,scales:cn,showAxes:_t,axes:Pt,showGrid:Xt,xFormat:qn,yFormat:Lt||Dt,axisExtent:Ct}),t("canvas",{ref:on,"aria-label":Js(null!==(b=null===(v=On.current)||void 0===v?void 0:v.scene)&&void 0!==b?b:[],_+" chart"),style:{position:"absolute",left:0,top:0}}),t("canvas",{ref:rn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t(Ys,{width:Je,height:tn,totalWidth:Be[0],totalHeight:Be[1],margin:Ze,scales:cn,showAxes:_t,axes:Pt,xLabel:Ot,yLabel:Tt,yLabelRight:$t,xFormat:qn,yFormat:Lt||Dt,axisExtent:Ct,showGrid:Xt,title:se,legend:qt,legendHoverBehavior:Vt,legendClickBehavior:Ut,legendHighlightedCategory:Zt,legendIsolatedCategories:Qt,legendPosition:Kt,legendLayout:Jt,foregroundGraphics:Or(Qe,jr(null===(x=On.current)||void 0===x?void 0:x.customLayoutOverlays,null!=Le?Le:null)),marginalGraphics:xe,xValues:kn,yValues:An,annotations:Yt,autoPlaceAnnotations:Gt,svgAnnotationRules:Ht,annotationFrame:sn,xAccessor:to,yAccessor:eo,annotationData:no(null===(k=On.current)||void 0===k?void 0:k.getData()),pointNodes:null===(w=On.current)||void 0===w?void 0:w.scene.filter(t=>"point"===t.type),curve:"string"==typeof F?F:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==rt&&!ne,linkedCrosshairName:Pe,linkedCrosshairSourceId:Oe}),(le||ce)&&t(_r,{width:Je,height:tn,totalWidth:Be[0],totalHeight:Be[1],margin:Ze,dimension:null!==(A=null==le?void 0:le.dimension)&&void 0!==A?A:"xy",scales:cn,onBrush:null!=ce?ce:()=>{},binSize:Y,snap:null==le?void 0:le.snap,binBoundaries:null!==(S=null==le?void 0:le.binBoundaries)&&void 0!==S?S:"bar"===_?null===(M=On.current)||void 0===M?void 0:M.getBinBoundaries():void 0,snapDuring:null==le?void 0:le.snapDuring,streaming:"streaming"===P}),(null==ge?void 0:ge.showBadge)&&t(hs,{isStale:bn,position:ge.badgePosition}),Qn,Un]})]})});tl.displayName="StreamXYFrame";const el=c(null);function nl(){return s(el)}function ol(t){const e=[];for(const[n,o]of Object.entries(t.fields))if("point"===o.type)e.push(t=>o.values.has(t[n]));else{const[t,i]=o.range;e.push(e=>{const o=e[n];return o>=t&&i>=o})}return t=>e.every(e=>e(t))}function il(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}function rl(t,e){if(t.type!==e.type)return!1;if("interval"===t.type&&"interval"===e.type)return t.range[0]===e.range[0]&&t.range[1]===e.range[1];if("point"===t.type&&"point"===e.type){if(t.values.size!==e.values.size)return!1;for(const n of t.values)if(!e.values.has(n))return!1;return!0}return!1}const[sl,al]=Io(t=>({selections:new Map,setClause(e,n){t(t=>{const o=t.selections.get(e),i=null==o?void 0:o.clauses.get(n.clientId);if(i&&function(t,e){if(t.clientId!==e.clientId||t.type!==e.type)return!1;const n=Object.entries(t.fields);if(n.length!==function(t){let e=0;for(const n in t)e++;return e}(e.fields))return!1;for(const[t,o]of n){const n=e.fields[t];if(!n||!rl(o,n))return!1}return!0}(i,n))return{};const r=new Map(t.selections),s=il(r,e),a=new Map(s.clauses);return a.set(n.clientId,n),r.set(e,Object.assign(Object.assign({},s),{clauses:a})),{selections:r}})},clearClause(e,n){t(t=>{const o=t.selections.get(e);if(!o||!o.clauses.has(n))return{};const i=new Map(t.selections),r=new Map(o.clauses);return r.delete(n),i.set(e,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},setResolution(e,n){t(t=>{const o=t.selections.get(e);if((null==o?void 0:o.resolution)===n)return{};const i=new Map(t.selections),r=il(i,e);return i.set(e,Object.assign(Object.assign({},r),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=t.selections.get(e);if(!n||0===n.clauses.size)return{};const o=new Map(t.selections);return o.set(e,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:o}})}})),[ll,cl]=Io(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));function ul(t){const e=g(),n=t.clientId||e,{name:o}=t,i=al(t=>t.selections.get(o)),s=al(t=>t.setClause),l=al(t=>t.clearClause),c=r(()=>!!i&&i.clauses.size>0,[i]);return{predicate:r(()=>i&&0!==i.clauses.size?function(t,e){const n=[];for(const[o,i]of t.clauses)"crossfilter"===t.resolution&&o===e||n.push(ol(i));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(i,n):()=>!0,[i,n]),isActive:c,selectPoints:a(t=>{const e={};let i=!1;for(const[n,o]of Object.entries(t))e[n]={type:"point",values:new Set(o)},i=!0;i&&s(o,{clientId:n,type:"point",fields:e})},[n,o,s]),selectInterval:a(t=>{const e={};let i=!1;for(const[n,o]of Object.entries(t))e[n]={type:"interval",range:o},i=!0;i&&s(o,{clientId:n,type:"interval",fields:e})},[n,o,s]),clear:a(()=>{l(o,n)},[l,o,n]),clientId:n}}const dl=c(!1),hl=c(null),fl="undefined"==typeof window?u:h;function gl(t,e,n){var o;const i=null!==(o=t.xValue)&&void 0!==o?o:null==e?void 0:e[n];if(null==i)return null;const r=Number(i);return Number.isFinite(r)?r:null}function yl(t){let e=t.data||t.datum||t;return Array.isArray(e)&&(e=e[0]),null!=t.xValue&&e&&"object"==typeof e&&!Array.isArray(e)&&null==e.xValue?Object.assign(Object.assign({},e),{xValue:t.xValue}):e||{}}function pl(t){if(!t)return!1;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}function ml(){var t;const e=Ko(t=>t.theme),n=null===(t=null==e?void 0:e.colors)||void 0===t?void 0:t.categorical;return n&&n.length>0?n:void 0}function vl({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:s,chartId:l,onClick:c,hoverHighlight:h,colorByField:f}){const y=g(),p=function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField,seriesField:t.seriesField}:null}(e,n),m="series"===(null==p?void 0:p.mode)?[p.seriesField||f||n[0]].filter(t=>!!t):(null==p?void 0:p.fields)||n||[],v=ul({name:(null==t?void 0:t.name)||"__unused__"}),b=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:o,isActive:i,selectPoints:r,clear:s}=ul({name:e}),l=a(t=>{if(!t)return void s();const e={};for(const o of n){const n=t[o];void 0!==n&&(e[o]=[n])}(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1})(e)&&r(e)},[n,r,s,e]);return{onHover:l,predicate:o,isActive:i}}({name:(null==p?void 0:p.name)||"hover",fields:m}),x=cl(t=>t.pushObservation),k=t?{isActive:v.isActive,predicate:v.predicate}:null,[w,A]=d(null),S=f||n[0],M=r(()=>{if(!h||null==w||!S)return null;const t=w,e=S;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[e]?n[e]:(null!==(o=n[e])&&void 0!==o?o:"")+"")===t}}},[h,w,S]),_=a(t=>{var n,o;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==p?void 0:p.mode)&&p.xField){const n=gl(t,e,p.xField);null!=n&&function(t,e,n){const o=Ss.positions.get(t);(null==o?void 0:o.locked)||o&&o.xValue===e&&o.sourceId===n||(Ss={positions:new Map(Ss.positions).set(t,{xValue:e,sourceId:n})},_s())}(p.name||"hover",n,y)}"x-position"!==(null==p?void 0:p.mode)&&b.onHover(e)}else"x-position"===(null==p?void 0:p.mode)&&Ps(p.name||"hover",y),"x-position"!==(null==p?void 0:p.mode)&&b.onHover(null);if(h&&S)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[S];A(null!=n?n+"":null)}else A(null);if(i||x){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){const r=yl(t),s=Object.assign(Object.assign({},e),{type:"hover",datum:r||{},x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(o=t.y)&&void 0!==o?o:0});i&&i(s),x&&x(s)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});i&&i(t),x&&x(t)}}},[e,b,p,y,i,s,l,x,h,S]),P=a(t=>{var e,n,o,r;if("x-position"===(null==p?void 0:p.mode)&&p.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=gl(t,e,p.xField);null!=n&&function(t,e,n){const o=Ss.positions.get(t);if(null==o?void 0:o.locked){const e=new Map(Ss.positions);return e.delete(t),Ss={positions:e},_s(),!1}Ss={positions:new Map(Ss.positions).set(t,{xValue:e,sourceId:n,locked:!0})},_s()}(p.name||"hover",n,y)}if(t&&c){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]),c(o,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(i||x){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){const n=yl(t),s=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(o=t.x)&&void 0!==o?o:0,y:null!==(r=t.y)&&void 0!==r?r:0});i&&i(s),x&&x(s)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});i&&i(t),x&&x(t)}}},[c,i,x,s,l,p,y]);return u(()=>{if("x-position"!==(null==p?void 0:p.mode))return;const t=p.name||"hover";return()=>{Os(t,y),Ps(t,y)}},[null==p?void 0:p.mode,null==p?void 0:p.name,y]),{activeSelectionHook:k,hoverSelectionHook:M,customHoverBehavior:_,customClickBehavior:P,crosshairSourceId:y}}function bl({data:t,colorBy:e,colorScale:n,showLegend:o,legendPosition:a="right",userMargin:l,defaults:c={top:50,bottom:60,left:70,right:40},categories:u}){const d=s(dl),h=null!==s(hl),f=void 0!==o?o:!d&&!!e,y=!!e&&(f||h),p=r(()=>{if(!y)return[];if(void 0!==u)return u;const n=new Set;for(const o of t){const t="function"==typeof e?e(o):o[e];null!=t&&n.add(t+"")}return Array.from(n)},[u,e,t,y]);!function(t){const e=s(hl),n=g(),o=function(t){const e=new Set,n=[];for(const o of t)e.has(o)||(e.add(o),n.push(o));return n}(t),r=i([]);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(r.current,o)||(r.current=o);const a=r.current;fl(()=>{if(e)return()=>e.unregisterCategories(n)},[e,n]),fl(()=>{e&&e.registerCategories(n,a)},[e,n,a])}(h&&e?p:[]);const m=r(()=>{if(!f||!e)return;const o=function({data:t,colorBy:e,colorScale:n,getColor:o,strokeColor:i,strokeWidth:r,categories:s}){const a=(s&&s.length>0?s:Array.from(new Set(t.map(t=>"function"==typeof e?e(t):t[e])))).map((i,r)=>{const s=t.find("function"==typeof e?t=>e(t)===i:t=>t[e]===i),a=s?o(s,e,n):n?n(i):fe[r%fe.length];return{label:i+"",color:a}});return{legendGroups:[{styleFn:t=>{const e=t.color||"#333",n={fill:e,stroke:e};return void 0!==i&&(n.stroke=i),void 0!==r&&(n.strokeWidth=r),n},type:"fill",items:a,label:""}]}}({data:t,colorBy:e,colorScale:n,getColor:ye,categories:p}),i=o.legendGroups.reduce((t,e)=>t+e.items.length,0);return 0!==i?o:void 0},[f,e,t,n,p]),v=r(()=>{const t="number"==typeof l?{top:l,bottom:l,left:l,right:l}:null!=l?l:{},e=e=>{const n=t[e];return"number"==typeof n?n:c[e]},n={top:e("top"),right:e("right"),bottom:e("bottom"),left:e("left")},o=e=>"number"==typeof t[e];return m&&("right"===a&&!o("right")&&110>n.right?n.right=110:"left"===a&&!o("left")&&110>n.left?n.left=110:"top"===a&&!o("top")&&50>n.top?n.top=50:"bottom"===a&&!o("bottom")&&80>n.bottom&&(n.bottom=80)),n},[c,l,m,a]);return{legend:m,margin:v,legendPosition:a}}o.createContext(void 0);const xl={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}}};function kl(t,e,n){if(!1!==e)return t;const o=Object.assign({},t);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function wl({componentName:n,message:o,diagnosticHint:i,width:r,height:s}){return t("div",{role:"alert",style:{width:r,height:Math.max(s,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:e("div",{style:{textAlign:"center",maxWidth:400},children:[t("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:n}),t("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:o}),i&&t("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:i})]})})}class Al extends o.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,e){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,t,e)}render(){if(this.state.error){const{fallback:e}=this.props,n=this.state.error;return"function"==typeof e?e(n):void 0!==e?e:t(wl,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Sl({componentName:e,width:n,height:o,children:i}){return t(Al,{fallback:i=>t(wl,{componentName:e,message:i.message,width:n,height:o}),children:i})}"undefined"!=typeof process&&process;const Ml={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"},_l={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Pl(t){if(null==t)return NaN;if("number"==typeof t)return t;if(t instanceof Date)return t.getTime();if("string"==typeof t){if(""===t.trim())return NaN;const e=+t;return Number.isFinite(e)?e:NaN}return NaN}function Ol(t,e,n,o){if(!t.length)return[];const i=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];let s=0,a=null,l=null,c=[];const u=(t,e)=>t>e?"A":e>t?"B":null,d=t=>`seg-${s}-${t}`,h=t=>r.push(t),f=(t,e)=>{h({__x:t.x,__y:t.y,__y0:t.y,__diffSegment:d(e),__diffWinner:e,__valA:t.y,__valB:t.y,__sourceDatum:t.datum})};for(let t=0;i.length>t;t++){const r=i[t],g=e(r),y=n(r),p=o(r);if(!Number.isFinite(g)||!Number.isFinite(y)||!Number.isFinite(p))continue;const m=u(y,p);if(null!==m)if(null!=a){if(l&&l.w!==m){let t,e;if(c.length>0)t=c[0].x,e=c[0].y;else{const n=y-l.a-(p-l.b);if(0!==n){const o=Math.max(0,Math.min(1,(l.b-l.a)/n));t=l.x+o*(g-l.x),e=l.a+o*(y-l.a)}else t=l.x,e=l.a}h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e}),s++,a=m,h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e});for(let t=1;c.length>t;t++)f(c[t],a)}else for(const t of c)f(t,a);c=[],h({__x:g,__y:p>y?p:y,__y0:p>y?y:p,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:p,__sourceDatum:r}),l={x:g,a:y,b:p,w:m}}else{a=m;for(const t of c)f(t,a);c=[],h({__x:g,__y:p>y?p:y,__y0:p>y?y:p,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:p,__sourceDatum:r}),l={x:g,a:y,b:p,w:m}}else c.push({x:g,y:y,datum:r})}for(const t of c)f(t,null!=a?a:"A");return r}const Tl=f(function(n,o){const s=i(null),l=function(t,e){var n,o,i,r,s,a,l;const c=xl[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(n=e.width)&&void 0!==n?n:c.width,height:null!==(o=e.height)&&void 0!==o?o:c.height,showAxes:null!==(i=e.showAxes)&&void 0!==i?i:c.showAxes,showGrid:null!==(r=e.showGrid)&&void 0!==r?r:c.showGrid,enableHover:null!==(s=e.enableHover)&&void 0!==s?s:!!e.linkedHover||c.enableHover,showLegend:null!==(a=e.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(l=e.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:u?void 0:e.xLabel,yLabel:u?void 0:e.yLabel,categoryLabel:u?void 0:e.categoryLabel,valueLabel:u?void 0:e.valueLabel,marginDefaults:kl(c.marginDefaults,e.showCategoryTicks,e.orientation),compactMode:u}}(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:c,margin:u,className:h,xFormat:f,yFormat:g,xAccessor:p="x",seriesAAccessor:m="a",seriesBAccessor:v="b",seriesALabel:b="A",seriesBLabel:x="B",seriesAColor:k="var(--semiotic-danger, #dc2626)",seriesBColor:w="var(--semiotic-info, #2563eb)",showLines:A=!0,lineWidth:S=1.5,showPoints:M=!1,pointRadius:_=3,curve:P="linear",areaOpacity:O=.6,gradientFill:T,tooltip:$,annotations:j,xExtent:L,yExtent:C,frameProps:z={},selection:D,linkedHover:E,onObservation:R,onClick:N,hoverHighlight:F,chartId:W,loading:B,loadingContent:I,emptyContent:Y,legendInteraction:G,legendPosition:H,pointIdAccessor:X,windowSize:q}=n,{width:V,height:U,enableHover:Z,showGrid:Q,showLegend:K,title:J,description:tt,summary:et,accessibleTable:nt,xLabel:ot,yLabel:it}=l,rt=r(()=>"function"==typeof p?t=>Pl(p(t)):t=>Pl(t[p]),[p]),st=r(()=>"function"==typeof m?t=>Pl(m(t)):t=>Pl(t[m]),[m]),at=r(()=>"function"==typeof v?t=>Pl(v(t)):t=>Pl(t[v]),[v]),[lt,ct]=d([]),ut=i([]),dt=null==c,ht=r(()=>mr(dt?lt:c),[dt,lt,c]),ft=r(()=>Ol(ht,rt,st,at),[ht,rt,st,at]),gt=r(()=>A?function(t,e,n,o){if(!t.length)return[];const i=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];for(const t of i){const i=e(t),s=n(t),a=o(t);Number.isFinite(s)&&r.push({__x:i,__y:s,__diffSegment:"line-A"}),Number.isFinite(a)&&r.push({__x:i,__y:a,__diffSegment:"line-B"})}return r}(ht,rt,st,at):[],[A,ht,rt,st,at]),yt=r(()=>[...ft,...gt],[ft,gt]),pt=r(()=>{const t=new Set;for(const e of ft)t.add(e.__diffSegment);return Array.from(t)},[ft]);y(o,()=>{const t=t=>{const e=q&&t.length>q?t.slice(t.length-q):t;ut.current=e,ct(e)},e=X?"function"==typeof X?X:t=>t[X]:null;return{push:e=>t([...ut.current,e]),pushMany:e=>t([...ut.current,...e]),remove:n=>{if(!e)return[];const o=Array.isArray(n)?n:[n],i=[],r=[];for(const t of ut.current)o.includes(e(t))?i.push(t):r.push(t);return t(r),i},update:(n,o)=>{if(!e)return[];const i=Array.isArray(n)?n:[n],r=[],s=ut.current.map(t=>{if(i.includes(e(t))){const e=o(t);return r.push(e),e}return t});return t(s),r},clear:()=>t([]),getData:()=>dt?ut.current:ht,getScales:()=>{var t,e;return null!==(e=null===(t=s.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}},[dt,ht,X,q]);const mt=function(e){const{data:n,rawData:o,colorBy:i,colorScheme:s,legendInteraction:l,legendPosition:c,selection:u,linkedHover:h,fallbackFields:f,unwrapData:g=!1,onObservation:y,chartType:p,chartId:m,showLegend:v,userMargin:b,marginDefaults:x,onClick:k,hoverHighlight:w,loading:A,loadingContent:S,emptyContent:M,width:_,height:P}=e,O=void 0===o,T=r(()=>mr(n),[n]),[$,j]=d([]),L=a(t=>{j(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)},[]),C="string"==typeof e.colorBy?e.colorBy:void 0,{activeSelectionHook:z,hoverSelectionHook:D,customHoverBehavior:E,customClickBehavior:R,crosshairSourceId:N}=vl({selection:u,linkedHover:h,fallbackFields:f,unwrapData:g,onObservation:y,chartType:p,chartId:m,onClick:k,hoverHighlight:w,colorByField:C}),F=function(t,e){const n="object"==typeof t&&null!==t?t:void 0;if("x-position"===(null==n?void 0:n.mode))return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:e}}(h,N),W=function(t,e,n){const o=nl(),i=ml();return r(()=>{var r;if(!e)return;const s=null!=o?o:void 0,a=null!==(r=null!=n?n:i&&i.length>0?i:void 0)&&void 0!==r?r:"category10";if(0!==t.length){if("function"==typeof e){const n=Array.from(new Set(t.map(t=>e(t)+"")));if(s&&pl(s)){const t=pe(n.map(t=>({_cat:t})),"_cat",a);return e=>s[e]||t(e)}return pe(n.map(t=>({_cat:t})),"_cat",a)}if(s&&pl(s)){const n=pe(t,e,a);return t=>s[t]||n(t)}return pe(t,e,a)}if(s&&pl(s)){const t=pe([{_:"a"}],"_",a);return e=>s[e]||t(e)}},[t,e,n,o,i])}(T,i,s),B=r(()=>{if(!i)return[];const t=new Set;for(const e of T){const n="function"==typeof i?i(e):e[i];null!=n&&t.add(n+"")}return Array.from(t)},[T,i]),I=r(()=>O&&$.length>0?$:B,[O,$,B]),Y=function(t,e,n){const[o,i]=d(null),[s,l]=d(new Set),c=r(()=>new Set,[]),u=a(e=>{"highlight"===t&&i(e?e.label:null)},[t]),h=a(e=>{"isolate"===t&&l(t=>{const o=new Set(t);return o.has(e.label)?o.delete(e.label):o.add(e.label),o.size===n.length?new Set:o})},[t,n.length]),f=r(()=>{if(!t||"none"===t||!e)return null;const n="string"==typeof e?e:null;return"highlight"===t&&null!=o?{isActive:!0,predicate:t=>(n?t[n]:"function"==typeof e?e(t):null)===o}:"isolate"===t&&s.size>0?{isActive:!0,predicate:t=>{const o=n?t[n]:"function"==typeof e?e(t):null;return s.has(o)}}:null},[t,e,o,s]);return{highlightedCategory:"highlight"===t?o:null,isolatedCategories:"isolate"===t?s:c,onLegendHover:u,onLegendClick:h,legendSelectionHook:f}}(l,i,I),G=r(()=>D||(Y.legendSelectionHook?Y.legendSelectionHook:z),[D,Y.legendSelectionHook,z]),H=function(t){const e=Ko(t=>t.theme.colors.selectionOpacity);return r(()=>{var n,o;if(void 0!==t||void 0!==e)return Object.assign(Object.assign({name:null!==(n=null==t?void 0:t.name)&&void 0!==n?n:""},t),{unselectedOpacity:null!==(o=null==t?void 0:t.unselectedOpacity)&&void 0!==o?o:e})},[t,e])}(u),X=ml(),q=nl(),V=r(()=>{if(W)return W;if(!i||0===I.length)return;const t=Array.isArray(s)&&s.length>0||"string"==typeof s&&s.length>0?s:X&&X.length>0?X:fe,e="__streamCat",n=pe(I.map(t=>({[e]:t})),e,t);return t=>(null==q?void 0:q[t])||n(t)||"#999"},[W,i,I,s,X,q]),{legend:U,margin:Z,legendPosition:Q}=bl({data:T,colorBy:i,colorScale:V,showLegend:v,legendPosition:c,userMargin:b,defaults:x,categories:I}),K=r(()=>{const t={};return U&&(t.legend=U,t.legendPosition=Q),l&&"none"!==l&&(t.legendHoverBehavior=Y.onLegendHover,t.legendClickBehavior=Y.onLegendClick,t.legendHighlightedCategory=Y.highlightedCategory,t.legendIsolatedCategories=Y.isolatedCategories),O&&i&&(t.legendCategoryAccessor=i,t.onCategoriesChange=L),t},[U,Q,l,Y.onLegendHover,Y.onLegendClick,Y.highlightedCategory,Y.isolatedCategories,O,i,L]),J=Array.isArray(o)?mr(o):o,tt=function(e,n,o,i){if(!e)return null;if(!1===i)return null;if(null!=i)return t("div",{style:{width:n,height:o,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:i});const r=Math.min(5,Math.floor(o/40)),s=Math.max(8,Math.floor(o/(3*r))),a=Math.max(6,Math.floor(o/(2.5*r))),l=Math.floor((o-(r*(s+a)-a))/2);return t("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(e,o)=>t("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},_l),{position:"absolute",top:l+o*(s+a),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:s,opacity:.5+o%2*.2})},o))})}(A,_,P,S),et=tt?null:function(e,n,o,i){return!1===i||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t("div",{style:Object.assign(Object.assign({},Ml),{width:n,height:o}),children:i||"No data available"}):null}(J,_,P,M);return{data:T,colorScale:W,allCategories:I,legendState:Y,effectiveSelectionHook:G,activeSelectionHook:z,customHoverBehavior:E,customClickBehavior:R,legend:U,margin:Z,legendPosition:Q,earlyReturn:tt||et||null,legendBehaviorProps:K,crosshairProps:F,resolvedSelection:H}}({data:ht,rawData:c,colorBy:"__diffWinner",colorScheme:[k,w],legendInteraction:G,legendPosition:H,selection:D,linkedHover:E,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:R,onClick:N,hoverHighlight:F,chartType:"DifferenceChart",chartId:W,showLegend:K,userMargin:u,marginDefaults:l.marginDefaults,loading:B,loadingContent:I,emptyContent:Y,width:V,height:U}),vt=r(()=>{if(!1!==K)return{legendGroups:[{label:"",type:"fill",styleFn:t=>({fill:t.color||"currentColor"}),items:[{label:b,color:k},{label:x,color:w}]}]}},[K,b,x,k,w]),bt=a(t=>{const e=t.__diffSegment;return{fill:"A"==((null==e?void 0:e.endsWith("-A"))?"A":"B")?k:w,stroke:"none",fillOpacity:O}},[k,w,O]),xt=a(t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?k:w,strokeWidth:S,fill:"none"}),[k,w,S]),kt=a(t=>({fill:"A"==("line-A"===t.__diffSegment?"A":"B")?k:w,r:_}),[k,w,_]),wt=a(n=>{var o;const i=n.data,r=n.allSeries,s=null!==(o=n.xValue)&&void 0!==o?o:null==i?void 0:i.__x;let a=null==i?void 0:i.__valA,l=null==i?void 0:i.__valB;if(r&&r.length>0){const t=r.find(t=>"line-A"===t.group),e=r.find(t=>"line-B"===t.group);null!=(null==t?void 0:t.value)&&Number.isFinite(t.value)&&(a=t.value),null!=(null==e?void 0:e.value)&&Number.isFinite(e.value)&&(l=e.value)}if(null!=s&&(null==a||null==l)){const t=ht.find(t=>rt(t)===s);t&&(null==a&&(a=st(t)),null==l&&(l=at(t)))}const c=t=>null!=t&&Number.isFinite(t)?""+Math.round(100*t)/100:"—",u=f&&null!=s?f(s):null!=s?s+"":"";return e("div",{className:"semiotic-tooltip",style:xr,children:[u&&t("div",{style:{fontWeight:600,marginBottom:4},children:u}),e("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t("span",{style:{width:10,height:10,background:k,display:"inline-block",borderRadius:2}}),e("span",{children:[b,": ",c(a)]})]}),e("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t("span",{style:{width:10,height:10,background:w,display:"inline-block",borderRadius:2}}),e("span",{children:[x,": ",c(l)]})]}),null!=a&&null!=l&&Number.isFinite(a)&&Number.isFinite(l)&&e("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",c(a-l)]})]})},[ht,rt,st,at,f,k,w,b,x]),At="multi"===$,St=r(()=>{if(!1===$)return()=>null;if(At)return wt;const e=function(e){if(!0!==e){if("function"==typeof e){const n=e;return e=>{var o;let i=vr(!0===(null==e?void 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)?null!==(o=e.data)&&void 0!==o?o:{}:e);("node"===(null==e?void 0:e.nodeOrEdge)&&"number"==typeof(null==i?void 0:i.x0)&&"number"==typeof(null==i?void 0:i.x1)||"edge"===(null==e?void 0:e.nodeOrEdge)&&"number"==typeof(null==i?void 0:i.sankeyWidth))&&i.data&&"object"==typeof i.data&&(i=i.data);const r=n(i);return null==r?null:t("div",{className:"semiotic-tooltip",style:xr,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Ar(e):Ar())}}($);return e||wt},[$,At,wt]);if(mt.earlyReturn)return mt.earlyReturn;const Mt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"mixed",data:yt,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:pt,curve:P,areaStyle:bt,lineStyle:xt},M&&{pointStyle:kt}),{size:[V,U],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:mt.margin,showAxes:l.showAxes,xLabel:ot,yLabel:it,xFormat:f,yFormat:g,enableHover:Z,showGrid:Q}),T&&{gradientFill:!0===T?{topOpacity:.85,bottomOpacity:.15}:T}),vt&&{legend:vt,legendPosition:mt.legendPosition}),function(t){const{title:e,description:n,summary:o,accessibleTable:i,className:r,animate:s,axisExtent:a,autoPlaceAnnotations:l}=t,c={};return e&&(c.title=e),n&&(c.description=n),o&&(c.summary=o),void 0!==i&&(c.accessibleTable=i),r&&(c.className=r),null!=s&&(c.animate=s),void 0!==a&&(c.axisExtent=a),void 0!==l&&(c.autoPlaceAnnotations=l),c}({title:J,description:tt,summary:et,accessibleTable:nt,className:h,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),{tooltipContent:St}),At&&{tooltipMode:"multi"}),function(t){const{linkedHover:e,onObservation:n,onClick:o,hoverHighlight:i,customHoverBehavior:r,customClickBehavior:s,linkedHoverInClickPredicate:a=!0}=t,l={};return(e||n||o||i)&&(l.customHoverBehavior=r),(a?n||o||e:n||o)&&(l.customClickBehavior=s),l}({linkedHover:E,onObservation:R,onClick:N,hoverHighlight:F,customHoverBehavior:mt.customHoverBehavior,customClickBehavior:mt.customClickBehavior})),j&&j.length>0&&{annotations:j}),L&&{xExtent:L}),C&&{yExtent:C}),mt.crosshairProps),z);return t(Sl,{componentName:"DifferenceChart",width:V,height:U,children:t(tl,Object.assign({ref:s},Mt))})});function $l(t,e,n){return"function"==typeof t?t(n):n[t||e]}function jl(t){return t instanceof Date?t.getTime():Number(t)}function Ll(t,e){return ie(1===e?.5:t/(e-1))}"function"==typeof Tl&&(Tl.displayName="DifferenceChart");const Cl={frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r,s,a,l;const c=null!==(r=i.min)&&void 0!==r?r:0,u=null!==(s=i.max)&&void 0!==s?s:100,d=null!==(a=i.sweep)&&void 0!==a?a:240,h=null!==(l=i.arcWidth)&&void 0!==l?l:.3,f=180+(360-d)/2,g=i.thresholds||[{value:u,color:i.color||"#4e79a7"}],y=o.gradientFill,p=function(t){const{min:e,max:n,value:o,thresholds:i,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=t,d=n-e||1,h=(Math.max(e,Math.min(n,o))-e)/d;let f=i&&i.length>0?[...i].sort((t,e)=>t.value-e.value):[{value:n,color:r||"#007bff"}];f=f.map(t=>Object.assign(Object.assign({},t),{value:Math.max(e,Math.min(n,t.value))})),n>f[f.length-1].value&&f.push({value:n,color:f[f.length-1].color});const g=!!c&&c.colorStops.length>=2,y=[],p=new Map,m=[];if(g){const t=a?h:1,e=nr("bg",0);if(y.push({category:e,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),p.set(e,{fill:s,opacity:.4}),t>0){const e=Math.max(1,Math.floor(u)),n=Math.max(1,Math.min(e,Math.round(t*e))),o=[];for(let e=0;n>e;e++)o.push(er(c.colorStops,t*(e+.5)/n));const i=nr("fill",0);y.push({category:i,value:t,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:t,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:o}}),p.set(i,{fill:o[0]||s})}}else{let t=e;for(let n=0;f.length>n;n++){const o=f[n],i=(o.value-t)/d,r=(t-e)/d,l=(o.value-e)/d,c=Math.max(0,(a?Math.min(h,l):l)-r),u=a?Math.max(0,i-c):0;if(c>0){const t=nr("fill",n);y.push({category:t,value:c,_zone:o.label||"Zone "+(n+1),_isFill:!0}),p.set(t,{fill:o.color})}if(u>0){const t=nr("bg",n);y.push({category:t,value:u,_zone:o.label||"Zone "+(n+1),_isFill:!1}),p.set(t,{fill:s,opacity:.4})}t=o.value}}if(l&&i&&i.length>0)for(const t of i)t.value>e&&n>t.value&&m.push({type:"gauge-label",value:t.value,label:t.label||t.value+""});return{gaugeData:y,pieceStyle:(t,e)=>p.get(e||t.category)||{fill:s},gaugeAnnotations:m}}({min:c,max:u,value:i.value,thresholds:g,fillColor:i.color,backgroundColor:i.backgroundColor||"#e0e0e0",fillZones:!1!==i.fillZones,showScaleLabels:!1!==i.showScaleLabels,gradientFill:y&&"object"==typeof y&&"colorStops"in y?y:void 0}),m=o.margin||{top:20,right:20,bottom:30,left:40},[v,b]=o.size||[300,300];return Object.assign(Object.assign(Object.assign({chartType:"donut",data:p.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(v-(m.left||0)-(m.right||0),b-(m.top||0)-(m.bottom||0))/2*(1-h)),sweepAngle:d,startAngle:f,oSort:!1,pieceStyle:p.pieceStyle},null!=i.cornerRadius&&{cornerRadius:i.cornerRadius}),o),{showAxes:!1,annotations:[...Array.isArray(o.annotations)?o.annotations:[],...p.gaugeAnnotations],__gauge:{gMin:c,gMax:u,sweep:d,arcWidth:h,value:i.value,startAngleDeg:f,thresholds:g}})}},zl={frameType:"geo",buildProps:(t,e,n,o,i)=>{var r,s,a,l,c;const u=(Array.isArray(t)?t:null)||i.flows||[],d=i.nodeIdAccessor||"id",h=i.valueAccessor||"value",f=i.xAccessor||"lon",g=i.yAccessor||"lat",y="function"==typeof f?f:t=>t[f],p="function"==typeof g?g:t=>t[g],m=(i.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:y(t),y:p(t)})),v=new Map;for(const t of m)v.set(t[d]+"",t);const b=null!==(r=i.edgeColorBy)&&void 0!==r?r:e,x="function"==typeof b,k=u.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=v.get(t.source+""),n=v.get(t.target+"");return e&&n?Object.assign(Object.assign({},t),{coordinates:[{x:e.x,y:e.y},{x:n.x,y:n.y}]}):null}).filter(Boolean),w="__flowMapEdgeColor",A=b?x?pe(k.map(t=>({[w]:b(t)})),w,n||"category10"):pe(k,b,n||"category10"):null,S=t=>b&&A?ye(t,b,A):"#007bff";let M=1/0,_=-1/0;for(const t of k){const e=Number(null!==(s=t[h])&&void 0!==s?s:0);isFinite(e)&&(M>e&&(M=e),e>_&&(_=e))}const P=_>M?_-M:0,[O,T]=null!==(a=i.edgeWidthRange)&&void 0!==a?a:[1,8],$=T-O,j=null!==(l=i.edgeOpacity)&&void 0!==l?l:.6,L=null!==(c=i.edgeLinecap)&&void 0!==c?c:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:i.lineType||"geo",flowStyle:i.flowStyle||"basic",areas:i.areas,areaStyle:i.areaStyle,projection:i.projection||"equalEarth",graticule:i.graticule,fitPadding:i.fitPadding,colorScheme:n,lineStyle:t=>{const e=Number(null==t?void 0:t[h]),n=O+Math.max(0,Math.min(1,P>0?((Number.isFinite(e)?e:M)-M)/P:0))*$;return{stroke:S(t),strokeWidth:n,strokeLinecap:L,opacity:j,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},o)}},Dl={Sparkline:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.lineBy||e,colorAccessor:e},o),{showAxes:!1,margin:o.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"line",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.lineBy||e,colorAccessor:e,colorScheme:n,lineStyle:i.lineStyle},o)},AreaChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"area",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",y0Accessor:i.y0Accessor,groupAccessor:i.areaBy||e,colorAccessor:e,colorScheme:n},o)},DifferenceChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>{var r,s;const a=i.xAccessor||"x",l=i.seriesAAccessor||"a",c=i.seriesBAccessor||"b",u=t=>jl($l(a,"x",t)),d=t=>jl($l(l,"a",t)),h=t=>jl($l(c,"b",t)),f=i.seriesAColor||"var(--semiotic-danger, #dc2626)",g=i.seriesBColor||"var(--semiotic-info, #2563eb)",y=null!==(r=i.areaOpacity)&&void 0!==r?r:.6,p=null!==(s=i.lineWidth)&&void 0!==s?s:1.5,m=!1!==i.showLines,v=Ol(Array.isArray(t)?t:[],u,d,h),b=[];if(m&&Array.isArray(t)){const e=t.filter(t=>Number.isFinite(u(t))).sort((t,e)=>u(t)-u(e));for(const t of e){const e=u(t),n=d(t),o=h(t);Number.isFinite(n)&&b.push({__x:e,__y:n,__diffSegment:"line-A"}),Number.isFinite(o)&&b.push({__x:e,__y:o,__diffSegment:"line-B"})}}const x=[...v,...b],k=Array.from(new Set(v.map(t=>t.__diffSegment)));return Object.assign({chartType:"mixed",data:x,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:k,areaStyle:t=>{const e=t.__diffSegment;return{fill:"A"==((null==e?void 0:e.endsWith("-A"))?"A":"B")?f:g,stroke:"none",fillOpacity:y}},lineStyle:t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?f:g,strokeWidth:p,fill:"none"}),curve:i.curve||"linear"},o)}},StackedAreaChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.areaBy,colorAccessor:e||i.areaBy,colorScheme:n,normalize:i.normalize},o)},Scatterplot:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"scatter",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,sizeAccessor:i.sizeBy,colorScheme:n},o)},CandlestickChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"candlestick",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.highAccessor||"high",highAccessor:i.highAccessor||"high",lowAccessor:i.lowAccessor||"low",openAccessor:i.openAccessor,closeAccessor:i.closeAccessor,candlestickStyle:i.candlestickStyle},o)},BubbleChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"scatter",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,sizeAccessor:i.sizeBy,sizeRange:i.sizeRange||[5,40],colorScheme:n},o)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,n,o,i)=>{var r,s;const a=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const n=e.xAccessor||"x",o=e.yAccessor||"y",i=e.orderAccessor?[...t].sort((t,n)=>null==t||"object"!=typeof t?1:null==n||"object"!=typeof n?-1:jl($l(e.orderAccessor,"order",t))-jl($l(e.orderAccessor,"order",n))):t,r=new WeakMap;let s=0;for(const t of i){if(null==t||"object"!=typeof t)continue;const e=jl($l(n,"x",t)),i=jl($l(o,"y",t));Number.isFinite(e)&&Number.isFinite(i)&&s++}let a=0;for(const t of i){if(null==t||"object"!=typeof t)continue;const e=jl($l(n,"x",t)),i=jl($l(o,"y",t));Number.isFinite(e)&&Number.isFinite(i)&&r.set(t,{idx:a++,total:s})}return{data:i,orderMap:r}}(t,i),l=null!==(r=i.pointRadius)&&void 0!==r?r:4;return Object.assign({chartType:"line",data:a.data,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,colorScheme:n,lineStyle:i.lineStyle||{stroke:i.stroke||"#6366f1",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:l,opacity:i.opacity},pointStyle:t=>{var e,n;const o=a.orderMap.get(t),i=null!==(e=null==o?void 0:o.idx)&&void 0!==e?e:0,r=null!==(n=null==o?void 0:o.total)&&void 0!==n?n:1;return{fill:r>0?Ll(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:l,fillOpacity:1}}},o)}},QuadrantChart:{frameType:"xy",buildProps:(t,e,n,i,r)=>{var s,a;const l=r.xCenter,c=r.yCenter,u=r.quadrants,d=r.centerlineStyle||{},h=!1!==r.showQuadrantLabels,f=null!==(s=r.quadrantLabelSize)&&void 0!==s?s:12,g=d.stroke||"#999",y=null!==(a=d.strokeWidth)&&void 0!==a?a:1,p=Array.isArray(d.strokeDasharray)?d.strokeDasharray.join(","):d.strokeDasharray,m=o.createElement,v=u?[(t,e,n)=>{if(!(null==e?void 0:e.x)||!(null==e?void 0:e.y))return null;const i=n.width,r=n.height,s=null!=l?e.x(l):i/2,a=null!=c?e.y(c):r/2;if(null!=l&&!Number.isFinite(s))return null;if(null!=c&&!Number.isFinite(a))return null;const d=Math.max(0,Math.min(i,s)),v=Math.max(0,Math.min(r,a)),b=[{c:u.topLeft,x:0,y:0,w:d,h:v},{c:u.topRight,x:d,y:0,w:i-d,h:v},{c:u.bottomLeft,x:0,y:v,w:d,h:r-v},{c:u.bottomRight,x:d,y:v,w:i-d,h:r-v}],x=h?[m("text",{key:"ltl",x:8,y:8+f,fill:u.topLeft.color,fontWeight:600,fontSize:f,opacity:.5},u.topLeft.label),m("text",{key:"ltr",x:i-8,y:8+f,fill:u.topRight.color,fontWeight:600,fontSize:f,opacity:.5,textAnchor:"end"},u.topRight.label),m("text",{key:"lbl",x:8,y:r-8,fill:u.bottomLeft.color,fontWeight:600,fontSize:f,opacity:.5},u.bottomLeft.label),m("text",{key:"lbr",x:i-8,y:r-8,fill:u.bottomRight.color,fontWeight:600,fontSize:f,opacity:.5,textAnchor:"end"},u.bottomRight.label)]:[];return m(o.Fragment,null,...b.map((t,e)=>{var n;return t.w>0&&t.h>0?m("rect",{key:"qf-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.c.color,opacity:null!==(n=t.c.opacity)&&void 0!==n?n:.08}):null}),m("line",{key:"vc",x1:d,y1:0,x2:d,y2:r,stroke:g,strokeWidth:y,strokeDasharray:p}),m("line",{key:"hc",x1:0,y1:v,x2:i,y2:v,stroke:g,strokeWidth:y,strokeDasharray:p}),...x)}]:void 0;return Object.assign(Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange,colorScheme:n,pointStyle:r.pointStyle},i),v&&{svgPreRenderers:v})}},Heatmap:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"heatmap",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",valueAccessor:i.valueAccessor,colorScheme:n||i.colorScheme||"blues",showValues:i.showValues,cellBorderColor:i.cellBorderColor},o)},BarChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"horizontal"===i.orientation?"horizontal":"vertical",oSort:null!==(r=i.sort)&&void 0!==r&&r,colorAccessor:e,colorScheme:n,barPadding:i.barPadding},null!=i.roundedTop&&{roundedTop:i.roundedTop}),o)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.stackBy,colorAccessor:e||i.stackBy,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical",normalize:i.normalize,oSort:null!==(r=i.sort)&&void 0!==r&&r,barPadding:i.barPadding},null!=i.roundedTop&&{roundedTop:i.roundedTop}),o)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",groupBy:i.groupBy,colorAccessor:e||i.groupBy,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical",oSort:null!==(r=i.sort)&&void 0!==r&&r,barPadding:i.barPadding},null!=i.roundedTop&&{roundedTop:i.roundedTop}),o)}},PieChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"radial",colorAccessor:e||i.categoryAccessor,colorScheme:n},null!=i.cornerRadius&&{cornerRadius:i.cornerRadius}),o)},DonutChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"radial",innerRadius:i.innerRadius||60,colorAccessor:e||i.categoryAccessor,colorScheme:n},null!=i.cornerRadius&&{cornerRadius:i.cornerRadius}),o)},Histogram:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"histogram",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"horizontal",bins:i.bins,colorAccessor:e,colorScheme:n},o)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"boxplot",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorScheme:n},o)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"violin",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",bins:i.bins,colorScheme:n},o)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"swarm",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorAccessor:e,colorScheme:n},o)},DotPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorAccessor:e,colorScheme:n},o),{showGrid:null===(r=o.showGrid)||void 0===r||r})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"swimlane",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.subcategoryAccessor,colorAccessor:e||i.subcategoryAccessor,categoryAccessor:i.categoryAccessor,subcategoryAccessor:i.subcategoryAccessor,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical"},o)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",bins:i.bins,amplitude:i.amplitude},o)},LikertChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.levelAccessor||"level",colorAccessor:e||i.levelAccessor||"level",colorScheme:n,normalize:!0,projection:"vertical"===i.orientation?"vertical":"horizontal"},o)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{const r="vertical"===i.orientation;return Object.assign({chartType:r?"bar-funnel":"funnel",data:t,oAccessor:i.stepAccessor||"step",rAccessor:i.valueAccessor||"value",colorAccessor:e||i.categoryAccessor,categoryAccessor:i.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,barPadding:r?40:0,showAxes:r,showGrid:r,colorScheme:n},o)}},GaugeChart:Cl,ForceDirectedGraph:{frameType:"network",buildProps:(t,e,n,o,i)=>{var r;const{edgeWidth:s,edgeColor:a,edgeOpacity:l}=i,c=null!==(r=i.edgeStyle)&&void 0!==r?r:void 0!==s||void 0!==a||void 0!==l?t=>{const e=(null==t?void 0:t.data)||t;let n=1;if("number"==typeof s)n=s;else if("function"==typeof s)n=s(e);else if("string"==typeof s){const t=null==e?void 0:e[s],o="number"==typeof t?t:Number(t);n=Number.isFinite(o)&&o>0?o:1}return{stroke:null!=a?a:"#999",strokeWidth:n,opacity:null!=l?l:.6}}:void 0;return Object.assign({chartType:"force",nodes:i.nodes,edges:i.edges,nodeIDAccessor:i.nodeIdAccessor||i.nodeIDAccessor,sourceAccessor:i.sourceAccessor,targetAccessor:i.targetAccessor,colorBy:e,colorScheme:n,iterations:i.iterations,forceStrength:i.forceStrength,showLabels:i.showLabels,nodeLabel:i.nodeLabel,nodeSize:i.nodeSize,nodeSizeRange:i.nodeSizeRange,nodeStyle:i.nodeStyle,edgeStyle:c},o)}},SankeyDiagram:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"sankey",nodes:i.nodes,edges:i.edges,nodeIDAccessor:i.nodeIdAccessor||i.nodeIDAccessor,sourceAccessor:i.sourceAccessor,targetAccessor:i.targetAccessor,valueAccessor:i.valueAccessor,orientation:i.orientation,nodeAlign:i.nodeAlign,nodeWidth:i.nodeWidth,nodePaddingRatio:i.nodePaddingRatio,showLabels:i.showLabels,nodeLabel:i.nodeLabel,colorBy:e,edgeColorBy:i.edgeColorBy,edgeOpacity:i.edgeOpacity,nodeStyle:i.nodeStyle,edgeStyle:i.edgeStyle,colorScheme:n},o)},ProcessSankey:{frameType:"network",buildProps:(t,e,n,o,i)=>{var r,s,a,l;const c=t=>null==t?NaN:t instanceof Date?t.getTime():"number"==typeof t?t:new Date(t).getTime(),u=i.sourceAccessor||"source",d=i.targetAccessor||"target",h=i.valueAccessor||"value",f=i.nodeIdAccessor||"id",g=i.startTimeAccessor||"startTime",y=i.endTimeAccessor||"endTime",p=i.systemInTimeAccessor,m=i.systemOutTimeAccessor,v=i.xExtentAccessor||"xExtent",b=i.edgeIdAccessor||"id",x=(t,e)=>"function"==typeof t?t(e):e[t],k=Array.isArray(i.edges)?i.edges:[],w=Array.isArray(i.nodes)?i.nodes:[],A=w.length>0?w:function(t,e,n,o){const i=new Set;return e.forEach(t=>{const e="function"==typeof n?n(t):t[n],r="function"==typeof o?o(t):t[o];i.add(e),i.add(r)}),Array.from(i).map(t=>({id:t}))}(0,k,u,d),S=[c(null===(r=i.domain)||void 0===r?void 0:r[0]),c(null===(s=i.domain)||void 0===s?void 0:s[1])],M=A.map(t=>{const e=x(f,t)+"",n=x(v,t),o={id:e,__raw:t};if(Array.isArray(n)&&2===n.length){const t=c(n[0]),e=c(n[1]);Number.isFinite(t)&&Number.isFinite(e)&&(o.xExtent=[t,e])}return o}),_=k.map((t,e)=>{const n=x(b,t),o={id:null!=n?n+"":`${x(u,t)}-${x(d,t)}-${e}`,source:x(u,t)+"",target:x(d,t)+"",value:Number(x(h,t)),startTime:c(x(g,t)),endTime:c(x(y,t)),__raw:t};if(p){const e=c(x(p,t));Number.isFinite(e)&&(o.systemInTime=e)}if(m){const e=c(x(m,t));Number.isFinite(e)&&(o.systemOutTime=e)}return o}),[P,O]=null!==(a=o.size)&&void 0!==a?a:[600,400],T=Object.assign({top:20,right:20,bottom:20,left:20},o.margin),$=null!==(l=o.legendPosition)&&void 0!==l?l:"right";o.showLegend&&("right"===$?T.right=Math.max(T.right,100):"left"===$?T.left=Math.max(T.left,100):"bottom"===$?T.bottom=Math.max(T.bottom,70):"top"===$&&(T.top=Math.max(T.top,40)));const j=T,L=P-j.left-j.right,C=O-j.top-j.bottom,z=Array.isArray(n)?n:null,D=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],E="function"==typeof e?e:null,R=E?A.map(t=>({_cat:E(t)})):A,N=E?"_cat":"string"==typeof e?e:void 0,F=N?pe(R,N,n):null,W=new Map;for(const t of M)W.set(t.id,t.__raw);const{layoutConfig:B,issues:I}=gr({nodes:M,edges:_,domain:S,plotW:L,plotH:C,ribbonLane:i.ribbonLane||"both",edgeOpacity:"number"==typeof i.edgeOpacity?i.edgeOpacity:.35,colorOf:(t,n)=>{if(e&&W.has(t)){const n=W.get(t);return E?ye({_cat:E(n)},"_cat",null!=F?F:void 0):ye(n,e,null!=F?F:void 0)}const o=z||D;return o[n%o.length]},layoutOpts:{pairing:i.pairing||"temporal",packing:i.packing||"reuse",laneOrder:i.laneOrder||"crossing-min",lifetimeMode:i.lifetimeMode||"half"}});if(I.length>0){const t=I.map(or).join("; ");throw Error("ProcessSankey: data invalid — "+t)}return Object.assign(Object.assign({chartType:"force",nodes:A,edges:k,customNetworkLayout:yr,layoutConfig:B,sourceAccessor:u,targetAccessor:d,valueAccessor:h,nodeIDAccessor:f,colorBy:e,colorScheme:n},o),{margin:j})}},ChordDiagram:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"chord",nodes:i.nodes,edges:i.edges,valueAccessor:i.valueAccessor,padAngle:i.padAngle,groupWidth:i.groupWidth,showLabels:i.showLabels,colorBy:e,edgeColorBy:i.edgeColorBy,colorScheme:n},o)},TreeDiagram:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"cluster"===i.layout?"cluster":"tree",data:t,childrenAccessor:i.childrenAccessor,colorBy:e,colorByDepth:i.colorByDepth,orientation:i.orientation,showLabels:i.showLabels,colorScheme:n},o)},Treemap:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:i.childrenAccessor,hierarchySum:i.valueAccessor,colorBy:e,colorByDepth:i.colorByDepth,showLabels:i.showLabels,colorScheme:n},o)},CirclePack:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:i.childrenAccessor,hierarchySum:i.valueAccessor,colorBy:e,colorByDepth:i.colorByDepth,colorScheme:n},o)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,n,o,i)=>Object.assign({areas:i.areas,projection:i.projection||"equalEarth",areaStyle:i.areaStyle,valueAccessor:i.valueAccessor,colorScheme:n||"blues",graticule:i.graticule,fitPadding:i.fitPadding},o)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,n,o,i)=>Object.assign({points:t||i.points,xAccessor:i.xAccessor||"lon",yAccessor:i.yAccessor||"lat",areas:i.areas,areaStyle:i.areaStyle,sizeBy:i.sizeBy,colorBy:e,colorScheme:n,projection:i.projection||"equalEarth",graticule:i.graticule,fitPadding:i.fitPadding},o)},FlowMap:zl};function El(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function Rl(t,e){if(0===e.categories.length)return;const n=e.position||"right",o=function(t){const{width:e,height:n,swatchSize:o}=ri(t);return{width:e,height:n,swatchSize:o}}({categories:e.categories,theme:e.theme,position:n,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,legendLayout:e.legendLayout});"right"===n?t.right=Math.max(t.right,o.width+14):"left"===n?t.left=Math.max(t.left,o.width+14):"top"===n?t.top=Math.max(t.top,(e.hasTitle?32:8)+o.height+4):t.bottom=Math.max(t.bottom,38+o.height+4)}function Nl(t,e){const n=e.position||"right",o={theme:e.theme,position:n,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout},i=Lt(e.legend)?function(t){const{width:e,height:n,swatchSize:o}=si(t);return{width:e,height:n,swatchSize:o}}(Object.assign(Object.assign({},o),{legendGroups:e.legend.legendGroups})):Ct(e.legend)?ai(Object.assign(Object.assign({},o),{gradient:e.legend.gradient})):null;i&&("right"===n?t.right=Math.max(t.right,i.width+14):"left"===n?t.left=Math.max(t.left,i.width+14):"top"===n?t.top=Math.max(t.top,(e.hasTitle?32:8)+i.height+4):t.bottom=Math.max(t.bottom,38+i.height+4))}function Fl(n,o){const i={theme:o.theme,position:o.position||"right",totalWidth:o.size[0],totalHeight:o.size[1],margin:o.margin,hasTitle:o.hasTitle,legendLayout:o.legendLayout,idPrefix:o.idPrefix};return Lt(n)?function(n){if(0===(o=n.legendGroups,o.flatMap(t=>t.items.map((e,n)=>({group:t,item:e,itemIndex:n,label:e.label})))).length)return null;var o;const i=si(n),r="top"===n.position||"bottom"===n.position,s=n.theme.colors.grid||n.theme.colors.textSecondary;let a,l;"left"===n.position?(a=Math.max(4,n.margin.left-i.width-10),l=n.margin.top):"top"===n.position?(a=n.margin.left,l=n.hasTitle?32:8):"bottom"===n.position?(a=n.margin.left,l=Math.min(n.totalHeight-n.margin.bottom+38,n.totalHeight-i.height-2)):(a=Math.min(n.totalWidth-i.width-4,n.totalWidth-n.margin.right+10),l=n.margin.top);const c=i.groups.flatMap((o,a)=>{var l;const{group:c}=o,u=null!==(l=c.type)&&void 0!==l?l:"fill",d=[];if(c.label&&d.push(t("text",r?{transform:`translate(${o.x},${o.y}) rotate(90)`,textAnchor:"start",fontSize:oi(n.theme),fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:c.label}:{x:o.x,y:o.y+oi(n.theme),fontSize:oi(n.theme),fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:c.label},"legend-group-label-"+a)),d.push(...o.items.map((r,s)=>{const l=c.items[s],d=c.styleFn(l,s),h="function"==typeof u?u(l):"line"===u?t("line",{x1:0,y1:0,x2:i.swatchSize,y2:i.swatchSize,style:d}):t("rect",{width:i.swatchSize,height:i.swatchSize,rx:i.swatchRadius,style:d});return e("g",{transform:`translate(${o.x+o.itemOffsetX+r.x},${o.y+o.itemOffsetY+r.y})`,children:[h,t("text",{x:i.labelOffset,y:i.swatchSize/2,dominantBaseline:"central",fontSize:oi(n.theme),fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:r.category})]},`legend-${a}-${s}`)})),!r&&i.groups.length-1>a)d.push(t("line",{x1:0,y1:o.y+o.height-6,x2:i.width,y2:o.y+o.height-6,stroke:s},"legend-group-separator-"+a));else if(r&&i.groups.length-1>a){const e=o.x+o.width+6;d.push(t("line",{x1:e,y1:0,x2:e,y2:i.height,stroke:s},"legend-group-separator-"+a))}return d});return t("g",{className:"semiotic-legend",transform:`translate(${a},${l})`,"data-orientation":r?"horizontal":"vertical",children:c})}(Object.assign(Object.assign({},i),{legendGroups:n.legendGroups})):Ct(n)?function(n){const o=ai(n),i="top"===n.position||"bottom"===n.position,r=(n.idPrefix?n.idPrefix+"-":"")+"semiotic-static-gradient-legend",s=n.gradient.format||(t=>Math.round(100*t)/100+"");let a,l;"left"===n.position?(a=Math.max(4,n.margin.left-o.width-10),l=n.margin.top):"top"===n.position?(a=n.margin.left,l=n.hasTitle?32:8):"bottom"===n.position?(a=n.margin.left,l=Math.min(n.totalHeight-n.margin.bottom+38,n.totalHeight-o.height-2)):(a=Math.min(n.totalWidth-o.width-4,n.totalWidth-n.margin.right+10),l=n.margin.top);const c=Array.from({length:17},(e,o)=>{const r=o/16;return t("stop",{offset:100*r+"%",stopColor:n.gradient.colorFn(i?n.gradient.domain[0]+r*(n.gradient.domain[1]-n.gradient.domain[0]):n.gradient.domain[1]-r*(n.gradient.domain[1]-n.gradient.domain[0]))},o)});if(i){const i=12,u=n.gradient.label?0:void 0,d=n.gradient.label?8:0;return e("g",{className:"semiotic-legend",transform:`translate(${a},${l})`,children:[t("defs",{children:t("linearGradient",{id:r,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),n.gradient.label&&t("text",{x:o.width/2,y:u,textAnchor:"middle",fontSize:n.theme.typography.tickSize,fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:n.gradient.label}),t("rect",{x:0,y:d,width:o.width,height:i,fill:`url(#${r})`,rx:2}),t("text",{x:0,y:d+i+12,textAnchor:"start",fontSize:n.theme.typography.tickSize,fill:n.theme.colors.textSecondary,fontFamily:n.theme.typography.fontFamily,children:s(n.gradient.domain[0])}),t("text",{x:o.width,y:d+i+12,textAnchor:"end",fontSize:n.theme.typography.tickSize,fill:n.theme.colors.textSecondary,fontFamily:n.theme.typography.fontFamily,children:s(n.gradient.domain[1])})]})}const u=n.gradient.label?-6:void 0;return e("g",{className:"semiotic-legend",transform:`translate(${a},${l+(n.gradient.label?12:0)})`,children:[t("defs",{children:t("linearGradient",{id:r,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),n.gradient.label&&t("text",{x:7,y:u,textAnchor:"middle",fontSize:n.theme.typography.tickSize,fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:n.gradient.label}),t("rect",{x:0,y:0,width:14,height:100,fill:`url(#${r})`,rx:2}),t("text",{x:19,y:10,fontSize:n.theme.typography.tickSize,fill:n.theme.colors.textSecondary,fontFamily:n.theme.typography.fontFamily,children:s(n.gradient.domain[1])}),t("text",{x:19,y:100,fontSize:n.theme.typography.tickSize,fill:n.theme.colors.textSecondary,fontFamily:n.theme.typography.fontFamily,children:s(n.gradient.domain[0])})]})}(Object.assign(Object.assign({},i),{gradient:n.gradient})):null}function Wl(t){return Math.round(100*t)/100+""}function Bl(n,o){const i=ei(o.theme),r=o.idPrefix?o.idPrefix+"-":"",s="string"==typeof o.title?o.title:void 0,a=s?r+"semiotic-title":void 0,l=o.description?r+"semiotic-desc":void 0,c=[a,l].filter(Boolean).join(" ")||void 0;return e("svg",{xmlns:"http://www.w3.org/2000/svg",className:o.className,width:o.width,height:o.height,role:"img","aria-labelledby":c,style:{fontFamily:i.fontFamily},children:[s&&t("title",{id:a,children:s}),o.description&&t("desc",{id:l,children:o.description}),o.defs&&t("defs",{children:o.defs}),o.background&&"transparent"!==o.background&&t("rect",{x:0,y:0,width:o.width,height:o.height,fill:o.background}),t("g",{id:r+"data-area",transform:o.innerTransform,children:n}),s&&t("text",{id:r+"chart-title",x:o.width/2,y:16,textAnchor:"middle",fontSize:i.titleSize,fontWeight:"bold",fill:i.text,fontFamily:i.fontFamily,children:s}),o.legend&&t("g",{id:r+"legend",children:o.legend}),o.outerElements]})}function Il(i,r){var s,a,l,c,u,d,h,f;const g=ti(i.theme),y=i.size||[500,300],m=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),i.margin),v=mr(i.data),b=i.showLegend?ci(v,i.colorAccessor||i.groupAccessor):[],x=i.legendPosition;Lt(i.legend)||Ct(i.legend)?Nl(m,{legend:i.legend,theme:g,position:x||"right",size:y,hasTitle:!!i.title,legendLayout:i.legendLayout}):i.showLegend&&b.length>0&&Rl(m,{categories:b,theme:g,position:x||"right",size:y,hasTitle:!!i.title,legendLayout:i.legendLayout});const k=y[0]-m.left-m.right,w=y[1]-m.top-m.bottom,A="streaming"===i.runtimeMode||["bar","swarm","waterfall"].includes(i.chartType),S=i.colorScheme||g.colors.categorical,M={chartType:i.chartType,windowSize:null!==(s=i.windowSize)&&void 0!==s?s:200,windowMode:null!==(a=i.windowMode)&&void 0!==a?a:"sliding",arrowOfTime:A&&null!==(l=i.arrowOfTime)&&void 0!==l?l:"right",extentPadding:null!==(c=i.extentPadding)&&void 0!==c?c:.1,xAccessor:A?void 0:i.xAccessor,yAccessor:A?void 0:i.yAccessor,timeAccessor:A?i.timeAccessor:void 0,valueAccessor:i.valueAccessor,colorAccessor:i.colorAccessor,sizeAccessor:i.sizeAccessor,groupAccessor:i.groupAccessor,categoryAccessor:i.categoryAccessor,lineDataAccessor:i.lineDataAccessor,xExtent:i.xExtent,yExtent:i.yExtent,sizeRange:i.sizeRange,xScaleType:i.xScaleType,yScaleType:i.yScaleType,scalePadding:i.scalePadding,binSize:i.binSize,normalize:i.normalize,boundsAccessor:i.boundsAccessor,boundsStyle:i.boundsStyle,y0Accessor:i.y0Accessor,areaGroups:i.areaGroups?i.areaGroups instanceof Set?i.areaGroups:new Set(i.areaGroups):void 0,curve:i.curve,gradientFill:!0===i.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===i.gradientFill?void 0:i.gradientFill,lineGradient:i.lineGradient,openAccessor:i.openAccessor,highAccessor:i.highAccessor,lowAccessor:i.lowAccessor,closeAccessor:i.closeAccessor,candlestickStyle:i.candlestickStyle,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,barStyle:i.barStyle,waterfallStyle:i.waterfallStyle,swarmStyle:i.swarmStyle,colorScheme:S,barColors:i.barColors},_=new He(M);if(i.data&&_.ingest({inserts:v,bounded:!0}),_.computeScene({width:k,height:w}),!_.scales||0===_.scene.length)return r&&(r.evidence=$o({frameType:"xy",width:y[0],height:y[1],marks:[],title:i.title,description:i.description,annotations:i.annotations,extraWarnings:_.scales?[]:["NO_SCALES"]})),p.renderToStaticMarkup(Bl(null,{width:y[0],height:y[1],className:"stream-xy-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:g,innerTransform:`translate(${m.left},${m.top})`,idPrefix:i._idPrefix}));r&&(r.evidence=$o({frameType:"xy",width:y[0],height:y[1],marks:_.scene,title:i.title,description:i.description,annotations:i.annotations,xDomain:To(null===(d=null===(u=_.scales.x)||void 0===u?void 0:u.domain)||void 0===d?void 0:d.call(u)),yDomain:To(null===(f=null===(h=_.scales.y)||void 0===h?void 0:h.domain)||void 0===f?void 0:f.call(h)),legendItems:b.length>0?b.length:void 0}));const P=i._idPrefix,O=i.showGrid?function(n,o,i,r){const{grid:s}=ei(i),a=r?r+"-":"",l=n.x.ticks(5),c=n.y.ticks(5);return e("g",{id:a+"grid",className:"semiotic-grid",opacity:.8,children:[l.map((e,i)=>{const r=n.x(e);return t("line",{x1:r,y1:0,x2:r,y2:o.height,stroke:s,strokeWidth:.5},"gx-"+i)}),c.map((e,i)=>{const r=n.y(e);return t("line",{x1:0,y1:r,x2:o.width,y2:r,stroke:s,strokeWidth:.5},"gy-"+i)})]})}(_.scales,{width:k,height:w},g,P):null,T=_.scene.map((t,e)=>Fo(t,e,P)).filter(Boolean),$=!1!==i.showAxes?function(n,o,i,r,s){var a,l,c,u;const d=ei(r),h=n.x.ticks(5).map(t=>({pixel:n.x(t),label:(i.xFormat||i.tickFormatTime||Wl)(t)})),f=n.y.ticks(5).map(t=>({pixel:n.y(t),label:(i.yFormat||i.tickFormatValue||Wl)(t)}));return e("g",{id:(s?s+"-":"")+"axes",className:"stream-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:d.border,strokeWidth:1}),h.map((n,i)=>e("g",{transform:`translate(${n.pixel},${o.height})`,children:[t("line",{y2:5,stroke:d.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:d.tickSize,fill:d.textSecondary,fontFamily:d.fontFamily,children:n.label})]},"xtick-"+i)),i.xLabel&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:d.labelSize,fill:d.text,fontFamily:d.fontFamily,children:i.xLabel}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:d.border,strokeWidth:1}),f.map((n,o)=>e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:d.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:d.tickSize,fill:d.textSecondary,fontFamily:d.fontFamily,children:n.label})]},"ytick-"+o)),i.yLabel&&t("text",{x:15-(null!==(l=null===(a=i.margin)||void 0===a?void 0:a.left)&&void 0!==l?l:40),y:o.height/2,textAnchor:"middle",fontSize:d.labelSize,fill:d.text,fontFamily:d.fontFamily,transform:`rotate(-90, ${15-(null!==(u=null===(c=i.margin)||void 0===c?void 0:c.left)&&void 0!==u?u:40)}, ${o.height/2})`,children:i.yLabel})]})}(_.scales,{width:k,height:w},i,g,P):null,j=i.annotations?Zi({annotations:i.annotations,autoPlaceAnnotations:i.autoPlaceAnnotations,scales:{x:_.scales.x,y:_.scales.y},layout:{width:k,height:w},theme:g,xAccessor:"string"==typeof i.xAccessor?i.xAccessor:void 0,yAccessor:"string"==typeof i.yAccessor?i.yAccessor:void 0,idPrefix:P}):null,L=i.svgPreRenderers&&_.scales?i.svgPreRenderers.map((e,n)=>{try{return t(o.Fragment,{children:e(_.scene,_.scales,{width:k,height:w})},"pre-"+n)}catch(t){return null}}).filter(Boolean):null,C=i.showLegend?0===b.length?null:li({categories:b,colorScheme:i.colorScheme,theme:g,position:i.legendPosition||"right",totalWidth:y[0],totalHeight:y[1],margin:m,hasTitle:!!i.title,legendLayout:i.legendLayout}):null,z=o.isValidElement(i.legend)?i.legend:Fl(i.legend,{theme:g,position:i.legendPosition||"right",size:y,margin:m,hasTitle:!!i.title,legendLayout:i.legendLayout,idPrefix:i._idPrefix})||C,D=e(n,{children:[i.backgroundGraphics,L,O,T,$,j,i.foregroundGraphics]});return p.renderToStaticMarkup(Bl(D,{width:y[0],height:y[1],className:"stream-xy-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:g,innerTransform:`translate(${m.left},${m.top})`,legend:z,idPrefix:i._idPrefix}))}function Yl(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const Gl=new Set(["tree","cluster","treemap","circlepack","partition"]);function Hl(i,r){var s,a,l,c,u;const d=ti(i.theme),h=i.chartType||"force",f=()=>$o({frameType:"network",width:g[0],height:g[1],marks:[],title:i.title,description:i.description,annotations:i.annotations,nodeCount:0,edgeCount:0}),g=i.size||[500,500],y=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),i.margin),m=i.showLegend?(()=>{const t="string"==typeof(e=i.colorBy)||"function"==typeof e?i.colorBy:void 0;var e;if(!t)return[];const n=mr(i.nodes||[]);if(n.length>0)return ci(n,t);const o=Array.isArray(i.edges)?mr(i.edges):[];if(0===o.length)return[];const r=Yl(i.sourceAccessor,"source"),s=Yl(i.targetAccessor,"target");return ci(Array.from(new Set(o.flatMap(t=>[r(t),s(t)]).filter(t=>null!=t).map(String))).map(t=>({id:t})),t)})():[],v=i.legendPosition;Lt(i.legend)||Ct(i.legend)?Nl(y,{legend:i.legend,theme:d,position:v||"right",size:g,hasTitle:!!i.title,legendLayout:i.legendLayout}):i.showLegend&&m.length>0&&Rl(y,{categories:m,theme:d,position:v||"right",size:g,hasTitle:!!i.title,legendLayout:i.legendLayout});const b=g[0]-y.left-y.right,x=g[1]-y.top-y.bottom,k=function(t){return co[t]}(h);if(!k)throw Error(`No layout plugin found for chart type: "${h}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const w={chartType:h,nodeIDAccessor:i.nodeIDAccessor,sourceAccessor:i.sourceAccessor,targetAccessor:i.targetAccessor,valueAccessor:i.valueAccessor,childrenAccessor:i.childrenAccessor,hierarchySum:i.hierarchySum,orientation:i.orientation,nodeAlign:i.nodeAlign,nodePaddingRatio:i.nodePaddingRatio,nodeWidth:i.nodeWidth,iterations:i.iterations,forceStrength:i.forceStrength,padAngle:i.padAngle,groupWidth:i.groupWidth,sortGroups:i.sortGroups,edgeSort:i.edgeSort,treeOrientation:i.treeOrientation,edgeType:i.edgeType,padding:i.padding,paddingTop:i.paddingTop,nodeStyle:i.nodeStyle,edgeStyle:i.edgeStyle,nodeLabel:i.nodeLabel,showLabels:i.showLabels,colorBy:i.colorBy,colorScheme:i.colorScheme||d.colors.categorical,edgeColorBy:i.edgeColorBy,edgeOpacity:i.edgeOpacity,colorByDepth:i.colorByDepth,nodeSize:i.nodeSize,nodeSizeRange:i.nodeSizeRange,customNetworkLayout:i.customNetworkLayout,layoutConfig:i.layoutConfig};let A,S;if(Gl.has(h)){const t=i.data||i.edges;if(!t||Array.isArray(t))return r&&(r.evidence=f()),p.renderToStaticMarkup(Bl(null,{width:g[0],height:g[1],className:"stream-network-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:d,innerTransform:`translate(${y.left},${y.top})`,idPrefix:i._idPrefix}));w.__hierarchyRoot=t,A=[],S=[]}else{const t=mr(i.nodes||[]),e=Array.isArray(i.edges)?mr(i.edges):[];if(0===t.length&&0===e.length)return r&&(r.evidence=f()),p.renderToStaticMarkup(Bl(null,{width:g[0],height:g[1],className:"stream-network-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:d,innerTransform:`translate(${y.left},${y.top})`,idPrefix:i._idPrefix}));if(S=function(t,e){const n=Yl(e.sourceAccessor,"source"),o=Yl(e.targetAccessor,"target"),i=Yl(e.valueAccessor,"value");return t.map(t=>({source:n(t)+"",target:o(t)+"",value:Number(i(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(e,w),0===t.length&&S.length>0){const t=new Set;for(const e of S){const n=El(e.source),o=El(e.target);n&&t.add(n),o&&t.add(o)}A=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else A=function(t,e){const n=Yl(e.nodeIDAccessor,"id");return t.map(t=>{var e,o;return{id:n(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(o=t.y)&&void 0!==o?o:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(t,w)}let M=[],_=[],P=[],O=null;if(w.customNetworkLayout){const t=uo(w.colorScheme,d.colors.categorical,Qt),e=ho(t),n={nodes:A,edges:S,dimensions:{width:b,height:x,plot:{x:0,y:0,width:b,height:x}},theme:{semantic:d.colors,categorical:[...t]},resolveColor:e,config:null!==(s=w.layoutConfig)&&void 0!==s?s:{}},o=w.customNetworkLayout(n);M=null!==(a=o.sceneNodes)&&void 0!==a?a:[],_=null!==(l=o.sceneEdges)&&void 0!==l?l:[],P=null!==(c=o.labels)&&void 0!==c?c:[],O=null!==(u=o.overlays)&&void 0!==u?u:null}else{k.computeLayout(A,S,w,[b,x]);const t=k.buildScene(A,S,w,[b,x]);M=t.sceneNodes,_=t.sceneEdges,P=t.labels}const T=ei(d);for(const t of P)t.fill||(t.fill=T.text);r&&(r.evidence=$o({frameType:"network",width:g[0],height:g[1],marks:[...M.map(t=>{var e;return{type:"node:"+(null!==(e=t.type)&&void 0!==e?e:"node")}}),..._.map(t=>{var e;return{type:"edge:"+(null!==(e=t.type)&&void 0!==e?e:"edge")}})],title:i.title,description:i.description,annotations:i.annotations,nodeCount:M.length,edgeCount:_.length}));const $=_.map((e,n)=>function(e,n){switch(e.type){case"line":return t("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-"+n);case"bezier":{const o=e;return t("path",{d:o.pathD,fill:Eo(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"ribbon":{const o=e;return t("path",{d:o.pathD,fill:Eo(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"curved":{const o=e;return t("path",{d:o.pathD,fill:Eo(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+n)}default:return null}}(e,n)).filter(Boolean),L=M.map((e,n)=>function(e,n){switch(e.type){case"circle":{const o=e;return t("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:Eo(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+n)}case"rect":{const o=e;return t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Eo(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+n)}case"arc":{const o=e,i=j().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)(Do)||"";return t("path",{d:i,transform:`translate(${o.cx},${o.cy})`,fill:Eo(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+n)}case"symbol":{const o=e,i=Ee(o.symbolType,o.size,o.path);return t("path",{d:i,transform:o.rotation?`translate(${o.cx},${o.cy}) rotate(${180*o.rotation/Math.PI})`:`translate(${o.cx},${o.cy})`,fill:o.style.fill?Eo(o.style.fill):"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-symbol-"+n)}default:return null}}(e,n)).filter(Boolean),C=P.map((e,n)=>function(e,n){return t("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||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+n)}(e,n)).filter(Boolean),z=i.annotations?Zi({annotations:i.annotations,autoPlaceAnnotations:i.autoPlaceAnnotations,scales:{},layout:{width:b,height:x},theme:d,idPrefix:i._idPrefix}):null,D=i.showLegend?(()=>{const t="string"==typeof(e=i.colorBy)||"function"==typeof e?i.colorBy:void 0;var e;if(!t)return[];const n=ci(A.length>0?A.map(t=>t.data||{id:t.id}):Array.from(new Set(S.flatMap(t=>[El(t.source),El(t.target)]).filter(Boolean))).map(t=>({id:t})),t);return 0===n.length?null:li({categories:n,colorScheme:i.colorScheme,theme:d,position:i.legendPosition||"right",totalWidth:g[0],totalHeight:g[1],margin:y,hasTitle:!!i.title,legendLayout:i.legendLayout})})():null,E=o.isValidElement(i.legend)?i.legend:Fl(i.legend,{theme:d,position:i.legendPosition||"right",size:g,margin:y,hasTitle:!!i.title,legendLayout:i.legendLayout,idPrefix:i._idPrefix})||D,R=e(n,{children:[i.backgroundGraphics,$,L,C,z,i.foregroundGraphics,O]});return p.renderToStaticMarkup(Bl(R,{width:g[0],height:g[1],className:"stream-network-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:d,innerTransform:`translate(${y.left},${y.top})`,legend:E,idPrefix:i._idPrefix}))}function Xl(i,r){var s,a,l,c,u,d,h,f,g;const y=ti(i.theme),m=i.size||[500,400],v=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),i.margin),b=mr(i.data),x=i.showLegend?ci(b,i.colorAccessor||i.stackBy||i.groupBy):[],k=i.legendPosition;Lt(i.legend)||Ct(i.legend)?Nl(v,{legend:i.legend,theme:y,position:k||"right",size:m,hasTitle:!!i.title,legendLayout:i.legendLayout}):i.showLegend&&x.length>0&&Rl(v,{categories:x,theme:y,position:k||"right",size:m,hasTitle:!!i.title,legendLayout:i.legendLayout});const w=m[0]-v.left-v.right,A=m[1]-v.top-v.bottom,S=i.projection||"vertical",M="radial"===S,_={chartType:i.chartType,windowSize:null!==(s=i.windowSize)&&void 0!==s?s:1e4,windowMode:null!==(a=i.windowMode)&&void 0!==a?a:"sliding",extentPadding:null!==(l=i.extentPadding)&&void 0!==l?l:.05,projection:S,oAccessor:i.oAccessor,rAccessor:i.rAccessor,colorAccessor:i.colorAccessor,stackBy:i.stackBy,groupBy:i.groupBy,categoryAccessor:i.categoryAccessor,valueAccessor:i.valueAccessor,timeAccessor:i.timeAccessor,rExtent:i.rExtent,oExtent:i.oExtent,barPadding:i.barPadding,roundedTop:i.roundedTop,innerRadius:i.innerRadius,cornerRadius:i.cornerRadius,normalize:i.normalize,startAngle:i.startAngle,sweepAngle:i.sweepAngle,bins:i.bins,showOutliers:i.showOutliers,showIQR:i.showIQR,amplitude:i.amplitude,oSort:i.oSort,connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,dynamicColumnWidth:i.dynamicColumnWidth,pieceStyle:i.pieceStyle,summaryStyle:i.summaryStyle,colorScheme:i.colorScheme||y.colors.categorical,barColors:i.barColors},P=new vo(_);if(i.data&&P.ingest({inserts:b,bounded:!0}),P.computeScene({width:w,height:A}),!P.scales||0===P.scene.length)return r&&(r.evidence=$o({frameType:"ordinal",width:m[0],height:m[1],marks:[],title:i.title,description:i.description,annotations:i.annotations,extraWarnings:P.scales?[]:["NO_SCALES"]})),p.renderToStaticMarkup(Bl(null,{width:m[0],height:m[1],className:"stream-ordinal-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:y,innerTransform:`translate(${v.left},${v.top})`,idPrefix:i._idPrefix}));if(r){const t=null===(u=null===(c=P.scales.o)||void 0===c?void 0:c.domain)||void 0===u?void 0:u.call(c);r.evidence=$o({frameType:"ordinal",width:m[0],height:m[1],marks:P.scene,title:i.title,description:i.description,annotations:i.annotations,yDomain:To(null===(h=null===(d=P.scales.r)||void 0===d?void 0:d.domain)||void 0===h?void 0:h.call(d)),categories:Array.isArray(t)?t.map(String):void 0})}const O=i._idPrefix,T=i.showGrid?function(e,n,o,i){const r=e.scales;if(!r||"radial"===r.projection)return null;const{grid:s}=ei(o),a=i?i+"-":"",l="vertical"===r.projection,c=r.r.ticks(5);return t("g",l?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,o)=>{const i=r.r(e);return t("line",{x1:0,y1:i,x2:n.width,y2:i,stroke:s,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,o)=>{const i=r.r(e);return t("line",{x1:i,y1:0,x2:i,y2:n.height,stroke:s,strokeWidth:.5},"gr-"+o)})})}(P,{width:w,height:A},y,O):null,$=P.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let j=null;if($){const n=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const n=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;n.length>t;t++)o=31*o+n.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(i),o=new Set;for(const t of P.scene)"rect"===t.type&&(null===(f=t.datum)||void 0===f?void 0:f.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");j=Array.from(o).map((o,i)=>function(n){const{id:o,background:i="transparent",stroke:r="#000",lineWidth:s=1.5,spacing:a=6,angle:l=45}=n,c=Math.max(8,Math.ceil(2*a));return e("pattern",{id:o,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==l?`rotate(${l})`:void 0,children:[i&&"transparent"!==i&&t("rect",{width:c,height:c,fill:i}),t("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:s}),t("line",{x1:a,y1:0,x2:a,y2:c,stroke:r,strokeWidth:s})]},o)}({id:`funnel-hatch-${n}-${i}`,background:o,stroke:"transparent"===y.colors.background?"#fff":y.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(o).forEach((t,e)=>r.set(t,`funnel-hatch-${n}-${e}`));for(const t of P.scene)if("rect"===t.type&&(null===(g=t.datum)||void 0===g?void 0:g.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${r.get(e)})`})}}const L=P.scene.map((t,e)=>Wo(t,e,O)).filter(Boolean),C=!1!==i.showAxes?function(n,o,i,r,s){var a,l,c,u,d,h,f,g;const y=n.scales;if(!y)return null;if("radial"===y.projection)return null;const p=ei(r),m="vertical"===y.projection,v=i.categoryFormat||i.oFormat,b=i.valueFormat||i.rFormat,x=i.categoryLabel||i.oLabel,k=i.valueLabel||i.rLabel,w=Object.values(n.columns).map(t=>({pixel:t.middle,label:(v||String)(t.name)})),A=y.r.ticks(5).map(t=>({pixel:y.r(t),label:(b||Wl)(t)}));return e("g",m?{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:p.border,strokeWidth:1}),w.map((n,i)=>e("g",{transform:`translate(${n.pixel},${o.height})`,children:[t("line",{y2:5,stroke:p.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:n.label})]},"oxtick-"+i)),x&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,children:x}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:p.border,strokeWidth:1}),A.map((n,o)=>e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:p.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:n.label})]},"oytick-"+o)),k&&t("text",{x:15-(null!==(l=null===(a=i.margin)||void 0===a?void 0:a.left)&&void 0!==l?l:40),y:o.height/2,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,transform:`rotate(-90, ${15-(null!==(u=null===(c=i.margin)||void 0===c?void 0:c.left)&&void 0!==u?u:40)}, ${o.height/2})`,children:k})]}:{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:p.border,strokeWidth:1}),A.map((n,i)=>e("g",{transform:`translate(${n.pixel},${o.height})`,children:[t("line",{y2:5,stroke:p.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:n.label})]},"oxtick-"+i)),k&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,children:k}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:p.border,strokeWidth:1}),w.map((n,o)=>e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:p.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:n.label})]},"oytick-"+o)),x&&t("text",{x:15-(null!==(h=null===(d=i.margin)||void 0===d?void 0:d.left)&&void 0!==h?h:40),y:o.height/2,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,transform:`rotate(-90, ${15-(null!==(g=null===(f=i.margin)||void 0===f?void 0:f.left)&&void 0!==g?g:40)}, ${o.height/2})`,children:x})]})}(P,{width:w,height:A},i,y,O):null,z=i.annotations?Zi({annotations:i.annotations,autoPlaceAnnotations:i.autoPlaceAnnotations,scales:{r:P.scales.r,y:"vertical"===P.scales.projection?P.scales.r:void 0},layout:{width:w,height:A},theme:y,projection:S,idPrefix:O}):null,D=i.showLegend?0===x.length?null:li({categories:x,colorScheme:i.colorScheme,theme:y,position:i.legendPosition||"right",totalWidth:m[0],totalHeight:m[1],margin:v,hasTitle:!!i.title,legendLayout:i.legendLayout}):null,E=o.isValidElement(i.legend)?i.legend:Fl(i.legend,{theme:y,position:i.legendPosition||"right",size:m,margin:v,hasTitle:!!i.title,legendLayout:i.legendLayout,idPrefix:i._idPrefix})||D,R=M?v.left+w/2:v.left,N=M?v.top+A/2:v.top,F=e(n,{children:[i.backgroundGraphics,T,L,C,z,i.foregroundGraphics]});return p.renderToStaticMarkup(Bl(F,{width:m[0],height:m[1],className:"stream-ordinal-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:y,innerTransform:`translate(${R},${N})`,legend:E,defs:j,idPrefix:i._idPrefix}))}function ql(i,r){var s,a,l,c,u,d,h,f,g,y;const m=ti(i.theme),v=i.size||[i.width||600,i.height||400],b=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),i.margin),x=Array.isArray(i.areas)?mr(i.areas):i.areas,k=mr(i.points),w=mr(i.lines),A=i.showLegend?(()=>{const t="string"==typeof(e=i.colorBy)||"function"==typeof e?i.colorBy:void 0;var e;return ci(k.length>0?k:Array.isArray(x)&&x.length>0?"string"==typeof t?x.map(t=>Object.assign(Object.assign({},t.properties||{}),t)):x:[],t)})():[],S=i.legendPosition;Lt(i.legend)||Ct(i.legend)?Nl(b,{legend:i.legend,theme:m,position:S||"right",size:v,hasTitle:!!i.title,legendLayout:i.legendLayout}):i.showLegend&&A.length>0&&Rl(b,{categories:A,theme:m,position:S||"right",size:v,hasTitle:!!i.title,legendLayout:i.legendLayout});const M=v[0]-(null!==(s=b.left)&&void 0!==s?s:0)-(null!==(a=b.right)&&void 0!==a?a:0),_=v[1]-(null!==(l=b.top)&&void 0!==l?l:0)-(null!==(c=b.bottom)&&void 0!==c?c:0),P=new Po({projection:i.projection||"equalEarth",xAccessor:i.xAccessor,yAccessor:i.yAccessor,lineDataAccessor:i.lineDataAccessor,pointIdAccessor:i.pointIdAccessor,lineType:i.lineType,areaStyle:i.areaStyle,pointStyle:i.pointStyle,lineStyle:i.lineStyle,graticule:i.graticule,fitPadding:i.fitPadding,projectionTransform:i.projectionTransform});if(x){if("string"==typeof x)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${x}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${x}')\` before calling renderGeoToStaticSVG.`);P.setAreas(x)}if(i.points&&P.setPoints(k),i.lines&&P.setLines(w),P.computeScene({width:M,height:_}),r&&(r.evidence=$o({frameType:"geo",width:v[0],height:v[1],marks:P.scene,title:i.title,description:i.description,annotations:i.annotations,legendItems:A.length>0?A.length:void 0})),0===P.scene.length){const t=i.backgroundGraphics||i.foregroundGraphics||i.annotations?e(n,{children:[i.backgroundGraphics,i.annotations?Zi({annotations:i.annotations,autoPlaceAnnotations:i.autoPlaceAnnotations,scales:{geoProjection:(null===(u=P.scales)||void 0===u?void 0:u.projectedPoint)?([t,e])=>P.scales.projectedPoint(t,e):void 0},layout:{width:M,height:_},theme:m,idPrefix:i._idPrefix}):null,i.foregroundGraphics]}):null;return p.renderToStaticMarkup(Bl(t,{width:v[0],height:v[1],className:"stream-geo-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:m,innerTransform:`translate(${null!==(d=b.left)&&void 0!==d?d:0},${null!==(h=b.top)&&void 0!==h?h:0})`,idPrefix:i._idPrefix}))}const O=P.scene.map((e,n)=>function(e,n){var o,i,r,s,a,l;switch(e.type){case"geoarea":{const r=e;return r.pathData?t("path",{d:r.pathData,fill:Eo(r.style.fill,"#e0e0e0"),fillOpacity:null!==(o=r.style.fillOpacity)&&void 0!==o?o:1,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth||.5,strokeDasharray:r.style.strokeDasharray,opacity:null!==(i=r._decayOpacity)&&void 0!==i?i:1},"geoarea-"+n):null}case"point":{const o=e;return t("circle",{cx:o.x,cy:o.y,r:o.r,fill:Eo(o.style.fill),fillOpacity:null!==(r=o.style.fillOpacity)&&void 0!==r?r:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(s=o._decayOpacity)&&void 0!==s?s:null!==(a=o.style.opacity)&&void 0!==a?a:1},"point-"+n)}case"line":{const o=e;if(2>o.path.length)return null;const i="M"+o.path.map(t=>`${t[0]},${t[1]}`).join("L");return t("path",{d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(l=o.style.opacity)&&void 0!==l?l:1},"line-"+n)}default:return null}}(e,n)).filter(Boolean),T=i.annotations?Zi({annotations:i.annotations,autoPlaceAnnotations:i.autoPlaceAnnotations,scales:{geoProjection:(null===(f=P.scales)||void 0===f?void 0:f.projectedPoint)?([t,e])=>P.scales.projectedPoint(t,e):void 0},layout:{width:M,height:_},theme:m,idPrefix:i._idPrefix}):null,$=i.showLegend?0===A.length?null:li({categories:A,colorScheme:i.colorScheme,theme:m,position:i.legendPosition||"right",totalWidth:v[0],totalHeight:v[1],margin:b,hasTitle:!!i.title,legendLayout:i.legendLayout}):null,j=o.isValidElement(i.legend)?i.legend:Fl(i.legend,{theme:m,position:i.legendPosition||"right",size:v,margin:b,hasTitle:!!i.title,legendLayout:i.legendLayout,idPrefix:i._idPrefix})||$,L=e(n,{children:[i.backgroundGraphics,O,T,i.foregroundGraphics]});return p.renderToStaticMarkup(Bl(L,{width:v[0],height:v[1],className:"stream-geo-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:m,innerTransform:`translate(${null!==(g=b.left)&&void 0!==g?g:0},${null!==(y=b.top)&&void 0!==y?y:0})`,legend:j,idPrefix:i._idPrefix}))}function Vl(t,e){switch(t){case"xy":return Il(e);case"ordinal":return Xl(e);case"network":return Hl(e);case"geo":return ql(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Ul(t){return Il(t)}function Zl(t){return Xl(t)}function Ql(t){return Hl(t)}function Kl(t){return ql(t)}const Jl=["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 tc(t,e,n){return nc(t,e).svg}function ec(t,e,n){var o;const i={},{svg:r,frameType:s}=nc(t,e,0,i),a=null!==(o=i.evidence)&&void 0!==o?o:$o({frameType:s,width:"number"==typeof e.width?e.width:600,height:"number"==typeof e.height?e.height:400,marks:[],title:"string"==typeof e.title?e.title:void 0,description:"string"==typeof e.description?e.description:void 0,annotations:e.annotations,extraWarnings:["NO_EVIDENCE"]});return a.component=t,{svg:r,evidence:a}}function nc(o,i,r,s){var a;const{data:l,width:c=600,height:u=400,theme:d,title:h,description:f,showLegend:g,showGrid:y,background:m,className:v,annotations:b,margin:x,colorScheme:k,colorBy:w,legendPosition:A}=i,S=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);o.length>i;i++)0>e.indexOf(o[i])&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(i,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),M=[c,u],_=S.frameProps||{},P=function(t,e){const n={};for(const o of e)void 0!==t[o]&&(n[o]=t[o]);return n}(S,Jl),O=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},_),P),{theme:d,title:h,description:f,showLegend:g,showGrid:y,background:m,className:v,annotations:b,size:M}),void 0!==x&&{margin:x}),void 0!==k&&{colorScheme:k}),void 0!==A&&{legendPosition:A}),{_idPrefix:S._idPrefix}),T=Dl[o];if(!T)throw Error(`Unknown chart component: "${o}". See CLAUDE.md for supported chart types.`);const $=T.buildProps(l,w,k,O,S);let j=(0,{xy:Il,ordinal:Xl,network:Hl,geo:ql}[T.frameType])($,s);if("GaugeChart"===o&&$.__gauge){const o=$.__gauge,i=O.margin||{top:20,right:20,bottom:30,left:40},r=(c||300)-i.left-i.right,s=(u||300)-i.top-i.bottom,l=Math.min(r,s)/2*.85,h=i.left+r/2,f=i.top+s/2,g=Math.max(o.gMin,Math.min(o.gMax,null!==(a=o.value)&&void 0!==a?a:o.gMin)),y=(o.startAngleDeg+(o.gMax===o.gMin?0:(g-o.gMin)/(o.gMax-o.gMin))*o.sweep-90)*Math.PI/180,m=ti(d).colors.text,v=p.renderToStaticMarkup(e(n,{children:[t("line",{x1:h,y1:f,x2:h+l*Math.cos(y),y2:f+l*Math.sin(y),stroke:m,strokeWidth:2.5,strokeLinecap:"round"}),t("circle",{cx:h,cy:f,r:4,fill:m})]}));j=j.replace("</svg>",v+"</svg>")}return{svg:j,frameType:T.frameType}}function oc(t,e){return jt(this,arguments,void 0,function*(t,e,n={}){var o,i,r;const{format:s="png",scale:a=1,background:l}=n;let c,u;c=["xy","ordinal","network","geo"].includes(t)?Vl(t,e):tc(t,e),l&&(c=c.replace(/<svg /,`<svg style="background:${l}" `));try{const t="sharp",e=yield import(t);u=null!==(o=e.default)&&void 0!==o?o:e}catch(t){throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const d=e.width||(null===(i=e.size)||void 0===i?void 0:i[0])||600,h=e.height||(null===(r=e.size)||void 0===r?void 0:r[1])||400,f=u(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*a}).resize(Math.round(d*a),Math.round(h*a));return"jpeg"===s?f.jpeg({quality:90}).toBuffer():f.png().toBuffer()})}function ic(n,o={}){var i;const{title:r,subtitle:s,theme:a,width:l=1200,height:c,layout:u={},background:d}=o,h=ei(ti(a)),f=u.columns||2,g=null!==(i=u.gap)&&void 0!==i?i:16;let y=0;r&&(y+=30),s&&(y+=20),y>0&&(y+=10);const m=Math.floor((l-g-g*(f-1))/f),v=[];let b=0,x=y+g,k=0;for(const t of n){const e=Math.min(t.colSpan||1,f),n=t.props.height||300;b+e>f&&(x+=k+g,b=0,k=0),v.push({chart:t,x:g/2+b*(m+g),y:x,w:m*e+g*(e-1),h:n}),k=Math.max(k,n),b+=e}const w=c||x+k+g,A=v.map((e,n)=>{const{chart:o,x:i,y:r,w:s,h:l}=e,c=Object.assign(Object.assign({},o.props),{width:s,height:l,theme:a,_idPrefix:"chart-"+n});let u;return u=o.component?tc(o.component,c):o.frameType?Vl(o.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${l}"></svg>`,t("g",{transform:`translate(${i},${r})`,children:t("foreignObject",{width:s,height:l,children:t("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})})},"dashboard-chart-"+n)}),S=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:w,role:"img","aria-label":r||"Dashboard",style:{fontFamily:h.fontFamily},children:[r&&t("title",{children:r}),d&&t("rect",{x:0,y:0,width:l,height:w,fill:d}),r&&t("text",{x:l/2,y:24,textAnchor:"middle",fontSize:h.titleSize+4,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily,children:r}),s&&t("text",{x:l/2,y:r?46:20,textAnchor:"middle",fontSize:h.labelSize,fill:h.textSecondary,fontFamily:h.fontFamily,children:s}),A]});return p.renderToStaticMarkup(S)}function rc(t,e,n,o={}){const{stepSize:i,windowSize:r,frameCount:s,xExtent:a,yExtent:l,transitionFrames:c=4,fps:u=12,easing:d="ease-out",decay:h}=o,f=n.width||600,g=n.height||400,y=ti(n.theme),p=Object.assign(Object.assign(Object.assign({},n),a&&{xExtent:a}),l&&{yExtent:l});if(!e||0===e.length)return[];const m=i||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),v=[];for(let t=m;e.length>=t;t+=m)v.push(t);v[v.length-1]!==e.length&&v.push(e.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),x=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),k=f-x.left-x.right,w=g-x.top-x.bottom,A=[];if(b)for(let o=0;v.length>o;o++){const i=v[o],s=e.slice(r?Math.max(0,i-r):0,i),a=Object.assign({chartType:t,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}),l=new vo(a);l.ingest({inserts:s,bounded:!0}),l.computeScene({width:k,height:w}),l.scene.length>0&&A.push(cc(l.scene,f,g,y,p))}else for(let o=0;v.length>o;o++){const i=v[o],s=e.slice(r?Math.max(0,i-r):0,i),m=Object.assign(Object.assign({chartType:t,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:l,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}),c>0&&{transition:{duration:c*(1e3/u),easing:d}}),b=new He(m);if(b.ingest({inserts:s,bounded:!0}),b.computeScene({width:k,height:w}),0===b.scene.length)continue;const x=b.scales?{y:b.scales.y}:void 0;if(A.push(lc(b.scene,f,g,y,p,x)),c>0&&o>0&&b.activeTransition){const t=c*(1e3/u);for(let e=1;c>=e;e++)b.advanceTransition(b.activeTransition.startTime+e/c*t),A.push(lc(b.scene,f,g,y,p,x))}}return A}function sc(t,e,n={}){return e.map(e=>{try{return tc(t,Object.assign(Object.assign({},n),e))}catch(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width||e.width||600}" height="${n.height||e.height||400}"></svg>`}})}function ac(t,e){const n=t.background||e.colors.background;return n&&"transparent"!==n?n:null}function lc(o,i,r,s,a,l){const c=ei(s),u=Object.assign({top:20,right:20,bottom:30,left:40},a.margin),d=i-u.left-u.right,h=r-u.top-u.bottom,f=ac(a,s),g=o.map((t,e)=>Fo(t,e)).filter(Boolean),y=function(o,i,r,s,a,l){var c;if(!o||0===o.length)return null;const u=ei(s),d=[];for(let n=0;o.length>n;n++){const s=o[n];if("y-threshold"===s.type&&null!=s.value){let o=null;if(l)o=l(s.value);else if(a){const[t,e]=a,n=e-t;if(0===n)continue;o=r-(s.value-t)/n*r}if(null==o)continue;const h=s.color||u.primary,f=null!==(c=s.strokeWidth)&&void 0!==c?c:1.5,g=s.labelPosition||"right";d.push(e("g",{children:[t("line",{x1:0,y1:o,x2:i,y2:o,stroke:h,strokeWidth:f,strokeDasharray:s.strokeDasharray||"6,4"}),s.label&&t("text",{x:"left"===g?4:"center"===g?i/2:i-4,y:o-5,textAnchor:"left"===g?"start":"center"===g?"middle":"end",fontSize:u.tickSize,fill:h,fontFamily:u.fontFamily,children:s.label})]},"ann-"+n))}}return d.length>0?t(n,{children:d}):null}(a.annotations,d,h,s,a.yExtent,null==l?void 0:l.y),m="string"==typeof a.title?a.title:void 0,v="string"==typeof a.description?a.description:void 0,b=m?"semiotic-title":void 0,x=v?"semiotic-desc":void 0,k=[b,x].filter(Boolean).join(" ")||void 0,w=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:r,role:"img","aria-labelledby":k,style:{fontFamily:c.fontFamily},children:[m&&t("title",{id:b,children:m}),v&&t("desc",{id:x,children:v}),f&&t("rect",{x:0,y:0,width:i,height:r,fill:f}),e("g",{transform:`translate(${u.left},${u.top})`,children:[y,g]}),m&&t("text",{x:i/2,y:16,textAnchor:"middle",fontSize:c.titleSize,fontWeight:"bold",fill:c.text,fontFamily:c.fontFamily,children:m})]});return p.renderToStaticMarkup(w)}function cc(n,o,i,r,s){const a=ei(r),l=Object.assign({top:20,right:20,bottom:30,left:40},s.margin),c="radial"===s.projection,u=c?l.left+(o-l.left-l.right)/2:l.left,d=c?l.top+(i-l.top-l.bottom)/2:l.top,h=ac(s,r),f=n.map((t,e)=>Wo(t,e)).filter(Boolean),g="string"==typeof s.title?s.title:void 0,y="string"==typeof s.description?s.description:void 0,m=g?"semiotic-title":void 0,v=y?"semiotic-desc":void 0,b=[m,v].filter(Boolean).join(" ")||void 0,x=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:i,role:"img","aria-labelledby":b,style:{fontFamily:a.fontFamily},children:[g&&t("title",{id:m,children:g}),y&&t("desc",{id:v,children:y}),h&&t("rect",{x:0,y:0,width:o,height:i,fill:h}),t("g",{transform:`translate(${u},${d})`,children:f}),g&&t("text",{x:o/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily,children:g})]});return p.renderToStaticMarkup(x)}function uc(t,e,n){return jt(this,arguments,void 0,function*(t,e,n,o={}){var i,r,s,a,l,c,u,d,h,f,g,y,p,m,v,b;const{fps:x=12,loop:k=!0,scale:w=1,background:A}=o,S=n.height||400,M=Math.round((n.width||600)*w),_=Math.round(S*w),P=rc(t,e,A?Object.assign(Object.assign({},n),{background:A}):n,o);if(0===P.length)throw Error("No frames generated — check that data is not empty");let O,T,$,j;try{const t="sharp",e=yield import(t);O=null!==(i=e.default)&&void 0!==i?i:e}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=yield import(t);T=null!==(a=null!==(r=e.GIFEncoder)&&void 0!==r?r:null===(s=e.default)||void 0===s?void 0:s.GIFEncoder)&&void 0!==a?a:null===(c=null===(l=e.default)||void 0===l?void 0:l.default)||void 0===c?void 0:c.GIFEncoder,$=null!==(h=null!==(u=e.quantize)&&void 0!==u?u:null===(d=e.default)||void 0===d?void 0:d.quantize)&&void 0!==h?h:null===(g=null===(f=e.default)||void 0===f?void 0:f.default)||void 0===g?void 0:g.quantize,j=null!==(m=null!==(y=e.applyPalette)&&void 0!==y?y:null===(p=e.default)||void 0===p?void 0:p.applyPalette)&&void 0!==m?m:null===(b=null===(v=e.default)||void 0===v?void 0:v.default)||void 0===b?void 0:b.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const L=Math.round(1e3/x),C=T();for(let t=0;P.length>t;t++){const e=P[t],n=yield O(Buffer.from(e),{density:72*w}).resize(M,_).ensureAlpha().raw().toBuffer(),o=new Uint8Array(n),i=$(o,256),r=j(o,i);C.writeFrame(r,M,_,{palette:i,delay:L,repeat:k?0:-1})}return C.finish(),Buffer.from(C.bytes())})}export{rc as generateFrameSVGs,sc as generateFrameSequence,tc as renderChart,ec as renderChartWithEvidence,ic as renderDashboard,Kl as renderGeoToStaticSVG,Ql as renderNetworkToStaticSVG,Zl as renderOrdinalToStaticSVG,uc as renderToAnimatedGif,oc as renderToImage,Vl as renderToStaticSVG,Ul as renderXYToStaticSVG,ti as resolveTheme,ei as themeStyles};
1
+ import*as t from"react-dom/server";import*as e from"react";import{scaleOrdinal as i}from"d3-scale";function o(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function n(t,e,i){const o=t=>t.toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(i)}`}function r(t){const e=t.map(o),i=e.length-1;return t=>{if(0>=t){const[t,i,o]=e[0];return n(t,i,o)}if(t>=1){const[t,o,r]=e[i];return n(t,o,r)}const o=t*i,r=Math.floor(o),s=o-r,[a,c,l]=e[r],[u,h,d]=e[r+1];return n(Math.round(a+(u-a)*s),Math.round(c+(h-c)*s),Math.round(l+(d-l)*s))}}var s=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],a=r(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),c=r(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),l=r(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),u=r(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),h=r(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),d=r(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),f=r(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),p=r(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),y=r(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),g=r(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),m=r(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),x=r(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),b={blues:a,reds:c,greens:l,viridis:f,oranges:u,purples:h,greys:d,plasma:p,inferno:y,magma:g,cividis:m,turbo:x};function v(t){return t&&b[t]||a}r(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),r(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),r(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),r(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),r(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),r(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),r(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var w={category10:s,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...b},k=s,S=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],A=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 M(t,e,i){if("function"==typeof e){const o=e(t);return i&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||A.has(e)}(o)?i(o):o}const o=t?.[e]+"";return i?i(o):k[Math.abs(function(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}(o))%k.length]}function _(t,e){if(null==e||!Object.prototype.hasOwnProperty.call(t,e))return;const i=t[e];return"string"==typeof i&&i.length>0?i:void 0}function P(t,e,o="category10"){if(o&&"object"==typeof o&&!Array.isArray(o)){const t=o;return e=>_(t,e)??"#999"}const n=Array.from(new Set(t.map(t=>t?.[e]).filter(t=>null!=t).map(t=>t+""))),r=n.every(t=>!isNaN(Number(t)));if(Array.isArray(o))return i().domain(n).range(o).unknown("#999");const s=w[o]||w.category10;if(r&&"function"==typeof s){let t=-1/0;for(const e of n){const i=Number(e);i>t&&(t=i)}return e=>s(Number(e)/t)}{const t=Array.isArray(s)?s:k;return i().domain(n).range(t).unknown("#999")}}function R(t,e,i=[3,20],o){let n;if(n="function"==typeof e?e(t):t?.[e],!o)return n;const[r,s]=o,[a,c]=i;if(s===r)return(a+c)/2;let l=(n-r)/(s-r);return 0>l?l=0:l>1&&(l=1),a+l*(c-a)}function T(t,e,i){return"function"==typeof t?t(i):i[t||e]}function L(t){return t instanceof Date?t.getTime():Number(t)}function C(t,e){return f(1===e?.5:t/(e-1))}function $(t){if(null==t)return()=>{};const e="function"==typeof t?t:e=>e[t];return t=>D(e(t))}function z(t,e){const i=$(e??"value"),o=null==t?void 0:"function"==typeof t?t:e=>e[t];return t=>{const e=o?o(t):void 0;return{value:i(t),category:null==e?void 0:e+""}}}function D(t){if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t&&""!==t.trim()){const e=Number(t);return Number.isFinite(e)?e:void 0}}function E(t,e,i){const o=t.when;return void 0===o||!0===o||!1!==o&&("function"==typeof o?o(e,i):function(t,e,i){const o=null!=t.axis?i[t.axis]:null!=t.field?e[t.field]:i.value;if(void 0!==t.eq&&o!==t.eq)return!1;if(void 0!==t.ne&&o===t.ne)return!1;if(void 0!==t.in&&!t.in.includes(o))return!1;if(void 0===t.gt&&void 0===t.gte&&void 0===t.lt&&void 0===t.lte&&void 0===t.within&&void 0===t.outside)return!0;const n=D(o);if(void 0===n)return!1;if(void 0!==t.gt&&t.gt>=n)return!1;if(void 0!==t.gte&&t.gte>n)return!1;if(void 0!==t.lt&&n>=t.lt)return!1;if(void 0!==t.lte&&n>t.lte)return!1;if(void 0!==t.within){const[e,i]=t.within;if(e>n||n>i)return!1}if(void 0!==t.outside){const[e,i]=t.outside;if(n>=e&&i>=n)return!1}return!0}(o,e,i))}function N(t,e,i){if(!e||0===e.length)return{};let o={};for(const n of e){if(!E(n,t,i))continue;const e="function"==typeof n.style?n.style(t,i):n.style;e&&(o={...o,...e})}return o}function I(t,e,i,o=t=>t){const n=t??(()=>({}));return e&&0!==e.length?(t,r)=>{const s=o(t),a={...n(t,r)};return Object.assign(a,N(s,e,i(s,r))),a}:n}function B(t,e,i){return t&&0!==t.length?(o,n)=>{const r=N(o,t,e(o,n)),s=i?i(o,n):void 0;return s?{...r,...s}:r}:i}function F(t,e,i,o){if(!t||0===t.length)return o;const n=z(e,i);return(e,i)=>{const r=e&&e.data||e,s=N(r,t,n(r)),a=o?o(e,i):void 0;return a?{...s,...a}:s}}function O(t,e,i,o){return B(t,function(t,e){const i=$(t),o=$(e);return(t,e)=>{const n=o(t);return{value:n,x:i(t),y:n,category:e}}}(e,i),o)}function W(t,e,i){const o=$(e);return B(t,(t,e)=>({value:o(t),category:e}),i)}var j={frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"line",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",groupAccessor:n.lineBy||e,colorAccessor:e,colorScheme:i,lineStyle:n.lineStyle,...o,...n.styleRules&&{lineStyle:O(n.styleRules,n.xAccessor||"x",n.yAccessor||"y",o.lineStyle||n.lineStyle)}})},Y={frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"area",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",y0Accessor:n.y0Accessor,groupAccessor:n.areaBy||e,colorAccessor:e,colorScheme:i,...o,...n.styleRules&&{lineStyle:O(n.styleRules,n.xAccessor||"x",n.yAccessor||"y",o.lineStyle)}})},X={frameType:"xy",buildProps:(t,e,i,o,n)=>{const r=n.xAccessor||"x",s=n.seriesAAccessor||"a",a=n.seriesBAccessor||"b",c=t=>L(T(r,"x",t)),l=t=>L(T(s,"a",t)),u=t=>L(T(a,"b",t)),h=n.seriesAColor||"var(--semiotic-danger, #dc2626)",d=n.seriesBColor||"var(--semiotic-info, #2563eb)",f=n.areaOpacity??.6,p=n.lineWidth??1.5,y=!1!==n.showLines,g=function(t,e,i,o){if(!t.length)return[];const n=t.filter(t=>Number.isFinite(e(t))).sort((t,i)=>e(t)-e(i)),r=[];let s=0,a=null,c=null,l=[];const u=(t,e)=>t>e?"A":e>t?"B":null,h=t=>`seg-${s}-${t}`,d=t=>r.push(t),f=(t,e)=>{d({__x:t.x,__y:t.y,__y0:t.y,__diffSegment:h(e),__diffWinner:e,__valA:t.y,__valB:t.y,__sourceDatum:t.datum})};for(let t=0;n.length>t;t++){const r=n[t],p=e(r),y=i(r),g=o(r);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 t,e;if(l.length>0)t=l[0].x,e=l[0].y;else{const i=y-c.a-(g-c.b);if(0!==i){const o=Math.max(0,Math.min(1,(c.b-c.a)/i));t=c.x+o*(p-c.x),e=c.a+o*(y-c.a)}else t=c.x,e=c.a}d({__x:t,__y:e,__y0:e,__diffSegment:h(a),__diffWinner:a,__valA:e,__valB:e}),s++,a=m,d({__x:t,__y:e,__y0:e,__diffSegment:h(a),__diffWinner:a,__valA:e,__valB:e});for(let t=1;l.length>t;t++)f(l[t],a)}else for(const t of l)f(t,a);l=[],d({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:h(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:p,a:y,b:g,w:m}}else{a=m;for(const t of l)f(t,a);l=[],d({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:h(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:p,a:y,b:g,w:m}}else l.push({x:p,y:y,datum:r})}for(const t of l)f(t,a??"A");return r}(Array.isArray(t)?t:[],c,l,u),m=[];if(y&&Array.isArray(t)){const e=t.filter(t=>Number.isFinite(c(t))).sort((t,e)=>c(t)-c(e));for(const t of e){const e=c(t),i=l(t),o=u(t);Number.isFinite(i)&&m.push({__x:e,__y:i,__diffSegment:"line-A"}),Number.isFinite(o)&&m.push({__x:e,__y:o,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...g,...m],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(g.map(t=>t.__diffSegment))),areaStyle:t=>{const e=t.__diffSegment;return{fill:"A"==(e?.endsWith("-A")?"A":"B")?h:d,stroke:"none",fillOpacity:f}},lineStyle:t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?h:d,strokeWidth:p,fill:"none"}),curve:n.curve||"linear",...o}}},q={frameType:"xy",buildProps:(t,e,i,o,n)=>{const r=e||n.areaBy,s="string"==typeof r&&Array.isArray(t)?P(t,r,i):void 0;return{chartType:"stackedarea",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",groupAccessor:n.areaBy,colorAccessor:r,colorScheme:i,normalize:n.normalize,stackOrder:n.stackOrder,lineStyle:null==n.areaOpacity?void 0:t=>{const e=null==r?void 0:M(t,r,s),i=n.showLine??!0;return{fill:n.color??e,stroke:i?n.stroke??e:"none",...i?{strokeWidth:n.strokeWidth??n.lineWidth??2}:{},fillOpacity:n.areaOpacity,...null==n.opacity?{}:{opacity:n.opacity}}},...o}}},G={frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"scatter",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,sizeAccessor:n.sizeBy,colorScheme:i,...o,...n.styleRules&&{pointStyle:O(n.styleRules,n.xAccessor||"x",n.yAccessor||"y",o.pointStyle)}})},V={frameType:"xy",buildProps:(t,i,o,n,r)=>{const s=r.xCenter,a=r.yCenter,c=r.quadrants,l=r.centerlineStyle||{},u=!1!==r.showQuadrantLabels,h=r.quadrantLabelSize??12,d=l.stroke||"#999",f=l.strokeWidth??1,p=Array.isArray(l.strokeDasharray)?l.strokeDasharray.join(","):l.strokeDasharray,y=e.createElement,g=c?[(t,i,o)=>{if(!i?.x||!i?.y)return null;const n=o.width,r=o.height,l=null!=s?i.x(s):n/2,g=null!=a?i.y(a):r/2;if(null!=s&&!Number.isFinite(l))return null;if(null!=a&&!Number.isFinite(g))return null;const m=Math.max(0,Math.min(n,l)),x=Math.max(0,Math.min(r,g)),b=[{c:c.topLeft,x:0,y:0,w:m,h:x},{c:c.topRight,x:m,y:0,w:n-m,h:x},{c:c.bottomLeft,x:0,y:x,w:m,h:r-x},{c:c.bottomRight,x:m,y:x,w:n-m,h:r-x}],v=u?[y("text",{key:"ltl",x:8,y:8+h,fill:c.topLeft.color,fontWeight:600,fontSize:h,opacity:.5},c.topLeft.label),y("text",{key:"ltr",x:n-8,y:8+h,fill:c.topRight.color,fontWeight:600,fontSize:h,opacity:.5,textAnchor:"end"},c.topRight.label),y("text",{key:"lbl",x:8,y:r-8,fill:c.bottomLeft.color,fontWeight:600,fontSize:h,opacity:.5},c.bottomLeft.label),y("text",{key:"lbr",x:n-8,y:r-8,fill:c.bottomRight.color,fontWeight:600,fontSize:h,opacity:.5,textAnchor:"end"},c.bottomRight.label)]:[];return y(e.Fragment,null,...b.map((t,e)=>t.w>0&&t.h>0?y("rect",{key:"qf-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.c.color,opacity:t.c.opacity??.08}):null),y("line",{key:"vc",x1:m,y1:0,x2:m,y2:r,stroke:d,strokeWidth:f,strokeDasharray:p}),y("line",{key:"hc",x1:0,y1:x,x2:n,y2:x,stroke:d,strokeWidth:f,strokeDasharray:p}),...v)}]:void 0;return{chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:i,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange,colorScheme:o,pointStyle:r.pointStyle,...n,...g&&{svgPreRenderers:g}}}},H={frameType:"xy",buildProps:(t,e,i,o,n)=>{const r=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const i=e.xAccessor||"x",o=e.yAccessor||"y",n=e.orderAccessor?[...t].sort((t,i)=>null==t||"object"!=typeof t?1:null==i||"object"!=typeof i?-1:L(T(e.orderAccessor,"order",t))-L(T(e.orderAccessor,"order",i))):t,r=new WeakMap;let s=0;for(const t of n){if(null==t||"object"!=typeof t)continue;const e=L(T(i,"x",t)),n=L(T(o,"y",t));Number.isFinite(e)&&Number.isFinite(n)&&s++}let a=0;for(const t of n){if(null==t||"object"!=typeof t)continue;const e=L(T(i,"x",t)),n=L(T(o,"y",t));Number.isFinite(e)&&Number.isFinite(n)&&r.set(t,{idx:a++,total:s})}return{data:n,orderMap:r}}(t,n),s=n.pointRadius??4;return{chartType:"line",data:r.data,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,colorScheme:i,lineStyle:n.lineStyle||{stroke:n.stroke||"#6366f1",strokeWidth:n.strokeWidth??s,opacity:n.opacity},pointStyle:t=>{const e=r.orderMap.get(t),i=e?.idx??0,o=e?.total??1;return{fill:o>0?C(i,o):"#6366f1",stroke:"white",strokeWidth:1,r:s,fillOpacity:1}},...o}}};function Z(t){return Math.max(0,Math.min(1,t))}function K(t){const e=t.trim();if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t.split("").map(t=>t+t).join("")),6===t.length&&/^[0-9a-f]{6}$/i.test(t))return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const i=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(i){const t=[Number(i[1]),Number(i[2]),Number(i[3])];if(t.every(Number.isFinite))return t}return null}function U(t,e,i){const o=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(i)}`}function Q(t,e){const i=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Z(t.offset),color:t.color})).sort((t,e)=>t.offset-e.offset);if(0===i.length)return"#999999";if(1===i.length)return i[0].color;const o=Z(e);if(i[0].offset>=o)return i[0].color;if(o>=i[i.length-1].offset)return i[i.length-1].color;for(let t=0;i.length-1>t;t++){const e=i[t],n=i[t+1];if(e.offset>o||o>n.offset)continue;const r=n.offset-e.offset,s=r>0?(o-e.offset)/r:0,a=K(e.color),c=K(n.color);if(!a||!c)return.5>s?e.color:n.color;const[l,u,h]=a,[d,f,p]=c;return U(l+(d-l)*s,u+(f-u)*s,h+(p-h)*s)}return i[i.length-1].color}function J(t,e,i){return null==i?`${t}-${e}`:`${t}-${e}-${i}`}var tt={frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"bar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"horizontal"===n.orientation?"horizontal":"vertical",oSort:n.sort??!1,colorAccessor:e,colorScheme:i,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...o,...n.styleRules&&{pieceStyle:W(n.styleRules,n.valueAccessor||"value",o.pieceStyle)}})},et={frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"bar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",stackBy:n.stackBy,colorAccessor:e||n.stackBy,colorScheme:i,projection:"horizontal"===n.orientation?"horizontal":"vertical",normalize:n.normalize,oSort:n.sort??!1,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...o,...n.styleRules&&{pieceStyle:W(n.styleRules,n.valueAccessor||"value",o.pieceStyle)}})},it={frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"clusterbar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",groupBy:n.groupBy,colorAccessor:e||n.groupBy,colorScheme:i,projection:"horizontal"===n.orientation?"horizontal":"vertical",oSort:n.sort??!1,barPadding:n.barPadding,...null!=n.roundedTop&&{roundedTop:n.roundedTop},...o,...n.styleRules&&{pieceStyle:W(n.styleRules,n.valueAccessor||"value",o.pieceStyle)}})},ot={frameType:"ordinal",buildProps:(t,e,i,o,n)=>{const r=n.min??0,s=n.max??100,a=n.sweep??240,c=n.arcWidth??.3,l=180+(360-a)/2,u=n.thresholds||[{value:s,color:n.color||"#4e79a7"}],h=o.gradientFill,d=function(t){const{min:e,max:i,value:o,thresholds:n,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=t,h=i-e||1,d=(Math.max(e,Math.min(i,o))-e)/h;let f=n&&n.length>0?[...n].sort((t,e)=>t.value-e.value):[{value:i,color:r||"#007bff"}];f=f.map(t=>({...t,value:Math.max(e,Math.min(i,t.value))})),i>f[f.length-1].value&&f.push({value:i,color:f[f.length-1].color});const p=!!l&&l.colorStops.length>=2,y=[],g=new Map,m=[];if(p){const t=a?d:1,e=J("bg",0);if(y.push({category:e,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),g.set(e,{fill:s,opacity:.4}),t>0){const e=Math.max(1,Math.floor(u)),i=Math.max(1,Math.min(e,Math.round(t*e))),o=[];for(let e=0;i>e;e++)o.push(Q(l.colorStops,t*(e+.5)/i));const n=J("fill",0);y.push({category:n,value:t,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:t,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:o}}),g.set(n,{fill:o[0]||s})}}else{let t=e;for(let i=0;f.length>i;i++){const o=f[i],n=(o.value-t)/h,r=(t-e)/h,c=(o.value-e)/h,l=Math.max(0,(a?Math.min(d,c):c)-r),u=a?Math.max(0,n-l):0;if(l>0){const t=J("fill",i);y.push({category:t,value:l,_zone:o.label||"Zone "+(i+1),_isFill:!0}),g.set(t,{fill:o.color})}if(u>0){const t=J("bg",i);y.push({category:t,value:u,_zone:o.label||"Zone "+(i+1),_isFill:!1}),g.set(t,{fill:s,opacity:.4})}t=o.value}}if(c&&n&&n.length>0)for(const t of n)t.value>e&&i>t.value&&m.push({type:"gauge-label",value:t.value,label:t.label||t.value+""});return{gaugeData:y,pieceStyle:(t,e)=>g.get(e||t.category)||{fill:s},gaugeAnnotations:m}}({min:r,max:s,value:n.value,thresholds:u,fillColor:n.color,backgroundColor:n.backgroundColor||"#e0e0e0",fillZones:!1!==n.fillZones,showScaleLabels:!1!==n.showScaleLabels,gradientFill:h&&"object"==typeof h&&"colorStops"in h?h:void 0}),f=o.margin||{top:20,right:20,bottom:30,left:40},[p,y]=o.size||[300,300];return{chartType:"donut",data:d.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:d.pieceStyle,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...o,showAxes:!1,annotations:[...Array.isArray(o.annotations)?o.annotations:[],...d.gaugeAnnotations],__gauge:{gMin:r,gMax:s,sweep:a,arcWidth:c,value:n.value,startAngleDeg:l,thresholds:u}}}};import{scaleTime as nt}from"d3-scale";function rt(t){let e=1/0,i=-1/0;for(const o of t)e>o&&(e=o),o>i&&(i=o);return[e,i]}function st(t,e=-1/0){let i=e;for(const e of t)e>i&&(i=e);return i}function at(t){return"invalid-node-time"===t.kind?`node ${t.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===t.kind?`edge ${t.id} has an invalid startTime or endTime`:"invalid-domain"===t.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===t.kind?`edge ${t.id} must have a positive finite value`:"missing-node"===t.kind?`edge ${t.id} references missing ${t.endpoint} node "${t.nodeId}"`:"backward-edge"===t.kind?`edge ${t.id} (${t.source}->${t.target}) ends before it starts`:t.kind}function ct(t,e,i){const o=e.incoming[t.id],n=e.outgoing[t.id],r=[];for(const t of o)r.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:i.get(t.id).targetSide});for(const t of n)r.push({time:t.startTime,delta:-t.value,edge:t,kind:"out",side:i.get(t.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((t,e)=>t.time-e.time||(s[t.kind]??99)-(s[e.kind]??99))},c=r.length?function(t,e=1/0){let i=e;for(const e of t)i>e&&(i=e);return i}(r.map(t=>t.time)):null,l=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[0])?t.xExtent[0]:null,u=null!=l?l-1:null!=c&&Number.isFinite(c)?c-1:null,h=[...new Set(r.map(t=>t.time))].sort((t,e)=>t-e),d=new Map;for(let t=1;h.length>t;t++)d.set(h[t],h[t-1]);const f=t=>{const e=d.get(t);return null!=e?(e+t)/2:null!=u?u:t};a();const p=[];let y=0,g=0;for(const t of r)if("out"===t.kind){const e=Math.abs(t.delta);let i=e-("top"===t.side?y:g);if(i>0){const e="top"===t.side?"bot":"top",o=Math.min(i,"top"===e?y:g);if(o>0){const n=f(t.time);p.push({time:n,delta:-o,kind:"transfer-out",side:e}),p.push({time:n,delta:+o,kind:"transfer-in",side:t.side}),"top"===e?y-=o:g-=o,"top"===t.side?y+=o:g+=o,i-=o}i>0&&null!==u&&(p.push({time:u,delta:+i,kind:"create",side:t.side}),"top"===t.side?y+=i:g+=i)}"top"===t.side?y-=e:g-=e}else if("in"===t.kind){const e=Math.abs(t.delta);"top"===t.side?y+=e:g+=e}r.push(...p),a();let m=0,x=0,b=0,v=0,w=0;const k=[],S=new Map;for(const t of r){if(k.push({t:t.time,topMass:m,botMass:x}),("in"===t.kind||"out"===t.kind)&&t.edge){const e="top"===t.side?m:x;S.set(t.edge.id,{side:t.side,time:t.time,sideMassBefore:e,sideMassAfter:e+t.delta,kind:t.kind,value:Math.abs(t.delta)})}"top"===t.side?m+=t.delta:x+=t.delta,m+x>b&&(b=m+x),m>v&&(v=m),x>w&&(w=x),k.push({t:t.time,topMass:m,botMass:x})}const A=[];let M=0;for(;k.length>M;){let t=M;for(;k.length>t+1&&k[t+1].t===k[M].t;)t++;A.push(k[M]);for(let e=M+1;t>=e;e++){const t=A[A.length-1];k[e].topMass===t.topMass&&k[e].botMass===t.botMass||A.push(k[e])}M=t+1}const _=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;let P=null;for(const t of n)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===P||P>t.systemInTime)&&(P=t.systemInTime);let R=null;for(const t of o)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===R||t.systemOutTime>R)&&(R=t.systemOutTime);if(A.length>0){const t=A[A.length-1],e=Math.max(null!=_?_:-1/0,null!=R?R:-1/0);Number.isFinite(e)&&e>t.t&&t.topMass+t.botMass>0&&A.push({t:e,topMass:t.topMass,botMass:t.botMass});const i=A[0],o=Math.min(null!=l?l:1/0,null!=P?P:1/0);Number.isFinite(o)&&i.t>o&&i.topMass+i.botMass>0&&A.unshift({t:o,topMass:i.topMass,botMass:i.botMass})}return{samples:A,peak:b,topPeak:v,botPeak:w,localAttachments:S}}function lt(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function ut(t,e){return t.map(t=>({t:lt(t.t,e),topMass:t.topMass,botMass:t.botMass}))}function ht(t,e,i){const o=t.value*i;if("out"===t.kind){const n=t.sideMassBefore*i;if("top"===t.side){const t=e-n;return[t,t+o]}const r=e+n;return[r-o,r]}const n=t.sideMassAfter*i;if("top"===t.side){const t=e-n;return[t,t+o]}const r=e+n;return[r-o,r]}function dt(t,e){let i=0;for(let o=0;e.length>o;o++)for(let n=o+1;e.length>n;n++){const r=e[o],s=e[n];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&t[s.source]>t[r.source]!=t[s.target]>t[r.target]&&i++)}return i}function ft(t,e){let i=0;for(const o of e)i+=Math.abs(t[o.source]-t[o.target])*(o.value||1);return i}function pt(t,e){return 1e3*dt(t,e)+ft(t,e)}function yt(t,e){return{slots:t.map(t=>({peak:{...t.peak},occupants:t.occupants.slice()})),map:{...e}}}function gt(t,e,i){t.length>8||i.length>40?(function(t,e,i,o=6){const n=t.length;if(1>=n)return;let r=yt(t,e),s=pt(e,i);for(let a=0;o>a;a++){const o=Array(n).fill(0),a=Array(n).fill(0);for(const t of i){const i=e[t.source],n=e[t.target];o[i]+=n*(t.value||1),a[i]+=t.value||1,o[n]+=i*(t.value||1),a[n]+=t.value||1}const c=Array.from({length:n},(t,e)=>e).sort((t,e)=>(a[t]>0?o[t]/a[t]:t)-(a[e]>0?o[e]/a[e]:e)),l=c.map(e=>t[e]),u=new Map;c.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of l)t.push(e);const h=pt(e,i);if(s>h)s=h,r=yt(t,e);else if(h===s)break}!function(t,e,i){t.length=0;for(const e of i.slots)t.push(e);for(const t of Object.keys(e))delete e[t];for(const t of Object.keys(i.map))e[t]=i.map[t]}(t,e,r)}(t,e,i,6),function(t,e,i,o=6){const n=t.length;if(1>=n)return;let r=pt(e,i);for(let s=0;o>s;s++){let o=!1;for(let s=0;n-1>s;s++){const n=t[s];t[s]=t[s+1],t[s+1]=n;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s);const a=pt(e,i);if(r>a)r=a,o=!0;else{const i=t[s];t[s]=t[s+1],t[s+1]=i;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s)}}if(!o)break}}(t,e,i,6)):function(t,e,i){const o=t.length;if(1>=o)return;const n={...e},r=Object.keys(n),s=Array.from({length:o},(t,e)=>e),a=s.slice(),c={...n};let l=s.slice(),u=1/0;const h=()=>{for(const t of r)c[t]=a[n[t]];const t=pt(c,i);u>t&&(u=t,l=s.slice())},d=(t,e)=>{const i=s[t],o=s[e];s[t]=o,s[e]=i,a[i]=e,a[o]=t};h();const f=Array(o).fill(0);let p=0;for(;o>p;)p>f[p]?(d(p%2==0?0:f[p],p),h(),f[p]++,p=0):(f[p]=0,p++);const y=l.map(e=>t[e]),g=new Map;l.forEach((t,e)=>g.set(t,e));for(const t of Object.keys(e))e[t]=g.get(e[t]);t.length=0;for(const e of y)t.push(e)}(t,e,i)}function mt(t,e,i,o,n){const{plotH:r,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="full"}=n,h={},d={};for(const e of t)h[e.id]=i[e.id].topPeak||0,d[e.id]=i[e.id].botPeak||0;const f="half"===u,p={};for(const e of t){const t=Array.isArray(e.xExtent)?e.xExtent[0]:null,i=Array.isArray(e.xExtent)?e.xExtent[1]:null;let n=null!=t&&Number.isFinite(t)?t:1/0,r=null!=i&&Number.isFinite(i)?i:-1/0;for(const t of o.outgoing[e.id]){n>t.startTime&&(n=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&n>t.systemInTime&&(n=t.systemInTime);const e=f?(t.startTime+t.endTime)/2:t.endTime;e>r&&(r=e)}for(const t of o.incoming[e.id]){const e=f?(t.startTime+t.endTime)/2:t.startTime;n>e&&(n=e),t.endTime>r&&(r=t.endTime),null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>r&&(r=t.systemOutTime)}p[e.id]={start:Number.isFinite(n)?n:null,end:Number.isFinite(r)?r:null}}const y={},g=[];if("reuse"===c){const i=new Map;for(const e of t)i.set(e.id,0);const n=new Map;for(const e of t)n.set(e.id,0);for(const t of e)n.set(t.target,(n.get(t.target)??0)+1);const r=[];for(const e of t)0===(n.get(e.id)??0)&&r.push(e.id);for(;r.length;){const t=r.shift();for(const e of o.outgoing[t]??[]){const o=(i.get(t)??0)+1;o>(i.get(e.target)??0)&&i.set(e.target,o),n.set(e.target,n.get(e.target)-1),0===n.get(e.target)&&r.push(e.target)}}const s=[...t].filter(t=>null!==p[t.id].start).sort((t,e)=>{const o=i.get(t.id)??0,n=i.get(e.id)??0;return o!==n?o-n:p[t.id].start-p[e.id].start}),a=t.filter(t=>null===p[t.id].start);for(const t of[...s,...a]){const e=p[t.id];let i=-1;for(let t=0;g.length>t;t++){const o=g[t].occupants[g[t].occupants.length-1];if(null===e.start||void 0===o||e.start>=o.end){i=t;break}}-1===i&&(g.push({occupants:[],peak:{topPeak:0,botPeak:0}}),i=g.length-1),g[i].occupants.push({id:t.id,end:e?.end??-1/0}),g[i].peak.topPeak=Math.max(g[i].peak.topPeak,h[t.id]),g[i].peak.botPeak=Math.max(g[i].peak.botPeak,d[t.id]),y[t.id]=i}}else t.forEach((t,e)=>{g.push({occupants:[{id:t.id,end:p[t.id]?.end??-1/0}],peak:{topPeak:h[t.id],botPeak:d[t.id]}}),y[t.id]=e});let m=null,x=null,b=null,v=null;const w=()=>{m=dt(y,e),b=ft(y,e)},k=()=>{x=dt(y,e),v=ft(y,e)};"crossing-min"===l?(w(),gt(g,y,e),k()):"inside-out"===l?(w(),function(t,e){const i=t.length;if(1>=i)return;const o=t=>t.peak.topPeak+t.peak.botPeak,n=t.map((t,e)=>({slot:t,idx:e})).sort((t,e)=>o(e.slot)-o(t.slot)),r=Array(i),s=Math.floor((i-1)/2);r[s]=n[0].idx;let a=s-1,c=s+1;for(let t=1;n.length>t;t++)t%2==1&&i>c||0>a?r[c++]=n[t].idx:r[a--]=n[t].idx;const l=r.map(e=>t[e]),u=new Map;r.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of l)t.push(e)}(g,y),k()):"crossing-min+inside-out"===l&&(w(),gt(g,y,e),function(t,e,i){const o=t.length;if(1>=o)return;const n=t.map(t=>{return{slot:t,size:(e=t,e.peak.topPeak+e.peak.botPeak)};var e}).sort((t,e)=>e.size-t.size),r=Math.floor((o-1)/2);let s=pt(e,i);for(const{slot:a}of n){const n=t.indexOf(a);if(0>n)continue;const c=r;if(n===c)continue;const l=t[n];t.splice(n,1),t.splice(c,0,l);const u=new Map;for(let t=0;o>t;t++)u.set(t,t);if(c>n){for(let t=n+1;c>=t;t++)u.set(t,t-1);u.set(n,c)}else{for(let t=c;n>t;t++)u.set(t,t+1);u.set(n,c)}for(const t of Object.keys(e))e[t]=u.get(e[t]);const h=pt(e,i);if(h>s){const i=t[c];t.splice(c,1),t.splice(n,0,i);const r=new Map;for(let t=0;o>t;t++)r.set(t,t);if(n>c){for(let t=c+1;n>=t;t++)r.set(t,t-1);r.set(c,n)}else{for(let t=n;c>t;t++)r.set(t,t+1);r.set(c,n)}for(const t of Object.keys(e))e[t]=r.get(e[t])}else s=h}}(g,y,e),k());const S=g.map(t=>{const e=new Map;for(const o of t.occupants){const t=i[o.id];if(t)for(const i of t.samples){const t=e.get(i.t)||{top:0,bot:0};e.set(i.t,{top:Math.max(t.top,i.topMass),bot:Math.max(t.bot,i.botMass)})}}return[...e.entries()].sort((t,e)=>t[0]-e[0])}),A=(t,e)=>{let i={top:0,bot:0};for(const[o,n]of t){if(o>e)break;i=n}return i},M=[];for(let t=0;g.length-1>t;t++){const e=S[t],i=S[t+1],o=new Set([...e.map(t=>t[0]),...i.map(t=>t[0])]);let n=0;for(const t of o){const o=A(e,t),r=A(i,t);o.bot+r.top>n&&(n=o.bot+r.top)}M.push(n)}const _=[];let P=s+(g[0]?.peak.topPeak??0)*a;g.length>0&&_.push(P);for(let t=1;g.length>t;t++)P+=M[t-1]*a+s,_.push(P);if(g.length>0&&(P+=g[g.length-1].peak.botPeak*a+s),P>r){const t=r/P;for(let e=0;_.length>e;e++)_[e]*=t}const R=0===g.length?0:g[0].peak.topPeak+M.reduce((t,e)=>t+e,0)+g[g.length-1].peak.botPeak,T={};for(const e of t)T[e.id]=_[y[e.id]];return{effectiveSlotsHeight:R,centerlines:T,laneLifetime:p,slots:g,slotByNode:y,slotCenter:_,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:v}}function xt(t){const{sx:e,sTop:i,sBot:o,tx:n,tTop:r,tBot:s,cp1X:a,cp2X:c}=t,l=(i+o)/2,u=(r+s)/2;return{pathD:[`M${e},${i}`,`C${a},${i} ${c},${r} ${n},${r}`,`L${n},${s}`,`C${c},${s} ${a},${o} ${e},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:l},{x:a,y:l},{x:c,y:u},{x:n,y:u}],halfWidth:(o-i)/2}}}function bt(t){const{nodes:e,edges:i,domain:o,plotW:n,plotH:r,ribbonLane:s,edgeOpacity:a,colorOf:c,layoutOpts:l}=t,u=function(t,e,i){const o=[],n=new Set(t.map(t=>t.id)),r=Array.isArray(i)&&2===i.length,s=r&&Number.isFinite(i[0])&&Number.isFinite(i[1]);r&&s&&s&&i[1]>=i[0]||o.push({kind:"invalid-domain"});for(const e of t)null!=e.xExtent&&(Array.isArray(e.xExtent)&&2===e.xExtent.length&&Number.isFinite(e.xExtent[0])&&Number.isFinite(e.xExtent[1])&&e.xExtent[1]>=e.xExtent[0]||o.push({kind:"invalid-node-time",id:e.id}));for(const t of e)n.has(t.source)||o.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),n.has(t.target)||o.push({kind:"missing-node",id:t.id,endpoint:"target",nodeId:t.target}),Number.isFinite(t.startTime)&&Number.isFinite(t.endTime)?(Number.isFinite(t.value)&&t.value>0||o.push({kind:"invalid-value",id:t.id}),t.endTime>t.startTime||o.push({kind:"backward-edge",id:t.id,source:t.source,target:t.target})):o.push({kind:"invalid-edge-time",id:t.id});return o}(e,i,o),h=nt().domain(o).range([0,n]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:h};const d=function(t,e,i){const{plotH:o,pairing:n="temporal",packing:r="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=i,c=function(t,e){const i={},o={};for(const e of t)i[e.id]=[],o[e.id]=[];for(const t of e)o[t.source]&&o[t.source].push(t),i[t.target]&&i[t.target].push(t);return{incoming:i,outgoing:o}}(t,e),l=function(t,e,i,o="value"){const n="temporal"===o?(t,e)=>t.endTime-e.endTime:(t,e)=>e.value-t.value,r="temporal"===o?(t,e)=>t.startTime-e.startTime:(t,e)=>e.value-t.value,s=new Map;for(const t of e)s.set(t.id,{});const a=(t,e)=>{const i=new Map;for(const o of t){const t=o[e];i.has(t)||i.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const n=i.get(t);n.edges.push(o),n.total+=o.value,n.earliestStart=Math.min(n.earliestStart,o.startTime),n.latestEnd=Math.max(n.latestEnd,o.endTime)}const s=[...i.values()];s.sort("temporal"===o?(t,i)=>"target"===e?t.earliestStart-i.earliestStart:t.latestEnd-i.latestEnd:(t,e)=>e.total-t.total);for(const t of s)t.edges.sort("target"===e?r:n);return s};for(const e of t){const t=i.outgoing[e.id],o=i.incoming[e.id];if(0===o.length)a(t,"target").forEach((t,e)=>{const i=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).sourceSide=i});else if(0===t.length)a(o,"source").forEach((t,e)=>{const i=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).targetSide=i});else{const e=a(o,"source"),i=a(t,"target"),n=Math.max(e.length,i.length);for(let t=0;n>t;t++){const o=t%2==0?"top":"bot";if(e[t])for(const i of e[t].edges)s.get(i.id).targetSide=o;if(i[t])for(const e of i[t].edges)s.get(e.id).sourceSide=o}}}return s}(t,e,c,n);let u={};for(const e of t)u[e.id]=ct(e,c,l);const h=mt(t,e,u,c,{plotH:o,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),d=new Set;for(const t of e){const e=h.slotByNode[t.source],i=h.slotByNode[t.target];if(void 0===e||void 0===i)continue;const o=l.get(t.id);e!==i?e>i?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(d.add(t.id),o.sourceSide="bot",o.targetSide="bot")}for(const e of t){const t=c.outgoing[e.id],i=c.incoming[e.id],o=new Set(t.map(t=>l.get(t.id).sourceSide)),n=new Set(i.map(t=>l.get(t.id).targetSide));if(1===o.size&&i.length>0){const t=[...o][0];for(const e of i)h.slotByNode[e.source]===h.slotByNode[e.target]&&(l.get(e.id).targetSide=t)}if(1===n.size&&t.length>0){const e=[...n][0];for(const i of t)h.slotByNode[i.source]===h.slotByNode[i.target]&&(l.get(i.id).sourceSide=e)}}for(const e of t){const t=c.incoming[e.id],i=c.outgoing[e.id];if(0===t.length||0===i.length)continue;const o=()=>{const e={inTop:0,inBot:0,outTop:0,outBot:0};for(const i of t)"top"===l.get(i.id).targetSide?e.inTop+=i.value:e.inBot+=i.value;for(const t of i)"top"===l.get(t.id).sourceSide?e.outTop+=t.value:e.outBot+=t.value;return e},n=(t,e)=>{const n=o(),r="top"===t?n.outTop-n.inTop:n.outBot-n.inBot,s="top"===e?n.inTop-n.outTop:n.inBot-n.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),c=i.filter(e=>!d.has(e.id)&&l.get(e.id).sourceSide===t&&a>=e.value).sort((t,e)=>e.value-t.value);return 0!==c.length&&(l.get(c[0].id).sourceSide=e,!0)};let r=i.length+1;for(;r-- >0&&(n("top","bot")||n("bot","top")););}u={};for(const e of t)u[e.id]=ct(e,c,l);const f=mt(t,e,u,c,{plotH:o,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),p=f.effectiveSlotsHeight??f.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),y=Math.min(12,.35*o/Math.max(f.slots.length+1,1)),g=p>0?Math.max(0,(o-y*(f.slots.length+1))/p):1,m=mt(t,e,u,c,{plotH:o,padding:y,valueScale:g,packing:r,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}}(e,i,{plotH:r,...l}),{centerlines:f,nodeData:p,valueScale:y}=d,g=[],m=[];e.forEach((t,e)=>{const n=p[t.id];if(!n||0===n.samples.length)return;const r=function(t,e,i,o,n){if(0===t.length)return null;const r=ut(t,n),s=t=>e-r[t].topMass*i,a=t=>e+r[t].botMass*i;let c=`M${o(r[0].t)},${s(0)}`;for(let t=1;r.length>t;t++)c+=` L${o(r[t].t)},${s(t)}`;c+=` L${o(r[r.length-1].t)},${a(r.length-1)}`;for(let t=r.length-2;t>=0;t--)c+=` L${o(r[t].t)},${a(t)}`;return c+" Z"}(n.samples,f[t.id],y,h,o);if(!r)return;const s=ut(n.samples,o),a=s.find(t=>t.topMass+t.botMass>0)||s[0],l=f[t.id]+(a.botMass-a.topMass)*y/2,u=c(t.id,e),m=function(t,e,i,o,n){const r=i.nodeData[t];if(!r||0===r.samples.length)return[];const s=i.valueScale,a=i.centerlines[t],c=ut(r.samples,n),l=c.find(t=>t.topMass+t.botMass>0)||c[0],u=[...c].reverse().find(t=>t.topMass+t.botMass>0)||c[c.length-1],h=o(l.t),d=o(u.t),f=t=>o(lt(t,n)),p=[],y=(t,e,i,o)=>`M${t},${e} L${i},${e} L${i},${o} L${t},${o} Z`;for(const i of e){if(i.source===t&&null!=i.systemInTime&&Number.isFinite(i.systemInTime)){const t=r.localAttachments.get(i.id);if(t&&"out"===t.kind&&i.startTime>i.systemInTime){const e=f(i.systemInTime),o=f(i.startTime),n=e-20,r=Math.max(h,n);if(o>r){const[i,c]=ht(t,a,s);p.push({pathD:y(r,i,o,c),x0:n,x1:e,from:0,to:1})}}}if(i.target===t&&null!=i.systemOutTime&&Number.isFinite(i.systemOutTime)){const t=r.localAttachments.get(i.id);if(t&&"in"===t.kind&&i.systemOutTime>i.endTime){const e=f(i.systemOutTime),o=f(i.endTime),n=e+20,r=Math.min(d,n);if(r>o){const[i,c]=ht(t,a,s);p.push({pathD:y(o,i,r,c),x0:e,x1:n,from:1,to:0})}}}}return p}(t.id,i,d,h,o);g.push({id:t.id,pathD:r,fill:u,stroke:u,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:t.__raw??t,labelX:h(a.t)-4,labelY:l,labelText:t.id})});const x=new Map;return e.forEach((t,e)=>x.set(t.id,e)),i.forEach(t=>{const e=p[t.source]?.localAttachments.get(t.id),i=p[t.target]?.localAttachments.get(t.id);if(!e||!i)return;const n=x.get(t.source)??0,r=c(t.source,n),l=function(t,e,i,o,n,r,s,a){const c=n,l=t=>a?Math.max(a[0],Math.min(a[1],t)):t,u=r(l(t.time)),h=r(l(i.time)),d=t.value*c,f=i.value*c,p=t.sideMassBefore*c,y=i.sideMassAfter*c;let g,m,x,b;"top"===t.side?(g=e-p,m=g+d):(m=e+p,g=m-d),"top"===i.side?(x=o-y,b=x+f):(b=o+y,x=b-f);const v="source"===s?u+.85*(h-u):"target"===s?u+.15*(h-u):(u+h)/2;return{sx:u,sTop:g,sBot:m,tx:h,tTop:x,tBot:b,cp1X:v,cp2X:v}}(e,f[t.source],i,f[t.target],y,h,s,o),{pathD:u,bezier:d}=xt(l);m.push({id:t.id,pathD:u,fill:r,opacity:a,rawDatum:t.__raw??t,bezier:d})}),{layout:d,layoutConfig:{bands:g,ribbons:m,showLabels:!0},issues:[],xScale:h}}var vt=t=>{const{bands:e=[],ribbons:i=[],showLabels:o=!0}=t.config,n=[];for(const t of i)n.push({type:"bezier",pathD:t.pathD,...t.bezier&&{bezierCache:t.bezier},style:{fill:t.fill,opacity:t.opacity,stroke:"none"},datum:{__kind:"ribbon",data:t.rawDatum,id:t.id}});for(const t of e)if(t.gradientStubs)for(let e=0;t.gradientStubs.length>e;e++){const i=t.gradientStubs[e];n.push({type:"bezier",pathD:i.pathD,interactive:!1,style:{fill:t.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:i.x0,x1:i.x1,from:i.from,to:i.to},datum:{__kind:"band",data:t.rawDatum,id:`${t.id}__stub${e}`}})}for(const t of e)n.push({type:"bezier",pathD:t.pathD,style:{...t.gradientStubs&&t.gradientStubs.length>0?{fill:"none"}:{fill:t.fill,fillOpacity:.86},stroke:t.stroke??t.fill,strokeWidth:t.strokeWidth??.5},datum:{__kind:"band",data:t.rawDatum,id:t.id}});const r=o?e.map(t=>({x:t.labelX,y:t.labelY,text:t.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:e.map(t=>({type:"circle",id:t.id,cx:-1e4,cy:-1e4,r:0,style:{fill:t.fill},datum:{__kind:"band",data:t.rawDatum,id:t.id}})),sceneEdges:n,labels:r}},wt={frameType:"network",buildProps:(t,e,i,o,n)=>{const{edgeWidth:r,edgeColor:s,edgeOpacity:a}=n,c=n.edgeStyle??(void 0!==r||void 0!==s||void 0!==a?t=>{const e=t?.data||t;let i=1;if("number"==typeof r)i=r;else if("function"==typeof r)i=r(e);else if("string"==typeof r){const t=e?.[r],o="number"==typeof t?t:Number(t);i=Number.isFinite(o)&&o>0?o:1}return{stroke:s??"#999",strokeWidth:i,opacity:a??.6}}:void 0);return{chartType:"force",nodes:n.nodes,edges:n.edges,nodeIDAccessor:n.nodeIdAccessor||n.nodeIDAccessor,sourceAccessor:n.sourceAccessor,targetAccessor:n.targetAccessor,colorBy:e,colorScheme:i,iterations:n.iterations,forceStrength:n.forceStrength,showLabels:n.showLabels,nodeLabel:n.nodeLabel,nodeSize:n.nodeSize,nodeSizeRange:n.nodeSizeRange,nodeStyle:F(n.styleRules,e,"number"==typeof n.nodeSize?void 0:n.nodeSize,n.nodeStyle)??n.nodeStyle,edgeStyle:c,...o}}},kt={frameType:"network",buildProps:(t,e,i,o,n)=>{const r=t=>null==t?NaN:t instanceof Date?t.getTime():"number"==typeof t?t:new Date(t).getTime(),s=n.sourceAccessor||"source",a=n.targetAccessor||"target",c=n.valueAccessor||"value",l=n.nodeIdAccessor||"id",u=n.startTimeAccessor||"startTime",h=n.endTimeAccessor||"endTime",d=n.systemInTimeAccessor,f=n.systemOutTimeAccessor,p=n.xExtentAccessor||"xExtent",y=n.edgeIdAccessor||"id",g=(t,e)=>"function"==typeof t?t(e):e[t],m=Array.isArray(n.edges)?n.edges:[],x=Array.isArray(n.nodes)?n.nodes:[],b=x.length>0?x:function(t,e,i,o){const n=new Set;return e.forEach(t=>{const e="function"==typeof i?i(t):t[i],r="function"==typeof o?o(t):t[o];n.add(e),n.add(r)}),Array.from(n).map(t=>({id:t}))}(0,m,s,a),v=[r(n.domain?.[0]),r(n.domain?.[1])],w=b.map(t=>{const e=g(l,t)+"",i=g(p,t),o={id:e,__raw:t};if(Array.isArray(i)&&2===i.length){const t=r(i[0]),e=r(i[1]);Number.isFinite(t)&&Number.isFinite(e)&&(o.xExtent=[t,e])}return o}),k=m.map((t,e)=>{const i=g(y,t),o={id:null!=i?i+"":`${g(s,t)}-${g(a,t)}-${e}`,source:g(s,t)+"",target:g(a,t)+"",value:Number(g(c,t)),startTime:r(g(u,t)),endTime:r(g(h,t)),__raw:t};if(d){const e=r(g(d,t));Number.isFinite(e)&&(o.systemInTime=e)}if(f){const e=r(g(f,t));Number.isFinite(e)&&(o.systemOutTime=e)}return o}),[S,A]=o.size??[600,400],_={top:20,right:20,bottom:20,left:20,...o.margin},R=o.legendPosition??"right";o.showLegend&&("right"===R?_.right=Math.max(_.right,100):"left"===R?_.left=Math.max(_.left,100):"bottom"===R?_.bottom=Math.max(_.bottom,70):"top"===R&&(_.top=Math.max(_.top,40)));const T=_,L=S-T.left-T.right,C=A-T.top-T.bottom,$=Array.isArray(i)?i:null,z=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],D="function"==typeof e?e:null,E=D?b.map(t=>({_cat:D(t)})):b,N=D?"_cat":"string"==typeof e?e:void 0,I=N?P(E,N,i):null,B=new Map;for(const t of w)B.set(t.id,t.__raw);const{layoutConfig:F,issues:O}=bt({nodes:w,edges:k,domain:v,plotW:L,plotH:C,ribbonLane:n.ribbonLane||"both",edgeOpacity:"number"==typeof n.edgeOpacity?n.edgeOpacity:.35,colorOf:(t,i)=>{if(e&&B.has(t)){const i=B.get(t);return D?M({_cat:D(i)},"_cat",I??void 0):M(i,"string"==typeof e?e:"id",I??void 0)}const o=$||z;return o[i%o.length]},layoutOpts:{pairing:n.pairing||"temporal",packing:n.packing||"reuse",laneOrder:n.laneOrder||"crossing-min",lifetimeMode:n.lifetimeMode||"half"}});if(O.length>0){const t=O.map(at).join("; ");throw Error("ProcessSankey: data invalid — "+t)}return{chartType:"force",nodes:b,edges:m,customNetworkLayout:vt,layoutConfig:F,sourceAccessor:s,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:e,colorScheme:i,...o,margin:T}}};import{useMemo as St,useCallback as At,useState as Mt,useId as _t,useEffect as Pt,useRef as Rt}from"react";import{createContext as Tt,useCallback as Lt,useContext as Ct,useMemo as $t,useRef as zt,useSyncExternalStore as Dt}from"react";import{jsx as Et}from"react/jsx-runtime";function Nt(t,e){const i=new Set;let o={...t(function(t){const e=t(o);if(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}(e)){o={...o,...e};for(const t of i)t()}}),...e??{}};return{getState:()=>o,subscribe:function(t){return i.add(t),()=>{i.delete(t)}}}}function It(t){if(!t?.colors)return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function Bt(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e={...e,colors:{...e.colors,categorical:Ft}}),t.accessibility.highContrast){const t="dark"===e.mode;e={...e,colors:{...e.colors,text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"}}}return e}var Ft=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Ot={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}},Wt={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}},jt={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Ft,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 Yt(t,e){if("light"===e)return Ot;if("dark"===e)return Wt;if("high-contrast"===e)return jt;if("string"==typeof e)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${e}". Keeping current theme.`),t;if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?Wt:Ot;return Bt({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}return Bt({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}var[Xt,qt]=function(t){let e=null;const i=()=>(e||(e=Tt(null)),e),o=Nt(t);return[function({children:e,initialState:o}){const n=zt(o),r=$t(()=>Nt(t,n.current),[]),s=i();return Et(s.Provider,{value:r,children:e})},(t,e)=>{const n=i(),r=Ct(n)??o,s=zt(t);s.current=t;const a=zt({hasValue:!1,value:void 0}),c=Lt(()=>{const t=s.current(r.getState()),i=a.current;return i.hasValue&&e&&e(i.value,t)?i.value:(a.current={hasValue:!0,value:t},t)},[r,e]),l=Lt(()=>s.current(r.getState()),[r]);return Dt(r.subscribe,c,l)}]}(t=>({theme:Ot,setTheme(e){t(t=>({theme:Yt(t.theme,e)}))}})),Gt={light:Ot,dark:Wt,"high-contrast":jt,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"}};import{scaleSequential as Vt}from"d3-scale";function Ht(t){return t&&"object"==typeof t&&t.properties?{...t.properties,...t}:t}var Zt={frameType:"geo",buildProps:(t,e,i,o,n)=>{const r="string"==typeof i?i:"blues",s=n.areaStyle??function(t,e,i,o){if(!Array.isArray(t))return;const n=t=>"function"==typeof e?e(t):null!=e?t?.properties?.[e]??t?.[e]:void 0;let r=1/0,s=-1/0;for(const e of t){const t=n(e);null!=t&&isFinite(t)&&(r>t&&(r=t),t>s&&(s=t))}const a=Vt(v(i)).domain([Number.isFinite(r)?r:0,Number.isFinite(s)?s:1]);return t=>{const e=n(t);return{fill:null!=e&&isFinite(e)?a(e):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:o}}}(n.areas,n.valueAccessor,r,n.areaOpacity??1),a=n.styleRules?I(s,n.styleRules,t=>{return{value:(e=t,"function"==typeof n.valueAccessor?n.valueAccessor(e):null!=n.valueAccessor?e?.properties?.[n.valueAccessor]??e?.[n.valueAccessor]:void 0)};var e},Ht):s;return{areas:n.areas,projection:n.projection||"equalEarth",areaStyle:a,valueAccessor:n.valueAccessor,colorScheme:r,graticule:n.graticule,fitPadding:n.fitPadding,...o}}},Kt={frameType:"geo",buildProps:(t,e,i,o,n)=>{const r=t||n.points,s=n.pointStyle??function(t,e,i,o){const n=Array.isArray(t)?t:[];let r,s;if(e){const t="string"==typeof e?e:"__geoColorBy",o="string"==typeof e?n:n.map(t=>({...t,__geoColorBy:e(t)}));r=P(o,t,i)}if(o.sizeBy){const t=n.map("function"==typeof o.sizeBy?o.sizeBy:t=>t?.[o.sizeBy]).filter(t=>null!=t&&isFinite(t));t.length>0&&(s=rt(t))}return t=>({fill:e&&r?M(t,e,r):"#007bff",fillOpacity:o.fillOpacity,stroke:"#fff",strokeWidth:o.strokeWidth,r:o.sizeBy?R(t,o.sizeBy,o.sizeRange,s):o.pointRadius??6})}(r,e,i,{sizeBy:n.sizeBy,sizeRange:n.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=n.styleRules?I(s,n.styleRules,z(e,n.sizeBy)):s;return{points:r,xAccessor:n.xAccessor||"lon",yAccessor:n.yAccessor||"lat",areas:n.areas,areaStyle:n.areaStyle,pointStyle:a,sizeBy:n.sizeBy,colorBy:e,colorScheme:i,projection:n.projection||"equalEarth",graticule:n.graticule,fitPadding:n.fitPadding,...o}}},Ut={frameType:"geo",buildProps:(t,e,i,o,n)=>{const r=(Array.isArray(t)?t:null)||n.flows||[],s=n.nodeIdAccessor||"id",a=n.valueAccessor||"value",c=n.xAccessor||"lon",l=n.yAccessor||"lat",u="function"==typeof c?c:t=>t[c],h="function"==typeof l?l:t=>t[l],d=(n.nodes||[]).map(t=>({...t,x:u(t),y:h(t)})),f=new Map;for(const t of d)f.set(t[s]+"",t);const p=n.edgeColorBy??e,y="function"==typeof p,g=r.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=f.get(t.source+""),i=f.get(t.target+"");return e&&i?{...t,coordinates:[{x:e.x,y:e.y},{x:i.x,y:i.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?P(g.map(t=>({[m]:p(t)})),m,i||"category10"):P(g,p,i||"category10"):null,b=t=>p&&x?M(t,p,x):"#007bff";let v=1/0,w=-1/0;for(const t of g){const e=Number(t[a]??0);isFinite(e)&&(v>e&&(v=e),e>w&&(w=e))}const k=w>v?w-v:0,[S,A]=n.edgeWidthRange??[1,8],_=A-S,R=n.edgeOpacity??.6,T=n.edgeLinecap??"round";return{lines:g,points:d,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:n.lineType||"geo",flowStyle:n.flowStyle||"basic",areas:n.areas,areaStyle:n.areaStyle,projection:n.projection||"equalEarth",graticule:n.graticule,fitPadding:n.fitPadding,colorScheme:i,lineStyle:t=>{const e=Number(t?.[a]),i=Number.isFinite(e)?e:v,o=S+Math.max(0,Math.min(1,k>0?(i-v)/k:0))*_;return{stroke:b(t),strokeWidth:o,strokeLinecap:T,opacity:R,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...o}}};function Qt(t){const[e,i]=t;return{width:e,height:i,plot:{x:32,y:24,width:Math.max(80,e-64),height:Math.max(80,i-58)}}}function Jt(t){const e=(t??"")+"";if(!e)return"#4e79a7";const i=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let o=0;for(let t=0;e.length>t;t+=1)o=31*o+e.charCodeAt(t)>>>0;return i[o%i.length]}function te(t,e="#4e79a7",i){const o=i?.styleRules,n=!!o&&o.length>0,r=n?$(i?.valueAccessor):void 0;return i=>{const s=i.datum,a=s&&t?"function"==typeof t?t(s,0):s[t]:void 0,c={fill:null==a?e:Jt(a),stroke:"#111827",strokeWidth:1,opacity:.9};return n&&s&&Object.assign(c,N(s,o,{value:r?r(s):void 0,category:null==a?void 0:a+""})),c}}function ee(t,e,i,o){return{fixedDt:1/120,maxSubsteps:8,colliders:e,observation:{chartType:i},kernel:{seed:t,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...o}}}function ie(t,e,i){return"function"==typeof i?i(t,e):t[i]}function oe(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:null}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:null}function ne(t,e,i){return Math.max(e,Math.min(i,t))}function re(t,e){const i=oe(t);return null!=i&&i>0?i:e}function se(t){return((t??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function ae(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}import{scaleLinear as ce}from"d3-scale";function le(t){let e=t>>>0;return function(){e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}var ue={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},he=1e-9,de=.005;function fe(t){return"circle"===t.type?{type:"circle",radius:t.radius}:{type:"aabb",width:t.width,height:t.height}}function pe(t){return"aabb"===t.type?{type:"aabb",x:t.x,y:t.y,width:t.width,height:t.height}:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:t.thickness}}function ye(t,e,i){return Math.max(e,Math.min(i,t))}function ge(t){return 0>t?-1:1}function me(t){if("circle"===t.shape.type){const e=t.shape.radius;return{minX:t.x-e,minY:t.y-e,maxX:t.x+e,maxY:t.y+e}}const e=t.shape.width/2,i=t.shape.height/2;return{minX:t.x-e,minY:t.y-i,maxX:t.x+e,maxY:t.y+i}}function xe(t){const e=t.shape;if("aabb"===e.type){const t=e.width/2,i=e.height/2;return{minX:e.x-t,minY:e.y-i,maxX:e.x+t,maxY:e.y+i}}const i=(e.thickness??0)/2;return{minX:Math.min(e.x1,e.x2)-i,minY:Math.min(e.y1,e.y2)-i,maxX:Math.max(e.x1,e.x2)+i,maxY:Math.max(e.y1,e.y2)+i}}function be(t,e){return!(t.minX>e.maxX||e.minX>t.maxX||t.minY>e.maxY||e.minY>t.maxY)}function ve(t,e,i,o,n,r,s,a){const c=n-t,l=(i+s)/2-Math.abs(c);if(0>=l)return null;const u=r-e,h=(o+a)/2-Math.abs(u);return h>0?h>l?{nx:ge(c),ny:0,penetration:l}:{nx:0,ny:ge(u),penetration:h}:null}function we(t,e,i,o,n,r,s){const a=r/2,c=s/2;let l=t-ye(t,o-a,o+a),u=e-ye(e,n-c,n+c);const h=l*l+u*u;if(h>i*i)return null;if(he>=h){const r=Math.abs(t-(o-a)),s=Math.abs(t-(o+a)),h=Math.abs(e-(n-c)),d=Math.abs(e-(n+c)),f=Math.min(r,s,h,d);return f===r?(l=-1,u=0,{nx:l,ny:u,penetration:i+r}):f===s?(l=1,u=0,{nx:l,ny:u,penetration:i+s}):f===h?(l=0,u=-1,{nx:l,ny:u,penetration:i+h}):(l=0,u=1,{nx:l,ny:u,penetration:i+d})}const d=Math.sqrt(h);return{nx:l/d,ny:u/d,penetration:i-d}}function ke(t,e){if("circle"===t.shape.type&&"circle"===e.shape.type)return function(t,e,i,o,n,r){const s=o-t,a=n-e,c=i+r,l=s*s+a*a;if(l>=c*c)return null;if(he>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/u,penetration:c-u}}(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.radius);if("aabb"===t.shape.type&&"aabb"===e.shape.type)return ve(t.x,t.y,t.shape.width,t.shape.height,e.x,e.y,e.shape.width,e.shape.height);if("circle"===t.shape.type&&"aabb"===e.shape.type){const i=we(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height);return i?{nx:-i.nx,ny:-i.ny,penetration:i.penetration}:null}return"aabb"===t.shape.type&&"circle"===e.shape.type?we(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height):null}function Se(t,e){const i=e.shape;return"aabb"===i.type?"circle"===t.shape.type?we(t.x,t.y,t.shape.radius,i.x,i.y,i.width,i.height):ve(i.x,i.y,i.width,i.height,t.x,t.y,t.shape.width,t.shape.height):function(t,e,i,o,n,r,s,a=0){const c=r-o,l=s-n,u=c*c+l*l,h=u>he?ye(((t-o)*c+(e-n)*l)/u,0,1):0,d=i+a/2,f=t-(o+c*h),p=e-(n+l*h),y=f*f+p*p;if(y>=d*d)return null;if(he>=y){const t=Math.sqrt(u);return t>he?{nx:-l/t,ny:c/t,penetration:d}:{nx:1,ny:0,penetration:d}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:d-g}}(t.x,t.y,"circle"===t.shape.type?t.shape.radius:Math.sqrt(t.shape.width*t.shape.width+t.shape.height*t.shape.height)/2,i.x1,i.y1,i.x2,i.y2,i.thickness??0)}function Ae(t,e){return`${t}\0${e}`}function Me(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function _e(t){return{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,bodyCollisions:t.bodyCollisions,shape:fe(t.shape),sleeping:t.sleeping,datum:t.datum,index:t.index,sleepTime:t.sleepTime,restitution:t.restitution,friction:t.friction}}function Pe(t){return t&&"function"!=typeof t?{property:t.property,equals:t.equals,notEquals:t.notEquals,oneOf:t.oneOf?.slice(),notOneOf:t.notOneOf?.slice()}:t}function Re(t){return{id:t.id,shape:pe(t.shape),sensor:t.sensor,restitution:t.restitution,friction:t.friction,bodyFilter:Pe(t.bodyFilter),index:t.index}}function Te(t,e){return!!e?.some(e=>Object.is(t,e))}function Le(t,e){const i=t.bodyFilter;if(!i)return!0;if("function"==typeof i)return i(e);const o=function(t,e){if(!e)return;let i=t;for(const t of e.split(".")){if(null==i||"object"!=typeof i)return;i=i[t]}return i}(e,i.property);return!("equals"in i&&!Object.is(o,i.equals)||"notEquals"in i&&Object.is(o,i.notEquals)||i.oneOf&&!Te(o,i.oneOf)||i.notOneOf&&Te(o,i.notOneOf))}var Ce=class{constructor(t={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...ue,...t},this.random=le(this.options.seed)}init(t={}){this.options={...ue,...t},this.random=le(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(t){const e={id:t.id,x:t.x,y:t.y,prevX:t.x,prevY:t.y,vx:t.vx??0,vy:t.vy??0,angle:t.angle??0,mass:Math.max(he,t.mass??1),bodyCollisions:t.bodyCollisions??!0,shape:fe(t.shape),sleeping:!1,datum:t.datum,restitution:t.restitution,friction:t.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(t.id,e)}remove(t){for(const e of t){this.bodies.delete(e);for(const t of Array.from(this.activeSensors))Me(t).bodyId===e&&this.activeSensors.delete(t)}}setColliders(t){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const e of t)this.colliders.set(e.id,{...e,shape:pe(e.shape),bodyFilter:Pe(e.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(t){const e=t.id??"spring-"+this.nextSpringIndex;return this.springs.set(e,{id:e,bodyId:t.bodyId,target:t.target,restLength:t.restLength??0,stiffness:t.stiffness??40,damping:t.damping??3}),this.nextSpringIndex+=1,e}removeConstraint(t){this.springs.delete(t)}applyImpulse(t,e,i){const o=this.bodies.get(t);o&&(o.vx+=e/o.mass,o.vy+=i/o.mass,this.wake(o))}step(t=this.options.fixedDt){const e=Math.max(0,t);if(this.lastEvents=[],0===e)return;const i=this.sortedBodies();for(const t of i)t.prevX=t.x,t.prevY=t.y;this.applySprings(e);const o=this.options.maxVelocity;for(const t of i)if(!t.sleeping){if(t.vx+=this.options.gravity.x*e,t.vy+=this.options.gravity.y*e,t.vx*=this.options.velocityDamping,t.vy*=this.options.velocityDamping,o>0){const e=Math.sqrt(t.vx*t.vx+t.vy*t.vy);if(e>o){const i=o/e;t.vx*=i,t.vy*=i}}t.x+=t.vx*e,t.y+=t.vy*e}this.supportedThisStep.clear();const n=this.bodyPairKeys(i),r=this.sortedColliders().filter(t=>!t.sensor);for(let t=0;this.options.collisionIterations>t;t+=1)this.resolveBodyPairs(i,n,0===t),this.resolveColliders(i,r,0===t);this.updateSensors(i),this.updateSleeping(i,e)}settle(t=1200,e=this.options.fixedDt){let i=0;for(;t>i&&!this.allSleeping();)this.step(e),i+=1;return i}readState(t=[]){t.length=0;for(const e of this.sortedBodies())t.push({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:fe(e.shape),sleeping:e.sleeping,datum:e.datum});return t}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Me)}allSleeping(){for(const t of this.bodies.values())if(!t.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(_e),colliders:this.sortedColliders().map(Re),springs:Array.from(this.springs.values()).map(t=>({...t,target:{...t.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(t){this.options={...t.options,gravity:{...t.options.gravity}},this.random=le(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(t.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const e of t.bodies){const t=_e(e);this.bodies.set(t.id,t),this.nextBodyIndex=Math.max(this.nextBodyIndex,t.index+1)}this.nextColliderIndex=0;for(const e of t.colliders){const t=Re(e);this.colliders.set(t.id,t),this.nextColliderIndex=Math.max(this.nextColliderIndex,t.index+1)}this.nextSpringIndex=0;for(const e of t.springs){this.springs.set(e.id,{...e,target:{...e.target}});const t=/^spring-(\d+)$/.exec(e.id);t&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(t[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((t,e)=>t.index-e.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((t,e)=>t.index-e.index)}applySprings(t){for(const e of Array.from(this.springs.values()).sort((t,e)=>t.id.localeCompare(e.id))){const i=this.bodies.get(e.bodyId);if(!i||i.sleeping)continue;const o="point"===e.target.type?e.target:this.bodies.get(e.target.bodyId);if(!o)continue;const n=o.x-i.x,r=o.y-i.y,s=Math.sqrt(n*n+r*r);if(he>=s)continue;const a=n/s,c=r/s,l=(s-e.restLength)*e.stiffness+((("vx"in o?o.vx:0)-i.vx)*a+(("vy"in o?o.vy:0)-i.vy)*c)*e.damping;i.vx+=l*a*t/i.mass,i.vy+=l*c*t/i.mass}}resolveBodyPairs(t,e,i){for(const o of e){const[e,n]=o.split(":").map(Number),r=t[e],s=t[n];if(!r||!s)continue;const a=ke(r,s);a&&(this.resolveDynamicCollision(r,s,a),i&&this.lastEvents.push({type:"contact",bodyId:r.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(t){const e=Math.max(1,this.options.cellSize),i=new Map;for(let o=0;t.length>o;o+=1){if(!1===t[o].bodyCollisions)continue;const n=me(t[o]),r=Math.floor(n.minX/e),s=Math.floor(n.maxX/e),a=Math.floor(n.minY/e),c=Math.floor(n.maxY/e);for(let t=r;s>=t;t+=1)for(let e=a;c>=e;e+=1){const n=`${t}:${e}`,r=i.get(n);r?r.push(o):i.set(n,[o])}}const o=new Set;for(const e of Array.from(i.keys()).sort()){const n=i.get(e)??[];n.sort((t,e)=>t-e);for(let e=0;n.length>e;e+=1)for(let i=e+1;n.length>i;i+=1){const r=n[e],s=n[i];!1!==t[r].bodyCollisions&&!1!==t[s].bodyCollisions&&be(me(t[r]),me(t[s]))&&o.add(`${r}:${s}`)}}return Array.from(o).sort((t,e)=>{const[i,o]=t.split(":").map(Number),[n,r]=e.split(":").map(Number);return i===n?o-r:i-n})}resolveDynamicCollision(t,e,i){t.sleeping&&this.supportedThisStep.add(e.id),e.sleeping&&this.supportedThisStep.add(t.id);const o=t.sleeping?0:1/t.mass,n=e.sleeping?0:1/e.mass,r=o+n;if(he>=r)return;const s=Math.max(0,i.penetration-de)/r;t.x-=i.nx*s*o,t.y-=i.ny*s*o,e.x+=i.nx*s*n,e.y+=i.ny*s*n;const a=(e.vx-t.vx)*i.nx+(e.vy-t.vy)*i.ny;if(a>0)return;const c=Math.abs(a),l=-(1+Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution))*a/r,u=l*i.nx,h=l*i.ny;t.vx-=u*o,t.vy-=h*o,e.vx+=u*n,e.vy+=h*n,this.applyFriction(t,e,i,l,o,n),c>this.options.contactWakeSpeed&&(this.wake(t),this.wake(e))}applyFriction(t,e,i,o,n,r){const s=-i.ny,a=i.nx,c=(e.vx-t.vx)*s+(e.vy-t.vy)*a,l=n+r;if(he>=Math.abs(c)||he>=l)return;const u=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction))),h=ye(-c/l,-o*u,o*u),d=h*s,f=h*a;t.vx-=d*n,t.vy-=f*n,e.vx+=d*r,e.vy+=f*r}resolveColliders(t,e,i){for(const o of t)for(const t of e){if(!Le(t,o))continue;if(!be(me(o),xe(t)))continue;const e=Se(o,t);e&&(this.resolveStaticCollision(o,t,e),this.supportedThisStep.add(o.id),i&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:t.id,sensor:!1}))}}resolveStaticCollision(t,e,i){t.x+=i.nx*Math.max(0,i.penetration-de),t.y+=i.ny*Math.max(0,i.penetration-de);const o=t.vx*i.nx+t.vy*i.ny;if(0>o){const n=Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution);t.vx-=(1+n)*o*i.nx,t.vy-=(1+n)*o*i.ny;const r=-i.ny,s=i.nx,a=t.vx*r+t.vy*s,c=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction)));t.vx-=a*r*c,t.vy-=a*s*c}}updateSensors(t){const e=new Set,i=this.sortedColliders().filter(t=>t.sensor);for(const o of t){const t=me(o);for(const n of i){if(!Le(n,o))continue;if(!be(t,xe(n)))continue;if(!Se(o,n))continue;const i=Ae(n.id,o.id);e.add(i),this.activeSensors.has(i)||this.lastEvents.push({type:"sensor-enter",bodyId:o.id,sensorId:n.id})}}for(const t of Array.from(this.activeSensors).sort()){if(e.has(t))continue;const{sensorId:i,bodyId:o}=Me(t);this.lastEvents.push({type:"sensor-exit",bodyId:o,sensorId:i})}this.activeSensors=e}updateSleeping(t,e){const i=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const o of t)Math.sqrt(o.vx*o.vx+o.vy*o.vy)>=this.options.sleepSpeed||Math.sqrt((o.x-o.prevX)*(o.x-o.prevX)+(o.y-o.prevY)*(o.y-o.prevY))>=this.options.sleepSpeed*e||i&&!this.supportedThisStep.has(o.id)?o.sleeping?this.wake(o):o.sleepTime=0:(o.sleepTime+=e,o.sleeping||this.options.sleepAfter>o.sleepTime||(o.sleeping=!0,o.vx=0,o.vy=0,this.lastEvents.push({type:"sleep",bodyId:o.id})))}wake(t){t.sleeping&&this.lastEvents.push({type:"wake",bodyId:t.id}),t.sleeping=!1,t.sleepTime=0}nextRandom(){return this.random()}},$e=class{constructor(t={}){this.id="builtin",this.capabilities={...(new Ce).capabilities,engine:"builtin"},this.world=new Ce(t)}init(t={}){this.world.init(t)}spawn(t){this.world.spawn(t)}remove(t){this.world.remove(t)}setColliders(t){this.world.setColliders(t)}setConstraint(t){return this.world.setConstraint(t)}removeConstraint(t){this.world.removeConstraint(t)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i)}step(t){this.world.step(t)}settle(t,e){return this.world.settle(t,e)}readState(t){return this.world.readState(t)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(t){this.world.restore(t)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function ze(t,e={}){return t?"function"==typeof t?t(e):(t.init(e),t):function(t={}){return new $e(t)}(e)}var De=["binId","targetBin","category","windowIndex","lane","group"];function Ee(t,e){if(!Number.isFinite(e))return;t.count+=1,t.total+=e,t.min=Math.min(t.min,e),t.max=Math.max(t.max,e);const i=e-t.mean;t.mean+=i/t.count,t.m2+=i*(e-t.mean)}function Ne(t){return{count:t.count,total:t.total,mean:t.count>0?t.mean:0,min:t.count>0?t.min:0,max:t.count>0?t.max:0,variance:t.count>1?t.m2/(t.count-1):0}}function Ie(t){return{count:t.count,total:t.total,mean:t.mean,m2:t.variance*Math.max(0,t.count-1),min:t.count>0?t.min:1/0,max:t.count>0?t.max:-1/0}}function Be(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function Fe(t,e,i){return"function"==typeof t?t(e,i):"string"==typeof t?Be(e,t):void 0}function Oe(t){if(null==t)return;const e=t+"";return e.trim()?e:void 0}function We(t){const e=Ne(t.value);return{id:t.id,label:t.label,count:e.count,total:e.total,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:Ne(t.x),y:Ne(t.y),value:e}}var je=class{constructor(t=!1){this.bins=new Map,this.nextIndex=0,this.config=t}updateConfig(t){void 0!==t&&(this.config=t,!1===t&&this.clear())}isEnabled(){return!1!==this.config}add(t){if(!1===this.config)return null;const e=this.nextIndex;this.nextIndex+=1;const i=Oe(Fe(this.config.binAccessor,t,e))??function(t){for(const e of De){const i=Oe(Be(t,e));if(i)return i}return"sediment"}(t),o=Oe(Fe(this.config.labelAccessor,t,e))??i,n=function(t,e,i){if("number"==typeof t)return t;const o="function"==typeof t?t(e,i):"string"==typeof t?Be(e,t):1,n="number"==typeof o?o:Number(o);return Number.isFinite(n)?n:1}(this.config.valueAccessor,t,e),r=Math.max(0,Math.floor(this.config.retainBodyIds??12));let s=this.bins.get(i);return s||(s={id:i,label:o,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(i,s)),s.label=o,s.lastBodyId=t.id,s.lastDatum=t.datum,Ee(s.x,t.x),Ee(s.y,t.y),Ee(s.value,n),r>0&&(s.bodyIds.push(t.id),s.bodyIds.length>r&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-r))),We(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(We)}restore(t=[]){this.bins.clear();for(const e of t)this.bins.set(e.id,{id:e.id,label:e.label,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:Ie(e.x),y:Ie(e.y),value:Ie(e.value)});this.nextIndex=t.reduce((t,e)=>t+e.count,0)}totals(){const t=this.snapshot();return{bins:t.length,count:t.reduce((t,e)=>t+e.count,0),total:t.reduce((t,e)=>t+e.total,0)}}};function Ye(t){const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}var Xe={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},qe={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function Ge(t={},e=qe){return{chartId:t.chartId??e.chartId,chartType:t.chartType??e.chartType,sensors:t.sensors??e.sensors,onObservation:t.onObservation??e.onObservation,onSimulationStateChange:t.onSimulationStateChange??e.onSimulationStateChange}}function Ve(t){return{...t,shape:{...t.shape},datum:t.datum,springs:t.springs?.map(t=>({...t,target:{...t.target}}))}}function He(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:void 0}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:void 0}function Ze(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function Ke(t){return{...Ve(t),sequence:t.sequence,spawnAt:t.spawnAt}}function Ue(t){return t.map(t=>({...t,shape:{...t.shape},bodyFilter:t.bodyFilter&&"function"!=typeof t.bodyFilter?{...t.bodyFilter,oneOf:t.bodyFilter.oneOf?.slice(),notOneOf:t.bodyFilter.notOneOf?.slice()}:t.bodyFilter}))}function Qe(t){return!1!==t&&{...t}}function Je(t,e){return t.spawnAt===e.spawnAt?t.sequence-e.sequence:t.spawnAt-e.spawnAt}function ti(t){return{...t,gravity:{...t.gravity}}}function ei(t,e,i,o){if("circle"===t.shape.type){const n=t.x-e,r=t.y-i,s=t.shape.radius+o,a=n*n+r*r;return a>s*s?null:a}const n=Math.max(Math.abs(e-t.x)-t.shape.width/2,0),r=Math.max(Math.abs(i-t.y)-t.shape.height/2,0),s=n*n+r*r;return s>o*o?null:s}function ii(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function oi(t,e={}){const{idPrefix:i="plot",includeFloor:o=!0,includeCeiling:n=!1,includeLeftWall:r=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=e,l=[],u=t.x+t.width/2,h=t.y+t.height/2;return o&&l.push({id:i+"-floor",shape:{type:"aabb",x:u,y:t.y+t.height+c/2,width:t.width+2*a,height:c}}),n&&l.push({id:i+"-ceiling",shape:{type:"aabb",x:u,y:t.y-c/2,width:t.width+2*a,height:c}}),r&&l.push({id:i+"-left-wall",shape:{type:"aabb",x:t.x-a/2,y:h,width:a,height:t.height+2*c}}),s&&l.push({id:i+"-right-wall",shape:{type:"aabb",x:t.x+t.width+a/2,y:h,width:a,height:t.height+2*c}}),l}function ni(t){const{idPrefix:e="bin",count:i,domainStart:o,domainStep:n,xScale:r,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:h,lidY:d=s,lidThickness:f=Math.max(2,c)}=t,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?i:i-1;if(u||l)for(let t=l?0:1;m>=t;t+=1){if(!u&&t>0&&i>t)continue;const s=r(o+t*n);p.push({id:`${e}-wall-${t}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=h)for(let t=0;i>t;t+=1){const i=o+t*n,s=i+n;if(s>=h)continue;const a=r(i),l=r(s);p.push({id:`${e}-lid-${t}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:d,x2:Math.max(a,l)-c/2,y2:d,thickness:f}})}return p}var ri={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 si(t,e){const i={...t};for(const t of e)i[ri[t]]++;return i}function ai(t,e,i){const o=new Set(e);return{changeSet:{...t,...t.keys?{keys:[...t.keys]}:{}},changed:o,revisions:si(i,o)}}var ci=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=ai({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}record(t,e){const i=ai(t,e,this.revisions);this.revisions=i.revisions,this.latest=i;for(const t of[...this.listeners])t();return i}};import{quadtree as li}from"d3-quadtree";var ui=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(t,e,i,o,n,r=0){const s=this.ensure(t,e);if(!s)return null;let a=null,c=1/0;const l=Math.max(0,r)+this.maxSearchRadius,u=o-l,h=o+l,d=n-l,f=n+l;return s.visit((t,e,s,l,p)=>{if(u>l||e>h||d>p||s>f)return!0;if(t.length)return!1;let y=t;for(;y;){const t=y.data;if(t){const e=ei(t,o,n,Math.max(0,r));null!=e&&(c>e||e===c&&i.indexOf(t.id)>i.indexOf(a?.id??""))&&(a=t,c=e)}y=y.next}return!1}),a}ensure(t,e){if(this.tree&&this.revision===e)return this.tree;const i=t.readState();return 0===i.length?(this.tree=null,this.maxSearchRadius=0,this.revision=e,null):(this.maxSearchRadius=i.reduce((t,e)=>Math.max(t,function(t){return"circle"===t.shape.type?t.shape.radius:Math.hypot(t.shape.width,t.shape.height)/2}(e)),0),this.tree=li().x(t=>t.x).y(t=>t.y).addAll(i),this.revision=e,this.tree)}},hi=["data","scene-geometry","data-paint","accessibility","evidence"],di=["scene-geometry","data-paint","accessibility","evidence"],fi=["overlay","accessibility","evidence"],pi=(t,e)=>({retainedData:t,invalidations:e}),yi=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gi=["scene-geometry","data-paint","accessibility","evidence"],mi=[],xi={engine:pi("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:pi("preserve",gi),colliders:pi("preserve",gi),sediment:pi("preserve",gi),bodyBudget:pi("preserve",yi),bodyLimit:pi("preserve",yi),eviction:pi("preserve",yi),fixedDt:pi("preserve",mi),maxDeltaSeconds:pi("preserve",mi),maxSubsteps:pi("preserve",mi),settleStepLimit:pi("preserve",mi),timeScale:pi("preserve",mi),observation:pi("preserve",mi)},bi=pi("preserve",yi);function vi(t){let e="preserve";const i=new Set;for(const o of t){const t=xi[o]??bi;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}var wi=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function ki(t,e){return t===e||!(!t||!e)&&t.gravity?.x===e.gravity?.x&&t.gravity?.y===e.gravity?.y&&wi.every(i=>t[i]===e[i])}function Si(t,e,i,o){return t||!e?"paused":i||!o?"running":"settled"}var Ai=class{constructor(t={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new ui,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new ci,this.simulationState="settled",this.visible=!0;const{bodyBudget:e,colliders:i,engine:o,kernel:n,observation:r,sediment:s,...a}=t;this.config={...Xe,...a},this.configInput={...t},this.bodyBudget=e??{},this.engineInput=o,this.observation=Ge(r),this.sediment=new je(s??!1),this.world=ze(o,{fixedDt:this.config.fixedDt,...n}),i&&this.world.setColliders(Ue(i))}updateConfig(t){const e=function(t,e){return Object.keys(t).filter(i=>"kernel"===i?!ki(t.kernel,e.kernel):t[i]!==e[i])}(t,this.configInput),{colliders:i,bodyBudget:o,engine:n,kernel:r,observation:s,sediment:a,...c}=t;if(this.config={...this.config,...c},void 0!==o&&(this.bodyBudget=o,!1===o&&(this.bodyBudgetObservationKey="ok")),n&&n!==this.engineInput){const t=this.world.snapshot();this.world.dispose(),this.engineInput=n,this.world=ze(n,t.options),this.world.restore(t),this.revision+=1}if(r&&!ki(r,this.configInput.kernel)){const t=this.world.snapshot(),e={...t.options,...r,gravity:{...t.options.gravity,...r.gravity}};this.world.restore({...t,options:e}),this.revision+=1}s&&(this.observation=Ge(s,this.observation)),this.sediment.updateConfig(a),i&&(this.world.setColliders(Ue(i)),this.revision+=1),this.configInput={...this.configInput,...t};const l=vi(e);this.updateResults.record({kind:"config",keys:e},l.invalidations)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setColliders(t){this.world.setColliders(Ue(t)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},vi(["colliders"]).invalidations)}enqueue(t,e){const i=Array.isArray(t)?t:[t],o=e?function(t,e={}){const i=He(e.startAt)??0,o=e.pacing??"immediate";if("arrival"===o){const o=t.map((t,i)=>function(t,e,i){return"function"==typeof i?He(i(t,e)):"string"==typeof i?He(Ze(t,i)):He(t.spawnAt)??He(Ze(t,"arrivalTime"))??He(Ze(t,"timestamp"))??He(Ze(t,"time"))??He(Ze(t,"eventTime"))}(t,i,e.timeAccessor)),n=o.filter(t=>null!=t),r=n.length>0?Math.min(...n):0,s=He(e.timeScale)??1,a=s>0?s:1;return t.map((t,e)=>{const n=o[e],s=null==n?0:Math.max(0,n-r);return{...Ve(t),spawnAt:i+s/a}})}if("object"==typeof o){const e=He(o.ratePerSec);if(e&&e>0)return t.map((t,o)=>({...Ve(t),spawnAt:i+o/e}))}return t.map(t=>({...Ve(t),spawnAt:i}))}(i,{...e,startAt:e.startAt??this.elapsedSeconds}):i;for(const t of o)this.queue.push({...Ve(t),sequence:this.nextSequence,spawnAt:t.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(Je),o.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:o.length},o.length?hi:[])}enqueueWithResult(t,e){return this.enqueue(t,e),this.updateResults.last}spawnNow(t){this.spawnOne(Ve(t)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},hi)}clear(){const t=this.world.snapshot().options;this.world.init({...t,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"},hi)}tick(t){const e=this.revision,i=[],o=[],n=[],r=[],s=[];if(this.paused||!this.visible){const t=this.result(0,i,o,n,r,s,!1);return this.updateResults.record({kind:"tick",count:0},[]),t}const a=Math.max(0,Math.min(t,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(i,s);const c=this.observeBodyBudget(s),l=this.evictOverflow(s);o.push(...l.evicted),n.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 t=this.world.events();r.push(...t),this.observeKernelEvents(t,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||i.length>0||o.length>0||n.length>0||r.length>0)&&(this.revision+=1);const h=this.result(u,i,o,n,r,s,void 0,c);return this.updateResults.record({kind:"tick",count:u},this.revision!==e?i.length||o.length||n.length?hi:di:[]),h}settle(t=this.config.settleStepLimit){const e=this.revision;this.spawnDue([],[]);const i=this.world.settle(t,this.config.fixedDt);return i>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:i},this.revision!==e?di:[]),i}settleWithObservations(t=this.config.settleStepLimit){const e=this.revision,i=[],o=[],n=[],r=[],s=[];if(this.paused||!this.visible){const t=this.result(0,i,o,n,r,s,!1);return this.updateResults.record({kind:"settle",count:0},[]),t}this.spawnDue(i,s);const a=this.observeBodyBudget(s),c=this.evictOverflow(s);o.push(...c.evicted),n.push(...c.sedimented),this.syncSimulationState(s);let l=0;for(;t>l&&!this.world.allSleeping();){this.world.step(this.config.fixedDt);const t=this.world.events();r.push(...t),this.observeKernelEvents(t,s),this.observeSensorTransitions(s),l+=1}(l>0||i.length>0||o.length>0||n.length>0||r.length>0)&&(this.revision+=1);const u=this.result(l,i,o,n,r,s,void 0,a);return this.updateResults.record({kind:"settle",count:l},this.revision!==e?i.length||o.length||n.length?hi:di:[]),u}readBodies(t=[]){return this.world.readState(t)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(t={}){return function(t,e={}){const{baselineY:i=0,binWidth:o=24,gap:n=2,maxHeight:r=80,value:s="count",x:a}=e,c=Math.max(1,...t.map(t=>t[s]));return t.map((t,e)=>{const l=Math.max(0,t[s]/c*r),u=a?.(t,e)??e*(o+n);return{binId:t.id,label:t.label,index:e,count:t.count,total:t.total,x:u,y:i-l,width:o,height:l,meanX:t.x.mean,meanY:t.y.mean}})}(this.readSediment(),t)}hitTest(t,e,i=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,t,e,i)}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(t){const{timestamp:e,chartType:i,chartId:o,...n}=t,r={...n,timestamp:e??this.elapsedSeconds,chartType:i??this.observation.chartType,chartId:o??this.observation.chartId};return this.emitObservation(r),this.updateResults.record({kind:"update",count:1},["evidence"]),r}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(t){return this.updateResults.subscribe(t)}version(){return this.revision}setPaused(t){const e=this.paused!==t;this.paused=t,this.syncSimulationState(),this.updateResults.record({kind:"pause"},e?fi:[])}setVisible(t){const e=this.visible!==t;this.visible=t,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},e?fi:[])}remove(t){const e=new Set(t),i=new Set(this.liveBodyOrder),o=new Set(this.queue.map(t=>t.id));this.queue=this.queue.filter(t=>!e.has(t.id)),this.liveBodyOrder=this.liveBodyOrder.filter(t=>!e.has(t)),this.world.remove(t),this.removeActiveSensorPairsForBodies(e);const n=t.filter(t=>i.has(t)||o.has(t));return n.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:n,count:n.length},n.length?hi:[]),n}setConstraint(t){const e=this.world.setConstraint(t);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},di),e}removeConstraint(t){this.world.removeConstraint(t),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},di)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[t]},di)}nextRandom(){return this.world.nextRandom()}controls(){return t=this,{applyImpulse:(e,i,o)=>t.applyImpulse(e,i,o),clear:()=>t.clear(),hitTest:(e,i,o)=>t.hitTest(e,i,o),pause:()=>t.setPaused(!0),push:(e,i)=>t.enqueue(e,i),pushMany:(e,i)=>t.enqueue(e,i),bodyBudgetStatus:()=>t.bodyBudgetStatus(),readBodies:e=>t.readBodies(e),readSediment:()=>t.readSediment(),recordObservation:e=>t.recordObservation(e),remove:e=>t.remove(e),restore:e=>t.restore(e),resume:()=>t.setPaused(!1),settle:e=>t.settle(e),settleWithObservations:e=>t.settleWithObservations(e),snapshot:()=>t.snapshot(),sedimentHeightfield:e=>t.sedimentHeightfield(e),sedimentTotals:()=>t.sedimentTotals(),step:e=>t.tick(e)};var t}snapshot(){const t=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:Qe(this.bodyBudget),config:{...this.config,kernel:ti(t.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(Ke),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:t}}restore(t){this.config={bodyLimit:t.config.bodyLimit,eviction:t.config.eviction,fixedDt:t.config.fixedDt,maxDeltaSeconds:t.config.maxDeltaSeconds,maxSubsteps:t.config.maxSubsteps,settleStepLimit:t.config.settleStepLimit,timeScale:t.config.timeScale},this.configInput={...t.config,bodyBudget:Qe(t.bodyBudget??{}),kernel:ti(t.world.options)},this.bodyBudget=Qe(t.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.activeSensorPairs=new Set(t.activeSensorPairs),this.accumulator=t.accumulator,this.elapsedSeconds=t.elapsedSeconds,this.paused=t.paused,this.queue=t.queue.map(Ke).sort(Je),this.revision=t.revision,this.sediment.restore(t.sediment??[]),this.simulationState=t.simulationState??Si(t.paused,t.visible,t.queue.length>0,t.world.bodies.every(t=>t.sleeping)),this.liveBodyOrder=t.liveBodyOrder.slice(),this.visible=t.visible,this.nextSequence=this.queue.reduce((t,e)=>Math.max(t,e.sequence),-1)+1,this.world.restore(t.world),this.updateResults.record({kind:"restore"},hi)}spawnDue(t,e){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const i=this.queue.shift();if(!i)return;this.spawnOne(i,e),t.push(i.id)}}spawnOne(t,e){this.liveBodyOrder=this.liveBodyOrder.filter(e=>e!==t.id),this.removeActiveSensorPairsForBodies(new Set([t.id])),this.world.spawn(t),this.liveBodyOrder.push(t.id);for(const e of t.springs??[])this.world.setConstraint({...e,bodyId:t.id});const i=this.world.readState().find(e=>e.id===t.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:t.id,datum:i?.datum??t.datum,x:i?.x??t.x,y:i?.y??t.y},e)}result(t,e,i,o,n,r,s,a=this.evaluateBodyBudget()){this.syncSimulationState(r);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:i,events:n,observations:r,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!c),sleeping:c,sedimented:o,spawned:e,steps:t}}observeKernelEvents(t,e){!function(t,e,i){if(0===e.length)return;const o=new Map(t.readState().map(t=>[t.id,t]));for(const t of e){if("sleep"!==t.type)continue;const e=o.get(t.bodyId);i.emit({type:"physics-settle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:t.bodyId,datum:e?.datum,x:e?.x,y:e?.y})}}(this.world,t,this.observationContext(e))}observeSensorTransitions(t){this.activeSensorPairs=function(t,e,i){const o=new Set(t.activeSensorPairs().map(t=>`${t.sensorId}\0${t.bodyId}`));if(0===o.size&&0===e.size)return o;const n=new Map(t.readState().map(t=>[t.id,t])),r=(t,e)=>{const{sensorId:o,bodyId:r}=ii(e),s=i.observation.sensors[o],a=n.get(r);i.emit({type:"enter"===t?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:r,datum:a?.datum,x:a?.x,y:a?.y,sensorId:o,binId:s?.binId??o})};for(const t of Array.from(o).sort())e.has(t)||r("enter",t);for(const t of Array.from(e).sort())o.has(t)||r("exit",t);return o}(this.world,this.activeSensorPairs,this.observationContext(t))}removeActiveSensorPairsForBodies(t){!function(t,e){for(const i of t)e.has(ii(i).bodyId)&&t.delete(i)}(this.activeSensorPairs,t)}observationContext(t){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:e=>this.emitObservation(e,t)}}emitObservation(t,e){e?.push(t),this.observation.onObservation?.(t)}evaluateBodyBudget(){return function(t){const e=Math.max(0,Math.floor(t.liveBodies)),i=Math.max(0,Math.floor(t.queuedBodies??0)),o=e+i,n=Ye(t.bodyLimit),r=Ye(t.engineMaxBodiesHint),s=function(t,e,i){if(!1===i)return;const o=Ye(i?.warnAt);return null!=o?o:null!=t?Math.max(1,Math.floor(.8*t)):null!=e?Math.max(1,Math.floor(.8*e)):void 0}(n,r,t.options),a=null==n?0:Math.max(0,e-n),c=a>0?"overflow":null==s||s>o?"ok":"warning";return{action:"overflow"!==c?"continue":t.sedimentEnabled?"sediment":t.evictionEnabled?"evict":"retain",bodyLimit:n,engineMaxBodiesHint:r,liveBodies:e,overflow:a,projectedBodies:o,queuedBodies:i,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(t){const e=this.evaluateBodyBudget();if("ok"===e.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",e;const i=`${e.state}:${e.action}`;return i===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=i,this.emitObservation({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:e.action,bodyLimit:e.bodyLimit,engineMaxBodiesHint:e.engineMaxBodiesHint,liveBodies:e.liveBodies,overflow:e.overflow,projectedBodies:e.projectedBodies,queuedBodies:e.queuedBodies,warnAt:e.warnAt},t)),e}syncSimulationState(t){const e=Si(this.paused,this.visible,this.queue.length>0,this.world.allSleeping());if(e===this.simulationState)return;const i=this.simulationState;this.simulationState=e,function(t,e,i){i.observation.onSimulationStateChange?.(e,t),"running"!==e&&"settled"!==e||i.emit({type:"running"===e?"sim-active":"sim-idle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,simulationState:e,previousSimulationState:t})}(i,e,this.observationContext(t))}evictOverflow(t){if(!1===this.config.eviction)return{evicted:[],sedimented:[]};const e=Math.max(0,Math.floor(this.config.bodyLimit));if(!Number.isFinite(e))return{evicted:[],sedimented:[]};const i=this.liveBodyOrder.length-e;if(0>=i)return{evicted:[],sedimented:[]};const o=("sleeping-first"===this.config.eviction?this.sleepingFirstEvictionOrder():this.liveBodyOrder.slice()).slice(0,i);if(0===o.length)return{evicted:[],sedimented:[]};const n=this.absorbSediment(o,t);this.world.remove(o);const r=new Set(o);return this.liveBodyOrder=this.liveBodyOrder.filter(t=>!r.has(t)),this.removeActiveSensorPairsForBodies(r),{evicted:o,sedimented:n}}absorbSediment(t,e){const i=new Map(this.world.readState().map(t=>[t.id,t])),o=[];for(const n of t){const t=i.get(n);if(!t)continue;const r=this.sediment.add(t);r&&(o.push(n),this.emitObservation({type:"physics-sediment",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:n,datum:t.datum,x:t.x,y:t.y,binId:r.id,count:r.count,total:r.total},e))}return o}sleepingFirstEvictionOrder(){const t=new Map(this.world.readState().map(t=>[t.id,t.sleeping])),e=[],i=[];for(const o of this.liveBodyOrder)t.get(o)?e.push(o):i.push(o);return[...e,...i]}};import{scaleLinear as Mi}from"d3-scale";function _i(t){const{count:e,idPrefix:i,wallThickness:o,xScale:n,yBottom:r,yTop:s,yTopForIndex:a}=t;return Array.from({length:e+1},(t,e)=>{const c=Math.min(r-1,a?.(e)??s),l=Math.max(1,r-c);return{id:`${i}-wall-${e}`,shape:{type:"aabb",x:n(e),y:c+l/2,width:o,height:l}}})}import{scaleLinear as Pi}from"d3-scale";function Ri(t){if(Array.isArray(t)&&t.length>=2){const e=oe(t[0]),i=oe(t[1]);return null!=e&&null!=i?{x:e,y:i}:null}if(t&&"object"==typeof t){const e=t,i=oe(e.x),o=oe(e.y);return null!=i&&null!=o?{x:i,y:o}:null}return null}function Ti(t){return Array.isArray(t)?t.map(Ri).filter(t=>null!=t):[]}function Li(t,e,i){return"normalized"===i?{x:e.plot.x+t.x*e.plot.width,y:e.plot.y+t.y*e.plot.height}:{x:ne(t.x,e.plot.x,e.plot.x+e.plot.width),y:ne(t.y,e.plot.y,e.plot.y+e.plot.height)}}function Ci(t){let e=0;for(let i=1;t.length>i;i+=1)e+=Math.hypot(t[i].x-t[i-1].x,t[i].y-t[i-1].y);return e}function $i(t,e){if(0===t.length)return{x:0,y:0};if(1===t.length)return{...t[0]};const i=ne(e,0,1)*Ci(t);let o=0;for(let e=1;t.length>e;e+=1){const n=t[e-1],r=t[e],s=Math.hypot(r.x-n.x,r.y-n.y);if(s>0){if(o+s>=i){const t=(i-o)/s;return{x:n.x+(r.x-n.x)*t,y:n.y+(r.y-n.y)*t}}o+=s}}return{...t[t.length-1]}}function zi(t,e){const i=$i(t,Math.max(0,e-.02)),o=$i(t,Math.min(1,e+.02)),n=o.x-i.x,r=o.y-i.y,s=Math.hypot(n,r)||1;return{x:n/s,y:r/s}}function Di(t,e,i){return Math.max(e,Math.min(i,t))}function Ei(t,e,i,o,n,r={}){return{id:t,friction:r.friction,restitution:r.restitution,bodyFilter:r.bodyFilter,shape:{type:"segment",x1:e,y1:i,x2:o,y2:n,thickness:r.thickness??8}}}function Ni(t){return{id:t.id,label:t.label,description:t.description,kind:t.kind,shape:(e=t.x,i=t.y,o=t.width,n=t.height,{type:"aabb",x:e,y:i,width:o,height:n}),bodyFilter:t.bodyFilter,collider:t.collider,colliderThickness:t.colliderThickness,friction:t.friction,restitution:t.restitution,semanticItem:t.semanticItem,metadata:t.metadata,bodyStyle:t.bodyStyle,attributes:t.attributes,onEnter:t.onEnter,onExit:t.onExit};var e,i,o,n}function Ii(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:12,y:0};return{...Ni({...t,kind:t.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.015}}function Bi(t,e=12){return"number"==typeof t?{x:t,y:0}:t&&"object"==typeof t?{x:Number.isFinite(t.x)?Number(t.x):e,y:Number.isFinite(t.y)?Number(t.y):0}:{x:e,y:0}}function Fi(t){const e=t.stages;if(!e.length)throw Error("buildProcessFlowPhysics requires at least one stage");const i=t.size,o=Qt(i),n=ne(t.ballRadius??6,2,18),r=t.seed??1,s=ae(r),a=t.idAccessor,c=t.stageAccessor??"stage",l=t.groupBy,u=t.groupLabelAccessor,h=t.workAccessor,d=t.radiusAccessor,f=t.groupCompletion??(l?"allAbsorbed":"none"),p=t.springStiffness??.28,y=t.springDamping??.72,g=!0===t.settle,m=e.map(t=>({id:t.id,label:t.label??t.id,description:t.description,share:t.share})),x=function(t){const e=t.shape??"lane",i=Math.max(1,Math.round(t.width)),o=Math.max(1,Math.round(t.height)),n=t.padX??46,r=t.padY??72,s=n,a=i-n,c=r,l=o-Math.max(24,Math.round(.45*r)),u=(c+l)/2,h=Math.max(1,l-c),d=Di(t.pinchRatio??.18,.06,.5),f=Number(t.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=Di(h*d+p,.06*h,.5*h),g=y/2,m=u-g,x=u+g,b=t.idPrefix??"process",v=t.friction??.58,w=t.restitution??.18,k=t.wallThickness??8,S=t.stages;if(!S.length)throw Error("processStageLayout requires at least one stage");const A=Di(t.centerStageIndex??Math.floor(S.length/2),0,S.length-1),M=function(t){const e=t.reduce((t,e)=>t+(e.share??1),0);return e>0?e:t.length}(S),_=a-s;let P=s;const R=S.map((t,e)=>{const i=P,o=e===S.length-1?a:P+(t.share??1)/M*_;return P=o,{id:t.id,label:t.label,description:t.description,kind:t.kind??"stage",index:e,x0:i,x1:o,x:(i+o)/2,width:o-i,y:u,height:h}}),T=R[A],L=T.x0,C=T.x1,$=(t,i)=>{if("lane"===e)return"top"===i?c:l;if("funnel"===e){const e=Di((t-s)/Math.max(1,a-s),0,1);return"top"===i?c+(m-c)*e:l+(x-l)*e}if(L>=t){const e=Di((t-s)/Math.max(1,L-s),0,1);return"top"===i?c+(m-c)*e:l+(x-l)*e}if(C>=t)return"top"===i?m:x;const o=Di((t-C)/Math.max(1,a-C),0,1);return"top"===i?m+(c-m)*o:x+(l-x)*o},z=R.map(t=>{const e=Math.min($(t.x0,"top"),$(t.x1,"top")),i=Math.max($(t.x0,"bottom"),$(t.x1,"bottom"));return{...t,y:(e+i)/2,height:Math.max(1,i-e)}}),D={thickness:k,friction:v,restitution:w},E=[];"lane"===e?E.push(Ei(b+"-top",s,c,a,c,D),Ei(b+"-bottom",s,l,a,l,D),Ei(b+"-left",s,c,s,l,{...D,thickness:Math.max(6,k-2)}),Ei(b+"-right",a,c,a,l,{...D,thickness:Math.max(6,k)})):"funnel"===e?E.push(Ei(b+"-top",s,c,a,m,D),Ei(b+"-bottom",s,l,a,x,D),Ei(b+"-left",s,c,s,l,{...D,thickness:Math.max(6,k-2)}),Ei(b+"-right",a,m,a,x,{...D,thickness:Math.max(6,k)})):E.push(Ei(b+"-left-top",s,c,L,m,D),Ei(b+"-left-bottom",s,l,L,x,D),Ei(b+"-center-top",L,m,C,m,D),Ei(b+"-center-bottom",L,x,C,x,D),Ei(b+"-right-top",C,m,a,c,D),Ei(b+"-right-bottom",C,x,a,l,D),Ei(b+"-left",s,c,s,l,{...D,thickness:Math.max(6,k-2)}),Ei(b+"-right",a,c,a,l,{...D,thickness:Math.max(6,k)}));const N=t.membraneDampingScale??.5,I=s,B=Math.max(1,("bowtie"===e?L:a)-I),F=(t.membranes??[]).map(t=>{const e=I+Di(t.offset,0,1)*B,i=t.width??18+18*t.cost,o=h-16,n=u+.25*(t.wobble??0);return{...t,x:e,y:n,width:i,height:o}}),O=!1===t.includeMembraneRegions?[]:F.map(t=>function(t){const e=t.dampingScale??.5,i=t.energyScale??1,o=Di(t.cost,0,2);return{...Ni({...t,kind:t.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:o*e,energyDelta:-o*i}}({id:t.id,label:t.label??t.id,description:t.description??(t.label??t.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:t.x,y:t.y,width:t.width,height:t.height,cost:t.cost,dampingScale:t.dampingScale??N,bodyStyle:t.bodyStyle,metadata:t.metadata,semanticItem:t.semanticItem,color:t.color}));return{shape:e,width:i,height:o,padX:n,padY:r,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:L,centerRight:C,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:z,membranes:F,colliders:E,regionEffects:O,boundaryY:$}}({width:i[0],height:i[1],shape:"lane",padX:Math.max(28,o.plot.x),padY:Math.max(36,o.plot.y+8),stages:m,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((t,e)=>[t.id,e])),v=new Map(x.stages.map(t=>[t.id,t])),w=x.stages[0].id,k=x.stages[0],S=new Set(e.filter(t=>t.absorb).map(t=>t.id)),A=e.map(t=>{const e=v.get(t.id)??k;return function(t,e){const i={id:"process-stage-"+t.id,label:t.label??t.id,description:t.description,x:e.x,y:e.y,width:Math.max(12,.92*e.width),height:Math.max(40,.88*e.height),semanticItem:!1,attributes:{stageId:t.id}};if(t.absorb)return function(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:24,y:0};return{...Ni({...t,kind:t.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.02,charge:t.charge??"absorbed"}}({...i,kind:t.kind??"sink",force:Bi(t.force,28),damping:t.damping??.04,charge:"absorbed",attributes:{...i.attributes,primitive:"absorb"}});if(t.portal){const e=t.portal.force??t.force??{x:-40,y:0};return o={...i,kind:t.kind??"force-field",force:Bi(e,-40),damping:t.damping??.1,targetStage:t.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:t.portal.targetStageId}},{...Ni({...o,kind:o.kind??"force-field",attributes:{primitive:"portal",targetStage:o.targetStage,..."object"==typeof o.attributes&&o.attributes?o.attributes:{}}}),force:o.force,impulseOnEnter:o.impulseOnEnter,damping:o.damping??.08}}var o;if(t.capacity){const e=Math.max(.1,t.capacity.unitsPerSecond);return function(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force;return{...Ni({...t,kind:t.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:t.capacity,unitsPerSecond:t.unitsPerSecond??t.capacity,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping,charge:t.charge??t.capacity}}({...i,kind:t.kind??"force-field",capacity:e,unitsPerSecond:e,force:Bi(t.force,10+.8*e),damping:t.damping??Math.max(.04,.32-.01*e),attributes:{...i.attributes,unitAccessor:t.capacity.unitAccessor,reviewerCapacity:e}})}if(t.pressure){const e="object"==typeof t.pressure&&t.pressure?t.pressure:{};return function(t){const e=t.pressure??t.occupancy??0,i=t.baseDamping??.08,o=t.dampingPerUnit??.12,n=t.energyPerUnit??0;return{...Ni({...t,kind:t.kind??"membrane",attributes:{primitive:"pressureField",pressure:e,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:i+e*o,energyDelta:n?-e*n:void 0,force:t.force}}({...i,kind:t.kind??"membrane",pressure:e.pressure,occupancy:e.occupancy,baseDamping:e.baseDamping??t.damping??.1,dampingPerUnit:e.dampingPerUnit??.1,energyPerUnit:e.energyPerUnit??0,force:Bi(t.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=t.force||null!=t.damping?Ii({...i,kind:t.kind??"force-field",force:Bi(t.force,14),damping:t.damping??.02,attributes:{...i.attributes,primitive:"routeSurface"}}):function(t){return{...Ni({...t,kind:t.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:t.force,damping:t.damping,energyDelta:t.energyDelta}}({...i,kind:t.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...i.attributes,primitive:"forceField"}})}(t,{x:e.x,y:x.midY,width:e.width,height:x.bottomY-x.topY})});A.unshift(Ii({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 t of x.stages)M.set(t.id,0);const _=[];t.data.forEach((t,e)=>{const i=(a?ie(t,e,a)??t.id??"process-flow-"+e:t.id??"process-flow-"+e)+"",o=(ie(t,e,c)??w)+"",r=b.has(o)?o:w;M.set(r,(M.get(r)??0)+1);const s=l?(ie(t,e,l)??"")+"":void 0,f=s&&u?(ie(t,e,u)??s)+"":s,p=h?oe(ie(t,e,h))??1:1,y=d?oe(ie(t,e,d)):null,g=ne(null!=y&&y>0?y:n,2,18);_.push({datum:t,id:i,stageId:r,groupId:s||void 0,groupLabel:f||void 0,work:p,radius:g,index:e})});const P=new Map,R=new Map;for(const t of _){if(!t.groupId)continue;const e=P.get(t.groupId)??[];e.push(t.id),P.set(t.groupId,e),t.groupLabel&&R.set(t.groupId,t.groupLabel)}const T=ne(t.groupAnchorAlong??.55,.15,.9),L=x.left+(x.right-x.left)*T,C=Array.from(P.keys()),$=C.map((t,i)=>{const o=P.get(t)??[],n=C.length>1?x.topY+28+i/Math.max(1,C.length-1)*(x.bottomY-x.topY-56):x.midY;return function(t){const e=t.x??t.anchor?.x??0,i=t.y??t.anchor?.y??0;return{id:t.id,label:t.label,description:t.description,group:t.group,bodyIds:t.bodyIds,datum:t.datum,state:t.state,x:e,y:i,width:t.width,height:t.height,anchor:t.anchor??{x:e,y:i},completion:t.completion,tether:t.tether,semanticItem:t.semanticItem}}({id:t,label:R.get(t)??t,bodyIds:o,anchor:{x:L,y:n},x:L,y:n,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:e.find(t=>t.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),z=function(t,e){const i=e instanceof Set?e:new Set(e);return t.map(t=>{const e=t.bodyIds??[],o=e.filter(t=>!i.has(t)),n=e.length-o.length,r=t.completion?.mode??"allMembersAbsorbed",s=t.completion?.valueByBodyId,a=t=>{const e=s?.[t];return Number.isFinite(e)&&Number(e)>=0?Number(e):1},c=e.reduce((t,e)=>t+a(e),0),l=e.reduce((t,e)=>t+(i.has(e)?a(e):0),0),u=t.completion?.threshold,h="threshold"===r?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:t.id,label:t.label??t.id,mode:r,complete:e.length>0&&("anyAbsorbed"===r?n>0:"threshold"===r?l>=(h??c):0===o.length),absorbed:n,total:e.length,absorbedValue:l,totalValue:c,threshold:h,missing:o}})}($,_.filter(t=>S.has(t.stageId)).map(t=>t.id)),D=new Map($.map(t=>[t.id,t])),E=_.map((t,e)=>{const i=v.get(t.stageId)??k,o=i.x+(s()-.5)*Math.min(24,.2*i.width),n=x.boundaryY(o,"top")+t.radius+10,r=x.boundaryY(o,"bottom")-t.radius-10,a=r>n?n+s()*Math.max(1,r-n):x.midY,c=g?o:x.left+18+e%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:o,y:a},restLength:.45*t.radius,stiffness:p,damping:y}];if(t.groupId){const e=D.get(t.groupId);e?.anchor&&!S.has(t.stageId)&&u.push({target:{type:"point",x:e.anchor.x,y:e.anchor.y},restLength:e.tether?.restLength??22,stiffness:e.tether?.stiffness??.05,damping:.8})}return{id:t.id,x:c,y:l,vx:g?0:40+40*s(),vy:g?0:20*(s()-.5),mass:1,shape:{type:"circle",radius:t.radius},spawnAt:g?0:.03*e,springs:u,datum:{...t.datum,id:t.id,stage:t.stageId,groupId:t.groupId,groupLabel:t.groupLabel,work:t.work,__processFlow:!0}}}),N={kernel:{seed:r,gravity:{x:t.gravityX??22,y:t.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},I=x.stages.map(t=>({label:t.label??t.id,value:M.get(t.id)??0})),B=e.map(t=>{const e=v.get(t.id)??k;return{id:t.id,label:t.label??t.id,x:e.x,width:e.width,count:M.get(t.id)??0,capacity:t.capacity?.unitsPerSecond,absorb:!0===t.absorb,portalTarget:t.portal?.targetStageId}});return{config:N,initialSpawns:E,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:I,metadata:{kind:"process-flow",plot:o.plot,volume:x,stages:B,groups:$,groupCompletion:z,regionEffects:A}}}import{scaleLinear as Oi}from"d3-scale";function Wi(t,e,i){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=Object.values(t).filter(t=>"string"==typeof t&&t.length>0);if(e.length>0)return e}if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=w[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:i}function ji(t,e){const i=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>i&&_(i,t)||"#4e79a7":e=>{if(i){const t=_(i,e);if(t)return t}let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return t[Math.abs(o)%t.length]??"#4e79a7"}}function Yi(t,e){const i=e.config??{},o=(e.sensors??[]).map(t=>({...t,sensor:!0})),n=[...e.colliders??[],...o],r=[...t.colliders??[],...i.colliders??[],...n];return{...t,...i,observation:{...t.observation,...i.observation},...r.length>0&&{colliders:r}}}function Xi(t){return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:28,y2:t.floorY,thickness:8}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:t.width-30,y2:76,thickness:8}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:t.floorY,x2:t.width-30,y2:t.floorY,thickness:8}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:t.width-30,y1:76,x2:t.width-30,y2:t.floorY,thickness:8}}]}function qi(t,e,i,o){return i?"function"==typeof i?i(t,e):t[i]??o:o}function Gi(t){return`gauntlet:${t}:core`}function Vi(t,e){return`gauntlet:${t}:positive:${e}`}function Hi(t,e,i){return`gauntlet:${t}:negative:${e}:${i}`}function Zi(t,e,i,o){const n=Math.max(2,i+2),r=80+n,s=o.floorY-n;return{x:Math.max(32+n,Math.min(o.width-30-4-n,t)),y:Math.max(r,Math.min(s,e))}}function Ki(t,e){const i=[...t].sort((t,e)=>t.localeCompare(e)),o=Math.max(0,i.indexOf(e));return{angle:.82*-Math.PI+(i.length>1?o/(i.length-1):.5)*Math.PI*.64,index:o,radius:48+o%2*6}}function Ui(t,e,i){const o=t.activePositiveIds.reduce((t,i)=>t+(e.get(i)?.value??1),0),n=t.missingPositiveIds.length+t.poppedPositiveIds.length,r=t.negativeIds.reduce((t,e)=>t+(i.get(e)?.load??1),0);return Math.max(0,Math.min(100,75+3*o-8*r-1.2*t.delay-5*n))}function Qi(t){const e=function(t,e,i){const[o,n]=t,r=Math.round(.48*n),s=n-36,a=(e??[]).filter(t=>!1!==t.enabled),c=Math.max(1,a.length),l=.22*o,u=c>1?(.78*o-l)/(c-1):0,h=Math.max(Math.round(.14*o),110);return{crashY:s-i,floorY:s,gates:a.map((t,e)=>({...t,id:t.id,x:t.x??Math.round(l+e*u),width:t.width??Math.max(54,Math.round(.07*o))})),graveyardX:Math.round(.84*o),graveyardY:s-4,height:n,routeY:r,socketX:Math.round(.92*o),startX:h,width:o}}(t.size??[900,520],t.gates,t.crashOffset??30),i=t.positiveProperties??[],o=new Map(i.map(t=>[t.id,t])),n=new Map((t.negativeProperties??[]).map(t=>[t.id,t])),r={idAccessor:t.idAccessor,initialViability:t.initialViability,metricsAccessor:t.metricsAccessor,negativeAccessor:t.negativeAccessor,positiveAccessor:t.positiveAccessor,startTimeAccessor:t.startTimeAccessor},s=(t.data??[]).map((e,s)=>{const a=function(t,e,i,o,n){const r=qi(t,e,i.idAccessor,null!=t.id?t.id+"":"project-"+e)+"",s=o.map(t=>t.id),a=[...qi(t,e,i.positiveAccessor,s)],c=[...qi(t,e,i.negativeAccessor,[])].filter(t=>n.has(t));return{id:r,activePositiveIds:a,datum:t,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...qi(t,e,i.metricsAccessor,{})},missingPositiveIds:s.filter(t=>!a.includes(t)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(qi(t,e,i.startTimeAccessor,0))||0),stage:"project filed",viability:qi(t,e,i.initialViability,100)}}(e,s,r,i,n);return{...a,viability:t.viability?.(a,{negativeProperties:n,positiveProperties:o})??Ui(a,o,n)}}),a=s.flatMap((i,r)=>{const s=function(t,e,i,o){const n=function(t){return{graveyardX:t.graveyardX,graveyardY:t.graveyardY,routeY:t.routeY,socketX:t.socketX,socketY:t.routeY-4,startX:t.startX,startY:t.routeY}}(i),r=o?.(t,e,i)??{};return{...n,...r,startY:r.startY??r.routeY??n.startY,socketY:r.socketY??r.routeY??n.socketY,graveyardY:r.graveyardY??n.graveyardY}}(i,r,e,t.projectPlacement);return function(t,e,i,o,n,r,s){const a=o.startX,c=o.startY+(o.startY===i.routeY?38*e:0),l=s?.(t,e,i,o)??{},u={__gauntlet:!0,kind:"gauntlet-core",projectId:t.id,sourceDatum:t.datum},h=[{...l,id:Gi(t.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??t.startedAt,datum:u}],d=Zi(a,c,l.shape&&"radius"in l.shape&&Number(l.shape.radius)||28,i);h[0].x=d.x,h[0].y=d.y;for(const e of t.activePositiveIds){const o=n.get(e);if(!o)continue;const r=Ki(t.activePositiveIds,e),s=o.radius??10,a=Zi(d.x+Math.cos(r.angle)*r.radius,d.y+Math.sin(r.angle)*r.radius,s,i);h.push({id:Vi(t.id,e),x:a.x,y:a.y,vx:18*Math.cos(r.angle),vy:18*Math.sin(r.angle),mass:o.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:l.spawnAt??t.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:t.id,property:o,sourceDatum:t.datum},springs:!1===o.spring?[]:[{target:{type:"body",bodyId:Gi(t.id)},stiffness:.56,damping:.9,restLength:52+r.index%2*4,...o.spring??{}}]})}return t.negativeIds.forEach((e,o)=>{const n=r.get(e);n&&h.push(function(t,e,i,o,n,r,s){const a=e.radius??7.2,c=Zi(o-12+i%4*12,n+54+12*Math.floor(i/4),a,r);return{id:Hi(t.id,e.id,i),x:c.x,y:c.y,vx:10,vy:6,mass:e.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:s,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:t.id,property:e,sourceDatum:t.datum},springs:!1===e.spring?[]:[{target:{type:"body",bodyId:Gi(t.id)},stiffness:.62,damping:.92,restLength:52+i%4*3,...e.spring??{}}]}}(t,n,o,d.x,d.y,i,l.spawnAt??t.startedAt))}),h}(i,r,e,s,o,n,t.coreBody)});return{layout:e,initialSpawns:a,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:Xi(e)}}}function Ji(t){return t.map(t=>({...t,spawnAt:void 0}))}var to={Sparkline:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"line",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",groupAccessor:n.lineBy||e,colorAccessor:e,...o,showAxes:!1,margin:o.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:j,AreaChart:Y,DifferenceChart:X,StackedAreaChart:q,Scatterplot:G,CandlestickChart:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"candlestick",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.highAccessor||"high",highAccessor:n.highAccessor||"high",lowAccessor:n.lowAccessor||"low",openAccessor:n.openAccessor,closeAccessor:n.closeAccessor,candlestickStyle:n.candlestickStyle,...o})},BubbleChart:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"scatter",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,sizeAccessor:n.sizeBy,sizeRange:n.sizeRange||[5,40],colorScheme:i,...o})},ConnectedScatterplot:H,QuadrantChart:V,Heatmap:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"heatmap",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",valueAccessor:n.valueAccessor,colorScheme:i||n.colorScheme||"blues",showValues:n.showValues,cellBorderColor:n.cellBorderColor,...o})},XYCustomChart:{frameType:"xy",buildProps:(t,e,i,o,n)=>({chartType:"custom",data:t,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:e,colorScheme:i,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...o,showAxes:o.showAxes??!1})},BarChart:tt,StackedBarChart:et,GroupedBarChart:it,PieChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"pie",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"radial",colorAccessor:e||n.categoryAccessor,colorScheme:i,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...o})},DonutChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"donut",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"radial",innerRadius:n.innerRadius||60,colorAccessor:e||n.categoryAccessor,colorScheme:i,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...o})},Histogram:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"histogram",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",projection:"horizontal",bins:n.bins,colorAccessor:e,colorScheme:i,...o})},BoxPlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"boxplot",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorScheme:i,...o})},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"violin",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",bins:n.bins,colorScheme:i,...o})},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"swarm",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorAccessor:e,colorScheme:i,...o})},DotPlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"point",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",colorAccessor:e,colorScheme:i,...o,showGrid:o.showGrid??!0})},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"swimlane",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",stackBy:n.subcategoryAccessor,colorAccessor:e||n.subcategoryAccessor,categoryAccessor:n.categoryAccessor,subcategoryAccessor:n.subcategoryAccessor,colorScheme:i,projection:"horizontal"===n.orientation?"horizontal":"vertical",...o})},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"ridgeline",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",bins:n.bins,amplitude:n.amplitude,...o})},LikertChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"bar",data:t,oAccessor:n.categoryAccessor||"category",rAccessor:n.valueAccessor||"value",stackBy:n.levelAccessor||"level",colorAccessor:e||n.levelAccessor||"level",colorScheme:i,normalize:!0,projection:"vertical"===n.orientation?"vertical":"horizontal",...o})},FunnelChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>{const r="vertical"===n.orientation;return{chartType:r?"bar-funnel":"funnel",data:t,oAccessor:n.stepAccessor||"step",rAccessor:n.valueAccessor||"value",colorAccessor:e||n.categoryAccessor,categoryAccessor:n.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:n.connectorAccessor,connectorStyle:n.connectorStyle,barPadding:r?40:0,showAxes:r,showGrid:r,colorScheme:i,...o}}},GaugeChart:ot,OrdinalCustomChart:{frameType:"ordinal",buildProps:(t,e,i,o,n)=>({chartType:"custom",data:t,oAccessor:n.categoryAccessor||n.oAccessor||"category",rAccessor:n.valueAccessor||n.rAccessor||"value",projection:n.projection||"vertical",colorAccessor:e,colorScheme:i,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...o,showAxes:o.showAxes??!1})},ForceDirectedGraph:wt,NetworkCustomChart:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"force",nodes:n.nodes||t||[],edges:n.edges||[],nodeIDAccessor:n.nodeIdAccessor||n.nodeIDAccessor||"id",sourceAccessor:n.sourceAccessor||"source",targetAccessor:n.targetAccessor||"target",valueAccessor:n.valueAccessor||"value",colorBy:e,colorScheme:i,customNetworkLayout:n.layout||n.customNetworkLayout,layoutConfig:n.layoutConfig,...o})},SankeyDiagram:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"sankey",nodes:n.nodes,edges:n.edges,nodeIDAccessor:n.nodeIdAccessor||n.nodeIDAccessor,sourceAccessor:n.sourceAccessor,targetAccessor:n.targetAccessor,valueAccessor:n.valueAccessor,orientation:n.orientation,nodeAlign:n.nodeAlign,nodeWidth:n.nodeWidth,nodePaddingRatio:n.nodePaddingRatio,showLabels:n.showLabels,nodeLabel:n.nodeLabel,colorBy:e,edgeColorBy:n.edgeColorBy,edgeOpacity:n.edgeOpacity,nodeStyle:n.nodeStyle,edgeStyle:n.edgeStyle,colorScheme:i,...o})},ProcessSankey:kt,ChordDiagram:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"chord",nodes:n.nodes,edges:n.edges,valueAccessor:n.valueAccessor,padAngle:n.padAngle,groupWidth:n.groupWidth,showLabels:n.showLabels,colorBy:e,edgeColorBy:n.edgeColorBy,colorScheme:i,...o})},TreeDiagram:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"cluster"===n.layout?"cluster":"tree",data:t,childrenAccessor:n.childrenAccessor,colorBy:e,colorByDepth:n.colorByDepth,orientation:n.orientation,showLabels:n.showLabels,colorScheme:i,...o})},Treemap:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"treemap",data:t,childrenAccessor:n.childrenAccessor,hierarchySum:n.valueAccessor,colorBy:e,colorByDepth:n.colorByDepth,showLabels:n.showLabels,colorScheme:i,...o})},CirclePack:{frameType:"network",buildProps:(t,e,i,o,n)=>({chartType:"circlepack",data:t,childrenAccessor:n.childrenAccessor,hierarchySum:n.valueAccessor,colorBy:e,colorByDepth:n.colorByDepth,colorScheme:i,...o})},ChoroplethMap:Zt,ProportionalSymbolMap:Kt,FlowMap:Ut,GeoCustomChart:{frameType:"geo",buildProps:(t,e,i,o,n)=>({points:n.points||t||[],areas:n.areas||[],lines:n.lines||[],projection:n.projection||"equirectangular",xAccessor:n.xAccessor||"lon",yAccessor:n.yAccessor||"lat",lineDataAccessor:n.lineDataAccessor,colorBy:e,colorScheme:i,customLayout:n.layout||n.customLayout,layoutConfig:n.layoutConfig,...o})},GaltonBoardChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[600,400],s=n.bins??21,a=n.seed??1,c=Math.max(1,Math.round(n.pegRows??s-1)),l="mechanical"===n.mode,u=l?function(t){const e=Math.max(2,Math.round(t.bins)),i=Math.max(1,Math.round(t.pegRows??e-1)),o=Math.max(1,Math.round(t.count??Math.max(64,4*e))),n=ne(Number.isFinite(t.branchProbability)?t.branchProbability??.5:.5,0,1),r=ae(t.seed??1),s=t.idPrefix??"mechanical";return Array.from({length:o},(t,e)=>{let o=0;for(let t=0;i>t;t+=1)r()<n&&(o+=1);const a=i/2;return{id:`${s}-${e}`,value:o,mechanical:!0,pegRows:i,branchProbability:n,pathRights:o,side:a>o?"left":o>a?"right":"center"}})}({bins:s,branchProbability:n.branchProbability,count:n.mechanicalCount,pegRows:c,seed:a}):Array.isArray(t)?t:[],h=function(t){const{data:e,valueAccessor:i,bins:o,ballRadius:n,seed:r,size:s,valueExtent:a}=t,c=Qt(s),l=e.map((t,e)=>oe(ie(t,e,i))).filter(t=>null!=t),u=function(t){if(!t)return;const e=oe(t[0]),i=oe(t[1]);return null!=e&&null!=i?e>i?[i,e]:[e,i]:void 0}(a),h=u?.[0]??(l.length?Math.min(...l):0),d=u?.[1]??(l.length?Math.max(...l):1),f=d===h?1:d-h,p=ce().domain([0,o]).range([c.plot.x,c.plot.x+c.plot.width]),y=Array.from({length:o},()=>0),g=[];e.forEach((t,e)=>{const r=oe(ie(t,e,i));if(null==r)return;const s=Math.max(0,Math.min(o-1,Math.floor((r-h)/f*o)));y[s]+=1,g.push({id:(t.id??"galton-"+e)+"",x:p(s+.5),y:c.plot.y+n+2,vx:8*(e%5-2),vy:0,mass:1,shape:{type:"circle",radius:n},datum:{...t,value:r,bin:s}})});const m=c.plot.y+c.plot.height;return{config:ee(r,[...oi({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...ni({idPrefix:"galton-bin",count:o,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((t,e)=>({label:e+1+"",value:t})),metadata:{kind:"galton-board",bins:o,plot:c.plot,valueExtent:[h,d]}}}({data:u,valueAccessor:n.valueAccessor||"value",bins:s,ballRadius:n.ballRadius??4,seed:a,size:r,valueExtent:l?[0,c]:void 0});return{...o,config:h.config,initialSpawns:Ji(h.initialSpawns),projectionRows:h.projectionRows,bodyStyle:te(e||n.colorBy||(l?"side":void 0),"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||"value"})}}},EventDropChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[600,400],s=function(t){const{data:e,timeAccessor:i,arrivalAccessor:o,windows:n,watermark:r,ballRadius:s,seed:a,size:c,timeExtent:l,timeScale:u=1}=t,h=Qt(c),d=e.map((t,e)=>oe(ie(t,e,i))).filter(t=>null!=t),f=oe(l?.[0]),p=oe(l?.[1]),y=d.length?Math.min(...d):0,g=d.length?Math.max(...d):y+n.size,m=Math.min(f??y,y),x=Math.max(p??g,g),b=Math.floor(m/n.size)*n.size,v=Math.max(1,Math.ceil((x-b+n.size)/n.size)),w=d.length?Math.max(...d):0,k="function"==typeof r?r(w):oe(r?.value)??w-(r?.delay??n.size),S=Math.max(0,Math.min(v,Array.from({length:v},(t,e)=>e).reduce((t,e)=>b+(e+1)*n.size>k?t:t+1,0))),A=function(t,e){const i=Math.max(5*e,Math.min(92,.13*t.plot.width));return{gutter:{x:t.plot.x,y:t.plot.y,width:i,height:t.plot.height},windowPlot:{x:t.plot.x+i,y:t.plot.y,width:Math.max(40,t.plot.width-i),height:t.plot.height},wallTop:t.plot.y+.48*t.plot.height}}(h,s),M=b+v*n.size,_=Mi().domain([b,M]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),P=Array.from({length:v},()=>({value:0,secondary:0})),R=[];e.forEach((t,e)=>{const r=oe(ie(t,e,i));if(null==r)return;const a=oe(ie(t,e,o))??r,c=Math.max(0,Math.min(v-1,Math.floor((r-b)/n.size))),l=k>=b+(c+1)*n.size;P[c].value+=l?0:1,P[c].secondary+=l?1:0,R.push({id:(t.id??"event-"+e)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,_(r))),y:h.plot.y+s+2,vx:8*(e%3-1),vy:0,mass:1,friction:.02,spawnAt:a,shape:{type:"circle",radius:s},datum:{...t,eventTime:r,arrivalTime:a,windowIndex:c,late:l}})});const T=h.plot.y+h.plot.height,L=function(t,e){const i=Math.max(0,Math.min(t.windowCount,t.closedWindowCount));if(!i)return[];const o=t.windowStart,n=t.windowStart+t.windowCount*t.windowSize,r=Mi().domain([o,n]).range([t.windowPlot.x,t.windowPlot.x+t.windowPlot.width]),s=r(t.windowStart+i*t.windowSize),a=t.windowPlot.x,c=e+Math.max(18,Math.min(.3*t.windowPlot.height,s-a)),l=t=>s===a?e:c+(t-a)/(s-a)*(e-c),u=[];for(let e=0;i>e;e+=1){const i=t.windowStart+e*t.windowSize,o=i+t.windowSize,n=r(i),s=r(o);u.push({id:"eventdrop-lid-"+e,windowIndex:e,x1:n,y1:l(n),x2:s,y2:l(s)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:h.plot,windowCount:v,windowPlot:A.windowPlot,windowSize:n.size,windowStart:b},h.plot.y+.28*h.plot.height);return{config:ee(a,[...oi({x:h.plot.x,y:h.plot.y,width:h.plot.width,height:h.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),..._i({idPrefix:"eventdrop-window",count:v,xScale:t=>_(b+t*n.size),yTop:A.wallTop,yTopForIndex:t=>{const e=(t=>{if(0>t||t>S)return null;const e=0===t?L[0]?.y1:L[t-1]?.y2??L[t]?.y1;return"number"==typeof e&&Number.isFinite(e)?e:null})(t);return null==e?A.wallTop:e+1.25*s},yBottom:T,wallThickness:6}),...L.map(t=>({id:t.id,shape:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:R,initialSpawnPacing:{pacing:"arrival",timeAccessor:t=>t.datum?.arrivalTime,timeScale:u},projectionRows:P.map((t,e)=>({label:`${b+e*n.size}-${b+(e+1)*n.size}`,value:t.value,secondary:t.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:L,lateCount:P.reduce((t,e)=>t+e.secondary,0),plot:h.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:v,windowSize:n.size,windowStart:b}}}({data:Array.isArray(t)?t:[],timeAccessor:n.timeAccessor||"time",arrivalAccessor:n.arrivalAccessor||"arrivalTime",windows:n.windows||{size:10},watermark:n.watermark,ballRadius:n.ballRadius??5,seed:n.seed??1,size:r,timeExtent:n.timeExtent,timeScale:n.timeScale??1});return{...o,config:s.config,initialSpawns:Ji(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:te(e||n.colorBy,"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||n.timeAccessor||"time"})}}},PhysicsPileChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[600,400],s="mechanical"===n.mode,a=function(t){const{data:e,categoryAccessor:i,valueAccessor:o,unitValue:n,ballRadius:r,seed:s,size:a}=t,c=re(n,1),l=Qt(a),u=[],h=new Map,d=new Map,f=[];function p(t){let e=h.get(t);return null==e&&(e=u.length,u.push(t),h.set(t,e)),e}e.forEach((t,e)=>{p((ie(t,e,i)??"unknown")+"")});const y=Math.max(1,u.length),g=function(t,e,i){const o=t.width/Math.max(1,e),n=Math.max(2,2*i),r=Math.min(.7*o,Math.max(3.2*n,n+8)),s=Math.max(1,Math.floor(r/n));return{laneWidth:o,tubeWidth:r,ballDiameter:n,perRow:s,centerX:e=>t.x+(e+.5)*o,pileHeight:t=>Math.ceil(Math.max(0,t)/s)*n}}(l.plot,y,r),m=Math.max(0,g.tubeWidth/2-r-1),x=u.map(()=>[]);e.forEach((t,e)=>{const n=(ie(t,e,i)??"unknown")+"",s=p(n),a=o?oe(ie(t,e,o)):1,u=Math.max(0,Math.round((a??0)/c)),h=g.centerX(s);for(let i=0;u>i;i+=1){const o=d.get(n)??0,a=g.perRow>1?((g.perRow>1?o%g.perRow:0)/(g.perRow-1)*2-1)*m:0;d.set(n,o+1),x[s].push({id:`${(t.id??"pile-"+e)+""}-${i}`,x:h+a,y:l.plot.y+r+2,vx:(i%3-1)*r/2,vy:0,mass:1,shape:{type:"circle",radius:r},datum:{...t,category:n,unitIndex:i}})}});const b=x.reduce((t,e)=>Math.max(t,e.length),0);for(let t=0;b>t;t+=1)for(const e of x)e.length>t&&f.push(e[t]);const v=l.plot.y+l.plot.height,w=[...oi({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 t=0;y>t;t+=1){const e=g.centerX(t);for(const i of[-1,1])w.push({id:`pile-tube-${t}-${0>i?"l":"r"}`,shape:{type:"aabb",x:e+i*g.tubeWidth/2,y:(k+v)/2,width:6,height:v-k}})}return{config:ee(s,w,"PhysicsPileChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(t=>({label:t,value:d.get(t)??0}))}}({data:s?function(t={}){const e=(t.categories?.length?t.categories:["Intake","Review","Build","Ship"]).map(t=>(t+"").trim()).filter(Boolean),i=e.length?e:["Intake"],o=Math.max(i.length,Math.round(t.count??Math.max(48,12*i.length))),n=re(t.unitValue,1),r=ae(t.seed??1),s=t.idPrefix??"mechanical-pile",a=i.map(()=>.65+.9*r()),c=a.reduce((t,e)=>t+e,0)||1,l=o-i.length,u=a.map(t=>t/c*l),h=u.map(t=>1+Math.floor(t));let d=o-h.reduce((t,e)=>t+e,0);const f=u.map((t,e)=>({index:e,fraction:t-Math.floor(t)})).sort((t,e)=>e.fraction-t.fraction);for(let t=0;d>0;t=(t+1)%f.length)h[f[t].index]+=1,d-=1;return i.map((t,e)=>({id:`${s}-${e}`,category:t,value:h[e]*n,mechanical:!0,unitCount:h[e],unitValue:n,share:h[e]/o}))}({categories:n.mechanicalCategories,count:n.mechanicalCount,seed:n.seed??1,unitValue:n.unitValue??1}):Array.isArray(t)?t:[],categoryAccessor:n.categoryAccessor||"category",valueAccessor:n.valueAccessor||(s?"value":void 0),unitValue:n.unitValue??1,ballRadius:n.ballRadius??5,seed:n.seed??1,size:r});return{...o,config:a.config,initialSpawns:Ji(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:te(e||n.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||"value"})}}},CollisionSwarmChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[600,360],s=function(t){const{data:e,xAccessor:i,groupAccessor:o,radiusAccessor:n,pointRadius:r,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=t,h=Qt(a),d=ae(s),f=[],p=[],y=new Map;e.forEach((t,e)=>{const s=oe(ie(t,e,i));if(null==s)return;const a=o?(ie(t,e,o)??"All")+"":"All",c=n?oe(ie(t,e,n)):null,l=ne(null!=c&&c>0?c:r,2,18);!function(t){let e=y.get(t);null==e&&(e=p.length,p.push(t),y.set(t,e))}(a),f.push({datum:t,index:e,value:s,group:a,radius:l})});const g=f.map(t=>t.value),m=c?oe(c[0]):null,x=c?oe(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 t=k;k=w,w=t}const S=Math.max(r,...f.map(t=>t.radius)),A=h.plot.x+S+8,M=h.plot.x+h.plot.width-S-8,_=Pi().domain([w,k]).range([A,M]),P=Math.max(1,p.length),R=h.plot.y+Math.max(28,3*S),T=Math.max(0,h.plot.y+h.plot.height-Math.max(28,3*S)-R),L=t=>{const e=y.get(t)??0;return 1===P?h.plot.y+.54*h.plot.height:R+e/(P-1)*T},C=new Map,$=f.map((t,e)=>{C.set(t.group,(C.get(t.group)??0)+1);const i=_(t.value),o=L(t.group),n=(d()-.5)*t.radius*1.6,r=(d()-.5)*t.radius*1.6;return{id:(t.datum.id??"collision-swarm-"+e)+"",x:u?i+n:ne(i+(e%9-4)*t.radius*2.5,A,M),y:u?o+r:h.plot.y-18-e%12*t.radius,vx:u?0:22*(d()-.5),vy:u?0:24+18*d(),mass:1,shape:{type:"circle",radius:t.radius},datum:{...t.datum,xValue:t.value,group:t.group,radius:t.radius,targetX:i,targetY:o},springs:[{target:{type:"point",x:i,y:o},restLength:0,stiffness:34,damping:5.5}]}});return{config:ee(s,oi({x:h.plot.x,y:h.plot.y,width:h.plot.width,height:h.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:$,projectionRows:p.map(t=>({label:t,value:C.get(t)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,M],groups:p.map(t=>({label:t,y:L(t),count:C.get(t)??0})),plot:h.plot}}}({data:Array.isArray(t)?t:[],xAccessor:n.xAccessor||"x",groupAccessor:n.groupAccessor,radiusAccessor:n.radiusAccessor,pointRadius:n.pointRadius??5,seed:n.seed??1,size:r,xExtent:n.xExtent,collisionIterations:n.collisionIterations,settle:n.settle});return{...o,config:s.config,initialSpawns:Ji(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:te(e||n.colorBy||n.groupAccessor,"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.xAccessor||"x"})}}},ProcessFlowChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[900,420],s=Array.isArray(n.stages)?n.stages:[],a=Fi({data:Array.isArray(t)?t:[],stages:s,size:r,idAccessor:n.idAccessor,stageAccessor:n.stageAccessor||"stage",groupBy:n.groupBy,groupLabelAccessor:n.groupLabelAccessor,workAccessor:n.workAccessor,radiusAccessor:n.radiusAccessor,ballRadius:n.ballRadius??6,seed:n.seed??1,groupCompletion:n.groupCompletion,groupAnchorAlong:n.groupAnchorAlong,settle:n.settle??!0,gravityX:n.gravityX,gravityY:n.gravityY}),c=a.metadata;return{...o,config:a.config,initialSpawns:Ji(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,bodyStyle:te(e||n.colorBy||n.groupBy)}}},GauntletChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[900,520],s=Qi({data:Array.isArray(t)?t:[],size:r,gates:n.gates,positiveProperties:n.positiveProperties,negativeProperties:n.negativeProperties,crashOffset:n.crashOffset,idAccessor:n.idAccessor,positiveAccessor:n.positiveAccessor,negativeAccessor:n.negativeAccessor,metricsAccessor:n.metricsAccessor,initialViability:n.initialViability,projectPlacement:n.projectPlacement,coreBody:n.coreBody,viability:n.viability});return{...o,config:s.config,initialSpawns:Ji(s.initialSpawns),projectionRows:[],bodyStyle:te(e||n.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[760,420],s=function(t){const{coordinateMode:e,flowSpeed:i,links:o,maxParticles:n,nodeIdAccessor:r,nodeXAccessor:s,nodeYAccessor:a,nodes:c,particleRadius:l,particleRate:u,pathAccessor:h,pathConstraint:d="path",reducedMotion:f,seed:p,size:y,sourceAccessor:g,targetAccessor:m,throughputAccessor:x}=t,b=Qt(y),v=ae(p),w=new Map,k=new Map,S=[];function A(t){if(t&&"object"==typeof t){const e=t;if("function"==typeof r){const t=r(e,0);if(null!=t)return t+""}if("string"==typeof r&&null!=e[r])return e[r]+"";if(null!=e.id)return e.id+""}return(t??"unknown")+""}c.forEach((t,e)=>{const i=(ie(t,e,r)??t.id??e)+"",o=oe(ie(t,e,s)),n=oe(ie(t,e,a));if(null!=o&&null!=n){const t={x:o,y:n};w.set(i,t),S.push(t)}k.set(i,(t.label??t.name??i)+"")});const M=[];o.forEach((t,e)=>{const i=A(ie(t,e,g)),o=A(ie(t,e,m)),n=Math.max(0,oe(ie(t,e,x))??0),r=Ti(h?ie(t,e,h):void 0),s=r.length?r:Ti(t.path??t.points??t.route);s.forEach(t=>S.push(t)),M.push({id:(t.id??`physical-flow-${i}-${o}-${e}`)+"",link:t,index:e,source:i,target:o,throughput:n,rawPath:s})});const _=(R=S,"normalized"===(P=e)||"pixels"===P?P:R.length>0&&R.every(t=>!(0>t.x||t.x>1||0>t.y||t.y>1))?"normalized":"pixels");var P,R;const T=new Map;for(const[t,e]of w)T.set(t,Li(e,b,_));const L=[];for(const t of M){let e=t.rawPath.map(t=>Li(t,b,_));if(2>e.length){const i=T.get(t.source),o=T.get(t.target);i&&o&&(e=[i,o])}else T.has(t.source)||T.set(t.source,e[0]),T.has(t.target)||T.set(t.target,e[e.length-1]);e.length>=2&&t.throughput>0&&(k.has(t.source)||k.set(t.source,t.source),k.has(t.target)||k.set(t.target,t.target),L.push({...t,path:e,packetCount:0}))}const C=re(u,.12),$=Math.max(1,Math.round(n)),z=L.map(t=>Math.max(1,Math.round(t.throughput*C))),D=z.reduce((t,e)=>t+e,0),E=D>$?$/D:1;L.forEach((t,e)=>{t.packetCount=Math.max(1,Math.floor(z[e]*E))});let N=L.reduce((t,e)=>t+e.packetCount,0);for(;N>$;){const t=L.reduce((t,e,i)=>e.packetCount>1&&(-1===t||e.packetCount>L[t].packetCount)?i:t,-1);if(-1===t)break;L[t].packetCount-=1,N-=1}const I=new Map,B=new Map,F=[],O=re(i,90),W=re(l,4);L.forEach((t,e)=>{I.set(t.target,(I.get(t.target)??0)+t.throughput),B.set(t.source,(B.get(t.source)??0)+t.throughput);const i=Ci(t.path);for(let o=0;t.packetCount>o;o+=1){const n=(o+.5)/t.packetCount,r=f?n:ne(.12+.84*n+.04*(v()-.5),.04,.98),s=f?r:Math.max(0,r-(.18+.12*v())),a=$i(t.path,s),c=$i(t.path,r),l=zi(t.path,s),u={x:-l.y,y:l.x},h=(v()-.5)*W*1.5;F.push({id:`${t.id}-packet-${o}`,x:a.x+u.x*h,y:a.y+u.y*h,vx:f?0:l.x*O+10*(v()-.5),vy:f?0:l.y*O+10*(v()-.5),mass:.8,spawnAt:f?0:.04*e+o/32,shape:{type:"circle",radius:W},datum:{...t.link,source:t.source,target:t.target,throughput:t.throughput,packetIndex:o,packetCount:t.packetCount,routeProgress:r,flowPath:t.path,flowPathLength:i,flowRouteId:t.id,flowSpeed:O,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target},springs:"none"!==d&&f?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*W,stiffness:26,damping:4.25}]:void 0})}});const j=Math.max(18,5*W),Y=Array.from(T,([t,e])=>({nodeId:t,label:k.get(t)??t,sensorId:"physical-flow-node-"+se(t),point:e})),X=Y.map(t=>({id:t.sensorId,sensor:!0,shape:{type:"aabb",x:t.point.x,y:t.point.y,width:j,height:j}})),q=Object.fromEntries(Y.map(t=>[t.sensorId,{binId:t.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),G=ee(p,[...oi({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...X],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*W),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});G.bodyLimit=$,G.eviction="oldest",G.observation={...G.observation,sensors:q};const V=Array.from(T,([t,e])=>({id:t,label:k.get(t)??t,x:e.x,y:e.y,sensorId:"physical-flow-node-"+se(t),incoming:I.get(t)??0,outgoing:B.get(t)??0})),H=L.map(t=>({id:t.id,source:t.source,target:t.target,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target,throughput:t.throughput,packetCount:t.packetCount,path:t.path}));return{config:G,initialSpawns:F,projectionRows:V.filter(t=>t.incoming>0||t.outgoing>0).map(t=>({label:t.label,value:t.incoming,secondary:t.outgoing})),metadata:{kind:"physical-flow",coordinateMode:_,particleCount:F.length,totalThroughput:L.reduce((t,e)=>t+e.throughput,0),plot:b.plot,nodes:V,links:H}}}({nodes:Array.isArray(n.nodes)?n.nodes:[],links:Array.isArray(n.links)?n.links:Array.isArray(n.edges)?n.edges:Array.isArray(t)?t:[],nodeIdAccessor:n.nodeIdAccessor||"id",nodeXAccessor:n.nodeXAccessor||"x",nodeYAccessor:n.nodeYAccessor||"y",sourceAccessor:n.sourceAccessor||"source",targetAccessor:n.targetAccessor||"target",throughputAccessor:n.throughputAccessor||"value",pathAccessor:n.pathAccessor||"path",coordinateMode:n.coordinateMode||"auto",particleRate:n.particleRate??.16,maxParticles:n.maxParticles??180,particleRadius:n.particleRadius??4,flowSpeed:n.flowSpeed??90,pathConstraint:n.pathConstraint||"path",reducedMotion:!0,seed:n.seed??1,size:r});return{...o,config:s.config,initialSpawns:Ji(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:te(e||n.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(t,e,i,o,n)=>{const r=o.size??[700,380],a=function(t){const e=function(t,e,i){const o=t?.observation;return{...t,observation:{...o,chartId:e??o?.chartId??"physics-custom",chartType:o?.chartType??"PhysicsCustomChart",onObservation:i??o?.onObservation}}}(t.config,t.chartId,t.onObservation),i=Wi(t.colorScheme,t.themeCategorical,s),o=Qt(t.size),n={data:t.data,scales:{x:Oi().domain(t.xExtent??[0,1]).range([o.plot.x,o.plot.x+o.plot.width]),y:Oi().domain(t.yExtent??[0,1]).range([o.plot.y+o.plot.height,o.plot.y])},dimensions:o,theme:{semantic:t.semantic,categorical:[...i]},resolveColor:ji(i,t.colorScheme),config:t.layoutConfig??{},world:new Ai(e)},r=t.skipLayout?{}:t.layout(n)??{},a=function(t,e){if(!e?.length)return t;const i=new Map;for(const t of e){const{bodyId:e,...o}=t,n=i.get(e)??[];n.push(o),i.set(e,n)}return t.map(t=>{const e=i.get(t.id);return e?.length?{...t,springs:[...t.springs??[],...e]}:t})}([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:Yi(e,r),context:n,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:a,result:r}}({chartId:n.chartId,colorScheme:i,config:n.config,data:Array.isArray(t)?t:[],layout:n.layout,layoutConfig:n.layoutConfig,semantic:It(Ot)??{},size:r,themeCategorical:Ot.colors.categorical,xExtent:n.xExtent,yExtent:n.yExtent});return{...o,config:a.config,initialSpawns:Ji(a.initialSpawns),projectionRows:[],bodyStyle:a.result.bodyStyle??te(e||n.colorBy)}}}};function eo(t){if(!t)return Ot;if("string"==typeof t){if("light"===t)return Ot;if("dark"===t)return Wt;if("high-contrast"===t)return jt;return Gt[t]||Ot}const e="dark"===t.mode?Wt:Ot;return Bt({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}},tooltip:{...e.tooltip,...t.tooltip||{}}})}function io(t){return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:t.colors.annotation??t.colors.text,legendSize:t.typography.legendSize??t.typography.labelSize,titleFontSize:t.typography.titleFontSize??t.typography.titleSize,tickFontFamily:t.typography.tickFontFamily??t.typography.fontFamily}}function oo(t){const e=t instanceof Date?t.getTime():"number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function no(t){if(!t||2>t.length)return;const e=oo(t[0]),i=oo(t[t.length-1]);return null!==e&&null!==i?[e,i]:void 0}function ro(t){const{count:e,byType:i}=function(t){const e={};for(const i of t){const t="string"==typeof i?.type&&i.type.length>0?i.type:"node";e[t]=(e[t]??0)+1}return{count:t.length,byType:e}}(t.marks),o=0===e,n=[...t.extraWarnings??[]];return o&&!n.includes("EMPTY_SCENE")&&n.push("EMPTY_SCENE"),{component:"",frameType:t.frameType,status:o?"empty":"ok",empty:o,markCount:e,markCountByType:i,width:t.width,height:t.height,...t.xDomain?{xDomain:t.xDomain}:{},...t.yDomain?{yDomain:t.yDomain}:{},...t.categories?{categories:t.categories}:{},...void 0!==t.nodeCount?{nodeCount:t.nodeCount}:{},...void 0!==t.edgeCount?{edgeCount:t.edgeCount}:{},...void 0!==t.legendItems?{legendItems:t.legendItems}:{},annotationCount:Array.isArray(t.annotations)?t.annotations.length:0,ariaLabel:"string"==typeof t.description&&t.description||"string"==typeof t.title&&t.title||`${t.frameType} chart, ${e} marks`,warnings:n}}function so(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function ao(t){return"object"==typeof t&&null!==t&&"gradient"in t}var co=Object.freeze([]);function lo(t){if(!t)return co;let e=!1;for(let i=0;t.length>i;i++){const o=t[i];if(null==o||"object"!=typeof o){e=!0;break}}if(!e)return t;const i=[];for(const e of t)null!=e&&"object"==typeof e&&i.push(e);return i}import*as uo from"react";import*as ho from"react-dom/server";var fo=class{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const i of t){const t=this.push(i);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+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 t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray();let i=0,o=[];e.length>t&&(i=e.length-t,o=e.slice(0,i)),this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(let t=i;e.length>t;t++)this.push(e[t]);return o}update(t,e){const i=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++){const r=(o+n)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},i.push(t),this.buffer[r]=e(s)}}return i}remove(t){const e=[],i=[];if(this.forEach(o=>{t(o)?i.push(o):e.push(o)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return i}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}},po=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const i of t){const t=e?e(i):i;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}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 yo(t,e){return t===e}function go(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function mo(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function xo(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}var bo=/^\d{4}-\d{1,2}$/;function vo(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const i=bo.test(e)?e+"-01":e;if(i===e&&10>e.length)return NaN;const o=Date.parse(i);return Number.isFinite(o)?o:NaN}function wo(t){return t instanceof Date?t.getTime():"string"==typeof t?vo(t):+t}function ko(t){return new Set(Array.isArray(t)?t:[t])}function So(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function Ao(t,e){return Math.min((t-e.startTime)/e.duration,1)}function Mo(t,e,i){return t+(e-t)*i}function _o(){return"undefined"!=typeof performance?performance.now():Date.now()}function Po(t,e,i){if(1>=i)return 1;const o=i-1;return function(t){const e=Math.max(0,Math.min(1,t.minOpacity??.1));if(Number.isNaN(t.age))return 1;if(t.age===1/0)return e;if(!Number.isFinite(t.extent)||0>=t.extent)return 1;const i=Math.max(0,t.age);if("step"===t.type)return(t.threshold??.5*t.extent)>i?1:e;if("exponential"===t.type){const o=t.halfLife??t.extent/2;return e+Math.pow(.5,i/(o>0?o:t.extent/2))*(1-e)}return e+Math.max(0,Math.min(1,1-i/t.extent))*(1-e)}({age:o-e,extent:o,type:t.type,halfLife:t.halfLife??i/2,threshold:t.stepThreshold??.5*i,minOpacity:t.minOpacity??.1})}function Ro(t){const e=new Map;for(let i=0;t.length>i;i++)e.set(t[i],i);return e}function To(t,e,i){const o=t.duration??500,n=i-e;return o>n?1-n/o:0}function Lo(t,e,i,o){let n=!1;return e>0?(t._pulseIntensity!==e&&(t._pulseIntensity=e,n=!0),t._pulseColor!==i&&(t._pulseColor=i,n=!0),t._pulseGlowRadius!==o&&(t._pulseGlowRadius=o,n=!0),n):(0!==t._pulseIntensity&&(t._pulseIntensity=0,n=!0),void 0!==t._pulseColor&&(t._pulseColor=void 0,n=!0),void 0!==t._pulseGlowRadius&&(t._pulseGlowRadius=void 0,n=!0),n)}function Co(t,e,i=("undefined"!=typeof performance?performance.now():Date.now())){if(!e||0===e.size)return!1;const o=t.duration??500,n=e.peek();return null!=n&&o>i-n}function $o(t,e,i){if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${o}`;if(null!=i&&null!=o)return`p:${i}:${o}`}return"p:"+i;case"glyph":return e.pointId?"g:"+e.pointId:"g:"+i;case"rect":return`r:${e.group||""}:${e.datum?.binStart??e.datum?.category??i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function zo(t,e,i,o,n,r){const s=[];for(const n of t){const t=i(n),r=o(n);Number.isFinite(t)&&Number.isFinite(r)&&s.push({px:e.x(t),py:e.y(r),rawY:r,d:n})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:n,datum:l,group:r}}function Do(t,e,i,o,n,r,s,a){const c=[];for(const r of t){const t=i(r),s=o(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const l=e.x(t),u=a?a(r):n;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:r,datum:t,group:s}}function Eo(t,e,i,o){const n=new Map;if("silhouette"===o)for(const o of t){let t=0;for(const n of e)t+=i(n,o)||0;n.set(o,-t/2)}else if("wiggle"===o){t.length>0&&n.set(t[0],0);for(let o=1;t.length>o;o++){const r=t[o-1],s=t[o];let a=0,c=0,l=0;for(const t of e){const e=i(t,s)||0;a+=(2*l+e)*(e-(i(t,r)||0)),c+=e,l+=e}const u=n.get(r)??0;n.set(s,u-(c>0?a/(2*c):0))}if(t.length>0){let o=0;for(const r of t){let t=0;for(const o of e)t+=i(o,r)||0;o+=(n.get(r)??0)+t/2}const r=o/t.length;for(const e of t)n.set(e,(n.get(e)??0)-r)}}else for(const e of t)n.set(e,0);return n}function No(t,e,i,o,n,r,s){const a=i(t),c=o(t);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:n,style:r,datum:t};return void 0!==s&&(l.pointId=s),l}function Io(t,e,i,o,n,r,s,a){const c=i(t),l=o(t);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:e.x(c),y:e.y(l),size:n,symbolType:r,style:s,datum:t};return void 0!==a&&(u.pointId=a),u}function Bo(t,e,i,o,n,r,s){return{type:"rect",x:t,y:e,w:i,h:o,style:n,datum:r,group:s}}function Fo(t,e,i,o,n,r,s){const a={type:"heatcell",x:t,y:e,w:i,h:o,fill:n,datum:r};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Oo(t,e,i,o){return"function"==typeof e.style?e.style(o||{},i):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(i,o)}function Wo(t,e,i,o){if(!t.scales)return null;const n=[],r=[];for(const i of e){const e=t.getX(i);if(!Number.isFinite(e))continue;const s=o.getTop(i),a=o.getBottom(i);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=t.scales.x(e),l=t.scales.y(s),u=t.scales.y(a);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(n.push([c,l]),r.push([c,u]))}return 2>n.length?null:{type:"area",topPath:n,bottomPath:r,style:Oo(t,o,i,e[0]),datum:e,group:i,interactive:o.interactive}}function jo(t){const e=[],i=[];if(!t)return{perSeries:e,aggregate:i};for(const o of t)o.perSeries?e.push(o):i.push(o);return{perSeries:e,aggregate:i}}function Yo(t,e,i){const o=[];for(const n of i){const i=Wo(t,e,"__ribbon_aggregate",n);i&&o.push(i)}return o}function Xo(t,e,i,o){const n=[];for(const r of o){const o=Wo(t,e,i,r);o&&n.push(o)}return n}function qo(t,e,i,o){if(!t.config.pointStyle)return;const n=o??t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const r of o.data){let o=t.config.pointStyle(r);!o.fill&&e&&(o={...o,fill:e});const s=o.r??3,a=t.getPointId?t.getPointId(r)+"":void 0,c=No(r,t.scales,t.getX,n,s,o,a);c&&i.push(c)}}}function Go(t){return"threshold"===t.type&&"string"==typeof t.color&&"number"==typeof t.value}var Vo={topOpacity:.8,bottomOpacity:.05};function Ho(t){if(t)return!0===t?Vo:"colorStops"in t?t:{topOpacity:t.topOpacity??Vo.topOpacity,bottomOpacity:t.bottomOpacity??Vo.bottomOpacity}}import{symbol as Zo,symbolCircle as Ko,symbolCross as Uo,symbolDiamond as Qo,symbolSquare as Jo,symbolStar as tn,symbolTriangle as en,symbolWye as on}from"d3-shape";var nn={circle:Ko,square:Jo,triangle:en,diamond:Qo,star:tn,cross:Uo,wye:on},rn=["circle","triangle","diamond","star","square","chevron","cross","wye"];function sn(t,e,i){if(i)return i;const o=t??"circle";return"chevron"===o?function(t){const e=1.5*function(t){return Math.sqrt(Math.max(1,t)/Math.PI)}(t),i=.92*e;return`M0,${-e}L${i},${(.78*e).toFixed(3)}L0,${(.28*e).toFixed(3)}L${-i},${(.78*e).toFixed(3)}Z`}(e):Zo(nn[o]??Ko,Math.max(1,e))()??""}var an=new Map;function cn(t,e,i,o,n){const r=new Map;for(const s of t){const t=e(s),a=i(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/o)*o;let l=r.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},r.set(c,l)),l.total+=a,n){const t=n(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return r}function ln(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:i,overlays:o,warned:n}=t;un(o)&&0===i.length&&hn(n,"overlay-only",`[semiotic] ${e} 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.`),i.length>0&&i.every(t=>null==t.datum)&&hn(n,"null-datums",`[semiotic] ${e} 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 un(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(un))}function hn(t,e,i){t.has(e)||(t.add(e),console.warn(i))}function dn(t,e,i,o){const n=function(t){if(t instanceof Error)return{name:t.name||"Error",message:t.message||"Custom layout threw."};if("string"==typeof t)return{name:"Error",message:t};if(null==t)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:t+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(e),r="network"===t?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:t,source:r,message:`Semiotic ${t} ${r} failed: ${n.message}`,error:n,recovery:i?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:i,affectedRevision:o}}function fn(t,e){const i="function"==typeof t?t:i=>i[t||e];return t=>{const e=i(t);return null==e?NaN:+e}}function pn(t){const e=[],i=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,o=fn(i&&t.valueAccessor||t.yAccessor,i?"value":"y");if(t.boundsAccessor){const i=go(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const n=i(t);return Number.isFinite(n)&&0!==n?e+n:e},getBottom:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const n=i(t);return Number.isFinite(n)&&0!==n?e-n:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const i=Array.isArray(t.band)?t.band:[t.band];for(const t of i)e.push({kind:"band",getTop:fn(t.y1Accessor,"y1"),getBottom:fn(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}import{scaleLinear as yn,scaleLog as gn,scaleSymlog as mn,scaleTime as xn}from"d3-scale";function bn(t,e){return e?[e[0]??t[0],e[1]??t[1]]:t}function vn(t,e,i){if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return gn().domain(t).range(i).clamp(!0)}return"symlog"===t?mn().domain(e).range(i):"time"===t?xn().domain([new Date(e[0]),new Date(e[1])]).range(i):yn().domain(e).range(i)}function wn(t,e,i){e>t.capacity&&(t.resize(e),i&&e>i.capacity&&i.resize(e))}function kn(t,e){const i=new fo(t.capacity);return t.forEach(()=>i.push(e)),i}function Sn(t,e,i,o){const n=t.push(e);return i&&i.push(o),n}function An(t,e,i){if(!e||0===e.size)return;const o=new Set;if(t.forEach((t,e)=>{i(t)&&o.add(e)}),0===o.size)return;const n=e.toArray();e.clear();for(let t=0;n.length>t;t++)o.has(t)||e.push(n[t])}var Mn=new WeakMap;function _n(){return this.updateResults.last}function Pn(){return this.updateResults.last}function Rn(t){return this.updateResults.subscribe(t)}function Tn(t){this.config.layoutSelection=t}function Ln(){Mn.set(this,!0)}function Cn(){const t=!0===Mn.get(this);return Mn.delete(this),t}function $n(t){Object.assign(t.prototype,{getLastUpdateResult:_n,getUpdateSnapshot:Pn,subscribeUpdateResult:Rn,setLayoutSelection:Tn,markStylePaintPending:Ln,consumeStylePaintPending:Cn})}var zn=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Dn=["scene-style","data-paint","accessibility","evidence"],En=(t,e)=>({retainedData:t,invalidations:e}),Nn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],In=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Bn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Fn=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],On=["scene-geometry","data-paint","accessibility","evidence"],Wn=["scene-style","data-paint","accessibility","evidence"],jn=[],Yn={chartType:En("rebuild",Nn),runtimeMode:En("rebuild",Nn),xAccessor:En("rebuild",Nn),yAccessor:En("rebuild",Nn),timeAccessor:En("rebuild",Nn),valueAccessor:En("rebuild",Nn),y0Accessor:En("rebuild",Nn),boundsAccessor:En("rebuild",Nn),band:En("rebuild",Nn),openAccessor:En("rebuild",Nn),highAccessor:En("rebuild",Nn),lowAccessor:En("rebuild",Nn),closeAccessor:En("rebuild",Nn),candlestickRangeMode:En("rebuild",Nn),accessorRevision:En("rebuild",Nn),groupAccessor:En("rebuild",In),categoryAccessor:En("rebuild",In),lineDataAccessor:En("rebuild",In),colorAccessor:En("rebuild",Wn),sizeAccessor:En("rebuild",On),symbolAccessor:En("rebuild",On),pointIdAccessor:En("rebuild",On),xScaleType:En("preserve",Bn),yScaleType:En("preserve",Bn),xExtent:En("preserve",Bn),yExtent:En("preserve",Bn),extentPadding:En("preserve",Bn),scalePadding:En("preserve",Bn),axisExtent:En("preserve",Bn),binSize:En("preserve",Bn),normalize:En("preserve",Bn),heatmapAggregation:En("preserve",Bn),heatmapXBins:En("preserve",Bn),heatmapYBins:En("preserve",Bn),arrowOfTime:En("preserve",Fn),baseline:En("preserve",Fn),stackOrder:En("preserve",Fn),sizeRange:En("preserve",Fn),curve:En("preserve",Fn),areaGroups:En("preserve",Fn),customLayout:En("preserve",Fn),layoutConfig:En("preserve",Fn),layoutMargin:En("preserve",Fn),symbolMap:En("preserve",On),showValues:En("preserve",On),heatmapValueFormat:En("preserve",On),lineStyle:En("preserve",Wn),pointStyle:En("preserve",Wn),areaStyle:En("preserve",Wn),barStyle:En("preserve",Wn),swarmStyle:En("preserve",Wn),waterfallStyle:En("preserve",Wn),candlestickStyle:En("preserve",Wn),boundsStyle:En("preserve",Wn),gradientFill:En("preserve",Wn),lineGradient:En("preserve",Wn),colorScheme:En("preserve",Wn),themeCategorical:En("preserve",Wn),themeSemantic:En("preserve",Wn),themeSequential:En("preserve",Wn),themeDiverging:En("preserve",Wn),barColors:En("preserve",Wn),decay:En("preserve",Wn),pulse:En("preserve",Wn),staleness:En("preserve",Wn),layoutSelection:En("preserve",Wn),annotations:En("preserve",["overlay","accessibility","evidence"]),windowSize:En("preserve",jn),windowMode:En("preserve",jn),maxCapacity:En("preserve",jn),clock:En("preserve",jn),transition:En("preserve",jn),introAnimation:En("preserve",jn),onLayoutError:En("preserve",jn)},Xn=En("preserve",Fn),qn=class{constructor(){this.tracker=new ci}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},zn)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Dn):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const i=new Set;for(const o of t){const t=Yn[o]??Xn;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}};import{quadtree as Gn}from"d3-quadtree";var Vn=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(t,e){if("scatter"!==t&&"bubble"!==t&&"custom"!==t)return void this.clear();let i=0,o=0;for(const t of e)"point"===t.type&&(i++,t.r>o&&(o=t.r));if(this.maxRadius=o,500>=i)return void(this.tree=null);const n=Array(i);let r=0;for(const t of e)"point"===t.type&&(n[r++]=t);this.tree=Gn().x(t=>t.x).y(t=>t.y).addAll(n)}},Hn=class t{constructor(t){if(this.xExtent=new po,this.yExtent=new po,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 qn,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 Vn,this._lastBoundedInsertsRef=null,this.applyPulse=(t,e,i)=>!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,i,o,n,r=("undefined"!=typeof performance?performance.now():Date.now())){const s=t.color??"rgba(255,255,255,0.6)",a=t.glowRadius??4;let c=!1;const l=n??(()=>{const t=new Map;for(let e=0;i.length>e;e++)t.set(i[e],e);return t})();for(const i of e){if("line"===i.type)continue;if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[i.datum];let n=0,a=!1;for(const i of e){const e=l.get(i);if(null==e)continue;a=!0;const s=o.get(e);if(null==s)continue;const c=To(t,s,r);c>n&&(n=c)}a&&(c=Lo(i,n,s)||c);continue}const e=l.get(i.datum);if(null==e)continue;const n=o.get(e);c=Lo(i,null==n?0:To(t,n,r),s,a)||c}return c}(this.config.pulse,t,e,this.timestampBuffer,this.getDatumIndexMap(e),i),this.config=t,this.buffer=new fo(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=go(t.timeAccessor||t.xAccessor,"time"),this.getY=go(t.valueAccessor||t.yAccessor,"value")):(this.getX=go(t.xAccessor,"x"),this.getY=go(t.yAccessor,"y")),this.getGroup=xo(t.groupAccessor),this.getCategory=xo(t.categoryAccessor),this.getSize=t.sizeAccessor?go(t.sizeAccessor,"size"):void 0,this.getColor=xo(t.colorAccessor),this.getSymbol=xo(t.symbolAccessor),this.getY0=t.y0Accessor?go(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=pn(t),this.getPointId=xo(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?go(t.openAccessor,"open"):void 0,this.getHigh=go(t.highAccessor,"high"),this.getLow=go(t.lowAccessor,"low"),this.getClose=i?go(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new fo(t.windowSize))}currentTime(){return this.config.clock?.()??_o()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=kn(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const i=e.getTop(t),o=e.getBottom(t);Number.isFinite(i)&&this.yExtent.push(i),Number.isFinite(o)&&this.yExtent.push(o)}}evictDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(t)),void this.yExtent.evict(this.getLow(t));this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const i=e.getTop(t),o=e.getBottom(t);Number.isFinite(i)&&this.yExtent.evict(i),Number.isFinite(o)&&this.yExtent.evict(o)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return this.updateResults.recordNoop("replace"),!1;const e=this.currentTime();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?go(this.config.timeAccessor||this.config.xAccessor,"time"):go(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,o="function"==typeof i?i(e):e[i||"x"],n=o instanceof Date,r="string"==typeof o&&Number.isFinite(vo(o));if(this.xIsDate=n||r,r){const t="string"==typeof i?i:void 0;this.getX=t?e=>wo(e[t]):t=>wo(i(t))}}wn(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const i of t.inserts)Sn(this.buffer,i,this.timestampBuffer,e),this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i)}else for(const i of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity??1e5;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),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 ${t}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const t=Sn(this.buffer,i,this.timestampBuffer,e);this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i),null!=t&&(this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t))}return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}computeScene(t){const{config:e,buffer:i}=this,o=this.scales,n=this.lastLayout;if(!this.needsFullRebuild&&!e.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(i,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const r=this.getBufferArray(),s=this.yExtent.extent;let a=bn(this.xExtent.extent,e.xExtent),c=bn(s,e.yExtent);const l=!(!(u=e.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===e.axisExtent;if("stackedarea"===e.chartType&&!l&&i.size>0){const t=function(t){const{config:e,groups:i,getX:o,getY:n}=t,r="exact"===e.axisExtent;if(e.normalize){const i=[0,r?1:1+e.extentPadding];return{yDomain:i,stackExtentCache:{key:`${t.bufferSize}:${t.ingestVersion}:norm`,yDomain:i}}}const s=`${t.bufferSize}:${t.ingestVersion}:${e.baseline??"zero"}:${e.stackOrder??"key"}`;if(t.stackExtentCache&&t.stackExtentCache.key===s)return{yDomain:t.stackExtentCache.yDomain,stackExtentCache:t.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,h=new Map;for(const t of i){const e=new Map;let i=0;for(const r of t.data){const t=o(r),s=n(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),c.add(t),i+=s;const a=(u.get(t)||0)+s;u.set(t,a),a>l&&(l=a)}a.set(t.key,e),h.set(t.key,i)}const d=e.stackOrder??"key",f=(t,e)=>e>t?-1:t>e?1:0;let p,y;if("input"===d)p=i.map(t=>t.key);else if("insideOut"===d){const t=[...i].map(t=>t.key).sort((t,e)=>{const i=(h.get(e)??0)-(h.get(t)??0);return 0!==i?i:f(t,e)}),e=[],o=[];let n=0,r=0;for(const i of t)r>n?(e.push(i),n+=h.get(i)??0):(o.push(i),r+=h.get(i)??0);p=[...o.reverse(),...e]}else p="asc"===d?i.map(t=>t.key).sort((t,e)=>{const i=(h.get(t)??0)-(h.get(e)??0);return 0!==i?i:f(t,e)}):"desc"===d?i.map(t=>t.key).sort((t,e)=>{const i=(h.get(e)??0)-(h.get(t)??0);return 0!==i?i:f(t,e)}):i.map(t=>t.key).sort(f);if("wiggle"===e.baseline||"silhouette"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),i=Eo(t,p,(t,e)=>a.get(t)?.get(e)||0,e.baseline);let o=1/0,n=-1/0;for(const e of t){const t=i.get(e)??0,r=u.get(e)??0;o>t&&(o=t),t+r>n&&(n=t+r)}Number.isFinite(o)&&Number.isFinite(n)||(o=0,n=0);const s=n-o,l=r?0:s>0?s*e.extentPadding:1;y=[o-l,n+l]}else if("diverging"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),[i,o]=function(t,e,i){let o=0,n=0;for(const r of t){let t=0,s=0;for(const o of e){const e=i(o,r)||0;0>e?s+=e:t+=e}o>s&&(o=s),t>n&&(n=t)}return[o,n]}(t,p,(t,e)=>a.get(t)?.get(e)||0),n=o-i,s=r?0:n>0?n*e.extentPadding:1;y=[i-s,o+s]}else y=[0,l+(r?0:l>0?l*e.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}({config:e,groups:this.groupData(r),getX:this.getX,getY:this.getY,bufferSize:i.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=t.yDomain,this._stackExtentCache=t.stackExtentCache}else"bar"===e.chartType&&e.binSize&&!l&&i.size>0?c=function(t,e,i,o,n,r,s){const[,a]=function(t,e,i,o,n){const r=cn(t,e,i,o,n);if(0===r.size)return[0,0];let s=0;for(const t of r.values())t.total>s&&(s=t.total);return[0,s]}(t,e,i,o,n);return[0,s?a:a+a*r]}(i,this.getX,this.getY,e.binSize,this.getCategory,e.extentPadding,h):"waterfall"===e.chartType&&!l&&i.size>0?c=function(t,e,i,o){const[n,r]=function(t,e){let i=0,o=0,n=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(n+=t,i>n&&(i=n),n>o&&(o=n))}return[i,o]}(t,e),s=r-n,a=o?0:s>0?s*i:1;return[Math.min(0,n-Math.abs(a)),Math.max(0,r+Math.abs(a))]}(i,this.getY,e.extentPadding,h):l||c[0]===1/0||(c=function(t,e,i){if(!i.length)return t;let[o,n]=t;for(const t of e)for(const e of i){const i=e.getTop(t),r=e.getBottom(t);Number.isFinite(i)&&(o>i&&(o=i),i>n&&(n=i)),Number.isFinite(r)&&(o>r&&(o=r),r>n&&(n=r))}return[o,n]}(c,r,this.resolvedRibbons),c=function(t,e){const i=t[1]-t[0],o=e.exactMode?0:i>0?i*e.extentPadding:1,n=[null!=e.userMin?t[0]:t[0]-o,null!=e.userMax?t[1]:t[1]+o];return"log"!==e.yScaleType||n[0]>0||0>=e.dataYDomain[0]||e.exactMode||null==e.userMin&&(n[0]=e.dataYDomain[0]/(1+e.extentPadding)),n}(c,{exactMode:h,extentPadding:e.extentPadding,userMin:e.yExtent?.[0],userMax:e.yExtent?.[1],yScaleType:e.yScaleType,dataYDomain:s}));c=function(t,e,i){if(!e||i)return t;const o=e[0],n=e[1];return null==o&&null==n?t:[null!=o?o:t[0],null!=n?n:t[1]]}(c,e.yExtent,!!l),({xDomain:a,yDomain:c}=function(t,e,i){let o=t,n=e;if(o[0]===1/0||o[1]===-1/0)if("time"===i){const t=Date.now();o=[t-864e5,t]}else o=[0,1];return n[0]!==1/0&&n[1]!==-1/0||(n=[0,1]),{xDomain:o,yDomain:n}}(a,c,e.xScaleType)),this.scales=function(t){const{config:e,layout:i,xDomain:o,yDomain:n}=t,r="streaming"===e.runtimeMode,s=Math.max(0,Math.min(e.scalePadding||0,Math.min(i.width,i.height)/2-1));if(r){if("x"==("up"===(a=e.arrowOfTime)||"down"===a?"y":"x")){const t="right"===e.arrowOfTime?[s,i.width-s]:[i.width-s,s];return{x:yn().domain(o).range(t),y:vn(e.yScaleType,n,[i.height-s,s])}}const t="down"===e.arrowOfTime?[s,i.height-s]:[i.height-s,s];return{x:vn(e.yScaleType,n,[s,i.width-s]),y:yn().domain(o).range(t)}}var a;return{x:vn(e.xScaleType,o,[s,i.width-s]),y:vn(e.yScaleType,n,[i.height-s,s])}}({config:e,layout:t,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(t,r);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.lastLayout=n):(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=d,this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r,this.currentTime()),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:t.width,height:t.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,i=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const o of t.path)o[0]*=e,o[1]*=i;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=i;for(const o of t.bottomPath)o[0]*=e,o[1]*=i;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*i,width:t.clipRect.width*e,height:t.clipRect.height*i});break;case"point":case"glyph":t.x*=e,t.y*=i;break;case"rect":case"heatcell":t.x*=e,t.y*=i,t.w*=e,t.h*=i;break;case"candlestick":t.x*=e,t.openY*=i,t.closeY*=i,t.highY*=i,t.lowY*=i}const o=this.scales.x.domain(),n=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),a=vn,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,o,r[0]>r[1]?[t.width-c,c]:[c,t.width-c]),y:a(this.config.yScaleType,n,l?[c,t.height-c]:[t.height-c,c])},this.lastLayout={width:t.width,height:t.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(t,e){const{config:i,scales:o}=this;if(!o)return[];if(i.customLayout){const n={data:e,scales:o,dimensions:{width:t.width,height:t.height,margin:i.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:i.themeSemantic??{},categorical:i.themeCategorical??S},resolveColor:(t,e)=>{const o=this.resolveGroupColor(t);if(o)return o;const n=this.resolveLineStyle(t,e);return n.stroke?n.stroke:"string"==typeof n.fill?n.fill:i.themeSemantic?.primary??"#4e79a7"},config:i.layoutConfig??{},selection:i.layoutSelection??null};let r;try{r=i.customLayout(n)}catch(t){const e=null!==this.lastCustomLayoutResult,o=dn("xy",t,e,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t);try{i.onLayoutError?.(o)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null;const s=r.nodes??[];if(this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of s)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(s,i.layoutSelection??null)}return ln({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===e.length)return[];const n={scales:o,config:i,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:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(i.chartType){case"line":return function(t,e){const i=t.groupData(e),o=[],n=t.config.annotations?.filter(Go).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=jo(t.ribbons);if(r.length>0&&o.push(...Yo(t,e,r)),n.length>0)for(const e of i)o.push(...Xo(t,e.data,e.key,n))}for(const e of i){const i=t.resolveLineStyle(e.key,e.data[0]),r=zo(e.data,t.scales,t.getX,t.getY,i,e.key);n&&n.length>0&&(r.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return qo(t,i,o),o}(n,e);case"area":return function(t,e){const i=t.groupData(e),o=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=jo(t.ribbons);if(r.length>0&&o.push(...Yo(t,e,r)),n.length>0)for(const e of i)o.push(...Xo(t,e.data,e.key,n))}const n=t.scales.y.domain()[0],r=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),s=Do(e.data,t.scales,t.getX,t.getY,n,i,e.key,r),a=Ho(t.config.gradientFill);a&&(s.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return qo(t,i,o),o}(n,e);case"mixed":return function(t,e){const i=t.groupData(e),o=[],n=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=jo(t.ribbons);if(r.length>0&&o.push(...Yo(t,e,r)),n.length>0)for(const e of i)o.push(...Xo(t,e.data,e.key,n))}const r=t.scales.y.domain()[0],s=t.getY0?e=>{const i=t.getY0(e);return null==i?r:i}:void 0;for(const e of i)if(n.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),n=Do(e.data,t.scales,t.getX,t.getY,r,i,e.key,s),a=Ho(t.config.gradientFill);a&&(n.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),o.push(n)}else{const i=t.resolveLineStyle(e.key,e.data[0]),n=zo(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),o.push(n)}return qo(t,i,o),o}(n,e);case"stackedarea":return function(t,e){const i=t.groupData(e),o=t.config.stackOrder??"key",n=()=>i.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("input"===o);else if("key"===o)n();else if("asc"===o||"desc"===o||"insideOut"===o){const e=new Map;for(const o of i){let i=0;for(const e of o.data){const o=t.getX(e),n=t.getY(e);Number.isFinite(o)&&Number.isFinite(n)&&(i+=n)}e.set(o.key,i)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===o)i.sort((t,i)=>{const o=(e.get(t.key)??0)-(e.get(i.key)??0);return 0!==o?o:n(t.key,i.key)});else if("desc"===o)i.sort((t,i)=>{const o=(e.get(i.key)??0)-(e.get(t.key)??0);return 0!==o?o:n(t.key,i.key)});else{const t=[...i].sort((t,i)=>{const o=(e.get(i.key)??0)-(e.get(t.key)??0);return 0!==o?o:n(t.key,i.key)}),o=[],r=[];let s=0,a=0;for(const i of t)a>s?(o.push(i),s+=e.get(i.key)??0):(r.push(i),a+=e.get(i.key)??0);i.length=0,i.push(...r.reverse(),...o)}}else n();const r=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,s=t.config.normalize?"zero":t.config.baseline??"zero",{nodes:a,stackedTops:c}=function(t,e,i,o,n,r,s,a="zero"){const c=new Set;for(const e of t)for(const t of e.data){const e=i(t);Number.isFinite(e)&&c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const n of e.data){const e=i(n),r=o(n);Number.isFinite(e)&&Number.isFinite(r)&&t.set(e,(t.get(e)||0)+r)}u.set(e.key,t)}let h;if(r){h=new Map;for(const e of l){let i=0;for(const o of t)i+=u.get(o.key)?.get(e)||0;h.set(e,i||1)}}const d=Eo(l,t.map(t=>t.key),(t,e)=>u.get(t)?.get(e)||0,a),f="diverging"===a&&!r,p=[],y=new Map,g=new Map,m=new Map,x=new Map;for(const t of l)g.set(t,d.get(t)??0),m.set(t,0),x.set(t,0);for(const i of t){const t=u.get(i.key),o=new Map;let a=[],c=[];const d=()=>{if(a.length>=2){const t={type:"area",topPath:a,bottomPath:c,style:n(i.key,i.data[0]),datum:i.data,group:i.key};s&&(t.curve=s),p.push(t)}a=[],c=[]};for(const i of l){const n=t.has(i);let s,l,u=n?t.get(i):0;if(r&&n&&(u/=h.get(i)),!n||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(i),l=s+u,m.set(i,l)):(s=x.get(i),l=s+u,x.set(i,l)):(s=g.get(i),l=s+u,g.set(i,l));const p=e.x(i);c.push([p,e.y(s)]),a.push([p,e.y(l)]),o.set(i,l)}d(),y.set(i.key,o)}return{nodes:p,stackedTops:y}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,r,s),l=a;if(t.config.pointStyle){const e=new WeakMap;for(const o of i){const i=c.get(o.key);if(i)for(const n of o.data){const o=t.getX(n),r=t.getY(n);null==o||Number.isNaN(o)||null==r||Number.isNaN(r)||!i.has(o)||e.set(n,i.get(o))}}const o=i=>e.get(i)??t.getY(i);qo(t,i,l,o)}return l}(n,e);case"scatter":case"bubble":return function(t,e){const i=[],o="bubble"===t.config.chartType?10:5,n=t.config.sizeRange||[3,15];let r=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const o of i)t>o&&(t=o),o>e&&(e=o);r=i=>t===e?(n[0]+n[1])/2:n[0]+(i-t)/(e-t)*(n[1]-n[0])}}const s=t.getColor?t.resolveColorMap(e):null,a=t.config.themeSemantic?.primary||"#4e79a7",c=t.getSymbol,l=t.config.symbolMap,u=new Map;let h=0;const d=t=>{const e=l?.[t];if(e)return e;let i=u.get(t);return i||(i=rn[h%rn.length],h++,u.set(t,i)),i};for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:a,opacity:.8},l=e.r||o;if(r&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(l=r(e))}if(s&&t.getColor&&!e.fill){const i=t.getColor(n);i&&s.has(i)&&(e={...e,fill:s.get(i)})}const u=t.getPointId?t.getPointId(n)+"":void 0;if(c){const o=d(c(n)+""),r=Io(n,t.scales,t.getX,t.getY,Math.PI*l*l,o,e,u);r&&i.push(r)}else{const o=No(n,t.scales,t.getX,t.getY,l,e,u);o&&i.push(o)}}return i}(n,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){const o=Math.max(1,Math.floor(t.config.heatmapXBins??20)),n=Math.max(1,Math.floor(t.config.heatmapYBins??20)),r=t.config.heatmapAggregation??"count",s=go(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[a,c]=t.scales.x.domain(),[l,u]=t.scales.y.domain(),h=(c-a||1)/o,d=(u-l||1)/n,f=o*n;if(f>1e6)return[];const p=new Int32Array(f),y=new Float64Array(f);for(let i=0;e.length>i;i++){const r=e[i],c=t.getX(r),u=t.getY(r);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/h),o-1),g=Math.min(Math.floor((u-l)/d),n-1);if(0>f||0>g)continue;const m=g*o+f;p[m]++;const x=s(r);y[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let t=0;f>t;t++){if(0===p[t])continue;let e;switch(r){case"sum":e=y[t];break;case"mean":e=y[t]/p[t];break;default:e=p[t]}g>e&&(g=e),e>m&&(m=e)}if(!isFinite(g))return[];const x=m-g||1,b=i.width/o,v=i.height/n,w=t.config.showValues,k=t.config.heatmapValueFormat,S=[];for(let t=0;n>t;t++){const e=t*o;for(let i=0;o>i;i++){const o=e+i;if(0===p[o])continue;let s;switch(r){case"sum":s=y[o];break;case"mean":s=y[o]/p[o];break;default:s=p[o]}const c=(s-g)/x;S.push(Fo(i*b,(n-1-t)*v,b,v,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:i,yi:t,value:s,count:p[o],sum:y[o],xCenter:a+(i+.5)*h,yCenter:l+(t+.5)*d,agg:r},w?{value:s,showValues:!0,valueFormat:k}:void 0))}}return S}(t,e,i);if(0===e.length)return[];const o=go(t.config.valueAccessor,"value"),n=mo(t.config.xAccessor,"x"),r=mo(t.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(e.length),l=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],o=n(i),u=r(i);c[t]=o,l[t]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),p=d.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(p){d.sort((t,e)=>Number(t)-Number(e)),s.clear();for(let t=0;d.length>t;t++)s.set(d[t],t)}if(y){f.sort((t,e)=>Number(t)-Number(e)),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const g=new Float64Array(e.length),m=new Float64Array(e.length),x=Array(e.length),w=new Map;let k=0;for(let t=0;e.length>t;t++){const i=e[t],n=s.get(c[t]),r=a.get(l[t]);if(void 0===n||void 0===r)continue;const h=o(i),d=r*u+n,f=w.get(d);let p;void 0!==f?p=f:(p=k++,w.set(d,p)),g[p]=d,m[p]=h,x[p]=i}let S=1/0,A=-1/0;for(let t=0;k>t;t++){const e=m[t];isFinite(e)&&(S>e&&(S=e),e>A&&(A=e))}if(!isFinite(S)||!isFinite(A))return[];const M=function(t){const e=t in b?t:"blues";let i=an.get(e);if(i)return i;i=Array(256);const o=v(e);for(let t=0;256>t;t++)i[t]=o(t/255);return an.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),_=255/(A-S||1),P=i.width/u,R=i.height/h,T=t.config.showValues,L=t.config.heatmapValueFormat,C=[];for(let t=0;k>t;t++){const e=m[t];if(!isFinite(e))continue;const i=g[t],o=i%u;C.push(Fo(o*P,(h-1-(i-o)/u)*R,P,R,M[Math.min((e-S)*_+.5|0,255)],x[t],T?{value:e,showValues:!0,valueFormat:L}:void 0))}return C}(n,e,t);case"bar":{const t=function(t,e){if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const i=cn(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===i.size)return{nodes:[],binBoundaries:[]};let o=null;if(t.getCategory){const e=new Set;for(const t of i.values())for(const i of t.categories.keys())e.add(i);const n=t.config.barColors?Object.keys(t.config.barColors):[],r=new Set(n),s=Array.from(e).filter(t=>!r.has(t)).sort(),a=n.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?o=t.barCategoryCache.order:(o=[...a,...s],t.barCategoryCache={key:c,order:o})}const n=[],r=t.scales,[s,a]=r.x.domain(),c=t.config.barStyle,l=t.config.themeSemantic?.primary,u=c?.gap,h="number"!=typeof u||0>u?1:u,d={};c?.stroke&&(d.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(d.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(d.opacity=c.opacity);for(const e of i.values()){const i=Math.max(e.start,s),u=Math.min(e.end,a);if(i>=u)continue;const f=r.x(i),p=r.x(u),y=Math.abs(p-f),g=y>h+1?h:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(o&&e.categories.size>0){let i=0;for(const s of o){const o=e.categories.get(s)||0;if(0===o)continue;const a=r.y(i),u=r.y(i+o);n.push(Bo(m,Math.min(a,u),x,Math.abs(a-u),{fill:t.config.barColors?.[s]||c?.fill||l||"#4e79a7",...d},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:o},s)),i+=o}}else{const t=r.y(0),i=r.y(e.total);n.push(Bo(m,Math.min(t,i),x,Math.abs(t-i),{fill:c?.fill||l||"#007bff",...d},{binStart:e.start,binEnd:e.end,total:e.total}))}}const f=new Set;for(const t of i.values())f.add(t.start),f.add(t.end);return{nodes:n,binBoundaries:Array.from(f).sort((t,e)=>t-e)}}(n,e);return this._barCategoryCache=n.barCategoryCache??null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){const i=[],o=t.config.swarmStyle||{},n=o.radius??3,r=o.fill??t.config.themeSemantic?.primary??"#007bff",s=o.opacity??.7,a=o.stroke,c=o.strokeWidth;for(const o of e){const e=t.getX(o),l=t.getY(o);if(null==l||Number.isNaN(l))continue;const u=t.scales.x(e),h=t.scales.y(l);let d=r;if(t.getCategory){const e=t.getCategory(o);d=t.config.barColors?.[e]||d}const{r:f,...p}=t.config.pointStyle?.(o)??{},y={type:"point",x:u,y:h,r:f??n,style:{fill:d,opacity:s,stroke:a,strokeWidth:c,...p},datum:o};t.getPointId&&(y.pointId=t.getPointId(o)+""),i.push(y)}return i}(n,e);case"waterfall":return function(t,e,i){const o=[],n=t.scales,r=t.config.waterfallStyle,s=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===s.length)return o;const a=r?.positiveColor??t.config.themeSemantic?.success??"#28a745",c=r?.negativeColor??t.config.themeSemantic?.danger??"#dc3545",l=r?.gap??1,u=r?.stroke,h=r?.strokeWidth,d=r?.opacity;let f=0;for(let e=0;s.length>e;e++){const p=s[e],y=t.getX(p),g=t.getY(p),m=f+g;let x;x=s.length-1>e?t.getX(s[e+1])-y:e>0?y-t.getX(s[e-1]):0;const b=n.x(y),v=0!==x?n.x(y+x):b+i.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=n.y(f),A=n.y(m),M=Math.min(S,A),_=Math.abs(S-A),P={fill:0>g?c:a,stroke:u,strokeWidth:h};null!=d&&(P.opacity=d),o.push(Bo(w,M,k,_,P,{...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:r?.connectorStroke,_connectorWidth:r?.connectorWidth})),f=m}return o}(n,e,t);case"candlestick":return function(t,e){if(!t.getHigh||!t.getLow||!t.scales)return[];const i=t.config.candlestickRangeMode??!1;if(!(i||t.getOpen&&t.getClose))return[];const o=[],n=t.config.candlestickStyle||{},r=n.rangeColor||"#6366f1",s=i?r:n.upColor||"#28a745",a=i?r:n.downColor||"#dc3545",c=i?r:n.wickColor||"#333",l=n.wickWidth||(i?2:1),u=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let h=n.bodyWidth??0;if(null==n.bodyWidth)if(u.length>1){let e=1/0;for(let i=1;u.length>i;i++){const o=Math.abs(t.scales.x(u[i])-t.scales.x(u[i-1]));o>0&&e>o&&(e=o)}h=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else h=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const r=t.getHigh(n),u=t.getLow(n);if(null==r||Number.isNaN(r)||null==u||Number.isNaN(u))continue;const d=i?r:t.getOpen(n),f=i?u:t.getClose(n);if(!i&&[d,f].some(t=>null==t||Number.isNaN(t)))continue;const p=f>=d,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(d),closeY:t.scales.y(f),highY:t.scales.y(r),lowY:t.scales.y(u),bodyWidth:h,upColor:s,downColor:a,wickColor:c,wickWidth:l,isUp:p,datum:n};i&&(y.isRange=!0),o.push(y)}return o}(n,e);default:return[]}}resolveBoundsStyle(t,e){return function(t,e,i,o){const n=t.boundsStyle;return"function"==typeof n?n(i||{},e):n&&"object"==typeof n?n:{fill:o(e,i).stroke||t.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,t,e,(t,e)=>this.resolveLineStyle(t,e))}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?Po(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const e=Ro(t);return this._datumIndexCache={version:this._ingestVersion,map:e},e}applyDecay(t,e){this.config.decay&&function(t,e,i,o=Ro(i)){const n=i.length;if(n>1)for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const r=Array(e.length);let s=!1;for(let i=0;e.length>i;i++){const a=o.get(e[i]);null!=a?(r[i]=Po(t,a,n),1>r[i]&&(s=!0)):r[i]=1}s&&(i._decayOpacities=r);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],r=i.topPath?i.topPath.length:e.length;if(2>r)continue;if(e.length===r){const s=Array(r);let a=!1;for(let i=0;e.length>i;i++){const r=o.get(e[i]);null!=r?(s[i]=Po(t,r,n),1>s[i]&&(a=!0)):s[i]=1}a&&(i._decayOpacities=s)}else{let s=1;for(const i of e){const e=o.get(i);if(null!=e){const i=Po(t,e,n);s>i&&(s=i)}}if(1>s){const t=Array(r);t.fill(s),i._decayOpacities=t}}continue}const e=o.get(i.datum);if(null==e)continue;const r=Po(t,e,n);"heatcell"===i.type?i.style={opacity:r}:"candlestick"===i.type?i._decayOpacity=r:i.style={...i.style,opacity:(i.style?.opacity??1)*r}}}(this.config.decay,t,e,this.getDatumIndexMap(e))}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&Co(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,i,o){i.clear(),o.clear();for(let n=0;e.length>n;n++){const r=e[n],s=$o(t,r,n);s&&("point"===r.type?i.set(s,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"glyph"===r.type?i.set(s,{x:r.x,y:r.y,r:r.size,opacity:r.style.opacity,glyph:r.glyph}):"rect"===r.type?i.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}):"heatcell"===r.type?i.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style?.opacity}):"candlestick"===r.type?i.set(s,{x:r.x,y:r.openY,w:r.bodyWidth,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY,opacity:r.style?.opacity}):"line"===r.type?o.set(s,{path:r.path.map(t=>[t[0],t[1]]),opacity:r.style?.opacity}):"area"===r.type&&o.set(s,{topPath:r.topPath.map(t=>[t[0],t[1]]),bottomPath:r.bottomPath.map(t=>[t[0],t[1]]),opacity:r.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const t=this.scales?.y(0)??0;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],o=$o(this.transitionContext,i,e);o&&("point"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,r:0,opacity:0}):"rect"===i.type?this.prevPositionMap.set(o,{x:i.x,y:t,w:i.w,h:0,opacity:i.style.opacity??1}):"heatcell"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:0}):"line"===i.type?(i._introClipFraction=0,this.prevPathMap.set(o,{path:i.path.map(t=>[t[0],t[1]]),opacity:i.style.opacity})):"area"===i.type&&(i._introClipFraction=0,this.prevPathMap.set(o,{topPath:i.topPath.map(t=>[t[0],t[1]]),bottomPath:i.bottomPath.map(t=>[t[0],t[1]]),opacity:i.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,o,n,r=_o()){if(0===o.size&&0===n.size)return i;const s=e.duration??300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let a=!1;const c=new Set,l=new Set;for(let e=0;i.scene.length>e;e++){const r=i.scene[e],s=$o(t,r,e);if(!s)continue;if(r._transitionKey=s,"line"===r.type||"area"===r.type){const t=n.get(s);if(t){if(l.add(s),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];a=!0}else if("area"===r.type&&t.topPath&&t.bottomPath&&t.topPath.length===r.topPath.length&&t.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(t=>[t[0],t[1]]),r._targetBottomPath=r.bottomPath.map(t=>[t[0],t[1]]),r._prevTopPath=t.topPath,r._prevBottomPath=t.bottomPath;for(let e=0;r.topPath.length>e;e++)r.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;r.bottomPath.length>e;e++)r.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];a=!0}r._targetOpacity=r.style.opacity??1,r._startOpacity=t.opacity??r.style.opacity??1}else r._targetOpacity=r.style.opacity??1,r._startOpacity=0,r.style={...r.style,opacity:0},a=!0;continue}const u=o.get(s);if("point"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=r.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=u.x,r.y=u.y,r.r=u.r??r.r,a=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},a=!0;else if("glyph"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,size:r.size};r._targetOpacity=r.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.size||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.size,r.x=u.x,r.y=u.y,r.size=u.r??r.size,a=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},a=!0;else if("rect"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=r.style.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=u.x,r.y=u.y,r.w=u.w??r.w,r.h=u.h??r.h,a=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},a=!0;else if("heatcell"===r.type)if(u){c.add(s);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=r.style?.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=u.x,r.y=u.y,r.w=u.w??r.w,r.h=u.h??r.h,a=!0)}else r._targetOpacity=r.style?.opacity??1,r.style={...r.style||{},opacity:0},a=!0;else if("candlestick"===r.type)if(u&&null!=u.openY){c.add(s);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=r.style?.opacity??1,(u.x!==t.x||u.openY!==t.openY||u.closeY!==t.closeY||u.highY!==t.highY||u.lowY!==t.lowY)&&(r._targetX=t.x,r._targetOpenY=t.openY,r._targetCloseY=t.closeY,r._targetHighY=t.highY,r._targetLowY=t.lowY,r.x=u.x,r.openY=u.openY,r.closeY=u.closeY??r.closeY,r.highY=u.highY??r.highY,r.lowY=u.lowY??r.lowY,a=!0)}else r._targetOpacity=r.style?.opacity??1,r.style={...r.style||{},opacity:0},a=!0}for(const[t,e]of n)if(!l.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),a=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),a=!0}for(const[t,e]of o)if(!c.has(t)){if(t.startsWith("p:"))i.exitNodes.push({type:"point",x:e.x,y:e.y,r:e.r??3,style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("g:")&&e.glyph)i.exitNodes.push({type:"glyph",x:e.x,y:e.y,size:e.r??12,glyph:e.glyph,color:"#999",accent:"#999",style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))i.exitNodes.push({type:"rect",x:e.x,y:e.y,w:e.w??0,h:e.h??0,style:{opacity:e.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("h:"))i.exitNodes.push({type:"heatcell",x:e.x,y:e.y,w:e.w??0,h:e.h??0,fill:"#999",datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t});else if(t.startsWith("c:")){const o=e.openY??e.y;i.exitNodes.push({type:"candlestick",x:e.x,openY:o,closeY:e.closeY??o,highY:e.highY??o,lowY:e.lowY??o,bodyWidth:e.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t})}a=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),a&&(i.activeTransition={startTime:r,duration:s}),i}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},i=function(t,e,i,o){if(!i.activeTransition)return!1;const n=Ao(t,i.activeTransition),r=So(n,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=Mo(i?i.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Mo(i.x,t._targetX,r),t.y=Mo(i.y,t._targetY,r),void 0!==t._targetR&&void 0!==i.r&&(t.r=Mo(i.r,t._targetR,r))}else if("glyph"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=Mo(i?i.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Mo(i.x,t._targetX,r),t.y=Mo(i.y,t._targetY,r),void 0!==t._targetR&&void 0!==i.r&&(t.size=Mo(i.r,t._targetR,r))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=Mo(i?i.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Mo(i.x,t._targetX,r),t.y=Mo(i.y,t._targetY,r),void 0!==i.w&&(t.w=Mo(i.w,t._targetW,r)),void 0!==i.h&&(t.h=Mo(i.h,t._targetH,r))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style={...t.style||{},opacity:Mo(i?i.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Mo(i.x,t._targetX,r),t.y=Mo(i.y,t._targetY,r),void 0!==i.w&&(t.w=Mo(i.w,t._targetW,r)),void 0!==i.h&&(t.h=Mo(i.h,t._targetH,r))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style={...t.style||{},opacity:Mo(i?i.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Mo(i.x,t._targetX,r),void 0!==i.openY&&(t.openY=Mo(i.openY,t._targetOpenY,r)),void 0!==i.closeY&&(t.closeY=Mo(i.closeY,t._targetCloseY,r)),void 0!==i.highY&&(t.highY=Mo(i.highY,t._targetHighY,r)),void 0!==i.lowY&&(t.lowY=Mo(i.lowY,t._targetLowY,r))}else if("line"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Mo(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=Mo(e[o][0],i[o][0],r),t.path[o][1]=Mo(e[o][1],i[o][1],r)}else if("area"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Mo(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevTopPath,i=t._prevBottomPath,o=t._targetTopPath,n=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=Mo(e[i][0],o[i][0],r),t.topPath[i][1]=Mo(e[i][1],o[i][1],r);if(i&&n&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=Mo(i[e][0],n[e][0],r),t.bottomPath[e][1]=Mo(i[e][1],n[e][1],r)}}if(n>=1){for(const t of i.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style="line"===t.type||"area"===t.type?{...t.style,opacity:0===e?0:e}:{...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("glyph"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,i}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){const{result:e,cache:i}=function(t,e,i,o){if(o&&o.version===i&&o.group===e&&o.data===t)return{result:o.result,cache:o};let n;if(e){const i=new Map;for(const o of t){const t=e(o);i.has(t)||i.set(t,[]),i.get(t).push(o)}n=Array.from(i.entries()).map(([t,e])=>({key:t,data:e}))}else n=[{key:"_default",data:t}];return{result:n,cache:{version:i,group:e,data:t,result:n}}}(t,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,e}resolveColorMap(t){const{map:e,cache:i}=function(t,e,i,o,n){if(n&&n.version===o)return{map:n.map,cache:n};const r=new Set;if(e)for(const i of t){const t=e(i);t&&r.add(t)}const s=Array.from(r).sort(),a=s.join("\0");if(n&&n.key===a){const t={...n,version:o};return{map:t.map,cache:t}}const c=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical||S,l=new Map;for(let t=0;s.length>t;t++)l.set(s[t],c[t%c.length]);return{map:l,cache:{key:a,map:l,version:o}}}(t,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,e}resolveLineStyle(t,e){return function(t,e,i,o){const n=t.lineStyle;if("function"==typeof n){const t=n(i||{},e);if(t&&!t.stroke&&e){const i=o(e);if(i)return{...t,stroke:i}}return t}const r=t.themeSemantic?.primary;return n&&"object"==typeof n?{stroke:n.stroke||r||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:o(e)||r||"#007bff",strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveAreaStyle(t,e){return function(t,e,i,o){if(t.areaStyle){const n=t.areaStyle(i||{});if(n&&!n.fill&&e){const t=o(e);if(t)return{...n,fill:t,stroke:n.stroke||t}}return n}const n=t.lineStyle;if("function"==typeof n){const t=n(i||{},e);if(t&&!t.fill&&e){const i=o(e);if(i)return{...t,fill:i,stroke:t.stroke||i}}return t}const r=t.themeSemantic?.primary;if(n&&"object"==typeof n)return{fill:n.fill||n.stroke||r||"#4e79a7",fillOpacity:n.fillOpacity??.7,stroke:n.stroke||r||"#4e79a7",strokeWidth:n.strokeWidth||2};const s=o(e)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveGroupColor(e){const{color:i,groupColorCounter:o}=function(t){const{group:e,colorMapCache:i,groupColorMap:o,groupColorMapCap:n,config:r}=t;let{groupColorCounter:s}=t;if(i){const t=i.map.get(e);if(t)return{color:t,groupColorCounter:s}}const a=o.get(e);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(r.colorScheme)&&r.colorScheme.length>0?r.colorScheme:null)||(Array.isArray(r.themeCategorical)&&r.themeCategorical.length>0?r.themeCategorical:null)||S;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,o.set(e,l),o.size>n){const t=o.keys().next().value;void 0!==t&&o.delete(t)}return{color:l,groupColorCounter:s}}({group:e,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:t.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=o,i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=ko(t),i=this.getPointId,o=t=>e.has(i(t));An(this.buffer,this.timestampBuffer,o);const n=this.buffer.remove(o);if(0===n.length)return this.updateResults.recordNoop("remove"),n;for(const t of n)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length),n}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=ko(t),o=this.getPointId,n=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&n.add(e)});const r=this.buffer.update(t=>i.has(o(t)),e);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const t of r)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.buffer.forEach((t,e)=>{n.has(e)&&(this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),r}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}applyCustomRestyle(t,e){const i=this._customRestyle;if(i)for(const o of t){const t=this._baseStyles.get(o)??o.style??{},n=i(o,e);o.style=n?{...t,...n}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(t){const e={...this.config},i=Object.keys(t).filter(i=>t[i]!==e[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.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 t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let o=!1,n=!1;Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();const r="chartType"in t&&t.chartType!==e.chartType||"runtimeMode"in t&&t.runtimeMode!==e.runtimeMode;if(r||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const t=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=t&&this.config.valueAccessor||this.config.yAccessor,s=t&&e.valueAccessor||e.yAccessor,a=r||!yo(t&&this.config.timeAccessor||this.config.xAccessor,t&&e.timeAccessor||e.xAccessor),c=r||!yo(i,s);(a||c)&&(t?(this.getX=go(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=go(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=go(this.config.xAccessor,"x"),this.getY=go(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=pn(this.config)),o=!0,n=!0)}if("groupAccessor"in t&&!yo(t.groupAccessor,e.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?xo(this.config.groupAccessor):void 0,o=!0),"categoryAccessor"in t&&!yo(t.categoryAccessor,e.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?xo(this.config.categoryAccessor):void 0,o=!0),"sizeAccessor"in t&&!yo(t.sizeAccessor,e.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?go(this.config.sizeAccessor,"size"):void 0,o=!0),"symbolAccessor"in t&&!yo(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?xo(this.config.symbolAccessor):void 0,o=!0),"colorAccessor"in t&&!yo(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?xo(this.config.colorAccessor):void 0,o=!0),"y0Accessor"in t&&!yo(t.y0Accessor,e.y0Accessor)&&(this.getY0=this.config.y0Accessor?go(this.config.y0Accessor,"y0"):void 0,o=!0,n=!0),("boundsAccessor"in t&&!yo(t.boundsAccessor,e.boundsAccessor)||"band"in t&&t.band!==e.band||"boundsStyle"in t&&t.boundsStyle!==e.boundsStyle)&&(this.resolvedRibbons=pn(this.config),o=!0,n=!0),"pointIdAccessor"in t&&!yo(t.pointIdAccessor,e.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?xo(this.config.pointIdAccessor):void 0,o=!0),"candlestick"===this.config.chartType&&(r||"openAccessor"in t&&!yo(t.openAccessor,e.openAccessor)||"closeAccessor"in t&&!yo(t.closeAccessor,e.closeAccessor)||"highAccessor"in t&&!yo(t.highAccessor,e.highAccessor)||"lowAccessor"in t&&!yo(t.lowAccessor,e.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?go(this.config.openAccessor,"open"):void 0,this.getHigh=go(this.config.highAccessor,"high"),this.getLow=go(this.config.lowAccessor,"low"),this.getClose=e?go(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,o=!0,n=!0}if("accessorRevision"in t&&t.accessorRevision!==e.accessorRevision&&(o=!0,n=!0),!o){const i=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of i)if(t[n]!==e[n]){o=!0;break}}o&&(n&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(i)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};Hn.GROUP_COLOR_MAP_CAP=1e3;var Zn=Hn;$n(Zn);import*as Kn from"react";import{arc as Un}from"d3-shape";import{jsx as Qn,jsxs as Jn}from"react/jsx-runtime";function tr(t){return"object"==typeof t&&null!==t&&"hatch"===t.type}function er(t,e){const{background:i="transparent",stroke:o="#000",lineWidth:n=1.5,spacing:r=6,angle:s=45,lineOpacity:a=1}=t,c=Math.max(8,Math.ceil(2*r));return Jn("pattern",{id:e,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[i&&"transparent"!==i&&Qn("rect",{width:c,height:c,fill:i}),Qn("line",{x1:0,y1:0,x2:0,y2:c,stroke:o,strokeWidth:n,strokeOpacity:a}),Qn("line",{x1:r,y1:0,x2:r,y2:c,stroke:o,strokeWidth:n,strokeOpacity:a})]},e)}function ir(t,e,i="#4e79a7"){if(tr(t)){const i=function(t,e){let i=2166136261;const o=function(t){return["hatch",t.background??"transparent",t.stroke??"#000",t.lineWidth??1.5,t.spacing??6,t.angle??45,t.lineOpacity??1].join("|")}(e);for(let t=0;o.length>t;t++)i^=o.charCodeAt(t),i=Math.imul(i,16777619);return`${t}-hatch-${(i>>>0).toString(36)}`}(e,t);return{fill:`url(#${i})`,def:er(t,i)}}return t&&"string"==typeof t?{fill:t}:{fill:i}}var or=[40,40],nr=[.5,.5];function rr(t,e,i,o){if("none"!==t)return"color"===t||null==t?e??o:"accent"===t?i:t}var sr=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function ar(t){const{innerRadius:e,outerRadius:i,startAngle:o,endAngle:n}=t,r=0>=e;if(0>=(t.cornerRadius??0)||!t.roundStart&&!t.roundEnd){if(r){const t=sr(i,o),e=sr(i,n);return`M0,0 L${t.x},${t.y} A${i},${i} 0 ${n-o>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=sr(i,o),s=sr(i,n),a=sr(e,n),c=sr(e,o),l=n-o>Math.PI?1:0;return`M${t.x},${t.y} A${i},${i} 0 ${l} 1 ${s.x},${s.y} L${a.x},${a.y} A${e},${e} 0 ${l} 0 ${c.x},${c.y} Z`}const s=Math.max(0,Math.min(t.cornerRadius??0,(i-e)/2));if(0===s)return ar({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,i-s))),c=r?0:Math.asin(Math.min(1,s/Math.max(1e-9,e+s))),l=n-o,u=t.roundStart&&t.roundEnd?l/2:l,h=!!t.roundStart&&u>a,d=!!t.roundEnd&&u>a;if(!h&&!d)return ar({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=o+(h?a:0),p=n-(d?a:0),y=o+(h?c:0),g=n-(d?c:0),m=sr(i,f),x=sr(i,p),b=(i-s)*Math.cos(a),v=sr(b,o),w=sr(b,n),k=r?null:sr(e,g),S=r?null:sr(e,y),A=r?0:(e+s)*Math.cos(c),M=r?null:sr(A,o),_=r?null:sr(A,n),P=p-f>Math.PI?1:0,R=r?0:g-y>Math.PI?1:0;let T="";if(h)T+=`M${v.x},${v.y}`,T+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const t=sr(i,o);T+=`M${t.x},${t.y}`}if(d)T+=` A${i},${i} 0 ${P} 1 ${x.x},${x.y}`,T+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const t=sr(i,n);T+=` A${i},${i} 0 ${P} 1 ${t.x},${t.y}`}if(r)T+=" L0,0";else{if(d)T+=` L${_.x},${_.y}`,T+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const t=sr(e,n);T+=` L${t.x},${t.y}`}if(h)T+=` A${e},${e} 0 ${R} 0 ${S.x},${S.y}`,T+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const t=sr(e,o);T+=` A${e},${e} 0 ${R} 0 ${t.x},${t.y}`}}return T+=" Z",T}import{jsx as cr,jsxs as lr}from"react/jsx-runtime";var ur={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function hr(t,e="#4e79a7"){return tr(t)?t.background&&"transparent"!==t.background?t.background:e:t&&"string"==typeof t?t:e}function dr(t,e,i){const o=sn(t.symbolType,t.size,t.path);return cr("path",{d:o,transform:t.rotation?`translate(${t.x},${t.y}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.x},${t.y})`,fill:t.style.fill?hr(t.style.fill):"none",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},`${i??""}symbol-${e}`)}function fr(t,e,i,o){const n=t.glyph;if(!n?.parts?.length||0>=t.size)return null;const r=function(t,e){const[i,o]=t.viewBox??or,[n,r]=t.anchor??nr,s=o>0?o:1,a=Math.max(0,e)/s,c=(i>0?i:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-n*c,offsetY:-r*l}}(n,t.size);if(0>=r.scale)return null;const s=`translate(${e},${i})${t.rotation?` rotate(${180*t.rotation/Math.PI})`:""} translate(${r.offsetX},${r.offsetY}) scale(${r.scale})`,a=t.color??("string"==typeof t.style.fill?t.style.fill:void 0),c=function(t,e,i=0,o="horizontal"){const[n,r]=t.viewBox??or,s=Math.min(1,Math.max(0,i)),a=Math.min(1,Math.max(0,e));return a>s?s>0||1>a?"vertical"===o?{x:0,y:r*(1-a),width:n,height:r*(a-s)}:{x:n*s,y:0,width:n*(a-s),height:r}:null:{x:0,y:0,width:0,height:0}}(n,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal"),l=c?pr(o+"-clip"):void 0,u=(t.style.opacity??1)*(t._decayOpacity??1)*(t.style.fillOpacity??1),h=e=>n.parts.map((i,o)=>{const n=e?"none"===i.fill?void 0:e:rr(i.fill,a,t.accent),r=e?i.stroke&&"none"!==i.stroke?e:void 0:rr(i.stroke??"none",a,t.accent);return n||r?cr("path",{d:i.d,fill:n??"none",stroke:r,strokeWidth:r?i.strokeWidth??1:void 0,strokeLinecap:i.strokeLinecap,strokeLinejoin:i.strokeLinejoin,opacity:i.opacity},o):null});return lr("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&cr("clipPath",{id:l,children:cr("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&t.ghostColor?cr("g",{children:h(t.ghostColor)}):null,c&&l?cr("g",{clipPath:`url(#${l})`,children:h()}):h()]},o)}function pr(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function yr(t,e,i){switch(t.type){case"line":{const i=t;if(0===i.path.length)return null;const o="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return cr("path",{d:o,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity},"line-"+e)}case"area":{const o=t;if(0===o.topPath.length)return null;const n=`M${o.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`,r=`${i?i+"-":""}area-${e}-hatch`,s=tr(o.style.fill)?er(o.style.fill,r):void 0,a=s?`url(#${r})`:hr(o.style.fill);if(o.clipRect){const t=`${i?i+"-":""}area-clip-${e}`;return lr("g",{children:[lr("defs",{children:[s,cr("clipPath",{id:t,children:cr("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),cr("path",{d:n,fill:a,fillOpacity:o.style.fillOpacity??o.style.opacity??.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,clipPath:`url(#${t})`})]},"area-"+e)}return lr(Kn.Fragment,{children:[s&&cr("defs",{children:s}),cr("path",{d:n,fill:a,fillOpacity:o.style.fillOpacity??o.style.opacity??.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"area-"+e)}case"point":{const o=t,n=`${i?i+"-":""}point-${e}-hatch`,r=tr(o.style.fill)?er(o.style.fill,n):void 0;return lr(Kn.Fragment,{children:[r&&cr("defs",{children:r}),cr("circle",{cx:o.x,cy:o.y,r:o.r,fill:r?`url(#${n})`:hr(o.style.fill),opacity:o.style.opacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"point-"+e)}case"symbol":return dr(t,e);case"glyph":return fr(t,t.x,t.y,`${i??""}glyph-${t.pointId??e}`);case"rect":{const o=t,n=`${i?i+"-":""}xyrect-${e}-hatch`,r=tr(o.style.fill)?er(o.style.fill,n):void 0;return lr(Kn.Fragment,{children:[r&&cr("defs",{children:r}),cr("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:r?`url(#${n})`:hr(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"rect-"+e)}case"heatcell":{const i=t;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const t=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[o,n,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(i.fill),s=.299*o+.587*n+.114*r>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return lr("g",{children:[cr("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),cr("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:t})]},"heatcell-"+e)}return cr("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill},"heatcell-"+e)}case"candlestick":{const i=t,o=Math.min(i.openY,i.closeY),n=Math.max(Math.abs(i.openY-i.closeY),1),r=i.isUp?i.upColor:i.downColor;return lr("g",{children:[cr("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),cr("rect",{x:i.x-i.bodyWidth/2,y:o,width:i.bodyWidth,height:n,fill:r,stroke:r,strokeWidth:1})]},"candle-"+e)}default:return null}}function gr(t,e,i){const o=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",n=i=>`ord-${t.type}-${o}-${e}-${i}`,r=`ord-${t.type}-${o}-${e}`;switch(t.type){case"rect":{const e=t,i=pr(r)+"-grad",o=function(t,e){const i=t.fillGradient;if(!i)return null;let o=t.x,n=t.y,r=t.x,s=t.y+t.h;"bottom"===t.roundedEdge?(n=t.y+t.h,s=t.y):"right"===t.roundedEdge?(o=t.x+t.w,n=t.y,r=t.x,s=t.y):"left"===t.roundedEdge&&(o=t.x,n=t.y,r=t.x+t.w,s=t.y);const a=[];if("colorStops"in i){const t=i.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>t.length)return null;for(let e=0;t.length>e;e++)a.push(cr("stop",{offset:t[e].offset,stopColor:t[e].color},e))}else{const e=hr(t.style.fill);a.push(cr("stop",{offset:0,stopColor:e,stopOpacity:i.topOpacity},"0")),a.push(cr("stop",{offset:1,stopColor:e,stopOpacity:i.bottomOpacity},"1"))}return cr("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:o,y1:n,x2:r,y2:s,children:a})}(e,i);let n,a;if(o)a=`url(#${i})`;else if(tr(e.style.fill)){const t=pr(r)+"-hatch";n=er(e.style.fill,t),a=`url(#${t})`}else a=hr(e.style.fill);const c=o||n?lr("defs",{children:[o,n]}):null;if(e.cornerRadii&&(((s=e.cornerRadii).tl??0)>0||(s.tr??0)>0||(s.br??0)>0||(s.bl??0)>0)){const t=function(t){const{x:e,y:i,w:o,h:n}=t,{tl:r,tr:s,br:a,bl:c}=function(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const i=Math.min(t.w,t.h)/2,o=t=>Math.max(0,Math.min(t??0,i));return{tl:o(e.tl),tr:o(e.tr),br:o(e.br),bl:o(e.bl)}}(t);let l=`M${e+r},${i}`;return l+=` L${e+o-s},${i}`,s>0&&(l+=` A${s},${s} 0 0 1 ${e+o},${i+s}`),l+=` L${e+o},${i+n-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${e+o-a},${i+n}`),l+=` L${e+c},${i+n}`,c>0&&(l+=` A${c},${c} 0 0 1 ${e},${i+n-c}`),l+=` L${e},${i+r}`,r>0&&(l+=` A${r},${r} 0 0 1 ${e+r},${i}`),l+=" Z",l}(e);return lr(Kn.Fragment,{children:[c,cr("path",{d:t,fill:a,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}if(e.roundedTop&&e.roundedTop>0){const t=Math.min(e.roundedTop,e.w/2,e.h/2),{x:i,y:o,w:n,h:s}=e;let l;switch(e.roundedEdge){case"right":l=`M${i},${o} L${i+n-t},${o} A${t},${t} 0 0 1 ${i+n},${o+t} L${i+n},${o+s-t} A${t},${t} 0 0 1 ${i+n-t},${o+s} L${i},${o+s} Z`;break;case"left":l=`M${i+n},${o} L${i+t},${o} A${t},${t} 0 0 0 ${i},${o+t} L${i},${o+s-t} A${t},${t} 0 0 0 ${i+t},${o+s} L${i+n},${o+s} Z`;break;case"bottom":l=`M${i},${o} L${i+n},${o} L${i+n},${o+s-t} A${t},${t} 0 0 1 ${i+n-t},${o+s} L${i+t},${o+s} A${t},${t} 0 0 1 ${i},${o+s-t} Z`;break;default:l=`M${i},${o+s} L${i},${o+t} A${t},${t} 0 0 1 ${i+t},${o} L${i+n-t},${o} A${t},${t} 0 0 1 ${i+n},${o+t} L${i+n},${o+s} Z`}return lr(Kn.Fragment,{children:[c,cr("path",{d:l,fill:a,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}return lr(Kn.Fragment,{children:[c,cr("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:a,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}case"point":{const e=t;return cr("circle",{cx:e.x,cy:e.y,r:e.r,fill:hr(e.style.fill),opacity:e.style.opacity??.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}case"symbol":return dr(t,e,i);case"glyph":return fr(t,t.x,t.y,`${i??""}ord-glyph-${t.pointId??e}`);case"wedge":{const o=t;if(o._gradientBand&&o._gradientBand.colors.length>0){const t=pr(`${i?i+"-":""}gauge-grad-${o.category||r}-${e}`),{clipPath:n,slices:s}=function(t){const e=ar({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),i=[],o=t.colors;if(o.length>0){const e=(t.endAngle-t.startAngle)/o.length;for(let n=0;o.length>n;n++)i.push({d:ar({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+n*e,endAngle:t.endAngle}),color:o[n]})}return{clipPath:e,slices:i}}({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds?.start??!0,roundEnd:o.roundedEnds?.end??!0,colors:o._gradientBand.colors});return lr("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[cr("defs",{children:cr("clipPath",{id:t,children:cr("path",{d:n})})}),cr("g",{clipPath:`url(#${t})`,children:s.map((t,e)=>cr("path",{d:t.d,fill:hr(t.color)},e))}),o.style.stroke&&"none"!==o.style.stroke&&cr("path",{d:n,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},r)}let n;if(o.roundedEnds)n=ar({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{const t=Un().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&t.cornerRadius(o.cornerRadius),n=t(ur)||""}return cr("path",{d:n,transform:`translate(${o.cx},${o.cy})`,fill:hr(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},r)}case"boxplot":{const e=t,i=e.columnWidth/2;return lr("g","vertical"===e.projection?{children:[cr("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1}),cr("rect",{x:e.x-i,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:hr(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:1}),cr("line",{x1:e.x-i,y1:e.medianPos,x2:e.x+i,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2}),cr("line",{x1:e.x-.5*i,y1:e.minPos,x2:e.x+.5*i,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:1}),cr("line",{x1:e.x-.5*i,y1:e.maxPos,x2:e.x+.5*i,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1})]}:{children:[cr("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:1}),cr("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-i,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:hr(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:1}),cr("line",{x1:e.medianPos,y1:e.y-i,x2:e.medianPos,y2:e.y+i,stroke:e.style.stroke||"#333",strokeWidth:2}),cr("line",{x1:e.minPos,y1:e.y-.5*i,x2:e.minPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1}),cr("line",{x1:e.maxPos,y1:e.y-.5*i,x2:e.maxPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1})]},r)}case"violin":{const e=t,i=[cr("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:hr(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1},n("path"))];if(e.iqrLine&&e.bounds){const t=e.bounds,o=t.x+t.width/2,r=t.y+t.height/2;t.height>t.width?i.push(cr("line",{x1:o,y1:e.iqrLine.q1Pos,x2:o,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},n("iqr")),cr("circle",{cx:o,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},n("med"))):i.push(cr("line",{x1:e.iqrLine.q1Pos,y1:r,x2:e.iqrLine.q3Pos,y2:r,stroke:e.style.stroke||"#333",strokeWidth:2},n("iqr")),cr("circle",{cx:e.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},n("med")))}return cr("g",{children:i},r)}case"connector":return cr("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity??.5},r);case"trapezoid":{const e=t,i=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return cr("polygon",{points:i,fill:hr(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}default:return null}var s}var mr=new Set;function xr(t){const{node:e,index:i,renderMode:o,fallback:n}=t,r=function(t,e){const i="function"==typeof t?t(e.datum??null,e):t;return(o=i)&&"object"==typeof o&&"string"==typeof o.id&&"function"==typeof o.cacheKey&&"function"==typeof o.drawCanvas&&"function"==typeof o.renderStaticSVG?i:void 0;var o}(o,e);if(!r)return n();const s=r.renderStaticSVG({node:e,style:e.style??{},key:`${r.id}-${i}`});return null!=s?s:(function(t,e){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const i=`${t}:${e}`;mr.has(i)||(mr.add(i),console.warn(`[Semiotic] Render backend "${t}" does not support scene node "${e}"; using the built-in renderer.`))}(r.id,e.type??"unknown"),n())}import{scaleOrdinal as br}from"d3-scale";import{jsx as vr,jsxs as wr}from"react/jsx-runtime";function kr(t){return"left"===t?"start":"right"===t?"end":t??"start"}function Sr(t){return Number(t.typography.legendSize??t.typography.labelSize??t.typography.tickSize)||11}function Ar(t,e,i,o){const n=Sr(o);return e+i+Math.ceil(t.length*n*.58)}function Mr(t){const{categories:e,theme:i,position:o="right",totalWidth:n,totalHeight:r,margin:s,legendLayout:a}=t,c=Math.max(1,a?.swatchSize??14),l=Math.max(0,a?.labelGap??6),u=Math.max(0,a?.itemGap??8),h=Math.max(c,a?.rowHeight??20),d=c+l,f=Math.min(2,c/2),p="top"===o||"bottom"===o,y=Math.max(c,n-s.left-s.right),g=Math.max(h,r-s.top-s.bottom),m=e.map(t=>Ar(t,c,l,i));if(p){const t=Math.max(c,a?.maxWidth??y),i=[];let o=0,n=0;m.forEach((e,r)=>{const s=0===n?e:n+u+e;n>0&&s>t?(i.push({start:o,end:r,width:n}),o=r,n=e):n=s}),e.length>0&&i.push({start:o,end:e.length,width:n});const r=kr(a?.align),s=[];return i.forEach((i,o)=>{let n="center"===r?Math.max(0,(t-i.width)/2):"end"===r?Math.max(0,t-i.width):0;for(let t=i.start;i.end>t;t++)s.push({category:e[t],width:m[t],x:n,y:o*h}),n+=m[t]+u}),{items:s,width:Math.max(0,...i.map(t=>t.width)),height:i.length*h,swatchSize:c,labelOffset:d,swatchRadius:f}}const x=Math.max(0,...m),b=Math.max(1,Math.floor(g/h)),v=Math.max(1,Math.ceil(e.length/b));return{items:e.map((t,e)=>({category:t,width:m[e],x:Math.floor(e/b)*(x+u),y:e%b*h})),width:v*x+Math.max(0,v-1)*u,height:Math.min(e.length,b)*h,swatchSize:c,labelOffset:d,swatchRadius:f}}function _r(t){const{legendGroups:e,theme:i,position:o="right",totalWidth:n,totalHeight:r,margin:s,legendLayout:a}=t,c=Math.max(1,a?.swatchSize??14),l=Math.max(0,a?.labelGap??6),u=Math.max(0,a?.itemGap??8),h=Math.max(c,a?.rowHeight??20),d=c+l,f=Math.min(2,c/2),p=Math.max(12,Sr(i)),y="top"===o||"bottom"===o,g=Math.max(c,n-s.left-s.right),m=Math.max(h,r-s.top-s.bottom);if(y){const o=Math.max(c,a?.maxWidth??g),n=kr(a?.align);let r=0,s=0;const l=[];for(const n of e){const e=n.items.map(t=>t.label),u=Mr({...t,categories:e,legendLayout:{...a,maxWidth:Math.max(c,o-p-8),align:"start"}}),h=n.label?p:0,d=n.label?Ar(n.label,0,0,i):0,f=h>0?h+8:0,y=f+u.width,g=Math.max(u.height,d);l.push({group:n,x:r,y:0,itemOffsetX:f,itemOffsetY:0,width:y,height:g,items:u.items}),r+=y+12,s=Math.max(s,g)}const u=l.length>0?r-12:0,h=u>o?0:"center"===n?Math.max(0,(o-u)/2):"end"===n?Math.max(0,o-u):0;return{groups:l.map(t=>({...t,x:t.x+h})),width:u,height:s,swatchSize:c,labelOffset:d,swatchRadius:f}}let x=0,b=0;const v=[];for(const t of e){const e=t.items.map(t=>t.label).map(t=>Ar(t,c,l,i)),o=Math.max(0,...e),n=Math.max(1,Math.min(t.items.length||1,Math.max(1,Math.floor(Math.max(h,m-x)/h)))),r=Math.max(1,Math.ceil(t.items.length/n)),s=t.items.map((t,i)=>({category:t.label,width:e[i],x:Math.floor(i/n)*(o+u),y:i%n*h})),a=r*o+Math.max(0,r-1)*u,d=Math.min(t.items.length,n)*h,f=t.label?Ar(t.label,0,0,i):0,y=t.label?p+8:0,g=y+d+12,w=Math.max(a,f);v.push({group:t,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:d,swatchRadius:f}}function Pr(t){const e="top"===t.position||"bottom"===t.position,i=Math.max(1,t.totalWidth-t.margin.left-t.margin.right);return e?{width:Math.min(t.legendLayout?.maxWidth??i,200),height:t.gradient.label?34:26,swatchSize:12}:{width:t.gradient.label?86:72,height:t.gradient.label?124:108,swatchSize:14}}function Rr(t){const{categories:e,colorScheme:i,theme:o,position:n="right",totalWidth:r,totalHeight:a,margin:c,hasTitle:l=!1}=t;if(!e||0===e.length)return null;const u=function(t,e,i){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;return e=>_(t,e)??"#999"}const o=Array.isArray(e)?e:i.colors.categorical.length>0?i.colors.categorical:s;return br().domain(t).range(o)}(e,i,o),h="top"===n||"bottom"===n,d=Mr(t);let f,p;if("left"===n?(f=Math.max(4,c.left-d.width-10),p=c.top):"top"===n?(f=c.left,p=l?32:8):"bottom"===n?(f=c.left,p=Math.min(a-c.bottom+38,a-d.height-2)):(f=Math.min(r-d.width-4,r-c.right+10),p=c.top),h){const t=d.items.map((t,e)=>wr("g",{transform:`translate(${t.x},${t.y})`,children:[vr("rect",{width:d.swatchSize,height:d.swatchSize,fill:u(t.category),rx:d.swatchRadius}),vr("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:Sr(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:t.category})]},"legend-"+e));return vr("g",{className:"semiotic-legend",transform:`translate(${f},${p})`,children:t})}const y=d.items.map((t,e)=>wr("g",{transform:`translate(${t.x},${t.y})`,children:[vr("rect",{width:d.swatchSize,height:d.swatchSize,fill:u(t.category),rx:d.swatchRadius}),vr("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:Sr(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:t.category})]},"legend-"+e));return vr("g",{className:"semiotic-legend",transform:`translate(${f},${p})`,children:y})}function Tr(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=i(e);null!=t&&o.add(t+"")}return Array.from(o)}import{jsx as Lr,jsxs as Cr}from"react/jsx-runtime";function $r(t,e=120,i=8){if(!t)return[];const o=Math.max(1,Math.floor(e/i)),n=t.split(/\s+/),r=[];let s="";for(const t of n)s&&s.length+1+t.length>o?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function zr(t,e,i,o){return"curly"===t?o?`M0,0 C${.6*i},0 ${.4*i},${e/2} ${i},${e/2} C${.4*i},${e/2} ${.6*i},${e} 0,${e}`:`M0,0 C0,${.6*i} ${e/2},${.4*i} ${e/2},${i} C${e/2},${.4*i} ${e},${.6*i} ${e},0`:o?`M0,0 L${i},0 L${i},${e} L0,${e}`:`M0,0 L0,${i} L${e},${i} L${e},0`}function Dr(t,e,i,o){if(!t)return Lr("g",{className:"annotation-note"});const{label:n,title:r,orientation:s,align:a,wrap:c=120,noWrap:l}=t;if(!n&&!r)return Lr("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(e)>Math.abs(i)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>i?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>e?"end":"start";const f=16,p=r?l?[r]:$r(r,c):[],y=n?l?[n]:$r(n,c):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const x=[],b=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";t.useHTML||t.html?x.push(Lr("foreignObject",{className:"annotation-note-html",x:"end"===d?g-c:"middle"===d?g-c/2:g,y:-16,width:c,height:Math.max(f,(p.length+y.length)*f+(r&&n?2:0))+f,style:{overflow:"visible"},children:Cr("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[r&&Lr("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:r}),n&&Lr("div",{className:"annotation-note-label",children:n})]})},"annotation-note-html")):(p.length>0&&(x.push(Lr("text",{className:"annotation-note-title",fill:b,textAnchor:d,fontWeight:"bold",children:p.map((t,e)=>Lr("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-title")),m=p.length*f),y.length>0&&x.push(Lr("text",{className:"annotation-note-label",fill:b,textAnchor:d,y:m,children:y.map((t,e)=>Lr("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-label")));let v=null;if((r||n)&&(0!==e||0!==i))if("topBottom"===u){const t=Math.min(c,120);let e=0,i=t;"end"===d?(e=-t,i=0):"middle"===d&&(e=-t/2,i=t/2),v=Lr("line",{className:"note-line",x1:e,x2:i,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(p.length+y.length)*f+(y.length>0?f:0);let e=0,i=t;"bottom"===h?(e=-t,i=0):"middle"===h&&(e=-t/2,i=t/2),v=Lr("line",{className:"note-line",x1:0,x2:0,y1:e,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let k=0;return"topBottom"===u?k=0>i?-(w+2):18:"leftRight"===u&&(k="middle"===h?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===h||0>i?-(w+2):18),Cr("g",{className:"annotation-note",transform:`translate(${e},${i})`,children:[Lr("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:x}),v]})}function Er(t,e,i,o,n){const r=[];switch(t){case"callout-circle":{const t=(e?.radius||0)+(e?.radiusPadding||0);t>0&&r.push(Lr("circle",{r:t,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=e?.width||0,o=e?.height||0;(t>0||o>0)&&r.push(Lr("rect",{width:t,height:o,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":e?.custom&&r.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=o||0,s=n||0;if(void 0!==e?.x){const o=(e.x||0)-t;r.push(Lr("line",{x1:o,y1:(e.y1||0)-s,x2:o,y2:(e.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==e?.y){const o=(e.y||0)-s;r.push(Lr("line",{x1:(e.x1||0)-t,y1:o,x2:(e.x2||0)-t,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==e?.x1||void 0!==e?.x2?r.push(Lr("line",{x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===e?.y1&&void 0===e?.y2||r.push(Lr("line",{x1:0,y1:(e.y1||0)-s,x2:0,y2:(e.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=e?.type||"curly",o=e?.width??e?.height;void 0!==o&&r.push(Lr("path",{d:zr(t,o,e?.depth||30,void 0===e?.width),fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return Lr("g",{className:"annotation-subject",children:r})}function Nr(t,e,i,o,n,r){const s=[];let a=0,c=0;if("callout-circle"!==n&&"label"!==n||!r?.radius){if("callout-rect"===n&&r){const i=r.width||0,o=r.height||0;if(i>0||o>0){const n=i/2,r=o/2,s=t-n,l=e-r;if(0!==s||0!==l){const t=Math.abs(s),e=Math.abs(l),u=i/2,h=o/2,d=t*h>e*u?u/t:h/e;a=n+s*d,c=r+l*d}}}else if("bracket"===n&&r){const t=r.width,e=r.height,i=r.depth||30;void 0!==t?(a=t/2,c=i):void 0!==e&&(a=i,c=e/2)}}else{const i=(r.radius||0)+(r.radiusPadding||0);if(i>0&&(0!==t||0!==e)){const o=Math.atan2(e,t);a=Math.cos(o)*i,c=Math.sin(o)*i}}const l=Math.sqrt((t-a)**2+(e-c)**2);if(l>.5){const n=o||"var(--semiotic-text-secondary, currentColor)",r="curve"===i?.type;let u=Math.atan2(e-c,t-a);if(r){const o=(a+t)/2,r=(c+e)/2,h=-(e-c)/l,d=(t-a)/l,f=(i?.curve??.25)*l,p=o+h*f,y=r+d*f;s.push(Lr("path",{className:"connector-curve",d:`M${a},${c}Q${p},${y} ${t},${e}`,fill:"none",stroke:n},"connector-line")),u=Math.atan2(y-c,p-a)}else s.push(Lr("line",{x1:a,y1:c,x2:t,y2:e,stroke:n},"connector-line"));if("arrow"===i?.end){const t=10,e=16/180*Math.PI;s.push(Lr("path",{d:`M${a},${c}L${a+t*Math.cos(u+e)},${c+t*Math.sin(u+e)}L${a+t*Math.cos(u-e)},${c+t*Math.sin(u-e)}Z`,fill:n,stroke:"none"},"connector-arrow"))}}return Lr("g",{className:"annotation-connector",children:s})}function Ir(t){const{x:e=0,y:i=0,dx:o,dy:n,nx:r,ny:s,note:a,connector:c,subject:l,type:u,color:h,className:d,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=t,x=Array.isArray(e)?e[0]??0:e,b=Array.isArray(i)?i[0]??0:i,v=new Set(Array.isArray(f)?f:[]);let w=o||0,k=n||0;null!=r&&(w=r-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 t=l.depth||30;k=t+(0>t?-5:5)}else if(void 0!==l.height){const t=l.depth||30;w=t+(0>t?-5:5),k=l.height/2}return Cr("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.has("connector")&&Nr(w,k,c,h,S,l),!v.has("subject")&&Er(S,l,h,x,b),!v.has("note")&&Dr(a,w,k,h)]})}function Br(t){const{noteData:e}=t,{screenCoordinates:i}=e,o="string"==typeof e.type?e.type:"label",n=e.eventListeners||e.events||{};if(e.coordinates&&i){const t=e.nx||i[0][0]+(e.dx??0),n=e.ny||i[0][1]+(e.dy??0),r=i.map((i,r)=>{const s=Object.assign({},e,{note:0===r?e.note:{label:""},x:i[0],y:i[1],nx:t,ny:n});return Lr(Ir,{"data-testid":"semiotic-annotation",...s,type:o},"multi-annotation-"+r)});return Lr("g",{children:r})}const r=e.note||{title:"none",label:e.label},s=`${r.label}-${r.title}-${e.i}`;return Lr(Ir,{"data-testid":"semiotic-annotation",events:n,...e,type:o},s)}import{jsx as Fr}from"react/jsx-runtime";var Or={secondary:0,primary:3};function Wr(t){return!0===t?._annotationDeferred}function jr(t){return"blended"===t?.cohesion||"layer"===t?.cohesion?t.cohesion:null}function Yr(t){const e=t?.provenance?.confidence;return"number"==typeof e&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):null}function Xr(t){return Math.max(.72,.95-.06*t)}function qr(t,e){const i=e.scales?.x??e.scales?.time;return i?null!=t.x?i(t.x):e.xAccessor&&null!=t[e.xAccessor]?i(t[e.xAccessor]):null:null}function Gr(t,e){const i=e.scales?.y??e.scales?.value;return i?null!=t.y?i(t.y):e.yAccessor&&null!=t[e.yAccessor]?i(t[e.yAccessor]):null:null}function Vr(t){return null==t?null:t+""}function Hr(t,e,i){return e.stickyPositionCache?.set(t,i),i}var Zr=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Kr(t){return!!t&&"object"==typeof t&&Zr.has(function(t){return"string"==typeof t?.type?t.type:""}(t))}function Ur(t){return"primary"===t?.emphasis||!0===t?.defensive}function Qr(t,e,i={}){return"number"==typeof i.maxAnnotations&&Number.isFinite(i.maxAnnotations)?Math.max(0,Math.floor(i.maxAnnotations)):t>0&&e>0?Math.max(1,Math.round(t*e/(i.areaPerAnnotation&&i.areaPerAnnotation>0?i.areaPerAnnotation:2e4))):1/0}function Jr(t){let e;const i=t?.emphasis;e="primary"===i?100:"secondary"===i?10:50;const o=t?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(e+=15*Math.max(0,Math.min(1,o))),t?.lifecycle?.freshness){case"fresh":e+=8;break;case"aging":e+=4;break;case"stale":e+=1;break;case"expired":e-=200}return e}new Set(["label","callout","callout-circle","callout-rect"]);var ts=32,es=6,is=4,os=8,ns=72;var rs={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function ss(t){if(!as(t))return t;const e=("string"==typeof t.mobileText?t.mobileText:void 0)??("string"==typeof t.shortText?t.shortText:void 0);return!e||"string"!=typeof t.label&&null!=t.label?t:{...t,label:e}}function as(t){return Kr(t)}function cs(t,e){if(!t)return[];const i=Math.max(1,Math.floor(e/7)),o=t.split(/\s+/).filter(Boolean),n=[];let r="";for(const t of o)r&&r.length+t.length+1>i?(n.push(r),r=t):r=r?`${r} ${t}`:t;return r&&n.push(r),n}function ls(t,e,i,o,n){const r=t+i,s=e+o;return Math.abs(i)>Math.abs(o)?{x:0>i?r-n.width-4:r+4,y:0>o?s-n.height:s,width:n.width,height:n.height}:{x:0>i?r-n.width:r,y:0>o?s-n.height-4:s+4,width:n.width,height:n.height}}function us(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function hs(t,e){return Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x))*Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}function ds(t,e,i,o,n,r,s,a){const c=us(t,s);let l=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,i,o){const n=Math.max(0,o-t.x),r=Math.max(0,o-t.y);return(n+Math.max(0,t.x+t.width-(e-o)))*t.height+(r+Math.max(0,t.y+t.height-(i-o)))*t.width}(c,n,r,a);for(const t of i)l+=12*hs(c,t);for(const t of o)l+=4*hs(c,t);return l}function fs(t,e,i){if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const o=t.pointId??t.nodeId;if(null!=o&&i.pointNodes){const t=i.pointNodes.find(t=>t.pointId===o);if(t)return{x:t.x,y:t.y}}const n=t.coordinates,r=i.scales?.geoProjection;if(Array.isArray(n)&&n.length>=2&&r){const t=n[0],e=n[1];if("number"==typeof t&&"number"==typeof e){const i=r([t,e]);if(i&&"number"==typeof i[0]&&"number"==typeof i[1])return{x:i[0],y:i[1]}}}return i.scales||"number"!=typeof t.x||"number"!=typeof t.y?function(t,e,i){const o=t.anchor||t.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=t.pointId&&i.pointNodes&&i.pointNodes.length>0)for(let o=i.pointNodes.length-1;o>=0;o--){const n=i.pointNodes[o];if(n.pointId===t.pointId)return Hr(e,i,{x:n.x,y:n.y})}const o=function(t){const e=t.data;if(!e||0===e.length)return null;const i=e[e.length-1],o=t.scales?.x??t.scales?.time,n=t.scales?.y??t.scales?.value;if(!o||!n)return null;const r=i[t.xAccessor||"x"],s=i[t.yAccessor||"y"];return null==r||null==s?null:{x:o(r),y:n(s)}}(i);return o?Hr(e,i,o):null}if("semantic"===o){const o=function(t,e,i){const o=function(t){return Vr(t.provenance?.stableId??t.stableId)}(t);if(!o)return null;const n=i.pointNodes?.find(t=>Vr(t.pointId)===o);if(n)return Hr(e,i,{x:n.x,y:n.y});const r=i.data?.find(t=>function(t){return Vr(t.stableId??t.id??t.provenance?.stableId)}(t)===o);if(!r)return null;const s=qr(r,i),a=Gr(r,i);return null==s||null==a?null:Hr(e,i,{x:s,y:a})}(t,e,i);if(o)return o}let n=null,r=null;if(null!=t.pointId&&i.pointNodes){const e=i.pointNodes.find(e=>e.pointId===t.pointId);e&&(n=e.x,r=e.y)}if(null!=n&&null!=r||(n=qr(t,i),r=Gr(t,i)),null!=n&&null!=r)return Hr(e,i,{x:n,y:r});if("sticky"===o){const t=i.stickyPositionCache?.get(e);if(t)return t}return null}(t,e,i):{x:t.x,y:t.y}}function ps(t){const{annotations:e,context:i,defaultOffset:o=ts,notePadding:n=es,markPadding:r=is,edgePadding:s=os,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=ns,density:u,progressiveDisclosure:h=!1,redundantCues:d=!1,responsive:f,mobile:p,cohesion:y,audience:g}=t,m=i.width||0,x=i.height||0,b="object"==typeof p?p:{},v=b.breakpoint??480,w=!!p&&v>=m,k=w&&!1!==b.preferShortText?e.map(ss):e,S=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,A=h||w&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),M=w&&!f?b.responsive??{minWidth:v}:f,_=w&&!y?b.cohesion:y;if(0===k.length||0>=m||0>=x)return k.slice();const P=[],R=function(t,e){return(t.pointNodes||[]).map(t=>{const i=Math.max(1,t.r||1)+e;return{x:t.x-i,y:t.y-i,width:2*i,height:2*i}})}(i,r);let T=!1;const L=k.map((t,e)=>{if(!as(t))return t;const r=fs(t,e,i);if(!r)return t;const u=function(t){if("widget"===t.type)return{width:"number"==typeof t.width?t.width:32,height:"number"==typeof t.height?t.height:32};const e="number"==typeof t.wrap?t.wrap:120,i=[...cs("string"==typeof t.title?t.title:void 0,e),...cs("string"==typeof t.label?t.label:void 0,e)],o=i.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*o)+10),height:Math.max(18,16*i.length+6)}}(t);if(a&&("number"==typeof(h=t).dx||"number"==typeof h.dy)){const e=function(t){return"text"===t.type||"widget"===t.type?{dx:0,dy:0}:{dx:30,dy:-30}}(t);return P.push(us(ls(r.x,r.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,u),n)),t}var h;let d=null,f=1/0;for(const t of function(t){const e=1.6*t;return[{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t},{dx:t,dy:0},{dx:-t,dy:0},{dx:0,dy:-t},{dx:0,dy:t},{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e}]}(o)){const e=ds(ls(r.x,r.y,t.dx,t.dy,u),t,P,R,m,x,n,s);f>e&&(d=t,f=e)}if(!d)return t;const p=us(ls(r.x,r.y,d.dx,d.dy,u),n);P.push(p);const y=Math.hypot(d.dx,d.dy),g=c&&y>=l&&"text"!==t.type&&"widget"!==t.type?{...t.connector||{end:"arrow"},type:"curve"}:t.connector;return T=!0,{...t,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),C=T?L:k.slice();let $=C;if(d){let t=!1;const e=C.map(e=>{const i=function(t){return"text"!==t.type||"string"!=typeof t.color||8>Math.hypot("number"==typeof t.dx?t.dx:0,"number"==typeof t.dy?t.dy:0)?t:{...t,_redundantConnector:!0}}(e);return i!==e&&(t=!0),i});$=t?e:C}{let t=!1;const e=$.map(e=>{if(!0!==e?.defensive)return e;const i=function(t){const e=t?.provenance;if(!e||"object"!=typeof e)return t;const i="string"==typeof e.source?rs[e.source]??e.source:null,o="number"==typeof e.confidence&&Number.isFinite(e.confidence)?Math.round(100*Math.max(0,Math.min(1,e.confidence)))+"%":null;if(!i&&!o)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const n=[i,o].filter(Boolean).join(" · "),r="string"==typeof t.label?t.label:"";return r.includes(`(${n})`)?t:{...t,label:r?`${r} (${n})`:`(${n})`}}(e);return i!==e&&(t=!0),i});$=t?e:$}const z=new Set;if(S){const t="object"==typeof S?S:{},e=function(t){if(!t)return 1;const e=function(t){const e=t?.familiarity;if(!e)return 3;const i=Object.values(e).filter(t=>"number"==typeof t&&Number.isFinite(t));return 0===i.length?3:i.reduce((t,e)=>t+e,0)/i.length}(t);return e>2?4>e?1:.6:1.5}(g),i=1===e?t:{...t,maxAnnotations:Math.max(0,Math.round((t.maxAnnotations??Qr(m,x,t))*e))},{deferred:o}=function(t){const{annotations:e,width:i,height:o}=t,n=Math.max(0,t.minVisible??1),r=Qr(i,o,t),s=e.map((t,e)=>{return{annotation:t,index:e,note:(i=t,Kr(i))};var i}),a=s.filter(t=>t.note);if(0===a.length||r>=a.length)return{visible:e.slice(),deferred:[],budget:r};const c=a.filter(t=>Ur(t.annotation)),l=a.filter(t=>!Ur(t.annotation)).sort((t,e)=>Jr(e.annotation)-Jr(t.annotation)||t.index-e.index),u=Math.min(l.length,Math.max(Math.max(0,r-c.length),Math.max(0,n-c.length))),h=new Set([...c.map(t=>t.index),...l.slice(0,u).map(t=>t.index)]),d=[],f=[];for(const{annotation:t,index:e,note:i}of s)!i||h.has(e)?d.push(t):f.push(t);return{visible:d,deferred:f,budget:r}}({annotations:$,width:m,height:x,...i});for(const t of o)z.add(t)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:480)>=m)for(const t of $)as(t)&&"secondary"===t.emphasis&&z.add(t);if(z.size>0)for(const t of $)!0===t?.defensive&&z.delete(t);let D;return D=0===z.size?$:A?$.map(t=>z.has(t)?{...t,_annotationDeferred:!0}:t):$.filter(t=>!z.has(t)),_?function(t,e){let i=!1;const o=t.map(t=>as(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(i=!0,{...t,cohesion:e}):t);return i?o:t}(D,_):D}import{jsx as ys,jsxs as gs}from"react/jsx-runtime";var ms="var(--semiotic-bg, #ffffff)";function xs(t){const{x:e,y:i,text:o,fill:n,fontSize:r=12,fontWeight:s,fontFamily:a,textAnchor:c="start",dominantBaseline:l,background:u,className:h}=t,d=function(t){return void 0===t||!0===t||"halo"===t?{type:"halo"}:!1===t||"none"===t?null:"box"===t?{type:"box"}:{type:t.type??"halo",...t}}(u),f=t=>ys("text",{x:e,y:i,textAnchor:c,dominantBaseline:l,fill:n,fontSize:r,fontWeight:s,fontFamily:a,className:h,...t?{stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:"stroke"}:{},children:o});if(!d)return f();if("halo"===d.type)return f({stroke:d.fill??ms,strokeWidth:d.haloWidth??3});const p=d.padding??{x:6,y:3},y="number"==typeof p?p:p.x,g="number"==typeof p?p:p.y,m=function(t,e){return(t+"").length*e*.6}(o,r),x=r+2*g;let b,v;return b="middle"===c?e-m/2-y:"end"===c?e-m-y:e-y,v="middle"===l||"central"===l?i-x/2:"hanging"===l||"text-before-edge"===l?i-g:i-.8*r-g,gs("g",{className:h,children:[ys("rect",{x:b,y:v,width:m+2*y,height:x,rx:d.radius??3,ry:d.radius??3,fill:d.fill??ms,fillOpacity:d.opacity??.85,stroke:d.stroke,strokeWidth:d.strokeWidth}),f()]})}import{jsx as bs,jsxs as vs}from"react/jsx-runtime";var ws=16;function ks(t,e){return t.color||e.colors.annotation||e.colors.text}function Ss(t,e,i){const o=t.labelBackground,n=e.colors.background;return void 0===o?"none"===i?"none":{type:"halo",fill:n}:!1===o||"none"===o?"none":!0===o||"halo"===o?{type:"halo",fill:n}:"box"===o?{type:"box",fill:n}:{fill:n,...o}}function As(t,e,i){return null!=t.x&&e.x?e.x(t.x):i&&null!=t[i]&&e.x?e.x(t[i]):"number"==typeof t.x?t.x:null}function Ms(t,e,i){return null!=t.y&&e.y?e.y(t.y):i&&null!=t[i]&&e.y?e.y(t[i]):"number"==typeof t.y?t.y:null}function _s(t){const{annotations:e}=t;if(!e||0===e.length)return null;const i=t.autoPlaceAnnotations?ps({annotations:e,context:{scales:{x:t.scales.x,y:t.scales.y,time:t.scales.x,value:t.scales.y,o:t.scales.o,geoProjection:t.scales.geoProjection},width:t.layout.width,height:t.layout.height,xAccessor:t.xAccessor,yAccessor:t.yAccessor,frameType:t.projection?"ordinal":"xy",projection:"horizontal"===t.projection?"horizontal":"vertical"},..."object"==typeof t.autoPlaceAnnotations?t.autoPlaceAnnotations:{}}):e,o=[];for(let e=0;i.length>e;e++){const n=Ps(i[e],e,t);n&&o.push({node:n,annotation:i[e]})}const n=function(t){const e=t.map((t,e)=>{return{p:t,i:e,emphasis:(i=t.annotation,"primary"===i?.emphasis||"secondary"===i?.emphasis?i.emphasis:null),confidence:Yr(t.annotation),readingOrder:null,rank:1};var i}),i=e.some(t=>null!=t.emphasis||null!=t.confidence),o=t.some(t=>Wr(t.annotation)),n=t.some(t=>null!=jr(t.annotation)),r=t.some(t=>"layer"===jr(t.annotation));if(!i&&!o&&!n)return t.map(t=>t.node);const s=e.filter(t=>null==t.emphasis&&null!=t.confidence).slice().sort((t,e)=>(e.confidence??0)-(t.confidence??0)||t.i-e.i);s.forEach((t,e)=>{t.readingOrder=e,t.rank=2-e/Math.max(1,s.length)});for(const t of e)t.emphasis&&(t.rank=Or[t.emphasis]);const a=e.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(t=>{const{p:e,i:i,emphasis:o,readingOrder:n}=t,r=Wr(e.annotation);let s=e.node;if("primary"===o||"secondary"===o||null!=n){const t=null==o&&null!=n;s=Fr("g",{className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+o,..."secondary"===o?{opacity:.6,fontSize:"0.88em"}:{},...t?{opacity:Xr(n),"data-annotation-reading-order":n}:{},children:e.node},"annotation-emphasis-"+i)}const a=jr(e.annotation);return a&&(s=Fr("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+i)),r&&(s=Fr("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+i)),s});return o&&a.unshift(Fr("style",{children:".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}}"},"annotation-disclosure-style")),r&&a.unshift(Fr("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),a}(o);return n.length>0?bs("g",{id:(t.idPrefix?t.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:n}):null}function Ps(t,e,i){const{scales:o,layout:n,theme:r,xAccessor:s,yAccessor:a}=i;switch(t.type){case"y-threshold":{const s=t.value;if(null==s)return null;const a=ks(t,r),c=t.label,l=t.labelPosition||"right",u=t.strokeDasharray||"6,4",h=t.strokeWidth??1.5;if("horizontal"===i.projection&&o.r){const i=o.r(s);return null==i?null:vs("g",{opacity:t.opacity,children:[bs("line",{x1:i,y1:0,x2:i,y2:n.height,stroke:a,strokeWidth:h,strokeDasharray:u}),c&&bs(xs,{x:i+4,y:ws,textAnchor:"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ss(t,r,"halo")})]},"ann-ythresh-"+e)}const d=o.y?o.y(s):o.r?o.r(s):null;return null==d?null:vs("g",{children:[bs("line",{x1:0,y1:d,x2:n.width,y2:d,stroke:a,strokeWidth:h,strokeDasharray:u}),c&&bs(xs,{x:"left"===l?4:"center"===l?n.width/2:n.width-4,y:20>d?Math.min(n.height-4,d+ws):d-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ss(t,r,"halo")})]},"ann-ythresh-"+e)}case"x-threshold":{const i=t.value;if(null==i||!o.x)return null;const s=o.x(i);if(null==s)return null;const a=ks(t,r),c=t.label,l=t.labelPosition||"top";return vs("g",{opacity:t.opacity,children:[bs("line",{x1:s,y1:0,x2:s,y2:n.height,stroke:a,strokeWidth:t.strokeWidth??1.5,strokeDasharray:t.strokeDasharray||"6,4"}),c&&bs(xs,{x:s>.6*n.width?s-4:s+4,y:"bottom"===l?n.height-4:"center"===l?n.height/2:ws,textAnchor:s>.6*n.width?"end":"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ss(t,r,"halo")})]},"ann-xthresh-"+e)}case"band":{const i=null!=t.y0&&o.y?o.y(t.y0):null,s=null!=t.y1&&o.y?o.y(t.y1):null;if(null==i||null==s)return null;const a=Math.min(i,s),c=Math.abs(s-i),l=ir(t.fill||ks(t,r),"ssr-band-"+e),u=t.fillOpacity??.1;return vs("g",{opacity:t.opacity,children:[l.def&&bs("defs",{children:l.def}),bs("rect",{x:0,y:a,width:n.width,height:c,fill:l.fill,fillOpacity:u}),t.label&&bs(xs,{x:n.width-4,y:Math.max(a,0)+ws,textAnchor:"end",fontSize:r.typography.tickSize,fill:t.color||ks(t,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:t.label,background:Ss(t,r,"halo")})]},"ann-band-"+e)}case"x-band":{const i=null!=t.x0&&o.x?o.x(t.x0):null,s=null!=t.x1&&o.x?o.x(t.x1):null;if(null==i||null==s)return null;const a=Math.min(i,s),c=Math.abs(s-i),l=ir(t.fill||ks(t,r),"ssr-xband-"+e),u=t.fillOpacity??.1;return vs("g",{opacity:t.opacity,children:[l.def&&bs("defs",{children:l.def}),bs("rect",{x:a,y:0,width:c,height:n.height,fill:l.fill,fillOpacity:u}),t.label&&bs(xs,{x:a+4,y:ws,textAnchor:"start",fontSize:r.typography.tickSize,fill:t.color||ks(t,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:t.label,background:Ss(t,r,"halo")})]},"ann-xband-"+e)}case"category-highlight":{if(null==t.category||!o.o)return null;const s=o.o(t.category+"");if(null==s)return null;const a=o.o.bandwidth?o.o.bandwidth():40,c=ks(t,r),l=t.opacity??.1,u=t.label;return vs("g","horizontal"===i.projection?{children:[bs("rect",{x:0,y:s,width:n.width,height:a,fill:c,opacity:l}),u&&bs(xs,{x:12,y:s+a/2,dominantBaseline:"middle",fill:c,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:u,background:Ss(t,r,"none")})]}:{children:[bs("rect",{x:s,y:0,width:a,height:n.height,fill:c,opacity:l}),u&&bs(xs,{x:s+a/2,y:ws,textAnchor:"middle",fill:c,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:u,background:Ss(t,r,"none")})]},"ann-cathighlight-"+e)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:i,y:n}=function(t,e,i,o){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const i=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(i)return{x:i[0],y:i[1]}}return{x:As(t,e,i),y:Ms(t,e,o)}}(t,o,s,a);if(null==i||null==n)return null;const c="text"===t.type,l=t.dx??(c?0:30),u=t.dy??(c?0:-30),h=t.color||r.colors.text;if(!c){const o="callout"===t.type?"callout-circle":t.type,r="callout-circle"===o?{radius:t.radius??12,radiusPadding:t.radiusPadding}:"callout-rect"===o?{width:t.width,height:t.height}:void 0;return bs(Br,{noteData:{x:i,y:n,dx:l,dy:u,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:o,...r?{subject:r}:{},connector:t.connector||{end:"arrow"},color:h,disable:t.disable,opacity:t.opacity,strokeDasharray:t.strokeDasharray,className:t.className}},"ann-label-"+e)}return bs("g",{children:bs("text",{x:i+l,y:n+u,textAnchor:t.textAnchor||"start",fontSize:t.fontSize||r.typography.labelSize,fill:h,fontFamily:r.typography.fontFamily,fontWeight:t.fontWeight,opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:t.label||t.title})},"ann-label-"+e)}default:return null}}function Rs(t){return"string"==typeof t&&t.length>0}function Ts(t,e){return function(t,e,i=!1){const o=i?e?58:34:e?36:0;return o>t.top?{...t,top:o}:t}(t,Rs(e))}import{jsx as Ls,jsxs as Cs}from"react/jsx-runtime";function $s(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function zs(t,e){if(0===e.categories.length)return;const i=e.position||"right",o=function(t){const{width:e,height:i,swatchSize:o}=Mr(t);return{width:e,height:i,swatchSize:o}}({categories:e.categories,colorScheme:e.colorScheme,theme:e.theme,position:i,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout});"right"===i?t.right=Math.max(t.right,o.width+14):"left"===i?t.left=Math.max(t.left,o.width+14):"top"===i?t.top=Math.max(t.top,(e.hasTitle?32:8)+o.height+4):t.bottom=Math.max(t.bottom,38+o.height+4)}function Ds(t,e){const i=e.position||"right",o={theme:e.theme,position:i,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout},n=so(e.legend)?function(t){const{width:e,height:i,swatchSize:o}=_r(t);return{width:e,height:i,swatchSize:o}}({...o,legendGroups:e.legend.legendGroups}):ao(e.legend)?Pr({...o,gradient:e.legend.gradient}):null;n&&("right"===i?t.right=Math.max(t.right,n.width+14):"left"===i?t.left=Math.max(t.left,n.width+14):"top"===i?t.top=Math.max(t.top,(e.hasTitle?32:8)+n.height+4):t.bottom=Math.max(t.bottom,38+n.height+4))}function Es(t,e){const i={theme:e.theme,position:e.position||"right",totalWidth:e.size[0],totalHeight:e.size[1],margin:e.margin,hasTitle:e.hasTitle,legendLayout:e.legendLayout,idPrefix:e.idPrefix};return so(t)?function(t){if(0===(e=t.legendGroups,e.flatMap(t=>t.items.map((e,i)=>({group:t,item:e,itemIndex:i,label:e.label})))).length)return null;var e;const i=_r(t),o="top"===t.position||"bottom"===t.position,n=t.theme.colors.grid||t.theme.colors.textSecondary;let r,s;"left"===t.position?(r=Math.max(4,t.margin.left-i.width-10),s=t.margin.top):"top"===t.position?(r=t.margin.left,s=t.hasTitle?32:8):"bottom"===t.position?(r=t.margin.left,s=Math.min(t.totalHeight-t.margin.bottom+38,t.totalHeight-i.height-2)):(r=Math.min(t.totalWidth-i.width-4,t.totalWidth-t.margin.right+10),s=t.margin.top);const a=i.groups.flatMap((e,r)=>{const{group:s}=e,a=s.type??"fill",c=[];if(s.label&&c.push(vr("text",o?{transform:`translate(${e.x},${e.y}) rotate(90)`,textAnchor:"start",fontSize:Sr(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:s.label}:{x:e.x,y:e.y+Sr(t.theme),fontSize:Sr(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:s.label},"legend-group-label-"+r)),c.push(...e.items.map((o,n)=>{const c=s.items[n],l=s.styleFn(c,n),u="function"==typeof a?a(c):"line"===a?vr("line",{x1:0,y1:0,x2:i.swatchSize,y2:i.swatchSize,style:l}):vr("rect",{width:i.swatchSize,height:i.swatchSize,rx:i.swatchRadius,style:l});return wr("g",{transform:`translate(${e.x+e.itemOffsetX+o.x},${e.y+e.itemOffsetY+o.y})`,children:[u,vr("text",{x:i.labelOffset,y:i.swatchSize/2,dominantBaseline:"central",fontSize:Sr(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:o.category})]},`legend-${r}-${n}`)})),!o&&i.groups.length-1>r)c.push(vr("line",{x1:0,y1:e.y+e.height-6,x2:i.width,y2:e.y+e.height-6,stroke:n},"legend-group-separator-"+r));else if(o&&i.groups.length-1>r){const t=e.x+e.width+6;c.push(vr("line",{x1:t,y1:0,x2:t,y2:i.height,stroke:n},"legend-group-separator-"+r))}return c});return vr("g",{className:"semiotic-legend",transform:`translate(${r},${s})`,"data-orientation":o?"horizontal":"vertical",children:a})}({...i,legendGroups:t.legendGroups}):ao(t)?function(t){const e=Pr(t),i="top"===t.position||"bottom"===t.position,o=(t.idPrefix?t.idPrefix+"-":"")+"semiotic-static-gradient-legend",n=t.gradient.format||(t=>Math.round(100*t)/100+"");let r,s;"left"===t.position?(r=Math.max(4,t.margin.left-e.width-10),s=t.margin.top):"top"===t.position?(r=t.margin.left,s=t.hasTitle?32:8):"bottom"===t.position?(r=t.margin.left,s=Math.min(t.totalHeight-t.margin.bottom+38,t.totalHeight-e.height-2)):(r=Math.min(t.totalWidth-e.width-4,t.totalWidth-t.margin.right+10),s=t.margin.top);const a=Array.from({length:17},(e,o)=>{const n=o/16;return vr("stop",{offset:100*n+"%",stopColor:t.gradient.colorFn(i?t.gradient.domain[0]+n*(t.gradient.domain[1]-t.gradient.domain[0]):t.gradient.domain[1]-n*(t.gradient.domain[1]-t.gradient.domain[0]))},o)});if(i){const i=12,c=t.gradient.label?0:void 0,l=t.gradient.label?8:0;return wr("g",{className:"semiotic-legend",transform:`translate(${r},${s})`,children:[vr("defs",{children:vr("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),t.gradient.label&&vr("text",{x:e.width/2,y:c,textAnchor:"middle",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:t.gradient.label}),vr("rect",{x:0,y:l,width:e.width,height:i,fill:`url(#${o})`,rx:2}),vr("text",{x:0,y:l+i+12,textAnchor:"start",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:n(t.gradient.domain[0])}),vr("text",{x:e.width,y:l+i+12,textAnchor:"end",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:n(t.gradient.domain[1])})]})}const c=t.gradient.label?-6:void 0;return wr("g",{className:"semiotic-legend",transform:`translate(${r},${s+(t.gradient.label?12:0)})`,children:[vr("defs",{children:vr("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),t.gradient.label&&vr("text",{x:7,y:c,textAnchor:"middle",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:t.gradient.label}),vr("rect",{x:0,y:0,width:14,height:100,fill:`url(#${o})`,rx:2}),vr("text",{x:19,y:10,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:n(t.gradient.domain[1])}),vr("text",{x:19,y:100,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:n(t.gradient.domain[0])})]})}({...i,gradient:t.gradient}):null}function Ns(t){return Math.round(100*t)/100+""}function Is(t,e){const i=io(e.theme),o=e.idPrefix?e.idPrefix+"-":"",n="string"==typeof e.title?e.title:void 0,r=n?o+"semiotic-title":void 0,s=e.description?o+"semiotic-desc":void 0,a=[r,s].filter(Boolean).join(" ")||void 0;return Cs("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,width:e.width,height:e.height,role:"img","aria-labelledby":a,style:{fontFamily:i.fontFamily},children:[n&&Ls("title",{id:r,children:n}),e.description&&Ls("desc",{id:s,children:e.description}),e.defs&&Ls("defs",{children:e.defs}),e.background&&"transparent"!==e.background&&Ls("rect",{x:0,y:0,width:e.width,height:e.height,fill:e.background}),Ls("g",{id:o+"data-area",transform:e.innerTransform,children:t}),n&&Ls("text",{id:o+"chart-title",x:e.width/2,y:22,textAnchor:"middle",fontSize:i.titleSize,fontWeight:"bold",fill:i.text,fontFamily:i.fontFamily,children:n}),e.legend&&Ls("g",{id:o+"legend",children:e.legend}),e.outerElements]})}import{Fragment as Bs,jsx as Fs,jsxs as Os}from"react/jsx-runtime";function Ws(t,e){const i=eo(t.theme),o=t.size||[500,300],n=Ts({top:20,right:20,bottom:30,left:40,...t.margin},t.title),r=Rs(t.title),s=lo(t.data),a=t.showLegend?Tr(s,t.colorAccessor||t.groupAccessor):[],c=t.legendPosition;so(t.legend)||ao(t.legend)?Ds(n,{legend:t.legend,theme:i,position:c||"right",size:o,hasTitle:r,legendLayout:t.legendLayout}):t.showLegend&&a.length>0&&zs(n,{categories:a,colorScheme:t.colorScheme,theme:i,position:c||"right",size:o,hasTitle:r,legendLayout:t.legendLayout});const l=o[0]-n.left-n.right,u=o[1]-n.top-n.bottom,h="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),d=t.colorScheme||i.colors.categorical,f={chartType:t.chartType,windowSize:t.windowSize??200,windowMode:t.windowMode??"sliding",arrowOfTime:h?t.arrowOfTime??"right":"right",extentPadding:t.extentPadding??.1,xAccessor:h?void 0:t.xAccessor,yAccessor:h?void 0:t.yAccessor,timeAccessor:h?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,groupAccessor:t.groupAccessor,categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,sizeRange:t.sizeRange,xScaleType:t.xScaleType,yScaleType:t.yScaleType,scalePadding:t.scalePadding,binSize:t.binSize,normalize:t.normalize,stackOrder:t.stackOrder,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,y0Accessor:t.y0Accessor,areaGroups:t.areaGroups?t.areaGroups instanceof Set?t.areaGroups:new Set(t.areaGroups):void 0,curve:t.curve,gradientFill:!0===t.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===t.gradientFill?void 0:t.gradientFill,lineGradient:t.lineGradient,openAccessor:t.openAccessor,highAccessor:t.highAccessor,lowAccessor:t.lowAccessor,closeAccessor:t.closeAccessor,candlestickStyle:t.candlestickStyle,lineStyle:t.lineStyle,pointStyle:t.pointStyle,areaStyle:t.areaStyle,barStyle:t.barStyle,waterfallStyle:t.waterfallStyle,swarmStyle:t.swarmStyle,colorScheme:d,themeCategorical:i.colors.categorical,themeSemantic:It(i),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,layoutSelection:t.layoutSelection,barColors:t.barColors},p=new Zn(f);if(t.data&&p.ingest({inserts:s,bounded:!0}),p.computeScene({width:l,height:u}),!p.scales||0===p.scene.length)return e&&(e.evidence=ro({frameType:"xy",width:o[0],height:o[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,extraWarnings:p.scales?[]:["NO_SCALES"]})),ho.renderToStaticMarkup(Is(null,{width:o[0],height:o[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:u,idPrefix:t._idPrefix}));e&&(e.evidence=ro({frameType:"xy",width:o[0],height:o[1],marks:p.scene,title:t.title,description:t.description,annotations:t.annotations,xDomain:no(p.scales.x?.domain?.()),yDomain:no(p.scales.y?.domain?.()),legendItems:a.length>0?a.length:void 0}));const y=t._idPrefix,g=t.showGrid?function(t,e,i,o){const{grid:n}=io(i),r=o?o+"-":"",s=t.x.ticks(5),a=t.y.ticks(5);return Cs("g",{id:r+"grid",className:"semiotic-grid",opacity:.8,children:[s.map((i,o)=>{const r=t.x(i);return Ls("line",{x1:r,y1:0,x2:r,y2:e.height,stroke:n,strokeWidth:.5},"gx-"+o)}),a.map((i,o)=>{const r=t.y(i);return Ls("line",{x1:0,y1:r,x2:e.width,y2:r,stroke:n,strokeWidth:.5},"gy-"+o)})]})}(p.scales,{width:l,height:u},i,y):null,m=p.scene.map((e,i)=>xr({node:e,index:i,renderMode:t.renderMode,fallback:()=>yr(e,i,y)})).filter(Boolean),x=!1!==t.showAxes?function(t,e,i,o,n){const r=io(o),s=t.x.ticks(5).map(e=>({pixel:t.x(e),label:(i.xFormat||i.tickFormatTime||Ns)(e)})),a=t.y.ticks(5).map(e=>({pixel:t.y(e),label:(i.yFormat||i.tickFormatValue||Ns)(e)}));return Cs("g",{id:(n?n+"-":"")+"axes",className:"stream-axes",children:[Ls("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:r.border,strokeWidth:1}),s.map((t,i)=>Cs("g",{transform:`translate(${t.pixel},${e.height})`,children:[Ls("line",{y2:5,stroke:r.border,strokeWidth:1}),Ls("text",{y:18,textAnchor:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:t.label})]},"xtick-"+i)),i.xLabel&&Ls("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,children:i.xLabel}),Ls("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:r.border,strokeWidth:1}),a.map((t,e)=>Cs("g",{transform:`translate(0,${t.pixel})`,children:[Ls("line",{x2:-5,stroke:r.border,strokeWidth:1}),Ls("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:t.label})]},"ytick-"+e)),i.yLabel&&Ls("text",{x:15-(i.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,transform:`rotate(-90, ${15-(i.margin?.left??40)}, ${e.height/2})`,children:i.yLabel})]})}(p.scales,{width:l,height:u},t,i,y):null,b=t.annotations?_s({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{x:p.scales.x,y:p.scales.y},layout:{width:l,height:u},theme:i,xAccessor:"string"==typeof t.xAccessor?t.xAccessor:void 0,yAccessor:"string"==typeof t.yAccessor?t.yAccessor:void 0,idPrefix:y}):null,v=t.svgPreRenderers&&p.scales?t.svgPreRenderers.map((t,e)=>{try{return Fs(uo.Fragment,{children:t(p.scene,p.scales,{width:l,height:u})},"pre-"+e)}catch{return null}}).filter(Boolean):null,w=t.showLegend?0===a.length?null:Rr({categories:a,colorScheme:t.colorScheme,theme:i,position:t.legendPosition||"right",totalWidth:o[0],totalHeight:o[1],margin:n,hasTitle:r,legendLayout:t.legendLayout}):null,k=uo.isValidElement(t.legend)?t.legend:Es(t.legend,{theme:i,position:t.legendPosition||"right",size:o,margin:n,hasTitle:r,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||w;return ho.renderToStaticMarkup(Is(Os(Bs,{children:[t.backgroundGraphics,v,g,m,x,b,t.foregroundGraphics,p.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:u,legend:k,idPrefix:t._idPrefix}))}import*as js from"react";import*as Ys from"react-dom/server";import{scaleBand as Xs,scaleLinear as qs}from"d3-scale";var Gs=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(t,e,i){if(e&&"function"==typeof t.pieceStyle){const o=t.pieceStyle(e,i);return o&&!o.fill&&i?{...o,fill:this.getColorFromScheme(t,i)}:o}return t.pieceStyle&&"object"==typeof t.pieceStyle?t.pieceStyle:t.barColors&&i?{fill:t.barColors[i]||"#007bff"}:{fill:i?this.getColorFromScheme(t,i):"#007bff"}}resolveSummaryStyle(t,e,i){return e&&"function"==typeof t.summaryStyle?t.summaryStyle(e,i):t.summaryStyle&&"object"==typeof t.summaryStyle?t.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(t,e){const i=this.colorSchemeMap.get(e);if(i)return i;const o=Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical||S,n=o[this.colorSchemeIndex%o.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(e,n),n}};function Vs(t){const e=t.getSymbol;if(!e)return null;const i=t.config.symbolMap,o=new Map;let n=0;return t=>{const r=e(t)+"",s=i?.[r];if(s)return s;let a=o.get(r);return a||(a=rn[n%rn.length],n++,o.set(r,a)),a}}function Hs(t,e,i,o,n,r,s){t.push(e?{type:"symbol",x:o,y:n,size:Math.PI*r*r,symbolType:e(i),style:s,datum:i}:{type:"point",x:o,y:n,r:r,style:s,datum:i})}function Zs(t,e){const{columns:i,config:o,resolvePieceStyle:n}=t,r=[],s=Math.min(e.width,e.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,l=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI,u=null!=o.sweepAngle&&360>o.sweepAngle,h=Object.values(i),d=h.some(t=>{const e=t.pieceData[0];return e&&("number"==typeof e._pct||"number"==typeof e._pctStart||null!=e._roundedEnds)}),f=u&&!d&&h.length>1&&(o.cornerRadius??0)>0;for(let t=0;h.length>t;t++){const e=h[t],i=e.pieceData[0],u="number"==typeof i?._pctStart?i._pctStart:e.pctStart,d=c+u*l,p=c+(u+("number"==typeof i?._pct?i._pct:e.pct))*l,y=n(e.pieceData[0],e.name),g=0===t,m=t===h.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:d,endAngle:p,...o.cornerRadius&&{cornerRadius:o.cornerRadius},style:y,datum:i?._nonInteractive?null:e.pieceData,category:e.name};i?._roundedEnds?x.roundedEnds=i._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),i?._gradientBand&&(x._gradientBand=i._gradientBand),r.push(x)}return r}import{quantile as Ks}from"d3-array";function Us(t){const e=t.length,i=t[0],o=t[e-1];return{n:e,min:i,q1:Ks(t,.25)??i,median:Ks(t,.5)??(i+o)/2,q3:Ks(t,.75)??o,max:o,mean:t.reduce((t,e)=>t+e,0)/e}}import{scaleLinear as Qs}from"d3-scale";var Js={bar:function(t,e){const{scales:i,columns:o,config:n,getR:r,getStack:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,d="horizontal"===l,f=n.normalize,p=[];if(s){const t=new Set;for(const e of Object.values(o))for(const i of e.pieceData){const e=s(i);t.has(e)||(t.add(e),p.push(e))}}else p.push("_default");for(const t of Object.values(o)){const e=new Map;for(const i of t.pieceData){const t=s?s(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=r(i),o.pieces.push(i)}let i=0;if(f)for(const t of e.values())i+=Math.abs(t.total);let o=0,n=0;for(const r of p){const l=e.get(r);if(!l)continue;let p=l.total;f&&i>0&&(p/=i);const y=a(l.pieces[0],s?r:t.name),g={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name};if(h){const e=c(0>p?n:o+p),i=0>p?c(n+p)-c(n):c(o)-c(o+p);u.push(Bo(t.x,e,t.width,Math.abs(i),y,g,r)),0>p?n+=p:o+=p}else if(d){const e=c(0>p?n+p:o),i=0>p?c(n)-c(n+p):c(o+p)-c(o);u.push(Bo(e,t.x,Math.abs(i),t.width,y,g,r)),0>p?n+=p:o+=p}}}const y="vertical"===l,g=n.roundedTop&&n.roundedTop>0?Math.max(0,n.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;const e=t.datum?.__aggregateValue??0;t.roundedEdge=y?0>e?"bottom":"top":0>e?"left":"right",n.gradientFill&&(t.fillGradient=n.gradientFill)}if(g>0){const t=new Map;for(const e of u){if("rect"!==e.type)continue;const i=e.datum?.category||"";t.has(i)||t.set(i,[]),t.get(i).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>(t.datum?.__aggregateValue??0)>=0),i=e.filter(t=>0>(t.datum?.__aggregateValue??0));t.length>0&&(t.reduce(y?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=g),i.length>0&&(i.reduce(y?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=g)}}return u},clusterbar:function(t,e){const{scales:i,columns:o,config:n,getR:r,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,d=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),d.push(t))}const p=d.length||1;for(const t of Object.values(o)){const e=t.width/p,i=.2*e,o=e-i,n=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";n.has(t)||n.set(t,[]),n.get(t).push(e)}for(let s=0;d.length>s;s++){const l=n.get(d[s])||[];for(const n of l){const l=r(n),f=a(n,d[s]);if(h){const r=t.x+s*e+i/2,a=c(0),h=c(l);u.push(Bo(r,Math.min(a,h),o,Math.abs(a-h),f,n,d[s]))}else{const r=t.x+s*e+i/2,a=c(0),h=c(l);u.push(Bo(Math.min(a,h),r,Math.abs(h-a),o,f,n,d[s]))}}}}const y=n.roundedTop&&n.roundedTop>0?Math.max(0,n.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=r(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=h?0>e?"bottom":"top":0>e?"left":"right",n.gradientFill&&(t.fillGradient=n.gradientFill)}return u},point:function(t,e){const{scales:i,columns:o,getR:n,multiScales:r,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h="radial"===c,d=r.length>0,f=Vs(t),p=2*Math.PI,y=-Math.PI/2;for(const t of Object.values(o))for(const e of t.pieceData){const i=e.__rIndex??0,o=e.__rValue??n(e),c=d&&r[i]||a,g=s(e,t.name),m=g.r||5;let x,b;if(h){const e=y+(t.pctStart+t.pct/2)*p,i=c(o);x=Math.cos(e)*i,b=Math.sin(e)*i}else u?(x=t.middle,b=c(o)):(x=c(o),b=t.middle);Hs(l,f,e,x,b,m,g)}return l},swarm:function(t,e){const{scales:i,columns:o,getR:n,resolvePieceStyle:r}=t,{r:s,projection:a}=i,c=[],l="vertical"===a,u=Vs(t);for(const t of Object.values(o)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const o=t.pieceData[i],a=n(o),h=r(o,t.name),d=h.r||4,f=(7919*i%100/100-.5)*e*.8;Hs(c,u,o,l?t.middle+f:s(a),l?s(a):t.middle+f,d,h)}}return c},pie:Zs,donut:Zs,boxplot:function(t,e){const{scales:i,columns:o,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h=!1!==n.showOutliers;for(const e of Object.values(o)){const i=e.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===i.length)continue;const o=i[0],n=i[i.length-1],c=Ks(i,.25)??o,d=Ks(i,.5)??(o+n)/2,f=Ks(i,.75)??n,p=f-c,y=c-1.5*p,g=f+1.5*p,m=i.find(t=>t>=y)??o,x=[...i].reverse().find(t=>g>=t)??n,b=s(e.pieceData[0],e.name),v=[];if(h)for(const t of e.pieceData){const i=r(t);if(y>i||i>g){const o=u?e.middle:a(i),n=u?a(i):e.middle;v.push({px:o,py:n,value:i,datum:t})}}if(l.push({type:"boxplot",x:u?e.middle:0,y:u?0:e.middle,projection:u?"vertical":"horizontal",columnWidth:.6*e.width,minPos:a(m),q1Pos:a(c),medianPos:a(d),q3Pos:a(f),maxPos:a(x),stats:{n:i.length,min:m,q1:c,median:d,q3:f,max:x,mean:i.reduce((t,e)=>t+e,0)/i.length},style:b,datum:e.pieceData,category:e.name,outliers:v}),h)for(const e of v)l.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:b.fill||t.config.themeSemantic?.secondary||"#999",opacity:.6},datum:e.datum})}return l},violin:function(t,e){const{scales:i,columns:o,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h=n.bins||20,d=!1!==n.showIQR;for(const t of Object.values(o)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const i=e[0],o=e[e.length-1],n=(o-i)/h||1,c=Array(h).fill(0);for(const t of e)c[Math.min(Math.floor((t-i)/n),h-1)]++;const f=st(c,1),p=t.width/2*.9;let y;if(u){y=`M ${t.middle} ${a(i)}`;for(let e=0;h>e;e++){const o=a(i+(e+.5)*n);y+=` L ${t.middle+c[e]/f*p} ${o}`}y+=` L ${t.middle} ${a(o)}`;for(let e=h-1;e>=0;e--){const o=a(i+(e+.5)*n);y+=` L ${t.middle-c[e]/f*p} ${o}`}y+=" Z"}else{y=`M ${a(i)} ${t.middle}`;for(let e=0;h>e;e++)y+=` L ${a(i+(e+.5)*n)} ${t.middle-c[e]/f*p}`;y+=` L ${a(o)} ${t.middle}`;for(let e=h-1;e>=0;e--)y+=` L ${a(i+(e+.5)*n)} ${t.middle+c[e]/f*p}`;y+=" Z"}const g=s(t.pieceData[0],t.name);let m;if(d&&e.length>=4){const n=Ks(e,.25)??i,r=Ks(e,.5)??(i+o)/2,s=Ks(e,.75)??o;m={q1Pos:a(n),medianPos:a(r),q3Pos:a(s),centerPos:t.middle,isVertical:u}}const x=u?{x:t.x,y:Math.min(a(o),a(i)),width:t.width,height:Math.abs(a(o)-a(i))}:{x:Math.min(a(i),a(o)),y:t.x,width:Math.abs(a(o)-a(i)),height:t.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:Us(e),style:g,datum:t.pieceData,category:t.name})}return l},histogram:function(t,e){const{scales:i,columns:o,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a}=i,c=[],l=n.bins||25,u=n.normalize,h=a.domain?.(),d=h?+h[0]:void 0,f=h?+h[1]:void 0;for(const t of Object.values(o)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const[i,o]=rt(e),n=null!=d&&isFinite(d)?d:i,h=null!=f&&isFinite(f)?f:o,p=(h-n)/l||1,y=Array(l).fill(0);for(const t of e)n>t||t>h||y[Math.min(Math.floor((t-n)/p),l-1)]++;const g=e.length,m=st(y,1),x=s(t.pieceData[0],t.name);for(let e=0;l>e;e++){if(0===y[e])continue;const i=(u?y[e]/g:y[e]/m)*t.width*.9,o=a(n+e*p),r=a(n+(e+1)*p);c.push(Bo(Math.min(o,r),t.x+t.width-i,Math.abs(r-o),i,x,{bin:e,count:y[e],range:[n+e*p,n+(e+1)*p],category:t.name},t.name))}}return c},ridgeline:function(t,e){const{scales:i,columns:o,config:n,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:c}=i,l=[],u=n.bins||20,h="horizontal"===c,d=n.amplitude||1.5;for(const t of Object.values(o)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const i=e[0],o=e[e.length-1],n=(o-i)/u||1,c=Array(u).fill(0);for(const t of e)i>t||t>o||c[Math.min(Math.floor((t-i)/n),u-1)]++;const f=st(c,1),p=s(t.pieceData[0],t.name),y=t.width*d;let g;if(h){const e=t.x+t.width;g=`M ${a(i)} ${e}`;for(let t=0;u>t;t++)g+=` L ${a(i+(t+.5)*n)} ${e-c[t]/f*y}`;g+=` L ${a(o)} ${e} Z`}else{const e=t.x;g=`M ${e} ${a(i)}`;for(let t=0;u>t;t++){const o=a(i+(t+.5)*n);g+=` L ${e+c[t]/f*y} ${o}`}g+=` L ${e} ${a(o)} Z`}const m=h?{x:Math.min(a(i),a(o)),y:t.x,width:Math.abs(a(o)-a(i)),height:t.width}:{x:t.x,y:Math.min(a(o),a(i)),width:t.width,height:Math.abs(a(o)-a(i))};l.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:m,stats:Us(e),style:{...p,fillOpacity:p.fillOpacity??.5},datum:t.pieceData,category:t.name})}return l},timeline:function(t,e){const{scales:i,columns:o,getRawRange:n,resolvePieceStyle:r}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const i=n(e);if(!i)continue;const[o,a]=i,u=r(e,t.name);if(l){const i=s(Math.min(o,a)),n=s(Math.max(o,a));c.push(Bo(i,t.x,n-i,t.width,u,e,t.name))}else{const i=s(Math.max(o,a)),n=s(Math.min(o,a));c.push(Bo(t.x,i,t.width,n-i,u,e,t.name))}}return c},funnel:function(t,e){const{columns:i,getR:o,getStack:n,resolvePieceStyle:r}=t,s=[],a=e.width/2,c=!1!==t.config.showLabels,l=t.scales.o.domain().map(t=>i[t]).filter(Boolean);if(0===l.length)return s;const u=[],h=new Set;for(const t of l)for(const e of t.pieceData){const t=n?n(e):"_default";h.has(t)||(h.add(t),u.push(t))}const d=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const t of l){const e=new Map;let i=0;for(const r of t.pieceData){const t=n?n(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const s=e.get(t),a=o(r);s.total+=a,s.pieces.push(r),i+=a}f.push({col:t,groups:e,stepTotal:i}),d||i>p&&(p=i)}if(d)for(const t of f){let e=0,i=0;for(let o=0;u.length>o;o++){const n=t.groups.get(u[o]);n&&(o%2==0?e+=n.total:i+=n.total)}const o=Math.max(e,i);o>p&&(p=o)}if(0===p)return s;const y=new Map;for(const t of u){const e=f[0].groups.get(t);y.set(t,e?.total??0)}const g=f[0].stepTotal,m=d?.95*a:.9*e.width,x=Qs().domain([0,p]).range([0,m]),b=t.config.connectorOpacity??.3;let v=new Map;for(let e=0;f.length>e;e++){const i=f[e],o=i.col,n=0===e,l=o.width,h=.55*l,p=o.x+(l-h)/2,m=new Map;if(d){let t=0;for(const e of u){const o=i.groups.get(e);o&&(t+=x(o.total))}let e=a,l=a;for(let d=0;u.length>d;d++){const f=u[d],g=i.groups.get(f);if(!g)continue;const b=x(g.total),v=d%2==0,w=v?e:l-b;v?e+=b:l-=b;const k=r(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:o.name,__funnelIsFirstStep:n,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};c&&(0===d&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=p,A.__funnelRowWidth=t),A.__funnelValueLabelX=w+b/2,A.__funnelValueLabelY=p,A.__funnelBarW=b),s.push(Bo(w,p,b,h,k,A,f)),m.set(f,{x:w,y:p,w:b,h:h})}}else{const t=i.stepTotal,e=x(t),l=a-e/2,d=u[0],f="_default"!==d,y=i.groups.get(d)?.pieces[0]??o.pieceData[0],b=f?d:o.name,v=r(y,b),w=g>0?t/g*100:0,k={...y,__funnelValue:t,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:n,category:f?d:o.name};c&&(k.__funnelStepLabel=o.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=e,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=e),s.push(Bo(l,p,e,h,v,k,b)),m.set(d,{x:l,y:p,w:e,h:h})}if(e>0&&v.size>0){const e=d?u:[u[0]];for(const n of e){const e=v.get(n),a=m.get(n);if(!e||!a)continue;const c=(()=>{const t=i.groups.get(n);return r(t?t.pieces[0]:o.pieceData[0],"_default"===n?o.name:n)})(),l={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:c.fill||t.config.themeSemantic?.secondary||"#999",opacity:b},datum:i.groups.get(n)?.pieces[0]??o.pieceData[0],category:"_default"===n?o.name:n};s.push(l)}}v=m}return s},"bar-funnel":function(t,e){const{columns:i,getR:o,getStack:n,resolvePieceStyle:r,scales:s}=t,a=[],c=s.o.domain().map(t=>i[t]).filter(Boolean);if(0===c.length)return a;const l=[],u=new Set;for(const t of c)for(const e of t.pieceData){const t=n?n(e):"_default";u.has(t)||(u.add(t),l.push(t))}const h=l.length>1&&"_default"!==l[0],d=[];for(const t of c){const e=new Map;let i=0;for(const r of t.pieceData){const t=n?n(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const s=e.get(t),a=o(r);s.total+=a,s.pieces.push(r),i+=a}d.push({col:t,groups:e,stepTotal:i})}const f=new Map;for(const t of l){const e=d[0]?.groups.get(t);f.set(t,e?.total??0)}const p=s.r,y=h?l.length:1,g=h?.15:0;for(let t=0;d.length>t;t++){const e=d[t],i=e.col,o=0===t,n=t>0?d[t-1]:null,s=i.width/y,c=s*g,u=s-c;for(let t=0;l.length>t;t++){const d=l[t],y=e.groups.get(d);if(!y)continue;const g=y.total,m=f.get(d)??g,x=m>0?g/m*100:0,b=n?.groups.get(d),v=o?0:Math.max(0,(b?.total??g)-g),w=i.x+t*s+c/2,k=p(g),S=p(0)-k,A=r(y.pieces[0],h?d:i.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:i.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(Bo(w,k,u,S,A,M,h?d:i.name)),v>0){const t=p(g+v),e=k-t,o={...A},n={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:i.name};a.push(Bo(w,t,u,e,o,n,h?d:i.name))}}}return a},swimlane:function(t,e){const{scales:i,columns:o,getR:n,getStack:r,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="horizontal"===c,h=t.config.gradientFill,d=u?"left":"bottom",f=t.config.trackFill;if(f){const t="string"==typeof f?f:f.color,e="string"==typeof f?1:f.opacity??1,[i,n]=a.range(),r=Math.min(i,n),s=Math.abs(n-i);for(const i of Object.values(o)){const o={fill:t,opacity:e},n=u?Bo(r,i.x,s,i.width,o,null,"__track__"):Bo(i.x,r,i.width,s,o,null,"__track__");l.push(n)}}const p=t.config.roundedTop&&t.config.roundedTop>0?Math.max(0,t.config.roundedTop):0;for(const t of Object.values(o)){let e=0;const i=l.length;for(const i of t.pieceData){const o=Math.abs(n(i));if(0===o)continue;const c=r?r(i):t.name,f=s(i,c);let p;if(u){const n=a(e),r=a(e+o);p=Bo(n,t.x,r-n,t.width,f,i,c)}else{const n=a(e+o),r=a(e);p=Bo(t.x,n,t.width,r-n,f,i,c)}h&&(p.fillGradient=h,p.roundedEdge=d),l.push(p),e+=o}if(p>0&&l.length>i){const t=l.slice(i),e=t[0],o=t[t.length-1];1===t.length?e.cornerRadii={tl:p,tr:p,br:p,bl:p}:u?(e.cornerRadii={tl:p,bl:p},o.cornerRadii={tr:p,br:p}):(e.cornerRadii={bl:p,br:p},o.cornerRadii={tl:p,tr:p})}}return l}},ta=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ea=["scene-style","data-paint","accessibility","evidence"],ia=(t,e)=>({retainedData:t,invalidations:e}),oa=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],na=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ra=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],sa=["scene-geometry","data-paint","accessibility","evidence"],aa=["scene-style","data-paint","accessibility","evidence"],ca=[],la={chartType:ia("rebuild",oa),runtimeMode:ia("rebuild",oa),categoryAccessor:ia("rebuild",oa),valueAccessor:ia("rebuild",oa),oAccessor:ia("rebuild",oa),rAccessor:ia("rebuild",oa),stackBy:ia("rebuild",oa),groupBy:ia("rebuild",oa),timeAccessor:ia("rebuild",oa),accessorRevision:ia("rebuild",oa),colorAccessor:ia("rebuild",aa),symbolAccessor:ia("rebuild",sa),connectorAccessor:ia("rebuild",sa),dataIdAccessor:ia("rebuild",sa),projection:ia("preserve",na),extentPadding:ia("preserve",na),axisExtent:ia("preserve",na),rExtent:ia("preserve",na),oExtent:ia("preserve",na),multiAxis:ia("preserve",na),normalize:ia("preserve",na),bins:ia("preserve",na),oSort:ia("preserve",ra),barPadding:ia("preserve",ra),roundedTop:ia("preserve",ra),baselinePadding:ia("preserve",ra),innerRadius:ia("preserve",ra),cornerRadius:ia("preserve",ra),startAngle:ia("preserve",ra),sweepAngle:ia("preserve",ra),trackFill:ia("preserve",ra),showOutliers:ia("preserve",ra),showIQR:ia("preserve",ra),amplitude:ia("preserve",ra),connectorOpacity:ia("preserve",ra),showLabels:ia("preserve",ra),dynamicColumnWidth:ia("rebuild",ra),customLayout:ia("preserve",ra),layoutConfig:ia("preserve",ra),layoutMargin:ia("preserve",ra),symbolMap:ia("preserve",sa),pieceStyle:ia("preserve",aa),summaryStyle:ia("preserve",aa),connectorStyle:ia("preserve",aa),gradientFill:ia("preserve",aa),colorScheme:ia("preserve",aa),themeCategorical:ia("preserve",aa),themeSemantic:ia("preserve",aa),themeSequential:ia("preserve",aa),themeDiverging:ia("preserve",aa),barColors:ia("preserve",aa),decay:ia("preserve",aa),pulse:ia("preserve",aa),staleness:ia("preserve",aa),layoutSelection:ia("preserve",aa),windowSize:ia("preserve",ca),windowMode:ia("preserve",ca),clock:ia("preserve",ca),transition:ia("preserve",ca),introAnimation:ia("preserve",ca),onLayoutError:ia("preserve",ca)},ua=ia("preserve",ra),ha=class{constructor(){this.tracker=new ci}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},ta)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},ea):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const i=new Set;for(const o of t){const t=la[o]??ua;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}};import{quadtree as da}from"d3-quadtree";var fa=class{constructor(t){this.rExtent=new po,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new ha,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new Gs,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=t,this.buffer=new fo(t.windowSize),this.getO=xo(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>go(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new po)):(this.getR=go(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=xo(t.stackBy),this.getGroup=xo(t.groupBy),this.getColor=xo(t.colorAccessor),this.getSymbol=xo(t.symbolAccessor),this.getConnector=xo(t.connectorAccessor),this.getDataId=xo(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new fo(t.windowSize))}syncPulseTimestampBuffer(){var t,e,i,o;this.timestampBuffer=(t=!!this.config.pulse,e=this.buffer,i=this.timestampBuffer,o=this.currentTime(),t?null!=i&&i.capacity===e.capacity&&i.size===e.size?i:kn(e,o):null)}currentTime(){return this.config.clock?.()??_o()}ingest(t){const e=this.currentTime();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),wn(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const i of t.inserts)Sn(this.buffer,i,this.timestampBuffer,e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=Sn(this.buffer,i,this.timestampBuffer,e);this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}}return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.valueAccessor||this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:e,buffer:i}=this,o=this.scales,n=this.multiScales,r=this.columns;if(0===i.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(i,this.getR);const s=this.getBufferArray(),a=e.projection||"vertical",c=e.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,h="radial"===a,d=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===a?t.width:t.height):.1));let f,p;if(h){f=Xs().domain(c).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,o=e.innerRadius||0;p=qs().domain(l).range([o,i])}else u?(f=Xs().domain(c).range([0,t.height]).padding(d),p=qs().domain(l).range([0,t.width])):(f=Xs().domain(c).range([0,t.width]).padding(d),p=qs().domain(l).range([t.height,0]));this.scales={o:f,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((o,n)=>{const r=this.rExtents[n];r.dirty&&r.recalculate(i,o);let[s,a]=r.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(e.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?qs().domain([s,a]).range([0,t.width]):qs().domain([s,a]).range([t.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(t=>this.rAccessors.map((e,i)=>({...t,__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(y,c,f,a,t),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,t);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.multiScales=n,this.columns=r):(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(t){const e=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(e)?e[t]:e;return"string"==typeof i?i:"value"+t}resolveCategories(t){const e=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let n=null;if(i){n=new Set;for(const e of t)n.add(this.getO(e))}const r=n?Array.from(this.categories).filter(t=>n.has(t)):Array.from(this.categories);if(i&&void 0===o){const t=Math.max(50,3*n.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;n.has(t)||(this.categories.delete(t),e--)}}return r}if(!1===o)return r;if("function"==typeof o)return r.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return r.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){return function(t){const{data:e,chartType:i,projection:o,normalize:n,rExtent:r,extentPadding:s=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:h,rawRExtent:d}=t,f=s;if("radial"===o&&("pie"===i||"donut"===i))return[0,1];let p=0,y=0;if("bar"===i&&h&&n)p=0,y=1;else if("bar"===i&&h){const t=new Map,i=new Map;for(const o of e){const e=l(o),n=u(o);0>n?i.set(e,(i.get(e)||0)+n):t.set(e,(t.get(e)||0)+n)}for(const e of t.values())e>y&&(y=e);for(const t of i.values())p>t&&(p=t)}else if("bar"===i){const t=new Map;for(const i of e){const e=l(i),o=u(i);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>y&&(y=e),p>e&&(p=e)}else if("swimlane"===i){const t=new Map;for(const i of e){const e=l(i),o=Math.abs(u(i));t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>y&&(y=e)}else if("clusterbar"===i||"bar-funnel"===i)for(const t of e){const e=u(t);e>y&&(y=e),p>e&&(p=e)}else{const t=d[0],e=d[1];t!==1/0&&(p=t),e!==-1/0&&(y=e)}r&&(null!=r[0]&&(p=r[0]),null!=r[1]&&(y=r[1]));const g="bar"===i||"clusterbar"===i||"bar-funnel"===i||"swimlane"===i;if(g&&null==r?.[0]&&null==r?.[1]&&(p>0&&(p=0),0>y&&(y=0)),"bar-funnel"!==i&&"exact"!==c){const t=y-p,e=t>0?t*f:1,o=g&&!a&&0===p,n=g&&!a&&0===y||"swimlane"===i;null!=r?.[0]||o||(p-=e),null!=r?.[1]||n||(y+=e)}return[p,y]}({data:t,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(t,e,i,o,n){return function(t){const{data:e,oExtent:i,oScale:o,projection:n,layout:r,dynamicColumnWidth:s,getO:a,getR:c}=t,l={},u=new Map;for(const t of e){const e=a(t);u.has(e)||u.set(e,[]),u.get(e).push(t)}let h=0;if("radial"===n)for(const t of e)h+=Math.abs(c(t));let d=null;if(s&&"radial"!==n){d=new Map;let t=0;for(const e of i){const i=u.get(e)||[];let o;o="string"==typeof s?i.reduce((t,e)=>t+(Number(e[s])||0),0):s(i),d.set(e,o),t+=o}const e=("horizontal"===n?r.height:r.width)-o.padding()*o.step()*i.length;if(t>0)for(const[i,o]of d)d.set(i,o/t*e)}let f=0,p=0;for(const t of i){const e=u.get(t)||[],i=e.reduce((t,e)=>t+Math.abs(c(e)),0),n=h>0?i/h:0;let r,s;d?(r=p,s=d.get(t)||o.bandwidth(),p+=s+o.padding()*o.step()):(r=o(t)??0,s=o.bandwidth()),l[t]={name:t,x:r,y:0,width:s,middle:r+s/2,padding:o.padding()*o.step(),pieceData:e,pct:n,pctStart:f},f+=n}return l}({data:t,oExtent:e,oScale:i,projection:o,layout:n,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:(t,e)=>this.styleResolver.resolvePieceStyle(this.config,t,e),resolveSummaryStyle:(t,e)=>this.styleResolver.resolveSummaryStyle(this.config,t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];if(this.config.customLayout){const i=this.buildLayoutContext(t,e);let o;try{o=this.config.customLayout(i)}catch(t){const e=null!==this.lastCustomLayoutResult,i=dn("ordinal",t,e,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t);try{this.config.onLayoutError?.(i)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?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 n=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of n)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(n,this.config.layoutSelection??null)}return ln({label:"ordinal customLayout",nodes:n,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),n}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const i=this.getSceneContext(),o=Js[this.config.chartType];let n=o?o(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:o,getConnector:n,getO:r}=t;if(!n||!i)return[];const s=[],{projection:a}=i,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=n(e);if(!i)continue;let o,s;"point"===t.type?(o=t.x,s=t.y):(o=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:o,y:s,datum:e,category:r(e)})}const l=i.o.domain(),u=o.connectorStyle;for(const[e,i]of c)if(i.length>=2){i.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let o=0;i.length-1>o;o++){const n=i[o],r=i[o+1],a="function"==typeof u?u(n.datum):u||{stroke:t.config.themeSemantic?.border||t.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:n.x,y1:n.y,x2:r.x,y2:r.y,style:a,datum:n.datum,group:e})}}return s}(i,n);n=[...t,...n]}return n}buildLayoutContext(t,e){const i=this.config,o=i.layoutMargin??{top:0,right:0,bottom:0,left:0},n=Wi(i.colorScheme,i.themeCategorical,S),r=this.scales;return{data:t,scales:{o:r.o,r:r.r,projection:r.projection},dimensions:{width:e.width,height:e.height,margin:o,plot:"radial"===r.projection?{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height}:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:i.themeSemantic??{},categorical:[...n]},resolveColor:ji(n,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?Po(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=Ro(t);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=function(t,e){const i="function"==typeof e,o=i?null:e||"category",n=new Map;for(let r=0;t.length>r;r++){const s=t[r],a=i?e(s):s[o],c=n.get(a);c?c.push(r):n.set(a,[r])}return n}(t,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:e},e}rebuildPointQuadtree(){const t=function(t){let e=0,i=0;for(const o of t)"point"===o.type&&(e++,o.r>i&&(i=o.r));if(500>=e)return{quadtree:null,maxRadius:i};const o=Array(e);let n=0;for(const e of t)"point"===e.type&&(o[n++]=e);return{maxRadius:i,quadtree:da().x(t=>t.x).y(t=>t.y).addAll(o)}}(this.scene);this._pointQuadtree=t.quadtree,this._maxPointRadius=t.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){if(!this.config.decay)return;const i=e.length;if(1>=i)return;const o=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;if(!e.datum)continue;const t=o.get(e.datum);if(null==t)continue;const n=this.computeDecayOpacity(t,i);e.style={...e.style,opacity:(e.style?.opacity??1)*n}}}applyPulse(t,e,i=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,i,o,n,r){const s=t.color??"rgba(255,255,255,0.6)",a=t.glowRadius??4;let c=!1;for(const l of e){if("connector"===l.type||"violin"===l.type||"boxplot"===l.type)continue;if("wedge"===l.type){const e=l.category;if(!e)continue;let o=0;for(const s of n(e)??[]){const e=i.get(s);null!=e&&(o=Math.max(o,To(t,e,r)))}c=Lo(l,o,s)||c;continue}if(null==l.datum)continue;const e=o.get(l.datum);if(null==e)continue;const u=i.get(e);c=Lo(l,null==u?0:To(t,u,r),s,a)||c}return c}(this.config.pulse,t,this.timestampBuffer,this.getDatumIndexMap(e),t=>this.getCategoryIndexMap(e).get(t),i)}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&Co(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();const t=new Map,e=this.scales?.r(0)??0,i="horizontal"!==this.scales?.projection;let o;for(let n=0;this.scene.length>n;n++){const r=this.scene[n],s=this.getNodeKey(r,t);s&&("rect"===r.type?this.prevPositionMap.set(s,i?{x:r.x,y:e,w:r.w,h:0,opacity:r.style.opacity??1}:{x:e,y:r.y,w:0,h:r.h,opacity:r.style.opacity??1}):"point"===r.type?this.prevPositionMap.set(s,{x:r.x,y:r.y,r:0,opacity:0}):"wedge"===r.type&&(void 0===o&&(o=r.startAngle),this.prevPositionMap.set(s,{x:r.cx,y:r.cy,startAngle:o,endAngle:o,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0})))}}getNodeKey(t,e){if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(i)||0;return e.set(i,o+1),`${i}:${o}`}return"rect"===t.type?`r:${t.group||""}:${t.datum?.category??""}`:"wedge"===t.type?"w:"+(t.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const t=new Map;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],o=this.getNodeKey(i,t);o&&("point"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"wedge"===i.type&&this.prevPositionMap.set(o,{x:i.cx,y:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:i.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const t=this.config.transition.duration??300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let e=!1;const i=new Set,o=new Map;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],r=this.getNodeKey(n,o);if(!r)continue;n._transitionKey=r;const s=this.prevPositionMap.get(r);if("point"===n.type)s?(i.add(r),n._targetOpacity=n.style.opacity??1,(s.x!==n.x||s.y!==n.y||void 0!==s.r&&s.r!==n.r)&&(n._targetX=n.x,n._targetY=n.y,n._targetR=n.r,n.x=s.x,n.y=s.y,void 0!==s.r&&(n.r=s.r),e=!0)):(n._targetOpacity=n.style.opacity??1,n._targetR=n.r,n.r=0,n.style={...n.style,opacity:0},e=!0);else if("rect"===n.type)s?(i.add(r),n._targetOpacity=n.style.opacity??1,s.x===n.x&&s.y===n.y&&s.w===n.w&&s.h===n.h||(n._targetX=n.x,n._targetY=n.y,n._targetW=n.w,n._targetH=n.h,n.x=s.x,n.y=s.y,n.w=s.w??n.w,n.h=s.h??n.h,e=!0)):(n._targetOpacity=n.style.opacity??1,n.style={...n.style,opacity:0},e=!0);else if("wedge"===n.type)if(s)i.add(r),n._targetOpacity=n.style.opacity??1,s.startAngle===n.startAngle&&s.endAngle===n.endAngle||(n._targetStartAngle=n.startAngle,n._targetEndAngle=n.endAngle,n.startAngle=s.startAngle,n.endAngle=s.endAngle,e=!0);else{n._targetOpacity=n.style.opacity??1,n._targetStartAngle=n.startAngle,n._targetEndAngle=n.endAngle;const t=n.startAngle;n.startAngle=t,n.endAngle=t,n.style={...n.style,opacity:0},this.prevPositionMap.set(r,{x:n.cx,y:n.cy,startAngle:t,endAngle:t,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:0}),e=!0}}this.exitNodes=[];for(const[t,o]of this.prevPositionMap)if(!i.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:o.x,y:o.y,r:o.r??3,style:{opacity:o.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:o.x,y:o.y,w:o.w??0,h:o.h??0,style:{opacity:o.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const e=((o.startAngle??0)+(o.endAngle??0))/2,i={type:"wedge",cx:o.x,cy:o.y,innerRadius:o.innerRadius??0,outerRadius:o.outerRadius??100,startAngle:o.startAngle??0,endAngle:o.endAngle??0,style:{opacity:o.opacity??1},datum:null,category:t.slice(2),_targetStartAngle:e,_targetEndAngle:e,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(i)}e=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),e&&(this.activeTransition={startTime:this.currentTime(),duration:t})}advanceTransition(t){if(!this.activeTransition)return!1;const e=Ao(t,this.activeTransition),i=So(e,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style.opacity=Mo(o?o.opacity??1:0,t._targetOpacity,i)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=Mo(o.x,t._targetX,i),t.y=Mo(o.y,t._targetY,i)),void 0!==t._targetR&&void 0!==o?.r&&(t.r=Mo(o.r,t._targetR,i))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style.opacity=Mo(o?o.opacity??1:0,t._targetOpacity,i)}if(void 0===t._targetX)continue;const o=this.prevPositionMap.get(e);if(!o)continue;t.x=Mo(o.x,t._targetX,i),t.y=Mo(o.y,t._targetY,i),void 0!==o.w&&(t.w=Mo(o.w,t._targetW,i),t.h=Mo(o.h,t._targetH,i))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style={...t.style,opacity:Mo(o?o.opacity??1:0,t._targetOpacity,i)}}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const o=this.prevPositionMap.get(e);o&&void 0!==o.startAngle&&(t.startAngle=Mo(o.startAngle,t._targetStartAngle,i),t.endAngle=Mo(o.endAngle,t._targetEndAngle,i))}}}if(e>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style={...t.style||{},opacity:0===t._targetOpacity?0:t._targetOpacity},t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX&&void 0===t._targetR)continue;void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY),void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0);if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),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()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=ko(t),i=this.getDataId,o=t=>e.has(i(t));An(this.buffer,this.timestampBuffer,o);const n=this.buffer.remove(o);if(0===n.length)return this.updateResults.recordNoop("remove"),n;for(const t of n)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length),n}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=ko(t),o=this.getDataId,n=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&n.add(e)});const r=this.buffer.update(t=>i.has(o(t)),e);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),n.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),r}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.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(t,e){const i=this._customRestyle;if(i)for(const o of t){const t=this._baseStyles.get(o)??o.style??{},n=i(o,e);o.style=n?{...t,...n}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();this._categoryIndexCache=null,this.buffer.forEach(t=>{this.categories.add(this.getO(t)),this.pushValueExtent(t)})}updateConfig(t){const e={...this.config},i=Object.keys(t).filter(i=>t[i]!==e[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.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 t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!yo(t.colorAccessor,e.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in t&&!yo(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!yo(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();let o=!1;("categoryAccessor"in t||"oAccessor"in t)&&(yo(this.config.categoryAccessor||this.config.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=xo(this.config.categoryAccessor||this.config.oAccessor,"category"),o=!0));let n=!1;if("valueAccessor"in t||"rAccessor"in t){const t=this.config.valueAccessor||this.config.rAccessor,i=e.valueAccessor||e.rAccessor,o=Array.isArray(t)?t:[t],r=Array.isArray(i)?i:[i];if(n=o.length!==r.length||o.some((t,e)=>!yo(t,r[e])),n){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>go(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new po)):(this.getR=go(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!yo(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?xo(this.config.stackBy):void 0),"groupBy"in t&&!yo(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?xo(this.config.groupBy):void 0),"colorAccessor"in t&&!yo(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?xo(this.config.colorAccessor):void 0),"symbolAccessor"in t&&!yo(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?xo(this.config.symbolAccessor):void 0),"connectorAccessor"in t&&!yo(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?xo(this.config.connectorAccessor):void 0),(o||n||"accessorRevision"in t&&t.accessorRevision!==e.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(i)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};$n(fa);import{jsx as pa,jsxs as ya}from"react/jsx-runtime";import{Fragment as ga,jsx as ma,jsxs as xa}from"react/jsx-runtime";function ba(t,e){const i=eo(t.theme),o=t.size||[500,400],n=Ts({top:20,right:20,bottom:30,left:40,...t.margin},t.title),r=Rs(t.title),s=lo(t.data),a=t.showLegend?Tr(s,t.colorAccessor||t.stackBy||t.groupBy):[],c=t.legendPosition;so(t.legend)||ao(t.legend)?Ds(n,{legend:t.legend,theme:i,position:c||"right",size:o,hasTitle:r,legendLayout:t.legendLayout}):t.showLegend&&a.length>0&&zs(n,{categories:a,colorScheme:t.colorScheme,theme:i,position:c||"right",size:o,hasTitle:r,legendLayout:t.legendLayout});const l=o[0]-n.left-n.right,u=o[1]-n.top-n.bottom,h=t.projection||"vertical",d="radial"===h,f={chartType:t.chartType,windowSize:t.windowSize??1e4,windowMode:t.windowMode??"sliding",extentPadding:t.extentPadding??.05,projection:h,oAccessor:t.oAccessor,rAccessor:t.rAccessor,colorAccessor:t.colorAccessor,stackBy:t.stackBy,groupBy:t.groupBy,categoryAccessor:t.categoryAccessor,valueAccessor:t.valueAccessor,timeAccessor:t.timeAccessor,rExtent:t.rExtent,oExtent:t.oExtent,barPadding:t.barPadding,roundedTop:t.roundedTop,innerRadius:t.innerRadius,cornerRadius:t.cornerRadius,normalize:t.normalize,startAngle:t.startAngle,sweepAngle:t.sweepAngle,bins:t.bins,showOutliers:t.showOutliers,showIQR:t.showIQR,amplitude:t.amplitude,oSort:t.oSort,connectorAccessor:t.connectorAccessor,connectorStyle:t.connectorStyle,dynamicColumnWidth:t.dynamicColumnWidth,pieceStyle:t.pieceStyle,summaryStyle:t.summaryStyle,colorScheme:t.colorScheme||i.colors.categorical,themeCategorical:i.colors.categorical,themeSemantic:It(i),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,layoutSelection:t.layoutSelection,barColors:t.barColors},p=new fa(f);if(t.data&&p.ingest({inserts:s,bounded:!0}),p.computeScene({width:l,height:u}),!p.scales||0===p.scene.length)return e&&(e.evidence=ro({frameType:"ordinal",width:o[0],height:o[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,extraWarnings:p.scales?[]:["NO_SCALES"]})),Ys.renderToStaticMarkup(Is(null,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:u,idPrefix:t._idPrefix}));if(e){const i=p.scales.o?.domain?.();e.evidence=ro({frameType:"ordinal",width:o[0],height:o[1],marks:p.scene,title:t.title,description:t.description,annotations:t.annotations,yDomain:no(p.scales.r?.domain?.()),categories:Array.isArray(i)?i.map(String):void 0})}const y=t._idPrefix,g=t.showGrid?function(t,e,i,o){const n=t.scales;if(!n||"radial"===n.projection)return null;const{grid:r}=io(i),s=o?o+"-":"",a="vertical"===n.projection,c=n.r.ticks(5);return Ls("g",a?{id:s+"grid",className:"semiotic-grid",opacity:.8,children:c.map((t,i)=>{const o=n.r(t);return Ls("line",{x1:0,y1:o,x2:e.width,y2:o,stroke:r,strokeWidth:.5},"gr-"+i)})}:{id:s+"grid",className:"semiotic-grid",opacity:.8,children:c.map((t,i)=>{const o=n.r(t);return Ls("line",{x1:o,y1:0,x2:o,y2:e.height,stroke:r,strokeWidth:.5},"gr-"+i)})})}(p,{width:l,height:u},i,y):null;let m=null;if(p.scene.some(t=>"rect"===t.type&&t.datum?.__barFunnelIsDropoff)){const e=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const i=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;i.length>t;t++)o=31*o+i.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(t),o=new Set;for(const t of p.scene)"rect"===t.type&&t.datum?.__barFunnelIsDropoff&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");m=Array.from(o).map((t,o)=>function(t){const{id:e,background:i="transparent",stroke:o="#000",lineWidth:n=1.5,spacing:r=6,angle:s=45}=t,a=Math.max(8,Math.ceil(2*r));return ya("pattern",{id:e,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[i&&"transparent"!==i&&pa("rect",{width:a,height:a,fill:i}),pa("line",{x1:0,y1:0,x2:0,y2:a,stroke:o,strokeWidth:n}),pa("line",{x1:r,y1:0,x2:r,y2:a,stroke:o,strokeWidth:n})]},e)}({id:`funnel-hatch-${e}-${o}`,background:t,stroke:"transparent"===i.colors.background?"#fff":i.colors.background,lineWidth:1.5,spacing:5,angle:45}));const n=new Map;Array.from(o).forEach((t,i)=>n.set(t,`funnel-hatch-${e}-${i}`));for(const t of p.scene)"rect"===t.type&&t.datum?.__barFunnelIsDropoff&&(t.style={...t.style,fill:`url(#${n.get("string"==typeof t.style.fill?t.style.fill:"#666")})`})}const x=p.scene.map((e,i)=>xr({node:e,index:i,renderMode:t.renderMode,fallback:()=>gr(e,i,y)})).filter(Boolean),b=!1!==t.showAxes?function(t,e,i,o,n){const r=t.scales;if(!r)return null;if("radial"===r.projection)return null;const s=io(o),a="vertical"===r.projection,c=i.categoryFormat||i.oFormat,l=i.valueFormat||i.rFormat,u=i.categoryLabel||i.oLabel,h=i.valueLabel||i.rLabel,d=Object.values(t.columns).map(t=>({pixel:t.middle,label:(c||String)(t.name)})),f=r.r.ticks(5).map(t=>({pixel:r.r(t),label:(l||Ns)(t)}));return xa("g",a?{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[ma("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:s.border,strokeWidth:1}),d.map((t,i)=>xa("g",{transform:`translate(${t.pixel},${e.height})`,children:[ma("line",{y2:5,stroke:s.border,strokeWidth:1}),ma("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oxtick-"+i)),u&&ma("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:u}),ma("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:s.border,strokeWidth:1}),f.map((t,e)=>xa("g",{transform:`translate(0,${t.pixel})`,children:[ma("line",{x2:-5,stroke:s.border,strokeWidth:1}),ma("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oytick-"+e)),h&&ma("text",{x:15-(i.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(i.margin?.left??40)}, ${e.height/2})`,children:h})]}:{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[ma("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:s.border,strokeWidth:1}),f.map((t,i)=>xa("g",{transform:`translate(${t.pixel},${e.height})`,children:[ma("line",{y2:5,stroke:s.border,strokeWidth:1}),ma("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oxtick-"+i)),h&&ma("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:h}),ma("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:s.border,strokeWidth:1}),d.map((t,e)=>xa("g",{transform:`translate(0,${t.pixel})`,children:[ma("line",{x2:-5,stroke:s.border,strokeWidth:1}),ma("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oytick-"+e)),u&&ma("text",{x:15-(i.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(i.margin?.left??40)}, ${e.height/2})`,children:u})]})}(p,{width:l,height:u},t,i,y):null,v=t.annotations?_s({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{o:p.scales.o,r:p.scales.r,y:"vertical"===p.scales.projection?p.scales.r:void 0},layout:{width:l,height:u},theme:i,projection:h,idPrefix:y}):null,w=t.showLegend?0===a.length?null:Rr({categories:a,colorScheme:t.colorScheme,theme:i,position:t.legendPosition||"right",totalWidth:o[0],totalHeight:o[1],margin:n,hasTitle:r,legendLayout:t.legendLayout}):null,k=js.isValidElement(t.legend)?t.legend:Es(t.legend,{theme:i,position:t.legendPosition||"right",size:o,margin:n,hasTitle:r,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||w,S=d?n.left+l/2:n.left,A=d?n.top+u/2:n.top;return Ys.renderToStaticMarkup(Is(xa(ga,{children:[t.backgroundGraphics,g,x,b,v,t.foregroundGraphics,p.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${S},${A})`,innerWidth:l,innerHeight:u,legend:k,defs:m,idPrefix:t._idPrefix}))}import*as va from"react";import*as wa from"react-dom/server";function ka(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function Sa(t,e){var i,o=[],n=[],r=[],s={},a=[];function c(t){r[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],r[e]&&c(e)})}function l(t){var e,o,h=!1;for(n.push(t),r[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===i?(u(i,n),h=!0):r[o]||(h=l(o));if(h)c(t);else for(e=0;a[t].length>e;e++){var d=s[o=a[t][e]];d||(s[o]=d={}),d[o]=!0}return n.pop(),h}function u(t,i){var n=[].concat(i).concat(t);e?e(n):o.push(n)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,o=function(t){for(var e=t.length,i=Array(e),o=Array(e),n=Array(e),r=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,o[c]=0,n[c]=!1,r[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],d=[];function f(e){var c=[e],l=[e];for(i[e]=o[e]=u,n[e]=!0,u+=1;l.length>0;){var f=t[e=l[l.length-1]];if(f.length>r[e]){for(var p=r[e];f.length>p;++p){var y=f[p];if(0>i[y]){i[y]=o[y]=u,n[y]=!0,u+=1,c.push(y),l.push(y);break}n[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}r[e]=p}else{if(o[e]===i[e]){var g=[],m=[],x=0;for(p=c.length-1;p>=0;--p){var b=c[p];if(n[b]=!1,g.push(b),m.push(a[b]),x+=a[b].length,s[b]=h.length,b===e){c.length=p;break}}h.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];d.push(v)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&f(c);for(c=0;d.length>c;c++){var p=d[c];if(0!==p.length){p.sort(function(t,e){return t-e}),l=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&l.push(p[y]);d[c]=l}}return{components:h,adjacencyList:d}}(t),n=o.components.filter(function(t){return t.length>1}),r=1/0,s=0;n.length>s;s++)for(var a=0;n[s].length>a;a++)r>n[s][a]&&(r=n[s][a],i=s);var c=n[i];return!!c&&{leastVertex:r,adjList:t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})})}}i=0;for(var d=t.length;d>i;){var f=h(i);if(i=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];r[+g]=!1,s[g]={}}l(i),i+=1}else i=d}return e?void 0:o}function Aa(t){return t.y0-t.y1>0?"up":"down"}function Ma(t,e){return e(t.source)==e(t.target)}function _a(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function Pa(t){return t.target.x0-t.source.x1}function Ra(t,e){var i=La(t),o=Pa(e)/Math.tan(i);return"up"==Aa(t)?t.y1-o:t.y1+o}function Ta(t,e){var i=La(t),o=Pa(e)/Math.tan(i);return"up"==Aa(t)?t.y1+o:t.y1-o}function La(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Ca(t,e){return e(t)}function $a(t){return Da(t.source)}function za(t){return Da(t.target)}function Da(t){return(t.y0+t.y1)/2}function Ea(t){return t.virtual?0:t.value}function Na(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!Ma(t,e)?i+1:i});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Ma(t,e)?o+1:o}),i+o}function Ia(t){return t.target.depth}function Ba(t,e){return t.sourceLinks.length?t.depth:e-1}function Fa(t,e){return t.y0-e.y0}function Oa(t,e){return e.y0-t.y0}function Wa(t,e){return t.y1-e.y1}function ja(t,e){return e.y1-t.y1}function Ya(t,e){return qa(t.source,e.source)||t.index-e.index}function Xa(t,e){return qa(t.target,e.target)||t.index-e.index}function qa(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ga(t,e){return Va(t)==Va(e)?"bottom"==t.circularLinkType?Oa(t,e):Fa(t,e):Va(e)-Va(t)}function Va(t){return t.target.column-t.source.column}function Ha(t,e){return Za(t)==Za(e)}function Za(t){return t.y0-t.y1>0?"up":"down"}import{min as Ka}from"d3-array";function Ua(t,e,i,o,n){let r=t;var s=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=Ka(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=r.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),Qa(r.links.filter(function(t){return"top"==t.circularLinkType}),e,i),Qa(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+o,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Ma(t,e)&&_a(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+n+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-n-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,c=t.circularLinkType,l=r.links.filter(function(t){return t.source.column==s&&t.circularLinkType==c});l.sort("bottom"==t.circularLinkType?Oa:Fa);var u=0;l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+n*i+u),u+=e._circularWidth||e.width}),s=t.target.column,(l=r.links.filter(function(t){return t.target.column==s&&t.circularLinkType==c})).sort("bottom"==t.circularLinkType?ja:Wa),u=0,l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+n*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+n+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-n-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,i=t.y0,o=t.target.x0,n=t.y1,r=(e+o)/2;return"M"+e+","+i+"C"+r+","+i+" "+r+","+n+" "+o+","+n}(t)}),r}function Qa(t,e,i){t.sort(Ga);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,n){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Ma(t,e)&&_a(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Ja(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;r=c>r?c:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function Ja(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}import{min as tc,max as ec,sum as ic,mean as oc,group as nc,groups as rc}from"d3-array";function sc(t){return function(){return t}}function ac(t){return t.index}function cc(t){return t.nodes}function lc(t){return t.links}function uc(t,e,i){var o=rc(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(n,r){var s=n.length;if(e)n.sort(e);else if(r>0){var a=new Map;n.forEach(function(t,e){var i,o,n,r=(o=0,n=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;n+=Da(t.source)*e,o+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;n+=Da(t.target)*e,o+=e}}),o>0?n/o:NaN);a.set(t,{bc:r,idx:e})}),n.sort(function(t,e){var i=a.get(t),o=a.get(e),n=i.bc,r=o.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(n)||isNaN(r)?isNaN(n)?isNaN(r)?i.idx-o.idx:1:-1:n-r})}else n.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Na(e,i)-Na(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});n.forEach(function(e,n){e.depth==o.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Na(e,i)?(e.y0=t.y1/2+n,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+n,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-n,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*n,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+n,e.y1=e.y0+e.value*t.ky)})})}function hc(t,e,i,o,n,r){var s=rc(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,c=r;c>0;--c)l(a*=.99,i),u();function l(e,i){var o=s.length;s.forEach(function(n){var r=n.length,s=n[0].depth;n.forEach(function(n){var a;if(n.sourceLinks.length||n.targetLinks.length)if(n.partOfCycle&&Na(n,i)>0){var c=oc(n.sourceLinks,za),l=oc(n.targetLinks,$a),u=c&&l?(c+l)/2:c||l;if(u){var h=(u-Da(n))*e*.3;n.y0+=h,n.y1+=h}}else if(0==s&&1==r)n.y0=t.y1/2-(a=n.y1-n.y0)/2,n.y1=t.y1/2+a/2;else if(s==o-1&&1==r)n.y0=t.y1/2-(a=n.y1-n.y0)/2,n.y1=t.y1/2+a/2;else if(1==n.targetLinks.length&&1==n.targetLinks[0].source.sourceLinks.length)a=n.y1-n.y0,n.y0=n.targetLinks[0].source.y0,n.y1=n.y0+a;else{var d=oc(n.sourceLinks,za),f=oc(n.targetLinks,$a),p=((d&&f?(d+f)/2:d||f)-Da(n))*e;n.y0+=p,n.y1+=p}})})}function u(){s.forEach(function(i){var r,s,a,c=t.y0,l=i.length;for(i.sort(e||qa),a=0;l>a;++a)(s=c-(r=i[a]).y0)>0&&(r.y0+=s,r.y1+=s),c=r.y1+o;if((s=c-o-t.y1)>0)for(c=r.y0-=s,r.y1-=s,a=l-2;a>=0;--a)(s=(r=i[a]).y1+n-c)>0&&(r.y0-=s,r.y1-=s),c=r.y0})}}function dc(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Xa),t.targetLinks.sort(Ya)}),t.nodes.forEach(function(t){var e=t.y0,i=e,o=t.y1,n=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=n-t.width/2,n-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function fc(){var t=0,e=0,i=1,o=1,n=24,r=8,s=null,a=ac,c=Ba,l=void 0,u=32,h=2,d=cc,f=lc;function p(){var p={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=i,d.y1=o,d.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return nc(t,e).forEach(function(t,e){i.set(e,t[0])}),i}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var o=t.source,n=t.target;"object"!=typeof o&&(o=t.source=ka(i,o)),"object"!=typeof n&&(n=t.target=ka(i,n)),o.sourceLinks.push(t),n.targetLinks.push(t)})}(d,a),function(t,e){var i=0;if(null==e){for(var o=[],n=0;t.links.length>n;n++){var r=t.links[n],s=r.source.index,a=r.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=Sa(o);c.sort(function(t,e){return t.length-e.length});var l={};for(n=0;c.length>n;n++){var u=c[n].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||l[o]&&l[o][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(d,l),function(t,e){var i=0,o=0;t.links.forEach(function(n){n.circular&&(n.circularLinkType=n.source.circularLinkType||n.target.circularLinkType?n.source.circularLinkType?n.source.circularLinkType:n.target.circularLinkType:o>i?"top":"bottom","top"==n.circularLinkType?i++:o++,t.nodes.forEach(function(t){Ca(t,e)!=Ca(n.source,e)&&Ca(t,e)!=Ca(n.target,e)||(t.circularLinkType=n.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Ma(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(ic(t.sourceLinks,Ea),ic(t.targetLinks,Ea)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(d),function(t,e,i){var o,n,r;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,n=[],r=0;o.length;++r,o=n,n=[])o.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>n.indexOf(t.target)&&!t.circular&&n.push(t.target)})});for(o=t.nodes,n=[],r=0;o.length;++r,o=n,n=[])o.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>n.indexOf(t.source)&&!t.circular&&n.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,r):t.column})}(d,l,c);var f=r;if(null!==s){var p=rc(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=ec(p,function(t){return t.length});y>1&&(f=Math.max(1,(o-e)*s/(y-1)))}(function(t,e,i){var o=rc(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var n=tc(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/ic(e,function(t){return t.value})});t.ky=n,t.links.forEach(function(e){e.width=e.value*t.ky});var r=ec(t.nodes,function(t){return t.column});t.nodes.forEach(r>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/r),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(d,f,n),uc(d,l,a),hc(d,l,a,f,f,u),dc(d),Ua(d,a,h,10,8),uc(d,l,a),hc(d,l,a,f,f,u),dc(d),Ua(d,a,h,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var o=i.links.filter(function(i){return Ca(i.source,e)==Ca(t,e)}),n=o.length;n>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Ha(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=Ra(e,t);return t.y1-i}if(e.target.column>t.target.column)return Ra(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var r=i+1,s=0;n>r;r++)s+=o[r].width;e.y0=t.y1-s-e.width/2}})})}(d,a),function(t,e){let i=t;i.nodes.forEach(function(t){var o=i.links.filter(function(i){return Ca(i.target,e)==Ca(t,e)}),n=o.length;n>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Ha(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=Ta(e,t);return t.y0-i}if(e.source.column>t.source.column)return Ta(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var r=i+1,s=0;n>r;r++)s+=o[r].width;e.y1=t.y1-s-e.width/2}})})}(d,a),function(t){var e=t.nodes,i=t.links,o=!1,n=!1;if(i.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(n=!0)}),0==o||0==n){let o=function(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0};var r=tc(e,function(t){return t.y0}),s=ec(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);1>a?(e.forEach(function(t){t.y0=o(t.y0),t.y1=o(t.y1)}),i.forEach(function(t){t.y0=o(t.y0),t.y1=o(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,i=o(t.y0)-t.y0;t.y0=o(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(d),Ua(d,a,h,10,8)}(p),p}return p.update=function(t){return dc(t),Ua(t,a,h,10,8),t},p.nodeWidth=function(t){return arguments.length?(n=+t,p):n},p.nodePadding=function(t){return arguments.length?(r=+t,p):r},p.nodePaddingRatio=function(t){return arguments.length?(s=+t,p):s},p.nodes=function(t){return arguments.length?(d="function"==typeof t?t:sc(t),p):d},p.links=function(t){return arguments.length?(f="function"==typeof t?t:sc(t),p):f},p.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:sc(t),p):a},p.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:sc(t),p):c},p.nodeSort=function(t){return arguments.length?(l=t,p):l},p.iterations=function(t){return arguments.length?(u=+t,p):u},p.circularLinkGap=function(t){return arguments.length?(h=+t,p):h},p.extent=function(n){return arguments.length?(t=+n[0][0],e=+n[0][1],i=+n[1][0],o=+n[1][1],p):[[t,e],[i,o]]},p.size=function(n){return arguments.length?(t=e=0,i=+n[0],o=+n[1],p):[i-t,o-e]},p}import{interpolateNumber as pc}from"d3-interpolate";import{line as yc,curveLinearClosed as gc}from"d3-shape";var mc=t=>{let e,i,o,n,r,s,a,c,l;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,n=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,a=pc(r,s),c=a(.5),l=a(.5),`M${e},${r}C${e},${c} ${i},${l} ${i},${s}L${o},${s}C${o},${l} ${n},${c} ${n},${r}Z`;const u=t.sankeyWidth/2,h=pc(t.source.x1,t.target.x0),{pathD:d}=xt({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:h(.5),cp2X:h(.5)});return d};function xc(t){const e=t.sankeyWidth/2,i=(t._circularWidth??t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const i=o.sourceX,n=o.sourceY,r=o.targetX,s=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-i))),c=Math.max(15,Math.min(40,.33*(r-o.leftFullExtent)));return`M${i},${n-e}L${i+a},${n-e}L${i+a},${n+e}L${i},${n+e}ZM${r},${s-e}L${r-c},${s-e}L${r-c},${s+e}L${r},${s+e}Z`}const n=o.sourceX,r=o.sourceY,s=o.targetX,a=o.targetY,c=o.rightFullExtent,l=o.leftFullExtent,u=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(i,15));return`M${n},${r-h*e}L${c},${r-h*e}L${c+i},${r-h*e+h*d}L${c+i},${u+h*i-h*d}L${c+i-d},${u+h*i}L${l-i+d},${u+h*i}L${l-i},${u+h*i-h*d}L${l-i},${a-h*e+h*d}L${l-i+d},${a-h*e}L${s},${a-h*e}L${s},${a+h*e}L${l+i},${a+h*e}L${l+i},${u-h*i}L${c-i},${u-h*i}L${c-i},${r+h*e}L${n},${r+h*e}Z`}var bc=new Set,vc=new WeakMap;function wc(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=vc.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,vc.set(t,i);const o=new Proxy(t,{get(t,i,o){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;bc.has(t)||(bc.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,i,o)}});return i.set(e,o),o}var kc={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(Ia))-1:0},justify:Ba};function Sc(t){return"string"==typeof t?t:t.id}var Ac={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const n="vertical"===i.orientation?"down":"right",r=i.nodeAlign||"justify",s=i.nodeWidth??15,a=i.nodePaddingRatio??.05,c=i.iterations??100,l=t.map(t=>({...t})),u=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let h;h="down"===n?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const d=fc().extent(h).links(u).nodes(l).nodeAlign(kc[r]||Ba).nodeId(t=>t.id).nodeWidth(s).iterations(c);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let t=1/0,e=-1/0,i=1/0,n=-1/0;for(const o of l)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),i>o.y0&&(i=o.y0),o.y1>n&&(n=o.y1);for(const o of u){if(!o.circular||!o.circularPathData)continue;const r=o.circularPathData,s=(o._circularWidth??o.width??0)/2;t>r.leftFullExtent-s&&(t=r.leftFullExtent-s),r.rightFullExtent+s>e&&(e=r.rightFullExtent+s),i>r.verticalFullExtent-s&&(i=r.verticalFullExtent-s),r.verticalFullExtent+s>n&&(n=r.verticalFullExtent+s)}const r=e-t,s=n-i,a=o[0],c=o[1];if(r>0&&s>0&&(0>t||0>i||e>a||n>c)){const e=Math.min(a/r,c/s),o=-t*e+(a-r*e)/2,n=-i*e+(c-s*e)/2;for(const t of l)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+n,t.y1=t.y1*e+n;for(const t of u)if(t.y0=t.y0*e+n,t.y1=t.y1*e+n,t.width=(t.width??0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+o,i.targetX=i.targetX*e+o,i.sourceY=i.sourceY*e+n,i.targetY=i.targetY*e+n,i.rightFullExtent=i.rightFullExtent*e+o,i.leftFullExtent=i.leftFullExtent*e+o,i.verticalFullExtent=i.verticalFullExtent*e+n,i.rightInnerExtent=i.rightInnerExtent*e+o,i.leftInnerExtent=i.leftInnerExtent*e+o,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+n,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+n,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const f=new Map;for(const e of t)f.set(e.id,e);for(const t of l){const e=f.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const p=new Map;for(const t of e)p.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of u){const e=Sc(t.source),i=Sc(t.target),o=p.get(t._edgeKey?t._edgeKey:`${e}\0${i}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=t.width??0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=n;const r=f.get(e),s=f.get(i);r&&(o.source=r),s&&(o.target=s)}}},buildScene(t,e,i,o){const n="vertical"===i.orientation?"down":"right",r=i.nodeStyle,a=i.edgeStyle,c=i.edgeOpacity??.5,l=i.edgeColorBy||"source",u=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:s,h=new Map;t.forEach((t,e)=>{h.set(t.id,u[e%u.length])});const d=[],f=[],p=[],y=new Map;for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const o=r?r(wc(e,"nodeStyle")):{},s={fill:o.fill||h.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};y.set(e.id,("string"==typeof s.fill?s.fill:null)||h.get(e.id)||"#4d430c"),d.push("down"===n?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:s,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:s,datum:e,id:e.id,label:e.id})}const g=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of g){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let n=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";n="function"==typeof l?l(t)||n:"target"===l?y.get(o.id)||h.get(o.id)||n:y.get(e.id)||h.get(e.id)||n;const r=a?a(wc(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),a=r.fill||n;f.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+o},${e.sourceY-i}L${e.sourceX+o},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:a,fillOpacity:r.fillOpacity??c,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),f.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-s},${e.targetY-i}L${e.targetX-s},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:a,fillOpacity:r.fillOpacity??c,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let s;(s=t.circular&&t.circularPathData?xc(t):mc(t),s)&&f.push({type:"bezier",pathD:s,bezierCache:t.bezier,style:{fill:r.fill||n,fillOpacity:r.fillOpacity??c,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity},datum:t})}if(!1!==i.showLabels){const e=(m=i.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const s=e?e(i):i.id;if(!s)continue;let a,c,l;"down"===n?(a=i.y0+(i.y1-i.y0)/2,c=i.x1+14,l="start"):(o[0]/2>i.x0+t/2?(a=i.x0-6,l="end"):(a=i.x1+6,l="start"),c=i.y0+r/2),p.push({x:a,y:c,text:s+"",anchor:"down"===n?"middle":l,baseline:"middle",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:f,labels:p}}};import{forceSimulation as Mc,forceCenter as _c,forceX as Pc,forceY as Rc,forceLink as Tc,forceManyBody as Lc,forceCollide as Cc}from"d3-force";import{scaleLinear as $c}from"d3-scale";var zc={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const n=i.forceStrength??.1,r=o[0]/2,s=o[1]/2,a=i.__previousPositions;let c=0;const l=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),i=a?.get(e.id);t?c++:i?(e.x=i.x,e.y=i.y,c++):l.push(e)}const u=c>0&&.3>=(t.length>0?l.length/t.length:1);if(u){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of l){const o=Dc(t.id,e,i);if(o.length>0){let e=0,i=0;for(const t of o)e+=t.x,i+=t.y;const n=Ec(t.id),r=n%360*(Math.PI/180),s=10+n%20;t.x=e/o.length+s*Math.cos(r),t.y=i/o.length+s*Math.sin(r)}else{const e=Ec(t.id),i=e%360*(Math.PI/180),o=15+e%30;t.x=r+o*Math.cos(i),t.y=s+o*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const o=t[i];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(i+.5),n=i*e;o.x=r+t*Math.cos(n),o.y=s+t*Math.sin(n)}}}const h=i.__skipForceSimulation||0===i.iterations?0:u?40:i.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),d=Nc(i.nodeSize,i.nodeSizeRange,t),f=t=>d(t);if(h>0){const o=new Map,a=new Map;for(const e of t)o.set(e.id,0),a.set(e.id,e);for(const t of e){const e="string"==typeof t.source?t.source:t.source.id,i="string"==typeof t.target?t.target:t.target.id;o.set(e,(o.get(e)??0)+1),o.set(i,(o.get(i)??0)+1)}const c=Tc().strength(t=>{const e=t.weight,i="string"==typeof t.target?t.target:t.target.id,r=Math.max(1,Math.min(o.get("string"==typeof t.source?t.source:t.source.id)??1,o.get(i)??1));return Math.min(2.5,(e&&e>0?Math.sqrt(e):1)*n/(.1*r))}).distance(t=>{const e="string"==typeof t.source?a.get(t.source):t.source,i="string"==typeof t.target?a.get(t.target):t.target,o=(e?f(e):0)+(i?f(i):0)+12;return Math.max(40,o)}).id(t=>t.id),l=Mc();if(void 0===i.random&&void 0===i.seed||l.randomSource(i.random??function(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}(i.seed)),l.force("charge",Lc().strength(t=>{const e=o.get(t.id)??0;return-15*f(t)*Math.sqrt(e+1)})).force("collide",Cc(t=>f(t)+3).strength(.9).iterations(2)).force("center",_c(r,s).strength(.8)).force("x",Pc(r).strength(.06)).force("y",Rc(s).strength(.06)),l.nodes(t),e.length>0){const t=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));c.links(t),l.force("link",c)}u?l.alpha(.3):.1>l.alpha()&&l.alpha(1),l.stop();for(let t=0;h>t;++t)l.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(e);e.x=Math.max(t,Math.min(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=p.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=p.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,o){const n=i.nodeStyle,r=i.edgeStyle,a=Nc(i.nodeSize,i.nodeSizeRange,t),c=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:s,l=new Map;t.forEach((t,e)=>{l.set(t.id,c[e%c.length])});const u=[],h=[],d=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=a(wc(e,"nodeSize")),o=n?n(wc(e,"nodeStyle")):{},r={fill:o.fill||l.get(e.id)||i.themeSemantic?.primary||"#007bff",stroke:o.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??2,opacity:o.opacity};u.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const f=new Map;for(const e of t)f.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:f.get(t.source),o="object"==typeof t.target?t.target:f.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const n=r?r(wc(t,"edgeStyle")):{};h.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:{stroke:n.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:n.strokeWidth??1,opacity:n.opacity??.6},datum:t})}if(!1!==i.showLabels){const e=(p=i.nodeLabel)?"function"==typeof p?p:t=>t[p]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const o=a(wc(i,"nodeSize"));d.push({x:i.x,y:i.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:u,sceneEdges:h,labels:d}}};function Dc(t,e,i){const o=[];for(const n of e){const e="string"==typeof n.source?n.source:n.source.id,r="string"==typeof n.target?n.target:n.target.id;let s=null;if(e===t?s=r:r===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function Ec(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i)|0;return Math.abs(e)}function Nc(t,e,i){if(i.some(t=>null!=t.__forceRadius))return t=>t.__forceRadius??8;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const o=e||[5,20],n=[];for(const e of i){const i=e.data?.[t];"number"==typeof i&&n.push(i)}if(0===n.length)return()=>o[0];const[r,s]=rt(n);if(r===s)return()=>(o[0]+o[1])/2;const a=$c().domain([r,s]).range(o).clamp(!0);return e=>{const i=e.data?.[t];return null==i||"number"!=typeof i?o[0]:a(i)}}import{chord as Ic,ribbon as Bc}from"d3-chord";import{arc as Fc}from"d3-shape";var Oc=s,Wc={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const{padAngle:n=.01,groupWidth:r=20,sortGroups:s}=i,a=Math.min(o[0],o[1])/2,c=a-r,l=o[0]/2,u=o[1]/2,h=(d=i.valueAccessor)?"function"==typeof d?d:t=>t[d]??1:t=>t.value??1;var d;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const p=t.length,y=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=f.get("string"==typeof t.source?t.source:t.source.id),o=f.get(e);if(void 0===i||void 0===o)continue;const n=h(t);y[i][o]=n}const g=Ic().padAngle(n);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=Fc().innerRadius(c).outerRadius(a);for(const e of x){const i=t[e.index],o=b.centroid({innerRadius:c,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});i.x=o[0]+l,i.y=o[1]+u,i.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=v.get("string"==typeof t.source?t.source:t.source.id),o=v.get(e);i&&(t.source=i),o&&(t.target=o)}const w=new Map;for(const t of e)w.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const i=t[e.source.index].id,o=t[e.target.index].id,n=w.get(`${i}\0${o}`)||w.get(`${o}\0${i}`);n&&(n.__chordData=e)}},buildScene(t,e,i,o){const{groupWidth:n=20,edgeOpacity:r=.5}=i,s=Math.min(o[0],o[1])/2,a=s-n,c=o[0]/2,l=o[1]/2,u=i.nodeStyle,h=i.edgeStyle,d=i.edgeColorBy||"source",f=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:Oc,p=new Map;t.forEach((t,e)=>{p.set(t.id,f[e%f.length])});const y=Bc().radius(a),g=[],m=[],x=[];for(let e=0;t.length>e;e++){const i=t[e],o=i.__arcData;if(!o)continue;let n;n=u?u(wc(i,"nodeStyle")).fill||p.get(i.id)||f[e%f.length]:p.get(i.id)||f[e%f.length];const r=u?u(wc(i,"nodeStyle")):{};g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:{fill:n,stroke:r.stroke||"black",strokeWidth:r.strokeWidth??1,opacity:r.opacity},datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const o=y(e);if(!o)continue;const n=jc(o,c,l);let s=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";if(h)s=h(wc(t,"edgeStyle")).fill||s;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===d&&i?s=p.get(i.id)||s:e&&(s=p.get(e.id)||s)}const a=h?h(wc(t,"edgeStyle")):{};m.push({type:"ribbon",pathD:n,style:{fill:s,fillOpacity:a.fillOpacity??r,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:t})}if(!1!==i.showLabels){const e=(b=i.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null,o=s+12;for(const i of t){const t=i.__arcData;if(!t)continue;const n=e?e(i):i.id;if(!n)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;x.push({x:c+Math.cos(s)*o,y:l+Math.sin(s)*o,text:n+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:g,sceneEdges:m,labels:x}}};function jc(t,e,i){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const n=[];let r=0;for(;o.length>r;){const t=o[r];if("M"===t||"L"===t)for(n.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)n.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(n.push(Number(o[r])+i+""),r++);else if("C"===t)for(n.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;3>t&&o.length>r&&!isNaN(Number(o[r]));t++)n.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(n.push(Number(o[r])+i+""),r++);else if("Q"===t)for(n.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;2>t&&o.length>r&&!isNaN(Number(o[r]));t++)n.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(n.push(Number(o[r])+i+""),r++);else if("A"===t)for(n.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)n.push(o[r++]),o.length>r&&n.push(o[r++]),o.length>r&&n.push(o[r++]),o.length>r&&n.push(o[r++]),o.length>r&&n.push(o[r++]),o.length>r&&(n.push(Number(o[r])+e+""),r++),o.length>r&&(n.push(Number(o[r])+i+""),r++);else"Z"===t||"z"===t?(n.push(t),r++):(n.push(o[r]),r++)}return n.join(" ")}import{hierarchy as Yc,tree as Xc,cluster as qc,treemap as Gc,pack as Vc,partition as Hc,treemapBinary as Zc}from"d3-hierarchy";var Kc=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Uc(t){const[e,i,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*i+.114*o>150?"#222":"#fff"}function Qc(t,e,i){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function Jc(t){if(!t)return null;if("function"==typeof t){const e=t;return t=>e(t.data??t)}return e=>e.data?.[t]||e[t]||e.id}function tl(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Kc}function el(t){return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:t.themeSemantic?.primary?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function il(t,e,i,o,n){if("horizontal"===n){const n=(t+i)/2;return`M ${t},${e} C ${n},${e} ${n},${o} ${i},${o}`}if("radial"===n){const n=(t+i)/2;return`M ${t},${e} Q ${n},${e} ${n},${(e+o)/2} T ${i},${o}`}{const n=(e+o)/2;return`M ${t},${e} C ${t},${n} ${i},${n} ${i},${o}`}}var ol={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,o){const n=i.__hierarchyRoot;if(!n)return;const r=i.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),a=i.hierarchySum,c="function"==typeof a?a:"string"==typeof a?t=>Number(t[a])||0:t=>Number(t.value)||0,l=Yc(n,s);l.sum(c),l.sort((t,e)=>(e.value??0)-(t.value??0));const[u,h]=o;switch(r){case"tree":!function(t,e,i,o){const n=e.treeOrientation||"vertical",r=Xc();r.size("horizontal"===n?[o,i]:"radial"===n?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),r(t)}(l,i,u,h);break;case"cluster":!function(t,e,i,o){const n=e.treeOrientation||"vertical",r=qc();r.size("horizontal"===n?[o,i]:"radial"===n?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),r(t)}(l,i,u,h);break;case"treemap":!function(t,e,i,o){const n=e.padding??4,r=e.paddingTop??0,s=Gc().size([i,o]).tile(Zc).padding(n);r>0&&s.paddingTop(r),s(t)}(l,i,u,h);break;case"circlepack":!function(t,e,i,o){const n=e.padding??4;Vc().size([i,o]).padding(n)(t)}(l,i,u,h);break;case"partition":!function(t,e,i,o){Hc().size([i,o]).padding(e.padding??1)(t)}(l,i,u,h)}const d=l.descendants();t.length=0,e.length=0;const f=new Map;for(let e=0;d.length>e;e++){const o=d[e],n={id:Qc(o,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:o.value??0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===r||"cluster"===r?nl(n,o,i):"treemap"===r||"partition"===r?rl(n,o):"circlepack"===r&&sl(n,o),n.__hierarchyNode=o,t.push(n),f.set(o,n)}if("tree"===r||"cluster"===r)for(const t of d)if(t.parent){const i=f.get(t.parent),o=f.get(t);i&&o&&e.push({source:i,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,o){const n=i.nodeStyle||(()=>({})),r=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,o,n,r){const s=[],a=[],c=[],l=i.treeOrientation||"vertical",u="radial"===l,h=o[0]/2,d=o[1]/2,f="number"==typeof(p=i.nodeSize)?p:5;var p;for(const e of t){let t=e.x,o=e.y;u&&(t+=h,o+=d);const r=n(wc(e,"nodeStyle"));let a=r.fill||el(i);if(i.colorByDepth&&void 0!==e.depth){const t=tl(i);a=t[e.depth%t.length]}s.push({type:"circle",cx:t,cy:o,r:f,style:{fill:a,stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity},datum:e,id:e.id,label:e.id,depth:e.depth})}const y=i.edgeOpacity??.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let n=e.x,s=e.y,c=o.x,f=o.y;u&&(n+=h,s+=d,c+=h,f+=d);const p=il(n,s,c,f,l),g=r(wc(t,"edgeStyle"));a.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y},datum:t})}if(!1!==i.showLabels){const e=Jc(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let o,n,r,s=i.x,a=i.y;if(u&&(s+=h,a+=d),u){const t=s-h,e=a-d,i=Math.sqrt(t*t+e*e);i>0?(o=s+t/i*10,n=a+e/i*10,r=0>t?"end":"start"):(o=s,n=a-12,r="middle")}else"horizontal"===l?(i.data?.children&&0!==i.data.children.length?(o=s-f-6,r="end"):(o=s+f+6,r="start"),n=a):(o=s,n=a+f+14,r="middle");c.push({x:o,y:n,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(t,e,i,o,n,r);case"treemap":case"partition":return function(t,e,i,o){const n=[],r=[];for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const s=o(wc(i,"nodeStyle"));let a=s.fill||el(e);if(e.colorByDepth&&void 0!==i.depth){const t=tl(e);a=t[i.depth%t.length]}n.push({type:"rect",x:i.x0,y:i.y0,w:t,h:r,style:{fill:a,stroke:s.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Jc(e.nodeLabel),n=e.labelMode||"leaf",s="partition"===e.chartType;for(const a of t){const t=a.x1-a.x0,c=a.y1-a.y0;if(0>=t||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===n&&!l)continue;if("parent"===n&&l)continue}const u=i?i(a):a.id;if(!u)continue;if((l?30:40)>t||(l?16:14)>c)continue;let h=o(wc(a,"nodeStyle")).fill||el(e);if(e.colorByDepth&&void 0!==a.depth){const t=tl(e);h=t[a.depth%t.length]}const d="string"==typeof h?Uc(h):e.themeSemantic?.text??"#000";r.push(l?{x:a.x0+t/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,c)/6)),fill:d}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:n,sceneEdges:[],labels:r}}(t,i,0,n);case"circlepack":return function(t,e,i,o){const n=[],r=[];for(const i of t){const t=i.__radius??5;if(0>=t)continue;const r=o(wc(i,"nodeStyle"));let s=r.fill||el(e);if(e.colorByDepth&&void 0!==i.depth){const t=tl(e);s=t[i.depth%t.length]}n.push({type:"circle",cx:i.x,cy:i.y,r:t,style:{fill:s,stroke:r.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.7},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Jc(e.nodeLabel);for(const n of t){const t=n.__radius??5,s=i?i(n):n.id;if(!s)continue;if(15>t)continue;const a=!(n.data?.children&&n.data.children.length>0);let c=o(wc(n,"nodeStyle")).fill||el(e);if(e.colorByDepth&&void 0!==n.depth){const t=tl(e);c=t[n.depth%t.length]}if(a){const i="string"==typeof c?Uc(c):e.themeSemantic?.text??"#000";r.push({x:n.x,y:n.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:i})}else r.push({x:n.x,y:n.y-t+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:e.themeSemantic?.text||"#000",stroke:e.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:n,sceneEdges:[],labels:r}}(t,i,0,n);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function nl(t,e,i){const o=i.treeOrientation||"vertical";if("radial"===o){const i=e.x,o=e.y;t.x=o*Math.cos(i-Math.PI/2),t.y=o*Math.sin(i-Math.PI/2)}else"horizontal"===o?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function rl(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function sl(t,e){const i=e.r??0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}import{pie as al}from"d3-shape";function cl(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}var ll={sankey:Ac,force:zc,chord:Wc,tree:ol,cluster:ol,treemap:ol,circlepack:ol,partition:ol,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,o){const n=i.__hierarchyRoot;n&&function(t,e,i,o,n){const r=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),s=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>(t[e]??"")+""}(i.nodeIDAccessor),a=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(i.orbitMode),c=i.orbitSize??2.95,l=i.orbitEccentricity??1,u="number"==typeof c?()=>c:c,h="number"==typeof l?()=>l:l,d=cl(i);d.metaMap.clear(),o.length=0,n.length=0;const f=new Map;function p(t){const e=f.get(t)??0;return f.set(t,e+1),0===e?t:`${t}__${e}`}const y=e[0]/2,g=e[1]/2,m=Math.min(e[0],e[1])/2*.85,x=p(s(t));o.push({id:x,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:t}),d.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,i,c,l,f,y,g){const m=r(e);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:i,depth:y,data:e,parentId:i},M=g?f/u(A)*S:f*S,_=al().value(t=>{const e=r(t)?.length;return e?4:1}).sort(null)(w),P=h(A);for(let e=0;w.length>e;e++){const r=(_[e].startAngle+_[e].endAngle)/2,a=w[e],u=p(s(a)),h=c+M*Math.sin(r),f=l+M*Math.cos(r)*P;o.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),d.metaMap.set(u,{ring:M,angle:r,depth:y,parentId:i,eccentricity:P}),n.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(a,u,h,f,M,y+1,!0)}k+=v}}(t,x,y,g,m,1,!1)}(n,o,i,t,e)},buildScene(t,e,i,o){const n=i.nodeStyle,r=i.nodeSize,s="number"==typeof r?()=>r:"function"==typeof r?r:()=>6,a=[],c=[],l=[];if(!1!==i.orbitShowRings){const e=cl(i),o=new Map;for(const e of t)o.set(e.id,e);const n=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;n.has(i)||n.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:o}]of n)for(let n=0;r>n;n++){const a=n/r*Math.PI*2,l=(n+1)/r*Math.PI*2;c.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*o,x2:t+i*Math.sin(l),y2:e+i*Math.cos(l)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=s(wc(e,"nodeSize")),o=n?n(wc(e,"nodeStyle")):{};a.push({type:"circle",cx:e.x,cy:e.y,r:t,style:{fill:o.fill||i.themeSemantic?.primary||"#6366f1",stroke:o.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??(0===(e.depth??0)?1:.85)},datum:e,id:e.id,label:e.id,depth:e.depth})}const u=new Map;for(const e of t)u.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:u.get(t.source),i="object"==typeof t.target?t.target:u.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&c.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=s(wc(i,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(i):e?i.data?.[e]??i.id:i.id;l.push({x:i.x,y:i.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(t,e,i,o,n)=>!1!==i.orbitAnimated&&(function(t,e){const i=cl(e),o=e.orbitSpeed??.25,n=e.orbitRevolution??function(t){switch(t){case"decay":return t=>Math.pow(.6,t.depth??0);case"alternate":return t=>{const e=t.depth??0;return(e%2==0?1:-1)/(e+1)};default:return t=>1/((t.depth??0)+1)}}(e.orbitRevolutionStyle),r=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,s=o*(Math.PI/6),a=new Map;for(const e of t)a.set(e.id,e);for(const e of t){const t=i.metaMap.get(e.id);if(!t||!t.parentId)continue;const o=a.get(t.parentId);if(!o)continue;const c=t.angle+r*s*n({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=o.x+t.ring*Math.sin(c),e.y=o.y+t.ring*Math.cos(c)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}};import{Fragment as ul,jsxs as hl}from"react/jsx-runtime";function dl(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}var fl=new Set(["tree","cluster","treemap","circlepack","partition"]);function pl(t,e){const i=eo(t.theme),o=t.chartType||"force",n=()=>ro({frameType:"network",width:r[0],height:r[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,nodeCount:0,edgeCount:0}),r=t.size||[500,500],a=Ts({top:20,right:20,bottom:20,left:20,...t.margin},t.title),c=Rs(t.title),l=t.showLegend?(()=>{const e="string"==typeof(i=t.colorBy)||"function"==typeof i?t.colorBy:void 0;var i;if(!e)return[];const o=lo(t.nodes||[]);if(o.length>0)return Tr(o,e);const n=Array.isArray(t.edges)?lo(t.edges):[];if(0===n.length)return[];const r=dl(t.sourceAccessor,"source"),s=dl(t.targetAccessor,"target");return Tr(Array.from(new Set(n.flatMap(t=>[r(t),s(t)]).filter(t=>null!=t).map(String))).map(t=>({id:t})),e)})():[],u=t.legendPosition;so(t.legend)||ao(t.legend)?Ds(a,{legend:t.legend,theme:i,position:u||"right",size:r,hasTitle:c,legendLayout:t.legendLayout}):t.showLegend&&l.length>0&&zs(a,{categories:l,colorScheme:t.colorScheme,theme:i,position:u||"right",size:r,hasTitle:c,legendLayout:t.legendLayout});const h=r[0]-a.left-a.right,d=r[1]-a.top-a.bottom,f=function(t){return ll[t]}(o);if(!f&&!t.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${o}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const p={chartType:o,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,colorBy:t.colorBy,colorScheme:t.colorScheme||i.colors.categorical,edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange,customNetworkLayout:t.customNetworkLayout,layoutConfig:t.layoutConfig};let y,g;if(fl.has(o)){const o=t.data||t.edges;if(!o||Array.isArray(o))return e&&(e.evidence=n()),wa.renderToStaticMarkup(Is(null,{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${a.left},${a.top})`,innerWidth:h,innerHeight:d,idPrefix:t._idPrefix}));p.__hierarchyRoot=o,y=[],g=[]}else{const o=lo(t.nodes||[]),s=Array.isArray(t.edges)?lo(t.edges):[];if(0===o.length&&0===s.length)return e&&(e.evidence=n()),wa.renderToStaticMarkup(Is(null,{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${a.left},${a.top})`,innerWidth:h,innerHeight:d,idPrefix:t._idPrefix}));if(g=function(t,e){const i=dl(e.sourceAccessor,"source"),o=dl(e.targetAccessor,"target"),n=dl(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:o(t)+"",value:Number(n(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(s,p),0===o.length&&g.length>0){const t=new Set;for(const e of g){const i=$s(e.source),o=$s(e.target);i&&t.add(i),o&&t.add(o)}y=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else y=function(t,e){const i=dl(e.nodeIDAccessor,"id");return t.map(t=>({id:i(t)+"",x:t.x??0,y:t.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}))}(o,p)}let m=[],x=[],b=[],v=null;if(p.customNetworkLayout){const t=p.colorScheme,e=Wi(t,i.colors.categorical,s),o=ji(e,t),n={nodes:y,edges:g,dimensions:{width:h,height:d,plot:{x:0,y:0,width:h,height:d}},theme:{semantic:i.colors,categorical:[...e]},resolveColor:o,config:p.layoutConfig??{}},r=p.customNetworkLayout(n);m=r.sceneNodes??[],x=r.sceneEdges??[],b=r.labels??[],v=r.overlays??null}else if(f){f.computeLayout(y,g,p,[h,d]);const t=f.buildScene(y,g,p,[h,d]);m=t.sceneNodes,x=t.sceneEdges,b=t.labels}const w=io(i);for(const t of b)t.fill||(t.fill=w.text);e&&(e.evidence=ro({frameType:"network",width:r[0],height:r[1],marks:[...m.map(t=>({type:"node:"+(t.type??"node")})),...x.map(t=>({type:"edge:"+(t.type??"edge")}))],title:t.title,description:t.description,annotations:t.annotations,nodeCount:m.length,edgeCount:x.length}));const k=x.map((e,i)=>xr({node:e,index:i,renderMode:t.renderMode,fallback:()=>function(t,e){switch(t.type){case"line":return cr("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity},"net-edge-"+e);case"bezier":{const i=t;return cr("path",{d:i.pathD,fill:hr(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+e)}case"ribbon":{const i=t;return cr("path",{d:i.pathD,fill:hr(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+e)}case"curved":{const i=t;return cr("path",{d:i.pathD,fill:hr(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity},"net-edge-"+e)}default:return null}}(e,i)})).filter(Boolean),S=m.map((e,i)=>xr({node:e,index:i,renderMode:t.renderMode,fallback:()=>function(t,e){switch(t.type){case"circle":{const i=t,o=tr(i.style.fill)?er(i.style.fill,`net-circle-${e}-hatch`):void 0;return lr(Kn.Fragment,{children:[o&&cr("defs",{children:o}),cr("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:o?`url(#net-circle-${e}-hatch)`:hr(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-circle-"+e)}case"rect":{const i=t,o=tr(i.style.fill)?er(i.style.fill,`net-rect-${e}-hatch`):void 0;return lr(Kn.Fragment,{children:[o&&cr("defs",{children:o}),cr("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:o?`url(#net-rect-${e}-hatch)`:hr(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-rect-"+e)}case"arc":{const i=t,o=Un().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(ur)||"",n=tr(i.style.fill)?er(i.style.fill,`net-arc-${e}-hatch`):void 0;return lr(Kn.Fragment,{children:[n&&cr("defs",{children:n}),cr("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:n?`url(#net-arc-${e}-hatch)`:hr(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-arc-"+e)}case"symbol":{const i=t,o=sn(i.symbolType,i.size,i.path);return cr("path",{d:o,transform:i.rotation?`translate(${i.cx},${i.cy}) rotate(${180*i.rotation/Math.PI})`:`translate(${i.cx},${i.cy})`,fill:i.style.fill?hr(i.style.fill):"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-symbol-"+e)}case"glyph":return fr(t,t.cx,t.cy,"net-glyph-"+(t.id??e));default:return null}}(e,i)})).filter(Boolean),A=b.map((t,e)=>function(t,e){return cr("text",{x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"var(--semiotic-text, #333)",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,children:t.text},"net-label-"+e)}(t,e)).filter(Boolean),M=t.annotations?_s({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{},layout:{width:h,height:d},theme:i,idPrefix:t._idPrefix}):null,_=t.showLegend?(()=>{const e="string"==typeof(o=t.colorBy)||"function"==typeof o?t.colorBy:void 0;var o;if(!e)return[];const n=Tr(y.length>0?y.map(t=>t.data||{id:t.id}):Array.from(new Set(g.flatMap(t=>[$s(t.source),$s(t.target)]).filter(Boolean))).map(t=>({id:t})),e);return 0===n.length?null:Rr({categories:n,colorScheme:t.colorScheme,theme:i,position:t.legendPosition||"right",totalWidth:r[0],totalHeight:r[1],margin:a,hasTitle:c,legendLayout:t.legendLayout})})():null,P=va.isValidElement(t.legend)?t.legend:Es(t.legend,{theme:i,position:t.legendPosition||"right",size:r,margin:a,hasTitle:c,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||_;return wa.renderToStaticMarkup(Is(hl(ul,{children:[t.backgroundGraphics,k,S,A,M,t.foregroundGraphics,v]}),{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${a.left},${a.top})`,innerWidth:h,innerHeight:d,legend:P,idPrefix:t._idPrefix}))}import*as yl from"react";import*as gl from"react-dom/server";import{geoPath as ml}from"d3-geo";import{quadtree as xl}from"d3-quadtree";import{geoMercator as bl,geoEqualEarth as vl,geoAlbersUsa as wl,geoOrthographic as kl,geoNaturalEarth1 as Sl,geoEquirectangular as Al}from"d3-geo";var Ml={mercator:bl,equalEarth:vl,albersUsa:wl,orthographic:kl,naturalEarth:Sl,equirectangular:Al};function _l(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Pl(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Rl(t,e,i){return t?"function"==typeof t?{...i,...t(e)}:{...i,...t}:{...i}}function Tl(t,e){if(2>t.length)return[t];const i=.4*e,o=[];let n=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>i?(2>n.length||o.push(n),n=[r]):n.push(r)}return 2>n.length||o.push(n),o}function Ll(t,e,i=24){const o=e[0]-t[0],n=e[1]-t[1],r=Math.sqrt(o*o+n*n);if(0===r)return[t,e];const s=-n/r,a=o/r,c=Math.min(.3*r,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let o=0;i>=o;o++){const n=o/i,r=1-n;h.push([r*r*t[0]+2*r*n*l+n*n*e[0],r*r*t[1]+2*r*n*u+n*n*e[1]])}return h}function Cl(t,e){if(2>t.length)return t;const i=e/2+1,o=[];for(let e=0;t.length>e;e++){const n=t[e];let r,s;0===e?(r=t[1][0]-n[0],s=t[1][1]-n[1]):e===t.length-1?(r=n[0]-t[e-1][0],s=n[1]-t[e-1][1]):(r=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(r*r+s*s)||1;o.push([n[0]+s/a*i,n[1]+-r/a*i])}return o}function $l(t,e,i,o,n){const r=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(r*r+s*s);if(0===a)return[t,e];const c=s/a,l=-r/a,u=n/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}import{scaleLinear as zl}from"d3-scale";var Dl=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],El=["scene-style","data-paint","accessibility","evidence"],Nl=(t,e)=>({retainedData:t,invalidations:e}),Il=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Bl=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Fl=["scene-geometry","data-paint","accessibility","evidence"],Ol=["scene-style","data-paint","accessibility","evidence"],Wl=["overlay","accessibility","evidence"],jl=[],Yl={xAccessor:Nl("rebuild",Il),yAccessor:Nl("rebuild",Il),lineDataAccessor:Nl("rebuild",Il),pointIdAccessor:Nl("rebuild",Fl),lineIdAccessor:Nl("rebuild",Fl),windowSize:Nl("rebuild",Il),projection:Nl("preserve",Bl),projectionExtent:Nl("preserve",Bl),fitPadding:Nl("preserve",Bl),lineType:Nl("preserve",Bl),flowStyle:Nl("preserve",Bl),graticule:Nl("preserve",Bl),projectionTransform:Nl("preserve",Bl),customLayout:Nl("preserve",Bl),layoutConfig:Nl("preserve",Bl),layoutMargin:Nl("preserve",Bl),areaStyle:Nl("preserve",Ol),pointStyle:Nl("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:Nl("preserve",Ol),colorScheme:Nl("preserve",Ol),themeCategorical:Nl("preserve",Ol),themeDiverging:Nl("preserve",Ol),themeSemantic:Nl("preserve",Ol),themeSequential:Nl("preserve",Ol),decay:Nl("preserve",Ol),pulse:Nl("preserve",Ol),layoutSelection:Nl("preserve",Ol),annotations:Nl("preserve",Wl),autoPlaceAnnotations:Nl("preserve",Wl),clock:Nl("preserve",jl),transition:Nl("preserve",jl),introAnimation:Nl("preserve",jl),onLayoutError:Nl("preserve",jl)},Xl=Nl("preserve",Bl),ql=class{constructor(){this.tracker=new ci}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},Dl)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},El):this.recordNoop("restyle")}recordConfig(t,e={}){const i=function(t){let e="preserve";const i=new Set;for(const o of t){const t=Yl[o]??Xl;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}(t),o=new Set(i.invalidations);return e.retainedDataChanged&&o.add("data"),this.tracker.record({kind:"config",keys:t},o)}};import{geoDistance as Gl,geoGraticule as Vl,geoInterpolate as Hl}from"d3-geo";function Zl(t){if(null==t)return 0;if("number"==typeof t&&Number.isFinite(t)&&t>=0&&.5>t)return t;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${t+""}.`)}var Kl=class t{constructor(t){this.updateResults=new ql,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.config=function(t){return{...t,fitPadding:Zl(t.fitPadding)}}(t)}currentTime(){return this.config.clock?.()??_o()}getConfiguredWindowSize(){const t=this.config.windowSize??500;if(!Number.isInteger(t)||1>t)throw Error("GeoPipelineStore windowSize must be a positive integer");return t}retainNewestLines(t=this.getConfiguredWindowSize()){this.lineData.length>t&&(this.lineData=this.lineData.slice(-t))}resizeStreamingWindow(t){if(this.pointBuffer){const e=this.pointBuffer.toArray(),i=this.timestampBuffer?.toArray()??[],o=e.slice(-t),n=i.slice(-o.length),r=this.currentTime();this.pointBuffer=new fo(t),this.timestampBuffer=new fo(t),o.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(n[e]??r)})}this.retainNewestLines(t)}updateConfig(t){const e=function(t){return"fitPadding"in t?{...t,fitPadding:Zl(t.fitPadding)}:t}(t),i=this.config,o=this.getConfiguredWindowSize(),n=Object.keys(e).filter(t=>e[t]!==i[t]);this.config={...this.config,...e};const r=this.getConfiguredWindowSize(),s=this.streaming&&r!==o;s&&(this.resizeStreamingWindow(r),this.version++),"customLayout"in e&&!e.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(n,{retainedDataChanged:s})}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setAreas(t){this.areas=t,this.updateResults.recordData("replace",t.length)}setAreasWithResult(t){return this.setAreas(t),this.updateResults.last}setPoints(t){this.pointData=t.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",t.length)}setPointsWithResult(t){return this.setPoints(t),this.updateResults.last}setLines(t){this.lineData=t.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",t.length)}setLinesWithResult(t){return this.setLines(t),this.updateResults.last}initStreaming(t){void 0!==t&&t!==this.config.windowSize&&(this.config={...this.config,windowSize:t});const e=this.getConfiguredWindowSize(),i=this.pointBuffer?this.pointBuffer.toArray():this.pointData,o=this.timestampBuffer?.toArray()??[],n=i.slice(-e),r=o.slice(-n.length),s=this.currentTime();this.pointBuffer=new fo(e),this.timestampBuffer=new fo(e),n.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(r[e]??s)}),this.pointData=[],this.retainNewestLines(e),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();Sn(this.pointBuffer,t,this.timestampBuffer,e),this.lastIngestTime=e,this.updateResults.recordData("ingest",1)}pushPointWithResult(t){return this.pushPoint(t),this.updateResults.last}pushMany(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();for(const i of t)Sn(this.pointBuffer,i,this.timestampBuffer,e);this.lastIngestTime=e,this.updateResults.recordData("ingest",t.length)}pushManyWithResult(t){return this.pushMany(t),this.updateResults.last}pushLine(t){null!=t&&"object"==typeof t?(this.streaming||this.initStreaming(),this.lineData.push(t),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(t){if(!Array.isArray(t)||0===t.length)return void this.updateResults.recordNoop("ingest");const e=t.filter(t=>null!=t&&"object"==typeof t);if(0!==e.length){this.streaming||this.initStreaming();for(const t of e)this.lineData.push(t);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",e.length)}else this.updateResults.recordNoop("ingest")}removeLine(t){const{lineIdAccessor:e}=this.config;if(!e)throw Error("removeLine() requires lineIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]),n=[];return this.lineData=this.lineData.filter(t=>!o.has(i(t)+"")||(n.push(t),!1)),n.length>0?(this.version++,this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n}getLines(){return this.lineData.slice()}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(i(t)+"");An(this.pointBuffer,this.timestampBuffer,t);const e=this.pointBuffer.remove(t);return e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(i(e)+"")||(t.push(e),!1)),t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,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++,this.updateResults.recordData("clear")}restyleScene(t){const e=this._customRestyle;if(e){for(const i of this.scene){const o=this._baseStyles.get(i)??i.style,n=e(i,t);i.style=n?{...o,...n}:o}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(t){const{config:e}=this,i=this.projection,o=this.geoPath,n=this.scales,r=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(t){if(!t)return vl();if("string"==typeof t){const e=Ml[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),vl())}if("object"==typeof t&&"type"in t){const e=Ml[t.type],i=e?e():vl();return t.rotate&&"rotate"in i&&i.rotate(t.rotate),t.center&&"center"in i&&i.center(t.center),i}return t}(e.projection),this.geoPath=ml(this.projection),this.fitProjection(t),this.geoPath=ml(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(t,e)=>l([t,e]),invertedPoint:(t,e)=>l.invert?l.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(t);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=i,this.geoPath=o,this.scales=n,this.baseScale=r,this.baseTranslate=s,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,i=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>({...t,x:e,y:i}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(t){const e=this.projection,i=this.config,o=[...this.areas],n=_l(i.xAccessor,"lon"),r=_l(i.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const t=s.map(t=>[n(t),r(t)]);o.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const a=Pl(i.lineDataAccessor);for(const t of this.lineData){const e=a(t);if(e&&e.length>0){const t=e.map(t=>[n(t),r(t)]);o.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==o.length){if(i.projectionExtent){const[[o,n],[r,s]]=i.projectionExtent;e.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[o,n],[r,n],[r,s],[o,s],[o,n]]]}})}else if(e.clipAngle&&(e.clipAngle()??0)>0){const o=i.fitPadding??0,n=Math.min(t.width,t.height);e.scale(n/2-n*o),e.translate([t.width/2,t.height/2])}else{const n=i.fitPadding??0,r=t.width*n,s=t.height*n;e.fitExtent([[r,s],[t.width-r,t.height-s]],{type:"FeatureCollection",features:o})}this.baseScale=e.scale(),this.baseTranslate=e.translate(),this.baseRotation=e.rotate?.()??[0,0,0]}}applyZoomTransform(t,e){const i=this.projection;if(!i)return;const o=this.geoPath,n=this.scales,r=i.scale(),s=[...i.translate()],a=this.currentZoom;i.scale(this.baseScale*t.k),i.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=ml(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(r),i.translate(s),this.currentZoom=a,this.geoPath=o,this.scales=n):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const i=this.projection;if(!i)return;const o=this.geoPath,n=this.scales,r=i.scale(),s=[...i.translate()],a=this.currentZoom;i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=ml(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(r),i.translate(s),this.currentZoom=a,this.geoPath=o,this.scales=n):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const i=this.projection;if(!i||!i.rotate)return;const o=this.geoPath,n=this.scales,r=[...i.rotate()];i.rotate(t),this.geoPath=ml(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.rotate(r),this.geoPath=o,this.scales=n):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}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 e=0,i=0;for(const t of this.scene)"point"===t.type&&(i++,t.r>e&&(e=t.r));if(this._maxPointRadius=e,t.QUADTREE_THRESHOLD>=i)return void(this._quadtree=null);const o=Array(i);let n=0;for(const t of this.scene)"point"===t.type&&(o[n++]=t);this._quadtree=xl().x(t=>t.x).y(t=>t.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){this._customLayoutFailedThisBuild=!1;const{config:e}=this,i=this.projection,o=this.geoPath;if(e.customLayout&&this.scales){const i=e.layoutMargin??{top:0,right:0,bottom:0,left:0},o=Wi(e.colorScheme,e.themeCategorical,S),n={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:t.width,height:t.height,margin:i,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:e.themeSemantic??{},categorical:[...o]},resolveColor:ji(o,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};let r;try{r=e.customLayout(n)}catch(t){const i=null!==this.lastCustomLayoutResult,o=dn("geo",t,i,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",t);try{e.onLayoutError?.(o)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return i?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const s=r.nodes??[];if(this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null,this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const t of s)this._baseStyles.set(t,t.style);this.restyleScene(e.layoutSelection??null)}return ln({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,function({config:t,projection:e,path:i,areas:o,points:n,lines:r,layout:s}){const a=_l(t.xAccessor,"lon"),c=_l(t.yAccessor,"lat"),l=[],u=function(t){return{fill:t.themeSemantic?.surface||"#e0e0e0",stroke:t.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(t),h=function(t){return{stroke:t.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(t),d=function(t){return{fill:t.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(t);if(t.graticule){const e=!0===t.graticule?{}:t.graticule,o=Vl();e.step&&o.step(e.step);const n=i(o())||"";n&&l.push({type:"geoarea",pathData:n,centroid:[s.width/2,s.height/2],bounds:[[0,0],[s.width,s.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of o){const o=i(e);if(!o)continue;const n=i.centroid(e),r=i.bounds(e),s=i.area(e);l.push({type:"geoarea",pathData:o,centroid:n,bounds:r,screenArea:s,style:Rl(t.areaStyle,e,u),datum:e,interactive:!0})}const f=Pl(t.lineDataAccessor);for(const i of r){const o=f(i);if(!o||2>o.length)continue;let n=[];if("geo"===t.lineType){const t=Array(o.length);for(let e=0;o.length>e;e++)t[e]=[a(o[e]),c(o[e])];for(let i=0;t.length-1>i;i++){const o=t[i],r=t[i+1],s=Gl(o,r)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=Hl(o,r);for(let t=0;a>=t;t++){if(i>0&&0===t)continue;const o=e(c(t/a));null!=o&&n.push(o)}}}else for(let t=0;o.length>t;t++){const i=o[t],r=e([a(i),c(i)]);null!=r&&n.push(r)}if(2>n.length)continue;const r=Rl(t.lineStyle,i,h),u="number"==typeof r.strokeWidth?r.strokeWidth:1;2!==o.length||2>n.length||"arc"!==t.flowStyle?2!==o.length||2>n.length||"offset"!==t.flowStyle||(n="geo"===t.lineType?Cl(n,u):$l(n[0],n[n.length-1],0,0,u)):n=Ll(n[0],n[n.length-1]);const d=Tl(n,s.width);if(d.length>1)for(const t of d)2>t.length||l.push({type:"line",path:t,style:{...r,_edgeFade:!0},datum:i});else l.push({type:"line",path:2>n.length&&d[0]||n,style:r,datum:i})}const p=t.pointIdAccessor?"function"==typeof t.pointIdAccessor?t.pointIdAccessor:e=>e[t.pointIdAccessor]:null,y=e.clipAngle?e.clipAngle()??0:0,g=y>0?y*Math.PI/180:null,m=e.rotate?e.rotate():[0,0,0],x="function"==typeof e.center?e.center():[0,0],b=[(x[0]??0)-m[0],(x[1]??0)-m[1]];for(const i of n){const o=a(i),n=c(i);if(null!=g&&Gl([o,n],b)>g)continue;const r=e([o,n]);if(!r)continue;const s=t.pointStyle?t.pointStyle(i):{...d},u={type:"point",x:r[0],y:r[1],r:s.r||4,style:s,datum:i,pointId:p?p(i)+"":void 0};l.push(u)}return l}({config:e,projection:i,path:o,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:t})}applyCartogramTransform(t,e){const i=function(t,e,i,o){const n=t.filter(t=>"point"===t.type);if(2>n.length)return null;const r=e.strength??1;if(0===r)return null;const s=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:t=>t.id,a="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],c=n.find(t=>t.datum&&s(t.datum)+""==e.center+"");if(!c)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`),null;const l=c.x,u=c.y,h=st(n.map(t=>t.datum?a(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),1),d=Math.min(i.width,i.height)/2,f=zl().domain([0,h]).range([0,d]);o>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 e=t.length-1;e>=0;e--){const i=t[e];"geoarea"===i.type&&i.interactive&&t.splice(e,1)}for(const t of n){if(t===c)continue;if(!t.datum)continue;const e=Math.atan2(t.y-u,t.x-l),i=Math.sqrt((t.x-l)**2+(t.y-u)**2),o=a(t.datum),n=i+((isFinite(o)?f(o):i)-i)*r;t.x=l+Math.cos(e)*n,t.y=u+Math.sin(e)*n}const p=i.width/2,y=i.height/2,g=p-c.x,m=y-c.y;if(Math.abs(g)>.5||Math.abs(m)>.5)for(const t of n)t.x+=g,t.y+=m;const x={cx:p,cy:y,maxCost:h,availableRadius:d},b=t.filter(t=>"line"===t.type);if(b.length>0&&"fractional"!==e.lineMode){const t=new Map;for(const e of n)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of b){const i=e.datum?.source,o=e.datum?.target;if(i&&o){const n=t.get(i+""),r=t.get(o+"");n&&r&&(e.path=[n,r])}}}return x}(this.scene,t,e,this.areas.length);i&&(this.cartogramLayout=i)}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const i=this.scene.filter(t=>"point"===t.type);for(let o=0;i.length>o;o++){const n=Po(t,o,e);i[o]._decayOpacity=n,i[o].style={...i[o].style,opacity:n}}}applyPulse(t=this.currentTime()){const e=this.config.pulse;if(!e||!this.timestampBuffer)return!1;const i=this.scene.filter(t=>"point"===t.type),o=this.timestampBuffer.toArray(),n=e.color||"rgba(255,255,255,0.6)",r=e.glowRadius??4;let s=!1;for(let a=0;i.length>a&&o.length>a;a++){const c=To(e,o[a],t);s=Lo(i[a],c,n,r)||s}return s}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(t)}hasActivePulsesAt(t){return!!this.config.pulse&&Co(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(t){const e=this.config.transition?.duration??300;if(0>=e)return;const i=new Map;for(const e of t)"point"===e.type&&e.pointId&&i.set(e.pointId,[e.x,e.y]);const o=this.scene.filter(t=>"point"===t.type);let n=!1;for(const t of o)if(t.pointId){const e=i.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(n=!0))}for(const t of o)t.pointId&&!i.has(t.pointId)&&(t._targetOpacity=t.style?.opacity??1,t.style={...t.style,opacity:0},n=!0);n&&(this.activeTransition={startTime:this.currentTime(),duration:e})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=Ao(t,this.activeTransition),i=So(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=Mo(t.x,t._targetX,i),t.y=Mo(e,t._targetY,i)}null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity*i})}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0),null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity},t._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};Kl.QUADTREE_THRESHOLD=500;var Ul=Kl;$n(Ul);import{Fragment as Ql,jsxs as Jl}from"react/jsx-runtime";function tu(t,e){const i=eo(t.theme),o=t.size||[t.width||600,t.height||400],n=Ts({top:10,right:10,bottom:10,left:10,...t.margin},t.title),r=Rs(t.title),s=Array.isArray(t.areas)?lo(t.areas):t.areas,a=lo(t.points),c=lo(t.lines),l=t.showLegend?(()=>{const e="string"==typeof(i=t.colorBy)||"function"==typeof i?t.colorBy:void 0;var i;return Tr(a.length>0?a:Array.isArray(s)&&s.length>0?"string"==typeof e?s.map(t=>({...t.properties||{},...t})):s:[],e)})():[],u=t.legendPosition;so(t.legend)||ao(t.legend)?Ds(n,{legend:t.legend,theme:i,position:u||"right",size:o,hasTitle:r,legendLayout:t.legendLayout}):t.showLegend&&l.length>0&&zs(n,{categories:l,colorScheme:t.colorScheme,theme:i,position:u||"right",size:o,hasTitle:r,legendLayout:t.legendLayout});const h=o[0]-(n.left??0)-(n.right??0),d=o[1]-(n.top??0)-(n.bottom??0),f={projection:t.projection||"equalEarth",xAccessor:t.xAccessor,yAccessor:t.yAccessor,lineDataAccessor:t.lineDataAccessor,pointIdAccessor:t.pointIdAccessor,lineType:t.lineType,areaStyle:t.areaStyle,pointStyle:t.pointStyle,lineStyle:t.lineStyle,graticule:t.graticule,fitPadding:t.fitPadding,projectionTransform:t.projectionTransform,customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:n,themeCategorical:i.colors.categorical,themeSemantic:It(i)},p=new Ul(f);if(s){if("string"==typeof s)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${s}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${s}')\` before calling renderGeoToStaticSVG.`);p.setAreas(s)}if(t.points&&p.setPoints(a),t.lines&&p.setLines(c),p.computeScene({width:h,height:d}),e&&(e.evidence=ro({frameType:"geo",width:o[0],height:o[1],marks:p.scene,title:t.title,description:t.description,annotations:t.annotations,legendItems:l.length>0?l.length:void 0})),0===p.scene.length){const e=t.backgroundGraphics||t.foregroundGraphics||t.annotations||p.customLayoutOverlays?Jl(Ql,{children:[t.backgroundGraphics,t.annotations?_s({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{geoProjection:p.scales?.projectedPoint?([t,e])=>p.scales.projectedPoint(t,e):void 0},layout:{width:h,height:d},theme:i,idPrefix:t._idPrefix}):null,t.foregroundGraphics,p.customLayoutOverlays]}):null;return gl.renderToStaticMarkup(Is(e,{width:o[0],height:o[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left??0},${n.top??0})`,innerWidth:h,innerHeight:d,idPrefix:t._idPrefix}))}const y=p.scene.map((e,i)=>xr({node:e,index:i,renderMode:t.renderMode,fallback:()=>function(t,e){switch(t.type){case"geoarea":{const i=t;if(!i.pathData)return null;const o=tr(i.style.fill)?er(i.style.fill,`geoarea-${e}-hatch`):void 0;return lr(Kn.Fragment,{children:[o&&cr("defs",{children:o}),cr("path",{d:i.pathData,fill:o?`url(#geoarea-${e}-hatch)`:hr(i.style.fill,"#e0e0e0"),fillOpacity:i.style.fillOpacity??1,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth||.5,strokeDasharray:i.style.strokeDasharray,opacity:i._decayOpacity??1})]},"geoarea-"+e)}case"point":{const i=t,o=tr(i.style.fill)?er(i.style.fill,`geopoint-${e}-hatch`):void 0;return lr(Kn.Fragment,{children:[o&&cr("defs",{children:o}),cr("circle",{cx:i.x,cy:i.y,r:i.r,fill:o?`url(#geopoint-${e}-hatch)`:hr(i.style.fill),fillOpacity:i.style.fillOpacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i._decayOpacity??i.style.opacity??1})]},"point-"+e)}case"line":{const i=t;if(2>i.path.length)return null;const o="M"+i.path.map(t=>`${t[0]},${t[1]}`).join("L");return cr("path",{d:o,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||1.5,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity??1},"line-"+e)}case"glyph":return fr(t,t.x,t.y,"geo-glyph-"+(t.pointId??e));default:return null}}(e,i)})).filter(Boolean),g=t.annotations?_s({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{geoProjection:p.scales?.projectedPoint?([t,e])=>p.scales.projectedPoint(t,e):void 0},layout:{width:h,height:d},theme:i,idPrefix:t._idPrefix}):null,m=t.showLegend?0===l.length?null:Rr({categories:l,colorScheme:t.colorScheme,theme:i,position:t.legendPosition||"right",totalWidth:o[0],totalHeight:o[1],margin:n,hasTitle:r,legendLayout:t.legendLayout}):null,x=yl.isValidElement(t.legend)?t.legend:Es(t.legend,{theme:i,position:t.legendPosition||"right",size:o,margin:n,hasTitle:r,legendLayout:t.legendLayout,idPrefix:t._idPrefix})||m;return gl.renderToStaticMarkup(Is(Jl(Ql,{children:[t.backgroundGraphics,y,g,t.foregroundGraphics,p.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${n.left??0},${n.top??0})`,innerWidth:h,innerHeight:d,legend:x,idPrefix:t._idPrefix}))}import*as eu from"react-dom/server";function iu(t=[]){return t.map(t=>({id:t.id,label:t.label,count:t.count,...null!=t.secondary?{secondary:t.secondary}:{},...t.secondaryLabel?{secondaryLabel:t.secondaryLabel}:{},...null!=t.observed?{observed:t.observed}:{}}))}var ou={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function nu(t){const e=t.datum;if(e&&"object"==typeof e){const t=e.label??e.name??e.id;if(null!=t&&""!==t)return t+""}return t.id}function ru(t,e){const i="function"==typeof e?e(t):e;return{...ou,...i??{}}}function su(t,e={}){return t.map(t=>function(t,e={}){const i=function(t){return t.datum&&"object"==typeof t.datum?t.datum:null}(t),o={label:e.getBodyLabel?.(t)??nu(t)},n={style:ru(t,e.bodyStyle),datum:i,accessibleDatum:i,accessibility:o,_transitionKey:t.id};return"aabb"===t.shape.type?{type:"rect",x:t.x-t.shape.width/2,y:t.y-t.shape.height/2,w:t.shape.width,h:t.shape.height,...n}:{type:"point",x:t.x,y:t.y,r:t.shape.radius,pointId:t.id,...n}}(t,e))}import{jsx as au,jsxs as cu}from"react/jsx-runtime";function lu(t,e){const i=t.size??[t.width??600,t.height??400],o=new Ai(t.config);Array.isArray(t.initialSpawns)&&t.initialSpawns.length>0&&o.enqueue(t.initialSpawns.map(t=>({...t,spawnAt:void 0})));const n=function(t,e={}){const{width:i=640,height:o=360,title:n,description:r,background:s,className:a,idPrefix:c="physics",...l}=e,u=function(t,e={}){const i=t.settle(e.maxSteps),o=t.readBodies(),n=t.snapshot(),r=su(o,e),s=function(t,e={}){const i=e.bodies??function(t){return t.world.bodies.map(t=>({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:{...t.shape},sleeping:t.sleeping,datum:t.datum}))}(t),o=i.filter(t=>t.sleeping).length;return{bodyCount:i.length,sleepingCount:o,settled:"settled"===t.simulationState&&0===t.queue.length&&o===i.length,stepsRun:Math.max(0,Math.floor(e.stepsRun??0)),seed:t.world.options.seed,binCounts:iu(e.projectionRows)}}(n,{bodies:o,projectionRows:e.projectionRows,stepsRun:i});return{snapshot:n,bodies:o,sceneNodes:r,evidence:s,stepsRun:i}}(t,l),h=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"physics-"+e:e}(c),d=n?h+"-title":void 0,f=r?h+"-desc":void 0,p=[d,f].filter(Boolean).join(" ")||void 0;return{svg:eu.renderToStaticMarkup(cu("svg",{xmlns:"http://www.w3.org/2000/svg",className:a??"stream-physics-frame",width:i,height:o,viewBox:`0 0 ${i} ${o}`,role:"img","aria-labelledby":p,children:[n&&au("title",{id:d,children:n}),r&&au("desc",{id:f,children:r}),s&&"transparent"!==s?au("rect",{x:0,y:0,width:i,height:o,fill:s}):null,au("g",{id:h+"-data-area",children:u.sceneNodes.map((t,e)=>yr(t,e,h))})]})),scene:u,evidence:u.evidence}}(o,{...t,width:i[0],height:i[1],idPrefix:t.idPrefix??t._idPrefix??"physics"});return e&&(e.evidence=ro({frameType:"physics",width:i[0],height:i[1],marks:n.scene.sceneNodes,title:t.title,description:t.description,annotations:[],extraWarnings:0===n.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),n.svg}import{Fragment as uu,jsx as hu,jsxs as du}from"react/jsx-runtime";function fu(t,e){switch(t){case"xy":return Ws(e);case"ordinal":return ba(e);case"network":return pl(e);case"geo":return tu(e);case"physics":return lu(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function pu(t){return Ws(t)}function yu(t){return ba(t)}function gu(t){return pl(t)}function mu(t){return tu(t)}var xu=["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 bu(t,e,i){return wu(t,e).svg}function vu(t,e,i){const o={},{svg:n,frameType:r}=wu(t,e,0,o),s=o.evidence??ro({frameType:r,width:"number"==typeof e.width?e.width:600,height:"number"==typeof e.height?e.height:400,marks:[],title:"string"==typeof e.title?e.title:void 0,description:"string"==typeof e.description?e.description:void 0,annotations:e.annotations,extraWarnings:["NO_EVIDENCE"]});return s.component=t,{svg:n,evidence:s}}function wu(e,i,o,n){const{data:r,width:s=600,height:a=400,theme:c,title:l,description:u,showLegend:h,showGrid:d,background:f,className:p,annotations:y,margin:g,colorScheme:m,colorBy:x,legendPosition:b,...v}=i,w=[s,a],k={...v.frameProps||{},...function(t,e){const i={};for(const o of e)void 0!==t[o]&&(i[o]=t[o]);return i}(v,xu),theme:c,title:l,description:u,showLegend:h,showGrid:d,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=to[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;switch(S.frameType){case"xy":M=Ws(A,n);break;case"ordinal":M=ba(A,n);break;case"network":M=pl(A,n);break;case"geo":M=tu(A,n);break;case"physics":M=lu(A,n)}if("GaugeChart"===e&&A.__gauge){const e=A.__gauge,i=k.margin||{top:20,right:20,bottom:30,left:40},o=(s||300)-i.left-i.right,n=(a||300)-i.top-i.bottom,r=Math.min(o,n)/2*.85,l=i.left+o/2,u=i.top+n/2,h=(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,d=eo(c).colors.text,f=t.renderToStaticMarkup(du(uu,{children:[hu("line",{x1:l,y1:u,x2:l+r*Math.cos(h),y2:u+r*Math.sin(h),stroke:d,strokeWidth:2.5,strokeLinecap:"round"}),hu("circle",{cx:l,cy:u,r:4,fill:d})]}));M=M.replace("</svg>",f+"</svg>")}return{svg:M,frameType:S.frameType}}async function ku(t,e,i={}){const{format:o="png",scale:n=1,background:r}=i;let s,a;s=["xy","ordinal","network","geo","physics"].includes(t)?fu(t,e):bu(t,e),r&&(s=s.replace(/<svg /,`<svg style="background:${r}" `));try{const t="sharp",e=await import(t);a=e.default??e}catch{throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const c=e.width||e.size?.[0]||600,l=e.height||e.size?.[1]||400,u=a(void 0!==globalThis.Buffer?globalThis.Buffer.from(s):(new TextEncoder).encode(s),{density:72*n}).resize(Math.round(c*n),Math.round(l*n));return"jpeg"===o?u.jpeg({quality:90}).toBuffer():u.png().toBuffer()}function Su(e,i={}){const{title:o,subtitle:n,theme:r,width:s=1200,height:a,layout:c={},background:l}=i,u=io(eo(r)),h=c.columns||2,d=c.gap??16;let f=0;o&&(f+=30),n&&(f+=20),f>0&&(f+=10);const p=Math.floor((s-d-d*(h-1))/h),y=[];let g=0,m=f+d,x=0;for(const t of e){const e=Math.min(t.colSpan||1,h),i=t.props.height||300;g+e>h&&(m+=x+d,g=0,x=0),y.push({chart:t,x:d/2+g*(p+d),y:m,w:p*e+d*(e-1),h:i}),x=Math.max(x,i),g+=e}const b=a||m+x+d,v=y.map((t,e)=>{const{chart:i,x:o,y:n,w:s,h:a}=t,c={...i.props,width:s,height:a,theme:r,_idPrefix:"chart-"+e};let l;return l=i.component?bu(i.component,c):i.frameType?fu(i.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,hu("g",{transform:`translate(${o},${n})`,children:hu("foreignObject",{width:s,height:a,children:hu("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+e)});return t.renderToStaticMarkup(du("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:b,role:"img","aria-label":o||"Dashboard",style:{fontFamily:u.fontFamily},children:[o&&hu("title",{children:o}),l&&hu("rect",{x:0,y:0,width:s,height:b,fill:l}),o&&hu("text",{x:s/2,y:24,textAnchor:"middle",fontSize:u.titleSize+4,fontWeight:"bold",fill:u.text,fontFamily:u.fontFamily,children:o}),n&&hu("text",{x:s/2,y:o?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:n}),v]}))}import*as Au from"react-dom/server";import{Fragment as Mu,jsx as _u,jsxs as Pu}from"react/jsx-runtime";function Ru(t,e,i,o={}){const{stepSize:n,windowSize:r,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:d}=o,f=i.width||600,p=i.height||400,y=eo(i.theme),g={...i,...a&&{xExtent:a},...c&&{yExtent:c}};if(!e||0===e.length)return[];const m=n||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),x=[];for(let t=m;e.length>=t;t+=m)x.push(t);x[x.length-1]!==e.length&&x.push(e.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),v=Ts({top:20,right:20,bottom:30,left:40,...i.margin},i.title),w=f-v.left-v.right,k=p-v.top-v.bottom,S=[];if(b)for(let o=0;x.length>o;o++){const n=x[o],s=e.slice(r?Math.max(0,n-r):0,n),a={chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical,...d&&{decay:d}},c=new fa(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:w,height:k}),c.scene.length>0&&S.push(Du(c.scene,f,p,y,g))}else for(let o=0;x.length>o;o++){const n=x[o],s=e.slice(r?Math.max(0,n-r):0,n),m={chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange,...d&&{decay:d},...l>0&&{transition:{duration:l*(1e3/u),easing:h}}},b=new Zn(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(zu(b.scene,f,p,y,g,v)),l>0&&o>0&&b.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)b.advanceTransition(b.activeTransition.startTime+e/l*t),S.push(zu(b.scene,f,p,y,g,v))}}return S}function Tu(t,e,i={}){return e.map(e=>{try{return bu(t,{...i,...e})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||e.width||600}" height="${i.height||e.height||400}"></svg>`}})}function Lu(t,e,i){const o=e.size??[e.width??600,e.height??400],n=eo(e.theme),r=io(n),s=e.background||n.colors.background,a=e.idPrefix??"physics-gif",c=e.title?`${a}-title-${i}`:void 0,l=e.description?`${a}-desc-${i}`:void 0,u=[c,l].filter(Boolean).join(" ")||void 0,h=su(t.readBodies(),{bodyStyle:e.bodyStyle,getBodyLabel:e.getBodyLabel}),d=Pu("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className??"stream-physics-frame",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,role:"img","aria-labelledby":u,style:{fontFamily:r.fontFamily},children:[e.title&&_u("title",{id:c,children:e.title}),e.description&&_u("desc",{id:l,children:e.description}),s&&"transparent"!==s?_u("rect",{x:0,y:0,width:o[0],height:o[1],fill:s}):null,_u("g",{id:`${a}-frame-${i}`,children:h.map((t,e)=>yr(t,e,`${a}-${i}`))})]});return Au.renderToStaticMarkup(d)}function Cu(t,e={}){const{fps:i=12,frameCount:o,durationSeconds:n=2,includeInitialFrame:r=!0,stepDt:s,stepsPerFrame:a,background:c}=e,l=Math.max(.001,s??t.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,i)/l)),h=o??Math.max(1,Math.ceil(n*Math.max(1,i))),d=c?{...t,background:c}:t,f=new Ai(t.config);t.initialSpawns?.length&&f.enqueue(t.initialSpawns,t.initialSpawnPacing);const p=[];for(r&&(f.tick(0),p.push(Lu(f,d,0)));h>p.length;){for(let t=0;u>t;t+=1)f.tick(l);p.push(Lu(f,d,p.length))}return p}function $u(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function zu(t,e,i,o,n,r){const s=io(o),a=Ts({top:20,right:20,bottom:30,left:40,...n.margin},n.title),c=e-a.left-a.right,l=i-a.top-a.bottom,u=$u(n,o),h=n.renderMode,d=t.map((t,e)=>xr({node:t,index:e,renderMode:h,fallback:()=>yr(t,e)})).filter(Boolean),f=function(t,e,i,o,n,r){if(!t||0===t.length)return null;const s=io(o),a=[];for(let o=0;t.length>o;o++){const c=t[o];if("y-threshold"===c.type&&null!=c.value){let t=null;if(r)t=r(c.value);else if(n){const[e,o]=n,r=o-e;if(0===r)continue;t=i-(c.value-e)/r*i}if(null==t)continue;const l=c.color||s.primary,u=c.labelPosition||"right";a.push(Pu("g",{children:[_u("line",{x1:0,y1:t,x2:e,y2:t,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&_u("text",{x:"left"===u?4:"center"===u?e/2:e-4,y:20>t?Math.min(i-4,t+16):t-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:s.tickSize,fill:l,fontFamily:s.fontFamily,children:c.label})]},"ann-"+o))}}return a.length>0?_u(Mu,{children:a}):null}(n.annotations,c,l,o,n.yExtent,r?.y),p="string"==typeof n.title?n.title:void 0,y="string"==typeof n.description?n.description:void 0,g=p?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[g,m].filter(Boolean).join(" ")||void 0;return Au.renderToStaticMarkup(Pu("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:i,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[p&&_u("title",{id:g,children:p}),y&&_u("desc",{id:m,children:y}),u&&_u("rect",{x:0,y:0,width:e,height:i,fill:u}),Pu("g",{transform:`translate(${a.left},${a.top})`,children:[f,d]}),p&&_u("text",{x:e/2,y:22,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:p})]}))}function Du(t,e,i,o,n){const r=io(o),s=Ts({top:20,right:20,bottom:30,left:40,...n.margin},n.title),a="radial"===n.projection,c=a?s.left+(e-s.left-s.right)/2:s.left,l=a?s.top+(i-s.top-s.bottom)/2:s.top,u=$u(n,o),h=n.renderMode,d=t.map((t,e)=>xr({node:t,index:e,renderMode:h,fallback:()=>gr(t,e)})).filter(Boolean),f="string"==typeof n.title?n.title:void 0,p="string"==typeof n.description?n.description:void 0,y=f?"semiotic-title":void 0,g=p?"semiotic-desc":void 0,m=[y,g].filter(Boolean).join(" ")||void 0;return Au.renderToStaticMarkup(Pu("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:i,role:"img","aria-labelledby":m,style:{fontFamily:r.fontFamily},children:[f&&_u("title",{id:y,children:f}),p&&_u("desc",{id:g,children:p}),u&&_u("rect",{x:0,y:0,width:e,height:i,fill:u}),_u("g",{transform:`translate(${c},${l})`,children:d}),f&&_u("text",{x:e/2,y:22,textAnchor:"middle",fontSize:r.titleSize,fontWeight:"bold",fill:r.text,fontFamily:r.fontFamily,children:f})]}))}async function Eu(t,e,i,o={}){const{fps:n=12,loop:r=!0,scale:s=1,background:a}=o,c=i.width||600,l=i.height||400,u=Ru(t,e,a?{...i,background:a}:i,o);if(0===u.length)throw Error("No frames generated — check that data is not empty");return Iu(u,c,l,{fps:n,loop:r,scale:s})}async function Nu(t,e={}){const{fps:i=12,loop:o=!0,scale:n=1}=e,r=t.size??[t.width??600,t.height??400],s=Cu(t,e);if(0===s.length)throw Error("No physics frames generated");return Iu(s,r[0],r[1],{fps:i,loop:o,scale:n})}async function Iu(t,e,i,o={}){const{fps:n=12,loop:r=!0,scale:s=1}=o,a=Math.round(e*s),c=Math.round(i*s);let l,u,h,d;try{const t="sharp",e=await import(t);l=e.default??e}catch{throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=await import(t),i=[e,e.default].find(t=>"function"==typeof t?.GIFEncoder&&"function"==typeof t.quantize&&"function"==typeof t.applyPalette);if(!i)throw Error("gifenc did not expose its encoder functions");u=i.GIFEncoder,h=i.quantize,d=i.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc',{cause:t})}const f=Math.round(1e3/n),p=u();for(let e=0;t.length>e;e++){const i=t[e],o=await l(Buffer.from(i),{density:72*s}).resize(a,c).ensureAlpha().raw().toBuffer(),n=new Uint8Array(o),u=h(n,256),y=d(n,u);p.writeFrame(y,a,c,{palette:u,delay:f,repeat:r?0:-1})}return p.finish(),Buffer.from(p.bytes())}export{Ru as generateFrameSVGs,Tu as generateFrameSequence,Cu as generatePhysicsFrameSVGs,bu as renderChart,vu as renderChartWithEvidence,Su as renderDashboard,mu as renderGeoToStaticSVG,gu as renderNetworkToStaticSVG,yu as renderOrdinalToStaticSVG,Nu as renderPhysicsToAnimatedGif,Eu as renderToAnimatedGif,ku as renderToImage,fu as renderToStaticSVG,pu as renderXYToStaticSVG,eo as resolveTheme,io as themeStyles};