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,30 +0,0 @@
1
- import{c as e}from"./c-5CI6XDJG.min.js";import{a as t}from"./c-RHDOOQ4X.min.js";function i(e){let{desired:t,minGaps:i,weights:n}=e,s=t.length;if(0===s)return[];if(i.length!==Math.max(0,s-1))throw new Error("placeWithMinGap: minGaps must have desired.length - 1 entries");let r=new Array(s).fill(0);for(let e=1;e<s;e++)r[e]=r[e-1]+Math.max(0,Number.isFinite(i[e-1])?i[e-1]:0);let o=[];for(let e=0;e<s;e++){let i=Math.max(Number.EPSILON,Number.isFinite(n?.[e])?n[e]:1),s=(Number.isFinite(t[e])?t[e]:0)-r[e];for(o.push({start:e,end:e,weight:i,mean:s});o.length>1;){let e=o[o.length-1],t=o[o.length-2];if(t.mean<=e.mean)break;let i=t.weight+e.weight;o.splice(o.length-2,2,{start:t.start,end:e.end,weight:i,mean:(t.mean*t.weight+e.mean*e.weight)/i})}}let a=Number.isFinite(e.min)?e.min:-1/0,l=Number.isFinite(e.max)?e.max-r[s-1]:1/0,d=l<a?a:l,h=new Array(s);for(let e of o){let t=Math.max(a,Math.min(d,e.mean));for(let i=e.start;i<=e.end;i++)h[i]=t+r[i]}return h}function n(e,t,i){return Math.max(t,Math.min(i,e))}var s=/* @__PURE__ */new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function r(e){return"string"==typeof e?.type?e.type:""}function o(e){return!!e&&"object"==typeof e&&s.has(r(e))}var a=2e4;function l(e){return o(e)}function d(e){return"primary"===e?.emphasis||!0===e?.defensive}function h(e,t,i={}){if("number"==typeof i.maxAnnotations&&Number.isFinite(i.maxAnnotations))return Math.max(0,Math.floor(i.maxAnnotations));if(!(e>0&&t>0))return 1/0;let n=i.areaPerAnnotation&&i.areaPerAnnotation>0?i.areaPerAnnotation:2e4;return Math.max(1,Math.round(e*t/n))}function u(e){let t,i=e?.emphasis;t="primary"===i?100:"secondary"===i?10:50;let s=e?.provenance?.confidence;switch("number"==typeof s&&Number.isFinite(s)&&(t+=15*n(s,0,1)),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}function c(e){let{annotations:t,width:i,height:n}=e,s=Math.max(0,e.minVisible??1),r=h(i,n,e),o=t.map((e,t)=>({annotation:e,index:t,note:l(e)})),a=o.filter(e=>e.note);if(0===a.length||a.length<=r)return{visible:t.slice(),deferred:[],budget:r};let c=a.filter(e=>d(e.annotation)),p=a.filter(e=>!d(e.annotation)).sort((e,t)=>u(t.annotation)-u(e.annotation)||e.index-t.index),f=Math.max(0,r-c.length),m=Math.max(0,s-c.length),y=Math.min(p.length,Math.max(f,m)),x=/* @__PURE__ */new Set([...c.map(e=>e.index),...p.slice(0,y).map(e=>e.index)]),g=[],v=[];for(let{annotation:e,index:t,note:i}of o)!i||x.has(t)?g.push(e):v.push(e);return{visible:g,deferred:v,budget:r}}function p(e,t){let i=t.scales?.x??t.scales?.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function f(e,t){let i=t.scales?.y??t.scales?.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function m(e){let t=e.data;if(!t||0===t.length)return null;let i=t[t.length-1],n=e.scales?.x??e.scales?.time,s=e.scales?.y??e.scales?.value;if(!n||!s)return null;let r=e.xAccessor||"x",o=e.yAccessor||"y",a=i[r],l=i[o];return null==a||null==l?null:{x:n(a),y:s(l)}}function y(e){return null==e?null:String(e)}function x(e){return y(e.provenance?.stableId??e.stableId)}function g(e){return y(e.stableId??e.id??e.provenance?.stableId)}function v(e,t,i){return t.stickyPositionCache?.set(e,i),i}function b(e,t,i){let n=x(e);if(!n)return null;let s=i.pointNodes?.find(e=>y(e.pointId)===n);if(s)return v(t,i,{x:s.x,y:s.y});let r=i.data?.find(e=>g(e)===n);if(!r)return null;let o=p(r,i),a=f(r,i);return null==o||null==a?null:v(t,i,{x:o,y:a})}function w(e,t,i){let n=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===n){if(null!=e.pointId&&i.pointNodes&&i.pointNodes.length>0)for(let n=i.pointNodes.length-1;n>=0;n--){let s=i.pointNodes[n];if(s.pointId===e.pointId)return v(t,i,{x:s.x,y:s.y})}let n=m(i);return n?v(t,i,n):null}if("semantic"===n){let n=b(e,t,i);if(n)return n}let s=null,r=null;if(null!=e.pointId&&i.pointNodes){let t=i.pointNodes.find(t=>t.pointId===e.pointId);t&&(s=t.x,r=t.y)}if((null==s||null==r)&&(s=p(e,i),r=f(e,i)),null!=s&&null!=r)return v(t,i,{x:s,y:r});if("sticky"===n){let e=i.stickyPositionCache?.get(t);if(e)return e}return null}function S(e,t,i,n=50){let s=i.width||0,r=i.height||0;return e>=-n&&e<=s+n&&t>=-n&&t<=r+n}function M(e){return{label:e.label,title:e.title,wrap:e.wrap||120,noWrap:"function"==typeof e._noteLayout?e.noWrap:void 0,_noteLayout:e._noteLayout}}function I(e){return"function"==typeof e._noteLayout?e._noteLayout(e):void 0}function k(e,t,i){if(!e)return[];let n=Math.max(1,Math.floor(t/i)),s=[],r="";for(let t of e.split(/\s+/))t&&(r&&r.length+1+t.length>n?(s.push(r),r=t):r=r?`${r} ${t}`:t);return r&&s.push(r),s}var $=32,B=6,O=4,A=8,C=72;function T(e){return"number"==typeof e.dx||"number"==typeof e.dy}function N(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}function P(e){let t=e?.familiarity;if(!t)return 3;let i=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===i.length?3:i.reduce((e,t)=>e+t,0)/i.length}function F(e){if(!e)return 1;let t=P(e);return t<=2?1.5:t>=4?.6:1}var q={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function D(e){let t=e?.provenance;if(!t||"object"!=typeof t)return e;let i="string"==typeof t.source?Object.prototype.hasOwnProperty.call(q,t.source)?q[t.source]:t.source:null,n="number"==typeof t.confidence&&Number.isFinite(t.confidence)?`${Math.round(100*Math.max(0,Math.min(1,t.confidence)))}%`:null;if(!i&&!n||null!=e.label&&"string"!=typeof e.label)return e;let s=[i,n].filter(Boolean).join(" · "),r="string"==typeof e.label?e.label:"";return r.includes(`(${s})`)?e:{...e,label:r?`${r} (${s})`:`(${s})`}}function Y(e,t){let i=!1,n=e.map(e=>L(e)&&"blended"!==e.cohesion&&"layer"!==e.cohesion?(i=!0,{...e,cohesion:t}):e);return i?n:e}function E(e){if(!L(e))return e;let t="string"==typeof e.mobileText?e.mobileText:void 0,i="string"==typeof e.shortText?e.shortText:void 0,n=t??i;return!n||"string"!=typeof e.label&&null!=e.label?e:{...e,label:n}}function j(e){if("text"!==e.type||"string"!=typeof e.color)return e;let t="number"==typeof e.dx?e.dx:0,i="number"==typeof e.dy?e.dy:0;return Math.hypot(t,i)<8?e:{...e,_redundantConnector:!0}}function L(e){return o(e)}function R(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};let t=I(e);if(t)return{width:Math.max(24,t.width+10),height:Math.max(18,t.height+6)};let i="number"==typeof e.wrap?e.wrap:120,n=[...k("string"==typeof e.title?e.title:void 0,i,7),...k("string"==typeof e.label?e.label:void 0,i,7)],s=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(i,7*s)+10),height:Math.max(18,16*n.length+6)}}function X(e,t,i,n,s){let r=e+i,o=t+n;return Math.abs(i)>Math.abs(n)?{x:i>=0?r+4:r-s.width-4,y:n<0?o-s.height:o,width:s.width,height:s.height}:{x:i>=0?r:r-s.width,y:n<0?o-s.height-4:o+4,width:s.width,height:s.height}}function W(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function z(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function G(e,t,i,n){let s=Math.max(0,n-e.x),r=Math.max(0,n-e.y),o=Math.max(0,e.x+e.width-(t-n)),a=Math.max(0,e.y+e.height-(i-n));return(s+o)*e.height+(r+a)*e.width}function V(e){let t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}function _(e,t){return(e.pointNodes||[]).map(e=>{let i=Math.max(1,e.r||1)+t;return{x:e.x-i,y:e.y-i,width:2*i,height:2*i}})}function H(e,t,i,n,s,r,o,a){let l=W(e,o),d=.4*Math.hypot(t.dx,t.dy)+80*G(l,s,r,a);for(let e of i)d+=12*z(l,e);for(let e of n)d+=4*z(l,e);return d}function U(e,t,i){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};let n=e.pointId??e.nodeId;if(null!=n&&i.pointNodes){let e=i.pointNodes.find(e=>e.pointId===n);if(e)return{x:e.x,y:e.y}}let s=e.coordinates,r=i.scales?.geoProjection;if(Array.isArray(s)&&s.length>=2&&r){let e=s[0],t=s[1];if("number"==typeof e&&"number"==typeof t){let i=r([e,t]);if(i&&"number"==typeof i[0]&&"number"==typeof i[1])return{x:i[0],y:i[1]}}}return i.scales||"number"!=typeof e.x||"number"!=typeof e.y?w(e,t,i):{x:e.x,y:e.y}}function K(e){let{annotations:t,context:i,defaultOffset:n=$,notePadding:s=B,markPadding:r=O,edgePadding:o=A,preserveManualOffsets:a=!0,routeLongConnectors:l=!0,connectorThreshold:d=C,density:u,progressiveDisclosure:p=!1,redundantCues:f=!1,responsive:m,mobile:y,cohesion:x,audience:g}=e,v=i.width||0,b=i.height||0,w="object"==typeof y?y:{},S=w.breakpoint??480,M=!!y&&v<=S,I=M&&!1!==w.preferShortText?t.map(E):t,k=M&&!u?{maxAnnotations:w.maxAnnotations??("callout-list"===w.strategy?1:2),minVisible:w.minVisible??1}:u,P=p||M&&(!1!==w.progressiveDisclosure||"callout-list"===w.strategy),q=M&&!m?w.responsive??{minWidth:S}:m,z=M&&!x?w.cohesion:x;if(0===I.length||v<=0||b<=0)return I.slice();let G=[],K=_(i,r),Q=!1,Z=I.map((e,t)=>{if(!L(e))return e;let r=U(e,t,i);if(!r)return e;let h=R(!0===e.defensive?D(e):e);if(a&&T(e)){let t=N(e),i="number"==typeof e.dx?e.dx:t.dx,n="number"==typeof e.dy?e.dy:t.dy;return G.push(W(X(r.x,r.y,i,n,h),s)),e}let u=null,c=1/0;for(let e of V(n)){let t=H(X(r.x,r.y,e.dx,e.dy,h),e,G,K,v,b,s,o);t<c&&(u=e,c=t)}if(!u)return e;let p=W(X(r.x,r.y,u.dx,u.dy,h),s);G.push(p);let f=Math.hypot(u.dx,u.dy),m=l&&f>=d&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return Q=!0,{...e,dx:u.dx,dy:u.dy,...m?{connector:m}:{}}}),J=Q?Z:I.slice(),ee=J;if(f){let e=!1,t=J.map(t=>{let i=j(t);return i!==t&&(e=!0),i});ee=e?t:J}{let e=!1,t=ee.map(t=>{if(!0!==t?.defensive)return t;let i=D(t);return i!==t&&(e=!0),i});ee=e?t:ee}let te,ie=/* @__PURE__ */new Set;if(k){let e="object"==typeof k?k:{},t=F(g),i=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??h(v,b,e))*t))},{deferred:n}=c({annotations:ee,width:v,height:b,...i});for(let e of n)ie.add(e)}if(q){let e="object"==typeof q&&"number"==typeof q.minWidth?q.minWidth:480;if(v<=e)for(let e of ee)L(e)&&"secondary"===e.emphasis&&ie.add(e)}if(ie.size>0)for(let e of ee)!0===e?.defensive&&ie.delete(e);return te=0===ie.size?ee:P?ee.map(e=>ie.has(e)?{...e,_annotationDeferred:!0}:e):ee.filter(e=>!ie.has(e)),z?Y(te,z):te}import{interpolateRgb as Q}from"d3-interpolate";var Z=864e5,J=e=>{let t=e.config,{plot:i}=e.dimensions;if(i.width<=0||i.height<=0)return{nodes:[]};let n=e=>{let i="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];return i instanceof Date?i:new Date(i)},s=e=>{let i="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return Number(i)},r=/* @__PURE__ */new Map,o=null;for(let t of e.data){let e=n(t);if(!isFinite(e.getTime()))continue;null==o&&(o=e.getUTCFullYear());let i=ee(e),a=s(t);r.set(i,(r.get(i)??0)+(Number.isFinite(a)?a:0))}let a=t.year??o??/* @__PURE__ */(new Date).getUTCFullYear(),l=1/0,d=-1/0;for(let e of r.values())e<l&&(l=e),e>d&&(d=e);l===1/0&&(l=0,d=0);let[h,u]=t.colorRamp??[e.theme.semantic.surface??"#ebedf0",e.theme.semantic.primary??"#216e39"],c=e=>{if(d===l)return h;let t=(e-l)/(d-l);return Q(h,u)(t)},p=t.gutter??2,f=t.labelInset??0,m=i.width-f,y=i.height,x=Math.min((m-53*p)/54,(y-6*p)/7);if(x<=0)return{nodes:[]};let g=new Date(Date.UTC(a,0,1)),v=g.getUTCDay(),b=new Date(g.getTime()-v*Z),w=[];for(let e=0;e<54;e++)for(let t=0;t<7;t++){let n=new Date(b.getTime()+(7*e+t)*Z);if(n.getUTCFullYear()!==a)continue;let s=ee(n),o=r.get(s),l=null==o?h:c(o);w.push({type:"rect",x:i.x+f+e*(x+p),y:i.y+t*(x+p),w:x,h:x,style:{fill:l,stroke:"none"},datum:{date:n,value:o??0}})}return{nodes:w}};function ee(e){return`${e.getUTCFullYear()}-${te(e.getUTCMonth()+1)}-${te(e.getUTCDate())}`}function te(e){return e<10?`0${e}`:String(e)}import{interpolateLab as ie}from"d3-interpolate";function ne(e){return"function"==typeof e?e:t=>t[e]}function se(e,t,i){let n=e?.data,s=n?n[t]:void 0;if(null!=s)return s;let r=e?.[t];return r??i}function re(e){if(null==e)return null;let t=e;return t.data??t.datum??e}function oe(e,t){let i=/* @__PURE__ */new Map;for(let n of e){let e=t(n),s=i.get(e);s?s.push(n):i.set(e,[n])}return i}function ae(e){let t=/* @__PURE__ */Object.create(null);return e((e,i)=>{t[e]=i}),t}function le(e,t){if(!t)return!0;let i=Array.isArray(t)?t:[t],n=e;for(let e of i)if(null!=e.value&&String(n[e.field])!==String(e.value))return!1;return!0}function de(e,t={}){let i=t.baseOpacity??1;return t.highlight||t.predicate?!le(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,i+(t.brighten??0)):i}function he(e){return e.join("|")}var ue=class{constructor(e=12){this.maxSize=e,this.store=/* @__PURE__ */new Map}get(e){return this.store.get(e)}set(e,t){this.store.size>=this.maxSize&&this.store.clear(),this.store.set(e,t)}getOrCompute(e,t){let i=this.store.get(e);if(void 0!==i)return i;let n=t();return this.set(e,n),n}clear(){this.store.clear()}get size(){return this.store.size}};function ce(e,t=.72){let i=ie(e,"#ffffff"),n=ie(e,"#000000"),s=ie(e,e)(0);return e=>{let r=e<0?0:e>1?1:e;return.5===r?s:r<.5?i(2*(.5-r)*t):n(2*(r-.5)*t)}}function pe(e,t,i=.72){return ce(e,i)(t)}function fe(e){return ae(t=>{for(let[i,n]of Object.entries(e))t(i,n)})}function me(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"item"}function ye(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function xe(e){if(0===e.length)return 0;let t=0;for(let i of e)t+=i;return t/e.length}function ge(e,t){let i=n(t,0,1),s=e.trim().replace(/^#/,""),r=3===s.length?s.split("").map(e=>e+e).join(""):s;return/^[0-9a-fA-F]{6}$/.test(r)?`rgba(${parseInt(r.slice(0,2),16)}, ${parseInt(r.slice(2,4),16)}, ${parseInt(r.slice(4,6),16)}, ${i})`:e}import{jsx as ve,jsxs as be}from"react/jsx-runtime";function we(e){/* @__PURE__ */
2
- return ve("rect",{className:e.className,x:e.x,y:e.y,width:Math.max(0,e.width),height:Math.max(0,e.height),rx:e.radius??10,ry:e.radius??10,fill:e.fill??"none",stroke:e.stroke,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray,opacity:e.opacity??.6,style:{pointerEvents:"none"}},e.keyId)}function Se(e,t=0){let i=1/0,n=1/0,s=-1/0,r=-1/0;for(let t of e){let e=t.r??0;t.x-e<i&&(i=t.x-e),t.x+e>s&&(s=t.x+e),t.y-e<n&&(n=t.y-e),t.y+e>r&&(r=t.y+e)}return Number.isFinite(i)?{x:i-t,y:n-t,width:s-i+2*t,height:r-n+2*t}:null}function Me(e,t=0){if(!e.length)return null;let i="number"==typeof t?t:t.x??0,n="number"==typeof t?t:t.y??0,s=1/0,r=1/0,o=-1/0,a=-1/0;for(let t of e){if(!(Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.width)&&Number.isFinite(t.height)))continue;let e=Math.max(0,t.width),i=Math.max(0,t.height);t.x<s&&(s=t.x),t.y<r&&(r=t.y),t.x+e>o&&(o=t.x+e),t.y+i>a&&(a=t.y+i)}return Number.isFinite(s)?{x:s-i,y:r-n,width:o-s+2*i,height:a-r+2*n}:null}function Ie(e){let t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:/* @__PURE__ */ve("text",{className:e.className,x:e.x,y:e.y,textAnchor:e.anchor??"middle",dominantBaseline:e.baseline??"middle",fontSize:t,fontWeight:e.fontWeight,fill:e.color,style:{pointerEvents:"none"},children:e.text},e.keyId)}function ke(e){let t=e.spacing??8,i=e.color??"currentColor";return{def:/* @__PURE__ */ve("pattern",{id:e.id,width:t,height:t,patternUnits:"userSpaceOnUse",patternTransform:`rotate(${e.angle??45})`,children:/* @__PURE__ */ve("line",{x1:0,y1:0,x2:0,y2:t,stroke:i,strokeWidth:e.strokeWidth??1,opacity:e.opacity??.5})},e.id),fill:`url(#${e.id})`}}function $e(e){let t=e.orient??"bottom",i="bottom"===t||"top"===t,n=e.offset??0,s=e.tickLength??6,r=e.gridLength??0,o=e.labelGap??4,a=e.fontSize??11,l=e.color??"var(--semiotic-text-secondary, #888)",d=e.gridColor??l,h=e.format??(e=>String(e)),u="top"===t||"left"===t?-1:1,c=e.ticks.length-1,p=e.ticks.map((p,f)=>{let m,y=e.scale(p),x=n+u*s,g=n-u*r,v=x+u*o;m=e.labelAnchor?e.labelAnchor:i?e.edgeAnchor&&0===f?"start":e.edgeAnchor&&f===c?"end":"middle":"left"===t?"end":"start";let b=i?"top"===t?"auto":"hanging":"middle",w=i?{x:y,y:v}:{x:v,y:y};/* @__PURE__ */
3
- return be("g",{children:[(s>0||r>0)&&/* @__PURE__ */ve("line",{...i?{x1:y,x2:y,y1:x,y2:g}:{x1:x,x2:g,y1:y,y2:y},stroke:r>0?d:l,strokeWidth:1,strokeDasharray:r>0?e.gridDasharray:void 0,opacity:r>0?.7:1}),
4
- /* @__PURE__ */ve("text",{x:w.x,y:w.y,textAnchor:m,dominantBaseline:b,fontSize:a,fontWeight:e.fontWeight,fill:l,children:h(p)})]},`tick-${p}-${f}`)});/* @__PURE__ */
5
- return ve("g",{className:e.className,style:{pointerEvents:"none"},children:p},e.keyId)}function Be(e){let t,i=e.stroke??"var(--semiotic-text, #f4f4f8)",n=e.strokeWidth??1,s=e.markRadius??0,r=e.labelX-e.markX,o=e.labelY-e.markY,a=Math.hypot(r,o)||1,l=e.markX+r/a*s,d=e.markY+o/a*s;return t="elbow"===e.connector?`M${l},${d} L${l},${e.labelY} L${e.labelX},${e.labelY}`:"curve"===e.connector?`M${l},${d} Q${(l+e.labelX)/2},${d} ${e.labelX},${e.labelY}`:`M${l},${d} L${e.labelX},${e.labelY}`,/* @__PURE__ */be("g",{className:e.className,style:{pointerEvents:"none"},children:[s>0&&/* @__PURE__ */ve("circle",{cx:e.markX,cy:e.markY,r:s,fill:"none",stroke:i,strokeWidth:n}),
6
- /* @__PURE__ */ve("path",{d:t,fill:"none",stroke:i,strokeWidth:n}),
7
- /* @__PURE__ */ve("text",{x:e.labelX,y:e.labelY,textAnchor:e.labelAnchor??"middle",dominantBaseline:e.labelBaseline??"hanging",fontSize:e.fontSize??11,fontWeight:e.fontWeight,fill:e.color??i,children:e.label})]},e.keyId)}import*as Oe from"react";import{scaleLinear as Ae}from"d3-scale";var Ce=e=>{let t=e.config,{plot:i}=e.dimensions,n=t.fields??[];if(n.length<2||i.width<=0||i.height<=0)return{nodes:[]};if(0===e.data.length)return{nodes:[]};let s=/* @__PURE__ */Object.create(null);for(let i of n){let n=t.domains&&Object.prototype.hasOwnProperty.call(t.domains,i)?t.domains[i]:void 0;if(Array.isArray(n)&&n.length>=2&&"number"==typeof n[0]&&Number.isFinite(n[0])&&"number"==typeof n[1]&&Number.isFinite(n[1])){s[i]=[n[0],n[1]];continue}let r=1/0,o=-1/0;for(let t of e.data){let e=Number(t[i]);Number.isFinite(e)&&(e<r&&(r=e),e>o&&(o=e))}if(Number.isFinite(r)&&Number.isFinite(o))if(r===o){let e=Math.max(.01*Math.abs(r),.5);s[i]=[r-e,o+e]}else s[i]=[r,o];else s[i]=[0,1]}let r=!1!==t.showAxes,o=r?t.axisLabelPadding??24:8,a=r?18:8,l=n.map(e=>Ae().domain(s[e]).range([i.y+i.height-a,i.y+o])),d=n.map((e,t)=>1===n.length?i.x+i.width/2:i.x+t/(n.length-1)*i.width),h=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>String(e[t.colorBy]??""):null,u=t.opacity??.45,c=t.strokeWidth??1.25,p=e.theme.semantic.primary??"#3b6cb1",f=t.dimmedOpacity??.08,m=t.highlightFn,y=[],x=[];for(let i of e.data){let s=h?e.resolveColor(String(h(i))):p,r=!m||m(i),o=de(i,{predicate:m,baseOpacity:u,dimOpacity:f,brighten:.4}),a=r?x:y;for(let e=0;e<n.length-1;e++){let t=Number(i[n[e]]),h=Number(i[n[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(h))continue;let u={type:"connector",x1:d[e],y1:l[e](t),x2:d[e+1],y2:l[e+1](h),style:{stroke:s,strokeWidth:m&&r?c+.75:c,opacity:o,fill:"none"},datum:i};a.push(u)}if(t.showPoints)for(let e=0;e<n.length;e++){let t=Number(i[n[e]]);if(!Number.isFinite(t))continue;let r={type:"point",x:d[e],y:l[e](t),r:2.5,style:{fill:s,stroke:"none",opacity:Math.min(1,o+.3)},datum:i};a.push(r)}}let g=null;if(r){let r=`var(--semiotic-border, ${e.theme.semantic.border??"#aaa"})`,h=`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`,u=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,c=i.y+o,p=i.y+i.height-a,f=[];for(let e=0;e<n.length;e++){let a=n[e],m=d[e],y=t.tickFormat&&Object.prototype.hasOwnProperty.call(t.tickFormat,a)?t.tickFormat[a]:void 0,x="function"==typeof y?y:e=>e.toLocaleString();f.push(Oe.createElement("line",{key:`pc-axis-line-${e}`,x1:m,x2:m,y1:c,y2:p,stroke:r,strokeWidth:1})),f.push(Ie({keyId:`pc-axis-label-${e}`,text:a,x:m,y:i.y+o-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:h}));let[g,v]=s[a],b=5;for(let t=0;t<b;t++){let i=g+(v-g)*t/(b-1),n=l[e](i);f.push(Oe.createElement("line",{key:`pc-tick-${e}-${t}`,x1:m-3,x2:m+3,y1:n,y2:n,stroke:r,strokeWidth:1}),Ie({keyId:`pc-ticktext-${e}-${t}`,text:x(i),x:m+6,y:n+3,anchor:"start",baseline:"auto",fontSize:10,color:u}))}}g=Oe.createElement(Oe.Fragment,null,...f)}return{nodes:y.concat(x),overlays:g}};function Te(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Ne(e){if(!e||"object"!=typeof e)return!1;let t=e;return"string"==typeof t.id&&(null==t.label||"string"==typeof t.label)&&"number"==typeof t.count&&Number.isFinite(t.count)&&Array.isArray(t.bodyIds)&&t.bodyIds.every(e=>"string"==typeof e)}function Pe(e,t){if("region-enter"!==t.type)return e;let i=t.region.id,n=Te(e,i),s=Ne(n)?n:{id:i,label:t.region.label??i,count:0,bodyIds:[]};if(s.bodyIds.includes(t.bodyId))return e;let r=[...s.bodyIds,t.bodyId];return{...e,[i]:{...s,count:r.length,bodyIds:r}}}function Fe(e,t){return(t??Object.keys(e)).map(t=>Te(e,t)).filter(Ne).map(e=>({label:e.label??e.id,value:e.count}))}function qe(e,t){let i=t instanceof Set?t:new Set(t);return e.map(e=>{let t=e.bodyIds??[],n=t.filter(e=>!i.has(e)),s=t.length-n.length,r=e.completion?.mode??"allMembersAbsorbed",o=e.completion?.valueByBodyId,a=e=>{let t=o?Te(o,e):void 0;return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:1},l=t.reduce((e,t)=>e+a(t),0),d=t.reduce((e,t)=>e+(i.has(t)?a(t):0),0),h=e.completion?.threshold,u="threshold"===r?Number.isFinite(h)&&Number(h)>=0?Number(h):l:void 0,c=t.length>0&&("anyAbsorbed"===r?s>0:"threshold"===r?d>=(u??l):0===n.length);return{id:e.id,label:e.label??e.id,mode:r,complete:c,absorbed:s,total:t.length,absorbedValue:d,totalValue:l,threshold:u,missing:n}})}function De(e){let t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}function Ye(e,t,i,n,s,r={}){return{id:e,friction:r.friction,restitution:r.restitution,bodyFilter:r.bodyFilter,shape:{type:"segment",x1:t,y1:i,x2:n,y2:s,thickness:r.thickness??8}}}function Ee(e,t,i,n){return{type:"aabb",x:e,y:t,width:i,height:n}}function je(e){let t=e.shape??"lane",i=Math.max(1,Math.round(e.width)),s=Math.max(1,Math.round(e.height)),r=e.padX??46,o=e.padY??72,a=r,l=i-r,d=o,h=s-Math.max(24,Math.round(.45*o)),u=(d+h)/2,c=Math.max(1,h-d),p=n(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),m=Number.isFinite(f)?f:0,y=n(c*p+m,.06*c,.5*c),x=y/2,g=u-x,v=u+x,b=e.idPrefix??"process",w=e.friction??.58,S=e.restitution??.18,M=e.wallThickness??8,I=e.stages;if(!I.length)throw new Error("processStageLayout requires at least one stage");let k=n(e.centerStageIndex??Math.floor(I.length/2),0,I.length-1),$=De(I),B=l-a,O=a,A=I.map((e,t)=>{let i=(e.share??1)/$*B,n=O,s=t===I.length-1?l:O+i;return O=s,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:s,x:(n+s)/2,width:s-n,y:u,height:c}}),C=A[k],T=C.x0,N=C.x1,P=(e,i)=>{if("lane"===t)return"top"===i?d:h;if("funnel"===t){let t=n((e-a)/Math.max(1,l-a),0,1);return"top"===i?d+(g-d)*t:h+(v-h)*t}if(e<=T){let t=n((e-a)/Math.max(1,T-a),0,1);return"top"===i?d+(g-d)*t:h+(v-h)*t}if(e<=N)return"top"===i?g:v;let s=n((e-N)/Math.max(1,l-N),0,1);return"top"===i?g+(d-g)*s:v+(h-v)*s},F=A.map(e=>{let t=Math.min(P(e.x0,"top"),P(e.x1,"top")),i=Math.max(P(e.x0,"bottom"),P(e.x1,"bottom"));return{...e,y:(t+i)/2,height:Math.max(1,i-t)}}),q={thickness:M,friction:w,restitution:S},D=[];"lane"===t?D.push(Ye(`${b}-top`,a,d,l,d,q),Ye(`${b}-bottom`,a,h,l,h,q),Ye(`${b}-left`,a,d,a,h,{...q,thickness:Math.max(6,M-2)}),Ye(`${b}-right`,l,d,l,h,{...q,thickness:Math.max(6,M)})):"funnel"===t?D.push(Ye(`${b}-top`,a,d,l,g,q),Ye(`${b}-bottom`,a,h,l,v,q),Ye(`${b}-left`,a,d,a,h,{...q,thickness:Math.max(6,M-2)}),Ye(`${b}-right`,l,g,l,v,{...q,thickness:Math.max(6,M)})):D.push(Ye(`${b}-left-top`,a,d,T,g,q),Ye(`${b}-left-bottom`,a,h,T,v,q),Ye(`${b}-center-top`,T,g,N,g,q),Ye(`${b}-center-bottom`,T,v,N,v,q),Ye(`${b}-right-top`,N,g,l,d,q),Ye(`${b}-right-bottom`,N,v,l,h,q),Ye(`${b}-left`,a,d,a,h,{...q,thickness:Math.max(6,M-2)}),Ye(`${b}-right`,l,d,l,h,{...q,thickness:Math.max(6,M)}));let Y=e.membraneDampingScale??.5,E=a,j=Math.max(1,("bowtie"===t?T:l)-E),L=(e.membranes??[]).map(e=>{let t=E+n(e.offset,0,1)*j,i=e.width??18+18*e.cost,s=c-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:i,height:s}}),R=!1===e.includeMembraneRegions?[]:L.map(e=>We({id:e.id,label:e.label??e.id,description:e.description??`${e.label??e.id} is a permeable region. It taxes energy and damps velocity while bodies overlap it.`,x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??Y,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:i,height:s,padX:r,padY:o,left:a,right:l,topY:d,bottomY:h,midY:u,centerLeft:T,centerRight:N,pinchHeight:y,pinchTop:g,pinchBottom:v,stages:F,membranes:L,colliders:D,regionEffects:R,boundaryY:P}}function Le(e,t,i){return"function"==typeof t?n=>({...i,...t(n),primitive:e}):{...i,...t,primitive:e}}function Re(e,t,i,n){return{id:e.id,label:e.label,description:e.description,kind:e.kind??t,shape:Ee(e.x,e.y,e.width,e.height),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:i?Le(i,e.attributes,n):e.attributes,onEnter:e.onEnter,onExit:e.onExit}}function Xe(e,t={}){let i=t.idPrefix??"stage",n=Math.max(0,t.insetX??0),s=Math.max(0,t.insetY??1);return e.stages.map(e=>{let r="function"==typeof t.metadata?t.metadata(e):t.metadata??{};return{...Re({id:i?`${i}:${e.id}`:e.id,label:e.label??e.id,description:e.description,kind:"region",x:e.x,y:e.y,width:Math.max(1,e.width-2*n),height:Math.max(1,e.height-2*s),bodyFilter:t.bodyFilter,semanticItem:t.semanticItem,attributes:{primitive:"processStage",stageId:e.id,stageIndex:e.index},metadata:{...r,primitive:"processStage",stageId:e.id,stageIndex:e.index}})}})}function We(e){let t=e.dampingScale??.5,i=e.energyScale??1,s=n(e.cost,0,2);return{...Re(e,"membrane","membrane",{membraneCost:s}),damping:s*t,energyDelta:-s*i}}function ze(e){return{...Re(e,"charge-gate","chargeGate"),charge:e.charge??!0,energyDelta:e.energyDelta,impulseOnEnter:e.impulseOnEnter}}function Ge(e){let t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...Re(e,"force-field","routeSurface"),force:t,damping:e.damping??.015}}function Ve(e){let t=e.pressure??e.occupancy??0,i=e.baseDamping??.08,n=e.dampingPerUnit??.12,s=e.energyPerUnit??0;return{...Re(e,"membrane","pressureField",{pressure:t}),damping:i+t*n,energyDelta:s?-t*s:void 0,force:e.force}}function _e(e){let t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...Re(e,"force-field","capacitatedSensor",{capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity}),force:t,damping:e.damping,charge:e.charge??e.capacity}}function He(e){return{...Re(e,"force-field","portal",{targetStage:e.targetStage}),force:e.force,impulseOnEnter:e.impulseOnEnter,damping:e.damping??.08}}function Ue(e){let t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...Re(e,"sink","absorb"),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}function Ke(e){return{...Re(e,"force-field","forceField"),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}function Qe(e){let t=e.x??e.anchor?.x??0,i=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:i,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:i},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}function Ze(e){let t=e.idPrefix??"lane",i={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},n=[Ye(`${t}-top`,e.left,e.top,e.right,e.top,i),Ye(`${t}-bottom`,e.left,e.bottom,e.right,e.bottom,i)];return e.openEnds||n.push(Ye(`${t}-left`,e.left,e.top,e.left,e.bottom,i),Ye(`${t}-right`,e.right,e.top,e.right,e.bottom,i)),n}import{Fragment as Je,jsx as et,jsxs as tt}from"react/jsx-runtime";var it={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}};function nt(e){return 6.2*e.length}function st(e,t){let i=e.trim();if(i.length<=t)return i;if(t<=1)return i.slice(0,1);let n=i.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return n.length>1&&n.length<=t?n:t<=3?i.slice(0,t).toUpperCase():`${i.slice(0,Math.max(1,t-2))}..`}function rt(e,t,i="auto"){let n=Math.max(1,Math.floor(t/6.2)),s="compact"===i?st(e,n):"full"===i||nt(e)<=t?e:st(e,n);return{text:s,textLength:nt(s)>t?Math.max(4,t):void 0}}function ot(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}function at(e){if(null!=e.capacity){let t=null!=e.queueDepth?` · q ${e.queueDepth}`:"";return e.capacityLabel?`${e.capacityLabel}${t}`:`cap ${Number.isInteger(e.capacity)?String(e.capacity):e.capacity.toFixed(1)}${t}`}return e.absorb?"absorb":e.portalTarget?"portal":"flow"}function lt(e,t={}){let{showFlowSpine:i=!0,showStageCounts:s=!0,showCapacityBadges:r=!0,showGroupSockets:o=!0,stageLabelMode:a="auto",outlineStages:l=!1,testId:d="process-flow-chrome"}=t,{width:h,height:u,left:c,right:p,topY:f,bottomY:m,midY:y,stages:x,groups:g=[]}=e,v=m-f;/* @__PURE__ */
8
- return tt("svg",{"aria-hidden":"true","data-testid":d,"data-outline-stages":l?"true":void 0,width:h,height:u,viewBox:`0 0 ${h} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",l?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[
9
- /* @__PURE__ */et("defs",{children:/* @__PURE__ */tt("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[
10
- /* @__PURE__ */et("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),
11
- /* @__PURE__ */et("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),
12
- /* @__PURE__ */et("rect",{x:0,y:0,width:h,height:u,fill:"url(#semiotic-process-floor)"}),
13
- /* @__PURE__ */et("rect",{x:c-6,y:f-8,width:p-c+12,height:v+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),i?/* @__PURE__ */et("line",{x1:c+8,x2:p-8,y1:y,y2:y,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,x.map((e,t)=>{let i=ot(e),o=it[i],d=Math.max(12,e.width-8),h=n(d-8,22,88),c=Math.max(8,h-10),p=rt(e.label,c,a),g="none"!==a&&d-8>=22,b=at(e),w=rt(b,Math.max(16,d-10),"auto"),S=r&&!1!==e.showBadge&&d>=32,M=null!=e.count?`n=${e.count}${null!=e.processed?` done ${e.processed}`:""}`:"",I=rt(M,Math.max(16,d-8),"auto"),k=Math.max(30,f-15),$=k-13;/* @__PURE__ */
14
- return tt("g",{"data-stage":e.id,"data-role":i,children:[
15
- /* @__PURE__ */et("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:f+6,width:d,height:v-12,rx:10,fill:l?"none":o.fill,stroke:o.stroke,strokeWidth:l?1.85:"flow"===i?1:1.6}),t<x.length-1?/* @__PURE__ */et("polygon",{points:`${e.x1-2},${y-7} ${e.x1+8},${y} ${e.x1-2},${y+7}`,fill:o.accent,opacity:.85}):null,g?/* @__PURE__ */tt(Je,{children:[
16
- /* @__PURE__ */et("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-h/2,y:$,width:h,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:o.stroke}),
17
- /* @__PURE__ */tt("text",{x:e.x,y:k,textAnchor:"middle",fill:o.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:p.textLength,lengthAdjust:p.textLength?"spacingAndGlyphs":void 0,children:[
18
- /* @__PURE__ */et("title",{children:e.label}),p.text]})]}):null,S?/* @__PURE__ */tt("text",{x:e.x,y:f+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:w.textLength,lengthAdjust:w.textLength?"spacingAndGlyphs":void 0,children:[
19
- /* @__PURE__ */et("title",{children:b}),w.text]}):null,s&&null!=e.count?/* @__PURE__ */tt("text",{x:e.x,y:Math.min(u-8,m+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:I.textLength,lengthAdjust:I.textLength?"spacingAndGlyphs":void 0,children:[
20
- /* @__PURE__ */et("title",{children:M}),I.text]}):null]},e.id)}),o?g.map((e,t)=>{let i=e.total??0,s=e.absorbed??0,r=e.complete??(i>0&&s>=i),o=!r&&i>0&&s/i>=.75,a=r?"rgba(52, 211, 153, 0.35)":o?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",l=r?"#34d399":o?"#fbbf24":"var(--semiotic-border, #64748b)",d=i>0?`${s}/${i}${r?" shipped":o?" almost":""}`:`feature ${t+1}`,h=n(Math.max(54,nt(e.label)+18,nt(d)+16),54,104),u=rt(e.label,h-12,"auto"),c=rt(d,h-12,"auto");/* @__PURE__ */
21
- return tt("g",{"data-group":e.id,children:[
22
- /* @__PURE__ */et("rect",{x:e.x-h/2,y:e.y-22,width:h,height:44,rx:10,fill:a,stroke:l,strokeWidth:1.5}),
23
- /* @__PURE__ */tt("text",{x:e.x,y:e.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[
24
- /* @__PURE__ */et("title",{children:e.label}),u.text]}),
25
- /* @__PURE__ */tt("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:l,fontSize:9,fontWeight:700,textLength:c.textLength,lengthAdjust:c.textLength?"spacingAndGlyphs":void 0,children:[
26
- /* @__PURE__ */et("title",{children:d}),c.text]})]},e.id)}):null]})}var dt=e=>"number"==typeof e&&Number.isFinite(e);function ht(e,t){let i="function"==typeof t?t(e):e[t];return dt(i)?i:void 0}function ut(e){return[...e].sort((e,t)=>e.localeCompare(t))}function ct(e,t){let i=new Map(e.map(e=>[e,/* @__PURE__ */new Set]));for(let e of t)!i.has(e.source)||!i.has(e.target)||(i.get(e.source)?.add(e.target),i.get(e.target)?.add(e.source));return i}function pt(e){let t=new Set(e.keys()),i=[];for(let n of ut(t)){if(!t.has(n))continue;let s=[n],r=[];t.delete(n);for(let i=0;i<s.length;i++){let n=s[i];r.push(n);for(let i of ut(e.get(n)??[]))t.has(i)&&(t.delete(i),s.push(i))}i.push(r.sort((e,t)=>e.localeCompare(t)))}return i.sort((e,t)=>t.length-e.length||e[0].localeCompare(t[0]))}function ft(e,t,i){let n=/* @__PURE__ */new Map([[e,0]]),s=[e];for(let e=0;e<s.length;e++){let r=s[e],o=n.get(r);for(let e of ut(i.get(r)??[]))!t.has(e)||n.has(e)||(n.set(e,o+1),s.push(e))}return n}function mt(e,t,i){let n=ft(e,t,i),s=e,r=-1;for(let[e,t]of n)(t>r||t===r&&e.localeCompare(s)<0)&&(s=e,r=t);return s}function yt(e,t,i){let n=new Set(e),s=e.filter(e=>(t.get(e)?.size??0)<=1)[0]??e[0],r=ft(i&&n.has(i)?i:mt(mt(s,n,t),n,t),n,t),o=0;for(let e of r.values())o=Math.max(o,e);let a=Array.from({length:o+1},()=>[]);for(let t of e)a[r.get(t)??0].push(t);a.forEach(e=>e.sort((e,t)=>e.localeCompare(t)));let l=(e,i)=>{let n=new Map(a[i].map((e,t)=>[e,t])),s=e=>{let i=[...t.get(e)??[]].map(e=>n.get(e)).filter(e=>null!=e);return 0===i.length?Number.POSITIVE_INFINITY:i.reduce((e,t)=>e+t,0)/i.length},r=new Map(a[e].map(e=>[e,s(e)]));a[e].sort((e,t)=>r.get(e)-r.get(t)||e.localeCompare(t))};for(let e=0;e<4;e+=1){for(let e=1;e<a.length;e+=1)l(e,e-1);for(let e=a.length-2;e>=0;e-=1)l(e,e+1)}return a}function xt(e,t,i,n,s,r){let o=ct(e.map(e=>e.id),t),a=pt(o),l=new Map(e.map(e=>[e.id,e.data])),d=/* @__PURE__ */new Map,h=Math.max(0,i.width),u=Math.max(0,i.height),c=Math.min(n,h/2),p=Math.min(n,u/2),f=Math.max(0,u-2*p),m=a.length>1?Math.min(s,f/a.length):0,y=Math.max(0,f-m*Math.max(0,a.length-1)),x=a.reduce((e,t)=>e+Math.sqrt(t.length),0),g=p;for(let e of a){let t=y*(Math.sqrt(e.length)/x),i=yt(e,o,r),n=Math.max(0,h-2*c);i.forEach((e,s)=>{let r=1===i.length?h/2:c+s/(i.length-1)*n;e.forEach((i,n)=>{let s=1===e.length?g+t/2:g+n/(e.length-1)*t;d.set(i,{id:i,x:r,y:s,data:l.get(i)})})}),g+=t+m}return d}function gt(e,t,i,n={}){let s=Math.max(0,n.padding??36),r=Math.max(0,n.componentGap??26),o=n.xAccessor??"x",a=n.yAccessor??"y",l=e.map(e=>({...e,authoredX:ht(e.data,o),authoredY:ht(e.data,a)})),d=l.length>0&&l.every(e=>dt(e.authoredX)&&dt(e.authoredY)),h="authored"===n.layoutMode||"automatic"!==n.layoutMode&&d,u=[];if(h&&!d&&u.push("Authored transit layout requested, but at least one station has no finite x/y position; using automatic topology layout."),!h||!d){!d&&"automatic"!==n.layoutMode&&u.push("Complete station positions were not supplied; using the deterministic automatic topology layout.");let o=xt(e,t,i,s,r,n.rootId);if("right-to-left"===n.direction)for(let e of o.values())e.x=i.width-e.x;return{positions:o,mode:"automatic",warnings:u,projectAuthoredPoint:e=>e}}let c=1/0,p=-1/0,f=1/0,m=-1/0;for(let e of l)c=Math.min(c,e.authoredX),p=Math.max(p,e.authoredX),f=Math.min(f,e.authoredY),m=Math.max(m,e.authoredY);let y=Math.max(1,i.width-2*s),x=Math.max(1,i.height-2*s),g=e=>({x:p===c?i.width/2:s+(e.x-c)/(p-c)*y,y:m===f?i.height/2:s+(e.y-f)/(m-f)*x}),v=/* @__PURE__ */new Map;for(let e of l){let t=g({x:e.authoredX,y:e.authoredY});v.set(e.id,{id:e.id,...t,data:e.data})}return{positions:v,mode:"authored",warnings:u,projectAuthoredPoint:g}}function vt(e,t){let i=t.x-e.x,n=t.y-e.y,s=Math.abs(i),r=Math.abs(n);if(s<.001||r<.001||Math.abs(s-r)<.001)return[e,t];let o=Math.sign(i),a=Math.sign(n);if(s>r){let i=(s-r)/2;return[e,{x:e.x+o*i,y:e.y},{x:t.x-o*i,y:t.y},t]}let l=(r-s)/2;return[e,{x:e.x,y:e.y+a*l},{x:t.x,y:t.y-a*l},t]}function bt(e,t){if(0===t||e.length<2)return e.map(e=>({...e}));let i=(e,t)=>{let i=t.x-e.x,n=t.y-e.y,s=Math.hypot(i,n)||1;return{x:-n/s,y:i/s}};return e.map((n,s)=>{let r=s>0?i(e[s-1],n):null,o=s<e.length-1?i(n,e[s+1]):null;if(!r||!o){let e=o??r??{x:0,y:0};return{x:n.x+e.x*t,y:n.y+e.y*t}}let a=r.x+o.x,l=r.y+o.y,d=Math.hypot(a,l);if(d<.001)return{x:n.x+o.x*t,y:n.y+o.y*t};a/=d,l/=d;let h=a*o.x+l*o.y;if(Math.abs(h)<.001)return{x:n.x+o.x*t,y:n.y+o.y*t};let u=4*Math.abs(t),c=t/h,p=Math.max(-u,Math.min(u,c));return{x:n.x+a*p,y:n.y+l*p}})}function wt(e,t){if(0===e.length)return"";if(1===e.length)return`M${e[0].x},${e[0].y}`;let i=Math.max(0,t),n=`M${e[0].x},${e[0].y}`;for(let t=1;t<e.length-1;t+=1){let s=e[t-1],r=e[t],o=e[t+1],a=Math.hypot(r.x-s.x,r.y-s.y),l=Math.hypot(o.x-r.x,o.y-r.y),d=Math.min(i,a/2,l/2);if(d<=.001){n+=` L${r.x},${r.y}`;continue}let h={x:r.x+(s.x-r.x)/a*d,y:r.y+(s.y-r.y)/a*d},u={x:r.x+(o.x-r.x)/l*d,y:r.y+(o.y-r.y)/l*d};n+=` L${h.x},${h.y} Q${r.x},${r.y} ${u.x},${u.y}`}let s=e[e.length-1];return`${n} L${s.x},${s.y}`}var St=(e,t,i)=>({x:e.x+(t.x-e.x)*i,y:e.y+(t.y-e.y)*i}),Mt=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y);function It(e){let t=[e[0]];for(let i=1;i<e.length-1;i++){let n=e[i-1],s=e[i],r=e[i+1],o=Mt(n,s),a=Mt(s,r),l=Math.min(8,o/2,a/2);if(0===l)continue;let d=St(s,n,l/o),h=St(s,r,l/a);t.push(d);for(let e=1;e<=12;e++){let i=e/12;t.push(St(St(d,s,i),St(s,h,i),i))}}return t.push(e[e.length-1]),t.filter((e,i)=>0===i||Mt(t[i-1],e)>1e-8)}function kt(e,t,i){if(e.length<2)return"";let n=It(e);if(n.length<2)return"";let s=[0];for(let e=1;e<n.length;e++)s.push(s[e-1]+Mt(n[e-1],n[e]));let r=s[s.length-1],o=bt(n,1),a=[1,-1].map(e=>n.map((n,a)=>{let l=t+(i-t)*s[a]/r;return St(n,o[a],e*l/2)}));return[...a[0],...a[1].reverse()].map((e,t)=>`${0===t?"M":"L"}${e.x},${e.y}`).join(" ")+" Z"}function $t(e){let t=-(e.reduce((e,t)=>e+t,0)+3*(e.length-1))/2;return e.map(e=>{let i=t+e/2;return t+=e+3,i})}var Bt={viewBox:[24,24],parts:[{d:"M5,0 H19 Q24,0 24,5 V19 Q24,24 19,24 H5 Q0,24 0,19 V5 Q0,0 5,0 Z",stroke:"accent"}]};function Ot(e){let t="";return e.split(">").map((e,i)=>t=i?`${t}>${e}`:e)}function At(e){let t=/* @__PURE__ */new Map;for(let i of e){let e=Ot(i.signature);i.nodePath.forEach((n,s)=>{let r=e[s],o=t.get(r);o||(o={id:r,state:n,depth:s+1,signatures:/* @__PURE__ */new Set},t.set(r,o)),o.signatures.add(i.signature)})}return[...t.values()]}var Ct=(e,t)=>e.stepEntityCounts?.[t]??e.entityCount,Tt=({datum:e},t)=>({opacity:!t?.isActive||t.predicate(e)||null!=e?.fromNodeId&&t.predicate({...e,nodeId:e.fromNodeId})?1:.2}),Nt=t=>{let i=t.config.braid,n=t.dimensions.plot,s=i.atlas.spec.comparison?.partitions??[...new Set(i.groups.map(e=>e.partition))],r=i.groups.filter(e=>s.includes(e.partition)&&e.nodePath.length>0),o=[],a=[],l=[];if(0===r.length)return{sceneNodes:a,sceneEdges:o,labels:l};let d=new Set(r.map(e=>e.signature)),h=[...i.signatureOrder.filter(e=>d.delete(e)),...d],u=new Map(h.map((e,t)=>[e,t])),c=[...r].sort((e,t)=>u.get(e.signature)-u.get(t.signature)),p=s.map(e=>c.filter(t=>t.partition===e)),f=At(c),m=e(f.map(e=>e.depth)),y=r.map(t=>e(t.stepEntityCounts??[t.entityCount])),x=e(y),g=e=>e<=0?0:Math.max(1,10*e/x),v=new Map(r.map((e,t)=>[e.id,g(y[t])])),b=n.height/s.length,{semantic:w}=t.theme,S=(e,t,i,n={})=>l.push({x:e,y:t,text:i,fill:w.text??"#333",fontSize:10,anchor:"middle",...n}),M={sourceRevision:i.atlas.provenance.sourceRevision,analysisRevision:i.atlas.analysisRevision,relationScopeId:"directed-admitted"},I=new Map(f.map(t=>{let i=p.map(e=>e.reduce((e,i)=>e+(t.signatures.has(i.signature)?v.get(i.id)+3:0),5));return[t.id,e(i,24)]})),k=e([...I.values()],24),$=Math.min(n.width/4,k/2+16),B=(n.width-2*$)/Math.max(m-1,1),O=e=>n.x+$+(e-1)*B,A=48+k/2,C=22+k/2,T=(e,t)=>e+A+(u.get(t)+.5)*Math.max(0,b-A-C)/h.length,N=(e,i,n,s,r)=>{let a=Ct(i,s),l=Ct(i,r),d=g(a),h=g(l);if(0===d&&0===h)return;let u=d!==h,c=t.resolveColor(i.signature);o.push({type:"curved",id:n,pathD:u?kt(e,d,h):wt(e,8),style:{fill:u?c:"none",fillOpacity:1,stroke:u?"none":c,strokeWidth:u?0:d},datum:{...M,id:n,kind:"braid-track",nodeId:i.nodePath[r],fromNodeId:i.nodePath[s],groupId:i.id,signature:i.signature,partition:i.partition,entityCount:i.entityCount,fromStep:s,toStep:r,fromCount:a,toCount:l,falseRoot:!1},accessibleDatum:{journey:i.nodePath.join(" → "),partition:i.partition??"all",fromStep:s+1,toStep:r+1,fromCount:a,toCount:l}})};return s.forEach((e,t)=>{let i=n.y+t*b,s=p[t];if(e&&S(n.x+8,i+14,e,{fontSize:12,fontWeight:600,anchor:"start"}),0===s.length)return;for(let e=1;e<=m;e++)S(O(e),i+34,`Step ${e}`);let r=/* @__PURE__ */new Map;for(let t of f){let n=s.filter(e=>t.signatures.has(e.signature));if(0===n.length)continue;let o=O(t.depth),l=xe([...t.signatures].map(e=>T(i,e))),d=$t(n.map(e=>v.get(e.id)));r.set(t.id,new Map(n.map((e,t)=>[e.id,{x:o,y:l+d[t],offset:d[t]}])));let h=I.get(t.id),u={state:t.state,step:t.depth,partition:e??"all"},c=`vertex:${e??"all"}:${t.id}`;a.push({type:"glyph",id:c,cx:o,cy:l,size:h,depth:t.depth,label:`${t.state} (step ${t.depth})`,glyph:Bt,accent:w.border??"#888",style:{fill:w.surface??"#fff"},datum:{...M,id:c,nodeId:t.state,kind:"braid-step",prefixId:t.id,...u},accessibleDatum:u}),S(o,l+h/2+12,t.state,{anchorPoint:[o,l]})}for(let t of s){let i=Ot(t.signature);for(let n=1;n<i.length;n++){let s=r.get(i[n-1]).get(t.id),o=r.get(i[n]).get(t.id),a=(s.x+o.x)/2-Math.sign(o.y-s.y)*o.offset,l=Math.abs(s.y-o.y)<1e-8?[s,o]:[s,{x:a,y:s.y},{x:a,y:o.y},o];N(l,t,`step:${e??"all"}:${i[n]}:${t.id}`,n-1,n)}}}),{sceneNodes:a,sceneEdges:o,labels:l,restyle:Tt,restyleEdge:Tt}};function Pt(e,t){let i=0,n=e.length-1,s=-1;for(;i<=n;){let r=i+n>>>1;e[r].at<=t?(s=r,i=r+1):n=r-1}return s<0?{at:t,before:0,after:0}:e[s]}function Ft(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};let i=[],n=[0];for(let s=0;s<e.length-1;s++){let r=e[s],o=e[s+1],a=[.../* @__PURE__ */new Set([...r.map(e=>e.at),...o.map(e=>e.at)])].sort((e,t)=>e-t),l=0;for(let e of a){let t=Pt(r,e),i=Pt(o,e);l=Math.max(l,t.after+i.before)}i.push(l),n.push(n[n.length-1]+l+t)}return{adjacentClearance:i,positions:n}}function qt(e,t,i,n={}){let s=[...e];if(s.length<=1)return s;let r=[...s],o=i(s),a=1,l=Math.max(0,n.passes??6),d=Math.max(1,n.maxEvaluations??1/0);for(let e=0;e<l&&a<d;e++){let e=new Map(s.map((e,t)=>[e,t])),l=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map;for(let i of t){let t=e.get(i.source),n=e.get(i.target);if(null==t||null==n)continue;let s=Number.isFinite(i.weight)&&i.weight>0?i.weight:1;l.set(i.source,(l.get(i.source)??0)+n*s),d.set(i.source,(d.get(i.source)??0)+s),l.set(i.target,(l.get(i.target)??0)+t*s),d.set(i.target,(d.get(i.target)??0)+s)}s=s.map((e,t)=>({item:e,index:t,barycenter:(l.get(e)??t)/(d.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(n.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);let h=i(s);if(a++,h<o)o=h,r=[...s];else if(h===o)break}return r}function Dt(e,t,i={}){let n=[...e];if(n.length<=1)return n;let s=t(n),r=1,o=Math.max(0,i.passes??6),a=Math.max(1,i.maxEvaluations??1/0);for(let e=0;e<o&&r<a;e++){let e=!1;for(let i=0;i<n.length-1&&r<a;i++){[n[i],n[i+1]]=[n[i+1],n[i]];let o=t(n);r++,o<s?(s=o,e=!0):[n[i],n[i+1]]=[n[i+1],n[i]]}if(!e)break}return n}function Yt(e,t,i={}){let n=[...e],s=n.length;if(s<=1||s>(i.maxItems??8))return n;let r=Math.max(1,i.maxEvaluations??1/0),o=0,a=[...n],l=1/0,d=()=>{if(o>=r)return;let e=t(n);o++,e<l&&(l=e,a=[...n])};d();let h=new Array(s).fill(0),u=0;for(;u<s&&o<r;)if(h[u]<u){let e=u%2==0?0:h[u];[n[e],n[u]]=[n[u],n[e]],d(),h[u]++,u=0}else h[u]=0,u++;return a}function Et(e,t,i=()=>!0){let n=0;for(let s=0;s<e.length;s++){let[r,o]=t(e[s]);for(let a=s+1;a<e.length;a++){if(!i(e[s],e[a]))continue;let[l,d]=t(e[a]);(r-l)*(o-d)<0&&n++}}return n}import*as jt from"react";import{jsx as Lt}from"react/jsx-runtime";var Rt,Xt={isActive:!1,predicate:()=>!0};function Wt(){let e=(Rt??(Rt=jt.createContext(null)),Rt);return jt.useContext(e)??Xt}function zt(e,t){let i=/* @__PURE__ */new Map;for(let t of e)i.set(t.id,/* @__PURE__ */new Set);for(let e of t)i.has(e.source)||i.set(e.source,/* @__PURE__ */new Set),i.has(e.target)||i.set(e.target,/* @__PURE__ */new Set),i.get(e.source).add(e.target);return i}function Gt(e,t,i={}){let n=/* @__PURE__ */new Set,s=[...e.get(t)??[]];for(let t=0;t<s.length;t++){let i=s[t];n.has(i)||(n.add(i),s.push(...e.get(i)??[]))}return i.includeStart&&n.add(t),n}function Vt(e){let t=e.fixedPosition;Number.isFinite(t?.x)&&(e.x=e.prevX=t.x,e.vx=0),Number.isFinite(t?.y)&&(e.y=e.prevY=t.y,e.vy=0)}function _t(e){if(!e)return;let t=Number.isFinite(e.x)?e.x:void 0,i=Number.isFinite(e.y)?e.y:void 0;return null==t&&null==i?void 0:{x:t,y:i}}function Ht(e,t,i){let n,s="x"===i?"y":"x",r=Math.abs(t[i]-e[i]),o=t[s]-e[s],a=(e,t)=>"circle"===e.shape.type?e.shape.radius:("x"===t?e.shape.width:e.shape.height)/2;if("circle"===e.shape.type&&"circle"===t.shape.type){let i=e.shape.radius+t.shape.radius;n=Math.sqrt(Math.max(0,i*i-r*r))}else if("aabb"===e.shape.type&&"aabb"===t.shape.type)n=a(e,s)+a(t,s);else{let o="circle"===e.shape.type?e:t,l="aabb"===e.shape.type?e:t,d=a(o,i),h=Math.max(0,r-a(l,i));n=a(l,s)+Math.sqrt(Math.max(0,d*d-h*h))}let l=o<0?-1:1;return{nx:"x"===s?l:0,ny:"y"===s?l:0,penetration:Math.max(0,n-Math.abs(o))}}function Ut(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function Kt(e){return"aabb"===e.type?{type:"aabb",x:e.x,y:e.y,width:e.width,height:e.height}:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:e.thickness}}function Qt(e){return{id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,bodyCollisions:e.bodyCollisions,...e.fixedPosition?{fixedPosition:_t(e.fixedPosition)}:{},shape:Ut(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function Zt(e){return e&&"function"!=typeof e?{property:e.property,equals:e.equals,notEquals:e.notEquals,oneOf:e.oneOf?.slice(),notOneOf:e.notOneOf?.slice()}:e}function Jt(e){return{id:e.id,shape:Kt(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:Zt(e.bodyFilter),index:e.index}}function ei(e,t,i){if("aabb"!==t.type)return null;let n=e.x-e.prevX,s=e.y-e.prevY;if(0===n&&0===s)return null;let r="circle"===e.shape.type?e.shape.radius:e.shape.width/2,o="circle"===e.shape.type?e.shape.radius:e.shape.height/2,a=t.x-t.width/2,l=t.x+t.width/2,d=t.y-t.height/2,h=t.y+t.height/2;if(Math.max(e.x,e.prevX)+r<a||Math.min(e.x,e.prevX)-r>l||Math.max(e.y,e.prevY)+o<d||Math.min(e.y,e.prevY)-o>h)return null;let u="circle"===e.shape.type?0:r,c="circle"===e.shape.type?0:o,p=1/0,f=null,m=(e,t,n,s,r,o,a,l,d,h,u)=>{let c,m,y;if(n>0&&t+s<=r+i&&e+s>r)c=Math.max(0,(r-s-t)/n),m=e+s-r,y=-1;else{if(!(n<0&&t-s>=o-i&&e-s<o))return;c=Math.max(0,(o+s-t)/n),m=o-(e-s),y=1}let x=a+l*c;c<p&&x>=d&&x<=h&&(p=c,f={nx:u?y:0,ny:u?0:y,penetration:m})};return m(e.x,e.prevX,n,r,a,l,e.prevY,s,d-c,h+c,!0),m(e.y,e.prevY,s,o,d,h,e.prevX,n,a-u,l+u,!1),f}function ti(e,t){return Math.abs(e.x-t.x)<=t.padding&&Math.abs(e.y-t.y)<=t.padding}function ii(e,t){let i=ni(e),n=[];for(let e=0;e<t.length;e++)oi(i,t[e].bounds)&&n.push(e);return{bounds:i,indexes:n}}function ni(e,t=!0){let i="circle"===e.shape.type?e.shape.radius:e.shape.width/2,n="circle"===e.shape.type?e.shape.radius:e.shape.height/2,s=t?Math.max(.005,Math.min(i,n)):0;return{x:e.x,y:e.y,padding:s,minX:Math.min(e.x,e.prevX)-i-s,minY:Math.min(e.y,e.prevY)-n-s,maxX:Math.max(e.x,e.prevX)+i+s,maxY:Math.max(e.y,e.prevY)+n+s}}function si(e){let t="circle"===e.shape.type?e.shape.radius:e.shape.width/2,i="circle"===e.shape.type?e.shape.radius:e.shape.height/2;return{minX:e.x-t,minY:e.y-i,maxX:e.x+t,maxY:e.y+i}}function ri(e){let t=e.shape;if("aabb"===t.type)return si({x:t.x,y:t.y,shape:t});let i=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-i,minY:Math.min(t.y1,t.y2)-i,maxX:Math.max(t.x1,t.x2)+i,maxY:Math.max(t.y1,t.y2)+i}}function oi(e,t){return e.minX<=t.maxX&&e.maxX>=t.minX&&e.minY<=t.maxY&&e.maxY>=t.minY}function ai(e,t,i={x:0,y:0}){let n=1,s=e.map(e=>{let t=ni(e,!(e.sleeping&&e.x===e.prevX&&e.y===e.prevY));return!1!==e.bodyCollisions&&(n=Math.max(n,t.maxX-t.minX,t.maxY-t.minY)),t}),r=Math.max(1,Math.min(t,n)),o=/* @__PURE__ */new Map;for(let t=0;t<e.length;t+=1){if(!1===e[t].bodyCollisions)continue;let i=s[t];i.cellX=Math.floor(i.minX/r),i.cellY=Math.floor(i.minY/r);for(let e=i.cellX;e<=Math.floor(i.maxX/r);e+=1){let n=o.get(e);n||o.set(e,n=/* @__PURE__ */new Map);for(let e=i.cellY;e<=Math.floor(i.maxY/r);e+=1){let i=n.get(e);i?i.push(t):n.set(e,[t])}}}let a=[];for(let[e,t]of o)for(let[i,n]of t)for(let t=0;t<n.length;t+=1)for(let r=t+1;r<n.length;r+=1){let o=n[t],l=n[r],d=s[o],h=s[l];e!==Math.max(d.cellX,h.cellX)||i!==Math.max(d.cellY,h.cellY)||oi(d,h)&&a.push([o,l])}let l=e.map(e=>e.x*i.x+e.y*i.y);return a.sort(([e,t],[i,n])=>Math.max(l[i],l[n])-Math.max(l[e],l[t])||(e===i?t-n:e-i)),{pairs:a,coversPositions:()=>e.every((e,t)=>!1===e.bodyCollisions||ti(e,s[t]))}}function li(e,t){if("circle"!==e.shape.type||"circle"!==t.shape.type)return null;let i=e.shape.radius+t.shape.radius;if(i<=0)return null;let n=t.prevX-e.prevX,s=t.prevY-e.prevY,r=t.x-e.x-n,o=t.y-e.y-s,a=r*r+o*o,l=2*(n*r+s*o),d=n*n+s*s-i*i;if(d<-1e-5||a<=1e-12||l>=0)return null;let h=l*l-4*a*d;if(h<0)return null;let u=(-l-Math.sqrt(h))/(2*a);if(u<0||u>1)return null;let c=(n+u*r)/i,p=(s+u*o)/i,f=i-((t.x-e.x)*c+(t.y-e.y)*p);return f>0?{nx:c,ny:p,penetration:f}:null}var di={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},hi=1e-9,ui=.005;function ci(e,t,i){return Math.max(t,Math.min(i,e))}function pi(e,t,i){return Math.min(e??i,t??i)}function fi(e,t,i){return ci(Math.max(e??i,t??i),0,1)}function mi(e){return e<0?-1:1}function yi(e){return e.sleeping&&e.x===e.prevX&&e.y===e.prevY}function xi(e,t,i,n,s,r){let o=n-e,a=s-t,l=i+r,d=o*o+a*a;if(d>=l*l)return null;if(d<=hi)return{nx:1,ny:0,penetration:l};let h=Math.sqrt(d);return{nx:o/h,ny:a/h,penetration:l-h}}function gi(e,t,i,n,s,r,o,a){let l=s-e,d=(i+o)/2-Math.abs(l);if(d<=0)return null;let h=r-t,u=(n+a)/2-Math.abs(h);return u<=0?null:d<u?{nx:mi(l),ny:0,penetration:d}:{nx:0,ny:mi(h),penetration:u}}function vi(e,t,i,n,s,r,o){let a=r/2,l=o/2,d=e-ci(e,n-a,n+a),h=t-ci(t,s-l,s+l),u=d*d+h*h;if(u>i*i)return null;if(u<=hi){let r=Math.abs(e-(n-a)),o=Math.abs(e-(n+a)),d=Math.abs(t-(s-l)),h=Math.abs(t-(s+l)),u=Math.min(r,o,d,h);return u===r?{nx:-1,ny:0,penetration:i+r}:u===o?{nx:1,ny:0,penetration:i+o}:u===d?{nx:0,ny:-1,penetration:i+d}:{nx:0,ny:1,penetration:i+h}}let c=Math.sqrt(u);return{nx:d/c,ny:h/c,penetration:i-c}}function bi(e,t,i,n,s,r,o,a=0){let l=r-n,d=o-s,h=l*l+d*d,u=h<=hi?0:ci(((e-n)*l+(t-s)*d)/h,0,1),c=i+a/2,p=e-(n+l*u),f=t-(s+d*u),m=p*p+f*f;if(m>=c*c)return null;if(m<=hi){let e=Math.sqrt(h);return e<=hi?{nx:1,ny:0,penetration:c}:{nx:-d/e,ny:l/e,penetration:c}}let y=Math.sqrt(m);return{nx:p/y,ny:f/y,penetration:c-y}}function wi(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return xi(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.radius);if("aabb"===e.shape.type&&"aabb"===t.shape.type)return gi(e.x,e.y,e.shape.width,e.shape.height,t.x,t.y,t.shape.width,t.shape.height);let i="circle"===e.shape.type?e:t,n=i===e?t:e;if("circle"!==i.shape.type||"aabb"!==n.shape.type)return null;let s=vi(i.x,i.y,i.shape.radius,n.x,n.y,n.shape.width,n.shape.height);return s&&i===e&&(s.nx=-s.nx,s.ny=-s.ny),s}function Si(e,t){let i=t.shape;if("aabb"===i.type)return"circle"===e.shape.type?vi(e.x,e.y,e.shape.radius,i.x,i.y,i.width,i.height):gi(i.x,i.y,i.width,i.height,e.x,e.y,e.shape.width,e.shape.height);let n="circle"===e.shape.type?e.shape.radius:Math.sqrt(e.shape.width*e.shape.width+e.shape.height*e.shape.height)/2;return bi(e.x,e.y,n,i.x1,i.y1,i.x2,i.y2,i.thickness??0)}function Mi(e,t){return`${e}\0${t}`}function Ii(e){let t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function ki(e,t){if(!t)return;let i=e;for(let e of t.split(".")){if(null==i||"object"!=typeof i||!Object.prototype.hasOwnProperty.call(i,e))return;i=i[e]}return i}function $i(e,t){return!!t?.some(t=>Object.is(e,t))}function Bi(e,t){if(!t)return!0;if("function"==typeof t)return t(e);let i=ki(e,t.property);return!("equals"in t&&!Object.is(i,t.equals)||"notEquals"in t&&Object.is(i,t.notEquals)||t.oneOf&&!$i(i,t.oneOf)||t.notOneOf&&$i(i,t.notOneOf))}function Oi(e,t){return Bi(t,e.bodyFilter)}var Ai=class{constructor(e={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=/* @__PURE__ */new Map,this.colliders=/* @__PURE__ */new Map,this.springs=/* @__PURE__ */new Map,this.activeSensors=/* @__PURE__ */new Set,this.supportedThisStep=/* @__PURE__ */new Set,this.supportDependents=/* @__PURE__ */new Map,this.supportContactsThisStep=/* @__PURE__ */new Set,this.reboundingThisStep=/* @__PURE__ */new Set,this.interpenetratingThisStep=/* @__PURE__ */new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...di,...e},this.random=t(this.options.seed)}init(e={}){this.options={...di,...e},this.random=t(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(e){let t={id:e.id,x:e.x,y:e.y,prevX:e.x,prevY:e.y,vx:e.vx??0,vy:e.vy??0,angle:e.angle??0,mass:Math.max(hi,e.mass??1),bodyCollisions:e.bodyCollisions??!0,...e.fixedPosition?{fixedPosition:_t(e.fixedPosition)}:{},shape:Ut(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};Vt(t),this.nextBodyIndex+=1,this.bodies.set(e.id,t)}remove(e){for(let t of e){this.bodies.delete(t);for(let e of Array.from(this.activeSensors))Ii(e).bodyId===t&&this.activeSensors.delete(e)}}setColliders(e){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(let t of e)this.colliders.set(t.id,{...t,shape:Kt(t.shape),bodyFilter:Zt(t.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(e){let t=e.id??`spring-${this.nextSpringIndex}`;return this.springs.set(t,{id:t,bodyId:e.bodyId,target:e.target,restLength:e.restLength??0,stiffness:e.stiffness??40,damping:e.damping??3}),this.nextSpringIndex+=1,t}removeConstraint(e){this.springs.delete(e)}applyImpulse(e,t,i){let n=this.bodies.get(e);n&&(n.vx+=t/n.mass,n.vy+=i/n.mass,Vt(n),this.wake(n))}step(e=this.options.fixedDt){let t=Math.max(0,e);if(this.lastEvents=[],0===t)return;this.reboundingThisStep.clear();let i=this.sortedBodies();for(let e of i)e.prevX=e.x,e.prevY=e.y;this.applySprings(t);let n=this.options.maxVelocity;for(let e of i)if(!e.sleeping){if(e.vx+=this.options.gravity.x*t,e.vy+=this.options.gravity.y*t,e.vx*=this.options.velocityDamping,e.vy*=this.options.velocityDamping,Vt(e),n>0){let t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>n){let i=n/t;e.vx*=i,e.vy*=i}}e.x+=e.vx*t,e.y+=e.vy*t}this.supportedThisStep.clear(),this.supportDependents.clear(),this.supportContactsThisStep.clear(),this.interpenetratingThisStep.clear();let s=this.sortedColliders().filter(e=>!e.sensor).map(e=>({collider:e,bounds:ri(e)})),r=s.some(({collider:e})=>e.bodyFilter)?void 0:new Array(i.length);this.resolveColliders(i,s,!1,r);let o=r&&i.map(yi),a=ai(i,this.options.cellSize,this.options.gravity);for(let e=0;e<this.options.collisionIterations;e+=1){e>0&&!a.coversPositions()&&(a=ai(i,this.options.cellSize,this.options.gravity));let t=this.resolveBodyPairs(i,a.pairs,0===e,o),n=this.resolveColliders(i,s,0===e,r);if(r&&!t&&!n)break}a.coversPositions()||(a=ai(i,this.options.cellSize,this.options.gravity));for(let[e,t]of a.pairs){let n=wi(i[e],i[t]);n&&n.penetration>.02&&(this.interpenetratingThisStep.add(i[e].id),this.interpenetratingThisStep.add(i[t].id))}let l=Array.from(this.supportedThisStep);for(let e=0;e<l.length;e+=1)for(let t of this.supportDependents.get(l[e])??[])this.supportedThisStep.has(t)||(this.supportedThisStep.add(t),l.push(t));this.reconcileSupportedVelocity(i,t),this.updateSensors(i),this.updateSleeping(i,t)}settle(e=1200,t=this.options.fixedDt){let i=0;for(;i<e&&!this.allSleeping();)this.step(t),i+=1;return i}readState(e=[]){e.length=0;for(let t of this.sortedBodies())e.push({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,...t.fixedPosition?{fixedPosition:_t(t.fixedPosition)}:{},shape:Ut(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Ii)}allSleeping(){for(let e of this.bodies.values())if(!e.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(Qt),colliders:this.sortedColliders().map(Jt),springs:Array.from(this.springs.values()).map(e=>({...e,target:{...e.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(e){this.options={...e.options,gravity:{...e.options.gravity}},this.random=t(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(let t of e.bodies){let e=Qt(t);Vt(e),this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(let t of e.colliders){let e=Jt(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(let t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});let e=/^spring-(\d+)$/.exec(t.id);e&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(e[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((e,t)=>e.index-t.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((e,t)=>e.index-t.index)}applySprings(e){for(let t of Array.from(this.springs.values()).sort((e,t)=>e.id.localeCompare(t.id))){let i=this.bodies.get(t.bodyId);if(!i||i.sleeping)continue;let n="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!n)continue;let s=n.x-i.x,r=n.y-i.y,o=s*s+r*r,a=Math.sqrt(o);if(a<=hi)continue;let l=s/a,d=r/a,h="vx"in n?n.vx:0,u="vy"in n?n.vy:0,c=(h-i.vx)*l+(u-i.vy)*d,p=(a-t.restLength)*t.stiffness+c*t.damping;i.vx+=p*l*e/i.mass,i.vy+=p*d*e/i.mass}}resolveBodyPairs(e,t,i,n){let s=!1;for(let[r,o]of t){let t=e[r],a=e[o];if(!t||!a)continue;if(!i&&n?.[r]&&n[o]&&yi(t)&&yi(a)){s=!0;continue}let l=li(t,a)??wi(t,a);l&&(s=!0,this.resolveDynamicCollision(t,a,l),i&&this.lastEvents.push({type:"contact",bodyId:t.id,otherId:a.id,sensor:!1}))}return s}resolveDynamicCollision(e,t,i){(e.fixedPosition||t.fixedPosition)&&(!e.sleeping&&null==e.fixedPosition?.x||!t.sleeping&&null==t.fixedPosition?.x?(e.sleeping||null!=e.fixedPosition?.y)&&(t.sleeping||null!=t.fixedPosition?.y)&&(i=Ht(e,t,"y")):i=Ht(e,t,"x"));let n=this.options.gravity,s=Math.hypot(n.x,n.y),r=this.contactOpposesGravity(i.nx,i.ny,s),o=this.contactOpposesGravity(-i.nx,-i.ny,s);r&&(e.sleeping&&this.supportedThisStep.add(t.id),this.addSupportContact(e.id,t.id)),o&&(t.sleeping&&this.supportedThisStep.add(e.id),this.addSupportContact(t.id,e.id));let a=e.sleeping?0:1/e.mass,l=t.sleeping?0:1/t.mass,d=null==e.fixedPosition?.x?a:0,h=null==e.fixedPosition?.y?a:0,u=null==t.fixedPosition?.x?l:0,c=null==t.fixedPosition?.y?l:0,p=e.fixedPosition||t.fixedPosition?i.nx**2*(d+u)+i.ny**2*(h+c):a+l;if(p<=hi)return;let f=this.supportedThisStep.has(e.id)&&r&&!t.sleeping&&!t.fixedPosition,m=this.supportedThisStep.has(t.id)&&o&&!e.sleeping&&!e.fixedPosition,y=s>1,x=y&&f?0:d,g=y&&f?0:h,v=y&&!f&&m?0:u,b=y&&!f&&m?0:c,w=i.nx**2*(x+v)+i.ny**2*(g+b),S=Math.max(0,i.penetration-ui)/Math.max(hi,w);e.x-=i.nx*S*x,e.y-=i.ny*S*g,t.x+=i.nx*S*v,t.y+=i.ny*S*b,y&&f&&this.supportedThisStep.add(t.id),y&&m&&this.supportedThisStep.add(e.id);let M=t.vx-e.vx,I=t.vy-e.vy,k=M*i.nx+I*i.ny;if(k>0)return;let $=Math.abs(k),B=pi(e.restitution,t.restitution,this.options.restitution),O=e.vx*n.x+e.vy*n.y,A=t.vx*n.x+t.vy*n.y,C=-(1+B)*k/p,T=C*i.nx,N=C*i.ny;e.vx-=T*d,e.vy-=N*h,t.vx+=T*u,t.vy+=N*c,this.applyFriction(e,t,i,C,d,h,u,c),B>0&&(O>=0&&e.vx*n.x+e.vy*n.y<0&&this.reboundingThisStep.add(e.id),A>=0&&t.vx*n.x+t.vy*n.y<0&&this.reboundingThisStep.add(t.id)),$>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,i,n,s,r,o,a){let l=-i.ny,d=i.nx,h=(t.vx-e.vx)*l+(t.vy-e.vy)*d,u=e.fixedPosition||t.fixedPosition?l**2*(s+o)+d**2*(r+a):s+o;if(Math.abs(h)<=hi||u<=hi)return;let c=fi(e.friction,t.friction,this.options.friction),p=ci(-h/u,-n*c,n*c),f=p*l,m=p*d;e.vx-=f*s,e.vy-=m*r,t.vx+=f*o,t.vy+=m*a}resolveColliders(e,t,i,n){if(0===t.length)return!1;let s=!1;for(let r=0;r<e.length;r++){let o=e[r],a=n?.[r];n&&(!a||!ti(o,a.bounds))&&(n[r]=a=ii(o,t));let l=0;for(;l<(a?a.indexes.length:t.length);){let e=a?a.indexes[l++]:l++,{collider:d,bounds:h}=t[e];if(!Oi(d,o))continue;let u=ei(o,d.shape,ui+hi);if(!u&&!oi(si(o),h))continue;let c=u??Si(o,d);if(c&&(s=!0,this.resolveStaticCollision(o,d,c),this.contactOpposesGravity(c.nx,c.ny)&&this.supportedThisStep.add(o.id),i&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:d.id,sensor:!1}),a&&n&&!ti(o,a.bounds)))for(n[r]=a=ii(o,t),l=0;l<a.indexes.length&&a.indexes[l]<=e;)l++}}return s}resolveStaticCollision(e,t,i){e.x+=i.nx*Math.max(0,i.penetration-ui),e.y+=i.ny*Math.max(0,i.penetration-ui);let n=e.vx*i.nx+e.vy*i.ny;if(n<0){let s=pi(e.restitution,t.restitution,this.options.restitution),r=this.options.gravity,o=e.vx*r.x+e.vy*r.y;e.vx-=(1+s)*n*i.nx,e.vy-=(1+s)*n*i.ny;let a=-i.ny,l=i.nx,d=e.vx*a+e.vy*l,h=fi(e.friction,t.friction,this.options.friction);e.vx-=d*a*h,e.vy-=d*l*h,s>0&&o>=0&&e.vx*r.x+e.vy*r.y<0&&this.reboundingThisStep.add(e.id)}Vt(e)}updateSensors(e){let t=this.sortedColliders().filter(e=>e.sensor);if(0===t.length&&0===this.activeSensors.size)return;let i=/* @__PURE__ */new Set;for(let n of e){let e=si(n);for(let s of t){if(!Oi(s,n)||!oi(e,ri(s))||!Si(n,s))continue;let t=Mi(s.id,n.id);i.add(t),this.activeSensors.has(t)||this.lastEvents.push({type:"sensor-enter",bodyId:n.id,sensorId:s.id})}}for(let e of Array.from(this.activeSensors).sort()){if(i.has(e))continue;let{sensorId:t,bodyId:n}=Ii(e);this.lastEvents.push({type:"sensor-exit",bodyId:n,sensorId:t})}this.activeSensors=i}updateSleeping(e,t){let i=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(let n of e){let e=Math.sqrt(n.vx*n.vx+n.vy*n.vy),s=Math.sqrt((n.x-n.prevX)*(n.x-n.prevX)+(n.y-n.prevY)*(n.y-n.prevY));e<this.options.sleepSpeed&&s<this.options.sleepSpeed*t&&!this.interpenetratingThisStep.has(n.id)&&(!i||this.supportedThisStep.has(n.id))?(n.sleepTime+=t,!n.sleeping&&n.sleepTime>=this.options.sleepAfter&&(n.sleeping=!0,n.vx=0,n.vy=0,this.lastEvents.push({type:"sleep",bodyId:n.id}))):n.sleeping?this.wake(n):n.sleepTime=0}}addSupportContact(e,t){let i=this.supportDependents.get(e);i?.has(t)||(this.supportContactsThisStep.add(e),this.supportContactsThisStep.add(t),i||(i=/* @__PURE__ */new Set,this.supportDependents.set(e,i)),i.add(t))}reconcileSupportedVelocity(e,t){let i=this.options.gravity;if(!(Math.hypot(i.x,i.y)<=1))for(let n of e)n.sleeping||!this.supportedThisStep.has(n.id)||!this.supportContactsThisStep.has(n.id)||this.reboundingThisStep.has(n.id)&&n.vx*i.x+n.vy*i.y<0||(n.vx=(n.x-n.prevX)/t,n.vy=(n.y-n.prevY)/t,Vt(n))}contactOpposesGravity(e,t,i){let{x:n,y:s}=this.options.gravity;return i??(i=Math.hypot(n,s)),i<=1e-9||(e*n+t*s)/i<-.2}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},Ci=["binId","targetBin","category","windowIndex","lane","group"];function Ti(){return{count:0,total:0,mean:0,m2:0,min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY}}function Ni(e,t){if(!Number.isFinite(t))return;e.count+=1,e.total+=t,e.min=Math.min(e.min,t),e.max=Math.max(e.max,t);let i=t-e.mean;e.mean+=i/e.count;let n=t-e.mean;e.m2+=i*n}function Pi(e){return{count:e.count,total:e.total,mean:e.count>0?e.mean:0,min:e.count>0?e.min:0,max:e.count>0?e.max:0,variance:e.count>1?e.m2/(e.count-1):0}}function Fi(e){return{count:e.count,total:e.total,mean:e.mean,m2:e.variance*Math.max(0,e.count-1),min:e.count>0?e.min:Number.POSITIVE_INFINITY,max:e.count>0?e.max:Number.NEGATIVE_INFINITY}}function qi(e,t){let i=e;if(null!=i[t])return i[t];let n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function Di(e,t,i){return"function"==typeof e?e(t,i):"string"==typeof e?qi(t,e):void 0}function Yi(e,t,i){if("number"==typeof e)return e;let n="function"==typeof e?e(t,i):"string"==typeof e?qi(t,e):1,s="number"==typeof n?n:Number(n);return Number.isFinite(s)?s:1}function Ei(e){if(null==e)return;let t=String(e);return t.trim()?t:void 0}function ji(e){for(let t of Ci){let i=Ei(qi(e,t));if(i)return i}return"sediment"}function Li(e){let t=Pi(e.value);return{id:e.id,label:e.label,count:t.count,total:t.total,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:Pi(e.x),y:Pi(e.y),value:t}}var Ri=class{constructor(e=!1){this.bins=/* @__PURE__ */new Map,this.nextIndex=0,this.config=e}updateConfig(e){void 0!==e&&(this.config=e,!1===e&&this.clear())}isEnabled(){return!1!==this.config}add(e){if(!1===this.config)return null;let t=this.nextIndex;this.nextIndex+=1;let i=Ei(Di(this.config.binAccessor,e,t))??ji(e),n=Ei(Di(this.config.labelAccessor,e,t))??i,s=Yi(this.config.valueAccessor,e,t),r=Math.max(0,Math.floor(this.config.retainBodyIds??12)),o=this.bins.get(i);return o||(o={id:i,label:n,bodyIds:[],x:Ti(),y:Ti(),value:Ti()},this.bins.set(i,o)),o.label=n,o.lastBodyId=e.id,o.lastDatum=e.datum,Ni(o.x,e.x),Ni(o.y,e.y),Ni(o.value,s),r>0&&(o.bodyIds.push(e.id),o.bodyIds.length>r&&(o.bodyIds=o.bodyIds.slice(o.bodyIds.length-r))),Li(o)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(Li)}restore(e=[]){this.bins.clear();for(let t of e)this.bins.set(t.id,{id:t.id,label:t.label,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:Fi(t.x),y:Fi(t.y),value:Fi(t.value)});this.nextIndex=e.reduce((e,t)=>e+t.count,0)}totals(){let e=this.snapshot();return{bins:e.length,count:e.reduce((e,t)=>e+t.count,0),total:e.reduce((e,t)=>e+t.total,0)}}};function Xi(e,t={}){let{baselineY:i=0,binWidth:n=24,gap:s=2,maxHeight:r=80,value:o="count",x:a}=t,l=e.reduce((e,t)=>Math.max(e,t[o]),1);return e.map((e,t)=>{let d=Math.max(0,e[o]/l*r),h=a?.(e,t)??t*(n+s);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:h,y:i-d,width:n,height:d,meanX:e.x.mean,meanY:e.y.mean}})}var Wi={bodyLimit:Number.POSITIVE_INFINITY,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},zi={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function Gi(e={},t=zi){return{chartId:e.chartId??t.chartId,chartType:e.chartType??t.chartType,sensors:e.sensors??t.sensors,onObservation:e.onObservation??t.onObservation,onSimulationStateChange:e.onSimulationStateChange??t.onSimulationStateChange}}function Vi(e){return{...e,shape:{...e.shape},...e.fixedPosition?{fixedPosition:{...e.fixedPosition}}:{},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function _i(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:void 0}let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function Hi(e,t){let i=e;if(null!=i[t])return i[t];let n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function Ui(e,t,i){return"function"==typeof i?_i(i(e,t)):"string"==typeof i?_i(Hi(e,i)):_i(e.spawnAt)??_i(Hi(e,"arrivalTime"))??_i(Hi(e,"timestamp"))??_i(Hi(e,"time"))??_i(Hi(e,"eventTime"))}function Ki(e,t={}){let i=_i(t.startAt)??0,n=t.pacing??"immediate";if("arrival"===n){let n=1/0,s=e.map((e,i)=>{let s=Ui(e,i,t.timeAccessor);return null!=s&&(n=Math.min(n,s)),s}),r=_i(t.timeScale)??1,o=r>0?r:1;return e.map((e,t)=>{let r=s[t],a=null==r?0:Math.max(0,r-n);return{...Vi(e),spawnAt:i+a/o}})}if("object"==typeof n){let t=_i(n.ratePerSec);if(t&&t>0)return e.map((e,n)=>({...Vi(e),spawnAt:i+n/t}))}return e.map(e=>({...Vi(e),spawnAt:i}))}function Qi(e){return{...Vi(e),sequence:e.sequence,spawnAt:e.spawnAt}}function Zi(e){return e.map(e=>({...e,shape:{...e.shape},bodyFilter:e.bodyFilter&&"function"!=typeof e.bodyFilter?{...e.bodyFilter,oneOf:e.bodyFilter.oneOf?.slice(),notOneOf:e.bodyFilter.notOneOf?.slice()}:e.bodyFilter}))}function Ji(e){return!1!==e&&{...e}}function en(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function tn(e){return{...e,gravity:{...e.gravity}}}function nn(e,t,i,n){if("circle"===e.shape.type){let s=e.x-t,r=e.y-i,o=e.shape.radius+n,a=s*s+r*r;return a<=o*o?a:null}let s=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),r=Math.max(Math.abs(i-e.y)-e.shape.height/2,0),o=s*s+r*r;return o<=n*n?o:null}function sn(e,t){return`${e}\0${t}`}function rn(e){let t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function on(e,t={}){let{idPrefix:i="plot",includeFloor:n=!0,includeCeiling:s=!1,includeLeftWall:r=!0,includeRightWall:o=!0,wallThickness:a=20,floorThickness:l=a}=t,d=[],h=e.x+e.width/2,u=e.y+e.height/2,c=(e,t,n,s,r)=>{d.push({id:`${i}-${e}`,shape:{type:"aabb",x:t,y:n,width:s,height:r}})};return n&&c("floor",h,e.y+e.height+l/2,e.width+2*a,l),s&&c("ceiling",h,e.y-l/2,e.width+2*a,l),r&&c("left-wall",e.x-a/2,u,a,e.height+2*l),o&&c("right-wall",e.x+e.width+a/2,u,a,e.height+2*l),d}function an(e){let{idPrefix:t="bin",count:i,domainStart:n,domainStep:s,xScale:r,yTop:o,yBottom:a,wallThickness:l=4,includeBoundaryWalls:d=!0,includeInteriorWalls:h=!0,closedBefore:u,lidY:c=o,lidThickness:p=Math.max(2,l)}=e,f=[],m=o+(a-o)/2,y=Math.abs(a-o),x=d?i:i-1;if(h||d)for(let e=d?0:1;e<=x;e+=1){if(!h&&e>0&&e<i)continue;let o=r(n+e*s);f.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:o,y:m,width:l,height:y}})}if(null!=u)for(let e=0;e<i;e+=1){let i=n+e*s,o=i+s;if(o>=u)continue;let a=r(i),d=r(o);f.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,d)+l/2,y1:c,x2:Math.max(a,d)-l/2,y2:c,thickness:p}})}return f}var ln=class{constructor(e={}){this.id="builtin",this.capabilities={...(new Ai).capabilities,engine:"builtin"},this.world=new Ai(e)}init(e={}){this.world.init(e)}spawn(e){this.world.spawn(e)}remove(e){this.world.remove(e)}setColliders(e){this.world.setColliders(e)}setConstraint(e){return this.world.setConstraint(e)}removeConstraint(e){this.world.removeConstraint(e)}applyImpulse(e,t,i){this.world.applyImpulse(e,t,i)}step(e){this.world.step(e)}settle(e,t){return this.world.settle(e,t)}readState(e){return this.world.readState(e)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(e){this.world.restore(e)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function dn(e={}){return new ln(e)}function hn(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):dn(t)}function un(e){let t=Number(e);if(Number.isFinite(t)&&!(t<=0))return Math.floor(t)}function cn(e,t,i){if(!1===i)return;let n=un(i?.warnAt);return null!=n?n:null!=e?Math.max(1,Math.floor(.8*e)):null!=t?Math.max(1,Math.floor(.8*t)):void 0}function pn(e){let t=Math.max(0,Math.floor(e.liveBodies)),i=Math.max(0,Math.floor(e.queuedBodies??0)),n=t+i,s=un(e.bodyLimit),r=un(e.engineMaxBodiesHint),o=cn(s,r,e.options),a=null==s?0:Math.max(0,t-s),l=a>0?"overflow":null!=o&&n>=o?"warning":"ok";return{action:"overflow"!==l?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:s,engineMaxBodiesHint:r,liveBodies:t,overflow:a,projectedBodies:n,queuedBodies:i,state:l,warnAt:o}}var fn={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function mn(e,t){let i={...e};for(let e of t)i[fn[e]]++;return i}function yn(e,t,i){let n=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:n,revisions:mn(i,n)}}var xn=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=yn({kind:"initialize"},[],this.revisions),this.listeners=/* @__PURE__ */new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){let i=yn(e,t,this.revisions);this.revisions=i.revisions,this.latest=i;for(let e of[...this.listeners])e();return i}};import{quadtree as gn}from"d3-quadtree";var vn=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,i,n,s,r=0,o){let a=this.ensure(e,t);if(!a)return null;let l=null,d=Number.POSITIVE_INFINITY,h=Math.max(0,o?.searchRadius??Math.max(0,r)+this.maxSearchRadius),u=n-h,c=n+h,p=s-h,f=s+h;return a.visit((e,t,a,h,m)=>{if(h<u||t>c||m<p||a>f)return!0;if(e.length)return!1;let y=e;for(;y;){let e=y.data;if(e&&(!o?.include||o.include(e))){let t=o?.distanceSquared?o.distanceSquared(e,n,s):nn(e,n,s,Math.max(0,r));null!=t&&(t<d||t===d&&i.indexOf(e.id)>i.indexOf(l?.id??""))&&(l=e,d=t)}y=y.next}return!1}),l}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;let i=e.readState();return 0===i.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=i.reduce((e,t)=>{return Math.max(e,"circle"===(i=t).shape.type?i.shape.radius:Math.hypot(i.shape.width,i.shape.height)/2);var i},0),this.tree=gn().x(e=>e.x).y(e=>e.y).addAll(i),this.revision=t,this.tree)}},bn=["data","scene-geometry","data-paint","accessibility","evidence"],wn=["scene-geometry","data-paint","accessibility","evidence"],Sn=["overlay","accessibility","evidence"],Mn=(e,t)=>({retainedData:e,invalidations:t}),In=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],kn=["scene-geometry","data-paint","accessibility","evidence"],$n=[],Bn={engine:/* @__PURE__ */Mn("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:/* @__PURE__ */Mn("preserve",kn),colliders:/* @__PURE__ */Mn("preserve",kn),sediment:/* @__PURE__ */Mn("preserve",kn),bodyBudget:/* @__PURE__ */Mn("preserve",In),bodyLimit:/* @__PURE__ */Mn("preserve",In),eviction:/* @__PURE__ */Mn("preserve",In),fixedDt:/* @__PURE__ */Mn("preserve",$n),maxDeltaSeconds:/* @__PURE__ */Mn("preserve",$n),maxSubsteps:/* @__PURE__ */Mn("preserve",$n),settleStepLimit:/* @__PURE__ */Mn("preserve",$n),timeScale:/* @__PURE__ */Mn("preserve",$n),observation:/* @__PURE__ */Mn("preserve",$n)},On=/* @__PURE__ */Mn("preserve",In);function An(e){let t="preserve",i=/* @__PURE__ */new Set;for(let n of e){let e=Bn[n]??On;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}var Cn=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function Tn(e,t){return e===t||!(!e||!t||e.gravity?.x!==t.gravity?.x||e.gravity?.y!==t.gravity?.y)&&Cn.every(i=>e[i]===t[i])}function Nn(e,t){return Object.keys(e).filter(i=>"kernel"===i?!Tn(e.kernel,t.kernel):e[i]!==t[i])}function Pn(e,t,i){if(!t.some(e=>"sleep"===e.type))return;let n=new Map(e.readState().map(e=>[e.id,e]));for(let e of t){if("sleep"!==e.type)continue;let t=n.get(e.bodyId);i.emit({type:"physics-settle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:e.bodyId,datum:t?.datum,x:t?.x,y:t?.y})}}function Fn(e,t,i){let n=new Set(e.activeSensorPairs().map(e=>sn(e.sensorId,e.bodyId))),s=n.size!==t.size;if(!s)for(let e of n)if(!t.has(e)){s=!0;break}if(!s)return n;let r=new Map(e.readState().map(e=>[e.id,e])),o=(e,t)=>{let{sensorId:n,bodyId:s}=rn(t),o=i.observation.sensors[n],a=r.get(s);i.emit({type:"enter"===e?o?.enterType??"physics-bin-enter":o?.exitType??"physics-bin-exit",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:s,datum:a?.datum,x:a?.x,y:a?.y,sensorId:n,binId:o?.binId??n})};for(let e of Array.from(n).sort())t.has(e)||o("enter",e);for(let e of Array.from(t).sort())n.has(e)||o("exit",e);return n}function qn(e,t){for(let i of e)t.has(rn(i).bodyId)&&e.delete(i)}function Dn(e,t,i,n){return e||!t?"paused":i||!n?"running":"settled"}function Yn(e,t,i){i.observation.onSimulationStateChange?.(t,e),("running"===t||"settled"===t)&&i.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,simulationState:t,previousSimulationState:e})}function En(e,t){t.emit({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:t.elapsedSeconds,chartType:t.observation.chartType,chartId:t.observation.chartId,budgetAction:e.action,bodyLimit:e.bodyLimit,engineMaxBodiesHint:e.engineMaxBodiesHint,liveBodies:e.liveBodies,overflow:e.overflow,projectedBodies:e.projectedBodies,queuedBodies:e.queuedBodies,warnAt:e.warnAt})}function jn(e,t,i){if("sleeping-first"!==t)return i.slice();let n=new Map(e.readState().map(e=>[e.id,e.sleeping])),s=[],r=[];for(let e of i)n.get(e)?s.push(e):r.push(e);return[...s,...r]}function Ln(e,t,i,n){let s=new Map(e.readState().map(e=>[e.id,e])),r=[];for(let e of i){let i=s.get(e);if(!i)continue;let o=t.add(i);o&&(r.push(e),n.emit({type:"physics-sediment",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:e,datum:i.datum,x:i.x,y:i.y,binId:o.id,count:o.count,total:o.total}))}return r}function Rn(e,t,i,n,s,r){let o={evicted:[],sedimented:[],liveBodyOrder:s};if(!1===i)return o;let a=Math.max(0,Math.floor(n));if(!Number.isFinite(a))return o;let l=s.length-a;if(l<=0)return o;let d=jn(e,i,s).slice(0,l);if(0===d.length)return o;let h=Ln(e,t,d,r);e.remove(d);let u=new Set(d);return{evicted:d,sedimented:h,liveBodyOrder:s.filter(e=>!u.has(e))}}function Xn(e){let t=e?.sleepSpeed;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:8}var Wn=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(e){this.speed=Xn(e)}reset(){this.seconds=0}isAtRest(){return this.seconds>=.6}refresh(e,t,i){if(i>0)return void(this.seconds=0);if(e.allSleeping())return void(this.seconds+=Math.max(0,t));let n=e.readState(this.scratch),s=this.speed*this.speed,r=!0;for(let e of n){if(e.sleeping)continue;let i=e.x-e.prevX,n=e.y-e.prevY;if(e.vx*e.vx+e.vy*e.vy>=s||t>0&&i*i+n*n>=s*t*t){r=!1;break}}this.seconds=r?this.seconds+Math.max(0,t):0}};function zn(e,t,i=!1){if(!e)return;let n=["spawned","evicted","sedimented","events","observations"],s={spawned:0,evicted:0,sedimented:0,events:0,observations:0},r=r=>{let o=t(r),a={...o};n.forEach(e=>{a[e]=o[e].slice(s[e]),s[e]=o[e].length}),(0!==r||i||!n.every(e=>0===a[e].length))&&e.onStep(a)};return r(0),()=>r(1)}function Gn(e,t,i,n={}){let s,r=0,o=0,a=t+(n.drainArrivals?Math.max(0,Math.ceil(((e.lastArrival()??e.elapsed())-e.elapsed())/e.fixedDt)):0);for(;r+o<a&&!n.shouldStop?.()&&(!1===n.stopAtRest||e.queueSize()>0||!e.atRest()||n.continueWhile?.());){let t=e.nextArrival(),l=n.skipIdle&&null!=t&&e.atRest()?Math.min(Math.max(0,Math.floor((t-e.elapsed())/e.fixedDt)-1),Math.max(0,a-r-o-1)):0;l>0&&(e.advanceTime(l*e.fixedDt),o+=l),e.step(e.fixedDt),e.advanceTime(e.fixedDt);let d=e.drainEvents();i.events&&(i.events.push(...d),e.observeKernelEvents(d,i.observations),e.observeSensorTransitions(i.observations));let h=[];if(e.spawnDue(h,i.observations),h.length>0){i.spawned.push(...h),s=e.observeBodyBudget(i.observations);let t=e.evictOverflow(i.observations);i.evicted?.push(...t.evicted),i.sedimented?.push(...t.sedimented)}r+=1,e.refreshQuiescence(e.fixedDt,h.length),n.afterStep?.()}return{steps:r,budget:s}}var Vn=class{constructor(e={}){this.activeSensorPairs=/* @__PURE__ */new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new vn,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.observedInitialBoundary=!1,this.updateResults=new xn,this.simulationState="settled",this.visible=!0,this.quiescence=new Wn;let{bodyBudget:t,colliders:i,engine:n,kernel:s,observation:r,sediment:o,...a}=e;this.config={...Wi,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=n,this.observation=Gi(r),this.sediment=new Ri(o??!1),this.world=hn(n,{fixedDt:this.config.fixedDt,...s}),this.quiescence.setKernelOptions(s),i&&this.world.setColliders(Zi(i))}updateConfig(e){let t=Nn(e,this.configInput),{colliders:i,bodyBudget:n,engine:s,kernel:r,observation:o,sediment:a,...l}=e;if(this.config={...this.config,...l},void 0!==n&&(this.bodyBudget=n,!1===n&&(this.bodyBudgetObservationKey="ok")),s&&s!==this.engineInput){let e=this.world.snapshot();this.world.dispose(),this.engineInput=s,this.world=hn(s,e.options),this.world.restore(e),this.revision+=1}if(r&&!Tn(r,this.configInput.kernel)){let e=this.world.snapshot(),t={...e.options,...r,gravity:{...e.options.gravity,...r.gravity}};this.world.restore({...e,options:t}),this.quiescence.setKernelOptions(t),this.revision+=1}o&&(this.observation=Gi(o,this.observation)),this.sediment.updateConfig(a),i&&(this.world.setColliders(Zi(i)),this.revision+=1),this.configInput={...this.configInput,...e};let d=An(t);this.updateResults.record({kind:"config",keys:t},d.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(Zi(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},An(["colliders"]).invalidations)}enqueue(e,t){let i=Array.isArray(e)?e:[e],n=t?Ki(i,{...t,startAt:t.startAt??this.elapsedSeconds}):i;for(let e of n)this.queue.push({...Vi(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(en),n.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:n.length},n.length?bn:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(Vi(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},bn)}materializeDueSpawns(){let e=this.revision,t=[],i=[];return this.spawnDue(t,i),0===t.length||(this.observeBodyBudget(i),this.evictOverflow(i),this.syncSimulationState(i),this.revision+=1,this.updateResults.record({kind:"enqueue",count:t.length},this.revision!==e?bn:[])),t}clear(){this.observedInitialBoundary=!1;let e=this.world.snapshot().options;this.world.init({...e,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.quiescence.reset(),this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},bn)}tick(e,t){let i=this.revision,n=[],s=[],r=[],o=[],a=[];if(this.paused||!this.visible){let e=this.result(0,n,s,r,o,a,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}let l=Math.max(0,Math.min(Number.isFinite(e)?e:0,this.config.maxDeltaSeconds))*this.config.timeScale;this.spawnDue(n,a);let d=this.observeBodyBudget(a),h=this.evictOverflow(a);s.push(...h.evicted),r.push(...h.sedimented),this.syncSimulationState(a),n.length>0&&this.quiescence.reset(),this.accumulator+=l;let u=this.stepObserver(t,{spawned:n,evicted:s,sedimented:r,events:o,observations:a}),c=l>0?Math.floor((this.accumulator+1e-9*this.config.fixedDt)/this.config.fixedDt):0,{steps:p,budget:f}=Gn(this.settleHost(),Math.min(c,this.config.maxSubsteps),{spawned:n,evicted:s,sedimented:r,events:o,observations:a},{stopAtRest:!1,shouldStop:()=>this.paused||!this.visible,afterStep:u});this.accumulator=Math.max(0,this.accumulator-p*this.config.fixedDt),p===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(p>0||n.length>0||s.length>0||r.length>0||o.length>0)&&(this.revision+=1);let m=this.result(p,n,s,r,o,a,void 0,f??d);return this.updateResults.record({kind:"tick",count:p},this.revision!==i?n.length||s.length||r.length?bn:wn:[]),m}settle(e){return this.runSettle(e,!1).steps}settleWithObservations(e,t){return this.runSettle(e,!0,t)}stepObserver(e,t){let i=!this.observedInitialBoundary;return e&&(this.observedInitialBoundary=!0),zn(e,e=>(e&&(this.revision+=1),this.result(e,t.spawned,t.evicted,t.sedimented,t.events,t.observations)),i)}settleHost(){return{fixedDt:this.config.fixedDt,queueSize:()=>this.queue.length,atRest:()=>this.atRest(),elapsed:()=>this.elapsedSeconds,nextArrival:()=>this.queue[0]?.spawnAt,lastArrival:()=>this.queue.at(-1)?.spawnAt,advanceTime:e=>{this.elapsedSeconds+=e},spawnDue:(e,t)=>this.spawnDue(e,t),observeBodyBudget:e=>this.observeBodyBudget(e),evictOverflow:e=>this.evictOverflow(e),step:e=>this.world.step(e),drainEvents:()=>this.world.events(),observeKernelEvents:(e,t)=>this.observeKernelEvents(e,t),observeSensorTransitions:e=>this.observeSensorTransitions(e),refreshQuiescence:(e,t)=>this.quiescence.refresh(this.world,e,t)}}runSettle(e,t,i){let n=this.revision,s=[],r=[],o=[],a=[],l=t?[]:void 0;if(t&&(this.paused||!this.visible)){let e=this.result(0,s,r,o,a,l??[],!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(s,l);let d=this.observeBodyBudget(l),h=this.evictOverflow(l);r.push(...h.evicted),o.push(...h.sedimented),this.syncSimulationState(l),s.length>0&&this.quiescence.reset();let u=t?{spawned:s,evicted:r,sedimented:o,events:a,observations:l}:{spawned:s},c=this.stepObserver(i,{spawned:s,evicted:r,sedimented:o,events:a,observations:l??[]}),{steps:p,budget:f}=Gn(this.settleHost(),e??this.config.settleStepLimit,u,{afterStep:c,continueWhile:i?.continueWhile,shouldStop:t?()=>this.paused||!this.visible:void 0,drainArrivals:void 0===e,skipIdle:void 0===e&&!i}),m=s.length+r.length+o.length>0;(p>0||m||a.length>0)&&(this.revision+=1);let y=this.result(p,s,r,o,a,l??[],void 0,f??d);return this.updateResults.record({kind:"settle",count:p},this.revision===n?[]:m?bn:wn),y}readBodies(e=[]){return this.world.readState(e)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(e={}){return Xi(this.readSediment(),e)}hitTest(e,t,i=0,n){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,i,n)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}atRest(){return this.world.allSleeping()||this.quiescence.isAtRest()}hasPendingWork(){return this.queue.length>0||!this.atRest()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(e){let{timestamp:t,chartType:i,chartId:n,...s}=e,r={...s,timestamp:t??this.elapsedSeconds,chartType:i??this.observation.chartType,chartId:n??this.observation.chartId};return this.emitObservation(r),this.updateResults.record({kind:"update",count:1},["evidence"]),r}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(e){return this.updateResults.subscribe(e)}version(){return this.revision}setPaused(e){let t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?Sn:[])}setVisible(e){let t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?Sn:[])}remove(e){let t=new Set(e),i=new Set(this.liveBodyOrder),n=new Set(this.queue.map(e=>e.id));this.queue=this.queue.filter(e=>!t.has(e.id)),this.liveBodyOrder=this.liveBodyOrder.filter(e=>!t.has(e)),this.world.remove(e),this.removeActiveSensorPairsForBodies(t);let s=e.filter(e=>i.has(e)||n.has(e));return s.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:s,count:s.length},s.length?bn:[]),s}setConstraint(e){let t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},wn),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},wn)}applyImpulse(e,t,i){this.world.applyImpulse(e,t,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},wn)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,i,n)=>e.applyImpulse(t,i,n),clear:()=>e.clear(),hitTest:(t,i,n)=>e.hitTest(t,i,n),pause:()=>e.setPaused(!0),push:(t,i)=>e.enqueue(t,i),pushMany:(t,i)=>e.enqueue(t,i),bodyBudgetStatus:()=>e.bodyBudgetStatus(),readBodies:t=>e.readBodies(t),readSediment:()=>e.readSediment(),recordObservation:t=>e.recordObservation(t),remove:t=>e.remove(t),restore:t=>e.restore(t),resume:()=>e.setPaused(!1),settle:t=>e.settle(t),settleWithObservations:t=>e.settleWithObservations(t),snapshot:()=>e.snapshot(),sedimentHeightfield:t=>e.sedimentHeightfield(t),sedimentTotals:()=>e.sedimentTotals(),step:t=>e.tick(t)};var e}snapshot(){let e=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:Ji(this.bodyBudget),config:{...this.config,kernel:tn(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(Qi),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:e}}restore(e){this.observedInitialBoundary=!1;let t=this.simulationState;this.config={bodyLimit:e.config.bodyLimit,eviction:e.config.eviction,fixedDt:e.config.fixedDt,maxDeltaSeconds:e.config.maxDeltaSeconds,maxSubsteps:e.config.maxSubsteps,settleStepLimit:e.config.settleStepLimit,timeScale:e.config.timeScale},this.configInput={...e.config,bodyBudget:Ji(e.bodyBudget??{}),kernel:tn(e.world.options)},this.bodyBudget=Ji(e.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.quiescence.setKernelOptions(e.world.options),this.quiescence.reset(),this.activeSensorPairs=new Set(e.activeSensorPairs),this.accumulator=e.accumulator,this.elapsedSeconds=e.elapsedSeconds,this.paused=e.paused,this.queue=e.queue.map(Qi).sort(en),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Dn(e.paused,e.visible,e.queue.length>0,e.world.bodies.every(e=>e.sleeping)),this.liveBodyOrder=e.liveBodyOrder.slice(),this.visible=e.visible,this.nextSequence=this.queue.reduce((e,t)=>Math.max(e,t.sequence),-1)+1,this.world.restore(e.world),this.updateResults.record({kind:"restore"},bn),this.simulationState!==t&&this.observation.onSimulationStateChange?.(this.simulationState,t)}spawnDue(e,t){for(;this.queue.length>0&&this.queue[0].spawnAt<=this.elapsedSeconds+1e-9*this.config.fixedDt;){let i=this.queue.shift();if(!i)return;this.spawnOne(i,t),e.push(i.id)}}spawnOne(e,t){this.liveBodyOrder=this.liveBodyOrder.filter(t=>t!==e.id),this.removeActiveSensorPairsForBodies(/* @__PURE__ */new Set([e.id])),this.world.spawn(e),this.liveBodyOrder.push(e.id);for(let t of e.springs??[])this.world.setConstraint({...t,bodyId:e.id});if(!t&&!this.observation.onObservation)return;let i=this.world.readState().find(t=>t.id===e.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:e.id,datum:i?.datum??e.datum,x:i?.x??e.x,y:i?.y??e.y},t)}result(e,t,i,n,s,r,o,a=this.evaluateBodyBudget()){this.syncSimulationState(r);let l=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:i,events:s,observations:r,queueSize:this.queue.length,revision:this.revision,shouldContinue:o??(!this.paused&&this.visible&&(this.queue.length>0||!this.atRest())),sleeping:l,sedimented:n,spawned:t,steps:e}}observeKernelEvents(e,t){Pn(this.world,e,this.observationContext(t))}observeSensorTransitions(e){this.activeSensorPairs=Fn(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){qn(this.activeSensorPairs,e)}observationContext(e){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:t=>this.emitObservation(t,e)}}emitObservation(e,t){t?.push(e),this.observation.onObservation?.(e)}evaluateBodyBudget(){return pn({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(e){let t=this.evaluateBodyBudget();if("ok"===t.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",t;let i=`${t.state}:${t.action}`;return i===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=i,En(t,this.observationContext(e))),t}syncSimulationState(e){let t=Dn(this.paused,this.visible,this.queue.length>0,this.atRest());if(t===this.simulationState)return;let i=this.simulationState;this.simulationState=t,Yn(i,t,this.observationContext(e))}evictOverflow(e){let{evicted:t,sedimented:i,liveBodyOrder:n}=Rn(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(e));return t.length>0&&(this.liveBodyOrder=n,this.removeActiveSensorPairsForBodies(new Set(t))),{evicted:t,sedimented:i}}};import*as _n from"react";import{Fragment as Hn,jsx as Un}from"react/jsx-runtime";var Kn={type:"flat",matrix:[1,0,0,1,0,0],lift:0,scale:1,bounds:null,project:(e,t)=>[e,t],unproject:(e,t)=>[e,t],depth:(e,t)=>t,groundTransform:"matrix(1 0 0 1 0 0)",billboardTransform:(e,t)=>`translate(${e},${t})`},Qn=/* @__PURE__ */Symbol.for("semiotic.networkPerspectiveContext");function Zn(){let e=globalThis;return e[Qn]??(e[Qn]=_n.createContext(Kn))}function Jn(){return _n.useContext(Zn())}function es(e,t,i){return t&&null!=e&&!1!==e?/* @__PURE__ */Un(ts,{frame:t,mode:i,children:e}):e}function ts({frame:e,mode:t,children:i}){if(!e)/* @__PURE__ */return Un(Hn,{children:i});let n=Zn();/* @__PURE__ */
27
- return Un(n.Provider,{value:e,children:"ground"===t?/* @__PURE__ */Un("g",{transform:e.groundTransform,children:i}):i})}import{Fragment as is,jsx as ns}from"react/jsx-runtime";function ss(e,t){return"top"===t?e.thickness??0:Number.isFinite(t)?t:0}function rs(e){let[t,i,n,s,r,o]=e.matrix;return 1===t&&0===i&&0===n&&1===s&&0===r&&0===o}var os=e=>Math.round(100*e)/100;function as({z:e=0,children:t}){let i=Jn();if(rs(i))/* @__PURE__ */return ns(is,{children:t});let[n,s,r,o,a,l]=i.matrix,d=l-i.lift*ss(i,e);/* @__PURE__ */
28
- return ns("g",{"data-perspective":"ground",transform:`matrix(${[n,s,r,o,a,d].map(os).join(" ")})`,children:t})}function ls({x:e,y:t,z:i="top",onGround:n=!1,children:s}){let r=Jn();if(rs(r)||!Number.isFinite(e)||!Number.isFinite(t))/* @__PURE__ */return ns(is,{children:s});let[o,a]=r.project(e,t,ss(r,i));if(!n)/* @__PURE__ */
29
- return ns("g",{"data-perspective":"billboard",transform:`translate(${os(o-e)},${os(a-t)})`,children:s});let[l,d,h,u]=r.matrix,c=Math.hypot(l,h)||1,p=[l/c,d/c,h/c,u/c].map(e=>Math.round(1e4*e)/1e4).join(" ");/* @__PURE__ */
30
- return ns("g",{"data-perspective":"on-ground",transform:`translate(${os(o)},${os(a)}) matrix(${p} 0 0) translate(${os(-e)},${os(-t)})`,children:s})}export{Wt as a,xn as b,i as c,M as d,I as e,k as f,p as g,f as h,w as i,S as j,o as k,n as l,a as m,h as n,c as o,K as p,zt as q,Gt as r,J as s,ne as t,se as u,re as v,oe as w,ae as x,le as y,de as z,he as A,ue as B,ce as C,pe as D,fe as E,me as F,ye as G,xe as H,ge as I,we as J,Se as K,Me as L,Ie as M,ke as N,$e as O,Be as P,Ce as Q,ki as R,Bi as S,Xi as T,on as U,an as V,Vn as W,Pe as X,Fe as Y,qe as Z,je as _,Xe as $,We as aa,ze as ba,Ge as ca,Ve as da,_e as ea,He as fa,Ue as ga,Ke as ha,Qe as ia,Ze as ja,lt as ka,gt as la,vt as ma,bt as na,wt as oa,Nt as pa,es as qa,as as ra,ls as sa,Ft as ta,qt as ua,Dt as va,Yt as wa,Et as xa};
@@ -1,4 +0,0 @@
1
- function t(t,e){return"top"===e?t.thickness??0:Number.isFinite(e)?e:0}function e(t){let[e,r,n,i,o,s]=t.matrix;return 1===e&&0===r&&0===n&&1===i&&0===o&&0===s}function r({z:r=0,children:n}){let i=d();if(e(i))/* @__PURE__ */return h(f,{children:n});let[o,s,a,u,l,c]=i.matrix,p=c-i.lift*t(i,r);/* @__PURE__ */
2
- return h("g",{"data-perspective":"ground",transform:`matrix(${[o,s,a,u,l,p].map(g).join(" ")})`,children:n})}function n({x:r,y:n,z:i="top",onGround:o=!1,children:s}){let a=d();if(e(a)||!Number.isFinite(r)||!Number.isFinite(n))/* @__PURE__ */return h(f,{children:s});let[u,l]=a.project(r,n,t(a,i));if(!o)/* @__PURE__ */
3
- return h("g",{"data-perspective":"billboard",transform:`translate(${g(u-r)},${g(l-n)})`,children:s});let[c,p,m,j]=a.matrix,y=Math.hypot(c,m)||1,b=[c/y,p/y,m/y,j/y].map(t=>Math.round(1e4*t)/1e4).join(" ");/* @__PURE__ */
4
- return h("g",{"data-perspective":"on-ground",transform:`translate(${g(u)},${g(l)}) matrix(${b} 0 0) translate(${g(-r)},${g(-n)})`,children:s})}async function i(t,e,r={}){let{execution:n="auto",signal:i,workerThreshold:o,nodeRadius:s,...a}=r,u=a.iterations??260;if(!p()||!c(n,t.length,e.length,u,o))return l(t,e,{...a,nodeRadius:s});let d={kind:"normalized",nodes:t.map(t=>({...t})),edges:e.map(t=>({...t})),options:a,nodeRadii:"function"==typeof s?Object.fromEntries(t.map(t=>[t.id,s(t)])):null==s?void 0:Object.fromEntries(t.map(t=>[t.id,s]))};try{let{runForceLayoutWorker:t}=await(import("./c-VW3UFK54.min.js"));return(await t(d,i)).positions}catch(r){if("AbortError"===r?.name)throw r;return l(t,e,{...a,nodeRadius:s})}}function o(t){let e=[];for(let r of Object.keys(t).sort()){let n=t[r];if(void 0!==n){if("function"==typeof n)return null;e.push(`${r}:${String(n)}`)}}return e.join("|")}function s(t,e,r){return null==r?null:x.get(t)?.get(e)?.get(r)??null}function a(t,e,r,n){if(null==r)return;let i=x.get(t);i||(i=/* @__PURE__ */new WeakMap,x.set(t,i));let o=i.get(e);if(o||(o=/* @__PURE__ */new Map,i.set(e,o)),!o.has(r)&&o.size>=16){let t=o.keys().next().value;void 0!==t&&o.delete(t)}o.set(r,n)}function u(t,e,r={}){let n=m(),{seed:u,iterations:d,repulsion:c,linkDistance:p,linkStrength:f,centerStrength:h,damping:g,nodeRadius:x,nodePadding:w,inset:v,execution:$,workerThreshold:R}=r,M=y(()=>({seed:u,iterations:d,repulsion:c,linkDistance:p,linkStrength:f,centerStrength:h,damping:g,nodeRadius:x,nodePadding:w,inset:v,execution:$,workerThreshold:R}),[u,d,c,p,f,h,g,x,w,v,$,R]),S=b(n),[F,E]=k(()=>{if(typeof window>"u"||n){let r=l(t,e,M);return a(t,e,o(M),r),{positions:r,status:"ready",error:null}}let r=s(t,e,o(M));return r?{positions:r,status:"ready",error:null}:{positions:null,status:"pending",error:null}});return j(()=>{if(S.current)return void(S.current=!1);let r=o(M),n=s(t,e,r);if(n)return void E(t=>"ready"===t.status&&t.positions===n?t:{positions:n,status:"ready",error:null});let u=new AbortController;return E(t=>({positions:t.positions,status:"pending",error:null})),i(t,e,{...M,signal:u.signal}).then(n=>{a(t,e,r,n),E({positions:n,status:"ready",error:null})}).catch(t=>{"AbortError"!==t.name&&E(e=>({positions:e.positions,status:"error",error:t}))}),()=>u.abort()},[t,e,M]),F}import{q as l}from"./c-RXJH4IRX.min.js";import{a as d}from"./c-73TOIYIW.min.js";import{b as c,c as p}from"./c-NIYSAQGB.min.js";import{ja as m}from"./c-2U5JMOPN.min.js";import{Fragment as f,jsx as h}from"react/jsx-runtime";var g=t=>Math.round(100*t)/100;import{useEffect as j,useMemo as y,useRef as b,useState as k}from"react";var x=/* @__PURE__ */new WeakMap;export{r as a,n as b,u as c};
@@ -1,51 +0,0 @@
1
- function e(e){let{accessor:t,data:o,isPushMode:i}=e,a=Qt(null),[r,n]=Ut(0),l=Yt(e=>{if(!i||!t)return;let o=!1;for(let i of e){let e="function"==typeof t?t(i):i[t];if(null==e)continue;let r="number"==typeof e?e:Number(e);Number.isFinite(r)&&(a.current?(r<a.current[0]&&(a.current[0]=r,o=!0),r>a.current[1]&&(a.current[1]=r,o=!0)):(a.current=[r,r],o=!0))}o&&n(e=>e+1)},[i,t]),s=Yt(()=>{i&&(a.current=null,n(e=>e+1))},[i]);return{domain:Kt(()=>{if(i)return a.current??void 0;if(!t||0===o.length)return;let e="function"==typeof t?t:e=>e[t],r=1/0,n=-1/0;for(let t of o){let o=e(t);if(null==o)continue;let i="number"==typeof o?o:Number(o);Number.isFinite(i)&&(i<r&&(r=i),i>n&&(n=i))}return Number.isFinite(r)&&Number.isFinite(n)?[r,n]:void 0},[o,t,i,r]),trackPushed:l,reset:s}}function t(e,t){return Ht(1===t?.5:e/(t-1))}function o(e){return e instanceof Date?`date:${e.getTime()}`:`${typeof e}:${String(e)}`}function i(e,t){let o=t=>e[Math.max(0,Math.min(e.length-1,Math.round(Number(t))))],i=e.every(e=>"number"==typeof e||e instanceof Date),r=t?void 0:a(e);return(a,n,l)=>{if(0===e.length)return"";let s=o(a);return t?t(s,n,l&&i?l.map(e=>Number(o(e).valueOf())):void 0):s instanceof Date&&r?r(s):String(s)}}function a(e){let t=e.filter(e=>e instanceof Date&&Number.isFinite(e.valueOf()));if(0===t.length)return;let o=t.every(e=>e.valueOf()%864e5==0),i=o&&t.every(e=>1===e.getUTCDate());if(i&&t.every(e=>0===e.getUTCMonth()))return e=>String(e.getUTCFullYear());if(i)return e=>`${be(e).split(" ")[0]} ${e.getUTCFullYear()}`;let a=t.map(e=>e.valueOf()),r=[Math.min(...a),Math.max(...a)];if(o){let e=new Date(r[0]).getUTCFullYear()===new Date(r[1]).getUTCFullYear();return t=>e?be(t):`${be(t)}, ${t.getUTCFullYear()}`}return xe(r)}function r(e,t,o){return"function"==typeof e?e(t,o):t[e]}function n(e,t){if(!e?.length)return;let i=new Map(t.map((e,t)=>[o(e),t]));return e.map(e=>{let t={...e},a=a=>{if(!(a in e))return;let r=i.get(o(e[a]));void 0!==r&&(t[a]=r)};return a("x"),a("x0"),a("x1"),"string"==typeof e.type&&("x-threshold"===e.type||"x"===e.type)&&a("value"),t})}function l(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 s(e){return"string"==typeof e&&""!==e.trim()?e:void 0}function c(e){let{seriesOrder:t,overallOrder:o,highlightTop:i,color:a,colorScheme:r,neutralColor:n,themeCategorical:l,themeNeutral:s}=e;if(null==i&&null==a)return r;let c="string"==typeof r?[...Bt(r,l)]:r,h=null==i?o.length:Math.max(0,Math.floor(i)),m=new Set(o.slice(0,h)),d=/* @__PURE__ */new Map,u={};for(let e of t)Object.defineProperty(u,e,{configurable:!0,enumerable:!0,writable:!0,value:a??(m.has(e)?Wt(void 0,l,c,e,d):n??s??"#b8bec8")});return u}function h(e,t={}){let i=t.xAccessor??"x",a=t.yAccessor??"y",n=t.lineBy??"series",l=t.rankDirection??"descending",s=[],c=/* @__PURE__ */new Map,h=/* @__PURE__ */new Map,m=[],d=/* @__PURE__ */new Map,u=1/0,p=-1/0;e.forEach((e,t)=>{let l=r(i,e,t),f=o(l),y=c.get(f);null==y&&(y=s.length,c.set(f,y),s.push(l),h.set(y,[]));let g=String(r(n,e,t));d.has(g)||(d.set(g,m.length),m.push(g));let b=Number(r(a,e,t));Number.isFinite(b)&&(u=Math.min(u,b),p=Math.max(p,b),h.get(y)?.push({datum:e,inputIndex:t,series:g,value:b}))});let f=[],y=/* @__PURE__ */new Map,g=/* @__PURE__ */new Map;for(let e=0;e<s.length;e++){let t=h.get(e)??[];t.sort((e,t)=>("descending"===l?t.value-e.value:e.value-t.value)||(d.get(e.series)??0)-(d.get(t.series)??0)),t.forEach((t,o)=>{let i=o+1;f.push({datum:t.datum,xIndex:e,xValue:s[e],series:t.series,value:t.value,rank:i}),y.set(t.series,(y.get(t.series)??0)+i),g.set(t.series,(g.get(t.series)??0)+1)})}let b=m.length+1,x=[...m].sort((e,t)=>{let o=g.get(e)??0,i=g.get(t)??0;return((y.get(e)??0)+(s.length-o)*b)/Math.max(1,s.length)-((y.get(t)??0)+(s.length-i)*b)/Math.max(1,s.length)||(d.get(e)??0)-(d.get(t)??0)}),v=null==t.highlightTop?x.length:Math.max(0,Math.floor(t.highlightTop)),w=new Set(x.slice(0,v));return{data:f.map(e=>{let t=w.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:s,seriesOrder:m,overallOrder:x,valueExtent:u===1/0?[0,0]:[u,p]}}function m({tooltip:e,xValues:t,xFormat:o,yFormat:a}){let r=uo(()=>i(t,o),[o,t]),n=mo(e=>a?a(e):e.toLocaleString(),[a]),l=it(e),s=uo(()=>l?void 0:st(e),[l,e]),c=mo(t=>{let o=t?.data??t;return o&&!1!==e?s?s({...t,data:o.__bumpRaw,__semioticHoverData:!0}):/* @__PURE__ */fo(Ge,{children:[
2
- /* @__PURE__ */po("div",{style:{fontWeight:700},children:o.__bumpSeries}),
3
- /* @__PURE__ */fo("div",{children:[r(o.x)," · Rank ",o.__bumpRank]}),
4
- /* @__PURE__ */fo("div",{children:["Value: ",n(o.__bumpValue)]})]}):null},[n,r,s,e]),h=mo(t=>{let o=(Array.isArray(t.allSeries)?t.allSeries:[]).map(e=>{let t=e.datum;return{...e,value:t?.__bumpValue??e.value,rank:t?.__bumpRank,datum:t?.__bumpRaw??e.datum}}),i=t?.data??t,a={...i?.__bumpRaw??{},xValue:i?.__bumpXValue??t.xValue,allSeries:o};if(rt(e)&&"function"==typeof e.content)return e.content(a);let l=t.xValue??i?.x;/* @__PURE__ */
5
- return fo(Ge,{children:[null!=l&&/* @__PURE__ */po("div",{style:{fontWeight:700,marginBottom:4},children:r(l)}),o.map((e,t)=>/* @__PURE__ */fo("div",{style:{display:"flex",alignItems:"center",gap:6},children:[
6
- /* @__PURE__ */po("span",{style:{width:8,height:8,borderRadius:"50%",background:e.color,flexShrink:0}}),
7
- /* @__PURE__ */po("span",{style:{flex:1},children:e.group}),
8
- /* @__PURE__ */fo("span",{children:[null!=e.rank?`Rank ${e.rank} · `:"",n(e.value)]})]},`${e.group}-${t}`))]})},[n,r,e]);return{tooltip:uo(()=>{if(!1===e)return!1;let t=l?h:c,o=(l?rt(e)&&Xe(e.content):Xe(s))?Ve(t):t;return l?{mode:"multi",content:o}:o},[l,h,s,c,e]),formatX:r}}function d(e,t,o,i,a){let r=1-a;return r*r*r*e+3*r*r*a*t+3*r*a*a*o+a*a*a*i}function u(e,t,o,i,a){let r=1-a;return 3*r*r*(t-e)+6*r*a*(o-t)+3*a*a*(i-o)}function p(e,t,o,i,a){let r=[],n=(e.x+t.x)/2;for(let l=0;l<=a;l++){let s,c,h,m,p=l/a;"linear"===i?(s=e.x+(t.x-e.x)*p,c=e.y+(t.y-e.y)*p,h=t.x-e.x,m=t.y-e.y):(s=d(e.x,n,n,t.x,p),c=d(e.y,e.y,t.y,t.y,p),h=u(e.x,n,n,t.x,p),m=u(e.y,e.y,t.y,t.y,p)),r.push({x:s,y:c,dx:h,dy:m,radius:e.radius+(t.radius-e.radius)*p,datumIndex:p<.5?o:o+1})}return r}function f(e,t){let o=e.length-1,i=Math.sign(e[o][0]-e[t][0])||1,a=i*e[o][0],r=i*e[t][0];for(let n=t+1;n<o;n++){let t=Math.max(r,Math.min(a,i*e[n][0]));e[n][0]=i*t,r=t}for(let i=t;i<o;i++){let t=i;for(;t<o&&e[t+1][0]===e[i][0];)t++;for(let o=i+1;o<t;o++)e[o][1]=e[i][1]+(e[t][1]-e[i][1])*(o-i)/(t-i);i=t}let n=1e-6*(a-i*e[t][0])/(o-t);r=i*e[t][0];for(let l=t+1;l<o;l++){let t=Math.max(r+n,Math.min(i*e[l][0],a-(o-l)*n));e[l][0]=i*t,r=t}}function y(e,t={}){let o=[],i=[],a=[];if(e.length<2)return{topPath:o,bottomPath:i,datumIndices:a};let r=t.curve??"smooth",n=Math.max(2,Math.floor(t.samplesPerSegment??12));for(let t=0;t<e.length-1;t++){let l=Math.max(0,o.length-1),s=p(e[t],e[t+1],t,r,n);for(let e=0===t?0:1;e<s.length;e++){let t=s[e],r=Math.hypot(t.dx,t.dy)||1,n=-t.dy/r,l=t.dx/r,c=Math.max(0,t.radius);o.push([t.x+n*c,t.y+l*c]),i.push([t.x-n*c,t.y-l*c]),a.push(t.datumIndex)}f(o,l),f(i,l)}return{topPath:o,bottomPath:i,datumIndices:a}}function g(e,t){let o=0;for(let t of e)o+=(t.codePointAt(0)??0)>=11904?1.1:go.find(([e])=>e.test(t))?.[1]??(t.toLowerCase()!==t?.75:.62);return o*t*1.05}function b(e){let t=e.fontSize??12,o=!0===e.showLabels?"end":e.showLabels,i="end"===o||"both"===o||"auto"===o,a="start"===o||"both"===o,r=e.labels.reduce((e,o)=>Math.max(e,g(o,t)),0),n=Math.round(e.width*(e.maxSideFraction??.38)),l=g(String(Math.max(1,e.rankCount)),t),s=e.showAxes?8+l+6:8,c={start:s+4+(e.showAxes&&e.yLabel?24:0),end:12},h=e.legendSide?St({legendGroups:[{label:"",styleFn:()=>({}),items:e.labels.map(e=>({label:e}))}]},{sideGutter:0}):0,m=g("MMM",t),d=(t,o)=>Math.min(o+r,e.legendSide===t?Math.max(o+m,n-h):n),u={start:a?d("left",c.start):0,end:i?d("right",c.end):0},p=!1===e.showLabels?24:110;return{margin:{...yo,right:Math.max(p,u.end),left:Math.max(yo.left,u.start)},startLabelOffset:s,chrome:c,room:u,labelWidth:r,fontSize:t,hasStart:a,hasEnd:i}}function x(e,t){let o={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:o,sideGutter:{...t.hasStart&&{left:t.chrome.start+Math.min(o.start,t.labelWidth)},...t.hasEnd&&{right:t.chrome.end+Math.min(o.end,t.labelWidth)}}}}function v(e,t,o){if(g(e,o)<=t)return{text:e,truncated:!1};let i=Array.from(e),a=i.length-1;for(;a>0&&g(`${i.slice(0,a).join("")}…`,o)>t;)a--;return{text:`${i.slice(0,a).join("").trimEnd()}…`,truncated:!0}}function w(e,t,o,i){let a=Math.max(1,Math.floor(t/18)),r="auto"===o?Number.isFinite(i)&&(i??0)>=0?Math.min(a,Math.floor(i)):a:1/0,n=e.map((e,t)=>({candidate:e,index:t})).sort((e,t)=>{let o=e.candidate.priority??0;return(t.candidate.priority??0)-o||Number(t.candidate.highlighted)-Number(e.candidate.highlighted)||e.candidate.rank-t.candidate.rank||e.index-t.index}),l=[];for(let{candidate:e}of n){if(l.length>=r)break;l.some(t=>t.side===e.side&&Math.abs(t.y-e.y)<14)||l.push(e)}return new Set(l.map(e=>e.id))}function A({datum:e,x:t,y:o,side:i,color:a,highlighted:r,labelStyle:n,offset:l,budget:s,fontSize:c}){let h=Oe(),m=h.isActive&&!h.predicate(e),d="function"==typeof n?n(e.__bumpRaw):n,u=null==s?{text:e.__bumpSeries,truncated:!1}:v(e.__bumpSeries,s,c);/* @__PURE__ */
9
- return xo("text",{className:"semiotic-bump-label",x:t+("end"===i?l:-l),y:o,dy:"0.35em",textAnchor:"end"===i?"start":"end",fill:a,fillOpacity:m?.16:1,fontWeight:r?650:450,fontSize:12,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 12px)",...d},children:[u.truncated&&/* @__PURE__ */bo("title",{children:e.__bumpSeries}),u.text]})}function S(e){let t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}function k(e,t,o){let[i,a]=t,[r,n]=o;return a===i?(r+n)/2:r+(n-r)*Math.max(0,Math.min(1,(e-i)/(a-i)))}function C(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 R(e){let t=e.config,o=/* @__PURE__ */new Map;for(let t of e.data){let e=o.get(t.__bumpSeries)??[];e.push(t),o.set(t.__bumpSeries,e)}let i=t.seriesOrder.filter(e=>o.has(e)).sort((e,i)=>(o.get(e)?.[0]?.__bumpHighlighted?1:0)-(o.get(i)?.[0]?.__bumpHighlighted?1:0)||t.seriesOrder.indexOf(e)-t.seriesOrder.indexOf(i)),a=[],r=[],n=[];for(let r of i){let i=(o.get(r)??[]).sort((e,t)=>e.x-t.x);if(i.length<2)continue;let l=i[0].__bumpHighlighted,s=(t.colorMap&&Dt(t.colorMap,r))??e.resolveColor(i[0].__bumpSeries,i[0]),c=t.color??(l?s:t.neutralColor??e.theme.semantic.textSecondary??e.theme.semantic.border??s),h=i.map(o=>({x:e.scales.x(o.x),y:e.scales.y(o.y),radius:t.ribbon?k(o.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),m=y(h,{curve:t.curve,samplesPerSegment:t.samplesPerSegment}),d={fill:c,fillOpacity:1,opacity:l?t.ribbon?t.ribbonOpacity:t.lineOpacity:Math.min(t.ribbon?t.ribbonOpacity:t.lineOpacity,.58)};t.styleRules?.length&&Object.assign(d,ot(i[0].__bumpRaw,t.styleRules,C(i[0]))),t.areaStyle&&Object.assign(d,t.areaStyle(i[0].__bumpRaw)??{}),void 0!==t.stroke&&(d.stroke=t.stroke),void 0!==t.strokeWidth&&(d.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(d.opacity=t.opacity),a.push({type:"area",topPath:m.topPath,bottomPath:m.bottomPath,_hitArea:!0,style:d,datum:m.datumIndices.map(e=>i[e]),accessibleDatum:i.map(e=>e.__bumpRaw),accessibility:{label:`${r} ranking trajectory`,tableFields:i.map(e=>e.__bumpRaw)},group:r,interactive:!0}),t.showPoints&&i.forEach((e,o)=>{let i={fill:c,stroke:"none",opacity:l?1:.75};t.styleRules?.length&&Object.assign(i,ot(e.__bumpRaw,t.styleRules,C(e))),t.pointStyle&&Object.assign(i,t.pointStyle(e.__bumpRaw)??{}),void 0!==t.stroke&&(i.stroke=t.stroke),void 0!==t.strokeWidth&&(i.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(i.opacity=t.opacity),a.push({type:"point",x:h[o].x,y:h[o].y,r:i.r??t.pointRadius,style:i,datum:e,accessibleDatum:e.__bumpRaw,accessibility:{label:`${r}, rank ${e.__bumpRank}, value ${e.__bumpValue}`},pointId:`${r}:${e.x}`})});let u=!0===t.showLabels?"end":t.showLabels,p=(e,o,i)=>{let a=null==t.labelPriorityAccessor?void 0:"function"==typeof t.labelPriorityAccessor?t.labelPriorityAccessor(e.__bumpRaw):Number(e.__bumpRaw[t.labelPriorityAccessor]);n.push({id:`${r}\0${i}`,datum:e,x:h[o].x,y:h[o].y,side:i,rank:e.__bumpRank,highlighted:l,priority:Number.isFinite(a)?a:void 0,color:"string"==typeof d.fill?d.fill:c})};("start"===u||"both"===u)&&p(i[0],0,"start"),("end"===u||"both"===u||"auto"===u)&&p(i.at(-1),i.length-1,"end")}let l=!0===t.showLabels?"end":t.showLabels,s=w(n,e.dimensions.plot.height,"auto"!==l||"auto",t.maxLabels);for(let e of n)s.has(e.id)&&r.push(
10
- /* @__PURE__ */bo(A,{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:a,overlays:r.length?/* @__PURE__ */bo("g",{className:"semiotic-bump-labels",children:r}):void 0,restyle:(e,t)=>{let o=S(e);if(t?.isActive&&o&&!t.predicate(o))return{opacity:.14}}}}function L({data:e,safeData:t,areaBy:o,lineDataAccessor:i}){if(null==e)return[];let a,r=void 0!==t[0]?.[i];if(!r&&!o)return t;if(r)a=t;else{let e=t.reduce((e,t)=>{let a="function"==typeof o?o(t):t[o],r=String(a);if(!e[r]){let t={[i]:[]};"string"==typeof o&&(t[o]=a),e[r]=t}return e[r][i].push(t),e},{});a=Object.values(e)}return a.flatMap(e=>{let t=Array.isArray(e[i])?e[i]:[];return"string"==typeof o?t.map(t=>({...t,[o]:t[o]??e[o]})):t})}function _(e){let{safeData:t,data:o,areaBy:i,lineDataAccessor:a,colorBy:r,colorScale:n,color:l,stroke:s,strokeWidth:c,opacity:h,effectiveSelectionHook:m,resolvedSelection:d,areaOpacity:u,showLine:p,lineWidth:f,showPoints:y,pointRadius:g,xAccessor:b,yAccessor:x,xLabel:v,yLabel:w,xFormat:A,yFormat:S,groupField:k,styleRules:C,ruleContext:R}=e,_=Co(()=>L({data:o,safeData:t,areaBy:i,lineDataAccessor:a}),[o,t,i,a]),H=Co(()=>e=>{let t={};if(r){if(n){let o=Mt(e,r,n);t.fill=o,p?(t.stroke=o,t.strokeWidth=f):t.stroke="none"}}else{let e=l||Pt;t.fill=e,p?(t.stroke=e,t.strokeWidth=f):t.stroke="none"}return t.fillOpacity=u,C&&C.length>0&&Object.assign(t,ot(e,C,R?R(e):{value:void 0})),t},[r,n,l,u,p,f,C,R]),I=Co(()=>Ne(H,{stroke:s,strokeWidth:c,opacity:h}),[H,s,c,h]);return{flattenedData:_,lineStyle:Co(()=>_t(I,m??null,d),[I,m,d]),pointStyle:Co(()=>{if(y)return e=>{let t={r:g,fillOpacity:1};return r?n&&(t.fill=Mt(e.parentLine||e,r,n)):t.fill=l||Pt,t}},[y,g,r,n,l]),defaultTooltipContent:Co(()=>Me([{label:v||Pe(b),accessor:b,role:"x",format:A},{label:w||Pe(x),accessor:x,role:"y",format:S},...k?[{label:Pe(k),accessor:k,role:"group"}]:[],...Be(e.band,S)]),[b,x,v,w,k,A,S,e.band])}}function H(e,t,o,i){if(!e.length)return[];let a=e.filter(e=>Number.isFinite(t(e))).sort((e,o)=>t(e)-t(o)),r=[],n=0,l=null,s=null,c=[],h=(e,t)=>e>t?"A":t>e?"B":null,m=e=>`seg-${n}-${e}`,d=e=>r.push(e),u=(e,t)=>{d({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:m(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;e<a.length;e++){let r=a[e],p=t(r),f=o(r),y=i(r);if(!Number.isFinite(p)||!Number.isFinite(f)||!Number.isFinite(y))continue;let g=h(f,y);if(null!==g){if(null==l){l=g;for(let e of c)u(e,l);c=[],d({__x:p,__y:f>=y?f:y,__y0:f>=y?y:f,__diffSegment:m(l),__diffWinner:l,__valA:f,__valB:y,__sourceDatum:r}),s={x:p,a:f,b:y,w:g};continue}if(s&&s.w!==g){let e,t;if(c.length>0)e=c[0].x,t=c[0].y;else{let o=f-s.a-(y-s.b);if(0!==o){let i=(s.b-s.a)/o,a=Math.max(0,Math.min(1,i));e=s.x+a*(p-s.x),t=s.a+a*(f-s.a)}else e=s.x,t=s.a}d({__x:e,__y:t,__y0:t,__diffSegment:m(l),__diffWinner:l,__valA:t,__valB:t}),n++,l=g,d({__x:e,__y:t,__y0:t,__diffSegment:m(l),__diffWinner:l,__valA:t,__valB:t});for(let e=1;e<c.length;e++)u(c[e],l)}else for(let e of c)u(e,l);c=[],d({__x:p,__y:f>=y?f:y,__y0:f>=y?y:f,__diffSegment:m(l),__diffWinner:l,__valA:f,__valB:y,__sourceDatum:r}),s={x:p,a:f,b:y,w:g}}else c.push({x:p,y:f,datum:r})}for(let e of c)u(e,l??"A");return r}function I(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 F(e,t){return at(e,t,e=>{let t=Number(e.__x),o=Number(e.__y);return{value:Number.isFinite(o)?o:void 0,x:Number.isFinite(t)?t:void 0,y:Number.isFinite(o)?o:void 0,category:I(e)}},e=>e.__sourceDatum?{...e.__sourceDatum,...e}:e)}function P(e){let{seriesAColor:t,seriesBColor:o,areaOpacity:i,styleRules:a}=e;return F(e=>({fill:"A"===I(e)?t:o,stroke:"none",fillOpacity:i}),a)}function B(e){let{seriesAColor:t,seriesBColor:o,lineWidth:i,styleRules:a}=e;return F(e=>({stroke:"A"===I(e)?t:o,strokeWidth:i,fill:"none"}),a)}function M(e){let{seriesAColor:t,seriesBColor:o,pointRadius:i,styleRules:a}=e;return F(e=>({fill:"A"===I(e)?t:o,r:i}),a)}function D(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();if("string"==typeof e){if(""===e.trim())return NaN;let t=+e;return Number.isFinite(t)?t:NaN}return NaN}function T(e,t,o,i){if(!e.length)return[];let a=e.filter(e=>Number.isFinite(t(e))).sort((e,o)=>t(e)-t(o)),r=[];for(let e of a){let a=t(e),n=o(e),l=i(e);Number.isFinite(n)&&r.push({__x:a,__y:n,__diffSegment:"line-A",__diffWinner:"A",__sourceDatum:e}),Number.isFinite(l)&&r.push({__x:a,__y:l,__diffSegment:"line-B",__diffWinner:"B",__sourceDatum:e})}return r}function W(e){let[t,o]=li.useState(()=>ci);return li.useEffect(()=>{if(t)return;let e=!1;return(ci?Promise.resolve(ci):(hi||(hi=import("./c-MXKN7S3R.min.js").then(e=>ci=e.ScatterplotMatrixBrushOverlay).catch(e=>{throw hi=null,e})),hi)).then(t=>{e||o(()=>t)}).catch(()=>{}),()=>{e=!0}},[t]),t?/* @__PURE__ */si(t,{...e}):null}function N({data:e,xField:t,yField:o,fieldLabels:i,cellSize:a,pointRadius:r,pointOpacity:n,styleRules:l,colorBy:s,colorScale:c,brushSelectionName:h,hoverSelectionName:m,unselectedOpacity:d,showGrid:u,maxDevicePixelRatio:p,mobileInteraction:f,mode:y,onPointHover:g,onPointClick:b}){Se(me);let x=ni(null),v=ft({name:h,clientId:`splom-${t}-${o}`,fields:[t,o]}),w=yt({name:h,xField:t,yField:o}),A=ft({name:m,clientId:"splom-hover-source",fields:[ui]}),S=A.selectPoints,k=ri(e=>{e?w.brushInteraction.during(e):w.brushInteraction.end(null)},[w.brushInteraction]),C=ri(e=>{if(!e)return void g?.(null);let t=e.data,o=t?.[ui];void 0!==o&&(S({[ui]:[o]}),g?.(t,e.x+pi.left,e.y+pi.top))},[S,g]),R=ri(e=>{if(!e)return void b?.(null);let t=e.data;t&&b?.(t,e.x+pi.left,e.y+pi.top)},[b]),L=ai(()=>tt(t,o),[t,o]),_=ai(()=>at(e=>({opacity:n,r:r,fill:s?Mt(e,s,c):Pt}),l,L),[n,r,s,c,l,L]),H=ri(e=>{let t={..._(e)};return"hover"===y?A.isActive&&A.predicate(e)?(t.opacity=1,t.r=2.5*r,t.stroke="#333",t.strokeWidth=1.5):A.isActive&&(t.opacity=.6*("number"==typeof t.opacity?t.opacity:n)):v.isActive&&!v.predicate(e)&&(t.opacity=d),t},[_,y,A,v,d,r,n]);/* @__PURE__ */
11
- return di("div",{style:{position:"relative",width:a,height:a},children:[
12
- /* @__PURE__ */mi(we,{ref:x,chartType:"scatter",data:e,size:[a,a],xAccessor:t,yAccessor:o,pointStyle:H,margin:pi,showAxes:!1,maxDevicePixelRatio:p,enableHover:"hover"===y,accessibleTable:!1,description:`${Dt(i,t)??t} versus ${Dt(i,o)??o} scatterplot`,...Te({forceHoverBehavior:"hover"===y,forceClickBehavior:!!b,mobileInteraction:f,customHoverBehavior:C,customClickBehavior:R}),tooltipContent:"hover"===y?()=>null:void 0}),"brush"===y&&/* @__PURE__ */mi(W,{frameRef:x,cellSize:a,onBrush:k})]})}function O({data:e,field:t,label:o,cellSize:i,bins:a,colorBy:r,colorScale:n,brushSelectionName:l,hoverSelectionName:s,unselectedOpacity:c,mode:h}){let m=ft({name:l,clientId:`splom-diag-${t}`,fields:[t]}),d=ft({name:s,clientId:`splom-diag-${t}-hover`,fields:[ui]}),u="hover"===h?d:m,p=u.isActive,f=u.predicate,y=ai(()=>{let o="string"==typeof r?r:null,n=[],l=/* @__PURE__ */new Set;for(let i of e){let e=i[t];if(null!=e&&!isNaN(e)&&n.push(Number(e)),o){let e=i[o];null!=e&&l.add(String(e))}}if(0===n.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};let[s,c]=jt(n),h=(c-s)/a||1,m=Array.from(l),d=new Map(m.map((e,t)=>[e,t])),u=new Array(a).fill(0),y=new Array(a).fill(0),g=Array.from({length:a},()=>new Array(m.length).fill(0)),b=Array.from({length:a},()=>new Array(m.length).fill(0));for(let i of e){let e=i[t];if(null==e||isNaN(e))continue;let r=Math.min(Math.floor((e-s)/h),a-1);if(u[r]++,(!p||f(i))&&y[r]++,o){let e=d.get(String(i[o]));void 0!==e&&(g[r][e]++,(!p||f(i))&&b[r][e]++)}}let x=zt(u,1),v=g.map((e,t)=>{let o=0;return e.map((e,r)=>{let n=e/x*(i-24),l={x:t/a*i,w:i/a-1,h:n,y0:o,category:m[r]};return o+=n,l})}),w=b.map((e,t)=>{let o=0;return e.map((e,r)=>{let n=e/x*(i-24),l={x:t/a*i,w:i/a-1,h:n,y0:o,category:m[r]};return o+=n,l})});return{bars:u.map((e,t)=>({x:t/a*i,w:i/a-1,h:e/x*(i-24),count:e})),selectedBars:y.map((e,t)=>({x:t/a*i,w:i/a-1,h:e/x*(i-24),count:e})),categoryBars:v,selectedCategoryBars:w,max:x,categories:m}},[e,t,a,i,p,f,r]);/* @__PURE__ */
13
- return di("svg",{width:i,height:i,style:{overflow:"hidden"},children:[
14
- /* @__PURE__ */mi("text",{x:i/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"var(--semiotic-text, #333)",fontFamily:"var(--semiotic-font-family, sans-serif)",children:o}),y.categories.length>0?y.categoryBars.map((e,t)=>e.map((e,o)=>/* @__PURE__ */mi("rect",{x:e.x,y:i-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:n?n(e.category):Pt,opacity:p?.3:.6},`bg-${t}-${o}`))):y.bars.map((e,t)=>/* @__PURE__ */mi("rect",{x:e.x,y:i-e.h,width:Math.max(e.w,1),height:e.h,fill:Pt,opacity:p?.3:.6},`bg-${t}`)),p&&(y.categories.length>0?y.selectedCategoryBars.map((e,t)=>e.map((e,o)=>/* @__PURE__ */mi("rect",{x:e.x,y:i-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:n?n(e.category):Pt,opacity:.7},`sel-${t}-${o}`))):y.selectedBars.map((e,t)=>/* @__PURE__ */mi("rect",{x:e.x,y:i-e.h,width:Math.max(e.w,1),height:e.h,fill:Pt,opacity:.7},`sel-${t}`)))]})}function E({label:e,cellSize:t}){/* @__PURE__ */
15
- return mi("svg",{width:t,height:t,children:/* @__PURE__ */mi("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"var(--semiotic-text, #333)",fontFamily:"var(--semiotic-font-family, sans-serif)",children:e})})}function j(e){let{data:t,fields:o,fieldLabels:i={},colorBy:a,colorScheme:r,cellSize:n=150,cellGap:l=4,pointRadius:s=2,pointOpacity:c=.5,diagonal:h="histogram",histogramBins:m=20,brushMode:d="crossfilter",hoverMode:u=!0,unselectedOpacity:p=.1,showGrid:f=!1,maxDevicePixelRatio:y,tooltip:g,showLegend:b,idAccessor:x,styleRules:v,width:w,height:A,className:S,title:k,description:C,summary:R,accessibleTable:L=!0,onObservation:_,onClick:H,chartId:I}=e,F="splom",P="splom-hover",B=gt(e.mobileInteraction,{mode:e.mode,width:w??o.length*n,mobileSemantics:e.mobileSemantics}),M=u?"hover":d?"brush":"hover",D=Ot(e=>e.clearSelection),[T,W]=ii(null),j=oi(()=>{D(P),W(null)},[D,P]),z=ti(()=>(t||[]).map((e,t)=>void 0!==e[ui]?e:{...e,[ui]:t}),[t]),G=Ue(z,a,r),$=`${ei.useId().replace(/:/g,"")}-data-table`,V=ti(()=>(t||[]).map(e=>({type:"point",datum:e})),[t]),X=ti(()=>st(g),[g]),Y=(o.length,40),K=oi((e,t,o,i)=>[Y+l+e*(n+l)+(o??0),t*(n+l)+(i??0)],[Y,n,l]),Q=void 0!==b?b:!!a,U=ti(()=>{if(!Q||!a)return null;let e="string"==typeof a?a:null;return e?Array.from(new Set(z.map(t=>t[e]).filter(e=>null!=e))).map(e=>({label:String(e),color:G?G(String(e)):Pt})):null},[Q,a,z,G]),q=ti(()=>({display:"grid",gridTemplateColumns:`40px ${o.map(()=>`${n}px`).join(" ")}`,gridTemplateRows:`${o.map(()=>`${n}px`).join(" ")} 40px`,gap:`${l}px`,width:"fit-content"}),[o,n,l,Y]);/* @__PURE__ */
16
- return yi("div",{className:S,style:{position:"relative",color:"var(--semiotic-text, #333)",fontFamily:"var(--semiotic-font-family, sans-serif)"},role:"group","aria-label":C||k||`Scatterplot matrix comparing ${o.length} fields`,children:[k&&/* @__PURE__ */fi("div",{className:"semiotic-chart-title",style:{fontWeight:600,marginBottom:8},children:k}),L&&/* @__PURE__ */fi(xt,{accessibleTable:L,children:/* @__PURE__ */fi(kt,{tableId:$})}),
17
- /* @__PURE__ */fi(At,{summary:R}),U&&/* @__PURE__ */fi("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:U.map(e=>/* @__PURE__ */yi("div",{style:{display:"flex",alignItems:"center",gap:4},children:[
18
- /* @__PURE__ */fi("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),
19
- /* @__PURE__ */fi("span",{style:{fontSize:11},children:e.label})]},e.label))}),
20
- /* @__PURE__ */yi("div",{style:{position:"relative",width:"fit-content"},children:[
21
- /* @__PURE__ */yi("div",{style:q,onMouseLeave:"hover"===M?j:void 0,children:[o.map((e,t)=>/* @__PURE__ */yi(ei.Fragment,{children:[
22
- /* @__PURE__ */fi("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"var(--semiotic-text, #333)"},children:Dt(i,e)??e}),o.map((o,r)=>t===r?"label"===h?/* @__PURE__ */fi(E,{label:Dt(i,e)??e,cellSize:n},`diag-${e}`):/* @__PURE__ */fi(O,{data:z,field:e,label:Dt(i,e)??e,cellSize:n,bins:m,colorBy:a,colorScale:G,brushSelectionName:F,hoverSelectionName:P,unselectedOpacity:p,mode:M},`diag-${e}`):/* @__PURE__ */fi(N,{data:z,xField:o,yField:e,fieldLabels:i,cellSize:n,pointRadius:s,pointOpacity:c,styleRules:v,colorBy:a,colorScale:G,brushSelectionName:F,hoverSelectionName:P,unselectedOpacity:p,showGrid:f,maxDevicePixelRatio:y,mobileInteraction:B,mode:M,onPointHover:"hover"===M?(i,a,n)=>{if(i){if(W({datum:i,xField:o,yField:e,colIndex:r,rowIndex:t,px:a??0,py:n??0}),_){let[e,o]=K(r,t,a,n);_({type:"hover",datum:i,x:e,y:o,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:I})}}else W(null),_&&_({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:I})}:void 0,onPointClick:H||_?(e,o,i)=>{if(!e)return;let[a,n]=K(r,t,o,i);H&&H(e,{x:a,y:n}),_&&_({type:"click",datum:e,x:a,y:n,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:I})}:void 0},`cell-${e}-${o}`))]},`row-${e}`)),
23
- /* @__PURE__ */fi("div",{})," ",o.map(e=>/* @__PURE__ */fi("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"},children:Dt(i,e)??e},`col-label-${e}`))]}),T&&"hover"===M&&!1!==g&&(()=>{let e=T.datum,t=Dt(i,T.xField)??T.xField,r=Dt(i,T.yField)??T.yField,s=a?"function"==typeof a?a(e):e[a]:null,c=x?"function"==typeof x?x(e):e[x]:`Row ${e[ui]}`,h=Y+l+T.colIndex*(n+l),m=T.rowIndex*(n+l),d=h+T.px,u=m+T.py,p={...e};delete p[ui];let f="function"==typeof X,y=f?X(p):null,g=/* @__PURE__ */yi(Ge,{style:{color:"var(--semiotic-tooltip-text, #333)",background:"var(--semiotic-tooltip-bg, rgba(255,255,255,0.95))",border:"1px solid var(--semiotic-border, #ddd)",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",boxShadow:"none"},children:[
24
- /* @__PURE__ */fi("div",{style:{fontWeight:"bold",marginBottom:2},children:String(c)}),
25
- /* @__PURE__ */yi("div",{children:[t,": ",null!=e[T.xField]?Number(e[T.xField]).toFixed(1):"–"]}),
26
- /* @__PURE__ */yi("div",{children:[r,": ",null!=e[T.yField]?Number(e[T.yField]).toFixed(1):"–"]}),null!=s&&/* @__PURE__ */yi("div",{style:{opacity:.8},children:["string"==typeof a?a:"group",": ",String(s)]})]}),b=f?y:g;return Rt(b)?/* @__PURE__ */fi(Ke,{contentOwnsChrome:Xe(X),x:d,y:u,containerWidth:Y+o.length*n+o.length*l,containerHeight:o.length*n+Y+o.length*l,margin:{top:0,right:0,bottom:0,left:0},className:"scatterplot-matrix-tooltip",zIndex:10,children:b}):null})()]}),L&&/* @__PURE__ */fi(xt,{accessibleTable:L,children:/* @__PURE__ */fi(wt,{scene:V,chartType:"scatterplot matrix",tableId:$,chartTitle:k})})]})}function z(e){let[t,o]=Si.useState(()=>Ci);return Si.useEffect(()=>{if(t)return;let e=!1;return(Ci?Promise.resolve(Ci):(Ri||(Ri=import("./c-VSOQPII4.min.js").then(e=>Ci=e.MinimapBrush).catch(e=>{throw Ri=null,e})),Ri)).then(t=>{e||o(()=>t)}).catch(()=>{}),()=>{e=!0}},[t]),t?/* @__PURE__ */ki(t,{...e}):null}function G(e){let t=e.handles&&"object"==typeof e.handles?e.handles:e.handles?{}:null,o="number"==typeof t?.size&&Number.isFinite(t.size)?t.size:12;return{top:t?.move?Math.ceil(U(o)/2)+2:0,bottom:e.showExtentLabels?34:20}}function $(e,t){return{label:t?.label??e.label,color:t?.color??e.color,opacity:t?.opacity??e.opacity}}function V(e,t,o){let i=Bt(t,o,Ft),a=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 o=e.label||`Series ${t+1}`,r=a?.[o];return"string"==typeof r&&r.length>0?r:i[t%i.length]})}function X(e,t){let o=et(e),i=t.map((e,t)=>({label:e.label||`Series ${t+1}`,readY:et(e.yAccessor)}));return(e,t)=>{let a=String(e[Vi]??t??""),r=(i.find(e=>e.label===a)??i[0])?.readY(e);return{value:r,x:o(e),y:r,category:a||void 0}}}function Y(e,t){let o=1/0,i=-1/0,a="function"==typeof t?t:e=>e[t];for(let t of e){let e=a(t);null!=e&&isFinite(e)&&(e<o&&(o=e),e>i&&(i=e))}if(!isFinite(o)||!isFinite(i))return[0,1];if(o===i){let e=0===o?1:.1*Math.abs(o);return[o-e,i+e]}return[o,i]}function K(e,t){let o=t[1]-t[0];return 0===o?.5:(e-t[0])/o}function Q(e,t){return t[0]+e*(t[1]-t[0])}import{a as U}from"./c-XN6FERBN.min.js";import{a as q}from"./c-27DCB5T6.min.js";import{a as Z,b as J,c as ee,d as te}from"./c-3VZHOPFW.min.js";import{a as oe}from"./c-PDQHLOKU.min.js";import{a as ie,c as ae}from"./c-L3LKYOLK.min.js";import{c as re}from"./c-CZI7G7G2.min.js";import{a as ne,b as le,c as se}from"./c-6O5WWP7F.min.js";import{a as ce}from"./c-2RG4WOVX.min.js";import{a as he,b as me,c as de,d as ue,g as pe,h as fe}from"./c-AE4M7BWH.min.js";import{e as ye}from"./c-UZJAWWAI.min.js";import{b as ge,c as be,d as xe,e as ve,f as we,g as Ae}from"./c-HXUOFDSD.min.js";import{a as Se,h as ke,j as Ce,k as Re}from"./c-TT4CTEBR.min.js";import{j as Le,k as _e,l as He,m as Ie,n as Fe}from"./c-BSLJZUTD.min.js";import{F as Pe,H as Be,I as Me,V as De,W as Te,X as We,Y as Ne}from"./c-QMKQVCCZ.min.js";import{b as Oe}from"./c-IU4QZ7Y5.min.js";import{$a as Ee,Aa as je,Ab as ze,Ba as Ge,Bb as $e,Ca as Ve,Da as Xe,Db as Ye,Ea as Ke,Eb as Qe,Gb as Ue,Ib as qe,Jb as Ze,Kb as Je,Lb as et,Mb as tt,Qb as ot,Ra as it,Rb as at,Sa as rt,Ta as nt,Va as lt,Wa as st,ab as ct,b as ht,cb as mt,db as dt,eb as ut,fb as pt,jb as ft,mb as yt,qb as gt,r as bt,ra as xt,v as vt,va as wt,wa as At,x as St,xa as kt,xb as Ct,za as Rt}from"./c-2U5JMOPN.min.js";import{e as Lt,f as _t}from"./c-2OZMC2MZ.min.js";import{b as Ht,d as It,m as Ft,n as Pt,o as Bt,r as Mt,s as Dt,u as Tt,v as Wt}from"./c-ZOE7TAR3.min.js";import{c as Nt}from"./c-SSKV5JPW.min.js";import{p as Ot,w as Et}from"./c-CNYFCSG4.min.js";import{a as jt,c as zt}from"./c-3PFVJFBK.min.js";import{useMemo as Gt,useCallback as $t,forwardRef as Vt,useRef as Xt}from"react";import{useCallback as Yt,useMemo as Kt,useRef as Qt,useState as Ut}from"react";import{jsx as qt}from"react/jsx-runtime";var Zt=/* @__PURE__ */Ee(/* @__PURE__ */Vt(function(t,o){ge(q),Se(me);let i=Xt(null),a=Je(t.mode,{width:t.width,height:t.height,showAxes:t.showAxes,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:t.xLabel,yLabel:t.yLabel,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules}),{data:r,margin:n,className:l,xFormat:s,yFormat:c,xAccessor:h="x",yAccessor:m="y",xScaleType:d,yScaleType:u,colorBy:p,colorScheme:f,styleRules:y,sizeBy:g,sizeRange:b=[3,15],symbolBy:x,symbolMap:v,pointRadius:w=5,pointOpacity:A=.8,tooltip:S,marginalGraphics:k,pointIdAccessor:C,annotations:R,regression:L,forecast:_,anomaly:H,xExtent:I,yExtent:F,pulse:P,decay:B,staleness:M,frameProps:D={},selection:T,linkedHover:W,linkedBrush:N,brush:O,onBrush:E,onObservation:j,onClick:z,hoverHighlight:G,chartId:$,loading:V,loadingContent:X,emptyContent:Y,legendInteraction:K,legendPosition:Q,color:U,stroke:ee,strokeWidth:te,opacity:ie}=t,{width:ae,height:ne,enableHover:ce,showGrid:he,showLegend:de,title:ue,description:pe,summary:fe,accessibleTable:ye,xLabel:be,yLabel:xe}=a,ve=Gt(()=>ht(r),[r]),ke=void 0===r,{domain:Ce,trackPushed:Re,reset:Le}=e({accessor:g,data:ve,isPushMode:ke}),_e=$t(e=>{Re([e]),i.current?.push(e)},[Re]),He=$t(e=>{Re(e),i.current?.pushMany(e)},[Re]);se(o,{variant:"xy",frameRef:i,overrides:{push:_e,pushMany:He,clear:()=>{Le(),i.current?.clear()}}});let Ie=le({data:ve,rawData:r,colorBy:p,colorScheme:f,legendInteraction:K,legendPosition:Q,frameLegend:D,selection:T,linkedHover:W,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!1,onObservation:j,onClick:z,hoverHighlight:G,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"Scatterplot",chartId:$,showLegend:de,userMargin:n,marginDefaults:a.marginDefaults,loading:V,loadingContent:X,emptyContent:Y,width:ae,height:ne,hasTitle:!!ue,axisChrome:vt(D,{showAxes:a.showAxes,xLabel:be,yLabel:xe})}),{brushStreamProps:Fe}=Ae({brush:O,onBrush:E,linkedBrush:N,xAccessor:h,yAccessor:m,defaultDimension:"xy"});pt("Scatterplot",ve,"xAccessor",h),pt("Scatterplot",ve,"yAccessor",m);let Be=Gt(()=>g?Ce??[0,1]:void 0,[g,Ce]),Ne=Gt(()=>g?e=>Tt(e,g,b,Be):void 0,[g,b,Be]),Oe=Gt(()=>tt(h,m),[h,m]),Ee=Z({colorBy:p,colorScale:Ie.colorScale,color:U,pointRadius:w,fillOpacity:A,radiusFn:Ne,stroke:ee,strokeWidth:te,opacity:ie,styleRules:y,ruleContext:Oe,effectiveSelectionHook:Ie.effectiveSelectionHook,resolvedSelection:Ie.resolvedSelection}),{effectiveData:je,statisticalAnnotations:ze,hasForecast:Ge,xAccessorKey:$e,yAccessorKey:Ve}=J({data:ve,xAccessor:h,yAccessor:m,forecast:_,anomaly:H}),Xe=Ge?$e:h,Ye=Ge?Ve:m,Ke=Gt(()=>Me([{label:be||Pe(h),accessor:Xe,role:"x",format:s},{label:xe||Pe(m),accessor:Ye,role:"y",format:c},...p?[{label:Pe(p),accessor:p,role:"color"}]:[],...g?[{label:Pe(g),accessor:g,role:"size"}]:[]]),[h,m,Xe,Ye,be,xe,p,g,s,c]),Qe=Gt(()=>{let e=oe(L),t=R||[];return e||0!==ze.length?[...e?[e]:[],...t,...ze]:R},[L,R,ze]);if(Ie.earlyReturn)return Ie.earlyReturn;let Ue=re({componentName:"Scatterplot",data:r,accessors:{xAccessor:h,yAccessor:m}});if(Ue)/* @__PURE__ */return qt(ct,{componentName:"Scatterplot",message:Ue,width:ae,height:ne});let qe={chartType:"scatter",...null!=r&&{data:je},xAccessor:Xe,yAccessor:Ye,xScaleType:d,yScaleType:u,colorAccessor:p||void 0,sizeAccessor:g||void 0,...x&&{symbolAccessor:x},...v&&{symbolMap:v},sizeRange:b,pointStyle:Ee,colorScheme:f,size:[ae,ne],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Ie.margin,showAxes:a.showAxes,xLabel:be,yLabel:xe,xFormat:s,yFormat:c,enableHover:ce,showGrid:he,...Ie.legendBehaviorProps,...De({title:ue,description:pe,summary:fe,accessibleTable:ye,className:l,animate:t.animate,maxDevicePixelRatio:t.maxDevicePixelRatio,axisExtent:t.axisExtent,autoPlaceAnnotations:t.autoPlaceAnnotations}),...We({tooltip:S,defaultTooltipContent:Ke}),...Te({linkedHover:W,selection:T,onObservation:j,onClick:z,hoverHighlight:G,hoverRadius:t.hoverRadius,mobileInteraction:Ie.mobileInteraction,customHoverBehavior:Ie.customHoverBehavior,customClickBehavior:Ie.customClickBehavior}),...k&&{marginalGraphics:k},...C&&{pointIdAccessor:C},...P&&{pulse:P},...B&&{decay:B},...M&&{staleness:M},...Qe&&Qe.length>0&&{annotations:Qe},...I&&{xExtent:I},...F&&{yExtent:F},...Fe,...Ie.crosshairProps,...D};/* @__PURE__ */
27
- return qt(mt,{componentName:"Scatterplot",width:ae,height:ne,children:/* @__PURE__ */qt(we,{ref:i,...qe})})}),"Scatterplot");import{useMemo as Jt,forwardRef as eo,useRef as to}from"react";import{Fragment as oo,jsx as io}from"react/jsx-runtime";var ao=/* @__PURE__ */Ee(/* @__PURE__ */eo(function(e,o){Se(me);let i=to(null);se(o,{variant:"xy",frameRef:i});let a=Je(e.mode,{width:e.width,height:e.height,showAxes:e.showAxes,showGrid:e.showGrid,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:r,margin:n,className:l,xFormat:s,yFormat:c,xAccessor:h="x",yAccessor:m="y",orderAccessor:d,orderLabel:u,styleRules:p,pointRadius:f=4,tooltip:y,pointIdAccessor:g,annotations:b,regression:x,forecast:v,anomaly:w,xExtent:A,yExtent:S,pulse:k,decay:C,staleness:R,frameProps:L={},selection:_,linkedHover:H,onObservation:I,onClick:F,hoverHighlight:P,chartId:B,loading:M,loadingContent:D,emptyContent:T,legendInteraction:W,stroke:N,strokeWidth:O,opacity:E}=e,{width:j,height:z,enableHover:G,showGrid:$,title:V,description:X,summary:Y,accessibleTable:K,xLabel:Q,yLabel:U}=a,{safeData:q,orderMap:ee}=Jt(()=>{let e=r||[],t="function"==typeof h?h:e=>e[h],o="function"==typeof m?m:e=>e[m],i=e;if(d&&e.length>0){let t="function"==typeof d?d:e=>e[d];i=[...e].sort((e,o)=>{let i=t(e),a=t(o);return(i instanceof Date?i.getTime():+i)-(a instanceof Date?a.getTime():+a)})}let a=/* @__PURE__ */new WeakMap,n=0;for(let e of i){let i=t(e),a=o(e);null!=i&&null!=a&&isFinite(i)&&isFinite(a)&&n++}let l=0;for(let e of i){let i=t(e),r=o(e);null!=i&&null!=r&&isFinite(i)&&isFinite(r)&&a.set(e,{idx:l++,total:n})}return{safeData:i,orderMap:a}},[r,d,h,m]);pt("ConnectedScatterplot",q,"xAccessor",h),pt("ConnectedScatterplot",q,"yAccessor",m);let te=le({data:q,rawData:r,colorBy:void 0,colorScheme:void 0,legendInteraction:W,selection:_,linkedHover:H,fallbackFields:[],unwrapData:!1,onObservation:I,onClick:F,hoverHighlight:P,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"ConnectedScatterplot",chartId:B,showLegend:void 0,userMargin:n,marginDefaults:a.marginDefaults,loading:M,loadingContent:D,emptyContent:T,width:j,height:z,hasTitle:!!V,axisChrome:vt(L,{showAxes:a.showAxes,xLabel:Q,yLabel:U})}),ie=te.resolvedSelection?.unselectedOpacity??Lt,ae=Jt(()=>(e,o)=>{let i=o.filter(e=>"point"===e.type);if(i.length<2)return;let a=te.effectiveSelectionHook?.isActive,r=te.effectiveSelectionHook?.predicate,n=i.length<100,l=i.length;e.lineCap="round";for(let o=0;o<l-1;o++){let s=i[o],c=i[o+1],h=t(o,l),m=!a||!r||r(s.datum??s)||r(c.datum??c),d=a?m?1:ie:1;n&&(e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(c.x,c.y),e.strokeStyle="white",e.lineWidth=f+2,e.globalAlpha=.5*d,e.stroke()),e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(c.x,c.y),e.strokeStyle=h,e.lineWidth=f,e.globalAlpha=d,e.stroke()}e.globalAlpha=1},[f,te.effectiveSelectionHook,ie]),ne=Jt(()=>[ae],[ae]),ce=Jt(()=>(e,o,i)=>{let a=e.filter(e=>"point"===e.type);if(a.length<2)return null;let r=a.length,n=r<100,l=[];for(let e=0;e<r-1;e++){let o=a[e],i=a[e+1],s=t(e,r),c="number"==typeof o.style?.opacity?o.style.opacity:1,h="number"==typeof i.style?.opacity?i.style.opacity:1,m=Math.min(c,h);n&&l.push(
28
- /* @__PURE__ */io("line",{x1:o.x,y1:o.y,x2:i.x,y2:i.y,stroke:"white",strokeWidth:f+2,strokeLinecap:"round",opacity:.5*m},`halo-${e}`)),l.push(
29
- /* @__PURE__ */io("line",{x1:o.x,y1:o.y,x2:i.x,y2:i.y,stroke:s,strokeWidth:f,strokeLinecap:"round",opacity:m},`seg-${e}`))}/* @__PURE__ */
30
- return io(oo,{children:l})},[f]),he=Jt(()=>[ce],[ce]),de=Jt(()=>e=>{let o=ee.get(e),i=o?.idx??0,a=o?.total??1;return{fill:a>0?t(i,a):"#6366f1",stroke:"white",strokeWidth:1,r:f,fillOpacity:1}},[f,ee]),ue=Jt(()=>tt(h,m),[h,m]),pe=Z({colorScale:void 0,baseStyleExtras:de,stroke:N,strokeWidth:O,opacity:E,styleRules:p,ruleContext:ue,effectiveSelectionHook:te.effectiveSelectionHook,resolvedSelection:te.resolvedSelection}),fe=u||("string"==typeof d?d:"Order"),{effectiveData:ye,statisticalAnnotations:ge,hasForecast:be,xAccessorKey:xe,yAccessorKey:ve}=J({data:q,xAccessor:h,yAccessor:m,forecast:v,anomaly:w}),Ae=be?xe:h,ke=be?ve:m,Ce=Jt(()=>Me([{label:Q||Pe(h),accessor:Ae,role:"x",format:s},{label:U||Pe(m),accessor:ke,role:"y",format:c},...d?[{label:fe,accessor:d,role:"group"}]:[]]),[h,m,Ae,ke,Q,U,d,fe,s,c]),Re=re({componentName:"ConnectedScatterplot",data:r,accessors:{xAccessor:h,yAccessor:m}});if(te.earlyReturn)return te.earlyReturn;let Le=oe(x),_e=b||[],He=Le||ge.length>0?[...Le?[Le]:[],..._e,...ge]:b,Ie={chartType:"scatter",...null!=r&&{data:ye},xAccessor:Ae,yAccessor:ke,pointStyle:pe,size:[j,z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:te.margin,showAxes:a.showAxes,xLabel:Q,yLabel:U,xFormat:s,yFormat:c,enableHover:G,showGrid:$,...De({title:V,description:X,summary:Y,accessibleTable:K,className:l,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...We({tooltip:y,defaultTooltipContent:Ce}),...Te({linkedHover:H,selection:_,onObservation:I,onClick:F,hoverHighlight:P,hoverRadius:e.hoverRadius,mobileInteraction:te.mobileInteraction,customHoverBehavior:te.customHoverBehavior,customClickBehavior:te.customClickBehavior}),...g&&{pointIdAccessor:g},...k&&{pulse:k},...C&&{decay:C},...R&&{staleness:R},canvasPreRenderers:ne,svgPreRenderers:he,...He&&He.length>0&&{annotations:He},...A&&{xExtent:A},...S&&{yExtent:S},...te.crosshairProps,...L};return Re?/* @__PURE__ */io(ct,{componentName:"ConnectedScatterplot",message:Re,width:j,height:z}):/* @__PURE__ */io(mt,{componentName:"ConnectedScatterplot",width:j,height:z,children:/* @__PURE__ */io(we,{ref:i,...Ie})})}),"ConnectedScatterplot");import{forwardRef as ro,useMemo as no}from"react";import{jsx as lo}from"react/jsx-runtime";var so=/* @__PURE__ */Ee(/* @__PURE__ */ro(function(e,t){Se(ye);let{data:o,layout:i,layoutConfig:a,onLayoutError:r,xExtent:n,yExtent:l,showAxes:s=!1,margin:c,className:h,annotations:m,onObservation:d,onClick:u,selection:p,linkedHover:f,hoverHighlight:y,chartId:g,loading:b,loadingContent:x,emptyContent:v,colorBy:w,colorScheme:A,legend:S,legendInteraction:k,legendPosition:C,frameProps:R={}}=e,{legend:L,..._}=R,H=no(()=>bt(L,S),[L,S]),{frameRef:I,resolved:F,safeData:P,setup:B,earlyReturn:M}=ae({imperativeRef:t,imperativeVariant:"xy",chartTypeLabel:"XYCustomChart",unwrapData:!1,data:o,colorBy:w,colorScheme:A,legend:H,legendInteraction:k,legendPosition:C,frameLegend:_,selection:p,linkedHover:f,hoverHighlight:y,onObservation:d,onClick:u,chartId:g,loading:b,loadingContent:x,emptyContent:v,margin:c,width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules,xLabel:e.xLabel,yLabel:e.yLabel}),D=B.effectiveSelectionHook,T=no(()=>D?.isActive?{isActive:!0,predicate:D.predicate}:null,[D?.isActive,D?.predicate]),W=no(()=>nt({tooltip:e.tooltip,defaultTooltipContent:e=>/* @__PURE__ */lo(ve,{hover:e})}),[e.tooltip]);if(M)return M;let{width:N,height:O,enableHover:E,showGrid:j,title:z,description:G,summary:$,accessibleTable:V,xLabel:X,yLabel:Y}=F,K={chartType:"custom",...null!=o&&{data:P},customLayout:i,layoutConfig:a,onLayoutError:r,...T&&{layoutSelection:T},xExtent:n,yExtent:l,colorAccessor:w,colorScheme:A,size:[N,O],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:B.margin,showAxes:s,xLabel:X,yLabel:Y,enableHover:E,showGrid:j,...B.legendBehaviorProps,...De({title:z,description:G,summary:$,accessibleTable:V,className:h,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...W,...Te({linkedHover:f,selection:p,onObservation:d,onClick:u,hoverRadius:e.hoverRadius,hoverHighlight:y,mobileInteraction:B.mobileInteraction,customHoverBehavior:B.customHoverBehavior,customClickBehavior:B.customClickBehavior}),...m&&m.length>0&&{annotations:m},...B.crosshairProps,..._};/* @__PURE__ */
31
- return lo(mt,{componentName:"XYCustomChart",width:N,height:O,children:/* @__PURE__ */lo(we,{ref:I,...K})})}),"XYCustomChart");import{forwardRef as co,useMemo as ho}from"react";import{useCallback as mo,useMemo as uo}from"react";import{jsx as po,jsxs as fo}from"react/jsx-runtime";var yo={top:20,bottom:48,left:48},go=[[/[mwMW@%…]/,.95],[/[ijlI'.,|\s]/,.28],[/[frt():;/[\]{}*`!\\-]/,.39]];import{jsx as bo,jsxs as xo}from"react/jsx-runtime";import{jsx as vo}from"react/jsx-runtime";var wo=/* @__PURE__ */Ee(/* @__PURE__ */co(function(e,t){let o=Ye(),i=Et(),{data:a,xAccessor:r,yAccessor:d,lineBy:u,rankDirection:p="descending",ribbon:f=!1,curve:y="smooth",ribbonSizeRange:g=[4,28],samplesPerSegment:v=12,lineWidth:w=3,highlightTop:A,neutralColor:S,styleRules:k,labelStyle:C,colorScheme:L,ribbonOpacity:_=.82,lineOpacity:H=.9,showPoints:I=!1,pointRadius:F=3,showLabels:P=!0,labelPriorityAccessor:B,maxLabels:M,showGrid:D=!0,showLegend:T=!1,enableHover:W=!0,hoverHighlight:N=!0,tooltip:O,frameProps:E={},xFormat:j,yFormat:z,onClick:G}=e,$=l(A),V=s(S),X=s(e.color),Y=Je(e.mode,{width:e.width,height:e.height,showAxes:e.showAxes,responsiveRules:e.responsiveRules}),K=ho(()=>h(a,{xAccessor:r,yAccessor:d,lineBy:u,rankDirection:p,highlightTop:$}),[a,r,d,u,p,$]),{axes:Q,areaStyle:U,pointStyle:q,margin:Z,...J}=E,ee="object"==typeof C&&"number"==typeof C?.fontSize?C.fontSize:12,te=e.legendPosition??"right",oe=!T||"left"!==te&&"right"!==te?void 0:te,ae=ho(()=>b({labels:K.seriesOrder,showLabels:P,width:Y.width,showAxes:Y.showAxes,rankCount:K.seriesOrder.length,yLabel:e.yLabel??"Rank",fontSize:ee,legendSide:oe}),[K.seriesOrder,P,Y.width,Y.showAxes,e.yLabel,ee,oe]),re=e.margin??Z,ne=ho(()=>({...ae.margin,...ie(re)}),[ae,re]),le=ho(()=>x(ne,ae),[ne,ae]),se=oe?le.sideGutter[oe]:void 0,ce=ho(()=>c({seriesOrder:K.seriesOrder,overallOrder:K.overallOrder,highlightTop:$,color:X,colorScheme:L,neutralColor:V,themeCategorical:o,themeNeutral:i.colors.textSecondary}),[K.seriesOrder,K.overallOrder,$,X,L,V,o,i.colors.textSecondary]),he=ho(()=>({ribbon:f,curve:y,samplesPerSegment:v,ribbonSizeRange:g,valueExtent:K.valueExtent,seriesOrder:K.seriesOrder,lineWidth:w,ribbonOpacity:_,lineOpacity:H,neutralColor:V,color:X,colorMap:ce&&"object"==typeof ce&&!Array.isArray(ce)?ce:void 0,stroke:e.stroke,strokeWidth:e.strokeWidth,opacity:e.opacity,styleRules:k,areaStyle:U,pointStyle:q,labelStyle:C,showPoints:I,pointRadius:F,showLabels:P,labelPriorityAccessor:B,maxLabels:M,startLabelOffset:ae.startLabelOffset,labelBudget:le.budget,labelFontSize:ee}),[f,y,v,g,K.valueExtent,K.seriesOrder,w,_,H,V,ce,X,e.stroke,e.strokeWidth,e.opacity,k,U,q,C,I,F,P,B,M,ae.startLabelOffset,le.budget,ee]),{tooltip:me,formatX:de}=m({tooltip:O,xValues:K.xValues,xFormat:j,yFormat:z}),ue=ho(()=>{if(G)return(e,t)=>{G(e.__bumpRaw??e,t)}},[G]),pe=Math.max(1,K.seriesOrder.length),fe=K.xValues.map((e,t)=>t),ye=Array.from({length:pe},(e,t)=>t+1),ge=Q??[{orient:"left",tickValues:ye,tickFormat:e=>String(e),label:e.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:fe,tickFormat:de,label:e.xLabel,tickAnchor:"edges"}],be=ho(()=>n(e.annotations,K.xValues),[e.annotations,K.xValues]);/* @__PURE__ */
32
- return vo(so,{ref:t,data:K.data,layout:R,layoutConfig:he,xExtent:[0,Math.max(1,K.xValues.length-1)],yExtent:[pe+.5,.5],showAxes:Y.showAxes,showGrid:D,showLegend:T,enableHover:W,hoverHighlight:N,colorBy:"__bumpSeries",colorScheme:ce,tooltip:me,onClick:ue,hoverRadius:e.hoverRadius,width:e.width,height:e.height,responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,responsiveRules:e.responsiveRules,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,mode:e.mode,margin:ne,className:e.className,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,selection:e.selection,linkedHover:e.linkedHover,legend:e.legend,legendInteraction:e.legendInteraction,legendPosition:e.legendPosition,onObservation:e.onObservation,chartId:e.chartId,loading:e.loading,loadingContent:e.loadingContent,emptyContent:e.emptyContent,animate:e.animate,autoPlaceAnnotations:e.autoPlaceAnnotations,annotations:be,xLabel:e.xLabel,yLabel:e.yLabel??"Rank",frameProps:{axes:ge,axisExtent:"exact",...J,...null!=se&&null==J.legendLayout?.sideGutter&&{legendLayout:{...J.legendLayout,sideGutter:se}}}})}),"BumpChart");import{useMemo as Ao,forwardRef as So,useRef as ko}from"react";import{useMemo as Co}from"react";import{jsx as Ro}from"react/jsx-runtime";var Lo=/* @__PURE__ */Ee(/* @__PURE__ */So(function(e,t){Se(Ce);let o=ko(null);se(t,{variant:"xy",frameRef:o});let i=Je(e.mode,{width:e.width,height:e.height,showAxes:e.showAxes,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:a,margin:r,className:n,xFormat:l,yFormat:s,xAccessor:c="x",yAccessor:h="y",areaBy:m,y0Accessor:d,gradientFill:u=!1,semanticGradient:p,semanticLine:f=!0,lineDataAccessor:y="coordinates",colorBy:g,colorScheme:b,styleRules:x,curve:v="monotoneX",areaOpacity:w=.7,lineGradient:A,showLine:S=!0,lineWidth:k=2,showPoints:C=!1,pointRadius:R=3,tooltip:L,annotations:H,forecast:I,anomaly:F,band:P,xExtent:B,yExtent:M,frameProps:D={},selection:T,linkedHover:W,onObservation:N,onClick:O,hoverHighlight:E,chartId:j,loading:z,loadingContent:G,emptyContent:$,legendInteraction:V,legendPosition:X,color:Y,stroke:K,strokeWidth:Q,opacity:U}=e,{width:q,height:Z,enableHover:ee,showGrid:te,showLegend:oe,title:ie,description:ae,summary:ne,accessibleTable:ce,xLabel:he,yLabel:me}=i,de=Ao(()=>ht(a),[a]),ue=g||m,pe=Ao(()=>He(p),[p]),fe=Ao(()=>pe?.stops.length?Fe(pe):Le(u),[pe,u]),ye=Ao(()=>_e(A),[A]),ge=Ao(()=>f?Ie(pe):void 0,[pe,f]);pt("AreaChart",de,"xAccessor",c),pt("AreaChart",de,"yAccessor",h);let be=le({data:de,rawData:a,colorBy:ue,colorScheme:b,legendInteraction:V,legendPosition:X,frameLegend:D,selection:T,linkedHover:W,fallbackFields:ue?["string"==typeof ue?ue:""]:[],unwrapData:!1,onObservation:N,onClick:O,hoverHighlight:E,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"AreaChart",chartId:j,showLegend:oe,userMargin:r,marginDefaults:i.marginDefaults,loading:z,loadingContent:G,emptyContent:$,width:q,height:Z,hasTitle:!!ie,axisChrome:vt(D,{showAxes:i.showAxes,xLabel:he,yLabel:me})}),{effectiveData:xe,statisticalAnnotations:ve,hasForecast:Ae,xAccessorKey:ke,yAccessorKey:Re}=J({data:de,xAccessor:c,yAccessor:h,forecast:I,anomaly:F,groupBy:m}),Be=Ae?ke:c,Me=Ae?Re:h,We=Ao(()=>tt(c,h),[c,h]),{flattenedData:Ne,lineStyle:Oe,pointStyle:Ee,defaultTooltipContent:je}=_({safeData:xe,data:a,areaBy:m,lineDataAccessor:y,colorBy:ue,colorScale:be.colorScale,color:Y,stroke:K,strokeWidth:Q,opacity:U,effectiveSelectionHook:be.effectiveSelectionHook,resolvedSelection:be.resolvedSelection,areaOpacity:w,showLine:S,lineWidth:k,showPoints:C,pointRadius:R,xAccessor:Be,yAccessor:Me,xLabel:he||Pe(c),yLabel:me||Pe(h),xFormat:l,yFormat:s,groupField:m||g,band:P,styleRules:x,ruleContext:We}),ze=re({componentName:"AreaChart",data:a,accessors:{xAccessor:c,yAccessor:h}}),Ge={chartType:"area",...null!=a&&{data:Ne},xAccessor:Be,yAccessor:Me,groupAccessor:m||void 0,...d&&{y0Accessor:d},...P&&{band:P},...fe&&{gradientFill:fe},...ye&&{lineGradient:ye},...ge&&{semanticLineStops:ge},curve:v,lineStyle:Oe,...C&&Ee&&{pointStyle:Ee},size:[q,Z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:be.margin,showAxes:i.showAxes,xLabel:he,yLabel:me,xFormat:l,yFormat:s,enableHover:ee,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:te,...be.legendBehaviorProps,...De({title:ie,description:ae,summary:ne,accessibleTable:ce,className:n,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...nt({tooltip:L,defaultTooltipContent:je,multiDefaultContent:lt({xFormat:l,yFormat:s})}),...Te({linkedHover:W,selection:T,onObservation:N,onClick:O,hoverHighlight:E,hoverRadius:e.hoverRadius,mobileInteraction:be.mobileInteraction,customHoverBehavior:be.customHoverBehavior,customClickBehavior:be.customClickBehavior}),...(H&&H.length>0||ve.length>0)&&{annotations:[...H||[],...ve]},...B&&{xExtent:B},...M&&{yExtent:M},...be.crosshairProps,...D};return be.earlyReturn?be.earlyReturn:ze?/* @__PURE__ */Ro(ct,{componentName:"AreaChart",message:ze,width:q,height:Z}):/* @__PURE__ */Ro(mt,{componentName:"AreaChart",width:q,height:Z,children:/* @__PURE__ */Ro(we,{ref:o,...Ge})})}),"AreaChart");import{useMemo as _o,forwardRef as Ho,useRef as Io,useState as Fo,useImperativeHandle as Po,useCallback as Bo}from"react";import{jsx as Mo,jsxs as Do}from"react/jsx-runtime";var To=/* @__PURE__ */Ee(/* @__PURE__ */Ho(function(e,t){Se(Re);let o=Io(null),i=Je(e.mode,{width:e.width,height:e.height,showAxes:e.showAxes,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:a,margin:r,className:n,xFormat:l,yFormat:s,xAccessor:c="x",seriesAAccessor:h="a",seriesBAccessor:m="b",seriesALabel:d="A",seriesBLabel:u="B",seriesAColor:p="var(--semiotic-danger, #dc2626)",seriesBColor:f="var(--semiotic-info, #2563eb)",showLines:y=!0,lineWidth:g=1.5,showPoints:b=!1,pointRadius:x=3,curve:v="linear",areaOpacity:w=.6,gradientFill:A,styleRules:S,tooltip:k,annotations:C,xExtent:R,yExtent:L,frameProps:_={},selection:I,linkedHover:F,onObservation:W,onClick:N,hoverHighlight:O,chartId:E,loading:j,loadingContent:z,emptyContent:G,legendInteraction:$,legendPosition:V,pointIdAccessor:X,windowSize:Y}=e,{width:K,height:Q,enableHover:U,showGrid:q,showLegend:Z,title:J,description:ee,summary:te,accessibleTable:oe,xLabel:ie,yLabel:ae}=i,re=_o(()=>"function"==typeof c?e=>D(c(e)):e=>D(e[c]),[c]),ne=_o(()=>"function"==typeof h?e=>D(h(e)):e=>D(e[h]),[h]),se=_o(()=>"function"==typeof m?e=>D(m(e)):e=>D(e[m]),[m]),[ce,he]=Fo([]),me=Io([]),de=null==a,ue=_o(()=>ht(de?ce:a),[de,ce,a]),pe=_o(()=>H(ue,re,ne,se),[ue,re,ne,se]),fe=_o(()=>y?T(ue,re,ne,se):[],[y,ue,re,ne,se]),ye=_o(()=>[...pe,...fe],[pe,fe]),ge=_o(()=>{let e=/* @__PURE__ */new Set;for(let t of pe)e.add(t.__diffSegment);return Array.from(e)},[pe]);Po(t,()=>{let e=e=>{let t=Y&&e.length>Y?e.slice(e.length-Y):e;me.current=t,he(t)},t=X?"function"==typeof X?X:e=>e[X]:null;return{push:t=>e([...me.current,t]),pushMany:t=>e([...me.current,...t]),remove:o=>{if(!t)return[];let i=Array.isArray(o)?o:[o],a=[],r=[];for(let e of me.current)i.includes(t(e))?a.push(e):r.push(e);return e(r),a},update:(o,i)=>{if(!t)return[];let a=Array.isArray(o)?o:[o],r=[],n=me.current.map(e=>{if(a.includes(t(e))){let t=i(e);return r.push(t),t}return e});return e(n),r},clear:()=>e([]),getData:()=>de?me.current:ue,getScales:()=>o.current?.getScales()??null}},[de,ue,X,Y]);let be=_o(()=>!1===Z?void 0:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:d,color:p},{label:u,color:f}]}]},[Z,d,u,p,f]),xe=Object.hasOwn(_,"legend")?_:{..._,legend:be},ve=le({data:ue,rawData:a,colorBy:"__diffWinner",colorScheme:[p,f],legendInteraction:$,legendPosition:V,frameLegend:xe,selection:I,linkedHover:F,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:W,onClick:N,hoverHighlight:O,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"DifferenceChart",chartId:E,showLegend:Z,userMargin:r,marginDefaults:i.marginDefaults,loading:j,loadingContent:z,emptyContent:G,width:K,height:Q,hasTitle:!!J,axisChrome:vt(_,{showAxes:i.showAxes,xLabel:ie,yLabel:ae})}),Ae=_o(()=>P({seriesAColor:p,seriesBColor:f,areaOpacity:w,styleRules:S}),[p,f,w,S]),ke=_o(()=>B({seriesAColor:p,seriesBColor:f,lineWidth:g,styleRules:S}),[p,f,g,S]),Ce=_o(()=>M({seriesAColor:p,seriesBColor:f,pointRadius:x,styleRules:S}),[p,f,x,S]),[_e,He,Ie]=_o(()=>[Ae,ke,Ce].map(e=>_t(e,ve.effectiveSelectionHook,ve.resolvedSelection)),[Ae,ke,Ce,ve.effectiveSelectionHook,ve.resolvedSelection]),Fe=Bo(e=>{let t=e.data,o=e.allSeries,i=e.xValue??t?.__x,a=t?.__valA,r=t?.__valB;if(o&&o.length>0){let e=o.find(e=>"line-A"===e.group),t=o.find(e=>"line-B"===e.group);null!=e?.value&&Number.isFinite(e.value)&&(a=e.value),null!=t?.value&&Number.isFinite(t.value)&&(r=t.value)}if(null!=i&&(null==a||null==r)){let e=ue.find(e=>re(e)===i);e&&(null==a&&(a=ne(e)),null==r&&(r=se(e)))}let n=e=>null!=e&&Number.isFinite(e)?(Math.round(100*e)/100).toString():"—",s=l&&null!=i?l(i):null!=i?String(i):"";/* @__PURE__ */
33
- return Do("div",{className:"semiotic-tooltip",style:je,children:[s&&/* @__PURE__ */Mo("div",{style:{fontWeight:600,marginBottom:4},children:s}),
34
- /* @__PURE__ */Do("div",{style:{display:"flex",alignItems:"center",gap:6},children:[
35
- /* @__PURE__ */Mo("span",{style:{width:10,height:10,background:p,display:"inline-block",borderRadius:2}}),
36
- /* @__PURE__ */Do("span",{children:[d,": ",n(a)]})]}),
37
- /* @__PURE__ */Do("div",{style:{display:"flex",alignItems:"center",gap:6},children:[
38
- /* @__PURE__ */Mo("span",{style:{width:10,height:10,background:f,display:"inline-block",borderRadius:2}}),
39
- /* @__PURE__ */Do("span",{children:[u,": ",n(r)]})]}),null!=a&&null!=r&&Number.isFinite(a)&&Number.isFinite(r)&&/* @__PURE__ */Do("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",n(a-r)]})]})},[ue,re,ne,se,l,p,f,d,u]),{tooltipContent:Pe,tooltipMode:Be}=_o(()=>nt({tooltip:k,defaultTooltipContent:Fe,multiDefaultContent:Fe}),[k,Fe]),Me=_o(()=>Le(A,{stops:[{offset:0,opacity:.85},{offset:1,opacity:.15}]}),[A]);if(ve.earlyReturn)return ve.earlyReturn;let We={chartType:"mixed",data:ye,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:ge,curve:v,areaStyle:_e,lineStyle:He,...b&&{pointStyle:Ie},size:[K,Q],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ve.margin,showAxes:i.showAxes,xLabel:ie,yLabel:ae,xFormat:l,yFormat:s,enableHover:U,showGrid:q,...Me&&{gradientFill:Me},...ve.legendBehaviorProps,...De({title:J,description:ee,summary:te,accessibleTable:oe,className:n,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),tooltipContent:Pe,..."multi"===Be&&{tooltipMode:"multi"},...Te({linkedHover:F,selection:I,onObservation:W,onClick:N,hoverHighlight:O,hoverRadius:e.hoverRadius,mobileInteraction:ve.mobileInteraction,customHoverBehavior:ve.customHoverBehavior,customClickBehavior:ve.customClickBehavior}),...C&&C.length>0&&{annotations:C},...R&&{xExtent:R},...L&&{yExtent:L},...ve.crosshairProps,..._};/* @__PURE__ */
40
- return Mo(mt,{componentName:"DifferenceChart",width:K,height:Q,children:/* @__PURE__ */Mo(we,{ref:o,...We})})}),"DifferenceChart");import{useMemo as Wo,forwardRef as No,useRef as Oo}from"react";import{jsx as Eo}from"react/jsx-runtime";var jo=/* @__PURE__ */Ee(/* @__PURE__ */No(function(e,t){Se(he);let o=Oo(null),i=Je(e.mode,{width:e.width,height:e.height,showAxes:e.showAxes,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:a,margin:r,className:n,xFormat:l,yFormat:s,xAccessor:c="x",yAccessor:h="y",areaBy:m,lineDataAccessor:d="coordinates",colorBy:u,colorScheme:p,styleRules:f,curve:y="monotoneX",areaOpacity:g=.7,showLine:b=!0,lineWidth:x=2,showPoints:v=!1,pointRadius:w=3,normalize:A=!1,baseline:S="zero",stackOrder:k,tooltip:C,annotations:R,xExtent:L,yExtent:H,frameProps:I={},selection:F,linkedHover:P,onObservation:B,onClick:M,hoverHighlight:D,chartId:T,loading:W,loadingContent:N,emptyContent:O,legendInteraction:E,legendPosition:j,color:z,stroke:G,strokeWidth:$,opacity:V}=e,{width:X,height:Y,enableHover:K,showGrid:Q,showLegend:U,title:q,description:Z,summary:J,accessibleTable:ee,xLabel:te,yLabel:oe}=i,ie=Wo(()=>ht(a),[a]),ae=u||m;se(t,{variant:"xy",frameRef:o});let ne=le({data:ie,rawData:a,colorBy:ae,colorScheme:p,legendInteraction:E,legendPosition:j,frameLegend:I,selection:F,linkedHover:P,fallbackFields:ae?["string"==typeof ae?ae:""]:[],unwrapData:!1,onObservation:B,onClick:M,hoverHighlight:D,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"StackedAreaChart",chartId:T,showLegend:U,userMargin:r,marginDefaults:i.marginDefaults,loading:W,loadingContent:N,emptyContent:O,width:X,height:Y,hasTitle:!!q,axisChrome:vt(I,{showAxes:i.showAxes,xLabel:te,yLabel:oe})}),ce=Wo(()=>tt(c,h),[c,h]),{flattenedData:me,lineStyle:de,pointStyle:ue,defaultTooltipContent:pe}=_({safeData:ie,data:a,areaBy:m,lineDataAccessor:d,colorBy:ae,colorScale:ne.colorScale,color:z,stroke:G,strokeWidth:$,opacity:V,effectiveSelectionHook:ne.effectiveSelectionHook,resolvedSelection:ne.resolvedSelection,areaOpacity:g,showLine:b,lineWidth:x,showPoints:v,pointRadius:w,xAccessor:c,yAccessor:h,xLabel:te,yLabel:oe,xFormat:l,yFormat:s,groupField:m||u,styleRules:f,ruleContext:ce}),fe=re({componentName:"StackedAreaChart",data:a,accessors:{xAccessor:c,yAccessor:h}}),ye={chartType:"stackedarea",...null!=a&&{data:me},xAccessor:c,yAccessor:h,groupAccessor:m||void 0,curve:y,normalize:A,baseline:A?"zero":S,stackOrder:k,lineStyle:de,...v&&ue&&{pointStyle:ue},size:[X,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ne.margin,showAxes:i.showAxes,xLabel:te,yLabel:oe,xFormat:l,yFormat:s,enableHover:K,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:Q,...ne.legendBehaviorProps,...De({title:q,description:Z,summary:J,accessibleTable:ee,className:n,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...nt({tooltip:C,defaultTooltipContent:pe,multiDefaultContent:lt({xFormat:l,yFormat:s})}),...Te({linkedHover:P,selection:F,onObservation:B,onClick:M,hoverHighlight:D,hoverRadius:e.hoverRadius,mobileInteraction:ne.mobileInteraction,customHoverBehavior:ne.customHoverBehavior,customClickBehavior:ne.customClickBehavior}),...R&&R.length>0&&{annotations:R},...L&&{xExtent:L},...H&&{yExtent:H},...ne.crosshairProps,...I};return ne.earlyReturn?ne.earlyReturn:fe?/* @__PURE__ */Eo(ct,{componentName:"StackedAreaChart",message:fe,width:X,height:Y}):/* @__PURE__ */Eo(mt,{componentName:"StackedAreaChart",width:X,height:Y,children:/* @__PURE__ */Eo(we,{ref:o,...ye})})}),"StackedAreaChart");import{useMemo as zo,forwardRef as Go,useRef as $o}from"react";import{scaleSequential as Vo}from"d3-scale";import{jsx as Xo}from"react/jsx-runtime";var Yo=/* @__PURE__ */Ee(/* @__PURE__ */Go(function(e,t){Se(ue);let o=$o(null);se(t,{variant:"xy",frameRef:o});let i=Je(e.mode,{width:e.width,height:e.height,showAxes:e.showAxes,showGrid:void 0,enableHover:e.enableHover,showLegend:void 0,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:a,margin:r,className:n,xAccessor:l="x",yAccessor:s="y",valueAccessor:c="value",xFormat:h,yFormat:m,colorScheme:d,customColorScale:u,showValues:p=!1,valueFormat:f,cellBorderColor:y="#fff",cellBorderWidth:g=1,tooltip:b,annotations:x,heatmapAggregation:v,heatmapXBins:w,heatmapYBins:A,styleRules:S,xExtent:k,yExtent:C,frameProps:R={},selection:L,linkedHover:_,onObservation:H,onClick:I,hoverHighlight:F,chartId:P,loading:B,loadingContent:M,emptyContent:D,showLegend:T,legendPosition:W,legend:N,legendInteraction:O,stroke:E,strokeWidth:j,opacity:z}=e,{width:G,height:$,enableHover:V,title:X,description:Y,summary:K,accessibleTable:Q,xLabel:U,yLabel:q}=i,Z=ut(B,G,$,M),J=Z?null:dt(a,G,$,D),ee=zo(()=>ht(a),[a]),te=Qe(),oe=d??te??"blues",ie=("string"==typeof R.colorScheme?R.colorScheme:void 0)??oe,ae="function"==typeof R.heatmapColorScale?R.heatmapColorScale:"custom"===ie&&"function"==typeof u?u:void 0,le=T??!1,he=W??"right",{activeSelectionHook:me,customHoverBehavior:de,customClickBehavior:pe,crosshairSourceId:fe}=qe({selection:L,linkedHover:_,fallbackFields:[],onObservation:H,onClick:I,chartType:"Heatmap",chartId:P,hoverHighlight:F,colorByField:void 0,mobileInteraction:i.mobileInteraction}),ye=ne(L),ge=Ze(_,fe);$e(O,void 0,[]);let be=zo(()=>"function"==typeof c?e=>c(e):e=>e[c],[c]),xe=zo(()=>{let e=ee.map(be);return jt(e)},[ee,be]),ve=zo(()=>{if(ae)return ae;let e=It(ie);return Vo(e).domain(xe)},[ie,ae,xe]),Ae=zo(()=>{let e=Number.isFinite(g)?Math.max(0,g):1;return()=>({stroke:y,strokeWidth:e})},[y,g]),ke=zo(()=>ce(l,s,c),[l,s,c]),Ce=zo(()=>at(Ae,S,ke),[Ae,S,ke]),Re=zo(()=>_t(Ce,me,ye),[me,Ce,ye]),Le=zo(()=>Me([{label:U||Pe(l),accessor:l,role:"x",format:h},{label:q||Pe(s),accessor:s,role:"y",format:m},{label:Pe(c),accessor:c,role:"value",format:f}]),[l,s,U,q,c,h,m,f]),_e=re({componentName:"Heatmap",data:a,accessors:{xAccessor:l,yAccessor:s,valueAccessor:c}}),He=zo(()=>le?{gradient:{colorFn:e=>ve(e),domain:xe,label:"string"==typeof c?c:"value",format:f},legendDistance:N?.legendDistance}:void 0,[le,ve,xe,c,f,N?.legendDistance]),{margin:Ie,legend:Fe,legendPosition:Be,legendMarginReserved:Ne}=ze({data:[],colorBy:void 0,colorScale:void 0,showLegend:!1,legendPosition:he,userMargin:r,defaults:i.marginDefaults,additionalLegend:He,chartWidth:G,chartHeight:$,legendLayout:R.legendLayout,frameLegend:R,hasTitle:!!X,axisChrome:vt(R,{showAxes:i.showAxes,xLabel:U,yLabel:q})}),Oe={chartType:"heatmap",...null!=a&&{data:ee},xAccessor:l,yAccessor:s,valueAccessor:c,colorScheme:"custom"!==ie?ie:void 0,...ae&&{heatmapColorScale:ae},areaStyle:Re,showValues:p,heatmapValueFormat:f,size:[G,$],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:Ie,showAxes:i.showAxes,xLabel:U,yLabel:q,xFormat:h,yFormat:m,enableHover:V,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},...Fe&&{legend:Fe,legendPosition:Be},...Ne&&{__legendMarginReservedFor:Fe},...De({title:X,description:Y,summary:K,accessibleTable:Q,className:n,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...We({tooltip:b,defaultTooltipContent:Le}),...Te({linkedHover:_,selection:L,onObservation:H,onClick:I,hoverHighlight:F,hoverRadius:e.hoverRadius,mobileInteraction:i.mobileInteraction,customHoverBehavior:de,customClickBehavior:pe}),...x&&x.length>0&&{annotations:x},...v&&{heatmapAggregation:v},...null!=w&&{heatmapXBins:w},...null!=A&&{heatmapYBins:A},...k&&{xExtent:k},...C&&{yExtent:C},...ge,...R};return Z||J||(_e?/* @__PURE__ */Xo(ct,{componentName:"Heatmap",message:_e,width:G,height:$}):/* @__PURE__ */Xo(mt,{componentName:"Heatmap",width:G,height:$,children:/* @__PURE__ */Xo(we,{ref:o,...Oe})}))}),"Heatmap");import{useMemo as Ko,useCallback as Qo,forwardRef as Uo,useRef as qo}from"react";import{jsx as Zo}from"react/jsx-runtime";var Jo=/* @__PURE__ */Ee(/* @__PURE__ */Uo(function(t,o){ge(q),Se(de);let i=qo(null),a=Je(t.mode,{width:t.width,height:t.height,showAxes:t.showAxes,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:t.xLabel,yLabel:t.yLabel,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules}),{data:r,margin:n,className:l,xFormat:s,yFormat:c,xAccessor:h="x",yAccessor:m="y",sizeBy:d,sizeRange:u=[5,40],colorBy:p,colorScheme:f,styleRules:y,bubbleOpacity:g=.6,bubbleStrokeWidth:b=1,bubbleStrokeColor:x="white",tooltip:v,marginalGraphics:w,pointIdAccessor:A,annotations:S,regression:k,xExtent:C,yExtent:R,pulse:L,decay:_,staleness:H,frameProps:I={},selection:F,linkedHover:P,linkedBrush:B,brush:M,onBrush:D,onObservation:T,onClick:W,hoverHighlight:N,chartId:O,loading:E,loadingContent:j,emptyContent:z,legendInteraction:G,legendPosition:$,color:V,stroke:X,strokeWidth:Y,opacity:K}=t,{width:Q,height:U,enableHover:J,showGrid:ee,showLegend:te,title:ie,description:ae,summary:ne,accessibleTable:ce,xLabel:he,yLabel:me}=a,ue=Ko(()=>ht(r),[r]),pe=void 0===r,fe=le({data:ue,rawData:r,colorBy:p,colorScheme:f,legendInteraction:G,legendPosition:$,frameLegend:I,selection:F,linkedHover:P,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!1,onObservation:T,onClick:W,hoverHighlight:N,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"BubbleChart",chartId:O,showLegend:te,userMargin:n,marginDefaults:a.marginDefaults,loading:E,loadingContent:j,emptyContent:z,width:Q,height:U,hasTitle:!!ie,axisChrome:vt(I,{showAxes:a.showAxes,xLabel:he,yLabel:me})}),{domain:ye,trackPushed:be,reset:xe}=e({accessor:d,data:ue,isPushMode:pe}),ve=Qo(e=>{be([e]),i.current?.push(e)},[be]),ke=Qo(e=>{be(e),i.current?.pushMany(e)},[be]);se(o,{variant:"xy",frameRef:i,overrides:{push:ve,pushMany:ke,clear:()=>{xe(),i.current?.clear()}}});let{brushStreamProps:Ce}=Ae({brush:M,onBrush:D,linkedBrush:B,xAccessor:h,yAccessor:m,defaultDimension:"xy"}),Re=Ko(()=>({stroke:x,strokeWidth:b}),[x,b]),Le=Ko(()=>ye??[0,1],[ye]),_e=Qo(e=>Tt(e,d,u,Le),[d,u,Le]),He=Ko(()=>tt(h,m),[h,m]),Ie=Z({colorBy:p,colorScale:fe.colorScale,color:V,fillOpacity:g,radiusFn:_e,baseStyleExtras:Re,stroke:X,strokeWidth:Y,opacity:K,styleRules:y,ruleContext:He,effectiveSelectionHook:fe.effectiveSelectionHook,resolvedSelection:fe.resolvedSelection}),Fe=Ko(()=>Me([{label:he||Pe(h),accessor:h,role:"x",format:s},{label:me||Pe(m),accessor:m,role:"y",format:c},{label:Pe(d),accessor:d,role:"size"},...p?[{label:Pe(p),accessor:p,role:"color"}]:[]]),[h,m,he,me,d,p,s,c]);if(fe.earlyReturn)return fe.earlyReturn;let Be=re({componentName:"BubbleChart",data:r,accessors:{xAccessor:h,yAccessor:m},requiredProps:{sizeBy:d}});if(Be)/* @__PURE__ */return Zo(ct,{componentName:"BubbleChart",message:Be,width:Q,height:U});let Ne=oe(k),Oe=Ne?[Ne,...S||[]]:S,Ee={chartType:"bubble",...null!=r&&{data:ue},xAccessor:h,yAccessor:m,colorAccessor:p||void 0,sizeAccessor:d,sizeRange:u,pointStyle:Ie,colorScheme:f,size:[Q,U],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:fe.margin,showAxes:a.showAxes,xLabel:he,yLabel:me,xFormat:s,yFormat:c,enableHover:J,showGrid:ee,...fe.legendBehaviorProps,...De({title:ie,description:ae,summary:ne,accessibleTable:ce,className:l,animate:t.animate,maxDevicePixelRatio:t.maxDevicePixelRatio,axisExtent:t.axisExtent,autoPlaceAnnotations:t.autoPlaceAnnotations}),...We({tooltip:v,defaultTooltipContent:Fe}),...Te({linkedHover:P,selection:F,onObservation:T,onClick:W,hoverHighlight:N,hoverRadius:t.hoverRadius,mobileInteraction:fe.mobileInteraction,customHoverBehavior:fe.customHoverBehavior,customClickBehavior:fe.customClickBehavior}),...w&&{marginalGraphics:w},...A&&{pointIdAccessor:A},...L&&{pulse:L},..._&&{decay:_},...H&&{staleness:H},...Oe&&Oe.length>0&&{annotations:Oe},...C&&{xExtent:C},...R&&{yExtent:R},...fe.crosshairProps,...Ce,...I};/* @__PURE__ */
41
- return Zo(mt,{componentName:"BubbleChart",width:Q,height:U,children:/* @__PURE__ */Zo(we,{ref:i,...Ee})})}),"BubbleChart");import*as ei from"react";import{useMemo as ti,useCallback as oi,useState as ii}from"react";import{useMemo as ai,useCallback as ri,useRef as ni}from"react";import*as li from"react";import{jsx as si}from"react/jsx-runtime";var ci=null,hi=null;import{jsx as mi,jsxs as di}from"react/jsx-runtime";var ui="__splomIdx",pi={top:4,bottom:4,left:4,right:4};import{jsx as fi,jsxs as yi}from"react/jsx-runtime";var gi=/* @__PURE__ */Ee(function(e){let{brushMode:t="crossfilter",hoverMode:o=!0}=e,i={};return!o&&t&&(i.splom={resolution:t}),o&&(i["splom-hover"]={resolution:"union"}),/* @__PURE__ */fi(Ct,{selections:i,children:/* @__PURE__ */fi(j,{...e})})},"ScatterplotMatrix");import{useState as bi,useRef as xi,useEffect as vi,useMemo as wi,useCallback as Ai}from"react";import*as Si from"react";import{jsx as ki}from"react/jsx-runtime";var Ci=null,Ri=null;import{jsx as Li,jsxs as _i}from"react/jsx-runtime";var Hi=/* @__PURE__ */Ee(function(e){ee();let{data:t,width:o=600,height:i=400,margin:a,className:r,title:n,description:l,summary:s,xLabel:c,yLabel:h,xFormat:m,yFormat:d,xAccessor:u="x",yAccessor:p="y",lineBy:f,lineDataAccessor:y="coordinates",colorBy:g,colorScheme:b,curve:x="linear",lineWidth:v=2,styleRules:w,fillArea:A=!1,areaOpacity:S=.3,showPoints:k=!1,pointRadius:C=3,enableHover:R=!0,showAxes:L=!0,showGrid:_=!1,showLegend:H,legendPosition:I,tooltip:F,minimap:P={},renderBefore:B=!1,onBrush:M,onBrushEnd:D,onObservation:T,chartId:W,brushExtent:N,yExtent:O,frameProps:E={},loading:j,loadingContent:$,emptyContent:V}=e,X=ut(j,o,i,$),Y=X?null:dt(t,o,i,V),K=wi(()=>ht(t),[t]),[Q,U]=bi(null),q=N??Q,Z=xi(null),[J,oe]=bi(null),ie=void 0!==K[0]?.[y],ae=wi(()=>{if(ie)return K;if(f){let e=K.reduce((e,t)=>{let o="function"==typeof f?f(t):t[f];if(!e[o]){let t={[y]:[]};"string"==typeof f&&(t[f]=o),e[o]=t}return e[o][y].push(t),e},{});return Object.values(e)}return[{[y]:K}]},[K,f,y,ie]),ne=wi(()=>ie||f?ae.flatMap(e=>{let t=e[y]||[];return f&&"string"==typeof f?t.map(t=>({...t,[f]:e[f]})):t}):K,[ae,y,ie,f,K]),le=Ue(K,g,b),se=wi(()=>tt(u,p),[u,p]),ce=te({lineWidth:v,colorBy:g,colorScale:le,fillArea:A,areaOpacity:S,styleRules:w,ruleContext:se}),he=wi(()=>{if(P.lineStyle)return P.lineStyle},[P.lineStyle]),me=te({lineWidth:1,colorBy:g,colorScale:le,styleRules:w,ruleContext:se}),de=he??me,ue=wi(()=>k?at(e=>{let t={r:C,fillOpacity:1};return t.fill=g?Mt(e.parentLine||e,g,le):Pt,t},w,se,e=>e.parentLine||e):void 0,[k,C,g,le,w,se]),{legend:pe,margin:fe,legendPosition:ye,legendMarginReserved:ge}=ze({data:ae,colorBy:g,colorScale:le,showLegend:H,legendPosition:I,userMargin:a,chartWidth:o,chartHeight:i,frameLegend:E,hasTitle:!!n,axisChrome:vt(E,{showAxes:L,xLabel:c,yLabel:h})}),be=P.height||60,xe=G(P),ve=wi(()=>({top:P.margin?.top??xe.top,bottom:P.margin?.bottom??xe.bottom,left:P.margin?.left??fe.left,right:P.margin?.right??fe.right}),[P.margin,xe.top,xe.bottom,fe]),Ae=P.brushDirection||"x",Se=Math.max(0,o-ve.left-ve.right),ke=O?.[0],Ce=O?.[1];vi(()=>{let e=0,t=!1,o=0,i=()=>{if(t)return;let a=Z.current?.getScales?.(),r=(e,t)=>Math.abs(Math.max(...e)-Math.min(...e)-t)<.5;a&&(o>=60||r(a.x.range(),Se)&&r(a.y.range(),be))?oe(a):(o++,e=requestAnimationFrame(i))};return e=requestAnimationFrame(i),()=>{t=!0,e&&cancelAnimationFrame(e)}},[t,Se,be,ve.top,ve.bottom,ke,Ce]);let Re=Ai(e=>{if(N||U(e),M?.(e),!T)return;if(!e)return void T({type:"brush-end",timestamp:Date.now(),chartType:"MinimapChart",chartId:W});let t=J?.["x"===Ae?"y":"x"].domain().map(Number)??[e[0],e[1]];T({type:"brush",extent:"x"===Ae?{x:e,y:t}:{x:t,y:e},timestamp:Date.now(),chartType:"MinimapChart",chartId:W})},[N,M,T,W,J,Ae]),Le=wi(()=>Me([{label:c||Pe(u),accessor:u,role:"x",format:m},{label:h||Pe(p),accessor:p,role:"y",format:d}]),[u,p,c,h,m,d]),_e=re({componentName:"MinimapChart",data:t,accessors:{xAccessor:u,yAccessor:p}});if(_e)/* @__PURE__ */return Li(ct,{componentName:"MinimapChart",message:_e,width:o,height:i});let He=A?"area":"line",Ie={chartType:He,data:ne,xAccessor:u,yAccessor:p,groupAccessor:f||void 0,curve:x,lineStyle:ce,...k&&{pointStyle:ue},size:[o,i],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,...void 0!==e.maxDevicePixelRatio&&{maxDevicePixelRatio:e.maxDevicePixelRatio},margin:fe,showAxes:L,xLabel:c,yLabel:h,xFormat:m,yFormat:d,enableHover:R,showGrid:_,...pe&&{legend:pe,legendPosition:ye},...ge&&{__legendMarginReservedFor:pe},...n&&{title:n},...l&&{description:l},...s&&{summary:s},...void 0!==e.accessibleTable&&{accessibleTable:e.accessibleTable},...void 0!==e.animate&&{animate:e.animate},...void 0!==e.hoverRadius&&{hoverRadius:e.hoverRadius},...nt({tooltip:F,defaultTooltipContent:Le}),...q&&"x"===Ae&&{xExtent:q},...O&&{yExtent:O},...q&&"y"===Ae&&{yExtent:q},...void 0!==e.axisExtent&&{axisExtent:e.axisExtent},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},...E},Fe={chartType:He,data:ne,xAccessor:u,yAccessor:p,groupAccessor:f||void 0,curve:x,lineStyle:de,...void 0!==e.maxDevicePixelRatio&&{maxDevicePixelRatio:e.maxDevicePixelRatio},size:[o,be+ve.top+ve.bottom],margin:ve,showAxes:P.showAxes??!1,background:P.background,enableHover:!1,accessibleTable:!1,description:`${l||n||"Chart"} overview minimap`,animate:!1,...O&&{yExtent:O}},Be=!!P.handles||!!P.showExtentLabels||!!P.renderHandle,De=/* @__PURE__ */_i("div",{style:{position:"relative",width:o,overflow:Be?"visible":"hidden"},children:[
42
- /* @__PURE__ */Li(we,{ref:Z,...Fe}),
43
- /* @__PURE__ */Li(z,{config:P,scales:J,margin:ve,plotWidth:Se,plotHeight:be,brushDirection:Ae,extent:q,axisFormat:"x"===Ae?m:d,onBrush:Re,onBrushEnd:D,onObservation:T,chartId:W})]},"minimap"),Te=/* @__PURE__ */Li("div",{style:{overflow:"hidden"},children:/* @__PURE__ */Li(we,{...Ie})},"main");return X||Y||/* @__PURE__ */Li(mt,{componentName:"MinimapChart",width:o,height:i,children:/* @__PURE__ */_i("div",{className:"minimap-chart"+(r?` ${r}`:""),role:"group","aria-label":l||n||"Chart with overview minimap",children:[B?De:Te,B?Te:De]})})},"MinimapChart");import{useMemo as Ii,forwardRef as Fi,useRef as Pi}from"react";var Bi={topLeft:{label:"Low / High",color:"#E9C46A",opacity:.08},topRight:{label:"High / High",color:"#2A9D8F",opacity:.08},bottomLeft:{label:"Low / Low",color:"#E76F51",opacity:.08},bottomRight:{label:"High / Low",color:"#86BBD8",opacity:.08}};import{Fragment as Mi,jsx as Di,jsxs as Ti}from"react/jsx-runtime";var Wi=/* @__PURE__ */Ee(/* @__PURE__ */Fi(function(e,t){Se(me);let o=Pi(null);se(t,{variant:"xy",frameRef:o});let i=Je(e.mode,{width:e.width,height:e.height,showAxes:e.showAxes,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:a,margin:r,className:n,xFormat:l,yFormat:s,xAccessor:c="x",yAccessor:h="y",xCenter:m,yCenter:d,quadrants:u,centerlineStyle:p={},showQuadrantLabels:f=!0,quadrantLabelSize:y=12,colorBy:g,colorScheme:b,styleRules:x,sizeBy:v,sizeRange:w=[3,15],pointRadius:A=5,pointOpacity:S=.8,tooltip:k,pointIdAccessor:C,annotations:R,frameProps:L={},selection:_,linkedHover:H,onObservation:I,onClick:F,hoverHighlight:P,chartId:B,loading:M,loadingContent:D,emptyContent:T,legendInteraction:W,legendPosition:N,color:O,stroke:E,strokeWidth:j,opacity:z}=e,{width:G,height:V,enableHover:X,showGrid:Y,showLegend:K,title:Q,description:U,summary:q,accessibleTable:J,xLabel:ee,yLabel:te}=i,oe=Ii(()=>({topLeft:$(Bi.topLeft,u?.topLeft),topRight:$(Bi.topRight,u?.topRight),bottomLeft:$(Bi.bottomLeft,u?.bottomLeft),bottomRight:$(Bi.bottomRight,u?.bottomRight)}),[u]),ie=Ii(()=>ht(a),[a]),ae=le({data:ie,rawData:a,colorBy:g,colorScheme:b,legendInteraction:W,legendPosition:N,frameLegend:L,selection:_,linkedHover:H,fallbackFields:"string"==typeof g?[g]:[],unwrapData:!1,onObservation:I,onClick:F,hoverHighlight:P,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"QuadrantChart",chartId:B,showLegend:K,userMargin:r,marginDefaults:i.marginDefaults,loading:M,loadingContent:D,emptyContent:T,width:G,height:V,hasTitle:!!Q,axisChrome:vt(L,{showAxes:i.showAxes,xLabel:ee,yLabel:te})});pt("QuadrantChart",ie,"xAccessor",c),pt("QuadrantChart",ie,"yAccessor",h);let ne=Ii(()=>{if(!ie.length)return;let e="function"==typeof c?c:e=>+e[c],t="function"==typeof h?h:e=>+e[h],o=1/0,i=-1/0,a=1/0,r=-1/0;for(let n of ie){let l=e(n),s=t(n);isFinite(l)&&(l<o&&(o=l),l>i&&(i=l)),isFinite(s)&&(s<a&&(a=s),s>r&&(r=s))}if(null!=m&&isFinite(m)&&(m<o&&(o=m),m>i&&(i=m)),null!=d&&isFinite(d)&&(d<a&&(a=d),d>r&&(r=d)),o===1/0)return;let n=.1*(i-o)||1,l=.1*(r-a)||1;return{xExtent:[o-n,i+n],yExtent:[a-l,r+l]}},[ie,c,h,m,d]),ce=Ii(()=>{if(!v||0===ie.length)return;let e=ie.map(e=>"function"==typeof v?v(e):e[v]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?jt(e):void 0},[ie,v]),he=Ii(()=>"function"==typeof c?c:e=>+e[c],[c]),de=Ii(()=>"function"==typeof h?h:e=>+e[h],[h]),ue=Ii(()=>e=>{let t=he(e),o=de(e),i=null!=m?t>=m:void 0,a=null!=d?o>=d:void 0;return void 0===a||void 0===i?O||Pt:a&&i?oe.topRight.color:a&&!i?oe.topLeft.color:!a&&i?oe.bottomRight.color:oe.bottomLeft.color},[he,de,m,d,oe,O]),pe=Ii(()=>v?e=>Tt(e,v,w,ce):void 0,[v,w,ce]),fe=Ii(()=>tt(c,h),[c,h]),ye=Z({colorBy:g,colorScale:ae.colorScale,color:O,pointRadius:A,fillOpacity:S,radiusFn:pe,fallbackFill:ue,stroke:E,strokeWidth:j,opacity:z,styleRules:x,ruleContext:fe,effectiveSelectionHook:ae.effectiveSelectionHook,resolvedSelection:ae.resolvedSelection}),ge=Ii(()=>{if(!ie.length)return;let e=/* @__PURE__ */new Set;"string"==typeof c&&e.add(c),"string"==typeof h&&e.add(h),"string"==typeof g&&e.add(g),"string"==typeof v&&e.add(v);let t=ie[0];for(let o of Object.keys(t))if(!o.startsWith("_")&&!e.has(o)&&"string"==typeof t[o])return o},[ie,c,h,g,v]),be=Ii(()=>Me([...ge?[{label:ge,accessor:ge,role:"title"}]:[],{label:ee||Pe(c),accessor:c,role:"x",format:l},{label:te||Pe(h),accessor:h,role:"y",format:s},...g?[{label:Pe(g),accessor:g,role:"color"}]:[],...v?[{label:Pe(v),accessor:v,role:"size"}]:[]]),[ge,c,h,ee,te,g,v,l,s]),xe=re({componentName:"QuadrantChart",data:a,accessors:{xAccessor:c,yAccessor:h}}),ve=Ii(()=>{let e={stroke:p.stroke||"#999",strokeWidth:p.strokeWidth??1,dashArray:p.strokeDasharray||[]};return[(t,o,i,a)=>{if(!i?.x||!i?.y)return;let r=a.width,n=a.height,l=null!=m?i.x(m):r/2,s=null!=d?i.y(d):n/2;if(null!=m&&!isFinite(l)||null!=d&&!isFinite(s))return;let c=Math.max(0,Math.min(r,l)),h=Math.max(0,Math.min(n,s)),u=[{config:oe.topLeft,x:0,y:0,w:c,h:h},{config:oe.topRight,x:c,y:0,w:r-c,h:h},{config:oe.bottomLeft,x:0,y:h,w:c,h:n-h},{config:oe.bottomRight,x:c,y:h,w:r-c,h:n-h}];for(let e of u)e.w<=0||e.h<=0||(t.fillStyle=e.config.color,t.globalAlpha=e.config.opacity??.08,t.fillRect(e.x,e.y,e.w,e.h));t.globalAlpha=1,t.strokeStyle=e.stroke,t.lineWidth=e.strokeWidth,e.dashArray.length>0&&t.setLineDash(e.dashArray),t.beginPath(),t.moveTo(c,0),t.lineTo(c,n),t.stroke(),t.beginPath(),t.moveTo(0,h),t.lineTo(r,h),t.stroke(),t.setLineDash([])}]},[m,d,oe,p]),Ae=Ii(()=>f?[...ve,(e,t,o,i)=>{if(!o?.x||!o?.y)return;let a=i.width,r=i.height,n=null!=m?o.x(m):a/2,l=null!=d?o.y(d):r/2;if(null!=m&&!isFinite(n)||null!=d&&!isFinite(l))return;Math.max(0,Math.min(a,n)),Math.max(0,Math.min(r,l));let s=Nt(e,"var(--semiotic-font-family, sans-serif)")||"sans-serif";e.font=`600 ${y}px ${s}`,e.globalAlpha=.5,e.fillStyle=oe.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(oe.topLeft.label,8,8),e.fillStyle=oe.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(oe.topRight.label,a-8,8),e.fillStyle=oe.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(oe.bottomLeft.label,8,r-8),e.fillStyle=oe.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(oe.bottomRight.label,a-8,r-8),e.globalAlpha=1}]:ve,[ve,f,y,oe,m,d]),ke=Ii(()=>{let e=L.canvasPreRenderers||[];return[...Ae,...e]},[Ae,L.canvasPreRenderers]),Ce=Ii(()=>{let e={stroke:p.stroke||"#999",strokeWidth:p.strokeWidth??1,dashArray:p.strokeDasharray?Array.isArray(p.strokeDasharray)?p.strokeDasharray.join(","):p.strokeDasharray:void 0};return[(t,o,i)=>{if(!o?.x||!o?.y)return null;let a=i.width,r=i.height,n=null!=m?o.x(m):a/2,l=null!=d?o.y(d):r/2;if(null!=m&&!isFinite(n)||null!=d&&!isFinite(l))return null;let s=Math.max(0,Math.min(a,n)),c=Math.max(0,Math.min(r,l)),h=[{config:oe.topLeft,x:0,y:0,w:s,h:c},{config:oe.topRight,x:s,y:0,w:a-s,h:c},{config:oe.bottomLeft,x:0,y:c,w:s,h:r-c},{config:oe.bottomRight,x:s,y:c,w:a-s,h:r-c}];/* @__PURE__ */
44
- return Ti(Mi,{children:[h.map((e,t)=>e.w>0&&e.h>0?/* @__PURE__ */Di("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:e.config.color,opacity:e.config.opacity??.08},`qf-${t}`):null),
45
- /* @__PURE__ */Di("line",{x1:s,y1:0,x2:s,y2:r,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.dashArray}),
46
- /* @__PURE__ */Di("line",{x1:0,y1:c,x2:a,y2:c,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.dashArray}),f&&/* @__PURE__ */Ti(Mi,{children:[
47
- /* @__PURE__ */Di("text",{x:8,y:8+y,fill:oe.topLeft.color,fontWeight:600,fontSize:y,opacity:.5,children:oe.topLeft.label}),
48
- /* @__PURE__ */Di("text",{x:a-8,y:8+y,fill:oe.topRight.color,fontWeight:600,fontSize:y,opacity:.5,textAnchor:"end",children:oe.topRight.label}),
49
- /* @__PURE__ */Di("text",{x:8,y:r-8,fill:oe.bottomLeft.color,fontWeight:600,fontSize:y,opacity:.5,children:oe.bottomLeft.label}),
50
- /* @__PURE__ */Di("text",{x:a-8,y:r-8,fill:oe.bottomRight.color,fontWeight:600,fontSize:y,opacity:.5,textAnchor:"end",children:oe.bottomRight.label})]})]})}]},[m,d,oe,p,f,y]);if(ae.earlyReturn)return ae.earlyReturn;let Re={chartType:"scatter",...null!=a&&{data:ie},xAccessor:c,yAccessor:h,colorAccessor:g||void 0,sizeAccessor:v||void 0,sizeRange:w,pointStyle:ye,colorScheme:b,size:[G,V],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,...void 0!==e.maxDevicePixelRatio&&{maxDevicePixelRatio:e.maxDevicePixelRatio},margin:ae.margin,showAxes:i.showAxes,xLabel:ee,yLabel:te,xFormat:l,yFormat:s,enableHover:X,showGrid:Y,...ne&&{xExtent:ne.xExtent,yExtent:ne.yExtent},...ae.legendBehaviorProps,...Q&&{title:Q},...U&&{description:U},...q&&{summary:q},...void 0!==J&&{accessibleTable:J},...n&&{className:n},...null!=e.animate&&{animate:e.animate},...void 0!==e.axisExtent&&{axisExtent:e.axisExtent},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},tooltipContent:!1===k?()=>null:!0===k||void 0===k?be:st(k)||be,...Te({linkedHover:H,selection:_,onObservation:I,onClick:F,hoverHighlight:P,hoverRadius:e.hoverRadius,mobileInteraction:ae.mobileInteraction,customHoverBehavior:ae.customHoverBehavior,customClickBehavior:ae.customClickBehavior}),...C&&{pointIdAccessor:C},...R&&R.length>0&&{annotations:R},canvasPreRenderers:ke,...ae.crosshairProps,...L,...ke.length>0&&{canvasPreRenderers:ke},svgPreRenderers:Ce};return xe?/* @__PURE__ */Di(ct,{componentName:"QuadrantChart",message:xe,width:G,height:V}):/* @__PURE__ */Di(mt,{componentName:"QuadrantChart",width:G,height:V,children:/* @__PURE__ */Di(we,{ref:o,...Re})})}),"QuadrantChart");import*as Ni from"react";import{useMemo as Oi,useCallback as Ei,forwardRef as ji,useRef as zi,useImperativeHandle as Gi}from"react";var $i="__ma_unitized",Vi="__ma_series";import{jsx as Xi}from"react/jsx-runtime";var Yi=/* @__PURE__ */Ee(/* @__PURE__ */ji(function(e,t){Se(ke);let o=zi(null),i=zi([]),a=zi(e.series);a.current=e.series,Gi(t,()=>{let e=()=>(a.current??[]).filter(e=>null!=e&&"object"==typeof e);return{push:t=>{if(!o.current)return;let a=e(),r=t;for(let e=0;e<a.length&&e<2;e++){let t=a[e],n=t.extent||i.current[e];if(!n)continue;let l=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(r);null==l||!isFinite(l)||o.current.push({...r,[$i]:K(l,n),[Vi]:t.label||`Series ${e+1}`})}},pushMany:t=>{if(!o.current)return;let a=e(),r=[];for(let e of t)for(let t=0;t<a.length&&t<2;t++){let o=a[t],n=o.extent||i.current[t];if(!n)continue;let l=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(e);null==l||!isFinite(l)||r.push({...e,[$i]:K(l,n),[Vi]:o.label||`Series ${t+1}`})}o.current.pushMany(r)},remove:e=>o.current?.remove(e)??[],update:(e,t)=>o.current?.update(e,t)??[],clear:()=>o.current?.clear(),getData:()=>o.current?.getData()??[],getScales:()=>o.current?.getScales()??null}},[]);let r=Je(e.mode,{width:e.width,height:e.height,showAxes:e.showAxes,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,xLabel:e.xLabel,accessibleTable:e.accessibleTable,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:800,height:400}),{data:n,margin:l,className:s,xFormat:c,xAccessor:h="x",series:m,colorScheme:d,curve:u="monotoneX",lineWidth:p=2,styleRules:f,tooltip:y,annotations:g,frameProps:b={},selection:x,linkedHover:v,onObservation:w,onClick:A,hoverHighlight:S,chartId:k,loading:C,loadingContent:R,emptyContent:L,legendInteraction:_,legendPosition:H,stroke:I,strokeWidth:F,opacity:P}=e,{width:B,height:M,enableHover:D,showGrid:T,showLegend:W=!0,title:N,description:O,summary:E,accessibleTable:j,xLabel:z}=r,G=Oi(()=>ht(n),[n]),$=Oi(()=>ht(m),[m]),U=$,q=2===$.length,Z=Oi(()=>q?{...b.legendLayout,sideGutter:b.legendLayout?.sideGutter??70}:b.legendLayout,[b.legendLayout,q]);"production"!==process.env.NODE_ENV&&!q&&console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${$.length}. Rendering as a standard multi-line chart.`);let J=ut(C,B,M,R),ee=J?null:dt(n,B,M,L),oe=Ye(),ie=Oi(()=>V(U,d,oe),[U,d,oe]),ae=Oi(()=>$.map((e,t)=>e.label||`Series ${t+1}`),[$]),{unitizedData:ne,extents:se}=Oi(()=>{if(0===G.length){let e=$.map(e=>e.extent||null).filter(Boolean);return e.length===$.length&&(i.current=e),{unitizedData:[],extents:e.length===$.length?e:[]}}let e=$.map(e=>e.extent||Y(G,e.yAccessor));if(i.current=e,!q){let t=[];for(let e of G)for(let o=0;o<$.length;o++){let i=$[o],a=("function"==typeof i.yAccessor?i.yAccessor:e=>e[i.yAccessor])(e);null!=a&&t.push({...e,[$i]:a,[Vi]:ae[o]})}return{unitizedData:t,extents:e}}let t=[];for(let o of G)for(let i=0;i<2;i++){let a=$[i],r=("function"==typeof a.yAccessor?a.yAccessor:e=>e[a.yAccessor])(o);null!=r&&t.push({...o,[$i]:K(r,e[i]),[Vi]:ae[i]})}return{unitizedData:t,extents:e}},[G,$,q,ae]),ce=Oi(()=>{if(!q||se.length<2)return;let e=e=>t=>{let o=Q(t,se[e]),i=$[e]?.format;return"function"==typeof i?i(o):Number.isInteger(o)?String(o):o.toFixed(1)},t=e(0),o=e(1);return[{orient:"left",label:ae[0],tickFormat:t},{orient:"right",label:ae[1],tickFormat:o},{orient:"bottom"}]},[q,se,$,ae]),he=Oi(()=>ne.length>0?ne:ae.map(e=>({[Vi]:e})),[ne,ae]),me=le({data:he,rawData:n,colorBy:Vi,colorScheme:ie,legendInteraction:_,legendPosition:H,frameLegend:{...b,legendLayout:Z},selection:x,linkedHover:v,fallbackFields:[Vi],unwrapData:!1,onObservation:w,onClick:A,hoverHighlight:S,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"MultiAxisLineChart",chartId:k,showLegend:W,legendLayout:Z,userMargin:l,marginDefaults:q?{...r.marginDefaults,left:70,right:70}:r.marginDefaults,loading:C,loadingContent:R,emptyContent:L,width:B,height:M,hasTitle:!!N,axisChrome:vt(b,{showAxes:r.showAxes,xLabel:z,yLabel:ae[0],yLabelRight:ae[1],axes:ce})}),de=Oi(()=>{let e=/* @__PURE__ */new Map;return ae.forEach((t,o)=>e.set(t,ie[o])),e},[ae,ie]),ue=Ei(e=>de.get(e[Vi])||ie[0],[de,ie]),pe=Oi(()=>X(h,$),[h,$]),fe=te({lineWidth:p,resolveStroke:ue,stroke:I,strokeWidth:F,opacity:P,effectiveSelectionHook:me.effectiveSelectionHook,resolvedSelection:me.resolvedSelection,styleRules:f,ruleContext:pe}),ye=Oi(()=>e=>{let t=e.data||e,o=t[Vi],i=ae.indexOf(o),a=t[$i],r=q&&i>=0&&se[i]?Q(a,se[i]):a,n=i>=0&&$[i]?.format?$[i].format:e=>Number.isInteger(e)?String(e):e.toFixed(2),l="function"==typeof h?h(t):t[h];return Ni.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},Ni.createElement("div",{style:{fontWeight:600,marginBottom:4,color:ie[i]||"inherit"}},o),Ni.createElement("div",null,`${"string"==typeof h?h:"x"}: `,c?c(l):String(l)),Ni.createElement("div",null,`${o}: ${n(r)}`))},[ae,ie,se,q,$,h,c]),ge=Ei(e=>{let t=(Array.isArray(e.allSeries)?e.allSeries:[]).map(e=>{let t=ae.indexOf(e.group),o=q&&t>=0&&se[t]?Q(e.value,se[t]):e.value,i=e.datum;return i&&(i={...i},delete i[$i],delete i[Vi]),{...e,value:o,datum:i}}),o=e.data&&"object"==typeof e.data&&!Array.isArray(e.data)?{...e.data}:e.data;o&&"object"==typeof o&&!Array.isArray(o)&&(delete o[$i],delete o[Vi]);let i={...e,data:o,allSeries:t};return delete i[$i],delete i[Vi],i},[se,q,ae]),be=Oi(()=>lt({xFormat:c,yFormat:(e,t)=>$[ae.indexOf(t??"")]?.format?.(e)}),[c,$,ae]),xe=Ei(e=>be(ge(e)),[be,ge]),ve=Oi(()=>{if(!rt(y)||"function"!=typeof y.content)return y;let e=e=>y.content(ge(e));return{mode:"multi",content:Xe(y.content)?Ve(e):e}},[ge,y]),Ae=Oi(()=>nt({tooltip:ve,defaultTooltipContent:ye,multiDefaultContent:xe}),[ye,xe,ve]);if(me.earlyReturn)return me.earlyReturn;let Ce=re({componentName:"MultiAxisLineChart",data:n,accessors:{xAccessor:h}}),Re=q?[0,1]:void 0,Le={chartType:"line",...null!=n&&{data:ne},xAccessor:h,yAccessor:$i,groupAccessor:Vi,lineStyle:fe,colorScheme:ie,size:[B,M],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,...void 0!==e.maxDevicePixelRatio&&{maxDevicePixelRatio:e.maxDevicePixelRatio},margin:me.margin,showAxes:r.showAxes,...ce&&{axes:ce},xLabel:z,...q?{}:{yLabel:ae[0]},xFormat:c,...q&&Re&&{yExtent:Re},enableHover:D,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:T,curve:u,...me.legendBehaviorProps,...N&&{title:N},...O&&{description:O},...E&&{summary:E},...void 0!==j&&{accessibleTable:j},...s&&{className:s},...null!=e.animate&&{animate:e.animate},...void 0!==e.axisExtent&&{axisExtent:e.axisExtent},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},...Ae,...g&&{annotations:g},...Te({linkedHover:v,selection:x,onObservation:w,onClick:A,hoverHighlight:S,hoverRadius:e.hoverRadius,mobileInteraction:me.mobileInteraction,customHoverBehavior:me.customHoverBehavior,customClickBehavior:me.customClickBehavior}),...me.crosshairProps,...b,...Z&&{legendLayout:Z}};return J||ee||(Ce?/* @__PURE__ */Xi(ct,{componentName:"MultiAxisLineChart",message:Ce,width:B,height:M}):/* @__PURE__ */Xi(mt,{componentName:"MultiAxisLineChart",width:B,height:M,children:/* @__PURE__ */Xi(we,{ref:o,...Le})}))}),"MultiAxisLineChart");import{useMemo as Ki,forwardRef as Qi,useRef as Ui}from"react";import{jsx as qi}from"react/jsx-runtime";var Zi=/* @__PURE__ */Ee(/* @__PURE__ */Qi(function(e,t){Se(fe);let o=Ui(null);se(t,{variant:"xy",frameRef:o});let i=Je(e.mode,{width:e.width,height:e.height,showAxes:e.showAxes,showGrid:e.showGrid,enableHover:e.enableHover,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:a,margin:r,className:n,xFormat:l,yFormat:s,xAccessor:c="x",highAccessor:h="high",lowAccessor:m="low",openAccessor:d,closeAccessor:u,candlestickStyle:p,styleRules:f,tooltip:y,annotations:g,xExtent:b,yExtent:x,frameProps:v={},selection:w,linkedHover:A,onObservation:S,onClick:k,chartId:C,loading:R,loadingContent:L,emptyContent:_}=e,{width:H,height:I,enableHover:F,showGrid:P,title:B,description:M,summary:D,accessibleTable:T,xLabel:W,yLabel:N}=i,O=ut(R,H,I,L),E=O?null:dt(a,H,I,_),j=Ki(()=>ht(a),[a]),z=null==d||null==u;pt("CandlestickChart",j,"xAccessor",c),pt("CandlestickChart",j,"highAccessor",h),pt("CandlestickChart",j,"lowAccessor",m),z||(pt("CandlestickChart",j,"openAccessor",d),pt("CandlestickChart",j,"closeAccessor",u));let{activeSelectionHook:G,customHoverBehavior:$,customClickBehavior:V,crosshairSourceId:X}=qe({selection:w,linkedHover:A,onObservation:S,onClick:k,chartType:"CandlestickChart",chartId:C,mobileInteraction:i.mobileInteraction}),Y=ne(w),K=Ki(()=>tt(c,z?h:u),[c,h,u,z]),Q=Ki(()=>_t(at(void 0,f,K),G,Y),[f,K,G,Y]),U=Ze(A,X),q=Ki(()=>{let e=i.marginDefaults,t="sparkline"===i.mode?{...e,top:0,bottom:0}:e;return null==r?t:{...t,...ie(r)}},[r,i.marginDefaults,i.mode]),Z=Ki(()=>{let e=[{label:W||Pe(c),accessor:c,role:"x",format:l}];return z?(e.push({label:"High",accessor:h,role:"y",format:s}),e.push({label:"Low",accessor:m,format:s})):(e.push({label:"Open",accessor:d,format:s}),e.push({label:"High",accessor:h,format:s}),e.push({label:"Low",accessor:m,format:s}),e.push({label:"Close",accessor:u,format:s})),Me(e)},[c,W,l,s,h,m,d,u,z]),J=re({componentName:"CandlestickChart",data:a,accessors:{xAccessor:c,highAccessor:h,lowAccessor:m,...!z&&{openAccessor:d,closeAccessor:u}}}),ee=Math.max(2,Math.min(12,Math.round(H/40))),te=H<=200?.02:.1,oe={chartType:"candlestick",...null!=a&&{data:j},xAccessor:c,yAccessor:h,highAccessor:h,lowAccessor:m,...!z&&{openAccessor:d,closeAccessor:u},...p&&{candlestickStyle:p},...(G||f?.length)&&{pointStyle:Q},scalePadding:ee,extentPadding:te,size:[H,I],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:q,showAxes:i.showAxes,xLabel:W,yLabel:N,xFormat:l,yFormat:s,enableHover:F,showGrid:P,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},...De({title:B,description:M,summary:D,accessibleTable:T,className:n,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...We({tooltip:y,defaultTooltipContent:Z}),...Te({linkedHover:A,selection:w,onObservation:S,onClick:k,hoverRadius:e.hoverRadius,mobileInteraction:i.mobileInteraction,customHoverBehavior:$,customClickBehavior:V}),...g&&g.length>0&&{annotations:g},...b&&{xExtent:b},...x&&{yExtent:x},...U,...v};return O||E||(J?/* @__PURE__ */qi(ct,{componentName:"CandlestickChart",message:J,width:H,height:I}):/* @__PURE__ */qi(mt,{componentName:"CandlestickChart",width:H,height:I,children:/* @__PURE__ */qi(we,{ref:o,...oe})}))}),"CandlestickChart");import{useMemo as Ji,forwardRef as ea,useRef as ta}from"react";import{jsx as oa}from"react/jsx-runtime";var ia=/* @__PURE__ */Ee(/* @__PURE__ */ea(function(e,t){Se(pe);let o=ta(null);se(t,{variant:"xy",frameRef:o});let i=Je(e.mode,{width:e.width,height:e.height,showAxes:e.showAxes,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:a,margin:r,className:n,xFormat:l,yFormat:s,xAccessor:c="x",yAccessor:h="y",pointIdAccessor:m,xScaleType:d,positiveColor:u,negativeColor:p,connectorStroke:f,connectorWidth:y,gap:g,styleRules:b,tooltip:x,annotations:v,xExtent:w,yExtent:A,frameProps:S={},selection:k,linkedHover:C,onObservation:R,onClick:L,hoverHighlight:_,chartId:H,loading:I,loadingContent:F,emptyContent:P,legendInteraction:B,legendPosition:M}=e,{areaStyle:D,...T}=S,{width:W,height:N,enableHover:O,showGrid:E,showLegend:j,title:z,description:G,summary:$,accessibleTable:V,xLabel:X,yLabel:Y}=i,K=Ji(()=>ht(a),[a]),Q=ta({next:0,indexOf:/* @__PURE__ */new WeakMap,idOf:/* @__PURE__ */new Map,labels:/* @__PURE__ */new Map}),{plotData:U,plotXAccessor:q,plotXFormat:Z,usesIndex:J}=Ji(()=>{let e="function"==typeof c?c:e=>e[c],t=m?"function"==typeof m?m:e=>e[m]:void 0,o=e=>"number"==typeof e&&Number.isFinite(e)||e instanceof Date,i=(e,t)=>{let o=e??t;return l?l(o):String(o)};if(null!=a&&!K.some((t,i)=>!o(e(t,i))))return{plotData:K,plotXAccessor:c,plotXFormat:l,usesIndex:!1};if(null!=a){let t=K.map((t,o)=>e(t,o));return{plotData:K.map((e,t)=>({...e,__waterfallX:t})),plotXAccessor:"__waterfallX",plotXFormat:e=>i(t[Number(e)],e),usesIndex:!0}}let r=Q.current,n=(e,t,o,i)=>{e&&"object"==typeof e&&(r.indexOf.set(e,t),!Object.isFrozen(e)&&!Object.isSealed(e)&&(e.__waterfallX=t)),o&&r.idOf.set(o,t),r.labels.set(t,i)};return{plotData:K,plotXAccessor:(i,a)=>{let l=e(i,a);if(o(l))return l;let s=t?String(t(i,a)??""):"",c=i&&"object"==typeof i?i.__waterfallX:void 0,h="number"==typeof c&&Number.isFinite(c)?c:(i&&"object"==typeof i?r.indexOf.get(i):void 0)??(s?r.idOf.get(s):void 0);if("number"==typeof h)return n(i,h,s,l),h;let m="number"==typeof a?a:r.next;return r.next=Math.max(r.next,m+1),n(i,m,s,l),m},plotXFormat:e=>i(r.labels.get(Number(e)),e),usesIndex:!0}},[a,K,c,l,m]),ee=Ji(()=>{if(J&&null!=a)return[{orient:"bottom",tickValues:U.map((e,t)=>t)}]},[a,U,J]),te=le({data:U,rawData:a,colorBy:void 0,colorScheme:void 0,legendInteraction:B,legendPosition:M,frameLegend:S,selection:k,linkedHover:C,fallbackFields:["string"==typeof c?c:"x"],unwrapData:!1,onObservation:R,onClick:L,hoverHighlight:_,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"WaterfallChart",chartId:H,showLegend:j,userMargin:r,marginDefaults:i.marginDefaults,loading:I,loadingContent:F,emptyContent:P,width:W,height:N,hasTitle:!!z,axisChrome:vt(S,{showAxes:i.showAxes,xLabel:X,yLabel:Y,axes:S.axes??ee})}),oe=Ji(()=>({positiveColor:u,negativeColor:p,connectorStroke:f,connectorWidth:y,gap:g,stroke:e.stroke,strokeWidth:e.strokeWidth,opacity:e.opacity}),[u,p,f,y,g,e.stroke,e.strokeWidth,e.opacity]),ie=Ji(()=>tt(c,h),[c,h]),ae=Ji(()=>at(void 0,b,ie),[b,ie]),ne=Ji(()=>_t(e=>{let t=ae(e);if(!D)return t;let o="function"==typeof D?D(e):D;return o?{...t,...o}:t},te.effectiveSelectionHook,te.resolvedSelection),[ae,D,te.effectiveSelectionHook,te.resolvedSelection]),ce=Ji(()=>Me([{label:X||Pe(c),accessor:c,role:"x",format:l},{label:Y||"Change",accessor:h,role:"y",format:s}]),[c,h,X,Y,l,s]);if(te.earlyReturn)return te.earlyReturn;let he=re({componentName:"WaterfallChart",data:a,accessors:{xAccessor:c,yAccessor:h}});if(he)/* @__PURE__ */return oa(ct,{componentName:"WaterfallChart",message:he,width:W,height:N});let me={chartType:"waterfall",...null!=a&&{data:U},xAccessor:q,yAccessor:h,xScaleType:null!=a&&J?"linear":d,waterfallStyle:oe,areaStyle:ne,size:[W,N],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:te.margin,showAxes:i.showAxes,xLabel:X,yLabel:Y,xFormat:Z,yFormat:s,enableHover:O,showGrid:E,...ee&&{axes:ee},...te.legendBehaviorProps,...De({title:z,description:G,summary:$,accessibleTable:V,className:n,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...We({tooltip:x,defaultTooltipContent:ce}),...Te({linkedHover:C,selection:k,onObservation:R,onClick:L,hoverHighlight:_,hoverRadius:e.hoverRadius,mobileInteraction:te.mobileInteraction,customHoverBehavior:te.customHoverBehavior,customClickBehavior:te.customClickBehavior}),...m&&{pointIdAccessor:m},...v&&v.length>0&&{annotations:v},...w&&{xExtent:w},...A&&{yExtent:A},...T};/* @__PURE__ */
51
- return oa(mt,{componentName:"WaterfallChart",width:W,height:N,children:/* @__PURE__ */oa(we,{ref:o,...me})})}),"WaterfallChart");export{Zt as a,ao as b,so as c,o as d,h as e,wo as f,Lo as g,To as h,jo as i,Yo as j,Jo as k,gi as l,Hi as m,Bi as n,Wi as o,Yi as p,Zi as q,ia as r};