semiotic 3.12.0 → 3.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/README.md +50 -46
  2. package/ai/artifact-surface-inventory.json +1 -1
  3. package/ai/behaviorContracts.cjs +1 -1
  4. package/ai/dist/diagnose-operation.js +3 -3
  5. package/ai/dist/mcp-server.js +1 -1
  6. package/ai/reference.md +15 -3
  7. package/ai/schema.json +908 -96
  8. package/ai/surface-manifest.json +1 -1
  9. package/ai/task-packets/compare-category-totals.json +5 -5
  10. package/ai/task-packets/compare-category-totals.md +2 -2
  11. package/ai/task-packets/correct-published-chart.json +5 -5
  12. package/ai/task-packets/correct-published-chart.md +2 -2
  13. package/ai/task-packets/index.json +6 -6
  14. package/ai/task-packets/update-live-chart.json +5 -5
  15. package/ai/task-packets/update-live-chart.md +2 -2
  16. package/dist/c-27DCB5T6.min.js +7 -7
  17. package/dist/c-2CKIGFD2.min.js +1 -1
  18. package/dist/c-3FATLOH4.min.js +1 -0
  19. package/dist/{c-STVM6CBI.min.js → c-4SCJKAWZ.min.js} +200 -200
  20. package/dist/c-5FUOKMH6.min.js +7 -0
  21. package/dist/c-AAIPWVQ5.min.js +6 -6
  22. package/dist/{c-2RG4WOVX.min.js → c-ALLF3Y77.min.js} +1 -1
  23. package/dist/{c-QMKQVCCZ.min.js → c-C5GXUHUO.min.js} +6 -6
  24. package/dist/c-C67QDKTU.min.js +34 -0
  25. package/dist/c-F76M77YC.min.js +1 -0
  26. package/dist/c-FEVXPKQH.min.js +1 -1
  27. package/dist/c-G42WVQO2.min.js +1 -0
  28. package/dist/c-G5A3YWTN.min.js +66 -0
  29. package/dist/c-H4HVKBU3.min.js +1 -0
  30. package/dist/c-HU3ASFKT.min.js +1 -0
  31. package/dist/c-I4FYCVJB.min.js +391 -0
  32. package/dist/{c-5L7JGWQW.min.js → c-IATPZOL7.min.js} +28 -28
  33. package/dist/c-IE5EBBP6.min.js +110 -0
  34. package/dist/c-IGONIKZL.min.js +1 -0
  35. package/dist/c-IKPM53JH.min.js +1 -0
  36. package/dist/c-IU4QZ7Y5.min.js +1 -1
  37. package/dist/{c-2ACLVPKF.min.js → c-K5VE57OI.min.js} +1 -1
  38. package/dist/c-KWJIBJ4R.min.js +1 -0
  39. package/dist/c-LIMFU6RD.min.js +1 -0
  40. package/dist/c-M4T43G76.min.js +1 -0
  41. package/dist/c-M7QUZZCE.min.js +1 -1
  42. package/dist/c-NVSINXE5.min.js +1 -0
  43. package/dist/{c-FAF6EV4E.min.js → c-NWRYV6ZF.min.js} +1 -1
  44. package/dist/c-O5GU2R5W.min.js +1 -0
  45. package/dist/c-OC7GNXGZ.min.js +1 -0
  46. package/dist/c-OV5F3DQP.min.js +1 -0
  47. package/dist/{c-5TAXHW7I.min.js → c-PJ5CAYAW.min.js} +1 -1
  48. package/dist/c-Q5LZRQGD.min.js +1 -0
  49. package/dist/c-QP3PXK3N.min.js +1 -0
  50. package/dist/c-SGZ7ZD2I.min.js +51 -0
  51. package/dist/c-SSKV5JPW.min.js +1 -1
  52. package/dist/c-THWTHWXU.min.js +37 -0
  53. package/dist/c-TRMNDRC4.min.js +41 -0
  54. package/dist/c-UP656CST.min.js +1 -1
  55. package/dist/c-USYOK5OX.min.js +1 -0
  56. package/dist/c-VI753KBO.min.js +1 -0
  57. package/dist/{c-TT4CTEBR.min.js → c-VLAAAFST.min.js} +1 -1
  58. package/dist/c-VSOQPII4.min.js +5 -5
  59. package/dist/c-WGDM4ZRP.min.js +26 -0
  60. package/dist/c-XCV7VUU3.min.js +87 -0
  61. package/dist/c-XGDZPYBI.min.js +1 -0
  62. package/dist/c-XI6CLZII.min.js +1 -0
  63. package/dist/{c-L4Q2YMXO.min.js → c-XLC7PKM7.min.js} +1 -1
  64. package/dist/{c-3YAGKCPU.min.js → c-YEB6Z35F.min.js} +1 -1
  65. package/dist/c-YWZBFG63.min.js +1 -0
  66. package/dist/c-ZMYO3NZU.min.js +2 -0
  67. package/dist/c-ZO36H5VH.min.js +48 -0
  68. package/dist/components/LinkedCharts.d.ts +6 -1
  69. package/dist/components/Tooltip/Tooltip.d.ts +11 -1
  70. package/dist/components/Tooltip/tooltipChrome.d.ts +8 -2
  71. package/dist/components/bundling/semioticVite.d.ts +24 -0
  72. package/dist/components/charts/physics/cruciblePhysics.d.ts +2 -2
  73. package/dist/components/charts/physics/gauntletPhysics.d.ts +2 -6
  74. package/dist/components/charts/physics/physicsHocUtils.d.ts +8 -1
  75. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +2 -0
  76. package/dist/components/charts/shared/chartSize.d.ts +58 -0
  77. package/dist/components/charts/shared/chartSizeDefaults.d.ts +189 -0
  78. package/dist/components/charts/shared/chartSizeDefaultsAtlas.d.ts +9 -0
  79. package/dist/components/charts/shared/chartSizeDefaultsNetwork.d.ts +29 -0
  80. package/dist/components/charts/shared/chartSizeDefaultsOrdinal.d.ts +13 -0
  81. package/dist/components/charts/shared/chartSizeDefaultsPhysics.d.ts +41 -0
  82. package/dist/components/charts/shared/chartSizeDefaultsValue.d.ts +19 -0
  83. package/dist/components/charts/shared/chartSizeDefaultsXY.d.ts +10 -0
  84. package/dist/components/charts/shared/networkPerspectiveWireSchema.d.ts +3 -0
  85. package/dist/components/charts/shared/useChartSetup.d.ts +3 -0
  86. package/dist/components/charts/shared/useCustomChartSetup.d.ts +4 -0
  87. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +2 -0
  88. package/dist/components/charts/shared/withChartWrapper.d.ts +6 -2
  89. package/dist/components/charts/value/BigNumber.d.ts +0 -8
  90. package/dist/components/charts/xy/minimapLayout.d.ts +10 -0
  91. package/dist/components/realtime/BinAccumulator.d.ts +5 -2
  92. package/dist/components/recipes/atlas/dependencyForestChartProps.d.ts +4 -4
  93. package/dist/components/recipes/atlas/flowCircuitChartProps.d.ts +177 -1
  94. package/dist/components/recipes/atlas/flowCircuitLayout.d.ts +3 -0
  95. package/dist/components/recipes/atlas/motifBraidChartProps.d.ts +2 -0
  96. package/dist/components/recipes/atlas/resolution/BoundaryLoomChart.d.ts +3 -0
  97. package/dist/components/recipes/atlas/resolution/ComponentCutaway.d.ts +16 -0
  98. package/dist/components/recipes/atlas/resolution/ResolutionAtlasChart.d.ts +3 -0
  99. package/dist/components/recipes/atlas/resolution/ResolutionGlyphs.d.ts +15 -0
  100. package/dist/components/recipes/atlas/resolution/ResolutionReader.d.ts +5 -0
  101. package/dist/components/recipes/atlas/resolution/appearance.d.ts +58 -0
  102. package/dist/components/recipes/atlas/resolution/boundaryLoomLayout.d.ts +4 -0
  103. package/dist/components/recipes/atlas/resolution/chartProps.d.ts +75 -0
  104. package/dist/components/recipes/atlas/resolution/componentCutawayLayout.d.ts +12 -0
  105. package/dist/components/recipes/atlas/resolution/cutawayContext.d.ts +23 -0
  106. package/dist/components/recipes/atlas/resolution/cutawayGraph.d.ts +4 -0
  107. package/dist/components/recipes/atlas/resolution/cycles.d.ts +7 -0
  108. package/dist/components/recipes/atlas/resolution/evidence.d.ts +43 -0
  109. package/dist/components/recipes/atlas/resolution/glyphs.d.ts +40 -0
  110. package/dist/components/recipes/atlas/resolution/identity.d.ts +4 -0
  111. package/dist/components/recipes/atlas/resolution/indexGraph.d.ts +32 -0
  112. package/dist/components/recipes/atlas/resolution/ownership.d.ts +25 -0
  113. package/dist/components/recipes/atlas/resolution/plan.d.ts +12 -0
  114. package/dist/components/recipes/atlas/resolution/ports.d.ts +44 -0
  115. package/dist/components/recipes/atlas/resolution/prepare.d.ts +4 -0
  116. package/dist/components/recipes/atlas/resolution/project.d.ts +70 -0
  117. package/dist/components/recipes/atlas/resolution/queries.d.ts +23 -0
  118. package/dist/components/recipes/atlas/resolution/resolutionAtlasLayout.d.ts +9 -0
  119. package/dist/components/recipes/atlas/resolution/rules.d.ts +14 -0
  120. package/dist/components/recipes/atlas/resolution/scene.d.ts +52 -0
  121. package/dist/components/recipes/atlas/resolution/selection.d.ts +3 -0
  122. package/dist/components/recipes/atlas/resolution/sets.d.ts +10 -0
  123. package/dist/components/recipes/atlas/resolution/types.d.ts +401 -0
  124. package/dist/components/recipes/atlas/resolution/validate.d.ts +4 -0
  125. package/dist/components/recipes/atlas/resolution/witnesses.d.ts +18 -0
  126. package/dist/components/recipes/atlas/resolution/worker.d.ts +34 -0
  127. package/dist/components/recipes/lineageDag.d.ts +4 -0
  128. package/dist/components/recipes/recipeUtils.d.ts +2 -0
  129. package/dist/components/recipes/transitDiagram.d.ts +2 -61
  130. package/dist/components/recipes/transitDiagramTypes.d.ts +65 -0
  131. package/dist/components/semiotic-ai.d.ts +2 -0
  132. package/dist/components/semiotic-experimental-network-resolution-react.d.ts +12 -0
  133. package/dist/components/semiotic-experimental-network-resolution.d.ts +13 -0
  134. package/dist/components/semiotic-geo.d.ts +1 -1
  135. package/dist/components/semiotic-network-perspective-core.d.ts +6 -0
  136. package/dist/components/semiotic-network.d.ts +1 -1
  137. package/dist/components/semiotic-ordinal.d.ts +1 -1
  138. package/dist/components/semiotic-physics.d.ts +1 -1
  139. package/dist/components/semiotic-realtime-core.d.ts +1 -1
  140. package/dist/components/semiotic-realtime-react.d.ts +2 -0
  141. package/dist/components/semiotic-utils-core.d.ts +3 -1
  142. package/dist/components/semiotic-vite.d.ts +2 -0
  143. package/dist/components/semiotic-xy.d.ts +3 -1
  144. package/dist/components/semiotic.d.ts +3 -1
  145. package/dist/components/server/renderToStaticSVG.d.ts +2 -1
  146. package/dist/components/server/serverChartConfigShared.d.ts +2 -0
  147. package/dist/components/store/LinkedCrosshairStore.d.ts +43 -11
  148. package/dist/components/store/themeCore.d.ts +2 -0
  149. package/dist/components/stream/frameKeyboardNavigation.d.ts +3 -1
  150. package/dist/components/stream/hoverUtils.d.ts +5 -0
  151. package/dist/components/stream/networkCustomLayout.d.ts +3 -0
  152. package/dist/components/stream/networkPerspective.d.ts +2 -0
  153. package/dist/components/stream/networkPerspectiveFit.d.ts +12 -1
  154. package/dist/components/stream/networkPerspectiveSolid.d.ts +1 -1
  155. package/dist/components/stream/networkSceneTypes.d.ts +4 -0
  156. package/dist/components/stream/networkTypes.d.ts +2 -0
  157. package/dist/components/stream/pipelineConfig.d.ts +2 -0
  158. package/dist/components/stream/pipelineDomainResolution.d.ts +4 -1
  159. package/dist/components/stream/types.d.ts +2 -0
  160. package/dist/components/stream/useFrame.d.ts +2 -0
  161. package/dist/components/stream/xySceneBuilders/types.d.ts +2 -0
  162. package/dist/controls.module.min.js +31 -31
  163. package/dist/geo.min.js +150 -150
  164. package/dist/geo.module.min.js +31 -31
  165. package/dist/network.module.min.js +1 -1
  166. package/dist/ordinal.module.min.js +1 -1
  167. package/dist/physics.module.min.js +1 -1
  168. package/dist/rough.module.min.js +1 -1
  169. package/dist/semiotic-ai-core.min.js +1 -1
  170. package/dist/semiotic-ai-core.module.min.js +1 -1
  171. package/dist/semiotic-ai.d.ts +2 -0
  172. package/dist/semiotic-ai.module.min.js +13 -13
  173. package/dist/semiotic-artifact-react.module.min.js +4 -4
  174. package/dist/semiotic-artifact.min.js +1 -1
  175. package/dist/semiotic-artifact.module.min.js +1 -1
  176. package/dist/semiotic-atlas-selection.module.min.js +1 -1
  177. package/dist/semiotic-atlas.module.min.js +10 -12
  178. package/dist/semiotic-client-cjs-shared.min.js +1078 -925
  179. package/dist/semiotic-client-glyph.module.min.js +2 -2
  180. package/dist/semiotic-client-shared.module.min.js +1 -1
  181. package/dist/semiotic-experimental-auxiliary.module.min.js +8 -9
  182. package/dist/semiotic-experimental-network-resolution-react.d.ts +12 -0
  183. package/dist/semiotic-experimental-network-resolution-react.min.js +2 -0
  184. package/dist/semiotic-experimental-network-resolution-react.module.min.js +89 -0
  185. package/dist/semiotic-experimental-network-resolution.d.ts +13 -0
  186. package/dist/semiotic-experimental-network-resolution.min.js +2 -0
  187. package/dist/semiotic-experimental-network-resolution.module.min.js +2 -0
  188. package/dist/semiotic-experimental-node-auxiliary.module.min.js +9 -10
  189. package/dist/semiotic-geo.d.ts +1 -1
  190. package/dist/semiotic-line.module.min.js +1 -1
  191. package/dist/semiotic-network-perspective-core.d.ts +6 -0
  192. package/dist/semiotic-network-perspective-core.min.js +1 -0
  193. package/dist/semiotic-network-perspective-core.module.min.js +1 -0
  194. package/dist/semiotic-network-perspective.module.min.js +1 -1
  195. package/dist/semiotic-network-placement.min.js +4 -0
  196. package/dist/semiotic-network-placement.module.min.js +4 -0
  197. package/dist/semiotic-network-zoom.module.min.js +1 -1
  198. package/dist/semiotic-network.d.ts +1 -1
  199. package/dist/semiotic-ordinal.d.ts +1 -1
  200. package/dist/semiotic-physics.d.ts +1 -1
  201. package/dist/semiotic-realtime-core.d.ts +1 -1
  202. package/dist/semiotic-realtime-core.module.min.js +1 -1
  203. package/dist/semiotic-realtime-react.d.ts +2 -0
  204. package/dist/semiotic-realtime-react.module.min.js +1 -1
  205. package/dist/semiotic-recipes-core-cjs-base.min.js +101 -106
  206. package/dist/semiotic-recipes-core.module.min.js +75 -76
  207. package/dist/semiotic-server-edge-node.module.min.js +391 -392
  208. package/dist/semiotic-server-edge.min.js +387 -388
  209. package/dist/semiotic-server-edge.module.min.js +371 -371
  210. package/dist/semiotic-server-node.min.js +387 -388
  211. package/dist/semiotic-server-node.module.min.js +1 -1
  212. package/dist/semiotic-utils-core.d.ts +3 -1
  213. package/dist/semiotic-utils-core.min.js +12 -11
  214. package/dist/semiotic-utils-core.module.min.js +12 -11
  215. package/dist/semiotic-value.module.min.js +4 -4
  216. package/dist/semiotic-vite.d.ts +2 -0
  217. package/dist/semiotic-vite.min.js +1 -0
  218. package/dist/semiotic-vite.module.min.js +1 -0
  219. package/dist/semiotic-xy.d.ts +3 -1
  220. package/dist/semiotic.d.ts +3 -1
  221. package/dist/semiotic.module.min.js +12 -12
  222. package/dist/server.min.js +387 -388
  223. package/dist/server.module.min.js +1 -1
  224. package/dist/xy.module.min.js +1 -1
  225. package/package.json +42 -13
  226. package/dist/c-2AB65V3L.min.js +0 -1
  227. package/dist/c-2U5JMOPN.min.js +0 -88
  228. package/dist/c-3DCTIRW4.min.js +0 -1
  229. package/dist/c-3OKFRTYM.min.js +0 -1
  230. package/dist/c-3VZHOPFW.min.js +0 -1
  231. package/dist/c-4ZSQIBC7.min.js +0 -1
  232. package/dist/c-5M4RUS7V.min.js +0 -34
  233. package/dist/c-6O5WWP7F.min.js +0 -1
  234. package/dist/c-73TOIYIW.min.js +0 -48
  235. package/dist/c-AE4M7BWH.min.js +0 -1
  236. package/dist/c-AEIK2NFW.min.js +0 -30
  237. package/dist/c-AFQSEIZ4.min.js +0 -4
  238. package/dist/c-BBX7DVVB.min.js +0 -51
  239. package/dist/c-CNYFCSG4.min.js +0 -5
  240. package/dist/c-E6QH2WYE.min.js +0 -1
  241. package/dist/c-GOMQWQJR.min.js +0 -1
  242. package/dist/c-GTYG4PDT.min.js +0 -1
  243. package/dist/c-H23GIKTK.min.js +0 -1
  244. package/dist/c-HQLUUSRJ.min.js +0 -1
  245. package/dist/c-HXUOFDSD.min.js +0 -64
  246. package/dist/c-L3LKYOLK.min.js +0 -1
  247. package/dist/c-MIKDFGKH.min.js +0 -1
  248. package/dist/c-OYSPTIAG.min.js +0 -1
  249. package/dist/c-PWPJNYQP.min.js +0 -1
  250. package/dist/c-QZ5SWKHC.min.js +0 -392
  251. package/dist/c-RXJH4IRX.min.js +0 -41
  252. package/dist/c-SN2D6QMH.min.js +0 -1
  253. package/dist/c-U5YGK6HL.min.js +0 -1
  254. package/dist/c-VIN5ASK2.min.js +0 -37
  255. package/dist/c-XZ3GASUJ.min.js +0 -1
  256. package/dist/c-ZLZZTH4I.min.js +0 -118
@@ -1,371 +1,371 @@
1
- import{A as e,B as t,C as i,D as r,E as o,F as n,G as a,H as s,a as l,d as c,i as u,j as d,k as h,l as f,m as p,n as g,o as m,p as y,q as x,r as b,s as v,t as w,u as k,v as A,w as S,x as M,y as $,z as _}from"./c-NSVENB5K.min.js";import{a as L,b as P,c as I,d as R,k as T}from"./c-QIVKWHDL.min.js";import{a as C}from"./c-LPX4CNQZ.min.js";import{a as N,b as F}from"./c-HQLUUSRJ.min.js";import{a as z,l as E,n as D}from"./c-SN2D6QMH.min.js";import{b as O,c as j,d as W,e as B,f as Y,x as G,y as X}from"./c-O53GOO7H.min.js";import{a as V,b as q,c as H,e as U,f as Z,g as Q}from"./c-FOTTQHOO.min.js";import{Q as K,U as J,V as ee,W as te,Z as ie,_ as re,a as oe,b as ne,c as ae,ca as se,d as le,da as ce,e as ue,ea as de,f as he,fa as fe,g as pe,ga as ge,h as me,ha as ye,i as xe,ia as be,j as ve,ja as we,ka as ke,p as Ae,pa as Se,q as Me,qa as $e,r as _e,ra as Le,s as Pe,ta as Ie,ua as Re,va as Te,wa as Ce}from"./c-AEIK2NFW.min.js";import{a as Ne,b as Fe,c as ze,d as Ee,e as De}from"./c-5CI6XDJG.min.js";import{a as Oe}from"./c-RHDOOQ4X.min.js";import{b as je,c as We,e as Be,h as Ye,j as Ge,k as Xe,l as Ve}from"./c-JY4ZN6AO.min.js";import{b as qe}from"./c-2CKIGFD2.min.js";import{a as He}from"./c-CRTZRHCC.min.js";function Ue(e){let t=e?.find(e=>"bottom"===e.orient),i=e?.find(e=>"top"===e.orient),r=e?.find(e=>"left"===e.orient),o=e?.find(e=>"right"===e.orient);return{bottomAxis:t,topAxis:i,leftAxis:r,rightAxis:o,xAxis:t??i,yAxis:r??o,xOrient:t||!i?"bottom":"top",yOrient:r||!o?"left":"right"}}function Ze(e){let t=6;for(let i=1;i<e.length;i++){let r=Math.abs(e[i]-e[i-1]);if(r>0&&Number.isFinite(r)){let o=Math.max(Math.abs(e[i]),Math.abs(e[i-1]));t=Math.max(t,Math.ceil(Math.log10(o/r))+1)}}let i=Math.min(17,t);return e=>Number.isInteger(e)?String(e):String(Number(e.toPrecision(i)))}function Qe(...e){let t;for(let i of e)i&&(t=Ke(t)&&Ke(i)?{legendGroups:[...t.legendGroups,...i.legendGroups],legendDistance:i.legendDistance??t.legendDistance}:i);return t}function Ke(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function Je(e){return"object"==typeof e&&null!==e&&"gradient"in e}function et(e){return"string"==typeof e&&e.length>0}function tt(e,t){let i=t?36:0;return e.top>=i?e:{...e,top:i}}function it(e,t){return tt(e,et(t))}function rt(e,t,i,r,o=8){let n="left"===r||"right"===r,a=r,s="left"===r?"right":"right"===r?"left":"top"===r?"bottom":"top",l=Math.max(0,(n?i[0]:i[1])-o),c=Math.max(t[a],l-e[s]);e[a]>c&&(e[a]=c)}function ot(e){return Math.ceil(7*e.length)}function nt(e,t){if(Ke(e)){let i=xt(t),r=100;for(let t of e.legendGroups){t.label&&(r=Math.max(r,ot(t.label)));for(let e of t.items)r=Math.max(r,i.swatchSize+i.labelGap+ot(e.label))}return r}if(Je(e)){let{gradient:t}=e,i=t.format||Ze(t.domain),r=Math.max(ot(i(t.domain[0])),ot(i(t.domain[1]))),o=t.label?ot(t.label):0;return Math.max(100,19+r,o)}return 100}function at(e){return(Ke(e)||Je(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):10}function st(e,t){return null!=e?.sideGutter?Math.max(0,e.sideGutter):t?.hasAxis?t.hasAxisLabel?ut:ct:0}function lt(e){return Math.max(0,e?.edgeGutter??3)}var ct=34,ut=70;function dt(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?64:46:22:0}function ht(e){let{bottomAxis:t,topAxis:i,leftAxis:r,rightAxis:o}=Ue(e.axes),n=!(i&&!t||!1===t?.visible),a=!!i&&!t&&!1!==i.visible,s=!(o&&!r||!1===r?.visible),l=!!o&&!1!==o.visible,c=!1!==e.showAxes;return{hasAxis:c&&n,hasAxisLabel:c&&n&&!!(t?.label??e.xLabel),rotatedTicks:c&&n&&(e.rotatedTicks??!!t?.autoRotate),topAxis:a?{hasAxis:c,hasAxisLabel:c&&!!(i?.label??e.xLabel),rotatedTicks:c&&(e.rotatedTicks??!!i?.autoRotate)}:void 0,leftAxis:s?{hasAxis:c,hasAxisLabel:c&&!!(r?.label??e.yLabel)}:void 0,rightAxis:l?{hasAxis:c,hasAxisLabel:c&&!!(o?.label??e.yLabelRight??e.yLabel)}:void 0}}function ft(e){let t=e.projection??"vertical",i=!1!==e.showAxes&&"radial"!==t;return{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasValueLabel:e.hasCategoryLabel),leftAxis:{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasCategoryLabel:e.hasValueLabel)}}}function pt(e,t,i){if(Je(e))return e.gradient.label?46:26;if(!Ke(e))return 20;let r=xt(i),o=Math.max(1,i?.maxWidth??t),n=r.rowHeight;for(let t of e.legendGroups){let e=0,i=0;for(let n of t.items){let t=r.swatchSize+r.labelGap+ot(n.label),a=0===i?t:i+r.itemGap+t;i>0&&a>o?(e+=1,i=t):i=a}t.items.length>0&&(e+=1),n=Math.max(n,e*r.rowHeight,t.label?ot(t.label):0)}return n+(e.legendGroups.length>1?16:0)}function gt(e,t,i){return nt(e,t)+at(e)+st(t,i)+lt(t)}function mt(e,t){let{legend:i}=t;if(!i)return;let r=t.position??"right",o=pt(i,Math.max(1,t.size[0]-e.left-e.right),t.legendLayout)+at(i)+dt("bottom"===r?t.axisChrome:"top"===r?t.axisChrome?.topAxis:void 0,t.legendLayout)+("top"===r&&t.hasTitle?24:0),n=Math.max(t.minimumMargin??0,"top"===r?t.hasTitle?58:34:0);"right"===r?e.right=Math.max(e.right,n,gt(i,t.legendLayout,t.axisChrome?.rightAxis)):"left"===r?e.left=Math.max(e.left,n,gt(i,t.legendLayout,t.axisChrome?.leftAxis)):"top"===r?e.top=Math.max(e.top,n,o):e.bottom=Math.max(e.bottom,n,o)}function yt(e,t){let i=t.position??"right",r="top"===i||"bottom"===i,o=Math.max(0,t.totalWidth-t.margin.left-t.margin.right),n=Math.max(1,r?t.legendLayout?.maxWidth??o:t.reservedWidth??nt(e,t.legendLayout)),a=at(e),s=st(t.legendLayout,"left"===i?t.axisChrome?.leftAxis:t.axisChrome?.rightAxis),l=lt(t.legendLayout),c=pt(e,o,t.legendLayout),u=dt(t.axisChrome,t.legendLayout),d=dt(t.axisChrome?.topAxis,t.legendLayout);if("left"===i)return{x:Math.max(l,t.margin.left-s-n-a),y:t.margin.top,width:n,height:c};if("top"===i)return{x:t.margin.left,y:t.margin.top-d-a-c,width:n,height:c};if("bottom"===i){let e=t.totalHeight-t.margin.bottom;return{x:t.margin.left,y:Math.max(e+a,Math.min(e+u+a,t.totalHeight-c)),width:n,height:c}}return{x:Math.min(t.totalWidth-n-l,t.totalWidth-t.margin.right+s+a),y:t.margin.top,width:n,height:c}}function xt(e){let t=Math.max(1,e?.swatchSize??16),i=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:i,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function bt(e,t){let i=24;return e.map(({hasLabel:e,itemCount:r})=>{i+=5;let o,n=i;i+=8,e&&(i+=16,o=i,i+=8);let a=i;return i+=r*t+8,{lineY:n,labelY:o,itemsY:a,endY:i}})}function vt(e,t,i=!1){let r={...e};for(let e of t??[])!1===e.visible&&("top"!==e.orient||!i)&&(r[e.orient]=0);return r}var wt=/\s+([^\s=<>/'"]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;function kt(e){let t=0;for(;t<e.length;){let i=/^\s+/.exec(e.slice(t));i&&(t+=i[0].length);let r=e.startsWith("\x3c!--",t)?"--\x3e":e.startsWith("<?",t)?"?>":void 0;if(r){let i=e.indexOf(r,t+2);if(i<0)return;t=i+r.length;continue}if(/^<!DOCTYPE\s/i.test(e.slice(t))){let i="",r=0,o=t+9;for(;o<e.length;o+=1){let t=e[o];if(i)t===i&&(i="");else if(e.startsWith("\x3c!--",o)){let t=e.indexOf("--\x3e",o+4);if(t<0)return;o=t+2}else if('"'===t||"'"===t)i=t;else if("["===t)r+=1;else if("]"===t)r-=1;else if(">"===t&&0===r)break}if(o===e.length)return;t=o+1;continue}break}let i=/^<((?:[A-Za-z_][\w.-]*:)?svg)(?=[\s/>])((?:[^<>"']|"[^"]*"|'[^']*')*)>/i.exec(e.slice(t));if(!i)return;let r=i[2].endsWith("/"),o=r?i[2].slice(0,-1):i[2];return o.replace(wt,"").trim()?void 0:{start:t,end:t+i[0].length,name:i[1],attributes:o,selfClosing:r}}function At(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\t/g,"&#9;").replace(/\n/g,"&#10;").replace(/\r/g,"&#13;")}function St(e){return e.replace(/\r\n|[\t\r\n]/g," ").replace(/&(amp|quot|apos|lt|gt|#\d+|#x[\da-fA-F]+);/g,(e,t)=>{if(!t.startsWith("#"))return{amp:"&",quot:'"',apos:"'",lt:"<",gt:">"}[t];let i=t.startsWith("#x")?parseInt(t.slice(2),16):Number(t.slice(1));return i>0&&i<=1114111?String.fromCodePoint(i):e})}function Mt(e,t){for(let i of e.attributes.matchAll(wt))if(i[1]===t)return St(i[2]??i[3])}function $t(e,t){let i=kt(e)?.start??0;return e.slice(0,i)+e.slice(i).replace(/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<\?[\s\S]*?(?:\?>|$)|<([A-Za-z_][\w.:-]*)(?=[\s/>])(?:[^<>"']|"[^"]*"|'[^']*')*>/g,(e,i)=>i?e.replace(wt,(e,i,r,o)=>{let n=t(i,St(r??o));return void 0===n?e:` ${i}="${At(n)}"`}):e)}function _t(e,t){let i=kt(e);if(!i)return e;let r=new Map(Object.entries(t)),o=i.attributes.replace(wt,(e,t)=>{let i=r.get(t);return void 0===i?e:(r.delete(t),` ${t}="${At(i)}"`)});for(let[e,t]of r)o+=` ${e}="${At(t)}"`;return`${e.slice(0,i.start)}<${i.name}${o}${i.selfClosing?"/":""}>${e.slice(i.end)}`}function Lt(e,t){let i=kt(e);if(!i)return t;let r=e=>{let r=Mt(i,e),o=r&&/^[0-9]+(?:\.[0-9]+)?$/.test(r)?Number(r):NaN;return Number.isFinite(o)&&o>0?o:t[e]};return{width:r("width"),height:r("height")}}function Pt(e,t){let i=kt(e);return i?_t(e,{width:"100%",height:"100%",...void 0===Mt(i,"viewBox")?{viewBox:`0 0 ${t.width} ${t.height}`}:{},...void 0===Mt(i,"preserveAspectRatio")?{preserveAspectRatio:"xMidYMid meet"}:{}}):e}function It(e,t){return l({kind:"semiotic.rendered-svg-scene",version:2,svg:e,frameType:t.frameType,width:t.width,height:t.height,margin:t.margin,plot:t.plot,xDomain:t.xDomain,yDomain:t.yDomain,categories:t.categories})}function Rt(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Tt(e){if(!("number"!=typeof e.height||e.height<=0))return e.width>=e.height?"landscape":"portrait"}function Ct(e){if(!("number"!=typeof e.height||e.height<=0))return e.width/e.height}function Nt(e,t){let{when:i}=e,r=t.width,o=t.height,n=Ct(t),a=Tt(t);return!("number"==typeof i.minWidth&&r<i.minWidth||"number"==typeof i.maxWidth&&r>i.maxWidth||"number"==typeof i.minHeight&&("number"!=typeof o||o<i.minHeight)||"number"==typeof i.maxHeight&&("number"!=typeof o||o>i.maxHeight)||"number"==typeof i.minAspectRatio&&("number"!=typeof n||n<i.minAspectRatio)||"number"==typeof i.maxAspectRatio&&("number"!=typeof n||n>i.maxAspectRatio)||i.orientation&&a!==i.orientation)}function Ft(e,t){let i={...e,...t};for(let r of["margin","frameProps","mobileSemantics","style"])Rt(e[r])&&Rt(t[r])&&(i[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(i.className=`${e.className} ${t.className}`),i}function zt(e,t,i=e.responsiveRules){if(!Array.isArray(i)||0===i.length)return{props:e,matches:[]};let r=i.map((e,t)=>({rule:e,index:t})).filter(e=>Nt(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>Ft(e,t.rule.transform),e),matches:r}}var Et={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Dt(e,t={}){let i=t.mobileSemantics?.interaction,r="number"==typeof i?.targetSize?i.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&t.width<=480,n=!!i||void 0!==r,a=e&&"object"==typeof e?e:void 0;if(!1===e||!1===a?.enabled||void 0===e&&!o&&!n)return Et;let s=a??{};return{enabled:!0,tapToSelect:s.tapToSelect??!0,tapToLockTooltip:s.tapToLockTooltip??!0,clearSelection:s.clearSelection??"backgroundTap",targetSize:s.targetSize??r??44,snap:s.snap??"nearestDatum",brushHandleSize:s.brushHandleSize??44,standardControls:s.standardControls??!1}}var Ot={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function jt(e){return"string"==typeof e&&Object.prototype.hasOwnProperty.call(Ot,e)}function Wt(e,t,i){let r=Ot[e||"primary"],o=e&&"primary"!==e||!i?.width?r.width:i.width,n=e&&"primary"!==e||!i?.height?r.height:i.height,a=zt({...t,mode:e},{width:t.width??o,height:t.height??n}).props,s=a.mode||e||"primary",l=Ot[s],c="context"===s||"sparkline"===s,u="primary"===s&&i?.width?i.width:l.width,d="primary"===s&&i?.height?i.height:l.height;return{mode:s,width:a.width??u,height:a.height??d,showAxes:a.showAxes??l.showAxes,showGrid:a.showGrid??l.showGrid,enableHover:a.enableHover??(!!a.linkedHover||l.enableHover),showLegend:a.showLegend??l.showLegend,showLabels:a.showLabels??l.showLabels,title:c?void 0:a.title,description:a.description,summary:a.summary,accessibleTable:a.accessibleTable,xLabel:c?void 0:a.xLabel,yLabel:c?void 0:a.yLabel,categoryLabel:c?void 0:a.categoryLabel,valueLabel:c?void 0:a.valueLabel,marginDefaults:Bt(l.marginDefaults,a.showCategoryTicks,a.orientation),compactMode:c,mobileInteraction:Dt(a.mobileInteraction,{mode:s,width:a.width??u,mobileSemantics:a.mobileSemantics}),mobileSemantics:a.mobileSemantics}}function Bt(e,t,i){if(!1!==t)return e;let r={...e};return"horizontal"===i?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}function Yt(e){return e instanceof Date?`date:${e.getTime()}`:`${typeof e}:${String(e)}`}var Gt={kind:"rank-competition"};function Xt(e,t,i,r){let o=e??t;return"function"==typeof o?o(i,r):i[String(o)]}function Vt(e){let t=/* @__PURE__ */new Map;(Array.isArray(e.data)?e.data:[]).forEach((i,r)=>{if(!Number.isFinite(Number(Xt(e.yAccessor,"y",i,r))))return;let o=Yt(Xt(e.xAccessor,"x",i,r)),n=t.get(o)??/* @__PURE__ */new Set;n.add(String(Xt(e.lineBy,"series",i,r))),t.set(o,n)});let i=Array.from(t.values(),e=>e.size).sort((e,t)=>e-t);if(0===i.length)return[];let r=Math.floor(i.length/2),o={columns:i.length,median:i.length%2?i[r]:(i[r-1]+i[r])/2,max:i[i.length-1],contestedColumns:i.filter(e=>e>=2).length},n=o.max<2;return!n&&o.contestedColumns>=2&&o.median>=2?[]:[{code:n?"BUMP_NO_RANK_COMPETITION":"BUMP_SPARSE_RANK_COMPETITION",severity:n?"error":"warning",message:n?"Every ranking column contains one series, so every trajectory remains at rank 1.":"Too few ranking columns contain competing series for reliable rank movement.",fix:"Use a lineBy field with repeated series across shared x columns, or choose a value-based chart.",metrics:{...o}}]}var qt=/* @__PURE__ */Symbol.for("semiotic.semantic-viability"),Ht=globalThis;function Ut(){return Ht[qt]}function Zt(e){return Ut()?.has(e)??!1}function Qt(e){return Ut()?.get(e)}function Kt(e){return Zt(e)?Qt(e):"BumpChart"===e?Gt:void 0}function Jt(e){return"string"==typeof e?.code&&e.code.length>0&&("warning"===e.severity||"error"===e.severity)&&"string"==typeof e.message&&e.message.length>0}function ei(e,t,i){if(e.semanticDiagnostics=[],e.semanticStatus="not-assessed",e.empty)return;let r,o=Kt(t);if(o){try{let t="function"==typeof o?o(i,e):Vt(i);r=Array.from(t).filter(Jt)}catch{return void(e.warnings.includes("SEMANTIC_VIABILITY_CHECK_FAILED")||e.warnings.push("SEMANTIC_VIABILITY_CHECK_FAILED"))}e.semanticDiagnostics=r,e.semanticStatus=r.some(e=>"error"===e.severity)?"degenerate":r.some(e=>"warning"===e.severity)?"degraded":"meaningful";for(let t of r)e.warnings.includes(t.code)||e.warnings.push(t.code)}}function ti(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};let t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}import*as ii from"react-dom/server";function ri(e,t,i){let r="function"==typeof t?t(e):e[String(t??i)];if(null==r||"string"==typeof r&&""===r.trim())return null;let o=Number(r);return Number.isFinite(o)?o:null}function oi(e,t,i){let r="function"==typeof t?t(e):e[String(t??i)];if(null==r||"string"==typeof r&&""===r.trim())return null;if(r instanceof Date)return Number.isFinite(r.getTime())?r:null;if("string"==typeof r){let e=d(r);if(Number.isFinite(e))return new Date(e)}let o=Number(r);return Number.isFinite(o)?o:null}import*as ni from"react";function ai({data:e,safeData:t,areaBy:i,lineDataAccessor:r}){if(null==e)return[];let o,n=void 0!==t[0]?.[r];if(!n&&!i)return t;if(n)o=t;else{let e=t.reduce((e,t)=>{let o="function"==typeof i?i(t):t[i],n=String(o);if(!e[n]){let t={[r]:[]};"string"==typeof i&&(t[i]=o),e[n]=t}return e[n][r].push(t),e},{});o=Object.values(e)}return o.flatMap(e=>{let t=Array.isArray(e[r])?e[r]:[];return"string"==typeof i?t.map(t=>({...t,[i]:t[i]??e[i]})):t})}var si=Object.freeze([]);function li(e){if(!e)return si;let t=!1;for(let i=0;i<e.length;i++){let r=e[i];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;let i=[];for(let t of e)null!=t&&"object"==typeof t&&i.push(t);return i}import{scaleOrdinal as ci}from"d3-scale";function ui(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function di(e,t,i){let r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(i)}`}function hi(e){let t=e.map(ui),i=t.length-1;return e=>{if(Number.isNaN(e)&&(e=0),e<=0){let[e,i,r]=t[0];return di(e,i,r)}if(e>=1){let[e,r,o]=t[i];return di(e,r,o)}let r=e*i,o=Math.floor(r),n=r-o,[a,s,l]=t[o],[c,u,d]=t[o+1];return di(Math.round(a+(c-a)*n),Math.round(s+(u-s)*n),Math.round(l+(d-l)*n))}}var fi=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],pi=/* @__PURE__ */hi(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),gi=/* @__PURE__ */hi(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),mi=/* @__PURE__ */hi(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),yi=/* @__PURE__ */hi(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),xi=/* @__PURE__ */hi(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),bi=/* @__PURE__ */hi(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),vi=/* @__PURE__ */hi(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),wi={blues:pi,reds:gi,greens:mi,viridis:vi,oranges:yi,purples:xi,greys:bi,plasma:/* @__PURE__ */hi(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),inferno:/* @__PURE__ */hi(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),magma:/* @__PURE__ */hi(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),cividis:/* @__PURE__ */hi(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),turbo:/* @__PURE__ */hi(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"])};function ki(e){return e&&Object.prototype.hasOwnProperty.call(wi,e)?wi[e]:pi}var Ai=/* @__PURE__ */hi(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Si=/* @__PURE__ */hi(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Mi=/* @__PURE__ */hi(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),$i=/* @__PURE__ */hi(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),_i=/* @__PURE__ */hi(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Li=/* @__PURE__ */hi(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Pi=/* @__PURE__ */hi(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),Ii={category10:fi,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...wi},Ri=fi,Ti="#007bff";function Ci(e,t,i=Ri){if(e&&"object"==typeof e&&!Array.isArray(e)){let t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){let t=Object.prototype.hasOwnProperty.call(Ii,e)?Ii[e]:void 0;if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:i}var Ni=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Fi=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],zi=/* @__PURE__ */new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function Ei(e){let t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||zi.has(t)}function Di(e,t,i){if("function"==typeof t){let r=t(e);return i&&r&&"string"==typeof r&&!Ei(r)?i(r):r}let r=String(e?.[t]);return i?i(r):Ri[Math.abs(Wi(r))%Ri.length]}function Oi(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;let i=e[t];return"string"==typeof i&&i.length>0?i:void 0}function ji(e,t,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){let e=i;return t=>Oi(e,t)??"#999"}let r=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>String(e)))),o=r.every(e=>!isNaN(Number(e)));if(Array.isArray(i))return ci().domain(r).range(i).unknown("#999");let n=Object.prototype.hasOwnProperty.call(Ii,i)?Ii[i]:Ii.category10;if(o&&"function"==typeof n){let e=-1/0;for(let t of r){let i=Number(t);i>e&&(e=i)}return t=>n(0===e?0:Number(t)/e)}{let e=Array.isArray(n)?n:Ri;return ci().domain(r).range(e).unknown("#999")}}function Wi(e){let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t&=t;return Math.abs(t)}function Bi(e,t,i=[3,20],r){let o;if(o="function"==typeof t?t(e):e?.[t],!r)return o;let[n,a]=r,[s,l]=i;if(a===n)return(s+l)/2;let c=(o-n)/(a-n);return c<0?c=0:c>1&&(c=1),s+c*(l-s)}function Yi(e,t,i,r,o){if(e)return e;if(i&&"object"==typeof i&&!Array.isArray(i)){let e=Oi(i,r);if(e)return e}let n;if(Array.isArray(i))n=i;else if(t&&t.length>0)n=t;else if("string"==typeof i){let e=Ii[i];Array.isArray(e)&&(n=e)}return n&&0!==n.length?null!=r?(o.has(r)||o.set(r,o.size),n[o.get(r)%n.length]):n[0]:Ti}function Gi(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}function Xi(e,t){if(!Gi(t))return e??((...e)=>({}));let i={};return void 0!==t.stroke&&(i.stroke=t.stroke),void 0!==t.strokeWidth&&(i.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(i.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...i}):(...e)=>({...i})}function Vi(e){let{lineWidth:t=2,colorBy:i,colorScale:r,color:o,resolveStroke:n,fillArea:a,areaOpacity:s=.3,styleRules:l,ruleContext:c}=e;return(e,u)=>{let d,h={strokeWidth:t},f=!0===a||Array.isArray(a)&&null!=u&&a.includes(u);return n?d=n(e,u):i?r&&(d=Di(e,i,r)):d=o||Ti,void 0!==d&&(h.stroke=d,f&&(h.fill=d,h.fillOpacity=s)),l?.length&&Object.assign(h,U(e,l,c?c(e,u):{value:void 0,category:u})),h}}function qi(e,t,i,r){if(!e.length)return[];let o=e.filter(e=>Number.isFinite(t(e))).sort((e,i)=>t(e)-t(i)),n=[],a=0,s=null,l=null,c=[],u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${a}-${e}`,h=e=>n.push(e),f=(e,t)=>{h({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;e<o.length;e++){let n=o[e],p=t(n),g=i(n),m=r(n);if(!Number.isFinite(p)||!Number.isFinite(g)||!Number.isFinite(m))continue;let y=u(g,m);if(null!==y){if(null==s){s=y;for(let e of c)f(e,s);c=[],h({__x:p,__y:g>=m?g:m,__y0:g>=m?m:g,__diffSegment:d(s),__diffWinner:s,__valA:g,__valB:m,__sourceDatum:n}),l={x:p,a:g,b:m,w:y};continue}if(l&&l.w!==y){let e,t;if(c.length>0)e=c[0].x,t=c[0].y;else{let i=g-l.a-(m-l.b);if(0!==i){let r=(l.b-l.a)/i,o=Math.max(0,Math.min(1,r));e=l.x+o*(p-l.x),t=l.a+o*(g-l.a)}else e=l.x,t=l.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t}),a++,s=y,h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t});for(let e=1;e<c.length;e++)f(c[e],s)}else for(let e of c)f(e,s);c=[],h({__x:p,__y:g>=m?g:m,__y0:g>=m?m:g,__diffSegment:d(s),__diffWinner:s,__valA:g,__valB:m,__sourceDatum:n}),l={x:p,a:g,b:m,w:y}}else c.push({x:p,y:g,datum:n})}for(let e of c)f(e,s??"A");return n}function Hi(e){if("A"===e.__diffWinner||"B"===e.__diffWinner)return e.__diffWinner;let t=String(e.__diffSegment??"");return"line-A"===t||t.endsWith("-A")?"A":"B"}function Ui(e,t){return Z(e,t,e=>{let t=Number(e.__x),i=Number(e.__y);return{value:Number.isFinite(i)?i:void 0,x:Number.isFinite(t)?t:void 0,y:Number.isFinite(i)?i:void 0,category:Hi(e)}},e=>e.__sourceDatum?{...e.__sourceDatum,...e}:e)}function Zi(e){let{seriesAColor:t,seriesBColor:i,areaOpacity:r,styleRules:o}=e;return Ui(e=>({fill:"A"===Hi(e)?t:i,stroke:"none",fillOpacity:r}),o)}function Qi(e){let{seriesAColor:t,seriesBColor:i,lineWidth:r,styleRules:o}=e;return Ui(e=>({stroke:"A"===Hi(e)?t:i,strokeWidth:r,fill:"none"}),o)}var Ki={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]};function Ji(e,t=Ki){if(e)return!0===e?t:"stops"in e?Array.isArray(e.stops)?e:void 0:"colorStops"in e?Array.isArray(e.colorStops)?{stops:e.colorStops.map(({offset:e,color:t})=>({offset:e,color:t}))}:void 0:{stops:[{offset:0,opacity:e.topOpacity??t.stops[0]?.opacity??.8},{offset:1,opacity:e.bottomOpacity??t.stops.at(-1)?.opacity??.05}]}}function er(e){return e?Ji(e):void 0}function tr(e){if(e)return Array.isArray(e)?{stops:e.map(({at:e,color:t,opacity:i})=>({offset:e/100,color:t,...null!=i&&{opacity:i}}))}:Array.isArray(e.stops)?e:void 0}function ir(e){let t=e?.stops.filter(e=>"string"==typeof e.color&&Number.isFinite(e.offset)).map(({offset:e,color:t,opacity:i})=>({offset:Math.max(0,Math.min(1,e)),color:t,...Number.isFinite(i)&&{opacity:Math.max(0,Math.min(1,i))}})).sort((e,t)=>e.offset-t.offset);if(!t?.length)return;let i=t[0];return i.offset>0?[{...i,offset:0},...t]:t}function rr(e){return{...e.extent&&{extent:e.extent},stops:e.stops.map(e=>({...e,offset:1-e.offset})).sort((e,t)=>e.offset-t.offset)}}function or(e){return{...rr(e),extent:"domain"}}function nr(e){if(!e)return;let t="boolean"==typeof e?{}:"string"==typeof e?{method:e}:e;return{type:"trend",method:t.method??"linear",...null!=t.bandwidth&&{bandwidth:t.bandwidth},...null!=t.order&&{order:t.order},...null!=t.color&&{color:t.color},...null!=t.strokeWidth&&{strokeWidth:t.strokeWidth},...null!=t.strokeDasharray&&{strokeDasharray:t.strokeDasharray},...null!=t.label&&{label:t.label}}}function ar(e,t,i){return"function"==typeof e?e(i):i[e||t]}function sr(e){return e instanceof Date?e.getTime():Number(e)}function lr(e,t){return vi(1===t?.5:e/(t-1))}function cr(e){let t={};return void 0!==e.stroke&&(t.stroke=e.stroke),void 0!==e.strokeWidth&&(t.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(t.opacity=e.opacity),t}function ur(e,t){let i=nr(t),r=Array.isArray(e)?e:void 0;return i?[i,...r??[]]:r}function dr(e,t){if(!Array.isArray(e))return{data:e,orderMap:/* @__PURE__ */new WeakMap};let i=t.xAccessor||"x",r=t.yAccessor||"y",o=t.orderAccessor?[...e].sort((e,i)=>null==e||"object"!=typeof e?1:null==i||"object"!=typeof i?-1:sr(ar(t.orderAccessor,"order",e))-sr(ar(t.orderAccessor,"order",i))):e,n=/* @__PURE__ */new WeakMap,a=0;for(let e of o){if(null==e||"object"!=typeof e)continue;let t=sr(ar(i,"x",e)),o=sr(ar(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&a++}let s=0;for(let e of o){if(null==e||"object"!=typeof e)continue;let t=sr(ar(i,"x",e)),o=sr(ar(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&n.set(e,{idx:s++,total:a})}return{data:o,orderMap:n}}function hr(e){if(!e)return O;if("string"==typeof e)return"light"===e?O:"dark"===e?j:"high-contrast"===e?W:G(e)||O;let t="dark"===e.mode?j:O,i={...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}};return Y(i)}function fr(e){return{background:e.colors.background,text:e.colors.text,textSecondary:e.colors.textSecondary,grid:e.colors.grid,border:e.colors.border,primary:e.colors.primary,fontFamily:e.typography.fontFamily,titleSize:e.typography.titleSize,labelSize:e.typography.labelSize,tickSize:e.typography.tickSize,categorical:e.colors.categorical,annotation:e.colors.annotation??e.colors.text,legendSize:e.typography.legendSize??e.typography.labelSize,legendFontFamily:e.typography.legendFontFamily??e.typography.fontFamily,legendFontWeight:e.typography.legendFontWeight,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,titleFontFamily:e.typography.titleFontFamily??e.typography.fontFamily,titleFontWeight:e.typography.titleFontWeight??"bold",tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}function pr(e){if(!e.axes)return[{orient:"bottom",visible:!1!==e.showTimeAxis},{orient:"left",visible:!1!==e.showValueAxis}];let t=(...t)=>e.axes.some(e=>t.includes(e.orient)),i=!1===e.showTimeAxis&&!t("bottom","top"),r=!1===e.showValueAxis&&!t("left","right");return i||r?[...e.axes,...i?[{orient:"bottom",visible:!1}]:[],...r?[{orient:"left",visible:!1}]:[]]:e.axes}function gr(e,t,i,r=!1){let o=ht({axes:t,showAxes:i});return{...vt(e,t,r),...!o.hasAxis&&{bottom:0},...!o.leftAxis?.hasAxis&&{left:0}}}function mr(e,t,i="x",r="y"){let o="function"==typeof i?i:e=>e[i],n="function"==typeof r?r:e=>e[r],a="function"==typeof t.colorBy?t.colorBy:e=>e[t.colorBy],s=/* @__PURE__ */new Map;for(let i of e){let e=a(i)??(i.parentLine&&a(i.parentLine));if(null==e||""===String(e))continue;let r=String(e),n=s.get(r);(!n||("end"===t.position?Number(o(i))>Number(o(n)):Number(o(i))<Number(o(n))))&&s.set(r,i)}return[...s].map(([e,a])=>({type:"text",label:e,["string"==typeof i?i:"x"]:o(a),["string"==typeof r?r:"y"]:n(a),x:o(a),y:n(a),_directLabel:{id:e,position:t.position},color:t.color(e),fontSize:t.fontSize}))}function yr(e=[]){let t=e.filter(e=>e._directLabel);return t.length?` Series endpoints: ${t.map(e=>`${e.label}: x ${String(e.x)}, y ${String(e.y)}`).join("; ")}.`:""}function xr(e,t=.5){let i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;let r=Math.round(parseInt(i[1],16)*(1-t)),o=Math.round(parseInt(i[2],16)*(1-t)),n=Math.round(parseInt(i[3],16)*(1-t));return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function br(e,t=.5){let i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;let r=Math.round(parseInt(i[1],16)+(255-parseInt(i[1],16))*t),o=Math.round(parseInt(i[2],16)+(255-parseInt(i[2],16))*t),n=Math.round(parseInt(i[3],16)+(255-parseInt(i[3],16))*t);return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function vr(e){return e instanceof Date&&(e=e.getTime()),"string"==typeof e&&""!==e.trim()&&(e=Number(e)),"number"==typeof e&&Number.isFinite(e)?e:null}function wr(e){let t=[];for(let[i,r]of e){let e=vr(i),o=vr(r);null!==e&&null!==o&&t.push([e,o])}return t.sort((e,t)=>e[0]-t[0])}function kr(){return{points:[],parameterCount:0,predict:()=>NaN,leverage:()=>NaN}}function Ar(e){let t=wr(e);if(!t.length)return{points:[],parameterCount:0,predict:()=>NaN,leverage:()=>NaN};let i=t[0][0],r=t.reduce((e,[r])=>e+(r-i)/t.length,0),o=t.reduce((e,[,i])=>e+i/t.length,0),n=0,a=0;for(let[e,s]of t){let t=e-i-r;n+=t*t,a+=t*(s-o)}let s=0===n?0:a/n,l=e=>o+s*(e-i-r);return{points:t.map(([e])=>[e,l(e)]),parameterCount:2,leverage:e=>1/t.length+(n>0?(e-i-r)**2/n:0),predict:l}}function Sr(e,t=2){let i=wr(e);if(!Number.isInteger(t)||t<0||t>=i.length)return{points:[],parameterCount:0,predict:()=>NaN,leverage:()=>NaN};let r=i[0][0]/2+i[i.length-1][0]/2,o=Math.max(Math.abs(i[0][0]-r),Math.abs(i[i.length-1][0]-r))||1,n=i.map(([e])=>(e-r)/o),a=[],s=Array.from({length:t+1},()=>Array(t+1).fill(0));for(let e=0;e<=t;e++){let t=n.map(t=>t**e);for(let i=0;i<2;i++)for(let i=0;i<e;i++){let r=t.reduce((e,t,r)=>e+t*a[i][r],0);s[i][e]+=r;for(let e=0;e<t.length;e++)t[e]-=r*a[i][e]}let r=Math.sqrt(t.reduce((e,t)=>e+t*t,0));if(!Number.isFinite(r)||r<=Number.EPSILON*i.length)return kr();s[e][e]=r,a.push(t.map(e=>e/r))}let l=a.map(e=>e.reduce((e,t,r)=>e+t*i[r][1],0));for(let e=t;e>=0;e--){for(let i=e+1;i<=t;i++)l[e]-=s[e][i]*l[i];l[e]/=s[e][e]}let c=e=>{let i=(e-r)/o,n=0;for(let e=t;e>=0;e--)n=n*i+l[e];return n};return{points:i.map(([e])=>[e,c(e)]),parameterCount:t+1,predict:c,leverage:e=>{let i=(e-r)/o,n=[];for(let e=0;e<=t;e++){let t=i**e;for(let i=0;i<e;i++)t-=s[i][e]*n[i];n.push(t/s[e][e])}return n.reduce((e,t)=>e+t*t,0)}}}function Mr(e,t,i=2){let r=e.length,o=e.reduce((e,[i,r])=>e+(r-t(i))**2,0);return{se:Math.sqrt(o/Math.max(r-i,1))}}function $r(e){return e>=.99?2.576:e>=.95?1.96:e>=.9?1.645:1}import{scaleLinear as _r}from"d3-scale";function Lr(e,t=.3){if(!Number.isFinite(t)||t<0||t>1)return[];let i=wr(e),r=i.length;if(r<2)return i;let o=i.map(e=>e[0]),n=i.map(e=>e[1]),a=0,s=Math.min(r,Math.max(2,Math.ceil(t*r)))-1,l=[];for(let e=0;e<r;e++){let t=o[e],i=0,c=r-1;for(;s<r-1&&Math.abs(o[s+1]-t)<=Math.abs(o[a]-t);)a++,s++;let u=Math.max(Math.abs(o[a]-t),Math.abs(o[s]-t)),d=u||1;u>0&&(i=a,c=s);let h=0,f=0,p=0,g=0,m=0;for(let e=i;e<=c;e++){let i=Math.abs(o[e]-t)/d,r=i<1?Math.pow(1-Math.pow(i,3),3):0;if(0===r)continue;h+=r;let a=(o[e]-t)/d;f+=r*a,p+=r*n[e],g+=r*a*a,m+=r*a*n[e]}if(0===h){l.push([t,n[e]]);continue}let y=h*g-f*f;if(Math.abs(y)<1e-12)l.push([t,p/h]);else{let e=(p-(h*m-f*p)/y*f)/h;l.push([t,e])}}return l}function Pr(e,t=.3){let i=new Map(Lr(e,t));return i.size<2?null:_r().domain([...i.keys()]).range([...i.values()])}function Ir(e,t){if(e.length<3||e[0][0]===e[e.length-1][0])return null;let i="polynomial"===t.method?Sr(e,t.order??2):Ar(e);if(!i.points.length)return null;let r="loess"===t.method?Pr(e,t.bandwidth):i.predict;if(!r)return null;let{se:o}=Mr(e,r,i.parameterCount),n=$r(t.confidence??.95),a=e[e.length-1][0],s=(a-e[0][0])/(e.length-1);return{predict:r,forecast:(e,t=a)=>!Number.isInteger(e)||e<=0?[]:Array.from({length:e},(e,a)=>{let l=t+(a+1)*s,c=r(l),u=o*n*Math.sqrt(1+i.leverage(l));return{x:l,y:c,upper:c+u,lower:c-u}})}}var Rr="__forecastSegment",Tr="__forecastOpacity";function Cr(e,t,i,r){let o=t.uncertaintyOpacity,n=t.confidenceAccessor;if(!o&&!n)return;let a="object"==typeof o?o:{},s=a.min??.15,l=a.max??1;if(n){let t="function"==typeof n?n:e=>e[n];for(let i of e){let e=t(i);if(null!=e&&Number.isFinite(e)){let t=Math.max(0,Math.min(1,e));i[Tr]=s+t*(l-s)}}return}let c=e.map(e=>{let t=i(e),o=r(e);return null!=t&&null!=o&&Number.isFinite(t)&&Number.isFinite(o)?Math.abs(t-o):NaN}),u=c.filter(e=>Number.isFinite(e));if(0===u.length)return;let[d,h]=Ne(u),f=h-d;e.forEach((e,t)=>{let i=c[t];if(!Number.isFinite(i))return;let r=f>0?(i-d)/f:0;e[Tr]=l-r*(l-s)})}function Nr(e,t){return"function"==typeof t?t(e):!!e[t]}function Fr(e){return[{type:"anomaly-band",threshold:e.threshold??2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:e.bandOpacity??.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:e.anomalyRadius??6,label:e.label}]}function zr(e,t,i,r,o){let{isTraining:n,isForecast:a,isAnomaly:s,upperBounds:l,lowerBounds:c,color:u="#6366f1",bandOpacity:d=.15,anomalyColor:h="#ef4444",anomalyRadius:f=6,label:p}=r,g=e.map(e=>{let t="observed";return a&&Nr(e,a)?t="forecast":n&&Nr(e,n)&&(t="training"),{...e,[Rr]:t}}),m=[];for(let e=0;e<g.length;e++)m.push(g[e]),e<g.length-1&&g[e][Rr]!==g[e+1][Rr]&&(m.push({...g[e+1],[Rr]:g[e][Rr]}),m.push({...g[e],[Rr]:g[e+1][Rr]}));if(r.trainUnderline){let e=[];for(let t of m)"training"===t[Rr]&&e.push({...t,[Rr]:"training-base"});m.unshift(...e)}let y=[];if(l&&c){let e="string"==typeof l?l:"__envUpper",t="string"==typeof c?c:"__envLower";if("function"==typeof l||"function"==typeof c)for(let i of m)"function"==typeof l&&(i[e]=l(i)),"function"==typeof c&&(i[t]=c(i));y.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:u,fillOpacity:d,label:p})}if(r.uncertaintyOpacity||r.confidenceAccessor){let e=l?"function"==typeof l?l:e=>e[l]:()=>{},t=c?"function"==typeof c?c:e=>e[c]:()=>{};Cr(m.filter(e=>"forecast"===e[Rr]),r,e,t)}if(s){let e=r.anomalyStyle,t={type:"highlight",filter:e=>Nr(e,s)};e?(t.style=e,t.r=f):"function"==typeof h?(t.style=e=>{let t=h(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=f):(t.color=h,t.r=f,t.style={stroke:h,strokeWidth:1.5,fill:h,fillOpacity:.7}),y.push(t)}return o&&y.push(...Fr(o)),{processedData:m,annotations:y}}function Er(e,t,i,r,o){let{trainEnd:n,steps:a=10,color:s="#6366f1",bandOpacity:l=.15,label:c}=r;if(null===vr(n))return{processedData:e,annotations:[]};let u=[],d=[];for(let i of[...e].sort((e,i)=>(vr(e[t])??1/0)-(vr(i[t])??1/0))){let e=vr(i[t]);null!==e&&e<=n?u.push({...i,[Rr]:"training"}):d.push({...i,[Rr]:"observed"})}let h=wr(u.map(e=>[e[t],e[i]])),f=[],p=[];if(h.length>=3&&Number.isInteger(a)&&a>0){let o=Ir(h,r);if(o){let n=e.map(e=>vr(e[t])).filter(e=>null!==e),h=ze(n),g=e.some(e=>e[t]instanceof Date);for(let{x:e,y:r,upper:n,lower:s}of o.forecast(a,h))p.push({...d[d.length-1]??u[u.length-1],[t]:g?new Date(e):e,[i]:r,[Rr]:"forecast",__forecastUpper:n,__forecastLower:s});Cr(p,r,e=>e.__forecastUpper,e=>e.__forecastLower),f.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:s,fillOpacity:l,label:c})}}f.push({type:"x-threshold",x:n,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),o&&f.push(...Fr(o));let g=[];if(g.push(...u),u.length>0&&d.length>0&&g.push({...u[u.length-1],[Rr]:"observed"}),g.push(...d),p.length>0){let e=d.length>0?d[d.length-1]:u[u.length-1];e&&g.push({...e,[Rr]:"forecast"}),g.push(...p)}return{processedData:g,annotations:f}}function Dr(e){return!!(e.isTraining||e.isForecast||e.isAnomaly||e.upperBounds||e.lowerBounds)}function Or(e,t,i,r,o){let n=r._groupBy;if(n&&e.length){let a="function"==typeof n?n:e=>e[n],s=/* @__PURE__ */new Map;for(let t of e){let e=a(t),i=s.get(e);i?i.push(t):s.set(e,[t])}let l=[],c=[];for(let[e,n]of s){let s=Or(n,t,i,{...r,_groupBy:void 0},o);for(let e of s.processedData)l.push(e);for(let t of s.annotations)if("x-threshold"===t.type)c.some(e=>"x-threshold"===e.type)||c.push(t);else{let i=t.filter;c.push({...t,filter:t=>{let r=a(t);return(r===e||Object.is(r,e))&&(!i||i(t))}})}}return{processedData:l,annotations:c}}return Dr(r)?zr(e,0,0,r,o):Er(e,t,i,r,o)}function jr(e,t){let i=t.trainDasharray??"8,4",r=t.forecastDasharray??"4,4",o=t.color||"#6366f1",n=t.trainOpacity,a=t.forecastOpacity,s=t.trainStroke,l=t.trainLinecap,c=t.trainUnderline;return t=>{let u=e(t),d=t[Rr];if("training"===d){let e=u.stroke;return"darken"===s?e=xr(u.stroke||"#666",.5):s&&(e=s),{...u,stroke:e,strokeDasharray:i,...l&&{strokeLinecap:l},...null!=n&&{strokeOpacity:n}}}if("training-base"===d){let e=u.stroke||"#666";return"lighten"===c&&(e=br(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===d){let e=t[Tr]??a;return{...u,stroke:o,strokeDasharray:r,...null!=e&&{strokeOpacity:e}}}return u}}function Wr(e,t,i){if(!i)return;let r=[t,i.upperBounds??"__forecastUpper",i.lowerBounds??"__forecastLower"].map(e=>"function"==typeof e?e:t=>t[e]),o=!(!i.upperBounds&&!i.lowerBounds),n=1/0,a=-1/0;for(let t of e){let e=r[1](t),i=r[2](t);(null!=e||null!=i)&&(o=!0);for(let o of[Number(r[0](t)),e,i])"number"==typeof o&&Number.isFinite(o)&&(n=Math.min(n,o),a=Math.max(a,o))}return o&&n<=a?[n,a]:void 0}var Br="__semiotic_resolvedX",Yr="__semiotic_resolvedY",Gr="__compoundGroup";function Xr(e,t,i){let r="function"==typeof t,o="function"==typeof i,n=r?Br:t,a=o?Yr:i;return r||o?{xKey:n,yKey:a,rows:e.map(e=>{let n={...e};return r&&(n[Br]=t(e)),o&&(n[Yr]=i(e)),n})}:{rows:e,xKey:n,yKey:a}}function Vr(e,t,i){let r=e[t],o=e[i];return null==r||null==o||Number.isNaN(r)||Number.isNaN(o)}function qr(e,t,i,r,o){let n=/* @__PURE__ */new Map;for(let t of e){let e=o?String(t[o]??""):"__single";n.has(e)||n.set(e,[]),n.get(e).push(t)}if("interpolate"===t){let e=[];for(let[,t]of n)for(let o of t)Vr(o,i,r)||e.push(o);return{rows:e,groupKey:o}}if("zero"===t){let e=[];for(let[,t]of n)for(let o of t)Vr(o,i,r)?e.push({...o,[r]:0}):e.push(o);return{rows:e,groupKey:o}}let a=[],s="_gapSegment";for(let[e,t]of n){let o=0,n=[],l=()=>{if(0===n.length)return;let t="__single"===e?`__seg${o}`:`${e}__seg${o}`;for(let e of n)a.push({...e,[s]:t});n=[],o++};for(let e of t)Vr(e,i,r)?l():n.push(e);l()}return{rows:a,groupKey:s}}function Hr(e,t,i,r,o,n,a,s){if(!t||!i)return{annotations:[]};let l="object"==typeof t?t:{},c=l.position||"end",u=l.fontSize||11,d="function"==typeof i?i:e=>e[i],h=ji(e.map(e=>({__lbl:String(d(e)??"")})),"__lbl",n??a),f=mr(e,{position:c,fontSize:u,colorBy:i,color:e=>h?h(e):s||Ti},r,o),p=f.reduce((e,t)=>Math.max(e,Array.from(String(t.label)).length*(.65*u)),0)+10;return{annotations:f,marginExtra:"end"===c?{right:p}:{left:p}}}function Ur(e){let t=e.xAccessor||"x",i=e.yAccessor||"y",r=e.lineBy,o=e.colorBy||r,n=Array.isArray(e.data)?li(e.data).filter(e=>!!e&&"object"==typeof e):[],a=Xr(n,t,i);n=a.rows;let s,l,c=a.xKey,u=a.yKey,d=Array.isArray(e.annotations)?[...e.annotations]:[],h="string"==typeof r||"function"==typeof r?r:void 0,f=e.baseLineStyle;if(e.forecast){let t=Or(n,c,u,!r||"string"!=typeof r&&"function"!=typeof r?e.forecast:{...e.forecast,_groupBy:r},e.anomaly);if(n=t.processedData,d.push(...t.annotations),s=Wr(n,u,e.forecast),!r||"string"!=typeof r&&"function"!=typeof r?h=Rr:(n=n.map(e=>({...e,[Gr]:`${"function"==typeof r?r(e):e[r]}__${e[Rr]||"observed"}`})),h=Gr),e.baseLineStyle){let t=jr(t=>e.baseLineStyle(t),e.forecast);f=e=>t(e)}}else e.anomaly&&d.push(...Fr(e.anomaly));if(e.gapStrategy){if("function"==typeof h){let e=h;n=n.map(t=>({...t,__semiotic_gapGroup:e(t)})),h="__semiotic_gapGroup"}let t="string"==typeof h?h:void 0,i=qr(n,e.gapStrategy,c,u,t);n=i.rows,i.groupKey&&(h=i.groupKey)}if(e.directLabel){let t=Hr(n,e.directLabel,"string"==typeof o||"function"==typeof o?o:void 0,c,u,e.colorScheme,e.themeCategorical,e.color);d.push(...t.annotations),l=t.marginExtra}return{data:n,xAccessor:"function"==typeof t?c:t,yAccessor:"function"==typeof i?u:i,groupAccessor:h,colorAccessor:o,annotations:d,lineStyle:f,yExtent:s,marginExtra:l}}function Zr(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=hr(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrScatterColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrScatterColorBy:t(e)})):n,u=t?ji(c,l,s):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[3,15],f=d?n.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?Ne(f):void 0,g=q(o.xAccessor,o.yAccessor),m=o.styleRules;return e=>{let i={fill:t&&u?Di(e,t,u):"string"==typeof o.color?o.color:Ti,fillOpacity:"number"==typeof o.pointOpacity?o.pointOpacity:.8,r:d?Bi(e,d,h,p):"number"==typeof o.pointRadius?o.pointRadius:5};return m?.length&&Object.assign(i,U(e,m,g(e))),void 0!==o.stroke&&(i.stroke=o.stroke),void 0!==o.strokeWidth&&(i.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(i.opacity=o.opacity),i}}var Qr={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Ur({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:hr(r.theme).colors.categorical}),a=ur(n.annotations,o.regression);return{chartType:"scatter",data:n.data,xAccessor:n.xAccessor,yAccessor:n.yAccessor,colorAccessor:t,sizeAccessor:o.sizeBy,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...r,...a&&a.length>0&&{annotations:a},...n.yExtent&&!r.yExtent&&{yExtent:n.yExtent},sizeRange:o.sizeRange||[3,15],pointStyle:r.pointStyle||Zr(e,t,i,r,o),showLegend:r.showLegend??!!t}}};function Kr(e,t){if(!t)return[];let i=/* @__PURE__ */new Set,r=[];for(let o of e){if(!o||"object"!=typeof o)continue;let e="function"==typeof t?t(o):o[t],n=String(e);i.has(n)||(i.add(n),r.push(n))}return r}function Jr(e,t,i,r){if(!i.categoryAccessor)return;let o=Kr(e,i.categoryAccessor),n=i.colors,a="explicit-then-alpha"===r?[...Object.keys(n??{}).filter(e=>o.includes(e)),...o.filter(e=>!Object.hasOwn(n??{},e)).sort()]:o,s=hr(t.theme).colors.categorical,l=s?.length?s:Ni;return Object.fromEntries(a.map((e,t)=>[e,n&&Oi(n,e)||i.fill||l[t%l.length]]))}var eo={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=ur(r.annotations,o.regression);return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[5,40],colorScheme:i,...r,...n&&{annotations:n},pointStyle:r.pointStyle||to(e,t,i,r,o),showLegend:r.showLegend??!!t}}};function to(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=hr(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrBubbleColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrBubbleColorBy:t(e)})):n,u=t?ji(c,l,s):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[5,40],f=d?n.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?Ne(f):void 0,g=q(o.xAccessor,o.yAccessor),m=o.styleRules;return e=>{let i={fill:t&&u?Di(e,t,u):"string"==typeof o.color?o.color:Ti,fillOpacity:"number"==typeof o.bubbleOpacity?o.bubbleOpacity:.6,r:d?Bi(e,d,h,p):h[0],stroke:o.bubbleStrokeColor??"white",strokeWidth:o.bubbleStrokeWidth??1};return m?.length&&Object.assign(i,U(e,m,g(e))),void 0!==o.stroke&&(i.stroke=o.stroke),void 0!==o.strokeWidth&&(i.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(i.opacity=o.opacity),i}}import{useMemo as io,useCallback as ro,useState as oo,useId as no,useEffect as ao,useRef as so}from"react";var lo="__semioticSelectionData";function co(e,t){return t?.length&&Object.defineProperty(e,lo,{configurable:!0,enumerable:!1,value:t}),e}function uo(e){return e?.[lo]}function ho(e){return e.parentLine?co({...e.parentLine,...e},uo(e)):e}function fo(e){return co({...e[0]},e.map(ho))}function po(e){return!!e&&uo(e)?.[0]===e}var go=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function mo(e){let t=new Date(e instanceof Date?e.valueOf():e);return`${go[t.getUTCMonth()]} ${t.getUTCDate()}`}function yo(e){let t=Math.abs(e[1]-e[0]);return t<864e5?e=>{let i=new Date(e instanceof Date?e.valueOf():e),r=`${String(i.getUTCHours()).padStart(2,"0")}:${String(i.getUTCMinutes()).padStart(2,"0")}`;return t<3e5&&(r+=`:${String(i.getUTCSeconds()).padStart(2,"0")}`),t<1e4&&(r+=`.${String(i.getUTCMilliseconds()).padStart(3,"0")}`),r}:t<3156e7?mo:t<1578e8?e=>{let t=new Date(e instanceof Date?e.valueOf():e);return`${go[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>String(new Date(e instanceof Date?e.valueOf():e).getUTCFullYear())}function xo(e,t){let i=t=>e[Math.max(0,Math.min(e.length-1,Math.round(Number(t))))],r=e.every(e=>"number"==typeof e||e instanceof Date),o=t?void 0:bo(e);return(n,a,s)=>{if(0===e.length)return"";let l=i(n);return t?t(l,a,s&&r?s.map(e=>Number(i(e).valueOf())):void 0):l instanceof Date&&o?o(l):String(l)}}function bo(e){let t=e.filter(e=>e instanceof Date&&Number.isFinite(e.valueOf()));if(0===t.length)return;let i=t.every(e=>e.valueOf()%864e5==0),r=i&&t.every(e=>1===e.getUTCDate());if(r&&t.every(e=>0===e.getUTCMonth()))return e=>String(e.getUTCFullYear());if(r)return e=>`${mo(e).split(" ")[0]} ${e.getUTCFullYear()}`;let o=t.map(e=>e.valueOf()),n=[Math.min(...o),Math.max(...o)];if(i){let e=new Date(n[0]).getUTCFullYear()===new Date(n[1]).getUTCFullYear();return t=>e?mo(t):`${mo(t)}, ${t.getUTCFullYear()}`}return yo(n)}function vo(e,t,i){return"function"==typeof e?e(t,i):t[e]}function wo(e,t){if(!e?.length)return;let i=new Map(t.map((e,t)=>[Yt(e),t]));return e.map(e=>{let t={...e},r=r=>{if(!(r in e))return;let o=i.get(Yt(e[r]));void 0!==o&&(t[r]=o)};return r("x"),r("x0"),r("x1"),"string"==typeof e.type&&("x-threshold"===e.type||"x"===e.type)&&r("value"),t})}function ko(e){let t="number"==typeof e?e:"string"==typeof e&&""!==e.trim()?Number(e):NaN;return Number.isFinite(t)?Math.max(0,Math.floor(t)):void 0}function Ao(e){return"string"==typeof e&&""!==e.trim()?e:void 0}function So(e){let{seriesOrder:t,overallOrder:i,highlightTop:r,color:o,colorScheme:n,neutralColor:a,themeCategorical:s,themeNeutral:l}=e;if(null==r&&null==o)return n;let c="string"==typeof n?[...Ci(n,s)]:n,u=null==r?i.length:Math.max(0,Math.floor(r)),d=new Set(i.slice(0,u)),h=/* @__PURE__ */new Map,f={};for(let e of t)Object.defineProperty(f,e,{configurable:!0,enumerable:!0,writable:!0,value:o??(d.has(e)?Yi(void 0,s,c,e,h):a??l??"#b8bec8")});return f}function Mo(e,t={}){let i=t.xAccessor??"x",r=t.yAccessor??"y",o=t.lineBy??"series",n=t.rankDirection??"descending",a=[],s=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map,c=[],u=/* @__PURE__ */new Map,d=1/0,h=-1/0;e.forEach((e,t)=>{let n=vo(i,e,t),f=Yt(n),p=s.get(f);null==p&&(p=a.length,s.set(f,p),a.push(n),l.set(p,[]));let g=String(vo(o,e,t));u.has(g)||(u.set(g,c.length),c.push(g));let m=Number(vo(r,e,t));Number.isFinite(m)&&(d=Math.min(d,m),h=Math.max(h,m),l.get(p)?.push({datum:e,inputIndex:t,series:g,value:m}))});let f=[],p=/* @__PURE__ */new Map,g=/* @__PURE__ */new Map;for(let e=0;e<a.length;e++){let t=l.get(e)??[];t.sort((e,t)=>("descending"===n?t.value-e.value:e.value-t.value)||(u.get(e.series)??0)-(u.get(t.series)??0)),t.forEach((t,i)=>{let r=i+1;f.push({datum:t.datum,xIndex:e,xValue:a[e],series:t.series,value:t.value,rank:r}),p.set(t.series,(p.get(t.series)??0)+r),g.set(t.series,(g.get(t.series)??0)+1)})}let m=c.length+1,y=[...c].sort((e,t)=>{let i=g.get(e)??0,r=g.get(t)??0;return((p.get(e)??0)+(a.length-i)*m)/Math.max(1,a.length)-((p.get(t)??0)+(a.length-r)*m)/Math.max(1,a.length)||(u.get(e)??0)-(u.get(t)??0)}),x=null==t.highlightTop?y.length:Math.max(0,Math.floor(t.highlightTop)),b=new Set(y.slice(0,x));return{data:f.map(e=>{let t=b.has(e.series);return{...e.datum,x:e.xIndex,y:e.rank,__bumpRaw:e.datum,__bumpSeries:e.series,__bumpColorGroup:t?e.series:"Other",__bumpValue:e.value,__bumpRank:e.rank,__bumpXValue:e.xValue,__bumpHighlighted:t}}),xValues:a,seriesOrder:c,overallOrder:y,valueExtent:d===1/0?[0,0]:[d,h]}}function $o(e,t,i,r,o){let n=1-o;return n*n*n*e+3*n*n*o*t+3*n*o*o*i+o*o*o*r}function _o(e,t,i,r,o){let n=1-o;return 3*n*n*(t-e)+6*n*o*(i-t)+3*o*o*(r-i)}function Lo(e,t,i,r,o){let n=[],a=(e.x+t.x)/2;for(let s=0;s<=o;s++){let l,c,u,d,h=s/o;"linear"===r?(l=e.x+(t.x-e.x)*h,c=e.y+(t.y-e.y)*h,u=t.x-e.x,d=t.y-e.y):(l=$o(e.x,a,a,t.x,h),c=$o(e.y,e.y,t.y,t.y,h),u=_o(e.x,a,a,t.x,h),d=_o(e.y,e.y,t.y,t.y,h)),n.push({x:l,y:c,dx:u,dy:d,radius:e.radius+(t.radius-e.radius)*h,datumIndex:h<.5?i:i+1})}return n}function Po(e,t){let i=e.length-1,r=Math.sign(e[i][0]-e[t][0])||1,o=r*e[i][0],n=r*e[t][0];for(let a=t+1;a<i;a++){let t=Math.max(n,Math.min(o,r*e[a][0]));e[a][0]=r*t,n=t}for(let r=t;r<i;r++){let t=r;for(;t<i&&e[t+1][0]===e[r][0];)t++;for(let i=r+1;i<t;i++)e[i][1]=e[r][1]+(e[t][1]-e[r][1])*(i-r)/(t-r);r=t}let a=1e-6*(o-r*e[t][0])/(i-t);n=r*e[t][0];for(let s=t+1;s<i;s++){let t=Math.max(n+a,Math.min(r*e[s][0],o-(i-s)*a));e[s][0]=r*t,n=t}}function Io(e,t={}){let i=[],r=[],o=[];if(e.length<2)return{topPath:i,bottomPath:r,datumIndices:o};let n=t.curve??"smooth",a=Math.max(2,Math.floor(t.samplesPerSegment??12));for(let t=0;t<e.length-1;t++){let s=Math.max(0,i.length-1),l=Lo(e[t],e[t+1],t,n,a);for(let e=0===t?0:1;e<l.length;e++){let t=l[e],n=Math.hypot(t.dx,t.dy)||1,a=-t.dy/n,s=t.dx/n,c=Math.max(0,t.radius);i.push([t.x+a*c,t.y+s*c]),r.push([t.x-a*c,t.y-s*c]),o.push(t.datumIndex)}Po(i,s),Po(r,s)}return{topPath:i,bottomPath:r,datumIndices:o}}var Ro={top:20,bottom:48,left:48},To=[[/[mwMW@%…]/,.95],[/[ijlI'.,|\s]/,.28],[/[frt():;/[\]{}*`!\\-]/,.39]];function Co(e,t){let i=0;for(let t of e)i+=(t.codePointAt(0)??0)>=11904?1.1:To.find(([e])=>e.test(t))?.[1]??(t.toLowerCase()!==t?.75:.62);return i*t*1.05}function No(e){let t=e.fontSize??12,i=!0===e.showLabels?"end":e.showLabels,r="end"===i||"both"===i||"auto"===i,o="start"===i||"both"===i,n=e.labels.reduce((e,i)=>Math.max(e,Co(i,t)),0),a=Math.round(e.width*(e.maxSideFraction??.38)),s=Co(String(Math.max(1,e.rankCount)),t),l=e.showAxes?8+s+6:8,c={start:l+4+(e.showAxes&&e.yLabel?24:0),end:12},u=e.legendSide?gt({legendGroups:[{label:"",styleFn:()=>({}),items:e.labels.map(e=>({label:e}))}]},{sideGutter:0}):0,d=Co("MMM",t),h=(t,i)=>Math.min(i+n,e.legendSide===t?Math.max(i+d,a-u):a),f={start:o?h("left",c.start):0,end:r?h("right",c.end):0},p=!1===e.showLabels?24:110;return{margin:{...Ro,right:Math.max(p,f.end),left:Math.max(Ro.left,f.start)},startLabelOffset:l,chrome:c,room:f,labelWidth:n,fontSize:t,hasStart:o,hasEnd:r}}function Fo(e,t){let i={start:t.hasStart?Math.max(0,Math.min(e.left,t.room.start)-t.chrome.start):0,end:t.hasEnd?Math.max(0,Math.min(e.right,t.room.end)-t.chrome.end):0};return{budget:i,sideGutter:{...t.hasStart&&{left:t.chrome.start+Math.min(i.start,t.labelWidth)},...t.hasEnd&&{right:t.chrome.end+Math.min(i.end,t.labelWidth)}}}}function zo(e,t,i){if(Co(e,i)<=t)return{text:e,truncated:!1};let r=Array.from(e),o=r.length-1;for(;o>0&&Co(`${r.slice(0,o).join("")}…`,i)>t;)o--;return{text:`${r.slice(0,o).join("").trimEnd()}…`,truncated:!0}}import{jsx as Eo,jsxs as Do}from"react/jsx-runtime";function Oo(e,t,i,r){let o=Math.max(1,Math.floor(t/18)),n="auto"===i?Number.isFinite(r)&&(r??0)>=0?Math.min(o,Math.floor(r)):o:1/0,a=e.map((e,t)=>({candidate:e,index:t})).sort((e,t)=>{let i=e.candidate.priority??0;return(t.candidate.priority??0)-i||Number(t.candidate.highlighted)-Number(e.candidate.highlighted)||e.candidate.rank-t.candidate.rank||e.index-t.index}),s=[];for(let{candidate:e}of a){if(s.length>=n)break;s.some(t=>t.side===e.side&&Math.abs(t.y-e.y)<14)||s.push(e)}return new Set(s.map(e=>e.id))}function jo({datum:e,x:t,y:i,side:r,color:o,highlighted:n,labelStyle:a,offset:s,budget:l,fontSize:c}){let u=oe(),d=u.isActive&&!u.predicate(e),h="function"==typeof a?a(e.__bumpRaw):a,f=null==l?{text:e.__bumpSeries,truncated:!1}:zo(e.__bumpSeries,l,c);/* @__PURE__ */
2
- return Do("text",{className:"semiotic-bump-label",x:t+("end"===r?s:-s),y:i,dy:"0.35em",textAnchor:"end"===r?"start":"end",fill:o,fillOpacity:d?.16:1,fontWeight:n?650:450,fontSize:12,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 12px)",...h},children:[f.truncated&&/* @__PURE__ */Eo("title",{children:e.__bumpSeries}),f.text]})}function Wo(e){let t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}function Bo(e,t,i){let[r,o]=t,[n,a]=i;return o===r?(n+a)/2:n+(a-n)*Math.max(0,Math.min(1,(e-r)/(o-r)))}function Yo(e){let t=e.__bumpXValue instanceof Date?e.__bumpXValue.getTime():Number(e.__bumpXValue);return{value:e.__bumpValue,x:Number.isFinite(t)?t:void 0,y:e.__bumpValue,category:e.__bumpSeries}}function Go(e){let t=e.config,i=/* @__PURE__ */new Map;for(let t of e.data){let e=i.get(t.__bumpSeries)??[];e.push(t),i.set(t.__bumpSeries,e)}let r=t.seriesOrder.filter(e=>i.has(e)).sort((e,r)=>(i.get(e)?.[0]?.__bumpHighlighted?1:0)-(i.get(r)?.[0]?.__bumpHighlighted?1:0)||t.seriesOrder.indexOf(e)-t.seriesOrder.indexOf(r)),o=[],n=[],a=[];for(let n of r){let r=(i.get(n)??[]).sort((e,t)=>e.x-t.x);if(r.length<2)continue;let s=r[0].__bumpHighlighted,l=(t.colorMap&&Oi(t.colorMap,n))??e.resolveColor(r[0].__bumpSeries,r[0]),c=t.color??(s?l:t.neutralColor??e.theme.semantic.textSecondary??e.theme.semantic.border??l),u=r.map(i=>({x:e.scales.x(i.x),y:e.scales.y(i.y),radius:t.ribbon?Bo(i.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),d=Io(u,{curve:t.curve,samplesPerSegment:t.samplesPerSegment}),h={fill:c,fillOpacity:1,opacity:s?t.ribbon?t.ribbonOpacity:t.lineOpacity:Math.min(t.ribbon?t.ribbonOpacity:t.lineOpacity,.58)};t.styleRules?.length&&Object.assign(h,U(r[0].__bumpRaw,t.styleRules,Yo(r[0]))),t.areaStyle&&Object.assign(h,t.areaStyle(r[0].__bumpRaw)??{}),void 0!==t.stroke&&(h.stroke=t.stroke),void 0!==t.strokeWidth&&(h.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(h.opacity=t.opacity),o.push({type:"area",topPath:d.topPath,bottomPath:d.bottomPath,_hitArea:!0,style:h,datum:d.datumIndices.map(e=>r[e]),accessibleDatum:r.map(e=>e.__bumpRaw),accessibility:{label:`${n} ranking trajectory`,tableFields:r.map(e=>e.__bumpRaw)},group:n,interactive:!0}),t.showPoints&&r.forEach((e,i)=>{let r={fill:c,stroke:"none",opacity:s?1:.75};t.styleRules?.length&&Object.assign(r,U(e.__bumpRaw,t.styleRules,Yo(e))),t.pointStyle&&Object.assign(r,t.pointStyle(e.__bumpRaw)??{}),void 0!==t.stroke&&(r.stroke=t.stroke),void 0!==t.strokeWidth&&(r.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(r.opacity=t.opacity),o.push({type:"point",x:u[i].x,y:u[i].y,r:r.r??t.pointRadius,style:r,datum:e,accessibleDatum:e.__bumpRaw,accessibility:{label:`${n}, rank ${e.__bumpRank}, value ${e.__bumpValue}`},pointId:`${n}:${e.x}`})});let f=!0===t.showLabels?"end":t.showLabels,p=(e,i,r)=>{let o=null==t.labelPriorityAccessor?void 0:"function"==typeof t.labelPriorityAccessor?t.labelPriorityAccessor(e.__bumpRaw):Number(e.__bumpRaw[t.labelPriorityAccessor]);a.push({id:`${n}\0${r}`,datum:e,x:u[i].x,y:u[i].y,side:r,rank:e.__bumpRank,highlighted:s,priority:Number.isFinite(o)?o:void 0,color:"string"==typeof h.fill?h.fill:c})};("start"===f||"both"===f)&&p(r[0],0,"start"),("end"===f||"both"===f||"auto"===f)&&p(r.at(-1),r.length-1,"end")}let s=!0===t.showLabels?"end":t.showLabels,l=Oo(a,e.dimensions.plot.height,"auto"!==s||"auto",t.maxLabels);for(let e of a)l.has(e.id)&&n.push(
3
- /* @__PURE__ */Eo(jo,{datum:e.datum,x:e.x,y:e.y,side:e.side,color:e.color,highlighted:e.highlighted,labelStyle:t.labelStyle,offset:"end"===e.side?8:t.startLabelOffset??8,budget:t.labelBudget?.[e.side],fontSize:t.labelFontSize??12},e.id));return{nodes:o,overlays:n.length?/* @__PURE__ */Eo("g",{className:"semiotic-bump-labels",children:n}):void 0,restyle:(e,t)=>{let i=Wo(e);if(t?.isActive&&i&&!t.predicate(i))return{opacity:.14}}}}function Xo(e){return Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[]}function Vo(e){return{xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineBy:e.lineBy,rankDirection:e.rankDirection,highlightTop:ko(e.highlightTop)}}function qo(e,t,i,r,o,n){let a=t.labelStyle,s=n.position??"right";return{legendSide:!0!==n.show||"left"!==s&&"right"!==s?void 0:s,labels:e,showLabels:t.showLabels??!0,width:i,showAxes:r,rankCount:e.length,yLabel:"string"==typeof o?o:"Rank",fontSize:"object"==typeof a&&"number"==typeof a?.fontSize?a.fontSize:12}}var Ho={frameType:"xy",layout:{modeDefaults:{showGrid:!0},margin:(e,t)=>{let{seriesOrder:i}=Mo(Xo(e.data),Vo(e));return No(qo(i,e,t.width,t.showAxes,e.yLabel,{show:e.showLegend,position:e.legendPosition})).margin}},buildProps:(e,t,i,r,o)=>{let n=Mo(Xo(e),Vo(o)),[a]=r.size??[600,400],s=No(qo(n.seriesOrder,o,a,!1!==r.showAxes,r.yLabel,{show:r.showLegend,position:r.legendPosition})),l=new Set(Array.isArray(r.__explicitMarginSides)?r.__explicitMarginSides:[]),c=r.margin,u={...c,...s.hasEnd&&!l.has("right")&&{right:Math.max(c.right,s.margin.right)},...s.hasStart&&!l.has("left")&&{left:Math.max(c.left,s.margin.left)}},d=Fo(u,s),h=r.legendPosition??"right",f=r.legendLayout,p=!0!==r.showLegend||"left"!==h&&"right"!==h?void 0:d.sideGutter[h],g=Math.max(1,n.seriesOrder.length),m=hr(r.theme),y=So({seriesOrder:n.seriesOrder,overallOrder:n.overallOrder,highlightTop:ko(o.highlightTop),color:Ao(o.color),colorScheme:i,neutralColor:Ao(o.neutralColor),themeCategorical:m.colors.categorical,themeNeutral:m.colors.textSecondary}),x={ribbon:!0===o.ribbon,curve:"linear"===o.curve?"linear":"smooth",samplesPerSegment:"number"==typeof o.samplesPerSegment?o.samplesPerSegment:12,ribbonSizeRange:Array.isArray(o.ribbonSizeRange)?o.ribbonSizeRange:[4,28],valueExtent:n.valueExtent,seriesOrder:n.seriesOrder,lineWidth:"number"==typeof o.lineWidth?o.lineWidth:3,ribbonOpacity:"number"==typeof o.ribbonOpacity?o.ribbonOpacity:.82,lineOpacity:"number"==typeof o.lineOpacity?o.lineOpacity:.9,neutralColor:Ao(o.neutralColor),color:Ao(o.color),colorMap:y&&"object"==typeof y&&!Array.isArray(y)?y:void 0,stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0,styleRules:o.styleRules,areaStyle:r.areaStyle,pointStyle:r.pointStyle,labelStyle:o.labelStyle,showPoints:!0===o.showPoints,pointRadius:"number"==typeof o.pointRadius?o.pointRadius:3,showLabels:o.showLabels??!0,labelPriorityAccessor:o.labelPriorityAccessor,maxLabels:"number"==typeof o.maxLabels?o.maxLabels:void 0,startLabelOffset:s.startLabelOffset,labelBudget:d.budget,labelFontSize:s.fontSize},b=xo(n.xValues,r.xFormat),v=n.xValues.map((e,t)=>t),w=Array.from({length:g},(e,t)=>t+1),k=r.axes??[{orient:"left",tickValues:w,tickFormat:e=>String(e),label:r.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:v,tickFormat:b,label:r.xLabel,tickAnchor:"edges"}];return{...r,margin:u,...null!=p&&null==f?.sideGutter&&{legendLayout:{...f,sideGutter:p}},chartType:"custom",data:n.data,xAccessor:"x",yAccessor:"y",xExtent:[0,Math.max(1,n.xValues.length-1)],yExtent:[g+.5,.5],customLayout:Go,layoutConfig:x,colorAccessor:"__bumpSeries",colorScheme:y,xFormat:b,axes:k,axisExtent:"exact",showAxes:r.showAxes??!0,showLegend:r.showLegend??!1,annotations:wo(r.annotations,n.xValues)}}},Uo="__ma_unitized",Zo="__ma_series";function Qo(e,t,i){let r=Ci(t,i,Ri),o=t&&"object"==typeof t&&!Array.isArray(t)?t:null;return e.map((e,t)=>{if("string"==typeof e.color&&e.color.length>0)return e.color;let i=e.label||`Series ${t+1}`,n=o?.[i];return"string"==typeof n&&n.length>0?n:r[t%r.length]})}function Ko(e,t){let i=V(e),r=t.map((e,t)=>({label:e.label||`Series ${t+1}`,readY:V(e.yAccessor)}));return(e,t)=>{let o=String(e[Zo]??t??""),n=(r.find(e=>e.label===o)??r[0])?.readY(e);return{value:n,x:i(e),y:n,category:o||void 0}}}function Jo(e,t){let i="function"==typeof t?t:e=>Number(e[t||"y"]),r=1/0,o=-1/0;for(let t of e){let e=i(t);"number"==typeof e&&Number.isFinite(e)&&(e<r&&(r=e),e>o&&(o=e))}if(!Number.isFinite(r)||!Number.isFinite(o))return[0,1];if(r===o){let e=0===r?1:.1*Math.abs(r);return[r-e,o+e]}return[r,o]}var en={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Array.isArray(o.series)?o.series:[],s=Qo(a,i,hr(r.theme).colors.categorical),l=2===a.length,c=a.map(e=>e.extent||Jo(n,e.yAccessor)),u=[];for(let e of n)a.forEach((t,i)=>{let r=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(e);if(null==r||!Number.isFinite(Number(r)))return;let o=Number(r),n=c[i],a=n[1]-n[0]||1;u.push({...e,[Uo]:l?(o-n[0])/a:o,[Zo]:t.label||`Series ${i+1}`})});let d=(e,t)=>i=>{let r=e[0]+i*(e[1]-e[0]);return"function"==typeof t?t(r):Number.isInteger(r)?String(r):r.toFixed(1)},h=l?[{orient:"left",label:a[0].label,tickFormat:d(c[0],a[0].format)},{orient:"right",label:a[1].label,tickFormat:d(c[1],a[1].format)},{orient:"bottom"}]:void 0,f=/* @__PURE__ */new Map;a.forEach((e,t)=>{f.set(e.label||`Series ${t+1}`,s[t])});let p=Xi(Vi({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,resolveStroke:e=>f.get(String(e[Zo]??""))||s[0],styleRules:o.styleRules,ruleContext:Ko(o.xAccessor,a)}),{stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0});return{chartType:"line",data:u,xAccessor:o.xAccessor||"x",yAccessor:Uo,groupAccessor:Zo,colorAccessor:Zo,...h&&{axes:h},...l&&{yExtent:[0,1]},...r,curve:o.curve||r.curve||"monotoneX",showLegend:r.showLegend??!0,colorScheme:s,lineStyle:p}}},tn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=o.xAccessor||"x",s="function"==typeof a?a:e=>e[a],l=n.some(e=>{let t=s(e);return!("number"==typeof t&&Number.isFinite(t)||t instanceof Date)}),c=l?n.map((e,t)=>({...e,__waterfallX:t,__waterfallTick:String(s(e)??t)})):n,u=o.styleRules?Z(void 0,o.styleRules,q(o.xAccessor,o.yAccessor)):void 0,d=u?e=>{let t=u(e),i="function"==typeof r.areaStyle?r.areaStyle(e):r.areaStyle;return i?{...t,...i}:t}:void 0;return{chartType:"waterfall",data:c,xAccessor:l?"__waterfallX":a,yAccessor:o.yAccessor||"y",waterfallStyle:{positiveColor:o.positiveColor,negativeColor:o.negativeColor,connectorStroke:o.connectorStroke,connectorWidth:o.connectorWidth,gap:o.gap,stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity},...r,...d&&{areaStyle:d},...l&&{axes:r.axes??[{orient:"bottom",tickValues:c.map((e,t)=>t)}],xFormat:e=>{let t=n[Number(e)]?s(n[Number(e)]):e,i=o.xFormat??r.xFormat;return"function"==typeof i?i(t):String(t??e)}}}}};function rn(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=hr(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrLineColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrLineColorBy:t(e)})):n,u=t?ji(c,l,s):void 0,d=q(o.xAccessor,o.yAccessor);return Xi(Vi({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,colorBy:t,colorScale:u,color:"string"==typeof o.color?o.color:void 0,fillArea:o.fillArea,areaOpacity:"number"==typeof o.areaOpacity?o.areaOpacity:.3,styleRules:o.styleRules,ruleContext:d}),{stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0})}function on(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=hr(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrAreaColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrAreaColorBy:t(e)})):n,u=t?ji(c,l,s):void 0,d=!1!==o.showLine,h="number"==typeof o.lineWidth?o.lineWidth:2,f="number"==typeof o.areaOpacity?o.areaOpacity:.7,p=V(o.yAccessor),g=o.styleRules;return(e,i)=>{let r=t&&u?Di(e,t,u):"string"==typeof o.color?o.color:Ti,n={fill:r,fillOpacity:f,stroke:d?r:"none",...d&&{strokeWidth:h}};return g?.length&&Object.assign(n,U(e,g,{value:p(e),category:i})),void 0!==o.stroke&&(n.stroke=o.stroke),void 0!==o.strokeWidth&&(n.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(n.opacity=o.opacity),n}}function nn(e,t,i,r,o){if(!o.showPoints)return;let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=hr(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrPointColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrPointColorBy:t(e)})):n,u=t?ji(c,l,s):void 0,d="number"==typeof o.pointRadius?o.pointRadius:3;return e=>{let i=t&&u?Di(e,t,u):"string"==typeof o.color?o.color:Ti;return{r:d,fill:i,stroke:"none"}}}var an={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=t||o.lineBy,a=o.fillArea,s=Array.isArray(a)?"mixed":a?"area":"line",l=hr(r.theme).colors.categorical,c=rn(e,n,i,r,o),u=Ur({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.lineBy,colorBy:n,colorScheme:i,color:"string"==typeof o.color?o.color:void 0,forecast:o.forecast,anomaly:o.anomaly,gapStrategy:o.gapStrategy,directLabel:o.directLabel,annotations:r.annotations,themeCategorical:l,baseLineStyle:c}),d=r.pointStyle||nn(u.data,u.colorAccessor,i,r,o),h=r.margin,f=new Set(Array.isArray(r.__explicitMarginSides)?r.__explicitMarginSides:[]);u.marginExtra&&h&&"object"==typeof h?h={...h,...null!=u.marginExtra.right&&!f.has("right")&&{right:Math.max(Number(h.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&!f.has("left")&&{left:Math.max(Number(h.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==h&&(h={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});let p=(!o.directLabel||void 0!==r.showLegend)&&(r.showLegend??!!u.colorAccessor);return{chartType:s,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:i,lineStyle:u.lineStyle||c,...Array.isArray(a)&&{areaGroups:a},...a&&null!=o.areaOpacity&&{areaOpacity:o.areaOpacity},...null!=o.band&&{band:o.band},...r,...void 0!==h&&{margin:h},annotations:u.annotations,...u.yExtent&&!r.yExtent&&{yExtent:u.yExtent},...d&&{pointStyle:d},showLegend:p}}},sn={frameType:"xy",layout:{margin:(e,t)=>gr(t.marginDefaults,pr(e),t.showAxes,!!t.title)},buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?li(e):[],a=o.timeAccessor||"time",s=o.valueAccessor||"value",l=o.categoryAccessor,c=Jr(n,r,o,"explicit-then-alpha"),u=o.valueExtent||r.yExtent,d={...cr(o),...void 0!==o.cursor&&{cursor:o.cursor}},h={...d,...void 0!==o.fill&&{fill:o.fill},...void 0!==o.gap&&{gap:o.gap},...Array.isArray(o.valueBands)&&{valueBands:o.valueBands}},f=Z(void 0,o.styleRules,e=>{let t=e.categoryValue??e.total,i="number"==typeof t&&Number.isFinite(t)?t:void 0,r=Number(e.binStart),o=Number(e.binEnd);return{value:i,x:Number.isFinite(r)&&Number.isFinite(o)?(r+o)/2:void 0,y:i,category:null==e.category?void 0:String(e.category)}});return{chartType:"bar",data:n,...r,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,n.length),arrowOfTime:o.arrowOfTime||"right",timeAccessor:e=>oi(e,a,"time")??NaN,valueAccessor:e=>ri(e,s,"value")??NaN,xExtent:o.timeExtent||r.xExtent,yExtent:u,invertY:"down"===o.direction,axes:pr({...o,axes:r.axes??o.axes}),extentPadding:o.extentPadding??r.extentPadding,binSize:o.binSize,categoryAccessor:l,barColors:c||r.barColors,colorScheme:c||r.colorScheme,barStyle:r.barStyle||h,areaStyle:r.areaStyle||(e=>({...f(e),...!l&&void 0!==o.fill&&{fill:o.fill},...d})),showLegend:r.showLegend??!!l}}},ln={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=t||o.areaBy,a=Ur({data:Array.isArray(e)?li(e):[],xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.areaBy,forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:hr(r.theme).colors.categorical}),s=ai({data:e,safeData:a.data,areaBy:o.areaBy,lineDataAccessor:o.lineDataAccessor||"coordinates"}),l=tr(o.semanticGradient),c=l?.stops.length?or(l):Ji(r.gradientFill),u=!1!==o.semanticLine?ir(l):void 0,d=r.pointStyle||nn(s,n,i,r,o);return{chartType:"area",data:s,xAccessor:a.xAccessor,yAccessor:a.yAccessor,y0Accessor:o.y0Accessor,groupAccessor:o.areaBy||void 0,colorAccessor:n,colorScheme:i,...r,...a.annotations.length>0&&{annotations:a.annotations},...a.yExtent&&!r.yExtent&&{yExtent:a.yExtent},...void 0!==c&&{gradientFill:c},...u&&{semanticLineStops:u},lineStyle:r.lineStyle||on(s,n,i,r,o),...d&&{pointStyle:d}}}},cn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=o.xAccessor||"x",a=o.seriesAAccessor||"a",s=o.seriesBAccessor||"b",l=e=>sr(ar(n,"x",e)),c=e=>sr(ar(a,"a",e)),u=e=>sr(ar(s,"b",e)),d=o.seriesAColor||"var(--semiotic-danger, #dc2626)",h=o.seriesBColor||"var(--semiotic-info, #2563eb)",f=o.areaOpacity??.6,p=o.lineWidth??1.5,g=!1!==o.showLines,m=!1!==r.showLegend,y=o.seriesALabel||"A",x=o.seriesBLabel||"B",b=r.legendPosition||"right",v=qi(Array.isArray(e)?e:[],l,c,u),w=[];if(g&&Array.isArray(e)){let t=e.filter(e=>Number.isFinite(l(e))).sort((e,t)=>l(e)-l(t));for(let e of t){let t=l(e),i=c(e),r=u(e);Number.isFinite(i)&&w.push({__x:t,__y:i,__diffSegment:"line-A",__diffWinner:"A",__sourceDatum:e}),Number.isFinite(r)&&w.push({__x:t,__y:r,__diffSegment:"line-B",__diffWinner:"B",__sourceDatum:e})}}return{chartType:"mixed",data:[...v,...w],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(v.map(e=>e.__diffSegment))),areaStyle:Zi({seriesAColor:d,seriesBColor:h,areaOpacity:f,styleRules:o.styleRules}),lineStyle:Qi({seriesAColor:d,seriesBColor:h,lineWidth:p,styleRules:o.styleRules}),curve:o.curve||"linear",...r,...m&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:y,color:d},{label:x,color:h}]}]},legendPosition:b}}}},un={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=t||o.areaBy,a="string"==typeof n&&Array.isArray(e)?ji(e,n,i):void 0,s="number"==typeof o.areaOpacity?o.areaOpacity:.7,l=r.lineStyle||(e=>{let t=null==n?void 0:Di(e,n,a),i=o.showLine??!0,r=o.stroke??t,l=o.strokeWidth??o.lineWidth??2,c={fill:o.color??t,stroke:i?r:"none",...i?{strokeWidth:l}:{},fillOpacity:s,...null==o.opacity?{}:{opacity:o.opacity}},u=o.styleRules;if(u?.length){let t=V(o.yAccessor),i=n?String("function"==typeof n?n(e)??"":e[n]??""):void 0;Object.assign(c,U(e,u,{value:t(e),category:i}))}return c}),c=o.normalize?"zero":o.baseline??"zero",u=r.pointStyle||nn(e,n,i,r,o);return{chartType:"stackedarea",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:n,colorScheme:i,normalize:o.normalize,baseline:c,stackOrder:o.stackOrder,lineStyle:l,...r,...u&&{pointStyle:u},curve:r.curve??o.curve??"monotoneX",showLegend:r.showLegend??!!n}}},dn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let[n]=r.size??[600,400];return{chartType:"candlestick",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.highAccessor||"high",highAccessor:o.highAccessor||"high",lowAccessor:o.lowAccessor||"low",openAccessor:o.openAccessor,closeAccessor:o.closeAccessor,candlestickStyle:o.candlestickStyle,...r,...!r.pointStyle&&Array.isArray(o.styleRules)&&o.styleRules.length>0&&{pointStyle:Z(void 0,o.styleRules,q(o.xAccessor||"x",o.closeAccessor||o.highAccessor||"high"))},scalePadding:r.scalePadding??Math.max(2,Math.min(12,Math.round(n/40))),extentPadding:r.extentPadding??(n<=200?.02:.1)}}},hn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=o.xCenter,a=o.yCenter,s=o.quadrants,l=o.centerlineStyle||{},c=!1!==o.showQuadrantLabels,u=o.quadrantLabelSize??12,d=l.stroke||"#999",h=l.strokeWidth??1,f=Array.isArray(l.strokeDasharray)?l.strokeDasharray.join(","):l.strokeDasharray,p=ni.createElement,g=s?[(e,t,i)=>{if(!t?.x||!t?.y)return null;let r=i.width,o=i.height,l=null!=n?t.x(n):r/2,g=null!=a?t.y(a):o/2;if(null!=n&&!Number.isFinite(l)||null!=a&&!Number.isFinite(g))return null;let m=Math.max(0,Math.min(r,l)),y=Math.max(0,Math.min(o,g)),x=[{c:s.topLeft,x:0,y:0,w:m,h:y},{c:s.topRight,x:m,y:0,w:r-m,h:y},{c:s.bottomLeft,x:0,y:y,w:m,h:o-y},{c:s.bottomRight,x:m,y:y,w:r-m,h:o-y}],b=c?[p("text",{key:"ltl",x:8,y:8+u,fill:s.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},s.topLeft.label),p("text",{key:"ltr",x:r-8,y:8+u,fill:s.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},s.topRight.label),p("text",{key:"lbl",x:8,y:o-8,fill:s.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},s.bottomLeft.label),p("text",{key:"lbr",x:r-8,y:o-8,fill:s.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},s.bottomRight.label)]:[];return p(ni.Fragment,null,...x.map((e,t)=>e.w>0&&e.h>0?p("rect",{key:`qf-${t}`,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.c.color,opacity:e.c.opacity??.08}):null),p("line",{key:"vc",x1:m,y1:0,x2:m,y2:o,stroke:d,strokeWidth:h,strokeDasharray:f}),p("line",{key:"hc",x1:0,y1:y,x2:r,y2:y,stroke:d,strokeWidth:h,strokeDasharray:f}),...b)}]:void 0;return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[3,15],colorScheme:i,pointStyle:r.pointStyle||o.pointStyle||Zr(e,t,i,r,o),...r,showLegend:r.showLegend??!!t,...g&&{svgPreRenderers:g}}}},fn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=dr(e,o),a=Ur({data:n.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:hr(r.theme).colors.categorical}),s=ur(a.annotations,o.regression),l=o.pointRadius??4,c=q(o.xAccessor,o.yAccessor),u=o.styleRules,d=[e=>{let t=e.filter(e=>"point"===e.type&&"number"==typeof e.x&&"number"==typeof e.y);if(t.length<2)return null;let i=[];for(let e=0;e<t.length-1;e++){let r=t[e],o=t[e+1],n=lr(e,t.length);t.length<100&&i.push(ni.createElement("line",{key:`halo-${e}`,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:"white",strokeWidth:l+2,strokeLinecap:"round",opacity:.5})),i.push(ni.createElement("line",{key:`segment-${e}`,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:n,strokeWidth:l,strokeLinecap:"round"}))}return ni.createElement(ni.Fragment,null,...i)}];return{chartType:"scatter",data:a.data,xAccessor:a.xAccessor,yAccessor:a.yAccessor,colorAccessor:t,colorScheme:i,pointStyle:Xi(e=>{let t=n.orderMap.get(e),i=t?.idx??0,r=t?.total??1,o={fill:r>0?lr(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:l,fillOpacity:1};return u?.length&&Object.assign(o,U(e,u,c(e))),o},cr(o)),...r,...s&&s.length>0&&{annotations:s},...a.yExtent&&!r.yExtent&&{yExtent:a.yExtent},svgPreRenderers:d}}};function pn(e,t,i){let r=V(e),o=V(t),n=V(i);return e=>{let t="string"==typeof e.agg&&"number"==typeof e.count&&"number"==typeof e.xCenter&&"number"==typeof e.yCenter;return{value:t?gn(e.value):n(e),x:t?gn(e.xCenter):r(e),y:t?gn(e.yCenter):o(e)}}}function gn(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}var mn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=o.frameProps&&"object"==typeof o.frameProps?o.frameProps:void 0,a=Number.isFinite(o.cellBorderWidth)?Math.max(0,o.cellBorderWidth):1,s=Z(()=>({stroke:o.cellBorderColor??"#fff",strokeWidth:a}),o.styleRules,pn(o.xAccessor,o.yAccessor,o.valueAccessor)),l=("string"==typeof n?.colorScheme?n.colorScheme:void 0)??i,c=null!=n&&Object.hasOwn(n,"heatmapColorScale"),u=n?.heatmapColorScale,d=c?"function"==typeof u?u:void 0:"custom"===l&&"function"==typeof o.customColorScale?o.customColorScale:void 0;return{chartType:"heatmap",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,showValues:o.showValues,heatmapValueFormat:o.valueFormat,...o.heatmapAggregation&&{heatmapAggregation:o.heatmapAggregation},...null!=o.heatmapXBins&&{heatmapXBins:o.heatmapXBins},...null!=o.heatmapYBins&&{heatmapYBins:o.heatmapYBins},areaStyle:s,...r,...void 0!==l&&{colorScheme:l},...d&&{heatmapColorScale:d}}}};import*as yn from"react-dom/server";import*as xn from"react";import*as bn from"react-dom/server";var vn=class{constructor(e){if(this._capacity=e,this.head=0,this._size=0,e<1)throw new Error("RingBuffer capacity must be at least 1");this.buffer=new Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){let t=[];for(let i of e){let e=this.push(i);void 0!==e&&t.push(e)}return t}get(e){if(e<0||e>=this._size)return;let t=(this.head-this._size+e+this._capacity)%this._capacity;return this.buffer[t]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;return{next:()=>e>=this._size?{done:!0,value:void 0}:{done:!1,value:this.get(e++)}}}forEach(e){let t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;i<this._size;i++)e(this.buffer[(t+i)%this._capacity],i)}toArray(){let e=new Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;i<this._size;i++)e[i]=this.buffer[(t+i)%this._capacity];return e}resize(e){if(e<1)throw new Error("RingBuffer capacity must be at least 1");let t=this.toArray(),i=0,r=[];t.length>e&&(i=t.length-e,r=t.slice(0,i)),this._capacity=e,this.buffer=new Array(e),this.head=0,this._size=0;for(let e=i;e<t.length;e++)this.push(t[e]);return r}update(e,t){let i=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;o<this._size;o++){let n=(r+o)%this._capacity,a=this.buffer[n];if(e(a)){let e;e="object"!=typeof a||null===a?a:Array.isArray(a)?[...a]:{...a},i.push(e),this.buffer[n]=t(a)}}return i}remove(e){let t=[],i=[];if(this.forEach(r=>{e(r)?i.push(r):t.push(r)}),0===i.length)return i;this.buffer=new Array(this._capacity),this.head=0,this._size=0;for(let e of t)this.push(e);return i}clear(){this.buffer=new Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},wn=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(e<this._min&&(this._min=e),e>this._max&&(this._max=e))}evict(e){(e===this._min||e===this._max)&&(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(let i of e){let e=t?t(i):i;Number.isFinite(e)&&(e<this._min&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function kn(e){return new Set(Array.isArray(e)?e:[e])}function An(e,t,i){if(null!=e)return"function"==typeof e?e(t,i):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}function Sn(e){let t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||e.extent<=0)return 1;let i=Math.max(0,e.age);if("step"===e.type)return i<(e.threshold??.5*e.extent)?1:t;if("exponential"===e.type){let r=e.halfLife??e.extent/2,o=r>0?r:e.extent/2;return t+Math.pow(.5,i/o)*(1-t)}return t+Math.max(0,Math.min(1,1-i/e.extent))*(1-t)}function Mn(e,t,i){if(i<=1)return 1;let r=i-1;return Sn({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??i/2,threshold:e.stepThreshold??.5*i,minOpacity:e.minOpacity??.1})}function $n(e){let t=/* @__PURE__ */new Map;for(let i=0;i<e.length;i++)t.set(e[i],i);return t}function _n(e,t,i,r=$n(i)){let o=i.length;if(!(o<=1))for(let i of t){if("line"===i.type){let t=Array.isArray(i.datum)?i.datum:[];if(t.length<2)continue;let n=new Array(t.length),a=!1;for(let i=0;i<t.length;i++){let s=r.get(t[i]);null!=s?(n[i]=Mn(e,s,o),n[i]<1&&(a=!0)):n[i]=1}a&&(i._decayOpacities=n);continue}if("area"===i.type){let t=Array.isArray(i.datum)?i.datum:[],n=i.topPath?i.topPath.length:t.length;if(n<2)continue;if(t.length===n){let a=new Array(n),s=!1;for(let i=0;i<t.length;i++){let n=r.get(t[i]);null!=n?(a[i]=Mn(e,n,o),a[i]<1&&(s=!0)):a[i]=1}s&&(i._decayOpacities=a)}else{let a=1;for(let i of t){let t=r.get(i);if(null!=t){let i=Mn(e,t,o);i<a&&(a=i)}}if(a<1){let e=new Array(n);e.fill(a),i._decayOpacities=e}}continue}let t=r.get(i.datum);if(null==t)continue;let n=Mn(e,t,o);if("candlestick"===i.type)i._decayOpacity=n;else{let e=i.style?.opacity??1;i.style={...i.style,opacity:e*n}}}}function Ln(e,t,i){let r=e.duration??500,o=i-t;return o>=r?0:1-o/r}function Pn(e,t,i,r,o,n=(typeof performance<"u"?performance.now():Date.now())){let a=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4,l=!1,c=o??(()=>{let e=/* @__PURE__ */new Map;for(let t=0;t<i.length;t++)e.set(i[t],t);return e})();for(let i of t){if("line"===i.type)continue;if("area"===i.type){let t=Array.isArray(i.datum)?i.datum:[i.datum],o=0,s=!1;for(let i of t){let t=c.get(i);if(null==t)continue;s=!0;let a=r.get(t);if(null==a)continue;let l=Ln(e,a,n);l>o&&(o=l)}s&&(l=In(i,o,a)||l);continue}let t=c.get(i.datum);if(null==t)continue;let o=r.get(t);l=In(i,null==o?0:Ln(e,o,n),a,s)||l}return l}function In(e,t,i,r){let o=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,o=!0),e._pulseColor!==i&&(e._pulseColor=i,o=!0),e._pulseGlowRadius!==r&&(e._pulseGlowRadius=r,o=!0),o):(0!==e._pulseIntensity&&(e._pulseIntensity=0,o=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,o=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,o=!0),o)}function Rn(e,t,i=(typeof performance<"u"?performance.now():Date.now())){if(!t||0===t.size)return!1;let r=e.duration??500,o=t.peek();return null!=o&&i-o<r}var Tn=null;function Cn(){return Tn}var Nn=/* @__PURE__ */Object.create(null);function Fn(e){Nn[e.chartType]=e}function zn(e){return Nn[e]}function En(e){return Array.isArray(e)?{nodes:e,binBoundaries:[]}:{nodes:e.nodes,binBoundaries:e.binBoundaries}}var Dn=typeof window>"u"||typeof document>"u",On=/* @__PURE__ */new Set;function jn(e){zn(e)||Dn&&(On.has(e)||(On.add(e),console.warn(`[semiotic] StreamXYFrame: no XY plugin registered for "${e}" during SSR. Import a chart HOC, or call registerBuiltInXYPlugins() from "semiotic/xy" or "semiotic/realtime/core" before render.`)))}function Wn(e){if("production"===process.env.NODE_ENV)return;let{label:t,nodes:i,overlays:r,warned:o}=e;Bn(r)&&0===i.length&&Yn(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),i.length>0&&i.every(e=>null==e.datum)&&Yn(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function Bn(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(Bn))}function Yn(e,t,i){e.has(t)||(e.add(t),console.warn(i))}function Gn(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:String(e)}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}function Xn(e,t,i,r){let o=Gn(t),n="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:n,message:`Semiotic ${e} ${n} failed: ${o.message}`,error:o,recovery:i?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:i,affectedRevision:r}}function Vn(e){try{return{kind:"success",result:e.run()}}catch(t){let i=e.hasPreviousResult,r=Xn(e.family,t,i,e.revision);"production"!==process.env.NODE_ENV&&console.error(`[semiotic] ${e.logLabel} threw:`,t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,preservedLastGoodScene:i}}}function qn(e,t){let i="function"==typeof e?e:i=>i[e||t];return e=>{let t=i(e);return null==t?Number.NaN:+t}}function Hn(e){let t=[],i=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=qn(i&&e.valueAccessor||e.yAccessor,i?"value":"y");if(e.boundsAccessor){let i=y(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{let t=r(e);if(!Number.isFinite(t))return Number.NaN;let o=i(e);return Number.isFinite(o)&&0!==o?t+o:t},getBottom:e=>{let t=r(e);if(!Number.isFinite(t))return Number.NaN;let o=i(e);return Number.isFinite(o)&&0!==o?t-o:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){let i=Array.isArray(e.band)?e.band:[e.band];for(let e of i)t.push({kind:"band",getTop:qn(e.y1Accessor,"y1"),getBottom:qn(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}import{scaleLinear as Un,scaleLog as Zn,scaleSymlog as Qn,scaleTime as Kn,scaleUtc as Jn}from"d3-scale";function ea(e,t,i,r,o,n=!1){let a=/* @__PURE__ */new Map;for(let s of e){let e=t(s),l=i(s);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;let c=Math.floor(e/r)*r,u=a.get(c);if(u||(u={start:c,end:c+r,total:0,categories:/* @__PURE__ */new Map,...n?{rows:[],categoryRows:/* @__PURE__ */new Map}:{}},a.set(c,u)),u.total+=l,u.rows?.push(s),o){let e=o(s);if(u.categories.set(e,(u.categories.get(e)||0)+l),u.categoryRows){let t=u.categoryRows.get(e);t||(t=[],u.categoryRows.set(e,t)),t.push(s)}}}return a}function ta(e,t,i,r,o){let n=ea(e,t,i,r,o);if(0===n.size)return[0,0];let a=0;for(let e of n.values())e.total>a&&(a=e.total);return[0,a]}function ia(e,t){let i=0,r=0,o=0;for(let n of e){let e=t(n);null==e||Number.isNaN(e)||(o+=e,o<i&&(i=o),o>r&&(r=o))}return[i,r]}function ra(e,t,i,r,o,n){let a=[];for(let n of e){let e=i(n),s=r(n),l=o?o(n):0;if(!Number.isFinite(e)||!Number.isFinite(s)||!Number.isFinite(l))continue;let c=t.x(e),u=t.y(s),d=o?t.y(l):0;!Number.isFinite(c)||!Number.isFinite(u)||!Number.isFinite(d)||a.push({x:c,y:u,bottom:d,raw:s,datum:n})}a.sort((e,t)=>e.x-t.x);let s=new Array(a.length),l=o?new Array(a.length):[],c=new Array(a.length),u=new Array(a.length),d=n?new Array(a.length):void 0;for(let e=0;e<a.length;e++){let t=a[e];s[e]=[t.x,t.y],o&&(l[e]=[t.x,t.bottom]),c[e]=t.raw,u[e]=t.datum,d&&n&&(d[e]=String(n(t.datum)))}return d?{topPath:s,bottomPath:l,rawValues:c,datum:u,pathIds:d}:{topPath:s,bottomPath:l,rawValues:c,datum:u}}function oa(e,t,i,r,o,n,a){let{topPath:s,rawValues:l,datum:c,pathIds:u}=ra(e,t,i,r,void 0,a),d={type:"line",path:s,rawValues:l,style:o,datum:c,group:n};return u&&(d.pathIds=u),d}function na(e,t,i,r,o,n,a,s,l){return{type:"area",...ra(e,t,i,r,s??(()=>o),l),style:n,group:a}}function aa(e,t,i,r){let o=/* @__PURE__ */new Map;if("silhouette"===r)for(let r of e){let e=0;for(let o of t)e+=i(o,r)||0;o.set(r,-e/2)}else if("wiggle"===r){e.length>0&&o.set(e[0],0);for(let r=1;r<e.length;r++){let n=e[r-1],a=e[r],s=0,l=0,c=0;for(let e of t){let t=i(e,a)||0;s+=(2*c+t)*(t-(i(e,n)||0)),l+=t,c+=t}let u=o.get(n)??0,d=l>0?s/(2*l):0;o.set(a,u-d)}if(e.length>0){let r=0;for(let n of e){let e=0;for(let r of t)e+=i(r,n)||0;r+=(o.get(n)??0)+e/2}let n=r/e.length;for(let t of e)o.set(t,(o.get(t)??0)-n)}}else for(let t of e)o.set(t,0);return o}function sa(e,t,i){let r=0,o=0;for(let n of e){let e=0,a=0;for(let r of t){let t=i(r,n)||0;t>=0?e+=t:a+=t}a<r&&(r=a),e>o&&(o=e)}return[r,o]}function la(e,t,i,r,o,n,a,s="zero",l){let c=/* @__PURE__ */new Set,u=/* @__PURE__ */new Map;for(let t of e){let e=/* @__PURE__ */new Map;for(let o of t.data){let t=i(o),n=r(o);if(!Number.isFinite(t)||(c.add(t),!Number.isFinite(n)))continue;let a=e.get(t);a?(a.value+=n,a.sources?a.sources.push(o):a.sources=[a.datum,o]):e.set(t,{value:n,datum:o})}u.set(t.key,e)}let d,h=Array.from(c).sort((e,t)=>e-t);if(n){d=/* @__PURE__ */new Map;for(let t of h){let i=0;for(let r of e)i+=u.get(r.key)?.get(t)?.value||0;d.set(t,i||1)}}let f=aa(h,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)?.value||0,s),p="diverging"===s&&!n,g=[],m=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map,x=/* @__PURE__ */new Map,b=/* @__PURE__ */new Map;for(let e of h)y.set(e,f.get(e)??0),x.set(e,0),b.set(e,0);for(let i of e){let e=u.get(i.key),r=/* @__PURE__ */new Map,s=[],c=[],f=[],v=[],w=[],k=l?[]:void 0,A=!1,S=()=>{if(0!==s.length){if(s.length>=2){let e=A?s.map((e,t)=>t).sort((e,t)=>s[e][0]-s[t][0]):void 0,t=e?e.map(e=>v[e]):v,r={type:"area",topPath:e?e.map(e=>s[e]):s,bottomPath:e?e.map(e=>c[e]):c,rawValues:e?e.map(e=>f[e]):f,style:o(i.key,fo(i.data)),datum:t,accessibleDatum:e?e.map(e=>w[e]):w,group:i.key};k&&(r.pathIds=e?e.map(e=>k[e]):k),a&&(r.curve=a),g.push(r)}s=[],c=[],f=[],v=[],w=[],k=l?[]:void 0,A=!1}};for(let o of h){let a,l,u=e.get(o),h=void 0!==u,g=u?.value??0;if(n&&h&&(g/=d.get(o)),!h||!Number.isFinite(g)||0===g){S();continue}p?g>0?(a=x.get(o),l=a+g,x.set(o,l)):(a=b.get(o),l=a+g,b.set(o,l)):(a=y.get(o),l=a+g,y.set(o,l));let m=t.x(o),M=t.y(a),$=t.y(l);if(!Number.isFinite(m)||!Number.isFinite(M)||!Number.isFinite($)){S();continue}let _=u.sources,L=u.value,P=_?{..._[0],__aggregateValue:L,__aggregateCount:_.length,__aggregateRows:_}:u.datum;s.length>0&&m<s[s.length-1][0]&&(A=!0),s.push([m,$]),c.push([m,M]),v.push(P),f.push(L),k&&k.push(`x:${o}`),w.push(_?{x:o,value:L,group:i.key,observations:_.length}:P),r.set(o,l)}S(),m.set(i.key,r)}return{nodes:g,stackedTops:m}}function ca(e,t,i,r,o,n,a){let s=i(e),l=r(e);if(!Number.isFinite(s)||!Number.isFinite(l))return null;let c={type:"point",x:t.x(s),y:t.y(l),r:o,style:n,datum:e};return void 0!==a&&(c.pointId=a),c}function ua(e,t,i,r,o,n,a,s){let l=i(e),c=r(e);if(!Number.isFinite(l)||!Number.isFinite(c))return null;let u={type:"symbol",x:t.x(l),y:t.y(c),size:o,symbolType:n,style:a,datum:e};return void 0!==s&&(u.pointId=s),u}function da(e,t,i,r,o,n,a){return{type:"rect",x:e,y:t,w:i,h:r,style:o,datum:n,group:a}}function ha(e,t,i,r,o,n,a){let s={type:"heatcell",x:e,y:t,w:i,h:r,fill:o,datum:n};return void 0!==a?.value&&(s.value=a.value),a?.showValues&&(s.showValues=!0,a.valueFormat&&(s.valueFormat=a.valueFormat)),s}function fa(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function pa(e){let{config:t,groups:i,getX:r,getY:o}=e,n="exact"===(t.yAxisExtent??t.axisExtent);if(t.normalize){let i=[0,n?1:1+t.extentPadding];return{yDomain:i,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:i}}}let a=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===a)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};let s=/* @__PURE__ */new Map,l=/* @__PURE__ */new Set,c=0,u=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map;for(let e of i){let t=/* @__PURE__ */new Map,i=0;for(let n of e.data){let e=r(n),a=o(n);if(!Number.isFinite(e)||!Number.isFinite(a))continue;t.set(e,(t.get(e)||0)+a),l.add(e),i+=a;let s=(u.get(e)||0)+a;u.set(e,s),s>c&&(c=s)}s.set(e.key,t),d.set(e.key,i)}let h,f,p=t.stackOrder??"key",g=(e,t)=>e<t?-1:e>t?1:0;if("input"===p)h=i.map(e=>e.key);else if("insideOut"===p){let e=[...i].map(e=>e.key).sort((e,t)=>{let i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:g(e,t)}),t=[],r=[],o=0,n=0;for(let i of e)o<n?(t.push(i),o+=d.get(i)??0):(r.push(i),n+=d.get(i)??0);h=[...r.reverse(),...t]}else h="asc"===p?i.map(e=>e.key).sort((e,t)=>{let i=(d.get(e)??0)-(d.get(t)??0);return 0!==i?i:g(e,t)}):"desc"===p?i.map(e=>e.key).sort((e,t)=>{let i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:g(e,t)}):i.map(e=>e.key).sort(g);if("wiggle"===t.baseline||"silhouette"===t.baseline){let e=Array.from(l).sort((e,t)=>e-t),i=aa(e,h,(e,t)=>s.get(e)?.get(t)||0,t.baseline),r=1/0,o=-1/0;for(let t of e){let e=i.get(t)??0,n=u.get(t)??0;e<r&&(r=e),e+n>o&&(o=e+n)}(!Number.isFinite(r)||!Number.isFinite(o))&&(r=0,o=0);let a=o-r,c=n?0:a>0?a*t.extentPadding:1;f=[r-c,o+c]}else if("diverging"===t.baseline){let e=Array.from(l).sort((e,t)=>e-t),[i,r]=sa(e,h,(e,t)=>s.get(e)?.get(t)||0),o=r-i,a=n?0:o>0?o*t.extentPadding:1;f=[i-a,r+a]}else f=[0,c+(n?0:c>0?c*t.extentPadding:1)];return{yDomain:f,stackExtentCache:{key:a,yDomain:f}}}function ga(e,t,i,r,o,n,a){let[,s]=ta(e,t,i,r,o);return[0,a?s:s+s*n]}function ma(e,t,i,r){let[o,n]=ia(e,t),a=n-o,s=r?0:a>0?a*i:1;return[Math.min(0,o-Math.abs(s)),Math.max(0,n+Math.abs(s))]}function ya(e,t,i,r,o){let n=Array.from(new Set(e.map(t).filter(e=>Number.isFinite(e)))).sort((e,t)=>e-t);if(n.length<2)return fa(i,r);let a=n[0],s=n[1],l=n[n.length-1],c=n[n.length-2];return fa("log"===o&&a>0?[a/Math.sqrt(s/a),l*Math.sqrt(l/c)]:[a-(s-a)/2,l+(l-c)/2],r)}function xa(e,t,i){if(!i.length)return e;let[r,o]=e;for(let e of t)for(let t of i){let i=t.getTop(e),n=t.getBottom(e);Number.isFinite(i)&&(i<r&&(r=i),i>o&&(o=i)),Number.isFinite(n)&&(n<r&&(r=n),n>o&&(o=n))}return[r,o]}function ba(e,t){let i=e[1]-e[0],r=t.exactMode?0:i>0?i*t.extentPadding:1,o=[null!=t.userMin?e[0]:e[0]-r,null!=t.userMax?e[1]:e[1]+r];if("log"===t.yScaleType&&o[0]<=0&&t.dataYDomain[0]>0&&!t.exactMode){let e=1+t.extentPadding;null==t.userMin&&(o[0]=t.dataYDomain[0]/e)}return o}function va(e,t,i){if(!t||i)return e;let r=t[0],o=t[1];return null==r&&null==o?e:[r??e[0],o??e[1]]}function wa(e,t,i){let r=e,o=t;return(r[0]===1/0||r[1]===-1/0)&&(r="time"===i?[0,864e5]:[0,1]),(o[0]===1/0||o[1]===-1/0)&&(o=[0,1]),{xDomain:r,yDomain:o}}function ka(e,t,i){if("log"===e){let e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return Zn().domain(e).range(i).clamp(!0)}return"symlog"===e?Qn().domain(t).range(i):"time"===e||"utc"===e?("utc"===e?Jn():Kn()).domain([new Date(t[0]),new Date(t[1])]).range(i):Un().domain(t).range(i)}function Aa(e){let{config:t,layout:i,xDomain:r}=e,o=t.xScaleType??(e.xIsDate?"utc":void 0),n=t.invertY?[e.yDomain[1],e.yDomain[0]]:e.yDomain,a="streaming"===t.runtimeMode,s=t.scalePadding||0,l=Math.max(0,Math.min(s,Math.min(i.width,i.height)/2-1));return a?{x:ka(o,r,"left"===t.arrowOfTime?[i.width-l,l]:[l,i.width-l]),y:ka(t.yScaleType,n,[i.height-l,l])}:{x:ka(o,r,[l,i.width-l]),y:ka(t.yScaleType,n,[i.height-l,l])}}function Sa(e,t){return e&&"object"==typeof e&&!Array.isArray(e)?Oi(e,t):void 0}function Ma(e,t,i,r){if(r&&r.version===i&&r.group===t&&r.data===e)return{result:r.result,cache:r};let o;if(t){let i=/* @__PURE__ */new Map;for(let r of e){let e=t(r);i.has(e)||i.set(e,[]),i.get(e).push(r)}o=Array.from(i.entries()).map(([e,t])=>({key:e,data:t}))}else o=[{key:"_default",data:e}];return{result:o,cache:{version:i,group:t,data:e,result:o}}}function $a(e,t,i,r,o){if(o&&o.version===r)return{map:o.map,cache:o};let n=/* @__PURE__ */new Set;if(t)for(let i of e){let e=t(i);e&&n.add(e)}let a=Array.from(n).sort(),s=a.join("\0");if(o&&o.key===s){let e={...o,version:r};return{map:e.map,cache:e}}let l=Ci(i.colorScheme,i.themeCategorical,Ni),c=/* @__PURE__ */new Map;for(let e=0;e<a.length;e++)c.set(a[e],Sa(i.colorScheme,a[e])??l[e%l.length]);return{map:c,cache:{key:s,map:c,version:r}}}function _a(e){let{group:t,colorMapCache:i,groupColorMap:r,groupColorMapCap:o,config:n}=e,{groupColorCounter:a}=e,s=Sa(n.colorScheme,t);if(s)return{color:s,groupColorCounter:a};if(i){let e=i.map.get(t);if(e)return{color:e,groupColorCounter:a}}let l=r.get(t);if(l)return{color:l,groupColorCounter:a};let c=Ci(n.colorScheme,n.themeCategorical,Ni);if(0===c.length)return{color:null,groupColorCounter:a};let u=c[a%c.length];if(a++,r.set(t,u),r.size>o){let e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:u,groupColorCounter:a}}function La(e,t,i,r){let o=e.lineStyle;if("function"==typeof o){let e=o(i||{},t);if(e&&!e.stroke&&t){let i=r(t);if(i)return{...e,stroke:i}}return e}let n=e.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||n||"#007bff",strokeWidth:o.strokeWidth??2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity,cursor:o.cursor}:{stroke:r(t)||n||"#007bff",strokeWidth:2}}function Pa(e,t,i,r){if(e.areaStyle){let o=e.areaStyle(i||{});if(o&&!o.fill&&t){let e=r(t);if(e)return{...o,fill:e,stroke:o.stroke||e}}return o}let o=e.lineStyle;if("function"==typeof o){let e=o(i||{},t);if(e&&!e.fill&&t){let i=r(t);if(i)return{...e,fill:i,stroke:e.stroke||i}}return e}let n=e.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||n||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||n||"#4e79a7",strokeWidth:o.strokeWidth??2,cursor:o.cursor};let a=r(t)||n||"#4e79a7";return{fill:a,fillOpacity:.7,stroke:a,strokeWidth:2}}function Ia(e,t,i,r){let o=e.boundsStyle;if("function"==typeof o)return o(i||{},t);if(o&&"object"==typeof o)return o;let n=r(t,i);return{fill:n.stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,...null!=n.opacity&&{opacity:n.opacity},stroke:"none",cursor:n.cursor}}function Ra(e,t,i){t<=e.capacity||(e.resize(t),i&&t>i.capacity&&i.resize(t))}function Ta(e,t){let i=new vn(e.capacity);return e.forEach(()=>i.push(t)),i}function Ca(e,t,i,r){let o=e.push(t);return i&&i.push(r),o}function Na(e,t,i){if(!t||0===t.size)return;let r=/* @__PURE__ */new Set;if(e.forEach((e,t)=>{i(e)&&r.add(t)}),0===r.size)return;let o=t.toArray();t.clear();for(let e=0;e<o.length;e++)r.has(e)||t.push(o[e])}var Fa=/* @__PURE__ */new WeakMap,za=class{getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(e){return this.updateResults.subscribe(e)}setLayoutSelection(e){this.config.layoutSelection=e}markStylePaintPending(){Fa.set(this,!0)}consumeStylePaintPending(){let e=!0===Fa.get(this);return Fa.delete(this),e}},Ea=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Da=["scene-style","data-paint","accessibility","evidence"],Oa=(e,t)=>({retainedData:e,invalidations:t}),ja=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Wa=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ba=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ya=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ga=["scene-geometry","data-paint","accessibility","evidence"],Xa=["scene-style","data-paint","accessibility","evidence"],Va=["overlay","accessibility","evidence"],qa=[],Ha={chartType:/* @__PURE__ */Oa("rebuild",ja),runtimeMode:/* @__PURE__ */Oa("rebuild",ja),xAccessor:/* @__PURE__ */Oa("rebuild",ja),yAccessor:/* @__PURE__ */Oa("rebuild",ja),timeAccessor:/* @__PURE__ */Oa("rebuild",ja),valueAccessor:/* @__PURE__ */Oa("rebuild",ja),y0Accessor:/* @__PURE__ */Oa("rebuild",ja),boundsAccessor:/* @__PURE__ */Oa("rebuild",ja),band:/* @__PURE__ */Oa("rebuild",ja),openAccessor:/* @__PURE__ */Oa("rebuild",ja),highAccessor:/* @__PURE__ */Oa("rebuild",ja),lowAccessor:/* @__PURE__ */Oa("rebuild",ja),closeAccessor:/* @__PURE__ */Oa("rebuild",ja),candlestickRangeMode:/* @__PURE__ */Oa("rebuild",ja),accessorRevision:/* @__PURE__ */Oa("rebuild",ja),groupAccessor:/* @__PURE__ */Oa("rebuild",Wa),categoryAccessor:/* @__PURE__ */Oa("rebuild",Wa),lineDataAccessor:/* @__PURE__ */Oa("rebuild",Wa),colorAccessor:/* @__PURE__ */Oa("rebuild",Xa),sizeAccessor:/* @__PURE__ */Oa("rebuild",Ga),symbolAccessor:/* @__PURE__ */Oa("rebuild",Ga),pointIdAccessor:/* @__PURE__ */Oa("rebuild",Ga),xScaleType:/* @__PURE__ */Oa("preserve",Ba),yScaleType:/* @__PURE__ */Oa("preserve",Ba),xExtent:/* @__PURE__ */Oa("preserve",Ba),invertY:/* @__PURE__ */Oa("preserve",Ba),yExtent:/* @__PURE__ */Oa("preserve",Ba),extentPadding:/* @__PURE__ */Oa("preserve",Ba),scalePadding:/* @__PURE__ */Oa("preserve",Ba),axisExtent:/* @__PURE__ */Oa("preserve",Ba),yAxisExtent:/* @__PURE__ */Oa("preserve",Ba),binSize:/* @__PURE__ */Oa("preserve",Ba),normalize:/* @__PURE__ */Oa("preserve",Ba),heatmapAggregation:/* @__PURE__ */Oa("preserve",Ba),heatmapXBins:/* @__PURE__ */Oa("preserve",Ba),heatmapYBins:/* @__PURE__ */Oa("preserve",Ba),arrowOfTime:/* @__PURE__ */Oa("preserve",Ya),baseline:/* @__PURE__ */Oa("preserve",Ya),stackOrder:/* @__PURE__ */Oa("preserve",Ya),sizeRange:/* @__PURE__ */Oa("preserve",Ya),curve:/* @__PURE__ */Oa("preserve",Ya),areaGroups:/* @__PURE__ */Oa("preserve",Ya),customLayout:/* @__PURE__ */Oa("preserve",Ya),layoutConfig:/* @__PURE__ */Oa("preserve",Ya),layoutMargin:/* @__PURE__ */Oa("preserve",Ya),symbolMap:/* @__PURE__ */Oa("preserve",Ga),showValues:/* @__PURE__ */Oa("preserve",Ga),heatmapValueFormat:/* @__PURE__ */Oa("preserve",Ga),trackHoverRows:/* @__PURE__ */Oa("preserve",Ga),lineStyle:/* @__PURE__ */Oa("preserve",Xa),pointStyle:/* @__PURE__ */Oa("preserve",Xa),areaStyle:/* @__PURE__ */Oa("preserve",Xa),barStyle:/* @__PURE__ */Oa("preserve",Xa),swarmStyle:/* @__PURE__ */Oa("preserve",Xa),waterfallStyle:/* @__PURE__ */Oa("preserve",Xa),candlestickStyle:/* @__PURE__ */Oa("preserve",Xa),boundsStyle:/* @__PURE__ */Oa("preserve",Xa),gradientFill:/* @__PURE__ */Oa("preserve",Xa),lineGradient:/* @__PURE__ */Oa("preserve",Xa),semanticLineStops:/* @__PURE__ */Oa("preserve",Xa),colorScheme:/* @__PURE__ */Oa("preserve",Xa),themeCategorical:/* @__PURE__ */Oa("preserve",Xa),themeSemantic:/* @__PURE__ */Oa("preserve",Xa),themeSequential:/* @__PURE__ */Oa("preserve",Xa),themeDiverging:/* @__PURE__ */Oa("preserve",Xa),barColors:/* @__PURE__ */Oa("preserve",Xa),decay:/* @__PURE__ */Oa("preserve",Xa),pulse:/* @__PURE__ */Oa("preserve",Xa),staleness:/* @__PURE__ */Oa("preserve",Xa),layoutSelection:/* @__PURE__ */Oa("preserve",Xa),annotations:/* @__PURE__ */Oa("preserve",Va),windowSize:/* @__PURE__ */Oa("preserve",qa),windowMode:/* @__PURE__ */Oa("preserve",qa),maxCapacity:/* @__PURE__ */Oa("preserve",qa),clock:/* @__PURE__ */Oa("preserve",qa),transition:/* @__PURE__ */Oa("preserve",qa),introAnimation:/* @__PURE__ */Oa("preserve",qa),onLayoutError:/* @__PURE__ */Oa("preserve",qa)},Ua=/* @__PURE__ */Oa("preserve",Ya);function Za(e){let t="preserve",i=/* @__PURE__ */new Set;for(let r of e){let e=Ha[r]??Ua;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}var Qa=class{constructor(){this.tracker=new ne}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Ea)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Da):this.recordNoop("restyle")}recordConfig(e,t=!1){let i=Za(e);return this.tracker.record({kind:"config",keys:e},t?/* @__PURE__ */new Set([...i.invalidations,...Ga]):i.invalidations)}};import{quadtree as Ka}from"d3-quadtree";var Ja=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let i=0,r=0;for(let e of t)"point"===e.type&&!1!==e.interactive&&(i++,e.r>r&&(r=e.r));if(this.maxRadius=r,i<=500)return void(this.tree=null);let o=new Array(i),n=0;for(let e of t)"point"===e.type&&!1!==e.interactive&&(o[n++]=e);this.tree=Ka().x(e=>e.x).y(e=>e.y).addAll(o)}};function es(e){for(let t of e){if(void 0!==t._targetOpacity){let e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0);else if("glyph"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0);else if("rect"===t.type||"heatcell"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0);else if("candlestick"===t.type)void 0!==t._targetX&&(t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0);else if("line"===t.type||"area"===t.type){if(t._introClipFraction=void 0,"line"===t.type&&t._targetPath){for(let e=0;e<t.path.length;e++)t.path[e]=t._targetPath[e];t._prevPath=void 0,t._targetPath=void 0}if("area"===t.type){if(t._targetTopPath)for(let e=0;e<t.topPath.length;e++)t.topPath[e]=t._targetTopPath[e];if(t._targetBottomPath)for(let e=0;e<t.bottomPath.length;e++)t.bottomPath[e]=t._targetBottomPath[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}}}function ts(e){for(let t of e){if(void 0!==t._targetOpacity){let e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}"point"===t.type?void 0!==t._targetX?(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0):void 0!==t._targetR&&(t.r=t._targetR,t._targetR=void 0):"rect"===t.type?void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0):"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0)}}function is(e,t,i,r){let o=r.width/i.width,n=r.height/i.height;for(let t of e)switch(t.type){case"line":for(let e of t.path)e[0]*=o,e[1]*=n;break;case"area":for(let e of t.topPath)e[0]*=o,e[1]*=n;for(let e of t.bottomPath)e[0]*=o,e[1]*=n;t.clipRect&&(t.clipRect={x:t.clipRect.x*o,y:t.clipRect.y*n,width:t.clipRect.width*o,height:t.clipRect.height*n}),t.strokeColorBands&&(t.strokeColorBands=t.strokeColorBands.map(e=>({...e,y:e.y*n,height:e.height*n})));break;case"point":case"symbol":case"glyph":t.x*=o,t.y*=n;break;case"rect":case"heatcell":t.x*=o,t.y*=n,t.w*=o,t.h*=n}return{x:t.x.copy().range(t.x.range().map(e=>e*o)),y:t.y.copy().range(t.y.range().map(e=>e*n))}}var rs=class extends za{constructor(e){super(),this.xExtent=new wn,this.yExtent=new wn,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=/* @__PURE__ */new Map,this.prevPathMap=/* @__PURE__ */new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=/* @__PURE__ */new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new Qa,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this.xIsDate=!1,this.xTypeDetected=!1,this.spatialIndex=new Ja,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,i)=>!(!this.config.pulse||!this.timestampBuffer)&&Pn(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),i),this.config=e,this.buffer=new vn(e.windowSize),this.growingCap=e.windowSize;let t=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode;if(this.resolveXAccessor(),this.getY=t?y(e.valueAccessor||e.yAccessor,"value"):y(e.yAccessor,"y"),this.getGroup=b(e.groupAccessor),this.getCategory=b(e.categoryAccessor),this.getSize=e.sizeAccessor?y(e.sizeAccessor,"size"):void 0,this.getColor=b(e.colorAccessor),this.getSymbol=b(e.symbolAccessor),this.getY0=e.y0Accessor?y(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=Hn(e),this.getPointId=b(e.pointIdAccessor),"candlestick"===e.chartType){let t=null!=e.openAccessor,i=null!=e.closeAccessor;this.getOpen=t?y(e.openAccessor,"open"):void 0,this.getHigh=y(e.highAccessor,"high"),this.getLow=y(e.lowAccessor,"low"),this.getClose=i?y(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!i}e.pulse&&(this.timestampBuffer=new vn(e.windowSize))}currentTime(){return this.config.clock?.()??R()}resolveXAccessor(e=this.buffer){let t=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=t&&this.config.timeAccessor||this.config.xAccessor,r=x(i,t?"time":"x");this.xIsDate=!1,this.xTypeDetected=!1;for(let t of e){let e=r(t);if(null==e||""===e)continue;let i=e instanceof Date&&Number.isFinite(e.getTime())||"string"==typeof e&&Number.isFinite(d(e));if(i||Number.isFinite(Number(e))){this.xIsDate=i,this.xTypeDetected=!0;break}}this.getX=this.xIsDate?e=>h(r(e)):e=>+r(e)}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Ta(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(let t of this.resolvedRibbons){let i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&this.yExtent.push(i),Number.isFinite(r)&&this.yExtent.push(r)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(let t of this.resolvedRibbons){let i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&this.yExtent.evict(i),Number.isFinite(r)&&this.yExtent.evict(r)}}rebuildYExtent(){this.yExtent.clear();for(let e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(let e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;let t=this.currentTime();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.resolveXAccessor(e.inserts);let i=e.totalSize||e.inserts.length;Ra(this.buffer,i,this.timestampBuffer);for(let i of e.inserts)Ca(this.buffer,i,this.timestampBuffer,t),this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i)}else{this.xTypeDetected||this.resolveXAccessor(e.inserts);for(let i of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){let e=this.config.maxCapacity??1e5;this.growingCap<e&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"!==process.env.NODE_ENV&&!this.growingCapacityWarned&&this.growingCap>=5e4&&(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}let e=Ca(this.buffer,i,this.timestampBuffer,t);this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){let{config:t,buffer:i}=this,r=this.scales,o=this.lastLayout;if(!(e.width>0&&e.height>0&&Number.isFinite(e.width)&&Number.isFinite(e.height)))return void(this.needsFullRebuild=!0);if(!this.needsFullRebuild&&!t.customLayout&&!this.activeTransition&&"bar"!==t.chartType&&"waterfall"!==t.chartType&&"candlestick"!==t.chartType&&this.lastLayout&&this.lastLayout.width>0&&this.lastLayout.height>0&&this.scene.length>0&&this.scales&&(this.config.scalePadding??0)<=0&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return this.scales=is(this.scene,this.scales,this.lastLayout,e),this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(t.chartType,this.scene),void this.version++;this.xExtent.dirty&&this.xExtent.recalculate(i,this.getX),this.yExtent.dirty&&this.rebuildYExtent();let n=this.getBufferArray(),a=this.xExtent.extent,s=this.yExtent.extent,l="waterfall"===t.chartType&&i.size>0?ya(n,this.getX,a,t.xExtent,t.xScaleType):fa(a,t.xExtent),c=fa(s,t.yExtent),u=!(!(h=t.yExtent)||null==h[0]||null==h[1]),d="exact"===(t.yAxisExtent??t.axisExtent);var h;if("stackedarea"===t.chartType&&!u&&i.size>0){let e=pa({config:t,groups:this.groupData(n),getX:this.getX,getY:this.getY,bufferSize:i.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!u&&i.size>0?c=ga(i,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,d):"waterfall"===t.chartType&&!u&&i.size>0?c=ma(i,this.getY,t.extentPadding,d):!u&&c[0]!==1/0&&(c=xa(c,n,this.resolvedRibbons),c=ba(c,{exactMode:d,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=va(c,t.yExtent,!!u),({xDomain:l,yDomain:c}=wa(l,c,t.xScaleType)),this.scales=Aa({config:t,layout:e,xDomain:l,yDomain:c,xIsDate:this.xIsDate}),this._customLayoutFailedThisBuild=!1;let f=this.buildSceneNodes(e,n);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.lastLayout=o):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);let p=this.config.transition?Cn():null;p&&this.scene.length>0&&this.snapshotPositions(),this.scene=f,this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&p&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),p&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}buildSceneNodes(e,t){let{config:i,scales:r}=this;if(!r)return[];if(i.customLayout){let o=i.layoutMargin??{top:0,right:0,bottom:0,left:0},n={data:t,scales:r,dimensions:{width:e.width,height:e.height,margin:o,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:i.themeSemantic??{},categorical:i.themeCategorical??Ni},resolveColor:(e,t)=>{let r=this.resolveGroupColor(e);if(r)return r;let o=this.resolveLineStyle(e,t);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:i.themeSemantic?.primary??"#4e79a7"},config:i.layoutConfig??{},selection:i.layoutSelection??null},a=Vn({family:"xy",logLabel:"customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:i.onLayoutError,run:()=>i.customLayout(n)});if("failure"===a.kind)return this.lastCustomLayoutFailure=a.diagnostic,this._customLayoutFailedThisBuild=!0,a.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);let s=a.result;this.customLayoutOverlays=s.overlays??null,this.lastCustomLayoutResult=s,this.lastCustomLayoutFailure=null;let l=s.nodes??[];if(this._customRestyle=s.restyle,this.hasCustomRestyle=!!s.restyle,this.hasCustomRestyle){this._baseStyles=/* @__PURE__ */new WeakMap;for(let e of l)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(l,i.layoutSelection??null)}return Wn({label:"customLayout",nodes:l,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),l}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];let o={scales:r,config:i,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache},n=(a=i.chartType,Nn[a]?.buildScene);var a;if(!n)return jn(i.chartType),[];let s=En(n(o,t,e));return"bar"===i.chartType&&(this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=s.binBoundaries),s.nodes}resolveBoundsStyle(e,t){return Ia(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){let i=this.config.decay;return!i||t<=1?1:Mn(i,e,t)}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;let t=$n(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&_n(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&Rn(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory,getPointId:this.getPointId}}get hasRenderedOnce(){return this._hasRenderedOnce}snapshotPositions(){Cn()?.snapshotPositions(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();let e=this.scales?.y(0)??0,t=Cn();if(t)for(let i=0;i<this.scene.length;i++){let r=this.scene[i],o=t.getNodeIdentity(this.transitionContext,r,i);o&&("point"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,r:0,opacity:0}):"rect"===r.type?this.prevPositionMap.set(o,{x:r.x,y:e,w:r.w,h:0,opacity:r.style.opacity??1}):"heatcell"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:0}):"line"===r.type?(r._introClipFraction=0,this.prevPathMap.set(o,{path:r.path.map(e=>[e[0],e[1]]),pathIds:r.pathIds?.slice(),opacity:r.style.opacity})):"area"===r.type&&(r._introClipFraction=0,this.prevPathMap.set(o,{topPath:r.topPath.map(e=>[e[0],e[1]]),bottomPath:r.bottomPath.map(e=>[e[0],e[1]]),pathIds:r.pathIds?.slice(),opacity:r.style.opacity})))}}startTransition(){let e=Cn();if(!this.config.transition||!e)return;let t=e.startTransition(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(e){let t=Cn();if(!this.activeTransition||!this.config.transition||!t)return!1;let i={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},r=t.advanceTransition(e,this.config.transition,i,this.prevPositionMap,this.prevPathMap);return this.scene=i.scene,this.exitNodes=i.exitNodes,this.activeTransition=i.activeTransition,r}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null,es(this.scene),this.exitNodes=[]}groupData(e){let{result:t,cache:i}=Ma(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,t}resolveColorMap(e){let{map:t,cache:i}=$a(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,t}resolveLineStyle(e,t){return La(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return Pa(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(e){let{color:t,groupColorCounter:i}=_a({group:e,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:1e3,config:this.config});return this._groupColorCounter=i,t}getBufferArray(){return(this._bufferDirty||!this._bufferArrayCache)&&(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw new Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&Cn()&&this.snapshotPositions();let t=kn(e),i=this.getPointId,r=e=>t.has(i(e));Na(this.buffer,this.timestampBuffer,r);let o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(let e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getPointId)throw new Error("update() requires pointIdAccessor to be configured");let i=kn(e),r=this.getPointId,o=/* @__PURE__ */new Set;this.buffer.forEach((e,t)=>{i.has(r(e))&&o.add(t)});let n=this.buffer.update(e=>i.has(r(e)),t);if(0===n.length)return this.updateResults.recordNoop("update"),n;for(let e of n)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{o.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",n.length),n}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.resolveXAccessor(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=/* @__PURE__ */new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(e,t){let i=this._customRestyle;if(i)for(let r of e){let e=this._baseStyles.get(r)??r.style??{},o=i(r,t);r.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){let t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=/* @__PURE__ */new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let r=!1,o=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let n="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(n||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){let e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=e&&this.config.timeAccessor||this.config.xAccessor,a=e&&t.timeAccessor||t.xAccessor,s=e&&this.config.valueAccessor||this.config.yAccessor,l=e&&t.valueAccessor||t.yAccessor,c=n||!m(i,a),u=n||!m(s,l);(c||u)&&(c&&this.resolveXAccessor(),this.getY=e?y(this.config.valueAccessor||this.config.yAccessor,"value"):y(this.config.yAccessor,"y"),u&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=Hn(this.config)),r=!0,o=!0)}if("groupAccessor"in e&&!m(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?b(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!m(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?b(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!m(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?y(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!m(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?b(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!m(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?b(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!m(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?y(this.config.y0Accessor,"y0"):void 0,r=!0,o=!0),("boundsAccessor"in e&&!m(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=Hn(this.config),r=!0,o=!0),"pointIdAccessor"in e&&!m(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?b(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(n||"openAccessor"in e&&!m(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!m(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!m(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!m(e.lowAccessor,t.lowAccessor))){let e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?y(this.config.openAccessor,"open"):void 0,this.getHigh=y(this.config.highAccessor,"high"),this.getLow=y(this.config.lowAccessor,"low"),this.getClose=t?y(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,r=!0,o=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(this.resolveXAccessor(),r=!0,o=!0),!r){let i=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(let o of i)if(e[o]!==t[o]){r=!0;break}}r&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(i,("bar"===this.config.chartType||"heatmap"===this.config.chartType)&&!this.config.trackHoverRows&&po(t.areaStyle)!==po(this.config.areaStyle))}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};function os(e,t,i,r){return"function"==typeof t.style?t.style(r||{},i):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(i,r)}function ns(e,t,i,r){if(!e.scales)return null;let{topPath:o,bottomPath:n,datum:a,pathIds:s}=ra(t,e.scales,e.getX,r.getTop,r.getBottom,e.getPointId);return o.length<2?null:{type:"area",topPath:o,bottomPath:n,...s&&{pathIds:s},...e.config.curve&&"linear"!==e.config.curve&&{curve:e.config.curve},style:os(e,r,i,fo(t)),datum:a,group:i,interactive:r.interactive}}function as(e){let t=[],i=[];if(!e)return{perSeries:t,aggregate:i};for(let r of e)r.perSeries?t.push(r):i.push(r);return{perSeries:t,aggregate:i}}function ss(e,t,i){let r=[];for(let o of i){let i=ns(e,t,"__ribbon_aggregate",o);i&&r.push(i)}return r}function ls(e,t,i,r){let o=[];for(let n of r){let r=ns(e,t,i,n);r&&o.push(r)}return o}function cs(e,t,i,r){if(!e.config.pointStyle)return;let o=r??e.getY;for(let r of t){let t=e.resolveGroupColor(r.key);for(let n of r.data){let r=e.config.pointStyle(n);!r.fill&&t&&(r={...r,fill:t});let a=r.r??3,s=e.getPointId?String(e.getPointId(n)):void 0,l=ca(n,e.scales,e.getX,o,a,r,s);l&&i.push(l)}}}function us(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}function ds(e){return Ji(e)}function hs(e,t){if("domain"!==e.extent)return;let[i,r]=t.domain(),o=t(r),n=t(i);return Number.isFinite(o)&&Number.isFinite(n)?[o,n]:void 0}function fs(e,t){let i=[],r="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15],n=null;if(e.getSize&&!e.config.pointStyle){let i=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(i.length>0){let e=1/0,t=-1/0;for(let r of i)r<e&&(e=r),r>t&&(t=r);n=i=>e===t?(o[0]+o[1])/2:o[0]+(i-e)/(t-e)*(o[1]-o[0])}}let a=e.getColor?e.resolveColorMap(t):null,s=e.config.themeSemantic?.primary||"#4e79a7",l=e.getSymbol,c=l?Be(l,e.config.symbolMap):null;for(let o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:s,opacity:.8},l=t.r||r;if(n&&e.getSize){let t=e.getSize(o);null!=t&&!Number.isNaN(t)&&(l=n(t))}if(a&&e.getColor&&!t.fill){let i=e.getColor(o);i&&a.has(i)&&(t={...t,fill:a.get(i)})}let u=e.getPointId?String(e.getPointId(o)):void 0;if(c){let r=c(o),n=ua(o,e.scales,e.getX,e.getY,Math.PI*l*l,r,t,u);n&&i.push(n)}else{let r=ca(o,e.scales,e.getX,e.getY,l,t,u);r&&i.push(r)}}return i}var ps=/* @__PURE__ */new Map;function gs(e,t,i){return t===i?Math.floor(128):Math.min(Math.floor(255*(e-t)/(i-t)+.5),255)}function ms(e){let t=Object.prototype.hasOwnProperty.call(wi,e)?e:"blues",i=ps.get(t);if(i)return i;i=new Array(256);let r=ki(t);for(let e=0;e<256;e++)i[e]=r(e/255);return ps.set(t,i),i}function ys(e,t,i){let r=i.config.areaStyle?.(t);return r&&("string"==typeof r.fill&&(e.fill=r.fill),e.style=r),e}function xs(e,t,i){let r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),o=Math.max(1,Math.floor(e.config.heatmapYBins??20)),n=e.config.heatmapAggregation??"count",a=y(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];let[s,l]=e.scales.x.domain(),[c,u]=e.scales.y.domain(),d=(l-s||1)/r,h=(u-c||1)/o,f=r*o;if(f>1e6)return[];let p=new Int32Array(f),g=new Float64Array(f),m=e.config.trackHoverRows||po(e.config.areaStyle)?/* @__PURE__ */new Map:void 0;for(let i=0;i<t.length;i++){let n=t[i],l=e.getX(n),u=e.getY(n);if(!isFinite(l)||!isFinite(u))continue;let f=Math.min(Math.floor((l-s)/d),r-1),y=Math.min(Math.floor((u-c)/h),o-1);if(f<0||y<0)continue;let x=y*r+f;p[x]++;let b=a(n);if(g[x]+=isFinite(b)?b:0,m){let e=m.get(x);e||(e=[],m.set(x,e)),e.push(n)}}let x=1/0,b=-1/0;for(let e=0;e<f;e++){if(0===p[e])continue;let t;switch(n){case"sum":t=g[e];break;case"mean":t=g[e]/p[e];break;default:t=p[e]}t<x&&(x=t),t>b&&(b=t)}if(!isFinite(x))return[];let v=e.config.heatmapColorScale,w="string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues",k=v?void 0:ms(w),A=i.width/r,S=i.height/o,M=e.config.showValues,$=e.config.heatmapValueFormat,_=[];for(let t=0;t<o;t++){let i=t*r;for(let a=0;a<r;a++){let r,l=i+a;if(0===p[l])continue;switch(n){case"sum":r=g[l];break;case"mean":r=g[l]/p[l];break;default:r=p[l]}let u=gs(r,x,b),f=v?v(r):k[u],y=M?{value:r,showValues:!0,valueFormat:$}:{value:r},w=s+(a+.5)*d,L=c+(t+.5)*h,P=co({xi:a,yi:t,value:r,count:p[l],sum:g[l],xCenter:w,yCenter:L,agg:n},m?.get(l));_.push(ys(ha(a*A,(o-1-t)*S,A,S,f,P,y),P,e))}}return _}function bs(e){if(!Array.isArray(e))return;let t=e.filter(e=>!!e&&("string"==typeof e.fill||"object"==typeof e.fill&&null!==e.fill)),i=t.filter(e=>"number"==typeof e.upTo&&Number.isFinite(e.upTo)).map(e=>({upTo:e.upTo,fill:e.fill})).sort((e,t)=>e.upTo-t.upTo),r=t.find(e=>"number"!=typeof e.upTo||!Number.isFinite(e.upTo)),o=r?[...i,{upTo:1/0,fill:r.fill}]:i;return o.length>0?o:void 0}function vs(e,t,i,r){let o=Math.min(t,i),n=Math.max(t,i);if(!(n>o))return[];let a=[],s=-1/0;for(let t of e){let e=Math.max(s,o),i=Math.min(t.upTo,n);if(i>e&&a.push({from:e,to:i,fill:t.fill}),s=t.upTo,s>=n)break}return s<n&&a.push({from:Math.max(s,o),to:n,fill:r}),a}var ws={line:function(e,t){let i=e.groupData(t),r=[],o=e.config.annotations?.filter(us).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:n}=as(e.ribbons);if(n.length>0&&r.push(...ss(e,t,n)),o.length>0)for(let t of i)r.push(...ls(e,t.data,t.key,o))}for(let t of i){let i=e.resolveLineStyle(t.key,fo(t.data)),n=oa(t.data,e.scales,e.getX,e.getY,i,t.key,e.getPointId);o&&o.length>0&&(n.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(n.curve=e.config.curve),e.config.lineGradient&&(n.strokeGradient=e.config.lineGradient),r.push(n)}return cs(e,i,r),r},area:function(e,t){let i=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:n}=as(e.ribbons);if(n.length>0&&r.push(...ss(e,t,n)),o.length>0)for(let t of i)r.push(...ls(e,t.data,t.key,o))}let o=e.scales.y.domain(),n=o[0],a=e.config.semanticLineStops?.filter(e=>Number.isFinite(e.offset)).map(e=>({value:o[0]+Math.max(0,Math.min(1,e.offset))*(o[1]-o[0]),color:e.color,opacity:e.opacity,thresholdType:"greater"})).sort((e,t)=>e.value-t.value),s=a&&a.length>0?(()=>{let t=a.reduce((e,t)=>(e.at(-1)?.value===t.value?e[e.length-1]=t:e.push(t),e),[]),i=[{from:o[0],to:t[0].value,color:t[0].color,opacity:t[0].opacity}];for(let e=0;e<t.length;e++)i.push({from:t[e].value,to:t[e+1]?.value??o[1],color:t[e].color,opacity:t[e].opacity});return i.map(({from:t,to:i,color:r,opacity:o})=>{let n=e.scales.y(t),a=e.scales.y(i);return{y:Math.min(n,a),height:Math.abs(a-n),color:r,...null!=o&&{opacity:o}}}).filter(e=>e.height>0)})():void 0,l=e.getY0?t=>e.getY0(t)??n:void 0;for(let t of i){let i=e.resolveAreaStyle(t.key,fo(t.data)),o=na(t.data,e.scales,e.getX,e.getY,n,i,t.key,l,e.getPointId),c=ds(e.config.gradientFill);if(c){o.fillGradient=c;let t=hs(c,e.scales.y);t&&(o.fillGradientSpan=t)}e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),a&&a.length>0&&(o.colorThresholds=a,o.strokeColorBands=s),r.push(o)}return cs(e,i,r),r},stackedarea:function(e,t){let i=e.groupData(t),r=e.config.stackOrder??"key",o=()=>i.sort((e,t)=>e.key<t.key?-1:e.key>t.key?1:0);if("input"!==r)if("key"===r)o();else if("asc"===r||"desc"===r||"insideOut"===r){let t=/* @__PURE__ */new Map;for(let r of i){let i=0;for(let t of r.data){let r=e.getX(t),o=e.getY(t);Number.isFinite(r)&&Number.isFinite(o)&&(i+=o)}t.set(r.key,i)}let o=(e,t)=>e<t?-1:e>t?1:0;if("asc"===r)i.sort((e,i)=>{let r=(t.get(e.key)??0)-(t.get(i.key)??0);return 0!==r?r:o(e.key,i.key)});else if("desc"===r)i.sort((e,i)=>{let r=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,i.key)});else{let e=[...i].sort((e,i)=>{let r=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,i.key)}),r=[],n=[],a=0,s=0;for(let i of e)a<s?(r.push(i),a+=t.get(i.key)??0):(n.push(i),s+=t.get(i.key)??0);i.length=0,i.push(...n.reverse(),...r)}}else o();let n=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,a=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:s,stackedTops:l}=la(i,e.scales,e.getX,e.getY,(t,i)=>e.resolveAreaStyle(t,i),e.config.normalize,n,a,e.getPointId),c=s;if(e.config.pointStyle){let t=/* @__PURE__ */new WeakMap;for(let r of i){let i=l.get(r.key);if(i)for(let o of r.data){let r=e.getX(o),n=e.getY(o);null!=r&&!Number.isNaN(r)&&null!=n&&!Number.isNaN(n)&&i.has(r)&&t.set(o,i.get(r))}}cs(e,i,c,i=>t.get(i)??e.getY(i))}return c},mixed:function(e,t){let i=e.groupData(t),r=[],o=e.config.areaGroups||/* @__PURE__ */new Set;if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:n}=as(e.ribbons);if(n.length>0&&r.push(...ss(e,t,n)),o.length>0)for(let t of i)r.push(...ls(e,t.data,t.key,o))}let n=e.scales.y.domain()[0],a=e.getY0?t=>e.getY0(t)??n:void 0;for(let t of i)if(o.has(t.key)){let i=e.resolveAreaStyle(t.key,fo(t.data)),o=na(t.data,e.scales,e.getX,e.getY,n,i,t.key,a,e.getPointId),s=ds(e.config.gradientFill);if(s){o.fillGradient=s;let t=hs(s,e.scales.y);t&&(o.fillGradientSpan=t)}e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}else{let i=e.resolveLineStyle(t.key,fo(t.data)),o=oa(t.data,e.scales,e.getX,e.getY,i,t.key,e.getPointId);e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return cs(e,i,r),r},scatter:fs,bubble:fs,heatmap:function(e,t,i){if(e.config.heatmapAggregation)return xs(e,t,i);if(0===t.length)return[];let r=y(e.config.valueAccessor,"value"),o=x(e.config.xAccessor,"x"),n=x(e.config.yAccessor,"y"),a=/* @__PURE__ */new Map,s=/* @__PURE__ */new Map,l=new Array(t.length),c=new Array(t.length);for(let e=0;e<t.length;e++){let i=t[e],r=o(i),u=n(i);l[e]=r,c[e]=u,a.has(r)||a.set(r,a.size),s.has(u)||s.set(u,s.size)}let u=a.size,d=s.size;if(0===u||0===d)return[];let h=Array.from(a.keys()),f=Array.from(s.keys()),p=h.every(e=>"number"==typeof e&&!isNaN(e)),g=f.every(e=>"number"==typeof e&&!isNaN(e)),m=4096;if(p&&g&&u*d>m&&t.length>m){let r=/* @__PURE__ */new Set;for(let o=0;o<t.length;o++){let n=a.get(l[o]),d=s.get(c[o]);if(void 0!==n&&void 0!==d&&(r.add(d*u+n),r.size>m))return xs({...e,config:{...e.config,heatmapAggregation:e.config.valueAccessor?"mean":"count"}},t,i)}}if(p){h.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;e<h.length;e++)a.set(h[e],e)}if(g){f.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;e<f.length;e++)s.set(f[e],e)}let b=new Float64Array(t.length),v=new Float64Array(t.length),w=new Array(t.length),k=/* @__PURE__ */new Map,A=0;for(let e=0;e<t.length;e++){let i=t[e],o=a.get(l[e]),n=s.get(c[e]);if(void 0===o||void 0===n)continue;let d,h=r(i),f=n*u+o,p=k.get(f);void 0!==p?d=p:(d=A++,k.set(f,d)),b[d]=f,v[d]=h,w[d]=i}let S=1/0,M=-1/0;for(let e=0;e<A;e++){let t=v[e];isFinite(t)&&(t<S&&(S=t),t>M&&(M=t))}if(!isFinite(S)||!isFinite(M))return[];let $="string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues",_=e.config.heatmapColorScale,L=_?void 0:ms($),P=i.width/u,I=i.height/d,R=e.config.showValues,T=e.config.heatmapValueFormat,C=[];for(let t=0;t<A;t++){let i=v[t];if(!isFinite(i))continue;let r=b[t],o=r%u,n=(r-o)/u,a=gs(i,S,M),s=_?_(i):L[a],l=R?{value:i,showValues:!0,valueFormat:T}:{value:i},c=w[t];C.push(ys(ha(o*P,(d-1-n)*I,P,I,s,c,l),c,e))}return C},bar:function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};let i=ea(t,e.getX,e.getY,e.config.binSize,e.getCategory,!!e.config.trackHoverRows||po(e.config.areaStyle));if(0===i.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){let t=/* @__PURE__ */new Set;for(let e of i.values())for(let i of e.categories.keys())t.add(i);let o=e.config.barColors?Object.keys(e.config.barColors):[],n=new Set(o),a=Array.from(t).filter(e=>!n.has(e)).sort(),s=o.filter(e=>t.has(e)),l=s.join("\0")+""+a.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...s,...a],e.barCategoryCache={key:l,order:r})}let o=[],n=e.scales,[a,s]=n.x.domain(),l=e.config.barStyle,c=e.config.themeSemantic?.primary,u=l?.gap,d="number"==typeof u&&u>=0?u:1,h={};l?.stroke&&(h.stroke=l.stroke),"number"==typeof l?.strokeWidth&&(h.strokeWidth=l.strokeWidth),"number"==typeof l?.opacity&&(h.opacity=l.opacity),l?.cursor&&(h.cursor=l.cursor);let f=bs(l?.valueBands);for(let t of i.values()){let i=Math.max(t.start,a),u=Math.min(t.end,s);if(i>=u)continue;let p=n.x(i),g=n.x(u),m=Math.abs(g-p),y=m>d+1?d:0,x=Math.min(p,g)+y/2,b=Math.max(m-y,1);if(!(b<=0))if(r&&t.categories.size>0){let i=co(r.flatMap(e=>{let i=t.categories.get(e)||0;return 0===i?[]:[co({category:e,value:i},t.categoryRows?.get(e))]}),t.rows),a=0;for(let{category:r,value:s}of i){let u=n.y(a),d=n.y(a+s),f=Math.min(u,d),p=Math.abs(u-d),g=(e.config.barColors?Oi(e.config.barColors,r):void 0)??l?.fill??c??"#4e79a7",m=co({binStart:t.start,binEnd:t.end,total:t.total,category:r,categoryValue:s,categories:i},t.categoryRows?.get(r)),y=e.config.areaStyle?.(m)??{};o.push(da(x,f,b,p,{fill:g,...h,...y},m,r)),a+=s}}else{let i=n.y(0),r=n.y(t.total),a=Math.min(i,r),s=Math.abs(i-r),u=l?.fill||c||"#007bff",d=co({binStart:t.start,binEnd:t.end,total:t.total},t.rows),p=e.config.areaStyle?.(d)??{},g=da(x,a,b,s,{fill:u,...h,...p},d);if(f){let e=g.style.fill,i="string"==typeof e||"object"==typeof e&&null!==e&&"hatch"===e.type?e:void 0,r=vs(f,0,t.total,i);r.length>0&&(g.fillBands=r.map(e=>({y0:n.y(e.from),y1:n.y(e.to),fill:e.fill??u})))}o.push(g)}}let p=/* @__PURE__ */new Set;for(let e of i.values())p.add(e.start),p.add(e.end);return{nodes:o,binBoundaries:Array.from(p).sort((e,t)=>e-t)}},swarm:function(e,t){let i=[],r=e.config.swarmStyle||{},o=r.radius??3,n=r.fill??e.config.themeSemantic?.primary??"#007bff",a=r.opacity??.7,s=r.stroke,l=r.strokeWidth,c=r.cursor;for(let r of t){let t=e.getX(r),u=e.getY(r);if(null==u||Number.isNaN(u))continue;let d=e.scales.x(t),h=e.scales.y(u),f=n;if(e.getCategory){let t=String(e.getCategory(r));f=(e.config.barColors?Oi(e.config.barColors,t):void 0)??f}let{r:p,...g}=e.config.pointStyle?.(r)??{},m={type:"point",x:d,y:h,r:p??o,style:{fill:f,opacity:a,stroke:s,strokeWidth:l,cursor:c,...g},datum:r};e.getPointId&&(m.pointId=String(e.getPointId(r))),i.push(m)}return i},waterfall:function(e,t,i){let r=[],o=e.scales,n=e.config.waterfallStyle,a=t.filter(t=>{let i=e.getY(t),r=e.getX(t);return null!=i&&!Number.isNaN(i)&&null!=r&&isFinite(r)});if(0===a.length)return r;let s=n?.positiveColor??e.config.themeSemantic?.success??"#28a745",l=n?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",c=n?.gap??1,u=n?.stroke,d=n?.strokeWidth,h=n?.opacity,f=0;for(let t=0;t<a.length;t++){let p=a[t],g=e.getX(p),m=e.getY(p),y=f+m,x=o.x(g),b=t>0?o.x(e.getX(a[t-1])):void 0,v=t<a.length-1?o.x(e.getX(a[t+1])):void 0,w=null!=b?(b+x)/2:null!=v?x-(v-x)/2:x-i.width/20,k=null!=v?(x+v)/2:null!=b?x+(x-b)/2:x+i.width/20,A=Math.min(w,k)+c/2,S=Math.max(w,k)-c/2-A;if(S<=0){f=y;continue}let M=o.y(f),$=o.y(y),_=Math.min(M,$),L=Math.abs(M-$),P=m>=0?s:l,I={...p,baseline:f,cumEnd:y,delta:m,_connectorStroke:n?.connectorStroke,_connectorWidth:n?.connectorWidth},R={fill:P,stroke:u,strokeWidth:d,opacity:h,cursor:n?.cursor,...e.config.areaStyle?.(I)};r.push(da(A,_,S,L,R,I)),f=y}return r},candlestick:function(e,t,i){if(!e.getHigh||!e.getLow||!e.scales)return[];let r=e.config.candlestickRangeMode??!1;if(!(r||e.getOpen&&e.getClose))return[];let o=[],n=e.config.candlestickStyle||{},a=n.rangeColor||"#6366f1",s=r?a:n.upColor||"#28a745",l=r?a:n.downColor||"#dc3545",c=r?a:n.wickColor||"#333",u=n.wickWidth||(r?2:1),d=n.bodyWidth??0;if(null==n.bodyWidth){let i=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);if(i.length>1){let t=1/0,r=e.scales.x(i[0]);for(let o=1;o<i.length;o++){let n=e.scales.x(i[o]),a=Math.abs(n-r);a>0&&a<t&&(t=a),r=n}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6}for(let a of t){let t=e.getX(a);if(null==t||Number.isNaN(t))continue;let h=e.getHigh(a),f=e.getLow(a);if(null==h||Number.isNaN(h)||null==f||Number.isNaN(f))continue;let p=r?h:e.getOpen(a),g=r?f:e.getClose(a);if(!r&&(null==p||Number.isNaN(p)||null==g||Number.isNaN(g)))continue;let m=g>=p,y=e.config.pointStyle?.(a)??{},x="string"==typeof y.fill?y.fill:void 0,b="string"==typeof y.stroke?y.stroke:void 0,v="number"==typeof y.strokeWidth?y.strokeWidth:void 0,w="number"==typeof y.opacity?y.opacity:"number"==typeof y.fillOpacity?y.fillOpacity:void 0,k={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(p),closeY:e.scales.y(g),highY:e.scales.y(h),lowY:e.scales.y(f),bodyWidth:d,upColor:x&&m?x:s,downColor:x&&!m?x:l,wickColor:b??(r&&x?x:c),wickWidth:v??u,isUp:m,style:{cursor:n.cursor,...y,...void 0!==w&&{opacity:w}},datum:a};r&&(k.isRange=!0,k.dotRadius=Math.max(2,Math.min(d/2,.12*i.height))),o.push(k)}return o},custom:()=>[]};function ks(){for(let e of Object.keys(ws))zn(e)||Fn({chartType:e,buildScene:ws[e],canvasRenderers:[]})}function As(e){let t=e.parts.filter(e=>null!=e),i={};for(let e of t)for(let[t,r]of Object.entries(e.markCountByType))i[t]=(i[t]??0)+r;for(let[t,r]of Object.entries(e.additionalMarkCountByType??{}))r>0&&(i[t]=(i[t]??0)+r);let r=Object.values(i).reduce((e,t)=>e+t,0),o=0===r,n=Array.from(
4
- /* @__PURE__ */new Set([...t.flatMap(e=>e.warnings),...e.extraWarnings??[],...o?["EMPTY_SCENE"]:[]])),a="string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${r} marks`;return{component:"",frameType:e.frameType,status:o?"empty":"ok",empty:o,markCount:r,markCountByType:i,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:t.reduce((e,t)=>e+t.annotationCount,0),ariaLabel:a,warnings:n,semanticStatus:"not-assessed",semanticDiagnostics:[]}}function Ss(e){let t={};for(let i of e){let e="string"==typeof i?.type&&i.type.length>0?i.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}function Ms(e){let t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function $s(e){if(!e||e.length<2)return;let t=Ms(e[0]),i=Ms(e[e.length-1]);return null!==t&&null!==i?[t,i]:void 0}function _s(e){let{count:t,byType:i}=Ss(e.marks),r=0===t,o=[...e.extraWarnings??[]];r&&!o.includes("EMPTY_SCENE")&&o.push("EMPTY_SCENE"),e.annotationRender&&e.annotationRender.unrenderedCount>0&&!o.includes("UNRENDERED_ANNOTATIONS")&&o.push("UNRENDERED_ANNOTATIONS");let n=Array.isArray(e.annotations)?e.annotations.length:0,a=e.annotationRender?.renderedCount??n,s="string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,l=e.margin,c=l?{x:l.left,y:l.top,width:Math.max(1,e.width-l.left-l.right),height:Math.max(1,e.height-l.top-l.bottom)}:void 0;return{component:"",frameType:e.frameType,status:r?"empty":"ok",empty:r,markCount:t,markCountByType:i,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:a,...e.annotationRender?.layout?{layout:e.annotationRender.layout}:{},...e.annotationRender?{annotationInputCount:e.annotationRender.inputCount,unrenderedAnnotationCount:e.annotationRender.unrenderedCount,...e.annotationRender.unrenderedTypes.length>0?{unrenderedAnnotationTypes:e.annotationRender.unrenderedTypes}:{}}:{},ariaLabel:s,warnings:o,semanticStatus:"not-assessed",semanticDiagnostics:[],...l?{margin:l}:{},...c?{plot:c}:{}}}import*as Ls from"react";import{area as Ps,line as Is}from"d3-shape";function Rs(e){let t=Number.isFinite(e)&&e>0?e:6;return{width:Math.max(8,t),height:t,lineY:t/2}}import{jsx as Ts,jsxs as Cs}from"react/jsx-runtime";function Ns(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function Fs(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function zs(e,t){return`${e}-hatch-${He(Fs(t)).toString(36)}`}function Es(e,t){let{background:i="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:n=6,angle:a=45,lineOpacity:s=1}=e,l=Rs(n);/* @__PURE__ */
5
- return Cs("pattern",{id:t,width:l.width,height:l.height,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[i&&"transparent"!==i&&"none"!==i&&/* @__PURE__ */Ts("rect",{width:l.width,height:l.height,fill:i}),
6
- /* @__PURE__ */Ts("line",{x1:0,y1:l.lineY,x2:l.width,y2:l.lineY,stroke:r,strokeWidth:o,...1!==s?{strokeOpacity:s}:{}})]},t)}function Ds(e,t,i="#4e79a7"){if(Ns(e)){let i=zs(t,e);return{fill:`url(#${i})`,def:Es(e,i)}}return e&&"string"==typeof e?{fill:e}:{fill:i}}function Os(e,t,i){if(!e||"object"!=typeof e)return;let r=e;if(!Array.isArray(r.stops))return;let o=r.stops.flatMap(e=>{if(!e||"object"!=typeof e)return[];let{offset:t,color:r,opacity:o}=e;return"number"==typeof t&&Number.isFinite(t)?[{offset:Math.max(0,Math.min(1,t)),color:"string"==typeof r&&r?r:i,opacity:"number"==typeof o&&Number.isFinite(o)?Math.max(0,Math.min(1,o)):void 0}]:[]}).sort((e,t)=>e.offset-t.offset);return o.length?{direction:"horizontal"===r.direction?"horizontal":"vertical"===r.direction?"vertical":t,stops:o}:void 0}function js(e,t,i,r){let o=Os(e,i,r);if(!o)return;let{direction:n,stops:a}=o,s=`${t}-gradient`;return{fill:`url(#${s})`,def:/* @__PURE__ */Ts("linearGradient",{id:s,x1:0,y1:0,x2:"horizontal"===n?"100%":0,y2:"vertical"===n?"100%":0,children:a.map((e,t)=>/* @__PURE__ */Ts("stop",{offset:100*e.offset+"%",stopColor:e.color,stopOpacity:e.opacity},`${e.offset}-${t}`))},s)}}import{curveMonotoneX as Ws,curveMonotoneY as Bs,curveCardinal as Ys,curveCatmullRom as Gs,curveStep as Xs,curveStepBefore as Vs,curveStepAfter as qs,curveBasis as Hs,curveNatural as Us}from"d3-shape";function Zs(e){switch(e){case"monotoneX":return Ws;case"monotoneY":return Bs;case"cardinal":return Ys;case"catmullRom":return Gs;case"step":return Xs;case"stepBefore":return Vs;case"stepAfter":return qs;case"basis":return Hs;case"natural":return Us;default:return null}}function Qs(e,t,i){let r=i;for(let i of t)"lesser"===i.thresholdType?e<i.value&&(r=i.color):e>i.value&&(r=i.color);return r}function Ks(e,t,i,r){if(e.length<2||t.length!==e.length||0===i.length)return[];let o=[],n=(e,t,i)=>{let r=o[o.length-1];r?.color===e?r.path.push(i):o.push({color:e,path:[t,i]})};for(let o=1;o<e.length;o++){let[a,s]=e[o-1],[l,c]=e[o],u=t[o-1],d=t[o]-u,h=[0,...0===d?[]:i.map(({value:e})=>(e-u)/d).filter(e=>e>0&&e<1&&Number.isFinite(e)).sort((e,t)=>e-t).filter((e,t,i)=>0===t||e!==i[t-1]),1];for(let e=1;e<h.length;e++){let t=h[e-1],o=h[e];n(Qs(u+d*((t+o)/2),i,r),[a+(l-a)*t,s+(c-s)*t],[a+(l-a)*o,s+(c-s)*o])}}return o}import*as Js from"react";function el(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function tl(e){let t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};let i=Math.min(e.w,e.h)/2,r=e=>Math.max(0,Math.min(e??0,i));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}import{jsx as il,jsxs as rl}from"react/jsx-runtime";var ol={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function nl(e,t="#4e79a7"){return Ns(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function al(e){let t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?`s_${t}`:t}function sl(e,t,i,r){let o=e.glyph;if(!o?.parts?.length||e.size<=0)return null;let n=Ye(o,e.size);if(n.scale<=0)return null;let a=`translate(${t},${i})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${n.offsetX},${n.offsetY}) scale(${n.scale})`,s=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=Xe(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?al(`${r}-clip`):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>o.parts.map((i,r)=>{let o=t?"none"===i.fill?void 0:t:Ge(i.fill,s,e.accent),n=t?i.stroke&&"none"!==i.stroke?t:void 0:Ge(i.stroke??"none",s,e.accent);return o||n?/* @__PURE__ */il("path",{d:i.d,fill:o??"none",stroke:n,strokeWidth:n?i.strokeWidth??1:void 0,strokeLinecap:i.strokeLinecap,strokeLinejoin:i.strokeLinejoin,opacity:i.opacity},r):null});/* @__PURE__ */
7
- return rl("g",{transform:a,opacity:1===u?void 0:u,children:[l&&c&&/* @__PURE__ */il("clipPath",{id:c,children:/* @__PURE__ */il("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?/* @__PURE__ */il("g",{children:d(e.ghostColor)}):null,l&&c?/* @__PURE__ */il("g",{clipPath:`url(#${c})`,children:d()}):d()]},r)}function ll(e,t){let i=e.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity))).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color??t,opacity:null==e.opacity?void 0:Math.max(0,Math.min(1,e.opacity))}));return i.length<2?null:i.map((e,t)=>/* @__PURE__ */il("stop",{offset:e.offset,stopColor:e.color,stopOpacity:e.opacity},t))}function cl(e,t){let i=e.fillGradient;if(!i||"object"!=typeof i)return null;let r=e.x,o=e.y,n=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(o=e.y+e.h,a=e.y):"right"===e.roundedEdge?(r=e.x+e.w,o=e.y,n=e.x,a=e.y):"left"===e.roundedEdge&&(r=e.x,o=e.y,n=e.x+e.w,a=e.y);let s=ll(i.stops,nl(e.style.fill));return s?/* @__PURE__ */il("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:r,y1:o,x2:n,y2:a,children:s}):null}function ul(e){let{x:t,y:i,w:r,h:o}=e,{tl:n,tr:a,br:s,bl:l}=tl(e),c=`M${t+n},${i}`;return c+=` L${t+r-a},${i}`,a>0&&(c+=` A${a},${a} 0 0 1 ${t+r},${i+a}`),c+=` L${t+r},${i+o-s}`,s>0&&(c+=` A${s},${s} 0 0 1 ${t+r-s},${i+o}`),c+=` L${t+l},${i+o}`,l>0&&(c+=` A${l},${l} 0 0 1 ${t},${i+o-l}`),c+=` L${t},${i+n}`,n>0&&(c+=` A${n},${n} 0 0 1 ${t+n},${i}`),c+=" Z",c}function dl(e,t,i){let r=je(e.symbolType,e.size,e.path),o=e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`;/* @__PURE__ */
8
- return il("path",{d:r,transform:o,fill:e.style.fill?nl(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${i??""}symbol-${t}`)}function hl(e,t,i){let r=e.y,o=e.y+e.h,n=[],a=[];e.fillBands.forEach((t,s)=>{let l,c=Math.max(Math.min(t.y0,t.y1),r),u=Math.min(Math.max(t.y0,t.y1),o);if(u>c){if(Ns(t.fill)){let e=`${i}-band-${s}`;n.push(Es(t.fill,e)),l=`url(#${e})`}else l=nl(t.fill);a.push(/* @__PURE__ */il("rect",{x:e.x,y:c,width:e.w,height:u-c,fill:l},s))}});let s=e.style.stroke&&"none"!==e.style.stroke;/* @__PURE__ */
9
- return rl("g",{opacity:e.style.opacity,children:[n.length>0&&/* @__PURE__ */il("defs",{children:n}),a,s&&/* @__PURE__ */il("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"none",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},`rect-${t}`)}function fl(e,t,i){let r="point"===e.type,o=r?"circle":"rect",n=r?{cx:e.x,cy:e.y,r:e.r}:{x:e.x,y:e.y,width:e.w,height:e.h},a=`${i?`${i}-`:""}${r?"point":"xyrect"}-${t}-hatch`;if(!r&&e.fillBands&&e.fillBands.length>0)return hl(e,t,a);let s=Ns(e.style.fill)?Es(e.style.fill,a):void 0;/* @__PURE__ */
10
- return rl(Js.Fragment,{children:[s&&/* @__PURE__ */il("defs",{children:s}),Js.createElement(o,{...n,fill:s?`url(#${a})`:nl(e.style.fill),opacity:r?e.style.opacity??e.style.fillOpacity??.8:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},`${e.type}-${t}`)}import*as pl from"react";import{jsx as gl}from"react/jsx-runtime";function ml(e){if(!1!==e?.interactive)return e?.style?.cursor}function yl(e,t,i){let r=ml(t);return r&&null!=e&&!1!==e?/* @__PURE__ */gl("g",{style:{cursor:r},"data-semiotic-mark-cursor":r,children:e},i):e}import{jsx as xl,jsxs as bl}from"react/jsx-runtime";function vl(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}let t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}function wl(e,t){let i=e.fillGradient;if(!i||"object"!=typeof i)return null;let r=1/0,o=-1/0;if(e.fillGradientSpan)[r,o]=e.fillGradientSpan;else{for(let[,t]of e.topPath)r=Math.min(r,t);for(let[,t]of e.bottomPath)o=Math.max(o,t)}if(!Number.isFinite(r)||!Number.isFinite(o))return null;let n=ll(i.stops,nl(e.style.fill));return n?/* @__PURE__ */xl("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:r,x2:0,y2:o,children:n}):null}function kl(e,t,i,r){if(!e||t.length<2)return null;let o=ll(e.stops,r);return o?/* @__PURE__ */xl("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:o}):null}function Al(e,t,i,r=30){let o=Sl(e,t,i,r);return"area"===e.type?o:yl(o,e,`xy-cursor-${t}`)}function Sl(e,t,i,r=30){switch(e.type){case"line":{let r=e;if(0===r.path.length)return null;let o=Zs(r.curve),n=o?Is().x(([e])=>e).y(([,e])=>e).curve(o)(r.path)??"":"M"+r.path.map(([e,t])=>`${e},${t}`).join("L"),a=al(`${i?`${i}-`:""}line-${t}-stroke-gradient`),s=kl(r.strokeGradient,r.path,a,r.style.stroke||"#4e79a7");/* @__PURE__ */
11
- return bl(Ls.Fragment,{children:[s&&/* @__PURE__ */xl("defs",{children:s}),
12
- /* @__PURE__ */xl("path",{d:n,fill:"none",stroke:s?`url(#${a})`:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth??2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})]},`line-${t}`)}case"area":{let o=e;if(0===o.topPath.length)return null;let n=Zs(o.curve),a=n&&o.topPath.length>=2&&o.bottomPath.length>=2?Ps().x(([e])=>e).y0((e,t)=>o.bottomPath[t][1]).y1(([,e])=>e).curve(n)(o.topPath)??"":`M${o.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...o.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`,s=`${i?`${i}-`:""}area-${t}-hatch`,l=Ns(o.style.fill)?Es(o.style.fill,s):void 0,c=al(`${i?`${i}-`:""}area-${t}-gradient`),u=wl(o,c),d=u?`url(#${c})`:l?`url(#${s})`:nl(o.style.fill),h=u?void 0:o.style.fillOpacity??.7,f=n?Is().x(([e])=>e).y(([,e])=>e).curve(n)(o.topPath)??"":"M"+o.topPath.map(([e,t])=>`${e},${t}`).join("L"),p=ml(o),g=p&&r>=0?/* @__PURE__ */xl("path",{d:f,fill:"none",stroke:"transparent",strokeWidth:Math.max(1,2*r),strokeLinecap:"round",pointerEvents:"stroke",style:{cursor:p},"data-semiotic-mark-cursor":p,"data-semiotic-cursor-hit-target":"area-top-path","aria-hidden":"true"},`area-${t}-cursor-target`):null,m=al(`${i?`${i}-`:""}area-${t}-stroke-gradient`),y=!(!o.colorThresholds?.length||!o.rawValues||o.rawValues.length!==o.topPath.length),x=!!o.strokeColorBands?.length,b=y||x?null:kl(o.strokeGradient,o.topPath,m,o.style.stroke||"#4e79a7"),v=o.style.strokeWidth??2,w=1/0,k=-1/0;for(let[e]of o.topPath)e<w&&(w=e),e>k&&(k=e);let A=x?o.strokeColorBands.map((e,r)=>al(`${i?`${i}-`:""}area-${t}-stroke-band-${r}`)):[],S=x?o.strokeColorBands.map((e,t)=>/* @__PURE__ */xl("clipPath",{id:A[t],children:/* @__PURE__ */xl("rect",{x:w-v,y:e.y,width:k-w+2*v,height:e.height})},A[t])):null,M=o.style.stroke&&"none"!==o.style.stroke?x?o.strokeColorBands.map((e,i)=>/* @__PURE__ */xl("path",{d:f,fill:"none",stroke:e.color??nl(o.style.stroke),strokeWidth:v,opacity:(o.style.opacity??1)*(e.opacity??1),clipPath:`url(#${A[i]})`},`area-${t}-stroke-band-${i}`)):y?Ks(o.topPath,o.rawValues,o.colorThresholds,nl(o.style.stroke)).map((e,i)=>/* @__PURE__ */xl("path",{d:"M"+e.path.map(([e,t])=>`${e},${t}`).join("L"),fill:"none",stroke:e.color,strokeWidth:v,opacity:o.style.opacity},`area-${t}-threshold-${i}`)):/* @__PURE__ */xl("path",{d:f,fill:"none",stroke:b?`url(#${m})`:nl(o.style.stroke),strokeWidth:v,opacity:o.style.opacity}):null;if(o.clipRect){let e=`${i?`${i}-`:""}area-clip-${t}`;/* @__PURE__ */
13
- return bl("g",{children:[
14
- /* @__PURE__ */bl("defs",{children:[u,!u&&l,b,S,
15
- /* @__PURE__ */xl("clipPath",{id:e,children:/* @__PURE__ */xl("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),
16
- /* @__PURE__ */bl("g",{clipPath:`url(#${e})`,children:[
17
- /* @__PURE__ */xl("path",{d:a,fill:d,fillOpacity:h,opacity:o.style.opacity,stroke:"none"}),M,g]})]},`area-${t}`)}/* @__PURE__ */
18
- return bl(Ls.Fragment,{children:[(u||l||b||S)&&/* @__PURE__ */bl("defs",{children:[u,!u&&l,b,S]}),
19
- /* @__PURE__ */xl("path",{d:a,fill:d,fillOpacity:h,opacity:o.style.opacity,stroke:"none"}),M,g]},`area-${t}`)}case"point":case"rect":return fl(e,t,i);case"symbol":return dl(e,t);case"glyph":{let r=e;return sl(r,r.x,r.y,`${i??""}glyph-${r.pointId??t}`)}case"heatcell":{let i=e,r={x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill,stroke:i.style?.stroke,strokeWidth:i.style?.strokeWidth,...null!=i.style?.opacity&&{opacity:i.style.opacity}};if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){let e=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?String(i.value):Math.abs(i.value)>=100?i.value.toFixed(0):Math.abs(i.value)>=1?i.value.toFixed(1):i.value.toPrecision(3),[o,n,a]=vl(i.fill),s=.299*o+.587*n+.114*a>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));/* @__PURE__ */
20
- return bl("g",{children:[
21
- /* @__PURE__ */xl("rect",{...r}),
22
- /* @__PURE__ */xl("text",{className:"semiotic-heatmap-value",x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:`${l}px`,fontFamily:"var(--semiotic-font-family, sans-serif)",children:e})]},`heatcell-${t}`)}/* @__PURE__ */
23
- return xl("rect",{...r},`heatcell-${t}`)}case"candlestick":{let r=e,o=`${i?`${i}-`:""}candle-${t}-hatch`,n=Ns(r.style?.fill)?Es(r.style.fill,o):void 0,a=n?`url(#${o})`:void 0,{fill:s,...l}=r.style??{};if(r.isRange){let e=r.dotRadius??Math.max(2,r.bodyWidth/2),i=a??r.wickColor;/* @__PURE__ */
24
- return bl(Ls.Fragment,{children:[n&&/* @__PURE__ */xl("defs",{children:n}),
25
- /* @__PURE__ */bl("g",{style:l,children:[
26
- /* @__PURE__ */xl("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth,opacity:r.style?.opacity}),
27
- /* @__PURE__ */xl("circle",{cx:r.x,cy:r.highY,r:e,fill:i,opacity:r.style?.opacity}),
28
- /* @__PURE__ */xl("circle",{cx:r.x,cy:r.lowY,r:e,fill:i,opacity:r.style?.opacity})]})]},`candle-${t}`)}let c=Math.min(r.openY,r.closeY),u=Math.max(Math.abs(r.openY-r.closeY),1),d=r.isUp?r.upColor:r.downColor,h=a??d;/* @__PURE__ */
29
- return bl(Ls.Fragment,{children:[n&&/* @__PURE__ */xl("defs",{children:n}),
30
- /* @__PURE__ */bl("g",{style:l,children:[
31
- /* @__PURE__ */xl("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth,opacity:r.style?.opacity}),
32
- /* @__PURE__ */xl("rect",{x:r.x-r.bodyWidth/2,y:c,width:r.bodyWidth,height:u,fill:h,stroke:a?r.wickColor:d,strokeWidth:1,opacity:r.style?.opacity})]})]},`candle-${t}`)}default:return null}}var Ml=/* @__PURE__ */new Set;function $l(e){if(!e||"object"!=typeof e)return!1;let t=e;return"string"==typeof t.id&&"function"==typeof t.cacheKey&&"function"==typeof t.drawCanvas&&"function"==typeof t.renderStaticSVG}function _l(e,t){let i="function"==typeof e?e(t.datum??null,t):e;return $l(i)?i:void 0}function Ll(e,t){if("production"===process.env.NODE_ENV)return;let i=`${e}:${t}`;Ml.has(i)||(Ml.add(i),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function Pl(e){let{node:t,index:i,renderMode:r,fallback:o}=e,n=_l(r,t);if(!n)return{element:o(),renderedByBackend:!1};let a=n.renderStaticSVG({node:t,style:t.style??{},key:`${n.id}-${i}`});return null!=a?{element:yl(a,t,`${n.id}-${i}-cursor`),renderedByBackend:!0}:(Ll(n.id,t.type??"unknown"),{element:o(),renderedByBackend:!1})}function Il(e){return Pl(e).element}function Rl(e){let t=[];return e.nodes.forEach((i,r)=>{let o=Pl({node:i,index:r,renderMode:e.renderMode,fallback:()=>e.fallback(i,r)});null!==o.element&&void 0!==o.element&&!1!==o.element&&t.push({node:i,index:r,...o})}),t}import{scaleOrdinal as Tl}from"d3-scale";import{jsx as Cl,jsxs as Nl}from"react/jsx-runtime";function Fl(e,t,i){if(t&&"object"==typeof t&&!Array.isArray(t)){let e=t;return t=>Oi(e,t)??"#999"}let r=Array.isArray(t)?t:i.colors.categorical.length>0?i.colors.categorical:fi;return Tl().domain(e).range(r)}function zl(e,t,i){if(0===e.length)return;let r=Fl(e,t,i);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:r(e.label)})}]}}function El(e){return"left"===e?"start":"right"===e?"end":e??"start"}function Dl(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function Ol(e){return e.typography.legendFontFamily??e.typography.fontFamily}function jl(e){return e.typography.legendFontWeight}function Wl(e,t,i,r){let o=Dl(r);return t+i+Math.ceil(e.length*o*.58)}function Bl(e){let{categories:t,theme:i,position:r="right",totalWidth:o,margin:n,legendLayout:a}=e,{swatchSize:s,labelGap:l,itemGap:c,rowHeight:u}=xt(a),d=s+l,h="top"===r||"bottom"===r,f=Math.max(s,o-n.left-n.right),p=t.map(e=>Wl(e,s,l,i));if(h){let e=Math.max(s,a?.maxWidth??f),i=[],r=0,o=0;p.forEach((t,n)=>{let a=0===o?t:o+c+t;o>0&&a>e?(i.push({start:r,end:n,width:o}),r=n,o=t):o=a}),t.length>0&&i.push({start:r,end:t.length,width:o});let n=El(a?.align),l=[];return i.forEach((i,r)=>{let o="center"===n?Math.max(0,(e-i.width)/2):"end"===n?Math.max(0,e-i.width):0;for(let e=i.start;e<i.end;e++)l.push({category:t[e],width:p[e],x:o,y:r*u}),o+=p[e]+c}),{items:l,width:i.reduce((e,t)=>Math.max(e,t.width),0),height:i.length*u,swatchSize:s,labelOffset:d,swatchRadius:0}}let g=p.reduce((e,t)=>Math.max(e,t),0);return{items:t.map((e,t)=>({category:e,width:p[t],x:0,y:t*u})),width:g,height:t.length*u,swatchSize:s,labelOffset:d,swatchRadius:0}}function Yl(e){let{legendGroups:t,theme:i,position:r="right",totalWidth:o,margin:n,legendLayout:a}=e,{swatchSize:s,labelGap:l,rowHeight:c}=xt(a),u=s+l,d=Math.max(12,Dl(i)),h="top"===r||"bottom"===r,f=Math.max(s,o-n.left-n.right);if(h){let r=Math.max(s,a?.maxWidth??f),o=El(a?.align),n=0,l=0,c=[];for(let o of t){let t=o.items.map(e=>e.label),u=Bl({...e,categories:t,legendLayout:{...a,maxWidth:Math.max(s,r-d-8),align:"start"}}),h=o.label?d:0,f=o.label?Wl(o.label,0,0,i):0,p=h>0?h+8:0,g=p+u.width,m=Math.max(u.height,f);c.push({group:o,x:n,y:0,itemOffsetX:p,itemOffsetY:0,width:g,height:m,items:u.items}),n+=g+12,l=Math.max(l,m)}let h=c.length>0?n-12:0,p=h>r?0:"center"===o?Math.max(0,(r-h)/2):"end"===o?Math.max(0,r-h):0;return{groups:c.map(e=>({...e,x:e.x+p})),width:h,height:l,swatchSize:s,labelOffset:u,swatchRadius:0}}let p=bt(t.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),c);return{groups:[],width:t.reduce((e,t)=>t.items.reduce((e,t)=>Math.max(e,Wl(t.label,s,l,i)),Math.max(e,t.label?Wl(t.label,0,0,i):0)),0),height:p.at(-1)?.endY??0,swatchSize:s,labelOffset:u,swatchRadius:0}}function Gl(e){let t="top"===e.position||"bottom"===e.position,i=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??i,200),height:e.gradient.label?46:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?126:108,swatchSize:14}}function Xl(e){let{categories:t,colorScheme:i,theme:r,position:o="right",totalWidth:n,totalHeight:a,margin:s}=e;if(!t||0===t.length)return null;let l=Fl(t,i,r),c="top"===o||"bottom"===o,u=Bl(e),d={...zl(t,i,r),legendDistance:e.legendDistance},h=e.reservedWidth??nt(d,e.legendLayout),{x:f,y:p}=yt(d,{totalWidth:n,totalHeight:a,margin:s,position:o,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:h}),g=c?void 0:bt([{hasLabel:!1,itemCount:t.length}],Math.max(u.swatchSize,e.legendLayout?.rowHeight??22))[0],m=u.items.map((e,t)=>/* @__PURE__ */Nl("g",{transform:`translate(${e.x},${e.y+(g?.itemsY??0)})`,children:[
33
- /* @__PURE__ */Cl("rect",{width:u.swatchSize,height:u.swatchSize,fill:l(e.category),rx:u.swatchRadius}),
34
- /* @__PURE__ */Cl("text",{x:u.labelOffset,y:u.swatchSize/2,dominantBaseline:"central",fontSize:Dl(r),fill:r.colors.text,fontFamily:Ol(r),children:e.category})]},`legend-${t}`));/* @__PURE__ */
35
- return Nl("g",{className:"semiotic-legend",transform:`translate(${f},${p})`,fontWeight:jl(r),children:[g&&/* @__PURE__ */Cl("line",{x1:0,y1:g.lineY,x2:h,y2:g.lineY,stroke:"gray"}),m]})}function Vl(e){if(!e.legendGroups.some(e=>e.items.some(()=>!0)))return null;let t=Yl(e),i="top"===e.position||"bottom"===e.position,r={legendGroups:e.legendGroups,legendDistance:e.legendDistance},o=e.reservedWidth??nt(r,e.legendLayout),n=e.theme.colors.grid||e.theme.colors.textSecondary,{x:a,y:s}=yt(r,{totalWidth:e.totalWidth,totalHeight:e.totalHeight,margin:e.margin,position:e.position,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:o});if(!i){let i=bt(e.legendGroups.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),Math.max(t.swatchSize,e.legendLayout?.rowHeight??22)),r=e.legendGroups.flatMap((r,n)=>{let a=i[n],s=r.type??"fill",l=[
36
- /* @__PURE__ */Cl("line",{x1:0,y1:a.lineY,x2:o,y2:a.lineY,stroke:"gray"},`legend-group-neatline-${n}`)];return r.label&&null!=a.labelY&&l.push(
37
- /* @__PURE__ */Cl("text",{y:a.labelY,fontSize:Dl(e.theme),fill:e.theme.colors.text,fontFamily:Ol(e.theme),children:r.label},`legend-group-label-${n}`)),l.push(
38
- /* @__PURE__ */Cl("g",{transform:`translate(0,${a.itemsY})`,children:r.items.map((i,o)=>{let a=r.styleFn(i,o),l="function"==typeof s?s(i):"line"===s?/* @__PURE__ */Cl("line",{x1:0,y1:0,x2:t.swatchSize,y2:t.swatchSize,style:a}):/* @__PURE__ */Cl("rect",{width:t.swatchSize,height:t.swatchSize,rx:t.swatchRadius,style:a});/* @__PURE__ */
39
- return Nl("g",{transform:`translate(0,${o*Math.max(t.swatchSize,e.legendLayout?.rowHeight??22)})`,children:[l,
40
- /* @__PURE__ */Cl("text",{x:t.labelOffset,y:t.swatchSize/2,dominantBaseline:"central",fontSize:Dl(e.theme),fill:e.theme.colors.text,fontFamily:Ol(e.theme),children:i.label})]},`legend-${n}-${o}`)})},`legend-group-${n}`)),l});/* @__PURE__ */
41
- return Cl("g",{className:"semiotic-legend",transform:`translate(${a},${s})`,"data-orientation":"vertical",fontWeight:jl(e.theme),children:r})}let l=t.groups.flatMap((i,r)=>{let{group:o}=i,a=o.type??"fill",s=[];if(o.label&&s.push(
42
- /* @__PURE__ */Cl("text",{transform:`translate(${i.x},${i.y}) rotate(90)`,textAnchor:"start",fontSize:Dl(e.theme),fill:e.theme.colors.text,fontFamily:Ol(e.theme),children:o.label},`legend-group-label-${r}`)),s.push(...i.items.map((n,s)=>{let l=o.items[s],c=o.styleFn(l,s),u="function"==typeof a?a(l):"line"===a?/* @__PURE__ */Cl("line",{x1:0,y1:0,x2:t.swatchSize,y2:t.swatchSize,style:c}):/* @__PURE__ */Cl("rect",{width:t.swatchSize,height:t.swatchSize,rx:t.swatchRadius,style:c});/* @__PURE__ */
43
- return Nl("g",{transform:`translate(${i.x+i.itemOffsetX+n.x},${i.y+i.itemOffsetY+n.y})`,children:[u,
44
- /* @__PURE__ */Cl("text",{x:t.labelOffset,y:t.swatchSize/2,dominantBaseline:"central",fontSize:Dl(e.theme),fill:e.theme.colors.text,fontFamily:Ol(e.theme),children:n.category})]},`legend-${r}-${s}`)})),r<t.groups.length-1){let e=i.x+i.width+6;s.push(
45
- /* @__PURE__ */Cl("line",{x1:e,y1:0,x2:e,y2:t.height,stroke:n},`legend-group-separator-${r}`))}return s});/* @__PURE__ */
46
- return Cl("g",{className:"semiotic-legend",transform:`translate(${a},${s})`,"data-orientation":"horizontal",fontWeight:jl(e.theme),children:l})}function ql(e){let t=Gl(e),i="top"===e.position||"bottom"===e.position,r={gradient:e.gradient,legendDistance:e.legendDistance},o=nt(r),n=(e.idPrefix?`${e.idPrefix}-`:"")+"semiotic-static-gradient-legend",a=e.gradient.format||Ze(e.gradient.domain),{x:s,y:l}=yt(r,{totalWidth:e.totalWidth,totalHeight:e.totalHeight,margin:e.margin,position:e.position,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:o}),c=Array.from({length:17},(t,r)=>{let o=r/16,n=i?e.gradient.domain[0]+o*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-o*(e.gradient.domain[1]-e.gradient.domain[0]);/* @__PURE__ */
47
- return Cl("stop",{offset:o,stopColor:e.gradient.colorFn(n)},r)});if(i){let i=e.gradient.label?12:void 0,r=e.gradient.label?18:0;/* @__PURE__ */
48
- return Nl("g",{className:"semiotic-legend",transform:`translate(${s},${l})`,fontWeight:jl(e.theme),children:[
49
- /* @__PURE__ */Cl("defs",{children:/* @__PURE__ */Cl("linearGradient",{id:n,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),e.gradient.label&&/* @__PURE__ */Cl("text",{x:t.width/2,y:i,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:Ol(e.theme),children:e.gradient.label}),
50
- /* @__PURE__ */Cl("rect",{x:0,y:r,width:t.width,height:12,fill:`url(#${n})`,rx:2}),
51
- /* @__PURE__ */Cl("text",{x:0,y:r+12+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Ol(e.theme),children:a(e.gradient.domain[0])}),
52
- /* @__PURE__ */Cl("text",{x:t.width,y:r+12+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Ol(e.theme),children:a(e.gradient.domain[1])})]})}let u=e.gradient.label?12:void 0,d=e.gradient.label?18:0;/* @__PURE__ */
53
- return Nl("g",{className:"semiotic-legend",transform:`translate(${s},${l})`,fontWeight:jl(e.theme),children:[
54
- /* @__PURE__ */Cl("defs",{children:/* @__PURE__ */Cl("linearGradient",{id:n,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),e.gradient.label&&/* @__PURE__ */Cl("text",{x:0,y:u,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:Ol(e.theme),children:e.gradient.label}),
55
- /* @__PURE__ */Cl("rect",{x:0,y:d,width:14,height:100,fill:`url(#${n})`,rx:2}),
56
- /* @__PURE__ */Cl("text",{x:19,y:d+10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Ol(e.theme),children:a(e.gradient.domain[1])}),
57
- /* @__PURE__ */Cl("text",{x:19,y:d+100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Ol(e.theme),children:a(e.gradient.domain[0])})]})}function Hl(e,t){if(!t||!e||0===e.length)return[];let i="function"==typeof t?t:e=>e[t],r=/* @__PURE__ */new Set;for(let t of e){let e=i(t);null!=e&&r.add(String(e))}return Array.from(r)}import*as Ul from"react";var Zl=(e,t)=>({width:Array.from(e).length*t.size*.65,height:1.2*t.size,ascent:.9*t.size,source:"estimated"}),Ql={INVALID_PROJECTION:"Check endpoint values and the scale domain, especially log-scale values.",INSUFFICIENT_SPACE:"Increase chart height or the label-side margin, or reduce the label font size.",TIED_ENDPOINTS:"Use connectors or a legend to distinguish series sharing an endpoint.",LABEL_OMITTED:"Consult the accessible series list; increase the label rail space to restore visible labels.",ESTIMATED_METRICS:"Load the intended font and remeasure before asserting collision-free text.",RENDER_FAILURE:"Inspect the annotation renderer; the placed label did not produce a node.",UNSUPPORTED_GEOMETRY:"Inspect custom-rendered text; its geometry has not been measured by the label solver.",LABEL_COLLISION:"Increase spacing or shorten the affected labels.",LABEL_OVERFLOW:"Increase the allocated bounds or shorten the affected labels."};function Kl(e,t,i="end",r=2){let o,n=/* @__PURE__ */new Map,a=/* @__PURE__ */new Map,s=(e,t)=>{let i=a.get(e)??{count:0,labelIds:[]};i.count++,i.labelIds.length<20&&i.labelIds.push(t),a.set(e,i)},l=(e,t)=>{n.set(e,{id:e,status:"omitted",reason:t}),s(t,e),s("LABEL_OMITTED",e)},c=[...e].sort((e,t)=>(Number.isFinite(e.anchor.y)?e.anchor.y:1/0)-(Number.isFinite(t.anchor.y)?t.anchor.y:1/0)||(e.id<t.id?-1:e.id>t.id?1:0)),u=[],d=0;for(let e of c){let{id:i,anchor:n,measurement:a}=e;if("estimated"===a.source&&s("ESTIMATED_METRICS",i),![n.x,n.y,a.width,a.height,a.ascent].every(Number.isFinite)||a.width<0||a.height<=0){l(i,"INVALID_PROJECTION");continue}o===n.y&&s("TIED_ENDPOINTS",i),o=n.y;let c=a.height+(u.length?r:0);![t.x,t.y,t.width,t.height,r].every(Number.isFinite)||r<0||a.width>t.width||d+c>t.height?l(i,"INSUFFICIENT_SPACE"):(u.push(e),d+=c)}let h=ae({desired:u.map(e=>e.anchor.y-e.measurement.height/2),minGaps:u.slice(0,-1).map(e=>e.measurement.height+r),min:t.y,max:t.y+t.height-(u.at(-1)?.measurement.height??0)});u.forEach((e,r)=>{let o={x:"end"===i?t.x:t.x+t.width-e.measurement.width,y:h[r],width:e.measurement.width,height:e.measurement.height},a="end"===i?o.x:o.x+o.width,s=o.y+o.height/2,l={x:a-e.anchor.x,y:s-e.anchor.y};n.set(e.id,{id:e.id,status:"placed",box:o,offset:l,...Math.abs(l.y)>.01||Math.abs(l.x)>6.01?{connector:{x1:e.anchor.x,y1:e.anchor.y,x2:a,y2:s}}:{}})});let f=e.map(e=>n.get(e.id)),p=f.filter(e=>"placed"===e.status&&Math.abs(e.offset.y)>.01),g=f.filter(e=>"omitted"===e.status),m=e.filter(e=>"estimated"===e.measurement.source).length;return{dispositions:f,evidence:{status:m||g.length?"incomplete":"complete",requested:e.length,rendered:u.length,displaced:p.length,omitted:g.length,omittedIds:g.slice(0,20).map(e=>e.id),displacedIds:p.slice(0,20).map(e=>e.id),measurement:{measured:e.length-m,estimated:m},collisions:0,overflows:0,fallback:"accessible-series-list",findings:[...a].map(([e,t])=>({code:e,...t,remedy:Ql[e]})),coverage:{directLabels:"assessed",axisLabels:"not-assessed"}}}}import{jsx as Jl,jsxs as ec}from"react/jsx-runtime";function tc(e,t){let i=e.filter(e=>e._directLabel);if(!i.length)return{node:null};let r=i[0]._directLabel.position,o=t.measure??Zl,n=i.map(e=>({family:t.fontFamily||"sans-serif",version:t.fontVersion??0,weight:400,size:e.fontSize||11})),a=i.map((e,i)=>{let r=(e,t)=>{if(null==e||!t)return NaN;try{return t(Number(e))}catch{return NaN}};return{id:String(e._directLabel.id),anchor:{x:r(e.x,t.scales?.x),y:r(e.y,t.scales?.y)},measurement:o(String(e.label),n[i])}}),s=Math.max(0,(t.margin?.["end"===r?"right":"left"]??0)-10),l=Kl(a,{x:"end"===r?t.width+6:-s-6,y:0,width:s,height:t.height},r),c=l.dispositions.map((e,r)=>{if("omitted"===e.status)return null;let o=e.box,s=e.connector,c=i[r],u=/* @__PURE__ */ec("g",{"data-direct-label-id":e.id,children:[s&&/* @__PURE__ */Jl("line",{...s,stroke:c.color,strokeWidth:.75}),
58
- /* @__PURE__ */Jl("text",{x:o.x+(a[r].measurement.left??0),y:o.y+a[r].measurement.ascent,fontFamily:n[r].family,fontWeight:n[r].weight,fontSize:n[r].size,fill:c.color,textAnchor:"start",children:c.label})]},e.id),d=t.renderLabel?t.renderLabel({...c,dx:o.x+(a[r].measurement.left??0)-a[r].anchor.x,dy:o.y+a[r].measurement.ascent-a[r].anchor.y,fontFamily:n[r].family},r,u):u;if(!d){let t=l.evidence;t.rendered--,t.omitted++,t.omittedIds.length<20&&t.omittedIds.push(e.id),Math.abs(e.offset.y)>.01&&t.displaced--,t.displacedIds=t.displacedIds.filter(t=>t!==e.id);for(let i of["RENDER_FAILURE","LABEL_OMITTED"]){let r=t.findings.find(e=>e.code===i);r||(r={code:i,count:0,labelIds:[],remedy:Ql[i]},t.findings.push(r)),r.count++,r.labelIds.length<20&&r.labelIds.push(e.id)}}if(d!==u&&(l.evidence.status="incomplete",d)){let t=l.evidence.findings.find(e=>"UNSUPPORTED_GEOMETRY"===e.code);t||(t={code:"UNSUPPORTED_GEOMETRY",count:0,labelIds:[],remedy:Ql.UNSUPPORTED_GEOMETRY},l.evidence.findings.push(t)),t.count++,t.labelIds.length<20&&t.labelIds.push(e.id)}return d?/* @__PURE__ */Jl(Ul.Fragment,{children:d},e.id):null}),u=/* @__PURE__ */Jl("g",{role:"list","aria-label":"Series endpoints","data-direct-label-fallback":"accessible-series-list",children:i.map((e,t)=>/* @__PURE__ */Jl("g",{role:"listitem","aria-label":`${e.label}: x ${String(e.x)}, y ${String(e.y)}`,children:/* @__PURE__ */Jl("title",{children:`${e.label}: x ${String(e.x)}, y ${String(e.y)}`})},a[t].id))});return{evidence:l.evidence,node:/* @__PURE__ */ec("g",{className:"semiotic-direct-labels","data-label-layout":JSON.stringify(l.evidence),children:[c,u]},"direct-labels")}}function ic(e){return"string"==typeof e&&e.includes("var(")}var rc=/^\s*var\(\s*--[^,)\s]+\s*(?:,\s*([\s\S]*))?\)\s*$/;function oc(e){let t=rc.exec(e);if(!t)return ic(e)?void 0:e;let i=t[1]?.trim();return i?oc(i):void 0}import{jsx as nc,jsxs as ac}from"react/jsx-runtime";var sc="var(--semiotic-bg, #ffffff)";function lc(e,t){return String(e).length*t*.6}function cc(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{...e,type:e.type??"halo"}}function uc(e){let{x:t,y:i,text:r,fill:o,fontSize:n=12,fontWeight:a,fontFamily:s,textAnchor:l="start",dominantBaseline:c,background:u,className:d}=e,h=cc(u),f=e=>/* @__PURE__ */nc("text",{x:t,y:i,textAnchor:l,dominantBaseline:c,fill:o,fontSize:n,fontWeight:a,fontFamily:s,className:d,...e?{style:{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}}:{},children:r});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??sc,strokeWidth:h.haloWidth??3});let p,g,m=h.padding??{x:6,y:3},y="number"==typeof m?m:m.x,x="number"==typeof m?m:m.y,b=lc(r,n),v=b+2*y,w=n+2*x;p="middle"===l?t-b/2-y:"end"===l?t-b-y:t-y,g="middle"===c||"central"===c?i-w/2:"hanging"===c||"text-before-edge"===c?i-x:i-.8*n-x;let k=h.fill??sc,A={};return ic(k)&&(A.fill=k),ic(h.stroke)&&(A.stroke=h.stroke),/* @__PURE__ */ac("g",{className:d,children:[
59
- /* @__PURE__ */nc("rect",{x:p,y:g,width:v,height:w,rx:h.radius??3,ry:h.radius??3,fill:ic(k)?oc(k):k,fillOpacity:h.opacity??.85,stroke:ic(h.stroke)?oc(h.stroke):h.stroke,strokeWidth:h.strokeWidth,...A.fill||A.stroke?{style:A}:{}}),f()]})}import{jsx as dc}from"react/jsx-runtime";function hc(e,t,i){if(!e)return null;let r="object"==typeof e?e:{};/* @__PURE__ */
60
- return dc("circle",{className:"semiotic-threshold-end-cap",cx:t[0],cy:t[1],r:Math.max(0,r.radius??4),fill:r.fill??i})}import{jsx as fc,jsxs as pc}from"react/jsx-runtime";function gc({ann:e,position:t,vertical:i,width:r,height:o,color:n,fontSize:a=12,fontFamily:s,bold:l,background:c,dash:u="6,3",labelGap:d=4}){let h=e.labelPosition,f=t>.6*r,p=i?t+(f?-4:4):"left"===h?4:"center"===h?r/2:r-4,g=i?"bottom"===h?o-4:"center"===h?o/2:16:t<20?Math.min(o-4,t+16):t-d,m=i?f?"end":"start":"left"===h?"start":"center"===h?"middle":"end",y=i?[t,0]:[0,t],x=i?[t,o]:[r,t];/* @__PURE__ */
61
- return pc("g",{opacity:e.opacity,children:[
62
- /* @__PURE__ */fc("line",{x1:y[0],y1:y[1],x2:x[0],y2:x[1],stroke:n,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||u}),hc(e.endCap,y,n),e.label&&/* @__PURE__ */fc(uc,{x:p,y:g,text:e.label,textAnchor:m,fill:e.labelColor??n,fontSize:a,fontFamily:s,fontWeight:l?"bold":void 0,background:c??e.labelBackground??"halo"})]})}import{jsx as mc,jsxs as yc}from"react/jsx-runtime";function xc(e,t,i,r){return"curly"===e?r?`M0,0 C${.6*i},0 ${.4*i},${t/2} ${i},${t/2} C${.4*i},${t/2} ${.6*i},${t} 0,${t}`:`M0,0 C0,${.6*i} ${t/2},${.4*i} ${t/2},${i} C${t/2},${.4*i} ${t},${.6*i} ${t},0`:r?`M0,0 L${i},0 L${i},${t} L0,${t}`:`M0,0 L0,${i} L${t},${i} L${t},0`}function bc(e,t,i,r){if(!e)/* @__PURE__ */return mc("g",{className:"annotation-note"});let{label:o,title:n,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!o&&!n)/* @__PURE__ */return mc("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(i)?"leftRight":"topBottom");let d="topBottom"===u,h="leftRight"===u,f=s;(!f||"dynamic"===f)&&(f=d?t>=0?"left":"right":i>=0?"top":"bottom");let p="start";d?"right"===f?p="end":"middle"===f&&(p="middle"):p=t>=0?"start":"end";let g=e.useHTML||e.html,m=g?void 0:ue(e),y=m?.lineHeight??16,x=m?.titleLines??(n?c?[n]:he(n,l,8):[]),b=m?.labelLines??(o?c?[o]:he(o,l,8):[]),v=x.length+b.length,w=h?"end"===p?-4:4:0,k=[],A=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";if(g){let e=l,t=Math.max(y,v*y+(n&&o?2:0)),i="end"===p?w-e:"middle"===p?w-e/2:w,r="end"===p?"right":"middle"===p?"center":"left";k.push(
63
- /* @__PURE__ */mc("foreignObject",{className:"annotation-note-html",x:i,y:-y,width:e,height:t+y,style:{overflow:"visible"},children:/* @__PURE__ */yc("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:A,fontSize:"12px",lineHeight:`${y}px`,overflow:"visible",textAlign:r,whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[n&&/* @__PURE__ */mc("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:n}),o&&/* @__PURE__ */mc("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html"))}else for(let e of[!0,!1]){let t=e?x:b;if(0===t.length)continue;let i="annotation-note-"+(e?"title":"label");k.push(
64
- /* @__PURE__ */mc("text",{className:i,fill:A,textAnchor:p,fontWeight:e?m?.titleFontWeight??"bold":void 0,y:e?void 0:x.length*y,children:t.map((e,t)=>/* @__PURE__ */mc("tspan",{x:w,dy:0===t?0:y,children:e},t))},i))}let S=null;if((n||o)&&(0!==t||0!==i)){let e=d?m?m.width:Math.min(l,120):(x.length+b.length+(b.length>0?1:0))*y,t=d?p:f,i="end"===t||"bottom"===t?-e:"middle"===t?-e/2:0;S=/* @__PURE__ */mc("line",{className:"note-line",x1:d?i:0,x2:d?i+e:0,y1:d?0:i,y2:d?0:i+e,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}let M=Math.max(0,v-1)*y,$=b.length>0&&x.length>0?2:0,_=0;(d||h)&&(_=h&&"middle"===f?-(M+y+$)/2+y/2:i<0||h&&"bottom"===f?-(M+2):2+y);let L=0!==_?`translate(0,${_})`:void 0;/* @__PURE__ */
65
- return yc("g",{className:"annotation-note",transform:`translate(${t},${i})`,...m?.textProps,children:[
66
- /* @__PURE__ */mc("g",{className:"annotation-note-content",transform:L,children:k}),S]})}function vc(e,t,i,r,o){let n=null,a=i||"var(--semiotic-text-secondary, currentColor)";switch(e){case"callout-circle":{let e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&(n=/* @__PURE__ */mc("circle",{r:e,fill:"none",stroke:a},"subject-circle"));break}case"callout-rect":{let e=t?.width||0,i=t?.height||0;(e>0||i>0)&&(n=/* @__PURE__ */mc("rect",{width:e,height:i,fill:"none",stroke:a},"subject-rect"));break}case"callout-custom":n=t?.custom;break;case"xy-threshold":{let e=r||0,i=o||0,s=0,l=0,c=0,u=0;if(void 0!==t?.x)s=l=(t.x||0)-e,c=(t.y1||0)-i,u=(t.y2||0)-i;else if(void 0!==t?.y)c=u=(t.y||0)-i,s=(t.x1||0)-e,l=(t.x2||0)-e;else if(void 0!==t?.x1||void 0!==t?.x2)s=(t.x1||0)-e,l=(t.x2||0)-e;else{if(void 0===t?.y1&&void 0===t?.y2)break;c=(t.y1||0)-i,u=(t.y2||0)-i}n=/* @__PURE__ */mc("line",{x1:s,y1:c,x2:l,y2:u,stroke:a,strokeDasharray:"5,5"},"threshold-line");break}case"bracket":{let e=t?.type||"curly",i=t?.width??t?.height;void 0!==i&&(n=/* @__PURE__ */mc("path",{d:xc(e,i,t?.depth||30,void 0===t?.width),fill:"none",stroke:a},"bracket-path"));break}}/* @__PURE__ */
67
- return mc("g",{className:"annotation-subject",children:n})}function wc(e,t,i,r,o,n){let a,s,l=0,c=0;if("callout-circle"!==o&&"label"!==o||!n?.radius){if("callout-rect"===o&&n){let i=n.width||0,r=n.height||0;if(i>0||r>0){let o=i/2,n=r/2,a=e-o,s=t-n;if(0!==a||0!==s){let e=Math.abs(a),t=Math.abs(s),u=i/2,d=r/2,h=e*d>t*u?u/e:d/t;l=o+a*h,c=n+s*h}}}else if("bracket"===o&&n){let e=n.width,t=n.height,i=n.depth||30;void 0!==e?(l=e/2,c=i):void 0!==t&&(l=i,c=t/2)}}else{let i=(n.radius||0)+(n.radiusPadding||0);if(i>0&&(0!==e||0!==t)){let r=Math.atan2(t,e);l=Math.cos(r)*i,c=Math.sin(r)*i}}let u=e-l,d=t-c,h=Math.hypot(u,d);if(h>.5){let o=r||"var(--semiotic-text-secondary, currentColor)",n="curve"===i?.type,f=Math.atan2(d,u);if(n){let r=(l+e)/2,n=(c+t)/2,s=-d/h,p=u/h,g=(i?.curve??.25)*h,m=r+s*g,y=n+p*g;a=/* @__PURE__ */mc("path",{className:"connector-curve",d:`M${l},${c}Q${m},${y} ${e},${t}`,fill:"none",stroke:o},"connector-line"),f=Math.atan2(y-c,m-l)}else a=/* @__PURE__ */mc("line",{x1:l,y1:c,x2:e,y2:t,stroke:o},"connector-line");if("arrow"===i?.end){let e=.08888888888888889*Math.PI,t=l+10*Math.cos(f+e),i=c+10*Math.sin(f+e),r=l+10*Math.cos(f-e),n=c+10*Math.sin(f-e);s=/* @__PURE__ */mc("path",{d:`M${l},${c}L${t},${i}L${r},${n}Z`,fill:o,stroke:"none"},"connector-arrow")}}/* @__PURE__ */
68
- return yc("g",{className:"annotation-connector",children:[a,s]})}function kc(e){let{x:t=0,y:i=0,dx:r,dy:o,nx:n,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:f,opacity:p,strokeDasharray:g,events:m={},"data-testid":y}=e,x=Array.isArray(t)?t[0]??0:t,b=Array.isArray(i)?i[0]??0:i,v=Array.isArray(f)?f:[],w=r||0,k=o||0;null!=n&&(w=n-x),null!=a&&(k=a-b);let A="string"==typeof u?u:"label";if("bracket"===A&&c&&0===w&&0===k)if(void 0!==c.width){w=c.width/2;let e=c.depth||30;k=e+(e>=0?5:-5)}else if(void 0!==c.height){let e=c.depth||30;w=e+(e>=0?5:-5),k=c.height/2}/* @__PURE__ */
69
- return yc("g",{className:`annotation ${h||""}`.trim(),transform:`translate(${x},${b})`,"data-testid":y,...null!=p&&{opacity:p},...g&&{strokeDasharray:g},...m,children:[!v.includes("connector")&&wc(w,k,l,d,A,c),!v.includes("subject")&&vc(A,c,d,x,b),!v.includes("note")&&bc(s,w,k,d)]})}function Ac(e){let{noteData:t}=e,{screenCoordinates:i}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&i){let e=t.nx||i[0][0]+(t.dx??0),o=t.ny||i[0][1]+(t.dy??0),n=i.map((i,n)=>{let a=Object.assign({},t,{note:0===n?t.note:{label:""},x:i[0],y:i[1],nx:e,ny:o});/* @__PURE__ */
70
- return mc(kc,{"data-testid":"semiotic-annotation",...a,type:r},`multi-annotation-${n}`)});/* @__PURE__ */
71
- return mc("g",{children:n})}let n=t.note||{title:"none",label:t.label},a=`${n.label}-${n.title}-${t.i}`;/* @__PURE__ */
72
- return mc(kc,{"data-testid":"semiotic-annotation",events:o,...t,type:r},a)}import{jsx as Sc}from"react/jsx-runtime";var Mc={secondary:0,primary:3};function $c(e){return!0===e?._annotationDeferred}function _c(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Lc(e){return"primary"===e?.emphasis||"secondary"===e?.emphasis?e.emphasis:null}function Pc(e){let t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function Ic(e){return Math.max(.72,.95-.06*e)}function Rc(e){let t=e.map((e,t)=>({p:e,i:t,emphasis:Lc(e.annotation),confidence:Pc(e.annotation),readingOrder:null,rank:1})),i=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>$c(e.annotation)),o=e.some(e=>null!=_c(e.annotation)),n=e.some(e=>"layer"===_c(e.annotation));if(!i&&!r&&!o)return e.map(e=>e.node);let a=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);a.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,a.length)});for(let e of t)e.emphasis&&(e.rank=Mc[e.emphasis]);let s=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{let{p:t,i:i,emphasis:r,readingOrder:o}=e,n=$c(t.annotation),a=t.node;if("primary"===r||"secondary"===r||null!=o){let e=null==r&&null!=o;a=/* @__PURE__ */Sc("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":`annotation-emphasis annotation-emphasis--${r}`,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:Ic(o),"data-annotation-reading-order":o}:{},children:t.node},`annotation-emphasis-${i}`)}let s=_c(t.annotation);return s&&(a=/* @__PURE__ */Sc("g",{className:`annotation-cohesion--${s}`,children:a},`annotation-cohesion-${i}`)),n&&(a=/* @__PURE__ */Sc("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},`annotation-deferred-${i}`)),a});return r&&s.unshift(
73
- /* @__PURE__ */Sc("style",{children:".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}"},"annotation-disclosure-style")),n&&s.unshift(
74
- /* @__PURE__ */Sc("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),s}function Tc(e,t,i,r){let o=[];return e.forEach((e,n)=>{let a;a=i?i(e,n,r)??t(e,n,r):t(e,n,r),a&&o.push({node:a,annotation:e})}),{nodes:Rc(o),renderedAnnotations:o.map(e=>e.annotation)}}function Cc(e,t,i,r){let o=Ds(e.fill??e.color,t,r),n="string"==typeof e.fill&&e.fill?e.fill:"string"==typeof e.color&&e.color?e.color:r;return js(e.gradient,t,i,n)??o}var Nc=/* @__PURE__ */new Set(["top-left","top-center","top-right","middle-left","center","middle-right","bottom-left","bottom-center","bottom-right"]);function Fc(e,t,i){let r=e.position,o="string"==typeof r&&Nc.has(r)?r:"bottom-left",n=o.endsWith("left")?"left":o.endsWith("right")?"right":"center",a=o.startsWith("top")?"top":o.startsWith("bottom")?"bottom":"middle",s="top"===a?0:"bottom"===a?i:i/2;return{x:("left"===n?0:"right"===n?t:t/2)+("number"==typeof e.dx&&Number.isFinite(e.dx)?e.dx:0),y:s+("number"==typeof e.dy&&Number.isFinite(e.dy)?e.dy:0),textAnchor:"start"===e.textAnchor||"middle"===e.textAnchor||"end"===e.textAnchor?e.textAnchor:"left"===n?"start":"right"===n?"end":"middle",dominantBaseline:"auto"===e.dominantBaseline||"middle"===e.dominantBaseline||"hanging"===e.dominantBaseline?e.dominantBaseline:"top"===a?"hanging":"bottom"===a?"auto":"middle"}}function zc(e,t,i,r){return{...Fc(e,t,i),fill:e.fill??e.color??r.fill,fontSize:e.fontSize??r.fontSize,fontFamily:e.fontFamily??r.fontFamily,fontWeight:e.fontWeight,fontStyle:e.fontStyle,letterSpacing:e.letterSpacing,opacity:e.opacity,className:e.className,style:{pointerEvents:"none"}}}import{jsx as Ec}from"react/jsx-runtime";var Dc={fill:"var(--semiotic-text, #333)",fontSize:11,fontFamily:"inherit"};function Oc({annotation:e,width:t,height:i,defaults:r=Dc}){let o=e.label??e.text;return null==o?null:/* @__PURE__ */Ec("text",{...zc(e,t,i,r),children:o})}import{packEnclose as jc}from"d3-hierarchy";import{area as Wc,curveBasis as Bc,curveCardinal as Yc,curveCatmullRom as Gc,curveLinear as Xc,curveMonotoneX as Vc,curveMonotoneY as qc,curveStep as Hc,curveStepAfter as Uc,curveStepBefore as Zc}from"d3-shape";import*as Qc from"react";function Kc(e){let t=e.provenance,i=e.id??e.stableId??t?.stableId;return null==i||""===i?void 0:String(i)}function Jc(e){let t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}function eu(e,t={}){let i=Kc(e);return{"data-semiotic-annotation-widget":"",...i?{"data-semiotic-annotation-id":i}:{},onClickCapture(r){let o=Jc(r);t.onAnnotationActivate?.({annotation:e,annotationId:i,chartId:t.chartId,inputType:o}),i&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:i,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function tu(e,t){return ic(e)?oc(e)??t:e}function iu(e,t,i){let r=e.labelBackground,o=t.colors.background,n=o&&"transparent"!==o?o:t.colors.surface||o;return void 0===r?"none"===i?"none":{type:"halo",fill:n}:!1===r||"none"===r?"none":!0===r||"halo"===r?{type:"halo",fill:n}:"box"===r?{type:"box",fill:n}:{...r,fill:tu(r.fill,n)??n,...void 0!==r.stroke?{stroke:tu(r.stroke,t.colors.border)}:{}}}function ru(e,t){let i=t.scales?.x??t.scales?.time,r=t.scales?.y??t.scales?.value;if(!i||!r)return[];let o=t.data||[],n=t.xAccessor||"x",a=t.yAccessor||"y",s="horizontal"===t.projection,l="ordinal"===t.frameType;l&&s&&([n,a]=[a,n]);let c=i,u=r,d=s?u:c,h=l?t.scales?.o?.domain().map(String)??[...new Set(o.filter(e=>null!=e[n]).map(e=>String(e[n])))].sort((e,t)=>d(e)-d(t)):[],f=new Map(h.map((e,t)=>[e,t])),p=wr(o.map(e=>[l?null==e[n]?void 0:f.get(String(e[n])):e[n],e[a]]));return p.length<2?[]:("loess"===e.method?Lr(p,e.bandwidth??.3):("polynomial"===e.method?Sr(p,e.order??2):Ar(p)).points).map(([e,t])=>{if(!l)return[c(e),u(t)];let i=d(h[e]);return s?[c(t),i]:[i,u(t)]}).filter(([e,t])=>Number.isFinite(e)&&Number.isFinite(t))}import{jsx as ou,jsxs as nu}from"react/jsx-runtime";var au={linear:Xc,monotoneX:Vc,monotoneY:qc,step:Hc,stepAfter:Uc,stepBefore:Zc,basis:Bc,cardinal:Yc,catmullRom:Gc};function su(e,t,i,r){let o=e.color||r?.colors.textSecondary||"#666",n=r?iu(e,r,"none"):e.labelBackground??"none";switch(e.type){case"enclose":{let r=(e.coordinates||[]).map(e=>({x:pe({...e,type:"point"},i),y:me({...e,type:"point"},i),r:1})).filter(e=>null!=e.x&&null!=e.y);if(r.length<2)return null;let a=jc(r),s=e.padding||10;/* @__PURE__ */
75
- return nu("g",{children:[
76
- /* @__PURE__ */ou("circle",{cx:a.x,cy:a.y,r:a.r+s,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:o,strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&/* @__PURE__ */ou(uc,{x:a.x,y:a.y-a.r-s-4,textAnchor:"middle",fill:o,fontSize:12,text:e.label,background:n})]},`ann-${t}`)}case"rect-enclose":{let r=(e.coordinates||[]).map(e=>({x:pe({...e,type:"point"},i),y:me({...e,type:"point"},i)})).filter(e=>null!=e.x&&null!=e.y);if(r.length<2)return null;let a=e.padding||10,[s,l]=Ne(r.map(e=>e.x)),[c,u]=Ne(r.map(e=>e.y)),d=s-a,h=l+a,f=c-a;/* @__PURE__ */
77
- return nu("g",{children:[
78
- /* @__PURE__ */ou("rect",{x:d,y:f,width:h-d,height:u+a-f,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:o,strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&/* @__PURE__ */ou(uc,{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:o,fontSize:12,text:e.label,background:n})]},`ann-${t}`)}case"highlight":{let r=i.data||[],o="function"==typeof e.filter?r.filter(e.filter):e.field&&null!=e.value?r.filter(t=>t[e.field]===e.value):[],n={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};/* @__PURE__ */
79
- return ou("g",{children:o.map((t,r)=>{let o=pe(t,i),a=me(t,i);if(null==o||null==a)return null;let s="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||n;/* @__PURE__ */
80
- return ou("circle",{cx:o,cy:a,r:s,...l},`hl-${r}`)})},`ann-${t}`)}case"bracket":{let r=pe(e,i),o=me(e,i);/* @__PURE__ */
81
- return ou(Ac,{noteData:{x:r??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:le(e),type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},`ann-${t}`)}case"trend":{let r=ru(e,i);if(r.length<2)return null;let o=r.map(([e,t])=>`${e},${t}`).join(" "),n=e.color||"#6366f1",[a,s]=r[r.length-1];/* @__PURE__ */
82
- return nu("g",{children:[
83
- /* @__PURE__ */ou("polyline",{points:o,fill:"none",stroke:n,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&/* @__PURE__ */ou("text",{x:a+4,y:s-4,fill:n,fontSize:11,children:e.label})]},`ann-${t}`)}case"envelope":{let r=i.data||[];if(r.length<2)return null;let o=i.xAccessor||"x",n=i.scales?.x??i.scales?.time,a=i.scales?.y??i.scales?.value;if(!n||!a)return null;let s=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=r.filter(e=>null!=e[s]&&null!=e[l]&&(!c||c(e))).sort((e,t)=>e[o]-t[o]);if(u.length<2)return null;let d=au[i.curve||"linear"]||Xc,h=Wc().x(e=>n(e[o])).y0(e=>a(e[l])).y1(e=>a(e[s])).curve(d)(u);if(!h)return null;let f=e.fill||"#6366f1",p=u[u.length-1];/* @__PURE__ */
84
- return nu("g",{children:[
85
- /* @__PURE__ */ou("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&/* @__PURE__ */ou("text",{x:n(p[o])+4,y:a(p[s])-4,fill:f,fontSize:11,children:e.label})]},`ann-${t}`)}case"anomaly-band":{let r=(i.data||[]).filter(t=>!e.filter||e.filter(t));if(r.length<2)return null;let o=i.yAccessor||"y",n=i.scales?.x??i.scales?.time,a=i.scales?.y??i.scales?.value;if(!n||!a)return null;let s=r.map(e=>vr(e[o])).filter(e=>null!==e);if(s.length<2)return null;let l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+(t-l)**2,0)/s.length,u=Math.sqrt(c),d=e.threshold??2,h=l-d*u,f=a(l+d*u),p=a(h),g=e.fill||"#6366f1",m=e.anomalyColor||"#ef4444",y=e.anomalyRadius??6,x=r.filter(e=>{let t=vr(e[o]);return null!=t&&Math.abs(t-l)>d*u});/* @__PURE__ */
86
- return nu("g",{children:[!1!==e.showBand&&/* @__PURE__ */ou("rect",{x:0,y:Math.min(f,p),width:i.width||0,height:Math.abs(p-f),fill:g,fillOpacity:e.fillOpacity??.1}),x.map((e,t)=>{let r=pe(e,i),o=me(e,i);return null==r||null==o?null:/* @__PURE__ */ou("circle",{cx:r,cy:o,r:y,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},`anomaly-${t}`)}),e.label&&/* @__PURE__ */ou("text",{x:(i.width||0)-4,y:Math.min(f,p)-4,textAnchor:"end",fill:g,fontSize:11,children:e.label})]},`ann-${t}`)}case"forecast":{let r=i.data||[],o=i.xAccessor||"x",n=i.yAccessor||"y",a=i.scales?.x??i.scales?.time,s=i.scales?.y??i.scales?.value;if(!a||!s)return null;let l=wr(r.map(e=>[e[o],e[n]])),c=Ir(l,e);if(!c)return null;let{predict:u}=c,d=l[l.length-1][0],h=c.forecast(e.steps??5);if(!h.length)return null;let f=Wc().x(e=>a(e.x)).y0(e=>s(e.lower)).y1(e=>s(e.upper))(h);if(!f)return null;let p=h.map(e=>`${a(e.x)},${s(e.y)}`).join(" "),g=e.fill||"#6366f1",m=e.strokeColor||"#6366f1",y=h[h.length-1];/* @__PURE__ */
87
- return nu("g",{children:[
88
- /* @__PURE__ */ou("path",{d:f,fill:g,fillOpacity:e.fillOpacity??.15,stroke:"none"}),
89
- /* @__PURE__ */ou("polyline",{points:`${a(d)},${s(u(d))} ${p}`,fill:"none",stroke:m,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&y&&/* @__PURE__ */ou("text",{x:a(y.x)+4,y:s(y.y)-4,fill:m,fontSize:11,children:e.label})]},`ann-${t}`)}case"widget":{let r,o;if(null!=e.px&&null!=e.py)r=e.px,o=e.py;else{let n=xe(e,t,i);if(!n)return null;r=n.x,o=n.y}if(!ve(r,o,i))return null;let n=e.width??32,a=e.height??32,s=e.content??/* @__PURE__ */ou("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});/* @__PURE__ */
90
- return ou("foreignObject",{x:r+(e.dx??0)-n/2,y:o+(e.dy??0)-a/2,width:n,height:a,style:{overflow:"visible",pointerEvents:"auto"},children:/* @__PURE__ */ou("div",{...eu(e),style:{width:n,height:a,display:"flex",alignItems:"center",justifyContent:"center"},children:s})},`ann-${t}`)}default:return null}}import{jsx as lu,jsxs as cu}from"react/jsx-runtime";function uu(e,t){return e.color||t.colors.annotation||t.colors.text}function du(e,t,i,r){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){let i=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(i)return{x:i[0],y:i[1]}}return{x:hu(e,t,i),y:fu(e,t,r)}}function hu(e,t,i){return null!=e.x&&t.x?t.x(e.x):i&&null!=e[i]&&t.x?t.x(e[i]):"number"==typeof e.x?e.x:null}function fu(e,t,i){return null!=e.y&&t.y?t.y(e.y):i&&null!=e[i]&&t.y?t.y(e[i]):"number"==typeof e.y?e.y:null}function pu(e){let{annotations:t}=e;if(!t||0===t.length)return e.onRender?.({inputCount:0,eligibleCount:0,renderedCount:0,unrenderedCount:0,unrenderedTypes:[]}),null;let i=g(t).filter(e=>!e._directLabel),r=e.scales.geoProjection,o=r?i.map(e=>{if(!Array.isArray(e.coordinates)||e.coordinates.length<2)return e;let t=r([Number(e.coordinates[0]),Number(e.coordinates[1])]);return t?{...e,x:t[0],y:t[1]}:e}):i,n=!!r&&!e.scales.x&&!e.scales.y,a=e=>Number(e),s=e.scales.x??(n?a:void 0),l=e.scales.y??(n?a:void 0),c=e.frameType??(e.projection?"ordinal":r||e.scales.x||e.scales.y?"xy":"network"),u="horizontal"===e.projection,d=e.projection?u?"horizontal":"vertical":void 0,h="vertical"===e.projection||u,f=e.scales.o,p=f?e=>(f(e)??0)+(f.bandwidth?.()??0)/2:void 0,m={scales:{x:(h?u?e.scales.r:p:void 0)??s,y:(h?u?p:e.scales.r:void 0)??l,time:h?e.scales.r:s,value:h?e.scales.r:l,o:f,...r?{geoProjection:r}:{}},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,data:e.annotationData,pointNodes:e.pointNodes,frameType:c,...d?{projection:d}:{}},y=tc(t,{...e.layout,scales:e.scales,margin:e.margin,fontFamily:e.theme.typography.fontFamily,measure:e.labelMeasurer,...e.svgAnnotationRules?{renderLabel:(t,i,r)=>e.svgAnnotationRules(t,i,m)??r}:{}}),x=e.autoPlaceAnnotations?Ae({annotations:o,context:m,..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):o,b=Tc(x,(t,i,r)=>gu(t,i,e,r)??su(t,i,r,e.theme),e.svgAnnotationRules,m),v=y.node?[...b.nodes,y.node]:b.nodes,w=/* @__PURE__ */new Map;for(let e of b.renderedAnnotations){let t="string"==typeof e.type?e.type:"unknown";w.set(t,(w.get(t)??0)+1)}y.evidence&&w.set("text",(w.get("text")??0)+y.evidence.rendered);let k=[];for(let e of t){let t="string"==typeof e.type?e.type:"unknown",i=w.get(t)??0;i>0?w.set(t,i-1):k.push(t)}e.onRender?.({inputCount:t.length,eligibleCount:x.length,renderedCount:b.renderedAnnotations.length+(y.evidence?.rendered??0),...y.evidence?{layout:y.evidence}:{},unrenderedCount:k.length,unrenderedTypes:k});let A=e.idPrefix?`${e.idPrefix}-`:"";return v.length>0?/* @__PURE__ */lu("g",{id:`${A}annotations`,className:"semiotic-annotations",children:v}):null}function gu(e,t,i,r){let{scales:o,layout:n,theme:a,xAccessor:s,yAccessor:l}=i;switch(e.type){case"frame-text":/* @__PURE__ */
91
- return lu(Oc,{annotation:e,width:n.width,height:n.height,defaults:{fill:a.colors.text,fontSize:11,fontFamily:a.typography.fontFamily}},`ann-frame-text-${t}`);case"y-threshold":{let r=e.value??e.y;if(null==r)return null;let s=uu(e,a),l=e.label,c=e.strokeDasharray||"6,4",u=e.strokeWidth??1.5;if("horizontal"===i.projection&&o.r){let i=o.r(r);return null==i?null:/* @__PURE__ */cu("g",{opacity:e.opacity,children:[
92
- /* @__PURE__ */lu("line",{x1:i,y1:0,x2:i,y2:n.height,stroke:s,strokeWidth:u,strokeDasharray:c}),hc(e.endCap,[i,0],s),l&&/* @__PURE__ */lu(uc,{x:i+4,y:16,textAnchor:"start",fontSize:a.typography.tickSize,fill:e.labelColor??s,fontFamily:a.typography.fontFamily,text:l,background:iu(e,a,"halo")})]},`ann-ythresh-${t}`)}let d=o.y?o.y(r):o.r?o.r(r):null;return null==d?null:/* @__PURE__ */lu(gc,{ann:e,position:d,vertical:!1,width:n.width,height:n.height,color:s,fontSize:a.typography.tickSize,fontFamily:a.typography.fontFamily,background:iu(e,a,"halo"),dash:"6,4",labelGap:6},`ann-ythresh-${t}`)}case"x-threshold":{let r=e.value??e.x;if(null==r)return null;let s="horizontal"===i.projection&&o.r?o.r(r):o.x?o.x(r):null;if(null==s)return null;let l=uu(e,a);/* @__PURE__ */
93
- return lu(gc,{ann:e,position:s,vertical:!0,width:n.width,height:n.height,color:l,fontSize:a.typography.tickSize,fontFamily:a.typography.fontFamily,background:iu(e,a,"halo"),dash:"6,4"},`ann-xthresh-${t}`)}case"band":{let r=o.y?.domain?.(),s=e.y0??r?.[0],l=e.y1??r?.[1],c=null!=s&&o.y?o.y(s):null,u=null!=l&&o.y?o.y(l):null;if(null==c||null==u)return null;let d=Math.min(c,u),h=Math.abs(u-c),f=Cc(e,`ssr-band-${t}`,"vertical",a.colors.primary||uu(e,a)),p=e.fillOpacity??.1,g=!0===i.underLayerBands&&"under"===e.layer;/* @__PURE__ */
94
- return cu("g",{opacity:e.opacity,children:[!g&&f.def&&/* @__PURE__ */lu("defs",{children:f.def}),!g&&/* @__PURE__ */lu("rect",{x:0,y:d,width:n.width,height:h,fill:f.fill,fillOpacity:p}),e.label&&/* @__PURE__ */lu(uc,{x:n.width-4,y:Math.max(d,0)+16,textAnchor:"end",fontSize:a.typography.tickSize,fill:e.labelColor??(e.color||a.colors.primary||uu(e,a)),fontFamily:a.typography.fontFamily,fontWeight:"bold",text:e.label,background:iu(e,a,"halo")})]},`ann-band-${t}`)}case"x-band":{let r=o.x?.domain?.(),s=e.x0??r?.[0],l=e.x1??r?.[1],c=null!=s&&o.x?o.x(s):null,u=null!=l&&o.x?o.x(l):null;if(null==c||null==u)return null;let d=Math.min(c,u),h=Math.abs(u-c),f=Cc(e,`ssr-xband-${t}`,"horizontal",a.colors.primary||uu(e,a)),p=e.fillOpacity??.1,g=!0===i.underLayerBands&&"under"===e.layer;/* @__PURE__ */
95
- return cu("g",{opacity:e.opacity,children:[!g&&f.def&&/* @__PURE__ */lu("defs",{children:f.def}),!g&&/* @__PURE__ */lu("rect",{x:d,y:0,width:h,height:n.height,fill:f.fill,fillOpacity:p}),e.label&&/* @__PURE__ */lu(uc,{x:d+4,y:16,textAnchor:"start",fontSize:a.typography.tickSize,fill:e.labelColor??(e.color||a.colors.primary||uu(e,a)),fontFamily:a.typography.fontFamily,fontWeight:"bold",text:e.label,background:iu(e,a,"halo")})]},`ann-xband-${t}`)}case"category-highlight":{if(null==e.category||!o.o)return null;let r=o.o(String(e.category));if(null==r)return null;let s=o.o.bandwidth?o.o.bandwidth():40,l=uu(e,a),c=e.opacity??.1,u=e.label;return"horizontal"===i.projection?/* @__PURE__ */cu("g",{children:[
96
- /* @__PURE__ */lu("rect",{x:0,y:r,width:n.width,height:s,fill:l,opacity:c}),u&&/* @__PURE__ */lu(uc,{x:12,y:r+s/2,dominantBaseline:"middle",fill:l,fontSize:a.typography.tickSize,fontWeight:"bold",fontFamily:a.typography.fontFamily,text:u,background:iu(e,a,"none")})]},`ann-cathighlight-${t}`):/* @__PURE__ */cu("g",{children:[
97
- /* @__PURE__ */lu("rect",{x:r,y:0,width:s,height:n.height,fill:l,opacity:c}),u&&/* @__PURE__ */lu(uc,{x:r+s/2,y:16,textAnchor:"middle",fill:l,fontSize:a.typography.tickSize,fontWeight:"bold",fontFamily:a.typography.fontFamily,text:u,background:iu(e,a,"none")})]},`ann-cathighlight-${t}`)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{let i=du(e,o,s,l),n=null==i.x||null==i.y?xe(e,t,r):null,c=i.x??n?.x??null,u=i.y??n?.y??null;if(null==c||null==u)return null;let d="text"===e.type,h=e.dx??(d?0:30),f=e.dy??(d?0:-30),p=e.color||a.colors.text;if(!d){let i="callout"===e.type?"callout-circle":e.type,r="callout-circle"===i?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===i?{width:e.width,height:e.height}:void 0;/* @__PURE__ */
98
- return lu(Ac,{noteData:{x:c,y:u,dx:h,dy:f,note:le(e),type:i,...r?{subject:r}:{},connector:e.connector||{end:"arrow"},color:p,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},`ann-label-${t}`)}/* @__PURE__ */
99
- return lu("g",{children:/* @__PURE__ */lu("text",{x:c+h,y:u+f,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||a.typography.labelSize,fill:p,fontFamily:a.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},`ann-label-${t}`)}default:return null}}import{jsx as mu}from"react/jsx-runtime";function yu(e,t,i,r="right",o,n){if(null==e||!1===e)return null;let{x:a,y:s}=yt(e,{totalWidth:t[0],totalHeight:t[1],margin:i,position:r,legendLayout:o,axisChrome:n});/* @__PURE__ */
100
- return mu("g",{transform:`translate(${a}, ${s})`,children:e})}function xu(e){let t=String(e).replace(/[^a-zA-Z0-9_-]/g,"_"),i=/^[A-Za-z_]/.test(t)?t:`c${t}`,r=`${i}-semiotic-title`,o=`${i}-semiotic-desc`;return{titleId:r,descId:o,labelledBy:`${r} ${o}`}}function bu(e,t){if(0===t.categories.length)return;let i=t.position||"right";mt(e,{legend:zl(t.categories,t.colorScheme,t.theme),position:i,size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}function vu(e,t){let i=t.position||"right";mt(e,{legend:t.legend,position:i,size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}import*as wu from"react";function ku(e,t,i){if("edges"===e){if(t)return"start";if(i)return"end"}return"middle"}function Au(e,t,i){if("edges"===e){if(t)return"hanging";if(i)return"auto"}return"middle"}function Su(e){if(0===e.length)return{min:null,max:null};let t=1/0,i=-1/0;for(let r of e)r.pixel<t&&(t=r.pixel),r.pixel>i&&(i=r.pixel);return{min:t,max:i}}function Mu(e){if(e)return"object"==typeof e?e.strokeDasharray:"dashed"===e?"6,4":"dotted"===e?"2,4":e}function $u(e,t){return e&&"string"!=typeof e?{stroke:e.stroke??t.stroke,strokeWidth:e.strokeWidth??t.strokeWidth,...null!=e.strokeOpacity&&{strokeOpacity:e.strokeOpacity},...e.strokeDasharray&&{strokeDasharray:e.strokeDasharray}}:{...t,..."string"==typeof e&&{strokeDasharray:Mu(e)}}}function _u(e,t,i){if("left"===e||"right"===e){let r="left"===e?i:0,o="left"===e?-1:1,n=Math.ceil(t/8),a=`M0,${r}`;for(let e=0;e<n;e++){let i=8*e+4,n=8*(e+1);a+=`L${Math.min(i,t)},${r+4*o}`,a+=`L${Math.min(n,t)},${r}`}return a}let r="bottom"===e?0:t,o="bottom"===e?1:-1,n=Math.ceil(i/8),a=`M${r},0`;for(let e=0;e<n;e++){let t=8*e+4,n=8*(e+1);a+=`L${r+4*o},${Math.min(t,i)}`,a+=`L${r},${Math.min(n,i)}`}return a}function Lu(e,t){let i=e.domain(),r=i[0],o=i[i.length-1],n=r instanceof Date,a=r instanceof Date?r.getTime():r,s=o instanceof Date?o.getTime():o;if(t<2||a===s)return n?[new Date(a),new Date(s)]:[a,s];let l=(s-a)/(t-1),c=new Array(t);for(let e=0;e<t;e++){let i=e===t-1?s:a+e*l;c[e]=n?new Date(i):i}return c}function Pu(e,t,i){return"exact"===i?Lu(e,t):e.ticks(t)}import{jsx as Iu}from"react/jsx-runtime";function Ru(e){return"string"==typeof e||"number"==typeof e}function Tu(e){let{label:t,x:i,y:r,textAlign:o,fontSize:n,fontFamily:a,color:s}=e;/* @__PURE__ */
101
- return Iu("foreignObject",{x:i,y:r,width:60,height:24,style:{overflow:"visible"},children:/* @__PURE__ */Iu("div",{style:{color:s,fontFamily:a,fontSize:n,textAlign:o,userSelect:"none"},children:t})})}function Cu(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Nu(e,t){let i=Cu(e);if(!i)return!1;let r=Cu(t);return!r||i.getFullYear()!==r.getFullYear()||i.getMonth()!==r.getMonth()}function Fu(e,t,i,r){return!!e&&("function"==typeof e?e(t.value,i):Nu(t.value,i>0?r[i-1].value:void 0))}function zu(e,t){return e?.ticks??e?.tickCount??t}function Eu(e,t){return!("string"!=typeof e&&"number"!=typeof e||"string"!=typeof t&&"number"!=typeof t||String(e)!==String(t))}function Du(e,t){if(e.length<=2)return e;let i=[e[0]];for(let r=1;r<e.length-1;r++)Math.abs(e[r].pixel-i[i.length-1].pixel)>=t&&i.push(e[r]);let r=e[e.length-1];return Math.abs(r.pixel-i[i.length-1].pixel)>=t?i.push(r):i[i.length-1]=r,i}function Ou(e){return"string"==typeof e||"number"==typeof e?6.5*String(e).length:60}function ju(e){for(let t=1;t<e.length;t++){let i=e[t-1],r=e[t];if(Math.abs(r.pixel-i.pixel)<(Ou(i.label)+Ou(r.label))/2+8)return!0}return!1}function Wu(e){let{scale:t,axis:i,size:r,horizontal:o=!1,axisExtent:n}=e,a=i?.extent??n,s=t.domain(),l=zu(i,5),c=Math.max(2,Math.floor(r/(o?70:30))),u="exact"===a?Math.max(2,l):Math.min(l,c),d=i?.tickValues??Pu(t,u,a),h=d.map(e=>e.valueOf()),f=i?.tickFormat||e.format||(s[0]instanceof Date||d[0]instanceof Date?yo([s[0].valueOf(),s[s.length-1].valueOf()]):Ze(h)),p=(e,t)=>o?f(e,t,h):f(e),g=d.map((e,i)=>({value:e,pixel:t(e),label:p(e,i)})),m=22;if(o){let e=g.reduce((e,t)=>Math.max(e,Ou(t.label)),0);m=i?.autoRotate?Math.max(20,Math.min(e+8,55)):Math.max(55,e+8)}let y=o&&(i?.tickFormat||e.format)?e=>{let t=e.map(e=>e.value.valueOf());return e.map((e,i)=>({...e,label:f(e.value,i,t)}))}:void 0,x=Du(g,m);if(y&&(x=y(x)),x.length>1&&(x=x.filter((e,t)=>0===t||!Eu(e.label,x[t-1].label))),i?.includeMax&&x.length>0&&"exact"!==a&&!i.tickValues){let e=s[s.length-1];if(null!=e){let i=t(e),r=Math.abs(i-x[x.length-1].pixel);if(r>1){let t=p(e,x.length);r<m&&x.length>1&&(x=x.slice(0,-1)),x=[...x,{value:e,pixel:i,label:t}]}}}return y?y(x):x}import{jsx as Bu,jsxs as Yu}from"react/jsx-runtime";function Gu(e){let t=e._idPrefix||e.chartId;if(t){let e=String(t).replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:`c${e}`}let i=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`,r=0;for(let e=0;e<i.length;e++)r=31*r+i.charCodeAt(e)|0;return`c${(r>>>0).toString(36)}`}function Xu(e,t,i){return Qe(e.showLegend&&!e.__legendIncludesAutomatic?zl(t,e.colorScheme,i):void 0,e.legend)}var Vu={right:110,left:110,top:50,bottom:80};function qu(e,t){if(e.__autoLegendMargin)return Vu[t]}function Hu(e,t){let i={theme:t.theme,position:t.position||"right",totalWidth:t.size[0],totalHeight:t.size[1],margin:t.margin,hasTitle:t.hasTitle,legendLayout:t.legendLayout,idPrefix:t.idPrefix,reservedWidth:t.reservedWidth,axisChrome:t.axisChrome,legendDistance:Ke(e)||Je(e)?e.legendDistance:void 0};return Ke(e)?Vl({...i,legendGroups:e.legendGroups}):Je(e)?ql({...i,gradient:e.gradient}):null}function Uu(e,t){let{props:i,categories:r,theme:o,size:n,hasTitle:a}=t,s=i.legendPosition||"right",l={...e},c={theme:o,position:s,size:n,hasTitle:a,legendLayout:i.legendLayout,axisChrome:i.axisChrome,minimumMargin:qu(i,s)};if(void 0!==i.legend&&null!==i.legend){let t=Xu(i,r,o);null!=t&&!1!==t&&vu(e,{...c,legend:t})}else i.showLegend&&r.length>0&&bu(e,{...c,categories:r,colorScheme:i.colorScheme});return rt(e,l,n,s),s}function Zu(e){let{props:t,categories:i,theme:r,size:o,margin:n,hasTitle:a}=e,s=t.legendPosition||"right",l={theme:r,position:s,size:o,margin:n,hasTitle:a,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix};if(void 0!==t.legend&&null!==t.legend){let e=Xu(t,i,r);return wu.isValidElement(e)?yu(e,o,n,s,t.legendLayout,t.axisChrome):Hu(e,l)||(Ke(e)||Je(e)?null:yu(e??null,o,n,s,t.legendLayout,t.axisChrome))}return t.showLegend&&0!==i.length?Xl({categories:i,colorScheme:t.colorScheme,theme:r,position:s,totalWidth:o[0],totalHeight:o[1],margin:n,hasTitle:a,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix}):null}function Qu(e,t,i,r,o,n){let a=e.scales;if(!a||"radial"===a.projection)return null;let{grid:s}=fr(i),l=r?`${r}-`:"",c="vertical"===a.projection,u=n??Pu(a.r,5,o);/* @__PURE__ */
102
- return Bu("g",c?{id:`${l}grid`,className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{let r=a.r(e);/* @__PURE__ */
103
- return Bu("line",{x1:0,y1:r,x2:t.width,y2:r,stroke:s,strokeWidth:.5},`gr-${i}`)})}:{id:`${l}grid`,className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{let r=a.r(e);/* @__PURE__ */
104
- return Bu("line",{x1:r,y1:0,x2:r,y2:t.height,stroke:s,strokeWidth:.5},`gr-${i}`)})})}function Ku(e,t){let i=fr(t.theme),r=t.background??i.background,o=t.idPrefix?`${t.idPrefix}-`:"",n="string"==typeof t.title?t.title:void 0,a=t.idPrefix?xu(t.idPrefix):{titleId:"semiotic-title",descId:"semiotic-desc"},s=n?a.titleId:void 0,l=t.description?a.descId:void 0,c=[s,l].filter(Boolean).join(" ")||void 0;/* @__PURE__ */
105
- return Yu("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":c,style:{fontFamily:i.fontFamily},children:[n&&/* @__PURE__ */Bu("title",{id:s,children:n}),t.description&&/* @__PURE__ */Bu("desc",{id:l,children:t.description}),t.defs&&/* @__PURE__ */Bu("defs",{children:t.defs}),r&&"transparent"!==r&&/* @__PURE__ */Bu("rect",{x:0,y:0,width:t.width,height:t.height,fill:r}),
106
- /* @__PURE__ */Bu("g",{id:`${o}data-area`,transform:t.innerTransform,children:e}),n&&/* @__PURE__ */Bu("text",{id:`${o}chart-title`,x:t.width/2,y:22,textAnchor:"middle",fontSize:i.titleFontSize,fontWeight:i.titleFontWeight,fill:i.text,fontFamily:i.titleFontFamily,children:n}),t.legend&&/* @__PURE__ */Bu("g",{id:`${o}legend`,children:t.legend}),t.outerElements]})}function Ju(e,t,i,r,o,n,a,s=!1){let l=fr(r),c=i.legendPosition??"right",u=st(i.legendLayout,a?.leftAxis),d=st(i.legendLayout,a?.rightAxis),h=s&&"left"===c&&u>0?u:n?.left??i.margin?.left??40,f=s&&"right"===c&&d>0?d:n?.right??i.margin?.right??40,{xAxis:p,yAxis:g,xOrient:m,yOrient:y}=Ue(i.axes),x="top"===m?0:t.height,b="right"===y?t.width:0,v="top"===m?-1:1,w="right"===y?1:-1,k=Wu({scale:e.x,axis:p,size:t.width,horizontal:!0,format:i.xFormat||i.tickFormatTime,axisExtent:i.axisExtent}),A=Wu({scale:e.y,axis:g,size:t.height,format:i.yFormat||i.tickFormatValue,axisExtent:i.axisExtent}),S=!(!p?.autoRotate||!ju(k)),M=Su(k),$=Su(A),_=p?.label??i.xLabel,L=g?.label??("right"===y?i.yLabelRight??i.yLabel:i.yLabel),P=$u(p?.axisStyle,{stroke:l.border,strokeWidth:1}),I=$u(g?.axisStyle,{stroke:l.border,strokeWidth:1}),R="right"===y?t.width+f-15:15-h;/* @__PURE__ */
107
- return Yu("g",{id:(o?`${o}-`:"")+"axes",className:"stream-axes",children:[!1!==p?.visible&&/* @__PURE__ */Yu("g",{className:`semiotic-axis semiotic-axis-${m}`,"data-orient":m,children:[!1!==p?.baseline&&!p?.jaggedBase&&/* @__PURE__ */Bu("line",{x1:0,y1:x,x2:t.width,y2:x,...P}),p?.jaggedBase&&/* @__PURE__ */Bu("path",{d:_u(m,t.width,t.height),fill:"none",...P}),k.map((e,t)=>{let i=Fu(p?.landmarkTicks,e,t,k);/* @__PURE__ */
108
- return Yu("g",{transform:`translate(${e.pixel},${x})`,children:[
109
- /* @__PURE__ */Bu("line",{y2:5*v,...P}),Ru(e.label)?/* @__PURE__ */Bu("text",{y:v*(S?12:18),textAnchor:S?"end":ku(p?.tickAnchor,e.pixel===M.min,e.pixel===M.max),fontWeight:i?600:400,fontSize:i?l.tickSize+1:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily,transform:S?"top"===m?"rotate(45)":"rotate(-45)":void 0,children:e.label}):Tu({label:e.label,x:-30,y:"top"===m?-30:6,textAlign:"center",fontSize:l.tickSize,fontFamily:l.fontFamily,color:l.textSecondary})]},`xtick-${t}`)}),_&&/* @__PURE__ */Bu("text",{x:t.width/2,y:"top"===m?-(S?58:40):t.height+(S?58:40),textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,children:_})]}),!1!==g?.visible&&/* @__PURE__ */Yu("g",{className:`semiotic-axis semiotic-axis-${y}`,"data-orient":y,children:[!1!==g?.baseline&&!g?.jaggedBase&&/* @__PURE__ */Bu("line",{x1:b,y1:0,x2:b,y2:t.height,...I}),g?.jaggedBase&&/* @__PURE__ */Bu("path",{d:_u(y,t.width,t.height),fill:"none",...I}),A.map((e,t)=>{let i=Fu(g?.landmarkTicks,e,t,A);/* @__PURE__ */
110
- return Yu("g",{transform:`translate(${b},${e.pixel})`,children:[
111
- /* @__PURE__ */Bu("line",{x2:5*w,...I}),Ru(e.label)?/* @__PURE__ */Bu("text",{x:8*w,textAnchor:"right"===y?"start":"end",dominantBaseline:Au(g?.tickAnchor,e.pixel===$.min,e.pixel===$.max),fontWeight:i?600:400,fontSize:i?l.tickSize+1:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:e.label}):Tu({label:e.label,x:"right"===y?8:-68,y:-12,textAlign:"right"===y?"left":"right",fontSize:l.tickSize,fontFamily:l.fontFamily,color:l.textSecondary})]},`ytick-${t}`)}),L&&/* @__PURE__ */Bu("text",{x:R,y:t.height/2,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,transform:`rotate(${"right"===y?90:-90}, ${R}, ${t.height/2})`,children:L})]})]})}import{jsx as ed,jsxs as td}from"react/jsx-runtime";function id(e,t,i,r,o,n,a){let{grid:s}=fr(i),l=r?`${r}-`:"",c=n?.find(e=>"bottom"===e.orient),u=n?.find(e=>"top"===e.orient),d=n?.find(e=>"left"===e.orient),h=n?.find(e=>"right"===e.orient),f=c??u,p=d??h,g=Wu({scale:e.x,axis:f,size:t.width,horizontal:!0,format:a?.xFormat||a?.tickFormatTime,axisExtent:o}),m=Wu({scale:e.y,axis:p,size:t.height,format:a?.yFormat||a?.tickFormatValue,axisExtent:o}),y=!1!==f?.grid,x=!1!==p?.grid,b=Mu(f?.gridStyle),v=Mu(p?.gridStyle),w=$u(f?.gridStyle,{stroke:s,strokeWidth:.5}),k=$u(p?.gridStyle,{stroke:s,strokeWidth:.5});/* @__PURE__ */
112
- return td("g",{id:`${l}grid`,className:"semiotic-grid",opacity:.8,children:[y&&g.map((e,i)=>/* @__PURE__ */ed("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:t.height,...w,strokeDasharray:b??w.strokeDasharray},`gx-${i}`)),x&&m.map((e,i)=>/* @__PURE__ */ed("line",{x1:0,y1:e.pixel,x2:t.width,y2:e.pixel,...k,strokeDasharray:v??k.strokeDasharray},`gy-${i}`))]})}import*as rd from"react";import{jsx as od,jsxs as nd}from"react/jsx-runtime";function ad(e){return"under"===e.layer&&("band"===e.type||"x-band"===e.type)}function sd(e,t,i,r){let o="band"===e.type,n=o?t.y:t.x;if("function"!=typeof n)return null;let a=n.domain?.(),s=n((o?e.y0:e.x0)??a?.[0]),l=n((o?e.y1:e.x1)??a?.[1]);if(!Number.isFinite(s)||!Number.isFinite(l))return null;let c=o?r:i,u=Math.min(c,Math.max(0,Math.min(s,l))),d=Math.max(0,Math.min(c,Math.max(s,l))-u);return o?{x:0,y:u,width:i,height:d}:{x:u,y:0,width:d,height:r}}function ld(e){return"band"===e.type?"vertical":"horizontal"}function cd(e,t="under-band",i="var(--semiotic-primary, #6366f1)"){return(r,o,n)=>e.map((e,r)=>{let a=sd(e,o,n.width,n.height);if(!a)return null;let s=Cc(e,`${t}-${r}`,ld(e),i);/* @__PURE__ */
113
- return nd("g",{opacity:e.opacity,children:[s.def&&/* @__PURE__ */od("defs",{children:s.def}),
114
- /* @__PURE__ */od("rect",{...a,fill:s.fill,fillOpacity:e.fillOpacity??.1})]},`${t}-${r}`)})}function ud(e,t){if(!t||0===e.length||!e.some(e=>null!=e&&"object"==typeof e&&Array.isArray(e[t])))return e;let i=[];for(let r of e){if(null==r||"object"!=typeof r)continue;let e=r[t];if(!Array.isArray(e))continue;let o=r.label??r.id??r.key;for(let t of e)null==t||"object"!=typeof t||i.push(null==o?t:{...t,_lineGroup:o})}return i}function dd(e,t,i,r){return"function"==typeof e?e({size:t,margin:i,scales:r}):e}var hd={top:50,right:40,bottom:60,left:70},fd={top:20,right:80,bottom:20,left:80},pd={top:40,right:40,bottom:40,left:40},gd=/* @__PURE__ */new Set(["chord","force","circlepack","orbit"]);function md(e){return gd.has(e)?pd:fd}import{jsx as yd,jsxs as xd}from"react/jsx-runtime";function bd(e){let{scales:t,layout:i,props:r,theme:o,leftAxis:n,rightAxis:a,margin:s,axisChrome:l,hasRenderedLegend:c}=e;if(!n||!a||!1===a.visible)return null;let u=fr(o),d=Wu({scale:t.y,axis:a,size:i.height,format:r.yFormat||r.tickFormatValue,axisExtent:r.axisExtent}),h=Su(d),f=a.label??r.yLabelRight,p=$u(a.axisStyle,{stroke:u.border,strokeWidth:1}),g=r.legendPosition??"right",m=st(r.legendLayout,l?.rightAxis),y=c&&"right"===g&&m>0?m:s.right,x=i.width+y-15;/* @__PURE__ */
115
- return xd("g",{className:"stream-axes semiotic-axis semiotic-axis-right","data-orient":"right",children:[!1!==a.baseline&&!a.jaggedBase&&/* @__PURE__ */yd("line",{x1:i.width,y1:0,x2:i.width,y2:i.height,...p}),a.jaggedBase&&/* @__PURE__ */yd("path",{d:_u("right",i.width,i.height),fill:"none",...p}),d.map((e,t)=>{let r=Fu(a.landmarkTicks,e,t,d);/* @__PURE__ */
116
- return xd("g",{transform:`translate(${i.width},${e.pixel})`,children:[
117
- /* @__PURE__ */yd("line",{x2:5,...p}),Ru(e.label)?/* @__PURE__ */yd("text",{x:8,textAnchor:"start",dominantBaseline:Au(a.tickAnchor,e.pixel===h.min,e.pixel===h.max),fontWeight:r?600:400,fontSize:r?u.tickSize+1:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):Tu({label:e.label,x:8,y:-12,textAlign:"left",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},`ytick-r-${t}`)}),f&&/* @__PURE__ */yd("text",{x:x,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(90, ${x}, ${i.height/2})`,children:f})]})}import{Fragment as vd,jsx as wd,jsxs as kd}from"react/jsx-runtime";function Ad(e,t){let i=hr(e.theme),r=hd,o=e.size||[500,300],n=it({...r,...e.margin},e.title),a=et(e.title),s=ud(li(e.data),e.lineDataAccessor),l=e.showLegend?Hl(s,e.colorAccessor||e.groupAccessor||e.categoryAccessor):[],c=ht({showAxes:e.showAxes,xLabel:e.xLabel,yLabel:e.yLabel,yLabelRight:e.yLabelRight,axes:e.axes});Uu(n,{props:{...e,axisChrome:c},categories:l,theme:i,size:o,hasTitle:a});let u=Zu({props:{...e,axisChrome:c},categories:l,theme:i,size:o,margin:n,hasTitle:a}),d=Math.max(1,o[0]-n.left-n.right),h=Math.max(1,o[1]-n.top-n.bottom),f="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),p=e.colorScheme||i.colors.categorical,m=(e.axes?.find(e=>"left"===e.orient)??e.axes?.find(e=>"right"===e.orient))?.extent??e.axisExtent,y={chartType:e.chartType,runtimeMode:f?"streaming":"bounded",windowSize:e.windowSize??e.capacity??200,windowMode:e.windowMode??e.capacityMode??"sliding",arrowOfTime:f?e.arrowOfTime??"right":"right",extentPadding:e.extentPadding??.1,xAccessor:e.xAccessor,yAccessor:e.yAccessor,timeAccessor:f?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,groupAccessor:e.groupAccessor||(e.lineDataAccessor?"_lineGroup":void 0),categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,invertY:e.invertY,axisExtent:e.axisExtent,yAxisExtent:m,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,baseline:e.baseline,stackOrder:e.stackOrder,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,band:e.band,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:Ji(e.gradientFill),lineGradient:er(e.lineGradient),semanticLineStops:e.semanticLineStops,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,barStyle:e.barStyle,waterfallStyle:e.waterfallStyle,swarmStyle:e.swarmStyle,colorScheme:p,themeCategorical:i.colors.categorical,themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging,themeSemantic:B(i),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:n,layoutSelection:e.layoutSelection,barColors:e.barColors,showValues:e.showValues,heatmapValueFormat:e.heatmapValueFormat,heatmapColorScale:e.heatmapColorScale,heatmapAggregation:e.heatmapAggregation,heatmapXBins:e.heatmapXBins,heatmapYBins:e.heatmapYBins,pointIdAccessor:e.pointIdAccessor,onLayoutError:e.onLayoutError},x=new rs(y);e.data&&x.ingest({inserts:s,bounded:!0}),x.computeScene({width:d,height:h});let b=dd(e.backgroundGraphics,o,n,x.scales),v=dd(e.foregroundGraphics,o,n,x.scales),w=yr(e.annotations),k=w?`${e.description||e.title||"Line chart."}${w}`:e.description;if(!x.scales){let r,a=e.annotations?pu({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{},layout:{width:d,height:h},theme:i,idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;t&&(t.evidence=_s({frameType:"xy",width:o[0],height:o[1],marks:[],title:e.title,description:k,annotations:e.annotations,annotationRender:r,extraWarnings:x.scales?[]:["NO_SCALES"],margin:n}));let l=b||v||e.annotations?/* @__PURE__ */kd(vd,{children:[b,a,v]}):null;return bn.renderToStaticMarkup(Ku(l,{width:o[0],height:o[1],className:"stream-xy-frame"+(e.className?` ${e.className}`:""),title:e.title,description:k,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:d,innerHeight:h,legend:u,idPrefix:e._idPrefix}))}let A,S=e._idPrefix,M=Rl({nodes:x.scene,renderMode:e.renderMode,fallback:(t,i)=>Al(t,i,S,e.hoverRadius??30)}),$=!x.xIsDate||e.xFormat||e.tickFormatTime?e:{...e,xFormat:yo(x.scales.x.domain().map(e=>e.valueOf()))},_=e.showGrid?id(x.scales,{width:d,height:h},i,S,e.axisExtent,e.axes,$):null,L=M.map(e=>e.element),P=`${Gu(e)}-plot-clip`,I=!1!==e.showAxes,R=I?Ju(x.scales,{width:d,height:h},$,i,S,n,c,!!u):null,T=I?bd({scales:x.scales,layout:{width:d,height:h},props:e,theme:i,leftAxis:e.axes?.find(e=>"left"===e.orient),rightAxis:e.axes?.find(e=>"right"===e.orient),margin:n,axisChrome:c,hasRenderedLegend:!!u}):null,C=e.annotations?pu({annotations:e.annotations,margin:n,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{x:x.scales.x,y:x.scales.y},layout:{width:d,height:h},theme:i,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:S,underLayerBands:!0,onRender:e=>{A=e}}):null;t&&(t.evidence=_s({frameType:"xy",width:o[0],height:o[1],marks:M.map(e=>e.node),title:e.title,description:k,annotations:e.annotations,annotationRender:A,xDomain:$s(x.scales.x?.domain?.()),yDomain:$s(x.scales.y?.domain?.()),legendItems:l.length>0?l.length:void 0,margin:n}));let N=e.svgPreRenderers&&x.scales?e.svgPreRenderers.map((e,t)=>{try{/* @__PURE__ */
118
- return wd(xn.Fragment,{children:e(x.scene,x.scales,{width:d,height:h})},`pre-${t}`)}catch{return null}}).filter(Boolean):null,F=g(e.annotations??[]).filter(ad),z=F.length>0?cd(F,`${Gu(e)}-under-band`,i.colors.primary||i.colors.annotation||i.colors.text)(x.scene,x.scales,{width:d,height:h}):null,E=/* @__PURE__ */kd(vd,{children:[b,N,_,
119
- /* @__PURE__ */wd("defs",{children:/* @__PURE__ */wd("clipPath",{id:P,children:/* @__PURE__ */wd("rect",{x:0,y:0,width:d,height:h})})}),
120
- /* @__PURE__ */kd("g",{clipPath:`url(#${P})`,children:[z,L]}),R,T,C,v,x.customLayoutOverlays]});return bn.renderToStaticMarkup(Ku(E,{width:o[0],height:o[1],className:"stream-xy-frame"+(e.className?` ${e.className}`:""),title:e.title,description:k,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:d,innerHeight:h,legend:u,idPrefix:e._idPrefix}))}ks();import*as Sd from"react-dom/server";import{jsx as Md,jsxs as $d}from"react/jsx-runtime";function _d(e,t){return t.completed.has(e.id)?"var(--semiotic-success, #2b8a66)":t.blockers.has(e.id)?"var(--semiotic-error, #c64035)":"in-progress"===e.status?"var(--semiotic-warning, #d18a22)":t.armed.has(e.id)?"var(--semiotic-primary, #2474a6)":"var(--semiotic-text-secondary, #75818a)"}function Ld({machine:e,layout:t,runtime:i,downstreamSet:r,selectedSet:o,width:n,height:a,seed:s,reduced:l,onSelectTask:c}){let u=t.tasks.length?t.tasks.reduce((e,t)=>Math.min(e,t.y-t.height/2),1/0):60,d=Math.max(20,u-12),h=Math.max(26,u-6);/* @__PURE__ */
121
- return $d("svg",{"aria-hidden":"true",width:n,height:a,viewBox:`0 0 ${n} ${a}`,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none"},children:[
122
- /* @__PURE__ */Md("defs",{children:/* @__PURE__ */Md("filter",{id:`chain-shadow-${s}`,x:"-20%",y:"-20%",width:"140%",height:"150%",children:/* @__PURE__ */Md("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodOpacity:"0.2"})})}),e.lanes.map((e,i)=>{let r=t.tasks.filter(e=>e.laneIndex===i)[0]?.x??0;/* @__PURE__ */
123
- return $d("g",{children:[
124
- /* @__PURE__ */Md("line",{x1:r,x2:r,y1:h,y2:a-24,stroke:"var(--semiotic-grid, #d7dde0)",strokeWidth:1,strokeDasharray:"3 7"}),
125
- /* @__PURE__ */Md("text",{x:r,y:d,textAnchor:"middle",fontSize:12,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e})]},e)}),t.routes.map(e=>{let t=i.delivered.has(e.edgeID),o=i.inFlight.has(e.edgeID),n=r.has(e.targetID)||r.has(e.sourceID),a=e.points.map(e=>`${e.x},${e.y}`).join(" ");/* @__PURE__ */
126
- return Md("polyline",{points:a,fill:"none",stroke:n?"var(--semiotic-selection-color, #e08a1e)":t?"var(--semiotic-success, #2b8a66)":"var(--semiotic-grid, #aeb8bd)",strokeWidth:n?4:o?3:2,strokeOpacity:t||o||n?.95:.48,strokeLinecap:"round",strokeLinejoin:"round"},e.edgeID)}),t.sockets.map(e=>{let t=i.delivered.has(e.edgeID);/* @__PURE__ */
127
- return $d("g",{children:[
128
- /* @__PURE__ */Md("circle",{cx:e.x,cy:e.y,r:e.radius+2,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.5}),t&&/* @__PURE__ */Md("circle",{cx:e.x,cy:e.y,r:e.radius-.5,fill:"var(--semiotic-success, #2b8a66)"})]},e.id)}),e.nodes.map(e=>{let n=t.taskByID.get(e.id);if(!n)return null;let a=i.completed.has(e.id),u=i.blockers.has(e.id),d=i.previewTaskID===e.id,h=o.has(e.id)||d,f=r.has(e.id),p=_d(e,i),g=n.x-n.width/2,m=n.y-n.height/2,y=Math.max(2,n.height*e.progress);/* @__PURE__ */
129
- return $d("g",{children:[
130
- /* @__PURE__ */$d("g",{style:{transform:`rotate(${a?76:0}deg)`,transformBox:"fill-box",transformOrigin:"50% 100%",transition:l?"none":"transform 520ms cubic-bezier(.2,.8,.25,1)",filter:"url(#chain-shadow-"+s+")"},children:[
131
- /* @__PURE__ */Md("rect",{x:g,y:m,width:n.width,height:n.height,rx:e.milestone?12:4,fill:"var(--semiotic-bg, #fff)",stroke:h||f?"var(--semiotic-selection-color, #e08a1e)":p,strokeWidth:h?4:f?3:2}),
132
- /* @__PURE__ */Md("rect",{x:g+3,y:m+n.height-y+1,width:n.width-6,height:Math.max(0,y-4),rx:2,fill:p,opacity:a?.86:.46})]}),u&&/* @__PURE__ */$d("g",{opacity:d?.28:1,children:[
133
- /* @__PURE__ */Md("line",{x1:g-8,x2:g+14,y1:n.y+9,y2:n.y-9,stroke:"var(--semiotic-error, #c64035)",strokeWidth:7,strokeLinecap:"round"}),
134
- /* @__PURE__ */Md("circle",{cx:g-8,cy:n.y+9,r:3,fill:"var(--semiotic-error, #c64035)"})]}),
135
- /* @__PURE__ */$d("g",{onPointerDown:()=>c(e.id),style:{cursor:"pointer",pointerEvents:"auto"},children:[
136
- /* @__PURE__ */Md("rect",{x:g,y:m,width:n.width,height:n.height,fill:"transparent"}),
137
- /* @__PURE__ */Md("text",{x:n.x,y:n.y-4,textAnchor:"middle",fontSize:10.5,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e.label.length>24?`${e.label.slice(0,22)}…`:e.label}),
138
- /* @__PURE__ */$d("text",{x:n.x,y:n.y+12,textAnchor:"middle",fontSize:9.5,fill:"var(--semiotic-text-secondary, #5f6b72)",children:[Math.round(100*e.progress),"% · ",a?"done":u?"blocked":i.armed.has(e.id)?"ready":"waiting"]})]})]},e.id)})]})}function Pd(e,t=0){if(e instanceof Date)return e.getTime();let i=Number(e);return Number.isFinite(i)?i:t}function Id(e){if(null==e.completionTime)return null;let t=Pd(e.completionTime,Number.NaN);return Number.isFinite(t)?t:null}function Rd(e,t,i,r){let o=/* @__PURE__ */new Set;for(let n of e.nodes){let a=e.incoming.get(n.id)??[];(r.has(n.id)||!i.has(n.id)&&a.every(e=>t.has(e.id)))&&o.add(n.id)}return o}function Td(e,t,i,r){let o=e.nodes.map(Id).filter(e=>null!=e),n=o.length?o.reduce((e,t)=>Math.min(e,t),1/0)-1:0,a="replay"!==t||r?i:n,s=/* @__PURE__ */new Set,l=/* @__PURE__ */new Map;for(let i of e.nodes){let e=Id(i),r=null!=e&&e<=a,o="done"===i.status&&"replay"!==t;(r||o)&&s.add(i.id),i.blockerReason&&!s.has(i.id)&&l.set(i.id,i.blockerReason)}let c=/* @__PURE__ */new Set;if("replay"!==t||r)for(let t of e.edges)s.has(t.sourceID)&&c.add(t.id);return{currentTime:a,playing:!1,completed:s,delivered:c,inFlight:/* @__PURE__ */new Set,armed:Rd(e,c,l,s),blockers:l,previewTaskID:null}}function Cd(e,t,i){return An(i,e,t)}function Nd(e,t){return e<t?-1:e>t?1:0}function Fd(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function zd(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function Ed(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function Dd(e){let t=[],i=/* @__PURE__ */new Map,r=[],o=/* @__PURE__ */new Set;e.data.forEach((n,a)=>{let s=String(Cd(n,a,e.taskIDAccessor)??"");if(!s)return void t.push({code:"duplicate-task-id",message:`Task row ${a} has an empty id.`,taskIDs:[]});if(i.has(s))return void t.push({code:"duplicate-task-id",message:`Task id "${s}" occurs more than once.`,taskIDs:[s]});let l=String(Cd(n,a,e.laneAccessor)??"Unassigned");o.has(l)||(o.add(l),r.push(l));let c=Cd(n,a,e.dependencyAccessor)??[],u=Array.from(new Set(Array.from(c,e=>String(e)))).sort(Nd),d=Cd(n,a,e.blockerAccessor),h=Cd(n,a,e.statusAccessor)??(d?"blocked":"waiting");i.set(s,{id:s,label:String(Cd(n,a,e.labelAccessor)??s),lane:l,laneIndex:0,level:0,index:a,datum:n,dependencyIDs:u,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:Cd(n,a,e.startAccessor),end:Cd(n,a,e.endAccessor),progress:Ed(Cd(n,a,e.progressAccessor)),status:h,completionTime:Cd(n,a,e.completionTimeAccessor),blockerReason:d||void 0,milestone:!!Cd(n,a,e.milestoneAccessor)})});let n=e.laneOrder?[...e.laneOrder,...r.filter(t=>!e.laneOrder?.includes(t))]:r,a=new Map(n.map((e,t)=>[e,t]));for(let e of i.values())e.laneIndex=a.get(e.lane)??0;let s=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;for(let e of i.keys())s.set(e,[]),l.set(e,[]);let c=[],u=[...i.values()].sort((e,t)=>e.index-t.index);for(let e of u)e.dependencyIDs.forEach((r,o)=>{let n=i.get(r);if(!n)return void t.push({code:"missing-dependency",message:`Task "${e.id}" depends on missing task "${r}".`,taskIDs:[e.id,r]});let a={id:Fd(r,e.id),sourceID:r,targetID:e.id,sourceIndex:n.index,targetIndex:e.index,socketID:zd(e.id,o),socketIndex:o};c.push(a),s.get(e.id)?.push(a),l.get(r)?.push(a),e.incomingEdgeIDs.push(a.id),e.socketIDs.push(a.socketID),n.outgoingEdgeIDs.push(a.id)});for(let e of s.values())e.sort((e,t)=>Nd(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=zd(e.targetID,t)});for(let e of l.values())e.sort((e,t)=>Nd(e.targetID,t.targetID));for(let e of i.values()){let t=s.get(e.id)??[];e.incomingEdgeIDs=t.map(e=>e.id),e.socketIDs=t.map(e=>e.socketID),e.outgoingEdgeIDs=(l.get(e.id)??[]).map(e=>e.id)}let d=/* @__PURE__ */new Map,h=/* @__PURE__ */new Map;for(let e of i.keys())d.set(e,s.get(e)?.length??0),h.set(e,0);let f=[...i.keys()].filter(e=>0===d.get(e)).sort(Nd),p=0;for(;f.length;){let e=f.shift();p+=1;for(let t of l.get(e)??[]){let i=Math.max(h.get(t.targetID)??0,(h.get(e)??0)+1);h.set(t.targetID,i);let r=(d.get(t.targetID)??0)-1;if(d.set(t.targetID,r),0===r){let e=f.findIndex(e=>e>t.targetID);e<0?f.push(t.targetID):f.splice(e,0,t.targetID)}}}if(p!==i.size){let e=[...i.keys()].filter(e=>(d.get(e)??0)>0).sort(Nd);t.push({code:"cycle",message:`Dependency graph contains a cycle involving: ${e.join(", ")}.`,taskIDs:e})}let g=0,m=[...i.values()].sort((e,t)=>e.index-t.index);for(let e of m)e.level=h.get(e.id)??0,g=Math.max(g,e.level);return{nodes:m,edges:c,byID:i,incoming:s,outgoing:l,lanes:n,maxLevel:g,diagnostics:t,valid:0===t.length}}function Od(e){return e.filter((t,i)=>{let r=e[i-1];return!r||r.x!==t.x||r.y!==t.y})}function jd(e,t,i={}){let r=Math.max(240,t.width),o=Math.max(220,t.height),n=t.paddingX??48,a=t.paddingTop??48,s=t.paddingBottom??44,l=Math.max(1,e.lanes.length),c=Math.max(70,(r-2*n)/l),u=Math.max(1,e.maxLevel+1),d=Math.max(76,(o-a-s)/u),h=Math.min(i.taskWidth??112,Math.max(58,.78*c)),f=Math.min(i.taskHeight??58,.64*d),p=i.socketRadius??5,g=Math.max(1,Math.round(i.gutterCount??3)),m=/* @__PURE__ */new Map;for(let t of e.nodes){let e=`${t.laneIndex}:${t.level}`,i=m.get(e)??[];i.push(t),m.set(e,i)}for(let e of m.values())e.sort((e,t)=>Nd(e.id,t.id));let y=.86*d,x=e=>e<=1?f:Math.max(22,Math.min(f,(y-4*(e-1))/e)),b=e.nodes.map(e=>{let t=m.get(`${e.laneIndex}:${e.level}`)??[e],i=Math.max(0,t.findIndex(t=>t.id===e.id))-(t.length-1)/2,r=x(t.length),o=i*(r+4);return{taskID:e.id,lane:e.lane,laneIndex:e.laneIndex,level:e.level,x:n+c*(e.laneIndex+.5),y:a+d*(e.level+.5)+o,width:h,height:r}}),v=new Map(b.map(e=>[e.taskID,e])),w=[],k=[];e.edges.forEach((t,i)=>{let r=v.get(t.sourceID),o=v.get(t.targetID);if(!r||!o)return;let n=e.incoming.get(t.targetID)??[],a=Math.min(.72*o.width,14*Math.max(1,n.length-1)),s=n.length<=1?o.x:o.x-a/2+a*t.socketIndex/(n.length-1),l=o.y-o.height/2-p-2,c={id:t.socketID,edgeID:t.id,taskID:o.taskID,index:t.socketIndex,x:s,y:l,radius:p};w.push(c);let u={x:r.x,y:r.y+r.height/2+3},d=Math.max(18,l-u.y),h=7*(i%g-(g-1)/2),f=Math.min(l-10,u.y+.48*d+h);k.push({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,socketID:t.socketID,points:Od([u,{x:u.x,y:f},{x:s,y:f},{x:s,y:l}])})});let A=new Map(w.map(e=>[e.id,e])),S=new Map(k.map(e=>[e.edgeID,e]));return{tasks:b,sockets:w,routes:k,taskByID:v,socketByID:A,routeByEdgeID:S}}function Wd(e,t,i={}){let r=new Set(i.completedTaskIDs??[]),o=Me(e.nodes,e.edges.map(e=>({source:e.sourceID,target:e.targetID}))),n=[..._e(o,t)].map(t=>e.byID.get(t)).filter(e=>null!=e).filter(e=>!(i.isComplete?i.isComplete(e):r.has(e.id)||"done"===e.status)).sort((e,t)=>e.index-t.index),a=Array.from(new Set(n.map(e=>e.lane)));return{blockerID:t,downstreamTaskCount:n.length,affectedLaneCount:a.length,downstreamTaskIDs:n.map(e=>e.id),affectedLanes:a}}import{jsx as Bd,jsxs as Yd}from"react/jsx-runtime";function Gd(e){return e.__composite}function Xd(e){return Array.isArray(e)?e.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[]}function Vd(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function qd(e,t,i){let r="string"==typeof i?i:"Tasks are arranged by workstream and dependency depth. Completed tasks deliver their authored prerequisites; task completion remains an explicit data event.",o=[...t.blockers.keys()].map(i=>{let r=Wd(e,i,{completedTaskIDs:t.completed});return`${e.byID.get(i)?.label??i} affects ${r.downstreamTaskCount} unfinished tasks across ${r.affectedLaneCount} lanes.`}).join(" ");return o?`${r} ${o}`:`${r} No explicit blockers are active.`}import*as Hd from"react-dom/server";var Ud=e=>Math.max(6,Math.round(2*e/3));function Zd(e){let t=e.handles&&"object"==typeof e.handles?e.handles:e.handles?{}:null,i="number"==typeof t?.size&&Number.isFinite(t.size)?t.size:12;return{top:t?.move?Math.ceil(Ud(i)/2)+2:0,bottom:e.showExtentLabels?34:20}}function Qd(e,t){let i=e.colors.selection??e.colors.primary;return{fill:i,fillOpacity:t,stroke:i,strokeWidth:1}}var Kd=(e,t,i)=>Math.min(i,Math.max(t,e)),Jd=e=>Number(e.toPrecision(15));function eh({domain:e,scale:t,orientation:i,reverse:r=!1}){if(t){let e=t.range().map(Number),i=t.domain().map(Number),r=Math.min(e[0],e[e.length-1]),o=Math.max(e[0],e[e.length-1])-r,n=Math.min(i[0],i[i.length-1]),a=Math.max(i[0],i[i.length-1]);if(![r,o,n,a].every(Number.isFinite)||o<=0||a<=n)return null;let s=Math.abs(t(n)-r)<=Math.abs(t(a)-r);return{min:n,max:a,toFraction:e=>(t(e)-r)/o,fromFraction:e=>e<=0?s?n:a:e>=1?s?a:n:Kd(Jd(Number(t.invert(r+e*o))),n,a)}}if(!e)return null;let o=Math.min(Number(e[0]),Number(e[1])),n=Math.max(Number(e[0]),Number(e[1]));if(!Number.isFinite(o)||!Number.isFinite(n)||n<=o)return null;let a=n-o,s="x"===i?!r:r;return{min:o,max:n,toFraction:e=>{let t=(e-o)/a;return s?t:1-t},fromFraction:e=>e<=0?s?o:n:e>=1?s?n:o:Jd(s?o+e*a:n-e*a)}}function th(e,t){if(!e||e.length<2)return null;let i=Number(e[0]),r=Number(e[1]);return Number.isFinite(i)&&Number.isFinite(r)?[Kd(Math.min(i,r),t.min,t.max),Kd(Math.max(i,r),t.min,t.max)]:null}function ih(e){if(!Number.isFinite(e))return"";let t=Math.round(100*e)/100;return String(Object.is(t,-0)?0:t)}function rh(e,t,i,r=1.2*i,o){return"y"===t?e.length*r:o??Math.max(0,...e.map(e=>Array.from(e).length))*i*.6}function oh(e){let{value:t,track:i,length:r,orientation:o,format:n,fontSize:a,labelWidth:s,showDomainLabels:l}=e,c=e.lineHeight??1.2*a,u=e.gap??6,[d,h]=e.bounds??[0,r],f=(e,t,r=i.toFraction(t))=>{let l=n(t),u=l.split("\n");return{kind:e,value:t,text:l,lines:u,fraction:r,size:rh(u,o,a,c,s)}},p=(e,t)=>{let i=e.fraction*r,o=t;"before"===o&&i-e.size<d?o="after":"after"===o&&i+e.size>h&&(o="before");let n="before"===o?i-e.size:i;return{...e,placement:o,row:0,from:n,to:n+e.size}},g=f("start",t[0]),m=f("end",t[1]),[y,x]=g.fraction<=m.fraction?[g,m]:[m,g],b=p(y,"before"),v=p(x,"after");b.to+u>v.from&&(v.row=1);let w=[b,v];if(!l)return w;let k=w.filter(e=>0===e.row),A=e=>{let t=i.fromFraction(e),o=f(t===i.min?"domain-start":"domain-end",t,e),n=0===e?0:r-o.size;return{...o,placement:0===e?"after":"before",row:0,from:n,to:n+o.size}};return[...[A(0),A(1)].filter(e=>e.from>=d&&e.to<=h&&k.every(t=>e.to+u<=t.from||t.to+u<=e.from)),...w]}function nh(e){return e.__composite}function ah(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function sh(e,t,i,r){return e.replace(/^<svg\b/,`<svg x="${t}" y="${i}" data-semiotic-composite-part="${r}"`)}function lh(e,t){for(let i of e){let e=i?.[t];if(Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1])return e}}import{jsx as ch,jsxs as uh}from"react/jsx-runtime";var dh=e=>!0===e?{}:e&&"object"==typeof e?e:null,hh=e=>"string"==typeof e?e:void 0;function fh(e){return t=>{try{let i="function"==typeof e?e(t):void 0;return"string"==typeof i?i:ih(t)}catch{return ih(t)}}}function ph(e,t,i,r,o,n,a){let s=[.35,.65].map(e=>"x"===a?{x1:t-r/2+r*e,x2:t-r/2+r*e,y1:i-.2*o,y2:i+.2*o}:{x1:t-.2*r,x2:t+.2*r,y1:i-o/2+o*e,y2:i-o/2+o*e});/* @__PURE__ */
139
- return uh("g",{className:"semiotic-brush-handle","data-semiotic-brush-part":e,children:[
140
- /* @__PURE__ */ch("rect",{x:t-r/2+.5,y:i-o/2+.5,width:r-1,height:o-1,rx:n.radius,fill:n.fill,stroke:n.stroke,strokeWidth:1}),s.map((e,t)=>/* @__PURE__ */ch("line",{...e,stroke:n.grip,strokeWidth:1},t))]},e)}function gh(e){let{theme:t,config:i,direction:r,plot:o,margin:n}=e,a=eh({domain:e.domain,orientation:r});if(!a)return null;let s=dh(i.handles),l=th(e.extent,a)??(s?[a.min,a.max]:null);if(!l)return null;let c=dh(i.brushStyle)??{},u=Qd(t,.2),d=t.colors.surface??t.colors.background,h="x"===r?o.width:o.height,[f,p]=[a.toFraction(l[0]),a.toFraction(l[1])].sort((e,t)=>e-t),g=(e,t)=>"x"===r?{x:o.x+e*h,y:o.y,width:(t-e)*h,height:o.height}:{x:o.x,y:o.y+e*h,width:o.width,height:(t-e)*h},m=[],y=dh(c.mask);if(y)for(let[e,t]of[[0,f],[p,1]])m.push(/* @__PURE__ */ch("rect",{className:"semiotic-brush-mask","data-semiotic-brush-part":"mask",...g(e,t),fill:hh(y.fill)??d,opacity:ah(y.opacity,.6)},`mask-${e}`));let x=ah(c.strokeWidth,1),b=g(f,p);if(m.push(
141
- /* @__PURE__ */ch("rect",{className:"selection","data-semiotic-brush-part":"selection",x:b.x+x/2,y:b.y+x/2,width:Math.max(0,b.width-x),height:Math.max(0,b.height-x),fill:hh(c.fill)??u.fill,fillOpacity:ah(c.fillOpacity,.2),stroke:hh(c.stroke)??u.stroke,strokeWidth:x},"selection")),s){let e=ah(s.size,12),t=Ud(e),i={fill:hh(s.fill)??d,stroke:hh(s.stroke)??u.stroke,grip:u.stroke,radius:ah(s.radius,3)};for(let[n,a]of[["start",f],["end",p]])m.push("x"===r?ph(n,o.x+a*h,o.y+o.height/2,t,2*e,i,"x"):ph(n,o.x+o.width/2,o.y+a*h,2*e,t,i,"y"));if(s.move){let n=(f+p)/2;m.push("x"===r?ph("move",o.x+n*h,o.y,2*e,t,i,"x"):ph("move",o.x,o.y+n*h,t,2*e,i,"y"))}}if(i.showExtentLabels){let s=oh({value:l,track:a,length:h,orientation:r,format:fh(i.extentLabelFormat??e.axisFormat),fontSize:11,bounds:"x"===r?[-n.left,o.width+n.right]:[-n.top,o.height+n.bottom]}),c=13.2*Math.max(1,...s.map(e=>e.lines.length));for(let e of s){let i="before"===e.placement,n="x"===r?o.x+e.fraction*h:o.x+o.width+4,a="x"===r?o.y+o.height+4+e.row*c:o.y+e.from;m.push(
142
- /* @__PURE__ */ch("text",{className:"semiotic-brush-label","data-semiotic-brush-label":e.kind,x:n,y:a+10.45,fill:t.colors.textSecondary,fontFamily:t.typography.fontFamily,fontSize:11,textAnchor:"x"===r&&i?"end":"start",children:e.lines.map((e,t)=>/* @__PURE__ */ch("tspan",{x:n,dy:0===t?0:13.2,children:e},t))},`label-${e.kind}`))}}/* @__PURE__ */
143
- return ch("g",{className:"semiotic-minimap-brush",children:m})}import{jsx as mh,jsxs as yh}from"react/jsx-runtime";import{jsx as xh,jsxs as bh}from"react/jsx-runtime";var vh={top:4,bottom:4,left:4,right:4};function wh(e,t,i,r,o){return{__composite:{data:e,colorBy:t,colorScheme:i,common:r,rest:o}}}function kh(e){return Array.isArray(e)?e.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[]}function Ah(e,t){return Math.max(1,Math.floor(ah(e,t)))}var Sh={frameType:"xy",buildProps:wh,renderStatic:function(e,t){let{data:i,colorBy:r,colorScheme:o,common:n,rest:a}=nh(e),[s,l]=n.size??[600,400],c=a.minimap&&"object"==typeof a.minimap?a.minimap:{},u=ah(c.height,60),d=n.margin,h=c.margin&&"object"==typeof c.margin?c.margin:{},f=Zd(c),p={top:ah(h.top,f.top),right:ah(h.right,ah(d?.right,20)),bottom:ah(h.bottom,f.bottom),left:ah(h.left,ah(d?.left,40))},g=u+p.top+p.bottom,m=a.frameProps&&"object"==typeof a.frameProps?a.frameProps:{},y={...a,xAccessor:a.xAccessor||"x",yAccessor:a.yAccessor||"y"},x="y"===c.brushDirection?"y":"x",b={...n,size:[s,l],xExtent:m.xExtent??("x"===x?a.brushExtent:void 0)??n.xExtent,yExtent:m.yExtent??("y"===x?a.brushExtent:void 0)??a.yExtent??n.yExtent,_idPrefix:`${String(n._idPrefix??"minimap")}-detail`},v=an.buildProps(i,r,o,b,y);Object.assign(v,m);let w={...n,size:[s,g],margin:p,title:void 0,description:`${String(n.description??n.title??"Chart")} overview minimap`,showAxes:c.showAxes??!1,showLegend:!1,showGrid:!1,accessibleTable:!1,background:c.background,xExtent:void 0,yExtent:a.yExtent??n.yExtent,_idPrefix:`${String(n._idPrefix??"minimap")}-overview`};delete w.lineStyle,delete w.pointStyle;let k={...y,fillArea:!1,lineWidth:1,showPoints:!1,directLabel:!1,forecast:void 0,anomaly:void 0,band:void 0},A=an.buildProps(i,r,o,w,k);A.chartType=a.fillArea?"area":"line","function"==typeof c.lineStyle&&(A.lineStyle=c.lineStyle);let S={},M={},$=Ad(v,S),_=Ad(A,M),L=!0===a.renderBefore,P=L?0:l,I=[sh($,0,L?g:0,"detail"),sh(_,0,P,"overview")].join(""),R=l+g,T=hr(n.theme),C=fr(T),N="string"==typeof n.title?n.title:void 0,F="string"==typeof n.description?n.description:N||"Chart with overview minimap",z=Gu(n),E=N?`${z}-title`:void 0,D=`${z}-description`,O=Array.isArray(a.brushExtent)&&a.brushExtent.length>=2?[Number(a.brushExtent[0]),Number(a.brushExtent[1])]:null,j="x"===x?M.evidence?.xDomain:M.evidence?.yDomain,W=j?gh({theme:T,config:c,direction:x,domain:j,extent:O&&O.every(Number.isFinite)?O:null,plot:{x:p.left,y:P+p.top,width:Math.max(0,s-p.left-p.right),height:u},margin:p,axisFormat:"x"===x?n.xFormat:n.yFormat}):null,B=Hd.renderToStaticMarkup(
144
- /* @__PURE__ */yh("svg",{xmlns:"http://www.w3.org/2000/svg",className:"minimap-chart",width:s,height:R,role:"img","aria-labelledby":[E,D].filter(Boolean).join(" "),style:{fontFamily:C.fontFamily},children:[N&&/* @__PURE__ */mh("title",{id:E,children:N}),
145
- /* @__PURE__ */mh("desc",{id:D,children:F}),
146
- /* @__PURE__ */mh("g",{dangerouslySetInnerHTML:{__html:I}}),W]}));if(t){let e=[S.evidence,M.evidence];t.evidence=As({frameType:"xy",width:s,height:R,parts:e,title:N,description:F,xDomain:lh(e,"xDomain"),yDomain:lh(e,"yDomain")})}return B}};function Mh(e,t){return String("function"==typeof t?t(e):e[t])}function $h(e,t,i,r){if(!t)return{categories:[],color:()=>Ti};let o=Array.from(new Set(e.map(e=>Mh(e,t)))),n="string"==typeof t?t:"__semioticSplomColor",a=ji("function"==typeof t?e.map(e=>({...e,[n]:Mh(e,t)})):e,n,i??r.colors.categorical);return{categories:o,color:e=>Di(e,t,a)}}function _h(e){let{data:t,field:i,label:r,cellSize:o,bins:n,diagonal:a,colorBy:s,color:l,x:c,y:u}=e;if("label"===a)return{visibleBars:0,svg:yn.renderToStaticMarkup(
147
- /* @__PURE__ */xh("svg",{x:c,y:u,width:o,height:o,"data-semiotic-composite-part":`diagonal-${i}`,children:/* @__PURE__ */xh("text",{x:o/2,y:o/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:r})}))};let d=t.map(e=>Number(e[i])).filter(Number.isFinite),h=d.length?Math.min(...d):0,f=((d.length?Math.max(...d):0)-h)/n||1,p=Array.from({length:n},()=>/* @__PURE__ */new Map);for(let e of t){let t=Number(e[i]);if(!Number.isFinite(t))continue;let r=Math.max(0,Math.min(n-1,Math.floor((t-h)/f))),o=s?Mh(e,s):"__all",a=p[r];a.set(o,[...a.get(o)??[],e])}let g=p.map(e=>Array.from(e.values()).reduce((e,t)=>e+t.length,0)),m=Math.max(1,...g),y=0,x=p.flatMap((e,t)=>{let i=0;return Array.from(e.entries()).flatMap(([e,r])=>{if(0===r.length)return[];y+=1;let a=r.length/m*(o-24),c=i;return i+=a,/* @__PURE__ */xh("rect",{x:t/n*o,y:o-c-a,width:Math.max(o/n-1,1),height:a,fill:s?l(r[0]):Ti,opacity:.6},`${t}-${e}`)})});return{visibleBars:y,svg:yn.renderToStaticMarkup(
148
- /* @__PURE__ */bh("svg",{x:c,y:u,width:o,height:o,"data-semiotic-composite-part":`diagonal-${i}`,children:[
149
- /* @__PURE__ */xh("text",{x:o/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333",children:r}),x]}))}}var Lh={frameType:"physics",layout:{primarySize:{width:920,height:620}},buildProps:wh,renderStatic:function(e,t){let{data:i,common:r,rest:o}=Gd(e),n=Xd(i),[a,s]=r.size??[920,620],l="string"==typeof r.title?r.title:"Dependency chain reaction",c=Dd({data:n,taskIDAccessor:o.taskIDAccessor,labelAccessor:o.labelAccessor,laneAccessor:o.laneAccessor,dependencyAccessor:o.dependencyAccessor,startAccessor:o.startAccessor,endAccessor:o.endAccessor,progressAccessor:o.progressAccessor,statusAccessor:o.statusAccessor,completionTimeAccessor:o.completionTimeAccessor,blockerAccessor:o.blockerAccessor,milestoneAccessor:o.milestoneAccessor}),u=hr(r.theme),d=fr(u),h=Gu(r),f=`${h}-title`,p=`${h}-description`;if(!c.valid){let e=c.diagnostics.map(e=>e.message).join(" "),i=Sd.renderToStaticMarkup(
150
- /* @__PURE__ */Yd("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:a,height:s,role:"img","aria-labelledby":`${f} ${p}`,style:{fontFamily:d.fontFamily},children:[
151
- /* @__PURE__ */Bd("title",{id:f,children:l}),
152
- /* @__PURE__ */Bd("desc",{id:p,children:e}),
153
- /* @__PURE__ */Bd("rect",{width:a,height:s,fill:d.background}),
154
- /* @__PURE__ */Bd("text",{x:24,y:36,fontSize:16,fontWeight:700,fill:d.text,children:l}),c.diagnostics.map((e,t)=>/* @__PURE__ */Bd("text",{x:24,y:72+22*t,fontSize:12,fill:u.colors.error,children:e.message},`${e.code}-${t}`))]}));return t&&(t.evidence=As({frameType:"physics",width:a,height:s,parts:[],title:l,description:e,nodeCount:c.nodes.length,edgeCount:c.edges.length,extraWarnings:["INVALID_DEPENDENCY_GRAPH"]})),i}let g=jd(c,{width:a,height:s}),m=Td(c,"snapshot",Pd(o.currentTime,1/0),!0),y=Array.isArray(o.selectedTaskIDs)?o.selectedTaskIDs.map(String):[],x=new Set(y),b=y[0]??null,v=b&&"none"!==o.insight?Wd(c,b,{completedTaskIDs:m.completed}):null,w=new Set(v?.downstreamTaskIDs??[]),k=Vd(o.seed,31),A=qd(c,m,r.description),S=Sd.renderToStaticMarkup(
155
- /* @__PURE__ */Bd(Ld,{machine:c,layout:g,runtime:m,downstreamSet:w,selectedSet:x,width:a,height:s,seed:k,reduced:!0,onSelectTask:()=>{}})),M=void 0===r.theme?{}:X(u),$=Sd.renderToStaticMarkup(
156
- /* @__PURE__ */Yd("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:a,height:s,role:"img","aria-labelledby":`${f} ${p}`,style:{...M,fontFamily:d.fontFamily},children:[
157
- /* @__PURE__ */Bd("title",{id:f,children:l}),
158
- /* @__PURE__ */Bd("desc",{id:p,children:A}),
159
- /* @__PURE__ */Bd("rect",{width:a,height:s,fill:d.background}),
160
- /* @__PURE__ */Bd("text",{x:a/2,y:22,textAnchor:"middle",fontSize:d.titleFontSize,fontFamily:d.titleFontFamily,fontWeight:d.titleFontWeight,fill:d.text,children:l}),
161
- /* @__PURE__ */Bd("g",{dangerouslySetInnerHTML:{__html:S}})]}));return t&&(t.evidence=As({frameType:"physics",width:a,height:s,parts:[],additionalMarkCountByType:{task:c.nodes.length,dependency:c.edges.length},title:l,description:A,categories:c.lanes,nodeCount:c.nodes.length,edgeCount:c.edges.length})),$}},Ph={LineChart:an,BumpChart:Ho,AreaChart:ln,DifferenceChart:cn,StackedAreaChart:un,Scatterplot:Qr,BubbleChart:eo,Heatmap:mn,QuadrantChart:hn,MultiAxisLineChart:en,WaterfallChart:tn,CandlestickChart:dn,ConnectedScatterplot:fn,ScatterplotMatrix:{frameType:"xy",buildProps:wh,renderStatic:function(e,t){let{data:i,colorBy:r,colorScheme:o,common:n,rest:a}=nh(e),s=kh(i),l=Array.isArray(a.fields)?a.fields.filter(e=>"string"==typeof e):[],c=a.fieldLabels&&"object"==typeof a.fieldLabels?a.fieldLabels:{},u=Ah(a.cellSize,150),d=Math.max(0,ah(a.cellGap,4)),h=Math.max(0,ah(a.pointRadius,2)),f=Math.max(0,Math.min(1,ah(a.pointOpacity,.5))),p=Ah(a.histogramBins,20),g="string"==typeof a.diagonal?a.diagonal:"histogram",m=40+l.length*u+l.length*d,y=l.length*u+40+l.length*d,x=hr(n.theme),b=fr(x),v=$h(s,r,o,x),w=a.showLegend??!!r,k="string"==typeof n.title?n.title:void 0,A="string"==typeof n.description?n.description:`Scatterplot matrix comparing ${l.length} fields`,S=k?28:0,M=w?v.categories:[],$=e=>Math.max(72,30+7*e.length),_=0,L=0,P=M.map(e=>{let t=$(e);_>0&&_+t>m&&(L+=1,_=0);let i={label:e,x:_,y:24*L};return _+=t,i}),I=M.length?24*(L+1)+4:0,R=S+I,T=R+y,C=[],N=[],F=0;l.forEach((e,t)=>{l.forEach((i,o)=>{let l=40+d+o*(u+d),m=R+t*(u+d);if(t===o){let t=_h({data:s,field:e,label:Oi(c,e)??e,cellSize:u,bins:p,diagonal:g,colorBy:r,color:v.color,x:l,y:m});return F+=t.visibleBars,void N.push(t.svg)}let y={},x=Ad({chartType:"scatter",data:s,size:[u,u],xAccessor:i,yAccessor:e,pointStyle:Z(e=>({r:h,opacity:f,fill:v.color(e)}),a.styleRules,q(i,e)),margin:vh,showAxes:!1,showGrid:!1,enableHover:!1,accessibleTable:!1,description:`${Oi(c,i)??i} versus ${Oi(c,e)??e} scatterplot`,theme:n.theme,_idPrefix:`${String(n._idPrefix??"splom")}-${t}-${o}`},y);C.push(y.evidence),N.push(sh(x,l,m,`cell-${e}-${i}`))})});let z=Gu(n),E=k?`${z}-title`:void 0,D=`${z}-description`,O=yn.renderToStaticMarkup(
162
- /* @__PURE__ */bh("svg",{xmlns:"http://www.w3.org/2000/svg",className:"scatterplot-matrix",width:m,height:T,role:"img","aria-labelledby":[E,D].filter(Boolean).join(" "),style:{fontFamily:b.fontFamily},children:[k&&/* @__PURE__ */xh("title",{id:E,children:k}),
163
- /* @__PURE__ */xh("desc",{id:D,children:A}),
164
- /* @__PURE__ */xh("rect",{width:m,height:T,fill:b.background}),k&&/* @__PURE__ */xh("text",{x:0,y:18,fontSize:14,fontWeight:600,fill:b.text,children:k}),P.map(e=>{let t=s.find(t=>r&&Mh(t,r)===e.label),i=t?v.color(t):Ti;/* @__PURE__ */
165
- return bh("g",{transform:`translate(${e.x},${S+e.y})`,children:[
166
- /* @__PURE__ */xh("circle",{cx:5,cy:8,r:5,fill:i}),
167
- /* @__PURE__ */xh("text",{x:14,y:12,fontSize:11,fill:b.text,children:e.label})]},e.label)}),l.map((e,t)=>{let i=R+t*(u+d)+u/2;/* @__PURE__ */
168
- return xh("text",{x:20,y:i,transform:`rotate(-90 20 ${i})`,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:b.text,children:Oi(c,e)??e},`row-${e}`)}),l.map((e,t)=>/* @__PURE__ */xh("text",{x:40+d+t*(u+d)+u/2,y:R+l.length*(u+d)+20,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:b.text,children:Oi(c,e)??e},`column-${e}`)),
169
- /* @__PURE__ */xh("g",{dangerouslySetInnerHTML:{__html:N.join("")}})]}));return t&&(t.evidence=As({frameType:"xy",width:m,height:T,parts:C,additionalMarkCountByType:F>0?{histogram:F}:void 0,title:k,description:A,categories:v.categories.length?v.categories:void 0,legendItems:M.length||void 0})),O}},MinimapChart:Sh},Ih=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;let t=e-this._mean;this._mean+=t/this._count;let i=e-this._mean;this._m2+=t*i,e<this._min&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);let t=this._count+e._count,i=e._mean-this._mean;this._mean+=i*e._count/t,this._m2+=e._m2+i*i*this._count*e._count/t,this._count=t,e._min<this._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){let t=new e;return t.merge(this),t}get count(){return this._count}get mean(){return this._mean}get sum(){return this._mean*this._count}get variance(){return this._count<2?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return this._count<2?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}};function Rh(e){let t=He(e);return t^=t>>>16,t=Math.imul(t,2146121005),t^=t>>>15,t=Math.imul(t,2221713035),t^=t>>>16,t>>>0}var Th=class e{constructor(e=10){let t=Math.max(4,Math.min(16,Math.floor(e)));this.p=t,this.m=1<<t,this.registers=new Uint8Array(this.m),this.alpha=.7213/(1+1.079/this.m),this.harmonicSum=this.m,this.zeros=this.m}add(e){let t=Rh(String(e)),i=t>>>32-this.p,r=Math.min(Math.clz32(t<<this.p),32-this.p)+1;this.updateRegister(i,r)}updateRegister(e,t){let i=this.registers[e];t<=i||(this.registers[e]=t,this.harmonicSum+=2**-t-2**-i,0===i&&this.zeros--)}merge(e){if(e.m===this.m)for(let t=0;t<this.m;t++)this.updateRegister(t,e.registers[t])}clone(){let t=new e(this.p);return t.registers.set(this.registers),t.harmonicSum=this.harmonicSum,t.zeros=this.zeros,t}count(){let e=this.alpha*this.m*this.m/this.harmonicSum;return e<=2.5*this.m&&this.zeros>0?Math.round(this.m*Math.log(this.m/this.zeros)):Math.round(e)}},Ch=class e{constructor(e=100){this.centroids=[],this.total=0,this.pending=0,this.compression=Math.max(20,e)}push(e){Number.isFinite(e)&&(this.centroids.push({mean:e,weight:1}),this.total+=1,this.pending++,this.pending>=2*this.compression&&this.compress())}merge(e){if(0===e.total)return;let t=0===this.total,i=e.centroids.length;for(let t=0;t<i;t++)this.centroids.push({...e.centroids[t]});this.total+=e.total,this.pending=t&&this.compression===e.compression?e.pending:this.pending+i,t||this.compress()}clone(){let t=new e(this.compression);return t.merge(this),t}quantile(e){if(0===this.total||Number.isNaN(e))return Number.NaN;let t=Math.min(1,Math.max(0,e));this.compress();let i=t*this.total,r=this.centroids[0].weight/2;if(i<=r)return this.centroids[0].mean;for(let e=1;e<this.centroids.length;e++){let t=this.centroids[e-1],o=this.centroids[e],n=(t.weight+o.weight)/2,a=r+n;if(i<=a){let e=(i-r)/n;return t.mean+(o.mean-t.mean)*e}r=a}return this.centroids[this.centroids.length-1].mean}get count(){return this.total}compress(){if(0===this.pending||(this.pending=0,this.centroids.length<=1))return;this.centroids.sort((e,t)=>e.mean-t.mean);let e=0,t=0,i=this.total,r=this.compression;for(let o=1;o<this.centroids.length;o++){let n=this.centroids[e],a=this.centroids[o],s=(t+n.weight/2)/i,l=4*i*s*(1-s)/r;if(n.weight+a.weight<=Math.max(1,l)){let e=n.weight+a.weight;n.mean=(n.mean*n.weight+a.mean*a.weight)/e,n.weight=e}else t+=n.weight,this.centroids[++e]=a}this.centroids.length=e+1}};function Nh(e){let t=Math.round(1e3*e)/10;return`p${String(t).replace(".","_")}`}function Fh(e,t,i){let r=e.length;for(e.push(t);r>0;){let o=r-1>>>1;if(i(e[o],t)<=0)break;e[r]=e[o],r=o}e[r]=t}function zh(e,t){let i=e[0],r=e.pop();if(e.length>0){let i=0;for(;2*i+1<e.length;){let o=2*i+1;if(o+1<e.length&&t(e[o+1],e[o])<0&&o++,t(r,e[o])<=0)break;e[i]=e[o],i=o}e[i]=r}return i}var Eh=(e,t)=>e-t,Dh=class{constructor(e,t){this.stats=new Ih,this.digest=e?new Ch:null,this.hll=t?new Th:null}push(e,t){this.stats.push(e),this.digest?.push(e),this.hll&&this.hll.add(t??e)}merge(e){this.stats.merge(e.stats),this.digest?.merge(e.digest),this.hll?.merge(e.hll)}},Oh=class{constructor(e){this.windows=/* @__PURE__ */new Map,this.starts=[],this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;let t=e.hop??e.size;this.hop=t>0&&t<=e.size?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0,this.percentiles=e.percentiles??[],this.wantDistinct=!0===e.distinct}newBucket(){return new Dh(this.percentiles.length>0,this.wantDistinct)}push(e,t,i){!Number.isFinite(e)||!Number.isFinite(t)||(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t,i):this.pushFixed(e,t,i),this.prune())}pushFixed(e,t,i){if("tumbling"===this.type||this.hop>=this.size){let r=Math.floor(e/this.size)*this.size;return void this.bump(r,t,i)}let r=this.hop,o=Math.floor(e/r);for(let n=Math.floor((e-this.size)/r)+1;n<=o;n++)this.bump(n*r,t,i)}bump(e,t,i){let r=this.windows.get(e);if(!r){if(this.windows.size>=this.retain&&e<this.starts[0])return;r=this.newBucket(),this.windows.set(e,r),this.retain!==1/0&&Fh(this.starts,e,Eh)}r.push(t,i)}pushSession(e,t,i){let r=e-this.gap,o=e+this.gap,n=0,a=this.sessions.length,s=this.sessions[a-1];if(!s||e>=s.end)n=a,s&&s.end>=r&&s.start<=o&&n--;else for(;n<a;){let e=n+a>>>1;this.sessions[e].end<r?n=e+1:a=e}let l=this.sessions[n];if(!l||l.start>o){let r=this.newBucket();return r.push(t,i),void this.sessions.splice(n,0,{start:e,end:e,bucket:r})}l.bucket.push(t,i),l.start=Math.min(l.start,e),l.end=Math.max(l.end,e);let c=n+1;for(;c<this.sessions.length&&this.sessions[c].start<=o;){let e=this.sessions[c++];l.bucket.merge(e.bucket),l.end=Math.max(l.end,e.end)}c>n+1&&this.sessions.splice(n+1,c-n-1)}prune(){if(this.retain!==1/0){if("session"===this.type)return void(this.sessions.length>this.retain&&this.sessions.splice(0,this.sessions.length-this.retain));for(;this.windows.size>this.retain;)this.windows.delete(zh(this.starts,Eh))}}emit(){if("session"===this.type)return this.sessions.map(e=>{let t=this.latest-e.end<this.gap;return this.row(e.start,e.end,e.bucket,t)});let e=[];for(let[t,i]of this.windows){let r=t+this.size;e.push(this.row(t,r,i,this.latest<r))}return e.sort((e,t)=>e.start-t.start),e}row(e,t,i,r){let o=i.stats,n={start:e,end:t,count:o.count,mean:o.mean,sum:o.sum,min:o.min,max:o.max,stddev:o.stddev,partial:r};if(i.digest){let e={};for(let t of this.percentiles)e[Nh(t)]=i.digest.quantile(t);n.percentiles=e}return i.hll&&(n.distinct=i.hll.count()),n}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.starts=[],this.sessions=[],this.latest=-1/0}};function jh(e,t){switch(t){case"distinct":return e.distinct??0;case"p50":case"p95":case"p99":return e.percentiles?.[t]??Number.NaN;default:return e[t]??e.mean}}function Wh(e,t,i,r=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];let o=jh(e,i),n=e.stddev*r;return[o-n,o+n]}var Bh={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Yh=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function Gh(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;let t=e.trim();if(""===t)return null;Yh.lastIndex=0;let i,r=0,o=0;for(;null!==(i=Yh.exec(t));){let e=parseFloat(i[1]),t=Bh[i[2]];if(null==t||!Number.isFinite(e))return null;r+=e*t,o+=i[0].length}return o!==t.length?null:r>0?r:null}var Xh="time",Vh="value",qh="__aggLower",Hh="__aggUpper",Uh="__aggPartial",Zh="count",Qh="__aggStart",Kh="__aggEnd";function Jh(e){let t=e.window??"tumbling",i=Gh("session"===t?e.gap??e.size:e.size);if(null==i)return null;let r=null!=e.hop?Gh(e.hop):void 0,o=null!=e.gap?Gh(e.gap):void 0;return new Oh({window:t,size:i,hop:r??void 0,gap:o??void 0,retain:e.retain,percentiles:e.percentiles,distinct:e.distinct})}function ef(e,t){let i=t.stat??"mean",r=t.band??"none",o=t.sigma??1;return e.emit().map(e=>{let t={[Xh]:(e.start+e.end)/2,[Vh]:jh(e,i),[Zh]:e.count,[Uh]:e.partial,[Qh]:e.start,[Kh]:e.end},n=Wh(e,r,i,o);return n&&(t[qh]=n[0],t[Hh]=n[1]),t})}function tf(e){return"none"!==(e.band??"none")}var rf="__aggSeries",of=class{constructor(e,t){this.config=e,this.seriesAccessor=t,this.groups=/* @__PURE__ */new Map}push(e,t,i){let r=oi(e,t,"time"),o=ri(e,i,"value");if(null==r||null==o)return;let n=null==this.seriesAccessor?"":String("function"==typeof this.seriesAccessor?this.seriesAccessor(e):e[this.seriesAccessor]),a=this.groups.get(n);if(!a){if(a=Jh(this.config),!a)return;this.groups.set(n,a)}a.push(+r,o)}emit(e){let t=[];for(let[i,r]of this.groups)for(let o of ef(r,e))t.push(null==this.seriesAccessor?o:{...o,[rf]:i});return t}clear(){this.groups.clear()}};function nf(e,t,i){return e??i??Math.max(t?.length??0,200)}function af(e,t){let i=Array.isArray(e)?li(e):[],r=t.aggregate;if(!r)return i;let o=new of(r,t.seriesAccessor);for(let e of i)o.push(e,t.timeAccessor,t.valueAccessor);return o.emit(r)}function sf(e){let t=e.timeAccessor||"time",i=e.valueAccessor||"value";return{timeAccessor:e=>oi(e,t,"time")??NaN,valueAccessor:e=>ri(e,i,"value")??NaN}}function lf(e,t,i){return{runtimeMode:"streaming",windowMode:i.windowMode??i.capacityMode??"sliding",windowSize:nf(i.windowSize,e,i.capacity),arrowOfTime:i.arrowOfTime??"right",...sf(i),xExtent:i.timeExtent??t.xExtent,yExtent:i.valueExtent??t.yExtent,extentPadding:i.extentPadding??t.extentPadding,tickFormatTime:i.tickFormatTime,tickFormatValue:i.tickFormatValue}}var cf={RealtimeLineChart:{frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=af(e,o),a=o.aggregate,s=o.aggregate?{timeAccessor:"time",valueAccessor:"value"}:sf(o),l=Z(()=>({stroke:"#007bff",strokeWidth:2}),o.styleRules,q(s.timeAccessor,s.valueAccessor));return{chartType:"line",data:n,...r,...lf(n,r,o),...s,groupAccessor:a&&null!=o.seriesAccessor?rf:o.seriesAccessor,...a&&{windowMode:"growing",windowSize:Math.max(1,a.retain??Math.max(n.length,600)),band:tf(a)?{y0Accessor:qh,y1Accessor:Hh,perSeries:null!=o.seriesAccessor}:void 0},lineStyle:r.lineStyle||(e=>({...l(e),...cr(o),...null!=o.strokeDasharray&&{strokeDasharray:o.strokeDasharray},...null!=o.cursor&&{cursor:o.cursor}}))}}},RealtimeHistogram:/* @__PURE__ */Object.assign({},sn,{buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?li(e):[];return{...sn.buildProps(n,t,i,r,o),...lf(n,r,o)}}}),TemporalHistogram:sn,RealtimeSwarmChart:{frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?li(e):[],a=Jr(n,r,o,"discovery"),s=Z(void 0,o.styleRules,q(o.timeAccessor??"time",o.valueAccessor??"value"));return{chartType:"swarm",data:n,...r,...lf(n,r,o),categoryAccessor:o.categoryAccessor,colorScheme:a||i||r.colorScheme,barColors:a,yScaleType:o.yScaleType,swarmStyle:{...cr(o),fill:o.fill,radius:o.radius,cursor:o.cursor},pointStyle:e=>({...s(e),..."function"==typeof o.pointStyle?o.pointStyle(e):{},..."function"==typeof r.pointStyle?r.pointStyle(e):r.pointStyle})}}},RealtimeWaterfallChart:{frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?li(e):[],a=tn.buildProps(n,t,i,r,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value"});return{...a,...lf(n,r,o),waterfallStyle:{...a.waterfallStyle,cursor:o.cursor}}}},RealtimeHeatmap:{frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?li(e):[];return{...mn.buildProps(n,t,i,r,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value",heatmapAggregation:o.aggregation??"count",cellBorderWidth:0}),...lf(n,r,o),categoryAccessor:o.categoryAccessor}}}};import{useMemo as uf,useCallback as df,useRef as hf}from"react";var ff={RdBu:Ai,PiYG:Si,PRGn:Mi,BrBG:$i,RdYlBu:_i,RdYlGn:Li,Spectral:Pi},pf="__likert_neutral_neg",gf="__likert_neutral_pos";function mf(e,t){if("function"==typeof e)return e;let i=e||t;return e=>e[i]}function yf(e,t){if(e<=0)return[];if(t&&Object.prototype.hasOwnProperty.call(ff,t)){let i=ff[t];if(1===e)return[i(.5)];let r=[];for(let t=0;t<e;t++)r.push(i(t/(e-1)));return r}let i=["#da1e28","#ff8389","#ffb3b8"],r=["#a6c8ff","#4589ff","#0043ce"],o="#a8a8a8";if(1===e)return[o];let n=e%2!=0,a=Math.floor(e/2),s=[];for(let e=0;e<a;e++)s.push(i[Math.min(Math.floor(e*i.length/a),i.length-1)]);n&&s.push(o);for(let e=0;e<a;e++)s.push(r[Math.min(Math.floor(e*r.length/a),r.length-1)]);return s}function xf(e,t,i,r,o,n,a={}){let s=/* @__PURE__ */new Map,l=new Set(t);for(let a of e){let e=i(a);s.has(e)||s.set(e,/* @__PURE__ */new Map);let c=s.get(e);if(r){let e=r(a);if(null==e||!Number.isFinite(e))continue;if(!Number.isInteger(e)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",e);continue}let i=e-1;if(i<0||i>=t.length)continue;let o=t[i];c.set(o,(c.get(o)||0)+1)}else if(o&&n){let e=o(a),t=n(a);if(!l.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}let c=[];for(let[e,i]of s){let r=0;for(let e of t)r+=i.get(e)||0;if(0!==r)for(let o=0;o<t.length;o++){let n=t[o],s=i.get(n)||0,l={};a.category&&(l[a.category]=e),a.level&&(l[a.level]=n),a.count&&(l[a.count]=s),a.score&&(l[a.score]=o+1),c.push({...l,__likertCategory:e,__likertLevel:n,__likertLevelLabel:n,__likertCount:s,__likertPct:s/r*100,__likertLevelIndex:o})}}return c}function bf(e,t){let i=t.length,r=i%2!=0,o=Math.floor(i/2),n=[];for(let t of e){let e=t.__likertLevelIndex;if(r&&e===o){let e=t.__likertPct/2;n.push({...t,__likertLevel:pf,__likertPct:-e}),n.push({...t,__likertLevel:gf,__likertPct:e})}else e<o?n.push({...t,__likertPct:-t.__likertPct}):n.push(t)}return n}function vf(e,t){let i=t.length,r=i%2!=0,o=Math.floor(i/2),n=/* @__PURE__ */new Map;for(let t of e){let e=n.get(t.__likertCategory)||[];e.push(t),n.set(t.__likertCategory,e)}let a=[];for(let[,e]of n){let t,n,s=/* @__PURE__ */new Map;for(let i of e)i.__likertLevel===pf?t=i:i.__likertLevel===gf?n=i:s.set(i.__likertLevelIndex,i);r&&t&&a.push(t);for(let e=o-1;e>=0;e--){let t=s.get(e);t&&a.push(t)}r&&n&&a.push(n);for(let e=r?o+1:o;e<i;e++){let t=s.get(e);t&&a.push(t)}}return a}import{jsx as wf,jsxs as kf}from"react/jsx-runtime";function Af(e,t,i){let r=Math.max(16,.3*t);if(null==i||i<=0)return r;let o=lc(e,r),n=2*i*.8;return o<=n?r:r*n/o}function Sf({value:e,min:t,max:i,radius:r,innerRadius:o,showScaleLabels:n,label:a}){let s=Af(e,r,o),l=.7*s+11;/* @__PURE__ */
170
- return kf("g",{textAnchor:"middle",children:[
171
- /* @__PURE__ */wf("text",{y:0,dominantBaseline:"central",fontSize:s,fontWeight:700,fill:"var(--semiotic-text, #333)",children:e}),n&&/* @__PURE__ */kf("text",{y:l,fontSize:11,fill:"var(--semiotic-text-secondary, #666)",children:[t," – ",i]}),null!=a&&""!==a&&/* @__PURE__ */wf("text",{y:l+(n?14:0),fontSize:11,fill:"var(--semiotic-text-secondary, #666)",children:a})]})}function Mf({centerContent:e,centerLabel:t,value:i,min:r,max:o,radius:n,innerRadius:a,showScaleLabels:s,valueFormat:l,compact:c}){if(null!=e){let s="function"==typeof e?e(i,r,o):e;return"string"==typeof s||"number"==typeof s?Sf({value:String(s),min:r,max:o,radius:n,innerRadius:a,showScaleLabels:!1,label:t}):s}return c?null:Sf({value:l?l(i):String(Math.round(i)),min:r,max:o,radius:n,innerRadius:a,showScaleLabels:s,label:t})}function $f(e){return Math.max(0,Math.min(1,e))}function _f(e){let t=e.trim();if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e.split("").map(e=>e+e).join("")),6===e.length&&/^[0-9a-f]{6}$/i.test(e))return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}let i=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(i){let e=[Number(i[1]),Number(i[2]),Number(i[3])];if(e.every(Number.isFinite))return e}return null}function Lf(e,t,i){let r=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(i)}`}function Pf(e,t,i){let r=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:$f(e.offset),color:e.color??i,opacity:null==e.opacity?1:$f(e.opacity)})).sort((e,t)=>e.offset-t.offset);if(0===r.length)return"#999999";let o=e=>{if(1===e.opacity)return e.color;let t=_f(e.color);return t?`rgba(${t[0]},${t[1]},${t[2]},${e.opacity})`:e.color};if(1===r.length)return o(r[0]);let n=$f(t);if(n<=r[0].offset)return o(r[0]);if(n>=r[r.length-1].offset)return o(r[r.length-1]);for(let e=0;e<r.length-1;e++){let t=r[e],i=r[e+1];if(n<t.offset||n>i.offset)continue;let a=i.offset-t.offset,s=a<=0?0:(n-t.offset)/a,l=_f(t.color),c=_f(i.color);if(!l||!c)return o(s<.5?t:i);let[u,d,h]=l,[f,p,g]=c,m=u+(f-u)*s,y=d+(p-d)*s,x=h+(g-h)*s,b=t.opacity+(i.opacity-t.opacity)*s;return 1===b?Lf(m,y,x):`rgba(${Math.round(m)},${Math.round(y)},${Math.round(x)},${b})`}return o(r[r.length-1])}function If(e,t,i){return null==i?`${e}-${t}`:`${e}-${t}-${i}`}function Rf(e){let{min:t,max:i,value:r,thresholds:o,fillColor:n,backgroundColor:a,fillZones:s,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=e,d=Math.max(t,Math.min(i,r)),h=i-t||1,f=(d-t)/h,p=o&&o.length>0?[...o].sort((e,t)=>e.value-t.value):[{value:i,color:n||"#007bff"}];p=p.map(e=>({...e,value:Math.max(t,Math.min(i,e.value))})),p[p.length-1].value<i&&p.push({value:i,color:p[p.length-1].color});let g=!!c&&c.stops.length>=2,m=[],y=/* @__PURE__ */new Map,x=[];if(g){let e=s?f:1,t=If("bg",0);if(m.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),y.set(t,{fill:a,opacity:.4}),e>0){let t=Math.max(1,Math.floor(u)),i=Math.max(1,Math.min(t,Math.round(e*t))),r=[];for(let t=0;t<i;t++){let o=e*(t+.5)/i;r.push(Pf(c.stops,o,n||p[0]?.color||"#007bff"))}let o=If("fill",0);m.push({category:o,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:r}}),y.set(o,{fill:r[0]||a})}}else{let e=t;for(let o=0;o<p.length;o++){let n=p[o],l=(n.value-e)/h,c=(e-t)/h,u=(n.value-t)/h,g=s?Math.min(f,u):u,x=Math.max(0,g-c),b=s?Math.max(0,l-x):0;if(x>0){let a=If("fill",o);m.push({category:a,value:x,_zone:n.label||`Zone ${o+1}`,_isFill:!0,__gaugeAccessibleDatum:{category:n.label||`Zone ${o+1}`,value:r,min:t,max:i,segmentStart:e,segmentEnd:t+g*h,filled:!0}}),y.set(a,{fill:n.color})}if(b>0){let s=If("bg",o);m.push({category:s,value:b,_zone:n.label||`Zone ${o+1}`,_isFill:!1,__gaugeAccessibleDatum:{category:n.label||`Zone ${o+1}`,value:r,min:t,max:i,segmentStart:Math.max(e,d),segmentEnd:n.value,filled:!1}}),y.set(s,{fill:a,opacity:.4})}e=n.value}}if(l&&o&&o.length>0)for(let e of o)e.value>t&&e.value<i&&x.push({type:"gauge-label",value:e.value,label:e.label||String(e.value)});return{gaugeData:m,pieceStyle:(e,t)=>{let i=t||e.category;return y.get(i)||{fill:a}},gaugeAnnotations:x}}function Tf(e=240){let t=e*Math.PI/180,i=360-e,r=180+i/2,o=r*Math.PI/180;return{sweepRad:t,gapDeg:i,startAngleDeg:r,startAngleRad:o,offsetRad:-Math.PI/2+o}}function Cf(e=240){let{sweepRad:t,offsetRad:i}=Tf(e),r=[[Math.cos(i),Math.sin(i)],[Math.cos(i+t),Math.sin(i+t)],[0,0]];for(let e=0;e<2*Math.PI;e+=Math.PI/2)((e-i)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)<=t+.001&&r.push([Math.cos(e),Math.sin(e)]);let o=r.map(e=>e[0]),n=r.map(e=>e[1]),[a,s]=Ne(o),[l,c]=Ne(n);return{minX:a,maxX:s,minY:l,maxY:c,width:s-a,height:c-l,cx:(a+s)/2,cy:(l+c)/2}}import{Fragment as Nf,jsx as Ff,jsxs as zf}from"react/jsx-runtime";function Ef(e){return Ji(e)}function Df(e,t,i,r,o,n){let a=hr(r.theme).colors.categorical,s=i??r.colorScheme,l=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],c="string"==typeof t?t:"__ssrColorBy",u="function"==typeof t?l.map(e=>({...e,__ssrColorBy:t(e)})):l,d=t?ji(u,c,s??a):void 0,h=Yi("string"==typeof o.color?o.color:void 0,a,s,void 0,
172
- /* @__PURE__ */new Map),f=n??V(o.valueAccessor??"value"),p=o.styleRules,g=r.pieceStyle;return(e,i)=>{let r={fill:t&&d?Di(e,t,d):h};return p?.length&&Object.assign(r,U(e,p,{value:f(e,i),category:i})),"function"==typeof g?Object.assign(r,g(e,i)||{}):g&&"object"==typeof g&&Object.assign(r,g),void 0!==o.stroke&&(r.stroke=o.stroke),void 0!==o.strokeWidth&&(r.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(r.opacity=o.opacity),r}}function Of(e,t,i,r,o,n="median",a=.8){let s=V(o.valueAccessor??"value"),l=Df(e,t,i,r,o,e=>"number"==typeof e[n]?e[n]:s(e));return(e,t)=>{let i=l(e,t);return void 0===i.fillOpacity&&(i.fillOpacity=a),void 0===i.stroke&&(i.stroke=i.fill),i}}function jf(e,t,i,r,o){return Of(e,t,i,r,o,"median",.6)}function Wf(e,t,i,r,o){let n=Df(e,t,i,r,o),a="number"==typeof o.dotRadius?o.dotRadius:5;return(e,t)=>({r:a,fillOpacity:.8,...n(e,t)})}function Bf(e,t,i,r,o){let n=Df(e,t,i,r,o),a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=o.sizeBy,l=Array.isArray(o.sizeRange)?o.sizeRange:[3,8],c=s?a.map(e=>"function"==typeof s?s(e):Number(e[s])).filter(Number.isFinite):[],u=c.length?Ne(c):void 0,d="number"==typeof o.pointRadius?o.pointRadius:4,h="number"==typeof o.pointOpacity?o.pointOpacity:.7;return(e,t)=>({r:s?Bi(e,s,l,u):d,fillOpacity:h,...n(e,t)})}var Yf={BarChart:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=ur(r.annotations,o.regression);return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,colorAccessor:t,colorScheme:i,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,...n&&{annotations:n},gradientFill:Ef(r.gradientFill),pieceStyle:Df(e,t,i,r,o)}}},StackedBarChart:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.stackBy;return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.stackBy,colorAccessor:n,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},normalize:o.normalize,oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:Ef(r.gradientFill),pieceStyle:Df(e,n,i,r,o),showLegend:r.showLegend??!!n}}},GroupedBarChart:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.groupBy;return{chartType:"clusterbar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",groupBy:o.groupBy,colorAccessor:n,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:Ef(r.gradientFill),pieceStyle:Df(e,n,i,r,o),showLegend:r.showLegend??!!n}}},SwarmPlot:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"swarm",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},barPadding:o.categoryPadding??20,colorAccessor:t,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...r,sizeRange:o.sizeRange||[3,8],pieceStyle:Bf(e,t,i,r,o),showLegend:r.showLegend??!!t})},BoxPlot:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"boxplot",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},colorAccessor:t,colorScheme:i,...null!=o.showOutliers&&{showOutliers:o.showOutliers},...null!=o.outlierRadius&&{outlierRadius:o.outlierRadius},...r,summaryStyle:Of(e,t,i,r,o)})},Histogram:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=o.valueAccessor||"value",s=n.map(e=>Number("function"==typeof a?a(e):e[a])).filter(Number.isFinite),l=s.length?[Math.min(...s),Math.max(...s)]:void 0;return{chartType:"histogram",data:e,oAccessor:o.categoryAccessor||(e=>null==e.category?"All":String(e.category)),rAccessor:a,projection:"horizontal",bins:o.bins??25,normalize:o.relative??!1,colorAccessor:t,colorScheme:i,barPadding:o.categoryPadding??20,...o.valueExtent?{rExtent:o.valueExtent}:l?{rExtent:l}:{},...r,summaryStyle:Of(e,t,i,r,o,"count")}}},ViolinPlot:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"violin",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,projection:"horizontal"===o.orientation?"horizontal":"vertical",bins:o.bins??25,showIQR:o.showIQR??!0,barPadding:o.categoryPadding??20,colorScheme:i,...r,summaryStyle:jf(e,t,i,r,o),showLegend:r.showLegend??!!t,...o.valueExtent&&{rExtent:o.valueExtent}})},RidgelinePlot:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"ridgeline",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},bins:o.bins??20,amplitude:o.amplitude??1.5,barPadding:o.categoryPadding??5,oSort:o.oSort??!1,...r,summaryStyle:Of(e,t,i,r,o,"median",.5),showLegend:r.showLegend??!!t})},DotPlot:{frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,i,r,o)=>{let n=ur(r.annotations,o.regression);return{chartType:"point",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??"auto",barPadding:o.categoryPadding??10,...r,...n&&{annotations:n},pieceStyle:Wf(e,t,i,r,o),showGrid:r.showGrid??!0,showLegend:r.showLegend??!!t}}},PieChart:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.categoryAccessor,a=V(o.valueAccessor??"value");return{chartType:"pie",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:n,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:Df(e,n,i,r,o,e=>{let t=a(e);return null==t?void 0:Math.abs(t)}),showLegend:r.showLegend??!!n}}},DonutChart:{frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,i,r,o)=>{let n=t||o.categoryAccessor,a=V(o.valueAccessor??"value");return{chartType:"donut",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",margin:r.margin??{top:50,right:40,bottom:60,left:70},innerRadius:o.innerRadius??60,colorAccessor:n,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:Df(e,n,i,r,o,e=>{let t=a(e);return null==t?void 0:Math.abs(t)})}}},GaugeChart:{frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(e,{theme:t}){let i=e.__gauge;if(!i)return null;let r=Math.max(i.gMin,Math.min(i.gMax,i.value??i.gMin)),o=i.gMax===i.gMin?0:(r-i.gMin)/(i.gMax-i.gMin),n=(i.startAngleDeg+o*i.sweep-90)*Math.PI/180,a=i.needleColor||t.colors.text,s=i.showScaleLabels?(i.thresholds||[]).filter(e=>e.value>i.gMin&&e.value<i.gMax):[];/* @__PURE__ */
173
- return zf(Nf,{children:[i.showNeedle&&/* @__PURE__ */zf(Nf,{children:[
174
- /* @__PURE__ */Ff("line",{x1:i.centerX,y1:i.centerY,x2:i.centerX+i.needleLength*Math.cos(n),y2:i.centerY+i.needleLength*Math.sin(n),stroke:a,strokeWidth:2.5,strokeLinecap:"round"}),
175
- /* @__PURE__ */Ff("circle",{cx:i.centerX,cy:i.centerY,r:4,fill:a})]}),null!=i.contextValue&&/* @__PURE__ */Ff("text",{x:i.centerX,y:i.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:i.valueFontSize,fontWeight:700,fill:a,children:i.contextValue}),s.map((e,r)=>{let o=i.gMax===i.gMin?0:(e.value-i.gMin)/(i.gMax-i.gMin),n=(i.startAngleDeg+o*i.sweep-90)*Math.PI/180,a=i.innerRadius-1,s=i.radius+1,l=i.radius+10,c=((n+Math.PI/2)/(2*Math.PI)*12+12)%12,u=c>=11||c<1?"middle":c<5?"start":c<7?"middle":"end",d=c>=11||c<1?"auto":c<5?"middle":c<7?"hanging":"middle";/* @__PURE__ */
176
- return zf("g",{children:[
177
- /* @__PURE__ */Ff("line",{x1:i.centerX+Math.cos(n)*a,y1:i.centerY+Math.sin(n)*a,x2:i.centerX+Math.cos(n)*s,y2:i.centerY+Math.sin(n)*s,stroke:t.colors.border,strokeWidth:2,strokeLinecap:"round"}),
178
- /* @__PURE__ */Ff("text",{x:i.centerX+Math.cos(n)*l,y:i.centerY+Math.sin(n)*l,textAnchor:u,dominantBaseline:d,fill:t.colors.textSecondary,fontSize:10,children:e.label||String(e.value)})]},`gauge-label-${r}`)})]})},buildProps:(e,t,i,r,o)=>{let n=o.min??0,a=o.max??100,s=o.sweep??240,l=o.arcWidth??.3,c=!1!==o.showNeedle,u=!1!==o.fillZones,{startAngleDeg:d}=Tf(s),h=r.__resolvedMode??o.mode,f="context"===h||"sparkline"===h,p=o.showScaleLabels??!f,g=o.thresholds,m=er(r.gradientFill),y=Rf({min:n,max:a,value:o.value,thresholds:g,fillColor:o.color,backgroundColor:o.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:p,gradientFill:m}),x=o.styleRules,[b,v]=r.size||[300,250],w=Cf(s),k=Math.min(10,Math.max(1,Math.min(b,v)/12)),A=Math.max(4,Math.min((b-2*k)/w.width,(v-2*k)/w.height)-2),S=Math.max(0,Math.min(A-1.5,A*(1-l))),M=b/2-w.cx*A,$=v/2-w.cy*A,_=2*(A+4),L=Math.max(n,Math.min(a,o.value??n)),P="function"==typeof o.valueFormat?o.valueFormat(L):String(Math.round(L)),I=o.centerContent??r.centerContent,R=Mf({centerContent:I,centerLabel:"string"==typeof o.centerLabel?o.centerLabel:void 0,value:L,min:n,max:a,radius:A,innerRadius:S,showScaleLabels:p,valueFormat:"function"==typeof o.valueFormat?o.valueFormat:void 0,compact:f});return{chartType:"donut",data:y.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:S,sweepAngle:s,startAngle:d,oSort:!1,pieceStyle:Xi((e,t)=>{let i={...y.pieceStyle(e,t)};return x?.length&&Object.assign(i,U(e,x,{value:"number"==typeof e.value?e.value:void 0,category:t??(null==e.category?void 0:String(e.category))})),i},cr(o)),...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...r,size:[b,v],margin:{top:$-_/2,bottom:v-$-_/2,left:M-_/2,right:b-M-_/2},...null!=R&&{centerContent:R},showAxes:!1,annotations:[...Array.isArray(r.annotations)?r.annotations:[],...y.gaugeAnnotations],__gauge:{gMin:n,gMax:a,sweep:s,arcWidth:l,value:L,startAngleDeg:d,thresholds:g,centerX:M,centerY:$,radius:A,innerRadius:S,showScaleLabels:p,needleLength:S>20?S-8:A-1,showNeedle:c,needleColor:o.needleColor,..."context"===h&&null==I&&{contextValue:P,contextValueY:$-.2*S,valueFontSize:Math.max(12,Math.min(22,.28*A))}}}}},FunnelChart:{frameType:"ordinal",layout:{margin:(e,t)=>"vertical"===e.orientation?{top:t.title?60:40,right:20,bottom:60,left:60}:{top:t.title?40:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n="vertical"===o.orientation,a=t||o.categoryAccessor;return{chartType:n?"bar-funnel":"funnel",data:e,oAccessor:o.stepAccessor||"step",rAccessor:o.valueAccessor||"value",colorAccessor:a,categoryAccessor:o.categoryAccessor,projection:n?"vertical":"horizontal",connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,...!n&&null!=o.connectorOpacity&&{connectorOpacity:o.connectorOpacity},barPadding:n?40:0,colorScheme:i,...r,showAxes:n&&!1!==r.showAxes,showGrid:n,pieceStyle:Df(e,a,i,r,o),showLabels:o.showLabels??!0}}},RadarChart:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=o.seriesAccessor||t||"__radar",a=t||("__radar"===n?void 0:n),s=Wf(e,a,i,r,{...o,dotRadius:o.pointRadius??4});return{chartType:"point",projection:"radial",data:e,oAccessor:o.categoryAccessor||"attribute",rAccessor:o.valueAccessor||"value",colorAccessor:a,colorScheme:i,connectorAccessor:n,connectorStyle:e=>{let t=s(e),i="string"==typeof t.fill?t.fill:void 0;return{fill:i,fillOpacity:.15,stroke:i,strokeWidth:2,opacity:.7}},pieceStyle:s,rExtent:o.valueExtent||[0],oLabel:"",...r,...o.categoryFormat&&{oFormat:o.categoryFormat},showLegend:r.showLegend??!!a}}},SwimlaneChart:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.subcategoryAccessor;return{chartType:"swimlane",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.subcategoryAccessor,colorAccessor:n,categoryAccessor:o.categoryAccessor,subcategoryAccessor:o.subcategoryAccessor,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...null!=o.trackFill&&{trackFill:o.trackFill},...o.valueExtent&&{rExtent:o.valueExtent},...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:Ef(r.gradientFill),pieceStyle:Df(e,n,i,r,o),showLegend:r.showLegend??!!n,barPadding:o.barPadding??40}}},LikertChart:{frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,i,r,o)=>{let n=Array.isArray(o.levels)&&o.levels.length>=2?o.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],a="vertical"!==o.orientation,s=xf(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n,mf(o.categoryAccessor,"question"),o.levelAccessor?null:mf(o.valueAccessor,"score"),o.levelAccessor?mf(o.levelAccessor,"level"):null,o.levelAccessor?mf(o.countAccessor,"count"):null,{category:"string"==typeof o.categoryAccessor?o.categoryAccessor:void 0,level:"string"==typeof o.levelAccessor?o.levelAccessor:void 0,count:"string"==typeof o.countAccessor?o.countAccessor:void 0,score:o.levelAccessor||"string"!=typeof o.valueAccessor?void 0:o.valueAccessor});a&&(s=vf(bf(s,n),n));let l=hr(r.theme).colors.diverging,c=Array.isArray(i)&&i.length>=n.length?i:yf(n.length,l),u=new Map(n.map((e,t)=>[e,c[t]||"#888"])),d=n.length%2&&u.get(n[Math.floor(n.length/2)])||"#888",h="function"==typeof o.valueFormat?o.valueFormat:e=>`${Math.abs(Number(e)).toFixed(0)}%`,f=Qe(!1===r.showLegend?void 0:{legendGroups:[{label:"",items:n.map(e=>({label:e})),styleFn:e=>({fill:u.get(e.label)||"#888"})}]},r.legend),p=o.styleRules,g=r.pieceStyle;return{chartType:"bar",data:s,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:a?"horizontal":"vertical",barPadding:o.barPadding,showGrid:r.showGrid,oLabel:o.categoryLabel,rLabel:o.valueLabel||(a?void 0:"Percentage"),rFormat:h,...o.categoryFormat&&{oFormat:o.categoryFormat},...o.valueExtent&&{rExtent:o.valueExtent},...r,pieceStyle:Xi((e,t)=>{let i=e.__likertLevel||e.data?.__likertLevel,r=e.__likertLevelLabel||e.data?.__likertLevelLabel,o=e.__likertPct??e.data?.__likertPct,n={fill:i===pf||i===gf?d:u.get(String(r||i))||"#888"};return p?.length&&Object.assign(n,U(e,p,{value:"number"==typeof o?o:void 0,category:t??(null==r?void 0:String(r))})),"function"==typeof g?Object.assign(n,g(e,t)||{}):g&&"object"==typeof g&&Object.assign(n,g),n},cr(o)),showLegend:r.showLegend??!0,legendPosition:r.legendPosition||"right",...f&&{legend:f},__legendIncludesAutomatic:!0}}}},Gf={frameType:"xy",buildProps:(e,t,i,r,o)=>({chartType:"custom",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1,showLegend:r.showLegend??!!t})},Xf={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"custom",data:e,oAccessor:o.categoryAccessor||o.oAccessor||"category",rAccessor:o.valueAccessor||o.rAccessor||"value",projection:o.projection||"vertical",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1})},Vf={frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(e,t,i,r,o)=>({chartType:"force",nodes:o.nodes||e||[],edges:o.edges||[],nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor||"id",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",valueAccessor:o.valueAccessor||"value",colorBy:t,colorScheme:i,customNetworkLayout:o.layout||o.customNetworkLayout,layoutConfig:o.layoutConfig,...r})},qf={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({...Xf.buildProps(e,t,i,r,o),customLayout:K,showAxes:!1})},Hf={frameType:"xy",buildProps:(e,t,i,r,o)=>({...Gf.buildProps(e,t,i,r,o),customLayout:Pe,showAxes:!1})};import*as Uf from"react";import{scaleLinear as Zf}from"d3-scale";function Qf(e){let{data:i,valueAccessor:r,bins:n,ballRadius:a,seed:s,size:l,valueExtent:c}=e,{rows:u}=o(i,"galton"),d=k(l),h=u.map((e,t)=>$(M(e,t,r))).filter(e=>null!=e),f=t(c),[p,g]=f??(h.length?Ne(h):[0,1]),m=g===p?1:g-p,y=Zf().domain([0,n]).range([d.plot.x,d.plot.x+d.plot.width]),x=Array.from({length:n},()=>0),b=[];u.forEach((e,t)=>{let i=$(M(e,t,r));if(null==i)return;let o=Math.max(0,Math.min(n-1,Math.floor((i-p)/m*n)));x[o]+=1,b.push({id:String(e.id??`galton-${t}`),x:y(o+.5),y:d.plot.y+a+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:a},datum:{...e,value:i,bin:o}})});let v=d.plot.y+d.plot.height,w=[...J({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...ee({idPrefix:"galton-bin",count:n,domainStart:0,domainStep:1,xScale:y,yTop:d.plot.y-400,yBottom:v,wallThickness:6})];return{config:S(s,w,"GaltonBoardChart"),initialSpawns:b,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:x.map((e,t)=>({label:String(t+1),value:e})),metadata:{kind:"galton-board",bins:n,plot:d.plot,valueExtent:[p,g]}}}import{scaleLinear as Kf}from"d3-scale";function Jf(e,t){let i=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:i,height:e.plot.height},windowPlot:{x:e.plot.x+i,y:e.plot.y,width:Math.max(40,e.plot.width-i),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}function ep(e,t){let i=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!i)return[];let r=e.windowStart,o=e.windowStart+e.windowCount*e.windowSize,n=Kf().domain([r,o]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),a=n(e.windowStart+i*e.windowSize),s=e.windowPlot.x,l=Math.max(18,Math.min(.3*e.windowPlot.height,a-s)),c=t+l,u=e=>a===s?t:c+(e-s)/(a-s)*(t-c),d=[];for(let t=0;t<i;t+=1){let i=e.windowStart+t*e.windowSize,r=i+e.windowSize,o=n(i),a=n(r);d.push({id:`eventdrop-lid-${t}`,windowIndex:t,x1:o,y1:u(o),x2:a,y2:u(a)})}return d}function tp(e){let{count:t,idPrefix:i,wallThickness:r,xScale:o,yBottom:n,yTop:a,yTopForIndex:s}=e;return Array.from({length:t+1},(e,t)=>{let l=Math.min(n-1,s?.(t)??a),c=Math.max(1,n-l);return{id:`${i}-wall-${t}`,shape:{type:"aabb",x:o(t),y:l+c/2,width:r,height:c}}})}function ip(e){let{data:t,timeAccessor:i,arrivalAccessor:r,windows:o,watermark:a,watermarkAtArrivalAccessor:s,ballRadius:l,seed:c,size:u,timeExtent:d,timeScale:h=1}=e,{events:f,watermarkValue:p}=n({data:t,timeAccessor:i,arrivalAccessor:r,watermark:a,watermarkAtArrivalAccessor:s,windowSize:o.size}),g=k(u),m=f.length?1/0:0,y=f.length?1/0:0,x=f.length?-1/0:o.size;for(let e of f)m=Math.min(m,e.arrivalTime),y=Math.min(y,e.eventTime),x=Math.max(x,e.eventTime);let b=$(d?.[0]),v=$(d?.[1]),w=Math.min(b??y,y),A=Math.max(v??x,x),M=Math.floor(w/o.size)*o.size,_=Math.max(1,Math.ceil((A-M+o.size)/o.size)),L=Jf(g,l),P=M+_*o.size,I=Kf().domain([M,P]).range([L.windowPlot.x,L.windowPlot.x+L.windowPlot.width]),R=0,T=Array.from({length:_},(e,t)=>(M+(t+1)*o.size<=p&&R++,{value:0,secondary:0})),C=[];f.forEach(({datum:e,index:t,eventTime:i,arrivalTime:r,watermarkAtArrival:n,late:a})=>{let s=Math.max(0,Math.min(_-1,Math.floor((i-M)/o.size)));T[s].value+=a?0:1,T[s].secondary+=a?1:0,C.push({id:String(e.id??`event-${t}`),x:op(i,s,a,{windowStart:M,windowSize:o.size,gutter:L.gutter,closedWindowCount:R,windowPlot:L.windowPlot,windowCount:_},l),y:g.plot.y+l+2,vx:0,vy:0,mass:1,friction:.02,spawnAt:r,shape:{type:"circle",radius:l},datum:{...e,eventTime:i,arrivalTime:r,windowIndex:s,watermarkAtArrival:n,late:a}})});let N=g.plot.y+g.plot.height,F=g.plot.y+.28*g.plot.height,z={closedWindowCount:R,gutter:L.gutter,plot:g.plot,windowCount:_,windowPlot:L.windowPlot,windowSize:o.size,windowStart:M},E=ep(z,F);for(let e of C){let t=e.datum;e.y=rp({...z,lidSegments:E},t.windowIndex,t.late,l)}let D=e=>{if(e<0||e>R)return null;let t=0===e?E[0]?.y1:E[e-1]?.y2??E[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null},O=tp({idPrefix:"eventdrop-window",count:_,xScale:e=>I(M+e*o.size),yTop:L.wallTop,yTopForIndex:e=>{let t=D(e);return null==t?L.wallTop:t+1.25*l},yBottom:N,wallThickness:6}),j=[...J({x:g.plot.x,y:g.plot.y,width:g.plot.width,height:g.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...O,...E.map(e=>({id:e.id,shape:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:Math.max(4,.42*l)},friction:.02,restitution:.01}))];return{config:S(c,j,"EventDropChart",{friction:.08}),initialSpawns:C,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>{let t=e.datum,i=t.windowIndex<R;return i&&!t.late||!i&&t.late?m:t.arrivalTime},timeScale:h},projectionRows:T.map((e,t)=>({label:`${M+t*o.size}-${M+(t+1)*o.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:R,gutter:L.gutter,lidSegments:E,lateCount:T.reduce((e,t)=>e+t.secondary,0),plot:g.plot,windowPlot:L.windowPlot,windowWalls:O.map(({id:e,shape:t})=>({id:e,x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height})),watermarkValue:p,windowCount:_,windowSize:o.size,windowStart:M}}}function rp(e,t,i,r){let{windowPlot:o,lidSegments:n}=e,a=n[t];return i&&!a?Math.min(o.y+o.height-r,o.y+.48*o.height+2*r+4):!i&&a?Math.min(o.y+o.height-r,Math.max(a.y1,a.y2)+2*r+4):o.y+r+2}function op(e,t,i,r,o){let{windowPlot:n,windowCount:a,windowStart:s,windowSize:l}=r;if(i&&t>=r.closedWindowCount)return r.gutter.x+r.gutter.width/2;let c=n.width/a,u=i?n.x:n.x+t*c,d=i?n.x+n.width:u+c,h=Math.min((d-u)/2,o+(i?0:3)),f=n.x+(e-s)/l*c;return Math.max(u+h,Math.min(d-h,f))}function np(e,t,i){let r=Math.max(1,t),o=e.width/r,n=Math.max(2,2*i),a=Math.min(.7*o,Math.max(3.2*n,n+8)),s=Math.max(1,Math.floor(a/n));return{laneWidth:o,tubeWidth:a,ballDiameter:n,perRow:s,centerX:t=>e.x+(t+.5)*o,pileHeight:e=>Math.ceil(Math.max(0,e)/s)*n}}function ap(t){let{data:i,categoryAccessor:r,valueAccessor:n,unitValue:a,ballRadius:l,seed:c,size:u}=t,d=e(a,1),{rows:h}=o(i,"pile"),f=k(u),p=[],g=/* @__PURE__ */new Map,m=/* @__PURE__ */new Map,y=[];function x(e){let t=g.get(e);return null==t&&(t=p.length,p.push(e),g.set(e,t)),t}h.forEach((e,t)=>{x(String(M(e,t,r)??"unknown"))});let b=Math.max(1,p.length),v=np(f.plot,b,l),w=Math.max(0,v.tubeWidth/2-l-1),A=p.map(()=>[]);h.forEach((e,t)=>{let i=String(M(e,t,r)??"unknown"),o=x(i),a=n?$(M(e,t,n)):1,c=Math.max(0,a??0);m.set(i,(m.get(i)??0)+c);let u=s(c,d),h=v.centerX(o);for(let r=0;r<u;r+=1){let n=A[o].length,a=r===u-1?c-r*d:d,s=Math.min(1,a/d),p=v.perRow>1?n%v.perRow:0,g=v.perRow>1?(p/(v.perRow-1)*2-1)*w:0;A[o].push({id:`${String(e.id??`pile-${t}`)}-${r}`,x:h+g,y:f.plot.y+l+2,vx:(r%3-1)*l/2,vy:0,mass:1,shape:{type:"circle",radius:l*Math.sqrt(s)},datum:{...e,category:i,unitIndex:r,unitValue:d,representedValue:a,unitFraction:s}})}});let _=A.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;e<_;e+=1)for(let t of A)e<t.length&&y.push(t[e]);let L=f.plot.y+f.plot.height,P=[...J({x:f.plot.x,y:f.plot.y,width:f.plot.width,height:f.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],I=f.plot.y-400;for(let e=0;e<b;e+=1){let t=v.centerX(e);for(let i of[-1,1])P.push({id:`pile-tube-${e}-${i<0?"l":"r"}`,shape:{type:"aabb",x:t+i*(v.tubeWidth+6)/2,y:(I+L)/2,width:6,height:L-I}})}return{config:S(c,P,"UnitPileChart"),initialSpawns:y,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:p.map(e=>({label:e,value:m.get(e)??0}))}}import{scaleLinear as sp}from"d3-scale";function lp(e,t,i,r){let o=(t+i)/2,n=[];for(let a of e){let s=n.filter(e=>Math.abs(a.x-e.x)<a.radius+e.radius+.5),l=[o];for(let e of s){let t=a.radius+e.radius+.5,i=Math.sqrt(t**2-(a.x-e.x)**2);l.push(e.y-i,e.y+i)}let c=r()<.5?-1:1;l.sort((e,t)=>Math.abs(e-o)-Math.abs(t-o)||c*(e-t));let u=l.find(e=>e-a.radius>=t&&e+a.radius<=i&&s.every(t=>(a.x-t.x)**2+(e-t.y)**2>=(a.radius+t.radius+.5)**2-1e-6));if(null==u){let r=e.reduce((e,t)=>Math.max(e,t.radius),-1/0),n=Math.max(0,i-t-2*r);return{positions:e.map((t,i)=>o+(1===e.length?0:i/(e.length-1)-.5)*n),overlapping:!0,entryOffset:0}}n.push({...a,y:u})}return{positions:n.map(e=>e.y),overlapping:!1,entryOffset:Math.max(0,n.reduce((e,i)=>Math.min(e,i.y-i.radius-t),36))}}function cp(e){let{data:t,xAccessor:i,groupAccessor:r,radiusAccessor:n,pointRadius:a,seed:s,size:l,xExtent:c,collisionIterations:u,settle:d}=e,{rows:h}=o(t,"collision-swarm"),f=k(l),p=Oe(s),g=[],m=[],y=/* @__PURE__ */new Map;function x(e){let t=y.get(e);return null==t&&(t=m.length,m.push(e),y.set(e,t)),t}h.forEach((e,t)=>{let o=$(M(e,t,i));if(null==o)return;let s=r?String(M(e,t,r)??"All"):"All",l=n?$(M(e,t,n)):null,c=_(null!=l&&l>0?l:a,2,18);x(s),g.push({datum:e,index:t,value:o,group:s,radius:c})});let b=c?$(c[0]):null,v=c?$(c[1]):null,w=g.reduce((e,t)=>Math.min(e,t.value),g.length?1/0:0),A=g.reduce((e,t)=>Math.max(e,t.value),g.length?-1/0:1),L=b??w,P=v??A;if(L===P&&(L-=.5,P+=.5),L>P){let e=P;P=L,L=e}let I=g.reduce((e,t)=>Math.max(e,t.radius),a),R=f.plot.x+I+8,T=f.plot.x+f.plot.width-I-8,C=sp().domain([L,P]).range([R,T]),N=Math.max(1,m.length),F=f.plot.height/N,z=Math.min(6,.05*F),E=e=>f.plot.y+((y.get(e)??0)+.5)*F,D=/* @__PURE__ */new Map,O=/* @__PURE__ */new Set,j=/* @__PURE__ */new Map;for(let e of m){let t=g.filter(t=>t.group===e),i=E(e),r=t.map(e=>({x:C(e.value),radius:e.radius})),o=lp(r,i-F/2+z,i+F/2-z,p);D.set(e,t.length),o.overlapping&&O.add(e),t.forEach((e,t)=>j.set(e.index,{x:r[t].x,y:o.positions[t],entryOffset:o.entryOffset}))}let W=g.map((e,t)=>{let i=j.get(e.index),r=i.x,o=i.y,n=O.has(e.group);return{id:String(e.datum.id??`collision-swarm-${t}`),x:r,y:o-(d?0:i.entryOffset),vx:0,vy:0,fixedPosition:{x:r},bodyCollisions:!n,mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:r,targetY:o,overlapping:n},springs:[{target:{type:"point",x:r,y:o},restLength:0,stiffness:34,damping:12}]}}),B=J({x:f.plot.x,y:f.plot.y,width:f.plot.width,height:f.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20});return{config:S(s,B,"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*I),collisionIterations:Math.max(1,Math.round(u??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:W,projectionRows:m.map(e=>({label:e,value:D.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[L,P],xRange:[R,T],groups:m.map(e=>({label:e,y:E(e),count:D.get(e)??0,overlapping:O.has(e)})),plot:f.plot}}}function up(e){if(Array.isArray(e)&&e.length>=2){let t=$(e[0]),i=$(e[1]);return null!=t&&null!=i?{x:t,y:i}:null}if(e&&"object"==typeof e){let t=e,i=$(t.x),r=$(t.y);return null!=i&&null!=r?{x:i,y:r}:null}return null}function dp(e){return Array.isArray(e)?e.map(up).filter(e=>null!=e):[]}function hp(e,t){return"normalized"===e||"pixels"===e?e:t.length>0&&t.every(e=>e.x>=0&&e.x<=1&&e.y>=0&&e.y<=1)?"normalized":"pixels"}function fp(e,t,i){return"normalized"===i?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:_(e.x,t.plot.x,t.plot.x+t.plot.width),y:_(e.y,t.plot.y,t.plot.y+t.plot.height)}}function pp(e){let t=0;for(let i=1;i<e.length;i+=1){let r=e[i].x-e[i-1].x,o=e[i].y-e[i-1].y;t+=Math.hypot(r,o)}return t}function gp(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};let i=_(t,0,1)*pp(e),r=0;for(let t=1;t<e.length;t+=1){let o=e[t-1],n=e[t],a=Math.hypot(n.x-o.x,n.y-o.y);if(!(a<=0)){if(r+a>=i){let e=(i-r)/a;return{x:o.x+(n.x-o.x)*e,y:o.y+(n.y-o.y)*e}}r+=a}}return{...e[e.length-1]}}function mp(e,t){let i=gp(e,Math.max(0,t-.02)),r=gp(e,Math.min(1,t+.02)),o=r.x-i.x,n=r.y-i.y,a=Math.hypot(o,n)||1;return{x:o/a,y:n/a}}function yp(t){let{coordinateMode:r,flowSpeed:o,links:n,maxParticles:a,nodeIdAccessor:s,nodeXAccessor:l,nodeYAccessor:c,nodes:u,particleRadius:d,particleRate:h,pathAccessor:f,pathConstraint:p="path",reducedMotion:g,seed:m,size:y,sourceAccessor:x,targetAccessor:b,throughputAccessor:v}=t,w=k(y),A=Oe(m),L=/* @__PURE__ */new Map,P=/* @__PURE__ */new Map,I=[];function R(e){if(e&&"object"==typeof e){let t=e;if("function"==typeof s){let e=s(t,0);if(null!=e)return String(e)}if("string"==typeof s&&null!=t[s])return String(t[s]);if(null!=t.id)return String(t.id)}return String(e??"unknown")}u.forEach((e,t)=>{let i=String(M(e,t,s)??e.id??t),r=$(M(e,t,l)),o=$(M(e,t,c));if(null!=r&&null!=o){let e={x:r,y:o};L.set(i,e),I.push(e)}P.set(i,String(e.label??e.name??i))});let T=[];n.forEach((e,t)=>{let i=R(M(e,t,x)),r=R(M(e,t,b)),o=Math.max(0,$(M(e,t,v))??0),n=dp(f?M(e,t,f):void 0),a=n.length?n:dp(e.path??e.points??e.route);a.forEach(e=>I.push(e)),T.push({id:String(e.id??`physical-flow-${i}-${r}-${t}`),link:e,index:t,source:i,target:r,throughput:o,rawPath:a})});let C=hp(r,I),N=/* @__PURE__ */new Map;for(let[e,t]of L)N.set(e,fp(t,w,C));let F=[];for(let e of T){let t=e.rawPath.map(e=>fp(e,w,C));if(t.length>=2)N.has(e.source)||N.set(e.source,t[0]),N.has(e.target)||N.set(e.target,t[t.length-1]);else{let i=N.get(e.source),r=N.get(e.target);i&&r&&(t=[i,r])}t.length<2||e.throughput<=0||(P.has(e.source)||P.set(e.source,e.source),P.has(e.target)||P.set(e.target,e.target),F.push({...e,path:t,packetCount:0}))}let z=e(h,.12),E=Math.max(1,Math.round(a)),D=F.map(e=>Math.max(1,Math.round(e.throughput*z))),O=D.reduce((e,t)=>e+t,0),j=O>E?E/O:1;F.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(D[t]*j))});let W=F.reduce((e,t)=>e+t.packetCount,0);for(;W>E;){let e=F.reduce((e,t,i)=>t.packetCount<=1?e:-1===e||t.packetCount>F[e].packetCount?i:e,-1);if(-1===e)break;F[e].packetCount-=1,W-=1}let B=/* @__PURE__ */new Map,Y=/* @__PURE__ */new Map,G=[],X=e(o,90),V=e(d,4);F.forEach((e,t)=>{B.set(e.target,(B.get(e.target)??0)+e.throughput),Y.set(e.source,(Y.get(e.source)??0)+e.throughput);let i=pp(e.path);for(let r=0;r<e.packetCount;r+=1){let o=(r+.5)/e.packetCount,n=g?o:_(.12+.84*o+.04*(A()-.5),.04,.98),a=g?n:Math.max(0,n-(.18+.12*A())),s=gp(e.path,a),l=gp(e.path,n),c=mp(e.path,a),u={x:-c.y,y:c.x},d=(A()-.5)*V*1.5,h=`${e.id}-packet-${r}`;G.push({id:h,x:s.x+u.x*d,y:s.y+u.y*d,vx:g?0:c.x*X+10*(A()-.5),vy:g?0:c.y*X+10*(A()-.5),mass:.8,spawnAt:g?0:.04*t+r/32,shape:{type:"circle",radius:V},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:r,packetCount:e.packetCount,routeProgress:n,flowPath:e.path,flowPathLength:i,flowRouteId:e.id,flowSpeed:X,sourceLabel:P.get(e.source)??e.source,targetLabel:P.get(e.target)??e.target},springs:"none"!==p&&g?[{target:{type:"point",x:l.x,y:l.y},restLength:.7*V,stiffness:26,damping:4.25}]:void 0})}});let q=Math.max(18,5*V),H=Array.from(N,([e,t])=>({nodeId:e,label:P.get(e)??e,sensorId:`physical-flow-node-${i(e)}`,point:t})),U=H.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:q,height:q}})),Z=Object.fromEntries(H.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),Q=[...J({x:w.plot.x,y:w.plot.y,width:w.plot.width,height:w.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...U],K=S(m,Q,"PacketFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*V),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});K.bodyLimit=E,K.eviction="oldest",K.observation={...K.observation,sensors:Z};let ee=Array.from(N,([e,t])=>({id:e,label:P.get(e)??e,x:t.x,y:t.y,sensorId:`physical-flow-node-${i(e)}`,incoming:B.get(e)??0,outgoing:Y.get(e)??0})),te=F.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:P.get(e.source)??e.source,targetLabel:P.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:K,initialSpawns:G,projectionRows:ee.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:C,particleCount:G.length,totalThroughput:F.reduce((e,t)=>e+t.throughput,0),plot:w.plot,nodes:ee,links:te}}}function xp(e,t=12){return"number"==typeof e?{x:e,y:0}:e&&"object"==typeof e?{x:Number.isFinite(e.x)?Number(e.x):t,y:Number.isFinite(e.y)?Number(e.y):0}:{x:t,y:0}}function bp(e,t){let i={id:`process-stage-${e.id}`,label:e.label??e.id,description:e.description,x:t.x,y:t.y,width:Math.max(12,.92*t.width),height:Math.max(40,.88*t.height),semanticItem:!1,attributes:{stageId:e.id}};if(e.absorb)return ge({...i,kind:e.kind??"sink",force:xp(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...i.attributes,primitive:"absorb"}});if(e.portal){let t=e.portal.force??e.force??{x:-40,y:0};return fe({...i,kind:e.kind??"force-field",force:xp(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:e.portal.targetStageId}})}if(e.capacity){let t=Math.max(.1,e.capacity.unitsPerSecond);return de({...i,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:xp(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...i.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){let t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return ce({...i,kind:e.kind??"membrane",pressure:t.pressure,occupancy:t.occupancy,baseDamping:t.baseDamping??e.damping??.1,dampingPerUnit:t.dampingPerUnit??.1,energyPerUnit:t.energyPerUnit??0,force:xp(e.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?se({...i,kind:e.kind??"force-field",force:xp(e.force,14),damping:e.damping??.02,attributes:{...i.attributes,primitive:"routeSurface"}}):ye({...i,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...i.attributes,primitive:"forceField"}})}function vp(e){let t=e.stages;if(!t.length)throw new Error("buildProcessFlowPhysics requires at least one stage");let i=e.size,r=k(i),o=_(e.ballRadius??6,2,18),n=e.seed??1,a=Oe(n),s=e.idAccessor,l=e.stageAccessor??"stage",c=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,f=e.groupCompletion??(c?"allAbsorbed":"none"),p=e.springStiffness??.28,g=e.springDamping??.72,m=!0===e.settle,y=t.map(e=>({id:e.id,label:e.label??e.id,description:e.description,share:e.share})),x=re({width:i[0],height:i[1],shape:"lane",padX:Math.max(28,r.plot.x),padY:Math.max(36,r.plot.y+8),stages:y,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((e,t)=>[e.id,t])),v=new Map(x.stages.map(e=>[e.id,e])),w=x.stages[0].id,A=x.stages[0],S=new Set(t.filter(e=>e.absorb).map(e=>e.id)),L=t.map(e=>{let t=v.get(e.id)??A;return bp(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});L.unshift(se({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(x.left+x.right)/2,y:x.midY,width:x.right-x.left,height:x.bottomY-x.topY-12,force:8,damping:.012,semanticItem:!1}));let P=/* @__PURE__ */new Map;for(let e of x.stages)P.set(e.id,0);let I=[];e.data.forEach((e,t)=>{let i=String(s?M(e,t,s)??e.id??`process-flow-${t}`:e.id??`process-flow-${t}`),r=String(M(e,t,l)??w),n=b.has(r)?r:w;P.set(n,(P.get(n)??0)+1);let a=c?String(M(e,t,c)??""):void 0,f=a&&u?String(M(e,t,u)??a):a,p=d?$(M(e,t,d))??1:1,g=h?$(M(e,t,h)):null,m=_(null!=g&&g>0?g:o,2,18);I.push({datum:e,id:i,stageId:n,groupId:a||void 0,groupLabel:f||void 0,work:p,radius:m,index:t})});let R=/* @__PURE__ */new Map,T=/* @__PURE__ */new Map;for(let e of I){if(!e.groupId)continue;let t=R.get(e.groupId)??[];t.push(e.id),R.set(e.groupId,t),e.groupLabel&&T.set(e.groupId,e.groupLabel)}let C=_(e.groupAnchorAlong??.55,.15,.9),N=x.left+(x.right-x.left)*C,F=Array.from(R.keys()),z=F.map((e,i)=>{let r=R.get(e)??[],o=F.length<=1?x.midY:x.topY+28+i/Math.max(1,F.length-1)*(x.bottomY-x.topY-56);return be({id:e,label:T.get(e)??e,bodyIds:r,anchor:{x:N,y:o},x:N,y:o,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),E=I.filter(e=>S.has(e.stageId)).map(e=>e.id),D=ie(z,E),O=new Map(z.map(e=>[e.id,e])),j=I.map((e,t)=>{let i=v.get(e.stageId)??A,r=i.x+(a()-.5)*Math.min(24,.2*i.width),o=x.boundaryY(r,"top")+e.radius+10,n=x.boundaryY(r,"bottom")-e.radius-10,s=n<=o?x.midY:o+a()*Math.max(1,n-o),l=m?r:x.left+18+t%7*4,c=m?s:x.midY+(a()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:r,y:s},restLength:.45*e.radius,stiffness:p,damping:g}];if(e.groupId){let t=O.get(e.groupId);t?.anchor&&!S.has(e.stageId)&&u.push({target:{type:"point",x:t.anchor.x,y:t.anchor.y},restLength:t.tether?.restLength??22,stiffness:t.tether?.stiffness??.05,damping:.8})}return{id:e.id,x:l,y:c,vx:m?0:40+40*a(),vy:m?0:20*(a()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:m?0:.03*t,springs:u,datum:{...e.datum,id:e.id,stage:e.stageId,groupId:e.groupId,groupLabel:e.groupLabel,work:e.work,__processFlow:!0}}}),W={kernel:{seed:n,gravity:{x:e.gravityX??22,y:e.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},B=x.stages.map(e=>({label:e.label??e.id,value:P.get(e.id)??0})),Y=t.map(e=>{let t=v.get(e.id)??A;return{id:e.id,label:e.label??e.id,x:t.x,width:t.width,count:P.get(e.id)??0,capacity:e.capacity?.unitsPerSecond,absorb:!0===e.absorb,portalTarget:e.portal?.targetStageId}});return{config:W,initialSpawns:j,initialSpawnPacing:m?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:B,metadata:{kind:"process-flow",plot:r.plot,volume:x,stages:Y,groups:z,groupCompletion:D,regionEffects:L}}}import{scaleLinear as wp}from"d3-scale";function kp(e,t,i){return Ci(e,t,i)}function Ap(e,t){let i=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>i&&Oi(i,e)||"#4e79a7":t=>{if(i){let e=Oi(i,t);if(e)return e}let r=0;for(let e=0;e<t.length;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}function Sp(e,t,i){let r=e?.observation;return{...e,observation:{...r,chartId:t??r?.chartId??"physics-custom",chartType:r?.chartType??"PhysicsCustomChart",onObservation:i??r?.onObservation}}}function Mp(e,t){let i=t.config??{},r=(t.sensors??[]).map(e=>({...e,sensor:!0})),o=[...t.colliders??[],...r],n=[...e.colliders??[],...i.colliders??[],...o];return{...e,...i,observation:{...e.observation,...i.observation},...n.length>0&&{colliders:n}}}function $p(e,t){if(!t?.length)return e;let i=/* @__PURE__ */new Map;for(let e of t){let{bodyId:t,...r}=e,o=i.get(t)??[];o.push(r),i.set(t,o)}return e.map(e=>{let t=i.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}function _p(e){let t=Sp(e.config,e.chartId,e.onObservation),i=kp(e.colorScheme,e.themeCategorical,fi),r=k(e.size),o={data:e.data,scales:{x:wp().domain(e.xExtent??[0,1]).range([r.plot.x,r.plot.x+r.plot.width]),y:wp().domain(e.yExtent??[0,1]).range([r.plot.y+r.plot.height,r.plot.y])},dimensions:r,theme:{semantic:e.semantic,categorical:[...i]},resolveColor:Ap(i,e.colorScheme),config:e.layoutConfig??{},world:new te(t)},n=e.skipLayout?{}:e.layout(o)??{},a=$p([...n.initialSpawns??n.bodies??[]],n.constraints);return{config:Mp(t,n),context:o,initialSpawnPacing:n.initialSpawnPacing,initialSpawns:a,result:n}}function Lp(e){let t=Np(e);return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:t.left,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:e.width-t.rightInset,y2:t.top,thickness:t.thickness}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:e.floorY,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-t.rightInset,y1:t.top,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}}]}function Pp(e,t,i,r){return i?"function"==typeof i?i(e,t):e[i]??r:r}function Ip(e){return`gauntlet:${e}:core`}function Rp(e,t){return`gauntlet:${e}:positive:${t}`}function Tp(e,t,i){return`gauntlet:${e}:negative:${t}:${i}`}var Cp={left:28,top:76,rightInset:30,thickness:8};function Np(e){let t=e.height??e.floorY+36;if(!(e.width<220||t<160))return Cp;let i=Math.max(1,Math.min(e.width,t)),r=Math.max(2,.04*e.width);return{left:r,top:Math.max(2,.08*t),rightInset:r,thickness:Math.max(1,Math.min(4,.04*i))}}function Fp(e){let t=e.height??e.floorY+36;return Math.max(.12,Math.min(1,e.width/500,t/260))}function zp(e,t,i,r){let o=Np(r),n=Math.max(2,i+2),a=o.left+o.thickness/2+n,s=r.width-o.rightInset-o.thickness/2-n,l=o.top+o.thickness/2+n,c=r.floorY-n,u=(e,t,i)=>t<=i?Math.max(t,Math.min(i,e)):(t+i)/2;return{x:u(e,a,s),y:u(t,l,c)}}function Ep(e,t,i){let[r,o]=e,n=r<220||o<160,a=Math.round(.48*o),s=n?o-Math.max(3,Math.min(12,.1*o)):o-36,l=(t??[]).filter(e=>!1!==e.enabled),c=Math.max(1,l.length),u=.22*r,d=c<=1?0:(.78*r-u)/(c-1),h=n?Math.max(Math.round(.12*r),.08*r+6):Math.max(Math.round(.14*r),110);return{crashY:s-(n?Math.min(i,Math.max(3,.22*o)):i),floorY:s,gates:l.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(u+t*d),width:e.width??Math.max(n?8:54,Math.round(.07*r))})),graveyardX:Math.round(r*(n?.72:.84)),graveyardY:s-4,height:o,routeY:a,socketX:Math.round(r*(n?.82:.92)),startX:h,width:r}}function Dp(e){return{graveyardX:e.graveyardX,graveyardY:e.graveyardY,routeY:e.routeY,socketX:e.socketX,socketY:e.routeY-4,startX:e.startX,startY:e.routeY}}function Op(e,t,i,r){let o=Dp(i),n=r?.(e,t,i)??{};return{...o,...n,startY:n.startY??n.routeY??o.startY,socketY:n.socketY??n.routeY??o.socketY,graveyardY:n.graveyardY??o.graveyardY}}function jp(e,t,i=1){let r=[...e].sort((e,t)=>e.localeCompare(t)),o=Math.max(0,r.indexOf(t)),n=r.length>1?o/(r.length-1):.5;return{angle:.82*-Math.PI+n*Math.PI*.64,index:o,radius:(48+o%2*6)*i}}function Wp(e,t,i){let r=e.activePositiveIds.reduce((e,i)=>e+(t.get(i)?.value??1),0),o=e.missingPositiveIds.length+e.poppedPositiveIds.length,n=e.negativeIds.reduce((e,t)=>e+(i.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*r-8*n-1.2*e.delay-5*o))}function Bp(e,t,i,r,o){let n=String(Pp(e,t,i.idAccessor,null!=e.id?String(e.id):`project-${t}`)),a=r.map(e=>e.id),s=[...Pp(e,t,i.positiveAccessor,a)],l=[...Pp(e,t,i.negativeAccessor,[])].filter(e=>o.has(e));return{id:n,activePositiveIds:s,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Pp(e,t,i.metricsAccessor,{})},missingPositiveIds:a.filter(e=>!s.includes(e)),negativeIds:l,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Pp(e,t,i.startTimeAccessor,0))||0),stage:"project filed",viability:Pp(e,t,i.initialViability,100)}}function Yp(e,t,i,r,o,n,a){let s=Fp(i),l=Math.max(3,28*s),c=r.startX,u=r.startY+(r.startY===i.routeY?38*t*s:0),d=a?.(e,t,i,r)??{},h=d.x??c,f=d.y??u,p={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},g=[{...d,id:Ip(e.id),x:h,y:f,vx:d.vx??42,vy:d.vy??0,mass:d.mass??7,bodyCollisions:d.bodyCollisions??!0,shape:d.shape??{type:"circle",radius:l},spawnAt:d.spawnAt??e.startedAt,datum:p}],m=zp(h,f,d.shape&&"radius"in d.shape&&Number(d.shape.radius)||l,i);g[0].x=m.x,g[0].y=m.y;for(let t of e.activePositiveIds){let r=o.get(t);if(!r)continue;let n=jp(e.activePositiveIds,t,s),a=r.radius??Math.max(2,10*s),l=zp(m.x+Math.cos(n.angle)*n.radius,m.y+Math.sin(n.angle)*n.radius,a,i);g.push({id:Rp(e.id,t),x:l.x,y:l.y,vx:18*Math.cos(n.angle),vy:18*Math.sin(n.angle),mass:r.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:d.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:e.id,property:r,sourceDatum:e.datum},springs:!1===r.spring?[]:[{target:{type:"body",bodyId:Ip(e.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+n.index%2*4)*s),...r.spring??{}}]})}return e.negativeIds.forEach((t,r)=>{let o=n.get(t);o&&g.push(Xp(e,o,r,m.x,m.y,i,d.spawnAt??e.startedAt))}),g}function Gp(e){let t=Ep(e.size??[900,520],e.gates,e.crashOffset??30),i=e.positiveProperties??[],r=new Map(i.map(e=>[e.id,e])),o=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),n={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},a=(e.data??[]).map((t,a)=>{let s=Bp(t,a,n,i,o);return{...s,viability:e.viability?.(s,{negativeProperties:o,positiveProperties:r})??Wp(s,r,o)}}),s=a.flatMap((i,n)=>{let a=Op(i,n,t,e.projectPlacement);return Yp(i,n,t,a,r,o,e.coreBody)});return{layout:t,states:a,initialSpawns:s,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:Lp(t)}}}function Xp(e,t,i,r,o,n,a){let s=Fp(n),l=t.radius??Math.max(2,7.2*s),c=zp(r+(i%4*12-12)*s,o+(54+12*Math.floor(i/4))*s,l,n);return{id:Tp(e.id,t.id,i),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:l},spawnAt:a,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:Ip(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+i%4*3)*s),...t.spring??{}}]}}function Vp(e=[]){let t=/* @__PURE__ */Object.create(null);for(let[i,r]of e)t[i]=r;return t}function qp(...e){let t=Vp();for(let i of e)for(let[e,r]of Object.entries(i??{}))t[e]=r;return t}function Hp(e){return qp(e)}function Up(e){return e.map(e=>({...e,sourceIds:e.sourceIds?[...e.sourceIds]:void 0,productIds:e.productIds?[...e.productIds]:void 0,relationIds:e.relationIds?[...e.relationIds]:void 0,outletIds:e.outletIds?[...e.outletIds]:void 0}))}function Zp(e){let t=Vp(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:Hp(t.initialMetrics),metrics:Hp(t.metrics),productIds:[...t.productIds],history:Up(t.history)}])),i=Vp(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:Hp(t.metrics),sourceIds:[...t.sourceIds],history:Up(t.history)}])),r=Vp(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?Hp(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:i,relations:r,input:{amount:e.input.amount,metrics:Hp(e.input.metrics)},metrics:Hp(e.metrics),loss:{amount:e.loss.amount,metrics:Hp(e.loss.metrics)},history:Up(e.history)}}var Qp=1e-9;function Kp(e,t){return e<t?-1:e>t?1:0}function Jp(e,t,i,r,o){return{severity:e,code:t,message:i,path:r,ids:o?[...o]:void 0}}function eg(e){let t=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(let r of e)t.has(r)&&i.add(r),t.add(r);return[...i].sort(Kp)}function tg(e,t){return e?Object.entries(e).flatMap(([e,i])=>Number.isFinite(i)?[]:[Jp("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function ig(e,t){for(let[i,r]of Object.entries(t))e[i]=Number(e[i]??0)+r}function rg(e){let t=Vp();for(let i of e)ig(t,i.metrics);return t}function og(e,t,i="selector"){let r=[],o=Object.values(e.components),n=new Set(o.map(e=>e.id)),a=(t.ids??[]).filter(e=>!n.has(e));if(a.length&&r.push(Jp("error","unknown-component",`Selector references unknown component id${1===a.length?"":"s"}: ${a.join(", ")}.`,`${i}.ids`,a)),void 0!==t.count&&(!Number.isInteger(t.count)||t.count<0)&&r.push(Jp("error","invalid-selector-count","Selector count must be a non-negative integer.",`${i}.count`)),r.some(e=>"error"===e.severity))return{ids:[],diagnostics:r};let s=t.ids?new Set(t.ids):null,l=t.categories?new Set(t.categories):null,c=t.statuses?new Set(t.statuses):null,u=t.outletIds?new Set(t.outletIds):null,d=o.filter(e=>!s||s.has(e.id)).filter(e=>!l||l.has(e.category)).filter(e=>!c||c.has(e.status)).filter(e=>!u||void 0!==e.outletId&&u.has(e.outletId)).map(e=>e.id).sort(Kp);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||r.push(Jp("warning","empty-selector","Selector matched no source components.",i)),{ids:d,diagnostics:r}}function ng(e,t,i={}){return{eventId:e.event.id,effectType:t.type,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,label:e.event.label,summary:e.event.summary,...i}}function ag(e,t){let i={...t,eventId:e.event.id};e.materializations.push(i),e.observations.push({...i,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt})}function sg(e,t,i){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(Jp("error","unknown-outlet",`Unknown outlet "${t}".`,i,[t])),1))}function lg(e,t,i){let r=eg(t);t.length||e.diagnostics.push(Jp("error","empty-source-list","A product requires at least one source component.",i)),r.length&&e.diagnostics.push(Jp("error","duplicate-source",`Source ids may appear only once: ${r.join(", ")}.`,i,r));let o=t.filter(t=>!e.state.components[t]);o.length&&e.diagnostics.push(Jp("error","unknown-component",`Unknown source component id${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o));let n=t.filter(t=>(e.state.components[t]?.productIds.length??0)>0);n.length&&e.diagnostics.push(Jp("error","source-already-assigned",`Source component${1===n.length?" is":"s are"} already assigned: ${n.join(", ")}.`,i,n));let a=t.filter(t=>"consumed"===e.state.components[t]?.status&&!n.includes(t));return a.length&&e.diagnostics.push(Jp("error","source-unavailable",`Consumed source component${1===a.length?" is":"s are"} unavailable: ${a.join(", ")}.`,i,a)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function cg(e,t,i){let r=eg(t),o=t.filter(t=>!e.state.components[t]);return t.length<2&&e.diagnostics.push(Jp("error","insufficient-relation-sources","A relation requires at least two source components.",i)),r.length&&e.diagnostics.push(Jp("error","duplicate-source",`Relation source ids must be unique: ${r.join(", ")}.`,i,r)),o.length&&e.diagnostics.push(Jp("error","unknown-component",`Relation references unknown source component${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function ug(e,t,i,r,o){let n=r?.amount??0;(!Number.isFinite(n)||n<0||n>t+Qp)&&e.diagnostics.push(Jp("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",`${o}.amount`)),e.diagnostics.push(...tg(r?.metrics,`${o}.metrics`));for(let[t,n]of Object.entries(r?.metrics??{}))(n<0||n>Number(i[t]??0)+Qp)&&e.diagnostics.push(Jp("error","invalid-metric-loss",`Metric loss "${t}" must be non-negative and no greater than its sources.`,`${o}.metrics.${t}`));return!e.diagnostics.some(e=>"error"===e.severity)}function dg(e,t,i,r){if(!t?.length)return[];let o=eg(t),n=t.filter(t=>!e.state.relations[t]),a=t.filter(t=>"resolved"===e.state.relations[t]?.status),s=new Set(i),l=t.filter(t=>(e.state.relations[t]?.sourceIds??[]).some(e=>!s.has(e)));return o.length&&e.diagnostics.push(Jp("error","duplicate-relation","Basis relations must be unique.",r,o)),n.length&&e.diagnostics.push(Jp("error","unknown-relation",`Unknown basis relation: ${n.join(", ")}.`,r,n)),a.length&&e.diagnostics.push(Jp("error","resolved-relation",`Basis relation is already resolved: ${a.join(", ")}.`,r,a)),l.length&&e.diagnostics.push(Jp("error","relation-source-mismatch",`Basis relation includes a source outside this product: ${l.join(", ")}.`,r,l)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.relations[t])}function hg(e,t){if(t.length){for(let i of t)i.status="resolved",i.resolution="combined",i.resolvedByEventId=e.event.id,i.resolvedAt=e.context.appliedAt;ag(e,{type:"resolve-relation",relationIds:t.map(e=>e.id)})}}function fg(e,t,i){e.state.loss.amount+=i?.amount??0;for(let[r,o]of Object.entries(i?.metrics??{}))t[r]=Number(t[r]??0)-o,e.state.loss.metrics[r]=Number(e.state.loss.metrics[r]??0)+o}function pg(e,t,i,r,o,n,a){let s=n&&void 0!==e.amount?e.amount:i;return{id:e.id,label:e.label??e.id,description:e.description,category:e.category??"product",color:e.color,order:e.order,declaredAmount:e.amount,amount:s,metrics:n&&e.metrics?qp(r,e.metrics):Hp(r),status:n?"complete":"forming",sourceIds:[...t],outletId:n?e.outletId??(o.outletIds.has("product")?"product":void 0):void 0,createdByEventId:o.event.id,createdAt:o.context.appliedAt,completedByEventId:n?o.event.id:void 0,completedAt:n?o.context.appliedAt:void 0,history:[a]}}function gg(e,t,i,r){void 0!==t.amount&&Math.abs(t.amount-i)>Qp&&e.diagnostics.push(Jp("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${i}.`,r,[t.id]))}function mg(e,t,i,r,o,n){let a=e.productDefinitions.get(t.id),s=i??a?.outletId??(e.outletIds.has("product")?"product":void 0);if(!sg(e,s,`${n}.outletId`))return;if("complete"===t.status)return void e.diagnostics.push(Jp("error","product-already-complete",`Product "${t.id}" is already complete.`,n,[t.id]));a&&(gg(e,a,t.amount,`${n}.productId`),void 0!==a.amount&&(t.amount=a.amount),a.metrics&&(t.metrics=qp(t.metrics,a.metrics))),t.status="complete",t.outletId=s,t.reason=r,t.completedByEventId=e.event.id,t.completedAt=e.context.appliedAt;let l=ng(e,o,{sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:s?[s]:void 0});t.history.push(l),e.state.history.push(l),ag(e,{type:"complete-product",sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:s?[s]:void 0})}function yg(e,t,i){let r=`events.${e.event.id}.effects.${i}`,o=e.state;if("set-state"===t.type){["queued","active","transformed","retained","ejected","failed","recovered"].includes(t.state)||e.diagnostics.push(Jp("error","invalid-component-state",`set-state cannot assign "${String(t.state)}".`,`${r}.state`)),e.diagnostics.push(...tg(t.metricsDelta,`${r}.metricsDelta`)),sg(e,t.outletId,`${r}.outletId`);let i=og(o,t.select,`${r}.select`);e.diagnostics.push(...i.diagnostics);let n=i.ids.filter(e=>o.components[e].productIds.length);if(n.length&&e.diagnostics.push(Jp("error","source-already-assigned",`Assigned source components cannot be retargeted: ${n.join(", ")}.`,`${r}.select`,n)),e.diagnostics.some(e=>"error"===e.severity))return;let a=ng(e,t,{sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0});for(let e of i.ids){let i=o.components[e];i.status=t.state,i.outletId=t.outletId,i.reason=t.reason,t.metricsDelta&&ig(i.metrics,t.metricsDelta),i.history.push(a)}return o.history.push(a),void(i.ids.length&&ag(e,{type:"retarget-component",sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0}))}if("set-relation"===t.type){let{relation:i}=t;(!i.id||o.relations[i.id])&&e.diagnostics.push(Jp("error","duplicate-relation",`Relation id "${i.id}" is missing or already active.`,`${r}.relation.id`,[i.id]));let n=cg(e,i.sourceIds,`${r}.relation.sourceIds`);if(e.diagnostics.push(...tg(i.metrics,`${r}.relation.metrics`)),!n||e.diagnostics.some(e=>"error"===e.severity))return;o.relations[i.id]={...i,sourceIds:[...i.sourceIds],metrics:i.metrics?Hp(i.metrics):void 0,status:"active",createdByEventId:e.event.id,createdAt:e.context.appliedAt};let a=ng(e,t,{sourceIds:[...i.sourceIds],relationIds:[i.id]});return o.history.push(a),void ag(e,{type:"activate-relation",sourceIds:[...i.sourceIds],relationIds:[i.id]})}if("resolve-relation"===t.type){let i=eg(t.relationIds),n=t.relationIds.filter(e=>!o.relations[e]),a=t.relationIds.filter(e=>"resolved"===o.relations[e]?.status);if(i.length&&e.diagnostics.push(Jp("error","duplicate-relation","Relation ids must be unique.",`${r}.relationIds`,i)),n.length&&e.diagnostics.push(Jp("error","unknown-relation",`Unknown relation: ${n.join(", ")}.`,`${r}.relationIds`,n)),a.length&&e.diagnostics.push(Jp("error","resolved-relation",`Relation is already resolved: ${a.join(", ")}.`,`${r}.relationIds`,a)),e.diagnostics.some(e=>"error"===e.severity))return;for(let i of t.relationIds){let r=o.relations[i];r.status="resolved",r.resolution=t.resolution,r.resolvedByEventId=e.event.id,r.resolvedAt=e.context.appliedAt,r.reason=t.reason}let s=ng(e,t,{relationIds:[...t.relationIds]});return o.history.push(s),void ag(e,{type:"resolve-relation",relationIds:[...t.relationIds]})}if("combine"===t.type||"contribute"===t.type){let i=e.productDefinitions.get(t.productId);i||e.diagnostics.push(Jp("error","unknown-product",`Product "${t.productId}" has no declared mold.`,`${r}.productId`,[t.productId]));let n=o.products[t.productId];"combine"===t.type&&n&&e.diagnostics.push(Jp("error","duplicate-product",`Product "${t.productId}" has already been formed.`,`${r}.productId`,[t.productId])),"contribute"===t.type&&(!n||"forming"!==n.status)&&e.diagnostics.push(Jp("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,`${r}.productId`,[t.productId]));let a=lg(e,t.sourceIds,`${r}.sourceIds`),s="contribute"===t.type&&n?[...n.sourceIds,...t.sourceIds]:t.sourceIds,l=dg(e,t.basisRelationIds,s,`${r}.basisRelationIds`);if(!a||!l||!i||e.diagnostics.some(e=>"error"===e.severity))return;let c=a.reduce((e,t)=>e+t.amount,0),u=rg(a);if(!ug(e,c,u,t.loss,`${r}.loss`))return;let d=c-(t.loss?.amount??0);fg(e,u,t.loss);let h,f="combine"===t.type&&!1!==t.complete,p=ng(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});if("combine"===t.type){if(f&&gg(e,i,d,`${r}.productId`),h=pg(i,t.sourceIds,d,u,e,f,p),f&&!sg(e,h.outletId,`${r}.productId`))return;o.products[t.productId]=h}else h=n,h.sourceIds.push(...t.sourceIds),h.amount+=d,ig(h.metrics,u),h.history.push(p);for(let e of a)e.productIds=[t.productId],e.status="consumed",e.outletId=void 0,e.history.push(p);return o.history.push(p),hg(e,l),ag(e,{type:"combine"===t.type?"form-product":"update-product",sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0,outletIds:h.outletId?[h.outletId]:void 0}),void(f&&ag(e,{type:"complete-product",sourceIds:[...h.sourceIds],productIds:[h.id],outletIds:h.outletId?[h.outletId]:void 0}))}if("complete-product"===t.type){let i=o.products[t.productId];return i?void mg(e,i,t.outletId,t.reason,t,r):void e.diagnostics.push(Jp("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,`${r}.productId`,[t.productId]))}if("split"===t.type){let i=lg(e,[t.sourceId],`${r}.sourceId`);t.products.length||e.diagnostics.push(Jp("error","empty-split","A split requires at least one product allocation.",`${r}.products`));let n=t.products.map(e=>e.productId),a=eg(n);a.length&&e.diagnostics.push(Jp("error","duplicate-product","Split product ids must be unique.",`${r}.products`,a));let s=n.map(t=>e.productDefinitions.get(t)),l=n.filter((e,t)=>!s[t]),c=n.filter(e=>o.products[e]);l.length&&e.diagnostics.push(Jp("error","unknown-product",`Split references undeclared product molds: ${l.join(", ")}.`,`${r}.products`,l)),c.length&&e.diagnostics.push(Jp("error","duplicate-product",`Split products already exist: ${c.join(", ")}.`,`${r}.products`,c));for(let[i,o]of t.products.entries())void 0!==o.amount&&(!Number.isFinite(o.amount)||o.amount<0)&&e.diagnostics.push(Jp("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${r}.products.${i}.amount`)),e.diagnostics.push(...tg(o.metrics,`${r}.products.${i}.metrics`));if(!i?.length||e.diagnostics.some(e=>"error"===e.severity))return;let u=i[0];if(!ug(e,u.amount,u.metrics,t.loss,`${r}.loss`))return;let d=u.amount-(t.loss?.amount??0),h=t.products.map((e,t)=>e.amount??s[t]?.amount),f=h.filter(e=>void 0!==e).length;if(0!==f&&f!==h.length)return void e.diagnostics.push(Jp("error","partial-split-allocation","Either every split product must declare an amount or none may do so.",`${r}.products`));let p=f?h:t.products.map(()=>d/t.products.length),g=p.reduce((e,t)=>e+t,0);if(Math.abs(g-d)>Qp)return void e.diagnostics.push(Jp("error","split-amount-mismatch",`Split allocations total ${g}, but ${d} remains after loss.`,`${r}.products`));let m=Hp(u.metrics);for(let[e,i]of Object.entries(t.loss?.metrics??{}))m[e]=Number(m[e]??0)-i;let y=ng(e,t,{sourceIds:[u.id],productIds:n});if(t.products.forEach((i,n)=>{let a=s[n],l=d>Qp?p[n]/d:1/t.products.length,c=Vp(Object.entries(m).map(([e,t])=>[e,t*l])),h=i.metrics??a.metrics??c,f=pg({...a,amount:p[n],metrics:h},[u.id],p[n],Hp(h),e,!0,y);sg(e,f.outletId,`${r}.products.${n}.productId`)&&(o.products[f.id]=f)}),e.diagnostics.some(e=>"error"===e.severity))return;u.productIds=n,u.status="consumed",u.outletId=void 0,u.history.push(y),o.loss.amount+=t.loss?.amount??0;for(let[e,i]of Object.entries(t.loss?.metrics??{}))o.loss.metrics[e]=Number(o.loss.metrics[e]??0)+i;o.history.push(y),ag(e,{type:"split-source",sourceIds:[u.id],productIds:n});for(let t of n)ag(e,{type:"complete-product",sourceIds:[u.id],productIds:[t],outletIds:o.products[t].outletId?[o.products[t].outletId]:void 0});return}if("eject"===t.type){sg(e,t.outletId,`${r}.outletId`);let i=og(o,t.select,`${r}.select`);e.diagnostics.push(...i.diagnostics);let n=i.ids.filter(e=>o.components[e].productIds.length);if(n.length&&e.diagnostics.push(Jp("error","source-already-assigned",`Assigned source components cannot be ejected: ${n.join(", ")}.`,`${r}.select`,n)),e.diagnostics.some(e=>"error"===e.severity))return;let a=ng(e,t,{sourceIds:i.ids,outletIds:[t.outletId]});for(let e of i.ids){let i=o.components[e];i.status=t.state??"ejected",i.outletId=t.outletId,i.reason=t.reason,i.history.push(a)}return o.history.push(a),void(i.ids.length&&ag(e,{type:"retarget-component",sourceIds:i.ids,outletIds:[t.outletId]}))}if("set-metric"===t.type){if(e.diagnostics.push(...tg(t.metricsDelta,`${r}.metricsDelta`)),e.diagnostics.some(e=>"error"===e.severity))return;let i,n;if("run"===t.target)ig(o.metrics,t.metricsDelta);else if("components"in t.target){let n=og(o,t.target.components,`${r}.target.components`);if(e.diagnostics.push(...n.diagnostics),e.diagnostics.some(e=>"error"===e.severity))return;i=n.ids;for(let e of n.ids)ig(o.components[e].metrics,t.metricsDelta)}else{n=[...t.target.productIds];let i=eg(n),a=n.filter(e=>!o.products[e]);if(i.length&&e.diagnostics.push(Jp("error","duplicate-product","Metric target product ids must be unique.",`${r}.target.productIds`,i)),a.length&&e.diagnostics.push(Jp("error","unknown-product-state",`Metric target product has not formed: ${a.join(", ")}.`,`${r}.target.productIds`,a)),e.diagnostics.some(e=>"error"===e.severity))return;for(let e of n)ig(o.products[e].metrics,t.metricsDelta)}return void o.history.push(ng(e,t,{sourceIds:i,productIds:n}))}t.outcome.trim()?(o.outcome=t.outcome,o.summary=t.summary,o.history.push(ng(e,t)),e.observations.push({type:"crucible-outcome",eventId:e.event.id,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,outcome:t.outcome})):e.diagnostics.push(Jp("error","invalid-outcome","Outcome must be a non-empty string.",`${r}.outcome`))}function xg(e,t,i){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[Jp("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,`events.${t.id}`,[t.id])]};let r=Zp(e),o={state:r,event:t,context:i,productDefinitions:new Map(i.products.map(e=>[e.id,e])),outletIds:new Set(i.outlets.map(e=>e.id)),diagnostics:[],materializations:[],observations:[]};for(let[i,r]of t.effects.entries())if(yg(o,r,i),o.diagnostics.some(e=>"error"===e.severity))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:o.diagnostics};return r.elapsed=Math.max(r.elapsed,i.appliedAt),r.phaseId=i.phaseId,r.eventsApplied.push(t.id),o.observations.unshift({type:"crucible-event",eventId:t.id,phaseId:i.phaseId,authoredAt:i.authoredAt,appliedAt:i.appliedAt}),{applied:!0,state:r,materializations:o.materializations,observations:o.observations,diagnostics:o.diagnostics}}function bg(e,t){return"product"===t?"product"===e.kind?e.id:"unassigned":"outlet"===t?e.outletId??"unassigned":"category"===t?e.category:e.status}function vg(e,t={}){let i=t.groupBy??"outlet",r=/* @__PURE__ */new Map,o=e=>{let t=bg({...e,status:e.status??"active"},i),o=r.get(t);if(o)return o.count+=1,o.amount+=e.amount,void ig(o.metrics,e.metrics);r.set(t,{key:t,label:"product"===i&&"product"===e.kind?e.label:t,count:1,amount:e.amount,metrics:Hp(e.metrics),status:"status"===i?e.status:void 0,outletId:"outlet"===i?e.outletId:void 0,category:"category"===i?e.category:void 0,productId:"product"===i&&"product"===e.kind?e.id:void 0})};for(let t of Object.values(e.components))t.productIds.length||"consumed"===t.status||o({kind:"component",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});for(let t of Object.values(e.products))o({kind:"product",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});let n=new Map((t.order??[]).map((e,t)=>[e,t]));return[...r.values()].sort((e,t)=>(n.get(e.key)??Number.MAX_SAFE_INTEGER)-(n.get(t.key)??Number.MAX_SAFE_INTEGER)||Kp(e.key,t.key))}var wg=[900,520],kg=[{id:"product",label:"Products",side:"bottom",order:0},{id:"retained",label:"Retained",side:"bottom",order:1},{id:"residue",label:"Residue",side:"left",order:2},{id:"failed",label:"Failed",side:"right",order:3},{id:"recovered",label:"Recovered",side:"right",order:4}],Ag=/* @__PURE__ */new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),Sg=1e-9;function Mg(e,t){return e<t?-1:e>t?1:0}function $g(e,t,i,r,o){return{severity:e,code:t,message:i,path:r,ids:o?[...o]:void 0}}function _g(e){let t=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(let r of e)t.has(r)&&i.add(r),t.add(r);return[...i].sort(Mg)}function Lg(e){let t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Pg(e,t,i,r,o,n){if(!i)return r;try{return("function"==typeof i?i(e,t):e[i])??r}catch(e){return o.push($g("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:String(e)}.`,n)),r}}function Ig(e,t,i){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push($g("error","invalid-metrics","Metrics must be a numeric object.",i)),Vp();let r=Vp();for(let[o,n]of Object.entries(e)){let e=Lg(n);null!=e?r[o]=e:t.push($g("error","invalid-metric",`Metric "${o}" must be finite.`,`${i}.${o}`))}return r}function Rg(e,t){for(let[i,r]of Object.entries(t))e[i]=Number(e[i]??0)+r}function Tg(e){let t=[],i=Vp(),r=[],o=0,n=Vp();e.data.forEach((a,s)=>{let l=String(a.id??`component-${s}`),c=Pg(a,s,e.idAccessor,l,t,`data.${s}.id`),u=String(c??l).trim();if(!u)return void t.push($g("error","invalid-component-id","Component ids may not be empty.",`data.${s}.id`));r.push(u);let d=Lg(Pg(a,s,e.amountAccessor,1,t,`data.${s}.amount`)),h=null!=d&&d>=0?d:0;(null==d||d<0)&&t.push($g("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${s}.amount`,[u]));let f=Ig(Pg(a,s,e.metricsAccessor,{},t,`data.${s}.metrics`),t,`data.${s}.metrics`),p=Pg(a,s,e.initialStateAccessor,"active",t,`data.${s}.status`),g=Ag.has(p)?p:"active";Ag.has(p)||t.push($g("error","invalid-component-status",`Unknown component status "${String(p)}".`,`data.${s}.status`,[u]));let m=String(Pg(a,s,e.labelAccessor,String(a.label??a.name??u),t,`data.${s}.label`)),y=String(Pg(a,s,e.categoryAccessor,"component",t,`data.${s}.category`));Object.hasOwn(i,u)||(i[u]={id:u,label:m,category:y,datum:a,status:g,initialAmount:h,amount:h,initialMetrics:qp(f),metrics:qp(f),productIds:[],history:[]},o+=h,Rg(n,f))});let a=_g(r);a.length&&t.push($g("error","duplicate-component-id",`Component ids must be unique: ${a.join(", ")}.`,"data",a));let s=Ig(e.metrics??{},t,"metrics");return{state:{elapsed:0,phaseElapsed:0,phaseId:e.phases[0]?.id??"",phaseIndex:e.phases.length?0:-1,playing:!1,complete:0===e.phases.length,outcome:"in_process",eventsApplied:[],components:i,products:Vp(),relations:Vp(),input:{amount:o,metrics:n},metrics:s,loss:{amount:0,metrics:Vp()},history:[]},diagnostics:t}}function Cg(e){let t=[];e.length||t.push($g("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));let i=_g(e.map(e=>e.id));i.length&&t.push($g("error","duplicate-phase-id",`Phase ids must be unique: ${i.join(", ")}.`,"phases",i));let r=0;return{phases:e.map((e,i)=>{let o=Lg(e.duration),n=null!=o&&o>0?o:0;e.id.trim()||t.push($g("error","invalid-phase-id","Phase ids may not be empty.",`phases.${i}.id`)),(null==o||o<=0)&&t.push($g("error","invalid-phase-duration","Phase duration must be finite and greater than zero.",`phases.${i}.duration`,[e.id])),void 0!==e.intensity&&!Number.isFinite(e.intensity)&&t.push($g("error","invalid-phase-intensity","Phase intensity must be finite.",`phases.${i}.intensity`,[e.id]));let a={...e,duration:n,intensity:void 0===e.intensity?.5:Number.isFinite(e.intensity)?Math.max(0,Math.min(1,e.intensity)):.5,motion:e.motion??"hold",index:i,start:r,end:r+n};return r=a.end,a}),diagnostics:t}}function Ng(e,t,i){let r=e.find(e=>Math.abs(e.start-i)<=Sg);if(r)return{phase:r,boundaryRank:1};let o=e.find(e=>i>=e.start&&i<e.end);return o?{phase:o,boundaryRank:0}:Math.abs(i-t)<=Sg&&e.length?{phase:e[e.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}function Fg(e,t,i){let r=[],o=_g(e.map(e=>e.id));o.length&&r.push($g("error","duplicate-event-id",`Event ids must be unique: ${o.join(", ")}.`,"events",o));let n=[];return e.forEach((e,o)=>{let a,s,l;if(e.id.trim()||r.push($g("error","invalid-event-id","Event ids may not be empty.",`events.${o}.id`)),"time"in e.at&&void 0!==e.at.time){let n=Lg(e.at.time);if(null==n||n<0||n>i+Sg)return void r.push($g("error","event-time-out-of-range",`Event time must fall between 0 and ${i}.`,`events.${o}.at.time`,[e.id]));a=Math.max(0,Math.min(i,n));let c=Ng(t,i,a);s=c.phase,l=c.boundaryRank}else{if(s=t.find(t=>t.id===e.at.phaseId),!s)return void r.push($g("error","unknown-event-phase",`Event references unknown phase "${e.at.phaseId}".`,`events.${o}.at.phaseId`,[e.id,e.at.phaseId]));let i=e.at.progress??0;if(!Number.isFinite(i)||i<0||i>1)return void r.push($g("error","event-progress-out-of-range","Event phase progress must be between 0 and 1.",`events.${o}.at.progress`,[e.id]));a=s.start+s.duration*i,l=0===i?1:0}s?n.push({...e,index:o,authoredAt:a,phaseId:s.id,phaseIndex:s.index,boundaryRank:l}):r.push($g("error","event-without-phase","Event could not be assigned to a phase.",`events.${o}.at`,[e.id]))}),n.sort((e,t)=>e.authoredAt-t.authoredAt||e.boundaryRank-t.boundaryRank||e.index-t.index),{events:n,diagnostics:r}}function zg(e,t){let i=[],r=new Set(t.map(e=>e.id)),o=_g(t.map(e=>e.id)),n=_g(e.map(e=>e.id));return o.length&&i.push($g("error","duplicate-outlet-id",`Outlet ids must be unique: ${o.join(", ")}.`,"outlets",o)),n.length&&i.push($g("error","duplicate-product-id",`Product ids must be unique: ${n.join(", ")}.`,"products",n)),t.forEach((e,t)=>{e.id.trim()||i.push($g("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0!==e.order&&!Number.isFinite(e.order)&&i.push($g("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||i.push($g("error","invalid-product-id","Product ids may not be empty.",`products.${t}.id`)),void 0!==e.amount&&(!Number.isFinite(e.amount)||e.amount<0)&&i.push($g("error","invalid-product-amount","Declared product amount must be finite and non-negative.",`products.${t}.amount`,[e.id])),void 0!==e.outletId&&!r.has(e.outletId)&&i.push($g("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),Ig(e.metrics??{},i,`products.${t}.metrics`)}),i}function Eg(e){return e.map((e,t)=>({outlet:e,index:t})).sort((e,t)=>(e.outlet.order??e.index)-(t.outlet.order??t.index)||e.index-t.index).map(({outlet:e})=>({...e}))}function Dg(e=wg,t=kg){let i=Math.max(1,Lg(e[0])??900),r=Math.max(1,Lg(e[1])??520),o=i<360||r<260,n=o?Math.max(4,.035*Math.min(i,r)):20,a=o?Math.max(10,.075*r):34,s={x:n,y:n,width:Math.max(1,i-2*n),height:a},l=o?Math.max(16,.14*r):Math.min(78,.16*r),c={x:n,y:r-n-l,width:Math.max(1,i-2*n),height:l},u=o?Math.max(12,.08*i):Math.min(150,.17*i),d=s.y+s.height+(o?12:38),h=c.y-(o?10:34),f={x:u,y:d,width:Math.max(24,i-2*u),height:Math.max(24,h-d)},p=Math.max(18,Math.min(.32*f.width,o?84:180)),g={x:f.x+(f.width-p)/2,y:f.y-(o?10:24),width:p,height:o?12:28},m=Eg(t),y={left:m.filter(e=>"left"===(e.side??"bottom")),right:m.filter(e=>"right"===e.side),bottom:m.filter(e=>"bottom"===(e.side??"bottom"))},x=[],b=(e,t)=>{let r=Math.max(8,u-1.5*n),a=f.height/Math.max(1,t.length);t.forEach((t,s)=>{x.push({...t,side:e,x:"left"===e?n:i-n-r,y:f.y+s*a,width:r,height:Math.max(8,a-(o?2:8))})})};b("left",y.left),b("right",y.right);let v=f.width/Math.max(1,y.bottom.length);return y.bottom.forEach((e,t)=>{x.push({...e,side:"bottom",x:f.x+t*v,y:f.y+f.height+(o?2:7),width:Math.max(8,v-(o?2:8)),height:Math.max(8,c.y-f.y-f.height-(o?4:12))})}),x.sort((e,t)=>m.findIndex(t=>t.id===e.id)-m.findIndex(e=>e.id===t.id)),{width:i,height:r,phaseRail:s,chamber:f,mouth:g,projection:c,outlets:x}}function Og(e,t,i){let r=i.map(([i,r])=>[Math.max(e,Math.min(i,r)),Math.min(t,Math.max(i,r))]).filter(([e,t])=>t>e+Sg).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),o=[],n=e;for(let[e,t]of r)e>n+Sg&&o.push([n,e]),n=Math.max(n,t);return t>n+Sg&&o.push([n,t]),o}function jg(e){let{id:t,orientation:i,fixed:r,start:o,end:n,openings:a,thickness:s,friction:l,restitution:c}=e,u=Og(o,n,a);return u.map(([e,o],n)=>({id:1===u.length?t:`${t}:${n}`,friction:l,restitution:c,shape:"horizontal"===i?{type:"segment",x1:e,y1:r,x2:o,y2:r,thickness:s}:{type:"segment",x1:r,y1:e,x2:r,y2:o,thickness:s}}))}function Wg(e){let{chamber:t,mouth:i}=e,r=Math.max(2,Math.min(10,.018*Math.min(e.width,e.height))),o=Math.max(t.x,i.x),n=Math.min(t.x+t.width,i.x+i.width),a={left:e.outlets.filter(e=>"left"===e.side),right:e.outlets.filter(e=>"right"===e.side),bottom:e.outlets.filter(e=>"bottom"===e.side)},s=[{id:"crucible:wall:top-left",friction:.42,restitution:.1,shape:{type:"segment",x1:t.x,y1:t.y,x2:o,y2:t.y,thickness:r}},{id:"crucible:wall:top-right",friction:.42,restitution:.1,shape:{type:"segment",x1:n,y1:t.y,x2:t.x+t.width,y2:t.y,thickness:r}}];s.push(...jg({id:"crucible:wall:left",orientation:"vertical",fixed:t.x,start:t.y,end:t.y+t.height,openings:a.left.map(e=>[e.y,e.y+e.height]),thickness:r,friction:.46,restitution:.12}),...jg({id:"crucible:wall:right",orientation:"vertical",fixed:t.x+t.width,start:t.y,end:t.y+t.height,openings:a.right.map(e=>[e.y,e.y+e.height]),thickness:r,friction:.46,restitution:.12}),...jg({id:"crucible:wall:bottom",orientation:"horizontal",fixed:t.y+t.height,start:t.x,end:t.x+t.width,openings:a.bottom.map(e=>[e.x,e.x+e.width]),thickness:r,friction:.5,restitution:.08}));for(let t of e.outlets)s.push({id:`crucible:outlet:${encodeURIComponent(t.id)}`,sensor:!0,shape:{type:"aabb",x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height}});return s}function Bg(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?He(e):1}function Yg(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:Bg(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function Gg(e){return`crucible:component:${encodeURIComponent(e)}`}function Xg(e){return`crucible:product:${encodeURIComponent(e)}`}function Vg(e,t,i,r){if(void 0!==i&&Number.isFinite(i)&&i>0)return i;let[o,n]=t;if(n-o<=Sg)return(r[0]+r[1])/2;let a=Math.sqrt(Math.max(0,e-o)/(n-o));return r[0]+(r[1]-r[0])*a}function qg(e,t){let i=Math.max(.25,Math.min(1,t.width/900,t.height/520)),r=e?.[0]??7*i,o=e?.[1]??18*i,n=Math.max(1,Math.min(r,o));return[n,Math.max(n,Math.max(r,o))]}function Hg(e,t,i={}){let r=Object.values(e.components).sort((e,t)=>Mg(e.id,t.id)),o=Ne(r.map(e=>e.amount)),n=qg(i.radiusRange,t),a=Oe(Bg(i.seed)),s=t.mouth.x+t.mouth.width/2,l=t.chamber.y+Math.max(18,.18*t.chamber.height),c=Math.max(4,.28*t.chamber.width),u=Math.max(4,.12*t.chamber.height);return r.map((e,t)=>{let d=t/Math.max(1,r.length)*Math.PI*2+.18*(a()-.5),h=Vg(e.amount,o,i.bodyRadius,n),f={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:Gg(e.id),x:s+Math.cos(d)*c*(.45+.45*a()),y:l+Math.sin(d)*u*(.45+.45*a()),vx:24*(a()-.5),vy:18*(a()-.5),mass:Math.max(.25,h*h*.015),restitution:.12,friction:.4,shape:{type:"circle",radius:h},datum:f}})}function Ug(e,t){if(!e)return[];let i=Math.min(e,Math.max(1,Math.ceil(Math.sqrt(e*Math.max(.5,t.width/Math.max(1,t.height)))))),r=Math.max(1,Math.ceil(e/i));return Array.from({length:e},(e,o)=>({x:t.x+(o%i+.5)*(t.width/i),y:t.y+(Math.floor(o/i)+.5)*(t.height/r)}))}function Zg(e){return e.outletId?e.outletId:"failed"===e.status?"failed":"recovered"===e.status?"recovered":"retained"===e.status?"retained":"ejected"===e.status?"residue":void 0}function Qg(e,t){return e.outlets.find(e=>e.id===t)||{x:e.chamber.x+.18*e.chamber.width,y:e.chamber.y+.2*e.chamber.height,width:.64*e.chamber.width,height:.6*e.chamber.height}}function Kg(e,t){let i=/* @__PURE__ */new Map;for(let t of e){let e=t.outletId??"__chamber__",r=i.get(e)??[];r.push(t),i.set(e,r)}let r=/* @__PURE__ */new Map;for(let[e,o]of i){o.sort((e,t)=>(e.order??Number.MAX_SAFE_INTEGER)-(t.order??Number.MAX_SAFE_INTEGER)||Mg(e.id,t.id));let i=Ug(o.length,Qg(t,"__chamber__"===e?void 0:e));o.forEach((e,t)=>r.set(e.id,i[t]))}return r}function Jg(e,t,i={}){let r=Object.values(e.products).sort((e,t)=>Mg(e.id,t.id)),o=Object.values(e.components).sort((e,t)=>Mg(e.id,t.id)),n=Ne([...o.map(e=>e.amount),...r.map(e=>e.amount)]),a=qg(i.radiusRange,t),s=Kg(r,t),l=r.map(e=>{let r=s.get(e.id)??{x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2},o=1.28*Vg(e.amount,n,i.bodyRadius,a),l={__crucible:!0,kind:"product",semanticId:e.id,product:e};return{id:Xg(e.id),x:r.x,y:r.y,mass:Math.max(.25,o*o*.018),bodyCollisions:!1,shape:{type:"circle",radius:o},datum:l}}),c=/* @__PURE__ */new Map;for(let e of o.filter(e=>!e.productIds.length)){let t=Zg(e)??"__chamber__",i=c.get(t)??[];i.push(e),c.set(t,i)}let u=/* @__PURE__ */new Map;for(let[e,i]of c){let r=Ug(i.length,Qg(t,"__chamber__"===e?void 0:e));i.forEach((e,t)=>u.set(e.id,r[t]))}return[...o.map(e=>{let r=u.get(e.id);if(e.productIds.length){let i=e.productIds.map(e=>s.get(e)).filter(e=>!!e);if(i.length){r={x:i.reduce((e,t)=>e+t.x,0)/i.length,y:i.reduce((e,t)=>e+t.y,0)/i.length};let o=He(e.id)/4294967295*Math.PI*2,n=Math.min(20,Math.max(4,.012*t.width));r={x:r.x+Math.cos(o)*n,y:r.y+Math.sin(o)*n}}}r??(r={x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2});let o=Vg(e.amount,n,i.bodyRadius,a),l={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:Gg(e.id),x:r.x,y:r.y,mass:Math.max(.25,o*o*.015),shape:{type:"circle",radius:o},datum:l}}),...l]}var em=Jg;function tm(e){return Array.isArray(e)?e.map(tm):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>Mg(e,t)).map(([e,t])=>[e,tm(t)])):e}function im(e){return JSON.stringify(tm(e))}function rm(e,t){let i=Lg(t)??0,r=Math.max(0,Math.min(e.duration,i));if(!e.phases.length)return{elapsed:r,phaseId:"",phaseIndex:-1,phaseElapsed:0,complete:!0};let o=r>=e.duration-Sg,n=o?e.phases[e.phases.length-1]:e.phases.find(e=>r>=e.start&&r<e.end)??e.phases[0];return{elapsed:r,phaseId:n.id,phaseIndex:n.index,phaseElapsed:o?n.duration:Math.max(0,r-n.start),complete:o}}function om(e,t){if(void 0===t)return e.duration;if("number"==typeof t)return Math.max(0,Math.min(e.duration,Lg(t)??0));let i=e.phases.find(e=>e.id===t.phaseId);if(!i)return e.duration;let r=Math.max(0,Math.min(1,Lg(t.progress??0)??0));return i.start+i.duration*r}function nm(e,t=e.duration){let i=rm(e,t),r=Zp(e.initialState),o=[],n=[],a=[];for(let t of e.events){if(t.authoredAt>i.elapsed+Sg)break;let s=xg(r,t,{phaseId:t.phaseId,authoredAt:t.authoredAt,appliedAt:t.authoredAt,products:e.products,outlets:e.outlets});o.push(...s.diagnostics),n.push(...s.materializations),a.push(...s.observations),s.applied&&(r=s.state)}return r.elapsed=i.elapsed,r.phaseId=i.phaseId,r.phaseIndex=i.phaseIndex,r.phaseElapsed=i.phaseElapsed,r.complete=i.complete,i.complete&&"in_process"===r.outcome&&(r.outcome="complete"),r.playing=!1,{state:r,diagnostics:o,materializations:n,observations:a}}function am(e){let t=Cg(e.phases),i=t.phases.at(-1)?.end??0,r=Eg(e.outlets??kg),o=(e.products??[]).map(e=>({...e,metrics:e.metrics?qp(e.metrics):void 0})),n=Fg(e.events??[],t.phases,i),a=Tg(e),s=Dg(e.size??wg,r),l=Wg(s),c=zg(o,r),u=im({seed:e.seed??1,components:Object.values(a.state.components).sort((e,t)=>Mg(e.id,t.id)).map(e=>({id:e.id,label:e.label,category:e.category,amount:e.amount,metrics:e.metrics,status:e.status})),phases:t.phases.map(({id:e,duration:t,label:i,description:r,intensity:o,motion:n,color:a,metrics:s})=>({id:e,duration:t,label:i,description:r,intensity:o,motion:n,color:a,metrics:s})),products:o,outlets:r,events:n.events.map(({id:e,label:t,description:i,summary:r,authoredAt:o,phaseId:n,boundaryRank:a,effects:s})=>({id:e,label:t,description:i,summary:r,authoredAt:o,phaseId:n,boundaryRank:a,effects:s}))}),d=Hg(a.state,s,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),h=[...t.diagnostics,...n.diagnostics,...a.diagnostics,...c],f={phases:t.phases,events:n.events,products:o,outlets:r,duration:i,initialState:a.state,terminalState:a.state,layout:s,colliders:l,config:Yg(e.seed,l),initialSpawns:d,terminalSpawns:[],semanticKey:u,diagnostics:h},p=nm(f),g=Object.values(p.state.products).filter(e=>"forming"===e.status).map(e=>e.id),m=g.length?[$g("warning","forming-product-at-end",`Products remain forming at the end of the tape: ${g.join(", ")}.`,"events",g)]:[];return f.terminalState=p.state,f.terminalSpawns=em(p.state,s,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),f.diagnostics=[...h,...p.diagnostics,...m],f}import*as sm from"react";import{jsx as lm,jsxs as cm}from"react/jsx-runtime";function um(e){return Number.isFinite(e)?Math.abs(e)>=1e3?e.toLocaleString():Number.isInteger(e)?String(e):e.toFixed(2).replace(/\.00$/,"").replace(/(\.\d)0$/,"$1"):"0"}function dm(e,t,i,r){let o=e.datum;if(!o?.__crucible)return;let n="circle"===e.shape.type?e.shape.radius:8,a="string"==typeof t.fill?t.fill:"product"===o.kind?"#b8792d":"#356b63",s="string"==typeof t.stroke?t.stroke:"#26323a",l="number"==typeof t.strokeWidth?t.strokeWidth:1.25,c="number"==typeof t.opacity?t.opacity:.96,u=r?`${r}-crucible-body-${i}`:`crucible-body-${i}`;if("product"===o.kind){let t=Array.from({length:6},(t,i)=>{let r=-Math.PI/2+i/6*Math.PI*2;return`${e.x+Math.cos(r)*n},${e.y+Math.sin(r)*n}`}).join(" "),i=`${u}-glow`;/* @__PURE__ */
179
- return cm(sm.Fragment,{children:[
180
- /* @__PURE__ */lm("defs",{children:/* @__PURE__ */lm("filter",{id:i,x:"-60%",y:"-60%",width:"220%",height:"220%",children:/* @__PURE__ */lm("feDropShadow",{dx:"0",dy:"0",stdDeviation:"4",floodColor:a,floodOpacity:"0.8"})})}),
181
- /* @__PURE__ */lm("polygon",{points:t,fill:a,stroke:s,strokeWidth:l,opacity:c,filter:`url(#${i})`}),
182
- /* @__PURE__ */lm("circle",{cx:e.x,cy:e.y,r:Math.max(2,.36*n),fill:"none",stroke:"var(--semiotic-bg, #fffaf0)",strokeWidth:l,opacity:.72*c})]},u)}/* @__PURE__ */
183
- return cm(sm.Fragment,{children:[
184
- /* @__PURE__ */lm("circle",{cx:e.x,cy:e.y,r:n,fill:a,stroke:s,strokeWidth:l,opacity:c}),
185
- /* @__PURE__ */lm("circle",{cx:e.x-.25*n,cy:e.y-.28*n,r:Math.max(1,.18*n),fill:"rgba(255,255,255,0.34)"})]},u)}import{Fragment as hm,jsx as fm,jsxs as pm}from"react/jsx-runtime";var gm="var(--semiotic-text, #26323a)",mm="var(--semiotic-text-secondary, #6c7377)",ym="var(--semiotic-primary, #b8792d)",xm="var(--semiotic-danger, #9f3d35)",bm="var(--semiotic-success, #356b63)";function vm(e){let{x:t,y:i,width:r,height:o}=e.chamber,n=Math.min(.14*r,48),a=i+o;return[`M ${t} ${i}`,`L ${t+n} ${a-.16*o}`,`Q ${t+r/2} ${a+.1*o} ${t+r-n} ${a-.16*o}`,`L ${t+r} ${i}`].join(" ")}function wm({layout:e,phases:t,state:i,compact:r=!1}){let o=Math.max(1,t.reduce((e,t)=>e+Math.max(0,t.duration),0));/* @__PURE__ */
186
- return pm("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",viewBox:`0 0 ${e.width} ${e.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:[
187
- /* @__PURE__ */pm("defs",{children:[
188
- /* @__PURE__ */pm("linearGradient",{id:"semiotic-crucible-heat",x1:"0",x2:"0",y1:"0",y2:"1",children:[
189
- /* @__PURE__ */fm("stop",{offset:"0",stopColor:ym,stopOpacity:"0.03"}),
190
- /* @__PURE__ */fm("stop",{offset:"0.66",stopColor:ym,stopOpacity:"0.1"}),
191
- /* @__PURE__ */fm("stop",{offset:"1",stopColor:xm,stopOpacity:"0.18"})]}),
192
- /* @__PURE__ */fm("pattern",{id:"semiotic-crucible-hatch",width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(20)",children:/* @__PURE__ */fm("line",{x1:"0",x2:"0",y1:"0",y2:"7",stroke:gm,strokeOpacity:"0.08",strokeWidth:"1"})})]}),
193
- /* @__PURE__ */fm("rect",{x:e.chamber.x,y:e.chamber.y,width:e.chamber.width,height:e.chamber.height,rx:2,fill:"url(#semiotic-crucible-heat)",stroke:gm,strokeOpacity:"0.52",strokeWidth:r?1:2.2}),
194
- /* @__PURE__ */fm("path",{d:vm(e),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),
195
- /* @__PURE__ */fm("line",{x1:e.mouth.x,x2:e.mouth.x+e.mouth.width,y1:e.mouth.y,y2:e.mouth.y,stroke:gm,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:r?2:5}),r?null:/* @__PURE__ */fm("g",{"data-testid":"crucible-phase-rail",children:t.map((r,n)=>{let a=t.slice(0,n).reduce((e,t)=>e+Math.max(0,t.duration),0),s=e.phaseRail.x+a/o*e.phaseRail.width,l=Math.max(0,r.duration)/o*e.phaseRail.width,c=r.id===i.phaseId,u=i.phaseIndex>n||i.complete;/* @__PURE__ */
196
- return pm("g",{children:[
197
- /* @__PURE__ */fm("rect",{x:s,y:e.phaseRail.y,width:Math.max(1,l-2),height:e.phaseRail.height,rx:2,fill:c?r.color??ym:u?bm:gm,fillOpacity:c?.68:u?.28:.09}),l>=46?/* @__PURE__ */fm("text",{x:s+l/2,y:e.phaseRail.y+e.phaseRail.height+13,fill:c?gm:mm,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8.5,fontWeight:c?800:650,letterSpacing:"0.04em",textAnchor:"middle",children:(r.label??r.id).toUpperCase()}):null]},r.id)})}),e.outlets.map(e=>/* @__PURE__ */pm("g",{children:[
198
- /* @__PURE__ */fm("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?xm:bm),fillOpacity:"0.1",stroke:e.color??("left"===e.side?xm:bm),strokeDasharray:"3 3",strokeOpacity:"0.62"}),r?null:/* @__PURE__ */fm("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:mm,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(e.label??e.id).toUpperCase()})]},e.id))]})}function km(e,t){return"count"===t?e.count:"amount"===t?e.amount:Number(e.metrics[t]??0)}function Am({rows:e,layout:t,projection:i,amountLabel:r}){if(!e.length)return null;let o=i.measure??"count",n=e.map(e=>Math.max(0,km(e,o))),a=n.reduce((e,t)=>Math.max(e,t),1),s=t.projection.width/Math.max(1,e.length),l=t.projection.height>48?21:4,c=Math.max(5,t.projection.height-l-5);/* @__PURE__ */
199
- return fm("svg",{"aria-hidden":"true","data-testid":"crucible-projection-overlay",viewBox:`0 0 ${t.width} ${t.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:e.map((e,i)=>{let u=n[i],d=Math.max(u>0?2:0,u/a*c),h=t.projection.x+i*s+.18*s,f=t.projection.y+c-d;/* @__PURE__ */
200
- return pm("g",{children:[
201
- /* @__PURE__ */fm("rect",{x:h,y:f,width:Math.max(3,.64*s),height:d,rx:2,fill:"failed"===e.status||"ejected"===e.status?xm:"complete"===e.status?ym:bm,fillOpacity:"0.68"}),l>4&&s>=34?/* @__PURE__ */pm(hm,{children:[
202
- /* @__PURE__ */fm("text",{x:h+.32*s,y:t.projection.y+c+10,fill:mm,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:7.5,fontWeight:700,textAnchor:"middle",children:e.label.length>13?`${e.label.slice(0,12)}…`:e.label}),
203
- /* @__PURE__ */pm("text",{x:h+.32*s,y:t.projection.y+c+19,fill:gm,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:850,textAnchor:"middle",children:[um(u),"amount"===o&&r?` ${r}`:""]})]}):null]},e.key)})})}function Sm(e){let t=e.datum;if(t&&"object"==typeof t){let e=t,i=e.label??e.name??e.id;if(null!=i&&""!==i)return String(i)}return e.id}function Mm(e,t={}){let i=t.bodies??[],r=Math.max(0,t.recentBodyLimit??6),o=/* @__PURE__ */new Map;for(let e of i){let i=t.getContainerId?.(e);if(!i)continue;let r=o.get(i);r?r.push(e):o.set(i,[e])}let n=e.map(e=>{let i=o.get(e.id)??[],n=Math.max(0,Math.floor(e.count??i.length)),a=i.slice(Math.max(0,i.length-r)).map(e=>({id:e.id,label:t.getBodyLabel?.(e)??Sm(e),datum:e.datum}));return{id:e.id,label:e.label,count:n,share:0,secondary:e.secondary,secondaryLabel:e.secondaryLabel,observed:e.observed,bodyIds:i.map(e=>e.id),recentBodies:a,metadata:e.metadata}}),a=n.reduce((e,t)=>e+t.count,0);return n.map(e=>({...e,share:a>0?e.count/a:0}))}import{Fragment as $m,jsx as _m,jsxs as Lm}from"react/jsx-runtime";function Pm(e,t,i,r,o){let n=Array.isArray(o)?o:o?[o]:[];if(!1!==i||0!==n.length)return({size:o})=>{let a=[Number(o[0])||700,Number(o[1])||420],s=k(a),l=Math.max(2,Math.round(t)),c=s.plot.width/l,u=s.plot.y+s.plot.height,d=e.reduce((e,t)=>Math.max(e,t.value),1),h=!1!==i,[f,p]=r?.valueExtent??[0,l],g=p===f?1:p-f,m=e.map((e,t)=>{let i=s.plot.x+(t+.5)*c,r=u-e.value/d*s.plot.height*.9;return`${0===t?"M":"L"} ${i.toFixed(1)} ${r.toFixed(1)}`}).join(" ");/* @__PURE__ */
204
- return Lm("svg",{"aria-hidden":"true","data-testid":"galton-board-structure-overlay",width:a[0],height:a[1],viewBox:`0 0 ${a[0]} ${a[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[h?/* @__PURE__ */Lm($m,{children:[Array.from({length:l+1},(e,t)=>{let i=s.plot.x+t*c;/* @__PURE__ */
205
- return _m("line",{"data-testid":"galton-board-bin-wall",x1:i,x2:i,y1:s.plot.y,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.28,strokeWidth:1},`bin-wall-${t}`)}),
206
- /* @__PURE__ */_m("line",{x1:s.plot.x,x2:s.plot.x+s.plot.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),
207
- /* @__PURE__ */_m("path",{d:m,fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.7,strokeWidth:2,strokeLinejoin:"round"}),e.map((e,t)=>{if(e.value<=0)return null;let i=s.plot.x+(t+.5)*c,r=u-e.value/d*s.plot.height*.9;/* @__PURE__ */
208
- return _m("text",{x:i,y:Math.max(s.plot.y+10,r-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.value},`${e.label}-${t}`)})]}):null,n.map((e,t)=>{let i=Number(e.value);if(!Number.isFinite(i))return null;let r=Math.max(0,Math.min(1,(i-f)/g)),o=s.plot.x+r*s.plot.width,n=e.color??"var(--semiotic-warning, #f28e2b)",l="bottom"===e.labelPosition?Math.min(a[1]-8,u+16):s.plot.y+16;/* @__PURE__ */
209
- return Lm("g",{className:e.className,"data-testid":"galton-board-reference-line",children:[
210
- /* @__PURE__ */_m("line",{x1:o,x2:o,y1:s.plot.y+8,y2:u-4,stroke:n,strokeDasharray:e.strokeDasharray??"6 5",strokeWidth:e.strokeWidth??2}),null==e.label?null:/* @__PURE__ */_m("text",{x:Math.min(s.plot.x+s.plot.width-4,o+6),y:l,fill:n,fontSize:10,fontWeight:700,children:e.label})]},`galton-reference-${t}-${i}`)})]})}}function Im(e,t,i){if(!1!==i&&t)return({size:i})=>{let r=[Number(i[0])||760,Number(i[1])||360],o=k(r),n=Math.max(1,t.windowCount),a=t.plot??o.plot,s=t.gutter??{x:a.x,y:a.y,width:0,height:a.height},l=t.windowPlot??a,c=l.width/n,u=a.y+a.height,d=a.y+.48*a.height,h=t.lidSegments[0]?.y1??d,f=t.windowStart,p=t.windowStart+n*t.windowSize,g=p===f?0:(t.watermarkValue-f)/(p-f),m=l.x+Math.max(0,Math.min(1,g))*l.width;/* @__PURE__ */
211
- return Lm("svg",{"aria-hidden":"true","data-testid":"event-drop-window-overlay",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
212
- /* @__PURE__ */_m("rect",{x:a.x,y:a.y,width:a.width,height:a.height,fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.7,strokeWidth:1}),s.width>0?/* @__PURE__ */Lm("g",{children:[
213
- /* @__PURE__ */_m("rect",{x:s.x,y:h,width:s.width,height:u-h,fill:"var(--semiotic-danger, #e15759)",fillOpacity:.07}),
214
- /* @__PURE__ */Lm("text",{x:s.x+s.width/2,y:h-8,textAnchor:"middle",fill:"var(--semiotic-danger, #e15759)",fontSize:10,fontWeight:700,children:[t.lateCount," late"]})]}):null,Array.from({length:n},(i,o)=>{let n=e[o],a=l.x+o*c,s=o<t.closedWindowCount;/* @__PURE__ */
215
- return Lm("g",{children:[
216
- /* @__PURE__ */_m("rect",{x:a,y:d,width:c,height:u-d,fill:s?"var(--semiotic-danger, #e15759)":"var(--semiotic-primary, #4e79a7)",fillOpacity:s?.08:.06}),s?t.lidSegments.filter(e=>e.windowIndex===o).map(e=>/* @__PURE__ */_m("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.78,strokeWidth:2,strokeLinecap:"round"},e.id)):null,
217
- /* @__PURE__ */_m("text",{x:a+c/2,y:d-8,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:n?.value??0}),
218
- /* @__PURE__ */_m("text",{x:a+c/2,y:Math.min(r[1]-8,u+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:n?.label??""})]},`window-${o}`)}),t.windowWalls?.map(({id:e,...t})=>/* @__PURE__ */_m("rect",{...t,fill:"var(--semiotic-border, #d1d5db)",fillOpacity:.68},e)),t.lidSegments.filter(e=>null==e.windowIndex).map(e=>/* @__PURE__ */_m("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.62,strokeWidth:2,strokeLinecap:"round"},e.id)),
219
- /* @__PURE__ */_m("line",{x1:a.x,x2:a.x+a.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),
220
- /* @__PURE__ */_m("line",{"data-testid":"event-drop-watermark",x1:m,x2:m,y1:a.y+8,y2:u,stroke:"var(--semiotic-warning, #f28e2b)",strokeDasharray:"5 4",strokeWidth:2}),
221
- /* @__PURE__ */Lm("text",{x:Math.min(a.x+a.width-4,m+6),y:a.y+16,fill:"var(--semiotic-warning, #f28e2b)",fontSize:10,fontWeight:700,children:["watermark ",Math.round(100*t.watermarkValue)/100]})]})}}function Rm(e,t,i,r=1){if(!1!==i&&0!==e.length)return({size:i})=>{let o=[Number(i[0])||700,Number(i[1])||380],n=k(o),a=np(n.plot,e.length,t),s=n.plot.y+n.plot.height;/* @__PURE__ */
222
- return Lm("svg",{"aria-hidden":"true","data-testid":"physics-pile-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
223
- /* @__PURE__ */_m("line",{x1:n.plot.x,x2:n.plot.x+n.plot.width,y1:s,y2:s,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1}),e.map((e,t)=>{let i=Math.min(n.plot.height,a.pileHeight(e.value/r)),l=a.tubeWidth,c=a.centerX(t),u=s-i;/* @__PURE__ */
224
- return Lm("g",{children:[
225
- /* @__PURE__ */_m("rect",{x:c-l/2,y:u,width:l,height:i,rx:3,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.08,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.42,strokeWidth:1,strokeDasharray:"4 3"}),
226
- /* @__PURE__ */_m("text",{x:c,y:Math.max(n.plot.y+12,u-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:11,fontWeight:700,children:e.value}),
227
- /* @__PURE__ */_m("text",{x:c,y:Math.min(o[1]-8,s+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${t}`)}),
228
- /* @__PURE__ */_m("text",{x:o[0]/2,y:o[1]-2,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:`Full circle = ${r}; partial circles scaled by area`})]})}}function Tm(e){return Math.abs(e)>=1e3||Math.abs(e)<.01?e.toLocaleString(void 0,{maximumFractionDigits:0}):e.toLocaleString(void 0,{maximumFractionDigits:2})}function Cm(e,t){if(!1!==t&&e)return({size:t})=>{let i=[Number(t[0])||700,Number(t[1])||360],r=k(i),o=r.plot.y+r.plot.height,[n,a]=e.xExtent,s=n+(a-n)/2,l=[{label:Tm(n),x:e.xRange[0]},{label:Tm(s),x:e.xRange[0]+(e.xRange[1]-e.xRange[0])/2},{label:Tm(a),x:e.xRange[1]}];/* @__PURE__ */
229
- return Lm("svg",{"aria-hidden":"true","data-testid":"collision-swarm-projection-overlay",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[e.groups.some(e=>e.overlapping)?/* @__PURE__ */_m("text",{"data-testid":"collision-swarm-overlap-warning",x:r.plot.x,y:Math.max(10,r.plot.y-9),fill:"var(--semiotic-warning, #b45309)",fontSize:10,children:i[0]<360?"Points overlap":"Points overlap. Reduce radius or increase height."}):null,e.groups.map(e=>/* @__PURE__ */Lm("g",{children:[
230
- /* @__PURE__ */_m("line",{x1:r.plot.x,x2:r.plot.x+r.plot.width,y1:e.y,y2:e.y,stroke:"var(--semiotic-border, #d1d5db)",strokeDasharray:"3 5",strokeWidth:1}),
231
- /* @__PURE__ */_m("text",{x:r.plot.x+4,y:e.y-7,fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.label}),
232
- /* @__PURE__ */Lm("text",{x:r.plot.x+r.plot.width-4,y:e.y-7,textAnchor:"end",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:["n=",e.count,e.overlapping?" · overlaps":""]})]},e.label)),
233
- /* @__PURE__ */_m("line",{x1:e.xRange[0],x2:e.xRange[1],y1:o,y2:o,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),l.map(e=>/* @__PURE__ */Lm("g",{children:[
234
- /* @__PURE__ */_m("line",{x1:e.x,x2:e.x,y1:o,y2:o+5,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),
235
- /* @__PURE__ */_m("text",{x:e.x,y:Math.min(i[1]-8,o+18),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${e.x}`))]})}}import{jsx as Nm}from"react/jsx-runtime";function Fm(e,t,i={},r){if(!1===t||!e)return;let{volume:o,stages:n,groups:a,groupCompletion:s}=e,l=new Map(o.stages.map(e=>[e.id,e])),c=new Map(s.map(e=>[e.id,e]));return({size:e})=>{let t=Number(e[0])||o.width,s=Number(e[1])||o.height,u=n.map(e=>{let t=l.get(e.id),r=i[`process-stage-${e.id}`];return{id:e.id,label:e.label,x0:t?.x0??e.x-e.width/2,x1:(t?.x0??e.x-e.width/2)+(t?.width??e.width),x:e.x,width:t?.width??e.width,count:e.count,capacity:e.capacity,absorb:e.absorb,portalTarget:e.portalTarget,queueDepth:r?.queueDepth,processed:r?.processedCount}}),d=a.map(e=>{let t=c.get(e.id);return{id:e.id,label:e.label??e.id,x:e.anchor?.x??e.x??0,y:e.anchor?.y??e.y??0,absorbed:t?.absorbed,total:t?.total,complete:t?.complete}});return ke({width:t,height:s,left:o.left,right:o.right,topY:o.topY,bottomY:o.bottomY,midY:o.midY,stages:u,groups:d},{showCapacityBadges:!0,showGroupSockets:!0,...r})}}function zm(e,t,i){if(!1===i||!t||0===e.length)return;let r=new Map(t.volume.stages.map(e=>[e.id,e]));return({size:i})=>{let o=[Number(i[0])||t.volume.width,Number(i[1])||t.volume.height],n=k(o),a=e.reduce((e,t)=>Math.max(e,t.value),1),s=Math.min(48,.18*n.plot.height),l=n.plot.y+6;/* @__PURE__ */
236
- return Nm("svg",{"aria-hidden":"true","data-testid":"process-flow-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:t.stages.map((t,i)=>{let o=e[i];if(!o)return null;let n=r.get(t.id);if(!n)return null;let c=Math.max(2,o.value/a*s),u=Math.max(8,.35*n.width);/* @__PURE__ */
237
- return Nm("rect",{x:n.x-u/2,y:l,width:u,height:c,rx:2,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.18,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.45,strokeWidth:1},t.id)})})}}function Em(e){return Math.abs(e)>=1e3?e.toLocaleString(void 0,{maximumFractionDigits:0}):e.toLocaleString(void 0,{maximumFractionDigits:1})}function Dm(e){return e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" ")}import{jsx as Om,jsxs as jm}from"react/jsx-runtime";function Wm(e,t){let{showNodeLabels:i,showSensors:r,showStaticFlow:o}=t;if(e&&(o||r||i))return({size:t})=>{let n=[Number(t[0])||760,Number(t[1])||420],a=e.links.reduce((e,t)=>Math.max(e,t.throughput),1),s=new Set(e.nodes.map(e=>e.sensorId));/* @__PURE__ */
238
- return jm("svg",{"aria-hidden":"true","data-testid":"physical-flow-static-flow-overlay",width:n[0],height:n[1],viewBox:`0 0 ${n[0]} ${n[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[o?e.links.map(e=>{let t=3+e.throughput/a*16,i=e.path[Math.floor(e.path.length/2)];/* @__PURE__ */
239
- return jm("g",{children:[
240
- /* @__PURE__ */Om("path",{d:Dm(e.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:t+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),
241
- /* @__PURE__ */Om("path",{d:Dm(e.path),fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),i?/* @__PURE__ */Om("text",{x:i.x,y:i.y-t/2-5,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:Em(e.throughput)}):null]},e.id)}):null,e.nodes.map(e=>/* @__PURE__ */jm("g",{children:[r&&s.has(e.sensorId)?/* @__PURE__ */Om("rect",{"data-testid":"physical-flow-sensor-overlay",x:e.x-12,y:e.y-12,width:24,height:24,rx:4,fill:"none",stroke:"var(--semiotic-warning, #f59e0b)",strokeDasharray:"3 3",strokeWidth:1.5,opacity:.88}):null,o?/* @__PURE__ */Om("circle",{cx:e.x,cy:e.y,r:6,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1.2}):null,i?/* @__PURE__ */Om("text",{x:e.x,y:e.y-14,textAnchor:"middle",fill:"var(--semiotic-text, #111827)",fontSize:11,fontWeight:800,children:e.label}):null]},e.id))]})}}import{Fragment as Bm,jsx as Ym,jsxs as Gm}from"react/jsx-runtime";function Xm({layout:e,compact:t,showLabels:i}){let r=t?Math.round(.14*e.height):Math.max(80,e.routeY-180),o=t?Math.max(6,Math.round(.72*e.height)):Math.min(360,e.height-170);/* @__PURE__ */
242
- return Ym(Bm,{children:e.gates.map(n=>/* @__PURE__ */Gm("g",{children:[
243
- /* @__PURE__ */Ym("rect",{x:n.x-n.width/2,y:r,width:n.width,height:o,rx:t?2:12,fill:n.color??"var(--semiotic-primary, #38bdf8)",fillOpacity:.1,stroke:n.color??"var(--semiotic-primary, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),i?/* @__PURE__ */Ym("text",{x:n.x,y:Math.max(64,e.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:n.label??n.id}):null]},n.id))})}function Vm({layout:e,states:t,compact:i=!1}){return i?/* @__PURE__ */Ym("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:/* @__PURE__ */Ym(Xm,{layout:e,compact:!0,showLabels:!1})}):/* @__PURE__ */Gm("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
244
- /* @__PURE__ */Ym("path",{d:`M ${e.startX-42} ${e.routeY} C ${.24*e.width} ${e.routeY-70}, ${.42*e.width} ${e.routeY+78}, ${.58*e.width} ${e.routeY} S ${.78*e.width} ${e.routeY-82}, ${e.socketX+36} ${e.routeY}`,fill:"none",stroke:"var(--semiotic-primary, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),
245
- /* @__PURE__ */Ym("line",{x1:Math.round(.06*e.width),x2:Math.round(.94*e.width),y1:e.crashY,y2:e.crashY,stroke:"var(--semiotic-danger, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),
246
- /* @__PURE__ */Ym("text",{x:Math.round(.07*e.width),y:e.crashY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),
247
- /* @__PURE__ */Ym(Xm,{layout:e,compact:!1,showLabels:!0}),
248
- /* @__PURE__ */Gm("g",{children:[
249
- /* @__PURE__ */Ym("rect",{x:e.socketX-52,y:e.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-success, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-success, #22c55e)",strokeWidth:1.5}),
250
- /* @__PURE__ */Ym("text",{x:e.socketX,y:e.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),
251
- /* @__PURE__ */Gm("g",{children:[
252
- /* @__PURE__ */Ym("rect",{x:e.graveyardX-82,y:e.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-danger, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-danger, #ef4444)",strokeOpacity:.7}),
253
- /* @__PURE__ */Ym("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),
254
- /* @__PURE__ */Ym("text",{x:e.graveyardX,y:e.graveyardY+12,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,textAnchor:"middle",children:t.some(e=>e.killed)?"lift shut off":"too heavy or too small"})]})]})}function qm(e){return e.map(e=>({label:e.id,value:Math.max(0,Number(e.viability)||0),outcome:e.outcome||e.stage||"in-process"}))}function Hm({states:e,layout:t}){let i=qm(e);if(!i.length)return null;let r=i.reduce((e,t)=>Math.max(e,t.value),1),o=Math.max(40,(t.width-80)/i.length);/* @__PURE__ */
255
- return Gm("svg",{"aria-hidden":"true","data-testid":"gauntlet-projection-overlay",width:t.width,height:t.height,viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
256
- /* @__PURE__ */Ym("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),i.map((e,t)=>{let i=40+t*o,n=Math.max(2,e.value/r*28),a=/kill|crash|block|grave/i.test(e.outcome);/* @__PURE__ */
257
- return Gm("g",{children:[
258
- /* @__PURE__ */Ym("rect",{x:i+.18*o,y:28-n+22,width:Math.max(10,.45*o),height:n,rx:2,fill:a?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:a?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),
259
- /* @__PURE__ */Ym("text",{x:i+.4*o,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}function Um(e,t){return e?"sparkline"===t?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0}}var Zm={margin:(e,t)=>Um(t.compactMode,e.mode)};function Qm(e,t){return e?t?i=>Uf.createElement(Uf.Fragment,null,"function"==typeof e?e(i):e,"function"==typeof t?t(i):t):e:t}function Km(e,t,i){let r=t[i];return"boolean"==typeof r?r:!0!==e.__compactMode}var Jm=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"];function ey(e){return Jm[He(e)%Jm.length]}function ty(e,t,i,r){let o=e.datum,n={stroke:r.stroke??("product"===o?.kind?"#fffaf0":"#26323a"),strokeWidth:r.strokeWidth??("product"===o?.kind?1.8:1.1),opacity:r.opacity??.96};if(!o?.__crucible)return{...n,fill:r.color??"#b8792d"};if("product"===o.kind){let e=t.products[o.semanticId];return{...n,fill:r.color??e?.color??ey(e?.id??o.semanticId)}}let a,s=t.components[o.semanticId];return s?(a="status"===i?s.status:"outlet"===i?s.outletId??"in chamber":"product"===i?s.productIds[0]??"unalloyed":"category"===i||null==i?s.category:String("function"==typeof i?i(s.datum)??"unassigned":s.datum[String(i)]??"unassigned"),{...n,fill:r.color??ey(a)}):{...n,fill:r.color??"#356b63"}}function iy(e,t){let i=e.datum;if(i?.__crucible)return"product"===i.kind?t.products[i.semanticId]?.label:t.components[i.semanticId]?.label}var ry={frameType:"physics",layout:Zm,buildProps:(e,t,i,o,n)=>{let a=o.size??[600,400],s=n.bins??21,l=n.seed??1,c=Math.max(1,Math.round(n.pegRows??s-1)),u="mechanical"===(n.simulationMode??n.mode),d=Qf({data:u?r({bins:s,branchProbability:n.branchProbability,count:n.mechanicalCount,pegRows:c,seed:l}):Array.isArray(e)?e:[],valueAccessor:n.valueAccessor||"value",bins:s,ballRadius:n.ballRadius??("sparkline"===n.mode?1.5:"context"===n.mode?4:6),seed:l,size:a,valueExtent:u?[0,c]:n.valueExtent});return{...o,config:d.config,initialSpawns:d.initialSpawns,initialSpawnPacing:d.initialSpawnPacing,projectionRows:d.projectionRows,foregroundGraphics:Qm(Pm(d.projectionRows,s,Km(o,n,"showProjection"),d.metadata,n.referenceLines),o.foregroundGraphics),bodyStyle:A(t||n.colorBy||(u?"side":void 0),"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||"value"})}}},oy={frameType:"physics",layout:Zm,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,400],a=ip({data:Array.isArray(e)?e:[],timeAccessor:o.timeAccessor||"time",arrivalAccessor:o.arrivalAccessor||"arrivalTime",watermarkAtArrivalAccessor:o.watermarkAtArrivalAccessor,windows:o.windows||{size:10},watermark:o.watermark,ballRadius:o.ballRadius??7,seed:o.seed??1,size:n,timeExtent:o.timeExtent,timeScale:o.timeScale??1});return{...r,config:a.config,initialSpawns:a.initialSpawns,initialSpawnPacing:a.initialSpawnPacing,projectionRows:a.projectionRows,foregroundGraphics:Qm(Im(a.projectionRows,a.metadata,Km(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:A(t||o.colorBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||o.timeAccessor||"time"})}}},ny={frameType:"physics",layout:Zm,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,400],s="mechanical"===(o.simulationMode??o.mode),l=ap({data:s?a({categories:o.mechanicalCategories,count:o.mechanicalCount,seed:o.seed??1,unitValue:o.unitValue??1}):Array.isArray(e)?e:[],categoryAccessor:o.categoryAccessor||"category",valueAccessor:o.valueAccessor||(s?"value":void 0),unitValue:o.unitValue??1,ballRadius:o.ballRadius??8,seed:o.seed??1,size:n});return{...r,config:l.config,initialSpawns:l.initialSpawns,initialSpawnPacing:l.initialSpawnPacing,projectionRows:l.projectionRows,foregroundGraphics:Qm(Rm(l.projectionRows,o.ballRadius??8,Km(r,o,"showProjection"),Number.isFinite(o.unitValue)&&o.unitValue>0?o.unitValue:1),r.foregroundGraphics),bodyStyle:A(t||o.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},ay={frameType:"physics",layout:Zm,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,360],a=cp({data:Array.isArray(e)?e:[],xAccessor:o.xAccessor||"x",groupAccessor:o.groupAccessor,radiusAccessor:o.radiusAccessor,pointRadius:o.pointRadius??5,seed:o.seed??1,size:n,xExtent:o.xExtent,collisionIterations:o.collisionIterations,settle:o.settle});return{...r,config:a.config,initialSpawns:a.initialSpawns,initialSpawnPacing:a.initialSpawnPacing,projectionRows:a.projectionRows,foregroundGraphics:Qm(Cm(a.metadata,Km(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:A(t||o.colorBy||o.groupAccessor,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.xAccessor||"x"})}}},sy={frameType:"physics",layout:Zm,buildProps:(e,t,i,r,o)=>{let n=r.size??[900,420],a=Array.isArray(o.stages)?o.stages:[],s=vp({data:Array.isArray(e)?e:[],stages:a,size:n,idAccessor:o.idAccessor,stageAccessor:o.stageAccessor||"stage",groupBy:o.groupBy,groupLabelAccessor:o.groupLabelAccessor,workAccessor:o.workAccessor,radiusAccessor:o.radiusAccessor,ballRadius:o.ballRadius??6,seed:o.seed??1,groupCompletion:o.groupCompletion,groupAnchorAlong:o.groupAnchorAlong,settle:o.settle??!0,gravityX:o.gravityX,gravityY:o.gravityY}),l=s.metadata;return{...r,config:s.config,initialSpawns:s.initialSpawns,initialSpawnPacing:s.initialSpawnPacing,projectionRows:s.projectionRows,regionEffects:l?.regionEffects,backgroundGraphics:Qm(Fm(s.metadata,Km(r,o,"showChrome"),{},o.chromeOptions),r.backgroundGraphics),foregroundGraphics:Qm(zm(s.projectionRows,s.metadata,Km(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:A(t||o.colorBy||o.groupBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.workAccessor||o.stageAccessor||"stage"})}}},ly={frameType:"physics",layout:Zm,buildProps:(e,t,i,r,o)=>{let n=r.size??[900,520],a=Gp({data:Array.isArray(e)?e:[],size:n,gates:o.gates,positiveProperties:o.positiveProperties,negativeProperties:o.negativeProperties,crashOffset:o.crashOffset,idAccessor:o.idAccessor,positiveAccessor:o.positiveAccessor,negativeAccessor:o.negativeAccessor,metricsAccessor:o.metricsAccessor,initialViability:o.initialViability,projectPlacement:o.projectPlacement,coreBody:o.coreBody,viability:o.viability});return{...r,config:a.config,initialSpawns:a.initialSpawns,projectionRows:[],backgroundGraphics:Qm(Km(r,o,"showChrome")?Uf.createElement(Vm,{layout:a.layout,states:a.states,compact:!0===r.__compactMode}):void 0,r.backgroundGraphics),foregroundGraphics:Qm(Km(r,o,"showProjection")?Uf.createElement(Hm,{layout:a.layout,states:a.states}):void 0,r.foregroundGraphics),bodyStyle:A(t||o.colorBy)}}},cy={frameType:"physics",layout:Zm,buildProps:(e,t,i,r,o)=>{let n=r.size??[900,520],a=am({data:Array.isArray(e)?e:[],phases:Array.isArray(o.phases)?o.phases:[],products:Array.isArray(o.products)?o.products:void 0,outlets:Array.isArray(o.outlets)?o.outlets:void 0,events:Array.isArray(o.events)?o.events:void 0,idAccessor:o.idAccessor,labelAccessor:o.labelAccessor,categoryAccessor:o.categoryAccessor,amountAccessor:o.amountAccessor,metricsAccessor:o.metricsAccessor,initialStateAccessor:o.initialStateAccessor,metrics:o.metrics,size:n,seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange}),s=nm(a,"snapshot"===o.playback?om(a,o.snapshotAt):a.duration).state,l=o.projection&&"object"==typeof o.projection?o.projection:{groupBy:"outlet",measure:"count"},c=vg(s,l),u=l.measure??"count",d=Mm(c.map(e=>({id:e.key,label:e.label,count:e.count,secondary:"count"===u||"amount"===u?e.amount:Number(e.metrics[u]??0),secondaryLabel:"count"===u||"amount"===u?o.amountLabel??"amount":u,metadata:{amount:e.amount,metrics:e.metrics,status:e.status,outletId:e.outletId,category:e.category,productId:e.productId}}))),h={seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange},f=t??o.colorBy??"category",p=!1===o.showChrome?null:Uf.createElement(wm,{layout:a.layout,phases:a.phases,state:s,compact:n[0]<520||n[1]<360}),g=!1===o.showProjection?null:Uf.createElement(Am,{rows:c,layout:a.layout,projection:l,amountLabel:o.amountLabel});return{...r,config:a.config,initialSpawns:Jg(s,a.layout,h),projectionRows:d,bodyStyle:e=>ty(e,s,f,o),getBodyLabel:e=>iy(e,s),renderBodySVG:dm,backgroundGraphics:Qm(p,r.backgroundGraphics),foregroundGraphics:Qm(g,r.foregroundGraphics)}}},uy={frameType:"physics",layout:Zm,buildProps:(e,t,i,r,o)=>{let n=r.size??[760,420],a=yp({nodes:Array.isArray(o.nodes)?o.nodes:[],links:Array.isArray(o.links)?o.links:Array.isArray(o.edges)?o.edges:Array.isArray(e)?e:[],nodeIdAccessor:o.nodeIdAccessor||"id",nodeXAccessor:o.nodeXAccessor||"x",nodeYAccessor:o.nodeYAccessor||"y",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",throughputAccessor:o.throughputAccessor||"value",pathAccessor:o.pathAccessor||"path",coordinateMode:o.coordinateMode||"auto",particleRate:o.particleRate??.16,maxParticles:o.maxParticles??180,particleRadius:o.particleRadius??4,flowSpeed:o.flowSpeed??90,pathConstraint:o.pathConstraint||"path",reducedMotion:!0,seed:o.seed??1,size:n});return{...r,config:a.config,initialSpawns:a.initialSpawns,initialSpawnPacing:a.initialSpawnPacing,projectionRows:a.projectionRows,foregroundGraphics:Qm(Wm(a.metadata,{showNodeLabels:!1!==o.showNodeLabels,showSensors:!1!==o.showSensors,showStaticFlow:!1!==o.showStaticFlow}),r.foregroundGraphics),bodyStyle:A(t||o.colorBy||"source")}}},dy={frameType:"physics",layout:Zm,buildProps:(e,t,i,r,o)=>{let n=r.size??[700,380],a=hr(r.theme),s=_p({chartId:o.chartId,colorScheme:i,config:o.config,data:Array.isArray(e)?e:[],layout:o.layout,layoutConfig:o.layoutConfig,semantic:B(a)??{},size:n,themeCategorical:a.colors.categorical,xExtent:o.xExtent,yExtent:o.yExtent});return{...r,config:s.config,initialSpawns:s.initialSpawns,initialSpawnPacing:s.initialSpawnPacing,projectionRows:[],bodyStyle:s.result.bodyStyle??A(t||o.colorBy),backgroundGraphics:Qm(r.backgroundGraphics,s.result.backgroundOverlays),foregroundGraphics:Qm(r.foregroundGraphics,s.result.overlays)}}};function hy(e){return e&&{fields:["nodeId"],..."object"==typeof e?e:{name:"string"==typeof e?e:"hover"}}}import*as fy from"react";function py(e,t){let i=/* @__PURE__ */new Set,r=[t];for(;r.length;){let t=r.pop();if(i.has(t))continue;i.add(t);let o=qe(e.children,t);Array.isArray(o)&&r.push(...o)}return i}function gy(e,t){let i=[],r=qe(e.requiredChildren,t);if(void 0===r)return i;if(!Array.isArray(r))throw new Error("Invalid required-path dominator children");let o=[...r],n=/* @__PURE__ */new Set([t]);for(;o.length;){let t=o.pop(),r=qe(e.requiredChildren,t);if("string"!=typeof t||n.has(t)||!Array.isArray(r))throw new Error("Invalid required-path dominator chain");n.add(t),i.push(t);for(let e of r)o.push(e)}return i.sort()}var my=e=>{let{forest:t,selection:i,reading:r="organize"}=e.config,{atlas:o}=t,n=e.dimensions.plot,a=e.theme.semantic.text??"#273442",s=e.config.colors?.backbone??e.theme.semantic.textSecondary??"#8995a3",l=e.config.colors?.residual??e.theme.semantic.warning??"#b66631",c=e.config.colors?.required??e.theme.semantic.primary??"#3983a5",u=i?.analysisRevision===o.analysisRevision&&"directed-admitted"===i.relationScopeId&&o.source.nodes.some(e=>e.id===i.nodeId)?i.nodeId:void 0,d=/* @__PURE__ */new Map;for(let i of t.order)if(e.config.collapsedNodeIds?.includes(i)&&!d.has(i))for(let e of py(t,i))e!==i&&d.set(e,i);let h=t.order.filter(e=>!d.has(e)),f=new Map(o.source.nodes.map(e=>[e.id,e])),p=/* @__PURE__ */new Map;for(let e of d.values())p.set(e,(p.get(e)??0)+1);let g=/* @__PURE__ */new Map;for(let e of o.source.edges){let t=d.get(e.source)??e.source;if(t===(d.get(e.target)??e.target)&&(e.source!==t||e.target!==t)){let i=g.get(t);i?i.push(e.id):g.set(t,[e.id])}}let m=[...o.sections.sectionIds];o.source.nodes.some(e=>!e.sectionId)&&m.push("Unsectioned");let y=new Map(o.source.nodes.map(e=>[e.id,e.sectionId??"Unsectioned"])),x=m.map(e=>h.filter(t=>y.get(t)===e)),b=/* @__PURE__ */new Map,v=[],w=[],k=[],A=[],S=(e,t,i,r=11,o)=>v.push({x:e,y:t,text:i,fill:a,anchor:"middle",fontSize:r,...o?{anchorPoint:o}:{}}),M=Math.max(16,Math.min(94,n.width/Math.max(1,m.length)-20));x.forEach((e,t)=>{let i=n.x+n.width*(t+.5)/m.length;S(i,n.y+18,m[t],12),e.forEach((t,r)=>{let o=n.y+58+(r+.5)*Math.max(40,n.height-110)/Math.max(1,e.length);b.set(t,{x:i,y:o})})});for(let t of h){let i=b.get(t),r=f.get(t),n=p.get(t)??0,a=g.get(t)??[],d=o.requiredPaths?.unreachableNodeIds.includes(t),h=r.completeness&&"known"!==r.completeness,m=h?"Unknown upstream":d?"Unreachable from roots":void 0;w.push({type:"glyph",id:t,cx:i.x,cy:i.y,size:34,glyph:{viewBox:[M,34],parts:[{d:`M6,0 H${M-6} Q${M},0 ${M},6 V28 Q${M},34 ${M-6},34 H6 Q0,34 0,28 V6 Q0,0 6,0 Z`,stroke:"accent"}]},accent:u===t?c:h?l:s,style:{fill:e.theme.semantic.surface??"#fff",strokeWidth:u===t?2.5:1},label:t,datum:{...r,nodeId:t,kind:"dependency-node",sourceRevision:o.provenance.sourceRevision,analysisRevision:o.analysisRevision,relationScopeId:"directed-admitted",hiddenCount:n,internalEdgeIds:a},accessibleDatum:{node:t,section:y.get(t),status:m??"Admitted",hiddenCount:n,internalEdges:a.join(", ")}});let x=[i.x,i.y];S(i.x,i.y+4,n?`${t} +${n}`:t,12,x),m?S(i.x,i.y+30,m,9,x):n&&S(i.x,i.y+30,`${a.length} internal links`,9,x)}let $,_=new Set(t.forest.backboneEdgeIds),L=new Set(e.config.highlightedEdgeIds),P=/* @__PURE__ */new Map;for(let e of o.source.edges){let t=d.get(e.source)??e.source,i=d.get(e.target)??e.target;if(t===i&&(e.source!==t||e.target!==i))continue;let r=b.get(t),a=b.get(i),u=JSON.stringify([t,i]),h=12*(P.get(u)??0);P.set(u,(P.get(u)??0)+1);let f,p,g=_.has(e.id),y=L.has(e.id)?c:g?s:l,x=a.x>r.x,v=r.x+(x?M/2:-M/2),w=a.x+(x?-M/2:M/2),S=[...b.values()].filter(e=>e.x>Math.min(r.x,a.x)&&e.x<Math.max(r.x,a.x));if(t===i)f=`M${r.x-14},${r.y-17} C${r.x-35-h},${r.y-64-h} ${r.x+35+h},${r.y-64-h} ${r.x+14},${r.y-17}`,p=1;else if(r.x===a.x){let e=a.y>r.y?1:-1,t=r.x+e*M/2,i=t+e*(32+h);f=`M${t},${r.y} C${i},${r.y} ${i},${a.y} ${t},${a.y}`,p=1===e?2:0}else if(S.length){let e=Math.min(r.y,a.y,...S.map(e=>e.y))-17-26-h,t=(n.width/m.length-M)/2*(x?1:-1);f=`M${v},${r.y} C${v+t},${r.y} ${v},${e} ${v+t},${e} H${w-t} C${w},${e} ${w-t},${a.y} ${w},${a.y}`,p=x?0:2}else if(x){let e=(v+w)/2;f=`M${v},${r.y} C${e},${r.y-h} ${e},${a.y-h} ${w},${a.y}`,p=0}else{let e=Math.min(r.y,a.y)-48-h;f=`M${v},${r.y} C${v-25},${e} ${w+25},${e} ${w},${a.y}`,p=2}k.push({type:"curved",id:e.id,pathD:f,style:{stroke:y,strokeWidth:L.has(e.id)?3:g?1.3:2,fill:"none"},datum:{...e,sourceRevision:o.provenance.sourceRevision,analysisRevision:o.analysisRevision,relationScopeId:"directed-admitted",kind:"dependency-edge",edgeClass:g?"backbone":"residual"},accessibleDatum:{edge:e.id,source:e.source,target:e.target,display:g?"backbone":"residual cross-link"}});let $=t===i?r.x+14:r.x===a.x?r.x+(a.y>r.y?M/2:-M/2):w,I=t===i?r.y-17:a.y;A.push(fy.createElement("path",{key:`arrow:${e.id}`,"data-dependency-edge":e.id,"data-source":e.source,"data-target":e.target,d:"M-6,-3 L0,0 L-6,3",fill:"none",stroke:y,transform:`translate(${$},${I}) rotate(${90*p})`}))}if("required-paths"===r&&u){let e=gy(t,u),i=[...new Set(e.map(e=>d.get(e)??e))].filter(e=>e!==u&&b.has(e));if(i.length){let e=i.map(e=>b.get(e)),t=Math.max(...e.map(e=>e.x))+M/2+8,r=Math.min(...e.map(e=>e.y))-23,o=Math.max(...e.map(e=>e.y))+23;$={x:t-7,y:r,width:7,height:o-r,z:"top"},A.push(fy.createElement("path",{key:"required-bracket",d:`M${t-7},${r} H${t} V${o} H${t-7}`,fill:"none",stroke:c,strokeWidth:2,"data-kind":"dominator-bracket"}))}S(n.x+n.width/2,n.y+n.height-16,e.length?`${u} lies on all admitted paths to ${e.join(", ")}${"incomplete"===o.requiredPaths?.status?" · incomplete scope":""}`:o.requiredPaths?`${u}: no other required targets in the admitted graph`:"Required paths have not been prepared")}let I=new Map(w.map(e=>[e.id,e.datum]));return{sceneNodes:w,sceneEdges:k,labels:v,restyle:(e,t)=>({opacity:t?.isActive&&!t.predicate(e.datum)?.2:1}),restyleEdge:(e,t)=>({opacity:t?.isActive&&![e.datum,I.get(String(e.datum?.source)),I.get(String(e.datum?.target))].some(e=>e&&t.predicate(e))?.2:1}),overlays:fy.createElement("g",{"aria-hidden":!0},fy.createElement(Le,{z:"top"},...A)),perspective:"manual",...e.perspective&&$?{perspectiveBounds:[$]}:{}}};import*as yy from"react";function xy(e,t,i){if(!Number.isFinite(t)||!Number.isFinite(i)||t<360||i<300)throw new Error("Circuit geometry needs at least 360 × 300 pixels");let r=[...e.atlas.sections.sectionIds];e.atlas.source.nodes.some(e=>!e.sectionId)&&r.push("Unsectioned");let o=re({width:t,height:i-110,padX:22,padY:70,stages:r.map(e=>({id:e})),shape:"lane"}),n=new Map(e.atlas.source.nodes.map(e=>[e.id,e.sectionId??"Unsectioned"])),a=o.stages.flatMap(t=>{let r=e.order.filter(e=>n.get(e)===t.id),o=(i-235)/Math.max(1,r.length);if(r.length&&o<78)throw new Error("Increase circuit height to keep every module readable");return r.map((i,r)=>{let n=e.modules.find(e=>e.nodeId===i),a=Math.max(68,Math.min(142,t.width-56)),s=Math.min(68,o-10),l=t.x-a/2,c=95+(r+.5)*o-s/2;return{module:n,x:l,y:c,width:a,height:s,queue:{x:l+8,y:c+s-8,width:a-16,height:4},sensor:{x:l+a-5,y:c+s/2-4,width:8,height:8}}})}),s=new Map(a.map(e=>[e.module.nodeId,e])),l=new Set(e.residualEdgeIds),c=0,u=e.atlas.source.edges.map(e=>{let t,i=s.get(e.source),o=s.get(e.target),a=o.x>i.x,u=o.x===i.x,d=(t,i)=>{let r=t.module.ports.filter(e=>e.direction===i),o=r.findIndex(t=>t.edgeId===e.id);return t.y+10+(o+.5)*(t.height-20)/r.length},h={x:i.x+(a||u?i.width:0),y:d(i,"out")},f={x:o.x+(a?0:o.width),y:d(o,"in")};if(u){let r=h.x+18+5*c++;t=e.source===e.target?[h,{x:r,y:h.y},{x:r,y:i.y-15},{x:f.x-8,y:i.y-15},{x:f.x-8,y:i.y}]:[h,{x:r,y:h.y},{x:r,y:f.y},f]}else if(!a||Math.abs(r.indexOf(n.get(e.source))-r.indexOf(n.get(e.target)))>1){let e=a?1:-1,i=62+7*c++;t=[h,{x:h.x+16*e,y:h.y},{x:h.x+16*e,y:i},{x:f.x-16*e,y:i},{x:f.x-16*e,y:f.y},f]}else{let e=(h.x+f.x)/2;t=[h,{x:e,y:h.y},{x:e,y:f.y},f]}return{edgeId:e.id,source:e.source,target:e.target,residual:l.has(e.id),points:t,pathD:Dm(t)}});return{width:t,height:i,modules:a,routes:u,sections:o.stages.map(e=>({id:e.id,x:e.x})),history:{x:42,y:i-88,width:t-84,height:46}}}function by(e,t){let i=e.slice(1).map((t,i)=>Math.hypot(t.x-e[i].x,t.y-e[i].y)),r=i.reduce((e,t)=>e+t,0),o=Math.max(0,Math.min(1,t))*r;for(let t=0;t<i.length;t++){if(o<=i[t]){let r=i[t]?o/i[t]:0;return{x:e[t].x+(e[t+1].x-e[t].x)*r,y:e[t].y+(e[t+1].y-e[t].y)*r}}o-=i[t]}return e[e.length-1]}import*as vy from"react";var wy=vy.createElement,ky={observed:"#387e98",modeled:"#946344",residual:"#a56537",muted:"#778796",alarm:"#bb5149"};function Ay(e,t={}){return{observed:t.observed??e.info??e.primary??ky.observed,modeled:t.modeled??e.secondary??ky.modeled,residual:t.residual??e.warning??ky.residual,muted:t.muted??e.textSecondary??ky.muted,alarm:t.alarm??e.danger??ky.alarm}}var Sy=e=>null===e?"unmeasured":e>=1e6?`${Number((e/1e6).toFixed(2))}m`:e>=1e3?`${Number((e/1e3).toFixed(1))}k`:String(e),My={stage:"M-5,0 H5",distributor:"M-5,0 H0 M0,0 L6,-5 M0,0 H6 M0,0 L6,5",queue:"M-6,-5 V5 H6 V-5 M-3,2 H3",retry:"M-5,2 A5,5 0 1,1 4,3 M4,-1 V4 H0","join-all":"M-6,-4 L0,0 L6,0 M-6,4 L0,0 M2,-5 V5",selector:"M-6,-4 L0,0 L6,0 M-6,4 L0,0 M1,-4 L5,0 L1,4",dependency:"M-5,-5 H5 V5 H-5 Z M-2,-2 L2,2 M-2,2 L2,-2",junction:"M0,-6 L6,0 L0,6 L-6,0 Z"},$y={stage:"stage",distributor:"distributor",queue:"FIFO queue",retry:"retry episode","join-all":"all-member join",selector:"first success",dependency:"dependency gate",junction:"unclassified junction"};function _y(e,t,i,r,o,n=ky,a){let s=Object.values(t.entry.nodes).reduce((e,t)=>Math.max(e,t.queued??0),0)||1;return e.modules.map(e=>{let{module:l,x:c,y:u,width:d,height:h,queue:f}=e,p=t.entry.nodes[l.nodeId],g=o===l.nodeId?i:(p.queued??0)>0?n.alarm:n.muted,m=c+d/2,y="records"===l.semantics.unit?"rec":"attempts"===l.semantics.unit?"att":"roots",x=null!==p.capacity?`${Sy(p.completions)} / ${Sy(p.capacity)} ${y}/s`:null!==p.completions?`${Sy(p.completions)} ${y}/s complete`:`${Sy(p.arrivals)} ${y}/s offered`;return wy("g",{key:l.id,"data-circuit-module":l.nodeId,"data-module-kind":l.kind,opacity:a?.(l.nodeId),"data-queued":p.queued??"unmeasured"},wy("rect",{x:c,y:u,width:d,height:h,fill:"none",stroke:g,strokeWidth:o===l.nodeId?2.5:1}),wy("path",{d:My[l.kind],transform:`translate(${c+10},${u+12})`,stroke:g,fill:"none",strokeWidth:1.4}),wy("text",{x:m+5,y:u+16,textAnchor:"middle",fontSize:d<110?9:11,fontWeight:600,fill:r},l.semantics.label),wy("text",{x:m,y:u+28,textAnchor:"middle",fontSize:8,fill:r},$y[l.kind]),wy("text",{x:m,y:u+41,textAnchor:"middle",fontSize:d<110?7:9,fill:r},x),wy("text",{x:m,y:u+h-13,textAnchor:"middle",fontSize:8,fill:r},`Queue ${Sy(p.queued)}`),null!==p.queued?wy("rect",{...f,width:f.width*p.queued/s,fill:g,"data-circuit-gauge":"queue"}):null,wy("rect",{...e.sensor,fill:i,"data-circuit-sensor":l.nodeId}),l.semantics.dependencyNodeIds?.length?wy("text",{x:m,y:u-8,fontSize:8,textAnchor:"middle",fill:r,"data-circuit-dependency":l.nodeId},`Requires ${l.semantics.dependencyNodeIds.join(", ")}`):null)})}function Ly(e,t,i,r,o,n){let{history:a}=e,s=e.modules.find(e=>e.module.nodeId===n)?.module,l="records"===t.unit?"queued":"attempts",c=t.entries.map(e=>s?e.nodes[s.nodeId]["records"===t.unit?"queued":"arrivals"]:e.totals[l]),u=c.reduce((e,t)=>Math.max(e,t??0),0)||1,d=t.entries[0].at,h=t.entries[t.entries.length-1].at,f=h>d?h-d:1,p=e=>a.x+(e-d)/f*a.width,g="",m=!1;for(let[e,i]of t.entries.entries()){if(null===c[e]){m=!1;continue}let t=a.y+a.height-c[e]/u*a.height;g+=`${m?" H":"M"}${p(i.at)}${m?` V${t}`:`,${t}`}`,m=!0}return wy("g",{"data-circuit-history":l,"data-history-module":s?.nodeId},wy("text",{x:a.x,y:a.y-9,fill:o,fontSize:10},s?`${s.semantics.label} · ${"queued"===l?`queued ${s.semantics.unit}`:`offered ${s.semantics.unit}/s`} · aggregate observations`:"queued"===l?"Queued records · aggregate observations":"Offered attempts/s · aggregate observations"),wy("path",{d:g,fill:"none",stroke:r,strokeWidth:2}),wy("line",{x1:p(i.observedAt),x2:p(i.observedAt),y1:a.y,y2:a.y+a.height,stroke:o,strokeDasharray:"3 3","data-circuit-cursor":i.observedAt}),...t.entries.map(e=>wy("text",{key:e.id,x:p(e.at),y:a.y+a.height+14,textAnchor:"middle",fontSize:9,fill:o},`${e.at}s`)))}function Py(e,t,i,r){return{id:r.nodeId,nodeId:r.nodeId,kind:"circuit-module",moduleKind:r.kind,label:r.semantics.label,unit:r.semantics.unit,sourceRevision:t.sourceRevision,analysisRevision:e.atlas.analysisRevision,relationScopeId:"directed-admitted",editionId:t.id,editionKind:t.kind,synthetic:t.synthetic,mode:i.mode,observedAt:i.observedAt,...i.entry.nodes[r.nodeId]}}var Iy=e=>null===e?"unmeasured":String(e);function Ry(e,t,i,r){return[...t.modules.map(t=>{let o=Py(e,i,r,t.module);return{id:o.id,bodyId:o.id,datum:o,x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height,shape:"rect",label:`${o.label}: ${o.moduleKind}`,description:`${o.label}. ${i.kind} at ${r.observedAt}s. Arrivals ${Iy(o.arrivals)} ${o.unit}/s; completions ${Iy(o.completions)} ${o.unit}/s; installed capacity ${Iy(o.capacity)} ${o.unit}/s; queue ${Iy(o.queued)} ${o.unit}. Measurement status: ${o.status}. Individual timings unavailable.`,group:"circuit modules"}}),...t.routes.map(t=>{let o=r.entry.flows.find(e=>e.edgeId===t.edgeId),n=t.points[Math.floor(t.points.length/2)];return{id:`pipe:${t.edgeId}`,x:n.x,y:n.y,shape:"path",pathData:t.pathD,label:`${t.source} → ${t.target}: ${Iy(o.perSecond)} ${o.unit}/s`,description:`Original edge ${t.edgeId}. ${t.residual?"Residual link":"Display backbone"}. ${i.kind} at ${r.observedAt}s; transferred volume ${Iy(o.perSecond)} ${o.unit}/s.`,group:"original pipes",datum:{id:t.edgeId,kind:"circuit-pipe",source:t.source,target:t.target,analysisRevision:e.atlas.analysisRevision,sourceRevision:i.sourceRevision,relationScopeId:"directed-admitted",editionId:i.id,editionKind:i.kind,observedAt:r.observedAt,...o}}})]}var Ty=yy.createElement,Cy=e=>{let{circuit:t,edition:i,reading:r,selection:o}=e.config;if(r.editionId!==i.id||i.analysisRevision!==t.atlas.analysisRevision)throw new Error("Circuit render inputs must share an edition and analysis revision");let n=xy(t,e.dimensions.width,e.dimensions.height),a=e.theme.semantic.text??"#273442",s=e.theme.semantic.surface??"#fff",l=Ay(e.theme.semantic,e.config.colors),c="modeled"===i.kind?l.modeled:l.observed,u={width:n.width,height:n.height,viewBox:`0 0 ${n.width} ${n.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},"aria-hidden":!0},d=o?.analysisRevision===t.atlas.analysisRevision&&"directed-admitted"===o.relationScopeId?o.nodeId:void 0,h=r.entry.flows.reduce((e,t)=>Math.max(e,t.perSecond??0),0)||1,f=new Map(r.entry.flows.map(e=>[e.edgeId,e])),p=new Map(t.modules.map(e=>[e.nodeId,Py(t,i,r,e)])),g=t=>e.config.layoutSelection?.isActive&&!e.config.layoutSelection.predicate(p.get(t))?.2:1,m=Math.max(0,Math.min(200,Math.floor(e.config.particleBudget??24))),y=Oe(e.config.placementSeed??1),x=n.routes.filter(e=>(f.get(e.edgeId)?.perSecond??0)>0),b=e.config.reducedMotion?[]:Array.from({length:x.length?m:0},(e,t)=>{let i=x[t%x.length],o=by(i.points,(y()+r.requestedTime/10)%1);return Ty("circle",{key:`cue:${t}`,cx:o.x,cy:o.y,r:2.3,fill:a,opacity:Math.max(g(i.source),g(i.target)),"data-circuit-particle":i.edgeId})}),v=n.modules.map(e=>({id:e.module.nodeId,x:e.x+e.width/2,y:e.y+e.height/2,fixedPosition:{x:e.x+e.width/2,y:e.y+e.height/2},shape:{type:"aabb",width:e.width,height:e.height},bodyCollisions:!1,datum:Py(t,i,r,e.module)}));return{bodies:v,config:{kernel:{gravity:{x:0,y:0},seed:e.config.placementSeed??1,sleepAfter:.01},bodyBudget:!1,bodyLimit:v.length,eviction:!1,sediment:!1,settleStepLimit:4},bodyStyle:e=>({fill:s,stroke:l.muted,strokeWidth:1,opacity:g(e.id)}),colliders:n.modules.flatMap(e=>we({idPrefix:`queue:${e.module.nodeId}`,left:e.queue.x,right:e.queue.x+e.queue.width,top:e.queue.y,bottom:e.queue.y+e.queue.height,thickness:1,openEnds:!0})),sensors:n.modules.map(e=>({id:`sensor:${e.module.nodeId}`,shape:{type:"aabb",x:e.sensor.x+e.sensor.width/2,y:e.sensor.y+e.sensor.height/2,width:e.sensor.width,height:e.sensor.height}})),semanticItems:Ry(t,n,i,r),backgroundOverlays:Ty("svg",u,...n.routes.map(t=>{let i=f.get(t.edgeId),r=t.points[t.points.length-1],o=t.points[t.points.length-2],s=n.modules.find(e=>e.module.nodeId===t.source),u=n.modules.find(e=>e.module.nodeId===t.target),d=s.module.ports.filter(e=>"out"===e.direction).length<u.module.ports.filter(e=>"in"===e.direction).length,p=d?t.points[0]:r,m=d?p.x>=s.x+s.width:p.x>u.x,y=180*Math.atan2(r.y-o.y,r.x-o.x)/Math.PI,x=e.config.highlightedEdgeIds?.includes(t.edgeId),b=x?a:t.residual?l.residual:c,v="records"===i.unit?"rec":"attempts"===i.unit?"att":"roots";return Ty("g",{key:t.edgeId,"data-circuit-edge":t.edgeId,opacity:Math.max(g(t.source),g(t.target)),"data-source":t.source,"data-target":t.target,"data-flow":i.perSecond??"unmeasured","data-highlighted":x||void 0,"data-unit":`${i.unit}/s`},Ty("title",null,`${t.edgeId}: ${t.source} → ${t.target}; ${i.perSecond??"unmeasured"} ${i.unit}/s`),Ty("path",{d:t.pathD,stroke:b,strokeWidth:null===i.perSecond?1.5:1+i.perSecond/h*7,strokeDasharray:null===i.perSecond?"4 3":void 0,strokeLinejoin:"round",fill:"none",opacity:0===i.perSecond?.35:.75}),Ty("path",{d:"M-5,-3 L0,0 L-5,3",transform:`translate(${r.x},${r.y}) rotate(${y})`,fill:"none",stroke:b}),Ty("text",{x:p.x+(m?5:-5),y:p.y-7,textAnchor:m?"start":"end",fontSize:8,fill:a},`${null===i.perSecond?"?":Sy(i.perSecond)} ${v}/s`))})),overlays:Ty("svg",{...u,"data-circuit-edition":i.kind,"data-circuit-time":r.observedAt},...n.sections.map(e=>Ty("text",{key:e.id,x:e.x,y:43,textAnchor:"middle",fontSize:11,fill:a},e.id)),..._y(n,r,c,a,d,l,g),...b,Ly(n,i,r,c,a,d),Ty("text",{x:n.width/2,y:n.height-8,textAnchor:"middle",fontSize:9,fill:a},`${"modeled"===i.kind?"Modeled":"Observed"} · ${r.observedAt}s · pipe width = transferred volume/s · individual timings unavailable`))}},Ny=()=>null;function Fy(e,t,i,r){return{frameType:e.frameType,layout:{...e.layout,primarySize:{width:i[0],height:i[1]},...r&&{margin:r}},buildProps:(i,r,o,n,a)=>{let[s,l]=n.size,c=t({...a,...n,width:s,height:l,colorScheme:o});return e.buildProps(c.data,r,o,{...n,title:c.title,description:c.description,summary:c.summary,accessibleTable:c.accessibleTable},{...a,...c})}}}var zy=Fy(Vf,function({atlas:e,linkedHover:t,...i},r=C(e)){return{...i,linkedHover:hy(t),title:i.title??e.spec.dataRevision,description:i.description??"Motif Braid. Labeled squares show successive journey steps; parallel strands split at diverging prefixes and taper with per-step traffic.",summary:i.summary??`${r.groups.length} supported journey groups. Counts use ${e.spec.motifs.countUnit}; overlapping motifs do not partition the population. Source revision: ${e.provenance.sourceRevision}.`,accessibleTable:i.accessibleTable??!0,nodes:r.sceneSeeds.nodes,edges:r.sceneSeeds.edges,layout:Se,layoutConfig:{braid:r}}},[600,400]),Ey=Fy(Vf,function({width:e=920,height:t=440,title:i="Dependency X-Ray",description:r,summary:o,accessibleTable:n=!0,chartId:a,className:s,onObservation:l,linkedHover:c,linkedSelection:u,annotations:d,frameProps:h,onSelectNode:f,...p}){return{nodes:p.forest.sceneSeeds.nodes,edges:p.forest.sceneSeeds.edges,layout:my,layoutConfig:p,nodeIDAccessor:"id",sourceAccessor:"source",targetAccessor:"target",width:e,height:t,title:i,chartId:a,className:s,onObservation:l,linkedHover:hy(c),selection:u,annotations:d,frameProps:h,animate:!1,margin:{top:12,right:24,bottom:12,left:12},description:r??`Sections organize the admitted directed graph. Backbone links organize the drawing; residual links retain other original edges. Brackets describe required paths, separately from transport. Roots: ${p.forest.atlas.requiredPaths?.roots.join(", ")??"not declared"}. Relation scope: directed-admitted. Completeness: ${p.forest.atlas.requiredPaths?.status??"not prepared"}.`,summary:o??`Roots: ${p.forest.atlas.requiredPaths?.roots.join(", ")??"not declared"}. Relation scope: directed-admitted. Required-path completeness: ${p.forest.atlas.requiredPaths?.status??"not prepared"}. ${p.forest.residual.originalEdgeIds.length} original edges retained.`,accessibleTable:n}},[920,440],{top:12,right:24,bottom:12,left:12}),Dy=Fy(dy,function({width:e=980,height:t=860,title:i,description:r,summary:o,accessibleTable:n=!0,chartId:a,className:s,onObservation:l,linkedHover:c,annotations:u,frameProps:d,linkedSelection:h,onSelectNode:f,...p}){return{key:JSON.stringify([p.circuit.atlas.analysisRevision,p.circuit.order,p.circuit.backboneEdgeIds,e,t]),data:p.circuit.modules.map(e=>Py(p.circuit,p.edition,p.reading,e)),layout:Cy,layoutConfig:p,width:e,height:t,chartId:a,className:s,onObservation:l,linkedHover:hy(c),annotations:u,frameProps:d,paused:!0,title:i??p.edition.label,description:r??`${p.edition.label}. ${p.edition.kind} aggregate interval tape at ${p.reading.observedAt} seconds. Pipe widths encode transferred volume per second in their labeled units; module readouts separate completions, capacity and queue stock. Individual timings are unavailable.`,summary:o??p.edition.assumptions.join(" "),accessibleTable:n,tooltip:!!(a||c||l)&&Ny}},[980,860]);import{scaleTime as Oy}from"d3-scale";var jy={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}};function Wy(e="static"){return jy[e]??jy.static}var By=/* @__PURE__ */new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]);function Yy(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:By.has(e.kind)?"fatal":"warn"}function Gy(e){let t=[],i=[];for(let r of e)"fatal"===Yy(r)?t.push(r):i.push(r);return{fatal:t,warnings:i}}function Xy(e,t,i,r={}){let o=Wy(r.usageMode??"static"),n=[],a=/* @__PURE__ */new Set;for(let t of e)a.has(t.id)&&n.push({kind:"duplicate-node",id:t.id,severity:o.duplicateIds}),a.add(t.id);let s=/* @__PURE__ */new Set,l=Array.isArray(i)&&2===i.length,c=l&&Number.isFinite(i[0])&&Number.isFinite(i[1]),u=c&&i[0]<=i[1];(!l||!c||!u)&&n.push({kind:"invalid-domain"});for(let 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[0]<=t.xExtent[1]||n.push({kind:"invalid-node-time",id:t.id}));for(let e of t)s.has(e.id)&&n.push({kind:"duplicate-edge",id:e.id,severity:o.duplicateIds}),s.add(e.id),a.has(e.source)||n.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),a.has(e.target)||n.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))&&n.push({kind:"invalid-system-time",id:e.id,severity:"warn"}),(!Number.isFinite(e.value)||e.value<=0)&&n.push({kind:"invalid-value",id:e.id}),e.endTime<e.startTime&&n.push({kind:"backward-edge",severity:"fatal",id:e.id,source:e.source,target:e.target})):n.push({kind:"invalid-edge-time",id:e.id});return n}function Vy(e,t,i="static"){if("strip"!==Wy(i).invalidSystemTime)return e;let r=new Set(t.filter(e=>"invalid-system-time"===e.kind).map(e=>e.id));return 0===r.size?e:e.map(e=>{if(!r.has(e.id))return e;let t={...e};return null!=t.systemInTime&&!Number.isFinite(t.systemInTime)&&delete t.systemInTime,null!=t.systemOutTime&&!Number.isFinite(t.systemOutTime)&&delete t.systemOutTime,t})}function qy(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 Hy(){/* @__PURE__ */
260
- return Object.create(null)}function Uy(e,t){return e<t?-1:e>t?1:0}function Zy(e){return e.occupants.map(e=>e.id).sort(Uy).join("\0")}function Qy(e,t,i=0){return e.slice(0,-1).map((r,o)=>{let n=e[o+1];return null!=r.group&&r.group===n.group?i:t})}function Ky(e,t){return e.map(e=>{let i=/* @__PURE__ */new Map;for(let r of e.occupants){let e=t[r.id];if(e)for(let t of e.samples){let e=i.get(t.t)??{before:0,after:0},r=t.boundaryOffset??0;i.set(t.t,{before:Math.max(e.before,t.topMass-r),after:Math.max(e.after,t.botMass+r)})}}return[...i].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function Jy(e,t,i){return Ie(Ky([e,t],i)).adjacentClearance[0]??0}function ex(e,t,i){if(0===e.length)return[];let{padding:r,plotH:o,valueScale:n}=i,a=i.stackValueScale??n,s=Qy(e,r,i.groupPadding??0),l=[r+e[0].peak.topPeak*a];for(let i=1;i<e.length;i++)l.push(l[i-1]+t[i-1]*a+s[i-1]);let c=l[l.length-1]+e[e.length-1].peak.botPeak*a+r;if(c>o&&c>0){let e=o/c;for(let t=0;t<l.length;t++)l[t]*=e}return l}function tx(e,t){let i=(e.boundaryOffset??0)*t,r=e.value*t;if("out"===e.kind){let o=e.sideMassBefore*t;return i+("top"===e.side?r/2-o:o-r/2)}let o=e.sideMassAfter*t;return i+("top"===e.side?r/2-o:o-r/2)}function ix(e,t,i,r,o,n,a){let s=e.length;if(0===s)return[];let{padding:l,plotH:c,valueScale:u}=a,d=Qy(e,l,a.groupPadding??0),h=o.map((e,t)=>e*u+d[t]),f=l+e[0].peak.topPeak*u,p=c-l-e[s-1].peak.botPeak*u;if(p-f<=h.reduce((e,t)=>e+t,0)+1e-6)return ex(e,o,a);let g=1===s?[(f+p)/2]:[...n];for(let e=0;e<12;e++){let e=new Array(s).fill(0),o=new Array(s).fill(0);for(let n of i){let i=t[n.source],a=t[n.target];if(null==i||null==a||i===a)continue;let s=r[n.source]?.localAttachments.get(n.id),l=r[n.target]?.localAttachments.get(n.id);if(!s||!l)continue;let c=n.value>0&&Number.isFinite(n.value)?n.value:1,d=tx(s,u),h=tx(l,u);e[i]+=(g[a]+h-d)*c,o[i]+=c,e[a]+=(g[i]+d-h)*c,o[a]+=c}let n=g.map((t,i)=>0===o[i]?t:.45*t+e[i]/o[i]*.55),a=ae({desired:n,minGaps:h,weights:o.map(e=>Math.max(1,e)),min:f,max:p}),l=0;for(let e=0;e<s;e++)l=Math.max(l,Math.abs(a[e]-g[e]));if(g=a,l<.01)break}return g}function rx(e,t,i,r,o,n){let a=n.adjacentClearance?[...n.adjacentClearance]:Ie(Ky(r,i)).adjacentClearance,s=ex(r,a,n),l="hug"===n.lanePlacement?ix(r,o,t,i,a,s,n):[...s];if("hug"===n.lanePlacement){let i=t=>{let i=Hy();for(let r of e)i[r.id]=t[o[r.id]];return i};ox(i(l),t)>ox(i(s),t)+1e-6&&(l=[...s])}let c=Hy();for(let t of e)c[t.id]=l[o[t.id]];let u=1/0,d=-1/0;for(let t of e){let e=c[t.id],r=i[t.id];!Number.isFinite(e)||!r||(u=Math.min(u,e-r.topPeak*n.valueScale),d=Math.max(d,e+r.botPeak*n.valueScale))}return{adjacentClearance:a,centerlines:c,slotCenter:l,stackCenter:s,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&n.plotH>0?Math.max(0,Math.min(1,(d-u)/n.plotH)):0}}function ox(e,t){let i=0;for(let r of t){let t=e[r.source],o=e[r.target];Number.isFinite(t)&&Number.isFinite(o)&&(i+=Math.abs(t-o)*(r.value>0?r.value:1))}return i}function nx(e,t){let i=e?.samples;if(!i||0===i.length||t<i[0].t)return{top:0,bot:0};let r=0,o=i.length-1,n=0;for(;r<=o;){let e=r+o>>>1;i[e].t<=t?(n=e,r=e+1):o=e-1}let a=i[n].boundaryOffset??0;return{top:i[n].topMass-a,bot:i[n].botMass+a}}function ax(e,t,i,r,o){let n=1-o;return n*n*n*e+3*n*n*o*t+3*n*o*o*i+o*o*o*r}function sx(e,t){let i=0,r=1;for(let o=0;o<28;o++){let o=(i+r)/2;ax(0,t,t,1,o)<e?i=o:r=o}return(i+r)/2}function lx(e,t,i){let r=t+tx(e,i),o=e.value*i/2;return[r-o,r+o]}function cx(e,t,i,r){return Math.max(0,Math.min(t,r)-Math.max(e,i))/Math.max(1e-9,t-e)}function ux(e,t,i,r,o,n,a){let{valueScale:s,domain:l,mode:c="quality"}=a,u="source"===a.ribbonLane?.85:"target"===a.ribbonLane?.15:.5,d=0;for(let a of e){let e=r[a.source],h=r[a.target];if(null==e||null==h||Math.abs(e-h)<2)continue;let f=t[a.source]?.localAttachments.get(a.id),p=t[a.target]?.localAttachments.get(a.id);if(!f||!p)continue;let g=Math.max(a.startTime,l?.[0]??-1/0),m=Math.min(a.endTime,l?.[1]??1/0);if(!(m>g))continue;let[y,x]=lx(f,o[a.source],s),[b,v]=lx(p,o[a.target],s),w=Math.min(e,h)+1,k=Math.max(e,h)-1;for(let e=w;e<=k;e++){let r=i[e];if(!r)continue;let l=[g,m];if("quality"===c)for(let e of r.occupants)for(let i of t[e.id]?.samples??[])i.t>g&&i.t<m&&l.push(i.t);let h=e=>{let i=sx((e-g)/(m-g),u),l=ax(y,y,b,b,i),c=ax(x,x,v,v,i),d=0;for(let i of r.occupants){if(i.id===a.source||i.id===a.target)continue;let r=n[i.id];if(null!=r?.start&&e<r.start||null!=r?.end&&e>r.end)continue;let u=nx(t[i.id],e),h=o[i.id];d=Math.max(d,cx(l,c,h-u.top*s,h+u.bot*s))}return d},f=[...new Set(l)].sort((e,t)=>e-t),p=0;for(let e=0;e<f.length-1;e++){let t=f[e],i=f[e+1]-t;p+=(h(t+.25*i)+h(t+.5*i)+h(t+.75*i))/3*i}d+=p/(m-g)*(a.value>0?a.value:1)}}return d}function dx(e,t,i,r,o,n,a,s,l,c,u="both",d){return{crossings:e,weightedLength:t,pixelLength:ox(a,i),transitOcclusion:ux(i,r,o,n,a,s,{valueScale:l,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:c}}function hx(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function fx(e,t){return e.map(e=>({t:hx(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function px(e,t,i){let r=t+(e.boundaryOffset??0)*i,o=e.value*i;if("out"===e.kind){let t=e.sideMassBefore*i;if("top"===e.side){let e=r-t;return[e,e+o]}let n=r+t;return[n-o,n]}let n=e.sideMassAfter*i;if("top"===e.side){let e=r-n;return[e,e+o]}let a=r+n;return[a-o,a]}function gx(e,t,i,r,o){if(0===e.length)return null;let n=fx(e,o),a=e=>t+(n[e].boundaryOffset??0)*i,s=e=>a(e)-n[e].topMass*i,l=e=>a(e)+n[e].botMass*i,c=`M${r(n[0].t)},${s(0)}`;for(let e=1;e<n.length;e++)c+=` L${r(n[e].t)},${s(e)}`;c+=` L${r(n[n.length-1].t)},${l(n.length-1)}`;for(let e=n.length-2;e>=0;e--)c+=` L${r(n[e].t)},${l(e)}`;return c+" Z"}function mx(e,t,i,r,o,n){let a=i.nodeData[e];if(!a||0===a.samples.length)return[];let s=i.valueScale,l=i.centerlines[e],c=fx(a.samples,o),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],h=r(u.t),f=r(d.t),p=e=>r(hx(e,o)),g=[],m=(e,t,i,r)=>`M${e},${t} L${i},${t} L${i},${r} L${e},${r} Z`;for(let i of t){if(i.source===e&&null!=i.systemInTime&&Number.isFinite(i.systemInTime)){let e=a.localAttachments.get(i.id),t=n?.get(i.id)??i.startTime;if(e&&"out"===e.kind&&i.systemInTime<t){let r=p(i.systemInTime),n=p(t),a=null!=o&&i.systemInTime<o[0],c=a?r:r-20,u=a?Math.min(n,r+20):r,d=Math.max(h,c);if(n>d){let[t,i]=px(e,l,s);g.push({pathD:m(d,t,n,i),x0:c,x1:u,from:0,to:1})}}}if(i.target===e&&null!=i.systemOutTime&&Number.isFinite(i.systemOutTime)){let e=a.localAttachments.get(i.id);if(e&&"in"===e.kind&&i.systemOutTime>i.endTime){let t=p(i.systemOutTime),r=p(i.endTime),o=t+20,n=Math.min(f,o);if(n>r){let[i,a]=px(e,l,s);g.push({pathD:m(r,i,n,a),x0:t,x1:o,from:1,to:0})}}}}return g}function yx(e,t){let i=Hy(),r=Hy();for(let t of e)i[t.id]=[],r[t.id]=[];for(let e of t)r[e.source]&&r[e.source].push(e),i[e.target]&&i[e.target].push(e);return{incoming:i,outgoing:r}}function xx(e,t,i,r="temporal"){let o="temporal"===r?(e,t)=>e.endTime-t.endTime||Uy(e.id,t.id):(e,t)=>t.value-e.value||Uy(e.id,t.id),n="temporal"===r?(e,t)=>e.startTime-t.startTime||Uy(e.id,t.id):(e,t)=>t.value-e.value||Uy(e.id,t.id),a=/* @__PURE__ */new Map;for(let e of t)a.set(e.id,{});let s=(e,t)=>{let i=/* @__PURE__ */new Map;for(let r of e){let e=r[t];i.has(e)||i.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});let o=i.get(e);o.edges.push(r),o.total+=r.value,o.earliestStart=Math.min(o.earliestStart,r.startTime),o.latestEnd=Math.max(o.latestEnd,r.endTime)}let a=[...i.values()];"temporal"===r?a.sort((e,i)=>"target"===t?e.earliestStart-i.earliestStart||Uy(e.partner,i.partner):e.latestEnd-i.latestEnd||Uy(e.partner,i.partner)):a.sort((e,t)=>t.total-e.total||Uy(e.partner,t.partner));for(let e of a)e.edges.sort("target"===t?n:o);return a};for(let t of e){let e=i.outgoing[t.id],r=i.incoming[t.id];if(0===r.length)s(e,"target").forEach((e,t)=>{let i=t%2==0?"top":"bot";for(let t of e.edges)a.get(t.id).sourceSide=i});else if(0===e.length)s(r,"source").forEach((e,t)=>{let i=t%2==0?"top":"bot";for(let t of e.edges)a.get(t.id).targetSide=i});else{let t=s(r,"source"),i=s(e,"target"),o=Math.max(t.length,i.length);for(let e=0;e<o;e++){let r=e%2==0?"top":"bot";if(t[e])for(let i of t[e].edges)a.get(i.id).targetSide=r;if(i[e])for(let t of i[e].edges)a.get(t.id).sourceSide=r}}}return a}function bx(e,t,i,r,o="temporal"){let n=t.incoming[e.id],a=t.outgoing[e.id],s=[];for(let e of n)s.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:i.get(e.id).targetSide});for(let e of a)s.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:i.get(e.id).sourceSide});let l={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},c=(e,t)=>{if(!r||!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;let i=r.get(e.edge.id)?.target,o=r.get(t.edge.id)?.target;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?i-o:o-i:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;let i=r.get(e.edge.id)?.source,o=r.get(t.edge.id)?.source;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?o-i:i-o:0}return 0},u=()=>{s.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)||c(e,t)||Uy(e.edge?.id??"",t.edge?.id??"")||Uy(e.side,t.side)||e.delta-t.delta)},d=s.length?Fe(s.map(e=>e.time)):null,h=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,f=null!=h?h-1:null!=d&&Number.isFinite(d)?d-1:null;u();let p=null,g=0;for(let e of s)e.time!==p&&(p=e.time,g=0),e.sequence=g++;let m=e=>({time:e.time,phase:0,sequence:e.sequence??0}),y=[],x=0,b=0;for(let e of s)if("out"===e.kind){let t=Math.abs(e.delta),i=t-("top"===e.side?x:b);if(i>0){let t="top"===e.side?"bot":"top",r=Math.min(i,"top"===t?x:b);if(r>0){let o=m(e);y.push({...o,delta:-r,kind:"transfer-out",side:t}),y.push({...o,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?x-=r:b-=r,"top"===e.side?x+=r:b+=r,i-=r}i>0&&null!==f&&(y.push({time:f,delta:+i,kind:"create",side:e.side}),"top"===e.side?x+=i:b+=i)}"top"===e.side?x-=t:b-=t}else if("in"===e.kind){let t=Math.abs(e.delta);"top"===e.side?x+=t:b+=t}s.push(...y),u();let v=0,w=0,k=0,A=0,S=0,M=0,$=[],_=/* @__PURE__ */new Map,L=e=>{$.push({t:e,topMass:v,botMass:w,...Math.abs(k)>1e-12&&{boundaryOffset:k}})},P=()=>{A=Math.max(A,v+w),S=Math.max(S,v-k),M=Math.max(M,w+k)};for(let e of s){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&L(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){let t="top"===e.side?v:w,i=t+e.delta;_.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:i,kind:e.kind,value:Math.abs(e.delta),...Math.abs(k)>1e-12&&{boundaryOffset:k}})}"top"===e.side?v+=e.delta:w+=e.delta,"transfer-in"===e.kind?(k+="top"===e.side?e.delta:-e.delta,P(),L(e.time)):"transfer-out"!==e.kind&&(P(),"out"===e.kind&&v+w<=1e-12&&(k=0),L(e.time))}let I=[],R=0;for(;R<$.length;){let e=R;for(;e+1<$.length&&$[e+1].t===$[R].t;)e++;I.push($[R]);for(let t=R+1;t<=e;t++){let e=I[I.length-1];($[t].topMass!==e.topMass||$[t].botMass!==e.botMass||($[t].boundaryOffset??0)!==(e.boundaryOffset??0))&&I.push($[t])}R=e+1}let T=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null,C=null;for(let e of a)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.systemInTime<e.startTime&&(null===C||e.systemInTime<C)&&(C=e.systemInTime);let N=null;for(let e of n)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===N||e.systemOutTime>N)&&(N=e.systemOutTime);if(I.length>0){let e=I[I.length-1],t=Math.max(T??-1/0,N??-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&I.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});let i,r=I[0],o=I.find(e=>e.topMass+e.botMass>0),n=1/0;null!=h&&Number.isFinite(h)&&h<r.t&&r.topMass+r.botMass>0&&(n=h,i=r),o&&null!=C&&Number.isFinite(C)&&C<o.t&&C<n&&(n=C,i=o),i&&Number.isFinite(n)&&I.unshift({t:n,topMass:i.topMass,botMass:i.botMass,...null!=i.boundaryOffset&&{boundaryOffset:i.boundaryOffset}})}let F=I;if("max"===o&&null!=h&&null!=T&&T>h){let e,t=0;for(let i of I){let r=i.topMass+i.botMass;r>t&&(t=r,e=i)}if(e){let t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};F=[...I.filter(e=>e.t<h),{t:h,...t},{t:T,...t},...I.filter(e=>e.t>T)]}}return{samples:F,peak:A,topPeak:S,botPeak:M,localAttachments:_}}function vx(e,t,i,r){let o=/* @__PURE__ */new Map;for(let n of e){let e=t[n.source]?.localAttachments.get(n.id),a=t[n.target]?.localAttachments.get(n.id),s=i[n.source],l=i[n.target];if(!(e&&a&&Number.isFinite(s)&&Number.isFinite(l)))continue;let c=px(e,s,r),u=px(a,l,r);o.set(n.id,{source:(c[0]+c[1])/2,target:(u[0]+u[1])/2})}return o}function wx(e,t){let i=(e,i)=>{for(let r of e){let e=/* @__PURE__ */new Map;for(let o of r){let r=`${("out"===i?t.get(o.id)?.sourceSide:t.get(o.id)?.targetSide)??""}\0${"out"===i?o.startTime:o.endTime}`,n="out"===i?`${o.target}\0${o.endTime}`:`${o.source}\0${o.startTime}`,a=e.get(r);if(null!=a&&a!==n)return!0;e.set(r,n)}}return!1};return i(Object.values(e.outgoing),"out")||i(Object.values(e.incoming),"in")}function kx(e,t,i){let r=/* @__PURE__ */new Map,o=[];for(let t of e)o.push({time:t.startTime,kind:"out",edge:t}),o.push({time:t.endTime,kind:"in",edge:t});o.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)||Uy(e.edge.id,t.edge.id));let n=e=>{let t=r.get(e);return t||(t={top:0,bot:0},r.set(e,t)),t},a=(e,t,i)=>{let r="top"===t?"bot":"top",o=Math.min(i,e[t]);e[t]-=o;let n=i-o;n>0&&(e[r]=Math.max(0,e[r]-n))};for(let e of o){let{edge:r}=e;if("in"===e.kind){let e=t.get(r.id)?.targetSide??"bot";n(r.target)[e]+=r.value;continue}let o=n(r.source),s=t.get(r.id),l=s.sourceSide??"bot";if(i[r.source]===i[r.target]){let e=o.top>=r.value,t=o.bot>=r.value;e!==t?l=e?"top":"bot":!e&&!t&&o.top!==o.bot&&(l=o.top>o.bot?"top":"bot"),s.sourceSide=l,s.targetSide=l}a(o,l,r.value)}}function Ax(e,t,i,r){for(let o of e){let e=t.incoming[o.id],n=t.outgoing[o.id];if(0===e.length||0===n.length)continue;let a=()=>{let t={inTop:0,inBot:0,outTop:0,outBot:0};for(let r of e)"top"===i.get(r.id).targetSide?t.inTop+=r.value:t.inBot+=r.value;for(let e of n)"top"===i.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},s=(e,t)=>{let o=a(),s="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,l="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(s<=0||l<=0)return!1;let c=Math.min(s,l),u=n.filter(t=>!r.has(t.id)&&i.get(t.id).sourceSide===e&&t.value<=c).sort((e,t)=>t.value-e.value||Uy(e.id,t.id));return 0!==u.length&&(i.get(u[0].id).sourceSide=t,!0)},l=n.length+1;for(;l-- >0&&(s("top","bot")||s("bot","top")););}}var Sx=(e,t)=>{let i=0,r=e.length;for(;i<r;){let o=i+r>>>1;e[o]<t?i=o+1:r=o}return i},Mx=class{constructor(e){this.coordinates=[...new Set(e)].sort((e,t)=>e-t),this.tree=new Int32Array(this.coordinates.length+1)}add(e,t){for(let i=Sx(this.coordinates,e)+1;i<this.tree.length;i+=i&-i)this.tree[i]+=t}below(e){let t=0;for(let i=Sx(this.coordinates,e);i>0;i-=i&-i)t+=this.tree[i];return t}};function $x(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.max(e.startTime,t.startTime)<Math.min(e.endTime,t.endTime)}var _x=class{constructor(e,t,i){this.size=i,this.routes=[],this.outgoing=Array.from({length:i},()=>[]),this.incoming=Array.from({length:i},()=>[]);let r=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;for(let e of t.keys())o.set(e,o.size);this.nodeCount=o.size;for(let i of e){let e=t.get(i.source),n=t.get(i.target);if(void 0===e||void 0===n||!(i.startTime<i.endTime))continue;let a=o.get(i.source),s=o.get(i.target),l=`${a}:${s}`;r.has(l)||r.set(l,r.size);let c=this.routes.length;this.routes.push({edge:i,source:e,target:n,sourceNode:a,targetNode:s,pair:r.get(l),reverse:-1}),this.outgoing[e].push(c),this.incoming[n].push(c)}for(let e of this.routes)e.reverse=r.get(`${e.targetNode}:${e.sourceNode}`)??-1;if(this.events=this.routes.flatMap((e,t)=>[{time:e.edge.startTime,route:t,delta:1},{time:e.edge.endTime,route:t,delta:-1}]).sort((e,t)=>e.time-t.time||e.delta-t.delta||e.route-t.route),this.smallPairs=this.routes.length<=80?[]:null,this.smallPairs)for(let e=0;e<this.routes.length;e++)for(let t=e+1;t<this.routes.length;t++)$x(this.routes[e].edge,this.routes[t].edge)&&this.smallPairs.push([e,t]);this.work=this.smallPairs?.length??1/0}crossing(e,t,i){return(i[e.source]-i[t.source])*(i[e.target]-i[t.target])<0?1:0}count(e){if(this.smallPairs){let t=0;for(let[i,r]of this.smallPairs)t+=this.crossing(this.routes[i],this.routes[r],e);return t}let t=Array.from({length:this.size+1},()=>[]);for(let i of this.routes){let r=e[i.source],o=e[i.target];for(let e=r+1;e<=this.size;e+=e&-e)t[e].push(o)}let i=t.map(e=>new Mx(e)),r=new Int32Array(4*this.nodeCount),o=new Int32Array(this.routes.length),n=(e,t)=>{let r=0;for(let o=e;o>0;o-=o&-o)r+=i[o].below(t);return r},a=0;for(let t of this.events){let s=this.routes[t.route],l=e[s.source],c=e[s.target];1===t.delta&&(a+=n(l,this.size)-n(l,c+1)+n(this.size,c)-n(l+1,c),l!==c&&(a-=r[4*s.sourceNode+(l<c?1:0)],a-=r[4*s.targetNode+(l<c?2:3)],s.reverse>=0&&(a+=o[s.reverse])));for(let e=l+1;e<=this.size;e+=e&-e)i[e].add(c,t.delta);l!==c&&(r[4*s.sourceNode+(l<c?3:2)]+=t.delta,r[4*s.targetNode+(l<c?0:1)]+=t.delta),o[s.pair]+=t.delta}return a}swapDelta(e,t,i){let r=0,o=0,n=r=>i[r===e?t:r===t?e:r],a=(e,t)=>{let a=this.routes[e],s=this.routes[t];if(!$x(a.edge,s.edge))return;o++;let l=(n(a.source)-n(s.source))*(n(a.target)-n(s.target))<0?1:0;r+=l-this.crossing(a,s,i)};for(let i of this.outgoing[e])for(let e of this.outgoing[t])a(i,e);for(let i of this.incoming[e])for(let r of this.incoming[t]){let o=this.routes[i],n=this.routes[r];o.source===e&&n.source===t||o.source===t&&n.source===e||a(i,r)}return{delta:r,evaluations:o}}};function Lx(e){let t=Hy();return e.forEach((e,i)=>{for(let r of e.occupants)t[r.id]=i}),t}function Px(e,t,i){e.splice(0,e.length,...i);let r=Lx(i);for(let e of Object.keys(t))delete t[e];Object.assign(t,r)}function Ix(e){let t=/* @__PURE__ */new Map,i=[];e.forEach((e,r)=>{if(!e.group)return void i.push({anchor:r,stableId:Zy(e),slots:[e]});let o=t.get(e.group)??{indexes:[],slots:[]};o.indexes.push(r),o.slots.push(e),t.set(e.group,o)});for(let[e,r]of t)i.push({anchor:r.indexes.reduce((e,t)=>e+t,0)/r.indexes.length,stableId:`${e}\0${r.slots.map(Zy).join("\0")}`,slots:r.slots});return i.sort((e,t)=>e.anchor-t.anchor||Uy(e.stableId,t.stableId))}function Rx(e){return e.some(e=>e.group)?Ix(e).flatMap(e=>e.slots):[...e]}function Tx(e){let t=/* @__PURE__ */new Set;for(let i of e)if(i.group){if(t.has(i.group))return!0;t.add(i.group)}return!1}function Cx(e){return e.flatMap(e=>e.slots)}function Nx(e,t){let i=/* @__PURE__ */new Map;for(let t of e)for(let e of t.slots)i.set(e,t);let r=/* @__PURE__ */new Map;for(let e of t){let t=i.get(e.source),o=i.get(e.target);if(!t||!o||t===o)continue;let n=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,a=t.stableId<o.stableId?`${t.stableId}\0${o.stableId}`:`${o.stableId}\0${t.stableId}`,s=r.get(a);s?s.weight=(s.weight??0)+n:r.set(a,{source:t,target:o,weight:n})}return[...r.values()]}function Fx(e,t,i){let r=/* @__PURE__ */new Map;return e.forEach((e,t)=>{for(let i of e.slots)r.set(i,t)}),e.map((e,o)=>{if(e.slots.length<=1)return e;let n=/* @__PURE__ */new Map;for(let t of e.slots)n.set(t,0);for(let e of t){let t=r.get(e.source),i=r.get(e.target);if(null==t||null==i)continue;let a=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===o&&i!==o){let t=i>o?1:-1;n.set(e.source,(n.get(e.source)??0)+a*t)}else if(i===o&&t!==o){let i=t>o?1:-1;n.set(e.target,(n.get(e.target)??0)+a*i)}}let a=[...e.slots].sort((e,t)=>(n.get(e)??0)-(n.get(t)??0)||i(e,t));return{...e,slots:a}})}function zx(e,t){e.some(e=>e.group)&&Px(e,t,Rx(e))}function Ex(e,t,i=0){return e.crossings<t.crossings||e.crossings===t.crossings&&e.cost<=t.cost+i}function Dx({order:e,after:t,nodes:i,edges:r,outgoingPartners:o,incomingPartners:n,slotForNode:a,averageGap:s,evaluate:l}){let c=(i,o)=>{let n=[...new Set(o.map(t=>e.indexOf(t)))].sort((e,t)=>e-t),a=e.indexOf(i),c=n[0],u=n[n.length-1];if(n.length<3||!n.includes(a)||u-c+1!==n.length||Math.abs(2*a-c-u)<=1)return;let d=[...e];d.splice(a,1),d.splice(c+u>>1,0,i);let h=Rx(d),f=l(h),p=new Set(i.occupants.map(e=>e.id)),g=new Set(o.flatMap(e=>e.occupants.map(e=>e.id))),m=r.reduce((e,t)=>p.has(t.source)&&g.has(t.target)||p.has(t.target)&&g.has(t.source)?e+(t.value>0?t.value:1):e,0),y=Math.abs(2*a-c-u)*s*Math.max(1,m);Ex(f,t,y)&&(e=h,t=f)};for(let[e,t]of o)!n.has(e)&&t.size>=3&&c(a.get(e),[...t].map(e=>a.get(e)));for(let e of i){let t=a.get(e.id);!e.group&&t.group&&(n.get(e.id)?.size??0)>=3&&c(t,[...n.get(e.id)??[]].map(e=>a.get(e)).filter(e=>e===t||e.group===t.group).filter((e,t,i)=>i.indexOf(e)===t))}return{order:e,after:t}}function Ox(e,t){let i=[...new Set(Object.values(e))].sort((e,t)=>e-t),r=new Map(i.map((e,t)=>[e,t])),o=new Map(Object.entries(e).map(([e,t])=>[e,r.get(t)]));return new _x(t,o,i.length).count(i.map((e,t)=>t))}function jx(e,t){let i=0;for(let r of t){let t=e[r.source],o=e[r.target];null==t||null==o||(i+=Math.abs(t-o)*(r.value>0?r.value:1))}return i}var Wx=e=>{let t=1;for(let i=2;i<=e;i++)t*=i;return t},Bx=/* @__PURE__ */828*Wx(8),Yx=3e3;function Gx(e){let t=new Array(e.length),i=Math.floor((e.length-1)/2),r=i-1,o=i+1;e.length>0&&(t[i]=e[0]);for(let i=1;i<e.length;i++)i%2==1&&o<e.length?t[o++]=e[i]:r>=0?t[r--]=e[i]:t[o++]=e[i];return t}function Xx(e,t,i){let r=i(e),o=r,n=[...e],a=Math.floor((e.length-1)/2);for(let s of t){let t=e.indexOf(s);if(t===a)continue;e.splice(t,1),e.splice(a,0,s);let l=i(e);l<=r?(r=l,l<o&&(n=[...e],o=l)):(e.splice(a,1),e.splice(t,0,s))}return n}function Vx(e,t,i,r,o,n,a){let s=[...o],l=new Map(o.map(e=>[e,Zy(e)])),c=/* @__PURE__ */new Map;for(let e of o)for(let t of e.occupants)c.set(t.id,e);let u=/* @__PURE__ */new Map,d=[];for(let e of t){let t=c.get(e.source),i=c.get(e.target);!t||!i||(u.set(e,[t,i]),t!==i&&d.push({source:t,target:i,weight:e.value}))}let h=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),f=a.plotH/Math.max(1,o.length),p=o.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),g=Math.max(1,h)*(Math.max(1,a.plotH)+f*Math.max(p,o.length)+1e-6*Math.max(1,o.length-1))+1,m=4*f,y={fullCrossing:0,localCrossing:0},x=/* @__PURE__ */new Map,b=(e,t)=>{let r=x.get(e);r||(r=/* @__PURE__ */new Map,x.set(e,r));let o=r.get(t);if(null!=o)return o;let n=Jy(e,t,i);return r.set(t,n),n},v=new Map(o.map((e,t)=>[e,t])),w=new _x(t,new Map([...c].map(([e,t])=>[e,v.get(t)])),o.length),k=e=>{let t=new Int32Array(o.length);for(let i=0;i<e.length;i++)t[v.get(e[i])]=i;return t},A=new Map([...u].map(([e,[t,i]])=>[e,{source:v.get(t),target:v.get(i),weight:e.value>0?e.value:1}])),S=[...A.values()],M=/* @__PURE__ */new Map,$=/* @__PURE__ */new Map,_=/* @__PURE__ */new Map,L=(e,t,i)=>{e.has(t)||e.set(t,/* @__PURE__ */new Set),e.get(t).add(i)};for(let e of t)L(M,e.source,e.target),L($,e.target,e.source),L(_,e.source,e.target),L(_,e.target,e.source);let P=e=>1===M.get(e.source)?.size&&M.get(e.source).has(e.target)||1===_.get(e.source)?.size||1===_.get(e.target)?.size,I=t.flatMap(e=>{if(!P(e))return[];let t=A.get(e);return t&&t.source!==t.target?[t]:[]}),R=e=>{let t=0;for(let i of I)t+=Math.max(0,Math.abs(e[i.source]-e[i.target])-1)*i.weight;return t*m},T=e=>R(k(e)),C=new Int32Array(o.length),N=new Float64Array(o.length),F=new Float64Array(o.length+1),z=e=>{for(let t=0;t<e.length;t++)C[v.get(e[t])]=t;let t=w.count(C);if(e.length>0){let t=v.get(e[0]);N[t]=a.padding+e[0].peak.topPeak*a.valueScale;for(let t=1;t<e.length;t++){let i=v.get(e[t-1]),r=v.get(e[t]);N[r]=N[i]+b(e[t-1],e[t])*a.valueScale+a.padding}let i=v.get(e[e.length-1]),r=N[i]+e[e.length-1].peak.botPeak*a.valueScale+a.padding;if(r>a.plotH&&r>0){let e=a.plotH/r;for(let t=0;t<N.length;t++)N[t]*=e}}F[0]=0;for(let t=0;t<e.length;t++)F[t+1]=F[t]+e[t].peak.topPeak+e[t].peak.botPeak;let i=0,r=0,o=0;for(let e of S){let t=C[e.source],n=C[e.target];if(i+=Math.abs(t-n)*e.weight,r+=Math.abs(N[e.source]-N[e.target])*e.weight,Math.abs(t-n)>=2){let i=Math.min(t,n)+1,r=Math.max(t,n);o+=(F[r]-F[i])*e.weight}}return t*g+r+o*f+R(C)+1e-6*i},E=(e,i)=>{let r=new Array(e.length+1).fill(0);for(let t=0;t<e.length;t++)r[t+1]=r[t]+e[t].peak.topPeak+e[t].peak.botPeak;let o=0;for(let e of t){let t=i[e.source],n=i[e.target];if(null==t||null==n||Math.abs(t-n)<2)continue;let a=Math.min(t,n)+1;o+=(r[Math.max(t,n)]-r[a])*(e.value>0?e.value:1)}return o},D=r=>{let o=Lx(r),n=r.slice(0,-1).map((e,t)=>b(e,r[t+1])),s=rx(e,t,i,r,o,{plotH:a.plotH,padding:a.padding,valueScale:a.valueScale,lanePlacement:a.lanePlacement??"stack",groupPadding:a.groupPadding,adjacentClearance:n});return{map:o,geometry:s,weightedLength:jx(o,t),pixelLength:ox(s.centerlines,t)}},O=(e,o,n)=>{let s=o;null==s&&(s=w.count(k(e)),y.fullCrossing++);let{map:l,geometry:c,weightedLength:u,pixelLength:d}=D(e),h=n?ux(t,i,e,l,c.centerlines,r,{valueScale:a.valueScale,ribbonLane:a.ribbonLane,domain:a.domain,mode:n}):E(e,l);return{crossings:s,weightedLength:u,pixelLength:d,transitOcclusion:h,cost:s*g+d+h*f+T(e)+1e-6*u}},j=(e,t,i="quality")=>O(e,t,i),W=[...s],B=(e,t)=>Uy(l.get(e),l.get(t)),Y=Tx(W),G=(e,t,i,r=Yx)=>{let o=t(e);for(let n=0;n<i&&r>0;n++){let i=!1,a=Array.from({length:e.length-1},(e,t)=>t);n%2==1&&a.reverse();for(let n of a){if(r--<=0)break;let a=e[n],s=e[n+1],l=w.swapDelta(v.get(a),v.get(s),k(e));[e[n],e[n+1]]=[s,a],y.localCrossing+=l.evaluations;let c=t(e,o.crossings+l.delta);c.cost<o.cost?(o=c,i=!0):[e[n],e[n+1]]=[a,s]}if(!i)break}return e},X=e=>{let t=Re(e,d,e=>O(e).cost,{passes:6,compare:B,maxEvaluations:Yx});return G(t,O,6)},V=e=>{let t=X(e);if((e.length<=8?Wx(e.length)*(e.length+S.length+w.work):1/0)>Bx)return t;let i=Ce(e,z,{maxItems:8,maxEvaluations:5e4}),r=j(i),o=j(t);return r.crossings!==o.crossings&&r.crossings<o.crossings?i:t},q=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),H=(e,t)=>q(t)-q(e)||Uy(e.stableId,t.stableId),U=(e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||B(e,t),Z="geometry-refine"===a.mode;if(Z||"crossing-min"!==a.laneOrder&&"crossing-min+inside-out"!==a.laneOrder?Z||"inside-out"!==a.laneOrder||(W=Y?Cx(Gx([...Ix(W)].sort(H))):Gx([...W].sort(U))):W=Y?(e=>{let t=Ix(e);if(t.length<=1)return Cx(t);let i=e=>O(Cx(e)).cost;t=Ix(V(e)),t=Fx(t,d,B);let r=Nx(t,d);if(t=Re(t,r,i,{passes:6,compare:(e,t)=>Uy(e.stableId,t.stableId),maxEvaluations:Yx}),t=Te(t,i,{passes:8,maxEvaluations:Yx}),(t.length<=8?Wx(t.length)*(t.length+S.length+w.work):1/0)<=Bx){let e=Ce(t,e=>z(Cx(e)),{maxItems:8,maxEvaluations:5e4}),i=Cx(e),r=Cx(t),o=j(i),n=j(r);o.crossings!==n.crossings?t=o.crossings<n.crossings?e:t:o.cost<n.cost&&(t=e)}return t=Fx(t,d,B),Cx(t)})(W):V(W),!Z&&"crossing-min+inside-out"===a.laneOrder&&W.length>1)if(Y){let e=Ix(W);W=Cx(Xx(e,[...e].sort(H),e=>O(Cx(e)).cost))}else W=Xx(W,[...W].sort(U),e=>O(e).cost);if((Z||"crossing-min"===a.laneOrder||"crossing-min+inside-out"===a.laneOrder)&&W.length>1)if(Y){let e=Te(Ix(W),e=>j(Cx(e),void 0,"score").cost,{passes:6});e=Fx(e,d,B),W=Cx(e)}else G(W,(e,t)=>j(e,t,"score"),1,1/0);let Q=Rx(s);W=Rx(W);let K=j(W),J=j(Q);if(Z){let e=T(Q),t=T(W);(K.crossings>J.crossings||K.crossings===J.crossings&&t>e+1e-9||K.cost>J.cost)&&(W=Q,K=J)}else K.cost>J.cost&&(W=Q,K=J);let ee=Dx({order:W,after:K,nodes:e,edges:t,outgoingPartners:M,incomingPartners:$,slotForNode:c,averageGap:f,evaluate:j});return W=ee.order,K=ee.after,Px(o,n,W),{before:J,after:K,initialOrder:s.map(e=>l.get(e)),evaluations:y}}function qx(e,t,i){let r=new Map(i.map((e,t)=>[e,t]));Px(e,t,[...e].sort((e,t)=>(r.get(Zy(e))??1/0)-(r.get(Zy(t))??1/0)||Uy(Zy(e),Zy(t))))}function Hx(e,t,i){let r=e.map(e=>{let r=e.occupants.map(e=>({id:e.id,end:i[e.id]?.end??e.end})),o=0,n=0;for(let e of r){let i=t[e.id];o=Math.max(o,i?.topPeak||0),n=Math.max(n,i?.botPeak||0)}return{occupants:r,peak:{topPeak:o,botPeak:n},...null!=e.group?{group:e.group}:{}}}),o=Hy();return r.forEach((e,t)=>{for(let i of e.occupants)o[i.id]=t}),{slots:r,slotByNode:o}}function Ux(e,t,i,r){return`${e.map(e=>{let t=i[e.id],o=r[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,o?.start??"",o?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}var Zx=/* @__PURE__ */new Map;function Qx(e){return Zx.get(e)}function Kx(e,t){for(Zx.has(e)&&Zx.delete(e),Zx.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(Hy(),t.slotByNode)});Zx.size>12;){let e=Zx.keys().next().value;if(null==e)break;Zx.delete(e)}}var Jx=1e5,eb=1e-9;function tb(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(e.end<=t.start||t.end<=e.start)}function ib(e,t){return Uy(e,t)<=0?`${e}\0${t}`:`${t}\0${e}`}function rb(e){let t=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(let r of e)i.has(r.source)||i.set(r.source,/* @__PURE__ */new Set),t.has(r.target)||t.set(r.target,/* @__PURE__ */new Set),i.get(r.source).add(r.target),t.get(r.target).add(r.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...i].map(([e,t])=>[e,t.size]))}}function ob(e){let t=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map,r=(e,t,i,r)=>{let o=e.get(t);o||(o=/* @__PURE__ */new Map,e.set(t,o)),o.set(i,(o.get(i)??0)+r)};for(let o of e){let e=o.value>0&&Number.isFinite(o.value)?o.value:1;r(t,o.source,o.target,e),r(i,o.target,o.source,e)}let o=/* @__PURE__ */new Map,n=e=>{if(o.has(e))return;let r=t.get(e),n=i.get(e),a=/* @__PURE__ */new Map;for(let[e,t]of r??[])a.set(e,(a.get(e)??0)+t);for(let[e,t]of n??[])a.set(e,(a.get(e)??0)+t);if(1===a.size){let[t,i]=[...a][0];o.set(e,{partner:t,weight:i})}};for(let t of e)n(t.source),n(t.target);return o}function nb(e,t,i){let r=i.get(e),o=i.get(t);return!r||!o||r.partner===o.partner||r.partner===t||o.partner===e}function ab(e,t,i){return!!i.has(e)&&t.some(t=>!nb(e,t,i))}function sb(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 lb(e,t,i,r,o,n){let a=/* @__PURE__ */new Set,s=new Map(e.map(e=>[e,/* @__PURE__ */new Set])),l=new Map(e.map(e=>[e,/* @__PURE__ */new Set]));for(let e of r)a.add(ib(e.source,e.target)),s.get(e.target)?.add(e.source),l.get(e.source)?.add(e.target);let c=/* @__PURE__ */new Map,u=/* @__PURE__ */new Set,d=(e,t)=>{for(let i=0;i<e.length;i++)for(let r=i+1;r<e.length;r++){let o=ib(e[i],e[r]);t instanceof Map?t.set(o,[e[i],e[r]]):t.add(o)}};for(let e of l.values())d([...e],c);for(let e of s.values())d([...e],u);let h=/* @__PURE__ */new Set;for(let[e,[r,o]]of c)u.has(e)&&(tb(t[r],t[o])||tb(i[r],i[o])&&(h.add(r),h.add(o)));return{conflicts:(e,i)=>{let r=o.get(e),s=o.get(i);return!((null==r||null==s||r===s)&&(null!=r==(null!=s)||a.has(ib(e,i))||n.has(e)&&n.has(i)&&nb(e,i,n))&&!tb(t[e],t[i])&&(!h.has(e)&&!h.has(i)||a.has(ib(e,i))))}}}function cb(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,i)=>t[e.id].start-t[i.id].start||t[e.id].end-t[i.id].end||Uy(e.id,i.id)).map(e=>e.id)}function ub(e,t,i=/* @__PURE__ */new Map){let r=[],o=[];for(let n of e){let e=r.findIndex(e=>e.every(e=>!t.conflicts(n,e))&&!ab(n,e,i));-1===e&&!i.has(n)&&(e=r.findIndex(e=>e.every(e=>!t.conflicts(n,e)))),-1===e&&(e=r.length,r.push([])),r[e].push(n),o.push(e)}return{assignment:o,slotCount:r.length}}function db(e,t,i,r){if(e.length<=12||r.slotCount<=1)return r.assignment;let o=new Map(e.map((e,t)=>[e,t])),n=Array.from({length:e.length},()=>/* @__PURE__ */new Map),a=rb(i);for(let e of i){let t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;let r=sb(e,a);n[t].set(i,(n[t].get(i)??0)+r),n[i].set(t,(n[i].get(t)??0)+r)}let s=ob(i),l=e.map(e=>s.get(e)?.weight??0),c=Array.from({length:e.length},()=>/* @__PURE__ */new Map),u=0;for(let i=0;i<e.length-1&&u<5e4;i++)if(s.has(e[i]))for(let r=i+1;r<e.length;r++){if(!s.has(e[r])||t.conflicts(e[i],e[r]))continue;u++;let o=Math.min(l[i],l[r])||Math.max(l[i],l[r]),n=nb(e[i],e[r],s)?o:-o;if(!(Math.abs(n)<=eb)&&(c[i].set(r,n),c[r].set(i,n),u>=5e4))break}let d=[...r.assignment],h=Array.from({length:r.slotCount},()=>[]);d.forEach((e,t)=>h[e].push(t));let f=(e,t,i)=>{let r=d[t],o=d[i],n=0,a=/* @__PURE__ */new Set;for(let s of[t,i])for(let[l,c]of e[s]){let e=s<l?`${s}:${l}`:`${l}:${s}`;if(a.has(e))continue;a.add(e);let u=d[s]===d[l],h=(s===t?o:r)===(l===t?o:l===i?r:d[l]);u!==h&&(n+=h?c:-c)}return n},p=(e,t,i)=>{let r=0;for(let[o,n]of e[t]){let e=d[t]===d[o],a=i===d[o];e!==a&&(r+=a?n:-n)}return r},g=(e,t)=>e>eb||Math.abs(e)<=eb&&t>eb,m=(e,t,i,r)=>e>i+eb||Math.abs(e-i)<=eb&&t>r+eb,y=0;for(let i=0;i<32&&y<Jx;i++){let i=null,r=-1,o=-1,a=-1,s=-1/0,l=-1/0;for(let u=0;u<e.length;u++){for(let f=0;f<h.length&&!(y++>=Jx);f++){if(f===d[u]||!h[f].every(i=>!t.conflicts(e[u],e[i])))continue;let y=p(n,u,f),x=p(c,u,f);g(y,x)&&m(y,x,s,l)&&(i="move",r=u,o=-1,a=f,s=y,l=x)}if(y>=Jx)break}for(let u=0;u<e.length-1;u++){for(let p=u+1;p<e.length&&!(y++>=Jx);p++){let y=d[u],x=d[p];if(y===x||!h[x].every(i=>i===p||!t.conflicts(e[u],e[i]))||!h[y].every(i=>i===u||!t.conflicts(e[p],e[i])))continue;let b=f(n,u,p),v=f(c,u,p);g(b,v)&&m(b,v,s,l)&&(i="swap",r=u,o=p,a=-1,s=b,l=v)}if(y>=Jx)break}if(null==i||-1===r)break;if("move"===i){let e=d[r];h[e].splice(h[e].indexOf(r),1),h[a].push(r),d[r]=a;continue}let u=d[r],x=d[o];h[u].splice(h[u].indexOf(r),1,o),h[x].splice(h[x].indexOf(o),1,r),d[r]=x,d[o]=u}return d}function hb(e,t){for(let i=0;i<Math.min(e.length,t.length);i++)if(e[i]!==t[i])return e[i]<t[i];return e.length<t.length}function fb(e,t,i,r){if(0===e.length||e.length>12||r.slotCount<=1)return r.assignment;let o=new Map(e.map((e,t)=>[e,t])),n=Array.from({length:e.length},()=>new Float64Array(e.length)),a=Array.from({length:e.length},()=>/* @__PURE__ */new Map),s=Array.from({length:e.length},()=>/* @__PURE__ */new Map),l=rb(i);for(let e of i){let t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;let r=sb(e,l);n[t][i]+=r,n[i][t]+=r,s[t].set(i,(s[t].get(i)??0)+r),a[i].set(t,(a[i].get(t)??0)+r)}let c=ob(i),u=e.map(e=>c.get(e)?.weight??0),d=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;t<e.length;t++)for(let i=t+1;i<e.length;i++){for(let[e,r]of a[t])d[t][i]+=Math.min(r,a[i].get(e)??0);for(let[e,r]of s[t])d[t][i]+=Math.min(r,s[i].get(e)??0);if(c.has(e[t])&&c.has(e[i])){let r=Math.min(u[t],u[i])||Math.max(u[t],u[i]);d[t][i]+=nb(e[t],e[i],c)?r:-r}d[i][t]=d[t][i]}let h=[...r.assignment],f=(t=>{let i=0,r=0;for(let o=0;o<e.length;o++)for(let a=o+1;a<e.length;a++)t[o]===t[a]&&(i+=n[o][a],r+=d[o][a]);return{flow:i,affinity:r}})(h),p=0,g=new Array(e.length).fill(-1),m=Array.from({length:r.slotCount},()=>[]),y=(i,o,a,s)=>{if(p>=75e3)return;if(i===e.length)return p++,void((a>f.flow||a===f.flow&&s>f.affinity||a===f.flow&&s===f.affinity&&hb(g,h))&&(h=[...g],f={flow:a,affinity:s}));let l=Math.min(o+1,r.slotCount-1);for(let r=0;r<=l;r++){if(m[r].some(r=>t.conflicts(e[i],e[r])))continue;let l=0,c=0;for(let e of m[r])l+=n[i][e],c+=d[i][e];if(g[i]=r,m[r].push(i),y(i+1,Math.max(o,r),a+l,s+c),m[r].pop(),g[i]=-1,p>=75e3)return}};return g[0]=0,m[0].push(0),y(1,0,0,0),h}function pb(e,t){let i=1/0,r=-1/0;for(let t of e?.samples??[])t.topMass+t.botMass<=1e-9||(i=Math.min(i,t.t),r=Math.max(r,t.t));return Number.isFinite(i)&&Number.isFinite(r)?(null!=t.start&&(i=Math.max(i,t.start)),null!=t.end&&(r=Math.min(r,t.end)),r>=i?{start:i,end:r}:{start:null,end:null}):{start:null,end:null}}function gb(e,t,i,r){let o=Ux(e,t,i,r),n=Qx(o);if(n)return Hx(n.slots,i,r);let a=Hy();for(let t of e)a[t.id]=pb(i[t.id],r[t.id]);let s=cb(e,a),l=new Map(e.map(e=>[e.id,e])),c=new Map(e.map(e=>[e.id,e.group||void 0])),u=ob(t),d=lb(s,a,r,t,c,u),h=ub(s,d,u),f=fb(s,d,t,{...h,assignment:db(s,d,t,h)}),p=/* @__PURE__ */new Map,g=f.map(e=>(p.has(e)||p.set(e,p.size),p.get(e))),m=Array.from({length:p.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),y=Hy();s.forEach((e,t)=>{let i=g[t],r=m[i];r.occupants.push({id:e,end:a[e].end??-1/0});let o=l.get(e)?.group;o&&(r.group=o),y[e]=i});for(let t of[...e].sort((e,t)=>Uy(e.id,t.id)))null==y[t.id]&&(m[0].occupants.push({id:t.id,end:-1/0}),y[t.id]=0);for(let e of m){e.occupants.sort((e,t)=>(a[e.id].start??1/0)-(a[t.id].start??1/0)||Uy(e.id,t.id));for(let t of e.occupants){let r=i[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,r?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,r?.botPeak||0)}}let x={slots:m,slotByNode:y};return Kx(o,x),x}function mb(e){return e.topMass+e.botMass}function yb(e){let t=/* @__PURE__ */new Map;for(let i of e.samples){if(Number.isNaN(i.t))continue;let e=t.get(i.t);e||(e=[],t.set(i.t,e)),e.push(i)}let i=0,r=-1/0;return o=>{o>=r||(i=0),r=o;let n=t.get(o);if(n){let e=n.reduce((e,t)=>mb(t)>=mb(e)?t:e,n[0]);return{exact:n,sample:e}}for(;i<e.samples.length&&!(e.samples[i].t>o);)i++;return{exact:n,sample:e.samples[i-1]??null}}}function xb(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]))}function bb(e,t,i,r,o,n,a=0){let s=/* @__PURE__ */new Map;for(let i of e){if(!i.group||!t[i.id])continue;let e=s.get(i.group)??[];e.push(i),s.set(i.group,e)}if(0===s.size||!(n>0))return t;let l=xb(t);for(let[e,c]of s){let s=i.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===s.length)continue;let u=s[0].slot,d=s.at(-1).slot,h=o[u.occupants[0]?.id],f=o[d.occupants[0]?.id];if(!Number.isFinite(h)||!Number.isFinite(f))continue;let p=(h-u.peak.topPeak*n+(f+d.peak.botPeak*n))/2,g=[...new Set(c.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),m=/* @__PURE__ */new Map;for(let e of c)m.set(e.id,/* @__PURE__ */new Map);let y=new Map(c.map(e=>[e.id,yb(t[e.id])]));for(let e of g){let t=/* @__PURE__ */new Map;for(let i of c){let{sample:o}=y.get(i.id)(e);if(!o||mb(o)<=1e-9)continue;let n=r[i.id];if(null==n)continue;let a=t.get(n)??[];a.push({node:i,sample:o}),t.set(n,a)}let i=[...t].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>mb(e)))}));if(0===i.length)continue;let s=p-(i.reduce((e,t)=>e+t.mass,0)*n+Math.max(0,a)*Math.max(0,i.length-1))/2;for(let t of i){for(let{node:i,sample:r}of t.active){let t=(s-o[i.id])/n+r.topMass-(r.boundaryOffset??0);m.get(i.id).set(e,t)}s+=t.mass*n+Math.max(0,a)}}for(let e of c){let i=t[e.id],r=l[e.id],o=m.get(e.id),n=y.get(e.id),a=[];for(let e of g){let t=o.get(e),{exact:i,sample:r}=n(e);i?a.push(...i.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}}))):null==t||!r||mb(r)<=1e-9||a.push({...r,t:e,boundaryOffset:(r.boundaryOffset??0)+t})}r.samples=a,r.localAttachments=new Map([...i.localAttachments].map(([e,t])=>{let i=o.get(t.time);return[e,{...t,...null!=i?{boundaryOffset:(t.boundaryOffset??0)+i}:{}}]}))}}return l}function vb(e,t,i,r,o){let{plotH:n,padding:a,valueScale:s,packing:l,laneOrder:c,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:h=0,ribbonLane:f="both",domain:p}=o,g=Hy(),m=Hy();for(let t of e)g[t.id]=i[t.id].topPeak||0,m[t.id]=i[t.id].botPeak||0;let y="half"===u,x=Hy();for(let t of e){let e=Array.isArray(t.xExtent)?t.xExtent[0]:null,i=Array.isArray(t.xExtent)?t.xExtent[1]:null,o=null!=e&&Number.isFinite(e)?e:1/0,n=null!=i&&Number.isFinite(i)?i:-1/0;for(let e of r.outgoing[t.id]){e.startTime<o&&(o=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.systemInTime<o&&(o=e.systemInTime);let t=y?(e.startTime+e.endTime)/2:e.endTime;t>n&&(n=t)}for(let e of r.incoming[t.id]){let t=y?(e.startTime+e.endTime)/2:e.startTime;t<o&&(o=t),e.endTime>n&&(n=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>n&&(n=e.systemOutTime)}x[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(n)?n:null}}let b=Hy(),v=[],w=[];if(o.frozenSlots){let e=Hx(o.frozenSlots,i,x);v=e.slots,b=e.slotByNode,w=v.map(Zy)}else if("reuse"===l){let r=gb(e,t,i,x);v=r.slots,b=r.slotByNode}else e.forEach((e,t)=>{v.push({occupants:[{id:e.id,end:x[e.id]?.end??-1/0}],peak:{topPeak:g[e.id],botPeak:m[e.id]},...e.group?{group:e.group}:{}}),b[e.id]=t});zx(v,b),0===w.length&&(w=v.map(Zy));let k=null;o.frozenSlots||(o.fixedSlotOrder?qx(v,b,o.fixedSlotOrder):o.runOrdering&&c&&"insertion"!==c&&(k=Vx(e,t,i,x,v,b,{plotH:n,padding:a,valueScale:s,groupPadding:h,laneOrder:c,ribbonLane:f,domain:p}))),zx(v,b);let A=rx(e,t,i,v,b,{plotH:n,padding:a,valueScale:s,stackValueScale:o.stackValueScale,lanePlacement:d,groupPadding:h}),S=0===v.length?0:v[0].peak.topPeak+A.adjacentClearance.reduce((e,t)=>e+t,0)+v[v.length-1].peak.botPeak,M=k?.before.crossings??null,$=k?.after.crossings??null,_=k?.before.weightedLength??null,L=k?.after.weightedLength??null;return{effectiveSlotsHeight:S,centerlines:A.centerlines,laneLifetime:x,slots:v,slotByNode:b,slotCenter:A.slotCenter,stackCenter:A.stackCenter,verticalUtilization:A.verticalUtilization,selectedSlotOrder:v.map(Zy),initialSlotOrder:w,ordering:k,crossingsBefore:M,crossingsAfter:$,lengthBefore:_,lengthAfter:L}}function wb(e,t,i){let{plotH:r,pairing:o="temporal",packing:n="reuse",laneOrder:a="crossing-min",lifetimeMode:s="half",maxValueScale:l,lanePlacement:c="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:h="both",domain:f}=i,p=Number.isFinite(d)?Math.max(0,d):0,g=yx(e,t),m=xx(e,t,g,o),y=Hy();for(let t of e)y[t.id]=bx(t,g,m,void 0,u);let x=vb(e,t,y,g,{plotH:r,padding:12,valueScale:1,packing:n,laneOrder:a,lifetimeMode:s,runOrdering:!0,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),b=x.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),v=/* @__PURE__ */new Set;for(let e of t){let t=x.slotByNode[e.source],i=x.slotByNode[e.target];if(void 0===t||void 0===i)continue;let r=m.get(e.id);t!==i?i<t?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(v.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(let t of e){let e=g.outgoing[t.id],i=g.incoming[t.id],r=new Set(e.map(e=>m.get(e.id).sourceSide)),o=new Set(i.map(e=>m.get(e.id).targetSide));if(1===r.size&&i.length>0){let e=[...r][0];for(let t of i)x.slotByNode[t.source]===x.slotByNode[t.target]&&(m.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){let t=[...o][0];for(let i of e)x.slotByNode[i.source]===x.slotByNode[i.target]&&(m.get(i.id).sourceSide=t)}}kx(t,m,x.slotByNode),Ax(e,g,m,v),y=Hy();for(let t of e)y[t.id]=bx(t,g,m,void 0,u);let w=vb(e,t,y,g,{plotH:r,padding:12,valueScale:1,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:b,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),k=w.effectiveSlotsHeight??w.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),A=w.slots.slice(0,-1).reduce((e,t,i)=>e+(null!=t.group&&t.group===w.slots[i+1].group?1:0),0),S=Math.max(1,w.slots.length+1-A),M=Math.min(12,Math.max(0,.35*r-A*p)/S),$=2*M+Qy(w.slots,M,p).reduce((e,t)=>e+t,0),_=k>0?Math.max(0,(r-$)/k):1,L=Number.isFinite(l)&&l>0?Math.min(_,l):_,P=vb(e,t,y,g,{plotH:r,padding:M,valueScale:L,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:b,lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:_}),I=Number.isFinite(l)&&l>0&&l+1e-12<_;if("insertion"!==a&&("hug"===c||I)&&P.slots.length>1&&(Vx(e,t,y,P.laneLifetime,P.slots,P.slotByNode,{plotH:r,padding:M,valueScale:L,groupPadding:p,laneOrder:a,ribbonLane:h,domain:f,lanePlacement:c,mode:"geometry-refine"}),P=vb(e,t,y,g,{plotH:r,padding:M,valueScale:L,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:P.slots,fixedSlotOrder:P.slots.map(Zy),lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:_})),wx(g,m)){let i=vx(t,y,P.centerlines,L);y=Hy();for(let t of e)y[t.id]=bx(t,g,m,i,u);P=vb(e,t,y,g,{plotH:r,padding:M,valueScale:L,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:P.slots,fixedSlotOrder:P.slots.map(Zy),lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:_})}let R=new Map(x.initialSlotOrder.map((e,t)=>[e,t])),T=[...P.slots].sort((e,t)=>(R.get(Zy(e))??1/0)-(R.get(Zy(t))??1/0)||Uy(Zy(e),Zy(t))),C=Hy();T.forEach((e,t)=>{for(let i of e.occupants)C[i.id]=t});let N=rx(e,t,y,T,C,{plotH:r,padding:M,valueScale:L,stackValueScale:_,lanePlacement:"stack",groupPadding:p}),F=bb(e,y,T,C,N.centerlines,L,p),z=dx(Ox(C,t),jx(C,t),t,F,T,C,N.centerlines,P.laneLifetime,L,N.verticalUtilization,h,f);y=bb(e,y,P.slots,P.slotByNode,P.centerlines,L,p);let E=dx(Ox(P.slotByNode,t),jx(P.slotByNode,t),t,y,P.slots,P.slotByNode,P.centerlines,P.laneLifetime,L,P.verticalUtilization,h,f);return{nodeData:y,sides:m,valueScale:L,padding:M,compressedPadding:M<12,centerlines:P.centerlines,laneLifetime:P.laneLifetime,slots:P.slots,slotByNode:P.slotByNode,crossingsBefore:"insertion"===a?null:z.crossings,crossingsAfter:"insertion"===a?null:E.crossings,lengthBefore:"insertion"===a?null:z.weightedLength,lengthAfter:"insertion"===a?null:E.weightedLength,layoutQualityBefore:z,layoutQuality:E}}function kb(e){return f(e)}function Ab(e){return p(e)}function Sb(e){let{sx:t,sTop:i,sBot:r,tx:o,tTop:n,tBot:a,cp1X:s,cp2X:l}=e,c=(i+r)/2,u=(n+a)/2;return{pathD:[`M${t},${i}`,`C${s},${i} ${l},${n} ${o},${n}`,`L${o},${a}`,`C${l},${a} ${s},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:s,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-i)/2}}}function Mb(e,t,i,r,o,n,a,s,l={}){let c,u,d,h,f=o,p=e=>s?Math.max(s[0],Math.min(s[1],e)):e,g=n(p(e.time)),m=n(p(i.time)),y=e.value*f,x=i.value*f,b=t+(e.boundaryOffset??0)*f,v=r+(i.boundaryOffset??0)*f,w=e.sideMassBefore*f,k=i.sideMassAfter*f;"top"===e.side?(c=b-w,u=c+y):(u=b+w,c=u-y),"top"===i.side?(d=v-k,h=d+x):(h=v+k,d=h-x);let A=l.sourceRunwayStart,S=l.minRun,M=(c+u)/2,$=(d+h)/2,_=Math.abs($-M),L=m-g,P="number"==typeof A&&Number.isFinite(A),I="number"==typeof S&&Number.isFinite(S)&&S>0;if(P&&_>1e-9&&L>0&&("auto"===S||I)){let t="source"===a?.85:"target"===a?.15:.5,i=1.5*Math.min(t*t,(1-t)*(1-t)),r="auto"===S?Math.min(144,Math.sqrt(8*_/i)):S;if(r>L){let t=n(p(Math.min(A,e.time)));if(Number.isFinite(t)){let e=Math.min(g,t);g=Math.min(g,Math.max(e,m-r))}}}let R="source"===a?g+.85*(m-g):"target"===a?g+.15*(m-g):(g+m)/2;return{sx:g,sTop:c,sBot:u,tx:m,tTop:d,tBot:h,cp1X:R,cp2X:R}}function $b(e,t,i,r,o,n){let a=new Map(t),s=/* @__PURE__ */new Map;for(let t of e){let e=n?.get(t.source),i=null==e?`node:${t.source}`:`group:${e}`,r=s.get(i)??/* @__PURE__ */new Map,o=r.get(t.startTime)??[];o.push(t),r.set(t.startTime,o),s.set(i,r)}for(let e of s.values())for(let[n,s]of e){if(!s.some(e=>i.has(e.id)))continue;let e=s.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;let l=r(n),c=Math.min(...e.map(e=>e.sx));if(!(c<l-1e-9))continue;let u=Math.max(...s.map(e=>{let t=i.get(e.id);return null==t?l:Math.min(l,r(t))})),d=Math.min(l,Math.max(c,u));for(let e of s){let i=t.get(e.id),r="source"===o?.85:"target"===o?.15:.5,n=d+(i.tx-d)*r;a.set(e.id,{...i,sx:d,cp1X:n,cp2X:n})}}return a}function _b(e,t,i){let r=new Set(t.map(e=>e.target)),o=new Map(e.map(e=>[e.id,e])),n=/* @__PURE__ */new Map;for(let e of t){if(r.has(e.source))continue;let t=n.get(e.source)??[];t.push(e),n.set(e.source,t)}let a=/* @__PURE__ */new Map;for(let t of e){if(!t.group)continue;let e=a.get(t.group)??[];e.push(t),a.set(t.group,e)}let s=/* @__PURE__ */new Set;for(let[e,t]of a){let i=t.flatMap(e=>n.get(e.id)??[]),o=new Set(i.map(e=>e.startTime));i.length>0&&1===o.size&&t.every(e=>{let t=e.xExtent?.[0],o=i[0].startTime;return!r.has(e.id)&&(n.get(e.id)?.length??0)>0&&Number.isFinite(t)&&t<o})&&s.add(e)}let l=/* @__PURE__ */new Map;for(let[e,t]of n){let r=o.get(e);if(r?.group&&!s.has(r.group))continue;let n=r?.xExtent?.[0],a=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),c=a[0]?.startTime-1,u=null;for(let e=0;e<a.length;){let t=a[e].startTime,r=e+1;for(;r<a.length&&a[r].startTime===t;)r++;for(let t=e;t<r;t++){let e=a[t],r=Number.isFinite(n)&&n<e.startTime,o=Number.isFinite(e.systemInTime)&&e.systemInTime<e.startTime;if(!r&&!o)continue;let s=i[0];r&&(s=Math.max(s,n)),o&&(s=Math.max(s,e.systemInTime)),!r&&o&&Number.isFinite(c)&&(s=Math.max(s,c)),null!=u&&(s=Math.max(s,u)),s<e.startTime&&l.set(e.id,s)}u=t,e=r}}for(let[e,t]of a){if(!s.has(e))continue;let i=t.flatMap(e=>n.get(e.id)??[]);if(!i.every(e=>l.has(e.id))){for(let e of i)l.delete(e.id);continue}let r=Math.max(...i.map(e=>l.get(e.id)));for(let e of i)l.set(e.id,r)}return l}function Lb(e,t,i,r,o){let n=/* @__PURE__ */new Map;for(let a of e){if(!i.has(a.id))continue;let e=t.get(a.id);if(!(e&&e.sx<r(a.startTime)-1e-9))continue;let s=o(e.sx);Number.isFinite(s)&&s<a.startTime&&n.set(a.id,s)}return n}function Pb(e,t,i){let r=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;for(let[e,t]of i??[]){let i=o.get(t)??[];i.push(e),o.set(t,i)}for(let n of e){let e=t.get(n.id);if(!(null!=e&&Number.isFinite(e)&&e<n.startTime))continue;let a=i?.get(n.source),s=null==a?[n.source]:o.get(a)??[n.source];for(let t of s){let i=r.get(t)??/* @__PURE__ */new Map,o=i.get(n.startTime);i.set(n.startTime,null==o?e:Math.min(o,e)),r.set(t,i)}}return r}function Ib(e,t){return t&&0!==t.size?e.map(e=>{let i=t.get(e.t);return null==i?e:{...e,t:i}}):e}function Rb(e){return Math.max(18,11*e.length*.58)}function Tb(e){let t=1.22*Rb(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 Cb(e,t){let i=e.labelX-Rb(e.labelText),r=t.labelX-Rb(t.labelText);return i<=t.labelX+3&&r<=e.labelX+3}function Nb(e,t){let i=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;e<3;e+=1){for(let e=0;e<i.length;e+=1){let t=8;for(let r=0;r<e;r+=1)Cb(i[e],i[r])&&(t=Math.max(t,i[r].labelY+16));i[e].labelY=Math.max(i[e].labelY,t)}for(let e=i.length-1;e>=0;e-=1){let r=t-8;for(let t=e+1;t<i.length;t+=1)Cb(i[e],i[t])&&(r=Math.min(r,i[t].labelY-16));i[e].labelY=Math.min(i[e].labelY,r)}}}function Fb(e,t,i){let r=e.map(e=>({...e})),o=/* @__PURE__ */new Map;for(let e of r){let i=t[e.id];if(null==i)continue;let r=o.get(i)??[];r.push(e),o.set(i,r)}let n=e=>{if(e.length<2)return;let t=e.reduce((e,t)=>e+t.labelY,0)/e.length,r=(e.length-1)/2;e.forEach((e,o)=>{e.labelY=Math.max(8,Math.min(i-8,t+16*(o-r)))})};for(let e of o.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],i=-1/0;for(let r of e){let e=r.labelX-Rb(r.labelText);t.length>0&&e>i+3&&(n(t),t=[],i=-1/0),t.push(r),i=Math.max(i,r.labelX)}n(t)}return Nb(r,i),r}function zb(e,t,i){let r=e.map(e=>({...e}));for(let e of r){let i=1.22*Rb(e.labelText)+4;e.labelX=i>=t-4?t/2:Math.max(i/2+2,Math.min(t-i/2-2,e.labelX))}let o=[],n=[...r].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(let e of n){let t=o[o.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?o.push([e]):t.push(e)}for(let e of o){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],r=/* @__PURE__ */new Map;for(let i of e){let[e,o]=Tb(i),n=t.findIndex(t=>e>t+8);-1===n&&(n=t.length),t[n]=o,r.set(i,n)}let o=e.reduce((e,t)=>e+t.labelY,0)/e.length,n=o<14*t.length+8;for(let t of e){let e=r.get(t)??0;t.labelY=n?Math.min(i-8,12+14*e):Math.max(8,o-14*e)}}return r}function Eb(e,t,i,r,o={}){if(!1===r)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===r)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let n=Math.max(1,t*i),a=Math.max(4,Math.min(e.length,Math.floor(n/14e3)));Number.isFinite(o.maxLabels)&&o.maxLabels>=0&&(a=Math.min(a,Math.floor(o.maxLabels)));let s=e.map((e,t)=>{let i=o.priorityById?.get(e.id),r=Math.abs(e.labelY);return{band:e,index:t,score:null!=i&&Number.isFinite(i)?1e6*i+Rb(e.labelText):Rb(e.labelText)+.01*r}}).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)),l=new Set(s.slice(0,a).map(e=>e.band.id));return e.map(e=>l.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}var Db=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi;function Ob(e){return e.replace(Db,(e,t,i)=>`${i},${t}`)}function jb(e){if(!e)return;let 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 Wb(e){return{...e,pathD:Ob(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function Bb(e,t){return"horizontal"===t?e:{...e,pathD:Ob(e.pathD),gradientStubs:e.gradientStubs?.map(Wb),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}function Yb(e,t){return"horizontal"===t?e:{...e,pathD:Ob(e.pathD),bezier:jb(e.bezier)}}function Gb(e){let{nodes:t,edges:i,domain:r,usageMode:o="static"}=e,n=Xy(t,i,r,{usageMode:o}),{fatal:a,warnings:s}=Gy(n),l=Vy(i,n,o);return{layout:a.length?null:wb(t,l,{plotH:"vertical"===e.orientation?e.plotW:e.plotH,...e.layoutOpts,ribbonLane:e.ribbonLane,domain:r}),issues:a,warnings:s}}function Xb(e,t=Gb(e)){let{nodes:i,edges:r,domain:o,plotW:n,plotH:a,ribbonLane:s,ribbonMinRun:l=0,edgeOpacity:c,colorOf:u,orientation:d="horizontal",showLabels:h=!0,labelPriorityAccessor:f,maxLabels:p,selectionDatum:g="raw",styleRules:m,colorBy:y,valueAccessor:x,usageMode:b="static"}=e,v="vertical"===d?a:n,w="vertical"===d?n:a,{layout:k,issues:A,warnings:S}=t,M=Vy(r,[...A,...S],b),$=Oy().domain(o).range([0,v]);if(!k)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==h},issues:A,warnings:S,xScale:$};let{centerlines:_,nodeData:L,valueScale:P}=k,I=H(y,x),R=[],T=[],C=0===l?/* @__PURE__ */new Map:_b(i,M,o),N=new Map(i.filter(e=>e.group).map(e=>[e.id,e.group])),F=/* @__PURE__ */new Map;for(let e of M){let t=L[e.source]?.localAttachments.get(e.id),i=L[e.target]?.localAttachments.get(e.id);!t||!i||F.set(e.id,Mb(t,_[e.source],i,_[e.target],P,$,s,o,{minRun:l,sourceRunwayStart:C.get(e.id)}))}let z=$b(M,F,C,$,s,N),E=Lb(M,z,C,$,e=>o[0]+e/v*(o[1]-o[0])),D=Pb(M,E,N);i.forEach((e,t)=>{let i=L[e.id];if(!i||0===i.samples.length)return;let r=Ib(i.samples,D.get(e.id)),n=gx(r,_[e.id],P,$,o);if(!n)return;let a,s,l=fx(r,o),c=l.find(e=>e.topMass+e.botMass>0)||l[0],h=(c.botMass-c.topMass+2*(c.boundaryOffset??0))*P/2,f=_[e.id]+h,p=u(e.id,t),g=p,y=.5,x=e.__raw??e;if(m&&m.length>0){let e=U(x,m,I(x));"string"==typeof e.fill?p=e.fill:null!=e.fill&&Ns(e.fill)&&(s=e.fill,p=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:p),"string"==typeof e.stroke&&(g=e.stroke),"number"==typeof e.strokeWidth&&(y=e.strokeWidth),"number"==typeof e.fillOpacity&&(a=e.fillOpacity),"number"==typeof e.opacity&&null==a&&(a=e.opacity)}let b=mx(e.id,M,k,$,o,E);R.push({id:e.id,pathD:n,fill:p,stroke:g,strokeWidth:y,...null!=a&&{fillOpacity:a},...s&&{hatchFill:s},...b.length>0&&{gradientStubs:b},rawDatum:x,labelX:$("vertical"===d&&e.xExtent?e.xExtent[0]:c.t)-4,labelY:f,labelText:e.label??e.id})});let O=/* @__PURE__ */new Map;i.forEach((e,t)=>O.set(e.id,t)),M.forEach(e=>{let t=z.get(e.id);if(!t)return;let i=O.get(e.source)??0,r=u(e.source,i),{pathD:o,bezier:n}=Sb(t),a=e.__raw??e,s="function"==typeof c?Number(c(a)):c,l=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.35;T.push({id:e.id,pathD:o,fill:r,opacity:l,rawDatum:a,bezier:n})});let j=Fb(R,k.slotByNode,w).map(e=>Bb(e,d)),W="vertical"===d?zb(j,n,a):j,B=/* @__PURE__ */new Map;if(null!=f)for(let e of i){let t=e.__raw??e,i="function"==typeof f?f(t):Number(t[f]);Number.isFinite(i)&&B.set(e.id,i)}let Y=Eb(W,n,a,h,{...B.size>0&&{priorityById:B},...null!=p&&{maxLabels:p}});return{layout:k,layoutConfig:{bands:Y,ribbons:T.map(e=>Yb(e,d)),showLabels:!1!==h,selectionDatum:g},issues:[],warnings:S,xScale:$}}function Vb(e,t,i,r="horizontal"){return"vertical"===r?{top:e?38:t?28:16,right:24,bottom:24,left:i?72:24}:{top:e?30:t?24:8,right:80,bottom:i?28:8,left:80}}import{scaleLinear as qb,scaleUtc as Hb}from"d3-scale";import{Fragment as Ub,jsx as Zb,jsxs as Qb}from"react/jsx-runtime";var Kb="var(--semiotic-grid, #94a3b8)",Jb="var(--semiotic-text-secondary, #475569)",ev="var(--semiotic-text-secondary, #94a3b8)";function tv(e){let t=e.layout,i=e.nodes,r=e.orientation,o=e.plotW,n=e.plotH,a=e.timelineExtent,s=e.showQualityReadout??!1,l=e.showLaneRails??!1,c=(e.warnings??[]).slice(0,3),u=e.timeFormat,d=e.colorOf,h=e.toTime,f=e.xScale,p=Ab(e.domain),{centerlines:g,laneLifetime:m,nodeData:y,valueScale:x,compressedPadding:b,crossingsBefore:v,crossingsAfter:w,layoutQualityBefore:k,layoutQuality:A}=t,S=null,M=null,$=1/0,_=-1/0;for(let e of i){let t=m[e.id];if(!t||null===t.start||null===t.end)continue;let i=f(t.start),r=f(t.end);$=Math.min($,t.start),_=Math.max(_,t.end),(null===S||i<S)&&(S=i),(null===M||r>M)&&(M=r)}let L=e=>Math.max(0,Math.min(a,e)),P=L(S??0),I=Math.max(P,L(M??a)),R=[Math.max(h(e.domain[0]),$),Math.min(h(e.domain[1]),_)],T=Math.max(2,Math.min(8,Math.floor(a/90))),C=Hb().domain(R),N=e.axisTicks??(Number.isFinite(R[0])&&Number.isFinite(R[1])?(p?C.ticks(T):qb().domain(R).ticks(T)).map(e=>({date:e})):[]),F=e=>{if(null!=e.label)return e.label;let t=h(e.date),i=p?new Date(t):t;return u?u(i):p?C.tickFormat()(i):String(t)},z=N.map((e,t)=>({tick:e,index:t,coordinate:f(h(e.date))})).filter(({coordinate:e})=>e>=P-.5&&e<=I+.5),E=null!==(w??null)&&null!=k&&null!=A,D=s&&(E||c.length>0)?/* @__PURE__ */Qb("g",{fill:ev,fontSize:10,textAnchor:"end",children:[E&&/* @__PURE__ */Qb(Ub,{children:[
261
- /* @__PURE__ */Qb("text",{x:o,y:-14,children:["crossings: ",v," → ",w," ","pixel length: ",Math.round(k.pixelLength)," → ",Math.round(A.pixelLength)]}),
262
- /* @__PURE__ */Qb("text",{x:o,y:-3,children:["transit: ",k.transitOcclusion.toFixed(1)," → ",A.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*A.verticalUtilization),"%"]})]}),c.map((e,t)=>/* @__PURE__ */Qb("text",{x:o,y:E?10+11*t:11*t-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",e]},`warn-${t}`))]}):null,O=b?/* @__PURE__ */Zb("text",{x:o,y:"vertical"===r?-3:2,fontSize:10,fill:ev,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,j=(e,t)=>d?d(e,t):Kb;/* @__PURE__ */
263
- return Qb("g","vertical"===r?{children:[D,O,z.map(({index:e,coordinate:t})=>/* @__PURE__ */Zb("line",{x1:0,y1:t,x2:o,y2:t,stroke:Kb,strokeOpacity:.15,strokeDasharray:"2 4"},`grid-${e}`)),l&&i.map((e,t)=>{let i=m[e.id];if(!i||null===i.start)return null;let r=g[e.id],o=y[e.id],n=o?{topPeak:o.topPeak,botPeak:o.botPeak}:{topPeak:0,botPeak:0},a=r+(n.botPeak-n.topPeak)*x/2,s=f(i.start),l=f(i.end),c=j(e.id,t);/* @__PURE__ */
264
- return Qb("g",{children:[
265
- /* @__PURE__ */Zb("line",{x1:a,y1:s,x2:a,y2:l,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),
266
- /* @__PURE__ */Zb("line",{x1:a-4,y1:s,x2:a+4,y2:s,stroke:c,strokeOpacity:.5}),
267
- /* @__PURE__ */Zb("line",{x1:a-4,y1:l,x2:a+4,y2:l,stroke:c,strokeOpacity:.5})]},`lane-${e.id}`)}),
268
- /* @__PURE__ */Zb("line",{x1:-4,y1:P,x2:-4,y2:I,stroke:Kb}),z.map(({tick:e,index:t,coordinate:i})=>{let r=F(e);/* @__PURE__ */
269
- return Qb("g",{transform:`translate(-4,${i})`,children:[
270
- /* @__PURE__ */Zb("line",{x2:-6,stroke:Kb}),
271
- /* @__PURE__ */Zb("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:Jb,children:r})]},t)})]}:{children:[D,O,z.map(({index:e,coordinate:t})=>/* @__PURE__ */Zb("line",{x1:t,y1:0,x2:t,y2:n,stroke:Kb,strokeOpacity:.15,strokeDasharray:"2 4"},`grid-${e}`)),l&&i.map((e,t)=>{let i=m[e.id];if(!i||null===i.start)return null;let r=g[e.id],o=y[e.id],n=o?{topPeak:o.topPeak,botPeak:o.botPeak}:{topPeak:0,botPeak:0},a=r+(n.botPeak-n.topPeak)*x/2,s=f(i.start),l=f(i.end),c=j(e.id,t);/* @__PURE__ */
272
- return Qb("g",{children:[
273
- /* @__PURE__ */Zb("line",{x1:s,y1:a,x2:l,y2:a,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),
274
- /* @__PURE__ */Zb("line",{x1:s,y1:a-4,x2:s,y2:a+4,stroke:c,strokeOpacity:.5}),
275
- /* @__PURE__ */Zb("line",{x1:l,y1:a-4,x2:l,y2:a+4,stroke:c,strokeOpacity:.5})]},`lane-${e.id}`)}),
276
- /* @__PURE__ */Zb("line",{x1:P,y1:n+4,x2:I,y2:n+4,stroke:Kb}),z.map(({tick:e,index:t,coordinate:i})=>{let r=F(e);/* @__PURE__ */
277
- return Qb("g",{transform:`translate(${i},${n+4})`,children:[
278
- /* @__PURE__ */Zb("line",{y2:6,stroke:Kb}),
279
- /* @__PURE__ */Zb("text",{y:20,textAnchor:"middle",fontSize:11,fill:Jb,children:r})]},t)})]})}function iv(e,t){return"scene"===t?e:e.data}function rv(e,t,i){return!t?.isActive||t.predicate(iv(e,i))}var ov=e=>{let{bands:t=[],ribbons:i=[],showLabels:r=!0,selectionDatum:o="raw"}=e.config,n=e.selection??null,a=[];for(let e of i){let t={__kind:"ribbon",data:e.rawDatum,id:e.id},i=!rv(t,n,o);a.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:i?Math.min(e.opacity,.22):e.opacity,stroke:"none"},datum:t})}for(let e of t){if(!e.gradientStubs)continue;let t=!rv({__kind:"band",data:e.rawDatum,id:e.id},n,o);for(let i=0;i<e.gradientStubs.length;i++){let r=e.gradientStubs[i];a.push({type:"bezier",pathD:r.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?.22:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:r.x0,x1:r.x1,...null!=r.y0&&{y0:r.y0},...null!=r.y1&&{y1:r.y1},from:r.from,to:r.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${i}`}})}}for(let e of t){let t=!!(e.gradientStubs&&e.gradientStubs.length>0),i={__kind:"band",data:e.rawDatum,id:e.id},r=!rv(i,n,o),s=e.fillOpacity??.86,l=e.hatchFill??e.fill;a.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:l,fillOpacity:r?.22:s},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...r&&t?{opacity:.22}:{}},datum:i})}let s=r?t.flatMap(e=>{let t=e.labelDeferred&&e.labelFullText?.trim(),i=e.labelText.trim().length>0,r=t&&n?.isActive&&rv({__kind:"band",data:e.rawDatum,id:e.id},n,o),a=i?e.labelText:r?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:s}};function nv(e,t){if(!e)return[];let i=[],r=e=>{i.push(e);let o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(r)};return r(e),i}function av(e,t,i,r){if(e&&e.length>0)return e;let o=/* @__PURE__ */new Set;return t.forEach(e=>{let t="function"==typeof i?i(e):e[i],n="function"==typeof r?r(e):e[r];o.add(t),o.add(n)}),Array.from(o).map(e=>({id:e}))}function sv({edgeColorBy:e,colorBy:t,colorScale:i,nodeStyleFn:r,edgeOpacity:o,baseStyle:n={}}){return a=>{let s={fillOpacity:o,...n};if("function"==typeof e)s.fill=e(a);else if("source"===e){let e="object"==typeof a.source?a.source:null;t&&e?s.fill=Di(e.data||e,t,i):e&&(s.fill=r(e,e.index).fill)}else if("target"===e){let e="object"==typeof a.target?a.target:null;t&&e?s.fill=Di(e.data||e,t,i):e&&(s.fill=r(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}var lv=(e,t,i,r,o)=>({data:e,nodeIDAccessor:o.nodeIdAccessor??o.nodeIDAccessor??"name",childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth)}),cv=(e,t,i,r,o)=>{let n=hr(r.theme).colors.categorical,a=/* @__PURE__ */new Map,s=nv(e??null,o.childrenAccessor??"children"),l="function"==typeof t?t:null,c=l?"__hierarchyColor":"string"==typeof t?t:void 0,u=l?s.map(e=>({__hierarchyColor:l(e)})):s,d=t&&c?ji(u,c,i??r.colorScheme??n):void 0;return e=>{if(o.colorByDepth)return Fi[Number(e?.depth||0)%Fi.length];let r=e?.data||e;return t?Di(l?{__hierarchyColor:l(r)}:r,c,d??void 0):Yi(void 0,n,i,void 0,a)}};function uv(e,t,i,r){let o=Z(e,r.styleRules,H(t,r.valueAccessor),e=>e?.data||e),n=i.nodeStyle||r.nodeStyle;return Xi(n?"function"==typeof n?e=>({...o(e),...n(e)??{}}):e=>({...o(e),...n}):o,cr(r))}function dv(e){if(void 0!==e.edgeStyle)return e.edgeStyle;let{edgeWidth:t,edgeColor:i,edgeOpacity:r}=e,o=e.strokeWidth??1;return void 0!==t||void 0!==i||void 0!==r||void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity?n=>{let a=n?.data||n,s=o;if("number"==typeof t)s=t;else if("function"==typeof t)s=t(a);else if("string"==typeof t){let e=a?.[t],i="number"==typeof e?e:Number(e);s=Number.isFinite(i)&&i>0?i:o}return{stroke:i??e.stroke??"#999",strokeWidth:s,opacity:r??e.opacity??.6}}:void 0}var hv={MotifBraidChart:zy,DependencyForestChart:Ey,ForceDirectedGraph:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=dv(o),a=hr(r.theme).colors.categorical,s=/* @__PURE__ */new Map,l=Array.isArray(o.nodes)?o.nodes:[],c="string"==typeof t?t:"__ssrForceColorBy",u=t?ji("function"==typeof t?l.map(e=>({...e,__ssrForceColorBy:t(e)})):l,c,i??r.colorScheme??a):void 0,d=o.nodeStyle??(e=>({fill:t?Di(e?.data||e,t,u):Yi(void 0,a,i,void 0,s),..."number"==typeof o.nodeSize&&{r:o.nodeSize}})),h=Q(o.styleRules,t,"number"==typeof o.nodeSize?void 0:o.nodeSize),f=Xi(h?(e,t)=>({...d(e),...h(e,t)}):d,{stroke:o.nodeStroke??o.stroke,strokeWidth:o.nodeStrokeWidth??o.strokeWidth,opacity:o.opacity});return{chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:t,colorScheme:i,iterations:o.iterations,forceStrength:o.forceStrength,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize??8,nodeSizeRange:o.nodeSizeRange,nodeStyle:f,edgeStyle:n,...r,showLabels:r.showLabels??o.showLabels??!1,showLegend:(r.showLegend??!!t)&&!!t}}},SankeyDiagram:{frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,i,r,o)=>{let n=Array.isArray(o.nodes)?o.nodes:av([],Array.isArray(o.edges)?o.edges:[],o.sourceAccessor||"source",o.targetAccessor||"target"),a=hr(r.theme).colors.categorical,s=/* @__PURE__ */new Map,l="string"==typeof t?t:"__ssrSankeyColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrSankeyColorBy:t(e)})):n,u=t?ji(c,l,i??r.colorScheme??a):void 0,d=e=>({fill:t?Di(e?.data||e,t,u):Yi(void 0,a,i,void 0,s),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),h=Q(o.styleRules,t,o.valueAccessor),f=h?(e,t)=>({...d(e),...h(e,t)}):d,p=sv({edgeColorBy:o.edgeColorBy??"source",colorBy:t,colorScale:u,nodeStyleFn:f,edgeOpacity:o.edgeOpacity??.5,baseStyle:{stroke:"none",strokeWidth:0}});return{chartType:"sankey",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,valueAccessor:o.valueAccessor,orientation:o.orientation,nodeAlign:o.nodeAlign,nodeWidth:o.nodeWidth,nodePaddingRatio:o.nodePaddingRatio,showLabels:o.showLabels,nodeLabel:o.nodeLabel,colorBy:t,edgeColorBy:o.edgeColorBy,edgeOpacity:o.edgeOpacity,nodeStyle:Xi(o.nodeStyle||f,cr(o)),edgeStyle:Xi(o.edgeStyle||p,cr(o)),colorScheme:i,...r,showLegend:(r.showLegend??!!t)&&!!t}}},ProcessSankey:{frameType:"network",layout:{margin:e=>Vb(!!e.title,!!e.showQualityReadout,!Array.isArray(e.axisTicks)||e.axisTicks.length>0,"vertical"===e.orientation?"vertical":"horizontal")},buildProps:(e,t,i,r,o)=>{let n=o.sourceAccessor||"source",a=o.targetAccessor||"target",s=o.valueAccessor||"value",l=o.nodeIdAccessor||"id",c=o.startTimeAccessor||"startTime",u=o.endTimeAccessor||"endTime",d=o.systemInTimeAccessor,h=o.systemOutTimeAccessor,f=o.xExtentAccessor||"xExtent",p=o.groupBy,g=o.edgeIdAccessor||"id",m=(e,t)=>"function"==typeof e?e(t):t[e],y=Array.isArray(o.edges)?o.edges:[],x=Array.isArray(o.nodes)?o.nodes:[],b=x.length>0?x:av([],y,n,a),v=[kb(o.domain?.[0]),kb(o.domain?.[1])],w=b.map(e=>{let t=String(m(l,e)),i=m(f,e),r=o.nodeLabel?m(o.nodeLabel,e):t,n={id:t,label:null==r?t:String(r),__raw:e},a=p?m(p,e):null;if(null!=a&&""!==String(a)&&(n.group=String(a)),Array.isArray(i)&&2===i.length){let e=kb(i[0]),t=kb(i[1]);Number.isFinite(e)&&Number.isFinite(t)&&(n.xExtent=[e,t])}return n}),k=y.map((e,t)=>{let i=m(g,e),r={id:null!=i?String(i):`${m(n,e)}-${m(a,e)}-${t}`,source:String(m(n,e)),target:String(m(a,e)),value:Number(m(s,e)),startTime:kb(m(c,e)),endTime:kb(m(u,e)),__raw:e};if(d){let t=kb(m(d,e));Number.isFinite(t)&&(r.systemInTime=t)}if(h){let t=kb(m(h,e));Number.isFinite(t)&&(r.systemOutTime=t)}return r}),[A,S]=r.size??[600,400],M=r.margin,$="vertical"===o.orientation?"vertical":"horizontal",_=!Array.isArray(o.axisTicks)||o.axisTicks.length>0,L={...Vb(!!r.title,!!o.showQualityReadout,_,$),...M},P=(r.showLegend??!!t)&&!!t,I=r.legendPosition??"right";if(P){let e="left"===I||"top"===I||"bottom"===I?I:"right",t={...L};"right"===e?L.right=Math.max(L.right,140):"left"===e?L.left=Math.max(L.left,140):"top"===e?L.top=Math.max(L.top,50):L.bottom=Math.max(L.bottom,80),rt(L,t,[A,S],e)}let R=L,T=Math.max(1,A-R.left-R.right),C=Math.max(1,S-R.top-R.bottom),N=Ci(i,hr(r.theme).colors.categorical,fi),F="function"==typeof t?t:null,z=F?b.map(e=>({_cat:F(e)})):b,E=F?"_cat":"string"==typeof t?t:void 0,D=i??[...N],O=E?ji(z,E,D):null,j=/* @__PURE__ */new Map;for(let e of w)j.set(e.id,e.__raw);let W=(e,i)=>{if(t&&j.has(e)){let i=j.get(e);return F?Di({_cat:F(i)},"_cat",O??void 0):Di(i,"string"==typeof t?t:"id",O??void 0)}return N[i%N.length]},B=Qe(P&&t?(()=>{let e=/* @__PURE__ */new Map;b.forEach((i,r)=>{let o=m(t,i),n=null==o?"":String(o);!n||e.has(n)||e.set(n,{label:n,color:W(String(m(l,i)),r)})});let i=Array.from(e.values());return i.length>0?{legendGroups:[{type:"fill",label:"",items:i,styleFn:e=>{let t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0})():void 0,r.legend),Y=!1!==o.showLabels&&("auto"!==o.showLabels||"auto"),{layout:G,layoutConfig:X,issues:V,xScale:q}=Xb({nodes:w,edges:k,domain:v,plotW:T,plotH:C,orientation:$,ribbonLane:o.ribbonLane||"both",ribbonMinRun:"auto"===o.ribbonMinRun||"number"==typeof o.ribbonMinRun?o.ribbonMinRun:0,edgeOpacity:"number"==typeof o.edgeOpacity?o.edgeOpacity:.35,colorOf:W,showLabels:Y,styleRules:o.styleRules,colorBy:t,valueAccessor:s,layoutOpts:{pairing:o.pairing||"temporal",packing:o.packing||"reuse",laneOrder:o.laneOrder||"crossing-min",lifetimeMode:o.lifetimeMode||"half",maxValueScale:"number"==typeof o.maxValueScale?o.maxValueScale:void 0,lanePlacement:o.lanePlacement||"stack",nodeSizing:o.nodeSizing||"temporal",groupPadding:"number"==typeof o.groupPadding?o.groupPadding:0}});if(V.length>0){let e=V.map(qy).join("; ");throw new Error(`ProcessSankey: data invalid — ${e}`)}let H=G?tv({layout:G,nodes:w,orientation:$,plotW:T,plotH:C,timelineExtent:"vertical"===$?C:T,domain:o.domain,axisTicks:Array.isArray(o.axisTicks)?o.axisTicks.map(e=>({date:e.date,label:e.label})):void 0,showQualityReadout:!!o.showQualityReadout,showLaneRails:!!o.showLaneRails,timeFormat:"function"==typeof o.timeFormat?e=>o.timeFormat(e):void 0,colorOf:W,toTime:e=>kb(e),xScale:e=>Number(q(e))}):void 0;return{chartType:"force",nodes:b,edges:y,customNetworkLayout:ov,layoutConfig:X,sourceAccessor:n,targetAccessor:a,valueAccessor:s,nodeIDAccessor:l,colorBy:t,colorScheme:i,...H&&{backgroundGraphics:H},...r,showLegend:P,...B&&{legend:B,legendPosition:I},__legendIncludesAutomatic:!0,margin:R}}},ChordDiagram:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=Array.isArray(o.styleRules)&&o.styleRules.length>0;if(!(t||n||r.nodeStyle||o.nodeStyle||Gi(cr(o))))return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,edgeOpacity:o.edgeOpacity,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:i,...r,showLegend:(r.showLegend??!!t)&&!!t};let a=Array.isArray(o.edges)?o.edges:[],s=Array.isArray(o.nodes)&&o.nodes.length>0?o.nodes:av([],a,o.sourceAccessor||"source",o.targetAccessor||"target"),l=hr(r.theme).colors.categorical,c=Ci(i,l),u="string"==typeof t?t:"__ssrChordColorBy",d="function"==typeof t?s.map(e=>({...e,__ssrChordColorBy:t(e)})):s,h=t?ji(d,u,i??r.colorScheme??l):void 0,f=/* @__PURE__ */new Map,p=o.nodeIdAccessor||o.nodeIDAccessor||"id",g=(e,i)=>{let r,n=e?.data||e;if(t)r=Di(n,t,h);else{let t=String(e.id??n?.[p]??"");f.has(t)||f.set(t,f.size);let o=e.index??i??f.get(t);r=c[o%c.length]}return{fill:r,stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},m=Q(o.styleRules,t,o.valueAccessor),y=m?(e,t)=>({...g(e,t),...m(e,t)}):g;return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,edgeOpacity:o.edgeOpacity,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:i,nodeStyle:Xi(o.nodeStyle||y,cr(o)),...r,showLegend:(r.showLegend??!!t)&&!!t}}},TreeDiagram:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=cv(e,t,i,r,o),a=!1!==o.showLabels;return{chartType:o.layout??"tree",orientation:o.orientation,nodeLabel:a?o.nodeLabel||o.nodeIdAccessor:void 0,...lv(e,t,i,r,o),nodeStyle:uv(e=>({fill:n(e),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),t,r,o)}}},Treemap:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=cv(e,t,i,r,o),a=o.showLabels??r.showLabels,s=o.labelMode,l=void 0!==o.paddingTop?o.paddingTop:r.paddingTop,c=void 0!==l?l:!a||"parent"!==s&&"all"!==s?void 0:18;return{chartType:"treemap",labelMode:s,nodeLabel:a?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},...null!=c&&{paddingTop:c},...lv(e,t,i,r,o),nodeStyle:uv(e=>({fill:n(e),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}),t,r,o)}}},CirclePack:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=cv(e,t,i,r,o);return{chartType:"circlepack",nodeLabel:o.showLabels??r.showLabels?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},...lv(e,t,i,r,o),nodeStyle:uv(e=>({fill:n(e),fillOpacity:o.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}),t,r,o)}}},OrbitDiagram:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=e??o.data,a=o.childrenAccessor||"children",s=o.nodeIdAccessor||o.nodeIDAccessor||"name",l=hr(r.theme).colors.categorical,c=i??r.colorScheme??l,u=Ci(c,l),d=nv(n,a),h="__ssrOrbitColorBy",f="function"==typeof t?t:null,p=t?ji(f?d.map(e=>({[h]:f(e)})):d,f?h:t,c):void 0,g=Z(e=>{let i=e.data||e,r=Number(e.depth??0);return{fill:o.colorByDepth?0===r?u[0]:Fi[r%Fi.length]:t?f?Di({[h]:f(i)},h,p):Di(i,t,p):u[0],stroke:"#fff",strokeWidth:1,opacity:0===r?1:.85}},o.styleRules,H(t,"value"),e=>e?.data||e);return{chartType:"orbit",data:n,childrenAccessor:a,nodeIDAccessor:s,colorBy:t,colorScheme:c,colorByDepth:o.colorByDepth??!1,nodeSize:o.nodeRadius??6,nodeLabel:o.showLabels?s:void 0,showLabels:o.showLabels??!1,orbitMode:o.orbitMode??"flat",orbitSize:o.orbitSize??2.95,orbitSpeed:o.speed??.25,orbitRevolution:o.revolution,orbitRevolutionStyle:o.revolutionStyle,orbitEccentricity:o.eccentricity??1,orbitShowRings:o.showRings??!0,orbitAnimated:!1,nodeStyle:Xi(g,cr(o)),edgeStyle:()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth)}}}},fv={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5};function pv(e,t,i){let[r,o]=i;if(!t)return r;let[n,a]=t,s=a>n?a-n:0,l=Number(e),c=Number.isFinite(l)?l:n,u=s>0?(c-n)/s:0;return r+Math.max(0,Math.min(1,u))*(o-r)}function gv(e){let{valueAccessor:t,valueDomain:i,edgeWidthRange:r,resolveStroke:o,edgeOpacity:n,edgeLinecap:a,styleRules:s}=e,l=V(t);return Z(e=>({stroke:o(e),strokeWidth:pv(e[t],i,r),strokeLinecap:a,opacity:n,fillOpacity:0}),s,e=>({value:l(e)}))}import{scaleSequential as mv}from"d3-scale";function yv(e,t,i,r){let o,n,a=Array.isArray(e)?e:[];if(t){let e="string"==typeof t?t:"__geoColorBy",r="string"==typeof t?a:a.map(e=>({...e,__geoColorBy:t(e)}));o=ji(r,e,i)}if(r.sizeBy){let e="function"==typeof r.sizeBy?r.sizeBy:e=>e?.[r.sizeBy],t=a.map(e).filter(e=>null!=e&&isFinite(e));t.length>0&&(n=Ne(t))}return e=>({fill:t&&o?Di(e,t,o):Ti,fillOpacity:r.fillOpacity,stroke:"#fff",strokeWidth:r.strokeWidth,r:r.sizeBy?Bi(e,r.sizeBy,r.sizeRange,n):r.pointRadius??6})}function xv(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function bv(e,t,i){if(!Array.isArray(e))return;let r=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0,o=1/0,n=-1/0;for(let t of e){let e=r(t);null==e||!isFinite(e)||(e<o&&(o=e),e>n&&(n=e))}let a=[Number.isFinite(o)?o:0,Number.isFinite(n)?n:1],s=mv(ki(i)).domain(a);return{domain:a,colorScale:e=>s(e),valueAccessor:r}}function vv(e,t){if(e)return i=>{let r=e.valueAccessor(i);return{fill:null!=r&&isFinite(r)?e.colorScale(r):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:t}}}var wv={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n="string"==typeof i?i:"blues",a=bv(o.areas,o.valueAccessor,n),s=o.areaStyle??vv(a,o.areaOpacity??1),l=e=>"function"==typeof o.valueAccessor?o.valueAccessor(e):null!=o.valueAccessor?e?.properties?.[o.valueAccessor]??e?.[o.valueAccessor]:void 0,c=o.styleRules?Z(s,o.styleRules,e=>({value:l(e)}),xv):s,u=!1!==r.showLegend&&a?{gradient:{colorFn:a.colorScale,domain:a.domain,label:"string"==typeof o.valueAccessor?o.valueAccessor:"value"}}:void 0;return{areas:o.areas,projection:o.projection||"equalEarth",areaStyle:c,valueAccessor:o.valueAccessor,colorScheme:n,graticule:o.graticule,fitPadding:o.fitPadding,...r,...void 0===r.legend&&u?{legend:u}:{}}}},kv={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n=e||o.points,a=o.pointStyle??yv(n,t,i,{sizeBy:o.sizeBy,sizeRange:o.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),s=o.styleRules?Z(a,o.styleRules,H(t,o.sizeBy)):a;return{points:n,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle||fv,pointStyle:s,sizeBy:o.sizeBy,colorBy:t,colorScheme:i,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,...r}}},Av={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n=e||o.points,a=r.__resolvedMode??o.mode,s="sparkline"===a,l=o.pointStyle??yv(n,t,i,{pointRadius:"number"==typeof o.pointRadius?o.pointRadius:s?1.5:5,fillOpacity:.85,strokeWidth:1}),c=o.nodeIdAccessor||"id",u=o.cartogramLayout||(s?"strip":"radial"),d="strip"===u,h=o.styleRules?Z(l,o.styleRules,H(t)):l;return{points:n,lines:o.lines,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",pointStyle:e=>{let t="function"==typeof h?h(e):h,i="function"==typeof c?c(e):e[c],r=null!=i&&String(i)===String(o.center),n="number"==typeof t.r?t.r:5;return{...t,fillOpacity:r?1:t.fillOpacity??.8,stroke:r?"var(--semiotic-text, #222)":t.stroke??"#fff",strokeWidth:r?1.25:t.strokeWidth??1,r:r?1.35*n:n}},colorBy:t,colorScheme:i,projection:o.projection||"mercator",graticule:o.graticule,fitPadding:o.fitPadding,projectionTransform:{center:o.center,centerAccessor:c,costAccessor:o.costAccessor,strength:o.strength??1,lineMode:o.lineMode||"straight",layout:u},...r,cartogramChrome:{showRings:o.showRings??!0,showNorth:o.showNorth??(!d&&!s),showRingLabels:o.showRingLabels??(!d&&"context"!==a&&!s),costLabel:o.costLabel}}}},Sv={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n=(Array.isArray(e)?e:null)||o.flows||[],a=o.nodes||[],s=o.nodeIdAccessor||"id",l=o.valueAccessor||"value",c=o.xAccessor||"lon",u=o.yAccessor||"lat",d="function"==typeof c?c:e=>e[c],h="function"==typeof u?u:e=>e[u],f=a.map(e=>({...e,x:d(e),y:h(e)})),p=/* @__PURE__ */new Map;for(let e of f)p.set(String(e[s]),e);let g=o.edgeColorBy??t,m="function"==typeof g,y=n.map(e=>{if(!e||null==e.source||null==e.target)return null;let t=p.get(String(e.source)),i=p.get(String(e.target));return t&&i?{...e,coordinates:[{x:t.x,y:t.y},{x:i.x,y:i.y}]}:null}).filter(Boolean),x="__flowMapEdgeColor",b=g?m?ji(y.map(e=>({[x]:g(e)})),x,i||"category10"):ji(y,g,i||"category10"):null,v=y.map(e=>Number(e[l]??0)).filter(e=>Number.isFinite(e)),w=v.length>0?Ne(v):void 0,[k,A]=o.edgeWidthRange??[1,8],S=o.edgeOpacity??.6,M=o.edgeLinecap??"round";return{lines:y,points:f,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:o.lineType||"geo",flowStyle:o.flowStyle||"basic",areas:o.areas,areaStyle:o.areaStyle||fv,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:i,lineStyle:gv({valueAccessor:l,valueDomain:w,edgeWidthRange:[k,A],resolveStroke:e=>g&&b?Di(e,g,b):"#007bff",edgeOpacity:S,edgeLinecap:M,styleRules:o.styleRules}),pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...r}}},Mv={FlowCircuitChart:Dy,GaltonBoardChart:ry,EventDropChart:oy,UnitPileChart:ny,CollisionSwarmChart:ay,PacketFlowChart:uy,ProcessFlowChart:sy,GauntletChart:ly,CrucibleChart:cy,ChainReactionChart:Lh},$v=/* @__PURE__ */Object.assign({Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(e,t,i,r,o)=>({chartType:"line",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||t,colorAccessor:t,...r,showAxes:!1,margin:r.margin,showLegend:!1,showGrid:!1,title:void 0})},XYCustomChart:Gf,OrdinalCustomChart:Xf,ParallelCoordinatesRecipe:qf,CalendarHeatmapRecipe:Hf,NetworkCustomChart:Vf,ChoroplethMap:wv,ProportionalSymbolMap:kv,FlowMap:Sv,DistanceCartogram:Av,GeoCustomChart:{frameType:"geo",buildProps:(e,t,i,r,o)=>({points:o.points||e||[],areas:o.areas||[],lines:o.lines||[],projection:o.projection||"equirectangular",xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",lineDataAccessor:o.lineDataAccessor,colorBy:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r})},PhysicsCustomChart:dy},
280
- /* @__PURE__ */Object.assign({},Ph,cf,Yf),
281
- /* @__PURE__ */Object.assign({},hv,Mv));import*as _v from"react";import{jsx as Lv}from"react/jsx-runtime";var Pv=/* @__PURE__ */new Set(["svg","g","text","tspan","path","circle","ellipse","rect","line","polyline","polygon","use","image","defs","symbol"]);function Iv(e){if(Array.isArray(e))return e.length>0&&e.every(Iv);if(!_v.isValidElement(e))return!1;if(e.type===_v.Fragment){let t=_v.Children.toArray(e.props.children);return t.length>0&&t.every(Iv)}return"string"==typeof e.type&&Pv.has(e.type)}function Rv(e,t,i){if(!Iv(e))return null;if(!_v.isValidElement(e)||e.type===_v.Fragment)/* @__PURE__ */
282
- return Lv("g",{className:"semiotic-radial-center-content",transform:`translate(${t},${i})`,pointerEvents:"none",children:e});let r=e,o="text"===r.type?_v.cloneElement(r,{x:r.props.x??0,y:r.props.y??0,textAnchor:r.props.textAnchor??"middle",dominantBaseline:r.props.dominantBaseline??"middle"}):r;/* @__PURE__ */
283
- return Lv("g",{className:"semiotic-radial-center-content",transform:`translate(${t},${i})`,pointerEvents:"none",children:o})}import*as Tv from"react-dom/server";import{scaleBand as Cv,scaleLinear as Nv}from"d3-scale";function Fv(e,t,i,r,o,n){let a=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4,l=!1;for(let c of t){if("connector"===c.type||"violin"===c.type||"boxplot"===c.type)continue;if("wedge"===c.type){let t=c.category;if(!t)continue;let r=0;for(let a of o(t)??[]){let t=i.get(a);null!=t&&(r=Math.max(r,Ln(e,t,n)))}l=In(c,r,a)||l;continue}if(null==c.datum)continue;let t=r.get(c.datum);if(null==t)continue;let u=i.get(t);l=In(c,null==u?0:Ln(e,u,n),a,s)||l}return l}var zv=class{constructor(){this.colorSchemeMap=/* @__PURE__ */new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,i){if(t&&"function"==typeof e.pieceStyle){let r=e.pieceStyle(t,i);return r&&!r.fill&&i?{...r,fill:this.getColorFromScheme(e,i)}:r}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&i?{fill:Oi(e.barColors,i)??"#007bff"}:{fill:i?this.getColorFromScheme(e,i):"#007bff"}}resolveSummaryStyle(e,t,i){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,i):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){let i=this.colorSchemeMap.get(t);if(i)return i;let r=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||Ni,o=r[this.colorSchemeIndex%r.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,o),o}};function Ev(e,t,i){let{scales:r,config:o,getConnector:n,getO:a}=e;if(!n||!r)return[];let s=[],{projection:l}=r,c=/* @__PURE__ */new Map;for(let e of t){if("point"!==e.type&&"rect"!==e.type)continue;let t=e.datum;if(!t)continue;let i,r,o=n(t);o&&("point"===e.type?(i=e.x,r=e.y):(i=e.x+e.w/2,r=e.y+("vertical"===l?0:e.h/2)),c.has(o)||c.set(o,[]),c.get(o).push({x:i,y:r,datum:t,category:a(t)}))}let u=new Map(r.o.domain().map((e,t)=>[e,t])),d=o.connectorStyle,h={stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5},f=e=>"function"==typeof d?d(e):d||h,p=(e,t,i)=>{s.push({type:"connector",x1:e.x,y1:e.y,x2:t.x,y2:t.y,style:f(e.datum),datum:e.datum,group:i})};for(let[e,t]of c)if(!(t.length<2)){t.sort((e,t)=>(u.get(e.category)??-1)-(u.get(t.category)??-1));for(let i=0;i<t.length-1;i++)p(t[i],t[i+1],e);"radial"===l&&t.length>=3&&p(t[t.length-1],t[0],e)}return s}function Dv(e,t,i,r=!1){let o=/* @__PURE__ */new Map;for(let r of e){let e=t(r);if(!Number.isFinite(e))continue;let n=i?i(r):"_default",a=o.get(n);a||(a={total:0,value:0,pieces:[]},o.set(n,a)),a.total+=e,a.pieces.push(r)}let n=0;for(let e of o.values())n+=Math.abs(e.total);for(let e of o.values())e.value=r&&n>0?e.total/n:e.total;return o}function Ov(e,t,i,r=!1){let o=/* @__PURE__ */new Set;return{steps:e.map(e=>{let n=Dv(e.pieceData,t,i,r),a=0;for(let[e,t]of n)o.add(e),a+=t.total;return{col:e,groups:n,stepTotal:a}}),keys:[...o]}}function jv(e,t,i){let r="function"==typeof e?e(i?t.w:t.h):e;return"number"==typeof r&&Number.isFinite(r)?Math.max(0,r):0}function Wv(e){let t=e.getSymbol;return t?Be(t,e.config.symbolMap):null}function Bv(e,t,i,r,o,n,a){t?e.push({type:"symbol",x:r,y:o,size:Math.PI*n*n,symbolType:t(i),style:a,datum:i}):e.push({type:"point",x:r,y:o,r:n,style:a,datum:i})}function Yv(e,t){let{scales:i,columns:r,config:o,resolvePieceStyle:n,getR:a}=e,s=[],l=Math.min(t.width,t.height)/2-4,c="donut"===o.chartType?o.innerRadius||60:0,u=-Math.PI/2+(o.startAngle||0)*Math.PI/180,d=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI,h=null!=o.sweepAngle&&o.sweepAngle<360,f=Object.values(r),p=f.some(e=>{let t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),g=f.length,m=h&&!p&&g>1&&(o.cornerRadius??0)>0;for(let e=0;e<f.length;e++){let t=f[e],i=t.pieceData[0],r="number"==typeof i?._pctStart?i._pctStart:t.pctStart,h="number"==typeof i?._pct?i._pct:t.pct,p=u+r*d,g=u+(r+h)*d,y=n(t.pieceData[0],t.name),x=0===e,b=e===f.length-1,v={type:"wedge",cx:0,cy:0,innerRadius:c,outerRadius:l,startAngle:p,endAngle:g,...o.cornerRadius&&{cornerRadius:o.cornerRadius},style:y,datum:i?._nonInteractive?null:t.pieceData,accessibleDatum:{...1===t.pieceData.length?t.pieceData[0]:{},category:t.name,value:t.pieceData.reduce((e,t)=>e+a(t),0),percent:100*h,count:t.pieceData.length,...t.pieceData[0]?.__gaugeAccessibleDatum},category:t.name};i?._roundedEnds?v.roundedEnds=i._roundedEnds:m&&(v.roundedEnds={start:x,end:b}),i?._gradientBand&&(v._gradientBand=i._gradientBand),s.push(v)}return s}import{quantileSorted as Gv}from"d3-array";function Xv(e,t,i){return{...e[0],...i,category:t,data:e}}function Vv(e){let t=e.length,i=e[0],r=e[t-1];return{n:t,min:i,q1:Gv(e,.25)??i,median:Gv(e,.5)??(i+r)/2,q3:Gv(e,.75)??r,max:r,mean:e.reduce((e,t)=>e+t,0)/t}}function qv(e,t,i,r,o){let n=new Array(o).fill(0);for(let a of e)a<t||a>i||n[Math.min(Math.floor((a-t)/r),o-1)]++;return n}import{scaleLinear as Hv}from"d3-scale";var Uv={bar:function(e,t){let{scales:i,columns:r,config:o,getR:n,getStack:a,resolvePieceStyle:s}=e,{r:l,projection:c}=i,u=[],d="vertical"===c,h="horizontal"===c,f=o.normalize,{steps:p,keys:g}=Ov(Object.values(r),n,a,f);for(let{col:e,groups:t}of p){let i=0,r=0;for(let o of g){let n=t.get(o);if(!n)continue;let c=n.value,f=s(n.pieces[0],a?o:e.name),p={...n.pieces[0],__aggregateValue:n.total,__pieceCount:n.pieces.length,category:e.name};if(d){let t=l(c>=0?i+c:r),n=c>=0?l(i)-l(i+c):l(r+c)-l(r);u.push(da(e.x,t,e.width,Math.abs(n),f,p,o)),c>=0?i+=c:r+=c}else if(h){let t=l(c>=0?i:r+c),n=c>=0?l(i+c)-l(i):l(r)-l(r+c);u.push(da(t,e.x,Math.abs(n),e.width,f,p,o)),c>=0?i+=c:r+=c}}}let m="vertical"===c;for(let e of u){if("rect"!==e.type)continue;let t=e.datum?.__aggregateValue??0;e.roundedEdge=m?t>=0?"top":"bottom":t>=0?"right":"left",o.gradientFill&&(e.fillGradient=o.gradientFill)}if(void 0!==o.roundedTop){let e=/* @__PURE__ */new Map;for(let t of u){if("rect"!==t.type)continue;let i=t.datum?.category||"";e.has(i)||e.set(i,[]),e.get(i).push(t)}for(let t of e.values()){if(0===t.length)continue;let e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),i=t.filter(e=>(e.datum?.__aggregateValue??0)<0);if(e.length>0){let t=m?e.reduce((e,t)=>e.y<t.y?e:t):e.reduce((e,t)=>e.x+e.w>t.x+t.w?e:t),i=jv(o.roundedTop,t,m);i>0&&(t.roundedTop=i)}if(i.length>0){let e=m?i.reduce((e,t)=>e.y+e.h>t.y+t.h?e:t):i.reduce((e,t)=>e.x<t.x?e:t),t=jv(o.roundedTop,e,m);t>0&&(e.roundedTop=t)}}}return u},clusterbar:function(e,t){let{scales:i,columns:r,config:o,getR:n,getGroup:a,resolvePieceStyle:s}=e,{r:l,projection:c}=i,u=[],d="vertical"===c,{steps:h,keys:f}=Ov(Object.values(r),n,a),p=f.length||1;for(let{col:e,groups:t}of h){let i=e.width/p,r=.2*i,o=i-r;for(let a=0;a<f.length;a++){let c=t.get(f[a])?.pieces||[];for(let t of c){let c=n(t),h=s(t,f[a]);if(d){let n=e.x+a*i+r/2,s=l(0),d=l(c);u.push(da(n,Math.min(s,d),o,Math.abs(s-d),h,t,f[a]))}else{let n=e.x+a*i+r/2,s=l(0),d=l(c);u.push(da(Math.min(s,d),n,Math.abs(d-s),o,h,t,f[a]))}}}}for(let e of u){if("rect"!==e.type||null==e.datum)continue;let t=n(e.datum),i=jv(o.roundedTop,e,d);i>0&&(e.roundedTop=i),e.roundedEdge=d?t>=0?"top":"bottom":t>=0?"right":"left",o.gradientFill&&(e.fillGradient=o.gradientFill)}return u},point:function(e,t){let{scales:i,columns:r,getR:o,multiScales:n,resolvePieceStyle:a}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d="radial"===l,h=n.length>0,f=Wv(e),p=2*Math.PI,g=-Math.PI/2;for(let e of Object.values(r))for(let t of e.pieceData){let i,r,l=t.__rIndex??0,m=t.__rValue??o(t),y=h&&n[l]||s,x=a(t,e.name),b=x.r||5;if(d){let t=g+(e.pctStart+e.pct/2)*p,o=y(m);i=Math.cos(t)*o,r=Math.sin(t)*o}else u?(i=e.middle,r=y(m)):(i=y(m),r=e.middle);Bv(c,f,t,i,r,b,x)}return c},swarm:function(e,t){let{scales:i,columns:r,getR:o,resolvePieceStyle:n}=e,{r:a,projection:s}=i,l=[],c="vertical"===s,u=Wv(e);for(let e of Object.values(r)){let t=e.width/2;for(let i=0;i<e.pieceData.length;i++){let r=e.pieceData[i],s=o(r),d=n(r,e.name),h=d.r||4,f=(7919*i%100/100-.5)*t*.8;Bv(l,u,r,c?e.middle+f:a(s),c?a(s):e.middle+f,h,d)}}return l},pie:Yv,donut:Yv,boxplot:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d=!1!==o.showOutliers;for(let t of Object.values(r)){let i=t.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===i.length)continue;let r=Vv(i),{min:o,max:l,q1:h,median:f,q3:p}=r,g=p-h,m=h-1.5*g,y=p+1.5*g,x=i.find(e=>e>=m)??o,b=l;for(let e=i.length-1;e>=0;e--)if(i[e]<=y){b=i[e];break}r.min=x,r.max=b;let v=a(Xv(t.pieceData,t.name,r),t.name),w=[];if(d)for(let e of t.pieceData){let i=n(e);if(i<m||i>y){let r=u?t.middle:s(i),o=u?s(i):t.middle;w.push({px:r,py:o,value:i,datum:e})}}if(c.push({type:"boxplot",x:u?t.middle:0,y:u?0:t.middle,projection:u?"vertical":"horizontal",columnWidth:.6*t.width,minPos:s(x),q1Pos:s(h),medianPos:s(f),q3Pos:s(p),maxPos:s(b),stats:r,style:v,datum:t.pieceData,category:t.name,outliers:w}),d)for(let t of w)c.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:v.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6,cursor:v.cursor},datum:t.datum})}return c},violin:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d=o.bins||20,h=!1!==o.showIQR;for(let e of Object.values(r)){let t=e.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(t.length<2)continue;let i,r=t[0],o=t[t.length-1],l=(o-r)/d||1,f=qv(t,r,o,l,d),p=ze(f,1),g=e.width/2*.9;if(u){i=`M ${e.middle} ${s(r)}`;for(let t=0;t<d;t++){let o=s(r+(t+.5)*l),n=f[t]/p*g;i+=` L ${e.middle+n} ${o}`}i+=` L ${e.middle} ${s(o)}`;for(let t=d-1;t>=0;t--){let o=s(r+(t+.5)*l),n=f[t]/p*g;i+=` L ${e.middle-n} ${o}`}i+=" Z"}else{i=`M ${s(r)} ${e.middle}`;for(let t=0;t<d;t++){let o=s(r+(t+.5)*l),n=f[t]/p*g;i+=` L ${o} ${e.middle-n}`}i+=` L ${s(o)} ${e.middle}`;for(let t=d-1;t>=0;t--){let o=s(r+(t+.5)*l),n=f[t]/p*g;i+=` L ${o} ${e.middle+n}`}i+=" Z"}let m,y=Vv(t),x=a(Xv(e.pieceData,e.name,y),e.name);h&&t.length>=4&&(m={q1Pos:s(y.q1),medianPos:s(y.median),q3Pos:s(y.q3),centerPos:e.middle,isVertical:u});let b=u?{x:e.x,y:Math.min(s(o),s(r)),width:e.width,height:Math.abs(s(o)-s(r))}:{x:Math.min(s(r),s(o)),y:e.x,width:Math.abs(s(o)-s(r)),height:e.width};c.push({type:"violin",pathString:i,translateX:0,translateY:0,bounds:b,iqrLine:m,stats:y,style:x,datum:e.pieceData,category:e.name})}return c},histogram:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s}=i,l=[],c=o.bins||25,u=o.normalize,d=s.domain?.(),h=d?+d[0]:void 0,f=d?+d[1]:void 0;for(let e of Object.values(r)){let t=e.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;let[i,r]=Ne(t),o=null!=h&&isFinite(h)?h:i,d=null!=f&&isFinite(f)?f:r,p=(d-o)/c||1,g=qv(t,o,d,p,c),m=t.length,y=ze(g,1);for(let t=0;t<c;t++){if(0===g[t])continue;let i=(u?g[t]/m:g[t]/y)*e.width*.9,r=s(o+t*p),n=s(o+(t+1)*p),c=Math.min(r,n),d=Math.abs(n-r),h=e.x+e.width-i,f={...e.pieceData[0],bin:t,count:g[t],range:[o+t*p,o+(t+1)*p],category:e.name,data:e.pieceData},x=a(f,e.name);l.push(da(c,h,d,i,x,f,e.name))}}return l},ridgeline:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s,projection:l}=i,c=[],u=o.bins||20,d="horizontal"===l,h=o.amplitude||1.5;for(let e of Object.values(r)){let t=e.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(t.length<2)continue;let i,r=t[0],o=t[t.length-1],l=(o-r)/u||1,f=qv(t,r,o,l,u),p=ze(f,1),g=Vv(t),m=a(Xv(e.pieceData,e.name,g),e.name),y=e.width*h;if(d){let t=e.x+e.width;i=`M ${s(r)} ${t}`;for(let e=0;e<u;e++)i+=` L ${s(r+(e+.5)*l)} ${t-f[e]/p*y}`;i+=` L ${s(o)} ${t} Z`}else{let t=e.x;i=`M ${t} ${s(r)}`;for(let e=0;e<u;e++){let o=s(r+(e+.5)*l);i+=` L ${t+f[e]/p*y} ${o}`}i+=` L ${t} ${s(o)} Z`}let x=d?{x:Math.min(s(r),s(o)),y:e.x,width:Math.abs(s(o)-s(r)),height:e.width}:{x:e.x,y:Math.min(s(o),s(r)),width:e.width,height:Math.abs(s(o)-s(r))};c.push({type:"violin",pathString:i,translateX:0,translateY:0,bounds:x,stats:g,style:{...m,fillOpacity:m.fillOpacity??.5},datum:e.pieceData,category:e.name})}return c},timeline:function(e,t){let{scales:i,columns:r,getRawRange:o,resolvePieceStyle:n}=e,{r:a,projection:s}=i,l=[],c="horizontal"===s;for(let e of Object.values(r))for(let t of e.pieceData){let i=o(t);if(!i)continue;let[r,s]=i,u=n(t,e.name);if(c){let i=a(Math.min(r,s)),o=a(Math.max(r,s));l.push(da(i,e.x,o-i,e.width,u,t,e.name))}else{let i=a(Math.max(r,s)),o=a(Math.min(r,s));l.push(da(e.x,i,e.width,o-i,u,t,e.name))}}return l},funnel:function(e,t){let{columns:i,getR:r,getStack:o,resolvePieceStyle:n}=e,a=[],s=t.width/2,l=!1!==e.config.showLabels,c=e.scales.o.domain().map(e=>i[e]).filter(Boolean);if(0===c.length)return a;let{steps:u,keys:d}=Ov(c,r,o),h=d.length>1&&"_default"!==d[0],f=0;if(!h)for(let{stepTotal:e}of u)e>f&&(f=e);if(h)for(let e of u){let t=0,i=0;for(let r=0;r<d.length;r++){let o=e.groups.get(d[r]);o&&(r%2==0?t+=o.total:i+=o.total)}let r=Math.max(t,i);r>f&&(f=r)}if(0===f)return a;let p=u[0].stepTotal,g=h?.95*s:.9*t.width,m=Hv().domain([0,f]).range([0,g]),y=e.config.connectorOpacity??.3,x=/* @__PURE__ */new Map;for(let t=0;t<u.length;t++){let i=u[t],r=i.col,o=0===t,c=r.x,f=r.width,g=.55*f,b=c+(f-g)/2,v=/* @__PURE__ */new Map;if(h){let e=0;for(let t of d){let r=i.groups.get(t);r&&(e+=m(r.total))}let t=s,c=s;for(let h=0;h<d.length;h++){let f=d[h],p=i.groups.get(f);if(!p)continue;let y=m(p.total),x=h%2==0,w=x?t:c-y;x?t+=y:c-=y;let k=n(p.pieces[0],f),A=u[0].groups.get(f)?.total??0,S=A>0?p.total/A*100:0,M={...p.pieces[0],__funnelValue:p.total,__funnelPercent:S,__funnelStep:r.name,__funnelIsFirstStep:o,__aggregateValue:p.total,__pieceCount:p.pieces.length,category:f};l&&(0===h&&(M.__funnelStepLabel=r.name,M.__funnelStepLabelX=s,M.__funnelStepLabelY=b,M.__funnelRowWidth=e),M.__funnelValueLabelX=w+y/2,M.__funnelValueLabelY=b,M.__funnelBarW=y),a.push(da(w,b,y,g,k,M,f)),v.set(f,{x:w,y:b,w:y,h:g})}}else{let e=i.stepTotal,t=m(e),c=s-t/2,u=d[0],h="_default"!==u,f=i.groups.get(u)?.pieces[0]??r.pieceData[0],y=h?u:r.name,x=n(f,y),w=p>0?e/p*100:0,k={...f,__funnelValue:e,__funnelPercent:w,__funnelStep:r.name,__funnelIsFirstStep:o,category:h?u:r.name};l&&(k.__funnelStepLabel=r.name,k.__funnelStepLabelX=s,k.__funnelStepLabelY=b,k.__funnelRowWidth=t,k.__funnelValueLabelX=s,k.__funnelValueLabelY=b,k.__funnelBarW=t),a.push(da(c,b,t,g,x,k,y)),v.set(u,{x:c,y:b,w:t,h:g})}if(t>0&&x.size>0){let t=h?d:[d[0]];for(let o of t){let t=x.get(o),s=v.get(o);if(!t||!s)continue;let l=(()=>{let e=i.groups.get(o),t="_default"===o?r.name:o;return n(e?e.pieces[0]:r.pieceData[0],t)})(),c={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[s.x+s.w,s.y],[s.x,s.y]],style:{fill:l.fill||e.config.themeSemantic?.secondary||"#999",opacity:y,cursor:l.cursor},datum:i.groups.get(o)?.pieces[0]??r.pieceData[0],category:"_default"===o?r.name:o};a.push(c)}}x=v}return a},"bar-funnel":function(e,t){let{columns:i,getR:r,getStack:o,resolvePieceStyle:n,scales:a}=e,s=[],l=a.o.domain().map(e=>i[e]).filter(Boolean);if(0===l.length)return s;let{steps:c,keys:u}=Ov(l,r,o),d=u.length>1&&"_default"!==u[0],h=a.r,f=d?u.length:1,p=d?.15:0;for(let e=0;e<c.length;e++){let t=c[e],i=t.col,r=0===e,o=e>0?c[e-1]:null,a=i.width/f,l=a*p,g=a-l;for(let e=0;e<u.length;e++){let f=u[e],p=t.groups.get(f);if(!p)continue;let m=p.total,y=c[0].groups.get(f)?.total??0,x=y>0?m/y*100:0,b=o?.groups.get(f)?.total??m,v=r?0:Math.max(0,b-m),w=i.x+e*a+l/2,k=h(m),A=h(0),S=A-k,M=n(p.pieces[0],d?f:i.name),$={...p.pieces[0],__barFunnelValue:m,__barFunnelPercent:x,__barFunnelIsFirstStep:r,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===f?void 0:f,category:d?f:i.name,__barFunnelLabelX:w+g/2,__barFunnelLabelY:h(m+v)};if(s.push(da(w,Math.min(k,A),g,Math.abs(S),M,$,d?f:i.name)),v>0){let e=h(m+v),t=k-e,r={...M},o={...p.pieces[0],__barFunnelValue:v,__barFunnelPercent:y>0?v/y*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===f?void 0:f,category:d?f:i.name};s.push(da(w,e,g,t,r,o,d?f:i.name))}}}return s},swimlane:function(e,t){let{scales:i,columns:r,getR:o,getStack:n,resolvePieceStyle:a}=e,{r:s,projection:l}=i,c=[],u="horizontal"===l,d=e.config.gradientFill,h=u?"left":"bottom",f=/* @__PURE__ */new Map,p=t=>{let i=f.get(t);if(void 0!==i)return i;let r="function"==typeof e.config.roundedTop?e.config.roundedTop(t.width):e.config.roundedTop,o="number"==typeof r&&Number.isFinite(r)?Math.max(0,r):0;return f.set(t,o),o},g=e.config.trackFill;if(g){let e="string"==typeof g?g:g.color,t="string"==typeof g?1:g.opacity??1,[i,o]=s.range(),n=Math.min(i,o),a=Math.abs(o-i);for(let i of Object.values(r)){let r={fill:e,opacity:t},o=u?da(n,i.x,a,i.width,r,null,"__track__"):da(i.x,n,i.width,a,r,null,"__track__"),s=p(i);s>0&&(o.cornerRadii={tl:s,tr:s,br:s,bl:s}),c.push(o)}}for(let e of Object.values(r)){let t=0,i=c.length,r=p(e);for(let i of e.pieceData){let r=Math.abs(o(i));if(0===r)continue;let l,f=n?n(i):e.name,p=a(i,f);if(u){let o=s(t),n=s(t+r);l=da(o,e.x,n-o,e.width,p,i,f)}else{let o=s(t+r),n=s(t);l=da(e.x,o,e.width,n-o,p,i,f)}d&&(l.fillGradient=d,l.roundedEdge=h),c.push(l),t+=r}if(r>0&&c.length>i){let e=c.slice(i),t=e[0],o=e[e.length-1];1===e.length?t.cornerRadii={tl:r,tr:r,br:r,bl:r}:u?(t.cornerRadii={tl:r,bl:r},o.cornerRadii={tr:r,br:r}):(t.cornerRadii={bl:r,br:r},o.cornerRadii={tl:r,tr:r})}}return c}};function Zv(e){let{data:t,chartType:i,projection:r,normalize:o,rExtent:n,extentPadding:a=.05,baselinePadding:s,axisExtent:l,getO:c,getR:u,getStack:d,rawRExtent:h}=e,f=a;if("radial"===r&&("pie"===i||"donut"===i))return[0,1];let p=0,g=0;if("bar"===i||"bar-funnel"===i){let e=/* @__PURE__ */new Map;for(let i of t){let t=c(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}for(let t of e.values()){let e=Dv(t,u,d,"bar"===i&&o),r=0,n=0;for(let{value:t}of e.values())"bar-funnel"===i?(r=Math.max(r,t),n=Math.min(n,t)):t>=0?r+=t:n+=t;g=Math.max(g,r),p=Math.min(p,n)}}else if("swimlane"===i){let e=/* @__PURE__ */new Map;for(let i of t){let t=c(i),r=Math.abs(u(i));e.set(t,(e.get(t)||0)+r)}for(let t of e.values())t>g&&(g=t)}else if("clusterbar"===i)for(let e of t){let t=u(e);Number.isFinite(t)&&(t>g&&(g=t),t<p&&(p=t))}else{let e=h[0],t=h[1];e!==1/0&&(p=e),t!==-1/0&&(g=t)}n&&(null!=n[0]&&(p=n[0]),null!=n[1]&&(g=n[1]));let m="bar"===i||"clusterbar"===i||"bar-funnel"===i||"swimlane"===i;if(m&&(null!=n?.[0]||null!=n?.[1]||(p>0&&(p=0),g<0&&(g=0))),"bar-funnel"!==i&&"exact"!==l){let e=g-p,t=e>0?e*f:1,r=m&&!s&&0===p,o=m&&!s&&0===g||"swimlane"===i;null==n?.[0]&&!r&&(p-=t),null==n?.[1]&&!o&&(g+=t)}return[p,g]}function Qv(e){let{data:t,oExtent:i,oScale:r,projection:o,layout:n,dynamicColumnWidth:a,getO:s,getR:l}=e,c=/* @__PURE__ */Object.create(null),u=/* @__PURE__ */new Map;for(let e of t){let t=s(e);u.has(t)||u.set(t,[]),u.get(t).push(e)}let d=0;if("radial"===o)for(let e of t)d+=Math.abs(l(e));let h=null;if(a&&"radial"!==o){h=/* @__PURE__ */new Map;let e=0;for(let t of i){let i,r=u.get(t)||[];i="string"==typeof a?r.reduce((e,t)=>{let i=Number(t[a]);return e+(Number.isFinite(i)?i:0)},0):a(r);let o=Number.isFinite(i)?Math.max(0,i):0;h.set(t,o),e=Math.max(e,o)}let t="horizontal"===o?n.height:n.width,s=r.padding()*r.step()*Math.max(0,i.length-1),l=Math.max(0,t-s);if(e>0){let t=0;for(let i of h.values())t+=i/e;for(let[i,r]of h)h.set(i,r/e/t*l)}}let f=0,p=0;for(let e of i){let t,i,o=u.get(e)||[],n=o.reduce((e,t)=>e+Math.abs(l(t)),0),a=d>0?n/d:0;h?(t=p,i=h.get(e)??r.bandwidth(),p+=i+r.padding()*r.step()):(t=r(e)??0,i=r.bandwidth()),c[e]={name:e,x:t,y:0,width:i,middle:t+i/2,padding:r.padding()*r.step(),pieceData:o,pct:a,pctStart:f},f+=a}return c}function Kv(e,t){let i="function"==typeof t,r=i?null:t||"category",o=/* @__PURE__ */new Map;for(let n=0;n<e.length;n++){let a=e[n],s=i?t(a):a[r],l=o.get(s);l?l.push(n):o.set(s,[n])}return o}var Jv=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ew=["scene-style","data-paint","accessibility","evidence"],tw=(e,t)=>({retainedData:e,invalidations:t}),iw=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],rw=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ow=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],nw=["scene-geometry","data-paint","accessibility","evidence"],aw=["scene-style","data-paint","accessibility","evidence"],sw=[],lw={chartType:/* @__PURE__ */tw("rebuild",iw),runtimeMode:/* @__PURE__ */tw("rebuild",iw),categoryAccessor:/* @__PURE__ */tw("rebuild",iw),valueAccessor:/* @__PURE__ */tw("rebuild",iw),oAccessor:/* @__PURE__ */tw("rebuild",iw),rAccessor:/* @__PURE__ */tw("rebuild",iw),stackBy:/* @__PURE__ */tw("rebuild",iw),groupBy:/* @__PURE__ */tw("rebuild",iw),timeAccessor:/* @__PURE__ */tw("rebuild",iw),accessorRevision:/* @__PURE__ */tw("rebuild",iw),colorAccessor:/* @__PURE__ */tw("rebuild",aw),symbolAccessor:/* @__PURE__ */tw("rebuild",nw),connectorAccessor:/* @__PURE__ */tw("rebuild",nw),dataIdAccessor:/* @__PURE__ */tw("rebuild",nw),projection:/* @__PURE__ */tw("preserve",rw),extentPadding:/* @__PURE__ */tw("preserve",rw),axisExtent:/* @__PURE__ */tw("preserve",rw),rExtent:/* @__PURE__ */tw("preserve",rw),oExtent:/* @__PURE__ */tw("preserve",rw),multiAxis:/* @__PURE__ */tw("preserve",rw),normalize:/* @__PURE__ */tw("preserve",rw),bins:/* @__PURE__ */tw("preserve",rw),oSort:/* @__PURE__ */tw("preserve",ow),barPadding:/* @__PURE__ */tw("preserve",ow),roundedTop:/* @__PURE__ */tw("preserve",ow),baselinePadding:/* @__PURE__ */tw("preserve",ow),innerRadius:/* @__PURE__ */tw("preserve",ow),cornerRadius:/* @__PURE__ */tw("preserve",ow),startAngle:/* @__PURE__ */tw("preserve",ow),sweepAngle:/* @__PURE__ */tw("preserve",ow),trackFill:/* @__PURE__ */tw("preserve",ow),showOutliers:/* @__PURE__ */tw("preserve",ow),showIQR:/* @__PURE__ */tw("preserve",ow),amplitude:/* @__PURE__ */tw("preserve",ow),connectorOpacity:/* @__PURE__ */tw("preserve",ow),showLabels:/* @__PURE__ */tw("preserve",ow),dynamicColumnWidth:/* @__PURE__ */tw("rebuild",ow),customLayout:/* @__PURE__ */tw("preserve",ow),layoutConfig:/* @__PURE__ */tw("preserve",ow),layoutMargin:/* @__PURE__ */tw("preserve",ow),symbolMap:/* @__PURE__ */tw("preserve",nw),pieceStyle:/* @__PURE__ */tw("preserve",aw),summaryStyle:/* @__PURE__ */tw("preserve",aw),connectorStyle:/* @__PURE__ */tw("preserve",aw),gradientFill:/* @__PURE__ */tw("preserve",aw),colorScheme:/* @__PURE__ */tw("preserve",aw),themeCategorical:/* @__PURE__ */tw("preserve",aw),themeSemantic:/* @__PURE__ */tw("preserve",aw),themeSequential:/* @__PURE__ */tw("preserve",aw),themeDiverging:/* @__PURE__ */tw("preserve",aw),barColors:/* @__PURE__ */tw("preserve",aw),decay:/* @__PURE__ */tw("preserve",aw),pulse:/* @__PURE__ */tw("preserve",aw),staleness:/* @__PURE__ */tw("preserve",aw),layoutSelection:/* @__PURE__ */tw("preserve",aw),windowSize:/* @__PURE__ */tw("preserve",sw),windowMode:/* @__PURE__ */tw("preserve",sw),clock:/* @__PURE__ */tw("preserve",sw),transition:/* @__PURE__ */tw("preserve",sw),introAnimation:/* @__PURE__ */tw("preserve",sw),onLayoutError:/* @__PURE__ */tw("preserve",sw)},cw=/* @__PURE__ */tw("preserve",ow);function uw(e){let t="preserve",i=/* @__PURE__ */new Set;for(let r of e){let e=lw[r]??cw;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}var dw=class{constructor(){this.tracker=new ne}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Jv)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},ew):this.recordNoop("restyle")}recordConfig(e){let t=uw(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as hw}from"d3-quadtree";function fw(e){let t=0,i=0;for(let r of e)"point"===r.type&&!1!==r.interactive&&(t++,r.r>i&&(i=r.r));if(t<=500)return{quadtree:null,maxRadius:i};let r=new Array(t),o=0;for(let t of e)"point"===t.type&&!1!==t.interactive&&(r[o++]=t);return{maxRadius:i,quadtree:hw().x(e=>e.x).y(e=>e.y).addAll(r)}}var pw=class extends za{constructor(e){super(),this.rExtent=new wn,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new dw,this.rAccessors=[],this.categories=/* @__PURE__ */new Set,this._hasStreamingData=!1,this.styleResolver=new zv,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=/* @__PURE__ */new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new vn(e.windowSize),this.getO=b(e.categoryAccessor||e.oAccessor,"category");let t="streaming"===e.runtimeMode,i=e.valueAccessor||e.rAccessor;Array.isArray(i)?(this.rAccessors=i.map(e=>y(e,"value")),this.getR=this.rAccessors[0],this.rExtents=i.map(()=>new wn)):(t&&e.timeAccessor,this.getR=y(i,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=b(e.stackBy),this.getGroup=b(e.groupBy),this.getColor=b(e.colorAccessor),this.getSymbol=b(e.symbolAccessor),this.getConnector=b(e.connectorAccessor),this.getDataId=b(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new vn(e.windowSize))}syncPulseTimestampBuffer(){var e,t,i,r;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,i=this.timestampBuffer,r=this.currentTime(),e?null!=i&&i.capacity===t.capacity&&i.size===t.size?i:Ta(t,r):null)}currentTime(){return this.config.clock?.()??R()}ingest(e){let t=this.currentTime();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(let e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();let i=e.totalSize||e.inserts.length;Ra(this.buffer,i,this.timestampBuffer);for(let i of e.inserts)Ca(this.buffer,i,this.timestampBuffer,t),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(let i of e.inserts){let e=Ca(this.buffer,i,this.timestampBuffer,t);this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=e&&this.evictValueExtent(e)}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}pushValueExtent(e){if("timeline"===this.config.chartType){let t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;t<this.rAccessors.length;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){let t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;t<this.rAccessors.length;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){let t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;let i="function"==typeof t?t(e):e[t];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(e){let{config:t,buffer:i}=this,r=this.scales,o=this.multiScales,n=this.columns;if(0===i.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,void this.version++;this.rExtent.dirty&&("timeline"===t.chartType?(this.rExtent.clear(),i.forEach(e=>this.pushValueExtent(e))):this.rExtent.recalculate(i,this.getR));let a,s,l=this.getBufferArray(),c=t.projection||"vertical",u=t.oExtent||this.resolveCategories(l),d=this.computeValueDomain(l,u),h="vertical"===c,f="horizontal"===c,p="radial"===c,g=null!=t.barPadding?t.barPadding/(h?e.width:e.height):.1,m=Math.min(.9,Math.max(0,g));if(p){a=Cv().domain(u).range([0,1]).padding(0);let i=Math.min(e.width,e.height)/2,r=t.innerRadius||0;s=Nv().domain(d).range([r,i])}else f?(a=Cv().domain(u).range([0,e.height]).padding(m),s=Nv().domain(d).range([0,e.width])):(a=Cv().domain(u).range([0,e.width]).padding(m),s=Nv().domain(d).range([e.height,0]));this.scales={o:a,r:s,projection:c},this.rAccessors.length>1&&t.multiAxis?this.multiScales=this.rAccessors.map((r,o)=>{let n=this.rExtents[o];n.dirty&&n.recalculate(i,r);let[a,s]=n.extent;a===1/0&&(a=0,s=1);let l=t.extentPadding??.05,c=s-a,u=c>0?c*l:1;return a-=u,s+=u,a>0&&(a=0),f?Nv().domain([a,s]).range([0,e.width]):Nv().domain([a,s]).range([e.height,0])}):this.multiScales=[];let y=l;this.rAccessors.length>1&&(y=l.flatMap(e=>this.rAccessors.map((t,i)=>({...e,__rIndex:i,__rValue:t(e),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(y,u,a,c,e),this._customLayoutFailedThisBuild=!1;let x=this.buildSceneNodes(y,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.multiScales=o,this.columns=n):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=x,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,l),this.config.pulse&&this.applyPulse(this.scene,l),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++)}resolveRAccessorName(e){let t=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(t)?t[e]:t;return"string"==typeof i?i:`value${e}`}resolveCategories(e){let t=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,r="auto"===t?void 0:t,o=null;if(i){o=/* @__PURE__ */new Set;for(let t of e)o.add(this.getO(t))}let n=o?Array.from(this.categories).filter(e=>o.has(e)):Array.from(this.categories);if(i&&void 0===r){let e=Math.max(50,3*o.size);if(this.categories.size>e){let t=this.categories.size-e;for(let e of this.categories){if(t<=0)break;o.has(e)||(this.categories.delete(e),t--)}}return n}if(!1===r)return n;if("function"==typeof r)return n.sort(r);let a=/* @__PURE__ */new Map;for(let t of e){let e=this.getO(t);a.set(e,(a.get(e)||0)+Math.abs(this.getR(t)))}return"asc"===r?n.sort((e,t)=>(a.get(e)||0)-(a.get(t)||0)):n.sort((e,t)=>(a.get(t)||0)-(a.get(e)||0))}computeValueDomain(e,t){return Zv({data:e,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(e,t,i,r,o){return Qv({data:e,oExtent:t,oScale:i,projection:r,layout:o,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.styleResolver.resolvePieceStyle(this.config,e,t),resolveSummaryStyle:(e,t)=>this.styleResolver.resolveSummaryStyle(this.config,e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){let i=this.buildLayoutContext(e,t),r=Vn({family:"ordinal",logLabel:"ordinal customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:this.config.onLayoutError,run:()=>this.config.customLayout(i)});if("failure"===r.kind)return this.lastCustomLayoutFailure=r.diagnostic,this._customLayoutFailedThisBuild=!0,r.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);let o=r.result;this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;let n=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=/* @__PURE__ */new WeakMap;for(let e of n)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(n,this.config.layoutSelection??null)}return Wn({label:"ordinal customLayout",nodes:n,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),n}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;let i=this.getSceneContext(),r=Uv[this.config.chartType],o=r?r(i,t):[];return this.getConnector&&this.scales&&(o=[...Ev(i,o),...o]),o}buildLayoutContext(e,t){let i=this.config,r=i.layoutMargin??{top:0,right:0,bottom:0,left:0},o=kp(i.colorScheme,i.themeCategorical,Ni),n=this.scales,a="radial"===n.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height};return{data:e,scales:{o:n.o,r:n.r,projection:n.projection},dimensions:{width:t.width,height:t.height,margin:r,plot:a},theme:{semantic:i.themeSemantic??{},categorical:[...o]},resolveColor:Ap(o,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(e,t){let i=this.config.decay;return!i||t<=1?1:Mn(i,e,t)}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;let t=$n(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;let t=Kv(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){let e=fw(this.scene);this._pointQuadtree=e.quadtree,this._maxPointRadius=e.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){if(!this.config.decay)return;let i=t.length;if(i<=1)return;let r=this.getDatumIndexMap(t);for(let t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type||!t.datum)continue;let e=r.get(t.datum);if(null==e)continue;let o=this.computeDecayOpacity(e,i),n=t.style?.opacity??1;t.style={...t.style,opacity:n*o}}}applyPulse(e,t,i=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&Fv(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),i)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&Rn(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();let e,t=/* @__PURE__ */new Map,i=this.scales?.r(0)??0,r="horizontal"!==this.scales?.projection;for(let o=0;o<this.scene.length;o++){let n=this.scene[o],a=this.getNodeKey(n,t);a&&("rect"===n.type?r?this.prevPositionMap.set(a,{x:n.x,y:i,w:n.w,h:0,opacity:n.style.opacity??1}):this.prevPositionMap.set(a,{x:i,y:n.y,w:0,h:n.h,opacity:n.style.opacity??1}):"point"===n.type?this.prevPositionMap.set(a,{x:n.x,y:n.y,r:0,opacity:0}):"wedge"===n.type&&(void 0===e&&(e=n.startAngle),this.prevPositionMap.set(a,{x:n.cx,y:n.cy,startAngle:e,endAngle:e,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){let i=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,r=t.get(i)||0;return t.set(i,r+1),`${i}:${r}`}if("rect"===e.type){let i=e.datum?null!=e.datum.category&&""!==e.datum.category?String(e.datum.category):String(this.getO(e.datum)??""):"",r=`r:${e.group||""}:${i}`,o=t.get(r)||0;return t.set(r,o+1),0===o?r:`${r}:${o}`}return"wedge"===e.type?`w:${e.category??""}`:null}snapshotPositions(){this.prevPositionMap.clear();let e=/* @__PURE__ */new Map;for(let t=0;t<this.scene.length;t++){let i=this.scene[t],r=this.getNodeKey(i,e);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity??i.style.fillOpacity}):"rect"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity??i.style.fillOpacity}):"wedge"===i.type&&this.prevPositionMap.set(r,{x:i.cx,y:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:i.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;let e=this.config.transition.duration??300;if(this.exitNodes.length>0){let e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1,i=/* @__PURE__ */new Set,r=/* @__PURE__ */new Map;for(let e=0;e<this.scene.length;e++){let o=this.scene[e],n=this.getNodeKey(o,r);if(!n)continue;o._transitionKey=n;let a=this.prevPositionMap.get(n);if("point"===o.type)a?(i.add(n),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(a.x!==o.x||a.y!==o.y||void 0!==a.r&&a.r!==o.r)&&(o._targetX=o.x,o._targetY=o.y,o._targetR=o.r,o.x=a.x,o.y=a.y,void 0!==a.r&&(o.r=a.r),t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetR=o.r,o.r=0,o.style={...o.style,opacity:0},t=!0);else if("rect"===o.type)a?(i.add(n),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(a.x!==o.x||a.y!==o.y||a.w!==o.w||a.h!==o.h)&&(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=a.x,o.y=a.y,o.w=a.w??o.w,o.h=a.h??o.h,t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o.style={...o.style,opacity:0},t=!0);else if("wedge"===o.type)if(a)i.add(n),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(a.startAngle!==o.startAngle||a.endAngle!==o.endAngle)&&(o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle,o.startAngle=a.startAngle,o.endAngle=a.endAngle,t=!0);else{o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle;let e=o.startAngle;o.startAngle=e,o.endAngle=e,o.style={...o.style,opacity:0},this.prevPositionMap.set(n,{x:o.cx,y:o.cy,startAngle:e,endAngle:e,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(let[e,r]of this.prevPositionMap)if(!i.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:r.x,y:r.y,r:r.r??3,style:{opacity:r.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:r.x,y:r.y,w:r.w??0,h:r.h??0,style:{opacity:r.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){let t=((r.startAngle??0)+(r.endAngle??0))/2,i={type:"wedge",cx:r.x,cy:r.y,innerRadius:r.innerRadius??0,outerRadius:r.outerRadius??100,startAngle:r.startAngle??0,endAngle:r.endAngle??0,style:{opacity:r.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(i)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:this.currentTime(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;let t=P(e,this.activeTransition),i="linear"===this.config.transition?.easing?"linear":"ease-out-cubic",r=L(t,i);for(let e of this.scene){let t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){let i=this.prevPositionMap.get(t),o=i?i.opacity??1:0;e.style.opacity=I(o,e._targetOpacity,r)}let i=this.prevPositionMap.get(t);void 0!==e._targetX&&i&&(e.x=I(i.x,e._targetX,r),e.y=I(i.y,e._targetY,r)),void 0!==e._targetR&&void 0!==i?.r&&(e.r=I(i.r,e._targetR,r))}else if("rect"===e.type){if(void 0!==e._targetOpacity){let i=this.prevPositionMap.get(t),o=i?i.opacity??1:0;e.style.opacity=I(o,e._targetOpacity,r)}if(void 0===e._targetX)continue;let i=this.prevPositionMap.get(t);if(!i)continue;e.x=I(i.x,e._targetX,r),e.y=I(i.y,e._targetY,r),void 0!==i.w&&(e.w=I(i.w,e._targetW,r),e.h=I(i.h,e._targetH,r))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){let i=this.prevPositionMap.get(t),o=i?i.opacity??1:0;e.style={...e.style,opacity:I(o,e._targetOpacity,r)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){let i=this.prevPositionMap.get(t);i&&void 0!==i.startAngle&&(e.startAngle=I(i.startAngle,e._targetStartAngle,r),e.endAngle=I(i.endAngle,e._targetEndAngle,r))}}}if(t>=1){for(let e of this.scene)if(void 0!==e._targetOpacity&&(e.style={...e.style||{},opacity:0===e._targetOpacity?0:e._targetOpacity},e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(e.x=e._targetX,e.y=e._targetY),void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){let e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null,ts(this.scene),this.exitNodes=[]}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw new Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();let t=kn(e),i=this.getDataId,r=e=>t.has(i(e));Na(this.buffer,this.timestampBuffer,r);let o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(let e of o)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getDataId)throw new Error("update() requires dataIdAccessor to be configured");let i=kn(e),r=this.getDataId,o=/* @__PURE__ */new Set;this.buffer.forEach((e,t)=>{i.has(r(e))&&o.add(t)});let n=this.buffer.update(e=>i.has(r(e)),t);if(0===n.length)return this.updateResults.recordNoop("update"),n;for(let e of n)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),o.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",n.length),n}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(e,t){let i=this._customRestyle;if(i)for(let r of e){let e=this._baseStyles.get(r)??r.style??{},o=i(r,t);r.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(let e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){let t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!m(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!m(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!m(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let r=!1;if("categoryAccessor"in e||"oAccessor"in e){let e=this.config.categoryAccessor||this.config.oAccessor,i=t.categoryAccessor||t.oAccessor;m(e,i)||(this.getO=b(this.config.categoryAccessor||this.config.oAccessor,"category"),r=!0)}let o=!1;if("valueAccessor"in e||"rAccessor"in e){let e=this.config.valueAccessor||this.config.rAccessor,i=t.valueAccessor||t.rAccessor,r=Array.isArray(e)?e:[e],n=Array.isArray(i)?i:[i];if(o=r.length!==n.length||r.some((e,t)=>!m(e,n[t])),o){let e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>y(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new wn)):(this.getR=y(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!m(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?b(this.config.stackBy):void 0),"groupBy"in e&&!m(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?b(this.config.groupBy):void 0),"colorAccessor"in e&&!m(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?b(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!m(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?b(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!m(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?b(this.config.connectorAccessor):void 0);let n="accessorRevision"in e&&e.accessorRevision!==t.accessorRevision;(r||o||n)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(i)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};function gw(e,t,i,r){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:i,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:r,fn:t}:{key:void 0,fn:null}}function mw(e,t,i){return r=>{if(!r||!i||!e.fn&&!t.fn)return r;let o=!1,n=r.map(i=>{let r=e.fn&&e.key&&!(e.key in i),n=t.fn&&t.key&&!(t.key in i);if(!r&&!n)return i;o=!0;let a={...i};return r&&(a[e.key]=e.fn(i)),n&&(a[t.key]=t.fn(i)),a});return o?n:r}}import*as yw from"react";import*as xw from"react";import{arc as bw}from"d3-shape";var vw=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function ww(e){let{innerRadius:t,outerRadius:i,startAngle:r,endAngle:o}=e,n=t<=0;if(!((e.cornerRadius??0)>0&&(e.roundStart||e.roundEnd))){if(n){let e=vw(i,r),t=vw(i,o),n=o-r>Math.PI?1:0;return`M0,0 L${e.x},${e.y} A${i},${i} 0 ${n} 1 ${t.x},${t.y} Z`}let e=vw(i,r),a=vw(i,o),s=vw(t,o),l=vw(t,r),c=o-r>Math.PI?1:0;return`M${e.x},${e.y} A${i},${i} 0 ${c} 1 ${a.x},${a.y} L${s.x},${s.y} A${t},${t} 0 ${c} 0 ${l.x},${l.y} Z`}let a=i-t,s=Math.max(0,Math.min(e.cornerRadius??0,a/2));if(0===s)return ww({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});let l=Math.asin(Math.min(1,s/Math.max(1e-9,i-s))),c=n?0:Math.asin(Math.min(1,s/Math.max(1e-9,t+s))),u=o-r,d=e.roundStart&&e.roundEnd?u/2:u,h=!!e.roundStart&&l<d,f=!!e.roundEnd&&l<d;if(!h&&!f)return ww({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});let p=r+(h?l:0),g=o-(f?l:0),m=r+(h?c:0),y=o-(f?c:0),x=vw(i,p),b=vw(i,g),v=(i-s)*Math.cos(l),w=vw(v,r),k=vw(v,o),A=n?null:vw(t,y),S=n?null:vw(t,m),M=n?0:(t+s)*Math.cos(c),$=n?null:vw(M,r),_=n?null:vw(M,o),L=g-p>Math.PI?1:0,P=n?0:y-m>Math.PI?1:0,I="";if(h)I+=`M${w.x},${w.y}`,I+=` A${s},${s} 0 0 1 ${x.x},${x.y}`;else{let e=vw(i,r);I+=`M${e.x},${e.y}`}if(f)I+=` A${i},${i} 0 ${L} 1 ${b.x},${b.y}`,I+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{let e=vw(i,o);I+=` A${i},${i} 0 ${L} 1 ${e.x},${e.y}`}if(n)I+=" L0,0";else{if(f)I+=` L${_.x},${_.y}`,I+=` A${s},${s} 0 0 1 ${A.x},${A.y}`;else{let e=vw(t,o);I+=` L${e.x},${e.y}`}if(h)I+=` A${t},${t} 0 ${P} 0 ${S.x},${S.y}`,I+=` A${s},${s} 0 0 1 ${$.x},${$.y}`;else{let e=vw(t,r);I+=` A${t},${t} 0 ${P} 0 ${e.x},${e.y}`}}return I+=" Z",I}function kw(e){let t=ww({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),i=[],r=e.colors;if(r.length>0){let t=(e.endAngle-e.startAngle)/r.length;for(let o=0;o<r.length;o++){let n=e.startAngle+o*t;i.push({d:ww({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:n,endAngle:e.endAngle}),color:r[o]})}}return{clipPath:t,slices:i}}import{jsx as Aw,jsxs as Sw}from"react/jsx-runtime";function Mw(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e4?`${(e/1e3).toFixed(0)}K`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function $w(e,t){let i=e.datum;if(!i)return null;let r=[],o=i.__funnelStepLabel,n=Number(i.__funnelStepLabelX),a=Number(i.__funnelStepLabelY),s=Number(i.__funnelRowWidth);"string"==typeof o&&Number.isFinite(n)&&Number.isFinite(a)&&(!Number.isFinite(s)||8.4*o.length+16<=s)&&r.push(
284
- /* @__PURE__ */Aw("text",{x:n,y:a+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:o},`${t}-funnel-step`));let l=Number(i.__funnelValue),c=Number(i.__funnelValueLabelX),u=Number(i.__funnelValueLabelY),d=Number(i.__funnelBarW);if(Number.isFinite(l)&&0!==l&&Number.isFinite(c)&&Number.isFinite(u)&&d>=60){let e=Number(i.__funnelPercent),o=!0!==i.__funnelIsFirstStep&&Number.isFinite(e)?`${Mw(l)} (${Math.abs(e-Math.round(e))<.05?Math.round(e):e.toFixed(1)}%)`:Mw(l);7.8*o.length+16>d&&(o=Mw(l)),7.8*o.length+16<=d&&r.push(
285
- /* @__PURE__ */Aw("text",{x:c,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:o},`${t}-funnel-value`))}return r.length?/* @__PURE__ */Aw("g",{children:r},`${t}-funnel-labels`):null}function _w(e,t,i){return yl(Lw(e,t,i),e,`ordinal-cursor-${t}`)}function Lw(e,t,i){let r=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",o=i=>`ord-${e.type}-${r}-${t}-${i}`,n=`ord-${e.type}-${r}-${t}`;switch(e.type){case"rect":{let t,i,r=e,o=`${al(n)}-grad`,a=cl(r,o);if(a)i=`url(#${o})`;else if(Ns(r.style.fill)){let e=`${al(n)}-hatch`;t=Es(r.style.fill,e),i=`url(#${e})`}else i=nl(r.style.fill);let s=a||t?/* @__PURE__ */Sw("defs",{children:[a,t]}):null;if(r.cornerRadii&&el(r.cornerRadii)){let e=ul(r);/* @__PURE__ */
286
- return Sw(xw.Fragment,{children:[s,
287
- /* @__PURE__ */Aw("path",{d:e,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},n)}if(r.roundedTop&&r.roundedTop>0){let e,t=Math.min(r.roundedTop,r.w/2,r.h/2),{x:o,y:a,w:l,h:c}=r;switch(r.roundedEdge){case"right":e=`M${o},${a} L${o+l-t},${a} A${t},${t} 0 0 1 ${o+l},${a+t} L${o+l},${a+c-t} A${t},${t} 0 0 1 ${o+l-t},${a+c} L${o},${a+c} Z`;break;case"left":e=`M${o+l},${a} L${o+t},${a} A${t},${t} 0 0 0 ${o},${a+t} L${o},${a+c-t} A${t},${t} 0 0 0 ${o+t},${a+c} L${o+l},${a+c} Z`;break;case"bottom":e=`M${o},${a} L${o+l},${a} L${o+l},${a+c-t} A${t},${t} 0 0 1 ${o+l-t},${a+c} L${o+t},${a+c} A${t},${t} 0 0 1 ${o},${a+c-t} Z`;break;default:e=`M${o},${a+c} L${o},${a+t} A${t},${t} 0 0 1 ${o+t},${a} L${o+l-t},${a} A${t},${t} 0 0 1 ${o+l},${a+t} L${o+l},${a+c} Z`}/* @__PURE__ */
288
- return Sw(xw.Fragment,{children:[s,
289
- /* @__PURE__ */Aw("path",{d:e,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},n)}/* @__PURE__ */
290
- return Sw(xw.Fragment,{children:[s,
291
- /* @__PURE__ */Aw("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth}),$w(r,n)]},n)}case"point":{let t=e;/* @__PURE__ */
292
- return Aw("circle",{cx:t.x,cy:t.y,r:t.r,fill:nl(t.style.fill),opacity:t.style.opacity??t.style.fillOpacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},n)}case"symbol":return dl(e,t,i);case"glyph":{let r=e;return sl(r,r.x,r.y,`${i??""}ord-glyph-${r.pointId??t}`)}case"wedge":{let r,o=e;if(o._gradientBand&&o._gradientBand.colors.length>0){let e=al(`${i?`${i}-`:""}gauge-grad-${o.category||n}-${t}`),{clipPath:r,slices:a}=kw({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds?.start??!0,roundEnd:o.roundedEnds?.end??!0,colors:o._gradientBand.colors});/* @__PURE__ */
293
- return Sw("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[
294
- /* @__PURE__ */Aw("defs",{children:/* @__PURE__ */Aw("clipPath",{id:e,children:/* @__PURE__ */Aw("path",{d:r})})}),
295
- /* @__PURE__ */Aw("g",{clipPath:`url(#${e})`,children:a.map((e,t)=>/* @__PURE__ */Aw("path",{d:e.d,fill:nl(e.color)},t))}),o.style.stroke&&"none"!==o.style.stroke&&
296
- /* @__PURE__ */Aw("path",{d:r,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},n)}if(o.roundedEnds)r=ww({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{let e=bw().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&e.cornerRadius(o.cornerRadius),r=e(ol)||""}/* @__PURE__ */
297
- return Aw("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:nl(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},n)}case"boxplot":{let t=e,i=t.columnWidth/2,r=t.style.strokeWidth??1;return"vertical"===t.projection?/* @__PURE__ */Sw("g",{children:[
298
- /* @__PURE__ */Aw("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:r}),
299
- /* @__PURE__ */Aw("rect",{x:t.x-i,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:nl(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:r}),
300
- /* @__PURE__ */Aw("line",{x1:t.x-i,y1:t.medianPos,x2:t.x+i,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2*r}),
301
- /* @__PURE__ */Aw("line",{x1:t.x-.5*i,y1:t.minPos,x2:t.x+.5*i,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:r}),
302
- /* @__PURE__ */Aw("line",{x1:t.x-.5*i,y1:t.maxPos,x2:t.x+.5*i,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:r})]},n):/* @__PURE__ */Sw("g",{children:[
303
- /* @__PURE__ */Aw("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:r}),
304
- /* @__PURE__ */Aw("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-i,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:nl(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:r}),
305
- /* @__PURE__ */Aw("line",{x1:t.medianPos,y1:t.y-i,x2:t.medianPos,y2:t.y+i,stroke:t.style.stroke||"#333",strokeWidth:2*r}),
306
- /* @__PURE__ */Aw("line",{x1:t.minPos,y1:t.y-.5*i,x2:t.minPos,y2:t.y+.5*i,stroke:t.style.stroke||"#333",strokeWidth:r}),
307
- /* @__PURE__ */Aw("line",{x1:t.maxPos,y1:t.y-.5*i,x2:t.maxPos,y2:t.y+.5*i,stroke:t.style.stroke||"#333",strokeWidth:r})]},n)}case"violin":{let t=e,i=[
308
- /* @__PURE__ */Aw("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:nl(t.style.fill),fillOpacity:t.style.fillOpacity??t.style.opacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth??1},o("path"))];if(t.iqrLine&&t.bounds){let e=t.bounds,r=e.x+e.width/2,n=e.y+e.height/2;t.iqrLine.isVertical?i.push(
309
- /* @__PURE__ */Aw("line",{x1:r,y1:t.iqrLine.q1Pos,x2:r,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),
310
- /* @__PURE__ */Aw("circle",{cx:r,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med"))):i.push(
311
- /* @__PURE__ */Aw("line",{x1:t.iqrLine.q1Pos,y1:n,x2:t.iqrLine.q3Pos,y2:n,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),
312
- /* @__PURE__ */Aw("circle",{cx:t.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med")))}/* @__PURE__ */
313
- return Aw("g",{children:i},n)}case"connector":{let t=e,i=t.style.fill&&"none"!==t.style.fill?nl(t.style.fill,"var(--semiotic-border, #999)"):"var(--semiotic-border, #999)";/* @__PURE__ */
314
- return Aw("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||i,strokeWidth:t.style.strokeWidth??1,opacity:t.style.opacity??.5},n)}case"trapezoid":{let t=e,i=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");/* @__PURE__ */
315
- return Aw("polygon",{points:i,fill:nl(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},n)}default:return null}}import{jsx as Pw,jsxs as Iw}from"react/jsx-runtime";function Rw(e){return"connector"===e.node.type}function Tw(e,t,i,r){if(e.length<2)return null;let o=e[0].node,n=o.style.fill;if(!n||"none"===n)return null;let a=al(`${t?`${t}-`:""}connector-${i}-${r}-hatch`),s=Ns(n)?Es(n,a):null,l=[`${o.x1},${o.y1}`,...e.map(({node:e})=>`${e.x2},${e.y2}`)].join(" ");return yl(/* @__PURE__ */Iw(yw.Fragment,{children:[s&&/* @__PURE__ */Pw("defs",{children:s}),
316
- /* @__PURE__ */Pw("polygon",{points:l,fill:s?`url(#${a})`:nl(n,"#999"),opacity:o.style.fillOpacity??o.style.opacity??.3,"data-semiotic-connector-fill":o.group||"_default"})]}),o,`ordinal-connector-fill-${i}-${r}`)}function Cw(e,t,i){let r=/* @__PURE__ */new Map;for(let t of e){if(!Rw(t))continue;let e=t.node.group||"_default",i=r.get(e);i?i.push(t):r.set(e,[t])}if(0===r.size)return;let o=Array.from(r.values()).map((e,r)=>/* @__PURE__ */Iw("g",{children:[Tw(e,t,i,r),e.map(e=>e.element)]},`ordinal-connectors-${i}-${r}`)),n=e[0],a=Rw(n)?null:n.element;for(let e of r.values())for(let t of e)t.element=null;n.element=/* @__PURE__ */Iw(yw.Fragment,{children:[o,a]},`ordinal-connector-run-${i}`)}function Nw(e){let t=Rl({nodes:e.nodes,renderMode:e.renderMode,fallback:(t,i)=>_w(t,i,e.idPrefix)}),i=0;for(let r=0;r<t.length;){if(t[r].renderedByBackend){r++;continue}let o=r+1;for(;o<t.length&&!t[o].renderedByBackend;)o++;Cw(t.slice(r,o),e.idPrefix,i++),r=o}return t}function Fw(e){let{id:t,...i}=e;return Es({type:"hatch",...i},t)}var zw={stroke:"rgba(255,255,255,0.5)",lineWidth:1.5,spacing:6,angle:45,lineOpacity:1};import{Fragment as Ew,jsx as Dw,jsxs as Ow}from"react/jsx-runtime";function jw(e,t,i,r,o,n,a,s=!1){let l=e.scales;if(!l||"radial"===l.projection)return null;let c=fr(r),u="vertical"===l.projection,d=e.columns,h=i.categoryFormat||i.oFormat,f=i.valueFormat||i.rFormat,p=i.categoryLabel||i.oLabel,g=i.valueLabel||i.rLabel,m=i.legendPosition??"right",y=st(i.legendLayout,a?.leftAxis),x=s&&"left"===m&&y>0?y:n?.left??i.margin?.left??40,b=Object.values(d).map((e,t)=>({pixel:e.middle,label:h?h(e.name,t):e.name})),v=i.rTickValues??Pu(l.r,5,i.axisExtent),w=f||Ze(v),k=v.map(e=>({pixel:l.r(e),label:w(e)}));/* @__PURE__ */
317
- return Ow("g",u?{id:(o?`${o}-`:"")+"axes",className:"ordinal-axes",children:[
318
- /* @__PURE__ */Dw("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:c.border,strokeWidth:1}),b.map((e,i)=>/* @__PURE__ */Ow("g",{transform:`translate(${e.pixel},${t.height})`,children:[
319
- /* @__PURE__ */Dw("line",{y2:5,stroke:c.border,strokeWidth:1}),Ru(e.label)?/* @__PURE__ */Dw("text",{y:18,textAnchor:"middle",fontSize:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:e.label}):Tu({label:e.label,x:-30,y:6,textAlign:"center",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},`oxtick-${i}`)),p&&/* @__PURE__ */Dw("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,children:p}),
320
- /* @__PURE__ */Dw("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:c.border,strokeWidth:1}),k.map((e,t)=>/* @__PURE__ */Ow("g",{transform:`translate(0,${e.pixel})`,children:[
321
- /* @__PURE__ */Dw("line",{x2:-5,stroke:c.border,strokeWidth:1}),
322
- /* @__PURE__ */Dw("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:e.label})]},`oytick-${t}`)),g&&/* @__PURE__ */Dw("text",{x:15-x,y:t.height/2,textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,transform:`rotate(-90, ${15-x}, ${t.height/2})`,children:g})]}:{id:(o?`${o}-`:"")+"axes",className:"ordinal-axes",children:[
323
- /* @__PURE__ */Dw("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:c.border,strokeWidth:1}),k.map((e,i)=>/* @__PURE__ */Ow("g",{transform:`translate(${e.pixel},${t.height})`,children:[
324
- /* @__PURE__ */Dw("line",{y2:5,stroke:c.border,strokeWidth:1}),
325
- /* @__PURE__ */Dw("text",{y:18,textAnchor:"middle",fontSize:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:e.label})]},`oxtick-${i}`)),g&&/* @__PURE__ */Dw("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,children:g}),
326
- /* @__PURE__ */Dw("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:c.border,strokeWidth:1}),b.map((e,t)=>/* @__PURE__ */Ow("g",{transform:`translate(0,${e.pixel})`,children:[
327
- /* @__PURE__ */Dw("line",{x2:-5,stroke:c.border,strokeWidth:1}),Ru(e.label)?/* @__PURE__ */Dw("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:e.label}):Tu({label:e.label,x:-68,y:-12,textAlign:"right",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},`oytick-${t}`)),p&&/* @__PURE__ */Dw("text",{x:15-x,y:t.height/2,textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,transform:`rotate(-90, ${15-x}, ${t.height/2})`,children:p})]})}function Ww(e,t){let i=hr(e.theme),r=hd,o=e.size||[500,400],n=it({...r,...e.margin},e.title),a=et(e.title),s=li(e.data),l=e.showLegend?Hl(s,e.colorAccessor||e.stackBy||e.groupBy):[],c=ft({showAxes:e.showAxes,projection:e.projection,hasCategoryLabel:!(!e.categoryLabel&&!e.oLabel),hasValueLabel:!(!e.valueLabel&&!e.rLabel)});Uu(n,{props:{...e,axisChrome:c},categories:l,theme:i,size:o,hasTitle:a});let u=Zu({props:{...e,axisChrome:c},categories:l,theme:i,size:o,margin:n,hasTitle:a}),d=Math.max(1,o[0]-n.left-n.right),h=Math.max(1,o[1]-n.top-n.bottom),f=e.projection||"vertical",p="radial"===f,g=e.colorScheme||i.colors.categorical,m={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:f,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,axisExtent:e.axisExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,gradientFill:Ji(e.gradientFill),symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:g,themeCategorical:i.colors.categorical,themeSemantic:B(i),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:n,layoutSelection:e.layoutSelection,barColors:e.barColors},y=new pw(m);e.data&&y.ingest({inserts:s,bounded:!0}),y.computeScene({width:d,height:h});let x=dd(e.backgroundGraphics,o,n,y.scales),b=dd(e.foregroundGraphics,o,n,y.scales);if(!y.scales){let r,a=e.annotations?pu({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{},layout:{width:d,height:h},theme:i,projection:f,idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;t&&(t.evidence=_s({frameType:"ordinal",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:r,extraWarnings:y.scales?[]:["NO_SCALES"],margin:n}));let l=x||b||e.annotations?/* @__PURE__ */Ow(Ew,{children:[x,a,b,y.customLayoutOverlays]}):null;return Tv.renderToStaticMarkup(Ku(l,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?` ${e.className}`:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:d,innerHeight:h,legend:u,idPrefix:e._idPrefix}))}let v=e._idPrefix,w=e.showGrid?Qu(y,{width:d,height:h},i,v,e.axisExtent,e.rTickValues):null,k=null;if(y.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){let t=Gu(e),i=/* @__PURE__ */new Set;for(let e of y.scene)if("rect"===e.type&&e.datum?.__barFunnelIsDropoff){let t="string"==typeof e.style.fill?e.style.fill:"#666";i.add(t)}k=Array.from(i).map((e,i)=>Fw({...zw,id:`funnel-hatch-${t}-${i}`,background:e}));let r=/* @__PURE__ */new Map;Array.from(i).forEach((e,i)=>r.set(e,`funnel-hatch-${t}-${i}`));for(let e of y.scene)if("rect"===e.type&&e.datum?.__barFunnelIsDropoff){let t="string"==typeof e.style.fill?e.style.fill:"#666";e.style={...e.style,fill:`url(#${r.get(t)})`}}}let A,S=Nw({nodes:y.scene,renderMode:e.renderMode,idPrefix:v}),M=S.map(e=>e.element),$=!1!==e.showAxes?jw(y,{width:d,height:h},e,i,v,n,c,!!u):null,_=e.categoryAccessor??e.oAccessor??"category",L=e.valueAccessor??e.rAccessor??"value",P="horizontal"===f,I=gw(P?L:_,void 0,"__semiotic_resolvedO",""),R=gw(P?_:L,void 0,"__semiotic_resolvedR",""),T=e.annotations?pu({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:mw(I,R,e.annotations.length>0)(s),scales:{o:y.scales.o,r:y.scales.r,y:"vertical"===y.scales.projection?y.scales.r:void 0},layout:{width:d,height:h},theme:i,projection:f,xAccessor:I.key,yAccessor:R.key,idPrefix:v,onRender:e=>{A=e}}):null;if(t){let i=y.scales.o?.domain?.();t.evidence=_s({frameType:"ordinal",width:o[0],height:o[1],marks:S.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:A,yDomain:$s(y.scales.r?.domain?.()),categories:Array.isArray(i)?i.map(String):void 0,margin:n})}let C=p&&e.centerContent?Rv(e.centerContent,n.left+d/2,n.top+h/2):null,N=p&&e.centerContent?C??/* @__PURE__ */Dw("foreignObject",{x:n.left,y:n.top,width:d,height:h,pointerEvents:"none",children:/* @__PURE__ */Dw("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null,F=/* @__PURE__ */Ow(Ew,{children:[w,M,$,T,b,y.customLayoutOverlays]}),z=/* @__PURE__ */Ow(Ew,p?{children:[x?/* @__PURE__ */Dw("g",{transform:`translate(${-d/2},${-h/2})`,children:x}):null,F]}:{children:[x,F]});return Tv.renderToStaticMarkup(Ku(z,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?` ${e.className}`:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:p?`translate(${n.left+d/2},${n.top+h/2})`:`translate(${n.left},${n.top})`,innerWidth:d,innerHeight:h,legend:u,defs:k,outerElements:N,idPrefix:e._idPrefix}))}function Bw({nodes:e,edges:t,restyle:i,restyleEdge:r,baseStyles:o,selection:n}){let a=!(!i&&!r);if(i)for(let t of e){let e=o.get(t)??t.style,r=i(t,n);t.style=r?{...e,...r}:e}if(r)for(let e of t){let t=o.get(e)??e.style,i=r(e,n);e.style=i?{...t,...i}:t}return a}import*as Yw from"react-dom/server";var Gw=/* @__PURE__ */Object.create(null);function Xw(e,t){Gw[e]=t}function Vw(e){return Gw[e]}function qw(e,t){var i=e.get(t);if(!i)throw new Error("missing: "+t);return i}function Hw(e,t,i){let r=e.length,o=Array.from({length:r},()=>[]),n=Array.from({length:r},()=>[]),a=new Int32Array(r),s=new Int32Array(r),l=new Float64Array(r),c=new Float64Array(t.length),u=new Int32Array(r),d=e.map(e=>{let t=i(e);return`${typeof t}:${String(t)}`}),h=0;for(let e of t)e.source.index!==e.target.index&&Number.isFinite(e.value)&&(h=Math.max(h,e.value));let f=(e,t)=>d[e]<d[t]?-1:d[e]>d[t]?1:0;t.map((e,t)=>t).sort((e,i)=>f(t[e].source.index,t[i].source.index)||f(t[e].target.index,t[i].target.index)||t[e].value-t[i].value).forEach(e=>{let i=t[e],r=i.source.index,u=i.target.index;if(r===u)return;let d=Number.isFinite(i.value)&&h>0?Math.max(0,i.value)/h:0;c[e]=d,n[r].push(e),o[u].push(e),s[r]++,a[u]++,l[r]+=d,l[u]-=d});let p=e.map(e=>e.index),g=Int32Array.from(p),m=e=>0===s[e]?2:0===a[e]?1:0,y=(e,t)=>{let i=m(e),r=m(t);return i!==r?i>r:0===i&&l[e]!==l[t]?l[e]>l[t]:d[e]<d[t]||d[e]===d[t]&&e<t},x=(e,t)=>{let i=p[e];p[e]=p[t],p[t]=i,g[p[e]]=e,g[i]=t},b=(e,t=!1)=>{let i=g[e];for(;!t&&i>0;){let t=i-1>>>1;if(!y(e,p[t]))break;x(i,t),i=t}for(;2*i+1<p.length;){let t=2*i+1;if(t+1<p.length&&y(p[t+1],p[t])&&t++,!y(p[t],e))break;x(i,t),i=t}};for(let e=(p.length>>>1)-1;e>=0;e--)b(p[e],!0);let v=0,w=r-1;for(;p.length;){let e=p[0];u[e]=0===s[e]?w--:v++;let i=p.pop();g[e]=-1,p.length&&(p[0]=i,g[i]=0,b(i));for(let i of n[e]){let e=t[i].target.index;g[e]<0||(a[e]--,l[e]+=c[i],b(e))}for(let i of o[e]){let e=t[i].source.index;g[e]<0||(s[e]--,l[e]-=c[i],b(e))}}return u}function Uw(e){return e.y0-e.y1>0?"up":"down"}function Zw(e,t){return t(e.source)==t(e.target)}function Qw(e){return e.target.x0-e.source.x1}function Kw(e,t){var i=ek(e),r=Qw(t)/Math.tan(i);return"up"==Uw(e)?e.y1-r:e.y1+r}function Jw(e,t){var i=ek(e),r=Qw(t)/Math.tan(i);return"up"==Uw(e)?e.y1+r:e.y1-r}function ek(e){var t=Math.abs(e.y1-e.y0),i=Math.abs(e.target.x0-e.source.x1);return Math.atan(i/t)}function tk(e){return rk(e.source)}function ik(e){return rk(e.target)}function rk(e){return(e.y0+e.y1)/2}function ok(e){return e.virtual?0:e.value}function nk(e,t){var i=0;e.sourceLinks.forEach(function(e){i=e.circular&&!Zw(e,t)?i+1:i});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!Zw(e,t)?r+1:r}),i+r}function ak(e){return e.target.depth}function sk(e,t){return e.sourceLinks.length?e.depth:t-1}function lk(e,t){return e.y0-t.y0}function ck(e,t){return t.y0-e.y0}function uk(e,t){return e.y1-t.y1}function dk(e,t){return t.y1-e.y1}function hk(e,t){return pk(e.source,t.source)||e.index-t.index}function fk(e,t){return pk(e.target,t.target)||e.index-t.index}function pk(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function gk(e,t){return mk(e)==mk(t)?"bottom"==e.circularLinkType?ck(e,t):lk(e,t):mk(t)-mk(e)}function mk(e){return e.target.column-e.source.column}function yk(e,t){let i=e;return i.nodes.forEach(function(e){e.y+(e.y1-e.y0)>i.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-i.y1));var t=e.sourceLinks.slice().sort(function(e,t){return e.index-t.index});t.length>1&&t.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!bk(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var i=Kw(t,e);return e.y1-i}if(t.target.column>e.target.column)return Kw(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var r=e.y0;t.forEach(function(e){e.y0=r+e.width/2,r+=e.width});for(var o=0,n=t.length-1;n>=0;n--){var a=t[n];"bottom"==a.circularLinkType&&(a.y0=e.y1-o-a.width/2),o+=a.width}}),i}function xk(e,t){let i=e;return i.nodes.forEach(function(e){var t=e.targetLinks.slice().sort(function(e,t){return e.index-t.index});t.length>1&&t.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!bk(e,t))return e.y0-t.y0;if(t.source.column<e.source.column){var i=Jw(t,e);return e.y0-i}if(e.source.column<t.source.column)return Jw(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;t.forEach(function(e){e.y1=i+e.width/2,i+=e.width});for(var r=0,o=t.length-1;o>=0;o--){var n=t[o];"bottom"==n.circularLinkType&&(n.y1=e.y1-r-n.width/2),r+=n.width}}),i}function bk(e,t){return vk(e)==vk(t)}function vk(e){return e.y0-e.y1>0?"up":"down"}import{min as wk}from"d3-array";var kk=class{constructor(e){this.size=e,this.maximum=new Float64Array(4*e),this.floor=new Float64Array(4*e)}query(e,t){let i=(r,o,n)=>{if(e<=o&&n<=t)return this.maximum[r];let a=o+n>>>1;return Math.max(this.floor[r],e<=a?i(2*r,o,a):0,t>a?i(2*r+1,a+1,n):0)};return i(1,0,this.size-1)}reserve(e,t,i){let r=(o,n,a)=>{if(this.maximum[o]=Math.max(this.maximum[o],i),e<=n&&a<=t)return void(this.floor[o]=Math.max(this.floor[o],i));let s=n+a>>>1;e<=s&&r(2*o,n,s),t>s&&r(2*o+1,s+1,a)};r(1,0,this.size-1)}};function Ak(e){var t=e.source.x1,i=e.y0,r=e.target.x0,o=e.y1,n=(t+r)/2;return"M"+t+","+i+"C"+n+","+i+" "+n+","+o+" "+r+","+o}function Sk(e,t,i,r,o){let n=e;n.links.forEach(function(e){e.circular&&(e._circularWidth=e.width,e._circularStub=!1)});var a=wk(n.links,function(e){return e.source.y0});n.links.forEach(function(e){e.circular&&(e.circularPathData={})});var s=n.links.filter(function(e){return e.circular}),l=/* @__PURE__ */new Map,c=/* @__PURE__ */new Map;s.forEach(function(e){l.set(e.source,(l.get(e.source)||0)+1),c.set(e.target,(c.get(e.target)||0)+1)});var u=new Set(s.filter(function(e){return Zw(e,t)&&1===l.get(e.source)&&1===c.get(e.target)}));return["top","bottom"].forEach(function(e){var t=s.filter(function(t){return t.circularLinkType===e});Mk(t.slice(),u,i),["source","target"].forEach(function(o){var n=/* @__PURE__ */new Map;t.forEach(function(e){var t=e[o].column;n.has(t)||n.set(t,[]),n.get(t).push(e)}),n.forEach(function(t){t.sort("source"===o?"bottom"===e?ck:lk:"bottom"===e?dk:uk);var n=0,a="source"===o?"right":"left";t.forEach(function(e,t){e.circularPathData[a+"SmallArcRadius"]=r+e._circularWidth/2+n,e.circularPathData[a+"LargeArcRadius"]=r+e._circularWidth/2+t*i+n,n+=e._circularWidth})})})}),n.links.forEach(function(e){e.circular&&(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,u.has(e)?(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)):"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(n.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius),e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer),e.circular?e.path=$k(e):e.path=Ak(e)}),n}function Mk(e,t,i){if(0!==e.length){e.sort(gk);var r=Array.from(new Set(e.flatMap(function(e){return[e.source.column,e.target.column]}))).sort(function(e,t){return e-t}),o=new Map(r.map(function(e,t){return[e,t]})),n=new kk(r.length);e.forEach(function(e){var r=o.get(e.source.column),a=o.get(e.target.column),s=Math.min(r,a),l=Math.max(r,a),c=t.has(e)?0:n.query(s,l);e.circularPathData.verticalBuffer=c+e._circularWidth/2,n.reserve(s,l,c+e._circularWidth+i)})}}function $k(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}import{min as _k,max as Lk,sum as Pk,mean as Ik,group as Rk,groups as Tk}from"d3-array";function Ck(e){return function(){return e}}function Nk(e){return e.index}function Fk(e){return e.nodes}function zk(e){return e.links}function Ek(e,t){var i=/* @__PURE__ */new Map;return Rk(e,t).forEach(function(e,t){i.set(t,e[0])}),i}function Dk(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var i=Ek(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=qw(i,r)),"object"!=typeof o&&(o=e.target=qw(i,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}function Ok(e,t,i){var r=0,o=null==t?Hw(e.nodes,e.links,i):null;e.nodes.forEach(function(e){delete e.circularLinkType}),e.links.forEach(function(e){delete e.circularLinkID,delete e.circularLinkType,delete e.circularPathData,delete e._circularWidth,delete e._circularStub,e.circular=o?o[e.source.index]>=o[e.target.index]:!(t(e.source)<t(e.target)),e.circular&&(e.circularLinkID=r++)})}function jk(e,t){var i=0,r=0;e.links.forEach(function(e){e.circular&&(e.source.circularLinkType||e.target.circularLinkType?e.circularLinkType=e.source.circularLinkType?e.source.circularLinkType:e.target.circularLinkType:e.circularLinkType=i<r?"top":"bottom","top"==e.circularLinkType?i++:r++,e.source.circularLinkType=e.circularLinkType,e.target.circularLinkType=e.circularLinkType)}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Zw(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}function Wk(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(Pk(e.sourceLinks,ok),Pk(e.targetLinks,ok)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}function Bk(e,t,i){if(null!=t&&e.nodes.length){e.nodes.sort(function(e,i){return t(e)<t(i)?-1:1});var r=0,o=t(e.nodes[0]);e.nodes.forEach(function(e){r=t(e)==o?r:r+1,o=t(e)==o?o:t(e),e.column=r})}var n=new Int32Array(e.nodes.length),a=[],s=1;e.nodes.forEach(function(e){e.depth=e.height=0,e.targetLinks.forEach(function(t){t.circular||n[e.index]++}),0===n[e.index]&&a.push(e)});for(var l=0;l<a.length;l++){var c=a[l];s=Math.max(s,c.depth+1),c.sourceLinks.forEach(function(e){e.circular||(e.target.depth=Math.max(e.target.depth,c.depth+1),0===--n[e.target.index]&&a.push(e.target))})}for(l=a.length-1;l>=0;l--)(c=a[l]).sourceLinks.forEach(function(e){e.circular||(c.height=Math.max(c.height,e.target.height+1))});e.nodes.forEach(function(e){e.column=null==t?i(e,s):e.column})}function Yk(e,t,i){var r=Tk(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=_k(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/Pk(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var n=Lk(e.nodes,function(e){return e.column});n>0?e.nodes.forEach(function(t){t.x0=e.x0+t.column*((e.x1-e.x0-i)/n),t.x1=t.x0+i}):e.nodes.forEach(function(t){t.x0=e.x0,t.x1=t.x0+i})}function Gk(e){var t=0,i=0;return e.targetLinks.forEach(function(e){if(!e.circular){var r=e.value||1;i+=rk(e.source)*r,t+=r}}),e.sourceLinks.forEach(function(e){if(!e.circular){var r=e.value||1;i+=rk(e.target)*r,t+=r}}),t>0?i/t:NaN}function Xk(e,t,i){var r=Tk(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,n){var a=o.length;if(t)o.sort(t);else if(n>0){var s=/* @__PURE__ */new Map;o.forEach(function(e,t){var i=Gk(e);s.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var i=s.get(e),r=s.get(t),o=i.bc,n=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType||"bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(n)?isNaN(o)?isNaN(n)?i.idx-r.idx:1:-1:o-n})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?nk(t,i)-nk(e,i):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==nk(t,i)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+o,t.y1=t.y0+t.value*e.ky)})})}function Vk(e,t,i,r,o,n){var a=Tk(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var s=1,l=n;l>0;--l)c(s*=.99,i),u();function c(t,i){var r=a.length;a.forEach(function(o){var n=o.length,a=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&nk(o,i)>0){var l=Ik(o.sourceLinks,ik),c=Ik(o.targetLinks,tk),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-rk(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==a&&1==n)s=o.y1-o.y0,o.y0=e.y1/2-s/2,o.y1=e.y1/2+s/2;else if(a==r-1&&1==n)s=o.y1-o.y0,o.y0=e.y1/2-s/2,o.y1=e.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var h=Ik(o.sourceLinks,ik),f=Ik(o.targetLinks,tk),p=((h&&f?(h+f)/2:h||f)-rk(o))*t;o.y0+=p,o.y1+=p}})})}function u(){a.forEach(function(i){var n,a,s,l=e.y0,c=i.length;for(t?i.sort(t):i.sort(pk),s=0;s<c;++s)(a=l-(n=i[s]).y0)>0&&(n.y0+=a,n.y1+=a),l=n.y1+r;if((a=l-r-e.y1)>0)for(l=n.y0-=a,n.y1-=a,s=c-2;s>=0;--s)(a=(n=i[s]).y1+o-l)>0&&(n.y0-=a,n.y1-=a),l=n.y0})}}function qk(e){e.nodes.forEach(function(e){e.sourceLinks.sort(fk),e.targetLinks.sort(hk)}),e.nodes.forEach(function(e){var t=e.y0,i=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=i+e.width/2,i+=e.width)})})}function Hk(e){var t=e.nodes,i=e.links,r=!1,o=!1;if(i.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-n)/(a-n)*(e.y1-e.y0)+e.y0};var n=_k(t,function(e){return e.y0}),a=Lk(t,function(e){return e.y1}),s=a-n,l=(e.y1-e.y0)/s;l<1?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),i.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,i=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+i}),e.targetLinks.forEach(function(e){e.y1=e.y1+i})})}}function Uk(){var e=0,t=0,i=1,r=1,o=24,n=8,a=null,s=Nk,l=sk,c=void 0,u=32,d=2,h=Fk,f=zk;function p(){var e={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return g(e),e}function g(h){h.x0=e,h.y0=t,h.x1=i,h.y1=r,h.py=0,Dk(h,s),Ok(h,c,s),jk(h,s),Wk(h),Bk(h,c,l);var f=n;if(null!==a){var p=Tk(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),g=Lk(p,function(e){return e.length});g>1&&(f=Math.max(1,(r-t)*a/(g-1)))}Yk(h,f,o),Xk(h,c,s),Vk(h,c,s,f,f,u),qk(h),Xk(h,c,s),Vk(h,c,s,f,f,u),qk(h),yk(h),xk(h),Hk(h),Sk(h,s,d,10,8)}return p.update=function(e){return qk(e),Sk(e,s,d,10,8),e},p.nodeWidth=function(e){return arguments.length?(o=+e,p):o},p.nodePadding=function(e){return arguments.length?(n=+e,p):n},p.nodePaddingRatio=function(e){return arguments.length?(a=+e,p):a},p.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Ck(e),p):h},p.links=function(e){return arguments.length?(f="function"==typeof e?e:Ck(e),p):f},p.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:Ck(e),p):s},p.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:Ck(e),p):l},p.nodeSort=function(e){return arguments.length?(c=e,p):c},p.iterations=function(e){return arguments.length?(u=+e,p):u},p.circularLinkGap=function(e){return arguments.length?(d=+e,p):d},p.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],i=+o[1][0],r=+o[1][1],p):[[e,t],[i,r]]},p.size=function(o){return arguments.length?(e=t=0,i=+o[0],r=+o[1],p):[i-e,r-t]},p}import{interpolateNumber as Zk}from"d3-interpolate";var Qk=e=>{let{source:t,target:i}=e;if("string"==typeof t||"string"==typeof i)return null;if("down"===e.direction){let r=e.y0-e.sankeyWidth/2,o=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,a=e.y0+e.sankeyWidth/2,s=t.x1,l=i.x0,c=Zk(s,l),u=c(.5),d=c(.5);return`M${r},${s}C${r},${u} ${o},${d} ${o},${l}L${n},${l}C${n},${d} ${a},${u} ${a},${s}Z`}let r=e.sankeyWidth/2,o=Zk(t.x1,i.x0),{pathD:n}=Sb({sx:t.x1,sTop:e.y0-r,sBot:e.y0+r,tx:i.x0,tTop:e.y1-r,tBot:e.y1+r,cp1X:o(.5),cp2X:o(.5)});return n};function Kk(e){let t=e.circularPathData;if(!t)return null;let i=e.sankeyWidth/2,r="bottom"===e.circularLinkType?1:-1,o=1===r?1:0,n="down"===e.direction,a=(e,t)=>n?`${t},${e}`:`${e},${t}`,s=(e,t,i,r,o)=>`A${n?t:e},${n?e:t} 0 0 ${n?1-i:i} ${a(r,o)}`,{sourceX:l,sourceY:c,targetX:u,targetY:d,rightInnerExtent:h,leftInnerExtent:f,rightFullExtent:p,leftFullExtent:g,verticalFullExtent:m,verticalRightInnerExtent:y,verticalLeftInnerExtent:x,rightLargeArcRadius:b,rightSmallArcRadius:v,leftLargeArcRadius:w,leftSmallArcRadius:k}=t;return`M${a(l,c-r*i)}L${a(h,c-r*i)}`+s(b+i,v+i,o,p+i,c+r*v)+`L${a(p+i,y)}`+s(b+i,b+i,o,h,m+r*i)+`L${a(f,m+r*i)}`+s(w+i,w+i,o,g-i,x)+`L${a(g-i,d+r*k)}`+s(w+i,k+i,o,f,d-r*i)+`L${a(u,d-r*i)}L${a(u,d+r*i)}L${a(f,d+r*i)}`+s(w-i,k-i,1-o,g+i,d+r*k)+`L${a(g+i,x)}`+s(w-i,w-i,1-o,f,m-r*i)+`L${a(h,m-r*i)}`+s(b-i,b-i,1-o,p-i,y)+`L${a(p-i,c+r*v)}`+s(b-i,v-i,1-o,h,c+r*i)+`L${a(l,c+r*i)}Z`}var Jk=/* @__PURE__ */new Set,eA=/* @__PURE__ */new WeakMap;function tA(e,t){if("production"===process.env.NODE_ENV||!e||!e.data||"object"!=typeof e.data)return e;let i=eA.get(e);if(i){let e=i.get(t);if(e)return e}else i=/* @__PURE__ */new Map,eA.set(e,i);let r=new Proxy(e,{get(e,i,r){if("string"==typeof i&&!(i in e)&&e.data&&i in e.data){let e=`${t}:${i}`;Jk.has(e)||(Jk.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,i,r)}});return i.set(t,r),r}var iA={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(ak))-1:0},justify:sk},rA={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,r){let o="vertical"===i.orientation?"down":"right",n=i.nodeAlign||"justify",a=i.nodeWidth??15,s=i.nodePaddingRatio??.05,l=i.iterations??300;for(let e of t)e.sankeyWidth=0,e.circular=!1,delete e.circularPathData,delete e._circularWidth,delete e._circularStub;for(let t of e)t.value=0,t.width=t.height=0,t.x0=t.x1=t.y0=t.y1=0,t.sourceLinks=[],t.targetLinks=[];let c=new Set(e.map(e=>e.id)),u=/* @__PURE__ */new Set,d=t.filter(e=>{let t=w(e.source),i=w(e.target);return!(!Number.isFinite(e.value)||e.value<=0||!c.has(t)||!c.has(i)||(u.add(t),u.add(i),0))}).map(e=>({...e,source:w(e.source),target:w(e.target)}));if(0===d.length)return;let h,f=e.filter(e=>u.has(e.id)).map(e=>({...e}));h="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];let p=Uk().extent(h).links(d).nodes(f).nodeAlign(iA[n]||sk).nodeId(e=>e.id).nodeWidth(a).iterations(l);p.nodePaddingRatio&&p.nodePaddingRatio(s),p();{let e=1/0,t=-1/0,i=1/0,r=-1/0;for(let o of f)o.x0<e&&(e=o.x0),o.x1>t&&(t=o.x1),o.y0<i&&(i=o.y0),o.y1>r&&(r=o.y1);for(let o of d){if(!o.circular||!o.circularPathData)continue;let n=o.circularPathData,a=(o._circularWidth??o.width??0)/2;n.leftFullExtent-a<e&&(e=n.leftFullExtent-a),n.rightFullExtent+a>t&&(t=n.rightFullExtent+a),n.verticalFullExtent-a<i&&(i=n.verticalFullExtent-a),n.verticalFullExtent+a>r&&(r=n.verticalFullExtent+a)}let o=t-e,n=r-i,a=h[1][0],s=h[1][1];if(o>0&&n>0&&(e<0||i<0||t>a||r>s)){let t=a/o,r=s/n,l=Math.min(t,r),c=-e*l+(a-o*l)/2,u=-i*l+(s-n*l)/2;for(let e of f)e.x0=e.x0*l+c,e.x1=e.x1*l+c,e.y0=e.y0*l+u,e.y1=e.y1*l+u;for(let e of d)if(e.y0=e.y0*l+u,e.y1=e.y1*l+u,e.width=(e.width??0)*l,e._circularWidth&&(e._circularWidth*=l),e.circular&&e.circularPathData){let t=e.circularPathData;t.sourceX=t.sourceX*l+c,t.targetX=t.targetX*l+c,t.sourceY=t.sourceY*l+u,t.targetY=t.targetY*l+u,t.rightFullExtent=t.rightFullExtent*l+c,t.leftFullExtent=t.leftFullExtent*l+c,t.verticalFullExtent=t.verticalFullExtent*l+u,t.rightInnerExtent=t.rightInnerExtent*l+c,t.leftInnerExtent=t.leftInnerExtent*l+c,t.verticalRightInnerExtent=t.verticalRightInnerExtent*l+u,t.verticalLeftInnerExtent=t.verticalLeftInnerExtent*l+u,t.rightSmallArcRadius*=l,t.rightLargeArcRadius*=l,t.leftSmallArcRadius*=l,t.leftLargeArcRadius*=l,t.sourceWidth*=l,t.rightNodeBuffer*=l,t.leftNodeBuffer*=l,t.arcRadius*=l}}}let g=/* @__PURE__ */new Map;for(let t of e)g.set(t.id,t);for(let e of f){let t=g.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}let m=/* @__PURE__ */new Map;for(let e of t)if(e._edgeKey)m.set(e._edgeKey,e);else{let t=w(e.source),i=w(e.target);m.set(`${t}\0${i}`,e)}for(let e of d){let t=w(e.source),i=w(e.target),r=e._edgeKey?m.get(e._edgeKey):m.get(`${t}\0${i}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=o;let n=g.get(t),a=g.get(i);n&&(r.source=n),a&&(r.target=a)}}},buildScene(e,t,i,r){let o="vertical"===i.orientation?"down":"right",n=i.nodeStyle,a=i.edgeStyle,s=i.edgeOpacity??.5,l=i.edgeColorBy||"source",c=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:fi,u=/* @__PURE__ */new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});let d=[],h=[],f=[],p=/* @__PURE__ */new Map;for(let t of e){let e=t.x1-t.x0,i=t.y1-t.y0;if(t.value<=0||e<=0||i<=0)continue;let r=n?n(tA(t,"nodeStyle")):{},a={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity,cursor:r.cursor};p.set(t.id,("string"==typeof a.fill?a.fill:null)||u.get(t.id)||"#4d430c"),"down"===o?d.push({type:"rect",x:t.y0,y:t.x0,w:i,h:e,style:a,datum:t,id:t.id,label:t.id}):d.push({type:"rect",x:t.x0,y:t.y0,w:e,h:i,style:a,datum:t,id:t.id,label:t.id})}let g=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(let e of g){if(!(e.value>0)||!e.sankeyWidth||e.sankeyWidth<=0)continue;let t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";o="function"==typeof l?l(e)||o:"target"===l?p.get(r.id)||u.get(r.id)||o:p.get(t.id)||u.get(t.id)||o;let n,c=a?a(tA(e,"edgeStyle")):{};if(n=e.circular&&e.circularPathData?Kk(e):Qk(e),!n)continue;let d={fill:c.fill||o,fillOpacity:c.fillOpacity??s,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,strokeOpacity:c.strokeOpacity,opacity:c.opacity,cursor:c.cursor};h.push({type:"bezier",pathD:n,bezierCache:e.bezier,style:d,datum:e})}if(!1!==i.showLabels){let t=v(i.nodeLabel);for(let i of e){let e=i.x1-i.x0,n=i.y1-i.y0;if(i.value<=0||e<=0||n<=0)continue;let a,s,l,c=t?t(i):i.id;if(c){if("down"===o)a=i.y0+(i.y1-i.y0)/2,s=i.x1+14,l="start";else{let t=r[0]/2;i.x0+e/2<t?(a=i.x0-6,l="end"):(a=i.x1+6,l="start"),s=i.y0+n/2}f.push({x:a,y:s,text:String(c),anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11})}}}return{sceneNodes:d,sceneEdges:h,labels:f}}};import{forceSimulation as oA,forceCenter as nA,forceX as aA,forceY as sA,forceLink as lA,forceManyBody as cA,forceCollide as uA}from"d3-force";function dA(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}var hA={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let o=i.forceStrength??.1,n=r[0]/2,a=r[1]/2,s=Math.max(.1,Math.min(1,Math.min(r[0],r[1])/200)),l=Math.min(.5,.06+1.8*(1-s)),c=i.__previousPositions,u=0,d=[];for(let t of e){let e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),i=c?.get(t.id);e?u++:i?(t.x=i.x,t.y=i.y,u++):d.push(t)}let h=e.length>0?d.length/e.length:1,f=u>0&&h<=.3;if(f){let i=/* @__PURE__ */new Map;for(let t of e)i.set(t.id,t);for(let e of d){let r=fA(e.id,t,i);if(r.length>0){let t=0,i=0;for(let e of r)t+=e.x,i+=e.y;let o=gA(e.id),n=o%360*(Math.PI/180),a=(10+o%20)*s;e.x=t/r.length+a*Math.cos(n),e.y=i/r.length+a*Math.sin(n)}else{let t=gA(e.id),i=t%360*(Math.PI/180),r=(15+t%30)*s;e.x=n+r*Math.cos(i),e.y=a+r*Math.sin(i)}}}else{let t=Math.PI*(3-Math.sqrt(5));for(let i=0;i<e.length;i++){let r=e[i];if(null==r.x||null==r.y||0===r.x&&0===r.y){let e=10*Math.sqrt(i+.5)*s,o=i*t;r.x=n+e*Math.cos(o),r.y=a+e*Math.sin(o)}}}let p=e.length,g=i.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(p-30)))),m=i.__skipForceSimulation||0===i.iterations?0:f?40:g,y=Ee(i.nodeSize,i.nodeSizeRange,e),x=e=>y(e);if(m>0){let c=/* @__PURE__ */new Map,u=/* @__PURE__ */new Map;for(let t of e)c.set(t.id,0),u.set(t.id,t);for(let e of t){let t=w(e.source),i=w(e.target);c.set(t,(c.get(t)??0)+1),c.set(i,(c.get(i)??0)+1)}let d=lA().strength(e=>{let t=De(e),i=w(e.source),r=w(e.target),n=Math.max(1,Math.min(c.get(i)??1,c.get(r)??1)),a=t&&t>0?Math.sqrt(t):1;return Math.min(2.5,a*o/(.1*n))}).distance(e=>{let t="string"==typeof e.source?u.get(e.source):e.source,i="string"==typeof e.target?u.get(e.target):e.target,r=(t?x(t):0)+(i?x(i):0)+Math.max(6,12*s);return Math.max(16,40*s,r)}).id(e=>e.id),h=oA();if((void 0!==i.random||void 0!==i.seed)&&h.randomSource(i.random??dA(i.seed)),h.force("charge",cA().strength(e=>{let t=c.get(e.id)??0;return-15*s*x(e)*Math.sqrt(t+1)})).force("collide",uA(e=>x(e)+3*s).strength(.9).iterations(2)).force("center",nA(n,a).strength(.8)).force("x",aA(n).strength(l)).force("y",sA(a).strength(l)).force("bounds",pA(r,x)),h.nodes(e),t.length>0){let e=t.map(e=>({...e,source:w(e.source),target:w(e.target)}));d.links(e),h.force("link",d)}f?h.alpha(.3):h.alpha()<.1&&h.alpha(1),h.stop();for(let e=0;e<m;++e)h.tick()}for(let t of e){if(null==t.x||null==t.y)continue;let e=x(t),i=m>0?2:0,o=Math.min(r[0]/2,e+i),n=Math.min(r[1]/2,e+i);t.x=Math.max(o,Math.min(r[0]-o,t.x)),t.y=Math.max(n,Math.min(r[1]-n,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}let b=/* @__PURE__ */new Map;for(let t of e)b.set(t.id,t);for(let e of t){if("string"==typeof e.source){let t=b.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){let t=b.get(e.target);t&&(e.target=t)}}},buildScene(e,t,i,r){let o=i.nodeStyle,n=i.edgeStyle,a=Ee(i.nodeSize,i.nodeSizeRange,e),s=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:fi,l=/* @__PURE__ */new Map;e.forEach((e,t)=>{l.set(e.id,s[t%s.length])});let c=[],u=[],d=[];for(let t of e){if(null==t.x||null==t.y)continue;let e=a(tA(t,"nodeSize")),r=o?o(tA(t,"nodeStyle")):{},n={fill:r.fill||l.get(t.id)||i.themeSemantic?.primary||"#007bff",stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity,cursor:r.cursor};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}let h=/* @__PURE__ */new Map;for(let t of e)h.set(t.id,t);for(let e of t){let t="object"==typeof e.source?e.source:h.get(e.source),r="object"==typeof e.target?e.target:h.get(e.target);if(!t||!r||null==t.x||null==t.y||null==r.x||null==r.y)continue;let o=n?n(tA(e,"edgeStyle")):{},a={stroke:o.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6,cursor:o.cursor};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:a,datum:e})}if(!1!==i.showLabels){let t=v(i.nodeLabel);for(let i of e){if(null==i.x||null==i.y)continue;let e=t?t(i):i.id;if(!e)continue;let r=a(tA(i,"nodeSize"));d.push({x:i.x,y:i.y-r-4,text:String(e),anchor:"middle",baseline:"auto",fontSize:11,anchorPoint:[i.x,i.y]})}}return{sceneNodes:c,sceneEdges:u,labels:d}}};function fA(e,t,i){let r=[];for(let o of t){let t=w(o.source),n=w(o.target),a=null;if(t===e?a=n:n===e&&(a=t),a){let e=i.get(a);e&&(0!==e.x||0!==e.y)&&r.push({x:e.x,y:e.y})}}return r}function pA(e,t,i=2,r=.6){let o=[],n=n=>{let a=r*Math.max(n,.2);for(let r of o){let o=r.x??e[0]/2,n=r.y??e[1]/2,s=r.vx??0,l=r.vy??0,c=t(r)+i,u=Math.min(e[0]/2,c),d=Math.max(e[0]/2,e[0]-c),h=Math.min(e[1]/2,c),f=Math.max(e[1]/2,e[1]-c),p=o+s,g=n+l;p<u?r.vx=s+(u-p)*a:p>d&&(r.vx=s+(d-p)*a),g<h?r.vy=l+(h-g)*a:g>f&&(r.vy=l+(f-g)*a)}};return n.initialize=e=>{o=e},n}function gA(e){let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i)|0;return Math.abs(t)}import{chord as mA,ribbon as yA}from"d3-chord";import{arc as xA}from"d3-shape";var bA=fi,vA={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,i,r){for(let t of e)delete t.__arcData;for(let e of t)delete e.__chordData,delete e.__chordEdges;if(0===e.length)return;let{padAngle:o=.01,groupWidth:n=20,sortGroups:a}=i,s=Math.min(r[0],r[1])/2,l=s-n,c=r[0]/2,u=r[1]/2,d=new Map(e.map(e=>[e.id,e])),h=/* @__PURE__ */new Set,f=t.filter(e=>{let t=w(e.source),i=w(e.target);return!(!Number.isFinite(e.value)||e.value<=0||!d.has(t)||!d.has(i)||(h.add(t),h.add(i),0))}),p=e.filter(e=>h.has(e.id)),g=p.length;if(0===g)return;let m=new Map(p.map((e,t)=>[e.id,t])),y=Array.from({length:g},()=>new Array(g).fill(0)),x=/* @__PURE__ */new Map;for(let e of f){let t=w(e.source),i=w(e.target),r=m.get(t),o=m.get(i);y[r][o]+=e.value;let n=r<=o?`${r}\0${o}`:`${o}\0${r}`,a=x.get(n);a?a.push(e):x.set(n,[e])}let b=Math.min(Number.isFinite(o)?Math.max(0,o):.01,Math.PI/g),v=mA().padAngle(b);a&&v.sortGroups(a);let k=v(y),A=k.groups,S=xA().innerRadius(l).outerRadius(s);for(let e of A){let t=p[e.index],i={innerRadius:l,outerRadius:s,startAngle:e.startAngle,endAngle:e.endAngle},r=S.centroid(i);t.x=r[0]+c,t.y=r[1]+u,t.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}for(let e of t){let t=w(e.source),i=w(e.target),r=d.get(t),o=d.get(i);r&&(e.source=r),o&&(e.target=o)}for(let e of k){let t=e.source.index,i=e.target.index,r=t<=i?`${t}\0${i}`:`${i}\0${t}`,o=x.get(r);for(let t of o)t.__chordData=e,t.__chordEdges=o}},buildScene(e,t,i,r){let{groupWidth:o=20,edgeOpacity:n=.5}=i,a=Math.min(r[0],r[1])/2,s=a-o,l=r[0]/2,c=r[1]/2,u=i.nodeStyle,d=i.edgeStyle,h=i.edgeColorBy||"source",f=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:bA,p=/* @__PURE__ */new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});let g=yA().radius(s),m=[],y=[],x=[];for(let t=0;t<e.length;t++){let i=e[t],r=i.__arcData;if(!r)continue;let o=u?u(tA(i,"nodeStyle")):{},n={fill:("string"==typeof o.fill?o.fill:void 0)||p.get(i.id)||f[t%f.length],stroke:o.stroke||"black",strokeWidth:o.strokeWidth??1,opacity:o.opacity,cursor:o.cursor};m.push({type:"arc",cx:l,cy:c,innerR:s,outerR:a,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:n,datum:i,id:i.id,label:i.id})}let b=/* @__PURE__ */new Set,k=e.filter(e=>e.__arcData);for(let e of t){let t=e.__chordData;if(!t||b.has(t))continue;b.add(t);let r=k[t.source.index].id;for(let t of e.__chordEdges||[])w(t.source)===r&&(e=t);let o=g(t);if(!o)continue;let a=wA(o,l,c),s=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",u=d?d(tA(e,"edgeStyle")):{};if(d)s=("string"==typeof u.fill?u.fill:void 0)||s;else{let t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;"target"===h&&i?s=p.get(i.id)||s:t&&(s=p.get(t.id)||s)}let f={fill:s,fillOpacity:u.fillOpacity??n,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,strokeOpacity:u.strokeOpacity,opacity:u.opacity,cursor:u.cursor};y.push({type:"ribbon",pathD:a,style:f,datum:e})}if(!1!==i.showLabels){let t=v(i.nodeLabel),r=a+12;for(let i of e){let e=i.__arcData;if(!e)continue;let o=t?t(i):i.id;if(!o)continue;let n=(e.startAngle+e.endAngle)/2,a=n-Math.PI/2,s=l+Math.cos(a)*r,u=c+Math.sin(a)*r,d=n>Math.PI?"end":"start";x.push({x:s,y:u,text:String(o),anchor:d,baseline:"middle",fontSize:11})}}return{sceneNodes:m,sceneEdges:y,labels:x}}};function wA(e,t,i){let r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;let o=[],n=0;for(;n<r.length;){let e=r[n];if("M"===e||"L"===e||"C"===e||"Q"===e)for(o.push(e),n++;n<r.length&&!isNaN(Number(r[n]));)o.push(String(Number(r[n])+t)),n++,n<r.length&&!isNaN(Number(r[n]))&&(o.push(String(Number(r[n])+i)),n++);else if("A"===e)for(o.push(e),n++;n<r.length&&!isNaN(Number(r[n]));)o.push(r[n++]),n<r.length&&o.push(r[n++]),n<r.length&&o.push(r[n++]),n<r.length&&o.push(r[n++]),n<r.length&&o.push(r[n++]),n<r.length&&(o.push(String(Number(r[n])+t)),n++),n<r.length&&(o.push(String(Number(r[n])+i)),n++);else"Z"===e||"z"===e?(o.push(e),n++):(o.push(r[n]),n++)}return o.join(" ")}import{hierarchy as kA,tree as AA,cluster as SA,treemap as MA,pack as $A,partition as _A,treemapBinary as LA}from"d3-hierarchy";var PA=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function IA(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[0,2,4].map(e=>parseInt(t.slice(e,e+2),16))}let t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}function RA(e){let[t,i,r]=IA(e);return.299*t+.587*i+.114*r>150?"#222":"#fff"}function TA(e){if(e)return"function"==typeof e?e:t=>t[e]}function CA(e,t,i){let r=t.nodeIDAccessor,o=e.data;return String("function"==typeof r?r(o):"string"==typeof r&&void 0!==o[r]?o[r]:void 0!==o.name?o.name:void 0!==o.id?o.id:`node-${i}`)}function NA(e){if(!e)return null;if("function"==typeof e){let t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function FA(e="value"){let t="function"==typeof e?e:t=>t[e];return e=>{let i=t(e),r="string"==typeof i?Number(i):i;return Number.isFinite(r)&&r>0?r:0}}function zA(e){let t=new Map(e.map(e=>[e,0]));return e.map(e=>{let i=t.get(e),r=e;for(;i>0&&t.has(r);)r=`${e}__${i++}`;return t.set(e,i||1),t.set(r,1),r})}function EA(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:PA}function DA(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function OA(e,t,i){if(t.colorByDepth&&void 0!==e.depth){let i=EA(t);return i[e.depth%i.length]}return i||DA(t)}function jA(e,t,i){return{fill:OA(e,t,i.fill),stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity,cursor:i.cursor}}function WA(e){return!e.__hierarchyNode?.children?.length}function BA(e,t,i,r,o,n){let a=[],s=[],l=[],c=i.treeOrientation||"vertical",u="radial"===c,d=r[0]/2,h=r[1]/2,{nodeSize:f}=i,p="number"==typeof f?f:5;for(let t of e){let e=t.x,r=t.y;u&&(e+=d,r+=h);let n=jA(t,i,o(tA(t,"nodeStyle")));a.push({type:"circle",cx:e,cy:r,r:p,style:n,datum:t,id:t.id,label:t.id,depth:t.depth})}let g=i.edgeOpacity??.5;for(let e of t){let t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,a=t.y,l=r.x,f=r.y;u&&(o+=d,a+=h,l+=d,f+=h);let p=XA(o,a,l,f,c),m=n(tA(e,"edgeStyle")),y={fill:"none",stroke:m.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:m.strokeWidth??1.5,opacity:m.opacity??g,cursor:m.cursor};s.push({type:"curved",pathD:p,style:y,datum:e})}if(!1!==i.showLabels){let t=NA(i.nodeLabel);for(let i of e){let e=t?t(i):i.id;if(!e)continue;let r,o,n,a=i.x,s=i.y;if(u&&(a+=d,s+=h),u){let e=a-d,t=s-h,i=Math.sqrt(e*e+t*t);i>0?(r=a+e/i*10,o=s+t/i*10,n=e>=0?"start":"end"):(r=a,o=s-12,n="middle")}else"horizontal"===c?(WA(i)?(r=a+p+6,n="start"):(r=a-p-6,n="end"),o=s):(r=a,o=s+p+14,n="middle");l.push({x:r,y:o,text:String(e),anchor:n,baseline:"middle",fontSize:11,anchorPoint:[a,s]})}}return{sceneNodes:a,sceneEdges:s,labels:l}}function YA(e,t,i){let r=[],o=[];for(let o of e){let e=o.x1-o.x0,n=o.y1-o.y0;if(e<=0||n<=0)continue;let a=i(tA(o,"nodeStyle")),s=jA(o,t,a);s.fillOpacity=a.fillOpacity,s.strokeOpacity=a.strokeOpacity,r.push({type:"rect",x:o.x0,y:o.y0,w:e,h:n,style:s,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){let r=NA(t.nodeLabel),n=t.labelMode||"leaf",a="partition"===t.chartType;for(let s of e){let e=s.x1-s.x0,l=s.y1-s.y0;if(e<=0||l<=0)continue;let c=WA(s);if(!a&&("leaf"===n&&!c||"parent"===n&&c))continue;let u=r?r(s):s.id;if(!u)continue;if(e<(c?30:40)||l<(c?16:14))continue;let d=OA(s,t,i(tA(s,"nodeStyle")).fill),h="string"==typeof d?RA(d):t.themeSemantic?.text??"#000";c?o.push({x:s.x0+e/2,y:s.y0+l/2,text:String(u),anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:h}):o.push({x:s.x0+4,y:s.y0+12,text:String(u),anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:r,sceneEdges:[],labels:o}}function GA(e,t,i){let r=[],o=[];for(let o of e){let e=o.__radius??5;if(e<=0)continue;let n=jA(o,t,i(tA(o,"nodeStyle")));n.opacity??(n.opacity=.7),r.push({type:"circle",cx:o.x,cy:o.y,r:e,style:n,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){let r=NA(t.nodeLabel);for(let n of e){let e=n.__radius??5,a=r?r(n):n.id;if(!a||e<15)continue;let s=WA(n),l=OA(n,t,i(tA(n,"nodeStyle")).fill);if(s){let i="string"==typeof l?RA(l):t.themeSemantic?.text??"#000";o.push({x:n.x,y:n.y,text:String(a),anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:i})}else o.push({x:n.x,y:n.y-e+14,text:String(a),anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:r,sceneEdges:[],labels:o}}function XA(e,t,i,r,o){let n=(e+i)/2,a=(t+r)/2;return"horizontal"===o?`M ${e},${t} C ${n},${t} ${n},${r} ${i},${r}`:"radial"===o?`M ${e},${t} Q ${n},${t} ${n},${a} T ${i},${r}`:`M ${e},${t} C ${e},${a} ${i},${a} ${i},${r}`}var VA={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,i,r){let o=i.__hierarchyRoot;if(!o)return;let n=i.chartType,a=TA(i.childrenAccessor),s=kA(o,a),l=[];s.eachBefore(e=>l.push(e));let c=zA(l.map((e,t)=>CA(e,i,t)));s.sum(FA(i.hierarchySum)).sort((e,t)=>t.value-e.value);let[u,d]=r;switch(n){case"tree":case"cluster":qA(s,i,u,d);break;case"treemap":case"partition":HA(s,i,u,d);break;case"circlepack":UA(s,i,u,d)}let h=s.descendants();e.length=0,t.length=0;let f=new Map(l.map((e,t)=>[e,{id:c[t],x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,depth:e.depth,data:e.data,createdByFrame:!0}]));for(let t of h){let r=f.get(t);"tree"===n||"cluster"===n?ZA(r,t,i):"treemap"===n||"partition"===n?QA(r,t):"circlepack"===n&&KA(r,t),r.__hierarchyNode=t,e.push(r)}if("tree"===n||"cluster"===n)for(let e of h)if(e.parent){let i=f.get(e.parent),r=f.get(e);t.push({source:i,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,i,r){let o=i.chartType,n=i.nodeStyle||(()=>({})),a=i.edgeStyle||(()=>({}));switch(o){case"tree":case"cluster":return BA(e,t,i,r,n,a);case"treemap":case"partition":return YA(e,i,n);case"circlepack":return GA(e,i,n);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function qA(e,t,i,r){let o=t.treeOrientation||"vertical",n="cluster"===t.chartType?SA():AA();if("horizontal"===o)n.size([r,i]);else if("radial"===o){let e=Math.min(i,r)/2;n.size([2*Math.PI,.8*e])}else n.size([i,r]);n(e)}function HA(e,t,i,r){let o="treemap"===t.chartType,n=o?MA().tile(LA):_A();n.size([i,r]).padding(t.padding??(o?4:1)),"paddingTop"in n&&t.paddingTop>0&&n.paddingTop(t.paddingTop),n(e)}function UA(e,t,i,r){let o=t.padding??4,n=$A().size([i,r]).padding(o);e.leaves().some(e=>e.value)||n.radius(()=>0).padding(0),n(e)}function ZA(e,t,i){let r=i.treeOrientation||"vertical";if("radial"===r){let i=t.x,r=t.y;e.x=r*Math.cos(i-Math.PI/2),e.y=r*Math.sin(i-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);JA(e,5)}function QA(e,t){e.x0=t.x0,e.y0=t.y0,e.x1=e.value?t.x1:t.x0,e.y1=e.value?t.y1:t.y0,e.x=(e.x0+e.x1)/2,e.y=(e.y0+e.y1)/2,e.width=e.x1-e.x0,e.height=e.y1-e.y0}function KA(e,t){let i=t.r??0;e.x=t.x,e.y=t.y,JA(e,i),e.__radius=i}function JA(e,t){e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}import{pie as eS}from"d3-shape";function tS(e){let t=e.__orbitState;return t||(t={metaMap:/* @__PURE__ */new Map,startTime:typeof performance<"u"?performance.now():Date.now()},e.__orbitState=t),t}function iS(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}function rS(e){if("function"==typeof e)return e;let t=e||"name";return e=>String(e[t]??"")}function oS(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{let t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}function nS(e,t,i,r,o){let n=TA(i.childrenAccessor||"children"),a=rS(i.nodeIDAccessor),s=iS(i.orbitMode),l=i.orbitSize??2.95,c=i.orbitEccentricity??1,u="number"==typeof l?()=>l:l,d="number"==typeof c?()=>c:c,h=tS(i);h.metaMap.clear(),r.length=0,o.length=0;let f=zA(nv(e,n).map(e=>String(a(e)))),p=0,g=t[0]/2,m=t[1]/2,y=Math.min(t[0],t[1])/2*.85,x=f[p++],b={id:x,x:g,y:m,x0:g,x1:g,y0:m,y1:m,width:0,height:0,value:0,depth:0,data:e};r.push(b),h.metaMap.set(x,{ring:y,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,i,a,l,c,g,m){let y=n(t);if(!y?.length)return;let x=y.length,b=0,v=0,w=0;for(;v<x;)v+=s[Math.min(w,s.length-1)],w++,b++;let k=0;for(let x=0;x<b;x++){let v=s[Math.min(x,s.length-1)],w=y.slice(k,k+v);if(!w.length)break;let A=(x+1)/b,S={id:i,depth:g,data:t,parentId:i},M=m?c/u(S)*A:c*A,$=eS().value(e=>n(e)?.length?4:1).sort(null)(w),_=d(S);for(let t=0;t<w.length;t++){let n=($[t].startAngle+$[t].endAngle)/2,s=w[t],c=f[p++],u=a+M*Math.sin(n),d=l+M*Math.cos(n)*_,m={id:c,x:u,y:d,x0:u,x1:u,y0:d,y1:d,width:0,height:0,value:0,depth:g,data:s};r.push(m),h.metaMap.set(c,{ring:M,angle:n,depth:g,parentId:i,eccentricity:_}),o.push({source:i,target:c,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:c}}),e(s,c,u,d,M,g+1,!0)}k+=v}}(e,x,g,m,y,1,!1)}function aS(e,t,i,r){let o=tS(t),n=t.orbitSpeed??.25,a=t.orbitRevolution??oS(t.orbitRevolutionStyle),s=((typeof performance<"u"?performance.now():Date.now())-o.startTime)/1e3,l=n*(Math.PI/6),c=/* @__PURE__ */new Map;for(let t of e)c.set(t.id,t);for(let t of e){let e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;let i=c.get(e.parentId);if(!i)continue;let r={id:t.id,depth:e.depth,data:t.data,parentId:e.parentId},n=e.angle+s*l*a(r);t.x=i.x+e.ring*Math.sin(n),t.y=i.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}var sS={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,i,r){let o=i.__hierarchyRoot;o&&nS(o,r,i,e,t)},buildScene(e,t,i,r){let o=i.nodeStyle,n=i.edgeStyle,a=i.nodeSize,s="number"==typeof a?()=>a:"function"==typeof a?a:()=>6,l=[],c=[],u=[];if(!1!==i.orbitShowRings){let t=tS(i),r=/* @__PURE__ */new Map;for(let t of e)r.set(t.id,t);let o=/* @__PURE__ */new Map;for(let[,e]of t.metaMap){if(!e.parentId)continue;let t=r.get(e.parentId);if(!t)continue;let i=`${e.parentId}:${e.ring}`;o.has(i)||o.set(i,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}let n=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(let[,{parentX:e,parentY:t,ring:i,ecc:r}]of o)for(let o=0;o<n;o++){let s=o/n*Math.PI*2,l=(o+1)/n*Math.PI*2;c.push({type:"line",x1:e+i*Math.sin(s),y1:t+i*Math.cos(s)*r,x2:e+i*Math.sin(l),y2:t+i*Math.cos(l)*r,style:a,datum:null})}}for(let t of e){if(null==t.x||null==t.y)continue;let e=s(tA(t,"nodeSize")),r=o?o(tA(t,"nodeStyle")):{},n={fill:r.fill||i.themeSemantic?.primary||"#6366f1",stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85),cursor:r.cursor};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id,depth:t.depth})}let d=/* @__PURE__ */new Map;for(let t of e)d.set(t.id,t);for(let e of t){let t="object"==typeof e.source?e.source:d.get(e.source),i="object"==typeof e.target?e.target:d.get(e.target);if(!t||!i||null==t.x||null==i.x)continue;let r=n?n(tA(e,"edgeStyle")):{},o={stroke:r.stroke||"rgba(128,128,128,0.35)",strokeWidth:r.strokeWidth??.5,opacity:r.opacity??1,cursor:r.cursor};c.push({type:"line",x1:t.x,y1:t.y,x2:i.x,y2:i.y,style:o,datum:e})}if(i.showLabels){let t=i.nodeLabel;for(let i of e){let e=s(tA(i,"nodeSize"));if(e<=4)continue;let r="function"==typeof t?t(i):t?i.data?.[t]??i.id:i.id;u.push({x:i.x,y:i.y+e+12,text:String(r),anchor:"middle",fontSize:10,fill:"currentColor",anchorPoint:[i.x,i.y]})}}return{sceneNodes:l,sceneEdges:c,labels:u}},tick:(e,t,i,r,o)=>!1!==i.orbitAnimated&&(aS(e,i),!0)};import*as lS from"react";import{arc as cS}from"d3-shape";import{jsx as uS,jsxs as dS}from"react/jsx-runtime";function hS(e,t){let i=e.style.fill;return(e.style.opacity??1)<=0||(e.style.fillOpacity??1)<=0||"string"==typeof i&&/^\s*(none|transparent)\s*$|^rgba\(.*,\s*0(\.0+)?\s*\)$|^#[\da-f]{3}0$|^#[\da-f]{6}00$/i.test(i)?null:e.faces?.map((i,r)=>/* @__PURE__ */uS("path",{d:i.pathD,fill:"string"==typeof e.style.fill?N(e.style.fill,i.shade):t,fillOpacity:e.style.fillOpacity,opacity:e.style.opacity},`face-${r}`))}function fS(e,t){return yl(pS(e,t),e,`network-node-cursor-${t}`)}function pS(e,t){switch(e.type){case"circle":{let i=e,r=Ns(i.style.fill)?Es(i.style.fill,`net-circle-${t}-hatch`):void 0,o={fill:r?`url(#net-circle-${t}-hatch)`:nl(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity};/* @__PURE__ */
328
- return dS(lS.Fragment,{children:[r&&/* @__PURE__ */uS("defs",{children:r}),i.pathD&&hS(i,o.fill),i.pathD?/* @__PURE__ */uS("path",{d:i.pathD,...o}):/* @__PURE__ */uS("circle",{cx:i.cx,cy:i.cy,r:i.r,...o})]},`net-circle-${t}`)}case"rect":{let i=e,r=Ns(i.style.fill)?Es(i.style.fill,`net-rect-${t}-hatch`):void 0,o={fill:r?`url(#net-rect-${t}-hatch)`:nl(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity};/* @__PURE__ */
329
- return dS(lS.Fragment,{children:[r&&/* @__PURE__ */uS("defs",{children:r}),i.pathD&&hS(i,o.fill),i.pathD?/* @__PURE__ */uS("path",{d:i.pathD,...o}):/* @__PURE__ */uS("rect",{x:i.x,y:i.y,width:i.w,height:i.h,...o})]},`net-rect-${t}`)}case"arc":{let i=e,r=i.pathD?"":cS().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(ol)||"",o=Ns(i.style.fill)?Es(i.style.fill,`net-arc-${t}-hatch`):void 0;/* @__PURE__ */
330
- return dS(lS.Fragment,{children:[o&&/* @__PURE__ */uS("defs",{children:o}),i.pathD&&hS(i,o?`url(#net-arc-${t}-hatch)`:nl(i.style.fill)),
331
- /* @__PURE__ */uS("path",{d:i.pathD??r,transform:i.pathD?void 0:`translate(${i.cx},${i.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:nl(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},`net-arc-${t}`)}case"symbol":{let i=e,r=je(i.symbolType,i.size,i.path),o=i.rotation?`translate(${i.cx},${i.cy}) rotate(${180*i.rotation/Math.PI})`:`translate(${i.cx},${i.cy})`,n=/* @__PURE__ */uS("path",{d:r,transform:o,fill:i.style.fill?nl(i.style.fill):"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity},`net-symbol-${t}`);return i.faces?.length?/* @__PURE__ */dS(lS.Fragment,{children:[hS(i,i.style.fill?nl(i.style.fill):void 0),n]},`net-symbol-${t}`):n}case"glyph":{let i=e;return sl(i,i.cx,i.cy,`net-glyph-${i.id??t}`)}default:return null}}function gS(e,t){return yl(mS(e,t),e,`network-edge-cursor-${t}`)}function mS(e,t){switch(e.type){case"line":{let i=e;/* @__PURE__ */
332
- return uS("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.stroke||"#999",strokeOpacity:i.style.strokeOpacity,strokeWidth:i.style.strokeWidth??1,strokeDasharray:i.style.strokeDasharray,strokeLinecap:i.style.strokeLinecap,opacity:i.style.opacity},`net-edge-${t}`)}case"bezier":{let i=e,r=`net-bezier-${t}-hatch`,o=Ns(i.style.fill)?Es(i.style.fill,r):void 0;/* @__PURE__ */
333
- return dS(lS.Fragment,{children:[o&&/* @__PURE__ */uS("defs",{children:o}),
334
- /* @__PURE__ */uS("path",{d:i.pathD,fill:o?`url(#${r})`:nl(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeOpacity:i.style.strokeOpacity,strokeWidth:i.style.strokeWidth,strokeDasharray:i.style.strokeDasharray,strokeLinecap:i.style.strokeLinecap,opacity:i.style.opacity})]},`net-edge-${t}`)}case"ribbon":{let i=e,r=`net-ribbon-${t}-hatch`,o=Ns(i.style.fill)?Es(i.style.fill,r):void 0;/* @__PURE__ */
335
- return dS(lS.Fragment,{children:[o&&/* @__PURE__ */uS("defs",{children:o}),
336
- /* @__PURE__ */uS("path",{d:i.pathD,fill:o?`url(#${r})`:nl(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeOpacity:i.style.strokeOpacity,strokeWidth:i.style.strokeWidth,strokeDasharray:i.style.strokeDasharray,strokeLinecap:i.style.strokeLinecap,opacity:i.style.opacity})]},`net-edge-${t}`)}case"curved":{let i=e;/* @__PURE__ */
337
- return uS("path",{d:i.pathD,fill:nl(i.style.fill,"none"),fillOpacity:i.style.fill&&"none"!==i.style.fill?i.style.fillOpacity??.1:void 0,stroke:i.style.stroke||"#999",strokeOpacity:i.style.strokeOpacity,strokeWidth:i.style.strokeWidth??1,strokeDasharray:i.style.strokeDasharray,strokeLinecap:i.style.strokeLinecap,opacity:i.style.opacity},`net-edge-${t}`)}default:return null}}function yS(e,t,i="middle",r="auto"){/* @__PURE__ */
338
- return uS("text",{x:e.x,y:e.y,textAnchor:e.anchor||i,dominantBaseline:e.baseline||r,fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,transform:e.rotate?`rotate(${Math.round(180*e.rotate/Math.PI*100)/100} ${e.x} ${e.y})`:void 0,style:{pointerEvents:"none"},children:e.text},`net-label-${t}`)}function xS(e){let t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:String(t)}function bS(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){let t=e.cx??e.x,i=e.cy??e.y;if("number"!=typeof t||"number"!=typeof i)return null;let r=Ve(e.glyph,e.size);return{x:t+r.centerDx,y:i+r.centerDy,r:Math.max(1,r.radius)}}let t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),i=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof i?null:{x:t,y:i,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,We(e.size)):Math.max(1,e.w??0,e.h??0)/2}}function vS(e){if(!e)return;let t=[];for(let i of e){let e=bS(i);e&&t.push({pointId:xS(i),...e})}return t}import{Fragment as wS,jsx as kS}from"react/jsx-runtime";var AS={x:0,y:0,k:1};function SS(e){return e&&Number.isFinite(e.k)&&e.k>0&&Number.isFinite(e.x)&&Number.isFinite(e.y)?e:AS}function MS({view:e,width:t,height:i,children:r}){if(!e)/* @__PURE__ */return kS(wS,{children:r});let{x:o,y:n,k:a}=SS(e);/* @__PURE__ */
339
- return kS("svg",{width:t,height:i,overflow:"hidden","data-network-view":"",children:/* @__PURE__ */kS("g",{transform:`translate(${o},${n}) scale(${a})`,children:r})})}function $S(e,t,i){return"function"==typeof t?t(e):e[t??i]}function _S(e){let t=null==e?NaN:Number(e);return Number.isFinite(t)?t:1}function LS(e,t){return null!=e?String(e):("production"!==process.env.NODE_ENV&&console.warn(`[Semiotic] Missing network ${t} ID; skipping this datum.`),null)}function PS(e,t){let i=LS($S(e,t.sourceAccessor,"source"),"source"),r=LS($S(e,t.targetAccessor,"target"),"target");return null===i||null===r?null:{source:i,target:r,value:_S($S(e,t.valueAccessor,"value")),data:e}}function IS(e,t,i){let r=/* @__PURE__ */new Map;for(let t of e){let e=LS($S(t,i.nodeIDAccessor,"id"),"node");null!==e&&(r.has(e)&&"production"!==process.env.NODE_ENV&&console.warn(`[Semiotic] Duplicate network node ID "${e}"; using the last datum.`),r.set(e,t))}let o=[];return t.forEach((e,t)=>{let n=PS(e,i);if(n){for(let e of[n.source,n.target])r.has(e)||r.set(e,{id:e});o.push({...n,_edgeKey:`${n.source}\0${n.target}\0${t}`})}}),{nodes:r,edges:o}}import{Fragment as RS,jsx as TS,jsxs as CS}from"react/jsx-runtime";function NS(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function FS([e,t]){return{id:e,x:t.x??0,y:t.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t,createdByFrame:!0}}function zS(e){return{...e,y0:0,y1:0,sankeyWidth:0}}D(F),Xw("sankey",rA),Xw("force",hA),Xw("chord",vA),Xw("tree",VA),Xw("cluster",VA),Xw("treemap",VA),Xw("circlepack",VA),Xw("partition",VA),Xw("orbit",sS);var ES=/* @__PURE__ */new Set(["tree","cluster","treemap","circlepack","partition","orbit"]);function DS(e){return e.map(e=>{let t=e.datum&&"object"==typeof e.datum?e.datum:{},i=t.data&&"object"==typeof t.data?t.data:t,r="cx"in e?e.cx:e.x+e.w/2,o="cy"in e?e.cy:e.y+e.h/2;return{...i,...null==i.id&&null!=e.id?{id:e.id}:{},x:r,y:o}})}function OS(e,t){let i=hr(e.theme),r=e.chartType||"force",o=e.size||[500,500],n=it({...md(r),...e.margin},e.title),a=et(e.title),s=e.showLegend?(()=>{let t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;if(!t)return[];let o=li(e.nodes||[]);if(o.length>0)return Hl(o,t);if(ES.has(r)&&e.data)return Hl(nv(e.data,e.childrenAccessor||"children"),t);let n=Array.isArray(e.edges)?li(e.edges):[];if(0===n.length)return[];let a=NS(e.sourceAccessor,"source"),s=NS(e.targetAccessor,"target"),l=Array.from(new Set(n.flatMap(e=>[a(e),s(e)]).filter(e=>null!=e).map(String)));return Hl(l.map(e=>({id:e})),t)})():[];Uu(n,{props:e,categories:s,theme:i,size:o,hasTitle:a});let l,c=Zu({props:e,categories:s,theme:i,size:o,margin:n,hasTitle:a}),u=Math.max(1,o[0]-n.left-n.right),d=Math.max(1,o[1]-n.top-n.bottom),h=dd(e.backgroundGraphics,o,n,null),f=dd(e.foregroundGraphics,o,n,null),p=(r,a=[],s=[])=>(t&&(t.evidence=_s({frameType:"network",width:o[0],height:o[1],marks:[...a.map(({node:e})=>({type:`node:${e.type??"node"}`})),...s.map(({node:e})=>({type:`edge:${e.type??"edge"}`}))],title:e.title,description:e.description,annotations:e.annotations,annotationRender:l,nodeCount:a.length,edgeCount:s.length,margin:n})),Yw.renderToStaticMarkup(Ku(/* @__PURE__ */TS(MS,{view:e.viewTransform,width:u,height:d,children:r}),{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?` ${e.className}`:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:u,innerHeight:d,legend:c,idPrefix:e._idPrefix}))),g=t=>{let r=e=>Number(e);return e.annotations?pu({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:r,y:r},layout:{width:u,height:d},theme:i,frameType:"network",annotationData:t&&DS(t),pointNodes:t&&vS(t),idPrefix:e._idPrefix,onRender:e=>{l=e}}):null},m=()=>{let t=g(),i=h||f||e.annotations?/* @__PURE__ */CS(RS,{children:[h,t,f]}):null;return p(i)},y=Vw(r);if(!y&&!e.customNetworkLayout)throw new Error(`No layout plugin found for chart type: "${r}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition, orbit.`);let x,b,v={chartType:r,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:!1,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig,perspective:e.perspective},w=z(e.perspective);if(ES.has(r)){let t=e.data||e.edges;if(!t||Array.isArray(t))return m();v.__hierarchyRoot=t,x=[],b=[]}else{let t=li(e.nodes||[]),i=Array.isArray(e.edges)?li(e.edges):[];if(0===t.length&&0===i.length)return m();let r=IS(t,i,v);x=Array.from(r.nodes,FS),b=r.edges.map(zS)}let k,A,S=[],M=[],$=[],_=null,L=null;if(v.customNetworkLayout){let t=v.colorScheme,r=kp(t,i.colors.categorical,fi),o=Ap(r,t),n={nodes:x,edges:b,dimensions:{width:u,height:d,plot:{x:0,y:0,width:u,height:d}},theme:{semantic:i.colors,categorical:[...r]},resolveColor:o,config:v.layoutConfig??{},selection:e.layoutSelection??null,perspective:w?.config??null},a=v.customNetworkLayout(n);k=a.perspective,S=a.sceneNodes??[],M=a.sceneEdges??[],Bw({nodes:S,edges:M,restyle:a.restyle,restyleEdge:a.restyleEdge,selection:e.layoutSelection??null,baseStyles:/* @__PURE__ */new WeakMap}),$=a.labels??[],_=a.backgrounds??null,L=a.overlays??null,A=a.perspectiveBounds}else if(y){y.computeLayout(x,b,v,[u,d]);let e=y.buildScene(x,b,v,[u,d]);S=e.sceneNodes,M=e.sceneEdges,$=e.labels}let P=[],I=w?(()=>{let e=E({sceneNodes:S,sceneEdges:M,labels:$,bounds:A,size:[u,d],perspective:w,chartType:r,theme:B(i)});return S=e.sceneNodes,M=e.sceneEdges,$=e.labels,P=e.underlay,e.frame})():null,R=fr(i);for(let e of $)e.fill||(e.fill=R.text);let T=Rl({nodes:M,renderMode:e.renderMode,fallback:(e,t)=>gS(e,t)}),C=Rl({nodes:S,renderMode:e.renderMode,fallback:(e,t)=>fS(e,t)}),N=T.map(e=>e.element),F=C.map(e=>e.element),D=$.map((e,t)=>yS(e,t)).filter(Boolean),O=g(S),j=/* @__PURE__ */CS(RS,{children:[h,$e(_,I,k),P.map((e,t)=>gS(e,t)),N,F,D,O,$e(f,I),$e(L,I,k)]});return p(j,C,T)}import*as jS from"react-dom/server";import{geoPath as WS}from"d3-geo";import{quadtree as BS}from"d3-quadtree";import{geoMercator as YS,geoEqualEarth as GS,geoAlbersUsa as XS,geoOrthographic as VS,geoNaturalEarth1 as qS,geoEquirectangular as HS}from"d3-geo";var US={mercator:YS,equalEarth:GS,albersUsa:XS,orthographic:VS,naturalEarth:qS,equirectangular:HS};function ZS(e){if(!e)return GS();if("string"==typeof e){let t=US[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),GS())}if("object"==typeof e&&"type"in e){let t=US[e.type],i=t?t():GS();return e.rotate&&"rotate"in i&&i.rotate(e.rotate),e.center&&"center"in i&&i.center(e.center),i}return e}function QS(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function KS(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function JS(e,t,i){return e?"function"==typeof e?{...i,...e(t)}:{...i,...e}:{...i}}function eM(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}function tM(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}function iM(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}function rM(e,t){if(e.length<2)return[e];let i=.4*t,r=[],o=[e[0]];for(let t=1;t<e.length;t++){let n=e[t-1],a=e[t];Math.abs(a[0]-n[0])>i?(o.length>=2&&r.push(o),o=[a]):o.push(a)}return o.length>=2&&r.push(o),r}function oM(e,t,i=24){let r=t[0]-e[0],o=t[1]-e[1],n=Math.sqrt(r*r+o*o);if(0===n)return[e,t];let a=-o/n,s=r/n,l=Math.min(.3*n,80),c=(e[0]+t[0])/2+a*l,u=(e[1]+t[1])/2+s*l,d=[];for(let r=0;r<=i;r++){let o=r/i,n=1-o,a=n*n*e[0]+2*n*o*c+o*o*t[0],s=n*n*e[1]+2*n*o*u+o*o*t[1];d.push([a,s])}return d}function nM(e,t){if(e.length<2)return e;let i=t/2+1,r=[];for(let t=0;t<e.length;t++){let o,n,a=e[t];0===t?(o=e[1][0]-a[0],n=e[1][1]-a[1]):t===e.length-1?(o=a[0]-e[t-1][0],n=a[1]-e[t-1][1]):(o=e[t+1][0]-e[t-1][0],n=e[t+1][1]-e[t-1][1]);let s=Math.sqrt(o*o+n*n)||1,l=n/s,c=-o/s;r.push([a[0]+l*i,a[1]+c*i])}return r}function aM(e,t,i,r,o){let n=t[0]-e[0],a=t[1]-e[1],s=Math.sqrt(n*n+a*a);if(0===s)return[e,t];let l=a/s,c=-n/s,u=o/2+1;return[[e[0]+l*u,e[1]+c*u],[t[0]+l*u,t[1]+c*u]]}import{scaleLinear as sM}from"d3-scale";function lM(e,t,i,r){let o=e.filter(e=>"point"===e.type);if(o.length<2)return null;let n=t.strength??1,a=Number.isFinite(n)?Math.max(0,Math.min(1,n)):1,s="strip"===t.layout?"strip":"radial";if("radial"===s&&0===a)return null;let l=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,c="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=o.find(e=>e.datum&&String(l(e.datum))===String(t.center));if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;let d=o.map(e=>e.datum?Number(c(e.datum)):NaN).filter(e=>isFinite(e)&&e>=0),h=ze(d,1);r>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let t=e.length-1;t>=0;t--){let i=e[t];"geoarea"===i.type&&i.interactive&&e.splice(t,1)}let f="strip"===s?uM(o,u,c,h,i):cM(o,u,c,h,a,i),p=e.filter(e=>"line"===e.type);if(p.length>0){let e=/* @__PURE__ */new Map;for(let t of o)null!=t.pointId&&e.set(String(t.pointId),[t.x,t.y]);for(let i of p){let r=i.datum?.source,o=i.datum?.target;if(null!=r&&null!=o){let n=e.get(String(r)),a=e.get(String(o));if(n&&a)if("fractional"===t.lineMode&&i.path.length>2){let e=i.path[0],t=i.path[i.path.length-1],r=[n[0]-e[0],n[1]-e[1]],o=[a[0]-t[0],a[1]-t[1]],s=[0];for(let e=1;e<i.path.length;e++)s.push(s[e-1]+Math.hypot(i.path[e][0]-i.path[e-1][0],i.path[e][1]-i.path[e-1][1]));let l=s[s.length-1];i.path=i.path.map((e,t)=>{let n=l>0?s[t]/l:t/(i.path.length-1);return[e[0]+r[0]*(1-n)+o[0]*n,e[1]+r[1]*(1-n)+o[1]*n]})}else i.path=[n,a]}}}return f}function cM(e,t,i,r,o,n){let a=t.x,s=t.y,l=n.width/2,c=n.height/2,u=Math.min(n.width,n.height)/2,d=sM().domain([0,r]).range([0,u]);for(let n of e){if(n===t||!n.datum)continue;let e=n.x,u=n.y,h=Math.atan2(u-s,e-a),f=Math.hypot(e-a,u-s),p=Number(i(n.datum)),g=isFinite(p)&&p>=0?r>0?d(p):0:f,m=l+Math.cos(h)*g,y=c+Math.sin(h)*g;n.x=e+(m-e)*o,n.y=u+(y-u)*o}return t.x=a+(l-a)*o,t.y=s+(c-s)*o,{cx:t.x,cy:t.y,maxCost:r,availableRadius:u,layout:"radial"}}function uM(e,t,i,r,o){let n=Math.max(3,Math.min(8,.35*o.height)),a=Math.max(1,o.width-2*n),s=o.height/2,l=sM().domain([0,r]).range([0,a]);t.x=n,t.y=s;let c=[];for(let o of e){if(o===t)continue;if(!o.datum){o.x=n,o.y=s;continue}let e=Number(i(o.datum)),a=n+(isFinite(e)&&e>=0&&r>0?l(e):0);o.x=a,o.y=s,c.push({node:o,x:a})}c.sort((e,t)=>e.x-t.x);let u=Math.max(0,Math.min(o.height/2-1,6)),d=0;for(;d<c.length;){let e=d+1;for(;e<c.length&&Math.abs(c[e].x-c[d].x)<3;)e++;let t=e-d;if(t>1&&u>0)for(let e=0;e<t;e++){let i=e-(t-1)/2,r=Math.min(2.5,2*u/Math.max(1,t-1));c[d+e].node.y=s+i*r}d=e}return{cx:n,cy:s,maxCost:r,availableRadius:a,layout:"strip"}}var dM=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],hM=["scene-style","data-paint","accessibility","evidence"],fM=(e,t)=>({retainedData:e,invalidations:t}),pM=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gM=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],mM=["scene-geometry","data-paint","accessibility","evidence"],yM=["scene-style","data-paint","accessibility","evidence"],xM=["scene-geometry","scene-style","data-paint","accessibility","evidence"],bM=["overlay","accessibility","evidence"],vM=[],wM={xAccessor:/* @__PURE__ */fM("rebuild",pM),yAccessor:/* @__PURE__ */fM("rebuild",pM),lineDataAccessor:/* @__PURE__ */fM("rebuild",pM),pointIdAccessor:/* @__PURE__ */fM("rebuild",mM),lineIdAccessor:/* @__PURE__ */fM("rebuild",mM),windowSize:/* @__PURE__ */fM("rebuild",pM),projection:/* @__PURE__ */fM("preserve",gM),projectionExtent:/* @__PURE__ */fM("preserve",gM),fitPadding:/* @__PURE__ */fM("preserve",gM),lineType:/* @__PURE__ */fM("preserve",gM),flowStyle:/* @__PURE__ */fM("preserve",gM),graticule:/* @__PURE__ */fM("preserve",gM),projectionTransform:/* @__PURE__ */fM("preserve",gM),customLayout:/* @__PURE__ */fM("preserve",gM),layoutConfig:/* @__PURE__ */fM("preserve",gM),layoutMargin:/* @__PURE__ */fM("preserve",gM),areaStyle:/* @__PURE__ */fM("preserve",yM),pointStyle:/* @__PURE__ */fM("preserve",xM),lineStyle:/* @__PURE__ */fM("preserve",yM),colorScheme:/* @__PURE__ */fM("preserve",yM),themeCategorical:/* @__PURE__ */fM("preserve",yM),themeDiverging:/* @__PURE__ */fM("preserve",yM),themeSemantic:/* @__PURE__ */fM("preserve",yM),themeSequential:/* @__PURE__ */fM("preserve",yM),decay:/* @__PURE__ */fM("preserve",yM),pulse:/* @__PURE__ */fM("preserve",yM),layoutSelection:/* @__PURE__ */fM("preserve",yM),annotations:/* @__PURE__ */fM("preserve",bM),autoPlaceAnnotations:/* @__PURE__ */fM("preserve",bM),clock:/* @__PURE__ */fM("preserve",vM),transition:/* @__PURE__ */fM("preserve",vM),introAnimation:/* @__PURE__ */fM("preserve",vM),onLayoutError:/* @__PURE__ */fM("preserve",vM)},kM=/* @__PURE__ */fM("preserve",gM);function AM(e){let t="preserve",i=/* @__PURE__ */new Set;for(let r of e){let e=wM[r]??kM;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}var SM=class{constructor(){this.tracker=new ne}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},dM)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},hM):this.recordNoop("restyle")}recordConfig(e,t={}){let i=AM(e),r=new Set(i.invalidations);return t.retainedDataChanged&&r.add("data"),this.tracker.record({kind:"config",keys:e},r)}};import{geoDistance as MM,geoGraticule as $M,geoInterpolate as _M}from"d3-geo";function LM({config:e,projection:t,path:i,areas:r,points:o,lines:n,layout:a}){let s=QS(e.xAccessor,"lon"),l=QS(e.yAccessor,"lat"),c=[],u=eM(e),d=iM(e),h=tM(e);if(e.graticule){let t=!0===e.graticule?{}:e.graticule,r=$M();t.step&&r.step(t.step);let o=i(r())||"";o&&c.push({type:"geoarea",pathData:o,centroid:[a.width/2,a.height/2],bounds:[[0,0],[a.width,a.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth??.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(let t of r){let r=i(t);if(!r)continue;let o=i.centroid(t),n=i.bounds(t),a=i.area(t);c.push({type:"geoarea",pathData:r,centroid:o,bounds:n,screenArea:a,style:JS(e.areaStyle,t,u),datum:t,interactive:!0})}let f=KS(e.lineDataAccessor);for(let i of n){let r=f(i);if(!r||r.length<2)continue;let o=[];if("geo"===e.lineType){let e=new Array(r.length);for(let t=0;t<r.length;t++)e[t]=[s(r[t]),l(r[t])];for(let i=0;i<e.length-1;i++){let r=e[i],n=e[i+1],a=MM(r,n)||0,s=Math.max(2,Math.ceil(a/(Math.PI/180))),l=_M(r,n);for(let e=0;e<=s;e++){if(i>0&&0===e)continue;let r=t(l(e/s));null!=r&&o.push(r)}}}else for(let e=0;e<r.length;e++){let i=r[e],n=t([s(i),l(i)]);null!=n&&o.push(n)}if(o.length<2)continue;let n=JS(e.lineStyle,i,d),u="number"==typeof n.strokeWidth?n.strokeWidth:1;2===r.length&&o.length>=2&&"arc"===e.flowStyle?o=oM(o[0],o[o.length-1]):2===r.length&&o.length>=2&&"offset"===e.flowStyle&&(o="geo"===e.lineType?nM(o,u):aM(o[0],o[o.length-1],0,0,u));let h=rM(o,a.width);if(h.length<=1)c.push({type:"line",path:o.length>=2?o:h[0]||o,style:n,datum:i});else for(let e of h)e.length<2||c.push({type:"line",path:e,style:{...n,_edgeFade:!0},datum:i})}let p=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,g=t.clipAngle?t.clipAngle()??0:0,m=g>0?g*Math.PI/180:null,y=t.rotate?t.rotate():[0,0,0],x="function"==typeof t.center?t.center():[0,0],b=[(x[0]??0)-y[0],(x[1]??0)-y[1]];for(let i of o){let r=s(i),o=l(i);if(null!=m&&MM([r,o],b)>m)continue;let n=t([r,o]);if(!n)continue;let a=e.pointStyle?e.pointStyle(i):{...h},u={type:"point",x:n[0],y:n[1],r:a.r||4,style:a,datum:i,pointId:p?String(p(i)):void 0};c.push(u)}return c}function PM(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e)&&e>=0&&e<.5)return e;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${String(e)}.`)}var IM=class extends za{constructor(e){var t;super(),this.updateResults=new SM,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=(t=e,{...t,fitPadding:PM(t.fitPadding)})}currentTime(){return this.config.clock?.()??R()}getConfiguredWindowSize(){let e=this.config.windowSize??500;if(!Number.isInteger(e)||e<1)throw new Error("GeoPipelineStore windowSize must be a positive integer");return e}retainNewestLines(e=this.getConfiguredWindowSize()){this.lineData.length>e&&(this.lineData=this.lineData.slice(-e))}resizeStreamingWindow(e){if(this.pointBuffer){let t=this.pointBuffer.toArray(),i=this.timestampBuffer?.toArray()??[],r=t.slice(-e),o=i.slice(-r.length),n=this.currentTime();this.pointBuffer=new vn(e),this.timestampBuffer=new vn(e),r.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(o[t]??n)})}this.retainNewestLines(e)}updateConfig(e){let t="fitPadding"in(n=e)?{...n,fitPadding:PM(n.fitPadding)}:n,i=this.config,r=this.getConfiguredWindowSize(),o=Object.keys(t).filter(e=>t[e]!==i[e]);var n;this.config={...this.config,...t};let a=this.getConfiguredWindowSize(),s=this.streaming&&a!==r;s&&(this.resizeStreamingWindow(a),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(o,{retainedDataChanged:s})}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setAreas(e){this.areas=e,this.updateResults.recordData("replace",e.length)}setAreasWithResult(e){return this.setAreas(e),this.updateResults.last}setPoints(e){this.pointData=e.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",e.length)}setPointsWithResult(e){return this.setPoints(e),this.updateResults.last}setLines(e){this.lineData=e.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",e.length)}setLinesWithResult(e){return this.setLines(e),this.updateResults.last}initStreaming(e){void 0!==e&&e!==this.config.windowSize&&(this.config={...this.config,windowSize:e});let t=this.getConfiguredWindowSize(),i=this.pointBuffer?this.pointBuffer.toArray():this.pointData,r=this.timestampBuffer?.toArray()??[],o=i.slice(-t),n=r.slice(-o.length),a=this.currentTime();this.pointBuffer=new vn(t),this.timestampBuffer=new vn(t),o.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(n[t]??a)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();let t=this.currentTime();Ca(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t,this.updateResults.recordData("ingest",1)}pushPointWithResult(e){return this.pushPoint(e),this.updateResults.last}pushMany(e){this.pointBuffer||this.initStreaming();let t=this.currentTime();for(let i of e)Ca(this.pointBuffer,i,this.timestampBuffer,t);this.lastIngestTime=t,this.updateResults.recordData("ingest",e.length)}pushManyWithResult(e){return this.pushMany(e),this.updateResults.last}pushLine(e){null!=e&&"object"==typeof e?(this.streaming||this.initStreaming(),this.lineData.push(e),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return void this.updateResults.recordNoop("ingest");let t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(let e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){let{lineIdAccessor:t}=this.config;if(!t)throw new Error("removeLine() requires lineIdAccessor to be configured");let i="function"==typeof t?t:e=>e[t],r=new Set(Array.isArray(e)?e:[e]),o=[];return this.lineData=this.lineData.filter(e=>!r.has(String(i(e)))||(o.push(e),!1)),o.length>0?(this.version++,this.updateResults.recordData("remove",o.length)):this.updateResults.recordNoop("remove"),o}getLines(){return this.lineData.slice()}removePoint(e){let{pointIdAccessor:t}=this.config;if(!t)throw new Error("removePoint() requires pointIdAccessor to be configured");let i="function"==typeof t?t:e=>e[t],r=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){let e=e=>r.has(String(i(e)));Na(this.pointBuffer,this.timestampBuffer,e);let t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{let e=[];return this.pointData=this.pointData.filter(t=>!r.has(String(i(t)))||(e.push(t),!1)),e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(e){let t=this._customRestyle;if(t){for(let i of this.scene){let r=this._baseStyles.get(i)??i.style,o=t(i,e);i.style=o?{...r,...o}:r}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){let{config:t}=this,i=this.projection,r=this.geoPath,o=this.scales,n=this.baseScale,a=[...this.baseTranslate],s=[...this.baseRotation],l=this.scene;this.projection=ZS(t.projection),this.geoPath=WS(this.projection),this.fitProjection(e),this.geoPath=WS(this.projection);let c=this.projection;this.scales={projection:c,geoPath:this.geoPath,projectedPoint:(e,t)=>c([e,t]),invertedPoint:(e,t)=>c.invert?c.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=i,this.geoPath=r,this.scales=o,this.baseScale=n,this.baseTranslate=a,this.baseRotation=s):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){let t=e.width/2,i=e.height/2,r=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:i}));r.length>0&&this.startTransition(r)}this._hasRenderedOnce=!0,t.transition&&l.length>0&&this.startTransition(l),this.version++}}fitProjection(e){let t=this.projection,i=this.config,r=[...this.areas],o=QS(i.xAccessor,"lon"),n=QS(i.yAccessor,"lat"),a=this.getPoints();if(a.length>0){let e=a.map(e=>[o(e),n(e)]);r.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}let s=KS(i.lineDataAccessor);for(let e of this.lineData){let t=s(e);if(t&&t.length>0){let e=t.map(e=>[o(e),n(e)]);r.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==r.length){if(i.projectionExtent){let[[r,o],[n,a]]=i.projectionExtent,s={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[r,o],[r,a],[n,a],[n,o],[r,o]]]}};t.fitExtent([[0,0],[e.width,e.height]],s)}else if(t.clipAngle&&(t.clipAngle()??0)>0){let r=i.fitPadding??0,o=Math.min(e.width,e.height),n=o/2-o*r;t.scale(n),t.translate([e.width/2,e.height/2])}else{let o={type:"FeatureCollection",features:r},n=i.fitPadding??0,a=e.width*n,s=e.height*n;t.fitExtent([[a,s],[e.width-a,e.height-s]],o)}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){let i=this.projection;if(!i)return;let r=this.geoPath,o=this.scales,n=i.scale(),a=[...i.translate()],s=this.currentZoom;i.scale(this.baseScale*e.k),i.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=WS(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(n),i.translate(a),this.currentZoom=s,this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=l,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){let i=this.projection;if(!i)return;let r=this.geoPath,o=this.scales,n=i.scale(),a=[...i.translate()],s=this.currentZoom;i.scale(this.baseScale*e),i.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=WS(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(n),i.translate(a),this.currentZoom=s,this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=l,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){let i=this.projection;if(!i||!i.rotate)return;let r=this.geoPath,o=this.scales,n=[...i.rotate()];i.rotate(e),this.geoPath=WS(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let a=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.rotate(n),this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=a,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){let t=this.projection;!t||!t.rotate||t.rotate(e)}hasProjection(){return null!=this.projection}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let e=0,t=0;for(let i of this.scene)"point"===i.type&&!1!==i.interactive&&(t++,i.r>e&&(e=i.r));if(this._maxPointRadius=e,t<=500)return void(this._quadtree=null);let i=new Array(t),r=0;for(let e of this.scene)"point"===e.type&&!1!==e.interactive&&(i[r++]=e);this._quadtree=BS().x(e=>e.x).y(e=>e.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;let{config:t}=this,i=this.projection,r=this.geoPath;if(t.customLayout&&this.scales){let i=t.layoutMargin??{top:0,right:0,bottom:0,left:0},r=kp(t.colorScheme,t.themeCategorical,Ni),o={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:i,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...r]},resolveColor:Ap(r,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null},n=Vn({family:"geo",logLabel:"geo customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:t.onLayoutError,run:()=>t.customLayout(o)});if("failure"===n.kind)return this.lastCustomLayoutFailure=n.diagnostic,this._customLayoutFailedThisBuild=!0,n.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);let a=n.result,s=a.nodes??[];if(this.customLayoutOverlays=a.overlays??null,this.lastCustomLayoutResult=a,this.lastCustomLayoutFailure=null,this._customRestyle=a.restyle,this.hasCustomRestyle=!!a.restyle,this._baseStyles=/* @__PURE__ */new WeakMap,this.hasCustomRestyle)for(let e of s){this._baseStyles.set(e,e.style);let i=a.restyle?.(e,t.layoutSelection??null);i&&(e.style={...e.style,...i})}return Wn({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,LM({config:t,projection:i,path:r,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){let i=lM(this.scene,e,t,this.areas.length);i&&(this.cartogramLayout=i)}applyDecay(){let e=this.config.decay;if(!e||!this.pointBuffer)return;let t=this.pointBuffer.size;if(0===t)return;let i=this.scene.filter(e=>"point"===e.type);for(let r=0;r<i.length;r++){let o=Mn(e,r,t);i[r]._decayOpacity=o,i[r].style={...i[r].style,opacity:o}}}applyPulse(e=this.currentTime()){let t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;let i=this.scene.filter(e=>"point"===e.type),r=this.timestampBuffer.toArray(),o=t.color||"rgba(255,255,255,0.6)",n=t.glowRadius??4,a=!1;for(let s=0;s<i.length&&s<r.length;s++){let l=Ln(t,r[s],e);a=In(i[s],l,o,n)||a}return a}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&Rn(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){let t=this.config.transition?.duration??300;if(t<=0)return;let i=/* @__PURE__ */new Map;for(let t of e)"point"===t.type&&t.pointId&&i.set(t.pointId,[t.x,t.y]);let r=this.scene.filter(e=>"point"===e.type),o=!1;for(let e of r)if(e.pointId){let t=i.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(o=!0))}for(let e of r)e.pointId&&!i.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??e.style?.fillOpacity??1,e.style={...e.style,opacity:0},o=!0);o&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null;for(let e of this.scene)"point"===e.type&&(null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0),null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0))}advanceTransition(e){if(!this.activeTransition)return!1;let t=P(e,this.activeTransition),i=L(t),r=this.scene.filter(e=>"point"===e.type);for(let e of r){if(null!=e._targetX&&null!=e._targetY){let t=e.x,r=e.y;e.x=I(t,e._targetX,i),e.y=I(r,e._targetY,i)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*i})}if(t>=1){for(let e of r)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0),null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};import*as RM from"react";import{jsx as TM,jsxs as CM}from"react/jsx-runtime";function NM(e,t){return yl(FM(e,t),e,`geo-cursor-${t}`)}function FM(e,t){switch(e.type){case"geoarea":{let i=e;if(!i.pathData)return null;let r=Ns(i.style.fill)?Es(i.style.fill,`geoarea-${t}-hatch`):void 0;/* @__PURE__ */
340
- return CM(RM.Fragment,{children:[r&&/* @__PURE__ */TM("defs",{children:r}),
341
- /* @__PURE__ */TM("path",{d:i.pathData,fill:r?`url(#geoarea-${t}-hatch)`:nl(i.style.fill,"#e0e0e0"),fillOpacity:i.style.fillOpacity??1,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth??.5,strokeDasharray:i.style.strokeDasharray,opacity:(i.style.opacity??1)*(i._decayOpacity??1)})]},`geoarea-${t}`)}case"point":{let i=e,r=Ns(i.style.fill)?Es(i.style.fill,`geopoint-${t}-hatch`):void 0;/* @__PURE__ */
342
- return CM(RM.Fragment,{children:[r&&/* @__PURE__ */TM("defs",{children:r}),
343
- /* @__PURE__ */TM("circle",{cx:i.x,cy:i.y,r:i.r,fill:r?`url(#geopoint-${t}-hatch)`:nl(i.style.fill),fillOpacity:i.style.fillOpacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i._decayOpacity??i.style.opacity??1})]},`point-${t}`)}case"line":{let i=e;if(i.path.length<2)return null;let r="M"+i.path.map(e=>`${e[0]},${e[1]}`).join("L");/* @__PURE__ */
344
- return TM("path",{d:r,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth??1.5,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity??1},`line-${t}`)}case"glyph":{let i=e;return sl(i,i.x,i.y,`geo-glyph-${i.pointId??t}`)}default:return null}}function zM(e){if(!e)return;let t=[];for(let i of e)if("point"===i.type)t.push(i);else if("glyph"===i.type){let e=i,r=Ve(e.glyph,e.size);t.push({pointId:e.pointId,x:e.x+r.centerDx,y:e.y+r.centerDy,r:r.radius})}return t}import{jsx as EM,jsxs as DM}from"react/jsx-runtime";function OM({bottomMargin:e,costLabel:t,layout:{cx:i,cy:r,maxCost:o,availableRadius:n,layout:a},ringStyle:s,ringValues:l,showNorth:c,showRingLabels:u,showRings:d}){let h="strip"===a,f={stroke:h?"var(--semiotic-border, #999)":"#999",strokeWidth:h?1:.8,strokeDasharray:h?"none":"4,3",labelColor:"var(--semiotic-text-secondary, #777)",labelSize:h?8:10,...s};/* @__PURE__ */
345
- return DM("g",h?{children:[
346
- /* @__PURE__ */EM("line",{x1:i,y1:r,x2:i+n,y2:r,stroke:f.stroke,strokeWidth:f.strokeWidth,strokeLinecap:"round",opacity:.85}),
347
- /* @__PURE__ */EM("line",{x1:i,y1:r-3.5,x2:i,y2:r+3.5,stroke:f.stroke,strokeWidth:f.strokeWidth,opacity:.9}),d&&l.map(a=>{let s=i+(o>0?a/o*n:0);/* @__PURE__ */
348
- return DM("g",{children:[
349
- /* @__PURE__ */EM("line",{x1:s,y1:r-2.5,x2:s,y2:r+2.5,stroke:f.stroke,strokeWidth:.9,opacity:.65}),u&&/* @__PURE__ */DM("text",{x:s,y:r+Math.min(10,(e??2)+8),textAnchor:"middle",fontSize:f.labelSize,fill:f.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[a,t?` ${t}`:""]})]},a)})]}:{children:[l.map(e=>{let a=e/o*n;/* @__PURE__ */
350
- return DM("g",{children:[
351
- /* @__PURE__ */EM("circle",{cx:i,cy:r,r:a,fill:"none",stroke:f.stroke,strokeWidth:f.strokeWidth,strokeDasharray:f.strokeDasharray,opacity:.5}),u&&/* @__PURE__ */DM("text",{x:i+a+3,y:r-2,fontSize:f.labelSize,fill:f.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[e,t?` ${t}`:""]})]},e)}),c&&/* @__PURE__ */DM("g",{transform:"translate(24, 24)",children:[
352
- /* @__PURE__ */EM("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),
353
- /* @__PURE__ */EM("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),
354
- /* @__PURE__ */EM("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:"N"}),
355
- /* @__PURE__ */EM("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),
356
- /* @__PURE__ */EM("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),
357
- /* @__PURE__ */EM("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]})]})}import{Fragment as jM,jsx as WM,jsxs as BM}from"react/jsx-runtime";function YM(e,t){let i=hr(e.theme),r=e.size||[e.width||600,e.height||400],o=it({top:10,right:10,bottom:10,left:10,...e.margin},e.title),n=et(e.title),a=Array.isArray(e.areas)?li(e.areas):e.areas,s=li(e.points),l=li(e.lines),c=e.showLegend?(()=>{let t="string"==typeof(r=e.colorBy)||"function"==typeof r?e.colorBy:void 0,i=s.length>0?s:Array.isArray(a)&&a.length>0?"string"==typeof t?a.map(e=>({...e.properties||{},...e})):a:[];var r;return Hl(i,t)})():[];Uu(o,{props:e,categories:c,theme:i,size:r,hasTitle:n});let u=Zu({props:e,categories:c,theme:i,size:r,margin:o,hasTitle:n}),d=Math.max(1,r[0]-o.left-o.right),h=Math.max(1,r[1]-o.top-o.bottom),f={projection:e.projection||"equalEarth",projectionExtent:e.projectionExtent,xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineIdAccessor:e.lineIdAccessor,lineType:e.lineType,flowStyle:e.flowStyle,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,colorScheme:e.colorScheme,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutSelection:e.layoutSelection,layoutMargin:o,onLayoutError:e.onLayoutError,themeCategorical:i.colors.categorical,themeSemantic:B(i),themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging},p=new IM(f);if(a){if("string"==typeof a)throw new Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${a}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${a}')\` before calling renderGeoToStaticSVG.`);p.setAreas(a)}e.points&&p.setPoints(s),e.lines&&p.setLines(l),p.computeScene({width:d,height:h});let g,m=dd(e.backgroundGraphics,r,o,p.scales),y=dd(e.foregroundGraphics,r,o,p.scales),x=Rl({nodes:p.scene,renderMode:e.renderMode,fallback:(e,t)=>NM(e,t)}),b=x.map(e=>e.element),v=x.length>0&&e.cartogramChrome,w=p.cartogramLayout&&v?/* @__PURE__ */WM(OM,{layout:{...p.cartogramLayout,layout:p.cartogramLayout.layout??"radial"},ringValues:GM(p.cartogramLayout.maxCost,v.showRings),showRings:v.showRings??!0,showNorth:v.showNorth??!0,showRingLabels:v.showRingLabels??!0,costLabel:"string"==typeof v.costLabel?v.costLabel:void 0}):null,k=e.annotations?pu({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:p.scales?.projectedPoint?([e,t])=>p.scales.projectedPoint(e,t):void 0},layout:{width:d,height:h},theme:i,pointNodes:zM(p.scene),idPrefix:e._idPrefix,onRender:e=>{g=e}}):null;t&&(t.evidence=_s({frameType:"geo",width:r[0],height:r[1],marks:x.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:g,legendItems:c.length>0?c.length:null!=e.legend?1:void 0,margin:o}));let A=/* @__PURE__ */BM(jM,{children:[m,b,k,w,y,p.customLayoutOverlays]});return jS.renderToStaticMarkup(Ku(A,{width:r[0],height:r[1],className:"stream-geo-frame"+(e.className?` ${e.className}`:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:d,innerHeight:h,legend:u,idPrefix:e._idPrefix}))}function GM(e,t){if(!1===t||e<=0)return[];if(Array.isArray(t))return t.filter(t=>t>0&&t<=e);let i="number"==typeof t?t:Math.min(5,Math.max(2,Math.ceil(e/5))),r=e/i,o=[];for(let e=1;e<=i;e++)o.push(Math.round(r*e*10)/10);return o}import*as XM from"react-dom/server.browser";function VM(e){return e.world.bodies.map(e=>({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:{...e.shape},sleeping:e.sleeping,datum:e.datum}))}function qM(e=[]){return e.map(e=>({id:e.id,label:e.label,count:e.count,...null!=e.secondary?{secondary:e.secondary}:{},...e.secondaryLabel?{secondaryLabel:e.secondaryLabel}:{},...null!=e.observed?{observed:e.observed}:{}}))}function HM(e,t,i,r){let o=e-(t+i+r);return{charge:e,live:t,queued:i,sedimented:r,unaccounted:o,balanced:0===o}}function UM(e,t={}){let i=t.bodies??VM(e),r=i.filter(e=>e.sleeping).length,o=e.queue.length,n=e.sediment.reduce((e,t)=>e+t.count,0),a="settled"===e.simulationState&&0===o&&r===i.length,s=[];a||s.push("PHYSICS_NOT_SETTLED"),o>0&&s.push("PHYSICS_QUEUE_UNDRAINED");let l=null!=t.charge&&Number.isFinite(t.charge)?HM(t.charge,i.length,o,n):void 0;return l&&!l.balanced&&s.push("PHYSICS_LEDGER_MISMATCH"),{bodyCount:i.length,sleepingCount:r,settled:a,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:qM(t.projectionRows),queuedCount:o,sedimentedCount:n,...l?{ledger:l}:{},warnings:s}}var ZM={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function QM(e){return e.datum&&"object"==typeof e.datum?e.datum:null}function KM(e){let t=e.datum;if(t&&"object"==typeof t){let e=t,i=e.label??e.name??e.id;if(null!=i&&""!==i)return String(i)}return e.id}function JM(e,t,i){let r="function"==typeof t?t(e,i):t;return{...ZM,...r??{}}}function e$(e,t={},i={index:0,simulationState:"settled"}){let r=QM(e),o={label:t.getBodyLabel?.(e)??KM(e)},n={style:JM(e,t.bodyStyle,i),datum:r,accessibleDatum:r,accessibility:o,_transitionKey:e.id};return"aabb"===e.shape.type?{type:"rect",x:e.x-e.shape.width/2,y:e.y-e.shape.height/2,w:e.shape.width,h:e.shape.height,...n}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...n}}function t$(e,t={},i="settled"){return e.map((e,r)=>e$(e,t,{index:r,simulationState:i}))}function i$(e,t={}){let i=e.settle(t.maxSteps),r=e.readBodies(),o=e.snapshot();return{snapshot:o,bodies:r,sceneNodes:t$(r,t,o.simulationState),evidence:UM(o,{bodies:r,projectionRows:t.projectionRows,stepsRun:i,charge:t.charge}),stepsRun:i}}import{jsx as r$,jsxs as o$}from"react/jsx-runtime";function n$(e){let t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?`physics-${t}`:t}var a$={top:0,right:0,bottom:0,left:0};function s$(e,t,i){return"function"==typeof e?e({size:t,margin:i}):e}function l$(e,t={}){let{width:i=640,height:r=360,title:o,description:n,background:a,backgroundGraphics:s,backgroundGraphicsBackdrop:l,className:c,foregroundGraphics:u,idPrefix:d="physics",margin:h,style:f,renderBodySVG:p,renderChrome:g,...m}=t,y=i$(e,m),x={...a$,...h},b=[i,r],v=s$(s,b,x),w=s$(u,b,x),k=n$(d),A=o?`${k}-title`:void 0,S=n?`${k}-desc`:void 0,M=[A,S].filter(Boolean).join(" ")||void 0,$=x.left||x.top?`translate(${x.left},${x.top})`:void 0,_=Math.max(1,i-x.left-x.right),L=Math.max(1,r-x.top-x.bottom),P=`${k}-plot-clip`,I=$&&null!=v?/* @__PURE__ */r$("g",{transform:$,children:v}):v;return{element:/* @__PURE__ */o$("svg",{xmlns:"http://www.w3.org/2000/svg",className:c??"stream-physics-frame",width:i,height:r,viewBox:`0 0 ${i} ${r}`,role:"img","aria-labelledby":M,style:f,children:[o&&/* @__PURE__ */r$("title",{id:A,children:o}),n&&/* @__PURE__ */r$("desc",{id:S,children:n}),
358
- /* @__PURE__ */r$("defs",{children:/* @__PURE__ */r$("clipPath",{id:P,children:/* @__PURE__ */r$("rect",{width:_,height:L})})}),l&&"transparent"!==l?/* @__PURE__ */r$("rect",{className:"stream-frame-background__backdrop",x:0,y:0,width:i,height:r,fill:l}):null,!s&&a&&"transparent"!==a?/* @__PURE__ */r$("rect",{x:0,y:0,width:i,height:r,fill:a}):null,I,
359
- /* @__PURE__ */r$("g",{id:`${k}-data-area`,transform:$,clipPath:`url(#${P})`,children:y.sceneNodes.map((e,t)=>{let i=y.bodies[t],r=i&&p?p(i,e.style??{},t,k):void 0;return null!=r?yl(r,e,t):yl("point"===e.type||"rect"===e.type?fl(e,t,k):null,e,`xy-cursor-${t}`)})}),w,g?.(y)]}),scene:y,evidence:y.evidence}}function c$(e,t={}){let{element:i,scene:r,evidence:o}=l$(e,t);return{svg:XM.renderToStaticMarkup(i),scene:r,evidence:o}}function u$(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function d$(e,t){let i="sensor"===e.physics?t.sensorThickness:t.barrierThickness;return Math.max(0,u$(e.thickness)??u$(i)??u$(t.thickness)??4)}function h$(e=[],t={}){let i=t.idPrefix?`${t.idPrefix}-`:"",r=[];for(let o of e){if("barrier"!==o.physics&&"sensor"!==o.physics)continue;let e,n=o.axis??t.defaultAxis??"x",a=d$(o,t),s=o.colliderId??`${i}${o.id}`;if("x"===n){let i=u$(o.x),r=u$(o.y1)??u$(t.plotBounds?.y)??u$(o.y),n=u$(o.y2)??(t.plotBounds?t.plotBounds.y+t.plotBounds.height:void 0)??u$(o.y);if(null==i||null==r||null==n)continue;e={type:"segment",x1:i,y1:r,x2:i,y2:n,thickness:a}}else{let i=u$(o.y),r=u$(o.x1)??u$(t.plotBounds?.x)??u$(o.x),n=u$(o.x2)??(t.plotBounds?t.plotBounds.x+t.plotBounds.width:void 0)??u$(o.x);if(null==i||null==r||null==n)continue;e={type:"segment",x1:r,y1:i,x2:n,y2:i,thickness:a}}r.push({id:s,shape:e,sensor:"sensor"===o.physics,..."barrier"!==o.physics||null==o.restitution&&null==t.barrierRestitution?{}:{restitution:u$(o.restitution)??u$(t.barrierRestitution)},..."barrier"!==o.physics||null==o.friction&&null==t.barrierFriction?{}:{friction:u$(o.friction)??u$(t.barrierFriction)}})}return r}function f$(e){return e.sensorId??`stream-region-${e.id}`}function p$(e){let t=f$(e),i={bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution};if("boundary"===e.collider&&"aabb"===e.shape.type){let r=e.colliderThickness??8,o=e.shape.x-e.shape.width/2,n=e.shape.x+e.shape.width/2,a=e.shape.y-e.shape.height/2,s=e.shape.y+e.shape.height/2;return[{...i,id:`${t}-top`,shape:{type:"segment",x1:o,y1:a,x2:n,y2:a,thickness:r}},{...i,id:`${t}-right`,shape:{type:"segment",x1:n,y1:a,x2:n,y2:s,thickness:r}},{...i,id:`${t}-bottom`,shape:{type:"segment",x1:n,y1:s,x2:o,y2:s,thickness:r}},{...i,id:`${t}-left`,shape:{type:"segment",x1:o,y1:s,x2:o,y2:a,thickness:r}}]}return e.collider?[{...i,id:`${t}-collider`,shape:e.shape}]:[]}function g$({annotations:e,chartId:t,chartType:i,config:r,onRegionObservation:o,regionEffects:n,seed:a,size:s}){let l=h$((e??[]).filter(e=>"barrier"===e.physics||"sensor"===e.physics),{idPrefix:t?`${t}-ann`:"physics-ann",plotBounds:{x:0,y:0,width:s[0],height:s[1]}}),c=void 0===a||void 0!==r?.kernel?.seed?r:{...r,kernel:{...r?.kernel,seed:a}},u=n.flatMap(e=>[{id:f$(e),sensor:!0,shape:e.shape,bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution},...p$(e)]),d=Object.fromEntries(n.map(e=>[f$(e),{binId:e.binId??e.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),h=c?.observation,f=n.length>0,p=u.length>0||l.length>0;return f||p||null!=t||h?{...c,colliders:[...c?.colliders??[],...u,...l],observation:{...h,chartId:t??h?.chartId,chartType:h?.chartType??i,sensors:{...h?.sensors??{},...d},onObservation:e=>{f&&o(e),h?.onObservation?.(e)}}}:c}import{jsx as m$}from"react/jsx-runtime";function y$({title:e,totalWidth:t,marginTop:i}){return e?"string"!=typeof e?/* @__PURE__ */m$("foreignObject",{x:0,y:0,width:t,height:i,children:e}):/* @__PURE__ */m$("text",{x:t/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",fontSize:14,className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)",fontFamily:"var(--semiotic-title-font-family, var(--semiotic-font-family, sans-serif))",fontWeight:"var(--semiotic-title-font-weight, bold)"},children:e}):null}import{scaleLinear as x$}from"d3-scale";function b$(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function v$(e){return e.map(e=>({pointId:e.id,x:e.x,y:e.y,r:Math.max(1,b$(e))}))}function w$(e){let{width:t,height:i,pointNodes:r=[],data:o}=e;return{scales:{x:x$().domain([0,Math.max(1,t)]).range([0,Math.max(1,t)]),y:x$().domain([0,Math.max(1,i)]).range([0,Math.max(1,i)])},width:t,height:i,frameType:"network",pointNodes:r,data:o,xAccessor:"x",yAccessor:"y"}}function k$(e){return e?.length?e.map(e=>null!=e.pointId||null==e.bodyId?e:{...e,pointId:String(e.bodyId)}):e}import{jsx as A$,jsxs as S$}from"react/jsx-runtime";function M$(e,t,i,r,o){let n=Math.max(1,i[0]-r.left-r.right),a=Math.max(1,i[1]-r.top-r.bottom),s=k$(t.annotations),l=w$({width:n,height:a,pointNodes:v$(e.bodies)}),c=l.scales?.x,u=l.scales?.y;if(!c||!u)throw new Error("Physics annotation context requires pixel scales");let d,h=pu({annotations:s,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{x:c,y:u},layout:{width:n,height:a},theme:o,frameType:"network",xAccessor:l.xAccessor,yAccessor:l.yAccessor,pointNodes:l.pointNodes,svgAnnotationRules:t.svgAnnotationRules,onRender:e=>{d=e}}),f=t.legend?Hu(t.legend,{theme:o,position:t.legendPosition,size:[i[0],i[1]],margin:r,hasTitle:!!t.title,legendLayout:t.legendLayout})??yu(t.legend,i,r,t.legendPosition,t.legendLayout):null;return{annotationRender:d,node:/* @__PURE__ */S$("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:i[0],height:i[1],style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[
360
- /* @__PURE__ */A$("g",{transform:`translate(${r.left},${r.top})`,children:h}),
361
- /* @__PURE__ */A$(y$,{title:t.title,totalWidth:i[0],marginTop:Math.max(r.top,28)}),f]})}}var $$={top:0,right:0,bottom:0,left:0};function _$(e,t){let i=e.size??[e.width??600,e.height??400],r=hr(e.theme),o=void 0===e.theme?{}:X(r),n=e.bodyStyle,a=!1,s=e.legendPosition??"right",l=tt({...$$,...e.margin},a);if(e.legend){let t={...l};mt(l,{legend:e.legend,position:s,size:i,hasTitle:a,legendLayout:e.legendLayout}),rt(l,t,i,s)}let c,u=[Math.max(1,i[0]-l.left-l.right),Math.max(1,i[1]-l.top-l.bottom)],d=g$({annotations:e.annotations,chartId:e.chartId,chartType:"StreamPhysicsFrame",config:e.config,onRegionObservation:()=>{},regionEffects:e.regionEffects??[],seed:e.seed,size:u}),h=new te(d);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&h.enqueue(e.initialSpawns,e.initialSpawnPacing);let f=c$(h,{...e,width:i[0],height:i[1],background:e.background??r.colors.background,bodyStyle:(e,t)=>({fill:r.colors.primary,stroke:r.colors.text,strokeWidth:1,opacity:.9,..."function"==typeof n?n(e,t):n}),style:{...o,fontFamily:r.typography.fontFamily,...e.style},charge:e.charge,idPrefix:e.idPrefix??e._idPrefix??"physics",margin:l,renderChrome:t=>{let o=M$(t,e,i,l,r);return c=o.annotationRender,o.node}});return t&&(t.evidence=_s({frameType:"physics",width:i[0],height:i[1],marks:f.scene.sceneNodes,title:e.title,description:e.description,annotations:e.annotations,annotationRender:c,extraWarnings:[...0===f.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[],...f.scene.evidence.warnings]})),f.svg}import*as L$ from"react-dom/server";function P$(e,t={}){if("function"==typeof e)return e;let i=t.locale??"en-US",r=t.currency??"USD";if("currency"===e){let e=t.precision??2,o=new Intl.NumberFormat(i,{style:"currency",currency:r,maximumFractionDigits:e,minimumFractionDigits:e});return e=>o.format(e)}if("percent"===e){let e=t.precision??1,r=new Intl.NumberFormat(i,{style:"percent",maximumFractionDigits:e,minimumFractionDigits:0});return e=>r.format(e)}if("compact"===e){let e=t.precision??1,r=new Intl.NumberFormat(i,{notation:"compact",maximumFractionDigits:e,minimumFractionDigits:0});return e=>r.format(e)}if("duration"===e)return e=>I$(e);let o=t.precision??0,n=new Intl.NumberFormat(i,{notation:t.notation??"standard",maximumFractionDigits:o,minimumFractionDigits:0});return e=>n.format(e)}function I$(e){if(!Number.isFinite(e))return String(e);let t=e<0?"-":"",i=Math.abs(e),r=Math.round(i);if(r<1e3)return`${t}${r}ms`;let o=Math.round(i/10)/100;if(o<60)return`${t}${T$(o)}s`;let n=Math.round(i/1e3);if(n<3600)return`${t}${R$(Math.floor(n/60),"m",n%60,"s")}`;let a=Math.round(i/6e4);if(a<1440)return`${t}${R$(Math.floor(a/60),"h",a%60,"m")}`;let s=Math.round(i/36e5);return`${t}${R$(Math.floor(s/24),"d",s%24,"h")}`}function R$(e,t,i,r){return 0===i?`${e}${t}`:`${e}${t} ${i}${r}`}function T$(e){return String(Math.round(100*e)/100)}function C$(e,t,i){return`${t??""}${e}${i??""}`}function N$(e,t){return 0===e||t(Math.abs(e))===t(0)}function F$(e,t){return Number.isFinite(e)?N$(e,t)?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}function z$(e,t){if(!t||0===t.length||!Number.isFinite(e))return null;let i=t.filter(e=>Number.isFinite(e.at)||e.at===-1/0).slice().sort((e,t)=>e.at-t.at),r=null;for(let t of i){if(!(e>=t.at))break;r=t}return r}import{jsx as E$,jsxs as D$}from"react/jsx-runtime";var O$={tile:{width:280,height:184,padding:16,labelSize:13,captionSize:11,valueSize:40,detailSize:13,align:"start",border:!0,showHeader:!0,showDetail:!0},presentation:{width:540,height:320,padding:32,labelSize:18,captionSize:14,valueSize:96,detailSize:18,align:"center",border:!0,showHeader:!0,showDetail:!0},inline:{width:240,height:64,padding:8,labelSize:0,captionSize:0,valueSize:28,detailSize:13,align:"start",border:!1,showHeader:!1,showDetail:!0},thumbnail:{width:96,height:56,padding:6,labelSize:0,captionSize:0,valueSize:22,detailSize:0,align:"center",border:!1,showHeader:!1,showDetail:!1}};function j$(e,t){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:t}function W$(e,t,i){return t||("success"===e?i.colors.success??"#2ca02c":"warning"===e?i.colors.warning??"#b26a00":"danger"===e?i.colors.danger??"#d62728":"info"===e?i.colors.info??i.colors.primary:i.colors.text)}function B$(e,t,i){let r=e.comparison&&"object"==typeof e.comparison?e.comparison:void 0,o=r&&"number"==typeof r.value&&Number.isFinite(r.value)?r.value:void 0,n=("number"==typeof e.delta&&Number.isFinite(e.delta)?e.delta:void 0)??(void 0===o?void 0:t-o);if(void 0!==n)return`${F$(n,i)}${r&&"string"==typeof r.label?` ${r.label}`:""}`}function Y$(e,t,i){let r=e.target&&"object"==typeof e.target?e.target:void 0;if(!r||"number"!=typeof r.value||!Number.isFinite(r.value))return;let o="string"==typeof r.label?` ${r.label}`:"";return 0===r.value?`target ${i(r.value)}${o}`:`${new Intl.NumberFormat("string"==typeof e.locale?e.locale:"en-US",{style:"percent",maximumFractionDigits:0}).format(t/r.value)} of ${i(r.value)}${o}`}var G$={BigNumber:function(e,t){let i="presentation"===e.mode||"inline"===e.mode||"thumbnail"===e.mode?e.mode:"tile",r=O$[i],o=j$(e.width,r.width),n=j$(e.height,r.height),a="number"==typeof e.padding&&Number.isFinite(e.padding)?Math.max(0,e.padding):r.padding,s="center"===e.align||"end"===e.align||"start"===e.align?e.align:r.align,l="center"===s?"middle":"end"===s?"end":"start",c="center"===s?o/2:"end"===s?o-a:a,u=hr(e.theme),d="number"==typeof e.value&&Number.isFinite(e.value)?e.value:void 0,h=P$("string"==typeof e.format||"function"==typeof e.format?e.format:"number",{locale:"string"==typeof e.locale?e.locale:void 0,currency:"string"==typeof e.currency?e.currency:void 0,precision:"number"==typeof e.precision?e.precision:void 0}),f=void 0===d?"No value":C$(h(d),"string"==typeof e.prefix?e.prefix:void 0,"string"==typeof e.suffix?e.suffix:void 0),p=void 0===d?void 0:z$(d,e.thresholds),g=p?.level??"neutral",m="string"==typeof e.color?e.color:W$(g,p?.color,u),y="string"==typeof e.label?e.label:void 0,x="string"==typeof e.caption?e.caption:void 0,b="string"==typeof e.unit?e.unit:void 0,v=[void 0===d?void 0:B$(e,d,h),void 0===d?void 0:Y$(e,d,h),p?.label].filter(Boolean).join(" · "),w="string"==typeof e.description&&e.description||[y,f,b,v].filter(Boolean).join(", "),k="string"==typeof e.background?e.background:u.colors.surface??u.colors.background,A="string"==typeof e.borderColor?e.borderColor:u.colors.border,S=a+r.labelSize,M=S+r.captionSize+4,$=r.showHeader&&(y||x)?x?M+10:S+14:a,_="presentation"===i?n/2+.32*r.valueSize:"thumbnail"===i?n/2+.34*r.valueSize:Math.min(n-a-(v?26:4),$+r.valueSize),L=c+("start"===l?Math.max(r.valueSize,f.length*r.valueSize*.55):0),P=L$.renderToStaticMarkup(
362
- /* @__PURE__ */D$("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:n,viewBox:`0 0 ${o} ${n}`,role:"img","aria-label":w,"data-semiotic-component":"BigNumber",children:[
363
- /* @__PURE__ */E$("title",{children:y??f}),"string"==typeof e.description&&/* @__PURE__ */E$("desc",{children:e.description}),
364
- /* @__PURE__ */E$("rect",{x:r.border?.5:0,y:r.border?.5:0,width:r.border?o-1:o,height:r.border?n-1:n,rx:r.border?8:0,fill:k,stroke:r.border?A:"none"}),r.showHeader&&y&&/* @__PURE__ */E$("text",{x:c,y:S,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.labelSize,fontWeight:600,fill:u.colors.text,children:y}),r.showHeader&&x&&/* @__PURE__ */E$("text",{x:c,y:M,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.captionSize,fill:u.colors.textSecondary,children:x}),
365
- /* @__PURE__ */E$("text",{x:c,y:_,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.valueSize,fontWeight:600,fontVariant:"tabular-nums",fill:void 0===d?u.colors.textSecondary:m,"data-mark-type":"value",children:f}),b&&void 0!==d&&"start"===l&&/* @__PURE__ */E$("text",{x:L+6,y:_,textAnchor:"start",fontFamily:u.typography.fontFamily,fontSize:Math.max(11,Math.round(.32*r.valueSize)),fontWeight:500,fill:u.colors.textSecondary,children:b}),r.showDetail&&v&&/* @__PURE__ */E$("text",{x:c,y:Math.min(n-a,_+r.detailSize+10),textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.detailSize,fill:u.colors.textSecondary,children:v})]}));return t&&(t.evidence=_s({frameType:"value",width:o,height:n,marks:void 0===d?[]:[{type:"value"}],title:y,description:w})),P}};function X$(e,t,i){return G$[e](t,i)}import*as V$ from"react-dom/server";import{jsx as q$,jsxs as H$}from"react/jsx-runtime";function U$(e,t,i){let{title:r,subtitle:o,theme:n,width:a=1200,height:s,layout:l={},background:c}=t,u=fr(hr(n)),d=l.columns||2,h=l.gap??16,f=0;r&&(f+=30),o&&(f+=20),f>0&&(f+=10);let p=a-h,g=Math.floor((p-h*(d-1))/d),m=[],y=0,x=f+h,b=0;for(let t of e){let e=Math.min(t.colSpan||1,d),r=g*e+h*(e-1),o=t.props.height||300;y+e>d&&(x+=b+h,y=0,b=0);let a=h/2+y*(g+h),s={...t.props,width:r,height:o,theme:n,_idPrefix:`chart-${m.length}`},l=t.component?i.chart(t.component,s):t.frameType?i.frame(t.frameType,s):`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${o}"></svg>`,c=Lt(l,{width:r,height:o}),u=Math.max(o,c.height);m.push({x:a,y:x,width:r,height:u,svg:l,svgDimensions:c}),b=Math.max(b,u),y+=e}let v=s||x+b+h,w=m.map((e,t)=>/* @__PURE__ */q$("g",{transform:`translate(${e.x},${e.y})`,children:/* @__PURE__ */q$("foreignObject",{width:e.width,height:e.height,children:/* @__PURE__ */q$("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:Pt(e.svg,e.svgDimensions)}})})},`dashboard-chart-${t}`));return V$.renderToStaticMarkup(
366
- /* @__PURE__ */H$("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:v,role:"img","aria-label":r||"Dashboard",style:{fontFamily:u.fontFamily},children:[r&&/* @__PURE__ */q$("title",{children:r}),c&&/* @__PURE__ */q$("rect",{x:0,y:0,width:a,height:v,fill:c}),r&&/* @__PURE__ */q$("text",{x:a/2,y:24,textAnchor:"middle",fontSize:u.titleFontSize+4,fontWeight:u.titleFontWeight,fill:u.text,fontFamily:u.titleFontFamily,children:r}),o&&/* @__PURE__ */q$("text",{x:a/2,y:r?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:o}),w]}))}import{Fragment as Z$,jsx as Q$}from"react/jsx-runtime";function K$(e,t){switch(e){case"xy":return Ad(t);case"ordinal":return Ww(t);case"network":return OS(t);case"geo":return YM(t);case"physics":return _$(t);default:throw new Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function J$(e){return Ad(e)}function e_(e){return Ww(e)}function t_(e){return OS(e)}function i_(e){return YM(e)}var r_=/* @__PURE__ */new Set(["d","transform","points","viewBox","x","y","x1","x2","y1","y2","cx","cy","r","rx","ry","width","height","dx","dy","offset","startOffset","stroke-width","stroke-opacity","stroke-dasharray","stroke-dashoffset","fill-opacity","opacity","font-size","letter-spacing"]),o_=/-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/gi;function n_(e){if(Number.isFinite(e))return Math.max(0,Math.min(8,Math.floor(e)))}function a_(e,t){let i=Number(e);if(!Number.isFinite(i))return e;let r=10**t,o=Math.round((i+Number.EPSILON)*r)/r;return Object.is(o,-0)?"0":String(o)}function s_(e,t){let i,r=new RegExp(o_.source,o_.flags),o="",n=0,a=!1;for(;i=r.exec(e);){let r=e.slice(n,i.index);a&&0===r.length?o+=" ":o+=r,o+=a_(i[0],t),n=i.index+i[0].length,a=!0}return o+e.slice(n)}function l_(e,t){let i=n_(t);return void 0===i?e:$t(e,(e,t)=>{if(r_.has(e)&&!/\b(?:var|calc|url)\(/i.test(t))return s_(t,i)})}var c_=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","hoverRadius","scalePadding","sizeRange","innerRadius","centerContent","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","svgAnnotationRules","barColors","legend","legendLayout","autoPlaceAnnotations","perspective"],u_=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];function d_(e,t){let i={};for(let r of t)void 0!==e[r]&&(i[r]=e[r]);return i}function h_(e,t,i){return p_(e,t,i).svg}function f_(e,t,i){let r={},{svg:o,frameType:n}=p_(e,t,i,r),a=r.evidence??_s({frameType:n,width:"number"==typeof t.width?t.width:600,height:"number"==typeof t.height?t.height:400,marks:[],title:"string"==typeof t.title?t.title:void 0,description:"string"==typeof t.description?t.description:void 0,annotations:t.annotations,extraWarnings:["NO_EVIDENCE"]});if(a.component=e,a.sceneHashVersion=2,a.sceneHash=It(o,a),ei(a,e,t),i?.artifactContract){let r=c(i.artifactContract,{excludeEvidenceSamples:!0});r.contract&&(a.artifactContract=r.contract),a.artifactTransfer=r.transfer,a.artifactBinding="0.1"===r.contract?.contractVersion&&"invalid"!==r.transfer.status?u(r.contract,t,e):{status:"unknown",mismatchPaths:[],unknownPaths:["artifactContract"]}}return{svg:o,evidence:a}}function p_(e,t,i,r){if(Object.prototype.hasOwnProperty.call(G$,e))return{svg:l_(X$(e,t,r),i?.precision),frameType:"value"};if(!Object.prototype.hasOwnProperty.call($v,e))throw new Error(`Unknown chart component: "${e}". Run \`npx semiotic-ai --list\` for supported chart types.`);let o,n=$v[e],a=Wt(n.layout?.mode??(jt(t.mode)?t.mode:void 0),{...n.layout?.modeDefaults,...d_(t,u_)},n.layout?.primarySize),{data:s,theme:l,background:c,className:u,annotations:d,margin:h,colorScheme:f,colorBy:p,legendPosition:g,...m}=t,{width:y,height:x}=a,b=[y,x],v=m.frameProps||{},w=n.layout?.margin,k="function"==typeof w?w(t,a):w??a.marginDefaults,A="xy"===n.frameType?vt(k,m.axes??v.axes,!!a.title):k,S=void 0!==h?h:v.margin,M=ti(S),$="number"==typeof S?{top:S,right:S,bottom:S,left:S}:{...A,...M},_=d_(m,c_),L=e=>v[e]??a[e],P={...v,..._,theme:l,title:a.title,description:a.description,showAxes:L("showAxes"),showLegend:L("showLegend"),showLabels:L("showLabels"),showGrid:L("showGrid"),xLabel:L("xLabel"),yLabel:L("yLabel"),categoryLabel:L("categoryLabel"),valueLabel:L("valueLabel"),background:c??v.background,className:u,annotations:d,size:b,margin:$,__resolvedMode:a.mode,__compactMode:a.compactMode,__explicitMarginSides:"number"==typeof S?["top","right","bottom","left"]:Object.keys(M??{}),__autoLegendMargin:!0,...void 0!==f&&{colorScheme:f},...void 0!==g&&{legendPosition:g},_idPrefix:m._idPrefix},I=n.buildProps(s,p,f,P,m);if(n.renderStatic)o=n.renderStatic(I,r);else switch(n.frameType){case"xy":o=Ad(I,r);break;case"ordinal":o=Ww(I,r);break;case"network":o=OS(I,r);break;case"geo":o=YM(I,r);break;case"physics":o=_$(I,r)}let R=n.renderOverlay?.(I,{theme:hr(l)});if(null!=R){let e=ii.renderToStaticMarkup(/* @__PURE__ */Q$(Z$,{children:R})),t=o.lastIndexOf("</svg>");o=t<0?`${o}${e}`:`${o.slice(0,t)}${e}${o.slice(t)}`}return{svg:l_(o,i?.precision),frameType:n.frameType}}function g_(e,t={}){return U$(e,t,{chart:h_,frame:K$})}import*as m_ from"react-dom/server";import{Fragment as y_,jsx as x_,jsxs as b_}from"react/jsx-runtime";function v_(e,t,i,r={}){let{stepSize:o,windowSize:n,frameCount:a,xExtent:s,yExtent:l,transitionFrames:c=4,fps:u=12,easing:d="ease-out",decay:h}=r,f=i.width||600,p=i.height||400,g=hr(i.theme),m={...i,...s&&{xExtent:s},...l&&{yExtent:l}};if(!t||0===t.length)return[];let y=a||Math.min(60,Math.max(10,t.length)),x=o||Math.max(1,Math.ceil(t.length/y)),b=[];for(let e=x;e<=t.length;e+=x)b.push(e);b[b.length-1]!==t.length&&b.push(t.length);let v=/* @__PURE__ */new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),w=it({top:20,right:20,bottom:30,left:40,...i.margin},i.title),k=Math.max(1,f-w.left-w.right),A=Math.max(1,p-w.top-w.bottom),S=[];if(v)for(let r=0;r<b.length;r++){let o=b[r],a=n?Math.max(0,o-n):0,s=t.slice(a,o),l={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||g.colors.categorical,...h&&{decay:h}},c=new pw(l);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&S.push(P_(c.scene,f,p,g,m,S.length))}else for(let r=0;r<b.length;r++){let o=b[r],a=n?Math.max(0,o-n):0,y=t.slice(a,o),x={chartType:e,windowSize:y.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:s,yExtent:l,colorScheme:i.colorScheme||g.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange,...h&&{decay:h},...c>0&&{transition:{duration:c*(1e3/u),easing:d}}},v=new rs(x);if(v.ingest({inserts:y,bounded:!0}),v.computeScene({width:k,height:A}),0===v.scene.length)continue;let w=v.scales?{y:v.scales.y}:void 0;if(S.push(L_(v.scene,f,p,g,m,w,S.length)),c>0&&r>0&&v.activeTransition){let e=c*(1e3/u);for(let t=1;t<=c;t++){let i=t/c,r=v.activeTransition.startTime+i*e;v.advanceTransition(r),S.push(L_(v.scene,f,p,g,m,w,S.length))}}}return S}function w_(e,t,i={}){return t.map(t=>{try{return h_(e,{...i,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||t.width||600}" height="${i.height||t.height||400}"></svg>`}})}function k_(e,t,i,r){let o=xu(`${e}-${t}`),n="string"==typeof i&&i.length>0?i:void 0,a="string"==typeof r&&r.length>0?r:void 0,s=n?o.titleId:void 0,l=a?o.descId:void 0;return{titleText:n,descText:a,titleId:s,descId:l,labelledBy:[s,l].filter(Boolean).join(" ")||void 0}}function A_(e,t){return"string"==typeof e.idPrefix&&e.idPrefix.length>0?e.idPrefix:Gu(e)||t}function S_(e,t,i){let r=t.size??[t.width??600,t.height??400],o=hr(t.theme),n=fr(o),a=t.background||o.colors.background,s=t.idPrefix??"physics-gif",l=k_(s,i,t.title,t.description),{titleId:c,descId:u,labelledBy:d}=l,h=t$(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),f=/* @__PURE__ */b_("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,role:"img","aria-labelledby":d,style:{fontFamily:n.fontFamily},children:[t.title&&/* @__PURE__ */x_("title",{id:c,children:t.title}),t.description&&/* @__PURE__ */x_("desc",{id:u,children:t.description}),a&&"transparent"!==a?/* @__PURE__ */x_("rect",{x:0,y:0,width:r[0],height:r[1],fill:a}):null,
367
- /* @__PURE__ */x_("g",{id:`${s}-frame-${i}`,children:h.map((e,t)=>Al(e,t,`${s}-${i}`))})]});return m_.renderToStaticMarkup(f)}function M_(e,t={}){let{fps:i=12,frameCount:r,durationSeconds:o=2,includeInitialFrame:n=!0,stepDt:a,stepsPerFrame:s,background:l}=t,c=Math.max(.001,a??e.config?.fixedDt??1/120),u=s??Math.max(1,Math.round(1/Math.max(1,i)/c)),d=r??Math.max(1,Math.ceil(o*Math.max(1,i))),h=l?{...e,background:l}:e,f=new te(e.config);e.initialSpawns?.length&&f.enqueue(e.initialSpawns,e.initialSpawnPacing);let p=[];for(n&&(f.tick(0),p.push(S_(f,h,0)));p.length<d;){for(let e=0;e<u;e+=1)f.tick(c);p.push(S_(f,h,p.length))}return p}function $_(e,t){let i=e.background||t.colors.background;return i&&"transparent"!==i?i:null}function __(e,t,i,r,o,n){if(!e||0===e.length)return null;let a=fr(r),s=[];for(let r=0;r<e.length;r++){let l=e[r];if("y-threshold"===l.type&&null!=l.value){let e=null;if(n)e=n(l.value);else if(o){let[t,r]=o,n=r-t;if(0===n)continue;e=i-(l.value-t)/n*i}if(null==e)continue;let c=l.color||a.primary,u=l.strokeDasharray||"6,4",d=l.strokeWidth??1.5,h=l.labelPosition||"right";s.push(
368
- /* @__PURE__ */b_("g",{children:[
369
- /* @__PURE__ */x_("line",{x1:0,y1:e,x2:t,y2:e,stroke:c,strokeWidth:d,strokeDasharray:u}),l.label&&/* @__PURE__ */x_("text",{x:"left"===h?4:"center"===h?t/2:t-4,y:e<20?Math.min(i-4,e+16):e-5,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:a.tickSize,fill:l.labelColor??c,fontFamily:a.fontFamily,children:l.label})]},`ann-${r}`))}}return s.length>0?/* @__PURE__ */x_(y_,{children:s}):null}function L_(e,t,i,r,o,n,a=0){let s=fr(r),l=it({top:20,right:20,bottom:30,left:40,...o.margin},o.title),c=Math.max(1,t-l.left-l.right),u=Math.max(1,i-l.top-l.bottom),d=$_(o,r),h=o.renderMode,f=e.map((e,t)=>Il({node:e,index:t,renderMode:h,fallback:()=>Al(e,t)})).filter(Boolean),p=__(o.annotations,c,u,r,o.yExtent,n?.y),{titleText:g,descText:m,titleId:y,descId:x,labelledBy:b}=k_(A_(o,"xy-gif"),a,o.title,o.description),v=/* @__PURE__ */b_("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":b,style:{fontFamily:s.fontFamily},children:[g&&/* @__PURE__ */x_("title",{id:y,children:g}),m&&/* @__PURE__ */x_("desc",{id:x,children:m}),d&&/* @__PURE__ */x_("rect",{x:0,y:0,width:t,height:i,fill:d}),
370
- /* @__PURE__ */b_("g",{transform:`translate(${l.left},${l.top})`,children:[p,f]}),g&&/* @__PURE__ */x_("text",{x:t/2,y:22,textAnchor:"middle",fontSize:s.titleFontSize,fontWeight:s.titleFontWeight,fill:s.text,fontFamily:s.titleFontFamily,children:g})]});return m_.renderToStaticMarkup(v)}function P_(e,t,i,r,o,n=0){let a=fr(r),s=it({top:20,right:20,bottom:30,left:40,...o.margin},o.title),l="radial"===o.projection,c=l?s.left+(t-s.left-s.right)/2:s.left,u=l?s.top+(i-s.top-s.bottom)/2:s.top,d=$_(o,r),h=Nw({nodes:e,renderMode:o.renderMode,idPrefix:o.idPrefix}).map(e=>e.element),{titleText:f,descText:p,titleId:g,descId:m,labelledBy:y}=k_(A_(o,"ordinal-gif"),n,o.title,o.description),x=/* @__PURE__ */b_("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":y,style:{fontFamily:a.fontFamily},children:[f&&/* @__PURE__ */x_("title",{id:g,children:f}),p&&/* @__PURE__ */x_("desc",{id:m,children:p}),d&&/* @__PURE__ */x_("rect",{x:0,y:0,width:t,height:i,fill:d}),
371
- /* @__PURE__ */x_("g",{transform:`translate(${c},${u})`,children:h}),f&&/* @__PURE__ */x_("text",{x:t/2,y:22,textAnchor:"middle",fontSize:a.titleFontSize,fontWeight:a.titleFontWeight,fill:a.text,fontFamily:a.titleFontFamily,children:f})]});return m_.renderToStaticMarkup(x)}ks(),Tn=T;export{v_ as generateFrameSVGs,w_ as generateFrameSequence,M_ as generatePhysicsFrameSVGs,h_ as renderChart,f_ as renderChartWithEvidence,g_ as renderDashboard,i_ as renderGeoToStaticSVG,t_ as renderNetworkToStaticSVG,e_ as renderOrdinalToStaticSVG,K$ as renderToStaticSVG,J$ as renderXYToStaticSVG,hr as resolveTheme,l_ as serializeSvgPrecision,fr as themeStyles};
1
+ import{A as e,B as t,C as i,D as r,E as o,F as n,G as a,H as s,a as l,d as c,i as u,j as d,k as h,l as f,m as p,n as g,o as m,p as y,q as x,r as b,s as v,t as w,u as k,v as A,w as S,x as M,y as $,z as _}from"./c-NSVENB5K.min.js";import{b as P}from"./c-ZMYO3NZU.min.js";import{a as L,b as I,c as R,d as T,k as C}from"./c-QIVKWHDL.min.js";import{a as N}from"./c-LPX4CNQZ.min.js";import{a as F,b as D}from"./c-USYOK5OX.min.js";import{i as E,k as z}from"./c-XGDZPYBI.min.js";import{a as O}from"./c-YWZBFG63.min.js";import{b as j,c as W,d as B,e as Y,f as G,x as X,y as V}from"./c-O53GOO7H.min.js";import{a as q,b as H,c as U,e as Z,f as Q,g as K}from"./c-FOTTQHOO.min.js";import{$ as J,R as ee,V as te,W as ie,X as re,_ as oe,a as ne,b as ae,c as se,d as le,da as ce,e as ue,ea as de,f as he,fa as fe,g as pe,ga as ge,h as me,ha as ye,i as xe,ia as be,j as ve,ja as we,ka as ke,la as Ae,p as Se,q as Me,qa as $e,r as _e,ra as Pe,s as Le,sa as Ie,ta as Re,ua as Te}from"./c-WGDM4ZRP.min.js";import{a as Ce,b as Ne,c as Fe,d as De,e as Ee}from"./c-5CI6XDJG.min.js";import{a as ze}from"./c-RHDOOQ4X.min.js";import{b as Oe}from"./c-2CKIGFD2.min.js";import{b as je,c as We,e as Be,h as Ye,j as Ge,k as Xe,l as Ve}from"./c-JY4ZN6AO.min.js";import{a as qe}from"./c-CRTZRHCC.min.js";function He(e){let t=e?.find(e=>"bottom"===e.orient),i=e?.find(e=>"top"===e.orient),r=e?.find(e=>"left"===e.orient),o=e?.find(e=>"right"===e.orient);return{bottomAxis:t,topAxis:i,leftAxis:r,rightAxis:o,xAxis:t??i,yAxis:r??o,xOrient:t||!i?"bottom":"top",yOrient:r||!o?"left":"right"}}function Ue(e){let t=6;for(let i=1;i<e.length;i++){let r=Math.abs(e[i]-e[i-1]);if(r>0&&Number.isFinite(r)){let o=Math.max(Math.abs(e[i]),Math.abs(e[i-1]));t=Math.max(t,Math.ceil(Math.log10(o/r))+1)}}let i=Math.min(17,t);return e=>Number.isInteger(e)?String(e):String(Number(e.toPrecision(i)))}function Ze(...e){let t;for(let i of e)i&&(t=Qe(t)&&Qe(i)?{legendGroups:[...t.legendGroups,...i.legendGroups],legendDistance:i.legendDistance??t.legendDistance}:i);return t}function Qe(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function Ke(e){return"object"==typeof e&&null!==e&&"gradient"in e}function Je(e){return"string"==typeof e&&e.length>0}function et(e,t){let i=t?36:0;return e.top>=i?e:{...e,top:i}}function tt(e,t){return et(e,Je(t))}function it(e,t,i,r,o=8){let n="left"===r||"right"===r,a=r,s="left"===r?"right":"right"===r?"left":"top"===r?"bottom":"top",l=Math.max(0,(n?i[0]:i[1])-o),c=Math.max(t[a],l-e[s]);e[a]>c&&(e[a]=c)}function rt(e){return Math.ceil(7*e.length)}function ot(e,t){if(Qe(e)){let i=yt(t),r=100;for(let t of e.legendGroups){t.label&&(r=Math.max(r,rt(t.label)));for(let e of t.items)r=Math.max(r,i.swatchSize+i.labelGap+rt(e.label))}return r}if(Ke(e)){let{gradient:t}=e,i=t.format||Ue(t.domain),r=Math.max(rt(i(t.domain[0])),rt(i(t.domain[1]))),o=t.label?rt(t.label):0;return Math.max(100,19+r,o)}return 100}function nt(e){return(Qe(e)||Ke(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):10}function at(e,t){return null!=e?.sideGutter?Math.max(0,e.sideGutter):t?.hasAxis?t.hasAxisLabel?ct:lt:0}function st(e){return Math.max(0,e?.edgeGutter??3)}var lt=34,ct=70;function ut(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?64:46:22:0}function dt(e){let{bottomAxis:t,topAxis:i,leftAxis:r,rightAxis:o}=He(e.axes),n=!(i&&!t||!1===t?.visible),a=!!i&&!t&&!1!==i.visible,s=!(o&&!r||!1===r?.visible),l=!!o&&!1!==o.visible,c=!1!==e.showAxes;return{hasAxis:c&&n,hasAxisLabel:c&&n&&!!(t?.label??e.xLabel),rotatedTicks:c&&n&&(e.rotatedTicks??!!t?.autoRotate),topAxis:a?{hasAxis:c,hasAxisLabel:c&&!!(i?.label??e.xLabel),rotatedTicks:c&&(e.rotatedTicks??!!i?.autoRotate)}:void 0,leftAxis:s?{hasAxis:c,hasAxisLabel:c&&!!(r?.label??e.yLabel)}:void 0,rightAxis:l?{hasAxis:c,hasAxisLabel:c&&!!(o?.label??e.yLabelRight??e.yLabel)}:void 0}}function ht(e){let t=e.projection??"vertical",i=!1!==e.showAxes&&"radial"!==t;return{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasValueLabel:e.hasCategoryLabel),leftAxis:{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasCategoryLabel:e.hasValueLabel)}}}function ft(e,t,i){if(Ke(e))return e.gradient.label?46:26;if(!Qe(e))return 20;let r=yt(i),o=Math.max(1,i?.maxWidth??t),n=r.rowHeight;for(let t of e.legendGroups){let e=0,i=0;for(let n of t.items){let t=r.swatchSize+r.labelGap+rt(n.label),a=0===i?t:i+r.itemGap+t;i>0&&a>o?(e+=1,i=t):i=a}t.items.length>0&&(e+=1),n=Math.max(n,e*r.rowHeight,t.label?rt(t.label):0)}return n+(e.legendGroups.length>1?16:0)}function pt(e,t,i){return ot(e,t)+nt(e)+at(t,i)+st(t)}function gt(e,t){let{legend:i}=t;if(!i)return;let r=t.position??"right",o=ft(i,Math.max(1,t.size[0]-e.left-e.right),t.legendLayout)+nt(i)+ut("bottom"===r?t.axisChrome:"top"===r?t.axisChrome?.topAxis:void 0,t.legendLayout)+("top"===r&&t.hasTitle?24:0),n=Math.max(t.minimumMargin??0,"top"===r?t.hasTitle?58:34:0);"right"===r?e.right=Math.max(e.right,n,pt(i,t.legendLayout,t.axisChrome?.rightAxis)):"left"===r?e.left=Math.max(e.left,n,pt(i,t.legendLayout,t.axisChrome?.leftAxis)):"top"===r?e.top=Math.max(e.top,n,o):e.bottom=Math.max(e.bottom,n,o)}function mt(e,t){let i=t.position??"right",r="top"===i||"bottom"===i,o=Math.max(0,t.totalWidth-t.margin.left-t.margin.right),n=Math.max(1,r?t.legendLayout?.maxWidth??o:t.reservedWidth??ot(e,t.legendLayout)),a=nt(e),s=at(t.legendLayout,"left"===i?t.axisChrome?.leftAxis:t.axisChrome?.rightAxis),l=st(t.legendLayout),c=ft(e,o,t.legendLayout),u=ut(t.axisChrome,t.legendLayout),d=ut(t.axisChrome?.topAxis,t.legendLayout);if("left"===i)return{x:Math.max(l,t.margin.left-s-n-a),y:t.margin.top,width:n,height:c};if("top"===i)return{x:t.margin.left,y:t.margin.top-d-a-c,width:n,height:c};if("bottom"===i){let e=t.totalHeight-t.margin.bottom;return{x:t.margin.left,y:Math.max(e+a,Math.min(e+u+a,t.totalHeight-c)),width:n,height:c}}return{x:Math.min(t.totalWidth-n-l,t.totalWidth-t.margin.right+s+a),y:t.margin.top,width:n,height:c}}function yt(e){let t=Math.max(1,e?.swatchSize??16),i=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:i,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function xt(e,t){let i=24;return e.map(({hasLabel:e,itemCount:r})=>{i+=5;let o,n=i;i+=8,e&&(i+=16,o=i,i+=8);let a=i;return i+=r*t+8,{lineY:n,labelY:o,itemsY:a,endY:i}})}function bt(e,t,i=!1){let r={...e};for(let e of t??[])!1===e.visible&&("top"!==e.orient||!i)&&(r[e.orient]=0);return r}var vt=/\s+([^\s=<>/'"]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;function wt(e){let t=0;for(;t<e.length;){let i=/^\s+/.exec(e.slice(t));i&&(t+=i[0].length);let r=e.startsWith("\x3c!--",t)?"--\x3e":e.startsWith("<?",t)?"?>":void 0;if(r){let i=e.indexOf(r,t+2);if(i<0)return;t=i+r.length;continue}if(/^<!DOCTYPE\s/i.test(e.slice(t))){let i="",r=0,o=t+9;for(;o<e.length;o+=1){let t=e[o];if(i)t===i&&(i="");else if(e.startsWith("\x3c!--",o)){let t=e.indexOf("--\x3e",o+4);if(t<0)return;o=t+2}else if('"'===t||"'"===t)i=t;else if("["===t)r+=1;else if("]"===t)r-=1;else if(">"===t&&0===r)break}if(o===e.length)return;t=o+1;continue}break}let i=/^<((?:[A-Za-z_][\w.-]*:)?svg)(?=[\s/>])((?:[^<>"']|"[^"]*"|'[^']*')*)>/i.exec(e.slice(t));if(!i)return;let r=i[2].endsWith("/"),o=r?i[2].slice(0,-1):i[2];return o.replace(vt,"").trim()?void 0:{start:t,end:t+i[0].length,name:i[1],attributes:o,selfClosing:r}}function kt(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\t/g,"&#9;").replace(/\n/g,"&#10;").replace(/\r/g,"&#13;")}function At(e){return e.replace(/\r\n|[\t\r\n]/g," ").replace(/&(amp|quot|apos|lt|gt|#\d+|#x[\da-fA-F]+);/g,(e,t)=>{if(!t.startsWith("#"))return{amp:"&",quot:'"',apos:"'",lt:"<",gt:">"}[t];let i=t.startsWith("#x")?parseInt(t.slice(2),16):Number(t.slice(1));return i>0&&i<=1114111?String.fromCodePoint(i):e})}function St(e,t){for(let i of e.attributes.matchAll(vt))if(i[1]===t)return At(i[2]??i[3])}function Mt(e,t){let i=wt(e)?.start??0;return e.slice(0,i)+e.slice(i).replace(/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<\?[\s\S]*?(?:\?>|$)|<([A-Za-z_][\w.:-]*)(?=[\s/>])(?:[^<>"']|"[^"]*"|'[^']*')*>/g,(e,i)=>i?e.replace(vt,(e,i,r,o)=>{let n=t(i,At(r??o));return void 0===n?e:` ${i}="${kt(n)}"`}):e)}function $t(e,t){let i=wt(e);if(!i)return e;let r=new Map(Object.entries(t)),o=i.attributes.replace(vt,(e,t)=>{let i=r.get(t);return void 0===i?e:(r.delete(t),` ${t}="${kt(i)}"`)});for(let[e,t]of r)o+=` ${e}="${kt(t)}"`;return`${e.slice(0,i.start)}<${i.name}${o}${i.selfClosing?"/":""}>${e.slice(i.end)}`}function _t(e,t){let i=wt(e);if(!i)return t;let r=e=>{let r=St(i,e),o=r&&/^[0-9]+(?:\.[0-9]+)?$/.test(r)?Number(r):NaN;return Number.isFinite(o)&&o>0?o:t[e]};return{width:r("width"),height:r("height")}}function Pt(e,t){let i=wt(e);return i?$t(e,{width:"100%",height:"100%",...void 0===St(i,"viewBox")?{viewBox:`0 0 ${t.width} ${t.height}`}:{},...void 0===St(i,"preserveAspectRatio")?{preserveAspectRatio:"xMidYMid meet"}:{}}):e}function Lt(e,t){return l({kind:"semiotic.rendered-svg-scene",version:2,svg:e,frameType:t.frameType,width:t.width,height:t.height,margin:t.margin,plot:t.plot,xDomain:t.xDomain,yDomain:t.yDomain,categories:t.categories})}function It(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Rt(e){if(!("number"!=typeof e.height||e.height<=0))return e.width>=e.height?"landscape":"portrait"}function Tt(e){if(!("number"!=typeof e.height||e.height<=0))return e.width/e.height}function Ct(e,t){let{when:i}=e,r=t.width,o=t.height,n=Tt(t),a=Rt(t);return!("number"==typeof i.minWidth&&r<i.minWidth||"number"==typeof i.maxWidth&&r>i.maxWidth||"number"==typeof i.minHeight&&("number"!=typeof o||o<i.minHeight)||"number"==typeof i.maxHeight&&("number"!=typeof o||o>i.maxHeight)||"number"==typeof i.minAspectRatio&&("number"!=typeof n||n<i.minAspectRatio)||"number"==typeof i.maxAspectRatio&&("number"!=typeof n||n>i.maxAspectRatio)||i.orientation&&a!==i.orientation)}function Nt(e,t){let i={...e,...t};for(let r of["margin","frameProps","mobileSemantics","style"])It(e[r])&&It(t[r])&&(i[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(i.className=`${e.className} ${t.className}`),i}function Ft(e,t,i=e.responsiveRules){if(!Array.isArray(i)||0===i.length)return{props:e,matches:[]};let r=i.map((e,t)=>({rule:e,index:t})).filter(e=>Ct(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>Nt(e,t.rule.transform),e),matches:r}}var Dt={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Et(e,t={}){let i=t.mobileSemantics?.interaction,r="number"==typeof i?.targetSize?i.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&t.width<=480,n=!!i||void 0!==r,a=e&&"object"==typeof e?e:void 0;if(!1===e||!1===a?.enabled||void 0===e&&!o&&!n)return Dt;let s=a??{};return{enabled:!0,tapToSelect:s.tapToSelect??!0,tapToLockTooltip:s.tapToLockTooltip??!0,clearSelection:s.clearSelection??"backgroundTap",targetSize:s.targetSize??r??44,snap:s.snap??"nearestDatum",brushHandleSize:s.brushHandleSize??44,standardControls:s.standardControls??!1}}var zt={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function Ot(e){return"string"==typeof e&&Object.prototype.hasOwnProperty.call(zt,e)}function jt(e,t,i){let r=zt[e||"primary"],o=e&&"primary"!==e||!i?.width?r.width:i.width,n=e&&"primary"!==e||!i?.height?r.height:i.height,a=Ft({...t,mode:e},{width:t.width??o,height:t.height??n}).props,s=a.mode||e||"primary",l=zt[s],c="context"===s||"sparkline"===s,u="primary"===s&&i?.width?i.width:l.width,d="primary"===s&&i?.height?i.height:l.height;return{mode:s,width:a.width??u,height:a.height??d,showAxes:a.showAxes??l.showAxes,showGrid:a.showGrid??l.showGrid,enableHover:a.enableHover??(!!a.linkedHover||l.enableHover),showLegend:a.showLegend??l.showLegend,showLabels:a.showLabels??l.showLabels,title:c?void 0:a.title,description:a.description,summary:a.summary,accessibleTable:a.accessibleTable,xLabel:c?void 0:a.xLabel,yLabel:c?void 0:a.yLabel,categoryLabel:c?void 0:a.categoryLabel,valueLabel:c?void 0:a.valueLabel,marginDefaults:Wt(l.marginDefaults,a.showCategoryTicks,a.orientation),compactMode:c,mobileInteraction:Et(a.mobileInteraction,{mode:s,width:a.width??u,mobileSemantics:a.mobileSemantics}),mobileSemantics:a.mobileSemantics}}function Wt(e,t,i){if(!1!==t)return e;let r={...e};return"horizontal"===i?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}var Bt={width:900,height:520},Yt={width:900,height:520},Gt={width:920,height:440},Xt={width:980,height:860},Vt={MultiAxisLineChart:{width:800,height:400},PieChart:{width:400,height:400},DonutChart:{width:400,height:400},GaugeChart:{width:300,height:250},ForceDirectedGraph:{width:600,height:600},SankeyDiagram:{width:800,height:600},ChordDiagram:{width:600,height:600},TreeDiagram:{width:600,height:600},Treemap:{width:600,height:600},CirclePack:{width:600,height:600},OrbitDiagram:{width:600,height:600},GaltonBoardChart:{width:700,height:420},UnitPileChart:{width:700,height:380},CollisionSwarmChart:{width:700,height:360},EventDropChart:{width:760,height:360},PacketFlowChart:{width:760,height:420},ProcessFlowChart:{width:900,height:420},PhysicsCustomChart:{width:700,height:380},GauntletChart:Bt,CrucibleChart:Yt,ChainReactionChart:{width:920,height:620},DependencyForestChart:Gt,FlowCircuitChart:Xt};function qt(e){return["MinimapChart","ProcessSankey","ChainReactionChart","DependencyForestChart","FlowCircuitChart"].includes(e)}function Ht(e){return Object.prototype.hasOwnProperty.call(Vt,e)?Vt[e]:void 0}function Ut(e){return e instanceof Date?`date:${e.getTime()}`:`${typeof e}:${String(e)}`}var Zt={kind:"rank-competition"};function Qt(e,t,i,r){let o=e??t;return"function"==typeof o?o(i,r):i[String(o)]}function Kt(e){let t=/* @__PURE__ */new Map;(Array.isArray(e.data)?e.data:[]).forEach((i,r)=>{if(!Number.isFinite(Number(Qt(e.yAccessor,"y",i,r))))return;let o=Ut(Qt(e.xAccessor,"x",i,r)),n=t.get(o)??/* @__PURE__ */new Set;n.add(String(Qt(e.lineBy,"series",i,r))),t.set(o,n)});let i=Array.from(t.values(),e=>e.size).sort((e,t)=>e-t);if(0===i.length)return[];let r=Math.floor(i.length/2),o={columns:i.length,median:i.length%2?i[r]:(i[r-1]+i[r])/2,max:i[i.length-1],contestedColumns:i.filter(e=>e>=2).length},n=o.max<2;return!n&&o.contestedColumns>=2&&o.median>=2?[]:[{code:n?"BUMP_NO_RANK_COMPETITION":"BUMP_SPARSE_RANK_COMPETITION",severity:n?"error":"warning",message:n?"Every ranking column contains one series, so every trajectory remains at rank 1.":"Too few ranking columns contain competing series for reliable rank movement.",fix:"Use a lineBy field with repeated series across shared x columns, or choose a value-based chart.",metrics:{...o}}]}var Jt=/* @__PURE__ */Symbol.for("semiotic.semantic-viability"),ei=globalThis;function ti(){return ei[Jt]}function ii(e){return ti()?.has(e)??!1}function ri(e){return ti()?.get(e)}function oi(e){return ii(e)?ri(e):"BumpChart"===e?Zt:void 0}function ni(e){return"string"==typeof e?.code&&e.code.length>0&&("warning"===e.severity||"error"===e.severity)&&"string"==typeof e.message&&e.message.length>0}function ai(e,t,i){if(e.semanticDiagnostics=[],e.semanticStatus="not-assessed",e.empty)return;let r,o=oi(t);if(o){try{let t="function"==typeof o?o(i,e):Kt(i);r=Array.from(t).filter(ni)}catch{return void(e.warnings.includes("SEMANTIC_VIABILITY_CHECK_FAILED")||e.warnings.push("SEMANTIC_VIABILITY_CHECK_FAILED"))}e.semanticDiagnostics=r,e.semanticStatus=r.some(e=>"error"===e.severity)?"degenerate":r.some(e=>"warning"===e.severity)?"degraded":"meaningful";for(let t of r)e.warnings.includes(t.code)||e.warnings.push(t.code)}}function si(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};let t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}import*as li from"react-dom/server";function ci(e,t,i){let r="function"==typeof t?t(e):e[String(t??i)];if(null==r||"string"==typeof r&&""===r.trim())return null;let o=Number(r);return Number.isFinite(o)?o:null}function ui(e,t,i){let r="function"==typeof t?t(e):e[String(t??i)];if(null==r||"string"==typeof r&&""===r.trim())return null;if(r instanceof Date)return Number.isFinite(r.getTime())?r:null;if("string"==typeof r){let e=d(r);if(Number.isFinite(e))return new Date(e)}let o=Number(r);return Number.isFinite(o)?o:null}import*as di from"react";function hi({data:e,safeData:t,areaBy:i,lineDataAccessor:r}){if(null==e)return[];let o,n=void 0!==t[0]?.[r];if(!n&&!i)return t;if(n)o=t;else{let e=t.reduce((e,t)=>{let o="function"==typeof i?i(t):t[i],n=String(o);if(!e[n]){let t={[r]:[]};"string"==typeof i&&(t[i]=o),e[n]=t}return e[n][r].push(t),e},{});o=Object.values(e)}return o.flatMap(e=>{let t=Array.isArray(e[r])?e[r]:[];return"string"==typeof i?t.map(t=>({...t,[i]:t[i]??e[i]})):t})}var fi=Object.freeze([]);function pi(e){if(!e)return fi;let t=!1;for(let i=0;i<e.length;i++){let r=e[i];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;let i=[];for(let t of e)null!=t&&"object"==typeof t&&i.push(t);return i}import{scaleOrdinal as gi}from"d3-scale";function mi(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function yi(e,t,i){let r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(i)}`}function xi(e){let t=e.map(mi),i=t.length-1;return e=>{if(Number.isNaN(e)&&(e=0),e<=0){let[e,i,r]=t[0];return yi(e,i,r)}if(e>=1){let[e,r,o]=t[i];return yi(e,r,o)}let r=e*i,o=Math.floor(r),n=r-o,[a,s,l]=t[o],[c,u,d]=t[o+1];return yi(Math.round(a+(c-a)*n),Math.round(s+(u-s)*n),Math.round(l+(d-l)*n))}}var bi=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],vi=/* @__PURE__ */xi(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),wi=/* @__PURE__ */xi(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),ki=/* @__PURE__ */xi(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),Ai=/* @__PURE__ */xi(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),Si=/* @__PURE__ */xi(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),Mi=/* @__PURE__ */xi(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),$i=/* @__PURE__ */xi(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),_i={blues:vi,reds:wi,greens:ki,viridis:$i,oranges:Ai,purples:Si,greys:Mi,plasma:/* @__PURE__ */xi(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),inferno:/* @__PURE__ */xi(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),magma:/* @__PURE__ */xi(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),cividis:/* @__PURE__ */xi(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),turbo:/* @__PURE__ */xi(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"])};function Pi(e){return e&&Object.prototype.hasOwnProperty.call(_i,e)?_i[e]:vi}var Li=/* @__PURE__ */xi(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Ii=/* @__PURE__ */xi(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Ri=/* @__PURE__ */xi(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),Ti=/* @__PURE__ */xi(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Ci=/* @__PURE__ */xi(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Ni=/* @__PURE__ */xi(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Fi=/* @__PURE__ */xi(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),Di={category10:bi,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],..._i},Ei=bi,zi="#007bff";function Oi(e,t,i=Ei){if(e&&"object"==typeof e&&!Array.isArray(e)){let t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){let t=Object.prototype.hasOwnProperty.call(Di,e)?Di[e]:void 0;if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:i}var ji=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Wi=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Bi=/* @__PURE__ */new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function Yi(e){let t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Bi.has(t)}function Gi(e,t,i){if("function"==typeof t){let r=t(e);return i&&r&&"string"==typeof r&&!Yi(r)?i(r):r}let r=String(e?.[t]);return i?i(r):Ei[Math.abs(qi(r))%Ei.length]}function Xi(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;let i=e[t];return"string"==typeof i&&i.length>0?i:void 0}function Vi(e,t,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){let e=i;return t=>Xi(e,t)??"#999"}let r=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>String(e)))),o=r.every(e=>!isNaN(Number(e)));if(Array.isArray(i))return gi().domain(r).range(i).unknown("#999");let n=Object.prototype.hasOwnProperty.call(Di,i)?Di[i]:Di.category10;if(o&&"function"==typeof n){let e=-1/0;for(let t of r){let i=Number(t);i>e&&(e=i)}return t=>n(0===e?0:Number(t)/e)}{let e=Array.isArray(n)?n:Ei;return gi().domain(r).range(e).unknown("#999")}}function qi(e){let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t&=t;return Math.abs(t)}function Hi(e,t,i=[3,20],r){let o;if(o="function"==typeof t?t(e):e?.[t],!r)return o;let[n,a]=r,[s,l]=i;if(a===n)return(s+l)/2;let c=(o-n)/(a-n);return c<0?c=0:c>1&&(c=1),s+c*(l-s)}function Ui(e,t,i,r,o){if(e)return e;if(i&&"object"==typeof i&&!Array.isArray(i)){let e=Xi(i,r);if(e)return e}let n;if(Array.isArray(i))n=i;else if(t&&t.length>0)n=t;else if("string"==typeof i){let e=Di[i];Array.isArray(e)&&(n=e)}return n&&0!==n.length?null!=r?(o.has(r)||o.set(r,o.size),n[o.get(r)%n.length]):n[0]:zi}function Zi(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}function Qi(e,t){if(!Zi(t))return e??((...e)=>({}));let i={};return void 0!==t.stroke&&(i.stroke=t.stroke),void 0!==t.strokeWidth&&(i.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(i.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...i}):(...e)=>({...i})}function Ki(e){let{lineWidth:t=2,colorBy:i,colorScale:r,color:o,resolveStroke:n,fillArea:a,areaOpacity:s=.3,styleRules:l,ruleContext:c}=e;return(e,u)=>{let d,h={strokeWidth:t},f=!0===a||Array.isArray(a)&&null!=u&&a.includes(u);return n?d=n(e,u):i?r&&(d=Gi(e,i,r)):d=o||zi,void 0!==d&&(h.stroke=d,f&&(h.fill=d,h.fillOpacity=s)),l?.length&&Object.assign(h,Z(e,l,c?c(e,u):{value:void 0,category:u})),h}}function Ji(e,t,i,r){if(!e.length)return[];let o=e.filter(e=>Number.isFinite(t(e))).sort((e,i)=>t(e)-t(i)),n=[],a=0,s=null,l=null,c=[],u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${a}-${e}`,h=e=>n.push(e),f=(e,t)=>{h({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;e<o.length;e++){let n=o[e],p=t(n),g=i(n),m=r(n);if(!Number.isFinite(p)||!Number.isFinite(g)||!Number.isFinite(m))continue;let y=u(g,m);if(null!==y){if(null==s){s=y;for(let e of c)f(e,s);c=[],h({__x:p,__y:g>=m?g:m,__y0:g>=m?m:g,__diffSegment:d(s),__diffWinner:s,__valA:g,__valB:m,__sourceDatum:n}),l={x:p,a:g,b:m,w:y};continue}if(l&&l.w!==y){let e,t;if(c.length>0)e=c[0].x,t=c[0].y;else{let i=g-l.a-(m-l.b);if(0!==i){let r=(l.b-l.a)/i,o=Math.max(0,Math.min(1,r));e=l.x+o*(p-l.x),t=l.a+o*(g-l.a)}else e=l.x,t=l.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t}),a++,s=y,h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t});for(let e=1;e<c.length;e++)f(c[e],s)}else for(let e of c)f(e,s);c=[],h({__x:p,__y:g>=m?g:m,__y0:g>=m?m:g,__diffSegment:d(s),__diffWinner:s,__valA:g,__valB:m,__sourceDatum:n}),l={x:p,a:g,b:m,w:y}}else c.push({x:p,y:g,datum:n})}for(let e of c)f(e,s??"A");return n}function er(e){if("A"===e.__diffWinner||"B"===e.__diffWinner)return e.__diffWinner;let t=String(e.__diffSegment??"");return"line-A"===t||t.endsWith("-A")?"A":"B"}function tr(e,t){return Q(e,t,e=>{let t=Number(e.__x),i=Number(e.__y);return{value:Number.isFinite(i)?i:void 0,x:Number.isFinite(t)?t:void 0,y:Number.isFinite(i)?i:void 0,category:er(e)}},e=>e.__sourceDatum?{...e.__sourceDatum,...e}:e)}function ir(e){let{seriesAColor:t,seriesBColor:i,areaOpacity:r,styleRules:o}=e;return tr(e=>({fill:"A"===er(e)?t:i,stroke:"none",fillOpacity:r}),o)}function rr(e){let{seriesAColor:t,seriesBColor:i,lineWidth:r,styleRules:o}=e;return tr(e=>({stroke:"A"===er(e)?t:i,strokeWidth:r,fill:"none"}),o)}var or={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]};function nr(e,t=or){if(e)return!0===e?t:"stops"in e?Array.isArray(e.stops)?e:void 0:"colorStops"in e?Array.isArray(e.colorStops)?{stops:e.colorStops.map(({offset:e,color:t})=>({offset:e,color:t}))}:void 0:{stops:[{offset:0,opacity:e.topOpacity??t.stops[0]?.opacity??.8},{offset:1,opacity:e.bottomOpacity??t.stops.at(-1)?.opacity??.05}]}}function ar(e){return e?nr(e):void 0}function sr(e){if(e)return Array.isArray(e)?{stops:e.map(({at:e,color:t,opacity:i})=>({offset:e/100,color:t,...null!=i&&{opacity:i}}))}:Array.isArray(e.stops)?e:void 0}function lr(e){let t=e?.stops.filter(e=>"string"==typeof e.color&&Number.isFinite(e.offset)).map(({offset:e,color:t,opacity:i})=>({offset:Math.max(0,Math.min(1,e)),color:t,...Number.isFinite(i)&&{opacity:Math.max(0,Math.min(1,i))}})).sort((e,t)=>e.offset-t.offset);if(!t?.length)return;let i=t[0];return i.offset>0?[{...i,offset:0},...t]:t}function cr(e){return{...e.extent&&{extent:e.extent},stops:e.stops.map(e=>({...e,offset:1-e.offset})).sort((e,t)=>e.offset-t.offset)}}function ur(e){return{...cr(e),extent:"domain"}}function dr(e){if(!e)return;let t="boolean"==typeof e?{}:"string"==typeof e?{method:e}:e;return{type:"trend",method:t.method??"linear",...null!=t.bandwidth&&{bandwidth:t.bandwidth},...null!=t.order&&{order:t.order},...null!=t.color&&{color:t.color},...null!=t.strokeWidth&&{strokeWidth:t.strokeWidth},...null!=t.strokeDasharray&&{strokeDasharray:t.strokeDasharray},...null!=t.label&&{label:t.label}}}function hr(e,t,i){return"function"==typeof e?e(i):i[e||t]}function fr(e){return e instanceof Date?e.getTime():Number(e)}function pr(e,t){return $i(1===t?.5:e/(t-1))}function gr(e){let t={};return void 0!==e.stroke&&(t.stroke=e.stroke),void 0!==e.strokeWidth&&(t.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(t.opacity=e.opacity),t}function mr(e,t){let i=dr(t),r=Array.isArray(e)?e:void 0;return i?[i,...r??[]]:r}function yr(e,t){if(!Array.isArray(e))return{data:e,orderMap:/* @__PURE__ */new WeakMap};let i=t.xAccessor||"x",r=t.yAccessor||"y",o=t.orderAccessor?[...e].sort((e,i)=>null==e||"object"!=typeof e?1:null==i||"object"!=typeof i?-1:fr(hr(t.orderAccessor,"order",e))-fr(hr(t.orderAccessor,"order",i))):e,n=/* @__PURE__ */new WeakMap,a=0;for(let e of o){if(null==e||"object"!=typeof e)continue;let t=fr(hr(i,"x",e)),o=fr(hr(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&a++}let s=0;for(let e of o){if(null==e||"object"!=typeof e)continue;let t=fr(hr(i,"x",e)),o=fr(hr(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&n.set(e,{idx:s++,total:a})}return{data:o,orderMap:n}}function xr(e){if(!e)return j;if("string"==typeof e)return"light"===e?j:"dark"===e?W:"high-contrast"===e?B:X(e)||j;let t="dark"===e.mode?W:j,i={...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}};return G(i)}function br(e){return{background:e.colors.background,text:e.colors.text,textSecondary:e.colors.textSecondary,grid:e.colors.grid,border:e.colors.border,primary:e.colors.primary,fontFamily:e.typography.fontFamily,titleSize:e.typography.titleSize,labelSize:e.typography.labelSize,tickSize:e.typography.tickSize,categorical:e.colors.categorical,annotation:e.colors.annotation??e.colors.text,legendSize:e.typography.legendSize??e.typography.labelSize,legendFontFamily:e.typography.legendFontFamily??e.typography.fontFamily,legendFontWeight:e.typography.legendFontWeight,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,titleFontFamily:e.typography.titleFontFamily??e.typography.fontFamily,titleFontWeight:e.typography.titleFontWeight??"bold",tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}function vr(e){if(!e.axes)return[{orient:"bottom",visible:!1!==e.showTimeAxis},{orient:"left",visible:!1!==e.showValueAxis}];let t=(...t)=>e.axes.some(e=>t.includes(e.orient)),i=!1===e.showTimeAxis&&!t("bottom","top"),r=!1===e.showValueAxis&&!t("left","right");return i||r?[...e.axes,...i?[{orient:"bottom",visible:!1}]:[],...r?[{orient:"left",visible:!1}]:[]]:e.axes}function wr(e,t,i,r=!1){let o=dt({axes:t,showAxes:i});return{...bt(e,t,r),...!o.hasAxis&&{bottom:0},...!o.leftAxis?.hasAxis&&{left:0}}}function kr(e,t,i="x",r="y"){let o="function"==typeof i?i:e=>e[i],n="function"==typeof r?r:e=>e[r],a="function"==typeof t.colorBy?t.colorBy:e=>e[t.colorBy],s=/* @__PURE__ */new Map;for(let i of e){let e=a(i)??(i.parentLine&&a(i.parentLine));if(null==e||""===String(e))continue;let r=String(e),n=s.get(r);(!n||("end"===t.position?Number(o(i))>Number(o(n)):Number(o(i))<Number(o(n))))&&s.set(r,i)}return[...s].map(([e,a])=>({type:"text",label:e,["string"==typeof i?i:"x"]:o(a),["string"==typeof r?r:"y"]:n(a),x:o(a),y:n(a),_directLabel:{id:e,position:t.position},color:t.color(e),fontSize:t.fontSize}))}function Ar(e=[]){let t=e.filter(e=>e._directLabel);return t.length?` Series endpoints: ${t.map(e=>`${e.label}: x ${String(e.x)}, y ${String(e.y)}`).join("; ")}.`:""}function Sr(e,t=.5){let i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;let r=Math.round(parseInt(i[1],16)*(1-t)),o=Math.round(parseInt(i[2],16)*(1-t)),n=Math.round(parseInt(i[3],16)*(1-t));return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function Mr(e,t=.5){let i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;let r=Math.round(parseInt(i[1],16)+(255-parseInt(i[1],16))*t),o=Math.round(parseInt(i[2],16)+(255-parseInt(i[2],16))*t),n=Math.round(parseInt(i[3],16)+(255-parseInt(i[3],16))*t);return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}function $r(e){return e instanceof Date&&(e=e.getTime()),"string"==typeof e&&""!==e.trim()&&(e=Number(e)),"number"==typeof e&&Number.isFinite(e)?e:null}function _r(e){let t=[];for(let[i,r]of e){let e=$r(i),o=$r(r);null!==e&&null!==o&&t.push([e,o])}return t.sort((e,t)=>e[0]-t[0])}function Pr(){return{points:[],parameterCount:0,predict:()=>NaN,leverage:()=>NaN}}function Lr(e){let t=_r(e);if(!t.length)return{points:[],parameterCount:0,predict:()=>NaN,leverage:()=>NaN};let i=t[0][0],r=t.reduce((e,[r])=>e+(r-i)/t.length,0),o=t.reduce((e,[,i])=>e+i/t.length,0),n=0,a=0;for(let[e,s]of t){let t=e-i-r;n+=t*t,a+=t*(s-o)}let s=0===n?0:a/n,l=e=>o+s*(e-i-r);return{points:t.map(([e])=>[e,l(e)]),parameterCount:2,leverage:e=>1/t.length+(n>0?(e-i-r)**2/n:0),predict:l}}function Ir(e,t=2){let i=_r(e);if(!Number.isInteger(t)||t<0||t>=i.length)return{points:[],parameterCount:0,predict:()=>NaN,leverage:()=>NaN};let r=i[0][0]/2+i[i.length-1][0]/2,o=Math.max(Math.abs(i[0][0]-r),Math.abs(i[i.length-1][0]-r))||1,n=i.map(([e])=>(e-r)/o),a=[],s=Array.from({length:t+1},()=>Array(t+1).fill(0));for(let e=0;e<=t;e++){let t=n.map(t=>t**e);for(let i=0;i<2;i++)for(let i=0;i<e;i++){let r=t.reduce((e,t,r)=>e+t*a[i][r],0);s[i][e]+=r;for(let e=0;e<t.length;e++)t[e]-=r*a[i][e]}let r=Math.sqrt(t.reduce((e,t)=>e+t*t,0));if(!Number.isFinite(r)||r<=Number.EPSILON*i.length)return Pr();s[e][e]=r,a.push(t.map(e=>e/r))}let l=a.map(e=>e.reduce((e,t,r)=>e+t*i[r][1],0));for(let e=t;e>=0;e--){for(let i=e+1;i<=t;i++)l[e]-=s[e][i]*l[i];l[e]/=s[e][e]}let c=e=>{let i=(e-r)/o,n=0;for(let e=t;e>=0;e--)n=n*i+l[e];return n};return{points:i.map(([e])=>[e,c(e)]),parameterCount:t+1,predict:c,leverage:e=>{let i=(e-r)/o,n=[];for(let e=0;e<=t;e++){let t=i**e;for(let i=0;i<e;i++)t-=s[i][e]*n[i];n.push(t/s[e][e])}return n.reduce((e,t)=>e+t*t,0)}}}function Rr(e,t,i=2){let r=e.length,o=e.reduce((e,[i,r])=>e+(r-t(i))**2,0);return{se:Math.sqrt(o/Math.max(r-i,1))}}function Tr(e){return e>=.99?2.576:e>=.95?1.96:e>=.9?1.645:1}import{scaleLinear as Cr}from"d3-scale";function Nr(e,t=.3){if(!Number.isFinite(t)||t<0||t>1)return[];let i=_r(e),r=i.length;if(r<2)return i;let o=i.map(e=>e[0]),n=i.map(e=>e[1]),a=0,s=Math.min(r,Math.max(2,Math.ceil(t*r)))-1,l=[];for(let e=0;e<r;e++){let t=o[e],i=0,c=r-1;for(;s<r-1&&Math.abs(o[s+1]-t)<=Math.abs(o[a]-t);)a++,s++;let u=Math.max(Math.abs(o[a]-t),Math.abs(o[s]-t)),d=u||1;u>0&&(i=a,c=s);let h=0,f=0,p=0,g=0,m=0;for(let e=i;e<=c;e++){let i=Math.abs(o[e]-t)/d,r=i<1?Math.pow(1-Math.pow(i,3),3):0;if(0===r)continue;h+=r;let a=(o[e]-t)/d;f+=r*a,p+=r*n[e],g+=r*a*a,m+=r*a*n[e]}if(0===h){l.push([t,n[e]]);continue}let y=h*g-f*f;if(Math.abs(y)<1e-12)l.push([t,p/h]);else{let e=(p-(h*m-f*p)/y*f)/h;l.push([t,e])}}return l}function Fr(e,t=.3){let i=new Map(Nr(e,t));return i.size<2?null:Cr().domain([...i.keys()]).range([...i.values()])}function Dr(e,t){if(e.length<3||e[0][0]===e[e.length-1][0])return null;let i="polynomial"===t.method?Ir(e,t.order??2):Lr(e);if(!i.points.length)return null;let r="loess"===t.method?Fr(e,t.bandwidth):i.predict;if(!r)return null;let{se:o}=Rr(e,r,i.parameterCount),n=Tr(t.confidence??.95),a=e[e.length-1][0],s=(a-e[0][0])/(e.length-1);return{predict:r,forecast:(e,t=a)=>!Number.isInteger(e)||e<=0?[]:Array.from({length:e},(e,a)=>{let l=t+(a+1)*s,c=r(l),u=o*n*Math.sqrt(1+i.leverage(l));return{x:l,y:c,upper:c+u,lower:c-u}})}}var Er="__forecastSegment",zr="__forecastOpacity";function Or(e,t,i,r){let o=t.uncertaintyOpacity,n=t.confidenceAccessor;if(!o&&!n)return;let a="object"==typeof o?o:{},s=a.min??.15,l=a.max??1;if(n){let t="function"==typeof n?n:e=>e[n];for(let i of e){let e=t(i);if(null!=e&&Number.isFinite(e)){let t=Math.max(0,Math.min(1,e));i[zr]=s+t*(l-s)}}return}let c=e.map(e=>{let t=i(e),o=r(e);return null!=t&&null!=o&&Number.isFinite(t)&&Number.isFinite(o)?Math.abs(t-o):NaN}),u=c.filter(e=>Number.isFinite(e));if(0===u.length)return;let[d,h]=Ce(u),f=h-d;e.forEach((e,t)=>{let i=c[t];if(!Number.isFinite(i))return;let r=f>0?(i-d)/f:0;e[zr]=l-r*(l-s)})}function jr(e,t){return"function"==typeof t?t(e):!!e[t]}function Wr(e){return[{type:"anomaly-band",threshold:e.threshold??2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:e.bandOpacity??.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:e.anomalyRadius??6,label:e.label}]}function Br(e,t,i,r,o){let{isTraining:n,isForecast:a,isAnomaly:s,upperBounds:l,lowerBounds:c,color:u="#6366f1",bandOpacity:d=.15,anomalyColor:h="#ef4444",anomalyRadius:f=6,label:p}=r,g=e.map(e=>{let t="observed";return a&&jr(e,a)?t="forecast":n&&jr(e,n)&&(t="training"),{...e,[Er]:t}}),m=[];for(let e=0;e<g.length;e++)m.push(g[e]),e<g.length-1&&g[e][Er]!==g[e+1][Er]&&(m.push({...g[e+1],[Er]:g[e][Er]}),m.push({...g[e],[Er]:g[e+1][Er]}));if(r.trainUnderline){let e=[];for(let t of m)"training"===t[Er]&&e.push({...t,[Er]:"training-base"});m.unshift(...e)}let y=[];if(l&&c){let e="string"==typeof l?l:"__envUpper",t="string"==typeof c?c:"__envLower";if("function"==typeof l||"function"==typeof c)for(let i of m)"function"==typeof l&&(i[e]=l(i)),"function"==typeof c&&(i[t]=c(i));y.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:u,fillOpacity:d,label:p})}if(r.uncertaintyOpacity||r.confidenceAccessor){let e=l?"function"==typeof l?l:e=>e[l]:()=>{},t=c?"function"==typeof c?c:e=>e[c]:()=>{};Or(m.filter(e=>"forecast"===e[Er]),r,e,t)}if(s){let e=r.anomalyStyle,t={type:"highlight",filter:e=>jr(e,s)};e?(t.style=e,t.r=f):"function"==typeof h?(t.style=e=>{let t=h(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=f):(t.color=h,t.r=f,t.style={stroke:h,strokeWidth:1.5,fill:h,fillOpacity:.7}),y.push(t)}return o&&y.push(...Wr(o)),{processedData:m,annotations:y}}function Yr(e,t,i,r,o){let{trainEnd:n,steps:a=10,color:s="#6366f1",bandOpacity:l=.15,label:c}=r;if(null===$r(n))return{processedData:e,annotations:[]};let u=[],d=[];for(let i of[...e].sort((e,i)=>($r(e[t])??1/0)-($r(i[t])??1/0))){let e=$r(i[t]);null!==e&&e<=n?u.push({...i,[Er]:"training"}):d.push({...i,[Er]:"observed"})}let h=_r(u.map(e=>[e[t],e[i]])),f=[],p=[];if(h.length>=3&&Number.isInteger(a)&&a>0){let o=Dr(h,r);if(o){let n=e.map(e=>$r(e[t])).filter(e=>null!==e),h=Fe(n),g=e.some(e=>e[t]instanceof Date);for(let{x:e,y:r,upper:n,lower:s}of o.forecast(a,h))p.push({...d[d.length-1]??u[u.length-1],[t]:g?new Date(e):e,[i]:r,[Er]:"forecast",__forecastUpper:n,__forecastLower:s});Or(p,r,e=>e.__forecastUpper,e=>e.__forecastLower),f.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:s,fillOpacity:l,label:c})}}f.push({type:"x-threshold",x:n,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),o&&f.push(...Wr(o));let g=[];if(g.push(...u),u.length>0&&d.length>0&&g.push({...u[u.length-1],[Er]:"observed"}),g.push(...d),p.length>0){let e=d.length>0?d[d.length-1]:u[u.length-1];e&&g.push({...e,[Er]:"forecast"}),g.push(...p)}return{processedData:g,annotations:f}}function Gr(e){return!!(e.isTraining||e.isForecast||e.isAnomaly||e.upperBounds||e.lowerBounds)}function Xr(e,t,i,r,o){let n=r._groupBy;if(n&&e.length){let a="function"==typeof n?n:e=>e[n],s=/* @__PURE__ */new Map;for(let t of e){let e=a(t),i=s.get(e);i?i.push(t):s.set(e,[t])}let l=[],c=[];for(let[e,n]of s){let s=Xr(n,t,i,{...r,_groupBy:void 0},o);for(let e of s.processedData)l.push(e);for(let t of s.annotations)if("x-threshold"===t.type)c.some(e=>"x-threshold"===e.type)||c.push(t);else{let i=t.filter;c.push({...t,filter:t=>{let r=a(t);return(r===e||Object.is(r,e))&&(!i||i(t))}})}}return{processedData:l,annotations:c}}return Gr(r)?Br(e,0,0,r,o):Yr(e,t,i,r,o)}function Vr(e,t){let i=t.trainDasharray??"8,4",r=t.forecastDasharray??"4,4",o=t.color||"#6366f1",n=t.trainOpacity,a=t.forecastOpacity,s=t.trainStroke,l=t.trainLinecap,c=t.trainUnderline;return t=>{let u=e(t),d=t[Er];if("training"===d){let e=u.stroke;return"darken"===s?e=Sr(u.stroke||"#666",.5):s&&(e=s),{...u,stroke:e,strokeDasharray:i,...l&&{strokeLinecap:l},...null!=n&&{strokeOpacity:n}}}if("training-base"===d){let e=u.stroke||"#666";return"lighten"===c&&(e=Mr(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===d){let e=t[zr]??a;return{...u,stroke:o,strokeDasharray:r,...null!=e&&{strokeOpacity:e}}}return u}}function qr(e,t,i){if(!i)return;let r=[t,i.upperBounds??"__forecastUpper",i.lowerBounds??"__forecastLower"].map(e=>"function"==typeof e?e:t=>t[e]),o=!(!i.upperBounds&&!i.lowerBounds),n=1/0,a=-1/0;for(let t of e){let e=r[1](t),i=r[2](t);(null!=e||null!=i)&&(o=!0);for(let o of[Number(r[0](t)),e,i])"number"==typeof o&&Number.isFinite(o)&&(n=Math.min(n,o),a=Math.max(a,o))}return o&&n<=a?[n,a]:void 0}var Hr="__semiotic_resolvedX",Ur="__semiotic_resolvedY",Zr="__compoundGroup";function Qr(e,t,i){let r="function"==typeof t,o="function"==typeof i,n=r?Hr:t,a=o?Ur:i;return r||o?{xKey:n,yKey:a,rows:e.map(e=>{let n={...e};return r&&(n[Hr]=t(e)),o&&(n[Ur]=i(e)),n})}:{rows:e,xKey:n,yKey:a}}function Kr(e,t,i){let r=e[t],o=e[i];return null==r||null==o||Number.isNaN(r)||Number.isNaN(o)}function Jr(e,t,i,r,o){let n=/* @__PURE__ */new Map;for(let t of e){let e=o?String(t[o]??""):"__single";n.has(e)||n.set(e,[]),n.get(e).push(t)}if("interpolate"===t){let e=[];for(let[,t]of n)for(let o of t)Kr(o,i,r)||e.push(o);return{rows:e,groupKey:o}}if("zero"===t){let e=[];for(let[,t]of n)for(let o of t)Kr(o,i,r)?e.push({...o,[r]:0}):e.push(o);return{rows:e,groupKey:o}}let a=[],s="_gapSegment";for(let[e,t]of n){let o=0,n=[],l=()=>{if(0===n.length)return;let t="__single"===e?`__seg${o}`:`${e}__seg${o}`;for(let e of n)a.push({...e,[s]:t});n=[],o++};for(let e of t)Kr(e,i,r)?l():n.push(e);l()}return{rows:a,groupKey:s}}function eo(e,t,i,r,o,n,a,s){if(!t||!i)return{annotations:[]};let l="object"==typeof t?t:{},c=l.position||"end",u=l.fontSize||11,d="function"==typeof i?i:e=>e[i],h=Vi(e.map(e=>({__lbl:String(d(e)??"")})),"__lbl",n??a),f=kr(e,{position:c,fontSize:u,colorBy:i,color:e=>h?h(e):s||zi},r,o),p=f.reduce((e,t)=>Math.max(e,Array.from(String(t.label)).length*(.65*u)),0)+10;return{annotations:f,marginExtra:"end"===c?{right:p}:{left:p}}}function to(e){let t=e.xAccessor||"x",i=e.yAccessor||"y",r=e.lineBy,o=e.colorBy||r,n=Array.isArray(e.data)?pi(e.data).filter(e=>!!e&&"object"==typeof e):[],a=Qr(n,t,i);n=a.rows;let s,l,c=a.xKey,u=a.yKey,d=Array.isArray(e.annotations)?[...e.annotations]:[],h="string"==typeof r||"function"==typeof r?r:void 0,f=e.baseLineStyle;if(e.forecast){let t=Xr(n,c,u,!r||"string"!=typeof r&&"function"!=typeof r?e.forecast:{...e.forecast,_groupBy:r},e.anomaly);if(n=t.processedData,d.push(...t.annotations),s=qr(n,u,e.forecast),!r||"string"!=typeof r&&"function"!=typeof r?h=Er:(n=n.map(e=>({...e,[Zr]:`${"function"==typeof r?r(e):e[r]}__${e[Er]||"observed"}`})),h=Zr),e.baseLineStyle){let t=Vr(t=>e.baseLineStyle(t),e.forecast);f=e=>t(e)}}else e.anomaly&&d.push(...Wr(e.anomaly));if(e.gapStrategy){if("function"==typeof h){let e=h;n=n.map(t=>({...t,__semiotic_gapGroup:e(t)})),h="__semiotic_gapGroup"}let t="string"==typeof h?h:void 0,i=Jr(n,e.gapStrategy,c,u,t);n=i.rows,i.groupKey&&(h=i.groupKey)}if(e.directLabel){let t=eo(n,e.directLabel,"string"==typeof o||"function"==typeof o?o:void 0,c,u,e.colorScheme,e.themeCategorical,e.color);d.push(...t.annotations),l=t.marginExtra}return{data:n,xAccessor:"function"==typeof t?c:t,yAccessor:"function"==typeof i?u:i,groupAccessor:h,colorAccessor:o,annotations:d,lineStyle:f,yExtent:s,marginExtra:l}}function io(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=xr(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrScatterColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrScatterColorBy:t(e)})):n,u=t?Vi(c,l,s):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[3,15],f=d?n.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?Ce(f):void 0,g=H(o.xAccessor,o.yAccessor),m=o.styleRules;return e=>{let i={fill:t&&u?Gi(e,t,u):"string"==typeof o.color?o.color:zi,fillOpacity:"number"==typeof o.pointOpacity?o.pointOpacity:.8,r:d?Hi(e,d,h,p):"number"==typeof o.pointRadius?o.pointRadius:5};return m?.length&&Object.assign(i,Z(e,m,g(e))),void 0!==o.stroke&&(i.stroke=o.stroke),void 0!==o.strokeWidth&&(i.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(i.opacity=o.opacity),i}}var ro={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=to({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:xr(r.theme).colors.categorical}),a=mr(n.annotations,o.regression);return{chartType:"scatter",data:n.data,xAccessor:n.xAccessor,yAccessor:n.yAccessor,colorAccessor:t,sizeAccessor:o.sizeBy,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...r,...a&&a.length>0&&{annotations:a},...n.yExtent&&!r.yExtent&&{yExtent:n.yExtent},sizeRange:o.sizeRange||[3,15],pointStyle:r.pointStyle||io(e,t,i,r,o),showLegend:r.showLegend??!!t}}};function oo(e,t){if(!t)return[];let i=/* @__PURE__ */new Set,r=[];for(let o of e){if(!o||"object"!=typeof o)continue;let e="function"==typeof t?t(o):o[t],n=String(e);i.has(n)||(i.add(n),r.push(n))}return r}function no(e,t,i,r){if(!i.categoryAccessor)return;let o=oo(e,i.categoryAccessor),n=i.colors,a="explicit-then-alpha"===r?[...Object.keys(n??{}).filter(e=>o.includes(e)),...o.filter(e=>!Object.hasOwn(n??{},e)).sort()]:o,s=xr(t.theme).colors.categorical,l=s?.length?s:ji;return Object.fromEntries(a.map((e,t)=>[e,n&&Xi(n,e)||i.fill||l[t%l.length]]))}var ao={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=mr(r.annotations,o.regression);return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[5,40],colorScheme:i,...r,...n&&{annotations:n},pointStyle:r.pointStyle||so(e,t,i,r,o),showLegend:r.showLegend??!!t}}};function so(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=xr(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrBubbleColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrBubbleColorBy:t(e)})):n,u=t?Vi(c,l,s):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[5,40],f=d?n.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?Ce(f):void 0,g=H(o.xAccessor,o.yAccessor),m=o.styleRules;return e=>{let i={fill:t&&u?Gi(e,t,u):"string"==typeof o.color?o.color:zi,fillOpacity:"number"==typeof o.bubbleOpacity?o.bubbleOpacity:.6,r:d?Hi(e,d,h,p):h[0],stroke:o.bubbleStrokeColor??"white",strokeWidth:o.bubbleStrokeWidth??1};return m?.length&&Object.assign(i,Z(e,m,g(e))),void 0!==o.stroke&&(i.stroke=o.stroke),void 0!==o.strokeWidth&&(i.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(i.opacity=o.opacity),i}}import{useMemo as lo,useCallback as co,useState as uo,useId as ho,useEffect as fo,useRef as po}from"react";var go="__semioticSelectionData";function mo(e,t){return t?.length&&Object.defineProperty(e,go,{configurable:!0,enumerable:!1,value:t}),e}function yo(e){return e?.[go]}function xo(e){return e.parentLine?mo({...e.parentLine,...e},yo(e)):e}function bo(e){return mo({...e[0]},e.map(xo))}function vo(e){return!!e&&yo(e)?.[0]===e}var wo=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ko(e){let t=new Date(e instanceof Date?e.valueOf():e);return`${wo[t.getUTCMonth()]} ${t.getUTCDate()}`}function Ao(e){let t=Math.abs(e[1]-e[0]);return t<864e5?e=>{let i=new Date(e instanceof Date?e.valueOf():e),r=`${String(i.getUTCHours()).padStart(2,"0")}:${String(i.getUTCMinutes()).padStart(2,"0")}`;return t<3e5&&(r+=`:${String(i.getUTCSeconds()).padStart(2,"0")}`),t<1e4&&(r+=`.${String(i.getUTCMilliseconds()).padStart(3,"0")}`),r}:t<3156e7?ko:t<1578e8?e=>{let t=new Date(e instanceof Date?e.valueOf():e);return`${wo[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>String(new Date(e instanceof Date?e.valueOf():e).getUTCFullYear())}function So(e,t){let i=t=>e[Math.max(0,Math.min(e.length-1,Math.round(Number(t))))],r=e.every(e=>"number"==typeof e||e instanceof Date),o=t?void 0:Mo(e);return(n,a,s)=>{if(0===e.length)return"";let l=i(n);return t?t(l,a,s&&r?s.map(e=>Number(i(e).valueOf())):void 0):l instanceof Date&&o?o(l):String(l)}}function Mo(e){let t=e.filter(e=>e instanceof Date&&Number.isFinite(e.valueOf()));if(0===t.length)return;let i=t.every(e=>e.valueOf()%864e5==0),r=i&&t.every(e=>1===e.getUTCDate());if(r&&t.every(e=>0===e.getUTCMonth()))return e=>String(e.getUTCFullYear());if(r)return e=>`${ko(e).split(" ")[0]} ${e.getUTCFullYear()}`;let o=t.map(e=>e.valueOf()),n=[Math.min(...o),Math.max(...o)];if(i){let e=new Date(n[0]).getUTCFullYear()===new Date(n[1]).getUTCFullYear();return t=>e?ko(t):`${ko(t)}, ${t.getUTCFullYear()}`}return Ao(n)}function $o(e,t,i){return"function"==typeof e?e(t,i):t[e]}function _o(e,t){if(!e?.length)return;let i=new Map(t.map((e,t)=>[Ut(e),t]));return e.map(e=>{let t={...e},r=r=>{if(!(r in e))return;let o=i.get(Ut(e[r]));void 0!==o&&(t[r]=o)};return r("x"),r("x0"),r("x1"),"string"==typeof e.type&&("x-threshold"===e.type||"x"===e.type)&&r("value"),t})}function Po(e){let t="number"==typeof e?e:"string"==typeof e&&""!==e.trim()?Number(e):NaN;return Number.isFinite(t)?Math.max(0,Math.floor(t)):void 0}function Lo(e){return"string"==typeof e&&""!==e.trim()?e:void 0}function Io(e){let{seriesOrder:t,overallOrder:i,highlightTop:r,color:o,colorScheme:n,neutralColor:a,themeCategorical:s,themeNeutral:l}=e;if(null==r&&null==o)return n;let c="string"==typeof n?[...Oi(n,s)]:n,u=null==r?i.length:Math.max(0,Math.floor(r)),d=new Set(i.slice(0,u)),h=/* @__PURE__ */new Map,f={};for(let e of t)Object.defineProperty(f,e,{configurable:!0,enumerable:!0,writable:!0,value:o??(d.has(e)?Ui(void 0,s,c,e,h):a??l??"#b8bec8")});return f}function Ro(e,t={}){let i=t.xAccessor??"x",r=t.yAccessor??"y",o=t.lineBy??"series",n=t.rankDirection??"descending",a=[],s=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map,c=[],u=/* @__PURE__ */new Map,d=1/0,h=-1/0;e.forEach((e,t)=>{let n=$o(i,e,t),f=Ut(n),p=s.get(f);null==p&&(p=a.length,s.set(f,p),a.push(n),l.set(p,[]));let g=String($o(o,e,t));u.has(g)||(u.set(g,c.length),c.push(g));let m=Number($o(r,e,t));Number.isFinite(m)&&(d=Math.min(d,m),h=Math.max(h,m),l.get(p)?.push({datum:e,inputIndex:t,series:g,value:m}))});let f=[],p=/* @__PURE__ */new Map,g=/* @__PURE__ */new Map;for(let e=0;e<a.length;e++){let t=l.get(e)??[];t.sort((e,t)=>("descending"===n?t.value-e.value:e.value-t.value)||(u.get(e.series)??0)-(u.get(t.series)??0)),t.forEach((t,i)=>{let r=i+1;f.push({datum:t.datum,xIndex:e,xValue:a[e],series:t.series,value:t.value,rank:r}),p.set(t.series,(p.get(t.series)??0)+r),g.set(t.series,(g.get(t.series)??0)+1)})}let m=c.length+1,y=[...c].sort((e,t)=>{let i=g.get(e)??0,r=g.get(t)??0;return((p.get(e)??0)+(a.length-i)*m)/Math.max(1,a.length)-((p.get(t)??0)+(a.length-r)*m)/Math.max(1,a.length)||(u.get(e)??0)-(u.get(t)??0)}),x=null==t.highlightTop?y.length:Math.max(0,Math.floor(t.highlightTop)),b=new Set(y.slice(0,x));return{data:f.map(e=>{let t=b.has(e.series);return{...e.datum,x:e.xIndex,y:e.rank,__bumpRaw:e.datum,__bumpSeries:e.series,__bumpColorGroup:t?e.series:"Other",__bumpValue:e.value,__bumpRank:e.rank,__bumpXValue:e.xValue,__bumpHighlighted:t}}),xValues:a,seriesOrder:c,overallOrder:y,valueExtent:d===1/0?[0,0]:[d,h]}}function To(e,t,i,r,o){let n=1-o;return n*n*n*e+3*n*n*o*t+3*n*o*o*i+o*o*o*r}function Co(e,t,i,r,o){let n=1-o;return 3*n*n*(t-e)+6*n*o*(i-t)+3*o*o*(r-i)}function No(e,t,i,r,o){let n=[],a=(e.x+t.x)/2;for(let s=0;s<=o;s++){let l,c,u,d,h=s/o;"linear"===r?(l=e.x+(t.x-e.x)*h,c=e.y+(t.y-e.y)*h,u=t.x-e.x,d=t.y-e.y):(l=To(e.x,a,a,t.x,h),c=To(e.y,e.y,t.y,t.y,h),u=Co(e.x,a,a,t.x,h),d=Co(e.y,e.y,t.y,t.y,h)),n.push({x:l,y:c,dx:u,dy:d,radius:e.radius+(t.radius-e.radius)*h,datumIndex:h<.5?i:i+1})}return n}function Fo(e,t){let i=e.length-1,r=Math.sign(e[i][0]-e[t][0])||1,o=r*e[i][0],n=r*e[t][0];for(let a=t+1;a<i;a++){let t=Math.max(n,Math.min(o,r*e[a][0]));e[a][0]=r*t,n=t}for(let r=t;r<i;r++){let t=r;for(;t<i&&e[t+1][0]===e[r][0];)t++;for(let i=r+1;i<t;i++)e[i][1]=e[r][1]+(e[t][1]-e[r][1])*(i-r)/(t-r);r=t}let a=1e-6*(o-r*e[t][0])/(i-t);n=r*e[t][0];for(let s=t+1;s<i;s++){let t=Math.max(n+a,Math.min(r*e[s][0],o-(i-s)*a));e[s][0]=r*t,n=t}}function Do(e,t={}){let i=[],r=[],o=[];if(e.length<2)return{topPath:i,bottomPath:r,datumIndices:o};let n=t.curve??"smooth",a=Math.max(2,Math.floor(t.samplesPerSegment??12));for(let t=0;t<e.length-1;t++){let s=Math.max(0,i.length-1),l=No(e[t],e[t+1],t,n,a);for(let e=0===t?0:1;e<l.length;e++){let t=l[e],n=Math.hypot(t.dx,t.dy)||1,a=-t.dy/n,s=t.dx/n,c=Math.max(0,t.radius);i.push([t.x+a*c,t.y+s*c]),r.push([t.x-a*c,t.y-s*c]),o.push(t.datumIndex)}Fo(i,s),Fo(r,s)}return{topPath:i,bottomPath:r,datumIndices:o}}var Eo={top:20,bottom:48,left:48},zo=[[/[mwMW@%…]/,.95],[/[ijlI'.,|\s]/,.28],[/[frt():;/[\]{}*`!\\-]/,.39]];function Oo(e,t){let i=0;for(let t of e)i+=(t.codePointAt(0)??0)>=11904?1.1:zo.find(([e])=>e.test(t))?.[1]??(t.toLowerCase()!==t?.75:.62);return i*t*1.05}function jo(e){let t=e.fontSize??12,i=!0===e.showLabels?"end":e.showLabels,r="end"===i||"both"===i||"auto"===i,o="start"===i||"both"===i,n=e.labels.reduce((e,i)=>Math.max(e,Oo(i,t)),0),a=Math.round(e.width*(e.maxSideFraction??.38)),s=Oo(String(Math.max(1,e.rankCount)),t),l=e.showAxes?8+s+6:8,c={start:l+4+(e.showAxes&&e.yLabel?24:0),end:12},u=e.legendSide?pt({legendGroups:[{label:"",styleFn:()=>({}),items:e.labels.map(e=>({label:e}))}]},{sideGutter:0}):0,d=Oo("MMM",t),h=(t,i)=>Math.min(i+n,e.legendSide===t?Math.max(i+d,a-u):a),f={start:o?h("left",c.start):0,end:r?h("right",c.end):0},p=!1===e.showLabels?24:110;return{margin:{...Eo,right:Math.max(p,f.end),left:Math.max(Eo.left,f.start)},startLabelOffset:l,chrome:c,room:f,labelWidth:n,fontSize:t,hasStart:o,hasEnd:r}}function Wo(e,t){let i={start:t.hasStart?Math.max(0,Math.min(e.left,t.room.start)-t.chrome.start):0,end:t.hasEnd?Math.max(0,Math.min(e.right,t.room.end)-t.chrome.end):0};return{budget:i,sideGutter:{...t.hasStart&&{left:t.chrome.start+Math.min(i.start,t.labelWidth)},...t.hasEnd&&{right:t.chrome.end+Math.min(i.end,t.labelWidth)}}}}function Bo(e,t,i){if(Oo(e,i)<=t)return{text:e,truncated:!1};let r=Array.from(e),o=r.length-1;for(;o>0&&Oo(`${r.slice(0,o).join("")}…`,i)>t;)o--;return{text:`${r.slice(0,o).join("").trimEnd()}…`,truncated:!0}}import{jsx as Yo,jsxs as Go}from"react/jsx-runtime";function Xo(e,t,i,r){let o=Math.max(1,Math.floor(t/18)),n="auto"===i?Number.isFinite(r)&&(r??0)>=0?Math.min(o,Math.floor(r)):o:1/0,a=e.map((e,t)=>({candidate:e,index:t})).sort((e,t)=>{let i=e.candidate.priority??0;return(t.candidate.priority??0)-i||Number(t.candidate.highlighted)-Number(e.candidate.highlighted)||e.candidate.rank-t.candidate.rank||e.index-t.index}),s=[];for(let{candidate:e}of a){if(s.length>=n)break;s.some(t=>t.side===e.side&&Math.abs(t.y-e.y)<14)||s.push(e)}return new Set(s.map(e=>e.id))}function Vo({datum:e,x:t,y:i,side:r,color:o,highlighted:n,labelStyle:a,offset:s,budget:l,fontSize:c}){let u=ne(),d=u.isActive&&!u.predicate(e),h="function"==typeof a?a(e.__bumpRaw):a,f=null==l?{text:e.__bumpSeries,truncated:!1}:Bo(e.__bumpSeries,l,c);/* */
2
+ return Go("text",{className:"semiotic-bump-label",x:t+("end"===r?s:-s),y:i,dy:"0.35em",textAnchor:"end"===r?"start":"end",fill:o,fillOpacity:d?.16:1,fontWeight:n?650:450,fontSize:12,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 12px)",...h},children:[f.truncated&&/* @__PURE__ */Yo("title",{children:e.__bumpSeries}),f.text]})}function qo(e){let t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}function Ho(e,t,i){let[r,o]=t,[n,a]=i;return o===r?(n+a)/2:n+(a-n)*Math.max(0,Math.min(1,(e-r)/(o-r)))}function Uo(e){let t=e.__bumpXValue instanceof Date?e.__bumpXValue.getTime():Number(e.__bumpXValue);return{value:e.__bumpValue,x:Number.isFinite(t)?t:void 0,y:e.__bumpValue,category:e.__bumpSeries}}function Zo(e){let t=e.config,i=/* @__PURE__ */new Map;for(let t of e.data){let e=i.get(t.__bumpSeries)??[];e.push(t),i.set(t.__bumpSeries,e)}let r=t.seriesOrder.filter(e=>i.has(e)).sort((e,r)=>(i.get(e)?.[0]?.__bumpHighlighted?1:0)-(i.get(r)?.[0]?.__bumpHighlighted?1:0)||t.seriesOrder.indexOf(e)-t.seriesOrder.indexOf(r)),o=[],n=[],a=[];for(let n of r){let r=(i.get(n)??[]).sort((e,t)=>e.x-t.x);if(r.length<2)continue;let s=r[0].__bumpHighlighted,l=(t.colorMap&&Xi(t.colorMap,n))??e.resolveColor(r[0].__bumpSeries,r[0]),c=t.color??(s?l:t.neutralColor??e.theme.semantic.textSecondary??e.theme.semantic.border??l),u=r.map(i=>({x:e.scales.x(i.x),y:e.scales.y(i.y),radius:t.ribbon?Ho(i.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),d=Do(u,{curve:t.curve,samplesPerSegment:t.samplesPerSegment}),h={fill:c,fillOpacity:1,opacity:s?t.ribbon?t.ribbonOpacity:t.lineOpacity:Math.min(t.ribbon?t.ribbonOpacity:t.lineOpacity,.58)};t.styleRules?.length&&Object.assign(h,Z(r[0].__bumpRaw,t.styleRules,Uo(r[0]))),t.areaStyle&&Object.assign(h,t.areaStyle(r[0].__bumpRaw)??{}),void 0!==t.stroke&&(h.stroke=t.stroke),void 0!==t.strokeWidth&&(h.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(h.opacity=t.opacity),o.push({type:"area",topPath:d.topPath,bottomPath:d.bottomPath,_hitArea:!0,style:h,datum:d.datumIndices.map(e=>r[e]),accessibleDatum:r.map(e=>e.__bumpRaw),accessibility:{label:`${n} ranking trajectory`,tableFields:r.map(e=>e.__bumpRaw)},group:n,interactive:!0}),t.showPoints&&r.forEach((e,i)=>{let r={fill:c,stroke:"none",opacity:s?1:.75};t.styleRules?.length&&Object.assign(r,Z(e.__bumpRaw,t.styleRules,Uo(e))),t.pointStyle&&Object.assign(r,t.pointStyle(e.__bumpRaw)??{}),void 0!==t.stroke&&(r.stroke=t.stroke),void 0!==t.strokeWidth&&(r.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(r.opacity=t.opacity),o.push({type:"point",x:u[i].x,y:u[i].y,r:r.r??t.pointRadius,style:r,datum:e,accessibleDatum:e.__bumpRaw,accessibility:{label:`${n}, rank ${e.__bumpRank}, value ${e.__bumpValue}`},pointId:`${n}:${e.x}`})});let f=!0===t.showLabels?"end":t.showLabels,p=(e,i,r)=>{let o=null==t.labelPriorityAccessor?void 0:"function"==typeof t.labelPriorityAccessor?t.labelPriorityAccessor(e.__bumpRaw):Number(e.__bumpRaw[t.labelPriorityAccessor]);a.push({id:`${n}\0${r}`,datum:e,x:u[i].x,y:u[i].y,side:r,rank:e.__bumpRank,highlighted:s,priority:Number.isFinite(o)?o:void 0,color:"string"==typeof h.fill?h.fill:c})};("start"===f||"both"===f)&&p(r[0],0,"start"),("end"===f||"both"===f||"auto"===f)&&p(r.at(-1),r.length-1,"end")}let s=!0===t.showLabels?"end":t.showLabels,l=Xo(a,e.dimensions.plot.height,"auto"!==s||"auto",t.maxLabels);for(let e of a)l.has(e.id)&&n.push(
3
+ /* @__PURE__ */Yo(Vo,{datum:e.datum,x:e.x,y:e.y,side:e.side,color:e.color,highlighted:e.highlighted,labelStyle:t.labelStyle,offset:"end"===e.side?8:t.startLabelOffset??8,budget:t.labelBudget?.[e.side],fontSize:t.labelFontSize??12},e.id));return{nodes:o,overlays:n.length?/* @__PURE__ */Yo("g",{className:"semiotic-bump-labels",children:n}):void 0,restyle:(e,t)=>{let i=qo(e);if(t?.isActive&&i&&!t.predicate(i))return{opacity:.14}}}}function Qo(e){return Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[]}function Ko(e){return{xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineBy:e.lineBy,rankDirection:e.rankDirection,highlightTop:Po(e.highlightTop)}}function Jo(e,t,i,r,o,n){let a=t.labelStyle,s=n.position??"right";return{legendSide:!0!==n.show||"left"!==s&&"right"!==s?void 0:s,labels:e,showLabels:t.showLabels??!0,width:i,showAxes:r,rankCount:e.length,yLabel:"string"==typeof o?o:"Rank",fontSize:"object"==typeof a&&"number"==typeof a?.fontSize?a.fontSize:12}}var en={frameType:"xy",layout:{modeDefaults:{showGrid:!0},margin:(e,t)=>{let{seriesOrder:i}=Ro(Qo(e.data),Ko(e));return jo(Jo(i,e,t.width,t.showAxes,e.yLabel,{show:e.showLegend,position:e.legendPosition})).margin}},buildProps:(e,t,i,r,o)=>{let n=Ro(Qo(e),Ko(o)),[a]=r.size??[600,400],s=jo(Jo(n.seriesOrder,o,a,!1!==r.showAxes,r.yLabel,{show:r.showLegend,position:r.legendPosition})),l=new Set(Array.isArray(r.__explicitMarginSides)?r.__explicitMarginSides:[]),c=r.margin,u={...c,...s.hasEnd&&!l.has("right")&&{right:Math.max(c.right,s.margin.right)},...s.hasStart&&!l.has("left")&&{left:Math.max(c.left,s.margin.left)}},d=Wo(u,s),h=r.legendPosition??"right",f=r.legendLayout,p=!0!==r.showLegend||"left"!==h&&"right"!==h?void 0:d.sideGutter[h],g=Math.max(1,n.seriesOrder.length),m=xr(r.theme),y=Io({seriesOrder:n.seriesOrder,overallOrder:n.overallOrder,highlightTop:Po(o.highlightTop),color:Lo(o.color),colorScheme:i,neutralColor:Lo(o.neutralColor),themeCategorical:m.colors.categorical,themeNeutral:m.colors.textSecondary}),x={ribbon:!0===o.ribbon,curve:"linear"===o.curve?"linear":"smooth",samplesPerSegment:"number"==typeof o.samplesPerSegment?o.samplesPerSegment:12,ribbonSizeRange:Array.isArray(o.ribbonSizeRange)?o.ribbonSizeRange:[4,28],valueExtent:n.valueExtent,seriesOrder:n.seriesOrder,lineWidth:"number"==typeof o.lineWidth?o.lineWidth:3,ribbonOpacity:"number"==typeof o.ribbonOpacity?o.ribbonOpacity:.82,lineOpacity:"number"==typeof o.lineOpacity?o.lineOpacity:.9,neutralColor:Lo(o.neutralColor),color:Lo(o.color),colorMap:y&&"object"==typeof y&&!Array.isArray(y)?y:void 0,stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0,styleRules:o.styleRules,areaStyle:r.areaStyle,pointStyle:r.pointStyle,labelStyle:o.labelStyle,showPoints:!0===o.showPoints,pointRadius:"number"==typeof o.pointRadius?o.pointRadius:3,showLabels:o.showLabels??!0,labelPriorityAccessor:o.labelPriorityAccessor,maxLabels:"number"==typeof o.maxLabels?o.maxLabels:void 0,startLabelOffset:s.startLabelOffset,labelBudget:d.budget,labelFontSize:s.fontSize},b=So(n.xValues,r.xFormat),v=n.xValues.map((e,t)=>t),w=Array.from({length:g},(e,t)=>t+1),k=r.axes??[{orient:"left",tickValues:w,tickFormat:e=>String(e),label:r.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:v,tickFormat:b,label:r.xLabel,tickAnchor:"edges"}];return{...r,margin:u,...null!=p&&null==f?.sideGutter&&{legendLayout:{...f,sideGutter:p}},chartType:"custom",data:n.data,xAccessor:"x",yAccessor:"y",xExtent:[0,Math.max(1,n.xValues.length-1)],yExtent:[g+.5,.5],customLayout:Zo,layoutConfig:x,colorAccessor:"__bumpSeries",colorScheme:y,xFormat:b,axes:k,axisExtent:"exact",showAxes:r.showAxes??!0,showLegend:r.showLegend??!1,annotations:_o(r.annotations,n.xValues)}}},tn="__ma_unitized",rn="__ma_series";function on(e,t,i){let r=Oi(t,i,Ei),o=t&&"object"==typeof t&&!Array.isArray(t)?t:null;return e.map((e,t)=>{if("string"==typeof e.color&&e.color.length>0)return e.color;let i=e.label||`Series ${t+1}`,n=o?.[i];return"string"==typeof n&&n.length>0?n:r[t%r.length]})}function nn(e,t){let i=q(e),r=t.map((e,t)=>({label:e.label||`Series ${t+1}`,readY:q(e.yAccessor)}));return(e,t)=>{let o=String(e[rn]??t??""),n=(r.find(e=>e.label===o)??r[0])?.readY(e);return{value:n,x:i(e),y:n,category:o||void 0}}}function an(e,t){let i="function"==typeof t?t:e=>Number(e[t||"y"]),r=1/0,o=-1/0;for(let t of e){let e=i(t);"number"==typeof e&&Number.isFinite(e)&&(e<r&&(r=e),e>o&&(o=e))}if(!Number.isFinite(r)||!Number.isFinite(o))return[0,1];if(r===o){let e=0===r?1:.1*Math.abs(r);return[r-e,o+e]}return[r,o]}var sn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Array.isArray(o.series)?o.series:[],s=on(a,i,xr(r.theme).colors.categorical),l=2===a.length,c=a.map(e=>e.extent||an(n,e.yAccessor)),u=[];for(let e of n)a.forEach((t,i)=>{let r=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(e);if(null==r||!Number.isFinite(Number(r)))return;let o=Number(r),n=c[i],a=n[1]-n[0]||1;u.push({...e,[tn]:l?(o-n[0])/a:o,[rn]:t.label||`Series ${i+1}`})});let d=(e,t)=>i=>{let r=e[0]+i*(e[1]-e[0]);return"function"==typeof t?t(r):Number.isInteger(r)?String(r):r.toFixed(1)},h=l?[{orient:"left",label:a[0].label,tickFormat:d(c[0],a[0].format)},{orient:"right",label:a[1].label,tickFormat:d(c[1],a[1].format)},{orient:"bottom"}]:void 0,f=/* @__PURE__ */new Map;a.forEach((e,t)=>{f.set(e.label||`Series ${t+1}`,s[t])});let p=Qi(Ki({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,resolveStroke:e=>f.get(String(e[rn]??""))||s[0],styleRules:o.styleRules,ruleContext:nn(o.xAccessor,a)}),{stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0});return{chartType:"line",data:u,xAccessor:o.xAccessor||"x",yAccessor:tn,groupAccessor:rn,colorAccessor:rn,...h&&{axes:h},...l&&{yExtent:[0,1]},...r,curve:o.curve||r.curve||"monotoneX",showLegend:r.showLegend??!0,colorScheme:s,lineStyle:p}}},ln={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=o.xAccessor||"x",s="function"==typeof a?a:e=>e[a],l=n.some(e=>{let t=s(e);return!("number"==typeof t&&Number.isFinite(t)||t instanceof Date)}),c=l?n.map((e,t)=>({...e,__waterfallX:t,__waterfallTick:String(s(e)??t)})):n,u=o.styleRules?Q(void 0,o.styleRules,H(o.xAccessor,o.yAccessor)):void 0,d=u?e=>{let t=u(e),i="function"==typeof r.areaStyle?r.areaStyle(e):r.areaStyle;return i?{...t,...i}:t}:void 0;return{chartType:"waterfall",data:c,xAccessor:l?"__waterfallX":a,yAccessor:o.yAccessor||"y",waterfallStyle:{positiveColor:o.positiveColor,negativeColor:o.negativeColor,connectorStroke:o.connectorStroke,connectorWidth:o.connectorWidth,gap:o.gap,stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity},...r,...d&&{areaStyle:d},...l&&{axes:r.axes??[{orient:"bottom",tickValues:c.map((e,t)=>t)}],xFormat:e=>{let t=n[Number(e)]?s(n[Number(e)]):e,i=o.xFormat??r.xFormat;return"function"==typeof i?i(t):String(t??e)}}}}};function cn(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=xr(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrLineColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrLineColorBy:t(e)})):n,u=t?Vi(c,l,s):void 0,d=H(o.xAccessor,o.yAccessor);return Qi(Ki({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,colorBy:t,colorScale:u,color:"string"==typeof o.color?o.color:void 0,fillArea:o.fillArea,areaOpacity:"number"==typeof o.areaOpacity?o.areaOpacity:.3,styleRules:o.styleRules,ruleContext:d}),{stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0})}function un(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=xr(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrAreaColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrAreaColorBy:t(e)})):n,u=t?Vi(c,l,s):void 0,d=!1!==o.showLine,h="number"==typeof o.lineWidth?o.lineWidth:2,f="number"==typeof o.areaOpacity?o.areaOpacity:.7,p=q(o.yAccessor),g=o.styleRules;return(e,i)=>{let r=t&&u?Gi(e,t,u):"string"==typeof o.color?o.color:zi,n={fill:r,fillOpacity:f,stroke:d?r:"none",...d&&{strokeWidth:h}};return g?.length&&Object.assign(n,Z(e,g,{value:p(e),category:i})),void 0!==o.stroke&&(n.stroke=o.stroke),void 0!==o.strokeWidth&&(n.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(n.opacity=o.opacity),n}}function dn(e,t,i,r,o){if(!o.showPoints)return;let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=xr(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrPointColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrPointColorBy:t(e)})):n,u=t?Vi(c,l,s):void 0,d="number"==typeof o.pointRadius?o.pointRadius:3;return e=>{let i=t&&u?Gi(e,t,u):"string"==typeof o.color?o.color:zi;return{r:d,fill:i,stroke:"none"}}}var hn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=t||o.lineBy,a=o.fillArea,s=Array.isArray(a)?"mixed":a?"area":"line",l=xr(r.theme).colors.categorical,c=cn(e,n,i,r,o),u=to({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.lineBy,colorBy:n,colorScheme:i,color:"string"==typeof o.color?o.color:void 0,forecast:o.forecast,anomaly:o.anomaly,gapStrategy:o.gapStrategy,directLabel:o.directLabel,annotations:r.annotations,themeCategorical:l,baseLineStyle:c}),d=r.pointStyle||dn(u.data,u.colorAccessor,i,r,o),h=r.margin,f=new Set(Array.isArray(r.__explicitMarginSides)?r.__explicitMarginSides:[]);u.marginExtra&&h&&"object"==typeof h?h={...h,...null!=u.marginExtra.right&&!f.has("right")&&{right:Math.max(Number(h.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&!f.has("left")&&{left:Math.max(Number(h.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==h&&(h={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});let p=(!o.directLabel||void 0!==r.showLegend)&&(r.showLegend??!!u.colorAccessor);return{chartType:s,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:i,lineStyle:u.lineStyle||c,...Array.isArray(a)&&{areaGroups:a},...a&&null!=o.areaOpacity&&{areaOpacity:o.areaOpacity},...null!=o.band&&{band:o.band},...r,...void 0!==h&&{margin:h},annotations:u.annotations,...u.yExtent&&!r.yExtent&&{yExtent:u.yExtent},...d&&{pointStyle:d},showLegend:p}}},fn={frameType:"xy",layout:{margin:(e,t)=>wr(t.marginDefaults,vr(e),t.showAxes,!!t.title)},buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?pi(e):[],a=o.timeAccessor||"time",s=o.valueAccessor||"value",l=o.categoryAccessor,c=no(n,r,o,"explicit-then-alpha"),u=o.valueExtent||r.yExtent,d={...gr(o),...void 0!==o.cursor&&{cursor:o.cursor}},h={...d,...void 0!==o.fill&&{fill:o.fill},...void 0!==o.gap&&{gap:o.gap},...Array.isArray(o.valueBands)&&{valueBands:o.valueBands}},f=Q(void 0,o.styleRules,e=>{let t=e.categoryValue??e.total,i="number"==typeof t&&Number.isFinite(t)?t:void 0,r=Number(e.binStart),o=Number(e.binEnd);return{value:i,x:Number.isFinite(r)&&Number.isFinite(o)?(r+o)/2:void 0,y:i,category:null==e.category?void 0:String(e.category)}});return{chartType:"bar",data:n,...r,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,n.length),arrowOfTime:o.arrowOfTime||"right",timeAccessor:e=>ui(e,a,"time")??NaN,valueAccessor:e=>ci(e,s,"value")??NaN,xExtent:o.timeExtent||r.xExtent,yExtent:u,invertY:"down"===o.direction,axes:vr({...o,axes:r.axes??o.axes}),extentPadding:o.extentPadding??r.extentPadding,binSize:o.binSize,binAlign:o.binAlign,categoryAccessor:l,barColors:c||r.barColors,colorScheme:c||r.colorScheme,barStyle:r.barStyle||h,areaStyle:r.areaStyle||(e=>({...f(e),...!l&&void 0!==o.fill&&{fill:o.fill},...d})),showLegend:r.showLegend??!!l}}},pn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=t||o.areaBy,a=to({data:Array.isArray(e)?pi(e):[],xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.areaBy,forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:xr(r.theme).colors.categorical}),s=hi({data:e,safeData:a.data,areaBy:o.areaBy,lineDataAccessor:o.lineDataAccessor||"coordinates"}),l=sr(o.semanticGradient),c=l?.stops.length?ur(l):nr(r.gradientFill),u=!1!==o.semanticLine?lr(l):void 0,d=r.pointStyle||dn(s,n,i,r,o);return{chartType:"area",data:s,xAccessor:a.xAccessor,yAccessor:a.yAccessor,y0Accessor:o.y0Accessor,groupAccessor:o.areaBy||void 0,colorAccessor:n,colorScheme:i,...r,...a.annotations.length>0&&{annotations:a.annotations},...a.yExtent&&!r.yExtent&&{yExtent:a.yExtent},...void 0!==c&&{gradientFill:c},...u&&{semanticLineStops:u},lineStyle:r.lineStyle||un(s,n,i,r,o),...d&&{pointStyle:d}}}},gn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=o.xAccessor||"x",a=o.seriesAAccessor||"a",s=o.seriesBAccessor||"b",l=e=>fr(hr(n,"x",e)),c=e=>fr(hr(a,"a",e)),u=e=>fr(hr(s,"b",e)),d=o.seriesAColor||"var(--semiotic-danger, #dc2626)",h=o.seriesBColor||"var(--semiotic-info, #2563eb)",f=o.areaOpacity??.6,p=o.lineWidth??1.5,g=!1!==o.showLines,m=!1!==r.showLegend,y=o.seriesALabel||"A",x=o.seriesBLabel||"B",b=r.legendPosition||"right",v=Ji(Array.isArray(e)?e:[],l,c,u),w=[];if(g&&Array.isArray(e)){let t=e.filter(e=>Number.isFinite(l(e))).sort((e,t)=>l(e)-l(t));for(let e of t){let t=l(e),i=c(e),r=u(e);Number.isFinite(i)&&w.push({__x:t,__y:i,__diffSegment:"line-A",__diffWinner:"A",__sourceDatum:e}),Number.isFinite(r)&&w.push({__x:t,__y:r,__diffSegment:"line-B",__diffWinner:"B",__sourceDatum:e})}}return{chartType:"mixed",data:[...v,...w],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(v.map(e=>e.__diffSegment))),areaStyle:ir({seriesAColor:d,seriesBColor:h,areaOpacity:f,styleRules:o.styleRules}),lineStyle:rr({seriesAColor:d,seriesBColor:h,lineWidth:p,styleRules:o.styleRules}),curve:o.curve||"linear",...r,...m&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:y,color:d},{label:x,color:h}]}]},legendPosition:b}}}},mn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=t||o.areaBy,a="string"==typeof n&&Array.isArray(e)?Vi(e,n,i):void 0,s="number"==typeof o.areaOpacity?o.areaOpacity:.7,l=r.lineStyle||(e=>{let t=null==n?void 0:Gi(e,n,a),i=o.showLine??!0,r=o.stroke??t,l=o.strokeWidth??o.lineWidth??2,c={fill:o.color??t,stroke:i?r:"none",...i?{strokeWidth:l}:{},fillOpacity:s,...null==o.opacity?{}:{opacity:o.opacity}},u=o.styleRules;if(u?.length){let t=q(o.yAccessor),i=n?String("function"==typeof n?n(e)??"":e[n]??""):void 0;Object.assign(c,Z(e,u,{value:t(e),category:i}))}return c}),c=o.normalize?"zero":o.baseline??"zero",u=r.pointStyle||dn(e,n,i,r,o);return{chartType:"stackedarea",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:n,colorScheme:i,normalize:o.normalize,baseline:c,stackOrder:o.stackOrder,lineStyle:l,...r,...u&&{pointStyle:u},curve:r.curve??o.curve??"monotoneX",showLegend:r.showLegend??!!n}}},yn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let[n]=r.size??[600,400];return{chartType:"candlestick",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.highAccessor||"high",highAccessor:o.highAccessor||"high",lowAccessor:o.lowAccessor||"low",openAccessor:o.openAccessor,closeAccessor:o.closeAccessor,candlestickStyle:o.candlestickStyle,...r,...!r.pointStyle&&Array.isArray(o.styleRules)&&o.styleRules.length>0&&{pointStyle:Q(void 0,o.styleRules,H(o.xAccessor||"x",o.closeAccessor||o.highAccessor||"high"))},scalePadding:r.scalePadding??Math.max(2,Math.min(12,Math.round(n/40))),extentPadding:r.extentPadding??(n<=200?.02:.1)}}},xn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=o.xCenter,a=o.yCenter,s=o.quadrants,l=o.centerlineStyle||{},c=!1!==o.showQuadrantLabels,u=o.quadrantLabelSize??12,d=l.stroke||"#999",h=l.strokeWidth??1,f=Array.isArray(l.strokeDasharray)?l.strokeDasharray.join(","):l.strokeDasharray,p=di.createElement,g=s?[(e,t,i)=>{if(!t?.x||!t?.y)return null;let r=i.width,o=i.height,l=null!=n?t.x(n):r/2,g=null!=a?t.y(a):o/2;if(null!=n&&!Number.isFinite(l)||null!=a&&!Number.isFinite(g))return null;let m=Math.max(0,Math.min(r,l)),y=Math.max(0,Math.min(o,g)),x=[{c:s.topLeft,x:0,y:0,w:m,h:y},{c:s.topRight,x:m,y:0,w:r-m,h:y},{c:s.bottomLeft,x:0,y:y,w:m,h:o-y},{c:s.bottomRight,x:m,y:y,w:r-m,h:o-y}],b=c?[p("text",{key:"ltl",x:8,y:8+u,fill:s.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},s.topLeft.label),p("text",{key:"ltr",x:r-8,y:8+u,fill:s.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},s.topRight.label),p("text",{key:"lbl",x:8,y:o-8,fill:s.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},s.bottomLeft.label),p("text",{key:"lbr",x:r-8,y:o-8,fill:s.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},s.bottomRight.label)]:[];return p(di.Fragment,null,...x.map((e,t)=>e.w>0&&e.h>0?p("rect",{key:`qf-${t}`,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.c.color,opacity:e.c.opacity??.08}):null),p("line",{key:"vc",x1:m,y1:0,x2:m,y2:o,stroke:d,strokeWidth:h,strokeDasharray:f}),p("line",{key:"hc",x1:0,y1:y,x2:r,y2:y,stroke:d,strokeWidth:h,strokeDasharray:f}),...b)}]:void 0;return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[3,15],colorScheme:i,pointStyle:r.pointStyle||o.pointStyle||io(e,t,i,r,o),...r,showLegend:r.showLegend??!!t,...g&&{svgPreRenderers:g}}}},bn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=yr(e,o),a=to({data:n.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:xr(r.theme).colors.categorical}),s=mr(a.annotations,o.regression),l=o.pointRadius??4,c=H(o.xAccessor,o.yAccessor),u=o.styleRules,d=[e=>{let t=e.filter(e=>"point"===e.type&&"number"==typeof e.x&&"number"==typeof e.y);if(t.length<2)return null;let i=[];for(let e=0;e<t.length-1;e++){let r=t[e],o=t[e+1],n=pr(e,t.length);t.length<100&&i.push(di.createElement("line",{key:`halo-${e}`,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:"white",strokeWidth:l+2,strokeLinecap:"round",opacity:.5})),i.push(di.createElement("line",{key:`segment-${e}`,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:n,strokeWidth:l,strokeLinecap:"round"}))}return di.createElement(di.Fragment,null,...i)}];return{chartType:"scatter",data:a.data,xAccessor:a.xAccessor,yAccessor:a.yAccessor,colorAccessor:t,colorScheme:i,pointStyle:Qi(e=>{let t=n.orderMap.get(e),i=t?.idx??0,r=t?.total??1,o={fill:r>0?pr(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:l,fillOpacity:1};return u?.length&&Object.assign(o,Z(e,u,c(e))),o},gr(o)),...r,...s&&s.length>0&&{annotations:s},...a.yExtent&&!r.yExtent&&{yExtent:a.yExtent},svgPreRenderers:d}}};function vn(e,t,i){let r=q(e),o=q(t),n=q(i);return e=>{let t="string"==typeof e.agg&&"number"==typeof e.count&&"number"==typeof e.xCenter&&"number"==typeof e.yCenter;return{value:t?wn(e.value):n(e),x:t?wn(e.xCenter):r(e),y:t?wn(e.yCenter):o(e)}}}function wn(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}var kn={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=o.frameProps&&"object"==typeof o.frameProps?o.frameProps:void 0,a=Number.isFinite(o.cellBorderWidth)?Math.max(0,o.cellBorderWidth):1,s=Q(()=>({stroke:o.cellBorderColor??"#fff",strokeWidth:a}),o.styleRules,vn(o.xAccessor,o.yAccessor,o.valueAccessor)),l=("string"==typeof n?.colorScheme?n.colorScheme:void 0)??i,c=null!=n&&Object.hasOwn(n,"heatmapColorScale"),u=n?.heatmapColorScale,d=c?"function"==typeof u?u:void 0:"custom"===l&&"function"==typeof o.customColorScale?o.customColorScale:void 0;return{chartType:"heatmap",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,showValues:o.showValues,heatmapValueFormat:o.valueFormat,...o.heatmapAggregation&&{heatmapAggregation:o.heatmapAggregation},...null!=o.heatmapXBins&&{heatmapXBins:o.heatmapXBins},...null!=o.heatmapYBins&&{heatmapYBins:o.heatmapYBins},areaStyle:s,...r,...void 0!==l&&{colorScheme:l},...d&&{heatmapColorScale:d}}}};import*as An from"react-dom/server";import*as Sn from"react";import*as Mn from"react-dom/server";var $n=class{constructor(e){if(this._capacity=e,this.head=0,this._size=0,e<1)throw new Error("RingBuffer capacity must be at least 1");this.buffer=new Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){let t=[];for(let i of e){let e=this.push(i);void 0!==e&&t.push(e)}return t}get(e){if(e<0||e>=this._size)return;let t=(this.head-this._size+e+this._capacity)%this._capacity;return this.buffer[t]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;return{next:()=>e>=this._size?{done:!0,value:void 0}:{done:!1,value:this.get(e++)}}}forEach(e){let t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;i<this._size;i++)e(this.buffer[(t+i)%this._capacity],i)}toArray(){let e=new Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;i<this._size;i++)e[i]=this.buffer[(t+i)%this._capacity];return e}resize(e){if(e<1)throw new Error("RingBuffer capacity must be at least 1");let t=this.toArray(),i=0,r=[];t.length>e&&(i=t.length-e,r=t.slice(0,i)),this._capacity=e,this.buffer=new Array(e),this.head=0,this._size=0;for(let e=i;e<t.length;e++)this.push(t[e]);return r}update(e,t){let i=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;o<this._size;o++){let n=(r+o)%this._capacity,a=this.buffer[n];if(e(a)){let e;e="object"!=typeof a||null===a?a:Array.isArray(a)?[...a]:{...a},i.push(e),this.buffer[n]=t(a)}}return i}remove(e){let t=[],i=[];if(this.forEach(r=>{e(r)?i.push(r):t.push(r)}),0===i.length)return i;this.buffer=new Array(this._capacity),this.head=0,this._size=0;for(let e of t)this.push(e);return i}clear(){this.buffer=new Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},_n=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(e<this._min&&(this._min=e),e>this._max&&(this._max=e))}evict(e){(e===this._min||e===this._max)&&(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(let i of e){let e=t?t(i):i;Number.isFinite(e)&&(e<this._min&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function Pn(e){return new Set(Array.isArray(e)?e:[e])}function Ln(e,t,i){if(null!=e)return"function"==typeof e?e(t,i):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}function In(e){let t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||e.extent<=0)return 1;let i=Math.max(0,e.age);if("step"===e.type)return i<(e.threshold??.5*e.extent)?1:t;if("exponential"===e.type){let r=e.halfLife??e.extent/2,o=r>0?r:e.extent/2;return t+Math.pow(.5,i/o)*(1-t)}return t+Math.max(0,Math.min(1,1-i/e.extent))*(1-t)}function Rn(e,t,i){if(i<=1)return 1;let r=i-1;return In({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??i/2,threshold:e.stepThreshold??.5*i,minOpacity:e.minOpacity??.1})}function Tn(e){let t=/* @__PURE__ */new Map;for(let i=0;i<e.length;i++)t.set(e[i],i);return t}function Cn(e,t,i,r=Tn(i)){let o=i.length;if(!(o<=1))for(let i of t){if("line"===i.type){let t=Array.isArray(i.datum)?i.datum:[];if(t.length<2)continue;let n=new Array(t.length),a=!1;for(let i=0;i<t.length;i++){let s=r.get(t[i]);null!=s?(n[i]=Rn(e,s,o),n[i]<1&&(a=!0)):n[i]=1}a&&(i._decayOpacities=n);continue}if("area"===i.type){let t=Array.isArray(i.datum)?i.datum:[],n=i.topPath?i.topPath.length:t.length;if(n<2)continue;if(t.length===n){let a=new Array(n),s=!1;for(let i=0;i<t.length;i++){let n=r.get(t[i]);null!=n?(a[i]=Rn(e,n,o),a[i]<1&&(s=!0)):a[i]=1}s&&(i._decayOpacities=a)}else{let a=1;for(let i of t){let t=r.get(i);if(null!=t){let i=Rn(e,t,o);i<a&&(a=i)}}if(a<1){let e=new Array(n);e.fill(a),i._decayOpacities=e}}continue}let t=r.get(i.datum);if(null==t)continue;let n=Rn(e,t,o);if("candlestick"===i.type)i._decayOpacity=n;else{let e=i.style?.opacity??1;i.style={...i.style,opacity:e*n}}}}function Nn(e,t,i){let r=e.duration??500,o=i-t;return o>=r?0:1-o/r}function Fn(e,t,i,r,o,n=(typeof performance<"u"?performance.now():Date.now())){let a=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4,l=!1,c=o??(()=>{let e=/* @__PURE__ */new Map;for(let t=0;t<i.length;t++)e.set(i[t],t);return e})();for(let i of t){if("line"===i.type)continue;if("area"===i.type){let t=Array.isArray(i.datum)?i.datum:[i.datum],o=0,s=!1;for(let i of t){let t=c.get(i);if(null==t)continue;s=!0;let a=r.get(t);if(null==a)continue;let l=Nn(e,a,n);l>o&&(o=l)}s&&(l=Dn(i,o,a)||l);continue}let t=c.get(i.datum);if(null==t)continue;let o=r.get(t);l=Dn(i,null==o?0:Nn(e,o,n),a,s)||l}return l}function Dn(e,t,i,r){let o=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,o=!0),e._pulseColor!==i&&(e._pulseColor=i,o=!0),e._pulseGlowRadius!==r&&(e._pulseGlowRadius=r,o=!0),o):(0!==e._pulseIntensity&&(e._pulseIntensity=0,o=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,o=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,o=!0),o)}function En(e,t,i=(typeof performance<"u"?performance.now():Date.now())){if(!t||0===t.size)return!1;let r=e.duration??500,o=t.peek();return null!=o&&i-o<r}var zn=null;function On(){return zn}var jn=/* @__PURE__ */Object.create(null);function Wn(e){jn[e.chartType]=e}function Bn(e){return jn[e]}function Yn(e){return Array.isArray(e)?{nodes:e,binBoundaries:[]}:{nodes:e.nodes,binBoundaries:e.binBoundaries}}var Gn=typeof window>"u"||typeof document>"u",Xn=/* @__PURE__ */new Set;function Vn(e){Bn(e)||Gn&&(Xn.has(e)||(Xn.add(e),console.warn(`[semiotic] StreamXYFrame: no XY plugin registered for "${e}" during SSR. Import a chart HOC, or call registerBuiltInXYPlugins() from "semiotic/xy" or "semiotic/realtime/core" before render.`)))}function qn(e){if("production"===process.env.NODE_ENV)return;let{label:t,nodes:i,overlays:r,warned:o}=e;Hn(r)&&0===i.length&&Un(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),i.length>0&&i.every(e=>null==e.datum)&&Un(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function Hn(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(Hn))}function Un(e,t,i){e.has(t)||(e.add(t),console.warn(i))}function Zn(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:String(e)}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}function Qn(e,t,i,r){let o=Zn(t),n="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:n,message:`Semiotic ${e} ${n} failed: ${o.message}`,error:o,recovery:i?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:i,affectedRevision:r}}function Kn(e){try{return{kind:"success",result:e.run()}}catch(t){let i=e.hasPreviousResult,r=Qn(e.family,t,i,e.revision);"production"!==process.env.NODE_ENV&&console.error(`[semiotic] ${e.logLabel} threw:`,t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,preservedLastGoodScene:i}}}function Jn(e,t){let i="function"==typeof e?e:i=>i[e||t];return e=>{let t=i(e);return null==t?Number.NaN:+t}}function ea(e){let t=[],i=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=Jn(i&&e.valueAccessor||e.yAccessor,i?"value":"y");if(e.boundsAccessor){let i=y(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{let t=r(e);if(!Number.isFinite(t))return Number.NaN;let o=i(e);return Number.isFinite(o)&&0!==o?t+o:t},getBottom:e=>{let t=r(e);if(!Number.isFinite(t))return Number.NaN;let o=i(e);return Number.isFinite(o)&&0!==o?t-o:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){let i=Array.isArray(e.band)?e.band:[e.band];for(let e of i)t.push({kind:"band",getTop:Jn(e.y1Accessor,"y1"),getBottom:Jn(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}import{scaleLinear as ta,scaleLog as ia,scaleSymlog as ra,scaleTime as oa,scaleUtc as na}from"d3-scale";function aa(e,t,i="start"){let r="center"===i?t/2:0;return Math.floor((e+r)/t)*t-r}function sa(e,t,i,r,o,n=!1,a="start"){let s=/* @__PURE__ */new Map;for(let l of e){let e=t(l),c=i(l);if(null==e||null==c||Number.isNaN(e)||Number.isNaN(c))continue;let u=aa(e,r,a),d=s.get(u);if(d||(d={start:u,end:u+r,total:0,categories:/* @__PURE__ */new Map,...n?{rows:[],categoryRows:/* @__PURE__ */new Map}:{}},s.set(u,d)),d.total+=c,d.rows?.push(l),o){let e=o(l);if(d.categories.set(e,(d.categories.get(e)||0)+c),d.categoryRows){let t=d.categoryRows.get(e);t||(t=[],d.categoryRows.set(e,t)),t.push(l)}}}return s}function la(e,t,i,r,o,n="start"){let a=sa(e,t,i,r,o,!1,n);if(0===a.size)return[0,0];let s=0;for(let e of a.values())e.total>s&&(s=e.total);return[0,s]}function ca(e,t){let i=0,r=0,o=0;for(let n of e){let e=t(n);null==e||Number.isNaN(e)||(o+=e,o<i&&(i=o),o>r&&(r=o))}return[i,r]}function ua(e,t,i,r,o,n){let a=[];for(let n of e){let e=i(n),s=r(n),l=o?o(n):0;if(!Number.isFinite(e)||!Number.isFinite(s)||!Number.isFinite(l))continue;let c=t.x(e),u=t.y(s),d=o?t.y(l):0;!Number.isFinite(c)||!Number.isFinite(u)||!Number.isFinite(d)||a.push({x:c,y:u,bottom:d,raw:s,datum:n})}a.sort((e,t)=>e.x-t.x);let s=new Array(a.length),l=o?new Array(a.length):[],c=new Array(a.length),u=new Array(a.length),d=n?new Array(a.length):void 0;for(let e=0;e<a.length;e++){let t=a[e];s[e]=[t.x,t.y],o&&(l[e]=[t.x,t.bottom]),c[e]=t.raw,u[e]=t.datum,d&&n&&(d[e]=String(n(t.datum)))}return d?{topPath:s,bottomPath:l,rawValues:c,datum:u,pathIds:d}:{topPath:s,bottomPath:l,rawValues:c,datum:u}}function da(e,t,i,r,o,n,a){let{topPath:s,rawValues:l,datum:c,pathIds:u}=ua(e,t,i,r,void 0,a),d={type:"line",path:s,rawValues:l,style:o,datum:c,group:n};return u&&(d.pathIds=u),d}function ha(e,t,i,r,o,n,a,s,l){return{type:"area",...ua(e,t,i,r,s??(()=>o),l),style:n,group:a}}function fa(e,t,i,r){let o=/* @__PURE__ */new Map;if("silhouette"===r)for(let r of e){let e=0;for(let o of t)e+=i(o,r)||0;o.set(r,-e/2)}else if("wiggle"===r){e.length>0&&o.set(e[0],0);for(let r=1;r<e.length;r++){let n=e[r-1],a=e[r],s=0,l=0,c=0;for(let e of t){let t=i(e,a)||0;s+=(2*c+t)*(t-(i(e,n)||0)),l+=t,c+=t}let u=o.get(n)??0,d=l>0?s/(2*l):0;o.set(a,u-d)}if(e.length>0){let r=0;for(let n of e){let e=0;for(let r of t)e+=i(r,n)||0;r+=(o.get(n)??0)+e/2}let n=r/e.length;for(let t of e)o.set(t,(o.get(t)??0)-n)}}else for(let t of e)o.set(t,0);return o}function pa(e,t,i){let r=0,o=0;for(let n of e){let e=0,a=0;for(let r of t){let t=i(r,n)||0;t>=0?e+=t:a+=t}a<r&&(r=a),e>o&&(o=e)}return[r,o]}function ga(e,t,i,r,o,n,a,s="zero",l){let c=/* @__PURE__ */new Set,u=/* @__PURE__ */new Map;for(let t of e){let e=/* @__PURE__ */new Map;for(let o of t.data){let t=i(o),n=r(o);if(!Number.isFinite(t)||(c.add(t),!Number.isFinite(n)))continue;let a=e.get(t);a?(a.value+=n,a.sources?a.sources.push(o):a.sources=[a.datum,o]):e.set(t,{value:n,datum:o})}u.set(t.key,e)}let d,h=Array.from(c).sort((e,t)=>e-t);if(n){d=/* @__PURE__ */new Map;for(let t of h){let i=0;for(let r of e)i+=u.get(r.key)?.get(t)?.value||0;d.set(t,i||1)}}let f=fa(h,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)?.value||0,s),p="diverging"===s&&!n,g=[],m=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map,x=/* @__PURE__ */new Map,b=/* @__PURE__ */new Map;for(let e of h)y.set(e,f.get(e)??0),x.set(e,0),b.set(e,0);for(let i of e){let e=u.get(i.key),r=/* @__PURE__ */new Map,s=[],c=[],f=[],v=[],w=[],k=l?[]:void 0,A=!1,S=()=>{if(0!==s.length){if(s.length>=2){let e=A?s.map((e,t)=>t).sort((e,t)=>s[e][0]-s[t][0]):void 0,t=e?e.map(e=>v[e]):v,r={type:"area",topPath:e?e.map(e=>s[e]):s,bottomPath:e?e.map(e=>c[e]):c,rawValues:e?e.map(e=>f[e]):f,style:o(i.key,bo(i.data)),datum:t,accessibleDatum:e?e.map(e=>w[e]):w,group:i.key};k&&(r.pathIds=e?e.map(e=>k[e]):k),a&&(r.curve=a),g.push(r)}s=[],c=[],f=[],v=[],w=[],k=l?[]:void 0,A=!1}};for(let o of h){let a,l,u=e.get(o),h=void 0!==u,g=u?.value??0;if(n&&h&&(g/=d.get(o)),!h||!Number.isFinite(g)||0===g){S();continue}p?g>0?(a=x.get(o),l=a+g,x.set(o,l)):(a=b.get(o),l=a+g,b.set(o,l)):(a=y.get(o),l=a+g,y.set(o,l));let m=t.x(o),M=t.y(a),$=t.y(l);if(!Number.isFinite(m)||!Number.isFinite(M)||!Number.isFinite($)){S();continue}let _=u.sources,P=u.value,L=_?{..._[0],__aggregateValue:P,__aggregateCount:_.length,__aggregateRows:_}:u.datum;s.length>0&&m<s[s.length-1][0]&&(A=!0),s.push([m,$]),c.push([m,M]),v.push(L),f.push(P),k&&k.push(`x:${o}`),w.push(_?{x:o,value:P,group:i.key,observations:_.length}:L),r.set(o,l)}S(),m.set(i.key,r)}return{nodes:g,stackedTops:m}}function ma(e,t,i,r,o,n,a){let s=i(e),l=r(e);if(!Number.isFinite(s)||!Number.isFinite(l))return null;let c={type:"point",x:t.x(s),y:t.y(l),r:o,style:n,datum:e};return void 0!==a&&(c.pointId=a),c}function ya(e,t,i,r,o,n,a,s){let l=i(e),c=r(e);if(!Number.isFinite(l)||!Number.isFinite(c))return null;let u={type:"symbol",x:t.x(l),y:t.y(c),size:o,symbolType:n,style:a,datum:e};return void 0!==s&&(u.pointId=s),u}function xa(e,t,i,r,o,n,a){return{type:"rect",x:e,y:t,w:i,h:r,style:o,datum:n,group:a}}function ba(e,t,i,r,o,n,a){let s={type:"heatcell",x:e,y:t,w:i,h:r,fill:o,datum:n};return void 0!==a?.value&&(s.value=a.value),a?.showValues&&(s.showValues=!0,a.valueFormat&&(s.valueFormat=a.valueFormat)),s}function va(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function wa(e){let{config:t,groups:i,getX:r,getY:o}=e,n="exact"===(t.yAxisExtent??t.axisExtent);if(t.normalize){let i=[0,n?1:1+t.extentPadding];return{yDomain:i,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:i}}}let a=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===a)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};let s=/* @__PURE__ */new Map,l=/* @__PURE__ */new Set,c=0,u=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map;for(let e of i){let t=/* @__PURE__ */new Map,i=0;for(let n of e.data){let e=r(n),a=o(n);if(!Number.isFinite(e)||!Number.isFinite(a))continue;t.set(e,(t.get(e)||0)+a),l.add(e),i+=a;let s=(u.get(e)||0)+a;u.set(e,s),s>c&&(c=s)}s.set(e.key,t),d.set(e.key,i)}let h,f,p=t.stackOrder??"key",g=(e,t)=>e<t?-1:e>t?1:0;if("input"===p)h=i.map(e=>e.key);else if("insideOut"===p){let e=[...i].map(e=>e.key).sort((e,t)=>{let i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:g(e,t)}),t=[],r=[],o=0,n=0;for(let i of e)o<n?(t.push(i),o+=d.get(i)??0):(r.push(i),n+=d.get(i)??0);h=[...r.reverse(),...t]}else h="asc"===p?i.map(e=>e.key).sort((e,t)=>{let i=(d.get(e)??0)-(d.get(t)??0);return 0!==i?i:g(e,t)}):"desc"===p?i.map(e=>e.key).sort((e,t)=>{let i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:g(e,t)}):i.map(e=>e.key).sort(g);if("wiggle"===t.baseline||"silhouette"===t.baseline){let e=Array.from(l).sort((e,t)=>e-t),i=fa(e,h,(e,t)=>s.get(e)?.get(t)||0,t.baseline),r=1/0,o=-1/0;for(let t of e){let e=i.get(t)??0,n=u.get(t)??0;e<r&&(r=e),e+n>o&&(o=e+n)}(!Number.isFinite(r)||!Number.isFinite(o))&&(r=0,o=0);let a=o-r,c=n?0:a>0?a*t.extentPadding:1;f=[r-c,o+c]}else if("diverging"===t.baseline){let e=Array.from(l).sort((e,t)=>e-t),[i,r]=pa(e,h,(e,t)=>s.get(e)?.get(t)||0),o=r-i,a=n?0:o>0?o*t.extentPadding:1;f=[i-a,r+a]}else f=[0,c+(n?0:c>0?c*t.extentPadding:1)];return{yDomain:f,stackExtentCache:{key:a,yDomain:f}}}function ka(e,t,i,r,o,n,a,s="start"){let[,l]=la(e,t,i,r,o,s);return[0,a?l:l+l*n]}function Aa(e,t,i){return e.every(Number.isFinite)?va([aa(e[0],t,"center"),aa(e[1],t,"center")+t],i):va(e,i)}function Sa(e,t,i,r){let[o,n]=ca(e,t),a=n-o,s=r?0:a>0?a*i:1;return[Math.min(0,o-Math.abs(s)),Math.max(0,n+Math.abs(s))]}function Ma(e,t,i,r,o){let n=Array.from(new Set(e.map(t).filter(e=>Number.isFinite(e)))).sort((e,t)=>e-t);if(n.length<2)return va(i,r);let a=n[0],s=n[1],l=n[n.length-1],c=n[n.length-2];return va("log"===o&&a>0?[a/Math.sqrt(s/a),l*Math.sqrt(l/c)]:[a-(s-a)/2,l+(l-c)/2],r)}function $a(e,t,i){if(!i.length)return e;let[r,o]=e;for(let e of t)for(let t of i){let i=t.getTop(e),n=t.getBottom(e);Number.isFinite(i)&&(i<r&&(r=i),i>o&&(o=i)),Number.isFinite(n)&&(n<r&&(r=n),n>o&&(o=n))}return[r,o]}function _a(e,t){let i=e[1]-e[0],r=t.exactMode?0:i>0?i*t.extentPadding:1,o=[null!=t.userMin?e[0]:e[0]-r,null!=t.userMax?e[1]:e[1]+r];if("log"===t.yScaleType&&o[0]<=0&&t.dataYDomain[0]>0&&!t.exactMode){let e=1+t.extentPadding;null==t.userMin&&(o[0]=t.dataYDomain[0]/e)}return o}function Pa(e,t,i){if(!t||i)return e;let r=t[0],o=t[1];return null==r&&null==o?e:[r??e[0],o??e[1]]}function La(e,t,i){let r=e,o=t;return(r[0]===1/0||r[1]===-1/0)&&(r="time"===i?[0,864e5]:[0,1]),(o[0]===1/0||o[1]===-1/0)&&(o=[0,1]),{xDomain:r,yDomain:o}}function Ia(e,t,i){if("log"===e){let e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return ia().domain(e).range(i).clamp(!0)}return"symlog"===e?ra().domain(t).range(i):"time"===e||"utc"===e?("utc"===e?na():oa()).domain([new Date(t[0]),new Date(t[1])]).range(i):ta().domain(t).range(i)}function Ra(e){let{config:t,layout:i,xDomain:r}=e,o=t.xScaleType??(e.xIsDate?"utc":void 0),n=t.invertY?[e.yDomain[1],e.yDomain[0]]:e.yDomain,a="streaming"===t.runtimeMode,s=t.scalePadding||0,l=Math.max(0,Math.min(s,Math.min(i.width,i.height)/2-1));return a?{x:Ia(o,r,"left"===t.arrowOfTime?[i.width-l,l]:[l,i.width-l]),y:Ia(t.yScaleType,n,[i.height-l,l])}:{x:Ia(o,r,[l,i.width-l]),y:Ia(t.yScaleType,n,[i.height-l,l])}}function Ta(e,t){return e&&"object"==typeof e&&!Array.isArray(e)?Xi(e,t):void 0}function Ca(e,t,i,r){if(r&&r.version===i&&r.group===t&&r.data===e)return{result:r.result,cache:r};let o;if(t){let i=/* @__PURE__ */new Map;for(let r of e){let e=t(r);i.has(e)||i.set(e,[]),i.get(e).push(r)}o=Array.from(i.entries()).map(([e,t])=>({key:e,data:t}))}else o=[{key:"_default",data:e}];return{result:o,cache:{version:i,group:t,data:e,result:o}}}function Na(e,t,i,r,o){if(o&&o.version===r)return{map:o.map,cache:o};let n=/* @__PURE__ */new Set;if(t)for(let i of e){let e=t(i);e&&n.add(e)}let a=Array.from(n).sort(),s=a.join("\0");if(o&&o.key===s){let e={...o,version:r};return{map:e.map,cache:e}}let l=Oi(i.colorScheme,i.themeCategorical,ji),c=/* @__PURE__ */new Map;for(let e=0;e<a.length;e++)c.set(a[e],Ta(i.colorScheme,a[e])??l[e%l.length]);return{map:c,cache:{key:s,map:c,version:r}}}function Fa(e){let{group:t,colorMapCache:i,groupColorMap:r,groupColorMapCap:o,config:n}=e,{groupColorCounter:a}=e,s=Ta(n.colorScheme,t);if(s)return{color:s,groupColorCounter:a};if(i){let e=i.map.get(t);if(e)return{color:e,groupColorCounter:a}}let l=r.get(t);if(l)return{color:l,groupColorCounter:a};let c=Oi(n.colorScheme,n.themeCategorical,ji);if(0===c.length)return{color:null,groupColorCounter:a};let u=c[a%c.length];if(a++,r.set(t,u),r.size>o){let e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:u,groupColorCounter:a}}function Da(e,t,i,r){let o=e.lineStyle;if("function"==typeof o){let e=o(i||{},t);if(e&&!e.stroke&&t){let i=r(t);if(i)return{...e,stroke:i}}return e}let n=e.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||n||"#007bff",strokeWidth:o.strokeWidth??2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity,cursor:o.cursor}:{stroke:r(t)||n||"#007bff",strokeWidth:2}}function Ea(e,t,i,r){if(e.areaStyle){let o=e.areaStyle(i||{});if(o&&!o.fill&&t){let e=r(t);if(e)return{...o,fill:e,stroke:o.stroke||e}}return o}let o=e.lineStyle;if("function"==typeof o){let e=o(i||{},t);if(e&&!e.fill&&t){let i=r(t);if(i)return{...e,fill:i,stroke:e.stroke||i}}return e}let n=e.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||n||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||n||"#4e79a7",strokeWidth:o.strokeWidth??2,cursor:o.cursor};let a=r(t)||n||"#4e79a7";return{fill:a,fillOpacity:.7,stroke:a,strokeWidth:2}}function za(e,t,i,r){let o=e.boundsStyle;if("function"==typeof o)return o(i||{},t);if(o&&"object"==typeof o)return o;let n=r(t,i);return{fill:n.stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,...null!=n.opacity&&{opacity:n.opacity},stroke:"none",cursor:n.cursor}}function Oa(e,t,i){t<=e.capacity||(e.resize(t),i&&t>i.capacity&&i.resize(t))}function ja(e,t){let i=new $n(e.capacity);return e.forEach(()=>i.push(t)),i}function Wa(e,t,i,r){let o=e.push(t);return i&&i.push(r),o}function Ba(e,t,i){if(!t||0===t.size)return;let r=/* @__PURE__ */new Set;if(e.forEach((e,t)=>{i(e)&&r.add(t)}),0===r.size)return;let o=t.toArray();t.clear();for(let e=0;e<o.length;e++)r.has(e)||t.push(o[e])}var Ya=/* @__PURE__ */new WeakMap,Ga=class{getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(e){return this.updateResults.subscribe(e)}setLayoutSelection(e){this.config.layoutSelection=e}markStylePaintPending(){Ya.set(this,!0)}consumeStylePaintPending(){let e=!0===Ya.get(this);return Ya.delete(this),e}},Xa=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Va=["scene-style","data-paint","accessibility","evidence"],qa=(e,t)=>({retainedData:e,invalidations:t}),Ha=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ua=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Za=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Qa=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ka=["scene-geometry","data-paint","accessibility","evidence"],Ja=["scene-style","data-paint","accessibility","evidence"],es=["overlay","accessibility","evidence"],ts=[],is={chartType:/* @__PURE__ */qa("rebuild",Ha),runtimeMode:/* @__PURE__ */qa("rebuild",Ha),xAccessor:/* @__PURE__ */qa("rebuild",Ha),yAccessor:/* @__PURE__ */qa("rebuild",Ha),timeAccessor:/* @__PURE__ */qa("rebuild",Ha),valueAccessor:/* @__PURE__ */qa("rebuild",Ha),y0Accessor:/* @__PURE__ */qa("rebuild",Ha),boundsAccessor:/* @__PURE__ */qa("rebuild",Ha),band:/* @__PURE__ */qa("rebuild",Ha),openAccessor:/* @__PURE__ */qa("rebuild",Ha),highAccessor:/* @__PURE__ */qa("rebuild",Ha),lowAccessor:/* @__PURE__ */qa("rebuild",Ha),closeAccessor:/* @__PURE__ */qa("rebuild",Ha),candlestickRangeMode:/* @__PURE__ */qa("rebuild",Ha),accessorRevision:/* @__PURE__ */qa("rebuild",Ha),groupAccessor:/* @__PURE__ */qa("rebuild",Ua),categoryAccessor:/* @__PURE__ */qa("rebuild",Ua),lineDataAccessor:/* @__PURE__ */qa("rebuild",Ua),colorAccessor:/* @__PURE__ */qa("rebuild",Ja),sizeAccessor:/* @__PURE__ */qa("rebuild",Ka),symbolAccessor:/* @__PURE__ */qa("rebuild",Ka),pointIdAccessor:/* @__PURE__ */qa("rebuild",Ka),xScaleType:/* @__PURE__ */qa("preserve",Za),yScaleType:/* @__PURE__ */qa("preserve",Za),xExtent:/* @__PURE__ */qa("preserve",Za),invertY:/* @__PURE__ */qa("preserve",Za),yExtent:/* @__PURE__ */qa("preserve",Za),extentPadding:/* @__PURE__ */qa("preserve",Za),scalePadding:/* @__PURE__ */qa("preserve",Za),axisExtent:/* @__PURE__ */qa("preserve",Za),yAxisExtent:/* @__PURE__ */qa("preserve",Za),binSize:/* @__PURE__ */qa("preserve",Za),binAlign:/* @__PURE__ */qa("preserve",Za),normalize:/* @__PURE__ */qa("preserve",Za),heatmapAggregation:/* @__PURE__ */qa("preserve",Za),heatmapXBins:/* @__PURE__ */qa("preserve",Za),heatmapYBins:/* @__PURE__ */qa("preserve",Za),arrowOfTime:/* @__PURE__ */qa("preserve",Qa),baseline:/* @__PURE__ */qa("preserve",Qa),stackOrder:/* @__PURE__ */qa("preserve",Qa),sizeRange:/* @__PURE__ */qa("preserve",Qa),curve:/* @__PURE__ */qa("preserve",Qa),areaGroups:/* @__PURE__ */qa("preserve",Qa),customLayout:/* @__PURE__ */qa("preserve",Qa),layoutConfig:/* @__PURE__ */qa("preserve",Qa),layoutMargin:/* @__PURE__ */qa("preserve",Qa),symbolMap:/* @__PURE__ */qa("preserve",Ka),showValues:/* @__PURE__ */qa("preserve",Ka),heatmapValueFormat:/* @__PURE__ */qa("preserve",Ka),trackHoverRows:/* @__PURE__ */qa("preserve",Ka),lineStyle:/* @__PURE__ */qa("preserve",Ja),pointStyle:/* @__PURE__ */qa("preserve",Ja),areaStyle:/* @__PURE__ */qa("preserve",Ja),barStyle:/* @__PURE__ */qa("preserve",Ja),swarmStyle:/* @__PURE__ */qa("preserve",Ja),waterfallStyle:/* @__PURE__ */qa("preserve",Ja),candlestickStyle:/* @__PURE__ */qa("preserve",Ja),boundsStyle:/* @__PURE__ */qa("preserve",Ja),gradientFill:/* @__PURE__ */qa("preserve",Ja),lineGradient:/* @__PURE__ */qa("preserve",Ja),semanticLineStops:/* @__PURE__ */qa("preserve",Ja),colorScheme:/* @__PURE__ */qa("preserve",Ja),themeCategorical:/* @__PURE__ */qa("preserve",Ja),themeSemantic:/* @__PURE__ */qa("preserve",Ja),themeSequential:/* @__PURE__ */qa("preserve",Ja),themeDiverging:/* @__PURE__ */qa("preserve",Ja),barColors:/* @__PURE__ */qa("preserve",Ja),decay:/* @__PURE__ */qa("preserve",Ja),pulse:/* @__PURE__ */qa("preserve",Ja),staleness:/* @__PURE__ */qa("preserve",Ja),layoutSelection:/* @__PURE__ */qa("preserve",Ja),annotations:/* @__PURE__ */qa("preserve",es),windowSize:/* @__PURE__ */qa("preserve",ts),windowMode:/* @__PURE__ */qa("preserve",ts),maxCapacity:/* @__PURE__ */qa("preserve",ts),clock:/* @__PURE__ */qa("preserve",ts),transition:/* @__PURE__ */qa("preserve",ts),introAnimation:/* @__PURE__ */qa("preserve",ts),onLayoutError:/* @__PURE__ */qa("preserve",ts)},rs=/* @__PURE__ */qa("preserve",Qa);function os(e){let t="preserve",i=/* @__PURE__ */new Set;for(let r of e){let e=is[r]??rs;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}var ns=class{constructor(){this.tracker=new ae}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Xa)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Va):this.recordNoop("restyle")}recordConfig(e,t=!1){let i=os(e);return this.tracker.record({kind:"config",keys:e},t?/* @__PURE__ */new Set([...i.invalidations,...Ka]):i.invalidations)}};import{quadtree as as}from"d3-quadtree";var ss=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let i=0,r=0;for(let e of t)"point"===e.type&&!1!==e.interactive&&(i++,e.r>r&&(r=e.r));if(this.maxRadius=r,i<=500)return void(this.tree=null);let o=new Array(i),n=0;for(let e of t)"point"===e.type&&!1!==e.interactive&&(o[n++]=e);this.tree=as().x(e=>e.x).y(e=>e.y).addAll(o)}};function ls(e){for(let t of e){if(void 0!==t._targetOpacity){let e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0);else if("glyph"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0);else if("rect"===t.type||"heatcell"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0);else if("candlestick"===t.type)void 0!==t._targetX&&(t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0);else if("line"===t.type||"area"===t.type){if(t._introClipFraction=void 0,"line"===t.type&&t._targetPath){for(let e=0;e<t.path.length;e++)t.path[e]=t._targetPath[e];t._prevPath=void 0,t._targetPath=void 0}if("area"===t.type){if(t._targetTopPath)for(let e=0;e<t.topPath.length;e++)t.topPath[e]=t._targetTopPath[e];if(t._targetBottomPath)for(let e=0;e<t.bottomPath.length;e++)t.bottomPath[e]=t._targetBottomPath[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}}}function cs(e){for(let t of e){if(void 0!==t._targetOpacity){let e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}"point"===t.type?void 0!==t._targetX?(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0):void 0!==t._targetR&&(t.r=t._targetR,t._targetR=void 0):"rect"===t.type?void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0):"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0)}}function us(e,t,i,r){let o=r.width/i.width,n=r.height/i.height;for(let t of e)switch(t.type){case"line":for(let e of t.path)e[0]*=o,e[1]*=n;break;case"area":for(let e of t.topPath)e[0]*=o,e[1]*=n;for(let e of t.bottomPath)e[0]*=o,e[1]*=n;t.clipRect&&(t.clipRect={x:t.clipRect.x*o,y:t.clipRect.y*n,width:t.clipRect.width*o,height:t.clipRect.height*n}),t.strokeColorBands&&(t.strokeColorBands=t.strokeColorBands.map(e=>({...e,y:e.y*n,height:e.height*n})));break;case"point":case"symbol":case"glyph":t.x*=o,t.y*=n;break;case"rect":case"heatcell":t.x*=o,t.y*=n,t.w*=o,t.h*=n}return{x:t.x.copy().range(t.x.range().map(e=>e*o)),y:t.y.copy().range(t.y.range().map(e=>e*n))}}var ds=class extends Ga{constructor(e){super(),this.xExtent=new _n,this.yExtent=new _n,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=/* @__PURE__ */new Map,this.prevPathMap=/* @__PURE__ */new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=/* @__PURE__ */new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new ns,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this.xIsDate=!1,this.xTypeDetected=!1,this.spatialIndex=new ss,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,i)=>!(!this.config.pulse||!this.timestampBuffer)&&Fn(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),i),this.config=e,this.buffer=new $n(e.windowSize),this.growingCap=e.windowSize;let t=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode;if(this.resolveXAccessor(),this.getY=t?y(e.valueAccessor||e.yAccessor,"value"):y(e.yAccessor,"y"),this.getGroup=b(e.groupAccessor),this.getCategory=b(e.categoryAccessor),this.getSize=e.sizeAccessor?y(e.sizeAccessor,"size"):void 0,this.getColor=b(e.colorAccessor),this.getSymbol=b(e.symbolAccessor),this.getY0=e.y0Accessor?y(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=ea(e),this.getPointId=b(e.pointIdAccessor),"candlestick"===e.chartType){let t=null!=e.openAccessor,i=null!=e.closeAccessor;this.getOpen=t?y(e.openAccessor,"open"):void 0,this.getHigh=y(e.highAccessor,"high"),this.getLow=y(e.lowAccessor,"low"),this.getClose=i?y(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!i}e.pulse&&(this.timestampBuffer=new $n(e.windowSize))}currentTime(){return this.config.clock?.()??T()}resolveXAccessor(e=this.buffer){let t=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=t&&this.config.timeAccessor||this.config.xAccessor,r=x(i,t?"time":"x");this.xIsDate=!1,this.xTypeDetected=!1;for(let t of e){let e=r(t);if(null==e||""===e)continue;let i=e instanceof Date&&Number.isFinite(e.getTime())||"string"==typeof e&&Number.isFinite(d(e));if(i||Number.isFinite(Number(e))){this.xIsDate=i,this.xTypeDetected=!0;break}}this.getX=this.xIsDate?e=>h(r(e)):e=>+r(e)}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=ja(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(let t of this.resolvedRibbons){let i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&this.yExtent.push(i),Number.isFinite(r)&&this.yExtent.push(r)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(let t of this.resolvedRibbons){let i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&this.yExtent.evict(i),Number.isFinite(r)&&this.yExtent.evict(r)}}rebuildYExtent(){this.yExtent.clear();for(let e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(let e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;let t=this.currentTime();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.resolveXAccessor(e.inserts);let i=e.totalSize||e.inserts.length;Oa(this.buffer,i,this.timestampBuffer);for(let i of e.inserts)Wa(this.buffer,i,this.timestampBuffer,t),this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i)}else{this.xTypeDetected||this.resolveXAccessor(e.inserts);for(let i of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){let e=this.config.maxCapacity??1e5;this.growingCap<e&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"!==process.env.NODE_ENV&&!this.growingCapacityWarned&&this.growingCap>=5e4&&(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}let e=Wa(this.buffer,i,this.timestampBuffer,t);this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){let{config:t,buffer:i}=this,r=this.scales,o=this.lastLayout;if(!(e.width>0&&e.height>0&&Number.isFinite(e.width)&&Number.isFinite(e.height)))return void(this.needsFullRebuild=!0);if(!this.needsFullRebuild&&!t.customLayout&&!this.activeTransition&&"bar"!==t.chartType&&"waterfall"!==t.chartType&&"candlestick"!==t.chartType&&this.lastLayout&&this.lastLayout.width>0&&this.lastLayout.height>0&&this.scene.length>0&&this.scales&&(this.config.scalePadding??0)<=0&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return this.scales=us(this.scene,this.scales,this.lastLayout,e),this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(t.chartType,this.scene),void this.version++;this.xExtent.dirty&&this.xExtent.recalculate(i,this.getX),this.yExtent.dirty&&this.rebuildYExtent();let n=this.getBufferArray(),a=this.xExtent.extent,s=this.yExtent.extent,l="waterfall"===t.chartType&&i.size>0?Ma(n,this.getX,a,t.xExtent,t.xScaleType):va(a,t.xExtent);"bar"===t.chartType&&t.binSize&&"center"===t.binAlign&&(l=Aa(a,t.binSize,t.xExtent));let c=va(s,t.yExtent),u=!(!(h=t.yExtent)||null==h[0]||null==h[1]),d="exact"===(t.yAxisExtent??t.axisExtent);var h;if("stackedarea"===t.chartType&&!u&&i.size>0){let e=wa({config:t,groups:this.groupData(n),getX:this.getX,getY:this.getY,bufferSize:i.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!u&&i.size>0?c=ka(i,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,d,t.binAlign):"waterfall"===t.chartType&&!u&&i.size>0?c=Sa(i,this.getY,t.extentPadding,d):!u&&c[0]!==1/0&&(c=$a(c,n,this.resolvedRibbons),c=_a(c,{exactMode:d,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=Pa(c,t.yExtent,!!u),({xDomain:l,yDomain:c}=La(l,c,t.xScaleType)),this.scales=Ra({config:t,layout:e,xDomain:l,yDomain:c,xIsDate:this.xIsDate}),this._customLayoutFailedThisBuild=!1;let f=this.buildSceneNodes(e,n);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.lastLayout=o):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);let p=this.config.transition?On():null;p&&this.scene.length>0&&this.snapshotPositions(),this.scene=f,this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&p&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),p&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}buildSceneNodes(e,t){let{config:i,scales:r}=this;if(!r)return[];if(i.customLayout){let o=i.layoutMargin??{top:0,right:0,bottom:0,left:0},n={data:t,scales:r,dimensions:{width:e.width,height:e.height,margin:o,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:i.themeSemantic??{},categorical:i.themeCategorical??ji},resolveColor:(e,t)=>{let r=this.resolveGroupColor(e);if(r)return r;let o=this.resolveLineStyle(e,t);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:i.themeSemantic?.primary??"#4e79a7"},config:i.layoutConfig??{},selection:i.layoutSelection??null},a=Kn({family:"xy",logLabel:"customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:i.onLayoutError,run:()=>i.customLayout(n)});if("failure"===a.kind)return this.lastCustomLayoutFailure=a.diagnostic,this._customLayoutFailedThisBuild=!0,a.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);let s=a.result;this.customLayoutOverlays=s.overlays??null,this.lastCustomLayoutResult=s,this.lastCustomLayoutFailure=null;let l=s.nodes??[];if(this._customRestyle=s.restyle,this.hasCustomRestyle=!!s.restyle,this.hasCustomRestyle){this._baseStyles=/* @__PURE__ */new WeakMap;for(let e of l)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(l,i.layoutSelection??null)}return qn({label:"customLayout",nodes:l,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),l}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];let o={scales:r,config:i,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache},n=(a=i.chartType,jn[a]?.buildScene);var a;if(!n)return Vn(i.chartType),[];let s=Yn(n(o,t,e));return"bar"===i.chartType&&(this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=s.binBoundaries),s.nodes}resolveBoundsStyle(e,t){return za(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){let i=this.config.decay;return!i||t<=1?1:Rn(i,e,t)}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;let t=Tn(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&Cn(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&En(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory,getPointId:this.getPointId}}get hasRenderedOnce(){return this._hasRenderedOnce}snapshotPositions(){On()?.snapshotPositions(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();let e=this.scales?.y(0)??0,t=On();if(t)for(let i=0;i<this.scene.length;i++){let r=this.scene[i],o=t.getNodeIdentity(this.transitionContext,r,i);o&&("point"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,r:0,opacity:0}):"rect"===r.type?this.prevPositionMap.set(o,{x:r.x,y:e,w:r.w,h:0,opacity:r.style.opacity??1}):"heatcell"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:0}):"line"===r.type?(r._introClipFraction=0,this.prevPathMap.set(o,{path:r.path.map(e=>[e[0],e[1]]),pathIds:r.pathIds?.slice(),opacity:r.style.opacity})):"area"===r.type&&(r._introClipFraction=0,this.prevPathMap.set(o,{topPath:r.topPath.map(e=>[e[0],e[1]]),bottomPath:r.bottomPath.map(e=>[e[0],e[1]]),pathIds:r.pathIds?.slice(),opacity:r.style.opacity})))}}startTransition(){let e=On();if(!this.config.transition||!e)return;let t=e.startTransition(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(e){let t=On();if(!this.activeTransition||!this.config.transition||!t)return!1;let i={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},r=t.advanceTransition(e,this.config.transition,i,this.prevPositionMap,this.prevPathMap);return this.scene=i.scene,this.exitNodes=i.exitNodes,this.activeTransition=i.activeTransition,r}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null,ls(this.scene),this.exitNodes=[]}groupData(e){let{result:t,cache:i}=Ca(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,t}resolveColorMap(e){let{map:t,cache:i}=Na(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,t}resolveLineStyle(e,t){return Da(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return Ea(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(e){let{color:t,groupColorCounter:i}=Fa({group:e,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:1e3,config:this.config});return this._groupColorCounter=i,t}getBufferArray(){return(this._bufferDirty||!this._bufferArrayCache)&&(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw new Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&On()&&this.snapshotPositions();let t=Pn(e),i=this.getPointId,r=e=>t.has(i(e));Ba(this.buffer,this.timestampBuffer,r);let o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(let e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getPointId)throw new Error("update() requires pointIdAccessor to be configured");let i=Pn(e),r=this.getPointId,o=/* @__PURE__ */new Set;this.buffer.forEach((e,t)=>{i.has(r(e))&&o.add(t)});let n=this.buffer.update(e=>i.has(r(e)),t);if(0===n.length)return this.updateResults.recordNoop("update"),n;for(let e of n)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{o.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",n.length),n}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.resolveXAccessor(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=/* @__PURE__ */new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(e,t){let i=this._customRestyle;if(i)for(let r of e){let e=this._baseStyles.get(r)??r.style??{},o=i(r,t);r.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){let t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=/* @__PURE__ */new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let r=!1,o=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let n="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(n||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){let e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=e&&this.config.timeAccessor||this.config.xAccessor,a=e&&t.timeAccessor||t.xAccessor,s=e&&this.config.valueAccessor||this.config.yAccessor,l=e&&t.valueAccessor||t.yAccessor,c=n||!m(i,a),u=n||!m(s,l);(c||u)&&(c&&this.resolveXAccessor(),this.getY=e?y(this.config.valueAccessor||this.config.yAccessor,"value"):y(this.config.yAccessor,"y"),u&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=ea(this.config)),r=!0,o=!0)}if("groupAccessor"in e&&!m(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?b(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!m(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?b(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!m(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?y(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!m(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?b(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!m(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?b(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!m(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?y(this.config.y0Accessor,"y0"):void 0,r=!0,o=!0),("boundsAccessor"in e&&!m(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=ea(this.config),r=!0,o=!0),"pointIdAccessor"in e&&!m(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?b(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(n||"openAccessor"in e&&!m(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!m(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!m(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!m(e.lowAccessor,t.lowAccessor))){let e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?y(this.config.openAccessor,"open"):void 0,this.getHigh=y(this.config.highAccessor,"high"),this.getLow=y(this.config.lowAccessor,"low"),this.getClose=t?y(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,r=!0,o=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(this.resolveXAccessor(),r=!0,o=!0),!r){let i=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(let o of i)if(e[o]!==t[o]){r=!0;break}}r&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(i,("bar"===this.config.chartType||"heatmap"===this.config.chartType)&&!this.config.trackHoverRows&&vo(t.areaStyle)!==vo(this.config.areaStyle))}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};function hs(e,t,i,r){return"function"==typeof t.style?t.style(r||{},i):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(i,r)}function fs(e,t,i,r){if(!e.scales)return null;let{topPath:o,bottomPath:n,datum:a,pathIds:s}=ua(t,e.scales,e.getX,r.getTop,r.getBottom,e.getPointId);return o.length<2?null:{type:"area",topPath:o,bottomPath:n,...s&&{pathIds:s},...e.config.curve&&"linear"!==e.config.curve&&{curve:e.config.curve},style:hs(e,r,i,bo(t)),datum:a,group:i,interactive:r.interactive}}function ps(e){let t=[],i=[];if(!e)return{perSeries:t,aggregate:i};for(let r of e)r.perSeries?t.push(r):i.push(r);return{perSeries:t,aggregate:i}}function gs(e,t,i){let r=[];for(let o of i){let i=fs(e,t,"__ribbon_aggregate",o);i&&r.push(i)}return r}function ms(e,t,i,r){let o=[];for(let n of r){let r=fs(e,t,i,n);r&&o.push(r)}return o}function ys(e,t,i,r){if(!e.config.pointStyle)return;let o=r??e.getY;for(let r of t){let t=e.resolveGroupColor(r.key);for(let n of r.data){let r=e.config.pointStyle(n);!r.fill&&t&&(r={...r,fill:t});let a=r.r??3,s=e.getPointId?String(e.getPointId(n)):void 0,l=ma(n,e.scales,e.getX,o,a,r,s);l&&i.push(l)}}}function xs(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}function bs(e){return nr(e)}function vs(e,t){if("domain"!==e.extent)return;let[i,r]=t.domain(),o=t(r),n=t(i);return Number.isFinite(o)&&Number.isFinite(n)?[o,n]:void 0}function ws(e,t){let i=[],r="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15],n=null;if(e.getSize&&!e.config.pointStyle){let i=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(i.length>0){let e=1/0,t=-1/0;for(let r of i)r<e&&(e=r),r>t&&(t=r);n=i=>e===t?(o[0]+o[1])/2:o[0]+(i-e)/(t-e)*(o[1]-o[0])}}let a=e.getColor?e.resolveColorMap(t):null,s=e.config.themeSemantic?.primary||"#4e79a7",l=e.getSymbol,c=l?Be(l,e.config.symbolMap):null;for(let o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:s,opacity:.8},l=t.r||r;if(n&&e.getSize){let t=e.getSize(o);null!=t&&!Number.isNaN(t)&&(l=n(t))}if(a&&e.getColor&&!t.fill){let i=e.getColor(o);i&&a.has(i)&&(t={...t,fill:a.get(i)})}let u=e.getPointId?String(e.getPointId(o)):void 0;if(c){let r=c(o),n=ya(o,e.scales,e.getX,e.getY,Math.PI*l*l,r,t,u);n&&i.push(n)}else{let r=ma(o,e.scales,e.getX,e.getY,l,t,u);r&&i.push(r)}}return i}var ks=/* @__PURE__ */new Map;function As(e,t,i){return t===i?Math.floor(128):Math.min(Math.floor(255*(e-t)/(i-t)+.5),255)}function Ss(e){let t=Object.prototype.hasOwnProperty.call(_i,e)?e:"blues",i=ks.get(t);if(i)return i;i=new Array(256);let r=Pi(t);for(let e=0;e<256;e++)i[e]=r(e/255);return ks.set(t,i),i}function Ms(e,t,i){let r=i.config.areaStyle?.(t);return r&&("string"==typeof r.fill&&(e.fill=r.fill),e.style=r),e}function $s(e,t,i){let r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),o=Math.max(1,Math.floor(e.config.heatmapYBins??20)),n=e.config.heatmapAggregation??"count",a=y(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];let[s,l]=e.scales.x.domain(),[c,u]=e.scales.y.domain(),d=(l-s||1)/r,h=(u-c||1)/o,f=r*o;if(f>1e6)return[];let p=new Int32Array(f),g=new Float64Array(f),m=e.config.trackHoverRows||vo(e.config.areaStyle)?/* @__PURE__ */new Map:void 0;for(let i=0;i<t.length;i++){let n=t[i],l=e.getX(n),u=e.getY(n);if(!isFinite(l)||!isFinite(u))continue;let f=Math.min(Math.floor((l-s)/d),r-1),y=Math.min(Math.floor((u-c)/h),o-1);if(f<0||y<0)continue;let x=y*r+f;p[x]++;let b=a(n);if(g[x]+=isFinite(b)?b:0,m){let e=m.get(x);e||(e=[],m.set(x,e)),e.push(n)}}let x=1/0,b=-1/0;for(let e=0;e<f;e++){if(0===p[e])continue;let t;switch(n){case"sum":t=g[e];break;case"mean":t=g[e]/p[e];break;default:t=p[e]}t<x&&(x=t),t>b&&(b=t)}if(!isFinite(x))return[];let v=e.config.heatmapColorScale,w="string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues",k=v?void 0:Ss(w),A=i.width/r,S=i.height/o,M=e.config.showValues,$=e.config.heatmapValueFormat,_=[];for(let t=0;t<o;t++){let i=t*r;for(let a=0;a<r;a++){let r,l=i+a;if(0===p[l])continue;switch(n){case"sum":r=g[l];break;case"mean":r=g[l]/p[l];break;default:r=p[l]}let u=As(r,x,b),f=v?v(r):k[u],y=M?{value:r,showValues:!0,valueFormat:$}:{value:r},w=s+(a+.5)*d,P=c+(t+.5)*h,L=mo({xi:a,yi:t,value:r,count:p[l],sum:g[l],xCenter:w,yCenter:P,agg:n},m?.get(l));_.push(Ms(ba(a*A,(o-1-t)*S,A,S,f,L,y),L,e))}}return _}function _s(e){if(!Array.isArray(e))return;let t=e.filter(e=>!!e&&("string"==typeof e.fill||"object"==typeof e.fill&&null!==e.fill)),i=t.filter(e=>"number"==typeof e.upTo&&Number.isFinite(e.upTo)).map(e=>({upTo:e.upTo,fill:e.fill})).sort((e,t)=>e.upTo-t.upTo),r=t.find(e=>"number"!=typeof e.upTo||!Number.isFinite(e.upTo)),o=r?[...i,{upTo:1/0,fill:r.fill}]:i;return o.length>0?o:void 0}function Ps(e,t,i,r){let o=Math.min(t,i),n=Math.max(t,i);if(!(n>o))return[];let a=[],s=-1/0;for(let t of e){let e=Math.max(s,o),i=Math.min(t.upTo,n);if(i>e&&a.push({from:e,to:i,fill:t.fill}),s=t.upTo,s>=n)break}return s<n&&a.push({from:Math.max(s,o),to:n,fill:r}),a}var Ls={line:function(e,t){let i=e.groupData(t),r=[],o=e.config.annotations?.filter(xs).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:n}=ps(e.ribbons);if(n.length>0&&r.push(...gs(e,t,n)),o.length>0)for(let t of i)r.push(...ms(e,t.data,t.key,o))}for(let t of i){let i=e.resolveLineStyle(t.key,bo(t.data)),n=da(t.data,e.scales,e.getX,e.getY,i,t.key,e.getPointId);o&&o.length>0&&(n.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(n.curve=e.config.curve),e.config.lineGradient&&(n.strokeGradient=e.config.lineGradient),r.push(n)}return ys(e,i,r),r},area:function(e,t){let i=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:n}=ps(e.ribbons);if(n.length>0&&r.push(...gs(e,t,n)),o.length>0)for(let t of i)r.push(...ms(e,t.data,t.key,o))}let o=e.scales.y.domain(),n=o[0],a=e.config.semanticLineStops?.filter(e=>Number.isFinite(e.offset)).map(e=>({value:o[0]+Math.max(0,Math.min(1,e.offset))*(o[1]-o[0]),color:e.color,opacity:e.opacity,thresholdType:"greater"})).sort((e,t)=>e.value-t.value),s=a&&a.length>0?(()=>{let t=a.reduce((e,t)=>(e.at(-1)?.value===t.value?e[e.length-1]=t:e.push(t),e),[]),i=[{from:o[0],to:t[0].value,color:t[0].color,opacity:t[0].opacity}];for(let e=0;e<t.length;e++)i.push({from:t[e].value,to:t[e+1]?.value??o[1],color:t[e].color,opacity:t[e].opacity});return i.map(({from:t,to:i,color:r,opacity:o})=>{let n=e.scales.y(t),a=e.scales.y(i);return{y:Math.min(n,a),height:Math.abs(a-n),color:r,...null!=o&&{opacity:o}}}).filter(e=>e.height>0)})():void 0,l=e.getY0?t=>e.getY0(t)??n:void 0;for(let t of i){let i=e.resolveAreaStyle(t.key,bo(t.data)),o=ha(t.data,e.scales,e.getX,e.getY,n,i,t.key,l,e.getPointId),c=bs(e.config.gradientFill);if(c){o.fillGradient=c;let t=vs(c,e.scales.y);t&&(o.fillGradientSpan=t)}e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),a&&a.length>0&&(o.colorThresholds=a,o.strokeColorBands=s),r.push(o)}return ys(e,i,r),r},stackedarea:function(e,t){let i=e.groupData(t),r=e.config.stackOrder??"key",o=()=>i.sort((e,t)=>e.key<t.key?-1:e.key>t.key?1:0);if("input"!==r)if("key"===r)o();else if("asc"===r||"desc"===r||"insideOut"===r){let t=/* @__PURE__ */new Map;for(let r of i){let i=0;for(let t of r.data){let r=e.getX(t),o=e.getY(t);Number.isFinite(r)&&Number.isFinite(o)&&(i+=o)}t.set(r.key,i)}let o=(e,t)=>e<t?-1:e>t?1:0;if("asc"===r)i.sort((e,i)=>{let r=(t.get(e.key)??0)-(t.get(i.key)??0);return 0!==r?r:o(e.key,i.key)});else if("desc"===r)i.sort((e,i)=>{let r=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,i.key)});else{let e=[...i].sort((e,i)=>{let r=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,i.key)}),r=[],n=[],a=0,s=0;for(let i of e)a<s?(r.push(i),a+=t.get(i.key)??0):(n.push(i),s+=t.get(i.key)??0);i.length=0,i.push(...n.reverse(),...r)}}else o();let n=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,a=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:s,stackedTops:l}=ga(i,e.scales,e.getX,e.getY,(t,i)=>e.resolveAreaStyle(t,i),e.config.normalize,n,a,e.getPointId),c=s;if(e.config.pointStyle){let t=/* @__PURE__ */new WeakMap;for(let r of i){let i=l.get(r.key);if(i)for(let o of r.data){let r=e.getX(o),n=e.getY(o);null!=r&&!Number.isNaN(r)&&null!=n&&!Number.isNaN(n)&&i.has(r)&&t.set(o,i.get(r))}}ys(e,i,c,i=>t.get(i)??e.getY(i))}return c},mixed:function(e,t){let i=e.groupData(t),r=[],o=e.config.areaGroups||/* @__PURE__ */new Set;if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:n}=ps(e.ribbons);if(n.length>0&&r.push(...gs(e,t,n)),o.length>0)for(let t of i)r.push(...ms(e,t.data,t.key,o))}let n=e.scales.y.domain()[0],a=e.getY0?t=>e.getY0(t)??n:void 0;for(let t of i)if(o.has(t.key)){let i=e.resolveAreaStyle(t.key,bo(t.data)),o=ha(t.data,e.scales,e.getX,e.getY,n,i,t.key,a,e.getPointId),s=bs(e.config.gradientFill);if(s){o.fillGradient=s;let t=vs(s,e.scales.y);t&&(o.fillGradientSpan=t)}e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}else{let i=e.resolveLineStyle(t.key,bo(t.data)),o=da(t.data,e.scales,e.getX,e.getY,i,t.key,e.getPointId);e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return ys(e,i,r),r},scatter:ws,bubble:ws,heatmap:function(e,t,i){if(e.config.heatmapAggregation)return $s(e,t,i);if(0===t.length)return[];let r=y(e.config.valueAccessor,"value"),o=x(e.config.xAccessor,"x"),n=x(e.config.yAccessor,"y"),a=/* @__PURE__ */new Map,s=/* @__PURE__ */new Map,l=new Array(t.length),c=new Array(t.length);for(let e=0;e<t.length;e++){let i=t[e],r=o(i),u=n(i);l[e]=r,c[e]=u,a.has(r)||a.set(r,a.size),s.has(u)||s.set(u,s.size)}let u=a.size,d=s.size;if(0===u||0===d)return[];let h=Array.from(a.keys()),f=Array.from(s.keys()),p=h.every(e=>"number"==typeof e&&!isNaN(e)),g=f.every(e=>"number"==typeof e&&!isNaN(e)),m=4096;if(p&&g&&u*d>m&&t.length>m){let r=/* @__PURE__ */new Set;for(let o=0;o<t.length;o++){let n=a.get(l[o]),d=s.get(c[o]);if(void 0!==n&&void 0!==d&&(r.add(d*u+n),r.size>m))return $s({...e,config:{...e.config,heatmapAggregation:e.config.valueAccessor?"mean":"count"}},t,i)}}if(p){h.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;e<h.length;e++)a.set(h[e],e)}if(g){f.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;e<f.length;e++)s.set(f[e],e)}let b=new Float64Array(t.length),v=new Float64Array(t.length),w=new Array(t.length),k=/* @__PURE__ */new Map,A=0;for(let e=0;e<t.length;e++){let i=t[e],o=a.get(l[e]),n=s.get(c[e]);if(void 0===o||void 0===n)continue;let d,h=r(i),f=n*u+o,p=k.get(f);void 0!==p?d=p:(d=A++,k.set(f,d)),b[d]=f,v[d]=h,w[d]=i}let S=1/0,M=-1/0;for(let e=0;e<A;e++){let t=v[e];isFinite(t)&&(t<S&&(S=t),t>M&&(M=t))}if(!isFinite(S)||!isFinite(M))return[];let $="string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues",_=e.config.heatmapColorScale,P=_?void 0:Ss($),L=i.width/u,I=i.height/d,R=e.config.showValues,T=e.config.heatmapValueFormat,C=[];for(let t=0;t<A;t++){let i=v[t];if(!isFinite(i))continue;let r=b[t],o=r%u,n=(r-o)/u,a=As(i,S,M),s=_?_(i):P[a],l=R?{value:i,showValues:!0,valueFormat:T}:{value:i},c=w[t];C.push(Ms(ba(o*L,(d-1-n)*I,L,I,s,c,l),c,e))}return C},bar:function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};let i=sa(t,e.getX,e.getY,e.config.binSize,e.getCategory,!!e.config.trackHoverRows||vo(e.config.areaStyle),e.config.binAlign);if(0===i.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){let t=/* @__PURE__ */new Set;for(let e of i.values())for(let i of e.categories.keys())t.add(i);let o=e.config.barColors?Object.keys(e.config.barColors):[],n=new Set(o),a=Array.from(t).filter(e=>!n.has(e)).sort(),s=o.filter(e=>t.has(e)),l=s.join("\0")+""+a.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...s,...a],e.barCategoryCache={key:l,order:r})}let o=[],n=e.scales,[a,s]=n.x.domain(),l=e.config.barStyle,c=e.config.themeSemantic?.primary,u=l?.gap,d="number"==typeof u&&u>=0?u:1,h={};l?.stroke&&(h.stroke=l.stroke),"number"==typeof l?.strokeWidth&&(h.strokeWidth=l.strokeWidth),"number"==typeof l?.opacity&&(h.opacity=l.opacity),l?.cursor&&(h.cursor=l.cursor);let f=_s(l?.valueBands);for(let t of i.values()){let i=Math.max(t.start,a),u=Math.min(t.end,s);if(i>=u)continue;let p=n.x(i),g=n.x(u),m=Math.abs(g-p),y=m>d+1?d:0,x=Math.min(p,g)+y/2,b=Math.max(m-y,1);if(!(b<=0))if(r&&t.categories.size>0){let i=mo(r.flatMap(e=>{let i=t.categories.get(e)||0;return 0===i?[]:[mo({category:e,value:i},t.categoryRows?.get(e))]}),t.rows),a=0;for(let{category:r,value:s}of i){let u=n.y(a),d=n.y(a+s),f=Math.min(u,d),p=Math.abs(u-d),g=(e.config.barColors?Xi(e.config.barColors,r):void 0)??l?.fill??c??"#4e79a7",m=mo({binStart:t.start,binEnd:t.end,total:t.total,category:r,categoryValue:s,categories:i},t.categoryRows?.get(r)),y=e.config.areaStyle?.(m)??{};o.push(xa(x,f,b,p,{fill:g,...h,...y},m,r)),a+=s}}else{let i=n.y(0),r=n.y(t.total),a=Math.min(i,r),s=Math.abs(i-r),u=l?.fill||c||"#007bff",d=mo({binStart:t.start,binEnd:t.end,total:t.total},t.rows),p=e.config.areaStyle?.(d)??{},g=xa(x,a,b,s,{fill:u,...h,...p},d);if(f){let e=g.style.fill,i="string"==typeof e||"object"==typeof e&&null!==e&&"hatch"===e.type?e:void 0,r=Ps(f,0,t.total,i);r.length>0&&(g.fillBands=r.map(e=>({y0:n.y(e.from),y1:n.y(e.to),fill:e.fill??u})))}o.push(g)}}let p=/* @__PURE__ */new Set;for(let e of i.values())p.add(e.start),p.add(e.end);return{nodes:o,binBoundaries:Array.from(p).sort((e,t)=>e-t)}},swarm:function(e,t){let i=[],r=e.config.swarmStyle||{},o=r.radius??3,n=r.fill??e.config.themeSemantic?.primary??"#007bff",a=r.opacity??.7,s=r.stroke,l=r.strokeWidth,c=r.cursor;for(let r of t){let t=e.getX(r),u=e.getY(r);if(null==u||Number.isNaN(u))continue;let d=e.scales.x(t),h=e.scales.y(u),f=n;if(e.getCategory){let t=String(e.getCategory(r));f=(e.config.barColors?Xi(e.config.barColors,t):void 0)??f}let{r:p,...g}=e.config.pointStyle?.(r)??{},m={type:"point",x:d,y:h,r:p??o,style:{fill:f,opacity:a,stroke:s,strokeWidth:l,cursor:c,...g},datum:r};e.getPointId&&(m.pointId=String(e.getPointId(r))),i.push(m)}return i},waterfall:function(e,t,i){let r=[],o=e.scales,n=e.config.waterfallStyle,a=t.filter(t=>{let i=e.getY(t),r=e.getX(t);return null!=i&&!Number.isNaN(i)&&null!=r&&isFinite(r)});if(0===a.length)return r;let s=n?.positiveColor??e.config.themeSemantic?.success??"#28a745",l=n?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",c=n?.gap??1,u=n?.stroke,d=n?.strokeWidth,h=n?.opacity,f=0;for(let t=0;t<a.length;t++){let p=a[t],g=e.getX(p),m=e.getY(p),y=f+m,x=o.x(g),b=t>0?o.x(e.getX(a[t-1])):void 0,v=t<a.length-1?o.x(e.getX(a[t+1])):void 0,w=null!=b?(b+x)/2:null!=v?x-(v-x)/2:x-i.width/20,k=null!=v?(x+v)/2:null!=b?x+(x-b)/2:x+i.width/20,A=Math.min(w,k)+c/2,S=Math.max(w,k)-c/2-A;if(S<=0){f=y;continue}let M=o.y(f),$=o.y(y),_=Math.min(M,$),P=Math.abs(M-$),L=m>=0?s:l,I={...p,baseline:f,cumEnd:y,delta:m,_connectorStroke:n?.connectorStroke,_connectorWidth:n?.connectorWidth},R={fill:L,stroke:u,strokeWidth:d,opacity:h,cursor:n?.cursor,...e.config.areaStyle?.(I)};r.push(xa(A,_,S,P,R,I)),f=y}return r},candlestick:function(e,t,i){if(!e.getHigh||!e.getLow||!e.scales)return[];let r=e.config.candlestickRangeMode??!1;if(!(r||e.getOpen&&e.getClose))return[];let o=[],n=e.config.candlestickStyle||{},a=n.rangeColor||"#6366f1",s=r?a:n.upColor||"#28a745",l=r?a:n.downColor||"#dc3545",c=r?a:n.wickColor||"#333",u=n.wickWidth||(r?2:1),d=n.bodyWidth??0;if(null==n.bodyWidth){let i=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);if(i.length>1){let t=1/0,r=e.scales.x(i[0]);for(let o=1;o<i.length;o++){let n=e.scales.x(i[o]),a=Math.abs(n-r);a>0&&a<t&&(t=a),r=n}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6}for(let a of t){let t=e.getX(a);if(null==t||Number.isNaN(t))continue;let h=e.getHigh(a),f=e.getLow(a);if(null==h||Number.isNaN(h)||null==f||Number.isNaN(f))continue;let p=r?h:e.getOpen(a),g=r?f:e.getClose(a);if(!r&&(null==p||Number.isNaN(p)||null==g||Number.isNaN(g)))continue;let m=g>=p,y=e.config.pointStyle?.(a)??{},x="string"==typeof y.fill?y.fill:void 0,b="string"==typeof y.stroke?y.stroke:void 0,v="number"==typeof y.strokeWidth?y.strokeWidth:void 0,w="number"==typeof y.opacity?y.opacity:"number"==typeof y.fillOpacity?y.fillOpacity:void 0,k={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(p),closeY:e.scales.y(g),highY:e.scales.y(h),lowY:e.scales.y(f),bodyWidth:d,upColor:x&&m?x:s,downColor:x&&!m?x:l,wickColor:b??(r&&x?x:c),wickWidth:v??u,isUp:m,style:{cursor:n.cursor,...y,...void 0!==w&&{opacity:w}},datum:a};r&&(k.isRange=!0,k.dotRadius=Math.max(2,Math.min(d/2,.12*i.height))),o.push(k)}return o},custom:()=>[]};function Is(){for(let e of Object.keys(Ls))Bn(e)||Wn({chartType:e,buildScene:Ls[e],canvasRenderers:[]})}function Rs(e){let t=e.parts.filter(e=>null!=e),i={};for(let e of t)for(let[t,r]of Object.entries(e.markCountByType))i[t]=(i[t]??0)+r;for(let[t,r]of Object.entries(e.additionalMarkCountByType??{}))r>0&&(i[t]=(i[t]??0)+r);let r=Object.values(i).reduce((e,t)=>e+t,0),o=0===r,n=Array.from(
4
+ /* @__PURE__ */new Set([...t.flatMap(e=>e.warnings),...e.extraWarnings??[],...o?["EMPTY_SCENE"]:[]])),a="string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${r} marks`;return{component:"",frameType:e.frameType,status:o?"empty":"ok",empty:o,markCount:r,markCountByType:i,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:t.reduce((e,t)=>e+t.annotationCount,0),ariaLabel:a,warnings:n,semanticStatus:"not-assessed",semanticDiagnostics:[]}}function Ts(e){let t={};for(let i of e){let e="string"==typeof i?.type&&i.type.length>0?i.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}function Cs(e){let t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Ns(e){if(!e||e.length<2)return;let t=Cs(e[0]),i=Cs(e[e.length-1]);return null!==t&&null!==i?[t,i]:void 0}function Fs(e){let{count:t,byType:i}=Ts(e.marks),r=0===t,o=[...e.extraWarnings??[]];r&&!o.includes("EMPTY_SCENE")&&o.push("EMPTY_SCENE"),e.annotationRender&&e.annotationRender.unrenderedCount>0&&!o.includes("UNRENDERED_ANNOTATIONS")&&o.push("UNRENDERED_ANNOTATIONS");let n=Array.isArray(e.annotations)?e.annotations.length:0,a=e.annotationRender?.renderedCount??n,s="string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,l=e.margin,c=l?{x:l.left,y:l.top,width:Math.max(1,e.width-l.left-l.right),height:Math.max(1,e.height-l.top-l.bottom)}:void 0;return{component:"",frameType:e.frameType,status:r?"empty":"ok",empty:r,markCount:t,markCountByType:i,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:a,...e.annotationRender?.layout?{layout:e.annotationRender.layout}:{},...e.annotationRender?{annotationInputCount:e.annotationRender.inputCount,unrenderedAnnotationCount:e.annotationRender.unrenderedCount,...e.annotationRender.unrenderedTypes.length>0?{unrenderedAnnotationTypes:e.annotationRender.unrenderedTypes}:{}}:{},ariaLabel:s,warnings:o,semanticStatus:"not-assessed",semanticDiagnostics:[],...l?{margin:l}:{},...c?{plot:c}:{}}}import*as Ds from"react";import{area as Es,line as zs}from"d3-shape";function Os(e){let t=Number.isFinite(e)&&e>0?e:6;return{width:Math.max(8,t),height:t,lineY:t/2}}import{jsx as js,jsxs as Ws}from"react/jsx-runtime";function Bs(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function Ys(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function Gs(e,t){return`${e}-hatch-${qe(Ys(t)).toString(36)}`}function Xs(e,t){let{background:i="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:n=6,angle:a=45,lineOpacity:s=1}=e,l=Os(n);/* */
5
+ return Ws("pattern",{id:t,width:l.width,height:l.height,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[i&&"transparent"!==i&&"none"!==i&&/* @__PURE__ */js("rect",{width:l.width,height:l.height,fill:i}),
6
+ /* @__PURE__ */js("line",{x1:0,y1:l.lineY,x2:l.width,y2:l.lineY,stroke:r,strokeWidth:o,...1!==s?{strokeOpacity:s}:{}})]},t)}function Vs(e,t,i="#4e79a7"){if(Bs(e)){let i=Gs(t,e);return{fill:`url(#${i})`,def:Xs(e,i)}}return e&&"string"==typeof e?{fill:e}:{fill:i}}function qs(e,t,i){if(!e||"object"!=typeof e)return;let r=e;if(!Array.isArray(r.stops))return;let o=r.stops.flatMap(e=>{if(!e||"object"!=typeof e)return[];let{offset:t,color:r,opacity:o}=e;return"number"==typeof t&&Number.isFinite(t)?[{offset:Math.max(0,Math.min(1,t)),color:"string"==typeof r&&r?r:i,opacity:"number"==typeof o&&Number.isFinite(o)?Math.max(0,Math.min(1,o)):void 0}]:[]}).sort((e,t)=>e.offset-t.offset);return o.length?{direction:"horizontal"===r.direction?"horizontal":"vertical"===r.direction?"vertical":t,stops:o}:void 0}function Hs(e,t,i,r){let o=qs(e,i,r);if(!o)return;let{direction:n,stops:a}=o,s=`${t}-gradient`;return{fill:`url(#${s})`,def:/* @__PURE__ */js("linearGradient",{id:s,x1:0,y1:0,x2:"horizontal"===n?"100%":0,y2:"vertical"===n?"100%":0,children:a.map((e,t)=>/* @__PURE__ */js("stop",{offset:100*e.offset+"%",stopColor:e.color,stopOpacity:e.opacity},`${e.offset}-${t}`))},s)}}import{curveMonotoneX as Us,curveMonotoneY as Zs,curveCardinal as Qs,curveCatmullRom as Ks,curveStep as Js,curveStepBefore as el,curveStepAfter as tl,curveBasis as il,curveNatural as rl}from"d3-shape";function ol(e){switch(e){case"monotoneX":return Us;case"monotoneY":return Zs;case"cardinal":return Qs;case"catmullRom":return Ks;case"step":return Js;case"stepBefore":return el;case"stepAfter":return tl;case"basis":return il;case"natural":return rl;default:return null}}function nl(e,t,i){let r=i;for(let i of t)"lesser"===i.thresholdType?e<i.value&&(r=i.color):e>i.value&&(r=i.color);return r}function al(e,t,i,r){if(e.length<2||t.length!==e.length||0===i.length)return[];let o=[],n=(e,t,i)=>{let r=o[o.length-1];r?.color===e?r.path.push(i):o.push({color:e,path:[t,i]})};for(let o=1;o<e.length;o++){let[a,s]=e[o-1],[l,c]=e[o],u=t[o-1],d=t[o]-u,h=[0,...0===d?[]:i.map(({value:e})=>(e-u)/d).filter(e=>e>0&&e<1&&Number.isFinite(e)).sort((e,t)=>e-t).filter((e,t,i)=>0===t||e!==i[t-1]),1];for(let e=1;e<h.length;e++){let t=h[e-1],o=h[e];n(nl(u+d*((t+o)/2),i,r),[a+(l-a)*t,s+(c-s)*t],[a+(l-a)*o,s+(c-s)*o])}}return o}import*as sl from"react";function ll(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function cl(e){let t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};let i=Math.min(e.w,e.h)/2,r=e=>Math.max(0,Math.min(e??0,i));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}import{jsx as ul,jsxs as dl}from"react/jsx-runtime";var hl={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function fl(e,t="#4e79a7"){return Bs(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function pl(e){let t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?`s_${t}`:t}function gl(e,t,i,r){let o=e.glyph;if(!o?.parts?.length||e.size<=0)return null;let n=Ye(o,e.size);if(n.scale<=0)return null;let a=`translate(${t},${i})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${n.offsetX},${n.offsetY}) scale(${n.scale})`,s=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=Xe(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?pl(`${r}-clip`):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>o.parts.map((i,r)=>{let o=t?"none"===i.fill?void 0:t:Ge(i.fill,s,e.accent),n=t?i.stroke&&"none"!==i.stroke?t:void 0:Ge(i.stroke??"none",s,e.accent);return o||n?/* @__PURE__ */ul("path",{d:i.d,fill:o??"none",stroke:n,strokeWidth:n?i.strokeWidth??1:void 0,strokeLinecap:i.strokeLinecap,strokeLinejoin:i.strokeLinejoin,opacity:i.opacity},r):null});/* */
7
+ return dl("g",{transform:a,opacity:1===u?void 0:u,children:[l&&c&&/* @__PURE__ */ul("clipPath",{id:c,children:/* @__PURE__ */ul("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?/* @__PURE__ */ul("g",{children:d(e.ghostColor)}):null,l&&c?/* @__PURE__ */ul("g",{clipPath:`url(#${c})`,children:d()}):d()]},r)}function ml(e,t){let i=e.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity))).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color??t,opacity:null==e.opacity?void 0:Math.max(0,Math.min(1,e.opacity))}));return i.length<2?null:i.map((e,t)=>/* @__PURE__ */ul("stop",{offset:e.offset,stopColor:e.color,stopOpacity:e.opacity},t))}function yl(e,t){let i=e.fillGradient;if(!i||"object"!=typeof i)return null;let r=e.x,o=e.y,n=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(o=e.y+e.h,a=e.y):"right"===e.roundedEdge?(r=e.x+e.w,o=e.y,n=e.x,a=e.y):"left"===e.roundedEdge&&(r=e.x,o=e.y,n=e.x+e.w,a=e.y);let s=ml(i.stops,fl(e.style.fill));return s?/* @__PURE__ */ul("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:r,y1:o,x2:n,y2:a,children:s}):null}function xl(e){let{x:t,y:i,w:r,h:o}=e,{tl:n,tr:a,br:s,bl:l}=cl(e),c=`M${t+n},${i}`;return c+=` L${t+r-a},${i}`,a>0&&(c+=` A${a},${a} 0 0 1 ${t+r},${i+a}`),c+=` L${t+r},${i+o-s}`,s>0&&(c+=` A${s},${s} 0 0 1 ${t+r-s},${i+o}`),c+=` L${t+l},${i+o}`,l>0&&(c+=` A${l},${l} 0 0 1 ${t},${i+o-l}`),c+=` L${t},${i+n}`,n>0&&(c+=` A${n},${n} 0 0 1 ${t+n},${i}`),c+=" Z",c}function bl(e,t,i){let r=je(e.symbolType,e.size,e.path),o=e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`;/* */
8
+ return ul("path",{d:r,transform:o,fill:e.style.fill?fl(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${i??""}symbol-${t}`)}function vl(e,t,i){let r=e.y,o=e.y+e.h,n=[],a=[];e.fillBands.forEach((t,s)=>{let l,c=Math.max(Math.min(t.y0,t.y1),r),u=Math.min(Math.max(t.y0,t.y1),o);if(u>c){if(Bs(t.fill)){let e=`${i}-band-${s}`;n.push(Xs(t.fill,e)),l=`url(#${e})`}else l=fl(t.fill);a.push(/* @__PURE__ */ul("rect",{x:e.x,y:c,width:e.w,height:u-c,fill:l},s))}});let s=e.style.stroke&&"none"!==e.style.stroke;/* */
9
+ return dl("g",{opacity:e.style.opacity,children:[n.length>0&&/* @__PURE__ */ul("defs",{children:n}),a,s&&/* @__PURE__ */ul("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:"none",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},`rect-${t}`)}function wl(e,t,i){let r="point"===e.type,o=r?"circle":"rect",n=r?{cx:e.x,cy:e.y,r:e.r}:{x:e.x,y:e.y,width:e.w,height:e.h},a=`${i?`${i}-`:""}${r?"point":"xyrect"}-${t}-hatch`;if(!r&&e.fillBands&&e.fillBands.length>0)return vl(e,t,a);let s=Bs(e.style.fill)?Xs(e.style.fill,a):void 0;/* */
10
+ return dl(sl.Fragment,{children:[s&&/* @__PURE__ */ul("defs",{children:s}),sl.createElement(o,{...n,fill:s?`url(#${a})`:fl(e.style.fill),opacity:r?e.style.opacity??e.style.fillOpacity??.8:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},`${e.type}-${t}`)}import*as kl from"react";import{jsx as Al}from"react/jsx-runtime";function Sl(e){if(!1!==e?.interactive)return e?.style?.cursor}function Ml(e,t,i){let r=Sl(t);return r&&null!=e&&!1!==e?/* @__PURE__ */Al("g",{style:{cursor:r},"data-semiotic-mark-cursor":r,children:e},i):e}import{jsx as $l,jsxs as _l}from"react/jsx-runtime";function Pl(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}let t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}function Ll(e,t){let i=e.fillGradient;if(!i||"object"!=typeof i)return null;let r=1/0,o=-1/0;if(e.fillGradientSpan)[r,o]=e.fillGradientSpan;else{for(let[,t]of e.topPath)r=Math.min(r,t);for(let[,t]of e.bottomPath)o=Math.max(o,t)}if(!Number.isFinite(r)||!Number.isFinite(o))return null;let n=ml(i.stops,fl(e.style.fill));return n?/* @__PURE__ */$l("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:r,x2:0,y2:o,children:n}):null}function Il(e,t,i,r){if(!e||t.length<2)return null;let o=ml(e.stops,r);return o?/* @__PURE__ */$l("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:o}):null}function Rl(e,t,i,r=30){let o=Tl(e,t,i,r);return"area"===e.type?o:Ml(o,e,`xy-cursor-${t}`)}function Tl(e,t,i,r=30){switch(e.type){case"line":{let r=e;if(0===r.path.length)return null;let o=ol(r.curve),n=o?zs().x(([e])=>e).y(([,e])=>e).curve(o)(r.path)??"":"M"+r.path.map(([e,t])=>`${e},${t}`).join("L"),a=pl(`${i?`${i}-`:""}line-${t}-stroke-gradient`),s=Il(r.strokeGradient,r.path,a,r.style.stroke||"#4e79a7");/* */
11
+ return _l(Ds.Fragment,{children:[s&&/* @__PURE__ */$l("defs",{children:s}),
12
+ /* @__PURE__ */$l("path",{d:n,fill:"none",stroke:s?`url(#${a})`:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth??2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})]},`line-${t}`)}case"area":{let o=e;if(0===o.topPath.length)return null;let n=ol(o.curve),a=n&&o.topPath.length>=2&&o.bottomPath.length>=2?Es().x(([e])=>e).y0((e,t)=>o.bottomPath[t][1]).y1(([,e])=>e).curve(n)(o.topPath)??"":`M${o.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...o.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`,s=`${i?`${i}-`:""}area-${t}-hatch`,l=Bs(o.style.fill)?Xs(o.style.fill,s):void 0,c=pl(`${i?`${i}-`:""}area-${t}-gradient`),u=Ll(o,c),d=u?`url(#${c})`:l?`url(#${s})`:fl(o.style.fill),h=u?void 0:o.style.fillOpacity??.7,f=n?zs().x(([e])=>e).y(([,e])=>e).curve(n)(o.topPath)??"":"M"+o.topPath.map(([e,t])=>`${e},${t}`).join("L"),p=Sl(o),g=p&&r>=0?/* @__PURE__ */$l("path",{d:f,fill:"none",stroke:"transparent",strokeWidth:Math.max(1,2*r),strokeLinecap:"round",pointerEvents:"stroke",style:{cursor:p},"data-semiotic-mark-cursor":p,"data-semiotic-cursor-hit-target":"area-top-path","aria-hidden":"true"},`area-${t}-cursor-target`):null,m=pl(`${i?`${i}-`:""}area-${t}-stroke-gradient`),y=!(!o.colorThresholds?.length||!o.rawValues||o.rawValues.length!==o.topPath.length),x=!!o.strokeColorBands?.length,b=y||x?null:Il(o.strokeGradient,o.topPath,m,o.style.stroke||"#4e79a7"),v=o.style.strokeWidth??2,w=1/0,k=-1/0;for(let[e]of o.topPath)e<w&&(w=e),e>k&&(k=e);let A=x?o.strokeColorBands.map((e,r)=>pl(`${i?`${i}-`:""}area-${t}-stroke-band-${r}`)):[],S=x?o.strokeColorBands.map((e,t)=>/* @__PURE__ */$l("clipPath",{id:A[t],children:/* @__PURE__ */$l("rect",{x:w-v,y:e.y,width:k-w+2*v,height:e.height})},A[t])):null,M=o.style.stroke&&"none"!==o.style.stroke?x?o.strokeColorBands.map((e,i)=>/* @__PURE__ */$l("path",{d:f,fill:"none",stroke:e.color??fl(o.style.stroke),strokeWidth:v,opacity:(o.style.opacity??1)*(e.opacity??1),clipPath:`url(#${A[i]})`},`area-${t}-stroke-band-${i}`)):y?al(o.topPath,o.rawValues,o.colorThresholds,fl(o.style.stroke)).map((e,i)=>/* @__PURE__ */$l("path",{d:"M"+e.path.map(([e,t])=>`${e},${t}`).join("L"),fill:"none",stroke:e.color,strokeWidth:v,opacity:o.style.opacity},`area-${t}-threshold-${i}`)):/* @__PURE__ */$l("path",{d:f,fill:"none",stroke:b?`url(#${m})`:fl(o.style.stroke),strokeWidth:v,opacity:o.style.opacity}):null;if(o.clipRect){let e=`${i?`${i}-`:""}area-clip-${t}`;/* */
13
+ return _l("g",{children:[
14
+ /* @__PURE__ */_l("defs",{children:[u,!u&&l,b,S,
15
+ /* @__PURE__ */$l("clipPath",{id:e,children:/* @__PURE__ */$l("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),
16
+ /* @__PURE__ */_l("g",{clipPath:`url(#${e})`,children:[
17
+ /* @__PURE__ */$l("path",{d:a,fill:d,fillOpacity:h,opacity:o.style.opacity,stroke:"none"}),M,g]})]},`area-${t}`)}/* */
18
+ return _l(Ds.Fragment,{children:[(u||l||b||S)&&/* @__PURE__ */_l("defs",{children:[u,!u&&l,b,S]}),
19
+ /* @__PURE__ */$l("path",{d:a,fill:d,fillOpacity:h,opacity:o.style.opacity,stroke:"none"}),M,g]},`area-${t}`)}case"point":case"rect":return wl(e,t,i);case"symbol":return bl(e,t);case"glyph":{let r=e;return gl(r,r.x,r.y,`${i??""}glyph-${r.pointId??t}`)}case"heatcell":{let i=e,r={x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill,stroke:i.style?.stroke,strokeWidth:i.style?.strokeWidth,...null!=i.style?.opacity&&{opacity:i.style.opacity}};if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){let e=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?String(i.value):Math.abs(i.value)>=100?i.value.toFixed(0):Math.abs(i.value)>=1?i.value.toFixed(1):i.value.toPrecision(3),[o,n,a]=Pl(i.fill),s=.299*o+.587*n+.114*a>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));/* */
20
+ return _l("g",{children:[
21
+ /* @__PURE__ */$l("rect",{...r}),
22
+ /* @__PURE__ */$l("text",{className:"semiotic-heatmap-value",x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:`${l}px`,fontFamily:"var(--semiotic-font-family, sans-serif)",children:e})]},`heatcell-${t}`)}/* */
23
+ return $l("rect",{...r},`heatcell-${t}`)}case"candlestick":{let r=e,o=`${i?`${i}-`:""}candle-${t}-hatch`,n=Bs(r.style?.fill)?Xs(r.style.fill,o):void 0,a=n?`url(#${o})`:void 0,{fill:s,...l}=r.style??{};if(r.isRange){let e=r.dotRadius??Math.max(2,r.bodyWidth/2),i=a??r.wickColor;/* */
24
+ return _l(Ds.Fragment,{children:[n&&/* @__PURE__ */$l("defs",{children:n}),
25
+ /* @__PURE__ */_l("g",{style:l,children:[
26
+ /* @__PURE__ */$l("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth,opacity:r.style?.opacity}),
27
+ /* @__PURE__ */$l("circle",{cx:r.x,cy:r.highY,r:e,fill:i,opacity:r.style?.opacity}),
28
+ /* @__PURE__ */$l("circle",{cx:r.x,cy:r.lowY,r:e,fill:i,opacity:r.style?.opacity})]})]},`candle-${t}`)}let c=Math.min(r.openY,r.closeY),u=Math.max(Math.abs(r.openY-r.closeY),1),d=r.isUp?r.upColor:r.downColor,h=a??d;/* */
29
+ return _l(Ds.Fragment,{children:[n&&/* @__PURE__ */$l("defs",{children:n}),
30
+ /* @__PURE__ */_l("g",{style:l,children:[
31
+ /* @__PURE__ */$l("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth,opacity:r.style?.opacity}),
32
+ /* @__PURE__ */$l("rect",{x:r.x-r.bodyWidth/2,y:c,width:r.bodyWidth,height:u,fill:h,stroke:a?r.wickColor:d,strokeWidth:1,opacity:r.style?.opacity})]})]},`candle-${t}`)}default:return null}}var Cl=/* @__PURE__ */new Set;function Nl(e){if(!e||"object"!=typeof e)return!1;let t=e;return"string"==typeof t.id&&"function"==typeof t.cacheKey&&"function"==typeof t.drawCanvas&&"function"==typeof t.renderStaticSVG}function Fl(e,t){let i="function"==typeof e?e(t.datum??null,t):e;return Nl(i)?i:void 0}function Dl(e,t){if("production"===process.env.NODE_ENV)return;let i=`${e}:${t}`;Cl.has(i)||(Cl.add(i),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function El(e){let{node:t,index:i,renderMode:r,fallback:o}=e,n=Fl(r,t);if(!n)return{element:o(),renderedByBackend:!1};let a=n.renderStaticSVG({node:t,style:t.style??{},key:`${n.id}-${i}`});return null!=a?{element:Ml(a,t,`${n.id}-${i}-cursor`),renderedByBackend:!0}:(Dl(n.id,t.type??"unknown"),{element:o(),renderedByBackend:!1})}function zl(e){return El(e).element}function Ol(e){let t=[];return e.nodes.forEach((i,r)=>{let o=El({node:i,index:r,renderMode:e.renderMode,fallback:()=>e.fallback(i,r)});null!==o.element&&void 0!==o.element&&!1!==o.element&&t.push({node:i,index:r,...o})}),t}import{scaleOrdinal as jl}from"d3-scale";import{jsx as Wl,jsxs as Bl}from"react/jsx-runtime";function Yl(e,t,i){if(t&&"object"==typeof t&&!Array.isArray(t)){let e=t;return t=>Xi(e,t)??"#999"}let r=Array.isArray(t)?t:i.colors.categorical.length>0?i.colors.categorical:bi;return jl().domain(e).range(r)}function Gl(e,t,i){if(0===e.length)return;let r=Yl(e,t,i);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:r(e.label)})}]}}function Xl(e){return"left"===e?"start":"right"===e?"end":e??"start"}function Vl(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function ql(e){return e.typography.legendFontFamily??e.typography.fontFamily}function Hl(e){return e.typography.legendFontWeight}function Ul(e,t,i,r){let o=Vl(r);return t+i+Math.ceil(e.length*o*.58)}function Zl(e){let{categories:t,theme:i,position:r="right",totalWidth:o,margin:n,legendLayout:a}=e,{swatchSize:s,labelGap:l,itemGap:c,rowHeight:u}=yt(a),d=s+l,h="top"===r||"bottom"===r,f=Math.max(s,o-n.left-n.right),p=t.map(e=>Ul(e,s,l,i));if(h){let e=Math.max(s,a?.maxWidth??f),i=[],r=0,o=0;p.forEach((t,n)=>{let a=0===o?t:o+c+t;o>0&&a>e?(i.push({start:r,end:n,width:o}),r=n,o=t):o=a}),t.length>0&&i.push({start:r,end:t.length,width:o});let n=Xl(a?.align),l=[];return i.forEach((i,r)=>{let o="center"===n?Math.max(0,(e-i.width)/2):"end"===n?Math.max(0,e-i.width):0;for(let e=i.start;e<i.end;e++)l.push({category:t[e],width:p[e],x:o,y:r*u}),o+=p[e]+c}),{items:l,width:i.reduce((e,t)=>Math.max(e,t.width),0),height:i.length*u,swatchSize:s,labelOffset:d,swatchRadius:0}}let g=p.reduce((e,t)=>Math.max(e,t),0);return{items:t.map((e,t)=>({category:e,width:p[t],x:0,y:t*u})),width:g,height:t.length*u,swatchSize:s,labelOffset:d,swatchRadius:0}}function Ql(e){let{legendGroups:t,theme:i,position:r="right",totalWidth:o,margin:n,legendLayout:a}=e,{swatchSize:s,labelGap:l,rowHeight:c}=yt(a),u=s+l,d=Math.max(12,Vl(i)),h="top"===r||"bottom"===r,f=Math.max(s,o-n.left-n.right);if(h){let r=Math.max(s,a?.maxWidth??f),o=Xl(a?.align),n=0,l=0,c=[];for(let o of t){let t=o.items.map(e=>e.label),u=Zl({...e,categories:t,legendLayout:{...a,maxWidth:Math.max(s,r-d-8),align:"start"}}),h=o.label?d:0,f=o.label?Ul(o.label,0,0,i):0,p=h>0?h+8:0,g=p+u.width,m=Math.max(u.height,f);c.push({group:o,x:n,y:0,itemOffsetX:p,itemOffsetY:0,width:g,height:m,items:u.items}),n+=g+12,l=Math.max(l,m)}let h=c.length>0?n-12:0,p=h>r?0:"center"===o?Math.max(0,(r-h)/2):"end"===o?Math.max(0,r-h):0;return{groups:c.map(e=>({...e,x:e.x+p})),width:h,height:l,swatchSize:s,labelOffset:u,swatchRadius:0}}let p=xt(t.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),c);return{groups:[],width:t.reduce((e,t)=>t.items.reduce((e,t)=>Math.max(e,Ul(t.label,s,l,i)),Math.max(e,t.label?Ul(t.label,0,0,i):0)),0),height:p.at(-1)?.endY??0,swatchSize:s,labelOffset:u,swatchRadius:0}}function Kl(e){let t="top"===e.position||"bottom"===e.position,i=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??i,200),height:e.gradient.label?46:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?126:108,swatchSize:14}}function Jl(e){let{categories:t,colorScheme:i,theme:r,position:o="right",totalWidth:n,totalHeight:a,margin:s}=e;if(!t||0===t.length)return null;let l=Yl(t,i,r),c="top"===o||"bottom"===o,u=Zl(e),d={...Gl(t,i,r),legendDistance:e.legendDistance},h=e.reservedWidth??ot(d,e.legendLayout),{x:f,y:p}=mt(d,{totalWidth:n,totalHeight:a,margin:s,position:o,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:h}),g=c?void 0:xt([{hasLabel:!1,itemCount:t.length}],Math.max(u.swatchSize,e.legendLayout?.rowHeight??22))[0],m=u.items.map((e,t)=>/* @__PURE__ */Bl("g",{transform:`translate(${e.x},${e.y+(g?.itemsY??0)})`,children:[
33
+ /* @__PURE__ */Wl("rect",{width:u.swatchSize,height:u.swatchSize,fill:l(e.category),rx:u.swatchRadius}),
34
+ /* @__PURE__ */Wl("text",{x:u.labelOffset,y:u.swatchSize/2,dominantBaseline:"central",fontSize:Vl(r),fill:r.colors.text,fontFamily:ql(r),children:e.category})]},`legend-${t}`));/* */
35
+ return Bl("g",{className:"semiotic-legend",transform:`translate(${f},${p})`,fontWeight:Hl(r),children:[g&&/* @__PURE__ */Wl("line",{x1:0,y1:g.lineY,x2:h,y2:g.lineY,stroke:"gray"}),m]})}function ec(e){if(!e.legendGroups.some(e=>e.items.some(()=>!0)))return null;let t=Ql(e),i="top"===e.position||"bottom"===e.position,r={legendGroups:e.legendGroups,legendDistance:e.legendDistance},o=e.reservedWidth??ot(r,e.legendLayout),n=e.theme.colors.grid||e.theme.colors.textSecondary,{x:a,y:s}=mt(r,{totalWidth:e.totalWidth,totalHeight:e.totalHeight,margin:e.margin,position:e.position,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:o});if(!i){let i=xt(e.legendGroups.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),Math.max(t.swatchSize,e.legendLayout?.rowHeight??22)),r=e.legendGroups.flatMap((r,n)=>{let a=i[n],s=r.type??"fill",l=[
36
+ /* @__PURE__ */Wl("line",{x1:0,y1:a.lineY,x2:o,y2:a.lineY,stroke:"gray"},`legend-group-neatline-${n}`)];return r.label&&null!=a.labelY&&l.push(
37
+ /* @__PURE__ */Wl("text",{y:a.labelY,fontSize:Vl(e.theme),fill:e.theme.colors.text,fontFamily:ql(e.theme),children:r.label},`legend-group-label-${n}`)),l.push(
38
+ /* @__PURE__ */Wl("g",{transform:`translate(0,${a.itemsY})`,children:r.items.map((i,o)=>{let a=r.styleFn(i,o),l="function"==typeof s?s(i):"line"===s?/* @__PURE__ */Wl("line",{x1:0,y1:0,x2:t.swatchSize,y2:t.swatchSize,style:a}):/* @__PURE__ */Wl("rect",{width:t.swatchSize,height:t.swatchSize,rx:t.swatchRadius,style:a});/* */
39
+ return Bl("g",{transform:`translate(0,${o*Math.max(t.swatchSize,e.legendLayout?.rowHeight??22)})`,children:[l,
40
+ /* @__PURE__ */Wl("text",{x:t.labelOffset,y:t.swatchSize/2,dominantBaseline:"central",fontSize:Vl(e.theme),fill:e.theme.colors.text,fontFamily:ql(e.theme),children:i.label})]},`legend-${n}-${o}`)})},`legend-group-${n}`)),l});/* */
41
+ return Wl("g",{className:"semiotic-legend",transform:`translate(${a},${s})`,"data-orientation":"vertical",fontWeight:Hl(e.theme),children:r})}let l=t.groups.flatMap((i,r)=>{let{group:o}=i,a=o.type??"fill",s=[];if(o.label&&s.push(
42
+ /* @__PURE__ */Wl("text",{transform:`translate(${i.x},${i.y}) rotate(90)`,textAnchor:"start",fontSize:Vl(e.theme),fill:e.theme.colors.text,fontFamily:ql(e.theme),children:o.label},`legend-group-label-${r}`)),s.push(...i.items.map((n,s)=>{let l=o.items[s],c=o.styleFn(l,s),u="function"==typeof a?a(l):"line"===a?/* @__PURE__ */Wl("line",{x1:0,y1:0,x2:t.swatchSize,y2:t.swatchSize,style:c}):/* @__PURE__ */Wl("rect",{width:t.swatchSize,height:t.swatchSize,rx:t.swatchRadius,style:c});/* */
43
+ return Bl("g",{transform:`translate(${i.x+i.itemOffsetX+n.x},${i.y+i.itemOffsetY+n.y})`,children:[u,
44
+ /* @__PURE__ */Wl("text",{x:t.labelOffset,y:t.swatchSize/2,dominantBaseline:"central",fontSize:Vl(e.theme),fill:e.theme.colors.text,fontFamily:ql(e.theme),children:n.category})]},`legend-${r}-${s}`)})),r<t.groups.length-1){let e=i.x+i.width+6;s.push(
45
+ /* @__PURE__ */Wl("line",{x1:e,y1:0,x2:e,y2:t.height,stroke:n},`legend-group-separator-${r}`))}return s});/* */
46
+ return Wl("g",{className:"semiotic-legend",transform:`translate(${a},${s})`,"data-orientation":"horizontal",fontWeight:Hl(e.theme),children:l})}function tc(e){let t=Kl(e),i="top"===e.position||"bottom"===e.position,r={gradient:e.gradient,legendDistance:e.legendDistance},o=ot(r),n=(e.idPrefix?`${e.idPrefix}-`:"")+"semiotic-static-gradient-legend",a=e.gradient.format||Ue(e.gradient.domain),{x:s,y:l}=mt(r,{totalWidth:e.totalWidth,totalHeight:e.totalHeight,margin:e.margin,position:e.position,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:o}),c=Array.from({length:17},(t,r)=>{let o=r/16,n=i?e.gradient.domain[0]+o*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-o*(e.gradient.domain[1]-e.gradient.domain[0]);/* */
47
+ return Wl("stop",{offset:o,stopColor:e.gradient.colorFn(n)},r)});if(i){let i=e.gradient.label?12:void 0,r=e.gradient.label?18:0;/* */
48
+ return Bl("g",{className:"semiotic-legend",transform:`translate(${s},${l})`,fontWeight:Hl(e.theme),children:[
49
+ /* @__PURE__ */Wl("defs",{children:/* @__PURE__ */Wl("linearGradient",{id:n,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),e.gradient.label&&/* @__PURE__ */Wl("text",{x:t.width/2,y:i,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:ql(e.theme),children:e.gradient.label}),
50
+ /* @__PURE__ */Wl("rect",{x:0,y:r,width:t.width,height:12,fill:`url(#${n})`,rx:2}),
51
+ /* @__PURE__ */Wl("text",{x:0,y:r+12+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:ql(e.theme),children:a(e.gradient.domain[0])}),
52
+ /* @__PURE__ */Wl("text",{x:t.width,y:r+12+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:ql(e.theme),children:a(e.gradient.domain[1])})]})}let u=e.gradient.label?12:void 0,d=e.gradient.label?18:0;/* */
53
+ return Bl("g",{className:"semiotic-legend",transform:`translate(${s},${l})`,fontWeight:Hl(e.theme),children:[
54
+ /* @__PURE__ */Wl("defs",{children:/* @__PURE__ */Wl("linearGradient",{id:n,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),e.gradient.label&&/* @__PURE__ */Wl("text",{x:0,y:u,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:ql(e.theme),children:e.gradient.label}),
55
+ /* @__PURE__ */Wl("rect",{x:0,y:d,width:14,height:100,fill:`url(#${n})`,rx:2}),
56
+ /* @__PURE__ */Wl("text",{x:19,y:d+10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:ql(e.theme),children:a(e.gradient.domain[1])}),
57
+ /* @__PURE__ */Wl("text",{x:19,y:d+100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:ql(e.theme),children:a(e.gradient.domain[0])})]})}function ic(e,t){if(!t||!e||0===e.length)return[];let i="function"==typeof t?t:e=>e[t],r=/* @__PURE__ */new Set;for(let t of e){let e=i(t);null!=e&&r.add(String(e))}return Array.from(r)}import*as rc from"react";var oc=(e,t)=>({width:Array.from(e).length*t.size*.65,height:1.2*t.size,ascent:.9*t.size,source:"estimated"}),nc={INVALID_PROJECTION:"Check endpoint values and the scale domain, especially log-scale values.",INSUFFICIENT_SPACE:"Increase chart height or the label-side margin, or reduce the label font size.",TIED_ENDPOINTS:"Use connectors or a legend to distinguish series sharing an endpoint.",LABEL_OMITTED:"Consult the accessible series list; increase the label rail space to restore visible labels.",ESTIMATED_METRICS:"Load the intended font and remeasure before asserting collision-free text.",RENDER_FAILURE:"Inspect the annotation renderer; the placed label did not produce a node.",UNSUPPORTED_GEOMETRY:"Inspect custom-rendered text; its geometry has not been measured by the label solver.",LABEL_COLLISION:"Increase spacing or shorten the affected labels.",LABEL_OVERFLOW:"Increase the allocated bounds or shorten the affected labels."};function ac(e,t,i="end",r=2){let o,n=/* @__PURE__ */new Map,a=/* @__PURE__ */new Map,s=(e,t)=>{let i=a.get(e)??{count:0,labelIds:[]};i.count++,i.labelIds.length<20&&i.labelIds.push(t),a.set(e,i)},l=(e,t)=>{n.set(e,{id:e,status:"omitted",reason:t}),s(t,e),s("LABEL_OMITTED",e)},c=[...e].sort((e,t)=>(Number.isFinite(e.anchor.y)?e.anchor.y:1/0)-(Number.isFinite(t.anchor.y)?t.anchor.y:1/0)||(e.id<t.id?-1:e.id>t.id?1:0)),u=[],d=0;for(let e of c){let{id:i,anchor:n,measurement:a}=e;if("estimated"===a.source&&s("ESTIMATED_METRICS",i),![n.x,n.y,a.width,a.height,a.ascent].every(Number.isFinite)||a.width<0||a.height<=0){l(i,"INVALID_PROJECTION");continue}o===n.y&&s("TIED_ENDPOINTS",i),o=n.y;let c=a.height+(u.length?r:0);![t.x,t.y,t.width,t.height,r].every(Number.isFinite)||r<0||a.width>t.width||d+c>t.height?l(i,"INSUFFICIENT_SPACE"):(u.push(e),d+=c)}let h=se({desired:u.map(e=>e.anchor.y-e.measurement.height/2),minGaps:u.slice(0,-1).map(e=>e.measurement.height+r),min:t.y,max:t.y+t.height-(u.at(-1)?.measurement.height??0)});u.forEach((e,r)=>{let o={x:"end"===i?t.x:t.x+t.width-e.measurement.width,y:h[r],width:e.measurement.width,height:e.measurement.height},a="end"===i?o.x:o.x+o.width,s=o.y+o.height/2,l={x:a-e.anchor.x,y:s-e.anchor.y};n.set(e.id,{id:e.id,status:"placed",box:o,offset:l,...Math.abs(l.y)>.01||Math.abs(l.x)>6.01?{connector:{x1:e.anchor.x,y1:e.anchor.y,x2:a,y2:s}}:{}})});let f=e.map(e=>n.get(e.id)),p=f.filter(e=>"placed"===e.status&&Math.abs(e.offset.y)>.01),g=f.filter(e=>"omitted"===e.status),m=e.filter(e=>"estimated"===e.measurement.source).length;return{dispositions:f,evidence:{status:m||g.length?"incomplete":"complete",requested:e.length,rendered:u.length,displaced:p.length,omitted:g.length,omittedIds:g.slice(0,20).map(e=>e.id),displacedIds:p.slice(0,20).map(e=>e.id),measurement:{measured:e.length-m,estimated:m},collisions:0,overflows:0,fallback:"accessible-series-list",findings:[...a].map(([e,t])=>({code:e,...t,remedy:nc[e]})),coverage:{directLabels:"assessed",axisLabels:"not-assessed"}}}}import{jsx as sc,jsxs as lc}from"react/jsx-runtime";function cc(e,t){let i=e.filter(e=>e._directLabel);if(!i.length)return{node:null};let r=i[0]._directLabel.position,o=t.measure??oc,n=i.map(e=>({family:t.fontFamily||"sans-serif",version:t.fontVersion??0,weight:400,size:e.fontSize||11})),a=i.map((e,i)=>{let r=(e,t)=>{if(null==e||!t)return NaN;try{return t(Number(e))}catch{return NaN}};return{id:String(e._directLabel.id),anchor:{x:r(e.x,t.scales?.x),y:r(e.y,t.scales?.y)},measurement:o(String(e.label),n[i])}}),s=Math.max(0,(t.margin?.["end"===r?"right":"left"]??0)-10),l=ac(a,{x:"end"===r?t.width+6:-s-6,y:0,width:s,height:t.height},r),c=l.dispositions.map((e,r)=>{if("omitted"===e.status)return null;let o=e.box,s=e.connector,c=i[r],u=/* @__PURE__ */lc("g",{"data-direct-label-id":e.id,children:[s&&/* @__PURE__ */sc("line",{...s,stroke:c.color,strokeWidth:.75}),
58
+ /* @__PURE__ */sc("text",{x:o.x+(a[r].measurement.left??0),y:o.y+a[r].measurement.ascent,fontFamily:n[r].family,fontWeight:n[r].weight,fontSize:n[r].size,fill:c.color,textAnchor:"start",children:c.label})]},e.id),d=t.renderLabel?t.renderLabel({...c,dx:o.x+(a[r].measurement.left??0)-a[r].anchor.x,dy:o.y+a[r].measurement.ascent-a[r].anchor.y,fontFamily:n[r].family},r,u):u;if(!d){let t=l.evidence;t.rendered--,t.omitted++,t.omittedIds.length<20&&t.omittedIds.push(e.id),Math.abs(e.offset.y)>.01&&t.displaced--,t.displacedIds=t.displacedIds.filter(t=>t!==e.id);for(let i of["RENDER_FAILURE","LABEL_OMITTED"]){let r=t.findings.find(e=>e.code===i);r||(r={code:i,count:0,labelIds:[],remedy:nc[i]},t.findings.push(r)),r.count++,r.labelIds.length<20&&r.labelIds.push(e.id)}}if(d!==u&&(l.evidence.status="incomplete",d)){let t=l.evidence.findings.find(e=>"UNSUPPORTED_GEOMETRY"===e.code);t||(t={code:"UNSUPPORTED_GEOMETRY",count:0,labelIds:[],remedy:nc.UNSUPPORTED_GEOMETRY},l.evidence.findings.push(t)),t.count++,t.labelIds.length<20&&t.labelIds.push(e.id)}return d?/* @__PURE__ */sc(rc.Fragment,{children:d},e.id):null}),u=/* @__PURE__ */sc("g",{role:"list","aria-label":"Series endpoints","data-direct-label-fallback":"accessible-series-list",children:i.map((e,t)=>/* @__PURE__ */sc("g",{role:"listitem","aria-label":`${e.label}: x ${String(e.x)}, y ${String(e.y)}`,children:/* @__PURE__ */sc("title",{children:`${e.label}: x ${String(e.x)}, y ${String(e.y)}`})},a[t].id))});return{evidence:l.evidence,node:/* @__PURE__ */lc("g",{className:"semiotic-direct-labels","data-label-layout":JSON.stringify(l.evidence),children:[c,u]},"direct-labels")}}function uc(e){return"string"==typeof e&&e.includes("var(")}var dc=/^\s*var\(\s*--[^,)\s]+\s*(?:,\s*([\s\S]*))?\)\s*$/;function hc(e){let t=dc.exec(e);if(!t)return uc(e)?void 0:e;let i=t[1]?.trim();return i?hc(i):void 0}import{jsx as fc,jsxs as pc}from"react/jsx-runtime";var gc="var(--semiotic-bg, #ffffff)";function mc(e,t){return String(e).length*t*.6}function yc(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{...e,type:e.type??"halo"}}function xc(e){let{x:t,y:i,text:r,fill:o,fontSize:n=12,fontWeight:a,fontFamily:s,textAnchor:l="start",dominantBaseline:c,background:u,className:d}=e,h=yc(u),f=e=>/* @__PURE__ */fc("text",{x:t,y:i,textAnchor:l,dominantBaseline:c,fill:o,fontSize:n,fontWeight:a,fontFamily:s,className:d,...e?{style:{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}}:{},children:r});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??gc,strokeWidth:h.haloWidth??3});let p,g,m=h.padding??{x:6,y:3},y="number"==typeof m?m:m.x,x="number"==typeof m?m:m.y,b=mc(r,n),v=b+2*y,w=n+2*x;p="middle"===l?t-b/2-y:"end"===l?t-b-y:t-y,g="middle"===c||"central"===c?i-w/2:"hanging"===c||"text-before-edge"===c?i-x:i-.8*n-x;let k=h.fill??gc,A={};return uc(k)&&(A.fill=k),uc(h.stroke)&&(A.stroke=h.stroke),/* @__PURE__ */pc("g",{className:d,children:[
59
+ /* @__PURE__ */fc("rect",{x:p,y:g,width:v,height:w,rx:h.radius??3,ry:h.radius??3,fill:uc(k)?hc(k):k,fillOpacity:h.opacity??.85,stroke:uc(h.stroke)?hc(h.stroke):h.stroke,strokeWidth:h.strokeWidth,...A.fill||A.stroke?{style:A}:{}}),f()]})}import{jsx as bc}from"react/jsx-runtime";function vc(e,t,i){if(!e)return null;let r="object"==typeof e?e:{};/* */
60
+ return bc("circle",{className:"semiotic-threshold-end-cap",cx:t[0],cy:t[1],r:Math.max(0,r.radius??4),fill:r.fill??i})}import{jsx as wc,jsxs as kc}from"react/jsx-runtime";function Ac({ann:e,position:t,vertical:i,width:r,height:o,color:n,fontSize:a=12,fontFamily:s,bold:l,background:c,dash:u="6,3",labelGap:d=4}){let h=e.labelPosition,f=t>.6*r,p=i?t+(f?-4:4):"left"===h?4:"center"===h?r/2:r-4,g=i?"bottom"===h?o-4:"center"===h?o/2:16:t<20?Math.min(o-4,t+16):t-d,m=i?f?"end":"start":"left"===h?"start":"center"===h?"middle":"end",y=i?[t,0]:[0,t],x=i?[t,o]:[r,t];/* */
61
+ return kc("g",{opacity:e.opacity,children:[
62
+ /* @__PURE__ */wc("line",{x1:y[0],y1:y[1],x2:x[0],y2:x[1],stroke:n,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||u}),vc(e.endCap,y,n),e.label&&/* @__PURE__ */wc(xc,{x:p,y:g,text:e.label,textAnchor:m,fill:e.labelColor??n,fontSize:a,fontFamily:s,fontWeight:l?"bold":void 0,background:c??e.labelBackground??"halo"})]})}import{jsx as Sc,jsxs as Mc}from"react/jsx-runtime";function $c(e,t,i,r){return"curly"===e?r?`M0,0 C${.6*i},0 ${.4*i},${t/2} ${i},${t/2} C${.4*i},${t/2} ${.6*i},${t} 0,${t}`:`M0,0 C0,${.6*i} ${t/2},${.4*i} ${t/2},${i} C${t/2},${.4*i} ${t},${.6*i} ${t},0`:r?`M0,0 L${i},0 L${i},${t} L0,${t}`:`M0,0 L0,${i} L${t},${i} L${t},0`}function _c(e,t,i,r){if(!e)/* */return Sc("g",{className:"annotation-note"});let{label:o,title:n,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!o&&!n)/* */return Sc("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(i)?"leftRight":"topBottom");let d="topBottom"===u,h="leftRight"===u,f=s;(!f||"dynamic"===f)&&(f=d?t>=0?"left":"right":i>=0?"top":"bottom");let p="start";d?"right"===f?p="end":"middle"===f&&(p="middle"):p=t>=0?"start":"end";let g=e.useHTML||e.html,m=g?void 0:ue(e),y=m?.lineHeight??16,x=m?.titleLines??(n?c?[n]:he(n,l,8):[]),b=m?.labelLines??(o?c?[o]:he(o,l,8):[]),v=x.length+b.length,w=h?"end"===p?-4:4:0,k=[],A=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";if(g){let e=l,t=Math.max(y,v*y+(n&&o?2:0)),i="end"===p?w-e:"middle"===p?w-e/2:w,r="end"===p?"right":"middle"===p?"center":"left";k.push(
63
+ /* @__PURE__ */Sc("foreignObject",{className:"annotation-note-html",x:i,y:-y,width:e,height:t+y,style:{overflow:"visible"},children:/* @__PURE__ */Mc("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:A,fontSize:"12px",lineHeight:`${y}px`,overflow:"visible",textAlign:r,whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[n&&/* @__PURE__ */Sc("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:n}),o&&/* @__PURE__ */Sc("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html"))}else for(let e of[!0,!1]){let t=e?x:b;if(0===t.length)continue;let i="annotation-note-"+(e?"title":"label");k.push(
64
+ /* @__PURE__ */Sc("text",{className:i,fill:A,textAnchor:p,fontWeight:e?m?.titleFontWeight??"bold":void 0,y:e?void 0:x.length*y,children:t.map((e,t)=>/* @__PURE__ */Sc("tspan",{x:w,dy:0===t?0:y,children:e},t))},i))}let S=null;if((n||o)&&(0!==t||0!==i)){let e=d?m?m.width:Math.min(l,120):(x.length+b.length+(b.length>0?1:0))*y,t=d?p:f,i="end"===t||"bottom"===t?-e:"middle"===t?-e/2:0;S=/* @__PURE__ */Sc("line",{className:"note-line",x1:d?i:0,x2:d?i+e:0,y1:d?0:i,y2:d?0:i+e,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}let M=Math.max(0,v-1)*y,$=b.length>0&&x.length>0?2:0,_=0;(d||h)&&(_=h&&"middle"===f?-(M+y+$)/2+y/2:i<0||h&&"bottom"===f?-(M+2):2+y);let P=0!==_?`translate(0,${_})`:void 0;/* */
65
+ return Mc("g",{className:"annotation-note",transform:`translate(${t},${i})`,...m?.textProps,children:[
66
+ /* @__PURE__ */Sc("g",{className:"annotation-note-content",transform:P,children:k}),S]})}function Pc(e,t,i,r,o){let n=null,a=i||"var(--semiotic-text-secondary, currentColor)";switch(e){case"callout-circle":{let e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&(n=/* @__PURE__ */Sc("circle",{r:e,fill:"none",stroke:a},"subject-circle"));break}case"callout-rect":{let e=t?.width||0,i=t?.height||0;(e>0||i>0)&&(n=/* @__PURE__ */Sc("rect",{width:e,height:i,fill:"none",stroke:a},"subject-rect"));break}case"callout-custom":n=t?.custom;break;case"xy-threshold":{let e=r||0,i=o||0,s=0,l=0,c=0,u=0;if(void 0!==t?.x)s=l=(t.x||0)-e,c=(t.y1||0)-i,u=(t.y2||0)-i;else if(void 0!==t?.y)c=u=(t.y||0)-i,s=(t.x1||0)-e,l=(t.x2||0)-e;else if(void 0!==t?.x1||void 0!==t?.x2)s=(t.x1||0)-e,l=(t.x2||0)-e;else{if(void 0===t?.y1&&void 0===t?.y2)break;c=(t.y1||0)-i,u=(t.y2||0)-i}n=/* @__PURE__ */Sc("line",{x1:s,y1:c,x2:l,y2:u,stroke:a,strokeDasharray:"5,5"},"threshold-line");break}case"bracket":{let e=t?.type||"curly",i=t?.width??t?.height;void 0!==i&&(n=/* @__PURE__ */Sc("path",{d:$c(e,i,t?.depth||30,void 0===t?.width),fill:"none",stroke:a},"bracket-path"));break}}/* */
67
+ return Sc("g",{className:"annotation-subject",children:n})}function Lc(e,t,i,r,o,n){let a,s,l=0,c=0;if("callout-circle"!==o&&"label"!==o||!n?.radius){if("callout-rect"===o&&n){let i=n.width||0,r=n.height||0;if(i>0||r>0){let o=i/2,n=r/2,a=e-o,s=t-n;if(0!==a||0!==s){let e=Math.abs(a),t=Math.abs(s),u=i/2,d=r/2,h=e*d>t*u?u/e:d/t;l=o+a*h,c=n+s*h}}}else if("bracket"===o&&n){let e=n.width,t=n.height,i=n.depth||30;void 0!==e?(l=e/2,c=i):void 0!==t&&(l=i,c=t/2)}}else{let i=(n.radius||0)+(n.radiusPadding||0);if(i>0&&(0!==e||0!==t)){let r=Math.atan2(t,e);l=Math.cos(r)*i,c=Math.sin(r)*i}}let u=e-l,d=t-c,h=Math.hypot(u,d);if(h>.5){let o=r||"var(--semiotic-text-secondary, currentColor)",n="curve"===i?.type,f=Math.atan2(d,u);if(n){let r=(l+e)/2,n=(c+t)/2,s=-d/h,p=u/h,g=(i?.curve??.25)*h,m=r+s*g,y=n+p*g;a=/* @__PURE__ */Sc("path",{className:"connector-curve",d:`M${l},${c}Q${m},${y} ${e},${t}`,fill:"none",stroke:o},"connector-line"),f=Math.atan2(y-c,m-l)}else a=/* @__PURE__ */Sc("line",{x1:l,y1:c,x2:e,y2:t,stroke:o},"connector-line");if("arrow"===i?.end){let e=.08888888888888889*Math.PI,t=l+10*Math.cos(f+e),i=c+10*Math.sin(f+e),r=l+10*Math.cos(f-e),n=c+10*Math.sin(f-e);s=/* @__PURE__ */Sc("path",{d:`M${l},${c}L${t},${i}L${r},${n}Z`,fill:o,stroke:"none"},"connector-arrow")}}/* */
68
+ return Mc("g",{className:"annotation-connector",children:[a,s]})}function Ic(e){let{x:t=0,y:i=0,dx:r,dy:o,nx:n,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:f,opacity:p,strokeDasharray:g,events:m={},"data-testid":y}=e,x=Array.isArray(t)?t[0]??0:t,b=Array.isArray(i)?i[0]??0:i,v=Array.isArray(f)?f:[],w=r||0,k=o||0;null!=n&&(w=n-x),null!=a&&(k=a-b);let A="string"==typeof u?u:"label";if("bracket"===A&&c&&0===w&&0===k)if(void 0!==c.width){w=c.width/2;let e=c.depth||30;k=e+(e>=0?5:-5)}else if(void 0!==c.height){let e=c.depth||30;w=e+(e>=0?5:-5),k=c.height/2}/* */
69
+ return Mc("g",{className:`annotation ${h||""}`.trim(),transform:`translate(${x},${b})`,"data-testid":y,...null!=p&&{opacity:p},...g&&{strokeDasharray:g},...m,children:[!v.includes("connector")&&Lc(w,k,l,d,A,c),!v.includes("subject")&&Pc(A,c,d,x,b),!v.includes("note")&&_c(s,w,k,d)]})}function Rc(e){let{noteData:t}=e,{screenCoordinates:i}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&i){let e=t.nx||i[0][0]+(t.dx??0),o=t.ny||i[0][1]+(t.dy??0),n=i.map((i,n)=>{let a=Object.assign({},t,{note:0===n?t.note:{label:""},x:i[0],y:i[1],nx:e,ny:o});/* */
70
+ return Sc(Ic,{"data-testid":"semiotic-annotation",...a,type:r},`multi-annotation-${n}`)});/* */
71
+ return Sc("g",{children:n})}let n=t.note||{title:"none",label:t.label},a=`${n.label}-${n.title}-${t.i}`;/* */
72
+ return Sc(Ic,{"data-testid":"semiotic-annotation",events:o,...t,type:r},a)}import{jsx as Tc}from"react/jsx-runtime";var Cc={secondary:0,primary:3};function Nc(e){return!0===e?._annotationDeferred}function Fc(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Dc(e){return"primary"===e?.emphasis||"secondary"===e?.emphasis?e.emphasis:null}function Ec(e){let t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function zc(e){return Math.max(.72,.95-.06*e)}function Oc(e){let t=e.map((e,t)=>({p:e,i:t,emphasis:Dc(e.annotation),confidence:Ec(e.annotation),readingOrder:null,rank:1})),i=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>Nc(e.annotation)),o=e.some(e=>null!=Fc(e.annotation)),n=e.some(e=>"layer"===Fc(e.annotation));if(!i&&!r&&!o)return e.map(e=>e.node);let a=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);a.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,a.length)});for(let e of t)e.emphasis&&(e.rank=Cc[e.emphasis]);let s=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{let{p:t,i:i,emphasis:r,readingOrder:o}=e,n=Nc(t.annotation),a=t.node;if("primary"===r||"secondary"===r||null!=o){let e=null==r&&null!=o;a=/* @__PURE__ */Tc("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":`annotation-emphasis annotation-emphasis--${r}`,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:zc(o),"data-annotation-reading-order":o}:{},children:t.node},`annotation-emphasis-${i}`)}let s=Fc(t.annotation);return s&&(a=/* @__PURE__ */Tc("g",{className:`annotation-cohesion--${s}`,children:a},`annotation-cohesion-${i}`)),n&&(a=/* @__PURE__ */Tc("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},`annotation-deferred-${i}`)),a});return r&&s.unshift(
73
+ /* @__PURE__ */Tc("style",{children:".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}"},"annotation-disclosure-style")),n&&s.unshift(
74
+ /* @__PURE__ */Tc("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),s}function jc(e,t,i,r){let o=[];return e.forEach((e,n)=>{let a;a=i?i(e,n,r)??t(e,n,r):t(e,n,r),a&&o.push({node:a,annotation:e})}),{nodes:Oc(o),renderedAnnotations:o.map(e=>e.annotation)}}function Wc(e,t,i,r){let o=Vs(e.fill??e.color,t,r),n="string"==typeof e.fill&&e.fill?e.fill:"string"==typeof e.color&&e.color?e.color:r;return Hs(e.gradient,t,i,n)??o}var Bc=/* @__PURE__ */new Set(["top-left","top-center","top-right","middle-left","center","middle-right","bottom-left","bottom-center","bottom-right"]);function Yc(e,t,i){let r=e.position,o="string"==typeof r&&Bc.has(r)?r:"bottom-left",n=o.endsWith("left")?"left":o.endsWith("right")?"right":"center",a=o.startsWith("top")?"top":o.startsWith("bottom")?"bottom":"middle",s="top"===a?0:"bottom"===a?i:i/2;return{x:("left"===n?0:"right"===n?t:t/2)+("number"==typeof e.dx&&Number.isFinite(e.dx)?e.dx:0),y:s+("number"==typeof e.dy&&Number.isFinite(e.dy)?e.dy:0),textAnchor:"start"===e.textAnchor||"middle"===e.textAnchor||"end"===e.textAnchor?e.textAnchor:"left"===n?"start":"right"===n?"end":"middle",dominantBaseline:"auto"===e.dominantBaseline||"middle"===e.dominantBaseline||"hanging"===e.dominantBaseline?e.dominantBaseline:"top"===a?"hanging":"bottom"===a?"auto":"middle"}}function Gc(e,t,i,r){return{...Yc(e,t,i),fill:e.fill??e.color??r.fill,fontSize:e.fontSize??r.fontSize,fontFamily:e.fontFamily??r.fontFamily,fontWeight:e.fontWeight,fontStyle:e.fontStyle,letterSpacing:e.letterSpacing,opacity:e.opacity,className:e.className,style:{pointerEvents:"none"}}}import{jsx as Xc}from"react/jsx-runtime";var Vc={fill:"var(--semiotic-text, #333)",fontSize:11,fontFamily:"inherit"};function qc({annotation:e,width:t,height:i,defaults:r=Vc}){let o=e.label??e.text;return null==o?null:/* @__PURE__ */Xc("text",{...Gc(e,t,i,r),children:o})}import{packEnclose as Hc}from"d3-hierarchy";import{area as Uc,curveBasis as Zc,curveCardinal as Qc,curveCatmullRom as Kc,curveLinear as Jc,curveMonotoneX as eu,curveMonotoneY as tu,curveStep as iu,curveStepAfter as ru,curveStepBefore as ou}from"d3-shape";import*as nu from"react";function au(e){let t=e.provenance,i=e.id??e.stableId??t?.stableId;return null==i||""===i?void 0:String(i)}function su(e){let t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}function lu(e,t={}){let i=au(e);return{"data-semiotic-annotation-widget":"",...i?{"data-semiotic-annotation-id":i}:{},onClickCapture(r){let o=su(r);t.onAnnotationActivate?.({annotation:e,annotationId:i,chartId:t.chartId,inputType:o}),i&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:i,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function cu(e,t){return uc(e)?hc(e)??t:e}function uu(e,t,i){let r=e.labelBackground,o=t.colors.background,n=o&&"transparent"!==o?o:t.colors.surface||o;return void 0===r?"none"===i?"none":{type:"halo",fill:n}:!1===r||"none"===r?"none":!0===r||"halo"===r?{type:"halo",fill:n}:"box"===r?{type:"box",fill:n}:{...r,fill:cu(r.fill,n)??n,...void 0!==r.stroke?{stroke:cu(r.stroke,t.colors.border)}:{}}}function du(e,t){let i=t.scales?.x??t.scales?.time,r=t.scales?.y??t.scales?.value;if(!i||!r)return[];let o=t.data||[],n=t.xAccessor||"x",a=t.yAccessor||"y",s="horizontal"===t.projection,l="ordinal"===t.frameType;l&&s&&([n,a]=[a,n]);let c=i,u=r,d=s?u:c,h=l?t.scales?.o?.domain().map(String)??[...new Set(o.filter(e=>null!=e[n]).map(e=>String(e[n])))].sort((e,t)=>d(e)-d(t)):[],f=new Map(h.map((e,t)=>[e,t])),p=_r(o.map(e=>[l?null==e[n]?void 0:f.get(String(e[n])):e[n],e[a]]));return p.length<2?[]:("loess"===e.method?Nr(p,e.bandwidth??.3):("polynomial"===e.method?Ir(p,e.order??2):Lr(p)).points).map(([e,t])=>{if(!l)return[c(e),u(t)];let i=d(h[e]);return s?[c(t),i]:[i,u(t)]}).filter(([e,t])=>Number.isFinite(e)&&Number.isFinite(t))}import{jsx as hu,jsxs as fu}from"react/jsx-runtime";var pu={linear:Jc,monotoneX:eu,monotoneY:tu,step:iu,stepAfter:ru,stepBefore:ou,basis:Zc,cardinal:Qc,catmullRom:Kc};function gu(e,t,i,r){let o=e.color||r?.colors.textSecondary||"#666",n=r?uu(e,r,"none"):e.labelBackground??"none";switch(e.type){case"enclose":{let r=(e.coordinates||[]).map(e=>({x:pe({...e,type:"point"},i),y:me({...e,type:"point"},i),r:1})).filter(e=>null!=e.x&&null!=e.y);if(r.length<2)return null;let a=Hc(r),s=e.padding||10;/* */
75
+ return fu("g",{children:[
76
+ /* @__PURE__ */hu("circle",{cx:a.x,cy:a.y,r:a.r+s,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:o,strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&/* @__PURE__ */hu(xc,{x:a.x,y:a.y-a.r-s-4,textAnchor:"middle",fill:o,fontSize:12,text:e.label,background:n})]},`ann-${t}`)}case"rect-enclose":{let r=(e.coordinates||[]).map(e=>({x:pe({...e,type:"point"},i),y:me({...e,type:"point"},i)})).filter(e=>null!=e.x&&null!=e.y);if(r.length<2)return null;let a=e.padding||10,[s,l]=Ce(r.map(e=>e.x)),[c,u]=Ce(r.map(e=>e.y)),d=s-a,h=l+a,f=c-a;/* */
77
+ return fu("g",{children:[
78
+ /* @__PURE__ */hu("rect",{x:d,y:f,width:h-d,height:u+a-f,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:o,strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&/* @__PURE__ */hu(xc,{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:o,fontSize:12,text:e.label,background:n})]},`ann-${t}`)}case"highlight":{let r=i.data||[],o="function"==typeof e.filter?r.filter(e.filter):e.field&&null!=e.value?r.filter(t=>t[e.field]===e.value):[],n={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};/* */
79
+ return hu("g",{children:o.map((t,r)=>{let o=pe(t,i),a=me(t,i);if(null==o||null==a)return null;let s="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||n;/* */
80
+ return hu("circle",{cx:o,cy:a,r:s,...l},`hl-${r}`)})},`ann-${t}`)}case"bracket":{let r=pe(e,i),o=me(e,i);/* */
81
+ return hu(Rc,{noteData:{x:r??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:le(e),type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},`ann-${t}`)}case"trend":{let r=du(e,i);if(r.length<2)return null;let o=r.map(([e,t])=>`${e},${t}`).join(" "),n=e.color||"#6366f1",[a,s]=r[r.length-1];/* */
82
+ return fu("g",{children:[
83
+ /* @__PURE__ */hu("polyline",{points:o,fill:"none",stroke:n,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&/* @__PURE__ */hu("text",{x:a+4,y:s-4,fill:n,fontSize:11,children:e.label})]},`ann-${t}`)}case"envelope":{let r=i.data||[];if(r.length<2)return null;let o=i.xAccessor||"x",n=i.scales?.x??i.scales?.time,a=i.scales?.y??i.scales?.value;if(!n||!a)return null;let s=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=r.filter(e=>null!=e[s]&&null!=e[l]&&(!c||c(e))).sort((e,t)=>e[o]-t[o]);if(u.length<2)return null;let d=pu[i.curve||"linear"]||Jc,h=Uc().x(e=>n(e[o])).y0(e=>a(e[l])).y1(e=>a(e[s])).curve(d)(u);if(!h)return null;let f=e.fill||"#6366f1",p=u[u.length-1];/* */
84
+ return fu("g",{children:[
85
+ /* @__PURE__ */hu("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&/* @__PURE__ */hu("text",{x:n(p[o])+4,y:a(p[s])-4,fill:f,fontSize:11,children:e.label})]},`ann-${t}`)}case"anomaly-band":{let r=(i.data||[]).filter(t=>!e.filter||e.filter(t));if(r.length<2)return null;let o=i.yAccessor||"y",n=i.scales?.x??i.scales?.time,a=i.scales?.y??i.scales?.value;if(!n||!a)return null;let s=r.map(e=>$r(e[o])).filter(e=>null!==e);if(s.length<2)return null;let l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+(t-l)**2,0)/s.length,u=Math.sqrt(c),d=e.threshold??2,h=l-d*u,f=a(l+d*u),p=a(h),g=e.fill||"#6366f1",m=e.anomalyColor||"#ef4444",y=e.anomalyRadius??6,x=r.filter(e=>{let t=$r(e[o]);return null!=t&&Math.abs(t-l)>d*u});/* */
86
+ return fu("g",{children:[!1!==e.showBand&&/* @__PURE__ */hu("rect",{x:0,y:Math.min(f,p),width:i.width||0,height:Math.abs(p-f),fill:g,fillOpacity:e.fillOpacity??.1}),x.map((e,t)=>{let r=pe(e,i),o=me(e,i);return null==r||null==o?null:/* @__PURE__ */hu("circle",{cx:r,cy:o,r:y,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},`anomaly-${t}`)}),e.label&&/* @__PURE__ */hu("text",{x:(i.width||0)-4,y:Math.min(f,p)-4,textAnchor:"end",fill:g,fontSize:11,children:e.label})]},`ann-${t}`)}case"forecast":{let r=i.data||[],o=i.xAccessor||"x",n=i.yAccessor||"y",a=i.scales?.x??i.scales?.time,s=i.scales?.y??i.scales?.value;if(!a||!s)return null;let l=_r(r.map(e=>[e[o],e[n]])),c=Dr(l,e);if(!c)return null;let{predict:u}=c,d=l[l.length-1][0],h=c.forecast(e.steps??5);if(!h.length)return null;let f=Uc().x(e=>a(e.x)).y0(e=>s(e.lower)).y1(e=>s(e.upper))(h);if(!f)return null;let p=h.map(e=>`${a(e.x)},${s(e.y)}`).join(" "),g=e.fill||"#6366f1",m=e.strokeColor||"#6366f1",y=h[h.length-1];/* */
87
+ return fu("g",{children:[
88
+ /* @__PURE__ */hu("path",{d:f,fill:g,fillOpacity:e.fillOpacity??.15,stroke:"none"}),
89
+ /* @__PURE__ */hu("polyline",{points:`${a(d)},${s(u(d))} ${p}`,fill:"none",stroke:m,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&y&&/* @__PURE__ */hu("text",{x:a(y.x)+4,y:s(y.y)-4,fill:m,fontSize:11,children:e.label})]},`ann-${t}`)}case"widget":{let r,o;if(null!=e.px&&null!=e.py)r=e.px,o=e.py;else{let n=xe(e,t,i);if(!n)return null;r=n.x,o=n.y}if(!ve(r,o,i))return null;let n=e.width??32,a=e.height??32,s=e.content??/* @__PURE__ */hu("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});/* */
90
+ return hu("foreignObject",{x:r+(e.dx??0)-n/2,y:o+(e.dy??0)-a/2,width:n,height:a,style:{overflow:"visible",pointerEvents:"auto"},children:/* @__PURE__ */hu("div",{...lu(e),style:{width:n,height:a,display:"flex",alignItems:"center",justifyContent:"center"},children:s})},`ann-${t}`)}default:return null}}import{jsx as mu,jsxs as yu}from"react/jsx-runtime";function xu(e,t){return e.color||t.colors.annotation||t.colors.text}function bu(e,t,i,r){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){let i=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(i)return{x:i[0],y:i[1]}}return{x:vu(e,t,i),y:wu(e,t,r)}}function vu(e,t,i){return null!=e.x&&t.x?t.x(e.x):i&&null!=e[i]&&t.x?t.x(e[i]):"number"==typeof e.x?e.x:null}function wu(e,t,i){return null!=e.y&&t.y?t.y(e.y):i&&null!=e[i]&&t.y?t.y(e[i]):"number"==typeof e.y?e.y:null}function ku(e){let{annotations:t}=e;if(!t||0===t.length)return e.onRender?.({inputCount:0,eligibleCount:0,renderedCount:0,unrenderedCount:0,unrenderedTypes:[]}),null;let i=g(t).filter(e=>!e._directLabel),r=e.scales.geoProjection,o=r?i.map(e=>{if(!Array.isArray(e.coordinates)||e.coordinates.length<2)return e;let t=r([Number(e.coordinates[0]),Number(e.coordinates[1])]);return t?{...e,x:t[0],y:t[1]}:e}):i,n=!!r&&!e.scales.x&&!e.scales.y,a=e=>Number(e),s=e.scales.x??(n?a:void 0),l=e.scales.y??(n?a:void 0),c=e.frameType??(e.projection?"ordinal":r||e.scales.x||e.scales.y?"xy":"network"),u="horizontal"===e.projection,d=e.projection?u?"horizontal":"vertical":void 0,h="vertical"===e.projection||u,f=e.scales.o,p=f?e=>(f(e)??0)+(f.bandwidth?.()??0)/2:void 0,m={scales:{x:(h?u?e.scales.r:p:void 0)??s,y:(h?u?p:e.scales.r:void 0)??l,time:h?e.scales.r:s,value:h?e.scales.r:l,o:f,...r?{geoProjection:r}:{}},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,data:e.annotationData,pointNodes:e.pointNodes,frameType:c,...d?{projection:d}:{}},y=cc(t,{...e.layout,scales:e.scales,margin:e.margin,fontFamily:e.theme.typography.fontFamily,measure:e.labelMeasurer,...e.svgAnnotationRules?{renderLabel:(t,i,r)=>e.svgAnnotationRules(t,i,m)??r}:{}}),x=e.autoPlaceAnnotations?Se({annotations:o,context:m,..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):o,b=jc(x,(t,i,r)=>Au(t,i,e,r)??gu(t,i,r,e.theme),e.svgAnnotationRules,m),v=y.node?[...b.nodes,y.node]:b.nodes,w=/* @__PURE__ */new Map;for(let e of b.renderedAnnotations){let t="string"==typeof e.type?e.type:"unknown";w.set(t,(w.get(t)??0)+1)}y.evidence&&w.set("text",(w.get("text")??0)+y.evidence.rendered);let k=[];for(let e of t){let t="string"==typeof e.type?e.type:"unknown",i=w.get(t)??0;i>0?w.set(t,i-1):k.push(t)}e.onRender?.({inputCount:t.length,eligibleCount:x.length,renderedCount:b.renderedAnnotations.length+(y.evidence?.rendered??0),...y.evidence?{layout:y.evidence}:{},unrenderedCount:k.length,unrenderedTypes:k});let A=e.idPrefix?`${e.idPrefix}-`:"";return v.length>0?/* @__PURE__ */mu("g",{id:`${A}annotations`,className:"semiotic-annotations",children:v}):null}function Au(e,t,i,r){let{scales:o,layout:n,theme:a,xAccessor:s,yAccessor:l}=i;switch(e.type){case"frame-text":/* */
91
+ return mu(qc,{annotation:e,width:n.width,height:n.height,defaults:{fill:a.colors.text,fontSize:11,fontFamily:a.typography.fontFamily}},`ann-frame-text-${t}`);case"y-threshold":{let r=e.value??e.y;if(null==r)return null;let s=xu(e,a),l=e.label,c=e.strokeDasharray||"6,4",u=e.strokeWidth??1.5;if("horizontal"===i.projection&&o.r){let i=o.r(r);return null==i?null:/* @__PURE__ */yu("g",{opacity:e.opacity,children:[
92
+ /* @__PURE__ */mu("line",{x1:i,y1:0,x2:i,y2:n.height,stroke:s,strokeWidth:u,strokeDasharray:c}),vc(e.endCap,[i,0],s),l&&/* @__PURE__ */mu(xc,{x:i+4,y:16,textAnchor:"start",fontSize:a.typography.tickSize,fill:e.labelColor??s,fontFamily:a.typography.fontFamily,text:l,background:uu(e,a,"halo")})]},`ann-ythresh-${t}`)}let d=o.y?o.y(r):o.r?o.r(r):null;return null==d?null:/* @__PURE__ */mu(Ac,{ann:e,position:d,vertical:!1,width:n.width,height:n.height,color:s,fontSize:a.typography.tickSize,fontFamily:a.typography.fontFamily,background:uu(e,a,"halo"),dash:"6,4",labelGap:6},`ann-ythresh-${t}`)}case"x-threshold":{let r=e.value??e.x;if(null==r)return null;let s="horizontal"===i.projection&&o.r?o.r(r):o.x?o.x(r):null;if(null==s)return null;let l=xu(e,a);/* */
93
+ return mu(Ac,{ann:e,position:s,vertical:!0,width:n.width,height:n.height,color:l,fontSize:a.typography.tickSize,fontFamily:a.typography.fontFamily,background:uu(e,a,"halo"),dash:"6,4"},`ann-xthresh-${t}`)}case"band":{let r=o.y?.domain?.(),s=e.y0??r?.[0],l=e.y1??r?.[1],c=null!=s&&o.y?o.y(s):null,u=null!=l&&o.y?o.y(l):null;if(null==c||null==u)return null;let d=Math.min(c,u),h=Math.abs(u-c),f=Wc(e,`ssr-band-${t}`,"vertical",a.colors.primary||xu(e,a)),p=e.fillOpacity??.1,g=!0===i.underLayerBands&&"under"===e.layer;/* */
94
+ return yu("g",{opacity:e.opacity,children:[!g&&f.def&&/* @__PURE__ */mu("defs",{children:f.def}),!g&&/* @__PURE__ */mu("rect",{x:0,y:d,width:n.width,height:h,fill:f.fill,fillOpacity:p}),e.label&&/* @__PURE__ */mu(xc,{x:n.width-4,y:Math.max(d,0)+16,textAnchor:"end",fontSize:a.typography.tickSize,fill:e.labelColor??(e.color||a.colors.primary||xu(e,a)),fontFamily:a.typography.fontFamily,fontWeight:"bold",text:e.label,background:uu(e,a,"halo")})]},`ann-band-${t}`)}case"x-band":{let r=o.x?.domain?.(),s=e.x0??r?.[0],l=e.x1??r?.[1],c=null!=s&&o.x?o.x(s):null,u=null!=l&&o.x?o.x(l):null;if(null==c||null==u)return null;let d=Math.min(c,u),h=Math.abs(u-c),f=Wc(e,`ssr-xband-${t}`,"horizontal",a.colors.primary||xu(e,a)),p=e.fillOpacity??.1,g=!0===i.underLayerBands&&"under"===e.layer;/* */
95
+ return yu("g",{opacity:e.opacity,children:[!g&&f.def&&/* @__PURE__ */mu("defs",{children:f.def}),!g&&/* @__PURE__ */mu("rect",{x:d,y:0,width:h,height:n.height,fill:f.fill,fillOpacity:p}),e.label&&/* @__PURE__ */mu(xc,{x:d+4,y:16,textAnchor:"start",fontSize:a.typography.tickSize,fill:e.labelColor??(e.color||a.colors.primary||xu(e,a)),fontFamily:a.typography.fontFamily,fontWeight:"bold",text:e.label,background:uu(e,a,"halo")})]},`ann-xband-${t}`)}case"category-highlight":{if(null==e.category||!o.o)return null;let r=o.o(String(e.category));if(null==r)return null;let s=o.o.bandwidth?o.o.bandwidth():40,l=xu(e,a),c=e.opacity??.1,u=e.label;return"horizontal"===i.projection?/* @__PURE__ */yu("g",{children:[
96
+ /* @__PURE__ */mu("rect",{x:0,y:r,width:n.width,height:s,fill:l,opacity:c}),u&&/* @__PURE__ */mu(xc,{x:12,y:r+s/2,dominantBaseline:"middle",fill:l,fontSize:a.typography.tickSize,fontWeight:"bold",fontFamily:a.typography.fontFamily,text:u,background:uu(e,a,"none")})]},`ann-cathighlight-${t}`):/* @__PURE__ */yu("g",{children:[
97
+ /* @__PURE__ */mu("rect",{x:r,y:0,width:s,height:n.height,fill:l,opacity:c}),u&&/* @__PURE__ */mu(xc,{x:r+s/2,y:16,textAnchor:"middle",fill:l,fontSize:a.typography.tickSize,fontWeight:"bold",fontFamily:a.typography.fontFamily,text:u,background:uu(e,a,"none")})]},`ann-cathighlight-${t}`)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{let i=bu(e,o,s,l),n=null==i.x||null==i.y?xe(e,t,r):null,c=i.x??n?.x??null,u=i.y??n?.y??null;if(null==c||null==u)return null;let d="text"===e.type,h=e.dx??(d?0:30),f=e.dy??(d?0:-30),p=e.color||a.colors.text;if(!d){let i="callout"===e.type?"callout-circle":e.type,r="callout-circle"===i?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===i?{width:e.width,height:e.height}:void 0;/* */
98
+ return mu(Rc,{noteData:{x:c,y:u,dx:h,dy:f,note:le(e),type:i,...r?{subject:r}:{},connector:e.connector||{end:"arrow"},color:p,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},`ann-label-${t}`)}/* */
99
+ return mu("g",{children:/* @__PURE__ */mu("text",{x:c+h,y:u+f,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||a.typography.labelSize,fill:p,fontFamily:a.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},`ann-label-${t}`)}default:return null}}import{jsx as Su}from"react/jsx-runtime";function Mu(e,t,i,r="right",o,n){if(null==e||!1===e)return null;let{x:a,y:s}=mt(e,{totalWidth:t[0],totalHeight:t[1],margin:i,position:r,legendLayout:o,axisChrome:n});/* */
100
+ return Su("g",{transform:`translate(${a}, ${s})`,children:e})}function $u(e){let t=String(e).replace(/[^a-zA-Z0-9_-]/g,"_"),i=/^[A-Za-z_]/.test(t)?t:`c${t}`,r=`${i}-semiotic-title`,o=`${i}-semiotic-desc`;return{titleId:r,descId:o,labelledBy:`${r} ${o}`}}function _u(e,t){if(0===t.categories.length)return;let i=t.position||"right";gt(e,{legend:Gl(t.categories,t.colorScheme,t.theme),position:i,size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}function Pu(e,t){let i=t.position||"right";gt(e,{legend:t.legend,position:i,size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}import*as Lu from"react";function Iu(e,t,i){if("edges"===e){if(t)return"start";if(i)return"end"}return"middle"}function Ru(e,t,i){if("edges"===e){if(t)return"hanging";if(i)return"auto"}return"middle"}function Tu(e){if(0===e.length)return{min:null,max:null};let t=1/0,i=-1/0;for(let r of e)r.pixel<t&&(t=r.pixel),r.pixel>i&&(i=r.pixel);return{min:t,max:i}}function Cu(e){if(e)return"object"==typeof e?e.strokeDasharray:"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Nu(e,t){return e&&"string"!=typeof e?{stroke:e.stroke??t.stroke,strokeWidth:e.strokeWidth??t.strokeWidth,...null!=e.strokeOpacity&&{strokeOpacity:e.strokeOpacity},...e.strokeDasharray&&{strokeDasharray:e.strokeDasharray}}:{...t,..."string"==typeof e&&{strokeDasharray:Cu(e)}}}function Fu(e,t,i){if("left"===e||"right"===e){let r="left"===e?i:0,o="left"===e?-1:1,n=Math.ceil(t/8),a=`M0,${r}`;for(let e=0;e<n;e++){let i=8*e+4,n=8*(e+1);a+=`L${Math.min(i,t)},${r+4*o}`,a+=`L${Math.min(n,t)},${r}`}return a}let r="bottom"===e?0:t,o="bottom"===e?1:-1,n=Math.ceil(i/8),a=`M${r},0`;for(let e=0;e<n;e++){let t=8*e+4,n=8*(e+1);a+=`L${r+4*o},${Math.min(t,i)}`,a+=`L${r},${Math.min(n,i)}`}return a}function Du(e,t){let i=e.domain(),r=i[0],o=i[i.length-1],n=r instanceof Date,a=r instanceof Date?r.getTime():r,s=o instanceof Date?o.getTime():o;if(t<2||a===s)return n?[new Date(a),new Date(s)]:[a,s];let l=(s-a)/(t-1),c=new Array(t);for(let e=0;e<t;e++){let i=e===t-1?s:a+e*l;c[e]=n?new Date(i):i}return c}function Eu(e,t,i){return"exact"===i?Du(e,t):e.ticks(t)}import{jsx as zu}from"react/jsx-runtime";function Ou(e){return"string"==typeof e||"number"==typeof e}function ju(e){let{label:t,x:i,y:r,textAlign:o,fontSize:n,fontFamily:a,color:s}=e;/* */
101
+ return zu("foreignObject",{x:i,y:r,width:60,height:24,style:{overflow:"visible"},children:/* @__PURE__ */zu("div",{style:{color:s,fontFamily:a,fontSize:n,textAlign:o,userSelect:"none"},children:t})})}function Wu(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Bu(e,t){let i=Wu(e);if(!i)return!1;let r=Wu(t);return!r||i.getFullYear()!==r.getFullYear()||i.getMonth()!==r.getMonth()}function Yu(e,t,i,r){return!!e&&("function"==typeof e?e(t.value,i):Bu(t.value,i>0?r[i-1].value:void 0))}function Gu(e,t){return e?.ticks??e?.tickCount??t}function Xu(e,t){return!("string"!=typeof e&&"number"!=typeof e||"string"!=typeof t&&"number"!=typeof t||String(e)!==String(t))}function Vu(e,t){if(e.length<=2)return e;let i=[e[0]];for(let r=1;r<e.length-1;r++)Math.abs(e[r].pixel-i[i.length-1].pixel)>=t&&i.push(e[r]);let r=e[e.length-1];return Math.abs(r.pixel-i[i.length-1].pixel)>=t?i.push(r):i[i.length-1]=r,i}function qu(e){return"string"==typeof e||"number"==typeof e?6.5*String(e).length:60}function Hu(e){for(let t=1;t<e.length;t++){let i=e[t-1],r=e[t];if(Math.abs(r.pixel-i.pixel)<(qu(i.label)+qu(r.label))/2+8)return!0}return!1}function Uu(e){let{scale:t,axis:i,size:r,horizontal:o=!1,axisExtent:n}=e,a=i?.extent??n,s=t.domain(),l=Gu(i,5),c=Math.max(2,Math.floor(r/(o?70:30))),u="exact"===a?Math.max(2,l):Math.min(l,c),d=i?.tickValues??Eu(t,u,a),h=d.map(e=>e.valueOf()),f=i?.tickFormat||e.format||(s[0]instanceof Date||d[0]instanceof Date?Ao([s[0].valueOf(),s[s.length-1].valueOf()]):Ue(h)),p=(e,t)=>o?f(e,t,h):f(e),g=d.map((e,i)=>({value:e,pixel:t(e),label:p(e,i)})),m=22;if(o){let e=g.reduce((e,t)=>Math.max(e,qu(t.label)),0);m=i?.autoRotate?Math.max(20,Math.min(e+8,55)):Math.max(55,e+8)}let y=o&&(i?.tickFormat||e.format)?e=>{let t=e.map(e=>e.value.valueOf());return e.map((e,i)=>({...e,label:f(e.value,i,t)}))}:void 0,x=Vu(g,m);if(y&&(x=y(x)),x.length>1&&(x=x.filter((e,t)=>0===t||!Xu(e.label,x[t-1].label))),i?.includeMax&&x.length>0&&"exact"!==a&&!i.tickValues){let e=s[s.length-1];if(null!=e){let i=t(e),r=Math.abs(i-x[x.length-1].pixel);if(r>1){let t=p(e,x.length);r<m&&x.length>1&&(x=x.slice(0,-1)),x=[...x,{value:e,pixel:i,label:t}]}}}return y?y(x):x}import{jsx as Zu,jsxs as Qu}from"react/jsx-runtime";function Ku(e){let t=e._idPrefix||e.chartId;if(t){let e=String(t).replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:`c${e}`}let i=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`,r=0;for(let e=0;e<i.length;e++)r=31*r+i.charCodeAt(e)|0;return`c${(r>>>0).toString(36)}`}function Ju(e,t,i){return Ze(e.showLegend&&!e.__legendIncludesAutomatic?Gl(t,e.colorScheme,i):void 0,e.legend)}var ed={right:110,left:110,top:50,bottom:80};function td(e,t){if(e.__autoLegendMargin)return ed[t]}function id(e,t){let i={theme:t.theme,position:t.position||"right",totalWidth:t.size[0],totalHeight:t.size[1],margin:t.margin,hasTitle:t.hasTitle,legendLayout:t.legendLayout,idPrefix:t.idPrefix,reservedWidth:t.reservedWidth,axisChrome:t.axisChrome,legendDistance:Qe(e)||Ke(e)?e.legendDistance:void 0};return Qe(e)?ec({...i,legendGroups:e.legendGroups}):Ke(e)?tc({...i,gradient:e.gradient}):null}function rd(e,t){let{props:i,categories:r,theme:o,size:n,hasTitle:a}=t,s=i.legendPosition||"right",l={...e},c={theme:o,position:s,size:n,hasTitle:a,legendLayout:i.legendLayout,axisChrome:i.axisChrome,minimumMargin:td(i,s)};if(void 0!==i.legend&&null!==i.legend){let t=Ju(i,r,o);null!=t&&!1!==t&&Pu(e,{...c,legend:t})}else i.showLegend&&r.length>0&&_u(e,{...c,categories:r,colorScheme:i.colorScheme});return it(e,l,n,s),s}function od(e){let{props:t,categories:i,theme:r,size:o,margin:n,hasTitle:a}=e,s=t.legendPosition||"right",l={theme:r,position:s,size:o,margin:n,hasTitle:a,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix};if(void 0!==t.legend&&null!==t.legend){let e=Ju(t,i,r);return Lu.isValidElement(e)?Mu(e,o,n,s,t.legendLayout,t.axisChrome):id(e,l)||(Qe(e)||Ke(e)?null:Mu(e??null,o,n,s,t.legendLayout,t.axisChrome))}return t.showLegend&&0!==i.length?Jl({categories:i,colorScheme:t.colorScheme,theme:r,position:s,totalWidth:o[0],totalHeight:o[1],margin:n,hasTitle:a,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix}):null}function nd(e,t,i,r,o,n){let a=e.scales;if(!a||"radial"===a.projection)return null;let{grid:s}=br(i),l=r?`${r}-`:"",c="vertical"===a.projection,u=n??Eu(a.r,5,o);/* */
102
+ return Zu("g",c?{id:`${l}grid`,className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{let r=a.r(e);/* */
103
+ return Zu("line",{x1:0,y1:r,x2:t.width,y2:r,stroke:s,strokeWidth:.5},`gr-${i}`)})}:{id:`${l}grid`,className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{let r=a.r(e);/* */
104
+ return Zu("line",{x1:r,y1:0,x2:r,y2:t.height,stroke:s,strokeWidth:.5},`gr-${i}`)})})}function ad(e,t){let i=br(t.theme),r=t.background??i.background,o=t.idPrefix?`${t.idPrefix}-`:"",n="string"==typeof t.title?t.title:void 0,a=t.idPrefix?$u(t.idPrefix):{titleId:"semiotic-title",descId:"semiotic-desc"},s=n?a.titleId:void 0,l=t.description?a.descId:void 0,c=[s,l].filter(Boolean).join(" ")||void 0;/* */
105
+ return Qu("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":c,style:{fontFamily:i.fontFamily},children:[n&&/* @__PURE__ */Zu("title",{id:s,children:n}),t.description&&/* @__PURE__ */Zu("desc",{id:l,children:t.description}),t.defs&&/* @__PURE__ */Zu("defs",{children:t.defs}),r&&"transparent"!==r&&/* @__PURE__ */Zu("rect",{x:0,y:0,width:t.width,height:t.height,fill:r}),
106
+ /* @__PURE__ */Zu("g",{id:`${o}data-area`,transform:t.innerTransform,children:e}),n&&/* @__PURE__ */Zu("text",{id:`${o}chart-title`,x:t.width/2,y:22,textAnchor:"middle",fontSize:i.titleFontSize,fontWeight:i.titleFontWeight,fill:i.text,fontFamily:i.titleFontFamily,children:n}),t.legend&&/* @__PURE__ */Zu("g",{id:`${o}legend`,children:t.legend}),t.outerElements]})}function sd(e,t,i,r,o,n,a,s=!1){let l=br(r),c=i.legendPosition??"right",u=at(i.legendLayout,a?.leftAxis),d=at(i.legendLayout,a?.rightAxis),h=s&&"left"===c&&u>0?u:n?.left??i.margin?.left??40,f=s&&"right"===c&&d>0?d:n?.right??i.margin?.right??40,{xAxis:p,yAxis:g,xOrient:m,yOrient:y}=He(i.axes),x="top"===m?0:t.height,b="right"===y?t.width:0,v="top"===m?-1:1,w="right"===y?1:-1,k=Uu({scale:e.x,axis:p,size:t.width,horizontal:!0,format:i.xFormat||i.tickFormatTime,axisExtent:i.axisExtent}),A=Uu({scale:e.y,axis:g,size:t.height,format:i.yFormat||i.tickFormatValue,axisExtent:i.axisExtent}),S=!(!p?.autoRotate||!Hu(k)),M=Tu(k),$=Tu(A),_=p?.label??i.xLabel,P=g?.label??("right"===y?i.yLabelRight??i.yLabel:i.yLabel),L=Nu(p?.axisStyle,{stroke:l.border,strokeWidth:1}),I=Nu(g?.axisStyle,{stroke:l.border,strokeWidth:1}),R="right"===y?t.width+f-15:15-h;/* */
107
+ return Qu("g",{id:(o?`${o}-`:"")+"axes",className:"stream-axes",children:[!1!==p?.visible&&/* @__PURE__ */Qu("g",{className:`semiotic-axis semiotic-axis-${m}`,"data-orient":m,children:[!1!==p?.baseline&&!p?.jaggedBase&&/* @__PURE__ */Zu("line",{x1:0,y1:x,x2:t.width,y2:x,...L}),p?.jaggedBase&&/* @__PURE__ */Zu("path",{d:Fu(m,t.width,t.height),fill:"none",...L}),k.map((e,t)=>{let i=Yu(p?.landmarkTicks,e,t,k);/* */
108
+ return Qu("g",{transform:`translate(${e.pixel},${x})`,children:[
109
+ /* @__PURE__ */Zu("line",{y2:5*v,...L}),Ou(e.label)?/* @__PURE__ */Zu("text",{y:v*(S?12:18),textAnchor:S?"end":Iu(p?.tickAnchor,e.pixel===M.min,e.pixel===M.max),fontWeight:i?600:400,fontSize:i?l.tickSize+1:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily,transform:S?"top"===m?"rotate(45)":"rotate(-45)":void 0,children:e.label}):ju({label:e.label,x:-30,y:"top"===m?-30:6,textAlign:"center",fontSize:l.tickSize,fontFamily:l.fontFamily,color:l.textSecondary})]},`xtick-${t}`)}),_&&/* @__PURE__ */Zu("text",{x:t.width/2,y:"top"===m?-(S?58:40):t.height+(S?58:40),textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,children:_})]}),!1!==g?.visible&&/* @__PURE__ */Qu("g",{className:`semiotic-axis semiotic-axis-${y}`,"data-orient":y,children:[!1!==g?.baseline&&!g?.jaggedBase&&/* @__PURE__ */Zu("line",{x1:b,y1:0,x2:b,y2:t.height,...I}),g?.jaggedBase&&/* @__PURE__ */Zu("path",{d:Fu(y,t.width,t.height),fill:"none",...I}),A.map((e,t)=>{let i=Yu(g?.landmarkTicks,e,t,A);/* */
110
+ return Qu("g",{transform:`translate(${b},${e.pixel})`,children:[
111
+ /* @__PURE__ */Zu("line",{x2:5*w,...I}),Ou(e.label)?/* @__PURE__ */Zu("text",{x:8*w,textAnchor:"right"===y?"start":"end",dominantBaseline:Ru(g?.tickAnchor,e.pixel===$.min,e.pixel===$.max),fontWeight:i?600:400,fontSize:i?l.tickSize+1:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:e.label}):ju({label:e.label,x:"right"===y?8:-68,y:-12,textAlign:"right"===y?"left":"right",fontSize:l.tickSize,fontFamily:l.fontFamily,color:l.textSecondary})]},`ytick-${t}`)}),P&&/* @__PURE__ */Zu("text",{x:R,y:t.height/2,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,transform:`rotate(${"right"===y?90:-90}, ${R}, ${t.height/2})`,children:P})]})]})}import{jsx as ld,jsxs as cd}from"react/jsx-runtime";function ud(e,t,i,r,o,n,a){let{grid:s}=br(i),l=r?`${r}-`:"",c=n?.find(e=>"bottom"===e.orient),u=n?.find(e=>"top"===e.orient),d=n?.find(e=>"left"===e.orient),h=n?.find(e=>"right"===e.orient),f=c??u,p=d??h,g=Uu({scale:e.x,axis:f,size:t.width,horizontal:!0,format:a?.xFormat||a?.tickFormatTime,axisExtent:o}),m=Uu({scale:e.y,axis:p,size:t.height,format:a?.yFormat||a?.tickFormatValue,axisExtent:o}),y=!1!==f?.grid,x=!1!==p?.grid,b=Cu(f?.gridStyle),v=Cu(p?.gridStyle),w=Nu(f?.gridStyle,{stroke:s,strokeWidth:.5}),k=Nu(p?.gridStyle,{stroke:s,strokeWidth:.5});/* */
112
+ return cd("g",{id:`${l}grid`,className:"semiotic-grid",opacity:.8,children:[y&&g.map((e,i)=>/* @__PURE__ */ld("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:t.height,...w,strokeDasharray:b??w.strokeDasharray},`gx-${i}`)),x&&m.map((e,i)=>/* @__PURE__ */ld("line",{x1:0,y1:e.pixel,x2:t.width,y2:e.pixel,...k,strokeDasharray:v??k.strokeDasharray},`gy-${i}`))]})}import*as dd from"react";import{jsx as hd,jsxs as fd}from"react/jsx-runtime";function pd(e){return"under"===e.layer&&("band"===e.type||"x-band"===e.type)}function gd(e,t,i,r){let o="band"===e.type,n=o?t.y:t.x;if("function"!=typeof n)return null;let a=n.domain?.(),s=n((o?e.y0:e.x0)??a?.[0]),l=n((o?e.y1:e.x1)??a?.[1]);if(!Number.isFinite(s)||!Number.isFinite(l))return null;let c=o?r:i,u=Math.min(c,Math.max(0,Math.min(s,l))),d=Math.max(0,Math.min(c,Math.max(s,l))-u);return o?{x:0,y:u,width:i,height:d}:{x:u,y:0,width:d,height:r}}function md(e){return"band"===e.type?"vertical":"horizontal"}function yd(e,t="under-band",i="var(--semiotic-primary, #6366f1)"){return(r,o,n)=>e.map((e,r)=>{let a=gd(e,o,n.width,n.height);if(!a)return null;let s=Wc(e,`${t}-${r}`,md(e),i);/* */
113
+ return fd("g",{opacity:e.opacity,children:[s.def&&/* @__PURE__ */hd("defs",{children:s.def}),
114
+ /* @__PURE__ */hd("rect",{...a,fill:s.fill,fillOpacity:e.fillOpacity??.1})]},`${t}-${r}`)})}function xd(e,t){if(!t||0===e.length||!e.some(e=>null!=e&&"object"==typeof e&&Array.isArray(e[t])))return e;let i=[];for(let r of e){if(null==r||"object"!=typeof r)continue;let e=r[t];if(!Array.isArray(e))continue;let o=r.label??r.id??r.key;for(let t of e)null==t||"object"!=typeof t||i.push(null==o?t:{...t,_lineGroup:o})}return i}function bd(e,t,i,r){return"function"==typeof e?e({size:t,margin:i,scales:r}):e}var vd={top:50,right:40,bottom:60,left:70},wd={top:20,right:80,bottom:20,left:80},kd={top:40,right:40,bottom:40,left:40},Ad=/* @__PURE__ */new Set(["chord","force","circlepack","orbit"]);function Sd(e){return Ad.has(e)?kd:wd}import{jsx as Md,jsxs as $d}from"react/jsx-runtime";function _d(e){let{scales:t,layout:i,props:r,theme:o,leftAxis:n,rightAxis:a,margin:s,axisChrome:l,hasRenderedLegend:c}=e;if(!n||!a||!1===a.visible)return null;let u=br(o),d=Uu({scale:t.y,axis:a,size:i.height,format:r.yFormat||r.tickFormatValue,axisExtent:r.axisExtent}),h=Tu(d),f=a.label??r.yLabelRight,p=Nu(a.axisStyle,{stroke:u.border,strokeWidth:1}),g=r.legendPosition??"right",m=at(r.legendLayout,l?.rightAxis),y=c&&"right"===g&&m>0?m:s.right,x=i.width+y-15;/* */
115
+ return $d("g",{className:"stream-axes semiotic-axis semiotic-axis-right","data-orient":"right",children:[!1!==a.baseline&&!a.jaggedBase&&/* @__PURE__ */Md("line",{x1:i.width,y1:0,x2:i.width,y2:i.height,...p}),a.jaggedBase&&/* @__PURE__ */Md("path",{d:Fu("right",i.width,i.height),fill:"none",...p}),d.map((e,t)=>{let r=Yu(a.landmarkTicks,e,t,d);/* */
116
+ return $d("g",{transform:`translate(${i.width},${e.pixel})`,children:[
117
+ /* @__PURE__ */Md("line",{x2:5,...p}),Ou(e.label)?/* @__PURE__ */Md("text",{x:8,textAnchor:"start",dominantBaseline:Ru(a.tickAnchor,e.pixel===h.min,e.pixel===h.max),fontWeight:r?600:400,fontSize:r?u.tickSize+1:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):ju({label:e.label,x:8,y:-12,textAlign:"left",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},`ytick-r-${t}`)}),f&&/* @__PURE__ */Md("text",{x:x,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(90, ${x}, ${i.height/2})`,children:f})]})}import{Fragment as Pd,jsx as Ld,jsxs as Id}from"react/jsx-runtime";function Rd(e,t){let i=xr(e.theme),r=vd,o=e.size||[500,300],n=tt({...r,...e.margin},e.title),a=Je(e.title),s=xd(pi(e.data),e.lineDataAccessor),l=e.showLegend?ic(s,e.colorAccessor||e.groupAccessor||e.categoryAccessor):[],c=dt({showAxes:e.showAxes,xLabel:e.xLabel,yLabel:e.yLabel,yLabelRight:e.yLabelRight,axes:e.axes});rd(n,{props:{...e,axisChrome:c},categories:l,theme:i,size:o,hasTitle:a});let u=od({props:{...e,axisChrome:c},categories:l,theme:i,size:o,margin:n,hasTitle:a}),d=Math.max(1,o[0]-n.left-n.right),h=Math.max(1,o[1]-n.top-n.bottom),f="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),p=e.colorScheme||i.colors.categorical,m=(e.axes?.find(e=>"left"===e.orient)??e.axes?.find(e=>"right"===e.orient))?.extent??e.axisExtent,y={chartType:e.chartType,runtimeMode:f?"streaming":"bounded",windowSize:e.windowSize??e.capacity??200,windowMode:e.windowMode??e.capacityMode??"sliding",arrowOfTime:f?e.arrowOfTime??"right":"right",extentPadding:e.extentPadding??.1,xAccessor:e.xAccessor,yAccessor:e.yAccessor,timeAccessor:f?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,groupAccessor:e.groupAccessor||(e.lineDataAccessor?"_lineGroup":void 0),categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,invertY:e.invertY,axisExtent:e.axisExtent,yAxisExtent:m,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,binAlign:e.binAlign,normalize:e.normalize,baseline:e.baseline,stackOrder:e.stackOrder,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,band:e.band,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:nr(e.gradientFill),lineGradient:ar(e.lineGradient),semanticLineStops:e.semanticLineStops,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,barStyle:e.barStyle,waterfallStyle:e.waterfallStyle,swarmStyle:e.swarmStyle,colorScheme:p,themeCategorical:i.colors.categorical,themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging,themeSemantic:Y(i),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:n,layoutSelection:e.layoutSelection,barColors:e.barColors,showValues:e.showValues,heatmapValueFormat:e.heatmapValueFormat,heatmapColorScale:e.heatmapColorScale,heatmapAggregation:e.heatmapAggregation,heatmapXBins:e.heatmapXBins,heatmapYBins:e.heatmapYBins,pointIdAccessor:e.pointIdAccessor,onLayoutError:e.onLayoutError},x=new ds(y);e.data&&x.ingest({inserts:s,bounded:!0}),x.computeScene({width:d,height:h});let b=bd(e.backgroundGraphics,o,n,x.scales),v=bd(e.foregroundGraphics,o,n,x.scales),w=Ar(e.annotations),k=w?`${e.description||e.title||"Line chart."}${w}`:e.description;if(!x.scales){let r,a=e.annotations?ku({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{},layout:{width:d,height:h},theme:i,idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;t&&(t.evidence=Fs({frameType:"xy",width:o[0],height:o[1],marks:[],title:e.title,description:k,annotations:e.annotations,annotationRender:r,extraWarnings:x.scales?[]:["NO_SCALES"],margin:n}));let l=b||v||e.annotations?/* @__PURE__ */Id(Pd,{children:[b,a,v]}):null;return Mn.renderToStaticMarkup(ad(l,{width:o[0],height:o[1],className:"stream-xy-frame"+(e.className?` ${e.className}`:""),title:e.title,description:k,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:d,innerHeight:h,legend:u,idPrefix:e._idPrefix}))}let A,S=e._idPrefix,M=Ol({nodes:x.scene,renderMode:e.renderMode,fallback:(t,i)=>Rl(t,i,S,e.hoverRadius??30)}),$=!x.xIsDate||e.xFormat||e.tickFormatTime?e:{...e,xFormat:Ao(x.scales.x.domain().map(e=>e.valueOf()))},_=e.showGrid?ud(x.scales,{width:d,height:h},i,S,e.axisExtent,e.axes,$):null,P=M.map(e=>e.element),L=`${Ku(e)}-plot-clip`,I=!1!==e.showAxes,R=I?sd(x.scales,{width:d,height:h},$,i,S,n,c,!!u):null,T=I?_d({scales:x.scales,layout:{width:d,height:h},props:e,theme:i,leftAxis:e.axes?.find(e=>"left"===e.orient),rightAxis:e.axes?.find(e=>"right"===e.orient),margin:n,axisChrome:c,hasRenderedLegend:!!u}):null,C=e.annotations?ku({annotations:e.annotations,margin:n,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{x:x.scales.x,y:x.scales.y},layout:{width:d,height:h},theme:i,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:S,underLayerBands:!0,onRender:e=>{A=e}}):null;t&&(t.evidence=Fs({frameType:"xy",width:o[0],height:o[1],marks:M.map(e=>e.node),title:e.title,description:k,annotations:e.annotations,annotationRender:A,xDomain:Ns(x.scales.x?.domain?.()),yDomain:Ns(x.scales.y?.domain?.()),legendItems:l.length>0?l.length:void 0,margin:n}));let N=e.svgPreRenderers&&x.scales?e.svgPreRenderers.map((e,t)=>{try{/* */
118
+ return Ld(Sn.Fragment,{children:e(x.scene,x.scales,{width:d,height:h})},`pre-${t}`)}catch{return null}}).filter(Boolean):null,F=g(e.annotations??[]).filter(pd),D=F.length>0?yd(F,`${Ku(e)}-under-band`,i.colors.primary||i.colors.annotation||i.colors.text)(x.scene,x.scales,{width:d,height:h}):null,E=/* @__PURE__ */Id(Pd,{children:[b,N,_,
119
+ /* @__PURE__ */Ld("defs",{children:/* @__PURE__ */Ld("clipPath",{id:L,children:/* @__PURE__ */Ld("rect",{x:0,y:0,width:d,height:h})})}),
120
+ /* @__PURE__ */Id("g",{clipPath:`url(#${L})`,children:[D,P]}),R,T,C,v,x.customLayoutOverlays]});return Mn.renderToStaticMarkup(ad(E,{width:o[0],height:o[1],className:"stream-xy-frame"+(e.className?` ${e.className}`:""),title:e.title,description:k,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:d,innerHeight:h,legend:u,idPrefix:e._idPrefix}))}Is();import*as Td from"react-dom/server";import{jsx as Cd,jsxs as Nd}from"react/jsx-runtime";function Fd(e,t){return t.completed.has(e.id)?"var(--semiotic-success, #2b8a66)":t.blockers.has(e.id)?"var(--semiotic-error, #c64035)":"in-progress"===e.status?"var(--semiotic-warning, #d18a22)":t.armed.has(e.id)?"var(--semiotic-primary, #2474a6)":"var(--semiotic-text-secondary, #75818a)"}function Dd({machine:e,layout:t,runtime:i,downstreamSet:r,selectedSet:o,width:n,height:a,seed:s,reduced:l,onSelectTask:c}){let u=t.tasks.length?t.tasks.reduce((e,t)=>Math.min(e,t.y-t.height/2),1/0):60,d=Math.max(20,u-12),h=Math.max(26,u-6);/* */
121
+ return Nd("svg",{"aria-hidden":"true",width:n,height:a,viewBox:`0 0 ${n} ${a}`,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none"},children:[
122
+ /* @__PURE__ */Cd("defs",{children:/* @__PURE__ */Cd("filter",{id:`chain-shadow-${s}`,x:"-20%",y:"-20%",width:"140%",height:"150%",children:/* @__PURE__ */Cd("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodOpacity:"0.2"})})}),e.lanes.map((e,i)=>{let r=t.tasks.filter(e=>e.laneIndex===i)[0]?.x??0;/* */
123
+ return Nd("g",{children:[
124
+ /* @__PURE__ */Cd("line",{x1:r,x2:r,y1:h,y2:a-24,stroke:"var(--semiotic-grid, #d7dde0)",strokeWidth:1,strokeDasharray:"3 7"}),
125
+ /* @__PURE__ */Cd("text",{x:r,y:d,textAnchor:"middle",fontSize:12,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e})]},e)}),t.routes.map(e=>{let t=i.delivered.has(e.edgeID),o=i.inFlight.has(e.edgeID),n=r.has(e.targetID)||r.has(e.sourceID),a=e.points.map(e=>`${e.x},${e.y}`).join(" ");/* */
126
+ return Cd("polyline",{points:a,fill:"none",stroke:n?"var(--semiotic-selection-color, #e08a1e)":t?"var(--semiotic-success, #2b8a66)":"var(--semiotic-grid, #aeb8bd)",strokeWidth:n?4:o?3:2,strokeOpacity:t||o||n?.95:.48,strokeLinecap:"round",strokeLinejoin:"round"},e.edgeID)}),t.sockets.map(e=>{let t=i.delivered.has(e.edgeID);/* */
127
+ return Nd("g",{children:[
128
+ /* @__PURE__ */Cd("circle",{cx:e.x,cy:e.y,r:e.radius+2,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.5}),t&&/* @__PURE__ */Cd("circle",{cx:e.x,cy:e.y,r:e.radius-.5,fill:"var(--semiotic-success, #2b8a66)"})]},e.id)}),e.nodes.map(e=>{let n=t.taskByID.get(e.id);if(!n)return null;let a=i.completed.has(e.id),u=i.blockers.has(e.id),d=i.previewTaskID===e.id,h=o.has(e.id)||d,f=r.has(e.id),p=Fd(e,i),g=n.x-n.width/2,m=n.y-n.height/2,y=Math.max(2,n.height*e.progress);/* */
129
+ return Nd("g",{children:[
130
+ /* @__PURE__ */Nd("g",{style:{transform:`rotate(${a?76:0}deg)`,transformBox:"fill-box",transformOrigin:"50% 100%",transition:l?"none":"transform 520ms cubic-bezier(.2,.8,.25,1)",filter:"url(#chain-shadow-"+s+")"},children:[
131
+ /* @__PURE__ */Cd("rect",{x:g,y:m,width:n.width,height:n.height,rx:e.milestone?12:4,fill:"var(--semiotic-bg, #fff)",stroke:h||f?"var(--semiotic-selection-color, #e08a1e)":p,strokeWidth:h?4:f?3:2}),
132
+ /* @__PURE__ */Cd("rect",{x:g+3,y:m+n.height-y+1,width:n.width-6,height:Math.max(0,y-4),rx:2,fill:p,opacity:a?.86:.46})]}),u&&/* @__PURE__ */Nd("g",{opacity:d?.28:1,children:[
133
+ /* @__PURE__ */Cd("line",{x1:g-8,x2:g+14,y1:n.y+9,y2:n.y-9,stroke:"var(--semiotic-error, #c64035)",strokeWidth:7,strokeLinecap:"round"}),
134
+ /* @__PURE__ */Cd("circle",{cx:g-8,cy:n.y+9,r:3,fill:"var(--semiotic-error, #c64035)"})]}),
135
+ /* @__PURE__ */Nd("g",{onPointerDown:()=>c(e.id),style:{cursor:"pointer",pointerEvents:"auto"},children:[
136
+ /* @__PURE__ */Cd("rect",{x:g,y:m,width:n.width,height:n.height,fill:"transparent"}),
137
+ /* @__PURE__ */Cd("text",{x:n.x,y:n.y-4,textAnchor:"middle",fontSize:10.5,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e.label.length>24?`${e.label.slice(0,22)}…`:e.label}),
138
+ /* @__PURE__ */Nd("text",{x:n.x,y:n.y+12,textAnchor:"middle",fontSize:9.5,fill:"var(--semiotic-text-secondary, #5f6b72)",children:[Math.round(100*e.progress),"% · ",a?"done":u?"blocked":i.armed.has(e.id)?"ready":"waiting"]})]})]},e.id)})]})}function Ed(e,t=0){if(e instanceof Date)return e.getTime();let i=Number(e);return Number.isFinite(i)?i:t}function zd(e){if(null==e.completionTime)return null;let t=Ed(e.completionTime,Number.NaN);return Number.isFinite(t)?t:null}function Od(e,t,i,r){let o=/* @__PURE__ */new Set;for(let n of e.nodes){let a=e.incoming.get(n.id)??[];(r.has(n.id)||!i.has(n.id)&&a.every(e=>t.has(e.id)))&&o.add(n.id)}return o}function jd(e,t,i,r){let o=e.nodes.map(zd).filter(e=>null!=e),n=o.length?o.reduce((e,t)=>Math.min(e,t),1/0)-1:0,a="replay"!==t||r?i:n,s=/* @__PURE__ */new Set,l=/* @__PURE__ */new Map;for(let i of e.nodes){let e=zd(i),r=null!=e&&e<=a,o="done"===i.status&&"replay"!==t;(r||o)&&s.add(i.id),i.blockerReason&&!s.has(i.id)&&l.set(i.id,i.blockerReason)}let c=/* @__PURE__ */new Set;if("replay"!==t||r)for(let t of e.edges)s.has(t.sourceID)&&c.add(t.id);return{currentTime:a,playing:!1,completed:s,delivered:c,inFlight:/* @__PURE__ */new Set,armed:Od(e,c,l,s),blockers:l,previewTaskID:null}}function Wd(e,t,i){return Ln(i,e,t)}function Bd(e,t){return e<t?-1:e>t?1:0}function Yd(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Gd(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function Xd(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function Vd(e){let t=[],i=/* @__PURE__ */new Map,r=[],o=/* @__PURE__ */new Set;e.data.forEach((n,a)=>{let s=String(Wd(n,a,e.taskIDAccessor)??"");if(!s)return void t.push({code:"duplicate-task-id",message:`Task row ${a} has an empty id.`,taskIDs:[]});if(i.has(s))return void t.push({code:"duplicate-task-id",message:`Task id "${s}" occurs more than once.`,taskIDs:[s]});let l=String(Wd(n,a,e.laneAccessor)??"Unassigned");o.has(l)||(o.add(l),r.push(l));let c=Wd(n,a,e.dependencyAccessor)??[],u=Array.from(new Set(Array.from(c,e=>String(e)))).sort(Bd),d=Wd(n,a,e.blockerAccessor),h=Wd(n,a,e.statusAccessor)??(d?"blocked":"waiting");i.set(s,{id:s,label:String(Wd(n,a,e.labelAccessor)??s),lane:l,laneIndex:0,level:0,index:a,datum:n,dependencyIDs:u,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:Wd(n,a,e.startAccessor),end:Wd(n,a,e.endAccessor),progress:Xd(Wd(n,a,e.progressAccessor)),status:h,completionTime:Wd(n,a,e.completionTimeAccessor),blockerReason:d||void 0,milestone:!!Wd(n,a,e.milestoneAccessor)})});let n=e.laneOrder?[...e.laneOrder,...r.filter(t=>!e.laneOrder?.includes(t))]:r,a=new Map(n.map((e,t)=>[e,t]));for(let e of i.values())e.laneIndex=a.get(e.lane)??0;let s=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;for(let e of i.keys())s.set(e,[]),l.set(e,[]);let c=[],u=[...i.values()].sort((e,t)=>e.index-t.index);for(let e of u)e.dependencyIDs.forEach((r,o)=>{let n=i.get(r);if(!n)return void t.push({code:"missing-dependency",message:`Task "${e.id}" depends on missing task "${r}".`,taskIDs:[e.id,r]});let a={id:Yd(r,e.id),sourceID:r,targetID:e.id,sourceIndex:n.index,targetIndex:e.index,socketID:Gd(e.id,o),socketIndex:o};c.push(a),s.get(e.id)?.push(a),l.get(r)?.push(a),e.incomingEdgeIDs.push(a.id),e.socketIDs.push(a.socketID),n.outgoingEdgeIDs.push(a.id)});for(let e of s.values())e.sort((e,t)=>Bd(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=Gd(e.targetID,t)});for(let e of l.values())e.sort((e,t)=>Bd(e.targetID,t.targetID));for(let e of i.values()){let t=s.get(e.id)??[];e.incomingEdgeIDs=t.map(e=>e.id),e.socketIDs=t.map(e=>e.socketID),e.outgoingEdgeIDs=(l.get(e.id)??[]).map(e=>e.id)}let d=/* @__PURE__ */new Map,h=/* @__PURE__ */new Map;for(let e of i.keys())d.set(e,s.get(e)?.length??0),h.set(e,0);let f=[...i.keys()].filter(e=>0===d.get(e)).sort(Bd),p=0;for(;f.length;){let e=f.shift();p+=1;for(let t of l.get(e)??[]){let i=Math.max(h.get(t.targetID)??0,(h.get(e)??0)+1);h.set(t.targetID,i);let r=(d.get(t.targetID)??0)-1;if(d.set(t.targetID,r),0===r){let e=f.findIndex(e=>e>t.targetID);e<0?f.push(t.targetID):f.splice(e,0,t.targetID)}}}if(p!==i.size){let e=[...i.keys()].filter(e=>(d.get(e)??0)>0).sort(Bd);t.push({code:"cycle",message:`Dependency graph contains a cycle involving: ${e.join(", ")}.`,taskIDs:e})}let g=0,m=[...i.values()].sort((e,t)=>e.index-t.index);for(let e of m)e.level=h.get(e.id)??0,g=Math.max(g,e.level);return{nodes:m,edges:c,byID:i,incoming:s,outgoing:l,lanes:n,maxLevel:g,diagnostics:t,valid:0===t.length}}function qd(e){return e.filter((t,i)=>{let r=e[i-1];return!r||r.x!==t.x||r.y!==t.y})}function Hd(e,t,i={}){let r=Math.max(240,t.width),o=Math.max(220,t.height),n=t.paddingX??48,a=t.paddingTop??48,s=t.paddingBottom??44,l=Math.max(1,e.lanes.length),c=Math.max(70,(r-2*n)/l),u=Math.max(1,e.maxLevel+1),d=Math.max(76,(o-a-s)/u),h=Math.min(i.taskWidth??112,Math.max(58,.78*c)),f=Math.min(i.taskHeight??58,.64*d),p=i.socketRadius??5,g=Math.max(1,Math.round(i.gutterCount??3)),m=/* @__PURE__ */new Map;for(let t of e.nodes){let e=`${t.laneIndex}:${t.level}`,i=m.get(e)??[];i.push(t),m.set(e,i)}for(let e of m.values())e.sort((e,t)=>Bd(e.id,t.id));let y=.86*d,x=e=>e<=1?f:Math.max(22,Math.min(f,(y-4*(e-1))/e)),b=e.nodes.map(e=>{let t=m.get(`${e.laneIndex}:${e.level}`)??[e],i=Math.max(0,t.findIndex(t=>t.id===e.id))-(t.length-1)/2,r=x(t.length),o=i*(r+4);return{taskID:e.id,lane:e.lane,laneIndex:e.laneIndex,level:e.level,x:n+c*(e.laneIndex+.5),y:a+d*(e.level+.5)+o,width:h,height:r}}),v=new Map(b.map(e=>[e.taskID,e])),w=[],k=[];e.edges.forEach((t,i)=>{let r=v.get(t.sourceID),o=v.get(t.targetID);if(!r||!o)return;let n=e.incoming.get(t.targetID)??[],a=Math.min(.72*o.width,14*Math.max(1,n.length-1)),s=n.length<=1?o.x:o.x-a/2+a*t.socketIndex/(n.length-1),l=o.y-o.height/2-p-2,c={id:t.socketID,edgeID:t.id,taskID:o.taskID,index:t.socketIndex,x:s,y:l,radius:p};w.push(c);let u={x:r.x,y:r.y+r.height/2+3},d=Math.max(18,l-u.y),h=7*(i%g-(g-1)/2),f=Math.min(l-10,u.y+.48*d+h);k.push({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,socketID:t.socketID,points:qd([u,{x:u.x,y:f},{x:s,y:f},{x:s,y:l}])})});let A=new Map(w.map(e=>[e.id,e])),S=new Map(k.map(e=>[e.edgeID,e]));return{tasks:b,sockets:w,routes:k,taskByID:v,socketByID:A,routeByEdgeID:S}}function Ud(e,t,i={}){let r=new Set(i.completedTaskIDs??[]),o=Me(e.nodes,e.edges.map(e=>({source:e.sourceID,target:e.targetID}))),n=[..._e(o,t)].map(t=>e.byID.get(t)).filter(e=>null!=e).filter(e=>!(i.isComplete?i.isComplete(e):r.has(e.id)||"done"===e.status)).sort((e,t)=>e.index-t.index),a=Array.from(new Set(n.map(e=>e.lane)));return{blockerID:t,downstreamTaskCount:n.length,affectedLaneCount:a.length,downstreamTaskIDs:n.map(e=>e.id),affectedLanes:a}}import{jsx as Zd,jsxs as Qd}from"react/jsx-runtime";function Kd(e){return e.__composite}function Jd(e){return Array.isArray(e)?e.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[]}function eh(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function th(e,t,i){let r="string"==typeof i?i:"Tasks are arranged by workstream and dependency depth. Completed tasks deliver their authored prerequisites; task completion remains an explicit data event.",o=[...t.blockers.keys()].map(i=>{let r=Ud(e,i,{completedTaskIDs:t.completed});return`${e.byID.get(i)?.label??i} affects ${r.downstreamTaskCount} unfinished tasks across ${r.affectedLaneCount} lanes.`}).join(" ");return o?`${r} ${o}`:`${r} No explicit blockers are active.`}import*as ih from"react-dom/server";var rh=e=>Math.max(6,Math.round(2*e/3));function oh(e){let t=e.handles&&"object"==typeof e.handles?e.handles:e.handles?{}:null,i="number"==typeof t?.size&&Number.isFinite(t.size)?t.size:12;return{top:t?.move?Math.ceil(rh(i)/2)+2:0,bottom:e.showExtentLabels?34:20}}function nh(e,t){let i=e.colors.selection??e.colors.primary;return{fill:i,fillOpacity:t,stroke:i,strokeWidth:1}}var ah=(e,t,i)=>Math.min(i,Math.max(t,e)),sh=e=>Number(e.toPrecision(15));function lh({domain:e,scale:t,orientation:i,reverse:r=!1}){if(t){let e=t.range().map(Number),i=t.domain().map(Number),r=Math.min(e[0],e[e.length-1]),o=Math.max(e[0],e[e.length-1])-r,n=Math.min(i[0],i[i.length-1]),a=Math.max(i[0],i[i.length-1]);if(![r,o,n,a].every(Number.isFinite)||o<=0||a<=n)return null;let s=Math.abs(t(n)-r)<=Math.abs(t(a)-r);return{min:n,max:a,toFraction:e=>(t(e)-r)/o,fromFraction:e=>e<=0?s?n:a:e>=1?s?a:n:ah(sh(Number(t.invert(r+e*o))),n,a)}}if(!e)return null;let o=Math.min(Number(e[0]),Number(e[1])),n=Math.max(Number(e[0]),Number(e[1]));if(!Number.isFinite(o)||!Number.isFinite(n)||n<=o)return null;let a=n-o,s="x"===i?!r:r;return{min:o,max:n,toFraction:e=>{let t=(e-o)/a;return s?t:1-t},fromFraction:e=>e<=0?s?o:n:e>=1?s?n:o:sh(s?o+e*a:n-e*a)}}function ch(e,t){if(!e||e.length<2)return null;let i=Number(e[0]),r=Number(e[1]);return Number.isFinite(i)&&Number.isFinite(r)?[ah(Math.min(i,r),t.min,t.max),ah(Math.max(i,r),t.min,t.max)]:null}function uh(e){if(!Number.isFinite(e))return"";let t=Math.round(100*e)/100;return String(Object.is(t,-0)?0:t)}function dh(e,t,i,r=1.2*i,o){return"y"===t?e.length*r:o??Math.max(0,...e.map(e=>Array.from(e).length))*i*.6}function hh(e){let{value:t,track:i,length:r,orientation:o,format:n,fontSize:a,labelWidth:s,showDomainLabels:l}=e,c=e.lineHeight??1.2*a,u=e.gap??6,[d,h]=e.bounds??[0,r],f=(e,t,r=i.toFraction(t))=>{let l=n(t),u=l.split("\n");return{kind:e,value:t,text:l,lines:u,fraction:r,size:dh(u,o,a,c,s)}},p=(e,t)=>{let i=e.fraction*r,o=t;"before"===o&&i-e.size<d?o="after":"after"===o&&i+e.size>h&&(o="before");let n="before"===o?i-e.size:i;return{...e,placement:o,row:0,from:n,to:n+e.size}},g=f("start",t[0]),m=f("end",t[1]),[y,x]=g.fraction<=m.fraction?[g,m]:[m,g],b=p(y,"before"),v=p(x,"after");b.to+u>v.from&&(v.row=1);let w=[b,v];if(!l)return w;let k=w.filter(e=>0===e.row),A=e=>{let t=i.fromFraction(e),o=f(t===i.min?"domain-start":"domain-end",t,e),n=0===e?0:r-o.size;return{...o,placement:0===e?"after":"before",row:0,from:n,to:n+o.size}};return[...[A(0),A(1)].filter(e=>e.from>=d&&e.to<=h&&k.every(t=>e.to+u<=t.from||t.to+u<=e.from)),...w]}function fh(e){return e.__composite}function ph(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function gh(e,t,i,r){return e.replace(/^<svg\b/,`<svg x="${t}" y="${i}" data-semiotic-composite-part="${r}"`)}function mh(e,t){for(let i of e){let e=i?.[t];if(Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1])return e}}import{jsx as yh,jsxs as xh}from"react/jsx-runtime";var bh=e=>!0===e?{}:e&&"object"==typeof e?e:null,vh=e=>"string"==typeof e?e:void 0;function wh(e){return t=>{try{let i="function"==typeof e?e(t):void 0;return"string"==typeof i?i:uh(t)}catch{return uh(t)}}}function kh(e,t,i,r,o,n,a){let s=[.35,.65].map(e=>"x"===a?{x1:t-r/2+r*e,x2:t-r/2+r*e,y1:i-.2*o,y2:i+.2*o}:{x1:t-.2*r,x2:t+.2*r,y1:i-o/2+o*e,y2:i-o/2+o*e});/* */
139
+ return xh("g",{className:"semiotic-brush-handle","data-semiotic-brush-part":e,children:[
140
+ /* @__PURE__ */yh("rect",{x:t-r/2+.5,y:i-o/2+.5,width:r-1,height:o-1,rx:n.radius,fill:n.fill,stroke:n.stroke,strokeWidth:1}),s.map((e,t)=>/* @__PURE__ */yh("line",{...e,stroke:n.grip,strokeWidth:1},t))]},e)}function Ah(e){let{theme:t,config:i,direction:r,plot:o,margin:n}=e,a=lh({domain:e.domain,orientation:r});if(!a)return null;let s=bh(i.handles),l=ch(e.extent,a)??(s?[a.min,a.max]:null);if(!l)return null;let c=bh(i.brushStyle)??{},u=nh(t,.2),d=t.colors.surface??t.colors.background,h="x"===r?o.width:o.height,[f,p]=[a.toFraction(l[0]),a.toFraction(l[1])].sort((e,t)=>e-t),g=(e,t)=>"x"===r?{x:o.x+e*h,y:o.y,width:(t-e)*h,height:o.height}:{x:o.x,y:o.y+e*h,width:o.width,height:(t-e)*h},m=[],y=bh(c.mask);if(y)for(let[e,t]of[[0,f],[p,1]])m.push(/* @__PURE__ */yh("rect",{className:"semiotic-brush-mask","data-semiotic-brush-part":"mask",...g(e,t),fill:vh(y.fill)??d,opacity:ph(y.opacity,.6)},`mask-${e}`));let x=ph(c.strokeWidth,1),b=g(f,p);if(m.push(
141
+ /* @__PURE__ */yh("rect",{className:"selection","data-semiotic-brush-part":"selection",x:b.x+x/2,y:b.y+x/2,width:Math.max(0,b.width-x),height:Math.max(0,b.height-x),fill:vh(c.fill)??u.fill,fillOpacity:ph(c.fillOpacity,.2),stroke:vh(c.stroke)??u.stroke,strokeWidth:x},"selection")),s){let e=ph(s.size,12),t=rh(e),i={fill:vh(s.fill)??d,stroke:vh(s.stroke)??u.stroke,grip:u.stroke,radius:ph(s.radius,3)};for(let[n,a]of[["start",f],["end",p]])m.push("x"===r?kh(n,o.x+a*h,o.y+o.height/2,t,2*e,i,"x"):kh(n,o.x+o.width/2,o.y+a*h,2*e,t,i,"y"));if(s.move){let n=(f+p)/2;m.push("x"===r?kh("move",o.x+n*h,o.y,2*e,t,i,"x"):kh("move",o.x,o.y+n*h,t,2*e,i,"y"))}}if(i.showExtentLabels){let s=hh({value:l,track:a,length:h,orientation:r,format:wh(i.extentLabelFormat??e.axisFormat),fontSize:11,bounds:"x"===r?[-n.left,o.width+n.right]:[-n.top,o.height+n.bottom]}),c=13.2*Math.max(1,...s.map(e=>e.lines.length));for(let e of s){let i="before"===e.placement,n="x"===r?o.x+e.fraction*h:o.x+o.width+4,a="x"===r?o.y+o.height+4+e.row*c:o.y+e.from;m.push(
142
+ /* @__PURE__ */yh("text",{className:"semiotic-brush-label","data-semiotic-brush-label":e.kind,x:n,y:a+10.45,fill:t.colors.textSecondary,fontFamily:t.typography.fontFamily,fontSize:11,textAnchor:"x"===r&&i?"end":"start",children:e.lines.map((e,t)=>/* @__PURE__ */yh("tspan",{x:n,dy:0===t?0:13.2,children:e},t))},`label-${e.kind}`))}}/* */
143
+ return yh("g",{className:"semiotic-minimap-brush",children:m})}import{jsx as Sh,jsxs as Mh}from"react/jsx-runtime";import{jsx as $h,jsxs as _h}from"react/jsx-runtime";var Ph={top:4,bottom:4,left:4,right:4};function Lh(e,t,i,r,o){return{__composite:{data:e,colorBy:t,colorScheme:i,common:r,rest:o}}}function Ih(e){return Array.isArray(e)?e.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[]}function Rh(e,t){return Math.max(1,Math.floor(ph(e,t)))}var Th={frameType:"xy",buildProps:Lh,renderStatic:function(e,t){let{data:i,colorBy:r,colorScheme:o,common:n,rest:a}=fh(e),[s,l]=n.size??[600,400],c=a.minimap&&"object"==typeof a.minimap?a.minimap:{},u=ph(c.height,60),d=n.margin,h=c.margin&&"object"==typeof c.margin?c.margin:{},f=oh(c),p={top:ph(h.top,f.top),right:ph(h.right,ph(d?.right,20)),bottom:ph(h.bottom,f.bottom),left:ph(h.left,ph(d?.left,40))},g=u+p.top+p.bottom,m=a.frameProps&&"object"==typeof a.frameProps?a.frameProps:{},y={...a,xAccessor:a.xAccessor||"x",yAccessor:a.yAccessor||"y"},x="y"===c.brushDirection?"y":"x",b={...n,size:[s,l],xExtent:m.xExtent??("x"===x?a.brushExtent:void 0)??n.xExtent,yExtent:m.yExtent??("y"===x?a.brushExtent:void 0)??a.yExtent??n.yExtent,_idPrefix:`${String(n._idPrefix??"minimap")}-detail`},v=hn.buildProps(i,r,o,b,y);Object.assign(v,m);let w={...n,size:[s,g],margin:p,title:void 0,description:`${String(n.description??n.title??"Chart")} overview minimap`,showAxes:c.showAxes??!1,showLegend:!1,showGrid:!1,accessibleTable:!1,background:c.background,xExtent:void 0,yExtent:a.yExtent??n.yExtent,_idPrefix:`${String(n._idPrefix??"minimap")}-overview`};delete w.lineStyle,delete w.pointStyle;let k={...y,fillArea:!1,lineWidth:1,showPoints:!1,directLabel:!1,forecast:void 0,anomaly:void 0,band:void 0},A=hn.buildProps(i,r,o,w,k);A.chartType=a.fillArea?"area":"line","function"==typeof c.lineStyle&&(A.lineStyle=c.lineStyle);let S={},M={},$=Rd(v,S),_=Rd(A,M),P=!0===a.renderBefore,L=P?0:l,I=[gh($,0,P?g:0,"detail"),gh(_,0,L,"overview")].join(""),R=l+g,T=xr(n.theme),C=br(T),N="string"==typeof n.title?n.title:void 0,F="string"==typeof n.description?n.description:N||"Chart with overview minimap",D=Ku(n),E=N?`${D}-title`:void 0,z=`${D}-description`,O=Array.isArray(a.brushExtent)&&a.brushExtent.length>=2?[Number(a.brushExtent[0]),Number(a.brushExtent[1])]:null,j="x"===x?M.evidence?.xDomain:M.evidence?.yDomain,W=j?Ah({theme:T,config:c,direction:x,domain:j,extent:O&&O.every(Number.isFinite)?O:null,plot:{x:p.left,y:L+p.top,width:Math.max(0,s-p.left-p.right),height:u},margin:p,axisFormat:"x"===x?n.xFormat:n.yFormat}):null,B=ih.renderToStaticMarkup(
144
+ /* @__PURE__ */Mh("svg",{xmlns:"http://www.w3.org/2000/svg",className:"minimap-chart",width:s,height:R,role:"img","aria-labelledby":[E,z].filter(Boolean).join(" "),style:{fontFamily:C.fontFamily},children:[N&&/* @__PURE__ */Sh("title",{id:E,children:N}),
145
+ /* @__PURE__ */Sh("desc",{id:z,children:F}),
146
+ /* @__PURE__ */Sh("g",{dangerouslySetInnerHTML:{__html:I}}),W]}));if(t){let e=[S.evidence,M.evidence];t.evidence=Rs({frameType:"xy",width:s,height:R,parts:e,title:N,description:F,xDomain:mh(e,"xDomain"),yDomain:mh(e,"yDomain")})}return B}};function Ch(e,t){return String("function"==typeof t?t(e):e[t])}function Nh(e,t,i,r){if(!t)return{categories:[],color:()=>zi};let o=Array.from(new Set(e.map(e=>Ch(e,t)))),n="string"==typeof t?t:"__semioticSplomColor",a=Vi("function"==typeof t?e.map(e=>({...e,[n]:Ch(e,t)})):e,n,i??r.colors.categorical);return{categories:o,color:e=>Gi(e,t,a)}}function Fh(e){let{data:t,field:i,label:r,cellSize:o,bins:n,diagonal:a,colorBy:s,color:l,x:c,y:u}=e;if("label"===a)return{visibleBars:0,svg:An.renderToStaticMarkup(
147
+ /* @__PURE__ */$h("svg",{x:c,y:u,width:o,height:o,"data-semiotic-composite-part":`diagonal-${i}`,children:/* @__PURE__ */$h("text",{x:o/2,y:o/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:r})}))};let d=t.map(e=>Number(e[i])).filter(Number.isFinite),h=d.length?Math.min(...d):0,f=((d.length?Math.max(...d):0)-h)/n||1,p=Array.from({length:n},()=>/* @__PURE__ */new Map);for(let e of t){let t=Number(e[i]);if(!Number.isFinite(t))continue;let r=Math.max(0,Math.min(n-1,Math.floor((t-h)/f))),o=s?Ch(e,s):"__all",a=p[r];a.set(o,[...a.get(o)??[],e])}let g=p.map(e=>Array.from(e.values()).reduce((e,t)=>e+t.length,0)),m=Math.max(1,...g),y=0,x=p.flatMap((e,t)=>{let i=0;return Array.from(e.entries()).flatMap(([e,r])=>{if(0===r.length)return[];y+=1;let a=r.length/m*(o-24),c=i;return i+=a,/* @__PURE__ */$h("rect",{x:t/n*o,y:o-c-a,width:Math.max(o/n-1,1),height:a,fill:s?l(r[0]):zi,opacity:.6},`${t}-${e}`)})});return{visibleBars:y,svg:An.renderToStaticMarkup(
148
+ /* @__PURE__ */_h("svg",{x:c,y:u,width:o,height:o,"data-semiotic-composite-part":`diagonal-${i}`,children:[
149
+ /* @__PURE__ */$h("text",{x:o/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333",children:r}),x]}))}}var Dh={frameType:"physics",buildProps:Lh,renderStatic:function(e,t){let{data:i,common:r,rest:o}=Kd(e),n=Jd(i),[a,s]=r.size??[920,620],l="string"==typeof r.title?r.title:"Dependency chain reaction",c=Vd({data:n,taskIDAccessor:o.taskIDAccessor,labelAccessor:o.labelAccessor,laneAccessor:o.laneAccessor,dependencyAccessor:o.dependencyAccessor,startAccessor:o.startAccessor,endAccessor:o.endAccessor,progressAccessor:o.progressAccessor,statusAccessor:o.statusAccessor,completionTimeAccessor:o.completionTimeAccessor,blockerAccessor:o.blockerAccessor,milestoneAccessor:o.milestoneAccessor}),u=xr(r.theme),d=br(u),h=Ku(r),f=`${h}-title`,p=`${h}-description`;if(!c.valid){let e=c.diagnostics.map(e=>e.message).join(" "),i=Td.renderToStaticMarkup(
150
+ /* @__PURE__ */Qd("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:a,height:s,role:"img","aria-labelledby":`${f} ${p}`,style:{fontFamily:d.fontFamily},children:[
151
+ /* @__PURE__ */Zd("title",{id:f,children:l}),
152
+ /* @__PURE__ */Zd("desc",{id:p,children:e}),
153
+ /* @__PURE__ */Zd("rect",{width:a,height:s,fill:d.background}),
154
+ /* @__PURE__ */Zd("text",{x:24,y:36,fontSize:16,fontWeight:700,fill:d.text,children:l}),c.diagnostics.map((e,t)=>/* @__PURE__ */Zd("text",{x:24,y:72+22*t,fontSize:12,fill:u.colors.error,children:e.message},`${e.code}-${t}`))]}));return t&&(t.evidence=Rs({frameType:"physics",width:a,height:s,parts:[],title:l,description:e,nodeCount:c.nodes.length,edgeCount:c.edges.length,extraWarnings:["INVALID_DEPENDENCY_GRAPH"]})),i}let g=Hd(c,{width:a,height:s}),m=jd(c,"snapshot",Ed(o.currentTime,1/0),!0),y=Array.isArray(o.selectedTaskIDs)?o.selectedTaskIDs.map(String):[],x=new Set(y),b=y[0]??null,v=b&&"none"!==o.insight?Ud(c,b,{completedTaskIDs:m.completed}):null,w=new Set(v?.downstreamTaskIDs??[]),k=eh(o.seed,31),A=th(c,m,r.description),S=Td.renderToStaticMarkup(
155
+ /* @__PURE__ */Zd(Dd,{machine:c,layout:g,runtime:m,downstreamSet:w,selectedSet:x,width:a,height:s,seed:k,reduced:!0,onSelectTask:()=>{}})),M=void 0===r.theme?{}:V(u),$=Td.renderToStaticMarkup(
156
+ /* @__PURE__ */Qd("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:a,height:s,role:"img","aria-labelledby":`${f} ${p}`,style:{...M,fontFamily:d.fontFamily},children:[
157
+ /* @__PURE__ */Zd("title",{id:f,children:l}),
158
+ /* @__PURE__ */Zd("desc",{id:p,children:A}),
159
+ /* @__PURE__ */Zd("rect",{width:a,height:s,fill:d.background}),
160
+ /* @__PURE__ */Zd("text",{x:a/2,y:22,textAnchor:"middle",fontSize:d.titleFontSize,fontFamily:d.titleFontFamily,fontWeight:d.titleFontWeight,fill:d.text,children:l}),
161
+ /* @__PURE__ */Zd("g",{dangerouslySetInnerHTML:{__html:S}})]}));return t&&(t.evidence=Rs({frameType:"physics",width:a,height:s,parts:[],additionalMarkCountByType:{task:c.nodes.length,dependency:c.edges.length},title:l,description:A,categories:c.lanes,nodeCount:c.nodes.length,edgeCount:c.edges.length})),$}},Eh={LineChart:hn,BumpChart:en,AreaChart:pn,DifferenceChart:gn,StackedAreaChart:mn,Scatterplot:ro,BubbleChart:ao,Heatmap:kn,QuadrantChart:xn,MultiAxisLineChart:sn,WaterfallChart:ln,CandlestickChart:yn,ConnectedScatterplot:bn,ScatterplotMatrix:{frameType:"xy",buildProps:Lh,renderStatic:function(e,t){let{data:i,colorBy:r,colorScheme:o,common:n,rest:a}=fh(e),s=Ih(i),l=Array.isArray(a.fields)?a.fields.filter(e=>"string"==typeof e):[],c=a.fieldLabels&&"object"==typeof a.fieldLabels?a.fieldLabels:{},u=Rh(a.cellSize,150),d=Math.max(0,ph(a.cellGap,4)),h=Math.max(0,ph(a.pointRadius,2)),f=Math.max(0,Math.min(1,ph(a.pointOpacity,.5))),p=Rh(a.histogramBins,20),g="string"==typeof a.diagonal?a.diagonal:"histogram",m=40+l.length*u+l.length*d,y=l.length*u+40+l.length*d,x=xr(n.theme),b=br(x),v=Nh(s,r,o,x),w=a.showLegend??!!r,k="string"==typeof n.title?n.title:void 0,A="string"==typeof n.description?n.description:`Scatterplot matrix comparing ${l.length} fields`,S=k?28:0,M=w?v.categories:[],$=e=>Math.max(72,30+7*e.length),_=0,P=0,L=M.map(e=>{let t=$(e);_>0&&_+t>m&&(P+=1,_=0);let i={label:e,x:_,y:24*P};return _+=t,i}),I=M.length?24*(P+1)+4:0,R=S+I,T=R+y,C=[],N=[],F=0;l.forEach((e,t)=>{l.forEach((i,o)=>{let l=40+d+o*(u+d),m=R+t*(u+d);if(t===o){let t=Fh({data:s,field:e,label:Xi(c,e)??e,cellSize:u,bins:p,diagonal:g,colorBy:r,color:v.color,x:l,y:m});return F+=t.visibleBars,void N.push(t.svg)}let y={},x=Rd({chartType:"scatter",data:s,size:[u,u],xAccessor:i,yAccessor:e,pointStyle:Q(e=>({r:h,opacity:f,fill:v.color(e)}),a.styleRules,H(i,e)),margin:Ph,showAxes:!1,showGrid:!1,enableHover:!1,accessibleTable:!1,description:`${Xi(c,i)??i} versus ${Xi(c,e)??e} scatterplot`,theme:n.theme,_idPrefix:`${String(n._idPrefix??"splom")}-${t}-${o}`},y);C.push(y.evidence),N.push(gh(x,l,m,`cell-${e}-${i}`))})});let D=Ku(n),E=k?`${D}-title`:void 0,z=`${D}-description`,O=An.renderToStaticMarkup(
162
+ /* @__PURE__ */_h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"scatterplot-matrix",width:m,height:T,role:"img","aria-labelledby":[E,z].filter(Boolean).join(" "),style:{fontFamily:b.fontFamily},children:[k&&/* @__PURE__ */$h("title",{id:E,children:k}),
163
+ /* @__PURE__ */$h("desc",{id:z,children:A}),
164
+ /* @__PURE__ */$h("rect",{width:m,height:T,fill:b.background}),k&&/* @__PURE__ */$h("text",{x:0,y:18,fontSize:14,fontWeight:600,fill:b.text,children:k}),L.map(e=>{let t=s.find(t=>r&&Ch(t,r)===e.label),i=t?v.color(t):zi;/* */
165
+ return _h("g",{transform:`translate(${e.x},${S+e.y})`,children:[
166
+ /* @__PURE__ */$h("circle",{cx:5,cy:8,r:5,fill:i}),
167
+ /* @__PURE__ */$h("text",{x:14,y:12,fontSize:11,fill:b.text,children:e.label})]},e.label)}),l.map((e,t)=>{let i=R+t*(u+d)+u/2;/* */
168
+ return $h("text",{x:20,y:i,transform:`rotate(-90 20 ${i})`,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:b.text,children:Xi(c,e)??e},`row-${e}`)}),l.map((e,t)=>/* @__PURE__ */$h("text",{x:40+d+t*(u+d)+u/2,y:R+l.length*(u+d)+20,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:b.text,children:Xi(c,e)??e},`column-${e}`)),
169
+ /* @__PURE__ */$h("g",{dangerouslySetInnerHTML:{__html:N.join("")}})]}));return t&&(t.evidence=Rs({frameType:"xy",width:m,height:T,parts:C,additionalMarkCountByType:F>0?{histogram:F}:void 0,title:k,description:A,categories:v.categories.length?v.categories:void 0,legendItems:M.length||void 0})),O}},MinimapChart:Th},zh=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;let t=e-this._mean;this._mean+=t/this._count;let i=e-this._mean;this._m2+=t*i,e<this._min&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);let t=this._count+e._count,i=e._mean-this._mean;this._mean+=i*e._count/t,this._m2+=e._m2+i*i*this._count*e._count/t,this._count=t,e._min<this._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){let t=new e;return t.merge(this),t}get count(){return this._count}get mean(){return this._mean}get sum(){return this._mean*this._count}get variance(){return this._count<2?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return this._count<2?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}};function Oh(e){let t=qe(e);return t^=t>>>16,t=Math.imul(t,2146121005),t^=t>>>15,t=Math.imul(t,2221713035),t^=t>>>16,t>>>0}var jh=class e{constructor(e=10){let t=Math.max(4,Math.min(16,Math.floor(e)));this.p=t,this.m=1<<t,this.registers=new Uint8Array(this.m),this.alpha=.7213/(1+1.079/this.m),this.harmonicSum=this.m,this.zeros=this.m}add(e){let t=Oh(String(e)),i=t>>>32-this.p,r=Math.min(Math.clz32(t<<this.p),32-this.p)+1;this.updateRegister(i,r)}updateRegister(e,t){let i=this.registers[e];t<=i||(this.registers[e]=t,this.harmonicSum+=2**-t-2**-i,0===i&&this.zeros--)}merge(e){if(e.m===this.m)for(let t=0;t<this.m;t++)this.updateRegister(t,e.registers[t])}clone(){let t=new e(this.p);return t.registers.set(this.registers),t.harmonicSum=this.harmonicSum,t.zeros=this.zeros,t}count(){let e=this.alpha*this.m*this.m/this.harmonicSum;return e<=2.5*this.m&&this.zeros>0?Math.round(this.m*Math.log(this.m/this.zeros)):Math.round(e)}},Wh=class e{constructor(e=100){this.centroids=[],this.total=0,this.pending=0,this.compression=Math.max(20,e)}push(e){Number.isFinite(e)&&(this.centroids.push({mean:e,weight:1}),this.total+=1,this.pending++,this.pending>=2*this.compression&&this.compress())}merge(e){if(0===e.total)return;let t=0===this.total,i=e.centroids.length;for(let t=0;t<i;t++)this.centroids.push({...e.centroids[t]});this.total+=e.total,this.pending=t&&this.compression===e.compression?e.pending:this.pending+i,t||this.compress()}clone(){let t=new e(this.compression);return t.merge(this),t}quantile(e){if(0===this.total||Number.isNaN(e))return Number.NaN;let t=Math.min(1,Math.max(0,e));this.compress();let i=t*this.total,r=this.centroids[0].weight/2;if(i<=r)return this.centroids[0].mean;for(let e=1;e<this.centroids.length;e++){let t=this.centroids[e-1],o=this.centroids[e],n=(t.weight+o.weight)/2,a=r+n;if(i<=a){let e=(i-r)/n;return t.mean+(o.mean-t.mean)*e}r=a}return this.centroids[this.centroids.length-1].mean}get count(){return this.total}compress(){if(0===this.pending||(this.pending=0,this.centroids.length<=1))return;this.centroids.sort((e,t)=>e.mean-t.mean);let e=0,t=0,i=this.total,r=this.compression;for(let o=1;o<this.centroids.length;o++){let n=this.centroids[e],a=this.centroids[o],s=(t+n.weight/2)/i,l=4*i*s*(1-s)/r;if(n.weight+a.weight<=Math.max(1,l)){let e=n.weight+a.weight;n.mean=(n.mean*n.weight+a.mean*a.weight)/e,n.weight=e}else t+=n.weight,this.centroids[++e]=a}this.centroids.length=e+1}};function Bh(e){let t=Math.round(1e3*e)/10;return`p${String(t).replace(".","_")}`}function Yh(e,t,i){let r=e.length;for(e.push(t);r>0;){let o=r-1>>>1;if(i(e[o],t)<=0)break;e[r]=e[o],r=o}e[r]=t}function Gh(e,t){let i=e[0],r=e.pop();if(e.length>0){let i=0;for(;2*i+1<e.length;){let o=2*i+1;if(o+1<e.length&&t(e[o+1],e[o])<0&&o++,t(r,e[o])<=0)break;e[i]=e[o],i=o}e[i]=r}return i}var Xh=(e,t)=>e-t,Vh=class{constructor(e,t){this.stats=new zh,this.digest=e?new Wh:null,this.hll=t?new jh:null}push(e,t){this.stats.push(e),this.digest?.push(e),this.hll&&this.hll.add(t??e)}merge(e){this.stats.merge(e.stats),this.digest?.merge(e.digest),this.hll?.merge(e.hll)}},qh=class{constructor(e){this.windows=/* @__PURE__ */new Map,this.starts=[],this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;let t=e.hop??e.size;this.hop=t>0&&t<=e.size?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0,this.percentiles=e.percentiles??[],this.wantDistinct=!0===e.distinct}newBucket(){return new Vh(this.percentiles.length>0,this.wantDistinct)}push(e,t,i){!Number.isFinite(e)||!Number.isFinite(t)||(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t,i):this.pushFixed(e,t,i),this.prune())}pushFixed(e,t,i){if("tumbling"===this.type||this.hop>=this.size){let r=Math.floor(e/this.size)*this.size;return void this.bump(r,t,i)}let r=this.hop,o=Math.floor(e/r);for(let n=Math.floor((e-this.size)/r)+1;n<=o;n++)this.bump(n*r,t,i)}bump(e,t,i){let r=this.windows.get(e);if(!r){if(this.windows.size>=this.retain&&e<this.starts[0])return;r=this.newBucket(),this.windows.set(e,r),this.retain!==1/0&&Yh(this.starts,e,Xh)}r.push(t,i)}pushSession(e,t,i){let r=e-this.gap,o=e+this.gap,n=0,a=this.sessions.length,s=this.sessions[a-1];if(!s||e>=s.end)n=a,s&&s.end>=r&&s.start<=o&&n--;else for(;n<a;){let e=n+a>>>1;this.sessions[e].end<r?n=e+1:a=e}let l=this.sessions[n];if(!l||l.start>o){let r=this.newBucket();return r.push(t,i),void this.sessions.splice(n,0,{start:e,end:e,bucket:r})}l.bucket.push(t,i),l.start=Math.min(l.start,e),l.end=Math.max(l.end,e);let c=n+1;for(;c<this.sessions.length&&this.sessions[c].start<=o;){let e=this.sessions[c++];l.bucket.merge(e.bucket),l.end=Math.max(l.end,e.end)}c>n+1&&this.sessions.splice(n+1,c-n-1)}prune(){if(this.retain!==1/0){if("session"===this.type)return void(this.sessions.length>this.retain&&this.sessions.splice(0,this.sessions.length-this.retain));for(;this.windows.size>this.retain;)this.windows.delete(Gh(this.starts,Xh))}}emit(){if("session"===this.type)return this.sessions.map(e=>{let t=this.latest-e.end<this.gap;return this.row(e.start,e.end,e.bucket,t)});let e=[];for(let[t,i]of this.windows){let r=t+this.size;e.push(this.row(t,r,i,this.latest<r))}return e.sort((e,t)=>e.start-t.start),e}row(e,t,i,r){let o=i.stats,n={start:e,end:t,count:o.count,mean:o.mean,sum:o.sum,min:o.min,max:o.max,stddev:o.stddev,partial:r};if(i.digest){let e={};for(let t of this.percentiles)e[Bh(t)]=i.digest.quantile(t);n.percentiles=e}return i.hll&&(n.distinct=i.hll.count()),n}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.starts=[],this.sessions=[],this.latest=-1/0}};function Hh(e,t){switch(t){case"distinct":return e.distinct??0;case"p50":case"p95":case"p99":return e.percentiles?.[t]??Number.NaN;default:return e[t]??e.mean}}function Uh(e,t,i,r=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];let o=Hh(e,i),n=e.stddev*r;return[o-n,o+n]}var Zh={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Qh=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function Kh(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;let t=e.trim();if(""===t)return null;Qh.lastIndex=0;let i,r=0,o=0;for(;null!==(i=Qh.exec(t));){let e=parseFloat(i[1]),t=Zh[i[2]];if(null==t||!Number.isFinite(e))return null;r+=e*t,o+=i[0].length}return o!==t.length?null:r>0?r:null}var Jh="time",ef="value",tf="__aggLower",rf="__aggUpper",of="__aggPartial",nf="count",af="__aggStart",sf="__aggEnd";function lf(e){let t=e.window??"tumbling",i=Kh("session"===t?e.gap??e.size:e.size);if(null==i)return null;let r=null!=e.hop?Kh(e.hop):void 0,o=null!=e.gap?Kh(e.gap):void 0;return new qh({window:t,size:i,hop:r??void 0,gap:o??void 0,retain:e.retain,percentiles:e.percentiles,distinct:e.distinct})}function cf(e,t){let i=t.stat??"mean",r=t.band??"none",o=t.sigma??1;return e.emit().map(e=>{let t={[Jh]:(e.start+e.end)/2,[ef]:Hh(e,i),[nf]:e.count,[of]:e.partial,[af]:e.start,[sf]:e.end},n=Uh(e,r,i,o);return n&&(t[tf]=n[0],t[rf]=n[1]),t})}function uf(e){return"none"!==(e.band??"none")}var df="__aggSeries",hf=class{constructor(e,t){this.config=e,this.seriesAccessor=t,this.groups=/* @__PURE__ */new Map}push(e,t,i){let r=ui(e,t,"time"),o=ci(e,i,"value");if(null==r||null==o)return;let n=null==this.seriesAccessor?"":String("function"==typeof this.seriesAccessor?this.seriesAccessor(e):e[this.seriesAccessor]),a=this.groups.get(n);if(!a){if(a=lf(this.config),!a)return;this.groups.set(n,a)}a.push(+r,o)}emit(e){let t=[];for(let[i,r]of this.groups)for(let o of cf(r,e))t.push(null==this.seriesAccessor?o:{...o,[df]:i});return t}clear(){this.groups.clear()}};function ff(e,t,i){return e??i??Math.max(t?.length??0,200)}function pf(e,t){let i=Array.isArray(e)?pi(e):[],r=t.aggregate;if(!r)return i;let o=new hf(r,t.seriesAccessor);for(let e of i)o.push(e,t.timeAccessor,t.valueAccessor);return o.emit(r)}function gf(e){let t=e.timeAccessor||"time",i=e.valueAccessor||"value";return{timeAccessor:e=>ui(e,t,"time")??NaN,valueAccessor:e=>ci(e,i,"value")??NaN}}function mf(e,t,i){return{runtimeMode:"streaming",windowMode:i.windowMode??i.capacityMode??"sliding",windowSize:ff(i.windowSize,e,i.capacity),arrowOfTime:i.arrowOfTime??"right",...gf(i),xExtent:i.timeExtent??t.xExtent,yExtent:i.valueExtent??t.yExtent,extentPadding:i.extentPadding??t.extentPadding,tickFormatTime:i.tickFormatTime,tickFormatValue:i.tickFormatValue}}var yf={RealtimeLineChart:{frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=pf(e,o),a=o.aggregate,s=o.aggregate?{timeAccessor:"time",valueAccessor:"value"}:gf(o),l=Q(()=>({stroke:"#007bff",strokeWidth:2}),o.styleRules,H(s.timeAccessor,s.valueAccessor));return{chartType:"line",data:n,...r,...mf(n,r,o),...s,groupAccessor:a&&null!=o.seriesAccessor?df:o.seriesAccessor,...a&&{windowMode:"growing",windowSize:Math.max(1,a.retain??Math.max(n.length,600)),band:uf(a)?{y0Accessor:tf,y1Accessor:rf,perSeries:null!=o.seriesAccessor}:void 0},lineStyle:r.lineStyle||(e=>({...l(e),...gr(o),...null!=o.strokeDasharray&&{strokeDasharray:o.strokeDasharray},...null!=o.cursor&&{cursor:o.cursor}}))}}},RealtimeHistogram:/* @__PURE__ */Object.assign({},fn,{buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?pi(e):[];return{...fn.buildProps(n,t,i,r,o),...mf(n,r,o)}}}),TemporalHistogram:fn,RealtimeSwarmChart:{frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?pi(e):[],a=no(n,r,o,"discovery"),s=Q(void 0,o.styleRules,H(o.timeAccessor??"time",o.valueAccessor??"value"));return{chartType:"swarm",data:n,...r,...mf(n,r,o),categoryAccessor:o.categoryAccessor,colorScheme:a||i||r.colorScheme,barColors:a,yScaleType:o.yScaleType,swarmStyle:{...gr(o),fill:o.fill,radius:o.radius,cursor:o.cursor},pointStyle:e=>({...s(e),..."function"==typeof o.pointStyle?o.pointStyle(e):{},..."function"==typeof r.pointStyle?r.pointStyle(e):r.pointStyle})}}},RealtimeWaterfallChart:{frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?pi(e):[],a=ln.buildProps(n,t,i,r,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value"});return{...a,...mf(n,r,o),waterfallStyle:{...a.waterfallStyle,cursor:o.cursor}}}},RealtimeHeatmap:{frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?pi(e):[];return{...kn.buildProps(n,t,i,r,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value",heatmapAggregation:o.aggregation??"count",cellBorderWidth:0}),...mf(n,r,o),categoryAccessor:o.categoryAccessor}}}};import{useMemo as xf,useCallback as bf,useRef as vf}from"react";var wf={RdBu:Li,PiYG:Ii,PRGn:Ri,BrBG:Ti,RdYlBu:Ci,RdYlGn:Ni,Spectral:Fi},kf="__likert_neutral_neg",Af="__likert_neutral_pos";function Sf(e,t){if("function"==typeof e)return e;let i=e||t;return e=>e[i]}function Mf(e,t){if(e<=0)return[];if(t&&Object.prototype.hasOwnProperty.call(wf,t)){let i=wf[t];if(1===e)return[i(.5)];let r=[];for(let t=0;t<e;t++)r.push(i(t/(e-1)));return r}let i=["#da1e28","#ff8389","#ffb3b8"],r=["#a6c8ff","#4589ff","#0043ce"],o="#a8a8a8";if(1===e)return[o];let n=e%2!=0,a=Math.floor(e/2),s=[];for(let e=0;e<a;e++)s.push(i[Math.min(Math.floor(e*i.length/a),i.length-1)]);n&&s.push(o);for(let e=0;e<a;e++)s.push(r[Math.min(Math.floor(e*r.length/a),r.length-1)]);return s}function $f(e,t,i,r,o,n,a={}){let s=/* @__PURE__ */new Map,l=new Set(t);for(let a of e){let e=i(a);s.has(e)||s.set(e,/* @__PURE__ */new Map);let c=s.get(e);if(r){let e=r(a);if(null==e||!Number.isFinite(e))continue;if(!Number.isInteger(e)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",e);continue}let i=e-1;if(i<0||i>=t.length)continue;let o=t[i];c.set(o,(c.get(o)||0)+1)}else if(o&&n){let e=o(a),t=n(a);if(!l.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}let c=[];for(let[e,i]of s){let r=0;for(let e of t)r+=i.get(e)||0;if(0!==r)for(let o=0;o<t.length;o++){let n=t[o],s=i.get(n)||0,l={};a.category&&(l[a.category]=e),a.level&&(l[a.level]=n),a.count&&(l[a.count]=s),a.score&&(l[a.score]=o+1),c.push({...l,__likertCategory:e,__likertLevel:n,__likertLevelLabel:n,__likertCount:s,__likertPct:s/r*100,__likertLevelIndex:o})}}return c}function _f(e,t){let i=t.length,r=i%2!=0,o=Math.floor(i/2),n=[];for(let t of e){let e=t.__likertLevelIndex;if(r&&e===o){let e=t.__likertPct/2;n.push({...t,__likertLevel:kf,__likertPct:-e}),n.push({...t,__likertLevel:Af,__likertPct:e})}else e<o?n.push({...t,__likertPct:-t.__likertPct}):n.push(t)}return n}function Pf(e,t){let i=t.length,r=i%2!=0,o=Math.floor(i/2),n=/* @__PURE__ */new Map;for(let t of e){let e=n.get(t.__likertCategory)||[];e.push(t),n.set(t.__likertCategory,e)}let a=[];for(let[,e]of n){let t,n,s=/* @__PURE__ */new Map;for(let i of e)i.__likertLevel===kf?t=i:i.__likertLevel===Af?n=i:s.set(i.__likertLevelIndex,i);r&&t&&a.push(t);for(let e=o-1;e>=0;e--){let t=s.get(e);t&&a.push(t)}r&&n&&a.push(n);for(let e=r?o+1:o;e<i;e++){let t=s.get(e);t&&a.push(t)}}return a}import{jsx as Lf,jsxs as If}from"react/jsx-runtime";function Rf(e,t,i){let r=Math.max(16,.3*t);if(null==i||i<=0)return r;let o=mc(e,r),n=2*i*.8;return o<=n?r:r*n/o}function Tf({value:e,min:t,max:i,radius:r,innerRadius:o,showScaleLabels:n,label:a}){let s=Rf(e,r,o),l=.7*s+11;/* */
170
+ return If("g",{textAnchor:"middle",children:[
171
+ /* @__PURE__ */Lf("text",{y:0,dominantBaseline:"central",fontSize:s,fontWeight:700,fill:"var(--semiotic-text, #333)",children:e}),n&&/* @__PURE__ */If("text",{y:l,fontSize:11,fill:"var(--semiotic-text-secondary, #666)",children:[t," – ",i]}),null!=a&&""!==a&&/* @__PURE__ */Lf("text",{y:l+(n?14:0),fontSize:11,fill:"var(--semiotic-text-secondary, #666)",children:a})]})}function Cf({centerContent:e,centerLabel:t,value:i,min:r,max:o,radius:n,innerRadius:a,showScaleLabels:s,valueFormat:l,compact:c}){if(null!=e){let s="function"==typeof e?e(i,r,o):e;return"string"==typeof s||"number"==typeof s?Tf({value:String(s),min:r,max:o,radius:n,innerRadius:a,showScaleLabels:!1,label:t}):s}return c?null:Tf({value:l?l(i):String(Math.round(i)),min:r,max:o,radius:n,innerRadius:a,showScaleLabels:s,label:t})}function Nf(e){return Math.max(0,Math.min(1,e))}function Ff(e){let t=e.trim();if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e.split("").map(e=>e+e).join("")),6===e.length&&/^[0-9a-f]{6}$/i.test(e))return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}let i=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(i){let e=[Number(i[1]),Number(i[2]),Number(i[3])];if(e.every(Number.isFinite))return e}return null}function Df(e,t,i){let r=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(i)}`}function Ef(e,t,i){let r=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Nf(e.offset),color:e.color??i,opacity:null==e.opacity?1:Nf(e.opacity)})).sort((e,t)=>e.offset-t.offset);if(0===r.length)return"#999999";let o=e=>{if(1===e.opacity)return e.color;let t=Ff(e.color);return t?`rgba(${t[0]},${t[1]},${t[2]},${e.opacity})`:e.color};if(1===r.length)return o(r[0]);let n=Nf(t);if(n<=r[0].offset)return o(r[0]);if(n>=r[r.length-1].offset)return o(r[r.length-1]);for(let e=0;e<r.length-1;e++){let t=r[e],i=r[e+1];if(n<t.offset||n>i.offset)continue;let a=i.offset-t.offset,s=a<=0?0:(n-t.offset)/a,l=Ff(t.color),c=Ff(i.color);if(!l||!c)return o(s<.5?t:i);let[u,d,h]=l,[f,p,g]=c,m=u+(f-u)*s,y=d+(p-d)*s,x=h+(g-h)*s,b=t.opacity+(i.opacity-t.opacity)*s;return 1===b?Df(m,y,x):`rgba(${Math.round(m)},${Math.round(y)},${Math.round(x)},${b})`}return o(r[r.length-1])}function zf(e,t,i){return null==i?`${e}-${t}`:`${e}-${t}-${i}`}function Of(e){let{min:t,max:i,value:r,thresholds:o,fillColor:n,backgroundColor:a,fillZones:s,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=e,d=Math.max(t,Math.min(i,r)),h=i-t||1,f=(d-t)/h,p=o&&o.length>0?[...o].sort((e,t)=>e.value-t.value):[{value:i,color:n||"#007bff"}];p=p.map(e=>({...e,value:Math.max(t,Math.min(i,e.value))})),p[p.length-1].value<i&&p.push({value:i,color:p[p.length-1].color});let g=!!c&&c.stops.length>=2,m=[],y=/* @__PURE__ */new Map,x=[];if(g){let e=s?f:1,t=zf("bg",0);if(m.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),y.set(t,{fill:a,opacity:.4}),e>0){let t=Math.max(1,Math.floor(u)),i=Math.max(1,Math.min(t,Math.round(e*t))),r=[];for(let t=0;t<i;t++){let o=e*(t+.5)/i;r.push(Ef(c.stops,o,n||p[0]?.color||"#007bff"))}let o=zf("fill",0);m.push({category:o,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:r}}),y.set(o,{fill:r[0]||a})}}else{let e=t;for(let o=0;o<p.length;o++){let n=p[o],l=(n.value-e)/h,c=(e-t)/h,u=(n.value-t)/h,g=s?Math.min(f,u):u,x=Math.max(0,g-c),b=s?Math.max(0,l-x):0;if(x>0){let a=zf("fill",o);m.push({category:a,value:x,_zone:n.label||`Zone ${o+1}`,_isFill:!0,__gaugeAccessibleDatum:{category:n.label||`Zone ${o+1}`,value:r,min:t,max:i,segmentStart:e,segmentEnd:t+g*h,filled:!0}}),y.set(a,{fill:n.color})}if(b>0){let s=zf("bg",o);m.push({category:s,value:b,_zone:n.label||`Zone ${o+1}`,_isFill:!1,__gaugeAccessibleDatum:{category:n.label||`Zone ${o+1}`,value:r,min:t,max:i,segmentStart:Math.max(e,d),segmentEnd:n.value,filled:!1}}),y.set(s,{fill:a,opacity:.4})}e=n.value}}if(l&&o&&o.length>0)for(let e of o)e.value>t&&e.value<i&&x.push({type:"gauge-label",value:e.value,label:e.label||String(e.value)});return{gaugeData:m,pieceStyle:(e,t)=>{let i=t||e.category;return y.get(i)||{fill:a}},gaugeAnnotations:x}}function jf(e=240){let t=e*Math.PI/180,i=360-e,r=180+i/2,o=r*Math.PI/180;return{sweepRad:t,gapDeg:i,startAngleDeg:r,startAngleRad:o,offsetRad:-Math.PI/2+o}}function Wf(e=240){let{sweepRad:t,offsetRad:i}=jf(e),r=[[Math.cos(i),Math.sin(i)],[Math.cos(i+t),Math.sin(i+t)],[0,0]];for(let e=0;e<2*Math.PI;e+=Math.PI/2)((e-i)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)<=t+.001&&r.push([Math.cos(e),Math.sin(e)]);let o=r.map(e=>e[0]),n=r.map(e=>e[1]),[a,s]=Ce(o),[l,c]=Ce(n);return{minX:a,maxX:s,minY:l,maxY:c,width:s-a,height:c-l,cx:(a+s)/2,cy:(l+c)/2}}import{Fragment as Bf,jsx as Yf,jsxs as Gf}from"react/jsx-runtime";function Xf(e){return nr(e)}function Vf(e,t,i,r,o,n){let a=xr(r.theme).colors.categorical,s=i??r.colorScheme,l=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],c="string"==typeof t?t:"__ssrColorBy",u="function"==typeof t?l.map(e=>({...e,__ssrColorBy:t(e)})):l,d=t?Vi(u,c,s??a):void 0,h=Ui("string"==typeof o.color?o.color:void 0,a,s,void 0,
172
+ /* @__PURE__ */new Map),f=n??q(o.valueAccessor??"value"),p=o.styleRules,g=r.pieceStyle;return(e,i)=>{let r={fill:t&&d?Gi(e,t,d):h};return p?.length&&Object.assign(r,Z(e,p,{value:f(e,i),category:i})),"function"==typeof g?Object.assign(r,g(e,i)||{}):g&&"object"==typeof g&&Object.assign(r,g),void 0!==o.stroke&&(r.stroke=o.stroke),void 0!==o.strokeWidth&&(r.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(r.opacity=o.opacity),r}}function qf(e,t,i,r,o,n="median",a=.8){let s=q(o.valueAccessor??"value"),l=Vf(e,t,i,r,o,e=>"number"==typeof e[n]?e[n]:s(e));return(e,t)=>{let i=l(e,t);return void 0===i.fillOpacity&&(i.fillOpacity=a),void 0===i.stroke&&(i.stroke=i.fill),i}}function Hf(e,t,i,r,o){return qf(e,t,i,r,o,"median",.6)}function Uf(e,t,i,r,o){let n=Vf(e,t,i,r,o),a="number"==typeof o.dotRadius?o.dotRadius:5;return(e,t)=>({r:a,fillOpacity:.8,...n(e,t)})}function Zf(e,t,i,r,o){let n=Vf(e,t,i,r,o),a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=o.sizeBy,l=Array.isArray(o.sizeRange)?o.sizeRange:[3,8],c=s?a.map(e=>"function"==typeof s?s(e):Number(e[s])).filter(Number.isFinite):[],u=c.length?Ce(c):void 0,d="number"==typeof o.pointRadius?o.pointRadius:4,h="number"==typeof o.pointOpacity?o.pointOpacity:.7;return(e,t)=>({r:s?Hi(e,s,l,u):d,fillOpacity:h,...n(e,t)})}var Qf={BarChart:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=mr(r.annotations,o.regression);return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,colorAccessor:t,colorScheme:i,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,...n&&{annotations:n},gradientFill:Xf(r.gradientFill),pieceStyle:Vf(e,t,i,r,o)}}},StackedBarChart:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.stackBy;return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.stackBy,colorAccessor:n,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},normalize:o.normalize,oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:Xf(r.gradientFill),pieceStyle:Vf(e,n,i,r,o),showLegend:r.showLegend??!!n}}},GroupedBarChart:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.groupBy;return{chartType:"clusterbar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",groupBy:o.groupBy,colorAccessor:n,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:Xf(r.gradientFill),pieceStyle:Vf(e,n,i,r,o),showLegend:r.showLegend??!!n}}},SwarmPlot:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"swarm",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},barPadding:o.categoryPadding??20,colorAccessor:t,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...r,sizeRange:o.sizeRange||[3,8],pieceStyle:Zf(e,t,i,r,o),showLegend:r.showLegend??!!t})},BoxPlot:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"boxplot",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},colorAccessor:t,colorScheme:i,...null!=o.showOutliers&&{showOutliers:o.showOutliers},...null!=o.outlierRadius&&{outlierRadius:o.outlierRadius},...r,summaryStyle:qf(e,t,i,r,o)})},Histogram:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=o.valueAccessor||"value",s=n.map(e=>Number("function"==typeof a?a(e):e[a])).filter(Number.isFinite),l=s.length?[Math.min(...s),Math.max(...s)]:void 0;return{chartType:"histogram",data:e,oAccessor:o.categoryAccessor||(e=>null==e.category?"All":String(e.category)),rAccessor:a,projection:"horizontal",bins:o.bins??25,normalize:o.relative??!1,colorAccessor:t,colorScheme:i,barPadding:o.categoryPadding??20,...o.valueExtent?{rExtent:o.valueExtent}:l?{rExtent:l}:{},...r,summaryStyle:qf(e,t,i,r,o,"count")}}},ViolinPlot:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"violin",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,projection:"horizontal"===o.orientation?"horizontal":"vertical",bins:o.bins??25,showIQR:o.showIQR??!0,barPadding:o.categoryPadding??20,colorScheme:i,...r,summaryStyle:Hf(e,t,i,r,o),showLegend:r.showLegend??!!t,...o.valueExtent&&{rExtent:o.valueExtent}})},RidgelinePlot:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"ridgeline",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},bins:o.bins??20,amplitude:o.amplitude??1.5,barPadding:o.categoryPadding??5,oSort:o.oSort??!1,...r,summaryStyle:qf(e,t,i,r,o,"median",.5),showLegend:r.showLegend??!!t})},DotPlot:{frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,i,r,o)=>{let n=mr(r.annotations,o.regression);return{chartType:"point",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??"auto",barPadding:o.categoryPadding??10,...r,...n&&{annotations:n},pieceStyle:Uf(e,t,i,r,o),showGrid:r.showGrid??!0,showLegend:r.showLegend??!!t}}},PieChart:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.categoryAccessor,a=q(o.valueAccessor??"value");return{chartType:"pie",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:n,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:Vf(e,n,i,r,o,e=>{let t=a(e);return null==t?void 0:Math.abs(t)}),showLegend:r.showLegend??!!n}}},DonutChart:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.categoryAccessor,a=q(o.valueAccessor??"value");return{chartType:"donut",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",margin:r.margin??{top:50,right:40,bottom:60,left:70},innerRadius:o.innerRadius??60,colorAccessor:n,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:Vf(e,n,i,r,o,e=>{let t=a(e);return null==t?void 0:Math.abs(t)})}}},GaugeChart:{frameType:"ordinal",renderOverlay:function(e,{theme:t}){let i=e.__gauge;if(!i)return null;let r=Math.max(i.gMin,Math.min(i.gMax,i.value??i.gMin)),o=i.gMax===i.gMin?0:(r-i.gMin)/(i.gMax-i.gMin),n=(i.startAngleDeg+o*i.sweep-90)*Math.PI/180,a=i.needleColor||t.colors.text,s=i.showScaleLabels?(i.thresholds||[]).filter(e=>e.value>i.gMin&&e.value<i.gMax):[];/* */
173
+ return Gf(Bf,{children:[i.showNeedle&&/* @__PURE__ */Gf(Bf,{children:[
174
+ /* @__PURE__ */Yf("line",{x1:i.centerX,y1:i.centerY,x2:i.centerX+i.needleLength*Math.cos(n),y2:i.centerY+i.needleLength*Math.sin(n),stroke:a,strokeWidth:2.5,strokeLinecap:"round"}),
175
+ /* @__PURE__ */Yf("circle",{cx:i.centerX,cy:i.centerY,r:4,fill:a})]}),null!=i.contextValue&&/* @__PURE__ */Yf("text",{x:i.centerX,y:i.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:i.valueFontSize,fontWeight:700,fill:a,children:i.contextValue}),s.map((e,r)=>{let o=i.gMax===i.gMin?0:(e.value-i.gMin)/(i.gMax-i.gMin),n=(i.startAngleDeg+o*i.sweep-90)*Math.PI/180,a=i.innerRadius-1,s=i.radius+1,l=i.radius+10,c=((n+Math.PI/2)/(2*Math.PI)*12+12)%12,u=c>=11||c<1?"middle":c<5?"start":c<7?"middle":"end",d=c>=11||c<1?"auto":c<5?"middle":c<7?"hanging":"middle";/* */
176
+ return Gf("g",{children:[
177
+ /* @__PURE__ */Yf("line",{x1:i.centerX+Math.cos(n)*a,y1:i.centerY+Math.sin(n)*a,x2:i.centerX+Math.cos(n)*s,y2:i.centerY+Math.sin(n)*s,stroke:t.colors.border,strokeWidth:2,strokeLinecap:"round"}),
178
+ /* @__PURE__ */Yf("text",{x:i.centerX+Math.cos(n)*l,y:i.centerY+Math.sin(n)*l,textAnchor:u,dominantBaseline:d,fill:t.colors.textSecondary,fontSize:10,children:e.label||String(e.value)})]},`gauge-label-${r}`)})]})},buildProps:(e,t,i,r,o)=>{let n=o.min??0,a=o.max??100,s=o.sweep??240,l=o.arcWidth??.3,c=!1!==o.showNeedle,u=!1!==o.fillZones,{startAngleDeg:d}=jf(s),h=r.__resolvedMode??o.mode,f="context"===h||"sparkline"===h,p=o.showScaleLabels??!f,g=o.thresholds,m=ar(r.gradientFill),y=Of({min:n,max:a,value:o.value,thresholds:g,fillColor:o.color,backgroundColor:o.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:p,gradientFill:m}),x=o.styleRules,[b,v]=r.size||[300,250],w=Wf(s),k=Math.min(10,Math.max(1,Math.min(b,v)/12)),A=Math.max(4,Math.min((b-2*k)/w.width,(v-2*k)/w.height)-2),S=Math.max(0,Math.min(A-1.5,A*(1-l))),M=b/2-w.cx*A,$=v/2-w.cy*A,_=2*(A+4),P=Math.max(n,Math.min(a,o.value??n)),L="function"==typeof o.valueFormat?o.valueFormat(P):String(Math.round(P)),I=o.centerContent??r.centerContent,R=Cf({centerContent:I,centerLabel:"string"==typeof o.centerLabel?o.centerLabel:void 0,value:P,min:n,max:a,radius:A,innerRadius:S,showScaleLabels:p,valueFormat:"function"==typeof o.valueFormat?o.valueFormat:void 0,compact:f});return{chartType:"donut",data:y.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:S,sweepAngle:s,startAngle:d,oSort:!1,pieceStyle:Qi((e,t)=>{let i={...y.pieceStyle(e,t)};return x?.length&&Object.assign(i,Z(e,x,{value:"number"==typeof e.value?e.value:void 0,category:t??(null==e.category?void 0:String(e.category))})),i},gr(o)),...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...r,size:[b,v],margin:{top:$-_/2,bottom:v-$-_/2,left:M-_/2,right:b-M-_/2},...null!=R&&{centerContent:R},showAxes:!1,annotations:[...Array.isArray(r.annotations)?r.annotations:[],...y.gaugeAnnotations],__gauge:{gMin:n,gMax:a,sweep:s,arcWidth:l,value:P,startAngleDeg:d,thresholds:g,centerX:M,centerY:$,radius:A,innerRadius:S,showScaleLabels:p,needleLength:S>20?S-8:A-1,showNeedle:c,needleColor:o.needleColor,..."context"===h&&null==I&&{contextValue:L,contextValueY:$-.2*S,valueFontSize:Math.max(12,Math.min(22,.28*A))}}}}},FunnelChart:{frameType:"ordinal",layout:{margin:(e,t)=>"vertical"===e.orientation?{top:t.title?60:40,right:20,bottom:60,left:60}:{top:t.title?40:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n="vertical"===o.orientation,a=t||o.categoryAccessor;return{chartType:n?"bar-funnel":"funnel",data:e,oAccessor:o.stepAccessor||"step",rAccessor:o.valueAccessor||"value",colorAccessor:a,categoryAccessor:o.categoryAccessor,projection:n?"vertical":"horizontal",connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,...!n&&null!=o.connectorOpacity&&{connectorOpacity:o.connectorOpacity},barPadding:n?40:0,colorScheme:i,...r,showAxes:n&&!1!==r.showAxes,showGrid:n,pieceStyle:Vf(e,a,i,r,o),showLabels:o.showLabels??!0}}},RadarChart:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=o.seriesAccessor||t||"__radar",a=t||("__radar"===n?void 0:n),s=Uf(e,a,i,r,{...o,dotRadius:o.pointRadius??4});return{chartType:"point",projection:"radial",data:e,oAccessor:o.categoryAccessor||"attribute",rAccessor:o.valueAccessor||"value",colorAccessor:a,colorScheme:i,connectorAccessor:n,connectorStyle:e=>{let t=s(e),i="string"==typeof t.fill?t.fill:void 0;return{fill:i,fillOpacity:.15,stroke:i,strokeWidth:2,opacity:.7}},pieceStyle:s,rExtent:o.valueExtent||[0],oLabel:"",...r,...o.categoryFormat&&{oFormat:o.categoryFormat},showLegend:r.showLegend??!!a}}},SwimlaneChart:{frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.subcategoryAccessor;return{chartType:"swimlane",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.subcategoryAccessor,colorAccessor:n,categoryAccessor:o.categoryAccessor,subcategoryAccessor:o.subcategoryAccessor,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...null!=o.trackFill&&{trackFill:o.trackFill},...o.valueExtent&&{rExtent:o.valueExtent},...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:Xf(r.gradientFill),pieceStyle:Vf(e,n,i,r,o),showLegend:r.showLegend??!!n,barPadding:o.barPadding??40}}},LikertChart:{frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,i,r,o)=>{let n=Array.isArray(o.levels)&&o.levels.length>=2?o.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],a="vertical"!==o.orientation,s=$f(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n,Sf(o.categoryAccessor,"question"),o.levelAccessor?null:Sf(o.valueAccessor,"score"),o.levelAccessor?Sf(o.levelAccessor,"level"):null,o.levelAccessor?Sf(o.countAccessor,"count"):null,{category:"string"==typeof o.categoryAccessor?o.categoryAccessor:void 0,level:"string"==typeof o.levelAccessor?o.levelAccessor:void 0,count:"string"==typeof o.countAccessor?o.countAccessor:void 0,score:o.levelAccessor||"string"!=typeof o.valueAccessor?void 0:o.valueAccessor});a&&(s=Pf(_f(s,n),n));let l=xr(r.theme).colors.diverging,c=Array.isArray(i)&&i.length>=n.length?i:Mf(n.length,l),u=new Map(n.map((e,t)=>[e,c[t]||"#888"])),d=n.length%2&&u.get(n[Math.floor(n.length/2)])||"#888",h="function"==typeof o.valueFormat?o.valueFormat:e=>`${Math.abs(Number(e)).toFixed(0)}%`,f=Ze(!1===r.showLegend?void 0:{legendGroups:[{label:"",items:n.map(e=>({label:e})),styleFn:e=>({fill:u.get(e.label)||"#888"})}]},r.legend),p=o.styleRules,g=r.pieceStyle;return{chartType:"bar",data:s,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:a?"horizontal":"vertical",barPadding:o.barPadding,showGrid:r.showGrid,oLabel:o.categoryLabel,rLabel:o.valueLabel||(a?void 0:"Percentage"),rFormat:h,...o.categoryFormat&&{oFormat:o.categoryFormat},...o.valueExtent&&{rExtent:o.valueExtent},...r,pieceStyle:Qi((e,t)=>{let i=e.__likertLevel||e.data?.__likertLevel,r=e.__likertLevelLabel||e.data?.__likertLevelLabel,o=e.__likertPct??e.data?.__likertPct,n={fill:i===kf||i===Af?d:u.get(String(r||i))||"#888"};return p?.length&&Object.assign(n,Z(e,p,{value:"number"==typeof o?o:void 0,category:t??(null==r?void 0:String(r))})),"function"==typeof g?Object.assign(n,g(e,t)||{}):g&&"object"==typeof g&&Object.assign(n,g),n},gr(o)),showLegend:r.showLegend??!0,legendPosition:r.legendPosition||"right",...f&&{legend:f},__legendIncludesAutomatic:!0}}}},Kf={frameType:"xy",buildProps:(e,t,i,r,o)=>({chartType:"custom",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1,showLegend:r.showLegend??!!t})},Jf={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"custom",data:e,oAccessor:o.categoryAccessor||o.oAccessor||"category",rAccessor:o.valueAccessor||o.rAccessor||"value",projection:o.projection||"vertical",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1})},ep={frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(e,t,i,r,o)=>({chartType:"force",nodes:o.nodes||e||[],edges:o.edges||[],nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor||"id",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",valueAccessor:o.valueAccessor||"value",colorBy:t,colorScheme:i,customNetworkLayout:o.layout||o.customNetworkLayout,layoutConfig:o.layoutConfig,...r})},tp={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({...Jf.buildProps(e,t,i,r,o),customLayout:ee,showAxes:!1})},ip={frameType:"xy",buildProps:(e,t,i,r,o)=>({...Kf.buildProps(e,t,i,r,o),customLayout:Le,showAxes:!1})};import*as rp from"react";import{scaleLinear as op}from"d3-scale";function np(e){let{data:i,valueAccessor:r,bins:n,ballRadius:a,seed:s,size:l,valueExtent:c}=e,{rows:u}=o(i,"galton"),d=k(l),h=u.map((e,t)=>$(M(e,t,r))).filter(e=>null!=e),f=t(c),[p,g]=f??(h.length?Ce(h):[0,1]),m=g===p?1:g-p,y=op().domain([0,n]).range([d.plot.x,d.plot.x+d.plot.width]),x=Array.from({length:n},()=>0),b=[];u.forEach((e,t)=>{let i=$(M(e,t,r));if(null==i)return;let o=Math.max(0,Math.min(n-1,Math.floor((i-p)/m*n)));x[o]+=1,b.push({id:String(e.id??`galton-${t}`),x:y(o+.5),y:d.plot.y+a+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:a},datum:{...e,value:i,bin:o}})});let v=d.plot.y+d.plot.height,w=[...te({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...ie({idPrefix:"galton-bin",count:n,domainStart:0,domainStep:1,xScale:y,yTop:d.plot.y-400,yBottom:v,wallThickness:6})];return{config:S(s,w,"GaltonBoardChart"),initialSpawns:b,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:x.map((e,t)=>({label:String(t+1),value:e})),metadata:{kind:"galton-board",bins:n,plot:d.plot,valueExtent:[p,g]}}}import{scaleLinear as ap}from"d3-scale";function sp(e,t){let i=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:i,height:e.plot.height},windowPlot:{x:e.plot.x+i,y:e.plot.y,width:Math.max(40,e.plot.width-i),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}function lp(e,t){let i=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!i)return[];let r=e.windowStart,o=e.windowStart+e.windowCount*e.windowSize,n=ap().domain([r,o]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),a=n(e.windowStart+i*e.windowSize),s=e.windowPlot.x,l=Math.max(18,Math.min(.3*e.windowPlot.height,a-s)),c=t+l,u=e=>a===s?t:c+(e-s)/(a-s)*(t-c),d=[];for(let t=0;t<i;t+=1){let i=e.windowStart+t*e.windowSize,r=i+e.windowSize,o=n(i),a=n(r);d.push({id:`eventdrop-lid-${t}`,windowIndex:t,x1:o,y1:u(o),x2:a,y2:u(a)})}return d}function cp(e){let{count:t,idPrefix:i,wallThickness:r,xScale:o,yBottom:n,yTop:a,yTopForIndex:s}=e;return Array.from({length:t+1},(e,t)=>{let l=Math.min(n-1,s?.(t)??a),c=Math.max(1,n-l);return{id:`${i}-wall-${t}`,shape:{type:"aabb",x:o(t),y:l+c/2,width:r,height:c}}})}function up(e){let{data:t,timeAccessor:i,arrivalAccessor:r,windows:o,watermark:a,watermarkAtArrivalAccessor:s,ballRadius:l,seed:c,size:u,timeExtent:d,timeScale:h=1}=e,{events:f,watermarkValue:p}=n({data:t,timeAccessor:i,arrivalAccessor:r,watermark:a,watermarkAtArrivalAccessor:s,windowSize:o.size}),g=k(u),m=f.length?1/0:0,y=f.length?1/0:0,x=f.length?-1/0:o.size;for(let e of f)m=Math.min(m,e.arrivalTime),y=Math.min(y,e.eventTime),x=Math.max(x,e.eventTime);let b=$(d?.[0]),v=$(d?.[1]),w=Math.min(b??y,y),A=Math.max(v??x,x),M=Math.floor(w/o.size)*o.size,_=Math.max(1,Math.ceil((A-M+o.size)/o.size)),P=sp(g,l),L=M+_*o.size,I=ap().domain([M,L]).range([P.windowPlot.x,P.windowPlot.x+P.windowPlot.width]),R=0,T=Array.from({length:_},(e,t)=>(M+(t+1)*o.size<=p&&R++,{value:0,secondary:0})),C=[];f.forEach(({datum:e,index:t,eventTime:i,arrivalTime:r,watermarkAtArrival:n,late:a})=>{let s=Math.max(0,Math.min(_-1,Math.floor((i-M)/o.size)));T[s].value+=a?0:1,T[s].secondary+=a?1:0,C.push({id:String(e.id??`event-${t}`),x:hp(i,s,a,{windowStart:M,windowSize:o.size,gutter:P.gutter,closedWindowCount:R,windowPlot:P.windowPlot,windowCount:_},l),y:g.plot.y+l+2,vx:0,vy:0,mass:1,friction:.02,spawnAt:r,shape:{type:"circle",radius:l},datum:{...e,eventTime:i,arrivalTime:r,windowIndex:s,watermarkAtArrival:n,late:a}})});let N=g.plot.y+g.plot.height,F=g.plot.y+.28*g.plot.height,D={closedWindowCount:R,gutter:P.gutter,plot:g.plot,windowCount:_,windowPlot:P.windowPlot,windowSize:o.size,windowStart:M},E=lp(D,F);for(let e of C){let t=e.datum;e.y=dp({...D,lidSegments:E},t.windowIndex,t.late,l)}let z=e=>{if(e<0||e>R)return null;let t=0===e?E[0]?.y1:E[e-1]?.y2??E[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null},O=cp({idPrefix:"eventdrop-window",count:_,xScale:e=>I(M+e*o.size),yTop:P.wallTop,yTopForIndex:e=>{let t=z(e);return null==t?P.wallTop:t+1.25*l},yBottom:N,wallThickness:6}),j=[...te({x:g.plot.x,y:g.plot.y,width:g.plot.width,height:g.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...O,...E.map(e=>({id:e.id,shape:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:Math.max(4,.42*l)},friction:.02,restitution:.01}))];return{config:S(c,j,"EventDropChart",{friction:.08}),initialSpawns:C,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>{let t=e.datum,i=t.windowIndex<R;return i&&!t.late||!i&&t.late?m:t.arrivalTime},timeScale:h},projectionRows:T.map((e,t)=>({label:`${M+t*o.size}-${M+(t+1)*o.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:R,gutter:P.gutter,lidSegments:E,lateCount:T.reduce((e,t)=>e+t.secondary,0),plot:g.plot,windowPlot:P.windowPlot,windowWalls:O.map(({id:e,shape:t})=>({id:e,x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height})),watermarkValue:p,windowCount:_,windowSize:o.size,windowStart:M}}}function dp(e,t,i,r){let{windowPlot:o,lidSegments:n}=e,a=n[t];return i&&!a?Math.min(o.y+o.height-r,o.y+.48*o.height+2*r+4):!i&&a?Math.min(o.y+o.height-r,Math.max(a.y1,a.y2)+2*r+4):o.y+r+2}function hp(e,t,i,r,o){let{windowPlot:n,windowCount:a,windowStart:s,windowSize:l}=r;if(i&&t>=r.closedWindowCount)return r.gutter.x+r.gutter.width/2;let c=n.width/a,u=i?n.x:n.x+t*c,d=i?n.x+n.width:u+c,h=Math.min((d-u)/2,o+(i?0:3)),f=n.x+(e-s)/l*c;return Math.max(u+h,Math.min(d-h,f))}function fp(e,t,i){let r=Math.max(1,t),o=e.width/r,n=Math.max(2,2*i),a=Math.min(.7*o,Math.max(3.2*n,n+8)),s=Math.max(1,Math.floor(a/n));return{laneWidth:o,tubeWidth:a,ballDiameter:n,perRow:s,centerX:t=>e.x+(t+.5)*o,pileHeight:e=>Math.ceil(Math.max(0,e)/s)*n}}function pp(t){let{data:i,categoryAccessor:r,valueAccessor:n,unitValue:a,ballRadius:l,seed:c,size:u}=t,d=e(a,1),{rows:h}=o(i,"pile"),f=k(u),p=[],g=/* @__PURE__ */new Map,m=/* @__PURE__ */new Map,y=[];function x(e){let t=g.get(e);return null==t&&(t=p.length,p.push(e),g.set(e,t)),t}h.forEach((e,t)=>{x(String(M(e,t,r)??"unknown"))});let b=Math.max(1,p.length),v=fp(f.plot,b,l),w=Math.max(0,v.tubeWidth/2-l-1),A=p.map(()=>[]);h.forEach((e,t)=>{let i=String(M(e,t,r)??"unknown"),o=x(i),a=n?$(M(e,t,n)):1,c=Math.max(0,a??0);m.set(i,(m.get(i)??0)+c);let u=s(c,d),h=v.centerX(o);for(let r=0;r<u;r+=1){let n=A[o].length,a=r===u-1?c-r*d:d,s=Math.min(1,a/d),p=v.perRow>1?n%v.perRow:0,g=v.perRow>1?(p/(v.perRow-1)*2-1)*w:0;A[o].push({id:`${String(e.id??`pile-${t}`)}-${r}`,x:h+g,y:f.plot.y+l+2,vx:(r%3-1)*l/2,vy:0,mass:1,shape:{type:"circle",radius:l*Math.sqrt(s)},datum:{...e,category:i,unitIndex:r,unitValue:d,representedValue:a,unitFraction:s}})}});let _=A.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;e<_;e+=1)for(let t of A)e<t.length&&y.push(t[e]);let P=f.plot.y+f.plot.height,L=[...te({x:f.plot.x,y:f.plot.y,width:f.plot.width,height:f.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],I=f.plot.y-400;for(let e=0;e<b;e+=1){let t=v.centerX(e);for(let i of[-1,1])L.push({id:`pile-tube-${e}-${i<0?"l":"r"}`,shape:{type:"aabb",x:t+i*(v.tubeWidth+6)/2,y:(I+P)/2,width:6,height:P-I}})}return{config:S(c,L,"UnitPileChart"),initialSpawns:y,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:p.map(e=>({label:e,value:m.get(e)??0}))}}import{scaleLinear as gp}from"d3-scale";function mp(e,t,i,r){let o=(t+i)/2,n=[];for(let a of e){let s=n.filter(e=>Math.abs(a.x-e.x)<a.radius+e.radius+.5),l=[o];for(let e of s){let t=a.radius+e.radius+.5,i=Math.sqrt(t**2-(a.x-e.x)**2);l.push(e.y-i,e.y+i)}let c=r()<.5?-1:1;l.sort((e,t)=>Math.abs(e-o)-Math.abs(t-o)||c*(e-t));let u=l.find(e=>e-a.radius>=t&&e+a.radius<=i&&s.every(t=>(a.x-t.x)**2+(e-t.y)**2>=(a.radius+t.radius+.5)**2-1e-6));if(null==u){let r=e.reduce((e,t)=>Math.max(e,t.radius),-1/0),n=Math.max(0,i-t-2*r);return{positions:e.map((t,i)=>o+(1===e.length?0:i/(e.length-1)-.5)*n),overlapping:!0,entryOffset:0}}n.push({...a,y:u})}return{positions:n.map(e=>e.y),overlapping:!1,entryOffset:Math.max(0,n.reduce((e,i)=>Math.min(e,i.y-i.radius-t),36))}}function yp(e){let{data:t,xAccessor:i,groupAccessor:r,radiusAccessor:n,pointRadius:a,seed:s,size:l,xExtent:c,collisionIterations:u,settle:d}=e,{rows:h}=o(t,"collision-swarm"),f=k(l),p=ze(s),g=[],m=[],y=/* @__PURE__ */new Map;function x(e){let t=y.get(e);return null==t&&(t=m.length,m.push(e),y.set(e,t)),t}h.forEach((e,t)=>{let o=$(M(e,t,i));if(null==o)return;let s=r?String(M(e,t,r)??"All"):"All",l=n?$(M(e,t,n)):null,c=_(null!=l&&l>0?l:a,2,18);x(s),g.push({datum:e,index:t,value:o,group:s,radius:c})});let b=c?$(c[0]):null,v=c?$(c[1]):null,w=g.reduce((e,t)=>Math.min(e,t.value),g.length?1/0:0),A=g.reduce((e,t)=>Math.max(e,t.value),g.length?-1/0:1),P=b??w,L=v??A;if(P===L&&(P-=.5,L+=.5),P>L){let e=L;L=P,P=e}let I=g.reduce((e,t)=>Math.max(e,t.radius),a),R=f.plot.x+I+8,T=f.plot.x+f.plot.width-I-8,C=gp().domain([P,L]).range([R,T]),N=Math.max(1,m.length),F=f.plot.height/N,D=Math.min(6,.05*F),E=e=>f.plot.y+((y.get(e)??0)+.5)*F,z=/* @__PURE__ */new Map,O=/* @__PURE__ */new Set,j=/* @__PURE__ */new Map;for(let e of m){let t=g.filter(t=>t.group===e),i=E(e),r=t.map(e=>({x:C(e.value),radius:e.radius})),o=mp(r,i-F/2+D,i+F/2-D,p);z.set(e,t.length),o.overlapping&&O.add(e),t.forEach((e,t)=>j.set(e.index,{x:r[t].x,y:o.positions[t],entryOffset:o.entryOffset}))}let W=g.map((e,t)=>{let i=j.get(e.index),r=i.x,o=i.y,n=O.has(e.group);return{id:String(e.datum.id??`collision-swarm-${t}`),x:r,y:o-(d?0:i.entryOffset),vx:0,vy:0,fixedPosition:{x:r},bodyCollisions:!n,mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:r,targetY:o,overlapping:n},springs:[{target:{type:"point",x:r,y:o},restLength:0,stiffness:34,damping:12}]}}),B=te({x:f.plot.x,y:f.plot.y,width:f.plot.width,height:f.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20});return{config:S(s,B,"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*I),collisionIterations:Math.max(1,Math.round(u??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:W,projectionRows:m.map(e=>({label:e,value:z.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[P,L],xRange:[R,T],groups:m.map(e=>({label:e,y:E(e),count:z.get(e)??0,overlapping:O.has(e)})),plot:f.plot}}}function xp(e){if(Array.isArray(e)&&e.length>=2){let t=$(e[0]),i=$(e[1]);return null!=t&&null!=i?{x:t,y:i}:null}if(e&&"object"==typeof e){let t=e,i=$(t.x),r=$(t.y);return null!=i&&null!=r?{x:i,y:r}:null}return null}function bp(e){return Array.isArray(e)?e.map(xp).filter(e=>null!=e):[]}function vp(e,t){return"normalized"===e||"pixels"===e?e:t.length>0&&t.every(e=>e.x>=0&&e.x<=1&&e.y>=0&&e.y<=1)?"normalized":"pixels"}function wp(e,t,i){return"normalized"===i?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:_(e.x,t.plot.x,t.plot.x+t.plot.width),y:_(e.y,t.plot.y,t.plot.y+t.plot.height)}}function kp(e){let t=0;for(let i=1;i<e.length;i+=1){let r=e[i].x-e[i-1].x,o=e[i].y-e[i-1].y;t+=Math.hypot(r,o)}return t}function Ap(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};let i=_(t,0,1)*kp(e),r=0;for(let t=1;t<e.length;t+=1){let o=e[t-1],n=e[t],a=Math.hypot(n.x-o.x,n.y-o.y);if(!(a<=0)){if(r+a>=i){let e=(i-r)/a;return{x:o.x+(n.x-o.x)*e,y:o.y+(n.y-o.y)*e}}r+=a}}return{...e[e.length-1]}}function Sp(e,t){let i=Ap(e,Math.max(0,t-.02)),r=Ap(e,Math.min(1,t+.02)),o=r.x-i.x,n=r.y-i.y,a=Math.hypot(o,n)||1;return{x:o/a,y:n/a}}function Mp(t){let{coordinateMode:r,flowSpeed:o,links:n,maxParticles:a,nodeIdAccessor:s,nodeXAccessor:l,nodeYAccessor:c,nodes:u,particleRadius:d,particleRate:h,pathAccessor:f,pathConstraint:p="path",reducedMotion:g,seed:m,size:y,sourceAccessor:x,targetAccessor:b,throughputAccessor:v}=t,w=k(y),A=ze(m),P=/* @__PURE__ */new Map,L=/* @__PURE__ */new Map,I=[];function R(e){if(e&&"object"==typeof e){let t=e;if("function"==typeof s){let e=s(t,0);if(null!=e)return String(e)}if("string"==typeof s&&null!=t[s])return String(t[s]);if(null!=t.id)return String(t.id)}return String(e??"unknown")}u.forEach((e,t)=>{let i=String(M(e,t,s)??e.id??t),r=$(M(e,t,l)),o=$(M(e,t,c));if(null!=r&&null!=o){let e={x:r,y:o};P.set(i,e),I.push(e)}L.set(i,String(e.label??e.name??i))});let T=[];n.forEach((e,t)=>{let i=R(M(e,t,x)),r=R(M(e,t,b)),o=Math.max(0,$(M(e,t,v))??0),n=bp(f?M(e,t,f):void 0),a=n.length?n:bp(e.path??e.points??e.route);a.forEach(e=>I.push(e)),T.push({id:String(e.id??`physical-flow-${i}-${r}-${t}`),link:e,index:t,source:i,target:r,throughput:o,rawPath:a})});let C=vp(r,I),N=/* @__PURE__ */new Map;for(let[e,t]of P)N.set(e,wp(t,w,C));let F=[];for(let e of T){let t=e.rawPath.map(e=>wp(e,w,C));if(t.length>=2)N.has(e.source)||N.set(e.source,t[0]),N.has(e.target)||N.set(e.target,t[t.length-1]);else{let i=N.get(e.source),r=N.get(e.target);i&&r&&(t=[i,r])}t.length<2||e.throughput<=0||(L.has(e.source)||L.set(e.source,e.source),L.has(e.target)||L.set(e.target,e.target),F.push({...e,path:t,packetCount:0}))}let D=e(h,.12),E=Math.max(1,Math.round(a)),z=F.map(e=>Math.max(1,Math.round(e.throughput*D))),O=z.reduce((e,t)=>e+t,0),j=O>E?E/O:1;F.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(z[t]*j))});let W=F.reduce((e,t)=>e+t.packetCount,0);for(;W>E;){let e=F.reduce((e,t,i)=>t.packetCount<=1?e:-1===e||t.packetCount>F[e].packetCount?i:e,-1);if(-1===e)break;F[e].packetCount-=1,W-=1}let B=/* @__PURE__ */new Map,Y=/* @__PURE__ */new Map,G=[],X=e(o,90),V=e(d,4);F.forEach((e,t)=>{B.set(e.target,(B.get(e.target)??0)+e.throughput),Y.set(e.source,(Y.get(e.source)??0)+e.throughput);let i=kp(e.path);for(let r=0;r<e.packetCount;r+=1){let o=(r+.5)/e.packetCount,n=g?o:_(.12+.84*o+.04*(A()-.5),.04,.98),a=g?n:Math.max(0,n-(.18+.12*A())),s=Ap(e.path,a),l=Ap(e.path,n),c=Sp(e.path,a),u={x:-c.y,y:c.x},d=(A()-.5)*V*1.5,h=`${e.id}-packet-${r}`;G.push({id:h,x:s.x+u.x*d,y:s.y+u.y*d,vx:g?0:c.x*X+10*(A()-.5),vy:g?0:c.y*X+10*(A()-.5),mass:.8,spawnAt:g?0:.04*t+r/32,shape:{type:"circle",radius:V},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:r,packetCount:e.packetCount,routeProgress:n,flowPath:e.path,flowPathLength:i,flowRouteId:e.id,flowSpeed:X,sourceLabel:L.get(e.source)??e.source,targetLabel:L.get(e.target)??e.target},springs:"none"!==p&&g?[{target:{type:"point",x:l.x,y:l.y},restLength:.7*V,stiffness:26,damping:4.25}]:void 0})}});let q=Math.max(18,5*V),H=Array.from(N,([e,t])=>({nodeId:e,label:L.get(e)??e,sensorId:`physical-flow-node-${i(e)}`,point:t})),U=H.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:q,height:q}})),Z=Object.fromEntries(H.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),Q=[...te({x:w.plot.x,y:w.plot.y,width:w.plot.width,height:w.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...U],K=S(m,Q,"PacketFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*V),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});K.bodyLimit=E,K.eviction="oldest",K.observation={...K.observation,sensors:Z};let J=Array.from(N,([e,t])=>({id:e,label:L.get(e)??e,x:t.x,y:t.y,sensorId:`physical-flow-node-${i(e)}`,incoming:B.get(e)??0,outgoing:Y.get(e)??0})),ee=F.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:L.get(e.source)??e.source,targetLabel:L.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:K,initialSpawns:G,projectionRows:J.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:C,particleCount:G.length,totalThroughput:F.reduce((e,t)=>e+t.throughput,0),plot:w.plot,nodes:J,links:ee}}}function $p(e,t=12){return"number"==typeof e?{x:e,y:0}:e&&"object"==typeof e?{x:Number.isFinite(e.x)?Number(e.x):t,y:Number.isFinite(e.y)?Number(e.y):0}:{x:t,y:0}}function _p(e,t){let i={id:`process-stage-${e.id}`,label:e.label??e.id,description:e.description,x:t.x,y:t.y,width:Math.max(12,.92*t.width),height:Math.max(40,.88*t.height),semanticItem:!1,attributes:{stageId:e.id}};if(e.absorb)return ye({...i,kind:e.kind??"sink",force:$p(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...i.attributes,primitive:"absorb"}});if(e.portal){let t=e.portal.force??e.force??{x:-40,y:0};return ge({...i,kind:e.kind??"force-field",force:$p(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:e.portal.targetStageId}})}if(e.capacity){let t=Math.max(.1,e.capacity.unitsPerSecond);return fe({...i,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:$p(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...i.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){let t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return de({...i,kind:e.kind??"membrane",pressure:t.pressure,occupancy:t.occupancy,baseDamping:t.baseDamping??e.damping??.1,dampingPerUnit:t.dampingPerUnit??.1,energyPerUnit:t.energyPerUnit??0,force:$p(e.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?ce({...i,kind:e.kind??"force-field",force:$p(e.force,14),damping:e.damping??.02,attributes:{...i.attributes,primitive:"routeSurface"}}):be({...i,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...i.attributes,primitive:"forceField"}})}function Pp(e){let t=e.stages;if(!t.length)throw new Error("buildProcessFlowPhysics requires at least one stage");let i=e.size,r=k(i),o=_(e.ballRadius??6,2,18),n=e.seed??1,a=ze(n),s=e.idAccessor,l=e.stageAccessor??"stage",c=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,f=e.groupCompletion??(c?"allAbsorbed":"none"),p=e.springStiffness??.28,g=e.springDamping??.72,m=!0===e.settle,y=t.map(e=>({id:e.id,label:e.label??e.id,description:e.description,share:e.share})),x=J({width:i[0],height:i[1],shape:"lane",padX:Math.max(28,r.plot.x),padY:Math.max(36,r.plot.y+8),stages:y,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((e,t)=>[e.id,t])),v=new Map(x.stages.map(e=>[e.id,e])),w=x.stages[0].id,A=x.stages[0],S=new Set(t.filter(e=>e.absorb).map(e=>e.id)),P=t.map(e=>{let t=v.get(e.id)??A;return _p(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});P.unshift(ce({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(x.left+x.right)/2,y:x.midY,width:x.right-x.left,height:x.bottomY-x.topY-12,force:8,damping:.012,semanticItem:!1}));let L=/* @__PURE__ */new Map;for(let e of x.stages)L.set(e.id,0);let I=[];e.data.forEach((e,t)=>{let i=String(s?M(e,t,s)??e.id??`process-flow-${t}`:e.id??`process-flow-${t}`),r=String(M(e,t,l)??w),n=b.has(r)?r:w;L.set(n,(L.get(n)??0)+1);let a=c?String(M(e,t,c)??""):void 0,f=a&&u?String(M(e,t,u)??a):a,p=d?$(M(e,t,d))??1:1,g=h?$(M(e,t,h)):null,m=_(null!=g&&g>0?g:o,2,18);I.push({datum:e,id:i,stageId:n,groupId:a||void 0,groupLabel:f||void 0,work:p,radius:m,index:t})});let R=/* @__PURE__ */new Map,T=/* @__PURE__ */new Map;for(let e of I){if(!e.groupId)continue;let t=R.get(e.groupId)??[];t.push(e.id),R.set(e.groupId,t),e.groupLabel&&T.set(e.groupId,e.groupLabel)}let C=_(e.groupAnchorAlong??.55,.15,.9),N=x.left+(x.right-x.left)*C,F=Array.from(R.keys()),D=F.map((e,i)=>{let r=R.get(e)??[],o=F.length<=1?x.midY:x.topY+28+i/Math.max(1,F.length-1)*(x.bottomY-x.topY-56);return we({id:e,label:T.get(e)??e,bodyIds:r,anchor:{x:N,y:o},x:N,y:o,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),E=I.filter(e=>S.has(e.stageId)).map(e=>e.id),z=oe(D,E),O=new Map(D.map(e=>[e.id,e])),j=I.map((e,t)=>{let i=v.get(e.stageId)??A,r=i.x+(a()-.5)*Math.min(24,.2*i.width),o=x.boundaryY(r,"top")+e.radius+10,n=x.boundaryY(r,"bottom")-e.radius-10,s=n<=o?x.midY:o+a()*Math.max(1,n-o),l=m?r:x.left+18+t%7*4,c=m?s:x.midY+(a()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:r,y:s},restLength:.45*e.radius,stiffness:p,damping:g}];if(e.groupId){let t=O.get(e.groupId);t?.anchor&&!S.has(e.stageId)&&u.push({target:{type:"point",x:t.anchor.x,y:t.anchor.y},restLength:t.tether?.restLength??22,stiffness:t.tether?.stiffness??.05,damping:.8})}return{id:e.id,x:l,y:c,vx:m?0:40+40*a(),vy:m?0:20*(a()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:m?0:.03*t,springs:u,datum:{...e.datum,id:e.id,stage:e.stageId,groupId:e.groupId,groupLabel:e.groupLabel,work:e.work,__processFlow:!0}}}),W={kernel:{seed:n,gravity:{x:e.gravityX??22,y:e.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},B=x.stages.map(e=>({label:e.label??e.id,value:L.get(e.id)??0})),Y=t.map(e=>{let t=v.get(e.id)??A;return{id:e.id,label:e.label??e.id,x:t.x,width:t.width,count:L.get(e.id)??0,capacity:e.capacity?.unitsPerSecond,absorb:!0===e.absorb,portalTarget:e.portal?.targetStageId}});return{config:W,initialSpawns:j,initialSpawnPacing:m?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:B,metadata:{kind:"process-flow",plot:r.plot,volume:x,stages:Y,groups:D,groupCompletion:z,regionEffects:P}}}import{scaleLinear as Lp}from"d3-scale";function Ip(e,t,i){return Oi(e,t,i)}function Rp(e,t){let i=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>i&&Xi(i,e)||"#4e79a7":t=>{if(i){let e=Xi(i,t);if(e)return e}let r=0;for(let e=0;e<t.length;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}function Tp(e,t,i){let r=e?.observation;return{...e,observation:{...r,chartId:t??r?.chartId??"physics-custom",chartType:r?.chartType??"PhysicsCustomChart",onObservation:i??r?.onObservation}}}function Cp(e,t){let i=t.config??{},r=(t.sensors??[]).map(e=>({...e,sensor:!0})),o=[...t.colliders??[],...r],n=[...e.colliders??[],...i.colliders??[],...o];return{...e,...i,observation:{...e.observation,...i.observation},...n.length>0&&{colliders:n}}}function Np(e,t){if(!t?.length)return e;let i=/* @__PURE__ */new Map;for(let e of t){let{bodyId:t,...r}=e,o=i.get(t)??[];o.push(r),i.set(t,o)}return e.map(e=>{let t=i.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}function Fp(e){let t=Tp(e.config,e.chartId,e.onObservation),i=Ip(e.colorScheme,e.themeCategorical,bi),r=k(e.size),o={data:e.data,scales:{x:Lp().domain(e.xExtent??[0,1]).range([r.plot.x,r.plot.x+r.plot.width]),y:Lp().domain(e.yExtent??[0,1]).range([r.plot.y+r.plot.height,r.plot.y])},dimensions:r,theme:{semantic:e.semantic,categorical:[...i]},resolveColor:Rp(i,e.colorScheme),config:e.layoutConfig??{},world:new re(t)},n=e.skipLayout?{}:e.layout(o)??{},a=Np([...n.initialSpawns??n.bodies??[]],n.constraints);return{config:Cp(t,n),context:o,initialSpawnPacing:n.initialSpawnPacing,initialSpawns:a,result:n}}function Dp(e){let t=Bp(e);return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:t.left,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:e.width-t.rightInset,y2:t.top,thickness:t.thickness}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:e.floorY,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-t.rightInset,y1:t.top,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}}]}function Ep(e,t,i,r){return i?"function"==typeof i?i(e,t):e[i]??r:r}function zp(e){return`gauntlet:${e}:core`}function Op(e,t){return`gauntlet:${e}:positive:${t}`}function jp(e,t,i){return`gauntlet:${e}:negative:${t}:${i}`}Bt.width,Bt.height;var Wp={left:28,top:76,rightInset:30,thickness:8};function Bp(e){let t=e.height??e.floorY+36;if(!(e.width<220||t<160))return Wp;let i=Math.max(1,Math.min(e.width,t)),r=Math.max(2,.04*e.width);return{left:r,top:Math.max(2,.08*t),rightInset:r,thickness:Math.max(1,Math.min(4,.04*i))}}function Yp(e){let t=e.height??e.floorY+36;return Math.max(.12,Math.min(1,e.width/500,t/260))}function Gp(e,t,i,r){let o=Bp(r),n=Math.max(2,i+2),a=o.left+o.thickness/2+n,s=r.width-o.rightInset-o.thickness/2-n,l=o.top+o.thickness/2+n,c=r.floorY-n,u=(e,t,i)=>t<=i?Math.max(t,Math.min(i,e)):(t+i)/2;return{x:u(e,a,s),y:u(t,l,c)}}function Xp(e,t,i){let[r,o]=e,n=r<220||o<160,a=Math.round(.48*o),s=n?o-Math.max(3,Math.min(12,.1*o)):o-36,l=(t??[]).filter(e=>!1!==e.enabled),c=Math.max(1,l.length),u=.22*r,d=c<=1?0:(.78*r-u)/(c-1),h=n?Math.max(Math.round(.12*r),.08*r+6):Math.max(Math.round(.14*r),110);return{crashY:s-(n?Math.min(i,Math.max(3,.22*o)):i),floorY:s,gates:l.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(u+t*d),width:e.width??Math.max(n?8:54,Math.round(.07*r))})),graveyardX:Math.round(r*(n?.72:.84)),graveyardY:s-4,height:o,routeY:a,socketX:Math.round(r*(n?.82:.92)),startX:h,width:r}}function Vp(e){return{graveyardX:e.graveyardX,graveyardY:e.graveyardY,routeY:e.routeY,socketX:e.socketX,socketY:e.routeY-4,startX:e.startX,startY:e.routeY}}function qp(e,t,i,r){let o=Vp(i),n=r?.(e,t,i)??{};return{...o,...n,startY:n.startY??n.routeY??o.startY,socketY:n.socketY??n.routeY??o.socketY,graveyardY:n.graveyardY??o.graveyardY}}function Hp(e,t,i=1){let r=[...e].sort((e,t)=>e.localeCompare(t)),o=Math.max(0,r.indexOf(t)),n=r.length>1?o/(r.length-1):.5;return{angle:.82*-Math.PI+n*Math.PI*.64,index:o,radius:(48+o%2*6)*i}}function Up(e,t,i){let r=e.activePositiveIds.reduce((e,i)=>e+(t.get(i)?.value??1),0),o=e.missingPositiveIds.length+e.poppedPositiveIds.length,n=e.negativeIds.reduce((e,t)=>e+(i.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*r-8*n-1.2*e.delay-5*o))}function Zp(e,t,i,r,o){let n=String(Ep(e,t,i.idAccessor,null!=e.id?String(e.id):`project-${t}`)),a=r.map(e=>e.id),s=[...Ep(e,t,i.positiveAccessor,a)],l=[...Ep(e,t,i.negativeAccessor,[])].filter(e=>o.has(e));return{id:n,activePositiveIds:s,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Ep(e,t,i.metricsAccessor,{})},missingPositiveIds:a.filter(e=>!s.includes(e)),negativeIds:l,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Ep(e,t,i.startTimeAccessor,0))||0),stage:"project filed",viability:Ep(e,t,i.initialViability,100)}}function Qp(e,t,i,r,o,n,a){let s=Yp(i),l=Math.max(3,28*s),c=r.startX,u=r.startY+(r.startY===i.routeY?38*t*s:0),d=a?.(e,t,i,r)??{},h=d.x??c,f=d.y??u,p={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},g=[{...d,id:zp(e.id),x:h,y:f,vx:d.vx??42,vy:d.vy??0,mass:d.mass??7,bodyCollisions:d.bodyCollisions??!0,shape:d.shape??{type:"circle",radius:l},spawnAt:d.spawnAt??e.startedAt,datum:p}],m=Gp(h,f,d.shape&&"radius"in d.shape&&Number(d.shape.radius)||l,i);g[0].x=m.x,g[0].y=m.y;for(let t of e.activePositiveIds){let r=o.get(t);if(!r)continue;let n=Hp(e.activePositiveIds,t,s),a=r.radius??Math.max(2,10*s),l=Gp(m.x+Math.cos(n.angle)*n.radius,m.y+Math.sin(n.angle)*n.radius,a,i);g.push({id:Op(e.id,t),x:l.x,y:l.y,vx:18*Math.cos(n.angle),vy:18*Math.sin(n.angle),mass:r.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:d.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:e.id,property:r,sourceDatum:e.datum},springs:!1===r.spring?[]:[{target:{type:"body",bodyId:zp(e.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+n.index%2*4)*s),...r.spring??{}}]})}return e.negativeIds.forEach((t,r)=>{let o=n.get(t);o&&g.push(Jp(e,o,r,m.x,m.y,i,d.spawnAt??e.startedAt))}),g}function Kp(e){let t=Xp(e.size??[900,520],e.gates,e.crashOffset??30),i=e.positiveProperties??[],r=new Map(i.map(e=>[e.id,e])),o=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),n={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},a=(e.data??[]).map((t,a)=>{let s=Zp(t,a,n,i,o);return{...s,viability:e.viability?.(s,{negativeProperties:o,positiveProperties:r})??Up(s,r,o)}}),s=a.flatMap((i,n)=>{let a=qp(i,n,t,e.projectPlacement);return Qp(i,n,t,a,r,o,e.coreBody)});return{layout:t,states:a,initialSpawns:s,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:Dp(t)}}}function Jp(e,t,i,r,o,n,a){let s=Yp(n),l=t.radius??Math.max(2,7.2*s),c=Gp(r+(i%4*12-12)*s,o+(54+12*Math.floor(i/4))*s,l,n);return{id:jp(e.id,t.id,i),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:l},spawnAt:a,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:zp(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+i%4*3)*s),...t.spring??{}}]}}function eg(e=[]){let t=/* @__PURE__ */Object.create(null);for(let[i,r]of e)t[i]=r;return t}function tg(...e){let t=eg();for(let i of e)for(let[e,r]of Object.entries(i??{}))t[e]=r;return t}function ig(e){return tg(e)}function rg(e){return e.map(e=>({...e,sourceIds:e.sourceIds?[...e.sourceIds]:void 0,productIds:e.productIds?[...e.productIds]:void 0,relationIds:e.relationIds?[...e.relationIds]:void 0,outletIds:e.outletIds?[...e.outletIds]:void 0}))}function og(e){let t=eg(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:ig(t.initialMetrics),metrics:ig(t.metrics),productIds:[...t.productIds],history:rg(t.history)}])),i=eg(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:ig(t.metrics),sourceIds:[...t.sourceIds],history:rg(t.history)}])),r=eg(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?ig(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:i,relations:r,input:{amount:e.input.amount,metrics:ig(e.input.metrics)},metrics:ig(e.metrics),loss:{amount:e.loss.amount,metrics:ig(e.loss.metrics)},history:rg(e.history)}}var ng=1e-9;function ag(e,t){return e<t?-1:e>t?1:0}function sg(e,t,i,r,o){return{severity:e,code:t,message:i,path:r,ids:o?[...o]:void 0}}function lg(e){let t=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(let r of e)t.has(r)&&i.add(r),t.add(r);return[...i].sort(ag)}function cg(e,t){return e?Object.entries(e).flatMap(([e,i])=>Number.isFinite(i)?[]:[sg("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function ug(e,t){for(let[i,r]of Object.entries(t))e[i]=Number(e[i]??0)+r}function dg(e){let t=eg();for(let i of e)ug(t,i.metrics);return t}function hg(e,t,i="selector"){let r=[],o=Object.values(e.components),n=new Set(o.map(e=>e.id)),a=(t.ids??[]).filter(e=>!n.has(e));if(a.length&&r.push(sg("error","unknown-component",`Selector references unknown component id${1===a.length?"":"s"}: ${a.join(", ")}.`,`${i}.ids`,a)),void 0!==t.count&&(!Number.isInteger(t.count)||t.count<0)&&r.push(sg("error","invalid-selector-count","Selector count must be a non-negative integer.",`${i}.count`)),r.some(e=>"error"===e.severity))return{ids:[],diagnostics:r};let s=t.ids?new Set(t.ids):null,l=t.categories?new Set(t.categories):null,c=t.statuses?new Set(t.statuses):null,u=t.outletIds?new Set(t.outletIds):null,d=o.filter(e=>!s||s.has(e.id)).filter(e=>!l||l.has(e.category)).filter(e=>!c||c.has(e.status)).filter(e=>!u||void 0!==e.outletId&&u.has(e.outletId)).map(e=>e.id).sort(ag);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||r.push(sg("warning","empty-selector","Selector matched no source components.",i)),{ids:d,diagnostics:r}}function fg(e,t,i={}){return{eventId:e.event.id,effectType:t.type,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,label:e.event.label,summary:e.event.summary,...i}}function pg(e,t){let i={...t,eventId:e.event.id};e.materializations.push(i),e.observations.push({...i,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt})}function gg(e,t,i){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(sg("error","unknown-outlet",`Unknown outlet "${t}".`,i,[t])),1))}function mg(e,t,i){let r=lg(t);t.length||e.diagnostics.push(sg("error","empty-source-list","A product requires at least one source component.",i)),r.length&&e.diagnostics.push(sg("error","duplicate-source",`Source ids may appear only once: ${r.join(", ")}.`,i,r));let o=t.filter(t=>!e.state.components[t]);o.length&&e.diagnostics.push(sg("error","unknown-component",`Unknown source component id${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o));let n=t.filter(t=>(e.state.components[t]?.productIds.length??0)>0);n.length&&e.diagnostics.push(sg("error","source-already-assigned",`Source component${1===n.length?" is":"s are"} already assigned: ${n.join(", ")}.`,i,n));let a=t.filter(t=>"consumed"===e.state.components[t]?.status&&!n.includes(t));return a.length&&e.diagnostics.push(sg("error","source-unavailable",`Consumed source component${1===a.length?" is":"s are"} unavailable: ${a.join(", ")}.`,i,a)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function yg(e,t,i){let r=lg(t),o=t.filter(t=>!e.state.components[t]);return t.length<2&&e.diagnostics.push(sg("error","insufficient-relation-sources","A relation requires at least two source components.",i)),r.length&&e.diagnostics.push(sg("error","duplicate-source",`Relation source ids must be unique: ${r.join(", ")}.`,i,r)),o.length&&e.diagnostics.push(sg("error","unknown-component",`Relation references unknown source component${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function xg(e,t,i,r,o){let n=r?.amount??0;(!Number.isFinite(n)||n<0||n>t+ng)&&e.diagnostics.push(sg("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",`${o}.amount`)),e.diagnostics.push(...cg(r?.metrics,`${o}.metrics`));for(let[t,n]of Object.entries(r?.metrics??{}))(n<0||n>Number(i[t]??0)+ng)&&e.diagnostics.push(sg("error","invalid-metric-loss",`Metric loss "${t}" must be non-negative and no greater than its sources.`,`${o}.metrics.${t}`));return!e.diagnostics.some(e=>"error"===e.severity)}function bg(e,t,i,r){if(!t?.length)return[];let o=lg(t),n=t.filter(t=>!e.state.relations[t]),a=t.filter(t=>"resolved"===e.state.relations[t]?.status),s=new Set(i),l=t.filter(t=>(e.state.relations[t]?.sourceIds??[]).some(e=>!s.has(e)));return o.length&&e.diagnostics.push(sg("error","duplicate-relation","Basis relations must be unique.",r,o)),n.length&&e.diagnostics.push(sg("error","unknown-relation",`Unknown basis relation: ${n.join(", ")}.`,r,n)),a.length&&e.diagnostics.push(sg("error","resolved-relation",`Basis relation is already resolved: ${a.join(", ")}.`,r,a)),l.length&&e.diagnostics.push(sg("error","relation-source-mismatch",`Basis relation includes a source outside this product: ${l.join(", ")}.`,r,l)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.relations[t])}function vg(e,t){if(t.length){for(let i of t)i.status="resolved",i.resolution="combined",i.resolvedByEventId=e.event.id,i.resolvedAt=e.context.appliedAt;pg(e,{type:"resolve-relation",relationIds:t.map(e=>e.id)})}}function wg(e,t,i){e.state.loss.amount+=i?.amount??0;for(let[r,o]of Object.entries(i?.metrics??{}))t[r]=Number(t[r]??0)-o,e.state.loss.metrics[r]=Number(e.state.loss.metrics[r]??0)+o}function kg(e,t,i,r,o,n,a){let s=n&&void 0!==e.amount?e.amount:i;return{id:e.id,label:e.label??e.id,description:e.description,category:e.category??"product",color:e.color,order:e.order,declaredAmount:e.amount,amount:s,metrics:n&&e.metrics?tg(r,e.metrics):ig(r),status:n?"complete":"forming",sourceIds:[...t],outletId:n?e.outletId??(o.outletIds.has("product")?"product":void 0):void 0,createdByEventId:o.event.id,createdAt:o.context.appliedAt,completedByEventId:n?o.event.id:void 0,completedAt:n?o.context.appliedAt:void 0,history:[a]}}function Ag(e,t,i,r){void 0!==t.amount&&Math.abs(t.amount-i)>ng&&e.diagnostics.push(sg("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${i}.`,r,[t.id]))}function Sg(e,t,i,r,o,n){let a=e.productDefinitions.get(t.id),s=i??a?.outletId??(e.outletIds.has("product")?"product":void 0);if(!gg(e,s,`${n}.outletId`))return;if("complete"===t.status)return void e.diagnostics.push(sg("error","product-already-complete",`Product "${t.id}" is already complete.`,n,[t.id]));a&&(Ag(e,a,t.amount,`${n}.productId`),void 0!==a.amount&&(t.amount=a.amount),a.metrics&&(t.metrics=tg(t.metrics,a.metrics))),t.status="complete",t.outletId=s,t.reason=r,t.completedByEventId=e.event.id,t.completedAt=e.context.appliedAt;let l=fg(e,o,{sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:s?[s]:void 0});t.history.push(l),e.state.history.push(l),pg(e,{type:"complete-product",sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:s?[s]:void 0})}function Mg(e,t,i){let r=`events.${e.event.id}.effects.${i}`,o=e.state;if("set-state"===t.type){["queued","active","transformed","retained","ejected","failed","recovered"].includes(t.state)||e.diagnostics.push(sg("error","invalid-component-state",`set-state cannot assign "${String(t.state)}".`,`${r}.state`)),e.diagnostics.push(...cg(t.metricsDelta,`${r}.metricsDelta`)),gg(e,t.outletId,`${r}.outletId`);let i=hg(o,t.select,`${r}.select`);e.diagnostics.push(...i.diagnostics);let n=i.ids.filter(e=>o.components[e].productIds.length);if(n.length&&e.diagnostics.push(sg("error","source-already-assigned",`Assigned source components cannot be retargeted: ${n.join(", ")}.`,`${r}.select`,n)),e.diagnostics.some(e=>"error"===e.severity))return;let a=fg(e,t,{sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0});for(let e of i.ids){let i=o.components[e];i.status=t.state,i.outletId=t.outletId,i.reason=t.reason,t.metricsDelta&&ug(i.metrics,t.metricsDelta),i.history.push(a)}return o.history.push(a),void(i.ids.length&&pg(e,{type:"retarget-component",sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0}))}if("set-relation"===t.type){let{relation:i}=t;(!i.id||o.relations[i.id])&&e.diagnostics.push(sg("error","duplicate-relation",`Relation id "${i.id}" is missing or already active.`,`${r}.relation.id`,[i.id]));let n=yg(e,i.sourceIds,`${r}.relation.sourceIds`);if(e.diagnostics.push(...cg(i.metrics,`${r}.relation.metrics`)),!n||e.diagnostics.some(e=>"error"===e.severity))return;o.relations[i.id]={...i,sourceIds:[...i.sourceIds],metrics:i.metrics?ig(i.metrics):void 0,status:"active",createdByEventId:e.event.id,createdAt:e.context.appliedAt};let a=fg(e,t,{sourceIds:[...i.sourceIds],relationIds:[i.id]});return o.history.push(a),void pg(e,{type:"activate-relation",sourceIds:[...i.sourceIds],relationIds:[i.id]})}if("resolve-relation"===t.type){let i=lg(t.relationIds),n=t.relationIds.filter(e=>!o.relations[e]),a=t.relationIds.filter(e=>"resolved"===o.relations[e]?.status);if(i.length&&e.diagnostics.push(sg("error","duplicate-relation","Relation ids must be unique.",`${r}.relationIds`,i)),n.length&&e.diagnostics.push(sg("error","unknown-relation",`Unknown relation: ${n.join(", ")}.`,`${r}.relationIds`,n)),a.length&&e.diagnostics.push(sg("error","resolved-relation",`Relation is already resolved: ${a.join(", ")}.`,`${r}.relationIds`,a)),e.diagnostics.some(e=>"error"===e.severity))return;for(let i of t.relationIds){let r=o.relations[i];r.status="resolved",r.resolution=t.resolution,r.resolvedByEventId=e.event.id,r.resolvedAt=e.context.appliedAt,r.reason=t.reason}let s=fg(e,t,{relationIds:[...t.relationIds]});return o.history.push(s),void pg(e,{type:"resolve-relation",relationIds:[...t.relationIds]})}if("combine"===t.type||"contribute"===t.type){let i=e.productDefinitions.get(t.productId);i||e.diagnostics.push(sg("error","unknown-product",`Product "${t.productId}" has no declared mold.`,`${r}.productId`,[t.productId]));let n=o.products[t.productId];"combine"===t.type&&n&&e.diagnostics.push(sg("error","duplicate-product",`Product "${t.productId}" has already been formed.`,`${r}.productId`,[t.productId])),"contribute"===t.type&&(!n||"forming"!==n.status)&&e.diagnostics.push(sg("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,`${r}.productId`,[t.productId]));let a=mg(e,t.sourceIds,`${r}.sourceIds`),s="contribute"===t.type&&n?[...n.sourceIds,...t.sourceIds]:t.sourceIds,l=bg(e,t.basisRelationIds,s,`${r}.basisRelationIds`);if(!a||!l||!i||e.diagnostics.some(e=>"error"===e.severity))return;let c=a.reduce((e,t)=>e+t.amount,0),u=dg(a);if(!xg(e,c,u,t.loss,`${r}.loss`))return;let d=c-(t.loss?.amount??0);wg(e,u,t.loss);let h,f="combine"===t.type&&!1!==t.complete,p=fg(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});if("combine"===t.type){if(f&&Ag(e,i,d,`${r}.productId`),h=kg(i,t.sourceIds,d,u,e,f,p),f&&!gg(e,h.outletId,`${r}.productId`))return;o.products[t.productId]=h}else h=n,h.sourceIds.push(...t.sourceIds),h.amount+=d,ug(h.metrics,u),h.history.push(p);for(let e of a)e.productIds=[t.productId],e.status="consumed",e.outletId=void 0,e.history.push(p);return o.history.push(p),vg(e,l),pg(e,{type:"combine"===t.type?"form-product":"update-product",sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0,outletIds:h.outletId?[h.outletId]:void 0}),void(f&&pg(e,{type:"complete-product",sourceIds:[...h.sourceIds],productIds:[h.id],outletIds:h.outletId?[h.outletId]:void 0}))}if("complete-product"===t.type){let i=o.products[t.productId];return i?void Sg(e,i,t.outletId,t.reason,t,r):void e.diagnostics.push(sg("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,`${r}.productId`,[t.productId]))}if("split"===t.type){let i=mg(e,[t.sourceId],`${r}.sourceId`);t.products.length||e.diagnostics.push(sg("error","empty-split","A split requires at least one product allocation.",`${r}.products`));let n=t.products.map(e=>e.productId),a=lg(n);a.length&&e.diagnostics.push(sg("error","duplicate-product","Split product ids must be unique.",`${r}.products`,a));let s=n.map(t=>e.productDefinitions.get(t)),l=n.filter((e,t)=>!s[t]),c=n.filter(e=>o.products[e]);l.length&&e.diagnostics.push(sg("error","unknown-product",`Split references undeclared product molds: ${l.join(", ")}.`,`${r}.products`,l)),c.length&&e.diagnostics.push(sg("error","duplicate-product",`Split products already exist: ${c.join(", ")}.`,`${r}.products`,c));for(let[i,o]of t.products.entries())void 0!==o.amount&&(!Number.isFinite(o.amount)||o.amount<0)&&e.diagnostics.push(sg("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${r}.products.${i}.amount`)),e.diagnostics.push(...cg(o.metrics,`${r}.products.${i}.metrics`));if(!i?.length||e.diagnostics.some(e=>"error"===e.severity))return;let u=i[0];if(!xg(e,u.amount,u.metrics,t.loss,`${r}.loss`))return;let d=u.amount-(t.loss?.amount??0),h=t.products.map((e,t)=>e.amount??s[t]?.amount),f=h.filter(e=>void 0!==e).length;if(0!==f&&f!==h.length)return void e.diagnostics.push(sg("error","partial-split-allocation","Either every split product must declare an amount or none may do so.",`${r}.products`));let p=f?h:t.products.map(()=>d/t.products.length),g=p.reduce((e,t)=>e+t,0);if(Math.abs(g-d)>ng)return void e.diagnostics.push(sg("error","split-amount-mismatch",`Split allocations total ${g}, but ${d} remains after loss.`,`${r}.products`));let m=ig(u.metrics);for(let[e,i]of Object.entries(t.loss?.metrics??{}))m[e]=Number(m[e]??0)-i;let y=fg(e,t,{sourceIds:[u.id],productIds:n});if(t.products.forEach((i,n)=>{let a=s[n],l=d>ng?p[n]/d:1/t.products.length,c=eg(Object.entries(m).map(([e,t])=>[e,t*l])),h=i.metrics??a.metrics??c,f=kg({...a,amount:p[n],metrics:h},[u.id],p[n],ig(h),e,!0,y);gg(e,f.outletId,`${r}.products.${n}.productId`)&&(o.products[f.id]=f)}),e.diagnostics.some(e=>"error"===e.severity))return;u.productIds=n,u.status="consumed",u.outletId=void 0,u.history.push(y),o.loss.amount+=t.loss?.amount??0;for(let[e,i]of Object.entries(t.loss?.metrics??{}))o.loss.metrics[e]=Number(o.loss.metrics[e]??0)+i;o.history.push(y),pg(e,{type:"split-source",sourceIds:[u.id],productIds:n});for(let t of n)pg(e,{type:"complete-product",sourceIds:[u.id],productIds:[t],outletIds:o.products[t].outletId?[o.products[t].outletId]:void 0});return}if("eject"===t.type){gg(e,t.outletId,`${r}.outletId`);let i=hg(o,t.select,`${r}.select`);e.diagnostics.push(...i.diagnostics);let n=i.ids.filter(e=>o.components[e].productIds.length);if(n.length&&e.diagnostics.push(sg("error","source-already-assigned",`Assigned source components cannot be ejected: ${n.join(", ")}.`,`${r}.select`,n)),e.diagnostics.some(e=>"error"===e.severity))return;let a=fg(e,t,{sourceIds:i.ids,outletIds:[t.outletId]});for(let e of i.ids){let i=o.components[e];i.status=t.state??"ejected",i.outletId=t.outletId,i.reason=t.reason,i.history.push(a)}return o.history.push(a),void(i.ids.length&&pg(e,{type:"retarget-component",sourceIds:i.ids,outletIds:[t.outletId]}))}if("set-metric"===t.type){if(e.diagnostics.push(...cg(t.metricsDelta,`${r}.metricsDelta`)),e.diagnostics.some(e=>"error"===e.severity))return;let i,n;if("run"===t.target)ug(o.metrics,t.metricsDelta);else if("components"in t.target){let n=hg(o,t.target.components,`${r}.target.components`);if(e.diagnostics.push(...n.diagnostics),e.diagnostics.some(e=>"error"===e.severity))return;i=n.ids;for(let e of n.ids)ug(o.components[e].metrics,t.metricsDelta)}else{n=[...t.target.productIds];let i=lg(n),a=n.filter(e=>!o.products[e]);if(i.length&&e.diagnostics.push(sg("error","duplicate-product","Metric target product ids must be unique.",`${r}.target.productIds`,i)),a.length&&e.diagnostics.push(sg("error","unknown-product-state",`Metric target product has not formed: ${a.join(", ")}.`,`${r}.target.productIds`,a)),e.diagnostics.some(e=>"error"===e.severity))return;for(let e of n)ug(o.products[e].metrics,t.metricsDelta)}return void o.history.push(fg(e,t,{sourceIds:i,productIds:n}))}t.outcome.trim()?(o.outcome=t.outcome,o.summary=t.summary,o.history.push(fg(e,t)),e.observations.push({type:"crucible-outcome",eventId:e.event.id,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,outcome:t.outcome})):e.diagnostics.push(sg("error","invalid-outcome","Outcome must be a non-empty string.",`${r}.outcome`))}function $g(e,t,i){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[sg("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,`events.${t.id}`,[t.id])]};let r=og(e),o={state:r,event:t,context:i,productDefinitions:new Map(i.products.map(e=>[e.id,e])),outletIds:new Set(i.outlets.map(e=>e.id)),diagnostics:[],materializations:[],observations:[]};for(let[i,r]of t.effects.entries())if(Mg(o,r,i),o.diagnostics.some(e=>"error"===e.severity))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:o.diagnostics};return r.elapsed=Math.max(r.elapsed,i.appliedAt),r.phaseId=i.phaseId,r.eventsApplied.push(t.id),o.observations.unshift({type:"crucible-event",eventId:t.id,phaseId:i.phaseId,authoredAt:i.authoredAt,appliedAt:i.appliedAt}),{applied:!0,state:r,materializations:o.materializations,observations:o.observations,diagnostics:o.diagnostics}}function _g(e,t){return"product"===t?"product"===e.kind?e.id:"unassigned":"outlet"===t?e.outletId??"unassigned":"category"===t?e.category:e.status}function Pg(e,t={}){let i=t.groupBy??"outlet",r=/* @__PURE__ */new Map,o=e=>{let t=_g({...e,status:e.status??"active"},i),o=r.get(t);if(o)return o.count+=1,o.amount+=e.amount,void ug(o.metrics,e.metrics);r.set(t,{key:t,label:"product"===i&&"product"===e.kind?e.label:t,count:1,amount:e.amount,metrics:ig(e.metrics),status:"status"===i?e.status:void 0,outletId:"outlet"===i?e.outletId:void 0,category:"category"===i?e.category:void 0,productId:"product"===i&&"product"===e.kind?e.id:void 0})};for(let t of Object.values(e.components))t.productIds.length||"consumed"===t.status||o({kind:"component",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});for(let t of Object.values(e.products))o({kind:"product",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});let n=new Map((t.order??[]).map((e,t)=>[e,t]));return[...r.values()].sort((e,t)=>(n.get(e.key)??Number.MAX_SAFE_INTEGER)-(n.get(t.key)??Number.MAX_SAFE_INTEGER)||ag(e.key,t.key))}var Lg=Yt.width,Ig=Yt.height,Rg=[Lg,Ig],Tg=[{id:"product",label:"Products",side:"bottom",order:0},{id:"retained",label:"Retained",side:"bottom",order:1},{id:"residue",label:"Residue",side:"left",order:2},{id:"failed",label:"Failed",side:"right",order:3},{id:"recovered",label:"Recovered",side:"right",order:4}],Cg=/* @__PURE__ */new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),Ng=1e-9;function Fg(e,t){return e<t?-1:e>t?1:0}function Dg(e,t,i,r,o){return{severity:e,code:t,message:i,path:r,ids:o?[...o]:void 0}}function Eg(e){let t=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(let r of e)t.has(r)&&i.add(r),t.add(r);return[...i].sort(Fg)}function zg(e){let t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Og(e,t,i,r,o,n){if(!i)return r;try{return("function"==typeof i?i(e,t):e[i])??r}catch(e){return o.push(Dg("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:String(e)}.`,n)),r}}function jg(e,t,i){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push(Dg("error","invalid-metrics","Metrics must be a numeric object.",i)),eg();let r=eg();for(let[o,n]of Object.entries(e)){let e=zg(n);null!=e?r[o]=e:t.push(Dg("error","invalid-metric",`Metric "${o}" must be finite.`,`${i}.${o}`))}return r}function Wg(e,t){for(let[i,r]of Object.entries(t))e[i]=Number(e[i]??0)+r}function Bg(e){let t=[],i=eg(),r=[],o=0,n=eg();e.data.forEach((a,s)=>{let l=String(a.id??`component-${s}`),c=Og(a,s,e.idAccessor,l,t,`data.${s}.id`),u=String(c??l).trim();if(!u)return void t.push(Dg("error","invalid-component-id","Component ids may not be empty.",`data.${s}.id`));r.push(u);let d=zg(Og(a,s,e.amountAccessor,1,t,`data.${s}.amount`)),h=null!=d&&d>=0?d:0;(null==d||d<0)&&t.push(Dg("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${s}.amount`,[u]));let f=jg(Og(a,s,e.metricsAccessor,{},t,`data.${s}.metrics`),t,`data.${s}.metrics`),p=Og(a,s,e.initialStateAccessor,"active",t,`data.${s}.status`),g=Cg.has(p)?p:"active";Cg.has(p)||t.push(Dg("error","invalid-component-status",`Unknown component status "${String(p)}".`,`data.${s}.status`,[u]));let m=String(Og(a,s,e.labelAccessor,String(a.label??a.name??u),t,`data.${s}.label`)),y=String(Og(a,s,e.categoryAccessor,"component",t,`data.${s}.category`));Object.hasOwn(i,u)||(i[u]={id:u,label:m,category:y,datum:a,status:g,initialAmount:h,amount:h,initialMetrics:tg(f),metrics:tg(f),productIds:[],history:[]},o+=h,Wg(n,f))});let a=Eg(r);a.length&&t.push(Dg("error","duplicate-component-id",`Component ids must be unique: ${a.join(", ")}.`,"data",a));let s=jg(e.metrics??{},t,"metrics");return{state:{elapsed:0,phaseElapsed:0,phaseId:e.phases[0]?.id??"",phaseIndex:e.phases.length?0:-1,playing:!1,complete:0===e.phases.length,outcome:"in_process",eventsApplied:[],components:i,products:eg(),relations:eg(),input:{amount:o,metrics:n},metrics:s,loss:{amount:0,metrics:eg()},history:[]},diagnostics:t}}function Yg(e){let t=[];e.length||t.push(Dg("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));let i=Eg(e.map(e=>e.id));i.length&&t.push(Dg("error","duplicate-phase-id",`Phase ids must be unique: ${i.join(", ")}.`,"phases",i));let r=0;return{phases:e.map((e,i)=>{let o=zg(e.duration),n=null!=o&&o>0?o:0;e.id.trim()||t.push(Dg("error","invalid-phase-id","Phase ids may not be empty.",`phases.${i}.id`)),(null==o||o<=0)&&t.push(Dg("error","invalid-phase-duration","Phase duration must be finite and greater than zero.",`phases.${i}.duration`,[e.id])),void 0!==e.intensity&&!Number.isFinite(e.intensity)&&t.push(Dg("error","invalid-phase-intensity","Phase intensity must be finite.",`phases.${i}.intensity`,[e.id]));let a={...e,duration:n,intensity:void 0===e.intensity?.5:Number.isFinite(e.intensity)?Math.max(0,Math.min(1,e.intensity)):.5,motion:e.motion??"hold",index:i,start:r,end:r+n};return r=a.end,a}),diagnostics:t}}function Gg(e,t,i){let r=e.find(e=>Math.abs(e.start-i)<=Ng);if(r)return{phase:r,boundaryRank:1};let o=e.find(e=>i>=e.start&&i<e.end);return o?{phase:o,boundaryRank:0}:Math.abs(i-t)<=Ng&&e.length?{phase:e[e.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}function Xg(e,t,i){let r=[],o=Eg(e.map(e=>e.id));o.length&&r.push(Dg("error","duplicate-event-id",`Event ids must be unique: ${o.join(", ")}.`,"events",o));let n=[];return e.forEach((e,o)=>{let a,s,l;if(e.id.trim()||r.push(Dg("error","invalid-event-id","Event ids may not be empty.",`events.${o}.id`)),"time"in e.at&&void 0!==e.at.time){let n=zg(e.at.time);if(null==n||n<0||n>i+Ng)return void r.push(Dg("error","event-time-out-of-range",`Event time must fall between 0 and ${i}.`,`events.${o}.at.time`,[e.id]));a=Math.max(0,Math.min(i,n));let c=Gg(t,i,a);s=c.phase,l=c.boundaryRank}else{if(s=t.find(t=>t.id===e.at.phaseId),!s)return void r.push(Dg("error","unknown-event-phase",`Event references unknown phase "${e.at.phaseId}".`,`events.${o}.at.phaseId`,[e.id,e.at.phaseId]));let i=e.at.progress??0;if(!Number.isFinite(i)||i<0||i>1)return void r.push(Dg("error","event-progress-out-of-range","Event phase progress must be between 0 and 1.",`events.${o}.at.progress`,[e.id]));a=s.start+s.duration*i,l=0===i?1:0}s?n.push({...e,index:o,authoredAt:a,phaseId:s.id,phaseIndex:s.index,boundaryRank:l}):r.push(Dg("error","event-without-phase","Event could not be assigned to a phase.",`events.${o}.at`,[e.id]))}),n.sort((e,t)=>e.authoredAt-t.authoredAt||e.boundaryRank-t.boundaryRank||e.index-t.index),{events:n,diagnostics:r}}function Vg(e,t){let i=[],r=new Set(t.map(e=>e.id)),o=Eg(t.map(e=>e.id)),n=Eg(e.map(e=>e.id));return o.length&&i.push(Dg("error","duplicate-outlet-id",`Outlet ids must be unique: ${o.join(", ")}.`,"outlets",o)),n.length&&i.push(Dg("error","duplicate-product-id",`Product ids must be unique: ${n.join(", ")}.`,"products",n)),t.forEach((e,t)=>{e.id.trim()||i.push(Dg("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0!==e.order&&!Number.isFinite(e.order)&&i.push(Dg("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||i.push(Dg("error","invalid-product-id","Product ids may not be empty.",`products.${t}.id`)),void 0!==e.amount&&(!Number.isFinite(e.amount)||e.amount<0)&&i.push(Dg("error","invalid-product-amount","Declared product amount must be finite and non-negative.",`products.${t}.amount`,[e.id])),void 0!==e.outletId&&!r.has(e.outletId)&&i.push(Dg("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),jg(e.metrics??{},i,`products.${t}.metrics`)}),i}function qg(e){return e.map((e,t)=>({outlet:e,index:t})).sort((e,t)=>(e.outlet.order??e.index)-(t.outlet.order??t.index)||e.index-t.index).map(({outlet:e})=>({...e}))}function Hg(e=Rg,t=Tg){let i=Math.max(1,zg(e[0])??Lg),r=Math.max(1,zg(e[1])??Ig),o=i<360||r<260,n=o?Math.max(4,.035*Math.min(i,r)):20,a=o?Math.max(10,.075*r):34,s={x:n,y:n,width:Math.max(1,i-2*n),height:a},l=o?Math.max(16,.14*r):Math.min(78,.16*r),c={x:n,y:r-n-l,width:Math.max(1,i-2*n),height:l},u=o?Math.max(12,.08*i):Math.min(150,.17*i),d=s.y+s.height+(o?12:38),h=c.y-(o?10:34),f={x:u,y:d,width:Math.max(24,i-2*u),height:Math.max(24,h-d)},p=Math.max(18,Math.min(.32*f.width,o?84:180)),g={x:f.x+(f.width-p)/2,y:f.y-(o?10:24),width:p,height:o?12:28},m=qg(t),y={left:m.filter(e=>"left"===(e.side??"bottom")),right:m.filter(e=>"right"===e.side),bottom:m.filter(e=>"bottom"===(e.side??"bottom"))},x=[],b=(e,t)=>{let r=Math.max(8,u-1.5*n),a=f.height/Math.max(1,t.length);t.forEach((t,s)=>{x.push({...t,side:e,x:"left"===e?n:i-n-r,y:f.y+s*a,width:r,height:Math.max(8,a-(o?2:8))})})};b("left",y.left),b("right",y.right);let v=f.width/Math.max(1,y.bottom.length);return y.bottom.forEach((e,t)=>{x.push({...e,side:"bottom",x:f.x+t*v,y:f.y+f.height+(o?2:7),width:Math.max(8,v-(o?2:8)),height:Math.max(8,c.y-f.y-f.height-(o?4:12))})}),x.sort((e,t)=>m.findIndex(t=>t.id===e.id)-m.findIndex(e=>e.id===t.id)),{width:i,height:r,phaseRail:s,chamber:f,mouth:g,projection:c,outlets:x}}function Ug(e,t,i){let r=i.map(([i,r])=>[Math.max(e,Math.min(i,r)),Math.min(t,Math.max(i,r))]).filter(([e,t])=>t>e+Ng).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),o=[],n=e;for(let[e,t]of r)e>n+Ng&&o.push([n,e]),n=Math.max(n,t);return t>n+Ng&&o.push([n,t]),o}function Zg(e){let{id:t,orientation:i,fixed:r,start:o,end:n,openings:a,thickness:s,friction:l,restitution:c}=e,u=Ug(o,n,a);return u.map(([e,o],n)=>({id:1===u.length?t:`${t}:${n}`,friction:l,restitution:c,shape:"horizontal"===i?{type:"segment",x1:e,y1:r,x2:o,y2:r,thickness:s}:{type:"segment",x1:r,y1:e,x2:r,y2:o,thickness:s}}))}function Qg(e){let{chamber:t,mouth:i}=e,r=Math.max(2,Math.min(10,.018*Math.min(e.width,e.height))),o=Math.max(t.x,i.x),n=Math.min(t.x+t.width,i.x+i.width),a={left:e.outlets.filter(e=>"left"===e.side),right:e.outlets.filter(e=>"right"===e.side),bottom:e.outlets.filter(e=>"bottom"===e.side)},s=[{id:"crucible:wall:top-left",friction:.42,restitution:.1,shape:{type:"segment",x1:t.x,y1:t.y,x2:o,y2:t.y,thickness:r}},{id:"crucible:wall:top-right",friction:.42,restitution:.1,shape:{type:"segment",x1:n,y1:t.y,x2:t.x+t.width,y2:t.y,thickness:r}}];s.push(...Zg({id:"crucible:wall:left",orientation:"vertical",fixed:t.x,start:t.y,end:t.y+t.height,openings:a.left.map(e=>[e.y,e.y+e.height]),thickness:r,friction:.46,restitution:.12}),...Zg({id:"crucible:wall:right",orientation:"vertical",fixed:t.x+t.width,start:t.y,end:t.y+t.height,openings:a.right.map(e=>[e.y,e.y+e.height]),thickness:r,friction:.46,restitution:.12}),...Zg({id:"crucible:wall:bottom",orientation:"horizontal",fixed:t.y+t.height,start:t.x,end:t.x+t.width,openings:a.bottom.map(e=>[e.x,e.x+e.width]),thickness:r,friction:.5,restitution:.08}));for(let t of e.outlets)s.push({id:`crucible:outlet:${encodeURIComponent(t.id)}`,sensor:!0,shape:{type:"aabb",x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height}});return s}function Kg(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?qe(e):1}function Jg(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:Kg(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function em(e){return`crucible:component:${encodeURIComponent(e)}`}function tm(e){return`crucible:product:${encodeURIComponent(e)}`}function im(e,t,i,r){if(void 0!==i&&Number.isFinite(i)&&i>0)return i;let[o,n]=t;if(n-o<=Ng)return(r[0]+r[1])/2;let a=Math.sqrt(Math.max(0,e-o)/(n-o));return r[0]+(r[1]-r[0])*a}function rm(e,t){let i=Math.max(.25,Math.min(1,t.width/900,t.height/520)),r=e?.[0]??7*i,o=e?.[1]??18*i,n=Math.max(1,Math.min(r,o));return[n,Math.max(n,Math.max(r,o))]}function om(e,t,i={}){let r=Object.values(e.components).sort((e,t)=>Fg(e.id,t.id)),o=Ce(r.map(e=>e.amount)),n=rm(i.radiusRange,t),a=ze(Kg(i.seed)),s=t.mouth.x+t.mouth.width/2,l=t.chamber.y+Math.max(18,.18*t.chamber.height),c=Math.max(4,.28*t.chamber.width),u=Math.max(4,.12*t.chamber.height);return r.map((e,t)=>{let d=t/Math.max(1,r.length)*Math.PI*2+.18*(a()-.5),h=im(e.amount,o,i.bodyRadius,n),f={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:em(e.id),x:s+Math.cos(d)*c*(.45+.45*a()),y:l+Math.sin(d)*u*(.45+.45*a()),vx:24*(a()-.5),vy:18*(a()-.5),mass:Math.max(.25,h*h*.015),restitution:.12,friction:.4,shape:{type:"circle",radius:h},datum:f}})}function nm(e,t){if(!e)return[];let i=Math.min(e,Math.max(1,Math.ceil(Math.sqrt(e*Math.max(.5,t.width/Math.max(1,t.height)))))),r=Math.max(1,Math.ceil(e/i));return Array.from({length:e},(e,o)=>({x:t.x+(o%i+.5)*(t.width/i),y:t.y+(Math.floor(o/i)+.5)*(t.height/r)}))}function am(e){return e.outletId?e.outletId:"failed"===e.status?"failed":"recovered"===e.status?"recovered":"retained"===e.status?"retained":"ejected"===e.status?"residue":void 0}function sm(e,t){return e.outlets.find(e=>e.id===t)||{x:e.chamber.x+.18*e.chamber.width,y:e.chamber.y+.2*e.chamber.height,width:.64*e.chamber.width,height:.6*e.chamber.height}}function lm(e,t){let i=/* @__PURE__ */new Map;for(let t of e){let e=t.outletId??"__chamber__",r=i.get(e)??[];r.push(t),i.set(e,r)}let r=/* @__PURE__ */new Map;for(let[e,o]of i){o.sort((e,t)=>(e.order??Number.MAX_SAFE_INTEGER)-(t.order??Number.MAX_SAFE_INTEGER)||Fg(e.id,t.id));let i=nm(o.length,sm(t,"__chamber__"===e?void 0:e));o.forEach((e,t)=>r.set(e.id,i[t]))}return r}function cm(e,t,i={}){let r=Object.values(e.products).sort((e,t)=>Fg(e.id,t.id)),o=Object.values(e.components).sort((e,t)=>Fg(e.id,t.id)),n=Ce([...o.map(e=>e.amount),...r.map(e=>e.amount)]),a=rm(i.radiusRange,t),s=lm(r,t),l=r.map(e=>{let r=s.get(e.id)??{x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2},o=1.28*im(e.amount,n,i.bodyRadius,a),l={__crucible:!0,kind:"product",semanticId:e.id,product:e};return{id:tm(e.id),x:r.x,y:r.y,mass:Math.max(.25,o*o*.018),bodyCollisions:!1,shape:{type:"circle",radius:o},datum:l}}),c=/* @__PURE__ */new Map;for(let e of o.filter(e=>!e.productIds.length)){let t=am(e)??"__chamber__",i=c.get(t)??[];i.push(e),c.set(t,i)}let u=/* @__PURE__ */new Map;for(let[e,i]of c){let r=nm(i.length,sm(t,"__chamber__"===e?void 0:e));i.forEach((e,t)=>u.set(e.id,r[t]))}return[...o.map(e=>{let r=u.get(e.id);if(e.productIds.length){let i=e.productIds.map(e=>s.get(e)).filter(e=>!!e);if(i.length){r={x:i.reduce((e,t)=>e+t.x,0)/i.length,y:i.reduce((e,t)=>e+t.y,0)/i.length};let o=qe(e.id)/4294967295*Math.PI*2,n=Math.min(20,Math.max(4,.012*t.width));r={x:r.x+Math.cos(o)*n,y:r.y+Math.sin(o)*n}}}r??(r={x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2});let o=im(e.amount,n,i.bodyRadius,a),l={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:em(e.id),x:r.x,y:r.y,mass:Math.max(.25,o*o*.015),shape:{type:"circle",radius:o},datum:l}}),...l]}var um=cm;function dm(e){return Array.isArray(e)?e.map(dm):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>Fg(e,t)).map(([e,t])=>[e,dm(t)])):e}function hm(e){return JSON.stringify(dm(e))}function fm(e,t){let i=zg(t)??0,r=Math.max(0,Math.min(e.duration,i));if(!e.phases.length)return{elapsed:r,phaseId:"",phaseIndex:-1,phaseElapsed:0,complete:!0};let o=r>=e.duration-Ng,n=o?e.phases[e.phases.length-1]:e.phases.find(e=>r>=e.start&&r<e.end)??e.phases[0];return{elapsed:r,phaseId:n.id,phaseIndex:n.index,phaseElapsed:o?n.duration:Math.max(0,r-n.start),complete:o}}function pm(e,t){if(void 0===t)return e.duration;if("number"==typeof t)return Math.max(0,Math.min(e.duration,zg(t)??0));let i=e.phases.find(e=>e.id===t.phaseId);if(!i)return e.duration;let r=Math.max(0,Math.min(1,zg(t.progress??0)??0));return i.start+i.duration*r}function gm(e,t=e.duration){let i=fm(e,t),r=og(e.initialState),o=[],n=[],a=[];for(let t of e.events){if(t.authoredAt>i.elapsed+Ng)break;let s=$g(r,t,{phaseId:t.phaseId,authoredAt:t.authoredAt,appliedAt:t.authoredAt,products:e.products,outlets:e.outlets});o.push(...s.diagnostics),n.push(...s.materializations),a.push(...s.observations),s.applied&&(r=s.state)}return r.elapsed=i.elapsed,r.phaseId=i.phaseId,r.phaseIndex=i.phaseIndex,r.phaseElapsed=i.phaseElapsed,r.complete=i.complete,i.complete&&"in_process"===r.outcome&&(r.outcome="complete"),r.playing=!1,{state:r,diagnostics:o,materializations:n,observations:a}}function mm(e){let t=Yg(e.phases),i=t.phases.at(-1)?.end??0,r=qg(e.outlets??Tg),o=(e.products??[]).map(e=>({...e,metrics:e.metrics?tg(e.metrics):void 0})),n=Xg(e.events??[],t.phases,i),a=Bg(e),s=Hg(e.size??Rg,r),l=Qg(s),c=Vg(o,r),u=hm({seed:e.seed??1,components:Object.values(a.state.components).sort((e,t)=>Fg(e.id,t.id)).map(e=>({id:e.id,label:e.label,category:e.category,amount:e.amount,metrics:e.metrics,status:e.status})),phases:t.phases.map(({id:e,duration:t,label:i,description:r,intensity:o,motion:n,color:a,metrics:s})=>({id:e,duration:t,label:i,description:r,intensity:o,motion:n,color:a,metrics:s})),products:o,outlets:r,events:n.events.map(({id:e,label:t,description:i,summary:r,authoredAt:o,phaseId:n,boundaryRank:a,effects:s})=>({id:e,label:t,description:i,summary:r,authoredAt:o,phaseId:n,boundaryRank:a,effects:s}))}),d=om(a.state,s,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),h=[...t.diagnostics,...n.diagnostics,...a.diagnostics,...c],f={phases:t.phases,events:n.events,products:o,outlets:r,duration:i,initialState:a.state,terminalState:a.state,layout:s,colliders:l,config:Jg(e.seed,l),initialSpawns:d,terminalSpawns:[],semanticKey:u,diagnostics:h},p=gm(f),g=Object.values(p.state.products).filter(e=>"forming"===e.status).map(e=>e.id),m=g.length?[Dg("warning","forming-product-at-end",`Products remain forming at the end of the tape: ${g.join(", ")}.`,"events",g)]:[];return f.terminalState=p.state,f.terminalSpawns=um(p.state,s,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),f.diagnostics=[...h,...p.diagnostics,...m],f}import*as ym from"react";import{jsx as xm,jsxs as bm}from"react/jsx-runtime";function vm(e){return Number.isFinite(e)?Math.abs(e)>=1e3?e.toLocaleString():Number.isInteger(e)?String(e):e.toFixed(2).replace(/\.00$/,"").replace(/(\.\d)0$/,"$1"):"0"}function wm(e,t,i,r){let o=e.datum;if(!o?.__crucible)return;let n="circle"===e.shape.type?e.shape.radius:8,a="string"==typeof t.fill?t.fill:"product"===o.kind?"#b8792d":"#356b63",s="string"==typeof t.stroke?t.stroke:"#26323a",l="number"==typeof t.strokeWidth?t.strokeWidth:1.25,c="number"==typeof t.opacity?t.opacity:.96,u=r?`${r}-crucible-body-${i}`:`crucible-body-${i}`;if("product"===o.kind){let t=Array.from({length:6},(t,i)=>{let r=-Math.PI/2+i/6*Math.PI*2;return`${e.x+Math.cos(r)*n},${e.y+Math.sin(r)*n}`}).join(" "),i=`${u}-glow`;/* */
179
+ return bm(ym.Fragment,{children:[
180
+ /* @__PURE__ */xm("defs",{children:/* @__PURE__ */xm("filter",{id:i,x:"-60%",y:"-60%",width:"220%",height:"220%",children:/* @__PURE__ */xm("feDropShadow",{dx:"0",dy:"0",stdDeviation:"4",floodColor:a,floodOpacity:"0.8"})})}),
181
+ /* @__PURE__ */xm("polygon",{points:t,fill:a,stroke:s,strokeWidth:l,opacity:c,filter:`url(#${i})`}),
182
+ /* @__PURE__ */xm("circle",{cx:e.x,cy:e.y,r:Math.max(2,.36*n),fill:"none",stroke:"var(--semiotic-bg, #fffaf0)",strokeWidth:l,opacity:.72*c})]},u)}/* */
183
+ return bm(ym.Fragment,{children:[
184
+ /* @__PURE__ */xm("circle",{cx:e.x,cy:e.y,r:n,fill:a,stroke:s,strokeWidth:l,opacity:c}),
185
+ /* @__PURE__ */xm("circle",{cx:e.x-.25*n,cy:e.y-.28*n,r:Math.max(1,.18*n),fill:"rgba(255,255,255,0.34)"})]},u)}import{Fragment as km,jsx as Am,jsxs as Sm}from"react/jsx-runtime";var Mm="var(--semiotic-text, #26323a)",$m="var(--semiotic-text-secondary, #6c7377)",_m="var(--semiotic-primary, #b8792d)",Pm="var(--semiotic-danger, #9f3d35)",Lm="var(--semiotic-success, #356b63)";function Im(e){let{x:t,y:i,width:r,height:o}=e.chamber,n=Math.min(.14*r,48),a=i+o;return[`M ${t} ${i}`,`L ${t+n} ${a-.16*o}`,`Q ${t+r/2} ${a+.1*o} ${t+r-n} ${a-.16*o}`,`L ${t+r} ${i}`].join(" ")}function Rm({layout:e,phases:t,state:i,compact:r=!1}){let o=Math.max(1,t.reduce((e,t)=>e+Math.max(0,t.duration),0));/* */
186
+ return Sm("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",viewBox:`0 0 ${e.width} ${e.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:[
187
+ /* @__PURE__ */Sm("defs",{children:[
188
+ /* @__PURE__ */Sm("linearGradient",{id:"semiotic-crucible-heat",x1:"0",x2:"0",y1:"0",y2:"1",children:[
189
+ /* @__PURE__ */Am("stop",{offset:"0",stopColor:_m,stopOpacity:"0.03"}),
190
+ /* @__PURE__ */Am("stop",{offset:"0.66",stopColor:_m,stopOpacity:"0.1"}),
191
+ /* @__PURE__ */Am("stop",{offset:"1",stopColor:Pm,stopOpacity:"0.18"})]}),
192
+ /* @__PURE__ */Am("pattern",{id:"semiotic-crucible-hatch",width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(20)",children:/* @__PURE__ */Am("line",{x1:"0",x2:"0",y1:"0",y2:"7",stroke:Mm,strokeOpacity:"0.08",strokeWidth:"1"})})]}),
193
+ /* @__PURE__ */Am("rect",{x:e.chamber.x,y:e.chamber.y,width:e.chamber.width,height:e.chamber.height,rx:2,fill:"url(#semiotic-crucible-heat)",stroke:Mm,strokeOpacity:"0.52",strokeWidth:r?1:2.2}),
194
+ /* @__PURE__ */Am("path",{d:Im(e),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),
195
+ /* @__PURE__ */Am("line",{x1:e.mouth.x,x2:e.mouth.x+e.mouth.width,y1:e.mouth.y,y2:e.mouth.y,stroke:Mm,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:r?2:5}),r?null:/* @__PURE__ */Am("g",{"data-testid":"crucible-phase-rail",children:t.map((r,n)=>{let a=t.slice(0,n).reduce((e,t)=>e+Math.max(0,t.duration),0),s=e.phaseRail.x+a/o*e.phaseRail.width,l=Math.max(0,r.duration)/o*e.phaseRail.width,c=r.id===i.phaseId,u=i.phaseIndex>n||i.complete;/* */
196
+ return Sm("g",{children:[
197
+ /* @__PURE__ */Am("rect",{x:s,y:e.phaseRail.y,width:Math.max(1,l-2),height:e.phaseRail.height,rx:2,fill:c?r.color??_m:u?Lm:Mm,fillOpacity:c?.68:u?.28:.09}),l>=46?/* @__PURE__ */Am("text",{x:s+l/2,y:e.phaseRail.y+e.phaseRail.height+13,fill:c?Mm:$m,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8.5,fontWeight:c?800:650,letterSpacing:"0.04em",textAnchor:"middle",children:(r.label??r.id).toUpperCase()}):null]},r.id)})}),e.outlets.map(e=>/* @__PURE__ */Sm("g",{children:[
198
+ /* @__PURE__ */Am("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?Pm:Lm),fillOpacity:"0.1",stroke:e.color??("left"===e.side?Pm:Lm),strokeDasharray:"3 3",strokeOpacity:"0.62"}),r?null:/* @__PURE__ */Am("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:$m,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(e.label??e.id).toUpperCase()})]},e.id))]})}function Tm(e,t){return"count"===t?e.count:"amount"===t?e.amount:Number(e.metrics[t]??0)}function Cm({rows:e,layout:t,projection:i,amountLabel:r}){if(!e.length)return null;let o=i.measure??"count",n=e.map(e=>Math.max(0,Tm(e,o))),a=n.reduce((e,t)=>Math.max(e,t),1),s=t.projection.width/Math.max(1,e.length),l=t.projection.height>48?21:4,c=Math.max(5,t.projection.height-l-5);/* */
199
+ return Am("svg",{"aria-hidden":"true","data-testid":"crucible-projection-overlay",viewBox:`0 0 ${t.width} ${t.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:e.map((e,i)=>{let u=n[i],d=Math.max(u>0?2:0,u/a*c),h=t.projection.x+i*s+.18*s,f=t.projection.y+c-d;/* */
200
+ return Sm("g",{children:[
201
+ /* @__PURE__ */Am("rect",{x:h,y:f,width:Math.max(3,.64*s),height:d,rx:2,fill:"failed"===e.status||"ejected"===e.status?Pm:"complete"===e.status?_m:Lm,fillOpacity:"0.68"}),l>4&&s>=34?/* @__PURE__ */Sm(km,{children:[
202
+ /* @__PURE__ */Am("text",{x:h+.32*s,y:t.projection.y+c+10,fill:$m,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:7.5,fontWeight:700,textAnchor:"middle",children:e.label.length>13?`${e.label.slice(0,12)}…`:e.label}),
203
+ /* @__PURE__ */Sm("text",{x:h+.32*s,y:t.projection.y+c+19,fill:Mm,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:850,textAnchor:"middle",children:[vm(u),"amount"===o&&r?` ${r}`:""]})]}):null]},e.key)})})}function Nm(e){let t=e.datum;if(t&&"object"==typeof t){let e=t,i=e.label??e.name??e.id;if(null!=i&&""!==i)return String(i)}return e.id}function Fm(e,t={}){let i=t.bodies??[],r=Math.max(0,t.recentBodyLimit??6),o=/* @__PURE__ */new Map;for(let e of i){let i=t.getContainerId?.(e);if(!i)continue;let r=o.get(i);r?r.push(e):o.set(i,[e])}let n=e.map(e=>{let i=o.get(e.id)??[],n=Math.max(0,Math.floor(e.count??i.length)),a=i.slice(Math.max(0,i.length-r)).map(e=>({id:e.id,label:t.getBodyLabel?.(e)??Nm(e),datum:e.datum}));return{id:e.id,label:e.label,count:n,share:0,secondary:e.secondary,secondaryLabel:e.secondaryLabel,observed:e.observed,bodyIds:i.map(e=>e.id),recentBodies:a,metadata:e.metadata}}),a=n.reduce((e,t)=>e+t.count,0);return n.map(e=>({...e,share:a>0?e.count/a:0}))}import{Fragment as Dm,jsx as Em,jsxs as zm}from"react/jsx-runtime";function Om(e,t,i,r,o){let n=Array.isArray(o)?o:o?[o]:[];if(!1!==i||0!==n.length)return({size:o})=>{let a=[Number(o[0])||700,Number(o[1])||420],s=k(a),l=Math.max(2,Math.round(t)),c=s.plot.width/l,u=s.plot.y+s.plot.height,d=e.reduce((e,t)=>Math.max(e,t.value),1),h=!1!==i,[f,p]=r?.valueExtent??[0,l],g=p===f?1:p-f,m=e.map((e,t)=>{let i=s.plot.x+(t+.5)*c,r=u-e.value/d*s.plot.height*.9;return`${0===t?"M":"L"} ${i.toFixed(1)} ${r.toFixed(1)}`}).join(" ");/* */
204
+ return zm("svg",{"aria-hidden":"true","data-testid":"galton-board-structure-overlay",width:a[0],height:a[1],viewBox:`0 0 ${a[0]} ${a[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[h?/* @__PURE__ */zm(Dm,{children:[Array.from({length:l+1},(e,t)=>{let i=s.plot.x+t*c;/* */
205
+ return Em("line",{"data-testid":"galton-board-bin-wall",x1:i,x2:i,y1:s.plot.y,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.28,strokeWidth:1},`bin-wall-${t}`)}),
206
+ /* @__PURE__ */Em("line",{x1:s.plot.x,x2:s.plot.x+s.plot.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),
207
+ /* @__PURE__ */Em("path",{d:m,fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.7,strokeWidth:2,strokeLinejoin:"round"}),e.map((e,t)=>{if(e.value<=0)return null;let i=s.plot.x+(t+.5)*c,r=u-e.value/d*s.plot.height*.9;/* */
208
+ return Em("text",{x:i,y:Math.max(s.plot.y+10,r-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.value},`${e.label}-${t}`)})]}):null,n.map((e,t)=>{let i=Number(e.value);if(!Number.isFinite(i))return null;let r=Math.max(0,Math.min(1,(i-f)/g)),o=s.plot.x+r*s.plot.width,n=e.color??"var(--semiotic-warning, #f28e2b)",l="bottom"===e.labelPosition?Math.min(a[1]-8,u+16):s.plot.y+16;/* */
209
+ return zm("g",{className:e.className,"data-testid":"galton-board-reference-line",children:[
210
+ /* @__PURE__ */Em("line",{x1:o,x2:o,y1:s.plot.y+8,y2:u-4,stroke:n,strokeDasharray:e.strokeDasharray??"6 5",strokeWidth:e.strokeWidth??2}),null==e.label?null:/* @__PURE__ */Em("text",{x:Math.min(s.plot.x+s.plot.width-4,o+6),y:l,fill:n,fontSize:10,fontWeight:700,children:e.label})]},`galton-reference-${t}-${i}`)})]})}}function jm(e,t,i){if(!1!==i&&t)return({size:i})=>{let r=[Number(i[0])||760,Number(i[1])||360],o=k(r),n=Math.max(1,t.windowCount),a=t.plot??o.plot,s=t.gutter??{x:a.x,y:a.y,width:0,height:a.height},l=t.windowPlot??a,c=l.width/n,u=a.y+a.height,d=a.y+.48*a.height,h=t.lidSegments[0]?.y1??d,f=t.windowStart,p=t.windowStart+n*t.windowSize,g=p===f?0:(t.watermarkValue-f)/(p-f),m=l.x+Math.max(0,Math.min(1,g))*l.width;/* */
211
+ return zm("svg",{"aria-hidden":"true","data-testid":"event-drop-window-overlay",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
212
+ /* @__PURE__ */Em("rect",{x:a.x,y:a.y,width:a.width,height:a.height,fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.7,strokeWidth:1}),s.width>0?/* @__PURE__ */zm("g",{children:[
213
+ /* @__PURE__ */Em("rect",{x:s.x,y:h,width:s.width,height:u-h,fill:"var(--semiotic-danger, #e15759)",fillOpacity:.07}),
214
+ /* @__PURE__ */zm("text",{x:s.x+s.width/2,y:h-8,textAnchor:"middle",fill:"var(--semiotic-danger, #e15759)",fontSize:10,fontWeight:700,children:[t.lateCount," late"]})]}):null,Array.from({length:n},(i,o)=>{let n=e[o],a=l.x+o*c,s=o<t.closedWindowCount;/* */
215
+ return zm("g",{children:[
216
+ /* @__PURE__ */Em("rect",{x:a,y:d,width:c,height:u-d,fill:s?"var(--semiotic-danger, #e15759)":"var(--semiotic-primary, #4e79a7)",fillOpacity:s?.08:.06}),s?t.lidSegments.filter(e=>e.windowIndex===o).map(e=>/* @__PURE__ */Em("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.78,strokeWidth:2,strokeLinecap:"round"},e.id)):null,
217
+ /* @__PURE__ */Em("text",{x:a+c/2,y:d-8,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:n?.value??0}),
218
+ /* @__PURE__ */Em("text",{x:a+c/2,y:Math.min(r[1]-8,u+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:n?.label??""})]},`window-${o}`)}),t.windowWalls?.map(({id:e,...t})=>/* @__PURE__ */Em("rect",{...t,fill:"var(--semiotic-border, #d1d5db)",fillOpacity:.68},e)),t.lidSegments.filter(e=>null==e.windowIndex).map(e=>/* @__PURE__ */Em("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.62,strokeWidth:2,strokeLinecap:"round"},e.id)),
219
+ /* @__PURE__ */Em("line",{x1:a.x,x2:a.x+a.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),
220
+ /* @__PURE__ */Em("line",{"data-testid":"event-drop-watermark",x1:m,x2:m,y1:a.y+8,y2:u,stroke:"var(--semiotic-warning, #f28e2b)",strokeDasharray:"5 4",strokeWidth:2}),
221
+ /* @__PURE__ */zm("text",{x:Math.min(a.x+a.width-4,m+6),y:a.y+16,fill:"var(--semiotic-warning, #f28e2b)",fontSize:10,fontWeight:700,children:["watermark ",Math.round(100*t.watermarkValue)/100]})]})}}function Wm(e,t,i,r=1){if(!1!==i&&0!==e.length)return({size:i})=>{let o=[Number(i[0])||700,Number(i[1])||380],n=k(o),a=fp(n.plot,e.length,t),s=n.plot.y+n.plot.height;/* */
222
+ return zm("svg",{"aria-hidden":"true","data-testid":"physics-pile-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
223
+ /* @__PURE__ */Em("line",{x1:n.plot.x,x2:n.plot.x+n.plot.width,y1:s,y2:s,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1}),e.map((e,t)=>{let i=Math.min(n.plot.height,a.pileHeight(e.value/r)),l=a.tubeWidth,c=a.centerX(t),u=s-i;/* */
224
+ return zm("g",{children:[
225
+ /* @__PURE__ */Em("rect",{x:c-l/2,y:u,width:l,height:i,rx:3,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.08,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.42,strokeWidth:1,strokeDasharray:"4 3"}),
226
+ /* @__PURE__ */Em("text",{x:c,y:Math.max(n.plot.y+12,u-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:11,fontWeight:700,children:e.value}),
227
+ /* @__PURE__ */Em("text",{x:c,y:Math.min(o[1]-8,s+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${t}`)}),
228
+ /* @__PURE__ */Em("text",{x:o[0]/2,y:o[1]-2,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:`Full circle = ${r}; partial circles scaled by area`})]})}}function Bm(e){return Math.abs(e)>=1e3||Math.abs(e)<.01?e.toLocaleString(void 0,{maximumFractionDigits:0}):e.toLocaleString(void 0,{maximumFractionDigits:2})}function Ym(e,t){if(!1!==t&&e)return({size:t})=>{let i=[Number(t[0])||700,Number(t[1])||360],r=k(i),o=r.plot.y+r.plot.height,[n,a]=e.xExtent,s=n+(a-n)/2,l=[{label:Bm(n),x:e.xRange[0]},{label:Bm(s),x:e.xRange[0]+(e.xRange[1]-e.xRange[0])/2},{label:Bm(a),x:e.xRange[1]}];/* */
229
+ return zm("svg",{"aria-hidden":"true","data-testid":"collision-swarm-projection-overlay",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[e.groups.some(e=>e.overlapping)?/* @__PURE__ */Em("text",{"data-testid":"collision-swarm-overlap-warning",x:r.plot.x,y:Math.max(10,r.plot.y-9),fill:"var(--semiotic-warning, #b45309)",fontSize:10,children:i[0]<360?"Points overlap":"Points overlap. Reduce radius or increase height."}):null,e.groups.map(e=>/* @__PURE__ */zm("g",{children:[
230
+ /* @__PURE__ */Em("line",{x1:r.plot.x,x2:r.plot.x+r.plot.width,y1:e.y,y2:e.y,stroke:"var(--semiotic-border, #d1d5db)",strokeDasharray:"3 5",strokeWidth:1}),
231
+ /* @__PURE__ */Em("text",{x:r.plot.x+4,y:e.y-7,fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.label}),
232
+ /* @__PURE__ */zm("text",{x:r.plot.x+r.plot.width-4,y:e.y-7,textAnchor:"end",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:["n=",e.count,e.overlapping?" · overlaps":""]})]},e.label)),
233
+ /* @__PURE__ */Em("line",{x1:e.xRange[0],x2:e.xRange[1],y1:o,y2:o,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),l.map(e=>/* @__PURE__ */zm("g",{children:[
234
+ /* @__PURE__ */Em("line",{x1:e.x,x2:e.x,y1:o,y2:o+5,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),
235
+ /* @__PURE__ */Em("text",{x:e.x,y:Math.min(i[1]-8,o+18),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${e.x}`))]})}}import{jsx as Gm}from"react/jsx-runtime";function Xm(e,t,i={},r){if(!1===t||!e)return;let{volume:o,stages:n,groups:a,groupCompletion:s}=e,l=new Map(o.stages.map(e=>[e.id,e])),c=new Map(s.map(e=>[e.id,e]));return({size:e})=>{let t=Number(e[0])||o.width,s=Number(e[1])||o.height,u=n.map(e=>{let t=l.get(e.id),r=i[`process-stage-${e.id}`];return{id:e.id,label:e.label,x0:t?.x0??e.x-e.width/2,x1:(t?.x0??e.x-e.width/2)+(t?.width??e.width),x:e.x,width:t?.width??e.width,count:e.count,capacity:e.capacity,absorb:e.absorb,portalTarget:e.portalTarget,queueDepth:r?.queueDepth,processed:r?.processedCount}}),d=a.map(e=>{let t=c.get(e.id);return{id:e.id,label:e.label??e.id,x:e.anchor?.x??e.x??0,y:e.anchor?.y??e.y??0,absorbed:t?.absorbed,total:t?.total,complete:t?.complete}});return Ae({width:t,height:s,left:o.left,right:o.right,topY:o.topY,bottomY:o.bottomY,midY:o.midY,stages:u,groups:d},{showCapacityBadges:!0,showGroupSockets:!0,...r})}}function Vm(e,t,i){if(!1===i||!t||0===e.length)return;let r=new Map(t.volume.stages.map(e=>[e.id,e]));return({size:i})=>{let o=[Number(i[0])||t.volume.width,Number(i[1])||t.volume.height],n=k(o),a=e.reduce((e,t)=>Math.max(e,t.value),1),s=Math.min(48,.18*n.plot.height),l=n.plot.y+6;/* */
236
+ return Gm("svg",{"aria-hidden":"true","data-testid":"process-flow-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:t.stages.map((t,i)=>{let o=e[i];if(!o)return null;let n=r.get(t.id);if(!n)return null;let c=Math.max(2,o.value/a*s),u=Math.max(8,.35*n.width);/* */
237
+ return Gm("rect",{x:n.x-u/2,y:l,width:u,height:c,rx:2,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.18,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.45,strokeWidth:1},t.id)})})}}function qm(e){return Math.abs(e)>=1e3?e.toLocaleString(void 0,{maximumFractionDigits:0}):e.toLocaleString(void 0,{maximumFractionDigits:1})}function Hm(e){return e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" ")}import{jsx as Um,jsxs as Zm}from"react/jsx-runtime";function Qm(e,t){let{showNodeLabels:i,showSensors:r,showStaticFlow:o}=t;if(e&&(o||r||i))return({size:t})=>{let n=[Number(t[0])||760,Number(t[1])||420],a=e.links.reduce((e,t)=>Math.max(e,t.throughput),1),s=new Set(e.nodes.map(e=>e.sensorId));/* */
238
+ return Zm("svg",{"aria-hidden":"true","data-testid":"physical-flow-static-flow-overlay",width:n[0],height:n[1],viewBox:`0 0 ${n[0]} ${n[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[o?e.links.map(e=>{let t=3+e.throughput/a*16,i=e.path[Math.floor(e.path.length/2)];/* */
239
+ return Zm("g",{children:[
240
+ /* @__PURE__ */Um("path",{d:Hm(e.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:t+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),
241
+ /* @__PURE__ */Um("path",{d:Hm(e.path),fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),i?/* @__PURE__ */Um("text",{x:i.x,y:i.y-t/2-5,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:qm(e.throughput)}):null]},e.id)}):null,e.nodes.map(e=>/* @__PURE__ */Zm("g",{children:[r&&s.has(e.sensorId)?/* @__PURE__ */Um("rect",{"data-testid":"physical-flow-sensor-overlay",x:e.x-12,y:e.y-12,width:24,height:24,rx:4,fill:"none",stroke:"var(--semiotic-warning, #f59e0b)",strokeDasharray:"3 3",strokeWidth:1.5,opacity:.88}):null,o?/* @__PURE__ */Um("circle",{cx:e.x,cy:e.y,r:6,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1.2}):null,i?/* @__PURE__ */Um("text",{x:e.x,y:e.y-14,textAnchor:"middle",fill:"var(--semiotic-text, #111827)",fontSize:11,fontWeight:800,children:e.label}):null]},e.id))]})}}import{Fragment as Km,jsx as Jm,jsxs as ey}from"react/jsx-runtime";function ty({layout:e,compact:t,showLabels:i}){let r=t?Math.round(.14*e.height):Math.max(80,e.routeY-180),o=t?Math.max(6,Math.round(.72*e.height)):Math.min(360,e.height-170);/* */
242
+ return Jm(Km,{children:e.gates.map(n=>/* @__PURE__ */ey("g",{children:[
243
+ /* @__PURE__ */Jm("rect",{x:n.x-n.width/2,y:r,width:n.width,height:o,rx:t?2:12,fill:n.color??"var(--semiotic-primary, #38bdf8)",fillOpacity:.1,stroke:n.color??"var(--semiotic-primary, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),i?/* @__PURE__ */Jm("text",{x:n.x,y:Math.max(64,e.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:n.label??n.id}):null]},n.id))})}function iy({layout:e,states:t,compact:i=!1}){return i?/* @__PURE__ */Jm("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:/* @__PURE__ */Jm(ty,{layout:e,compact:!0,showLabels:!1})}):/* @__PURE__ */ey("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
244
+ /* @__PURE__ */Jm("path",{d:`M ${e.startX-42} ${e.routeY} C ${.24*e.width} ${e.routeY-70}, ${.42*e.width} ${e.routeY+78}, ${.58*e.width} ${e.routeY} S ${.78*e.width} ${e.routeY-82}, ${e.socketX+36} ${e.routeY}`,fill:"none",stroke:"var(--semiotic-primary, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),
245
+ /* @__PURE__ */Jm("line",{x1:Math.round(.06*e.width),x2:Math.round(.94*e.width),y1:e.crashY,y2:e.crashY,stroke:"var(--semiotic-danger, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),
246
+ /* @__PURE__ */Jm("text",{x:Math.round(.07*e.width),y:e.crashY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),
247
+ /* @__PURE__ */Jm(ty,{layout:e,compact:!1,showLabels:!0}),
248
+ /* @__PURE__ */ey("g",{children:[
249
+ /* @__PURE__ */Jm("rect",{x:e.socketX-52,y:e.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-success, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-success, #22c55e)",strokeWidth:1.5}),
250
+ /* @__PURE__ */Jm("text",{x:e.socketX,y:e.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),
251
+ /* @__PURE__ */ey("g",{children:[
252
+ /* @__PURE__ */Jm("rect",{x:e.graveyardX-82,y:e.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-danger, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-danger, #ef4444)",strokeOpacity:.7}),
253
+ /* @__PURE__ */Jm("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),
254
+ /* @__PURE__ */Jm("text",{x:e.graveyardX,y:e.graveyardY+12,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,textAnchor:"middle",children:t.some(e=>e.killed)?"lift shut off":"too heavy or too small"})]})]})}function ry(e){return e.map(e=>({label:e.id,value:Math.max(0,Number(e.viability)||0),outcome:e.outcome||e.stage||"in-process"}))}function oy({states:e,layout:t}){let i=ry(e);if(!i.length)return null;let r=i.reduce((e,t)=>Math.max(e,t.value),1),o=Math.max(40,(t.width-80)/i.length);/* */
255
+ return ey("svg",{"aria-hidden":"true","data-testid":"gauntlet-projection-overlay",width:t.width,height:t.height,viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
256
+ /* @__PURE__ */Jm("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),i.map((e,t)=>{let i=40+t*o,n=Math.max(2,e.value/r*28),a=/kill|crash|block|grave/i.test(e.outcome);/* */
257
+ return ey("g",{children:[
258
+ /* @__PURE__ */Jm("rect",{x:i+.18*o,y:28-n+22,width:Math.max(10,.45*o),height:n,rx:2,fill:a?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:a?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),
259
+ /* @__PURE__ */Jm("text",{x:i+.4*o,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}function ny(e,t){return e?"sparkline"===t?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0}}var ay={margin:(e,t)=>ny(t.compactMode,e.mode)};function sy(e,t){return e?t?i=>rp.createElement(rp.Fragment,null,"function"==typeof e?e(i):e,"function"==typeof t?t(i):t):e:t}function ly(e,t,i){let r=t[i];return"boolean"==typeof r?r:!0!==e.__compactMode}var cy=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"];function uy(e){return cy[qe(e)%cy.length]}function dy(e,t,i,r){let o=e.datum,n={stroke:r.stroke??("product"===o?.kind?"#fffaf0":"#26323a"),strokeWidth:r.strokeWidth??("product"===o?.kind?1.8:1.1),opacity:r.opacity??.96};if(!o?.__crucible)return{...n,fill:r.color??"#b8792d"};if("product"===o.kind){let e=t.products[o.semanticId];return{...n,fill:r.color??e?.color??uy(e?.id??o.semanticId)}}let a,s=t.components[o.semanticId];return s?(a="status"===i?s.status:"outlet"===i?s.outletId??"in chamber":"product"===i?s.productIds[0]??"unalloyed":"category"===i||null==i?s.category:String("function"==typeof i?i(s.datum)??"unassigned":s.datum[String(i)]??"unassigned"),{...n,fill:r.color??uy(a)}):{...n,fill:r.color??"#356b63"}}function hy(e,t){let i=e.datum;if(i?.__crucible)return"product"===i.kind?t.products[i.semanticId]?.label:t.components[i.semanticId]?.label}var fy={frameType:"physics",layout:ay,buildProps:(e,t,i,o,n)=>{let a=o.size??[600,400],s=n.bins??21,l=n.seed??1,c=Math.max(1,Math.round(n.pegRows??s-1)),u="mechanical"===(n.simulationMode??n.mode),d=np({data:u?r({bins:s,branchProbability:n.branchProbability,count:n.mechanicalCount,pegRows:c,seed:l}):Array.isArray(e)?e:[],valueAccessor:n.valueAccessor||"value",bins:s,ballRadius:n.ballRadius??("sparkline"===n.mode?1.5:"context"===n.mode?4:6),seed:l,size:a,valueExtent:u?[0,c]:n.valueExtent});return{...o,config:d.config,initialSpawns:d.initialSpawns,initialSpawnPacing:d.initialSpawnPacing,projectionRows:d.projectionRows,foregroundGraphics:sy(Om(d.projectionRows,s,ly(o,n,"showProjection"),d.metadata,n.referenceLines),o.foregroundGraphics),bodyStyle:A(t||n.colorBy||(u?"side":void 0),"#4e79a7",{styleRules:n.styleRules,valueAccessor:n.valueAccessor||"value"})}}},py={frameType:"physics",layout:ay,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,400],a=up({data:Array.isArray(e)?e:[],timeAccessor:o.timeAccessor||"time",arrivalAccessor:o.arrivalAccessor||"arrivalTime",watermarkAtArrivalAccessor:o.watermarkAtArrivalAccessor,windows:o.windows||{size:10},watermark:o.watermark,ballRadius:o.ballRadius??7,seed:o.seed??1,size:n,timeExtent:o.timeExtent,timeScale:o.timeScale??1});return{...r,config:a.config,initialSpawns:a.initialSpawns,initialSpawnPacing:a.initialSpawnPacing,projectionRows:a.projectionRows,foregroundGraphics:sy(jm(a.projectionRows,a.metadata,ly(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:A(t||o.colorBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||o.timeAccessor||"time"})}}},gy={frameType:"physics",layout:ay,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,400],s="mechanical"===(o.simulationMode??o.mode),l=pp({data:s?a({categories:o.mechanicalCategories,count:o.mechanicalCount,seed:o.seed??1,unitValue:o.unitValue??1}):Array.isArray(e)?e:[],categoryAccessor:o.categoryAccessor||"category",valueAccessor:o.valueAccessor||(s?"value":void 0),unitValue:o.unitValue??1,ballRadius:o.ballRadius??8,seed:o.seed??1,size:n});return{...r,config:l.config,initialSpawns:l.initialSpawns,initialSpawnPacing:l.initialSpawnPacing,projectionRows:l.projectionRows,foregroundGraphics:sy(Wm(l.projectionRows,o.ballRadius??8,ly(r,o,"showProjection"),Number.isFinite(o.unitValue)&&o.unitValue>0?o.unitValue:1),r.foregroundGraphics),bodyStyle:A(t||o.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},my={frameType:"physics",layout:ay,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,360],a=yp({data:Array.isArray(e)?e:[],xAccessor:o.xAccessor||"x",groupAccessor:o.groupAccessor,radiusAccessor:o.radiusAccessor,pointRadius:o.pointRadius??5,seed:o.seed??1,size:n,xExtent:o.xExtent,collisionIterations:o.collisionIterations,settle:o.settle});return{...r,config:a.config,initialSpawns:a.initialSpawns,initialSpawnPacing:a.initialSpawnPacing,projectionRows:a.projectionRows,foregroundGraphics:sy(Ym(a.metadata,ly(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:A(t||o.colorBy||o.groupAccessor,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.xAccessor||"x"})}}},yy={frameType:"physics",layout:ay,buildProps:(e,t,i,r,o)=>{let n=r.size??[900,420],a=Array.isArray(o.stages)?o.stages:[],s=Pp({data:Array.isArray(e)?e:[],stages:a,size:n,idAccessor:o.idAccessor,stageAccessor:o.stageAccessor||"stage",groupBy:o.groupBy,groupLabelAccessor:o.groupLabelAccessor,workAccessor:o.workAccessor,radiusAccessor:o.radiusAccessor,ballRadius:o.ballRadius??6,seed:o.seed??1,groupCompletion:o.groupCompletion,groupAnchorAlong:o.groupAnchorAlong,settle:o.settle??!0,gravityX:o.gravityX,gravityY:o.gravityY}),l=s.metadata;return{...r,config:s.config,initialSpawns:s.initialSpawns,initialSpawnPacing:s.initialSpawnPacing,projectionRows:s.projectionRows,regionEffects:l?.regionEffects,backgroundGraphics:sy(Xm(s.metadata,ly(r,o,"showChrome"),{},o.chromeOptions),r.backgroundGraphics),foregroundGraphics:sy(Vm(s.projectionRows,s.metadata,ly(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:A(t||o.colorBy||o.groupBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.workAccessor||o.stageAccessor||"stage"})}}},xy={frameType:"physics",layout:ay,buildProps:(e,t,i,r,o)=>{let n=r.size??[900,520],a=Kp({data:Array.isArray(e)?e:[],size:n,gates:o.gates,positiveProperties:o.positiveProperties,negativeProperties:o.negativeProperties,crashOffset:o.crashOffset,idAccessor:o.idAccessor,positiveAccessor:o.positiveAccessor,negativeAccessor:o.negativeAccessor,metricsAccessor:o.metricsAccessor,initialViability:o.initialViability,projectPlacement:o.projectPlacement,coreBody:o.coreBody,viability:o.viability});return{...r,config:a.config,initialSpawns:a.initialSpawns,projectionRows:[],backgroundGraphics:sy(ly(r,o,"showChrome")?rp.createElement(iy,{layout:a.layout,states:a.states,compact:!0===r.__compactMode}):void 0,r.backgroundGraphics),foregroundGraphics:sy(ly(r,o,"showProjection")?rp.createElement(oy,{layout:a.layout,states:a.states}):void 0,r.foregroundGraphics),bodyStyle:A(t||o.colorBy)}}},by={frameType:"physics",layout:ay,buildProps:(e,t,i,r,o)=>{let n=r.size??[900,520],a=mm({data:Array.isArray(e)?e:[],phases:Array.isArray(o.phases)?o.phases:[],products:Array.isArray(o.products)?o.products:void 0,outlets:Array.isArray(o.outlets)?o.outlets:void 0,events:Array.isArray(o.events)?o.events:void 0,idAccessor:o.idAccessor,labelAccessor:o.labelAccessor,categoryAccessor:o.categoryAccessor,amountAccessor:o.amountAccessor,metricsAccessor:o.metricsAccessor,initialStateAccessor:o.initialStateAccessor,metrics:o.metrics,size:n,seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange}),s=gm(a,"snapshot"===o.playback?pm(a,o.snapshotAt):a.duration).state,l=o.projection&&"object"==typeof o.projection?o.projection:{groupBy:"outlet",measure:"count"},c=Pg(s,l),u=l.measure??"count",d=Fm(c.map(e=>({id:e.key,label:e.label,count:e.count,secondary:"count"===u||"amount"===u?e.amount:Number(e.metrics[u]??0),secondaryLabel:"count"===u||"amount"===u?o.amountLabel??"amount":u,metadata:{amount:e.amount,metrics:e.metrics,status:e.status,outletId:e.outletId,category:e.category,productId:e.productId}}))),h={seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange},f=t??o.colorBy??"category",p=!1===o.showChrome?null:rp.createElement(Rm,{layout:a.layout,phases:a.phases,state:s,compact:n[0]<520||n[1]<360}),g=!1===o.showProjection?null:rp.createElement(Cm,{rows:c,layout:a.layout,projection:l,amountLabel:o.amountLabel});return{...r,config:a.config,initialSpawns:cm(s,a.layout,h),projectionRows:d,bodyStyle:e=>dy(e,s,f,o),getBodyLabel:e=>hy(e,s),renderBodySVG:wm,backgroundGraphics:sy(p,r.backgroundGraphics),foregroundGraphics:sy(g,r.foregroundGraphics)}}},vy={frameType:"physics",layout:ay,buildProps:(e,t,i,r,o)=>{let n=r.size??[760,420],a=Mp({nodes:Array.isArray(o.nodes)?o.nodes:[],links:Array.isArray(o.links)?o.links:Array.isArray(o.edges)?o.edges:Array.isArray(e)?e:[],nodeIdAccessor:o.nodeIdAccessor||"id",nodeXAccessor:o.nodeXAccessor||"x",nodeYAccessor:o.nodeYAccessor||"y",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",throughputAccessor:o.throughputAccessor||"value",pathAccessor:o.pathAccessor||"path",coordinateMode:o.coordinateMode||"auto",particleRate:o.particleRate??.16,maxParticles:o.maxParticles??180,particleRadius:o.particleRadius??4,flowSpeed:o.flowSpeed??90,pathConstraint:o.pathConstraint||"path",reducedMotion:!0,seed:o.seed??1,size:n});return{...r,config:a.config,initialSpawns:a.initialSpawns,initialSpawnPacing:a.initialSpawnPacing,projectionRows:a.projectionRows,foregroundGraphics:sy(Qm(a.metadata,{showNodeLabels:!1!==o.showNodeLabels,showSensors:!1!==o.showSensors,showStaticFlow:!1!==o.showStaticFlow}),r.foregroundGraphics),bodyStyle:A(t||o.colorBy||"source")}}},wy={frameType:"physics",layout:ay,buildProps:(e,t,i,r,o)=>{let n=r.size??[700,380],a=xr(r.theme),s=Fp({chartId:o.chartId,colorScheme:i,config:o.config,data:Array.isArray(e)?e:[],layout:o.layout,layoutConfig:o.layoutConfig,semantic:Y(a)??{},size:n,themeCategorical:a.colors.categorical,xExtent:o.xExtent,yExtent:o.yExtent});return{...r,config:s.config,initialSpawns:s.initialSpawns,initialSpawnPacing:s.initialSpawnPacing,projectionRows:[],bodyStyle:s.result.bodyStyle??A(t||o.colorBy),backgroundGraphics:sy(r.backgroundGraphics,s.result.backgroundOverlays),foregroundGraphics:sy(r.foregroundGraphics,s.result.overlays)}}};function ky(e){return e&&{fields:["nodeId"],..."object"==typeof e?e:{name:"string"==typeof e?e:"hover"}}}import*as Ay from"react";import{NetworkPerspectiveGround as Sy}from"./semiotic-network-placement.module.min.js";function My(e,t){let i=/* @__PURE__ */new Set,r=[t];for(;r.length;){let t=r.pop();if(i.has(t))continue;i.add(t);let o=Oe(e.children,t);Array.isArray(o)&&r.push(...o)}return i}function $y(e,t){let i=[],r=Oe(e.requiredChildren,t);if(void 0===r)return i;if(!Array.isArray(r))throw new Error("Invalid required-path dominator children");let o=[...r],n=/* @__PURE__ */new Set([t]);for(;o.length;){let t=o.pop(),r=Oe(e.requiredChildren,t);if("string"!=typeof t||n.has(t)||!Array.isArray(r))throw new Error("Invalid required-path dominator chain");n.add(t),i.push(t);for(let e of r)o.push(e)}return i.sort()}var _y=e=>{let{forest:t,selection:i,reading:r="organize"}=e.config,{atlas:o}=t,n=e.dimensions.plot,a=e.theme.semantic.text??"#273442",s=e.config.colors?.backbone??e.theme.semantic.textSecondary??"#8995a3",l=e.config.colors?.residual??e.theme.semantic.warning??"#b66631",c=e.config.colors?.required??e.theme.semantic.primary??"#3983a5",u=i?.analysisRevision===o.analysisRevision&&"directed-admitted"===i.relationScopeId&&o.source.nodes.some(e=>e.id===i.nodeId)?i.nodeId:void 0,d=/* @__PURE__ */new Map;for(let i of t.order)if(e.config.collapsedNodeIds?.includes(i)&&!d.has(i))for(let e of My(t,i))e!==i&&d.set(e,i);let h=t.order.filter(e=>!d.has(e)),f=new Map(o.source.nodes.map(e=>[e.id,e])),p=/* @__PURE__ */new Map;for(let e of d.values())p.set(e,(p.get(e)??0)+1);let g=/* @__PURE__ */new Map;for(let e of o.source.edges){let t=d.get(e.source)??e.source;if(t===(d.get(e.target)??e.target)&&(e.source!==t||e.target!==t)){let i=g.get(t);i?i.push(e.id):g.set(t,[e.id])}}let m=[...o.sections.sectionIds];o.source.nodes.some(e=>!e.sectionId)&&m.push("Unsectioned");let y=new Map(o.source.nodes.map(e=>[e.id,e.sectionId??"Unsectioned"])),x=m.map(e=>h.filter(t=>y.get(t)===e)),b=/* @__PURE__ */new Map,v=[],w=[],k=[],A=[],S=(e,t,i,r=11,o)=>v.push({x:e,y:t,text:i,fill:a,anchor:"middle",fontSize:r,...o?{anchorPoint:o}:{}}),M=Math.max(16,Math.min(94,n.width/Math.max(1,m.length)-20));x.forEach((e,t)=>{let i=n.x+n.width*(t+.5)/m.length;S(i,n.y+18,m[t],12),e.forEach((t,r)=>{let o=n.y+58+(r+.5)*Math.max(40,n.height-110)/Math.max(1,e.length);b.set(t,{x:i,y:o})})});for(let t of h){let i=b.get(t),r=f.get(t),n=p.get(t)??0,a=g.get(t)??[],d=o.requiredPaths?.unreachableNodeIds.includes(t),h=r.completeness&&"known"!==r.completeness,m=h?"Unknown upstream":d?"Unreachable from roots":void 0;w.push({type:"glyph",id:t,cx:i.x,cy:i.y,size:34,glyph:{viewBox:[M,34],parts:[{d:`M6,0 H${M-6} Q${M},0 ${M},6 V28 Q${M},34 ${M-6},34 H6 Q0,34 0,28 V6 Q0,0 6,0 Z`,stroke:"accent"}]},accent:u===t?c:h?l:s,style:{fill:e.theme.semantic.surface??"#fff",strokeWidth:u===t?2.5:1},label:t,datum:{...r,nodeId:t,kind:"dependency-node",sourceRevision:o.provenance.sourceRevision,analysisRevision:o.analysisRevision,relationScopeId:"directed-admitted",hiddenCount:n,internalEdgeIds:a},accessibleDatum:{node:t,section:y.get(t),status:m??"Admitted",hiddenCount:n,internalEdges:a.join(", ")}});let x=[i.x,i.y];S(i.x,i.y+4,n?`${t} +${n}`:t,12,x),m?S(i.x,i.y+30,m,9,x):n&&S(i.x,i.y+30,`${a.length} internal links`,9,x)}let $,_=new Set(t.forest.backboneEdgeIds),P=new Set(e.config.highlightedEdgeIds),L=/* @__PURE__ */new Map;for(let e of o.source.edges){let t=d.get(e.source)??e.source,i=d.get(e.target)??e.target;if(t===i&&(e.source!==t||e.target!==i))continue;let r=b.get(t),a=b.get(i),u=JSON.stringify([t,i]),h=12*(L.get(u)??0);L.set(u,(L.get(u)??0)+1);let f,p,g=_.has(e.id),y=P.has(e.id)?c:g?s:l,x=a.x>r.x,v=r.x+(x?M/2:-M/2),w=a.x+(x?-M/2:M/2),S=[...b.values()].filter(e=>e.x>Math.min(r.x,a.x)&&e.x<Math.max(r.x,a.x));if(t===i)f=`M${r.x-14},${r.y-17} C${r.x-35-h},${r.y-64-h} ${r.x+35+h},${r.y-64-h} ${r.x+14},${r.y-17}`,p=1;else if(r.x===a.x){let e=a.y>r.y?1:-1,t=r.x+e*M/2,i=t+e*(32+h);f=`M${t},${r.y} C${i},${r.y} ${i},${a.y} ${t},${a.y}`,p=1===e?2:0}else if(S.length){let e=Math.min(r.y,a.y,...S.map(e=>e.y))-17-26-h,t=(n.width/m.length-M)/2*(x?1:-1);f=`M${v},${r.y} C${v+t},${r.y} ${v},${e} ${v+t},${e} H${w-t} C${w},${e} ${w-t},${a.y} ${w},${a.y}`,p=x?0:2}else if(x){let e=(v+w)/2;f=`M${v},${r.y} C${e},${r.y-h} ${e},${a.y-h} ${w},${a.y}`,p=0}else{let e=Math.min(r.y,a.y)-48-h;f=`M${v},${r.y} C${v-25},${e} ${w+25},${e} ${w},${a.y}`,p=2}k.push({type:"curved",id:e.id,pathD:f,style:{stroke:y,strokeWidth:P.has(e.id)?3:g?1.3:2,fill:"none"},datum:{...e,sourceRevision:o.provenance.sourceRevision,analysisRevision:o.analysisRevision,relationScopeId:"directed-admitted",kind:"dependency-edge",edgeClass:g?"backbone":"residual"},accessibleDatum:{edge:e.id,source:e.source,target:e.target,display:g?"backbone":"residual cross-link"}});let $=t===i?r.x+14:r.x===a.x?r.x+(a.y>r.y?M/2:-M/2):w,I=t===i?r.y-17:a.y;A.push(Ay.createElement("path",{key:`arrow:${e.id}`,"data-dependency-edge":e.id,"data-source":e.source,"data-target":e.target,d:"M-6,-3 L0,0 L-6,3",fill:"none",stroke:y,transform:`translate(${$},${I}) rotate(${90*p})`}))}if("required-paths"===r&&u){let e=$y(t,u),i=[...new Set(e.map(e=>d.get(e)??e))].filter(e=>e!==u&&b.has(e));if(i.length){let e=i.map(e=>b.get(e)),t=Math.max(...e.map(e=>e.x))+M/2+8,r=Math.min(...e.map(e=>e.y))-23,o=Math.max(...e.map(e=>e.y))+23;$={x:t-7,y:r,width:7,height:o-r,z:"top"},A.push(Ay.createElement("path",{key:"required-bracket",d:`M${t-7},${r} H${t} V${o} H${t-7}`,fill:"none",stroke:c,strokeWidth:2,"data-kind":"dominator-bracket"}))}S(n.x+n.width/2,n.y+n.height-16,e.length?`${u} lies on all admitted paths to ${e.join(", ")}${"incomplete"===o.requiredPaths?.status?" · incomplete scope":""}`:o.requiredPaths?`${u}: no other required targets in the admitted graph`:"Required paths have not been prepared")}let I=new Map(w.map(e=>[e.id,e.datum]));return{sceneNodes:w,sceneEdges:k,labels:v,restyle:(e,t)=>({opacity:t?.isActive&&!t.predicate(e.datum)?.2:1}),restyleEdge:(e,t)=>({opacity:t?.isActive&&![e.datum,I.get(String(e.datum?.source)),I.get(String(e.datum?.target))].some(e=>e&&t.predicate(e))?.2:1}),overlays:Ay.createElement("g",{"aria-hidden":!0},Ay.createElement(Sy,{z:"top"},...A)),perspective:"manual",...e.perspective&&$?{perspectiveBounds:[$]}:{}}};import*as Py from"react";import{NetworkPerspectiveGround as Ly}from"./semiotic-network-placement.module.min.js";function Iy(e,t,i){if(!Number.isFinite(t)||!Number.isFinite(i)||t<360||i<300)throw new Error("Circuit geometry needs at least 360 × 300 pixels");let r=[...e.atlas.sections.sectionIds];e.atlas.source.nodes.some(e=>!e.sectionId)&&r.push("Unsectioned");let o=J({width:t,height:i-110,padX:22,padY:70,stages:r.map(e=>({id:e})),shape:"lane"}),n=new Map(e.atlas.source.nodes.map(e=>[e.id,e.sectionId??"Unsectioned"])),a=o.stages.flatMap(t=>{let r=e.order.filter(e=>n.get(e)===t.id),o=(i-235)/Math.max(1,r.length);if(r.length&&o<78)throw new Error("Increase circuit height to keep every module readable");return r.map((i,r)=>{let n=e.modules.find(e=>e.nodeId===i),a=Math.max(68,Math.min(142,t.width-56)),s=Math.min(68,o-10),l=t.x-a/2,c=95+(r+.5)*o-s/2;return{module:n,x:l,y:c,width:a,height:s,queue:{x:l+8,y:c+s-8,width:a-16,height:4},sensor:{x:l+a-5,y:c+s/2-4,width:8,height:8}}})}),s=new Map(a.map(e=>[e.module.nodeId,e])),l=new Set(e.residualEdgeIds),c=0,u=e.atlas.source.edges.map(e=>{let t,i=s.get(e.source),o=s.get(e.target),a=o.x>i.x,u=o.x===i.x,d=(t,i)=>{let r=t.module.ports.filter(e=>e.direction===i),o=r.findIndex(t=>t.edgeId===e.id);return t.y+10+(o+.5)*(t.height-20)/r.length},h={x:i.x+(a||u?i.width:0),y:d(i,"out")},f={x:o.x+(a?0:o.width),y:d(o,"in")};if(u){let r=h.x+18+5*c++;t=e.source===e.target?[h,{x:r,y:h.y},{x:r,y:i.y-15},{x:f.x-8,y:i.y-15},{x:f.x-8,y:i.y}]:[h,{x:r,y:h.y},{x:r,y:f.y},f]}else if(!a||Math.abs(r.indexOf(n.get(e.source))-r.indexOf(n.get(e.target)))>1){let e=a?1:-1,i=62+7*c++;t=[h,{x:h.x+16*e,y:h.y},{x:h.x+16*e,y:i},{x:f.x-16*e,y:i},{x:f.x-16*e,y:f.y},f]}else{let e=(h.x+f.x)/2;t=[h,{x:e,y:h.y},{x:e,y:f.y},f]}return{edgeId:e.id,source:e.source,target:e.target,residual:l.has(e.id),points:t,pathD:Hm(t)}});return{width:t,height:i,modules:a,routes:u,sections:o.stages.map(e=>({id:e.id,x:e.x})),history:{x:42,y:i-88,width:t-84,height:46}}}function Ry(e,t){let i=e.slice(1).map((t,i)=>Math.hypot(t.x-e[i].x,t.y-e[i].y)),r=i.reduce((e,t)=>e+t,0),o=Math.max(0,Math.min(1,t))*r;for(let t=0;t<i.length;t++){if(o<=i[t]){let r=i[t]?o/i[t]:0;return{x:e[t].x+(e[t+1].x-e[t].x)*r,y:e[t].y+(e[t+1].y-e[t].y)*r}}o-=i[t]}return e[e.length-1]}import*as Ty from"react";var Cy=Ty.createElement,Ny={observed:"#387e98",modeled:"#946344",residual:"#a56537",muted:"#778796",alarm:"#bb5149"};function Fy(e,t={}){return{observed:t.observed??e.info??e.primary??Ny.observed,modeled:t.modeled??e.secondary??Ny.modeled,residual:t.residual??e.warning??Ny.residual,muted:t.muted??e.textSecondary??Ny.muted,alarm:t.alarm??e.danger??Ny.alarm}}var Dy=e=>null===e?"unmeasured":e>=1e6?`${Number((e/1e6).toFixed(2))}m`:e>=1e3?`${Number((e/1e3).toFixed(1))}k`:Number.isInteger(e)?String(e):String(Number(e.toPrecision(3))),Ey={stage:"M-5,0 H5",distributor:"M-5,0 H0 M0,0 L6,-5 M0,0 H6 M0,0 L6,5",queue:"M-6,-5 V5 H6 V-5 M-3,2 H3",retry:"M-5,2 A5,5 0 1,1 4,3 M4,-1 V4 H0","join-all":"M-6,-4 L0,0 L6,0 M-6,4 L0,0 M2,-5 V5",selector:"M-6,-4 L0,0 L6,0 M-6,4 L0,0 M1,-4 L5,0 L1,4",dependency:"M-5,-5 H5 V5 H-5 Z M-2,-2 L2,2 M-2,2 L2,-2",junction:"M0,-6 L6,0 L0,6 L-6,0 Z"},zy={stage:"stage",distributor:"distributor",queue:"FIFO queue",retry:"retry episode","join-all":"all-member join",selector:"first success",dependency:"dependency gate",junction:"unclassified junction"};function Oy(e,t,i,r,o,n=Ny,a){let s=Object.values(t.entry.nodes).reduce((e,t)=>Math.max(e,t.queued??0),0)||1;return e.modules.map(e=>{let{module:l,x:c,y:u,width:d,height:h,queue:f}=e,p=t.entry.nodes[l.nodeId],g=o===l.nodeId?i:(p.queued??0)>0?n.alarm:n.muted,m=c+d/2,y="records"===l.semantics.unit?"rec":"attempts"===l.semantics.unit?"att":"roots",x=null!==p.capacity?`${Dy(p.completions)} / ${Dy(p.capacity)} ${y}/s`:null!==p.completions?`${Dy(p.completions)} ${y}/s complete`:`${Dy(p.arrivals)} ${y}/s offered`;return Cy("g",{key:l.id,"data-circuit-module":l.nodeId,"data-module-kind":l.kind,opacity:a?.(l.nodeId),"data-queued":p.queued??"unmeasured"},Cy("rect",{x:c,y:u,width:d,height:h,fill:"none",stroke:g,strokeWidth:o===l.nodeId?2.5:1}),Cy("path",{d:Ey[l.kind],transform:`translate(${c+10},${u+12})`,stroke:g,fill:"none",strokeWidth:1.4}),Cy("text",{x:m+5,y:u+16,textAnchor:"middle",fontSize:d<110?9:11,fontWeight:600,fill:r},l.semantics.label),Cy("text",{x:m,y:u+28,textAnchor:"middle",fontSize:8,fill:r},zy[l.kind]),Cy("text",{x:m,y:u+41,textAnchor:"middle",fontSize:d<110?7:9,fill:r},x),Cy("text",{x:m,y:u+h-13,textAnchor:"middle",fontSize:8,fill:r},`Queue ${Dy(p.queued)}`),null!==p.queued?Cy("rect",{...f,width:f.width*p.queued/s,fill:g,"data-circuit-gauge":"queue"}):null,Cy("rect",{...e.sensor,fill:i,"data-circuit-sensor":l.nodeId}),l.semantics.dependencyNodeIds?.length?Cy("text",{x:m,y:u-8,fontSize:8,textAnchor:"middle",fill:r,"data-circuit-dependency":l.nodeId},`Requires ${l.semantics.dependencyNodeIds.join(", ")}`):null)})}function jy(e,t,i,r,o,n){let{history:a}=e,s=e.modules.find(e=>e.module.nodeId===n)?.module,l="records"===t.unit?"queued":"attempts",c=t.entries.map(e=>s?e.nodes[s.nodeId]["records"===t.unit?"queued":"arrivals"]:e.totals[l]),u=c.reduce((e,t)=>Math.max(e,t??0),0)||1,d=t.entries[0].at,h=t.entries[t.entries.length-1].at,f=h>d?h-d:1,p=e=>a.x+(e-d)/f*a.width,g="",m=!1;for(let[e,i]of t.entries.entries()){if(null===c[e]){m=!1;continue}let t=a.y+a.height-c[e]/u*a.height;g+=`${m?" H":"M"}${p(i.at)}${m?` V${t}`:`,${t}`}`,m=!0}return Cy("g",{"data-circuit-history":l,"data-history-module":s?.nodeId},Cy("text",{x:a.x,y:a.y-9,fill:o,fontSize:10},s?`${s.semantics.label} · ${"queued"===l?`queued ${s.semantics.unit}`:`offered ${s.semantics.unit}/s`} · aggregate observations`:"queued"===l?"Queued records · aggregate observations":"Offered attempts/s · aggregate observations"),Cy("path",{d:g,fill:"none",stroke:r,strokeWidth:2}),Cy("line",{x1:p(i.observedAt),x2:p(i.observedAt),y1:a.y,y2:a.y+a.height,stroke:o,strokeDasharray:"3 3","data-circuit-cursor":i.observedAt}),...t.entries.map(e=>Cy("text",{key:e.id,x:p(e.at),y:a.y+a.height+14,textAnchor:"middle",fontSize:9,fill:o},`${e.at}s`)))}function Wy(e,t,i,r){return{id:r.nodeId,nodeId:r.nodeId,kind:"circuit-module",moduleKind:r.kind,label:r.semantics.label,unit:r.semantics.unit,sourceRevision:t.sourceRevision,analysisRevision:e.atlas.analysisRevision,relationScopeId:"directed-admitted",editionId:t.id,editionKind:t.kind,synthetic:t.synthetic,mode:i.mode,observedAt:i.observedAt,...i.entry.nodes[r.nodeId]}}var By=e=>null===e?"unmeasured":String(e);function Yy(e,t,i,r){return[...t.modules.map(t=>{let o=Wy(e,i,r,t.module);return{id:o.id,bodyId:o.id,datum:o,x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height,shape:"rect",label:`${o.label}: ${o.moduleKind}`,description:`${o.label}. ${i.kind} at ${r.observedAt}s. Arrivals ${By(o.arrivals)} ${o.unit}/s; completions ${By(o.completions)} ${o.unit}/s; installed capacity ${By(o.capacity)} ${o.unit}/s; queue ${By(o.queued)} ${o.unit}. Measurement status: ${o.status}. Individual timings unavailable.`,group:"circuit modules"}}),...t.routes.map(t=>{let o=r.entry.flows.find(e=>e.edgeId===t.edgeId),n=t.points[Math.floor(t.points.length/2)];return{id:`pipe:${t.edgeId}`,x:n.x,y:n.y,shape:"path",pathData:t.pathD,label:`${t.source} → ${t.target}: ${By(o.perSecond)} ${o.unit}/s`,description:`Original edge ${t.edgeId}. ${t.residual?"Residual link":"Display backbone"}. ${i.kind} at ${r.observedAt}s; transferred volume ${By(o.perSecond)} ${o.unit}/s.`,group:"original pipes",datum:{id:t.edgeId,kind:"circuit-pipe",source:t.source,target:t.target,analysisRevision:e.atlas.analysisRevision,sourceRevision:i.sourceRevision,relationScopeId:"directed-admitted",editionId:i.id,editionKind:i.kind,observedAt:r.observedAt,...o}}})]}var Gy=Py.createElement,Xy=e=>qy(e,!1),Vy=e=>qy(e,!0);function qy(e,t){let{circuit:i,edition:r,reading:o,selection:n}=e.config;if(o.editionId!==r.id||r.analysisRevision!==i.atlas.analysisRevision)throw new Error("Circuit render inputs must share an edition and analysis revision");let a=Iy(i,e.dimensions.width,e.dimensions.height),s=e.theme.semantic.text??"#273442",l=e.theme.semantic.surface??"#fff",c=Fy(e.theme.semantic,e.config.colors),u="modeled"===r.kind?c.modeled:c.observed,d={width:a.width,height:a.height,viewBox:`0 0 ${a.width} ${a.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},"aria-hidden":!0},h=n?.analysisRevision===i.atlas.analysisRevision&&"directed-admitted"===n.relationScopeId?n.nodeId:void 0,f=o.entry.flows.reduce((e,t)=>Math.max(e,t.perSecond??0),0)||1,p=new Map(o.entry.flows.map(e=>[e.edgeId,e])),g=new Map(i.modules.map(e=>[e.nodeId,Wy(i,r,o,e)])),m=t=>e.config.layoutSelection?.isActive&&!e.config.layoutSelection.predicate(g.get(t))?.2:1,y=Math.max(0,Math.min(200,Math.floor(e.config.particleBudget??24))),x=ze(e.config.placementSeed??1),b=a.routes.filter(e=>(p.get(e.edgeId)?.perSecond??0)>0),v=e.config.reducedMotion?[]:Array.from({length:b.length?y:0},(e,t)=>{let i=b[t%b.length],r=Ry(i.points,(x()+o.requestedTime/10)%1);return Gy("circle",{key:`cue:${t}`,cx:r.x,cy:r.y,r:2.3,fill:s,opacity:Math.max(m(i.source),m(i.target)),"data-circuit-particle":i.edgeId})}),w=a.modules.map(e=>({id:e.module.nodeId,x:e.x+e.width/2,y:e.y+e.height/2,fixedPosition:{x:e.x+e.width/2,y:e.y+e.height/2},shape:{type:"aabb",width:e.width,height:e.height},bodyCollisions:!1,datum:Wy(i,r,o,e.module)})),k=[],A=Yy(i,a,r,o),S=t?new Map(A.map(e=>[e.id,e])):null,M={bodies:w,config:{kernel:{gravity:{x:0,y:0},seed:e.config.placementSeed??1,sleepAfter:.01},bodyBudget:!1,bodyLimit:w.length,eviction:!1,sediment:!1,settleStepLimit:4},bodyStyle:e=>({fill:l,stroke:c.muted,strokeWidth:1,opacity:m(e.id)}),colliders:a.modules.flatMap(e=>ke({idPrefix:`queue:${e.module.nodeId}`,left:e.queue.x,right:e.queue.x+e.queue.width,top:e.queue.y,bottom:e.queue.y+e.queue.height,thickness:1,openEnds:!0})),sensors:a.modules.map(e=>({id:`sensor:${e.module.nodeId}`,shape:{type:"aabb",x:e.sensor.x+e.sensor.width/2,y:e.sensor.y+e.sensor.height/2,width:e.sensor.width,height:e.sensor.height}})),semanticItems:A,backgroundOverlays:Gy("svg",d,...a.routes.map(i=>{let r=p.get(i.edgeId),o=i.points[i.points.length-1],n=i.points[i.points.length-2],l=a.modules.find(e=>e.module.nodeId===i.source),d=a.modules.find(e=>e.module.nodeId===i.target),h=l.module.ports.filter(e=>"out"===e.direction).length<d.module.ports.filter(e=>"in"===e.direction).length,g=h?i.points[0]:o,y=h?g.x>=l.x+l.width:g.x>d.x,x=180*Math.atan2(o.y-n.y,o.x-n.x)/Math.PI,b=e.config.highlightedEdgeIds?.includes(i.edgeId),v=b?s:i.residual?c.residual:u,w="records"===r.unit?"rec":"attempts"===r.unit?"att":"roots";if(t){let e=S.get(`pipe:${i.edgeId}`);k.push({type:"curved",pathD:i.pathD,datum:e.datum,id:i.edgeId,label:e.label,accessibility:{label:`${e.label}. ${e.description}`},style:{stroke:v,strokeWidth:null===r.perSecond?1.5:1+r.perSecond/f*7,strokeDasharray:null===r.perSecond?"4 3":void 0,fill:"none",opacity:(0===r.perSecond?.35:.75)*Math.max(m(i.source),m(i.target))}})}return Gy("g",{key:i.edgeId,"data-circuit-edge":i.edgeId,opacity:Math.max(m(i.source),m(i.target)),"data-source":i.source,"data-target":i.target,"data-flow":r.perSecond??"unmeasured","data-highlighted":b||void 0,"data-unit":`${r.unit}/s`},Gy("title",null,`${i.edgeId}: ${i.source} → ${i.target}; ${r.perSecond??"unmeasured"} ${r.unit}/s`),!t&&Gy("path",{d:i.pathD,stroke:v,strokeWidth:null===r.perSecond?1.5:1+r.perSecond/f*7,strokeDasharray:null===r.perSecond?"4 3":void 0,strokeLinejoin:"round",fill:"none",opacity:0===r.perSecond?.35:.75}),Gy("path",{d:"M-5,-3 L0,0 L-5,3",transform:`translate(${o.x},${o.y}) rotate(${x})`,fill:"none",stroke:v}),Gy("text",{x:g.x+(y?5:-5),y:g.y-7,textAnchor:y?"start":"end",fontSize:8,fill:s},`${null===r.perSecond?"?":Dy(r.perSecond)} ${w}/s`))})),overlays:Gy("svg",{...d,"data-circuit-edition":r.kind,"data-circuit-time":o.observedAt},...a.sections.map(e=>Gy("text",{key:e.id,x:e.x,y:43,textAnchor:"middle",fontSize:11,fill:s},e.id)),...Oy(a,o,u,s,h,c,m),...v,jy(a,r,o,u,s,h),Gy("text",{x:a.width/2,y:a.height-8,textAnchor:"middle",fontSize:9,fill:s},`${"modeled"===r.kind?"Modeled":"Observed"} · ${o.observedAt}s · pipe width = transferred volume/s · individual timings unavailable`))};if(!t)return M;let $=e=>e.props.children;return{sceneNodes:w.map(e=>{let t=S.get(e.id);return{type:"rect",id:e.id,x:e.x-e.shape.width/2,y:e.y-e.shape.height/2,w:e.shape.width,h:e.shape.height,datum:e.datum,label:t.label,accessibility:{label:`${t.label}. ${t.description}`},style:{fill:l,stroke:c.muted,strokeWidth:1,opacity:m(e.id)}}}),sceneEdges:k,overlays:Gy(Ly,{z:"top"},$(M.backgroundOverlays),$(M.overlays)),perspective:"manual",perspectiveBounds:[{x:0,y:0,width:a.width,height:a.height,z:"top"}]}}import{scaleLinear as Hy}from"d3-scale";function Uy(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function Zy(e){return e.map(e=>({pointId:e.id,x:e.x,y:e.y,r:Math.max(1,Uy(e))}))}function Qy(e){let{width:t,height:i,pointNodes:r=[],data:o}=e;return{scales:{x:Hy().domain([0,Math.max(1,t)]).range([0,Math.max(1,t)]),y:Hy().domain([0,Math.max(1,i)]).range([0,Math.max(1,i)])},width:t,height:i,frameType:"network",pointNodes:r,data:o,xAccessor:"x",yAccessor:"y"}}function Ky(e){return e?.length?e.map(e=>null!=e.pointId||null==e.bodyId?e:{...e,pointId:String(e.bodyId)}):e}var Jy=()=>null;function ex({width:e=Xt.width,height:t=Xt.height,title:i,description:r,summary:o,accessibleTable:n=!0,chartId:a,className:s,onObservation:l,linkedHover:c,annotations:u,frameProps:d,perspective:h,networkFrameProps:f,linkedSelection:p,onSelectNode:g,...m}){return{key:JSON.stringify([m.circuit.atlas.analysisRevision,m.circuit.order,m.circuit.backboneEdgeIds,e,t]),data:m.circuit.modules.map(e=>Wy(m.circuit,m.edition,m.reading,e)),layout:Xy,layoutConfig:m,width:e,height:t,chartId:a,className:s,onObservation:l,linkedHover:ky(c),annotations:u,frameProps:d,paused:!0,title:i??m.edition.label,description:r??`${m.edition.label}. ${m.edition.kind} aggregate interval tape at ${m.reading.observedAt} seconds. Pipe widths encode transferred volume per second in their labeled units; module readouts separate completions, capacity and queue stock. Individual timings are unavailable.`,summary:o??m.edition.assumptions.join(" "),accessibleTable:n,tooltip:!!(a||c||l)&&Jy}}function tx({nodes:e,edges:t,restyle:i,restyleEdge:r,baseStyles:o,selection:n}){let a=!(!i&&!r);if(i)for(let t of e){let e=o.get(t)??t.style,r=i(t,n);t.style=r?{...e,...r}:e}if(r)for(let e of t){let t=o.get(e)??e.style,i=r(e,n);e.style=i?{...t,...i}:t}return a}import*as ix from"react-dom/server";var rx=/* @__PURE__ */Object.create(null);function ox(e,t){rx[e]=t}function nx(e){return rx[e]}function ax(e,t){var i=e.get(t);if(!i)throw new Error("missing: "+t);return i}function sx(e,t,i){let r=e.length,o=Array.from({length:r},()=>[]),n=Array.from({length:r},()=>[]),a=new Int32Array(r),s=new Int32Array(r),l=new Float64Array(r),c=new Float64Array(t.length),u=new Int32Array(r),d=e.map(e=>{let t=i(e);return`${typeof t}:${String(t)}`}),h=0;for(let e of t)e.source.index!==e.target.index&&Number.isFinite(e.value)&&(h=Math.max(h,e.value));let f=(e,t)=>d[e]<d[t]?-1:d[e]>d[t]?1:0;t.map((e,t)=>t).sort((e,i)=>f(t[e].source.index,t[i].source.index)||f(t[e].target.index,t[i].target.index)||t[e].value-t[i].value).forEach(e=>{let i=t[e],r=i.source.index,u=i.target.index;if(r===u)return;let d=Number.isFinite(i.value)&&h>0?Math.max(0,i.value)/h:0;c[e]=d,n[r].push(e),o[u].push(e),s[r]++,a[u]++,l[r]+=d,l[u]-=d});let p=e.map(e=>e.index),g=Int32Array.from(p),m=e=>0===s[e]?2:0===a[e]?1:0,y=(e,t)=>{let i=m(e),r=m(t);return i!==r?i>r:0===i&&l[e]!==l[t]?l[e]>l[t]:d[e]<d[t]||d[e]===d[t]&&e<t},x=(e,t)=>{let i=p[e];p[e]=p[t],p[t]=i,g[p[e]]=e,g[i]=t},b=(e,t=!1)=>{let i=g[e];for(;!t&&i>0;){let t=i-1>>>1;if(!y(e,p[t]))break;x(i,t),i=t}for(;2*i+1<p.length;){let t=2*i+1;if(t+1<p.length&&y(p[t+1],p[t])&&t++,!y(p[t],e))break;x(i,t),i=t}};for(let e=(p.length>>>1)-1;e>=0;e--)b(p[e],!0);let v=0,w=r-1;for(;p.length;){let e=p[0];u[e]=0===s[e]?w--:v++;let i=p.pop();g[e]=-1,p.length&&(p[0]=i,g[i]=0,b(i));for(let i of n[e]){let e=t[i].target.index;g[e]<0||(a[e]--,l[e]+=c[i],b(e))}for(let i of o[e]){let e=t[i].source.index;g[e]<0||(s[e]--,l[e]-=c[i],b(e))}}return u}function lx(e){return e.y0-e.y1>0?"up":"down"}function cx(e,t){return t(e.source)==t(e.target)}function ux(e){return e.target.x0-e.source.x1}function dx(e,t){var i=fx(e),r=ux(t)/Math.tan(i);return"up"==lx(e)?e.y1-r:e.y1+r}function hx(e,t){var i=fx(e),r=ux(t)/Math.tan(i);return"up"==lx(e)?e.y1+r:e.y1-r}function fx(e){var t=Math.abs(e.y1-e.y0),i=Math.abs(e.target.x0-e.source.x1);return Math.atan(i/t)}function px(e){return mx(e.source)}function gx(e){return mx(e.target)}function mx(e){return(e.y0+e.y1)/2}function yx(e){return e.virtual?0:e.value}function xx(e,t){var i=0;e.sourceLinks.forEach(function(e){i=e.circular&&!cx(e,t)?i+1:i});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!cx(e,t)?r+1:r}),i+r}function bx(e){return e.target.depth}function vx(e,t){return e.sourceLinks.length?e.depth:t-1}function wx(e,t){return e.y0-t.y0}function kx(e,t){return t.y0-e.y0}function Ax(e,t){return e.y1-t.y1}function Sx(e,t){return t.y1-e.y1}function Mx(e,t){return _x(e.source,t.source)||e.index-t.index}function $x(e,t){return _x(e.target,t.target)||e.index-t.index}function _x(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Px(e,t){return Lx(e)==Lx(t)?"bottom"==e.circularLinkType?kx(e,t):wx(e,t):Lx(t)-Lx(e)}function Lx(e){return e.target.column-e.source.column}function Ix(e,t){let i=e;return i.nodes.forEach(function(e){e.y+(e.y1-e.y0)>i.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-i.y1));var t=e.sourceLinks.slice().sort(function(e,t){return e.index-t.index});t.length>1&&t.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Tx(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var i=dx(t,e);return e.y1-i}if(t.target.column>e.target.column)return dx(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var r=e.y0;t.forEach(function(e){e.y0=r+e.width/2,r+=e.width});for(var o=0,n=t.length-1;n>=0;n--){var a=t[n];"bottom"==a.circularLinkType&&(a.y0=e.y1-o-a.width/2),o+=a.width}}),i}function Rx(e,t){let i=e;return i.nodes.forEach(function(e){var t=e.targetLinks.slice().sort(function(e,t){return e.index-t.index});t.length>1&&t.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Tx(e,t))return e.y0-t.y0;if(t.source.column<e.source.column){var i=hx(t,e);return e.y0-i}if(e.source.column<t.source.column)return hx(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;t.forEach(function(e){e.y1=i+e.width/2,i+=e.width});for(var r=0,o=t.length-1;o>=0;o--){var n=t[o];"bottom"==n.circularLinkType&&(n.y1=e.y1-r-n.width/2),r+=n.width}}),i}function Tx(e,t){return Cx(e)==Cx(t)}function Cx(e){return e.y0-e.y1>0?"up":"down"}import{min as Nx}from"d3-array";var Fx=class{constructor(e){this.size=e,this.maximum=new Float64Array(4*e),this.floor=new Float64Array(4*e)}query(e,t){let i=(r,o,n)=>{if(e<=o&&n<=t)return this.maximum[r];let a=o+n>>>1;return Math.max(this.floor[r],e<=a?i(2*r,o,a):0,t>a?i(2*r+1,a+1,n):0)};return i(1,0,this.size-1)}reserve(e,t,i){let r=(o,n,a)=>{if(this.maximum[o]=Math.max(this.maximum[o],i),e<=n&&a<=t)return void(this.floor[o]=Math.max(this.floor[o],i));let s=n+a>>>1;e<=s&&r(2*o,n,s),t>s&&r(2*o+1,s+1,a)};r(1,0,this.size-1)}};function Dx(e){var t=e.source.x1,i=e.y0,r=e.target.x0,o=e.y1,n=(t+r)/2;return"M"+t+","+i+"C"+n+","+i+" "+n+","+o+" "+r+","+o}function Ex(e,t,i,r,o){let n=e;n.links.forEach(function(e){e.circular&&(e._circularWidth=e.width,e._circularStub=!1)});var a=Nx(n.links,function(e){return e.source.y0});n.links.forEach(function(e){e.circular&&(e.circularPathData={})});var s=n.links.filter(function(e){return e.circular}),l=/* @__PURE__ */new Map,c=/* @__PURE__ */new Map;s.forEach(function(e){l.set(e.source,(l.get(e.source)||0)+1),c.set(e.target,(c.get(e.target)||0)+1)});var u=new Set(s.filter(function(e){return cx(e,t)&&1===l.get(e.source)&&1===c.get(e.target)}));return["top","bottom"].forEach(function(e){var t=s.filter(function(t){return t.circularLinkType===e});zx(t.slice(),u,i),["source","target"].forEach(function(o){var n=/* @__PURE__ */new Map;t.forEach(function(e){var t=e[o].column;n.has(t)||n.set(t,[]),n.get(t).push(e)}),n.forEach(function(t){t.sort("source"===o?"bottom"===e?kx:wx:"bottom"===e?Sx:Ax);var n=0,a="source"===o?"right":"left";t.forEach(function(e,t){e.circularPathData[a+"SmallArcRadius"]=r+e._circularWidth/2+n,e.circularPathData[a+"LargeArcRadius"]=r+e._circularWidth/2+t*i+n,n+=e._circularWidth})})})}),n.links.forEach(function(e){e.circular&&(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,u.has(e)?(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)):"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(n.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius),e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer),e.circular?e.path=Ox(e):e.path=Dx(e)}),n}function zx(e,t,i){if(0!==e.length){e.sort(Px);var r=Array.from(new Set(e.flatMap(function(e){return[e.source.column,e.target.column]}))).sort(function(e,t){return e-t}),o=new Map(r.map(function(e,t){return[e,t]})),n=new Fx(r.length);e.forEach(function(e){var r=o.get(e.source.column),a=o.get(e.target.column),s=Math.min(r,a),l=Math.max(r,a),c=t.has(e)?0:n.query(s,l);e.circularPathData.verticalBuffer=c+e._circularWidth/2,n.reserve(s,l,c+e._circularWidth+i)})}}function Ox(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}import{min as jx,max as Wx,sum as Bx,mean as Yx,group as Gx,groups as Xx}from"d3-array";function Vx(e){return function(){return e}}function qx(e){return e.index}function Hx(e){return e.nodes}function Ux(e){return e.links}function Zx(e,t){var i=/* @__PURE__ */new Map;return Gx(e,t).forEach(function(e,t){i.set(t,e[0])}),i}function Qx(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var i=Zx(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=ax(i,r)),"object"!=typeof o&&(o=e.target=ax(i,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}function Kx(e,t,i){var r=0,o=null==t?sx(e.nodes,e.links,i):null;e.nodes.forEach(function(e){delete e.circularLinkType}),e.links.forEach(function(e){delete e.circularLinkID,delete e.circularLinkType,delete e.circularPathData,delete e._circularWidth,delete e._circularStub,e.circular=o?o[e.source.index]>=o[e.target.index]:!(t(e.source)<t(e.target)),e.circular&&(e.circularLinkID=r++)})}function Jx(e,t){var i=0,r=0;e.links.forEach(function(e){e.circular&&(e.source.circularLinkType||e.target.circularLinkType?e.circularLinkType=e.source.circularLinkType?e.source.circularLinkType:e.target.circularLinkType:e.circularLinkType=i<r?"top":"bottom","top"==e.circularLinkType?i++:r++,e.source.circularLinkType=e.circularLinkType,e.target.circularLinkType=e.circularLinkType)}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),cx(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}function eb(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(Bx(e.sourceLinks,yx),Bx(e.targetLinks,yx)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}function tb(e,t,i){if(null!=t&&e.nodes.length){e.nodes.sort(function(e,i){return t(e)<t(i)?-1:1});var r=0,o=t(e.nodes[0]);e.nodes.forEach(function(e){r=t(e)==o?r:r+1,o=t(e)==o?o:t(e),e.column=r})}var n=new Int32Array(e.nodes.length),a=[],s=1;e.nodes.forEach(function(e){e.depth=e.height=0,e.targetLinks.forEach(function(t){t.circular||n[e.index]++}),0===n[e.index]&&a.push(e)});for(var l=0;l<a.length;l++){var c=a[l];s=Math.max(s,c.depth+1),c.sourceLinks.forEach(function(e){e.circular||(e.target.depth=Math.max(e.target.depth,c.depth+1),0===--n[e.target.index]&&a.push(e.target))})}for(l=a.length-1;l>=0;l--)(c=a[l]).sourceLinks.forEach(function(e){e.circular||(c.height=Math.max(c.height,e.target.height+1))});e.nodes.forEach(function(e){e.column=null==t?i(e,s):e.column})}function ib(e,t,i){var r=Xx(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=jx(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/Bx(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var n=Wx(e.nodes,function(e){return e.column});n>0?e.nodes.forEach(function(t){t.x0=e.x0+t.column*((e.x1-e.x0-i)/n),t.x1=t.x0+i}):e.nodes.forEach(function(t){t.x0=e.x0,t.x1=t.x0+i})}function rb(e){var t=0,i=0;return e.targetLinks.forEach(function(e){if(!e.circular){var r=e.value||1;i+=mx(e.source)*r,t+=r}}),e.sourceLinks.forEach(function(e){if(!e.circular){var r=e.value||1;i+=mx(e.target)*r,t+=r}}),t>0?i/t:NaN}function ob(e,t,i){var r=Xx(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,n){var a=o.length;if(t)o.sort(t);else if(n>0){var s=/* @__PURE__ */new Map;o.forEach(function(e,t){var i=rb(e);s.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var i=s.get(e),r=s.get(t),o=i.bc,n=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType||"bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(n)?isNaN(o)?isNaN(n)?i.idx-r.idx:1:-1:o-n})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?xx(t,i)-xx(e,i):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==xx(t,i)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+o,t.y1=t.y0+t.value*e.ky)})})}function nb(e,t,i,r,o,n){var a=Xx(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var s=1,l=n;l>0;--l)c(s*=.99,i),u();function c(t,i){var r=a.length;a.forEach(function(o){var n=o.length,a=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&xx(o,i)>0){var l=Yx(o.sourceLinks,gx),c=Yx(o.targetLinks,px),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-mx(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==a&&1==n)s=o.y1-o.y0,o.y0=e.y1/2-s/2,o.y1=e.y1/2+s/2;else if(a==r-1&&1==n)s=o.y1-o.y0,o.y0=e.y1/2-s/2,o.y1=e.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var h=Yx(o.sourceLinks,gx),f=Yx(o.targetLinks,px),p=((h&&f?(h+f)/2:h||f)-mx(o))*t;o.y0+=p,o.y1+=p}})})}function u(){a.forEach(function(i){var n,a,s,l=e.y0,c=i.length;for(t?i.sort(t):i.sort(_x),s=0;s<c;++s)(a=l-(n=i[s]).y0)>0&&(n.y0+=a,n.y1+=a),l=n.y1+r;if((a=l-r-e.y1)>0)for(l=n.y0-=a,n.y1-=a,s=c-2;s>=0;--s)(a=(n=i[s]).y1+o-l)>0&&(n.y0-=a,n.y1-=a),l=n.y0})}}function ab(e){e.nodes.forEach(function(e){e.sourceLinks.sort($x),e.targetLinks.sort(Mx)}),e.nodes.forEach(function(e){var t=e.y0,i=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=i+e.width/2,i+=e.width)})})}function sb(e){var t=e.nodes,i=e.links,r=!1,o=!1;if(i.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-n)/(a-n)*(e.y1-e.y0)+e.y0};var n=jx(t,function(e){return e.y0}),a=Wx(t,function(e){return e.y1}),s=a-n,l=(e.y1-e.y0)/s;l<1?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),i.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,i=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+i}),e.targetLinks.forEach(function(e){e.y1=e.y1+i})})}}function lb(){var e=0,t=0,i=1,r=1,o=24,n=8,a=null,s=qx,l=vx,c=void 0,u=32,d=2,h=Hx,f=Ux;function p(){var e={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return g(e),e}function g(h){h.x0=e,h.y0=t,h.x1=i,h.y1=r,h.py=0,Qx(h,s),Kx(h,c,s),Jx(h,s),eb(h),tb(h,c,l);var f=n;if(null!==a){var p=Xx(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),g=Wx(p,function(e){return e.length});g>1&&(f=Math.max(1,(r-t)*a/(g-1)))}ib(h,f,o),ob(h,c,s),nb(h,c,s,f,f,u),ab(h),ob(h,c,s),nb(h,c,s,f,f,u),ab(h),Ix(h),Rx(h),sb(h),Ex(h,s,d,10,8)}return p.update=function(e){return ab(e),Ex(e,s,d,10,8),e},p.nodeWidth=function(e){return arguments.length?(o=+e,p):o},p.nodePadding=function(e){return arguments.length?(n=+e,p):n},p.nodePaddingRatio=function(e){return arguments.length?(a=+e,p):a},p.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Vx(e),p):h},p.links=function(e){return arguments.length?(f="function"==typeof e?e:Vx(e),p):f},p.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:Vx(e),p):s},p.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:Vx(e),p):l},p.nodeSort=function(e){return arguments.length?(c=e,p):c},p.iterations=function(e){return arguments.length?(u=+e,p):u},p.circularLinkGap=function(e){return arguments.length?(d=+e,p):d},p.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],i=+o[1][0],r=+o[1][1],p):[[e,t],[i,r]]},p.size=function(o){return arguments.length?(e=t=0,i=+o[0],r=+o[1],p):[i-e,r-t]},p}import{interpolateNumber as cb}from"d3-interpolate";function ub(e){let{sx:t,sTop:i,sBot:r,tx:o,tTop:n,tBot:a,cp1X:s,cp2X:l}=e,c=(i+r)/2,u=(n+a)/2;return{pathD:[`M${t},${i}`,`C${s},${i} ${l},${n} ${o},${n}`,`L${o},${a}`,`C${l},${a} ${s},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:s,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-i)/2}}}var db=e=>{let{source:t,target:i}=e;if("string"==typeof t||"string"==typeof i)return null;if("down"===e.direction){let r=e.y0-e.sankeyWidth/2,o=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,a=e.y0+e.sankeyWidth/2,s=t.x1,l=i.x0,c=cb(s,l),u=c(.5),d=c(.5);return`M${r},${s}C${r},${u} ${o},${d} ${o},${l}L${n},${l}C${n},${d} ${a},${u} ${a},${s}Z`}let r=e.sankeyWidth/2,o=cb(t.x1,i.x0),{pathD:n}=ub({sx:t.x1,sTop:e.y0-r,sBot:e.y0+r,tx:i.x0,tTop:e.y1-r,tBot:e.y1+r,cp1X:o(.5),cp2X:o(.5)});return n};function hb(e){let t=e.circularPathData;if(!t)return null;let i=e.sankeyWidth/2,r="bottom"===e.circularLinkType?1:-1,o=1===r?1:0,n="down"===e.direction,a=(e,t)=>n?`${t},${e}`:`${e},${t}`,s=(e,t,i,r,o)=>`A${n?t:e},${n?e:t} 0 0 ${n?1-i:i} ${a(r,o)}`,{sourceX:l,sourceY:c,targetX:u,targetY:d,rightInnerExtent:h,leftInnerExtent:f,rightFullExtent:p,leftFullExtent:g,verticalFullExtent:m,verticalRightInnerExtent:y,verticalLeftInnerExtent:x,rightLargeArcRadius:b,rightSmallArcRadius:v,leftLargeArcRadius:w,leftSmallArcRadius:k}=t;return`M${a(l,c-r*i)}L${a(h,c-r*i)}`+s(b+i,v+i,o,p+i,c+r*v)+`L${a(p+i,y)}`+s(b+i,b+i,o,h,m+r*i)+`L${a(f,m+r*i)}`+s(w+i,w+i,o,g-i,x)+`L${a(g-i,d+r*k)}`+s(w+i,k+i,o,f,d-r*i)+`L${a(u,d-r*i)}L${a(u,d+r*i)}L${a(f,d+r*i)}`+s(w-i,k-i,1-o,g+i,d+r*k)+`L${a(g+i,x)}`+s(w-i,w-i,1-o,f,m-r*i)+`L${a(h,m-r*i)}`+s(b-i,b-i,1-o,p-i,y)+`L${a(p-i,c+r*v)}`+s(b-i,v-i,1-o,h,c+r*i)+`L${a(l,c+r*i)}Z`}var fb=/* @__PURE__ */new Set,pb=/* @__PURE__ */new WeakMap;function gb(e,t){if("production"===process.env.NODE_ENV||!e||!e.data||"object"!=typeof e.data)return e;let i=pb.get(e);if(i){let e=i.get(t);if(e)return e}else i=/* @__PURE__ */new Map,pb.set(e,i);let r=new Proxy(e,{get(e,i,r){if("string"==typeof i&&!(i in e)&&e.data&&i in e.data){let e=`${t}:${i}`;fb.has(e)||(fb.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,i,r)}});return i.set(t,r),r}var mb={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(bx))-1:0},justify:vx},yb={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,r){let o="vertical"===i.orientation?"down":"right",n=i.nodeAlign||"justify",a=i.nodeWidth??15,s=i.nodePaddingRatio??.05,l=i.iterations??300;for(let e of t)e.sankeyWidth=0,e.circular=!1,delete e.circularPathData,delete e._circularWidth,delete e._circularStub;for(let t of e)t.value=0,t.width=t.height=0,t.x0=t.x1=t.y0=t.y1=0,t.sourceLinks=[],t.targetLinks=[];let c=new Set(e.map(e=>e.id)),u=/* @__PURE__ */new Set,d=t.filter(e=>{let t=w(e.source),i=w(e.target);return!(!Number.isFinite(e.value)||e.value<=0||!c.has(t)||!c.has(i)||(u.add(t),u.add(i),0))}).map(e=>({...e,source:w(e.source),target:w(e.target)}));if(0===d.length)return;let h,f=e.filter(e=>u.has(e.id)).map(e=>({...e}));h="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];let p=lb().extent(h).links(d).nodes(f).nodeAlign(mb[n]||vx).nodeId(e=>e.id).nodeWidth(a).iterations(l);p.nodePaddingRatio&&p.nodePaddingRatio(s),p();{let e=1/0,t=-1/0,i=1/0,r=-1/0;for(let o of f)o.x0<e&&(e=o.x0),o.x1>t&&(t=o.x1),o.y0<i&&(i=o.y0),o.y1>r&&(r=o.y1);for(let o of d){if(!o.circular||!o.circularPathData)continue;let n=o.circularPathData,a=(o._circularWidth??o.width??0)/2;n.leftFullExtent-a<e&&(e=n.leftFullExtent-a),n.rightFullExtent+a>t&&(t=n.rightFullExtent+a),n.verticalFullExtent-a<i&&(i=n.verticalFullExtent-a),n.verticalFullExtent+a>r&&(r=n.verticalFullExtent+a)}let o=t-e,n=r-i,a=h[1][0],s=h[1][1];if(o>0&&n>0&&(e<0||i<0||t>a||r>s)){let t=a/o,r=s/n,l=Math.min(t,r),c=-e*l+(a-o*l)/2,u=-i*l+(s-n*l)/2;for(let e of f)e.x0=e.x0*l+c,e.x1=e.x1*l+c,e.y0=e.y0*l+u,e.y1=e.y1*l+u;for(let e of d)if(e.y0=e.y0*l+u,e.y1=e.y1*l+u,e.width=(e.width??0)*l,e._circularWidth&&(e._circularWidth*=l),e.circular&&e.circularPathData){let t=e.circularPathData;t.sourceX=t.sourceX*l+c,t.targetX=t.targetX*l+c,t.sourceY=t.sourceY*l+u,t.targetY=t.targetY*l+u,t.rightFullExtent=t.rightFullExtent*l+c,t.leftFullExtent=t.leftFullExtent*l+c,t.verticalFullExtent=t.verticalFullExtent*l+u,t.rightInnerExtent=t.rightInnerExtent*l+c,t.leftInnerExtent=t.leftInnerExtent*l+c,t.verticalRightInnerExtent=t.verticalRightInnerExtent*l+u,t.verticalLeftInnerExtent=t.verticalLeftInnerExtent*l+u,t.rightSmallArcRadius*=l,t.rightLargeArcRadius*=l,t.leftSmallArcRadius*=l,t.leftLargeArcRadius*=l,t.sourceWidth*=l,t.rightNodeBuffer*=l,t.leftNodeBuffer*=l,t.arcRadius*=l}}}let g=/* @__PURE__ */new Map;for(let t of e)g.set(t.id,t);for(let e of f){let t=g.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}let m=/* @__PURE__ */new Map;for(let e of t)if(e._edgeKey)m.set(e._edgeKey,e);else{let t=w(e.source),i=w(e.target);m.set(`${t}\0${i}`,e)}for(let e of d){let t=w(e.source),i=w(e.target),r=e._edgeKey?m.get(e._edgeKey):m.get(`${t}\0${i}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=o;let n=g.get(t),a=g.get(i);n&&(r.source=n),a&&(r.target=a)}}},buildScene(e,t,i,r){let o="vertical"===i.orientation?"down":"right",n=i.nodeStyle,a=i.edgeStyle,s=i.edgeOpacity??.5,l=i.edgeColorBy||"source",c=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:bi,u=/* @__PURE__ */new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});let d=[],h=[],f=[],p=/* @__PURE__ */new Map;for(let t of e){let e=t.x1-t.x0,i=t.y1-t.y0;if(t.value<=0||e<=0||i<=0)continue;let r=n?n(gb(t,"nodeStyle")):{},a={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity,cursor:r.cursor};p.set(t.id,("string"==typeof a.fill?a.fill:null)||u.get(t.id)||"#4d430c"),"down"===o?d.push({type:"rect",x:t.y0,y:t.x0,w:i,h:e,style:a,datum:t,id:t.id,label:t.id}):d.push({type:"rect",x:t.x0,y:t.y0,w:e,h:i,style:a,datum:t,id:t.id,label:t.id})}let g=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(let e of g){if(!(e.value>0)||!e.sankeyWidth||e.sankeyWidth<=0)continue;let t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";o="function"==typeof l?l(e)||o:"target"===l?p.get(r.id)||u.get(r.id)||o:p.get(t.id)||u.get(t.id)||o;let n,c=a?a(gb(e,"edgeStyle")):{};if(n=e.circular&&e.circularPathData?hb(e):db(e),!n)continue;let d={fill:c.fill||o,fillOpacity:c.fillOpacity??s,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,strokeOpacity:c.strokeOpacity,opacity:c.opacity,cursor:c.cursor};h.push({type:"bezier",pathD:n,bezierCache:e.bezier,style:d,datum:e})}if(!1!==i.showLabels){let t=v(i.nodeLabel);for(let i of e){let e=i.x1-i.x0,n=i.y1-i.y0;if(i.value<=0||e<=0||n<=0)continue;let a,s,l,c=t?t(i):i.id;if(c){if("down"===o)a=i.y0+(i.y1-i.y0)/2,s=i.x1+14,l="start";else{let t=r[0]/2;i.x0+e/2<t?(a=i.x0-6,l="end"):(a=i.x1+6,l="start"),s=i.y0+n/2}f.push({x:a,y:s,text:String(c),anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11})}}}return{sceneNodes:d,sceneEdges:h,labels:f}}};import{forceSimulation as xb,forceCenter as bb,forceX as vb,forceY as wb,forceLink as kb,forceManyBody as Ab,forceCollide as Sb}from"d3-force";function Mb(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}var $b={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let o=i.forceStrength??.1,n=r[0]/2,a=r[1]/2,s=Math.max(.1,Math.min(1,Math.min(r[0],r[1])/200)),l=Math.min(.5,.06+1.8*(1-s)),c=i.__previousPositions,u=0,d=[];for(let t of e){let e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),i=c?.get(t.id);e?u++:i?(t.x=i.x,t.y=i.y,u++):d.push(t)}let h=e.length>0?d.length/e.length:1,f=u>0&&h<=.3;if(f){let i=/* @__PURE__ */new Map;for(let t of e)i.set(t.id,t);for(let e of d){let r=_b(e.id,t,i);if(r.length>0){let t=0,i=0;for(let e of r)t+=e.x,i+=e.y;let o=Lb(e.id),n=o%360*(Math.PI/180),a=(10+o%20)*s;e.x=t/r.length+a*Math.cos(n),e.y=i/r.length+a*Math.sin(n)}else{let t=Lb(e.id),i=t%360*(Math.PI/180),r=(15+t%30)*s;e.x=n+r*Math.cos(i),e.y=a+r*Math.sin(i)}}}else{let t=Math.PI*(3-Math.sqrt(5));for(let i=0;i<e.length;i++){let r=e[i];if(null==r.x||null==r.y||0===r.x&&0===r.y){let e=10*Math.sqrt(i+.5)*s,o=i*t;r.x=n+e*Math.cos(o),r.y=a+e*Math.sin(o)}}}let p=e.length,g=i.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(p-30)))),m=i.__skipForceSimulation||0===i.iterations?0:f?40:g,y=De(i.nodeSize,i.nodeSizeRange,e),x=e=>y(e);if(m>0){let c=/* @__PURE__ */new Map,u=/* @__PURE__ */new Map;for(let t of e)c.set(t.id,0),u.set(t.id,t);for(let e of t){let t=w(e.source),i=w(e.target);c.set(t,(c.get(t)??0)+1),c.set(i,(c.get(i)??0)+1)}let d=kb().strength(e=>{let t=Ee(e),i=w(e.source),r=w(e.target),n=Math.max(1,Math.min(c.get(i)??1,c.get(r)??1)),a=t&&t>0?Math.sqrt(t):1;return Math.min(2.5,a*o/(.1*n))}).distance(e=>{let t="string"==typeof e.source?u.get(e.source):e.source,i="string"==typeof e.target?u.get(e.target):e.target,r=(t?x(t):0)+(i?x(i):0)+Math.max(6,12*s);return Math.max(16,40*s,r)}).id(e=>e.id),h=xb();if((void 0!==i.random||void 0!==i.seed)&&h.randomSource(i.random??Mb(i.seed)),h.force("charge",Ab().strength(e=>{let t=c.get(e.id)??0;return-15*s*x(e)*Math.sqrt(t+1)})).force("collide",Sb(e=>x(e)+3*s).strength(.9).iterations(2)).force("center",bb(n,a).strength(.8)).force("x",vb(n).strength(l)).force("y",wb(a).strength(l)).force("bounds",Pb(r,x)),h.nodes(e),t.length>0){let e=t.map(e=>({...e,source:w(e.source),target:w(e.target)}));d.links(e),h.force("link",d)}f?h.alpha(.3):h.alpha()<.1&&h.alpha(1),h.stop();for(let e=0;e<m;++e)h.tick()}for(let t of e){if(null==t.x||null==t.y)continue;let e=x(t),i=m>0?2:0,o=Math.min(r[0]/2,e+i),n=Math.min(r[1]/2,e+i);t.x=Math.max(o,Math.min(r[0]-o,t.x)),t.y=Math.max(n,Math.min(r[1]-n,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}let b=/* @__PURE__ */new Map;for(let t of e)b.set(t.id,t);for(let e of t){if("string"==typeof e.source){let t=b.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){let t=b.get(e.target);t&&(e.target=t)}}},buildScene(e,t,i,r){let o=i.nodeStyle,n=i.edgeStyle,a=De(i.nodeSize,i.nodeSizeRange,e),s=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:bi,l=/* @__PURE__ */new Map;e.forEach((e,t)=>{l.set(e.id,s[t%s.length])});let c=[],u=[],d=[];for(let t of e){if(null==t.x||null==t.y)continue;let e=a(gb(t,"nodeSize")),r=o?o(gb(t,"nodeStyle")):{},n={fill:r.fill||l.get(t.id)||i.themeSemantic?.primary||"#007bff",stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity,cursor:r.cursor};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}let h=/* @__PURE__ */new Map;for(let t of e)h.set(t.id,t);for(let e of t){let t="object"==typeof e.source?e.source:h.get(e.source),r="object"==typeof e.target?e.target:h.get(e.target);if(!t||!r||null==t.x||null==t.y||null==r.x||null==r.y)continue;let o=n?n(gb(e,"edgeStyle")):{},a={stroke:o.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6,cursor:o.cursor};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:a,datum:e})}if(!1!==i.showLabels){let t=v(i.nodeLabel);for(let i of e){if(null==i.x||null==i.y)continue;let e=t?t(i):i.id;if(!e)continue;let r=a(gb(i,"nodeSize"));d.push({x:i.x,y:i.y-r-4,text:String(e),anchor:"middle",baseline:"auto",fontSize:11,anchorPoint:[i.x,i.y]})}}return{sceneNodes:c,sceneEdges:u,labels:d}}};function _b(e,t,i){let r=[];for(let o of t){let t=w(o.source),n=w(o.target),a=null;if(t===e?a=n:n===e&&(a=t),a){let e=i.get(a);e&&(0!==e.x||0!==e.y)&&r.push({x:e.x,y:e.y})}}return r}function Pb(e,t,i=2,r=.6){let o=[],n=n=>{let a=r*Math.max(n,.2);for(let r of o){let o=r.x??e[0]/2,n=r.y??e[1]/2,s=r.vx??0,l=r.vy??0,c=t(r)+i,u=Math.min(e[0]/2,c),d=Math.max(e[0]/2,e[0]-c),h=Math.min(e[1]/2,c),f=Math.max(e[1]/2,e[1]-c),p=o+s,g=n+l;p<u?r.vx=s+(u-p)*a:p>d&&(r.vx=s+(d-p)*a),g<h?r.vy=l+(h-g)*a:g>f&&(r.vy=l+(f-g)*a)}};return n.initialize=e=>{o=e},n}function Lb(e){let t=0;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i)|0;return Math.abs(t)}import{chord as Ib,ribbon as Rb}from"d3-chord";import{arc as Tb}from"d3-shape";var Cb=bi,Nb={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,i,r){for(let t of e)delete t.__arcData;for(let e of t)delete e.__chordData,delete e.__chordEdges;if(0===e.length)return;let{padAngle:o=.01,groupWidth:n=20,sortGroups:a}=i,s=Math.min(r[0],r[1])/2,l=s-n,c=r[0]/2,u=r[1]/2,d=new Map(e.map(e=>[e.id,e])),h=/* @__PURE__ */new Set,f=t.filter(e=>{let t=w(e.source),i=w(e.target);return!(!Number.isFinite(e.value)||e.value<=0||!d.has(t)||!d.has(i)||(h.add(t),h.add(i),0))}),p=e.filter(e=>h.has(e.id)),g=p.length;if(0===g)return;let m=new Map(p.map((e,t)=>[e.id,t])),y=Array.from({length:g},()=>new Array(g).fill(0)),x=/* @__PURE__ */new Map;for(let e of f){let t=w(e.source),i=w(e.target),r=m.get(t),o=m.get(i);y[r][o]+=e.value;let n=r<=o?`${r}\0${o}`:`${o}\0${r}`,a=x.get(n);a?a.push(e):x.set(n,[e])}let b=Math.min(Number.isFinite(o)?Math.max(0,o):.01,Math.PI/g),v=Ib().padAngle(b);a&&v.sortGroups(a);let k=v(y),A=k.groups,S=Tb().innerRadius(l).outerRadius(s);for(let e of A){let t=p[e.index],i={innerRadius:l,outerRadius:s,startAngle:e.startAngle,endAngle:e.endAngle},r=S.centroid(i);t.x=r[0]+c,t.y=r[1]+u,t.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}for(let e of t){let t=w(e.source),i=w(e.target),r=d.get(t),o=d.get(i);r&&(e.source=r),o&&(e.target=o)}for(let e of k){let t=e.source.index,i=e.target.index,r=t<=i?`${t}\0${i}`:`${i}\0${t}`,o=x.get(r);for(let t of o)t.__chordData=e,t.__chordEdges=o}},buildScene(e,t,i,r){let{groupWidth:o=20,edgeOpacity:n=.5}=i,a=Math.min(r[0],r[1])/2,s=a-o,l=r[0]/2,c=r[1]/2,u=i.nodeStyle,d=i.edgeStyle,h=i.edgeColorBy||"source",f=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:Cb,p=/* @__PURE__ */new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});let g=Rb().radius(s),m=[],y=[],x=[];for(let t=0;t<e.length;t++){let i=e[t],r=i.__arcData;if(!r)continue;let o=u?u(gb(i,"nodeStyle")):{},n={fill:("string"==typeof o.fill?o.fill:void 0)||p.get(i.id)||f[t%f.length],stroke:o.stroke||"black",strokeWidth:o.strokeWidth??1,opacity:o.opacity,cursor:o.cursor};m.push({type:"arc",cx:l,cy:c,innerR:s,outerR:a,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:n,datum:i,id:i.id,label:i.id})}let b=/* @__PURE__ */new Set,k=e.filter(e=>e.__arcData);for(let e of t){let t=e.__chordData;if(!t||b.has(t))continue;b.add(t);let r=k[t.source.index].id;for(let t of e.__chordEdges||[])w(t.source)===r&&(e=t);let o=g(t);if(!o)continue;let a=Fb(o,l,c),s=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",u=d?d(gb(e,"edgeStyle")):{};if(d)s=("string"==typeof u.fill?u.fill:void 0)||s;else{let t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;"target"===h&&i?s=p.get(i.id)||s:t&&(s=p.get(t.id)||s)}let f={fill:s,fillOpacity:u.fillOpacity??n,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,strokeOpacity:u.strokeOpacity,opacity:u.opacity,cursor:u.cursor};y.push({type:"ribbon",pathD:a,style:f,datum:e})}if(!1!==i.showLabels){let t=v(i.nodeLabel),r=a+12;for(let i of e){let e=i.__arcData;if(!e)continue;let o=t?t(i):i.id;if(!o)continue;let n=(e.startAngle+e.endAngle)/2,a=n-Math.PI/2,s=l+Math.cos(a)*r,u=c+Math.sin(a)*r,d=n>Math.PI?"end":"start";x.push({x:s,y:u,text:String(o),anchor:d,baseline:"middle",fontSize:11})}}return{sceneNodes:m,sceneEdges:y,labels:x}}};function Fb(e,t,i){let r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;let o=[],n=0;for(;n<r.length;){let e=r[n];if("M"===e||"L"===e||"C"===e||"Q"===e)for(o.push(e),n++;n<r.length&&!isNaN(Number(r[n]));)o.push(String(Number(r[n])+t)),n++,n<r.length&&!isNaN(Number(r[n]))&&(o.push(String(Number(r[n])+i)),n++);else if("A"===e)for(o.push(e),n++;n<r.length&&!isNaN(Number(r[n]));)o.push(r[n++]),n<r.length&&o.push(r[n++]),n<r.length&&o.push(r[n++]),n<r.length&&o.push(r[n++]),n<r.length&&o.push(r[n++]),n<r.length&&(o.push(String(Number(r[n])+t)),n++),n<r.length&&(o.push(String(Number(r[n])+i)),n++);else"Z"===e||"z"===e?(o.push(e),n++):(o.push(r[n]),n++)}return o.join(" ")}import{hierarchy as Db,tree as Eb,cluster as zb,treemap as Ob,pack as jb,partition as Wb,treemapBinary as Bb}from"d3-hierarchy";var Yb=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Gb(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[0,2,4].map(e=>parseInt(t.slice(e,e+2),16))}let t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}function Xb(e){let[t,i,r]=Gb(e);return.299*t+.587*i+.114*r>150?"#222":"#fff"}function Vb(e){if(e)return"function"==typeof e?e:t=>t[e]}function qb(e,t,i){let r=t.nodeIDAccessor,o=e.data;return String("function"==typeof r?r(o):"string"==typeof r&&void 0!==o[r]?o[r]:void 0!==o.name?o.name:void 0!==o.id?o.id:`node-${i}`)}function Hb(e){if(!e)return null;if("function"==typeof e){let t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function Ub(e="value"){let t="function"==typeof e?e:t=>t[e];return e=>{let i=t(e),r="string"==typeof i?Number(i):i;return Number.isFinite(r)&&r>0?r:0}}function Zb(e){let t=new Map(e.map(e=>[e,0]));return e.map(e=>{let i=t.get(e),r=e;for(;i>0&&t.has(r);)r=`${e}__${i++}`;return t.set(e,i||1),t.set(r,1),r})}function Qb(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Yb}function Kb(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function Jb(e,t,i){if(t.colorByDepth&&void 0!==e.depth){let i=Qb(t);return i[e.depth%i.length]}return i||Kb(t)}function ev(e,t,i){return{fill:Jb(e,t,i.fill),stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity,cursor:i.cursor}}function tv(e){return!e.__hierarchyNode?.children?.length}function iv(e,t,i,r,o,n){let a=[],s=[],l=[],c=i.treeOrientation||"vertical",u="radial"===c,d=r[0]/2,h=r[1]/2,{nodeSize:f}=i,p="number"==typeof f?f:5;for(let t of e){let e=t.x,r=t.y;u&&(e+=d,r+=h);let n=ev(t,i,o(gb(t,"nodeStyle")));a.push({type:"circle",cx:e,cy:r,r:p,style:n,datum:t,id:t.id,label:t.id,depth:t.depth})}let g=i.edgeOpacity??.5;for(let e of t){let t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,a=t.y,l=r.x,f=r.y;u&&(o+=d,a+=h,l+=d,f+=h);let p=nv(o,a,l,f,c),m=n(gb(e,"edgeStyle")),y={fill:"none",stroke:m.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:m.strokeWidth??1.5,opacity:m.opacity??g,cursor:m.cursor};s.push({type:"curved",pathD:p,style:y,datum:e})}if(!1!==i.showLabels){let t=Hb(i.nodeLabel);for(let i of e){let e=t?t(i):i.id;if(!e)continue;let r,o,n,a=i.x,s=i.y;if(u&&(a+=d,s+=h),u){let e=a-d,t=s-h,i=Math.sqrt(e*e+t*t);i>0?(r=a+e/i*10,o=s+t/i*10,n=e>=0?"start":"end"):(r=a,o=s-12,n="middle")}else"horizontal"===c?(tv(i)?(r=a+p+6,n="start"):(r=a-p-6,n="end"),o=s):(r=a,o=s+p+14,n="middle");l.push({x:r,y:o,text:String(e),anchor:n,baseline:"middle",fontSize:11,anchorPoint:[a,s]})}}return{sceneNodes:a,sceneEdges:s,labels:l}}function rv(e,t,i){let r=[],o=[];for(let o of e){let e=o.x1-o.x0,n=o.y1-o.y0;if(e<=0||n<=0)continue;let a=i(gb(o,"nodeStyle")),s=ev(o,t,a);s.fillOpacity=a.fillOpacity,s.strokeOpacity=a.strokeOpacity,r.push({type:"rect",x:o.x0,y:o.y0,w:e,h:n,style:s,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){let r=Hb(t.nodeLabel),n=t.labelMode||"leaf",a="partition"===t.chartType;for(let s of e){let e=s.x1-s.x0,l=s.y1-s.y0;if(e<=0||l<=0)continue;let c=tv(s);if(!a&&("leaf"===n&&!c||"parent"===n&&c))continue;let u=r?r(s):s.id;if(!u)continue;if(e<(c?30:40)||l<(c?16:14))continue;let d=Jb(s,t,i(gb(s,"nodeStyle")).fill),h="string"==typeof d?Xb(d):t.themeSemantic?.text??"#000";c?o.push({x:s.x0+e/2,y:s.y0+l/2,text:String(u),anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:h}):o.push({x:s.x0+4,y:s.y0+12,text:String(u),anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:r,sceneEdges:[],labels:o}}function ov(e,t,i){let r=[],o=[];for(let o of e){let e=o.__radius??5;if(e<=0)continue;let n=ev(o,t,i(gb(o,"nodeStyle")));n.opacity??(n.opacity=.7),r.push({type:"circle",cx:o.x,cy:o.y,r:e,style:n,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){let r=Hb(t.nodeLabel);for(let n of e){let e=n.__radius??5,a=r?r(n):n.id;if(!a||e<15)continue;let s=tv(n),l=Jb(n,t,i(gb(n,"nodeStyle")).fill);if(s){let i="string"==typeof l?Xb(l):t.themeSemantic?.text??"#000";o.push({x:n.x,y:n.y,text:String(a),anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:i})}else o.push({x:n.x,y:n.y-e+14,text:String(a),anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:r,sceneEdges:[],labels:o}}function nv(e,t,i,r,o){let n=(e+i)/2,a=(t+r)/2;return"horizontal"===o?`M ${e},${t} C ${n},${t} ${n},${r} ${i},${r}`:"radial"===o?`M ${e},${t} Q ${n},${t} ${n},${a} T ${i},${r}`:`M ${e},${t} C ${e},${a} ${i},${a} ${i},${r}`}var av={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,i,r){let o=i.__hierarchyRoot;if(!o)return;let n=i.chartType,a=Vb(i.childrenAccessor),s=Db(o,a),l=[];s.eachBefore(e=>l.push(e));let c=Zb(l.map((e,t)=>qb(e,i,t)));s.sum(Ub(i.hierarchySum)).sort((e,t)=>t.value-e.value);let[u,d]=r;switch(n){case"tree":case"cluster":sv(s,i,u,d);break;case"treemap":case"partition":lv(s,i,u,d);break;case"circlepack":cv(s,i,u,d)}let h=s.descendants();e.length=0,t.length=0;let f=new Map(l.map((e,t)=>[e,{id:c[t],x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,depth:e.depth,data:e.data,createdByFrame:!0}]));for(let t of h){let r=f.get(t);"tree"===n||"cluster"===n?uv(r,t,i):"treemap"===n||"partition"===n?dv(r,t):"circlepack"===n&&hv(r,t),r.__hierarchyNode=t,e.push(r)}if("tree"===n||"cluster"===n)for(let e of h)if(e.parent){let i=f.get(e.parent),r=f.get(e);t.push({source:i,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,i,r){let o=i.chartType,n=i.nodeStyle||(()=>({})),a=i.edgeStyle||(()=>({}));switch(o){case"tree":case"cluster":return iv(e,t,i,r,n,a);case"treemap":case"partition":return rv(e,i,n);case"circlepack":return ov(e,i,n);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function sv(e,t,i,r){let o=t.treeOrientation||"vertical",n="cluster"===t.chartType?zb():Eb();if("horizontal"===o)n.size([r,i]);else if("radial"===o){let e=Math.min(i,r)/2;n.size([2*Math.PI,.8*e])}else n.size([i,r]);n(e)}function lv(e,t,i,r){let o="treemap"===t.chartType,n=o?Ob().tile(Bb):Wb();n.size([i,r]).padding(t.padding??(o?4:1)),"paddingTop"in n&&t.paddingTop>0&&n.paddingTop(t.paddingTop),n(e)}function cv(e,t,i,r){let o=t.padding??4,n=jb().size([i,r]).padding(o);e.leaves().some(e=>e.value)||n.radius(()=>0).padding(0),n(e)}function uv(e,t,i){let r=i.treeOrientation||"vertical";if("radial"===r){let i=t.x,r=t.y;e.x=r*Math.cos(i-Math.PI/2),e.y=r*Math.sin(i-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);fv(e,5)}function dv(e,t){e.x0=t.x0,e.y0=t.y0,e.x1=e.value?t.x1:t.x0,e.y1=e.value?t.y1:t.y0,e.x=(e.x0+e.x1)/2,e.y=(e.y0+e.y1)/2,e.width=e.x1-e.x0,e.height=e.y1-e.y0}function hv(e,t){let i=t.r??0;e.x=t.x,e.y=t.y,fv(e,i),e.__radius=i}function fv(e,t){e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}import{pie as pv}from"d3-shape";function gv(e,t){if(!e)return[];let i=[],r=e=>{i.push(e);let o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(r)};return r(e),i}function mv(e,t,i,r){if(e&&e.length>0)return e;let o=/* @__PURE__ */new Set;return t.forEach(e=>{let t="function"==typeof i?i(e):e[i],n="function"==typeof r?r(e):e[r];o.add(t),o.add(n)}),Array.from(o).map(e=>({id:e}))}function yv({edgeColorBy:e,colorBy:t,colorScale:i,nodeStyleFn:r,edgeOpacity:o,baseStyle:n={}}){return a=>{let s={fillOpacity:o,...n};if("function"==typeof e)s.fill=e(a);else if("source"===e){let e="object"==typeof a.source?a.source:null;t&&e?s.fill=Gi(e.data||e,t,i):e&&(s.fill=r(e,e.index).fill)}else if("target"===e){let e="object"==typeof a.target?a.target:null;t&&e?s.fill=Gi(e.data||e,t,i):e&&(s.fill=r(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}function xv(e){let t=e.__orbitState;return t||(t={metaMap:/* @__PURE__ */new Map,startTime:typeof performance<"u"?performance.now():Date.now()},e.__orbitState=t),t}function bv(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}function vv(e){if("function"==typeof e)return e;let t=e||"name";return e=>String(e[t]??"")}function wv(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{let t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}function kv(e,t,i,r,o){let n=Vb(i.childrenAccessor||"children"),a=vv(i.nodeIDAccessor),s=bv(i.orbitMode),l=i.orbitSize??2.95,c=i.orbitEccentricity??1,u="number"==typeof l?()=>l:l,d="number"==typeof c?()=>c:c,h=xv(i);h.metaMap.clear(),r.length=0,o.length=0;let f=Zb(gv(e,n).map(e=>String(a(e)))),p=0,g=t[0]/2,m=t[1]/2,y=Math.min(t[0],t[1])/2*.85,x=f[p++],b={id:x,x:g,y:m,x0:g,x1:g,y0:m,y1:m,width:0,height:0,value:0,depth:0,data:e};r.push(b),h.metaMap.set(x,{ring:y,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,i,a,l,c,g,m){let y=n(t);if(!y?.length)return;let x=y.length,b=0,v=0,w=0;for(;v<x;)v+=s[Math.min(w,s.length-1)],w++,b++;let k=0;for(let x=0;x<b;x++){let v=s[Math.min(x,s.length-1)],w=y.slice(k,k+v);if(!w.length)break;let A=(x+1)/b,S={id:i,depth:g,data:t,parentId:i},M=m?c/u(S)*A:c*A,$=pv().value(e=>n(e)?.length?4:1).sort(null)(w),_=d(S);for(let t=0;t<w.length;t++){let n=($[t].startAngle+$[t].endAngle)/2,s=w[t],c=f[p++],u=a+M*Math.sin(n),d=l+M*Math.cos(n)*_,m={id:c,x:u,y:d,x0:u,x1:u,y0:d,y1:d,width:0,height:0,value:0,depth:g,data:s};r.push(m),h.metaMap.set(c,{ring:M,angle:n,depth:g,parentId:i,eccentricity:_}),o.push({source:i,target:c,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:c}}),e(s,c,u,d,M,g+1,!0)}k+=v}}(e,x,g,m,y,1,!1)}function Av(e,t,i,r){let o=xv(t),n=t.orbitSpeed??.25,a=t.orbitRevolution??wv(t.orbitRevolutionStyle),s=((typeof performance<"u"?performance.now():Date.now())-o.startTime)/1e3,l=n*(Math.PI/6),c=/* @__PURE__ */new Map;for(let t of e)c.set(t.id,t);for(let t of e){let e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;let i=c.get(e.parentId);if(!i)continue;let r={id:t.id,depth:e.depth,data:t.data,parentId:e.parentId},n=e.angle+s*l*a(r);t.x=i.x+e.ring*Math.sin(n),t.y=i.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}var Sv={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,i,r){let o=i.__hierarchyRoot;o&&kv(o,r,i,e,t)},buildScene(e,t,i,r){let o=i.nodeStyle,n=i.edgeStyle,a=i.nodeSize,s="number"==typeof a?()=>a:"function"==typeof a?a:()=>6,l=[],c=[],u=[];if(!1!==i.orbitShowRings){let t=xv(i),r=/* @__PURE__ */new Map;for(let t of e)r.set(t.id,t);let o=/* @__PURE__ */new Map;for(let[,e]of t.metaMap){if(!e.parentId)continue;let t=r.get(e.parentId);if(!t)continue;let i=`${e.parentId}:${e.ring}`;o.has(i)||o.set(i,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}let n=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(let[,{parentX:e,parentY:t,ring:i,ecc:r}]of o)for(let o=0;o<n;o++){let s=o/n*Math.PI*2,l=(o+1)/n*Math.PI*2;c.push({type:"line",x1:e+i*Math.sin(s),y1:t+i*Math.cos(s)*r,x2:e+i*Math.sin(l),y2:t+i*Math.cos(l)*r,style:a,datum:null})}}for(let t of e){if(null==t.x||null==t.y)continue;let e=s(gb(t,"nodeSize")),r=o?o(gb(t,"nodeStyle")):{},n={fill:r.fill||i.themeSemantic?.primary||"#6366f1",stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85),cursor:r.cursor};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id,depth:t.depth})}let d=/* @__PURE__ */new Map;for(let t of e)d.set(t.id,t);for(let e of t){let t="object"==typeof e.source?e.source:d.get(e.source),i="object"==typeof e.target?e.target:d.get(e.target);if(!t||!i||null==t.x||null==i.x)continue;let r=n?n(gb(e,"edgeStyle")):{},o={stroke:r.stroke||"rgba(128,128,128,0.35)",strokeWidth:r.strokeWidth??.5,opacity:r.opacity??1,cursor:r.cursor};c.push({type:"line",x1:t.x,y1:t.y,x2:i.x,y2:i.y,style:o,datum:e})}if(i.showLabels){let t=i.nodeLabel;for(let i of e){let e=s(gb(i,"nodeSize"));if(e<=4)continue;let r="function"==typeof t?t(i):t?i.data?.[t]??i.id:i.id;u.push({x:i.x,y:i.y+e+12,text:String(r),anchor:"middle",fontSize:10,fill:"currentColor",anchorPoint:[i.x,i.y]})}}return{sceneNodes:l,sceneEdges:c,labels:u}},tick:(e,t,i,r,o)=>!1!==i.orbitAnimated&&(Av(e,i),!0)};import*as Mv from"react";import{arc as $v}from"d3-shape";import{jsx as _v,jsxs as Pv}from"react/jsx-runtime";function Lv(e,t,i="slab-face"){let r=e.style.fill;return(e.style.opacity??1)<=0||(e.style.fillOpacity??1)<=0||"string"==typeof r&&/^\s*(none|transparent)\s*$|^rgba\(.*,\s*0(\.0+)?\s*\)$|^#[\da-f]{3}0$|^#[\da-f]{6}00$/i.test(r)?null:e.faces?.map((r,o)=>/* @__PURE__ */_v("path",{"data-perspective-part":i,"data-perspective-face":o,d:r.pathD,fill:"string"==typeof e.style.fill?F(e.style.fill,r.shade):t,fillOpacity:e.style.fillOpacity,opacity:e.style.opacity},`face-${o}`))}function Iv(e,t){return Ml(Rv(e,t),e,`network-node-cursor-${t}`)}function Rv(e,t){switch(e.type){case"circle":{let i=e,r=Bs(i.style.fill)?Xs(i.style.fill,`net-circle-${t}-hatch`):void 0,o={fill:r?`url(#net-circle-${t}-hatch)`:fl(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity};/* */
260
+ return Pv(Mv.Fragment,{children:[r&&/* @__PURE__ */_v("defs",{children:r}),i.pathD&&Lv(i,o.fill,i._perspectiveToken?"token-rim":"slab-face"),i.pathD?/* @__PURE__ */_v("path",{"data-perspective-part":i._perspectiveToken?"token-top":"slab-top",d:i.pathD,...o}):/* @__PURE__ */_v("circle",{cx:i.cx,cy:i.cy,r:i.r,...o})]},`net-circle-${t}`)}case"rect":{let i=e,r=Bs(i.style.fill)?Xs(i.style.fill,`net-rect-${t}-hatch`):void 0,o={fill:r?`url(#net-rect-${t}-hatch)`:fl(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity};/* */
261
+ return Pv(Mv.Fragment,{children:[r&&/* @__PURE__ */_v("defs",{children:r}),i.pathD&&Lv(i,o.fill),i.pathD?/* @__PURE__ */_v("path",{"data-perspective-part":"slab-top",d:i.pathD,...o}):/* @__PURE__ */_v("rect",{x:i.x,y:i.y,width:i.w,height:i.h,...o})]},`net-rect-${t}`)}case"arc":{let i=e,r=i.pathD?"":$v().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(hl)||"",o=Bs(i.style.fill)?Xs(i.style.fill,`net-arc-${t}-hatch`):void 0;/* */
262
+ return Pv(Mv.Fragment,{children:[o&&/* @__PURE__ */_v("defs",{children:o}),i.pathD&&Lv(i,o?`url(#net-arc-${t}-hatch)`:fl(i.style.fill)),
263
+ /* @__PURE__ */_v("path",{d:i.pathD??r,"data-perspective-part":i.pathD?"slab-top":void 0,transform:i.pathD?void 0:`translate(${i.cx},${i.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:fl(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},`net-arc-${t}`)}case"symbol":{let i=e,r=je(i.symbolType,i.size,i.path),o=i.rotation?`translate(${i.cx},${i.cy}) rotate(${180*i.rotation/Math.PI})`:`translate(${i.cx},${i.cy})`,n=/* @__PURE__ */_v("path",{"data-perspective-part":i._perspectiveToken?"token-top":void 0,d:r,transform:o,fill:i.style.fill?fl(i.style.fill):"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity},`net-symbol-${t}`);return i.faces?.length?/* @__PURE__ */Pv(Mv.Fragment,{children:[Lv(i,i.style.fill?fl(i.style.fill):void 0,"token-rim"),n]},`net-symbol-${t}`):n}case"glyph":{let i=e;return gl(i,i.cx,i.cy,`net-glyph-${i.id??t}`)}default:return null}}function Tv(e,t){return Ml(Cv(e,t),e,`network-edge-cursor-${t}`)}function Cv(e,t){switch(e.type){case"line":{let i=e;/* */
264
+ return _v("line",{"data-perspective-part":i._perspectivePart,x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.stroke||"#999",strokeOpacity:i.style.strokeOpacity,strokeWidth:i.style.strokeWidth??1,strokeDasharray:i.style.strokeDasharray,strokeLinecap:i.style.strokeLinecap,opacity:i.style.opacity},`net-edge-${t}`)}case"bezier":{let i=e,r=`net-bezier-${t}-hatch`,o=Bs(i.style.fill)?Xs(i.style.fill,r):void 0;/* */
265
+ return Pv(Mv.Fragment,{children:[o&&/* @__PURE__ */_v("defs",{children:o}),
266
+ /* @__PURE__ */_v("path",{d:i.pathD,"data-perspective-part":i._perspectivePart,fill:o?`url(#${r})`:fl(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeOpacity:i.style.strokeOpacity,strokeWidth:i.style.strokeWidth,strokeDasharray:i.style.strokeDasharray,strokeLinecap:i.style.strokeLinecap,opacity:i.style.opacity})]},`net-edge-${t}`)}case"ribbon":{let i=e,r=`net-ribbon-${t}-hatch`,o=Bs(i.style.fill)?Xs(i.style.fill,r):void 0;/* */
267
+ return Pv(Mv.Fragment,{children:[o&&/* @__PURE__ */_v("defs",{children:o}),
268
+ /* @__PURE__ */_v("path",{d:i.pathD,"data-perspective-part":i._perspectivePart,fill:o?`url(#${r})`:fl(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeOpacity:i.style.strokeOpacity,strokeWidth:i.style.strokeWidth,strokeDasharray:i.style.strokeDasharray,strokeLinecap:i.style.strokeLinecap,opacity:i.style.opacity})]},`net-edge-${t}`)}case"curved":{let i=e;/* */
269
+ return _v("path",{d:i.pathD,"data-perspective-part":i._perspectivePart,fill:fl(i.style.fill,"none"),fillOpacity:i.style.fill&&"none"!==i.style.fill?i.style.fillOpacity??.1:void 0,stroke:i.style.stroke||"#999",strokeOpacity:i.style.strokeOpacity,strokeWidth:i.style.strokeWidth??1,strokeDasharray:i.style.strokeDasharray,strokeLinecap:i.style.strokeLinecap,opacity:i.style.opacity},`net-edge-${t}`)}default:return null}}function Nv(e,t,i="middle",r="auto"){/* */
270
+ return _v("text",{x:e.x,y:e.y,textAnchor:e.anchor||i,dominantBaseline:e.baseline||r,fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,transform:e.rotate?`rotate(${Math.round(180*e.rotate/Math.PI*100)/100} ${e.x} ${e.y})`:void 0,style:{pointerEvents:"none"},children:e.text},`net-label-${t}`)}function Fv(e){let t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:String(t)}function Dv(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){let t=e.cx??e.x,i=e.cy??e.y;if("number"!=typeof t||"number"!=typeof i)return null;let r=Ve(e.glyph,e.size);return{x:t+r.centerDx,y:i+r.centerDy,r:Math.max(1,r.radius)}}let t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),i=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof i?null:{x:t,y:i,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,We(e.size)):Math.max(1,e.w??0,e.h??0)/2}}function Ev(e){if(!e)return;let t=[];for(let i of e){let e=Dv(i);e&&t.push({pointId:Fv(i),...e})}return t}import{Fragment as zv,jsx as Ov}from"react/jsx-runtime";var jv={x:0,y:0,k:1};function Wv(e){return e&&Number.isFinite(e.k)&&e.k>0&&Number.isFinite(e.x)&&Number.isFinite(e.y)?e:jv}function Bv({view:e,width:t,height:i,children:r}){if(!e)/* */return Ov(zv,{children:r});let{x:o,y:n,k:a}=Wv(e);/* */
271
+ return Ov("svg",{width:t,height:i,overflow:"hidden","data-network-view":"",children:/* @__PURE__ */Ov("g",{transform:`translate(${o},${n}) scale(${a})`,children:r})})}function Yv(e,t,i){return"function"==typeof t?t(e):e[t??i]}function Gv(e){let t=null==e?NaN:Number(e);return Number.isFinite(t)?t:1}function Xv(e,t){return null!=e?String(e):("production"!==process.env.NODE_ENV&&console.warn(`[Semiotic] Missing network ${t} ID; skipping this datum.`),null)}function Vv(e,t){let i=Xv(Yv(e,t.sourceAccessor,"source"),"source"),r=Xv(Yv(e,t.targetAccessor,"target"),"target");return null===i||null===r?null:{source:i,target:r,value:Gv(Yv(e,t.valueAccessor,"value")),data:e}}function qv(e,t,i){let r=/* @__PURE__ */new Map;for(let t of e){let e=Xv(Yv(t,i.nodeIDAccessor,"id"),"node");null!==e&&(r.has(e)&&"production"!==process.env.NODE_ENV&&console.warn(`[Semiotic] Duplicate network node ID "${e}"; using the last datum.`),r.set(e,t))}let o=[];return t.forEach((e,t)=>{let n=Vv(e,i);if(n){for(let e of[n.source,n.target])r.has(e)||r.set(e,{id:e});o.push({...n,_edgeKey:`${n.source}\0${n.target}\0${t}`})}}),{nodes:r,edges:o}}import{Fragment as Hv,jsx as Uv,jsxs as Zv}from"react/jsx-runtime";function Qv(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Kv([e,t]){return{id:e,x:t.x??0,y:t.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t,createdByFrame:!0}}function Jv(e){return{...e,y0:0,y1:0,sankeyWidth:0}}z(D),ox("sankey",yb),ox("force",$b),ox("chord",Nb),ox("tree",av),ox("cluster",av),ox("treemap",av),ox("circlepack",av),ox("partition",av),ox("orbit",Sv);var ew=/* @__PURE__ */new Set(["tree","cluster","treemap","circlepack","partition","orbit"]);function tw(e){return e.map(e=>{let t=e.datum&&"object"==typeof e.datum?e.datum:{},i=t.data&&"object"==typeof t.data?t.data:t,r="cx"in e?e.cx:e.x+e.w/2,o="cy"in e?e.cy:e.y+e.h/2;return{...i,...null==i.id&&null!=e.id?{id:e.id}:{},x:r,y:o}})}function iw(e,t){let i=xr(e.theme),r=e.chartType||"force",o=e.size||[500,500],n=tt({...Sd(r),...e.margin},e.title),a=Je(e.title),s=e.showLegend?(()=>{let t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;if(!t)return[];let o=pi(e.nodes||[]);if(o.length>0)return ic(o,t);if(ew.has(r)&&e.data)return ic(gv(e.data,e.childrenAccessor||"children"),t);let n=Array.isArray(e.edges)?pi(e.edges):[];if(0===n.length)return[];let a=Qv(e.sourceAccessor,"source"),s=Qv(e.targetAccessor,"target"),l=Array.from(new Set(n.flatMap(e=>[a(e),s(e)]).filter(e=>null!=e).map(String)));return ic(l.map(e=>({id:e})),t)})():[];rd(n,{props:e,categories:s,theme:i,size:o,hasTitle:a});let l,c=od({props:e,categories:s,theme:i,size:o,margin:n,hasTitle:a}),u=Math.max(1,o[0]-n.left-n.right),d=Math.max(1,o[1]-n.top-n.bottom),h=bd(e.backgroundGraphics,o,n,null),f=bd(e.foregroundGraphics,o,n,null),p=(r,a=[],s=[])=>(t&&(t.evidence=Fs({frameType:"network",width:o[0],height:o[1],marks:[...a.map(({node:e})=>({type:`node:${e.type??"node"}`})),...s.map(({node:e})=>({type:`edge:${e.type??"edge"}`}))],title:e.title,description:e.description,annotations:e.annotations,annotationRender:l,nodeCount:a.length,edgeCount:s.length,margin:n})),ix.renderToStaticMarkup(ad(/* @__PURE__ */Uv(Bv,{view:e.viewTransform,width:u,height:d,children:r}),{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?` ${e.className}`:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:u,innerHeight:d,legend:c,idPrefix:e._idPrefix}))),g=t=>{let r=e=>Number(e);return e.annotations?ku({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:r,y:r},layout:{width:u,height:d},theme:i,frameType:"network",annotationData:t&&tw(t),pointNodes:t&&Ev(t),idPrefix:e._idPrefix,onRender:e=>{l=e}}):null},m=()=>{let t=g(),i=h||f||e.annotations?/* @__PURE__ */Zv(Hv,{children:[h,t,f]}):null;return p(i)},y=nx(r);if(!y&&!e.customNetworkLayout)throw new Error(`No layout plugin found for chart type: "${r}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition, orbit.`);let x,b,v={chartType:r,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:!1,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig,perspective:e.perspective},w=O(e.perspective);if(ew.has(r)){let t=e.data||e.edges;if(!t||Array.isArray(t))return m();v.__hierarchyRoot=t,x=[],b=[]}else{let t=pi(e.nodes||[]),i=Array.isArray(e.edges)?pi(e.edges):[];if(0===t.length&&0===i.length)return m();let r=qv(t,i,v);x=Array.from(r.nodes,Kv),b=r.edges.map(Jv)}let k,A,S=[],M=[],$=[],_=null,L=null;if(v.customNetworkLayout){let t=v.colorScheme,r=Ip(t,i.colors.categorical,bi),o=Rp(r,t),n={nodes:x,edges:b,dimensions:{width:u,height:d,plot:{x:0,y:0,width:u,height:d}},theme:{sequential:i.colors.sequential,selectionOpacity:i.colors.selectionOpacity,semantic:i.colors,categorical:[...r]},resolveColor:o,config:v.layoutConfig??{},selection:e.layoutSelection??null,perspective:w?.config??null},a=v.customNetworkLayout(n);k=a.perspective,S=a.sceneNodes??[],M=a.sceneEdges??[],tx({nodes:S,edges:M,restyle:a.restyle,restyleEdge:a.restyleEdge,selection:e.layoutSelection??null,baseStyles:/* @__PURE__ */new WeakMap}),$=a.labels??[],_=a.backgrounds??null,L=a.overlays??null,A=a.perspectiveBounds}else if(y){y.computeLayout(x,b,v,[u,d]);let e=y.buildScene(x,b,v,[u,d]);S=e.sceneNodes,M=e.sceneEdges,$=e.labels}let I=[],R=w?(()=>{let e=E({sceneNodes:S,sceneEdges:M,labels:$,bounds:A,size:[u,d],perspective:w,chartType:r,theme:Y(i)});return S=e.sceneNodes,M=e.sceneEdges,$=e.labels,I=e.underlay,e.frame})():null,T=br(i);for(let e of $)e.fill||(e.fill=T.text);let C=Ol({nodes:M,renderMode:e.renderMode,fallback:(e,t)=>Tv(e,t)}),N=Ol({nodes:S,renderMode:e.renderMode,fallback:(e,t)=>Iv(e,t)}),F=C.map(e=>e.element),D=N.map(e=>e.element),z=$.map((e,t)=>Nv(e,t)).filter(Boolean),j=g(S),W=/* @__PURE__ */Zv(Hv,{children:[h,P(_,R,k),I.map((e,t)=>Tv(e,t)),F,D,z,j,P(f,R),P(L,R,k)]});return p(W,N,C)}import*as rw from"react-dom/server.browser";function ow(e){return e.world.bodies.map(e=>({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:{...e.shape},sleeping:e.sleeping,datum:e.datum}))}function nw(e=[]){return e.map(e=>({id:e.id,label:e.label,count:e.count,...null!=e.secondary?{secondary:e.secondary}:{},...e.secondaryLabel?{secondaryLabel:e.secondaryLabel}:{},...null!=e.observed?{observed:e.observed}:{}}))}function aw(e,t,i,r){let o=e-(t+i+r);return{charge:e,live:t,queued:i,sedimented:r,unaccounted:o,balanced:0===o}}function sw(e,t={}){let i=t.bodies??ow(e),r=i.filter(e=>e.sleeping).length,o=e.queue.length,n=e.sediment.reduce((e,t)=>e+t.count,0),a="settled"===e.simulationState&&0===o&&r===i.length,s=[];a||s.push("PHYSICS_NOT_SETTLED"),o>0&&s.push("PHYSICS_QUEUE_UNDRAINED");let l=null!=t.charge&&Number.isFinite(t.charge)?aw(t.charge,i.length,o,n):void 0;return l&&!l.balanced&&s.push("PHYSICS_LEDGER_MISMATCH"),{bodyCount:i.length,sleepingCount:r,settled:a,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:nw(t.projectionRows),queuedCount:o,sedimentedCount:n,...l?{ledger:l}:{},warnings:s}}var lw={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function cw(e){return e.datum&&"object"==typeof e.datum?e.datum:null}function uw(e){let t=e.datum;if(t&&"object"==typeof t){let e=t,i=e.label??e.name??e.id;if(null!=i&&""!==i)return String(i)}return e.id}function dw(e,t,i){let r="function"==typeof t?t(e,i):t;return{...lw,...r??{}}}function hw(e,t={},i={index:0,simulationState:"settled"}){let r=cw(e),o={label:t.getBodyLabel?.(e)??uw(e)},n={style:dw(e,t.bodyStyle,i),datum:r,accessibleDatum:r,accessibility:o,_transitionKey:e.id};return"aabb"===e.shape.type?{type:"rect",x:e.x-e.shape.width/2,y:e.y-e.shape.height/2,w:e.shape.width,h:e.shape.height,...n}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...n}}function fw(e,t={},i="settled"){return e.map((e,r)=>hw(e,t,{index:r,simulationState:i}))}function pw(e,t={}){let i=e.settle(t.maxSteps),r=e.readBodies(),o=e.snapshot();return{snapshot:o,bodies:r,sceneNodes:fw(r,t,o.simulationState),evidence:sw(o,{bodies:r,projectionRows:t.projectionRows,stepsRun:i,charge:t.charge}),stepsRun:i}}import{jsx as gw,jsxs as mw}from"react/jsx-runtime";function yw(e){let t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?`physics-${t}`:t}var xw={top:0,right:0,bottom:0,left:0};function bw(e,t,i){return"function"==typeof e?e({size:t,margin:i}):e}function vw(e,t={}){let{width:i=640,height:r=360,title:o,description:n,background:a,backgroundGraphics:s,backgroundGraphicsBackdrop:l,className:c,foregroundGraphics:u,idPrefix:d="physics",margin:h,style:f,renderBodySVG:p,renderChrome:g,...m}=t,y=pw(e,m),x={...xw,...h},b=[i,r],v=bw(s,b,x),w=bw(u,b,x),k=yw(d),A=o?`${k}-title`:void 0,S=n?`${k}-desc`:void 0,M=[A,S].filter(Boolean).join(" ")||void 0,$=x.left||x.top?`translate(${x.left},${x.top})`:void 0,_=Math.max(1,i-x.left-x.right),P=Math.max(1,r-x.top-x.bottom),L=`${k}-plot-clip`,I=$&&null!=v?/* @__PURE__ */gw("g",{transform:$,children:v}):v;return{element:/* @__PURE__ */mw("svg",{xmlns:"http://www.w3.org/2000/svg",className:c??"stream-physics-frame",width:i,height:r,viewBox:`0 0 ${i} ${r}`,role:"img","aria-labelledby":M,style:f,children:[o&&/* @__PURE__ */gw("title",{id:A,children:o}),n&&/* @__PURE__ */gw("desc",{id:S,children:n}),
272
+ /* @__PURE__ */gw("defs",{children:/* @__PURE__ */gw("clipPath",{id:L,children:/* @__PURE__ */gw("rect",{width:_,height:P})})}),l&&"transparent"!==l?/* @__PURE__ */gw("rect",{className:"stream-frame-background__backdrop",x:0,y:0,width:i,height:r,fill:l}):null,!s&&a&&"transparent"!==a?/* @__PURE__ */gw("rect",{x:0,y:0,width:i,height:r,fill:a}):null,I,
273
+ /* @__PURE__ */gw("g",{id:`${k}-data-area`,transform:$,clipPath:`url(#${L})`,children:y.sceneNodes.map((e,t)=>{let i=y.bodies[t],r=i&&p?p(i,e.style??{},t,k):void 0;return null!=r?Ml(r,e,t):Ml("point"===e.type||"rect"===e.type?wl(e,t,k):null,e,`xy-cursor-${t}`)})}),w,g?.(y)]}),scene:y,evidence:y.evidence}}function ww(e,t={}){let{element:i,scene:r,evidence:o}=vw(e,t);return{svg:rw.renderToStaticMarkup(i),scene:r,evidence:o}}function kw(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Aw(e,t){let i="sensor"===e.physics?t.sensorThickness:t.barrierThickness;return Math.max(0,kw(e.thickness)??kw(i)??kw(t.thickness)??4)}function Sw(e=[],t={}){let i=t.idPrefix?`${t.idPrefix}-`:"",r=[];for(let o of e){if("barrier"!==o.physics&&"sensor"!==o.physics)continue;let e,n=o.axis??t.defaultAxis??"x",a=Aw(o,t),s=o.colliderId??`${i}${o.id}`;if("x"===n){let i=kw(o.x),r=kw(o.y1)??kw(t.plotBounds?.y)??kw(o.y),n=kw(o.y2)??(t.plotBounds?t.plotBounds.y+t.plotBounds.height:void 0)??kw(o.y);if(null==i||null==r||null==n)continue;e={type:"segment",x1:i,y1:r,x2:i,y2:n,thickness:a}}else{let i=kw(o.y),r=kw(o.x1)??kw(t.plotBounds?.x)??kw(o.x),n=kw(o.x2)??(t.plotBounds?t.plotBounds.x+t.plotBounds.width:void 0)??kw(o.x);if(null==i||null==r||null==n)continue;e={type:"segment",x1:r,y1:i,x2:n,y2:i,thickness:a}}r.push({id:s,shape:e,sensor:"sensor"===o.physics,..."barrier"!==o.physics||null==o.restitution&&null==t.barrierRestitution?{}:{restitution:kw(o.restitution)??kw(t.barrierRestitution)},..."barrier"!==o.physics||null==o.friction&&null==t.barrierFriction?{}:{friction:kw(o.friction)??kw(t.barrierFriction)}})}return r}function Mw(e){return e.sensorId??`stream-region-${e.id}`}function $w(e){let t=Mw(e),i={bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution};if("boundary"===e.collider&&"aabb"===e.shape.type){let r=e.colliderThickness??8,o=e.shape.x-e.shape.width/2,n=e.shape.x+e.shape.width/2,a=e.shape.y-e.shape.height/2,s=e.shape.y+e.shape.height/2;return[{...i,id:`${t}-top`,shape:{type:"segment",x1:o,y1:a,x2:n,y2:a,thickness:r}},{...i,id:`${t}-right`,shape:{type:"segment",x1:n,y1:a,x2:n,y2:s,thickness:r}},{...i,id:`${t}-bottom`,shape:{type:"segment",x1:n,y1:s,x2:o,y2:s,thickness:r}},{...i,id:`${t}-left`,shape:{type:"segment",x1:o,y1:s,x2:o,y2:a,thickness:r}}]}return e.collider?[{...i,id:`${t}-collider`,shape:e.shape}]:[]}function _w({annotations:e,chartId:t,chartType:i,config:r,onRegionObservation:o,regionEffects:n,seed:a,size:s}){let l=Sw((e??[]).filter(e=>"barrier"===e.physics||"sensor"===e.physics),{idPrefix:t?`${t}-ann`:"physics-ann",plotBounds:{x:0,y:0,width:s[0],height:s[1]}}),c=void 0===a||void 0!==r?.kernel?.seed?r:{...r,kernel:{...r?.kernel,seed:a}},u=n.flatMap(e=>[{id:Mw(e),sensor:!0,shape:e.shape,bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution},...$w(e)]),d=Object.fromEntries(n.map(e=>[Mw(e),{binId:e.binId??e.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),h=c?.observation,f=n.length>0,p=u.length>0||l.length>0;return f||p||null!=t||h?{...c,colliders:[...c?.colliders??[],...u,...l],observation:{...h,chartId:t??h?.chartId,chartType:h?.chartType??i,sensors:{...h?.sensors??{},...d},onObservation:e=>{f&&o(e),h?.onObservation?.(e)}}}:c}import{jsx as Pw}from"react/jsx-runtime";function Lw({title:e,totalWidth:t,marginTop:i}){return e?"string"!=typeof e?/* @__PURE__ */Pw("foreignObject",{x:0,y:0,width:t,height:i,children:e}):/* @__PURE__ */Pw("text",{x:t/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",fontSize:14,className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)",fontFamily:"var(--semiotic-title-font-family, var(--semiotic-font-family, sans-serif))",fontWeight:"var(--semiotic-title-font-weight, bold)"},children:e}):null}import{jsx as Iw,jsxs as Rw}from"react/jsx-runtime";function Tw(e,t,i,r,o){let n=Math.max(1,i[0]-r.left-r.right),a=Math.max(1,i[1]-r.top-r.bottom),s=Ky(t.annotations),l=Qy({width:n,height:a,pointNodes:Zy(e.bodies)}),c=l.scales?.x,u=l.scales?.y;if(!c||!u)throw new Error("Physics annotation context requires pixel scales");let d,h=ku({annotations:s,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{x:c,y:u},layout:{width:n,height:a},theme:o,frameType:"network",xAccessor:l.xAccessor,yAccessor:l.yAccessor,pointNodes:l.pointNodes,svgAnnotationRules:t.svgAnnotationRules,onRender:e=>{d=e}}),f=t.legend?id(t.legend,{theme:o,position:t.legendPosition,size:[i[0],i[1]],margin:r,hasTitle:!!t.title,legendLayout:t.legendLayout})??Mu(t.legend,i,r,t.legendPosition,t.legendLayout):null;return{annotationRender:d,node:/* @__PURE__ */Rw("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:i[0],height:i[1],style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[
274
+ /* @__PURE__ */Iw("g",{transform:`translate(${r.left},${r.top})`,children:h}),
275
+ /* @__PURE__ */Iw(Lw,{title:t.title,totalWidth:i[0],marginTop:Math.max(r.top,28)}),f]})}}var Cw={top:0,right:0,bottom:0,left:0};function Nw(e,t){let i=e.size??[e.width??600,e.height??400],r=xr(e.theme),o=void 0===e.theme?{}:V(r),n=e.bodyStyle,a=!1,s=e.legendPosition??"right",l=et({...Cw,...e.margin},a);if(e.legend){let t={...l};gt(l,{legend:e.legend,position:s,size:i,hasTitle:a,legendLayout:e.legendLayout}),it(l,t,i,s)}let c,u=[Math.max(1,i[0]-l.left-l.right),Math.max(1,i[1]-l.top-l.bottom)],d=_w({annotations:e.annotations,chartId:e.chartId,chartType:"StreamPhysicsFrame",config:e.config,onRegionObservation:()=>{},regionEffects:e.regionEffects??[],seed:e.seed,size:u}),h=new re(d);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&h.enqueue(e.initialSpawns,e.initialSpawnPacing);let f=ww(h,{...e,width:i[0],height:i[1],background:e.background??r.colors.background,bodyStyle:(e,t)=>({fill:r.colors.primary,stroke:r.colors.text,strokeWidth:1,opacity:.9,..."function"==typeof n?n(e,t):n}),style:{...o,fontFamily:r.typography.fontFamily,...e.style},charge:e.charge,idPrefix:e.idPrefix??e._idPrefix??"physics",margin:l,renderChrome:t=>{let o=Tw(t,e,i,l,r);return c=o.annotationRender,o.node}});return t&&(t.evidence=Fs({frameType:"physics",width:i[0],height:i[1],marks:f.scene.sceneNodes,title:e.title,description:e.description,annotations:e.annotations,annotationRender:c,extraWarnings:[...0===f.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[],...f.scene.evidence.warnings]})),f.svg}function Fw(e,t,i){return{frameType:e.frameType,layout:{...e.layout,...i&&{margin:i}},buildProps:(i,r,o,n,a)=>{let[s,l]=n.size,c=t({...a,...n,width:s,height:l,colorScheme:o});return e.buildProps(c.data,r,o,{...n,...null!=c.annotations&&{annotations:c.annotations},...c.frameProps,title:c.title,description:c.description,summary:c.summary,accessibleTable:c.accessibleTable},{...a,...c})}}}var Dw=Fw(ep,function({atlas:e,linkedHover:t,...i},r=N(e)){return{...i,linkedHover:ky(t),title:i.title??e.spec.dataRevision,description:i.description??"Motif Braid. Labeled squares show successive journey steps; parallel strands split at diverging prefixes and taper with per-step traffic.",summary:i.summary??`${r.groups.length} supported journey groups. Counts use ${e.spec.motifs.countUnit}; overlapping motifs do not partition the population. Source revision: ${e.provenance.sourceRevision}.`,accessibleTable:i.accessibleTable??!0,nodes:r.sceneSeeds.nodes,edges:r.sceneSeeds.edges,layout:$e,layoutConfig:{braid:r}}}),Ew=Fw(ep,function({width:e=Gt.width,height:t=Gt.height,title:i="Dependency X-Ray",description:r,summary:o,accessibleTable:n=!0,chartId:a,className:s,onObservation:l,linkedHover:c,linkedSelection:u,annotations:d,frameProps:h,perspective:f,onSelectNode:p,...g}){return{nodes:g.forest.sceneSeeds.nodes,edges:g.forest.sceneSeeds.edges,layout:_y,layoutConfig:g,nodeIDAccessor:"id",sourceAccessor:"source",targetAccessor:"target",width:e,height:t,title:i,chartId:a,className:s,onObservation:l,linkedHover:ky(c),selection:u,annotations:d,frameProps:h,perspective:f,animate:!1,margin:{top:12,right:24,bottom:12,left:12},description:r??`Sections organize the admitted directed graph. Backbone links organize the drawing; residual links retain other original edges. Brackets describe required paths, separately from transport. Roots: ${g.forest.atlas.requiredPaths?.roots.join(", ")??"not declared"}. Relation scope: directed-admitted. Completeness: ${g.forest.atlas.requiredPaths?.status??"not prepared"}.`,summary:o??`Roots: ${g.forest.atlas.requiredPaths?.roots.join(", ")??"not declared"}. Relation scope: directed-admitted. Required-path completeness: ${g.forest.atlas.requiredPaths?.status??"not prepared"}. ${g.forest.residual.originalEdgeIds.length} original edges retained.`,accessibleTable:n}},{top:12,right:24,bottom:12,left:12}),zw=Fw(wy,ex),Ow=Fw(ep,function(e){let{key:t,data:i,layout:r,paused:o,frameProps:n,...a}=ex(e);return{...a,annotations:Ky(a.annotations),nodes:i,edges:e.circuit.atlas.source.edges,layout:Vy,perspective:e.perspective,margin:0,frameProps:{...e.frameProps&&{background:e.frameProps.background,backgroundGraphics:e.frameProps.backgroundGraphics,foregroundGraphics:e.frameProps.foregroundGraphics},...e.networkFrameProps},tooltip:e=>`${e.label??e.id??"Circuit"}: ${"circuit-pipe"===e.kind?`${e.perSecond??"unmeasured"} ${e.unit}/s`:`${e.completions??"unmeasured"} ${e.unit??"units"}/s completed; queue ${e.queued??"unmeasured"}`}`}}),jw={...zw,resolveFrameType:e=>e._projectedCircuit?"network":"physics",buildProps:(...e)=>{let t=O(e[4].perspective);return{...(t?Ow:zw).buildProps(...e),_projectedCircuit:!!t}},renderStatic:(e,t)=>e._projectedCircuit?iw(e,t):Nw(e,t)};import{scaleTime as Ww}from"d3-scale";var Bw={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}};function Yw(e="static"){return Bw[e]??Bw.static}var Gw=/* @__PURE__ */new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]);function Xw(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:Gw.has(e.kind)?"fatal":"warn"}function Vw(e){let t=[],i=[];for(let r of e)"fatal"===Xw(r)?t.push(r):i.push(r);return{fatal:t,warnings:i}}function qw(e,t,i,r={}){let o=Yw(r.usageMode??"static"),n=[],a=/* @__PURE__ */new Set;for(let t of e)a.has(t.id)&&n.push({kind:"duplicate-node",id:t.id,severity:o.duplicateIds}),a.add(t.id);let s=/* @__PURE__ */new Set,l=Array.isArray(i)&&2===i.length,c=l&&Number.isFinite(i[0])&&Number.isFinite(i[1]),u=c&&i[0]<=i[1];(!l||!c||!u)&&n.push({kind:"invalid-domain"});for(let 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[0]<=t.xExtent[1]||n.push({kind:"invalid-node-time",id:t.id}));for(let e of t)s.has(e.id)&&n.push({kind:"duplicate-edge",id:e.id,severity:o.duplicateIds}),s.add(e.id),a.has(e.source)||n.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),a.has(e.target)||n.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))&&n.push({kind:"invalid-system-time",id:e.id,severity:"warn"}),(!Number.isFinite(e.value)||e.value<=0)&&n.push({kind:"invalid-value",id:e.id}),e.endTime<e.startTime&&n.push({kind:"backward-edge",severity:"fatal",id:e.id,source:e.source,target:e.target})):n.push({kind:"invalid-edge-time",id:e.id});return n}function Hw(e,t,i="static"){if("strip"!==Yw(i).invalidSystemTime)return e;let r=new Set(t.filter(e=>"invalid-system-time"===e.kind).map(e=>e.id));return 0===r.size?e:e.map(e=>{if(!r.has(e.id))return e;let t={...e};return null!=t.systemInTime&&!Number.isFinite(t.systemInTime)&&delete t.systemInTime,null!=t.systemOutTime&&!Number.isFinite(t.systemOutTime)&&delete t.systemOutTime,t})}function Uw(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 Zw(){/* */
276
+ return Object.create(null)}function Qw(e,t){return e<t?-1:e>t?1:0}function Kw(e){return e.occupants.map(e=>e.id).sort(Qw).join("\0")}function Jw(e,t,i=0){return e.slice(0,-1).map((r,o)=>{let n=e[o+1];return null!=r.group&&r.group===n.group?i:t})}function ek(e,t){return e.map(e=>{let i=/* @__PURE__ */new Map;for(let r of e.occupants){let e=t[r.id];if(e)for(let t of e.samples){let e=i.get(t.t)??{before:0,after:0},r=t.boundaryOffset??0;i.set(t.t,{before:Math.max(e.before,t.topMass-r),after:Math.max(e.after,t.botMass+r)})}}return[...i].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function tk(e,t,i){return Pe(ek([e,t],i)).adjacentClearance[0]??0}function ik(e,t,i){if(0===e.length)return[];let{padding:r,plotH:o,valueScale:n}=i,a=i.stackValueScale??n,s=Jw(e,r,i.groupPadding??0),l=[r+e[0].peak.topPeak*a];for(let i=1;i<e.length;i++)l.push(l[i-1]+t[i-1]*a+s[i-1]);let c=l[l.length-1]+e[e.length-1].peak.botPeak*a+r;if(c>o&&c>0){let e=o/c;for(let t=0;t<l.length;t++)l[t]*=e}return l}function rk(e,t){let i=(e.boundaryOffset??0)*t,r=e.value*t;if("out"===e.kind){let o=e.sideMassBefore*t;return i+("top"===e.side?r/2-o:o-r/2)}let o=e.sideMassAfter*t;return i+("top"===e.side?r/2-o:o-r/2)}function ok(e,t,i,r,o,n,a){let s=e.length;if(0===s)return[];let{padding:l,plotH:c,valueScale:u}=a,d=Jw(e,l,a.groupPadding??0),h=o.map((e,t)=>e*u+d[t]),f=l+e[0].peak.topPeak*u,p=c-l-e[s-1].peak.botPeak*u;if(p-f<=h.reduce((e,t)=>e+t,0)+1e-6)return ik(e,o,a);let g=1===s?[(f+p)/2]:[...n];for(let e=0;e<12;e++){let e=new Array(s).fill(0),o=new Array(s).fill(0);for(let n of i){let i=t[n.source],a=t[n.target];if(null==i||null==a||i===a)continue;let s=r[n.source]?.localAttachments.get(n.id),l=r[n.target]?.localAttachments.get(n.id);if(!s||!l)continue;let c=n.value>0&&Number.isFinite(n.value)?n.value:1,d=rk(s,u),h=rk(l,u);e[i]+=(g[a]+h-d)*c,o[i]+=c,e[a]+=(g[i]+d-h)*c,o[a]+=c}let n=g.map((t,i)=>0===o[i]?t:.45*t+e[i]/o[i]*.55),a=se({desired:n,minGaps:h,weights:o.map(e=>Math.max(1,e)),min:f,max:p}),l=0;for(let e=0;e<s;e++)l=Math.max(l,Math.abs(a[e]-g[e]));if(g=a,l<.01)break}return g}function nk(e,t,i,r,o,n){let a=n.adjacentClearance?[...n.adjacentClearance]:Pe(ek(r,i)).adjacentClearance,s=ik(r,a,n),l="hug"===n.lanePlacement?ok(r,o,t,i,a,s,n):[...s];if("hug"===n.lanePlacement){let i=t=>{let i=Zw();for(let r of e)i[r.id]=t[o[r.id]];return i};ak(i(l),t)>ak(i(s),t)+1e-6&&(l=[...s])}let c=Zw();for(let t of e)c[t.id]=l[o[t.id]];let u=1/0,d=-1/0;for(let t of e){let e=c[t.id],r=i[t.id];!Number.isFinite(e)||!r||(u=Math.min(u,e-r.topPeak*n.valueScale),d=Math.max(d,e+r.botPeak*n.valueScale))}return{adjacentClearance:a,centerlines:c,slotCenter:l,stackCenter:s,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&n.plotH>0?Math.max(0,Math.min(1,(d-u)/n.plotH)):0}}function ak(e,t){let i=0;for(let r of t){let t=e[r.source],o=e[r.target];Number.isFinite(t)&&Number.isFinite(o)&&(i+=Math.abs(t-o)*(r.value>0?r.value:1))}return i}function sk(e,t){let i=e?.samples;if(!i||0===i.length||t<i[0].t)return{top:0,bot:0};let r=0,o=i.length-1,n=0;for(;r<=o;){let e=r+o>>>1;i[e].t<=t?(n=e,r=e+1):o=e-1}let a=i[n].boundaryOffset??0;return{top:i[n].topMass-a,bot:i[n].botMass+a}}function lk(e,t,i,r,o){let n=1-o;return n*n*n*e+3*n*n*o*t+3*n*o*o*i+o*o*o*r}function ck(e,t){let i=0,r=1;for(let o=0;o<28;o++){let o=(i+r)/2;lk(0,t,t,1,o)<e?i=o:r=o}return(i+r)/2}function uk(e,t,i){let r=t+rk(e,i),o=e.value*i/2;return[r-o,r+o]}function dk(e,t,i,r){return Math.max(0,Math.min(t,r)-Math.max(e,i))/Math.max(1e-9,t-e)}function hk(e,t,i,r,o,n,a){let{valueScale:s,domain:l,mode:c="quality"}=a,u="source"===a.ribbonLane?.85:"target"===a.ribbonLane?.15:.5,d=0;for(let a of e){let e=r[a.source],h=r[a.target];if(null==e||null==h||Math.abs(e-h)<2)continue;let f=t[a.source]?.localAttachments.get(a.id),p=t[a.target]?.localAttachments.get(a.id);if(!f||!p)continue;let g=Math.max(a.startTime,l?.[0]??-1/0),m=Math.min(a.endTime,l?.[1]??1/0);if(!(m>g))continue;let[y,x]=uk(f,o[a.source],s),[b,v]=uk(p,o[a.target],s),w=Math.min(e,h)+1,k=Math.max(e,h)-1;for(let e=w;e<=k;e++){let r=i[e];if(!r)continue;let l=[g,m];if("quality"===c)for(let e of r.occupants)for(let i of t[e.id]?.samples??[])i.t>g&&i.t<m&&l.push(i.t);let h=e=>{let i=ck((e-g)/(m-g),u),l=lk(y,y,b,b,i),c=lk(x,x,v,v,i),d=0;for(let i of r.occupants){if(i.id===a.source||i.id===a.target)continue;let r=n[i.id];if(null!=r?.start&&e<r.start||null!=r?.end&&e>r.end)continue;let u=sk(t[i.id],e),h=o[i.id];d=Math.max(d,dk(l,c,h-u.top*s,h+u.bot*s))}return d},f=[...new Set(l)].sort((e,t)=>e-t),p=0;for(let e=0;e<f.length-1;e++){let t=f[e],i=f[e+1]-t;p+=(h(t+.25*i)+h(t+.5*i)+h(t+.75*i))/3*i}d+=p/(m-g)*(a.value>0?a.value:1)}}return d}function fk(e,t,i,r,o,n,a,s,l,c,u="both",d){return{crossings:e,weightedLength:t,pixelLength:ak(a,i),transitOcclusion:hk(i,r,o,n,a,s,{valueScale:l,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:c}}function pk(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function gk(e,t){return e.map(e=>({t:pk(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function mk(e,t,i){let r=t+(e.boundaryOffset??0)*i,o=e.value*i;if("out"===e.kind){let t=e.sideMassBefore*i;if("top"===e.side){let e=r-t;return[e,e+o]}let n=r+t;return[n-o,n]}let n=e.sideMassAfter*i;if("top"===e.side){let e=r-n;return[e,e+o]}let a=r+n;return[a-o,a]}function yk(e,t,i,r,o){if(0===e.length)return null;let n=gk(e,o),a=e=>t+(n[e].boundaryOffset??0)*i,s=e=>a(e)-n[e].topMass*i,l=e=>a(e)+n[e].botMass*i,c=`M${r(n[0].t)},${s(0)}`;for(let e=1;e<n.length;e++)c+=` L${r(n[e].t)},${s(e)}`;c+=` L${r(n[n.length-1].t)},${l(n.length-1)}`;for(let e=n.length-2;e>=0;e--)c+=` L${r(n[e].t)},${l(e)}`;return c+" Z"}function xk(e,t,i,r,o,n){let a=i.nodeData[e];if(!a||0===a.samples.length)return[];let s=i.valueScale,l=i.centerlines[e],c=gk(a.samples,o),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],h=r(u.t),f=r(d.t),p=e=>r(pk(e,o)),g=[],m=(e,t,i,r)=>`M${e},${t} L${i},${t} L${i},${r} L${e},${r} Z`;for(let i of t){if(i.source===e&&null!=i.systemInTime&&Number.isFinite(i.systemInTime)){let e=a.localAttachments.get(i.id),t=n?.get(i.id)??i.startTime;if(e&&"out"===e.kind&&i.systemInTime<t){let r=p(i.systemInTime),n=p(t),a=null!=o&&i.systemInTime<o[0],c=a?r:r-20,u=a?Math.min(n,r+20):r,d=Math.max(h,c);if(n>d){let[t,i]=mk(e,l,s);g.push({pathD:m(d,t,n,i),x0:c,x1:u,from:0,to:1})}}}if(i.target===e&&null!=i.systemOutTime&&Number.isFinite(i.systemOutTime)){let e=a.localAttachments.get(i.id);if(e&&"in"===e.kind&&i.systemOutTime>i.endTime){let t=p(i.systemOutTime),r=p(i.endTime),o=t+20,n=Math.min(f,o);if(n>r){let[i,a]=mk(e,l,s);g.push({pathD:m(r,i,n,a),x0:t,x1:o,from:1,to:0})}}}}return g}function bk(e,t){let i=Zw(),r=Zw();for(let t of e)i[t.id]=[],r[t.id]=[];for(let e of t)r[e.source]&&r[e.source].push(e),i[e.target]&&i[e.target].push(e);return{incoming:i,outgoing:r}}function vk(e,t,i,r="temporal"){let o="temporal"===r?(e,t)=>e.endTime-t.endTime||Qw(e.id,t.id):(e,t)=>t.value-e.value||Qw(e.id,t.id),n="temporal"===r?(e,t)=>e.startTime-t.startTime||Qw(e.id,t.id):(e,t)=>t.value-e.value||Qw(e.id,t.id),a=/* @__PURE__ */new Map;for(let e of t)a.set(e.id,{});let s=(e,t)=>{let i=/* @__PURE__ */new Map;for(let r of e){let e=r[t];i.has(e)||i.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});let o=i.get(e);o.edges.push(r),o.total+=r.value,o.earliestStart=Math.min(o.earliestStart,r.startTime),o.latestEnd=Math.max(o.latestEnd,r.endTime)}let a=[...i.values()];"temporal"===r?a.sort((e,i)=>"target"===t?e.earliestStart-i.earliestStart||Qw(e.partner,i.partner):e.latestEnd-i.latestEnd||Qw(e.partner,i.partner)):a.sort((e,t)=>t.total-e.total||Qw(e.partner,t.partner));for(let e of a)e.edges.sort("target"===t?n:o);return a};for(let t of e){let e=i.outgoing[t.id],r=i.incoming[t.id];if(0===r.length)s(e,"target").forEach((e,t)=>{let i=t%2==0?"top":"bot";for(let t of e.edges)a.get(t.id).sourceSide=i});else if(0===e.length)s(r,"source").forEach((e,t)=>{let i=t%2==0?"top":"bot";for(let t of e.edges)a.get(t.id).targetSide=i});else{let t=s(r,"source"),i=s(e,"target"),o=Math.max(t.length,i.length);for(let e=0;e<o;e++){let r=e%2==0?"top":"bot";if(t[e])for(let i of t[e].edges)a.get(i.id).targetSide=r;if(i[e])for(let t of i[e].edges)a.get(t.id).sourceSide=r}}}return a}function wk(e,t,i,r,o="temporal"){let n=t.incoming[e.id],a=t.outgoing[e.id],s=[];for(let e of n)s.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:i.get(e.id).targetSide});for(let e of a)s.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:i.get(e.id).sourceSide});let l={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},c=(e,t)=>{if(!r||!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;let i=r.get(e.edge.id)?.target,o=r.get(t.edge.id)?.target;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?i-o:o-i:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;let i=r.get(e.edge.id)?.source,o=r.get(t.edge.id)?.source;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?o-i:i-o:0}return 0},u=()=>{s.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)||c(e,t)||Qw(e.edge?.id??"",t.edge?.id??"")||Qw(e.side,t.side)||e.delta-t.delta)},d=s.length?Ne(s.map(e=>e.time)):null,h=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,f=null!=h?h-1:null!=d&&Number.isFinite(d)?d-1:null;u();let p=null,g=0;for(let e of s)e.time!==p&&(p=e.time,g=0),e.sequence=g++;let m=e=>({time:e.time,phase:0,sequence:e.sequence??0}),y=[],x=0,b=0;for(let e of s)if("out"===e.kind){let t=Math.abs(e.delta),i=t-("top"===e.side?x:b);if(i>0){let t="top"===e.side?"bot":"top",r=Math.min(i,"top"===t?x:b);if(r>0){let o=m(e);y.push({...o,delta:-r,kind:"transfer-out",side:t}),y.push({...o,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?x-=r:b-=r,"top"===e.side?x+=r:b+=r,i-=r}i>0&&null!==f&&(y.push({time:f,delta:+i,kind:"create",side:e.side}),"top"===e.side?x+=i:b+=i)}"top"===e.side?x-=t:b-=t}else if("in"===e.kind){let t=Math.abs(e.delta);"top"===e.side?x+=t:b+=t}s.push(...y),u();let v=0,w=0,k=0,A=0,S=0,M=0,$=[],_=/* @__PURE__ */new Map,P=e=>{$.push({t:e,topMass:v,botMass:w,...Math.abs(k)>1e-12&&{boundaryOffset:k}})},L=()=>{A=Math.max(A,v+w),S=Math.max(S,v-k),M=Math.max(M,w+k)};for(let e of s){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&P(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){let t="top"===e.side?v:w,i=t+e.delta;_.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:i,kind:e.kind,value:Math.abs(e.delta),...Math.abs(k)>1e-12&&{boundaryOffset:k}})}"top"===e.side?v+=e.delta:w+=e.delta,"transfer-in"===e.kind?(k+="top"===e.side?e.delta:-e.delta,L(),P(e.time)):"transfer-out"!==e.kind&&(L(),"out"===e.kind&&v+w<=1e-12&&(k=0),P(e.time))}let I=[],R=0;for(;R<$.length;){let e=R;for(;e+1<$.length&&$[e+1].t===$[R].t;)e++;I.push($[R]);for(let t=R+1;t<=e;t++){let e=I[I.length-1];($[t].topMass!==e.topMass||$[t].botMass!==e.botMass||($[t].boundaryOffset??0)!==(e.boundaryOffset??0))&&I.push($[t])}R=e+1}let T=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null,C=null;for(let e of a)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.systemInTime<e.startTime&&(null===C||e.systemInTime<C)&&(C=e.systemInTime);let N=null;for(let e of n)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===N||e.systemOutTime>N)&&(N=e.systemOutTime);if(I.length>0){let e=I[I.length-1],t=Math.max(T??-1/0,N??-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&I.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});let i,r=I[0],o=I.find(e=>e.topMass+e.botMass>0),n=1/0;null!=h&&Number.isFinite(h)&&h<r.t&&r.topMass+r.botMass>0&&(n=h,i=r),o&&null!=C&&Number.isFinite(C)&&C<o.t&&C<n&&(n=C,i=o),i&&Number.isFinite(n)&&I.unshift({t:n,topMass:i.topMass,botMass:i.botMass,...null!=i.boundaryOffset&&{boundaryOffset:i.boundaryOffset}})}let F=I;if("max"===o&&null!=h&&null!=T&&T>h){let e,t=0;for(let i of I){let r=i.topMass+i.botMass;r>t&&(t=r,e=i)}if(e){let t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};F=[...I.filter(e=>e.t<h),{t:h,...t},{t:T,...t},...I.filter(e=>e.t>T)]}}return{samples:F,peak:A,topPeak:S,botPeak:M,localAttachments:_}}function kk(e,t,i,r){let o=/* @__PURE__ */new Map;for(let n of e){let e=t[n.source]?.localAttachments.get(n.id),a=t[n.target]?.localAttachments.get(n.id),s=i[n.source],l=i[n.target];if(!(e&&a&&Number.isFinite(s)&&Number.isFinite(l)))continue;let c=mk(e,s,r),u=mk(a,l,r);o.set(n.id,{source:(c[0]+c[1])/2,target:(u[0]+u[1])/2})}return o}function Ak(e,t){let i=(e,i)=>{for(let r of e){let e=/* @__PURE__ */new Map;for(let o of r){let r=`${("out"===i?t.get(o.id)?.sourceSide:t.get(o.id)?.targetSide)??""}\0${"out"===i?o.startTime:o.endTime}`,n="out"===i?`${o.target}\0${o.endTime}`:`${o.source}\0${o.startTime}`,a=e.get(r);if(null!=a&&a!==n)return!0;e.set(r,n)}}return!1};return i(Object.values(e.outgoing),"out")||i(Object.values(e.incoming),"in")}function Sk(e,t,i){let r=/* @__PURE__ */new Map,o=[];for(let t of e)o.push({time:t.startTime,kind:"out",edge:t}),o.push({time:t.endTime,kind:"in",edge:t});o.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)||Qw(e.edge.id,t.edge.id));let n=e=>{let t=r.get(e);return t||(t={top:0,bot:0},r.set(e,t)),t},a=(e,t,i)=>{let r="top"===t?"bot":"top",o=Math.min(i,e[t]);e[t]-=o;let n=i-o;n>0&&(e[r]=Math.max(0,e[r]-n))};for(let e of o){let{edge:r}=e;if("in"===e.kind){let e=t.get(r.id)?.targetSide??"bot";n(r.target)[e]+=r.value;continue}let o=n(r.source),s=t.get(r.id),l=s.sourceSide??"bot";if(i[r.source]===i[r.target]){let e=o.top>=r.value,t=o.bot>=r.value;e!==t?l=e?"top":"bot":!e&&!t&&o.top!==o.bot&&(l=o.top>o.bot?"top":"bot"),s.sourceSide=l,s.targetSide=l}a(o,l,r.value)}}function Mk(e,t,i,r){for(let o of e){let e=t.incoming[o.id],n=t.outgoing[o.id];if(0===e.length||0===n.length)continue;let a=()=>{let t={inTop:0,inBot:0,outTop:0,outBot:0};for(let r of e)"top"===i.get(r.id).targetSide?t.inTop+=r.value:t.inBot+=r.value;for(let e of n)"top"===i.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},s=(e,t)=>{let o=a(),s="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,l="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(s<=0||l<=0)return!1;let c=Math.min(s,l),u=n.filter(t=>!r.has(t.id)&&i.get(t.id).sourceSide===e&&t.value<=c).sort((e,t)=>t.value-e.value||Qw(e.id,t.id));return 0!==u.length&&(i.get(u[0].id).sourceSide=t,!0)},l=n.length+1;for(;l-- >0&&(s("top","bot")||s("bot","top")););}}var $k=(e,t)=>{let i=0,r=e.length;for(;i<r;){let o=i+r>>>1;e[o]<t?i=o+1:r=o}return i},_k=class{constructor(e){this.coordinates=[...new Set(e)].sort((e,t)=>e-t),this.tree=new Int32Array(this.coordinates.length+1)}add(e,t){for(let i=$k(this.coordinates,e)+1;i<this.tree.length;i+=i&-i)this.tree[i]+=t}below(e){let t=0;for(let i=$k(this.coordinates,e);i>0;i-=i&-i)t+=this.tree[i];return t}};function Pk(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.max(e.startTime,t.startTime)<Math.min(e.endTime,t.endTime)}var Lk=class{constructor(e,t,i){this.size=i,this.routes=[],this.outgoing=Array.from({length:i},()=>[]),this.incoming=Array.from({length:i},()=>[]);let r=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;for(let e of t.keys())o.set(e,o.size);this.nodeCount=o.size;for(let i of e){let e=t.get(i.source),n=t.get(i.target);if(void 0===e||void 0===n||!(i.startTime<i.endTime))continue;let a=o.get(i.source),s=o.get(i.target),l=`${a}:${s}`;r.has(l)||r.set(l,r.size);let c=this.routes.length;this.routes.push({edge:i,source:e,target:n,sourceNode:a,targetNode:s,pair:r.get(l),reverse:-1}),this.outgoing[e].push(c),this.incoming[n].push(c)}for(let e of this.routes)e.reverse=r.get(`${e.targetNode}:${e.sourceNode}`)??-1;if(this.events=this.routes.flatMap((e,t)=>[{time:e.edge.startTime,route:t,delta:1},{time:e.edge.endTime,route:t,delta:-1}]).sort((e,t)=>e.time-t.time||e.delta-t.delta||e.route-t.route),this.smallPairs=this.routes.length<=80?[]:null,this.smallPairs)for(let e=0;e<this.routes.length;e++)for(let t=e+1;t<this.routes.length;t++)Pk(this.routes[e].edge,this.routes[t].edge)&&this.smallPairs.push([e,t]);this.work=this.smallPairs?.length??1/0}crossing(e,t,i){return(i[e.source]-i[t.source])*(i[e.target]-i[t.target])<0?1:0}count(e){if(this.smallPairs){let t=0;for(let[i,r]of this.smallPairs)t+=this.crossing(this.routes[i],this.routes[r],e);return t}let t=Array.from({length:this.size+1},()=>[]);for(let i of this.routes){let r=e[i.source],o=e[i.target];for(let e=r+1;e<=this.size;e+=e&-e)t[e].push(o)}let i=t.map(e=>new _k(e)),r=new Int32Array(4*this.nodeCount),o=new Int32Array(this.routes.length),n=(e,t)=>{let r=0;for(let o=e;o>0;o-=o&-o)r+=i[o].below(t);return r},a=0;for(let t of this.events){let s=this.routes[t.route],l=e[s.source],c=e[s.target];1===t.delta&&(a+=n(l,this.size)-n(l,c+1)+n(this.size,c)-n(l+1,c),l!==c&&(a-=r[4*s.sourceNode+(l<c?1:0)],a-=r[4*s.targetNode+(l<c?2:3)],s.reverse>=0&&(a+=o[s.reverse])));for(let e=l+1;e<=this.size;e+=e&-e)i[e].add(c,t.delta);l!==c&&(r[4*s.sourceNode+(l<c?3:2)]+=t.delta,r[4*s.targetNode+(l<c?0:1)]+=t.delta),o[s.pair]+=t.delta}return a}swapDelta(e,t,i){let r=0,o=0,n=r=>i[r===e?t:r===t?e:r],a=(e,t)=>{let a=this.routes[e],s=this.routes[t];if(!Pk(a.edge,s.edge))return;o++;let l=(n(a.source)-n(s.source))*(n(a.target)-n(s.target))<0?1:0;r+=l-this.crossing(a,s,i)};for(let i of this.outgoing[e])for(let e of this.outgoing[t])a(i,e);for(let i of this.incoming[e])for(let r of this.incoming[t]){let o=this.routes[i],n=this.routes[r];o.source===e&&n.source===t||o.source===t&&n.source===e||a(i,r)}return{delta:r,evaluations:o}}};function Ik(e){let t=Zw();return e.forEach((e,i)=>{for(let r of e.occupants)t[r.id]=i}),t}function Rk(e,t,i){e.splice(0,e.length,...i);let r=Ik(i);for(let e of Object.keys(t))delete t[e];Object.assign(t,r)}function Tk(e){let t=/* @__PURE__ */new Map,i=[];e.forEach((e,r)=>{if(!e.group)return void i.push({anchor:r,stableId:Kw(e),slots:[e]});let o=t.get(e.group)??{indexes:[],slots:[]};o.indexes.push(r),o.slots.push(e),t.set(e.group,o)});for(let[e,r]of t)i.push({anchor:r.indexes.reduce((e,t)=>e+t,0)/r.indexes.length,stableId:`${e}\0${r.slots.map(Kw).join("\0")}`,slots:r.slots});return i.sort((e,t)=>e.anchor-t.anchor||Qw(e.stableId,t.stableId))}function Ck(e){return e.some(e=>e.group)?Tk(e).flatMap(e=>e.slots):[...e]}function Nk(e){let t=/* @__PURE__ */new Set;for(let i of e)if(i.group){if(t.has(i.group))return!0;t.add(i.group)}return!1}function Fk(e){return e.flatMap(e=>e.slots)}function Dk(e,t){let i=/* @__PURE__ */new Map;for(let t of e)for(let e of t.slots)i.set(e,t);let r=/* @__PURE__ */new Map;for(let e of t){let t=i.get(e.source),o=i.get(e.target);if(!t||!o||t===o)continue;let n=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,a=t.stableId<o.stableId?`${t.stableId}\0${o.stableId}`:`${o.stableId}\0${t.stableId}`,s=r.get(a);s?s.weight=(s.weight??0)+n:r.set(a,{source:t,target:o,weight:n})}return[...r.values()]}function Ek(e,t,i){let r=/* @__PURE__ */new Map;return e.forEach((e,t)=>{for(let i of e.slots)r.set(i,t)}),e.map((e,o)=>{if(e.slots.length<=1)return e;let n=/* @__PURE__ */new Map;for(let t of e.slots)n.set(t,0);for(let e of t){let t=r.get(e.source),i=r.get(e.target);if(null==t||null==i)continue;let a=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===o&&i!==o){let t=i>o?1:-1;n.set(e.source,(n.get(e.source)??0)+a*t)}else if(i===o&&t!==o){let i=t>o?1:-1;n.set(e.target,(n.get(e.target)??0)+a*i)}}let a=[...e.slots].sort((e,t)=>(n.get(e)??0)-(n.get(t)??0)||i(e,t));return{...e,slots:a}})}function zk(e,t){e.some(e=>e.group)&&Rk(e,t,Ck(e))}function Ok(e,t,i=0){return e.crossings<t.crossings||e.crossings===t.crossings&&e.cost<=t.cost+i}function jk({order:e,after:t,nodes:i,edges:r,outgoingPartners:o,incomingPartners:n,slotForNode:a,averageGap:s,evaluate:l}){let c=(i,o)=>{let n=[...new Set(o.map(t=>e.indexOf(t)))].sort((e,t)=>e-t),a=e.indexOf(i),c=n[0],u=n[n.length-1];if(n.length<3||!n.includes(a)||u-c+1!==n.length||Math.abs(2*a-c-u)<=1)return;let d=[...e];d.splice(a,1),d.splice(c+u>>1,0,i);let h=Ck(d),f=l(h),p=new Set(i.occupants.map(e=>e.id)),g=new Set(o.flatMap(e=>e.occupants.map(e=>e.id))),m=r.reduce((e,t)=>p.has(t.source)&&g.has(t.target)||p.has(t.target)&&g.has(t.source)?e+(t.value>0?t.value:1):e,0),y=Math.abs(2*a-c-u)*s*Math.max(1,m);Ok(f,t,y)&&(e=h,t=f)};for(let[e,t]of o)!n.has(e)&&t.size>=3&&c(a.get(e),[...t].map(e=>a.get(e)));for(let e of i){let t=a.get(e.id);!e.group&&t.group&&(n.get(e.id)?.size??0)>=3&&c(t,[...n.get(e.id)??[]].map(e=>a.get(e)).filter(e=>e===t||e.group===t.group).filter((e,t,i)=>i.indexOf(e)===t))}return{order:e,after:t}}function Wk(e,t){let i=[...new Set(Object.values(e))].sort((e,t)=>e-t),r=new Map(i.map((e,t)=>[e,t])),o=new Map(Object.entries(e).map(([e,t])=>[e,r.get(t)]));return new Lk(t,o,i.length).count(i.map((e,t)=>t))}function Bk(e,t){let i=0;for(let r of t){let t=e[r.source],o=e[r.target];null==t||null==o||(i+=Math.abs(t-o)*(r.value>0?r.value:1))}return i}var Yk=e=>{let t=1;for(let i=2;i<=e;i++)t*=i;return t},Gk=/* */828*Yk(8),Xk=3e3;function Vk(e){let t=new Array(e.length),i=Math.floor((e.length-1)/2),r=i-1,o=i+1;e.length>0&&(t[i]=e[0]);for(let i=1;i<e.length;i++)i%2==1&&o<e.length?t[o++]=e[i]:r>=0?t[r--]=e[i]:t[o++]=e[i];return t}function qk(e,t,i){let r=i(e),o=r,n=[...e],a=Math.floor((e.length-1)/2);for(let s of t){let t=e.indexOf(s);if(t===a)continue;e.splice(t,1),e.splice(a,0,s);let l=i(e);l<=r?(r=l,l<o&&(n=[...e],o=l)):(e.splice(a,1),e.splice(t,0,s))}return n}function Hk(e,t,i,r,o,n,a){let s=[...o],l=new Map(o.map(e=>[e,Kw(e)])),c=/* @__PURE__ */new Map;for(let e of o)for(let t of e.occupants)c.set(t.id,e);let u=/* @__PURE__ */new Map,d=[];for(let e of t){let t=c.get(e.source),i=c.get(e.target);!t||!i||(u.set(e,[t,i]),t!==i&&d.push({source:t,target:i,weight:e.value}))}let h=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),f=a.plotH/Math.max(1,o.length),p=o.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),g=Math.max(1,h)*(Math.max(1,a.plotH)+f*Math.max(p,o.length)+1e-6*Math.max(1,o.length-1))+1,m=4*f,y={fullCrossing:0,localCrossing:0},x=/* @__PURE__ */new Map,b=(e,t)=>{let r=x.get(e);r||(r=/* @__PURE__ */new Map,x.set(e,r));let o=r.get(t);if(null!=o)return o;let n=tk(e,t,i);return r.set(t,n),n},v=new Map(o.map((e,t)=>[e,t])),w=new Lk(t,new Map([...c].map(([e,t])=>[e,v.get(t)])),o.length),k=e=>{let t=new Int32Array(o.length);for(let i=0;i<e.length;i++)t[v.get(e[i])]=i;return t},A=new Map([...u].map(([e,[t,i]])=>[e,{source:v.get(t),target:v.get(i),weight:e.value>0?e.value:1}])),S=[...A.values()],M=/* @__PURE__ */new Map,$=/* @__PURE__ */new Map,_=/* @__PURE__ */new Map,P=(e,t,i)=>{e.has(t)||e.set(t,/* @__PURE__ */new Set),e.get(t).add(i)};for(let e of t)P(M,e.source,e.target),P($,e.target,e.source),P(_,e.source,e.target),P(_,e.target,e.source);let L=e=>1===M.get(e.source)?.size&&M.get(e.source).has(e.target)||1===_.get(e.source)?.size||1===_.get(e.target)?.size,I=t.flatMap(e=>{if(!L(e))return[];let t=A.get(e);return t&&t.source!==t.target?[t]:[]}),R=e=>{let t=0;for(let i of I)t+=Math.max(0,Math.abs(e[i.source]-e[i.target])-1)*i.weight;return t*m},T=e=>R(k(e)),C=new Int32Array(o.length),N=new Float64Array(o.length),F=new Float64Array(o.length+1),D=e=>{for(let t=0;t<e.length;t++)C[v.get(e[t])]=t;let t=w.count(C);if(e.length>0){let t=v.get(e[0]);N[t]=a.padding+e[0].peak.topPeak*a.valueScale;for(let t=1;t<e.length;t++){let i=v.get(e[t-1]),r=v.get(e[t]);N[r]=N[i]+b(e[t-1],e[t])*a.valueScale+a.padding}let i=v.get(e[e.length-1]),r=N[i]+e[e.length-1].peak.botPeak*a.valueScale+a.padding;if(r>a.plotH&&r>0){let e=a.plotH/r;for(let t=0;t<N.length;t++)N[t]*=e}}F[0]=0;for(let t=0;t<e.length;t++)F[t+1]=F[t]+e[t].peak.topPeak+e[t].peak.botPeak;let i=0,r=0,o=0;for(let e of S){let t=C[e.source],n=C[e.target];if(i+=Math.abs(t-n)*e.weight,r+=Math.abs(N[e.source]-N[e.target])*e.weight,Math.abs(t-n)>=2){let i=Math.min(t,n)+1,r=Math.max(t,n);o+=(F[r]-F[i])*e.weight}}return t*g+r+o*f+R(C)+1e-6*i},E=(e,i)=>{let r=new Array(e.length+1).fill(0);for(let t=0;t<e.length;t++)r[t+1]=r[t]+e[t].peak.topPeak+e[t].peak.botPeak;let o=0;for(let e of t){let t=i[e.source],n=i[e.target];if(null==t||null==n||Math.abs(t-n)<2)continue;let a=Math.min(t,n)+1;o+=(r[Math.max(t,n)]-r[a])*(e.value>0?e.value:1)}return o},z=r=>{let o=Ik(r),n=r.slice(0,-1).map((e,t)=>b(e,r[t+1])),s=nk(e,t,i,r,o,{plotH:a.plotH,padding:a.padding,valueScale:a.valueScale,lanePlacement:a.lanePlacement??"stack",groupPadding:a.groupPadding,adjacentClearance:n});return{map:o,geometry:s,weightedLength:Bk(o,t),pixelLength:ak(s.centerlines,t)}},O=(e,o,n)=>{let s=o;null==s&&(s=w.count(k(e)),y.fullCrossing++);let{map:l,geometry:c,weightedLength:u,pixelLength:d}=z(e),h=n?hk(t,i,e,l,c.centerlines,r,{valueScale:a.valueScale,ribbonLane:a.ribbonLane,domain:a.domain,mode:n}):E(e,l);return{crossings:s,weightedLength:u,pixelLength:d,transitOcclusion:h,cost:s*g+d+h*f+T(e)+1e-6*u}},j=(e,t,i="quality")=>O(e,t,i),W=[...s],B=(e,t)=>Qw(l.get(e),l.get(t)),Y=Nk(W),G=(e,t,i,r=Xk)=>{let o=t(e);for(let n=0;n<i&&r>0;n++){let i=!1,a=Array.from({length:e.length-1},(e,t)=>t);n%2==1&&a.reverse();for(let n of a){if(r--<=0)break;let a=e[n],s=e[n+1],l=w.swapDelta(v.get(a),v.get(s),k(e));[e[n],e[n+1]]=[s,a],y.localCrossing+=l.evaluations;let c=t(e,o.crossings+l.delta);c.cost<o.cost?(o=c,i=!0):[e[n],e[n+1]]=[a,s]}if(!i)break}return e},X=e=>{let t=Ie(e,d,e=>O(e).cost,{passes:6,compare:B,maxEvaluations:Xk});return G(t,O,6)},V=e=>{let t=X(e);if((e.length<=8?Yk(e.length)*(e.length+S.length+w.work):1/0)>Gk)return t;let i=Te(e,D,{maxItems:8,maxEvaluations:5e4}),r=j(i),o=j(t);return r.crossings!==o.crossings&&r.crossings<o.crossings?i:t},q=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),H=(e,t)=>q(t)-q(e)||Qw(e.stableId,t.stableId),U=(e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||B(e,t),Z="geometry-refine"===a.mode;if(Z||"crossing-min"!==a.laneOrder&&"crossing-min+inside-out"!==a.laneOrder?Z||"inside-out"!==a.laneOrder||(W=Y?Fk(Vk([...Tk(W)].sort(H))):Vk([...W].sort(U))):W=Y?(e=>{let t=Tk(e);if(t.length<=1)return Fk(t);let i=e=>O(Fk(e)).cost;t=Tk(V(e)),t=Ek(t,d,B);let r=Dk(t,d);if(t=Ie(t,r,i,{passes:6,compare:(e,t)=>Qw(e.stableId,t.stableId),maxEvaluations:Xk}),t=Re(t,i,{passes:8,maxEvaluations:Xk}),(t.length<=8?Yk(t.length)*(t.length+S.length+w.work):1/0)<=Gk){let e=Te(t,e=>D(Fk(e)),{maxItems:8,maxEvaluations:5e4}),i=Fk(e),r=Fk(t),o=j(i),n=j(r);o.crossings!==n.crossings?t=o.crossings<n.crossings?e:t:o.cost<n.cost&&(t=e)}return t=Ek(t,d,B),Fk(t)})(W):V(W),!Z&&"crossing-min+inside-out"===a.laneOrder&&W.length>1)if(Y){let e=Tk(W);W=Fk(qk(e,[...e].sort(H),e=>O(Fk(e)).cost))}else W=qk(W,[...W].sort(U),e=>O(e).cost);if((Z||"crossing-min"===a.laneOrder||"crossing-min+inside-out"===a.laneOrder)&&W.length>1)if(Y){let e=Re(Tk(W),e=>j(Fk(e),void 0,"score").cost,{passes:6});e=Ek(e,d,B),W=Fk(e)}else G(W,(e,t)=>j(e,t,"score"),1,1/0);let Q=Ck(s);W=Ck(W);let K=j(W),J=j(Q);if(Z){let e=T(Q),t=T(W);(K.crossings>J.crossings||K.crossings===J.crossings&&t>e+1e-9||K.cost>J.cost)&&(W=Q,K=J)}else K.cost>J.cost&&(W=Q,K=J);let ee=jk({order:W,after:K,nodes:e,edges:t,outgoingPartners:M,incomingPartners:$,slotForNode:c,averageGap:f,evaluate:j});return W=ee.order,K=ee.after,Rk(o,n,W),{before:J,after:K,initialOrder:s.map(e=>l.get(e)),evaluations:y}}function Uk(e,t,i){let r=new Map(i.map((e,t)=>[e,t]));Rk(e,t,[...e].sort((e,t)=>(r.get(Kw(e))??1/0)-(r.get(Kw(t))??1/0)||Qw(Kw(e),Kw(t))))}function Zk(e,t,i){let r=e.map(e=>{let r=e.occupants.map(e=>({id:e.id,end:i[e.id]?.end??e.end})),o=0,n=0;for(let e of r){let i=t[e.id];o=Math.max(o,i?.topPeak||0),n=Math.max(n,i?.botPeak||0)}return{occupants:r,peak:{topPeak:o,botPeak:n},...null!=e.group?{group:e.group}:{}}}),o=Zw();return r.forEach((e,t)=>{for(let i of e.occupants)o[i.id]=t}),{slots:r,slotByNode:o}}function Qk(e,t,i,r){return`${e.map(e=>{let t=i[e.id],o=r[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,o?.start??"",o?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}var Kk=/* @__PURE__ */new Map;function Jk(e){return Kk.get(e)}function eA(e,t){for(Kk.has(e)&&Kk.delete(e),Kk.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(Zw(),t.slotByNode)});Kk.size>12;){let e=Kk.keys().next().value;if(null==e)break;Kk.delete(e)}}var tA=1e5,iA=1e-9;function rA(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(e.end<=t.start||t.end<=e.start)}function oA(e,t){return Qw(e,t)<=0?`${e}\0${t}`:`${t}\0${e}`}function nA(e){let t=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(let r of e)i.has(r.source)||i.set(r.source,/* @__PURE__ */new Set),t.has(r.target)||t.set(r.target,/* @__PURE__ */new Set),i.get(r.source).add(r.target),t.get(r.target).add(r.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...i].map(([e,t])=>[e,t.size]))}}function aA(e){let t=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map,r=(e,t,i,r)=>{let o=e.get(t);o||(o=/* @__PURE__ */new Map,e.set(t,o)),o.set(i,(o.get(i)??0)+r)};for(let o of e){let e=o.value>0&&Number.isFinite(o.value)?o.value:1;r(t,o.source,o.target,e),r(i,o.target,o.source,e)}let o=/* @__PURE__ */new Map,n=e=>{if(o.has(e))return;let r=t.get(e),n=i.get(e),a=/* @__PURE__ */new Map;for(let[e,t]of r??[])a.set(e,(a.get(e)??0)+t);for(let[e,t]of n??[])a.set(e,(a.get(e)??0)+t);if(1===a.size){let[t,i]=[...a][0];o.set(e,{partner:t,weight:i})}};for(let t of e)n(t.source),n(t.target);return o}function sA(e,t,i){let r=i.get(e),o=i.get(t);return!r||!o||r.partner===o.partner||r.partner===t||o.partner===e}function lA(e,t,i){return!!i.has(e)&&t.some(t=>!sA(e,t,i))}function cA(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 uA(e,t,i,r,o,n){let a=/* @__PURE__ */new Set,s=new Map(e.map(e=>[e,/* @__PURE__ */new Set])),l=new Map(e.map(e=>[e,/* @__PURE__ */new Set]));for(let e of r)a.add(oA(e.source,e.target)),s.get(e.target)?.add(e.source),l.get(e.source)?.add(e.target);let c=/* @__PURE__ */new Map,u=/* @__PURE__ */new Set,d=(e,t)=>{for(let i=0;i<e.length;i++)for(let r=i+1;r<e.length;r++){let o=oA(e[i],e[r]);t instanceof Map?t.set(o,[e[i],e[r]]):t.add(o)}};for(let e of l.values())d([...e],c);for(let e of s.values())d([...e],u);let h=/* @__PURE__ */new Set;for(let[e,[r,o]]of c)u.has(e)&&(rA(t[r],t[o])||rA(i[r],i[o])&&(h.add(r),h.add(o)));return{conflicts:(e,i)=>{let r=o.get(e),s=o.get(i);return!((null==r||null==s||r===s)&&(null!=r==(null!=s)||a.has(oA(e,i))||n.has(e)&&n.has(i)&&sA(e,i,n))&&!rA(t[e],t[i])&&(!h.has(e)&&!h.has(i)||a.has(oA(e,i))))}}}function dA(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,i)=>t[e.id].start-t[i.id].start||t[e.id].end-t[i.id].end||Qw(e.id,i.id)).map(e=>e.id)}function hA(e,t,i=/* @__PURE__ */new Map){let r=[],o=[];for(let n of e){let e=r.findIndex(e=>e.every(e=>!t.conflicts(n,e))&&!lA(n,e,i));-1===e&&!i.has(n)&&(e=r.findIndex(e=>e.every(e=>!t.conflicts(n,e)))),-1===e&&(e=r.length,r.push([])),r[e].push(n),o.push(e)}return{assignment:o,slotCount:r.length}}function fA(e,t,i,r){if(e.length<=12||r.slotCount<=1)return r.assignment;let o=new Map(e.map((e,t)=>[e,t])),n=Array.from({length:e.length},()=>/* @__PURE__ */new Map),a=nA(i);for(let e of i){let t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;let r=cA(e,a);n[t].set(i,(n[t].get(i)??0)+r),n[i].set(t,(n[i].get(t)??0)+r)}let s=aA(i),l=e.map(e=>s.get(e)?.weight??0),c=Array.from({length:e.length},()=>/* @__PURE__ */new Map),u=0;for(let i=0;i<e.length-1&&u<5e4;i++)if(s.has(e[i]))for(let r=i+1;r<e.length;r++){if(!s.has(e[r])||t.conflicts(e[i],e[r]))continue;u++;let o=Math.min(l[i],l[r])||Math.max(l[i],l[r]),n=sA(e[i],e[r],s)?o:-o;if(!(Math.abs(n)<=iA)&&(c[i].set(r,n),c[r].set(i,n),u>=5e4))break}let d=[...r.assignment],h=Array.from({length:r.slotCount},()=>[]);d.forEach((e,t)=>h[e].push(t));let f=(e,t,i)=>{let r=d[t],o=d[i],n=0,a=/* @__PURE__ */new Set;for(let s of[t,i])for(let[l,c]of e[s]){let e=s<l?`${s}:${l}`:`${l}:${s}`;if(a.has(e))continue;a.add(e);let u=d[s]===d[l],h=(s===t?o:r)===(l===t?o:l===i?r:d[l]);u!==h&&(n+=h?c:-c)}return n},p=(e,t,i)=>{let r=0;for(let[o,n]of e[t]){let e=d[t]===d[o],a=i===d[o];e!==a&&(r+=a?n:-n)}return r},g=(e,t)=>e>iA||Math.abs(e)<=iA&&t>iA,m=(e,t,i,r)=>e>i+iA||Math.abs(e-i)<=iA&&t>r+iA,y=0;for(let i=0;i<32&&y<tA;i++){let i=null,r=-1,o=-1,a=-1,s=-1/0,l=-1/0;for(let u=0;u<e.length;u++){for(let f=0;f<h.length&&!(y++>=tA);f++){if(f===d[u]||!h[f].every(i=>!t.conflicts(e[u],e[i])))continue;let y=p(n,u,f),x=p(c,u,f);g(y,x)&&m(y,x,s,l)&&(i="move",r=u,o=-1,a=f,s=y,l=x)}if(y>=tA)break}for(let u=0;u<e.length-1;u++){for(let p=u+1;p<e.length&&!(y++>=tA);p++){let y=d[u],x=d[p];if(y===x||!h[x].every(i=>i===p||!t.conflicts(e[u],e[i]))||!h[y].every(i=>i===u||!t.conflicts(e[p],e[i])))continue;let b=f(n,u,p),v=f(c,u,p);g(b,v)&&m(b,v,s,l)&&(i="swap",r=u,o=p,a=-1,s=b,l=v)}if(y>=tA)break}if(null==i||-1===r)break;if("move"===i){let e=d[r];h[e].splice(h[e].indexOf(r),1),h[a].push(r),d[r]=a;continue}let u=d[r],x=d[o];h[u].splice(h[u].indexOf(r),1,o),h[x].splice(h[x].indexOf(o),1,r),d[r]=x,d[o]=u}return d}function pA(e,t){for(let i=0;i<Math.min(e.length,t.length);i++)if(e[i]!==t[i])return e[i]<t[i];return e.length<t.length}function gA(e,t,i,r){if(0===e.length||e.length>12||r.slotCount<=1)return r.assignment;let o=new Map(e.map((e,t)=>[e,t])),n=Array.from({length:e.length},()=>new Float64Array(e.length)),a=Array.from({length:e.length},()=>/* @__PURE__ */new Map),s=Array.from({length:e.length},()=>/* @__PURE__ */new Map),l=nA(i);for(let e of i){let t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;let r=cA(e,l);n[t][i]+=r,n[i][t]+=r,s[t].set(i,(s[t].get(i)??0)+r),a[i].set(t,(a[i].get(t)??0)+r)}let c=aA(i),u=e.map(e=>c.get(e)?.weight??0),d=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;t<e.length;t++)for(let i=t+1;i<e.length;i++){for(let[e,r]of a[t])d[t][i]+=Math.min(r,a[i].get(e)??0);for(let[e,r]of s[t])d[t][i]+=Math.min(r,s[i].get(e)??0);if(c.has(e[t])&&c.has(e[i])){let r=Math.min(u[t],u[i])||Math.max(u[t],u[i]);d[t][i]+=sA(e[t],e[i],c)?r:-r}d[i][t]=d[t][i]}let h=[...r.assignment],f=(t=>{let i=0,r=0;for(let o=0;o<e.length;o++)for(let a=o+1;a<e.length;a++)t[o]===t[a]&&(i+=n[o][a],r+=d[o][a]);return{flow:i,affinity:r}})(h),p=0,g=new Array(e.length).fill(-1),m=Array.from({length:r.slotCount},()=>[]),y=(i,o,a,s)=>{if(p>=75e3)return;if(i===e.length)return p++,void((a>f.flow||a===f.flow&&s>f.affinity||a===f.flow&&s===f.affinity&&pA(g,h))&&(h=[...g],f={flow:a,affinity:s}));let l=Math.min(o+1,r.slotCount-1);for(let r=0;r<=l;r++){if(m[r].some(r=>t.conflicts(e[i],e[r])))continue;let l=0,c=0;for(let e of m[r])l+=n[i][e],c+=d[i][e];if(g[i]=r,m[r].push(i),y(i+1,Math.max(o,r),a+l,s+c),m[r].pop(),g[i]=-1,p>=75e3)return}};return g[0]=0,m[0].push(0),y(1,0,0,0),h}function mA(e,t){let i=1/0,r=-1/0;for(let t of e?.samples??[])t.topMass+t.botMass<=1e-9||(i=Math.min(i,t.t),r=Math.max(r,t.t));return Number.isFinite(i)&&Number.isFinite(r)?(null!=t.start&&(i=Math.max(i,t.start)),null!=t.end&&(r=Math.min(r,t.end)),r>=i?{start:i,end:r}:{start:null,end:null}):{start:null,end:null}}function yA(e,t,i,r){let o=Qk(e,t,i,r),n=Jk(o);if(n)return Zk(n.slots,i,r);let a=Zw();for(let t of e)a[t.id]=mA(i[t.id],r[t.id]);let s=dA(e,a),l=new Map(e.map(e=>[e.id,e])),c=new Map(e.map(e=>[e.id,e.group||void 0])),u=aA(t),d=uA(s,a,r,t,c,u),h=hA(s,d,u),f=gA(s,d,t,{...h,assignment:fA(s,d,t,h)}),p=/* @__PURE__ */new Map,g=f.map(e=>(p.has(e)||p.set(e,p.size),p.get(e))),m=Array.from({length:p.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),y=Zw();s.forEach((e,t)=>{let i=g[t],r=m[i];r.occupants.push({id:e,end:a[e].end??-1/0});let o=l.get(e)?.group;o&&(r.group=o),y[e]=i});for(let t of[...e].sort((e,t)=>Qw(e.id,t.id)))null==y[t.id]&&(m[0].occupants.push({id:t.id,end:-1/0}),y[t.id]=0);for(let e of m){e.occupants.sort((e,t)=>(a[e.id].start??1/0)-(a[t.id].start??1/0)||Qw(e.id,t.id));for(let t of e.occupants){let r=i[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,r?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,r?.botPeak||0)}}let x={slots:m,slotByNode:y};return eA(o,x),x}function xA(e){return e.topMass+e.botMass}function bA(e){let t=/* @__PURE__ */new Map;for(let i of e.samples){if(Number.isNaN(i.t))continue;let e=t.get(i.t);e||(e=[],t.set(i.t,e)),e.push(i)}let i=0,r=-1/0;return o=>{o>=r||(i=0),r=o;let n=t.get(o);if(n){let e=n.reduce((e,t)=>xA(t)>=xA(e)?t:e,n[0]);return{exact:n,sample:e}}for(;i<e.samples.length&&!(e.samples[i].t>o);)i++;return{exact:n,sample:e.samples[i-1]??null}}}function vA(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]))}function wA(e,t,i,r,o,n,a=0){let s=/* @__PURE__ */new Map;for(let i of e){if(!i.group||!t[i.id])continue;let e=s.get(i.group)??[];e.push(i),s.set(i.group,e)}if(0===s.size||!(n>0))return t;let l=vA(t);for(let[e,c]of s){let s=i.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===s.length)continue;let u=s[0].slot,d=s.at(-1).slot,h=o[u.occupants[0]?.id],f=o[d.occupants[0]?.id];if(!Number.isFinite(h)||!Number.isFinite(f))continue;let p=(h-u.peak.topPeak*n+(f+d.peak.botPeak*n))/2,g=[...new Set(c.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),m=/* @__PURE__ */new Map;for(let e of c)m.set(e.id,/* @__PURE__ */new Map);let y=new Map(c.map(e=>[e.id,bA(t[e.id])]));for(let e of g){let t=/* @__PURE__ */new Map;for(let i of c){let{sample:o}=y.get(i.id)(e);if(!o||xA(o)<=1e-9)continue;let n=r[i.id];if(null==n)continue;let a=t.get(n)??[];a.push({node:i,sample:o}),t.set(n,a)}let i=[...t].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>xA(e)))}));if(0===i.length)continue;let s=p-(i.reduce((e,t)=>e+t.mass,0)*n+Math.max(0,a)*Math.max(0,i.length-1))/2;for(let t of i){for(let{node:i,sample:r}of t.active){let t=(s-o[i.id])/n+r.topMass-(r.boundaryOffset??0);m.get(i.id).set(e,t)}s+=t.mass*n+Math.max(0,a)}}for(let e of c){let i=t[e.id],r=l[e.id],o=m.get(e.id),n=y.get(e.id),a=[];for(let e of g){let t=o.get(e),{exact:i,sample:r}=n(e);i?a.push(...i.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}}))):null==t||!r||xA(r)<=1e-9||a.push({...r,t:e,boundaryOffset:(r.boundaryOffset??0)+t})}r.samples=a,r.localAttachments=new Map([...i.localAttachments].map(([e,t])=>{let i=o.get(t.time);return[e,{...t,...null!=i?{boundaryOffset:(t.boundaryOffset??0)+i}:{}}]}))}}return l}function kA(e,t,i,r,o){let{plotH:n,padding:a,valueScale:s,packing:l,laneOrder:c,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:h=0,ribbonLane:f="both",domain:p}=o,g=Zw(),m=Zw();for(let t of e)g[t.id]=i[t.id].topPeak||0,m[t.id]=i[t.id].botPeak||0;let y="half"===u,x=Zw();for(let t of e){let e=Array.isArray(t.xExtent)?t.xExtent[0]:null,i=Array.isArray(t.xExtent)?t.xExtent[1]:null,o=null!=e&&Number.isFinite(e)?e:1/0,n=null!=i&&Number.isFinite(i)?i:-1/0;for(let e of r.outgoing[t.id]){e.startTime<o&&(o=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.systemInTime<o&&(o=e.systemInTime);let t=y?(e.startTime+e.endTime)/2:e.endTime;t>n&&(n=t)}for(let e of r.incoming[t.id]){let t=y?(e.startTime+e.endTime)/2:e.startTime;t<o&&(o=t),e.endTime>n&&(n=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>n&&(n=e.systemOutTime)}x[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(n)?n:null}}let b=Zw(),v=[],w=[];if(o.frozenSlots){let e=Zk(o.frozenSlots,i,x);v=e.slots,b=e.slotByNode,w=v.map(Kw)}else if("reuse"===l){let r=yA(e,t,i,x);v=r.slots,b=r.slotByNode}else e.forEach((e,t)=>{v.push({occupants:[{id:e.id,end:x[e.id]?.end??-1/0}],peak:{topPeak:g[e.id],botPeak:m[e.id]},...e.group?{group:e.group}:{}}),b[e.id]=t});zk(v,b),0===w.length&&(w=v.map(Kw));let k=null;o.frozenSlots||(o.fixedSlotOrder?Uk(v,b,o.fixedSlotOrder):o.runOrdering&&c&&"insertion"!==c&&(k=Hk(e,t,i,x,v,b,{plotH:n,padding:a,valueScale:s,groupPadding:h,laneOrder:c,ribbonLane:f,domain:p}))),zk(v,b);let A=nk(e,t,i,v,b,{plotH:n,padding:a,valueScale:s,stackValueScale:o.stackValueScale,lanePlacement:d,groupPadding:h}),S=0===v.length?0:v[0].peak.topPeak+A.adjacentClearance.reduce((e,t)=>e+t,0)+v[v.length-1].peak.botPeak,M=k?.before.crossings??null,$=k?.after.crossings??null,_=k?.before.weightedLength??null,P=k?.after.weightedLength??null;return{effectiveSlotsHeight:S,centerlines:A.centerlines,laneLifetime:x,slots:v,slotByNode:b,slotCenter:A.slotCenter,stackCenter:A.stackCenter,verticalUtilization:A.verticalUtilization,selectedSlotOrder:v.map(Kw),initialSlotOrder:w,ordering:k,crossingsBefore:M,crossingsAfter:$,lengthBefore:_,lengthAfter:P}}function AA(e,t,i){let{plotH:r,pairing:o="temporal",packing:n="reuse",laneOrder:a="crossing-min",lifetimeMode:s="half",maxValueScale:l,lanePlacement:c="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:h="both",domain:f}=i,p=Number.isFinite(d)?Math.max(0,d):0,g=bk(e,t),m=vk(e,t,g,o),y=Zw();for(let t of e)y[t.id]=wk(t,g,m,void 0,u);let x=kA(e,t,y,g,{plotH:r,padding:12,valueScale:1,packing:n,laneOrder:a,lifetimeMode:s,runOrdering:!0,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),b=x.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),v=/* @__PURE__ */new Set;for(let e of t){let t=x.slotByNode[e.source],i=x.slotByNode[e.target];if(void 0===t||void 0===i)continue;let r=m.get(e.id);t!==i?i<t?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(v.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(let t of e){let e=g.outgoing[t.id],i=g.incoming[t.id],r=new Set(e.map(e=>m.get(e.id).sourceSide)),o=new Set(i.map(e=>m.get(e.id).targetSide));if(1===r.size&&i.length>0){let e=[...r][0];for(let t of i)x.slotByNode[t.source]===x.slotByNode[t.target]&&(m.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){let t=[...o][0];for(let i of e)x.slotByNode[i.source]===x.slotByNode[i.target]&&(m.get(i.id).sourceSide=t)}}Sk(t,m,x.slotByNode),Mk(e,g,m,v),y=Zw();for(let t of e)y[t.id]=wk(t,g,m,void 0,u);let w=kA(e,t,y,g,{plotH:r,padding:12,valueScale:1,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:b,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),k=w.effectiveSlotsHeight??w.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),A=w.slots.slice(0,-1).reduce((e,t,i)=>e+(null!=t.group&&t.group===w.slots[i+1].group?1:0),0),S=Math.max(1,w.slots.length+1-A),M=Math.min(12,Math.max(0,.35*r-A*p)/S),$=2*M+Jw(w.slots,M,p).reduce((e,t)=>e+t,0),_=k>0?Math.max(0,(r-$)/k):1,P=Number.isFinite(l)&&l>0?Math.min(_,l):_,L=kA(e,t,y,g,{plotH:r,padding:M,valueScale:P,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:b,lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:_}),I=Number.isFinite(l)&&l>0&&l+1e-12<_;if("insertion"!==a&&("hug"===c||I)&&L.slots.length>1&&(Hk(e,t,y,L.laneLifetime,L.slots,L.slotByNode,{plotH:r,padding:M,valueScale:P,groupPadding:p,laneOrder:a,ribbonLane:h,domain:f,lanePlacement:c,mode:"geometry-refine"}),L=kA(e,t,y,g,{plotH:r,padding:M,valueScale:P,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:L.slots,fixedSlotOrder:L.slots.map(Kw),lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:_})),Ak(g,m)){let i=kk(t,y,L.centerlines,P);y=Zw();for(let t of e)y[t.id]=wk(t,g,m,i,u);L=kA(e,t,y,g,{plotH:r,padding:M,valueScale:P,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:L.slots,fixedSlotOrder:L.slots.map(Kw),lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:_})}let R=new Map(x.initialSlotOrder.map((e,t)=>[e,t])),T=[...L.slots].sort((e,t)=>(R.get(Kw(e))??1/0)-(R.get(Kw(t))??1/0)||Qw(Kw(e),Kw(t))),C=Zw();T.forEach((e,t)=>{for(let i of e.occupants)C[i.id]=t});let N=nk(e,t,y,T,C,{plotH:r,padding:M,valueScale:P,stackValueScale:_,lanePlacement:"stack",groupPadding:p}),F=wA(e,y,T,C,N.centerlines,P,p),D=fk(Wk(C,t),Bk(C,t),t,F,T,C,N.centerlines,L.laneLifetime,P,N.verticalUtilization,h,f);y=wA(e,y,L.slots,L.slotByNode,L.centerlines,P,p);let E=fk(Wk(L.slotByNode,t),Bk(L.slotByNode,t),t,y,L.slots,L.slotByNode,L.centerlines,L.laneLifetime,P,L.verticalUtilization,h,f);return{nodeData:y,sides:m,valueScale:P,padding:M,compressedPadding:M<12,centerlines:L.centerlines,laneLifetime:L.laneLifetime,slots:L.slots,slotByNode:L.slotByNode,crossingsBefore:"insertion"===a?null:D.crossings,crossingsAfter:"insertion"===a?null:E.crossings,lengthBefore:"insertion"===a?null:D.weightedLength,lengthAfter:"insertion"===a?null:E.weightedLength,layoutQualityBefore:D,layoutQuality:E}}function SA(e){return f(e)}function MA(e){return p(e)}function $A(e,t,i,r,o,n,a,s,l={}){let c,u,d,h,f=o,p=e=>s?Math.max(s[0],Math.min(s[1],e)):e,g=n(p(e.time)),m=n(p(i.time)),y=e.value*f,x=i.value*f,b=t+(e.boundaryOffset??0)*f,v=r+(i.boundaryOffset??0)*f,w=e.sideMassBefore*f,k=i.sideMassAfter*f;"top"===e.side?(c=b-w,u=c+y):(u=b+w,c=u-y),"top"===i.side?(d=v-k,h=d+x):(h=v+k,d=h-x);let A=l.sourceRunwayStart,S=l.minRun,M=(c+u)/2,$=(d+h)/2,_=Math.abs($-M),P=m-g,L="number"==typeof A&&Number.isFinite(A),I="number"==typeof S&&Number.isFinite(S)&&S>0;if(L&&_>1e-9&&P>0&&("auto"===S||I)){let t="source"===a?.85:"target"===a?.15:.5,i=1.5*Math.min(t*t,(1-t)*(1-t)),r="auto"===S?Math.min(144,Math.sqrt(8*_/i)):S;if(r>P){let t=n(p(Math.min(A,e.time)));if(Number.isFinite(t)){let e=Math.min(g,t);g=Math.min(g,Math.max(e,m-r))}}}let R="source"===a?g+.85*(m-g):"target"===a?g+.15*(m-g):(g+m)/2;return{sx:g,sTop:c,sBot:u,tx:m,tTop:d,tBot:h,cp1X:R,cp2X:R}}function _A(e,t,i,r,o,n){let a=new Map(t),s=/* @__PURE__ */new Map;for(let t of e){let e=n?.get(t.source),i=null==e?`node:${t.source}`:`group:${e}`,r=s.get(i)??/* @__PURE__ */new Map,o=r.get(t.startTime)??[];o.push(t),r.set(t.startTime,o),s.set(i,r)}for(let e of s.values())for(let[n,s]of e){if(!s.some(e=>i.has(e.id)))continue;let e=s.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;let l=r(n),c=Math.min(...e.map(e=>e.sx));if(!(c<l-1e-9))continue;let u=Math.max(...s.map(e=>{let t=i.get(e.id);return null==t?l:Math.min(l,r(t))})),d=Math.min(l,Math.max(c,u));for(let e of s){let i=t.get(e.id),r="source"===o?.85:"target"===o?.15:.5,n=d+(i.tx-d)*r;a.set(e.id,{...i,sx:d,cp1X:n,cp2X:n})}}return a}function PA(e,t,i){let r=new Set(t.map(e=>e.target)),o=new Map(e.map(e=>[e.id,e])),n=/* @__PURE__ */new Map;for(let e of t){if(r.has(e.source))continue;let t=n.get(e.source)??[];t.push(e),n.set(e.source,t)}let a=/* @__PURE__ */new Map;for(let t of e){if(!t.group)continue;let e=a.get(t.group)??[];e.push(t),a.set(t.group,e)}let s=/* @__PURE__ */new Set;for(let[e,t]of a){let i=t.flatMap(e=>n.get(e.id)??[]),o=new Set(i.map(e=>e.startTime));i.length>0&&1===o.size&&t.every(e=>{let t=e.xExtent?.[0],o=i[0].startTime;return!r.has(e.id)&&(n.get(e.id)?.length??0)>0&&Number.isFinite(t)&&t<o})&&s.add(e)}let l=/* @__PURE__ */new Map;for(let[e,t]of n){let r=o.get(e);if(r?.group&&!s.has(r.group))continue;let n=r?.xExtent?.[0],a=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),c=a[0]?.startTime-1,u=null;for(let e=0;e<a.length;){let t=a[e].startTime,r=e+1;for(;r<a.length&&a[r].startTime===t;)r++;for(let t=e;t<r;t++){let e=a[t],r=Number.isFinite(n)&&n<e.startTime,o=Number.isFinite(e.systemInTime)&&e.systemInTime<e.startTime;if(!r&&!o)continue;let s=i[0];r&&(s=Math.max(s,n)),o&&(s=Math.max(s,e.systemInTime)),!r&&o&&Number.isFinite(c)&&(s=Math.max(s,c)),null!=u&&(s=Math.max(s,u)),s<e.startTime&&l.set(e.id,s)}u=t,e=r}}for(let[e,t]of a){if(!s.has(e))continue;let i=t.flatMap(e=>n.get(e.id)??[]);if(!i.every(e=>l.has(e.id))){for(let e of i)l.delete(e.id);continue}let r=Math.max(...i.map(e=>l.get(e.id)));for(let e of i)l.set(e.id,r)}return l}function LA(e,t,i,r,o){let n=/* @__PURE__ */new Map;for(let a of e){if(!i.has(a.id))continue;let e=t.get(a.id);if(!(e&&e.sx<r(a.startTime)-1e-9))continue;let s=o(e.sx);Number.isFinite(s)&&s<a.startTime&&n.set(a.id,s)}return n}function IA(e,t,i){let r=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;for(let[e,t]of i??[]){let i=o.get(t)??[];i.push(e),o.set(t,i)}for(let n of e){let e=t.get(n.id);if(!(null!=e&&Number.isFinite(e)&&e<n.startTime))continue;let a=i?.get(n.source),s=null==a?[n.source]:o.get(a)??[n.source];for(let t of s){let i=r.get(t)??/* @__PURE__ */new Map,o=i.get(n.startTime);i.set(n.startTime,null==o?e:Math.min(o,e)),r.set(t,i)}}return r}function RA(e,t){return t&&0!==t.size?e.map(e=>{let i=t.get(e.t);return null==i?e:{...e,t:i}}):e}function TA(e){return Math.max(18,11*e.length*.58)}function CA(e){let t=1.22*TA(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 NA(e,t){let i=e.labelX-TA(e.labelText),r=t.labelX-TA(t.labelText);return i<=t.labelX+3&&r<=e.labelX+3}function FA(e,t){let i=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;e<3;e+=1){for(let e=0;e<i.length;e+=1){let t=8;for(let r=0;r<e;r+=1)NA(i[e],i[r])&&(t=Math.max(t,i[r].labelY+16));i[e].labelY=Math.max(i[e].labelY,t)}for(let e=i.length-1;e>=0;e-=1){let r=t-8;for(let t=e+1;t<i.length;t+=1)NA(i[e],i[t])&&(r=Math.min(r,i[t].labelY-16));i[e].labelY=Math.min(i[e].labelY,r)}}}function DA(e,t,i){let r=e.map(e=>({...e})),o=/* @__PURE__ */new Map;for(let e of r){let i=t[e.id];if(null==i)continue;let r=o.get(i)??[];r.push(e),o.set(i,r)}let n=e=>{if(e.length<2)return;let t=e.reduce((e,t)=>e+t.labelY,0)/e.length,r=(e.length-1)/2;e.forEach((e,o)=>{e.labelY=Math.max(8,Math.min(i-8,t+16*(o-r)))})};for(let e of o.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],i=-1/0;for(let r of e){let e=r.labelX-TA(r.labelText);t.length>0&&e>i+3&&(n(t),t=[],i=-1/0),t.push(r),i=Math.max(i,r.labelX)}n(t)}return FA(r,i),r}function EA(e,t,i){let r=e.map(e=>({...e}));for(let e of r){let i=1.22*TA(e.labelText)+4;e.labelX=i>=t-4?t/2:Math.max(i/2+2,Math.min(t-i/2-2,e.labelX))}let o=[],n=[...r].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(let e of n){let t=o[o.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?o.push([e]):t.push(e)}for(let e of o){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],r=/* @__PURE__ */new Map;for(let i of e){let[e,o]=CA(i),n=t.findIndex(t=>e>t+8);-1===n&&(n=t.length),t[n]=o,r.set(i,n)}let o=e.reduce((e,t)=>e+t.labelY,0)/e.length,n=o<14*t.length+8;for(let t of e){let e=r.get(t)??0;t.labelY=n?Math.min(i-8,12+14*e):Math.max(8,o-14*e)}}return r}function zA(e,t,i,r,o={}){if(!1===r)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===r)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let n=Math.max(1,t*i),a=Math.max(4,Math.min(e.length,Math.floor(n/14e3)));Number.isFinite(o.maxLabels)&&o.maxLabels>=0&&(a=Math.min(a,Math.floor(o.maxLabels)));let s=e.map((e,t)=>{let i=o.priorityById?.get(e.id),r=Math.abs(e.labelY);return{band:e,index:t,score:null!=i&&Number.isFinite(i)?1e6*i+TA(e.labelText):TA(e.labelText)+.01*r}}).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)),l=new Set(s.slice(0,a).map(e=>e.band.id));return e.map(e=>l.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}var OA=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi;function jA(e){return e.replace(OA,(e,t,i)=>`${i},${t}`)}function WA(e){if(!e)return;let 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 BA(e){return{...e,pathD:jA(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function YA(e,t){return"horizontal"===t?e:{...e,pathD:jA(e.pathD),gradientStubs:e.gradientStubs?.map(BA),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}function GA(e,t){return"horizontal"===t?e:{...e,pathD:jA(e.pathD),bezier:WA(e.bezier)}}function XA(e){let{nodes:t,edges:i,domain:r,usageMode:o="static"}=e,n=qw(t,i,r,{usageMode:o}),{fatal:a,warnings:s}=Vw(n),l=Hw(i,n,o);return{layout:a.length?null:AA(t,l,{plotH:"vertical"===e.orientation?e.plotW:e.plotH,...e.layoutOpts,ribbonLane:e.ribbonLane,domain:r}),issues:a,warnings:s}}function VA(e,t=XA(e)){let{nodes:i,edges:r,domain:o,plotW:n,plotH:a,ribbonLane:s,ribbonMinRun:l=0,edgeOpacity:c,colorOf:u,orientation:d="horizontal",showLabels:h=!0,labelPriorityAccessor:f,maxLabels:p,selectionDatum:g="raw",styleRules:m,colorBy:y,valueAccessor:x,usageMode:b="static"}=e,v="vertical"===d?a:n,w="vertical"===d?n:a,{layout:k,issues:A,warnings:S}=t,M=Hw(r,[...A,...S],b),$=Ww().domain(o).range([0,v]);if(!k)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==h},issues:A,warnings:S,xScale:$};let{centerlines:_,nodeData:P,valueScale:L}=k,I=U(y,x),R=[],T=[],C=0===l?/* @__PURE__ */new Map:PA(i,M,o),N=new Map(i.filter(e=>e.group).map(e=>[e.id,e.group])),F=/* @__PURE__ */new Map;for(let e of M){let t=P[e.source]?.localAttachments.get(e.id),i=P[e.target]?.localAttachments.get(e.id);!t||!i||F.set(e.id,$A(t,_[e.source],i,_[e.target],L,$,s,o,{minRun:l,sourceRunwayStart:C.get(e.id)}))}let D=_A(M,F,C,$,s,N),E=LA(M,D,C,$,e=>o[0]+e/v*(o[1]-o[0])),z=IA(M,E,N);i.forEach((e,t)=>{let i=P[e.id];if(!i||0===i.samples.length)return;let r=RA(i.samples,z.get(e.id)),n=yk(r,_[e.id],L,$,o);if(!n)return;let a,s,l=gk(r,o),c=l.find(e=>e.topMass+e.botMass>0)||l[0],h=(c.botMass-c.topMass+2*(c.boundaryOffset??0))*L/2,f=_[e.id]+h,p=u(e.id,t),g=p,y=.5,x=e.__raw??e;if(m&&m.length>0){let e=Z(x,m,I(x));"string"==typeof e.fill?p=e.fill:null!=e.fill&&Bs(e.fill)&&(s=e.fill,p=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:p),"string"==typeof e.stroke&&(g=e.stroke),"number"==typeof e.strokeWidth&&(y=e.strokeWidth),"number"==typeof e.fillOpacity&&(a=e.fillOpacity),"number"==typeof e.opacity&&null==a&&(a=e.opacity)}let b=xk(e.id,M,k,$,o,E);R.push({id:e.id,pathD:n,fill:p,stroke:g,strokeWidth:y,...null!=a&&{fillOpacity:a},...s&&{hatchFill:s},...b.length>0&&{gradientStubs:b},rawDatum:x,labelX:$("vertical"===d&&e.xExtent?e.xExtent[0]:c.t)-4,labelY:f,labelText:e.label??e.id})});let O=/* @__PURE__ */new Map;i.forEach((e,t)=>O.set(e.id,t)),M.forEach(e=>{let t=D.get(e.id);if(!t)return;let i=O.get(e.source)??0,r=u(e.source,i),{pathD:o,bezier:n}=ub(t),a=e.__raw??e,s="function"==typeof c?Number(c(a)):c,l=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.35;T.push({id:e.id,pathD:o,fill:r,opacity:l,rawDatum:a,bezier:n})});let j=DA(R,k.slotByNode,w).map(e=>YA(e,d)),W="vertical"===d?EA(j,n,a):j,B=/* @__PURE__ */new Map;if(null!=f)for(let e of i){let t=e.__raw??e,i="function"==typeof f?f(t):Number(t[f]);Number.isFinite(i)&&B.set(e.id,i)}let Y=zA(W,n,a,h,{...B.size>0&&{priorityById:B},...null!=p&&{maxLabels:p}});return{layout:k,layoutConfig:{bands:Y,ribbons:T.map(e=>GA(e,d)),showLabels:!1!==h,selectionDatum:g},issues:[],warnings:S,xScale:$}}function qA(e,t,i,r="horizontal"){return"vertical"===r?{top:e?38:t?28:16,right:24,bottom:24,left:i?72:24}:{top:e?30:t?24:8,right:80,bottom:i?28:8,left:80}}import{scaleLinear as HA,scaleUtc as UA}from"d3-scale";import{Fragment as ZA,jsx as QA,jsxs as KA}from"react/jsx-runtime";var JA="var(--semiotic-grid, #94a3b8)",eS="var(--semiotic-text-secondary, #475569)",tS="var(--semiotic-text-secondary, #94a3b8)";function iS(e){let t=e.layout,i=e.nodes,r=e.orientation,o=e.plotW,n=e.plotH,a=e.timelineExtent,s=e.showQualityReadout??!1,l=e.showLaneRails??!1,c=(e.warnings??[]).slice(0,3),u=e.timeFormat,d=e.colorOf,h=e.toTime,f=e.xScale,p=MA(e.domain),{centerlines:g,laneLifetime:m,nodeData:y,valueScale:x,compressedPadding:b,crossingsBefore:v,crossingsAfter:w,layoutQualityBefore:k,layoutQuality:A}=t,S=null,M=null,$=1/0,_=-1/0;for(let e of i){let t=m[e.id];if(!t||null===t.start||null===t.end)continue;let i=f(t.start),r=f(t.end);$=Math.min($,t.start),_=Math.max(_,t.end),(null===S||i<S)&&(S=i),(null===M||r>M)&&(M=r)}let P=e=>Math.max(0,Math.min(a,e)),L=P(S??0),I=Math.max(L,P(M??a)),R=[Math.max(h(e.domain[0]),$),Math.min(h(e.domain[1]),_)],T=Math.max(2,Math.min(8,Math.floor(a/90))),C=UA().domain(R),N=e.axisTicks??(Number.isFinite(R[0])&&Number.isFinite(R[1])?(p?C.ticks(T):HA().domain(R).ticks(T)).map(e=>({date:e})):[]),F=e=>{if(null!=e.label)return e.label;let t=h(e.date),i=p?new Date(t):t;return u?u(i):p?C.tickFormat()(i):String(t)},D=N.map((e,t)=>({tick:e,index:t,coordinate:f(h(e.date))})).filter(({coordinate:e})=>e>=L-.5&&e<=I+.5),E=null!==(w??null)&&null!=k&&null!=A,z=s&&(E||c.length>0)?/* @__PURE__ */KA("g",{fill:tS,fontSize:10,textAnchor:"end",children:[E&&/* @__PURE__ */KA(ZA,{children:[
277
+ /* @__PURE__ */KA("text",{x:o,y:-14,children:["crossings: ",v," → ",w," ","pixel length: ",Math.round(k.pixelLength)," → ",Math.round(A.pixelLength)]}),
278
+ /* @__PURE__ */KA("text",{x:o,y:-3,children:["transit: ",k.transitOcclusion.toFixed(1)," → ",A.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*A.verticalUtilization),"%"]})]}),c.map((e,t)=>/* @__PURE__ */KA("text",{x:o,y:E?10+11*t:11*t-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",e]},`warn-${t}`))]}):null,O=b?/* @__PURE__ */QA("text",{x:o,y:"vertical"===r?-3:2,fontSize:10,fill:tS,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,j=(e,t)=>d?d(e,t):JA;/* */
279
+ return KA("g","vertical"===r?{children:[z,O,D.map(({index:e,coordinate:t})=>/* @__PURE__ */QA("line",{x1:0,y1:t,x2:o,y2:t,stroke:JA,strokeOpacity:.15,strokeDasharray:"2 4"},`grid-${e}`)),l&&i.map((e,t)=>{let i=m[e.id];if(!i||null===i.start)return null;let r=g[e.id],o=y[e.id],n=o?{topPeak:o.topPeak,botPeak:o.botPeak}:{topPeak:0,botPeak:0},a=r+(n.botPeak-n.topPeak)*x/2,s=f(i.start),l=f(i.end),c=j(e.id,t);/* */
280
+ return KA("g",{children:[
281
+ /* @__PURE__ */QA("line",{x1:a,y1:s,x2:a,y2:l,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),
282
+ /* @__PURE__ */QA("line",{x1:a-4,y1:s,x2:a+4,y2:s,stroke:c,strokeOpacity:.5}),
283
+ /* @__PURE__ */QA("line",{x1:a-4,y1:l,x2:a+4,y2:l,stroke:c,strokeOpacity:.5})]},`lane-${e.id}`)}),
284
+ /* @__PURE__ */QA("line",{x1:-4,y1:L,x2:-4,y2:I,stroke:JA}),D.map(({tick:e,index:t,coordinate:i})=>{let r=F(e);/* */
285
+ return KA("g",{transform:`translate(-4,${i})`,children:[
286
+ /* @__PURE__ */QA("line",{x2:-6,stroke:JA}),
287
+ /* @__PURE__ */QA("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:eS,children:r})]},t)})]}:{children:[z,O,D.map(({index:e,coordinate:t})=>/* @__PURE__ */QA("line",{x1:t,y1:0,x2:t,y2:n,stroke:JA,strokeOpacity:.15,strokeDasharray:"2 4"},`grid-${e}`)),l&&i.map((e,t)=>{let i=m[e.id];if(!i||null===i.start)return null;let r=g[e.id],o=y[e.id],n=o?{topPeak:o.topPeak,botPeak:o.botPeak}:{topPeak:0,botPeak:0},a=r+(n.botPeak-n.topPeak)*x/2,s=f(i.start),l=f(i.end),c=j(e.id,t);/* */
288
+ return KA("g",{children:[
289
+ /* @__PURE__ */QA("line",{x1:s,y1:a,x2:l,y2:a,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),
290
+ /* @__PURE__ */QA("line",{x1:s,y1:a-4,x2:s,y2:a+4,stroke:c,strokeOpacity:.5}),
291
+ /* @__PURE__ */QA("line",{x1:l,y1:a-4,x2:l,y2:a+4,stroke:c,strokeOpacity:.5})]},`lane-${e.id}`)}),
292
+ /* @__PURE__ */QA("line",{x1:L,y1:n+4,x2:I,y2:n+4,stroke:JA}),D.map(({tick:e,index:t,coordinate:i})=>{let r=F(e);/* */
293
+ return KA("g",{transform:`translate(${i},${n+4})`,children:[
294
+ /* @__PURE__ */QA("line",{y2:6,stroke:JA}),
295
+ /* @__PURE__ */QA("text",{y:20,textAnchor:"middle",fontSize:11,fill:eS,children:r})]},t)})]})}function rS(e,t){return"scene"===t?e:e.data}function oS(e,t,i){return!t?.isActive||t.predicate(rS(e,i))}var nS=e=>{let{bands:t=[],ribbons:i=[],showLabels:r=!0,selectionDatum:o="raw"}=e.config,n=e.selection??null,a=[];for(let e of i){let t={__kind:"ribbon",data:e.rawDatum,id:e.id},i=!oS(t,n,o);a.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:i?Math.min(e.opacity,.22):e.opacity,stroke:"none"},datum:t})}for(let e of t){if(!e.gradientStubs)continue;let t=!oS({__kind:"band",data:e.rawDatum,id:e.id},n,o);for(let i=0;i<e.gradientStubs.length;i++){let r=e.gradientStubs[i];a.push({type:"bezier",pathD:r.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?.22:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:r.x0,x1:r.x1,...null!=r.y0&&{y0:r.y0},...null!=r.y1&&{y1:r.y1},from:r.from,to:r.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${i}`}})}}for(let e of t){let t=!!(e.gradientStubs&&e.gradientStubs.length>0),i={__kind:"band",data:e.rawDatum,id:e.id},r=!oS(i,n,o),s=e.fillOpacity??.86,l=e.hatchFill??e.fill;a.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:l,fillOpacity:r?.22:s},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...r&&t?{opacity:.22}:{}},datum:i})}let s=r?t.flatMap(e=>{let t=e.labelDeferred&&e.labelFullText?.trim(),i=e.labelText.trim().length>0,r=t&&n?.isActive&&oS({__kind:"band",data:e.rawDatum,id:e.id},n,o),a=i?e.labelText:r?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:s}},aS=(e,t,i,r,o)=>({data:e,nodeIDAccessor:o.nodeIdAccessor??o.nodeIDAccessor??"name",childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth)}),sS=(e,t,i,r,o)=>{let n=xr(r.theme).colors.categorical,a=/* @__PURE__ */new Map,s=gv(e??null,o.childrenAccessor??"children"),l="function"==typeof t?t:null,c=l?"__hierarchyColor":"string"==typeof t?t:void 0,u=l?s.map(e=>({__hierarchyColor:l(e)})):s,d=t&&c?Vi(u,c,i??r.colorScheme??n):void 0;return e=>{if(o.colorByDepth)return Wi[Number(e?.depth||0)%Wi.length];let r=e?.data||e;return t?Gi(l?{__hierarchyColor:l(r)}:r,c,d??void 0):Ui(void 0,n,i,void 0,a)}};function lS(e,t,i,r){let o=Q(e,r.styleRules,U(t,r.valueAccessor),e=>e?.data||e),n=i.nodeStyle||r.nodeStyle;return Qi(n?"function"==typeof n?e=>({...o(e),...n(e)??{}}):e=>({...o(e),...n}):o,gr(r))}function cS(e){if(void 0!==e.edgeStyle)return e.edgeStyle;let{edgeWidth:t,edgeColor:i,edgeOpacity:r}=e,o=e.strokeWidth??1;return void 0!==t||void 0!==i||void 0!==r||void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity?n=>{let a=n?.data||n,s=o;if("number"==typeof t)s=t;else if("function"==typeof t)s=t(a);else if("string"==typeof t){let e=a?.[t],i="number"==typeof e?e:Number(e);s=Number.isFinite(i)&&i>0?i:o}return{stroke:i??e.stroke??"#999",strokeWidth:s,opacity:r??e.opacity??.6}}:void 0}var uS={MotifBraidChart:Dw,DependencyForestChart:Ew,ForceDirectedGraph:{frameType:"network",buildProps:(e,t,i,r,o)=>{let n=cS(o),a=xr(r.theme).colors.categorical,s=/* @__PURE__ */new Map,l=Array.isArray(o.nodes)?o.nodes:[],c="string"==typeof t?t:"__ssrForceColorBy",u=t?Vi("function"==typeof t?l.map(e=>({...e,__ssrForceColorBy:t(e)})):l,c,i??r.colorScheme??a):void 0,d=o.nodeStyle??(e=>({fill:t?Gi(e?.data||e,t,u):Ui(void 0,a,i,void 0,s),..."number"==typeof o.nodeSize&&{r:o.nodeSize}})),h=K(o.styleRules,t,"number"==typeof o.nodeSize?void 0:o.nodeSize),f=Qi(h?(e,t)=>({...d(e),...h(e,t)}):d,{stroke:o.nodeStroke??o.stroke,strokeWidth:o.nodeStrokeWidth??o.strokeWidth,opacity:o.opacity});return{chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:t,colorScheme:i,iterations:o.iterations,forceStrength:o.forceStrength,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize??8,nodeSizeRange:o.nodeSizeRange,nodeStyle:f,edgeStyle:n,...r,showLabels:r.showLabels??o.showLabels??!1,showLegend:(r.showLegend??!!t)&&!!t}}},SankeyDiagram:{frameType:"network",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(o.nodes)?o.nodes:mv([],Array.isArray(o.edges)?o.edges:[],o.sourceAccessor||"source",o.targetAccessor||"target"),a=xr(r.theme).colors.categorical,s=/* @__PURE__ */new Map,l="string"==typeof t?t:"__ssrSankeyColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrSankeyColorBy:t(e)})):n,u=t?Vi(c,l,i??r.colorScheme??a):void 0,d=e=>({fill:t?Gi(e?.data||e,t,u):Ui(void 0,a,i,void 0,s),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),h=K(o.styleRules,t,o.valueAccessor),f=h?(e,t)=>({...d(e),...h(e,t)}):d,p=yv({edgeColorBy:o.edgeColorBy??"source",colorBy:t,colorScale:u,nodeStyleFn:f,edgeOpacity:o.edgeOpacity??.5,baseStyle:{stroke:"none",strokeWidth:0}});return{chartType:"sankey",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,valueAccessor:o.valueAccessor,orientation:o.orientation,nodeAlign:o.nodeAlign,nodeWidth:o.nodeWidth,nodePaddingRatio:o.nodePaddingRatio,showLabels:o.showLabels,nodeLabel:o.nodeLabel,colorBy:t,edgeColorBy:o.edgeColorBy,edgeOpacity:o.edgeOpacity,nodeStyle:Qi(o.nodeStyle||f,gr(o)),edgeStyle:Qi(o.edgeStyle||p,gr(o)),colorScheme:i,...r,showLegend:(r.showLegend??!!t)&&!!t}}},ProcessSankey:{frameType:"network",layout:{margin:e=>qA(!!e.title,!!e.showQualityReadout,!Array.isArray(e.axisTicks)||e.axisTicks.length>0,"vertical"===e.orientation?"vertical":"horizontal")},buildProps:(e,t,i,r,o)=>{let n=o.sourceAccessor||"source",a=o.targetAccessor||"target",s=o.valueAccessor||"value",l=o.nodeIdAccessor||"id",c=o.startTimeAccessor||"startTime",u=o.endTimeAccessor||"endTime",d=o.systemInTimeAccessor,h=o.systemOutTimeAccessor,f=o.xExtentAccessor||"xExtent",p=o.groupBy,g=o.edgeIdAccessor||"id",m=(e,t)=>"function"==typeof e?e(t):t[e],y=Array.isArray(o.edges)?o.edges:[],x=Array.isArray(o.nodes)?o.nodes:[],b=x.length>0?x:mv([],y,n,a),v=[SA(o.domain?.[0]),SA(o.domain?.[1])],w=b.map(e=>{let t=String(m(l,e)),i=m(f,e),r=o.nodeLabel?m(o.nodeLabel,e):t,n={id:t,label:null==r?t:String(r),__raw:e},a=p?m(p,e):null;if(null!=a&&""!==String(a)&&(n.group=String(a)),Array.isArray(i)&&2===i.length){let e=SA(i[0]),t=SA(i[1]);Number.isFinite(e)&&Number.isFinite(t)&&(n.xExtent=[e,t])}return n}),k=y.map((e,t)=>{let i=m(g,e),r={id:null!=i?String(i):`${m(n,e)}-${m(a,e)}-${t}`,source:String(m(n,e)),target:String(m(a,e)),value:Number(m(s,e)),startTime:SA(m(c,e)),endTime:SA(m(u,e)),__raw:e};if(d){let t=SA(m(d,e));Number.isFinite(t)&&(r.systemInTime=t)}if(h){let t=SA(m(h,e));Number.isFinite(t)&&(r.systemOutTime=t)}return r}),[A,S]=r.size??[600,400],M=r.margin,$="vertical"===o.orientation?"vertical":"horizontal",_=!Array.isArray(o.axisTicks)||o.axisTicks.length>0,P={...qA(!!r.title,!!o.showQualityReadout,_,$),...M},L=(r.showLegend??!!t)&&!!t,I=r.legendPosition??"right";if(L){let e="left"===I||"top"===I||"bottom"===I?I:"right",t={...P};"right"===e?P.right=Math.max(P.right,140):"left"===e?P.left=Math.max(P.left,140):"top"===e?P.top=Math.max(P.top,50):P.bottom=Math.max(P.bottom,80),it(P,t,[A,S],e)}let R=P,T=Math.max(1,A-R.left-R.right),C=Math.max(1,S-R.top-R.bottom),N=Oi(i,xr(r.theme).colors.categorical,bi),F="function"==typeof t?t:null,D=F?b.map(e=>({_cat:F(e)})):b,E=F?"_cat":"string"==typeof t?t:void 0,z=i??[...N],O=E?Vi(D,E,z):null,j=/* @__PURE__ */new Map;for(let e of w)j.set(e.id,e.__raw);let W=(e,i)=>{if(t&&j.has(e)){let i=j.get(e);return F?Gi({_cat:F(i)},"_cat",O??void 0):Gi(i,"string"==typeof t?t:"id",O??void 0)}return N[i%N.length]},B=Ze(L&&t?(()=>{let e=/* @__PURE__ */new Map;b.forEach((i,r)=>{let o=m(t,i),n=null==o?"":String(o);!n||e.has(n)||e.set(n,{label:n,color:W(String(m(l,i)),r)})});let i=Array.from(e.values());return i.length>0?{legendGroups:[{type:"fill",label:"",items:i,styleFn:e=>{let t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0})():void 0,r.legend),Y=!1!==o.showLabels&&("auto"!==o.showLabels||"auto"),{layout:G,layoutConfig:X,issues:V,xScale:q}=VA({nodes:w,edges:k,domain:v,plotW:T,plotH:C,orientation:$,ribbonLane:o.ribbonLane||"both",ribbonMinRun:"auto"===o.ribbonMinRun||"number"==typeof o.ribbonMinRun?o.ribbonMinRun:0,edgeOpacity:"number"==typeof o.edgeOpacity?o.edgeOpacity:.35,colorOf:W,showLabels:Y,styleRules:o.styleRules,colorBy:t,valueAccessor:s,layoutOpts:{pairing:o.pairing||"temporal",packing:o.packing||"reuse",laneOrder:o.laneOrder||"crossing-min",lifetimeMode:o.lifetimeMode||"half",maxValueScale:"number"==typeof o.maxValueScale?o.maxValueScale:void 0,lanePlacement:o.lanePlacement||"stack",nodeSizing:o.nodeSizing||"temporal",groupPadding:"number"==typeof o.groupPadding?o.groupPadding:0}});if(V.length>0){let e=V.map(Uw).join("; ");throw new Error(`ProcessSankey: data invalid — ${e}`)}let H=G?iS({layout:G,nodes:w,orientation:$,plotW:T,plotH:C,timelineExtent:"vertical"===$?C:T,domain:o.domain,axisTicks:Array.isArray(o.axisTicks)?o.axisTicks.map(e=>({date:e.date,label:e.label})):void 0,showQualityReadout:!!o.showQualityReadout,showLaneRails:!!o.showLaneRails,timeFormat:"function"==typeof o.timeFormat?e=>o.timeFormat(e):void 0,colorOf:W,toTime:e=>SA(e),xScale:e=>Number(q(e))}):void 0;return{chartType:"force",nodes:b,edges:y,customNetworkLayout:nS,layoutConfig:X,sourceAccessor:n,targetAccessor:a,valueAccessor:s,nodeIDAccessor:l,colorBy:t,colorScheme:i,...H&&{backgroundGraphics:H},...r,showLegend:L,...B&&{legend:B,legendPosition:I},__legendIncludesAutomatic:!0,margin:R}}},ChordDiagram:{frameType:"network",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(o.styleRules)&&o.styleRules.length>0;if(!(t||n||r.nodeStyle||o.nodeStyle||Zi(gr(o))))return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,edgeOpacity:o.edgeOpacity,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:i,...r,showLegend:(r.showLegend??!!t)&&!!t};let a=Array.isArray(o.edges)?o.edges:[],s=Array.isArray(o.nodes)&&o.nodes.length>0?o.nodes:mv([],a,o.sourceAccessor||"source",o.targetAccessor||"target"),l=xr(r.theme).colors.categorical,c=Oi(i,l),u="string"==typeof t?t:"__ssrChordColorBy",d="function"==typeof t?s.map(e=>({...e,__ssrChordColorBy:t(e)})):s,h=t?Vi(d,u,i??r.colorScheme??l):void 0,f=/* @__PURE__ */new Map,p=o.nodeIdAccessor||o.nodeIDAccessor||"id",g=(e,i)=>{let r,n=e?.data||e;if(t)r=Gi(n,t,h);else{let t=String(e.id??n?.[p]??"");f.has(t)||f.set(t,f.size);let o=e.index??i??f.get(t);r=c[o%c.length]}return{fill:r,stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},m=K(o.styleRules,t,o.valueAccessor),y=m?(e,t)=>({...g(e,t),...m(e,t)}):g;return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,edgeOpacity:o.edgeOpacity,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:i,nodeStyle:Qi(o.nodeStyle||y,gr(o)),...r,showLegend:(r.showLegend??!!t)&&!!t}}},TreeDiagram:{frameType:"network",buildProps:(e,t,i,r,o)=>{let n=sS(e,t,i,r,o),a=!1!==o.showLabels;return{chartType:o.layout??"tree",orientation:o.orientation,nodeLabel:a?o.nodeLabel||o.nodeIdAccessor:void 0,...aS(e,t,i,r,o),nodeStyle:lS(e=>({fill:n(e),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),t,r,o)}}},Treemap:{frameType:"network",buildProps:(e,t,i,r,o)=>{let n=sS(e,t,i,r,o),a=o.showLabels??r.showLabels,s=o.labelMode,l=void 0!==o.paddingTop?o.paddingTop:r.paddingTop,c=void 0!==l?l:!a||"parent"!==s&&"all"!==s?void 0:18;return{chartType:"treemap",labelMode:s,nodeLabel:a?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},...null!=c&&{paddingTop:c},...aS(e,t,i,r,o),nodeStyle:lS(e=>({fill:n(e),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}),t,r,o)}}},CirclePack:{frameType:"network",buildProps:(e,t,i,r,o)=>{let n=sS(e,t,i,r,o);return{chartType:"circlepack",nodeLabel:o.showLabels??r.showLabels?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},...aS(e,t,i,r,o),nodeStyle:lS(e=>({fill:n(e),fillOpacity:o.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}),t,r,o)}}},OrbitDiagram:{frameType:"network",buildProps:(e,t,i,r,o)=>{let n=e??o.data,a=o.childrenAccessor||"children",s=o.nodeIdAccessor||o.nodeIDAccessor||"name",l=xr(r.theme).colors.categorical,c=i??r.colorScheme??l,u=Oi(c,l),d=gv(n,a),h="__ssrOrbitColorBy",f="function"==typeof t?t:null,p=t?Vi(f?d.map(e=>({[h]:f(e)})):d,f?h:t,c):void 0,g=Q(e=>{let i=e.data||e,r=Number(e.depth??0);return{fill:o.colorByDepth?0===r?u[0]:Wi[r%Wi.length]:t?f?Gi({[h]:f(i)},h,p):Gi(i,t,p):u[0],stroke:"#fff",strokeWidth:1,opacity:0===r?1:.85}},o.styleRules,U(t,"value"),e=>e?.data||e);return{chartType:"orbit",data:n,childrenAccessor:a,nodeIDAccessor:s,colorBy:t,colorScheme:c,colorByDepth:o.colorByDepth??!1,nodeSize:o.nodeRadius??6,nodeLabel:o.showLabels?s:void 0,showLabels:o.showLabels??!1,orbitMode:o.orbitMode??"flat",orbitSize:o.orbitSize??2.95,orbitSpeed:o.speed??.25,orbitRevolution:o.revolution,orbitRevolutionStyle:o.revolutionStyle,orbitEccentricity:o.eccentricity??1,orbitShowRings:o.showRings??!0,orbitAnimated:!1,nodeStyle:Qi(g,gr(o)),edgeStyle:()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth)}}}},dS={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5};function hS(e,t,i){let[r,o]=i;if(!t)return r;let[n,a]=t,s=a>n?a-n:0,l=Number(e),c=Number.isFinite(l)?l:n,u=s>0?(c-n)/s:0;return r+Math.max(0,Math.min(1,u))*(o-r)}function fS(e){let{valueAccessor:t,valueDomain:i,edgeWidthRange:r,resolveStroke:o,edgeOpacity:n,edgeLinecap:a,styleRules:s}=e,l=q(t);return Q(e=>({stroke:o(e),strokeWidth:hS(e[t],i,r),strokeLinecap:a,opacity:n,fillOpacity:0}),s,e=>({value:l(e)}))}import{scaleSequential as pS}from"d3-scale";function gS(e,t,i,r){let o,n,a=Array.isArray(e)?e:[];if(t){let e="string"==typeof t?t:"__geoColorBy",r="string"==typeof t?a:a.map(e=>({...e,__geoColorBy:t(e)}));o=Vi(r,e,i)}if(r.sizeBy){let e="function"==typeof r.sizeBy?r.sizeBy:e=>e?.[r.sizeBy],t=a.map(e).filter(e=>null!=e&&isFinite(e));t.length>0&&(n=Ce(t))}return e=>({fill:t&&o?Gi(e,t,o):zi,fillOpacity:r.fillOpacity,stroke:"#fff",strokeWidth:r.strokeWidth,r:r.sizeBy?Hi(e,r.sizeBy,r.sizeRange,n):r.pointRadius??6})}function mS(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function yS(e,t,i){if(!Array.isArray(e))return;let r=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0,o=1/0,n=-1/0;for(let t of e){let e=r(t);null==e||!isFinite(e)||(e<o&&(o=e),e>n&&(n=e))}let a=[Number.isFinite(o)?o:0,Number.isFinite(n)?n:1],s=pS(Pi(i)).domain(a);return{domain:a,colorScale:e=>s(e),valueAccessor:r}}function xS(e,t){if(e)return i=>{let r=e.valueAccessor(i);return{fill:null!=r&&isFinite(r)?e.colorScale(r):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:t}}}var bS={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n="string"==typeof i?i:"blues",a=yS(o.areas,o.valueAccessor,n),s=o.areaStyle??xS(a,o.areaOpacity??1),l=e=>"function"==typeof o.valueAccessor?o.valueAccessor(e):null!=o.valueAccessor?e?.properties?.[o.valueAccessor]??e?.[o.valueAccessor]:void 0,c=o.styleRules?Q(s,o.styleRules,e=>({value:l(e)}),mS):s,u=!1!==r.showLegend&&a?{gradient:{colorFn:a.colorScale,domain:a.domain,label:"string"==typeof o.valueAccessor?o.valueAccessor:"value"}}:void 0;return{areas:o.areas,projection:o.projection||"equalEarth",areaStyle:c,valueAccessor:o.valueAccessor,colorScheme:n,graticule:o.graticule,fitPadding:o.fitPadding,...r,...void 0===r.legend&&u?{legend:u}:{}}}},vS={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n=e||o.points,a=o.pointStyle??gS(n,t,i,{sizeBy:o.sizeBy,sizeRange:o.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),s=o.styleRules?Q(a,o.styleRules,U(t,o.sizeBy)):a;return{points:n,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle||dS,pointStyle:s,sizeBy:o.sizeBy,colorBy:t,colorScheme:i,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,...r}}},wS={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n=e||o.points,a=r.__resolvedMode??o.mode,s="sparkline"===a,l=o.pointStyle??gS(n,t,i,{pointRadius:"number"==typeof o.pointRadius?o.pointRadius:s?1.5:5,fillOpacity:.85,strokeWidth:1}),c=o.nodeIdAccessor||"id",u=o.cartogramLayout||(s?"strip":"radial"),d="strip"===u,h=o.styleRules?Q(l,o.styleRules,U(t)):l;return{points:n,lines:o.lines,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",pointStyle:e=>{let t="function"==typeof h?h(e):h,i="function"==typeof c?c(e):e[c],r=null!=i&&String(i)===String(o.center),n="number"==typeof t.r?t.r:5;return{...t,fillOpacity:r?1:t.fillOpacity??.8,stroke:r?"var(--semiotic-text, #222)":t.stroke??"#fff",strokeWidth:r?1.25:t.strokeWidth??1,r:r?1.35*n:n}},colorBy:t,colorScheme:i,projection:o.projection||"mercator",graticule:o.graticule,fitPadding:o.fitPadding,projectionTransform:{center:o.center,centerAccessor:c,costAccessor:o.costAccessor,strength:o.strength??1,lineMode:o.lineMode||"straight",layout:u},...r,cartogramChrome:{showRings:o.showRings??!0,showNorth:o.showNorth??(!d&&!s),showRingLabels:o.showRingLabels??(!d&&"context"!==a&&!s),costLabel:o.costLabel}}}},kS={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n=(Array.isArray(e)?e:null)||o.flows||[],a=o.nodes||[],s=o.nodeIdAccessor||"id",l=o.valueAccessor||"value",c=o.xAccessor||"lon",u=o.yAccessor||"lat",d="function"==typeof c?c:e=>e[c],h="function"==typeof u?u:e=>e[u],f=a.map(e=>({...e,x:d(e),y:h(e)})),p=/* @__PURE__ */new Map;for(let e of f)p.set(String(e[s]),e);let g=o.edgeColorBy??t,m="function"==typeof g,y=n.map(e=>{if(!e||null==e.source||null==e.target)return null;let t=p.get(String(e.source)),i=p.get(String(e.target));return t&&i?{...e,coordinates:[{x:t.x,y:t.y},{x:i.x,y:i.y}]}:null}).filter(Boolean),x="__flowMapEdgeColor",b=g?m?Vi(y.map(e=>({[x]:g(e)})),x,i||"category10"):Vi(y,g,i||"category10"):null,v=y.map(e=>Number(e[l]??0)).filter(e=>Number.isFinite(e)),w=v.length>0?Ce(v):void 0,[k,A]=o.edgeWidthRange??[1,8],S=o.edgeOpacity??.6,M=o.edgeLinecap??"round";return{lines:y,points:f,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:o.lineType||"geo",flowStyle:o.flowStyle||"basic",areas:o.areas,areaStyle:o.areaStyle||dS,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:i,lineStyle:fS({valueAccessor:l,valueDomain:w,edgeWidthRange:[k,A],resolveStroke:e=>g&&b?Gi(e,g,b):"#007bff",edgeOpacity:S,edgeLinecap:M,styleRules:o.styleRules}),pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...r}}},AS={FlowCircuitChart:jw,GaltonBoardChart:fy,EventDropChart:py,UnitPileChart:gy,CollisionSwarmChart:my,PacketFlowChart:vy,ProcessFlowChart:yy,GauntletChart:xy,CrucibleChart:by,ChainReactionChart:Dh},SS=/* @__PURE__ */Object.assign({Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(e,t,i,r,o)=>({chartType:"line",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||t,colorAccessor:t,...r,showAxes:!1,margin:r.margin,showLegend:!1,showGrid:!1,title:void 0})},XYCustomChart:Kf,OrdinalCustomChart:Jf,ParallelCoordinatesRecipe:tp,CalendarHeatmapRecipe:ip,NetworkCustomChart:ep,ChoroplethMap:bS,ProportionalSymbolMap:vS,FlowMap:kS,DistanceCartogram:wS,GeoCustomChart:{frameType:"geo",buildProps:(e,t,i,r,o)=>({points:o.points||e||[],areas:o.areas||[],lines:o.lines||[],projection:o.projection||"equirectangular",xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",lineDataAccessor:o.lineDataAccessor,colorBy:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r})},PhysicsCustomChart:wy},
296
+ /* @__PURE__ */Object.assign({},Eh,yf,Qf),
297
+ /* @__PURE__ */Object.assign({},uS,AS));import*as MS from"react";import{jsx as $S}from"react/jsx-runtime";var _S=/* @__PURE__ */new Set(["svg","g","text","tspan","path","circle","ellipse","rect","line","polyline","polygon","use","image","defs","symbol"]);function PS(e){if(Array.isArray(e))return e.length>0&&e.every(PS);if(!MS.isValidElement(e))return!1;if(e.type===MS.Fragment){let t=MS.Children.toArray(e.props.children);return t.length>0&&t.every(PS)}return"string"==typeof e.type&&_S.has(e.type)}function LS(e,t,i){if(!PS(e))return null;if(!MS.isValidElement(e)||e.type===MS.Fragment)/* */
298
+ return $S("g",{className:"semiotic-radial-center-content",transform:`translate(${t},${i})`,pointerEvents:"none",children:e});let r=e,o="text"===r.type?MS.cloneElement(r,{x:r.props.x??0,y:r.props.y??0,textAnchor:r.props.textAnchor??"middle",dominantBaseline:r.props.dominantBaseline??"middle"}):r;/* */
299
+ return $S("g",{className:"semiotic-radial-center-content",transform:`translate(${t},${i})`,pointerEvents:"none",children:o})}import*as IS from"react-dom/server";import{scaleBand as RS,scaleLinear as TS}from"d3-scale";function CS(e,t,i,r,o,n){let a=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4,l=!1;for(let c of t){if("connector"===c.type||"violin"===c.type||"boxplot"===c.type)continue;if("wedge"===c.type){let t=c.category;if(!t)continue;let r=0;for(let a of o(t)??[]){let t=i.get(a);null!=t&&(r=Math.max(r,Nn(e,t,n)))}l=Dn(c,r,a)||l;continue}if(null==c.datum)continue;let t=r.get(c.datum);if(null==t)continue;let u=i.get(t);l=Dn(c,null==u?0:Nn(e,u,n),a,s)||l}return l}var NS=class{constructor(){this.colorSchemeMap=/* @__PURE__ */new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,i){if(t&&"function"==typeof e.pieceStyle){let r=e.pieceStyle(t,i);return r&&!r.fill&&i?{...r,fill:this.getColorFromScheme(e,i)}:r}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&i?{fill:Xi(e.barColors,i)??"#007bff"}:{fill:i?this.getColorFromScheme(e,i):"#007bff"}}resolveSummaryStyle(e,t,i){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,i):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){let i=this.colorSchemeMap.get(t);if(i)return i;let r=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||ji,o=r[this.colorSchemeIndex%r.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,o),o}};function FS(e,t,i){let{scales:r,config:o,getConnector:n,getO:a}=e;if(!n||!r)return[];let s=[],{projection:l}=r,c=/* @__PURE__ */new Map;for(let e of t){if("point"!==e.type&&"rect"!==e.type)continue;let t=e.datum;if(!t)continue;let i,r,o=n(t);o&&("point"===e.type?(i=e.x,r=e.y):(i=e.x+e.w/2,r=e.y+("vertical"===l?0:e.h/2)),c.has(o)||c.set(o,[]),c.get(o).push({x:i,y:r,datum:t,category:a(t)}))}let u=new Map(r.o.domain().map((e,t)=>[e,t])),d=o.connectorStyle,h={stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5},f=e=>"function"==typeof d?d(e):d||h,p=(e,t,i)=>{s.push({type:"connector",x1:e.x,y1:e.y,x2:t.x,y2:t.y,style:f(e.datum),datum:e.datum,group:i})};for(let[e,t]of c)if(!(t.length<2)){t.sort((e,t)=>(u.get(e.category)??-1)-(u.get(t.category)??-1));for(let i=0;i<t.length-1;i++)p(t[i],t[i+1],e);"radial"===l&&t.length>=3&&p(t[t.length-1],t[0],e)}return s}function DS(e,t,i,r=!1){let o=/* @__PURE__ */new Map;for(let r of e){let e=t(r);if(!Number.isFinite(e))continue;let n=i?i(r):"_default",a=o.get(n);a||(a={total:0,value:0,pieces:[]},o.set(n,a)),a.total+=e,a.pieces.push(r)}let n=0;for(let e of o.values())n+=Math.abs(e.total);for(let e of o.values())e.value=r&&n>0?e.total/n:e.total;return o}function ES(e,t,i,r=!1){let o=/* @__PURE__ */new Set;return{steps:e.map(e=>{let n=DS(e.pieceData,t,i,r),a=0;for(let[e,t]of n)o.add(e),a+=t.total;return{col:e,groups:n,stepTotal:a}}),keys:[...o]}}function zS(e,t,i){let r="function"==typeof e?e(i?t.w:t.h):e;return"number"==typeof r&&Number.isFinite(r)?Math.max(0,r):0}function OS(e){let t=e.getSymbol;return t?Be(t,e.config.symbolMap):null}function jS(e,t,i,r,o,n,a){t?e.push({type:"symbol",x:r,y:o,size:Math.PI*n*n,symbolType:t(i),style:a,datum:i}):e.push({type:"point",x:r,y:o,r:n,style:a,datum:i})}function WS(e,t){let{scales:i,columns:r,config:o,resolvePieceStyle:n,getR:a}=e,s=[],l=Math.min(t.width,t.height)/2-4,c="donut"===o.chartType?o.innerRadius||60:0,u=-Math.PI/2+(o.startAngle||0)*Math.PI/180,d=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI,h=null!=o.sweepAngle&&o.sweepAngle<360,f=Object.values(r),p=f.some(e=>{let t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),g=f.length,m=h&&!p&&g>1&&(o.cornerRadius??0)>0;for(let e=0;e<f.length;e++){let t=f[e],i=t.pieceData[0],r="number"==typeof i?._pctStart?i._pctStart:t.pctStart,h="number"==typeof i?._pct?i._pct:t.pct,p=u+r*d,g=u+(r+h)*d,y=n(t.pieceData[0],t.name),x=0===e,b=e===f.length-1,v={type:"wedge",cx:0,cy:0,innerRadius:c,outerRadius:l,startAngle:p,endAngle:g,...o.cornerRadius&&{cornerRadius:o.cornerRadius},style:y,datum:i?._nonInteractive?null:t.pieceData,accessibleDatum:{...1===t.pieceData.length?t.pieceData[0]:{},category:t.name,value:t.pieceData.reduce((e,t)=>e+a(t),0),percent:100*h,count:t.pieceData.length,...t.pieceData[0]?.__gaugeAccessibleDatum},category:t.name};i?._roundedEnds?v.roundedEnds=i._roundedEnds:m&&(v.roundedEnds={start:x,end:b}),i?._gradientBand&&(v._gradientBand=i._gradientBand),s.push(v)}return s}import{quantileSorted as BS}from"d3-array";function YS(e,t,i){return{...e[0],...i,category:t,data:e}}function GS(e){let t=e.length,i=e[0],r=e[t-1];return{n:t,min:i,q1:BS(e,.25)??i,median:BS(e,.5)??(i+r)/2,q3:BS(e,.75)??r,max:r,mean:e.reduce((e,t)=>e+t,0)/t}}function XS(e,t,i,r,o){let n=new Array(o).fill(0);for(let a of e)a<t||a>i||n[Math.min(Math.floor((a-t)/r),o-1)]++;return n}import{scaleLinear as VS}from"d3-scale";var qS={bar:function(e,t){let{scales:i,columns:r,config:o,getR:n,getStack:a,resolvePieceStyle:s}=e,{r:l,projection:c}=i,u=[],d="vertical"===c,h="horizontal"===c,f=o.normalize,{steps:p,keys:g}=ES(Object.values(r),n,a,f);for(let{col:e,groups:t}of p){let i=0,r=0;for(let o of g){let n=t.get(o);if(!n)continue;let c=n.value,f=s(n.pieces[0],a?o:e.name),p={...n.pieces[0],__aggregateValue:n.total,__pieceCount:n.pieces.length,category:e.name};if(d){let t=l(c>=0?i+c:r),n=c>=0?l(i)-l(i+c):l(r+c)-l(r);u.push(xa(e.x,t,e.width,Math.abs(n),f,p,o)),c>=0?i+=c:r+=c}else if(h){let t=l(c>=0?i:r+c),n=c>=0?l(i+c)-l(i):l(r)-l(r+c);u.push(xa(t,e.x,Math.abs(n),e.width,f,p,o)),c>=0?i+=c:r+=c}}}let m="vertical"===c;for(let e of u){if("rect"!==e.type)continue;let t=e.datum?.__aggregateValue??0;e.roundedEdge=m?t>=0?"top":"bottom":t>=0?"right":"left",o.gradientFill&&(e.fillGradient=o.gradientFill)}if(void 0!==o.roundedTop){let e=/* @__PURE__ */new Map;for(let t of u){if("rect"!==t.type)continue;let i=t.datum?.category||"";e.has(i)||e.set(i,[]),e.get(i).push(t)}for(let t of e.values()){if(0===t.length)continue;let e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),i=t.filter(e=>(e.datum?.__aggregateValue??0)<0);if(e.length>0){let t=m?e.reduce((e,t)=>e.y<t.y?e:t):e.reduce((e,t)=>e.x+e.w>t.x+t.w?e:t),i=zS(o.roundedTop,t,m);i>0&&(t.roundedTop=i)}if(i.length>0){let e=m?i.reduce((e,t)=>e.y+e.h>t.y+t.h?e:t):i.reduce((e,t)=>e.x<t.x?e:t),t=zS(o.roundedTop,e,m);t>0&&(e.roundedTop=t)}}}return u},clusterbar:function(e,t){let{scales:i,columns:r,config:o,getR:n,getGroup:a,resolvePieceStyle:s}=e,{r:l,projection:c}=i,u=[],d="vertical"===c,{steps:h,keys:f}=ES(Object.values(r),n,a),p=f.length||1;for(let{col:e,groups:t}of h){let i=e.width/p,r=.2*i,o=i-r;for(let a=0;a<f.length;a++){let c=t.get(f[a])?.pieces||[];for(let t of c){let c=n(t),h=s(t,f[a]);if(d){let n=e.x+a*i+r/2,s=l(0),d=l(c);u.push(xa(n,Math.min(s,d),o,Math.abs(s-d),h,t,f[a]))}else{let n=e.x+a*i+r/2,s=l(0),d=l(c);u.push(xa(Math.min(s,d),n,Math.abs(d-s),o,h,t,f[a]))}}}}for(let e of u){if("rect"!==e.type||null==e.datum)continue;let t=n(e.datum),i=zS(o.roundedTop,e,d);i>0&&(e.roundedTop=i),e.roundedEdge=d?t>=0?"top":"bottom":t>=0?"right":"left",o.gradientFill&&(e.fillGradient=o.gradientFill)}return u},point:function(e,t){let{scales:i,columns:r,getR:o,multiScales:n,resolvePieceStyle:a}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d="radial"===l,h=n.length>0,f=OS(e),p=2*Math.PI,g=-Math.PI/2;for(let e of Object.values(r))for(let t of e.pieceData){let i,r,l=t.__rIndex??0,m=t.__rValue??o(t),y=h&&n[l]||s,x=a(t,e.name),b=x.r||5;if(d){let t=g+(e.pctStart+e.pct/2)*p,o=y(m);i=Math.cos(t)*o,r=Math.sin(t)*o}else u?(i=e.middle,r=y(m)):(i=y(m),r=e.middle);jS(c,f,t,i,r,b,x)}return c},swarm:function(e,t){let{scales:i,columns:r,getR:o,resolvePieceStyle:n}=e,{r:a,projection:s}=i,l=[],c="vertical"===s,u=OS(e);for(let e of Object.values(r)){let t=e.width/2;for(let i=0;i<e.pieceData.length;i++){let r=e.pieceData[i],s=o(r),d=n(r,e.name),h=d.r||4,f=(7919*i%100/100-.5)*t*.8;jS(l,u,r,c?e.middle+f:a(s),c?a(s):e.middle+f,h,d)}}return l},pie:WS,donut:WS,boxplot:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d=!1!==o.showOutliers;for(let t of Object.values(r)){let i=t.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===i.length)continue;let r=GS(i),{min:o,max:l,q1:h,median:f,q3:p}=r,g=p-h,m=h-1.5*g,y=p+1.5*g,x=i.find(e=>e>=m)??o,b=l;for(let e=i.length-1;e>=0;e--)if(i[e]<=y){b=i[e];break}r.min=x,r.max=b;let v=a(YS(t.pieceData,t.name,r),t.name),w=[];if(d)for(let e of t.pieceData){let i=n(e);if(i<m||i>y){let r=u?t.middle:s(i),o=u?s(i):t.middle;w.push({px:r,py:o,value:i,datum:e})}}if(c.push({type:"boxplot",x:u?t.middle:0,y:u?0:t.middle,projection:u?"vertical":"horizontal",columnWidth:.6*t.width,minPos:s(x),q1Pos:s(h),medianPos:s(f),q3Pos:s(p),maxPos:s(b),stats:r,style:v,datum:t.pieceData,category:t.name,outliers:w}),d)for(let t of w)c.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:v.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6,cursor:v.cursor},datum:t.datum})}return c},violin:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d=o.bins||20,h=!1!==o.showIQR;for(let e of Object.values(r)){let t=e.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(t.length<2)continue;let i,r=t[0],o=t[t.length-1],l=(o-r)/d||1,f=XS(t,r,o,l,d),p=Fe(f,1),g=e.width/2*.9;if(u){i=`M ${e.middle} ${s(r)}`;for(let t=0;t<d;t++){let o=s(r+(t+.5)*l),n=f[t]/p*g;i+=` L ${e.middle+n} ${o}`}i+=` L ${e.middle} ${s(o)}`;for(let t=d-1;t>=0;t--){let o=s(r+(t+.5)*l),n=f[t]/p*g;i+=` L ${e.middle-n} ${o}`}i+=" Z"}else{i=`M ${s(r)} ${e.middle}`;for(let t=0;t<d;t++){let o=s(r+(t+.5)*l),n=f[t]/p*g;i+=` L ${o} ${e.middle-n}`}i+=` L ${s(o)} ${e.middle}`;for(let t=d-1;t>=0;t--){let o=s(r+(t+.5)*l),n=f[t]/p*g;i+=` L ${o} ${e.middle+n}`}i+=" Z"}let m,y=GS(t),x=a(YS(e.pieceData,e.name,y),e.name);h&&t.length>=4&&(m={q1Pos:s(y.q1),medianPos:s(y.median),q3Pos:s(y.q3),centerPos:e.middle,isVertical:u});let b=u?{x:e.x,y:Math.min(s(o),s(r)),width:e.width,height:Math.abs(s(o)-s(r))}:{x:Math.min(s(r),s(o)),y:e.x,width:Math.abs(s(o)-s(r)),height:e.width};c.push({type:"violin",pathString:i,translateX:0,translateY:0,bounds:b,iqrLine:m,stats:y,style:x,datum:e.pieceData,category:e.name})}return c},histogram:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s}=i,l=[],c=o.bins||25,u=o.normalize,d=s.domain?.(),h=d?+d[0]:void 0,f=d?+d[1]:void 0;for(let e of Object.values(r)){let t=e.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;let[i,r]=Ce(t),o=null!=h&&isFinite(h)?h:i,d=null!=f&&isFinite(f)?f:r,p=(d-o)/c||1,g=XS(t,o,d,p,c),m=t.length,y=Fe(g,1);for(let t=0;t<c;t++){if(0===g[t])continue;let i=(u?g[t]/m:g[t]/y)*e.width*.9,r=s(o+t*p),n=s(o+(t+1)*p),c=Math.min(r,n),d=Math.abs(n-r),h=e.x+e.width-i,f={...e.pieceData[0],bin:t,count:g[t],range:[o+t*p,o+(t+1)*p],category:e.name,data:e.pieceData},x=a(f,e.name);l.push(xa(c,h,d,i,x,f,e.name))}}return l},ridgeline:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s,projection:l}=i,c=[],u=o.bins||20,d="horizontal"===l,h=o.amplitude||1.5;for(let e of Object.values(r)){let t=e.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(t.length<2)continue;let i,r=t[0],o=t[t.length-1],l=(o-r)/u||1,f=XS(t,r,o,l,u),p=Fe(f,1),g=GS(t),m=a(YS(e.pieceData,e.name,g),e.name),y=e.width*h;if(d){let t=e.x+e.width;i=`M ${s(r)} ${t}`;for(let e=0;e<u;e++)i+=` L ${s(r+(e+.5)*l)} ${t-f[e]/p*y}`;i+=` L ${s(o)} ${t} Z`}else{let t=e.x;i=`M ${t} ${s(r)}`;for(let e=0;e<u;e++){let o=s(r+(e+.5)*l);i+=` L ${t+f[e]/p*y} ${o}`}i+=` L ${t} ${s(o)} Z`}let x=d?{x:Math.min(s(r),s(o)),y:e.x,width:Math.abs(s(o)-s(r)),height:e.width}:{x:e.x,y:Math.min(s(o),s(r)),width:e.width,height:Math.abs(s(o)-s(r))};c.push({type:"violin",pathString:i,translateX:0,translateY:0,bounds:x,stats:g,style:{...m,fillOpacity:m.fillOpacity??.5},datum:e.pieceData,category:e.name})}return c},timeline:function(e,t){let{scales:i,columns:r,getRawRange:o,resolvePieceStyle:n}=e,{r:a,projection:s}=i,l=[],c="horizontal"===s;for(let e of Object.values(r))for(let t of e.pieceData){let i=o(t);if(!i)continue;let[r,s]=i,u=n(t,e.name);if(c){let i=a(Math.min(r,s)),o=a(Math.max(r,s));l.push(xa(i,e.x,o-i,e.width,u,t,e.name))}else{let i=a(Math.max(r,s)),o=a(Math.min(r,s));l.push(xa(e.x,i,e.width,o-i,u,t,e.name))}}return l},funnel:function(e,t){let{columns:i,getR:r,getStack:o,resolvePieceStyle:n}=e,a=[],s=t.width/2,l=!1!==e.config.showLabels,c=e.scales.o.domain().map(e=>i[e]).filter(Boolean);if(0===c.length)return a;let{steps:u,keys:d}=ES(c,r,o),h=d.length>1&&"_default"!==d[0],f=0;if(!h)for(let{stepTotal:e}of u)e>f&&(f=e);if(h)for(let e of u){let t=0,i=0;for(let r=0;r<d.length;r++){let o=e.groups.get(d[r]);o&&(r%2==0?t+=o.total:i+=o.total)}let r=Math.max(t,i);r>f&&(f=r)}if(0===f)return a;let p=u[0].stepTotal,g=h?.95*s:.9*t.width,m=VS().domain([0,f]).range([0,g]),y=e.config.connectorOpacity??.3,x=/* @__PURE__ */new Map;for(let t=0;t<u.length;t++){let i=u[t],r=i.col,o=0===t,c=r.x,f=r.width,g=.55*f,b=c+(f-g)/2,v=/* @__PURE__ */new Map;if(h){let e=0;for(let t of d){let r=i.groups.get(t);r&&(e+=m(r.total))}let t=s,c=s;for(let h=0;h<d.length;h++){let f=d[h],p=i.groups.get(f);if(!p)continue;let y=m(p.total),x=h%2==0,w=x?t:c-y;x?t+=y:c-=y;let k=n(p.pieces[0],f),A=u[0].groups.get(f)?.total??0,S=A>0?p.total/A*100:0,M={...p.pieces[0],__funnelValue:p.total,__funnelPercent:S,__funnelStep:r.name,__funnelIsFirstStep:o,__aggregateValue:p.total,__pieceCount:p.pieces.length,category:f};l&&(0===h&&(M.__funnelStepLabel=r.name,M.__funnelStepLabelX=s,M.__funnelStepLabelY=b,M.__funnelRowWidth=e),M.__funnelValueLabelX=w+y/2,M.__funnelValueLabelY=b,M.__funnelBarW=y),a.push(xa(w,b,y,g,k,M,f)),v.set(f,{x:w,y:b,w:y,h:g})}}else{let e=i.stepTotal,t=m(e),c=s-t/2,u=d[0],h="_default"!==u,f=i.groups.get(u)?.pieces[0]??r.pieceData[0],y=h?u:r.name,x=n(f,y),w=p>0?e/p*100:0,k={...f,__funnelValue:e,__funnelPercent:w,__funnelStep:r.name,__funnelIsFirstStep:o,category:h?u:r.name};l&&(k.__funnelStepLabel=r.name,k.__funnelStepLabelX=s,k.__funnelStepLabelY=b,k.__funnelRowWidth=t,k.__funnelValueLabelX=s,k.__funnelValueLabelY=b,k.__funnelBarW=t),a.push(xa(c,b,t,g,x,k,y)),v.set(u,{x:c,y:b,w:t,h:g})}if(t>0&&x.size>0){let t=h?d:[d[0]];for(let o of t){let t=x.get(o),s=v.get(o);if(!t||!s)continue;let l=(()=>{let e=i.groups.get(o),t="_default"===o?r.name:o;return n(e?e.pieces[0]:r.pieceData[0],t)})(),c={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[s.x+s.w,s.y],[s.x,s.y]],style:{fill:l.fill||e.config.themeSemantic?.secondary||"#999",opacity:y,cursor:l.cursor},datum:i.groups.get(o)?.pieces[0]??r.pieceData[0],category:"_default"===o?r.name:o};a.push(c)}}x=v}return a},"bar-funnel":function(e,t){let{columns:i,getR:r,getStack:o,resolvePieceStyle:n,scales:a}=e,s=[],l=a.o.domain().map(e=>i[e]).filter(Boolean);if(0===l.length)return s;let{steps:c,keys:u}=ES(l,r,o),d=u.length>1&&"_default"!==u[0],h=a.r,f=d?u.length:1,p=d?.15:0;for(let e=0;e<c.length;e++){let t=c[e],i=t.col,r=0===e,o=e>0?c[e-1]:null,a=i.width/f,l=a*p,g=a-l;for(let e=0;e<u.length;e++){let f=u[e],p=t.groups.get(f);if(!p)continue;let m=p.total,y=c[0].groups.get(f)?.total??0,x=y>0?m/y*100:0,b=o?.groups.get(f)?.total??m,v=r?0:Math.max(0,b-m),w=i.x+e*a+l/2,k=h(m),A=h(0),S=A-k,M=n(p.pieces[0],d?f:i.name),$={...p.pieces[0],__barFunnelValue:m,__barFunnelPercent:x,__barFunnelIsFirstStep:r,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===f?void 0:f,category:d?f:i.name,__barFunnelLabelX:w+g/2,__barFunnelLabelY:h(m+v)};if(s.push(xa(w,Math.min(k,A),g,Math.abs(S),M,$,d?f:i.name)),v>0){let e=h(m+v),t=k-e,r={...M},o={...p.pieces[0],__barFunnelValue:v,__barFunnelPercent:y>0?v/y*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===f?void 0:f,category:d?f:i.name};s.push(xa(w,e,g,t,r,o,d?f:i.name))}}}return s},swimlane:function(e,t){let{scales:i,columns:r,getR:o,getStack:n,resolvePieceStyle:a}=e,{r:s,projection:l}=i,c=[],u="horizontal"===l,d=e.config.gradientFill,h=u?"left":"bottom",f=/* @__PURE__ */new Map,p=t=>{let i=f.get(t);if(void 0!==i)return i;let r="function"==typeof e.config.roundedTop?e.config.roundedTop(t.width):e.config.roundedTop,o="number"==typeof r&&Number.isFinite(r)?Math.max(0,r):0;return f.set(t,o),o},g=e.config.trackFill;if(g){let e="string"==typeof g?g:g.color,t="string"==typeof g?1:g.opacity??1,[i,o]=s.range(),n=Math.min(i,o),a=Math.abs(o-i);for(let i of Object.values(r)){let r={fill:e,opacity:t},o=u?xa(n,i.x,a,i.width,r,null,"__track__"):xa(i.x,n,i.width,a,r,null,"__track__"),s=p(i);s>0&&(o.cornerRadii={tl:s,tr:s,br:s,bl:s}),c.push(o)}}for(let e of Object.values(r)){let t=0,i=c.length,r=p(e);for(let i of e.pieceData){let r=Math.abs(o(i));if(0===r)continue;let l,f=n?n(i):e.name,p=a(i,f);if(u){let o=s(t),n=s(t+r);l=xa(o,e.x,n-o,e.width,p,i,f)}else{let o=s(t+r),n=s(t);l=xa(e.x,o,e.width,n-o,p,i,f)}d&&(l.fillGradient=d,l.roundedEdge=h),c.push(l),t+=r}if(r>0&&c.length>i){let e=c.slice(i),t=e[0],o=e[e.length-1];1===e.length?t.cornerRadii={tl:r,tr:r,br:r,bl:r}:u?(t.cornerRadii={tl:r,bl:r},o.cornerRadii={tr:r,br:r}):(t.cornerRadii={bl:r,br:r},o.cornerRadii={tl:r,tr:r})}}return c}};function HS(e){let{data:t,chartType:i,projection:r,normalize:o,rExtent:n,extentPadding:a=.05,baselinePadding:s,axisExtent:l,getO:c,getR:u,getStack:d,rawRExtent:h}=e,f=a;if("radial"===r&&("pie"===i||"donut"===i))return[0,1];let p=0,g=0;if("bar"===i||"bar-funnel"===i){let e=/* @__PURE__ */new Map;for(let i of t){let t=c(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}for(let t of e.values()){let e=DS(t,u,d,"bar"===i&&o),r=0,n=0;for(let{value:t}of e.values())"bar-funnel"===i?(r=Math.max(r,t),n=Math.min(n,t)):t>=0?r+=t:n+=t;g=Math.max(g,r),p=Math.min(p,n)}}else if("swimlane"===i){let e=/* @__PURE__ */new Map;for(let i of t){let t=c(i),r=Math.abs(u(i));e.set(t,(e.get(t)||0)+r)}for(let t of e.values())t>g&&(g=t)}else if("clusterbar"===i)for(let e of t){let t=u(e);Number.isFinite(t)&&(t>g&&(g=t),t<p&&(p=t))}else{let e=h[0],t=h[1];e!==1/0&&(p=e),t!==-1/0&&(g=t)}n&&(null!=n[0]&&(p=n[0]),null!=n[1]&&(g=n[1]));let m="bar"===i||"clusterbar"===i||"bar-funnel"===i||"swimlane"===i;if(m&&(null!=n?.[0]||null!=n?.[1]||(p>0&&(p=0),g<0&&(g=0))),"bar-funnel"!==i&&"exact"!==l){let e=g-p,t=e>0?e*f:1,r=m&&!s&&0===p,o=m&&!s&&0===g||"swimlane"===i;null==n?.[0]&&!r&&(p-=t),null==n?.[1]&&!o&&(g+=t)}return[p,g]}function US(e){let{data:t,oExtent:i,oScale:r,projection:o,layout:n,dynamicColumnWidth:a,getO:s,getR:l}=e,c=/* @__PURE__ */Object.create(null),u=/* @__PURE__ */new Map;for(let e of t){let t=s(e);u.has(t)||u.set(t,[]),u.get(t).push(e)}let d=0;if("radial"===o)for(let e of t)d+=Math.abs(l(e));let h=null;if(a&&"radial"!==o){h=/* @__PURE__ */new Map;let e=0;for(let t of i){let i,r=u.get(t)||[];i="string"==typeof a?r.reduce((e,t)=>{let i=Number(t[a]);return e+(Number.isFinite(i)?i:0)},0):a(r);let o=Number.isFinite(i)?Math.max(0,i):0;h.set(t,o),e=Math.max(e,o)}let t="horizontal"===o?n.height:n.width,s=r.padding()*r.step()*Math.max(0,i.length-1),l=Math.max(0,t-s);if(e>0){let t=0;for(let i of h.values())t+=i/e;for(let[i,r]of h)h.set(i,r/e/t*l)}}let f=0,p=0;for(let e of i){let t,i,o=u.get(e)||[],n=o.reduce((e,t)=>e+Math.abs(l(t)),0),a=d>0?n/d:0;h?(t=p,i=h.get(e)??r.bandwidth(),p+=i+r.padding()*r.step()):(t=r(e)??0,i=r.bandwidth()),c[e]={name:e,x:t,y:0,width:i,middle:t+i/2,padding:r.padding()*r.step(),pieceData:o,pct:a,pctStart:f},f+=a}return c}function ZS(e,t){let i="function"==typeof t,r=i?null:t||"category",o=/* @__PURE__ */new Map;for(let n=0;n<e.length;n++){let a=e[n],s=i?t(a):a[r],l=o.get(s);l?l.push(n):o.set(s,[n])}return o}var QS=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],KS=["scene-style","data-paint","accessibility","evidence"],JS=(e,t)=>({retainedData:e,invalidations:t}),eM=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],tM=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],iM=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],rM=["scene-geometry","data-paint","accessibility","evidence"],oM=["scene-style","data-paint","accessibility","evidence"],nM=[],aM={chartType:/* @__PURE__ */JS("rebuild",eM),runtimeMode:/* @__PURE__ */JS("rebuild",eM),categoryAccessor:/* @__PURE__ */JS("rebuild",eM),valueAccessor:/* @__PURE__ */JS("rebuild",eM),oAccessor:/* @__PURE__ */JS("rebuild",eM),rAccessor:/* @__PURE__ */JS("rebuild",eM),stackBy:/* @__PURE__ */JS("rebuild",eM),groupBy:/* @__PURE__ */JS("rebuild",eM),timeAccessor:/* @__PURE__ */JS("rebuild",eM),accessorRevision:/* @__PURE__ */JS("rebuild",eM),colorAccessor:/* @__PURE__ */JS("rebuild",oM),symbolAccessor:/* @__PURE__ */JS("rebuild",rM),connectorAccessor:/* @__PURE__ */JS("rebuild",rM),dataIdAccessor:/* @__PURE__ */JS("rebuild",rM),projection:/* @__PURE__ */JS("preserve",tM),extentPadding:/* @__PURE__ */JS("preserve",tM),axisExtent:/* @__PURE__ */JS("preserve",tM),rExtent:/* @__PURE__ */JS("preserve",tM),oExtent:/* @__PURE__ */JS("preserve",tM),multiAxis:/* @__PURE__ */JS("preserve",tM),normalize:/* @__PURE__ */JS("preserve",tM),bins:/* @__PURE__ */JS("preserve",tM),oSort:/* @__PURE__ */JS("preserve",iM),barPadding:/* @__PURE__ */JS("preserve",iM),roundedTop:/* @__PURE__ */JS("preserve",iM),baselinePadding:/* @__PURE__ */JS("preserve",iM),innerRadius:/* @__PURE__ */JS("preserve",iM),cornerRadius:/* @__PURE__ */JS("preserve",iM),startAngle:/* @__PURE__ */JS("preserve",iM),sweepAngle:/* @__PURE__ */JS("preserve",iM),trackFill:/* @__PURE__ */JS("preserve",iM),showOutliers:/* @__PURE__ */JS("preserve",iM),showIQR:/* @__PURE__ */JS("preserve",iM),amplitude:/* @__PURE__ */JS("preserve",iM),connectorOpacity:/* @__PURE__ */JS("preserve",iM),showLabels:/* @__PURE__ */JS("preserve",iM),dynamicColumnWidth:/* @__PURE__ */JS("rebuild",iM),customLayout:/* @__PURE__ */JS("preserve",iM),layoutConfig:/* @__PURE__ */JS("preserve",iM),layoutMargin:/* @__PURE__ */JS("preserve",iM),symbolMap:/* @__PURE__ */JS("preserve",rM),pieceStyle:/* @__PURE__ */JS("preserve",oM),summaryStyle:/* @__PURE__ */JS("preserve",oM),connectorStyle:/* @__PURE__ */JS("preserve",oM),gradientFill:/* @__PURE__ */JS("preserve",oM),colorScheme:/* @__PURE__ */JS("preserve",oM),themeCategorical:/* @__PURE__ */JS("preserve",oM),themeSemantic:/* @__PURE__ */JS("preserve",oM),themeSequential:/* @__PURE__ */JS("preserve",oM),themeDiverging:/* @__PURE__ */JS("preserve",oM),barColors:/* @__PURE__ */JS("preserve",oM),decay:/* @__PURE__ */JS("preserve",oM),pulse:/* @__PURE__ */JS("preserve",oM),staleness:/* @__PURE__ */JS("preserve",oM),layoutSelection:/* @__PURE__ */JS("preserve",oM),windowSize:/* @__PURE__ */JS("preserve",nM),windowMode:/* @__PURE__ */JS("preserve",nM),clock:/* @__PURE__ */JS("preserve",nM),transition:/* @__PURE__ */JS("preserve",nM),introAnimation:/* @__PURE__ */JS("preserve",nM),onLayoutError:/* @__PURE__ */JS("preserve",nM)},sM=/* @__PURE__ */JS("preserve",iM);function lM(e){let t="preserve",i=/* @__PURE__ */new Set;for(let r of e){let e=aM[r]??sM;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}var cM=class{constructor(){this.tracker=new ae}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},QS)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},KS):this.recordNoop("restyle")}recordConfig(e){let t=lM(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as uM}from"d3-quadtree";function dM(e){let t=0,i=0;for(let r of e)"point"===r.type&&!1!==r.interactive&&(t++,r.r>i&&(i=r.r));if(t<=500)return{quadtree:null,maxRadius:i};let r=new Array(t),o=0;for(let t of e)"point"===t.type&&!1!==t.interactive&&(r[o++]=t);return{maxRadius:i,quadtree:uM().x(e=>e.x).y(e=>e.y).addAll(r)}}var hM=class extends Ga{constructor(e){super(),this.rExtent=new _n,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new cM,this.rAccessors=[],this.categories=/* @__PURE__ */new Set,this._hasStreamingData=!1,this.styleResolver=new NS,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=/* @__PURE__ */new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new $n(e.windowSize),this.getO=b(e.categoryAccessor||e.oAccessor,"category");let t="streaming"===e.runtimeMode,i=e.valueAccessor||e.rAccessor;Array.isArray(i)?(this.rAccessors=i.map(e=>y(e,"value")),this.getR=this.rAccessors[0],this.rExtents=i.map(()=>new _n)):(t&&e.timeAccessor,this.getR=y(i,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=b(e.stackBy),this.getGroup=b(e.groupBy),this.getColor=b(e.colorAccessor),this.getSymbol=b(e.symbolAccessor),this.getConnector=b(e.connectorAccessor),this.getDataId=b(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new $n(e.windowSize))}syncPulseTimestampBuffer(){var e,t,i,r;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,i=this.timestampBuffer,r=this.currentTime(),e?null!=i&&i.capacity===t.capacity&&i.size===t.size?i:ja(t,r):null)}currentTime(){return this.config.clock?.()??T()}ingest(e){let t=this.currentTime();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(let e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();let i=e.totalSize||e.inserts.length;Oa(this.buffer,i,this.timestampBuffer);for(let i of e.inserts)Wa(this.buffer,i,this.timestampBuffer,t),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(let i of e.inserts){let e=Wa(this.buffer,i,this.timestampBuffer,t);this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=e&&this.evictValueExtent(e)}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}pushValueExtent(e){if("timeline"===this.config.chartType){let t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;t<this.rAccessors.length;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){let t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;t<this.rAccessors.length;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){let t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;let i="function"==typeof t?t(e):e[t];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(e){let{config:t,buffer:i}=this,r=this.scales,o=this.multiScales,n=this.columns;if(0===i.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,void this.version++;this.rExtent.dirty&&("timeline"===t.chartType?(this.rExtent.clear(),i.forEach(e=>this.pushValueExtent(e))):this.rExtent.recalculate(i,this.getR));let a,s,l=this.getBufferArray(),c=t.projection||"vertical",u=t.oExtent||this.resolveCategories(l),d=this.computeValueDomain(l,u),h="vertical"===c,f="horizontal"===c,p="radial"===c,g=null!=t.barPadding?t.barPadding/(h?e.width:e.height):.1,m=Math.min(.9,Math.max(0,g));if(p){a=RS().domain(u).range([0,1]).padding(0);let i=Math.min(e.width,e.height)/2,r=t.innerRadius||0;s=TS().domain(d).range([r,i])}else f?(a=RS().domain(u).range([0,e.height]).padding(m),s=TS().domain(d).range([0,e.width])):(a=RS().domain(u).range([0,e.width]).padding(m),s=TS().domain(d).range([e.height,0]));this.scales={o:a,r:s,projection:c},this.rAccessors.length>1&&t.multiAxis?this.multiScales=this.rAccessors.map((r,o)=>{let n=this.rExtents[o];n.dirty&&n.recalculate(i,r);let[a,s]=n.extent;a===1/0&&(a=0,s=1);let l=t.extentPadding??.05,c=s-a,u=c>0?c*l:1;return a-=u,s+=u,a>0&&(a=0),f?TS().domain([a,s]).range([0,e.width]):TS().domain([a,s]).range([e.height,0])}):this.multiScales=[];let y=l;this.rAccessors.length>1&&(y=l.flatMap(e=>this.rAccessors.map((t,i)=>({...e,__rIndex:i,__rValue:t(e),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(y,u,a,c,e),this._customLayoutFailedThisBuild=!1;let x=this.buildSceneNodes(y,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.multiScales=o,this.columns=n):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=x,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,l),this.config.pulse&&this.applyPulse(this.scene,l),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++)}resolveRAccessorName(e){let t=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(t)?t[e]:t;return"string"==typeof i?i:`value${e}`}resolveCategories(e){let t=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,r="auto"===t?void 0:t,o=null;if(i){o=/* @__PURE__ */new Set;for(let t of e)o.add(this.getO(t))}let n=o?Array.from(this.categories).filter(e=>o.has(e)):Array.from(this.categories);if(i&&void 0===r){let e=Math.max(50,3*o.size);if(this.categories.size>e){let t=this.categories.size-e;for(let e of this.categories){if(t<=0)break;o.has(e)||(this.categories.delete(e),t--)}}return n}if(!1===r)return n;if("function"==typeof r)return n.sort(r);let a=/* @__PURE__ */new Map;for(let t of e){let e=this.getO(t);a.set(e,(a.get(e)||0)+Math.abs(this.getR(t)))}return"asc"===r?n.sort((e,t)=>(a.get(e)||0)-(a.get(t)||0)):n.sort((e,t)=>(a.get(t)||0)-(a.get(e)||0))}computeValueDomain(e,t){return HS({data:e,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(e,t,i,r,o){return US({data:e,oExtent:t,oScale:i,projection:r,layout:o,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.styleResolver.resolvePieceStyle(this.config,e,t),resolveSummaryStyle:(e,t)=>this.styleResolver.resolveSummaryStyle(this.config,e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){let i=this.buildLayoutContext(e,t),r=Kn({family:"ordinal",logLabel:"ordinal customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:this.config.onLayoutError,run:()=>this.config.customLayout(i)});if("failure"===r.kind)return this.lastCustomLayoutFailure=r.diagnostic,this._customLayoutFailedThisBuild=!0,r.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);let o=r.result;this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;let n=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=/* @__PURE__ */new WeakMap;for(let e of n)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(n,this.config.layoutSelection??null)}return qn({label:"ordinal customLayout",nodes:n,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),n}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;let i=this.getSceneContext(),r=qS[this.config.chartType],o=r?r(i,t):[];return this.getConnector&&this.scales&&(o=[...FS(i,o),...o]),o}buildLayoutContext(e,t){let i=this.config,r=i.layoutMargin??{top:0,right:0,bottom:0,left:0},o=Ip(i.colorScheme,i.themeCategorical,ji),n=this.scales,a="radial"===n.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height};return{data:e,scales:{o:n.o,r:n.r,projection:n.projection},dimensions:{width:t.width,height:t.height,margin:r,plot:a},theme:{semantic:i.themeSemantic??{},categorical:[...o]},resolveColor:Rp(o,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(e,t){let i=this.config.decay;return!i||t<=1?1:Rn(i,e,t)}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;let t=Tn(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;let t=ZS(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){let e=dM(this.scene);this._pointQuadtree=e.quadtree,this._maxPointRadius=e.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){if(!this.config.decay)return;let i=t.length;if(i<=1)return;let r=this.getDatumIndexMap(t);for(let t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type||!t.datum)continue;let e=r.get(t.datum);if(null==e)continue;let o=this.computeDecayOpacity(e,i),n=t.style?.opacity??1;t.style={...t.style,opacity:n*o}}}applyPulse(e,t,i=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&CS(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),i)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&En(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();let e,t=/* @__PURE__ */new Map,i=this.scales?.r(0)??0,r="horizontal"!==this.scales?.projection;for(let o=0;o<this.scene.length;o++){let n=this.scene[o],a=this.getNodeKey(n,t);a&&("rect"===n.type?r?this.prevPositionMap.set(a,{x:n.x,y:i,w:n.w,h:0,opacity:n.style.opacity??1}):this.prevPositionMap.set(a,{x:i,y:n.y,w:0,h:n.h,opacity:n.style.opacity??1}):"point"===n.type?this.prevPositionMap.set(a,{x:n.x,y:n.y,r:0,opacity:0}):"wedge"===n.type&&(void 0===e&&(e=n.startAngle),this.prevPositionMap.set(a,{x:n.cx,y:n.cy,startAngle:e,endAngle:e,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){let i=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,r=t.get(i)||0;return t.set(i,r+1),`${i}:${r}`}if("rect"===e.type){let i=e.datum?null!=e.datum.category&&""!==e.datum.category?String(e.datum.category):String(this.getO(e.datum)??""):"",r=`r:${e.group||""}:${i}`,o=t.get(r)||0;return t.set(r,o+1),0===o?r:`${r}:${o}`}return"wedge"===e.type?`w:${e.category??""}`:null}snapshotPositions(){this.prevPositionMap.clear();let e=/* @__PURE__ */new Map;for(let t=0;t<this.scene.length;t++){let i=this.scene[t],r=this.getNodeKey(i,e);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity??i.style.fillOpacity}):"rect"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity??i.style.fillOpacity}):"wedge"===i.type&&this.prevPositionMap.set(r,{x:i.cx,y:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:i.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;let e=this.config.transition.duration??300;if(this.exitNodes.length>0){let e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1,i=/* @__PURE__ */new Set,r=/* @__PURE__ */new Map;for(let e=0;e<this.scene.length;e++){let o=this.scene[e],n=this.getNodeKey(o,r);if(!n)continue;o._transitionKey=n;let a=this.prevPositionMap.get(n);if("point"===o.type)a?(i.add(n),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(a.x!==o.x||a.y!==o.y||void 0!==a.r&&a.r!==o.r)&&(o._targetX=o.x,o._targetY=o.y,o._targetR=o.r,o.x=a.x,o.y=a.y,void 0!==a.r&&(o.r=a.r),t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetR=o.r,o.r=0,o.style={...o.style,opacity:0},t=!0);else if("rect"===o.type)a?(i.add(n),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(a.x!==o.x||a.y!==o.y||a.w!==o.w||a.h!==o.h)&&(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=a.x,o.y=a.y,o.w=a.w??o.w,o.h=a.h??o.h,t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o.style={...o.style,opacity:0},t=!0);else if("wedge"===o.type)if(a)i.add(n),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(a.startAngle!==o.startAngle||a.endAngle!==o.endAngle)&&(o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle,o.startAngle=a.startAngle,o.endAngle=a.endAngle,t=!0);else{o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle;let e=o.startAngle;o.startAngle=e,o.endAngle=e,o.style={...o.style,opacity:0},this.prevPositionMap.set(n,{x:o.cx,y:o.cy,startAngle:e,endAngle:e,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(let[e,r]of this.prevPositionMap)if(!i.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:r.x,y:r.y,r:r.r??3,style:{opacity:r.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:r.x,y:r.y,w:r.w??0,h:r.h??0,style:{opacity:r.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){let t=((r.startAngle??0)+(r.endAngle??0))/2,i={type:"wedge",cx:r.x,cy:r.y,innerRadius:r.innerRadius??0,outerRadius:r.outerRadius??100,startAngle:r.startAngle??0,endAngle:r.endAngle??0,style:{opacity:r.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(i)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:this.currentTime(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;let t=I(e,this.activeTransition),i="linear"===this.config.transition?.easing?"linear":"ease-out-cubic",r=L(t,i);for(let e of this.scene){let t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){let i=this.prevPositionMap.get(t),o=i?i.opacity??1:0;e.style.opacity=R(o,e._targetOpacity,r)}let i=this.prevPositionMap.get(t);void 0!==e._targetX&&i&&(e.x=R(i.x,e._targetX,r),e.y=R(i.y,e._targetY,r)),void 0!==e._targetR&&void 0!==i?.r&&(e.r=R(i.r,e._targetR,r))}else if("rect"===e.type){if(void 0!==e._targetOpacity){let i=this.prevPositionMap.get(t),o=i?i.opacity??1:0;e.style.opacity=R(o,e._targetOpacity,r)}if(void 0===e._targetX)continue;let i=this.prevPositionMap.get(t);if(!i)continue;e.x=R(i.x,e._targetX,r),e.y=R(i.y,e._targetY,r),void 0!==i.w&&(e.w=R(i.w,e._targetW,r),e.h=R(i.h,e._targetH,r))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){let i=this.prevPositionMap.get(t),o=i?i.opacity??1:0;e.style={...e.style,opacity:R(o,e._targetOpacity,r)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){let i=this.prevPositionMap.get(t);i&&void 0!==i.startAngle&&(e.startAngle=R(i.startAngle,e._targetStartAngle,r),e.endAngle=R(i.endAngle,e._targetEndAngle,r))}}}if(t>=1){for(let e of this.scene)if(void 0!==e._targetOpacity&&(e.style={...e.style||{},opacity:0===e._targetOpacity?0:e._targetOpacity},e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(e.x=e._targetX,e.y=e._targetY),void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){let e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null,cs(this.scene),this.exitNodes=[]}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw new Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();let t=Pn(e),i=this.getDataId,r=e=>t.has(i(e));Ba(this.buffer,this.timestampBuffer,r);let o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(let e of o)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getDataId)throw new Error("update() requires dataIdAccessor to be configured");let i=Pn(e),r=this.getDataId,o=/* @__PURE__ */new Set;this.buffer.forEach((e,t)=>{i.has(r(e))&&o.add(t)});let n=this.buffer.update(e=>i.has(r(e)),t);if(0===n.length)return this.updateResults.recordNoop("update"),n;for(let e of n)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),o.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",n.length),n}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(e,t){let i=this._customRestyle;if(i)for(let r of e){let e=this._baseStyles.get(r)??r.style??{},o=i(r,t);r.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(let e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){let t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!m(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!m(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!m(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let r=!1;if("categoryAccessor"in e||"oAccessor"in e){let e=this.config.categoryAccessor||this.config.oAccessor,i=t.categoryAccessor||t.oAccessor;m(e,i)||(this.getO=b(this.config.categoryAccessor||this.config.oAccessor,"category"),r=!0)}let o=!1;if("valueAccessor"in e||"rAccessor"in e){let e=this.config.valueAccessor||this.config.rAccessor,i=t.valueAccessor||t.rAccessor,r=Array.isArray(e)?e:[e],n=Array.isArray(i)?i:[i];if(o=r.length!==n.length||r.some((e,t)=>!m(e,n[t])),o){let e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>y(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new _n)):(this.getR=y(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!m(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?b(this.config.stackBy):void 0),"groupBy"in e&&!m(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?b(this.config.groupBy):void 0),"colorAccessor"in e&&!m(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?b(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!m(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?b(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!m(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?b(this.config.connectorAccessor):void 0);let n="accessorRevision"in e&&e.accessorRevision!==t.accessorRevision;(r||o||n)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(i)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};function fM(e,t,i,r){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:i,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:r,fn:t}:{key:void 0,fn:null}}function pM(e,t,i){return r=>{if(!r||!i||!e.fn&&!t.fn)return r;let o=!1,n=r.map(i=>{let r=e.fn&&e.key&&!(e.key in i),n=t.fn&&t.key&&!(t.key in i);if(!r&&!n)return i;o=!0;let a={...i};return r&&(a[e.key]=e.fn(i)),n&&(a[t.key]=t.fn(i)),a});return o?n:r}}import*as gM from"react";import*as mM from"react";import{arc as yM}from"d3-shape";var xM=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function bM(e){let{innerRadius:t,outerRadius:i,startAngle:r,endAngle:o}=e,n=t<=0;if(!((e.cornerRadius??0)>0&&(e.roundStart||e.roundEnd))){if(n){let e=xM(i,r),t=xM(i,o),n=o-r>Math.PI?1:0;return`M0,0 L${e.x},${e.y} A${i},${i} 0 ${n} 1 ${t.x},${t.y} Z`}let e=xM(i,r),a=xM(i,o),s=xM(t,o),l=xM(t,r),c=o-r>Math.PI?1:0;return`M${e.x},${e.y} A${i},${i} 0 ${c} 1 ${a.x},${a.y} L${s.x},${s.y} A${t},${t} 0 ${c} 0 ${l.x},${l.y} Z`}let a=i-t,s=Math.max(0,Math.min(e.cornerRadius??0,a/2));if(0===s)return bM({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});let l=Math.asin(Math.min(1,s/Math.max(1e-9,i-s))),c=n?0:Math.asin(Math.min(1,s/Math.max(1e-9,t+s))),u=o-r,d=e.roundStart&&e.roundEnd?u/2:u,h=!!e.roundStart&&l<d,f=!!e.roundEnd&&l<d;if(!h&&!f)return bM({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});let p=r+(h?l:0),g=o-(f?l:0),m=r+(h?c:0),y=o-(f?c:0),x=xM(i,p),b=xM(i,g),v=(i-s)*Math.cos(l),w=xM(v,r),k=xM(v,o),A=n?null:xM(t,y),S=n?null:xM(t,m),M=n?0:(t+s)*Math.cos(c),$=n?null:xM(M,r),_=n?null:xM(M,o),P=g-p>Math.PI?1:0,L=n?0:y-m>Math.PI?1:0,I="";if(h)I+=`M${w.x},${w.y}`,I+=` A${s},${s} 0 0 1 ${x.x},${x.y}`;else{let e=xM(i,r);I+=`M${e.x},${e.y}`}if(f)I+=` A${i},${i} 0 ${P} 1 ${b.x},${b.y}`,I+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{let e=xM(i,o);I+=` A${i},${i} 0 ${P} 1 ${e.x},${e.y}`}if(n)I+=" L0,0";else{if(f)I+=` L${_.x},${_.y}`,I+=` A${s},${s} 0 0 1 ${A.x},${A.y}`;else{let e=xM(t,o);I+=` L${e.x},${e.y}`}if(h)I+=` A${t},${t} 0 ${L} 0 ${S.x},${S.y}`,I+=` A${s},${s} 0 0 1 ${$.x},${$.y}`;else{let e=xM(t,r);I+=` A${t},${t} 0 ${L} 0 ${e.x},${e.y}`}}return I+=" Z",I}function vM(e){let t=bM({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),i=[],r=e.colors;if(r.length>0){let t=(e.endAngle-e.startAngle)/r.length;for(let o=0;o<r.length;o++){let n=e.startAngle+o*t;i.push({d:bM({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:n,endAngle:e.endAngle}),color:r[o]})}}return{clipPath:t,slices:i}}import{jsx as wM,jsxs as kM}from"react/jsx-runtime";function AM(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e4?`${(e/1e3).toFixed(0)}K`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function SM(e,t){let i=e.datum;if(!i)return null;let r=[],o=i.__funnelStepLabel,n=Number(i.__funnelStepLabelX),a=Number(i.__funnelStepLabelY),s=Number(i.__funnelRowWidth);"string"==typeof o&&Number.isFinite(n)&&Number.isFinite(a)&&(!Number.isFinite(s)||8.4*o.length+16<=s)&&r.push(
300
+ /* @__PURE__ */wM("text",{x:n,y:a+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:o},`${t}-funnel-step`));let l=Number(i.__funnelValue),c=Number(i.__funnelValueLabelX),u=Number(i.__funnelValueLabelY),d=Number(i.__funnelBarW);if(Number.isFinite(l)&&0!==l&&Number.isFinite(c)&&Number.isFinite(u)&&d>=60){let e=Number(i.__funnelPercent),o=!0!==i.__funnelIsFirstStep&&Number.isFinite(e)?`${AM(l)} (${Math.abs(e-Math.round(e))<.05?Math.round(e):e.toFixed(1)}%)`:AM(l);7.8*o.length+16>d&&(o=AM(l)),7.8*o.length+16<=d&&r.push(
301
+ /* @__PURE__ */wM("text",{x:c,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:o},`${t}-funnel-value`))}return r.length?/* @__PURE__ */wM("g",{children:r},`${t}-funnel-labels`):null}function MM(e,t,i){return Ml($M(e,t,i),e,`ordinal-cursor-${t}`)}function $M(e,t,i){let r=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",o=i=>`ord-${e.type}-${r}-${t}-${i}`,n=`ord-${e.type}-${r}-${t}`;switch(e.type){case"rect":{let t,i,r=e,o=`${pl(n)}-grad`,a=yl(r,o);if(a)i=`url(#${o})`;else if(Bs(r.style.fill)){let e=`${pl(n)}-hatch`;t=Xs(r.style.fill,e),i=`url(#${e})`}else i=fl(r.style.fill);let s=a||t?/* @__PURE__ */kM("defs",{children:[a,t]}):null;if(r.cornerRadii&&ll(r.cornerRadii)){let e=xl(r);/* */
302
+ return kM(mM.Fragment,{children:[s,
303
+ /* @__PURE__ */wM("path",{d:e,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},n)}if(r.roundedTop&&r.roundedTop>0){let e,t=Math.min(r.roundedTop,r.w/2,r.h/2),{x:o,y:a,w:l,h:c}=r;switch(r.roundedEdge){case"right":e=`M${o},${a} L${o+l-t},${a} A${t},${t} 0 0 1 ${o+l},${a+t} L${o+l},${a+c-t} A${t},${t} 0 0 1 ${o+l-t},${a+c} L${o},${a+c} Z`;break;case"left":e=`M${o+l},${a} L${o+t},${a} A${t},${t} 0 0 0 ${o},${a+t} L${o},${a+c-t} A${t},${t} 0 0 0 ${o+t},${a+c} L${o+l},${a+c} Z`;break;case"bottom":e=`M${o},${a} L${o+l},${a} L${o+l},${a+c-t} A${t},${t} 0 0 1 ${o+l-t},${a+c} L${o+t},${a+c} A${t},${t} 0 0 1 ${o},${a+c-t} Z`;break;default:e=`M${o},${a+c} L${o},${a+t} A${t},${t} 0 0 1 ${o+t},${a} L${o+l-t},${a} A${t},${t} 0 0 1 ${o+l},${a+t} L${o+l},${a+c} Z`}/* */
304
+ return kM(mM.Fragment,{children:[s,
305
+ /* @__PURE__ */wM("path",{d:e,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},n)}/* */
306
+ return kM(mM.Fragment,{children:[s,
307
+ /* @__PURE__ */wM("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth}),SM(r,n)]},n)}case"point":{let t=e;/* */
308
+ return wM("circle",{cx:t.x,cy:t.y,r:t.r,fill:fl(t.style.fill),opacity:t.style.opacity??t.style.fillOpacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},n)}case"symbol":return bl(e,t,i);case"glyph":{let r=e;return gl(r,r.x,r.y,`${i??""}ord-glyph-${r.pointId??t}`)}case"wedge":{let r,o=e;if(o._gradientBand&&o._gradientBand.colors.length>0){let e=pl(`${i?`${i}-`:""}gauge-grad-${o.category||n}-${t}`),{clipPath:r,slices:a}=vM({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds?.start??!0,roundEnd:o.roundedEnds?.end??!0,colors:o._gradientBand.colors});/* */
309
+ return kM("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[
310
+ /* @__PURE__ */wM("defs",{children:/* @__PURE__ */wM("clipPath",{id:e,children:/* @__PURE__ */wM("path",{d:r})})}),
311
+ /* @__PURE__ */wM("g",{clipPath:`url(#${e})`,children:a.map((e,t)=>/* @__PURE__ */wM("path",{d:e.d,fill:fl(e.color)},t))}),o.style.stroke&&"none"!==o.style.stroke&&
312
+ /* @__PURE__ */wM("path",{d:r,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},n)}if(o.roundedEnds)r=bM({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{let e=yM().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&e.cornerRadius(o.cornerRadius),r=e(hl)||""}/* */
313
+ return wM("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:fl(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},n)}case"boxplot":{let t=e,i=t.columnWidth/2,r=t.style.strokeWidth??1;return"vertical"===t.projection?/* @__PURE__ */kM("g",{children:[
314
+ /* @__PURE__ */wM("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:r}),
315
+ /* @__PURE__ */wM("rect",{x:t.x-i,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:fl(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:r}),
316
+ /* @__PURE__ */wM("line",{x1:t.x-i,y1:t.medianPos,x2:t.x+i,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2*r}),
317
+ /* @__PURE__ */wM("line",{x1:t.x-.5*i,y1:t.minPos,x2:t.x+.5*i,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:r}),
318
+ /* @__PURE__ */wM("line",{x1:t.x-.5*i,y1:t.maxPos,x2:t.x+.5*i,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:r})]},n):/* @__PURE__ */kM("g",{children:[
319
+ /* @__PURE__ */wM("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:r}),
320
+ /* @__PURE__ */wM("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-i,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:fl(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:r}),
321
+ /* @__PURE__ */wM("line",{x1:t.medianPos,y1:t.y-i,x2:t.medianPos,y2:t.y+i,stroke:t.style.stroke||"#333",strokeWidth:2*r}),
322
+ /* @__PURE__ */wM("line",{x1:t.minPos,y1:t.y-.5*i,x2:t.minPos,y2:t.y+.5*i,stroke:t.style.stroke||"#333",strokeWidth:r}),
323
+ /* @__PURE__ */wM("line",{x1:t.maxPos,y1:t.y-.5*i,x2:t.maxPos,y2:t.y+.5*i,stroke:t.style.stroke||"#333",strokeWidth:r})]},n)}case"violin":{let t=e,i=[
324
+ /* @__PURE__ */wM("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:fl(t.style.fill),fillOpacity:t.style.fillOpacity??t.style.opacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth??1},o("path"))];if(t.iqrLine&&t.bounds){let e=t.bounds,r=e.x+e.width/2,n=e.y+e.height/2;t.iqrLine.isVertical?i.push(
325
+ /* @__PURE__ */wM("line",{x1:r,y1:t.iqrLine.q1Pos,x2:r,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),
326
+ /* @__PURE__ */wM("circle",{cx:r,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med"))):i.push(
327
+ /* @__PURE__ */wM("line",{x1:t.iqrLine.q1Pos,y1:n,x2:t.iqrLine.q3Pos,y2:n,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),
328
+ /* @__PURE__ */wM("circle",{cx:t.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med")))}/* */
329
+ return wM("g",{children:i},n)}case"connector":{let t=e,i=t.style.fill&&"none"!==t.style.fill?fl(t.style.fill,"var(--semiotic-border, #999)"):"var(--semiotic-border, #999)";/* */
330
+ return wM("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||i,strokeWidth:t.style.strokeWidth??1,opacity:t.style.opacity??.5},n)}case"trapezoid":{let t=e,i=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");/* */
331
+ return wM("polygon",{points:i,fill:fl(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},n)}default:return null}}import{jsx as _M,jsxs as PM}from"react/jsx-runtime";function LM(e){return"connector"===e.node.type}function IM(e,t,i,r){if(e.length<2)return null;let o=e[0].node,n=o.style.fill;if(!n||"none"===n)return null;let a=pl(`${t?`${t}-`:""}connector-${i}-${r}-hatch`),s=Bs(n)?Xs(n,a):null,l=[`${o.x1},${o.y1}`,...e.map(({node:e})=>`${e.x2},${e.y2}`)].join(" ");return Ml(/* @__PURE__ */PM(gM.Fragment,{children:[s&&/* @__PURE__ */_M("defs",{children:s}),
332
+ /* @__PURE__ */_M("polygon",{points:l,fill:s?`url(#${a})`:fl(n,"#999"),opacity:o.style.fillOpacity??o.style.opacity??.3,"data-semiotic-connector-fill":o.group||"_default"})]}),o,`ordinal-connector-fill-${i}-${r}`)}function RM(e,t,i){let r=/* @__PURE__ */new Map;for(let t of e){if(!LM(t))continue;let e=t.node.group||"_default",i=r.get(e);i?i.push(t):r.set(e,[t])}if(0===r.size)return;let o=Array.from(r.values()).map((e,r)=>/* @__PURE__ */PM("g",{children:[IM(e,t,i,r),e.map(e=>e.element)]},`ordinal-connectors-${i}-${r}`)),n=e[0],a=LM(n)?null:n.element;for(let e of r.values())for(let t of e)t.element=null;n.element=/* @__PURE__ */PM(gM.Fragment,{children:[o,a]},`ordinal-connector-run-${i}`)}function TM(e){let t=Ol({nodes:e.nodes,renderMode:e.renderMode,fallback:(t,i)=>MM(t,i,e.idPrefix)}),i=0;for(let r=0;r<t.length;){if(t[r].renderedByBackend){r++;continue}let o=r+1;for(;o<t.length&&!t[o].renderedByBackend;)o++;RM(t.slice(r,o),e.idPrefix,i++),r=o}return t}function CM(e){let{id:t,...i}=e;return Xs({type:"hatch",...i},t)}var NM={stroke:"rgba(255,255,255,0.5)",lineWidth:1.5,spacing:6,angle:45,lineOpacity:1};import{Fragment as FM,jsx as DM,jsxs as EM}from"react/jsx-runtime";function zM(e,t,i,r,o,n,a,s=!1){let l=e.scales;if(!l||"radial"===l.projection)return null;let c=br(r),u="vertical"===l.projection,d=e.columns,h=i.categoryFormat||i.oFormat,f=i.valueFormat||i.rFormat,p=i.categoryLabel||i.oLabel,g=i.valueLabel||i.rLabel,m=i.legendPosition??"right",y=at(i.legendLayout,a?.leftAxis),x=s&&"left"===m&&y>0?y:n?.left??i.margin?.left??40,b=Object.values(d).map((e,t)=>({pixel:e.middle,label:h?h(e.name,t):e.name})),v=i.rTickValues??Eu(l.r,5,i.axisExtent),w=f||Ue(v),k=v.map(e=>({pixel:l.r(e),label:w(e)}));/* */
333
+ return EM("g",u?{id:(o?`${o}-`:"")+"axes",className:"ordinal-axes",children:[
334
+ /* @__PURE__ */DM("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:c.border,strokeWidth:1}),b.map((e,i)=>/* @__PURE__ */EM("g",{transform:`translate(${e.pixel},${t.height})`,children:[
335
+ /* @__PURE__ */DM("line",{y2:5,stroke:c.border,strokeWidth:1}),Ou(e.label)?/* @__PURE__ */DM("text",{y:18,textAnchor:"middle",fontSize:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:e.label}):ju({label:e.label,x:-30,y:6,textAlign:"center",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},`oxtick-${i}`)),p&&/* @__PURE__ */DM("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,children:p}),
336
+ /* @__PURE__ */DM("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:c.border,strokeWidth:1}),k.map((e,t)=>/* @__PURE__ */EM("g",{transform:`translate(0,${e.pixel})`,children:[
337
+ /* @__PURE__ */DM("line",{x2:-5,stroke:c.border,strokeWidth:1}),
338
+ /* @__PURE__ */DM("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:e.label})]},`oytick-${t}`)),g&&/* @__PURE__ */DM("text",{x:15-x,y:t.height/2,textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,transform:`rotate(-90, ${15-x}, ${t.height/2})`,children:g})]}:{id:(o?`${o}-`:"")+"axes",className:"ordinal-axes",children:[
339
+ /* @__PURE__ */DM("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:c.border,strokeWidth:1}),k.map((e,i)=>/* @__PURE__ */EM("g",{transform:`translate(${e.pixel},${t.height})`,children:[
340
+ /* @__PURE__ */DM("line",{y2:5,stroke:c.border,strokeWidth:1}),
341
+ /* @__PURE__ */DM("text",{y:18,textAnchor:"middle",fontSize:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:e.label})]},`oxtick-${i}`)),g&&/* @__PURE__ */DM("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,children:g}),
342
+ /* @__PURE__ */DM("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:c.border,strokeWidth:1}),b.map((e,t)=>/* @__PURE__ */EM("g",{transform:`translate(0,${e.pixel})`,children:[
343
+ /* @__PURE__ */DM("line",{x2:-5,stroke:c.border,strokeWidth:1}),Ou(e.label)?/* @__PURE__ */DM("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:e.label}):ju({label:e.label,x:-68,y:-12,textAlign:"right",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},`oytick-${t}`)),p&&/* @__PURE__ */DM("text",{x:15-x,y:t.height/2,textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,transform:`rotate(-90, ${15-x}, ${t.height/2})`,children:p})]})}function OM(e,t){let i=xr(e.theme),r=vd,o=e.size||[500,400],n=tt({...r,...e.margin},e.title),a=Je(e.title),s=pi(e.data),l=e.showLegend?ic(s,e.colorAccessor||e.stackBy||e.groupBy):[],c=ht({showAxes:e.showAxes,projection:e.projection,hasCategoryLabel:!(!e.categoryLabel&&!e.oLabel),hasValueLabel:!(!e.valueLabel&&!e.rLabel)});rd(n,{props:{...e,axisChrome:c},categories:l,theme:i,size:o,hasTitle:a});let u=od({props:{...e,axisChrome:c},categories:l,theme:i,size:o,margin:n,hasTitle:a}),d=Math.max(1,o[0]-n.left-n.right),h=Math.max(1,o[1]-n.top-n.bottom),f=e.projection||"vertical",p="radial"===f,g=e.colorScheme||i.colors.categorical,m={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:f,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,axisExtent:e.axisExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,gradientFill:nr(e.gradientFill),symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:g,themeCategorical:i.colors.categorical,themeSemantic:Y(i),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:n,layoutSelection:e.layoutSelection,barColors:e.barColors},y=new hM(m);e.data&&y.ingest({inserts:s,bounded:!0}),y.computeScene({width:d,height:h});let x=bd(e.backgroundGraphics,o,n,y.scales),b=bd(e.foregroundGraphics,o,n,y.scales);if(!y.scales){let r,a=e.annotations?ku({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{},layout:{width:d,height:h},theme:i,projection:f,idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;t&&(t.evidence=Fs({frameType:"ordinal",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:r,extraWarnings:y.scales?[]:["NO_SCALES"],margin:n}));let l=x||b||e.annotations?/* @__PURE__ */EM(FM,{children:[x,a,b,y.customLayoutOverlays]}):null;return IS.renderToStaticMarkup(ad(l,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?` ${e.className}`:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,innerWidth:d,innerHeight:h,legend:u,idPrefix:e._idPrefix}))}let v=e._idPrefix,w=e.showGrid?nd(y,{width:d,height:h},i,v,e.axisExtent,e.rTickValues):null,k=null;if(y.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){let t=Ku(e),i=/* @__PURE__ */new Set;for(let e of y.scene)if("rect"===e.type&&e.datum?.__barFunnelIsDropoff){let t="string"==typeof e.style.fill?e.style.fill:"#666";i.add(t)}k=Array.from(i).map((e,i)=>CM({...NM,id:`funnel-hatch-${t}-${i}`,background:e}));let r=/* @__PURE__ */new Map;Array.from(i).forEach((e,i)=>r.set(e,`funnel-hatch-${t}-${i}`));for(let e of y.scene)if("rect"===e.type&&e.datum?.__barFunnelIsDropoff){let t="string"==typeof e.style.fill?e.style.fill:"#666";e.style={...e.style,fill:`url(#${r.get(t)})`}}}let A,S=TM({nodes:y.scene,renderMode:e.renderMode,idPrefix:v}),M=S.map(e=>e.element),$=!1!==e.showAxes?zM(y,{width:d,height:h},e,i,v,n,c,!!u):null,_=e.categoryAccessor??e.oAccessor??"category",P=e.valueAccessor??e.rAccessor??"value",L="horizontal"===f,I=fM(L?P:_,void 0,"__semiotic_resolvedO",""),R=fM(L?_:P,void 0,"__semiotic_resolvedR",""),T=e.annotations?ku({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:pM(I,R,e.annotations.length>0)(s),scales:{o:y.scales.o,r:y.scales.r,y:"vertical"===y.scales.projection?y.scales.r:void 0},layout:{width:d,height:h},theme:i,projection:f,xAccessor:I.key,yAccessor:R.key,idPrefix:v,onRender:e=>{A=e}}):null;if(t){let i=y.scales.o?.domain?.();t.evidence=Fs({frameType:"ordinal",width:o[0],height:o[1],marks:S.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:A,yDomain:Ns(y.scales.r?.domain?.()),categories:Array.isArray(i)?i.map(String):void 0,margin:n})}let C=p&&e.centerContent?LS(e.centerContent,n.left+d/2,n.top+h/2):null,N=p&&e.centerContent?C??/* @__PURE__ */DM("foreignObject",{x:n.left,y:n.top,width:d,height:h,pointerEvents:"none",children:/* @__PURE__ */DM("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null,F=/* @__PURE__ */EM(FM,{children:[w,M,$,T,b,y.customLayoutOverlays]}),D=/* @__PURE__ */EM(FM,p?{children:[x?/* @__PURE__ */DM("g",{transform:`translate(${-d/2},${-h/2})`,children:x}):null,F]}:{children:[x,F]});return IS.renderToStaticMarkup(ad(D,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?` ${e.className}`:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:p?`translate(${n.left+d/2},${n.top+h/2})`:`translate(${n.left},${n.top})`,innerWidth:d,innerHeight:h,legend:u,defs:k,outerElements:N,idPrefix:e._idPrefix}))}import*as jM from"react-dom/server";import{geoPath as WM}from"d3-geo";import{quadtree as BM}from"d3-quadtree";import{geoMercator as YM,geoEqualEarth as GM,geoAlbersUsa as XM,geoOrthographic as VM,geoNaturalEarth1 as qM,geoEquirectangular as HM}from"d3-geo";var UM={mercator:YM,equalEarth:GM,albersUsa:XM,orthographic:VM,naturalEarth:qM,equirectangular:HM};function ZM(e){if(!e)return GM();if("string"==typeof e){let t=UM[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),GM())}if("object"==typeof e&&"type"in e){let t=UM[e.type],i=t?t():GM();return e.rotate&&"rotate"in i&&i.rotate(e.rotate),e.center&&"center"in i&&i.center(e.center),i}return e}function QM(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function KM(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function JM(e,t,i){return e?"function"==typeof e?{...i,...e(t)}:{...i,...e}:{...i}}function e$(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}function t$(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}function i$(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}function r$(e,t){if(e.length<2)return[e];let i=.4*t,r=[],o=[e[0]];for(let t=1;t<e.length;t++){let n=e[t-1],a=e[t];Math.abs(a[0]-n[0])>i?(o.length>=2&&r.push(o),o=[a]):o.push(a)}return o.length>=2&&r.push(o),r}function o$(e,t,i=24){let r=t[0]-e[0],o=t[1]-e[1],n=Math.sqrt(r*r+o*o);if(0===n)return[e,t];let a=-o/n,s=r/n,l=Math.min(.3*n,80),c=(e[0]+t[0])/2+a*l,u=(e[1]+t[1])/2+s*l,d=[];for(let r=0;r<=i;r++){let o=r/i,n=1-o,a=n*n*e[0]+2*n*o*c+o*o*t[0],s=n*n*e[1]+2*n*o*u+o*o*t[1];d.push([a,s])}return d}function n$(e,t){if(e.length<2)return e;let i=t/2+1,r=[];for(let t=0;t<e.length;t++){let o,n,a=e[t];0===t?(o=e[1][0]-a[0],n=e[1][1]-a[1]):t===e.length-1?(o=a[0]-e[t-1][0],n=a[1]-e[t-1][1]):(o=e[t+1][0]-e[t-1][0],n=e[t+1][1]-e[t-1][1]);let s=Math.sqrt(o*o+n*n)||1,l=n/s,c=-o/s;r.push([a[0]+l*i,a[1]+c*i])}return r}function a$(e,t,i,r,o){let n=t[0]-e[0],a=t[1]-e[1],s=Math.sqrt(n*n+a*a);if(0===s)return[e,t];let l=a/s,c=-n/s,u=o/2+1;return[[e[0]+l*u,e[1]+c*u],[t[0]+l*u,t[1]+c*u]]}import{scaleLinear as s$}from"d3-scale";function l$(e,t,i,r){let o=e.filter(e=>"point"===e.type);if(o.length<2)return null;let n=t.strength??1,a=Number.isFinite(n)?Math.max(0,Math.min(1,n)):1,s="strip"===t.layout?"strip":"radial";if("radial"===s&&0===a)return null;let l=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,c="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=o.find(e=>e.datum&&String(l(e.datum))===String(t.center));if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;let d=o.map(e=>e.datum?Number(c(e.datum)):NaN).filter(e=>isFinite(e)&&e>=0),h=Fe(d,1);r>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let t=e.length-1;t>=0;t--){let i=e[t];"geoarea"===i.type&&i.interactive&&e.splice(t,1)}let f="strip"===s?u$(o,u,c,h,i):c$(o,u,c,h,a,i),p=e.filter(e=>"line"===e.type);if(p.length>0){let e=/* @__PURE__ */new Map;for(let t of o)null!=t.pointId&&e.set(String(t.pointId),[t.x,t.y]);for(let i of p){let r=i.datum?.source,o=i.datum?.target;if(null!=r&&null!=o){let n=e.get(String(r)),a=e.get(String(o));if(n&&a)if("fractional"===t.lineMode&&i.path.length>2){let e=i.path[0],t=i.path[i.path.length-1],r=[n[0]-e[0],n[1]-e[1]],o=[a[0]-t[0],a[1]-t[1]],s=[0];for(let e=1;e<i.path.length;e++)s.push(s[e-1]+Math.hypot(i.path[e][0]-i.path[e-1][0],i.path[e][1]-i.path[e-1][1]));let l=s[s.length-1];i.path=i.path.map((e,t)=>{let n=l>0?s[t]/l:t/(i.path.length-1);return[e[0]+r[0]*(1-n)+o[0]*n,e[1]+r[1]*(1-n)+o[1]*n]})}else i.path=[n,a]}}}return f}function c$(e,t,i,r,o,n){let a=t.x,s=t.y,l=n.width/2,c=n.height/2,u=Math.min(n.width,n.height)/2,d=s$().domain([0,r]).range([0,u]);for(let n of e){if(n===t||!n.datum)continue;let e=n.x,u=n.y,h=Math.atan2(u-s,e-a),f=Math.hypot(e-a,u-s),p=Number(i(n.datum)),g=isFinite(p)&&p>=0?r>0?d(p):0:f,m=l+Math.cos(h)*g,y=c+Math.sin(h)*g;n.x=e+(m-e)*o,n.y=u+(y-u)*o}return t.x=a+(l-a)*o,t.y=s+(c-s)*o,{cx:t.x,cy:t.y,maxCost:r,availableRadius:u,layout:"radial"}}function u$(e,t,i,r,o){let n=Math.max(3,Math.min(8,.35*o.height)),a=Math.max(1,o.width-2*n),s=o.height/2,l=s$().domain([0,r]).range([0,a]);t.x=n,t.y=s;let c=[];for(let o of e){if(o===t)continue;if(!o.datum){o.x=n,o.y=s;continue}let e=Number(i(o.datum)),a=n+(isFinite(e)&&e>=0&&r>0?l(e):0);o.x=a,o.y=s,c.push({node:o,x:a})}c.sort((e,t)=>e.x-t.x);let u=Math.max(0,Math.min(o.height/2-1,6)),d=0;for(;d<c.length;){let e=d+1;for(;e<c.length&&Math.abs(c[e].x-c[d].x)<3;)e++;let t=e-d;if(t>1&&u>0)for(let e=0;e<t;e++){let i=e-(t-1)/2,r=Math.min(2.5,2*u/Math.max(1,t-1));c[d+e].node.y=s+i*r}d=e}return{cx:n,cy:s,maxCost:r,availableRadius:a,layout:"strip"}}var d$=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],h$=["scene-style","data-paint","accessibility","evidence"],f$=(e,t)=>({retainedData:e,invalidations:t}),p$=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],g$=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],m$=["scene-geometry","data-paint","accessibility","evidence"],y$=["scene-style","data-paint","accessibility","evidence"],x$=["scene-geometry","scene-style","data-paint","accessibility","evidence"],b$=["overlay","accessibility","evidence"],v$=[],w$={xAccessor:/* @__PURE__ */f$("rebuild",p$),yAccessor:/* @__PURE__ */f$("rebuild",p$),lineDataAccessor:/* @__PURE__ */f$("rebuild",p$),pointIdAccessor:/* @__PURE__ */f$("rebuild",m$),lineIdAccessor:/* @__PURE__ */f$("rebuild",m$),windowSize:/* @__PURE__ */f$("rebuild",p$),projection:/* @__PURE__ */f$("preserve",g$),projectionExtent:/* @__PURE__ */f$("preserve",g$),fitPadding:/* @__PURE__ */f$("preserve",g$),lineType:/* @__PURE__ */f$("preserve",g$),flowStyle:/* @__PURE__ */f$("preserve",g$),graticule:/* @__PURE__ */f$("preserve",g$),projectionTransform:/* @__PURE__ */f$("preserve",g$),customLayout:/* @__PURE__ */f$("preserve",g$),layoutConfig:/* @__PURE__ */f$("preserve",g$),layoutMargin:/* @__PURE__ */f$("preserve",g$),areaStyle:/* @__PURE__ */f$("preserve",y$),pointStyle:/* @__PURE__ */f$("preserve",x$),lineStyle:/* @__PURE__ */f$("preserve",y$),colorScheme:/* @__PURE__ */f$("preserve",y$),themeCategorical:/* @__PURE__ */f$("preserve",y$),themeDiverging:/* @__PURE__ */f$("preserve",y$),themeSemantic:/* @__PURE__ */f$("preserve",y$),themeSequential:/* @__PURE__ */f$("preserve",y$),decay:/* @__PURE__ */f$("preserve",y$),pulse:/* @__PURE__ */f$("preserve",y$),layoutSelection:/* @__PURE__ */f$("preserve",y$),annotations:/* @__PURE__ */f$("preserve",b$),autoPlaceAnnotations:/* @__PURE__ */f$("preserve",b$),clock:/* @__PURE__ */f$("preserve",v$),transition:/* @__PURE__ */f$("preserve",v$),introAnimation:/* @__PURE__ */f$("preserve",v$),onLayoutError:/* @__PURE__ */f$("preserve",v$)},k$=/* @__PURE__ */f$("preserve",g$);function A$(e){let t="preserve",i=/* @__PURE__ */new Set;for(let r of e){let e=w$[r]??k$;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}var S$=class{constructor(){this.tracker=new ae}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},d$)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},h$):this.recordNoop("restyle")}recordConfig(e,t={}){let i=A$(e),r=new Set(i.invalidations);return t.retainedDataChanged&&r.add("data"),this.tracker.record({kind:"config",keys:e},r)}};import{geoDistance as M$,geoGraticule as $$,geoInterpolate as _$}from"d3-geo";function P$({config:e,projection:t,path:i,areas:r,points:o,lines:n,layout:a}){let s=QM(e.xAccessor,"lon"),l=QM(e.yAccessor,"lat"),c=[],u=e$(e),d=i$(e),h=t$(e);if(e.graticule){let t=!0===e.graticule?{}:e.graticule,r=$$();t.step&&r.step(t.step);let o=i(r())||"";o&&c.push({type:"geoarea",pathData:o,centroid:[a.width/2,a.height/2],bounds:[[0,0],[a.width,a.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth??.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(let t of r){let r=i(t);if(!r)continue;let o=i.centroid(t),n=i.bounds(t),a=i.area(t);c.push({type:"geoarea",pathData:r,centroid:o,bounds:n,screenArea:a,style:JM(e.areaStyle,t,u),datum:t,interactive:!0})}let f=KM(e.lineDataAccessor);for(let i of n){let r=f(i);if(!r||r.length<2)continue;let o=[];if("geo"===e.lineType){let e=new Array(r.length);for(let t=0;t<r.length;t++)e[t]=[s(r[t]),l(r[t])];for(let i=0;i<e.length-1;i++){let r=e[i],n=e[i+1],a=M$(r,n)||0,s=Math.max(2,Math.ceil(a/(Math.PI/180))),l=_$(r,n);for(let e=0;e<=s;e++){if(i>0&&0===e)continue;let r=t(l(e/s));null!=r&&o.push(r)}}}else for(let e=0;e<r.length;e++){let i=r[e],n=t([s(i),l(i)]);null!=n&&o.push(n)}if(o.length<2)continue;let n=JM(e.lineStyle,i,d),u="number"==typeof n.strokeWidth?n.strokeWidth:1;2===r.length&&o.length>=2&&"arc"===e.flowStyle?o=o$(o[0],o[o.length-1]):2===r.length&&o.length>=2&&"offset"===e.flowStyle&&(o="geo"===e.lineType?n$(o,u):a$(o[0],o[o.length-1],0,0,u));let h=r$(o,a.width);if(h.length<=1)c.push({type:"line",path:o.length>=2?o:h[0]||o,style:n,datum:i});else for(let e of h)e.length<2||c.push({type:"line",path:e,style:{...n,_edgeFade:!0},datum:i})}let p=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,g=t.clipAngle?t.clipAngle()??0:0,m=g>0?g*Math.PI/180:null,y=t.rotate?t.rotate():[0,0,0],x="function"==typeof t.center?t.center():[0,0],b=[(x[0]??0)-y[0],(x[1]??0)-y[1]];for(let i of o){let r=s(i),o=l(i);if(null!=m&&M$([r,o],b)>m)continue;let n=t([r,o]);if(!n)continue;let a=e.pointStyle?e.pointStyle(i):{...h},u={type:"point",x:n[0],y:n[1],r:a.r||4,style:a,datum:i,pointId:p?String(p(i)):void 0};c.push(u)}return c}function L$(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e)&&e>=0&&e<.5)return e;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${String(e)}.`)}var I$=class extends Ga{constructor(e){var t;super(),this.updateResults=new S$,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=(t=e,{...t,fitPadding:L$(t.fitPadding)})}currentTime(){return this.config.clock?.()??T()}getConfiguredWindowSize(){let e=this.config.windowSize??500;if(!Number.isInteger(e)||e<1)throw new Error("GeoPipelineStore windowSize must be a positive integer");return e}retainNewestLines(e=this.getConfiguredWindowSize()){this.lineData.length>e&&(this.lineData=this.lineData.slice(-e))}resizeStreamingWindow(e){if(this.pointBuffer){let t=this.pointBuffer.toArray(),i=this.timestampBuffer?.toArray()??[],r=t.slice(-e),o=i.slice(-r.length),n=this.currentTime();this.pointBuffer=new $n(e),this.timestampBuffer=new $n(e),r.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(o[t]??n)})}this.retainNewestLines(e)}updateConfig(e){let t="fitPadding"in(n=e)?{...n,fitPadding:L$(n.fitPadding)}:n,i=this.config,r=this.getConfiguredWindowSize(),o=Object.keys(t).filter(e=>t[e]!==i[e]);var n;this.config={...this.config,...t};let a=this.getConfiguredWindowSize(),s=this.streaming&&a!==r;s&&(this.resizeStreamingWindow(a),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(o,{retainedDataChanged:s})}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setAreas(e){this.areas=e,this.updateResults.recordData("replace",e.length)}setAreasWithResult(e){return this.setAreas(e),this.updateResults.last}setPoints(e){this.pointData=e.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",e.length)}setPointsWithResult(e){return this.setPoints(e),this.updateResults.last}setLines(e){this.lineData=e.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",e.length)}setLinesWithResult(e){return this.setLines(e),this.updateResults.last}initStreaming(e){void 0!==e&&e!==this.config.windowSize&&(this.config={...this.config,windowSize:e});let t=this.getConfiguredWindowSize(),i=this.pointBuffer?this.pointBuffer.toArray():this.pointData,r=this.timestampBuffer?.toArray()??[],o=i.slice(-t),n=r.slice(-o.length),a=this.currentTime();this.pointBuffer=new $n(t),this.timestampBuffer=new $n(t),o.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(n[t]??a)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();let t=this.currentTime();Wa(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t,this.updateResults.recordData("ingest",1)}pushPointWithResult(e){return this.pushPoint(e),this.updateResults.last}pushMany(e){this.pointBuffer||this.initStreaming();let t=this.currentTime();for(let i of e)Wa(this.pointBuffer,i,this.timestampBuffer,t);this.lastIngestTime=t,this.updateResults.recordData("ingest",e.length)}pushManyWithResult(e){return this.pushMany(e),this.updateResults.last}pushLine(e){null!=e&&"object"==typeof e?(this.streaming||this.initStreaming(),this.lineData.push(e),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return void this.updateResults.recordNoop("ingest");let t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(let e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){let{lineIdAccessor:t}=this.config;if(!t)throw new Error("removeLine() requires lineIdAccessor to be configured");let i="function"==typeof t?t:e=>e[t],r=new Set(Array.isArray(e)?e:[e]),o=[];return this.lineData=this.lineData.filter(e=>!r.has(String(i(e)))||(o.push(e),!1)),o.length>0?(this.version++,this.updateResults.recordData("remove",o.length)):this.updateResults.recordNoop("remove"),o}getLines(){return this.lineData.slice()}removePoint(e){let{pointIdAccessor:t}=this.config;if(!t)throw new Error("removePoint() requires pointIdAccessor to be configured");let i="function"==typeof t?t:e=>e[t],r=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){let e=e=>r.has(String(i(e)));Ba(this.pointBuffer,this.timestampBuffer,e);let t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{let e=[];return this.pointData=this.pointData.filter(t=>!r.has(String(i(t)))||(e.push(t),!1)),e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(e){let t=this._customRestyle;if(t){for(let i of this.scene){let r=this._baseStyles.get(i)??i.style,o=t(i,e);i.style=o?{...r,...o}:r}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){let{config:t}=this,i=this.projection,r=this.geoPath,o=this.scales,n=this.baseScale,a=[...this.baseTranslate],s=[...this.baseRotation],l=this.scene;this.projection=ZM(t.projection),this.geoPath=WM(this.projection),this.fitProjection(e),this.geoPath=WM(this.projection);let c=this.projection;this.scales={projection:c,geoPath:this.geoPath,projectedPoint:(e,t)=>c([e,t]),invertedPoint:(e,t)=>c.invert?c.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=i,this.geoPath=r,this.scales=o,this.baseScale=n,this.baseTranslate=a,this.baseRotation=s):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){let t=e.width/2,i=e.height/2,r=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:i}));r.length>0&&this.startTransition(r)}this._hasRenderedOnce=!0,t.transition&&l.length>0&&this.startTransition(l),this.version++}}fitProjection(e){let t=this.projection,i=this.config,r=[...this.areas],o=QM(i.xAccessor,"lon"),n=QM(i.yAccessor,"lat"),a=this.getPoints();if(a.length>0){let e=a.map(e=>[o(e),n(e)]);r.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}let s=KM(i.lineDataAccessor);for(let e of this.lineData){let t=s(e);if(t&&t.length>0){let e=t.map(e=>[o(e),n(e)]);r.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==r.length){if(i.projectionExtent){let[[r,o],[n,a]]=i.projectionExtent,s={type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[r,o],[r,a],[n,a],[n,o],[r,o]]]}};t.fitExtent([[0,0],[e.width,e.height]],s)}else if(t.clipAngle&&(t.clipAngle()??0)>0){let r=i.fitPadding??0,o=Math.min(e.width,e.height),n=o/2-o*r;t.scale(n),t.translate([e.width/2,e.height/2])}else{let o={type:"FeatureCollection",features:r},n=i.fitPadding??0,a=e.width*n,s=e.height*n;t.fitExtent([[a,s],[e.width-a,e.height-s]],o)}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){let i=this.projection;if(!i)return;let r=this.geoPath,o=this.scales,n=i.scale(),a=[...i.translate()],s=this.currentZoom;i.scale(this.baseScale*e.k),i.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=WM(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(n),i.translate(a),this.currentZoom=s,this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=l,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){let i=this.projection;if(!i)return;let r=this.geoPath,o=this.scales,n=i.scale(),a=[...i.translate()],s=this.currentZoom;i.scale(this.baseScale*e),i.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=WM(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(n),i.translate(a),this.currentZoom=s,this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=l,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){let i=this.projection;if(!i||!i.rotate)return;let r=this.geoPath,o=this.scales,n=[...i.rotate()];i.rotate(e),this.geoPath=WM(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let a=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.rotate(n),this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=a,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){let t=this.projection;!t||!t.rotate||t.rotate(e)}hasProjection(){return null!=this.projection}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let e=0,t=0;for(let i of this.scene)"point"===i.type&&!1!==i.interactive&&(t++,i.r>e&&(e=i.r));if(this._maxPointRadius=e,t<=500)return void(this._quadtree=null);let i=new Array(t),r=0;for(let e of this.scene)"point"===e.type&&!1!==e.interactive&&(i[r++]=e);this._quadtree=BM().x(e=>e.x).y(e=>e.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;let{config:t}=this,i=this.projection,r=this.geoPath;if(t.customLayout&&this.scales){let i=t.layoutMargin??{top:0,right:0,bottom:0,left:0},r=Ip(t.colorScheme,t.themeCategorical,ji),o={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:i,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...r]},resolveColor:Rp(r,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null},n=Kn({family:"geo",logLabel:"geo customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:t.onLayoutError,run:()=>t.customLayout(o)});if("failure"===n.kind)return this.lastCustomLayoutFailure=n.diagnostic,this._customLayoutFailedThisBuild=!0,n.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);let a=n.result,s=a.nodes??[];if(this.customLayoutOverlays=a.overlays??null,this.lastCustomLayoutResult=a,this.lastCustomLayoutFailure=null,this._customRestyle=a.restyle,this.hasCustomRestyle=!!a.restyle,this._baseStyles=/* @__PURE__ */new WeakMap,this.hasCustomRestyle)for(let e of s){this._baseStyles.set(e,e.style);let i=a.restyle?.(e,t.layoutSelection??null);i&&(e.style={...e.style,...i})}return qn({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,P$({config:t,projection:i,path:r,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){let i=l$(this.scene,e,t,this.areas.length);i&&(this.cartogramLayout=i)}applyDecay(){let e=this.config.decay;if(!e||!this.pointBuffer)return;let t=this.pointBuffer.size;if(0===t)return;let i=this.scene.filter(e=>"point"===e.type);for(let r=0;r<i.length;r++){let o=Rn(e,r,t);i[r]._decayOpacity=o,i[r].style={...i[r].style,opacity:o}}}applyPulse(e=this.currentTime()){let t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;let i=this.scene.filter(e=>"point"===e.type),r=this.timestampBuffer.toArray(),o=t.color||"rgba(255,255,255,0.6)",n=t.glowRadius??4,a=!1;for(let s=0;s<i.length&&s<r.length;s++){let l=Nn(t,r[s],e);a=Dn(i[s],l,o,n)||a}return a}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&En(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){let t=this.config.transition?.duration??300;if(t<=0)return;let i=/* @__PURE__ */new Map;for(let t of e)"point"===t.type&&t.pointId&&i.set(t.pointId,[t.x,t.y]);let r=this.scene.filter(e=>"point"===e.type),o=!1;for(let e of r)if(e.pointId){let t=i.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(o=!0))}for(let e of r)e.pointId&&!i.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??e.style?.fillOpacity??1,e.style={...e.style,opacity:0},o=!0);o&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null;for(let e of this.scene)"point"===e.type&&(null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0),null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0))}advanceTransition(e){if(!this.activeTransition)return!1;let t=I(e,this.activeTransition),i=L(t),r=this.scene.filter(e=>"point"===e.type);for(let e of r){if(null!=e._targetX&&null!=e._targetY){let t=e.x,r=e.y;e.x=R(t,e._targetX,i),e.y=R(r,e._targetY,i)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*i})}if(t>=1){for(let e of r)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0),null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};import*as R$ from"react";import{jsx as T$,jsxs as C$}from"react/jsx-runtime";function N$(e,t){return Ml(F$(e,t),e,`geo-cursor-${t}`)}function F$(e,t){switch(e.type){case"geoarea":{let i=e;if(!i.pathData)return null;let r=Bs(i.style.fill)?Xs(i.style.fill,`geoarea-${t}-hatch`):void 0;/* */
344
+ return C$(R$.Fragment,{children:[r&&/* @__PURE__ */T$("defs",{children:r}),
345
+ /* @__PURE__ */T$("path",{d:i.pathData,fill:r?`url(#geoarea-${t}-hatch)`:fl(i.style.fill,"#e0e0e0"),fillOpacity:i.style.fillOpacity??1,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth??.5,strokeDasharray:i.style.strokeDasharray,opacity:(i.style.opacity??1)*(i._decayOpacity??1)})]},`geoarea-${t}`)}case"point":{let i=e,r=Bs(i.style.fill)?Xs(i.style.fill,`geopoint-${t}-hatch`):void 0;/* */
346
+ return C$(R$.Fragment,{children:[r&&/* @__PURE__ */T$("defs",{children:r}),
347
+ /* @__PURE__ */T$("circle",{cx:i.x,cy:i.y,r:i.r,fill:r?`url(#geopoint-${t}-hatch)`:fl(i.style.fill),fillOpacity:i.style.fillOpacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i._decayOpacity??i.style.opacity??1})]},`point-${t}`)}case"line":{let i=e;if(i.path.length<2)return null;let r="M"+i.path.map(e=>`${e[0]},${e[1]}`).join("L");/* */
348
+ return T$("path",{d:r,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth??1.5,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity??1},`line-${t}`)}case"glyph":{let i=e;return gl(i,i.x,i.y,`geo-glyph-${i.pointId??t}`)}default:return null}}function D$(e){if(!e)return;let t=[];for(let i of e)if("point"===i.type)t.push(i);else if("glyph"===i.type){let e=i,r=Ve(e.glyph,e.size);t.push({pointId:e.pointId,x:e.x+r.centerDx,y:e.y+r.centerDy,r:r.radius})}return t}import{jsx as E$,jsxs as z$}from"react/jsx-runtime";function O$({bottomMargin:e,costLabel:t,layout:{cx:i,cy:r,maxCost:o,availableRadius:n,layout:a},ringStyle:s,ringValues:l,showNorth:c,showRingLabels:u,showRings:d}){let h="strip"===a,f={stroke:h?"var(--semiotic-border, #999)":"#999",strokeWidth:h?1:.8,strokeDasharray:h?"none":"4,3",labelColor:"var(--semiotic-text-secondary, #777)",labelSize:h?8:10,...s};/* */
349
+ return z$("g",h?{children:[
350
+ /* @__PURE__ */E$("line",{x1:i,y1:r,x2:i+n,y2:r,stroke:f.stroke,strokeWidth:f.strokeWidth,strokeLinecap:"round",opacity:.85}),
351
+ /* @__PURE__ */E$("line",{x1:i,y1:r-3.5,x2:i,y2:r+3.5,stroke:f.stroke,strokeWidth:f.strokeWidth,opacity:.9}),d&&l.map(a=>{let s=i+(o>0?a/o*n:0);/* */
352
+ return z$("g",{children:[
353
+ /* @__PURE__ */E$("line",{x1:s,y1:r-2.5,x2:s,y2:r+2.5,stroke:f.stroke,strokeWidth:.9,opacity:.65}),u&&/* @__PURE__ */z$("text",{x:s,y:r+Math.min(10,(e??2)+8),textAnchor:"middle",fontSize:f.labelSize,fill:f.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[a,t?` ${t}`:""]})]},a)})]}:{children:[l.map(e=>{let a=e/o*n;/* */
354
+ return z$("g",{children:[
355
+ /* @__PURE__ */E$("circle",{cx:i,cy:r,r:a,fill:"none",stroke:f.stroke,strokeWidth:f.strokeWidth,strokeDasharray:f.strokeDasharray,opacity:.5}),u&&/* @__PURE__ */z$("text",{x:i+a+3,y:r-2,fontSize:f.labelSize,fill:f.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[e,t?` ${t}`:""]})]},e)}),c&&/* @__PURE__ */z$("g",{transform:"translate(24, 24)",children:[
356
+ /* @__PURE__ */E$("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),
357
+ /* @__PURE__ */E$("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),
358
+ /* @__PURE__ */E$("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:"N"}),
359
+ /* @__PURE__ */E$("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),
360
+ /* @__PURE__ */E$("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),
361
+ /* @__PURE__ */E$("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]})]})}import{Fragment as j$,jsx as W$,jsxs as B$}from"react/jsx-runtime";function Y$(e,t){let i=xr(e.theme),r=e.size||[e.width||600,e.height||400],o=tt({top:10,right:10,bottom:10,left:10,...e.margin},e.title),n=Je(e.title),a=Array.isArray(e.areas)?pi(e.areas):e.areas,s=pi(e.points),l=pi(e.lines),c=e.showLegend?(()=>{let t="string"==typeof(r=e.colorBy)||"function"==typeof r?e.colorBy:void 0,i=s.length>0?s:Array.isArray(a)&&a.length>0?"string"==typeof t?a.map(e=>({...e.properties||{},...e})):a:[];var r;return ic(i,t)})():[];rd(o,{props:e,categories:c,theme:i,size:r,hasTitle:n});let u=od({props:e,categories:c,theme:i,size:r,margin:o,hasTitle:n}),d=Math.max(1,r[0]-o.left-o.right),h=Math.max(1,r[1]-o.top-o.bottom),f={projection:e.projection||"equalEarth",projectionExtent:e.projectionExtent,xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineIdAccessor:e.lineIdAccessor,lineType:e.lineType,flowStyle:e.flowStyle,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,colorScheme:e.colorScheme,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutSelection:e.layoutSelection,layoutMargin:o,onLayoutError:e.onLayoutError,themeCategorical:i.colors.categorical,themeSemantic:Y(i),themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging},p=new I$(f);if(a){if("string"==typeof a)throw new Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${a}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${a}')\` before calling renderGeoToStaticSVG.`);p.setAreas(a)}e.points&&p.setPoints(s),e.lines&&p.setLines(l),p.computeScene({width:d,height:h});let g,m=bd(e.backgroundGraphics,r,o,p.scales),y=bd(e.foregroundGraphics,r,o,p.scales),x=Ol({nodes:p.scene,renderMode:e.renderMode,fallback:(e,t)=>N$(e,t)}),b=x.map(e=>e.element),v=x.length>0&&e.cartogramChrome,w=p.cartogramLayout&&v?/* @__PURE__ */W$(O$,{layout:{...p.cartogramLayout,layout:p.cartogramLayout.layout??"radial"},ringValues:G$(p.cartogramLayout.maxCost,v.showRings),showRings:v.showRings??!0,showNorth:v.showNorth??!0,showRingLabels:v.showRingLabels??!0,costLabel:"string"==typeof v.costLabel?v.costLabel:void 0}):null,k=e.annotations?ku({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:p.scales?.projectedPoint?([e,t])=>p.scales.projectedPoint(e,t):void 0},layout:{width:d,height:h},theme:i,pointNodes:D$(p.scene),idPrefix:e._idPrefix,onRender:e=>{g=e}}):null;t&&(t.evidence=Fs({frameType:"geo",width:r[0],height:r[1],marks:x.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:g,legendItems:c.length>0?c.length:null!=e.legend?1:void 0,margin:o}));let A=/* @__PURE__ */B$(j$,{children:[m,b,k,w,y,p.customLayoutOverlays]});return jM.renderToStaticMarkup(ad(A,{width:r[0],height:r[1],className:"stream-geo-frame"+(e.className?` ${e.className}`:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:d,innerHeight:h,legend:u,idPrefix:e._idPrefix}))}function G$(e,t){if(!1===t||e<=0)return[];if(Array.isArray(t))return t.filter(t=>t>0&&t<=e);let i="number"==typeof t?t:Math.min(5,Math.max(2,Math.ceil(e/5))),r=e/i,o=[];for(let e=1;e<=i;e++)o.push(Math.round(r*e*10)/10);return o}import*as X$ from"react-dom/server";function V$(e,t={}){if("function"==typeof e)return e;let i=t.locale??"en-US",r=t.currency??"USD";if("currency"===e){let e=t.precision??2,o=new Intl.NumberFormat(i,{style:"currency",currency:r,maximumFractionDigits:e,minimumFractionDigits:e});return e=>o.format(e)}if("percent"===e){let e=t.precision??1,r=new Intl.NumberFormat(i,{style:"percent",maximumFractionDigits:e,minimumFractionDigits:0});return e=>r.format(e)}if("compact"===e){let e=t.precision??1,r=new Intl.NumberFormat(i,{notation:"compact",maximumFractionDigits:e,minimumFractionDigits:0});return e=>r.format(e)}if("duration"===e)return e=>q$(e);let o=t.precision??0,n=new Intl.NumberFormat(i,{notation:t.notation??"standard",maximumFractionDigits:o,minimumFractionDigits:0});return e=>n.format(e)}function q$(e){if(!Number.isFinite(e))return String(e);let t=e<0?"-":"",i=Math.abs(e),r=Math.round(i);if(r<1e3)return`${t}${r}ms`;let o=Math.round(i/10)/100;if(o<60)return`${t}${U$(o)}s`;let n=Math.round(i/1e3);if(n<3600)return`${t}${H$(Math.floor(n/60),"m",n%60,"s")}`;let a=Math.round(i/6e4);if(a<1440)return`${t}${H$(Math.floor(a/60),"h",a%60,"m")}`;let s=Math.round(i/36e5);return`${t}${H$(Math.floor(s/24),"d",s%24,"h")}`}function H$(e,t,i,r){return 0===i?`${e}${t}`:`${e}${t} ${i}${r}`}function U$(e){return String(Math.round(100*e)/100)}function Z$(e,t,i){return`${t??""}${e}${i??""}`}function Q$(e,t){return 0===e||t(Math.abs(e))===t(0)}function K$(e,t){return Number.isFinite(e)?Q$(e,t)?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}function J$(e,t){if(!t||0===t.length||!Number.isFinite(e))return null;let i=t.filter(e=>Number.isFinite(e.at)||e.at===-1/0).slice().sort((e,t)=>e.at-t.at),r=null;for(let t of i){if(!(e>=t.at))break;r=t}return r}import{jsx as e_,jsxs as t_}from"react/jsx-runtime";var i_={tile:{width:280,height:184,padding:16,labelSize:13,captionSize:11,valueSize:40,detailSize:13,align:"start",border:!0,showHeader:!0,showDetail:!0},presentation:{width:540,height:320,padding:32,labelSize:18,captionSize:14,valueSize:96,detailSize:18,align:"center",border:!0,showHeader:!0,showDetail:!0},inline:{width:240,height:64,padding:8,labelSize:0,captionSize:0,valueSize:28,detailSize:13,align:"start",border:!1,showHeader:!1,showDetail:!0},thumbnail:{width:96,height:56,padding:6,labelSize:0,captionSize:0,valueSize:22,detailSize:0,align:"center",border:!1,showHeader:!1,showDetail:!1}};function r_(e,t){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:t}function o_(e,t,i){return t||("success"===e?i.colors.success??"#2ca02c":"warning"===e?i.colors.warning??"#b26a00":"danger"===e?i.colors.danger??"#d62728":"info"===e?i.colors.info??i.colors.primary:i.colors.text)}function n_(e,t,i){let r=e.comparison&&"object"==typeof e.comparison?e.comparison:void 0,o=r&&"number"==typeof r.value&&Number.isFinite(r.value)?r.value:void 0,n=("number"==typeof e.delta&&Number.isFinite(e.delta)?e.delta:void 0)??(void 0===o?void 0:t-o);if(void 0!==n)return`${K$(n,i)}${r&&"string"==typeof r.label?` ${r.label}`:""}`}function a_(e,t,i){let r=e.target&&"object"==typeof e.target?e.target:void 0;if(!r||"number"!=typeof r.value||!Number.isFinite(r.value))return;let o="string"==typeof r.label?` ${r.label}`:"";return 0===r.value?`target ${i(r.value)}${o}`:`${new Intl.NumberFormat("string"==typeof e.locale?e.locale:"en-US",{style:"percent",maximumFractionDigits:0}).format(t/r.value)} of ${i(r.value)}${o}`}var s_={BigNumber:function(e,t){let i="presentation"===e.mode||"inline"===e.mode||"thumbnail"===e.mode?e.mode:"tile",r=i_[i],o=r_(e.width,r.width),n=r_(e.height,r.height),a="number"==typeof e.padding&&Number.isFinite(e.padding)?Math.max(0,e.padding):r.padding,s="center"===e.align||"end"===e.align||"start"===e.align?e.align:r.align,l="center"===s?"middle":"end"===s?"end":"start",c="center"===s?o/2:"end"===s?o-a:a,u=xr(e.theme),d="number"==typeof e.value&&Number.isFinite(e.value)?e.value:void 0,h=V$("string"==typeof e.format||"function"==typeof e.format?e.format:"number",{locale:"string"==typeof e.locale?e.locale:void 0,currency:"string"==typeof e.currency?e.currency:void 0,precision:"number"==typeof e.precision?e.precision:void 0}),f=void 0===d?"No value":Z$(h(d),"string"==typeof e.prefix?e.prefix:void 0,"string"==typeof e.suffix?e.suffix:void 0),p=void 0===d?void 0:J$(d,e.thresholds),g=p?.level??"neutral",m="string"==typeof e.color?e.color:o_(g,p?.color,u),y="string"==typeof e.label?e.label:void 0,x="string"==typeof e.caption?e.caption:void 0,b="string"==typeof e.unit?e.unit:void 0,v=[void 0===d?void 0:n_(e,d,h),void 0===d?void 0:a_(e,d,h),p?.label].filter(Boolean).join(" · "),w="string"==typeof e.description&&e.description||[y,f,b,v].filter(Boolean).join(", "),k="string"==typeof e.background?e.background:u.colors.surface??u.colors.background,A="string"==typeof e.borderColor?e.borderColor:u.colors.border,S=a+r.labelSize,M=S+r.captionSize+4,$=r.showHeader&&(y||x)?x?M+10:S+14:a,_="presentation"===i?n/2+.32*r.valueSize:"thumbnail"===i?n/2+.34*r.valueSize:Math.min(n-a-(v?26:4),$+r.valueSize),P=c+("start"===l?Math.max(r.valueSize,f.length*r.valueSize*.55):0),L=X$.renderToStaticMarkup(
362
+ /* @__PURE__ */t_("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:n,viewBox:`0 0 ${o} ${n}`,role:"img","aria-label":w,"data-semiotic-component":"BigNumber",children:[
363
+ /* @__PURE__ */e_("title",{children:y??f}),"string"==typeof e.description&&/* @__PURE__ */e_("desc",{children:e.description}),
364
+ /* @__PURE__ */e_("rect",{x:r.border?.5:0,y:r.border?.5:0,width:r.border?o-1:o,height:r.border?n-1:n,rx:r.border?8:0,fill:k,stroke:r.border?A:"none"}),r.showHeader&&y&&/* @__PURE__ */e_("text",{x:c,y:S,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.labelSize,fontWeight:600,fill:u.colors.text,children:y}),r.showHeader&&x&&/* @__PURE__ */e_("text",{x:c,y:M,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.captionSize,fill:u.colors.textSecondary,children:x}),
365
+ /* @__PURE__ */e_("text",{x:c,y:_,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.valueSize,fontWeight:600,fontVariant:"tabular-nums",fill:void 0===d?u.colors.textSecondary:m,"data-mark-type":"value",children:f}),b&&void 0!==d&&"start"===l&&/* @__PURE__ */e_("text",{x:P+6,y:_,textAnchor:"start",fontFamily:u.typography.fontFamily,fontSize:Math.max(11,Math.round(.32*r.valueSize)),fontWeight:500,fill:u.colors.textSecondary,children:b}),r.showDetail&&v&&/* @__PURE__ */e_("text",{x:c,y:Math.min(n-a,_+r.detailSize+10),textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.detailSize,fill:u.colors.textSecondary,children:v})]}));return t&&(t.evidence=Fs({frameType:"value",width:o,height:n,marks:void 0===d?[]:[{type:"value"}],title:y,description:w})),L}};function l_(e,t,i){return s_[e](t,i)}import*as c_ from"react-dom/server";import{jsx as u_,jsxs as d_}from"react/jsx-runtime";function h_(e,t,i){let{title:r,subtitle:o,theme:n,width:a=1200,height:s,layout:l={},background:c}=t,u=br(xr(n)),d=l.columns||2,h=l.gap??16,f=0;r&&(f+=30),o&&(f+=20),f>0&&(f+=10);let p=a-h,g=Math.floor((p-h*(d-1))/d),m=[],y=0,x=f+h,b=0;for(let t of e){let e=Math.min(t.colSpan||1,d),r=g*e+h*(e-1),o=t.props.height||300;y+e>d&&(x+=b+h,y=0,b=0);let a=h/2+y*(g+h),s={...t.props,width:r,height:o,theme:n,_idPrefix:`chart-${m.length}`},l=t.component?i.chart(t.component,s):t.frameType?i.frame(t.frameType,s):`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${o}"></svg>`,c=_t(l,{width:r,height:o}),u=Math.max(o,c.height);m.push({x:a,y:x,width:r,height:u,svg:l,svgDimensions:c}),b=Math.max(b,u),y+=e}let v=s||x+b+h,w=m.map((e,t)=>/* @__PURE__ */u_("g",{transform:`translate(${e.x},${e.y})`,children:/* @__PURE__ */u_("foreignObject",{width:e.width,height:e.height,children:/* @__PURE__ */u_("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:Pt(e.svg,e.svgDimensions)}})})},`dashboard-chart-${t}`));return c_.renderToStaticMarkup(
366
+ /* @__PURE__ */d_("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:v,role:"img","aria-label":r||"Dashboard",style:{fontFamily:u.fontFamily},children:[r&&/* @__PURE__ */u_("title",{children:r}),c&&/* @__PURE__ */u_("rect",{x:0,y:0,width:a,height:v,fill:c}),r&&/* @__PURE__ */u_("text",{x:a/2,y:24,textAnchor:"middle",fontSize:u.titleFontSize+4,fontWeight:u.titleFontWeight,fill:u.text,fontFamily:u.titleFontFamily,children:r}),o&&/* @__PURE__ */u_("text",{x:a/2,y:r?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:o}),w]}))}import{Fragment as f_,jsx as p_}from"react/jsx-runtime";function g_(e,t){switch(e){case"xy":return Rd(t);case"ordinal":return OM(t);case"network":return iw(t);case"geo":return Y$(t);case"physics":return Nw(t);default:throw new Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function m_(e){return Rd(e)}function y_(e){return OM(e)}function x_(e){return iw(e)}function b_(e){return Y$(e)}var v_=/* @__PURE__ */new Set(["d","transform","gradientTransform","patternTransform","points","viewBox","x","y","x1","x2","y1","y2","cx","cy","r","rx","ry","width","height","dx","dy","offset","startOffset","stroke-width","stroke-opacity","stroke-dasharray","stroke-dashoffset","fill-opacity","opacity","font-size","letter-spacing"]),w_=/-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/gi;function k_(e){if(Number.isFinite(e))return Math.max(0,Math.min(8,Math.floor(e)))}function A_(e,t){let i=Number(e);if(!Number.isFinite(i))return e;let r=10**t,o=Math.round((i+Number.EPSILON)*r)/r;return Object.is(o,-0)?"0":String(o)}function S_(e,t,i=0){let r,o=new RegExp(w_.source,w_.flags),n="",a=0,s=!1,l=0;for(;r=o.exec(e);){let o=e.slice(a,r.index);s&&0===o.length?n+=" ":n+=o,n+=A_(r[0],l++<i?Math.max(8,t):t),a=r.index+r[0].length,s=!0}return n+e.slice(a)}function M_(e,t){let i=k_(t);return void 0===i?e:Mt(e,(e,t)=>{if(v_.has(e)&&!/\b(?:var|calc|url)\(/i.test(t))return"transform"===e||"gradientTransform"===e||"patternTransform"===e?t.replace(/(matrix|translate|scale|rotate|skewX|skewY)\(([^)]*)\)/g,(e,t,r)=>`${t}(${S_(r,i,"matrix"===t?4:"scale"===t?2:"translate"===t?0:1)})`):S_(t,i)})}var $_=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","hoverRadius","scalePadding","sizeRange","innerRadius","centerContent","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","svgAnnotationRules","barColors","legend","legendLayout","autoPlaceAnnotations","perspective"],__=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];function P_(e,t){let i={};for(let r of t)void 0!==e[r]&&(i[r]=e[r]);return i}function L_(e,t,i){return R_(e,t,i).svg}function I_(e,t,i){let r={},{svg:o,frameType:n}=R_(e,t,i,r),a=r.evidence??Fs({frameType:n,width:"number"==typeof t.width?t.width:600,height:"number"==typeof t.height?t.height:400,marks:[],title:"string"==typeof t.title?t.title:void 0,description:"string"==typeof t.description?t.description:void 0,annotations:t.annotations,extraWarnings:["NO_EVIDENCE"]});if(a.component=e,a.sceneHashVersion=2,a.sceneHash=Lt(o,a),ai(a,e,t),i?.artifactContract){let r=c(i.artifactContract,{excludeEvidenceSamples:!0});r.contract&&(a.artifactContract=r.contract),a.artifactTransfer=r.transfer,a.artifactBinding="0.1"===r.contract?.contractVersion&&"invalid"!==r.transfer.status?u(r.contract,t,e):{status:"unknown",mismatchPaths:[],unknownPaths:["artifactContract"]}}return{svg:o,evidence:a}}function R_(e,t,i,r){if(Object.prototype.hasOwnProperty.call(s_,e))return{svg:M_(l_(e,t,r),i?.precision),frameType:"value"};if(!Object.prototype.hasOwnProperty.call(SS,e))throw new Error(`Unknown chart component: "${e}". Run \`npx semiotic-ai --list\` for supported chart types.`);let o,n=SS[e],a=jt(n.layout?.mode??(!qt(e)&&Ot(t.mode)?t.mode:void 0),{...n.layout?.modeDefaults,...P_(t,__),...qt(e)&&{responsiveRules:void 0}},Ht(e)??n.layout?.primarySize),{data:s,theme:l,background:c,className:u,annotations:d,margin:h,colorScheme:f,colorBy:p,legendPosition:g,...m}=t,{width:y,height:x}=a,b=[y,x],v=m.frameProps||{},w=n.layout?.margin,k="function"==typeof w?w(t,a):w??a.marginDefaults,A="xy"===n.frameType?bt(k,m.axes??v.axes,!!a.title):k,S=void 0!==h?h:v.margin,M=si(S),$="number"==typeof S?{top:S,right:S,bottom:S,left:S}:{...A,...M},_=P_(m,$_),P=e=>v[e]??a[e],L={...v,..._,theme:l,title:a.title,description:a.description,showAxes:P("showAxes"),showLegend:P("showLegend"),showLabels:P("showLabels"),showGrid:P("showGrid"),xLabel:P("xLabel"),yLabel:P("yLabel"),categoryLabel:P("categoryLabel"),valueLabel:P("valueLabel"),background:c??v.background,className:u,annotations:d,size:b,margin:$,__resolvedMode:a.mode,__compactMode:a.compactMode,__explicitMarginSides:"number"==typeof S?["top","right","bottom","left"]:Object.keys(M??{}),__autoLegendMargin:!0,...void 0!==f&&{colorScheme:f},...void 0!==g&&{legendPosition:g},_idPrefix:m._idPrefix},I=n.buildProps(s,p,f,L,m);if(n.renderStatic)o=n.renderStatic(I,r);else switch(n.frameType){case"xy":o=Rd(I,r);break;case"ordinal":o=OM(I,r);break;case"network":o=iw(I,r);break;case"geo":o=Y$(I,r);break;case"physics":o=Nw(I,r)}let R=n.renderOverlay?.(I,{theme:xr(l)});if(null!=R){let e=li.renderToStaticMarkup(/* @__PURE__ */p_(f_,{children:R})),t=o.lastIndexOf("</svg>");o=t<0?`${o}${e}`:`${o.slice(0,t)}${e}${o.slice(t)}`}return{svg:M_(o,i?.precision),frameType:n.resolveFrameType?.(I)??n.frameType}}function T_(e,t={}){return h_(e,t,{chart:L_,frame:g_})}import*as C_ from"react-dom/server";import{Fragment as N_,jsx as F_,jsxs as D_}from"react/jsx-runtime";function E_(e,t,i,r={}){let{stepSize:o,windowSize:n,frameCount:a,xExtent:s,yExtent:l,transitionFrames:c=4,fps:u=12,easing:d="ease-out",decay:h}=r,f=i.width||600,p=i.height||400,g=xr(i.theme),m={...i,...s&&{xExtent:s},...l&&{yExtent:l}};if(!t||0===t.length)return[];let y=a||Math.min(60,Math.max(10,t.length)),x=o||Math.max(1,Math.ceil(t.length/y)),b=[];for(let e=x;e<=t.length;e+=x)b.push(e);b[b.length-1]!==t.length&&b.push(t.length);let v=/* @__PURE__ */new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),w=tt({top:20,right:20,bottom:30,left:40,...i.margin},i.title),k=Math.max(1,f-w.left-w.right),A=Math.max(1,p-w.top-w.bottom),S=[];if(v)for(let r=0;r<b.length;r++){let o=b[r],a=n?Math.max(0,o-n):0,s=t.slice(a,o),l={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||g.colors.categorical,...h&&{decay:h}},c=new hM(l);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&S.push(V_(c.scene,f,p,g,m,S.length))}else for(let r=0;r<b.length;r++){let o=b[r],a=n?Math.max(0,o-n):0,y=t.slice(a,o),x={chartType:e,windowSize:y.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:s,yExtent:l,colorScheme:i.colorScheme||g.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange,...h&&{decay:h},...c>0&&{transition:{duration:c*(1e3/u),easing:d}}},v=new ds(x);if(v.ingest({inserts:y,bounded:!0}),v.computeScene({width:k,height:A}),0===v.scene.length)continue;let w=v.scales?{y:v.scales.y}:void 0;if(S.push(X_(v.scene,f,p,g,m,w,S.length)),c>0&&r>0&&v.activeTransition){let e=c*(1e3/u);for(let t=1;t<=c;t++){let i=t/c,r=v.activeTransition.startTime+i*e;v.advanceTransition(r),S.push(X_(v.scene,f,p,g,m,w,S.length))}}}return S}function z_(e,t,i={}){return t.map(t=>{try{return L_(e,{...i,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||t.width||600}" height="${i.height||t.height||400}"></svg>`}})}function O_(e,t,i,r){let o=$u(`${e}-${t}`),n="string"==typeof i&&i.length>0?i:void 0,a="string"==typeof r&&r.length>0?r:void 0,s=n?o.titleId:void 0,l=a?o.descId:void 0;return{titleText:n,descText:a,titleId:s,descId:l,labelledBy:[s,l].filter(Boolean).join(" ")||void 0}}function j_(e,t){return"string"==typeof e.idPrefix&&e.idPrefix.length>0?e.idPrefix:Ku(e)||t}function W_(e,t,i){let r=t.size??[t.width??600,t.height??400],o=xr(t.theme),n=br(o),a=t.background||o.colors.background,s=t.idPrefix??"physics-gif",l=O_(s,i,t.title,t.description),{titleId:c,descId:u,labelledBy:d}=l,h=fw(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),f=/* @__PURE__ */D_("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,role:"img","aria-labelledby":d,style:{fontFamily:n.fontFamily},children:[t.title&&/* @__PURE__ */F_("title",{id:c,children:t.title}),t.description&&/* @__PURE__ */F_("desc",{id:u,children:t.description}),a&&"transparent"!==a?/* @__PURE__ */F_("rect",{x:0,y:0,width:r[0],height:r[1],fill:a}):null,
367
+ /* @__PURE__ */F_("g",{id:`${s}-frame-${i}`,children:h.map((e,t)=>Rl(e,t,`${s}-${i}`))})]});return C_.renderToStaticMarkup(f)}function B_(e,t={}){let{fps:i=12,frameCount:r,durationSeconds:o=2,includeInitialFrame:n=!0,stepDt:a,stepsPerFrame:s,background:l}=t,c=Math.max(.001,a??e.config?.fixedDt??1/120),u=s??Math.max(1,Math.round(1/Math.max(1,i)/c)),d=r??Math.max(1,Math.ceil(o*Math.max(1,i))),h=l?{...e,background:l}:e,f=new re(e.config);e.initialSpawns?.length&&f.enqueue(e.initialSpawns,e.initialSpawnPacing);let p=[];for(n&&(f.tick(0),p.push(W_(f,h,0)));p.length<d;){for(let e=0;e<u;e+=1)f.tick(c);p.push(W_(f,h,p.length))}return p}function Y_(e,t){let i=e.background||t.colors.background;return i&&"transparent"!==i?i:null}function G_(e,t,i,r,o,n){if(!e||0===e.length)return null;let a=br(r),s=[];for(let r=0;r<e.length;r++){let l=e[r];if("y-threshold"===l.type&&null!=l.value){let e=null;if(n)e=n(l.value);else if(o){let[t,r]=o,n=r-t;if(0===n)continue;e=i-(l.value-t)/n*i}if(null==e)continue;let c=l.color||a.primary,u=l.strokeDasharray||"6,4",d=l.strokeWidth??1.5,h=l.labelPosition||"right";s.push(
368
+ /* @__PURE__ */D_("g",{children:[
369
+ /* @__PURE__ */F_("line",{x1:0,y1:e,x2:t,y2:e,stroke:c,strokeWidth:d,strokeDasharray:u}),l.label&&/* @__PURE__ */F_("text",{x:"left"===h?4:"center"===h?t/2:t-4,y:e<20?Math.min(i-4,e+16):e-5,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:a.tickSize,fill:l.labelColor??c,fontFamily:a.fontFamily,children:l.label})]},`ann-${r}`))}}return s.length>0?/* @__PURE__ */F_(N_,{children:s}):null}function X_(e,t,i,r,o,n,a=0){let s=br(r),l=tt({top:20,right:20,bottom:30,left:40,...o.margin},o.title),c=Math.max(1,t-l.left-l.right),u=Math.max(1,i-l.top-l.bottom),d=Y_(o,r),h=o.renderMode,f=e.map((e,t)=>zl({node:e,index:t,renderMode:h,fallback:()=>Rl(e,t)})).filter(Boolean),p=G_(o.annotations,c,u,r,o.yExtent,n?.y),{titleText:g,descText:m,titleId:y,descId:x,labelledBy:b}=O_(j_(o,"xy-gif"),a,o.title,o.description),v=/* @__PURE__ */D_("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":b,style:{fontFamily:s.fontFamily},children:[g&&/* @__PURE__ */F_("title",{id:y,children:g}),m&&/* @__PURE__ */F_("desc",{id:x,children:m}),d&&/* @__PURE__ */F_("rect",{x:0,y:0,width:t,height:i,fill:d}),
370
+ /* @__PURE__ */D_("g",{transform:`translate(${l.left},${l.top})`,children:[p,f]}),g&&/* @__PURE__ */F_("text",{x:t/2,y:22,textAnchor:"middle",fontSize:s.titleFontSize,fontWeight:s.titleFontWeight,fill:s.text,fontFamily:s.titleFontFamily,children:g})]});return C_.renderToStaticMarkup(v)}function V_(e,t,i,r,o,n=0){let a=br(r),s=tt({top:20,right:20,bottom:30,left:40,...o.margin},o.title),l="radial"===o.projection,c=l?s.left+(t-s.left-s.right)/2:s.left,u=l?s.top+(i-s.top-s.bottom)/2:s.top,d=Y_(o,r),h=TM({nodes:e,renderMode:o.renderMode,idPrefix:o.idPrefix}).map(e=>e.element),{titleText:f,descText:p,titleId:g,descId:m,labelledBy:y}=O_(j_(o,"ordinal-gif"),n,o.title,o.description),x=/* @__PURE__ */D_("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":y,style:{fontFamily:a.fontFamily},children:[f&&/* @__PURE__ */F_("title",{id:g,children:f}),p&&/* @__PURE__ */F_("desc",{id:m,children:p}),d&&/* @__PURE__ */F_("rect",{x:0,y:0,width:t,height:i,fill:d}),
371
+ /* @__PURE__ */F_("g",{transform:`translate(${c},${u})`,children:h}),f&&/* @__PURE__ */F_("text",{x:t/2,y:22,textAnchor:"middle",fontSize:a.titleFontSize,fontWeight:a.titleFontWeight,fill:a.text,fontFamily:a.titleFontFamily,children:f})]});return C_.renderToStaticMarkup(x)}Is(),zn=C;export{E_ as generateFrameSVGs,z_ as generateFrameSequence,B_ as generatePhysicsFrameSVGs,L_ as renderChart,I_ as renderChartWithEvidence,T_ as renderDashboard,b_ as renderGeoToStaticSVG,x_ as renderNetworkToStaticSVG,y_ as renderOrdinalToStaticSVG,g_ as renderToStaticSVG,m_ as renderXYToStaticSVG,xr as resolveTheme,M_ as serializeSvgPrecision,br as themeStyles};