semiotic 3.8.3 → 3.8.4

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 (163) hide show
  1. package/CLAUDE.md +9 -9
  2. package/README.md +40 -39
  3. package/ai/examples.md +1 -1
  4. package/ai/schema.json +2726 -300
  5. package/ai/surface-manifest.json +1 -1
  6. package/ai/system-prompt.md +1 -1
  7. package/dist/chunk-chunk-2JGJ5GUG.module.min.js +0 -1
  8. package/dist/chunk-chunk-3ILKBVVQ.module.min.js +1 -0
  9. package/dist/{chunk-chunk-XQYVEKEJ.module.min.js → chunk-chunk-6TPGFL7M.module.min.js} +1 -1
  10. package/dist/{chunk-chunk-VVCA3DB7.module.min.js → chunk-chunk-7ALTGHK6.module.min.js} +1 -1
  11. package/dist/chunk-chunk-7KZJUTKP.module.min.js +2 -0
  12. package/dist/chunk-chunk-7RYBCTK5.module.min.js +1 -0
  13. package/dist/chunk-chunk-ACLDBMRH.module.min.js +2 -0
  14. package/dist/{chunk-chunk-AZJUDQRM.module.min.js → chunk-chunk-AQPQN2HH.module.min.js} +1 -1
  15. package/dist/chunk-chunk-ASKSE5F5.module.min.js +1 -0
  16. package/dist/chunk-chunk-AVBI6GDT.module.min.js +1 -0
  17. package/dist/chunk-chunk-B3DRZPBK.module.min.js +2 -0
  18. package/dist/chunk-chunk-BFHUYEOS.module.min.js +2 -0
  19. package/dist/chunk-chunk-C4YA6TDR.module.min.js +1 -0
  20. package/dist/chunk-chunk-C57LR3YG.module.min.js +1 -0
  21. package/dist/chunk-chunk-F5V4UIE6.module.min.js +2 -0
  22. package/dist/chunk-chunk-F7WFPD4O.module.min.js +2 -0
  23. package/dist/{chunk-chunk-SANERMIZ.module.min.js → chunk-chunk-FBGHXL72.module.min.js} +1 -1
  24. package/dist/chunk-chunk-FP44FHFO.module.min.js +2 -0
  25. package/dist/chunk-chunk-HKXUAEPJ.module.min.js +2 -0
  26. package/dist/chunk-chunk-ICEXPNDC.module.min.js +2 -0
  27. package/dist/chunk-chunk-IY7RYD4S.module.min.js +1 -0
  28. package/dist/{chunk-chunk-7FW6EGLP.module.min.js → chunk-chunk-JDXT6ORT.module.min.js} +1 -1
  29. package/dist/chunk-chunk-JMVEIZXP.module.min.js +1 -0
  30. package/dist/chunk-chunk-KHCOJMGK.module.min.js +1 -0
  31. package/dist/{chunk-chunk-OQTLSTGI.module.min.js → chunk-chunk-KQ546MKE.module.min.js} +1 -1
  32. package/dist/chunk-chunk-LQBSXO7K.module.min.js +2 -0
  33. package/dist/chunk-chunk-LRIFN2HK.module.min.js +1 -0
  34. package/dist/chunk-chunk-MFHF4J2Z.module.min.js +1 -0
  35. package/dist/{chunk-chunk-JNCHKRIR.module.min.js → chunk-chunk-N6VKKF3A.module.min.js} +1 -1
  36. package/dist/chunk-chunk-NEVE562N.module.min.js +1 -0
  37. package/dist/chunk-chunk-NKZ75IM5.module.min.js +2 -0
  38. package/dist/chunk-chunk-PLIDPQNG.module.min.js +2 -0
  39. package/dist/{chunk-chunk-FYY2ACNJ.module.min.js → chunk-chunk-PRDGLMJT.module.min.js} +1 -1
  40. package/dist/chunk-chunk-QGZGZI4X.module.min.js +1 -0
  41. package/dist/chunk-chunk-RP7WTID5.module.min.js +1 -0
  42. package/dist/chunk-chunk-S7KLNUO6.module.min.js +1 -0
  43. package/dist/chunk-chunk-SR4ZXOWR.module.min.js +2 -0
  44. package/dist/chunk-chunk-ZOAQDIJO.module.min.js +1 -0
  45. package/dist/chunk-minimapBrushOverlay-JU57U7NM.module.min.js +2 -0
  46. package/dist/chunk-scatterplotMatrixBrushOverlay-SDIZSN66.module.min.js +2 -0
  47. package/dist/chunk-statisticalOverlays-QGDLRUHX.module.min.js +1 -0
  48. package/dist/chunk-statisticalOverlays-T77OKLDY.module.min.js +1 -0
  49. package/dist/components/ChartContainer.d.ts +2 -2
  50. package/dist/components/ai/chartCapabilityTypes.d.ts +5 -0
  51. package/dist/components/charts/geo/ChoroplethMap.d.ts +2 -0
  52. package/dist/components/charts/geo/DistanceCartogram.d.ts +7 -3
  53. package/dist/components/charts/geo/FlowMap.d.ts +4 -0
  54. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +3 -1
  55. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +6 -1
  56. package/dist/components/charts/physics/GaltonBoardChart.d.ts +6 -1
  57. package/dist/components/charts/physics/gauntletChartProps.d.ts +7 -1
  58. package/dist/components/charts/physics/gauntletChrome.d.ts +2 -1
  59. package/dist/components/charts/physics/gauntletPhysics.d.ts +19 -4
  60. package/dist/components/charts/physics/gauntletRuntime.d.ts +3 -0
  61. package/dist/components/charts/physics/physicsHocUtils.d.ts +12 -0
  62. package/dist/components/charts/shared/chartMode.d.ts +8 -0
  63. package/dist/components/charts/shared/chartSpecCore.d.ts +2 -2
  64. package/dist/components/charts/shared/hatchPattern.d.ts +8 -3
  65. package/dist/components/charts/shared/lineSeriesSsr.d.ts +55 -0
  66. package/dist/components/charts/shared/types.d.ts +2 -2
  67. package/dist/components/charts/shared/validateProps.d.ts +1 -1
  68. package/dist/components/charts/xy/AreaChart.d.ts +10 -0
  69. package/dist/components/charts/xy/minimapBrushOverlay.d.ts +17 -0
  70. package/dist/components/charts/xy/minimapBrushOverlayLazy.d.ts +4 -0
  71. package/dist/components/charts/xy/scatterplotMatrixBrushOverlay.d.ts +8 -0
  72. package/dist/components/charts/xy/scatterplotMatrixBrushOverlayLazy.d.ts +3 -0
  73. package/dist/components/realtime/types.d.ts +5 -0
  74. package/dist/components/recipes/gridObservatory.d.ts +176 -0
  75. package/dist/components/recipes/recipeChrome.d.ts +24 -0
  76. package/dist/components/recipes/sequenceLayout.d.ts +139 -0
  77. package/dist/components/semiotic-recipes-core.d.ts +6 -2
  78. package/dist/components/server/staticAnnotations.d.ts +3 -1
  79. package/dist/components/stream/SceneToSVG.d.ts +6 -6
  80. package/dist/components/stream/SceneToSVGOrdinal.d.ts +12 -0
  81. package/dist/components/stream/networkFramePaint.d.ts +2 -0
  82. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +18 -2
  83. package/dist/components/stream/physics/physicsBodyCanvas.d.ts +7 -0
  84. package/dist/components/stream/physics/physicsPipelineEviction.d.ts +15 -0
  85. package/dist/components/stream/physics/physicsPipelineObservations.d.ts +1 -1
  86. package/dist/components/stream/physics/physicsPipelineQuiescence.d.ts +20 -0
  87. package/dist/components/stream/sceneToSVGShared.d.ts +30 -1
  88. package/dist/components/stream/types.d.ts +4 -0
  89. package/dist/components/stream/useHydration.d.ts +7 -1
  90. package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +1 -1
  91. package/dist/forceLayoutWorker.js +1 -1
  92. package/dist/geo.min.js +1 -1
  93. package/dist/geo.module.min.js +1 -1
  94. package/dist/network.min.js +1 -1
  95. package/dist/network.module.min.js +1 -1
  96. package/dist/ordinal.min.js +1 -1
  97. package/dist/ordinal.module.min.js +1 -1
  98. package/dist/physics.min.js +1 -1
  99. package/dist/physics.module.min.js +1 -1
  100. package/dist/physicsWorker.js +1 -1
  101. package/dist/realtime.min.js +1 -1
  102. package/dist/realtime.module.min.js +1 -1
  103. package/dist/rough.min.js +1 -1
  104. package/dist/rough.module.min.js +1 -1
  105. package/dist/semiotic-ai-core.min.js +1 -1
  106. package/dist/semiotic-ai-core.module.min.js +1 -1
  107. package/dist/semiotic-ai.min.js +1 -1
  108. package/dist/semiotic-ai.module.min.js +1 -1
  109. package/dist/semiotic-experimental.min.js +1 -1
  110. package/dist/semiotic-experimental.module.min.js +1 -1
  111. package/dist/semiotic-realtime-core.min.js +1 -1
  112. package/dist/semiotic-realtime-core.module.min.js +1 -1
  113. package/dist/semiotic-recipes-core.d.ts +6 -2
  114. package/dist/semiotic-recipes-core.min.js +1 -1
  115. package/dist/semiotic-recipes-core.module.min.js +1 -1
  116. package/dist/semiotic-recipes.min.js +1 -1
  117. package/dist/semiotic-recipes.module.min.js +1 -1
  118. package/dist/semiotic-server-edge.min.js +1 -1
  119. package/dist/semiotic-server-edge.module.min.js +1 -1
  120. package/dist/semiotic-server-node.min.js +1 -1
  121. package/dist/semiotic-server-node.module.min.js +1 -1
  122. package/dist/semiotic-utils-core.min.js +1 -1
  123. package/dist/semiotic-utils-core.module.min.js +1 -1
  124. package/dist/semiotic-utils.min.js +1 -1
  125. package/dist/semiotic-utils.module.min.js +1 -1
  126. package/dist/semiotic-value.module.min.js +1 -1
  127. package/dist/semiotic.min.js +1 -1
  128. package/dist/semiotic.module.min.js +1 -1
  129. package/dist/server.min.js +1 -1
  130. package/dist/server.module.min.js +1 -1
  131. package/dist/xy.min.js +1 -1
  132. package/dist/xy.module.min.js +1 -1
  133. package/package.json +3 -2
  134. package/dist/chunk-chunk-255KDHW5.module.min.js +0 -1
  135. package/dist/chunk-chunk-2CCFBTQC.module.min.js +0 -2
  136. package/dist/chunk-chunk-2RXP3FS3.module.min.js +0 -1
  137. package/dist/chunk-chunk-2WVCH4PL.module.min.js +0 -1
  138. package/dist/chunk-chunk-4TMZXLCR.module.min.js +0 -1
  139. package/dist/chunk-chunk-5APBQXZA.module.min.js +0 -1
  140. package/dist/chunk-chunk-6HSGDMTA.module.min.js +0 -2
  141. package/dist/chunk-chunk-7OEOSCBP.module.min.js +0 -1
  142. package/dist/chunk-chunk-A63CTACR.module.min.js +0 -2
  143. package/dist/chunk-chunk-B6V35LMY.module.min.js +0 -2
  144. package/dist/chunk-chunk-BOSVL645.module.min.js +0 -2
  145. package/dist/chunk-chunk-CP3EN6KZ.module.min.js +0 -1
  146. package/dist/chunk-chunk-F25UA5HT.module.min.js +0 -1
  147. package/dist/chunk-chunk-FRIO6MCV.module.min.js +0 -1
  148. package/dist/chunk-chunk-GWSWSPXN.module.min.js +0 -1
  149. package/dist/chunk-chunk-I6C3KR5H.module.min.js +0 -2
  150. package/dist/chunk-chunk-IP2UE74X.module.min.js +0 -1
  151. package/dist/chunk-chunk-J3ELI22J.module.min.js +0 -1
  152. package/dist/chunk-chunk-J5RL6GXU.module.min.js +0 -2
  153. package/dist/chunk-chunk-L3H6DQCR.module.min.js +0 -2
  154. package/dist/chunk-chunk-M337NY6L.module.min.js +0 -1
  155. package/dist/chunk-chunk-M7VYYHCE.module.min.js +0 -2
  156. package/dist/chunk-chunk-MC35ILYP.module.min.js +0 -2
  157. package/dist/chunk-chunk-N72SWNBV.module.min.js +0 -1
  158. package/dist/chunk-chunk-OBQRFTIL.module.min.js +0 -2
  159. package/dist/chunk-chunk-QRIBHZYW.module.min.js +0 -1
  160. package/dist/chunk-chunk-SA3D43RA.module.min.js +0 -2
  161. package/dist/chunk-chunk-UHSZEB74.module.min.js +0 -1
  162. package/dist/chunk-chunk-Y6AXCRVO.module.min.js +0 -1
  163. package/dist/chunk-chunk-ZCNBUZPL.module.min.js +0 -2
@@ -0,0 +1 @@
1
+ import{accessorsEquivalent as t,annotationActivationProps as e,annotationBudget as n,annotationDensity as o,bandFromAge as i,createStore as r,filterAnnotationsByStatus as s,isAnnotationActivationTarget as a,isNoteAnnotation as l,mulberry32 as c,resolveAccessor as u,resolveRawAccessor as h,resolveResponsiveRules as d,resolveStringAccessor as f,useAnnotationActivationOptions as p,useObservationSelector as y,validateArrayData as g}from"./chunk-chunk-RP7WTID5.module.min.js";import{SEGMENT_FIELD as m,buildAnomalyAnnotations as x,buildForecast as b,createSegmentLineStyle as v,getMax as w,getMin as k,getMinMax as S}from"./chunk-chunk-AVBI6GDT.module.min.js";function A(t){if(!t?.colors)return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function M(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e={...e,colors:{...e.colors,categorical:_}}),t.accessibility.highContrast){const t="dark"===e.mode;e={...e,colors:{...e.colors,text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"}}}return e}var _=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],P={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},C={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},T={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:_,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function L(t,e){if("light"===e)return P;if("dark"===e)return C;if("high-contrast"===e)return T;if("string"==typeof e)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${e}". Keeping current theme.`),t;if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?C:P;return M({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}return M({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}var[R,$]=r(t=>({theme:P,setTheme(e){t(t=>({theme:L(t.theme,e)}))}})),z={light:P,dark:C,"high-contrast":T,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#64717f",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#c63b3b",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function D(t){if(!t)return P;if("string"==typeof t){if("light"===t)return P;if("dark"===t)return C;if("high-contrast"===t)return T;return z[t]||P}const e="dark"===t.mode?C:P;return M({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}},tooltip:{...e.tooltip,...t.tooltip||{}}})}function I(t){return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:t.colors.annotation??t.colors.text,legendSize:t.typography.legendSize??t.typography.labelSize,titleFontSize:t.typography.titleFontSize??t.typography.titleSize,tickFontFamily:t.typography.tickFontFamily??t.typography.fontFamily}}var B={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function F(t,e={}){const n=e.mobileSemantics?.interaction,o="number"==typeof n?.targetSize?n.targetSize:"number"==typeof e.mobileSemantics?.minimumHitTarget?e.mobileSemantics.minimumHitTarget:void 0,i="mobile"===e.mode||"number"==typeof e.width&&480>=e.width,r=!!n||void 0!==o,s=t&&"object"==typeof t?t:void 0;if(!1===t||!1===s?.enabled||void 0===t&&!i&&!r)return B;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??o??44,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??44,standardControls:a.standardControls??!1}}var E={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function O(t,e,n){const o=E[t||"primary"],i=t&&"primary"!==t||!n?.width?o.width:n.width,r=t&&"primary"!==t||!n?.height?o.height:n.height,s={...e,mode:t},a=d(s,{width:e.width??i,height:e.height??r}).props,l=a.mode||t||"primary",c=E[l],u="context"===l||"sparkline"===l,h="primary"===l&&n?.width?n.width:c.width;return{mode:l,width:a.width??h,height:a.height??("primary"===l&&n?.height?n.height:c.height),showAxes:a.showAxes??c.showAxes,showGrid:a.showGrid??c.showGrid,enableHover:a.enableHover??(!!a.linkedHover||c.enableHover),showLegend:a.showLegend??c.showLegend,showLabels:a.showLabels??c.showLabels,title:u?void 0:a.title,description:a.description,summary:a.summary,accessibleTable:a.accessibleTable,xLabel:u?void 0:a.xLabel,yLabel:u?void 0:a.yLabel,categoryLabel:u?void 0:a.categoryLabel,valueLabel:u?void 0:a.valueLabel,marginDefaults:N(c.marginDefaults,a.showCategoryTicks,a.orientation),compactMode:u,mobileInteraction:F(a.mobileInteraction,{mode:l,width:a.width??h,mobileSemantics:a.mobileSemantics}),mobileSemantics:a.mobileSemantics}}function N(t,e,n){if(!1!==e)return t;const o={...t};return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}import*as W from"react-dom/server";import*as j from"react";function Y({data:t,safeData:e,areaBy:n,lineDataAccessor:o}){if(null==t)return[];const i=void 0!==e[0]?.[o];if(!i&&!n)return e;let r;if(i)r=e;else{const t=e.reduce((t,e)=>{const i="function"==typeof n?n(e):e[n],r=i+"";if(!t[r]){const e={[o]:[]};"string"==typeof n&&(e[n]=i),t[r]=e}return t[r][o].push(e),t},{});r=Object.values(t)}return r.flatMap(t=>{const e=Array.isArray(t[o])?t[o]:[];return"string"==typeof n?e.map(e=>({...e,[n]:e[n]??t[n]})):e})}var G=Object.freeze([]);function q(t){if(!t)return G;let e=!1;for(let n=0;t.length>n;n++){const o=t[n];if(null==o||"object"!=typeof o){e=!0;break}}if(!e)return t;const n=[];for(const e of t)null!=e&&"object"==typeof e&&n.push(e);return n}import{scaleOrdinal as X}from"d3-scale";function H(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function V(t,e,n){const o=t=>t.toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(n)}`}function U(t){const e=t.map(H),n=e.length-1;return t=>{if(0>=t){const[t,n,o]=e[0];return V(t,n,o)}if(t>=1){const[t,o,i]=e[n];return V(t,o,i)}const o=t*n,i=Math.floor(o),r=o-i,[s,a,l]=e[i],[c,u,h]=e[i+1];return V(Math.round(s+(c-s)*r),Math.round(a+(u-a)*r),Math.round(l+(h-l)*r))}}var K=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Z=U(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Q=U(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),J=U(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),tt=U(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),et=U(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),nt=U(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),ot=U(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),it=U(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),rt=U(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),st=U(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),at=U(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),lt=U(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ct={blues:Z,reds:Q,greens:J,viridis:ot,oranges:tt,purples:et,greys:nt,plasma:it,inferno:rt,magma:st,cividis:at,turbo:lt};function ut(t){return t&&ct[t]||Z}var ht=U(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),dt=U(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),ft=U(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),pt=U(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),yt=U(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),gt=U(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),mt=U(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),xt={category10:K,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...ct},bt=K,vt="#007bff";function wt(t,e,n=bt){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=Object.values(t).filter(t=>"string"==typeof t&&t.length>0);if(e.length>0)return e}if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=xt[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}var kt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],St=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],At=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function Mt(t,e,n){if("function"==typeof e){const o=e(t);return n&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||At.has(e)}(o)?n(o):o}const o=t?.[e]+"";return n?n(o):bt[Math.abs(function(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n),e&=e;return Math.abs(e)}(o))%bt.length]}function _t(t,e){if(null==e||!Object.prototype.hasOwnProperty.call(t,e))return;const n=t[e];return"string"==typeof n&&n.length>0?n:void 0}function Pt(t,e,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const t=n;return e=>_t(t,e)??"#999"}const o=Array.from(new Set(t.map(t=>t?.[e]).filter(t=>null!=t).map(t=>t+""))),i=o.every(t=>!isNaN(Number(t)));if(Array.isArray(n))return X().domain(o).range(n).unknown("#999");const r=xt[n]||xt.category10;if(i&&"function"==typeof r){let t=-1/0;for(const e of o){const n=Number(e);n>t&&(t=n)}return e=>r(Number(e)/t)}{const t=Array.isArray(r)?r:bt;return X().domain(o).range(t).unknown("#999")}}function Ct(t,e,n=[3,20],o){let i;if(i="function"==typeof e?e(t):t?.[e],!o)return i;const[r,s]=o,[a,l]=n;if(s===r)return(a+l)/2;let c=(i-r)/(s-r);return 0>c?c=0:c>1&&(c=1),a+c*(l-a)}function Tt(t,e){if(!function(t){return void 0!==t.stroke||void 0!==t.strokeWidth||void 0!==t.opacity}(e))return t??((...t)=>({}));const n={};return void 0!==e.stroke&&(n.stroke=e.stroke),void 0!==e.strokeWidth&&(n.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(n.opacity=e.opacity),t?(...e)=>({...t(...e)||{},...n}):(...t)=>({...n})}function Lt(t){if(null==t)return()=>{};const e="function"==typeof t?t:e=>e[t];return t=>zt(e(t))}function Rt(t,e){const n=Lt(t),o=Lt(e);return(t,e)=>{const i=o(t);return{value:i,x:n(t),y:i,category:e}}}function $t(t,e){const n=Lt(e??"value"),o=null==t?void 0:"function"==typeof t?t:e=>e[t];return t=>{const e=o?o(t):void 0;return{value:n(t),category:null==e?void 0:e+""}}}function zt(t){if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t&&""!==t.trim()){const e=Number(t);return Number.isFinite(e)?e:void 0}}function Dt(t,e,n){const o=t.when;return void 0===o||!0===o||!1!==o&&("function"==typeof o?o(e,n):function(t,e,n){const o=null!=t.axis?n[t.axis]:null!=t.field?e[t.field]:n.value;if(void 0!==t.eq&&o!==t.eq)return!1;if(void 0!==t.ne&&o===t.ne)return!1;if(void 0!==t.in&&!t.in.includes(o))return!1;if(void 0===t.gt&&void 0===t.gte&&void 0===t.lt&&void 0===t.lte&&void 0===t.within&&void 0===t.outside)return!0;const i=zt(o);if(void 0===i)return!1;if(void 0!==t.gt&&t.gt>=i)return!1;if(void 0!==t.gte&&t.gte>i)return!1;if(void 0!==t.lt&&i>=t.lt)return!1;if(void 0!==t.lte&&i>t.lte)return!1;if(void 0!==t.within){const[e,n]=t.within;if(e>i||i>n)return!1}if(void 0!==t.outside){const[e,n]=t.outside;if(i>=e&&n>=i)return!1}return!0}(o,e,n))}function It(t,e,n){if(!e||0===e.length)return{};let o={};for(const i of e){if(!Dt(i,t,n))continue;const e="function"==typeof i.style?i.style(t,n):i.style;e&&(o={...o,...e})}return o}function Bt(t,e,n,o=t=>t){const i=t??(()=>({}));return e&&0!==e.length?(t,r)=>{const s=o(t),a={...i(t,r)};return Object.assign(a,It(s,e,n(s,r))),a}:i}function Ft(t,e,n,o){if(!t||0===t.length)return o;const i=$t(e,n);return(e,n)=>{const r=e&&e.data||e,s=It(r,t,i(r)),a=o?o(e,n):void 0;return a?{...s,...a}:s}}function Et(t,e){return"touch"===e?Math.max(t,24):t}function Ot(t){return Array.isArray(t)?t[0]:t}function Nt(t,e,n,o){return{data:Ot(t),x:e,y:n,__semioticHoverData:!0,...o}}var Wt=["name","label","title"],jt=["type","kind","category","group","class","status","role","shape"],Yt=["value","amount","total","count","weight","score"],Gt=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function qt(t,e){for(const n of e){const e=t.find(t=>t.lower===n);if(e)return e}}function Xt(t,e={}){if(!t||"object"!=typeof t)return{entries:[]};const n=e.maxEntries??6,o=!1!==e.skipPositional,i=[];for(const[e,n]of Object.entries(t)){if(e.startsWith("_"))continue;if("data"===e)continue;if(o&&Gt.has(e.toLowerCase()))continue;if(null==n)continue;const t=typeof n;("string"===t||"number"===t||"boolean"===t||n instanceof Date)&&i.push({key:e,lower:e.toLowerCase(),value:n})}if(0===i.length)return{entries:[]};let r=i.findIndex(t=>Wt.includes(t.lower));const s=r>=0;0>r&&(r=i.findIndex(t=>"id"===t.lower)),0>r&&(r=i.findIndex(t=>"string"==typeof t.value));const a=0>r?void 0:i[r];let l=i.filter((t,e)=>e!==r);s&&(l=l.filter(t=>"id"!==t.lower));const c=qt(l,jt),u=qt(l,Yt),h=new Set(jt),d=new Set(Yt),f=[];c&&f.push({key:c.key,value:c.value}),u&&f.push({key:u.key,value:u.value});for(const t of l){if(f.length>=n)break;t!==c&&t!==u&&(h.has(t.lower)||d.has(t.lower)||f.push({key:t.key,value:t.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}import{jsx as Ht,jsxs as Vt}from"react/jsx-runtime";var Ut={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Kt(t,e){return"function"==typeof e?e(t):t[e]}function Zt(t,e){if(e)return e(t);if(null==t)return"";if("number"==typeof t){if(!Number.isFinite(t))return t+"";const e=Number.isInteger(t)?t:parseFloat(t.toPrecision(6));return Math.abs(e)>9999?e.toLocaleString():e+""}return t instanceof Date?t.toLocaleDateString():"object"==typeof t&&null!==t?void 0!==t.id?t.id+"":void 0!==t.name?t.name+"":JSON.stringify(t):t+""}function Qt(t={}){const{fields:e,title:n,format:o,style:i={},className:r=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let s;const a=[];if(n){const e=Kt(t,n);s=Zt(e,o)}if(e&&e.length>0)e.forEach(e=>{let n,i,r;"string"==typeof e?(n=e,i=e,r=o):(n=e.label,i=e.accessor||e.key||"",r=e.format||o);const s=Kt(t,i);a.push({label:n,value:Zt(s,r)})});else if(!n){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){s=Zt(t[n],o);break}if(!s){const e=Object.keys(t).filter(t=>!t.startsWith("_"));e.length>0&&(s=Zt(t[e[0]],o))}}const l={...Ut,...i};return Vt("div",{className:("semiotic-tooltip "+r).trim(),style:l,children:[s&&Ht("div",{style:{fontWeight:a.length>0?"bold":"normal"},children:s}),a.map((t,e)=>Vt("div",{style:{marginTop:0===e&&s?"4px":0},children:[t.label&&Vt("span",{children:[t.label,": "]}),t.value]},e))]})}}function Jt(t){if(!0!==t){if("function"==typeof t){const e=t;return t=>{let n=Ot(!0===t?.__semioticHoverData||t&&void 0!==t.data&&"number"==typeof t.x&&"number"==typeof t.y&&t&&("node"===t.type||"edge"===t.type||void 0!==t.nodeOrEdge||void 0!==t.allSeries||void 0!==t.stats||void 0!==t.__chartType)?t.data??{}:t);if(!n)return null;if(("node"===t?.nodeOrEdge&&"number"==typeof n?.x0&&"number"==typeof n?.x1||"edge"===t?.nodeOrEdge&&"number"==typeof n?.sankeyWidth)&&n.data&&"object"==typeof n.data&&(n=n.data),!n)return null;const o=e(n);return null==o?null:Ht("div",{className:"semiotic-tooltip",style:Ut,children:o})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?Qt(t):"multi"===t?("undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&console.warn('[semiotic] tooltip="multi" reached normalizeTooltip — prefer charts that set tooltipMode (LineChart, AreaChart, StackedAreaChart, DifferenceChart). Rendering MultiLineTooltip content as a fallback.'),function(t={}){const{fields:e=[],title:n,format:o,style:i={},className:r="",showLabels:s=!0,separator:a=": "}=t;return t=>{if(!t||"object"!=typeof t)return null;const l=[];if(n){const e=Kt(t,n);l.push({value:Zt(e,o)})}if(e&&Array.isArray(e)&&e.length>0)e.forEach(e=>{let n,i,r;"string"==typeof e?(n=e,i=e,r=o):(n=e.label,i=e.accessor||e.key||"",r=e.format||o);const a=Zt(Kt(t,i),r);l.push({label:s?n:void 0,value:a})});else{const e=Xt(t,{skipPositional:!1});null!=e.title&&l.push({label:void 0,value:Zt(e.title,o),bold:!0}),e.entries.forEach(t=>{l.push({label:s?t.key:void 0,value:Zt(t.value,o)})})}const c={...Ut,...i};return Array.isArray(l)&&0!==l.length?Ht("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+r).trim(),style:c,children:l.map((t,e)=>Vt("div",{style:{marginBottom:l.length-1>e?"4px":0,fontWeight:t.bold?"bold":void 0},children:[t.label&&Vt("strong",{children:[t.label,a]}),t.value]},e))}):null}}()):Qt())}}function te(t){const{title:e,description:n,summary:o,accessibleTable:i,className:r,animate:s,axisExtent:a,autoPlaceAnnotations:l}=t,c={};return e&&(c.title=e),n&&(c.description=n),o&&(c.summary=o),void 0!==i&&(c.accessibleTable=i),r&&(c.className=r),null!=s&&(c.animate=s),void 0!==a&&(c.axisExtent=a),void 0!==l&&(c.autoPlaceAnnotations=l),c}function ee(t){const{linkedHover:e,selection:n,onObservation:o,onClick:i,hoverRadius:r,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:h,linkedHoverInClickPredicate:d=!0}=t,f={};o&&(f.annotationObservationCallback=o);const p=c?.enabled?Math.max(r??30,Math.ceil((c.targetSize||44)/2),24):r;return(a||e||o||i||s)&&(f.customHoverBehavior=u),h&&(l||(d?o||i||e:o||i)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(e||s||n))&&(f.customClickBehavior=h),null!=p&&(f.hoverRadius=p),f}function ne(t){const{tooltip:e,defaultTooltipContent:n}=t;return{tooltipContent:!1===e?()=>null:Jt(e)||n}}import{useMemo as oe,forwardRef as ie,useRef as re}from"react";import*as se from"react";import{useRef as ae,useState as le,useEffect as ce,useMemo as ue,useCallback as he,useImperativeHandle as de,useId as fe,forwardRef as pe,memo as ye}from"react";import*as ge from"react";import{jsx as me}from"react/jsx-runtime";var xe=null,be=null;function ve(t){const[e,n]=ge.useState(()=>xe);return ge.useEffect(()=>{if(e)return;let t=!1;return(xe?Promise.resolve(xe):(be||(be=import("./chunk-XYBrushOverlay-ECZJJLAJ.module.min.js").then(t=>xe=t.XYBrushOverlay).catch(t=>{throw be=null,t})),be)).then(e=>{t||n(()=>e)}),()=>{t=!0}},[e]),e?me(e,{...t}):null}var we=class{constructor(t,e){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=e?.chunkThreshold??5e3,this.chunkSize=e?.chunkSize??5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(t=q(t),this.lastBoundedData===t)return;if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,o),bounded:!1}),e=o,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(t=q(t),this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,o),bounded:!1}),e=o,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){null!=t&&"object"==typeof t&&(this.pushBuffer.push(t),this.scheduleFlush())}pushMany(t){if(0===t.length)return;let e=0;for(let n=0;t.length>n;n++){const o=t[n];null!=o&&"object"==typeof o&&(this.pushBuffer.push(o),e++)}0!==e&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}},ke=class{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray();let n=0,o=[];e.length>t&&(n=e.length-t,o=e.slice(0,n)),this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(let t=n;e.length>t;t++)this.push(e[t]);return o}update(t,e){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const r=(o+i)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(t),this.buffer[r]=e(s)}}return n}remove(t){const e=[],n=[];if(this.forEach(o=>{t(o)?n.push(o):e.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},Se=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}},Ae=/^\d{4}-\d{1,2}$/;function Me(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const n=Ae.test(e)?e+"-01":e;if(n===e&&10>e.length)return NaN;const o=Date.parse(n);return Number.isFinite(o)?o:NaN}function _e(t){return t instanceof Date?t.getTime():"string"==typeof t?Me(t):+t}function Pe(t){return new Set(Array.isArray(t)?t:[t])}function Ce(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function Te(t,e){return Math.min((t-e.startTime)/e.duration,1)}function Le(t,e,n){return t+(e-t)*n}function Re(){return"undefined"!=typeof performance?performance.now():Date.now()}function $e(t,e,n){if(1>=n)return 1;const o=n-1;return function(t){const e=Math.max(0,Math.min(1,t.minOpacity??.1));if(Number.isNaN(t.age))return 1;if(t.age===1/0)return e;if(!Number.isFinite(t.extent)||0>=t.extent)return 1;const n=Math.max(0,t.age);if("step"===t.type)return(t.threshold??.5*t.extent)>n?1:e;if("exponential"===t.type){const o=t.halfLife??t.extent/2;return e+Math.pow(.5,n/(o>0?o:t.extent/2))*(1-e)}return e+Math.max(0,Math.min(1,1-n/t.extent))*(1-e)}({age:o-e,extent:o,type:t.type,halfLife:t.halfLife??n/2,threshold:t.stepThreshold??.5*n,minOpacity:t.minOpacity??.1})}function ze(t){const e=new Map;for(let n=0;t.length>n;n++)e.set(t[n],n);return e}function De(t,e,n){const o=t.duration??500,i=n-e;return o>i?1-i/o:0}function Ie(t,e,n,o){let i=!1;return e>0?(t._pulseIntensity!==e&&(t._pulseIntensity=e,i=!0),t._pulseColor!==n&&(t._pulseColor=n,i=!0),t._pulseGlowRadius!==o&&(t._pulseGlowRadius=o,i=!0),i):(0!==t._pulseIntensity&&(t._pulseIntensity=0,i=!0),void 0!==t._pulseColor&&(t._pulseColor=void 0,i=!0),void 0!==t._pulseGlowRadius&&(t._pulseGlowRadius=void 0,i=!0),i)}function Be(t,e,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!e||0===e.size)return!1;const o=t.duration??500,i=e.peek();return null!=i&&o>n-i}function Fe(t,e,n){if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"glyph":return e.pointId?"g:"+e.pointId:"g:"+n;case"rect":return`r:${e.group||""}:${e.datum?.binStart??e.datum?.category??n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function Ee(t,e,n,o,i,r){const s=[];for(const i of t){const t=n(i),r=o(i);Number.isFinite(t)&&Number.isFinite(r)&&s.push({px:e.x(t),py:e.y(r),rawY:r,d:i})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],l[t]=e.rawY,c[t]=e.d}return{type:"line",path:a,rawValues:l,style:i,datum:c,group:r}}function Oe(t,e,n,o,i,r,s,a){const l=[];for(const r of t){const t=n(r),s=o(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const c=e.x(t),u=a?a(r):i;l.push({px:c,topY:e.y(s),botY:e.y(u)})}l.sort((t,e)=>t.px-e.px);const c=Array(l.length),u=Array(l.length);for(let t=0;l.length>t;t++){const e=l[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:r,datum:t,group:s}}function Ne(t,e,n,o){const i=new Map;if("silhouette"===o)for(const o of t){let t=0;for(const i of e)t+=n(i,o)||0;i.set(o,-t/2)}else if("wiggle"===o){t.length>0&&i.set(t[0],0);for(let o=1;t.length>o;o++){const r=t[o-1],s=t[o];let a=0,l=0,c=0;for(const t of e){const e=n(t,s)||0;a+=(2*c+e)*(e-(n(t,r)||0)),l+=e,c+=e}const u=i.get(r)??0;i.set(s,u-(l>0?a/(2*l):0))}if(t.length>0){let o=0;for(const r of t){let t=0;for(const o of e)t+=n(o,r)||0;o+=(i.get(r)??0)+t/2}const r=o/t.length;for(const e of t)i.set(e,(i.get(e)??0)-r)}}else for(const e of t)i.set(e,0);return i}function We(t,e,n,o,i,r,s){const a=n(t),l=o(t);if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c={type:"point",x:e.x(a),y:e.y(l),r:i,style:r,datum:t};return void 0!==s&&(c.pointId=s),c}function je(t,e,n,o,i,r,s,a){const l=n(t),c=o(t);if(!Number.isFinite(l)||!Number.isFinite(c))return null;const u={type:"symbol",x:e.x(l),y:e.y(c),size:i,symbolType:r,style:s,datum:t};return void 0!==a&&(u.pointId=a),u}function Ye(t,e,n,o,i,r,s){return{type:"rect",x:t,y:e,w:n,h:o,style:i,datum:r,group:s}}function Ge(t,e,n,o,i,r,s){const a={type:"heatcell",x:t,y:e,w:n,h:o,fill:i,datum:r};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function qe(t,e,n,o){return"function"==typeof e.style?e.style(o||{},n):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(n,o)}function Xe(t,e,n,o){if(!t.scales)return null;const i=[],r=[];for(const n of e){const e=t.getX(n);if(!Number.isFinite(e))continue;const s=o.getTop(n),a=o.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const l=t.scales.x(e),c=t.scales.y(s),u=t.scales.y(a);Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(u)&&(i.push([l,c]),r.push([l,u]))}return 2>i.length?null:{type:"area",topPath:i,bottomPath:r,...t.config.curve&&"linear"!==t.config.curve&&{curve:t.config.curve},style:qe(t,o,n,e[0]),datum:e,group:n,interactive:o.interactive}}function He(t){const e=[],n=[];if(!t)return{perSeries:e,aggregate:n};for(const o of t)o.perSeries?e.push(o):n.push(o);return{perSeries:e,aggregate:n}}function Ve(t,e,n){const o=[];for(const i of n){const n=Xe(t,e,"__ribbon_aggregate",i);n&&o.push(n)}return o}function Ue(t,e,n,o){const i=[];for(const r of o){const o=Xe(t,e,n,r);o&&i.push(o)}return i}function Ke(t,e){if(!t)return{};if(!e||0===e.length)return t;const n=[];for(const o of e){if("band"!==o.kind)continue;const e=o.getTop(t),i=o.getBottom(t);Number.isFinite(i)&&Number.isFinite(e)&&n.push({y0:i,y1:e})}return 0===n.length?t:{...t,band:n[0],bands:n}}function Ze(t,e,n,o){if(!t.config.pointStyle)return;const i=o??t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const r of o.data){let o=t.config.pointStyle(r);!o.fill&&e&&(o={...o,fill:e});const s=o.r??3,a=t.getPointId?t.getPointId(r)+"":void 0,l=We(r,t.scales,t.getX,i,s,o,a);l&&n.push(l)}}}function Qe(t){return"threshold"===t.type&&"string"==typeof t.color&&"number"==typeof t.value}var Je={topOpacity:.8,bottomOpacity:.05};function tn(t){if(t)return!0===t?Je:"colorStops"in t?t:{topOpacity:t.topOpacity??Je.topOpacity,bottomOpacity:t.bottomOpacity??Je.bottomOpacity}}import{symbol as en,symbolCircle as nn,symbolCross as on,symbolDiamond as rn,symbolSquare as sn,symbolStar as an,symbolTriangle as ln,symbolWye as cn}from"d3-shape";var un={circle:nn,square:sn,triangle:ln,diamond:rn,star:an,cross:on,wye:cn},hn=["circle","triangle","diamond","star","square","chevron","cross","wye"];function dn(t,e,n){if(n)return n;const o=t??"circle";return"chevron"===o?function(t){const e=1.5*fn(t),n=.92*e;return`M0,${-e}L${n},${(.78*e).toFixed(3)}L0,${(.28*e).toFixed(3)}L${-n},${(.78*e).toFixed(3)}Z`}(e):en(un[o]??nn,Math.max(1,e))()??""}function fn(t){return Math.sqrt(Math.max(1,t)/Math.PI)}var pn=new Map;function yn(t,e,n){const o=n.config.areaStyle?.(e);return o&&(t.style=o),t}function gn(t,e,n,o,i){const r=new Map;for(const s of t){const t=e(s),a=n(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=Math.floor(t/o)*o;let c=r.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},r.set(l,c)),c.total+=a,i){const t=i(s);c.categories.set(t,(c.categories.get(t)||0)+a)}}return r}function mn(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:n,overlays:o,warned:i}=t;xn(o)&&0===n.length&&bn(i,"overlay-only",`[semiotic] ${e} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(t=>null==t.datum)&&bn(i,"null-datums",`[semiotic] ${e} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function xn(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(xn))}function bn(t,e,n){t.has(e)||(t.add(e),console.warn(n))}function vn(t,e,n,o){const i=function(t){if(t instanceof Error)return{name:t.name||"Error",message:t.message||"Custom layout threw."};if("string"==typeof t)return{name:"Error",message:t};if(null==t)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:t+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(e),r="network"===t?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:t,source:r,message:`Semiotic ${t} ${r} failed: ${i.message}`,error:i,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:o}}function wn(t,e){const n="function"==typeof t?t:n=>n[t||e];return t=>{const e=n(t);return null==e?NaN:+e}}function kn(t){const e=[],n=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,o=wn(n&&t.valueAccessor||t.yAccessor,n?"value":"y");if(t.boundsAccessor){const n=u(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const i=n(t);return Number.isFinite(i)&&0!==i?e+i:e},getBottom:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const i=n(t);return Number.isFinite(i)&&0!==i?e-i:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const n=Array.isArray(t.band)?t.band:[t.band];for(const t of n)e.push({kind:"band",getTop:wn(t.y1Accessor,"y1"),getBottom:wn(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}import{scaleLinear as Sn,scaleLog as An,scaleSymlog as Mn,scaleTime as _n}from"d3-scale";function Pn(t,e){return e?[e[0]??t[0],e[1]??t[1]]:t}function Cn(t,e,n){if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return An().domain(t).range(n).clamp(!0)}return"symlog"===t?Mn().domain(e).range(n):"time"===t?_n().domain([new Date(e[0]),new Date(e[1])]).range(n):Sn().domain(e).range(n)}function Tn(t,e,n){e>t.capacity&&(t.resize(e),n&&e>n.capacity&&n.resize(e))}function Ln(t,e){const n=new ke(t.capacity);return t.forEach(()=>n.push(e)),n}function Rn(t,e,n,o){const i=t.push(e);return n&&n.push(o),i}function $n(t,e,n){if(!e||0===e.size)return;const o=new Set;if(t.forEach((t,e)=>{n(t)&&o.add(e)}),0===o.size)return;const i=e.toArray();e.clear();for(let t=0;i.length>t;t++)o.has(t)||e.push(i[t])}var zn=new WeakMap;function Dn(){return this.updateResults.last}function In(){return this.updateResults.last}function Bn(t){return this.updateResults.subscribe(t)}function Fn(t){this.config.layoutSelection=t}function En(){zn.set(this,!0)}function On(){const t=!0===zn.get(this);return zn.delete(this),t}function Nn(t){Object.assign(t.prototype,{getLastUpdateResult:Dn,getUpdateSnapshot:In,subscribeUpdateResult:Bn,setLayoutSelection:Fn,markStylePaintPending:En,consumeStylePaintPending:On})}var Wn={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 jn(t,e){const n={...t};for(const t of e)n[Wn[t]]++;return n}function Yn(t,e,n){const o=new Set(e);return{changeSet:{...t,...t.keys?{keys:[...t.keys]}:{}},changed:o,revisions:jn(n,o)}}var Gn=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=new Set}get last(){return this.latest}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}record(t,e){const n=Yn(t,e,this.revisions);this.revisions=n.revisions,this.latest=n;for(const t of[...this.listeners])t();return n}},qn=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Xn=["scene-style","data-paint","accessibility","evidence"],Hn=(t,e)=>({retainedData:t,invalidations:e}),Vn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Un=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Kn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Zn=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Qn=["scene-geometry","data-paint","accessibility","evidence"],Jn=["scene-style","data-paint","accessibility","evidence"],to=[],eo={chartType:Hn("rebuild",Vn),runtimeMode:Hn("rebuild",Vn),xAccessor:Hn("rebuild",Vn),yAccessor:Hn("rebuild",Vn),timeAccessor:Hn("rebuild",Vn),valueAccessor:Hn("rebuild",Vn),y0Accessor:Hn("rebuild",Vn),boundsAccessor:Hn("rebuild",Vn),band:Hn("rebuild",Vn),openAccessor:Hn("rebuild",Vn),highAccessor:Hn("rebuild",Vn),lowAccessor:Hn("rebuild",Vn),closeAccessor:Hn("rebuild",Vn),candlestickRangeMode:Hn("rebuild",Vn),accessorRevision:Hn("rebuild",Vn),groupAccessor:Hn("rebuild",Un),categoryAccessor:Hn("rebuild",Un),lineDataAccessor:Hn("rebuild",Un),colorAccessor:Hn("rebuild",Jn),sizeAccessor:Hn("rebuild",Qn),symbolAccessor:Hn("rebuild",Qn),pointIdAccessor:Hn("rebuild",Qn),xScaleType:Hn("preserve",Kn),yScaleType:Hn("preserve",Kn),xExtent:Hn("preserve",Kn),yExtent:Hn("preserve",Kn),extentPadding:Hn("preserve",Kn),scalePadding:Hn("preserve",Kn),axisExtent:Hn("preserve",Kn),binSize:Hn("preserve",Kn),normalize:Hn("preserve",Kn),heatmapAggregation:Hn("preserve",Kn),heatmapXBins:Hn("preserve",Kn),heatmapYBins:Hn("preserve",Kn),arrowOfTime:Hn("preserve",Zn),baseline:Hn("preserve",Zn),stackOrder:Hn("preserve",Zn),sizeRange:Hn("preserve",Zn),curve:Hn("preserve",Zn),areaGroups:Hn("preserve",Zn),customLayout:Hn("preserve",Zn),layoutConfig:Hn("preserve",Zn),layoutMargin:Hn("preserve",Zn),symbolMap:Hn("preserve",Qn),showValues:Hn("preserve",Qn),heatmapValueFormat:Hn("preserve",Qn),lineStyle:Hn("preserve",Jn),pointStyle:Hn("preserve",Jn),areaStyle:Hn("preserve",Jn),barStyle:Hn("preserve",Jn),swarmStyle:Hn("preserve",Jn),waterfallStyle:Hn("preserve",Jn),candlestickStyle:Hn("preserve",Jn),boundsStyle:Hn("preserve",Jn),gradientFill:Hn("preserve",Jn),lineGradient:Hn("preserve",Jn),colorScheme:Hn("preserve",Jn),themeCategorical:Hn("preserve",Jn),themeSemantic:Hn("preserve",Jn),themeSequential:Hn("preserve",Jn),themeDiverging:Hn("preserve",Jn),barColors:Hn("preserve",Jn),decay:Hn("preserve",Jn),pulse:Hn("preserve",Jn),staleness:Hn("preserve",Jn),layoutSelection:Hn("preserve",Jn),annotations:Hn("preserve",["overlay","accessibility","evidence"]),windowSize:Hn("preserve",to),windowMode:Hn("preserve",to),maxCapacity:Hn("preserve",to),clock:Hn("preserve",to),transition:Hn("preserve",to),introAnimation:Hn("preserve",to),onLayoutError:Hn("preserve",to)},no=Hn("preserve",Zn),oo=class{constructor(){this.tracker=new Gn}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},qn)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Xn):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const n=new Set;for(const o of t){const t=eo[o]??no;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)n.add(e)}return{retainedData:e,invalidations:n}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}};import{quadtree as io}from"d3-quadtree";var ro=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(t,e){if("scatter"!==t&&"bubble"!==t&&"custom"!==t)return void this.clear();let n=0,o=0;for(const t of e)"point"===t.type&&(n++,t.r>o&&(o=t.r));if(this.maxRadius=o,500>=n)return void(this.tree=null);const i=Array(n);let r=0;for(const t of e)"point"===t.type&&(i[r++]=t);this.tree=io().x(t=>t.x).y(t=>t.y).addAll(i)}},so=class e{constructor(t){if(this.xExtent=new Se,this.yExtent=new Se,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new oo,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new ro,this._lastBoundedInsertsRef=null,this.applyPulse=(t,e,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,n,o,i,r=("undefined"!=typeof performance?performance.now():Date.now())){const s=t.color??"rgba(255,255,255,0.6)",a=t.glowRadius??4;let l=!1;const c=i??(()=>{const t=new Map;for(let e=0;n.length>e;e++)t.set(n[e],e);return t})();for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let i=0,a=!1;for(const n of e){const e=c.get(n);if(null==e)continue;a=!0;const s=o.get(e);if(null==s)continue;const l=De(t,s,r);l>i&&(i=l)}a&&(l=Ie(n,i,s)||l);continue}const e=c.get(n.datum);if(null==e)continue;const i=o.get(e);l=Ie(n,null==i?0:De(t,i,r),s,a)||l}return l}(this.config.pulse,t,e,this.timestampBuffer,this.getDatumIndexMap(e),n),this.config=t,this.buffer=new ke(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=u(t.timeAccessor||t.xAccessor,"time"),this.getY=u(t.valueAccessor||t.yAccessor,"value")):(this.getX=u(t.xAccessor,"x"),this.getY=u(t.yAccessor,"y")),this.getGroup=f(t.groupAccessor),this.getCategory=f(t.categoryAccessor),this.getSize=t.sizeAccessor?u(t.sizeAccessor,"size"):void 0,this.getColor=f(t.colorAccessor),this.getSymbol=f(t.symbolAccessor),this.getY0=t.y0Accessor?u(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=kn(t),this.getPointId=f(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?u(t.openAccessor,"open"):void 0,this.getHigh=u(t.highAccessor,"high"),this.getLow=u(t.lowAccessor,"low"),this.getClose=n?u(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new ke(t.windowSize))}currentTime(){return this.config.clock?.()??Re()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Ln(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),o=e.getBottom(t);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(o)&&this.yExtent.push(o)}}evictDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(t)),void this.yExtent.evict(this.getLow(t));this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),o=e.getBottom(t);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(o)&&this.yExtent.evict(o)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return this.updateResults.recordNoop("replace"),!1;const e=this.currentTime();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=n?u(this.config.timeAccessor||this.config.xAccessor,"time"):u(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,o="function"==typeof n?n(e):e[n||"x"],i=o instanceof Date,r="string"==typeof o&&Number.isFinite(Me(o));if(this.xIsDate=i||r,r){const t="string"==typeof n?n:void 0;this.getX=t?e=>_e(e[t]):t=>_e(n(t))}}Tn(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const n of t.inserts)Rn(this.buffer,n,this.timestampBuffer,e),this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n)}else for(const n of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity??1e5;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${t}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const t=Rn(this.buffer,n,this.timestampBuffer,e);this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n),null!=t&&(this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t))}return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}computeScene(t){const{config:e,buffer:n}=this,o=this.scales,i=this.lastLayout;if(!this.needsFullRebuild&&!e.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(n,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const r=this.getBufferArray(),s=this.yExtent.extent;let a=Pn(this.xExtent.extent,e.xExtent),l=Pn(s,e.yExtent);const c=!(!(u=e.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===e.axisExtent;if("stackedarea"===e.chartType&&!c&&n.size>0){const t=function(t){const{config:e,groups:n,getX:o,getY:i}=t,r="exact"===e.axisExtent;if(e.normalize){const n=[0,r?1:1+e.extentPadding];return{yDomain:n,stackExtentCache:{key:`${t.bufferSize}:${t.ingestVersion}:norm`,yDomain:n}}}const s=`${t.bufferSize}:${t.ingestVersion}:${e.baseline??"zero"}:${e.stackOrder??"key"}`;if(t.stackExtentCache&&t.stackExtentCache.key===s)return{yDomain:t.stackExtentCache.yDomain,stackExtentCache:t.stackExtentCache};const a=new Map,l=new Set;let c=0;const u=new Map,h=new Map;for(const t of n){const e=new Map;let n=0;for(const r of t.data){const t=o(r),s=i(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),l.add(t),n+=s;const a=(u.get(t)||0)+s;u.set(t,a),a>c&&(c=a)}a.set(t.key,e),h.set(t.key,n)}const d=e.stackOrder??"key",f=(t,e)=>e>t?-1:t>e?1:0;let p,y;if("input"===d)p=n.map(t=>t.key);else if("insideOut"===d){const t=[...n].map(t=>t.key).sort((t,e)=>{const n=(h.get(e)??0)-(h.get(t)??0);return 0!==n?n:f(t,e)}),e=[],o=[];let i=0,r=0;for(const n of t)r>i?(e.push(n),i+=h.get(n)??0):(o.push(n),r+=h.get(n)??0);p=[...o.reverse(),...e]}else p="asc"===d?n.map(t=>t.key).sort((t,e)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(t,e)}):"desc"===d?n.map(t=>t.key).sort((t,e)=>{const n=(h.get(e)??0)-(h.get(t)??0);return 0!==n?n:f(t,e)}):n.map(t=>t.key).sort(f);if("wiggle"===e.baseline||"silhouette"===e.baseline){const t=Array.from(l).sort((t,e)=>t-e),n=Ne(t,p,(t,e)=>a.get(t)?.get(e)||0,e.baseline);let o=1/0,i=-1/0;for(const e of t){const t=n.get(e)??0,r=u.get(e)??0;o>t&&(o=t),t+r>i&&(i=t+r)}Number.isFinite(o)&&Number.isFinite(i)||(o=0,i=0);const s=i-o,c=r?0:s>0?s*e.extentPadding:1;y=[o-c,i+c]}else if("diverging"===e.baseline){const t=Array.from(l).sort((t,e)=>t-e),[n,o]=function(t,e,n){let o=0,i=0;for(const r of t){let t=0,s=0;for(const o of e){const e=n(o,r)||0;0>e?s+=e:t+=e}o>s&&(o=s),t>i&&(i=t)}return[o,i]}(t,p,(t,e)=>a.get(t)?.get(e)||0),i=o-n,s=r?0:i>0?i*e.extentPadding:1;y=[n-s,o+s]}else y=[0,c+(r?0:c>0?c*e.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}({config:e,groups:this.groupData(r),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});l=t.yDomain,this._stackExtentCache=t.stackExtentCache}else"bar"===e.chartType&&e.binSize&&!c&&n.size>0?l=function(t,e,n,o,i,r,s){const[,a]=function(t,e,n,o,i){const r=gn(t,e,n,o,i);if(0===r.size)return[0,0];let s=0;for(const t of r.values())t.total>s&&(s=t.total);return[0,s]}(t,e,n,o,i);return[0,s?a:a+a*r]}(n,this.getX,this.getY,e.binSize,this.getCategory,e.extentPadding,h):"waterfall"===e.chartType&&!c&&n.size>0?l=function(t,e,n,o){const[i,r]=function(t,e){let n=0,o=0,i=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(i+=t,n>i&&(n=i),i>o&&(o=i))}return[n,o]}(t,e),s=r-i,a=o?0:s>0?s*n:1;return[Math.min(0,i-Math.abs(a)),Math.max(0,r+Math.abs(a))]}(n,this.getY,e.extentPadding,h):c||l[0]===1/0||(l=function(t,e,n){if(!n.length)return t;let[o,i]=t;for(const t of e)for(const e of n){const n=e.getTop(t),r=e.getBottom(t);Number.isFinite(n)&&(o>n&&(o=n),n>i&&(i=n)),Number.isFinite(r)&&(o>r&&(o=r),r>i&&(i=r))}return[o,i]}(l,r,this.resolvedRibbons),l=function(t,e){const n=t[1]-t[0],o=e.exactMode?0:n>0?n*e.extentPadding:1,i=[null!=e.userMin?t[0]:t[0]-o,null!=e.userMax?t[1]:t[1]+o];return"log"!==e.yScaleType||i[0]>0||0>=e.dataYDomain[0]||e.exactMode||null==e.userMin&&(i[0]=e.dataYDomain[0]/(1+e.extentPadding)),i}(l,{exactMode:h,extentPadding:e.extentPadding,userMin:e.yExtent?.[0],userMax:e.yExtent?.[1],yScaleType:e.yScaleType,dataYDomain:s}));l=function(t,e,n){if(!e||n)return t;const o=e[0],i=e[1];return null==o&&null==i?t:[null!=o?o:t[0],null!=i?i:t[1]]}(l,e.yExtent,!!c),({xDomain:a,yDomain:l}=function(t,e,n){let o=t,i=e;if(o[0]===1/0||o[1]===-1/0)if("time"===n){const t=Date.now();o=[t-864e5,t]}else o=[0,1];return i[0]!==1/0&&i[1]!==-1/0||(i=[0,1]),{xDomain:o,yDomain:i}}(a,l,e.xScaleType)),this.scales=function(t){const{config:e,layout:n,xDomain:o,yDomain:i}=t,r="streaming"===e.runtimeMode,s=Math.max(0,Math.min(e.scalePadding||0,Math.min(n.width,n.height)/2-1));if(r){if("x"==("up"===(a=e.arrowOfTime)||"down"===a?"y":"x")){const t="right"===e.arrowOfTime?[s,n.width-s]:[n.width-s,s];return{x:Sn().domain(o).range(t),y:Cn(e.yScaleType,i,[n.height-s,s])}}const t="down"===e.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Cn(e.yScaleType,i,[s,n.width-s]),y:Sn().domain(o).range(t)}}var a;return{x:Cn(e.xScaleType,o,[s,n.width-s]),y:Cn(e.yScaleType,i,[n.height-s,s])}}({config:e,layout:t,xDomain:a,yDomain:l}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(t,r);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.lastLayout=i):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=d,this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const o of t.path)o[0]*=e,o[1]*=n;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=n;for(const o of t.bottomPath)o[0]*=e,o[1]*=n;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*n,width:t.clipRect.width*e,height:t.clipRect.height*n});break;case"point":case"glyph":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const o=this.scales.x.domain(),i=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),a=Cn,l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),c=s[1]>s[0];this.scales={x:a(this.config.xScaleType,o,r[0]>r[1]?[t.width-l,l]:[l,t.width-l]),y:a(this.config.yScaleType,i,c?[l,t.height-l]:[t.height-l,l])},this.lastLayout={width:t.width,height:t.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(t,e){const{config:n,scales:o}=this;if(!o)return[];if(n.customLayout){const i={data:e,scales:o,dimensions:{width:t.width,height:t.height,margin:n.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:n.themeSemantic??{},categorical:n.themeCategorical??kt},resolveColor:(t,e)=>{const o=this.resolveGroupColor(t);if(o)return o;const i=this.resolveLineStyle(t,e);return i.stroke?i.stroke:"string"==typeof i.fill?i.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let r;try{r=n.customLayout(i)}catch(t){const e=null!==this.lastCustomLayoutResult,o=vn("xy",t,e,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t);try{n.onLayoutError?.(o)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null;const s=r.nodes??[];if(this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of s)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(s,n.layoutSelection??null)}return mn({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===e.length)return[];const i={scales:o,config:n,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(n.chartType){case"line":return function(t,e){const n=t.groupData(e),o=[],i=t.config.annotations?.filter(Qe).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:r}=He(t.ribbons);if(r.length>0&&o.push(...Ve(t,e,r)),i.length>0)for(const e of n)o.push(...Ue(t,e.data,e.key,i))}for(const e of n){const n=t.resolveLineStyle(e.key,e.data[0]),r=Ee(e.data,t.scales,t.getX,t.getY,n,e.key);i&&i.length>0&&(r.colorThresholds=i),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return Ze(t,n,o),o}(i,e);case"area":return function(t,e){const n=t.groupData(e),o=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:r}=He(t.ribbons);if(r.length>0&&o.push(...Ve(t,e,r)),i.length>0)for(const e of n)o.push(...Ue(t,e.data,e.key,i))}const i=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?i:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),s=Oe(e.data,t.scales,t.getX,t.getY,i,n,e.key,r),a=tn(t.config.gradientFill);a&&(s.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return Ze(t,n,o),o}(i,e);case"mixed":return function(t,e){const n=t.groupData(e),o=[],i=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:r}=He(t.ribbons);if(r.length>0&&o.push(...Ve(t,e,r)),i.length>0)for(const e of n)o.push(...Ue(t,e.data,e.key,i))}const r=t.scales.y.domain()[0],s=t.getY0?e=>{const n=t.getY0(e);return null==n?r:n}:void 0;for(const e of n)if(i.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),i=Oe(e.data,t.scales,t.getX,t.getY,r,n,e.key,s),a=tn(t.config.gradientFill);a&&(i.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}else{const n=t.resolveLineStyle(e.key,e.data[0]),i=Ee(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return Ze(t,n,o),o}(i,e);case"stackedarea":return function(t,e){const n=t.groupData(e),o=t.config.stackOrder??"key",i=()=>n.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("input"===o);else if("key"===o)i();else if("asc"===o||"desc"===o||"insideOut"===o){const e=new Map;for(const o of n){let n=0;for(const e of o.data){const o=t.getX(e),i=t.getY(e);Number.isFinite(o)&&Number.isFinite(i)&&(n+=i)}e.set(o.key,n)}const i=(t,e)=>e>t?-1:t>e?1:0;if("asc"===o)n.sort((t,n)=>{const o=(e.get(t.key)??0)-(e.get(n.key)??0);return 0!==o?o:i(t.key,n.key)});else if("desc"===o)n.sort((t,n)=>{const o=(e.get(n.key)??0)-(e.get(t.key)??0);return 0!==o?o:i(t.key,n.key)});else{const t=[...n].sort((t,n)=>{const o=(e.get(n.key)??0)-(e.get(t.key)??0);return 0!==o?o:i(t.key,n.key)}),o=[],r=[];let s=0,a=0;for(const n of t)a>s?(o.push(n),s+=e.get(n.key)??0):(r.push(n),a+=e.get(n.key)??0);n.length=0,n.push(...r.reverse(),...o)}}else i();const r=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,s=t.config.normalize?"zero":t.config.baseline??"zero",{nodes:a,stackedTops:l}=function(t,e,n,o,i,r,s,a="zero"){const l=new Set;for(const e of t)for(const t of e.data){const e=n(t);Number.isFinite(e)&&l.add(e)}const c=Array.from(l).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const i of e.data){const e=n(i),r=o(i);Number.isFinite(e)&&Number.isFinite(r)&&t.set(e,(t.get(e)||0)+r)}u.set(e.key,t)}let h;if(r){h=new Map;for(const e of c){let n=0;for(const o of t)n+=u.get(o.key)?.get(e)||0;h.set(e,n||1)}}const d=Ne(c,t.map(t=>t.key),(t,e)=>u.get(t)?.get(e)||0,a),f="diverging"===a&&!r,p=[],y=new Map,g=new Map,m=new Map,x=new Map;for(const t of c)g.set(t,d.get(t)??0),m.set(t,0),x.set(t,0);for(const n of t){const t=u.get(n.key),o=new Map;let a=[],l=[];const d=()=>{if(a.length>=2){const t={type:"area",topPath:a,bottomPath:l,style:i(n.key,n.data[0]),datum:n.data,group:n.key};s&&(t.curve=s),p.push(t)}a=[],l=[]};for(const n of c){const i=t.has(n);let s,c,u=i?t.get(n):0;if(r&&i&&(u/=h.get(n)),!i||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(n),c=s+u,m.set(n,c)):(s=x.get(n),c=s+u,x.set(n,c)):(s=g.get(n),c=s+u,g.set(n,c));const p=e.x(n);l.push([p,e.y(s)]),a.push([p,e.y(c)]),o.set(n,c)}d(),y.set(n.key,o)}return{nodes:p,stackedTops:y}}(n,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,r,s),c=a;if(t.config.pointStyle){const e=new WeakMap;for(const o of n){const n=l.get(o.key);if(n)for(const i of o.data){const o=t.getX(i),r=t.getY(i);null==o||Number.isNaN(o)||null==r||Number.isNaN(r)||!n.has(o)||e.set(i,n.get(o))}}const o=n=>e.get(n)??t.getY(n);Ze(t,n,c,o)}return c}(i,e);case"scatter":case"bubble":return function(t,e){const n=[],o="bubble"===t.config.chartType?10:5,i=t.config.sizeRange||[3,15];let r=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const o of n)t>o&&(t=o),o>e&&(e=o);r=n=>t===e?(i[0]+i[1])/2:i[0]+(n-t)/(e-t)*(i[1]-i[0])}}const s=t.getColor?t.resolveColorMap(e):null,a=t.config.themeSemantic?.primary||"#4e79a7",l=t.getSymbol,c=t.config.symbolMap,u=new Map;let h=0;const d=t=>{const e=c?.[t];if(e)return e;let n=u.get(t);return n||(n=hn[h%hn.length],h++,u.set(t,n)),n};for(const i of e){let e=t.config.pointStyle?t.config.pointStyle(i):{fill:a,opacity:.8},c=e.r||o;if(r&&t.getSize){const e=t.getSize(i);null==e||Number.isNaN(e)||(c=r(e))}if(s&&t.getColor&&!e.fill){const n=t.getColor(i);n&&s.has(n)&&(e={...e,fill:s.get(n)})}const u=t.getPointId?t.getPointId(i)+"":void 0;if(l){const o=d(l(i)+""),r=je(i,t.scales,t.getX,t.getY,Math.PI*c*c,o,e,u);r&&n.push(r)}else{const o=We(i,t.scales,t.getX,t.getY,c,e,u);o&&n.push(o)}}return n}(i,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){const o=Math.max(1,Math.floor(t.config.heatmapXBins??20)),i=Math.max(1,Math.floor(t.config.heatmapYBins??20)),r=t.config.heatmapAggregation??"count",s=u(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[a,l]=t.scales.x.domain(),[c,h]=t.scales.y.domain(),d=(l-a||1)/o,f=(h-c||1)/i,p=o*i;if(p>1e6)return[];const y=new Int32Array(p),g=new Float64Array(p);for(let n=0;e.length>n;n++){const r=e[n],l=t.getX(r),u=t.getY(r);if(!isFinite(l)||!isFinite(u))continue;const h=Math.min(Math.floor((l-a)/d),o-1),p=Math.min(Math.floor((u-c)/f),i-1);if(0>h||0>p)continue;const m=p*o+h;y[m]++;const x=s(r);g[m]+=isFinite(x)?x:0}let m=1/0,x=-1/0;for(let t=0;p>t;t++){if(0===y[t])continue;let e;switch(r){case"sum":e=g[t];break;case"mean":e=g[t]/y[t];break;default:e=y[t]}m>e&&(m=e),e>x&&(x=e)}if(!isFinite(m))return[];const b=x-m||1,v=n.width/o,w=n.height/i,k=t.config.showValues,S=t.config.heatmapValueFormat,A=[];for(let e=0;i>e;e++){const n=e*o;for(let s=0;o>s;s++){const o=n+s;if(0===y[o])continue;let l;switch(r){case"sum":l=g[o];break;case"mean":l=g[o]/y[o];break;default:l=y[o]}const u=(l-m)/b,h={xi:s,yi:e,value:l,count:y[o],sum:g[o],xCenter:a+(s+.5)*d,yCenter:c+(e+.5)*f,agg:r};A.push(yn(Ge(s*v,(i-1-e)*w,v,w,`rgb(${220-(180*u+.5)|0},${220-(100*u+.5)|0},${255-(50*u+.5)|0})`,h,k?{value:l,showValues:!0,valueFormat:S}:void 0),h,t))}}return A}(t,e,n);if(0===e.length)return[];const o=u(t.config.valueAccessor,"value"),i=h(t.config.xAccessor,"x"),r=h(t.config.yAccessor,"y"),s=new Map,a=new Map,l=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],o=i(n),u=r(n);l[t]=o,c[t]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const d=s.size,f=a.size;if(0===d||0===f)return[];const p=Array.from(s.keys()),y=Array.from(a.keys()),g=p.every(t=>"number"==typeof t&&!isNaN(t)),m=y.every(t=>"number"==typeof t&&!isNaN(t));if(g){p.sort((t,e)=>Number(t)-Number(e)),s.clear();for(let t=0;p.length>t;t++)s.set(p[t],t)}if(m){y.sort((t,e)=>Number(t)-Number(e)),a.clear();for(let t=0;y.length>t;t++)a.set(y[t],t)}const x=new Float64Array(e.length),b=new Float64Array(e.length),v=Array(e.length),w=new Map;let k=0;for(let t=0;e.length>t;t++){const n=e[t],i=s.get(l[t]),r=a.get(c[t]);if(void 0===i||void 0===r)continue;const u=o(n),h=r*d+i,f=w.get(h);let p;void 0!==f?p=f:(p=k++,w.set(h,p)),x[p]=h,b[p]=u,v[p]=n}let S=1/0,A=-1/0;for(let t=0;k>t;t++){const e=b[t];isFinite(e)&&(S>e&&(S=e),e>A&&(A=e))}if(!isFinite(S)||!isFinite(A))return[];const M=function(t){const e=t in ct?t:"blues";let n=pn.get(e);if(n)return n;n=Array(256);const o=ut(e);for(let t=0;256>t;t++)n[t]=o(t/255);return pn.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),_=255/(A-S||1),P=n.width/d,C=n.height/f,T=t.config.showValues,L=t.config.heatmapValueFormat,R=[];for(let e=0;k>e;e++){const n=b[e];if(!isFinite(n))continue;const o=x[e],i=o%d,r=v[e];R.push(yn(Ge(i*P,(f-1-(o-i)/d)*C,P,C,M[Math.min((n-S)*_+.5|0,255)],r,T?{value:n,showValues:!0,valueFormat:L}:void 0),r,t))}return R}(i,e,t);case"bar":{const t=function(t,e){if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const n=gn(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let o=null;if(t.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const i=t.config.barColors?Object.keys(t.config.barColors):[],r=new Set(i),s=Array.from(e).filter(t=>!r.has(t)).sort(),a=i.filter(t=>e.has(t)),l=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===l?o=t.barCategoryCache.order:(o=[...a,...s],t.barCategoryCache={key:l,order:o})}const i=[],r=t.scales,[s,a]=r.x.domain(),l=t.config.barStyle,c=t.config.themeSemantic?.primary,u=l?.gap,h="number"!=typeof u||0>u?1:u,d={};l?.stroke&&(d.stroke=l.stroke),"number"==typeof l?.strokeWidth&&(d.strokeWidth=l.strokeWidth),"number"==typeof l?.opacity&&(d.opacity=l.opacity);for(const e of n.values()){const n=Math.max(e.start,s),u=Math.min(e.end,a);if(n>=u)continue;const f=r.x(n),p=r.x(u),y=Math.abs(p-f),g=y>h+1?h:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(o&&e.categories.size>0){let n=0;for(const s of o){const o=e.categories.get(s)||0;if(0===o)continue;const a=r.y(n),u=r.y(n+o);i.push(Ye(m,Math.min(a,u),x,Math.abs(a-u),{fill:t.config.barColors?.[s]||l?.fill||c||"#4e79a7",...d},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:o},s)),n+=o}}else{const t=r.y(0),n=r.y(e.total);i.push(Ye(m,Math.min(t,n),x,Math.abs(t-n),{fill:l?.fill||c||"#007bff",...d},{binStart:e.start,binEnd:e.end,total:e.total}))}}const f=new Set;for(const t of n.values())f.add(t.start),f.add(t.end);return{nodes:i,binBoundaries:Array.from(f).sort((t,e)=>t-e)}}(i,e);return this._barCategoryCache=i.barCategoryCache??null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){const n=[],o=t.config.swarmStyle||{},i=o.radius??3,r=o.fill??t.config.themeSemantic?.primary??"#007bff",s=o.opacity??.7,a=o.stroke,l=o.strokeWidth;for(const o of e){const e=t.getX(o),c=t.getY(o);if(null==c||Number.isNaN(c))continue;const u=t.scales.x(e),h=t.scales.y(c);let d=r;if(t.getCategory){const e=t.getCategory(o);d=t.config.barColors?.[e]||d}const{r:f,...p}=t.config.pointStyle?.(o)??{},y={type:"point",x:u,y:h,r:f??i,style:{fill:d,opacity:s,stroke:a,strokeWidth:l,...p},datum:o};t.getPointId&&(y.pointId=t.getPointId(o)+""),n.push(y)}return n}(i,e);case"waterfall":return function(t,e,n){const o=[],i=t.scales,r=t.config.waterfallStyle,s=e.filter(e=>{const n=t.getY(e),o=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===s.length)return o;const a=r?.positiveColor??t.config.themeSemantic?.success??"#28a745",l=r?.negativeColor??t.config.themeSemantic?.danger??"#dc3545",c=r?.gap??1,u=r?.stroke,h=r?.strokeWidth,d=r?.opacity;let f=0;for(let e=0;s.length>e;e++){const p=s[e],y=t.getX(p),g=t.getY(p),m=f+g;let x;x=s.length-1>e?t.getX(s[e+1])-y:e>0?y-t.getX(s[e-1]):0;const b=i.x(y),v=0!==x?i.x(y+x):b+n.width/10,w=Math.min(b,v)+c/2,k=Math.max(b,v)-c/2-w;if(0>=k){f=m;continue}const S=i.y(f),A=i.y(m),M=Math.min(S,A),_=Math.abs(S-A),P={fill:0>g?l:a,stroke:u,strokeWidth:h};null!=d&&(P.opacity=d),o.push(Ye(w,M,k,_,P,{...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:r?.connectorStroke,_connectorWidth:r?.connectorWidth})),f=m}return o}(i,e,t);case"candlestick":return function(t,e,n){if(!t.getHigh||!t.getLow||!t.scales)return[];const o=t.config.candlestickRangeMode??!1;if(!(o||t.getOpen&&t.getClose))return[];const i=[],r=t.config.candlestickStyle||{},s=r.rangeColor||"#6366f1",a=o?s:r.upColor||"#28a745",l=o?s:r.downColor||"#dc3545",c=o?s:r.wickColor||"#333",u=r.wickWidth||(o?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let d=r.bodyWidth??0;if(null==r.bodyWidth)if(h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const o=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));o>0&&e>o&&(e=o)}d=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else d=6;for(const r of e){const e=t.getX(r);if(null==e||Number.isNaN(e))continue;const s=t.getHigh(r),h=t.getLow(r);if(null==s||Number.isNaN(s)||null==h||Number.isNaN(h))continue;const f=o?s:t.getOpen(r),p=o?h:t.getClose(r);if(!o&&[f,p].some(t=>null==t||Number.isNaN(t)))continue;const y=p>=f,g={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(f),closeY:t.scales.y(p),highY:t.scales.y(s),lowY:t.scales.y(h),bodyWidth:d,upColor:a,downColor:l,wickColor:c,wickWidth:u,isUp:y,datum:r};o&&(g.isRange=!0,g.dotRadius=Math.max(2,Math.min(d/2,.12*n.height))),i.push(g)}return i}(i,e,t);default:return[]}}resolveBoundsStyle(t,e){return function(t,e,n,o){const i=t.boundsStyle;return"function"==typeof i?i(n||{},e):i&&"object"==typeof i?i:{fill:o(e,n).stroke||t.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,t,e,(t,e)=>this.resolveLineStyle(t,e))}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?$e(n,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const e=ze(t);return this._datumIndexCache={version:this._ingestVersion,map:e},e}applyDecay(t,e){this.config.decay&&function(t,e,n,o=ze(n)){const i=n.length;if(i>1)for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const r=Array(e.length);let s=!1;for(let n=0;e.length>n;n++){const a=o.get(e[n]);null!=a?(r[n]=$e(t,a,i),1>r[n]&&(s=!0)):r[n]=1}s&&(n._decayOpacities=r);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],r=n.topPath?n.topPath.length:e.length;if(2>r)continue;if(e.length===r){const s=Array(r);let a=!1;for(let n=0;e.length>n;n++){const r=o.get(e[n]);null!=r?(s[n]=$e(t,r,i),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of e){const e=o.get(n);if(null!=e){const n=$e(t,e,i);s>n&&(s=n)}}if(1>s){const t=Array(r);t.fill(s),n._decayOpacities=t}}continue}const e=o.get(n.datum);if(null==e)continue;const r=$e(t,e,i);"heatcell"===n.type?n.style={opacity:r}:"candlestick"===n.type?n._decayOpacity=r:n.style={...n.style,opacity:(n.style?.opacity??1)*r}}}(this.config.decay,t,e,this.getDatumIndexMap(e))}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&Be(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,o){n.clear(),o.clear();for(let i=0;e.length>i;i++){const r=e[i],s=Fe(t,r,i);s&&("point"===r.type?n.set(s,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"glyph"===r.type?n.set(s,{x:r.x,y:r.y,r:r.size,opacity:r.style.opacity,glyph:r.glyph}):"rect"===r.type?n.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}):"heatcell"===r.type?n.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style?.opacity}):"candlestick"===r.type?n.set(s,{x:r.x,y:r.openY,w:r.bodyWidth,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY,opacity:r.style?.opacity}):"line"===r.type?o.set(s,{path:r.path.map(t=>[t[0],t[1]]),opacity:r.style?.opacity}):"area"===r.type&&o.set(s,{topPath:r.topPath.map(t=>[t[0],t[1]]),bottomPath:r.bottomPath.map(t=>[t[0],t[1]]),opacity:r.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const t=this.scales?.y(0)??0;for(let e=0;this.scene.length>e;e++){const n=this.scene[e],o=Fe(this.transitionContext,n,e);o&&("point"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(o,{x:n.x,y:t,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(o,{path:n.path.map(t=>[t[0],t[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(o,{topPath:n.topPath.map(t=>[t[0],t[1]]),bottomPath:n.bottomPath.map(t=>[t[0],t[1]]),opacity:n.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,o,i,r=Re()){if(0===o.size&&0===i.size)return n;const s=e.duration??300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let a=!1;const l=new Set,c=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],s=Fe(t,r,e);if(!s)continue;if(r._transitionKey=s,"line"===r.type||"area"===r.type){const t=i.get(s);if(t){if(c.add(s),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];a=!0}else if("area"===r.type&&t.topPath&&t.bottomPath&&t.topPath.length===r.topPath.length&&t.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(t=>[t[0],t[1]]),r._targetBottomPath=r.bottomPath.map(t=>[t[0],t[1]]),r._prevTopPath=t.topPath,r._prevBottomPath=t.bottomPath;for(let e=0;r.topPath.length>e;e++)r.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;r.bottomPath.length>e;e++)r.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];a=!0}r._targetOpacity=r.style.opacity??1,r._startOpacity=t.opacity??r.style.opacity??1}else r._targetOpacity=r.style.opacity??1,r._startOpacity=0,r.style={...r.style,opacity:0},a=!0;continue}const u=o.get(s);if("point"===r.type)if(u){l.add(s);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=r.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=u.x,r.y=u.y,r.r=u.r??r.r,a=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},a=!0;else if("glyph"===r.type)if(u){l.add(s);const t={x:r.x,y:r.y,size:r.size};r._targetOpacity=r.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.size||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.size,r.x=u.x,r.y=u.y,r.size=u.r??r.size,a=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},a=!0;else if("rect"===r.type)if(u){l.add(s);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=r.style.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=u.x,r.y=u.y,r.w=u.w??r.w,r.h=u.h??r.h,a=!0)}else r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},a=!0;else if("heatcell"===r.type)if(u){l.add(s);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=r.style?.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=u.x,r.y=u.y,r.w=u.w??r.w,r.h=u.h??r.h,a=!0)}else r._targetOpacity=r.style?.opacity??1,r.style={...r.style||{},opacity:0},a=!0;else if("candlestick"===r.type)if(u&&null!=u.openY){l.add(s);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=r.style?.opacity??1,(u.x!==t.x||u.openY!==t.openY||u.closeY!==t.closeY||u.highY!==t.highY||u.lowY!==t.lowY)&&(r._targetX=t.x,r._targetOpenY=t.openY,r._targetCloseY=t.closeY,r._targetHighY=t.highY,r._targetLowY=t.lowY,r.x=u.x,r.openY=u.openY,r.closeY=u.closeY??r.closeY,r.highY=u.highY??r.highY,r.lowY=u.lowY??r.lowY,a=!0)}else r._targetOpacity=r.style?.opacity??1,r.style={...r.style||{},opacity:0},a=!0}for(const[t,e]of i)if(!c.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(o),a=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(o),a=!0}for(const[t,e]of o)if(!l.has(t)){if(t.startsWith("p:"))n.exitNodes.push({type:"point",x:e.x,y:e.y,r:e.r??3,style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("g:")&&e.glyph)n.exitNodes.push({type:"glyph",x:e.x,y:e.y,size:e.r??12,glyph:e.glyph,color:"#999",accent:"#999",style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))n.exitNodes.push({type:"rect",x:e.x,y:e.y,w:e.w??0,h:e.h??0,style:{opacity:e.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("h:"))n.exitNodes.push({type:"heatcell",x:e.x,y:e.y,w:e.w??0,h:e.h??0,fill:"#999",datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t});else if(t.startsWith("c:")){const o=e.openY??e.y;n.exitNodes.push({type:"candlestick",x:e.x,openY:o,closeY:e.closeY??o,highY:e.highY??o,lowY:e.lowY??o,bodyWidth:e.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t})}a=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),a&&(n.activeTransition={startTime:r,duration:s}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,o){if(!n.activeTransition)return!1;const i=Te(t,n.activeTransition),r=Ce(i,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0;t.style.opacity=Le(n?n.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=Le(n.x,t._targetX,r),t.y=Le(n.y,t._targetY,r),void 0!==t._targetR&&void 0!==n.r&&(t.r=Le(n.r,t._targetR,r))}else if("glyph"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0;t.style.opacity=Le(n?n.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=Le(n.x,t._targetX,r),t.y=Le(n.y,t._targetY,r),void 0!==t._targetR&&void 0!==n.r&&(t.size=Le(n.r,t._targetR,r))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0;t.style.opacity=Le(n?n.opacity??1:0,t._targetOpacity,r)}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=Le(n.x,t._targetX,r),t.y=Le(n.y,t._targetY,r),void 0!==n.w&&(t.w=Le(n.w,t._targetW,r)),void 0!==n.h&&(t.h=Le(n.h,t._targetH,r))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0;t.style={...t.style||{},opacity:Le(n?n.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=Le(n.x,t._targetX,r),t.y=Le(n.y,t._targetY,r),void 0!==n.w&&(t.w=Le(n.w,t._targetW,r)),void 0!==n.h&&(t.h=Le(n.h,t._targetH,r))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0;t.style={...t.style||{},opacity:Le(n?n.opacity??1:0,t._targetOpacity,r)}}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=Le(n.x,t._targetX,r),void 0!==n.openY&&(t.openY=Le(n.openY,t._targetOpenY,r)),void 0!==n.closeY&&(t.closeY=Le(n.closeY,t._targetCloseY,r)),void 0!==n.highY&&(t.highY=Le(n.highY,t._targetHighY,r)),void 0!==n.lowY&&(t.lowY=Le(n.lowY,t._targetLowY,r))}else if("line"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Le(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=Le(e[o][0],n[o][0],r),t.path[o][1]=Le(e[o][1],n[o][1],r)}else if("area"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Le(t._startOpacity??0,t._targetOpacity,r)}),void 0!==t._introClipFraction&&(t._introClipFraction=r);const e=t._prevTopPath,n=t._prevBottomPath,o=t._targetTopPath,i=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=Le(e[n][0],o[n][0],r),t.topPath[n][1]=Le(e[n][1],o[n][1],r);if(n&&i&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=Le(n[e][0],i[e][0],r),t.bottomPath[e][1]=Le(n[e][1],i[e][1],r)}}if(i>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style="line"===t.type||"area"===t.type?{...t.style,opacity:0===e?0:e}:{...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("glyph"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){const{result:e,cache:n}=function(t,e,n,o){if(o&&o.version===n&&o.group===e&&o.data===t)return{result:o.result,cache:o};let i;if(e){const n=new Map;for(const o of t){const t=e(o);n.has(t)||n.set(t,[]),n.get(t).push(o)}i=Array.from(n.entries()).map(([t,e])=>({key:t,data:e}))}else i=[{key:"_default",data:t}];return{result:i,cache:{version:n,group:e,data:t,result:i}}}(t,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,e}resolveColorMap(t){const{map:e,cache:n}=function(t,e,n,o,i){if(i&&i.version===o)return{map:i.map,cache:i};const r=new Set;if(e)for(const n of t){const t=e(n);t&&r.add(t)}const s=Array.from(r).sort(),a=s.join("\0");if(i&&i.key===a){const t={...i,version:o};return{map:t.map,cache:t}}const l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||kt,c=new Map;for(let t=0;s.length>t;t++)c.set(s[t],l[t%l.length]);return{map:c,cache:{key:a,map:c,version:o}}}(t,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,e}resolveLineStyle(t,e){return function(t,e,n,o){const i=t.lineStyle;if("function"==typeof i){const t=i(n||{},e);if(t&&!t.stroke&&e){const n=o(e);if(n)return{...t,stroke:n}}return t}const r=t.themeSemantic?.primary;return i&&"object"==typeof i?{stroke:i.stroke||r||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:o(e)||r||"#007bff",strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveAreaStyle(t,e){return function(t,e,n,o){if(t.areaStyle){const i=t.areaStyle(n||{});if(i&&!i.fill&&e){const t=o(e);if(t)return{...i,fill:t,stroke:i.stroke||t}}return i}const i=t.lineStyle;if("function"==typeof i){const t=i(n||{},e);if(t&&!t.fill&&e){const n=o(e);if(n)return{...t,fill:n,stroke:t.stroke||n}}return t}const r=t.themeSemantic?.primary;if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||r||"#4e79a7",fillOpacity:i.fillOpacity??.7,stroke:i.stroke||r||"#4e79a7",strokeWidth:i.strokeWidth||2};const s=o(e)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveGroupColor(t){const{color:n,groupColorCounter:o}=function(t){const{group:e,colorMapCache:n,groupColorMap:o,groupColorMapCap:i,config:r}=t;let{groupColorCounter:s}=t;if(n){const t=n.map.get(e);if(t)return{color:t,groupColorCounter:s}}const a=o.get(e);if(a)return{color:a,groupColorCounter:s};const l=(Array.isArray(r.colorScheme)&&r.colorScheme.length>0?r.colorScheme:null)||(Array.isArray(r.themeCategorical)&&r.themeCategorical.length>0?r.themeCategorical:null)||kt;if(0===l.length)return{color:null,groupColorCounter:s};const c=l[s%l.length];if(s++,o.set(e,c),o.size>i){const t=o.keys().next().value;void 0!==t&&o.delete(t)}return{color:c,groupColorCounter:s}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=o,n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=Pe(t),n=this.getPointId,o=t=>e.has(n(t));$n(this.buffer,this.timestampBuffer,o);const i=this.buffer.remove(o);if(0===i.length)return this.updateResults.recordNoop("remove"),i;for(const t of i)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",i.length),i}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=Pe(t),o=this.getPointId,i=new Set;this.buffer.forEach((t,e)=>{n.has(o(t))&&i.add(e)});const r=this.buffer.update(t=>n.has(o(t)),e);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const t of r)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.buffer.forEach((t,e)=>{i.has(e)&&(this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(t,e){const n=this._customRestyle;if(n)for(const o of t){const t=this._baseStyles.get(o)??o.style??{},i=n(o,e);o.style=i?{...t,...i}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const n={...this.config},o=Object.keys(e).filter(t=>e[t]!==n[t]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==n.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${n.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let i=!1,r=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const s="chartType"in e&&e.chartType!==n.chartType||"runtimeMode"in e&&e.runtimeMode!==n.runtimeMode;if(s||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,o=e&&this.config.valueAccessor||this.config.yAccessor,a=e&&n.valueAccessor||n.yAccessor,l=s||!t(e&&this.config.timeAccessor||this.config.xAccessor,e&&n.timeAccessor||n.xAccessor),c=s||!t(o,a);(l||c)&&(e?(this.getX=u(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=u(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=u(this.config.xAccessor,"x"),this.getY=u(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=kn(this.config)),i=!0,r=!0)}if("groupAccessor"in e&&!t(e.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?f(this.config.groupAccessor):void 0,i=!0),"categoryAccessor"in e&&!t(e.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?f(this.config.categoryAccessor):void 0,i=!0),"sizeAccessor"in e&&!t(e.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?u(this.config.sizeAccessor,"size"):void 0,i=!0),"symbolAccessor"in e&&!t(e.symbolAccessor,n.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?f(this.config.symbolAccessor):void 0,i=!0),"colorAccessor"in e&&!t(e.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?f(this.config.colorAccessor):void 0,i=!0),"y0Accessor"in e&&!t(e.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?u(this.config.y0Accessor,"y0"):void 0,i=!0,r=!0),("boundsAccessor"in e&&!t(e.boundsAccessor,n.boundsAccessor)||"band"in e&&e.band!==n.band||"boundsStyle"in e&&e.boundsStyle!==n.boundsStyle)&&(this.resolvedRibbons=kn(this.config),i=!0,r=!0),"pointIdAccessor"in e&&!t(e.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?f(this.config.pointIdAccessor):void 0,i=!0),"candlestick"===this.config.chartType&&(s||"openAccessor"in e&&!t(e.openAccessor,n.openAccessor)||"closeAccessor"in e&&!t(e.closeAccessor,n.closeAccessor)||"highAccessor"in e&&!t(e.highAccessor,n.highAccessor)||"lowAccessor"in e&&!t(e.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?u(this.config.openAccessor,"open"):void 0,this.getHigh=u(this.config.highAccessor,"high"),this.getLow=u(this.config.lowAccessor,"low"),this.getClose=e?u(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,i=!0,r=!0}if("accessorRevision"in e&&e.accessorRevision!==n.accessorRevision&&(i=!0,r=!0),!i){const t=Object.keys(e).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const o of t)if(e[o]!==n[o]){i=!0;break}}i&&(r&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(o)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};so.GROUP_COLOR_MAP_CAP=1e3;var ao=so;Nn(ao);import{memo as lo,useEffect as co,useRef as uo}from"react";var ho={sceneGeometry:0,layout:0,domain:0};function fo(t){const{domain:e,layout:n,sceneGeometry:o}=t.revisions;return{domain:e,layout:n,sceneGeometry:o}}function po(t,e){return{sceneGeometry:Math.max(t.sceneGeometry,e.sceneGeometry),layout:Math.max(t.layout,e.layout),domain:Math.max(t.domain,e.domain)}}var yo="production"!==process.env.NODE_ENV,go={revisions:ho,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},mo=class{constructor(t="scene host"){this.hostName=t,this.lastConsumed=ho,this.lastObserved=ho,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(t){yo&&(this.lastObserved=po(this.lastObserved,fo(t)))}beforeCompute(t,e){if(!yo)return go;const n=po(fo(t),this.lastObserved),o=function(t){return`${t.sceneGeometry}|${t.layout}|${t.domain}`}(n),i=!((r=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&r.layout===s.layout&&r.domain===s.domain);var r,s;return{revisions:n,signature:o,sawSignals:t.changed.has("scene-geometry")||t.changed.has("layout")||t.changed.has("domain"),wasUnconsumed:i,warnUnconsumed:!e&&i&&this.lastUnconsumedWarning!==o}}afterCompute(t,e,n){if(yo){if(e&&t.wasUnconsumed&&(this.lastConsumed=t.revisions),t.warnUnconsumed&&!e)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${t.signature}.`),void(this.lastUnconsumedWarning=t.signature);e&&t.sawSignals&&!t.wasUnconsumed&&!n&&this.lastDuplicateWarning!==t.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${t.signature}.`),this.lastDuplicateWarning=t.signature):e&&!t.sawSignals&&(this.lastDuplicateWarning="")}}},xo=lo(function({store:t,diagnostics:e}){return co(()=>{const n=()=>e.observeUpdateResult(t.getUpdateSnapshot());return n(),t.subscribeUpdateResult(n)},[e,t]),null});import*as bo from"react";function vo(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:bo.createElement(bo.Fragment,null,...e)}import*as wo from"react";import{jsx as ko}from"react/jsx-runtime";var So=wo.createContext(null);function Ao({value:t,children:e}){return ko(So.Provider,{value:t,children:e})}function Mo(t,e){return null!=t?ko(Ao,{value:e,children:t}):t}import{useEffect as _o,useRef as Po}from"react";function Co(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function To(t,e=30){return Math.max((t??4)+5,12,e)}function Lo(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function Ro(t,e){const n=Lo(t);if(!n)return!1;const o=Lo(e);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}var $o=[40,40],zo=[.5,.5];function Do(t,e){const[n,o]=t.viewBox??$o,[i,r]=t.anchor??zo,s=o>0?o:1,a=Math.max(0,e)/s,l=(n>0?n:s)*a,c=s*a;return{width:l,height:c,scale:a,offsetX:-i*l,offsetY:-r*c}}function Io(t,e,n,o){if("none"!==t)return"color"===t||null==t?e??o:"accent"===t?n:t}var Bo=null;function Fo(t){if("undefined"==typeof Path2D)return null;Bo||(Bo=new Map);const e=Bo.get(t);if(e)return e;const n=new Path2D(t);return Bo.size>1024&&Bo.clear(),Bo.set(t,n),n}function Eo(t,e,n=0,o="horizontal"){const[i,r]=t.viewBox??$o,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,e));return a>s?s>0||1>a?"vertical"===o?{x:0,y:r*(1-a),width:i,height:r*(a-s)}:{x:i*s,y:0,width:i*(a-s),height:r}:null:{x:0,y:0,width:0,height:0}}function Oo(t,e){const n=Do(t,e);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function No(t,e,n,o,i,r=t=>t){for(const s of e.parts){const e=Fo(s.d);if(!e)continue;const a=s.opacity??1,l=t.globalAlpha;1!==a&&(t.globalAlpha=l*a);const c=i?"none"===s.fill?void 0:i:Io(s.fill,n,o);c&&(t.fillStyle=r(c),t.fill(e));const u=i?s.stroke&&"none"!==s.stroke?i:void 0:Io(s.stroke??"none",n,o);u&&(t.strokeStyle=r(u),t.lineWidth=s.strokeWidth??1,t.lineCap=s.strokeLinecap??"butt",t.lineJoin=s.strokeLinejoin??"miter",t.stroke(e)),1!==a&&(t.globalAlpha=l)}}var Wo=new WeakMap,jo=0,Yo=!1,Go=null,qo=null;function Xo(t,e){if(!e)return e;const n=function(t){const e=t.trim();if(!e.startsWith("var(")||!e.endsWith(")"))return null;const n=e.slice(4,-1),o=n.indexOf(",");if(-1===o){const t=n.trim();return t.startsWith("--")?{name:t}:null}const i=n.slice(0,o).trim(),r=n.slice(o+1).trim();return i.startsWith("--")?{name:i,fallback:r||void 0}:null}(e);if(!n)return e;const o=()=>n.fallback?Xo(t,n.fallback):e,i=t.canvas;if(!i)return o();!function(){if(Yo)return;if("undefined"==typeof window||"undefined"==typeof document)return;Yo=!0;const t=()=>{jo++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(t).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"],subtree:!0}),"function"==typeof window.matchMedia)try{Go=window.matchMedia("(prefers-color-scheme: dark)"),qo=t,"function"==typeof Go.addEventListener?Go.addEventListener("change",qo):"function"==typeof Go.addListener&&Go.addListener(qo)}catch{}}();let r=Wo.get(i);r&&r.version===jo||(r={version:jo,map:new Map},Wo.set(i,r));const s=r.map.get(e);if(void 0!==s)return s;const a=getComputedStyle(i).getPropertyValue(n.name).trim()||o()||e;return r.map.set(e,a),a}function Ho(t){return{type:"hatch",background:t.background,stroke:t.stroke,lineWidth:t.lineWidth,spacing:t.spacing,angle:t.angle}}var Vo=null;import{jsx as Uo,jsxs as Ko}from"react/jsx-runtime";function Zo(t){return"object"==typeof t&&null!==t&&"hatch"===t.type}function Qo(t){return["hatch",t.background??"transparent",t.stroke??"#000",t.lineWidth??1.5,t.spacing??6,t.angle??45,t.lineOpacity??1].join("|")}var Jo=new Map;function ti(t,e){const{background:n="transparent",stroke:o="#000",lineWidth:i=1.5,spacing:r=6,angle:s=45,lineOpacity:a=1}=t,l=Math.max(8,Math.ceil(2*r));return Ko("pattern",{id:e,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&Uo("rect",{width:l,height:l,fill:n}),Uo("line",{x1:0,y1:0,x2:0,y2:l,stroke:o,strokeWidth:i,strokeOpacity:a}),Uo("line",{x1:r,y1:0,x2:r,y2:l,stroke:o,strokeWidth:i,strokeOpacity:a})]},e)}function ei(t,e,n="#4e79a7"){if(Zo(t)){const n=function(t,e){let n=2166136261;const o=Qo(e);for(let t=0;o.length>t;t++)n^=o.charCodeAt(t),n=Math.imul(n,16777619);return`${t}-hatch-${(n>>>0).toString(36)}`}(e,t);return{fill:`url(#${n})`,def:ti(t,n)}}return t&&"string"==typeof t?{fill:t}:{fill:n}}import{curveMonotoneX as ni,curveMonotoneY as oi,curveCardinal as ii,curveCatmullRom as ri,curveStep as si,curveStepBefore as ai,curveStepAfter as li,curveBasis as ci,curveNatural as ui}from"d3-shape";function hi(t){switch(t){case"monotoneX":return ni;case"monotoneY":return oi;case"cardinal":return ii;case"catmullRom":return ri;case"step":return si;case"stepBefore":return ai;case"stepAfter":return li;case"basis":return ci;case"natural":return ui;default:return null}}function di(t,e,n){if(null==e)return n;if(Zo(e)){const o=function(t,e){const n="undefined"!=typeof window&&window.devicePixelRatio||1,o=`${Qo(t)}@${n}`,i=Jo.get(o);if(void 0!==i)return i;const r=function(t={},e){const{background:n="transparent",stroke:o="#000",lineWidth:i=1.5,spacing:r=6,angle:s=45}=t,a={background:n,stroke:o,lineWidth:i,spacing:r,angle:s},l=Math.max(8,Math.ceil(2*r));let c;try{c=function(t){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(t,t):(Vo||(Vo=document.createElement("canvas")),Vo.width=t,Vo.height=t,Vo)}(l)}catch{return Ho(a)}const u=c.getContext("2d");if(!u)return Ho(a);n&&"transparent"!==n?(u.fillStyle=n,u.fillRect(0,0,l,l)):u.clearRect(0,0,l,l),u.strokeStyle=o,u.lineWidth=i,u.lineCap="square";const h=s*Math.PI/180;if(45===s||-45===s){const t=s>0?1:-1;for(let e=-l;2*l>=e;e+=r)u.beginPath(),u.moveTo(e,0),u.lineTo(e+t*l,l),u.stroke()}else{u.save(),u.translate(l/2,l/2),u.rotate(h);const t=2*l;for(let e=-t;t>=e;e+=r)u.beginPath(),u.moveTo(-t,e),u.lineTo(t,e),u.stroke();u.restore()}return(e||u).createPattern(c,"repeat")}({background:t.background,stroke:t.stroke,lineWidth:t.lineWidth,spacing:t.spacing,angle:t.angle},e),s=Zo(r)?null:r;return Jo.set(o,s),s}(e,t);return o||e.background&&Xo(t,e.background)||n}return"string"!=typeof e?e:Xo(t,e)||n}function fi(t,e,n,o,i,r,s){if("colorStops"in e){const n=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>n.length)return null;const a=t.createLinearGradient(o,i,r,s);for(const t of n)a.addColorStop(t.offset,t.color);return a}const{topOpacity:a,bottomOpacity:l}=e;if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,l)),h=t.createLinearGradient(o,i,r,s),[d,f,p]=function(t,e){const n=t.fillStyle,o="#010203";try{t.fillStyle=o,t.fillStyle=e}catch{return t.fillStyle=n,[78,121,167]}const i=t.fillStyle;if(t.fillStyle=n,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===o&&e.trim().toLowerCase()!==o)return[78,121,167];if(i.startsWith("#"))return[parseInt(i.slice(1,3),16),parseInt(i.slice(3,5),16),parseInt(i.slice(5,7),16)];const r=i.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}(t,n);return h.addColorStop(0,`rgba(${d},${f},${p},${c})`),h.addColorStop(1,`rgba(${d},${f},${p},${u})`),h}function pi(t,e,n,o,i,r){const s=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>s.length)return null;const a=t.createLinearGradient(n,o,i,r);for(const t of s)a.addColorStop(t.offset,t.color);return a}import{line as yi}from"d3-shape";var gi=new WeakMap;function mi(t,e){const n=hi(e);if(!n)return t;const o=gi.get(t);if(o)return o;const i=function(t,e,n=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const o=[];let i=null;const r={moveTo(t,e){i=[t,e],o.push([t,e])},lineTo(t,e){i=[t,e],o.push([t,e])},bezierCurveTo(t,e,r,s,a,l){if(!i)return i=[a,l],void o.push([a,l]);const[c,u]=i;for(let i=1;n>=i;i++){const h=i/n,d=1-h;o.push([d*d*d*c+3*d*d*h*t+3*d*h*h*r+h*h*h*a,d*d*d*u+3*d*d*h*e+3*d*h*h*s+h*h*h*l])}i=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,n,r){i=[n,r],o.push([n,r])}};return yi().x(t=>t[0]).y(t=>t[1]).curve(e).context(r)(t),o}(t,n);return gi.set(t,i),i}function xi(t,e,n,o=30,i,r=0){let s=null;if(i){const t=function(t,e,n,o,i,r=t=>t.x,s=t=>t.y,a=t=>t.r){const l=Math.max(o,i+5,12),c=e-l,u=e+l,h=n-l,d=n+l;let f=null,p=1/0;return t.visit((t,i,l,y,g)=>{if(i>u||c>y||l>d||h>g)return!0;if(!t.length){let i=t;do{const t=i.data,l=r(t)-e,c=s(t)-n,u=Math.sqrt(l*l+c*c);To(a(t),o)>=u&&p>u&&(f=t,p=u),i=i.next}while(i)}return!1}),f?{node:f,distance:p}:null}(i,e,n,o,r);t&&(s={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const r of t){let t=null;switch(r.type){case"point":if(i)break;t=vi(r,e,n,o);break;case"symbol":t=wi(r,e,n,o);break;case"glyph":t=ki(r,e,n,o);break;case"line":t=Si(r,e,n,o);break;case"rect":if(null==r.datum)break;t=Mi(r,e,n);break;case"heatcell":t=_i(r,e,n);break;case"area":if(!1===r.interactive)break;t=Ci(r,e,n);break;case"candlestick":t=Pi(r,e,n)}t&&o>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function bi(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const o=Ti(t,e);if(0>o)return null;if(Math.abs(t[o][0]-e)>n)return null;let i=o,r=o;o>0&&t[o][0]>=e?(i=o-1,r=o):t.length-1>o&&(i=o,r=o+1);const[s,a]=t[i],[l,c]=t[r];return l===s?a:a+Math.max(0,Math.min(1,(e-s)/(l-s)))*(c-a)}function vi(t,e,n,o=30){const i=e-t.x,r=n-t.y,s=Math.sqrt(i*i+r*r);return s>To(t.r,o)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function wi(t,e,n,o=30){const i=e-t.x,r=n-t.y,s=Math.sqrt(i*i+r*r);return s>To(fn(t.size),o)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function ki(t,e,n,o=30){if(null==t.datum)return null;const i=Oo(t.glyph,t.size),r=t.x+i.centerDx,s=t.y+i.centerDy,a=e-r,l=n-s,c=Math.sqrt(a*a+l*l);return c>To(i.radius,o)?null:{node:t,datum:t.datum,x:r,y:s,distance:c}}function Si(t,e,n,o=30){if(0===t.path.length)return null;const i=Ti(t.path,e);if(0>i)return null;const[r,s]=t.path[i];let a;if(t.path.length>1){let o=1/0;const r=Math.max(0,i-1),s=Math.min(t.path.length-2,i);for(let i=r;s>=i;i++){const[r,s]=t.path[i],[a,l]=t.path[i+1],c=Ai(e,n,r,s,a,l);o>c&&(o=c)}a=o}else{const t=e-r,o=n-s;a=Math.sqrt(t*t+o*o)}const l=t.style;return a>Math.max(5,(l.strokeWidth??l.lineWidth??1)/2+2,o)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:r,y:s,distance:a}}function Ai(t,e,n,o,i,r){const s=i-n,a=r-o,l=s*s+a*a;if(0===l)return Math.sqrt((t-n)**2+(e-o)**2);let c=((t-n)*s+(e-o)*a)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((t-(n+c*s))**2+(e-(o+c*a))**2)}function Mi(t,e,n){const o=Co(e,n,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function _i(t,e,n){const o=Co(e,n,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function Pi(t,e,n){const o=t.bodyWidth/2,i=Math.min(t.openY,t.closeY);if(!(t.x-o-3>e||e>t.x+o+3||t.highY-3>n||n>t.lowY+3)){const o=i+Math.max(Math.max(t.openY,t.closeY)-i,1)/2,r=e-t.x,s=n-o;return{node:t,datum:t.datum,x:t.x,y:o,distance:Math.sqrt(r*r+s*s)}}return null}function Ci(t,e,n){if(0===t.topPath.length)return null;const o=Ti(t.topPath,e);if(0>o)return null;const[i,r]=t.topPath[o],s=e-i,a=n-r,l=Math.sqrt(s*s+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[o]?t.datum[o]:t.datum,x:i,y:r,distance:l}}function Ti(t,e){if(0===t.length)return-1;let n=0,o=t.length-1;for(;o>n;){const i=n+o>>1;e>t[i][0]?n=i+1:o=i}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}import{useEffect as Li,useRef as Ri}from"react";var $i={fresh:1,aging:.7,stale:.45,expired:.25},zi={alpha:1,band:"fresh",isStale:!1};function Di(t,e){if(!t||0>=e)return zi;const n=null!=t.threshold&&t.threshold>0?t.threshold:5e3,o=t.graded;if(o){const t="object"==typeof o?o:{},r=i(e,n,t.thresholds);return{alpha:{...$i,...t.opacities??{}}[r],band:r,isStale:"fresh"!==r}}return e>n?{alpha:t.dimOpacity??.5,band:"stale",isStale:!0}:zi}import{jsx as Ii}from"react/jsx-runtime";function Bi({isStale:t,position:e}){return Ii("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===e?{top:4,left:4}:"bottom-left"===e?{bottom:4,left:4}:"bottom-right"===e?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:t?"#dc3545":"#28a745",color:"white"},children:t?"STALE":"LIVE"})}import{useMemo as Fi,useRef as Ei,useEffect as Oi}from"react";import*as Ni from"react";function Wi(t){const e=Math.max(1,t?.swatchSize??16),n=Math.max(e,t?.rowHeight??22);return{swatchSize:e,labelGap:Math.max(0,t?.labelGap??6),itemGap:Math.max(0,t?.itemGap??10),rowHeight:n,align:"left"===t?.align?"start":"right"===t?.align?"end":t?.align??"start",maxWidth:t?.maxWidth}}function ji(t,e){let n=24;return t.map(({hasLabel:t,itemCount:o})=>{n+=5;const i=n;let r;n+=8,t&&(n+=16,r=n,n+=8);const s=n;return n+=o*e+8,{lineY:i,labelY:r,itemsY:s,endY:n}})}import{jsx as Yi,jsxs as Gi}from"react/jsx-runtime";var qi={fill:(t,e)=>Yi("rect",{style:t,width:e,height:e}),line:(t,e)=>Yi("line",{style:t,x1:0,y1:0,x2:e,y2:e})};function Xi(t,e,n,o,i){let r;return r="function"==typeof n?n(t):(0,qi[n])(o(t,e),i),r}function Hi({swatchSize:t}){return Yi("path",{d:`M${.25*t},${.55*t} L${.45*t},${.75*t} L${.8*t},${.3*t}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Vi(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}var Ui=(t,e,n,o,i,r,s,a,l,c,u)=>{const{type:h="fill",styleFn:d,items:f}=t,p=[];let y=0;const g=!(!e&&!n),m="isolate"===c||void 0===c&&null!=i,{swatchSize:x,labelGap:b,rowHeight:v}=u;return f.forEach((t,c)=>{const u=Xi(t,c,h,d,x),w=Vi(t,o,i),k=i&&i.size>0&&i.has(t.label);p.push(Gi("g",{transform:`translate(0,${y})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===r&&c===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?k||!1:void 0,"aria-current":g&&!m&&null!=o&&t.label===o||void 0,"aria-label":t.label,onKeyDown:g?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const t=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;l(a,t);const e=n.currentTarget.parentElement?.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:g?e=>{l(a,c),n&&n(t);const o=e.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:g?t=>{n&&n(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&Yi("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+b+2+7*t.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,k&&Yi(Hi,{swatchSize:x}),Yi("text",{y:x/2,x:x+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+c)),y+=v}),p};function Ki({config:t,orientation:e="vertical",width:n=100}){const{colorFn:o,domain:i,label:r,format:s}=t,a=s||(t=>Math.round(100*t)/100+""),l="grad-legend-"+Ni.useId();if("horizontal"===e){const t=12,e=Math.min(n,200),s=Math.max(0,(n-e)/2),c=[];for(let t=0;64>=t;t++){const e=t/64;c.push(Yi("stop",{offset:100*e+"%",stopColor:o(i[0]+e*(i[1]-i[0]))},t))}return Gi("g",{"aria-label":r||"Gradient legend",children:[Yi("defs",{children:Yi("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),r&&Yi("text",{x:s+e/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:r}),Yi("rect",{x:s,y:0,width:e,height:t,fill:`url(#${l})`,rx:2}),Yi("text",{x:s,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[0])}),Yi("text",{x:s+e,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[1])})]})}const c=[];for(let t=0;64>=t;t++){const e=t/64;c.push(Yi("stop",{offset:100*e+"%",stopColor:o(i[1]-e*(i[1]-i[0]))},t))}return Gi("g",{"aria-label":r||"Gradient legend",children:[r&&Yi("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:r}),Yi("defs",{children:Yi("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),Yi("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),Yi("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[1])}),Yi("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[0])})]})}function Zi(t){const{legendGroups:e,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:r,legendInteraction:s,title:a="Legend",width:l=100,height:c=20,orientation:u="vertical",legendLayout:h}=t,d=Wi(h),[f,p]=Ni.useState(0),[y,g]=Ni.useState(0),m=Ni.useCallback((t,e)=>{p(t),g(e)},[]),x="vertical"===u?(({legendGroups:t,width:e,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:r,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:l,legendInteraction:c,metrics:u})=>{const h=[],d=ji(t.map(t=>({hasLabel:!!t.label,itemCount:t.items.length})),u.rowHeight);return t.forEach((t,f)=>{const p=d[f];h.push(Yi("line",{stroke:"gray",x1:0,y1:p.lineY,x2:e,y2:p.lineY},"legend-top-line legend-symbol-"+f)),t.label&&null!=p.labelY&&h.push(Yi("text",{y:p.labelY,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+f)),h.push(Yi("g",{className:"legend-item",transform:`translate(0,${p.itemsY})`,children:Ui(t,n,o,i,r,s,a,f,l,c,u)},"legend-group-"+f))}),h})({legendGroups:e||[],width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:r,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:d}):(({legendGroups:t,height:e,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:h})=>{let d=0;const f=[];t.forEach((t,e)=>{let p=0;t.label&&(p+=16);const y=((t,e,n,o,i,r,s,a,l,c,u,h)=>{const{type:d="fill",styleFn:f,items:p}=t,y=[],{swatchSize:g,labelGap:m,itemGap:x,rowHeight:b,align:v}=u,w=!(!e&&!n),k="isolate"===c||void 0===c&&null!=i,S=p.map(t=>g+m+7*t.label.length),A=[];let M=0,_=0;S.forEach((t,e)=>{const n=0===_?t:_+x+t;h&&h>0&&_>0&&n>h?(A.push({start:M,end:e,width:_}),M=e,_=t):_=n}),p.length>0&&A.push({start:M,end:p.length,width:_}),A.forEach((t,c)=>{let u="center"===v?Math.max(0,((h??t.width)-t.width)/2):"end"===v?Math.max(0,(h??t.width)-t.width):0;for(let h=t.start;t.end>h;h++){const t=p[h],v=Xi(t,h,d,f,g),A=Vi(t,o,i),M=i&&i.size>0&&i.has(t.label);y.push(Gi("g",{transform:`translate(${u},${c*b})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:w?a===r&&h===s?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&k?M||!1:void 0,"aria-current":w&&!k&&null!=o&&t.label===o||void 0,"aria-label":t.label,onKeyDown:w?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const t=(h+("ArrowRight"===n.key?1:-1)+p.length)%p.length;l(a,t);const e=n.currentTarget.parentElement?.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:w?e=>{l(a,h),n&&n(t);const o=e.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:w?t=>{n&&n(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&Yi("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+m+2+7*t.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,M&&Yi(Hi,{swatchSize:g}),Yi("text",{y:g/2,x:g+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+h)),u+=S[h]+x}});const P=Math.max(0,...A.map(t=>t.width)),C=A.length;return{items:y,offset:P,totalRows:C,totalHeight:C*b}})(t,o,i,r,s,a,l,e,c,u,h,h.maxWidth??n);p+=y.offset+5,f.push({label:t.label,...y,offset:p,totalRows:y.totalRows,totalHeight:y.totalHeight}),d+=p+12});const p=h.maxWidth??n;let y=d>p?0:"center"===h.align?Math.max(0,(p-d)/2):"end"===h.align?Math.max(0,p-d):0;const g=[];return f.forEach((n,o)=>{const i=t[o];i.label&&(g.push(Yi("text",{transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:i.label},"legend-text-"+o)),y+=16),g.push(Yi("g",{className:"legend-item",transform:`translate(${y},0)`,children:n.items},"legend-group-"+o)),y+=n.offset+5,t[o+1]&&g.push(Yi("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(n.totalHeight||e)+0+8},"legend-top-line legend-symbol-"+o)),y+=12}),Yi("g",{children:g})})({legendGroups:e||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:r,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:d}),b=!(!n&&!o);return Gi("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==r))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&Yi("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),x]})}function Qi(...t){let e;for(const n of t)n&&(e=Ji(e)&&Ji(n)?{legendGroups:[...e.legendGroups,...n.legendGroups]}:n);return e}function Ji(t){return"object"==typeof t&&null!==t&&"legendGroups"in t&&Array.isArray(t.legendGroups)}function tr(t){return"object"==typeof t&&null!==t&&"gradient"in t}import{jsx as er}from"react/jsx-runtime";function nr(t){const{legend:e,totalWidth:n,totalHeight:o,margin:i,legendPosition:r="right",legendLayout:s,title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:h,legendInteraction:d}=t;if(!e)return null;const f="top"===r||"bottom"===r,p=!!a,y=Math.max(0,n-i.left-i.right),g=Math.max(1,f?s?.maxWidth??y:100);let m,x;return"left"===r?(m=Math.max(4,i.left-g-10),x=i.top):"top"===r?(m=i.left,x=p?32:8):"bottom"===r?(m=i.left,x=o-i.bottom+38):(m=n-i.right+10,x=i.top),er("g",{transform:`translate(${m}, ${x})`,children:tr(e)?er(Ki,{config:e.gradient,orientation:f?"horizontal":"vertical",width:g}):Ji(e)?er(Zi,{legendGroups:e.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):e})}import{useMemo as or}from"react";import{bin as ir}from"d3-array";import{jsx as rr,jsxs as sr}from"react/jsx-runtime";function ar(t){return"string"==typeof t?{type:t}:t}function lr({orient:t,config:e,values:n,scale:o,size:i,length:r}){const s=function(t){return{type:t.type,bins:t.bins??20,fill:t.fill??"#4e79a7",fillOpacity:t.fillOpacity??.5,stroke:t.stroke??"none",strokeWidth:t.strokeWidth??1}}(e),a="top"===t||"bottom"===t,l=or(()=>{if(0===n.length)return null;const e=o.domain(),l=i-8;if("boxplot"===s.type){const e=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const o=e[Math.floor(.25*n)],i=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-o;return{q1:o,median:i,q3:r,whiskerLow:Math.max(e[0],o-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(n);if(!e)return null;const{q1:i,median:r,q3:c,whiskerLow:u,whiskerHigh:h}=e,d=Math.min(.5*l,20),f=(l-d)/2+4;if(a){const e=o(i),n=o(c),a=o(r),l=o(u),p=o(h),y="top"===t?-1:1,g=0;return sr("g",{"data-testid":"marginal-boxplot-"+t,children:[rr("line",{x1:l,y1:g+y*(f+d/2),x2:p,y2:g+y*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),rr("line",{x1:l,y1:g+y*f,x2:l,y2:g+y*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),rr("line",{x1:p,y1:g+y*f,x2:p,y2:g+y*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),rr("rect",{x:Math.min(e,n),y:"top"===t?g-f-d:g+f,width:Math.abs(n-e),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),rr("line",{x1:a,y1:"top"===t?g-f-d:g+f,x2:a,y2:"top"===t?g-f:g+f+d,stroke:s.fill,strokeWidth:2})]})}{const e=o(i),n=o(c),a=o(r),l=o(u),p=o(h),y="left"===t?-1:1,g=0;return sr("g",{"data-testid":"marginal-boxplot-"+t,children:[rr("line",{x1:g+y*(f+d/2),y1:l,x2:g+y*(f+d/2),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),rr("line",{x1:g+y*f,y1:l,x2:g+y*(f+d),y2:l,stroke:s.fill,strokeWidth:s.strokeWidth}),rr("line",{x1:g+y*f,y1:p,x2:g+y*(f+d),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),rr("rect",{x:"left"===t?g-f-d:g+f,y:Math.min(e,n),width:d,height:Math.abs(n-e),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),rr("line",{x1:"left"===t?g-f-d:g+f,y1:a,x2:"left"===t?g-f:g+f+d,y2:a,stroke:s.fill,strokeWidth:2})]})}}const c=ir().domain(e).thresholds(s.bins)(n);if(0===c.length)return null;const u=w(c.map(t=>t.length));if(0===u)return null;if("histogram"===s.type)return rr("g",{"data-testid":"marginal-histogram-"+t,children:c.map((e,n)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/u*l;if(a){const r=o(e.x0),a=o(e.x1)-o(e.x0);return rr("rect",{x:r,y:"top"===t?-4-i:4,width:Math.max(a,.5),height:i,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const r=o(e.x0),a=o(e.x1)-o(e.x0);return rr("rect",{x:"left"===t?-4-i:4,y:Math.min(r,r+a),width:i,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const e=l/2+4,n=[];for(const i of c){if(null==i.x0||null==i.x1)continue;const r=i.length/u*(l/2),s=o((i.x0+i.x1)/2);n.push(a?`${s},${"top"===t?-(e-r):e-r}`:`${"left"===t?-(e-r):e-r},${s}`)}for(let i=c.length-1;i>=0;i--){const r=c[i];if(null==r.x0||null==r.x1)continue;const s=r.length/u*(l/2),h=o((r.x0+r.x1)/2);n.push(a?`${h},${"top"===t?-(e+s):e+s}`:`${"left"===t?-(e+s):e+s},${h}`)}return rr("g",{"data-testid":"marginal-violin-"+t,children:rr("polygon",{points:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}if("ridgeline"===s.type){const e=[];if(a){const n=0,i=null!=c[0].x0?o(c[0].x0):0;e.push(`M${i},${n}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const i=n.length/u*l,r=o((n.x0+n.x1)/2);e.push(`L${r},${"top"===t?-i-4:i+4}`)}const s=null!=c[c.length-1].x1?o(c[c.length-1].x1):r;e.push(`L${s},${n}`),e.push("Z")}else{const n=0,i=null!=c[0].x0?o(c[0].x0):0;e.push(`M${n},${i}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const i=n.length/u*l,r=o((n.x0+n.x1)/2);e.push(`L${"left"===t?-i-4:i+4},${r}`)}const s=null!=c[c.length-1].x1?o(c[c.length-1].x1):r;e.push(`L${n},${s}`),e.push("Z")}return rr("g",{"data-testid":"marginal-ridgeline-"+t,children:rr("path",{d:e.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,o,s,i,r,t,a,4]);return l?rr("g",{className:"marginal-"+t,"data-testid":"marginal-"+t,children:l}):null}import*as cr from"react";import{jsx as ur,jsxs as hr}from"react/jsx-runtime";function dr(t,e=120,n=8){if(!t)return[];const o=Math.max(1,Math.floor(e/n)),i=t.split(/\s+/),r=[];let s="";for(const t of i)s&&s.length+1+t.length>o?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function fr(t,e,n,o){return"curly"===t?o?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:o?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function pr(t,e,n,o){if(!t)return ur("g",{className:"annotation-note"});const{label:i,title:r,orientation:s,align:a,wrap:l=120,noWrap:c}=t;if(!i&&!r)return ur("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>e?"end":"start";const f=16,p=r?c?[r]:dr(r,l):[],y=i?c?[i]:dr(i,l):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const x=[],b=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";t.useHTML||t.html?x.push(ur("foreignObject",{className:"annotation-note-html",x:"end"===d?g-l:"middle"===d?g-l/2:g,y:-16,width:l,height:Math.max(f,(p.length+y.length)*f+(r&&i?2:0))+f,style:{overflow:"visible"},children:hr("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[r&&ur("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:r}),i&&ur("div",{className:"annotation-note-label",children:i})]})},"annotation-note-html")):(p.length>0&&(x.push(ur("text",{className:"annotation-note-title",fill:b,textAnchor:d,fontWeight:"bold",children:p.map((t,e)=>ur("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-title")),m=p.length*f),y.length>0&&x.push(ur("text",{className:"annotation-note-label",fill:b,textAnchor:d,y:m,children:y.map((t,e)=>ur("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-label")));let v=null;if((r||i)&&(0!==e||0!==n))if("topBottom"===u){const t=Math.min(l,120);let e=0,n=t;"end"===d?(e=-t,n=0):"middle"===d&&(e=-t/2,n=t/2),v=ur("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(p.length+y.length)*f+(y.length>0?f:0);let e=0,n=t;"bottom"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),v=ur("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let k=0;return"topBottom"===u?k=0>n?-(w+2):18:"leftRight"===u&&(k="middle"===h?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===h||0>n?-(w+2):18),hr("g",{className:"annotation-note",transform:`translate(${e},${n})`,children:[ur("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:x}),v]})}function yr(t,e,n,o,i){const r=[];switch(t){case"callout-circle":{const t=(e?.radius||0)+(e?.radiusPadding||0);t>0&&r.push(ur("circle",{r:t,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=e?.width||0,o=e?.height||0;(t>0||o>0)&&r.push(ur("rect",{width:t,height:o,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":e?.custom&&r.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=o||0,s=i||0;if(void 0!==e?.x){const o=(e.x||0)-t;r.push(ur("line",{x1:o,y1:(e.y1||0)-s,x2:o,y2:(e.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==e?.y){const o=(e.y||0)-s;r.push(ur("line",{x1:(e.x1||0)-t,y1:o,x2:(e.x2||0)-t,y2:o,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==e?.x1||void 0!==e?.x2?r.push(ur("line",{x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===e?.y1&&void 0===e?.y2||r.push(ur("line",{x1:0,y1:(e.y1||0)-s,x2:0,y2:(e.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=e?.type||"curly",o=e?.width??e?.height;void 0!==o&&r.push(ur("path",{d:fr(t,o,e?.depth||30,void 0===e?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return ur("g",{className:"annotation-subject",children:r})}function gr(t,e,n,o,i,r){const s=[];let a=0,l=0;if("callout-circle"!==i&&"label"!==i||!r?.radius){if("callout-rect"===i&&r){const n=r.width||0,o=r.height||0;if(n>0||o>0){const i=n/2,r=o/2,s=t-i,c=e-r;if(0!==s||0!==c){const t=Math.abs(s),e=Math.abs(c),u=n/2,h=o/2,d=t*h>e*u?u/t:h/e;a=i+s*d,l=r+c*d}}}else if("bracket"===i&&r){const t=r.width,e=r.height,n=r.depth||30;void 0!==t?(a=t/2,l=n):void 0!==e&&(a=n,l=e/2)}}else{const n=(r.radius||0)+(r.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const o=Math.atan2(e,t);a=Math.cos(o)*n,l=Math.sin(o)*n}}const c=Math.sqrt((t-a)**2+(e-l)**2);if(c>.5){const i=o||"var(--semiotic-text-secondary, currentColor)",r="curve"===n?.type;let u=Math.atan2(e-l,t-a);if(r){const o=(a+t)/2,r=(l+e)/2,h=-(e-l)/c,d=(t-a)/c,f=(n?.curve??.25)*c,p=o+h*f,y=r+d*f;s.push(ur("path",{className:"connector-curve",d:`M${a},${l}Q${p},${y} ${t},${e}`,fill:"none",stroke:i},"connector-line")),u=Math.atan2(y-l,p-a)}else s.push(ur("line",{x1:a,y1:l,x2:t,y2:e,stroke:i},"connector-line"));if("arrow"===n?.end){const t=10,e=16/180*Math.PI;s.push(ur("path",{d:`M${a},${l}L${a+t*Math.cos(u+e)},${l+t*Math.sin(u+e)}L${a+t*Math.cos(u-e)},${l+t*Math.sin(u-e)}Z`,fill:i,stroke:"none"},"connector-arrow"))}}return ur("g",{className:"annotation-connector",children:s})}function mr(t){const{x:e=0,y:n=0,dx:o,dy:i,nx:r,ny:s,note:a,connector:l,subject:c,type:u,color:h,className:d,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=t,x=Array.isArray(e)?e[0]??0:e,b=Array.isArray(n)?n[0]??0:n,v=new Set(Array.isArray(f)?f:[]);let w=o||0,k=i||0;null!=r&&(w=r-x),null!=s&&(k=s-b);const S="string"==typeof u?u:"label";if("bracket"===S&&c&&0===w&&0===k)if(void 0!==c.width){w=c.width/2;const t=c.depth||30;k=t+(0>t?-5:5)}else if(void 0!==c.height){const t=c.depth||30;w=t+(0>t?-5:5),k=c.height/2}return hr("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.has("connector")&&gr(w,k,l,h,S,c),!v.has("subject")&&yr(S,c,h,x,b),!v.has("note")&&pr(a,w,k,h)]})}function xr(t){const{noteData:e}=t,{screenCoordinates:n}=e,o="string"==typeof e.type?e.type:"label",i=e.eventListeners||e.events||{};if(e.coordinates&&n){const t=e.nx||n[0][0]+(e.dx??0),i=e.ny||n[0][1]+(e.dy??0),r=n.map((n,r)=>{const s=Object.assign({},e,{note:0===r?e.note:{label:""},x:n[0],y:n[1],nx:t,ny:i});return ur(mr,{"data-testid":"semiotic-annotation",...s,type:o},"multi-annotation-"+r)});return ur("g",{children:r})}const r=e.note||{title:"none",label:e.label},s=`${r.label}-${r.title}-${e.i}`;return ur(mr,{"data-testid":"semiotic-annotation",events:i,...e,type:o},s)}import{packEnclose as br}from"d3-hierarchy";import{area as vr,curveLinear as wr,curveMonotoneX as kr,curveMonotoneY as Sr,curveStep as Ar,curveStepAfter as Mr,curveStepBefore as _r,curveBasis as Pr,curveCardinal as Cr,curveCatmullRom as Tr}from"d3-shape";function Lr(t){return Math.round(100*t)/100}function Rr(t,e=2){const n=[],o=[],i=e+1;for(let e=0;i>e;e++){let r=0;for(const[n,o]of t)null!==o&&(r+=n**e*o);n.push(r);const s=[];for(let n=0;i>n;n++){let o=0;for(const[i,r]of t)null!==r&&(o+=i**(e+n));s.push(o)}o.push(s)}o.push(n);const r=function(t,e){const n=t,o=t.length-1,i=[e];for(let t=0;o>t;t++){let e=t;for(let i=t+1;o>i;i++)Math.abs(n[t][i])>Math.abs(n[t][e])&&(e=i);for(let i=t;o+1>i;i++){const o=n[i][t];n[i][t]=n[i][e],n[i][e]=o}for(let e=t+1;o>e;e++)for(let i=o;i>=t;i--)n[i][e]-=n[i][t]*n[t][e]/n[t][t]}for(let t=o-1;t>=0;t--){let e=0;for(let r=t+1;o>r;r++)e+=n[r][t]*i[r];i[t]=(n[o][t]-e)/n[t][t]}return i}(o,i).map(Lr);return{points:t.map(([t])=>[Lr(t),Lr(r.reduce((e,n,o)=>e+n*t**o,0))]),equation:[...r].reverse()}}function $r(t,e){const n=e.scales?.x??e.scales?.time;return n?null!=t.x?n(t.x):e.xAccessor&&null!=t[e.xAccessor]?n(t[e.xAccessor]):null:null}function zr(t,e){const n=e.scales?.y??e.scales?.value;return n?null!=t.y?n(t.y):e.yAccessor&&null!=t[e.yAccessor]?n(t[e.yAccessor]):null:null}function Dr(t){return null==t?null:t+""}function Ir(t,e,n){return e.stickyPositionCache?.set(t,n),n}function Br(t,e,n){const o=t.anchor||t.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const i=n.pointNodes[o];if(i.pointId===t.pointId)return Ir(e,n,{x:i.x,y:i.y})}const o=function(t){const e=t.data;if(!e||0===e.length)return null;const n=e[e.length-1],o=t.scales?.x??t.scales?.time,i=t.scales?.y??t.scales?.value;if(!o||!i)return null;const r=n[t.xAccessor||"x"],s=n[t.yAccessor||"y"];return null==r||null==s?null:{x:o(r),y:i(s)}}(n);return o?Ir(e,n,o):null}if("semantic"===o){const o=function(t,e,n){const o=function(t){return Dr(t.provenance?.stableId??t.stableId)}(t);if(!o)return null;const i=n.pointNodes?.find(t=>Dr(t.pointId)===o);if(i)return Ir(e,n,{x:i.x,y:i.y});const r=n.data?.find(t=>function(t){return Dr(t.stableId??t.id??t.provenance?.stableId)}(t)===o);if(!r)return null;const s=$r(r,n),a=zr(r,n);return null==s||null==a?null:Ir(e,n,{x:s,y:a})}(t,e,n);if(o)return o}let i=null,r=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(i=e.x,r=e.y)}if(null!=i&&null!=r||(i=$r(t,n),r=zr(t,n)),null!=i&&null!=r)return Ir(e,n,{x:i,y:r});if("sticky"===o){const t=n.stickyPositionCache?.get(e);if(t)return t}return null}function Fr(t,e,n,o=50){return!(-o>t||t>(n.width||0)+o||-o>e||e>(n.height||0)+o)}import{jsx as Er}from"react/jsx-runtime";var Or={secondary:0,primary:3};function Nr(t){return!0===t?._annotationDeferred}function Wr(t){return"blended"===t?.cohesion||"layer"===t?.cohesion?t.cohesion:null}function jr(t){const e=t?.provenance?.confidence;return"number"==typeof e&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):null}function Yr(t){return Math.max(.72,.95-.06*t)}function Gr(t){const e=t.map((t,e)=>{return{p:t,i:e,emphasis:(n=t.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:jr(t.annotation),readingOrder:null,rank:1};var n}),n=e.some(t=>null!=t.emphasis||null!=t.confidence),o=t.some(t=>Nr(t.annotation)),i=t.some(t=>null!=Wr(t.annotation)),r=t.some(t=>"layer"===Wr(t.annotation));if(!n&&!o&&!i)return t.map(t=>t.node);const s=e.filter(t=>null==t.emphasis&&null!=t.confidence).slice().sort((t,e)=>(e.confidence??0)-(t.confidence??0)||t.i-e.i);s.forEach((t,e)=>{t.readingOrder=e,t.rank=2-e/Math.max(1,s.length)});for(const t of e)t.emphasis&&(t.rank=Or[t.emphasis]);const a=e.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(t=>{const{p:e,i:n,emphasis:o,readingOrder:i}=t,r=Nr(e.annotation);let s=e.node;if("primary"===o||"secondary"===o||null!=i){const t=null==o&&null!=i;s=Er("g",{className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+o,..."secondary"===o?{opacity:.6,fontSize:"0.88em"}:{},...t?{opacity:Yr(i),"data-annotation-reading-order":i}:{},children:e.node},"annotation-emphasis-"+n)}const a=Wr(e.annotation);return a&&(s=Er("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),r&&(s=Er("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return o&&a.unshift(Er("style",{children:".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}"},"annotation-disclosure-style")),r&&a.unshift(Er("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),a}import{jsx as qr,jsxs as Xr}from"react/jsx-runtime";var Hr="var(--semiotic-bg, #ffffff)";function Vr(t){const{x:e,y:n,text:o,fill:i,fontSize:r=12,fontWeight:s,fontFamily:a,textAnchor:l="start",dominantBaseline:c,background:u,className:h}=t,d=function(t){return void 0===t||!0===t||"halo"===t?{type:"halo"}:!1===t||"none"===t?null:"box"===t?{type:"box"}:{type:t.type??"halo",...t}}(u),f=t=>qr("text",{x:e,y:n,textAnchor:l,dominantBaseline:c,fill:i,fontSize:r,fontWeight:s,fontFamily:a,className:h,...t?{stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:"stroke"}:{},children:o});if(!d)return f();if("halo"===d.type)return f({stroke:d.fill??Hr,strokeWidth:d.haloWidth??3});const p=d.padding??{x:6,y:3},y="number"==typeof p?p:p.x,g="number"==typeof p?p:p.y,m=function(t,e){return(t+"").length*e*.6}(o,r),x=r+2*g;let b,v;return b="middle"===l?e-m/2-y:"end"===l?e-m-y:e-y,v="middle"===c||"central"===c?n-x/2:"hanging"===c||"text-before-edge"===c?n-g:n-.8*r-g,Xr("g",{className:h,children:[qr("rect",{x:b,y:v,width:m+2*y,height:x,rx:d.radius??3,ry:d.radius??3,fill:d.fill??Hr,fillOpacity:d.opacity??.85,stroke:d.stroke,strokeWidth:d.strokeWidth}),f()]})}import{jsx as Ur,jsxs as Kr}from"react/jsx-runtime";var Zr={linear:wr,monotoneX:kr,monotoneY:Sr,step:Ar,stepAfter:Mr,stepBefore:_r,basis:Pr,cardinal:Cr,catmullRom:Tr};var Qr=32,Jr=6,ts=4,es=8,ns=72;var os={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function is(t){if(!rs(t))return t;const e=("string"==typeof t.mobileText?t.mobileText:void 0)??("string"==typeof t.shortText?t.shortText:void 0);return!e||"string"!=typeof t.label&&null!=t.label?t:{...t,label:e}}function rs(t){return l(t)}function ss(t,e){if(!t)return[];const n=Math.max(1,Math.floor(e/7)),o=t.split(/\s+/).filter(Boolean),i=[];let r="";for(const t of o)r&&r.length+t.length+1>n?(i.push(r),r=t):r=r?`${r} ${t}`:t;return r&&i.push(r),i}function as(t,e,n,o,i){const r=t+n,s=e+o;return Math.abs(n)>Math.abs(o)?{x:0>n?r-i.width-4:r+4,y:0>o?s-i.height:s,width:i.width,height:i.height}:{x:0>n?r-i.width:r,y:0>o?s-i.height-4:s+4,width:i.width,height:i.height}}function ls(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function cs(t,e){return Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x))*Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}function us(t,e,n,o,i,r,s,a){const l=ls(t,s);let c=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,n,o){const i=Math.max(0,o-t.x),r=Math.max(0,o-t.y);return(i+Math.max(0,t.x+t.width-(e-o)))*t.height+(r+Math.max(0,t.y+t.height-(n-o)))*t.width}(l,i,r,a);for(const t of n)c+=12*cs(l,t);for(const t of o)c+=4*cs(l,t);return c}function hs(t){const{annotations:e,context:i,defaultOffset:r=Qr,notePadding:s=Jr,markPadding:a=ts,edgePadding:l=es,preserveManualOffsets:c=!0,routeLongConnectors:u=!0,connectorThreshold:h=ns,density:d,progressiveDisclosure:f=!1,redundantCues:p=!1,responsive:y,mobile:g,cohesion:m,audience:x}=t,b=i.width||0,v=i.height||0,w="object"==typeof g?g:{},k=w.breakpoint??480,S=!!g&&k>=b,A=S&&!1!==w.preferShortText?e.map(is):e,M=S&&!d?{maxAnnotations:w.maxAnnotations??("callout-list"===w.strategy?1:2),minVisible:w.minVisible??1}:d,_=f||S&&(!1!==w.progressiveDisclosure||"callout-list"===w.strategy),P=S&&!y?w.responsive??{minWidth:k}:y,C=S&&!m?w.cohesion:m;if(0===A.length||0>=b||0>=v)return A.slice();const T=[],L=function(t,e){return(t.pointNodes||[]).map(t=>{const n=Math.max(1,t.r||1)+e;return{x:t.x-n,y:t.y-n,width:2*n,height:2*n}})}(i,a);let R=!1;const $=A.map((t,e)=>{if(!rs(t))return t;const n=function(t,e,n){if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const o=t.pointId??t.nodeId;if(null!=o&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===o);if(t)return{x:t.x,y:t.y}}const i=t.coordinates,r=n.scales?.geoProjection;if(Array.isArray(i)&&i.length>=2&&r){const t=i[0],e=i[1];if("number"==typeof t&&"number"==typeof e){const n=r([t,e]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof t.x||"number"!=typeof t.y?Br(t,e,n):{x:t.x,y:t.y}}(t,e,i);if(!n)return t;const o=function(t){if("widget"===t.type)return{width:"number"==typeof t.width?t.width:32,height:"number"==typeof t.height?t.height:32};const e="number"==typeof t.wrap?t.wrap:120,n=[...ss("string"==typeof t.title?t.title:void 0,e),...ss("string"==typeof t.label?t.label:void 0,e)],o=n.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*o)+10),height:Math.max(18,16*n.length+6)}}(t);if(c&&("number"==typeof(a=t).dx||"number"==typeof a.dy)){const e=function(t){return"text"===t.type||"widget"===t.type?{dx:0,dy:0}:{dx:30,dy:-30}}(t);return T.push(ls(as(n.x,n.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,o),s)),t}var a;let d=null,f=1/0;for(const t of function(t){const e=1.6*t;return[{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t},{dx:t,dy:0},{dx:-t,dy:0},{dx:0,dy:-t},{dx:0,dy:t},{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e}]}(r)){const e=us(as(n.x,n.y,t.dx,t.dy,o),t,T,L,b,v,s,l);f>e&&(d=t,f=e)}if(!d)return t;const p=ls(as(n.x,n.y,d.dx,d.dy,o),s);T.push(p);const y=Math.hypot(d.dx,d.dy),g=u&&y>=h&&"text"!==t.type&&"widget"!==t.type?{...t.connector||{end:"arrow"},type:"curve"}:t.connector;return R=!0,{...t,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),z=R?$:A.slice();let D=z;if(p){let t=!1;const e=z.map(e=>{const n=function(t){return"text"!==t.type||"string"!=typeof t.color||8>Math.hypot("number"==typeof t.dx?t.dx:0,"number"==typeof t.dy?t.dy:0)?t:{...t,_redundantConnector:!0}}(e);return n!==e&&(t=!0),n});D=t?e:z}{let t=!1;const e=D.map(e=>{if(!0!==e?.defensive)return e;const n=function(t){const e=t?.provenance;if(!e||"object"!=typeof e)return t;const n="string"==typeof e.source?os[e.source]??e.source:null,o="number"==typeof e.confidence&&Number.isFinite(e.confidence)?Math.round(100*Math.max(0,Math.min(1,e.confidence)))+"%":null;if(!n&&!o)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const i=[n,o].filter(Boolean).join(" · "),r="string"==typeof t.label?t.label:"";return r.includes(`(${i})`)?t:{...t,label:r?`${r} (${i})`:`(${i})`}}(e);return n!==e&&(t=!0),n});D=t?e:D}const I=new Set;if(M){const t="object"==typeof M?M:{},e=function(t){if(!t)return 1;const e=function(t){const e=t?.familiarity;if(!e)return 3;const n=Object.values(e).filter(t=>"number"==typeof t&&Number.isFinite(t));return 0===n.length?3:n.reduce((t,e)=>t+e,0)/n.length}(t);return e>2?4>e?1:.6:1.5}(x),i=1===e?t:{...t,maxAnnotations:Math.max(0,Math.round((t.maxAnnotations??n(b,v,t))*e))},{deferred:r}=o({annotations:D,width:b,height:v,...i});for(const t of r)I.add(t)}if(P&&("object"==typeof P&&"number"==typeof P.minWidth?P.minWidth:480)>=b)for(const t of D)rs(t)&&"secondary"===t.emphasis&&I.add(t);if(I.size>0)for(const t of D)!0===t?.defensive&&I.delete(t);let B;return B=0===I.size?D:_?D.map(t=>I.has(t)?{...t,_annotationDeferred:!0}:t):D.filter(t=>!I.has(t)),C?function(t,e){let n=!1;const o=t.map(t=>rs(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(n=!0,{...t,cohesion:e}):t);return n?o:t}(B,C):B}import{useSyncExternalStore as ds}from"react";var fs={positions:new Map},ps=new Set;function ys(){for(const t of ps)t()}function gs(t,e){const n=fs.positions.get(t);if(n?.locked)return;if(!n||n.sourceId!==e)return;const o=new Map(fs.positions);o.delete(t),fs={positions:o},ys()}function ms(t,e){const n=fs.positions.get(t);if(!n?.locked)return;if(e&&n.sourceId!==e)return;const o=new Map(fs.positions);o.delete(t),fs={positions:o},ys()}function xs(){return fs}function bs(t){return ps.add(t),()=>ps.delete(t)}var vs={positions:new Map};function ws(){return()=>{}}function ks(){return vs}function Ss(t,e,n){return"exact"===n?function(t,e){const n=t.domain(),o=n[0],i=n[n.length-1],r=o instanceof Date,s=o instanceof Date?o.getTime():o,a=i instanceof Date?i.getTime():i;if(2>e||s===a)return r?[new Date(s),new Date(a)]:[s,a];const l=(a-s)/(e-1),c=Array(e);for(let t=0;e>t;t++){const n=t===e-1?a:s+t*l;c[t]=r?new Date(n):n}return c}(t,e):t.ticks(e)}function As(t,e,n){if("edges"===t){if(e)return"start";if(n)return"end"}return"middle"}function Ms(t,e,n){if("edges"===t){if(e)return"hanging";if(n)return"auto"}return"middle"}function _s(t){if(0===t.length)return{min:null,max:null};let e=1/0,n=-1/0;for(const o of t)e>o.pixel&&(e=o.pixel),o.pixel>n&&(n=o.pixel);return{min:e,max:n}}function Ps(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Cs(t,e,n){if("left"===t||"right"===t){const o="left"===t?n:0,i="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+o;for(let t=0;r>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${o+4*i}`,s+=`L${Math.min(n,e)},${o}`}return s}const o="bottom"===t?0:e,i="bottom"===t?1:-1,r=Math.ceil(n/8);let s=`M${o},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${o+4*i},${Math.min(8*t+4,n)}`,s+=`L${o},${Math.min(e,n)}`}return s}function Ts(t){return"string"==typeof t&&t.length>0}function Ls(t,e,n=!1){const o=n?e?58:34:e?36:0;return o>t.top?{...t,top:o}:t}function Rs(t,e){return Ls(t,Ts(e))}import{Fragment as $s,jsx as zs,jsxs as Ds}from"react/jsx-runtime";function Is(t){const{width:e,height:n,totalWidth:o,totalHeight:i,margin:r,scales:s,showAxes:a,axes:l,showGrid:c,xFormat:u,yFormat:h,axisExtent:d}=t,f=Fi(()=>{if(!s)return[];const t=l?.find(t=>"bottom"===t.orient),n=t?.tickFormat||u||Bs,o=Math.max(2,Math.floor(e/70)),i=t?.ticks??5,r="exact"===d?Math.max(2,i):Math.min(i,o),a=t?.tickValues??Ss(s.x,r,d),c=a.map(t=>t.valueOf()),h=a.map((t,e)=>({value:t,pixel:s.x(t),label:n(t,e,c)})),f=h.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return Fs(h,Math.max(55,f+8))},[s,l,u,e,d]),p=Fi(()=>{if(!s)return[];const t=l?.find(t=>"left"===t.orient),e=t?.tickFormat||h||Bs,o=Math.max(2,Math.floor(n/30)),i=t?.ticks??5,r="exact"===d?Math.max(2,i):Math.min(i,o);return Fs((t?.tickValues??Ss(s.y,r,d)).map(t=>({value:t,pixel:s.y(t),label:e(t)})),22)},[s,l,h,n,d]),y=c&&s,g=a&&s;if(!y&&!g)return null;const m=l?.find(t=>"bottom"===t.orient),x=l?.find(t=>"left"===t.orient),b=g&&(!m||!1!==m.baseline),v=g&&(!x||!1!==x.baseline),w=m?.jaggedBase||!1,k=x?.jaggedBase||!1,S="var(--semiotic-border, #ccc)";return zs("svg",{width:o,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:Ds("g",{transform:`translate(${r.left},${r.top})`,children:[y&&(()=>{const t=Ps(l?.find(t=>"bottom"===t.orient)?.gridStyle),o=Ps(l?.find(t=>"left"===t.orient)?.gridStyle);return Ds("g",{className:"stream-grid",children:[f.map((e,o)=>zs("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:t},"xgrid-"+o)),p.map((t,n)=>zs("line",{x1:0,y1:t.pixel,x2:e,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),b&&!w&&zs("line",{x1:0,y1:n,x2:e,y2:n,stroke:S,strokeWidth:1}),w&&zs("path",{d:Cs("bottom",e,n),fill:"none",stroke:S,strokeWidth:1}),v&&!k&&zs("line",{x1:0,y1:0,x2:0,y2:n,stroke:S,strokeWidth:1}),k&&zs("path",{d:Cs("left",e,n),fill:"none",stroke:S,strokeWidth:1})]})})}function Bs(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function Fs(t,e){if(2>=t.length)return t;const n=[t[0]];for(let o=1;t.length-1>o;o++)e>Math.abs(t[o].pixel-n[n.length-1].pixel)||n.push(t[o]);const o=t[t.length-1];return e>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function Es(t){const{width:n,height:o,totalWidth:i,totalHeight:r,margin:a,scales:l,showAxes:c,axes:u,xLabel:h,yLabel:d,yLabelRight:f,xFormat:y,yFormat:g,axisExtent:m,showGrid:x,title:b,legend:v,legendHoverBehavior:w,legendClickBehavior:k,legendHighlightedCategory:A,legendIsolatedCategories:M,legendPosition:_="right",legendLayout:P,foregroundGraphics:C,marginalGraphics:T,xValues:L,yValues:R,annotations:$,onAnnotationActivate:z,onObservation:D,chartId:I,chartType:B,autoPlaceAnnotations:F,svgAnnotationRules:E,xAccessor:O,yAccessor:N,annotationData:W,pointNodes:j,curve:Y,underlayRendered:G,canvasObscuresUnderlay:q=!0,linkedCrosshairName:X,linkedCrosshairSourceId:H,children:V}=t,U=p({onAnnotationActivate:z,onObservation:D,chartId:I,chartType:B}),K=Fi(()=>{if(!c||!l)return[];const t=u?.find(t=>"bottom"===t.orient),e=t?.tickFormat||y||Bs,o=Math.max(2,Math.floor(n/70)),i=t?.ticks??5,r="exact"===m?Math.max(2,i):Math.min(i,o),s=t?.tickValues??Ss(l.x,r,m),a=s.map(t=>t.valueOf()),h=s.map((t,n)=>({value:t,pixel:l.x(t),label:e(t,n,a)})),d=h.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),f=t?.autoRotate?Math.max(20,Math.min(d+8,55)):Math.max(55,d+8);let p=Fs(h,f);if(p.length>1&&(p=p.filter((t,e)=>0===e||t.label+""!=p[e-1].label+"")),t?.includeMax&&p.length>0&&"exact"!==m&&!t?.tickValues){const t=l.x.domain()[1],n=l.x(t),o=p[p.length-1].pixel;if(Math.abs(n-o)>1){const i=e(t,p.length,a);f>n-o&&p.length>1&&(p=p.slice(0,-1)),p.push({value:t,pixel:n,label:i})}}return p},[c,l,u,y,n,m]),Z=Fi(()=>{if(!c||!l)return[];const t=u?.find(t=>"left"===t.orient),e=t?.tickFormat||g||Bs,n=Math.max(2,Math.floor(o/30)),i=t?.ticks??5,r="exact"===m?Math.max(2,i):Math.min(i,n);let s=Fs((t?.tickValues??Ss(l.y,r,m)).map(t=>({value:t,pixel:l.y(t),label:e(t)})),22);if(s.length>1&&(s=s.filter((t,e)=>0===e||t.label+""!=s[e-1].label+"")),t?.includeMax&&s.length>0&&"exact"!==m&&!t?.tickValues){const t=l.y.domain()[1],n=l.y(t),o=s[s.length-1].pixel;if(Math.abs(n-o)>1){const i=e(t);22>Math.abs(n-o)&&s.length>1&&(s=s.slice(0,-1)),s.push({value:t,pixel:n,label:i})}}return s},[c,l,u,g,o,m]),Q=Fi(()=>{if(!c||!l)return[];const t=u?.find(t=>"right"===t.orient);if(!t)return[];const e=t.tickFormat||g||Bs,n=Math.max(2,Math.floor(o/30)),i=t.ticks??5;return Fs((t.tickValues??Ss(l.y,"exact"===m?Math.max(2,i):Math.min(i,n),m)).map(t=>({value:t,pixel:l.y(t),label:e(t)})),22)},[c,l,u,g,o,m]),J=Ei(new Map),tt=Ei($?.length??0),et=$?.length??0;tt.current!==et&&(tt.current=et,J.current=new Map);const nt=Fi(()=>{if(!$||0===$.length)return null;const t=s($),i=function(t,n={}){return function(t,o,i){switch(t.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const e=Br(t,o,i);if(!e)return null;const{x:n,y:r}=e;if(!Fr(n,r,i))return null;const s="callout"===t.type?"callout-circle":t.type,a="callout-circle"===s?{radius:t.radius??12,radiusPadding:t.radiusPadding}:"callout-rect"===s?{width:t.width,height:t.height}:void 0;return Ur(xr,{noteData:{x:n,y:r,dx:t.dx??30,dy:t.dy??-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:s,...a?{subject:a}:{},connector:t.connector||{end:"arrow"},color:t.color,disable:t.disable,opacity:t.opacity,strokeDasharray:t.strokeDasharray,className:t.className}},"ann-"+o)}case"x-threshold":{const e=$r(null!=t.value?{...t,x:t.value}:t,i);if(null==e)return null;const n=t.color||"#f97316",r=t.labelPosition||"top";let s;s="bottom"===r?(i.height||0)-4:"center"===r?(i.height||0)/2:16;const a=e>.6*(i.width||0),l=a?e-4:e+4,c=a?"end":"start";return Kr("g",{opacity:t.opacity,children:[Ur("line",{x1:e,y1:0,x2:e,y2:i.height||0,stroke:n,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&Ur(Vr,{x:l,y:s,text:t.label,textAnchor:c,fill:n,fontSize:12,fontWeight:"bold",background:t.labelBackground??"halo"})]},"ann-"+o)}case"y-threshold":{const e=zr(null!=t.value?{...t,y:t.value}:t,i);if(null==e)return null;const n=t.color||"#f97316",r=t.labelPosition||"right";let s,l;"left"===r?(s=4,l="start"):"center"===r?(s=(i.width||0)/2,l="middle"):(s=(i.width||0)-4,l="end");const c=20>(a=e)?Math.min((i.height||0)-4,a+16):a-4;return Kr("g",{opacity:t.opacity,children:[Ur("line",{x1:0,y1:e,x2:i.width||0,y2:e,stroke:n,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&Ur(Vr,{x:s,y:c,text:t.label,textAnchor:l,fill:n,fontSize:12,fontWeight:"bold",background:t.labelBackground??"halo"})]},"ann-"+o)}case"enclose":{const e=(t.coordinates||[]).map(t=>({x:$r({...t,type:"point"},i),y:zr({...t,type:"point"},i),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>e.length)return null;const n=br(e),r=t.padding||10;return Kr("g",{children:[Ur("circle",{cx:n.x,cy:n.y,r:n.r+r,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&Ur(Vr,{x:n.x,y:n.y-n.r-r-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:t.label,background:t.labelBackground??"none"})]},"ann-"+o)}case"rect-enclose":{const e=(t.coordinates||[]).map(t=>({x:$r({...t,type:"point"},i),y:zr({...t,type:"point"},i)})).filter(t=>null!=t.x&&null!=t.y);if(2>e.length)return null;const n=t.padding||10,r=e.map(t=>t.x),s=e.map(t=>t.y),[a,l]=S(r),[c,u]=S(s),h=a-n,d=l+n,f=c-n;return Kr("g",{children:[Ur("rect",{x:h,y:f,width:d-h,height:u+n-f,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&Ur(Vr,{x:(h+d)/2,y:f-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:t.label,background:t.labelBackground??"none"})]},"ann-"+o)}case"highlight":{const e=i.data||[],n="function"==typeof t.filter?e.filter(t.filter):t.field&&null!=t.value?e.filter(e=>e[t.field]===t.value):[],r={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return Ur("g",{children:n.map((e,n)=>{const o=$r(e,i),s=zr(e,i);if(null==o||null==s)return null;const a="function"==typeof t.r?t.r(e):t.r||6,l="function"==typeof t.style?t.style(e):t.style||r;return Ur("circle",{cx:o,cy:s,r:a,...l},"hl-"+n)})},"ann-"+o)}case"bracket":{const e=$r(t,i),n=zr(t,i);return Ur(xr,{noteData:{x:e??0,y:n??0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}},"ann-"+o)}case"trend":{const e=i.data||[];if(2>e.length)return null;const n=i.xAccessor||"x",r=i.yAccessor||"y",s="ordinal"===i.frameType,a="horizontal"===i.projection,l=s?n:null,c=s?r:null;let u;const h=[],d=new Map;if(s&&l&&c){for(const t of e){const e=t[l];if(null==e)continue;const n=e+"";d.has(n)||(d.set(n,h.length),h.push(n))}u=e.map(t=>{const e=t[l],n=t[c];if(null==e||null==n)return null;const o=d.get(e+"");return null!=o?[o,+n]:null}).filter(t=>null!==t)}else u=e.map(t=>[t[n],t[r]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>u.length)return null;const f=i.scales?.x??i.scales?.time,p=i.scales?.y??i.scales?.value;if(!f||!p)return null;const y=t=>e=>{const n=Math.max(0,Math.floor(e)),o=Math.min(h.length-1,n+1),i=e-n,r=t(h[n]);return r+(t(h[o])-r)*i},g=f,m=p;let x;if(s)if(a){const t=y(m);x=(e,n)=>[g(n),t(e)]}else{const t=y(g);x=(e,n)=>[t(e),m(n)]}else x=(t,e)=>[g(t),m(e)];const b=t.method||"linear";let v;if("loess"===b)v=function(t,e=.3){const n=t.length;if(2>n)return t.slice();const o=t.slice().sort((t,e)=>t[0]-e[0]),i=o.map(t=>t[0]),r=o.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=i[t],o=i.map(t=>Math.abs(t-e)),l=o.slice().sort((t,e)=>t-e)[Math.min(s-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===l?0:o[t]/l;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,h=0,d=0,f=0,p=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,h+=e*i[t],d+=e*r[t],f+=e*i[t]*i[t],p+=e*i[t]*r[t])}if(0===u){a.push([e,r[t]]);continue}const y=u*f-h*h;if(1e-12>Math.abs(y))a.push([e,d/u]);else{const t=(u*p-h*d)/y;a.push([e,(d-t*h)/u+t*e])}}return a}(u,t.bandwidth??.3);else{const e="polynomial"===b?Rr(u,t.order||2):function(t){const e=[0,0,0,0];let n=0;for(const[o,i]of t)null!==i&&(n++,e[0]+=o,e[1]+=i,e[2]+=o*o,e[3]+=o*i);const o=n*e[2]-e[0]*e[0],i=0===o?0:Lr((n*e[3]-e[0]*e[1])/o),r=Lr(e[1]/n-i*e[0]/n);return{points:t.map(([t])=>[Lr(t),Lr(i*t+r)]),equation:[i,r]}}(u);v=e.points}const w=v.map(([t,e])=>{const[n,o]=x(t,e);return`${n},${o}`}).join(" "),k=t.color||"#6366f1",S=v[v.length-1],[A,M]=x(S[0],S[1]);return Kr("g",{children:[Ur("polyline",{points:w,fill:"none",stroke:k,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&Ur("text",{x:A+4,y:M-4,fill:k,fontSize:11,children:t.label})]},"ann-"+o)}case"band":{const e=i.scales?.y??i.scales?.value,n=e?.domain?.(),a=t.y0??n?.[0],l=t.y1??n?.[1],c=null!=a&&e?e(a):0,u=null!=l&&e?e(l):i.height||0,h=ei(t.fill,"ann-"+o,"var(--semiotic-primary, #6366f1)");return Kr("g",{opacity:t.opacity,children:[h.def&&Ur("defs",{children:h.def}),Ur("rect",{x:0,y:Math.min(c,u),width:i.width||0,height:Math.abs(u-c),fill:h.fill,fillOpacity:t.fillOpacity||.1}),t.label&&Ur(Vr,{x:(i.width||0)-4,y:(r=c,s=u,Math.max(Math.min(r,s),0)+16),textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:t.label,background:t.labelBackground??"halo"})]},"ann-"+o)}case"x-band":{const e=i.scales?.x??i.scales?.time,n=e?.domain?.(),r=t.x0??n?.[0],s=t.x1??n?.[1],a=null!=r&&e?e(r):null,l=null!=s&&e?e(s):null;if(null==a||null==l)return null;const c=ei(t.fill||t.color,"ann-"+o,"var(--semiotic-primary, #6366f1)");return Kr("g",{opacity:t.opacity,children:[c.def&&Ur("defs",{children:c.def}),Ur("rect",{x:Math.min(a,l),y:0,width:Math.abs(l-a),height:i.height||0,fill:c.fill,fillOpacity:t.fillOpacity??.1}),t.label&&Ur(Vr,{x:Math.min(a,l)+4,y:16,textAnchor:"start",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:t.label,background:t.labelBackground??"halo"})]},"ann-"+o)}case"envelope":{const e=i.data||[];if(2>e.length)return null;const n=i.xAccessor||"x",r=i.scales?.x??i.scales?.time,s=i.scales?.y??i.scales?.value;if(!r||!s)return null;const a=t.upperAccessor||"upperBounds",l=t.lowerAccessor||"lowerBounds",c=t.filter,u=e.filter(t=>null!=t[a]&&null!=t[l]&&!(c&&!c(t))).sort((t,e)=>t[n]-e[n]);if(2>u.length)return null;const h=Zr[i.curve||"linear"]||wr,d=vr().x(t=>r(t[n])).y0(t=>s(t[l])).y1(t=>s(t[a])).curve(h)(u);if(!d)return null;const f=t.fill||"#6366f1";return Kr("g",{children:[Ur("path",{d:d,fill:f,fillOpacity:t.fillOpacity??.15,stroke:"none"}),t.label&&u.length>0&&Ur("text",{x:r(u[u.length-1][n])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:t.label})]},"ann-"+o)}case"anomaly-band":{const e=i.data||[];if(2>e.length)return null;const n=i.yAccessor||"y",r=i.scales?.x??i.scales?.time,s=i.scales?.y??i.scales?.value;if(!r||!s)return null;const a=e.map(t=>t[n]).filter(t=>null!=t&&isFinite(t));if(2>a.length)return null;const l=a.reduce((t,e)=>t+e,0)/a.length,c=a.reduce((t,e)=>t+(e-l)**2,0)/a.length,u=Math.sqrt(c),h=t.threshold??2,d=l-h*u,f=!1!==t.showBand,p=t.fill||"#6366f1",y=t.fillOpacity??.1,g=t.anomalyColor||"#ef4444",m=t.anomalyRadius??6,x=s(l+h*u),b=s(d),v=e.filter(t=>{const e=t[n];return null!=e&&Math.abs(e-l)>h*u});return Kr("g",{children:[f&&Ur("rect",{x:0,y:Math.min(x,b),width:i.width||0,height:Math.abs(b-x),fill:p,fillOpacity:y}),v.map((t,e)=>{const n=$r(t,i),o=zr(t,i);return null==n||null==o?null:Ur("circle",{cx:n,cy:o,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+e)}),t.label&&Ur("text",{x:(i.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:p,fontSize:11,children:t.label})]},"ann-"+o)}case"forecast":{const e=i.data||[];if(3>e.length)return null;const n=i.xAccessor||"x",r=i.yAccessor||"y",s=i.scales?.x??i.scales?.time,a=i.scales?.y??i.scales?.value;if(!s||!a)return null;const l=e.map(t=>[t[n],t[r]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>l.length)return null;let c;if("polynomial"===(t.method||"linear")){const e=Rr(l,t.order||2).equation;c=t=>e.reduce((e,n,o)=>e+n*Math.pow(t,o),0)}else{const t=l.length;let e=0,n=0,o=0,i=0;for(const[t,r]of l)e+=t,n+=r,o+=t*t,i+=t*r;const r=t*o-e*e;if(1e-12>Math.abs(r))return null;const s=(t*i-e*n)/r,a=(n-s*e)/t;c=t=>a+s*t}const u=l.length,h=l.map(([t,e])=>e-c(t)),d=h.reduce((t,e)=>t+e*e,0),f=Math.sqrt(d/Math.max(u-2,1)),p=l.reduce((t,e)=>t+e[0],0)/u,y=l.reduce((t,e)=>t+(e[0]-p)**2,0),g=t.confidence??.95,m=.99>g?.95>g?.9>g?1:1.645:1.96:2.576,x=t.steps??5,b=l[u-1][0],v=(b-l[0][0])/Math.max(u-1,1),w=[];for(let t=1;x>=t;t++)w.push(b+t*v);const k=[];for(const t of w){const e=c(t),n=f*Math.sqrt(1+1/u+(y>0?(t-p)**2/y:0))*m;k.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const S=`M${k.map(t=>`${s(t.x)},${a(t.yUpper)}`).join(" L")} L${k.slice().reverse().map(t=>`${s(t.x)},${a(t.yLower)}`).join(" L")} Z`,A=k.map(t=>`${s(t.x)},${a(t.yCenter)}`).join(" "),M=`${s(b)},${a(c(b))}`,_=t.strokeColor||"#6366f1";return Kr("g",{children:[Ur("path",{d:S,fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity??.15,stroke:"none"}),Ur("polyline",{points:`${M} ${A}`,fill:"none",stroke:_,strokeWidth:t.strokeWidth??2,strokeDasharray:t.strokeDasharray??"6,3"}),t.label&&k.length>0&&Ur("text",{x:s(k[k.length-1].x)+4,y:a(k[k.length-1].yCenter)-4,fill:_,fontSize:11,children:t.label})]},"ann-"+o)}case"widget":{let r,s;if(null!=t.px&&null!=t.py)r=t.px,s=t.py;else{const e=Br(t,o,i);if(!e)return null;r=e.x,s=e.y}if(!Fr(r,s,i))return null;const a=t.dx??0,l=t.dy??0,c=t.width??32,u=t.height??32,h=t.content??Ur("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info",children:"ℹ️"});return Ur("foreignObject",{x:r+a-c/2,y:s+l-u/2,width:c,height:u,style:{overflow:"visible",pointerEvents:"auto"},children:Ur("div",{...e(t,n),style:{width:c,height:u,display:"flex",alignItems:"center",justifyContent:"center"},children:h})},"ann-"+o)}case"text":{const e=Br(t,o,i);if(!e)return null;const{x:n,y:r}=e,s=n+(t.dx||0),a=r+(t.dy||0),l=t.color||"var(--semiotic-text, #333)",c=Ur("text",{x:s,y:a,fill:l,fontSize:t.fontSize||11,opacity:t.opacity,strokeDasharray:t.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:t.label});return!0!==t._redundantConnector?cr.cloneElement(c,{key:"ann-text-"+o}):Kr("g",{opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:[Ur("line",{x1:n,y1:r,x2:s,y2:a,stroke:l,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),cr.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+o)}case"category-highlight":{const e=t.category;if(null==e)return null;const n=t=>"function"==typeof t&&"function"==typeof t.bandwidth,r=i.scales?.o,s=i.scales?.x,a=i.scales?.y,l=n(r)?r:n(s)?s:n(a)?a:null;if(!l)return null;const c=l(e+"");if(null==c)return null;const u=l.bandwidth(),h=t.color||"var(--semiotic-primary, #4589ff)",d=t.opacity??.15,f=t.label;return Kr("g",(i.projection?"vertical"===i.projection:l===s)?{children:[Ur("rect",{x:c,y:0,width:u,height:i.height||0,fill:h,fillOpacity:d}),f&&Ur(Vr,{x:c+u/2,y:16,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:t.labelBackground??"none"})]}:{children:[Ur("rect",{x:0,y:c,width:i.width||0,height:u,fill:h,fillOpacity:d}),f&&Ur(Vr,{x:12,y:c+u/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:t.labelBackground??"none"})]},"ann-"+o)}default:return null}var r,s,a}}(0,U),r={scales:l?{x:l.x,y:l.y,time:l.x,value:l.y}:null,timeAxis:"x",xAccessor:O,yAccessor:N,width:n,height:o,data:W,frameType:"xy",pointNodes:j,curve:Y,stickyPositionCache:J.current};return function(t,e,n,o){const i=[];return t.forEach((t,r)=>{let s;if(n){const i=n(t,r,o);s=null!=i?i:e(t,r,o)}else s=e(t,r,o);s&&i.push({node:s,annotation:t})}),Gr(i)}(F?hs({annotations:t,context:r,..."object"==typeof F?F:{}}):t,i,E,r)},[$,F,E,n,o,O,N,W,l,j,Y,U]),ot=function(t){const e=ds(t?bs:ws,t?xs:ks,t?xs:ks);return t?e.positions.get(t)??null:null}(X);return Oi(()=>{if(!ot?.locked||!X)return;const t=t=>{"Escape"===t.key&&ms(X)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[ot?.locked,X]),c||b||v||C||T||nt&&nt.length>0||x||V||ot?Ds("svg",{role:"img",width:i,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[zs("title",{children:"string"==typeof b?b:"XY Chart"}),zs("desc",{children:"string"==typeof b?b+" (XY data visualization)":"XY data visualization"}),Ds("g",{transform:`translate(${a.left},${a.top})`,children:[x&&l&&(!G||q)&&(()=>{const t=Ps(u?.find(t=>"bottom"===t.orient)?.gridStyle),e=Ps(u?.find(t=>"left"===t.orient)?.gridStyle);return Ds("g",{className:"stream-grid",children:[K.map((e,n)=>zs("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:t},"xgrid-"+n)),Z.map((t,o)=>zs("line",{x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"ygrid-"+o))]})})(),c&&l&&(()=>{const t=u?.find(t=>"left"===t.orient),e=u?.find(t=>"bottom"===t.orient),i=!t||!1!==t.baseline,r=!e||!1!==e.baseline,s=t?.jaggedBase||!1,l=e?.jaggedBase||!1,c=e?.landmarkTicks,p=t?.landmarkTicks,y="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",x=!!e?.autoRotate&&K.length>1&&(()=>{const t=n/Math.max(K.length-1,1);return K.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8>t})(),b=x?12:18,v=o+(x?58:40),w={fontSize:"var(--semiotic-tick-font-size, 12px)"},k={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},S={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},A=e?.tickAnchor,M=t?.tickAnchor,_=_s(K),P=_s(Z);return Ds("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[Ds("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!G||q)&&r&&!l&&zs("line",{x1:0,y1:o,x2:n,y2:o,stroke:y,strokeWidth:1}),(!G||q)&&l&&zs("path",{d:Cs("bottom",n,o),fill:"none",stroke:y,strokeWidth:1}),K.map((t,e)=>{const n=!!c&&("function"==typeof c?c(t.value,e):Ro(t.value,e>0?K[e-1].value:void 0));return Ds("g",{transform:`translate(${t.pixel},${o})`,children:[zs("line",{y2:5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?zs("text",{y:b,textAnchor:x?"end":As(A,t.pixel===_.min,t.pixel===_.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?k:w},transform:x?"rotate(-45)":void 0,children:t.label}):zs("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:zs("div",{style:{textAlign:"center",userSelect:"none",...w},children:t.label})})]},"xtick-"+e)}),h&&zs("text",{x:n/2,y:v,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:h})]}),Ds("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!G||q)&&i&&!s&&zs("line",{x1:0,y1:0,x2:0,y2:o,stroke:y,strokeWidth:1}),(!G||q)&&s&&zs("path",{d:Cs("left",n,o),fill:"none",stroke:y,strokeWidth:1}),Z.map((t,e)=>{const n=!!p&&("function"==typeof p?p(t.value,e):Ro(t.value,e>0?Z[e-1].value:void 0));return Ds("g",{transform:`translate(0,${t.pixel})`,children:[zs("line",{x2:-5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?zs("text",{x:-8,textAnchor:"end",dominantBaseline:Ms(M,t.pixel===P.min,t.pixel===P.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?k:w},children:t.label}):zs("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:zs("div",{style:{textAlign:"right",userSelect:"none",...w},children:t.label})})]},"ytick-"+e)}),(()=>{const e=t?.label||d;return e?zs("text",{x:15-a.left,y:o/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-a.left}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:e}):null})()]}),(()=>{const t=u?.find(t=>"right"===t.orient);if(!t||0===Q.length)return null;const e=!1!==t.baseline,i=t.landmarkTicks,r=t.label||f,s=t.tickAnchor,l=_s(Q);return Ds("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[e&&zs("line",{x1:n,y1:0,x2:n,y2:o,stroke:y,strokeWidth:1}),Q.map((t,e)=>{const o=!!i&&("function"==typeof i?i(t.value,e):Ro(t.value,e>0?Q[e-1].value:void 0));return Ds("g",{transform:`translate(${n},${t.pixel})`,children:[zs("line",{x2:5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?zs("text",{x:8,textAnchor:"start",dominantBaseline:Ms(s,t.pixel===l.min,t.pixel===l.max),fontWeight:o?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...o?k:w},children:t.label}):zs("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:zs("div",{style:{textAlign:"left",userSelect:"none",...w},children:t.label})})]},"ytick-r-"+e)}),r&&zs("text",{x:n+a.right-15,y:o/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${n+a.right-15}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:r})]})})()]})})(),nt,T&&l&&L&&R&&Ds($s,{children:[T.top&&zs("g",{transform:"translate(0, 0)",children:zs(lr,{orient:"top",config:ar(T.top),values:L,scale:l.x,size:a.top,length:n})}),T.bottom&&zs("g",{transform:`translate(0, ${o})`,children:zs(lr,{orient:"bottom",config:ar(T.bottom),values:L,scale:l.x,size:a.bottom,length:n})}),T.left&&zs("g",{transform:"translate(0, 0)",children:zs(lr,{orient:"left",config:ar(T.left),values:R,scale:l.y,size:a.left,length:o})}),T.right&&zs("g",{transform:`translate(${n}, 0)`,children:zs(lr,{orient:"right",config:ar(T.right),values:R,scale:l.y,size:a.right,length:o})})]}),C,ot&&ot.sourceId!==H&&l?.x&&(()=>{const t=l.x(ot.xValue);if(null==t||0>t||t>n)return null;const e=ot.locked;return zs("line",{x1:t,y1:0,x2:t,y2:o,stroke:e?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:e?1.5:1,strokeDasharray:e?"6,3":"4,4",pointerEvents:"none"})})(),V]}),b&&"string"==typeof b?zs("text",{x:i/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:b}):b?zs("foreignObject",{x:0,y:0,width:i,height:a.top,children:b}):null,nr({legend:v,totalWidth:i,totalHeight:r,margin:a,legendPosition:_,title:b,legendLayout:P,legendHoverBehavior:w,legendClickBehavior:k,legendHighlightedCategory:A,legendIsolatedCategories:M})]}):null}import*as Os from"react";import{area as Ns,line as Ws}from"d3-shape";function js(t){return(t.tl??0)>0||(t.tr??0)>0||(t.br??0)>0||(t.bl??0)>0}function Ys(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(t.w,t.h)/2,o=t=>Math.max(0,Math.min(t??0,n));return{tl:o(e.tl),tr:o(e.tr),br:o(e.br),bl:o(e.bl)}}import{jsx as Gs,jsxs as qs}from"react/jsx-runtime";var Xs={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Hs(t,e="#4e79a7"){return Zo(t)?t.background&&"transparent"!==t.background?t.background:e:t&&"string"==typeof t?t:e}function Vs(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function Us(t,e,n,o){const i=t.glyph;if(!i?.parts?.length||0>=t.size)return null;const r=Do(i,t.size);if(0>=r.scale)return null;const s=`translate(${e},${n})${t.rotation?` rotate(${180*t.rotation/Math.PI})`:""} translate(${r.offsetX},${r.offsetY}) scale(${r.scale})`,a=t.color??("string"==typeof t.style.fill?t.style.fill:void 0),l=Eo(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal"),c=l?Vs(o+"-clip"):void 0,u=(t.style.opacity??1)*(t._decayOpacity??1)*(t.style.fillOpacity??1),h=e=>i.parts.map((n,o)=>{const i=e?"none"===n.fill?void 0:e:Io(n.fill,a,t.accent),r=e?n.stroke&&"none"!==n.stroke?e:void 0:Io(n.stroke??"none",a,t.accent);return i||r?Gs("path",{d:n.d,fill:i??"none",stroke:r,strokeWidth:r?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},o):null});return qs("g",{transform:s,opacity:1===u?void 0:u,children:[l&&c&&Gs("clipPath",{id:c,children:Gs("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&t.ghostColor?Gs("g",{children:h(t.ghostColor)}):null,l&&c?Gs("g",{clipPath:`url(#${c})`,children:h()}):h()]},o)}function Ks(t){const e=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));return 2>e.length?null:e.map((t,e)=>Gs("stop",{offset:t.offset,stopColor:t.color},e))}function Zs(t,e,n){const o=dn(t.symbolType,t.size,t.path);return Gs("path",{d:o,transform:t.rotation?`translate(${t.x},${t.y}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.x},${t.y})`,fill:t.style.fill?Hs(t.style.fill):"none",fillOpacity:t.style.fillOpacity,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},`${n??""}symbol-${e}`)}import*as Qs from"react";import{arc as Js}from"d3-shape";import{jsx as ta,jsxs as ea}from"react/jsx-runtime";import*as na from"react";import{jsx as oa,jsxs as ia}from"react/jsx-runtime";import*as ra from"react";import{arc as sa}from"d3-shape";var aa=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function la(t){const{innerRadius:e,outerRadius:n,startAngle:o,endAngle:i}=t,r=0>=e;if(0>=(t.cornerRadius??0)||!t.roundStart&&!t.roundEnd){if(r){const t=aa(n,o),e=aa(n,i);return`M0,0 L${t.x},${t.y} A${n},${n} 0 ${i-o>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=aa(n,o),s=aa(n,i),a=aa(e,i),l=aa(e,o),c=i-o>Math.PI?1:0;return`M${t.x},${t.y} A${n},${n} 0 ${c} 1 ${s.x},${s.y} L${a.x},${a.y} A${e},${e} 0 ${c} 0 ${l.x},${l.y} Z`}const s=Math.max(0,Math.min(t.cornerRadius??0,(n-e)/2));if(0===s)return la({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,n-s))),l=r?0:Math.asin(Math.min(1,s/Math.max(1e-9,e+s))),c=i-o,u=t.roundStart&&t.roundEnd?c/2:c,h=!!t.roundStart&&u>a,d=!!t.roundEnd&&u>a;if(!h&&!d)return la({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=o+(h?a:0),p=i-(d?a:0),y=o+(h?l:0),g=i-(d?l:0),m=aa(n,f),x=aa(n,p),b=(n-s)*Math.cos(a),v=aa(b,o),w=aa(b,i),k=r?null:aa(e,g),S=r?null:aa(e,y),A=r?0:(e+s)*Math.cos(l),M=r?null:aa(A,o),_=r?null:aa(A,i),P=p-f>Math.PI?1:0,C=r?0:g-y>Math.PI?1:0;let T="";if(h)T+=`M${v.x},${v.y}`,T+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const t=aa(n,o);T+=`M${t.x},${t.y}`}if(d)T+=` A${n},${n} 0 ${P} 1 ${x.x},${x.y}`,T+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const t=aa(n,i);T+=` A${n},${n} 0 ${P} 1 ${t.x},${t.y}`}if(r)T+=" L0,0";else{if(d)T+=` L${_.x},${_.y}`,T+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const t=aa(e,i);T+=` L${t.x},${t.y}`}if(h)T+=` A${e},${e} 0 ${C} 0 ${S.x},${S.y}`,T+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const t=aa(e,o);T+=` A${e},${e} 0 ${C} 0 ${t.x},${t.y}`}}return T+=" Z",T}import{jsx as ca,jsxs as ua}from"react/jsx-runtime";function ha(t){return 1e6>t?1e4>t?1e3>t?t+"":(t/1e3).toFixed(1)+"K":(t/1e3).toFixed(0)+"K":(t/1e6).toFixed(1)+"M"}function da(t,e){const n=t.datum;if(!n)return null;const o=[],i=n.__funnelStepLabel,r=Number(n.__funnelStepLabelX),s=Number(n.__funnelStepLabelY),a=Number(n.__funnelRowWidth);"string"!=typeof i||!Number.isFinite(r)||!Number.isFinite(s)||Number.isFinite(a)&&8.4*i.length+16>a||o.push(ca("text",{x:r,y:s+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:i},e+"-funnel-step"));const l=Number(n.__funnelValue),c=Number(n.__funnelValueLabelX),u=Number(n.__funnelValueLabelY),h=Number(n.__funnelBarW);if(Number.isFinite(l)&&0!==l&&Number.isFinite(c)&&Number.isFinite(u)&&h>=60){const t=Number(n.__funnelPercent);let i=!0!==n.__funnelIsFirstStep&&Number.isFinite(t)?`${ha(l)} (${.05>Math.abs(t-Math.round(t))?Math.round(t):t.toFixed(1)}%)`:ha(l);7.8*i.length+16>h&&(i=ha(l)),7.8*i.length+16>h||o.push(ca("text",{x:c,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:i},e+"-funnel-value"))}return o.length?ca("g",{children:o},e+"-funnel-labels"):null}function fa(t,e,n){const o=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",i=n=>`ord-${t.type}-${o}-${e}-${n}`,r=`ord-${t.type}-${o}-${e}`;switch(t.type){case"rect":{const e=t,n=Vs(r)+"-grad",o=function(t,e){const n=t.fillGradient;if(!n||"object"!=typeof n)return null;let o=t.x,i=t.y,r=t.x,s=t.y+t.h;"bottom"===t.roundedEdge?(i=t.y+t.h,s=t.y):"right"===t.roundedEdge?(o=t.x+t.w,i=t.y,r=t.x,s=t.y):"left"===t.roundedEdge&&(o=t.x,i=t.y,r=t.x+t.w,s=t.y);const a=[];if("colorStops"in n){const t=Ks(n.colorStops);if(!t)return null;a.push(...t)}else{const e=Hs(t.style.fill);a.push(Gs("stop",{offset:0,stopColor:e,stopOpacity:n.topOpacity},"0")),a.push(Gs("stop",{offset:1,stopColor:e,stopOpacity:n.bottomOpacity},"1"))}return Gs("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:o,y1:i,x2:r,y2:s,children:a})}(e,n);let i,s;if(o)s=`url(#${n})`;else if(Zo(e.style.fill)){const t=Vs(r)+"-hatch";i=ti(e.style.fill,t),s=`url(#${t})`}else s=Hs(e.style.fill);const a=o||i?ua("defs",{children:[o,i]}):null;if(e.cornerRadii&&js(e.cornerRadii)){const t=function(t){const{x:e,y:n,w:o,h:i}=t,{tl:r,tr:s,br:a,bl:l}=Ys(t);let c=`M${e+r},${n}`;return c+=` L${e+o-s},${n}`,s>0&&(c+=` A${s},${s} 0 0 1 ${e+o},${n+s}`),c+=` L${e+o},${n+i-a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${e+o-a},${n+i}`),c+=` L${e+l},${n+i}`,l>0&&(c+=` A${l},${l} 0 0 1 ${e},${n+i-l}`),c+=` L${e},${n+r}`,r>0&&(c+=` A${r},${r} 0 0 1 ${e+r},${n}`),c+=" Z",c}(e);return ua(ra.Fragment,{children:[a,ca("path",{d:t,fill:s,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}if(e.roundedTop&&e.roundedTop>0){const t=Math.min(e.roundedTop,e.w/2,e.h/2),{x:n,y:o,w:i,h:l}=e;let c;switch(e.roundedEdge){case"right":c=`M${n},${o} L${n+i-t},${o} A${t},${t} 0 0 1 ${n+i},${o+t} L${n+i},${o+l-t} A${t},${t} 0 0 1 ${n+i-t},${o+l} L${n},${o+l} Z`;break;case"left":c=`M${n+i},${o} L${n+t},${o} A${t},${t} 0 0 0 ${n},${o+t} L${n},${o+l-t} A${t},${t} 0 0 0 ${n+t},${o+l} L${n+i},${o+l} Z`;break;case"bottom":c=`M${n},${o} L${n+i},${o} L${n+i},${o+l-t} A${t},${t} 0 0 1 ${n+i-t},${o+l} L${n+t},${o+l} A${t},${t} 0 0 1 ${n},${o+l-t} Z`;break;default:c=`M${n},${o+l} L${n},${o+t} A${t},${t} 0 0 1 ${n+t},${o} L${n+i-t},${o} A${t},${t} 0 0 1 ${n+i},${o+t} L${n+i},${o+l} Z`}return ua(ra.Fragment,{children:[a,ca("path",{d:c,fill:s,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},r)}return ua(ra.Fragment,{children:[a,ca("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:s,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth}),da(e,r)]},r)}case"point":{const e=t;return ca("circle",{cx:e.x,cy:e.y,r:e.r,fill:Hs(e.style.fill),opacity:e.style.opacity??e.style.fillOpacity??.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}case"symbol":return Zs(t,e,n);case"glyph":return Us(t,t.x,t.y,`${n??""}ord-glyph-${t.pointId??e}`);case"wedge":{const o=t;if(o._gradientBand&&o._gradientBand.colors.length>0){const t=Vs(`${n?n+"-":""}gauge-grad-${o.category||r}-${e}`),{clipPath:i,slices:s}=function(t){const e=la({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),n=[],o=t.colors;if(o.length>0){const e=(t.endAngle-t.startAngle)/o.length;for(let i=0;o.length>i;i++)n.push({d:la({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+i*e,endAngle:t.endAngle}),color:o[i]})}return{clipPath:e,slices:n}}({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds?.start??!0,roundEnd:o.roundedEnds?.end??!0,colors:o._gradientBand.colors});return ua("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[ca("defs",{children:ca("clipPath",{id:t,children:ca("path",{d:i})})}),ca("g",{clipPath:`url(#${t})`,children:s.map((t,e)=>ca("path",{d:t.d,fill:Hs(t.color)},e))}),o.style.stroke&&"none"!==o.style.stroke&&ca("path",{d:i,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},r)}let i;if(o.roundedEnds)i=la({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{const t=sa().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&t.cornerRadius(o.cornerRadius),i=t(Xs)||""}return ca("path",{d:i,transform:`translate(${o.cx},${o.cy})`,fill:Hs(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},r)}case"boxplot":{const e=t,n=e.columnWidth/2;return ua("g","vertical"===e.projection?{children:[ca("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1}),ca("rect",{x:e.x-n,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:Hs(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:1}),ca("line",{x1:e.x-n,y1:e.medianPos,x2:e.x+n,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2}),ca("line",{x1:e.x-.5*n,y1:e.minPos,x2:e.x+.5*n,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:1}),ca("line",{x1:e.x-.5*n,y1:e.maxPos,x2:e.x+.5*n,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1})]}:{children:[ca("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:1}),ca("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-n,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:Hs(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:1}),ca("line",{x1:e.medianPos,y1:e.y-n,x2:e.medianPos,y2:e.y+n,stroke:e.style.stroke||"#333",strokeWidth:2}),ca("line",{x1:e.minPos,y1:e.y-.5*n,x2:e.minPos,y2:e.y+.5*n,stroke:e.style.stroke||"#333",strokeWidth:1}),ca("line",{x1:e.maxPos,y1:e.y-.5*n,x2:e.maxPos,y2:e.y+.5*n,stroke:e.style.stroke||"#333",strokeWidth:1})]},r)}case"violin":{const e=t,n=[ca("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:Hs(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1},i("path"))];if(e.iqrLine&&e.bounds){const t=e.bounds,o=t.x+t.width/2,r=t.y+t.height/2;e.iqrLine.isVertical?n.push(ca("line",{x1:o,y1:e.iqrLine.q1Pos,x2:o,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},i("iqr")),ca("circle",{cx:o,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},i("med"))):n.push(ca("line",{x1:e.iqrLine.q1Pos,y1:r,x2:e.iqrLine.q3Pos,y2:r,stroke:e.style.stroke||"#333",strokeWidth:2},i("iqr")),ca("circle",{cx:e.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},i("med")))}return ca("g",{children:n},r)}case"connector":return ca("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity??.5},r);case"trapezoid":{const e=t,n=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return ca("polygon",{points:n,fill:Hs(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},r)}default:return null}}import{jsx as pa,jsxs as ya}from"react/jsx-runtime";function ga(t,e,n){if(!t||2>e.length)return null;const o=Ks(t.colorStops);return o?pa("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:e[0][0],y1:0,x2:e[e.length-1][0],y2:0,children:o}):null}function ma(t,e,n){switch(t.type){case"line":{const o=t;if(0===o.path.length)return null;const i=hi(o.curve),r=i?Ws().x(([t])=>t).y(([,t])=>t).curve(i)(o.path)??"":"M"+o.path.map(([t,e])=>`${t},${e}`).join("L"),s=Vs(`${n?n+"-":""}line-${e}-stroke-gradient`),a=ga(o.strokeGradient,o.path,s);return ya(Os.Fragment,{children:[a&&pa("defs",{children:a}),pa("path",{d:r,fill:"none",stroke:a?`url(#${s})`:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity})]},"line-"+e)}case"area":{const o=t;if(0===o.topPath.length)return null;const i=hi(o.curve),r=!i||2>o.topPath.length||2>o.bottomPath.length?`M${o.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`:Ns().x(([t])=>t).y0((t,e)=>o.bottomPath[e][1]).y1(([,t])=>t).curve(i)(o.topPath)??"",s=`${n?n+"-":""}area-${e}-hatch`,a=Zo(o.style.fill)?ti(o.style.fill,s):void 0,l=Vs(`${n?n+"-":""}area-${e}-gradient`),c=function(t,e){const n=t.fillGradient;if(!n||"object"!=typeof n)return null;let o=1/0;for(const[,e]of t.topPath)o=Math.min(o,e);let i=-1/0;for(const[,e]of t.bottomPath)i=Math.max(i,e);if(!Number.isFinite(o)||!Number.isFinite(i))return null;const r=[];if("colorStops"in n){const t=Ks(n.colorStops);if(!t)return null;r.push(...t)}else{if(!Number.isFinite(n.topOpacity)||!Number.isFinite(n.bottomOpacity))return null;r.push(pa("stop",{offset:0,stopColor:Hs(t.style.fill),stopOpacity:Math.max(0,Math.min(1,n.topOpacity))},"0")),r.push(pa("stop",{offset:1,stopColor:Hs(t.style.fill),stopOpacity:Math.max(0,Math.min(1,n.bottomOpacity))},"1"))}return pa("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:0,y1:o,x2:0,y2:i,children:r})}(o,l),u=c?`url(#${l})`:a?`url(#${s})`:Hs(o.style.fill),h=c?void 0:o.style.fillOpacity??o.style.opacity??.7,d=i?Ws().x(([t])=>t).y(([,t])=>t).curve(i)(o.topPath)??"":"M"+o.topPath.map(([t,e])=>`${t},${e}`).join("L"),f=Vs(`${n?n+"-":""}area-${e}-stroke-gradient`),p=ga(o.strokeGradient,o.topPath,f),y=o.style.stroke&&"none"!==o.style.stroke?pa("path",{d:d,fill:"none",stroke:p?`url(#${f})`:Hs(o.style.stroke),strokeWidth:o.style.strokeWidth||2,opacity:o.style.opacity}):null;if(o.clipRect){const t=`${n?n+"-":""}area-clip-${e}`;return ya("g",{children:[ya("defs",{children:[c,!c&&a,p,pa("clipPath",{id:t,children:pa("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),ya("g",{clipPath:`url(#${t})`,children:[pa("path",{d:r,fill:u,fillOpacity:h,opacity:c?o.style.opacity:void 0,stroke:"none"}),y]})]},"area-"+e)}return ya(Os.Fragment,{children:[(c||a||p)&&ya("defs",{children:[c,!c&&a,p]}),pa("path",{d:r,fill:u,fillOpacity:h,opacity:c?o.style.opacity:void 0,stroke:"none"}),y]},"area-"+e)}case"point":{const o=t,i=`${n?n+"-":""}point-${e}-hatch`,r=Zo(o.style.fill)?ti(o.style.fill,i):void 0;return ya(Os.Fragment,{children:[r&&pa("defs",{children:r}),pa("circle",{cx:o.x,cy:o.y,r:o.r,fill:r?`url(#${i})`:Hs(o.style.fill),opacity:o.style.opacity??o.style.fillOpacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"point-"+e)}case"symbol":return Zs(t,e);case"glyph":return Us(t,t.x,t.y,`${n??""}glyph-${t.pointId??e}`);case"rect":{const o=t,i=`${n?n+"-":""}xyrect-${e}-hatch`,r=Zo(o.style.fill)?ti(o.style.fill,i):void 0;return ya(Os.Fragment,{children:[r&&pa("defs",{children:r}),pa("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:r?`url(#${i})`:Hs(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"rect-"+e)}case"heatcell":{const n=t;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const t=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[o,i,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(n.fill),s=.299*o+.587*i+.114*r>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return ya("g",{children:[pa("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill,stroke:n.style?.stroke,strokeWidth:n.style?.strokeWidth}),pa("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:t})]},"heatcell-"+e)}return pa("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill,stroke:n.style?.stroke,strokeWidth:n.style?.strokeWidth},"heatcell-"+e)}case"candlestick":{const n=t;if(n.isRange){const t=n.dotRadius??Math.max(2,n.bodyWidth/2);return ya("g",{children:[pa("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),pa("circle",{cx:n.x,cy:n.highY,r:t,fill:n.wickColor}),pa("circle",{cx:n.x,cy:n.lowY,r:t,fill:n.wickColor})]},"candle-"+e)}const o=Math.min(n.openY,n.closeY),i=Math.max(Math.abs(n.openY-n.closeY),1),r=n.isUp?n.upColor:n.downColor;return ya("g",{children:[pa("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),pa("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:i,fill:r,stroke:r,strokeWidth:1})]},"candle-"+e)}default:return null}}var xa="undefined"==typeof window||"undefined"==typeof document;import{useEffect as ba,useLayoutEffect as va,useRef as wa,useState as ka,useSyncExternalStore as Sa}from"react";var Aa="undefined"!=typeof window?va:ba,Ma=()=>()=>{},_a=()=>!1,Pa=()=>!0;import{useRef as Ca}from"react";function Ta(t,e){const n=Object.keys(t),o=Object.keys(e);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))return!1;if(!Object.is(t[o],e[o]))return!1}return!0}function La(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(!Object.is(t[n],e[n]))return!1;return!0}function Ra(t){if(null===t||"object"!=typeof t)return!1;if(Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function $a(t){const{background:e,hasBackgroundGraphics:n=!1,themeBackground:o=""}=t;return"transparent"===e||n?null:e||(o&&"transparent"!==o?o:"")||null}var za={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff",background:""};function Da(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],o=n[2],i=n[3];return`#${t}${t}${o}${o}${i}${i}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}import*as Ia from"react";import*as Ba from"react";import{jsx as Fa}from"react/jsx-runtime";var Ea=Ba.createContext(null);import{jsx as Oa}from"react/jsx-runtime";var Na={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Wa({hoverPoint:t}){let e="";if(t){const n=t.data||t;e="object"==typeof n?"Data point: "+Object.entries(n).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Data point: "+n}return Oa("div",{"aria-live":"polite","aria-atomic":"true",style:Na,children:e})}function ja(t){const e={};if(null==t||"object"!=typeof t)return e;for(const[n,o]of Object.entries(t))n.startsWith("_")||null!=o&&""!==o&&("number"==typeof o?Number.isFinite(o)&&(e[n]=o):"string"==typeof o?e[n]=o:"boolean"==typeof o?e[n]=o+"":o instanceof Date&&(e[n]=o.toISOString().slice(0,10)));return e}function Ya(t){return t&&"object"==typeof t?t:{}}function Ga(t){return Ya(t.accessibility).tableFields??t.accessibleDatum??t.datum}import{jsx as qa,jsxs as Xa}from"react/jsx-runtime";function Ha(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t){if(null===e?.datum)continue;const t=e.type+"";n[t]=(n[t]||0)+1}if(0===Object.keys(n).length)return e+", empty";const o=[],i={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},r=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((t,e)=>{const n=r.indexOf(t),o=r.indexOf(e);return(-1===n?999:n)-(-1===o?999:o)});for(const t of s)o.push(`${n[t]} ${i[t]||t}`);return`${e}, ${o.join(", ")}`}var Va=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},Ua="semiotic-accessible-data-table",Ka=Ua+" semiotic-accessible-data-table-hidden",Za=Ua+" semiotic-accessible-data-table-visible",Qa={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Ja={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},tl={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},el={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},nl={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},ol={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},il={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},rl={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function sl({scene:t,chartType:e,tableId:n,chartTitle:o}){const[i,r]=Ia.useState(!1),[s,a]=Ia.useState(5),l=Ba.useContext(Ea),c=l?.visible??!1,u=i||c,h=Ia.useRef(null),d=o?"Data summary for "+o:n?`Data summary for ${e} ${n}`:"Data summary for "+e;Ia.useEffect(()=>{u||a(5)},[u]);const f=Ia.useCallback(t=>{t.target===t.currentTarget&&(i||c||r(!0))},[i,c]),p=Ia.useCallback(t=>{c||h.current?.contains(t.relatedTarget)||r(!1)},[c]);if(!t||0===t.length)return n?qa("span",{id:n,tabIndex:-1,style:Na}):null;if(!u)return qa("div",{id:n,className:Ka,tabIndex:-1,onFocus:f,style:Na,role:"region","aria-label":d,children:Xa("button",{type:"button",onClick:()=>r(!0),children:["View data summary (",t.length," elements)"]})});const y=function(t){const e=[];if(!Array.isArray(t))return e;const n=t.some(t=>t&&("line"===t.type||"area"===t.type));for(const o of t)if(o&&"object"==typeof o&&null!==o.datum)try{switch(o.type){case"point":if(n)break;e.push({label:"Point",values:ja(Ga(o))});break;case"line":case"area":{const t=Ga(o),n=Array.isArray(t)?t:[],i="line"===o.type?"Line point":"Area point";for(const t of n)e.push({label:i,values:ja(t)});break}case"rect":{const t=Ga(o),n=null!=t&&"object"==typeof t?t:{},i=n.category??o.group??"",r=n.value??n.__aggregateValue??n.total,s=ja(n);null==s.category&&""!==i&&(s.category=i+""),null==s.value&&null!=r&&(s.value="number"==typeof r||"string"==typeof r?r:r+""),e.push({label:"Bar",values:s});break}case"heatcell":{const t=ja(Ga(o));null==t.value&&"number"==typeof o.value&&Number.isFinite(o.value)&&(t.value=o.value),e.push({label:"Cell",values:t});break}case"wedge":{const t=Ga(o),n=ja(t);if(null==n.category){const e=Ya(t),o=e.category??e.label;null!=o&&(n.category=o+"")}e.push({label:"Wedge",values:n});break}case"circle":e.push({label:"Node",values:ja(Ga(o))});break;case"arc":e.push({label:"Arc",values:ja(Ga(o))});break;case"candlestick":e.push({label:"Candlestick",values:ja(Ga(o))});break;case"geoarea":{const t=Ya(Ga(o)),n=ja(t);if(null==n.name){const e=Ya(t.properties).name??t.name;null!=e&&(n.name=e+"")}e.push({label:"Region",values:n});break}}}catch{}return e}(t),g=function(t){if(!t||0===t.length)return[];const e=new Set;for(const n of t)if(n&&n.values)for(const t of Object.keys(n.values))e.add(t);const n=[];for(const o of e){const e=[],i=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[o];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&i.add(t+""))}if(e.length>0){let t=e[0],i=e[0],r=0;for(const n of e)t>n&&(t=n),n>i&&(i=n),r+=n;n.push({name:o,count:e.length,numeric:!0,min:t,max:i,mean:r/e.length})}else if(i.size>0){const t=Array.from(i);n.push({name:o,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(y),m=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${Va(t.min)} to ${Va(t.max)}, mean ${Va(t.mean)}.`);else{const e=t.uniqueValues,o=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${o}.`)}return n.join(" ")}(y.length,g),x=Math.min(s,y.length),b=y.slice(0,x),v=y.length-x,w=new Set;for(const t of b)for(const e of Object.keys(t.values))w.add(e);const k=Array.from(w);return Xa("div",{ref:h,id:n,className:Za,tabIndex:-1,onBlur:p,style:Qa,role:"region","aria-label":d,children:[qa("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{c&&l&&l.setVisible(!1),r(!1)},"aria-label":"Close data summary",style:tl,children:"×"}),qa("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Ja,children:m}),Xa("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+e,style:el,children:[qa("caption",{className:"semiotic-accessible-data-table-caption",style:il,children:v>0?`First ${x} of ${y.length} data points`:`All ${y.length} data points`}),qa("thead",{children:Xa("tr",{children:[qa("th",{style:nl,children:"type"}),k.map(t=>qa("th",{style:nl,children:t},t))]})}),qa("tbody",{children:b.map((t,e)=>Xa("tr",{children:[qa("td",{style:ol,children:t.label}),k.map(e=>{return qa("td",{style:ol,children:(n=t.values[e],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Va(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},e);var n})]},e))})]}),v>0&&Xa("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(t=>t+25),style:rl,children:["Show ",Math.min(25,v)," more"," ",1===v?"row":"rows"," (",v," remaining)"]})]})}function al({summary:t}){return t?qa("div",{role:"note",style:Na,children:t}):null}function ll({tableId:t}){return qa("a",{href:"#"+t,style:Na,onClick:e=>{e.preventDefault();const n=document.getElementById(t);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,Na)},children:"Skip to data table"})}import{jsx as cl}from"react/jsx-runtime";var ul="var(--semiotic-focus, #005fcc)";function hl({active:t,hoverPoint:e,margin:n,size:o,shape:i="circle",width:r,height:s,pathData:a}){if(!t||!e)return null;const l=e.x+n.left,c=e.y+n.top;let u;if("geoarea"!==i&&"path"!==i||!a)if("rect"===i&&null!=r&&null!=s){const t=Math.max(r,4),e=Math.max(s,4);u=cl("rect",{x:l-t/2-3,y:c-e/2-3,width:t+6,height:e+6,rx:3,fill:"none",stroke:ul,strokeWidth:2,strokeDasharray:"4,2"})}else u=cl("circle","wedge"===i?{cx:l,cy:c,r:12,fill:"none",stroke:ul,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:ul,strokeWidth:2,strokeDasharray:"4,2"});else u=cl("g",{transform:`translate(${n.left},${n.top})`,children:cl("path",{d:a,fill:"none",stroke:ul,strokeWidth:2.5,strokeDasharray:"6,3"})});return cl("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}import*as dl from"react";import{jsx as fl}from"react/jsx-runtime";function pl({x:t,y:e,containerWidth:n,containerHeight:o,margin:i,children:r,className:s="stream-frame-tooltip",zIndex:a=1}){const l=Number.isFinite(t)&&Number.isFinite(e),c=dl.useRef(null),[u,h]=dl.useState(null);dl.useLayoutEffect(()=>{const t=c.current;if(!t)return;const e=()=>{const e=t.getBoundingClientRect();Number.isFinite(e.width)&&Number.isFinite(e.height)&&h(t=>t&&.5>Math.abs(t.width-e.width)&&.5>Math.abs(t.height-e.height)?t:{width:e.width,height:e.height})};if(e(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(e);return n.observe(t),()=>n.disconnect()},[s,n,o,l]);let d;d=u?`translate(${u.width+12>n-t?"calc(-100% - 12px)":"12px"}, ${u.height+12>o-e?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*o>e?"4px":"calc(-100% - 4px)"})`;const f=function(t){if(!dl.isValidElement(t))return!1;const e=t.type;if("string"!=typeof e&&e&&!0===e.ownsChrome)return!0;const n=t.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const o=n.style;if(o&&"object"==typeof o){if(null!=o.background&&""!==o.background&&"transparent"!==o.background)return!0;if(null!=o.backgroundColor&&""!==o.backgroundColor&&"transparent"!==o.backgroundColor)return!0}return!1}(r),p=f?null:Ut;return l?fl("div",{ref:c,className:f?s:(s+" semiotic-tooltip").trim(),style:{...p||{},position:"absolute",left:i.left+t,top:i.top+e,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"},children:r}):null}import*as yl from"react";import{useCallback as gl,useEffect as ml,useLayoutEffect as xl,useMemo as bl,useRef as vl}from"react";import{useState as wl,useEffect as kl}from"react";import{useRef as Sl,useState as Al,useEffect as Ml}from"react";var _l=()=>"undefined"!=typeof performance?performance.now():Date.now();function Pl(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}function Cl(t,e){const n=t();return Number.isFinite(n)?n:e}var Tl=class{constructor(t={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=t.clock??_l,this.lastWallTime=Cl(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===t.paused,this.visibleValue=!1!==t.visible,this.setRandomSource(t.random,t.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(t){this.setClock(t.clock),this.setRandomSource(t.random,t.seed)}setPaused(t){this.pausedValue!==t&&(this.advance(),this.pausedValue=t,this.emit())}setVisible(t){this.visibleValue!==t&&(this.advance(),this.visibleValue=t,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}advance(){const t=Cl(this.clock,this.lastWallTime),e=Math.max(0,t-this.lastWallTime);return this.lastWallTime=t,this.isActive&&(this.logicalTime+=e),this.logicalTime}emit(){for(const t of this.subscribers)t()}setClock(t){const e=t??_l;e!==this.clock&&(this.advance(),this.clock=e,this.lastWallTime=Cl(e,this.lastWallTime))}setRandomSource(t,e){const n=function(t){return"number"==typeof t&&Number.isFinite(t)?Math.trunc(t):void 0}(e);t===this.randomInput&&n===this.seedValue||(this.randomInput=t,this.seedValue=n,this.randomSource=t??(void 0===n?Math.random:Pl(n)))}},Ll="undefined"==typeof window?ml:xl,Rl={requestAnimationFrame:t=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(t),cancelAnimationFrame:t=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(t)};function $l(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function zl(t){const e=function(){const[t,e]=wl(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return kl(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(t.matches),function(t,e){if("function"==typeof t.addEventListener)return t.addEventListener("change",e),()=>t.removeEventListener("change",e);const n=t;return n.addListener(e),()=>n.removeListener(e)}(t,t=>e(t.matches))},[]),t}(),n=vl(e);n.current=e;const[o,i]=function(t,e,n){const o=Sl(null),[i,r]=Al(null);return Ml(()=>{if(!e&&!n)return;const t=o.current;if(!t)return;const i=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;r(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return i.observe(t),()=>i.disconnect()},[e,n]),[o,[e&&i?i.w:t[0],n&&i?i.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),r=!!t.title,s=!!t.legend&&"top"===t.legendPosition,a=bl(()=>Ls({...t.marginDefault,...t.userMargin},r,s),[t.marginDefault,t.userMargin,r,s]),l=i[0]-a.left-a.right,c=i[1]-a.top-a.bottom,u=$l(t.foregroundGraphics,i,a),h=$l(t.backgroundGraphics,i,a),d=$(t=>t.theme),{transition:f,introEnabled:p}=function(t,e){if(!1===t)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:t?!0===t?{duration:300}:{duration:t.duration??300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(n||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),y="semiotic-table-"+yl.useId(),g=vl(null);if(!g.current){const e=!t.suspendWhenHidden||"undefined"==typeof document||!document.hidden;g.current=new Tl({clock:t.clock,random:t.random,seed:t.seed,paused:t.paused,visible:e})}const m=g.current;m.configure({clock:t.clock,random:t.random,seed:t.seed});const x=vl(null),b=vl(t.frameScheduler??Rl);b.current=t.frameScheduler??Rl;const v=vl(null),w=vl(!1),k=vl(()=>{}),S=gl(()=>{if(null!==x.current||w.current)return;const t=b.current;let e=!1,n=!1;const o=t.requestAnimationFrame(()=>{e=!0;const t=!n;t&&(w.current=!0),x.current=null,v.current=null;try{k.current()}finally{t&&(w.current=!1)}});n=!0,e||(x.current=o,v.current=t)},[]),A=gl(()=>{null!==x.current&&((v.current??b.current).cancelAnimationFrame(x.current),x.current=null,v.current=null)},[]);Ll(()=>{m.setPaused(!0===t.paused)},[m,t.paused]),ml(()=>{if(!t.suspendWhenHidden||"undefined"==typeof document)return void m.setVisible(!0);const e=()=>m.setVisible(!document.hidden);return e(),document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[m,t.suspendWhenHidden]),ml(()=>()=>{A()},[A]);const M=vl(()=>{}),_=vl(()=>{}),P=vl(null),C=vl(null),T=vl(null),L=gl(()=>{const t=P.current;P.current=null,t&&M.current(t)},[]),R=gl(t=>{if(P.current={clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType},null===C.current){const t=b.current;let e=!1;const n=t.requestAnimationFrame(()=>{e=!0,C.current=null,T.current=null,L()});e||(C.current=n,T.current=t)}},[L]),z=gl(()=>{P.current=null,null!==C.current&&((T.current??b.current).cancelAnimationFrame(C.current),C.current=null,T.current=null),_.current()},[]);ml(()=>()=>{P.current=null,null!==C.current&&((T.current??b.current).cancelAnimationFrame(C.current),C.current=null,T.current=null)},[]);const D=t.themeDirtyRef;return Ll(()=>{D&&(jo++,D.current=!0,S())},[d,S,D]),{reducedMotion:e,reducedMotionRef:n,responsiveRef:o,size:i,margin:a,adjustedWidth:l,adjustedHeight:c,resolvedForeground:u,resolvedBackground:h,currentTheme:d,transition:f,introEnabled:p,tableId:y,frameRuntime:m,rafRef:x,renderFnRef:k,scheduleRender:S,cancelRender:A,hoverHandlerRef:M,hoverLeaveRef:_,onPointerMove:R,onPointerLeave:z}}import{useEffect as Dl,useRef as Il}from"react";import{jsx as Bl}from"react/jsx-runtime";function Fl({children:t,size:e,margin:n,overflowVisible:o=!1}){return t?Bl("svg",{style:{position:"absolute",left:0,top:0,width:e[0],height:e[1],pointerEvents:"none",overflow:o?"visible":void 0},children:Bl("g",{transform:`translate(${n.left},${n.top})`,children:t})}):null}function El(t,e,n,o){return"function"==typeof t?t({size:e,margin:n,scales:o}):t}function Ol(t,e,n,o){const i=t.getContext("2d");if(!i)return null;const r=Math.round(e[0]*o),s=Math.round(e[1]*o),a=r/e[0],l=s/e[1],c=e[0]+"px",u=e[1]+"px";return t.style.width!==c&&(t.style.width=c),t.style.height!==u&&(t.style.height=u),t.width===r&&t.height===s||(t.width=r,t.height=s),i.setTransform(a,0,0,l,0,0),i.translate(n.left,n.top),i}import{useCallback as Nl,useRef as Wl}from"react";function jl(t,e,n,o){return"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:o,fn:e}:{key:void 0,fn:null}}var Yl=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Gl=3156e7;function ql(t){const e=t[1]-t[0];return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:Gl>e?t=>{const e=new Date(t);return`${Yl[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*Gl>e?t=>{const e=new Date(t);return`${Yl[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}function Xl(t){if(!t)return;const e=[];for(const n of t)if("point"===n.type)e.push(n);else if("symbol"===n.type)e.push({pointId:n.pointId,x:n.x,y:n.y,r:fn(n.size)});else if("glyph"===n.type){const t=Oo(n.glyph,n.size);e.push({pointId:n.pointId,x:n.x+t.centerDx,y:n.y+t.centerDy,r:t.radius})}return e}import{line as Hl}from"d3-shape";function Vl(t,e,n){let o=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(o=n.color):t>n.value&&(o=n.color);return o}function Ul(t,e,n,o,i,r){if(2>e.length)return;const s=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],o=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=o,t.lineCap=r;for(let n=0;e.length-1>n;n++){const o=(s[n]+s[n+1])/2;let r=i;l>o&&(r*=o/l),l>a-o&&(r*=(a-o)/l),t.globalAlpha=Math.max(0,r),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}var Kl=(t,e,n,o)=>{const i=e.filter(t=>"line"===t.type);for(const e of i){if(2>e.path.length)continue;const n=e._introClipFraction;void 0!==n&&1>n&&(t.save(),t.beginPath(),t.rect(0,0,o.width*n,o.height),t.clip());const i=e.style.stroke||"#007bff",r=Xo(t,i)||i,s=e.style.strokeWidth||2,a=e.colorThresholds,l=e.rawValues;if(t.setLineDash(e.style.strokeDasharray?e.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),t.lineWidth=s,t.lineCap=e.style.strokeLinecap||"butt",e.style._edgeFade){Ul(t,e.path,r,s,e.style.opacity??1,e.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const c=hi(e.curve),u=a&&a.length>0&&l&&l.length===e.path.length,h=e._decayOpacities;if(h&&h.length===e.path.length&&!u){t.strokeStyle=r;const n=e.style.opacity??1;for(let o=0;e.path.length-1>o;o++)t.globalAlpha=.5*(h[o]+h[o+1])*n,t.beginPath(),t.moveTo(e.path[o][0],e.path[o][1]),t.lineTo(e.path[o+1][0],e.path[o+1][1]),t.stroke()}else if(u){let n=function(e,n,o){t.beginPath(),t.strokeStyle=e,t.moveTo(n,o),h=!0},o=function(){h&&(t.stroke(),h=!1)},i=null,s=null,c=null,u=null,h=!1;for(let h=0;e.path.length>h;h++){const[d,f]=e.path[h],p=l[h],y=Vl(p,a,r);if(null!==i&&null!==u&&null!==c){if(y===u)t.lineTo(d,f);else{const e=[];for(const t of a){const n=t.value;(c>n||n>p)&&(n>c||p>n)||c===n||p===n||e.push({t:(n-c)/(p-c)})}e.sort((t,e)=>t.t-e.t);for(const l of e){const e=i+(d-i)*l.t,u=s+(f-s)*l.t,h=Vl(c+(p-c)*Math.min(l.t+1e-4,1),a,r);t.lineTo(e,u),o(),n(h,e,u)}t.lineTo(d,f)}i=d,s=f,c=p,u=y}else n(y,d,f),i=d,s=f,c=p,u=y}o()}else{t.beginPath();const n=e.strokeGradient&&e.path.length>=2?pi(t,e.strokeGradient,e.path[0][0],0,e.path[e.path.length-1][0],0):null;if(t.strokeStyle=n||r,c)Hl().x(t=>t[0]).y(t=>t[1]).curve(c).context(t)(e.path);else{const[n,o]=e.path[0];t.moveTo(n,o);for(let n=1;e.path.length>n;n++)t.lineTo(e.path[n][0],e.path[n][1])}t.stroke()}if(e.style.fill&&e.style.fillOpacity&&e.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=e.style.fillOpacity,t.fillStyle=di(t,e.style.fill,e.style.fill),c&&!u)Hl().x(t=>t[0]).y(t=>t[1]).curve(c).context(t)(e.path);else{const[n,o]=e.path[0];t.moveTo(n,o);for(let n=1;e.path.length>n;n++)t.lineTo(e.path[n][0],e.path[n][1])}const n=e.path[0][0];t.lineTo(e.path[e.path.length-1][0],o.height),t.lineTo(n,o.height),t.closePath(),t.fill()}void 0!==n&&1>n&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function Zl(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function Ql(t,e,n=.3){Zl(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function Jl(t,e,n=.6){if(!Zl(e))return;const o=e.r+(e._pulseGlowRadius??4)*e._pulseIntensity,i=e.cx??e.x??0,r=e.cy??e.y??0;t.beginPath(),t.arc(i,r,o,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function tc(t,e,n,o=.35){Zl(e)&&(t.globalAlpha=e._pulseIntensity*o,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",n?t.fill(n):t.fill())}import{area as ec,line as nc}from"d3-shape";function oc(t,e){const n=hi(e.curve);if(!n||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath()}else{const o=ec().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),o(e.topPath)}}var ic=(t,e,n,o)=>{const i=e.filter(t=>"area"===t.type);for(const e of i){if(2>e.topPath.length)continue;let n=!1;e.clipRect&&(t.save(),t.beginPath(),t.rect(e.clipRect.x,e.clipRect.y,e.clipRect.width,e.clipRect.height),t.clip(),n=!0);const i=e._introClipFraction;void 0!==i&&1>i&&(t.save(),t.beginPath(),t.rect(0,0,o.width*i,o.height),t.clip());const r=di(t,e.style.fill,"#4e79a7"),s=e._decayOpacities;if(s&&s.length===e.topPath.length){const n=e.style.fillOpacity??.7;t.fillStyle=r;for(let o=0;e.topPath.length-1>o;o++)t.globalAlpha=.5*(s[o]+s[o+1])*n,t.beginPath(),t.moveTo(e.topPath[o][0],e.topPath[o][1]),t.lineTo(e.topPath[o+1][0],e.topPath[o+1][1]),t.lineTo(e.bottomPath[o+1][0],e.bottomPath[o+1][1]),t.lineTo(e.bottomPath[o][0],e.bottomPath[o][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=Xo(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(s[n]+s[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const a=e.style.opacity??1;if(oc(t,e),e.fillGradient&&("colorStops"in e.fillGradient&&e.fillGradient.colorStops.length>=2||"topOpacity"in e.fillGradient)&&e.fillGradient){let n=1/0;for(const t of e.topPath)n>t[1]&&(n=t[1]);let o=-1/0;for(const t of e.bottomPath)t[1]>o&&(o=t[1]);const i=fi(t,e.fillGradient,"string"==typeof r?r:"#4e79a7",0,n,0,o);t.fillStyle=i||r,t.globalAlpha=a}else t.globalAlpha=(e.style.fillOpacity??.7)*a,t.fillStyle=r;if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(oc(t,e),tc(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=a;const n=e.strokeGradient&&e.topPath.length>=2?pi(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||Xo(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const o=hi(e.curve);if(t.beginPath(),o)nc().x(t=>t[0]).y(t=>t[1]).curve(o).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}void 0!==i&&1>i&&t.restore(),n&&t.restore(),t.globalAlpha=1}},rc=(t,e,n,o)=>{const i=e.filter(t=>"point"===t.type);if(0!==i.length){t.save();try{const e=t.globalAlpha;for(const n of i)t.beginPath(),t.arc(n.x,n.y,n.r,0,2*Math.PI),t.globalAlpha=e*(n.style.opacity??n.style.fillOpacity??1),t.fillStyle=di(t,n.style.fill,"#4e79a7"),t.fill(),n.style.stroke&&(t.strokeStyle=di(t,n.style.stroke,n.style.stroke),t.lineWidth=n.style.strokeWidth||1,t.stroke()),Jl(t,n)}finally{t.restore()}}},sc=new Map;function ac(t){try{if(t.path)return new Path2D(t.path);const e=`${t.symbolType??"circle"}:${Math.round(t.size)}`;let n=sc.get(e);return n||(n=new Path2D(dn(t.symbolType,t.size)),sc.size>256&&sc.clear(),sc.set(e,n)),n}catch{return null}}var lc=(t,e)=>{const n=t.globalAlpha;for(const o of e){if("symbol"!==o.type)continue;const e=o;if(0>=e.size)continue;const i=ac(e);if(!i)continue;t.save(),t.translate(e.x,e.y),e.rotation&&t.rotate(e.rotation);const r=(e.style.opacity??1)*(e._decayOpacity??1);e.style.fill&&(t.globalAlpha=n*r*(e.style.fillOpacity??1),t.fillStyle=di(t,e.style.fill,"#4e79a7"),t.fill(i)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=n*r,t.strokeStyle=di(t,e.style.stroke,e.style.stroke),t.lineWidth=e.style.strokeWidth??1,t.stroke(i)),t.restore()}t.globalAlpha=n};function cc(t,e,n,o,i){if(0>=e.size)return;const r=e.glyph;if(!r||!r.parts?.length)return;const s=Do(r,e.size);if(0>=s.scale)return;const a=(e.style.opacity??1)*(e._decayOpacity??1);if(0>=a)return;const l=e=>{const n=di(t,e,e);return"string"==typeof n?n:e},c=e.color??("string"==typeof e.style.fill?e.style.fill:void 0);t.save(),t.translate(n,o),e.rotation&&t.rotate(e.rotation),t.translate(s.offsetX,s.offsetY),t.scale(s.scale,s.scale),t.globalAlpha=i*a*(e.style.fillOpacity??1);const u=Eo(r,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal");u&&e.ghostColor&&No(t,r,c,e.accent,e.ghostColor,l),u&&(t.beginPath(),t.rect(u.x,u.y,u.width,u.height),t.clip()),No(t,r,c,e.accent,void 0,l),t.restore()}function uc(t,e){const{x:n,y:o,w:i,h:r}=e,{tl:s,tr:a,br:l,bl:c}=Ys(e);t.beginPath(),t.moveTo(n+s,o),t.lineTo(n+i-a,o),a>0&&t.arcTo(n+i,o,n+i,o+a,a),t.lineTo(n+i,o+r-l),l>0&&t.arcTo(n+i,o+r,n+i-l,o+r,l),t.lineTo(n+c,o+r),c>0&&t.arcTo(n,o+r,n,o+r-c,c),t.lineTo(n,o+s),s>0&&t.arcTo(n,o,n+s,o,s),t.closePath()}function hc(t){switch(t.roundedEdge){case"bottom":return{x0:t.x,y0:t.y+t.h,x1:t.x,y1:t.y};case"right":return{x0:t.x+t.w,y0:t.y,x1:t.x,y1:t.y};case"left":return{x0:t.x,y0:t.y,x1:t.x+t.w,y1:t.y};default:return{x0:t.x,y0:t.y,x1:t.x,y1:t.y+t.h}}}var dc=(t,e,n,o)=>{const i=e.filter(t=>"rect"===t.type);for(const e of i){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)fc(t,e);else if(e.cornerRadii&&js(e.cornerRadii)){const n=di(t,e.style.fill,Xo(t,"var(--semiotic-primary, #007bff)")),o=hc(e),i=e.fillGradient&&"string"==typeof n?fi(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n,uc(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Xo(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const n=di(t,e.style.fill,Xo(t,"var(--semiotic-primary, #007bff)")),o=hc(e),i=e.fillGradient&&"string"==typeof n?fi(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n;const r=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:s,y:a,w:l,h:c}=e;switch(e.roundedEdge){case"right":t.moveTo(s,a),t.lineTo(s+l-r,a),t.arcTo(s+l,a,s+l,a+r,r),t.lineTo(s+l,a+c-r),t.arcTo(s+l,a+c,s+l-r,a+c,r),t.lineTo(s,a+c);break;case"left":t.moveTo(s+l,a),t.lineTo(s+r,a),t.arcTo(s,a,s,a+r,r),t.lineTo(s,a+c-r),t.arcTo(s,a+c,s+r,a+c,r),t.lineTo(s+l,a+c);break;case"bottom":t.moveTo(s,a),t.lineTo(s+l,a),t.lineTo(s+l,a+c-r),t.arcTo(s+l,a+c,s+l-r,a+c,r),t.lineTo(s+r,a+c),t.arcTo(s,a+c,s,a+c-r,r);break;default:t.moveTo(s,a+c),t.lineTo(s,a+r),t.arcTo(s,a,s+r,a,r),t.lineTo(s+l-r,a),t.arcTo(s+l,a,s+l,a+r,r),t.lineTo(s+l,a+c)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Xo(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=di(t,e.style.fill,Xo(t,"var(--semiotic-primary, #007bff)")),o=hc(e),i=e.fillGradient&&"string"==typeof n?fi(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Xo(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}Ql(t,e),t.globalAlpha=1}};function fc(t,e){const n=e.style.icon,o=e.style.iconPadding||2,i=Math.min(e.w,e.h)-o;if(0>=i)return;const r=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),r){const r=i+o,s=e.x+(e.w-i)/2;for(let o=e.y+e.h-i;o>=e.y-i;o-=r)t.drawImage(n,s,o,i,i)}else{const r=i+o,s=e.y+(e.h-i)/2;for(let o=e.x;e.x+e.w>o;o+=r)t.drawImage(n,o,s,i,i)}t.restore()}function pc(t){const[e,n,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*o>128?"#000":"#fff"}function yc(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}var gc=(t,e,n,o)=>{const i=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of i){const n=e.style;null!=n?.opacity&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h);const o=Math.max(0,n?.strokeWidth??1);if(o>0&&(t.strokeStyle=Xo(t,n?.stroke??"var(--semiotic-surface, #fff)"),t.lineWidth=o,t.strokeRect(e.x,e.y,e.w,e.h)),Ql(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const n=e.valueFormat?e.valueFormat(e.value):yc(e.value),o=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),i=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=pc(e.fill),t.font=o+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,i,r)}}}finally{t.restore()}},mc=(t,e,n,o)=>{for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const i=(e._decayOpacity??1)*(e.style?.opacity??1);1!==i&&(t.globalAlpha=i);const r=Xo(t,e.wickColor)||e.wickColor,s=60>o.height,a=s?Math.max(e.wickWidth,2):e.wickWidth,l=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=r,t.lineWidth=a,t.stroke()};if(s||l(),e.isRange){const n=e.dotRadius??Math.max(2,Math.min(e.bodyWidth/2,.12*o.height));t.fillStyle=r,t.beginPath(),t.arc(e.x,e.highY,n,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,n,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const n=Math.min(e.openY,e.closeY),o=Math.abs(e.openY-e.closeY),i=e.isUp?e.upColor:e.downColor,r=Xo(t,i)||i;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(o,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(o,1))}s&&l(),t.restore()}},xc={line:[ic,Kl,rc],area:[ic,rc],stackedarea:[ic,rc],scatter:[rc,lc],bubble:[rc,lc],heatmap:[gc],bar:[dc],swarm:[rc],waterfall:[(t,e,n,o)=>{dc(t,e);const i=e.filter(t=>"rect"===t.type);if(2>i.length)return;const r=i[0].datum,s=r?._connectorStroke;if(s){t.save(),t.strokeStyle=Xo(t,s)||s,t.lineWidth=r?._connectorWidth??1,t.setLineDash([]);for(let e=0;i.length-1>e;e++){const o=i[e],r=i[e+1],s=o.datum,a=r.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const l=n.y(s.cumEnd),c=o.x+o.w,u=r.x;t.beginPath(),t.moveTo(c,l),t.lineTo(u,l),t.stroke()}t.restore()}}],candlestick:[mc],mixed:[ic,Kl,rc],custom:[ic,dc,gc,Kl,rc,lc,(t,e)=>{const n=t.globalAlpha;for(const o of e)"glyph"===o.type&&cc(t,o,o.x,o.y,n);t.globalAlpha=n},mc]},bc=new Set;function vc(t,e){const n="function"==typeof t?t(e.datum??null,e):t;return(o=n)&&"object"==typeof o&&"string"==typeof o.id&&"function"==typeof o.cacheKey&&"function"==typeof o.drawCanvas&&"function"==typeof o.renderStaticSVG?n:void 0;var o}function wc(t,e){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${t}:${e}`;bc.has(n)||(bc.add(n),console.warn(`[Semiotic] Render backend "${t}" does not support scene node "${e}"; using the built-in renderer.`))}function kc(t){const{node:e,index:n,renderMode:o,fallback:i}=t,r=vc(o,e);if(!r)return i();const s=r.renderStaticSVG({node:e,style:e.style??{},key:`${r.id}-${n}`});return null!=s?s:(wc(r.id,e.type??"unknown"),i())}function Sc(t){const e=[];return t.nodes.forEach((n,o)=>{const i=kc({node:n,index:o,renderMode:t.renderMode,fallback:()=>t.fallback(n,o)});null!=i&&!1!==i&&e.push({node:n,element:i})}),e}import{jsx as Ac,jsxs as Mc}from"react/jsx-runtime";function _c(t){return"string"==typeof t?t:"value"}function Pc(t){return null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+""}function Cc(t,e){if(!e)return Pc(t);try{const n=e(t);return null==n?Pc(t):n}catch{return Pc(t)}}function Tc(t,e){return"function"==typeof e?e(t):t[e]}function Lc(t,e){if(!t)return[];const n=[];return(Array.isArray(t)?t:[t]).forEach((t,o)=>{const i="string"==typeof t?.y0Accessor?t.y0Accessor:"low",r="string"==typeof t?.y1Accessor?t.y1Accessor:"high";n.push({label:i,accessor:t=>t.bands?.[o]?.y0??(0===o?t.band?.y0:void 0),format:e}),n.push({label:r,accessor:t=>t.bands?.[o]?.y1??(0===o?t.band?.y1:void 0),format:e})}),n}import{jsx as Rc,jsxs as $c}from"react/jsx-runtime";function zc(t){return null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+""}function Dc({hover:t}){const e=t.data??{},n=e.y??e.value,o=e.x??e.time;if(void 0===n&&void 0===o){const t=Xt(e);if(null!=t.title||t.entries.length>0)return $c("div",{className:"semiotic-tooltip",style:Ut,children:[null!=t.title&&Rc("div",{style:{fontWeight:600,marginBottom:t.entries.length?2:0},children:t.title+""}),t.entries.map(t=>$c("div",{style:{opacity:.7,fontSize:11},children:[t.key,":"," ",Rc("span",{style:{fontWeight:600},children:zc(t.value)})]},t.key))]})}return $c("div",{className:"semiotic-tooltip",style:Ut,children:[Rc("div",{style:{fontWeight:600,marginBottom:2},children:zc(n)}),Rc("div",{style:{opacity:.7,fontSize:11},children:zc(o)})]})}function Ic(t){const{onObservation:e,datum:n,x:o=0,y:i=0,chartType:r,chartId:s,context:a,timestamp:l=Date.now()}=t;e&&(n?(e({type:"hover",datum:n,x:o,y:i,timestamp:l,chartType:r,chartId:s}),"focus"===a?.type&&e({type:"focus",datum:n,inputType:"touch"===a.inputType?"pointer":a.inputType,timestamp:l,chartType:r,chartId:s})):e({type:"hover-end",timestamp:l,chartType:r,chartId:s}))}function Bc(t){const{onObservation:e,datum:n,x:o=0,y:i=0,chartType:r,chartId:s,context:a,timestamp:l=Date.now()}=t;e&&(n?(e({type:"click",datum:n,x:o,y:i,timestamp:l,chartType:r,chartId:s}),"activate"===a?.type&&e({type:"activate",datum:n,inputType:a.inputType,timestamp:l,chartType:r,chartId:s})):e({type:"click-end",timestamp:l,chartType:r,chartId:s}))}Dc.ownsChrome=!0;import{useCallback as Fc}from"react";import{useCallback as Ec,useRef as Oc}from"react";function Nc(t,e,n){const o=t.byGroup.get(e);let i=0,r=Math.abs(o[0].x-n.x);for(let t=1;o.length>t;t++){const e=Math.abs(o[t].x-n.x);r>e&&(r=e,i=t)}return o[i]._flatIndex}function Wc(t){const e=[];for(const n of t)switch(n.type){case"point":e.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;e.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const t=Oo(n.glyph,n.size);e.push({x:n.x+t.centerDx,y:n.y+t.centerDy,datum:n.datum,shape:"rect",w:2*t.halfWidth,h:2*t.halfHeight,group:"_default"});break}case"line":{const t=n,o=Array.isArray(t.datum)?t.datum:[],i=t.group??"_default";for(let n=0;t.path.length>n&&o.length>n;n++)e.push({x:t.path[n][0],y:t.path[n][1],datum:o[n],shape:"circle",group:i});break}case"area":{const t=n,o=Array.isArray(t.datum)?t.datum:[],i=t.group??"_default";for(let n=0;t.topPath.length>n&&o.length>n;n++)e.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:o[n],shape:"circle",group:i});break}case"rect":e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}import{jsx as jc,jsxs as Yc}from"react/jsx-runtime";var Gc={top:20,right:20,bottom:30,left:40},qc=za;function Xc(t){if(t)return"x"===t.dimension?"pan-y":"y"===t.dimension?"pan-x":"none"}var Hc=ye(pe(function(t,e){const{chartType:n,runtimeMode:o,data:i,chunkThreshold:r,chunkSize:s,xAccessor:l,yAccessor:c,accessorRevision:u,colorAccessor:h,sizeAccessor:d,symbolAccessor:f,symbolMap:p,groupAccessor:y,lineDataAccessor:g,curve:m,normalize:x,baseline:b,stackOrder:v,binSize:w,valueAccessor:k,arrowOfTime:S="right",windowMode:M="sliding",windowSize:_=200,timeAccessor:P,xExtent:C,yExtent:T,extentPadding:L=.1,scalePadding:R,sizeRange:$,size:z=[500,300],responsiveWidth:D,responsiveHeight:I,margin:B,className:F,background:E,renderMode:O,lineStyle:N,pointStyle:W,areaStyle:j,barStyle:Y,waterfallStyle:G,swarmStyle:X,barColors:H,colorScheme:V,boundsAccessor:U,boundsStyle:K,y0Accessor:Z,band:Q,gradientFill:J,lineGradient:tt,areaGroups:et,openAccessor:nt,highAccessor:ot,lowAccessor:it,closeAccessor:rt,candlestickStyle:st,showAxes:at=!0,axes:lt,xLabel:ct,yLabel:ut,yLabelRight:ht,xFormat:dt,yFormat:ft,axisExtent:pt,tickFormatTime:yt,tickFormatValue:gt,hoverAnnotation:mt,tooltipContent:xt,customHoverBehavior:bt,customClickBehavior:vt,onObservation:wt,annotationObservationCallback:kt,chartId:St,enableHover:At,hoverRadius:Mt=30,tooltipMode:_t,annotations:Pt,onAnnotationActivate:Ct,autoPlaceAnnotations:Tt,svgAnnotationRules:Lt,showGrid:Rt,legend:$t,legendHoverBehavior:zt,legendClickBehavior:Dt,legendHighlightedCategory:It,legendIsolatedCategories:Bt,legendPosition:Ft,legendLayout:Ot,legendCategoryAccessor:Wt,onCategoriesChange:jt,backgroundGraphics:Yt,foregroundGraphics:Gt,canvasPreRenderers:qt,svgPreRenderers:Xt,title:Ht,categoryAccessor:Vt,brush:Ut,onBrush:Kt,decay:Zt,pulse:Qt,transition:Jt,animate:te,staleness:ee,frameScheduler:ne,clock:oe,random:ie,seed:re,paused:pe=!1,suspendWhenHidden:ye=!0,heatmapAggregation:ge,heatmapXBins:me,heatmapYBins:xe,showValues:be,heatmapValueFormat:ke,marginalGraphics:Se,pointIdAccessor:Ae,xScaleType:Me,yScaleType:_e,accessibleTable:Pe=!0,description:Ce,summary:Te,linkedCrosshairName:Le,linkedCrosshairSourceId:Re,customLayout:$e,onLayoutError:ze,layoutConfig:De,layoutSelection:Ie}=t,{customHoverBehavior:Be,customClickBehavior:Fe,hasClickBehavior:Ee}=function({customHoverBehavior:t,customClickBehavior:e,onObservation:n,chartId:o,chartType:i}){return{customHoverBehavior:Fc((e,r)=>{t?.(e,r),Ic({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:i,chartId:o,context:r})},[o,i,t,n]),customClickBehavior:Fc((t,r)=>{e?.(t,r),Bc({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:i,chartId:o,context:r})},[o,i,e,n]),hasClickBehavior:!(!e&&!n)}}({customHoverBehavior:bt,customClickBehavior:vt,onObservation:wt,chartId:St,chartType:"StreamXYFrame"}),Oe=fe().replace(/:/g,""),Ne=ae(!1),We=ae({w:-1,h:-1}),je=ae(!1),Ye=zl({sizeProp:z,responsiveWidth:D,responsiveHeight:I,userMargin:B,marginDefault:Gc,title:Ht,legend:$t,legendPosition:Ft,animate:te,transitionProp:Jt,frameScheduler:ne,clock:oe,random:ie,seed:re,paused:pe,suspendWhenHidden:ye,themeDirtyRef:Ne}),Ge=function(){const[t,e]=ka(!1);return Aa(()=>{e(!0)},[]),t}(),qe=function(){const t=Sa(Ma,_a,Pa);return wa(t).current}(),{reducedMotionRef:Xe,responsiveRef:He,size:Ve,currentTheme:Ue,transition:Ze,introEnabled:Qe,tableId:Je,rafRef:tn,renderFnRef:en,scheduleRender:nn,frameRuntime:on}=Ye;let rn=Ye.margin;if(Se){const t=60,e={...Ye.margin};Se.top&&t>e.top&&(e.top=t),Se.bottom&&t>e.bottom&&(e.bottom=t),Se.left&&t>e.left&&(e.left=t),Se.right&&t>e.right&&(e.right=t),rn=e}const sn=Ve[0]-rn.left-rn.right,an=Ve[1]-rn.top-rn.bottom,ln=ue(()=>q(i),[i]),cn=mt??At,[un,hn]=le(0),dn=ae(0),[fn,pn]=le(null),yn=El(Gt,Ve,rn,fn),gn=El(Yt,Ve,rn,fn),mn=ae(null),xn=ae(null),bn=ae(void 0),[vn,wn]=le(null),kn=ae(qc.primary),Sn=ae(function(){let t=-1,e=za;return{resolve(n){if(!n)return za;const o=jo;return o===t||(e=function(t){if(!t)return za;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),o=e.getPropertyValue("--semiotic-text-secondary").trim(),i=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),s=o||e.getPropertyValue("--text-secondary").trim(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),c=i||e.getPropertyValue("--surface-0").trim();return s||a||n||r?{axisStroke:l||za.axisStroke,tickText:s||za.tickText,crosshair:s?Da(s,"66"):za.crosshair,hoverFill:c?Da(c,"4D"):za.hoverFill,hoverStroke:s?Da(s,"99"):za.hoverStroke,pointRing:c||za.pointRing,primary:r||za.primary,background:c||za.background}:za}(n),t=o),e},invalidate(){t=-1}}}()),An=ae(!1),Mn=uo(new mo("StreamXYFrame")),[_n,Pn]=le(!1),[Cn,Tn]=le([]),[Ln,Rn]=le([]),$n="streaming"===o||["bar","swarm","waterfall"].includes(n),zn=function(t){const e=Ca(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return La(t,e);if(!Ra(t)||!Ra(e))return!1;const n=Object.keys(t),o=Object.keys(e);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))return!1;const n=t[o],i=e[o];if(!Object.is(n,i))if(Array.isArray(n)&&Array.isArray(i)){if(!La(n,i))return!1}else{if(!Ra(n)||!Ra(i))return!1;if(!Ta(n,i))return!1}}return!0}(e.current,t)||(e.current=t),e.current}(ue(()=>({chartType:n,runtimeMode:$n?"streaming":"bounded",windowSize:_,windowMode:M,arrowOfTime:$n?S:"right",extentPadding:L,scalePadding:R,axisExtent:pt,xAccessor:l,yAccessor:c,accessorRevision:u,timeAccessor:$n?P:void 0,valueAccessor:k,colorAccessor:h,sizeAccessor:d,symbolAccessor:f,symbolMap:p,groupAccessor:y||(g?"_lineGroup":void 0),categoryAccessor:Vt,lineDataAccessor:g,xScaleType:Me,yScaleType:_e,xExtent:C,yExtent:T,sizeRange:$,binSize:w,normalize:x,baseline:b,stackOrder:v,boundsAccessor:U,boundsStyle:K,y0Accessor:Z,band:Q,gradientFill:!0===J?{topOpacity:.8,bottomOpacity:.05}:!1===J?void 0:J,areaGroups:et?new Set(et):void 0,lineGradient:tt,openAccessor:nt,highAccessor:ot,lowAccessor:it,closeAccessor:rt,candlestickStyle:st,lineStyle:N,pointStyle:W,areaStyle:j,swarmStyle:X,waterfallStyle:G,colorScheme:V,barColors:H,barStyle:Y,annotations:Pt,decay:Zt,pulse:Qt,transition:Ze,introAnimation:Qe,staleness:ee,clock:on.now,heatmapAggregation:ge,heatmapXBins:me,heatmapYBins:xe,showValues:be,heatmapValueFormat:ke,pointIdAccessor:Ae,curve:m,themeCategorical:Ue?.colors?.categorical,themeSemantic:A(Ue),themeSequential:Ue?.colors?.sequential,themeDiverging:Ue?.colors?.diverging,customLayout:$e,onLayoutError:ze,layoutConfig:De,layoutMargin:rn}),[n,$n,_,M,S,L,R,pt,l,c,u,P,k,h,d,f,p,y,g,Vt,Me,_e,C,T,$,w,x,b,v,U,K,Z,Q,J,et,tt,nt,ot,it,rt,st,N,W,j,X,G,V,H,Y,Pt,Zt,Qt,Ze,Qe,ee,on.now,ge,me,xe,be,ke,Ae,m,Ue,$e,ze,De,rn])),Dn=ae(null);Dn.current||(Dn.current=new ao(zn));const In=function(t,e,n,o){const i=Wl({accessor:e,onChange:n,readData:o}),r=Wl([]);return i.current={accessor:e,onChange:n,readData:o},Nl(()=>{const{accessor:e,onChange:n,readData:o}=i.current;if(!n||!e)return;const s=function(t,e){if(!e)return[];const n=new Set,o=[];for(const i of t){if(!i||"object"!=typeof i)continue;const t="function"==typeof e?e(i):i[e];if(null==t)continue;const r=t+"";n.has(r)||(n.add(r),o.push(r))}return o}(t.current?o(t.current):[],e);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(s,r.current)||(r.current=s,n(s))},[t])}(Dn,Wt,jt,t=>t.getData());!function(t,e,n,o){_o(()=>{t.current?.updateConfig(e),n.current=!0,o()},[e,o,t,n])}(Dn,zn,Ne,nn),function(t,e,n,o){const i=Po(null);_o(()=>{const r=t.current;if(!r)return;const s=e??null;i.current!==s&&(i.current=s,r.setLayoutSelection(s),r.hasCustomRestyle?r.restyleScene(s):n.current=!0,o())},[e,o,t,n])}(Dn,Ie,Ne,nn);const Bn=ae(null);Bn.current||(Bn.current=new we(t=>{const e=Dn.current;e&&e.ingest(t)&&(Ne.current=!0,nn())},{chunkThreshold:r,chunkSize:s})),ce(()=>{Bn.current?.updateChunkOptions({chunkThreshold:r,chunkSize:s})},[r,s]);const Fn=he(t=>{Bn.current?.push(t)},[]),En=he(t=>{Bn.current?.pushMany(t)},[]),On=he(()=>{Bn.current?.clear(),Dn.current?.clear(),Ne.current=!0,nn()},[nn]);de(e,()=>({push:Fn,pushMany:En,remove:t=>{Bn.current?.flush();const e=Dn.current?.remove(t)??[];return e.length>0&&(mn.current&&e.some(t=>t===mn.current?.data)&&(mn.current=null,wn(null)),Ne.current=!0,nn()),e},update:(t,e)=>{Bn.current?.flush();const n=Dn.current?.update(t,e)??[];return n.length>0&&(Ne.current=!0,nn()),n},clear:On,getData:()=>(Bn.current?.flush(),Dn.current?.getData()??[]),getScales:()=>Dn.current?.scales??null,getExtents:()=>Dn.current?.getExtents()??null,getCustomLayout:()=>Dn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Dn.current?.lastCustomLayoutFailure??null}),[Fn,En,On,nn]),ce(()=>{if(i){if(g&&ln.length>0&&"object"==typeof ln[0]&&null!==ln[0]){const t="string"==typeof g?g:"coordinates";if(Array.isArray(ln[0][t])){const e=[];for(const n of ln){const o=n[t];if(Array.isArray(o)){const t=n.label||n.id||n.key;if(null!=t)for(const n of o)e.push({...n,_lineGroup:t});else for(const t of o)e.push(t)}}return void Bn.current?.setBoundedData(e)}}Bn.current?.setBoundedData(ln)}},[i,ln,g]);const{canvasRef:Nn,interactionCanvasRef:Wn}=function(t,e){return function(t){const{cancelRender:e,dirtyRef:n,frameRuntime:o,manageFrameRuntime:i,scheduleRender:r}=t,s=Il(null),a=Il(null),l=Il(!1);return function(t){const{hydrated:e,wasHydratingFromSSR:n,storeRef:o,dirtyRef:i,renderFnRef:r,cancelRender:s,cleanup:a}=t;Aa(()=>{const t=o.current;e&&n&&t?.cancelIntroAnimation?.(),!n&&t?.sceneNodes&&t.sceneNodes.length>0&&t?.markStylePaintPending?t.markStylePaintPending():i.current=!0,s?.(),r.current()},[e,n]);const l=wa(a);l.current=a,ba(()=>()=>l.current?.(),[])}({hydrated:t.hydrated,wasHydratingFromSSR:t.wasHydratingFromSSR,storeRef:t.storeRef,dirtyRef:t.dirtyRef,renderFnRef:t.renderFnRef,cancelRender:t.cancelRender,cleanup:t.cleanup}),Dl(()=>{if(!1!==i)return o.subscribe(()=>{o.isActive?(n.current=!0,r()):e()})},[e,n,o,i,r]),Dl(()=>{!l.current&&(l.current=!0,t.skipInitialCanvasPaintInvalidation)||(t.dirtyRef.current=!0,t.scheduleRender())},t.canvasPaintDependencies),{canvasRef:s,interactionCanvasRef:a}}({...e,renderFnRef:t.renderFnRef,scheduleRender:t.scheduleRender,cancelRender:t.cancelRender,frameRuntime:t.frameRuntime})}(Ye,{storeRef:Dn,dirtyRef:Ne,hydrated:Ge,wasHydratingFromSSR:qe,cleanup:()=>Bn.current?.clear(),canvasPaintDependencies:[n,sn,an,at,E,Yt,N,O,qt,nn]}),{hoverHandlerRef:jn,hoverLeaveRef:Yn,onPointerMove:Gn,onPointerLeave:qn}=Ye;jn.current=t=>{if(!cn)return;const e=Nn.current;if(!e)return;const o=e.getBoundingClientRect(),i=t.clientX-o.left-rn.left,r=t.clientY-o.top-rn.top;if(0>i||i>sn||0>r||r>an)return void(mn.current&&(mn.current=null,xn.current=null,wn(null),Be&&(Be(null),Ne.current=!0),nn()));const s=Dn.current;if(!s||0===s.scene.length)return;const a=Et(Mt,t.pointerType),c=xi(s.scene,i,r,a,s.quadtree,s.maxPointRadius),u="multi"===_t,h=()=>{mn.current&&(mn.current=null,xn.current=null,wn(null),Be&&Be(null),nn())};if(!c&&!u)return void h();const d=u||!c?i:c.x,f=u||!c?r:c.y,p=c?.datum?Ke(c.datum,s.resolvedRibbons):{},y=s.scales?.x?.invert,g="function"==typeof y?y(d):void 0;let m=Nt(p,d,f,null!=g?{xValue:g,xPx:d}:void 0);if(u&&s.scene.length>0&&s.scales){const t=function(t,e,n=30){const o=[];for(const i of t)if("line"===i.type){const t=i;if(2>t.path.length)continue;const r=bi(mi(t.path,t.curve),e,n);if(null===r)continue;const s=Ti(t.path,e);o.push({node:i,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:t.path[s][0],y:r,group:t.group,color:t.style.stroke})}else if("area"===i.type){const t=i;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=mi(t.topPath,t.curve),s=mi(t.bottomPath,t.curve),a=bi(r,e,n);if(null===a)continue;const l=bi(s,e,n),c=Ti(t.topPath,e);o.push({node:i,datum:Array.isArray(t.datum)&&t.datum[c]?t.datum[c]:t.datum,x:t.topPath[c][0],y:a,y0:l??void 0,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return o}(s.scene,d,Math.max(a,sn));if(t.length>0){const e=s.scales.y.invert,o=kn.current,i=y?y(d):d;if(c)m.xValue=i,m.xPx=d;else{const t={xValue:i};"string"==typeof l&&(t[l]=i),m=Nt(t,d,f,{xValue:i,xPx:d})}m.allSeries=t.map(t=>{const i=e?e(t.y):t.y,r=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===n&&null!=r?i-r:i,valuePx:t.y,color:t.color||o,datum:Ke(t.datum,s.resolvedRibbons)}})}}c||m.allSeries?.length?(mn.current=m,xn.current=c?.node??null,wn(m),Be&&(Be(m),Ne.current=!0),nn()):h()},Yn.current=()=>{mn.current&&(mn.current=null,xn.current=null,wn(null),Be&&(Be(null),Ne.current=!0),nn())};const Xn=ae(()=>{});Xn.current=t=>{if(a(t.target))return;if(!Fe)return;const e=Nn.current;if(!e)return;const n=e.getBoundingClientRect(),o=t.clientX-n.left-rn.left,i=t.clientY-n.top-rn.top;if(0>o||o>sn||0>i||i>an)return void Fe(null);const r=Dn.current;if(!r||0===r.scene.length)return void Fe(null);const s=Et(Mt,bn.current),l=xi(r.scene,o,i,s,r.quadtree,r.maxPointRadius);if(!l)return void Fe(null);const c=l.datum||{},u=r.scales?.x?.invert,h="function"==typeof u?u(l.x):void 0;var d;Fe(Nt(c,l.x,l.y,null!=h?{xValue:h,xPx:l.x}:void 0),{type:"activate",inputType:(d=bn.current,"touch"===d?"touch":"pointer")})};const Hn=he(t=>Xn.current(t),[]),{kbFocusIndexRef:Vn,focusedNavPointRef:Un,onKeyDown:Kn}=(Zn={storeRef:Dn,hoverRef:mn,hoveredNodeRef:xn,setHoverPoint:wn,customHoverBehavior:Be,customClickBehavior:Fe,scheduleRender:nn},function({storeRef:t,hoverRef:e,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:i,customClickBehavior:r,scheduleRender:s,extractPoints:a,toHover:l}){const c=Oc(-1),u=Oc(null),h=Oc(null),d=Ec(d=>{if(function(t){const e=t.target;return e instanceof Element&&e!==t.currentTarget&&null!=e.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}(d))return;const f=t.current;if(!f)return;const p=()=>{c.current=-1,u.current=null,e.current=null,n&&(n.current=null),o(null),i(null),s()};if(0===f.scene.length)return void(0>c.current||p());let y;if(h.current?.version===f.version)y=h.current.graph;else{const t=a(f.scene);if(0===t.length)return void(0>c.current||p());y=function(t){const e=new Map;for(const n of t){const t=n.group??"_default";let o=e.get(t);o||(o=[],e.set(t,o)),o.push(n)}for(const t of e.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const n=Array.from(e.keys()).sort((t,n)=>{const o=e.get(t),i=e.get(n);return(o.length>0?o[0].y:0)-(i.length>0?i[0].y:0)}),o=Array.from(e.values()).flat();o.sort((t,e)=>t.x-e.x||t.y-e.y);const i=new Map;for(let t=0;o.length>t;t++){o[t]._flatIndex=t;const e=o[t].datum?.id;null!=e&&i.set(e+"",t)}return{flat:o,groups:n,byGroup:e,idToIdx:i}}(t),h.current={version:f.version,graph:y}}let g=c.current;if(y.flat.length>g||(p(),g=-1),("Enter"===d.key||" "===d.key)&&g>=0)return d.preventDefault(),void r(l(y.flat[g],f),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===d.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(d.key))return;d.preventDefault(),c.current=0;const t=y.flat[0];u.current=t;const n=l(t,f);return e.current=n,o(n),i(n,{type:"focus",inputType:"keyboard"}),void s()}const m=function(t,e,n){const{group:o,indexInGroup:i}=e,r=n.byGroup.get(o);switch(t){case"ArrowRight":return r.length-1>i?r[i+1]._flatIndex:e.flatIndex;case"ArrowLeft":return i>0?r[i-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(o);return n.groups.length-1>t?Nc(n,n.groups[t+1],r[i]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(o);return t>0?Nc(n,n.groups[t-1],r[i]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}(d.key,function(t,e){if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(e,t.flat.length-1)),o=t.flat[n];return{flatIndex:n,group:o.group??"_default",indexInGroup:o._groupIndex??0}}(y,g),y);if(null===m)return;if(d.preventDefault(),0>m)return void p();c.current=m;const x=y.flat[m];u.current=x;const b=l(x,f);e.current=b,o(b),i(b,{type:"focus",inputType:"keyboard"}),s()},[r,i,a,e,n,s,o,t,l]);return{kbFocusIndexRef:c,focusedNavPointRef:u,onKeyDown:d}}({...Zn,extractPoints:Wc,toHover:(t,e)=>function(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}({...t,datum:Ke(t.datum,e.resolvedRibbons)})}));var Zn;const Qn=he(t=>{bn.current=t.pointerType,Vn.current=-1,Un.current=null,Gn(t)},[Un,Vn,Gn]),Jn=he(t=>{bn.current="mouse",Vn.current=-1,Un.current=null,Gn({clientX:t.clientX,clientY:t.clientY,pointerType:"mouse"})},[Un,Vn,Gn]),to=he(t=>{bn.current=t.pointerType},[]);en.current=()=>{if(tn.current=null,!on.isActive)return;const t=Nn.current,e=Wn.current;if(!t||!e)return;const o=Dn.current;if(!o)return;const i=on.now(),r=o.advanceTransition(Xe.current?i+1e6:i),s=!Xe.current&&r,a=We.current.w!==sn||We.current.h!==an,u=Ne.current||r||a,h=o.consumeStylePaintPending();let d=!1;const f=o.getLastUpdateResult(),p=Mn.current.beforeCompute(f,s);!u||s&&!a||(o.computeScene({width:sn,height:an}),We.current={w:sn,h:an},d=!0,In()),Mn.current.afterCompute(p,d,a);const y=function(t,e,n,o){const i=o.current,r=!0===t.lastCustomLayoutFailure?.preservedLastGoodScene,s=!r&&t.hasActivePulsesAt(e),a=!(n||r||!s&&!i)&&t.refreshPulse(e);return o.current=s,{changed:a,pending:s}}(o,i,d,je),g=function(){if("undefined"==typeof window)return 1;const t=window.devicePixelRatio||1,e=function(){if("undefined"==typeof window)return!1;const t="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,e=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return t||e}()?2:3;return Math.max(1,Math.min(t,e))}(),m=Sn.current.resolve(t);kn.current=m.primary;const x=Di(ee,o.lastIngestTime>0?i-o.lastIngestTime:0),b=ee&&x.isStale;if(u||h||y.changed){const e=Ol(t,Ve,rn,g);if(e){if(e.clearRect(-rn.left,-rn.top,Ve[0],Ve[1]),ee&&1>x.alpha&&(e.globalAlpha=x.alpha),function(t,e){const{background:n,hasBackgroundGraphics:o=!1,themeBackground:i="",x:r=0,y:s=0,width:a,height:l}=e,c=$a({background:n,hasBackgroundGraphics:o,themeBackground:i});if(!c)return!1;const u=Xo(t,c);u&&(t.fillStyle=u,t.fillRect(r,s,a,l))}(e,{background:E,hasBackgroundGraphics:!!Yt,themeBackground:m.background,x:-rn.left,y:-rn.top,width:Ve[0],height:Ve[1]}),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,sn,an),e.clip()),qt&&o.scales)for(const t of qt)e.save(),t(e,o.scene,o.scales,{width:sn,height:an}),e.restore();const t=$e?xc.custom:xc[n];!function(t){const{context:e,nodes:n,renderMode:o,pixelRatio:i,paintBuiltIn:r}=t;if(!o||"sketchy"===o)return void r(n);let s=[];const a=()=>{s.length&&(r(s),s=[])};for(const t of n){const n=vc(o,t);if(!n){s.push(t);continue}let l;a(),e.save();try{l=n.drawCanvas({context:e,node:t,style:t.style??{},pixelRatio:i})}finally{e.restore()}l||(wc(n.id,t.type??"unknown"),r([t]))}a()}({context:e,nodes:o.scene,renderMode:O,pixelRatio:g,paintBuiltIn:n=>{if(t&&o.scales)for(const i of t)i(e,n,o.scales,{width:sn,height:an})}}),e.restore(),ee&&1>x.alpha&&(e.globalAlpha=1)}}const v=!!(cn&&mn.current&&o.scales),w=!!(xn.current&&Array.isArray(mt)&&mt.some(t=>t&&"object"==typeof t&&"highlight"===t.type)),k=v||w;if(k||An.current){const t=Ol(e,Ve,rn,g);if(t&&(t.clearRect(-rn.left,-rn.top,Ve[0],Ve[1]),v&&mn.current&&function(t,e,n,o,i,r,s){if(!1===i.crosshair)return;const a=e.allSeries,l=a&&a.length>0,c=e.xPx??e.x;t.save();const u="object"==typeof i.crosshair?i.crosshair:{};if(t.strokeStyle=u.stroke||s.crosshair,t.lineWidth=u.strokeWidth||1,t.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(l?c:e.x,0),t.lineTo(l?c:e.x,o),t.stroke(),l||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),l){t.lineWidth=2,t.strokeStyle=s.pointRing;for(const e of a)null!=e.valuePx&&(t.beginPath(),t.arc(c,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||s.primary,t.fill(),t.stroke())}else{const n=i.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const n="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||n||null:n||e.stroke||null}(r)||s.primary;t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=n,t.fill(),t.strokeStyle=s.pointRing,t.lineWidth=2,t.stroke()}}(t,mn.current,sn,an,"object"==typeof cn?cn:{},xn.current,m),w&&xn.current&&Array.isArray(mt))){const e=mt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,o,i){if(!n)return;const r="group"in n?n.group:void 0;if(void 0!==r)for(const n of e){if("line"!==n.type)continue;if(n.group!==r)continue;if(2>n.path.length)continue;const e="function"==typeof o.style?n.datum?o.style(n.datum):{}:o.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||i.primary,t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=e.opacity??1,t.stroke(),t.restore()}}(t,o.scene,xn.current,e,m)}An.current=k}u&&t&&t.setAttribute("aria-label",Ha(o.scene,n+" chart"));const S=Ne.current;if(Ne.current=S&&s&&!d,S&&o.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!fn||t(fn.x.domain()[0])!==t(o.scales.x.domain()[0])||t(fn.x.domain()[1])!==t(o.scales.x.domain()[1])||t(fn.y.domain()[0])!==t(o.scales.y.domain()[0])||t(fn.y.domain()[1])!==t(o.scales.y.domain()[1])||fn.x.range()[0]!==o.scales.x.range()[0]||fn.x.range()[1]!==o.scales.x.range()[1]||fn.y.range()[0]!==o.scales.y.range()[0]||fn.y.range()[1]!==o.scales.y.range()[1])&&pn(o.scales),Se){const t=o.getData(),e="function"==typeof l?l:t=>t[l||"x"],n="function"==typeof c?c:t=>t[c||"y"];Tn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Rn(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}!((Pt&&Pt.length>0||$e)&&(d||s))||!d&&33>i-dn.current||(hn(t=>t+1),dn.current=i),ee?.showBadge&&Pn(!!b),(s||null!=o.activeTransition||y.pending)&&nn()},function(t,e,n,o,i,r){const s=Ri("fresh");Li(()=>{if(!t)return;const a=setInterval(()=>{const a=e.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=Di(t,l-a.lastIngestTime);c.band===s.current&&c.isStale===i||(s.current=c.band,c.isStale!==i&&r(c.isStale),n.current=!0,o())},1e3);return()=>clearInterval(a)},[t,i,o,e,r,n])}(ee,Dn,Ne,nn,_n,Pn);const eo=ue(()=>{if(dt||yt)return;const t=Dn.current;return t?.xIsDate&&fn?ql(fn.x.domain()):void 0},[dt,yt,fn]),no=dt||yt||eo,oo=cn&&vn?xt?xt(vn):jc(Dc,{hover:vn}):null,io=oo?jc(pl,{x:vn.x,y:vn.y,containerWidth:sn,containerHeight:an,margin:rn,className:"stream-frame-tooltip",children:oo}):null,ro=Un.current,so=jc(hl,{active:Vn.current>=0,hoverPoint:vn,margin:rn,size:Ve,shape:ro?.shape,width:ro?.w,height:ro?.h}),lo=jl(l,P,"__semiotic_resolvedX","__semiotic_resolvedTime"),co=jl(c,k,"__semiotic_resolvedY","__semiotic_resolvedValue"),ho=lo.key,fo=co.key,po=function(t,e,n){return o=>{if(!o||!n||!t.fn&&!e.fn)return o;let i=!1;const r=o.map(n=>{const o=t.fn&&t.key&&!(t.key in n),r=e.fn&&e.key&&!(e.key in n);if(!o&&!r)return n;i=!0;const s={...n};return o&&(s[t.key]=t.fn(n)),r&&(s[e.key]=e.fn(n)),s});return i?r:o}}(lo,co,Pt&&Pt.length>0||!1);if(xa||!Ge&&qe){const t=Dn.current;t&&i&&(t.ingest({inserts:ln,bounded:!0}),t.computeScene({width:sn,height:an}));const e=t?.scene??[],n=t?.scales??null,o=El(Gt,Ve,rn,n),r=El(Yt,Ve,rn,n),s=no||(()=>{if(t?.xIsDate&&n)return ql(n.x.domain())})();return Yc("div",{ref:He,className:"stream-xy-frame"+(F?" "+F:""),role:"img","aria-label":Ce||("string"==typeof Ht?Ht:"XY chart"),style:{position:"relative",width:D?"100%":Ve[0],height:I?"100%":Ve[1]},children:[jc(al,{summary:Te}),Yc("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ve[0],height:Ve[1],style:{position:"absolute",left:0,top:0},children:[jc("g",{transform:`translate(${rn.left},${rn.top})`,children:r}),Yc("g",{transform:`translate(${rn.left},${rn.top})`,children:[E&&jc("rect",{x:0,y:0,width:sn,height:an,fill:E}),Xt&&n&&Xt.map((t,o)=>jc(se.Fragment,{children:t(e,n,{width:sn,height:an})},"svgpre-"+o)),e.map((t,e)=>kc({node:t,index:e,renderMode:O,fallback:()=>ma(t,e,Oe)})).filter(Boolean)]})]}),jc(Es,{width:sn,height:an,totalWidth:Ve[0],totalHeight:Ve[1],margin:rn,scales:n,showAxes:at,axes:lt,xLabel:ct,yLabel:ut,yLabelRight:ht,xFormat:s,yFormat:ft||gt,axisExtent:pt,showGrid:Rt,title:Ht,legend:$t,legendHoverBehavior:zt,legendClickBehavior:Dt,legendHighlightedCategory:It,legendIsolatedCategories:Bt,legendPosition:Ft,legendLayout:Ot,foregroundGraphics:vo(o,Mo(Dn.current?.customLayoutOverlays,Ie??null)),marginalGraphics:Se,xValues:[],yValues:[],annotations:Pt,onAnnotationActivate:Ct,onObservation:kt??wt,chartId:St,chartType:"StreamXYFrame",autoPlaceAnnotations:Tt,svgAnnotationRules:Lt,annotationFrame:0,xAccessor:ho,yAccessor:fo,annotationData:po(Dn.current?.getData()),pointNodes:Xl(Dn.current?.scene),curve:"string"==typeof m?m:void 0,linkedCrosshairName:Le,linkedCrosshairSourceId:Re})]})}return Yc("div",{ref:He,className:"stream-xy-frame"+(F?" "+F:""),role:"group","aria-label":Ce||("string"==typeof Ht?Ht:"XY chart"),tabIndex:0,style:{position:"relative",width:D?"100%":Ve[0],height:I?"100%":Ve[1],overflow:"visible",touchAction:Xc(Ut)},onKeyDown:Kn,children:["production"!==process.env.NODE_ENV&&Dn.current&&jc(xo,{store:Dn.current,diagnostics:Mn.current}),Pe&&jc(ll,{tableId:Je}),Pe&&jc(sl,{scene:Dn.current?.scene??[],chartType:n+" chart",tableId:Je,chartTitle:"string"==typeof Ht?Ht:void 0}),jc(al,{summary:Te}),jc(Wa,{hoverPoint:vn}),Yc("div",{role:"img","aria-label":Ce||("string"==typeof Ht?Ht:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:cn?Qn:void 0,onMouseMove:cn?Jn:void 0,onPointerLeave:cn?qn:void 0,onMouseLeave:cn?qn:void 0,onPointerDown:cn||Ee?to:void 0,onClick:Ee?Hn:void 0,children:[jc(Fl,{size:Ve,margin:rn,children:gn}),jc(Is,{width:sn,height:an,totalWidth:Ve[0],totalHeight:Ve[1],margin:rn,scales:fn,showAxes:at,axes:lt,showGrid:Rt,xFormat:no,yFormat:ft||gt,axisExtent:pt}),jc("canvas",{ref:Nn,"aria-label":Ha(Dn.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),jc("canvas",{ref:Wn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),jc(Es,{width:sn,height:an,totalWidth:Ve[0],totalHeight:Ve[1],margin:rn,scales:fn,showAxes:at,axes:lt,xLabel:ct,yLabel:ut,yLabelRight:ht,xFormat:no,yFormat:ft||gt,axisExtent:pt,showGrid:Rt,title:Ht,legend:$t,legendHoverBehavior:zt,legendClickBehavior:Dt,legendHighlightedCategory:It,legendIsolatedCategories:Bt,legendPosition:Ft,legendLayout:Ot,foregroundGraphics:vo(yn,Mo(Dn.current?.customLayoutOverlays,Ie??null)),marginalGraphics:Se,xValues:Cn,yValues:Ln,annotations:Pt,onAnnotationActivate:Ct,onObservation:kt??wt,chartId:St,chartType:"StreamXYFrame",autoPlaceAnnotations:Tt,svgAnnotationRules:Lt,annotationFrame:un,xAccessor:ho,yAccessor:fo,annotationData:po(Dn.current?.getData()),pointNodes:Xl(Dn.current?.scene),curve:"string"==typeof m?m:void 0,underlayRendered:!0,canvasObscuresUnderlay:!!$a({background:E,hasBackgroundGraphics:!!Yt,themeBackground:Ue?.colors.background}),linkedCrosshairName:Le,linkedCrosshairSourceId:Re}),(Ut||Kt)&&jc(ve,{width:sn,height:an,totalWidth:Ve[0],totalHeight:Ve[1],margin:rn,dimension:Ut?.dimension??"xy",scales:fn,onBrush:Kt??(()=>{}),binSize:w,snap:Ut?.snap,binBoundaries:Ut?.binBoundaries??("bar"===n?Dn.current?.getBinBoundaries():void 0),snapDuring:Ut?.snapDuring,streaming:"streaming"===o}),ee?.showBadge&&jc(Bi,{isStale:_n,position:ee.badgePosition}),so,io]})]})}));Hc.displayName="StreamXYFrame";var Vc=Hc;import{useMemo as Uc,useCallback as Kc,useState as Zc,useId as Qc,useEffect as Jc,useRef as tu}from"react";import{createContext as eu,useContext as nu,useMemo as ou}from"react";import{jsx as iu}from"react/jsx-runtime";var ru=eu(null);function su(){return nu(ru)}import{createContext as au,useContext as lu,useEffect as cu,useId as uu,useLayoutEffect as hu,useMemo as du,useRef as fu,useState as pu,useCallback as yu}from"react";function gu(t){const e=[];for(const[n,o]of Object.entries(t.fields))if("point"===o.type)e.push(t=>o.values.has(t[n]));else{const[t,i]=o.range;e.push(e=>{const o=e[n];return o>=t&&i>=o})}return t=>e.every(e=>e(t))}function mu(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}function xu(t,e){if(t.type!==e.type)return!1;if("interval"===t.type&&"interval"===e.type)return t.range[0]===e.range[0]&&t.range[1]===e.range[1];if("point"===t.type&&"point"===e.type){if(t.values.size!==e.values.size)return!1;for(const n of t.values)if(!e.values.has(n))return!1;return!0}return!1}var[bu,vu]=r(t=>({selections:new Map,setClause(e,n){t(t=>{const o=t.selections.get(e),i=o?.clauses.get(n.clientId);if(i&&function(t,e){if(t.clientId!==e.clientId||t.type!==e.type)return!1;const n=Object.entries(t.fields);if(n.length!==function(t){let e=0;for(const n in t)e++;return e}(e.fields))return!1;for(const[t,o]of n){const n=e.fields[t];if(!n||!xu(o,n))return!1}return!0}(i,n))return{};const r=new Map(t.selections),s=mu(r,e),a=new Map(s.clauses);return a.set(n.clientId,n),r.set(e,{...s,clauses:a}),{selections:r}})},clearClause(e,n){t(t=>{const o=t.selections.get(e);if(!o||!o.clauses.has(n))return{};const i=new Map(t.selections),r=new Map(o.clauses);return r.delete(n),i.set(e,{...o,clauses:r}),{selections:i}})},setResolution(e,n){t(t=>{const o=t.selections.get(e);if(o?.resolution===n)return{};const i=new Map(t.selections),r=mu(i,e);return i.set(e,{...r,resolution:n}),{selections:i}})},clearSelection(e){t(t=>{const n=t.selections.get(e);if(!n||0===n.clauses.size)return{};const o=new Map(t.selections);return o.set(e,{...n,clauses:new Map}),{selections:o}})}}));import{useId as wu,useMemo as ku,useCallback as Su}from"react";function Au(t){const e=wu(),n=t.clientId||e,{name:o}=t,i=vu(t=>t.selections.get(o)),r=vu(t=>t.setClause),s=vu(t=>t.clearClause),a=ku(()=>!!i&&i.clauses.size>0,[i]);return{predicate:ku(()=>i&&0!==i.clauses.size?function(t,e){const n=[];for(const[o,i]of t.clauses)"crossfilter"===t.resolution&&o===e||n.push(gu(i));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(i,n):()=>!0,[i,n]),isActive:a,selectPoints:Su(t=>{const e={};let i=!1;for(const[n,o]of Object.entries(t))e[n]={type:"point",values:new Set(o)},i=!0;i&&r(o,{clientId:n,type:"point",fields:e})},[n,o,r]),selectInterval:Su(t=>{const e={};let i=!1;for(const[n,o]of Object.entries(t))e[n]={type:"interval",range:o},i=!0;i&&r(o,{clientId:n,type:"interval",fields:e})},[n,o,r]),clear:Su(()=>{s(o,n)},[s,o,n]),clientId:n}}import{jsx as Mu,jsxs as _u}from"react/jsx-runtime";var Pu=au(!1);au(!1);var Cu=au(null),Tu="undefined"==typeof window?cu:hu;import*as Lu from"react";import{jsx as Ru,jsxs as $u}from"react/jsx-runtime";function zu(t,e,n){const o=t.xValue??e?.[n];if(null==o)return null;const i=Number(o);return Number.isFinite(i)?i:null}function Du(t){let e=t.data||t.datum||t;return Array.isArray(e)&&(e=e[0]),null!=t.xValue&&e&&"object"==typeof e&&!Array.isArray(e)&&null==e.xValue?{...e,xValue:t.xValue}:e||{}}function Iu(t){if(!t)return!1;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}Lu.createContext(void 0);var Bu=[];function Fu(){const t=$(t=>t.theme),e=t?.colors?.categorical;return e&&e.length>0?e:void 0}function Eu(t,e,n,o,i){if(t)return t;if(n&&"object"==typeof n&&!Array.isArray(n)){const t=_t(n,o);if(t)return t}let r;if(Array.isArray(n))r=n;else if(e&&e.length>0)r=e;else if("string"==typeof n){const t=xt[n];Array.isArray(t)&&(r=t)}return r&&0!==r.length?null!=o?(i.has(o)||i.set(o,i.size),r[i.get(o)%r.length]):r[0]:vt}function Ou({selection:t,linkedHover:e,fallbackFields:n=Bu,unwrapData:o=!1,onObservation:i,chartType:r,chartId:s,onClick:a,hoverHighlight:l,colorByField:c,mobileInteraction:u}){const h=Qc(),d=Uc(()=>function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField,seriesField:t.seriesField}:null}(e,n),[e,n]),f=Uc(()=>"series"===d?.mode?[d.seriesField||c||n[0]].filter(t=>!!t):d?.fields||n,[d,c,n]),p=Au({name:t?.name||"__unused__",fields:f}),g=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:o,isActive:i,selectPoints:r,clear:s}=Au({name:e,fields:n});return{onHover:Su(t=>{if(!t)return void s();const e={};for(const o of n){const n=t[o];void 0!==n&&(e[o]=[n])}(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1})(e)&&r(e)},[n,r,s]),predicate:o,isActive:i}}({name:d?.name||"hover",fields:f}),m=y(t=>t.pushObservation),x=Kc(t=>{i?.(t),m?.(t)},[i,m]),b=t?{isActive:p.isActive,predicate:p.predicate}:null,[v,w]=Zc(null),k=tu(!1),S=c||n[0],A=Uc(()=>{if(!l||null==v||!S)return null;const t=v,e=S;return{isActive:!0,predicate:n=>("string"==typeof n[e]?n[e]:(n[e]??"")+"")===t}},[l,v,S]),M=Kc((t,n)=>{const o=!t&&k.current&&!!u?.enabled&&u.tapToLockTooltip;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===d?.mode&&d.xField){const n=zu(t,e,d.xField);null!=n&&function(t,e,n){const o=fs.positions.get(t);o?.locked||o&&o.xValue===e&&o.sourceId===n||(fs={positions:new Map(fs.positions).set(t,{xValue:e,sourceId:n})},ys())}(d.name||"hover",n,h)}"x-position"!==d?.mode&&g.onHover(e)}else"x-position"!==d?.mode||o||gs(d.name||"hover",h),"x-position"===d?.mode||o||g.onHover(null);if(l&&S)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=e?.[S];w(null!=n?n+"":null)}else o||w(null);(i||m)&&Ic({onObservation:x,datum:t?Du(t):null,x:t?.x,y:t?.y,chartType:r||"unknown",chartId:s,context:n})},[e,g,d,h,i,r,s,m,x,l,S,u]),_=Kc((n=!0)=>{k.current=!1,e&&"x-position"!==d?.mode&&g.onHover(null),t&&u?.tapToSelect&&p.clear(),n&&l&&w(null),"x-position"===d?.mode&&(ms(d.name||"hover",h),gs(d.name||"hover",h))},[e,d,g,t,u,p,l,h]),P=Kc((n,o)=>{const c=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),y=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===d?.mode&&d.xField&&n){let t=n.data||n.datum||n;Array.isArray(t)&&(t=t[0]);const e=zu(n,t,d.xField);null!=e&&function(t,e,n){const o=fs.positions.get(t);if(o?.locked){const e=new Map(fs.positions);return e.delete(t),fs={positions:e},ys(),!1}fs={positions:new Map(fs.positions).set(t,{xValue:e,sourceId:n,locked:!0})},ys()}(d.name||"hover",e,h)}if(c)if(n){k.current=!0;const o=Du(n);if(e&&"x-position"!==d?.mode&&g.onHover(o),t&&u?.tapToSelect&&f.length>0){const t={};for(const e of f){const n=o[e];void 0!==n&&(t[e]=[n])}Iu(t)&&p.selectPoints(t)}if(l&&S){const t=o?.[S];w(null!=t?t+"":null)}}else y&&_();if(n||y){if(n&&a){let t=n.data||n.datum||n;Array.isArray(t)&&(t=t[0]),a(t,{x:n.x??0,y:n.y??0})}(i||m)&&Bc({onObservation:x,datum:n?Du(n):null,x:n?.x,y:n?.y,chartType:r||"unknown",chartId:s,context:o})}},[a,i,m,x,r,s,d,h,u,e,g,t,p,f,l,S,_]);return Jc(()=>{if(!u?.enabled||"undefined"==typeof document)return;const t=t=>{"Escape"===t.key&&k.current&&_()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[u?.enabled,_]),Jc(()=>()=>{k.current&&_(!1)},[_]),Jc(()=>{if("x-position"!==d?.mode)return;const t=d.name||"hover";return()=>{ms(t,h),gs(t,h)}},[d?.mode,d?.name,h]),{activeSelectionHook:b,hoverSelectionHook:A,customHoverBehavior:M,customClickBehavior:P,crosshairSourceId:h}}function Nu({data:t,colorBy:e,colorScale:n,showLegend:o,legendPosition:i="right",userMargin:r,defaults:s={top:50,bottom:60,left:70,right:40},categories:a,additionalLegend:l}){const c=lu(Pu),u=null!==lu(Cu),h=void 0!==o?o:!c&&!!e,d=!!e&&(h||u),f=Uc(()=>{if(!d)return[];if(void 0!==a)return a;const n=new Set;for(const o of t){const t="function"==typeof e?e(o):o[e];null!=t&&n.add(t+"")}return Array.from(n)},[a,e,t,d]);!function(t){const e=lu(Cu),n=uu(),o=function(t){const e=new Set,n=[];for(const o of t)e.has(o)||(e.add(o),n.push(o));return n}(t),i=fu([]);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(i.current,o)||(i.current=o);const r=i.current;Tu(()=>{if(e)return()=>e.unregisterCategories(n)},[e,n]),Tu(()=>{e&&e.registerCategories(n,r)},[e,n,r])}(u&&e?f:[]);const p=Uc(()=>{if(!h||!e)return;const o=function({data:t,colorBy:e,colorScale:n,getColor:o,strokeColor:i,strokeWidth:r,categories:s}){return{legendGroups:[{styleFn:t=>{const e=t.color||"#333",n={fill:e,stroke:e};return void 0!==i&&(n.stroke=i),void 0!==r&&(n.strokeWidth=r),n},type:"fill",items:(s&&s.length>0?s:Array.from(new Set(t.map(t=>"function"==typeof e?e(t):t[e])))).map((i,r)=>{const s=t.find("function"==typeof e?t=>e(t)===i:t=>t[e]===i),a=s?o(s,e,n):n?n(i):kt[r%kt.length];return{label:i+"",color:a}}),label:""}]}}({data:t,colorBy:e,colorScale:n,getColor:Mt,categories:f});return 0!==o.legendGroups.reduce((t,e)=>t+e.items.length,0)?o:void 0},[h,e,t,n,f]),y=Uc(()=>Qi(p,l),[p,l]),g=Uc(()=>{const t="number"==typeof r?{top:r,bottom:r,left:r,right:r}:r??{},e=e=>{const n=t[e];return"number"==typeof n?n:s[e]},n={top:e("top"),right:e("right"),bottom:e("bottom"),left:e("left")},o=e=>"number"==typeof t[e];return y&&("right"===i&&!o("right")&&110>n.right?n.right=110:"left"===i&&!o("left")&&110>n.left?n.left=110:"top"===i&&!o("top")&&50>n.top?n.top=50:"bottom"===i&&!o("bottom")&&80>n.bottom&&(n.bottom=80)),n},[s,r,y,i]);return{legend:y,margin:g,legendPosition:i}}import{jsx as Wu,jsxs as ju}from"react/jsx-runtime";function Yu({componentName:t,message:e,diagnosticHint:n,width:o,height:i}){return Wu("div",{role:"alert",style:{width:o,height:Math.max(i,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:ju("div",{style:{textAlign:"center",maxWidth:400},children:[Wu("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:t}),Wu("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:e}),n&&Wu("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:n})]})})}import*as Gu from"react";import{jsx as qu}from"react/jsx-runtime";var Xu=class extends Gu.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,e){this.props.onError?.(t,e)}render(){if(this.state.error){const{fallback:t}=this.props,e=this.state.error;return"function"==typeof t?t(e):void 0!==t?t:qu(Yu,{componentName:"ChartErrorBoundary",message:e.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}};import{jsx as Hu}from"react/jsx-runtime";var Vu="undefined"!=typeof process&&"production"!==process.env?.NODE_ENV;function Uu({componentName:t,width:e,height:n,children:o}){return Hu(Xu,{fallback:o=>Hu(Yu,{componentName:t,message:o.message,width:e,height:n}),children:o})}var Ku={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Zu={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Qu(t,e,n,o){if(!Vu)return;if(!e||0===e.length)return;if("string"!=typeof o)return;const i=e[0];if(!i||"object"!=typeof i)return;if(o in i)return;const r=Object.keys(i).join(", ");console.warn(`[semiotic] ${t}: ${n} "${o}" not found in data. Available keys: ${r}`)}import{useCallback as Ju,useMemo as th,useState as eh}from"react";import{useMemo as nh}from"react";import{useImperativeHandle as oh,useRef as ih}from"react";import{useMemo as rh}from"react";import{useEffect as sh,useMemo as ah,useRef as lh,useState as ch}from"react";var uh=null;async function hh(){return uh||(uh=await import("./chunk-statisticalOverlays-T77OKLDY.module.min.js")),uh}var dh="__semiotic_resolvedX",fh="__semiotic_resolvedY";import{jsx as ph}from"react/jsx-runtime";function yh(t,e){if(null==e)return t;const n=t.trim(),o=n.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(o){const t=o[1],n=3===t.length?t.split("").map(t=>t+t).join(""):t;return`rgba(${parseInt(n.slice(0,2),16)}, ${parseInt(n.slice(2,4),16)}, ${parseInt(n.slice(4,6),16)}, ${e})`}if(n.startsWith("rgba(")){const t=n.lastIndexOf(","),o=n.lastIndexOf(")");if(-1!==t&&o>t)return`${n.slice(0,t+1)} ${e})`}return n.startsWith("rgb(")?n.replace(/^rgb\(/,"rgba(").replace(/\)$/,`, ${e})`):t}function gh(t){return t.filter(t=>Number.isFinite(t.at)).map(t=>({offset:1-Math.max(0,Math.min(100,t.at))/100,color:yh(t.color,t.opacity)})).sort((t,e)=>t.offset-e.offset)}function mh(t,e,n){return"function"==typeof t?t(n):n[t||e]}function xh(t){return t instanceof Date?t.getTime():Number(t)}function bh(t,e){return ot(1===e?.5:t/(e-1))}function vh(t,e,n){const o="function"==typeof e?e(t):t[e??n];if(null==o)return null;if(o instanceof Date)return o.getTime();if("string"==typeof o&&""===o.trim())return null;const i=Number(o);return Number.isFinite(i)?i:null}ie(function(t,e){const n=re(null);!function(t,e){const{variant:n,frameRef:o,overrides:i}=e,r=ih(i);r.current=i,oh(t,()=>{const t=function(t,e){if("xy"===t){const t=e;return{push:e=>t.current?.push(e),pushMany:e=>t.current?.pushMany(e),remove:e=>t.current?.remove(e)??[],update:(e,n)=>t.current?.update(e,n)??[],replace:e=>t.current?.replace?.(e),clear:()=>t.current?.clear(),getData:()=>t.current?.getData()??[],getScales:()=>t.current?.getScales()??null,getCustomLayout:()=>t.current?.getCustomLayout?.()??null,getLayoutFailure:()=>t.current?.getLayoutFailure?.()??null}}if("network"===t){const t=e;return{push:e=>t.current?.push(e),pushMany:e=>t.current?.pushMany(e),remove:e=>{const n=Array.isArray(e)?e:[e],o=t.current?.getTopology()?.nodes??[],i=[];for(const e of n){const n=o.find(t=>t.id===e);n&&i.push({...n.data??{},id:e}),t.current?.removeNode(e)}return i},update:(e,n)=>(Array.isArray(e)?e:[e]).flatMap(e=>{const o=t.current?.updateNode(e,n);return o?[{...o,id:e}]:[]}),clear:()=>t.current?.clear(),getData:()=>t.current?.getTopology()?.nodes?.map(t=>t.data)??[],getCustomLayout:()=>t.current?.getCustomLayout?.()??null,getLayoutFailure:()=>t.current?.getLayoutFailure?.()??null}}if("geo-points"===t){const t=e;return{push:e=>t.current?.push(e),pushMany:e=>t.current?.pushMany(e),remove:e=>t.current?.removePoint(e)??[],update:(e,n)=>{const o=t.current?.removePoint(e)??[];for(const e of o)t.current?.push(n(e));return o},clear:()=>t.current?.clear(),getData:()=>t.current?.getData()??[],getCustomLayout:()=>t.current?.getCustomLayout?.()??null,getLayoutFailure:()=>t.current?.getLayoutFailure?.()??null}}const n=e;return{push:t=>n.current?.pushLine(t),pushMany:t=>n.current?.pushManyLines(t),remove:t=>n.current?.removeLine(t)??[],update:(t,e)=>{const o=n.current?.removeLine(t)??[];for(const t of o)n.current?.pushLine(e(t));return o},clear:()=>n.current?.clear(),getData:()=>n.current?.getLines()??[],getCustomLayout:()=>n.current?.getCustomLayout?.()??null,getLayoutFailure:()=>n.current?.getLayoutFailure?.()??null}}(n,o);return new Proxy(t,{get(t,e,n){if("string"==typeof e){const t=r.current?.[e];if("function"==typeof t)return t}return Reflect.get(t,e,n)},has:(t,e)=>!("string"!=typeof e||!r.current||!(e in r.current))||Reflect.has(t,e)})},[])}(e,{variant:"xy",frameRef:n});const o=O(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},void 0);const{data:i,margin:r,className:s,xFormat:a,yFormat:l,xAccessor:c="x",yAccessor:u="y",areaBy:h,y0Accessor:d,gradientFill:f=!1,semanticGradient:p,lineDataAccessor:y="coordinates",colorBy:m,colorScheme:x,styleRules:b,curve:v="monotoneX",areaOpacity:w=.7,lineGradient:k,showLine:S=!0,lineWidth:A=2,showPoints:M=!1,pointRadius:_=3,tooltip:P,annotations:C,forecast:T,anomaly:L,band:R,xExtent:z,yExtent:D,frameProps:I={},selection:B,linkedHover:E,onObservation:N,onClick:W,hoverHighlight:j,chartId:G,loading:X,loadingContent:H,emptyContent:V,legendInteraction:U,legendPosition:K,color:Z,stroke:Q,strokeWidth:J,opacity:tt}=t,{width:et,height:nt,enableHover:ot,showGrid:it,showLegend:rt,title:st,description:at,summary:lt,accessibleTable:ct,xLabel:ut,yLabel:ht}=o,dt=oe(()=>q(i),[i]),ft=m||h,pt=oe(()=>p&&p.length>0?{colorStops:gh(p)}:f,[p,f]);Qu("AreaChart",dt,"xAccessor",c),Qu("AreaChart",dt,"yAccessor",u);const yt=function(t){const{data:e,rawData:n,colorBy:o,colorScheme:i,legendInteraction:r,legendPosition:s,selection:a,linkedHover:l,fallbackFields:c,unwrapData:u=!1,onObservation:h,chartType:d,chartId:f,showLegend:p,legend:y,userMargin:g,marginDefaults:m,onClick:x,hoverHighlight:b,mobileInteraction:v,mobileSemantics:w,loading:k,loadingContent:S,emptyContent:A,width:M,height:_}=t,P=void 0===n,C=th(()=>q(e),[e]),[T,L]=eh([]),R=Ju(t=>{L(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)},[]),z="string"==typeof t.colorBy?t.colorBy:void 0,D=th(()=>F(v,{width:M,mobileSemantics:w}),[v,M,w]),{activeSelectionHook:I,hoverSelectionHook:B,customHoverBehavior:E,customClickBehavior:O,crosshairSourceId:N}=Ou({selection:a,linkedHover:l,fallbackFields:c,unwrapData:u,onObservation:h,chartType:d,chartId:f,onClick:x,hoverHighlight:b,colorByField:z,mobileInteraction:D}),W=function(t,e){const n="object"==typeof t&&null!==t?t:void 0;if("x-position"===n?.mode)return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:e}}(l,N),j=function(t,e,n){const o=su(),i=Fu();return Uc(()=>{if(!e)return;const r=o??void 0,s=n??(i&&i.length>0?i:void 0)??"category10";if(0!==t.length){if("function"==typeof e){const n=Array.from(new Set(t.map(t=>e(t)+"")));if(r&&Iu(r)){const t=Pt(n.map(t=>({_cat:t})),"_cat",s);return e=>r[e]||t(e)}return Pt(n.map(t=>({_cat:t})),"_cat",s)}if(r&&Iu(r)){const n=Pt(t,e,s);return t=>r[t]||n(t)}return Pt(t,e,s)}if(r&&Iu(r)){const t=Pt([{_:"a"}],"_",s);return e=>r[e]||t(e)}},[t,e,n,o,i])}(C,o,i),Y=th(()=>{if(!o)return[];const t=new Set;for(const e of C){const n="function"==typeof o?o(e):e[o];null!=n&&t.add(n+"")}return Array.from(t)},[C,o]),G=th(()=>P&&T.length>0?T:Y,[P,T,Y]),X=function(t,e,n){const[o,i]=Zc(null),[r,s]=Zc(new Set),a=Uc(()=>new Set,[]),l=Kc(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=Kc(e=>{"isolate"===t&&s(t=>{const o=new Set(t);return o.has(e.label)?o.delete(e.label):o.add(e.label),o.size===n.length?new Set:o})},[t,n.length]),u=Uc(()=>{if(!t||"none"===t||!e)return null;const n="string"==typeof e?e:null;return"highlight"===t&&null!=o?{isActive:!0,predicate:t=>(n?t[n]:"function"==typeof e?e(t):null)===o}:"isolate"===t&&r.size>0?{isActive:!0,predicate:t=>{const o=n?t[n]:"function"==typeof e?e(t):null;return r.has(o)}}:null},[t,e,o,r]);return{highlightedCategory:"highlight"===t?o:null,isolatedCategories:"isolate"===t?r:a,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}(r,o,G),H=th(()=>B||(X.legendSelectionHook?X.legendSelectionHook:I),[B,X.legendSelectionHook,I]),V=function(t){const e=$(t=>t.theme.colors.selectionOpacity);return nh(()=>{if(void 0!==t||void 0!==e)return{name:t?.name??"",...t,unselectedOpacity:t?.unselectedOpacity??e}},[t,e])}(a),U=Fu(),K=su(),Z=th(()=>{if(j)return j;if(!o||0===G.length)return;const t=Array.isArray(i)&&i.length>0||"string"==typeof i&&i.length>0?i:U&&U.length>0?U:kt,e="__streamCat",n=Pt(G.map(t=>({[e]:t})),e,t);return t=>K?.[t]||n(t)||"#999"},[j,o,G,i,U,K]),{legend:Q,margin:J,legendPosition:tt}=Nu({data:C,colorBy:o,colorScale:Z,showLegend:p,legendPosition:s,userMargin:g,defaults:m,categories:G,additionalLegend:y}),et=th(()=>{const t={};return Q&&(t.legend=Q,t.legendPosition=tt),r&&"none"!==r&&(t.legendHoverBehavior=X.onLegendHover,t.legendClickBehavior=X.onLegendClick,t.legendHighlightedCategory=X.highlightedCategory,t.legendIsolatedCategories=X.isolatedCategories),P&&o&&(t.legendCategoryAccessor=o,t.onCategoriesChange=R),t},[Q,tt,r,X.onLegendHover,X.onLegendClick,X.highlightedCategory,X.isolatedCategories,P,o,R]),nt=Array.isArray(n)?q(n):n,ot=function(t,e,n,o){if(!t)return null;if(!1===o)return null;if(null!=o)return Hu("div",{style:{width:e,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:o});const i=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*i))),s=Math.max(6,Math.floor(n/(2.5*i))),a=Math.floor((n-(i*(r+s)-s))/2);return Hu("div",{style:{width:e,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:i},(t,n)=>Hu("div",{className:"semiotic-loading-bar",style:{...Zu,position:"absolute",top:a+n*(r+s),left:Math.floor(.1*e),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2}},n))})}(k,M,_,S),it=ot?null:function(t,e,n,o){return!1===o||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?Hu("div",{style:{...Ku,width:e,height:n},children:o||"No data available"}):null}(nt,M,_,A);return{data:C,colorScale:j,allCategories:G,legendState:X,effectiveSelectionHook:H,activeSelectionHook:I,customHoverBehavior:E,customClickBehavior:O,mobileInteraction:D,legend:Q,margin:J,legendPosition:tt,earlyReturn:ot||it||null,legendBehaviorProps:et,crosshairProps:W,resolvedSelection:V}}({data:dt,rawData:i,colorBy:ft,colorScheme:x,legendInteraction:U,legendPosition:K,selection:B,linkedHover:E,fallbackFields:ft?["string"==typeof ft?ft:""]:[],unwrapData:!1,onObservation:N,onClick:W,hoverHighlight:j,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"AreaChart",chartId:G,showLegend:rt,userMargin:r,marginDefaults:o.marginDefaults,loading:X,loadingContent:H,emptyContent:V,width:et,height:nt}),{effectiveData:gt,statisticalAnnotations:mt}=function(t){const{data:e,xAccessor:n,yAccessor:o,forecast:i,anomaly:r,groupBy:s}=t,a="string"==typeof n?n:dh,l="string"==typeof o?o:fh,c=ah(()=>{if(!i&&!r)return e;const t="function"==typeof n,s="function"==typeof o;return t||s?e.map(e=>{const i={...e};return t&&(i[dh]=n(e)),s&&(i[fh]=o(e)),i}):e},[e,i,r,n,o]),[u,h]=ch(null),[d,f]=ch([]),p=lh(i),y=lh(r);return sh(()=>{if(!i&&!r)return void((p.current||y.current)&&(h(null),f([]),p.current=i,y.current=r));let t=!1;const e=i!==p.current||r!==y.current;if(p.current=i,y.current=r,e&&(h(null),f([])),i){const e=s&&"string"==typeof s&&"object"==typeof i?{...i,_groupBy:s}:i;(async function(...t){return(await hh()).buildForecast(...t)})(c,a,l,e,r).then(e=>{t||(h(e),f(e.annotations))}).catch(()=>{t||(h(null),f([]))})}else r&&async function(...t){return(await hh()).buildAnomalyAnnotations(...t)}(r).then(e=>{t||(h(null),f(e))}).catch(()=>{t||f([])});return()=>{t=!0}},[c,i,r,a,l,s]),{effectiveData:u?u.processedData:e,statisticalAnnotations:d,hasForecast:!!u,xAccessorKey:a,yAccessorKey:l}}({data:dt,xAccessor:c,yAccessor:u,forecast:T,anomaly:L,groupBy:h}),xt=oe(()=>Rt(c,u),[c,u]),{flattenedData:bt,lineStyle:wt,pointStyle:St,defaultTooltipContent:At}=function(t){const{safeData:e,data:n,areaBy:o,lineDataAccessor:i,colorBy:r,colorScale:s,color:a,stroke:l,strokeWidth:c,opacity:u,effectiveSelectionHook:h,resolvedSelection:d,areaOpacity:f,showLine:p,lineWidth:y,showPoints:g,pointRadius:m,xAccessor:x,yAccessor:b,xLabel:v,yLabel:w,xFormat:k,yFormat:S,groupField:A,styleRules:M,ruleContext:_}=t,P=rh(()=>Y({data:n,safeData:e,areaBy:o,lineDataAccessor:i}),[n,e,o,i]),C=rh(()=>t=>{const e={};if(r){if(s){const n=Mt(t,r,s);e.fill=n,p?(e.stroke=n,e.strokeWidth=y):e.stroke="none"}}else{const t=a||vt;e.fill=t,p?(e.stroke=t,e.strokeWidth=y):e.stroke="none"}return e.fillOpacity=f,M&&M.length>0&&Object.assign(e,It(t,M,_?_(t):{value:void 0})),e},[r,s,a,f,p,y,M,_]),T=rh(()=>Tt(C,{stroke:l,strokeWidth:c,opacity:u}),[C,l,c,u]);return{flattenedData:P,lineStyle:rh(()=>{return t=T,n=d,(e=h??null)?(o,...i)=>{const r={...t(o,...i)};if(e.isActive)if(e.predicate(o))n?.selectedStyle&&Object.assign(r,n.selectedStyle);else{const t=n?.unselectedOpacity??.5;r.opacity=t,r.fillOpacity=t,r.strokeOpacity=t,n?.unselectedStyle&&Object.assign(r,n.unselectedStyle)}return r}:t;var t,e,n},[T,h,d]),pointStyle:rh(()=>{if(g)return t=>{const e={r:m,fillOpacity:1};return r?s&&(e.fill=Mt(t.parentLine||t,r,s)):e.fill=a||vt,e}},[g,m,r,s,a]),defaultTooltipContent:rh(()=>function(t){const e=t.find(t=>"title"===t.role),n=t.filter(t=>"title"!==t.role);return t=>{const o=t.data;if(!o)return null;const i=e?Cc(Tc(o,e.accessor),e.format):null;return Mc("div",{className:"semiotic-tooltip",style:Ut,children:[null!=i&&Ac("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0},children:i}),n.map((t,e)=>{const n=Cc(Tc(o,t.accessor),t.format);return Mc("div",{style:e>0?{marginTop:2}:void 0,children:[Mc("span",{style:{opacity:.7},children:[t.label,": "]}),Ac("span",{children:n})]},e)})]})}}([{label:v||_c(x),accessor:x,role:"x",format:k},{label:w||_c(b),accessor:b,role:"y",format:S},...A?[{label:_c(A),accessor:A,role:"group"}]:[],...Lc(t.band,S)]),[x,b,v,w,A,k,S,t.band])}}({safeData:gt,data:i,areaBy:h,lineDataAccessor:y,colorBy:ft,colorScale:yt.colorScale,color:Z,stroke:Q,strokeWidth:J,opacity:tt,effectiveSelectionHook:yt.effectiveSelectionHook,resolvedSelection:yt.resolvedSelection,areaOpacity:w,showLine:S,lineWidth:A,showPoints:M,pointRadius:_,xAccessor:c,yAccessor:u,xLabel:ut,yLabel:ht,xFormat:a,yFormat:l,groupField:h||m,band:R,styleRules:b,ruleContext:xt}),_t=g({componentName:"AreaChart",data:i,accessors:{xAccessor:c,yAccessor:u}}),Ct={chartType:"area",...null!=i&&{data:bt},xAccessor:c,yAccessor:u,groupAccessor:h||void 0,...d&&{y0Accessor:d},...R&&{band:R},...pt&&{gradientFill:pt},...k&&{lineGradient:k},curve:v,lineStyle:wt,...M&&St&&{pointStyle:St},size:[et,nt],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:yt.margin,showAxes:o.showAxes,xLabel:ut,yLabel:ht,xFormat:a,yFormat:l,enableHover:ot,...t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor},showGrid:it,...yt.legendBehaviorProps,...te({title:st,description:at,summary:lt,accessibleTable:ct,className:s,animate:t.animate,axisExtent:t.axisExtent,autoPlaceAnnotations:t.autoPlaceAnnotations}),..."multi"===P?{tooltipContent:t=>{const e=t.allSeries;if(!e||0===e.length)return Ht("div",{className:"semiotic-tooltip",style:Ut,children:Ht("div",{children:Zt(t.data?.value??t.data?.y)})});const n=t.xValue??t.data?.time??t.data?.x;return Vt("div",{className:"semiotic-tooltip",style:Ut,children:[null!=n&&Ht("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4},children:Zt(n)}),e.map((t,e)=>Vt("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"},children:[Ht("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:t.color,flexShrink:0}}),Ht("span",{style:{flex:1,fontSize:"0.85em"},children:t.group}),Ht("span",{style:{fontWeight:500,fontSize:"0.85em"},children:Zt(t.value)})]},e))]})},tooltipMode:"multi"}:ne({tooltip:P,defaultTooltipContent:At}),...ee({linkedHover:E,selection:B,onObservation:N,onClick:W,hoverHighlight:j,mobileInteraction:yt.mobileInteraction,customHoverBehavior:yt.customHoverBehavior,customClickBehavior:yt.customClickBehavior}),...(C&&C.length>0||mt.length>0)&&{annotations:[...C||[],...mt]},...z&&{xExtent:z},...D&&{yExtent:D},...yt.crosshairProps,...I};return yt.earlyReturn?yt.earlyReturn:_t?ph(Yu,{componentName:"AreaChart",message:_t,width:et,height:nt}):ph(Uu,{componentName:"AreaChart",width:et,height:nt,children:ph(Vc,{ref:n,...Ct})})}).displayName="AreaChart";var wh="__semiotic_resolvedX",kh="__semiotic_resolvedY",Sh="__compoundGroup";function Ah(t,e,n){const o=t[e],i=t[n];return null==o||null==i||Number.isNaN(o)||Number.isNaN(i)}function Mh(t,e,n,o,i){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=D(o.theme).colors.categorical,a=n??o.colorScheme??s,l="string"==typeof e?e:"__ssrAreaColorBy",c="function"==typeof e?r.map(t=>({...t,__ssrAreaColorBy:e(t)})):r,u=e?Pt(c,l,a):void 0,h=!1!==i.showLine,d="number"==typeof i.lineWidth?i.lineWidth:2,f="number"==typeof i.areaOpacity?i.areaOpacity:.7,p=Lt(i.yAccessor),y=i.styleRules;return(t,n)=>{const o=e&&u?Mt(t,e,u):"string"==typeof i.color?i.color:vt,r={fill:o,fillOpacity:f,stroke:h?o:"none",...h&&{strokeWidth:d}};return y?.length&&Object.assign(r,It(t,y,{value:p(t),category:n})),void 0!==i.stroke&&(r.stroke=i.stroke),void 0!==i.strokeWidth&&(r.strokeWidth=i.strokeWidth),void 0!==i.opacity&&(r.opacity=i.opacity),r}}function _h(t,e,n,o,i){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=D(o.theme).colors.categorical,a=n??o.colorScheme??s,l="string"==typeof e?e:"__ssrBubbleColorBy",c="function"==typeof e?r.map(t=>({...t,__ssrBubbleColorBy:e(t)})):r,u=e?Pt(c,l,a):void 0,h=i.sizeBy,d=Array.isArray(i.sizeRange)?i.sizeRange:[5,40],f=h?r.map(t=>"function"==typeof h?h(t):Number(t[h])).filter(Number.isFinite):[],p=f.length?S(f):void 0;return t=>({fill:e&&u?Mt(t,e,u):"string"==typeof i.color?i.color:vt,fillOpacity:"number"==typeof i.bubbleOpacity?i.bubbleOpacity:.6,r:h?Ct(t,h,d,p):d[0],stroke:i.stroke??i.bubbleStrokeColor??"white",strokeWidth:i.strokeWidth??i.bubbleStrokeWidth??1,...void 0!==i.opacity&&{opacity:i.opacity}})}function Ph(t,e,n,o,i){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=D(o.theme).colors.categorical,a=n??o.colorScheme??s,l="string"==typeof e?e:"__ssrScatterColorBy",c="function"==typeof e?r.map(t=>({...t,__ssrScatterColorBy:e(t)})):r,u=e?Pt(c,l,a):void 0,h=i.sizeBy,d=Array.isArray(i.sizeRange)?i.sizeRange:[3,15],f=h?r.map(t=>"function"==typeof h?h(t):Number(t[h])).filter(Number.isFinite):[],p=f.length?S(f):void 0,y=Rt(i.xAccessor,i.yAccessor),g=i.styleRules;return t=>{const n={fill:e&&u?Mt(t,e,u):"string"==typeof i.color?i.color:vt,fillOpacity:"number"==typeof i.pointOpacity?i.pointOpacity:.8,r:h?Ct(t,h,d,p):"number"==typeof i.pointRadius?i.pointRadius:5};return g?.length&&Object.assign(n,It(t,g,y(t))),void 0!==i.stroke&&(n.stroke=i.stroke),void 0!==i.strokeWidth&&(n.strokeWidth=i.strokeWidth),void 0!==i.opacity&&(n.opacity=i.opacity),n}}var Ch={frameType:"xy",buildProps:(t,e,n,o,i)=>({chartType:"scatter",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,sizeAccessor:i.sizeBy,sizeRange:i.sizeRange||[5,40],colorScheme:n,...o,pointStyle:o.pointStyle||_h(t,e,n,o,i),showLegend:o.showLegend??!!e})};function Th(t,e,n,o,i){if(!i.showPoints)return;const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=D(o.theme).colors.categorical,a=n??o.colorScheme??s,l="string"==typeof e?e:"__ssrPointColorBy",c="function"==typeof e?r.map(t=>({...t,__ssrPointColorBy:e(t)})):r,u=e?Pt(c,l,a):void 0,h="number"==typeof i.pointRadius?i.pointRadius:3;return t=>{const n=e&&u?Mt(t,e,u):"string"==typeof i.color?i.color:vt;return{r:h,fill:n,stroke:"none"}}}var Lh={frameType:"xy",buildProps:(t,e,n,o,i)=>{const r=e||i.lineBy,s=i.fillArea,a=Array.isArray(s)?"mixed":s?"area":"line",l=D(o.theme).colors.categorical,c=function(t,e,n,o,i){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=D(o.theme).colors.categorical,a=n??o.colorScheme??s,l="string"==typeof e?e:"__ssrLineColorBy",c="function"==typeof e?r.map(t=>({...t,__ssrLineColorBy:e(t)})):r,u=e?Pt(c,l,a):void 0,h=Rt(i.xAccessor,i.yAccessor),d=function(t){const{lineWidth:e=2,colorBy:n,colorScale:o,color:i,resolveStroke:r,fillArea:s,areaOpacity:a=.3,styleRules:l,ruleContext:c}=t;return(t,u)=>{const h={strokeWidth:e},d=!0===s||Array.isArray(s)&&null!=u&&s.includes(u);let f;return r?f=r(t,u):n?o&&(f=Mt(t,n,o)):f=i||vt,void 0!==f&&(h.stroke=f,d&&(h.fill=f,h.fillOpacity=a)),l?.length&&Object.assign(h,It(t,l,c?c(t,u):{value:void 0,category:u})),h}}({lineWidth:"number"==typeof i.lineWidth?i.lineWidth:2,colorBy:e,colorScale:u,color:"string"==typeof i.color?i.color:void 0,fillArea:i.fillArea,areaOpacity:"number"==typeof i.areaOpacity?i.areaOpacity:.3,styleRules:i.styleRules,ruleContext:h});return Tt(d,{stroke:"string"==typeof i.stroke?i.stroke:void 0,strokeWidth:"number"==typeof i.strokeWidth?i.strokeWidth:void 0,opacity:"number"==typeof i.opacity?i.opacity:void 0})}(t,r,n,o,i),u=function(t){const e=t.xAccessor||"x",n=t.yAccessor||"y",o=t.lineBy,i=t.colorBy||o;let r=Array.isArray(t.data)?q(t.data).filter(t=>!!t&&"object"==typeof t):[];const s=function(t,e,n){const o="function"==typeof e,i="function"==typeof n,r=o?wh:e,s=i?kh:n;return o||i?{xKey:r,yKey:s,rows:t.map(t=>{const r={...t};return o&&(r[wh]=e(t)),i&&(r[kh]=n(t)),r})}:{rows:t,xKey:r,yKey:s}}(r,e,n);r=s.rows;const a=s.xKey,l=s.yKey,c=Array.isArray(t.annotations)?[...t.annotations]:[];let u,h,d="string"==typeof o||"function"==typeof o?o:void 0,f=t.baseLineStyle;if(t.forecast){const e=o&&"string"==typeof o&&"object"==typeof t.forecast?{...t.forecast,_groupBy:o}:t.forecast,n=b(r,a,l,e,t.anomaly);if(r=n.processedData,c.push(...n.annotations),u=function(t,e,n){const o=n.upperBounds,i=n.lowerBounds;if(!o&&!i)return;const r="function"==typeof o?o:"string"==typeof o?t=>t[o]:null,s="function"==typeof i?i:"string"==typeof i?t=>t[i]:null;let a=1/0,l=-1/0;for(const n of t){const t=Number(n[e]);if(Number.isFinite(t)&&(a>t&&(a=t),t>l&&(l=t)),r){const t=r(n);null!=t&&Number.isFinite(t)&&(t>l&&(l=t),a>t&&(a=t))}if(s){const t=s(n);null!=t&&Number.isFinite(t)&&(a>t&&(a=t),t>l&&(l=t))}}return Number.isFinite(a)&&Number.isFinite(l)?[a,l]:void 0}(r,l,t.forecast),o&&"string"==typeof o?(r=r.map(t=>({...t,[Sh]:`${t[o]}__${t[m]||"observed"}`})),d=Sh):d=m,t.baseLineStyle){const e=v(e=>t.baseLineStyle(e),t.forecast);f=t=>e(t)}}else t.anomaly&&c.push(...x(t.anomaly));if(t.gapStrategy){if("function"==typeof d){const t=d;r=r.map(e=>({...e,__semiotic_gapGroup:t(e)})),d="__semiotic_gapGroup"}const e=function(t,e,n,o,i){const r=new Map;for(const e of t){const t=i?(e[i]??"")+"":"__single";r.has(t)||r.set(t,[]),r.get(t).push(e)}if("interpolate"===e){const t=[];for(const[,e]of r)for(const i of e)Ah(i,n,o)||t.push(i);return{rows:t,groupKey:i}}if("zero"===e){const t=[];for(const[,e]of r)for(const i of e)Ah(i,n,o)?t.push({...i,[o]:0}):t.push(i);return{rows:t,groupKey:i}}const s=[],a="_gapSegment";for(const[t,e]of r){let i=0,r=[];const l=()=>{if(0===r.length)return;const e="__single"===t?"__seg"+i:`${t}__seg${i}`;for(const t of r)s.push({...t,[a]:e});r=[],i++};for(const t of e)Ah(t,n,o)?l():r.push(t);l()}return{rows:s,groupKey:a}}(r,t.gapStrategy,a,l,"string"==typeof d?d:void 0);r=e.rows,e.groupKey&&(d=e.groupKey)}if(t.directLabel){const e=function(t,e,n,o,i,r,s,a){if(!e||!n)return{annotations:[]};const l="object"==typeof e?e:{},c=l.position||"end",u=l.fontSize||11,h="function"==typeof n?n:t=>t[n],d=new Map;for(const e of t){const t=h(e);if(null==t)continue;const n=t+"";""!==n&&(d.has(n)||d.set(n,[]),d.get(n).push(e))}const f=new Map;for(const[t,e]of d)e.sort((t,e)=>Number(t[o])-Number(e[o])),f.set(t,"end"===c?e[e.length-1]:e[0]);const p=Pt(Array.from(f.entries()).map(([t])=>({__lbl:t})),"__lbl",r??s),y=Array.from(f.entries()).map(([t,e])=>({type:"text",label:t,[o]:e[o],[i]:e[i],dx:"end"===c?6:-6,dy:0,color:p?Mt({__lbl:t},"__lbl",p):a||vt,fontSize:u}));y.sort((t,e)=>Number(t[i])-Number(e[i]));for(let t=1;y.length>t;t++){const e=y[t-1],n=y[t],o=Number(e[i])+e.dy;u+2>Math.abs(Number(n[i])+n.dy-o)&&(n.dy+=u+2)}const g=y.reduce((t,e)=>Math.max(t,(e.label+"").length*(.6*u)),0)+10;return{annotations:y,marginExtra:"end"===c?{right:g}:{left:g}}}(r,t.directLabel,"string"==typeof i||"function"==typeof i?i:void 0,a,l,t.colorScheme,t.themeCategorical,t.color);c.push(...e.annotations),h=e.marginExtra}return{data:r,xAccessor:"function"==typeof e?a:e,yAccessor:"function"==typeof n?l:n,groupAccessor:d,colorAccessor:i,annotations:c,lineStyle:f,yExtent:u,marginExtra:h}}({data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",lineBy:i.lineBy,colorBy:r,colorScheme:n,color:"string"==typeof i.color?i.color:void 0,forecast:i.forecast,anomaly:i.anomaly,gapStrategy:i.gapStrategy,directLabel:i.directLabel,annotations:o.annotations,themeCategorical:l,baseLineStyle:c}),h=o.pointStyle||Th(u.data,u.colorAccessor,n,o,i);let d=o.margin;u.marginExtra&&d&&"object"==typeof d?d={...d,...null!=u.marginExtra.right&&{right:Math.max(Number(d.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&{left:Math.max(Number(d.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==d&&(d={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});const f=(!i.directLabel||void 0!==o.showLegend)&&(o.showLegend??!!u.colorAccessor);return{chartType:a,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:n,lineStyle:u.lineStyle||c,...Array.isArray(s)&&{areaGroups:s},...s&&null!=i.areaOpacity&&{areaOpacity:i.areaOpacity},...null!=i.band&&{band:i.band},...o,...void 0!==d&&{margin:d},annotations:u.annotations,...u.yExtent&&!o.yExtent&&{yExtent:u.yExtent},...h&&{pointStyle:h},showLegend:f}}},Rh={frameType:"xy",buildProps:(t,e,n,o,i)=>{const r=Array.isArray(t)?q(t):[],s=i.timeAccessor||"time",a=i.valueAccessor||"value",l=i.categoryAccessor,c=i.valueExtent||o.yExtent,u="down"===i.direction?function({data:t,valueAccessor:e,timeAccessor:n,binSize:o,valueExtent:i,extentPadding:r}){if(i)return[i[1],i[0]];if(!t||0===t.length)return;const s=new Map;for(const i of t){const t=vh(i,n,"time"),r=vh(i,e,"value");if(null==t||null==r)continue;const a=Math.floor(t/o)*o;s.set(a,(s.get(a)??0)+r)}let a=0;for(const t of s.values())a=Math.max(a,t);return[a>0?a+a*(r??.1):1,0]}({data:r,timeAccessor:s,valueAccessor:a,binSize:Number(i.binSize),valueExtent:c,extentPadding:i.extentPadding}):c,h={...void 0!==i.fill&&{fill:i.fill},...void 0!==i.stroke&&{stroke:i.stroke},...void 0!==i.strokeWidth&&{strokeWidth:i.strokeWidth},...void 0!==i.opacity&&{opacity:i.opacity},...void 0!==i.gap&&{gap:i.gap}};return{chartType:"bar",data:r,...o,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,r.length),arrowOfTime:i.arrowOfTime||"right",timeAccessor:s,valueAccessor:a,xExtent:i.timeExtent||o.xExtent,yExtent:u,extentPadding:i.extentPadding??o.extentPadding,binSize:i.binSize,categoryAccessor:l,barColors:i.colors||o.barColors,colorScheme:i.colors||o.colorScheme,barStyle:o.barStyle||h,showLegend:o.showLegend??!!l}}},$h={frameType:"xy",buildProps:(t,e,n,o,i)=>{const r=e||i.areaBy,s=Y({data:t,safeData:Array.isArray(t)?q(t):[],areaBy:i.areaBy,lineDataAccessor:i.lineDataAccessor||"coordinates"}),a=i.semanticGradient,l=a&&a.length>0?{colorStops:gh(a)}:o.gradientFill,c=o.pointStyle||Th(s,r,n,o,i);return{chartType:"area",data:s,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",y0Accessor:i.y0Accessor,groupAccessor:i.areaBy||void 0,colorAccessor:r,colorScheme:n,...o,...void 0!==l&&{gradientFill:l},lineStyle:o.lineStyle||Mh(s,r,n,o,i),...c&&{pointStyle:c}}}},zh={frameType:"xy",buildProps:(t,e,n,o,i)=>{const r=i.xAccessor||"x",s=i.seriesAAccessor||"a",a=i.seriesBAccessor||"b",l=t=>xh(mh(r,"x",t)),c=t=>xh(mh(s,"a",t)),u=t=>xh(mh(a,"b",t)),h=i.seriesAColor||"var(--semiotic-danger, #dc2626)",d=i.seriesBColor||"var(--semiotic-info, #2563eb)",f=i.areaOpacity??.6,p=i.lineWidth??1.5,y=!1!==i.showLines,g=!1!==o.showLegend,m=i.seriesALabel||"A",x=i.seriesBLabel||"B",b=o.legendPosition||"right",v=function(t,e,n,o){if(!t.length)return[];const i=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];let s=0,a=null,l=null,c=[];const u=(t,e)=>t>e?"A":e>t?"B":null,h=t=>`seg-${s}-${t}`,d=t=>r.push(t),f=(t,e)=>{d({__x:t.x,__y:t.y,__y0:t.y,__diffSegment:h(e),__diffWinner:e,__valA:t.y,__valB:t.y,__sourceDatum:t.datum})};for(let t=0;i.length>t;t++){const r=i[t],p=e(r),y=n(r),g=o(r);if(!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(g))continue;const m=u(y,g);if(null!==m)if(null!=a){if(l&&l.w!==m){let t,e;if(c.length>0)t=c[0].x,e=c[0].y;else{const n=y-l.a-(g-l.b);if(0!==n){const o=Math.max(0,Math.min(1,(l.b-l.a)/n));t=l.x+o*(p-l.x),e=l.a+o*(y-l.a)}else t=l.x,e=l.a}d({__x:t,__y:e,__y0:e,__diffSegment:h(a),__diffWinner:a,__valA:e,__valB:e}),s++,a=m,d({__x:t,__y:e,__y0:e,__diffSegment:h(a),__diffWinner:a,__valA:e,__valB:e});for(let t=1;c.length>t;t++)f(c[t],a)}else for(const t of c)f(t,a);c=[],d({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:h(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),l={x:p,a:y,b:g,w:m}}else{a=m;for(const t of c)f(t,a);c=[],d({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:h(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),l={x:p,a:y,b:g,w:m}}else c.push({x:p,y:y,datum:r})}for(const t of c)f(t,a??"A");return r}(Array.isArray(t)?t:[],l,c,u),w=[];if(y&&Array.isArray(t)){const e=t.filter(t=>Number.isFinite(l(t))).sort((t,e)=>l(t)-l(e));for(const t of e){const e=l(t),n=c(t),o=u(t);Number.isFinite(n)&&w.push({__x:e,__y:n,__diffSegment:"line-A"}),Number.isFinite(o)&&w.push({__x:e,__y:o,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...v,...w],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(v.map(t=>t.__diffSegment))),areaStyle:t=>{const e=t.__diffSegment;return{fill:"A"==(e?.endsWith("-A")?"A":"B")?h:d,stroke:"none",fillOpacity:f}},lineStyle:t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?h:d,strokeWidth:p,fill:"none"}),curve:i.curve||"linear",...o,...g&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:t=>({fill:t.color||"currentColor"}),items:[{label:m,color:h},{label:x,color:d}]}]},legendPosition:b}}}},Dh={frameType:"xy",buildProps:(t,e,n,o,i)=>{const r=e||i.areaBy,s="string"==typeof r&&Array.isArray(t)?Pt(t,r,n):void 0,a="number"==typeof i.areaOpacity?i.areaOpacity:.7,l=o.lineStyle||(t=>{const e=null==r?void 0:Mt(t,r,s),n=i.showLine??!0,o={fill:i.color??e,stroke:n?i.stroke??e:"none",...n?{strokeWidth:i.strokeWidth??i.lineWidth??2}:{},fillOpacity:a,...null==i.opacity?{}:{opacity:i.opacity}},l=i.styleRules;if(l?.length){const e=Lt(i.yAccessor),n=r?"function"==typeof r?(r(t)??"")+"":(t[r]??"")+"":void 0;Object.assign(o,It(t,l,{value:e(t),category:n}))}return o}),c=i.normalize?"zero":i.baseline??"zero",u=o.pointStyle||Th(t,r,n,o,i);return{chartType:"stackedarea",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.areaBy,colorAccessor:r,colorScheme:n,normalize:i.normalize,baseline:c,stackOrder:i.stackOrder,lineStyle:l,...o,...u&&{pointStyle:u},curve:o.curve??i.curve??"monotoneX",showLegend:o.showLegend??!!r}}},Ih={frameType:"xy",buildProps:(t,e,n,o,i)=>{const[r]=o.size??[600,400];return{chartType:"candlestick",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.highAccessor||"high",highAccessor:i.highAccessor||"high",lowAccessor:i.lowAccessor||"low",openAccessor:i.openAccessor,closeAccessor:i.closeAccessor,candlestickStyle:i.candlestickStyle,...o,scalePadding:o.scalePadding??Math.max(2,Math.min(12,Math.round(r/40))),extentPadding:o.extentPadding??(r>200?.1:.02)}}},Bh={frameType:"xy",buildProps:(t,e,n,o,i)=>{const r=o.pointStyle||Ph(t,e,n,o,i),s=function(t,e,n){return t&&0!==t.length?(o,i)=>{const r=It(o,t,e(o,i)),s=n?n(o,i):void 0;return s?{...r,...s}:r}:n}(i.styleRules,Rt(i.xAccessor||"x",i.yAccessor||"y"),l),a=s?t=>({..."function"==typeof r?r(t):r,...s(t)}):r;var l;return{chartType:"scatter",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,sizeAccessor:i.sizeBy,...i.symbolBy&&{symbolAccessor:i.symbolBy},...i.symbolMap&&{symbolMap:i.symbolMap},colorScheme:n,...o,sizeRange:i.sizeRange||[3,15],pointStyle:a,showLegend:o.showLegend??!!e}}},Fh={frameType:"xy",buildProps:(t,e,n,o,i)=>{const r=i.xCenter,s=i.yCenter,a=i.quadrants,l=i.centerlineStyle||{},c=!1!==i.showQuadrantLabels,u=i.quadrantLabelSize??12,h=l.stroke||"#999",d=l.strokeWidth??1,f=Array.isArray(l.strokeDasharray)?l.strokeDasharray.join(","):l.strokeDasharray,p=j.createElement,y=a?[(t,e,n)=>{if(!e?.x||!e?.y)return null;const o=n.width,i=n.height,l=null!=r?e.x(r):o/2,y=null!=s?e.y(s):i/2;if(null!=r&&!Number.isFinite(l))return null;if(null!=s&&!Number.isFinite(y))return null;const g=Math.max(0,Math.min(o,l)),m=Math.max(0,Math.min(i,y)),x=[{c:a.topLeft,x:0,y:0,w:g,h:m},{c:a.topRight,x:g,y:0,w:o-g,h:m},{c:a.bottomLeft,x:0,y:m,w:g,h:i-m},{c:a.bottomRight,x:g,y:m,w:o-g,h:i-m}],b=c?[p("text",{key:"ltl",x:8,y:8+u,fill:a.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.topLeft.label),p("text",{key:"ltr",x:o-8,y:8+u,fill:a.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.topRight.label),p("text",{key:"lbl",x:8,y:i-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.bottomLeft.label),p("text",{key:"lbr",x:o-8,y:i-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return p(j.Fragment,null,...x.map((t,e)=>t.w>0&&t.h>0?p("rect",{key:"qf-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.c.color,opacity:t.c.opacity??.08}):null),p("line",{key:"vc",x1:g,y1:0,x2:g,y2:i,stroke:h,strokeWidth:d,strokeDasharray:f}),p("line",{key:"hc",x1:0,y1:m,x2:o,y2:m,stroke:h,strokeWidth:d,strokeDasharray:f}),...b)}]:void 0;return{chartType:"scatter",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,sizeAccessor:i.sizeBy,sizeRange:i.sizeRange||[3,15],colorScheme:n,pointStyle:o.pointStyle||i.pointStyle||Ph(t,e,n,o,i),...o,showLegend:o.showLegend??!!e,...y&&{svgPreRenderers:y}}}},Eh={frameType:"xy",buildProps:(t,e,n,o,i)=>{const r=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const n=e.xAccessor||"x",o=e.yAccessor||"y",i=e.orderAccessor?[...t].sort((t,n)=>null==t||"object"!=typeof t?1:null==n||"object"!=typeof n?-1:xh(mh(e.orderAccessor,"order",t))-xh(mh(e.orderAccessor,"order",n))):t,r=new WeakMap;let s=0;for(const t of i){if(null==t||"object"!=typeof t)continue;const e=xh(mh(n,"x",t)),i=xh(mh(o,"y",t));Number.isFinite(e)&&Number.isFinite(i)&&s++}let a=0;for(const t of i){if(null==t||"object"!=typeof t)continue;const e=xh(mh(n,"x",t)),i=xh(mh(o,"y",t));Number.isFinite(e)&&Number.isFinite(i)&&r.set(t,{idx:a++,total:s})}return{data:i,orderMap:r}}(t,i),s=i.pointRadius??4;return{chartType:"scatter",data:r.data,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,colorScheme:n,pointStyle:t=>{const e=r.orderMap.get(t),n=e?.idx??0,o=e?.total??1;return{fill:o>0?bh(n,o):"#6366f1",stroke:"white",strokeWidth:1,r:s,fillOpacity:1}},...o,svgPreRenderers:[t=>{const e=t.filter(t=>"point"===t.type&&"number"==typeof t.x&&"number"==typeof t.y);if(2>e.length)return null;const n=[];for(let t=0;e.length-1>t;t++){const o=e[t],i=e[t+1],r=bh(t,e.length);100>e.length&&n.push(j.createElement("line",{key:"halo-"+t,x1:o.x,y1:o.y,x2:i.x,y2:i.y,stroke:"white",strokeWidth:s+2,strokeLinecap:"round",opacity:.5})),n.push(j.createElement("line",{key:"segment-"+t,x1:o.x,y1:o.y,x2:i.x,y2:i.y,stroke:r,strokeWidth:s,strokeLinecap:"round"}))}return j.createElement(j.Fragment,null,...n)}]}}};function Oh(t){return Math.max(0,Math.min(1,t))}function Nh(t){const e=t.trim();if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t.split("").map(t=>t+t).join("")),6===t.length&&/^[0-9a-f]{6}$/i.test(t))return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const n=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(n){const t=[Number(n[1]),Number(n[2]),Number(n[3])];if(t.every(Number.isFinite))return t}return null}function Wh(t,e,n){const o=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(n)}`}function jh(t,e){const n=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Oh(t.offset),color:t.color})).sort((t,e)=>t.offset-e.offset);if(0===n.length)return"#999999";if(1===n.length)return n[0].color;const o=Oh(e);if(n[0].offset>=o)return n[0].color;if(o>=n[n.length-1].offset)return n[n.length-1].color;for(let t=0;n.length-1>t;t++){const e=n[t],i=n[t+1];if(e.offset>o||o>i.offset)continue;const r=i.offset-e.offset,s=r>0?(o-e.offset)/r:0,a=Nh(e.color),l=Nh(i.color);if(!a||!l)return.5>s?e.color:i.color;const[c,u,h]=a,[d,f,p]=l;return Wh(c+(d-c)*s,u+(f-u)*s,h+(p-h)*s)}return n[n.length-1].color}function Yh(t,e,n){return null==n?`${t}-${e}`:`${t}-${e}-${n}`}import{Fragment as Gh,jsx as qh,jsxs as Xh}from"react/jsx-runtime";function Hh(t=240){const e=360-t,n=180+e/2,o=n*Math.PI/180;return{sweepRad:t*Math.PI/180,gapDeg:e,startAngleDeg:n,startAngleRad:o,offsetRad:-Math.PI/2+o}}import{useMemo as Vh,useCallback as Uh,useRef as Kh}from"react";var Zh={RdBu:ht,PiYG:dt,PRGn:ft,BrBG:pt,RdYlBu:yt,RdYlGn:gt,Spectral:mt},Qh="__likert_neutral_neg",Jh="__likert_neutral_pos";function td(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}import*as ed from"react";function nd(t){return!0===t?{topOpacity:.8,bottomOpacity:.05}:!1===t?void 0:t}function od(t,e,n,o,i){const r=D(o.theme).colors.categorical,s=n??o.colorScheme,a=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],l="string"==typeof e?e:"__ssrColorBy",c="function"==typeof e?a.map(t=>({...t,__ssrColorBy:e(t)})):a,u=e?Pt(c,l,s??r):void 0,h=Eu("string"==typeof i.color?i.color:void 0,r,s,void 0,new Map),d=Lt(i.valueAccessor),f=i.styleRules,p=o.pieceStyle;return(t,n)=>{const o={fill:e&&u?Mt(t,e,u):h};return f?.length&&Object.assign(o,It(t,f,{value:d(t),category:n})),"function"==typeof p?Object.assign(o,p(t,n)||{}):p&&"object"==typeof p&&Object.assign(o,p),void 0!==i.stroke&&(o.stroke=i.stroke),void 0!==i.strokeWidth&&(o.strokeWidth=i.strokeWidth),void 0!==i.opacity&&(o.opacity=i.opacity),o}}function id(t,e,n,o,i){const r=od(t,e,n,o,i);return(t,e)=>{const n=r(t,e);return void 0===n.fillOpacity&&(n.fillOpacity=.8),void 0===n.stroke&&(n.stroke=n.fill),n}}function rd(t,e,n,o,i){const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s="string"==typeof e?e:"__ssrViolinColorBy",a="function"==typeof e?r.map(t=>({...t,__ssrViolinColorBy:e(t)})):r,l=D(o.theme).colors.categorical,c=n??o.colorScheme,u=e?Pt(a,s,c??l):void 0,h=Eu("string"==typeof i.color?i.color:void 0,l,c,void 0,new Map);return t=>{const n=e&&u?Mt(t,e,u):h;return{fill:n,fillOpacity:.6,stroke:i.stroke??n,...void 0!==i.strokeWidth&&{strokeWidth:i.strokeWidth},...void 0!==i.opacity&&{opacity:i.opacity}}}}function sd(t,e,n,o,i){const r=od(t,e,n,o,i),s="number"==typeof i.dotRadius?i.dotRadius:5;return(t,e)=>({r:s,fillOpacity:.8,...r(t,e)})}function ad(t,e,n,o,i){const r=od(t,e,n,o,i),s=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],a=i.sizeBy,l=Array.isArray(i.sizeRange)?i.sizeRange:[3,8],c=a?s.map(t=>"function"==typeof a?a(t):Number(t[a])).filter(Number.isFinite):[],u=c.length?S(c):void 0,h="number"==typeof i.pointRadius?i.pointRadius:4,d="number"==typeof i.pointOpacity?i.pointOpacity:.7;return(t,e)=>({r:a?Ct(t,a,l,u):h,fillOpacity:d,...r(t,e)})}var ld={frameType:"ordinal",buildProps:(t,e,n,o,i)=>({chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"horizontal"===i.orientation?"horizontal":"vertical",oSort:i.sort??!1,colorAccessor:e,colorScheme:n,barPadding:i.barPadding,...null!=i.roundedTop&&{roundedTop:i.roundedTop},...o,gradientFill:nd(o.gradientFill),pieceStyle:od(t,e,n,o,i)})},cd={frameType:"ordinal",buildProps:(t,e,n,o,i)=>{const r=e||i.stackBy;return{chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.stackBy,colorAccessor:r,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical",normalize:i.normalize,oSort:i.sort??!1,barPadding:i.barPadding,...null!=i.roundedTop&&{roundedTop:i.roundedTop},...o,gradientFill:nd(o.gradientFill),pieceStyle:od(t,r,n,o,i),showLegend:o.showLegend??!!r}}},ud={frameType:"ordinal",buildProps:(t,e,n,o,i)=>{const r=e||i.groupBy;return{chartType:"clusterbar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",groupBy:i.groupBy,colorAccessor:r,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical",oSort:i.sort??!1,barPadding:i.barPadding,...null!=i.roundedTop&&{roundedTop:i.roundedTop},...o,gradientFill:nd(o.gradientFill),pieceStyle:od(t,r,n,o,i),showLegend:o.showLegend??!!r}}},hd={frameType:"ordinal",buildProps:(t,e,n,o,i)=>{const r=e||i.categoryAccessor;return{chartType:"pie",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"radial",colorAccessor:r,colorScheme:n,...null!=i.cornerRadius&&{cornerRadius:i.cornerRadius},...null!=i.startAngle&&{startAngle:i.startAngle},...o,pieceStyle:od(t,r,n,o,i),showLegend:o.showLegend??!!r}}},dd={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(t,e,n,o,i)=>{const r=e||i.categoryAccessor;return{chartType:"donut",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"radial",margin:o.margin??{top:50,right:40,bottom:60,left:70},innerRadius:i.innerRadius??60,colorAccessor:r,colorScheme:n,...null!=i.cornerRadius&&{cornerRadius:i.cornerRadius},...null!=i.startAngle&&{startAngle:i.startAngle},...o,pieceStyle:od(t,r,n,o,i)}}},fd={frameType:"ordinal",buildProps:(t,e,n,o,i)=>{const r=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=i.valueAccessor||"value",a=r.map(t=>Number("function"==typeof s?s(t):t[s])).filter(Number.isFinite),l=a.length?[Math.min(...a),Math.max(...a)]:void 0;return{chartType:"histogram",data:t,oAccessor:i.categoryAccessor||(t=>null==t.category?"All":t.category+""),rAccessor:s,projection:"horizontal",bins:i.bins??25,normalize:i.relative??!1,colorAccessor:e,colorScheme:n,barPadding:i.categoryPadding??20,...i.valueExtent?{rExtent:i.valueExtent}:l?{rExtent:l}:{},...o,summaryStyle:id(t,e,n,o,i)}}},pd={frameType:"ordinal",buildProps:(t,e,n,o,i)=>({chartType:"boxplot",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorAccessor:e,colorScheme:n,...null!=i.showOutliers&&{showOutliers:i.showOutliers},...null!=i.outlierRadius&&{outlierRadius:i.outlierRadius},...o,summaryStyle:o.summaryStyle||id(t,e,n,o,i)})},yd={frameType:"ordinal",buildProps:(t,e,n,o,i)=>({chartType:"violin",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorAccessor:e,projection:"horizontal"===i.orientation?"horizontal":"vertical",bins:i.bins??25,showIQR:i.showIQR??!0,barPadding:i.categoryPadding??20,colorScheme:n,...o,summaryStyle:o.summaryStyle||rd(t,e,n,o,i),showLegend:o.showLegend??!!e,...i.valueExtent&&{rExtent:i.valueExtent}})},gd={frameType:"ordinal",buildProps:(t,e,n,o,i)=>({chartType:"swarm",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorAccessor:e,...i.symbolBy&&{symbolAccessor:i.symbolBy},...i.symbolMap&&{symbolMap:i.symbolMap},colorScheme:n,...o,sizeRange:i.sizeRange||[3,8],pieceStyle:o.pieceStyle||ad(t,e,n,o,i),showLegend:o.showLegend??!!e})},md={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(t,e,n,o,i)=>({chartType:"point",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorAccessor:e,colorScheme:n,projection:"vertical"===i.orientation?"vertical":"horizontal",oSort:i.sort??"auto",barPadding:i.categoryPadding??10,...o,pieceStyle:sd(t,e,n,o,i),showGrid:o.showGrid??!0,showLegend:o.showLegend??!!e})},xd={frameType:"ordinal",buildProps:(t,e,n,o,i)=>{const r=e||i.subcategoryAccessor;return{chartType:"swimlane",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.subcategoryAccessor,colorAccessor:r,categoryAccessor:i.categoryAccessor,subcategoryAccessor:i.subcategoryAccessor,colorScheme:n,projection:"vertical"===i.orientation?"vertical":"horizontal",...null!=i.trackFill&&{trackFill:i.trackFill},...i.valueExtent&&{rExtent:i.valueExtent},...null!=i.roundedTop&&{roundedTop:i.roundedTop},...o,gradientFill:nd(o.gradientFill),pieceStyle:o.pieceStyle||od(t,r,n,o,i),showLegend:o.showLegend??!!r,barPadding:i.barPadding??40}}},bd={frameType:"ordinal",buildProps:(t,e,n,o,i)=>({chartType:"ridgeline",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorAccessor:e,colorScheme:n,projection:"vertical"===i.orientation?"vertical":"horizontal",bins:i.bins??20,amplitude:i.amplitude??1.5,barPadding:i.categoryPadding??5,oSort:i.oSort??!1,...o,summaryStyle:o.summaryStyle||((r,s)=>({fillOpacity:.5,...od(t,e,n,o,i)(r,s)})),showLegend:o.showLegend??!!e})},vd={frameType:"ordinal",layout:{margin:(t,e)=>({...e.marginDefaults,left:"vertical"===t.orientation?e.marginDefaults.left:Math.max(100,e.marginDefaults.left)})},buildProps:(t,e,n,o,i)=>{const r=Array.isArray(i.levels)&&i.levels.length>=2?i.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],s="vertical"!==i.orientation;let a=function(t,e,n,o,i,r){const s=new Map,a=new Set(e);for(const l of t){const t=n(l);s.has(t)||s.set(t,new Map);const c=s.get(t);if(o){const t=o(l);if(null==t||!Number.isFinite(t))continue;if(!Number.isInteger(t)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",t);continue}const n=t-1;if(0>n||n>=e.length)continue;const i=e[n];c.set(i,(c.get(i)||0)+1)}else if(i&&r){const t=i(l),e=r(l);if(!a.has(t))continue;c.set(t,(c.get(t)||0)+(Number.isFinite(e)?e:0))}}const l=[];for(const[t,n]of s){let o=0;for(const t of e)o+=n.get(t)||0;if(0!==o)for(let i=0;e.length>i;i++){const r=e[i],s=n.get(r)||0;l.push({__likertCategory:t,__likertLevel:r,__likertLevelLabel:r,__likertCount:s,__likertPct:s/o*100,__likertLevelIndex:i})}}return l}(Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],r,td(i.categoryAccessor,"question"),i.levelAccessor?null:td(i.valueAccessor,"score"),i.levelAccessor?td(i.levelAccessor,"level"):null,i.levelAccessor?td(i.countAccessor,"count"):null);s&&(a=function(t,e){const n=e.length,o=n%2!=0,i=Math.floor(n/2),r=new Map;for(const e of t){const t=r.get(e.__likertCategory)||[];t.push(e),r.set(e.__likertCategory,t)}const s=[];for(const[,t]of r){const e=new Map;let r,a;for(const n of t)n.__likertLevel===Qh?r=n:n.__likertLevel===Jh?a=n:e.set(n.__likertLevelIndex,n);o&&r&&s.push(r);for(let t=i-1;t>=0;t--){const n=e.get(t);n&&s.push(n)}o&&a&&s.push(a);for(let t=o?i+1:i;n>t;t++){const n=e.get(t);n&&s.push(n)}}return s}(function(t,e){const n=e.length,o=n%2!=0,i=Math.floor(n/2),r=[];for(const e of t){const t=e.__likertLevelIndex;if(o&&t===i){const t=e.__likertPct/2;r.push({...e,__likertLevel:Qh,__likertPct:-t}),r.push({...e,__likertLevel:Jh,__likertPct:t})}else r.push(i>t?{...e,__likertPct:-e.__likertPct}:e)}return r}(a,r),r));const l=D(o.theme).colors.diverging,c=Array.isArray(n)&&n.length>=r.length?n:function(t,e){if(0>=t)return[];if(e){const n=Zh[e];if(n){if(1===t)return[n(.5)];const e=[];for(let o=0;t>o;o++)e.push(n(o/(t-1)));return e}}const n=["#da1e28","#ff8389","#ffb3b8"],o=["#a6c8ff","#4589ff","#0043ce"],i="#a8a8a8";if(1===t)return[i];const r=t%2!=0,s=Math.floor(t/2),a=[];for(let t=0;s>t;t++)a.push(n[Math.min(Math.floor(t*n.length/s),n.length-1)]);r&&a.push(i);for(let t=0;s>t;t++)a.push(o[Math.min(Math.floor(t*o.length/s),o.length-1)]);return a}(r.length,l),u=new Map(r.map((t,e)=>[t,c[e]||"#888"])),h=r.length%2&&u.get(r[Math.floor(r.length/2)])||"#888",d="function"==typeof i.valueFormat?i.valueFormat:t=>Math.abs(Number(t)).toFixed(0)+"%",f=Qi(!1===o.showLegend?void 0:{legendGroups:[{label:"",items:r.map(t=>({label:t})),styleFn:t=>({fill:u.get(t.label)||"#888"})}]},o.legend);return{chartType:"bar",data:a,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:s?"horizontal":"vertical",barPadding:i.barPadding,showGrid:o.showGrid,oLabel:i.categoryLabel,rLabel:i.valueLabel||(s?void 0:"Percentage"),rFormat:d,...i.categoryFormat&&{oFormat:i.categoryFormat},...i.valueExtent&&{rExtent:i.valueExtent},...o,pieceStyle:t=>{const e=t.__likertLevel||t.data?.__likertLevel;return{fill:e===Qh||e===Jh?h:u.get((t.__likertLevelLabel||t.data?.__likertLevelLabel||e)+"")||"#888"}},showLegend:o.showLegend??!0,legendPosition:o.legendPosition||"right",...f&&{legend:f},__legendIncludesAutomatic:!0}}},wd={frameType:"ordinal",layout:{margin:(t,e)=>"vertical"===t.orientation?{top:e.title?60:40,right:20,bottom:60,left:60}:{top:e.title?40:10,right:10,bottom:10,left:10}},buildProps:(t,e,n,o,i)=>{const r="vertical"===i.orientation,s=e||i.categoryAccessor;return{chartType:r?"bar-funnel":"funnel",data:t,oAccessor:i.stepAccessor||"step",rAccessor:i.valueAccessor||"value",colorAccessor:s,categoryAccessor:i.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,...!r&&null!=i.connectorOpacity&&{connectorOpacity:i.connectorOpacity},barPadding:r?40:0,colorScheme:n,...o,showAxes:r,showGrid:r,pieceStyle:od(t,s,n,o,i),showLabels:i.showLabels??!0}}},kd={frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(t,{theme:e}){const n=t.__gauge;if(!n)return null;const o=(n.startAngleDeg+(n.gMax===n.gMin?0:(Math.max(n.gMin,Math.min(n.gMax,n.value??n.gMin))-n.gMin)/(n.gMax-n.gMin))*n.sweep-90)*Math.PI/180,i=n.needleColor||e.colors.text,r=n.showScaleLabels?(n.thresholds||[]).filter(t=>t.value>n.gMin&&n.gMax>t.value):[];return Xh(Gh,{children:[n.showNeedle&&Xh(Gh,{children:[qh("line",{x1:n.centerX,y1:n.centerY,x2:n.centerX+n.needleLength*Math.cos(o),y2:n.centerY+n.needleLength*Math.sin(o),stroke:i,strokeWidth:2.5,strokeLinecap:"round"}),qh("circle",{cx:n.centerX,cy:n.centerY,r:4,fill:i})]}),null!=n.contextValue&&qh("text",{x:n.centerX,y:n.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:n.valueFontSize,fontWeight:700,fill:i,children:n.contextValue}),r.map((t,o)=>{const i=(n.startAngleDeg+(n.gMax===n.gMin?0:(t.value-n.gMin)/(n.gMax-n.gMin))*n.sweep-90)*Math.PI/180,r=n.innerRadius-1,s=n.radius+1,a=n.radius+10,l=((i+Math.PI/2)/(2*Math.PI)*12+12)%12,c=l>=11||1>l?"middle":5>l?"start":7>l?"middle":"end",u=l>=11||1>l?"auto":5>l?"middle":7>l?"hanging":"middle";return Xh("g",{children:[qh("line",{x1:n.centerX+Math.cos(i)*r,y1:n.centerY+Math.sin(i)*r,x2:n.centerX+Math.cos(i)*s,y2:n.centerY+Math.sin(i)*s,stroke:e.colors.border,strokeWidth:2,strokeLinecap:"round"}),qh("text",{x:n.centerX+Math.cos(i)*a,y:n.centerY+Math.sin(i)*a,textAnchor:c,dominantBaseline:u,fill:e.colors.textSecondary,fontSize:10,children:t.label||t.value+""})]},"gauge-label-"+o)})]})},buildProps:(t,e,n,o,i)=>{const r=i.min??0,s=i.max??100,a=i.sweep??240,l=i.arcWidth??.3,c=!1!==i.showNeedle,u=!1!==i.fillZones,{startAngleDeg:h}=Hh(a),d=i.thresholds||[{value:s,color:i.color||"#4e79a7"}],f=o.gradientFill,p=function(t){const{min:e,max:n,value:o,thresholds:i,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=t,h=n-e||1,d=(Math.max(e,Math.min(n,o))-e)/h;let f=i&&i.length>0?[...i].sort((t,e)=>t.value-e.value):[{value:n,color:r||"#007bff"}];f=f.map(t=>({...t,value:Math.max(e,Math.min(n,t.value))})),n>f[f.length-1].value&&f.push({value:n,color:f[f.length-1].color});const p=!!c&&c.colorStops.length>=2,y=[],g=new Map,m=[];if(p){const t=a?d:1,e=Yh("bg",0);if(y.push({category:e,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),g.set(e,{fill:s,opacity:.4}),t>0){const e=Math.max(1,Math.floor(u)),n=Math.max(1,Math.min(e,Math.round(t*e))),o=[];for(let e=0;n>e;e++)o.push(jh(c.colorStops,t*(e+.5)/n));const i=Yh("fill",0);y.push({category:i,value:t,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:t,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:o}}),g.set(i,{fill:o[0]||s})}}else{let t=e;for(let n=0;f.length>n;n++){const o=f[n],i=(o.value-t)/h,r=(t-e)/h,l=(o.value-e)/h,c=Math.max(0,(a?Math.min(d,l):l)-r),u=a?Math.max(0,i-c):0;if(c>0){const t=Yh("fill",n);y.push({category:t,value:c,_zone:o.label||"Zone "+(n+1),_isFill:!0}),g.set(t,{fill:o.color})}if(u>0){const t=Yh("bg",n);y.push({category:t,value:u,_zone:o.label||"Zone "+(n+1),_isFill:!1}),g.set(t,{fill:s,opacity:.4})}t=o.value}}if(l&&i&&i.length>0)for(const t of i)t.value>e&&n>t.value&&m.push({type:"gauge-label",value:t.value,label:t.label||t.value+""});return{gaugeData:y,pieceStyle:(t,e)=>g.get(e||t.category)||{fill:s},gaugeAnnotations:m}}({min:r,max:s,value:i.value,thresholds:d,fillColor:i.color,backgroundColor:i.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:!1!==i.showScaleLabels,gradientFill:f&&"object"==typeof f&&"colorStops"in f?f:void 0}),[y,g]=o.size||[300,250],m=function(t=240){const{sweepRad:e,offsetRad:n}=Hh(t),o=[[Math.cos(n),Math.sin(n)],[Math.cos(n+e),Math.sin(n+e)],[0,0]];for(let t=0;2*Math.PI>t;t+=Math.PI/2)((t-n)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>e+.001||o.push([Math.cos(t),Math.sin(t)]);const i=o.map(t=>t[0]),r=o.map(t=>t[1]),[s,a]=S(i),[l,c]=S(r);return{minX:s,maxX:a,minY:l,maxY:c,width:a-s,height:c-l,cx:(s+a)/2,cy:(l+c)/2}}(a),x=Math.min(10,Math.max(1,Math.min(y,g)/12)),b=Math.max(4,Math.min((y-2*x)/m.width,(g-2*x)/m.height)-2),v=Math.max(0,Math.min(b-1.5,b*(1-l))),w=y/2-m.cx*b,k=g/2-m.cy*b,A=2*(b+4),M=Math.max(r,Math.min(s,i.value??r)),_="function"==typeof i.valueFormat?i.valueFormat(M):Math.round(M)+"",P=i.centerContent??o.centerContent,C=null!=P?"function"==typeof P?P(M,r,s):P:"sparkline"===i.mode||"context"===i.mode?void 0:ed.createElement("div",{style:{textAlign:"center",lineHeight:1.2}},ed.createElement("div",{style:{fontSize:Math.max(16,.3*b),fontWeight:700,color:"var(--semiotic-text, #333)"}},_),!1!==i.showScaleLabels&&ed.createElement("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"}},`${r} – ${s}`));return{chartType:"donut",data:p.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:v,sweepAngle:a,startAngle:h,oSort:!1,pieceStyle:p.pieceStyle,...null!=i.cornerRadius&&{cornerRadius:i.cornerRadius},...o,size:[y,g],margin:{top:k-A/2,bottom:g-k-A/2,left:w-A/2,right:y-w-A/2},...null!=C&&{centerContent:C},showAxes:!1,annotations:[...Array.isArray(o.annotations)?o.annotations:[],...p.gaugeAnnotations],__gauge:{gMin:r,gMax:s,sweep:a,arcWidth:l,value:M,startAngleDeg:h,thresholds:d,centerX:w,centerY:k,radius:b,innerRadius:v,showScaleLabels:!1!==i.showScaleLabels,needleLength:v>20?v-8:b-1,showNeedle:c,needleColor:i.needleColor,..."context"===i.mode&&null==P&&{contextValue:_,contextValueY:k-.2*v,valueFontSize:Math.max(12,Math.min(22,.28*b))}}}}};import{scaleTime as Sd}from"d3-scale";function Ad(t){return"invalid-node-time"===t.kind?`node ${t.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===t.kind?`edge ${t.id} has an invalid startTime or endTime`:"invalid-domain"===t.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===t.kind?`edge ${t.id} must have a positive finite value`:"missing-node"===t.kind?`edge ${t.id} references missing ${t.endpoint} node "${t.nodeId}"`:"backward-edge"===t.kind?`edge ${t.id} (${t.source}->${t.target}) ends before it starts`:t.kind}function Md(t,e,n){const o=e.incoming[t.id],i=e.outgoing[t.id],r=[];for(const t of o)r.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:n.get(t.id).targetSide});for(const t of i)r.push({time:t.startTime,delta:-t.value,edge:t,kind:"out",side:n.get(t.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((t,e)=>t.time-e.time||(s[t.kind]??99)-(s[e.kind]??99))},l=r.length?k(r.map(t=>t.time)):null,c=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[0])?t.xExtent[0]:null,u=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,h=[...new Set(r.map(t=>t.time))].sort((t,e)=>t-e),d=new Map;for(let t=1;h.length>t;t++)d.set(h[t],h[t-1]);const f=t=>{const e=d.get(t);return null!=e?(e+t)/2:null!=u?u:t};a();const p=[];let y=0,g=0;for(const t of r)if("out"===t.kind){const e=Math.abs(t.delta);let n=e-("top"===t.side?y:g);if(n>0){const e="top"===t.side?"bot":"top",o=Math.min(n,"top"===e?y:g);if(o>0){const i=f(t.time);p.push({time:i,delta:-o,kind:"transfer-out",side:e}),p.push({time:i,delta:+o,kind:"transfer-in",side:t.side}),"top"===e?y-=o:g-=o,"top"===t.side?y+=o:g+=o,n-=o}n>0&&null!==u&&(p.push({time:u,delta:+n,kind:"create",side:t.side}),"top"===t.side?y+=n:g+=n)}"top"===t.side?y-=e:g-=e}else if("in"===t.kind){const e=Math.abs(t.delta);"top"===t.side?y+=e:g+=e}r.push(...p),a();let m=0,x=0,b=0,v=0,w=0;const S=[],A=new Map;for(const t of r){if(S.push({t:t.time,topMass:m,botMass:x}),("in"===t.kind||"out"===t.kind)&&t.edge){const e="top"===t.side?m:x;A.set(t.edge.id,{side:t.side,time:t.time,sideMassBefore:e,sideMassAfter:e+t.delta,kind:t.kind,value:Math.abs(t.delta)})}"top"===t.side?m+=t.delta:x+=t.delta,m+x>b&&(b=m+x),m>v&&(v=m),x>w&&(w=x),S.push({t:t.time,topMass:m,botMass:x})}const M=[];let _=0;for(;S.length>_;){let t=_;for(;S.length>t+1&&S[t+1].t===S[_].t;)t++;M.push(S[_]);for(let e=_+1;t>=e;e++){const t=M[M.length-1];S[e].topMass===t.topMass&&S[e].botMass===t.botMass||M.push(S[e])}_=t+1}const P=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;let C=null;for(const t of i)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===C||C>t.systemInTime)&&(C=t.systemInTime);let T=null;for(const t of o)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===T||t.systemOutTime>T)&&(T=t.systemOutTime);if(M.length>0){const t=M[M.length-1],e=Math.max(null!=P?P:-1/0,null!=T?T:-1/0);Number.isFinite(e)&&e>t.t&&t.topMass+t.botMass>0&&M.push({t:e,topMass:t.topMass,botMass:t.botMass});const n=M[0],o=Math.min(null!=c?c:1/0,null!=C?C:1/0);Number.isFinite(o)&&n.t>o&&n.topMass+n.botMass>0&&M.unshift({t:o,topMass:n.topMass,botMass:n.botMass})}return{samples:M,peak:b,topPeak:v,botPeak:w,localAttachments:A}}function _d(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function Pd(t,e){return t.map(t=>({t:_d(t.t,e),topMass:t.topMass,botMass:t.botMass}))}function Cd(t,e,n){const o=t.value*n;if("out"===t.kind){const i=t.sideMassBefore*n;if("top"===t.side){const t=e-i;return[t,t+o]}const r=e+i;return[r-o,r]}const i=t.sideMassAfter*n;if("top"===t.side){const t=e-i;return[t,t+o]}const r=e+i;return[r-o,r]}function Td(t,e){let n=0;for(let o=0;e.length>o;o++)for(let i=o+1;e.length>i;i++){const r=e[o],s=e[i];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&t[s.source]>t[r.source]!=t[s.target]>t[r.target]&&n++)}return n}function Ld(t,e){let n=0;for(const o of e)n+=Math.abs(t[o.source]-t[o.target])*(o.value||1);return n}function Rd(t,e){return 1e3*Td(t,e)+Ld(t,e)}function $d(t,e){return{slots:t.map(t=>({peak:{...t.peak},occupants:t.occupants.slice()})),map:{...e}}}function zd(t,e,n){t.length>8||n.length>40?(function(t,e,n,o=6){const i=t.length;if(1>=i)return;let r=$d(t,e),s=Rd(e,n);for(let a=0;o>a;a++){const o=Array(i).fill(0),a=Array(i).fill(0);for(const t of n){const n=e[t.source],i=e[t.target];o[n]+=i*(t.value||1),a[n]+=t.value||1,o[i]+=n*(t.value||1),a[i]+=t.value||1}const l=Array.from({length:i},(t,e)=>e).sort((t,e)=>(a[t]>0?o[t]/a[t]:t)-(a[e]>0?o[e]/a[e]:e)),c=l.map(e=>t[e]),u=new Map;l.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of c)t.push(e);const h=Rd(e,n);if(s>h)s=h,r=$d(t,e);else if(h===s)break}!function(t,e,n){t.length=0;for(const e of n.slots)t.push(e);for(const t of Object.keys(e))delete e[t];for(const t of Object.keys(n.map))e[t]=n.map[t]}(t,e,r)}(t,e,n,6),function(t,e,n,o=6){const i=t.length;if(1>=i)return;let r=Rd(e,n);for(let s=0;o>s;s++){let o=!1;for(let s=0;i-1>s;s++){const i=t[s];t[s]=t[s+1],t[s+1]=i;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s);const a=Rd(e,n);if(r>a)r=a,o=!0;else{const n=t[s];t[s]=t[s+1],t[s+1]=n;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s)}}if(!o)break}}(t,e,n,6)):function(t,e,n){const o=t.length;if(1>=o)return;const i={...e},r=Object.keys(i),s=Array.from({length:o},(t,e)=>e),a=s.slice(),l={...i};let c=s.slice(),u=1/0;const h=()=>{for(const t of r)l[t]=a[i[t]];const t=Rd(l,n);u>t&&(u=t,c=s.slice())},d=(t,e)=>{const n=s[t],o=s[e];s[t]=o,s[e]=n,a[n]=e,a[o]=t};h();const f=Array(o).fill(0);let p=0;for(;o>p;)p>f[p]?(d(p%2==0?0:f[p],p),h(),f[p]++,p=0):(f[p]=0,p++);const y=c.map(e=>t[e]),g=new Map;c.forEach((t,e)=>g.set(t,e));for(const t of Object.keys(e))e[t]=g.get(e[t]);t.length=0;for(const e of y)t.push(e)}(t,e,n)}function Dd(t,e,n,o,i){const{plotH:r,padding:s,valueScale:a,packing:l,laneOrder:c,lifetimeMode:u="full"}=i,h={},d={};for(const e of t)h[e.id]=n[e.id].topPeak||0,d[e.id]=n[e.id].botPeak||0;const f="half"===u,p={};for(const e of t){const t=Array.isArray(e.xExtent)?e.xExtent[0]:null,n=Array.isArray(e.xExtent)?e.xExtent[1]:null;let i=null!=t&&Number.isFinite(t)?t:1/0,r=null!=n&&Number.isFinite(n)?n:-1/0;for(const t of o.outgoing[e.id]){i>t.startTime&&(i=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&i>t.systemInTime&&(i=t.systemInTime);const e=f?(t.startTime+t.endTime)/2:t.endTime;e>r&&(r=e)}for(const t of o.incoming[e.id]){const e=f?(t.startTime+t.endTime)/2:t.startTime;i>e&&(i=e),t.endTime>r&&(r=t.endTime),null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>r&&(r=t.systemOutTime)}p[e.id]={start:Number.isFinite(i)?i:null,end:Number.isFinite(r)?r:null}}const y={},g=[];if("reuse"===l){const n=new Map;for(const e of t)n.set(e.id,0);const i=new Map;for(const e of t)i.set(e.id,0);for(const t of e)i.set(t.target,(i.get(t.target)??0)+1);const r=[];for(const e of t)0===(i.get(e.id)??0)&&r.push(e.id);for(;r.length;){const t=r.shift();for(const e of o.outgoing[t]??[]){const o=(n.get(t)??0)+1;o>(n.get(e.target)??0)&&n.set(e.target,o),i.set(e.target,i.get(e.target)-1),0===i.get(e.target)&&r.push(e.target)}}const s=[...t].filter(t=>null!==p[t.id].start).sort((t,e)=>{const o=n.get(t.id)??0,i=n.get(e.id)??0;return o!==i?o-i:p[t.id].start-p[e.id].start}),a=t.filter(t=>null===p[t.id].start);for(const t of[...s,...a]){const e=p[t.id];let n=-1;for(let t=0;g.length>t;t++){const o=g[t].occupants[g[t].occupants.length-1];if(null===e.start||void 0===o||e.start>=o.end){n=t;break}}-1===n&&(g.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=g.length-1),g[n].occupants.push({id:t.id,end:e?.end??-1/0}),g[n].peak.topPeak=Math.max(g[n].peak.topPeak,h[t.id]),g[n].peak.botPeak=Math.max(g[n].peak.botPeak,d[t.id]),y[t.id]=n}}else t.forEach((t,e)=>{g.push({occupants:[{id:t.id,end:p[t.id]?.end??-1/0}],peak:{topPeak:h[t.id],botPeak:d[t.id]}}),y[t.id]=e});let m=null,x=null,b=null,v=null;const w=()=>{m=Td(y,e),b=Ld(y,e)},k=()=>{x=Td(y,e),v=Ld(y,e)};"crossing-min"===c?(w(),zd(g,y,e),k()):"inside-out"===c?(w(),function(t,e){const n=t.length;if(1>=n)return;const o=t=>t.peak.topPeak+t.peak.botPeak,i=t.map((t,e)=>({slot:t,idx:e})).sort((t,e)=>o(e.slot)-o(t.slot)),r=Array(n),s=Math.floor((n-1)/2);r[s]=i[0].idx;let a=s-1,l=s+1;for(let t=1;i.length>t;t++)t%2==1&&n>l||0>a?r[l++]=i[t].idx:r[a--]=i[t].idx;const c=r.map(e=>t[e]),u=new Map;r.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of c)t.push(e)}(g,y),k()):"crossing-min+inside-out"===c&&(w(),zd(g,y,e),function(t,e,n){const o=t.length;if(1>=o)return;const i=t.map(t=>{return{slot:t,size:(e=t,e.peak.topPeak+e.peak.botPeak)};var e}).sort((t,e)=>e.size-t.size),r=Math.floor((o-1)/2);let s=Rd(e,n);for(const{slot:a}of i){const i=t.indexOf(a);if(0>i)continue;const l=r;if(i===l)continue;const c=t[i];t.splice(i,1),t.splice(l,0,c);const u=new Map;for(let t=0;o>t;t++)u.set(t,t);if(l>i){for(let t=i+1;l>=t;t++)u.set(t,t-1);u.set(i,l)}else{for(let t=l;i>t;t++)u.set(t,t+1);u.set(i,l)}for(const t of Object.keys(e))e[t]=u.get(e[t]);const h=Rd(e,n);if(h>s){const n=t[l];t.splice(l,1),t.splice(i,0,n);const r=new Map;for(let t=0;o>t;t++)r.set(t,t);if(i>l){for(let t=l+1;i>=t;t++)r.set(t,t-1);r.set(l,i)}else{for(let t=i;l>t;t++)r.set(t,t+1);r.set(l,i)}for(const t of Object.keys(e))e[t]=r.get(e[t])}else s=h}}(g,y,e),k());const S=g.map(t=>{const e=new Map;for(const o of t.occupants){const t=n[o.id];if(t)for(const n of t.samples){const t=e.get(n.t)||{top:0,bot:0};e.set(n.t,{top:Math.max(t.top,n.topMass),bot:Math.max(t.bot,n.botMass)})}}return[...e.entries()].sort((t,e)=>t[0]-e[0])}),A=(t,e)=>{let n={top:0,bot:0};for(const[o,i]of t){if(o>e)break;n=i}return n},M=[];for(let t=0;g.length-1>t;t++){const e=S[t],n=S[t+1],o=new Set([...e.map(t=>t[0]),...n.map(t=>t[0])]);let i=0;for(const t of o){const o=A(e,t),r=A(n,t);o.bot+r.top>i&&(i=o.bot+r.top)}M.push(i)}const _=[];let P=s+(g[0]?.peak.topPeak??0)*a;g.length>0&&_.push(P);for(let t=1;g.length>t;t++)P+=M[t-1]*a+s,_.push(P);if(g.length>0&&(P+=g[g.length-1].peak.botPeak*a+s),P>r){const t=r/P;for(let e=0;_.length>e;e++)_[e]*=t}const C=0===g.length?0:g[0].peak.topPeak+M.reduce((t,e)=>t+e,0)+g[g.length-1].peak.botPeak,T={};for(const e of t)T[e.id]=_[y[e.id]];return{effectiveSlotsHeight:C,centerlines:T,laneLifetime:p,slots:g,slotByNode:y,slotCenter:_,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:v}}function Id(t){const{sx:e,sTop:n,sBot:o,tx:i,tTop:r,tBot:s,cp1X:a,cp2X:l}=t,c=(n+o)/2,u=(r+s)/2;return{pathD:[`M${e},${n}`,`C${a},${n} ${l},${r} ${i},${r}`,`L${i},${s}`,`C${l},${s} ${a},${o} ${e},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:c},{x:a,y:c},{x:l,y:u},{x:i,y:u}],halfWidth:(o-n)/2}}}function Bd(t){const{nodes:e,edges:n,domain:o,plotW:i,plotH:r,ribbonLane:s,edgeOpacity:a,colorOf:l,layoutOpts:c}=t,u=function(t,e,n){const o=[],i=new Set(t.map(t=>t.id)),r=Array.isArray(n)&&2===n.length,s=r&&Number.isFinite(n[0])&&Number.isFinite(n[1]);r&&s&&s&&n[1]>=n[0]||o.push({kind:"invalid-domain"});for(const e of t)null!=e.xExtent&&(Array.isArray(e.xExtent)&&2===e.xExtent.length&&Number.isFinite(e.xExtent[0])&&Number.isFinite(e.xExtent[1])&&e.xExtent[1]>=e.xExtent[0]||o.push({kind:"invalid-node-time",id:e.id}));for(const t of e)i.has(t.source)||o.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),i.has(t.target)||o.push({kind:"missing-node",id:t.id,endpoint:"target",nodeId:t.target}),Number.isFinite(t.startTime)&&Number.isFinite(t.endTime)?(Number.isFinite(t.value)&&t.value>0||o.push({kind:"invalid-value",id:t.id}),t.endTime>t.startTime||o.push({kind:"backward-edge",id:t.id,source:t.source,target:t.target})):o.push({kind:"invalid-edge-time",id:t.id});return o}(e,n,o),h=Sd().domain(o).range([0,i]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:h};const d=function(t,e,n){const{plotH:o,pairing:i="temporal",packing:r="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=n,l=function(t,e){const n={},o={};for(const e of t)n[e.id]=[],o[e.id]=[];for(const t of e)o[t.source]&&o[t.source].push(t),n[t.target]&&n[t.target].push(t);return{incoming:n,outgoing:o}}(t,e),c=function(t,e,n,o="value"){const i="temporal"===o?(t,e)=>t.endTime-e.endTime:(t,e)=>e.value-t.value,r="temporal"===o?(t,e)=>t.startTime-e.startTime:(t,e)=>e.value-t.value,s=new Map;for(const t of e)s.set(t.id,{});const a=(t,e)=>{const n=new Map;for(const o of t){const t=o[e];n.has(t)||n.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const i=n.get(t);i.edges.push(o),i.total+=o.value,i.earliestStart=Math.min(i.earliestStart,o.startTime),i.latestEnd=Math.max(i.latestEnd,o.endTime)}const s=[...n.values()];s.sort("temporal"===o?(t,n)=>"target"===e?t.earliestStart-n.earliestStart:t.latestEnd-n.latestEnd:(t,e)=>e.total-t.total);for(const t of s)t.edges.sort("target"===e?r:i);return s};for(const e of t){const t=n.outgoing[e.id],o=n.incoming[e.id];if(0===o.length)a(t,"target").forEach((t,e)=>{const n=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).sourceSide=n});else if(0===t.length)a(o,"source").forEach((t,e)=>{const n=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).targetSide=n});else{const e=a(o,"source"),n=a(t,"target"),i=Math.max(e.length,n.length);for(let t=0;i>t;t++){const o=t%2==0?"top":"bot";if(e[t])for(const n of e[t].edges)s.get(n.id).targetSide=o;if(n[t])for(const e of n[t].edges)s.get(e.id).sourceSide=o}}}return s}(t,e,l,i);let u={};for(const e of t)u[e.id]=Md(e,l,c);const h=Dd(t,e,u,l,{plotH:o,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),d=new Set;for(const t of e){const e=h.slotByNode[t.source],n=h.slotByNode[t.target];if(void 0===e||void 0===n)continue;const o=c.get(t.id);e!==n?e>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(d.add(t.id),o.sourceSide="bot",o.targetSide="bot")}for(const e of t){const t=l.outgoing[e.id],n=l.incoming[e.id],o=new Set(t.map(t=>c.get(t.id).sourceSide)),i=new Set(n.map(t=>c.get(t.id).targetSide));if(1===o.size&&n.length>0){const t=[...o][0];for(const e of n)h.slotByNode[e.source]===h.slotByNode[e.target]&&(c.get(e.id).targetSide=t)}if(1===i.size&&t.length>0){const e=[...i][0];for(const n of t)h.slotByNode[n.source]===h.slotByNode[n.target]&&(c.get(n.id).sourceSide=e)}}for(const e of t){const t=l.incoming[e.id],n=l.outgoing[e.id];if(0===t.length||0===n.length)continue;const o=()=>{const e={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of t)"top"===c.get(n.id).targetSide?e.inTop+=n.value:e.inBot+=n.value;for(const t of n)"top"===c.get(t.id).sourceSide?e.outTop+=t.value:e.outBot+=t.value;return e},i=(t,e)=>{const i=o(),r="top"===t?i.outTop-i.inTop:i.outBot-i.inBot,s="top"===e?i.inTop-i.outTop:i.inBot-i.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),l=n.filter(e=>!d.has(e.id)&&c.get(e.id).sourceSide===t&&a>=e.value).sort((t,e)=>e.value-t.value);return 0!==l.length&&(c.get(l[0].id).sourceSide=e,!0)};let r=n.length+1;for(;r-- >0&&(i("top","bot")||i("bot","top")););}u={};for(const e of t)u[e.id]=Md(e,l,c);const f=Dd(t,e,u,l,{plotH:o,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),p=f.effectiveSlotsHeight??f.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),y=Math.min(12,.35*o/Math.max(f.slots.length+1,1)),g=p>0?Math.max(0,(o-y*(f.slots.length+1))/p):1,m=Dd(t,e,u,l,{plotH:o,padding:y,valueScale:g,packing:r,laneOrder:s,lifetimeMode:a});return{nodeData:u,sides:c,valueScale:g,padding:y,compressedPadding:12>y,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(e,n,{plotH:r,...c}),{centerlines:f,nodeData:p,valueScale:y}=d,g=[],m=[];e.forEach((t,e)=>{const i=p[t.id];if(!i||0===i.samples.length)return;const r=function(t,e,n,o,i){if(0===t.length)return null;const r=Pd(t,i),s=t=>e-r[t].topMass*n,a=t=>e+r[t].botMass*n;let l=`M${o(r[0].t)},${s(0)}`;for(let t=1;r.length>t;t++)l+=` L${o(r[t].t)},${s(t)}`;l+=` L${o(r[r.length-1].t)},${a(r.length-1)}`;for(let t=r.length-2;t>=0;t--)l+=` L${o(r[t].t)},${a(t)}`;return l+" Z"}(i.samples,f[t.id],y,h,o);if(!r)return;const s=Pd(i.samples,o),a=s.find(t=>t.topMass+t.botMass>0)||s[0],c=f[t.id]+(a.botMass-a.topMass)*y/2,u=l(t.id,e),m=function(t,e,n,o,i){const r=n.nodeData[t];if(!r||0===r.samples.length)return[];const s=n.valueScale,a=n.centerlines[t],l=Pd(r.samples,i),c=l.find(t=>t.topMass+t.botMass>0)||l[0],u=[...l].reverse().find(t=>t.topMass+t.botMass>0)||l[l.length-1],h=o(c.t),d=o(u.t),f=t=>o(_d(t,i)),p=[],y=(t,e,n,o)=>`M${t},${e} L${n},${e} L${n},${o} L${t},${o} Z`;for(const n of e){if(n.source===t&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const t=r.localAttachments.get(n.id);if(t&&"out"===t.kind&&n.startTime>n.systemInTime){const e=f(n.systemInTime),o=f(n.startTime),i=e-20,r=Math.max(h,i);if(o>r){const[n,l]=Cd(t,a,s);p.push({pathD:y(r,n,o,l),x0:i,x1:e,from:0,to:1})}}}if(n.target===t&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const t=r.localAttachments.get(n.id);if(t&&"in"===t.kind&&n.systemOutTime>n.endTime){const e=f(n.systemOutTime),o=f(n.endTime),i=e+20,r=Math.min(d,i);if(r>o){const[n,l]=Cd(t,a,s);p.push({pathD:y(o,n,r,l),x0:e,x1:i,from:1,to:0})}}}}return p}(t.id,n,d,h,o);g.push({id:t.id,pathD:r,fill:u,stroke:u,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:t.__raw??t,labelX:h(a.t)-4,labelY:c,labelText:t.id})});const x=new Map;return e.forEach((t,e)=>x.set(t.id,e)),n.forEach(t=>{const e=p[t.source]?.localAttachments.get(t.id),n=p[t.target]?.localAttachments.get(t.id);if(!e||!n)return;const i=x.get(t.source)??0,r=l(t.source,i),c=function(t,e,n,o,i,r,s,a){const l=i,c=t=>a?Math.max(a[0],Math.min(a[1],t)):t,u=r(c(t.time)),h=r(c(n.time)),d=t.value*l,f=n.value*l,p=t.sideMassBefore*l,y=n.sideMassAfter*l;let g,m,x,b;"top"===t.side?(g=e-p,m=g+d):(m=e+p,g=m-d),"top"===n.side?(x=o-y,b=x+f):(b=o+y,x=b-f);const v="source"===s?u+.85*(h-u):"target"===s?u+.15*(h-u):(u+h)/2;return{sx:u,sTop:g,sBot:m,tx:h,tTop:x,tBot:b,cp1X:v,cp2X:v}}(e,f[t.source],n,f[t.target],y,h,s,o),{pathD:u,bezier:d}=Id(c);m.push({id:t.id,pathD:u,fill:r,opacity:a,rawDatum:t.__raw??t,bezier:d})}),{layout:d,layoutConfig:{bands:g,ribbons:m,showLabels:!0},issues:[],xScale:h}}var Fd=t=>{const{bands:e=[],ribbons:n=[],showLabels:o=!0}=t.config,i=[];for(const t of n)i.push({type:"bezier",pathD:t.pathD,...t.bezier&&{bezierCache:t.bezier},style:{fill:t.fill,opacity:t.opacity,stroke:"none"},datum:{__kind:"ribbon",data:t.rawDatum,id:t.id}});for(const t of e)if(t.gradientStubs)for(let e=0;t.gradientStubs.length>e;e++){const n=t.gradientStubs[e];i.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:t.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:t.rawDatum,id:`${t.id}__stub${e}`}})}for(const t of e)i.push({type:"bezier",pathD:t.pathD,style:{...t.gradientStubs&&t.gradientStubs.length>0?{fill:"none"}:{fill:t.fill,fillOpacity:.86},stroke:t.stroke??t.fill,strokeWidth:t.strokeWidth??.5},datum:{__kind:"band",data:t.rawDatum,id:t.id}});const r=o?e.map(t=>({x:t.labelX,y:t.labelY,text:t.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:e.map(t=>({type:"circle",id:t.id,cx:-1e4,cy:-1e4,r:0,style:{fill:t.fill},datum:{__kind:"band",data:t.rawDatum,id:t.id}})),sceneEdges:i,labels:r}};function Ed(t,e){if(!t)return[];const n=[],o=t=>{n.push(t);const i="function"==typeof e?e(t):t[e];i&&Array.isArray(i)&&i.forEach(o)};return o(t),n}function Od(t,e,n,o){if(t&&t.length>0)return t;const i=new Set;return e.forEach(t=>{const e="function"==typeof n?n(t):t[n],r="function"==typeof o?o(t):t[o];i.add(e),i.add(r)}),Array.from(i).map(t=>({id:t}))}import*as Nd from"react";var Wd={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,n,o,i)=>{const{edgeWidth:r,edgeColor:s,edgeOpacity:a}=i,l=i.edgeStyle??(void 0!==r||void 0!==s||void 0!==a?t=>{const e=t?.data||t;let n=1;if("number"==typeof r)n=r;else if("function"==typeof r)n=r(e);else if("string"==typeof r){const t=e?.[r],o="number"==typeof t?t:Number(t);n=Number.isFinite(o)&&o>0?o:1}return{stroke:s??"#999",strokeWidth:n,opacity:a??.6}}:void 0),c=D(o.theme).colors.categorical,u=new Map,h=i.nodeStyle??(t=>({fill:e?Mt(t?.data||t,e,void 0):Eu(void 0,c,n,void 0,u),..."number"==typeof i.nodeSize&&{r:i.nodeSize}})),d=Ft(i.styleRules,e,"number"==typeof i.nodeSize?void 0:i.nodeSize);return{chartType:"force",nodes:i.nodes,edges:i.edges,nodeIDAccessor:i.nodeIdAccessor||i.nodeIDAccessor,sourceAccessor:i.sourceAccessor,targetAccessor:i.targetAccessor,colorBy:e,colorScheme:n,iterations:i.iterations,forceStrength:i.forceStrength,showLabels:i.showLabels??!1,nodeLabel:i.nodeLabel,nodeSize:i.nodeSize??8,nodeSizeRange:i.nodeSizeRange,nodeStyle:d?(t,e)=>({...h(t),...d(t,e)}):h,edgeStyle:l,...o}}},jd={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(t,e,n,o,i)=>{const r=t=>null==t?NaN:t instanceof Date?t.getTime():"number"==typeof t?t:new Date(t).getTime(),s=i.sourceAccessor||"source",a=i.targetAccessor||"target",l=i.valueAccessor||"value",c=i.nodeIdAccessor||"id",u=i.startTimeAccessor||"startTime",h=i.endTimeAccessor||"endTime",d=i.systemInTimeAccessor,f=i.systemOutTimeAccessor,p=i.xExtentAccessor||"xExtent",y=i.edgeIdAccessor||"id",g=(t,e)=>"function"==typeof t?t(e):e[t],m=Array.isArray(i.edges)?i.edges:[],x=Array.isArray(i.nodes)?i.nodes:[],b=x.length>0?x:Od([],m,s,a),v=[r(i.domain?.[0]),r(i.domain?.[1])],w=b.map(t=>{const e=g(c,t)+"",n=g(p,t),o={id:e,__raw:t};if(Array.isArray(n)&&2===n.length){const t=r(n[0]),e=r(n[1]);Number.isFinite(t)&&Number.isFinite(e)&&(o.xExtent=[t,e])}return o}),k=m.map((t,e)=>{const n=g(y,t),o={id:null!=n?n+"":`${g(s,t)}-${g(a,t)}-${e}`,source:g(s,t)+"",target:g(a,t)+"",value:Number(g(l,t)),startTime:r(g(u,t)),endTime:r(g(h,t)),__raw:t};if(d){const e=r(g(d,t));Number.isFinite(e)&&(o.systemInTime=e)}if(f){const e=r(g(f,t));Number.isFinite(e)&&(o.systemOutTime=e)}return o}),[S,A]=o.size??[600,400],M={top:20,right:20,bottom:20,left:20,...o.margin},_=(o.showLegend??!!e)&&!!e,P=o.legendPosition??"right",C=o.__explicitMargin,T=t=>"number"==typeof C||null!=C&&"object"==typeof C&&null!=C[t];_&&("right"!==P||T("right")?"bottom"!==P||T("bottom")||(M.bottom=Math.max(M.bottom,80)):M.right=Math.max(M.right,140));const L=M,R=S-L.left-L.right,$=A-L.top-L.bottom,z=wt(n,D(o.theme).colors.categorical,K),I="function"==typeof e?e:null,B=I?b.map(t=>({_cat:I(t)})):b,F=I?"_cat":"string"==typeof e?e:void 0,E=n??[...z],O=F?Pt(B,F,E):null,N=new Map;for(const t of w)N.set(t.id,t.__raw);const W=(t,n)=>{if(e&&N.has(t)){const n=N.get(t);return I?Mt({_cat:I(n)},"_cat",O??void 0):Mt(n,"string"==typeof e?e:"id",O??void 0)}return z[n%z.length]},j=Qi(_&&e?(()=>{const t=new Map;b.forEach((n,o)=>{const i=g(e,n),r=null==i?"":i+"";r&&!t.has(r)&&t.set(r,{label:r,color:W(g(c,n)+"",o)})});const n=Array.from(t.values());return n.length>0?{legendGroups:[{type:"fill",label:"",items:n,styleFn:t=>{const e=t.color||"#333";return{fill:e,stroke:e}}}]}:void 0})():void 0,o.legend),{layout:Y,layoutConfig:G,issues:q,xScale:X}=Bd({nodes:w,edges:k,domain:v,plotW:R,plotH:$,ribbonLane:i.ribbonLane||"both",edgeOpacity:"number"==typeof i.edgeOpacity?i.edgeOpacity:.35,colorOf:W,layoutOpts:{pairing:i.pairing||"temporal",packing:i.packing||"reuse",laneOrder:i.laneOrder||"crossing-min",lifetimeMode:i.lifetimeMode||"half"}});if(q.length>0){const t=q.map(Ad).join("; ");throw Error("ProcessSankey: data invalid — "+t)}const H=Array.isArray(i.axisTicks)?i.axisTicks:[],V=Y?(()=>{let t=null,e=null;for(const n of w){const o=Y.laneLifetime[n.id];if(!o||null==o.start||null==o.end)continue;const i=Number(X(o.start)),r=Number(X(o.end));t=null==t?i:Math.min(t,i),e=null==e?r:Math.max(e,r)}const n=t=>Math.max(0,Math.min(R,t)),o=n(t??0),s=Math.max(o,n(e??R)),a=H.map((t,e)=>({tick:t,index:e,x:Number(X(r(t.date)))})).filter(({x:t})=>t>=o-.5&&s+.5>=t);return Nd.createElement("g",null,...a.map(({index:t,x:e})=>Nd.createElement("line",{key:"grid-"+t,x1:e,y1:0,x2:e,y2:$,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"})),Nd.createElement("line",{key:"axis",x1:o,y1:$+4,x2:s,y2:$+4,stroke:"#94a3b8"}),...a.map(({tick:t,index:e,x:n})=>{const o=r(t.date),s=null!=t.label?t.label:"function"==typeof i.timeFormat?i.timeFormat(new Date(o)):"";return Nd.createElement("g",{key:"tick-"+e,transform:`translate(${n},${$+4})`},Nd.createElement("line",{y2:6,stroke:"#94a3b8"}),Nd.createElement("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569"},s))}))})():void 0;return{chartType:"force",nodes:b,edges:m,customNetworkLayout:Fd,layoutConfig:G,sourceAccessor:s,targetAccessor:a,valueAccessor:l,nodeIDAccessor:c,colorBy:e,colorScheme:n,...V&&{backgroundGraphics:V},...o,showLegend:_,...j&&{legend:j,legendPosition:P},__legendIncludesAutomatic:!0,margin:L}}},Yd={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(t,e,n,o,i)=>{const r=Array.isArray(i.nodes)?i.nodes:Od([],Array.isArray(i.edges)?i.edges:[],i.sourceAccessor||"source",i.targetAccessor||"target"),s=D(o.theme).colors.categorical,a=new Map,l="string"==typeof e?e:"__ssrSankeyColorBy",c="function"==typeof e?r.map(t=>({...t,__ssrSankeyColorBy:e(t)})):r,u=e?Pt(c,l,n??o.colorScheme??s):void 0,h=t=>({fill:e?Mt(t?.data||t,e,u):Eu(void 0,s,n,void 0,a),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),d=Ft(i.styleRules,e,i.valueAccessor),f=d?(t,e)=>({...h(t),...d(t,e)}):h,p=function({edgeColorBy:t,colorBy:e,colorScale:n,nodeStyleFn:o,edgeOpacity:i,baseStyle:r={}}){return s=>{const a={fillOpacity:i,...r};if("function"==typeof t)a.fill=t(s);else if("source"===t){const t="object"==typeof s.source?s.source:null;e&&t?a.fill=Mt(t.data||t,e,n):t&&(a.fill=o(t,t.index).fill)}else if("target"===t){const t="object"==typeof s.target?s.target:null;e&&t?a.fill=Mt(t.data||t,e,n):t&&(a.fill=o(t,t.index).fill)}else"gradient"===t&&(a.fill="#999",a.fillOpacity=.7*i);return a}}({edgeColorBy:i.edgeColorBy??"source",colorBy:e,colorScale:u,nodeStyleFn:f,edgeOpacity:i.edgeOpacity??.5,baseStyle:{stroke:"none",strokeWidth:0}});return{chartType:"sankey",nodes:i.nodes,edges:i.edges,nodeIDAccessor:i.nodeIdAccessor||i.nodeIDAccessor,sourceAccessor:i.sourceAccessor,targetAccessor:i.targetAccessor,valueAccessor:i.valueAccessor,orientation:i.orientation,nodeAlign:i.nodeAlign,nodeWidth:i.nodeWidth,nodePaddingRatio:i.nodePaddingRatio,showLabels:i.showLabels,nodeLabel:i.nodeLabel,colorBy:e,edgeColorBy:i.edgeColorBy,edgeOpacity:i.edgeOpacity,nodeStyle:o.nodeStyle||i.nodeStyle||f,edgeStyle:o.edgeStyle||i.edgeStyle||p,colorScheme:n,...o}}},Gd={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,n,o,i)=>{if(!(e||Array.isArray(i.styleRules)&&i.styleRules.length>0||o.nodeStyle||i.nodeStyle))return{chartType:"chord",nodes:i.nodes,edges:i.edges,valueAccessor:i.valueAccessor,padAngle:i.padAngle,groupWidth:i.groupWidth,showLabels:i.showLabels,colorBy:e,edgeColorBy:i.edgeColorBy,colorScheme:n,...o};const r=Array.isArray(i.edges)?i.edges:[],s=Array.isArray(i.nodes)&&i.nodes.length>0?i.nodes:Od([],r,i.sourceAccessor||"source",i.targetAccessor||"target"),a=D(o.theme).colors.categorical,l=wt(n,a),c="string"==typeof e?e:"__ssrChordColorBy",u="function"==typeof e?s.map(t=>({...t,__ssrChordColorBy:e(t)})):s,h=e?Pt(u,c,n??o.colorScheme??a):void 0,d=new Map,f=i.nodeIdAccessor||i.nodeIDAccessor||"id",p=(t,n)=>{const i=t?.data||t;let r;if(e)r=Mt(i,e,h);else{const e=(t.id??i?.[f]??"")+"";d.has(e)||d.set(e,d.size);const o=t.index??n??d.get(e);r=l[o%l.length]}return{fill:r,stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},y=Ft(i.styleRules,e,i.valueAccessor,p)??p;return{chartType:"chord",nodes:i.nodes,edges:i.edges,valueAccessor:i.valueAccessor,padAngle:i.padAngle,groupWidth:i.groupWidth,showLabels:i.showLabels,colorBy:e,edgeColorBy:i.edgeColorBy,colorScheme:n,nodeStyle:o.nodeStyle||i.nodeStyle||y,...o}}},qd={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,n,o,i)=>{const r=D(o.theme).colors.categorical,s=new Map,a=Ed(t??null,i.childrenAccessor),l="function"==typeof e?e:null,c=l?a.map(t=>({__ssrTreeColorBy:l(t)})):a,u=l?"__ssrTreeColorBy":"string"==typeof e?e:void 0,h=e&&u?Pt(c,u,n??o.colorScheme??r):void 0;return{chartType:"cluster"===i.layout?"cluster":"tree",data:t,childrenAccessor:i.childrenAccessor,colorBy:e,colorByDepth:i.colorByDepth,orientation:i.orientation,showLabels:i.showLabels,nodeLabel:!1!==i.showLabels?i.nodeLabel||i.nodeIdAccessor:void 0,colorScheme:n,...o,nodeStyle:o.nodeStyle||i.nodeStyle||(t=>{const a=t?.data||t;return{fill:i.colorByDepth?St[Number(t?.depth||0)%St.length]:e?l?Mt({__ssrTreeColorBy:l(a)},"__ssrTreeColorBy",h??void 0):Mt(a,e,h??void 0):Eu(void 0,r,n,void 0,s),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}})}}},Xd={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,n,o,i)=>{const r=D(o.theme).colors.categorical,s=new Map,a=Ed(t??null,i.childrenAccessor),l="function"==typeof e?e:null,c=l?a.map(t=>({__ssrTreemapColorBy:l(t)})):a,u=l?"__ssrTreemapColorBy":"string"==typeof e?e:void 0,h=e&&u?Pt(c,u,n??o.colorScheme??r):void 0,d=i.showLabels??o.showLabels,f=i.labelMode,p=void 0!==i.paddingTop?i.paddingTop:!d||"parent"!==f&&"all"!==f?void 0:18;return{chartType:"treemap",data:t,childrenAccessor:i.childrenAccessor,hierarchySum:i.valueAccessor,colorBy:e,colorByDepth:i.colorByDepth,showLabels:i.showLabels,labelMode:f,nodeLabel:d?i.nodeLabel||i.nodeIdAccessor:void 0,...null!=i.padding&&{padding:i.padding},...null!=p&&{paddingTop:p},colorScheme:n,...o,nodeStyle:o.nodeStyle||i.nodeStyle||(t=>{const o=t?.data||t;return{fill:i.colorByDepth?St[Number(t?.depth||0)%St.length]:e?l?Mt({__ssrTreemapColorBy:l(o)},"__ssrTreemapColorBy",h??void 0):Mt(o,e,h??void 0):Eu(void 0,r,n,void 0,s),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}})}}},Hd={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,n,o,i)=>{const r=D(o.theme).colors.categorical,s=new Map,a=Ed(t??null,i.childrenAccessor),l="function"==typeof e?e:null,c=l?a.map(t=>({__ssrCirclePackColorBy:l(t)})):a,u=l?"__ssrCirclePackColorBy":"string"==typeof e?e:void 0,h=e&&u?Pt(c,u,n??o.colorScheme??r):void 0;return{chartType:"circlepack",data:t,childrenAccessor:i.childrenAccessor,hierarchySum:i.valueAccessor,colorBy:e,colorByDepth:i.colorByDepth,showLabels:i.showLabels,nodeLabel:i.showLabels??o.showLabels?i.nodeLabel||i.nodeIdAccessor:void 0,...null!=i.padding&&{padding:i.padding},colorScheme:n,...o,nodeStyle:o.nodeStyle||i.nodeStyle||(t=>{const o=t?.data||t;return{fill:i.colorByDepth?St[Number(t?.depth||0)%St.length]:e?l?Mt({__ssrCirclePackColorBy:l(o)},"__ssrCirclePackColorBy",h??void 0):Mt(o,e,h??void 0):Eu(void 0,r,n,void 0,s),fillOpacity:i.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}})}}},Vd={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5};import{scaleSequential as Ud}from"d3-scale";function Kd(t){return t&&"object"==typeof t&&t.properties?{...t.properties,...t}:t}var Zd={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(t,e,n,o,i)=>{const r="string"==typeof n?n:"blues",s=i.areaStyle??function(t,e,n,o){if(!Array.isArray(t))return;const i=t=>"function"==typeof e?e(t):null!=e?t?.properties?.[e]??t?.[e]:void 0;let r=1/0,s=-1/0;for(const e of t){const t=i(e);null!=t&&isFinite(t)&&(r>t&&(r=t),t>s&&(s=t))}const a=Ud(ut(n)).domain([Number.isFinite(r)?r:0,Number.isFinite(s)?s:1]);return t=>{const e=i(t);return{fill:null!=e&&isFinite(e)?a(e):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:o}}}(i.areas,i.valueAccessor,r,i.areaOpacity??1),a=i.styleRules?Bt(s,i.styleRules,t=>{return{value:(e=t,"function"==typeof i.valueAccessor?i.valueAccessor(e):null!=i.valueAccessor?e?.properties?.[i.valueAccessor]??e?.[i.valueAccessor]:void 0)};var e},Kd):s;return{areas:i.areas,projection:i.projection||"equalEarth",areaStyle:a,valueAccessor:i.valueAccessor,colorScheme:r,graticule:i.graticule,fitPadding:i.fitPadding,...o}}},Qd={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(t,e,n,o,i)=>{const r=t||i.points,s=i.pointStyle??function(t,e,n,o){const i=Array.isArray(t)?t:[];let r,s;if(e){const t="string"==typeof e?e:"__geoColorBy",o="string"==typeof e?i:i.map(t=>({...t,__geoColorBy:e(t)}));r=Pt(o,t,n)}if(o.sizeBy){const t=i.map("function"==typeof o.sizeBy?o.sizeBy:t=>t?.[o.sizeBy]).filter(t=>null!=t&&isFinite(t));t.length>0&&(s=S(t))}return t=>({fill:e&&r?Mt(t,e,r):vt,fillOpacity:o.fillOpacity,stroke:"#fff",strokeWidth:o.strokeWidth,r:o.sizeBy?Ct(t,o.sizeBy,o.sizeRange,s):o.pointRadius??6})}(r,e,n,{sizeBy:i.sizeBy,sizeRange:i.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=i.styleRules?Bt(s,i.styleRules,$t(e,i.sizeBy)):s;return{points:r,xAccessor:i.xAccessor||"lon",yAccessor:i.yAccessor||"lat",areas:i.areas,areaStyle:i.areaStyle||Vd,pointStyle:a,sizeBy:i.sizeBy,colorBy:e,colorScheme:n,projection:i.projection||"equalEarth",graticule:i.graticule,fitPadding:i.fitPadding,...o}}},Jd={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(t,e,n,o,i)=>{const r=(Array.isArray(t)?t:null)||i.flows||[],s=i.nodeIdAccessor||"id",a=i.valueAccessor||"value",l=i.xAccessor||"lon",c=i.yAccessor||"lat",u="function"==typeof l?l:t=>t[l],h="function"==typeof c?c:t=>t[c],d=(i.nodes||[]).map(t=>({...t,x:u(t),y:h(t)})),f=new Map;for(const t of d)f.set(t[s]+"",t);const p=i.edgeColorBy??e,y="function"==typeof p,g=r.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=f.get(t.source+""),n=f.get(t.target+"");return e&&n?{...t,coordinates:[{x:e.x,y:e.y},{x:n.x,y:n.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?Pt(g.map(t=>({[m]:p(t)})),m,n||"category10"):Pt(g,p,n||"category10"):null,b=t=>p&&x?Mt(t,p,x):"#007bff";let v=1/0,w=-1/0;for(const t of g){const e=Number(t[a]??0);isFinite(e)&&(v>e&&(v=e),e>w&&(w=e))}const k=w>v?w-v:0,[S,A]=i.edgeWidthRange??[1,8],M=A-S,_=i.edgeOpacity??.6,P=i.edgeLinecap??"round";return{lines:g,points:d,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:i.lineType||"geo",flowStyle:i.flowStyle||"basic",areas:i.areas,areaStyle:i.areaStyle||Vd,projection:i.projection||"equalEarth",graticule:i.graticule,fitPadding:i.fitPadding,colorScheme:n,lineStyle:t=>{const e=Number(t?.[a]),n=Number.isFinite(e)?e:v,o=S+Math.max(0,Math.min(1,k>0?(n-v)/k:0))*M;return{stroke:b(t),strokeWidth:o,strokeLinecap:P,opacity:_,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...o}}};function tf(t){const[e,n]=t,o=160>e||116>n,i=o?Math.min(12,Math.max(2,.08*e)):32,r=o?Math.min(8,Math.max(2,.12*n)):24,s=o?r:34;return{width:e,height:n,plot:{x:i,y:r,width:Math.max(1,e-2*i),height:Math.max(1,n-r-s)}}}function ef(t){const e=(t??"")+"";if(!e)return"#4e79a7";const n=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let o=0;for(let t=0;e.length>t;t+=1)o=31*o+e.charCodeAt(t)>>>0;return n[o%n.length]}function nf(t,e="#4e79a7",n){const o=n?.styleRules,i=!!o&&o.length>0,r=i?Lt(n?.valueAccessor):void 0;return n=>{const s=n.datum,a=s&&t?"function"==typeof t?t(s,0):s[t]:void 0,l={fill:null==a?e:ef(a),stroke:"#111827",strokeWidth:1,opacity:.9};return i&&s&&Object.assign(l,It(s,o,{value:r?r(s):void 0,category:null==a?void 0:a+""})),l}}function of(t,e,n,o){return{fixedDt:1/120,maxSubsteps:8,colliders:e,observation:{chartType:n},kernel:{seed:t,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...o}}}function rf(t,e,n){return"function"==typeof n?n(t,e):t[n]}function sf(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:null}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:null}function af(t,e,n){return Math.max(e,Math.min(n,t))}function lf(t,e){const n=sf(t);return null!=n&&n>0?n:e}function cf(t){return((t??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function uf(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}import{scaleLinear as hf}from"d3-scale";var df={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},ff=1e-9,pf=.005;function yf(t){return"circle"===t.type?{type:"circle",radius:t.radius}:{type:"aabb",width:t.width,height:t.height}}function gf(t){return"aabb"===t.type?{type:"aabb",x:t.x,y:t.y,width:t.width,height:t.height}:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:t.thickness}}function mf(t,e,n){return Math.max(e,Math.min(n,t))}function xf(t){return 0>t?-1:1}function bf(t){if("circle"===t.shape.type){const e=t.shape.radius;return{minX:t.x-e,minY:t.y-e,maxX:t.x+e,maxY:t.y+e}}const e=t.shape.width/2,n=t.shape.height/2;return{minX:t.x-e,minY:t.y-n,maxX:t.x+e,maxY:t.y+n}}function vf(t){const e=t.shape;if("aabb"===e.type){const t=e.width/2,n=e.height/2;return{minX:e.x-t,minY:e.y-n,maxX:e.x+t,maxY:e.y+n}}const n=(e.thickness??0)/2;return{minX:Math.min(e.x1,e.x2)-n,minY:Math.min(e.y1,e.y2)-n,maxX:Math.max(e.x1,e.x2)+n,maxY:Math.max(e.y1,e.y2)+n}}function wf(t,e){return!(t.minX>e.maxX||e.minX>t.maxX||t.minY>e.maxY||e.minY>t.maxY)}function kf(t,e,n,o,i,r,s,a){const l=i-t,c=(n+s)/2-Math.abs(l);if(0>=c)return null;const u=r-e,h=(o+a)/2-Math.abs(u);return h>0?h>c?{nx:xf(l),ny:0,penetration:c}:{nx:0,ny:xf(u),penetration:h}:null}function Sf(t,e,n,o,i,r,s){const a=r/2,l=s/2;let c=t-mf(t,o-a,o+a),u=e-mf(e,i-l,i+l);const h=c*c+u*u;if(h>n*n)return null;if(ff>=h){const r=Math.abs(t-(o-a)),s=Math.abs(t-(o+a)),h=Math.abs(e-(i-l)),d=Math.abs(e-(i+l)),f=Math.min(r,s,h,d);return f===r?(c=-1,u=0,{nx:c,ny:u,penetration:n+r}):f===s?(c=1,u=0,{nx:c,ny:u,penetration:n+s}):f===h?(c=0,u=-1,{nx:c,ny:u,penetration:n+h}):(c=0,u=1,{nx:c,ny:u,penetration:n+d})}const d=Math.sqrt(h);return{nx:c/d,ny:u/d,penetration:n-d}}function Af(t,e){if("circle"===t.shape.type&&"circle"===e.shape.type)return function(t,e,n,o,i,r){const s=o-t,a=i-e,l=n+r,c=s*s+a*a;if(c>=l*l)return null;if(ff>=c)return{nx:1,ny:0,penetration:l};const u=Math.sqrt(c);return{nx:s/u,ny:a/u,penetration:l-u}}(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.radius);if("aabb"===t.shape.type&&"aabb"===e.shape.type)return kf(t.x,t.y,t.shape.width,t.shape.height,e.x,e.y,e.shape.width,e.shape.height);if("circle"===t.shape.type&&"aabb"===e.shape.type){const n=Sf(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height);return n?{nx:-n.nx,ny:-n.ny,penetration:n.penetration}:null}return"aabb"===t.shape.type&&"circle"===e.shape.type?Sf(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height):null}function Mf(t,e){const n=e.shape;return"aabb"===n.type?"circle"===t.shape.type?Sf(t.x,t.y,t.shape.radius,n.x,n.y,n.width,n.height):kf(n.x,n.y,n.width,n.height,t.x,t.y,t.shape.width,t.shape.height):function(t,e,n,o,i,r,s,a=0){const l=r-o,c=s-i,u=l*l+c*c,h=u>ff?mf(((t-o)*l+(e-i)*c)/u,0,1):0,d=n+a/2,f=t-(o+l*h),p=e-(i+c*h),y=f*f+p*p;if(y>=d*d)return null;if(ff>=y){const t=Math.sqrt(u);return t>ff?{nx:-c/t,ny:l/t,penetration:d}:{nx:1,ny:0,penetration:d}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:d-g}}(t.x,t.y,"circle"===t.shape.type?t.shape.radius:Math.sqrt(t.shape.width*t.shape.width+t.shape.height*t.shape.height)/2,n.x1,n.y1,n.x2,n.y2,n.thickness??0)}function _f(t,e){return`${t}\0${e}`}function Pf(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function Cf(t){return{id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,bodyCollisions:t.bodyCollisions,shape:yf(t.shape),sleeping:t.sleeping,datum:t.datum,index:t.index,sleepTime:t.sleepTime,restitution:t.restitution,friction:t.friction}}function Tf(t){return t&&"function"!=typeof t?{property:t.property,equals:t.equals,notEquals:t.notEquals,oneOf:t.oneOf?.slice(),notOneOf:t.notOneOf?.slice()}:t}function Lf(t){return{id:t.id,shape:gf(t.shape),sensor:t.sensor,restitution:t.restitution,friction:t.friction,bodyFilter:Tf(t.bodyFilter),index:t.index}}function Rf(t,e){return!!e?.some(e=>Object.is(t,e))}function $f(t,e){const n=t.bodyFilter;if(!n)return!0;if("function"==typeof n)return n(e);const o=function(t,e){if(!e)return;let n=t;for(const t of e.split(".")){if(null==n||"object"!=typeof n)return;n=n[t]}return n}(e,n.property);return!("equals"in n&&!Object.is(o,n.equals)||"notEquals"in n&&Object.is(o,n.notEquals)||n.oneOf&&!Rf(o,n.oneOf)||n.notOneOf&&Rf(o,n.notOneOf))}var zf=class{constructor(t={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...df,...t},this.random=c(this.options.seed)}init(t={}){this.options={...df,...t},this.random=c(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(t){const e={id:t.id,x:t.x,y:t.y,prevX:t.x,prevY:t.y,vx:t.vx??0,vy:t.vy??0,angle:t.angle??0,mass:Math.max(ff,t.mass??1),bodyCollisions:t.bodyCollisions??!0,shape:yf(t.shape),sleeping:!1,datum:t.datum,restitution:t.restitution,friction:t.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(t.id,e)}remove(t){for(const e of t){this.bodies.delete(e);for(const t of Array.from(this.activeSensors))Pf(t).bodyId===e&&this.activeSensors.delete(t)}}setColliders(t){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const e of t)this.colliders.set(e.id,{...e,shape:gf(e.shape),bodyFilter:Tf(e.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(t){const e=t.id??"spring-"+this.nextSpringIndex;return this.springs.set(e,{id:e,bodyId:t.bodyId,target:t.target,restLength:t.restLength??0,stiffness:t.stiffness??40,damping:t.damping??3}),this.nextSpringIndex+=1,e}removeConstraint(t){this.springs.delete(t)}applyImpulse(t,e,n){const o=this.bodies.get(t);o&&(o.vx+=e/o.mass,o.vy+=n/o.mass,this.wake(o))}step(t=this.options.fixedDt){const e=Math.max(0,t);if(this.lastEvents=[],0===e)return;const n=this.sortedBodies();for(const t of n)t.prevX=t.x,t.prevY=t.y;this.applySprings(e);const o=this.options.maxVelocity;for(const t of n)if(!t.sleeping){if(t.vx+=this.options.gravity.x*e,t.vy+=this.options.gravity.y*e,t.vx*=this.options.velocityDamping,t.vy*=this.options.velocityDamping,o>0){const e=Math.sqrt(t.vx*t.vx+t.vy*t.vy);if(e>o){const n=o/e;t.vx*=n,t.vy*=n}}t.x+=t.vx*e,t.y+=t.vy*e}this.supportedThisStep.clear();const i=this.bodyPairKeys(n),r=this.sortedColliders().filter(t=>!t.sensor);for(let t=0;this.options.collisionIterations>t;t+=1)this.resolveBodyPairs(n,i,0===t),this.resolveColliders(n,r,0===t);this.updateSensors(n),this.updateSleeping(n,e)}settle(t=1200,e=this.options.fixedDt){let n=0;for(;t>n&&!this.allSleeping();)this.step(e),n+=1;return n}readState(t=[]){t.length=0;for(const e of this.sortedBodies())t.push({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:yf(e.shape),sleeping:e.sleeping,datum:e.datum});return t}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Pf)}allSleeping(){for(const t of this.bodies.values())if(!t.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(Cf),colliders:this.sortedColliders().map(Lf),springs:Array.from(this.springs.values()).map(t=>({...t,target:{...t.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(t){this.options={...t.options,gravity:{...t.options.gravity}},this.random=c(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(t.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const e of t.bodies){const t=Cf(e);this.bodies.set(t.id,t),this.nextBodyIndex=Math.max(this.nextBodyIndex,t.index+1)}this.nextColliderIndex=0;for(const e of t.colliders){const t=Lf(e);this.colliders.set(t.id,t),this.nextColliderIndex=Math.max(this.nextColliderIndex,t.index+1)}this.nextSpringIndex=0;for(const e of t.springs){this.springs.set(e.id,{...e,target:{...e.target}});const t=/^spring-(\d+)$/.exec(e.id);t&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(t[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((t,e)=>t.index-e.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((t,e)=>t.index-e.index)}applySprings(t){for(const e of Array.from(this.springs.values()).sort((t,e)=>t.id.localeCompare(e.id))){const n=this.bodies.get(e.bodyId);if(!n||n.sleeping)continue;const o="point"===e.target.type?e.target:this.bodies.get(e.target.bodyId);if(!o)continue;const i=o.x-n.x,r=o.y-n.y,s=Math.sqrt(i*i+r*r);if(ff>=s)continue;const a=i/s,l=r/s,c=(s-e.restLength)*e.stiffness+((("vx"in o?o.vx:0)-n.vx)*a+(("vy"in o?o.vy:0)-n.vy)*l)*e.damping;n.vx+=c*a*t/n.mass,n.vy+=c*l*t/n.mass}}resolveBodyPairs(t,e,n){for(const o of e){const[e,i]=o.split(":").map(Number),r=t[e],s=t[i];if(!r||!s)continue;const a=Af(r,s);a&&(this.resolveDynamicCollision(r,s,a),n&&this.lastEvents.push({type:"contact",bodyId:r.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(t){const e=Math.max(1,this.options.cellSize),n=new Map;for(let o=0;t.length>o;o+=1){if(!1===t[o].bodyCollisions)continue;const i=bf(t[o]),r=Math.floor(i.minX/e),s=Math.floor(i.maxX/e),a=Math.floor(i.minY/e),l=Math.floor(i.maxY/e);for(let t=r;s>=t;t+=1)for(let e=a;l>=e;e+=1){const i=`${t}:${e}`,r=n.get(i);r?r.push(o):n.set(i,[o])}}const o=new Set;for(const e of Array.from(n.keys()).sort()){const i=n.get(e)??[];i.sort((t,e)=>t-e);for(let e=0;i.length>e;e+=1)for(let n=e+1;i.length>n;n+=1){const r=i[e],s=i[n];!1!==t[r].bodyCollisions&&!1!==t[s].bodyCollisions&&wf(bf(t[r]),bf(t[s]))&&o.add(`${r}:${s}`)}}return Array.from(o).sort((t,e)=>{const[n,o]=t.split(":").map(Number),[i,r]=e.split(":").map(Number);return n===i?o-r:n-i})}resolveDynamicCollision(t,e,n){t.sleeping&&this.supportedThisStep.add(e.id),e.sleeping&&this.supportedThisStep.add(t.id);const o=t.sleeping?0:1/t.mass,i=e.sleeping?0:1/e.mass,r=o+i;if(ff>=r)return;const s=Math.max(0,n.penetration-pf)/r;t.x-=n.nx*s*o,t.y-=n.ny*s*o,e.x+=n.nx*s*i,e.y+=n.ny*s*i;const a=(e.vx-t.vx)*n.nx+(e.vy-t.vy)*n.ny;if(a>0)return;const l=Math.abs(a),c=-(1+Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution))*a/r,u=c*n.nx,h=c*n.ny;t.vx-=u*o,t.vy-=h*o,e.vx+=u*i,e.vy+=h*i,this.applyFriction(t,e,n,c,o,i),l>this.options.contactWakeSpeed&&(this.wake(t),this.wake(e))}applyFriction(t,e,n,o,i,r){const s=-n.ny,a=n.nx,l=(e.vx-t.vx)*s+(e.vy-t.vy)*a,c=i+r;if(ff>=Math.abs(l)||ff>=c)return;const u=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction))),h=mf(-l/c,-o*u,o*u),d=h*s,f=h*a;t.vx-=d*i,t.vy-=f*i,e.vx+=d*r,e.vy+=f*r}resolveColliders(t,e,n){for(const o of t)for(const t of e){if(!$f(t,o))continue;if(!wf(bf(o),vf(t)))continue;const e=Mf(o,t);e&&(this.resolveStaticCollision(o,t,e),this.supportedThisStep.add(o.id),n&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:t.id,sensor:!1}))}}resolveStaticCollision(t,e,n){t.x+=n.nx*Math.max(0,n.penetration-pf),t.y+=n.ny*Math.max(0,n.penetration-pf);const o=t.vx*n.nx+t.vy*n.ny;if(0>o){const i=Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution);t.vx-=(1+i)*o*n.nx,t.vy-=(1+i)*o*n.ny;const r=-n.ny,s=n.nx,a=t.vx*r+t.vy*s,l=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction)));t.vx-=a*r*l,t.vy-=a*s*l}}updateSensors(t){const e=new Set,n=this.sortedColliders().filter(t=>t.sensor);for(const o of t){const t=bf(o);for(const i of n){if(!$f(i,o))continue;if(!wf(t,vf(i)))continue;if(!Mf(o,i))continue;const n=_f(i.id,o.id);e.add(n),this.activeSensors.has(n)||this.lastEvents.push({type:"sensor-enter",bodyId:o.id,sensorId:i.id})}}for(const t of Array.from(this.activeSensors).sort()){if(e.has(t))continue;const{sensorId:n,bodyId:o}=Pf(t);this.lastEvents.push({type:"sensor-exit",bodyId:o,sensorId:n})}this.activeSensors=e}updateSleeping(t,e){const n=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const o of t)Math.sqrt(o.vx*o.vx+o.vy*o.vy)>=this.options.sleepSpeed||Math.sqrt((o.x-o.prevX)*(o.x-o.prevX)+(o.y-o.prevY)*(o.y-o.prevY))>=this.options.sleepSpeed*e||n&&!this.supportedThisStep.has(o.id)?o.sleeping?this.wake(o):o.sleepTime=0:(o.sleepTime+=e,o.sleeping||this.options.sleepAfter>o.sleepTime||(o.sleeping=!0,o.vx=0,o.vy=0,this.lastEvents.push({type:"sleep",bodyId:o.id})))}wake(t){t.sleeping&&this.lastEvents.push({type:"wake",bodyId:t.id}),t.sleeping=!1,t.sleepTime=0}nextRandom(){return this.random()}},Df=class{constructor(t={}){this.id="builtin",this.capabilities={...(new zf).capabilities,engine:"builtin"},this.world=new zf(t)}init(t={}){this.world.init(t)}spawn(t){this.world.spawn(t)}remove(t){this.world.remove(t)}setColliders(t){this.world.setColliders(t)}setConstraint(t){return this.world.setConstraint(t)}removeConstraint(t){this.world.removeConstraint(t)}applyImpulse(t,e,n){this.world.applyImpulse(t,e,n)}step(t){this.world.step(t)}settle(t,e){return this.world.settle(t,e)}readState(t){return this.world.readState(t)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(t){this.world.restore(t)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function If(t,e={}){return t?"function"==typeof t?t(e):(t.init(e),t):function(t={}){return new Df(t)}(e)}var Bf=["binId","targetBin","category","windowIndex","lane","group"];function Ff(t,e){if(!Number.isFinite(e))return;t.count+=1,t.total+=e,t.min=Math.min(t.min,e),t.max=Math.max(t.max,e);const n=e-t.mean;t.mean+=n/t.count,t.m2+=n*(e-t.mean)}function Ef(t){return{count:t.count,total:t.total,mean:t.count>0?t.mean:0,min:t.count>0?t.min:0,max:t.count>0?t.max:0,variance:t.count>1?t.m2/(t.count-1):0}}function Of(t){return{count:t.count,total:t.total,mean:t.mean,m2:t.variance*Math.max(0,t.count-1),min:t.count>0?t.min:1/0,max:t.count>0?t.max:-1/0}}function Nf(t,e){if(null!=t[e])return t[e];const n=t.datum;return n&&"object"==typeof n?n[e]:void 0}function Wf(t,e,n){return"function"==typeof t?t(e,n):"string"==typeof t?Nf(e,t):void 0}function jf(t){if(null==t)return;const e=t+"";return e.trim()?e:void 0}function Yf(t){const e=Ef(t.value);return{id:t.id,label:t.label,count:e.count,total:e.total,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:Ef(t.x),y:Ef(t.y),value:e}}var Gf=class{constructor(t=!1){this.bins=new Map,this.nextIndex=0,this.config=t}updateConfig(t){void 0!==t&&(this.config=t,!1===t&&this.clear())}isEnabled(){return!1!==this.config}add(t){if(!1===this.config)return null;const e=this.nextIndex;this.nextIndex+=1;const n=jf(Wf(this.config.binAccessor,t,e))??function(t){for(const e of Bf){const n=jf(Nf(t,e));if(n)return n}return"sediment"}(t),o=jf(Wf(this.config.labelAccessor,t,e))??n,i=function(t,e,n){if("number"==typeof t)return t;const o="function"==typeof t?t(e,n):"string"==typeof t?Nf(e,t):1,i="number"==typeof o?o:Number(o);return Number.isFinite(i)?i:1}(this.config.valueAccessor,t,e),r=Math.max(0,Math.floor(this.config.retainBodyIds??12));let s=this.bins.get(n);return s||(s={id:n,label:o,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(n,s)),s.label=o,s.lastBodyId=t.id,s.lastDatum=t.datum,Ff(s.x,t.x),Ff(s.y,t.y),Ff(s.value,i),r>0&&(s.bodyIds.push(t.id),s.bodyIds.length>r&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-r))),Yf(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(Yf)}restore(t=[]){this.bins.clear();for(const e of t)this.bins.set(e.id,{id:e.id,label:e.label,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:Of(e.x),y:Of(e.y),value:Of(e.value)});this.nextIndex=t.reduce((t,e)=>t+e.count,0)}totals(){const t=this.snapshot();return{bins:t.length,count:t.reduce((t,e)=>t+e.count,0),total:t.reduce((t,e)=>t+e.total,0)}}};function qf(t){const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}var Xf={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},Hf={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function Vf(t={},e=Hf){return{chartId:t.chartId??e.chartId,chartType:t.chartType??e.chartType,sensors:t.sensors??e.sensors,onObservation:t.onObservation??e.onObservation,onSimulationStateChange:t.onSimulationStateChange??e.onSimulationStateChange}}function Uf(t){return{...t,shape:{...t.shape},datum:t.datum,springs:t.springs?.map(t=>({...t,target:{...t.target}}))}}function Kf(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:void 0}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:void 0}function Zf(t,e){if(null!=t[e])return t[e];const n=t.datum;return n&&"object"==typeof n?n[e]:void 0}function Qf(t){return{...Uf(t),sequence:t.sequence,spawnAt:t.spawnAt}}function Jf(t){return t.map(t=>({...t,shape:{...t.shape},bodyFilter:t.bodyFilter&&"function"!=typeof t.bodyFilter?{...t.bodyFilter,oneOf:t.bodyFilter.oneOf?.slice(),notOneOf:t.bodyFilter.notOneOf?.slice()}:t.bodyFilter}))}function tp(t){return!1!==t&&{...t}}function ep(t,e){return t.spawnAt===e.spawnAt?t.sequence-e.sequence:t.spawnAt-e.spawnAt}function np(t){return{...t,gravity:{...t.gravity}}}function op(t,e,n,o){if("circle"===t.shape.type){const i=t.x-e,r=t.y-n,s=t.shape.radius+o,a=i*i+r*r;return a>s*s?null:a}const i=Math.max(Math.abs(e-t.x)-t.shape.width/2,0),r=Math.max(Math.abs(n-t.y)-t.shape.height/2,0),s=i*i+r*r;return s>o*o?null:s}function ip(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function rp(t,e={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:i=!1,includeLeftWall:r=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:l=a}=e,c=[],u=t.x+t.width/2,h=t.y+t.height/2;return o&&c.push({id:n+"-floor",shape:{type:"aabb",x:u,y:t.y+t.height+l/2,width:t.width+2*a,height:l}}),i&&c.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:t.y-l/2,width:t.width+2*a,height:l}}),r&&c.push({id:n+"-left-wall",shape:{type:"aabb",x:t.x-a/2,y:h,width:a,height:t.height+2*l}}),s&&c.push({id:n+"-right-wall",shape:{type:"aabb",x:t.x+t.width+a/2,y:h,width:a,height:t.height+2*l}}),c}function sp(t){const{idPrefix:e="bin",count:n,domainStart:o,domainStep:i,xScale:r,yTop:s,yBottom:a,wallThickness:l=4,includeBoundaryWalls:c=!0,includeInteriorWalls:u=!0,closedBefore:h,lidY:d=s,lidThickness:f=Math.max(2,l)}=t,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=c?n:n-1;if(u||c)for(let t=c?0:1;m>=t;t+=1){if(!u&&t>0&&n>t)continue;const s=r(o+t*i);p.push({id:`${e}-wall-${t}`,shape:{type:"aabb",x:s,y:y,width:l,height:g}})}if(null!=h)for(let t=0;n>t;t+=1){const n=o+t*i,s=n+i;if(s>=h)continue;const a=r(n),c=r(s);p.push({id:`${e}-lid-${t}`,shape:{type:"segment",x1:Math.min(a,c)+l/2,y1:d,x2:Math.max(a,c)-l/2,y2:d,thickness:f}})}return p}import{quadtree as ap}from"d3-quadtree";var lp=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(t,e,n,o,i,r=0){const s=this.ensure(t,e);if(!s)return null;let a=null,l=1/0;const c=Math.max(0,r)+this.maxSearchRadius,u=o-c,h=o+c,d=i-c,f=i+c;return s.visit((t,e,s,c,p)=>{if(u>c||e>h||d>p||s>f)return!0;if(t.length)return!1;let y=t;for(;y;){const t=y.data;if(t){const e=op(t,o,i,Math.max(0,r));null!=e&&(l>e||e===l&&n.indexOf(t.id)>n.indexOf(a?.id??""))&&(a=t,l=e)}y=y.next}return!1}),a}ensure(t,e){if(this.tree&&this.revision===e)return this.tree;const n=t.readState();return 0===n.length?(this.tree=null,this.maxSearchRadius=0,this.revision=e,null):(this.maxSearchRadius=n.reduce((t,e)=>Math.max(t,function(t){return"circle"===t.shape.type?t.shape.radius:Math.hypot(t.shape.width,t.shape.height)/2}(e)),0),this.tree=ap().x(t=>t.x).y(t=>t.y).addAll(n),this.revision=e,this.tree)}},cp=["data","scene-geometry","data-paint","accessibility","evidence"],up=["scene-geometry","data-paint","accessibility","evidence"],hp=["overlay","accessibility","evidence"],dp=(t,e)=>({retainedData:t,invalidations:e}),fp=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],pp=["scene-geometry","data-paint","accessibility","evidence"],yp=[],gp={engine:dp("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:dp("preserve",pp),colliders:dp("preserve",pp),sediment:dp("preserve",pp),bodyBudget:dp("preserve",fp),bodyLimit:dp("preserve",fp),eviction:dp("preserve",fp),fixedDt:dp("preserve",yp),maxDeltaSeconds:dp("preserve",yp),maxSubsteps:dp("preserve",yp),settleStepLimit:dp("preserve",yp),timeScale:dp("preserve",yp),observation:dp("preserve",yp)},mp=dp("preserve",fp);function xp(t){let e="preserve";const n=new Set;for(const o of t){const t=gp[o]??mp;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)n.add(e)}return{retainedData:e,invalidations:n}}var bp=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function vp(t,e){return t===e||!(!t||!e)&&t.gravity?.x===e.gravity?.x&&t.gravity?.y===e.gravity?.y&&bp.every(n=>t[n]===e[n])}function wp(t,e,n,o){return t||!e?"paused":n||!o?"running":"settled"}var kp=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(t){this.speed=function(t){const e=t?.sleepSpeed;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:8}(t)}reset(){this.seconds=0}isAtRest(){return this.seconds>=.6}refresh(t,e,n){if(n>0)return void(this.seconds=0);const o=t.readState(this.scratch),i=this.speed*this.speed;let r=!0;for(const t of o)if(!t.sleeping&&t.vx*t.vx+t.vy*t.vy>=i){r=!1;break}this.seconds=r?this.seconds+Math.max(0,e):0}},Sp=class{constructor(t={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new lp,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new Gn,this.simulationState="settled",this.visible=!0,this.quiescence=new kp;const{bodyBudget:e,colliders:n,engine:o,kernel:i,observation:r,sediment:s,...a}=t;this.config={...Xf,...a},this.configInput={...t},this.bodyBudget=e??{},this.engineInput=o,this.observation=Vf(r),this.sediment=new Gf(s??!1),this.world=If(o,{fixedDt:this.config.fixedDt,...i}),this.quiescence.setKernelOptions(i),n&&this.world.setColliders(Jf(n))}updateConfig(t){const e=function(t,e){return Object.keys(t).filter(n=>"kernel"===n?!vp(t.kernel,e.kernel):t[n]!==e[n])}(t,this.configInput),{colliders:n,bodyBudget:o,engine:i,kernel:r,observation:s,sediment:a,...l}=t;if(this.config={...this.config,...l},void 0!==o&&(this.bodyBudget=o,!1===o&&(this.bodyBudgetObservationKey="ok")),i&&i!==this.engineInput){const t=this.world.snapshot();this.world.dispose(),this.engineInput=i,this.world=If(i,t.options),this.world.restore(t),this.revision+=1}if(r&&!vp(r,this.configInput.kernel)){const t=this.world.snapshot(),e={...t.options,...r,gravity:{...t.options.gravity,...r.gravity}};this.world.restore({...t,options:e}),this.quiescence.setKernelOptions(e),this.revision+=1}s&&(this.observation=Vf(s,this.observation)),this.sediment.updateConfig(a),n&&(this.world.setColliders(Jf(n)),this.revision+=1),this.configInput={...this.configInput,...t};const c=xp(e);this.updateResults.record({kind:"config",keys:e},c.invalidations)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setColliders(t){this.world.setColliders(Jf(t)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},xp(["colliders"]).invalidations)}enqueue(t,e){const n=Array.isArray(t)?t:[t],o=e?function(t,e={}){const n=Kf(e.startAt)??0,o=e.pacing??"immediate";if("arrival"===o){const o=t.map((t,n)=>function(t,e,n){return"function"==typeof n?Kf(n(t,e)):"string"==typeof n?Kf(Zf(t,n)):Kf(t.spawnAt)??Kf(Zf(t,"arrivalTime"))??Kf(Zf(t,"timestamp"))??Kf(Zf(t,"time"))??Kf(Zf(t,"eventTime"))}(t,n,e.timeAccessor)),i=o.filter(t=>null!=t),r=i.length>0?Math.min(...i):0,s=Kf(e.timeScale)??1,a=s>0?s:1;return t.map((t,e)=>{const i=o[e],s=null==i?0:Math.max(0,i-r);return{...Uf(t),spawnAt:n+s/a}})}if("object"==typeof o){const e=Kf(o.ratePerSec);if(e&&e>0)return t.map((t,o)=>({...Uf(t),spawnAt:n+o/e}))}return t.map(t=>({...Uf(t),spawnAt:n}))}(n,{...e,startAt:e.startAt??this.elapsedSeconds}):n;for(const t of o)this.queue.push({...Uf(t),sequence:this.nextSequence,spawnAt:t.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(ep),o.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:o.length},o.length?cp:[])}enqueueWithResult(t,e){return this.enqueue(t,e),this.updateResults.last}spawnNow(t){this.spawnOne(Uf(t)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},cp)}materializeDueSpawns(){const t=this.revision,e=[],n=[];return this.spawnDue(e,n),0===e.length||(this.observeBodyBudget(n),this.evictOverflow(n),this.syncSimulationState(n),this.revision+=1,this.updateResults.record({kind:"enqueue",count:e.length},this.revision!==t?cp:[])),e}clear(){const t=this.world.snapshot().options;this.world.init({...t,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.quiescence.reset(),this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},cp)}tick(t){const e=this.revision,n=[],o=[],i=[],r=[],s=[];if(this.paused||!this.visible){const t=this.result(0,n,o,i,r,s,!1);return this.updateResults.record({kind:"tick",count:0},[]),t}const a=Math.max(0,Math.min(t,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(n,s);const l=this.observeBodyBudget(s),c=this.evictOverflow(s);o.push(...c.evicted),i.push(...c.sedimented),this.syncSimulationState(s),this.accumulator+=a;let u=0;for(;this.accumulator>=this.config.fixedDt&&this.config.maxSubsteps>u;){this.world.step(this.config.fixedDt);const t=this.world.events();r.push(...t),this.observeKernelEvents(t,s),this.observeSensorTransitions(s),this.accumulator-=this.config.fixedDt,u+=1}u===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),this.quiescence.refresh(this.world,a,n.length),(u>0||n.length>0||o.length>0||i.length>0||r.length>0)&&(this.revision+=1);const h=this.result(u,n,o,i,r,s,void 0,l);return this.updateResults.record({kind:"tick",count:u},this.revision!==e?n.length||o.length||i.length?cp:up:[]),h}settle(t=this.config.settleStepLimit){const e=this.revision;this.spawnDue([],[]);const n=this.world.settle(t,this.config.fixedDt);return n>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:n},this.revision!==e?up:[]),n}settleWithObservations(t=this.config.settleStepLimit){const e=this.revision,n=[],o=[],i=[],r=[],s=[];if(this.paused||!this.visible){const t=this.result(0,n,o,i,r,s,!1);return this.updateResults.record({kind:"settle",count:0},[]),t}this.spawnDue(n,s);const a=this.observeBodyBudget(s),l=this.evictOverflow(s);o.push(...l.evicted),i.push(...l.sedimented),this.syncSimulationState(s);let c=0;for(n.length>0&&this.quiescence.reset();t>c&&!this.atRest();){this.world.step(this.config.fixedDt);const t=this.world.events();r.push(...t),this.observeKernelEvents(t,s),this.observeSensorTransitions(s),c+=1,this.quiescence.refresh(this.world,this.config.fixedDt,0)}(c>0||n.length>0||o.length>0||i.length>0||r.length>0)&&(this.revision+=1);const u=this.result(c,n,o,i,r,s,void 0,a);return this.updateResults.record({kind:"settle",count:c},this.revision!==e?n.length||o.length||i.length?cp:up:[]),u}readBodies(t=[]){return this.world.readState(t)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(t={}){return function(t,e={}){const{baselineY:n=0,binWidth:o=24,gap:i=2,maxHeight:r=80,value:s="count",x:a}=e,l=Math.max(1,...t.map(t=>t[s]));return t.map((t,e)=>{const c=Math.max(0,t[s]/l*r),u=a?.(t,e)??e*(o+i);return{binId:t.id,label:t.label,index:e,count:t.count,total:t.total,x:u,y:n-c,width:o,height:c,meanX:t.x.mean,meanY:t.y.mean}})}(this.readSediment(),t)}hitTest(t,e,n=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,t,e,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(t){const{timestamp:e,chartType:n,chartId:o,...i}=t,r={...i,timestamp:e??this.elapsedSeconds,chartType:n??this.observation.chartType,chartId:o??this.observation.chartId};return this.emitObservation(r),this.updateResults.record({kind:"update",count:1},["evidence"]),r}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(t){return this.updateResults.subscribe(t)}version(){return this.revision}setPaused(t){const e=this.paused!==t;this.paused=t,this.syncSimulationState(),this.updateResults.record({kind:"pause"},e?hp:[])}setVisible(t){const e=this.visible!==t;this.visible=t,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},e?hp:[])}remove(t){const e=new Set(t),n=new Set(this.liveBodyOrder),o=new Set(this.queue.map(t=>t.id));this.queue=this.queue.filter(t=>!e.has(t.id)),this.liveBodyOrder=this.liveBodyOrder.filter(t=>!e.has(t)),this.world.remove(t),this.removeActiveSensorPairsForBodies(e);const i=t.filter(t=>n.has(t)||o.has(t));return i.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:i,count:i.length},i.length?cp:[]),i}setConstraint(t){const e=this.world.setConstraint(t);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},up),e}removeConstraint(t){this.world.removeConstraint(t),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},up)}applyImpulse(t,e,n){this.world.applyImpulse(t,e,n),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[t]},up)}nextRandom(){return this.world.nextRandom()}controls(){return t=this,{applyImpulse:(e,n,o)=>t.applyImpulse(e,n,o),clear:()=>t.clear(),hitTest:(e,n,o)=>t.hitTest(e,n,o),pause:()=>t.setPaused(!0),push:(e,n)=>t.enqueue(e,n),pushMany:(e,n)=>t.enqueue(e,n),bodyBudgetStatus:()=>t.bodyBudgetStatus(),readBodies:e=>t.readBodies(e),readSediment:()=>t.readSediment(),recordObservation:e=>t.recordObservation(e),remove:e=>t.remove(e),restore:e=>t.restore(e),resume:()=>t.setPaused(!1),settle:e=>t.settle(e),settleWithObservations:e=>t.settleWithObservations(e),snapshot:()=>t.snapshot(),sedimentHeightfield:e=>t.sedimentHeightfield(e),sedimentTotals:()=>t.sedimentTotals(),step:e=>t.tick(e)};var t}snapshot(){const t=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:tp(this.bodyBudget),config:{...this.config,kernel:np(t.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(Qf),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:t}}restore(t){this.config={bodyLimit:t.config.bodyLimit,eviction:t.config.eviction,fixedDt:t.config.fixedDt,maxDeltaSeconds:t.config.maxDeltaSeconds,maxSubsteps:t.config.maxSubsteps,settleStepLimit:t.config.settleStepLimit,timeScale:t.config.timeScale},this.configInput={...t.config,bodyBudget:tp(t.bodyBudget??{}),kernel:np(t.world.options)},this.bodyBudget=tp(t.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.quiescence.setKernelOptions(t.world.options),this.quiescence.reset(),this.activeSensorPairs=new Set(t.activeSensorPairs),this.accumulator=t.accumulator,this.elapsedSeconds=t.elapsedSeconds,this.paused=t.paused,this.queue=t.queue.map(Qf).sort(ep),this.revision=t.revision,this.sediment.restore(t.sediment??[]),this.simulationState=t.simulationState??wp(t.paused,t.visible,t.queue.length>0,t.world.bodies.every(t=>t.sleeping)),this.liveBodyOrder=t.liveBodyOrder.slice(),this.visible=t.visible,this.nextSequence=this.queue.reduce((t,e)=>Math.max(t,e.sequence),-1)+1,this.world.restore(t.world),this.updateResults.record({kind:"restore"},cp)}spawnDue(t,e){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const n=this.queue.shift();if(!n)return;this.spawnOne(n,e),t.push(n.id)}}spawnOne(t,e){this.liveBodyOrder=this.liveBodyOrder.filter(e=>e!==t.id),this.removeActiveSensorPairsForBodies(new Set([t.id])),this.world.spawn(t),this.liveBodyOrder.push(t.id);for(const e of t.springs??[])this.world.setConstraint({...e,bodyId:t.id});const n=this.world.readState().find(e=>e.id===t.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:t.id,datum:n?.datum??t.datum,x:n?.x??t.x,y:n?.y??t.y},e)}result(t,e,n,o,i,r,s,a=this.evaluateBodyBudget()){this.syncSimulationState(r);const l=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:n,events:i,observations:r,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!this.atRest()),sleeping:l,sedimented:o,spawned:e,steps:t}}observeKernelEvents(t,e){!function(t,e,n){if(0===e.length)return;const o=new Map(t.readState().map(t=>[t.id,t]));for(const t of e){if("sleep"!==t.type)continue;const e=o.get(t.bodyId);n.emit({type:"physics-settle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:t.bodyId,datum:e?.datum,x:e?.x,y:e?.y})}}(this.world,t,this.observationContext(e))}observeSensorTransitions(t){this.activeSensorPairs=function(t,e,n){const o=new Set(t.activeSensorPairs().map(t=>`${t.sensorId}\0${t.bodyId}`));if(0===o.size&&0===e.size)return o;const i=new Map(t.readState().map(t=>[t.id,t])),r=(t,e)=>{const{sensorId:o,bodyId:r}=ip(e),s=n.observation.sensors[o],a=i.get(r);n.emit({type:"enter"===t?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:r,datum:a?.datum,x:a?.x,y:a?.y,sensorId:o,binId:s?.binId??o})};for(const t of Array.from(o).sort())e.has(t)||r("enter",t);for(const t of Array.from(e).sort())o.has(t)||r("exit",t);return o}(this.world,this.activeSensorPairs,this.observationContext(t))}removeActiveSensorPairsForBodies(t){!function(t,e){for(const n of t)e.has(ip(n).bodyId)&&t.delete(n)}(this.activeSensorPairs,t)}observationContext(t){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:e=>this.emitObservation(e,t)}}emitObservation(t,e){e?.push(t),this.observation.onObservation?.(t)}evaluateBodyBudget(){return function(t){const e=Math.max(0,Math.floor(t.liveBodies)),n=Math.max(0,Math.floor(t.queuedBodies??0)),o=e+n,i=qf(t.bodyLimit),r=qf(t.engineMaxBodiesHint),s=function(t,e,n){if(!1===n)return;const o=qf(n?.warnAt);return null!=o?o:null!=t?Math.max(1,Math.floor(.8*t)):null!=e?Math.max(1,Math.floor(.8*e)):void 0}(i,r,t.options),a=null==i?0:Math.max(0,e-i),l=a>0?"overflow":null==s||s>o?"ok":"warning";return{action:"overflow"!==l?"continue":t.sedimentEnabled?"sediment":t.evictionEnabled?"evict":"retain",bodyLimit:i,engineMaxBodiesHint:r,liveBodies:e,overflow:a,projectedBodies:o,queuedBodies:n,state:l,warnAt:s}}({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(t){const e=this.evaluateBodyBudget();if("ok"===e.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",e;const n=`${e.state}:${e.action}`;return n===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=n,this.emitObservation({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:e.action,bodyLimit:e.bodyLimit,engineMaxBodiesHint:e.engineMaxBodiesHint,liveBodies:e.liveBodies,overflow:e.overflow,projectedBodies:e.projectedBodies,queuedBodies:e.queuedBodies,warnAt:e.warnAt},t)),e}syncSimulationState(t){const e=wp(this.paused,this.visible,this.queue.length>0,this.atRest());if(e===this.simulationState)return;const n=this.simulationState;this.simulationState=e,function(t,e,n){n.observation.onSimulationStateChange?.(e,t),"running"!==e&&"settled"!==e||n.emit({type:"running"===e?"sim-active":"sim-idle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,simulationState:e,previousSimulationState:t})}(n,e,this.observationContext(t))}evictOverflow(t){const{evicted:e,sedimented:n,liveBodyOrder:o}=function(t,e,n,o,i,r){const s={evicted:[],sedimented:[],liveBodyOrder:i};if(!1===n)return s;const a=Math.max(0,Math.floor(o));if(!Number.isFinite(a))return s;const l=i.length-a;if(0>=l)return s;const c=function(t,e,n){if("sleeping-first"!==e)return n.slice();const o=new Map(t.readState().map(t=>[t.id,t.sleeping])),i=[],r=[];for(const t of n)o.get(t)?i.push(t):r.push(t);return[...i,...r]}(t,n,i),u=c.slice(0,l);if(0===u.length)return s;const h=function(t,e,n,o){const i=new Map(t.readState().map(t=>[t.id,t])),r=[];for(const t of n){const n=i.get(t);if(!n)continue;const s=e.add(n);s&&(r.push(t),o.emit({type:"physics-sediment",timestamp:o.elapsedSeconds,chartType:o.observation.chartType,chartId:o.observation.chartId,bodyId:t,datum:n.datum,x:n.x,y:n.y,binId:s.id,count:s.count,total:s.total}))}return r}(t,e,u,r);t.remove(u);const d=new Set(u);return{evicted:u,sedimented:h,liveBodyOrder:i.filter(t=>!d.has(t))}}(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(t));return e.length>0&&(this.liveBodyOrder=o,this.removeActiveSensorPairsForBodies(new Set(e))),{evicted:e,sedimented:n}}};import{scaleLinear as Ap}from"d3-scale";function Mp(t){const{count:e,idPrefix:n,wallThickness:o,xScale:i,yBottom:r,yTop:s,yTopForIndex:a}=t;return Array.from({length:e+1},(t,e)=>{const l=Math.min(r-1,a?.(e)??s),c=Math.max(1,r-l);return{id:`${n}-wall-${e}`,shape:{type:"aabb",x:i(e),y:l+c/2,width:o,height:c}}})}import{scaleLinear as _p}from"d3-scale";function Pp(t){if(Array.isArray(t)&&t.length>=2){const e=sf(t[0]),n=sf(t[1]);return null!=e&&null!=n?{x:e,y:n}:null}if(t&&"object"==typeof t){const e=t,n=sf(e.x),o=sf(e.y);return null!=n&&null!=o?{x:n,y:o}:null}return null}function Cp(t){return Array.isArray(t)?t.map(Pp).filter(t=>null!=t):[]}function Tp(t,e,n){return"normalized"===n?{x:e.plot.x+t.x*e.plot.width,y:e.plot.y+t.y*e.plot.height}:{x:af(t.x,e.plot.x,e.plot.x+e.plot.width),y:af(t.y,e.plot.y,e.plot.y+e.plot.height)}}function Lp(t){let e=0;for(let n=1;t.length>n;n+=1)e+=Math.hypot(t[n].x-t[n-1].x,t[n].y-t[n-1].y);return e}function Rp(t,e){if(0===t.length)return{x:0,y:0};if(1===t.length)return{...t[0]};const n=af(e,0,1)*Lp(t);let o=0;for(let e=1;t.length>e;e+=1){const i=t[e-1],r=t[e],s=Math.hypot(r.x-i.x,r.y-i.y);if(s>0){if(o+s>=n){const t=(n-o)/s;return{x:i.x+(r.x-i.x)*t,y:i.y+(r.y-i.y)*t}}o+=s}}return{...t[t.length-1]}}function $p(t,e){const n=Rp(t,Math.max(0,e-.02)),o=Rp(t,Math.min(1,e+.02)),i=o.x-n.x,r=o.y-n.y,s=Math.hypot(i,r)||1;return{x:i/s,y:r/s}}function zp(t,e,n){return Math.max(e,Math.min(n,t))}function Dp(t,e,n,o,i,r={}){return{id:t,friction:r.friction,restitution:r.restitution,bodyFilter:r.bodyFilter,shape:{type:"segment",x1:e,y1:n,x2:o,y2:i,thickness:r.thickness??8}}}function Ip(t){return{id:t.id,label:t.label,description:t.description,kind:t.kind,shape:(e=t.x,n=t.y,o=t.width,i=t.height,{type:"aabb",x:e,y:n,width:o,height:i}),bodyFilter:t.bodyFilter,collider:t.collider,colliderThickness:t.colliderThickness,friction:t.friction,restitution:t.restitution,semanticItem:t.semanticItem,metadata:t.metadata,bodyStyle:t.bodyStyle,attributes:t.attributes,onEnter:t.onEnter,onExit:t.onExit};var e,n,o,i}function Bp(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:12,y:0};return{...Ip({...t,kind:t.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.015}}function Fp(t,e=12){return"number"==typeof t?{x:t,y:0}:t&&"object"==typeof t?{x:Number.isFinite(t.x)?Number(t.x):e,y:Number.isFinite(t.y)?Number(t.y):0}:{x:e,y:0}}function Ep(t){const e=t.stages;if(!e.length)throw Error("buildProcessFlowPhysics requires at least one stage");const n=t.size,o=tf(n),i=af(t.ballRadius??6,2,18),r=t.seed??1,s=uf(r),a=t.idAccessor,l=t.stageAccessor??"stage",c=t.groupBy,u=t.groupLabelAccessor,h=t.workAccessor,d=t.radiusAccessor,f=t.groupCompletion??(c?"allAbsorbed":"none"),p=t.springStiffness??.28,y=t.springDamping??.72,g=!0===t.settle,m=e.map(t=>({id:t.id,label:t.label??t.id,description:t.description,share:t.share})),x=function(t){const e=t.shape??"lane",n=Math.max(1,Math.round(t.width)),o=Math.max(1,Math.round(t.height)),i=t.padX??46,r=t.padY??72,s=i,a=n-i,l=r,c=o-Math.max(24,Math.round(.45*r)),u=(l+c)/2,h=Math.max(1,c-l),d=zp(t.pinchRatio??.18,.06,.5),f=Number(t.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=zp(h*d+p,.06*h,.5*h),g=y/2,m=u-g,x=u+g,b=t.idPrefix??"process",v=t.friction??.58,w=t.restitution??.18,k=t.wallThickness??8,S=t.stages;if(!S.length)throw Error("processStageLayout requires at least one stage");const A=zp(t.centerStageIndex??Math.floor(S.length/2),0,S.length-1),M=function(t){const e=t.reduce((t,e)=>t+(e.share??1),0);return e>0?e:t.length}(S),_=a-s;let P=s;const C=S.map((t,e)=>{const n=P,o=e===S.length-1?a:P+(t.share??1)/M*_;return P=o,{id:t.id,label:t.label,description:t.description,kind:t.kind??"stage",index:e,x0:n,x1:o,x:(n+o)/2,width:o-n,y:u,height:h}}),T=C[A],L=T.x0,R=T.x1,$=(t,n)=>{if("lane"===e)return"top"===n?l:c;if("funnel"===e){const e=zp((t-s)/Math.max(1,a-s),0,1);return"top"===n?l+(m-l)*e:c+(x-c)*e}if(L>=t){const e=zp((t-s)/Math.max(1,L-s),0,1);return"top"===n?l+(m-l)*e:c+(x-c)*e}if(R>=t)return"top"===n?m:x;const o=zp((t-R)/Math.max(1,a-R),0,1);return"top"===n?m+(l-m)*o:x+(c-x)*o},z=C.map(t=>{const e=Math.min($(t.x0,"top"),$(t.x1,"top")),n=Math.max($(t.x0,"bottom"),$(t.x1,"bottom"));return{...t,y:(e+n)/2,height:Math.max(1,n-e)}}),D={thickness:k,friction:v,restitution:w},I=[];"lane"===e?I.push(Dp(b+"-top",s,l,a,l,D),Dp(b+"-bottom",s,c,a,c,D),Dp(b+"-left",s,l,s,c,{...D,thickness:Math.max(6,k-2)}),Dp(b+"-right",a,l,a,c,{...D,thickness:Math.max(6,k)})):"funnel"===e?I.push(Dp(b+"-top",s,l,a,m,D),Dp(b+"-bottom",s,c,a,x,D),Dp(b+"-left",s,l,s,c,{...D,thickness:Math.max(6,k-2)}),Dp(b+"-right",a,m,a,x,{...D,thickness:Math.max(6,k)})):I.push(Dp(b+"-left-top",s,l,L,m,D),Dp(b+"-left-bottom",s,c,L,x,D),Dp(b+"-center-top",L,m,R,m,D),Dp(b+"-center-bottom",L,x,R,x,D),Dp(b+"-right-top",R,m,a,l,D),Dp(b+"-right-bottom",R,x,a,c,D),Dp(b+"-left",s,l,s,c,{...D,thickness:Math.max(6,k-2)}),Dp(b+"-right",a,l,a,c,{...D,thickness:Math.max(6,k)}));const B=t.membraneDampingScale??.5,F=s,E=Math.max(1,("bowtie"===e?L:a)-F),O=(t.membranes??[]).map(t=>{const e=F+zp(t.offset,0,1)*E,n=t.width??18+18*t.cost,o=h-16,i=u+.25*(t.wobble??0);return{...t,x:e,y:i,width:n,height:o}}),N=!1===t.includeMembraneRegions?[]:O.map(t=>function(t){const e=t.dampingScale??.5,n=t.energyScale??1,o=zp(t.cost,0,2);return{...Ip({...t,kind:t.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:o*e,energyDelta:-o*n}}({id:t.id,label:t.label??t.id,description:t.description??(t.label??t.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:t.x,y:t.y,width:t.width,height:t.height,cost:t.cost,dampingScale:t.dampingScale??B,bodyStyle:t.bodyStyle,metadata:t.metadata,semanticItem:t.semanticItem,color:t.color}));return{shape:e,width:n,height:o,padX:i,padY:r,left:s,right:a,topY:l,bottomY:c,midY:u,centerLeft:L,centerRight:R,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:z,membranes:O,colliders:I,regionEffects:N,boundaryY:$}}({width:n[0],height:n[1],shape:"lane",padX:Math.max(28,o.plot.x),padY:Math.max(36,o.plot.y+8),stages:m,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((t,e)=>[t.id,e])),v=new Map(x.stages.map(t=>[t.id,t])),w=x.stages[0].id,k=x.stages[0],S=new Set(e.filter(t=>t.absorb).map(t=>t.id)),A=e.map(t=>{const e=v.get(t.id)??k;return function(t,e){const n={id:"process-stage-"+t.id,label:t.label??t.id,description:t.description,x:e.x,y:e.y,width:Math.max(12,.92*e.width),height:Math.max(40,.88*e.height),semanticItem:!1,attributes:{stageId:t.id}};if(t.absorb)return function(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:24,y:0};return{...Ip({...t,kind:t.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.02,charge:t.charge??"absorbed"}}({...n,kind:t.kind??"sink",force:Fp(t.force,28),damping:t.damping??.04,charge:"absorbed",attributes:{...n.attributes,primitive:"absorb"}});if(t.portal){const e=t.portal.force??t.force??{x:-40,y:0};return o={...n,kind:t.kind??"force-field",force:Fp(e,-40),damping:t.damping??.1,targetStage:t.portal.targetStageId,attributes:{...n.attributes,primitive:"portal",targetStage:t.portal.targetStageId}},{...Ip({...o,kind:o.kind??"force-field",attributes:{primitive:"portal",targetStage:o.targetStage,..."object"==typeof o.attributes&&o.attributes?o.attributes:{}}}),force:o.force,impulseOnEnter:o.impulseOnEnter,damping:o.damping??.08}}var o;if(t.capacity){const e=Math.max(.1,t.capacity.unitsPerSecond);return function(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force;return{...Ip({...t,kind:t.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:t.capacity,unitsPerSecond:t.unitsPerSecond??t.capacity,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping,charge:t.charge??t.capacity}}({...n,kind:t.kind??"force-field",capacity:e,unitsPerSecond:e,force:Fp(t.force,10+.8*e),damping:t.damping??Math.max(.04,.32-.01*e),attributes:{...n.attributes,unitAccessor:t.capacity.unitAccessor,reviewerCapacity:e}})}if(t.pressure){const e="object"==typeof t.pressure&&t.pressure?t.pressure:{};return function(t){const e=t.pressure??t.occupancy??0,n=t.baseDamping??.08,o=t.dampingPerUnit??.12,i=t.energyPerUnit??0;return{...Ip({...t,kind:t.kind??"membrane",attributes:{primitive:"pressureField",pressure:e,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:n+e*o,energyDelta:i?-e*i:void 0,force:t.force}}({...n,kind:t.kind??"membrane",pressure:e.pressure,occupancy:e.occupancy,baseDamping:e.baseDamping??t.damping??.1,dampingPerUnit:e.dampingPerUnit??.1,energyPerUnit:e.energyPerUnit??0,force:Fp(t.force,8),attributes:{...n.attributes,primitive:"pressureField"}})}return null!=t.force||null!=t.damping?Bp({...n,kind:t.kind??"force-field",force:Fp(t.force,14),damping:t.damping??.02,attributes:{...n.attributes,primitive:"routeSurface"}}):function(t){return{...Ip({...t,kind:t.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:t.force,damping:t.damping,energyDelta:t.energyDelta}}({...n,kind:t.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...n.attributes,primitive:"forceField"}})}(t,{x:e.x,y:x.midY,width:e.width,height:x.bottomY-x.topY})});A.unshift(Bp({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(x.left+x.right)/2,y:x.midY,width:x.right-x.left,height:x.bottomY-x.topY-12,force:8,damping:.012,semanticItem:!1}));const M=new Map;for(const t of x.stages)M.set(t.id,0);const _=[];t.data.forEach((t,e)=>{const n=(a?rf(t,e,a)??t.id??"process-flow-"+e:t.id??"process-flow-"+e)+"",o=(rf(t,e,l)??w)+"",r=b.has(o)?o:w;M.set(r,(M.get(r)??0)+1);const s=c?(rf(t,e,c)??"")+"":void 0,f=s&&u?(rf(t,e,u)??s)+"":s,p=h?sf(rf(t,e,h))??1:1,y=d?sf(rf(t,e,d)):null,g=af(null!=y&&y>0?y:i,2,18);_.push({datum:t,id:n,stageId:r,groupId:s||void 0,groupLabel:f||void 0,work:p,radius:g,index:e})});const P=new Map,C=new Map;for(const t of _){if(!t.groupId)continue;const e=P.get(t.groupId)??[];e.push(t.id),P.set(t.groupId,e),t.groupLabel&&C.set(t.groupId,t.groupLabel)}const T=af(t.groupAnchorAlong??.55,.15,.9),L=x.left+(x.right-x.left)*T,R=Array.from(P.keys()),$=R.map((t,n)=>{const o=P.get(t)??[],i=R.length>1?x.topY+28+n/Math.max(1,R.length-1)*(x.bottomY-x.topY-56):x.midY;return function(t){const e=t.x??t.anchor?.x??0,n=t.y??t.anchor?.y??0;return{id:t.id,label:t.label,description:t.description,group:t.group,bodyIds:t.bodyIds,datum:t.datum,state:t.state,x:e,y:n,width:t.width,height:t.height,anchor:t.anchor??{x:e,y:n},completion:t.completion,tether:t.tether,semanticItem:t.semanticItem}}({id:t,label:C.get(t)??t,bodyIds:o,anchor:{x:L,y:i},x:L,y:i,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:e.find(t=>t.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),z=function(t,e){const n=e instanceof Set?e:new Set(e);return t.map(t=>{const e=t.bodyIds??[],o=e.filter(t=>!n.has(t)),i=e.length-o.length,r=t.completion?.mode??"allMembersAbsorbed",s=t.completion?.valueByBodyId,a=t=>{const e=s?.[t];return Number.isFinite(e)&&Number(e)>=0?Number(e):1},l=e.reduce((t,e)=>t+a(e),0),c=e.reduce((t,e)=>t+(n.has(e)?a(e):0),0),u=t.completion?.threshold,h="threshold"===r?Number.isFinite(u)&&Number(u)>=0?Number(u):l:void 0;return{id:t.id,label:t.label??t.id,mode:r,complete:e.length>0&&("anyAbsorbed"===r?i>0:"threshold"===r?c>=(h??l):0===o.length),absorbed:i,total:e.length,absorbedValue:c,totalValue:l,threshold:h,missing:o}})}($,_.filter(t=>S.has(t.stageId)).map(t=>t.id)),D=new Map($.map(t=>[t.id,t])),I=_.map((t,e)=>{const n=v.get(t.stageId)??k,o=n.x+(s()-.5)*Math.min(24,.2*n.width),i=x.boundaryY(o,"top")+t.radius+10,r=x.boundaryY(o,"bottom")-t.radius-10,a=r>i?i+s()*Math.max(1,r-i):x.midY,l=g?o:x.left+18+e%7*4,c=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:o,y:a},restLength:.45*t.radius,stiffness:p,damping:y}];if(t.groupId){const e=D.get(t.groupId);e?.anchor&&!S.has(t.stageId)&&u.push({target:{type:"point",x:e.anchor.x,y:e.anchor.y},restLength:e.tether?.restLength??22,stiffness:e.tether?.stiffness??.05,damping:.8})}return{id:t.id,x:l,y:c,vx:g?0:40+40*s(),vy:g?0:20*(s()-.5),mass:1,shape:{type:"circle",radius:t.radius},spawnAt:g?0:.03*e,springs:u,datum:{...t.datum,id:t.id,stage:t.stageId,groupId:t.groupId,groupLabel:t.groupLabel,work:t.work,__processFlow:!0}}}),B={kernel:{seed:r,gravity:{x:t.gravityX??22,y:t.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},F=x.stages.map(t=>({label:t.label??t.id,value:M.get(t.id)??0})),E=e.map(t=>{const e=v.get(t.id)??k;return{id:t.id,label:t.label??t.id,x:e.x,width:e.width,count:M.get(t.id)??0,capacity:t.capacity?.unitsPerSecond,absorb:!0===t.absorb,portalTarget:t.portal?.targetStageId}});return{config:B,initialSpawns:I,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:F,metadata:{kind:"process-flow",plot:o.plot,volume:x,stages:E,groups:$,groupCompletion:z,regionEffects:A}}}import{scaleLinear as Op}from"d3-scale";function Np(t,e,n){return wt(t,e,n)}function Wp(t,e){const n=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>n&&_t(n,t)||"#4e79a7":e=>{if(n){const t=_t(n,e);if(t)return t}let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return t[Math.abs(o)%t.length]??"#4e79a7"}}function jp(t,e){const n=e.config??{},o=(e.sensors??[]).map(t=>({...t,sensor:!0})),i=[...e.colliders??[],...o],r=[...t.colliders??[],...n.colliders??[],...i];return{...t,...n,observation:{...t.observation,...n.observation},...r.length>0&&{colliders:r}}}function Yp(t){const e=Up(t);return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:e.left,y1:e.top,x2:e.left,y2:t.floorY,thickness:e.thickness}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:e.left,y1:e.top,x2:t.width-e.rightInset,y2:e.top,thickness:e.thickness}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:e.left,y1:t.floorY,x2:t.width-e.rightInset,y2:t.floorY,thickness:e.thickness}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:t.width-e.rightInset,y1:e.top,x2:t.width-e.rightInset,y2:t.floorY,thickness:e.thickness}}]}function Gp(t,e,n,o){return n?"function"==typeof n?n(t,e):t[n]??o:o}function qp(t){return`gauntlet:${t}:core`}function Xp(t,e){return`gauntlet:${t}:positive:${e}`}function Hp(t,e,n){return`gauntlet:${t}:negative:${e}:${n}`}var Vp={left:28,top:76,rightInset:30,thickness:8};function Up(t){const e=t.height??t.floorY+36;if(t.width>=220&&e>=160)return Vp;const n=Math.max(1,Math.min(t.width,e)),o=Math.max(2,.04*t.width);return{left:o,top:Math.max(2,.08*e),rightInset:o,thickness:Math.max(1,Math.min(4,.04*n))}}function Kp(t){return Math.max(.12,Math.min(1,t.width/500,(t.height??t.floorY+36)/260))}function Zp(t,e,n,o){const i=Up(o),r=Math.max(2,n+2),s=i.top+i.thickness/2+r,a=o.floorY-r,l=(t,e,n)=>e>n?(e+n)/2:Math.max(e,Math.min(n,t));return{x:l(t,i.left+i.thickness/2+r,o.width-i.rightInset-i.thickness/2-r),y:l(e,s,a)}}function Qp(t,e,n=1){const o=[...t].sort((t,e)=>t.localeCompare(e)),i=Math.max(0,o.indexOf(e));return{angle:.82*-Math.PI+(o.length>1?i/(o.length-1):.5)*Math.PI*.64,index:i,radius:(48+i%2*6)*n}}function Jp(t,e,n){const o=t.activePositiveIds.reduce((t,n)=>t+(e.get(n)?.value??1),0),i=t.missingPositiveIds.length+t.poppedPositiveIds.length,r=t.negativeIds.reduce((t,e)=>t+(n.get(e)?.load??1),0);return Math.max(0,Math.min(100,75+3*o-8*r-1.2*t.delay-5*i))}function ty(t){const e=function(t,e,n){const[o,i]=t,r=220>o||160>i,s=Math.round(.48*i),a=r?i-Math.max(3,Math.min(12,.1*i)):i-36,l=(e??[]).filter(t=>!1!==t.enabled),c=Math.max(1,l.length),u=.22*o,h=c>1?(.78*o-u)/(c-1):0,d=r?Math.max(Math.round(.12*o),.08*o+6):Math.max(Math.round(.14*o),110);return{crashY:a-(r?Math.min(n,Math.max(3,.22*i)):n),floorY:a,gates:l.map((t,e)=>({...t,id:t.id,x:t.x??Math.round(u+e*h),width:t.width??Math.max(r?8:54,Math.round(.07*o))})),graveyardX:Math.round(o*(r?.72:.84)),graveyardY:a-4,height:i,routeY:s,socketX:Math.round(o*(r?.82:.92)),startX:d,width:o}}(t.size??[900,520],t.gates,t.crashOffset??30),n=t.positiveProperties??[],o=new Map(n.map(t=>[t.id,t])),i=new Map((t.negativeProperties??[]).map(t=>[t.id,t])),r={idAccessor:t.idAccessor,initialViability:t.initialViability,metricsAccessor:t.metricsAccessor,negativeAccessor:t.negativeAccessor,positiveAccessor:t.positiveAccessor,startTimeAccessor:t.startTimeAccessor},s=(t.data??[]).map((e,s)=>{const a=function(t,e,n,o,i){const r=Gp(t,e,n.idAccessor,null!=t.id?t.id+"":"project-"+e)+"",s=o.map(t=>t.id),a=[...Gp(t,e,n.positiveAccessor,s)],l=[...Gp(t,e,n.negativeAccessor,[])].filter(t=>i.has(t));return{id:r,activePositiveIds:a,datum:t,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Gp(t,e,n.metricsAccessor,{})},missingPositiveIds:s.filter(t=>!a.includes(t)),negativeIds:l,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Gp(t,e,n.startTimeAccessor,0))||0),stage:"project filed",viability:Gp(t,e,n.initialViability,100)}}(e,s,r,n,i);return{...a,viability:t.viability?.(a,{negativeProperties:i,positiveProperties:o})??Jp(a,o,i)}}),a=s.flatMap((n,r)=>{const s=function(t,e,n,o){const i=function(t){return{graveyardX:t.graveyardX,graveyardY:t.graveyardY,routeY:t.routeY,socketX:t.socketX,socketY:t.routeY-4,startX:t.startX,startY:t.routeY}}(n),r=o?.(t,e,n)??{};return{...i,...r,startY:r.startY??r.routeY??i.startY,socketY:r.socketY??r.routeY??i.socketY,graveyardY:r.graveyardY??i.graveyardY}}(n,r,e,t.projectPlacement);return function(t,e,n,o,i,r,s){const a=Kp(n),l=Math.max(3,28*a),c=o.startX,u=o.startY+(o.startY===n.routeY?38*e*a:0),h=s?.(t,e,n,o)??{},d=h.x??c,f=h.y??u,p={__gauntlet:!0,kind:"gauntlet-core",projectId:t.id,sourceDatum:t.datum},y=[{...h,id:qp(t.id),x:d,y:f,vx:h.vx??42,vy:h.vy??0,mass:h.mass??7,bodyCollisions:h.bodyCollisions??!0,shape:h.shape??{type:"circle",radius:l},spawnAt:h.spawnAt??t.startedAt,datum:p}],g=Zp(d,f,h.shape&&"radius"in h.shape&&Number(h.shape.radius)||l,n);y[0].x=g.x,y[0].y=g.y;for(const e of t.activePositiveIds){const o=i.get(e);if(!o)continue;const r=Qp(t.activePositiveIds,e,a),s=o.radius??Math.max(2,10*a),l=Zp(g.x+Math.cos(r.angle)*r.radius,g.y+Math.sin(r.angle)*r.radius,s,n);y.push({id:Xp(t.id,e),x:l.x,y:l.y,vx:18*Math.cos(r.angle),vy:18*Math.sin(r.angle),mass:o.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:h.spawnAt??t.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:t.id,property:o,sourceDatum:t.datum},springs:!1===o.spring?[]:[{target:{type:"body",bodyId:qp(t.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+r.index%2*4)*a),...o.spring??{}}]})}return t.negativeIds.forEach((e,o)=>{const i=r.get(e);i&&y.push(function(t,e,n,o,i,r,s){const a=Kp(r),l=e.radius??Math.max(2,7.2*a),c=Zp(o+(n%4*12-12)*a,i+(54+12*Math.floor(n/4))*a,l,r);return{id:Hp(t.id,e.id,n),x:c.x,y:c.y,vx:10,vy:6,mass:e.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:l},spawnAt:s,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:t.id,property:e,sourceDatum:t.datum},springs:!1===e.spring?[]:[{target:{type:"body",bodyId:qp(t.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+n%4*3)*a),...e.spring??{}}]}}(t,i,o,g.x,g.y,n,h.spawnAt??t.startedAt))}),y}(n,r,e,s,o,i,t.coreBody)});return{layout:e,initialSpawns:a,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:Yp(e)}}}function ey(t){return t.map(t=>({...t,spawnAt:void 0}))}var ny={Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(t,e,n,o,i)=>({chartType:"line",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.lineBy||e,colorAccessor:e,...o,showAxes:!1,margin:o.margin,showLegend:!1,showGrid:!1,title:void 0})},LineChart:Lh,AreaChart:$h,DifferenceChart:zh,StackedAreaChart:Dh,Scatterplot:Bh,CandlestickChart:Ih,BubbleChart:Ch,ConnectedScatterplot:Eh,QuadrantChart:Fh,Heatmap:{frameType:"xy",buildProps:(t,e,n,o,i)=>({chartType:"heatmap",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",valueAccessor:i.valueAccessor,colorScheme:n||i.colorScheme||"blues",showValues:i.showValues,heatmapValueFormat:i.valueFormat,cellBorderColor:i.cellBorderColor,...o})},TemporalHistogram:Rh,XYCustomChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>({chartType:"custom",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,colorScheme:n,customLayout:i.layout||i.customLayout,layoutConfig:i.layoutConfig,...o,showAxes:i.frameProps?.showAxes??i.showAxes??!1,showLegend:o.showLegend??!!e})},BarChart:ld,StackedBarChart:cd,GroupedBarChart:ud,PieChart:hd,DonutChart:dd,Histogram:fd,BoxPlot:pd,ViolinPlot:yd,SwarmPlot:gd,DotPlot:md,SwimlaneChart:xd,RidgelinePlot:bd,LikertChart:vd,FunnelChart:wd,GaugeChart:kd,OrdinalCustomChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>({chartType:"custom",data:t,oAccessor:i.categoryAccessor||i.oAccessor||"category",rAccessor:i.valueAccessor||i.rAccessor||"value",projection:i.projection||"vertical",colorAccessor:e,colorScheme:n,customLayout:i.layout||i.customLayout,layoutConfig:i.layoutConfig,...o,showAxes:i.frameProps?.showAxes??i.showAxes??!1})},ForceDirectedGraph:Wd,NetworkCustomChart:{frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(t,e,n,o,i)=>({chartType:"force",nodes:i.nodes||t||[],edges:i.edges||[],nodeIDAccessor:i.nodeIdAccessor||i.nodeIDAccessor||"id",sourceAccessor:i.sourceAccessor||"source",targetAccessor:i.targetAccessor||"target",valueAccessor:i.valueAccessor||"value",colorBy:e,colorScheme:n,customNetworkLayout:i.layout||i.customNetworkLayout,layoutConfig:i.layoutConfig,...o})},SankeyDiagram:Yd,ProcessSankey:jd,ChordDiagram:Gd,TreeDiagram:qd,Treemap:Xd,CirclePack:Hd,ChoroplethMap:Zd,ProportionalSymbolMap:Qd,FlowMap:Jd,GeoCustomChart:{frameType:"geo",buildProps:(t,e,n,o,i)=>({points:i.points||t||[],areas:i.areas||[],lines:i.lines||[],projection:i.projection||"equirectangular",xAccessor:i.xAccessor||"lon",yAccessor:i.yAccessor||"lat",lineDataAccessor:i.lineDataAccessor,colorBy:e,colorScheme:n,customLayout:i.layout||i.customLayout,layoutConfig:i.layoutConfig,...o})},GaltonBoardChart:{frameType:"physics",buildProps:(t,e,n,o,i)=>{const r=o.size??[600,400],s=i.bins??21,a=i.seed??1,l=Math.max(1,Math.round(i.pegRows??s-1)),c="mechanical"===i.mode,u=c?function(t){const e=Math.max(2,Math.round(t.bins)),n=Math.max(1,Math.round(t.pegRows??e-1)),o=Math.max(1,Math.round(t.count??Math.max(64,4*e))),i=af(Number.isFinite(t.branchProbability)?t.branchProbability??.5:.5,0,1),r=uf(t.seed??1),s=t.idPrefix??"mechanical";return Array.from({length:o},(t,e)=>{let o=0;for(let t=0;n>t;t+=1)r()<i&&(o+=1);const a=n/2;return{id:`${s}-${e}`,value:o,mechanical:!0,pegRows:n,branchProbability:i,pathRights:o,side:a>o?"left":o>a?"right":"center"}})}({bins:s,branchProbability:i.branchProbability,count:i.mechanicalCount,pegRows:l,seed:a}):Array.isArray(t)?t:[],h=function(t){const{data:e,valueAccessor:n,bins:o,ballRadius:i,seed:r,size:s,valueExtent:a}=t,l=tf(s),c=e.map((t,e)=>sf(rf(t,e,n))).filter(t=>null!=t),u=function(t){if(!t)return;const e=sf(t[0]),n=sf(t[1]);return null!=e&&null!=n?e>n?[n,e]:[e,n]:void 0}(a),h=u?.[0]??(c.length?Math.min(...c):0),d=u?.[1]??(c.length?Math.max(...c):1),f=d===h?1:d-h,p=hf().domain([0,o]).range([l.plot.x,l.plot.x+l.plot.width]),y=Array.from({length:o},()=>0),g=[];e.forEach((t,e)=>{const r=sf(rf(t,e,n));if(null==r)return;const s=Math.max(0,Math.min(o-1,Math.floor((r-h)/f*o)));y[s]+=1,g.push({id:(t.id??"galton-"+e)+"",x:p(s+.5),y:l.plot.y+i+2,vx:8*(e%5-2),vy:0,mass:1,shape:{type:"circle",radius:i},datum:{...t,value:r,bin:s}})});const m=l.plot.y+l.plot.height;return{config:of(r,[...rp({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...sp({idPrefix:"galton-bin",count:o,domainStart:0,domainStep:1,xScale:p,yTop:l.plot.y-400,yBottom:m,wallThickness:6})],"GaltonBoardChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:y.map((t,e)=>({label:e+1+"",value:t})),metadata:{kind:"galton-board",bins:o,plot:l.plot,valueExtent:[h,d]}}}({data:u,valueAccessor:i.valueAccessor||"value",bins:s,ballRadius:i.ballRadius??4,seed:a,size:r,valueExtent:c?[0,l]:void 0});return{...o,config:h.config,initialSpawns:ey(h.initialSpawns),projectionRows:h.projectionRows,bodyStyle:nf(e||i.colorBy||(c?"side":void 0),"#4e79a7",{styleRules:i.styleRules,valueAccessor:i.valueAccessor||"value"})}}},EventDropChart:{frameType:"physics",buildProps:(t,e,n,o,i)=>{const r=o.size??[600,400],s=function(t){const{data:e,timeAccessor:n,arrivalAccessor:o,windows:i,watermark:r,ballRadius:s,seed:a,size:l,timeExtent:c,timeScale:u=1}=t,h=tf(l),d=e.map((t,e)=>sf(rf(t,e,n))).filter(t=>null!=t),f=sf(c?.[0]),p=sf(c?.[1]),y=d.length?Math.min(...d):0,g=d.length?Math.max(...d):y+i.size,m=Math.min(f??y,y),x=Math.max(p??g,g),b=Math.floor(m/i.size)*i.size,v=Math.max(1,Math.ceil((x-b+i.size)/i.size)),w=d.length?Math.max(...d):0,k="function"==typeof r?r(w):sf(r?.value)??w-(r?.delay??i.size),S=Math.max(0,Math.min(v,Array.from({length:v},(t,e)=>e).reduce((t,e)=>b+(e+1)*i.size>k?t:t+1,0))),A=function(t,e){const n=Math.max(5*e,Math.min(92,.13*t.plot.width));return{gutter:{x:t.plot.x,y:t.plot.y,width:n,height:t.plot.height},windowPlot:{x:t.plot.x+n,y:t.plot.y,width:Math.max(40,t.plot.width-n),height:t.plot.height},wallTop:t.plot.y+.48*t.plot.height}}(h,s),M=b+v*i.size,_=Ap().domain([b,M]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),P=Array.from({length:v},()=>({value:0,secondary:0})),C=[];e.forEach((t,e)=>{const r=sf(rf(t,e,n));if(null==r)return;const a=sf(rf(t,e,o))??r,l=Math.max(0,Math.min(v-1,Math.floor((r-b)/i.size))),c=k>=b+(l+1)*i.size;P[l].value+=c?0:1,P[l].secondary+=c?1:0,C.push({id:(t.id??"event-"+e)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,_(r))),y:h.plot.y+s+2,vx:8*(e%3-1),vy:0,mass:1,friction:.02,spawnAt:a,shape:{type:"circle",radius:s},datum:{...t,eventTime:r,arrivalTime:a,windowIndex:l,late:c}})});const T=h.plot.y+h.plot.height,L=function(t,e){const n=Math.max(0,Math.min(t.windowCount,t.closedWindowCount));if(!n)return[];const o=t.windowStart,i=t.windowStart+t.windowCount*t.windowSize,r=Ap().domain([o,i]).range([t.windowPlot.x,t.windowPlot.x+t.windowPlot.width]),s=r(t.windowStart+n*t.windowSize),a=t.windowPlot.x,l=e+Math.max(18,Math.min(.3*t.windowPlot.height,s-a)),c=t=>s===a?e:l+(t-a)/(s-a)*(e-l),u=[];for(let e=0;n>e;e+=1){const n=t.windowStart+e*t.windowSize,o=n+t.windowSize,i=r(n),s=r(o);u.push({id:"eventdrop-lid-"+e,windowIndex:e,x1:i,y1:c(i),x2:s,y2:c(s)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:h.plot,windowCount:v,windowPlot:A.windowPlot,windowSize:i.size,windowStart:b},h.plot.y+.28*h.plot.height);return{config:of(a,[...rp({x:h.plot.x,y:h.plot.y,width:h.plot.width,height:h.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...Mp({idPrefix:"eventdrop-window",count:v,xScale:t=>_(b+t*i.size),yTop:A.wallTop,yTopForIndex:t=>{const e=(t=>{if(0>t||t>S)return null;const e=0===t?L[0]?.y1:L[t-1]?.y2??L[t]?.y1;return"number"==typeof e&&Number.isFinite(e)?e:null})(t);return null==e?A.wallTop:e+1.25*s},yBottom:T,wallThickness:6}),...L.map(t=>({id:t.id,shape:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:C,initialSpawnPacing:{pacing:"arrival",timeAccessor:t=>t.datum?.arrivalTime,timeScale:u},projectionRows:P.map((t,e)=>({label:`${b+e*i.size}-${b+(e+1)*i.size}`,value:t.value,secondary:t.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:L,lateCount:P.reduce((t,e)=>t+e.secondary,0),plot:h.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:v,windowSize:i.size,windowStart:b}}}({data:Array.isArray(t)?t:[],timeAccessor:i.timeAccessor||"time",arrivalAccessor:i.arrivalAccessor||"arrivalTime",windows:i.windows||{size:10},watermark:i.watermark,ballRadius:i.ballRadius??5,seed:i.seed??1,size:r,timeExtent:i.timeExtent,timeScale:i.timeScale??1});return{...o,config:s.config,initialSpawns:ey(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:nf(e||i.colorBy,"#4e79a7",{styleRules:i.styleRules,valueAccessor:i.valueAccessor||i.timeAccessor||"time"})}}},PhysicsPileChart:{frameType:"physics",buildProps:(t,e,n,o,i)=>{const r=o.size??[600,400],s="mechanical"===i.mode,a=function(t){const{data:e,categoryAccessor:n,valueAccessor:o,unitValue:i,ballRadius:r,seed:s,size:a}=t,l=lf(i,1),c=tf(a),u=[],h=new Map,d=new Map,f=[];function p(t){let e=h.get(t);return null==e&&(e=u.length,u.push(t),h.set(t,e)),e}e.forEach((t,e)=>{p((rf(t,e,n)??"unknown")+"")});const y=Math.max(1,u.length),g=function(t,e,n){const o=t.width/Math.max(1,e),i=Math.max(2,2*n),r=Math.min(.7*o,Math.max(3.2*i,i+8)),s=Math.max(1,Math.floor(r/i));return{laneWidth:o,tubeWidth:r,ballDiameter:i,perRow:s,centerX:e=>t.x+(e+.5)*o,pileHeight:t=>Math.ceil(Math.max(0,t)/s)*i}}(c.plot,y,r),m=Math.max(0,g.tubeWidth/2-r-1),x=u.map(()=>[]);e.forEach((t,e)=>{const i=(rf(t,e,n)??"unknown")+"",s=p(i),a=o?sf(rf(t,e,o)):1,u=Math.max(0,Math.round((a??0)/l)),h=g.centerX(s);for(let n=0;u>n;n+=1){const o=d.get(i)??0,a=g.perRow>1?((g.perRow>1?o%g.perRow:0)/(g.perRow-1)*2-1)*m:0;d.set(i,o+1),x[s].push({id:`${(t.id??"pile-"+e)+""}-${n}`,x:h+a,y:c.plot.y+r+2,vx:(n%3-1)*r/2,vy:0,mass:1,shape:{type:"circle",radius:r},datum:{...t,category:i,unitIndex:n}})}});const b=x.reduce((t,e)=>Math.max(t,e.length),0);for(let t=0;b>t;t+=1)for(const e of x)e.length>t&&f.push(e[t]);const v=c.plot.y+c.plot.height,w=[...rp({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=c.plot.y-400;for(let t=0;y>t;t+=1){const e=g.centerX(t);for(const n of[-1,1])w.push({id:`pile-tube-${t}-${0>n?"l":"r"}`,shape:{type:"aabb",x:e+n*g.tubeWidth/2,y:(k+v)/2,width:6,height:v-k}})}return{config:of(s,w,"PhysicsPileChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(t=>({label:t,value:d.get(t)??0}))}}({data:s?function(t={}){const e=(t.categories?.length?t.categories:["Intake","Review","Build","Ship"]).map(t=>(t+"").trim()).filter(Boolean),n=e.length?e:["Intake"],o=Math.max(n.length,Math.round(t.count??Math.max(48,12*n.length))),i=lf(t.unitValue,1),r=uf(t.seed??1),s=t.idPrefix??"mechanical-pile",a=n.map(()=>.65+.9*r()),l=a.reduce((t,e)=>t+e,0)||1,c=o-n.length,u=a.map(t=>t/l*c),h=u.map(t=>1+Math.floor(t));let d=o-h.reduce((t,e)=>t+e,0);const f=u.map((t,e)=>({index:e,fraction:t-Math.floor(t)})).sort((t,e)=>e.fraction-t.fraction);for(let t=0;d>0;t=(t+1)%f.length)h[f[t].index]+=1,d-=1;return n.map((t,e)=>({id:`${s}-${e}`,category:t,value:h[e]*i,mechanical:!0,unitCount:h[e],unitValue:i,share:h[e]/o}))}({categories:i.mechanicalCategories,count:i.mechanicalCount,seed:i.seed??1,unitValue:i.unitValue??1}):Array.isArray(t)?t:[],categoryAccessor:i.categoryAccessor||"category",valueAccessor:i.valueAccessor||(s?"value":void 0),unitValue:i.unitValue??1,ballRadius:i.ballRadius??5,seed:i.seed??1,size:r});return{...o,config:a.config,initialSpawns:ey(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:nf(e||i.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:i.styleRules,valueAccessor:i.valueAccessor||"value"})}}},CollisionSwarmChart:{frameType:"physics",buildProps:(t,e,n,o,i)=>{const r=o.size??[600,360],s=function(t){const{data:e,xAccessor:n,groupAccessor:o,radiusAccessor:i,pointRadius:r,seed:s,size:a,xExtent:l,collisionIterations:c,settle:u}=t,h=tf(a),d=uf(s),f=[],p=[],y=new Map;e.forEach((t,e)=>{const s=sf(rf(t,e,n));if(null==s)return;const a=o?(rf(t,e,o)??"All")+"":"All",l=i?sf(rf(t,e,i)):null,c=af(null!=l&&l>0?l:r,2,18);!function(t){let e=y.get(t);null==e&&(e=p.length,p.push(t),y.set(t,e))}(a),f.push({datum:t,index:e,value:s,group:a,radius:c})});const g=f.map(t=>t.value),m=l?sf(l[0]):null,x=l?sf(l[1]):null,b=g.length?Math.min(...g):0,v=g.length?Math.max(...g):1;let w=m??b,k=x??v;if(w===k&&(w-=.5,k+=.5),w>k){const t=k;k=w,w=t}const S=Math.max(r,...f.map(t=>t.radius)),A=h.plot.x+S+8,M=h.plot.x+h.plot.width-S-8,_=_p().domain([w,k]).range([A,M]),P=Math.max(1,p.length),C=Math.min(Math.max(28,3*S),h.plot.height/4),T=h.plot.y+C,L=Math.max(0,h.plot.y+h.plot.height-C-T),R=t=>{const e=y.get(t)??0;return 1===P?h.plot.y+.54*h.plot.height:T+e/(P-1)*L},$=new Map,z=f.map((t,e)=>{$.set(t.group,($.get(t.group)??0)+1);const n=_(t.value),o=R(t.group),i=(d()-.5)*t.radius*1.6,r=(d()-.5)*t.radius*1.6;return{id:(t.datum.id??"collision-swarm-"+e)+"",x:u?n+i:af(n+(e%9-4)*t.radius*2.5,A,M),y:u?o+r:h.plot.y-18-e%12*t.radius,vx:u?0:22*(d()-.5),vy:u?0:24+18*d(),mass:1,shape:{type:"circle",radius:t.radius},datum:{...t.datum,xValue:t.value,group:t.group,radius:t.radius,targetX:n,targetY:o},springs:[{target:{type:"point",x:n,y:o},restLength:0,stiffness:34,damping:5.5}]}});return{config:of(s,rp({x:h.plot.x,y:h.plot.y,width:h.plot.width,height:h.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(c??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:z,projectionRows:p.map(t=>({label:t,value:$.get(t)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,M],groups:p.map(t=>({label:t,y:R(t),count:$.get(t)??0})),plot:h.plot}}}({data:Array.isArray(t)?t:[],xAccessor:i.xAccessor||"x",groupAccessor:i.groupAccessor,radiusAccessor:i.radiusAccessor,pointRadius:i.pointRadius??5,seed:i.seed??1,size:r,xExtent:i.xExtent,collisionIterations:i.collisionIterations,settle:i.settle});return{...o,config:s.config,initialSpawns:ey(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:nf(e||i.colorBy||i.groupAccessor,"#4e79a7",{styleRules:i.styleRules,valueAccessor:i.xAccessor||"x"})}}},ProcessFlowChart:{frameType:"physics",buildProps:(t,e,n,o,i)=>{const r=o.size??[900,420],s=Array.isArray(i.stages)?i.stages:[],a=Ep({data:Array.isArray(t)?t:[],stages:s,size:r,idAccessor:i.idAccessor,stageAccessor:i.stageAccessor||"stage",groupBy:i.groupBy,groupLabelAccessor:i.groupLabelAccessor,workAccessor:i.workAccessor,radiusAccessor:i.radiusAccessor,ballRadius:i.ballRadius??6,seed:i.seed??1,groupCompletion:i.groupCompletion,groupAnchorAlong:i.groupAnchorAlong,settle:i.settle??!0,gravityX:i.gravityX,gravityY:i.gravityY}),l=a.metadata;return{...o,config:a.config,initialSpawns:ey(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:l?.regionEffects,bodyStyle:nf(e||i.colorBy||i.groupBy,"#4e79a7",{styleRules:i.styleRules,valueAccessor:i.workAccessor||i.stageAccessor||"stage"})}}},GauntletChart:{frameType:"physics",buildProps:(t,e,n,o,i)=>{const r=o.size??[900,520],s=ty({data:Array.isArray(t)?t:[],size:r,gates:i.gates,positiveProperties:i.positiveProperties,negativeProperties:i.negativeProperties,crashOffset:i.crashOffset,idAccessor:i.idAccessor,positiveAccessor:i.positiveAccessor,negativeAccessor:i.negativeAccessor,metricsAccessor:i.metricsAccessor,initialViability:i.initialViability,projectPlacement:i.projectPlacement,coreBody:i.coreBody,viability:i.viability});return{...o,config:s.config,initialSpawns:ey(s.initialSpawns),projectionRows:[],bodyStyle:nf(e||i.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(t,e,n,o,i)=>{const r=o.size??[760,420],s=function(t){const{coordinateMode:e,flowSpeed:n,links:o,maxParticles:i,nodeIdAccessor:r,nodeXAccessor:s,nodeYAccessor:a,nodes:l,particleRadius:c,particleRate:u,pathAccessor:h,pathConstraint:d="path",reducedMotion:f,seed:p,size:y,sourceAccessor:g,targetAccessor:m,throughputAccessor:x}=t,b=tf(y),v=uf(p),w=new Map,k=new Map,S=[];function A(t){if(t&&"object"==typeof t){const e=t;if("function"==typeof r){const t=r(e,0);if(null!=t)return t+""}if("string"==typeof r&&null!=e[r])return e[r]+"";if(null!=e.id)return e.id+""}return(t??"unknown")+""}l.forEach((t,e)=>{const n=(rf(t,e,r)??t.id??e)+"",o=sf(rf(t,e,s)),i=sf(rf(t,e,a));if(null!=o&&null!=i){const t={x:o,y:i};w.set(n,t),S.push(t)}k.set(n,(t.label??t.name??n)+"")});const M=[];o.forEach((t,e)=>{const n=A(rf(t,e,g)),o=A(rf(t,e,m)),i=Math.max(0,sf(rf(t,e,x))??0),r=Cp(h?rf(t,e,h):void 0),s=r.length?r:Cp(t.path??t.points??t.route);s.forEach(t=>S.push(t)),M.push({id:(t.id??`physical-flow-${n}-${o}-${e}`)+"",link:t,index:e,source:n,target:o,throughput:i,rawPath:s})});const _=(C=S,"normalized"===(P=e)||"pixels"===P?P:C.length>0&&C.every(t=>!(0>t.x||t.x>1||0>t.y||t.y>1))?"normalized":"pixels");var P,C;const T=new Map;for(const[t,e]of w)T.set(t,Tp(e,b,_));const L=[];for(const t of M){let e=t.rawPath.map(t=>Tp(t,b,_));if(2>e.length){const n=T.get(t.source),o=T.get(t.target);n&&o&&(e=[n,o])}else T.has(t.source)||T.set(t.source,e[0]),T.has(t.target)||T.set(t.target,e[e.length-1]);e.length>=2&&t.throughput>0&&(k.has(t.source)||k.set(t.source,t.source),k.has(t.target)||k.set(t.target,t.target),L.push({...t,path:e,packetCount:0}))}const R=lf(u,.12),$=Math.max(1,Math.round(i)),z=L.map(t=>Math.max(1,Math.round(t.throughput*R))),D=z.reduce((t,e)=>t+e,0),I=D>$?$/D:1;L.forEach((t,e)=>{t.packetCount=Math.max(1,Math.floor(z[e]*I))});let B=L.reduce((t,e)=>t+e.packetCount,0);for(;B>$;){const t=L.reduce((t,e,n)=>e.packetCount>1&&(-1===t||e.packetCount>L[t].packetCount)?n:t,-1);if(-1===t)break;L[t].packetCount-=1,B-=1}const F=new Map,E=new Map,O=[],N=lf(n,90),W=lf(c,4);L.forEach((t,e)=>{F.set(t.target,(F.get(t.target)??0)+t.throughput),E.set(t.source,(E.get(t.source)??0)+t.throughput);const n=Lp(t.path);for(let o=0;t.packetCount>o;o+=1){const i=(o+.5)/t.packetCount,r=f?i:af(.12+.84*i+.04*(v()-.5),.04,.98),s=f?r:Math.max(0,r-(.18+.12*v())),a=Rp(t.path,s),l=Rp(t.path,r),c=$p(t.path,s),u={x:-c.y,y:c.x},h=(v()-.5)*W*1.5;O.push({id:`${t.id}-packet-${o}`,x:a.x+u.x*h,y:a.y+u.y*h,vx:f?0:c.x*N+10*(v()-.5),vy:f?0:c.y*N+10*(v()-.5),mass:.8,spawnAt:f?0:.04*e+o/32,shape:{type:"circle",radius:W},datum:{...t.link,source:t.source,target:t.target,throughput:t.throughput,packetIndex:o,packetCount:t.packetCount,routeProgress:r,flowPath:t.path,flowPathLength:n,flowRouteId:t.id,flowSpeed:N,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target},springs:"none"!==d&&f?[{target:{type:"point",x:l.x,y:l.y},restLength:.7*W,stiffness:26,damping:4.25}]:void 0})}});const j=Math.max(18,5*W),Y=Array.from(T,([t,e])=>({nodeId:t,label:k.get(t)??t,sensorId:"physical-flow-node-"+cf(t),point:e})),G=Y.map(t=>({id:t.sensorId,sensor:!0,shape:{type:"aabb",x:t.point.x,y:t.point.y,width:j,height:j}})),q=Object.fromEntries(Y.map(t=>[t.sensorId,{binId:t.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),X=of(p,[...rp({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...G],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*W),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});X.bodyLimit=$,X.eviction="oldest",X.observation={...X.observation,sensors:q};const H=Array.from(T,([t,e])=>({id:t,label:k.get(t)??t,x:e.x,y:e.y,sensorId:"physical-flow-node-"+cf(t),incoming:F.get(t)??0,outgoing:E.get(t)??0})),V=L.map(t=>({id:t.id,source:t.source,target:t.target,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target,throughput:t.throughput,packetCount:t.packetCount,path:t.path}));return{config:X,initialSpawns:O,projectionRows:H.filter(t=>t.incoming>0||t.outgoing>0).map(t=>({label:t.label,value:t.incoming,secondary:t.outgoing})),metadata:{kind:"physical-flow",coordinateMode:_,particleCount:O.length,totalThroughput:L.reduce((t,e)=>t+e.throughput,0),plot:b.plot,nodes:H,links:V}}}({nodes:Array.isArray(i.nodes)?i.nodes:[],links:Array.isArray(i.links)?i.links:Array.isArray(i.edges)?i.edges:Array.isArray(t)?t:[],nodeIdAccessor:i.nodeIdAccessor||"id",nodeXAccessor:i.nodeXAccessor||"x",nodeYAccessor:i.nodeYAccessor||"y",sourceAccessor:i.sourceAccessor||"source",targetAccessor:i.targetAccessor||"target",throughputAccessor:i.throughputAccessor||"value",pathAccessor:i.pathAccessor||"path",coordinateMode:i.coordinateMode||"auto",particleRate:i.particleRate??.16,maxParticles:i.maxParticles??180,particleRadius:i.particleRadius??4,flowSpeed:i.flowSpeed??90,pathConstraint:i.pathConstraint||"path",reducedMotion:!0,seed:i.seed??1,size:r});return{...o,config:s.config,initialSpawns:ey(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:nf(e||i.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(t,e,n,o,i)=>{const r=o.size??[700,380],s=function(t){const e=function(t,e,n){const o=t?.observation;return{...t,observation:{...o,chartId:e??o?.chartId??"physics-custom",chartType:o?.chartType??"PhysicsCustomChart",onObservation:n??o?.onObservation}}}(t.config,t.chartId,t.onObservation),n=Np(t.colorScheme,t.themeCategorical,K),o=tf(t.size),i={data:t.data,scales:{x:Op().domain(t.xExtent??[0,1]).range([o.plot.x,o.plot.x+o.plot.width]),y:Op().domain(t.yExtent??[0,1]).range([o.plot.y+o.plot.height,o.plot.y])},dimensions:o,theme:{semantic:t.semantic,categorical:[...n]},resolveColor:Wp(n,t.colorScheme),config:t.layoutConfig??{},world:new Sp(e)},r=t.skipLayout?{}:t.layout(i)??{},s=function(t,e){if(!e?.length)return t;const n=new Map;for(const t of e){const{bodyId:e,...o}=t,i=n.get(e)??[];i.push(o),n.set(e,i)}return t.map(t=>{const e=n.get(t.id);return e?.length?{...t,springs:[...t.springs??[],...e]}:t})}([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:jp(e,r),context:i,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:s,result:r}}({chartId:i.chartId,colorScheme:n,config:i.config,data:Array.isArray(t)?t:[],layout:i.layout,layoutConfig:i.layoutConfig,semantic:A(P)??{},size:r,themeCategorical:P.colors.categorical,xExtent:i.xExtent,yExtent:i.yExtent});return{...o,config:s.config,initialSpawns:ey(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??nf(e||i.colorBy)}}}};function oy(t){const e=t instanceof Date?t.getTime():"number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function iy(t){if(!t||2>t.length)return;const e=oy(t[0]),n=oy(t[t.length-1]);return null!==e&&null!==n?[e,n]:void 0}function ry(t){const{count:e,byType:n}=function(t){const e={};for(const n of t){const t="string"==typeof n?.type&&n.type.length>0?n.type:"node";e[t]=(e[t]??0)+1}return{count:t.length,byType:e}}(t.marks),o=0===e,i=[...t.extraWarnings??[]];return o&&!i.includes("EMPTY_SCENE")&&i.push("EMPTY_SCENE"),{component:"",frameType:t.frameType,status:o?"empty":"ok",empty:o,markCount:e,markCountByType:n,width:t.width,height:t.height,...t.xDomain?{xDomain:t.xDomain}:{},...t.yDomain?{yDomain:t.yDomain}:{},...t.categories?{categories:t.categories}:{},...void 0!==t.nodeCount?{nodeCount:t.nodeCount}:{},...void 0!==t.edgeCount?{edgeCount:t.edgeCount}:{},...void 0!==t.legendItems?{legendItems:t.legendItems}:{},annotationCount:Array.isArray(t.annotations)?t.annotations.length:0,ariaLabel:"string"==typeof t.description&&t.description||"string"==typeof t.title&&t.title||`${t.frameType} chart, ${e} marks`,warnings:i}}import*as sy from"react";import*as ay from"react-dom/server";import{scaleOrdinal as ly}from"d3-scale";import{jsx as cy,jsxs as uy}from"react/jsx-runtime";function hy(t,e,n){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;return e=>_t(t,e)??"#999"}const o=Array.isArray(e)?e:n.colors.categorical.length>0?n.colors.categorical:K;return ly().domain(t).range(o)}function dy(t){return"left"===t?"start":"right"===t?"end":t??"start"}function fy(t){return Number(t.typography.legendSize??t.typography.labelSize??t.typography.tickSize)||11}function py(t,e,n,o){const i=fy(o);return e+n+Math.ceil(t.length*i*.58)}function yy(t){const{categories:e,theme:n,position:o="right",totalWidth:i,margin:r,legendLayout:s}=t,{swatchSize:a,labelGap:l,itemGap:c,rowHeight:u}=Wi(s),h=a+l,d="top"===o||"bottom"===o,f=Math.max(a,i-r.left-r.right),p=e.map(t=>py(t,a,l,n));if(d){const t=Math.max(a,s?.maxWidth??f),n=[];let o=0,i=0;p.forEach((e,r)=>{const s=0===i?e:i+c+e;i>0&&s>t?(n.push({start:o,end:r,width:i}),o=r,i=e):i=s}),e.length>0&&n.push({start:o,end:e.length,width:i});const r=dy(s?.align),l=[];return n.forEach((n,o)=>{let i="center"===r?Math.max(0,(t-n.width)/2):"end"===r?Math.max(0,t-n.width):0;for(let t=n.start;n.end>t;t++)l.push({category:e[t],width:p[t],x:i,y:o*u}),i+=p[t]+c}),{items:l,width:Math.max(0,...n.map(t=>t.width)),height:n.length*u,swatchSize:a,labelOffset:h,swatchRadius:0}}const y=Math.max(0,...p);return{items:e.map((t,e)=>({category:t,width:p[e],x:0,y:e*u})),width:y,height:e.length*u,swatchSize:a,labelOffset:h,swatchRadius:0}}function gy(t){const{legendGroups:e,theme:n,position:o="right",totalWidth:i,margin:r,legendLayout:s}=t,{swatchSize:a,labelGap:l,rowHeight:c}=Wi(s),u=a+l,h=Math.max(12,fy(n)),d="top"===o||"bottom"===o,f=Math.max(a,i-r.left-r.right);if(d){const o=Math.max(a,s?.maxWidth??f),i=dy(s?.align);let r=0,l=0;const c=[];for(const i of e){const e=i.items.map(t=>t.label),u=yy({...t,categories:e,legendLayout:{...s,maxWidth:Math.max(a,o-h-8),align:"start"}}),d=i.label?h:0,f=i.label?py(i.label,0,0,n):0,p=d>0?d+8:0,y=p+u.width,g=Math.max(u.height,f);c.push({group:i,x:r,y:0,itemOffsetX:p,itemOffsetY:0,width:y,height:g,items:u.items}),r+=y+12,l=Math.max(l,g)}const d=c.length>0?r-12:0,p=d>o?0:"center"===i?Math.max(0,(o-d)/2):"end"===i?Math.max(0,o-d):0;return{groups:c.map(t=>({...t,x:t.x+p})),width:d,height:l,swatchSize:a,labelOffset:u,swatchRadius:0}}const p=ji(e.map(t=>({hasLabel:!!t.label,itemCount:t.items.length})),c);let y=0;return{groups:e.map((t,e)=>{const o=t.items.map(t=>py(t.label,a,l,n)),i=Math.max(0,...o,t.label?py(t.label,0,0,n):0);return y=Math.max(y,i),{group:t,x:0,y:p[e].itemsY,itemOffsetX:0,itemOffsetY:0,width:i,height:t.items.length*c,items:t.items.map((t,e)=>({category:t.label,width:o[e],x:0,y:e*c}))}}),width:y,height:p.at(-1)?.endY??0,swatchSize:a,labelOffset:u,swatchRadius:0}}function my(t){const e="top"===t.position||"bottom"===t.position,n=Math.max(1,t.totalWidth-t.margin.left-t.margin.right);return e?{width:Math.min(t.legendLayout?.maxWidth??n,200),height:t.gradient.label?34:26,swatchSize:12}:{width:t.gradient.label?86:72,height:t.gradient.label?124:108,swatchSize:14}}function xy(t,e){if(!e||!t||0===t.length)return[];const n="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=n(e);null!=t&&o.add(t+"")}return Array.from(o)}import{jsx as by,jsxs as vy}from"react/jsx-runtime";var wy=16;function ky(t,e){return t.color||e.colors.annotation||e.colors.text}function Sy(t,e,n){const o=t.labelBackground,i=e.colors.background,r=i&&"transparent"!==i?i:e.colors.surface||i;return void 0===o?"none"===n?"none":{type:"halo",fill:r}:!1===o||"none"===o?"none":!0===o||"halo"===o?{type:"halo",fill:r}:"box"===o?{type:"box",fill:r}:{fill:r,...o}}function Ay(t,e,n){return null!=t.x&&e.x?e.x(t.x):n&&null!=t[n]&&e.x?e.x(t[n]):"number"==typeof t.x?t.x:null}function My(t,e,n){return null!=t.y&&e.y?e.y(t.y):n&&null!=t[n]&&e.y?e.y(t[n]):"number"==typeof t.y?t.y:null}function _y(t){const{annotations:e}=t;if(!e||0===e.length)return null;const n=s(e),o=t.autoPlaceAnnotations?hs({annotations:n,context:{scales:{x:t.scales.x,y:t.scales.y,time:t.scales.x,value:t.scales.y,o:t.scales.o,geoProjection:t.scales.geoProjection},width:t.layout.width,height:t.layout.height,xAccessor:t.xAccessor,yAccessor:t.yAccessor,frameType:t.projection?"ordinal":"xy",projection:"horizontal"===t.projection?"horizontal":"vertical"},..."object"==typeof t.autoPlaceAnnotations?t.autoPlaceAnnotations:{}}):n,i=[];for(let e=0;o.length>e;e++){const n=Py(o[e],e,t);n&&i.push({node:n,annotation:o[e]})}const r=Gr(i);return r.length>0?by("g",{id:(t.idPrefix?t.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:r}):null}function Py(t,e,n){const{scales:o,layout:i,theme:r,xAccessor:s,yAccessor:a}=n;switch(t.type){case"y-threshold":{const s=t.value;if(null==s)return null;const a=ky(t,r),l=t.label,c=t.labelPosition||"right",u=t.strokeDasharray||"6,4",h=t.strokeWidth??1.5;if("horizontal"===n.projection&&o.r){const n=o.r(s);return null==n?null:vy("g",{opacity:t.opacity,children:[by("line",{x1:n,y1:0,x2:n,y2:i.height,stroke:a,strokeWidth:h,strokeDasharray:u}),l&&by(Vr,{x:n+4,y:wy,textAnchor:"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:l,background:Sy(t,r,"halo")})]},"ann-ythresh-"+e)}const d=o.y?o.y(s):o.r?o.r(s):null;return null==d?null:vy("g",{children:[by("line",{x1:0,y1:d,x2:i.width,y2:d,stroke:a,strokeWidth:h,strokeDasharray:u}),l&&by(Vr,{x:"left"===c?4:"center"===c?i.width/2:i.width-4,y:20>d?Math.min(i.height-4,d+wy):d-6,textAnchor:"left"===c?"start":"center"===c?"middle":"end",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:l,background:Sy(t,r,"halo")})]},"ann-ythresh-"+e)}case"x-threshold":{const n=t.value;if(null==n||!o.x)return null;const s=o.x(n);if(null==s)return null;const a=ky(t,r),l=t.label,c=t.labelPosition||"top";return vy("g",{opacity:t.opacity,children:[by("line",{x1:s,y1:0,x2:s,y2:i.height,stroke:a,strokeWidth:t.strokeWidth??1.5,strokeDasharray:t.strokeDasharray||"6,4"}),l&&by(Vr,{x:s>.6*i.width?s-4:s+4,y:"bottom"===c?i.height-4:"center"===c?i.height/2:wy,textAnchor:s>.6*i.width?"end":"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:l,background:Sy(t,r,"halo")})]},"ann-xthresh-"+e)}case"band":{const n=o.y?.domain?.(),s=t.y0??n?.[0],a=t.y1??n?.[1],l=null!=s&&o.y?o.y(s):null,c=null!=a&&o.y?o.y(a):null;if(null==l||null==c)return null;const u=Math.min(l,c),h=Math.abs(c-l),d=ei(t.fill||ky(t,r),"ssr-band-"+e),f=t.fillOpacity??.1;return vy("g",{opacity:t.opacity,children:[d.def&&by("defs",{children:d.def}),by("rect",{x:0,y:u,width:i.width,height:h,fill:d.fill,fillOpacity:f}),t.label&&by(Vr,{x:i.width-4,y:Math.max(u,0)+wy,textAnchor:"end",fontSize:r.typography.tickSize,fill:t.color||ky(t,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:t.label,background:Sy(t,r,"halo")})]},"ann-band-"+e)}case"x-band":{const n=o.x?.domain?.(),s=t.x0??n?.[0],a=t.x1??n?.[1],l=null!=s&&o.x?o.x(s):null,c=null!=a&&o.x?o.x(a):null;if(null==l||null==c)return null;const u=Math.min(l,c),h=Math.abs(c-l),d=ei(t.fill||ky(t,r),"ssr-xband-"+e),f=t.fillOpacity??.1;return vy("g",{opacity:t.opacity,children:[d.def&&by("defs",{children:d.def}),by("rect",{x:u,y:0,width:h,height:i.height,fill:d.fill,fillOpacity:f}),t.label&&by(Vr,{x:u+4,y:wy,textAnchor:"start",fontSize:r.typography.tickSize,fill:t.color||r.colors.primary||ky(t,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:t.label,background:Sy(t,r,"halo")})]},"ann-xband-"+e)}case"category-highlight":{if(null==t.category||!o.o)return null;const s=o.o(t.category+"");if(null==s)return null;const a=o.o.bandwidth?o.o.bandwidth():40,l=ky(t,r),c=t.opacity??.1,u=t.label;return vy("g","horizontal"===n.projection?{children:[by("rect",{x:0,y:s,width:i.width,height:a,fill:l,opacity:c}),u&&by(Vr,{x:12,y:s+a/2,dominantBaseline:"middle",fill:l,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:u,background:Sy(t,r,"none")})]}:{children:[by("rect",{x:s,y:0,width:a,height:i.height,fill:l,opacity:c}),u&&by(Vr,{x:s+a/2,y:wy,textAnchor:"middle",fill:l,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:u,background:Sy(t,r,"none")})]},"ann-cathighlight-"+e)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:n,y:i}=function(t,e,n,o){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const n=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(n)return{x:n[0],y:n[1]}}return{x:Ay(t,e,n),y:My(t,e,o)}}(t,o,s,a);if(null==n||null==i)return null;const l="text"===t.type,c=t.dx??(l?0:30),u=t.dy??(l?0:-30),h=t.color||r.colors.text;if(!l){const o="callout"===t.type?"callout-circle":t.type,r="callout-circle"===o?{radius:t.radius??12,radiusPadding:t.radiusPadding}:"callout-rect"===o?{width:t.width,height:t.height}:void 0;return by(xr,{noteData:{x:n,y:i,dx:c,dy:u,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:o,...r?{subject:r}:{},connector:t.connector||{end:"arrow"},color:h,disable:t.disable,opacity:t.opacity,strokeDasharray:t.strokeDasharray,className:t.className}},"ann-label-"+e)}return by("g",{children:by("text",{x:n+c,y:i+u,textAnchor:t.textAnchor||"start",fontSize:t.fontSize||r.typography.labelSize,fill:h,fontFamily:r.typography.fontFamily,fontWeight:t.fontWeight,opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:t.label||t.title})},"ann-label-"+e)}default:return null}}import*as Cy from"react";import{jsx as Ty,jsxs as Ly}from"react/jsx-runtime";function Ry(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function $y(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const n=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;n.length>t;t++)o=31*o+n.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}function zy(t,e,n){const o=t.showLegend&&!t.__legendIncludesAutomatic?function(t,e,n){if(0===t.length)return;const o=hy(t,e,n);return{legendGroups:[{label:"",type:"fill",items:t.map(t=>({label:t})),styleFn:t=>({fill:o(t.label)})}]}}(e,t.colorScheme,n):void 0;return Qi(o,t.legend)}var Dy={right:110,left:110,top:50,bottom:80};function Iy(t,e){if(t.__autoLegendMargin&&!By(t,e))return Dy[e]}function By(t,e){const n=t.__explicitMargin;return"number"==typeof n||!(!n||"object"!=typeof n||"number"!=typeof n[e])}function Fy(t,e){const{props:n,categories:o,theme:i,size:r,hasTitle:s}=e,a=n.legendPosition||"right",l={theme:i,position:a,size:r,hasTitle:s,legendLayout:n.legendLayout,minimumMargin:Iy(n,a),preserveExplicitMargin:By(n,a)};if(null!=n.legend){const e=zy(n,o,i);(Ji(e)||tr(e))&&function(t,e){if(e.preserveExplicitMargin)return;const n=e.position||"right",o={theme:e.theme,position:n,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout},i=Ji(e.legend)?function(t){const{width:e,height:n,swatchSize:o}=gy(t);return{width:e,height:n,swatchSize:o}}({...o,legendGroups:e.legend.legendGroups}):tr(e.legend)?my({...o,gradient:e.legend.gradient}):null;if(!i)return;const r=e.minimumMargin??i.width+14,s=e.minimumMargin??(e.hasTitle?32:8)+i.height+4,a=e.minimumMargin??38+i.height+4;"right"===n?t.right=Math.max(t.right,r):"left"===n?t.left=Math.max(t.left,r):"top"===n?t.top=Math.max(t.top,s):t.bottom=Math.max(t.bottom,a)}(t,{...l,legend:e})}else n.showLegend&&o.length>0&&function(t,e){if(0===e.categories.length)return;if(e.preserveExplicitMargin)return;const n=e.position||"right",o=function(t){const{width:e,height:n,swatchSize:o}=yy(t);return{width:e,height:n,swatchSize:o}}({categories:e.categories,colorScheme:e.colorScheme,theme:e.theme,position:n,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout}),i=e.minimumMargin??o.width+14,r=e.minimumMargin??(e.hasTitle?32:8)+o.height+4,s=e.minimumMargin??38+o.height+4;"right"===n?t.right=Math.max(t.right,i):"left"===n?t.left=Math.max(t.left,i):"top"===n?t.top=Math.max(t.top,r):t.bottom=Math.max(t.bottom,s)}(t,{...l,categories:o,colorScheme:n.colorScheme});return a}function Ey(t){const{props:e,categories:n,theme:o,size:i,margin:r,hasTitle:s}=t,a=e.legendPosition||"right",l={theme:o,position:a,size:i,margin:r,hasTitle:s,legendLayout:e.legendLayout,idPrefix:e._idPrefix,reservedWidth:e.__autoLegendMargin?100:void 0};if(null!=e.legend){const t=zy(e,n,o);if(Cy.isValidElement(t))return t;const i=function(t,e){const n={theme:e.theme,position:e.position||"right",totalWidth:e.size[0],totalHeight:e.size[1],margin:e.margin,hasTitle:e.hasTitle,legendLayout:e.legendLayout,idPrefix:e.idPrefix,reservedWidth:e.reservedWidth};return Ji(t)?function(t){if(0===(e=t.legendGroups,e.flatMap(t=>t.items.map((e,n)=>({group:t,item:e,itemIndex:n,label:e.label})))).length)return null;var e;const n=gy(t),o="top"===t.position||"bottom"===t.position,i=t.theme.colors.grid||t.theme.colors.textSecondary;let r,s;if("left"===t.position?(r=Math.max(4,t.margin.left-(t.reservedWidth??100)-10),s=t.margin.top):"top"===t.position?(r=t.margin.left,s=t.hasTitle?32:8):"bottom"===t.position?(r=t.margin.left,s=t.totalHeight-t.margin.bottom+38):(r=t.totalWidth-t.margin.right+10,s=t.margin.top),!o){const e=ji(t.legendGroups.map(t=>({hasLabel:!!t.label,itemCount:t.items.length})),Math.max(n.swatchSize,t.legendLayout?.rowHeight??22)),o=t.legendGroups.flatMap((o,i)=>{const r=e[i],s=o.type??"fill",a=[cy("line",{x1:0,y1:r.lineY,x2:t.reservedWidth??100,y2:r.lineY,stroke:"gray"},"legend-group-neatline-"+i)];return o.label&&null!=r.labelY&&a.push(cy("text",{y:r.labelY,fontSize:fy(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:o.label},"legend-group-label-"+i)),a.push(cy("g",{transform:`translate(0,${r.itemsY})`,children:o.items.map((e,r)=>{const a=o.styleFn(e,r),l="function"==typeof s?s(e):"line"===s?cy("line",{x1:0,y1:0,x2:n.swatchSize,y2:n.swatchSize,style:a}):cy("rect",{width:n.swatchSize,height:n.swatchSize,rx:n.swatchRadius,style:a});return uy("g",{transform:`translate(0,${r*Math.max(n.swatchSize,t.legendLayout?.rowHeight??22)})`,children:[l,cy("text",{x:n.labelOffset,y:n.swatchSize/2,dominantBaseline:"central",fontSize:fy(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:e.label})]},`legend-${i}-${r}`)})},"legend-group-"+i)),a});return cy("g",{className:"semiotic-legend",transform:`translate(${r},${s})`,"data-orientation":"vertical",children:o})}const a=n.groups.flatMap((e,r)=>{const{group:s}=e,a=s.type??"fill",l=[];if(s.label&&l.push(cy("text",o?{transform:`translate(${e.x},${e.y}) rotate(90)`,textAnchor:"start",fontSize:fy(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:s.label}:{x:e.x,y:e.y+fy(t.theme),fontSize:fy(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:s.label},"legend-group-label-"+r)),l.push(...e.items.map((o,i)=>{const l=s.items[i],c=s.styleFn(l,i),u="function"==typeof a?a(l):"line"===a?cy("line",{x1:0,y1:0,x2:n.swatchSize,y2:n.swatchSize,style:c}):cy("rect",{width:n.swatchSize,height:n.swatchSize,rx:n.swatchRadius,style:c});return uy("g",{transform:`translate(${e.x+e.itemOffsetX+o.x},${e.y+e.itemOffsetY+o.y})`,children:[u,cy("text",{x:n.labelOffset,y:n.swatchSize/2,dominantBaseline:"central",fontSize:fy(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:o.category})]},`legend-${r}-${i}`)})),o&&n.groups.length-1>r){const t=e.x+e.width+6;l.push(cy("line",{x1:t,y1:0,x2:t,y2:n.height,stroke:i},"legend-group-separator-"+r))}return l});return cy("g",{className:"semiotic-legend",transform:`translate(${r},${s})`,"data-orientation":o?"horizontal":"vertical",children:a})}({...n,legendGroups:t.legendGroups}):tr(t)?function(t){const e=my(t),n="top"===t.position||"bottom"===t.position,o=(t.idPrefix?t.idPrefix+"-":"")+"semiotic-static-gradient-legend",i=t.gradient.format||(t=>Math.round(100*t)/100+"");let r,s;"left"===t.position?(r=Math.max(4,t.margin.left-100-10),s=t.margin.top):"top"===t.position?(r=t.margin.left,s=t.hasTitle?32:8):"bottom"===t.position?(r=t.margin.left,s=t.totalHeight-t.margin.bottom+38):(r=t.totalWidth-t.margin.right+10,s=t.margin.top);const a=Array.from({length:17},(e,o)=>{const i=o/16;return cy("stop",{offset:100*i+"%",stopColor:t.gradient.colorFn(n?t.gradient.domain[0]+i*(t.gradient.domain[1]-t.gradient.domain[0]):t.gradient.domain[1]-i*(t.gradient.domain[1]-t.gradient.domain[0]))},o)});if(n){const n=12,l=t.gradient.label?0:void 0,c=t.gradient.label?8:0;return uy("g",{className:"semiotic-legend",transform:`translate(${r},${s})`,children:[cy("defs",{children:cy("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),t.gradient.label&&cy("text",{x:e.width/2,y:l,textAnchor:"middle",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:t.gradient.label}),cy("rect",{x:0,y:c,width:e.width,height:n,fill:`url(#${o})`,rx:2}),cy("text",{x:0,y:c+n+12,textAnchor:"start",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:i(t.gradient.domain[0])}),cy("text",{x:e.width,y:c+n+12,textAnchor:"end",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:i(t.gradient.domain[1])})]})}const l=t.gradient.label?-6:void 0;return uy("g",{className:"semiotic-legend",transform:`translate(${r},${s+(t.gradient.label?12:0)})`,children:[cy("defs",{children:cy("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),t.gradient.label&&cy("text",{x:7,y:l,textAnchor:"middle",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:t.gradient.label}),cy("rect",{x:0,y:0,width:14,height:100,fill:`url(#${o})`,rx:2}),cy("text",{x:19,y:10,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:i(t.gradient.domain[1])}),cy("text",{x:19,y:100,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:i(t.gradient.domain[0])})]})}({...n,gradient:t.gradient}):null}(t,l);return i||(Ji(t)||tr(t)?null:t??null)}return e.showLegend&&0!==n.length?function(t){const{categories:e,colorScheme:n,theme:o,position:i="right",totalWidth:r,totalHeight:s,margin:a,hasTitle:l=!1}=t;if(!e||0===e.length)return null;const c=hy(e,n,o),u="top"===i||"bottom"===i,h=yy(t);let d,f;if("left"===i?(d=Math.max(4,a.left-(t.reservedWidth??100)-10),f=a.top):"top"===i?(d=a.left,f=l?32:8):"bottom"===i?(d=a.left,f=s-a.bottom+38):(d=r-a.right+10,f=a.top),u){const t=h.items.map((t,e)=>uy("g",{transform:`translate(${t.x},${t.y})`,children:[cy("rect",{width:h.swatchSize,height:h.swatchSize,fill:c(t.category),rx:h.swatchRadius}),cy("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:fy(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:t.category})]},"legend-"+e));return cy("g",{className:"semiotic-legend",transform:`translate(${d},${f})`,children:t})}const p=ji([{hasLabel:!1,itemCount:e.length}],Math.max(h.swatchSize,t.legendLayout?.rowHeight??22))[0],y=h.items.map((t,e)=>uy("g",{transform:`translate(${t.x},${t.y+p.itemsY})`,children:[cy("rect",{width:h.swatchSize,height:h.swatchSize,fill:c(t.category),rx:h.swatchRadius}),cy("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:fy(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:t.category})]},"legend-"+e));return uy("g",{className:"semiotic-legend",transform:`translate(${d},${f})`,children:[cy("line",{x1:0,y1:p.lineY,x2:t.reservedWidth??100,y2:p.lineY,stroke:"gray"}),y]})}({categories:n,colorScheme:e.colorScheme,theme:o,position:a,totalWidth:i[0],totalHeight:i[1],margin:r,hasTitle:s,legendLayout:e.legendLayout,reservedWidth:e.__autoLegendMargin?100:void 0,idPrefix:e._idPrefix}):null}function Oy(t){return Math.round(100*t)/100+""}function Ny(t,e){const n=I(e.theme),o=e.background??n.background,i=e.idPrefix?e.idPrefix+"-":"",r="string"==typeof e.title?e.title:void 0,s=r?i+"semiotic-title":void 0,a=e.description?i+"semiotic-desc":void 0,l=[s,a].filter(Boolean).join(" ")||void 0;return Ly("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,width:e.width,height:e.height,role:"img","aria-labelledby":l,style:{fontFamily:n.fontFamily},children:[r&&Ty("title",{id:s,children:r}),e.description&&Ty("desc",{id:a,children:e.description}),e.defs&&Ty("defs",{children:e.defs}),o&&"transparent"!==o&&Ty("rect",{x:0,y:0,width:e.width,height:e.height,fill:o}),Ty("g",{id:i+"data-area",transform:e.innerTransform,children:t}),r&&Ty("text",{id:i+"chart-title",x:e.width/2,y:22,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily,children:r}),e.legend&&Ty("g",{id:i+"legend",children:e.legend}),e.outerElements]})}import{Fragment as Wy,jsx as jy,jsxs as Yy}from"react/jsx-runtime";function Gy(t,e){const n=D(t.theme),o=t.size||[500,300],i=Rs({top:20,right:20,bottom:30,left:40,...t.margin},t.title),r=Ts(t.title),s=q(t.data),a=t.showLegend?xy(s,t.colorAccessor||t.groupAccessor||t.categoryAccessor):[];Fy(i,{props:t,categories:a,theme:n,size:o,hasTitle:r});const l=o[0]-i.left-i.right,c=o[1]-i.top-i.bottom,u="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),h=t.colorScheme||n.colors.categorical,d={chartType:t.chartType,windowSize:t.windowSize??200,windowMode:t.windowMode??"sliding",arrowOfTime:u?t.arrowOfTime??"right":"right",extentPadding:t.extentPadding??.1,xAccessor:u?void 0:t.xAccessor,yAccessor:u?void 0:t.yAccessor,timeAccessor:u?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,symbolAccessor:t.symbolAccessor,symbolMap:t.symbolMap,groupAccessor:t.groupAccessor,categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,axisExtent:t.axisExtent,sizeRange:t.sizeRange,xScaleType:t.xScaleType,yScaleType:t.yScaleType,scalePadding:t.scalePadding,binSize:t.binSize,normalize:t.normalize,baseline:t.baseline,stackOrder:t.stackOrder,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,band:t.band,y0Accessor:t.y0Accessor,areaGroups:t.areaGroups?t.areaGroups instanceof Set?t.areaGroups:new Set(t.areaGroups):void 0,curve:t.curve,gradientFill:!0===t.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===t.gradientFill?void 0:t.gradientFill,lineGradient:t.lineGradient,openAccessor:t.openAccessor,highAccessor:t.highAccessor,lowAccessor:t.lowAccessor,closeAccessor:t.closeAccessor,candlestickStyle:t.candlestickStyle,lineStyle:t.lineStyle,pointStyle:t.pointStyle,areaStyle:t.areaStyle,barStyle:t.barStyle,waterfallStyle:t.waterfallStyle,swarmStyle:t.swarmStyle,colorScheme:h,themeCategorical:n.colors.categorical,themeSemantic:A(n),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:i,layoutSelection:t.layoutSelection,barColors:t.barColors,showValues:t.showValues,heatmapValueFormat:t.heatmapValueFormat},f=new ao(d);if(t.data&&f.ingest({inserts:s,bounded:!0}),f.computeScene({width:l,height:c}),!f.scales||0===f.scene.length)return e&&(e.evidence=ry({frameType:"xy",width:o[0],height:o[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),ay.renderToStaticMarkup(Ny(null,{width:o[0],height:o[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${i.left},${i.top})`,innerWidth:l,innerHeight:c,idPrefix:t._idPrefix}));const p=t._idPrefix,y=Sc({nodes:f.scene,renderMode:t.renderMode,fallback:(t,e)=>ma(t,e,p)});e&&(e.evidence=ry({frameType:"xy",width:o[0],height:o[1],marks:y.map(t=>t.node),title:t.title,description:t.description,annotations:t.annotations,xDomain:iy(f.scales.x?.domain?.()),yDomain:iy(f.scales.y?.domain?.()),legendItems:a.length>0?a.length:void 0}));const g=t.showGrid?function(t,e,n,o,i){const{grid:r}=I(n),s=o?o+"-":"",a="exact"===i?5:Math.min(5,Math.max(2,Math.floor(e.width/70))),l="exact"===i?5:Math.min(5,Math.max(2,Math.floor(e.height/30))),c=Ss(t.x,a,i),u=Ss(t.y,l,i);return Ly("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[c.map((n,o)=>{const i=t.x(n);return Ty("line",{x1:i,y1:0,x2:i,y2:e.height,stroke:r,strokeWidth:.5},"gx-"+o)}),u.map((n,o)=>{const i=t.y(n);return Ty("line",{x1:0,y1:i,x2:e.width,y2:i,stroke:r,strokeWidth:.5},"gy-"+o)})]})}(f.scales,{width:l,height:c},n,p,t.axisExtent):null,m=y.map(t=>t.element),x=$y(t)+"-plot-clip",b=!1!==t.showAxes?function(t,e,n,o,i){const r=I(o),s="exact"===n.axisExtent?5:Math.min(5,Math.max(2,Math.floor(e.width/70))),a="exact"===n.axisExtent?5:Math.min(5,Math.max(2,Math.floor(e.height/30))),l=Ss(t.x,s,n.axisExtent).map(e=>({pixel:t.x(e),label:(n.xFormat||n.tickFormatTime||Oy)(e)})),c=Ss(t.y,a,n.axisExtent).map(e=>({pixel:t.y(e),label:(n.yFormat||n.tickFormatValue||Oy)(e)}));return Ly("g",{id:(i?i+"-":"")+"axes",className:"stream-axes",children:[Ty("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:r.border,strokeWidth:1}),l.map((t,n)=>Ly("g",{transform:`translate(${t.pixel},${e.height})`,children:[Ty("line",{y2:5,stroke:r.border,strokeWidth:1}),Ty("text",{y:18,textAnchor:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:t.label})]},"xtick-"+n)),n.xLabel&&Ty("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,children:n.xLabel}),Ty("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:r.border,strokeWidth:1}),c.map((t,e)=>Ly("g",{transform:`translate(0,${t.pixel})`,children:[Ty("line",{x2:-5,stroke:r.border,strokeWidth:1}),Ty("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:t.label})]},"ytick-"+e)),n.yLabel&&Ty("text",{x:15-(n.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${e.height/2})`,children:n.yLabel})]})}(f.scales,{width:l,height:c},t,n,p):null,v=t.annotations?_y({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{x:f.scales.x,y:f.scales.y},layout:{width:l,height:c},theme:n,xAccessor:"string"==typeof t.xAccessor?t.xAccessor:void 0,yAccessor:"string"==typeof t.yAccessor?t.yAccessor:void 0,idPrefix:p}):null,w=t.svgPreRenderers&&f.scales?t.svgPreRenderers.map((t,e)=>{try{return jy(sy.Fragment,{children:t(f.scene,f.scales,{width:l,height:c})},"pre-"+e)}catch{return null}}).filter(Boolean):null,k=Ey({props:t,categories:a,theme:n,size:o,margin:i,hasTitle:r});return ay.renderToStaticMarkup(Ny(Yy(Wy,{children:[t.backgroundGraphics,w,g,jy("defs",{children:jy("clipPath",{id:x,children:jy("rect",{x:0,y:0,width:l,height:c})})}),jy("g",{clipPath:`url(#${x})`,children:m}),b,v,t.foregroundGraphics,f.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${i.left},${i.top})`,innerWidth:l,innerHeight:c,legend:k,idPrefix:t._idPrefix}))}import*as qy from"react-dom/server";import{scaleBand as Xy,scaleLinear as Hy}from"d3-scale";var Vy=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(t,e,n){if(e&&"function"==typeof t.pieceStyle){const o=t.pieceStyle(e,n);return o&&!o.fill&&n?{...o,fill:this.getColorFromScheme(t,n)}:o}return t.pieceStyle&&"object"==typeof t.pieceStyle?t.pieceStyle:t.barColors&&n?{fill:t.barColors[n]||"#007bff"}:{fill:n?this.getColorFromScheme(t,n):"#007bff"}}resolveSummaryStyle(t,e,n){return e&&"function"==typeof t.summaryStyle?t.summaryStyle(e,n):t.summaryStyle&&"object"==typeof t.summaryStyle?t.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(t,e){const n=this.colorSchemeMap.get(e);if(n)return n;const o=Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical||kt,i=o[this.colorSchemeIndex%o.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(e,i),i}};function Uy(t){const e=t.getSymbol;if(!e)return null;const n=t.config.symbolMap,o=new Map;let i=0;return t=>{const r=e(t)+"",s=n?.[r];if(s)return s;let a=o.get(r);return a||(a=hn[i%hn.length],i++,o.set(r,a)),a}}function Ky(t,e,n,o,i,r,s){t.push(e?{type:"symbol",x:o,y:i,size:Math.PI*r*r,symbolType:e(n),style:s,datum:n}:{type:"point",x:o,y:i,r:r,style:s,datum:n})}function Zy(t,e){const{columns:n,config:o,resolvePieceStyle:i}=t,r=[],s=Math.min(e.width,e.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,l=-Math.PI/2+(o.startAngle||0)*Math.PI/180,c=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI,u=null!=o.sweepAngle&&360>o.sweepAngle,h=Object.values(n),d=h.some(t=>{const e=t.pieceData[0];return e&&("number"==typeof e._pct||"number"==typeof e._pctStart||null!=e._roundedEnds)}),f=u&&!d&&h.length>1&&(o.cornerRadius??0)>0;for(let t=0;h.length>t;t++){const e=h[t],n=e.pieceData[0],u="number"==typeof n?._pctStart?n._pctStart:e.pctStart,d=l+u*c,p=l+(u+("number"==typeof n?._pct?n._pct:e.pct))*c,y=i(e.pieceData[0],e.name),g=0===t,m=t===h.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:d,endAngle:p,...o.cornerRadius&&{cornerRadius:o.cornerRadius},style:y,datum:n?._nonInteractive?null:e.pieceData,category:e.name};n?._roundedEnds?x.roundedEnds=n._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),n?._gradientBand&&(x._gradientBand=n._gradientBand),r.push(x)}return r}import{quantile as Qy}from"d3-array";function Jy(t){const e=t.length,n=t[0],o=t[e-1];return{n:e,min:n,q1:Qy(t,.25)??n,median:Qy(t,.5)??(n+o)/2,q3:Qy(t,.75)??o,max:o,mean:t.reduce((t,e)=>t+e,0)/e}}import{scaleLinear as tg}from"d3-scale";var eg={bar:function(t,e){const{scales:n,columns:o,config:i,getR:r,getStack:s,resolvePieceStyle:a}=t,{r:l,projection:c}=n,u=[],h="vertical"===c,d="horizontal"===c,f=i.normalize,p=[];if(s){const t=new Set;for(const e of Object.values(o))for(const n of e.pieceData){const e=s(n);t.has(e)||(t.add(e),p.push(e))}}else p.push("_default");for(const t of Object.values(o)){const e=new Map;for(const n of t.pieceData){const t=s?s(n):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=r(n),o.pieces.push(n)}let n=0;if(f)for(const t of e.values())n+=Math.abs(t.total);let o=0,i=0;for(const r of p){const c=e.get(r);if(!c)continue;let p=c.total;f&&n>0&&(p/=n);const y=a(c.pieces[0],s?r:t.name),g={...c.pieces[0],__aggregateValue:c.total,__pieceCount:c.pieces.length,category:t.name};if(h){const e=l(0>p?i:o+p),n=0>p?l(i+p)-l(i):l(o)-l(o+p);u.push(Ye(t.x,e,t.width,Math.abs(n),y,g,r)),0>p?i+=p:o+=p}else if(d){const e=l(0>p?i+p:o),n=0>p?l(i)-l(i+p):l(o+p)-l(o);u.push(Ye(e,t.x,Math.abs(n),t.width,y,g,r)),0>p?i+=p:o+=p}}}const y="vertical"===c,g=i.roundedTop&&i.roundedTop>0?Math.max(0,i.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;const e=t.datum?.__aggregateValue??0;t.roundedEdge=y?0>e?"bottom":"top":0>e?"left":"right",i.gradientFill&&(t.fillGradient=i.gradientFill)}if(g>0){const t=new Map;for(const e of u){if("rect"!==e.type)continue;const n=e.datum?.category||"";t.has(n)||t.set(n,[]),t.get(n).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>(t.datum?.__aggregateValue??0)>=0),n=e.filter(t=>0>(t.datum?.__aggregateValue??0));t.length>0&&(t.reduce(y?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=g),n.length>0&&(n.reduce(y?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=g)}}return u},clusterbar:function(t,e){const{scales:n,columns:o,config:i,getR:r,getGroup:s,resolvePieceStyle:a}=t,{r:l,projection:c}=n,u=[],h="vertical"===c,d=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),d.push(t))}const p=d.length||1;for(const t of Object.values(o)){const e=t.width/p,n=.2*e,o=e-n,i=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";i.has(t)||i.set(t,[]),i.get(t).push(e)}for(let s=0;d.length>s;s++){const c=i.get(d[s])||[];for(const i of c){const c=r(i),f=a(i,d[s]);if(h){const r=t.x+s*e+n/2,a=l(0),h=l(c);u.push(Ye(r,Math.min(a,h),o,Math.abs(a-h),f,i,d[s]))}else{const r=t.x+s*e+n/2,a=l(0),h=l(c);u.push(Ye(Math.min(a,h),r,Math.abs(h-a),o,f,i,d[s]))}}}}const y=i.roundedTop&&i.roundedTop>0?Math.max(0,i.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=r(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=h?0>e?"bottom":"top":0>e?"left":"right",i.gradientFill&&(t.fillGradient=i.gradientFill)}return u},point:function(t,e){const{scales:n,columns:o,getR:i,multiScales:r,resolvePieceStyle:s}=t,{r:a,projection:l}=n,c=[],u="vertical"===l,h="radial"===l,d=r.length>0,f=Uy(t),p=2*Math.PI,y=-Math.PI/2;for(const t of Object.values(o))for(const e of t.pieceData){const n=e.__rIndex??0,o=e.__rValue??i(e),l=d&&r[n]||a,g=s(e,t.name),m=g.r||5;let x,b;if(h){const e=y+(t.pctStart+t.pct/2)*p,n=l(o);x=Math.cos(e)*n,b=Math.sin(e)*n}else u?(x=t.middle,b=l(o)):(x=l(o),b=t.middle);Ky(c,f,e,x,b,m,g)}return c},swarm:function(t,e){const{scales:n,columns:o,getR:i,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="vertical"===a,u=Uy(t);for(const t of Object.values(o)){const e=t.width/2;for(let n=0;t.pieceData.length>n;n++){const o=t.pieceData[n],a=i(o),h=r(o,t.name),d=h.r||4,f=(7919*n%100/100-.5)*e*.8;Ky(l,u,o,c?t.middle+f:s(a),c?s(a):t.middle+f,d,h)}}return l},pie:Zy,donut:Zy,boxplot:function(t,e){const{scales:n,columns:o,config:i,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:l}=n,c=[],u="vertical"===l,h=!1!==i.showOutliers;for(const e of Object.values(o)){const n=e.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===n.length)continue;const o=n[0],i=n[n.length-1],l=Qy(n,.25)??o,d=Qy(n,.5)??(o+i)/2,f=Qy(n,.75)??i,p=f-l,y=l-1.5*p,g=f+1.5*p,m=n.find(t=>t>=y)??o,x=[...n].reverse().find(t=>g>=t)??i,b=s(e.pieceData[0],e.name),v=[];if(h)for(const t of e.pieceData){const n=r(t);if(y>n||n>g){const o=u?e.middle:a(n),i=u?a(n):e.middle;v.push({px:o,py:i,value:n,datum:t})}}if(c.push({type:"boxplot",x:u?e.middle:0,y:u?0:e.middle,projection:u?"vertical":"horizontal",columnWidth:.6*e.width,minPos:a(m),q1Pos:a(l),medianPos:a(d),q3Pos:a(f),maxPos:a(x),stats:{n:n.length,min:m,q1:l,median:d,q3:f,max:x,mean:n.reduce((t,e)=>t+e,0)/n.length},style:b,datum:e.pieceData,category:e.name,outliers:v}),h)for(const e of v)c.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:b.fill||t.config.themeSemantic?.secondary||"#999",opacity:.6},datum:e.datum})}return c},violin:function(t,e){const{scales:n,columns:o,config:i,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:l}=n,c=[],u="vertical"===l,h=i.bins||20,d=!1!==i.showIQR;for(const t of Object.values(o)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const n=e[0],o=e[e.length-1],i=(o-n)/h||1,l=Array(h).fill(0);for(const t of e)l[Math.min(Math.floor((t-n)/i),h-1)]++;const f=w(l,1),p=t.width/2*.9;let y;if(u){y=`M ${t.middle} ${a(n)}`;for(let e=0;h>e;e++){const o=a(n+(e+.5)*i);y+=` L ${t.middle+l[e]/f*p} ${o}`}y+=` L ${t.middle} ${a(o)}`;for(let e=h-1;e>=0;e--){const o=a(n+(e+.5)*i);y+=` L ${t.middle-l[e]/f*p} ${o}`}y+=" Z"}else{y=`M ${a(n)} ${t.middle}`;for(let e=0;h>e;e++)y+=` L ${a(n+(e+.5)*i)} ${t.middle-l[e]/f*p}`;y+=` L ${a(o)} ${t.middle}`;for(let e=h-1;e>=0;e--)y+=` L ${a(n+(e+.5)*i)} ${t.middle+l[e]/f*p}`;y+=" Z"}const g=s(t.pieceData[0],t.name);let m;if(d&&e.length>=4){const i=Qy(e,.25)??n,r=Qy(e,.5)??(n+o)/2,s=Qy(e,.75)??o;m={q1Pos:a(i),medianPos:a(r),q3Pos:a(s),centerPos:t.middle,isVertical:u}}const x=u?{x:t.x,y:Math.min(a(o),a(n)),width:t.width,height:Math.abs(a(o)-a(n))}:{x:Math.min(a(n),a(o)),y:t.x,width:Math.abs(a(o)-a(n)),height:t.width};c.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:Jy(e),style:g,datum:t.pieceData,category:t.name})}return c},histogram:function(t,e){const{scales:n,columns:o,config:i,getR:r,resolveSummaryStyle:s}=t,{r:a}=n,l=[],c=i.bins||25,u=i.normalize,h=a.domain?.(),d=h?+h[0]:void 0,f=h?+h[1]:void 0;for(const t of Object.values(o)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const[n,o]=S(e),i=null!=d&&isFinite(d)?d:n,h=null!=f&&isFinite(f)?f:o,p=(h-i)/c||1,y=Array(c).fill(0);for(const t of e)i>t||t>h||y[Math.min(Math.floor((t-i)/p),c-1)]++;const g=e.length,m=w(y,1),x=s(t.pieceData[0],t.name);for(let e=0;c>e;e++){if(0===y[e])continue;const n=(u?y[e]/g:y[e]/m)*t.width*.9,o=a(i+e*p),r=a(i+(e+1)*p);l.push(Ye(Math.min(o,r),t.x+t.width-n,Math.abs(r-o),n,x,{bin:e,count:y[e],range:[i+e*p,i+(e+1)*p],category:t.name},t.name))}}return l},ridgeline:function(t,e){const{scales:n,columns:o,config:i,getR:r,resolveSummaryStyle:s}=t,{r:a,projection:l}=n,c=[],u=i.bins||20,h="horizontal"===l,d=i.amplitude||1.5;for(const t of Object.values(o)){const e=t.pieceData.map(t=>r(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const n=e[0],o=e[e.length-1],i=(o-n)/u||1,l=Array(u).fill(0);for(const t of e)n>t||t>o||l[Math.min(Math.floor((t-n)/i),u-1)]++;const f=w(l,1),p=s(t.pieceData[0],t.name),y=t.width*d;let g;if(h){const e=t.x+t.width;g=`M ${a(n)} ${e}`;for(let t=0;u>t;t++)g+=` L ${a(n+(t+.5)*i)} ${e-l[t]/f*y}`;g+=` L ${a(o)} ${e} Z`}else{const e=t.x;g=`M ${e} ${a(n)}`;for(let t=0;u>t;t++){const o=a(n+(t+.5)*i);g+=` L ${e+l[t]/f*y} ${o}`}g+=` L ${e} ${a(o)} Z`}const m=h?{x:Math.min(a(n),a(o)),y:t.x,width:Math.abs(a(o)-a(n)),height:t.width}:{x:t.x,y:Math.min(a(o),a(n)),width:t.width,height:Math.abs(a(o)-a(n))};c.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:m,stats:Jy(e),style:{...p,fillOpacity:p.fillOpacity??.5},datum:t.pieceData,category:t.name})}return c},timeline:function(t,e){const{scales:n,columns:o,getRawRange:i,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const n=i(e);if(!n)continue;const[o,a]=n,u=r(e,t.name);if(c){const n=s(Math.min(o,a)),i=s(Math.max(o,a));l.push(Ye(n,t.x,i-n,t.width,u,e,t.name))}else{const n=s(Math.max(o,a)),i=s(Math.min(o,a));l.push(Ye(t.x,n,t.width,i-n,u,e,t.name))}}return l},funnel:function(t,e){const{columns:n,getR:o,getStack:i,resolvePieceStyle:r}=t,s=[],a=e.width/2,l=!1!==t.config.showLabels,c=t.scales.o.domain().map(t=>n[t]).filter(Boolean);if(0===c.length)return s;const u=[],h=new Set;for(const t of c)for(const e of t.pieceData){const t=i?i(e):"_default";h.has(t)||(h.add(t),u.push(t))}const d=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const t of c){const e=new Map;let n=0;for(const r of t.pieceData){const t=i?i(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const s=e.get(t),a=o(r);s.total+=a,s.pieces.push(r),n+=a}f.push({col:t,groups:e,stepTotal:n}),d||n>p&&(p=n)}if(d)for(const t of f){let e=0,n=0;for(let o=0;u.length>o;o++){const i=t.groups.get(u[o]);i&&(o%2==0?e+=i.total:n+=i.total)}const o=Math.max(e,n);o>p&&(p=o)}if(0===p)return s;const y=new Map;for(const t of u){const e=f[0].groups.get(t);y.set(t,e?.total??0)}const g=f[0].stepTotal,m=d?.95*a:.9*e.width,x=tg().domain([0,p]).range([0,m]),b=t.config.connectorOpacity??.3;let v=new Map;for(let e=0;f.length>e;e++){const n=f[e],o=n.col,i=0===e,c=o.width,h=.55*c,p=o.x+(c-h)/2,m=new Map;if(d){let t=0;for(const e of u){const o=n.groups.get(e);o&&(t+=x(o.total))}let e=a,c=a;for(let d=0;u.length>d;d++){const f=u[d],g=n.groups.get(f);if(!g)continue;const b=x(g.total),v=d%2==0,w=v?e:c-b;v?e+=b:c-=b;const k=r(g.pieces[0],f),S=y.get(f)??g.total,A={...g.pieces[0],__funnelValue:g.total,__funnelPercent:S>0?g.total/S*100:0,__funnelStep:o.name,__funnelIsFirstStep:i,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};l&&(0===d&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=p,A.__funnelRowWidth=t),A.__funnelValueLabelX=w+b/2,A.__funnelValueLabelY=p,A.__funnelBarW=b),s.push(Ye(w,p,b,h,k,A,f)),m.set(f,{x:w,y:p,w:b,h:h})}}else{const t=n.stepTotal,e=x(t),c=a-e/2,d=u[0],f="_default"!==d,y=n.groups.get(d)?.pieces[0]??o.pieceData[0],b=f?d:o.name,v=r(y,b),w=g>0?t/g*100:0,k={...y,__funnelValue:t,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:i,category:f?d:o.name};l&&(k.__funnelStepLabel=o.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=e,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=e),s.push(Ye(c,p,e,h,v,k,b)),m.set(d,{x:c,y:p,w:e,h:h})}if(e>0&&v.size>0){const e=d?u:[u[0]];for(const i of e){const e=v.get(i),a=m.get(i);if(!e||!a)continue;const l=(()=>{const t=n.groups.get(i);return r(t?t.pieces[0]:o.pieceData[0],"_default"===i?o.name:i)})(),c={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:l.fill||t.config.themeSemantic?.secondary||"#999",opacity:b},datum:n.groups.get(i)?.pieces[0]??o.pieceData[0],category:"_default"===i?o.name:i};s.push(c)}}v=m}return s},"bar-funnel":function(t,e){const{columns:n,getR:o,getStack:i,resolvePieceStyle:r,scales:s}=t,a=[],l=s.o.domain().map(t=>n[t]).filter(Boolean);if(0===l.length)return a;const c=[],u=new Set;for(const t of l)for(const e of t.pieceData){const t=i?i(e):"_default";u.has(t)||(u.add(t),c.push(t))}const h=c.length>1&&"_default"!==c[0],d=[];for(const t of l){const e=new Map;let n=0;for(const r of t.pieceData){const t=i?i(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const s=e.get(t),a=o(r);s.total+=a,s.pieces.push(r),n+=a}d.push({col:t,groups:e,stepTotal:n})}const f=new Map;for(const t of c){const e=d[0]?.groups.get(t);f.set(t,e?.total??0)}const p=s.r,y=h?c.length:1,g=h?.15:0;for(let t=0;d.length>t;t++){const e=d[t],n=e.col,o=0===t,i=t>0?d[t-1]:null,s=n.width/y,l=s*g,u=s-l;for(let t=0;c.length>t;t++){const d=c[t],y=e.groups.get(d);if(!y)continue;const g=y.total,m=f.get(d)??g,x=m>0?g/m*100:0,b=i?.groups.get(d),v=o?0:Math.max(0,(b?.total??g)-g),w=n.x+t*s+l/2,k=p(g),S=p(0)-k,A=r(y.pieces[0],h?d:n.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:n.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(Ye(w,k,u,S,A,M,h?d:n.name)),v>0){const t=p(g+v),e=k-t,o={...A},i={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:n.name};a.push(Ye(w,t,u,e,o,i,h?d:n.name))}}}return a},swimlane:function(t,e){const{scales:n,columns:o,getR:i,getStack:r,resolvePieceStyle:s}=t,{r:a,projection:l}=n,c=[],u="horizontal"===l,h=t.config.gradientFill,d=u?"left":"bottom",f=t.config.trackFill;if(f){const t="string"==typeof f?f:f.color,e="string"==typeof f?1:f.opacity??1,[n,i]=a.range(),r=Math.min(n,i),s=Math.abs(i-n);for(const n of Object.values(o)){const o={fill:t,opacity:e},i=u?Ye(r,n.x,s,n.width,o,null,"__track__"):Ye(n.x,r,n.width,s,o,null,"__track__");c.push(i)}}const p=t.config.roundedTop&&t.config.roundedTop>0?Math.max(0,t.config.roundedTop):0;for(const t of Object.values(o)){let e=0;const n=c.length;for(const n of t.pieceData){const o=Math.abs(i(n));if(0===o)continue;const l=r?r(n):t.name,f=s(n,l);let p;if(u){const i=a(e),r=a(e+o);p=Ye(i,t.x,r-i,t.width,f,n,l)}else{const i=a(e+o),r=a(e);p=Ye(t.x,i,t.width,r-i,f,n,l)}h&&(p.fillGradient=h,p.roundedEdge=d),c.push(p),e+=o}if(p>0&&c.length>n){const t=c.slice(n),e=t[0],o=t[t.length-1];1===t.length?e.cornerRadii={tl:p,tr:p,br:p,bl:p}:u?(e.cornerRadii={tl:p,bl:p},o.cornerRadii={tr:p,br:p}):(e.cornerRadii={bl:p,br:p},o.cornerRadii={tl:p,tr:p})}}return c}},ng=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],og=["scene-style","data-paint","accessibility","evidence"],ig=(t,e)=>({retainedData:t,invalidations:e}),rg=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],sg=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ag=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],lg=["scene-geometry","data-paint","accessibility","evidence"],cg=["scene-style","data-paint","accessibility","evidence"],ug=[],hg={chartType:ig("rebuild",rg),runtimeMode:ig("rebuild",rg),categoryAccessor:ig("rebuild",rg),valueAccessor:ig("rebuild",rg),oAccessor:ig("rebuild",rg),rAccessor:ig("rebuild",rg),stackBy:ig("rebuild",rg),groupBy:ig("rebuild",rg),timeAccessor:ig("rebuild",rg),accessorRevision:ig("rebuild",rg),colorAccessor:ig("rebuild",cg),symbolAccessor:ig("rebuild",lg),connectorAccessor:ig("rebuild",lg),dataIdAccessor:ig("rebuild",lg),projection:ig("preserve",sg),extentPadding:ig("preserve",sg),axisExtent:ig("preserve",sg),rExtent:ig("preserve",sg),oExtent:ig("preserve",sg),multiAxis:ig("preserve",sg),normalize:ig("preserve",sg),bins:ig("preserve",sg),oSort:ig("preserve",ag),barPadding:ig("preserve",ag),roundedTop:ig("preserve",ag),baselinePadding:ig("preserve",ag),innerRadius:ig("preserve",ag),cornerRadius:ig("preserve",ag),startAngle:ig("preserve",ag),sweepAngle:ig("preserve",ag),trackFill:ig("preserve",ag),showOutliers:ig("preserve",ag),showIQR:ig("preserve",ag),amplitude:ig("preserve",ag),connectorOpacity:ig("preserve",ag),showLabels:ig("preserve",ag),dynamicColumnWidth:ig("rebuild",ag),customLayout:ig("preserve",ag),layoutConfig:ig("preserve",ag),layoutMargin:ig("preserve",ag),symbolMap:ig("preserve",lg),pieceStyle:ig("preserve",cg),summaryStyle:ig("preserve",cg),connectorStyle:ig("preserve",cg),gradientFill:ig("preserve",cg),colorScheme:ig("preserve",cg),themeCategorical:ig("preserve",cg),themeSemantic:ig("preserve",cg),themeSequential:ig("preserve",cg),themeDiverging:ig("preserve",cg),barColors:ig("preserve",cg),decay:ig("preserve",cg),pulse:ig("preserve",cg),staleness:ig("preserve",cg),layoutSelection:ig("preserve",cg),windowSize:ig("preserve",ug),windowMode:ig("preserve",ug),clock:ig("preserve",ug),transition:ig("preserve",ug),introAnimation:ig("preserve",ug),onLayoutError:ig("preserve",ug)},dg=ig("preserve",ag),fg=class{constructor(){this.tracker=new Gn}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},ng)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},og):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const n=new Set;for(const o of t){const t=hg[o]??dg;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)n.add(e)}return{retainedData:e,invalidations:n}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}};import{quadtree as pg}from"d3-quadtree";var yg=class{constructor(t){this.rExtent=new Se,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new fg,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new Vy,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new ke(t.windowSize),this.getO=f(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>u(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new Se)):(this.getR=u(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=f(t.stackBy),this.getGroup=f(t.groupBy),this.getColor=f(t.colorAccessor),this.getSymbol=f(t.symbolAccessor),this.getConnector=f(t.connectorAccessor),this.getDataId=f(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new ke(t.windowSize))}syncPulseTimestampBuffer(){var t,e,n,o;this.timestampBuffer=(t=!!this.config.pulse,e=this.buffer,n=this.timestampBuffer,o=this.currentTime(),t?null!=n&&n.capacity===e.capacity&&n.size===e.size?n:Ln(e,o):null)}currentTime(){return this.config.clock?.()??Re()}ingest(t){const e=this.currentTime();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),Tn(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const n of t.inserts)Rn(this.buffer,n,this.timestampBuffer,e),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of t.inserts){const t=Rn(this.buffer,n,this.timestampBuffer,e);this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=t&&this.evictValueExtent(t)}}return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.valueAccessor||this.config.rAccessor;if(!e)return null;const n="function"==typeof e?e(t):t[e];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(t){const{config:e,buffer:n}=this,o=this.scales,i=this.multiScales,r=this.columns;if(0===n.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const s=this.getBufferArray(),a=e.projection||"vertical",l=e.oExtent||this.resolveCategories(s),c=this.computeValueDomain(s,l),u="horizontal"===a,h="radial"===a,d=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===a?t.width:t.height):.1));let f,p;if(h){f=Xy().domain(l).range([0,1]).padding(0);const n=Math.min(t.width,t.height)/2,o=e.innerRadius||0;p=Hy().domain(c).range([o,n])}else u?(f=Xy().domain(l).range([0,t.height]).padding(d),p=Hy().domain(c).range([0,t.width])):(f=Xy().domain(l).range([0,t.width]).padding(d),p=Hy().domain(c).range([t.height,0]));this.scales={o:f,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((o,i)=>{const r=this.rExtents[i];r.dirty&&r.recalculate(n,o);let[s,a]=r.extent;s===1/0&&(s=0,a=1);const l=a-s,c=l>0?l*(e.extentPadding??.05):1;return s-=c,a+=c,s>0&&(s=0),u?Hy().domain([s,a]).range([0,t.width]):Hy().domain([s,a]).range([t.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(t=>this.rAccessors.map((e,n)=>({...t,__rIndex:n,__rValue:e(t),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(y,l,f,a,t),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,t);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.multiScales=i,this.columns=r):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=g,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,s),this.config.pulse&&this.applyPulse(this.scene,s),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++)}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,n=Array.isArray(e)?e[t]:e;return"string"==typeof n?n:"value"+t}resolveCategories(t){const e=this.config.oSort,n="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let i=null;if(n){i=new Set;for(const e of t)i.add(this.getO(e))}const r=i?Array.from(this.categories).filter(t=>i.has(t)):Array.from(this.categories);if(n&&void 0===o){const t=Math.max(50,3*i.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;i.has(t)||(this.categories.delete(t),e--)}}return r}if(!1===o)return r;if("function"==typeof o)return r.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return r.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){return function(t){const{data:e,chartType:n,projection:o,normalize:i,rExtent:r,extentPadding:s=.05,baselinePadding:a,axisExtent:l,getO:c,getR:u,getStack:h,rawRExtent:d}=t,f=s;if("radial"===o&&("pie"===n||"donut"===n))return[0,1];let p=0,y=0;if("bar"===n&&h&&i)p=0,y=1;else if("bar"===n&&h){const t=new Map,n=new Map;for(const o of e){const e=c(o),i=u(o);0>i?n.set(e,(n.get(e)||0)+i):t.set(e,(t.get(e)||0)+i)}for(const e of t.values())e>y&&(y=e);for(const t of n.values())p>t&&(p=t)}else if("bar"===n){const t=new Map;for(const n of e){const e=c(n),o=u(n);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>y&&(y=e),p>e&&(p=e)}else if("swimlane"===n){const t=new Map;for(const n of e){const e=c(n),o=Math.abs(u(n));t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>y&&(y=e)}else if("clusterbar"===n||"bar-funnel"===n)for(const t of e){const e=u(t);e>y&&(y=e),p>e&&(p=e)}else{const t=d[0],e=d[1];t!==1/0&&(p=t),e!==-1/0&&(y=e)}r&&(null!=r[0]&&(p=r[0]),null!=r[1]&&(y=r[1]));const g="bar"===n||"clusterbar"===n||"bar-funnel"===n||"swimlane"===n;if(g&&null==r?.[0]&&null==r?.[1]&&(p>0&&(p=0),0>y&&(y=0)),"bar-funnel"!==n&&"exact"!==l){const t=y-p,e=t>0?t*f:1,o=g&&!a&&0===p,i=g&&!a&&0===y||"swimlane"===n;null!=r?.[0]||o||(p-=e),null!=r?.[1]||i||(y+=e)}return[p,y]}({data:t,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(t,e,n,o,i){return function(t){const{data:e,oExtent:n,oScale:o,projection:i,layout:r,dynamicColumnWidth:s,getO:a,getR:l}=t,c={},u=new Map;for(const t of e){const e=a(t);u.has(e)||u.set(e,[]),u.get(e).push(t)}let h=0;if("radial"===i)for(const t of e)h+=Math.abs(l(t));let d=null;if(s&&"radial"!==i){d=new Map;let t=0;for(const e of n){const n=u.get(e)||[];let o;o="string"==typeof s?n.reduce((t,e)=>t+(Number(e[s])||0),0):s(n),d.set(e,o),t+=o}const e=("horizontal"===i?r.height:r.width)-o.padding()*o.step()*n.length;if(t>0)for(const[n,o]of d)d.set(n,o/t*e)}let f=0,p=0;for(const t of n){const e=u.get(t)||[],n=e.reduce((t,e)=>t+Math.abs(l(e)),0),i=h>0?n/h:0;let r,s;d?(r=p,s=d.get(t)||o.bandwidth(),p+=s+o.padding()*o.step()):(r=o(t)??0,s=o.bandwidth()),c[t]={name:t,x:r,y:0,width:s,middle:r+s/2,padding:o.padding()*o.step(),pieceData:e,pct:i,pctStart:f},f+=i}return c}({data:t,oExtent:e,oScale:n,projection:o,layout:i,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.styleResolver.resolvePieceStyle(this.config,t,e),resolveSummaryStyle:(t,e)=>this.styleResolver.resolveSummaryStyle(this.config,t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];if(this.config.customLayout){const n=this.buildLayoutContext(t,e);let o;try{o=this.config.customLayout(n)}catch(t){const e=null!==this.lastCustomLayoutResult,n=vn("ordinal",t,e,this.version);this.lastCustomLayoutFailure=n,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t);try{this.config.onLayoutError?.(n)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;const i=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of i)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(i,this.config.layoutSelection??null)}return mn({label:"ordinal customLayout",nodes:i,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),i}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const n=this.getSceneContext(),o=eg[this.config.chartType];let i=o?o(n,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:n,config:o,getConnector:i,getO:r}=t;if(!i||!n)return[];const s=[],{projection:a}=n,l=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const n=i(e);if(!n)continue;let o,s;"point"===t.type?(o=t.x,s=t.y):(o=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),l.has(n)||l.set(n,[]),l.get(n).push({x:o,y:s,datum:e,category:r(e)})}const c=n.o.domain(),u=o.connectorStyle;for(const[e,n]of l)if(n.length>=2){n.sort((t,e)=>c.indexOf(t.category)-c.indexOf(e.category));for(let o=0;n.length-1>o;o++){const i=n[o],r=n[o+1],a="function"==typeof u?u(i.datum):u||{stroke:t.config.themeSemantic?.border||t.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:i.x,y1:i.y,x2:r.x,y2:r.y,style:a,datum:i.datum,group:e})}}return s}(n,i);i=[...t,...i]}return i}buildLayoutContext(t,e){const n=this.config,o=n.layoutMargin??{top:0,right:0,bottom:0,left:0},i=Np(n.colorScheme,n.themeCategorical,kt),r=this.scales;return{data:t,scales:{o:r.o,r:r.r,projection:r.projection},dimensions:{width:e.width,height:e.height,margin:o,plot:"radial"===r.projection?{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height}:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:n.themeSemantic??{},categorical:[...i]},resolveColor:Wp(i,n.colorScheme),config:n.layoutConfig??{},selection:n.layoutSelection??null}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?$e(n,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=ze(t);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=function(t,e){const n="function"==typeof e,o=n?null:e||"category",i=new Map;for(let r=0;t.length>r;r++){const s=t[r],a=n?e(s):s[o],l=i.get(a);l?l.push(r):i.set(a,[r])}return i}(t,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:e},e}rebuildPointQuadtree(){const t=function(t){let e=0,n=0;for(const o of t)"point"===o.type&&(e++,o.r>n&&(n=o.r));if(500>=e)return{quadtree:null,maxRadius:n};const o=Array(e);let i=0;for(const e of t)"point"===e.type&&(o[i++]=e);return{maxRadius:n,quadtree:pg().x(t=>t.x).y(t=>t.y).addAll(o)}}(this.scene);this._pointQuadtree=t.quadtree,this._maxPointRadius=t.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){if(!this.config.decay)return;const n=e.length;if(1>=n)return;const o=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;if(!e.datum)continue;const t=o.get(e.datum);if(null==t)continue;const i=this.computeDecayOpacity(t,n);e.style={...e.style,opacity:(e.style?.opacity??1)*i}}}applyPulse(t,e,n=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,n,o,i,r){const s=t.color??"rgba(255,255,255,0.6)",a=t.glowRadius??4;let l=!1;for(const c of e){if("connector"===c.type||"violin"===c.type||"boxplot"===c.type)continue;if("wedge"===c.type){const e=c.category;if(!e)continue;let o=0;for(const s of i(e)??[]){const e=n.get(s);null!=e&&(o=Math.max(o,De(t,e,r)))}l=Ie(c,o,s)||l;continue}if(null==c.datum)continue;const e=o.get(c.datum);if(null==e)continue;const u=n.get(e);l=Ie(c,null==u?0:De(t,u,r),s,a)||l}return l}(this.config.pulse,t,this.timestampBuffer,this.getDatumIndexMap(e),t=>this.getCategoryIndexMap(e).get(t),n)}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&Be(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();const t=new Map,e=this.scales?.r(0)??0,n="horizontal"!==this.scales?.projection;let o;for(let i=0;this.scene.length>i;i++){const r=this.scene[i],s=this.getNodeKey(r,t);s&&("rect"===r.type?this.prevPositionMap.set(s,n?{x:r.x,y:e,w:r.w,h:0,opacity:r.style.opacity??1}:{x:e,y:r.y,w:0,h:r.h,opacity:r.style.opacity??1}):"point"===r.type?this.prevPositionMap.set(s,{x:r.x,y:r.y,r:0,opacity:0}):"wedge"===r.type&&(void 0===o&&(o=r.startAngle),this.prevPositionMap.set(s,{x:r.cx,y:r.cy,startAngle:o,endAngle:o,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0})))}}getNodeKey(t,e){if("point"===t.type){const n=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(n)||0;return e.set(n,o+1),`${n}:${o}`}return"rect"===t.type?`r:${t.group||""}:${t.datum?.category??""}`:"wedge"===t.type?"w:"+(t.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const t=new Map;for(let e=0;this.scene.length>e;e++){const n=this.scene[e],o=this.getNodeKey(n,t);o&&("point"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"wedge"===n.type&&this.prevPositionMap.set(o,{x:n.cx,y:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:n.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const t=this.config.transition.duration??300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let e=!1;const n=new Set,o=new Map;for(let t=0;this.scene.length>t;t++){const i=this.scene[t],r=this.getNodeKey(i,o);if(!r)continue;i._transitionKey=r;const s=this.prevPositionMap.get(r);if("point"===i.type)s?(n.add(r),i._targetOpacity=i.style.opacity??1,(s.x!==i.x||s.y!==i.y||void 0!==s.r&&s.r!==i.r)&&(i._targetX=i.x,i._targetY=i.y,i._targetR=i.r,i.x=s.x,i.y=s.y,void 0!==s.r&&(i.r=s.r),e=!0)):(i._targetOpacity=i.style.opacity??1,i._targetR=i.r,i.r=0,i.style={...i.style,opacity:0},e=!0);else if("rect"===i.type)s?(n.add(r),i._targetOpacity=i.style.opacity??1,s.x===i.x&&s.y===i.y&&s.w===i.w&&s.h===i.h||(i._targetX=i.x,i._targetY=i.y,i._targetW=i.w,i._targetH=i.h,i.x=s.x,i.y=s.y,i.w=s.w??i.w,i.h=s.h??i.h,e=!0)):(i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},e=!0);else if("wedge"===i.type)if(s)n.add(r),i._targetOpacity=i.style.opacity??1,s.startAngle===i.startAngle&&s.endAngle===i.endAngle||(i._targetStartAngle=i.startAngle,i._targetEndAngle=i.endAngle,i.startAngle=s.startAngle,i.endAngle=s.endAngle,e=!0);else{i._targetOpacity=i.style.opacity??1,i._targetStartAngle=i.startAngle,i._targetEndAngle=i.endAngle;const t=i.startAngle;i.startAngle=t,i.endAngle=t,i.style={...i.style,opacity:0},this.prevPositionMap.set(r,{x:i.cx,y:i.cy,startAngle:t,endAngle:t,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:0}),e=!0}}this.exitNodes=[];for(const[t,o]of this.prevPositionMap)if(!n.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:o.x,y:o.y,r:o.r??3,style:{opacity:o.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:o.x,y:o.y,w:o.w??0,h:o.h??0,style:{opacity:o.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const e=((o.startAngle??0)+(o.endAngle??0))/2,n={type:"wedge",cx:o.x,cy:o.y,innerRadius:o.innerRadius??0,outerRadius:o.outerRadius??100,startAngle:o.startAngle??0,endAngle:o.endAngle??0,style:{opacity:o.opacity??1},datum:null,category:t.slice(2),_targetStartAngle:e,_targetEndAngle:e,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(n)}e=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),e&&(this.activeTransition={startTime:this.currentTime(),duration:t})}advanceTransition(t){if(!this.activeTransition)return!1;const e=Te(t,this.activeTransition),n=Ce(e,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style.opacity=Le(o?o.opacity??1:0,t._targetOpacity,n)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=Le(o.x,t._targetX,n),t.y=Le(o.y,t._targetY,n)),void 0!==t._targetR&&void 0!==o?.r&&(t.r=Le(o.r,t._targetR,n))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style.opacity=Le(o?o.opacity??1:0,t._targetOpacity,n)}if(void 0===t._targetX)continue;const o=this.prevPositionMap.get(e);if(!o)continue;t.x=Le(o.x,t._targetX,n),t.y=Le(o.y,t._targetY,n),void 0!==o.w&&(t.w=Le(o.w,t._targetW,n),t.h=Le(o.h,t._targetH,n))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style={...t.style,opacity:Le(o?o.opacity??1:0,t._targetOpacity,n)}}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const o=this.prevPositionMap.get(e);o&&void 0!==o.startAngle&&(t.startAngle=Le(o.startAngle,t._targetStartAngle,n),t.endAngle=Le(o.endAngle,t._targetEndAngle,n))}}}if(e>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style={...t.style||{},opacity:0===t._targetOpacity?0:t._targetOpacity},t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX&&void 0===t._targetR)continue;void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY),void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0);if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=Pe(t),n=this.getDataId,o=t=>e.has(n(t));$n(this.buffer,this.timestampBuffer,o);const i=this.buffer.remove(o);if(0===i.length)return this.updateResults.recordNoop("remove"),i;for(const t of i)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",i.length),i}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=Pe(t),o=this.getDataId,i=new Set;this.buffer.forEach((t,e)=>{n.has(o(t))&&i.add(e)});const r=this.buffer.update(t=>n.has(o(t)),e);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),i.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),r}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(t,e){const n=this._customRestyle;if(n)for(const o of t){const t=this._baseStyles.get(o)??o.style??{},i=n(o,e);o.style=i?{...t,...i}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();this._categoryIndexCache=null,this.buffer.forEach(t=>{this.categories.add(this.getO(t)),this.pushValueExtent(t)})}updateConfig(e){const n={...this.config},o=Object.keys(e).filter(t=>e[t]!==n[t]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==n.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${n.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e&&e.colorScheme!==n.colorScheme||"themeCategorical"in e&&e.themeCategorical!==n.themeCategorical||"colorAccessor"in e&&!t(e.colorAccessor,n.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!t(e.categoryAccessor,n.categoryAccessor)||"oAccessor"in e&&!t(e.oAccessor,n.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let i=!1;("categoryAccessor"in e||"oAccessor"in e)&&(t(this.config.categoryAccessor||this.config.oAccessor,n.categoryAccessor||n.oAccessor)||(this.getO=f(this.config.categoryAccessor||this.config.oAccessor,"category"),i=!0));let r=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,o=n.valueAccessor||n.rAccessor,i=Array.isArray(e)?e:[e],s=Array.isArray(o)?o:[o];if(r=i.length!==s.length||i.some((e,n)=>!t(e,s[n])),r){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>u(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new Se)):(this.getR=u(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!t(e.stackBy,n.stackBy)&&(this.getStack=null!=this.config.stackBy?f(this.config.stackBy):void 0),"groupBy"in e&&!t(e.groupBy,n.groupBy)&&(this.getGroup=null!=this.config.groupBy?f(this.config.groupBy):void 0),"colorAccessor"in e&&!t(e.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?f(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!t(e.symbolAccessor,n.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?f(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!t(e.connectorAccessor,n.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?f(this.config.connectorAccessor):void 0),(i||r||"accessorRevision"in e&&e.accessorRevision!==n.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(o)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};Nn(yg);import{jsx as gg,jsxs as mg}from"react/jsx-runtime";import{Fragment as xg,jsx as bg,jsxs as vg}from"react/jsx-runtime";function wg(t,e){const n=D(t.theme),o=t.size||[500,400],i=Rs({top:20,right:20,bottom:30,left:40,...t.margin},t.title),r=Ts(t.title),s=q(t.data),a=t.showLegend?xy(s,t.colorAccessor||t.stackBy||t.groupBy):[];Fy(i,{props:t,categories:a,theme:n,size:o,hasTitle:r});const l=o[0]-i.left-i.right,c=o[1]-i.top-i.bottom,u=t.projection||"vertical",h="radial"===u,d={chartType:t.chartType,windowSize:t.windowSize??1e4,windowMode:t.windowMode??"sliding",extentPadding:t.extentPadding??.05,projection:u,oAccessor:t.oAccessor,rAccessor:t.rAccessor,colorAccessor:t.colorAccessor,stackBy:t.stackBy,groupBy:t.groupBy,categoryAccessor:t.categoryAccessor,valueAccessor:t.valueAccessor,timeAccessor:t.timeAccessor,rExtent:t.rExtent,oExtent:t.oExtent,axisExtent:t.axisExtent,barPadding:t.barPadding,roundedTop:t.roundedTop,innerRadius:t.innerRadius,cornerRadius:t.cornerRadius,normalize:t.normalize,startAngle:t.startAngle,sweepAngle:t.sweepAngle,bins:t.bins,showOutliers:t.showOutliers,showIQR:t.showIQR,amplitude:t.amplitude,oSort:t.oSort,connectorAccessor:t.connectorAccessor,connectorStyle:t.connectorStyle,dynamicColumnWidth:t.dynamicColumnWidth,pieceStyle:t.pieceStyle,summaryStyle:t.summaryStyle,gradientFill:t.gradientFill,symbolAccessor:t.symbolAccessor,symbolMap:t.symbolMap,multiAxis:t.multiAxis,baselinePadding:t.baselinePadding,trackFill:t.trackFill,connectorOpacity:t.connectorOpacity,showLabels:t.showLabels,colorScheme:t.colorScheme||n.colors.categorical,themeCategorical:n.colors.categorical,themeSemantic:A(n),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:i,layoutSelection:t.layoutSelection,barColors:t.barColors},f=new yg(d);if(t.data&&f.ingest({inserts:s,bounded:!0}),f.computeScene({width:l,height:c}),!f.scales||0===f.scene.length)return e&&(e.evidence=ry({frameType:"ordinal",width:o[0],height:o[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),qy.renderToStaticMarkup(Ny(null,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${i.left},${i.top})`,innerWidth:l,innerHeight:c,idPrefix:t._idPrefix}));const p=t._idPrefix,y=t.showGrid?function(t,e,n,o,i){const r=t.scales;if(!r||"radial"===r.projection)return null;const{grid:s}=I(n),a=o?o+"-":"",l="vertical"===r.projection,c=Ss(r.r,5,i);return Ty("g",l?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((t,n)=>{const o=r.r(t);return Ty("line",{x1:0,y1:o,x2:e.width,y2:o,stroke:s,strokeWidth:.5},"gr-"+n)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((t,n)=>{const o=r.r(t);return Ty("line",{x1:o,y1:0,x2:o,y2:e.height,stroke:s,strokeWidth:.5},"gr-"+n)})})}(f,{width:l,height:c},n,p,t.axisExtent):null;let g=null;if(f.scene.some(t=>"rect"===t.type&&t.datum?.__barFunnelIsDropoff)){const e=$y(t),o=new Set;for(const t of f.scene)"rect"===t.type&&t.datum?.__barFunnelIsDropoff&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");g=Array.from(o).map((t,o)=>function(t){const{id:e,background:n="transparent",stroke:o="#000",lineWidth:i=1.5,spacing:r=6,angle:s=45}=t,a=Math.max(8,Math.ceil(2*r));return mg("pattern",{id:e,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&gg("rect",{width:a,height:a,fill:n}),gg("line",{x1:0,y1:0,x2:0,y2:a,stroke:o,strokeWidth:i}),gg("line",{x1:r,y1:0,x2:r,y2:a,stroke:o,strokeWidth:i})]},e)}({id:`funnel-hatch-${e}-${o}`,background:t,stroke:"transparent"===n.colors.background?"#fff":n.colors.background,lineWidth:1.5,spacing:5,angle:45}));const i=new Map;Array.from(o).forEach((t,n)=>i.set(t,`funnel-hatch-${e}-${n}`));for(const t of f.scene)"rect"===t.type&&t.datum?.__barFunnelIsDropoff&&(t.style={...t.style,fill:`url(#${i.get("string"==typeof t.style.fill?t.style.fill:"#666")})`})}const m=Sc({nodes:f.scene,renderMode:t.renderMode,fallback:(t,e)=>fa(t,e,p)}),x=m.map(t=>t.element);if(e){const n=f.scales.o?.domain?.();e.evidence=ry({frameType:"ordinal",width:o[0],height:o[1],marks:m.map(t=>t.node),title:t.title,description:t.description,annotations:t.annotations,yDomain:iy(f.scales.r?.domain?.()),categories:Array.isArray(n)?n.map(String):void 0})}const b=!1!==t.showAxes?function(t,e,n,o,i){const r=t.scales;if(!r)return null;if("radial"===r.projection)return null;const s=I(o),a="vertical"===r.projection,l=n.categoryFormat||n.oFormat,c=n.valueFormat||n.rFormat,u=n.categoryLabel||n.oLabel,h=n.valueLabel||n.rLabel,d=Object.values(t.columns).map(t=>({pixel:t.middle,label:(l||String)(t.name)})),f=Ss(r.r,5,n.axisExtent).map(t=>({pixel:r.r(t),label:(c||Oy)(t)}));return vg("g",a?{id:(i?i+"-":"")+"axes",className:"ordinal-axes",children:[bg("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:s.border,strokeWidth:1}),d.map((t,n)=>vg("g",{transform:`translate(${t.pixel},${e.height})`,children:[bg("line",{y2:5,stroke:s.border,strokeWidth:1}),bg("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oxtick-"+n)),u&&bg("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:u}),bg("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:s.border,strokeWidth:1}),f.map((t,e)=>vg("g",{transform:`translate(0,${t.pixel})`,children:[bg("line",{x2:-5,stroke:s.border,strokeWidth:1}),bg("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oytick-"+e)),h&&bg("text",{x:15-(n.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${e.height/2})`,children:h})]}:{id:(i?i+"-":"")+"axes",className:"ordinal-axes",children:[bg("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:s.border,strokeWidth:1}),f.map((t,n)=>vg("g",{transform:`translate(${t.pixel},${e.height})`,children:[bg("line",{y2:5,stroke:s.border,strokeWidth:1}),bg("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oxtick-"+n)),h&&bg("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:h}),bg("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:s.border,strokeWidth:1}),d.map((t,e)=>vg("g",{transform:`translate(0,${t.pixel})`,children:[bg("line",{x2:-5,stroke:s.border,strokeWidth:1}),bg("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oytick-"+e)),u&&bg("text",{x:15-(n.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${e.height/2})`,children:u})]})}(f,{width:l,height:c},t,n,p):null,v=t.annotations?_y({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{o:f.scales.o,r:f.scales.r,y:"vertical"===f.scales.projection?f.scales.r:void 0},layout:{width:l,height:c},theme:n,projection:u,idPrefix:p}):null,w=Ey({props:t,categories:a,theme:n,size:o,margin:i,hasTitle:r}),k=h?i.left+l/2:i.left,S=h?i.top+c/2:i.top,M=h&&t.centerContent?bg("foreignObject",{x:i.left,y:i.top,width:l,height:c,pointerEvents:"none",children:bg("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:t.centerContent})}):null;return qy.renderToStaticMarkup(Ny(vg(xg,{children:[t.backgroundGraphics,y,x,b,v,t.foregroundGraphics,f.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${k},${S})`,innerWidth:l,innerHeight:c,legend:w,defs:g,outerElements:M,idPrefix:t._idPrefix}))}import*as kg from"react-dom/server";function Sg(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function Ag(t,e){var n,o=[],i=[],r=[],s={},a=[];function l(t){r[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],r[e]&&l(e)})}function c(t){var e,o,h=!1;for(i.push(t),r[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===n?(u(n,i),h=!0):r[o]||(h=c(o));if(h)l(t);else for(e=0;a[t].length>e;e++){var d=s[o=a[t][e]];d||(s[o]=d={}),d[o]=!0}return i.pop(),h}function u(t,n){var i=[].concat(n).concat(t);e?e(i):o.push(i)}function h(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,o=function(t){for(var e=t.length,n=Array(e),o=Array(e),i=Array(e),r=Array(e),s=Array(e),a=Array(e),l=0;e>l;++l)n[l]=-1,o[l]=0,i[l]=!1,r[l]=0,s[l]=-1,a[l]=[];var c,u=0,h=[],d=[];function f(e){var l=[e],c=[e];for(n[e]=o[e]=u,i[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>r[e]){for(var p=r[e];f.length>p;++p){var y=f[p];if(0>n[y]){n[y]=o[y]=u,i[y]=!0,u+=1,l.push(y),c.push(y);break}i[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}r[e]=p}else{if(o[e]===n[e]){var g=[],m=[],x=0;for(p=l.length-1;p>=0;--p){var b=l[p];if(i[b]=!1,g.push(b),m.push(a[b]),x+=a[b].length,s[b]=h.length,b===e){l.length=p;break}}h.push(g);var v=Array(x);for(p=0;m.length>p;p++)for(var w=0;m[p].length>w;w++)v[--x]=m[p][w];d.push(v)}c.pop()}}}for(l=0;e>l;++l)0>n[l]&&f(l);for(l=0;d.length>l;l++){var p=d[l];if(0!==p.length){p.sort(function(t,e){return t-e}),c=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&c.push(p[y]);d[l]=c}}return{components:h,adjacencyList:d}}(t),i=o.components.filter(function(t){return t.length>1}),r=1/0,s=0;i.length>s;s++)for(var a=0;i[s].length>a;a++)r>i[s][a]&&(r=i[s][a],n=s);var l=i[n];return!!l&&{leastVertex:r,adjList:t.map(function(t,e){return-1===l.indexOf(e)?[]:t.filter(function(t){return-1!==l.indexOf(t)})})}}n=0;for(var d=t.length;d>n;){var f=h(n);if(n=f.leastVertex,a=f.adjList){for(var p=0;a.length>p;p++)for(var y=0;a[p].length>y;y++){var g=a[p][y];r[+g]=!1,s[g]={}}c(n),n+=1}else n=d}return e?void 0:o}function Mg(t){return t.y0-t.y1>0?"up":"down"}function _g(t,e){return e(t.source)==e(t.target)}function Pg(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function Cg(t){return t.target.x0-t.source.x1}function Tg(t,e){var n=Rg(t),o=Cg(e)/Math.tan(n);return"up"==Mg(t)?t.y1-o:t.y1+o}function Lg(t,e){var n=Rg(t),o=Cg(e)/Math.tan(n);return"up"==Mg(t)?t.y1+o:t.y1-o}function Rg(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function $g(t,e){return e(t)}function zg(t){return Ig(t.source)}function Dg(t){return Ig(t.target)}function Ig(t){return(t.y0+t.y1)/2}function Bg(t){return t.virtual?0:t.value}function Fg(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!_g(t,e)?n+1:n});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!_g(t,e)?o+1:o}),n+o}function Eg(t){return t.target.depth}function Og(t,e){return t.sourceLinks.length?t.depth:e-1}function Ng(t,e){return t.y0-e.y0}function Wg(t,e){return e.y0-t.y0}function jg(t,e){return t.y1-e.y1}function Yg(t,e){return e.y1-t.y1}function Gg(t,e){return Xg(t.source,e.source)||t.index-e.index}function qg(t,e){return Xg(t.target,e.target)||t.index-e.index}function Xg(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Hg(t,e){return Vg(t)==Vg(e)?"bottom"==t.circularLinkType?Wg(t,e):Ng(t,e):Vg(e)-Vg(t)}function Vg(t){return t.target.column-t.source.column}function Ug(t,e){return Kg(t)==Kg(e)}function Kg(t){return t.y0-t.y1>0?"up":"down"}import{min as Zg}from"d3-array";function Qg(t,e,n,o,i){let r=t;var s=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=Zg(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=r.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),Jg(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),Jg(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+o,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,_g(t,e)&&Pg(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+i+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,l=t.circularLinkType,c=r.links.filter(function(t){return t.source.column==s&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?Wg:Ng);var u=0;c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),s=t.target.column,(c=r.links.filter(function(t){return t.target.column==s&&t.circularLinkType==l})).sort("bottom"==t.circularLinkType?Yg:jg),u=0,c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+i+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,o=t.target.x0,i=t.y1,r=(e+o)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+i+" "+o+","+i}(t)}),r}function Jg(t,e,n){t.sort(Hg);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,i){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(_g(t,e)&&Pg(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&tm(t,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;r=l>r?l:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function tm(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}import{min as em,max as nm,sum as om,mean as im,group as rm,groups as sm}from"d3-array";function am(t){return function(){return t}}function lm(t){return t.index}function cm(t){return t.nodes}function um(t){return t.links}function hm(t,e,n){var o=sm(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(i,r){var s=i.length;if(e)i.sort(e);else if(r>0){var a=new Map;i.forEach(function(t,e){var n,o,i,r=(o=0,i=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=Ig(t.source)*e,o+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=Ig(t.target)*e,o+=e}}),o>0?i/o:NaN);a.set(t,{bc:r,idx:e})}),i.sort(function(t,e){var n=a.get(t),o=a.get(e),i=n.bc,r=o.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(i)||isNaN(r)?isNaN(i)?isNaN(r)?n.idx-o.idx:1:-1:i-r})}else i.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Fg(e,n)-Fg(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});i.forEach(function(e,i){e.depth==o.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Fg(e,n)?(e.y0=t.y1/2+i,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+i,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-i,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*i,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+i,e.y1=e.y0+e.value*t.ky)})})}function dm(t,e,n,o,i,r){var s=sm(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,l=r;l>0;--l)c(a*=.99,n),u();function c(e,n){var o=s.length;s.forEach(function(i){var r=i.length,s=i[0].depth;i.forEach(function(i){var a;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Fg(i,n)>0){var l=im(i.sourceLinks,Dg),c=im(i.targetLinks,zg),u=l&&c?(l+c)/2:l||c;if(u){var h=(u-Ig(i))*e*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==r)i.y0=t.y1/2-(a=i.y1-i.y0)/2,i.y1=t.y1/2+a/2;else if(s==o-1&&1==r)i.y0=t.y1/2-(a=i.y1-i.y0)/2,i.y1=t.y1/2+a/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)a=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+a;else{var d=im(i.sourceLinks,Dg),f=im(i.targetLinks,zg),p=((d&&f?(d+f)/2:d||f)-Ig(i))*e;i.y0+=p,i.y1+=p}})})}function u(){s.forEach(function(n){var r,s,a,l=t.y0,c=n.length;for(n.sort(e||Xg),a=0;c>a;++a)(s=l-(r=n[a]).y0)>0&&(r.y0+=s,r.y1+=s),l=r.y1+o;if((s=l-o-t.y1)>0)for(l=r.y0-=s,r.y1-=s,a=c-2;a>=0;--a)(s=(r=n[a]).y1+i-l)>0&&(r.y0-=s,r.y1-=s),l=r.y0})}}function fm(t){t.nodes.forEach(function(t){t.sourceLinks.sort(qg),t.targetLinks.sort(Gg)}),t.nodes.forEach(function(t){var e=t.y0,n=e,o=t.y1,i=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=i-t.width/2,i-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function pm(){var t=0,e=0,n=1,o=1,i=24,r=8,s=null,a=lm,l=Og,c=void 0,u=32,h=2,d=cm,f=um;function p(){var p={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=n,d.y1=o,d.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return rm(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var o=t.source,i=t.target;"object"!=typeof o&&(o=t.source=Sg(n,o)),"object"!=typeof i&&(i=t.target=Sg(n,i)),o.sourceLinks.push(t),i.targetLinks.push(t)})}(d,a),function(t,e){var n=0;if(null==e){for(var o=[],i=0;t.links.length>i;i++){var r=t.links[i],s=r.source.index,a=r.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var l=Ag(o);l.sort(function(t,e){return t.length-e.length});var c={};for(i=0;l.length>i;i++){var u=l[i].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||c[o]&&c[o][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(d,c),function(t,e){var n=0,o=0;t.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:o>n?"top":"bottom","top"==i.circularLinkType?n++:o++,t.nodes.forEach(function(t){$g(t,e)!=$g(i.source,e)&&$g(t,e)!=$g(i.target,e)||(t.circularLinkType=i.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),_g(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(om(t.sourceLinks,Bg),om(t.targetLinks,Bg)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(d),function(t,e,n){var o,i,r;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,i=[],r=0;o.length;++r,o=i,i=[])o.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>i.indexOf(t.target)&&!t.circular&&i.push(t.target)})});for(o=t.nodes,i=[],r=0;o.length;++r,o=i,i=[])o.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>i.indexOf(t.source)&&!t.circular&&i.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(d,c,l);var f=r;if(null!==s){var p=sm(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=nm(p,function(t){return t.length});y>1&&(f=Math.max(1,(o-e)*s/(y-1)))}(function(t,e,n){var o=sm(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var i=em(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/om(e,function(t){return t.value})});t.ky=i,t.links.forEach(function(e){e.width=e.value*t.ky});var r=nm(t.nodes,function(t){return t.column});t.nodes.forEach(r>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/r),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(d,f,i),hm(d,c,a),dm(d,c,a,f,f,u),fm(d),Qg(d,a,h,10,8),hm(d,c,a),dm(d,c,a,f,f,u),fm(d),Qg(d,a,h,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var o=n.links.filter(function(n){return $g(n.source,e)==$g(t,e)}),i=o.length;i>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Ug(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Tg(e,t);return t.y1-n}if(e.target.column>t.target.column)return Tg(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),o.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;i>r;r++)s+=o[r].width;e.y0=t.y1-s-e.width/2}})})}(d,a),function(t,e){let n=t;n.nodes.forEach(function(t){var o=n.links.filter(function(n){return $g(n.target,e)==$g(t,e)}),i=o.length;i>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Ug(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Lg(e,t);return t.y0-n}if(e.source.column>t.source.column)return Lg(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),o.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;i>r;r++)s+=o[r].width;e.y1=t.y1-s-e.width/2}})})}(d,a),function(t){var e=t.nodes,n=t.links,o=!1,i=!1;if(n.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(i=!0)}),0==o||0==i){let o=function(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0};var r=em(e,function(t){return t.y0}),s=nm(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);1>a?(e.forEach(function(t){t.y0=o(t.y0),t.y1=o(t.y1)}),n.forEach(function(t){t.y0=o(t.y0),t.y1=o(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=o(t.y0)-t.y0;t.y0=o(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(d),Qg(d,a,h,10,8)}(p),p}return p.update=function(t){return fm(t),Qg(t,a,h,10,8),t},p.nodeWidth=function(t){return arguments.length?(i=+t,p):i},p.nodePadding=function(t){return arguments.length?(r=+t,p):r},p.nodePaddingRatio=function(t){return arguments.length?(s=+t,p):s},p.nodes=function(t){return arguments.length?(d="function"==typeof t?t:am(t),p):d},p.links=function(t){return arguments.length?(f="function"==typeof t?t:am(t),p):f},p.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:am(t),p):a},p.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:am(t),p):l},p.nodeSort=function(t){return arguments.length?(c=t,p):c},p.iterations=function(t){return arguments.length?(u=+t,p):u},p.circularLinkGap=function(t){return arguments.length?(h=+t,p):h},p.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],n=+i[1][0],o=+i[1][1],p):[[t,e],[n,o]]},p.size=function(i){return arguments.length?(t=e=0,n=+i[0],o=+i[1],p):[n-t,o-e]},p}import{interpolateNumber as ym}from"d3-interpolate";import{line as gm,curveLinearClosed as mm}from"d3-shape";var xm=t=>{let e,n,o,i,r,s,a,l,c;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,i=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,a=ym(r,s),l=a(.5),c=a(.5),`M${e},${r}C${e},${l} ${n},${c} ${n},${s}L${o},${s}C${o},${c} ${i},${l} ${i},${r}Z`;const u=t.sankeyWidth/2,h=ym(t.source.x1,t.target.x0),{pathD:d}=Id({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:h(.5),cp2X:h(.5)});return d};function bm(t){const e=t.sankeyWidth/2,n=(t._circularWidth??t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const n=o.sourceX,i=o.sourceY,r=o.targetX,s=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-n))),l=Math.max(15,Math.min(40,.33*(r-o.leftFullExtent)));return`M${n},${i-e}L${n+a},${i-e}L${n+a},${i+e}L${n},${i+e}ZM${r},${s-e}L${r-l},${s-e}L${r-l},${s+e}L${r},${s+e}Z`}const i=o.sourceX,r=o.sourceY,s=o.targetX,a=o.targetY,l=o.rightFullExtent,c=o.leftFullExtent,u=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(n,15));return`M${i},${r-h*e}L${l},${r-h*e}L${l+n},${r-h*e+h*d}L${l+n},${u+h*n-h*d}L${l+n-d},${u+h*n}L${c-n+d},${u+h*n}L${c-n},${u+h*n-h*d}L${c-n},${a-h*e+h*d}L${c-n+d},${a-h*e}L${s},${a-h*e}L${s},${a+h*e}L${c+n},${a+h*e}L${c+n},${u-h*n}L${l-n},${u-h*n}L${l-n},${r+h*e}L${i},${r+h*e}Z`}var vm=new Set,wm=new WeakMap;function km(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=wm.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,wm.set(t,n);const o=new Proxy(t,{get(t,n,o){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;vm.has(t)||(vm.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,n,o)}});return n.set(e,o),o}var Sm={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(Eg))-1:0},justify:Og};function Am(t){return"string"==typeof t?t:t.id}var Mm={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,o){if(0===t.length)return;const i="vertical"===n.orientation?"down":"right",r=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,l=n.iterations??100,c=t.map(t=>({...t})),u=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let h;h="down"===i?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const d=pm().extent(h).links(u).nodes(c).nodeAlign(Sm[r]||Og).nodeId(t=>t.id).nodeWidth(s).iterations(l);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let t=1/0,e=-1/0,n=1/0,i=-1/0;for(const o of c)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),n>o.y0&&(n=o.y0),o.y1>i&&(i=o.y1);for(const o of u){if(!o.circular||!o.circularPathData)continue;const r=o.circularPathData,s=(o._circularWidth??o.width??0)/2;t>r.leftFullExtent-s&&(t=r.leftFullExtent-s),r.rightFullExtent+s>e&&(e=r.rightFullExtent+s),n>r.verticalFullExtent-s&&(n=r.verticalFullExtent-s),r.verticalFullExtent+s>i&&(i=r.verticalFullExtent+s)}const r=e-t,s=i-n,a=o[0],l=o[1];if(r>0&&s>0&&(0>t||0>n||e>a||i>l)){const e=Math.min(a/r,l/s),o=-t*e+(a-r*e)/2,i=-n*e+(l-s*e)/2;for(const t of c)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+i,t.y1=t.y1*e+i;for(const t of u)if(t.y0=t.y0*e+i,t.y1=t.y1*e+i,t.width=(t.width??0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+o,n.targetX=n.targetX*e+o,n.sourceY=n.sourceY*e+i,n.targetY=n.targetY*e+i,n.rightFullExtent=n.rightFullExtent*e+o,n.leftFullExtent=n.leftFullExtent*e+o,n.verticalFullExtent=n.verticalFullExtent*e+i,n.rightInnerExtent=n.rightInnerExtent*e+o,n.leftInnerExtent=n.leftInnerExtent*e+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+i,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+i,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const f=new Map;for(const e of t)f.set(e.id,e);for(const t of c){const e=f.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const p=new Map;for(const t of e)p.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of u){const e=Am(t.source),n=Am(t.target),o=p.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=t.width??0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=i;const r=f.get(e),s=f.get(n);r&&(o.source=r),s&&(o.target=s)}}},buildScene(t,e,n,o){const i="vertical"===n.orientation?"down":"right",r=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,l=n.edgeColorBy||"source",c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:K,u=new Map;t.forEach((t,e)=>{u.set(t.id,c[e%c.length])});const h=[],d=[],f=[],p=new Map;for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const o=r?r(km(e,"nodeStyle")):{},s={fill:o.fill||u.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};p.set(e.id,("string"==typeof s.fill?s.fill:null)||u.get(e.id)||"#4d430c"),h.push("down"===i?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:s,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:s,datum:e,id:e.id,label:e.id})}const y=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of y){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let i=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";i="function"==typeof l?l(t)||i:"target"===l?p.get(o.id)||u.get(o.id)||i:p.get(e.id)||u.get(e.id)||i;const r=s?s(km(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=r.fill||i;d.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+o},${e.sourceY-n}L${e.sourceX+o},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:l,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),d.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-s},${e.targetY-n}L${e.targetX-s},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:l,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let c;(c=t.circular&&t.circularPathData?bm(t):xm(t),c)&&d.push({type:"bezier",pathD:c,bezierCache:t.bezier,style:{fill:r.fill||i,fillOpacity:r.fillOpacity??a,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity},datum:t})}if(!1!==n.showLabels){const e=(g=n.nodeLabel)?"function"==typeof g?g:t=>t[g]||t.id:null;for(const n of t){const t=n.x1-n.x0,r=n.y1-n.y0;if(0>=t||0>=r)continue;const s=e?e(n):n.id;if(!s)continue;let a,l,c;"down"===i?(a=n.y0+(n.y1-n.y0)/2,l=n.x1+14,c="start"):(o[0]/2>n.x0+t/2?(a=n.x0-6,c="end"):(a=n.x1+6,c="start"),l=n.y0+r/2),f.push({x:a,y:l,text:s+"",anchor:"down"===i?"middle":c,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:h,sceneEdges:d,labels:f}}};import{forceSimulation as _m,forceCenter as Pm,forceX as Cm,forceY as Tm,forceLink as Lm,forceManyBody as Rm,forceCollide as $m}from"d3-force";import{scaleLinear as zm}from"d3-scale";var Dm={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,o){if(0===t.length)return;const i=n.forceStrength??.1,r=o[0]/2,s=o[1]/2,a=Math.max(.1,Math.min(1,Math.min(o[0],o[1])/200)),l=Math.min(.5,.06+1.8*(1-a)),c=n.__previousPositions;let u=0;const h=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=c?.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):h.push(e)}const d=u>0&&.3>=(t.length>0?h.length/t.length:1);if(d){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of h){const o=Im(t.id,e,n);if(o.length>0){let e=0,n=0;for(const t of o)e+=t.x,n+=t.y;const i=Bm(t.id),r=i%360*(Math.PI/180),s=(10+i%20)*a;t.x=e/o.length+s*Math.cos(r),t.y=n/o.length+s*Math.sin(r)}else{const e=Bm(t.id),n=e%360*(Math.PI/180),o=(15+e%30)*a;t.x=r+o*Math.cos(n),t.y=s+o*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const o=t[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(n+.5)*a,i=n*e;o.x=r+t*Math.cos(i),o.y=s+t*Math.sin(i)}}}const f=n.__skipForceSimulation||0===n.iterations?0:d?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),p=Fm(n.nodeSize,n.nodeSizeRange,t),y=t=>p(t);if(f>0){const c=new Map,u=new Map;for(const e of t)c.set(e.id,0),u.set(e.id,e);for(const t of e){const e="string"==typeof t.source?t.source:t.source.id,n="string"==typeof t.target?t.target:t.target.id;c.set(e,(c.get(e)??0)+1),c.set(n,(c.get(n)??0)+1)}const h=Lm().strength(t=>{const e=t.weight,n="string"==typeof t.target?t.target:t.target.id,o=Math.max(1,Math.min(c.get("string"==typeof t.source?t.source:t.source.id)??1,c.get(n)??1));return Math.min(2.5,(e&&e>0?Math.sqrt(e):1)*i/(.1*o))}).distance(t=>{const e="string"==typeof t.source?u.get(t.source):t.source,n="string"==typeof t.target?u.get(t.target):t.target,o=(e?y(e):0)+(n?y(n):0)+Math.max(6,12*a);return Math.max(16,40*a,o)}).id(t=>t.id),p=_m();if(void 0===n.random&&void 0===n.seed||p.randomSource(n.random??Pl(n.seed)),p.force("charge",Rm().strength(t=>{const e=c.get(t.id)??0;return-15*a*y(t)*Math.sqrt(e+1)})).force("collide",$m(t=>y(t)+3*a).strength(.9).iterations(2)).force("center",Pm(r,s).strength(.8)).force("x",Cm(r).strength(l)).force("y",Tm(s).strength(l)).force("bounds",function(t,e,n=2,o=.6){let i=[];const r=r=>{const s=o*Math.max(r,.2);for(const o of i){const i=o.x??t[0]/2,r=o.y??t[1]/2,a=o.vx??0,l=o.vy??0,c=e(o)+n,u=Math.min(t[0]/2,c),h=Math.max(t[0]/2,t[0]-c),d=Math.min(t[1]/2,c),f=Math.max(t[1]/2,t[1]-c),p=i+a,y=r+l;u>p?o.vx=a+(u-p)*s:p>h&&(o.vx=a+(h-p)*s),d>y?o.vy=l+(d-y)*s:y>f&&(o.vy=l+(f-y)*s)}};return r.initialize=t=>{i=t},r}(o,y)),p.nodes(t),e.length>0){const t=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));h.links(t),p.force("link",h)}d?p.alpha(.3):.1>p.alpha()&&p.alpha(1),p.stop();for(let t=0;f>t;++t)p.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=y(e),n=f>0?2:0,i=Math.min(o[0]/2,t+n),r=Math.min(o[1]/2,t+n);e.x=Math.max(i,Math.min(o[0]-i,e.x)),e.y=Math.max(r,Math.min(o[1]-r,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=g.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=g.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,o){const i=n.nodeStyle,r=n.edgeStyle,s=Fm(n.nodeSize,n.nodeSizeRange,t),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:K,l=new Map;t.forEach((t,e)=>{l.set(t.id,a[e%a.length])});const c=[],u=[],h=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=s(km(e,"nodeSize")),o=i?i(km(e,"nodeStyle")):{},r={fill:o.fill||l.get(e.id)||n.themeSemantic?.primary||"#007bff",stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??2,opacity:o.opacity};c.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const d=new Map;for(const e of t)d.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:d.get(t.source),o="object"==typeof t.target?t.target:d.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const i=r?r(km(t,"edgeStyle")):{};u.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:{stroke:i.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.6},datum:t})}if(!1!==n.showLabels){const e=(f=n.nodeLabel)?"function"==typeof f?f:t=>t[f]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const o=s(km(n,"nodeSize"));h.push({x:n.x,y:n.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:c,sceneEdges:u,labels:h}}};function Im(t,e,n){const o=[];for(const i of e){const e="string"==typeof i.source?i.source:i.source.id,r="string"==typeof i.target?i.target:i.target.id;let s=null;if(e===t?s=r:r===t&&(s=e),s){const t=n.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function Bm(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return Math.abs(e)}function Fm(t,e,n){if(n.some(t=>null!=t.__forceRadius))return t=>t.__forceRadius??8;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const o=e||[5,20],i=[];for(const e of n){const n=e.data?.[t];"number"==typeof n&&i.push(n)}if(0===i.length)return()=>o[0];const[r,s]=S(i);if(r===s)return()=>(o[0]+o[1])/2;const a=zm().domain([r,s]).range(o).clamp(!0);return e=>{const n=e.data?.[t];return null==n||"number"!=typeof n?o[0]:a(n)}}import{chord as Em,ribbon as Om}from"d3-chord";import{arc as Nm}from"d3-shape";var Wm=K,jm={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,o){if(0===t.length)return;const{padAngle:i=.01,groupWidth:r=20,sortGroups:s}=n,a=Math.min(o[0],o[1])/2,l=a-r,c=o[0]/2,u=o[1]/2,h=(d=n.valueAccessor)?"function"==typeof d?d:t=>t[d]??1:t=>t.value??1;var d;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const p=t.length,y=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),o=f.get(e);if(void 0===n||void 0===o)continue;const i=h(t);y[n][o]=i}const g=Em().padAngle(i);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=Nm().innerRadius(l).outerRadius(a);for(const e of x){const n=t[e.index],o=b.centroid({innerRadius:l,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});n.x=o[0]+c,n.y=o[1]+u,n.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=v.get("string"==typeof t.source?t.source:t.source.id),o=v.get(e);n&&(t.source=n),o&&(t.target=o)}const w=new Map;for(const t of e)w.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const n=t[e.source.index].id,o=t[e.target.index].id,i=w.get(`${n}\0${o}`)||w.get(`${o}\0${n}`);i&&(i.__chordData=e)}},buildScene(t,e,n,o){const{groupWidth:i=20,edgeOpacity:r=.5}=n,s=Math.min(o[0],o[1])/2,a=s-i,l=o[0]/2,c=o[1]/2,u=n.nodeStyle,h=n.edgeStyle,d=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Wm,p=new Map;t.forEach((t,e)=>{p.set(t.id,f[e%f.length])});const y=Om().radius(a),g=[],m=[],x=[];for(let e=0;t.length>e;e++){const n=t[e],o=n.__arcData;if(!o)continue;let i;i=u?u(km(n,"nodeStyle")).fill||p.get(n.id)||f[e%f.length]:p.get(n.id)||f[e%f.length];const r=u?u(km(n,"nodeStyle")):{};g.push({type:"arc",cx:l,cy:c,innerR:a,outerR:s,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:{fill:i,stroke:r.stroke||"black",strokeWidth:r.strokeWidth??1,opacity:r.opacity},datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const o=y(e);if(!o)continue;const i=Ym(o,l,c);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(h)s=h(km(t,"edgeStyle")).fill||s;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===d&&n?s=p.get(n.id)||s:e&&(s=p.get(e.id)||s)}const a=h?h(km(t,"edgeStyle")):{};m.push({type:"ribbon",pathD:i,style:{fill:s,fillOpacity:a.fillOpacity??r,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:t})}if(!1!==n.showLabels){const e=(b=n.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null,o=s+12;for(const n of t){const t=n.__arcData;if(!t)continue;const i=e?e(n):n.id;if(!i)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;x.push({x:l+Math.cos(s)*o,y:c+Math.sin(s)*o,text:i+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:g,sceneEdges:m,labels:x}}};function Ym(t,e,n){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const i=[];let r=0;for(;o.length>r;){const t=o[r];if("M"===t||"L"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("C"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;3>t&&o.length>r&&!isNaN(Number(o[r]));t++)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("Q"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;2>t&&o.length>r&&!isNaN(Number(o[r]));t++)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("A"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&(i.push(Number(o[r])+e+""),r++),o.length>r&&(i.push(Number(o[r])+n+""),r++);else"Z"===t||"z"===t?(i.push(t),r++):(i.push(o[r]),r++)}return i.join(" ")}import{hierarchy as Gm,tree as qm,cluster as Xm,treemap as Hm,pack as Vm,partition as Um,treemapBinary as Km}from"d3-hierarchy";var Zm=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Qm(t){const[e,n,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*o>150?"#222":"#fff"}function Jm(t,e,n){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function tx(t){if(!t)return null;if("function"==typeof t){const e=t;return t=>e(t.data??t)}return e=>e.data?.[t]||e[t]||e.id}function ex(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Zm}function nx(t){return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:t.themeSemantic?.primary?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function ox(t,e,n,o,i){if("horizontal"===i){const i=(t+n)/2;return`M ${t},${e} C ${i},${e} ${i},${o} ${n},${o}`}if("radial"===i){const i=(t+n)/2;return`M ${t},${e} Q ${i},${e} ${i},${(e+o)/2} T ${n},${o}`}{const i=(e+o)/2;return`M ${t},${e} C ${t},${i} ${n},${i} ${n},${o}`}}var ix={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,o){const i=n.__hierarchyRoot;if(!i)return;const r=n.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),a=n.hierarchySum,l="function"==typeof a?a:"string"==typeof a?t=>Number(t[a])||0:t=>Number(t.value)||0,c=Gm(i,s);c.sum(l),c.sort((t,e)=>(e.value??0)-(t.value??0));const[u,h]=o;switch(r){case"tree":!function(t,e,n,o){const i=e.treeOrientation||"vertical",r=qm();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(t)}(c,n,u,h);break;case"cluster":!function(t,e,n,o){const i=e.treeOrientation||"vertical",r=Xm();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(t)}(c,n,u,h);break;case"treemap":!function(t,e,n,o){const i=e.padding??4,r=e.paddingTop??0,s=Hm().size([n,o]).tile(Km).padding(i);r>0&&s.paddingTop(r),s(t)}(c,n,u,h);break;case"circlepack":!function(t,e,n,o){const i=e.padding??4;Vm().size([n,o]).padding(i)(t)}(c,n,u,h);break;case"partition":!function(t,e,n,o){Um().size([n,o]).padding(e.padding??1)(t)}(c,n,u,h)}const d=c.descendants();t.length=0,e.length=0;const f=new Map;for(let e=0;d.length>e;e++){const o=d[e],i={id:Jm(o,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:o.value??0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===r||"cluster"===r?rx(i,o,n):"treemap"===r||"partition"===r?sx(i,o):"circlepack"===r&&ax(i,o),i.__hierarchyNode=o,t.push(i),f.set(o,i)}if("tree"===r||"cluster"===r)for(const t of d)if(t.parent){const n=f.get(t.parent),o=f.get(t);n&&o&&e.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,o){const i=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,o,i,r){const s=[],a=[],l=[],c=n.treeOrientation||"vertical",u="radial"===c,h=o[0]/2,d=o[1]/2,f="number"==typeof(p=n.nodeSize)?p:5;var p;for(const e of t){let t=e.x,o=e.y;u&&(t+=h,o+=d);const r=i(km(e,"nodeStyle"));let a=r.fill||nx(n);if(n.colorByDepth&&void 0!==e.depth){const t=ex(n);a=t[e.depth%t.length]}s.push({type:"circle",cx:t,cy:o,r:f,style:{fill:a,stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity},datum:e,id:e.id,label:e.id,depth:e.depth})}const y=n.edgeOpacity??.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let i=e.x,s=e.y,l=o.x,f=o.y;u&&(i+=h,s+=d,l+=h,f+=d);const p=ox(i,s,l,f,c),g=r(km(t,"edgeStyle"));a.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y},datum:t})}if(!1!==n.showLabels){const e=tx(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let o,i,r,s=n.x,a=n.y;if(u&&(s+=h,a+=d),u){const t=s-h,e=a-d,n=Math.sqrt(t*t+e*e);n>0?(o=s+t/n*10,i=a+e/n*10,r=0>t?"end":"start"):(o=s,i=a-12,r="middle")}else"horizontal"===c?(n.data?.children&&0!==n.data.children.length?(o=s-f-6,r="end"):(o=s+f+6,r="start"),i=a):(o=s,i=a+f+14,r="middle");l.push({x:o,y:i,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:l}}(t,e,n,o,i,r);case"treemap":case"partition":return function(t,e,n,o){const i=[],r=[];for(const n of t){const t=n.x1-n.x0,r=n.y1-n.y0;if(0>=t||0>=r)continue;const s=o(km(n,"nodeStyle"));let a=s.fill||nx(e);if(e.colorByDepth&&void 0!==n.depth){const t=ex(e);a=t[n.depth%t.length]}i.push({type:"rect",x:n.x0,y:n.y0,w:t,h:r,style:{fill:a,stroke:s.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=tx(e.nodeLabel),i=e.labelMode||"leaf",s="partition"===e.chartType;for(const a of t){const t=a.x1-a.x0,l=a.y1-a.y0;if(0>=t||0>=l)continue;const c=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===i&&!c)continue;if("parent"===i&&c)continue}const u=n?n(a):a.id;if(!u)continue;if((c?30:40)>t||(c?16:14)>l)continue;let h=o(km(a,"nodeStyle")).fill||nx(e);if(e.colorByDepth&&void 0!==a.depth){const t=ex(e);h=t[a.depth%t.length]}const d="string"==typeof h?Qm(h):e.themeSemantic?.text??"#000";r.push(c?{x:a.x0+t/2,y:a.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,l)/6)),fill:d}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:i,sceneEdges:[],labels:r}}(t,n,0,i);case"circlepack":return function(t,e,n,o){const i=[],r=[];for(const n of t){const t=n.__radius??5;if(0>=t)continue;const r=o(km(n,"nodeStyle"));let s=r.fill||nx(e);if(e.colorByDepth&&void 0!==n.depth){const t=ex(e);s=t[n.depth%t.length]}i.push({type:"circle",cx:n.x,cy:n.y,r:t,style:{fill:s,stroke:r.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=tx(e.nodeLabel);for(const i of t){const t=i.__radius??5,s=n?n(i):i.id;if(!s)continue;if(15>t)continue;const a=!(i.data?.children&&i.data.children.length>0);let l=o(km(i,"nodeStyle")).fill||nx(e);if(e.colorByDepth&&void 0!==i.depth){const t=ex(e);l=t[i.depth%t.length]}if(a){const n="string"==typeof l?Qm(l):e.themeSemantic?.text??"#000";r.push({x:i.x,y:i.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else r.push({x:i.x,y:i.y-t+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:e.themeSemantic?.text||"#000",stroke:e.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:i,sceneEdges:[],labels:r}}(t,n,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function rx(t,e,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=e.x,o=e.y;t.x=o*Math.cos(n-Math.PI/2),t.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function sx(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function ax(t,e){const n=e.r??0;t.x=e.x,t.y=e.y,t.x0=e.x-n,t.x1=e.x+n,t.y0=e.y-n,t.y1=e.y+n,t.width=2*n,t.height=2*n,t.__radius=n}import{pie as lx}from"d3-shape";function cx(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}var ux={sankey:Mm,force:Dm,chord:jm,tree:ix,cluster:ix,treemap:ix,circlepack:ix,partition:ix,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,o){const i=n.__hierarchyRoot;i&&function(t,e,n,o,i){const r=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),s=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>(t[e]??"")+""}(n.nodeIDAccessor),a=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),l=n.orbitSize??2.95,c=n.orbitEccentricity??1,u="number"==typeof l?()=>l:l,h="number"==typeof c?()=>c:c,d=cx(n);d.metaMap.clear(),o.length=0,i.length=0;const f=new Map;function p(t){const e=f.get(t)??0;return f.set(t,e+1),0===e?t:`${t}__${e}`}const y=e[0]/2,g=e[1]/2,m=Math.min(e[0],e[1])/2*.85,x=p(s(t));o.push({id:x,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:t}),d.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,l,c,f,y,g){const m=r(e);if(!m?.length)return;const x=m.length;let b=0,v=0,w=0;for(;x>v;)v+=a[Math.min(w,a.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){const v=a[Math.min(x,a.length-1)],w=m.slice(k,k+v);if(!w.length)break;const S=(x+1)/b,A={id:n,depth:y,data:e,parentId:n},M=g?f/u(A)*S:f*S,_=lx().value(t=>{const e=r(t)?.length;return e?4:1}).sort(null)(w),P=h(A);for(let e=0;w.length>e;e++){const r=(_[e].startAngle+_[e].endAngle)/2,a=w[e],u=p(s(a)),h=l+M*Math.sin(r),f=c+M*Math.cos(r)*P;o.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),d.metaMap.set(u,{ring:M,angle:r,depth:y,parentId:n,eccentricity:P}),i.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(a,u,h,f,M,y+1,!0)}k+=v}}(t,x,y,g,m,1,!1)}(i,o,n,t,e)},buildScene(t,e,n,o){const i=n.nodeStyle,r=n.nodeSize,s="number"==typeof r?()=>r:"function"==typeof r?r:()=>6,a=[],l=[],c=[];if(!1!==n.orbitShowRings){const e=cx(n),o=new Map;for(const e of t)o.set(e.id,e);const i=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;i.has(n)||i.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:o}]of i)for(let i=0;r>i;i++){const a=i/r*Math.PI*2,c=(i+1)/r*Math.PI*2;l.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*o,x2:t+n*Math.sin(c),y2:e+n*Math.cos(c)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=s(km(e,"nodeSize")),o=i?i(km(e,"nodeStyle")):{};a.push({type:"circle",cx:e.x,cy:e.y,r:t,style:{fill:o.fill||n.themeSemantic?.primary||"#6366f1",stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??(0===(e.depth??0)?1:.85)},datum:e,id:e.id,label:e.id,depth:e.depth})}const u=new Map;for(const e of t)u.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:u.get(t.source),n="object"==typeof t.target?t.target:u.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&l.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=s(km(n,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(n):e?n.data?.[e]??n.id:n.id;c.push({x:n.x,y:n.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:l,labels:c}},tick:(t,e,n,o,i)=>!1!==n.orbitAnimated&&(function(t,e){const n=cx(e),o=e.orbitSpeed??.25,i=e.orbitRevolution??function(t){switch(t){case"decay":return t=>Math.pow(.6,t.depth??0);case"alternate":return t=>{const e=t.depth??0;return(e%2==0?1:-1)/(e+1)};default:return t=>1/((t.depth??0)+1)}}(e.orbitRevolutionStyle),r=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=o*(Math.PI/6),a=new Map;for(const e of t)a.set(e.id,e);for(const e of t){const t=n.metaMap.get(e.id);if(!t||!t.parentId)continue;const o=a.get(t.parentId);if(!o)continue;const l=t.angle+r*s*i({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=o.x+t.ring*Math.sin(l),e.y=o.y+t.ring*Math.cos(l)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)}};import{Fragment as hx,jsxs as dx}from"react/jsx-runtime";function fx(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}var px=new Set(["tree","cluster","treemap","circlepack","partition"]);function yx(t,e){const n=D(t.theme),o=t.chartType||"force",i=()=>ry({frameType:"network",width:r[0],height:r[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,nodeCount:0,edgeCount:0}),r=t.size||[500,500],s=Rs({top:20,right:20,bottom:20,left:20,...t.margin},t.title),a=Ts(t.title),l=t.showLegend?(()=>{const e="string"==typeof(n=t.colorBy)||"function"==typeof n?t.colorBy:void 0;var n;if(!e)return[];const o=q(t.nodes||[]);if(o.length>0)return xy(o,e);const i=Array.isArray(t.edges)?q(t.edges):[];if(0===i.length)return[];const r=fx(t.sourceAccessor,"source"),s=fx(t.targetAccessor,"target");return xy(Array.from(new Set(i.flatMap(t=>[r(t),s(t)]).filter(t=>null!=t).map(String))).map(t=>({id:t})),e)})():[];Fy(s,{props:t,categories:l,theme:n,size:r,hasTitle:a});const c=r[0]-s.left-s.right,u=r[1]-s.top-s.bottom,h=function(t){return ux[t]}(o);if(!h&&!t.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${o}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const d={chartType:o,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,labelMode:t.labelMode,colorBy:t.colorBy,colorScheme:t.colorScheme||n.colors.categorical,edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange,customNetworkLayout:t.customNetworkLayout,layoutConfig:t.layoutConfig};let f,p;if(px.has(o)){const o=t.data||t.edges;if(!o||Array.isArray(o))return e&&(e.evidence=i()),kg.renderToStaticMarkup(Ny(null,{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:c,innerHeight:u,idPrefix:t._idPrefix}));d.__hierarchyRoot=o,f=[],p=[]}else{const o=q(t.nodes||[]),a=Array.isArray(t.edges)?q(t.edges):[];if(0===o.length&&0===a.length)return e&&(e.evidence=i()),kg.renderToStaticMarkup(Ny(null,{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:c,innerHeight:u,idPrefix:t._idPrefix}));if(p=function(t,e){const n=fx(e.sourceAccessor,"source"),o=fx(e.targetAccessor,"target"),i=fx(e.valueAccessor,"value");return t.map(t=>({source:n(t)+"",target:o(t)+"",value:Number(i(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(a,d),0===o.length&&p.length>0){const t=new Set;for(const e of p){const n=Ry(e.source),o=Ry(e.target);n&&t.add(n),o&&t.add(o)}f=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else f=function(t,e){const n=fx(e.nodeIDAccessor,"id");return t.map(t=>({id:n(t)+"",x:t.x??0,y:t.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}))}(o,d)}let y=[],g=[],m=[],x=null;if(d.customNetworkLayout){const t=d.colorScheme,e=Np(t,n.colors.categorical,K),o=Wp(e,t),i={nodes:f,edges:p,dimensions:{width:c,height:u,plot:{x:0,y:0,width:c,height:u}},theme:{semantic:n.colors,categorical:[...e]},resolveColor:o,config:d.layoutConfig??{}},r=d.customNetworkLayout(i);y=r.sceneNodes??[],g=r.sceneEdges??[],m=r.labels??[],x=r.overlays??null}else if(h){h.computeLayout(f,p,d,[c,u]);const t=h.buildScene(f,p,d,[c,u]);y=t.sceneNodes,g=t.sceneEdges,m=t.labels}const b=I(n);for(const t of m)t.fill||(t.fill=b.text);const v=Sc({nodes:g,renderMode:t.renderMode,fallback:(t,e)=>function(t,e){switch(t.type){case"line":return ta("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity},"net-edge-"+e);case"bezier":{const n=t;return ta("path",{d:n.pathD,fill:Hs(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+e)}case"ribbon":{const n=t;return ta("path",{d:n.pathD,fill:Hs(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+e)}case"curved":{const n=t;return ta("path",{d:n.pathD,fill:Hs(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+e)}default:return null}}(t,e)}),w=Sc({nodes:y,renderMode:t.renderMode,fallback:(t,e)=>function(t,e){switch(t.type){case"circle":{const n=t,o=Zo(n.style.fill)?ti(n.style.fill,`net-circle-${e}-hatch`):void 0;return ea(Qs.Fragment,{children:[o&&ta("defs",{children:o}),ta("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:o?`url(#net-circle-${e}-hatch)`:Hs(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-circle-"+e)}case"rect":{const n=t,o=Zo(n.style.fill)?ti(n.style.fill,`net-rect-${e}-hatch`):void 0;return ea(Qs.Fragment,{children:[o&&ta("defs",{children:o}),ta("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:o?`url(#net-rect-${e}-hatch)`:Hs(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-rect-"+e)}case"arc":{const n=t,o=Js().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(Xs)||"",i=Zo(n.style.fill)?ti(n.style.fill,`net-arc-${e}-hatch`):void 0;return ea(Qs.Fragment,{children:[i&&ta("defs",{children:i}),ta("path",{d:o,transform:`translate(${n.cx},${n.cy})`,fill:i?`url(#net-arc-${e}-hatch)`:Hs(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-arc-"+e)}case"symbol":{const n=t,o=dn(n.symbolType,n.size,n.path);return ta("path",{d:o,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?Hs(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+e)}case"glyph":return Us(t,t.cx,t.cy,"net-glyph-"+(t.id??e));default:return null}}(t,e)});e&&(e.evidence=ry({frameType:"network",width:r[0],height:r[1],marks:[...w.map(({node:t})=>({type:"node:"+(t.type??"node")})),...v.map(({node:t})=>({type:"edge:"+(t.type??"edge")}))],title:t.title,description:t.description,annotations:t.annotations,nodeCount:w.length,edgeCount:v.length}));const k=v.map(t=>t.element),S=w.map(t=>t.element),A=m.map((t,e)=>function(t,e){return ta("text",{x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"var(--semiotic-text, #333)",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,children:t.text},"net-label-"+e)}(t,e)).filter(Boolean),M=t.annotations?_y({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{},layout:{width:c,height:u},theme:n,idPrefix:t._idPrefix}):null,_=Ey({props:t,categories:l,theme:n,size:r,margin:s,hasTitle:a});return kg.renderToStaticMarkup(Ny(dx(hx,{children:[t.backgroundGraphics,k,S,A,M,t.foregroundGraphics,x]}),{width:r[0],height:r[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:c,innerHeight:u,legend:_,idPrefix:t._idPrefix}))}import*as gx from"react-dom/server";import{geoPath as mx}from"d3-geo";import{quadtree as xx}from"d3-quadtree";import{geoMercator as bx,geoEqualEarth as vx,geoAlbersUsa as wx,geoOrthographic as kx,geoNaturalEarth1 as Sx,geoEquirectangular as Ax}from"d3-geo";var Mx={mercator:bx,equalEarth:vx,albersUsa:wx,orthographic:kx,naturalEarth:Sx,equirectangular:Ax};function _x(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Px(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Cx(t,e,n){return t?"function"==typeof t?{...n,...t(e)}:{...n,...t}:{...n}}function Tx(t,e){if(2>t.length)return[t];const n=.4*e,o=[];let i=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>n?(2>i.length||o.push(i),i=[r]):i.push(r)}return 2>i.length||o.push(i),o}function Lx(t,e,n=24){const o=e[0]-t[0],i=e[1]-t[1],r=Math.sqrt(o*o+i*i);if(0===r)return[t,e];const s=-i/r,a=o/r,l=Math.min(.3*r,80),c=(t[0]+e[0])/2+s*l,u=(t[1]+e[1])/2+a*l,h=[];for(let o=0;n>=o;o++){const i=o/n,r=1-i;h.push([r*r*t[0]+2*r*i*c+i*i*e[0],r*r*t[1]+2*r*i*u+i*i*e[1]])}return h}function Rx(t,e){if(2>t.length)return t;const n=e/2+1,o=[];for(let e=0;t.length>e;e++){const i=t[e];let r,s;0===e?(r=t[1][0]-i[0],s=t[1][1]-i[1]):e===t.length-1?(r=i[0]-t[e-1][0],s=i[1]-t[e-1][1]):(r=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(r*r+s*s)||1;o.push([i[0]+s/a*n,i[1]+-r/a*n])}return o}function $x(t,e,n,o,i){const r=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(r*r+s*s);if(0===a)return[t,e];const l=s/a,c=-r/a,u=i/2+1;return[[t[0]+l*u,t[1]+c*u],[e[0]+l*u,e[1]+c*u]]}import{scaleLinear as zx}from"d3-scale";var Dx=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ix=["scene-style","data-paint","accessibility","evidence"],Bx=(t,e)=>({retainedData:t,invalidations:e}),Fx=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ex=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ox=["scene-geometry","data-paint","accessibility","evidence"],Nx=["scene-style","data-paint","accessibility","evidence"],Wx=["overlay","accessibility","evidence"],jx=[],Yx={xAccessor:Bx("rebuild",Fx),yAccessor:Bx("rebuild",Fx),lineDataAccessor:Bx("rebuild",Fx),pointIdAccessor:Bx("rebuild",Ox),lineIdAccessor:Bx("rebuild",Ox),windowSize:Bx("rebuild",Fx),projection:Bx("preserve",Ex),projectionExtent:Bx("preserve",Ex),fitPadding:Bx("preserve",Ex),lineType:Bx("preserve",Ex),flowStyle:Bx("preserve",Ex),graticule:Bx("preserve",Ex),projectionTransform:Bx("preserve",Ex),customLayout:Bx("preserve",Ex),layoutConfig:Bx("preserve",Ex),layoutMargin:Bx("preserve",Ex),areaStyle:Bx("preserve",Nx),pointStyle:Bx("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:Bx("preserve",Nx),colorScheme:Bx("preserve",Nx),themeCategorical:Bx("preserve",Nx),themeDiverging:Bx("preserve",Nx),themeSemantic:Bx("preserve",Nx),themeSequential:Bx("preserve",Nx),decay:Bx("preserve",Nx),pulse:Bx("preserve",Nx),layoutSelection:Bx("preserve",Nx),annotations:Bx("preserve",Wx),autoPlaceAnnotations:Bx("preserve",Wx),clock:Bx("preserve",jx),transition:Bx("preserve",jx),introAnimation:Bx("preserve",jx),onLayoutError:Bx("preserve",jx)},Gx=Bx("preserve",Ex),qx=class{constructor(){this.tracker=new Gn}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},Dx)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Ix):this.recordNoop("restyle")}recordConfig(t,e={}){const n=function(t){let e="preserve";const n=new Set;for(const o of t){const t=Yx[o]??Gx;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)n.add(e)}return{retainedData:e,invalidations:n}}(t),o=new Set(n.invalidations);return e.retainedDataChanged&&o.add("data"),this.tracker.record({kind:"config",keys:t},o)}};import{geoDistance as Xx,geoGraticule as Hx,geoInterpolate as Vx}from"d3-geo";function Ux(t){if(null==t)return 0;if("number"==typeof t&&Number.isFinite(t)&&t>=0&&.5>t)return t;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${t+""}.`)}var Kx=class t{constructor(t){this.updateResults=new qx,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=function(t){return{...t,fitPadding:Ux(t.fitPadding)}}(t)}currentTime(){return this.config.clock?.()??Re()}getConfiguredWindowSize(){const t=this.config.windowSize??500;if(!Number.isInteger(t)||1>t)throw Error("GeoPipelineStore windowSize must be a positive integer");return t}retainNewestLines(t=this.getConfiguredWindowSize()){this.lineData.length>t&&(this.lineData=this.lineData.slice(-t))}resizeStreamingWindow(t){if(this.pointBuffer){const e=this.pointBuffer.toArray(),n=this.timestampBuffer?.toArray()??[],o=e.slice(-t),i=n.slice(-o.length),r=this.currentTime();this.pointBuffer=new ke(t),this.timestampBuffer=new ke(t),o.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(i[e]??r)})}this.retainNewestLines(t)}updateConfig(t){const e=function(t){return"fitPadding"in t?{...t,fitPadding:Ux(t.fitPadding)}:t}(t),n=this.config,o=this.getConfiguredWindowSize(),i=Object.keys(e).filter(t=>e[t]!==n[t]);this.config={...this.config,...e};const r=this.getConfiguredWindowSize(),s=this.streaming&&r!==o;s&&(this.resizeStreamingWindow(r),this.version++),"customLayout"in e&&!e.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(i,{retainedDataChanged:s})}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setAreas(t){this.areas=t,this.updateResults.recordData("replace",t.length)}setAreasWithResult(t){return this.setAreas(t),this.updateResults.last}setPoints(t){this.pointData=t.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",t.length)}setPointsWithResult(t){return this.setPoints(t),this.updateResults.last}setLines(t){this.lineData=t.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",t.length)}setLinesWithResult(t){return this.setLines(t),this.updateResults.last}initStreaming(t){void 0!==t&&t!==this.config.windowSize&&(this.config={...this.config,windowSize:t});const e=this.getConfiguredWindowSize(),n=this.pointBuffer?this.pointBuffer.toArray():this.pointData,o=this.timestampBuffer?.toArray()??[],i=n.slice(-e),r=o.slice(-i.length),s=this.currentTime();this.pointBuffer=new ke(e),this.timestampBuffer=new ke(e),i.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(r[e]??s)}),this.pointData=[],this.retainNewestLines(e),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();Rn(this.pointBuffer,t,this.timestampBuffer,e),this.lastIngestTime=e,this.updateResults.recordData("ingest",1)}pushPointWithResult(t){return this.pushPoint(t),this.updateResults.last}pushMany(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();for(const n of t)Rn(this.pointBuffer,n,this.timestampBuffer,e);this.lastIngestTime=e,this.updateResults.recordData("ingest",t.length)}pushManyWithResult(t){return this.pushMany(t),this.updateResults.last}pushLine(t){null!=t&&"object"==typeof t?(this.streaming||this.initStreaming(),this.lineData.push(t),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(t){if(!Array.isArray(t)||0===t.length)return void this.updateResults.recordNoop("ingest");const e=t.filter(t=>null!=t&&"object"==typeof t);if(0!==e.length){this.streaming||this.initStreaming();for(const t of e)this.lineData.push(t);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",e.length)}else this.updateResults.recordNoop("ingest")}removeLine(t){const{lineIdAccessor:e}=this.config;if(!e)throw Error("removeLine() requires lineIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]),i=[];return this.lineData=this.lineData.filter(t=>!o.has(n(t)+"")||(i.push(t),!1)),i.length>0?(this.version++,this.updateResults.recordData("remove",i.length)):this.updateResults.recordNoop("remove"),i}getLines(){return this.lineData.slice()}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(n(t)+"");$n(this.pointBuffer,this.timestampBuffer,t);const e=this.pointBuffer.remove(t);return e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(n(e)+"")||(t.push(e),!1)),t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(t){const e=this._customRestyle;if(e){for(const n of this.scene){const o=this._baseStyles.get(n)??n.style,i=e(n,t);n.style=i?{...o,...i}:o}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(t){const{config:e}=this,n=this.projection,o=this.geoPath,i=this.scales,r=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],l=this.scene;this.projection=function(t){if(!t)return vx();if("string"==typeof t){const e=Mx[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),vx())}if("object"==typeof t&&"type"in t){const e=Mx[t.type],n=e?e():vx();return t.rotate&&"rotate"in n&&n.rotate(t.rotate),t.center&&"center"in n&&n.center(t.center),n}return t}(e.projection),this.geoPath=mx(this.projection),this.fitProjection(t),this.geoPath=mx(this.projection);const c=this.projection;this.scales={projection:c,geoPath:this.geoPath,projectedPoint:(t,e)=>c([t,e]),invertedPoint:(t,e)=>c.invert?c.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(t);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=n,this.geoPath=o,this.scales=i,this.baseScale=r,this.baseTranslate=s,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,n=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>({...t,x:e,y:n}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&l.length>0&&this.startTransition(l),this.version++}}fitProjection(t){const e=this.projection,n=this.config,o=[...this.areas],i=_x(n.xAccessor,"lon"),r=_x(n.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const t=s.map(t=>[i(t),r(t)]);o.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const a=Px(n.lineDataAccessor);for(const t of this.lineData){const e=a(t);if(e&&e.length>0){const t=e.map(t=>[i(t),r(t)]);o.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==o.length){if(n.projectionExtent){const[[o,i],[r,s]]=n.projectionExtent;e.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[o,i],[o,s],[r,s],[r,i],[o,i]]]}})}else if(e.clipAngle&&(e.clipAngle()??0)>0){const o=n.fitPadding??0,i=Math.min(t.width,t.height);e.scale(i/2-i*o),e.translate([t.width/2,t.height/2])}else{const i=n.fitPadding??0,r=t.width*i,s=t.height*i;e.fitExtent([[r,s],[t.width-r,t.height-s]],{type:"FeatureCollection",features:o})}this.baseScale=e.scale(),this.baseTranslate=e.translate(),this.baseRotation=e.rotate?.()??[0,0,0]}}applyZoomTransform(t,e){const n=this.projection;if(!n)return;const o=this.geoPath,i=this.scales,r=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*t.k),n.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=mx(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const l=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(r),n.translate(s),this.currentZoom=a,this.geoPath=o,this.scales=i):(this.scene=[],this.rebuildQuadtree()):(this.scene=l,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const n=this.projection;if(!n)return;const o=this.geoPath,i=this.scales,r=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*t),n.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=mx(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const l=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(r),n.translate(s),this.currentZoom=a,this.geoPath=o,this.scales=i):(this.scene=[],this.rebuildQuadtree()):(this.scene=l,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const n=this.projection;if(!n||!n.rotate)return;const o=this.geoPath,i=this.scales,r=[...n.rotate()];n.rotate(t),this.geoPath=mx(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.rotate(r),this.geoPath=o,this.scales=i):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}hasProjection(){return null!=this.projection}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let e=0,n=0;for(const t of this.scene)"point"===t.type&&(n++,t.r>e&&(e=t.r));if(this._maxPointRadius=e,t.QUADTREE_THRESHOLD>=n)return void(this._quadtree=null);const o=Array(n);let i=0;for(const t of this.scene)"point"===t.type&&(o[i++]=t);this._quadtree=xx().x(t=>t.x).y(t=>t.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){this._customLayoutFailedThisBuild=!1;const{config:e}=this,n=this.projection,o=this.geoPath;if(e.customLayout&&this.scales){const n=e.layoutMargin??{top:0,right:0,bottom:0,left:0},o=Np(e.colorScheme,e.themeCategorical,kt),i={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:t.width,height:t.height,margin:n,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:e.themeSemantic??{},categorical:[...o]},resolveColor:Wp(o,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};let r;try{r=e.customLayout(i)}catch(t){const n=null!==this.lastCustomLayoutResult,o=vn("geo",t,n,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",t);try{e.onLayoutError?.(o)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return n?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const s=r.nodes??[];if(this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null,this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const t of s)this._baseStyles.set(t,t.style);this.restyleScene(e.layoutSelection??null)}return mn({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,function({config:t,projection:e,path:n,areas:o,points:i,lines:r,layout:s}){const a=_x(t.xAccessor,"lon"),l=_x(t.yAccessor,"lat"),c=[],u=function(t){return{fill:t.themeSemantic?.surface||"#e0e0e0",stroke:t.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(t),h=function(t){return{stroke:t.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(t),d=function(t){return{fill:t.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(t);if(t.graticule){const e=!0===t.graticule?{}:t.graticule,o=Hx();e.step&&o.step(e.step);const i=n(o())||"";i&&c.push({type:"geoarea",pathData:i,centroid:[s.width/2,s.height/2],bounds:[[0,0],[s.width,s.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of o){const o=n(e);if(!o)continue;const i=n.centroid(e),r=n.bounds(e),s=n.area(e);c.push({type:"geoarea",pathData:o,centroid:i,bounds:r,screenArea:s,style:Cx(t.areaStyle,e,u),datum:e,interactive:!0})}const f=Px(t.lineDataAccessor);for(const n of r){const o=f(n);if(!o||2>o.length)continue;let i=[];if("geo"===t.lineType){const t=Array(o.length);for(let e=0;o.length>e;e++)t[e]=[a(o[e]),l(o[e])];for(let n=0;t.length-1>n;n++){const o=t[n],r=t[n+1],s=Xx(o,r)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),l=Vx(o,r);for(let t=0;a>=t;t++){if(n>0&&0===t)continue;const o=e(l(t/a));null!=o&&i.push(o)}}}else for(let t=0;o.length>t;t++){const n=o[t],r=e([a(n),l(n)]);null!=r&&i.push(r)}if(2>i.length)continue;const r=Cx(t.lineStyle,n,h),u="number"==typeof r.strokeWidth?r.strokeWidth:1;2!==o.length||2>i.length||"arc"!==t.flowStyle?2!==o.length||2>i.length||"offset"!==t.flowStyle||(i="geo"===t.lineType?Rx(i,u):$x(i[0],i[i.length-1],0,0,u)):i=Lx(i[0],i[i.length-1]);const d=Tx(i,s.width);if(d.length>1)for(const t of d)2>t.length||c.push({type:"line",path:t,style:{...r,_edgeFade:!0},datum:n});else c.push({type:"line",path:2>i.length&&d[0]||i,style:r,datum:n})}const p=t.pointIdAccessor?"function"==typeof t.pointIdAccessor?t.pointIdAccessor:e=>e[t.pointIdAccessor]:null,y=e.clipAngle?e.clipAngle()??0:0,g=y>0?y*Math.PI/180:null,m=e.rotate?e.rotate():[0,0,0],x="function"==typeof e.center?e.center():[0,0],b=[(x[0]??0)-m[0],(x[1]??0)-m[1]];for(const n of i){const o=a(n),i=l(n);if(null!=g&&Xx([o,i],b)>g)continue;const r=e([o,i]);if(!r)continue;const s=t.pointStyle?t.pointStyle(n):{...d},u={type:"point",x:r[0],y:r[1],r:s.r||4,style:s,datum:n,pointId:p?p(n)+"":void 0};c.push(u)}return c}({config:e,projection:n,path:o,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:t})}applyCartogramTransform(t,e){const n=function(t,e,n,o){const i=t.filter(t=>"point"===t.type);if(2>i.length)return null;const r=e.strength??1;if(0===r)return null;const s=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:t=>t.id,a="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],l=i.find(t=>t.datum&&s(t.datum)+""==e.center+"");if(!l)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`),null;const c=l.x,u=l.y,h=i.map(t=>t.datum?a(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),d=w(h,1),f=Math.min(n.width,n.height)/2,p=zx().domain([0,d]).range([0,f]);o>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let e=t.length-1;e>=0;e--){const n=t[e];"geoarea"===n.type&&n.interactive&&t.splice(e,1)}for(const t of i){if(t===l)continue;if(!t.datum)continue;const e=Math.atan2(t.y-u,t.x-c),n=Math.sqrt((t.x-c)**2+(t.y-u)**2),o=a(t.datum),i=n+((isFinite(o)?p(o):n)-n)*r;t.x=c+Math.cos(e)*i,t.y=u+Math.sin(e)*i}const y=n.width/2,g=n.height/2,m=y-l.x,x=g-l.y;if(Math.abs(m)>.5||Math.abs(x)>.5)for(const t of i)t.x+=m,t.y+=x;const b={cx:y,cy:g,maxCost:d,availableRadius:f},v=t.filter(t=>"line"===t.type);if(v.length>0&&"fractional"!==e.lineMode){const t=new Map;for(const e of i)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of v){const n=e.datum?.source,o=e.datum?.target;if(n&&o){const i=t.get(n+""),r=t.get(o+"");i&&r&&(e.path=[i,r])}}}return b}(this.scene,t,e,this.areas.length);n&&(this.cartogramLayout=n)}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const n=this.scene.filter(t=>"point"===t.type);for(let o=0;n.length>o;o++){const i=$e(t,o,e);n[o]._decayOpacity=i,n[o].style={...n[o].style,opacity:i}}}applyPulse(t=this.currentTime()){const e=this.config.pulse;if(!e||!this.timestampBuffer)return!1;const n=this.scene.filter(t=>"point"===t.type),o=this.timestampBuffer.toArray(),i=e.color||"rgba(255,255,255,0.6)",r=e.glowRadius??4;let s=!1;for(let a=0;n.length>a&&o.length>a;a++){const l=De(e,o[a],t);s=Ie(n[a],l,i,r)||s}return s}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(t)}hasActivePulsesAt(t){return!!this.config.pulse&&Be(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(t){const e=this.config.transition?.duration??300;if(0>=e)return;const n=new Map;for(const e of t)"point"===e.type&&e.pointId&&n.set(e.pointId,[e.x,e.y]);const o=this.scene.filter(t=>"point"===t.type);let i=!1;for(const t of o)if(t.pointId){const e=n.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(i=!0))}for(const t of o)t.pointId&&!n.has(t.pointId)&&(t._targetOpacity=t.style?.opacity??1,t.style={...t.style,opacity:0},i=!0);i&&(this.activeTransition={startTime:this.currentTime(),duration:e})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=Te(t,this.activeTransition),n=Ce(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=Le(t.x,t._targetX,n),t.y=Le(e,t._targetY,n)}null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity*n})}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0),null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity},t._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};Kx.QUADTREE_THRESHOLD=500;var Zx=Kx;Nn(Zx);import{Fragment as Qx,jsxs as Jx}from"react/jsx-runtime";function tb(t,e){const n=D(t.theme),o=t.size||[t.width||600,t.height||400],i=Rs({top:10,right:10,bottom:10,left:10,...t.margin},t.title),r=Ts(t.title),s=Array.isArray(t.areas)?q(t.areas):t.areas,a=q(t.points),l=q(t.lines),c=t.showLegend?(()=>{const e="string"==typeof(n=t.colorBy)||"function"==typeof n?t.colorBy:void 0;var n;return xy(a.length>0?a:Array.isArray(s)&&s.length>0?"string"==typeof e?s.map(t=>({...t.properties||{},...t})):s:[],e)})():[];Fy(i,{props:t,categories:c,theme:n,size:o,hasTitle:r});const u=o[0]-(i.left??0)-(i.right??0),h=o[1]-(i.top??0)-(i.bottom??0),d={projection:t.projection||"equalEarth",xAccessor:t.xAccessor,yAccessor:t.yAccessor,lineDataAccessor:t.lineDataAccessor,pointIdAccessor:t.pointIdAccessor,lineType:t.lineType,areaStyle:t.areaStyle,pointStyle:t.pointStyle,lineStyle:t.lineStyle,graticule:t.graticule,fitPadding:t.fitPadding,projectionTransform:t.projectionTransform,customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:i,themeCategorical:n.colors.categorical,themeSemantic:A(n)},f=new Zx(d);if(s){if("string"==typeof s)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${s}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${s}')\` before calling renderGeoToStaticSVG.`);f.setAreas(s)}t.points&&f.setPoints(a),t.lines&&f.setLines(l),f.computeScene({width:u,height:h});const p=Sc({nodes:f.scene,renderMode:t.renderMode,fallback:(t,e)=>function(t,e){switch(t.type){case"geoarea":{const n=t;if(!n.pathData)return null;const o=Zo(n.style.fill)?ti(n.style.fill,`geoarea-${e}-hatch`):void 0;return ia(na.Fragment,{children:[o&&oa("defs",{children:o}),oa("path",{d:n.pathData,fill:o?`url(#geoarea-${e}-hatch)`:Hs(n.style.fill,"#e0e0e0"),fillOpacity:n.style.fillOpacity??1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:n._decayOpacity??1})]},"geoarea-"+e)}case"point":{const n=t,o=Zo(n.style.fill)?ti(n.style.fill,`geopoint-${e}-hatch`):void 0;return ia(na.Fragment,{children:[o&&oa("defs",{children:o}),oa("circle",{cx:n.x,cy:n.y,r:n.r,fill:o?`url(#geopoint-${e}-hatch)`:Hs(n.style.fill),fillOpacity:n.style.fillOpacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n._decayOpacity??n.style.opacity??1})]},"point-"+e)}case"line":{const n=t;if(2>n.path.length)return null;const o="M"+n.path.map(t=>`${t[0]},${t[1]}`).join("L");return oa("path",{d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||1.5,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity??1},"line-"+e)}case"glyph":return Us(t,t.x,t.y,"geo-glyph-"+(t.pointId??e));default:return null}}(t,e)});if(e&&(e.evidence=ry({frameType:"geo",width:o[0],height:o[1],marks:p.map(t=>t.node),title:t.title,description:t.description,annotations:t.annotations,legendItems:c.length>0?c.length:void 0})),0===p.length){const e=t.backgroundGraphics||t.foregroundGraphics||t.annotations||f.customLayoutOverlays?Jx(Qx,{children:[t.backgroundGraphics,t.annotations?_y({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([t,e])=>f.scales.projectedPoint(t,e):void 0},layout:{width:u,height:h},theme:n,idPrefix:t._idPrefix}):null,t.foregroundGraphics,f.customLayoutOverlays]}):null;return gx.renderToStaticMarkup(Ny(e,{width:o[0],height:o[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${i.left??0},${i.top??0})`,innerWidth:u,innerHeight:h,idPrefix:t._idPrefix}))}const y=p.map(t=>t.element),g=t.annotations?_y({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([t,e])=>f.scales.projectedPoint(t,e):void 0},layout:{width:u,height:h},theme:n,idPrefix:t._idPrefix}):null,m=Ey({props:t,categories:c,theme:n,size:o,margin:i,hasTitle:r});return gx.renderToStaticMarkup(Ny(Jx(Qx,{children:[t.backgroundGraphics,y,g,t.foregroundGraphics,f.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${i.left??0},${i.top??0})`,innerWidth:u,innerHeight:h,legend:m,idPrefix:t._idPrefix}))}import*as eb from"react-dom/server";function nb(t=[]){return t.map(t=>({id:t.id,label:t.label,count:t.count,...null!=t.secondary?{secondary:t.secondary}:{},...t.secondaryLabel?{secondaryLabel:t.secondaryLabel}:{},...null!=t.observed?{observed:t.observed}:{}}))}var ob={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function ib(t){const e=t.datum;if(e&&"object"==typeof e){const t=e.label??e.name??e.id;if(null!=t&&""!==t)return t+""}return t.id}function rb(t,e){const n="function"==typeof e?e(t):e;return{...ob,...n??{}}}function sb(t,e={}){return t.map(t=>function(t,e={}){const n=function(t){return t.datum&&"object"==typeof t.datum?t.datum:null}(t),o={label:e.getBodyLabel?.(t)??ib(t)},i={style:rb(t,e.bodyStyle),datum:n,accessibleDatum:n,accessibility:o,_transitionKey:t.id};return"aabb"===t.shape.type?{type:"rect",x:t.x-t.shape.width/2,y:t.y-t.shape.height/2,w:t.shape.width,h:t.shape.height,...i}:{type:"point",x:t.x,y:t.y,r:t.shape.radius,pointId:t.id,...i}}(t,e))}import{jsx as ab,jsxs as lb}from"react/jsx-runtime";function cb(t,e){const n=t.size??[t.width??600,t.height??400],o=new Sp(t.config);Array.isArray(t.initialSpawns)&&t.initialSpawns.length>0&&o.enqueue(t.initialSpawns.map(t=>({...t,spawnAt:void 0})));const i=function(t,e={}){const{width:n=640,height:o=360,title:i,description:r,background:s,className:a,idPrefix:l="physics",...c}=e,u=function(t,e={}){const n=t.settle(e.maxSteps),o=t.readBodies(),i=t.snapshot(),r=sb(o,e),s=function(t,e={}){const n=e.bodies??function(t){return t.world.bodies.map(t=>({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:{...t.shape},sleeping:t.sleeping,datum:t.datum}))}(t),o=n.filter(t=>t.sleeping).length;return{bodyCount:n.length,sleepingCount:o,settled:"settled"===t.simulationState&&0===t.queue.length&&o===n.length,stepsRun:Math.max(0,Math.floor(e.stepsRun??0)),seed:t.world.options.seed,binCounts:nb(e.projectionRows)}}(i,{bodies:o,projectionRows:e.projectionRows,stepsRun:n});return{snapshot:i,bodies:o,sceneNodes:r,evidence:s,stepsRun:n}}(t,c),h=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"physics-"+e:e}(l),d=i?h+"-title":void 0,f=r?h+"-desc":void 0,p=[d,f].filter(Boolean).join(" ")||void 0;return{svg:eb.renderToStaticMarkup(lb("svg",{xmlns:"http://www.w3.org/2000/svg",className:a??"stream-physics-frame",width:n,height:o,viewBox:`0 0 ${n} ${o}`,role:"img","aria-labelledby":p,children:[i&&ab("title",{id:d,children:i}),r&&ab("desc",{id:f,children:r}),s&&"transparent"!==s?ab("rect",{x:0,y:0,width:n,height:o,fill:s}):null,ab("g",{id:h+"-data-area",children:u.sceneNodes.map((t,e)=>ma(t,e,h))})]})),scene:u,evidence:u.evidence}}(o,{...t,width:n[0],height:n[1],idPrefix:t.idPrefix??t._idPrefix??"physics"});return e&&(e.evidence=ry({frameType:"physics",width:n[0],height:n[1],marks:i.scene.sceneNodes,title:t.title,description:t.description,annotations:[],extraWarnings:0===i.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),i.svg}import{Fragment as ub,jsx as hb,jsxs as db}from"react/jsx-runtime";function fb(t,e){switch(t){case"xy":return Gy(e);case"ordinal":return wg(e);case"network":return yx(e);case"geo":return tb(e);case"physics":return cb(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function pb(t){return Gy(t)}function yb(t){return wg(t)}function gb(t){return yx(t)}function mb(t){return tb(t)}var xb=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","innerRadius","centerContent","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout","autoPlaceAnnotations"],bb=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];function vb(t,e){const n={};for(const o of e)void 0!==t[o]&&(n[o]=t[o]);return n}function wb(t,e,n){return Sb(t,e).svg}function kb(t,e,n){const o={},{svg:i,frameType:r}=Sb(t,e,0,o),s=o.evidence??ry({frameType:r,width:"number"==typeof e.width?e.width:600,height:"number"==typeof e.height?e.height:400,marks:[],title:"string"==typeof e.title?e.title:void 0,description:"string"==typeof e.description?e.description:void 0,annotations:e.annotations,extraWarnings:["NO_EVIDENCE"]});return s.component=t,{svg:i,evidence:s}}function Sb(t,e,n,o){const i=ny[t];if(!i)throw Error(`Unknown chart component: "${t}". See CLAUDE.md for supported chart types.`);var r;const s=O(i.layout?.mode??("string"==typeof(r=e.mode)&&Object.prototype.hasOwnProperty.call(E,r)?e.mode:void 0),{...i.layout?.modeDefaults,...vb(e,bb)},i.layout?.primarySize),{data:a,theme:l,background:c,className:u,annotations:h,margin:d,colorScheme:f,colorBy:p,legendPosition:y,...g}=e,{width:m,height:x}=s,b=[m,x],v=g.frameProps||{},w=i.layout?.margin,k="function"==typeof w?w(e,s):w??s.marginDefaults,S=void 0!==d?d:v.margin,A=function(t){if(null==t)return;if("number"==typeof t)return{top:t,right:t,bottom:t,left:t};const e={};return"number"==typeof t.top&&(e.top=t.top),"number"==typeof t.right&&(e.right=t.right),"number"==typeof t.bottom&&(e.bottom=t.bottom),"number"==typeof t.left&&(e.left=t.left),e}(S),M="number"==typeof S?{top:S,right:S,bottom:S,left:S}:{...k,...A},_=vb(g,xb),P={...v,..._,theme:l,title:s.title,description:s.description,showAxes:s.showAxes,showLegend:s.showLegend,showLabels:s.showLabels,showGrid:s.showGrid,xLabel:s.xLabel,yLabel:s.yLabel,categoryLabel:s.categoryLabel,valueLabel:s.valueLabel,background:c,className:u,annotations:h,size:b,margin:M,__explicitMargin:S,__autoLegendMargin:!0,...void 0!==f&&{colorScheme:f},...void 0!==y&&{legendPosition:y},_idPrefix:g._idPrefix},C=i.buildProps(a,p,f,P,g);let T;switch(i.frameType){case"xy":T=Gy(C,o);break;case"ordinal":T=wg(C,o);break;case"network":T=yx(C,o);break;case"geo":T=tb(C,o);break;case"physics":T=cb(C,o)}const L=i.renderOverlay?.(C,{theme:D(l)});if(null!=L){const t=W.renderToStaticMarkup(hb(ub,{children:L}));T=T.replace("</svg>",t+"</svg>")}return{svg:T,frameType:i.frameType}}async function Ab(t,e,n={}){const{format:o="png",scale:i=1,background:r}=n;let s,a;s=["xy","ordinal","network","geo","physics"].includes(t)?fb(t,e):wb(t,e),r&&(s=s.replace(/<svg /,`<svg style="background:${r}" `));try{const t="sharp",e=await import(t);a=e.default??e}catch{throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const l=e.width||e.size?.[0]||600,c=e.height||e.size?.[1]||400,u=a(void 0!==globalThis.Buffer?globalThis.Buffer.from(s):(new TextEncoder).encode(s),{density:72*i}).resize(Math.round(l*i),Math.round(c*i));return"jpeg"===o?u.jpeg({quality:90}).toBuffer():u.png().toBuffer()}function Mb(t,e={}){const{title:n,subtitle:o,theme:i,width:r=1200,height:s,layout:a={},background:l}=e,c=I(D(i)),u=a.columns||2,h=a.gap??16;let d=0;n&&(d+=30),o&&(d+=20),d>0&&(d+=10);const f=Math.floor((r-h-h*(u-1))/u),p=[];let y=0,g=d+h,m=0;for(const e of t){const t=Math.min(e.colSpan||1,u),n=e.props.height||300;y+t>u&&(g+=m+h,y=0,m=0),p.push({chart:e,x:h/2+y*(f+h),y:g,w:f*t+h*(t-1),h:n}),m=Math.max(m,n),y+=t}const x=s||g+m+h,b=p.map((t,e)=>{const{chart:n,x:o,y:r,w:s,h:a}=t,l={...n.props,width:s,height:a,theme:i,_idPrefix:"chart-"+e};let c;return c=n.component?wb(n.component,l):n.frameType?fb(n.frameType,l):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,hb("g",{transform:`translate(${o},${r})`,children:hb("foreignObject",{width:s,height:a,children:hb("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:c}})})},"dashboard-chart-"+e)});return W.renderToStaticMarkup(db("svg",{xmlns:"http://www.w3.org/2000/svg",width:r,height:x,role:"img","aria-label":n||"Dashboard",style:{fontFamily:c.fontFamily},children:[n&&hb("title",{children:n}),l&&hb("rect",{x:0,y:0,width:r,height:x,fill:l}),n&&hb("text",{x:r/2,y:24,textAnchor:"middle",fontSize:c.titleSize+4,fontWeight:"bold",fill:c.text,fontFamily:c.fontFamily,children:n}),o&&hb("text",{x:r/2,y:n?46:20,textAnchor:"middle",fontSize:c.labelSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:o}),b]}))}import*as _b from"react-dom/server";import{Fragment as Pb,jsx as Cb,jsxs as Tb}from"react/jsx-runtime";function Lb(t,e,n,o={}){const{stepSize:i,windowSize:r,frameCount:s,xExtent:a,yExtent:l,transitionFrames:c=4,fps:u=12,easing:h="ease-out",decay:d}=o,f=n.width||600,p=n.height||400,y=D(n.theme),g={...n,...a&&{xExtent:a},...l&&{yExtent:l}};if(!e||0===e.length)return[];const m=i||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),x=[];for(let t=m;e.length>=t;t+=m)x.push(t);x[x.length-1]!==e.length&&x.push(e.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),v=Rs({top:20,right:20,bottom:30,left:40,...n.margin},n.title),w=f-v.left-v.right,k=p-v.top-v.bottom,S=[];if(b)for(let o=0;x.length>o;o++){const i=x[o],s=e.slice(r?Math.max(0,i-r):0,i),a={chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:n.projection||"vertical",oAccessor:n.oAccessor||n.categoryAccessor||"category",rAccessor:n.rAccessor||n.valueAccessor||"value",colorAccessor:n.colorAccessor||n.colorBy,stackBy:n.stackBy,groupBy:n.groupBy,barPadding:n.barPadding,innerRadius:n.innerRadius,normalize:n.normalize,bins:n.bins,colorScheme:n.colorScheme||y.colors.categorical,...d&&{decay:d}},l=new yg(a);l.ingest({inserts:s,bounded:!0}),l.computeScene({width:w,height:k}),l.scene.length>0&&S.push(Bb(l.scene,f,p,y,g))}else for(let o=0;x.length>o;o++){const i=x[o],s=e.slice(r?Math.max(0,i-r):0,i),m={chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:n.colorAccessor||n.colorBy,groupAccessor:n.groupAccessor||n.lineBy,lineDataAccessor:n.lineDataAccessor,xExtent:a,yExtent:l,colorScheme:n.colorScheme||y.colors.categorical,lineStyle:n.lineStyle,pointStyle:n.pointStyle,areaStyle:n.areaStyle,sizeAccessor:n.sizeAccessor||n.sizeBy,sizeRange:n.sizeRange,...d&&{decay:d},...c>0&&{transition:{duration:c*(1e3/u),easing:h}}},b=new ao(m);if(b.ingest({inserts:s,bounded:!0}),b.computeScene({width:w,height:k}),0===b.scene.length)continue;const v=b.scales?{y:b.scales.y}:void 0;if(S.push(Ib(b.scene,f,p,y,g,v)),c>0&&o>0&&b.activeTransition){const t=c*(1e3/u);for(let e=1;c>=e;e++)b.advanceTransition(b.activeTransition.startTime+e/c*t),S.push(Ib(b.scene,f,p,y,g,v))}}return S}function Rb(t,e,n={}){return e.map(e=>{try{return wb(t,{...n,...e})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width||e.width||600}" height="${n.height||e.height||400}"></svg>`}})}function $b(t,e,n){const o=e.size??[e.width??600,e.height??400],i=D(e.theme),r=I(i),s=e.background||i.colors.background,a=e.idPrefix??"physics-gif",l=e.title?`${a}-title-${n}`:void 0,c=e.description?`${a}-desc-${n}`:void 0,u=[l,c].filter(Boolean).join(" ")||void 0,h=sb(t.readBodies(),{bodyStyle:e.bodyStyle,getBodyLabel:e.getBodyLabel}),d=Tb("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className??"stream-physics-frame",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,role:"img","aria-labelledby":u,style:{fontFamily:r.fontFamily},children:[e.title&&Cb("title",{id:l,children:e.title}),e.description&&Cb("desc",{id:c,children:e.description}),s&&"transparent"!==s?Cb("rect",{x:0,y:0,width:o[0],height:o[1],fill:s}):null,Cb("g",{id:`${a}-frame-${n}`,children:h.map((t,e)=>ma(t,e,`${a}-${n}`))})]});return _b.renderToStaticMarkup(d)}function zb(t,e={}){const{fps:n=12,frameCount:o,durationSeconds:i=2,includeInitialFrame:r=!0,stepDt:s,stepsPerFrame:a,background:l}=e,c=Math.max(.001,s??t.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,n)/c)),h=o??Math.max(1,Math.ceil(i*Math.max(1,n))),d=l?{...t,background:l}:t,f=new Sp(t.config);t.initialSpawns?.length&&f.enqueue(t.initialSpawns,t.initialSpawnPacing);const p=[];for(r&&(f.tick(0),p.push($b(f,d,0)));h>p.length;){for(let t=0;u>t;t+=1)f.tick(c);p.push($b(f,d,p.length))}return p}function Db(t,e){const n=t.background||e.colors.background;return n&&"transparent"!==n?n:null}function Ib(t,e,n,o,i,r){const s=I(o),a=Rs({top:20,right:20,bottom:30,left:40,...i.margin},i.title),l=e-a.left-a.right,c=n-a.top-a.bottom,u=Db(i,o),h=i.renderMode,d=t.map((t,e)=>kc({node:t,index:e,renderMode:h,fallback:()=>ma(t,e)})).filter(Boolean),f=function(t,e,n,o,i,r){if(!t||0===t.length)return null;const s=I(o),a=[];for(let o=0;t.length>o;o++){const l=t[o];if("y-threshold"===l.type&&null!=l.value){let t=null;if(r)t=r(l.value);else if(i){const[e,o]=i,r=o-e;if(0===r)continue;t=n-(l.value-e)/r*n}if(null==t)continue;const c=l.color||s.primary,u=l.labelPosition||"right";a.push(Tb("g",{children:[Cb("line",{x1:0,y1:t,x2:e,y2:t,stroke:c,strokeWidth:l.strokeWidth??1.5,strokeDasharray:l.strokeDasharray||"6,4"}),l.label&&Cb("text",{x:"left"===u?4:"center"===u?e/2:e-4,y:20>t?Math.min(n-4,t+16):t-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:s.tickSize,fill:c,fontFamily:s.fontFamily,children:l.label})]},"ann-"+o))}}return a.length>0?Cb(Pb,{children:a}):null}(i.annotations,l,c,o,i.yExtent,r?.y),p="string"==typeof i.title?i.title:void 0,y="string"==typeof i.description?i.description:void 0,g=p?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[g,m].filter(Boolean).join(" ")||void 0;return _b.renderToStaticMarkup(Tb("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:n,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[p&&Cb("title",{id:g,children:p}),y&&Cb("desc",{id:m,children:y}),u&&Cb("rect",{x:0,y:0,width:e,height:n,fill:u}),Tb("g",{transform:`translate(${a.left},${a.top})`,children:[f,d]}),p&&Cb("text",{x:e/2,y:22,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:p})]}))}function Bb(t,e,n,o,i){const r=I(o),s=Rs({top:20,right:20,bottom:30,left:40,...i.margin},i.title),a="radial"===i.projection,l=a?s.left+(e-s.left-s.right)/2:s.left,c=a?s.top+(n-s.top-s.bottom)/2:s.top,u=Db(i,o),h=i.renderMode,d=t.map((t,e)=>kc({node:t,index:e,renderMode:h,fallback:()=>fa(t,e)})).filter(Boolean),f="string"==typeof i.title?i.title:void 0,p="string"==typeof i.description?i.description:void 0,y=f?"semiotic-title":void 0,g=p?"semiotic-desc":void 0,m=[y,g].filter(Boolean).join(" ")||void 0;return _b.renderToStaticMarkup(Tb("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:n,role:"img","aria-labelledby":m,style:{fontFamily:r.fontFamily},children:[f&&Cb("title",{id:y,children:f}),p&&Cb("desc",{id:g,children:p}),u&&Cb("rect",{x:0,y:0,width:e,height:n,fill:u}),Cb("g",{transform:`translate(${l},${c})`,children:d}),f&&Cb("text",{x:e/2,y:22,textAnchor:"middle",fontSize:r.titleSize,fontWeight:"bold",fill:r.text,fontFamily:r.fontFamily,children:f})]}))}async function Fb(t,e,n,o={}){const{fps:i=12,loop:r=!0,scale:s=1,background:a}=o,l=n.width||600,c=n.height||400,u=Lb(t,e,a?{...n,background:a}:n,o);if(0===u.length)throw Error("No frames generated — check that data is not empty");return Ob(u,l,c,{fps:i,loop:r,scale:s})}async function Eb(t,e={}){const{fps:n=12,loop:o=!0,scale:i=1}=e,r=t.size??[t.width??600,t.height??400],s=zb(t,e);if(0===s.length)throw Error("No physics frames generated");return Ob(s,r[0],r[1],{fps:n,loop:o,scale:i})}async function Ob(t,e,n,o={}){const{fps:i=12,loop:r=!0,scale:s=1}=o,a=Math.round(e*s),l=Math.round(n*s);let c,u,h,d;try{const t="sharp",e=await import(t);c=e.default??e}catch{throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=await import(t),n=[e,e.default].find(t=>"function"==typeof t?.GIFEncoder&&"function"==typeof t.quantize&&"function"==typeof t.applyPalette);if(!n)throw Error("gifenc did not expose its encoder functions");u=n.GIFEncoder,h=n.quantize,d=n.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc',{cause:t})}const f=Math.round(1e3/i),p=u();for(let e=0;t.length>e;e++){const n=t[e],o=await c(Buffer.from(n),{density:72*s}).resize(a,l).ensureAlpha().raw().toBuffer(),i=new Uint8Array(o),u=h(i,256),y=d(i,u);p.writeFrame(y,a,l,{palette:u,delay:f,repeat:r?0:-1})}return p.finish(),Buffer.from(p.bytes())}export{D as resolveTheme,I as themeStyles,fb as renderToStaticSVG,pb as renderXYToStaticSVG,yb as renderOrdinalToStaticSVG,gb as renderNetworkToStaticSVG,mb as renderGeoToStaticSVG,wb as renderChart,kb as renderChartWithEvidence,Ab as renderToImage,Mb as renderDashboard,Lb as generateFrameSVGs,Rb as generateFrameSequence,zb as generatePhysicsFrameSVGs,Fb as renderToAnimatedGif,Eb as renderPhysicsToAnimatedGif};