semiotic 3.9.0 → 3.9.2

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 (331) hide show
  1. package/README.md +102 -90
  2. package/agent-skill/semiotic-charts/SKILL.md +14 -10
  3. package/ai/componentMetadata.cjs +13 -3
  4. package/ai/dist/mcp-server.js +140 -36407
  5. package/ai/examples.md +109 -6
  6. package/ai/reference.md +55 -18
  7. package/ai/schema.json +5964 -1190
  8. package/ai/surface-manifest.json +51 -7
  9. package/ai/system-prompt.md +16 -3
  10. package/dist/c-3SCUN5HI.min.js +1 -0
  11. package/dist/c-3VVKFA4M.min.js +1 -0
  12. package/dist/c-43TJZS3F.min.js +1 -0
  13. package/dist/c-4DTZPSUD.min.js +1 -0
  14. package/dist/c-4ES5367Y.min.js +1 -0
  15. package/dist/c-54IRWOGM.min.js +1 -0
  16. package/dist/c-5D2S4RMI.min.js +1 -0
  17. package/dist/c-5JWCTX3G.min.js +1 -0
  18. package/dist/c-6CMMSN6N.min.js +1 -0
  19. package/dist/c-6HRB2L7H.min.js +1 -0
  20. package/dist/c-7W4SV36A.min.js +1 -0
  21. package/dist/c-A4WRGZFX.min.js +1 -0
  22. package/dist/c-AG7WWVIH.min.js +1 -0
  23. package/dist/c-AH6J4MTN.min.js +1 -0
  24. package/dist/c-ALYR5LKK.min.js +1 -0
  25. package/dist/c-BYDPC44I.min.js +1 -0
  26. package/dist/c-CFFIU2MW.min.js +1 -0
  27. package/dist/c-CGNHBHCE.min.js +1 -0
  28. package/dist/c-CJYSXIFV.min.js +1 -0
  29. package/dist/c-CKLIFCGN.min.js +1 -0
  30. package/dist/c-CZF7MV67.min.js +1 -0
  31. package/dist/c-D53OKBSY.min.js +1 -0
  32. package/dist/c-DBQ2V7CH.min.js +1 -0
  33. package/dist/c-DPMVAUAW.min.js +1 -0
  34. package/dist/c-ECJCKLYY.min.js +1 -0
  35. package/dist/c-EGATGOWJ.min.js +1 -0
  36. package/dist/c-EGR6VYBW.min.js +1 -0
  37. package/dist/c-ENF72HU5.min.js +1 -0
  38. package/dist/c-ESNR43AN.min.js +1 -0
  39. package/dist/c-F3LIKINL.min.js +1 -0
  40. package/dist/c-F5ZB5GJ6.min.js +1 -0
  41. package/dist/c-G3VYMHKE.min.js +1 -0
  42. package/dist/c-GR6MOEQC.min.js +1 -0
  43. package/dist/c-GSVCN34B.min.js +1 -0
  44. package/dist/c-GYOQCEFP.min.js +1 -0
  45. package/dist/c-H3DNMTCC.min.js +1 -0
  46. package/dist/c-I6J3FEZE.min.js +1 -0
  47. package/dist/c-IGH6MGJ5.min.js +1 -0
  48. package/dist/c-II2EEAJN.min.js +1 -0
  49. package/dist/c-J6M4JHRS.min.js +1 -0
  50. package/dist/c-JM3MGLQV.min.js +1 -0
  51. package/dist/c-KM3N7F7R.min.js +1 -0
  52. package/dist/c-LF5BZFNC.min.js +1 -0
  53. package/dist/c-LKBSGFQC.min.js +1 -0
  54. package/dist/c-NDJADPIF.min.js +1 -0
  55. package/dist/c-NVPQCIL5.min.js +1 -0
  56. package/dist/c-OFWJBEE5.min.js +1 -0
  57. package/dist/c-OYFHP5F5.min.js +1 -0
  58. package/dist/c-PGKQGGQ2.min.js +1 -0
  59. package/dist/c-Q2IPZ3MU.min.js +1 -0
  60. package/dist/c-QKHMBE2E.min.js +1 -0
  61. package/dist/c-QMVM3AY6.min.js +1 -0
  62. package/dist/c-QSGWX53A.min.js +1 -0
  63. package/dist/c-RJKEKZOO.min.js +1 -0
  64. package/dist/c-SFDIIU5G.min.js +1 -0
  65. package/dist/c-SRTBCRVE.min.js +1 -0
  66. package/dist/c-T6UAIKBH.min.js +1 -0
  67. package/dist/c-TMCTEVVW.min.js +1 -0
  68. package/dist/c-TMOSJLT3.min.js +1 -0
  69. package/dist/c-U6ESPM7V.min.js +1 -0
  70. package/dist/c-UC5PTTFI.min.js +1 -0
  71. package/dist/c-VGKUEZBC.min.js +1 -0
  72. package/dist/c-VN2HG5BS.min.js +1 -0
  73. package/dist/{c-J5G56TUH.min.js → c-VPZDY5Q4.min.js} +1 -1
  74. package/dist/c-VRXUB2F2.min.js +1 -0
  75. package/dist/c-VUBQNQJH.min.js +1 -0
  76. package/dist/c-VUH4PGZY.min.js +1 -0
  77. package/dist/c-XDRV7RKW.min.js +1 -0
  78. package/dist/c-YGZHURXZ.min.js +1 -0
  79. package/dist/components/Annotation.d.ts +1 -1
  80. package/dist/components/access/chartAccessCapabilities.generated.d.ts +14 -0
  81. package/dist/components/access/chartAccessContract.d.ts +90 -0
  82. package/dist/components/access/chartAccessContractFixtures.d.ts +11 -0
  83. package/dist/components/ai/aestheticProfileTypes.d.ts +35 -0
  84. package/dist/components/ai/annotationProvenance.d.ts +2 -7
  85. package/dist/components/ai/auditVisualHierarchy.d.ts +49 -0
  86. package/dist/components/ai/builtInChartRecipeLayouts.d.ts +2 -0
  87. package/dist/components/ai/builtInChartRecipePublic.d.ts +4 -0
  88. package/dist/components/ai/builtInChartRecipes.d.ts +26 -0
  89. package/dist/components/ai/chartCapabilities.d.ts +3 -1
  90. package/dist/components/ai/chartRecipeRegistry.d.ts +2 -1
  91. package/dist/components/ai/chartRecipes.d.ts +6 -0
  92. package/dist/components/ai/colorEvidence.d.ts +12 -0
  93. package/dist/components/ai/evaluateAesthetics.d.ts +47 -0
  94. package/dist/components/ai/geoNavigation.d.ts +4 -0
  95. package/dist/components/ai/hierarchyNavigation.d.ts +4 -0
  96. package/dist/components/ai/navigationTree.d.ts +7 -1
  97. package/dist/components/ai/qualityFixtures.d.ts +8 -0
  98. package/dist/components/ai/suggestionPropContracts.d.ts +1 -1
  99. package/dist/components/ai/useNavigationSync.d.ts +3 -3
  100. package/dist/components/charts/index.d.ts +4 -0
  101. package/dist/components/charts/network/ChordDiagram.d.ts +5 -1
  102. package/dist/components/charts/network/CirclePack.d.ts +8 -1
  103. package/dist/components/charts/network/OrbitDiagram.d.ts +9 -0
  104. package/dist/components/charts/network/TreeDiagram.d.ts +8 -1
  105. package/dist/components/charts/network/Treemap.d.ts +8 -1
  106. package/dist/components/charts/ordinal/BarChart.d.ts +6 -0
  107. package/dist/components/charts/ordinal/BoxPlot.d.ts +3 -0
  108. package/dist/components/charts/ordinal/DonutChart.d.ts +3 -0
  109. package/dist/components/charts/ordinal/DotPlot.d.ts +3 -0
  110. package/dist/components/charts/ordinal/FunnelChart.d.ts +3 -0
  111. package/dist/components/charts/ordinal/GaugeChart.d.ts +3 -0
  112. package/dist/components/charts/ordinal/Histogram.d.ts +3 -0
  113. package/dist/components/charts/ordinal/LikertChart.d.ts +3 -0
  114. package/dist/components/charts/ordinal/PieChart.d.ts +3 -0
  115. package/dist/components/charts/ordinal/RadarChart.capability.d.ts +2 -0
  116. package/dist/components/charts/ordinal/RadarChart.d.ts +75 -0
  117. package/dist/components/charts/ordinal/RidgelinePlot.d.ts +3 -0
  118. package/dist/components/charts/ordinal/SwarmPlot.d.ts +3 -0
  119. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +3 -0
  120. package/dist/components/charts/ordinal/ViolinPlot.d.ts +3 -0
  121. package/dist/components/charts/physics/GauntletChart.d.ts +1 -5
  122. package/dist/components/charts/physics/chainReactionTypes.d.ts +3 -0
  123. package/dist/components/charts/physics/gauntletPhysics.d.ts +1 -0
  124. package/dist/components/charts/physics/physicsHocUtils.d.ts +7 -1
  125. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +10 -1
  126. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +11 -1
  127. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +14 -5
  128. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +7 -1
  129. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +7 -1
  130. package/dist/components/charts/realtime/aggregate.d.ts +12 -1
  131. package/dist/components/charts/realtime/realtimeChartRuntime.d.ts +4 -2
  132. package/dist/components/charts/realtime/realtimeStyleRules.d.ts +4 -0
  133. package/dist/components/charts/shared/annotationStatusFilter.d.ts +18 -0
  134. package/dist/components/charts/shared/chartDefinitionPilot.d.ts +5 -4
  135. package/dist/components/charts/shared/chartSpecCore.d.ts +2 -2
  136. package/dist/components/charts/shared/heatmapStyleRules.d.ts +13 -0
  137. package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
  138. package/dist/components/charts/shared/networkUtils.d.ts +14 -0
  139. package/dist/components/charts/shared/selectionUtils.d.ts +3 -1
  140. package/dist/components/charts/shared/types.d.ts +4 -2
  141. package/dist/components/charts/shared/useChartLegend.d.ts +2 -1
  142. package/dist/components/charts/shared/useLikertAggregation.d.ts +8 -2
  143. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +9 -5
  144. package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +1 -1
  145. package/dist/components/charts/shared/useXYBrush.d.ts +24 -0
  146. package/dist/components/charts/xy/Heatmap.d.ts +16 -0
  147. package/dist/components/charts/xy/LineChart.d.ts +9 -0
  148. package/dist/components/charts/xy/Scatterplot.d.ts +7 -0
  149. package/dist/components/charts/xy/WaterfallChart.capability.d.ts +2 -0
  150. package/dist/components/charts/xy/WaterfallChart.d.ts +68 -0
  151. package/dist/components/evidence/chartEvidenceEnvelope.d.ts +146 -0
  152. package/dist/components/evidence/evidenceGate.d.ts +28 -0
  153. package/dist/components/realtime/BinAccumulator.d.ts +5 -1
  154. package/dist/components/realtime/types.d.ts +16 -7
  155. package/dist/components/recipes/adjacencyFlow.d.ts +12 -0
  156. package/dist/components/recipes/adjacencyFlowAggregation.d.ts +72 -0
  157. package/dist/components/recipes/adjacencyFlowGeometry.d.ts +79 -0
  158. package/dist/components/recipes/lineageDag.d.ts +17 -0
  159. package/dist/components/recipes/lineageDagHulls.d.ts +22 -0
  160. package/dist/components/recipes/transitDiagram.d.ts +75 -0
  161. package/dist/components/recipes/transitDiagramGeometry.d.ts +47 -0
  162. package/dist/components/semiotic-access.d.ts +9 -0
  163. package/dist/components/semiotic-ai-audits.d.ts +17 -0
  164. package/dist/components/semiotic-ai-core.d.ts +9 -0
  165. package/dist/components/semiotic-ai.d.ts +5 -17
  166. package/dist/components/semiotic-evidence.d.ts +10 -0
  167. package/dist/components/semiotic-line.d.ts +9 -0
  168. package/dist/components/semiotic-network.d.ts +3 -0
  169. package/dist/components/semiotic-ordinal.d.ts +2 -0
  170. package/dist/components/semiotic-realtime-core.d.ts +3 -2
  171. package/dist/components/semiotic-recipes-core.d.ts +6 -0
  172. package/dist/components/semiotic-themes-core.d.ts +3 -0
  173. package/dist/components/semiotic-utils-core.d.ts +5 -0
  174. package/dist/components/semiotic-utils.d.ts +1 -1
  175. package/dist/components/semiotic-xy.d.ts +3 -0
  176. package/dist/components/semiotic.d.ts +9 -3
  177. package/dist/components/server/renderDashboard.d.ts +37 -0
  178. package/dist/components/server/renderEvidence.d.ts +27 -0
  179. package/dist/components/server/renderToStaticSVG.d.ts +2 -30
  180. package/dist/components/server/serverChartConfigShared.d.ts +13 -0
  181. package/dist/components/server/serverChartConfigs.d.ts +9 -0
  182. package/dist/components/server/serverChartConfigsComposite.d.ts +4 -0
  183. package/dist/components/server/serverChartConfigsCustom.d.ts +2 -0
  184. package/dist/components/server/serverChartConfigsGeo.d.ts +1 -0
  185. package/dist/components/server/serverChartConfigsOrdinal.d.ts +3 -2
  186. package/dist/components/server/serverChartConfigsXY.d.ts +1 -0
  187. package/dist/components/server/serverChartConfigsXYExtra.d.ts +3 -0
  188. package/dist/components/server/serverCompositeChainReaction.d.ts +3 -0
  189. package/dist/components/server/serverOrdinalGauge.d.ts +3 -0
  190. package/dist/components/server/serverOrdinalLikert.d.ts +2 -0
  191. package/dist/components/store/selectionProvenance.d.ts +8 -0
  192. package/dist/components/store/themeCore.d.ts +5 -1
  193. package/dist/components/stream/GeoPipelineStore.d.ts +1 -1
  194. package/dist/components/stream/MarginalGraphics.d.ts +3 -3
  195. package/dist/components/stream/MarginalGraphicsLazy.d.ts +22 -0
  196. package/dist/components/stream/NetworkPipelineStore.d.ts +2 -0
  197. package/dist/components/stream/OrdinalPipelineStore.d.ts +1 -1
  198. package/dist/components/stream/PipelineStore.d.ts +1 -1
  199. package/dist/components/stream/SceneToSVG.d.ts +1 -1
  200. package/dist/components/stream/canvasSetup.d.ts +8 -2
  201. package/dist/components/stream/customLayoutAttempt.d.ts +21 -0
  202. package/dist/components/stream/geoTypes.d.ts +1 -1
  203. package/dist/components/stream/isServerEnvironment.d.ts +6 -0
  204. package/dist/components/stream/layouts/forceLayoutNodeSize.d.ts +12 -0
  205. package/dist/components/stream/layouts/forceLayoutPlugin.d.ts +2 -9
  206. package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +2 -21
  207. package/dist/components/stream/layouts/forceLayoutWorkerPolicy.d.ts +21 -0
  208. package/dist/components/stream/layouts/index.d.ts +6 -12
  209. package/dist/components/stream/layouts/missingPlugin.d.ts +7 -0
  210. package/dist/components/stream/layouts/registerBuiltIn.d.ts +1 -0
  211. package/dist/components/stream/layouts/registry.d.ts +12 -0
  212. package/dist/components/stream/marginalConfig.d.ts +3 -0
  213. package/dist/components/stream/networkCustomLayout.d.ts +7 -0
  214. package/dist/components/stream/networkCustomLayoutOutput.d.ts +13 -0
  215. package/dist/components/stream/networkCustomLayoutRunner.d.ts +1 -1
  216. package/dist/components/stream/networkTypes.d.ts +5 -1
  217. package/dist/components/stream/ordinalTypes.d.ts +1 -1
  218. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +1 -1
  219. package/dist/components/stream/pipelineDomainResolution.d.ts +6 -0
  220. package/dist/components/stream/renderers/pointCanvasRenderer.d.ts +4 -0
  221. package/dist/components/stream/renderers/resolveCSSColor.d.ts +4 -4
  222. package/dist/components/stream/types.d.ts +8 -1
  223. package/dist/components/stream/useEnsureCustomXYRenderers.d.ts +18 -0
  224. package/dist/components/stream/useMarginalValues.d.ts +13 -0
  225. package/dist/components/stream/xyCanvasRenderers.d.ts +4 -4
  226. package/dist/components/stream/xyPlugins/areaPlugin.d.ts +2 -0
  227. package/dist/components/stream/xyPlugins/barPlugin.d.ts +2 -0
  228. package/dist/components/stream/xyPlugins/candlestickPlugin.d.ts +2 -0
  229. package/dist/components/stream/xyPlugins/customPlugin.d.ts +6 -0
  230. package/dist/components/stream/xyPlugins/heatmapPlugin.d.ts +2 -0
  231. package/dist/components/stream/xyPlugins/lineFamily.d.ts +5 -0
  232. package/dist/components/stream/xyPlugins/linePlugin.d.ts +2 -0
  233. package/dist/components/stream/xyPlugins/missingPlugin.d.ts +7 -0
  234. package/dist/components/stream/xyPlugins/mixedPlugin.d.ts +2 -0
  235. package/dist/components/stream/xyPlugins/pointPlugin.d.ts +3 -0
  236. package/dist/components/stream/xyPlugins/registerBuiltIn.d.ts +1 -0
  237. package/dist/components/stream/xyPlugins/registry.d.ts +31 -0
  238. package/dist/components/stream/xyPlugins/stackedAreaPlugin.d.ts +2 -0
  239. package/dist/components/stream/xyPlugins/swarmPlugin.d.ts +2 -0
  240. package/dist/components/stream/xyPlugins/waterfallPlugin.d.ts +2 -0
  241. package/dist/forceLayoutWorker.js +1 -1
  242. package/dist/geo.min.js +1 -1
  243. package/dist/geo.module.min.js +1 -1
  244. package/dist/network.module.min.js +1 -1
  245. package/dist/ordinal.module.min.js +1 -1
  246. package/dist/physics.module.min.js +1 -1
  247. package/dist/rough.module.min.js +1 -1
  248. package/dist/semiotic-access.d.ts +9 -0
  249. package/dist/semiotic-access.min.js +2 -0
  250. package/dist/semiotic-access.module.min.js +2 -0
  251. package/dist/semiotic-ai-core.d.ts +9 -0
  252. package/dist/semiotic-ai-core.min.js +1 -1
  253. package/dist/semiotic-ai-core.module.min.js +1 -1
  254. package/dist/semiotic-ai.d.ts +5 -17
  255. package/dist/semiotic-ai.module.min.js +1 -1
  256. package/dist/semiotic-client-cjs-shared.min.js +1 -1
  257. package/dist/semiotic-client-shared.module.min.js +1 -1
  258. package/dist/semiotic-evidence.d.ts +10 -0
  259. package/dist/semiotic-evidence.min.js +1 -0
  260. package/dist/semiotic-evidence.module.min.js +1 -0
  261. package/dist/semiotic-experimental-auxiliary.module.min.js +1 -1
  262. package/dist/semiotic-experimental-node-auxiliary.module.min.js +1 -1
  263. package/dist/semiotic-experimental-react-shared.module.min.js +1 -1
  264. package/dist/semiotic-experimental-vacp.min.js +1 -1
  265. package/dist/semiotic-experimental-vacp.module.min.js +1 -1
  266. package/dist/semiotic-line.d.ts +9 -0
  267. package/dist/semiotic-line.min.js +2 -0
  268. package/dist/semiotic-line.module.min.js +2 -0
  269. package/dist/semiotic-network.d.ts +3 -0
  270. package/dist/semiotic-ordinal.d.ts +2 -0
  271. package/dist/semiotic-realtime-core.d.ts +3 -2
  272. package/dist/semiotic-realtime-core.module.min.js +1 -1
  273. package/dist/semiotic-recipes-core-cjs-base.min.js +1 -1
  274. package/dist/semiotic-recipes-core.d.ts +6 -0
  275. package/dist/semiotic-recipes-core.module.min.js +1 -1
  276. package/dist/semiotic-server-edge-node.module.min.js +1 -1
  277. package/dist/semiotic-server-edge.min.js +1 -1
  278. package/dist/semiotic-server-edge.module.min.js +1 -1
  279. package/dist/semiotic-server-node.min.js +1 -1
  280. package/dist/semiotic-server-node.module.min.js +1 -1
  281. package/dist/semiotic-themes-core.d.ts +3 -0
  282. package/dist/semiotic-themes-core.min.js +1 -1
  283. package/dist/semiotic-themes-core.module.min.js +1 -1
  284. package/dist/semiotic-themes.min.js +1 -1
  285. package/dist/semiotic-themes.module.min.js +1 -1
  286. package/dist/semiotic-utils-core.d.ts +5 -0
  287. package/dist/semiotic-utils-core.min.js +1 -1
  288. package/dist/semiotic-utils-core.module.min.js +1 -1
  289. package/dist/semiotic-utils.d.ts +1 -1
  290. package/dist/semiotic-utils.module.min.js +1 -1
  291. package/dist/semiotic-xy.d.ts +3 -0
  292. package/dist/semiotic.d.ts +9 -3
  293. package/dist/semiotic.module.min.js +1 -1
  294. package/dist/server.min.js +1 -1
  295. package/dist/server.module.min.js +1 -1
  296. package/dist/xy.module.min.js +1 -1
  297. package/package.json +39 -60
  298. package/dist/c-3KZD6AXJ.min.js +0 -1
  299. package/dist/c-4TWEX5HG.min.js +0 -1
  300. package/dist/c-5YCIX3VZ.min.js +0 -1
  301. package/dist/c-6FEKTA3U.min.js +0 -1
  302. package/dist/c-74HEEZGK.min.js +0 -1
  303. package/dist/c-BWNB6USU.min.js +0 -1
  304. package/dist/c-C25ENHIK.min.js +0 -1
  305. package/dist/c-CDR5AO3R.min.js +0 -1
  306. package/dist/c-E3JFRRMI.min.js +0 -1
  307. package/dist/c-EBFPQHHO.min.js +0 -1
  308. package/dist/c-GIKRQI4X.min.js +0 -1
  309. package/dist/c-GPYOFETM.min.js +0 -1
  310. package/dist/c-IDUHYYSI.min.js +0 -1
  311. package/dist/c-JAZ73J32.min.js +0 -1
  312. package/dist/c-KG3NXHAL.min.js +0 -1
  313. package/dist/c-KII3PLZE.min.js +0 -1
  314. package/dist/c-LIXGXMNS.min.js +0 -1
  315. package/dist/c-LVEY6D6B.min.js +0 -1
  316. package/dist/c-M4Y3BHFR.min.js +0 -1
  317. package/dist/c-MAIICR2Z.min.js +0 -1
  318. package/dist/c-MG5DM6VE.min.js +0 -1
  319. package/dist/c-O6U6K4CW.min.js +0 -1
  320. package/dist/c-OQ7M4AGV.min.js +0 -1
  321. package/dist/c-OXYMVK7Q.min.js +0 -1
  322. package/dist/c-QHF5YON3.min.js +0 -1
  323. package/dist/c-RR3GO5SW.min.js +0 -1
  324. package/dist/c-S2BXNNJN.min.js +0 -1
  325. package/dist/c-SUILCHWU.min.js +0 -1
  326. package/dist/c-US5ZFT6E.min.js +0 -1
  327. package/dist/c-UUKVD4WB.min.js +0 -1
  328. package/dist/c-WJCD5EUY.min.js +0 -1
  329. package/dist/c-YDAY2WFR.min.js +0 -1
  330. package/dist/c-ZOWWU34K.min.js +0 -1
  331. /package/dist/{c-COHXCW3Q.min.js → c-YZVRZGX2.min.js} +0 -0
@@ -1 +0,0 @@
1
- import{validateNetworkData as e,validateObjectData as t}from"./c-RSVIHIQ4.min.js";import{ModuleWorkerSession as o,StreamNetworkFrame_default as n,buildRibbonGeometry as i,createSharedWorkerSessionHolder as s,errorFromPayload as a,parseModuleWorkerErrorField as r}from"./c-OXYMVK7Q.min.js";import{mulberry32 as l}from"./c-N4G2L7ID.min.js";import{commonJsWorkerModuleUrl as c}from"./c-VGW3VG3I.min.js";import{mergeShapeStyle as d,useCustomChartScaffold as u,useFrameImperativeHandle as g,useResolvedSelection as m}from"./c-3KZD6AXJ.min.js";import{buildBaseMetadataProps as f,buildCustomBehaviorProps as h}from"./c-GPYOFETM.min.js";import{composeStyleRules as p,makeNodeRuleContext as b,resolveStyleRules as y}from"./c-S2BXNNJN.min.js";import{COLOR_SCHEMES as v,ChartError as k,DEFAULT_COLORS as w,DEFAULT_SELECTION_OPACITY as x,DEPTH_PALETTE_COLORS as M,SafeRender as S,clampLegendReservation as T,distinctCategories as A,filterSparseArray as I,getColor as P,isHatchFill as C,normalizeTooltip as O,renderEmptyState as N,renderLoadingState as L,reserveLegendMargin as B,resolveAxisFreeMarginDefaults as H,resolveCategoricalPalette as D,resolveDefaultFill as E,resolveMobileInteraction as F,useChartLegendAndMargin as R,useChartMode as z,useChartSelection as W,useColorScale as _,useLegendInteraction as $,useThemeCategorical as j,useWasHydratingFromSSR as X}from"./c-GIKRQI4X.min.js";import{getMin as Y}from"./c-WJCD5EUY.min.js";import{useMemo as G,forwardRef as q,useRef as V}from"react";import{useMemo as U}from"react";function Q(e,t){if(!e)return[];const o=[],n=e=>{o.push(e);const i="function"==typeof t?t(e):e[t];i&&Array.isArray(i)&&i.forEach(n)};return n(e),o}function K(e,t,o,n){if(e&&e.length>0)return e;const i=new Set;return t.forEach(e=>{const t="function"==typeof o?o(e):e[o],s="function"==typeof n?n(e):e[n];i.add(t),i.add(s)}),Array.from(i).map(e=>({id:e}))}function J(e){return"function"==typeof e?e:t=>t[e]||1}function Z({edgeColorBy:e,colorBy:t,colorScale:o,nodeStyleFn:n,edgeOpacity:i,baseStyle:s={}}){return a=>{const r={fillOpacity:i,...s};if("function"==typeof e)r.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?r.fill=P(e.data||e,t,o):e&&(r.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?r.fill=P(e.data||e,t,o):e&&(r.fill=n(e,e.index).fill)}else"gradient"===e&&(r.fill="#999",r.fillOpacity=.7*i);return r}}function ee(e){const{nodes:t,edges:o,inferNodes:n=!0,sourceAccessor:i="source",targetAccessor:s="target",colorBy:a,colorScheme:r,showLegend:l,legendPosition:c,legendInteraction:d,frameLegend:u,selection:g,linkedHover:m,onObservation:f,onClick:h,mobileInteraction:p,mobileSemantics:b,chartType:y,chartId:v,marginDefaults:k,userMargin:x,width:M,height:S,hasTitle:T,loading:P,loadingContent:C,emptyContent:O,emptyDataKey:B="edges"}=e,H=U(()=>I(o),[o]),E=U(()=>I(t),[t]),z=L(P,M,S,C),X=z?null:N("nodes"===B?void 0===t?void 0:E:void 0===o?void 0:H,M,S,O),Y=U(()=>n?K(E,H,i,s):E,[n,E,H,i,s]),G=_(Y,a,r),q=j(),V=U(()=>Array.isArray(r)&&r.length>0?r:[...D(r,q,w)],[r,q]),Q=U(()=>A(Y,a),[Y,a]),J=$(d,a,Q),{legend:Z,margin:ee,legendPosition:te,legendMarginReserved:oe}=R({data:Y,colorBy:a,colorScale:G,showLegend:l,legendPosition:c,userMargin:x,defaults:k,categories:Q,chartWidth:M,chartHeight:S,frameLegend:u,hasTitle:T}),ne=U(()=>Z&&oe?{__legendMarginReservedFor:Z}:{},[Z,oe]),ie=U(()=>F(p,{width:M,mobileSemantics:b}),[p,M,b]),se=W({selection:g,linkedHover:m,fallbackFields:a?["string"==typeof a?a:""]:[],unwrapData:!0,onObservation:f,onClick:h,mobileInteraction:ie,chartType:y,chartId:v}),{customHoverBehavior:ae,customClickBehavior:re,activeSelectionHook:le,hoverSelectionHook:ce,crosshairSourceId:de}=se;return{safeNodes:Y,safeEdges:H,colorScale:G,effectivePalette:V,themeCategorical:q,allCategories:Q,legendState:J,legend:Z,margin:ee,legendPosition:te,legendBehaviorProps:ne,mobileInteraction:ie,customHoverBehavior:ae,customClickBehavior:re,activeSelectionHook:le,hoverSelectionHook:ce,crosshairSourceId:de,loadingEl:z,emptyEl:X}}import{jsx as te}from"react/jsx-runtime";var oe=q(function(t,o){const i=V(null);g(o,{variant:"network",frameRef:i});const s=z(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},{width:600,height:600}),{nodes:a,edges:r,margin:l,className:c,nodeIdAccessor:u,nodeIDAccessor:m,sourceAccessor:f="source",targetAccessor:y="target",nodeLabel:v,colorBy:w,colorScheme:x,styleRules:M,nodeSize:T=8,nodeSizeRange:A=[5,20],nodeStroke:I,nodeStrokeWidth:C,edgeWidth:N,edgeColor:L,edgeOpacity:B,iterations:H=300,forceStrength:D=.1,layoutExecution:F="auto",layoutLoadingContent:R,onLayoutStateChange:W,tooltip:_,frameProps:$={},onObservation:j,onClick:X,chartId:Y,selection:q,linkedHover:U,loading:Q,loadingContent:K,emptyContent:J,legendInteraction:Z,legendPosition:oe,stroke:ne,strokeWidth:ie,opacity:se}=t,ae=u??m??"id",{width:re,height:le,enableHover:ce,showLegend:de,showLabels:ue=!1,title:ge,description:me,summary:fe,accessibleTable:he}=s,pe=ee({nodes:a,edges:r,inferNodes:!1,nodeIdAccessor:ae,sourceAccessor:f,targetAccessor:y,colorBy:w,colorScheme:x,showLegend:de,legendPosition:oe,legendInteraction:Z,frameLegend:$,selection:q,linkedHover:U,onObservation:j,onClick:X,mobileInteraction:s.mobileInteraction,mobileSemantics:s.mobileSemantics,chartType:"ForceDirectedGraph",chartId:Y,marginDefaults:s.marginDefaults,userMargin:l,width:re,height:le,hasTitle:!!ge,loading:Q,loadingContent:K,emptyContent:J,emptyDataKey:"nodes"}),be=G(()=>new Map,[]),ye=G(()=>e=>{const t={};return t.fill=w?P(e.data||e,w,pe.colorScale):E(void 0,pe.themeCategorical,x,void 0,be),"number"==typeof T&&(t.r=T),t},[w,pe.colorScale,T,pe.themeCategorical,x,be]),ve=G(()=>b(w,"number"==typeof T?void 0:T),[w,T]),ke=G(()=>d(p(ye,M,ve,e=>e.data||e),{stroke:I??ne,strokeWidth:C??ie,opacity:se}),[ye,M,ve,I,ne,C,ie,se]),we=L??ne??"#999",xe=B??se??.6,Me=ie??1,Se=G(()=>e=>{const t=e.data||e;let o;if(void 0===N)o=Me;else if("number"==typeof N)o=N;else if("function"==typeof N)o=N(t);else{const e=t[N],n="number"==typeof e?e:Number(e);o=Number.isFinite(n)&&n>0?n:Me}return{stroke:we,strokeWidth:o,opacity:xe}},[N,we,xe,Me]),Te=G(()=>{if(ue&&v)return"function"==typeof v?v:e=>e.data?.[v]??e[v]??e.id},[ue,v]),Ae=e({componentName:"ForceDirectedGraph",nodes:a,edges:r,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:ae}});return Ae?te(k,{componentName:"ForceDirectedGraph",message:Ae,width:re,height:le}):pe.loadingEl?pe.loadingEl:pe.emptyEl?pe.emptyEl:te(S,{componentName:"ForceDirectedGraph",width:re,height:le,children:te(n,{ref:i,chartType:"force",...null!=a&&{nodes:pe.safeNodes},...null!=r&&{edges:pe.safeEdges},size:[re,le],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,maxDevicePixelRatio:t.maxDevicePixelRatio,margin:pe.margin,...pe.legendBehaviorProps,nodeIDAccessor:ae,sourceAccessor:f,targetAccessor:y,iterations:H,forceStrength:D,layoutExecution:F,layoutLoadingContent:R,onLayoutStateChange:W,nodeStyle:ke,edgeStyle:Se,colorBy:w,colorScheme:pe.effectivePalette,nodeSize:T,nodeSizeRange:A,nodeLabel:Te,showLabels:ue,enableHover:ce,tooltipContent:!1===_?()=>null:O(_)||void 0,...h({linkedHover:U,selection:q,onObservation:j,onClick:X,mobileInteraction:pe.mobileInteraction,customHoverBehavior:pe.customHoverBehavior,customClickBehavior:pe.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:pe.legend,legendPosition:pe.legendPosition,...Z&&"none"!==Z&&{legendHoverBehavior:pe.legendState.onLegendHover,legendClickBehavior:pe.legendState.onLegendClick,legendHighlightedCategory:pe.legendState.highlightedCategory,legendIsolatedCategories:pe.legendState.isolatedCategories},className:c,title:ge,description:me,summary:fe,accessibleTable:he,...null!=t.animate&&{animate:t.animate},...$})})});oe.displayName="ForceDirectedGraph";import{useMemo as ne,forwardRef as ie,useRef as se}from"react";import{jsx as ae}from"react/jsx-runtime";var re=ie(function(t,o){const i=se(null);g(o,{variant:"network",frameRef:i,overrides:{getData:()=>i.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const s=z(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},{width:600,height:600}),{nodes:a,edges:r,margin:l,className:c,sourceAccessor:u="source",targetAccessor:m="target",valueAccessor:f="value",nodeIdAccessor:y="id",colorBy:x,colorScheme:M,styleRules:T,edgeColorBy:A="source",padAngle:I=.01,groupWidth:C=20,sortGroups:N,nodeLabel:L,edgeOpacity:B=.5,tooltip:H,frameProps:D={},onObservation:F,onClick:R,chartId:W,selection:_,linkedHover:$,loading:j,loadingContent:X,emptyContent:Y,legendInteraction:G,stroke:q,strokeWidth:V,opacity:U}=t,{width:Q,height:K,enableHover:J,showLabels:te=!0,title:oe,description:ie,summary:re,accessibleTable:le}=s,ce=ee({nodes:a,edges:r,inferNodes:!0,nodeIdAccessor:y,sourceAccessor:u,targetAccessor:m,colorBy:x,colorScheme:M,showLegend:!1,legendInteraction:G,frameLegend:D,selection:_,linkedHover:$,onObservation:F,onClick:R,mobileInteraction:s.mobileInteraction,mobileSemantics:s.mobileSemantics,chartType:"ChordDiagram",chartId:W,marginDefaults:s.marginDefaults,userMargin:l,width:Q,height:K,hasTitle:!!oe,loading:j,loadingContent:X,emptyContent:Y}),de=ne(()=>new Map,[]),ue=ne(()=>new Map,[]),ge=ce.safeNodes.length>0,me=ne(()=>{if(ge)return(e,t)=>{const o={stroke:"black",strokeWidth:1};if(x)o.fill=P(e.data||e,x,ce.colorScale);else{const n=Array.isArray(M)?M:v[M]||w,i=Array.isArray(n)?n:w,s=(e.id??e.data?.[y]??"")+"";ue.has(s)||ue.set(s,ue.size);const a=e.index??t??ue.get(s);o.fill=i[a%i.length]}return o}},[ge,x,ce.colorScale,M,y,ue]),fe=ne(()=>b(x),[x]),he=ne(()=>{if(me||T&&T.length>0)return d(p(me,T,fe,e=>e.data||e),{stroke:q,strokeWidth:V,opacity:U})},[me,T,fe,q,V,U]),pe=ne(()=>{if(ge)return Z({edgeColorBy:A,colorBy:x,colorScale:ce.colorScale,nodeStyleFn:he||(e=>({fill:E(void 0,ce.themeCategorical,M,void 0,de)})),edgeOpacity:B,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:B}})},[ge,A,x,ce.colorScale,he,B,ce.themeCategorical,M,de]),be=ne(()=>pe?d(pe,{stroke:q,strokeWidth:V,opacity:U}):void 0,[pe,q,V,U]),ye=ne(()=>{if(!te)return;const e=L||y;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[te,L,y]),ve=e({componentName:"ChordDiagram",edges:r,edgesRequired:!0});return ve?ae(k,{componentName:"ChordDiagram",message:ve,width:Q,height:K}):ce.loadingEl?ce.loadingEl:ce.emptyEl?ce.emptyEl:ae(S,{componentName:"ChordDiagram",width:Q,height:K,children:ae(n,{ref:i,chartType:"chord",...ce.safeNodes.length>0&&{nodes:ce.safeNodes},...null!=r&&{edges:ce.safeEdges},size:[Q,K],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,maxDevicePixelRatio:t.maxDevicePixelRatio,margin:ce.margin,...ce.legendBehaviorProps,nodeIDAccessor:y,sourceAccessor:u,targetAccessor:m,valueAccessor:f,padAngle:I,groupWidth:C,sortGroups:N,nodeStyle:he,edgeStyle:be,colorBy:x,colorScheme:ce.effectivePalette,edgeColorBy:A,edgeOpacity:B,nodeLabel:ye,showLabels:te,enableHover:J,tooltipContent:!1===H?()=>null:O(H)||void 0,...h({linkedHover:$,selection:_,onObservation:F,onClick:R,mobileInteraction:ce.mobileInteraction,customHoverBehavior:ce.customHoverBehavior,customClickBehavior:ce.customClickBehavior,linkedHoverInClickPredicate:!1}),...G&&"none"!==G&&{legendHoverBehavior:ce.legendState.onLegendHover,legendClickBehavior:ce.legendState.onLegendClick,legendHighlightedCategory:ce.legendState.highlightedCategory,legendIsolatedCategories:ce.legendState.isolatedCategories},className:c,title:oe,description:ie,summary:re,accessibleTable:le,...null!=t.animate&&{animate:t.animate},...D})})});re.displayName="ChordDiagram";import{useMemo as le,forwardRef as ce,useRef as de}from"react";import{jsx as ue}from"react/jsx-runtime";var ge=ce(function(t,o){const i=de(null);g(o,{variant:"network",frameRef:i,overrides:{getData:()=>i.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const s=z(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},{width:800,height:600}),{nodes:a,edges:r,margin:l,className:c,sourceAccessor:u="source",targetAccessor:m="target",valueAccessor:f="value",nodeIdAccessor:y="id",colorBy:v,colorScheme:w,styleRules:x,edgeColorBy:M="source",orientation:T="horizontal",nodeAlign:A="justify",nodePaddingRatio:I=.05,nodeWidth:C=15,nodeLabel:N,edgeOpacity:L=.5,edgeSort:B,tooltip:H,frameProps:D={},onObservation:F,onClick:R,chartId:W,selection:_,linkedHover:$,loading:j,loadingContent:X,emptyContent:Y,showLegend:G,legendPosition:q,legendInteraction:V,stroke:U,strokeWidth:Q,opacity:K}=t,{width:J,height:te,enableHover:oe,showLabels:ne=!0,title:ie,description:se,summary:ae,accessibleTable:re}=s,ce=ee({nodes:a,edges:r,inferNodes:!0,nodeIdAccessor:y,sourceAccessor:u,targetAccessor:m,colorBy:v,colorScheme:w,showLegend:G,legendPosition:q,legendInteraction:V,frameLegend:D,selection:_,linkedHover:$,onObservation:F,onClick:R,mobileInteraction:s.mobileInteraction,mobileSemantics:s.mobileSemantics,chartType:"SankeyDiagram",chartId:W,marginDefaults:s.marginDefaults,userMargin:l,width:J,height:te,hasTitle:!!ie,loading:j,loadingContent:X,emptyContent:Y}),ge=le(()=>new Map,[]),me=le(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=v?P(e.data||e,v,ce.colorScale):E(void 0,ce.themeCategorical,w,void 0,ge),t},[v,ce.colorScale,ce.themeCategorical,w,ge]),fe=le(()=>b(v,f),[v,f]),he=le(()=>d(p(me,x,fe,e=>e.data||e),{stroke:U,strokeWidth:Q,opacity:K}),[me,x,fe,U,Q,K]),pe=le(()=>Z({edgeColorBy:M,colorBy:v,colorScale:ce.colorScale,nodeStyleFn:he,edgeOpacity:L,baseStyle:{stroke:"none",strokeWidth:0}}),[M,v,ce.colorScale,he,L]),be=le(()=>d(pe,{stroke:U,strokeWidth:Q,opacity:K}),[pe,U,Q,K]),ye=le(()=>{if(!ne)return;const e=N||y;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[ne,N,y]),ve=e({componentName:"SankeyDiagram",edges:r,edgesRequired:!0});return ve?ue(k,{componentName:"SankeyDiagram",message:ve,width:J,height:te}):ce.loadingEl?ce.loadingEl:ce.emptyEl?ce.emptyEl:ue(S,{componentName:"SankeyDiagram",width:J,height:te,children:ue(n,{ref:i,chartType:"sankey",...ce.safeNodes.length>0&&{nodes:ce.safeNodes},...null!=r&&{edges:ce.safeEdges},size:[J,te],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,maxDevicePixelRatio:t.maxDevicePixelRatio,margin:ce.margin,...ce.legendBehaviorProps,nodeIDAccessor:y,sourceAccessor:u,targetAccessor:m,valueAccessor:f,orientation:T,nodeAlign:A,nodePaddingRatio:I,nodeWidth:C,nodeStyle:he,edgeStyle:be,colorBy:v,colorScheme:ce.effectivePalette,edgeColorBy:M,edgeOpacity:L,edgeSort:B,nodeLabel:ye,showLabels:ne,enableHover:oe,tooltipContent:!1===H?()=>null:O(H)||void 0,...h({linkedHover:$,selection:_,onObservation:F,onClick:R,mobileInteraction:ce.mobileInteraction,customHoverBehavior:ce.customHoverBehavior,customClickBehavior:ce.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:ce.legend,legendPosition:ce.legendPosition,...V&&"none"!==V&&{legendHoverBehavior:ce.legendState.onLegendHover,legendClickBehavior:ce.legendState.onLegendClick,legendHighlightedCategory:ce.legendState.highlightedCategory,legendIsolatedCategories:ce.legendState.isolatedCategories},className:c,title:ie,description:se,summary:ae,accessibleTable:re,...null!=t.animate&&{animate:t.animate},...D})})});ge.displayName="SankeyDiagram";var me={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}};function fe(e="static"){return me[e]??me.static}var he=new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]);function pe(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:he.has(e.kind)?"fatal":"warn"}function be(e,t,o,n={}){const i=fe(n.usageMode??"static"),s=[],a=new Set;for(const t of e)a.has(t.id)&&s.push({kind:"duplicate-node",id:t.id,severity:i.duplicateIds}),a.add(t.id);const r=new Set,l=Array.isArray(o)&&2===o.length,c=l&&Number.isFinite(o[0])&&Number.isFinite(o[1]);l&&c&&c&&o[1]>=o[0]||s.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||s.push({kind:"invalid-node-time",id:t.id}));for(const e of t)r.has(e.id)&&s.push({kind:"duplicate-edge",id:e.id,severity:i.duplicateIds}),r.add(e.id),a.has(e.source)||s.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),a.has(e.target)||s.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?((null!=e.systemInTime&&!Number.isFinite(e.systemInTime)||null!=e.systemOutTime&&!Number.isFinite(e.systemOutTime))&&s.push({kind:"invalid-system-time",id:e.id,severity:"warn"}),Number.isFinite(e.value)&&e.value>0||s.push({kind:"invalid-value",id:e.id}),e.startTime>e.endTime&&s.push({kind:"backward-edge",severity:"fatal",id:e.id,source:e.source,target:e.target})):s.push({kind:"invalid-edge-time",id:e.id});return s}function ye(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:"duplicate-node"===e.kind?`node id "${e.id}" is duplicated`:"duplicate-edge"===e.kind?`edge id "${e.id}" is duplicated`:"invalid-system-time"===e.kind?`edge ${e.id} has an invalid systemInTime or systemOutTime`:e.kind}function ve(e){if(!e?.layoutQuality)return[];const t=[],o=e.layoutQuality,n=e.layoutQualityBefore;e.compressedPadding&&t.push({severity:"warning",code:"PROCESS_SANKEY_COMPRESSED_PADDING",message:"Lane gaps were compressed to fit peaks into the plot height.",fix:'Increase height, lower maxValueScale, use packing="reuse", or reduce concurrent peaks.'}),8>o.transitOcclusion||t.push({severity:"warning",code:"PROCESS_SANKEY_HIGH_TRANSIT",message:`High transit occlusion (${o.transitOcclusion.toFixed(1)}) — ribbons cross dense intermediate lanes.`,fix:'Try laneOrder="crossing-min+inside-out", packing="reuse", or lanePlacement="hug" with a modest maxValueScale.'}),.92>o.verticalUtilization||t.push({severity:"warning",code:"PROCESS_SANKEY_HIGH_UTILIZATION",message:`Lane utilization is ${Math.round(100*o.verticalUtilization)}% of plot height.`,fix:"Increase chart height or cap band scale with maxValueScale."});const i=e.crossingsAfter??o.crossings;return null==i||3>i||t.push({severity:"warning",code:"PROCESS_SANKEY_RESIDUAL_CROSSINGS",message:`Ordering left ${i} edge-pair crossings`+(n?` (from ${n.crossings})`:"")+".",fix:'Prefer laneOrder="crossing-min" or "crossing-min+inside-out"; check for unavoidable fan-outs.'}),t}function ke(e){if(!e?.layoutQuality)return null;const t=e.layoutQuality,o=e.layoutQualityBefore,n=e.crossingsAfter??t.crossings;return[`ProcessSankey layout uses ${e.slots?.length??"?"} packed lane(s).`,null!=n?`Edge-pair crossings ${o?o.crossings+" → ":""}${n}.`:null,`Pixel path length ${o?Math.round(o.pixelLength)+" → ":""}${Math.round(t.pixelLength)}.`,`Transit occlusion ${o?o.transitOcclusion.toFixed(1)+" → ":""}${t.transitOcclusion.toFixed(1)}.`,`Lane utilization ${Math.round(100*t.verticalUtilization)}%.`,e.compressedPadding?"Lane gaps were compressed to fit the plot.":null].filter(Boolean).join(" ")}function we(e){const t=[],o=e.domain;null==o?t.push({severity:"error",code:"PROCESS_SANKEY_MISSING_DOMAIN",message:"ProcessSankey requires domain: [tStart, tEnd].",fix:"Pass domain={[start, end]} as numbers or Date-compatible values."}):Array.isArray(o)&&2===o.length&&Number.isFinite(Number(o[0]))&&Number.isFinite(Number(o[1]))||t.push({severity:"error",code:"PROCESS_SANKEY_BAD_DOMAIN",message:"domain must be a 2-tuple of finite times.",fix:"Use domain={[t0, t1]} with t0 <= t1."});const n=e.edges;if(Array.isArray(n)&&n.length>0){const e=n[0];null!=e.startTime&&null!=e.endTime||t.push({severity:"warning",code:"PROCESS_SANKEY_EDGE_TIMES",message:"Edges should carry startTime and endTime for temporal layout.",fix:"Add startTime/endTime fields or set startTimeAccessor/endTimeAccessor."})}const i=e.nodes,s=Array.isArray(i)?i.length:0;return!0!==e.showLabels||24>s||t.push({severity:"warning",code:"PROCESS_SANKEY_LABEL_DENSITY",message:`showLabels={true} with ${s} nodes may overcrowd the plot.`,fix:'Use showLabels="auto" with optional labelPriorityAccessor / maxLabels.'}),80>(Array.isArray(n)?n.length:0)||null!=e.layoutExecution||"off"===e.packing||t.push({severity:"warning",code:"PROCESS_SANKEY_WORKER_HINT",message:"Dense ProcessSankey layouts benefit from worker packing/order.",fix:'layoutExecution defaults to "auto"; set layoutExecution="worker" or raise layoutWorkerThreshold deliberately.'}),t}function xe(e,t,o,n={}){const i=!1!==n.inferOpeningStock,s=[];for(const t of o){const o=Number(t.value);if(!Number.isFinite(o))continue;const n=Number(t.endTime);t.target===e&&Number.isFinite(n)&&s.push({time:n,delta:o});const i=Number(t.startTime);if(t.source===e&&Number.isFinite(i)&&s.push({time:i,delta:-o}),t.target===e&&null!=t.systemOutTime){const e=Number(t.systemOutTime);Number.isFinite(e)&&s.push({time:e,delta:-o})}}s.sort((e,t)=>e.time-t.time||t.delta-e.delta);let a=0,r=0,l=0;for(const e of s)a+=e.delta,r=Math.min(r,a),e.time>t||(l+=e.delta);return i?l-r:l}function Me(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function Se(e){const{desired:t,minGaps:o,weights:n}=e,i=t.length;if(0===i)return[];if(o.length!==Math.max(0,i-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const s=Array(i).fill(0);for(let e=1;i>e;e++)s[e]=s[e-1]+Math.max(0,Number.isFinite(o[e-1])?o[e-1]:0);const a=[];for(let e=0;i>e;e++){const o=Math.max(Number.EPSILON,Number.isFinite(n?.[e])?n[e]:1),i=(Number.isFinite(t[e])?t[e]:0)-s[e];for(a.push({start:e,end:e,weight:o,mean:i});a.length>1;){const e=a[a.length-1],t=a[a.length-2];if(e.mean>=t.mean)break;const o=t.weight+e.weight;a.splice(a.length-2,2,{start:t.start,end:e.end,weight:o,mean:(t.mean*t.weight+e.mean*e.weight)/o})}}const r=Number.isFinite(e.min)?e.min:-1/0,l=Number.isFinite(e.max)?e.max-s[i-1]:1/0,c=r>l?r:l,d=Array(i);for(const e of a){const t=Math.max(r,Math.min(c,e.mean));for(let o=e.start;e.end>=o;o++)d[o]=t+s[o]}return d}function Te(e,t){let o=0,n=e.length-1,i=-1;for(;n>=o;){const s=o+n>>>1;e[s].at>t?n=s-1:(i=s,o=s+1)}return 0>i?{at:t,before:0,after:0}:e[i]}function Ae(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const o=[],n=[0];for(let i=0;e.length-1>i;i++){const s=e[i],a=e[i+1],r=[...new Set([...s.map(e=>e.at),...a.map(e=>e.at)])].sort((e,t)=>e-t);let l=0;for(const e of r){const t=Te(s,e),o=Te(a,e);l=Math.max(l,t.after+o.before)}o.push(l),n.push(n[n.length-1]+l+t)}return{adjacentClearance:o,positions:n}}function Ie(e,t,o,n={}){let i=[...e];if(1>=i.length)return i;let s=[...i],a=o(i),r=1;const l=Math.max(0,n.passes??6),c=Math.max(1,n.maxEvaluations??1/0);for(let e=0;l>e&&c>r;e++){const e=new Map(i.map((e,t)=>[e,t])),l=new Map,c=new Map;for(const o of t){const t=e.get(o.source),n=e.get(o.target);if(null==t||null==n)continue;const i=Number.isFinite(o.weight)&&o.weight>0?o.weight:1;l.set(o.source,(l.get(o.source)??0)+n*i),c.set(o.source,(c.get(o.source)??0)+i),l.set(o.target,(l.get(o.target)??0)+t*i),c.set(o.target,(c.get(o.target)??0)+i)}i=i.map((e,t)=>({item:e,index:t,barycenter:(l.get(e)??t)/(c.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(n.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const d=o(i);if(r++,a>d)a=d,s=[...i];else if(d===a)break}return s}function Pe(e,t,o={}){const n=[...e],i=n.length;if(1>=i||i>(o.maxItems??8))return n;const s=Math.max(1,o.maxEvaluations??1/0);let a=0,r=[...n],l=1/0;const c=()=>{if(a>=s)return;const e=t(n);a++,l>e&&(l=e,r=[...n])};c();const d=Array(i).fill(0);let u=0;for(;i>u&&s>a;)if(u>d[u]){const e=u%2==0?0:d[u];[n[e],n[u]]=[n[u],n[e]],c(),d[u]++,u=0}else d[u]=0,u++;return r}function Ce(){return Object.create(null)}function Oe(e,t){return t>e?-1:e>t?1:0}function Ne(e){return e.occupants.map(e=>e.id).sort(Oe).join("\0")}function Le(e,t,o=0){return e.slice(0,-1).map((n,i)=>null!=n.group&&n.group===e[i+1].group?o:t)}function Be(e,t){return e.map(e=>{const o=new Map;for(const n of e.occupants){const e=t[n.id];if(e)for(const t of e.samples){const e=o.get(t.t)??{before:0,after:0},n=t.boundaryOffset??0;o.set(t.t,{before:Math.max(e.before,t.topMass-n),after:Math.max(e.after,t.botMass+n)})}}return[...o].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function He(e,t,o){if(0===e.length)return[];const{padding:n,plotH:i,valueScale:s}=o,a=o.stackValueScale??s,r=Le(e,n,o.groupPadding??0),l=[n+e[0].peak.topPeak*a];for(let o=1;e.length>o;o++)l.push(l[o-1]+t[o-1]*a+r[o-1]);const c=l[l.length-1]+e[e.length-1].peak.botPeak*a+n;if(c>i&&c>0){const e=i/c;for(let t=0;l.length>t;t++)l[t]*=e}return l}function De(e,t){const o=(e.boundaryOffset??0)*t,n=e.value*t;if("out"===e.kind){const i=e.sideMassBefore*t;return o+("top"===e.side?n/2-i:i-n/2)}const i=e.sideMassAfter*t;return o+("top"===e.side?n/2-i:i-n/2)}function Ee(e,t,o,n,i,s){const a=s.adjacentClearance?[...s.adjacentClearance]:Ae(Be(n,o)).adjacentClearance,r=He(n,a,s);let l="hug"===s.lanePlacement?function(e,t,o,n,i,s,a){const r=e.length;if(0===r)return[];const{padding:l,plotH:c,valueScale:d}=a,u=Le(e,l,a.groupPadding??0),g=i.map((e,t)=>e*d+u[t]),m=l+e[0].peak.topPeak*d,f=c-l-e[r-1].peak.botPeak*d;if(g.reduce((e,t)=>e+t,0)+1e-6>=f-m)return He(e,i,a);let h=1===r?[(m+f)/2]:[...s];for(let e=0;12>e;e++){const e=Array(r).fill(0),i=Array(r).fill(0);for(const s of o){const o=t[s.source],a=t[s.target];if(null==o||null==a||o===a)continue;const r=n[s.source]?.localAttachments.get(s.id),l=n[s.target]?.localAttachments.get(s.id);if(!r||!l)continue;const c=s.value>0&&Number.isFinite(s.value)?s.value:1,u=De(r,d),g=De(l,d);e[o]+=(h[a]+g-u)*c,i[o]+=c,e[a]+=(h[o]+u-g)*c,i[a]+=c}const s=Se({desired:h.map((t,o)=>0===i[o]?t:.45*t+e[o]/i[o]*.55),minGaps:g,weights:i.map(e=>Math.max(1,e)),min:m,max:f});let a=0;for(let e=0;r>e;e++)a=Math.max(a,Math.abs(s[e]-h[e]));if(h=s,.01>a)break}return h}(n,i,t,o,a,r,s):[...r];if("hug"===s.lanePlacement){const o=t=>{const o=Ce();for(const n of e)o[n.id]=t[i[n.id]];return o};Fe(o(l),t)>Fe(o(r),t)+1e-6&&(l=[...r])}const c=Ce();for(const t of e)c[t.id]=l[i[t.id]];let d=1/0,u=-1/0;for(const t of e){const e=c[t.id],n=o[t.id];Number.isFinite(e)&&n&&(d=Math.min(d,e-n.topPeak*s.valueScale),u=Math.max(u,e+n.botPeak*s.valueScale))}return{adjacentClearance:a,centerlines:c,slotCenter:l,stackCenter:r,verticalUtilization:Number.isFinite(d)&&Number.isFinite(u)&&s.plotH>0?Math.max(0,Math.min(1,(u-d)/s.plotH)):0}}function Fe(e,t){let o=0;for(const n of t){const t=e[n.source],i=e[n.target];Number.isFinite(t)&&Number.isFinite(i)&&(o+=Math.abs(t-i)*(n.value>0?n.value:1))}return o}function Re(e,t){const o=e?.samples;if(!o||0===o.length||o[0].t>t)return{top:0,bot:0};let n=0,i=o.length-1,s=0;for(;i>=n;){const e=n+i>>>1;o[e].t>t?i=e-1:(s=e,n=e+1)}const a=o[s].boundaryOffset??0;return{top:o[s].topMass-a,bot:o[s].botMass+a}}function ze(e,t,o,n,i){const s=1-i;return s*s*s*e+3*s*s*i*t+3*s*i*i*o+i*i*i*n}function We(e,t){let o=0,n=1;for(let i=0;28>i;i++){const i=(o+n)/2;e>ze(0,t,t,1,i)?o=i:n=i}return(o+n)/2}function _e(e,t,o){const n=t+De(e,o),i=e.value*o/2;return[n-i,n+i]}function $e(e,t,o,n){return Math.max(0,Math.min(t,n)-Math.max(e,o))/Math.max(1e-9,t-e)}function je(e,t,o,n,i,s,a){const{valueScale:r,domain:l,mode:c="quality"}=a,d="source"===a.ribbonLane?.85:"target"===a.ribbonLane?.15:.5;let u=0;for(const a of e){const e=n[a.source],g=n[a.target];if(null==e||null==g||2>Math.abs(e-g))continue;const m=t[a.source]?.localAttachments.get(a.id),f=t[a.target]?.localAttachments.get(a.id);if(!m||!f)continue;const h=Math.max(a.startTime,l?.[0]??-1/0),p=Math.min(a.endTime,l?.[1]??1/0);if(h>=p)continue;const[b,y]=_e(m,i[a.source],r),[v,k]=_e(f,i[a.target],r),w=Math.min(e,g)+1,x=Math.max(e,g)-1;for(let e=w;x>=e;e++){const n=o[e];if(!n)continue;const l=[h,p];if("quality"===c)for(const e of n.occupants)for(const o of t[e.id]?.samples??[])o.t>h&&p>o.t&&l.push(o.t);const g=e=>{const o=We((e-h)/(p-h),d),l=ze(b,b,v,v,o),c=ze(y,y,k,k,o);let u=0;for(const o of n.occupants){if(o.id===a.source||o.id===a.target)continue;const n=s[o.id];if(null!=n?.start&&n.start>e)continue;if(null!=n?.end&&e>n.end)continue;const d=Re(t[o.id],e),g=i[o.id];u=Math.max(u,$e(l,c,g-d.top*r,g+d.bot*r))}return u},m=[...new Set(l)].sort((e,t)=>e-t);let f=0;for(let e=0;m.length-1>e;e++){const t=m[e],o=m[e+1]-t;f+=(g(t+.25*o)+g(t+.5*o)+g(t+.75*o))/3*o}u+=f/(p-h)*(a.value>0?a.value:1)}}return u}function Xe(e,t,o,n,i,s,a,r,l,c,d="both",u){return{crossings:e,weightedLength:t,pixelLength:Fe(a,o),transitOcclusion:je(o,n,i,s,a,r,{valueScale:l,ribbonLane:d,domain:u,mode:"quality"}),verticalUtilization:c}}function Ye(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Ge(e,t){return e.map(e=>({t:Ye(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function qe(e,t,o){const n=t+(e.boundaryOffset??0)*o,i=e.value*o;if("out"===e.kind){const t=e.sideMassBefore*o;if("top"===e.side){const e=n-t;return[e,e+i]}const s=n+t;return[s-i,s]}const s=e.sideMassAfter*o;if("top"===e.side){const e=n-s;return[e,e+i]}const a=n+s;return[a-i,a]}function Ve(e,t,o,n,i="temporal"){const s=t.incoming[e.id],a=t.outgoing[e.id],r=[];for(const e of s)r.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:o.get(e.id).targetSide});for(const e of a)r.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:o.get(e.id).sourceSide});const l={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},c=()=>{r.sort((e,t)=>e.time-t.time||(e.phase??0)-(t.phase??0)||(e.sequence??0)-(t.sequence??0)||(l[e.kind]??99)-(l[t.kind]??99)||((e,t)=>{if(!n||!e.edge||!t.edge||e.kind!==t.kind||e.side!==t.side)return 0;if("out"===e.kind){if(e.edge.target===t.edge.target&&e.edge.endTime===t.edge.endTime)return 0;const o=n.get(e.edge.id)?.target,i=n.get(t.edge.id)?.target;return"number"==typeof o&&Number.isFinite(o)&&"number"==typeof i&&Number.isFinite(i)&&o!==i?"top"===e.side?o-i:i-o:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;const o=n.get(e.edge.id)?.source,i=n.get(t.edge.id)?.source;return"number"==typeof o&&Number.isFinite(o)&&"number"==typeof i&&Number.isFinite(i)&&o!==i?"top"===e.side?i-o:o-i:0}return 0})(e,t)||Oe(e.edge?.id??"",t.edge?.id??"")||Oe(e.side,t.side)||e.delta-t.delta)},d=r.length?Y(r.map(e=>e.time)):null,u=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,g=null!=u?u-1:null!=d&&Number.isFinite(d)?d-1:null;c();let m=null,f=0;for(const e of r)e.time!==m&&(m=e.time,f=0),e.sequence=f++;const h=e=>({time:e.time,phase:0,sequence:e.sequence??0}),p=[];let b=0,y=0;for(const e of r)if("out"===e.kind){const t=Math.abs(e.delta);let o=t-("top"===e.side?b:y);if(o>0){const t="top"===e.side?"bot":"top",n=Math.min(o,"top"===t?b:y);if(n>0){const i=h(e);p.push({...i,delta:-n,kind:"transfer-out",side:t}),p.push({...i,delta:+n,kind:"transfer-in",side:e.side}),"top"===t?b-=n:y-=n,"top"===e.side?b+=n:y+=n,o-=n}o>0&&null!==g&&(p.push({time:g,delta:+o,kind:"create",side:e.side}),"top"===e.side?b+=o:y+=o)}"top"===e.side?b-=t:y-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?b+=t:y+=t}r.push(...p),c();let v=0,k=0,w=0,x=0,M=0,S=0;const T=[],A=new Map,I=e=>{T.push({t:e,topMass:v,botMass:k,...Math.abs(w)>1e-12&&{boundaryOffset:w}})},P=()=>{x=Math.max(x,v+k),M=Math.max(M,v-w),S=Math.max(S,k+w)};for(const e of r){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&I(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?v:k;A.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta),...Math.abs(w)>1e-12&&{boundaryOffset:w}})}"top"===e.side?v+=e.delta:k+=e.delta,"transfer-in"===e.kind?(w+="top"===e.side?e.delta:-e.delta,P(),I(e.time)):"transfer-out"!==e.kind&&(P(),"out"!==e.kind||v+k>1e-12||(w=0),I(e.time))}const C=[];let O=0;for(;T.length>O;){let e=O;for(;T.length>e+1&&T[e+1].t===T[O].t;)e++;C.push(T[O]);for(let t=O+1;e>=t;t++){const e=C[C.length-1];T[t].topMass===e.topMass&&T[t].botMass===e.botMass&&(T[t].boundaryOffset??0)===(e.boundaryOffset??0)||C.push(T[t])}O=e+1}const N=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let L=null;for(const e of a)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===L||L>e.systemInTime)&&(L=e.systemInTime);let B=null;for(const e of s)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===B||e.systemOutTime>B)&&(B=e.systemOutTime);if(C.length>0){const e=C[C.length-1],t=Math.max(null!=N?N:-1/0,null!=B?B:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&C.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});const o=C[0],n=C.find(e=>e.topMass+e.botMass>0);let i,s=1/0;null!=u&&Number.isFinite(u)&&o.t>u&&o.topMass+o.botMass>0&&(s=u,i=o),n&&null!=L&&Number.isFinite(L)&&n.t>L&&s>L&&(s=L,i=n),i&&Number.isFinite(s)&&C.unshift({t:s,topMass:i.topMass,botMass:i.botMass,...null!=i.boundaryOffset&&{boundaryOffset:i.boundaryOffset}})}let H=C;if("max"===i&&null!=u&&null!=N&&N>u){let e,t=0;for(const o of C){const n=o.topMass+o.botMass;n>t&&(t=n,e=o)}if(e){const t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};H=[...C.filter(e=>u>e.t),{t:u,...t},{t:N,...t},...C.filter(e=>e.t>N)]}}return{samples:H,peak:x,topPeak:M,botPeak:S,localAttachments:A}}function Ue(e){const t=Ce();return e.forEach((e,o)=>{for(const n of e.occupants)t[n.id]=o}),t}function Qe(e,t,o){e.splice(0,e.length,...o);const n=Ue(o);for(const e of Object.keys(t))delete t[e];Object.assign(t,n)}function Ke(e){const t=new Map,o=[];e.forEach((e,n)=>{if(!e.group)return void o.push({anchor:n,stableId:Ne(e),slots:[e]});const i=t.get(e.group)??{indexes:[],slots:[]};i.indexes.push(n),i.slots.push(e),t.set(e.group,i)});for(const[e,n]of t)o.push({anchor:n.indexes.reduce((e,t)=>e+t,0)/n.indexes.length,stableId:`${e}\0${n.slots.map(Ne).join("\0")}`,slots:n.slots});return o.sort((e,t)=>e.anchor-t.anchor||Oe(e.stableId,t.stableId))}function Je(e){return e.some(e=>e.group)?Ke(e).flatMap(e=>e.slots):[...e]}function Ze(e){return e.flatMap(e=>e.slots)}function et(e,t,o){const n=new Map;return e.forEach((e,t)=>{for(const o of e.slots)n.set(o,t)}),e.map((e,i)=>{if(1>=e.slots.length)return e;const s=new Map;for(const t of e.slots)s.set(t,0);for(const e of t){const t=n.get(e.source),o=n.get(e.target);if(null==t||null==o)continue;const a=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===i&&o!==i){const t=o>i?1:-1;s.set(e.source,(s.get(e.source)??0)+a*t)}else if(o===i&&t!==i){const o=t>i?1:-1;s.set(e.target,(s.get(e.target)??0)+a*o)}}const a=[...e.slots].sort((e,t)=>(s.get(e)??0)-(s.get(t)??0)||o(e,t));return{...e,slots:a}})}function tt(e,t){e.some(e=>e.group)&&Qe(e,t,Je(e))}function ot(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.min(e.endTime,t.endTime)>Math.max(e.startTime,t.startTime)}function nt(e,t){return function(e,t,o=()=>!0){let n=0;for(let i=0;e.length>i;i++){const[s,a]=t(e[i]);for(let r=i+1;e.length>r;r++){if(!o(e[i],e[r]))continue;const[l,c]=t(e[r]);0>(s-l)*(a-c)&&n++}}return n}(t,t=>[e[t.source],e[t.target]],ot)}function it(e,t){let o=0;for(const n of t){const t=e[n.source],i=e[n.target];null!=t&&null!=i&&(o+=Math.abs(t-i)*(n.value>0?n.value:1))}return o}function st(e,t,o){const[n,i]=o.get(e.first),[s,a]=o.get(e.second);return 0>(t.get(n)-t.get(s))*(t.get(i)-t.get(a))?1:0}var at=e=>{let t=1;for(let o=2;e>=o;o++)t*=o;return t},rt=828*at(8),lt=3e3;function ct(e,t,o,n,i,s,a){const r=[...i],l=new Map(i.map(e=>[e,Ne(e)])),c=new Map;for(const e of i)for(const t of e.occupants)c.set(t.id,e);const d=new Map,u=[];for(const e of t){const t=c.get(e.source),o=c.get(e.target);t&&o&&(d.set(e,[t,o]),t!==o&&u.push({source:t,target:o,weight:e.value}))}const g=[];for(let e=0;t.length>e;e++)if(d.has(t[e]))for(let o=e+1;t.length>o;o++){if(!d.has(t[o])||!ot(t[e],t[o]))continue;const n=new Set([...d.get(t[e]),...d.get(t[o])]);g.push({index:g.length,first:t[e],second:t[o],involvedSlots:n})}const m=new Map;for(const e of i)m.set(e,[]);for(const e of g)for(const t of e.involvedSlots)m.get(t)?.push(e);const f=new Uint32Array(g.length);let h=0;const p=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),b=a.plotH/Math.max(1,i.length),y=i.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),v=Math.max(1,p)*(Math.max(1,a.plotH)+b*Math.max(y,i.length)+1e-6*Math.max(1,i.length-1))+1,k=4*b,w={fullCrossing:0,localCrossing:0},x=new Map,M=(e,t)=>{let n=x.get(e);n||(n=new Map,x.set(e,n));const i=n.get(t);if(null!=i)return i;const s=function(e,t,o){return Ae(Be([e,t],o)).adjacentClearance[0]??0}(e,t,o);return n.set(t,s),s},S=new Map(i.map((e,t)=>[e,t])),T=t.flatMap(e=>{const t=d.get(e);return t?[{source:S.get(t[0]),target:S.get(t[1]),weight:e.value>0?e.value:1}]:[]}),A=new Map;for(const e of t){const t=d.get(e);t&&A.set(e,{source:S.get(t[0]),target:S.get(t[1])})}const I=new Map,P=new Map,C=new Map,O=(e,t,o)=>{e.has(t)||e.set(t,new Set),e.get(t).add(o)};for(const e of t)O(I,e.source,e.target),O(P,e.target,e.source),O(C,e.source,e.target),O(C,e.target,e.source);const N=t.flatMap(e=>{if(!(e=>1===I.get(e.source)?.size&&I.get(e.source).has(e.target)||1===C.get(e.source)?.size||1===C.get(e.target)?.size)(e))return[];const t=A.get(e);return t&&t.source!==t.target?[{source:t.source,target:t.target,weight:e.value>0?e.value:1}]:[]}),L=e=>{let t=0;for(const o of N)t+=Math.max(0,Math.abs(e[o.source]-e[o.target])-1)*o.weight;return t*k},B=e=>{const t=new Int16Array(i.length);for(let o=0;e.length>o;o++)t[S.get(e[o])]=o;return L(t)},H=g.map(e=>{const t=A.get(e.first),o=A.get(e.second);return[t.source,t.target,o.source,o.target]}),D=new Int16Array(i.length),E=new Float64Array(i.length),F=new Float64Array(i.length+1),R=e=>{for(let t=0;e.length>t;t++)D[S.get(e[t])]=t;let t=0;for(const[e,o,n,i]of H)0>(D[e]-D[n])*(D[o]-D[i])&&t++;if(e.length>0){const t=S.get(e[0]);E[t]=a.padding+e[0].peak.topPeak*a.valueScale;for(let t=1;e.length>t;t++){const o=S.get(e[t-1]),n=S.get(e[t]);E[n]=E[o]+M(e[t-1],e[t])*a.valueScale+a.padding}const o=S.get(e[e.length-1]),n=E[o]+e[e.length-1].peak.botPeak*a.valueScale+a.padding;if(n>a.plotH&&n>0){const e=a.plotH/n;for(let t=0;E.length>t;t++)E[t]*=e}}F[0]=0;for(let t=0;e.length>t;t++)F[t+1]=F[t]+e[t].peak.topPeak+e[t].peak.botPeak;let o=0,n=0,i=0;for(const e of T){const t=D[e.source],s=D[e.target];if(o+=Math.abs(t-s)*e.weight,n+=Math.abs(E[e.source]-E[e.target])*e.weight,Math.abs(t-s)>=2){const o=Math.min(t,s)+1;i+=(F[Math.max(t,s)]-F[o])*e.weight}}return t*v+n+i*b+L(D)+1e-6*o},z=(e,o)=>{const n=Array(e.length+1).fill(0);for(let t=0;e.length>t;t++)n[t+1]=n[t]+e[t].peak.topPeak+e[t].peak.botPeak;let i=0;for(const e of t){const t=o[e.source],s=o[e.target];if(null==t||null==s||2>Math.abs(t-s))continue;const a=Math.min(t,s)+1;i+=(n[Math.max(t,s)]-n[a])*(e.value>0?e.value:1)}return i},W=n=>{const i=Ue(n),s=n.slice(0,-1).map((e,t)=>M(e,n[t+1])),r=Ee(e,t,o,n,i,{plotH:a.plotH,padding:a.padding,valueScale:a.valueScale,lanePlacement:a.lanePlacement??"stack",groupPadding:a.groupPadding,adjacentClearance:s});return{map:i,geometry:r,weightedLength:it(i,t),pixelLength:Fe(r.centerlines,t),transitOcclusion:z(n,i)}},_=(e,t,o)=>({crossings:e,weightedLength:t.weightedLength,pixelLength:t.pixelLength,transitOcclusion:t.transitOcclusion,cost:e*v+t.pixelLength+t.transitOcclusion*b+B(o)+1e-6*t.weightedLength}),$=(e,t)=>{let o=t;if(null==o){const t=new Map(e.map((e,t)=>[e,t]));o=g.reduce((e,o)=>e+st(o,t,d),0),w.fullCrossing++}return _(o,W(e),e)},j=(e,i,s="quality")=>{let r=i;if(null==r){const t=new Map(e.map((e,t)=>[e,t]));r=g.reduce((e,o)=>e+st(o,t,d),0),w.fullCrossing++}const l=W(e);return _(r,{...l,transitOcclusion:je(t,o,e,l.map,l.geometry.centerlines,n,{valueScale:a.valueScale,ribbonLane:a.ribbonLane,domain:a.domain,mode:s})},e)};let X=[...r];const Y=(e,t)=>Oe(l.get(e),l.get(t)),G=function(e){const t=new Set;for(const o of e)if(o.group){if(t.has(o.group))return!0;t.add(o.group)}return!1}(X),q=e=>{const t=(e=>{const t=Ie(e,u,e=>$(e).cost,{passes:6,compare:Y,maxEvaluations:lt});let o=$(t),n=lt;for(let e=0;6>e&&n>0;e++){let i=!1;const s=Array.from({length:t.length-1},(e,t)=>t);e%2==1&&s.reverse();for(const e of s){if(0>=n--)break;const s=t[e],a=t[e+1],r=new Map(t.map((e,t)=>[e,t]));let l=0;const c=[];h++;for(const e of[...m.get(s)??[],...m.get(a)??[]])f[e.index]!==h&&(f[e.index]=h,c.push(e),l+=st(e,r,d));[t[e],t[e+1]]=[a,s];const u=new Map(r);u.set(s,e+1),u.set(a,e);let g=0;for(const e of c)g+=st(e,u,d);w.localCrossing+=c.length;const p=$(t,o.crossings-l+g);o.cost>p.cost?(o=p,i=!0):[t[e],t[e+1]]=[s,a]}if(!i)break}return t})(e);if((e.length>8?1/0:at(e.length)*(e.length+T.length+H.length))>rt)return t;const o=Pe(e,R,{maxItems:8,maxEvaluations:5e4}),n=j(o),i=j(t);return n.crossings!==i.crossings&&i.crossings>n.crossings?o:t},V="geometry-refine"===a.mode;if(V||"crossing-min"!==a.laneOrder&&"crossing-min+inside-out"!==a.laneOrder){if(!V&&"inside-out"===a.laneOrder)if(G){const e=Ke(X),t=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),o=[...e].sort((e,o)=>t(o)-t(e)||Oe(e.stableId,o.stableId)),n=Array(o.length);let i=Math.floor((o.length-1)/2)-1,s=Math.floor((o.length-1)/2)+1;o.length>0&&(n[Math.floor((o.length-1)/2)]=o[0]);for(let e=1;o.length>e;e++)e%2==1&&o.length>s||0>i?n[s++]=o[e]:n[i--]=o[e];X=Ze(n)}else{const e=[...X].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||Y(e,t)),t=Array(e.length);let o=Math.floor((e.length-1)/2)-1,n=Math.floor((e.length-1)/2)+1;e.length>0&&(t[Math.floor((e.length-1)/2)]=e[0]);for(let i=1;e.length>i;i++)i%2==1&&e.length>n||0>o?t[n++]=e[i]:t[o--]=e[i];X=t}}else X=G?(e=>{let t=Ke(e);if(1>=t.length)return Ze(t);const o=e=>$(Ze(e)).cost;t=Ke(q(e)),t=et(t,u,Y);const n=function(e,t){const o=new Map;for(const t of e)for(const e of t.slots)o.set(e,t);const n=new Map;for(const e of t){const t=o.get(e.source),i=o.get(e.target);if(!t||!i||t===i)continue;const s=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,a=i.stableId>t.stableId?`${t.stableId}\0${i.stableId}`:`${i.stableId}\0${t.stableId}`,r=n.get(a);r?r.weight=(r.weight??0)+s:n.set(a,{source:t,target:i,weight:s})}return[...n.values()]}(t,u);t=Ie(t,n,o,{passes:6,compare:(e,t)=>Oe(e.stableId,t.stableId),maxEvaluations:lt}),t=function(e,t,o={}){const n=[...e];if(1>=n.length)return n;let i=t(n),s=1;const a=Math.max(0,o.passes??6),r=Math.max(1,o.maxEvaluations??1/0);for(let e=0;a>e&&r>s;e++){let e=!1;for(let o=0;n.length-1>o&&r>s;o++){[n[o],n[o+1]]=[n[o+1],n[o]];const a=t(n);s++,i>a?(i=a,e=!0):[n[o],n[o+1]]=[n[o+1],n[o]]}if(!e)break}return n}(t,o,{passes:8,maxEvaluations:lt});const i=t.length>8?1/0:at(t.length)*(t.length+T.length+H.length);if(rt>=i){const e=Pe(t,e=>R(Ze(e)),{maxItems:8,maxEvaluations:5e4}),o=Ze(e),n=Ze(t),i=j(o),s=j(n);i.crossings!==s.crossings?t=s.crossings>i.crossings?e:t:s.cost>i.cost&&(t=e)}return t=et(t,u,Y),Ze(t)})(X):q(X);if(!V&&"crossing-min+inside-out"===a.laneOrder&&X.length>1)if(G){const e=Ke(X);let t=$(Ze(e)),o=Ze(e),n=t;const i=Math.floor((e.length-1)/2),s=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),a=[...e].sort((e,t)=>s(t)-s(e)||Oe(e.stableId,t.stableId));for(const s of a){const a=e.indexOf(s);if(a===i)continue;e.splice(a,1),e.splice(i,0,s);const r=Ze(e),l=$(r);l.cost>t.cost?(e.splice(i,1),e.splice(a,0,s)):(t=l,n.cost>l.cost&&(o=r,n=l))}X=o}else{let e=$(X),t=[...X],o=e;const n=Math.floor((X.length-1)/2),i=[...X].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||Y(e,t));for(const s of i){const i=X.indexOf(s);if(i===n)continue;X.splice(i,1),X.splice(n,0,s);const a=$(X);a.cost>e.cost?(X.splice(n,1),X.splice(i,0,s)):(e=a,o.cost>a.cost&&(t=[...X],o=a))}X=t}if((V||"crossing-min"===a.laneOrder||"crossing-min+inside-out"===a.laneOrder)&&X.length>1)if(G){let e=Ke(X),t=j(Ze(e),void 0,"score");for(let o=0;6>o&&e.length>1;o++){let o=!1;for(let n=0;e.length-1>n;n++){[e[n],e[n+1]]=[e[n+1],e[n]];const i=Ze(e),s=j(i,void 0,"score");t.cost>s.cost?(X=i,t=s,o=!0):[e[n],e[n+1]]=[e[n+1],e[n]]}if(!o)break}e=et(Ke(X),u,Y),X=Ze(e)}else{let e=j(X,void 0,"score");for(let t=0;X.length-1>t;t++){const o=X[t],n=X[t+1],i=new Map(X.map((e,t)=>[e,t]));let s=0;const a=[];h++;for(const e of[...m.get(o)??[],...m.get(n)??[]])f[e.index]!==h&&(f[e.index]=h,a.push(e),s+=st(e,i,d));[X[t],X[t+1]]=[n,o];const r=new Map(i);r.set(o,t+1),r.set(n,t);let l=0;for(const e of a)l+=st(e,r,d);w.localCrossing+=a.length;const c=j(X,e.crossings-s+l,"score");e.cost>c.cost?e=c:[X[t],X[t+1]]=[o,n]}}const U=Je(r);X=Je(X);let Q=j(X);const K=j(U);if(V){const e=B(U),t=B(X);(Q.crossings>K.crossings||Q.crossings===K.crossings&&t>e+1e-9||Q.cost>K.cost)&&(X=U,Q=K)}else Q.cost>K.cost&&(X=U,Q=K);const J=function({order:e,after:t,nodes:o,edges:n,outgoingPartners:i,incomingPartners:s,slotForNode:a,averageGap:r,evaluate:l}){const c=(o,i)=>{const s=[...new Set(i.map(t=>e.indexOf(t)))].sort((e,t)=>e-t),a=e.indexOf(o),c=s[0],d=s[s.length-1];if(3>s.length||!s.includes(a)||d-c+1!==s.length||1>=Math.abs(2*a-c-d))return;const u=[...e];u.splice(a,1),u.splice(c+d>>1,0,o);const g=Je(u),m=l(g),f=new Set(o.occupants.map(e=>e.id)),h=new Set(i.flatMap(e=>e.occupants.map(e=>e.id))),p=n.reduce((e,t)=>f.has(t.source)&&h.has(t.target)||f.has(t.target)&&h.has(t.source)?e+(t.value>0?t.value:1):e,0);(function(e,t,o=0){return t.crossings>e.crossings||e.crossings===t.crossings&&t.cost+o>=e.cost})(m,t,Math.abs(2*a-c-d)*r*Math.max(1,p))&&(e=g,t=m)};for(const[e,t]of i)s.has(e)||3>t.size||c(a.get(e),[...t].map(e=>a.get(e)));for(const e of o){const t=a.get(e.id);e.group||!t.group||3>(s.get(e.id)?.size??0)||c(t,[...s.get(e.id)??[]].map(e=>a.get(e)).filter(e=>e===t||e.group===t.group).filter((e,t,o)=>o.indexOf(e)===t))}return{order:e,after:t}}({order:X,after:Q,nodes:e,edges:t,outgoingPartners:I,incomingPartners:P,slotForNode:c,averageGap:b,evaluate:j});return X=J.order,Q=J.after,Qe(i,s,X),{before:K,after:Q,initialOrder:r.map(e=>l.get(e)),evaluations:w}}function dt(e,t,o){const n=e.map(e=>{const n=e.occupants.map(e=>({id:e.id,end:o[e.id]?.end??e.end}));let i=0,s=0;for(const e of n){const o=t[e.id];i=Math.max(i,o?.topPeak||0),s=Math.max(s,o?.botPeak||0)}return{occupants:n,peak:{topPeak:i,botPeak:s},...null!=e.group?{group:e.group}:{}}}),i=Ce();return n.forEach((e,t)=>{for(const o of e.occupants)i[o.id]=t}),{slots:n,slotByNode:i}}var ut=new Map,gt=1e5,mt=1e-9;function ft(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function ht(e,t){return Oe(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function pt(e){const t=new Map,o=new Map;for(const n of e)o.has(n.source)||o.set(n.source,new Set),t.has(n.target)||t.set(n.target,new Set),o.get(n.source).add(n.target),t.get(n.target).add(n.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...o].map(([e,t])=>[e,t.size]))}}function bt(e){const t=new Map,o=new Map,n=(e,t,o,n)=>{let i=e.get(t);i||(i=new Map,e.set(t,i)),i.set(o,(i.get(o)??0)+n)};for(const i of e){const e=i.value>0&&Number.isFinite(i.value)?i.value:1;n(t,i.source,i.target,e),n(o,i.target,i.source,e)}const i=new Map,s=e=>{if(i.has(e))return;const n=t.get(e),s=o.get(e),a=new Map;for(const[e,t]of n??[])a.set(e,(a.get(e)??0)+t);for(const[e,t]of s??[])a.set(e,(a.get(e)??0)+t);if(1===a.size){const[t,o]=[...a][0];i.set(e,{partner:t,weight:o})}};for(const t of e)s(t.source),s(t.target);return i}function yt(e,t,o){const n=o.get(e),i=o.get(t);return!n||!i||n.partner===i.partner||n.partner===t||i.partner===e}function vt(e,t,o){return!!o.has(e)&&t.some(t=>!yt(e,t,o))}function kt(e,t){return(e.value>0&&Number.isFinite(e.value)?e.value:1)*(1+(1===t.outgoing.get(e.source)?1:0)+(1===t.incoming.get(e.target)?1:0))}function wt(e,t,o,n){if(12>=e.length||1>=n.slotCount)return n.assignment;const i=new Map(e.map((e,t)=>[e,t])),s=Array.from({length:e.length},()=>new Map),a=pt(o);for(const e of o){const t=i.get(e.source),o=i.get(e.target);if(null==t||null==o||t===o)continue;const n=kt(e,a);s[t].set(o,(s[t].get(o)??0)+n),s[o].set(t,(s[o].get(t)??0)+n)}const r=bt(o),l=e.map(e=>r.get(e)?.weight??0),c=Array.from({length:e.length},()=>new Map);let d=0;for(let o=0;e.length-1>o&&5e4>d;o++)if(r.has(e[o]))for(let n=o+1;e.length>n;n++){if(!r.has(e[n]))continue;if(t.conflicts(e[o],e[n]))continue;d++;const i=Math.min(l[o],l[n])||Math.max(l[o],l[n]),s=yt(e[o],e[n],r)?i:-i;if(Math.abs(s)>mt&&(c[o].set(n,s),c[n].set(o,s),d>=5e4))break}const u=[...n.assignment],g=Array.from({length:n.slotCount},()=>[]);u.forEach((e,t)=>g[e].push(t));const m=(e,t,o)=>{const n=u[t],i=u[o];let s=0;const a=new Set;for(const r of[t,o])for(const[l,c]of e[r]){const e=l>r?`${r}:${l}`:`${l}:${r}`;if(a.has(e))continue;a.add(e);const d=(r===t?i:n)===(l===t?i:l===o?n:u[l]);u[r]===u[l]!==d&&(s+=d?c:-c)}return s},f=(e,t,o)=>{let n=0;for(const[i,s]of e[t]){const e=o===u[i];u[t]===u[i]!==e&&(n+=e?s:-s)}return n},h=(e,t)=>e>mt||mt>=Math.abs(e)&&t>mt,p=(e,t,o,n)=>e>o+mt||mt>=Math.abs(e-o)&&t>n+mt;let b=0;for(let o=0;32>o&&gt>b;o++){let o=null,n=-1,i=-1,a=-1,r=-1/0,l=-1/0;for(let d=0;e.length>d;d++){for(let m=0;g.length>m&&b++<gt;m++){if(m===u[d])continue;if(!g[m].every(o=>!t.conflicts(e[d],e[o])))continue;const b=f(s,d,m),y=f(c,d,m);h(b,y)&&p(b,y,r,l)&&(o="move",n=d,i=-1,a=m,r=b,l=y)}if(b>=gt)break}for(let d=0;e.length-1>d;d++){for(let f=d+1;e.length>f&&b++<gt;f++){const b=u[d],y=u[f];if(b===y)continue;if(!g[y].every(o=>o===f||!t.conflicts(e[d],e[o])))continue;if(!g[b].every(o=>o===d||!t.conflicts(e[f],e[o])))continue;const v=m(s,d,f),k=m(c,d,f);h(v,k)&&p(v,k,r,l)&&(o="swap",n=d,i=f,a=-1,r=v,l=k)}if(b>=gt)break}if(null==o||-1===n)break;if("move"===o){const e=u[n];g[e].splice(g[e].indexOf(n),1),g[a].push(n),u[n]=a;continue}const d=u[n],y=u[i];g[d].splice(g[d].indexOf(n),1,i),g[y].splice(g[y].indexOf(i),1,n),u[n]=y,u[i]=d}return u}function xt(e,t){let o=1/0,n=-1/0;for(const t of e?.samples??[])t.topMass+t.botMass>1e-9&&(o=Math.min(o,t.t),n=Math.max(n,t.t));return Number.isFinite(o)&&Number.isFinite(n)?(null!=t.start&&(o=Math.max(o,t.start)),null!=t.end&&(n=Math.min(n,t.end)),o>n?{start:null,end:null}:{start:o,end:n}):{start:null,end:null}}function Mt(e,t,o,n){const i=function(e,t,o,n){return`${e.map(e=>{const t=o[e.id],i=n[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,i?.start??"",i?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}(e,t,o,n),s=ut.get(i);if(s)return dt(s.slots,o,n);const a=Ce();for(const t of e)a[t.id]=xt(o[t.id],n[t.id]);const r=function(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,o)=>t[e.id].start-t[o.id].start||t[e.id].end-t[o.id].end||Oe(e.id,o.id)).map(e=>e.id)}(e,a),l=new Map(e.map(e=>[e.id,e])),c=new Map(e.map(e=>[e.id,e.group||void 0])),d=bt(t),u=function(e,t,o,n,i,s){const a=new Set,r=new Map(e.map(e=>[e,new Set])),l=new Map(e.map(e=>[e,new Set]));for(const e of n)a.add(ht(e.source,e.target)),r.get(e.target)?.add(e.source),l.get(e.source)?.add(e.target);const c=new Map,d=new Set,u=(e,t)=>{for(let o=0;e.length>o;o++)for(let n=o+1;e.length>n;n++){const i=ht(e[o],e[n]);t instanceof Map?t.set(i,[e[o],e[n]]):t.add(i)}};for(const e of l.values())u([...e],c);for(const e of r.values())u([...e],d);const g=new Set;for(const[e,[n,i]]of c)d.has(e)&&(ft(t[n],t[i])||ft(o[n],o[i])&&(g.add(n),g.add(i)));return{conflicts:(e,o)=>{const n=i.get(e),r=i.get(o);return null!=n&&null!=r&&n!==r||!(null!=n==(null!=r)||a.has(ht(e,o))||s.has(e)&&s.has(o)&&yt(e,o,s))||!!ft(t[e],t[o])||!(!g.has(e)&&!g.has(o))&&!a.has(ht(e,o))}}}(r,a,n,t,c,d),g=function(e,t,o=new Map){const n=[],i=[];for(const s of e){let e=n.findIndex(e=>e.every(e=>!t.conflicts(s,e))&&!vt(s,e,o));-1!==e||o.has(s)||(e=n.findIndex(e=>e.every(e=>!t.conflicts(s,e)))),-1===e&&(e=n.length,n.push([])),n[e].push(s),i.push(e)}return{assignment:i,slotCount:n.length}}(r,u,d),m=function(e,t,o,n){if(0===e.length||e.length>12||1>=n.slotCount)return n.assignment;const i=new Map(e.map((e,t)=>[e,t])),s=Array.from({length:e.length},()=>new Float64Array(e.length)),a=Array.from({length:e.length},()=>new Map),r=Array.from({length:e.length},()=>new Map),l=pt(o);for(const e of o){const t=i.get(e.source),o=i.get(e.target);if(null==t||null==o||t===o)continue;const n=kt(e,l);s[t][o]+=n,s[o][t]+=n,r[t].set(o,(r[t].get(o)??0)+n),a[o].set(t,(a[o].get(t)??0)+n)}const c=bt(o),d=e.map(e=>c.get(e)?.weight??0),u=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;e.length>t;t++)for(let o=t+1;e.length>o;o++){for(const[e,n]of a[t])u[t][o]+=Math.min(n,a[o].get(e)??0);for(const[e,n]of r[t])u[t][o]+=Math.min(n,r[o].get(e)??0);if(c.has(e[t])&&c.has(e[o])){const n=Math.min(d[t],d[o])||Math.max(d[t],d[o]);u[t][o]+=yt(e[t],e[o],c)?n:-n}u[o][t]=u[t][o]}let g=[...n.assignment],m=(t=>{let o=0,n=0;for(let i=0;e.length>i;i++)for(let a=i+1;e.length>a;a++)t[i]===t[a]&&(o+=s[i][a],n+=u[i][a]);return{flow:o,affinity:n}})(g),f=0;const h=Array(e.length).fill(-1),p=Array.from({length:n.slotCount},()=>[]),b=(o,i,a,r)=>{if(f>=75e3)return;if(o===e.length)return f++,void((a>m.flow||a===m.flow&&r>m.affinity||a===m.flow&&r===m.affinity&&function(e,t){for(let o=0;Math.min(e.length,t.length)>o;o++)if(e[o]!==t[o])return t[o]>e[o];return t.length>e.length}(h,g))&&(g=[...h],m={flow:a,affinity:r}));const l=Math.min(i+1,n.slotCount-1);for(let n=0;l>=n;n++){if(p[n].some(n=>t.conflicts(e[o],e[n])))continue;let l=0,c=0;for(const e of p[n])l+=s[o][e],c+=u[o][e];if(h[o]=n,p[n].push(o),b(o+1,Math.max(i,n),a+l,r+c),p[n].pop(),h[o]=-1,f>=75e3)return}};return h[0]=0,p[0].push(0),b(1,0,0,0),g}(r,u,t,{...g,assignment:wt(r,u,t,g)}),f=new Map,h=m.map(e=>(f.has(e)||f.set(e,f.size),f.get(e))),p=Array.from({length:f.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),b=Ce();r.forEach((e,t)=>{const o=h[t],n=p[o];n.occupants.push({id:e,end:a[e].end??-1/0});const i=l.get(e)?.group;i&&(n.group=i),b[e]=o});for(const t of[...e].sort((e,t)=>Oe(e.id,t.id)))null==b[t.id]&&(p[0].occupants.push({id:t.id,end:-1/0}),b[t.id]=0);for(const e of p){e.occupants.sort((e,t)=>(a[e.id].start??1/0)-(a[t.id].start??1/0)||Oe(e.id,t.id));for(const t of e.occupants){const n=o[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,n?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,n?.botPeak||0)}}const y={slots:p,slotByNode:b};return function(e,t){for(ut.has(e)&&ut.delete(e),ut.set(e,{slots:t.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),slotByNode:Object.assign(Ce(),t.slotByNode)});ut.size>12;){const e=ut.keys().next().value;if(null==e)break;ut.delete(e)}}(i,y),y}function St(e){return e.topMass+e.botMass}function Tt(e,t){const o=e.samples.filter(e=>e.t===t);if(o.length>0)return o.reduce((e,t)=>St(t)<St(e)?e:t,o[0]);let n=null;for(const o of e.samples){if(o.t>t)break;n=o}return n}function At(e,t,o,n,i,s,a=0){const r=new Map;for(const o of e){if(!o.group||!t[o.id])continue;const e=r.get(o.group)??[];e.push(o),r.set(o.group,e)}if(0===r.size||0>=s)return t;const l=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]));for(const[e,c]of r){const r=o.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===r.length)continue;const d=r[0].slot,u=r.at(-1).slot,g=i[d.occupants[0]?.id],m=i[u.occupants[0]?.id];if(!Number.isFinite(g)||!Number.isFinite(m))continue;const f=(g-d.peak.topPeak*s+(m+u.peak.botPeak*s))/2,h=[...new Set(c.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),p=new Map;for(const e of c)p.set(e.id,new Map);for(const e of h){const o=new Map;for(const i of c){const s=Tt(t[i.id],e);if(!s||1e-9>=St(s))continue;const a=n[i.id];if(null==a)continue;const r=o.get(a)??[];r.push({node:i,sample:s}),o.set(a,r)}const r=[...o].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>St(e)))}));if(0===r.length)continue;let l=f-(r.reduce((e,t)=>e+t.mass,0)*s+Math.max(0,a)*Math.max(0,r.length-1))/2;for(const t of r){for(const{node:o,sample:n}of t.active){const t=(l-i[o.id])/s+n.topMass-(n.boundaryOffset??0);p.get(o.id).set(e,t)}l+=t.mass*s+Math.max(0,a)}}for(const e of c){const o=t[e.id],n=l[e.id],i=p.get(e.id),s=[];for(const e of h){const t=i.get(e),n=o.samples.filter(t=>t.t===e);if(n.length>0){s.push(...n.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}})));continue}const a=Tt(o,e);null!=t&&a&&St(a)>1e-9&&s.push({...a,t:e,boundaryOffset:(a.boundaryOffset??0)+t})}n.samples=s,n.localAttachments=new Map([...o.localAttachments].map(([e,t])=>{const o=i.get(t.time);return[e,{...t,...null!=o?{boundaryOffset:(t.boundaryOffset??0)+o}:{}}]}))}}return l}function It(e,t,o,n,i){const{plotH:s,padding:a,valueScale:r,packing:l,laneOrder:c,lifetimeMode:d="half",lanePlacement:u="stack",groupPadding:g=0,ribbonLane:m="both",domain:f}=i,h=Ce(),p=Ce();for(const t of e)h[t.id]=o[t.id].topPeak||0,p[t.id]=o[t.id].botPeak||0;const b="half"===d,y=Ce();for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,o=Array.isArray(t.xExtent)?t.xExtent[1]:null;let i=null!=e&&Number.isFinite(e)?e:1/0,s=null!=o&&Number.isFinite(o)?o:-1/0;for(const e of n.outgoing[t.id]){i>e.startTime&&(i=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&i>e.systemInTime&&(i=e.systemInTime);const t=b?(e.startTime+e.endTime)/2:e.endTime;t>s&&(s=t)}for(const e of n.incoming[t.id]){const t=b?(e.startTime+e.endTime)/2:e.startTime;i>t&&(i=t),e.endTime>s&&(s=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>s&&(s=e.systemOutTime)}y[t.id]={start:Number.isFinite(i)?i:null,end:Number.isFinite(s)?s:null}}let v=Ce(),k=[],w=[];if(i.frozenSlots){const e=dt(i.frozenSlots,o,y);k=e.slots,v=e.slotByNode,w=k.map(Ne)}else if("reuse"===l){const n=Mt(e,t,o,y);k=n.slots,v=n.slotByNode}else e.forEach((e,t)=>{k.push({occupants:[{id:e.id,end:y[e.id]?.end??-1/0}],peak:{topPeak:h[e.id],botPeak:p[e.id]},...e.group?{group:e.group}:{}}),v[e.id]=t});tt(k,v),0===w.length&&(w=k.map(Ne));let x=null;i.frozenSlots||(i.fixedSlotOrder?function(e,t,o){const n=new Map(o.map((e,t)=>[e,t]));Qe(e,t,[...e].sort((e,t)=>(n.get(Ne(e))??1/0)-(n.get(Ne(t))??1/0)||Oe(Ne(e),Ne(t))))}(k,v,i.fixedSlotOrder):i.runOrdering&&c&&"insertion"!==c&&(x=ct(e,t,o,y,k,v,{plotH:s,padding:a,valueScale:r,groupPadding:g,laneOrder:c,ribbonLane:m,domain:f}))),tt(k,v);const M=Ee(e,t,o,k,v,{plotH:s,padding:a,valueScale:r,stackValueScale:i.stackValueScale,lanePlacement:u,groupPadding:g}),S=0===k.length?0:k[0].peak.topPeak+M.adjacentClearance.reduce((e,t)=>e+t,0)+k[k.length-1].peak.botPeak,T=x?.before.crossings??null,A=x?.after.crossings??null,I=x?.before.weightedLength??null,P=x?.after.weightedLength??null;return{effectiveSlotsHeight:S,centerlines:M.centerlines,laneLifetime:y,slots:k,slotByNode:v,slotCenter:M.slotCenter,stackCenter:M.stackCenter,verticalUtilization:M.verticalUtilization,selectedSlotOrder:k.map(Ne),initialSlotOrder:w,ordering:x,crossingsBefore:T,crossingsAfter:A,lengthBefore:I,lengthAfter:P}}import{forwardRef as Pt,useMemo as Ct,useRef as Ot,useCallback as Nt,useEffect as Lt}from"react";function Bt(e,t,o,n="horizontal"){return"vertical"===n?{top:e?38:t?28:16,right:24,bottom:24,left:o?72:24}:{top:e?30:t?24:8,right:80,bottom:o?28:8,left:80}}import{Fragment as Ht,jsx as Dt,jsxs as Et}from"react/jsx-runtime";var Ft="var(--semiotic-grid, #94a3b8)",Rt="var(--semiotic-text-secondary, #475569)",zt="var(--semiotic-text-secondary, #94a3b8)";import{useEffect as Wt,useMemo as _t,useRef as $t,useState as jt}from"react";import{scaleTime as Xt}from"d3-scale";import{scaleTime as Yt}from"d3-scale";function Gt(e,t,o,n,i,s,a,r,l={}){const c=i,d=e=>r?Math.max(r[0],Math.min(r[1],e)):e;let u=s(d(e.time));const g=s(d(o.time)),m=e.value*c,f=o.value*c,h=t+(e.boundaryOffset??0)*c,p=n+(o.boundaryOffset??0)*c,b=e.sideMassBefore*c,y=o.sideMassAfter*c;let v,k,w,x;"top"===e.side?(v=h-b,k=v+m):(k=h+b,v=k-m),"top"===o.side?(w=p-y,x=w+f):(x=p+y,w=x-f);const M=l.sourceRunwayStart,S=l.minRun,T=Math.abs((w+x)/2-(v+k)/2),A=g-u,I="number"==typeof M&&Number.isFinite(M),P="number"==typeof S&&Number.isFinite(S)&&S>0;if(I&&T>1e-9&&A>0&&("auto"===S||P)){const t="source"===a?.85:"target"===a?.15:.5,o="auto"===S?Math.min(144,Math.sqrt(8*T/(1.5*Math.min(t*t,(1-t)*(1-t))))):S;if(o>A){const t=s(d(Math.min(M,e.time)));Number.isFinite(t)&&(u=Math.min(u,Math.max(Math.min(u,t),g-o)))}}const C="source"===a?u+.85*(g-u):"target"===a?u+.15*(g-u):(u+g)/2;return{sx:u,sTop:v,sBot:k,tx:g,tTop:w,tBot:x,cp1X:C,cp2X:C}}function qt(e){return Math.max(18,11*e.length*.58)}function Vt(e){const t=1.22*qt(e.labelText)+4;return"start"===e.labelAnchor?[e.labelX,e.labelX+t]:"middle"===e.labelAnchor?[e.labelX-t/2,e.labelX+t/2]:[e.labelX-t,e.labelX]}function Ut(e,t){const o=e.labelX-qt(e.labelText),n=t.labelX-qt(t.labelText);return t.labelX+3>=o&&e.labelX+3>=n}var Qt=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi;function Kt(e){return e.replace(Qt,(e,t,o)=>`${o},${t}`)}function Jt(e){if(!e)return;const t=e=>({x:e.y,y:e.x});return{...e,...e.points&&{points:e.points.map(t)},...e.segments&&{segments:e.segments.map(e=>e.map(t))}}}function Zt(e){return{...e,pathD:Kt(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function eo(e){const{nodes:t,edges:o,domain:n,plotW:s,plotH:a,ribbonLane:r,ribbonMinRun:l=0,edgeOpacity:c,colorOf:d,layoutOpts:u,orientation:g="horizontal",showLabels:m=!0,labelPriorityAccessor:f,maxLabels:h,selectionDatum:p="raw",styleRules:v,colorBy:k,valueAccessor:w,usageMode:x="static"}=e,M="vertical"===g?a:s,S="vertical"===g?s:a,T=be(t,o,n,{usageMode:x}),{fatal:A,warnings:I}=function(e){const t=[],o=[];for(const n of e)"fatal"===pe(n)?t.push(n):o.push(n);return{fatal:t,warnings:o}}(T),P=function(e,t,o="static"){if("strip"!==fe(o).invalidSystemTime)return e;const n=new Set(t.filter(e=>"invalid-system-time"===e.kind).map(e=>e.id));return 0===n.size?e:e.map(e=>{if(!n.has(e.id))return e;const t={...e};return null==t.systemInTime||Number.isFinite(t.systemInTime)||delete t.systemInTime,null==t.systemOutTime||Number.isFinite(t.systemOutTime)||delete t.systemOutTime,t})}(o,T,x),O=Yt().domain(n).range([0,M]);if(A.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==m},issues:A,warnings:I,xScale:O};const N=function(e,t,o){const{plotH:n,pairing:i="temporal",packing:s="reuse",laneOrder:a="crossing-min",lifetimeMode:r="half",maxValueScale:l,lanePlacement:c="stack",nodeSizing:d="temporal",groupPadding:u=0,ribbonLane:g="both",domain:m}=o,f=Number.isFinite(u)?Math.max(0,u):0,h=function(e,t){const o=Ce(),n=Ce();for(const t of e)o[t.id]=[],n[t.id]=[];for(const e of t)n[e.source]&&n[e.source].push(e),o[e.target]&&o[e.target].push(e);return{incoming:o,outgoing:n}}(e,t),p=function(e,t,o,n="temporal"){const i="temporal"===n?(e,t)=>e.endTime-t.endTime||Oe(e.id,t.id):(e,t)=>t.value-e.value||Oe(e.id,t.id),s="temporal"===n?(e,t)=>e.startTime-t.startTime||Oe(e.id,t.id):(e,t)=>t.value-e.value||Oe(e.id,t.id),a=new Map;for(const e of t)a.set(e.id,{});const r=(e,t)=>{const o=new Map;for(const n of e){const e=n[t];o.has(e)||o.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const i=o.get(e);i.edges.push(n),i.total+=n.value,i.earliestStart=Math.min(i.earliestStart,n.startTime),i.latestEnd=Math.max(i.latestEnd,n.endTime)}const a=[...o.values()];a.sort("temporal"===n?(e,o)=>"target"===t?e.earliestStart-o.earliestStart||Oe(e.partner,o.partner):e.latestEnd-o.latestEnd||Oe(e.partner,o.partner):(e,t)=>t.total-e.total||Oe(e.partner,t.partner));for(const e of a)e.edges.sort("target"===t?s:i);return a};for(const t of e){const e=o.outgoing[t.id],n=o.incoming[t.id];if(0===n.length)r(e,"target").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).sourceSide=o});else if(0===e.length)r(n,"source").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).targetSide=o});else{const t=r(n,"source"),o=r(e,"target"),i=Math.max(t.length,o.length);for(let e=0;i>e;e++){const n=e%2==0?"top":"bot";if(t[e])for(const o of t[e].edges)a.get(o.id).targetSide=n;if(o[e])for(const t of o[e].edges)a.get(t.id).sourceSide=n}}}return a}(e,t,h,i);let b=Ce();for(const t of e)b[t.id]=Ve(t,h,p,void 0,d);const y=It(e,t,b,h,{plotH:n,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:r,runOrdering:!0,lanePlacement:"stack",groupPadding:f,ribbonLane:g,domain:m}),v=y.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),k=new Set;for(const e of t){const t=y.slotByNode[e.source],o=y.slotByNode[e.target];if(void 0===t||void 0===o)continue;const n=p.get(e.id);t!==o?t>o?(n.sourceSide="top",n.targetSide="bot"):(n.sourceSide="bot",n.targetSide="top"):(k.add(e.id),n.sourceSide="bot",n.targetSide="bot")}for(const t of e){const e=h.outgoing[t.id],o=h.incoming[t.id],n=new Set(e.map(e=>p.get(e.id).sourceSide)),i=new Set(o.map(e=>p.get(e.id).targetSide));if(1===n.size&&o.length>0){const e=[...n][0];for(const t of o)y.slotByNode[t.source]===y.slotByNode[t.target]&&(p.get(t.id).targetSide=e)}if(1===i.size&&e.length>0){const t=[...i][0];for(const o of e)y.slotByNode[o.source]===y.slotByNode[o.target]&&(p.get(o.id).sourceSide=t)}}!function(e,t,o){const n=new Map,i=[];for(const t of e)i.push({time:t.startTime,kind:"out",edge:t}),i.push({time:t.endTime,kind:"in",edge:t});i.sort((e,t)=>e.time-t.time||(e.kind===t.kind?0:"in"===e.kind?-1:1)||("out"===e.kind?t.edge.value-e.edge.value:0)||Oe(e.edge.id,t.edge.id));const s=e=>{let t=n.get(e);return t||(t={top:0,bot:0},n.set(e,t)),t},a=(e,t,o)=>{const n="top"===t?"bot":"top",i=Math.min(o,e[t]);e[t]-=i;const s=o-i;s>0&&(e[n]=Math.max(0,e[n]-s))};for(const e of i){const{edge:n}=e;if("in"===e.kind){const e=t.get(n.id)?.targetSide??"bot";s(n.target)[e]+=n.value;continue}const i=s(n.source),r=t.get(n.id);let l=r.sourceSide??"bot";if(o[n.source]===o[n.target]){const e=i.top>=n.value,t=i.bot>=n.value;e!==t?l=e?"top":"bot":e||t||i.top===i.bot||(l=i.top>i.bot?"top":"bot"),r.sourceSide=l,r.targetSide=l}a(i,l,n.value)}}(t,p,y.slotByNode),function(e,t,o,n){for(const i of e){const e=t.incoming[i.id],s=t.outgoing[i.id];if(0===e.length||0===s.length)continue;const a=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===o.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of s)"top"===o.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},r=(e,t)=>{const i=a(),r="top"===e?i.outTop-i.inTop:i.outBot-i.inBot,l="top"===t?i.inTop-i.outTop:i.inBot-i.outBot;if(0>=r||0>=l)return!1;const c=Math.min(r,l),d=s.filter(t=>!n.has(t.id)&&o.get(t.id).sourceSide===e&&c>=t.value).sort((e,t)=>t.value-e.value||Oe(e.id,t.id));return 0!==d.length&&(o.get(d[0].id).sourceSide=t,!0)};let l=s.length+1;for(;l-- >0&&(r("top","bot")||r("bot","top")););}}(e,h,p,k),b=Ce();for(const t of e)b[t.id]=Ve(t,h,p,void 0,d);const w=It(e,t,b,h,{plotH:n,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:r,frozenSlots:v,lanePlacement:"stack",groupPadding:f,ribbonLane:g,domain:m}),x=w.effectiveSlotsHeight??w.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),M=w.slots.slice(0,-1).reduce((e,t,o)=>e+(null!=t.group&&t.group===w.slots[o+1].group?1:0),0),S=Math.max(1,w.slots.length+1-M),T=Math.min(12,Math.max(0,.35*n-M*f)/S),A=2*T+Le(w.slots,T,f).reduce((e,t)=>e+t,0),I=x>0?Math.max(0,(n-A)/x):1,P=Number.isFinite(l)&&l>0?Math.min(I,l):I;let C=It(e,t,b,h,{plotH:n,padding:T,valueScale:P,packing:s,laneOrder:a,lifetimeMode:r,frozenSlots:v,lanePlacement:c,groupPadding:f,ribbonLane:g,domain:m,stackValueScale:I});const O=Number.isFinite(l)&&l>0&&I>l+1e-12;if("insertion"!==a&&("hug"===c||O)&&C.slots.length>1&&(ct(e,t,b,C.laneLifetime,C.slots,C.slotByNode,{plotH:n,padding:T,valueScale:P,groupPadding:f,laneOrder:a,ribbonLane:g,domain:m,lanePlacement:c,mode:"geometry-refine"}),C=It(e,t,b,h,{plotH:n,padding:T,valueScale:P,packing:s,laneOrder:a,lifetimeMode:r,frozenSlots:C.slots,fixedSlotOrder:C.slots.map(Ne),lanePlacement:c,groupPadding:f,ribbonLane:g,domain:m,stackValueScale:I})),function(e,t){const o=(e,o)=>{for(const n of e){const e=new Map;for(const i of n){const n=`${("out"===o?t.get(i.id)?.sourceSide:t.get(i.id)?.targetSide)??""}\0${"out"===o?i.startTime:i.endTime}`,s="out"===o?`${i.target}\0${i.endTime}`:`${i.source}\0${i.startTime}`,a=e.get(n);if(null!=a&&a!==s)return!0;e.set(n,s)}}return!1};return o(Object.values(e.outgoing),"out")||o(Object.values(e.incoming),"in")}(h,p)){const o=function(e,t,o,n){const i=new Map;for(const s of e){const e=t[s.source]?.localAttachments.get(s.id),a=t[s.target]?.localAttachments.get(s.id),r=o[s.source],l=o[s.target];if(!(e&&a&&Number.isFinite(r)&&Number.isFinite(l)))continue;const c=qe(e,r,n),d=qe(a,l,n);i.set(s.id,{source:(c[0]+c[1])/2,target:(d[0]+d[1])/2})}return i}(t,b,C.centerlines,P);b=Ce();for(const t of e)b[t.id]=Ve(t,h,p,o,d);C=It(e,t,b,h,{plotH:n,padding:T,valueScale:P,packing:s,laneOrder:a,lifetimeMode:r,frozenSlots:C.slots,fixedSlotOrder:C.slots.map(Ne),lanePlacement:c,groupPadding:f,ribbonLane:g,domain:m,stackValueScale:I})}const N=new Map(y.initialSlotOrder.map((e,t)=>[e,t])),L=[...C.slots].sort((e,t)=>(N.get(Ne(e))??1/0)-(N.get(Ne(t))??1/0)||Oe(Ne(e),Ne(t))),B=Ce();L.forEach((e,t)=>{for(const o of e.occupants)B[o.id]=t});const H=Ee(e,t,b,L,B,{plotH:n,padding:T,valueScale:P,stackValueScale:I,lanePlacement:"stack",groupPadding:f}),D=At(e,b,L,B,H.centerlines,P,f),E=Xe(nt(B,t),it(B,t),t,D,L,B,H.centerlines,C.laneLifetime,P,H.verticalUtilization,g,m);b=At(e,b,C.slots,C.slotByNode,C.centerlines,P,f);const F=Xe(nt(C.slotByNode,t),it(C.slotByNode,t),t,b,C.slots,C.slotByNode,C.centerlines,C.laneLifetime,P,C.verticalUtilization,g,m);return{nodeData:b,sides:p,valueScale:P,padding:T,compressedPadding:12>T,centerlines:C.centerlines,laneLifetime:C.laneLifetime,slots:C.slots,slotByNode:C.slotByNode,crossingsBefore:"insertion"===a?null:E.crossings,crossingsAfter:"insertion"===a?null:F.crossings,lengthBefore:"insertion"===a?null:E.weightedLength,lengthAfter:"insertion"===a?null:F.weightedLength,layoutQualityBefore:E,layoutQuality:F}}(t,P,{plotH:S,...u,ribbonLane:r,domain:n}),{centerlines:L,nodeData:B,valueScale:H}=N,D=b(k,w),E=[],F=[],R=0===l?new Map:function(e,t,o){const n=new Set(t.map(e=>e.target)),i=new Map(e.map(e=>[e.id,e])),s=new Map;for(const e of t){if(n.has(e.source))continue;const t=s.get(e.source)??[];t.push(e),s.set(e.source,t)}const a=new Map;for(const t of e){if(!t.group)continue;const e=a.get(t.group)??[];e.push(t),a.set(t.group,e)}const r=new Set;for(const[e,t]of a){const o=t.flatMap(e=>s.get(e.id)??[]),i=new Set(o.map(e=>e.startTime));o.length>0&&1===i.size&&t.every(e=>{const t=e.xExtent?.[0],i=o[0].startTime;return!n.has(e.id)&&(s.get(e.id)?.length??0)>0&&Number.isFinite(t)&&i>t})&&r.add(e)}const l=new Map;for(const[e,t]of s){const n=i.get(e);if(n?.group&&!r.has(n.group))continue;const s=n?.xExtent?.[0],a=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),c=a[0]?.startTime-1;let d=null;for(let e=0;a.length>e;){const t=a[e].startTime;let n=e+1;for(;a.length>n&&a[n].startTime===t;)n++;for(let t=e;n>t;t++){const e=a[t],n=Number.isFinite(s)&&e.startTime>s,i=Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime;if(!n&&!i)continue;let r=o[0];n&&(r=Math.max(r,s)),i&&(r=Math.max(r,e.systemInTime)),!n&&i&&Number.isFinite(c)&&(r=Math.max(r,c)),null!=d&&(r=Math.max(r,d)),e.startTime>r&&l.set(e.id,r)}d=t,e=n}}for(const[e,t]of a){if(!r.has(e))continue;const o=t.flatMap(e=>s.get(e.id)??[]);if(!o.every(e=>l.has(e.id))){for(const e of o)l.delete(e.id);continue}const n=Math.max(...o.map(e=>l.get(e.id)));for(const e of o)l.set(e.id,n)}return l}(t,P,n),z=new Map(t.filter(e=>e.group).map(e=>[e.id,e.group])),W=new Map;for(const e of P){const t=B[e.source]?.localAttachments.get(e.id),o=B[e.target]?.localAttachments.get(e.id);t&&o&&W.set(e.id,Gt(t,L[e.source],o,L[e.target],H,O,r,n,{minRun:l,sourceRunwayStart:R.get(e.id)}))}const _=function(e,t,o,n,i,s){const a=new Map(t),r=new Map;for(const t of e){const e=s?.get(t.source),o=null==e?"node:"+t.source:"group:"+e,n=r.get(o)??new Map,i=n.get(t.startTime)??[];i.push(t),n.set(t.startTime,i),r.set(o,n)}for(const e of r.values())for(const[s,r]of e){if(!r.some(e=>o.has(e.id)))continue;const e=r.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;const l=n(s),c=Math.min(...e.map(e=>e.sx));if(c>=l-1e-9)continue;const d=Math.max(...r.map(e=>{const t=o.get(e.id);return null==t?l:Math.min(l,n(t))})),u=Math.min(l,Math.max(c,d));for(const e of r){const o=t.get(e.id),n=u+(o.tx-u)*("source"===i?.85:"target"===i?.15:.5);a.set(e.id,{...o,sx:u,cp1X:n,cp2X:n})}}return a}(P,W,R,O,r,z),$=function(e,t,o,n,i){const s=new Map;for(const a of e){if(!o.has(a.id))continue;const e=t.get(a.id);if(!e||e.sx>=n(a.startTime)-1e-9)continue;const r=i(e.sx);Number.isFinite(r)&&a.startTime>r&&s.set(a.id,r)}return s}(P,_,R,O,e=>n[0]+e/M*(n[1]-n[0])),j=function(e,t,o){const n=new Map,i=new Map;for(const[e,t]of o??[]){const o=i.get(t)??[];o.push(e),i.set(t,o)}for(const s of e){const e=t.get(s.id);if(null==e||!Number.isFinite(e)||e>=s.startTime)continue;const a=o?.get(s.source),r=null==a?[s.source]:i.get(a)??[s.source];for(const t of r){const o=n.get(t)??new Map,i=o.get(s.startTime);o.set(s.startTime,null==i?e:Math.min(i,e)),n.set(t,o)}}return n}(P,$,z);t.forEach((e,t)=>{const o=B[e.id];if(!o||0===o.samples.length)return;const i=(s=o.samples,(a=j.get(e.id))&&0!==a.size?s.map(e=>{const t=a.get(e.t);return null==t?e:{...e,t:t}}):s);var s,a;const r=function(e,t,o,n,i){if(0===e.length)return null;const s=Ge(e,i),a=e=>t+(s[e].boundaryOffset??0)*o,r=e=>a(e)-s[e].topMass*o,l=e=>a(e)+s[e].botMass*o;let c=`M${n(s[0].t)},${r(0)}`;for(let e=1;s.length>e;e++)c+=` L${n(s[e].t)},${r(e)}`;c+=` L${n(s[s.length-1].t)},${l(s.length-1)}`;for(let e=s.length-2;e>=0;e--)c+=` L${n(s[e].t)},${l(e)}`;return c+" Z"}(i,L[e.id],H,O,n);if(!r)return;const l=Ge(i,n),c=l.find(e=>e.topMass+e.botMass>0)||l[0],u=L[e.id]+(c.botMass-c.topMass+2*(c.boundaryOffset??0))*H/2;let m,f,h=d(e.id,t),p=h,b=.5;const k=e.__raw??e;if(v&&v.length>0){const e=y(k,v,D(k));"string"==typeof e.fill?h=e.fill:null!=e.fill&&C(e.fill)&&(f=e.fill,h=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:h),"string"==typeof e.stroke&&(p=e.stroke),"number"==typeof e.strokeWidth&&(b=e.strokeWidth),"number"==typeof e.fillOpacity&&(m=e.fillOpacity),"number"==typeof e.opacity&&null==m&&(m=e.opacity)}const w=function(e,t,o,n,i,s){const a=o.nodeData[e];if(!a||0===a.samples.length)return[];const r=o.valueScale,l=o.centerlines[e],c=Ge(a.samples,i),d=c.find(e=>e.topMass+e.botMass>0)||c[0],u=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],g=n(d.t),m=n(u.t),f=e=>n(Ye(e,i)),h=[],p=(e,t,o,n)=>`M${e},${t} L${o},${t} L${o},${n} L${e},${n} Z`;for(const o of t){if(o.source===e&&null!=o.systemInTime&&Number.isFinite(o.systemInTime)){const e=a.localAttachments.get(o.id),t=s?.get(o.id)??o.startTime;if(e&&"out"===e.kind&&t>o.systemInTime){const n=f(o.systemInTime),s=f(t),a=null!=i&&i[0]>o.systemInTime,c=a?n:n-20,d=a?Math.min(s,n+20):n,u=Math.max(g,c);if(s>u){const[t,o]=qe(e,l,r);h.push({pathD:p(u,t,s,o),x0:c,x1:d,from:0,to:1})}}}if(o.target===e&&null!=o.systemOutTime&&Number.isFinite(o.systemOutTime)){const e=a.localAttachments.get(o.id);if(e&&"in"===e.kind&&o.systemOutTime>o.endTime){const t=f(o.systemOutTime),n=f(o.endTime),i=t+20,s=Math.min(m,i);if(s>n){const[o,a]=qe(e,l,r);h.push({pathD:p(n,o,s,a),x0:t,x1:i,from:1,to:0})}}}}return h}(e.id,P,N,O,n,$);E.push({id:e.id,pathD:r,fill:h,stroke:p,strokeWidth:b,...null!=m&&{fillOpacity:m},...f&&{hatchFill:f},...w.length>0&&{gradientStubs:w},rawDatum:k,labelX:O("vertical"===g&&e.xExtent?e.xExtent[0]:c.t)-4,labelY:u,labelText:e.label??e.id})});const X=new Map;t.forEach((e,t)=>X.set(e.id,t)),P.forEach(e=>{const t=_.get(e.id);if(!t)return;const o=X.get(e.source)??0,n=d(e.source,o),{pathD:s,bezier:a}=i(t),r=e.__raw??e,l="function"==typeof c?Number(c(r)):c,u=Number.isFinite(l)?Math.max(0,Math.min(1,l)):.35;F.push({id:e.id,pathD:s,fill:n,opacity:u,rawDatum:r,bezier:a})});const Y=function(e,t,o){const n=e.map(e=>({...e})),i=new Map;for(const e of n){const o=t[e.id];if(null==o)continue;const n=i.get(o)??[];n.push(e),i.set(o,n)}const s=e=>{if(2>e.length)return;const t=e.reduce((e,t)=>e+t.labelY,0)/e.length,n=(e.length-1)/2;e.forEach((e,i)=>{e.labelY=Math.max(8,Math.min(o-8,t+16*(i-n)))})};for(const e of i.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],o=-1/0;for(const n of e){const e=n.labelX-qt(n.labelText);t.length>0&&e>o+3&&(s(t),t=[],o=-1/0),t.push(n),o=Math.max(o,n.labelX)}s(t)}return function(e,t){const o=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;3>e;e+=1){for(let e=0;o.length>e;e+=1){let t=8;for(let n=0;e>n;n+=1)Ut(o[e],o[n])&&(t=Math.max(t,o[n].labelY+16));o[e].labelY=Math.max(o[e].labelY,t)}for(let e=o.length-1;e>=0;e-=1){let n=t-8;for(let t=e+1;o.length>t;t+=1)Ut(o[e],o[t])&&(n=Math.min(n,o[t].labelY-16));o[e].labelY=Math.min(o[e].labelY,n)}}}(n,o),n}(E,N.slotByNode,S).map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:Kt(e.pathD),gradientStubs:e.gradientStubs?.map(Zt),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}(e,g)),G="vertical"===g?function(e,t,o){const n=e.map(e=>({...e}));for(const e of n){const o=1.22*qt(e.labelText)+4;e.labelX=t-4>o?Math.max(o/2+2,Math.min(t-o/2-2,e.labelX)):t/2}const i=[],s=[...n].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(const e of s){const t=i[i.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?i.push([e]):t.push(e)}for(const e of i){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));const t=[],n=new Map;for(const o of e){const[e,i]=Vt(o);let s=t.findIndex(t=>e>t+8);-1===s&&(s=t.length),t[s]=i,n.set(o,s)}const i=e.reduce((e,t)=>e+t.labelY,0)/e.length,s=14*t.length+8>i;for(const t of e){const e=n.get(t)??0;t.labelY=s?Math.min(o-8,12+14*e):Math.max(8,i-14*e)}}return n}(Y,s,a):Y,q=new Map;if(null!=f)for(const e of t){const t=e.__raw??e,o="function"==typeof f?f(t):Number(t[f]);Number.isFinite(o)&&q.set(e.id,o)}const V=function(e,t,o,n,i={}){if(!1===n)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===n)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let s=Math.max(4,Math.min(e.length,Math.floor(Math.max(1,t*o)/14e3)));Number.isFinite(i.maxLabels)&&i.maxLabels>=0&&(s=Math.min(s,Math.floor(i.maxLabels)));const a=e.map((e,t)=>{const o=i.priorityById?.get(e.id),n=Math.abs(e.labelY);return{band:e,index:t,score:null!=o&&Number.isFinite(o)?1e6*o+qt(e.labelText):qt(e.labelText)+.01*n}}).filter(e=>e.band.labelText.trim().length>0).sort((e,t)=>t.score-e.score||e.index-t.index||e.band.id.localeCompare(t.band.id)),r=new Set(a.slice(0,s).map(e=>e.band.id));return e.map(e=>r.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}(G,s,a,m,{...q.size>0&&{priorityById:q},...null!=h&&{maxLabels:h}});return{layout:N,layoutConfig:{bands:V,ribbons:F.map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:Kt(e.pathD),bezier:Jt(e.bezier)}}(e,g)),showLabels:!1!==m,selectionDatum:p},issues:[],warnings:I,xScale:O}}import{scaleTime as to}from"d3-scale";function oo(e,t,o,n="reuse",i="crossing-min",s=5e4){return"sync"!==e&&("worker"===e||function(e,t,o="reuse",n="crossing-min"){return e*e*("reuse"===o?80:1)+t*t*(n&&"insertion"!==n?40:1)+10*(e+t)}(t,o,n,i)>=s)}function no(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function io(e){if(!e)return null;const t=e.sides,o=t instanceof Map?t:new Map(Array.isArray(t)?t:[]);return{...e,sides:o}}var so=class{constructor(e=function(){const e="string"==typeof import.meta.url&&import.meta.url?new URL("./processSankeyLayoutWorker.js",import.meta.url):c("processSankeyLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-process-sankey-layout"})}()){this.session=new o({name:"ProcessSankey layout",createWorker:()=>e,parseMessage:e=>{const t=e,{requestId:o,error:n}=r(t);return n?{requestId:o,ok:!1,error:a(n)}:{requestId:o,ok:!0,payload:{layout:io(t.layout),layoutConfig:t.layoutConfig??{bands:[],ribbons:[],showLabels:!0},issues:t.issues??[],warnings:t.warnings??[],domain:t.domain??[0,1],timelineExtent:t.timelineExtent??0}}}})}get isDead(){return this.session.isDead}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},ao=s(()=>new so);function ro(e){if(function(e){if(!e||0===e.length)return!1;for(const t of e){if("function"==typeof t.when)return!0;if("function"==typeof t.style)return!0}return!1}(e.styleRules))return!0;if("function"==typeof e.edgeOpacity)return!0;if("function"==typeof e.labelPriorityAccessor)return!0;if(e.styleRules&&e.styleRules.length>0){if("function"==typeof e.colorBy)return!0;if("function"==typeof e.valueAccessor)return!0}return!1}function lo(e){if(null!=e&&"object"==typeof e){try{if("function"==typeof structuredClone)return structuredClone(e)}catch{}try{return JSON.parse(JSON.stringify(e))}catch{return}}}function co(e){const t=lo(e.__raw);return{id:e.id,...null!=e.label&&{label:e.label},...null!=e.group&&{group:e.group},...null!=e.xExtent&&{xExtent:e.xExtent},...null!=t&&{__raw:t}}}function uo(e){const t=lo(e.__raw);return{id:e.id,source:e.source,target:e.target,value:e.value,startTime:e.startTime,endTime:e.endTime,...null!=e.systemInTime&&{systemInTime:e.systemInTime},...null!=e.systemOutTime&&{systemOutTime:e.systemOutTime},...null!=t&&{__raw:t}}}var go=(e,t)=>({layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:[],warnings:[],xScale:Xt().domain(e).range([0,t])});function mo(e,t){const o=X(),{execution:n="auto",workerThreshold:i,colorById:s,fallbackPalette:a,rawNodeById:r,rawEdgeById:l}=t,c=_t(()=>Object.keys(s).sort().map(e=>`${e}:${s[e]}`).join("|"),[s]),d=_t(()=>e?[e.nodes,e.edges,e.plotW,e.plotH,e.orientation??"horizontal",e.ribbonLane,(e.ribbonMinRun??0)+"",e.edgeOpacity,(e.showLabels??!0)+"",e.layoutOpts.pairing??"temporal",e.layoutOpts.packing??"reuse",e.layoutOpts.laneOrder??"crossing-min",e.layoutOpts.lifetimeMode??"half",e.layoutOpts.maxValueScale??"",e.layoutOpts.lanePlacement??"stack",e.layoutOpts.nodeSizing??"temporal",e.layoutOpts.groupPadding??0,e.domain[0],e.domain[1],e.styleRules,c]:"null",[e,c]),u=!!e&&!o&&function(e,t,o){return"undefined"!=typeof window&&!!no()&&!ro(e)&&oo(t,e.nodes.length,e.edges.length,e.layoutOpts.packing??"reuse",e.layoutOpts.laneOrder??"crossing-min",o)}(e,n,i),g=_t(()=>e?u?null:eo(e):go([0,1],1),[d,u,e]),m=$t(o),[f,h]=jt(()=>e?o?{...eo(e),status:"ready",error:null}:u?{...go(e.domain,"vertical"===e.orientation?e.plotH:e.plotW),status:"pending",error:null}:{...eo(e),status:"ready",error:null}:{...go([0,1],1),status:"ready",error:null});return Wt(()=>{if(m.current)return void(m.current=!1);if(!e||!u)return;const t=new AbortController;return h(e=>({...e,status:"pending",error:null})),async function(e,t){const{execution:o="auto",workerThreshold:n,signal:i,colorById:s,fallbackPalette:a=["#475569"],rawNodeById:r=new Map,rawEdgeById:l=new Map}=t,c=e.layoutOpts.packing??"reuse",d=e.layoutOpts.laneOrder??"crossing-min";if(!no()||ro(e)||!oo(o,e.nodes.length,e.edges.length,c,d,n))return eo(e);try{const t=await function(e,t){return no()?ao.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(function(e,t,o){return{input:{nodes:e.nodes.map(co),edges:e.edges.map(uo),domain:e.domain,plotW:e.plotW,plotH:e.plotH,orientation:e.orientation,ribbonLane:e.ribbonLane,ribbonMinRun:e.ribbonMinRun,edgeOpacity:"number"==typeof e.edgeOpacity?e.edgeOpacity:.35,layoutOpts:{...e.layoutOpts},showLabels:e.showLabels,..."string"==typeof e.labelPriorityAccessor&&{labelPriorityAccessor:e.labelPriorityAccessor},...null!=e.maxLabels&&{maxLabels:e.maxLabels},...null!=e.selectionDatum&&{selectionDatum:e.selectionDatum},...null!=e.usageMode&&{usageMode:e.usageMode},styleRules:e.styleRules,colorBy:"string"==typeof e.colorBy?e.colorBy:void 0,valueAccessor:"string"==typeof e.valueAccessor?e.valueAccessor:void 0},colorById:t,fallbackPalette:o}}(e,s,a),i);return function(e,t,o){const n=(e.layoutConfig.bands??[]).map(e=>({...e,rawDatum:t.get(e.id)??{id:e.id}})),i=(e.layoutConfig.ribbons??[]).map(e=>({...e,rawDatum:o.get(e.id)??{id:e.id}})),s=to().domain(e.domain).range([0,e.timelineExtent]);return{layout:e.layout,layoutConfig:{bands:n,ribbons:i,showLabels:e.layoutConfig.showLabels},issues:e.issues,warnings:e.warnings,xScale:s}}(t,r,l)}catch(t){if("AbortError"===t?.name)throw t;return eo(e)}}(e,{execution:n,workerThreshold:i,signal:t.signal,colorById:s,fallbackPalette:a,rawNodeById:r,rawEdgeById:l}).then(e=>{h({...e,status:"ready",error:null})}).catch(e=>{"AbortError"!==e.name&&h(t=>({...t,status:"error",error:e}))}),()=>t.abort()},[d,u,n,i,a,r,l]),g?{...g,status:"ready",error:null}:f}import{useCallback as fo,useMemo as ho,useRef as po,useState as bo}from"react";function yo(e,t){return"function"==typeof e?e(t):t[e]}import{useCallback as vo,useMemo as ko}from"react";var wo=.22;function xo(e,t,o){return!t?.isActive||t.predicate(function(e,t){return"scene"===t?e:e.data}(e,o))}var Mo=e=>{const{bands:t=[],ribbons:o=[],showLabels:n=!0,selectionDatum:i="raw"}=e.config,s=e.selection??null,a=[];for(const e of o){const t={__kind:"ribbon",data:e.rawDatum,id:e.id},o=!xo(t,s,i);a.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:o?Math.min(e.opacity,wo):e.opacity,stroke:"none"},datum:t})}for(const e of t){if(!e.gradientStubs)continue;const t=!xo({__kind:"band",data:e.rawDatum,id:e.id},s,i);for(let o=0;e.gradientStubs.length>o;o++){const n=e.gradientStubs[o];a.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?wo:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,...null!=n.y0&&{y0:n.y0},...null!=n.y1&&{y1:n.y1},from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${o}`}})}}for(const e of t){const t=!(!e.gradientStubs||0>=e.gradientStubs.length),o={__kind:"band",data:e.rawDatum,id:e.id},n=!xo(o,s,i);a.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:n?wo:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...n&&t?{opacity:wo}:{}},datum:o})}const r=n?t.flatMap(e=>{const t=e.labelDeferred&&e.labelFullText?.trim(),o=e.labelText.trim().length>0,n=t&&s?.isActive&&xo({__kind:"band",data:e.rawDatum,id:e.id},s,i),a=o?e.labelText:n?e.labelFullText:"";return a.trim()?[{x:e.labelX,y:e.labelY,text:a,anchor:e.labelAnchor??"end",baseline:e.labelBaseline??"middle",fontSize:11,fontWeight:600}]:[]}):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:a,labels:r}};function So(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}import{Fragment as To,jsx as Ao,jsxs as Io}from"react/jsx-runtime";import{jsx as Po,jsxs as Co}from"react/jsx-runtime";var Oo=Pt(function(e,t){const{nodes:o,edges:i,domain:s,axisTicks:a=[],nodeIdAccessor:r="id",nodeLabel:l,sourceAccessor:c="source",targetAccessor:d="target",valueAccessor:u="value",startTimeAccessor:m="startTime",endTimeAccessor:f="endTime",systemInTimeAccessor:p,systemOutTimeAccessor:b,xExtentAccessor:y="xExtent",groupBy:v,edgeIdAccessor:k="id",colorBy:w,colorScheme:x,showLegend:M,legendPosition:S="right",orientation:A="horizontal",pairing:C="temporal",packing:N="reuse",laneOrder:H="crossing-min",maxValueScale:D,lanePlacement:E="stack",nodeSizing:F="temporal",groupPadding:R=0,ribbonLane:z="both",ribbonMinRun:W=0,lifetimeMode:_="half",showLaneRails:$=!1,showQualityReadout:j=!1,showLabels:X=!0,labelPriorityAccessor:Y,maxLabels:G,selectionDatum:q="raw",styleRules:V,layoutExecution:U="auto",layoutWorkerThreshold:Q,layoutLoadingContent:J,onLayoutStateChange:Z,width:te=600,height:oe=400,margin:ne,title:ie,description:se,summary:ae,accessibleTable:re,responsiveWidth:le,responsiveHeight:ce,loading:de,loadingContent:ue,emptyContent:ge,edgeOpacity:me=.35,timeFormat:fe,valueFormat:he,tooltip:pe,enableHover:be=!0,onObservation:ve,onClick:ke,selection:we,linkedHover:xe,showParticles:Se=!1,particleStyle:Te,chartId:Ae,frameProps:Ie={}}=e,Pe=Ot(null),Ce=Ot(null),{rawNodes:Oe,rawEdges:Ne,frameRef:Le,getNodeId:Be,getEdgeId:He}=function(e){const{ref:t,rawNodesProp:o,rawEdgesProp:n,nodeIdAccessor:i,edgeIdAccessor:s,sourceAccessor:a,targetAccessor:r,scalesRef:l,layoutSnapshotRef:c}=e,[d,u]=bo([]),[m,f]=bo([]),h=po(d),p=po(m);h.current=d,p.current=m;const b=fo(e=>{h.current=e,u(e)},[]),y=fo(e=>{p.current=e,f(e)},[]),v=void 0!==n,k=I(v?n:d),w=ho(()=>{const e=I(o??[]),t=m;if(0===e.length&&0===t.length)return K([],k,a,r);const n=new Set,s=[];for(const t of e){const e=yo(i,t)+"";n.has(e)||(n.add(e),s.push(t))}for(const e of t){const t=yo(i,e)+"";n.has(t)||(n.add(t),s.push(e))}const l=K([],k,a,r);for(const e of l)n.has(e.id)||(n.add(e.id),s.push(e));return s},[o,m,k,i,a,r]),x=po(null),M=fo((e,t)=>{const o=yo(s,e);return null!=o?o+"":`${yo(a,e)}-${yo(r,e)}-${t}`},[s,a,r]),S=fo(e=>{if(null==e)return!1;const t=e;return null!=yo(a,t)&&null!=yo(r,t)},[a,r]),T=fo(e=>yo(i,e)+"",[i]);return g(t,{variant:"network",frameRef:x,overrides:{push(e){if(S(e)){if(v)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");b([...h.current,e])}else y([...p.current,e])},pushMany(e){const t=[],o=[];for(const n of e)S(n)?t.push(n):o.push(n);t.length>0&&(v?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):b([...h.current,...t])),o.length>0&&y([...p.current,...o])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),o=[];if(!v){const e=h.current,n=[];for(let i=0;e.length>i;i++){const s=e[i];t.has(M(s,i))?o.push(s):n.push(s)}n.length!==e.length&&b(n)}const n=p.current,s=[];for(const e of n){const n=yo(i,e)+"";t.has(n)?o.push(e):s.push(e)}return s.length!==n.length&&y(s),o},update(e,t){const o=new Set(Array.isArray(e)?e:[e]),n=[];if(!v){let e=!1;const i=h.current.map((i,s)=>o.has(M(i,s))?(n.push(i),e=!0,t(i)):i);e&&b(i)}let s=!1;const a=p.current.map(e=>{const a=yo(i,e)+"";return o.has(a)?(n.push(e),s=!0,t(e)):e});return s&&y(a),n},clear(){v||b([]),y([]),x.current?.clear()},getData:()=>k??[],getScales:()=>l.current,getCustomLayout:()=>c.current}}),{rawNodes:w,rawEdges:k,frameRef:x,getNodeId:T,getEdgeId:M,isControlled:v}}({ref:t,rawNodesProp:o,rawEdgesProp:i,nodeIdAccessor:r,edgeIdAccessor:k,sourceAccessor:c,targetAccessor:d,scalesRef:Pe,layoutSnapshotRef:Ce}),{nodes:De,edges:Ee,domain:Fe,rawNodeById:Re,rawEdgeById:ze}=Ct(()=>{const e=(Oe??[]).map(e=>{const t=Be(e),o=l?yo(l,e):t,n={id:t,label:null==o?t:o+"",__raw:e},i=v?yo(v,e):null;null!=i&&i+""!=""&&(n.group=i+"");const s=y?yo(y,e):null;if(Array.isArray(s)&&2===s.length){const e=Me(s[0]),t=Me(s[1]);Number.isFinite(e)&&Number.isFinite(t)&&(n.xExtent=[e,t])}return n}),t=(Ne??[]).map((e,t)=>{const o={id:He(e,t),source:yo(c,e)+"",target:yo(d,e)+"",value:Number(yo(u,e)),startTime:Me(yo(m,e)),endTime:Me(yo(f,e)),__raw:e};if(p){const t=Me(yo(p,e));Number.isFinite(t)&&(o.systemInTime=t)}if(b){const t=Me(yo(b,e));Number.isFinite(t)&&(o.systemOutTime=t)}return o}),o=[Me(s[0]),Me(s[1])],n=new Map;for(const t of e)null!=t.__raw&&n.set(t.id,t.__raw);const i=new Map;for(const e of t)null!=e.__raw&&i.set(e.id,e.__raw);return{nodes:e,edges:t,domain:o,rawNodeById:n,rawEdgeById:i}},[Oe,Ne,s,Be,He,l,y,v,c,d,u,m,f,p,b]),We=ee({nodes:Oe,edges:Ne,inferNodes:!1,nodeIdAccessor:r,sourceAccessor:c,targetAccessor:d,colorBy:w,colorScheme:x,showLegend:!1,legendPosition:S,frameLegend:Ie,selection:we,linkedHover:xe,onObservation:ve,onClick:ke?(e,t)=>{So(e)?ke(e.data,t):ke(e,t)}:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:Ae,marginDefaults:Bt(!!ie,j,a.length>0,A),userMargin:ne,width:te,height:oe,hasTitle:!!ie,loading:de,loadingContent:ue,emptyContent:ge}),_e=Object.hasOwn(Ie,"legend"),$e=!_e&&(M??!!w)&&!!w,je=Nt((e,t)=>{if(w&&Oe){const t=Re.get(e);if(t)return P(t,w,We.colorScale)}return We.effectivePalette[t%We.effectivePalette.length]||"#475569"},[w,Oe,Re,We.colorScale,We.effectivePalette]),Xe=Ct(()=>{if(!$e||!w)return;const e=new Map;(Oe??[]).forEach((t,o)=>{const n=yo(w,t),i=null==n?"":n+"";i&&!e.has(i)&&e.set(i,{label:i,color:je(Be(t),o)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[$e,w,Oe,je,Be]),Ye=_e?Ie.legend:Xe,Ge=Ct(()=>{const e={...We.margin};if(Ye){const t={...e};B(e,{legend:Ye,position:We.legendPosition,size:[te,oe],hasTitle:!!ie,legendLayout:Ie.legendLayout,minimumMargin:"right"===We.legendPosition||"left"===We.legendPosition?140:"top"===We.legendPosition?50:80}),T(e,t,[te,oe],We.legendPosition)}return e},[We.margin,We.legendPosition,Ye,te,oe,ie,Ie.legendLayout]),qe=te-Ge.left-Ge.right,Ve=oe-Ge.top-Ge.bottom,Ue="vertical"===A?Ve:qe,Qe=mo(Ct(()=>qe>0&&Ve>0?{nodes:De,edges:Ee,domain:Fe,plotW:qe,plotH:Ve,orientation:A,ribbonLane:z,ribbonMinRun:W,edgeOpacity:"function"==typeof me?e=>me(e):me,colorOf:je,showLabels:X,labelPriorityAccessor:Y,maxLabels:G,selectionDatum:q,styleRules:V,usageMode:"push",colorBy:w,valueAccessor:u,layoutOpts:{pairing:C,packing:N,laneOrder:H,lifetimeMode:_,maxValueScale:D,lanePlacement:E,nodeSizing:F,groupPadding:R}}:null,[De,Ee,Fe,qe,Ve,A,z,W,me,je,X,Y,G,q,V,w,u,C,N,H,_,D,E,F,R]),{execution:U,workerThreshold:Q,colorById:Ct(()=>Object.fromEntries(De.map((e,t)=>[e.id,je(e.id,t)])),[De,je]),fallbackPalette:We.effectivePalette,rawNodeById:Re,rawEdgeById:ze}),{issues:Ke,warnings:Je,layout:Ze,xScale:et}=Qe,tt=Qe.layoutConfig,ot=Qe.status;Pe.current=Ze?{time:et,centerlines:Ze.centerlines}:{time:et},Ce.current=Ze?{layout:Ze,nodes:De,edges:Ee,bands:tt.bands,ribbons:tt.ribbons,warnings:Je,status:ot}:null;const nt=Ot(Z);nt.current=Z,Lt(()=>{nt.current?.(ot)},[ot]),Lt(()=>{0!==Je.length&&console.warn("ProcessSankey warnings:",Je.map(ye).join("; "))},[Je]);const it=void 0!==Ye&&!Object.hasOwn(Ie,"margin"),st=function(e){const{tooltip:t,enableHover:o,layout:n,timeFormat:i,valueFormat:s,sourceAccessor:a,targetAccessor:r,valueAccessor:l,startTimeAccessor:c,endTimeAccessor:d}=e,u=ko(()=>!1!==t&&o?void 0===t||!0===t?null:O(t)||null:null,[t,o]),g=vo(e=>i?i(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[i]),m=vo(e=>s?s(e):e+"",[s]);return vo(e=>{if(!e||!e.data)return null;const t=e.data;if(!So(t))return null;const o=t.data;if(u)return u(o);if("band"===t.__kind){const e=t.id,o=n?function(e){if(!e)return[];const t=new Set,o=[];for(const n of e.samples){const e=n.topMass+n.botMass,i=`${n.t}:${e}`;t.has(i)||(t.add(i),o.push({t:n.t,total:e}))}return o}(n.nodeData[e]):[],i=5,s=o.length>i?o.length:null,a=function(e,t=5){if(t>=e.length)return e.slice();const o=[...e].sort((e,t)=>e.total-t.total),n=o.length-1,i=[{...o[0],mark:"min"},{...o[Math.floor(.25*n)],mark:"q25"},{...o[Math.floor(.5*n)],mark:"median"},{...o[Math.floor(.75*n)],mark:"q75"},{...o[n],mark:"max"}],s=new Set,a=[];for(const e of i)s.has(e.t)||(s.add(e.t),a.push(e));return a.sort((e,t)=>e.t-t.t)}(o,i);return Io("div",{style:{minWidth:160},children:[Ao("div",{style:{fontWeight:600,marginBottom:4},children:e}),a.length>0&&Io("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[Ao("thead",{children:Io("tr",{style:{opacity:.6},children:[Ao("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),Ao("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=s&&Ao("th",{})]})}),Ao("tbody",{children:a.map((e,t)=>Io("tr",{children:[Ao("td",{style:{paddingRight:8},children:g(e.t)}),Ao("td",{style:{textAlign:"right"},children:m(e.total)}),null!=s&&Ao("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=s&&Io("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",a.length," of ",s," samples"]})]})}const i=o,s=yo(a,i),f=yo(r,i),h=yo(l,i),p=yo(c,i),b=yo(d,i);return Io("div",{style:{minWidth:160},children:[Io("div",{style:{fontWeight:600,marginBottom:4},children:[s+""," → ",f+""]}),Io("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=h&&Io(To,{children:[Ao("span",{style:{opacity:.6},children:"value"}),Ao("span",{style:{textAlign:"right"},children:m(Number(h))})]}),null!=p&&Io(To,{children:[Ao("span",{style:{opacity:.6},children:"start"}),Ao("span",{style:{textAlign:"right"},children:g(Me(p))})]}),null!=b&&Io(To,{children:[Ao("span",{style:{opacity:.6},children:"end"}),Ao("span",{style:{textAlign:"right"},children:g(Me(b))})]})]})]})},[n,u,g,m,a,r,l,c,d])}({tooltip:pe,enableHover:be,layout:Ze,timeFormat:fe,valueFormat:he,sourceAccessor:c,targetAccessor:d,valueAccessor:u,startTimeAccessor:m,endTimeAccessor:f}),at=Ct(()=>{if(!Ze)return null;const e=Je.map(e=>ye(e));return function(e){const t=e.layout,o=e.nodes,n=e.orientation,i=e.plotW,s=e.plotH,a=e.timelineExtent,r=e.axisTicks,l=e.showQualityReadout??!1,c=e.showLaneRails??!1,d=(e.warnings??[]).slice(0,3),u=e.timeFormat,g=e.colorOf,m=e.toTime,f=e.xScale,{centerlines:h,laneLifetime:p,nodeData:b,valueScale:y,compressedPadding:v,crossingsBefore:k,crossingsAfter:w,layoutQualityBefore:x,layoutQuality:M}=t;let S=null,T=null;for(const e of o){const t=p[e.id];if(!t||null===t.start||null===t.end)continue;const o=f(t.start),n=f(t.end);(null===S||S>o)&&(S=o),(null===T||n>T)&&(T=n)}const A=e=>Math.max(0,Math.min(a,e)),I=A(S??0),P=Math.max(I,A(T??a)),C=r.map((e,t)=>({tick:e,index:t,coordinate:f(m(e.date))})).filter(({coordinate:e})=>e>=I-.5&&P+.5>=e),O=null!==(w??null)&&null!=x&&null!=M,N=l&&(O||d.length>0)?Et("g",{fill:zt,fontSize:10,textAnchor:"end",children:[O&&Et(Ht,{children:[Et("text",{x:i,y:-14,children:["crossings: ",k," → ",w," ","pixel length: ",Math.round(x.pixelLength)," → ",Math.round(M.pixelLength)]}),Et("text",{x:i,y:-3,children:["transit: ",x.transitOcclusion.toFixed(1)," → ",M.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*M.verticalUtilization),"%"]})]}),d.map((e,t)=>Et("text",{x:i,y:O?10+11*t:11*t-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",e]},"warn-"+t))]}):null,L=v?Dt("text",{x:i,y:"vertical"===n?-3:2,fontSize:10,fill:zt,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,B=(e,t)=>g?g(e,t):Ft;return Et("g","vertical"===n?{children:[N,L,C.map(({index:e,coordinate:t})=>Dt("line",{x1:0,y1:t,x2:i,y2:t,stroke:Ft,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&o.map((e,t)=>{const o=p[e.id];if(!o||null===o.start)return null;const n=b[e.id],i=n?{topPeak:n.topPeak,botPeak:n.botPeak}:{topPeak:0,botPeak:0},s=h[e.id]+(i.botPeak-i.topPeak)*y/2,a=f(o.start),r=f(o.end),l=B(e.id,t);return Et("g",{children:[Dt("line",{x1:s,y1:a,x2:s,y2:r,stroke:l,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),Dt("line",{x1:s-4,y1:a,x2:s+4,y2:a,stroke:l,strokeOpacity:.5}),Dt("line",{x1:s-4,y1:r,x2:s+4,y2:r,stroke:l,strokeOpacity:.5})]},"lane-"+e.id)}),Dt("line",{x1:-4,y1:I,x2:-4,y2:P,stroke:Ft}),C.map(({tick:e,index:t,coordinate:o})=>{const n=m(e.date),i=null!=e.label?e.label:u?u(new Date(n)):"";return Et("g",{transform:`translate(-4,${o})`,children:[Dt("line",{x2:-6,stroke:Ft}),Dt("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:Rt,children:i})]},t)})]}:{children:[N,L,C.map(({index:e,coordinate:t})=>Dt("line",{x1:t,y1:0,x2:t,y2:s,stroke:Ft,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&o.map((e,t)=>{const o=p[e.id];if(!o||null===o.start)return null;const n=b[e.id],i=n?{topPeak:n.topPeak,botPeak:n.botPeak}:{topPeak:0,botPeak:0},s=h[e.id]+(i.botPeak-i.topPeak)*y/2,a=f(o.start),r=f(o.end),l=B(e.id,t);return Et("g",{children:[Dt("line",{x1:a,y1:s,x2:r,y2:s,stroke:l,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),Dt("line",{x1:a,y1:s-4,x2:a,y2:s+4,stroke:l,strokeOpacity:.5}),Dt("line",{x1:r,y1:s-4,x2:r,y2:s+4,stroke:l,strokeOpacity:.5})]},"lane-"+e.id)}),Dt("line",{x1:I,y1:s+4,x2:P,y2:s+4,stroke:Ft}),C.map(({tick:e,index:t,coordinate:o})=>{const n=m(e.date),i=null!=e.label?e.label:u?u(new Date(n)):"";return Et("g",{transform:`translate(${o},${s+4})`,children:[Dt("line",{y2:6,stroke:Ft}),Dt("text",{y:20,textAnchor:"middle",fontSize:11,fill:Rt,children:i})]},t)})]})}({layout:Ze,nodes:De,orientation:A,plotW:qe,plotH:Ve,timelineExtent:Ue,axisTicks:a,showQualityReadout:j,showLaneRails:$,warnings:e,timeFormat:fe?e=>fe(e):void 0,colorOf:je,toTime:Me,xScale:e=>Number(et(e))})},[Ze,De,A,qe,Ve,Ue,a,j,$,Je,fe,je,et]),rt=Ct(()=>(Oe??[]).map(e=>({id:Be(e),data:e})),[Oe,Be]),lt=Ct(()=>{const e=new Map;for(const t of tt.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[tt]),ct=Ct(()=>(Ne??[]).map((e,t)=>{const o=He(e,t),n=Number(yo(u,e));return{id:o,source:yo(c,e)+"",target:yo(d,e)+"",value:Number.isFinite(n)?n:0,bezier:lt.get(o),data:e}}),[Ne,He,c,d,u,lt]);return Ke.length>0?Co("svg",{width:te,height:oe,role:"img","aria-label":ie??"Process Sankey validation failed",children:[Po("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Ke.map((e,t)=>Po("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+ye(e)},t))]}):We.loadingEl?We.loadingEl:We.emptyEl?We.emptyEl:Co("div",{style:{position:"relative",width:te,height:oe},children:["pending"===ot&&!1!==J&&!Ze&&Po("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:L(!0,te,oe,J)}),Po(n,{ref:Le,chartType:"force",nodes:rt,edges:ct,customNetworkLayout:Mo,layoutConfig:tt,size:[te,oe],responsiveWidth:le,responsiveHeight:ce,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:Ge,title:ie,description:se??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:ae,accessibleTable:re,enableHover:be,tooltipContent:!1===pe?()=>null:st,backgroundGraphics:at,showParticles:Se,particleStyle:Te,legend:Ye,legendPosition:We.legendPosition,...it&&{__legendMarginReservedFor:Ye},...h({linkedHover:xe,selection:we,onObservation:ve,onClick:ke,mobileInteraction:We.mobileInteraction,customHoverBehavior:We.customHoverBehavior,customClickBehavior:We.customClickBehavior,linkedHoverInClickPredicate:!1}),chartId:Ae,colorScheme:Array.isArray(x)?x:void 0,layoutSelection:We.activeSelectionHook,...Ie})]})});Oo.displayName="ProcessSankey";import{useMemo as No}from"react";import{jsx as Lo}from"react/jsx-runtime";function Bo(e){const o=z(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:s,className:a,layout:r="tree",orientation:l="vertical",childrenAccessor:c="children",valueAccessor:u="value",nodeIdAccessor:g="name",colorBy:m,colorScheme:f,colorByDepth:p=!1,edgeStyle:b="curve",nodeLabel:y,nodeSize:v=5,tooltip:w,frameProps:x={},onObservation:T,onClick:A,chartId:I,selection:C,linkedHover:N,loading:L,loadingContent:B,legendInteraction:H,stroke:D,strokeWidth:F,opacity:R}=e,{width:W,height:_,enableHover:$,showLabels:j=!0,title:X,description:Y,summary:G,accessibleTable:q}=o,V=ee({nodes:No(()=>Q(i??null,c),[i,c]),edges:void 0,inferNodes:!1,colorBy:p?void 0:m,colorScheme:f,showLegend:!1,legendInteraction:H,frameLegend:x,selection:C,linkedHover:N,onObservation:T,onClick:A,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"TreeDiagram",chartId:I,marginDefaults:o.marginDefaults,userMargin:s,width:W,height:_,hasTitle:!!X,loading:L,loadingContent:B}),U=No(()=>new Map,[]),K=No(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=p?M[(e.depth||0)%M.length]:m?P(e.data||e,m,V.colorScale):E(void 0,V.themeCategorical,f,void 0,U),t},[m,p,V.colorScale,V.themeCategorical,f,U]),Z=No(()=>d(K,{stroke:D,strokeWidth:F,opacity:R}),[K,D,F,R]),te=No(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),oe=No(()=>d(te,{stroke:D,strokeWidth:F,opacity:R}),[te,D,F,R]),ne=No(()=>{if("treemap"===r||"circlepack"===r||"partition"===r)return J(u)},[r,u]),ie=t({componentName:"TreeDiagram",data:i});return ie?Lo(k,{componentName:"TreeDiagram",message:ie,width:W,height:_}):V.loadingEl?V.loadingEl:Lo(S,{componentName:"TreeDiagram",width:W,height:_,children:Lo(n,{chartType:r,...null!=i&&{data:i},size:[W,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:V.margin,...V.legendBehaviorProps,nodeIDAccessor:g,childrenAccessor:c,hierarchySum:ne,treeOrientation:l,edgeType:b,nodeStyle:Z,edgeStyle:oe,colorBy:m,colorScheme:V.effectivePalette,colorByDepth:p,nodeSize:v,nodeLabel:j?y||g:void 0,showLabels:j,enableHover:$,tooltipContent:!1===w?()=>null:O(w)||void 0,...h({linkedHover:N,selection:C,onObservation:T,onClick:A,mobileInteraction:V.mobileInteraction,customHoverBehavior:V.customHoverBehavior,customClickBehavior:V.customClickBehavior,linkedHoverInClickPredicate:!1}),...H&&"none"!==H&&{legendHoverBehavior:V.legendState.onLegendHover,legendClickBehavior:V.legendState.onLegendClick,legendHighlightedCategory:V.legendState.highlightedCategory,legendIsolatedCategories:V.legendState.isolatedCategories},className:a,title:X,description:Y,summary:G,accessibleTable:q,...null!=e.animate&&{animate:e.animate},...x})})}Bo.displayName="TreeDiagram";import{useMemo as Ho,useCallback as Do}from"react";import{jsx as Eo}from"react/jsx-runtime";function Fo(e){const o=z(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:s,className:a,childrenAccessor:r="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:g,colorByDepth:f=!1,labelMode:p="leaf",nodeLabel:b,padding:y=4,paddingTop:v,nodeStyle:w,tooltip:T,frameProps:A={},selection:I,linkedHover:C,onObservation:N,onClick:L,chartId:B,loading:H,loadingContent:D,legendInteraction:F,stroke:R,strokeWidth:W,opacity:_}=e,{nodeStyle:$,...j}=A,{width:X,height:Y,enableHover:G,showLabels:q=!0,title:V,description:U,summary:K,accessibleTable:Z}=o,te=ee({nodes:Ho(()=>Q(i??null,r),[i,r]),edges:void 0,inferNodes:!1,colorBy:f?void 0:u,colorScheme:g,showLegend:!1,legendInteraction:F,frameLegend:j,selection:I,linkedHover:C,onObservation:N,onClick:L,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"Treemap",chartId:B,marginDefaults:o.marginDefaults,userMargin:s,width:X,height:Y,hasTitle:!!V,loading:H,loadingContent:D}),oe=m(I),ne=te.customHoverBehavior,ie=Do(e=>{if(!e)return ne(null);const t=e.data||e;ne({data:t?.data||t})},[ne]),se=Ho(()=>new Map,[]),ae=Ho(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=f?M[(e.depth||0)%M.length]:u?P(e.data||e,u,te.colorScale):E(void 0,te.themeCategorical,g,void 0,se),t},[u,f,te.colorScale,te.themeCategorical,g,se]),re=Ho(()=>w||$?e=>({...ae(e),...$?$(e)??{}:{},...w?w(e)??{}:{}}):ae,[ae,w,$]),le=Ho(()=>d(re,{stroke:R,strokeWidth:W,opacity:_}),[re,R,W,_]),ce=Ho(()=>te.activeSelectionHook?e=>{const t={...le(e)};if(te.activeSelectionHook.isActive)if(te.activeSelectionHook.predicate(e.data||e))oe?.selectedStyle&&Object.assign(t,oe.selectedStyle);else{const e=oe?.unselectedOpacity??x;t.opacity=e,t.fillOpacity=e,t.strokeOpacity=e,oe?.unselectedStyle&&Object.assign(t,oe.unselectedStyle)}return t}:le,[le,te.activeSelectionHook,oe]),de=Ho(()=>J(l),[l]),ue=void 0!==v?v:!q||"parent"!==p&&"all"!==p?void 0:18,ge=t({componentName:"Treemap",data:i});return ge?Eo(k,{componentName:"Treemap",message:ge,width:X,height:Y}):te.loadingEl?te.loadingEl:Eo(S,{componentName:"Treemap",width:X,height:Y,children:Eo(n,{chartType:"treemap",...null!=i&&{data:i},size:[X,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:te.margin,...te.legendBehaviorProps,nodeIDAccessor:c,childrenAccessor:r,hierarchySum:de,padding:y,paddingTop:ue,nodeStyle:ce,colorBy:u,colorScheme:te.effectivePalette,colorByDepth:f,nodeLabel:q?b||c:void 0,showLabels:q,labelMode:p,enableHover:G,tooltipContent:!1===T?()=>null:O(T)||void 0,...h({linkedHover:C,selection:I,onObservation:N,onClick:L,mobileInteraction:te.mobileInteraction,customHoverBehavior:ie,customClickBehavior:te.customClickBehavior,linkedHoverInClickPredicate:!1}),...F&&"none"!==F&&{legendHoverBehavior:te.legendState.onLegendHover,legendClickBehavior:te.legendState.onLegendClick,legendHighlightedCategory:te.legendState.highlightedCategory,legendIsolatedCategories:te.legendState.isolatedCategories},className:a,title:V,description:U,summary:K,accessibleTable:Z,...null!=e.animate&&{animate:e.animate},...j})})}Fo.displayName="Treemap";import{useMemo as Ro}from"react";import{jsx as zo}from"react/jsx-runtime";function Wo(e){const o=z(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:s,className:a,childrenAccessor:r="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:g,colorByDepth:m=!1,nodeLabel:f,circleOpacity:p=.7,padding:b=4,tooltip:y,frameProps:v={},onObservation:w,onClick:x,chartId:T,selection:A,linkedHover:I,loading:C,loadingContent:N,legendInteraction:L,stroke:B,strokeWidth:H,opacity:D}=e,{width:F,height:R,enableHover:W,showLabels:_=!0,title:$,description:j,summary:X,accessibleTable:Y}=o,G=ee({nodes:Ro(()=>Q(i??null,r),[i,r]),edges:void 0,inferNodes:!1,colorBy:m?void 0:u,colorScheme:g,showLegend:!1,legendInteraction:L,frameLegend:v,selection:A,linkedHover:I,onObservation:w,onClick:x,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"CirclePack",chartId:T,marginDefaults:o.marginDefaults,userMargin:s,width:F,height:R,hasTitle:!!$,loading:C,loadingContent:N}),q=Ro(()=>new Map,[]),V=Ro(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:p};return t.fill=m?M[(e.depth||0)%M.length]:u?P(e.data||e,u,G.colorScale):E(void 0,G.themeCategorical,g,void 0,q),t},[u,m,G.colorScale,p,G.themeCategorical,g,q]),U=Ro(()=>d(V,{stroke:B,strokeWidth:H,opacity:D}),[V,B,H,D]),K=Ro(()=>J(l),[l]),Z=t({componentName:"CirclePack",data:i});return Z?zo(k,{componentName:"CirclePack",message:Z,width:F,height:R}):G.loadingEl?G.loadingEl:zo(S,{componentName:"CirclePack",width:F,height:R,children:zo(n,{chartType:"circlepack",...null!=i&&{data:i},size:[F,R],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:G.margin,...G.legendBehaviorProps,nodeIDAccessor:c,childrenAccessor:r,hierarchySum:K,padding:b,nodeStyle:U,colorBy:u,colorScheme:G.effectivePalette,colorByDepth:m,nodeLabel:_?f||c:void 0,showLabels:_,enableHover:W,tooltipContent:!1===y?()=>null:O(y)||void 0,...h({linkedHover:I,selection:A,onObservation:w,onClick:x,mobileInteraction:G.mobileInteraction,customHoverBehavior:G.customHoverBehavior,customClickBehavior:G.customClickBehavior,linkedHoverInClickPredicate:!1}),...L&&"none"!==L&&{legendHoverBehavior:G.legendState.onLegendHover,legendClickBehavior:G.legendState.onLegendClick,legendHighlightedCategory:G.legendState.highlightedCategory,legendIsolatedCategories:G.legendState.isolatedCategories},className:a,title:$,description:j,summary:X,accessibleTable:Y,...null!=e.animate&&{animate:e.animate},...v})})}Wo.displayName="CirclePack";import{useMemo as _o}from"react";import{jsx as $o}from"react/jsx-runtime";var jo=M;function Xo(e){const o=z(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:s,className:a,childrenAccessor:r="children",nodeIdAccessor:l="name",colorBy:c,colorScheme:u,colorByDepth:g=!1,orbitMode:m="flat",orbitSize:f=2.95,speed:p=.25,revolution:b,revolutionStyle:y,eccentricity:x=1,showRings:M=!0,nodeRadius:T=6,showLabels:A=!1,animated:I=!0,tooltip:C,foregroundGraphics:N,annotations:L,frameProps:B={},onObservation:D,onClick:F,chartId:R,selection:W,linkedHover:_,loading:$,loadingContent:j,stroke:X,strokeWidth:Y,opacity:G}=e,{width:q,height:V,enableHover:U,title:K,description:J,summary:Z,accessibleTable:te}=o,oe=ee({nodes:_o(()=>Q(i,r),[i,r]),edges:void 0,inferNodes:!1,colorBy:g?void 0:c,colorScheme:u,showLegend:!1,legendInteraction:void 0,frameLegend:B,selection:W,linkedHover:_,onObservation:D,onClick:F,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"OrbitDiagram",chartId:R,marginDefaults:H(o),userMargin:s,width:q,height:V,hasTitle:!!K,loading:$,loadingContent:j}),ne=_o(()=>new Map,[]),{colorScale:ie,customClickBehavior:se,customHoverBehavior:ae,themeCategorical:re}=oe,le=_o(()=>{if(Array.isArray(u))return u;const e=v[u];return Array.isArray(e)?e:w},[u]),ce=_o(()=>e=>{const t={stroke:"#fff",strokeWidth:1},o=0===(e.depth??0);return t.fill=g?o?le[0]:jo[(e.depth||0)%jo.length]:c?P(e.data||e,c,ie):E(void 0,re,u,void 0,ne),t.opacity=o?1:.85,t},[c,g,ie,le,re,u,ne]),de=_o(()=>d(ce,{stroke:X,strokeWidth:Y,opacity:G}),[ce,X,Y,G]),ue=_o(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),ge=_o(()=>e=>{ae(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[ae]),me=_o(()=>e=>{se(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[se]),fe=t({componentName:"OrbitDiagram",data:i});return fe?$o(k,{componentName:"OrbitDiagram",message:fe,width:q,height:V}):oe.loadingEl?oe.loadingEl:$o(S,{componentName:"OrbitDiagram",width:q,height:V,children:$o(n,{chartType:"orbit",...null!=i&&{data:i},size:[q,V],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:oe.margin,...oe.legendBehaviorProps,nodeIDAccessor:l,childrenAccessor:r,nodeStyle:de,edgeStyle:ue,colorBy:c,colorScheme:oe.effectivePalette,colorByDepth:g,nodeSize:T,nodeLabel:A?l:void 0,showLabels:A,enableHover:!I&&U,tooltipContent:I?void 0:!1===C?()=>null:O(C)||void 0,...h({linkedHover:_,selection:W,onObservation:D,onClick:F,mobileInteraction:oe.mobileInteraction,customHoverBehavior:ge,customClickBehavior:me,linkedHoverInClickPredicate:!1}),foregroundGraphics:N,annotations:L,className:a,title:K,description:J,summary:Z,orbitMode:m,orbitSize:f,orbitSpeed:p,orbitRevolution:b,orbitRevolutionStyle:y,orbitEccentricity:x,orbitShowRings:M,orbitAnimated:I,accessibleTable:te,...null!=e.animate&&{animate:e.animate},...B})})}Xo.displayName="OrbitDiagram";import{forwardRef as Yo,useMemo as Go}from"react";import{jsx as qo}from"react/jsx-runtime";var Vo=Yo(function(e,t){const{nodes:o,edges:i,layout:s,layoutConfig:a,onLayoutError:r,nodeIDAccessor:l="id",sourceAccessor:c="source",targetAccessor:d="target",margin:g,className:m,colorBy:p,colorScheme:b,tooltip:y,selection:v,linkedHover:k,onObservation:w,onClick:x,chartId:M,annotations:T,autoPlaceAnnotations:A,frameProps:P={}}=e,{frameRef:C,resolved:B,normalizedMargin:H}=u({imperativeRef:t,imperativeVariant:"network",margin:g,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),D=Go(()=>I(o),[o]),E=Go(()=>I(i),[i]),R=Go(()=>void 0===o&&void 0===i?void 0:[...D,...E],[i,o,E,D]),z=F(e.mobileInteraction,{mode:e.mode,width:B.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:_,customClickBehavior:$,activeSelectionHook:j}=W({selection:v,linkedHover:k,fallbackFields:"string"==typeof p?[p]:[],onObservation:w,onClick:x,chartType:"NetworkCustomChart",chartId:M,colorByField:"string"==typeof p?p:void 0,mobileInteraction:z}),X=Go(()=>j?.isActive?{isActive:!0,predicate:j.predicate}:null,[j?.isActive,j?.predicate]),{width:Y,height:G,enableHover:q,title:V,description:U,summary:Q,accessibleTable:K}=B,J=Go(()=>O(y),[y]),Z=L(e.loading,Y,G,e.loadingContent),ee=Z?null:N(R,Y,G,e.emptyContent);if(Z||ee)return Z||ee;const te={chartType:"force",...null!=o&&{nodes:D},...null!=i&&{edges:E},customNetworkLayout:s,layoutConfig:a,onLayoutError:r,nodeIDAccessor:l,sourceAccessor:c,targetAccessor:d,colorBy:p,colorScheme:b,size:[Y,G],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:H,enableHover:q,...f({title:V,description:U,summary:Q,accessibleTable:K,className:m,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,autoPlaceAnnotations:A}),...!1===y?{tooltipContent:()=>null}:J?{tooltipContent:J}:{},...h({linkedHover:k,selection:v,onObservation:w,onClick:x,mobileInteraction:z,customHoverBehavior:_,customClickBehavior:$,linkedHoverInClickPredicate:!1}),layoutSelection:X,...null!=T&&{annotations:T},...P};return qo(S,{componentName:"NetworkCustomChart",width:Y,height:G,children:qo(n,{ref:C,...te})})});Vo.displayName="NetworkCustomChart";import{forceCenter as Uo,forceCollide as Qo,forceLink as Ko,forceManyBody as Jo,forceSimulation as Zo,forceX as en,forceY as tn}from"d3-force";function on(e,t,o={}){const n=o.iterations??260,i=o.repulsion??5200,s=o.linkDistance??165,a=o.linkStrength??.045,r=o.centerStrength??.018,c=o.damping??.84,d=o.nodeRadius??12,u=o.nodePadding??3,g=o.inset??.06,m=l(o.seed??1),f=new Map;for(const t of e)f.set(t.id,0);for(const e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);const h=500,p=e.map(e=>({id:e.id,data:e,x:200+600*m(),y:200+600*m()})),b=new Set(e.map(e=>e.id)),y=t.filter(e=>b.has(e.source)&&b.has(e.target)).map(e=>({source:e.source,target:e.target}));if(n>0){const e=Zo(p).randomSource(m).alphaDecay(1-Math.pow(.001,1/n)).velocityDecay(Math.max(0,Math.min(1,1-c))).force("charge",Jo().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(i)*Math.sqrt(t+1)})).force("collide",Qo(e=>(e=>"function"==typeof d?d(e.data):d)(e)+u).strength(.9).iterations(2)).force("center",Uo(h,h).strength(.8)).force("x",en(h).strength(r)).force("y",tn(h).strength(r));y.length>0&&e.force("link",Ko(y).id(e=>e.id).distance(s).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(f.get("string"==typeof e.source?e.source:e.source.id)??1,f.get(t)??1));return a/.045/o})),e.stop();for(let t=0;n>t;t+=1)e.tick()}let v=1/0,k=1/0,w=-1/0,x=-1/0;for(const e of p){const t=e.x??h,o=e.y??h;v>t&&(v=t),k>o&&(k=o),t>w&&(w=t),o>x&&(x=o)}const M=w-v,S=x-k,T={};for(const e of p)Object.defineProperty(T,e.id,{value:{x:0===M?.5:g+((e.x??h)-v)/M*(1-2*g),y:0===S?.5:g+((e.y??h)-k)/S*(1-2*g)},enumerable:!0,configurable:!0,writable:!0});return T}export{oe as ForceDirectedGraph,re as ChordDiagram,ge as SankeyDiagram,be as validateProcessSankey,ye as formatProcessSankeyIssue,ve as diagnoseProcessSankeyLayout,ke as explainProcessSankeyLayout,we as diagnoseProcessSankeyProps,xe as inventoryAtTime,Me as toProcessSankeyTime,Oo as ProcessSankey,Bo as TreeDiagram,Fo as Treemap,Wo as CirclePack,Xo as OrbitDiagram,Vo as NetworkCustomChart,on as forceLayout};
@@ -1 +0,0 @@
1
- import{resolveCSSColor as t,resolveCanvasFill as o,symbolPathString as e}from"./c-GIKRQI4X.min.js";function n(t,o){return t===o}function r(t,o){if("function"==typeof t)return o=>+t(o);const e=t||o;return t=>+t[e]}function l(t,o){if("function"==typeof t)return t;const e=t||o;return t=>t[e]}function i(t,o){return"function"==typeof t?o=>t(o)+"":t?o=>o[t]+"":o?t=>t[o]+"":void 0}function c(t){return t?"function"==typeof t?t:o=>o[t]||o.id:null}function f(t){return"string"==typeof t?t:t.id}var s={top:50,right:40,bottom:60,left:70},a={top:20,right:80,bottom:20,left:80},u={top:40,right:40,bottom:40,left:40},y=new Set(["chord","force","circlepack","orbit"]);function p(t){return y.has(t)?u:a}var h=new Map;function b(n,r,l,i,c,f){if(0>=r.size)return;const s=function(t,o,n){try{if(n)return new Path2D(n);const r=`${t??"circle"}:${Math.round(o)}`;let l=h.get(r);return l||(l=new Path2D(e(t,o)),h.size>256&&h.clear(),h.set(r,l)),l}catch{return null}}(r.symbolType,r.size,r.path);if(!s)return;n.save(),n.translate(l,i),r.rotation&&n.rotate(r.rotation);const a=(r.style.opacity??1)*(r._decayOpacity??1);r.style.fill&&(n.globalAlpha=c*a*(r.style.fillOpacity??1),n.fillStyle=o(n,r.style.fill,f),n.fill(s)),r.style.stroke&&"none"!==r.style.stroke&&(n.globalAlpha=c*a,n.strokeStyle=t(n,r.style.stroke)||r.style.stroke,n.lineWidth=r.style.strokeWidth??1,n.stroke(s)),n.restore()}var g=(t,o)=>{const e=t.globalAlpha;for(const n of o)"symbol"===n.type&&b(t,n,n.x,n.y,e,"#4e79a7");t.globalAlpha=e};function m(t,o){const e=t.globalAlpha;for(const n of o)"symbol"===n.type&&b(t,n,n.cx,n.cy,e,"#007bff");t.globalAlpha=e}export{n as accessorsEquivalent,r as resolveAccessor,l as resolveRawAccessor,i as resolveStringAccessor,c as resolveLabelFn,f as resolveNodeRefId,g as symbolCanvasRenderer,m as networkSymbolRenderer,s as AXIS_FRAME_DEFAULT_MARGIN,p as networkFrameDefaultMargin};
@@ -1 +0,0 @@
1
- function t(t){if(null==t)return()=>{};const n="function"==typeof t?t:n=>n[t];return t=>e(n(t))}function n(n,i){const e=t(n),o=t(i);return(t,n)=>{const i=o(t);return{value:i,x:e(t),y:i,category:n}}}function i(n,i){const e=t(i??"value"),o=null==n?void 0:"function"==typeof n?n:t=>t[n];return t=>{const n=o?o(t):void 0;return{value:e(t),category:null==n?void 0:n+""}}}function e(t){if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t&&""!==t.trim()){const n=Number(t);return Number.isFinite(n)?n:void 0}}function o(t,n,i){const o=null!=t.axis?i[t.axis]:null!=t.field?n[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 r=e(o);if(void 0===r)return!1;if(void 0!==t.gt&&t.gt>=r)return!1;if(void 0!==t.gte&&t.gte>r)return!1;if(void 0!==t.lt&&r>=t.lt)return!1;if(void 0!==t.lte&&r>t.lte)return!1;if(void 0!==t.within){const[n,i]=t.within;if(n>r||r>i)return!1}if(void 0!==t.outside){const[n,i]=t.outside;if(r>=n&&i>=r)return!1}return!0}function r(t,n,i){const e=t.when;return void 0===e||!0===e||!1!==e&&("function"==typeof e?e(n,i):o(e,n,i))}function u(t,n,i){if(!n||0===n.length)return{};let e={};for(const o of n){if(!r(o,t,i))continue;const n="function"==typeof o.style?o.style(t,i):o.style;n&&(e={...e,...n})}return e}function f(t,n,i,e=t=>t){const o=t??(()=>({}));return n&&0!==n.length?(t,r)=>{const f=e(t),c={...o(t,r)};return Object.assign(c,u(f,n,i(f,r))),c}:o}function c(t,n,i){return t&&0!==t.length?(e,o)=>{const r=u(e,t,n(e,o)),f=i?i(e,o):void 0;return f?{...r,...f}:r}:i}function s(t,n,e,o){if(!t||0===t.length)return o;const r=i(n,e);return(n,i)=>{const e=n&&n.data||n,f=u(e,t,r(e)),c=o?o(n,i):void 0;return c?{...f,...c}:f}}function l(t,i,e,o){return c(t,n(i,e),o)}function d(n,i,e){const o=t(i);return c(n,(t,n)=>({value:o(t),category:n}),e)}export{t as makeRuleValueResolver,n as makeXYRuleContext,i as makeNodeRuleContext,o as matchesThreshold,r as ruleMatches,u as resolveStyleRules,f as composeStyleRules,c as makeStyleRuleStyleFn,s as styleRulesToNodeStyle,l as styleRulesToXYStyle,d as styleRulesToPieceStyle};
@@ -1 +0,0 @@
1
- function n(n){let t=n>>>0;return function(){t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}var t=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),e=new Set(["label","callout","callout-circle","callout-rect"]);function a(n){return"string"==typeof n?.type?n.type:""}function i(n){return!!n&&"object"==typeof n&&t.has(a(n))}function r(n){return e.has(a(n))&&!function(n){return Array.isArray(n?.disable)&&n.disable.includes("connector")}(n)}var o=2e4;function c(n){return"primary"===n?.emphasis||!0===n?.defensive}function l(n,t,e={}){return"number"==typeof e.maxAnnotations&&Number.isFinite(e.maxAnnotations)?Math.max(0,Math.floor(e.maxAnnotations)):n>0&&t>0?Math.max(1,Math.round(n*t/(e.areaPerAnnotation&&e.areaPerAnnotation>0?e.areaPerAnnotation:2e4))):1/0}function s(n){let t;const e=n?.emphasis;t="primary"===e?100:"secondary"===e?10:50;const a=n?.provenance?.confidence;switch("number"==typeof a&&Number.isFinite(a)&&(t+=15*Math.max(0,Math.min(1,a))),n?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}function u(n){const{annotations:t,width:e,height:a}=n,r=Math.max(0,n.minVisible??1),o=l(e,a,n),u=t.map((n,t)=>{return{annotation:n,index:t,note:(e=n,i(e))};var e}),h=u.filter(n=>n.note);if(0===h.length||o>=h.length)return{visible:t.slice(),deferred:[],budget:o};const f=h.filter(n=>c(n.annotation)),m=h.filter(n=>!c(n.annotation)).sort((n,t)=>s(t.annotation)-s(n.annotation)||n.index-t.index),d=Math.min(m.length,Math.max(Math.max(0,o-f.length),Math.max(0,r-f.length))),x=new Set([...f.map(n=>n.index),...m.slice(0,d).map(n=>n.index)]),p=[],b=[];for(const{annotation:n,index:t,note:e}of u)!e||x.has(t)?p.push(n):b.push(n);return{visible:p,deferred:b,budget:o}}export{n as mulberry32,a as annotationType,i as isNoteAnnotation,r as annotationDrawsConnector,o as DEFAULT_AREA_PER_ANNOTATION,l as annotationBudget,u as annotationDensity};